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