瀏覽代碼

update

tmp
DengBiao 8 月之前
父節點
當前提交
846611cc9b
共有 2 個文件被更改,包括 22 次插入3 次删除
  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 查看文件

@@ -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 查看文件

@@ -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…
取消
儲存