...
|
...
|
@@ -59,6 +59,7 @@ func (OrderPaymentService *OrderPaymentService) CreateOrderPayment(command *comm |
|
|
return
|
|
|
}
|
|
|
var excludeIdList []int
|
|
|
var bonusStatus int = domain.BonusPaid //分红状态
|
|
|
excludeIdList = append(excludeIdList, 0)
|
|
|
for i := range command.DivdendPaymentItem {
|
|
|
paymentItem := command.DivdendPaymentItem[i]
|
...
|
...
|
@@ -67,13 +68,15 @@ func (OrderPaymentService *OrderPaymentService) CreateOrderPayment(command *comm |
|
|
CreateAt: time.Now(),
|
|
|
UpdateAt: time.Now(),
|
|
|
}
|
|
|
if paymentItem.PaymentId > 0 && paymentItem.StateOfPayment == domain.BonusPaid {
|
|
|
continue
|
|
|
if bonusStatus == domain.BonusPaid && paymentItem.StateOfPayment == domain.BonusWaitPay {
|
|
|
bonusStatus = domain.BonusWaitPay
|
|
|
}
|
|
|
if paymentItem.PaymentId > 0 {
|
|
|
//检查货款 已存在 / 未存在
|
|
|
if findDm, e := OrderPaymentRepository.FindOne(domain.OrderPaymentFindOneQuery{OrderId: command.OrderId, PaymentId: paymentItem.PaymentId}); e == nil {
|
|
|
if findDm.BonusStatus == domain.BonusPaid {
|
|
|
//状态更金额一样的时候 不做更新
|
|
|
if findDm.BonusStatus == paymentItem.StateOfPayment && findDm.PaymentAmount == paymentItem.PaymentForGoods {
|
|
|
excludeIdList = append(excludeIdList, paymentItem.PaymentId)
|
|
|
continue
|
|
|
}
|
|
|
dm = findDm
|
...
|
...
|
@@ -81,7 +84,7 @@ func (OrderPaymentService *OrderPaymentService) CreateOrderPayment(command *comm |
|
|
}
|
|
|
dm.PartnerId = orderBase["PartnerId"].(int64)
|
|
|
bonusPercent := orderBase["PartnerBonusPercent"].(float64)
|
|
|
dm.BonusAmount = paymentItem.PaymentForGoods * (bonusPercent / 100.0)
|
|
|
dm.BonusAmount = utils.Decimal(paymentItem.PaymentForGoods * (bonusPercent / 100.0))
|
|
|
dm.PaymentAmount = paymentItem.PaymentForGoods
|
|
|
dm.BonusStatus = paymentItem.StateOfPayment
|
|
|
dm.UpdateAt = time.Now()
|
...
|
...
|
@@ -90,10 +93,7 @@ func (OrderPaymentService *OrderPaymentService) CreateOrderPayment(command *comm |
|
|
}
|
|
|
excludeIdList = append(excludeIdList, int(dm.Id))
|
|
|
}
|
|
|
var bonusStatus int = 1
|
|
|
if len(command.DivdendPaymentItem) > 0 {
|
|
|
bonusStatus = command.DivdendPaymentItem[len(command.DivdendPaymentItem)-1].StateOfPayment
|
|
|
}
|
|
|
|
|
|
if err = OrderPaymentDao.Remove(command.OrderId, domain.BonusWaitPay, excludeIdList); err != nil {
|
|
|
return
|
|
|
}
|
...
|
...
|
|