wangkaiyue 6 жил өмнө
parent
commit
bc5f0bd947

+ 12 - 5
src/config.json

@@ -1,5 +1,5 @@
 {
-	"mongodbServers": "192.168.3.18:27080",
+	"mongodbServers": "192.168.3.11:27080",
 	"mongodbPoolSize": "25",
 	"mongodbName": "qfw",
 	"influxaddr": "http://192.168.3.11:8086",
@@ -16,12 +16,12 @@
 	"cacheflag": false,
 	"cassandra": {
 		"log": {
-			"host": ["192.168.3.207"],
+			"host": ["192.168.3.11"],
 			"size": 5,
-			"port": 9043
+			"port": 9042
 		},
 		"push": {
-			"host": ["192.168.3.207"],
+			"host": ["192.168.3.11"],
 			"size": 5
 		}
 	},
@@ -213,6 +213,13 @@
 			"sjdc_detailmsg": "剑鱼标讯-历史数据"
 		}
 	},
+	"aliPay": {
+	"appid": "2016092900620854",
+	"reqUrl":"https://openapi.alipaydev.com/gateway.do",
+	"Subject":"剑鱼数据导出",
+	"privateKey": "-----BEGIN RSA PRIVATE KEY-----\nMIIEogIBAAKCAQEAtO7CU4hpdcMmV43MEA8bqQJYYx+f6yvYkP0nFc/oCvU24bU6zAdK/H2H56quEwD8Dh5YtVTfUCcKqpcG9HXY11TXWKCEUQiK1tkb0o7oSSURwk6h1DdDbg8m1+H8s+k+mvMvcqVCYKYi03PIPQyJCuHmzx/vcaALXRr2HOrEFaFFA8WYST1rywiKeyrC9PCNX1aJjGADhCs3cGrdZEJc4k+2tIHTYJccx+mJ96QiEkzFhJTqEmSFPcNqNUX9uCPgeVhfHW2pRNyffvrhoEyeSr1QoOpaYyn0I5JD2axnypBFCbk6P69LY3eGNKtOe81lp9hiZbMYpXPqb6KwPXTVQQIDAQABAoIBAEbJQm276MaR2uZWK4f84S12JW5iaQZw2QGgiTIXbQkcdqRHawF3uPafhhQ0ynXU5MgBR2NqGRQasimbfLUXhgZ4wueBpUKuvOLhfekaz/YN8qy6ZsXH+TGN6/x6BYu9rSiiC+YmkZmOZgGkQqrfxJ3lU4+lRuCFZOzAJ5mYn652CHRJXy6eDgZfyFLP2ol4/ioJEhwnGFXV345DlsVgmXTEe+IfjTyuvzxBtjod4lfu3dj/f2PhPrcgvN0ZQf1ldZbS+6FkMWInMOQt/WsJ/ANfiKgQ4sPzlxIhmVjrvDlnYTc1lbFekyInzZumV0pDyId+1Y6LAjxJTAhnjFAlBSECgYEAwsQdxOiZNLtxZ8J8JCQHKERYIo7euArW0iAurF+3Q9VNeGj0voFrmfHPju5OF5BHtuc7D3lkwZG4Ac+pyQtxF5dsEMl4vBoNc6onRQFsSDVEEIpl7OBghGlg1as23tvPSMh7DKnILM9OzVfFQ9WLvwHJwLRGsM7LOtmNovq4UFsCgYEA7dE/9Avr5YtCUjij8Y2zkAxN6qb8+ggqFoPiCr91JNGaKNKV9D2K7D3Zk49TXFJm7SX2zgYFuqR2Pa9vAWh9jtmwsc8L0qpIym4J1MM5ud/Xiu9c8O/prQOr7JlICNdk8WfqGbUC83BYfWa5SDonlXFYi6x3LlXdZnvEfZF645MCgYAC2ZnR6tFrGx8StJ7abIiKR02+27ZYnRf9pSjprtDgtjtW+royG3S2oPo3jjcoUx0piQKtPEqEJpy5sg86+ObjwHx9VmVk40C1I5VFhjrOZ7EiSNQq/jGLXntjRQkdg7vpxb0/NzDNrw7pJFKnpnVQCzenkTvDlJMWvl47N04BJwKBgHnpVtuIcPlPFkSH/KMLfQ1PAXJVAEI8hTbdjLbtxuOE/34F1hFKqzjHzA2034roQxM27vpWZAF15Zdho4oZQqREPCwqc2kfGgmLt0Z2fdUnRptWcVKh6ixjQXMccKz3niuSlZNwE38wDGzciAbaqQgW/sk7NC1wnvq2X9fvCAw5AoGANG2usqWYF4x+LvbhcdrKpJsjtvkLa2u9g2/wNXdoj+tBrv310O22/YM5LOcq9MrKPlx1S1C1KLoQO9TWFZiYuQ9C/sk7/ZTNmKQxCxVV0FVPaBYp+meD6sjgoRVJvaqY0UxnJwlHWMrusPTFua7Mtogqx9cvzlQolWh5VX7N1DM=\n-----END RSA PRIVATE KEY-----",
+		"callbackPublicKey":"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqkZY9RWrX1cZi/AWuBn7u6bjoT2RMBaq4Gdc87CgrIZm89wa28mYzbnuOrzxGtEMP82lU/KoVAbzY46j7s+bR0qUyUwQyFDFHYzDNSjhngeokzcZ+8rU6a8IOyXOHU0V2BLuvzKb44P4ctzZpmgtDZfxMbAt0ULumz9ma3elYa3pEYgQCoWm5i9eiN8DwhY2uBKZ94vW8+c2iCSwoNntZt6S608TYNOICl7nNWIR+zu3f3HnEE+7mQR37XC1aJWmtH5hKrHF8W5PVzEGhOWETcEdpUmaLhXOfN9nCBKNgFbYUmH+r6s93kfdHAqm6MEuFE6m42nmk6lqoDhEeHKteQIDAQAB"
+	},
 	"industry": "分类综合测试",
 	"recommendEntLimit": "50",
 	"jyapp": {
@@ -263,7 +270,7 @@
 	},
 	"mysql": {
 		"dbName": "jianyu",
-		"address": "192.168.3.207:3366",
+		"address": "192.168.3.11:3366",
 		"userName": "root",
 		"passWord": "Topnet123"
 	},

+ 1 - 1
src/jfw/front/dataExport.go

@@ -210,7 +210,7 @@ func (d *DataExport) QueryOrder() error {
 				v["order_money"] = float64(orderMoney.(int64)) / 100
 			}
 			if v["id"] != nil && orderMoney != nil && v["order_code"] != nil {
-				v["token"] = public.GetWaitPayToken(v["id"].(int64), int(orderMoney.(int64)), v["order_code"].(string), query["user_openid"].(string))
+				v["token"] = public.GetWaitPayToken(v["id"].(int64), int(orderMoney.(int64)), v["order_code"].(string), v["pay_way"].(string), query["user_openid"].(string))
 			}
 		}
 	}

+ 267 - 0
src/jfw/pay/aliPay.go

@@ -0,0 +1,267 @@
+package pay
+
+import (
+	"crypto"
+	"crypto/rand"
+	"crypto/rsa"
+	"crypto/sha256"
+	"crypto/x509"
+	"encoding/base64"
+	"encoding/json"
+	"encoding/pem"
+	"errors"
+	"fmt"
+	"hash"
+	"jfw/config"
+	"jfw/public"
+	"log"
+	"net/url"
+	"qfw/util"
+	"strings"
+	"time"
+
+	"github.com/go-xweb/xweb"
+)
+
+type AliPayStruct struct {
+	Appid        string
+	PrivateKey   *rsa.PrivateKey //请求接口秘钥
+	AliPublicKey *rsa.PublicKey  //支付完成回调,校验使用(取支付宝后台)
+	Qr_width     int             //二维码宽度
+	CallBackUrl  string          //支付完成回调地址
+	ReturnUrl    string          //支付完成页面跳转地址
+	Requseturl   string          //接口请求地址
+	Subject      string          //支付小标题
+}
+
+//支付订单生成请求参数
+type BizContent struct {
+	Subject      string  `json:"subject"`
+	OutTradeNo   string  `json:"out_trade_no"`
+	TotalAmount  float64 `json:"total_amount"`
+	ProductCode  string  `json:"product_code"`
+	Qr_pay_mode  string  `json:"qr_pay_mode"`
+	Qrcode_width int     `json:"qrcode_width"`
+}
+
+type AliPayAction struct {
+	*xweb.Action
+	payCallback xweb.Mapper `xweb:"/alipay/pay/callback"` //微信支付回调
+}
+
+var Alipay *AliPayStruct
+var alipayConf map[string]interface{}
+
+func init() {
+	alipayConf = config.Sysconfig["aliPay"].(map[string]interface{})
+	//加载本地私钥
+	privateKey, err := parsePrivateKey(util.ObjToString(alipayConf["privateKey"]))
+	if err != nil {
+		panic(err)
+	}
+	//加载支付宝后台公钥
+	aliPublicKey, err := parseAliPayPublicKey(util.ObjToString(alipayConf["callbackPublicKey"]))
+	if err != nil {
+		panic(err)
+	}
+	Alipay = &AliPayStruct{
+		Appid:        util.ObjToString(alipayConf["appid"]),
+		PrivateKey:   privateKey,
+		AliPublicKey: aliPublicKey,
+		CallBackUrl:  util.ObjToString(config.Sysconfig["webdomain"]) + "/alipay/pay/callback",
+		Qr_width:     250,
+		ReturnUrl:    "", //不配置
+		Requseturl:   util.ObjToString(alipayConf["reqUrl"]),
+		Subject:      util.ObjToString(alipayConf["Subject"]),
+	}
+	xweb.AddAction(&AliPayAction{})
+}
+
+func (w *AliPayStruct) GetTradeno() string {
+	return fmt.Sprintf("%s_%d%s%s", "z", time.Now().UnixNano(), util.GetRandom(5), util.GetLetterRandom(6))
+}
+
+//获取支付连接
+func (a *AliPayStruct) GetPayUrl(order_money float64) (string, string, error) {
+	tradeno := a.GetTradeno()
+	bizContent := BizContent{
+		Subject:      a.Subject,
+		OutTradeNo:   tradeno,
+		TotalAmount:  order_money / 100,
+		ProductCode:  "FAST_INSTANT_TRADE_PAY",
+		Qr_pay_mode:  "4",
+		Qrcode_width: a.Qr_width,
+	}
+	bizbyte, err := json.Marshal(bizContent)
+	if err != nil {
+		return "", "", err
+	}
+	var data = url.Values{}
+	data.Add("app_id", Alipay.Appid)
+	data.Add("method", "alipay.trade.page.pay")
+	if a.CallBackUrl != "" {
+		data.Add("notify_url", a.CallBackUrl) //支付完成回调地址
+	}
+	if a.ReturnUrl != "" {
+		data.Add("return_url", a.ReturnUrl)
+	}
+	data.Add("format", "json")
+	data.Add("charset", "UTF-8")
+	data.Add("sign_type", "RSA2")
+	data.Add("timestamp", time.Now().Format("2006-01-02 15:04:05"))
+	data.Add("version", "1.0")
+	data.Add("biz_content", string(bizbyte))
+
+	signContentBytes, _ := url.QueryUnescape(data.Encode())
+	signature, err := a.getSign([]byte(signContentBytes))
+	if err != nil {
+		return "", "", err
+	}
+	data.Add("sign", signature)
+	return a.Requseturl + "?" + data.Encode(), tradeno, nil
+}
+
+//加载秘钥
+func parsePrivateKey(key string) (*rsa.PrivateKey, error) {
+	block, _ := pem.Decode([]byte(key))
+	if block == nil {
+		return nil, errors.New("私钥格式不正确")
+	}
+	if strings.ToUpper(block.Type) != "RSA PRIVATE KEY" {
+		return nil, errors.New("私钥类型不正确" + block.Type)
+	}
+	rsaPrivateKey, err := x509.ParsePKCS1PrivateKey(block.Bytes)
+	if err != nil {
+		return nil, err
+	}
+	return rsaPrivateKey, nil
+}
+
+//加载支付宝后台公钥
+func parseAliPayPublicKey(key string) (*rsa.PublicKey, error) {
+	publicKeyDecoded, err := base64.StdEncoding.DecodeString(key)
+	if err != nil {
+		return nil, err
+	}
+	pub, err := x509.ParsePKIXPublicKey(publicKeyDecoded)
+	if err != nil {
+		return nil, err
+	}
+	if pub, ok := pub.(*rsa.PublicKey); ok {
+		return pub, nil
+	}
+	return nil, errors.New("rsa.PublicKey 断言出错")
+}
+
+//生成加密token
+func (a *AliPayStruct) getSign(data []byte) (signature string, err error) {
+	var h hash.Hash
+	var hType crypto.Hash
+	h = sha256.New()
+	hType = crypto.SHA256
+	//}
+	h.Write(data)
+	d := h.Sum(nil)
+	bs, err := rsa.SignPKCS1v15(rand.Reader, a.PrivateKey, hType, d)
+
+	if err != nil {
+		return "", err
+	}
+	signature = base64.StdEncoding.EncodeToString(bs)
+	return
+}
+
+//校验回调sign
+func (a *AliPayStruct) checkCallBackSign(param, sign string) bool {
+	newHash := sha256.New()
+	newHash.Write([]byte(param))
+	hashed := newHash.Sum(nil)
+	cryptoHash := crypto.SHA256
+
+	signDecoded, err := base64.StdEncoding.DecodeString(sign)
+	if err != nil {
+		fmt.Println("checkCallBackSign DecodeString err:", err)
+		return false
+	}
+	if err := rsa.VerifyPKCS1v15(Alipay.AliPublicKey, cryptoHash, hashed, signDecoded); err != nil {
+		if err != rsa.ErrVerification {
+			log.Println("VerifyPKCS1v15 err:", err)
+		}
+		return false
+	}
+	return true
+}
+
+//支付宝支付回调
+func (a *AliPayAction) PayCallback() {
+	checkSign := a.GetForm()
+	sign := checkSign.Get("sign") //待验证签名
+	checkSign.Del("sign")
+	checkSign.Del("sign_type")
+	signContentBytes, _ := url.QueryUnescape(checkSign.Encode())
+	if !Alipay.checkCallBackSign(signContentBytes, sign) { //验签
+		log.Println("支付宝签名验证失败")
+		return
+	}
+	//校验
+	if checkSign.Get("app_id") != util.ObjToString(alipayConf["appid"]) {
+		return
+	}
+	out_trade_no := checkSign.Get("out_trade_no")
+	trade_no := checkSign.Get("trade_no")                              //支付宝交易号
+	receipt_amount := util.Float64All(checkSign.Get("receipt_amount")) //实收金额
+	total_amount := util.Float64All(checkSign.Get("total_amount"))     //订单金额
+	//seller_id := checkSign.Get("seller_id")                        //卖家支付宝号
+	gmt_payment := checkSign.Get("gmt_payment") //付款时间
+
+	//支付完成插入
+	now := time.Now()
+	orderdata := public.Mysql.FindOne("dataexport_order", map[string]interface{}{
+		"out_trade_no": out_trade_no,
+		"order_money":  total_amount * 100,
+	}, "id,filter,user_mail,product_type,data_spec,user_phone,filter_id,order_code,data_count,order_status,order_money,out_trade_no,create_time", "")
+	pay_time := util.FormatDate(&now, util.Date_Full_Layout)
+	filename := fmt.Sprintf("%s.xlsx", fmt.Sprintf("%s_%s_%s", time.Now().Format("20060102150405"), util.ObjToString((*orderdata)["order_code"]), util.GetLetterRandom(5)))
+	download_url := fmt.Sprintf("/res/dataexport/%s", filename)
+	changeOrderStatus, insertAliPay := false, false
+	if orderdata != nil {
+		order_status := util.IntAll((*orderdata)["order_status"])
+		if order_status == 0 {
+			changeOrderStatus = public.Mysql.Update("dataexport_order", map[string]interface{}{
+				"order_status": 0,
+				"out_trade_no": out_trade_no,
+				"order_money":  total_amount * 100,
+			}, map[string]interface{}{
+				"pay_money":    receipt_amount * 100,
+				"pay_time":     pay_time,
+				"order_status": 1,
+				"pay_way":      "支付宝",
+				"download_url": download_url,
+			})
+			if changeOrderStatus {
+				//先发个通知
+				go public.SendNotice(orderdata, total_amount, pay_time, download_url, config.GmailAuth)
+				go public.SendMailToPayUser(orderdata, total_amount, pay_time, filename, download_url, config.GmailAuth)
+				go public.SendMailToBJFinance(orderdata, pay_time, trade_no, 1, config.GmailAuth) //订单号
+			}
+		} else {
+			changeOrderStatus = true
+		}
+	}
+
+	pay_count := public.Mysql.Count("ali_pay", map[string]interface{}{
+		"transaction_id": trade_no,
+		"out_trade_no":   out_trade_no,
+	})
+	if pay_count == 0 {
+		insertAliPay = public.Mysql.Insert("ali_pay", map[string]interface{}{
+			"transaction_id": trade_no,
+			"out_trade_no":   out_trade_no,
+			"create_time":    util.FormatDate(&now, util.Date_Full_Layout),
+			"total_fee":      total_amount * 100,
+			"cash_fee":       receipt_amount * 100,
+			"time_end":       gmt_payment,
+		}) > 0
+		log.Println("insertAliPay", insertAliPay)
+	}
+}

+ 365 - 0
src/jfw/pay/dataExportPay.go

@@ -0,0 +1,365 @@
+package pay
+
+import (
+	"bytes"
+	"encoding/base64"
+	"encoding/json"
+	"jfw/config"
+	"jfw/public"
+	"log"
+	"qfw/util"
+	"time"
+
+	"github.com/SKatiyar/qr"
+	"github.com/go-xweb/xweb"
+)
+
+type DataExportPayAction struct {
+	*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"`    //是否支付成功
+}
+
+func init() {
+	xweb.AddAction(&DataExportPayAction{})
+}
+
+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"])
+		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 == "支付宝" {
+				if qr_url, tradeno, err := Alipay.GetPayUrl(util.Float64All(orderMoney)); 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")
+}
+func (p *DataExportPayAction) SacnPay_CreateOrder() {
+	defer util.Catch()
+	openId, _ := p.GetSession("s_m_openid").(string)
+	id := util.SE.Decode4Hex(p.GetString("id"))
+	if openId == "" || id == "" {
+		log.Println("openId,id错误", openId, id)
+		p.ServeJson(map[string]interface{}{
+			"status": "n",
+		})
+		return
+	}
+	//
+	data_spec := p.GetString("data_spec")
+	if data_spec == "standard" {
+		data_spec = "标准字段包"
+	} else if data_spec == "senior" {
+		data_spec = "高级字段包"
+	}
+	user_mail_status := p.GetSession("EMVerifySucess").(bool)
+	pay_way := p.GetString("pay_way")
+	if pay_way == "weixin" {
+		pay_way = "微信"
+	} else if pay_way == "alipay" {
+		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_openid": openId,
+		"filter_id":   id,
+	}, "id,order_status,order_code,order_money,user_mail,user_phone,data_spec,prepay_time,pay_way", "")
+	if oldOrder != nil {
+		if user_mail != "" && user_mail != util.ObjToString((*oldOrder)["user_mail"]) {
+			public.Mysql.Update("dataexport_order", map[string]interface{}{
+				"user_openid": openId,
+				"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_openid": openId,
+				"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"])) || pay_way != util.ObjToString((*oldOrder)["pay_way"]) {
+			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)
+			prepayTime, _ := time.ParseInLocation(util.Date_Full_Layout, util.ObjToString((*oldOrder)["prepay_time"]), time.Local)
+			surplus_second := prepayTime.Unix() - 7200 //价格变动  支付二维码更新成超时状态--重新生订单二维码
+			public.Mysql.Update("dataexport_order", map[string]interface{}{
+				"user_openid": openId,
+				"filter_id":   id,
+			}, map[string]interface{}{
+				"data_spec":      data_spec,
+				"order_money":    order_money,
+				"original_price": original_price,
+				"prepay_time":    util.FormatDateByInt64(&surplus_second, util.Date_Full_Layout),
+				"pay_way":        pay_way,
+			})
+			(*oldOrder)["order_money"] = order_money
+		}
+		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"]), pay_way, openId),
+		})
+		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", openId, id)
+			return false
+		}
+		return true
+	}()
+	nickname, _ := p.GetSession("s_nickname").(string)
+	result := map[string]interface{}{
+		"status": "n",
+	}
+	if isPass {
+		//创建微信预支付订单
+		if pay_way == "微信" {
+			tradeno, ret := public.WxStruct.CreatePrepayOrder(config.Sysconfig["weixinrpc"].(string), "b", 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,
+				})
+				if orderid > 0 {
+					p.SetSession("DataExportVerifyPhone_val", user_phone)
+					result["status"] = "y"
+					result["code"] = ordercode
+					result["token"] = public.GetWaitPayToken(orderid, order_money, ordercode, pay_way, openId)
+				}
+			} else {
+				log.Println("生成微信预支付交易单失败", ret)
+			}
+		} else if pay_way == "支付宝" {
+			if qr_url, tradeno, err := Alipay.GetPayUrl(util.Float64All(order_money)); err == nil {
+				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":          "",
+					"code_url":           qr_url,
+					"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,
+				})
+				if orderid > 0 {
+					p.SetSession("DataExportVerifyPhone_val", user_phone)
+					result["status"] = "y"
+					result["code"] = ordercode
+					result["token"] = public.GetWaitPayToken(orderid, order_money, ordercode, pay_way, openId)
+				}
+			} else {
+				log.Println("生成支付宝预支付交易单失败")
+			}
+		}
+	}
+	p.ServeJson(result)
+}
+
+func (p *DataExportPayAction) IsPaySuccess() {
+	defer util.Catch()
+	code := p.GetString("code")
+	openid, _ := p.GetSession("s_m_openid").(string)
+	status := "n"
+	if code != "" || openid != "" {
+		data := public.Mysql.FindOne("dataexport_order", map[string]interface{}{
+			"order_code":  code,
+			"user_openid": openid,
+		}, "order_status", "")
+		if data != nil && util.IntAll((*data)["order_status"]) == 1 {
+			status = "y"
+		}
+	}
+	p.ServeJson(map[string]interface{}{
+		"status": status,
+	})
+}

+ 3 - 279
src/jfw/pay/weixin.go

@@ -1,9 +1,6 @@
 package pay
 
 import (
-	"bytes"
-	"encoding/base64"
-	"encoding/json"
 	"fmt"
 	"jfw/config"
 	"jfw/jyutil"
@@ -29,11 +26,10 @@ type WxPayAction struct {
 	payIndex      xweb.Mapper `xweb:"/weixin/pay/index"`      //微信支付页面
 	wxPay         xweb.Mapper `xweb:"/weixin/pay/pay"`        //微信支付
 	//pc端扫码支付
-	sacnPay_WaitPay     xweb.Mapper `xweb:"/weixin/sacnPay/waitPay"`     //生成支付二维码
-	sacnPay_CreateOrder xweb.Mapper `xweb:"/weixin/sacnPay/createOrder"` //创建订单
+	//sacnPay_WaitPay     xweb.Mapper `xweb:"/weixin/sacnPay/waitPay"`     //生成支付二维码
+	//sacnPay_CreateOrder xweb.Mapper `xweb:"/weixin/sacnPay/createOrder"` //创建订单
 	//统一回调函数
-	payCallback  xweb.Mapper `xweb:"/weixin/pay/callback"`     //微信支付回调
-	isPaySuccess xweb.Mapper `xweb:"/weixin/pay/isPaySuccess"` //是否支付成功
+	payCallback xweb.Mapper `xweb:"/weixin/pay/callback"` //微信支付回调
 }
 
 func init() {
@@ -296,275 +292,3 @@ func (c *WxPayAction) Qr(code string) error {
 	_, err := w.Write(pngdat)
 	return err
 }
-func (p *WxPayAction) SacnPay_CreateOrder() {
-	defer util.Catch()
-	openId, _ := p.GetSession("s_m_openid").(string)
-	id := util.SE.Decode4Hex(p.GetString("id"))
-	if openId == "" || id == "" {
-		log.Println("openId,id错误", openId, id)
-		p.ServeJson(map[string]interface{}{
-			"status": "n",
-		})
-		return
-	}
-	//
-	data_spec := p.GetString("data_spec")
-	if data_spec == "standard" {
-		data_spec = "标准字段包"
-	} else if data_spec == "senior" {
-		data_spec = "高级字段包"
-	}
-	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_openid": openId,
-		"filter_id":   id,
-	}, "id,order_status,order_code,order_money,user_mail,user_phone,data_spec,prepay_time", "")
-	if oldOrder != nil {
-		if user_mail != "" && user_mail != util.ObjToString((*oldOrder)["user_mail"]) {
-			public.Mysql.Update("dataexport_order", map[string]interface{}{
-				"user_openid": openId,
-				"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_openid": openId,
-				"filter_id":   id,
-			}, map[string]interface{}{
-				"user_phone": user_phone,
-			})
-		}
-		if data_spec != "" && data_spec != util.ObjToString((*oldOrder)["data_spec"]) {
-			//
-			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)
-			prepayTime, _ := time.ParseInLocation(util.Date_Full_Layout, util.ObjToString((*oldOrder)["prepay_time"]), time.Local)
-			surplus_second := prepayTime.Unix() - 7200 //价格变动  支付二维码更新成超时状态--重新生订单二维码
-			public.Mysql.Update("dataexport_order", map[string]interface{}{
-				"user_openid": openId,
-				"filter_id":   id,
-			}, map[string]interface{}{
-				"data_spec":      data_spec,
-				"order_money":    order_money,
-				"original_price": original_price,
-				"prepay_time":    util.FormatDateByInt64(&surplus_second, util.Date_Full_Layout),
-			})
-			(*oldOrder)["order_money"] = order_money
-		}
-		if util.IntAll((*oldOrder)["order_status"]) == 0 {
-			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"]), openId),
-			})
-			return
-		} else {
-			log.Println("该订单已存在,订单状态不允许支付!", openId)
-			p.ServeJson(map[string]interface{}{
-				"status": "n",
-			})
-			return
-		}
-	}
-	user_mail_status := p.GetSession("EMVerifySucess").(bool)
-	pay_way := p.GetString("pay_way")
-	//
-	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", openId, id)
-			return false
-		}
-		return true
-	}()
-	nickname, _ := p.GetSession("s_nickname").(string)
-	result := map[string]interface{}{
-		"status": "n",
-	}
-	if isPass {
-		//创建微信预支付订单
-		if pay_way == "weixin" {
-			tradeno, ret := public.WxStruct.CreatePrepayOrder(config.Sysconfig["weixinrpc"].(string), "b", 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,
-				})
-				if orderid > 0 {
-					p.SetSession("DataExportVerifyPhone_val", user_phone)
-					result["status"] = "y"
-					result["code"] = ordercode
-					result["token"] = public.GetWaitPayToken(orderid, order_money, ordercode, openId)
-				}
-			} else {
-				log.Println("生成预支付交易单失败", ret)
-			}
-		}
-	}
-	p.ServeJson(result)
-}
-func (p *WxPayAction) SacnPay_WaitPay() error {
-	defer util.Catch()
-	openid, _ := p.GetSession("s_m_openid").(string)
-	code := p.GetString("code")
-	token := p.GetString("token")
-	surplus, money, qrcode := func() (int64, int, 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", "")
-		if data == nil {
-			log.Println("订单号不存在!", openid)
-			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"])
-		realToken := public.GetWaitPayToken(orderid, orderMoney, code, 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
-			//重新生成预订单
-			tradeno, ret := public.WxStruct.CreatePrepayOrder(config.Sysconfig["weixinrpc"].(string), "b", p.IP(), openid, "", orderMoney)
-			if ret != nil {
-				now := time.Now()
-				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 = (*ret)["codeurl"]
-				}
-			}
-		}
-		r, _ := qr.Encode(codeUrl, qr.M)
-		pngdat := r.PNG()
-		return surplus_second, orderMoney, base64.StdEncoding.EncodeToString(pngdat)
-	}()
-	p.T["money"] = float64(money) / 100
-	p.T["surplus_second"] = surplus
-	p.T["qrcode"] = qrcode
-	p.T["ordercode"] = code
-	return p.Render("/pc/waitpay.html")
-}
-func (p *WxPayAction) IsPaySuccess() {
-	defer util.Catch()
-	code := p.GetString("code")
-	openid, _ := p.GetSession("s_m_openid").(string)
-	status := "n"
-	if code != "" || openid != "" {
-		data := public.Mysql.FindOne("dataexport_order", map[string]interface{}{
-			"order_code":  code,
-			"user_openid": openid,
-		}, "order_status", "")
-		if data != nil && util.IntAll((*data)["order_status"]) == 1 {
-			status = "y"
-		}
-	}
-	p.ServeJson(map[string]interface{}{
-		"status": status,
-	})
-}

+ 2 - 2
src/jfw/public/dataexport.go

@@ -524,8 +524,8 @@ func SendMailToPayUser(order *map[string]interface{}, order_money float64, pay_t
 		}
 	}
 }
-func GetWaitPayToken(orderid int64, order_money int, ordercode, openId string) string {
-	return util.GetMd5String(fmt.Sprintf("%d_%d_%s_%s", orderid, order_money, ordercode, openId))
+func GetWaitPayToken(orderid int64, order_money int, ordercode, payway, openId string) string {
+	return util.GetMd5String(fmt.Sprintf("%d_%d_%s_%s_%s", orderid, order_money, ordercode, payway, openId))
 }
 func GetOrderCode(id string) string {
 	return fmt.Sprintf("%s%s", time.Now().Format("150405"), util.GetRandom(6))

+ 19 - 14
src/web/staticres/dataExport/css/payment_order.css

@@ -58,33 +58,38 @@ body { background-color: #F5F5FB !important; }
 
 #pay .inner .email .input .status .err i { color: #FE737A; font-size: 18px; }
 
-#pay .inner .guige, #pay .inner .wxpay { padding-bottom: 18px; border-bottom: 1px solid #ccc; margin-bottom: 15px; }
+#pay .inner .guige, #pay .inner .pay { padding-bottom: 18px; border-bottom: 1px solid #ccc; margin-bottom: 15px; }
 
-#pay .inner .guige .title, #pay .inner .wxpay .title { font-size: 16px; color: #1d1d1d; margin-bottom: 16px; }
+#pay .inner .guige .title, #pay .inner .pay .title { font-size: 16px; color: #1d1d1d; margin-bottom: 16px; }
 
-#pay .inner .guige .title i, #pay .inner .wxpay .title i { color: #2CB7CA; font-size: 20px; margin-left: 10px; cursor: pointer; }
+#pay .inner .guige .title i, #pay .inner .pay .title i { color: #2CB7CA; font-size: 20px; margin-left: 10px; cursor: pointer; }
 
-#pay .inner .guige .inner div, #pay .inner .wxpay .inner div { width: 140px; height: 58px; padding: 8px 0; box-sizing: border-box; border: 1px solid #ccc; float: left; margin-right: 16px; border-radius: 4px; cursor: pointer; }
+#pay .inner .guige .inner div, #pay .inner .pay .inner div { width: 140px; height: 58px; padding: 8px 0; box-sizing: border-box; border: 1px solid #ccc; float: left; margin-right: 16px; border-radius: 4px; cursor: pointer; }
 
-#pay .inner .guige .inner div.bz p, #pay .inner .guige .inner div.gj p, #pay .inner .wxpay .inner div.bz p, #pay .inner .wxpay .inner div.gj p { width: 100%; text-align: center; }
+#pay .inner .guige .inner div.bz p, #pay .inner .guige .inner div.gj p, #pay .inner .pay .inner div.bz p, #pay .inner .pay .inner div.gj p { width: 100%; text-align: center; }
 
-#pay .inner .guige .inner div.bz p:nth-of-type(1), #pay .inner .guige .inner div.gj p:nth-of-type(1), #pay .inner .wxpay .inner div.bz p:nth-of-type(1), #pay .inner .wxpay .inner div.gj p:nth-of-type(1) { font-size: 14px; color: #1D1D1D; margin-bottom: 1px; }
+#pay .inner .guige .inner div.bz p:nth-of-type(1), #pay .inner .guige .inner div.gj p:nth-of-type(1), #pay .inner .pay .inner div.bz p:nth-of-type(1), #pay .inner .pay .inner div.gj p:nth-of-type(1) { font-size: 14px; color: #1D1D1D; margin-bottom: 1px; }
 
-#pay .inner .guige .inner div.bz p:nth-of-type(2), #pay .inner .guige .inner div.gj p:nth-of-type(2), #pay .inner .wxpay .inner div.bz p:nth-of-type(2), #pay .inner .wxpay .inner div.gj p:nth-of-type(2) { font-size: 12px; color: #888; }
+#pay .inner .guige .inner div.bz p:nth-of-type(2), #pay .inner .guige .inner div.gj p:nth-of-type(2), #pay .inner .pay .inner div.bz p:nth-of-type(2), #pay .inner .pay .inner div.gj p:nth-of-type(2) { font-size: 12px; color: #888; }
 
-#pay .inner .guige .inner div.bz.active, #pay .inner .guige .inner div.gj.active, #pay .inner .wxpay .inner div.bz.active, #pay .inner .wxpay .inner div.gj.active { border: 1.5px solid #2CB7CA; background: #fff url(../image/bgsanjiao.png) 118px 36px no-repeat; background-size: 19px 19px; }
+#pay .inner .guige .inner div.bz.active, #pay .inner .guige .inner div.gj.active, #pay .inner .pay .inner div.bz.active, #pay .inner .pay .inner div.gj.active { border: 1.5px solid #2CB7CA; background: #fff url(../image/bgsanjiao.png) 118px 36px no-repeat; background-size: 19px 19px; }
 
-#pay .inner .guige .inner div.gj p:nth-of-type(1) i, #pay .inner .wxpay .inner div.gj p:nth-of-type(1) i { color: #FFBA00; font-size: 12px; margin-right: 6px; }
+#pay .inner .guige .inner div.gj p:nth-of-type(1) i, #pay .inner .pay .inner div.gj p:nth-of-type(1) i { color: #FFBA00; font-size: 12px; margin-right: 6px; }
 
-#pay .inner .wxpay { border: 0; padding-bottom: 0; }
+#pay .inner .pay { border: 0; padding-bottom: 0; }
 
-#pay .inner .wxpay .inner .wx { vertical-align: middle; box-sizing: border-box; height: 40px; line-height: 40px; padding: 0; padding-left: 55px; background: #fff url(../image/wxpay.png) 25px center no-repeat; background-size: 22px 20px; }
+#pay .inner .pay .inner .wx { vertical-align: middle; box-sizing: border-box; height: 40px; font-size: 14px; line-height: 40px; padding: 0; padding-left: 55px; background: #fff url(../image/wxpay.png) 25px center no-repeat; background-size: 22px 20px; }
 
-#pay .inner .wxpay .inner .wx img { width: 22px; height: 20px; display: inline-block; }
+#pay .inner .pay .inner .wx img { width: 22px; height: 20px; display: inline-block; }
 
-#pay .inner .wxpay .inner .wx span { display: inline-block; }
+#pay .inner .pay .inner  span { display: inline-block; }
+
+#pay .inner .pay .inner .wx.active { border: 1.5px solid #2CB7CA; background-image: url(../image/wxpay.png), url(../image/bgsanjiao.png); background-position: 25px center, 118px 18px; background-repeat: no-repeat, no-repeat; background-size: 22px 20px,19px 19px;font-size: 14px;}
+
+#pay .inner .pay .inner .alipay { vertical-align: middle; box-sizing: border-box; font-size: 14px; height: 40px; line-height: 40px; padding: 0; padding-left: 55px; background: #fff url(../image/alipay.png) 25px center no-repeat; background-size: 22px 20px;}
+
+#pay .inner .pay .inner .alipay.active { border: 1.5px solid #2CB7CA; background-image: url(../image/alipay.png), url(../image/bgsanjiao.png); background-position: 25px center, 118px 18px; background-repeat: no-repeat, no-repeat; background-size: 22px 20px,19px 19px;font-size: 14px;}
 
-#pay .inner .wxpay .inner .wx.active { border: 1.5px solid #2CB7CA; background-image: url(../image/wxpay.png), url(../image/bgsanjiao.png); background-position: 25px center, 118px 18px; background-repeat: no-repeat, no-repeat; background-size: 22px 20px,19px 19px;font-size: 14px;}
 
 #pay .inner .money { width: 100%; height: 80px; background: #F5F5FB; border-top: 1px solid #ccc; padding-right: 20px; margin-bottom: 15px; }
 

BIN
src/web/staticres/dataExport/image/alipay.png


BIN
src/web/staticres/dataExport/image/alipay_b.png


BIN
src/web/staticres/dataExport/image/phone_wx.png


BIN
src/web/staticres/dataExport/image/phone_zfb.png


+ 31 - 8
src/web/templates/pc/createOrderPage.html

@@ -100,12 +100,15 @@
                 <div>公告标题、公告内容、公告地址、剑鱼标讯地址、省份、城市、发布时间、项目名称、项目编号、采购单位、采购单位联系人、采购单位联系电话、预算、开标日期、中标单位、中标价、招标机构、项目范围、币种、公告类别</div>
             </span>
         </span>
-        <div class="wxpay">
+        <div class="pay">
             <div class="title">支付方式</div>
-            <div class="inner clearfix">
-                <div class="wx active no-select">
+            <div class="inner clearfix payway">
+                <div class="wx no-select">
                     <span>微信支付</span>
                 </div>
+                <div class="alipay no-select">
+                    <span>支付宝</span>
+                </div>
             </div>
         </div>
         <div class="money ">
@@ -154,6 +157,7 @@
 	var finishEmailVerity=false;
 	var readClause=false;
 	var dataType=1;
+  var pay_way="weixin";
 	var finishPhoneVerity=false;
 	
 	var email_lastInput={{.T.email}}
@@ -293,7 +297,7 @@
 				$(".toPay").css("background-color","#ddd")
 				$(".toPay").attr("disabled","disabled");
 			}
-		});;
+		});
 		//邮箱验证
 		var canVerify=true;
 		$(".sendEmail").on("click",function(){
@@ -372,6 +376,25 @@
 			$(".infotitle em").css("display","");
 		} 
 		
+    //支付方式
+    if(sessionStorage.getItem("order_payway"+{{.T._id}})!=null){
+      pay_way=sessionStorage.getItem("order_payway"+{{.T._id}})  
+    }
+    if(pay_way=="weixin"){
+      $(".payway .wx").addClass("active");
+    }else if(pay_way=="alipay"){
+      $(".payway .alipay").addClass("active");
+    }
+    //支付方式切换
+    $(".payway>div").on("click",function(){
+      $(this).addClass("active").siblings().removeClass("active");
+      if($(this).hasClass("wx")){
+        pay_way="weixin"
+      }else if($(this).hasClass("alipay")){
+        pay_way="alipay"
+      }
+    })
+    
 		//点击阅读条款
 		$('#checkBoxjy').on('click', function () {
 			$(this).toggleClass('hideBf');
@@ -405,18 +428,18 @@
 				return	
 			}
 			canpay=false;
-			
 			var param={};
-			param.pay_way="weixin";
+      param.pay_way=pay_way;
 			param.data_spec=dataType==2?"senior":"standard";
 			param.id={{.T._id}}
 			
-			$.post("/weixin/sacnPay/createOrder",param,function(data){
+			$.post("/dataExport/sacnPay/createOrder",param,function(data){
 				if(data.status=="y"){
 					sessionStorage.setItem("order_spec"+{{.T._id}}, dataType);
 					sessionStorage.setItem("order_email"+{{.T._id}}, $(".email_input").val().replace(/\s*/g,""));
 					sessionStorage.setItem("order_phone"+{{.T._id}}, $(".phone_input").val().replace(/\s*/g,""));
-					window.location.href="/weixin/sacnPay/waitPay?code="+data.code+"&token="+data.token;
+          sessionStorage.setItem("order_payway"+{{.T._id}},pay_way);
+					window.location.href="/dataExport/sacnPay/waitPay?code="+data.code+"&token="+data.token;
 				}else{
 					canpay=true;
 					$.confirm({

+ 1 - 1
src/web/templates/pc/dataExport_sieve.html

@@ -392,7 +392,7 @@
 			  {{range $k,$v := $s}}
     			{{if $v.s_pic}}
     				{{if $v.s_link}}<a href="{{$v.s_link}}" target="_blank"/>{{end}}
-    				<img src="{{$v.s_pic}}">
+    				<img src="{{$v.s_pic}}" style="width:1200px;height:125px">
     				{{if $v.s_link}}</a>{{end}}
     			  {{else}}
     			{{Html $v.s_script}}

+ 1 - 1
src/web/templates/pc/myOrder.html

@@ -461,7 +461,7 @@
     }
 
     function toPay(orderCode,token) {
-        window.location.href = "/weixin/sacnPay/waitPay?code="+orderCode+"&token="+token;
+        window.location.href = "/dataExport/sacnPay/waitPay?code="+orderCode+"&token="+token;
     }
 
     function FormatNum(n){

+ 16 - 5
src/web/templates/pc/waitpay.html

@@ -130,16 +130,27 @@
             <p>距离二维码过期还有<span id="surplus_second"></span>,过期后请重新刷新页面获取二维码</p>
             <div class="center clearfix">
                 <div class="fl">
-					<div style="position:relative;width: 300px;height: 300px;">
-						{{if .T.qrcode}}<img src="data:image/png;base64,{{.T.qrcode}}" style="width: 330px;position:relative;left:-15px;top:-15px;">{{end}}
+					<div style="position:relative;width: 300px;height: 300px;user-select: none;">
+            {{if eq .T.pay_way "微信"}}
+						  {{if .T.qrcode}}<img src="data:image/png;base64,{{.T.qrcode}}" style="width: 330px;position:relative;left:-15px;top:-15px;">{{end}}
+            {{end}}
+            {{if eq .T.pay_way "支付宝"}}
+              <iframe src={{.T.qrcode}} style="width: 330px;height:330px;border:none;padding-left: 25px;padding-top: 25px;">
+              </iframe>
+            {{end}}
 						<a style="border-radius:3px;position:absolute;left: 0;top:0px;border: 1px solid #ccc;width: 300px;height:300px;"></a>
 					</div>
                     <div style="text-align:left;font-size: 16px; color: #1d1d1d;padding-left: 30px;margin-top: 30px;">
-						<img src="{{Msg "seo" "cdn"}}/dataExport/image/wx_cm.jpg" style="vertical-align: middle;margin-right:10px;position: relative;top: -2px;"><span>使用手机微信扫描二维码支付</span>
+						<img src="{{Msg "seo" "cdn"}}/dataExport/image/wx_cm.jpg" style="vertical-align: middle;margin-right:10px;position: relative;top: -2px;"><span>使用手机{{.T.pay_way}}扫描二维码支付</span>
 					</div>
                 </div>
                 <div class="fr">
-                    <img src="{{Msg "seo" "cdn"}}/dataExport/image/phone_.png" alt="">
+                {{if eq .T.pay_way "微信"}}
+                    <img src="{{Msg "seo" "cdn"}}/dataExport/image/phone_wx.png" alt="">
+                {{end}}
+                {{if eq .T.pay_way "支付宝"}}
+                     <img src="{{Msg "seo" "cdn"}}/dataExport/image/phone_zfb.png" alt="">
+                {{end}}
                 </div>
             </div>
         </div>
@@ -179,7 +190,7 @@
 		}
 	}
 	setInterval(function(){
-		$.post("/weixin/pay/isPaySuccess",{code:{{.T.ordercode}}},function(r){
+		$.post("/dataExport/pay/isPaySuccess",{code:{{.T.ordercode}}},function(r){
 			if(r.status == "y"){
 				window.location.href = "/front/dataExport/paysuccess?code="+{{.T.ordercode}};
 			}