From 1c740e34482b8bf0b7b4a07a91f2fa9ca3b612c2 Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Wed, 6 Mar 2024 18:29:22 +0800 Subject: [PATCH] update --- app/customer/hdl/hdl_call_back.go | 6 ++++-- app/customer/svc/svc_pay.go | 10 ++++++---- app/db/model/central_kitchen_for_school_package_ord.go | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/customer/hdl/hdl_call_back.go b/app/customer/hdl/hdl_call_back.go index 1bf16a2..a292952 100644 --- a/app/customer/hdl/hdl_call_back.go +++ b/app/customer/hdl/hdl_call_back.go @@ -12,6 +12,7 @@ import ( "fmt" "github.com/gin-gonic/gin" "github.com/wechatpay-apiv3/wechatpay-go/utils" + "time" ) func AlipayJsApiCallBack(c *gin.Context) { @@ -32,7 +33,7 @@ func AlipayJsApiCallBack(c *gin.Context) { c.String(200, "success") return } - _, err := svc.DealCentralKitchenForSchoolOrderCallBack(args.OutTradeNo, args.TradeStatus) + _, err := svc.DealCentralKitchenForSchoolOrderCallBack(args.OutTradeNo, args.TradeStatus, args.GmtPayment) if err != nil { e.OutErr(c, e.ERR, err.Error()) return @@ -71,7 +72,8 @@ func WxJsApiCallBack(c *gin.Context) { } utils2.FilePutContents("WxJsApiCallBack", utils2.SerializeStr(resp)) - _, err = svc.DealCentralKitchenForSchoolOrderCallBackForWx(resp.OutTradeNo, resp.TransactionId, resp.TradeState) + successTime, _ := time.ParseInLocation("2006-01-02 15:04:05", resp.SuccessTime, time.Local) + _, err = svc.DealCentralKitchenForSchoolOrderCallBackForWx(resp.OutTradeNo, resp.TransactionId, resp.TradeState, successTime.Format("2006-01-02 15:04:05")) 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 e3b2669..89c40b7 100644 --- a/app/customer/svc/svc_pay.go +++ b/app/customer/svc/svc_pay.go @@ -400,7 +400,7 @@ func NursingHomeBuyPackageReq(c *gin.Context, req md.NursingHomeBuyPackageReq) ( return } -func DealCentralKitchenForSchoolOrderCallBack(outTradeNo, tradeStatus string) (state int, err error) { +func DealCentralKitchenForSchoolOrderCallBack(outTradeNo, tradeStatus, successTime string) (state int, err error) { centralKitchenForSchoolPackageOrd := db.CentralKitchenForSchoolPackageOrd{} centralKitchenForSchoolPackageOrd.Set(outTradeNo) ord, err := centralKitchenForSchoolPackageOrd.GetCentralKitchenForSchoolPackageOrd() @@ -420,6 +420,7 @@ func DealCentralKitchenForSchoolOrderCallBack(outTradeNo, tradeStatus string) (s if tradeStatus == "TRADE_SUCCESS" { ord.State = enum2.CentralKitchenForSchoolPackageOrdStateForSuccess ord.OrdState = enum2.CentralKitchenForSchoolPackageOrdOrdStateForSuccess + ord.PayAt = successTime //TODO::将预留数据插入到 `central_kitchen_for_school_user_with_day` var data []*model.CentralKitchenForSchoolUserWithDay @@ -493,7 +494,7 @@ func DealCentralKitchenForSchoolOrderCallBack(outTradeNo, tradeStatus string) (s } } } - _, err = centralKitchenForSchoolPackageOrd.CentralKitchenForSchoolPackageOrdUpdate(ord, "state", "ord_state") + _, err = centralKitchenForSchoolPackageOrd.CentralKitchenForSchoolPackageOrdUpdate(ord, "state", "ord_state", "pay_at") if err != nil { return } @@ -502,7 +503,7 @@ func DealCentralKitchenForSchoolOrderCallBack(outTradeNo, tradeStatus string) (s return } -func DealCentralKitchenForSchoolOrderCallBackForWx(outTradeNo, transactionId, tradeStatus string) (state int, err error) { +func DealCentralKitchenForSchoolOrderCallBackForWx(outTradeNo, transactionId, tradeStatus, successTime string) (state int, err error) { centralKitchenForSchoolPackageOrd := db.CentralKitchenForSchoolPackageOrd{} centralKitchenForSchoolPackageOrd.Set(outTradeNo) ord, err := centralKitchenForSchoolPackageOrd.GetCentralKitchenForSchoolPackageOrd() @@ -523,6 +524,7 @@ func DealCentralKitchenForSchoolOrderCallBackForWx(outTradeNo, transactionId, tr ord.State = enum2.CentralKitchenForSchoolPackageOrdStateForSuccess ord.OrdState = enum2.CentralKitchenForSchoolPackageOrdOrdStateForSuccess ord.TradeNo = transactionId + ord.PayAt = successTime //TODO::将预留数据插入到 `central_kitchen_for_school_user_with_day` var data []*model.CentralKitchenForSchoolUserWithDay @@ -596,7 +598,7 @@ func DealCentralKitchenForSchoolOrderCallBackForWx(outTradeNo, transactionId, tr } } } - _, err = centralKitchenForSchoolPackageOrd.CentralKitchenForSchoolPackageOrdUpdate(ord, "state", "ord_state", "trade_no") + _, err = centralKitchenForSchoolPackageOrd.CentralKitchenForSchoolPackageOrdUpdate(ord, "state", "ord_state", "trade_no", "pay_at") 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 64a1541..8497c82 100644 --- a/app/db/model/central_kitchen_for_school_package_ord.go +++ b/app/db/model/central_kitchen_for_school_package_ord.go @@ -18,4 +18,5 @@ type CentralKitchenForSchoolPackageOrd struct { 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"` + PayAt string `json:"pay_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` }