cmb
This commit is contained in:
parent
09bf8b90fc
commit
803a8706b1
|
|
@ -65,19 +65,18 @@ func (v *VoucherBiz) CmbProductQuery(ctx context.Context, productNo string) (rep
|
|||
}
|
||||
|
||||
reps = &v1.CmbQueryProductReply{
|
||||
ActivityName: product.Name,
|
||||
ActivityId: product.ProductNo,
|
||||
|
||||
StartTime: *wechatResp.AvailableBeginTime,
|
||||
EndTime: *wechatResp.AvailableEndTime,
|
||||
Detail: *wechatResp.Description,
|
||||
|
||||
Amount: "",
|
||||
MinAmount: "",
|
||||
|
||||
AvailableStock: "",
|
||||
RespCode: vo.CmbResponseStatusSuccess.GetValue(),
|
||||
RespMsg: "成功",
|
||||
ActivityName: product.Name,
|
||||
ActivityId: product.ProductNo,
|
||||
Amount: "",
|
||||
MinAmount: "",
|
||||
AvailableType: "",
|
||||
AvailableDays: "", // 动态有效期天数
|
||||
StartTime: *wechatResp.AvailableBeginTime,
|
||||
EndTime: *wechatResp.AvailableEndTime,
|
||||
AvailableStock: "",
|
||||
Detail: *wechatResp.Description,
|
||||
}
|
||||
|
||||
reps.Amount = fmt.Sprintf("%d", *wechatResp.StockUseRule.FixedNormalCoupon.CouponAmount)
|
||||
|
|
|
|||
|
|
@ -34,8 +34,6 @@ func NewHTTPServer(
|
|||
return ctx.String(http2.StatusOK, "pong")
|
||||
})
|
||||
|
||||
r.POST("/v1/wechat/notify", voucherService.WechatNotify)
|
||||
|
||||
cmb := r.Group("/cmb")
|
||||
|
||||
cmb.POST("/v1/orderMock", voucherService.CmbOrderMock)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package service
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/go-kratos/kratos/v2/log"
|
||||
"github.com/go-kratos/kratos/v2/transport/http"
|
||||
v1 "voucher/api/v1"
|
||||
"voucher/internal/biz/bo"
|
||||
|
|
@ -12,29 +13,36 @@ func (s *VoucherService) CmbOrder(ctx http.Context) error {
|
|||
|
||||
var (
|
||||
reply *v1.CmbReply
|
||||
err error
|
||||
|
||||
bizReply *v1.CmbOrderReply
|
||||
)
|
||||
|
||||
orderNo, err := s.cmbOrder(ctx)
|
||||
|
||||
if err != nil {
|
||||
reply, err = s.CmbMixRepo.GetResponse(ctx, &bo.CmbResponseBo{
|
||||
RespCode: vo.CmbResponseStatusFail.GetValue(),
|
||||
RespMsg: err.Error(),
|
||||
BizContent: "",
|
||||
})
|
||||
bizReply = &v1.CmbOrderReply{
|
||||
RespCode: vo.CmbResponseStatusFail.GetValue(),
|
||||
RespMsg: err.Error(),
|
||||
CodeNo: orderNo,
|
||||
}
|
||||
} else {
|
||||
bizReply := &v1.CmbOrderReply{
|
||||
bizReply = &v1.CmbOrderReply{
|
||||
RespCode: vo.CmbResponseStatusSuccess.GetValue(),
|
||||
RespMsg: "成功",
|
||||
CodeNo: orderNo,
|
||||
}
|
||||
replyBizContent, _ := json.Marshal(bizReply)
|
||||
reply, err = s.CmbMixRepo.GetResponse(ctx, &bo.CmbResponseBo{
|
||||
RespCode: vo.CmbResponseStatusSuccess.GetValue(),
|
||||
RespMsg: "成功",
|
||||
BizContent: string(replyBizContent),
|
||||
})
|
||||
}
|
||||
|
||||
replyBizContent, _ := json.Marshal(bizReply)
|
||||
xx := &bo.CmbResponseBo{
|
||||
RespCode: vo.CmbResponseStatusSuccess.GetValue(),
|
||||
RespMsg: err.Error(),
|
||||
BizContent: string(replyBizContent),
|
||||
}
|
||||
|
||||
reply, err = s.CmbMixRepo.GetResponse(ctx, xx)
|
||||
if err != nil {
|
||||
log.Errorf("cmbOrder CmbMixRepo GetResponse error: %v", err)
|
||||
}
|
||||
|
||||
return ctx.JSON(200, reply)
|
||||
|
|
@ -76,25 +84,28 @@ func (s *VoucherService) CmbProductQuery(ctx http.Context) error {
|
|||
|
||||
var (
|
||||
reply *v1.CmbReply
|
||||
err error
|
||||
|
||||
bizReply *v1.CmbQueryProductReply
|
||||
)
|
||||
|
||||
bizReply, err := s.cmbProductQuery(ctx)
|
||||
if err != nil {
|
||||
reply, err = s.CmbMixRepo.GetResponse(ctx, &bo.CmbResponseBo{
|
||||
RespCode: vo.CmbResponseStatusFail.GetValue(),
|
||||
RespMsg: err.Error(),
|
||||
BizContent: "",
|
||||
},
|
||||
)
|
||||
} else {
|
||||
replyBizContent, _ := json.Marshal(bizReply)
|
||||
reply, err = s.CmbMixRepo.GetResponse(ctx, &bo.CmbResponseBo{
|
||||
RespCode: vo.CmbResponseStatusSuccess.GetValue(),
|
||||
RespMsg: "成功",
|
||||
BizContent: string(replyBizContent),
|
||||
},
|
||||
)
|
||||
bizReply = &v1.CmbQueryProductReply{
|
||||
RespCode: vo.CmbResponseStatusFail.GetValue(),
|
||||
RespMsg: err.Error(),
|
||||
}
|
||||
}
|
||||
|
||||
replyBizContent, _ := json.Marshal(bizReply)
|
||||
xx := &bo.CmbResponseBo{
|
||||
RespCode: vo.CmbResponseStatusSuccess.GetValue(),
|
||||
RespMsg: "成功",
|
||||
BizContent: string(replyBizContent),
|
||||
}
|
||||
|
||||
reply, err = s.CmbMixRepo.GetResponse(ctx, xx)
|
||||
if err != nil {
|
||||
log.Errorf("cmbProductQuery CmbMixRepo GetResponse error: %v", err)
|
||||
}
|
||||
|
||||
return ctx.JSON(200, reply)
|
||||
|
|
@ -116,10 +127,5 @@ func (s *VoucherService) cmbProductQuery(ctx http.Context) (*v1.CmbQueryProductR
|
|||
return nil, err
|
||||
}
|
||||
|
||||
reply, err := s.VoucherBiz.CmbProductQuery(ctx, bizContent.ActivityId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return reply, nil
|
||||
return s.VoucherBiz.CmbProductQuery(ctx, bizContent.ActivityId)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue