Commit e7e87b3b authored by zhengxiuming's avatar zhengxiuming

update

parent 69307215
...@@ -11,8 +11,6 @@ import ( ...@@ -11,8 +11,6 @@ import (
"encoding/pem" "encoding/pem"
"errors" "errors"
"fmt" "fmt"
"github.com/astaxie/beego/httplib"
uID "github.com/satori/go.uuid"
"io/ioutil" "io/ioutil"
rand2 "math/rand" rand2 "math/rand"
"strconv" "strconv"
...@@ -21,15 +19,18 @@ import ( ...@@ -21,15 +19,18 @@ import (
"system_pay/mysql" "system_pay/mysql"
"system_pay/setting" "system_pay/setting"
"time" "time"
"github.com/astaxie/beego/httplib"
uID "github.com/satori/go.uuid"
) )
// 拉卡拉支付 // 拉卡拉支付
func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{}, error) { func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{}, error) {
//输入项check //输入项check
if input.SourceCode==0 { if input.SourceCode == 0 {
return nil, errors.New("输入项「source_code」为空错误") return nil, errors.New("输入项「source_code」为空错误")
} }
if input.PlatformType==0 { if input.PlatformType == 0 {
return nil, errors.New("输入项「platform_type」为空错误") return nil, errors.New("输入项「platform_type」为空错误")
} }
...@@ -72,7 +73,7 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{}, ...@@ -72,7 +73,7 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{},
var version, out_org_code, merchant_no1, merchant_no2, merchant_no3, term_no3, merchant_no4, term_no4 string var version, out_org_code, merchant_no1, merchant_no2, merchant_no3, term_no3, merchant_no4, term_no4 string
//平台类型 1:saas 2:shop 3:shop mobile 4:收银台 6:bk_shop 7:bk_shop_mobile //平台类型 1:saas 2:shop 3:shop mobile 4:收银台 6:bk_shop 7:bk_shop_mobile
if input.PlatformType==2 || input.PlatformType==3 { if input.PlatformType == 2 || input.PlatformType == 3 {
// 谛宝多多自营 // 谛宝多多自营
version = setting.Conf.Lakala.DbcVersion version = setting.Conf.Lakala.DbcVersion
out_org_code = setting.Conf.Lakala.DbcAppid out_org_code = setting.Conf.Lakala.DbcAppid
...@@ -82,7 +83,7 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{}, ...@@ -82,7 +83,7 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{},
term_no3 = setting.Conf.Lakala.DbcTermNo3 term_no3 = setting.Conf.Lakala.DbcTermNo3
merchant_no4 = setting.Conf.Lakala.DbcMerchantNo4 merchant_no4 = setting.Conf.Lakala.DbcMerchantNo4
term_no4 = setting.Conf.Lakala.DbcTermNo4 term_no4 = setting.Conf.Lakala.DbcTermNo4
} else if input.PlatformType==6 || input.PlatformType==7 { } else if input.PlatformType == 6 || input.PlatformType == 7 {
// 必康自营 // 必康自营
version = setting.Conf.Lakala.BkVersion version = setting.Conf.Lakala.BkVersion
out_org_code = setting.Conf.Lakala.BkAppid out_org_code = setting.Conf.Lakala.BkAppid
...@@ -114,9 +115,9 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{}, ...@@ -114,9 +115,9 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{},
//5:支付宝(web)-扫码或登录支付宝账户 6:alipay(mobile) 7:alipay(app) //5:支付宝(web)-扫码或登录支付宝账户 6:alipay(mobile) 7:alipay(app)
//9: B2C 10:bk支付宝web 11:bk 支付宝手机 15:快捷支付(银行卡) //9: B2C 10:bk支付宝web 11:bk 支付宝手机 15:快捷支付(银行卡)
//16:微信小程序-必康自营 17:微信JASPI-必康自营 18:支付宝 //16:微信小程序-必康自营 17:微信JASPI-必康自营 18:支付宝
if input.SourceCode==4 || input.SourceCode==6 ||input.SourceCode==1 || if input.SourceCode == 4 || input.SourceCode == 6 || input.SourceCode == 1 ||
input.SourceCode==5 || input.SourceCode==15 || input.SourceCode == 5 || input.SourceCode == 15 ||
input.SourceCode==16 || input.SourceCode==17 { input.SourceCode == 16 || input.SourceCode == 17 {
//聚合收银台(微信H5、支付宝H5、微信扫码、支付宝扫码) //聚合收银台(微信H5、支付宝H5、微信扫码、支付宝扫码)
//聚合收银台(快捷支付(银行卡)) //聚合收银台(快捷支付(银行卡))
//聚合收银台(微信小程序-必康自营) //聚合收银台(微信小程序-必康自营)
...@@ -126,15 +127,15 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{}, ...@@ -126,15 +127,15 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{},
input.NoticeURL = GetNoticeURL(input.SourceCode) input.NoticeURL = GetNoticeURL(input.SourceCode)
data2 := make(map[string]interface{}) data2 := make(map[string]interface{})
if input.SourceCode==4 || input.SourceCode==6 { if input.SourceCode == 4 || input.SourceCode == 6 {
data2["merchant_no"] = merchant_no1 //微信H5、支付宝H5 data2["merchant_no"] = merchant_no1 //微信H5、支付宝H5
} else { } else {
data2["merchant_no"] = merchant_no2 //其它 data2["merchant_no"] = merchant_no2 //其它
} }
data2["total_amount"] = input.GoodsPrice*100 data2["total_amount"] = input.GoodsPrice * 100
data2["out_order_no"] = orderID //随机生成的订单号 //商户订单号 data2["out_order_no"] = orderID //随机生成的订单号 //商户订单号
if input.SourceCode==15 { if input.SourceCode == 15 {
//快捷支付 //快捷支付
data2["counter_param"] = "{\"pay_mode\":\"QUICK_PAY\"}" data2["counter_param"] = "{\"pay_mode\":\"QUICK_PAY\"}"
if input.AuthCodes != "" { if input.AuthCodes != "" {
...@@ -142,7 +143,7 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{}, ...@@ -142,7 +143,7 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{},
auth_codes := strings.Split(input.AuthCodes, ",") auth_codes := strings.Split(input.AuthCodes, ",")
data2["sgn_info"] = auth_codes //签约协议号列表(字符串) data2["sgn_info"] = auth_codes //签约协议号列表(字符串)
} }
} else if input.SourceCode < 5 || input.SourceCode==16 || input.SourceCode==17 { } else if input.SourceCode < 5 || input.SourceCode == 16 || input.SourceCode == 17 {
//微信 //微信
data2["counter_param"] = "{\"pay_mode\":\"WECHAT\"}" data2["counter_param"] = "{\"pay_mode\":\"WECHAT\"}"
} else { } else {
...@@ -155,12 +156,12 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{}, ...@@ -155,12 +156,12 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{},
data2["callback_url"] = input.ReturnURL //客户端下单完成支付后返回的商户网页跳转地址 data2["callback_url"] = input.ReturnURL //客户端下单完成支付后返回的商户网页跳转地址
data2["order_info"] = input.PlatformInfo //订单标题,在使用收银台扫码支付时必输入,交易时送往账户端 data2["order_info"] = input.PlatformInfo //订单标题,在使用收银台扫码支付时必输入,交易时送往账户端
//data2["goods_mark"] = input.AttachInfo //商品信息标识 (1:含商品信息,不填默认不含商品信息) //data2["goods_mark"] = input.AttachInfo //商品信息标识 (1:含商品信息,不填默认不含商品信息)
data2["support_refund"] = 1 //是否支持退款 默认0 不支持 data2["support_refund"] = 1 //是否支持退款 默认0 不支持
data["req_data"] = make(map[string]interface{}) data["req_data"] = make(map[string]interface{})
data["req_data"] = data2 data["req_data"] = data2
} else if input.SourceCode==2 || input.SourceCode==3 || input.SourceCode==18 { } else if input.SourceCode == 2 || input.SourceCode == 3 || input.SourceCode == 18 {
//聚合主扫(微信JSAPI、微信小程序、支付宝) //聚合主扫(微信JSAPI、微信小程序、支付宝)
url = setting.Conf.Lakala.UrlPreorder //聚合主扫 url = setting.Conf.Lakala.UrlPreorder //聚合主扫
...@@ -170,20 +171,20 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{}, ...@@ -170,20 +171,20 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{},
data2 := make(map[string]interface{}) data2 := make(map[string]interface{})
data2["merchant_no"] = merchant_no3 data2["merchant_no"] = merchant_no3
data2["term_no"] = term_no3 data2["term_no"] = term_no3
data2["total_amount"] = input.GoodsPrice*100 data2["total_amount"] = input.GoodsPrice * 100
data2["out_trade_no"] = orderID //随机生成的订单号 //商户交易流水号 data2["out_trade_no"] = orderID //随机生成的订单号 //商户交易流水号
//data2["order_efficient_time"] = date_time2 //订单有效期 格式yyyyMMddHHmmss,最大支持下单时间+2天 //data2["order_efficient_time"] = date_time2 //订单有效期 格式yyyyMMddHHmmss,最大支持下单时间+2天
data2["notify_url"] = input.NoticeURL //订单支付成功后商户接收订单通知的地址 http://xxx.xxx.com data2["notify_url"] = input.NoticeURL //订单支付成功后商户接收订单通知的地址 http://xxx.xxx.com
//data2["callback_url"] = input.ReturnURL //客户端下单完成支付后返回的商户网页跳转地址 //data2["callback_url"] = input.ReturnURL //客户端下单完成支付后返回的商户网页跳转地址
data2["subject"] = input.PlatformInfo //订单标题,在使用收银台扫码支付时必输入,交易时送往账户端 data2["subject"] = input.PlatformInfo //订单标题,在使用收银台扫码支付时必输入,交易时送往账户端
//data2["goods_mark"] = input.AttachInfo //商品信息标识 (1:含商品信息,不填默认不含商品信息) //data2["goods_mark"] = input.AttachInfo //商品信息标识 (1:含商品信息,不填默认不含商品信息)
//微信JSAPI、微信小程序 //微信JSAPI、微信小程序
if input.SourceCode==2 { if input.SourceCode == 2 {
data2["trans_type"] = "71" //接入方式:微信小程序 data2["trans_type"] = "71" //接入方式:微信小程序
} else if input.SourceCode==18 { } else if input.SourceCode == 18 {
data2["trans_type"] = "41" //接入方式:ALIPAY data2["trans_type"] = "41" //接入方式:ALIPAY
} else { } else {
data2["trans_type"] = "51" //接入方式:微信JSAPI data2["trans_type"] = "51" //接入方式:微信JSAPI
...@@ -195,7 +196,7 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{}, ...@@ -195,7 +196,7 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{},
data2["location_info"] = make(map[string]interface{}) data2["location_info"] = make(map[string]interface{})
data2["location_info"] = data3 data2["location_info"] = data3
if input.SourceCode==18 { if input.SourceCode == 18 {
data2["account_type"] = "ALIPAY" //钱包类型 data2["account_type"] = "ALIPAY" //钱包类型
} else { } else {
data2["account_type"] = "WECHAT" //钱包类型 data2["account_type"] = "WECHAT" //钱包类型
...@@ -212,9 +213,9 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{}, ...@@ -212,9 +213,9 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{},
data["req_data"] = make(map[string]interface{}) data["req_data"] = make(map[string]interface{})
data["req_data"] = data2 data["req_data"] = data2
} else if input.SourceCode==9 { } else if input.SourceCode == 9 {
//聚合被扫(扫码枪) //聚合被扫(扫码枪)
if input.DynamicID=="" { if input.DynamicID == "" {
tx.Rollback() tx.Rollback()
return nil, errors.New("输入项「dynamic_id」为空错误") return nil, errors.New("输入项「dynamic_id」为空错误")
} }
...@@ -227,7 +228,7 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{}, ...@@ -227,7 +228,7 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{},
data2["out_trade_no"] = orderID //随机生成的订单号 //商户交易流水号 data2["out_trade_no"] = orderID //随机生成的订单号 //商户交易流水号
//扫码支付授权码,设备读取用户APP中的条码或者二维码信息,用户付款码条形码规则见说明 //扫码支付授权码,设备读取用户APP中的条码或者二维码信息,用户付款码条形码规则见说明
data2["auth_code"] = input.DynamicID data2["auth_code"] = input.DynamicID
data2["total_amount"] = input.GoodsPrice*100 data2["total_amount"] = input.GoodsPrice * 100
data3 := make(map[string]interface{}) data3 := make(map[string]interface{})
data3["request_ip"] = ip data3["request_ip"] = ip
...@@ -261,7 +262,7 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{}, ...@@ -261,7 +262,7 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{},
return nil, err return nil, err
} }
if input.SourceCode==9 { if input.SourceCode == 9 {
//收钱吧(扫码枪) //收钱吧(扫码枪)
//调拉卡拉接口 //调拉卡拉接口
...@@ -280,8 +281,8 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{}, ...@@ -280,8 +281,8 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{},
tx.Rollback() tx.Rollback()
return nil, err return nil, err
} }
fmt.Println("谛宝多多拼接后返回值:") fmt.Println("谛宝多多拼接后返回值:")
fmt.Println(response) fmt.Println(response)
// 插入下单成功后返回的参数 // 插入下单成功后返回的参数
err = InsertPayBillDetailResponseBody(tx, billID, lakala_rtn) err = InsertPayBillDetailResponseBody(tx, billID, lakala_rtn)
if err != nil { if err != nil {
...@@ -298,9 +299,9 @@ fmt.Println(response) ...@@ -298,9 +299,9 @@ fmt.Println(response)
func lakala_post(input *models.PlaceAnOrderParamInput, url, order_id string, data_json []byte) (error, interface{}, interface{}) { func lakala_post(input *models.PlaceAnOrderParamInput, url, order_id string, data_json []byte) (error, interface{}, interface{}) {
var source_code, platform_type uint8 var source_code, platform_type uint8
if input==nil { if input == nil {
source_code = 0 //支付方式 source_code = 0 //支付方式
platform_type = 0 //平台类型 platform_type = 0 //平台类型
} else { } else {
source_code = input.SourceCode //支付方式 source_code = input.SourceCode //支付方式
platform_type = input.PlatformType //平台类型 platform_type = input.PlatformType //平台类型
...@@ -332,7 +333,7 @@ func lakala_post(input *models.PlaceAnOrderParamInput, url, order_id string, dat ...@@ -332,7 +333,7 @@ func lakala_post(input *models.PlaceAnOrderParamInput, url, order_id string, dat
fmt.Println("拉卡拉返回值") fmt.Println("拉卡拉返回值")
fmt.Println(temp) fmt.Println(temp)
if temp["code"] != "000000" && temp["code"] != "BBS00000"{ if temp["code"] != "000000" && temp["code"] != "BBS00000" {
//this.Data["json"] = utils.CheckError(errors.New("拉卡拉错误"), temp["msg"].(string)) //todo //this.Data["json"] = utils.CheckError(errors.New("拉卡拉错误"), temp["msg"].(string)) //todo
//this.ServeJSON() //this.ServeJSON()
return errors.New(temp["msg"].(string)), "", temp return errors.New(temp["msg"].(string)), "", temp
...@@ -340,19 +341,19 @@ func lakala_post(input *models.PlaceAnOrderParamInput, url, order_id string, dat ...@@ -340,19 +341,19 @@ func lakala_post(input *models.PlaceAnOrderParamInput, url, order_id string, dat
response := make(map[string]string) response := make(map[string]string)
response["out_trade_no"] = order_id response["out_trade_no"] = order_id
if source_code==4 || source_code==6 || source_code==1 || source_code==5 || source_code==15 || input.SourceCode==16 || input.SourceCode==17 { if source_code == 4 || source_code == 6 || source_code == 1 || source_code == 5 || source_code == 15 || input.SourceCode == 16 || input.SourceCode == 17 {
//聚合收银台(微信H5、支付宝H5、微信扫码、支付宝扫码、快捷支付(银行卡)(包括微信小程序)) //聚合收银台(微信H5、支付宝H5、微信扫码、支付宝扫码、快捷支付(银行卡)(包括微信小程序))
//聚合收银台(微信小程序-必康自营)、聚合JSAPI(微信小程序-必康自营) //聚合收银台(微信小程序-必康自营)、聚合JSAPI(微信小程序-必康自营)
temp2, _ := temp["resp_data"].(map[string]interface{}) temp2, _ := temp["resp_data"].(map[string]interface{})
if temp2["counter_url"]=="" { if temp2["counter_url"] == "" {
return errors.New("拉卡拉返回值「counter_url」为空错误"), "", temp return errors.New("拉卡拉返回值「counter_url」为空错误"), "", temp
} }
if source_code==4 || source_code==6 || source_code==15 || source_code==17 { if source_code == 4 || source_code == 6 || source_code == 15 || source_code == 17 {
//微信H5、支付宝H5、快捷支付(银行卡)(包括微信小程序) //微信H5、支付宝H5、快捷支付(银行卡)(包括微信小程序)
//聚合收银台(微信JSAPI-必康自营) //聚合收银台(微信JSAPI-必康自营)
response["m_web_url"] = temp2["counter_url"].(string) response["m_web_url"] = temp2["counter_url"].(string)
} else if source_code==1 || source_code==5 { } else if source_code == 1 || source_code == 5 {
//微信扫码、支付宝扫码 //微信扫码、支付宝扫码
response["qr_code_url"] = temp2["counter_url"].(string) response["qr_code_url"] = temp2["counter_url"].(string)
} else { } else {
...@@ -360,29 +361,30 @@ func lakala_post(input *models.PlaceAnOrderParamInput, url, order_id string, dat ...@@ -360,29 +361,30 @@ func lakala_post(input *models.PlaceAnOrderParamInput, url, order_id string, dat
response["counter_url"] = temp2["counter_url"].(string) response["counter_url"] = temp2["counter_url"].(string)
} }
} else if source_code==2 || source_code==3 { } else if source_code == 2 || source_code == 3 {
//聚合主扫(微信JSAPI、微信小程序)(必康自营的微信小程序除外) //聚合主扫(微信JSAPI、微信小程序)(必康自营的微信小程序除外)
temp2, _ := temp["resp_data"].(map[string]interface{}) temp2, _ := temp["resp_data"].(map[string]interface{})
temp3, _ := temp2["acc_resp_fields"].(map[string]interface{}) temp3, _ := temp2["acc_resp_fields"].(map[string]interface{})
if temp2["acc_resp_fields"]=="" { if temp2["acc_resp_fields"] == "" {
return errors.New("拉卡拉返回值「acc_resp_fields」为空错误"), "", temp return errors.New("拉卡拉返回值「acc_resp_fields」为空错误"), "", temp
} }
response["app_id"] = temp3["app_id"].(string) response["app_id"] = temp3["app_id"].(string)
response["app_id"] = temp3["trade_no"].(string)
response["nonce_str"] = temp3["nonce_str"].(string) response["nonce_str"] = temp3["nonce_str"].(string)
response["package"] = temp3["package"].(string) response["package"] = temp3["package"].(string)
response["pay_sign"] = temp3["pay_sign"].(string) response["pay_sign"] = temp3["pay_sign"].(string)
response["prepay_id"] = temp3["prepay_id"].(string) response["prepay_id"] = temp3["prepay_id"].(string)
response["sign_type"] = temp3["sign_type"].(string) response["sign_type"] = temp3["sign_type"].(string)
response["timeStamp"] = temp3["time_stamp"].(string) response["timeStamp"] = temp3["time_stamp"].(string)
} else if source_code==18 { } else if source_code == 18 {
//聚合主扫(支付宝) //聚合主扫(支付宝)
temp2, _ := temp["resp_data"].(map[string]interface{}) temp2, _ := temp["resp_data"].(map[string]interface{})
if temp2["out_trade_no"]=="" { if temp2["out_trade_no"] == "" {
return errors.New("拉卡拉返回值「out_trade_no」为空错误"), "", temp return errors.New("拉卡拉返回值「out_trade_no」为空错误"), "", temp
} }
out_trade_no := temp2["out_trade_no"].(string) out_trade_no := temp2["out_trade_no"].(string)
if temp2["acc_resp_fields"]=="" { if temp2["acc_resp_fields"] == "" {
return errors.New("拉卡拉返回值「acc_resp_fields」为空错误"), "", temp return errors.New("拉卡拉返回值「acc_resp_fields」为空错误"), "", temp
} }
temp3, _ := temp2["acc_resp_fields"].(map[string]interface{}) temp3, _ := temp2["acc_resp_fields"].(map[string]interface{})
...@@ -391,7 +393,7 @@ func lakala_post(input *models.PlaceAnOrderParamInput, url, order_id string, dat ...@@ -391,7 +393,7 @@ func lakala_post(input *models.PlaceAnOrderParamInput, url, order_id string, dat
//out_trade_no := temp3["out_trade_no"].(string) //out_trade_no := temp3["out_trade_no"].(string)
response["url"] = url + "?biz_content={\"out_trade_no\":\"" + out_trade_no + "\"}" response["url"] = url + "?biz_content={\"out_trade_no\":\"" + out_trade_no + "\"}"
return nil, response["url"], temp return nil, response["url"], temp
} else if source_code==9 { } else if source_code == 9 {
//扫码枪 //扫码枪
//mBody := map[string]string{ //mBody := map[string]string{
// "payment_order_code": orderID, // "payment_order_code": orderID,
...@@ -406,12 +408,12 @@ func getAuthorization(platform_type uint8, body string) (string, error) { ...@@ -406,12 +408,12 @@ func getAuthorization(platform_type uint8, body string) (string, error) {
var path_private_key, appid, mchSerialNo string //私钥文件地址 var path_private_key, appid, mchSerialNo string //私钥文件地址
//平台类型 1:saas 2:shop 3:shop mobile 4:收银台 6:bk_shop 7:bk_shop_mobile //平台类型 1:saas 2:shop 3:shop mobile 4:收银台 6:bk_shop 7:bk_shop_mobile
if platform_type==2 || platform_type==3 { if platform_type == 2 || platform_type == 3 {
// 谛宝多多自营 // 谛宝多多自营
appid = setting.Conf.Lakala.DbcAppid appid = setting.Conf.Lakala.DbcAppid
mchSerialNo = setting.Conf.Lakala.DbcSerialNo mchSerialNo = setting.Conf.Lakala.DbcSerialNo
path_private_key = setting.Conf.Lakala.DbcPathPrivateKey path_private_key = setting.Conf.Lakala.DbcPathPrivateKey
} else if platform_type==6 || platform_type==7 { } else if platform_type == 6 || platform_type == 7 {
// 必康自营 // 必康自营
appid = setting.Conf.Lakala.BkAppid appid = setting.Conf.Lakala.BkAppid
mchSerialNo = setting.Conf.Lakala.BkSerialNo mchSerialNo = setting.Conf.Lakala.BkSerialNo
...@@ -426,8 +428,7 @@ func getAuthorization(platform_type uint8, body string) (string, error) { ...@@ -426,8 +428,7 @@ func getAuthorization(platform_type uint8, body string) (string, error) {
nonceStr := RandomString(32) // 构造随机数 nonceStr := RandomString(32) // 构造随机数
timestamp := strconv.FormatInt(time.Now().Unix(), 10) timestamp := strconv.FormatInt(time.Now().Unix(), 10)
message := appid + "\n" + mchSerialNo + "\n" + timestamp + "\n" + nonceStr + "\n" + body + "\n"; message := appid + "\n" + mchSerialNo + "\n" + timestamp + "\n" + nonceStr + "\n" + body + "\n"
//todo 退款时,证书??? //todo 退款时,证书???
//return "", errors.New("输入项「平台类型(platform_type)」数据错误") //return "", errors.New("输入项「平台类型(platform_type)」数据错误")
...@@ -440,7 +441,7 @@ func getAuthorization(platform_type uint8, body string) (string, error) { ...@@ -440,7 +441,7 @@ func getAuthorization(platform_type uint8, body string) (string, error) {
//fmt.Println("签名2:", base64Sig) //fmt.Println("签名2:", base64Sig)
signature := base64Sig signature := base64Sig
authorization := "LKLAPI-SHA256withRSA " + "appid=\"" + appid + "\"," + "serial_no=\"" + mchSerialNo + "\"," + "timestamp=\"" + timestamp + "\"," + "nonce_str=\"" + nonceStr + "\"," + "signature=\"" + signature + "\""; authorization := "LKLAPI-SHA256withRSA " + "appid=\"" + appid + "\"," + "serial_no=\"" + mchSerialNo + "\"," + "timestamp=\"" + timestamp + "\"," + "nonce_str=\"" + nonceStr + "\"," + "signature=\"" + signature + "\""
//System.out.println("authorization message :" + authorization); //System.out.println("authorization message :" + authorization);
return authorization, nil return authorization, nil
...@@ -503,7 +504,7 @@ func ReadParsePrivaterKey(filename string) (*rsa.PrivateKey, error) { ...@@ -503,7 +504,7 @@ func ReadParsePrivaterKey(filename string) (*rsa.PrivateKey, error) {
// GetNoticeURL is 获取回调地址 // GetNoticeURL is 获取回调地址
func GetNoticeURL(source_code uint8) string { func GetNoticeURL(source_code uint8) string {
domainName := setting.Conf.PayUrl.DomainName domainName := setting.Conf.PayUrl.DomainName
if source_code==2 || source_code==3 || source_code==9 || source_code==18 { if source_code == 2 || source_code == 3 || source_code == 9 || source_code == 18 {
//聚合扫码+聚合被扫 //聚合扫码+聚合被扫
return domainName + "/api/v1/pay/scan_notice" return domainName + "/api/v1/pay/scan_notice"
} else { } else {
...@@ -639,7 +640,7 @@ func UnifiedRefund(input *models.RefundParamInput, ip string) (interface{}, erro ...@@ -639,7 +640,7 @@ func UnifiedRefund(input *models.RefundParamInput, ip string) (interface{}, erro
var version, out_org_code, merchant_no1, merchant_no2, merchant_no3, term_no3, merchant_no4, term_no4 string var version, out_org_code, merchant_no1, merchant_no2, merchant_no3, term_no3, merchant_no4, term_no4 string
//平台类型 1:saas 2:shop 3:shop mobile 4:收银台 6:bk_shop 7:bk_shop_mobile //平台类型 1:saas 2:shop 3:shop mobile 4:收银台 6:bk_shop 7:bk_shop_mobile
if platform_type==2 || platform_type==3 { if platform_type == 2 || platform_type == 3 {
// 谛宝多多自营 // 谛宝多多自营
version = setting.Conf.Lakala.DbcVersion version = setting.Conf.Lakala.DbcVersion
out_org_code = setting.Conf.Lakala.DbcAppid out_org_code = setting.Conf.Lakala.DbcAppid
...@@ -649,7 +650,7 @@ func UnifiedRefund(input *models.RefundParamInput, ip string) (interface{}, erro ...@@ -649,7 +650,7 @@ func UnifiedRefund(input *models.RefundParamInput, ip string) (interface{}, erro
term_no3 = setting.Conf.Lakala.DbcTermNo3 term_no3 = setting.Conf.Lakala.DbcTermNo3
merchant_no4 = setting.Conf.Lakala.DbcMerchantNo4 merchant_no4 = setting.Conf.Lakala.DbcMerchantNo4
term_no4 = setting.Conf.Lakala.DbcTermNo4 term_no4 = setting.Conf.Lakala.DbcTermNo4
} else if platform_type==6 || platform_type==7 { } else if platform_type == 6 || platform_type == 7 {
// 必康自营 // 必康自营
version = setting.Conf.Lakala.BkVersion version = setting.Conf.Lakala.BkVersion
out_org_code = setting.Conf.Lakala.BkAppid out_org_code = setting.Conf.Lakala.BkAppid
...@@ -674,7 +675,7 @@ func UnifiedRefund(input *models.RefundParamInput, ip string) (interface{}, erro ...@@ -674,7 +675,7 @@ func UnifiedRefund(input *models.RefundParamInput, ip string) (interface{}, erro
var url string var url string
data := make(map[string]interface{}) data := make(map[string]interface{})
if source_code==15 { if source_code == 15 {
//快捷支付(银行卡) //快捷支付(银行卡)
url = setting.Conf.Lakala.UrlTradeRefund //统一退货接口 url = setting.Conf.Lakala.UrlTradeRefund //统一退货接口
} else { } else {
...@@ -692,15 +693,15 @@ func UnifiedRefund(input *models.RefundParamInput, ip string) (interface{}, erro ...@@ -692,15 +693,15 @@ func UnifiedRefund(input *models.RefundParamInput, ip string) (interface{}, erro
//5:支付宝(web)-扫码或登录支付宝账户 6:alipay(mobile) 7:alipay(app) //5:支付宝(web)-扫码或登录支付宝账户 6:alipay(mobile) 7:alipay(app)
//9: B2C 10:bk支付宝web 11:bk 支付宝手机 15:快捷支付(银行卡) //9: B2C 10:bk支付宝web 11:bk 支付宝手机 15:快捷支付(银行卡)
//16:微信小程序-必康自营 17:微信JASPI-必康自营 //16:微信小程序-必康自营 17:微信JASPI-必康自营
if source_code==4 || source_code==6 || source_code==1 || if source_code == 4 || source_code == 6 || source_code == 1 ||
source_code==5 || source_code==15 || source_code == 5 || source_code == 15 ||
source_code==16 || source_code==17 { source_code == 16 || source_code == 17 {
//聚合收银台(微信H5、支付宝H5、微信扫码、支付宝扫码) //聚合收银台(微信H5、支付宝H5、微信扫码、支付宝扫码)
//聚合收银台(快捷支付(银行卡)) //聚合收银台(快捷支付(银行卡))
//聚合收银台(微信小程序-必康自营、微信JASPI-必康自营) //聚合收银台(微信小程序-必康自营、微信JASPI-必康自营)
//data2["merchant_no"] = "8221210701101SB" //data2["merchant_no"] = "8221210701101SB"
//data2["merchant_no"] = "8222900581201QB" //data2["merchant_no"] = "8222900581201QB"
if source_code==4 || source_code==6 { if source_code == 4 || source_code == 6 {
data2["merchant_no"] = merchant_no1 //微信H5、支付宝H5 data2["merchant_no"] = merchant_no1 //微信H5、支付宝H5
} else { } else {
data2["merchant_no"] = merchant_no2 //其它 data2["merchant_no"] = merchant_no2 //其它
...@@ -708,7 +709,7 @@ func UnifiedRefund(input *models.RefundParamInput, ip string) (interface{}, erro ...@@ -708,7 +709,7 @@ func UnifiedRefund(input *models.RefundParamInput, ip string) (interface{}, erro
//收银台支付时,没有传「term_no」,所以需要取得支付返回值的「trans_term_no」 //收银台支付时,没有传「term_no」,所以需要取得支付返回值的「trans_term_no」
data2["term_no"] = trans_term_no data2["term_no"] = trans_term_no
} else if source_code==2 || source_code==3 { } else if source_code == 2 || source_code == 3 {
//聚合主扫(微信JSAPI、微信小程序、支付宝) //聚合主扫(微信JSAPI、微信小程序、支付宝)
//data2["merchant_no"] = "8222900701107M5" //data2["merchant_no"] = "8222900701107M5"
//data2["term_no"] = "A1062976" //data2["term_no"] = "A1062976"
...@@ -716,7 +717,7 @@ func UnifiedRefund(input *models.RefundParamInput, ip string) (interface{}, erro ...@@ -716,7 +717,7 @@ func UnifiedRefund(input *models.RefundParamInput, ip string) (interface{}, erro
data2["merchant_no"] = merchant_no3 data2["merchant_no"] = merchant_no3
data2["term_no"] = term_no3 data2["term_no"] = term_no3
} else if source_code==9 { } else if source_code == 9 {
//扫码枪 //扫码枪
data2["merchant_no"] = merchant_no4 data2["merchant_no"] = merchant_no4
data2["term_no"] = term_no4 data2["term_no"] = term_no4
...@@ -730,18 +731,18 @@ func UnifiedRefund(input *models.RefundParamInput, ip string) (interface{}, erro ...@@ -730,18 +731,18 @@ func UnifiedRefund(input *models.RefundParamInput, ip string) (interface{}, erro
//扫码支付授权码,设备读取用户APP中的条码或者二维码信息,用户付款码条形码规则见说明 //扫码支付授权码,设备读取用户APP中的条码或者二维码信息,用户付款码条形码规则见说明
//data2["auth_code"] = "135178236713755038" //data2["auth_code"] = "135178236713755038"
//data2["auth_code"] = input.DynamicID //data2["auth_code"] = input.DynamicID
data2["refund_amount"] = input.RefundAmount*100 //退款金额 data2["refund_amount"] = input.RefundAmount * 100 //退款金额
data2["refund_reason"] = input.RefundReason //退款原因 data2["refund_reason"] = input.RefundReason //退款原因
//input.OrderId = "2023070566210308960791" //input.OrderId = "2023070566210308960791"
//data2["origin_out_trade_no"] = input.OrderId //原商户交易流水号 //data2["origin_out_trade_no"] = input.OrderId //原商户交易流水号
//data2["origin_trade_no"] = input.OrderId //原拉卡拉交易流水号 //data2["origin_trade_no"] = input.OrderId //原拉卡拉交易流水号
//data2["origin_log_no"] = input.OrderId //原对账单流水号 //data2["origin_log_no"] = input.OrderId //原对账单流水号
if source_code==15 { if source_code == 15 {
//快捷支付(银行卡) //快捷支付(银行卡)
data2["origin_biz_type"] = "4" //原交易类型:1 银行卡,2 外卡,3 扫码,4 线上 data2["origin_biz_type"] = "4" //原交易类型:1 银行卡,2 外卡,3 扫码,4 线上
data2["refund_type"] = "00" //当商户进件时退货模式配置的为 指定模式退货时,该字段有效。00:退货帐户,05:商户余额退货,06:终端余额退货 data2["refund_type"] = "00" //当商户进件时退货模式配置的为 指定模式退货时,该字段有效。00:退货帐户,05:商户余额退货,06:终端余额退货
//data2["origin_card_no"] = "621700*********0114" todo //data2["origin_card_no"] = "621700*********0114" todo
data2["origin_card_no"] = payer_account_no //原交易银行卡号,银行卡退款必填 data2["origin_card_no"] = payer_account_no //原交易银行卡号,银行卡退款必填
//data2["origin_trade_no"] = //原交易拉卡拉交易订单号 //data2["origin_trade_no"] = //原交易拉卡拉交易订单号
...@@ -750,7 +751,6 @@ func UnifiedRefund(input *models.RefundParamInput, ip string) (interface{}, erro ...@@ -750,7 +751,6 @@ func UnifiedRefund(input *models.RefundParamInput, ip string) (interface{}, erro
data2["origin_log_no"] = log_no //原对账单流水号 data2["origin_log_no"] = log_no //原对账单流水号
data3 := make(map[string]interface{}) data3 := make(map[string]interface{})
//data3["request_ip"] = "10.176.1.192" //data3["request_ip"] = "10.176.1.192"
data3["request_ip"] = ip data3["request_ip"] = ip
...@@ -828,13 +828,13 @@ func selectRefundBill(tx *sql.Tx, input *models.RefundParamInput) (string, strin ...@@ -828,13 +828,13 @@ func selectRefundBill(tx *sql.Tx, input *models.RefundParamInput) (string, strin
return "", "", 0, 0, "", "", err return "", "", 0, 0, "", "", err
} }
if source_code==2 || source_code==3 { if source_code == 2 || source_code == 3 {
//聚合扫码 //聚合扫码
notice_request = new(models.ScanNoticeInput) notice_request = new(models.ScanNoticeInput)
if err := json.Unmarshal(notice_request2, &notice_request); err != nil { if err := json.Unmarshal(notice_request2, &notice_request); err != nil {
return "", "", 0, 0, "", "", err return "", "", 0, 0, "", "", err
} }
} else if source_code==9 { } else if source_code == 9 {
//聚合被扫 //聚合被扫
notice_request = make(map[string]interface{}, 0) notice_request = make(map[string]interface{}, 0)
if err := json.Unmarshal(notice_response, &notice_request); err != nil { if err := json.Unmarshal(notice_response, &notice_request); err != nil {
...@@ -869,19 +869,19 @@ func selectRefundBill(tx *sql.Tx, input *models.RefundParamInput) (string, strin ...@@ -869,19 +869,19 @@ func selectRefundBill(tx *sql.Tx, input *models.RefundParamInput) (string, strin
return "", "", 0, 0, "", "", errors.New("订单未结算") return "", "", 0, 0, "", "", errors.New("订单未结算")
} }
if source_code==0 { if source_code == 0 {
return "", "", 0, 0, "", "", errors.New("「source_code」错误,有效值为[1-6,9,15-17]") return "", "", 0, 0, "", "", errors.New("「source_code」错误,有效值为[1-6,9,15-17]")
} }
// 获取「对账单流水号」、「交易终端号」和「付款人账号」,退款用 // 获取「对账单流水号」、「交易终端号」和「付款人账号」,退款用
var log_no, trans_term_no, payer_account_no string var log_no, trans_term_no, payer_account_no string
if source_code==2 || source_code==3 { if source_code == 2 || source_code == 3 {
//聚合扫码 //聚合扫码
log_no = notice_request.(*models.ScanNoticeInput).LogNo log_no = notice_request.(*models.ScanNoticeInput).LogNo
if log_no=="" { if log_no == "" {
return "", "", 0, 0, "", "", errors.New("「对账单流水号」未取得错误") return "", "", 0, 0, "", "", errors.New("「对账单流水号」未取得错误")
} }
} else if source_code==9 { } else if source_code == 9 {
//聚合被扫 //聚合被扫
resp_data := notice_request.(map[string]interface{})["resp_data"] resp_data := notice_request.(map[string]interface{})["resp_data"]
fmt.Println("resp_data返回值:", resp_data) fmt.Println("resp_data返回值:", resp_data)
...@@ -898,11 +898,11 @@ func selectRefundBill(tx *sql.Tx, input *models.RefundParamInput) (string, strin ...@@ -898,11 +898,11 @@ func selectRefundBill(tx *sql.Tx, input *models.RefundParamInput) (string, strin
//其它支付 //其它支付
// 针对有的支付,不需要传「交易终端号」时,需要用支付返回的「交易终端号」进行退款 // 针对有的支付,不需要传「交易终端号」时,需要用支付返回的「交易终端号」进行退款
log_no = notice_request.(*models.CashierNoticeInput).OrderTradeInfo.(map[string]interface{})["log_no"].(string) log_no = notice_request.(*models.CashierNoticeInput).OrderTradeInfo.(map[string]interface{})["log_no"].(string)
if log_no=="" { if log_no == "" {
return "", "", 0, 0, "", "", errors.New("「对账单流水号」未取得错误") return "", "", 0, 0, "", "", errors.New("「对账单流水号」未取得错误")
} }
trans_term_no = notice_request.(*models.CashierNoticeInput).TransTermNo trans_term_no = notice_request.(*models.CashierNoticeInput).TransTermNo
if trans_term_no=="" { if trans_term_no == "" {
return "", "", 0, 0, "", "", errors.New("「交易终端号」未取得错误") return "", "", 0, 0, "", "", errors.New("「交易终端号」未取得错误")
} }
// 银行卡支付时,获取付款人账号 // 银行卡支付时,获取付款人账号
...@@ -1033,7 +1033,7 @@ func SqbQueryOrderState(tx *sql.Tx, paymentOrderCode, attach string, billID int6 ...@@ -1033,7 +1033,7 @@ func SqbQueryOrderState(tx *sql.Tx, paymentOrderCode, attach string, billID int6
now.Add(time.Minute * 60) now.Add(time.Minute * 60)
date_time1 := now.Format("20060102150405") date_time1 := now.Format("20060102150405")
//平台类型 1:saas 2:shop 3:shop mobile 4:收银台 6:bk_shop 7:bk_shop_mobile //平台类型 1:saas 2:shop 3:shop mobile 4:收银台 6:bk_shop 7:bk_shop_mobile
if platformType==2 || platformType==3 { if platformType == 2 || platformType == 3 {
// 谛宝多多自营 // 谛宝多多自营
version = setting.Conf.Lakala.DbcVersion version = setting.Conf.Lakala.DbcVersion
out_org_code = setting.Conf.Lakala.DbcAppid out_org_code = setting.Conf.Lakala.DbcAppid
...@@ -1043,7 +1043,7 @@ func SqbQueryOrderState(tx *sql.Tx, paymentOrderCode, attach string, billID int6 ...@@ -1043,7 +1043,7 @@ func SqbQueryOrderState(tx *sql.Tx, paymentOrderCode, attach string, billID int6
term_no3 = setting.Conf.Lakala.DbcTermNo3 term_no3 = setting.Conf.Lakala.DbcTermNo3
merchant_no4 = setting.Conf.Lakala.DbcMerchantNo4 merchant_no4 = setting.Conf.Lakala.DbcMerchantNo4
term_no4 = setting.Conf.Lakala.DbcTermNo4 term_no4 = setting.Conf.Lakala.DbcTermNo4
} else if platformType==6 || platformType==7 { } else if platformType == 6 || platformType == 7 {
// 必康自营 // 必康自营
version = setting.Conf.Lakala.BkVersion version = setting.Conf.Lakala.BkVersion
out_org_code = setting.Conf.Lakala.BkAppid out_org_code = setting.Conf.Lakala.BkAppid
...@@ -1065,11 +1065,11 @@ func SqbQueryOrderState(tx *sql.Tx, paymentOrderCode, attach string, billID int6 ...@@ -1065,11 +1065,11 @@ func SqbQueryOrderState(tx *sql.Tx, paymentOrderCode, attach string, billID int6
term_no4 = setting.Conf.Lakala.SaasTermNo4 term_no4 = setting.Conf.Lakala.SaasTermNo4
} }
if sourceCode==2 || sourceCode==3 { if sourceCode == 2 || sourceCode == 3 {
//聚合主扫(微信JSAPI、微信小程序) //聚合主扫(微信JSAPI、微信小程序)
merchant_no = merchant_no3 merchant_no = merchant_no3
term_no = term_no3 term_no = term_no3
} else if sourceCode==9 { } else if sourceCode == 9 {
//聚合被扫(扫码枪) //聚合被扫(扫码枪)
merchant_no = merchant_no4 merchant_no = merchant_no4
term_no = term_no4 term_no = term_no4
...@@ -1081,8 +1081,8 @@ func SqbQueryOrderState(tx *sql.Tx, paymentOrderCode, attach string, billID int6 ...@@ -1081,8 +1081,8 @@ func SqbQueryOrderState(tx *sql.Tx, paymentOrderCode, attach string, billID int6
data["out_org_code"] = out_org_code data["out_org_code"] = out_org_code
data2 := make(map[string]interface{}) data2 := make(map[string]interface{})
data2["merchant_no"] = merchant_no //商户号 data2["merchant_no"] = merchant_no //商户号
data2["term_no"] = term_no//终端号 data2["term_no"] = term_no //终端号
data2["out_trade_no"] = paymentOrderCode //商户交易流水号 data2["out_trade_no"] = paymentOrderCode //商户交易流水号
//data["trade_no"] = trade_no //拉卡拉交易流水号 //data["trade_no"] = trade_no //拉卡拉交易流水号
data["req_data"] = data2 data["req_data"] = data2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment