Explorar o código

支持PayerMax支付URL

zhouxnsz hai 1 ano
pai
achega
3580859a3d
Modificáronse 7 ficheiros con 63 adicións e 35 borrados
  1. 1 0
      .gitignore
  2. 12 12
      config/config.xml
  3. 4 12
      controllers/bank/bank.go
  4. 4 4
      controllers/guangzuan/tradeService.go
  5. 11 6
      models/bank.go
  6. 29 0
      models/ori.go
  7. 2 1
      token/token.go

+ 1 - 0
.gitignore

@@ -9,3 +9,4 @@ go.sum
 mtp2_if.exe
 .idea
 __debug_bin*
+debug_*

+ 12 - 12
config/config.xml

@@ -49,18 +49,18 @@
     <Username value="quote_test136"/>
     <Password value="123456"/>
   </MySQLSetting>
-  <Tencent>
-    <Enabled value="1"/>
-    <SecretId value="AKyDwiyUUckpkct4igUy8lsS7SEqR6c7yR"/>
-    <SecretKey value="SKwvG74cbV3OrAiJdjU5k4507vZwNYDbwT"/>
-    <EndPoint value="essbasic.test.ess.tencent.cn"/>
-    <AppId value="yDCABUUckpyfbvkqUymdfGq8FhvR4fxy"/>
-    <ProxyOrganizationName value="测试永坤黄金"/>
-    <ProxyOrganizationOpenId value="YKHJ"/>
-    <ProxyOperatorOpenId value="YKHJ_LEGAL"/>
-    <SignToken value="9A9F0FA77A744EB294751C0F75FEDDE1"/>
-    <SignKey value="9AEFF9F8F9AD4DD69C4E0606EA121BDF"/>
-  </Tencent>
+<Tencent>
+  <Enabled value="1"/>
+  <SecretId value="AKIDPktwvneP2WqxvmWFsMclmfLLKDyrbAXp"/>
+  <SecretKey value="GNH9tX8c6Wls02vhNzUvdLuGMYfeVErM"/>
+  <EndPoint value="essbasic.tencentcloudapi.com"/>
+  <AppId value="yDCADUUpu1n1m4UEI0NjHCMBOg0yst3p"/>
+  <ProxyOrganizationName value="深圳市永坤黄金有限公司"/>
+  <ProxyOrganizationOpenId value="YKHJ"/>
+  <ProxyOperatorOpenId value="YKHJ_LEGAL"/>
+  <SignToken value="B2EF7AF0E61F4727ACAA57ED4765161B"/>
+  <SignKey value="468EA61DB12741D9928CC73B9628202D"/>
+</Tencent>
   <Asign>
     <Url value="https://prev.asign.cn"/>
     <AppId value="896210645"/>

+ 4 - 12
controllers/bank/bank.go

@@ -1,7 +1,6 @@
 package bank
 
 import (
-	"errors"
 	"mtp2_if/global/app"
 	"mtp2_if/global/e"
 	"mtp2_if/logger"
@@ -72,23 +71,16 @@ func GetAmtInByPaidUrl(c *gin.Context) {
 		return
 	}
 
-	rec, err := models.GetAmtInByPaid(req.AccountId, req.Exchticket)
-	if err != nil {
-		// 查询失败
-		logger.GetLogger().Errorf("GetAmtInByPaidUrl failed: %s", err.Error())
-		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
-		return
-	}
-	if rec == nil {
+	rec := models.GetAmtInByPaid(req.AccountId, req.Exchticket)
+	if rec == "" {
 		// 查询失败
-		err = errors.New("获取记录失败")
-		logger.GetLogger().Errorf("GetAmtInByPaidUrl failed: %s", err.Error())
+		logger.GetLogger().Error("GetAmtInByPaidUrl failed: 获取记录失败")
 		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
 		return
 	}
 
 	// 查询成功返回
-	appG.Response(http.StatusOK, e.SUCCESS, rec.PAYMENTURL)
+	appG.Response(http.StatusOK, e.SUCCESS, rec)
 }
 
 // GetCusBankInfos 获取托管银行信息列表

+ 4 - 4
controllers/guangzuan/tradeService.go

@@ -18,8 +18,8 @@ import (
 // @Security Group
 // @Param    userid   query    int    true  "用户ID"
 // @Param    executestatus query    int false "执行状态 - 1:未生效 2:进行中 3:已结束"
-// @Param    page     query    int    false "页码"
-// @Param    pagesize query    int    false "每页条数"
+// @Param    page          query    int false "页码"
+// @Param    pagesize      query    int false "每页条数"
 // @Success  200           {array}  models.GzcjjcorderM
 // @Failure  500     {object} app.Response
 // @Router   /Guangzuan/QueryGZCJJCOrder [get]
@@ -39,8 +39,8 @@ func QueryGZCJJCOrder(c *gin.Context) {
 // @Security Group
 // @Param    userid        query    int true  "用户ID"
 // @Param    orderid  query    string false "单据ID"
-// @Param    page          query    int false "页码"
-// @Param    pagesize      query    int false "每页条数"
+// @Param    page     query    int    false "页码"
+// @Param    pagesize query    int    false "每页条数"
 // @Success  200      {array}  models.GzcjjcorderdetailM
 // @Failure  500           {object} app.Response
 // @Router   /Guangzuan/QueryGZCJJCOrderDetail [get]

+ 11 - 6
models/bank.go

@@ -96,19 +96,24 @@ func (r *Bankbranchnuminfo) GetDataByPage() (interface{}, error, int, int, int)
 	return sData, err, r.Page, r.PageSize, total
 }
 
-func GetAmtInByPaid(accountId int, exchticket string) (*Chillpayamtinrec, error) {
+func GetAmtInByPaid(accountId int, exchticket string) string {
 	engine := db.GetEngine()
 
+	// 尝试 ChillPay
 	var rec Chillpayamtinrec
-	has, err := engine.Where("accountid = ? and exch_seq = ? and deal_status = 2", accountId, exchticket).Get(&rec)
-	if err != nil {
-		return nil, err
+	has, _ := engine.Where("accountid = ? and exch_seq = ? and deal_status = 2", accountId, exchticket).Get(&rec)
+	if has {
+		return rec.PAYMENTURL
 	}
+
+	// 尝试 PayerMax
+	var rec1 Payermaxamtinrec
+	has, _ = engine.Where("accountid = ? and exch_seq = ? and deal_status = 2", accountId, exchticket).Get(&rec1)
 	if has {
-		return &rec, nil
+		return rec1.REDIRECTURL
 	}
 
-	return nil, nil
+	return ""
 }
 
 func GetCusBankInfos() ([]Bankcusbankinfo, error) {

+ 29 - 0
models/ori.go

@@ -1096,6 +1096,35 @@ func (r *Chillpayamtinrec) TableName() string {
 	return "CHILLPAY_AMT_IN_REC"
 }
 
+// Payermaxamtinrec PayerMax 入金记录表
+type Payermaxamtinrec struct {
+	ID           int64     `json:"id" xorm:"ID"`                     // 自增ID
+	REC_VERSION  int64     `json:"rec_version" xorm:"REC_VERSION"`   // 乐观锁
+	EXCH_NO      string    `json:"exch_no" xorm:"EXCH_NO"`           // 交易所编号
+	EXCH_DATE    string    `json:"exch_date" xorm:"EXCH_DATE"`       // 交易日
+	EXCH_SEQ     string    `json:"exch_seq" xorm:"EXCH_SEQ"`         // 交易所流水号
+	DEAL_STATUS  int32     `json:"deal_status" xorm:"DEAL_STATUS"`   // 入金状态 0-成功 1-失败 2-已发送 3-初始化
+	DEAL_DESC    string    `json:"deal_desc" xorm:"DEAL_DESC"`       // 状态描述
+	CREATED_AT   time.Time `json:"created_at" xorm:"CREATED_AT"`     // 创建时间
+	UPDATED_AT   time.Time `json:"updated_at" xorm:"UPDATED_AT"`     // 修改时间
+	ACCOUNTID    int64     `json:"accountid" xorm:"ACCOUNTID"`       // 账户ID
+	AMOUNT       float64   `json:"amount" xorm:"AMOUNT"`             // 入金金额
+	OUTTRADENO   string    `json:"outtradeno" xorm:"OUTTRADENO"`     // 商户订单号
+	TRADETOKEN   string    `json:"tradetoken" xorm:"TRADETOKEN"`     // PayerMax流水号
+	REDIRECTURL  string    `json:"redirecturl" xorm:"REDIRECTURL"`   // 跳转地址
+	ORDERSTATUS  string    `json:"orderstatus" xorm:"ORDERSTATUS"`   // 平台交易状态
+	TOTALAMOUNT  string    `json:"totalamount" xorm:"TOTALAMOUNT"`   // 标价金额,金额的单位为元。
+	CURRENCY     string    `json:"currency" xorm:"CURRENCY"`         // 标价币种
+	COMPLETETIME string    `json:"completetime" xorm:"COMPLETETIME"` // 平台完成时间
+	RESULTMSG    string    `json:"resultmsg" xorm:"RESULTMSG"`       // 交易状态结果描述,仅失败时有值
+	RESPONSEBODY string    `json:"responsebody" xorm:"RESPONSEBODY"` // 回复数据
+}
+
+// TableName is PAYERMAX_AMT_IN_REC
+func (r *Payermaxamtinrec) TableName() string {
+	return "PAYERMAX_AMT_IN_REC"
+}
+
 // Bankcusbankinfo 托管银行信息表
 type Bankcusbankinfo struct {
 	CUSBANKID            string `json:"cusbankid" xorm:"CUSBANKID"`                   // 托管银行编号(对应清算中心TRAN_NO)

+ 2 - 1
token/token.go

@@ -8,6 +8,7 @@ import (
 	"fmt"
 	"mtp2_if/config"
 	"mtp2_if/global/e"
+	"mtp2_if/logger"
 	"mtp2_if/rediscli"
 	"net/http"
 	"runtime"
@@ -134,8 +135,8 @@ func Auth() gin.HandlerFunc {
 			}
 			now := time.Now().UTC().UnixMilli()
 			ts := int64(t) - now
-			// logger.GetLogger().Debugf("t:%v now:%v ts: %v", t, now, ts)
 			if ts < -10*1000 || ts > 10*1000 {
+				logger.GetLogger().Errorf("t:%v now:%v ts: %v", t, now, ts)
 				c.JSON(http.StatusUnauthorized, gin.H{
 					"code": e.ERROR,
 					"msg":  "apikey_err3",