作者 陈志颖

fix:修复分红订单数量问题

... ... @@ -84,7 +84,7 @@ func (dividendsEstimateService *DividendsEstimateService) ListDividendsIncentive
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if dividendsOrder == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsOrderNumber))
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("分红订单%s不存在", orderGood.DividendsOrderNumber))
}
if err := dividendsIncentivesEstimateDto.LoadDto(orderGood, dividendsOrder.DividendsOrderNumber, dividendsOrder.DividendsOriginalOrderNum, dividendsOrder.CustomerName, dividendsOrder.Region.RegionName, dividendsOrder.OrderTime); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -96,7 +96,7 @@ func (dividendsEstimateService *DividendsEstimateService) ListDividendsIncentive
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if dividendsReturnedOrder == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsReturnedOrderNumber))
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("分红退货单%s不存在", orderGood.DividendsReturnedOrderNumber))
}
if err := dividendsIncentivesEstimateDto.LoadDto(orderGood, dividendsReturnedOrder.DividendsReturnedOrderNumber, dividendsReturnedOrder.OriginalOrderNum, dividendsReturnedOrder.DividendsReturnedCustomerName, dividendsReturnedOrder.Region.RegionName, dividendsReturnedOrder.OrderTime); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -628,7 +628,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单不存在")
}
if dividendsOrder == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsOrderNumber))
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("分红订单%s不存在", orderGood.DividendsOrderNumber))
}
// 分红订单产品预算
if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoods); err != nil {
... ... @@ -673,7 +673,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if dividendsReturnedOrder == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsReturnedOrderNumber))
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("分红退货单%s不存在", orderGood.DividendsReturnedOrderNumber))
}
// 分红退货单产品预算
if dividendsReturnedEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoods); err != nil {
... ...
... ... @@ -18,7 +18,7 @@ type OrderGoods struct {
// 订单产品单价
OrderGoodPrice float64 `json:"orderGoodPrice"`
// 订单产品数量
OrderGoodQuantity int64 `json:"orderGoodQuantity"`
OrderGoodQuantity float64 `json:"orderGoodQuantity"`
// 关联分红订单号
DividendsOrderNumber string `json:"dividendsOrderNumber"`
// 关联的共创合约编号
... ...
... ... @@ -488,7 +488,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
}
// 产品相关:产品名称,产品数量、产品价格、费用
quantity, err := strconv.ParseInt(dividendsOrder.OrderGoodQuantity, 10, 64)
quantity, err := strconv.ParseFloat(dividendsOrder.OrderGoodQuantity, 64)
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
... ... @@ -533,7 +533,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
}
} else { // 聚合同一笔订单产品
// 产品相关:产品名称,产品数量、产品价格、费用
quantity, err := strconv.ParseInt(dividendsOrder.OrderGoodQuantity, 10, 64)
quantity, err := strconv.ParseFloat(dividendsOrder.OrderGoodQuantity, 64)
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
... ...
... ... @@ -17,7 +17,7 @@ type OrderGoods struct {
// 订单产品单价
OrderGoodPrice float64 `cname:"订单产品单价" json:"orderGoodPrice"`
// 订单产品数量
OrderGoodQuantity int64 `cname:"订单产品数量" json:"orderGoodQuantity"`
OrderGoodQuantity float64 `cname:"订单产品数量" json:"orderGoodQuantity"`
// 关联分红订单号
DividendsOrderNumber string `cname:"关联分红订单号" json:"dividendsOrderNumber"`
// 关联的共创合约编号
... ...
... ... @@ -524,7 +524,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
}
// 产品相关:产品名称,退货数量、退货价格
quantity, err := strconv.ParseInt(dividendsReturnedOrder.OrderGoodQuantity, 10, 64)
quantity, err := strconv.ParseFloat(dividendsReturnedOrder.OrderGoodQuantity, 64)
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
... ... @@ -562,7 +562,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
}
} else { // 聚合同一笔订单产品
// 产品相关:产品名称,退货数量、退货价格
quantity, err := strconv.ParseInt(dividendsReturnedOrder.OrderGoodQuantity, 10, 64)
quantity, err := strconv.ParseFloat(dividendsReturnedOrder.OrderGoodQuantity, 64)
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
... ...
... ... @@ -18,7 +18,7 @@ type OrderGood struct {
// 订单产品单价
OrderGoodPrice float64 `json:"orderGoodPrice"`
// 订单产品数量
OrderGoodQuantity int64 `json:"orderGoodQuantity,string"`
OrderGoodQuantity float64 `json:"orderGoodQuantity,string"`
// 关联分红订单号
DividendsOrderNumber string `json:"dividendsOrderNumber"`
// 关联的分红退货单号
... ... @@ -66,7 +66,7 @@ func (orderGood *OrderGood) Update(data map[string]interface{}) error {
orderGood.OrderGoodPrice = orderGoodPrice.(float64)
}
if orderGoodQuantity, ok := data["orderGoodQuantity"]; ok {
orderGood.OrderGoodQuantity = orderGoodQuantity.(int64)
orderGood.OrderGoodQuantity = orderGoodQuantity.(float64)
}
if cooperationContractNumber, ok := data["cooperationContractNumber"]; ok {
orderGood.CooperationContractNumber = cooperationContractNumber.(string)
... ...
... ... @@ -47,7 +47,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创合约不存在")
}
if cooperationContract == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.CooperationContractNumber))
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("共创合约%s不存在", orderGood.CooperationContractNumber))
}
if orderGood.DividendsOrderNumber != "" {
// 获取分红订单
... ... @@ -60,7 +60,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单不存在")
}
if dividendsOrder == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsOrderNumber))
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("分红订单%s不存在", orderGood.DividendsOrderNumber))
}
// 匹配分红规则
var dividendsIncentivesRuleMatched *domain.DividendsIncentivesRule
... ... @@ -79,7 +79,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
for _, undertaker := range cooperationContract.Undertakers {
// 添加承接人分红预算信息详情
// TODO 使用decimal提高精度
undertakerDividendsAmount := (orderGood.OrderGoodAmount - orderGood.OrderGoodExpense) * dividendsIncentivesRuleMatched.DividendsIncentivesPercentage / 100
undertakerDividendsAmount := orderGood.OrderGoodAmount * dividendsIncentivesRuleMatched.DividendsIncentivesPercentage / 100
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
UserId: undertaker.UserId,
... ... @@ -90,7 +90,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
Roles: undertaker.Roles,
UserInfo: undertaker.UserInfo,
UserType: undertaker.UserType,
UserName: undertaker.UserName,
UserName: undertaker.UserInfo.UserName,
UserPhone: undertaker.UserPhone,
Status: undertaker.Status,
Company: undertaker.Company,
... ... @@ -101,7 +101,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
})
// 添加推荐人分红预算信息详情
if undertaker.Referrer != nil {
referrerDividendsAmount := (orderGood.OrderGoodAmount - orderGood.OrderGoodExpense) * dividendsIncentivesRuleMatched.ReferrerPercentage / 100
referrerDividendsAmount := orderGood.OrderGoodAmount * dividendsIncentivesRuleMatched.ReferrerPercentage / 100
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
UserId: undertaker.Referrer.UserId,
... ... @@ -112,7 +112,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
Roles: undertaker.Referrer.Roles,
UserInfo: undertaker.Referrer.UserInfo,
UserType: undertaker.Referrer.UserType,
UserName: undertaker.Referrer.UserName,
UserName: undertaker.Referrer.UserInfo.UserName,
UserPhone: undertaker.Referrer.UserPhone,
Company: undertaker.Referrer.Company,
},
... ... @@ -123,7 +123,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
}
// 添加关联业务员分红预算信息详情
if undertaker.Salesman != nil {
salesmanDividendsAmount := (orderGood.OrderGoodAmount - orderGood.OrderGoodExpense) * dividendsIncentivesRuleMatched.SalesmanPercentage / 100
salesmanDividendsAmount := orderGood.OrderGoodAmount * dividendsIncentivesRuleMatched.SalesmanPercentage / 100
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
UserId: undertaker.Salesman.UserId,
... ... @@ -134,7 +134,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
Roles: undertaker.Salesman.Roles,
UserInfo: undertaker.Salesman.UserInfo,
UserType: undertaker.Salesman.UserType,
UserName: undertaker.Salesman.UserName,
UserName: undertaker.Salesman.UserInfo.UserName,
UserPhone: undertaker.Salesman.UserPhone,
Company: undertaker.Salesman.Company,
},
... ... @@ -177,7 +177,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
Roles: undertaker.Roles,
UserInfo: undertaker.UserInfo,
UserType: undertaker.UserType,
UserName: undertaker.UserName,
UserName: undertaker.UserInfo.UserName,
UserPhone: undertaker.UserPhone,
Status: undertaker.Status,
Company: undertaker.Company,
... ... @@ -199,7 +199,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
Roles: undertaker.Referrer.Roles,
UserInfo: undertaker.Referrer.UserInfo,
UserType: undertaker.Referrer.UserType,
UserName: undertaker.Referrer.UserName,
UserName: undertaker.Referrer.UserInfo.UserName,
UserPhone: undertaker.Referrer.UserPhone,
Company: undertaker.Referrer.Company,
},
... ... @@ -221,7 +221,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
Roles: undertaker.Salesman.Roles,
UserInfo: undertaker.Salesman.UserInfo,
UserType: undertaker.Salesman.UserType,
UserName: undertaker.Salesman.UserName,
UserName: undertaker.Salesman.UserInfo.UserName,
UserPhone: undertaker.Salesman.UserPhone,
Company: undertaker.Salesman.Company,
},
... ...
... ... @@ -13,7 +13,7 @@ type OrderGood struct {
// 订单产品单价
OrderGoodPrice float64 `comment:"订单产品单价"`
// 订单产品数量
OrderGoodQuantity int64 `comment:"订单产品数量"`
OrderGoodQuantity float64 `comment:"订单产品数量"`
// 关联分红订单号
DividendsOrderNumber string `comment:"关联分红订单号"`
// 关联的分红退货单号
... ...