正在显示
2 个修改的文件
包含
8 行增加
和
9 行删除
@@ -59,6 +59,7 @@ func (OrderPaymentService *OrderPaymentService) CreateOrderPayment(command *comm | @@ -59,6 +59,7 @@ func (OrderPaymentService *OrderPaymentService) CreateOrderPayment(command *comm | ||
59 | return | 59 | return |
60 | } | 60 | } |
61 | var excludeIdList []int | 61 | var excludeIdList []int |
62 | + var bonusStatus int = domain.BonusPaid //分红状态 | ||
62 | excludeIdList = append(excludeIdList, 0) | 63 | excludeIdList = append(excludeIdList, 0) |
63 | for i := range command.DivdendPaymentItem { | 64 | for i := range command.DivdendPaymentItem { |
64 | paymentItem := command.DivdendPaymentItem[i] | 65 | paymentItem := command.DivdendPaymentItem[i] |
@@ -67,13 +68,15 @@ func (OrderPaymentService *OrderPaymentService) CreateOrderPayment(command *comm | @@ -67,13 +68,15 @@ func (OrderPaymentService *OrderPaymentService) CreateOrderPayment(command *comm | ||
67 | CreateAt: time.Now(), | 68 | CreateAt: time.Now(), |
68 | UpdateAt: time.Now(), | 69 | UpdateAt: time.Now(), |
69 | } | 70 | } |
70 | - if paymentItem.PaymentId > 0 && paymentItem.StateOfPayment == domain.BonusPaid { | ||
71 | - continue | 71 | + if bonusStatus == domain.BonusPaid && paymentItem.StateOfPayment == domain.BonusWaitPay { |
72 | + bonusStatus = domain.BonusWaitPay | ||
72 | } | 73 | } |
73 | if paymentItem.PaymentId > 0 { | 74 | if paymentItem.PaymentId > 0 { |
74 | //检查货款 已存在 / 未存在 | 75 | //检查货款 已存在 / 未存在 |
75 | if findDm, e := OrderPaymentRepository.FindOne(domain.OrderPaymentFindOneQuery{OrderId: command.OrderId, PaymentId: paymentItem.PaymentId}); e == nil { | 76 | if findDm, e := OrderPaymentRepository.FindOne(domain.OrderPaymentFindOneQuery{OrderId: command.OrderId, PaymentId: paymentItem.PaymentId}); e == nil { |
76 | - if findDm.BonusStatus == domain.BonusPaid { | 77 | + //状态更金额一样的时候 不做更新 |
78 | + if findDm.BonusStatus == paymentItem.StateOfPayment && findDm.PaymentAmount == paymentItem.PaymentForGoods { | ||
79 | + excludeIdList = append(excludeIdList, paymentItem.PaymentId) | ||
77 | continue | 80 | continue |
78 | } | 81 | } |
79 | dm = findDm | 82 | dm = findDm |
@@ -81,7 +84,7 @@ func (OrderPaymentService *OrderPaymentService) CreateOrderPayment(command *comm | @@ -81,7 +84,7 @@ func (OrderPaymentService *OrderPaymentService) CreateOrderPayment(command *comm | ||
81 | } | 84 | } |
82 | dm.PartnerId = orderBase["PartnerId"].(int64) | 85 | dm.PartnerId = orderBase["PartnerId"].(int64) |
83 | bonusPercent := orderBase["PartnerBonusPercent"].(float64) | 86 | bonusPercent := orderBase["PartnerBonusPercent"].(float64) |
84 | - dm.BonusAmount = paymentItem.PaymentForGoods * (bonusPercent / 100.0) | 87 | + dm.BonusAmount = utils.Decimal(paymentItem.PaymentForGoods * (bonusPercent / 100.0)) |
85 | dm.PaymentAmount = paymentItem.PaymentForGoods | 88 | dm.PaymentAmount = paymentItem.PaymentForGoods |
86 | dm.BonusStatus = paymentItem.StateOfPayment | 89 | dm.BonusStatus = paymentItem.StateOfPayment |
87 | dm.UpdateAt = time.Now() | 90 | dm.UpdateAt = time.Now() |
@@ -90,10 +93,7 @@ func (OrderPaymentService *OrderPaymentService) CreateOrderPayment(command *comm | @@ -90,10 +93,7 @@ func (OrderPaymentService *OrderPaymentService) CreateOrderPayment(command *comm | ||
90 | } | 93 | } |
91 | excludeIdList = append(excludeIdList, int(dm.Id)) | 94 | excludeIdList = append(excludeIdList, int(dm.Id)) |
92 | } | 95 | } |
93 | - var bonusStatus int = 1 | ||
94 | - if len(command.DivdendPaymentItem) > 0 { | ||
95 | - bonusStatus = command.DivdendPaymentItem[len(command.DivdendPaymentItem)-1].StateOfPayment | ||
96 | - } | 96 | + |
97 | if err = OrderPaymentDao.Remove(command.OrderId, domain.BonusWaitPay, excludeIdList); err != nil { | 97 | if err = OrderPaymentDao.Remove(command.OrderId, domain.BonusWaitPay, excludeIdList); err != nil { |
98 | return | 98 | return |
99 | } | 99 | } |
@@ -19,7 +19,6 @@ func (o *OrderPayment) Remove(orderId int64, status int, idList []int) error { | @@ -19,7 +19,6 @@ func (o *OrderPayment) Remove(orderId int64, status int, idList []int) error { | ||
19 | tx := o.transactionContext.PgTx | 19 | tx := o.transactionContext.PgTx |
20 | m := new(models.OrderPayment) | 20 | m := new(models.OrderPayment) |
21 | q := tx.Model(m).Where("order_id=?", orderId). | 21 | q := tx.Model(m).Where("order_id=?", orderId). |
22 | - Where("bonus_status=?", status). | ||
23 | WhereIn("id not in(?)", idList) | 22 | WhereIn("id not in(?)", idList) |
24 | _, err := q.Delete() | 23 | _, err := q.Delete() |
25 | return err | 24 | return err |
-
请 注册 或 登录 后发表评论