1
This commit is contained in:
@@ -158,7 +158,8 @@ func OrderStatusCallback(param *lakala.QueryOrderCallBackResp) error {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
order, err := partner.CurOrderManager.LoadOrder(param.OrderCreateTime, model.VendorIDJX)
|
||||
|
||||
order, err := partner.CurOrderManager.LoadOrder(param.OutOrderNo, model.VendorIDJX)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -181,7 +182,34 @@ func OrderStatusCallback(param *lakala.QueryOrderCallBackResp) error {
|
||||
case "6":
|
||||
|
||||
}
|
||||
order.VendorOrderID2 = param.OrderTradeInfo.LogNo
|
||||
order.VendorStatus = param.OrderStatus
|
||||
_, err = dao.UpdateEntity(db, order, "Status", "VendorStatus", "OrderFinishedAt")
|
||||
_, err = dao.UpdateEntity(db, order, "Status", "VendorOrderID2", "VendorStatus", "OrderFinishedAt")
|
||||
|
||||
orderPay := &model.OrderPay{
|
||||
PayOrderID: param.PayOrderNo,
|
||||
}
|
||||
orderPay.DeletedAt = utils.DefaultTimeValue
|
||||
if err := dao.GetEntity(db, orderPay, "PayOrderID", "DeletedAt"); err == nil {
|
||||
if orderPay.Status != 0 {
|
||||
return err
|
||||
}
|
||||
loc, _ := time.LoadLocation("Local")
|
||||
t1, _ := time.ParseInLocation("20060102150405", param.OrderTradeInfo.TradeTime, loc)
|
||||
orderPay.PayFinishedAt = utils.Time2Pointer(t1)
|
||||
orderPay.OriginalData = utils.Format4Output(param, true)
|
||||
//TradeType string `json:"trade_type"` // M String 16 交易类型 PAY-消费 REFUND-退款 CANCEL-撤销
|
||||
//TradeStatus string `json:"trade_status"` // M String 2 支付状态 返回状态 S:成功 F:失败 C:被冲正 U:预记状态 X:发送失败 T: 发送超时 P: 处理中
|
||||
orderPay.TransactionID = param.OrderTradeInfo.LogNo
|
||||
switch param.OrderTradeInfo.TradeStatus {
|
||||
case "S":
|
||||
orderPay.Status = model.PayStatusYes
|
||||
default:
|
||||
orderPay.Status = model.PayStatusFailed
|
||||
}
|
||||
|
||||
dao.UpdateEntity(db, orderPay)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -517,7 +517,7 @@ func Separate(ctx *jxcontext.Context, param *lakala.OrderSeparateReq) (string, s
|
||||
param.OutSeparateNo = lakala.GetOrderNumber(10)
|
||||
param.NotifyUrl = lakala.CallbackLaKaLaSeparateUrl
|
||||
|
||||
status, separateNo, logNo, err := api.LaKaLaApi.Separate(param)
|
||||
status, separateNo, err := api.LaKaLaApi.Separate(param)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
@@ -530,9 +530,9 @@ func Separate(ctx *jxcontext.Context, param *lakala.OrderSeparateReq) (string, s
|
||||
FinishDate: "",
|
||||
TotalAmt: param.TotalAmt,
|
||||
Status: status,
|
||||
LogNo: logNo,
|
||||
DetailData: string(recv),
|
||||
Remark: "分账",
|
||||
//LogNo: logNo,
|
||||
DetailData: string(recv),
|
||||
Remark: "分账",
|
||||
}
|
||||
t, err := time.Parse("20060102", param.LogDate)
|
||||
if err != nil {
|
||||
@@ -700,7 +700,7 @@ func SubMerchantInfoQuery(merInnerNo, merCupNo string) ([]*lakala.SubMerchantInf
|
||||
//#region 订单相关
|
||||
|
||||
// CreateOrder 创建拉卡拉交易订单
|
||||
func CreateOrder(vendorOrderID, merchantNo string, vendorId int) (*lakala.CreateOrderResp, error) {
|
||||
func CreateOrder(ctx *jxcontext.Context, vendorOrderID, merchantNo string, vendorId int) (*lakala.CreateOrderResp, error) {
|
||||
order, err := partner.CurOrderManager.LoadOrder(vendorOrderID, vendorId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -719,6 +719,22 @@ func CreateOrder(vendorOrderID, merchantNo string, vendorId int) (*lakala.Create
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
orderPay := &model.OrderPay{
|
||||
PayOrderID: result.PayOrderNo,
|
||||
PayType: model.PayTypeLaKaLa,
|
||||
VendorPayType: lakala.PayWayRegister,
|
||||
TransactionID: "",
|
||||
VendorOrderID: order.VendorOrderID,
|
||||
VendorID: order.VendorID,
|
||||
Status: 0,
|
||||
PayCreatedAt: time.Now(),
|
||||
PrepayID: result.PayOrderNo,
|
||||
CodeURL: "",
|
||||
TotalFee: int(order.ActualPayPrice),
|
||||
}
|
||||
dao.WrapAddIDCULDEntity(orderPay, ctx.GetUserName())
|
||||
err = dao.CreateEntity(dao.GetDB(), orderPay)
|
||||
return result, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ type LakalaSeparateAmt struct {
|
||||
CmdType string `orm:"column(cmd_type);size(32)" json:"cmdType"` // SEPARATE:分账 CANCEL:分账撤销FALLBACK:分账回退
|
||||
SeparateNo string `orm:"column(separate_no);size(32)" json:"separateNo"` // 分账系统生成唯一流水
|
||||
Status string `orm:"column(status);size(32)" json:"status1"` // 分账状态
|
||||
LogNo string `orm:"column(log_no);size(32)" json:"logNo"` // 交易流水号
|
||||
//LogNo string `orm:"column(log_no);size(32)" json:"logNo"` // 交易流水号
|
||||
//SeparateNo2 string `orm:"column(separate_no2);size(32)" json:"separateNo2"` // 分账撤销系统生成唯一流水
|
||||
//Status2 string `orm:"column(status2);size(32)" json:"status2"` // 分账撤销状态
|
||||
//SeparateNo3 string `orm:"column(separate_no3);size(32)" json:"separateNo3"` // 分账回退系统生成唯一流水
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -191,31 +190,26 @@ func BarCodeScannerPayByLaKaLa(ctx *jxcontext.Context, vendorOrderId, userPaymen
|
||||
SettleType: "1",
|
||||
Subject: fmt.Sprintf("感谢您在本店%s消费,欢迎下次再来", goodsOrder.StoreName),
|
||||
}
|
||||
code, msg, payOrderId, err := api.LaKaLaApi.ScannerPayMicroPay(parma)
|
||||
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")
|
||||
dao.UpdateEntity(db, goodsOrder, "Status", "VendorStatus", "OrderFinishedAt", "VendorOrderID2")
|
||||
return "支付成功", nil
|
||||
}
|
||||
|
||||
vendorPayType := ""
|
||||
if strings.Contains(userPaymentLabel, "101112131415") {
|
||||
vendorPayType = lakala.Wechat
|
||||
} else {
|
||||
vendorPayType = lakala.Alipay
|
||||
}
|
||||
payInfo := &model.OrderPay{
|
||||
PayOrderID: payOrderId,
|
||||
PayOrderID: tradeNo,
|
||||
PayType: model.PayTypeLaKaLa,
|
||||
VendorPayType: vendorPayType,
|
||||
TransactionID: userPaymentLabel,
|
||||
VendorPayType: lakala.PayWayAPP,
|
||||
TransactionID: logNo,
|
||||
VendorOrderID: goodsOrder.VendorOrderID,
|
||||
VendorID: goodsOrder.VendorID,
|
||||
Status: 0,
|
||||
PayCreatedAt: time.Now(),
|
||||
PrepayID: userPaymentLabel,
|
||||
PrepayID: tradeNo,
|
||||
CodeURL: "",
|
||||
TotalFee: int(goodsOrder.ActualPayPrice),
|
||||
}
|
||||
|
||||
@@ -85,9 +85,9 @@ func pay4OrderByLaKaLa(ctx *jxcontext.Context, order *model.GoodsOrder, payType
|
||||
result, err := api.LaKaLaApi.AggregatePay(param)
|
||||
if err == nil {
|
||||
orderPay = &model.OrderPay{
|
||||
PayOrderID: param.OutTradeNo,
|
||||
PayOrderID: result.TradeNo,
|
||||
PayType: payType,
|
||||
VendorPayType: vendorPayType,
|
||||
VendorPayType: lakala.PayWayMini,
|
||||
TransactionID: result.LogNo,
|
||||
VendorOrderID: order.VendorOrderID,
|
||||
VendorID: order.VendorID,
|
||||
@@ -102,6 +102,9 @@ func pay4OrderByLaKaLa(ctx *jxcontext.Context, order *model.GoodsOrder, payType
|
||||
orderPay.CodeURL = utils.LimitUTF8StringLen(string(fields), 3200)
|
||||
}
|
||||
}
|
||||
order.VendorOrderID2 = result.LogNo
|
||||
dao.UpdateEntity(dao.GetDB(), order, "VendorOrderID2")
|
||||
|
||||
return orderPay, err
|
||||
}
|
||||
|
||||
@@ -124,7 +127,7 @@ func OnLaKaLaPayCallback(call *lakala.PayStatusCallBack) (err error) {
|
||||
// onLaKaLaPayFinished 订单支付成功或失败
|
||||
func onLaKaLaPayFinished(call *lakala.PayStatusCallBack) (err error) {
|
||||
orderPay := &model.OrderPay{
|
||||
PayOrderID: call.OutTradeNo,
|
||||
PayOrderID: call.TradeNo,
|
||||
}
|
||||
orderPay.DeletedAt = utils.DefaultTimeValue
|
||||
db := dao.GetDB()
|
||||
@@ -154,7 +157,7 @@ func onLaKaLaPayFinished(call *lakala.PayStatusCallBack) (err error) {
|
||||
// onLaKaLaOrderCancel 订单取消或撤单
|
||||
func onLaKaLaOrderCancel(call *lakala.PayStatusCallBack) (err error) {
|
||||
orderPay := &model.OrderPay{
|
||||
PayOrderID: call.OutTradeNo,
|
||||
PayOrderID: call.TradeNo,
|
||||
}
|
||||
orderPay.DeletedAt = utils.DefaultTimeValue
|
||||
db := dao.GetDB()
|
||||
@@ -173,7 +176,7 @@ func onLaKaLaOrderCancel(call *lakala.PayStatusCallBack) (err error) {
|
||||
|
||||
func onLaKaLaPayRefund(call *lakala.PayStatusCallBack) (err error) {
|
||||
orderPayRefund := &model.OrderPayRefund{
|
||||
RefundID: call.OutTradeNo,
|
||||
RefundID: call.TradeNo,
|
||||
}
|
||||
db := dao.GetDB()
|
||||
if err = dao.GetEntity(db, orderPayRefund, "RefundID"); err != nil && err == orm.ErrNoRows {
|
||||
|
||||
@@ -648,7 +648,7 @@ func (c *LaKaLaController) SeparateFallBack() {
|
||||
// @router /CreateOrder [get]
|
||||
func (c *LaKaLaController) CreateOrder() {
|
||||
c.callCreateOrder(func(params *tLakalaCreateOrderParams) (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = lakalaServer.CreateOrder(params.VendorOrderId, params.MerchantNo, params.VendorId)
|
||||
retVal, err = lakalaServer.CreateOrder(params.Ctx, params.VendorOrderId, params.MerchantNo, params.VendorId)
|
||||
return
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user