This commit is contained in:
parent
e0d69c5e22
commit
eb4beba9e4
|
|
@ -0,0 +1,103 @@
|
|||
package biz
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
v1 "voucher/api/v1"
|
||||
"voucher/internal/biz/bo"
|
||||
"voucher/internal/biz/kog"
|
||||
)
|
||||
|
||||
func (v *VoucherBiz) cmbToBB(ctx context.Context, cmbReq *v1.CmbOrderRequest) error {
|
||||
|
||||
req := &kog.CmbToBBRequest{
|
||||
TransactionId: cmbReq.TransactionId,
|
||||
ActivityId: cmbReq.ActivityId,
|
||||
CmbUid: cmbReq.CmbUid,
|
||||
CmbUidType: cmbReq.CmbUidType,
|
||||
Timestamp: cmbReq.Timestamp,
|
||||
AppId: cmbReq.AppId,
|
||||
Attach: cmbReq.Attach,
|
||||
}
|
||||
|
||||
return v.KxMixRepo.Request(ctx, req.GetNotice())
|
||||
}
|
||||
|
||||
func (v *VoucherBiz) bbToWx(ctx context.Context, order *bo.OrderBo, cmbReply *v1.CmbReply) error {
|
||||
|
||||
b, err := json.Marshal(cmbReply)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
wxRes, err := json.Marshal(map[string]string{"coupon_id": order.VoucherNo})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
req := &kog.BBToWechatRequest{
|
||||
StockId: order.BatchNo,
|
||||
OutRequestNo: order.OrderNo,
|
||||
AppId: order.AppID,
|
||||
StockCreatorMhId: order.MerchantNo,
|
||||
CouponValue: 0,
|
||||
CouponMinimum: order.MiniMum,
|
||||
CouponId: order.VoucherNo,
|
||||
WxRes: string(wxRes),
|
||||
CmbRes: string(b),
|
||||
TransactionId: order.OutBizNo,
|
||||
}
|
||||
|
||||
return v.KxMixRepo.Request(ctx, req.GetNotice())
|
||||
}
|
||||
|
||||
func (v *VoucherBiz) wxToBBUse(ctx context.Context, order *bo.OrderBo, wxReq *bo.WechatVoucherNotifyBo) error {
|
||||
|
||||
req := &kog.WechatToBBRequest{
|
||||
ActivityId: order.BatchNo,
|
||||
ActivityName: wxReq.PlainText.CouponName,
|
||||
VoucherId: order.VoucherNo,
|
||||
UserId: order.Account,
|
||||
UseTime: wxReq.PlainText.ConsumeInformation.ConsumeTime,
|
||||
UseAmount: wxReq.PlainText.ConsumeInformation.ConsumeAmount,
|
||||
BizType: "V_USE",
|
||||
RefundTime: "",
|
||||
RefundAmount: "",
|
||||
VoucherStatus: "",
|
||||
OrderId: order.OutBizNo,
|
||||
TradeNo: order.OrderNo,
|
||||
GmtVoucherCreate: fmt.Sprintf("%d", order.ReceiveSuccessTime.Unix()),
|
||||
}
|
||||
|
||||
inputFormat := time.RFC3339
|
||||
|
||||
if wxReq.PlainText.ConsumeInformation.ConsumeTime != "" {
|
||||
useTime, _ := time.Parse(inputFormat, wxReq.PlainText.ConsumeInformation.ConsumeTime)
|
||||
req.UseTime = fmt.Sprintf("%d", useTime.Unix())
|
||||
}
|
||||
|
||||
return v.KxMixRepo.Request(ctx, req.GetNotice())
|
||||
}
|
||||
|
||||
func (v *VoucherBiz) wxToBBRefund(ctx context.Context, order *bo.OrderBo) error {
|
||||
|
||||
req := &kog.WechatToBBRequest{
|
||||
ActivityId: order.BatchNo,
|
||||
ActivityName: "",
|
||||
VoucherId: order.VoucherNo,
|
||||
UserId: order.Account,
|
||||
UseTime: "",
|
||||
UseAmount: 0,
|
||||
BizType: "V_REFUND",
|
||||
RefundTime: "",
|
||||
RefundAmount: "",
|
||||
VoucherStatus: "",
|
||||
OrderId: order.OutBizNo,
|
||||
TradeNo: order.OrderNo,
|
||||
GmtVoucherCreate: fmt.Sprintf("%d", order.ReceiveSuccessTime.Unix()),
|
||||
}
|
||||
|
||||
return v.KxMixRepo.Request(ctx, req.GetNotice())
|
||||
}
|
||||
|
|
@ -6,11 +6,9 @@ import (
|
|||
"fmt"
|
||||
"github.com/go-kratos/kratos/v2/errors"
|
||||
"github.com/go-kratos/kratos/v2/log"
|
||||
"time"
|
||||
err2 "voucher/api/err"
|
||||
v1 "voucher/api/v1"
|
||||
"voucher/internal/biz/bo"
|
||||
"voucher/internal/biz/kog"
|
||||
"voucher/internal/biz/vo"
|
||||
)
|
||||
|
||||
|
|
@ -214,95 +212,3 @@ func (c *VoucherBiz) OrderFail(ctx context.Context, err error) (*v1.CmbReply, er
|
|||
|
||||
return c.GetResponse(ctx, replyBizContent)
|
||||
}
|
||||
|
||||
func (v *VoucherBiz) cmbToBB(ctx context.Context, cmbReq *v1.CmbOrderRequest) error {
|
||||
|
||||
req := &kog.CmbToBBRequest{
|
||||
TransactionId: cmbReq.TransactionId,
|
||||
ActivityId: cmbReq.ActivityId,
|
||||
CmbUid: cmbReq.CmbUid,
|
||||
CmbUidType: cmbReq.CmbUidType,
|
||||
Timestamp: cmbReq.Timestamp,
|
||||
AppId: cmbReq.AppId,
|
||||
Attach: cmbReq.Attach,
|
||||
}
|
||||
|
||||
return v.KxMixRepo.Request(ctx, req.GetNotice())
|
||||
}
|
||||
|
||||
func (v *VoucherBiz) bbToWx(ctx context.Context, order *bo.OrderBo, cmbReply *v1.CmbReply) error {
|
||||
|
||||
b, err := json.Marshal(cmbReply)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
wxRes, err := json.Marshal(map[string]string{"coupon_id": order.VoucherNo})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
req := &kog.BBToWechatRequest{
|
||||
StockId: order.BatchNo,
|
||||
OutRequestNo: order.OrderNo,
|
||||
AppId: order.AppID,
|
||||
StockCreatorMhId: order.MerchantNo,
|
||||
CouponValue: 0,
|
||||
CouponMinimum: order.MiniMum,
|
||||
CouponId: order.VoucherNo,
|
||||
WxRes: string(wxRes),
|
||||
CmbRes: string(b),
|
||||
TransactionId: order.OutBizNo,
|
||||
}
|
||||
|
||||
return v.KxMixRepo.Request(ctx, req.GetNotice())
|
||||
}
|
||||
|
||||
func (v *VoucherBiz) wxToBBUse(ctx context.Context, order *bo.OrderBo, wxReq *bo.WechatVoucherNotifyBo) error {
|
||||
|
||||
req := &kog.WechatToBBRequest{
|
||||
ActivityId: order.BatchNo,
|
||||
ActivityName: wxReq.PlainText.CouponName,
|
||||
VoucherId: order.VoucherNo,
|
||||
UserId: order.Account,
|
||||
UseTime: wxReq.PlainText.ConsumeInformation.ConsumeTime,
|
||||
UseAmount: wxReq.PlainText.ConsumeInformation.ConsumeAmount,
|
||||
BizType: "V_USE",
|
||||
RefundTime: "",
|
||||
RefundAmount: "",
|
||||
VoucherStatus: "",
|
||||
OrderId: order.OutBizNo,
|
||||
TradeNo: order.OrderNo,
|
||||
GmtVoucherCreate: fmt.Sprintf("%d", order.ReceiveSuccessTime.Unix()),
|
||||
}
|
||||
|
||||
inputFormat := time.RFC3339
|
||||
|
||||
if wxReq.PlainText.ConsumeInformation.ConsumeTime != "" {
|
||||
useTime, _ := time.Parse(inputFormat, wxReq.PlainText.ConsumeInformation.ConsumeTime)
|
||||
req.UseTime = fmt.Sprintf("%d", useTime.Unix())
|
||||
}
|
||||
|
||||
return v.KxMixRepo.Request(ctx, req.GetNotice())
|
||||
}
|
||||
|
||||
func (v *VoucherBiz) wxToBBRefund(ctx context.Context, order *bo.OrderBo) error {
|
||||
|
||||
req := &kog.WechatToBBRequest{
|
||||
ActivityId: order.BatchNo,
|
||||
ActivityName: "",
|
||||
VoucherId: order.VoucherNo,
|
||||
UserId: order.Account,
|
||||
UseTime: "",
|
||||
UseAmount: 0,
|
||||
BizType: "V_REFUND",
|
||||
RefundTime: "",
|
||||
RefundAmount: "",
|
||||
VoucherStatus: "",
|
||||
OrderId: order.OutBizNo,
|
||||
TradeNo: order.OrderNo,
|
||||
GmtVoucherCreate: fmt.Sprintf("%d", order.ReceiveSuccessTime.Unix()),
|
||||
}
|
||||
|
||||
return v.KxMixRepo.Request(ctx, req.GetNotice())
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue