fix promotion
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"tyc-server/app/main/api/internal/service"
|
||||
"tyc-server/app/main/api/internal/svc"
|
||||
"tyc-server/app/main/api/internal/types"
|
||||
"tyc-server/app/main/model"
|
||||
"tyc-server/common/ctxdata"
|
||||
"tyc-server/common/xerr"
|
||||
|
||||
@@ -70,6 +71,26 @@ func (l *PaymentLogic) Payment(req *types.PaymentReq) (resp *types.PaymentResp,
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "生成订单失败: %+v", err)
|
||||
}
|
||||
|
||||
promoteKey, ok := l.ctx.Value("promoteKey").(string)
|
||||
if ok && promoteKey != "" {
|
||||
url := fmt.Sprintf("%s/%s", l.svcCtx.Config.AdminPromotion.URLDomain, promoteKey)
|
||||
promoteLink, err := l.svcCtx.AdminPromotionLinkModel.FindOneByUrl(l.ctx, url)
|
||||
if err != nil && !errors.Is(err, model.ErrNotFound) {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "生成订单, 查找推广链接失败: %+v", err)
|
||||
}
|
||||
if promoteLink != nil {
|
||||
promoteOrder := &model.AdminPromotionOrder{
|
||||
OrderId: orderResp.OrderID,
|
||||
LinkId: promoteLink.Id,
|
||||
UserId: userID,
|
||||
AdminUserId: promoteLink.AdminUserId,
|
||||
}
|
||||
_, insertPromoteOrderErr := l.svcCtx.AdminPromotionOrderModel.Insert(l.ctx, nil, promoteOrder)
|
||||
if insertPromoteOrderErr != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "生成订单, 保存推广订单失败: %+v", insertPromoteOrderErr)
|
||||
}
|
||||
}
|
||||
}
|
||||
return &types.PaymentResp{
|
||||
PrepayData: orderResp.PayData,
|
||||
PrepayId: orderResp.OrderNo,
|
||||
|
||||
Reference in New Issue
Block a user