111 lines
2.6 KiB
Go
111 lines
2.6 KiB
Go
package yl
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
"rs/cmd/api/internal/logic/vo"
|
|
"rs/cmd/api/internal/svc"
|
|
"rs/cmd/api/internal/types"
|
|
"rs/rpc/transfer"
|
|
"strconv"
|
|
"time"
|
|
)
|
|
|
|
type GetOrderLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
// 订单查询接口
|
|
func NewGetOrderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetOrderLogic {
|
|
return &GetOrderLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *GetOrderLogic) GetOrder(req *types.GetOrderReq) (resp *types.GetOrderRsp, err error) {
|
|
var (
|
|
status int
|
|
)
|
|
|
|
order, err := l.svcCtx.BaseServiceContext.YlOrderMarketRepo.FindOneByDeliverOrderNoSupplierOrderNo(l.ctx, req.DeliverOrderNo, req.SupplierOrderNo)
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
data := transfer.MarketKeySendRes{}
|
|
err = json.Unmarshal([]byte(order.Resp), &data)
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
if data.Data.ShortUrl != "" {
|
|
status = 1
|
|
}
|
|
accouont, _ := strconv.Atoi(order.Account)
|
|
supplierId, _ := strconv.Atoi(order.SupplierId)
|
|
resp = &types.GetOrderRsp{
|
|
DeliverOrderNo: req.DeliverOrderNo,
|
|
SupplierOrderNo: req.SupplierOrderNo,
|
|
SupplierSkuId: order.SupplierSkuId,
|
|
Account: int64(accouont),
|
|
SendStatus: status,
|
|
Price: 0,
|
|
StatusTime: order.UpdateTime.Unix(),
|
|
Msg: "",
|
|
SupplierId: int64(supplierId),
|
|
CardNo: "",
|
|
CardKey: "",
|
|
CardExpireTime: "",
|
|
CardExchangeUrl: data.Data.ShortUrl,
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
func (l *GetOrderLogic) GetOrder2(req *types.GetOrderReq) (resp *types.GetOrderRsp, err error) {
|
|
request := transfer.MarketQueryReq{
|
|
AppId: l.svcCtx.Config.MarketConfig.AppId,
|
|
//Sign: "",
|
|
ReqCode: "voucher.query",
|
|
MemId: fmt.Sprintf("%d", req.SupplierId),
|
|
ReqSerialNo: req.DeliverOrderNo,
|
|
Timestamp: time.Unix(req.RequestTime, 0).Format("20060102150405"),
|
|
VoucherId: "",
|
|
VoucherCode: req.SupplierOrderNo,
|
|
}
|
|
|
|
request.Sign = l.svcCtx.Config.Sys.PrimaryKey
|
|
|
|
result, err := l.svcCtx.TransferRpc.MarketQuery(l.ctx, &request)
|
|
if err != nil {
|
|
return
|
|
}
|
|
if result.ErrCode != vo.RES_SUCCESS {
|
|
return nil, fmt.Errorf("请求失败:%v", result.Msg)
|
|
}
|
|
|
|
resp = &types.GetOrderRsp{
|
|
DeliverOrderNo: req.DeliverOrderNo,
|
|
SupplierOrderNo: req.SupplierOrderNo,
|
|
//SupplierSkuId: req,
|
|
//Count: req.,
|
|
SendStatus: 1,
|
|
Price: 0,
|
|
StatusTime: 0,
|
|
Msg: "",
|
|
SupplierId: 0,
|
|
CardNo: "",
|
|
CardKey: "",
|
|
CardExpireTime: "",
|
|
CardExchangeUrl: result.Data.VoucherCode,
|
|
}
|
|
|
|
return
|
|
}
|