修改拉卡拉卡分账
This commit is contained in:
@@ -216,19 +216,19 @@ func QueryBarCodeRefundStatus(afsOrderID string) (resp []*lakala.RefundOrderQuer
|
||||
}
|
||||
|
||||
// BarCodeScannerPayByLaKaLa 拉卡拉扫码枪扫码
|
||||
func BarCodeScannerPayByLaKaLa(ctx *jxcontext.Context, vendorOrderId, userPaymentLabel, ip string) (string, error) {
|
||||
func BarCodeScannerPayByLaKaLa(ctx *jxcontext.Context, vendorOrderId, userPaymentLabel, ip string) (*lakala.PayMicroPayResp, error) {
|
||||
db := dao.GetDB()
|
||||
goodsOrder, err := dao.GetSimpleOrder(db, vendorOrderId)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return nil, err
|
||||
}
|
||||
if goodsOrder.VendorID != model.VendorIDJX {
|
||||
return "", fmt.Errorf("此订单不是京西订单,无法使用该功能")
|
||||
return nil, fmt.Errorf("此订单不是京西订单,无法使用该功能")
|
||||
}
|
||||
|
||||
merchantObj, err := dao.GetStoreInfoByMerchantID(db, "", goodsOrder.JxStoreID, "", "")
|
||||
if err != nil {
|
||||
return "", err
|
||||
return nil, err
|
||||
}
|
||||
parma := &lakala.PayMicroPayReq{
|
||||
MerchantNo: merchantObj.MerchantNo,
|
||||
@@ -243,33 +243,55 @@ func BarCodeScannerPayByLaKaLa(ctx *jxcontext.Context, vendorOrderId, userPaymen
|
||||
SettleType: "1",
|
||||
Subject: fmt.Sprintf("感谢您在本店%s消费,欢迎下次再来", goodsOrder.StoreName),
|
||||
}
|
||||
code, msg, tradeNo, logNo, err := api.LaKaLaApi.ScannerPayMicroPay(parma)
|
||||
if code == lakala.PaySuccess {
|
||||
goodsOrder.Status = model.OrderStatusFinished
|
||||
goodsOrder.VendorStatus = code
|
||||
goodsOrder.VendorOrderID2 = logNo
|
||||
goodsOrder.OrderFinishedAt = time.Now()
|
||||
dao.UpdateEntity(db, goodsOrder, "Status", "VendorStatus", "OrderFinishedAt", "VendorOrderID2")
|
||||
return "支付成功", nil
|
||||
resp, err := api.LaKaLaApi.ScannerPayMicroPay(parma)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
goodsOrder.Status = model.OrderStatusFinished
|
||||
goodsOrder.VendorStatus = lakala.PayStatusSUCCESS
|
||||
goodsOrder.VendorOrderID2 = resp.LogNo
|
||||
goodsOrder.OrderFinishedAt = time.Now()
|
||||
dao.UpdateEntity(db, goodsOrder, "Status", "VendorStatus", "OrderFinishedAt", "VendorOrderID2")
|
||||
|
||||
payInfo := &model.OrderPay{
|
||||
PayOrderID: tradeNo,
|
||||
PayOrderID: resp.TradeNo,
|
||||
PayType: model.PayTypeLaKaLa,
|
||||
VendorPayType: lakala.PayWayAPP,
|
||||
TransactionID: logNo,
|
||||
VendorPayType: lakala.PayWayRegister,
|
||||
TransactionID: resp.LogNo,
|
||||
VendorOrderID: goodsOrder.VendorOrderID,
|
||||
VendorID: goodsOrder.VendorID,
|
||||
Status: 0,
|
||||
PayCreatedAt: time.Now(),
|
||||
PrepayID: tradeNo,
|
||||
PrepayID: resp.TradeNo,
|
||||
CodeURL: "",
|
||||
TotalFee: int(goodsOrder.ActualPayPrice),
|
||||
}
|
||||
dao.WrapAddIDCULDEntity(payInfo, ctx.GetUserName())
|
||||
dao.CreateEntity(db, payInfo)
|
||||
|
||||
return msg, err
|
||||
separate := &model.LakalaSeparateAmt{
|
||||
MerchantNo: merchantObj.MerchantNo2,
|
||||
VendorOrderID: goodsOrder.VendorOrderID,
|
||||
StoreId: goodsOrder.JxStoreID,
|
||||
CmdType: lakala.SeparateType_SEPATRATE,
|
||||
Status: "1",
|
||||
LogNo: resp.LogNo,
|
||||
LogDate: time.Now(),
|
||||
OutSeparateNo: "",
|
||||
SeparateNo: "",
|
||||
CalType: "",
|
||||
FinishDate: "",
|
||||
TotalAmt: "",
|
||||
ActualSeparateAmt: "",
|
||||
TotalFeeAmt: "",
|
||||
FinalStatus: "",
|
||||
DetailData: "",
|
||||
Remark: "聚合被扫订单",
|
||||
}
|
||||
dao.WrapAddIDCULEntity(separate, ctx.GetUserName())
|
||||
dao.CreateEntity(db, separate)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
// LaKaLaBarCodeScannerStatus 刷新当前订单的支付状态
|
||||
|
||||
@@ -22,7 +22,8 @@ import (
|
||||
)
|
||||
|
||||
func pay4OrderByLaKaLa(ctx *jxcontext.Context, order *model.GoodsOrder, payType int, vendorPayType, subAppID, code, source string) (orderPay *model.OrderPay, err error) {
|
||||
merchantObj, err := dao.GetStoreInfoByMerchantID(dao.GetDB(), "", order.JxStoreID, "", "")
|
||||
var db = dao.GetDB()
|
||||
merchantObj, err := dao.GetStoreInfoByMerchantID(db, "", order.JxStoreID, "", "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -101,9 +102,31 @@ func pay4OrderByLaKaLa(ctx *jxcontext.Context, order *model.GoodsOrder, payType
|
||||
fields, _ := json.Marshal(result.AccRespFields)
|
||||
orderPay.CodeURL = utils.LimitUTF8StringLen(string(fields), 3200)
|
||||
}
|
||||
|
||||
separate := &model.LakalaSeparateAmt{
|
||||
MerchantNo: merchantObj.MerchantNo2,
|
||||
VendorOrderID: order.VendorOrderID,
|
||||
StoreId: order.JxStoreID,
|
||||
CmdType: lakala.SeparateType_SEPATRATE,
|
||||
Status: "1",
|
||||
LogNo: result.LogNo,
|
||||
LogDate: time.Now(),
|
||||
OutSeparateNo: "",
|
||||
SeparateNo: "",
|
||||
CalType: "",
|
||||
FinishDate: "",
|
||||
TotalAmt: "",
|
||||
ActualSeparateAmt: "",
|
||||
TotalFeeAmt: "",
|
||||
FinalStatus: "",
|
||||
DetailData: "",
|
||||
Remark: "聚合主扫订单",
|
||||
}
|
||||
dao.WrapAddIDCULEntity(separate, ctx.GetUserName())
|
||||
dao.CreateEntity(db, separate)
|
||||
}
|
||||
order.VendorOrderID2 = result.LogNo
|
||||
dao.UpdateEntity(dao.GetDB(), order, "VendorOrderID2")
|
||||
dao.UpdateEntity(db, order, "VendorOrderID2")
|
||||
|
||||
return orderPay, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user