| | |
| | | import ( |
| | | "aps_crm/constvar" |
| | | "aps_crm/model" |
| | | "aps_crm/model/request" |
| | | "aps_crm/pkg/ecode" |
| | | "github.com/shopspring/decimal" |
| | | "gorm.io/gorm" |
| | |
| | | salesReturn.AmountTotal = decimal.Zero |
| | | for _, product := range salesReturn.Products { |
| | | salesReturn.AmountTotal = salesReturn.AmountTotal.Add(product.Amount.Mul(product.Price)) |
| | | product.Id = 0 |
| | | } |
| | | salesReturn.AmountShouldRefund = salesReturn.AmountTotal |
| | | err := model.NewSalesReturnSearch().Create(salesReturn) |
| | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (SalesReturnService) GetSalesReturnList(page, pageSize int, keywordType constvar.SalesReturnKeywordType, keyword string) ([]*model.SalesReturn, int64, int) { |
| | | func (SalesReturnService) GetSalesReturnList(params request.GetSalesReturnList, memberIds []int) ([]*model.SalesReturn, int64, int) { |
| | | // get contact list |
| | | contacts, total, err := model.NewSalesReturnSearch(). |
| | | SetKeywordType(keywordType). |
| | | SetKeyword(keyword). |
| | | SetPage(page, pageSize). |
| | | SetKeywordType(params.KeywordType). |
| | | SetKeyword(params.Keyword). |
| | | SetPage(params.Page, params.PageSize). |
| | | SetSourceId(params.SourceId). |
| | | SetSourceType(params.SourceType). |
| | | SetClientId(params.ClientId). |
| | | SetPreload(true). |
| | | SetMemberIds(memberIds). |
| | | FindAll() |
| | | if err != nil { |
| | | return nil, 0, ecode.SalesReturnListErr |