多笔立减金
This commit is contained in:
parent
b841ad3661
commit
05ba50661c
|
|
@ -7,8 +7,6 @@ import (
|
|||
"fmt"
|
||||
"github.com/go-kratos/kratos/v2/log"
|
||||
"gorm.io/gorm"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
err2 "voucher/api/err"
|
||||
v1 "voucher/api/v1"
|
||||
|
|
@ -187,45 +185,34 @@ func (biz *MultiBiz) RetryRunByMultiNotifyDataId(ctx context.Context, multiNotif
|
|||
|
||||
func (biz *MultiBiz) run(ctx context.Context, req *bo.WechatVoucherNotifyBo, mnd *bo.MultiNotifyDataBo, order *bo.OrderBo) error {
|
||||
|
||||
if req.PlainText.Status.IsUsed() {
|
||||
|
||||
if order.Status.IsUse() {
|
||||
|
||||
parts := strings.Split(order.Remark, "_")
|
||||
l := len(parts)
|
||||
|
||||
remark := "核销完成_"
|
||||
if l == 1 {
|
||||
remark = "核销完成_2"
|
||||
}
|
||||
if l == 2 {
|
||||
i, err := strconv.Atoi(parts[1])
|
||||
if err != nil {
|
||||
return fmt.Errorf("订单再次核销完成修改发生错误 error: %v", err)
|
||||
}
|
||||
remark = fmt.Sprintf("核销完成_%d", i+1)
|
||||
}
|
||||
|
||||
if err := biz.OrderRepo.MultiOverUsed(ctx, order.ID, req.PlainText.ConsumeInformation.ConsumeTime, remark); err != nil {
|
||||
return fmt.Errorf("订单再次核销完成修改发生错误 error: %v", err)
|
||||
}
|
||||
} else {
|
||||
if err := biz.OrderRepo.MultiOverUsed(ctx, order.ID, req.PlainText.ConsumeInformation.ConsumeTime, "核销完成_1"); err != nil {
|
||||
return fmt.Errorf("订单核销完成修改发生错误 error: %v", err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if err := biz.OrderRepo.MultiLastUsed(ctx, order.ID, req.PlainText.ConsumeInformation.ConsumeTime); err != nil {
|
||||
return fmt.Errorf("订单核销修改发生错误 error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
nl, err := biz.nlCreate(ctx, req, mnd, order)
|
||||
if err != nil {
|
||||
return fmt.Errorf("创建通知日志错误 error: %v", err)
|
||||
}
|
||||
|
||||
return biz.Request(ctx, mnd, nl, order)
|
||||
if err = biz.Request(ctx, mnd, nl, order); err != nil {
|
||||
return fmt.Errorf("请求错误 error: %v", err)
|
||||
}
|
||||
|
||||
if req.PlainText.Status.IsUsed() {
|
||||
|
||||
if order.Status.IsUse() {
|
||||
if err = biz.OrderRepo.MultiOverUsed(ctx, order.ID, req.PlainText.ConsumeInformation.ConsumeTime, "再次核销完成"); err != nil {
|
||||
return fmt.Errorf("订单再次核销完成修改发生错误 error: %v", err)
|
||||
}
|
||||
} else {
|
||||
if err = biz.OrderRepo.MultiOverUsed(ctx, order.ID, req.PlainText.ConsumeInformation.ConsumeTime, "核销完成"); err != nil {
|
||||
return fmt.Errorf("订单核销完成修改发生错误 error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if err = biz.OrderRepo.MultiLastUsed(ctx, order.ID, req.PlainText.ConsumeInformation.ConsumeTime); err != nil {
|
||||
return fmt.Errorf("订单核销修改发生错误 error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (biz *MultiBiz) mndCreate(ctx context.Context, ip, source string, req *bo.WechatVoucherNotifyBo, order *bo.OrderBo) (*bo.MultiNotifyDataBo, error) {
|
||||
|
|
|
|||
|
|
@ -462,6 +462,7 @@ func (p *OrderRepoImpl) MultiLastUsed(ctx context.Context, id uint64, lastUseTim
|
|||
}).
|
||||
Updates(model.Order{
|
||||
Remark: "核销",
|
||||
Status: vo.OrderStatusSuccess.GetValue(),
|
||||
LastUseTime: &lastUseTime,
|
||||
UpdateTime: &now,
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue