|
@@ -17,17 +17,19 @@ import (
|
|
|
|
|
|
type DataExportPayAction struct {
|
|
type DataExportPayAction struct {
|
|
*xweb.Action
|
|
*xweb.Action
|
|
- sacnPay_WaitPay xweb.Mapper `xweb:"/dataExport/sacnPay/waitPay"` //生成支付二维码
|
|
|
|
- sacnPay_CreateOrder xweb.Mapper `xweb:"/dataExport/sacnPay/createOrder"` //创建订单
|
|
|
|
- isPaySuccess xweb.Mapper `xweb:"/dataExport/pay/isPaySuccess"` //是否支付成功
|
|
|
|
- getOrderPayMsg xweb.Mapper `xweb:"/dataexport/getOrderPayMsg"` //我的订单页面获取支付二维码
|
|
|
|
|
|
+ sacnPay_WaitPay xweb.Mapper `xweb:"/dataExport/sacnPay/waitPay"` //生成支付二维码
|
|
|
|
+ sacnPay_CreateOrder xweb.Mapper `xweb:"/dataExport/sacnPay/createOrder"` //创建订单
|
|
|
|
+ isPaySuccess xweb.Mapper `xweb:"/dataExport/pay/isPaySuccess"` //是否支付成功
|
|
|
|
+ getOrderPayMsg xweb.Mapper `xweb:"/dataexport/getOrderPayMsg"` //我的订单页面获取支付二维码
|
|
|
|
+ wxSacnPay_CreateOrder xweb.Mapper `xweb:"/dataExport/wx_sacnPay/createOrder"` //微信端-创建订单
|
|
}
|
|
}
|
|
|
|
|
|
func init() {
|
|
func init() {
|
|
xweb.AddAction(&DataExportPayAction{})
|
|
xweb.AddAction(&DataExportPayAction{})
|
|
}
|
|
}
|
|
|
|
|
|
-func (p *DataExportPayAction) SacnPay_CreateOrder() {
|
|
|
|
|
|
+//微信端创建订单
|
|
|
|
+func (p *DataExportPayAction) WxSacnPay_CreateOrder() {
|
|
defer util.Catch()
|
|
defer util.Catch()
|
|
openId, _ := p.GetSession("s_m_openid").(string)
|
|
openId, _ := p.GetSession("s_m_openid").(string)
|
|
userId, _ := p.GetSession("userId").(string)
|
|
userId, _ := p.GetSession("userId").(string)
|
|
@@ -39,13 +41,284 @@ func (p *DataExportPayAction) SacnPay_CreateOrder() {
|
|
})
|
|
})
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- //根据来源判断,pc端微信支付生成订单 tradeclass:b,微信端支付tradeclass:c
|
|
|
|
- sourcePage := p.GetString("sourcePage")
|
|
|
|
- tradeclass := "b"
|
|
|
|
- if sourcePage == "weixin" {
|
|
|
|
- tradeclass = "c"
|
|
|
|
|
|
+ //
|
|
|
|
+ data_spec := p.GetString("data_spec")
|
|
|
|
+ if data_spec == "standard" {
|
|
|
|
+ data_spec = "标准字段包"
|
|
|
|
+ } else if data_spec == "senior" {
|
|
|
|
+ data_spec = "高级字段包"
|
|
|
|
+ }
|
|
|
|
+ user_mail_status := util.ObjToString(p.GetSession("DataExportVerifyEmail_val")) != ""
|
|
|
|
+ pay_way := p.GetString("pay_way")
|
|
|
|
+ user_mail, _ := p.GetSession("DataExportVerifyEmail_val").(string)
|
|
|
|
+ user_phone, _ := p.GetSession("DataExportVerifyPhone").(string)
|
|
|
|
+ if user_phone != "" {
|
|
|
|
+ p.SetSession("DataExportVerifyPhone_val", user_phone) //提交后下次默认带出手机号
|
|
|
|
+ } else {
|
|
|
|
+ user_phone, _ = p.GetSession("DataExportVerifyPhone_val").(string)
|
|
|
|
+ }
|
|
|
|
+ //先看有没有创建过预支付订单
|
|
|
|
+ oldOrder := public.Mysql.FindOne("dataexport_order", map[string]interface{}{
|
|
|
|
+ "user_id": userId,
|
|
|
|
+ "filter_id": id,
|
|
|
|
+ }, "id,order_status,order_code,order_money,user_mail,user_phone,data_spec,prepay_time,prepay_id", "")
|
|
|
|
+ if oldOrder != nil {
|
|
|
|
+ if user_mail != "" && user_mail != util.ObjToString((*oldOrder)["user_mail"]) {
|
|
|
|
+ public.Mysql.Update("dataexport_order", map[string]interface{}{
|
|
|
|
+ "user_id": userId,
|
|
|
|
+ "filter_id": id,
|
|
|
|
+ }, map[string]interface{}{
|
|
|
|
+ "user_mail": user_mail,
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ if user_phone != "" && user_phone != util.ObjToString((*oldOrder)["user_phone"]) {
|
|
|
|
+ public.Mysql.Update("dataexport_order", map[string]interface{}{
|
|
|
|
+ "user_id": userId,
|
|
|
|
+ "filter_id": id,
|
|
|
|
+ }, map[string]interface{}{
|
|
|
|
+ "user_phone": user_phone,
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ //如果已支付,则返回
|
|
|
|
+ if util.IntAll((*oldOrder)["order_status"]) != 0 {
|
|
|
|
+ log.Println("该订单已存在,订单状态不允许支付!", openId)
|
|
|
|
+ p.ServeJson(map[string]interface{}{
|
|
|
|
+ "status": "n",
|
|
|
|
+ })
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ //价格支付方式变动需要重新生成订单二维码
|
|
|
|
+ if data_spec != "" && data_spec == util.ObjToString((*oldOrder)["data_spec"]) {
|
|
|
|
+ var res map[string]interface{}
|
|
|
|
+ nonceStr := util.GetRandom(16) + util.GetLetterRandom(16)
|
|
|
|
+ timestamp := time.Now().Unix()
|
|
|
|
+ sign := util.WxSign(fmt.Sprintf("appId=%s&nonceStr=%s&package=%s&signType=%s&timeStamp=%d&key=%s", public.WxStruct.Appid, nonceStr, "prepay_id="+util.ObjToString((*oldOrder)["prepay_id"]), "MD5", timestamp, public.WxStruct.Key))
|
|
|
|
+ res = map[string]interface{}{
|
|
|
|
+ "appId": public.WxStruct.Appid,
|
|
|
|
+ "timestamp": fmt.Sprint(timestamp),
|
|
|
|
+ "signType": "MD5",
|
|
|
|
+ "sign": sign,
|
|
|
|
+ "nonceStr": nonceStr,
|
|
|
|
+ "prepayId": "prepay_id=" + util.ObjToString((*oldOrder)["prepay_id"]),
|
|
|
|
+ }
|
|
|
|
+ p.ServeJson(map[string]interface{}{
|
|
|
|
+ "status": "y",
|
|
|
|
+ "code": util.ObjToString((*oldOrder)["order_code"]),
|
|
|
|
+ "token": public.GetWaitPayToken(util.Int64All((*oldOrder)["id"]), util.IntAll((*oldOrder)["order_money"]), util.ObjToString((*oldOrder)["order_code"]), "微信", userId),
|
|
|
|
+ "res": res,
|
|
|
|
+ })
|
|
|
|
+ return
|
|
|
|
+ }
|
|
}
|
|
}
|
|
//
|
|
//
|
|
|
|
+ data_count := public.GetDataExportSearchCountUseId(id)
|
|
|
|
+ if data_count > public.ExConf.MsgMaxCount {
|
|
|
|
+ data_count = public.ExConf.MsgMaxCount
|
|
|
|
+ }
|
|
|
|
+ order_money_, original_price_ := float64(0), float64(0)
|
|
|
|
+ if data_spec == "标准字段包" {
|
|
|
|
+ original_price_ = float64(data_count) * public.ExConf.UnitPrice_normal
|
|
|
|
+ } else if data_spec == "高级字段包" {
|
|
|
|
+ original_price_ = float64(data_count) * public.ExConf.UnitPrice_senior
|
|
|
|
+ }
|
|
|
|
+ order_money_ = float64(original_price_) * public.ExConf.Discount
|
|
|
|
+ if order_money_ < public.ExConf.OrderMinPrice {
|
|
|
|
+ order_money_ = public.ExConf.OrderMinPrice
|
|
|
|
+ }
|
|
|
|
+ if original_price_ < public.ExConf.OrderMinPrice {
|
|
|
|
+ original_price_ = public.ExConf.OrderMinPrice
|
|
|
|
+ }
|
|
|
|
+ order_money := int(order_money_ * 100)
|
|
|
|
+ original_price := int(original_price_ * 100)
|
|
|
|
+ //order_money = 1
|
|
|
|
+ //original_price = 1
|
|
|
|
+ filter_keys, filter_publishtime, filter := "", "", ""
|
|
|
|
+ //
|
|
|
|
+ isPass := func() bool {
|
|
|
|
+ if pay_way == "" || user_mail == "" || user_phone == "" || !user_mail_status || data_spec == "" || order_money <= 0 || data_count <= 0 || original_price <= 0 {
|
|
|
|
+ log.Println("参数不合法! pay_way, user_mail,user_phone, user_mail_status, data_spec, order_money, data_count, original_price", pay_way, user_mail, user_phone, user_mail_status, data_spec, order_money, data_count, original_price)
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ userfilter, ok := public.MQFW.FindById("export_search", id, nil)
|
|
|
|
+ if ok && userfilter != nil {
|
|
|
|
+ keywords, _ := (*userfilter)["keywords"].([]interface{})
|
|
|
|
+ var buffer bytes.Buffer
|
|
|
|
+ for _, v := range keywords {
|
|
|
|
+ vm, _ := v.(map[string]interface{})
|
|
|
|
+ if buffer.Len() > 0 {
|
|
|
|
+ buffer.WriteString(",")
|
|
|
|
+ }
|
|
|
|
+ buffer.WriteString(util.ObjToString(vm["keyword"]))
|
|
|
|
+ }
|
|
|
|
+ filter_keys = buffer.String()
|
|
|
|
+ filter_publishtime = util.ObjToString((*userfilter)["publishtime"])
|
|
|
|
+ filterByte, _ := json.Marshal(userfilter)
|
|
|
|
+ filter = string(filterByte)
|
|
|
|
+ } else {
|
|
|
|
+ log.Println("id is not find in mongodb", userId, id)
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ return true
|
|
|
|
+ }()
|
|
|
|
+ nickname, _ := p.GetSession("s_nickname").(string)
|
|
|
|
+ result := map[string]interface{}{
|
|
|
|
+ "status": "n",
|
|
|
|
+ }
|
|
|
|
+ if isPass {
|
|
|
|
+ //创建微信预支付订单,微信端支付tradeclass:c
|
|
|
|
+ tradeno, ret := public.WxStruct.CreatePrepayOrder(config.Sysconfig["weixinrpc"].(string), "c", p.IP(), openId, "", order_money)
|
|
|
|
+ log.Println("支付交易单", openId, ret)
|
|
|
|
+ if ret != nil && (*ret)["status"] == "1" {
|
|
|
|
+ now := time.Now()
|
|
|
|
+ ordercode := public.GetOrderCode(openId)
|
|
|
|
+ orderid := public.Mysql.Insert("dataexport_order", map[string]interface{}{
|
|
|
|
+ "order_money": order_money,
|
|
|
|
+ "order_status": 0,
|
|
|
|
+ "service_status": 0,
|
|
|
|
+ "user_nickname": nickname,
|
|
|
|
+ "user_openid": openId,
|
|
|
|
+ "filter": filter,
|
|
|
|
+ "prepay_id": (*ret)["prepayid"],
|
|
|
|
+ "code_url": (*ret)["codeurl"],
|
|
|
|
+ "out_trade_no": tradeno,
|
|
|
|
+ "order_code": ordercode,
|
|
|
|
+ "product_type": "历史数据",
|
|
|
|
+ "create_time": util.FormatDate(&now, util.Date_Full_Layout),
|
|
|
|
+ "prepay_time": util.FormatDate(&now, util.Date_Full_Layout),
|
|
|
|
+ "original_price": original_price,
|
|
|
|
+ "data_spec": data_spec,
|
|
|
|
+ "user_mail": user_mail,
|
|
|
|
+ "user_phone": user_phone,
|
|
|
|
+ "data_count": data_count,
|
|
|
|
+ "filter_publishtime": filter_publishtime,
|
|
|
|
+ "filter_keys": filter_keys,
|
|
|
|
+ "filter_id": id,
|
|
|
|
+ "pay_way": pay_way,
|
|
|
|
+ "user_id": userId, //20190719 移动端数据导出 生订单添加用户id
|
|
|
|
+ })
|
|
|
|
+ if orderid > 0 {
|
|
|
|
+ var res map[string]interface{}
|
|
|
|
+ nonceStr := util.GetRandom(16) + util.GetLetterRandom(16)
|
|
|
|
+ timestamp := time.Now().Unix()
|
|
|
|
+ sign := util.WxSign(fmt.Sprintf("appId=%s&nonceStr=%s&package=%s&signType=%s&timeStamp=%d&key=%s", public.WxStruct.Appid, nonceStr, "prepay_id="+util.ObjToString((*ret)["prepayid"]), "MD5", timestamp, public.WxStruct.Key))
|
|
|
|
+ res = map[string]interface{}{
|
|
|
|
+ "appId": public.WxStruct.Appid,
|
|
|
|
+ "timestamp": fmt.Sprint(timestamp),
|
|
|
|
+ "signType": "MD5",
|
|
|
|
+ "sign": sign,
|
|
|
|
+ "nonceStr": nonceStr,
|
|
|
|
+ "prepayId": "prepay_id=" + util.ObjToString((*ret)["prepayid"]),
|
|
|
|
+ }
|
|
|
|
+ p.SetSession("DataExportVerifyPhone_val", user_phone)
|
|
|
|
+ result["status"] = "y"
|
|
|
|
+ result["code"] = ordercode
|
|
|
|
+ result["token"] = public.GetWaitPayToken(orderid, order_money, ordercode, pay_way, userId)
|
|
|
|
+ result["res"] = res
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ log.Println("生成微信预支付交易单失败", ret)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ p.ServeJson(result)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//
|
|
|
|
+func (p *DataExportPayAction) SacnPay_WaitPay() error {
|
|
|
|
+ defer util.Catch()
|
|
|
|
+ openid, _ := p.GetSession("s_m_openid").(string)
|
|
|
|
+ code := p.GetString("code")
|
|
|
|
+ token := p.GetString("token")
|
|
|
|
+ surplus, money, qrcode, pay_way := func() (int64, int, string, string) {
|
|
|
|
+ if openid == "" || code == "" || token == "" {
|
|
|
|
+ return 0, 0, "", ""
|
|
|
|
+ }
|
|
|
|
+ data := public.Mysql.FindOne("dataexport_order", map[string]interface{}{"order_code": code, "user_openid": openid}, "id,code_url,prepay_time,order_money,order_status,pay_way", "")
|
|
|
|
+ if data == nil {
|
|
|
|
+ log.Println("订单号不存在!", openid, " code", code)
|
|
|
|
+ return 0, 0, "", ""
|
|
|
|
+ }
|
|
|
|
+ if util.IntAll((*data)["order_status"]) != 0 {
|
|
|
|
+ log.Println("订单状态不允许支付!", openid)
|
|
|
|
+ return 0, 0, "", ""
|
|
|
|
+ }
|
|
|
|
+ orderid := util.Int64All((*data)["id"])
|
|
|
|
+ orderMoney := util.IntAll((*data)["order_money"])
|
|
|
|
+ //orderMoney = 1
|
|
|
|
+ pay_way := util.ObjToString((*data)["pay_way"])
|
|
|
|
+ realToken := public.GetWaitPayToken(orderid, orderMoney, code, pay_way, openid)
|
|
|
|
+ if realToken != token {
|
|
|
|
+ log.Println("token错误!", openid, realToken, token)
|
|
|
|
+ return 0, 0, "", ""
|
|
|
|
+ }
|
|
|
|
+ prepayTime, err := time.ParseInLocation(util.Date_Full_Layout, util.ObjToString((*data)["prepay_time"]), time.Local)
|
|
|
|
+ surplus_second := prepayTime.Unix() + 7200 - time.Now().Unix()
|
|
|
|
+ codeUrl := util.ObjToString((*data)["code_url"])
|
|
|
|
+ if err == nil && surplus_second <= 0 { //重新生成预订单
|
|
|
|
+ log.Println("二维码已失效,重新生成预订单!", openid)
|
|
|
|
+ surplus_second = 0
|
|
|
|
+ now := time.Now()
|
|
|
|
+ if pay_way == "微信" {
|
|
|
|
+ tradeno, ret := public.WxStruct.CreatePrepayOrder(config.Sysconfig["weixinrpc"].(string), "b", p.IP(), openid, "", orderMoney)
|
|
|
|
+ if ret != nil {
|
|
|
|
+ if public.Mysql.Update("dataexport_order", map[string]interface{}{
|
|
|
|
+ "id": orderid,
|
|
|
|
+ }, map[string]interface{}{
|
|
|
|
+ "prepay_time": util.FormatDate(&now, util.Date_Full_Layout),
|
|
|
|
+ "prepay_id": (*ret)["prepayid"],
|
|
|
|
+ "code_url": (*ret)["codeurl"],
|
|
|
|
+ "out_trade_no": tradeno,
|
|
|
|
+ }) {
|
|
|
|
+ surplus_second = 7200
|
|
|
|
+ codeUrl = util.ObjToString((*ret)["codeurl"])
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if pay_way == "支付宝" {
|
|
|
|
+ payOutTime := now.Add(time.Hour * 2)
|
|
|
|
+ if qr_url, tradeno, err := Alipay.GetPayUrl(util.Float64All(orderMoney), util.FormatDate(&payOutTime, util.Date_Full_Layout)); err == nil {
|
|
|
|
+ if public.Mysql.Update("dataexport_order", map[string]interface{}{
|
|
|
|
+ "id": orderid,
|
|
|
|
+ }, map[string]interface{}{
|
|
|
|
+ "prepay_time": util.FormatDate(&now, util.Date_Full_Layout),
|
|
|
|
+ "prepay_id": "",
|
|
|
|
+ "code_url": qr_url,
|
|
|
|
+ "out_trade_no": tradeno,
|
|
|
|
+ }) {
|
|
|
|
+ surplus_second = 7200
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ codeUrl = qr_url
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return surplus_second, orderMoney, codeUrl, pay_way
|
|
|
|
+ }()
|
|
|
|
+ if pay_way == "微信" {
|
|
|
|
+ r, _ := qr.Encode(qrcode, qr.M)
|
|
|
|
+ pngdat := r.PNG()
|
|
|
|
+ qrcode = base64.StdEncoding.EncodeToString(pngdat)
|
|
|
|
+ }
|
|
|
|
+ p.T["money"] = float64(money) / 100
|
|
|
|
+ p.T["surplus_second"] = surplus
|
|
|
|
+ p.T["qrcode"] = qrcode
|
|
|
|
+ p.T["ordercode"] = code
|
|
|
|
+ p.T["pay_way"] = pay_way
|
|
|
|
+ return p.Render("/pc/waitpay.html")
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//pc端生成数据导出订单
|
|
|
|
+func (p *DataExportPayAction) SacnPay_CreateOrder() {
|
|
|
|
+ defer util.Catch()
|
|
|
|
+ openId, _ := p.GetSession("s_m_openid").(string)
|
|
|
|
+ userId, _ := p.GetSession("userId").(string)
|
|
|
|
+ id := util.SE.Decode4Hex(p.GetString("id"))
|
|
|
|
+ if userId == "" || id == "" {
|
|
|
|
+ log.Println("userId,id错误", userId, id)
|
|
|
|
+ p.ServeJson(map[string]interface{}{
|
|
|
|
+ "status": "n",
|
|
|
|
+ })
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ //根据来源判断,pc端微信支付生成订单 b
|
|
data_spec := p.GetString("data_spec")
|
|
data_spec := p.GetString("data_spec")
|
|
if data_spec == "standard" {
|
|
if data_spec == "standard" {
|
|
data_spec = "标准字段包"
|
|
data_spec = "标准字段包"
|
|
@@ -94,13 +367,11 @@ func (p *DataExportPayAction) SacnPay_CreateOrder() {
|
|
//价格支付方式变动需要重新生成订单二维码(关闭之前的订单)
|
|
//价格支付方式变动需要重新生成订单二维码(关闭之前的订单)
|
|
if (data_spec != "" && data_spec != util.ObjToString((*oldOrder)["data_spec"])) || pay_way != util.ObjToString((*oldOrder)["pay_way"]) {
|
|
if (data_spec != "" && data_spec != util.ObjToString((*oldOrder)["data_spec"])) || pay_way != util.ObjToString((*oldOrder)["pay_way"]) {
|
|
//在此关闭之前的订单
|
|
//在此关闭之前的订单
|
|
- if sourcePage == "" {
|
|
|
|
- if !CloseDataExportOrder(util.ObjToString((*oldOrder)["pay_way"]), util.ObjToString((*oldOrder)["out_trade_no"]), util.ObjToString((*oldOrder)["prepay_time"])) {
|
|
|
|
- p.ServeJson(map[string]interface{}{
|
|
|
|
- "status": "n",
|
|
|
|
- })
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
|
|
+ if !CloseDataExportOrder(util.ObjToString((*oldOrder)["pay_way"]), util.ObjToString((*oldOrder)["out_trade_no"]), util.ObjToString((*oldOrder)["prepay_time"])) {
|
|
|
|
+ p.ServeJson(map[string]interface{}{
|
|
|
|
+ "status": "n",
|
|
|
|
+ })
|
|
|
|
+ return
|
|
}
|
|
}
|
|
data_count := public.GetDataExportSearchCountUseId(id)
|
|
data_count := public.GetDataExportSearchCountUseId(id)
|
|
if data_count > public.ExConf.MsgMaxCount {
|
|
if data_count > public.ExConf.MsgMaxCount {
|
|
@@ -134,33 +405,10 @@ func (p *DataExportPayAction) SacnPay_CreateOrder() {
|
|
"pay_way": pay_way,
|
|
"pay_way": pay_way,
|
|
})
|
|
})
|
|
(*oldOrder)["order_money"] = order_money
|
|
(*oldOrder)["order_money"] = order_money
|
|
- }
|
|
|
|
- if util.IntAll((*oldOrder)["order_status"]) == 0 {
|
|
|
|
- var res map[string]interface{}
|
|
|
|
- if sourcePage == "weixin" {
|
|
|
|
- nonceStr := util.GetRandom(16) + util.GetLetterRandom(16)
|
|
|
|
- timestamp := time.Now().Unix()
|
|
|
|
- sign := util.WxSign(fmt.Sprintf("appId=%s&nonceStr=%s&package=%s&signType=%s&timeStamp=%d&key=%s", public.WxStruct.Appid, nonceStr, "prepay_id="+util.ObjToString((*oldOrder)["prepay_id"]), "MD5", timestamp, public.WxStruct.Key))
|
|
|
|
- res = map[string]interface{}{
|
|
|
|
- "appId": public.WxStruct.Appid,
|
|
|
|
- "timestamp": fmt.Sprint(timestamp),
|
|
|
|
- "signType": "MD5",
|
|
|
|
- "sign": sign,
|
|
|
|
- "nonceStr": nonceStr,
|
|
|
|
- "prepayId": "prepay_id=" + util.ObjToString((*oldOrder)["prepay_id"]),
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
p.ServeJson(map[string]interface{}{
|
|
p.ServeJson(map[string]interface{}{
|
|
"status": "y",
|
|
"status": "y",
|
|
"code": util.ObjToString((*oldOrder)["order_code"]),
|
|
"code": util.ObjToString((*oldOrder)["order_code"]),
|
|
"token": public.GetWaitPayToken(util.Int64All((*oldOrder)["id"]), util.IntAll((*oldOrder)["order_money"]), util.ObjToString((*oldOrder)["order_code"]), "微信", userId),
|
|
"token": public.GetWaitPayToken(util.Int64All((*oldOrder)["id"]), util.IntAll((*oldOrder)["order_money"]), util.ObjToString((*oldOrder)["order_code"]), "微信", userId),
|
|
- "res": res,
|
|
|
|
- })
|
|
|
|
- return
|
|
|
|
- } else {
|
|
|
|
- log.Println("该订单已存在,订单状态不允许支付!", userId)
|
|
|
|
- p.ServeJson(map[string]interface{}{
|
|
|
|
- "status": "n",
|
|
|
|
})
|
|
})
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -222,7 +470,7 @@ func (p *DataExportPayAction) SacnPay_CreateOrder() {
|
|
if isPass {
|
|
if isPass {
|
|
//创建微信预支付订单
|
|
//创建微信预支付订单
|
|
if pay_way == "wx_pc" {
|
|
if pay_way == "wx_pc" {
|
|
- tradeno, ret := public.WxStruct.CreatePrepayOrder(config.Sysconfig["weixinrpc"].(string), tradeclass, p.IP(), openId, "", order_money)
|
|
|
|
|
|
+ tradeno, ret := public.WxStruct.CreatePrepayOrder(config.Sysconfig["weixinrpc"].(string), "b", p.IP(), openId, "", order_money)
|
|
log.Println("支付交易单", openId, ret)
|
|
log.Println("支付交易单", openId, ret)
|
|
if ret != nil && (*ret)["status"] == "1" {
|
|
if ret != nil && (*ret)["status"] == "1" {
|
|
now := time.Now()
|
|
now := time.Now()
|
|
@@ -253,25 +501,10 @@ func (p *DataExportPayAction) SacnPay_CreateOrder() {
|
|
"user_id": userId, //20190719 移动端数据导出 生订单添加用户id
|
|
"user_id": userId, //20190719 移动端数据导出 生订单添加用户id
|
|
})
|
|
})
|
|
if orderid > 0 {
|
|
if orderid > 0 {
|
|
- var res map[string]interface{}
|
|
|
|
- if sourcePage == "weixin" {
|
|
|
|
- nonceStr := util.GetRandom(16) + util.GetLetterRandom(16)
|
|
|
|
- timestamp := time.Now().Unix()
|
|
|
|
- sign := util.WxSign(fmt.Sprintf("appId=%s&nonceStr=%s&package=%s&signType=%s&timeStamp=%d&key=%s", public.WxStruct.Appid, nonceStr, "prepay_id="+util.ObjToString((*ret)["prepayid"]), "MD5", timestamp, public.WxStruct.Key))
|
|
|
|
- res = map[string]interface{}{
|
|
|
|
- "appId": public.WxStruct.Appid,
|
|
|
|
- "timestamp": fmt.Sprint(timestamp),
|
|
|
|
- "signType": "MD5",
|
|
|
|
- "sign": sign,
|
|
|
|
- "nonceStr": nonceStr,
|
|
|
|
- "prepayId": "prepay_id=" + util.ObjToString((*ret)["prepayid"]),
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
p.SetSession("DataExportVerifyPhone_val", user_phone)
|
|
p.SetSession("DataExportVerifyPhone_val", user_phone)
|
|
result["status"] = "y"
|
|
result["status"] = "y"
|
|
result["code"] = ordercode
|
|
result["code"] = ordercode
|
|
result["token"] = public.GetWaitPayToken(orderid, order_money, ordercode, pay_way, userId)
|
|
result["token"] = public.GetWaitPayToken(orderid, order_money, ordercode, pay_way, userId)
|
|
- result["res"] = res
|
|
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
log.Println("生成微信预支付交易单失败", ret)
|
|
log.Println("生成微信预支付交易单失败", ret)
|