Browse Source

update

tmp
DengBiao 9 months ago
parent
commit
846611cc9b
2 changed files with 22 additions and 3 deletions
  1. +6
    -3
      app/customer/hdl/hdl_call_back.go
  2. +16
    -0
      app/utils/time.go

+ 6
- 3
app/customer/hdl/hdl_call_back.go View File

@@ -12,7 +12,6 @@ import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/wechatpay-apiv3/wechatpay-go/utils"
"time"
)

func AlipayJsApiCallBack(c *gin.Context) {
@@ -72,8 +71,12 @@ func WxJsApiCallBack(c *gin.Context) {
}

utils2.FilePutContents("WxJsApiCallBack", utils2.SerializeStr(resp))
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"))
successTime, err := utils2.ConvertWechatTime(resp.SuccessTime)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
_, err = svc.DealCentralKitchenForSchoolOrderCallBackForWx(resp.OutTradeNo, resp.TransactionId, resp.TradeState, successTime)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return


+ 16
- 0
app/utils/time.go View File

@@ -223,3 +223,19 @@ func GetLastDateOfMonth(d time.Time) time.Time {
func GetZeroTime(d time.Time) time.Time {
return time.Date(d.Year(), d.Month(), d.Day(), 0, 0, 0, 0, d.Location())
}

func ConvertWechatTime(wechatTime string) (string, error) {
const layout = time.RFC3339
parsedTime, err := time.Parse(layout, wechatTime)
if err != nil {
return "", err
}
// 转换到本地时区
localTime := parsedTime.In(time.Local)
// 格式化本地时间为指定的格式,例如:"2006-01-02 15:04:05"

formattedLocalTime := localTime.Format("2006-01-02 15:04:05")

// 返回转换后的时间字符串
return formattedLocalTime, nil
}

Loading…
Cancel
Save