Commit 4fa1273d authored by wangp's avatar wangp

lakala

parent da55a1f2
...@@ -23,9 +23,9 @@ import ( ...@@ -23,9 +23,9 @@ import (
// 拉卡拉支付 // 拉卡拉支付
func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{}, error) { func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{}, error) {
//if input.ChainCode=="" || input.HospitalCode=="" || input.VendorId=="" || seller_id=="" { if input.SourceCode==0 {
// return nil, errors.New("输入项为空") return nil, errors.New("输入项「source_code」为空错误")
//} }
fmt.Println("谛宝多多输入参数") fmt.Println("谛宝多多输入参数")
fmt.Println(input) fmt.Println(input)
...@@ -61,12 +61,11 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{}, ...@@ -61,12 +61,11 @@ func UnifiedOrder(input *models.PlaceAnOrderParamInput, ip string) (interface{},
//数据重组 - start //数据重组 - start
data := make(map[string]interface{}) data := make(map[string]interface{})
var url string var url string
//source_code 1: 微信 Native 2:微信小程序 3:微信内支付 4:h5 跳微信 //source_code 1: 微信 Native 2:微信小程序 3:微信内支付 4:h5 跳微信
//5:支付宝(web)-扫码或登录支付宝账户 6:alipay(mobile) 7:alipay(app) //5:支付宝(web)-扫码或登录支付宝账户 6:alipay(mobile) 7:alipay(app)
if input.SourceCode==4 || input.SourceCode==6 { //9: B2C 10:bk支付宝web 11:bk 支付宝手机
if input.SourceCode==4 || input.SourceCode==6 ||input.SourceCode==1 || input.SourceCode==5 {
//聚合收银台(微信H5、支付宝H5、微信扫码、支付宝扫码) //聚合收银台(微信H5、支付宝H5、微信扫码、支付宝扫码)
url = "https://test.wsmsd.cn/sit/api/v3/ccss/counter/order/create" //聚合收银台 url = "https://test.wsmsd.cn/sit/api/v3/ccss/counter/order/create" //聚合收银台
...@@ -83,7 +82,9 @@ if input.SourceCode==4 || input.SourceCode==6 { ...@@ -83,7 +82,9 @@ if input.SourceCode==4 || input.SourceCode==6 {
data2 := make(map[string]interface{}) data2 := make(map[string]interface{})
//data2["merchant_no"] = "8222900701107M5" //data2["merchant_no"] = "8222900701107M5"
data2["merchant_no"] = "8221210701101SB" //data2["merchant_no"] = "8221210701101SB"
//data2["merchant_no"] = "8222900581201QB"
data2["merchant_no"] = "8221210594300JY"
//data2["term_no"] = "29034705" //不需要传? //data2["term_no"] = "29034705" //不需要传?
//data2["total_amount"] = "1" //data2["total_amount"] = "1"
...@@ -112,7 +113,7 @@ if input.SourceCode==4 || input.SourceCode==6 { ...@@ -112,7 +113,7 @@ if input.SourceCode==4 || input.SourceCode==6 {
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==1 || input.SourceCode==5 { } else if input.SourceCode==2 || input.SourceCode==3 {
//聚合主扫(微信JSAPI、微信小程序) //聚合主扫(微信JSAPI、微信小程序)
url = "https://test.wsmsd.cn/sit/api/v3/labs/trans/preorder" //聚合主扫 url = "https://test.wsmsd.cn/sit/api/v3/labs/trans/preorder" //聚合主扫
...@@ -125,7 +126,7 @@ if input.SourceCode==4 || input.SourceCode==6 { ...@@ -125,7 +126,7 @@ if input.SourceCode==4 || input.SourceCode==6 {
// 构造回调url // 构造回调url
input.NoticeURL = GetNoticeURL(input.SourceCode) input.NoticeURL = GetNoticeURL(input.SourceCode)
// 传递给支付渠道的 // 传递给支付渠道的
//p.ServeNoticeUrl = noticeURLx //p.ServeNoticeUrl = noticeURL
data2 := make(map[string]interface{}) data2 := make(map[string]interface{})
//data2["merchant_no"] = "8222900701107M5" //data2["merchant_no"] = "8222900701107M5"
...@@ -133,16 +134,9 @@ if input.SourceCode==4 || input.SourceCode==6 { ...@@ -133,16 +134,9 @@ if input.SourceCode==4 || input.SourceCode==6 {
//data2["merchant_no"] = "8221210701101SB" //data2["merchant_no"] = "8221210701101SB"
data2["merchant_no"] = "8222900581201QB" data2["merchant_no"] = "8222900581201QB"
data2["term_no"] = "D0027598" data2["term_no"] = "D0027598"
//data2["total_amount"] = "1"
//tempMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", p.GoodsPrice*100), 64) //tempMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", p.GoodsPrice*100), 64)
data2["total_amount"] = input.GoodsPrice*100 data2["total_amount"] = input.GoodsPrice*100
data2["out_trade_no"] = orderID //随机生成的订单号 //商户交易流水号 data2["out_trade_no"] = orderID //随机生成的订单号 //商户交易流水号
//data2["out_trade_no"] = RandomString(32)
//data2["out_order_no"] = orderID //随机生成的订单号 //商户订单号
//data2["out_order_no"] = RandomString(32)
//data2["out_trade_no"] = input.AttachInfo
//data2["out_order_no"] = input.AttachInfo
data2["order_efficient_time"] = "20230630235959" //订单有效期 格式yyyyMMddHHmmss,最大支持下单时间+2天 data2["order_efficient_time"] = "20230630235959" //订单有效期 格式yyyyMMddHHmmss,最大支持下单时间+2天
data2["notify_url"] = input.NoticeURL //订单支付成功后商户接收订单通知的地址 http://xxx.xxx.com data2["notify_url"] = input.NoticeURL //订单支付成功后商户接收订单通知的地址 http://xxx.xxx.com
...@@ -186,10 +180,41 @@ if input.SourceCode==4 || input.SourceCode==6 { ...@@ -186,10 +180,41 @@ if input.SourceCode==4 || input.SourceCode==6 {
data["req_data"] = make(map[string]interface{}) data["req_data"] = make(map[string]interface{})
data["req_data"] = data2 data["req_data"] = data2
} else { } else if input.SourceCode==9 {
return nil, errors.New("输入参数「source_code」错误") //收钱吧(扫码枪)
} if input.DynamicID=="" {
return nil, errors.New("输入项「dynamic_id」为空错误")
}
url = "https://test.wsmsd.cn/sit/api/v3/labs/trans/micropay" //聚合被扫
data["req_time"] = "20220714160009"
data["version"] = "3.0"
data["out_org_code"] = "OP00000003"
data2 := make(map[string]interface{})
data2["merchant_no"] = "822290070111135"
data2["term_no"] = "29034705"
data2["out_trade_no"] = orderID //随机生成的订单号 //商户交易流水号
//data2["out_trade_no"] = RandomString(32)
//扫码支付授权码,设备读取用户APP中的条码或者二维码信息,用户付款码条形码规则见说明
//data2["auth_code"] = "135178236713755038"
data2["auth_code"] = input.DynamicID
data2["total_amount"] = input.GoodsPrice*100
data3 := make(map[string]interface{})
//data3["request_ip"] = "10.176.1.192"
data3["request_ip"] = ip
//data3["location"] = "+37.123456789,-121.123456789"
data2["location_info"] = make(map[string]interface{})
data2["location_info"] = data3
data["req_data"] = make(map[string]interface{})
data["req_data"] = data2
} else {
return nil, errors.New("输入参数「source_code」错误,有效值为[1-6,9]")
}
//数据重组 - end //数据重组 - end
fmt.Println("拉卡拉输入参数") fmt.Println("拉卡拉输入参数")
fmt.Println(data) fmt.Println(data)
...@@ -209,10 +234,6 @@ if input.SourceCode==4 || input.SourceCode==6 { ...@@ -209,10 +234,6 @@ if input.SourceCode==4 || input.SourceCode==6 {
return nil, err return nil, err
} }
//url := "https://test.wsmsd.cn/sit/api/v3/labs/trans/preorder" //聚合主扫
//url := "https://test.wsmsd.cn/sit/api/v3/labs/trans/micropay" //聚合被扫
//url := "https://test.wsmsd.cn/sit/api/v3/ccss/counter/order/create" //聚合收银台
//调拉卡拉接口 //调拉卡拉接口
err, response, lakala_rtn := lakala_post(input.SourceCode, url, data_json) err, response, lakala_rtn := lakala_post(input.SourceCode, url, data_json)
if err != nil { if err != nil {
...@@ -220,9 +241,6 @@ if input.SourceCode==4 || input.SourceCode==6 { ...@@ -220,9 +241,6 @@ if input.SourceCode==4 || input.SourceCode==6 {
return nil, err return nil, err
} }
//response := make(map[string]string)
//response["m_web_url"] = m_web_url
// 插入下单成功后返回的参数 // 插入下单成功后返回的参数
err = InsertPayBillDetailResponseBody(tx, billID, lakala_rtn) err = InsertPayBillDetailResponseBody(tx, billID, lakala_rtn)
if err != nil { if err != nil {
...@@ -230,9 +248,15 @@ if input.SourceCode==4 || input.SourceCode==6 { ...@@ -230,9 +248,15 @@ if input.SourceCode==4 || input.SourceCode==6 {
return nil, err return nil, err
} }
if input.SourceCode==9 {
//收钱吧(扫码枪)
response := make(map[string]string)
response["payment_order_code"] = orderID //随机生成的订单号
return response, nil return response, nil
} }
return response, nil
}
func lakala_post(source_code uint8, url string, data_json []byte) (error, interface{}, interface{}) { func lakala_post(source_code uint8, url string, data_json []byte) (error, interface{}, interface{}) {
authorization, err := getAuthorization(string(data_json)) authorization, err := getAuthorization(string(data_json))
...@@ -277,15 +301,21 @@ func lakala_post(source_code uint8, url string, data_json []byte) (error, interf ...@@ -277,15 +301,21 @@ func lakala_post(source_code uint8, url string, data_json []byte) (error, interf
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 {
//微信H5、支付宝H5
response["m_web_url"] = temp2["counter_url"].(string) response["m_web_url"] = temp2["counter_url"].(string)
} else {
//微信扫码、支付宝扫码
response["qr_code_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 temp3["counter_url"]=="" { if temp2["acc_resp_fields"]=="" {
// return errors.New("拉卡拉返回值「counter_url」为空错误"), "", temp return errors.New("拉卡拉返回值「acc_resp_fields」为空错误"), "", temp
//} }
response["app_id"] = temp3["app_id"].(string) response["app_id"] = temp3["app_id"].(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)
...@@ -293,6 +323,7 @@ func lakala_post(source_code uint8, url string, data_json []byte) (error, interf ...@@ -293,6 +323,7 @@ func lakala_post(source_code uint8, url string, data_json []byte) (error, interf
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 { } else {
return errors.New("输入参数「source_code」错误"), "", temp return errors.New("输入参数「source_code」错误"), "", temp
} }
......
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