feat: 过期时间返回
This commit is contained in:
parent
ad517b9d56
commit
d715eb4a30
|
|
@ -47,6 +47,15 @@ func (l *GetOrderLogic) GetOrder(req *types.GetOrderReq) (resp *types.GetOrderRs
|
||||||
if data.Data.ShortUrl != "" {
|
if data.Data.ShortUrl != "" {
|
||||||
status = 1
|
status = 1
|
||||||
}
|
}
|
||||||
|
startTime, err := time.Parse("20060102", data.Data.VoucherSdate)
|
||||||
|
if err != nil {
|
||||||
|
startTime = time.Now()
|
||||||
|
}
|
||||||
|
endTime, err := time.Parse("20060102", data.Data.VoucherEdate)
|
||||||
|
if err != nil {
|
||||||
|
endTime = startTime.AddDate(0, 0, 30).Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||||
|
}
|
||||||
|
|
||||||
accouont, _ := strconv.Atoi(order.Account)
|
accouont, _ := strconv.Atoi(order.Account)
|
||||||
supplierId, _ := strconv.Atoi(order.SupplierId)
|
supplierId, _ := strconv.Atoi(order.SupplierId)
|
||||||
resp = &types.GetOrderRsp{
|
resp = &types.GetOrderRsp{
|
||||||
|
|
@ -55,29 +64,29 @@ func (l *GetOrderLogic) GetOrder(req *types.GetOrderReq) (resp *types.GetOrderRs
|
||||||
SupplierSkuId: order.SupplierSkuId,
|
SupplierSkuId: order.SupplierSkuId,
|
||||||
Account: int64(accouont),
|
Account: int64(accouont),
|
||||||
SendStatus: status,
|
SendStatus: status,
|
||||||
Price: 0,
|
Price: order.Price,
|
||||||
StatusTime: order.UpdateTime.Unix(),
|
StatusTime: order.UpdateTime.Unix(),
|
||||||
Msg: "",
|
Msg: "",
|
||||||
SupplierId: int64(supplierId),
|
SupplierId: int64(supplierId),
|
||||||
CardNo: "",
|
CardNo: "",
|
||||||
CardKey: "",
|
CardKey: "",
|
||||||
CardExpireTime: "",
|
CardExpireTime: endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second).Format(time.DateTime),
|
||||||
CardExchangeUrl: data.Data.ShortUrl,
|
CardExchangeUrl: data.Data.ShortUrl,
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 营销系统查询
|
||||||
func (l *GetOrderLogic) GetOrder2(req *types.GetOrderReq) (resp *types.GetOrderRsp, err error) {
|
func (l *GetOrderLogic) GetOrder2(req *types.GetOrderReq) (resp *types.GetOrderRsp, err error) {
|
||||||
request := transfer.MarketQueryReq{
|
request := transfer.MarketQueryReq{
|
||||||
AppId: l.svcCtx.Config.MarketConfig.AppId,
|
AppId: l.svcCtx.Config.MarketConfig.AppId,
|
||||||
//Sign: "",
|
|
||||||
ReqCode: "voucher.query",
|
ReqCode: "voucher.query",
|
||||||
MemId: fmt.Sprintf("%d", req.SupplierId),
|
MemId: fmt.Sprintf("%d", req.SupplierId),
|
||||||
ReqSerialNo: req.DeliverOrderNo,
|
ReqSerialNo: req.DeliverOrderNo,
|
||||||
Timestamp: time.Unix(req.RequestTime, 0).Format("20060102150405"),
|
Timestamp: time.Unix(req.RequestTime, 0).Format("20060102150405"),
|
||||||
VoucherId: "",
|
//VoucherId: "yl20240730",
|
||||||
VoucherCode: req.SupplierOrderNo,
|
//VoucherCode: "AAAESSGEVVpTHsbe",
|
||||||
}
|
}
|
||||||
|
|
||||||
request.Sign = l.svcCtx.Config.Sys.PrimaryKey
|
request.Sign = l.svcCtx.Config.Sys.PrimaryKey
|
||||||
|
|
|
||||||
|
|
@ -83,16 +83,16 @@ func (l *YlAsyncLogic) YlAsync(req *types.AsyncReq) (resp *types.AsyncResp, err
|
||||||
if result.Data.VoucherCode == "" {
|
if result.Data.VoucherCode == "" {
|
||||||
return nil, fmt.Errorf("请求失败未取到数据:%v", result.Msg)
|
return nil, fmt.Errorf("请求失败未取到数据:%v", result.Msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
supplierOrderNo := req.DeliverOrderNo
|
supplierOrderNo := req.DeliverOrderNo
|
||||||
|
// 记录订单
|
||||||
|
l.saveOrder(req, result, supplierOrderNo, VoucherId)
|
||||||
// 异步通知
|
// 异步通知
|
||||||
go func() {
|
go func() {
|
||||||
time.Sleep(2 * time.Second)
|
time.Sleep(2 * time.Second)
|
||||||
l.asyncSendMarket(supplierOrderNo, req, result.Data)
|
l.asyncSendMarket(supplierOrderNo, req, result.Data)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// 记录订单
|
|
||||||
l.saveOrder(req, result, supplierOrderNo, VoucherId)
|
|
||||||
|
|
||||||
return &types.AsyncResp{
|
return &types.AsyncResp{
|
||||||
Msg: "",
|
Msg: "",
|
||||||
Status: 0,
|
Status: 0,
|
||||||
|
|
@ -109,8 +109,17 @@ func (l *YlAsyncLogic) getExchangeCode(voucherCode string) string {
|
||||||
return temp[len(temp)-1]
|
return temp[len(temp)-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
// 往营销系统下单,返回数据,通知下游系统
|
// 返回数据,通知下游系统
|
||||||
func (l *YlAsyncLogic) asyncSendMarket(supplierOrderNo string, asyncReq *types.AsyncReq, data *transfer.MarketKeySendRes_Data) {
|
func (l *YlAsyncLogic) asyncSendMarket(supplierOrderNo string, asyncReq *types.AsyncReq, data *transfer.MarketKeySendRes_Data) {
|
||||||
|
startTime, err := time.Parse("20060102", data.VoucherSdate)
|
||||||
|
if err != nil {
|
||||||
|
startTime = time.Now()
|
||||||
|
}
|
||||||
|
endTime, err := time.Parse("20060102", data.VoucherEdate)
|
||||||
|
if err != nil {
|
||||||
|
endTime = startTime.AddDate(0, 0, 30).Add(23*time.Hour + 59*time.Minute + 59*time.Second)
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
reqDataMap map[string]interface{}
|
reqDataMap map[string]interface{}
|
||||||
header = map[string]string{"Content-Type": "application/json;charset=UTF-8"}
|
header = map[string]string{"Content-Type": "application/json;charset=UTF-8"}
|
||||||
|
|
@ -127,14 +136,14 @@ func (l *YlAsyncLogic) asyncSendMarket(supplierOrderNo string, asyncReq *types.A
|
||||||
SupplierId: asyncReq.SupplierId,
|
SupplierId: asyncReq.SupplierId,
|
||||||
CardNo: "",
|
CardNo: "",
|
||||||
CardKey: "",
|
CardKey: "",
|
||||||
CardExpireTime: "",
|
CardExpireTime: endTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second).Format(time.DateTime),
|
||||||
CardExchangeUrl: data.ShortUrl,
|
CardExchangeUrl: data.ShortUrl,
|
||||||
Sign: "",
|
Sign: "",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
b, _ := json.Marshal(req)
|
b, _ := json.Marshal(req)
|
||||||
err := json.Unmarshal(b, &reqDataMap)
|
err = json.Unmarshal(b, &reqDataMap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue