|
@@ -777,28 +777,21 @@ func (this *CommonAction) GetWxReturnPayParam() {
|
|
|
if !(payWayReq == "wx_js" || payWayReq == "ali_pc") {
|
|
|
return nil, fmt.Errorf("未知支付方式")
|
|
|
}
|
|
|
-
|
|
|
- rList := util.Mysql.SelectBySql("SELECT return_money,expire_time,pay_way,pay_param,pay_way,return_money,order_code FROM return_money_online r WHERE r.status=0 and r.token=? ", token)
|
|
|
+ rList := util.Mysql.SelectBySql("SELECT id,return_money,expire_time,return_money,order_code FROM return_money_online r WHERE r.status=0 and r.token=? ", token)
|
|
|
if rList == nil || len(*rList) == 0 {
|
|
|
return nil, fmt.Errorf("未知回款单")
|
|
|
}
|
|
|
var (
|
|
|
rMap = (*rList)[0]
|
|
|
expireTime = gconv.String(rMap["expire_time"])
|
|
|
- pay_param = gconv.String(rMap["pay_param"])
|
|
|
- payWay = gconv.String(rMap["pay_way"])
|
|
|
returnMoney = gconv.Int(rMap["return_money"])
|
|
|
OrderCode = gconv.String(rMap["order_code"])
|
|
|
+ returnId = gconv.Int(rMap["id"])
|
|
|
)
|
|
|
- if pay_param != "" {
|
|
|
- if payWay == payWayReq {
|
|
|
- return pay_param, nil
|
|
|
- }
|
|
|
- return "", fmt.Errorf("支付方式更变")
|
|
|
- }
|
|
|
var (
|
|
|
tradeno, payParam string
|
|
|
err error
|
|
|
+ openId string
|
|
|
)
|
|
|
expire, dateErr := time.ParseInLocation(time.DateTime, expireTime, time.Local)
|
|
|
if dateErr == nil {
|
|
@@ -813,36 +806,34 @@ func (this *CommonAction) GetWxReturnPayParam() {
|
|
|
case "wx_js":
|
|
|
var (
|
|
|
sessVal = this.Session().GetMultiple()
|
|
|
- openId = qutil.ObjToString(sessVal["s_m_openid"])
|
|
|
)
|
|
|
- if openId == "" {
|
|
|
+ if openId = qutil.ObjToString(sessVal["s_m_openid"]); openId == "" {
|
|
|
openId = qutil.ObjToString(sessVal["openid_returnMoney"])
|
|
|
}
|
|
|
if openId == "" {
|
|
|
return nil, fmt.Errorf("创建微信支付参数异常")
|
|
|
}
|
|
|
- tradeno, _, payParam, err = pay.CreateOrderPay(returnMoney, pay.WX_RETURN_NATIVE, "", openId, "", payWay, OrderCode, expire.Unix())
|
|
|
+ tradeno, _, payParam, err = pay.CreateOrderPay(returnMoney, pay.WX_RETURN_NATIVE, "", openId, "", payWayReq, OrderCode, expire.Unix())
|
|
|
if err != nil {
|
|
|
return nil, fmt.Errorf("创建微信支付异常")
|
|
|
}
|
|
|
case "ali_pc":
|
|
|
- tradeno, _, payParam, err = pay.CreateOrderPay(returnMoney, pay.ALI_RETURN_NATIVE, "", "", "", payWay, OrderCode, expire.Unix())
|
|
|
+ tradeno, _, payParam, err = pay.CreateOrderPay(returnMoney, pay.ALI_RETURN_NATIVE, "", "", "", payWayReq, OrderCode, expire.Unix())
|
|
|
if err != nil {
|
|
|
return nil, fmt.Errorf("创建支付宝支付异常")
|
|
|
}
|
|
|
}
|
|
|
//更新支付串
|
|
|
now := time.Now()
|
|
|
- if !util.Mysql.Update("return_money_online", map[string]interface{}{
|
|
|
- "status": 0,
|
|
|
- "token": token,
|
|
|
- }, map[string]interface{}{
|
|
|
- "order_code": OrderCode,
|
|
|
+ if util.Mysql.Insert("return_money_online_pay", map[string]interface{}{
|
|
|
+ "return_id": returnId,
|
|
|
"pay_param": payParam,
|
|
|
+ "s_openid": openId,
|
|
|
"out_trade_no": tradeno,
|
|
|
- "pay_way": payWay,
|
|
|
+ "order_code": OrderCode,
|
|
|
+ "pay_way": payWayReq,
|
|
|
"creat_time": FormatDate(&now, Date_Full_Layout),
|
|
|
- }) {
|
|
|
+ }) <= 0 {
|
|
|
return nil, fmt.Errorf("数据保存异常")
|
|
|
}
|
|
|
return payParam, nil
|
|
@@ -859,28 +850,26 @@ func (this *CommonAction) GetReturnResult() {
|
|
|
if token == "" {
|
|
|
return nil, fmt.Errorf("缺少参数")
|
|
|
}
|
|
|
- rData := util.Mysql.FindOne("return_money_online", map[string]interface{}{
|
|
|
- "token": token,
|
|
|
- }, "transaction_id,pay_time,status,order_code,pay_money,return_money", "")
|
|
|
- if rData == nil || len(*rData) == 0 {
|
|
|
- return nil, fmt.Errorf("未知回款单")
|
|
|
- }
|
|
|
var (
|
|
|
- r = map[string]interface{}{}
|
|
|
- status = gconv.Int((*rData)["status"])
|
|
|
+ payed bool
|
|
|
+ r = map[string]interface{}{}
|
|
|
)
|
|
|
- r["success"] = status > 0
|
|
|
- if status > 0 {
|
|
|
- r["order_code"] = (*rData)["order_code"]
|
|
|
- r["transaction_id"] = (*rData)["transaction_id"]
|
|
|
- r["pay_money"] = (*rData)["pay_money"]
|
|
|
- r["return_money"] = (*rData)["return_money"]
|
|
|
- if payTime := gconv.String((*rData)["pay_time"]); payTime != "" {
|
|
|
+ res := util.Mysql.SelectBySql("SELECT r.status,r.order_code,r.return_money,p.pay_time,p.transaction_id FROM return_money_online r inner join return_money_online_pay p on (r.id = p.return_id and p.status=1) WHERE r.token=?", token)
|
|
|
+ if res != nil && len(*res) > 0 {
|
|
|
+ var (
|
|
|
+ rData = (*res)[0]
|
|
|
+ )
|
|
|
+ payed = true
|
|
|
+ r["order_code"] = rData["order_code"]
|
|
|
+ r["transaction_id"] = rData["transaction_id"]
|
|
|
+ r["return_money"] = rData["return_money"]
|
|
|
+ if payTime := gconv.String(rData["pay_time"]); payTime != "" {
|
|
|
if t, e := time.ParseInLocation(time.DateTime, payTime, time.Local); e == nil {
|
|
|
r["pay_time"] = t.Unix()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ r["success"] = payed
|
|
|
return r, nil
|
|
|
}()
|
|
|
if errMsg != nil {
|