From 07a2f48755259d098f42f614090ec02497855aab Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Tue, 10 Oct 2023 16:03:29 +0800 Subject: [PATCH] update --- app/customer/hdl/hdl_call_back.go | 2 +- app/customer/svc/svc_pay.go | 6 ++++-- app/db/model/central_kitchen_for_school_package_ord.go | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/customer/hdl/hdl_call_back.go b/app/customer/hdl/hdl_call_back.go index 4a7749b..2f873e3 100644 --- a/app/customer/hdl/hdl_call_back.go +++ b/app/customer/hdl/hdl_call_back.go @@ -68,7 +68,7 @@ func WxJsApiCallBack(c *gin.Context) { return } - _, err = svc.DealCentralKitchenForSchoolOrderCallBackForWx(resp.OutTradeNo, resp.TradeState) + _, err = svc.DealCentralKitchenForSchoolOrderCallBackForWx(resp.OutTradeNo, resp.TransactionId, resp.TradeState) if err != nil { e.OutErr(c, e.ERR, err.Error()) return diff --git a/app/customer/svc/svc_pay.go b/app/customer/svc/svc_pay.go index e68486e..48fa19f 100644 --- a/app/customer/svc/svc_pay.go +++ b/app/customer/svc/svc_pay.go @@ -252,6 +252,7 @@ func BuyPackageForWx(c *gin.Context, req md.BuyPackageReq) (outTradeNo, total st ReqContent: string(utils.Serialize(req)), WithDayData: string(utils.Serialize(data)), PayWay: enum.PayWayForWx, + PrepayId: *result.PrepayId, CreateAt: now.Format("2006-01-02 15:04:05"), UpdateAt: now.Format("2006-01-02 15:04:05"), }) @@ -493,7 +494,7 @@ func DealCentralKitchenForSchoolOrderCallBack(outTradeNo, tradeStatus string) (s return } -func DealCentralKitchenForSchoolOrderCallBackForWx(outTradeNo, tradeStatus string) (state int, err error) { +func DealCentralKitchenForSchoolOrderCallBackForWx(outTradeNo, transactionId, tradeStatus string) (state int, err error) { centralKitchenForSchoolPackageOrd := db.CentralKitchenForSchoolPackageOrd{} centralKitchenForSchoolPackageOrd.Set(outTradeNo) ord, err := centralKitchenForSchoolPackageOrd.GetCentralKitchenForSchoolPackageOrd() @@ -513,6 +514,7 @@ func DealCentralKitchenForSchoolOrderCallBackForWx(outTradeNo, tradeStatus strin if tradeStatus == "SUCCESS" { ord.State = enum2.CentralKitchenForSchoolPackageOrdStateForSuccess ord.OrdState = enum2.CentralKitchenForSchoolPackageOrdOrdStateForSuccess + ord.TradeNo = transactionId //TODO::将预留数据插入到 `central_kitchen_for_school_user_with_day` var data []*model.CentralKitchenForSchoolUserWithDay @@ -586,7 +588,7 @@ func DealCentralKitchenForSchoolOrderCallBackForWx(outTradeNo, tradeStatus strin } } } - _, err = centralKitchenForSchoolPackageOrd.CentralKitchenForSchoolPackageOrdUpdate(ord, "state", "ord_state") + _, err = centralKitchenForSchoolPackageOrd.CentralKitchenForSchoolPackageOrdUpdate(ord, "state", "ord_state", "trade_no") if err != nil { return } diff --git a/app/db/model/central_kitchen_for_school_package_ord.go b/app/db/model/central_kitchen_for_school_package_ord.go index 7646c95..64a1541 100644 --- a/app/db/model/central_kitchen_for_school_package_ord.go +++ b/app/db/model/central_kitchen_for_school_package_ord.go @@ -15,6 +15,7 @@ type CentralKitchenForSchoolPackageOrd struct { ReqContent string `json:"req_content" xorm:"comment('请求内容') TEXT"` WithDayData string `json:"with_day_data" xorm:"comment('待支付成功插入 central_kitchen_for_school_user_with_day') TEXT"` PayWay int `json:"pay_way" xorm:"not null default 1 comment('支付方式(1:支付宝 2:微信)') TINYINT(1)"` + PrepayId string `json:"prepay_id" xorm:"not null default '' comment('预支付交易会话标识。用于后续接口调用中使用,该值有效期为2小时(微信使用)') VARCHAR(255)"` CreateAt string `json:"create_at" xorm:"not null pk default 'CURRENT_TIMESTAMP' DATETIME"` UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` }