diff --git a/business/jxstore/financial/financial.go b/business/jxstore/financial/financial.go index 08bc19d79..1272131b1 100644 --- a/business/jxstore/financial/financial.go +++ b/business/jxstore/financial/financial.go @@ -283,7 +283,7 @@ func onTLpayFinished(call *tonglianpayapi.CallBackResult) (err error) { return err } userOrder := model.UserVendorOrder{LocalWayBill: order.OrderID} - if err := dao.GetEntity(db, &userOrder, `LocalWayBill`); err != nil { + if err := dao.GetEntity(db, &userOrder, "LocalWayBill"); err != nil { dao.Rollback(db, txdb) return err } @@ -296,7 +296,13 @@ func onTLpayFinished(call *tonglianpayapi.CallBackResult) (err error) { if call.TrxStatus == tonglianpayapi.TrxStatusSuccess { switch order.OrderType { case model.PayType4Express: +<<<<<<< HEAD err = q_bida.CreateOrder2QBiDa(&userOrder) +======= + err = q_bida.CreateOrder2QBiDa(&userOrder, order.OrderID) + case model.PayType4Member, model.PayType4Recharge: + err = OnPayFinished(order) +>>>>>>> 273aa3164fbc887ac30837bd4ce1b25410ca498c } } return err diff --git a/business/model/user_vendor_order.go b/business/model/user_vendor_order.go index c82ed9e3a..25f2014fa 100644 --- a/business/model/user_vendor_order.go +++ b/business/model/user_vendor_order.go @@ -35,6 +35,7 @@ type UserVendorOrder struct { OrderStatus int `orm:"size(8);column(order_status)" json:"orderType"` // 订单状态(2-待支付,3-支付失败,4-支付成功,10预下单11待取件12运输中15已签收16取消订单17终止揽收,150取消) Img string `orm:"size(1024);column(img)" json:"img"` // 包裹图片 IsForward int `orm:"column(is_forward)" json:"isForward"` // 1否,2是 转寄单 + ErrorMsg string `orm:"size(1024);column(error_msg)" json:"errorMsg"` // 平台错误 } const ( diff --git a/business/q_bida/q_bida_server.go b/business/q_bida/q_bida_server.go index ce6d926b6..8a0720969 100644 --- a/business/q_bida/q_bida_server.go +++ b/business/q_bida/q_bida_server.go @@ -236,7 +236,9 @@ func CancelWayOrder(ctx *jxcontext.Context, userId string, param *bida.CancelOrd OrderNo: order.OtherWayBill, Type: param.Type, } - api.QBiDaAPI.CancelOrder(cancelParma) + if err := api.QBiDaAPI.CancelOrder(cancelParma); err != nil { + return err + } // 暂时考虑余额支付渠道,加载order表判断支付渠道方式 orderWay := &model.Order{OrderID: param.OrderNo, UserID: userId} if err := dao.GetEntity(dao.GetDB(), orderWay, "OrderID", "UserID"); err != nil { @@ -336,7 +338,7 @@ func QueryUserOrderList(userId string, expressType, orderStatus int, pageNum, pa } // CreateOrder2QBiDa 订单回调成功,且为运费支付时使用该接口 -func CreateOrder2QBiDa(order *model.UserVendorOrder) error { +func CreateOrder2QBiDa(order *model.UserVendorOrder, orderId string) error { //// 加载订单 //order := &model.UserVendorOrder{} //sql := `SELECT * FROM user_vendor_order WHERE local_way_bill = ? ` @@ -348,6 +350,8 @@ func CreateOrder2QBiDa(order *model.UserVendorOrder) error { // globals.SugarLogger.Debug("Callback Success But Order Status Update Fail ....") // return errors.New("Callback Success But Order Status Update Fail ") //} + globals.SugarLogger.Debug("order==================", order) + globals.SugarLogger.Debug("order==================", order.LocalWayBill) // 创建QBIDA订单 makeOrder := &bida.MakeOrderReq{ @@ -383,11 +387,15 @@ func CreateOrder2QBiDa(order *model.UserVendorOrder) error { makeOrder.ReceiveName = receiveAddress.ConsigneeName makeOrder.ReceivePhone = receiveAddress.ConsigneeMobile otherId, err := createOtherOrder(makeOrder) - + if err != nil { + order.ErrorMsg = err.Error() + globals.SugarLogger.Debug("err==========", err) + } + globals.SugarLogger.Debug("otherId==========", otherId) order.OtherWayBill = otherId order.OrderStatus = model.OrderStatusWaitPickup order.UpdatedAt = time.Now() - if _, err = dao.UpdateEntity(dao.GetDB(), order, "OtherWayBill", "OrderStatus", "UpdatedAt"); err != nil { + if _, err = dao.UpdateEntity(dao.GetDB(), order, "OtherWayBill", "OrderStatus", "UpdatedAt", "ErrorMsg"); err != nil { return err } return nil @@ -524,7 +532,7 @@ func DeleteOrderByLocalId(userId, localId string) (int64, error) { // UpdateOrderStatus 查询所有支付成功的订单 func UpdateOrderStatus() { - globals.SugarLogger.Debug("没十分钟更新一下订单,定时任务") + globals.SugarLogger.Debug("每十分钟更新一下订单,定时任务") // 查询状态值为【4-支付成功,10预下单11待取件12运输中17终止揽收】//2,3 15已签收16取消订单 完成订单 db := dao.GetDB() sql := `SELECT * FROM user_vendor_order WHERE order_status IN (4,10,11,12,17) AND deleted_at = ?` @@ -536,11 +544,11 @@ func UpdateOrderStatus() { } for _, v := range data { - if v.LocalWayBill == v.OtherWayBill { + if v.LocalWayBill == v.OtherWayBill && v.OrderStatus == model.OrderStatusSuccessPay { globals.SugarLogger.Debug("ERROR ", "第三方订单Id写入错误,") continue } - if v.OrderStatus == 2 || v.OrderStatus == 3 || v.OrderStatus == 15 || v.OrderStatus == 16 { + if v.OrderStatus == 2 || v.OrderStatus == 3 || v.OrderStatus == 15 || v.OrderStatus == 16 || v.OrderStatus == 115 { continue } otherOrder, err := QueryOrderDetail(v.Type, v.OtherWayBill) diff --git a/controllers/tonglian_callback.go b/controllers/tonglian_callback.go index e34461869..6572311de 100644 --- a/controllers/tonglian_callback.go +++ b/controllers/tonglian_callback.go @@ -24,11 +24,15 @@ func (c *TongLianController) Msg() { if c.Ctx.Input.Method() == http.MethodPost { call, err := api.TLpayAPI.GetCallbackMsg(getUsefulRequest2(c.Ctx)) globals.SugarLogger.Debugf("tonglianapi callback callbackResponse:%s", utils.Format4Output(call, true)) - if err == nil { - err = financial.OnTLPayCallback(call) + if err != nil { + c.Abort("404") + return } - globals.SugarLogger.Debug("err==============", err) - c.Data["json"] = call + if err = financial.OnTLPayCallback(call); err != nil { + c.Abort("404") + return + } + c.Data["json"] = "success" c.ServeJSON() } else { c.Abort("404")