浏览代码

合并支付

wangkaiyue 5 年之前
父节点
当前提交
00d6674170
共有 86 个文件被更改,包括 4247 次插入5506 次删除
  1. 3 31
      src/config.json
  2. 0 115
      src/dataexport.json
  3. 10 49
      src/jfw/front/dataExport.go
  4. 0 219
      src/jfw/front/datareport.go
  5. 25 0
      src/jfw/front/front.go
  6. 2 92
      src/jfw/front/ws_dataExport.go
  7. 0 43
      src/jfw/front/wxMyOrder.go
  8. 1 235
      src/jfw/modules/app/src/app/front/datareport.go
  9. 1 45
      src/jfw/modules/app/src/app/front/myorder.go
  10. 0 77
      src/jfw/modules/app/src/app/front/paycallbak.go
  11. 0 183
      src/jfw/modules/app/src/app/pay/alipay.go
  12. 0 462
      src/jfw/modules/app/src/app/pay/dataexport_pay.go
  13. 0 25
      src/jfw/modules/app/src/app/pay/wxpay.go
  14. 1 23
      src/jfw/modules/app/src/config.json
  15. 0 115
      src/jfw/modules/app/src/dataexport.json
  16. 2 1
      src/jfw/modules/app/src/main.go
  17. 4 4
      src/jfw/modules/app/src/web/templates/dataExport/dataExport_payOrder.html
  18. 2 2
      src/jfw/modules/app/src/web/templates/dataExport/dataExport_toMyOrder.html
  19. 2 2
      src/jfw/modules/app/src/web/templates/dataExport/dataExport_toOrderDetail.html
  20. 2 2
      src/jfw/modules/app/src/web/templates/datareport/dataReport_info.html
  21. 6 0
      src/jfw/modules/app/src/web/templates/weixin/search/mainSearch.html
  22. 二进制
      src/jfw/modules/followent/src/src.exe~
  23. 17 7
      src/jfw/modules/subscribepay/src/a/init.go
  24. 4 21
      src/jfw/modules/subscribepay/src/config.json
  25. 38 25
      src/jfw/modules/subscribepay/src/config/config.go
  26. 0 9
      src/jfw/modules/subscribepay/src/dataexport.json
  27. 20 0
      src/jfw/modules/subscribepay/src/entity/JsonRespStrust.go
  28. 696 0
      src/jfw/modules/subscribepay/src/entity/dataExportSearch.go
  29. 41 0
      src/jfw/modules/subscribepay/src/entity/dataReportStruct.go
  30. 668 0
      src/jfw/modules/subscribepay/src/entity/dataexport.go
  31. 63 0
      src/jfw/modules/subscribepay/src/entity/payCalbackStrust.go
  32. 29 0
      src/jfw/modules/subscribepay/src/entity/reWardStruct.go
  33. 182 0
      src/jfw/modules/subscribepay/src/entity/subscribeVip.go
  34. 5 0
      src/jfw/modules/subscribepay/src/filter/sessionfilter.go
  35. 222 0
      src/jfw/modules/subscribepay/src/pay/aliPay.go
  36. 75 0
      src/jfw/modules/subscribepay/src/pay/util.go
  37. 225 0
      src/jfw/modules/subscribepay/src/pay/wxPay.go
  38. 31 0
      src/jfw/modules/subscribepay/src/pay_config.json
  39. 58 0
      src/jfw/modules/subscribepay/src/rpc/rpc.go
  40. 108 0
      src/jfw/modules/subscribepay/src/service/commonAction.go
  41. 602 0
      src/jfw/modules/subscribepay/src/service/dataExportPay_mobile.go
  42. 483 0
      src/jfw/modules/subscribepay/src/service/dataExportPay_pc.go
  43. 141 0
      src/jfw/modules/subscribepay/src/service/dataReport.go
  44. 0 346
      src/jfw/modules/subscribepay/src/service/orderListDetails.go
  45. 122 0
      src/jfw/modules/subscribepay/src/service/payCallback.go
  46. 144 0
      src/jfw/modules/subscribepay/src/service/reward.go
  47. 0 16
      src/jfw/modules/subscribepay/src/service/test.go
  48. 3 2
      src/jfw/modules/subscribepay/src/service/vipSubscribeEdit.go
  49. 29 145
      src/jfw/modules/subscribepay/src/service/vipSubscribePay.go
  50. 17 59
      src/jfw/modules/subscribepay/src/service/vipSubscribeTrial.go
  51. 0 842
      src/jfw/modules/subscribepay/src/util/dataexport.go
  52. 3 0
      src/jfw/modules/subscribepay/src/util/db.go
  53. 0 21
      src/jfw/modules/subscribepay/src/util/public.go
  54. 0 69
      src/jfw/modules/subscribepay/src/util/subutil.go
  55. 60 0
      src/jfw/modules/subscribepay/src/util/wx.go
  56. 二进制
      src/jfw/modules/subscribepay/src/web/staticres/res/dataexport/20191101111057_110751943118_YiwEl.xlsx
  57. 二进制
      src/jfw/modules/subscribepay/src/web/staticres/res/dataexport/20191101111643_111625569281_ncpRN.xlsx
  58. 二进制
      src/jfw/modules/subscribepay/src/web/staticres/res/dataexport/20191102102441_102419312529_GbsLn.xlsx
  59. 二进制
      src/jfw/modules/subscribepay/src/web/staticres/res/dataexport/20191102103704_103411306790_jwzPW.xlsx
  60. 二进制
      src/jfw/modules/subscribepay/src/web/staticres/res/dataexport/20191102104505_104459602072_ArZWk.xlsx
  61. 二进制
      src/jfw/modules/subscribepay/src/web/staticres/res/dataexport/20191102142336_112752020479_cgMbr.xlsx
  62. 二进制
      src/jfw/modules/subscribepay/src/web/staticres/res/dataexport/20191102142618_142558530331_pOGGw.xlsx
  63. 二进制
      src/jfw/modules/subscribepay/src/web/staticres/res/dataexport/20191102143022_143006774983_mVjxm.xlsx
  64. 二进制
      src/jfw/modules/subscribepay/src/web/staticres/res/dataexport/20191102144321_144312451130_xyeJQ.xlsx
  65. 二进制
      src/jfw/modules/subscribepay/src/web/staticres/res/dataexport/20191102145809_145756817218_xfYgY.xlsx
  66. 二进制
      src/jfw/modules/subscribepay/src/web/staticres/res/dataexport/20191102145853_145845017344_HMKbP.xlsx
  67. 5 5
      src/jfw/modules/weixin/src/config.json
  68. 二进制
      src/jfw/modules/weixin/src/src
  69. 0 333
      src/jfw/pay/aliPay.go
  70. 0 753
      src/jfw/pay/dataExportPay.go
  71. 0 323
      src/jfw/pay/weixin.go
  72. 6 674
      src/jfw/public/dataexport.go
  73. 0 59
      src/jfw/rpcfollow/rpc.go
  74. 2 2
      src/main.go
  75. 1 1
      src/web/templates/pc/biddetail.html
  76. 1 1
      src/web/templates/pc/biddetail_rec.html
  77. 1 1
      src/web/templates/pc/createOrderPage.html
  78. 1 1
      src/web/templates/pc/dataExport_invoice.html
  79. 72 56
      src/web/templates/pc/waitpay.html
  80. 1 1
      src/web/templates/weixin/dataExport/dataExport_payOrder.html
  81. 1 1
      src/web/templates/weixin/dataExport/dataExport_toMyOrder.html
  82. 1 1
      src/web/templates/weixin/dataExport/dataExport_toOrderDetail.html
  83. 3 2
      src/web/templates/weixin/datareport/dataReport_info.html
  84. 3 3
      src/web/templates/weixin/pay.html
  85. 1 1
      src/web/templates/weixin/wxinfocontent.html
  86. 1 1
      src/web/templates/weixin/wxinfocontent_rec.html

+ 3 - 31
src/config.json

@@ -210,35 +210,12 @@
     "advertUrl": "/swordfish/about",
     "wxJianyu": {
         "appid": "wxd66e9589c9fecff6",
-        "appsecret": "4d9d4b9ddab59e65fcb7bed125fbd342",
-        "pay": {
-            "mchid": "1418321102",
-            "key": "topnet2016topnet2016topnet2016ab",
-            "attachmsg": "剑鱼标讯打赏",
-            "bodymsg": "剑鱼标讯-招标信息打赏",
-            "detailmsg": "招标推送信息[%s] 打赏%s元钱",
-            "sjdc_attachmsg": "剑鱼标讯-历史数据",
-            "sjdc_bodymsg": "剑鱼标讯-历史数据",
-            "sjdc_detailmsg": "剑鱼标讯-历史数据",
-            "sjbd_msg": "剑鱼标讯-数据报告",
-            "subvip_msg":"剑鱼标讯-vip订阅"
-        },
-        "openidSwitch": {
-            "oIMvJvrVXG89597EFmYiSiznbyyY": "oHwE_wEQlEBvjZJOyZeNnQcgKQMo",
-            "ouCYjw4BJMbpdMRYrTTLb9nFi2RE": "oHwE_wNA1V0DURDO0h7wAriz0qIY"
-        }
-    },
-    "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"
+        "appsecret": "4d9d4b9ddab59e65fcb7bed125fbd342"
     },
     "industry": "分类综合测试",
     "recommendEntLimit": "50",
     "jyapp": {
-        "domain": "http://web-jydev-wky.jianyu360.cn",
+        "domain": "http://web-jydev-ws.jianyu360.cn",
         "apkurl": "/jyapp/res/%s/jianyu360.apk",
         "appstoreurl": "https://itunes.apple.com/cn/app/id1354897149",
         "channelDir": {
@@ -261,11 +238,6 @@
         "timeout": 60,
         "totalPage": 10,
         "userIds": [
-            "o8-2pwHj1s_tv3nnRxrH9cD2ngkk",
-            "oHwE_wEzNi8ASXJ7YEVvZ73YfwHw",
-            "oHwE_wO-IK3t2Emq95K9hxuWTuC4",
-            "oHwE_wGFScDzGRPAWNaT0ZE9vDn8",
-            "oHwE_wDlNyATr6Qb0iXynZf1EeEE"
         ],
         "msg": "f 开关状态:%s //-2 从配置文件重置,-1 关闭,1 打开<br><br>c 并发数:%d //-2 不限制并发数,-1 无条件直接限制,>0 限制并发数<br><br>t 个人查询限制时间:%ds //-1 不限制<br><br>p 限制页数:%d"
     },
@@ -279,7 +251,7 @@
         "shareTimesUpperLimitR": 4000,
         "shareTimesUpperLimitIrr": 1000
     },
-    "cookiedomain": "web-jydev-wky.jianyu360.cn",
+    "cookiedomain": "web-jydev-ws.jianyu360.cn",
     "pcHelper": {
         "subscribeTokenTimeout": 15,
         "version": "V2.5.1"

文件差异内容过多而无法显示
+ 0 - 115
src/dataexport.json


+ 10 - 49
src/jfw/front/dataExport.go

@@ -6,7 +6,8 @@ import (
 	"errors"
 	"fmt"
 	"jfw/config"
-	"jfw/pay"
+
+	//	"jfw/pay"
 	"jfw/public"
 	"log"
 	"qfw/util"
@@ -30,7 +31,6 @@ type DataExport struct {
 	deleteOrder   xweb.Mapper `xweb:"/front/dataExport/deleteOrder"`         //删除订单
 	toOrderDetail xweb.Mapper `xweb:"/front/dataExport/toOrderDetail/(.*)"`  //订单详情
 	getOrderCode  xweb.Mapper `xweb:"/front/dataExport/getOrderCode/(\\w+)"` //申请发票获取订单编号
-	applyInvoice  xweb.Mapper `xweb:"/front/dataExport/applyInvoice"`        //申请发票
 
 	superSearchExport xweb.Mapper `xweb:"/front/dataExport/superSearchExport"`      //数据导出-超级搜索
 	toCreateOrderPage xweb.Mapper `xweb:"/front/dataExport/toCreateOrderPage/(.*)"` //数据导出-订单页面
@@ -39,8 +39,8 @@ type DataExport struct {
 	checkMailVerify   xweb.Mapper `xweb:"/front/dataExport/checkMailVerify"`        //验证邮箱验证码
 	paysuccess        xweb.Mapper `xweb:"/front/dataExport/paysuccess"`             //支付成功页面
 	checkPhoneVerify  xweb.Mapper `xweb:"/front/dataExport/checkPhoneVerify"`       //验证手机号
-
-	fontSet xweb.Mapper `xweb:"/front/dataExport/fontSet/(.*)"`
+	payPage           xweb.Mapper `xweb:"/dataExport/sacnPay/waitPay"`              //支付页面
+	fontSet           xweb.Mapper `xweb:"/front/dataExport/fontSet/(.*)"`
 
 	cancelOrder xweb.Mapper `xweb:"/front/dataExport/cancelOrder"` //取消订单
 }
@@ -210,7 +210,7 @@ func (d *DataExport) QueryOrder() error {
 	if list != nil {
 		for _, v := range *list {
 			filter_publishtime := v["filter_publishtime"]
-			if filter_publishtime != nil || filter_publishtime != "" {
+			if filter_publishtime != nil && filter_publishtime != "" {
 				timeArr := strings.Split(filter_publishtime.(string), "_")
 				if len(timeArr) == 2 {
 					start, err := strconv.ParseInt(timeArr[0], 10, 64)
@@ -276,7 +276,7 @@ func (d *DataExport) DeleteOrder() error {
 		order := public.Mysql.FindOne(tableName_order, queryMap, "pay_way,out_trade_no,prepay_time,order_status", "")
 		if order != nil {
 			if util.IntAll((*order)["order_status"]) == 0 { //未支付状态下 删除订单需要先关闭订单
-				flag = pay.CloseDataExportOrder(util.ObjToString((*order)["pay_way"]), util.ObjToString((*order)["out_trade_no"]), util.ObjToString((*order)["prepay_time"]))
+				//flag = pay.CloseDataExportOrder(util.ObjToString((*order)["pay_way"]), util.ObjToString((*order)["out_trade_no"]), util.ObjToString((*order)["prepay_time"]))
 			} else {
 				flag = true
 			}
@@ -401,49 +401,6 @@ func (d *DataExport) GetOrderCode(order_code string) error {
 	return nil
 }
 
-//----------------------------申请发票------------------------------------
-func (d *DataExport) ApplyInvoice() error {
-	var applyBill_status int
-	var order_code, applyBill_company, applyBill_taxnum, applyBill_type string
-	var updateBl bool = false
-	order_code = d.GetString("order_code")
-	//获取数据
-	applyBill_type = d.GetString("demo-radio") //个人 单位
-	queryMap := map[string]interface{}{
-		"order_code": order_code,
-	}
-	if applyBill_type == "个人" {
-		applyBill_status = 1
-		updateBl = public.Mysql.Update(tableName_order, queryMap, map[string]interface{}{"applyBill_status": applyBill_status})
-
-	} else if applyBill_type == "单位" {
-		applyBill_status = 1                                 //状态
-		applyBill_company = d.GetString("applyBill_company") //公司名
-		applyBill_taxnum = d.GetString("applyBill_taxnum")   //纳税人识别号
-		updateBl = public.Mysql.Update(tableName_order, queryMap, map[string]interface{}{
-			"applyBill_company": applyBill_company,
-			"applyBill_taxnum":  applyBill_taxnum,
-			"applyBill_status":  applyBill_status,
-			"applyBill_type":    1,
-		}) //修改操作
-	}
-	//判断条件
-	if updateBl {
-		go func() {
-			orderdata := public.Mysql.FindOne(tableName_order, map[string]interface{}{
-				"order_code": order_code,
-			}, "id,filter,user_mail,user_phone,product_type,data_spec,filter_id,order_code,data_count,order_status,order_money,out_trade_no,applybill_type,applybill_company,applybill_taxnum,user_openid,create_time,pay_time,pay_way", "")
-			tt := time.Now()
-			pay_time := util.FormatDate(&tt, util.Date_Full_Layout)
-			public.SendMailToBJFinance(orderdata, pay_time, "", 2, config.GmailAuth)
-		}()
-	}
-	d.ServeJson(map[string]interface{}{
-		"flag": updateBl,
-	})
-	return nil
-}
-
 //---------------------------生成订单预览----------------------------------
 func (d *DataExport) SuperSearchExport() error {
 	openid := util.ObjToString(d.GetSession("s_m_openid"))
@@ -849,3 +806,7 @@ func (d *DataExport) Paysuccess() error {
 	d.T["order_code"] = code
 	return d.Render("/pc/paysuccess.html")
 }
+
+func (d *DataExport) PayPage() {
+	d.Render("/pc/waitpay.html")
+}

+ 0 - 219
src/jfw/front/datareport.go

@@ -6,12 +6,10 @@ import (
 	"jfw/config"
 	"jfw/jyutil"
 	"jfw/public"
-	"log"
 	"net/url"
 	"qfw/util"
 	"regexp"
 	"strings"
-	"time"
 
 	"github.com/go-xweb/xweb"
 )
@@ -19,9 +17,7 @@ import (
 type DataReport struct {
 	*xweb.Action
 	toDataReport xweb.Mapper `xweb:"/weixin/pay/dataReport"`         //数据报告支付页面
-	toWxjsPay    xweb.Mapper `xweb:"/front/dataReport/toWxjsPay"`    //数据报告支付页面
 	isPaySuccess xweb.Mapper `xweb:"/front/dataReport/isPaySuccess"` //数据报告是否支付完成
-	payCallback  xweb.Mapper `xweb:"/front/dataReport/payCallback"`  //支付完成回调
 	paySuccess   xweb.Mapper `xweb:"/front/dataReport/paySuccess"`   //数据报告支付完成
 }
 
@@ -31,7 +27,6 @@ func init() {
 
 func (d *DataReport) ToDataReport() error {
 	userId := util.ObjToString(d.GetSession("userId"))
-	log.Println("sesseioIIIIIDDDD", d.Session().Id(), "zzzz", userId)
 	if userId == "" { //自动登录
 		//若不是在微信中打开跳转关于剑鱼
 		if !strings.Contains(strings.ToLower(d.Header("user-agent")), "micromessenger") {
@@ -84,220 +79,6 @@ func (d *DataReport) PaySuccess() {
 	d.Render("/weixin/datareport/dataReport_success.html", &d.T)
 }
 
-func (d *DataReport) ToWxjsPay() {
-	name := d.GetString("s_name")
-	company := d.GetString("s_company")
-	phone := d.GetString("s_phone")
-	email := d.GetString("s_email")
-	reportId := d.GetString("s_reportId")
-	userId := util.ObjToString(d.GetSession("userId"))
-	openId := util.ObjToString(d.GetSession("s_m_openid"))
-	log.Println("openId--", openId, "userId--", userId)
-	var payOrderId int64 //可重复支付修改
-	payStr, errMsg := func() (string, error) {
-		if !checkUserName(name) || !checkCompany(company) || !checkEmail(email) || !checkPhone(phone) {
-			return "", errors.New("输入校验不通过")
-		}
-		//检索订单  //可以重复支付
-		// oldOrder := public.Mysql.FindOne("jy_datareport_order", map[string]interface{}{
-		// 	"user_id":   userId,
-		// 	"report_id": reportId,
-		// }, "id,order_status,order_money,prepay_time,pay_way,order_pay,user_name,user_mail,user_phone,user_company", "")
-		// if oldOrder != nil {
-		// 	if util.IntAll((*oldOrder)["order_status"]) != 0 {
-		// 		return "", errors.New("订单状态不能更改")
-		// 	}
-		// 	prepayTime, _ := time.Parse(util.Date_Full_Layout, util.ObjToString((*oldOrder)["prepay_time"]))
-		// 	now := time.Now()
-		// 	orderPay := util.ObjToString((*oldOrder)["order_pay"])
-		// 	//基本信息改变 更新字段
-		// 	if util.ObjToString((*oldOrder)["user_name"]) != name || util.ObjToString((*oldOrder)["user_mail"]) != email ||
-		// 		util.ObjToString((*oldOrder)["user_phone"]) != phone || util.ObjToString((*oldOrder)["user_company"]) != company {
-		// 		updateValue := map[string]interface{}{
-		// 			"user_name":    name,
-		// 			"user_mail":    email,
-		// 			"user_phone":   phone,
-		// 			"user_company": company,
-		// 		}
-		// 		if !public.Mysql.Update("jy_datareport_order", map[string]interface{}{
-		// 			"user_id":   userId,
-		// 			"report_id": reportId,
-		// 		}, updateValue) {
-		// 			return "", errors.New(fmt.Sprintf("更新基本信息出错:%+v", updateValue))
-		// 		}
-		// 	}
-		// 	//订单过期需要重新生成订单
-		// 	if util.ObjToString((*oldOrder)["pay_way"]) != "wx_js" || now.After(prepayTime.Add(time.Hour*2)) || orderPay == "" {
-		// 		//查询订单单价
-		// 		order_money := util.IntAll((*oldOrder)["order_money"])
-		// 		tradeno, ret := public.WxStruct.CreatePrepayOrder(config.Sysconfig["weixinrpc"].(string), "d", d.IP(), openId, "", order_money)
-		// 		if ret == nil || (*ret)["status"] != "1" {
-		// 			return "", errors.New(fmt.Sprintf("微信生成订单出错:%s\n", (*ret)["errcodedes"]))
-		// 		}
-		// 		prepayid := util.ObjToString((*ret)["prepayid"])
-		// 		orderPay = public.WxStruct.GetWxjsPaySign(prepayid)
-		// 		//更新数据库
-		// 		updateValue := map[string]interface{}{
-		// 			"order_money":  order_money,
-		// 			"prepay_time":  util.FormatDate(&now, util.Date_Full_Layout),
-		// 			"pay_way":      "wx_js",
-		// 			"prepay_id":    prepayid,
-		// 			"order_pay":    orderPay,
-		// 			"out_trade_no": tradeno,
-		// 		}
-		// 		if !public.Mysql.Update("jy_datareport_order", map[string]interface{}{
-		// 			"user_id":   userId,
-		// 			"report_id": reportId,
-		// 		}, updateValue) {
-		// 			return "", errors.New(fmt.Sprintf("更新数据库状态出错:%+v", updateValue))
-		// 		}
-		// 	}
-		// 	return orderPay, nil
-		// } else {
-
-		//检索订单
-		datareport := public.Mysql.FindOne("jy_datareport", map[string]interface{}{
-			"report_id": reportId,
-		}, "i_price", "")
-		if datareport == nil {
-			return "", errors.New("未知数据报告")
-		}
-		order_money := util.IntAll((*datareport)["i_price"])
-		now := time.Now()
-		tradeno, ret := public.WxStruct.CreatePrepayOrder(config.Sysconfig["weixinrpc"].(string), "d", d.IP(), openId, "", order_money)
-		if ret == nil || (*ret)["status"] != "1" {
-			return "", errors.New("微信生成订单出错")
-		}
-		prepayid := util.ObjToString((*ret)["prepayid"])
-		orderPay := public.WxStruct.GetWxjsPaySign(prepayid)
-		insertValue := map[string]interface{}{
-			"order_money":    order_money,
-			"order_status":   0,
-			"service_status": 0,
-			"user_name":      name,
-			"prepay_id":      prepayid,
-			"order_pay":      orderPay,
-			"out_trade_no":   tradeno,
-			"report_id":      reportId,
-			"product_type":   "数据报告",
-			"create_time":    util.FormatDate(&now, util.Date_Full_Layout),
-			"prepay_time":    util.FormatDate(&now, util.Date_Full_Layout),
-			"user_mail":      email,
-			"user_phone":     phone,
-			"pay_way":        "wx_js",
-			"user_id":        userId,
-			"user_company":   company,
-		}
-		if payOrderId = public.Mysql.Insert("jy_datareport_order", insertValue); payOrderId == 0 {
-			return "", errors.New(fmt.Sprintf("插入数据库出错:%+v", insertValue))
-		}
-		return orderPay, nil
-		//}
-	}()
-	errMsgStr := ""
-	if errMsg != nil {
-		log.Printf("%s CreateOlder 生成支付出错%v", userId, errMsg)
-		errMsgStr = strings.Split(errMsg.Error(), ":")[0]
-	}
-	d.ServeJson(map[string]interface{}{
-		"success":    util.If(errMsg == nil, true, false).(bool),
-		"payStr":     payStr,
-		"showErr":    errMsgStr,
-		"payOrderId": payOrderId,
-	})
-}
-
-//查询是否支付完成
-func (d *DataReport) IsPaySuccess() {
-	userId := util.ObjToString(d.GetSession("userId"))
-	payOrderId := d.GetString("payOrderId")
-	success := false
-	orderdata := public.Mysql.FindOne("jy_datareport_order", map[string]interface{}{
-		"user_id": userId,
-		"id":      payOrderId,
-	}, "order_status", "")
-	if orderdata != nil && util.IntAll((*orderdata)["order_status"]) == 1 {
-		success = true
-	}
-	d.ServeJson(map[string]interface{}{
-		"success": success,
-	})
-}
-
-//微信支付完成回调
-func (d *DataReport) PayCallback() {
-	defer util.Catch()
-	by := d.Body()
-	fmt.Println("数据报告-回调通知参数", string(by))
-	ret := util.XmlToMap(string(by))
-	if ret["return_code"] == "SUCCESS" && ret["appid"] == public.WxStruct.Appid && ret["mch_id"] == public.WxStruct.Mchid {
-		order_money := util.IntAll(ret["total_fee"])
-		orderdata := public.Mysql.FindOne("jy_datareport_order", map[string]interface{}{
-			"out_trade_no": ret["out_trade_no"],
-			"order_money":  order_money,
-		}, "order_status,report_id,user_mail", "")
-		updateStatus, insertStatus := false, false
-		now := time.Now()
-		if orderdata != nil {
-			order_status := util.IntAll((*orderdata)["order_status"])
-			if order_status == 0 {
-				updateStatus = public.Mysql.Update("jy_datareport_order", map[string]interface{}{
-					"out_trade_no": ret["out_trade_no"],
-					"order_money":  order_money,
-				}, map[string]interface{}{
-					"pay_money":    util.IntAll(ret["cash_fee"]),
-					"pay_time":     util.FormatDate(&now, util.Date_Full_Layout),
-					"order_status": 1,
-					"pay_way":      "wx_js",
-				})
-
-				if updateStatus {
-					//发送数据
-					go public.SendDatareportMailToPayUser(util.IntAll((*orderdata)["report_id"]), util.ObjToString(ret["out_trade_no"]), util.ObjToString((*orderdata)["user_mail"]), config.GmailAuth)
-				}
-			}
-		} else {
-			log.Println("未找到此订单", ret)
-		}
-
-		pay_count := public.Mysql.Count("weixin_pay", map[string]interface{}{
-			"transaction_id": ret["transaction_id"],
-			"out_trade_no":   ret["out_trade_no"],
-			"user_openid":    ret["openid"],
-		})
-		if pay_count == 0 {
-			newPayData := map[string]interface{}{
-				"transaction_id": ret["transaction_id"],
-				"out_trade_no":   ret["out_trade_no"],
-				"user_openid":    ret["openid"],
-				"create_time":    util.FormatDate(&now, util.Date_Full_Layout),
-				"total_fee":      util.IntAll(ret["total_fee"]),
-				"cash_fee":       util.IntAll(ret["cash_fee"]),
-				"time_end":       ret["time_end"],
-			}
-			if public.Mysql.Insert("weixin_pay", newPayData) > 0 {
-				insertStatus = true
-			} else {
-				log.Printf("支付数据插入失败%+v", newPayData)
-			}
-		} else {
-			log.Printf("支付数据已存在%s %s %s", ret["transaction_id"], ret["out_trade_no"], ret["openid"])
-		}
-
-		if updateStatus && insertStatus {
-			d.Write(`<xml>
-			  	<return_code><![CDATA[SUCCESS]]></return_code>
-			  	<return_msg><![CDATA[OK]]></return_msg>
-			</xml>`)
-		} else {
-			d.Write(`<xml>
-				<return_code><![CDATA[FAIL]]></return_code>
-				<return_msg><![CDATA[ERROR]]></return_msg>
-			</xml>`)
-		}
-	}
-}
-
 func checkUserName(value string) bool {
 	if value == "" {
 		return false

+ 25 - 0
src/jfw/front/front.go

@@ -133,6 +133,8 @@ type Front struct {
 	staticPage xweb.Mapper `xweb:"/front/staticPage/(.+)"`
 	//数据服务页面
 	dataService xweb.Mapper `xweb:"/front/dataService.html"`
+	//打赏页面
+	payIndex xweb.Mapper `xweb:"/weixin/reward/index"` //微信支付页面
 }
 
 var sewx util.SimpleEncrypt //微信的加密方法
@@ -182,6 +184,29 @@ func (f *Front) DataService() {
 	f.Render("/pc/dataService.html", &f.T)
 }
 
+func (p *Front) PayIndex() error {
+	defer util.Catch()
+	param := p.GetString("param")
+	params := strings.Split(param, "_")
+	id := util.DecodeArticleId2ByCheck(params[1])[0]
+	title := ""
+	if id != "" {
+		data, ok := public.MQFW.FindById("bidding", id, `{"title":1}`)
+		if ok && (data == nil || *data == nil || len(*data) == 0) {
+			data, ok = public.MQFW.FindById("bidding_back", id, `{"title":1}`)
+		}
+		if ok && data != nil && len(*data) > 0 {
+			title, _ = (*data)["title"].(string)
+		}
+	}
+	p.T["source"] = params[0]
+	p.T["id"] = id
+	p.T["pid"] = params[1]
+	p.T["title"] = title
+	p.T["signature"] = wx.SignJSSDK(p.Site() + p.Url())
+	return p.Render("/weixin/pay.html", &p.T)
+}
+
 //
 func (f *Front) RecInof() error {
 	var msg = ""

+ 2 - 92
src/jfw/front/ws_dataExport.go

@@ -5,7 +5,8 @@ import (
 	"fmt"
 	"jfw/config"
 	"jfw/jyutil"
-	"jfw/pay"
+
+	//	"jfw/pay"
 	"jfw/public"
 	"jfw/wx"
 	"log"
@@ -26,7 +27,6 @@ type WsDataExport struct {
 	searchExport   xweb.Mapper `xweb:"/front/wx_dataExport/searchExport"`   //微信数据导出
 	toPreview      xweb.Mapper `xweb:"/front/wx_dataExport/toPreview/(.*)"` //微信数据导出-预览页面
 	paySuccessPage xweb.Mapper `xweb:"/front/wx_dataExport/paySuccessPage"` //微信数据导出-支付成功页面
-	getPayParm     xweb.Mapper `xweb:"/front/wx_dataExport/getPayParm"`     //微信数据导出-获取微信支付参数
 	//微信端支付
 	toCreateOrderPage xweb.Mapper `xweb:"/weixin/pay/dataexport"`          //微信数据导出-订单微信支付
 	getPreview        xweb.Mapper `xweb:"/front/wx_dataExport/getPreview"` //微信数据导出-预览数据
@@ -78,96 +78,6 @@ func (w *WsDataExport) GetPreview() error {
 	return nil
 }
 
-//
-func (w *WsDataExport) GetPayParm() error {
-	defer util.Catch()
-	userid := util.ObjToString(w.GetSession("userId"))
-	openid := util.ObjToString(w.GetSession("s_m_openid"))
-	filterid := util.SE.Decode4Hex(w.GetString("filterid"))
-	id := w.GetString("id")
-	if userid == "" || openid == "" || id == "" {
-		log.Println("userid,id 有误!")
-		w.ServeJson(map[string]interface{}{
-			"status": 0,
-		})
-		return nil
-	}
-	token := w.GetString("token")
-	//查看创建过的预支付订单
-	Order := public.Mysql.FindOne("dataexport_order", map[string]interface{}{
-		"user_id":   userid,
-		"filter_id": filterid,
-		"id":        id,
-	}, "prepay_id,order_code,order_money,id,prepay_time,pay_way,out_trade_no,user_mail", "")
-	if Order == nil {
-		log.Println("查不到订单!")
-		w.ServeJson(map[string]interface{}{
-			"status": -1,
-		})
-		return nil
-	}
-	prepayId := util.ObjToString((*Order)["prepay_id"])
-	//	if prepayId == "" {
-	//		log.Println("订单有误!")
-	//		w.ServeJson(map[string]interface{}{
-	//			"status": -2,
-	//		})
-	//		return nil
-	//	}
-	pay_way := util.ObjToString((*Order)["pay_way"])
-	order_code := util.ObjToString((*Order)["order_code"])
-	orderid := util.Int64All((*Order)["id"])
-	orderMoney := util.IntAll((*Order)["order_money"])
-	user_mail := util.ObjToString((*Order)["user_mail"])
-
-	realToken := public.GetWaitPayToken(orderid, orderMoney, order_code, pay_way, userid)
-	if realToken != token && pay_way == "wx_js" {
-		log.Println("token错误!", userid, realToken, token, order_code, orderMoney, orderid, pay_way)
-		return nil
-	}
-	prepayTime, err := time.ParseInLocation(util.Date_Full_Layout, util.ObjToString((*Order)["prepay_time"]), time.Local)
-	surplus_second := prepayTime.Unix() + 7200 - time.Now().Unix()
-	if (err == nil && surplus_second <= 0) || prepayId == "" || pay_way != "wx_js" {
-		//在此关闭之前的订单
-		if !pay.CloseDataExportOrder(util.ObjToString((*Order)["pay_way"]), util.ObjToString((*Order)["out_trade_no"]), util.ObjToString((*Order)["prepay_time"])) {
-			w.ServeJson(map[string]interface{}{
-				"status": "n",
-			})
-			return nil
-		}
-		log.Println("订单过期或支付pc端订单,重新生成预订单!", userid)
-		tradeno, ret := public.WxStruct.CreatePrepayOrder(config.Sysconfig["weixinrpc"].(string), "c", w.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"],
-				"out_trade_no": tradeno,
-				"pay_way":      "wx_js",
-			}) {
-				prepayId = (*ret)["prepayid"]
-			}
-		}
-	}
-	timestamp := time.Now().Unix()
-	nonceStr := util.GetRandom(16) + util.GetLetterRandom(16)
-	sign := util.WxSign(fmt.Sprintf("appId=%s&nonceStr=%s&package=%s&signType=%s&timeStamp=%d&key=%s", public.WxStruct.Appid, nonceStr, "prepay_id="+prepayId, "MD5", timestamp, public.WxStruct.Key))
-	w.ServeJson(map[string]interface{}{
-		"status":     1,
-		"appId":      public.WxStruct.Appid,
-		"timestamp":  fmt.Sprint(timestamp),
-		"signType":   "MD5",
-		"sign":       sign,
-		"nonceStr":   nonceStr,
-		"prepayId":   "prepay_id=" + prepayId,
-		"order_code": order_code,
-		"user_mail":  user_mail,
-	})
-	return nil
-}
-
 //
 func (w *WsDataExport) PaySuccessPage() error {
 	defer util.Catch()

+ 0 - 43
src/jfw/front/wxMyOrder.go

@@ -25,7 +25,6 @@ type WxMyOrder struct {
 	myOrder        xweb.Mapper `xweb:"/front/wxMyOrder/myOrder"`               //查询订单
 	myOrderPaging  xweb.Mapper `xweb:"/front/wxMyOrder/myOrder/myOrderPaging"` //查询订单--分页
 	wxGetOrderCode xweb.Mapper `xweb:"/front/wxMyOrder/wxGetOrderCode/(\\w+)"` //申请发票获取订单编号
-	wxApplyInvoice xweb.Mapper `xweb:"/front/wxMyOrder/wxApplyInvoice"`        //申请发票
 	wxPaySuccess   xweb.Mapper `xweb:"/front/wxMyorder/wxPaySuccess/(\\w+)"`
 	wxDeleteOrder  xweb.Mapper `xweb:"/front/wxMyorder/wxDeleteOrder"` //删除订单
 	getOneMore     xweb.Mapper `xweb:"/front/wxMyorder/getOneMore"`    //获取额外一条数据
@@ -510,48 +509,6 @@ func (w *WxMyOrder) WxGetOrderCode(order_code string) error {
 	return nil
 }
 
-func (w *WxMyOrder) WxApplyInvoice() error {
-	var applyBill_status int
-	var order_code, applyBill_company, applyBill_taxnum, applyBill_type string
-	var updateBl bool = false
-	order_code = w.GetString("order_code")
-	//获取数据
-	applyBill_type = w.GetString("demo-radio") //个人 单位
-	queryMap := map[string]interface{}{
-		"order_code": order_code,
-	}
-	if applyBill_type == "个人" {
-		applyBill_status = 1
-		updateBl = public.Mysql.Update(tableName_order, queryMap, map[string]interface{}{"applyBill_status": applyBill_status})
-
-	} else if applyBill_type == "单位" {
-		applyBill_status = 1                                 //状态
-		applyBill_company = w.GetString("applyBill_company") //公司名
-		applyBill_taxnum = w.GetString("applyBill_taxnum")   //纳税人识别号
-		updateBl = public.Mysql.Update(tableName_order, queryMap, map[string]interface{}{
-			"applyBill_company": applyBill_company,
-			"applyBill_taxnum":  applyBill_taxnum,
-			"applyBill_status":  applyBill_status,
-			"applyBill_type":    1,
-		}) //修改操作
-	}
-	//判断条件
-	if updateBl {
-		go func() {
-			orderdata := public.Mysql.FindOne(tableName_order, map[string]interface{}{
-				"order_code": order_code,
-			}, "id,filter,user_mail,user_phone,product_type,data_spec,filter_id,order_code,data_count,order_status,order_money,out_trade_no,applybill_type,applybill_company,applybill_taxnum,user_openid,create_time,pay_time,pay_way", "")
-			tt := time.Now()
-			pay_time := util.FormatDate(&tt, util.Date_Full_Layout)
-			public.SendMailToBJFinance(orderdata, pay_time, "", 2, config.GmailAuth)
-		}()
-	}
-	w.ServeJson(map[string]interface{}{
-		"flag": updateBl,
-	})
-	return nil
-}
-
 func (w *WxMyOrder) WxPaySuccess(order_code string) error {
 	userId := w.Session().Get("userId")
 	openid := w.Session().Get("s_m_openid")

+ 1 - 235
src/jfw/modules/app/src/app/front/datareport.go

@@ -2,17 +2,13 @@ package front
 
 import (
 	"errors"
-	"fmt"
 
 	"strings"
 
-	"app/pay"
-	"jfw/config"
 	"jfw/public"
-	"log"
+
 	"qfw/util"
 	"regexp"
-	"time"
 
 	"github.com/go-xweb/xweb"
 )
@@ -20,8 +16,6 @@ import (
 type DataReport struct {
 	*xweb.Action
 	toDataReport xweb.Mapper `xweb:"/jyapp/dataReport/toPayPage/(.*)"` //数据报告支付页面
-	toAppPay     xweb.Mapper `xweb:"/jyapp/dataReport/toAppPay"`       //数据报告支付页面
-	isPaySuccess xweb.Mapper `xweb:"/jyapp/dataReport/isPaySuccess"`   //数据报告是否支付完成
 	paySuccess   xweb.Mapper `xweb:"/jyapp/dataReport/paySuccess"`     //数据报告支付完成
 }
 
@@ -57,234 +51,6 @@ func (d *DataReport) PaySuccess() {
 	d.Render("/datareport/dataReport_success.html", &d.T)
 }
 
-func (d *DataReport) ToAppPay() {
-	name := d.GetString("s_name")
-	company := d.GetString("s_company")
-	phone := d.GetString("s_phone")
-	email := d.GetString("s_email")
-	reportId := d.GetString("s_reportId")
-	pay_way := d.GetString("s_payway")
-	userId := util.ObjToString(d.GetSession("userId"))
-	var payOrderId int64 //可重复支付修改
-	payStr, errMsg := func() (string, error) {
-		if !checkUserName(name) || !checkCompany(company) || !checkEmail(email) || !checkPhone(phone) {
-			return "", errors.New("输入校验不通过")
-		}
-		//可重复支付修改
-		//检索订单
-		// oldOrder := public.Mysql.FindOne("jy_datareport_order", map[string]interface{}{
-		// 	"user_id":   userId,
-		// 	"report_id": reportId,
-		// }, "id,order_status,order_money,prepay_time,pay_way,order_pay,user_name,user_mail,user_phone,user_company", "")
-
-		// if oldOrder != nil {
-		// 	if util.IntAll((*oldOrder)["order_status"]) != 0 {
-		// 		return "", errors.New("订单状态不能更改")
-		// 	}
-		// 	prepayTime, _ := time.Parse(util.Date_Full_Layout, util.ObjToString((*oldOrder)["prepay_time"]))
-		// 	now := time.Now()
-		// 	orderPay := util.ObjToString((*oldOrder)["order_pay"])
-		// 	//基本信息改变 更新字段
-		// 	if util.ObjToString((*oldOrder)["user_name"]) != name || util.ObjToString((*oldOrder)["user_mail"]) != email ||
-		// 		util.ObjToString((*oldOrder)["user_phone"]) != phone || util.ObjToString((*oldOrder)["user_company"]) != company {
-		// 		updateValue := map[string]interface{}{
-		// 			"user_name":    name,
-		// 			"user_mail":    email,
-		// 			"user_phone":   phone,
-		// 			"user_company": company,
-		// 		}
-		// 		if !public.Mysql.Update("jy_datareport_order", map[string]interface{}{
-		// 			"user_id":   userId,
-		// 			"report_id": reportId,
-		// 		}, updateValue) {
-		// 			return "", errors.New(fmt.Sprintf("更新基本信息出错:%+v", updateValue))
-		// 		}
-		// 	}
-
-		// 	//订单过期需要重新生成订单
-		// 	if util.ObjToString((*oldOrder)["pay_way"]) != pay_way || now.After(prepayTime.Add(time.Hour*2)) || orderPay == "" {
-		// 		//查询订单单价
-		// 		order_money := util.IntAll((*oldOrder)["order_money"])
-		// 		tradeno, prepayid := "", ""
-		// 		if pay_way == "wx_app" { //"wx_app" 微信支付
-		// 			var ret *map[string]string
-		// 			tradeno, ret = public.WxStruct.CreatePrepayOrder(config.Sysconfig["weixinrpc"].(string), "D", d.IP(), openId, "", order_money)
-		// 			if ret == nil || (*ret)["status"] != "1" {
-		// 				return "", errors.New("微信生成订单出错")
-		// 			}
-		// 			prepayid = util.ObjToString((*ret)["prepayid"])
-		// 			orderPay = public.WxStruct.GetAppWxPayStr(prepayid)
-		// 		} else { //"ali_app"支付宝支付
-		// 			var err error
-		// 			orderPay, tradeno, err = pay.Alipay.GetAliPayToken((util.Float64All(order_money)), "dataReport")
-		// 			if err != nil {
-		// 				return "", errors.New(fmt.Sprintf("支付宝订单生成出错:%v", err))
-		// 			}
-		// 		}
-		// 		//更新数据库订单
-		// 		updateValue := map[string]interface{}{
-		// 			"order_money":  order_money,
-		// 			"prepay_time":  util.FormatDate(&now, util.Date_Full_Layout),
-		// 			"pay_way":      pay_way,
-		// 			"prepay_id":    prepayid,
-		// 			"order_pay":    orderPay,
-		// 			"out_trade_no": tradeno,
-		// 		}
-		// 		if !public.Mysql.Update("jy_datareport_order", map[string]interface{}{
-		// 			"user_id":   userId,
-		// 			"report_id": reportId,
-		// 		}, updateValue) {
-		// 			return "", errors.New(fmt.Sprintf("更新数据库状态出错:%+v", updateValue))
-		// 		}
-		// 	}
-		// 	return orderPay, nil
-		// } else {
-		//检索订单
-		datareport := public.Mysql.FindOne("jy_datareport", map[string]interface{}{
-			"report_id": reportId,
-		}, "i_price", "")
-		if datareport == nil {
-			return "", errors.New("未知数据报告")
-		}
-		order_money := util.IntAll((*datareport)["i_price"])
-		now := time.Now()
-
-		tradeno, prepayid, orderPay := "", "", ""
-		if pay_way == "wx_app" { //"wx_app" 微信支付
-			var ret *map[string]string
-			tradeno, ret = public.WxStruct.CreatePrepayOrder(config.Sysconfig["weixinrpc"].(string), "D", d.IP(), "", "", order_money)
-			if ret == nil || (*ret)["status"] != "1" {
-				return "", errors.New("微信生成订单出错")
-			}
-			prepayid = util.ObjToString((*ret)["prepayid"])
-			orderPay = public.WxStruct.GetAppWxPayStr(prepayid)
-		} else { //"ali_app"支付宝支付
-			var err error
-			orderPay, tradeno, err = pay.Alipay.GetAliPayToken((util.Float64All(order_money)), "dataReport")
-			if err != nil {
-				return "", errors.New(fmt.Sprintf("支付宝订单生成出错:%v", err))
-			}
-		}
-		insertValue := map[string]interface{}{
-			"order_money":    order_money,
-			"order_status":   0,
-			"service_status": 0,
-			"user_name":      name,
-			"prepay_id":      prepayid,
-			"order_pay":      orderPay,
-			"out_trade_no":   tradeno,
-			"report_id":      reportId,
-			"product_type":   "数据报告",
-			"create_time":    util.FormatDate(&now, util.Date_Full_Layout),
-			"prepay_time":    util.FormatDate(&now, util.Date_Full_Layout),
-			"user_mail":      email,
-			"user_phone":     phone,
-			"pay_way":        pay_way,
-			"user_id":        userId,
-			"user_company":   company,
-		}
-		if payOrderId = public.Mysql.Insert("jy_datareport_order", insertValue); payOrderId == 0 {
-			return "", errors.New(fmt.Sprintf("插入数据库出错:%+v", insertValue))
-		}
-		return orderPay, nil
-		//}
-	}()
-	errMsgStr := ""
-	if errMsg != nil {
-		log.Printf("%s CreateOlder 生成支付出错:%s", userId, errMsg.Error())
-		errMsgStr = strings.Split(errMsg.Error(), ":")[0]
-	}
-	d.ServeJson(map[string]interface{}{
-		"success":    util.If(errMsg == nil, true, false).(bool),
-		"payStr":     payStr,
-		"showErr":    errMsgStr,
-		"payOrderId": payOrderId,
-	})
-}
-
-//查询是否支付完成
-func (d *DataReport) IsPaySuccess() {
-	userId := util.ObjToString(d.GetSession("userId"))
-	payOrderId := d.GetString("payOrderId")
-	success := false
-	orderdata := public.Mysql.FindOne("jy_datareport_order", map[string]interface{}{
-		"user_id": userId,
-		"id":      payOrderId,
-	}, "order_status", "")
-	if orderdata != nil && util.IntAll((*orderdata)["order_status"]) == 1 {
-		success = true
-	}
-	d.ServeJson(map[string]interface{}{
-		"success": success,
-	})
-}
-
-//openid 微信支付不为空
-func DataReportCalBakAfter(order_money, cash_fee int, out_trade_no, transaction_id, time_end, openid string) bool {
-	orderdata := public.Mysql.FindOne("jy_datareport_order", map[string]interface{}{
-		"out_trade_no": out_trade_no,
-		"order_money":  order_money,
-	}, "order_status,report_id,user_mail", "")
-
-	now := time.Now()
-	if orderdata != nil {
-		pay_way := "wx_app"
-		if openid == "" {
-			pay_way = "ali_app"
-		}
-		order_status := util.IntAll((*orderdata)["order_status"])
-		if order_status == 0 {
-			updateStatus := public.Mysql.Update("jy_datareport_order", map[string]interface{}{
-				"out_trade_no": out_trade_no,
-				"order_money":  order_money,
-			}, map[string]interface{}{
-				"pay_money":    cash_fee,
-				"pay_time":     util.FormatDate(&now, util.Date_Full_Layout),
-				"order_status": 1,
-				"pay_way":      pay_way,
-			})
-			if updateStatus {
-				//发送数据
-				log.Println("========数据报告支付完成=====")
-				go public.SendDatareportMailToPayUser(util.IntAll((*orderdata)["report_id"]), out_trade_no, util.ObjToString((*orderdata)["user_mail"]), config.GmailAuth)
-
-			}
-		}
-	} else {
-		log.Printf("DataReportCalBakAfter未找到订单 %s %d \n", out_trade_no, order_money)
-	}
-
-	pay_count := public.Mysql.Count("weixin_pay", map[string]interface{}{
-		"transaction_id": transaction_id,
-		"out_trade_no":   out_trade_no,
-		"user_openid":    openid,
-	})
-	if pay_count == 0 {
-		newPayData := map[string]interface{}{
-			"transaction_id": transaction_id,
-			"out_trade_no":   out_trade_no,
-			"create_time":    util.FormatDate(&now, util.Date_Full_Layout),
-			"total_fee":      order_money,
-			"cash_fee":       cash_fee,
-			"time_end":       time_end,
-		}
-		if openid == "" {
-			if public.Mysql.Insert("ali_pay", newPayData) == 0 {
-				log.Printf("支付数据插入失败%+v\n", newPayData)
-			}
-		} else {
-			newPayData["user_openid"] = openid
-			if public.Mysql.Insert("weixin_pay", newPayData) == 0 {
-				log.Printf("支付数据插入失败%+v\n", newPayData)
-				return false
-			}
-		}
-	} else {
-		log.Printf("支付数据已存在%s %s %s", transaction_id, out_trade_no, openid)
-	}
-	return true
-}
-
 func checkUserName(value string) bool {
 	if value == "" {
 		return false

+ 1 - 45
src/jfw/modules/app/src/app/front/myorder.go

@@ -2,13 +2,12 @@ package front
 
 import (
 	"encoding/json"
-	"jfw/config"
+
 	"jfw/public"
 	"log"
 	"qfw/util"
 	"strconv"
 	"strings"
-	"time"
 
 	"github.com/go-xweb/xweb"
 )
@@ -20,7 +19,6 @@ type MyOrder struct {
 	myOrderPaging xweb.Mapper `xweb:"/jyapp/front/myOrder/queryMyOrder/myOrderPaging"` //查询订单--分页
 	toOrderDetail xweb.Mapper `xweb:"/jyapp/front/myOrder/toOrderDetail"`              //订单详情
 	getOrderCode  xweb.Mapper `xweb:"/jyapp/front/myOrder/getOrderCode/(\\w+)"`        //申请发票获取订单编号
-	applyInvoice  xweb.Mapper `xweb:"/jyapp/front/myOrder/applyInvoice"`               //申请发票
 	paySuccess    xweb.Mapper `xweb:"/jyapp/front/myorder/paySuccess/(\\w+)"`          //支付成功发票
 	deleteOrder   xweb.Mapper `xweb:"/jyapp/front/myorder/deleteOrder"`                //删除订单
 	getOneMore    xweb.Mapper `xweb:"/jyapp/front/myorder/getOneMore"`                 //获取额外一条数据
@@ -375,48 +373,6 @@ func (m *MyOrder) GetOrderCode(order_code string) error {
 	return nil
 }
 
-func (m *MyOrder) ApplyInvoice() error {
-	var applyBill_status int
-	var order_code, applyBill_company, applyBill_taxnum, applyBill_type string
-	var updateBl bool = false
-	order_code = m.GetString("order_code")
-	//获取数据
-	applyBill_type = m.GetString("demo-radio") //个人 单位
-	queryMap := map[string]interface{}{
-		"order_code": order_code,
-	}
-	if applyBill_type == "个人" {
-		applyBill_status = 1
-		updateBl = public.Mysql.Update(tableName_order, queryMap, map[string]interface{}{"applyBill_status": applyBill_status})
-
-	} else if applyBill_type == "单位" {
-		applyBill_status = 1                                 //状态
-		applyBill_company = m.GetString("applyBill_company") //公司名
-		applyBill_taxnum = m.GetString("applyBill_taxnum")   //纳税人识别号
-		updateBl = public.Mysql.Update(tableName_order, queryMap, map[string]interface{}{
-			"applyBill_company": applyBill_company,
-			"applyBill_taxnum":  applyBill_taxnum,
-			"applyBill_status":  applyBill_status,
-			"applyBill_type":    1,
-		}) //修改操作
-	}
-	//判断条件
-	if updateBl {
-		go func() {
-			orderdata := public.Mysql.FindOne(tableName_order, map[string]interface{}{
-				"order_code": order_code,
-			}, "id,filter,user_mail,user_phone,product_type,data_spec,filter_id,order_code,data_count,order_status,order_money,out_trade_no,applybill_type,applybill_company,applybill_taxnum,user_openid,create_time,pay_time,pay_way", "")
-			tt := time.Now()
-			pay_time := util.FormatDate(&tt, util.Date_Full_Layout)
-			public.SendMailToBJFinance(orderdata, pay_time, "", 2, config.GmailAuth)
-		}()
-	}
-	m.ServeJson(map[string]interface{}{
-		"flag": updateBl,
-	})
-	return nil
-}
-
 func (m *MyOrder) PaySuccess(order_code string) error {
 	userId := m.Session().Get("userId")
 	if userId == nil || userId == "" {

+ 0 - 77
src/jfw/modules/app/src/app/front/paycallbak.go

@@ -1,77 +0,0 @@
-package front
-
-import (
-	"app/pay"
-	"fmt"
-	"jfw/public"
-	"log"
-	"net/url"
-	"qfw/util"
-
-	"github.com/go-xweb/xweb"
-)
-
-//微信支付宝回调
-
-type PayCallBackAction struct {
-	*xweb.Action
-	wxPayCallback  xweb.Mapper `xweb:"/jyapp/dataReport/wxpay/callback"`  //微信数据报告支付完成回调
-	aliPayCallback xweb.Mapper `xweb:"/jyapp/dataReport/alipay/callback"` //支付宝数据报告支付完成回调
-}
-
-func init() {
-	xweb.AddAction(&PayCallBackAction{})
-}
-
-//微信支付完成回调
-func (d *PayCallBackAction) WxPayCallback() {
-	defer util.Catch()
-	by := d.Body()
-	fmt.Println("数据报告-回调通知参数", string(by))
-	ret := util.XmlToMap(string(by))
-	if ret["return_code"] == "SUCCESS" && ret["appid"] == public.WxStruct.Appid && ret["mch_id"] == public.WxStruct.Mchid {
-		order_money := util.IntAll(ret["total_fee"])
-		out_trade_no := ret["out_trade_no"]
-		transaction_id := ret["transaction_id"]
-		openid := ret["openid"]
-		cash_fee := util.IntAll(ret["cash_fee"])
-		time_end := ret["time_end"]
-		if DataReportCalBakAfter(order_money, cash_fee, out_trade_no, transaction_id, time_end, openid) {
-			d.Write(`<xml>
-			  	<return_code><![CDATA[SUCCESS]]></return_code>
-			  	<return_msg><![CDATA[OK]]></return_msg>
-			</xml>`)
-		} else {
-			d.Write(`<xml>
-				<return_code><![CDATA[FAIL]]></return_code>
-				<return_msg><![CDATA[ERROR]]></return_msg>
-			</xml>`)
-		}
-	}
-}
-
-//支付宝支付完成回调
-func (a *PayCallBackAction) AliPayCallback() {
-	checkSign := a.GetForm()
-	sign := checkSign.Get("sign") //待验证签名
-	checkSign.Del("sign")
-	checkSign.Del("sign_type")
-	signContentBytes, _ := url.QueryUnescape(checkSign.Encode())
-	if !pay.Alipay.CheckCallBackSign(signContentBytes, sign) { //验签
-		log.Printf("支付宝签名验证失败 %+v\n", checkSign)
-		return
-	}
-	//校验
-	if checkSign.Get("app_id") != util.ObjToString(pay.AlipayConf["appid"]) {
-		log.Println("支付宝Appid校验出错", checkSign.Get("app_id"))
-		return
-	}
-	out_trade_no := checkSign.Get("out_trade_no")
-	trade_no := checkSign.Get("trade_no")                                                 //支付宝交易号
-	receipt_amount := util.IntAll(util.Float64All(checkSign.Get("receipt_amount")) * 100) //实收金额
-	total_amount := util.IntAll(util.Float64All(checkSign.Get("total_amount")) * 100)     //订单金额
-	//seller_id := checkSign.Get("seller_id")                        //卖家支付宝号
-	gmt_payment := checkSign.Get("gmt_payment") //付款时间
-
-	DataReportCalBakAfter(total_amount, receipt_amount, out_trade_no, trade_no, gmt_payment, "")
-}

+ 0 - 183
src/jfw/modules/app/src/app/pay/alipay.go

@@ -1,183 +0,0 @@
-package pay
-
-import (
-	"crypto"
-	"crypto/rand"
-	"crypto/rsa"
-	"crypto/sha256"
-	"crypto/x509"
-	"encoding/base64"
-	"encoding/json"
-	"encoding/pem"
-	"errors"
-	"fmt"
-	"hash"
-
-	"jfw/config"
-	"log"
-	"net/url"
-	"qfw/util"
-	"strings"
-	"time"
-)
-
-type AliPayStruct struct {
-	Appid        string
-	PrivateKey   *rsa.PrivateKey //请求接口秘钥
-	AliPublicKey *rsa.PublicKey  //支付完成回调,校验使用(取支付宝后台)
-	CallBackUrl  string          //支付完成回调地址
-	Subject      string          //支付小标题
-}
-
-//支付订单生成请求参数(App支付)
-type BizContent struct {
-	Subject        string  `json:"subject"`
-	OutTradeNo     string  `json:"out_trade_no"`
-	TotalAmount    float64 `json:"total_amount"`
-	ProductCode    string  `json:"product_code"`
-	TimeoutExpress string  `json:"timeout_express"`
-}
-
-//支付订单关闭请求参数
-type CloseContent struct {
-	OutTradeNo string `json:"out_trade_no"`
-}
-
-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"]) + "/jyapp/%s/alipay/callback",
-		Subject:      util.ObjToString(AlipayConf["Subject"]),
-	}
-}
-
-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) GetAliPayToken(order_money float64, flag string) (string, string, error) {
-	tradeno := a.GetTradeno()
-	bizContent := BizContent{
-		Subject:        a.Subject,
-		OutTradeNo:     tradeno,
-		TotalAmount:    order_money / 100,
-		ProductCode:    "QUICK_MSECURITY_PAY",
-		TimeoutExpress: "2h",
-	}
-	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.app.pay")
-	if a.CallBackUrl != "" {
-		backUrl := fmt.Sprintf(a.CallBackUrl, flag)
-		data.Add("notify_url", backUrl) //支付完成回调地址
-	}
-	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 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
-}

+ 0 - 462
src/jfw/modules/app/src/app/pay/dataexport_pay.go

@@ -1,462 +0,0 @@
-package pay
-
-import (
-	"bytes"
-	"encoding/json"
-	"fmt"
-	"net/url"
-
-	"jfw/config"
-	"jfw/public"
-	"log"
-	"qfw/util"
-	"time"
-
-	"github.com/go-xweb/xweb"
-)
-
-func init() {
-	xweb.AddAction(&AppDataExportPay{})
-	WeixinConfig := config.Sysconfig["wxJianyu"].(map[string]interface{})
-	payConfig := WeixinConfig["pay"].(map[string]interface{})
-	public.WxStruct = &public.WeixinStruct{
-		Appid:             util.ObjToString(WeixinConfig["appid"]),
-		Mchid:             util.ObjToString(payConfig["mchid"]),
-		Key:               util.ObjToString(payConfig["key"]),
-		Dashang_attachmsg: util.ObjToString(payConfig["attachmsg"]),
-		Dashang_bodymsg:   util.ObjToString(payConfig["bodymsg"]),
-		Dashang_detailmsg: util.ObjToString(payConfig["detailmsg"]),
-		Sjdc_attachmsg:    util.ObjToString(payConfig["sjdc_attachmsg"]),
-		Sjdc_bodymsg:      util.ObjToString(payConfig["sjdc_bodymsg"]),
-		Sjdc_detailmsg:    util.ObjToString(payConfig["sjdc_detailmsg"]),
-		Subvip_msg:        util.ObjToString(payConfig["subvip_msg"]),
-	}
-}
-
-type AppDataExportPay struct {
-	*xweb.Action
-	isPaySuccess   xweb.Mapper `xweb:"/jyapp/dataExport/pay/isPaySuccess"` //查询是否支付成功
-	createOrder    xweb.Mapper `xweb:"/jyapp/dataExport/pay/createOrder"`  //创建订单——支付
-	wxPayCallback  xweb.Mapper `xweb:"/jyapp/dataExport/wxpay/callback"`   //微信支付完成回调
-	aliPayCallback xweb.Mapper `xweb:"/jyapp/dataExport/alipay/callback"`  //支付宝支付完成回调
-}
-
-func (p *AppDataExportPay) IsPaySuccess() {
-	defer util.Catch()
-	code := p.GetString("code")
-	userId, _ := p.GetSession("userId").(string)
-	if code != "" || userId != "" {
-		data := public.Mysql.FindOne("dataexport_order", map[string]interface{}{
-			"order_code": code,
-			"user_id":    userId,
-		}, "order_status,pay_time,user_mail,pay_way", "")
-		if data != nil && util.IntAll((*data)["order_status"]) == 1 {
-			t, _ := time.ParseInLocation(util.Date_Full_Layout, util.ObjToString((*data)["pay_time"]), time.Local)
-			pay_way := "微信"
-			if util.ObjToString((*data)["pay_way"]) == "ali_app" {
-				pay_way = "支付宝"
-			}
-			p.ServeJson(map[string]interface{}{
-				"success":   true,
-				"email":     util.ObjToString((*data)["user_mail"]),
-				"payTime":   t.Unix(),
-				"pay_way":   pay_way,
-				"orderCode": code,
-			})
-		}
-	}
-	p.ServeJson(map[string]interface{}{
-		"success": false,
-	})
-}
-
-func (p *AppDataExportPay) CreateOrder() {
-	defer util.Catch()
-	userId, _ := p.GetSession("userId").(string)
-	openId, _ := p.GetSession("s_m_openid").(string)
-	pay_way := p.GetString("pay_way")
-
-	payStr, ordercode, errMsg, ok := func() (string, string, string, bool) {
-		id := util.SE.Decode4Hex(p.GetString("id"))
-		if userId == "" || id == "" || !(pay_way == "wx_app" || pay_way == "ali_app") {
-			return "", "", fmt.Sprintf("请求出错 id:%s,pay_way:%s \n", id, pay_way), false
-		}
-		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")) != ""
-		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,pay_way,code_url,user_openid", "")
-
-		//非新订单
-		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 {
-				return "", "", fmt.Sprintf("该订单已存在,订单状态不允许支付!"), false
-			}
-			//订单未超时两小时内 订单未改变
-			local, _ := time.LoadLocation("Local")
-			prepayTime, _ := time.ParseInLocation(util.Date_Full_Layout, util.ObjToString((*oldOrder)["prepay_time"]), local)
-			now := time.Now()
-			if data_spec != "" && data_spec == util.ObjToString((*oldOrder)["data_spec"]) && util.ObjToString((*oldOrder)["pay_way"]) == pay_way && now.Before(prepayTime.Add(time.Hour*2)) {
-				log.Println("支付取数据库")
-				return util.ObjToString((*oldOrder)["code_url"]), util.ObjToString((*oldOrder)["order_code"]), "", true
-			} else {
-				//价格变动需重新生预支付订单 更新原来得库的信息
-				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)
-				payStr, tradeno, prepayid := "", "", ""
-				if pay_way == "wx_app" {
-					var ret *map[string]string
-					tradeno, ret = public.WxStruct.CreatePrepayOrder(config.Sysconfig["weixinrpc"].(string), "C", p.IP(), "", "", order_money)
-					if ret == nil || (*ret)["status"] != "1" {
-						return "", "", fmt.Sprintf("%s生成订单出错", pay_way), false
-					}
-					prepayid = util.ObjToString((*ret)["prepayid"])
-					payStr = public.WxStruct.GetAppWxPayStr(prepayid)
-					if payStr == "" {
-						return "", "", fmt.Sprintf("%s生成签名出错出错", pay_way), false
-					}
-				} else if pay_way == "ali_app" {
-					var err error
-					payStr, tradeno, err = Alipay.GetAliPayToken((util.Float64All(order_money)), "dataExport")
-					if err != nil {
-						return "", "", fmt.Sprintf("支付宝订单生成出错%v"), false
-					}
-				}
-
-				//更新数据库
-				if public.Mysql.Update("dataexport_order", map[string]interface{}{
-					"user_id":   userId,
-					"filter_id": id,
-				}, map[string]interface{}{
-					"data_spec":      data_spec,
-					"order_money":    order_money,
-					"original_price": original_price,
-					"prepay_time":    util.FormatDate(&now, util.Date_Full_Layout),
-					"pay_way":        pay_way,
-					"prepay_id":      prepayid,
-					"code_url":       payStr,
-					"out_trade_no":   tradeno,
-				}) {
-					//(*oldOrder)["order_money"] = order_money
-					return payStr, util.ObjToString((*oldOrder)["order_code"]), "", true
-				} else {
-					return "", "", fmt.Sprintf("更新数据库状态出错"), false
-				}
-			}
-		}
-
-		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)
-
-		filter_keys, filter_publishtime, filter := "", "", ""
-
-		isPass := func() bool {
-			if 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
-		}()
-
-		if !isPass {
-			return "", "", "创建新订单参数异常", false
-		}
-
-		prepayid, payStr, tradeno := "", "", ""
-		if pay_way == "wx_app" {
-			var ret *map[string]string
-			tradeno, ret = public.WxStruct.CreatePrepayOrder(config.Sysconfig["weixinrpc"].(string), "C", p.IP(), "", "", order_money)
-			if ret == nil || (*ret)["status"] != "1" {
-				return "", "", fmt.Sprintf("%s创建订单出错", pay_way), false
-			}
-			prepayid = util.ObjToString((*ret)["prepayid"])
-			payStr = public.WxStruct.GetAppWxPayStr(util.ObjToString((*ret)["prepayid"]))
-			if payStr == "" {
-				return "", "", fmt.Sprintf("%s创建订单生成签名出错", pay_way), false
-			}
-		} else if pay_way == "ali_app" {
-			var err error
-			payStr, tradeno, err = Alipay.GetAliPayToken((util.Float64All(order_money)), "dataExport")
-			if err != nil {
-				return "", "", fmt.Sprintf("支付宝订单生成出错%v"), false
-			}
-		}
-		nickname, _ := p.GetSession("s_nickname").(string)
-		now := time.Now()
-		code := public.GetOrderCode(userId)
-		orderid := public.Mysql.Insert("dataexport_order", map[string]interface{}{
-			"order_money":        order_money,
-			"order_status":       0,
-			"service_status":     0,
-			"user_nickname":      nickname,
-			"filter":             filter,
-			"prepay_id":          prepayid,
-			"code_url":           payStr,
-			"out_trade_no":       tradeno,
-			"order_code":         code,
-			"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
-			"user_openid":        openId,
-		})
-		if orderid == 0 {
-			return "", "", fmt.Sprintf("数据插入出错"), false
-		}
-		return payStr, code, "", true
-	}()
-	if errMsg != "" {
-		log.Println(userId, errMsg)
-	}
-	p.ServeJson(map[string]interface{}{
-		"success": ok,
-		"data":    payStr,
-		"order":   ordercode,
-	})
-}
-
-//微信支付成功后回调
-func (p *AppDataExportPay) WxPayCallback() {
-	defer util.Catch()
-	by := p.Body()
-	fmt.Println("回调通知参数", string(by))
-	ret := util.XmlToMap(string(by))
-	flag := false
-	if ret["return_code"] == "SUCCESS" && ret["appid"] == public.WxStruct.Appid && ret["mch_id"] == public.WxStruct.Mchid {
-		if ret["sign"] == util.CreateWxSign(fmt.Sprintf("&key=%s", public.WxStruct.Key), ret) {
-			now := time.Now()
-			changeOrderStatus, insertAliPay := false, false
-			orderdata := public.Mysql.FindOne("dataexport_order", map[string]interface{}{
-				"out_trade_no": ret["out_trade_no"],
-				"order_money":  util.IntAll(ret["total_fee"]),
-			}, "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_way", "")
-			order_money := util.IntAll(ret["total_fee"])
-			pay_time := util.FormatDate(&now, util.Date_Full_Layout)
-			if orderdata != nil {
-				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("/jyapp/res/dataexport/%s", filename)
-				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": ret["out_trade_no"],
-						"order_money":  order_money,
-					}, map[string]interface{}{
-						"pay_money":    util.IntAll(ret["cash_fee"]),
-						"pay_time":     pay_time,
-						"order_status": 1,
-						"download_url": download_url,
-					})
-					if changeOrderStatus {
-						//先发个通知
-						ordermoney := float64(order_money) / 100
-						go public.SendNotice(orderdata, ordermoney, pay_time, download_url, config.GmailAuth)
-						go public.SendMailToPayUser(orderdata, ordermoney, pay_time, filename, download_url, config.GmailAuth)
-						go public.SendMailToBJFinance(orderdata, pay_time, ret["transaction_id"], 1, config.GmailAuth)
-					}
-				}
-			}
-			//
-			pay_count := public.Mysql.Count("weixin_pay", map[string]interface{}{
-				"transaction_id": ret["transaction_id"],
-				"out_trade_no":   ret["out_trade_no"],
-				"user_openid":    ret["openid"],
-			})
-			if pay_count == 0 {
-				insertAliPay = public.Mysql.Insert("weixin_pay", map[string]interface{}{
-					"transaction_id": ret["transaction_id"],
-					"out_trade_no":   ret["out_trade_no"],
-					"user_openid":    ret["openid"],
-					"create_time":    util.FormatDate(&now, util.Date_Full_Layout),
-					"total_fee":      util.IntAll(ret["total_fee"]),
-					"cash_fee":       util.IntAll(ret["cash_fee"]),
-					"time_end":       ret["time_end"],
-				}) > 0
-			}
-			flag = changeOrderStatus && insertAliPay
-		} else {
-			log.Println("支付回调签名校验未通过!", ret["openid"])
-		}
-	} else {
-		log.Println("支付回调参数校验未通过!", ret["openid"])
-	}
-	if flag {
-		p.Write(`<xml>
-			  	<return_code><![CDATA[SUCCESS]]></return_code>
-			  	<return_msg><![CDATA[OK]]></return_msg>
-			</xml>`)
-	} else {
-		p.Write(`<xml>
-				<return_code><![CDATA[FAIL]]></return_code>
-				<return_msg><![CDATA[ERROR]]></return_msg>
-			</xml>`)
-	}
-}
-
-//支付宝支付回调
-func (a *AppDataExportPay) AliPayCallback() {
-	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()
-	log.Printf("支付宝支付完成-回调  订单号%s\n", out_trade_no)
-	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_way", "")
-	changeOrderStatus, insertAliPay := false, false
-	if orderdata != nil {
-		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("/jyapp/res/dataexport/%s", filename)
-		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":      "ali_app",
-				"download_url": download_url,
-			})
-			if changeOrderStatus {
-				log.Println("pay_way----------------", (*orderdata)["pay_way"])
-				//先发个通知
-				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)
-	}
-}

+ 0 - 25
src/jfw/modules/app/src/app/pay/wxpay.go

@@ -1,25 +0,0 @@
-package pay
-
-import (
-	"jfw/config"
-	"jfw/public"
-	"log"
-	"qfw/util"
-)
-
-func init() {
-	payConfig := config.WeixinConfig["pay"].(map[string]interface{})
-	public.WxStruct = &public.WeixinStruct{
-		Appid:             util.ObjToString(config.WeixinConfig["appid"]),
-		Mchid:             util.ObjToString(payConfig["mchid"]),
-		Key:               util.ObjToString(payConfig["key"]),
-		Dashang_attachmsg: util.ObjToString(payConfig["attachmsg"]),
-		Dashang_bodymsg:   util.ObjToString(payConfig["bodymsg"]),
-		Dashang_detailmsg: util.ObjToString(payConfig["detailmsg"]),
-		Sjdc_attachmsg:    util.ObjToString(payConfig["sjdc_attachmsg"]),
-		Sjdc_bodymsg:      util.ObjToString(payConfig["sjdc_bodymsg"]),
-		Sjdc_detailmsg:    util.ObjToString(payConfig["sjdc_detailmsg"]),
-		Sjbg_msg:          util.ObjToString(payConfig["sjbd_msg"]),
-		//Subvip_msg:        util.ObjToString(payConfig["subvip_msg"]),
-	}
-}

+ 1 - 23
src/jfw/modules/app/src/config.json

@@ -87,7 +87,7 @@
         "ios_version": "2.7.3",
         "ios_mustupdate": false,
         "ios_openUpdate": false,
-        "apkurl": "http://web-jydev-wky.jianyu360.cn/jyapp/res/%s/jianyu360.apk",
+        "apkurl": "http://web-jydev-ws.jianyu360.cn/jyapp/res/%s/jianyu360.apk",
         "channelDir":{
 			"baidu":"baiduSem",
 			"shenma":"shenmaSem",
@@ -129,28 +129,6 @@
         "grayflag": false
     },
     "afterSavePushId": 60,
-    "aliPay": {
-        "appid": "2019062465625929",
-        "reqUrl": "https://openapi.alipay.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": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqFZfev75+sa7O0f29qwuWeqWRQ+p59c8hz2s4aeh5Ohc08P1ls5e8UmPhaN9ZTkGwabOKN658pOhmVoa16ldKFZQ5j1hLTDS6yfKcvVs/hf1mQvsbUjtZgCfMQx5NNf1R4MsTvAqbl2l6DXMu7gHjAhKNR0QQBELv7HmYuWPE35ELQqBH0eVcvWSNV3/3zOansftY5NIT749B+Bv1uirE8PNMp20sWWqx8fMNi2EZksnWNUmnVldBqUwMJIxcXolBH/RGX5ZjBlBenoIB3PVQ8/+SPz9Hip7+QNH8utSnUlrh2AsJVtdNKIQk74Eevkn+Q+WyUVGoY0ca9DzGwh4hQIDAQAB"
-    },
-    "wxJianyu": {
-        "appid": "wx0e6a5b18f4cfd10d",
-        "appsecret": "bf12200554cb6edeb2be69d49dc11a3e",
-        "pay": {
-            "mchid": "1418321102",
-            "key": "topnet2016topnet2016topnet2016ab",
-            "attachmsg": "剑鱼标讯打赏",
-            "bodymsg": "剑鱼标讯-招标信息打赏",
-            "detailmsg": "招标推送信息[%s] 打赏%s元钱",
-            "sjdc_attachmsg": "剑鱼标讯-历史数据",
-            "sjdc_bodymsg": "剑鱼标讯-历史数据",
-            "sjdc_detailmsg": "剑鱼标讯-历史数据",
-            "sjbd_msg": "剑鱼标讯-数据报告"
-        }
-    },
     "mail": [
         {
             "addr": "smtp.exmail.qq.com",

文件差异内容过多而无法显示
+ 0 - 115
src/jfw/modules/app/src/dataexport.json


+ 2 - 1
src/jfw/modules/app/src/main.go

@@ -7,7 +7,8 @@ import (
 	_ "app/filter"
 	_ "app/followent"
 	_ "app/front"
-	_ "app/pay"
+
+	//_ "app/pay"
 	"app/tag"
 	. "jfw/config"
 	"jfw/public"

+ 4 - 4
src/jfw/modules/app/src/web/templates/dataExport/dataExport_payOrder.html

@@ -762,7 +762,7 @@
 					param.sourcePage = "weixin"
 					//先去创建预支付订单
 					/*-----------------*/
-					$.post("/jyapp/dataExport/pay/createOrder", param, function(data) {
+					$.post("/jypay/dataExport/app/createOrder", param, function(data) {
 						if (data.success) {
 							localStorage.setItem("new_email_"+userId, $(".email_input").val().replace(/\s*/g,""));
 							try {
@@ -789,13 +789,13 @@
             clearInterval(interval);
           }
          interval=setInterval(function() {
-            $.post("/jyapp/dataExport/pay/isPaySuccess", {
+            $.post("/jypay/isPaySuccess", {
 							code: orderCode
 						}, function(r) {
 								if (r.success) {
 						            //清除我已阅读缓存
-							        sessionStorage.removeItem("readClause");
-								    sessionStorage.removeItem("index");
+							    sessionStorage.removeItem("readClause");
+								  sessionStorage.removeItem("index");
 									sessionStorage.removeItem("pay_way");
 									sessionStorage.removeItem("EmailVerity_"+{{.T._id}});
 									sessionStorage.removeItem("ischecked");

+ 2 - 2
src/jfw/modules/app/src/web/templates/dataExport/dataExport_toMyOrder.html

@@ -780,7 +780,7 @@
 					param.id = $(".param_id").text();
 					param.sourcePage = "weixin"
 					//先去创建预支付订单
-					$.post("/jyapp/dataExport/pay/createOrder", param, function(data) {
+					$.post("/jypay/dataExport/app/createOrder", param, function(data) {
 						if (data.success){
 							try {
 								console.log(typ)
@@ -809,7 +809,7 @@
 		          }
 		         $(".loading_").show();
 		         interval=setInterval(function() {
-		            $.post("/jyapp/dataExport/pay/isPaySuccess", {
+		            $.post("/jypay/isPaySuccess", {
 									code: orderCode
 								}, function(r) {
 									if (r.success) {

+ 2 - 2
src/jfw/modules/app/src/web/templates/dataExport/dataExport_toOrderDetail.html

@@ -436,7 +436,7 @@
 					param.id = $(".param_id").text();
 					param.sourcePage = "weixin"
 					//先去创建预支付订单
-					$.post("/jyapp/dataExport/pay/createOrder", param, function(data) {
+					$.post("/jypay/dataExport/app/createOrder", param, function(data) {
 						if (data.success){
 							try {
 				                if(pay_way=="wx_app"){
@@ -462,7 +462,7 @@
 		            	clearInterval(interval);
 	        		}
 		        	interval=setInterval(function() {
-		            	$.post("/jyapp/dataExport/pay/isPaySuccess", {
+		            	$.post("/jypay/isPaySuccess", {
 									code: orderCode
 								}, function(r) {
 									if (r.success) {

+ 2 - 2
src/jfw/modules/app/src/web/templates/datareport/dataReport_info.html

@@ -198,7 +198,7 @@
                     canpay=true
                   },1000)
                   canpay=false
-                  $.post("/jyapp/dataReport/toAppPay", {
+                  $.post("/jypay/dataReport/getPayParam", {
                       "s_name": s_name,
                       "s_phone": s_phone,
                       "s_email": s_email,
@@ -235,7 +235,7 @@
                   clearInterval(interval);
                 }
                 interval=setInterval(function() {
-                  $.post("/jyapp/dataReport/isPaySuccess",{payOrderId:orderid},function(r){
+                  $.post("/jypay/dataReport/paySuccess",{payOrderId:orderid},function(r){
                     if(r.success){
                       location.replace("/jyapp/dataReport/paySuccess?email="+s_email); 
                     }

+ 6 - 0
src/jfw/modules/app/src/web/templates/weixin/search/mainSearch.html

@@ -212,6 +212,12 @@
 					<div>导出任意条件的招标数据,按条数付费</div>
 				</a>
 			</li>
+      <li class="dataExport">
+				<a href="/jyapp/dataReport/toPayPage/1">
+					<div>历史数据导出</div>
+					<div>导出任意条件的招标数据,按条数付费</div>
+				</a>
+			</li>
 			{{if .T.pullnew}}
 			<li>
 				<a>

二进制
src/jfw/modules/followent/src/src.exe~


+ 17 - 7
src/jfw/modules/subscribepay/src/a/init.go

@@ -12,7 +12,7 @@ func init() {
 	//开启redissession
 	httpsession.IsRedisSessionStore = true
 	xweb.Config.Profiler = true
-	xweb.RootApp().BasePath = "/subscribepay"
+	//xweb.RootApp().BasePath = "/subscribepay"
 	xweb.RootApp().AppConfig.StaticFileVersion = false
 	xweb.RootApp().AppConfig.CheckXsrf = false
 	xweb.RootApp().AppConfig.EnableHttpCache = false
@@ -21,11 +21,21 @@ func init() {
 	xweb.RootApp().AppConfig.SessionTimeout = 30 * time.Minute
 	xweb.RootApp().Logger.SetOutputLevel(1) //输出日志,改为4则不输出任何日志
 	//
-	xweb.AddAction(&service.Test{})
-	xweb.AddAction(&service.AfterPay{})
-	xweb.AddAction(&service.Trial{})
-	xweb.AddAction(&service.Order{})
-	xweb.AddAction(&service.EditSub{})
-	xweb.AddAction(&service.OrderListDetails{})
+	xweb.AddRouter("/subscribepay",&service.AfterPay{})
+	xweb.AddRouter("/subscribepay",&service.Trial{})
+	xweb.AddRouter("/subscribepay",&service.Order{})
+	xweb.AddRouter("/subscribepay",&service.EditSub{})
+	//xweb.AddRouter("/subscribepay",&service.OrderListDetails{})
+
+	//数据导出
+	xweb.AddRouter("/jypay",&service.DataExportPayMobile{})
+	xweb.AddRouter("/jypay",&service.DataExportPayPC{})
+	xweb.AddRouter("/jypay",&service.RewardPayAction{})
+	//数据报告
+	xweb.AddRouter("/jypay",&service.DataReport{})
+	//支付回调
+	xweb.AddRouter("/jypay",&service.PayCallBackAction{})
+	//支付成功&申请等
+	xweb.AddRouter("/jypay",&service.CommonAction{})
 
 }

+ 4 - 21
src/jfw/modules/subscribepay/src/config.json

@@ -2,7 +2,9 @@
 	"mongodbServers": "192.168.3.11:27080",
     "mongodbPoolSize": 25,
     "mongodbName": "qfw",
-    "redisaddrs": "other=192.168.3.128:1712,session=192.168.3.128:1712",
+    "redisaddrs": "other=192.168.3.128:1712,session=192.168.3.128:1712,push=192.168.3.128:1712",
+    "elasticsearch": "http://192.168.3.11:9800",
+    "elasticPoolSize": 30,
     "webport": "86",
     "weixinrpc": "127.0.0.1:8083",
     "cassandra": {
@@ -27,26 +29,7 @@
         "passWord": "Topnet123"
     },
 	"appPushServiceRpc": "127.0.0.1:5566",
-    "wxJianyu": {
-       "appid": "wxd66e9589c9fecff6",
-       "appsecret": "4d9d4b9ddab59e65fcb7bed125fbd342",
-       "pay": {
-           "mchid": "1418321102",
-           "key": "topnet2016topnet2016topnet2016ab",
-           "attachmsg": "剑鱼标讯打赏",
-           "bodymsg": "剑鱼标讯-招标信息打赏",
-           "detailmsg": "招标推送信息[%s] 打赏%s元钱",
-           "sjdc_attachmsg": "剑鱼标讯-历史数据",
-           "sjdc_bodymsg": "剑鱼标讯-历史数据",
-           "sjdc_detailmsg": "剑鱼标讯-历史数据",
-           "sjbd_msg": "剑鱼标讯-数据报告",
-           "subvip_msg":"剑鱼标讯-vip订阅"
-       },
-       "openidSwitch": {
-           "oIMvJvrVXG89597EFmYiSiznbyyY": "oHwE_wEQlEBvjZJOyZeNnQcgKQMo",
-           "ouCYjw4BJMbpdMRYrTTLb9nFi2RE": "oHwE_wNA1V0DURDO0h7wAriz0qIY"
-       }
-   },
+    "webdomain": "http://web-jydev-ws.jianyu360.cn",
     "mail": [
         {
             "addr": "smtp.exmail.qq.com",

+ 38 - 25
src/jfw/modules/subscribepay/src/config/config.go

@@ -1,7 +1,7 @@
 package config
 
 import (
-	"qfw/util"
+	qutil "qfw/util"
 	"qfw/util/mail"
 )
 
@@ -10,6 +10,8 @@ type config struct {
 	MongodbPoolSize int
 	MongodbName     string
 	Redisaddrs      string
+	Elasticsearch string
+	ElasticPoolSize int
 	Webport         string
 	Weixinrpc       string
 	Cassandra       struct {
@@ -24,38 +26,49 @@ type config struct {
 		PassWord string
 	}
 	AppPushServiceRpc string
+	WebDomain string
+	Mail []struct{
+		Addr string
+		Port int
+		Pwd string
+		User string
+	}
 }
 
 var Config *config
-
-//seo.josn 配置文件中的版本号,可以动态更新
-var Seoconfig_Version string
-
-var Sysconfig map[string]interface{}
-var Seoconfig map[string]interface{}
-var WeixinConfig map[string]interface{}
-var Wxoauth, Wxoauthinfo string
-
+//发送邮件邮箱
 var GmailAuth []*mail.GmailAuth
+//支付配置
+var PayConf map[string]interface{}
+var AliPayConf map[string]interface{}
+var WxPayConf map[string]interface{}
+
+var Wxoauth,Wxoauthinfo string
 
 func init() {
-	util.ReadConfig(&Config)
-
-	util.ReadConfig(&Sysconfig)
-	WeixinConfig, _ = Sysconfig["wxJianyu"].(map[string]interface{})
-	Wxoauth = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=` + util.ObjToString(WeixinConfig["appid"]) + `&redirect_uri=%s&response_type=code&scope=snsapi_base&state=%s#wechat_redirect`
-	Wxoauthinfo = `https://api.weixin.qq.com/sns/oauth2/access_token?appid=` + util.ObjToString(WeixinConfig["appid"]) + `&secret=` + util.ObjToString(WeixinConfig["appsecret"]) + `&code=%s&grant_type=authorization_code`
-	mails, _ := Sysconfig["mail"].([]interface{})
-	mailConfigArrMap := util.ObjArrToMapArr(mails)
-	for _, v := range mailConfigArrMap {
+	//程序配置文件
+	qutil.ReadConfig(&Config)
+	for _, v := range Config.Mail {
 		mail := &mail.GmailAuth{
-			SmtpHost: v["addr"].(string),
-			SmtpPort: util.IntAll(v["port"]),
-			User:     v["user"].(string),
-			Pwd:      v["pwd"].(string),
-			//			PoolChan: nil,
-			//			PoolSize: 0,
+			SmtpHost: v.Addr,
+			SmtpPort: v.Port,
+			User:     v.User,
+			Pwd:      v.Pwd,
 		}
 		GmailAuth = append(GmailAuth, mail)
 	}
+	//支付配置文件
+	qutil.ReadConfig("./pay_config.json", &PayConf)
+	AliPayConf = PayConf["aliPay"].(map[string]interface{})
+	WxPayConf = PayConf["wxPay"].(map[string]interface{})
+	//微信
+	Wxoauth = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=` + qutil.ObjToString(WxPayConf["appid"]) + `&redirect_uri=%s&response_type=code&scope=snsapi_base&state=%s#wechat_redirect`
+	Wxoauthinfo = `https://api.weixin.qq.com/sns/oauth2/access_token?appid=` + qutil.ObjToString(WxPayConf["appid"]) + `&secret=` + qutil.ObjToString(WxPayConf["appsecret"]) + `&code=%s&grant_type=authorization_code`
+
 }
+
+
+
+
+
+

文件差异内容过多而无法显示
+ 0 - 9
src/jfw/modules/subscribepay/src/dataexport.json


+ 20 - 0
src/jfw/modules/subscribepay/src/entity/JsonRespStrust.go

@@ -0,0 +1,20 @@
+package entity
+
+
+type FuncResult struct {
+	Success bool  //是否成功
+	Err     error //错误
+	Data    map[string]interface{}
+}
+
+func (f *FuncResult) Format() *map[string]interface{} {
+	errStr := ""
+	if f.Err != nil {
+		errStr = f.Err.Error()
+	}
+	return &map[string]interface{}{
+		"success": f.Success,
+		"errMsg":  errStr,
+		"data":    f.Data,
+	}
+}

+ 696 - 0
src/jfw/modules/subscribepay/src/entity/dataExportSearch.go

@@ -0,0 +1,696 @@
+package entity
+
+import (
+	"config"
+	"encoding/json"
+	"fmt"
+	"log"
+	qutil "qfw/util"
+	"qfw/util/elastic"
+	"qfw/util/jy"
+	"qfw/util/redis"
+	"regexp"
+	"sort"
+	"strconv"
+	"strings"
+	"sync"
+	"time"
+	"util"
+)
+
+/*筛选条件--关键词*/
+type KeyWord struct {
+	Keyword  string   `json:"keyword"`  //关键词
+	Appended []string `json:"appended"` //附加词
+	Exclude  []string `json:"exclude"`  //排除词
+}
+
+/*筛选条件*/
+type SieveCondition struct {
+	Id          string    `json:"id"`
+	PublishTime string    `json:"publishtime"` //发布时间
+	Area        []string  `json:"area"`        //地区-省份
+	City        []string  `json:"city"`        //地区-城市
+	Region      []string  `json:"region"`      //地区-省份+城市
+	Industry    []string  `json:"industry"`    //行业
+	Keyword     []KeyWord `json:"keywords"`    //关键词
+	Buyer       []string  `json:"buyer"`       //招标单位(采购单位)
+	Winner      []string  `json:"winner"`      //中标单位
+	ComeInTime  int64     `json:"comeintime"`  //入库时间(秒)
+	OpenId      string    `json:"openid"`      //用户openid
+	MinPrice    string    `json:"minprice"`    //金额——最少
+	MaxPrice    string    `json:"maxprice"`    //金额——最多
+	SelectType  string    `json:"selectType"`  //筛选(正文 or 标题)
+	Subtype     string    `json:"subtype"`     //信息类型
+	Comeinfrom  string    `json:"comeinfrom"`  //查询来源
+}
+
+const (
+	INDEX          = "bidding"
+	TYPE           = "bidding"
+	bidSearch_sort = `{"publishtime":-1}`
+)
+var ClearHtml = regexp.MustCompile("<[^>]*>")
+var ClearOther = regexp.MustCompile("[\n\r\\s\u3000\u2003\u00a0]")
+var onceSearchCount = 500
+var ExportTable string = "export_search"
+var searchWaitGroup = &sync.WaitGroup{}
+var searchPool = make(chan bool, 8)
+
+//获取数据导出查询语句
+func getDataExportSql(scd *SieveCondition) string {
+	multi_match := `{"multi_match": {"query": %s,"type": "phrase", "fields": [%s]}}`
+	query := `{"query":{"bool":{"must":[%s],"should":[%s],"minimum_should_match": %d}}}`
+	query_bool_should := `{"bool":{"should":[%s],"minimum_should_match": 1}}`
+	query_bools_must := `{"bool":{"must":[{"range":{"bidamount":{%s}}}],"must_not":[{"term":{"bidamount":0}},{"term":{"budget":0}}]}},{"bool":{"must":[{"term":{"bidamount":0}},{"range":{"budget":{%s}}}]}},{"bool":{"must":[{"term":{"budget":0}},{"range":{"bidamount":{%s}}}]}}`
+	query_bool_must := `{"terms":{"%s":[%s]}}`
+	query_bool_must_and := `{"bool":{"must":[%s]%s}}`
+	gte := `"gte": %s`
+	lte := `"lte": %s`
+
+	bools := []string{}
+	musts := []string{}
+	//省份
+	areaCity := []string{}
+	if len(scd.Area) > 0 {
+		areaquery := `{"terms":{"area":[`
+		for k, v := range scd.Area {
+			if k > 0 {
+				areaquery += `,`
+			}
+			areaquery += `"` + v + `"`
+		}
+		areaquery += `]}}`
+		areaCity = append(areaCity, areaquery)
+	}
+	//城市
+	if len(scd.City) > 0 {
+		areaquery := `{"terms":{"city":[`
+		for k, v := range scd.City {
+			if k > 0 {
+				areaquery += `,`
+			}
+			areaquery += `"` + v + `"`
+		}
+		areaquery += `]}}`
+		areaCity = append(areaCity, areaquery)
+	}
+	if len(areaCity) > 0 {
+		musts = append(musts, fmt.Sprintf(query_bool_should, strings.Join(areaCity, ",")))
+	}
+	//检索日期
+	if scd.ComeInTime != 0 {
+		starttime := ""
+		now := time.Unix(scd.ComeInTime, 0)
+		endtime := fmt.Sprintf("%d", now.Unix())
+		if scd.PublishTime == "lately-7" { //最近7天
+			starttime = fmt.Sprint(time.Date(now.Year(), now.Month(), now.Day()-7, 0, 0, 0, 0, time.Local).Unix())
+		} else if scd.PublishTime == "lately-30" { //最近30天
+			starttime = fmt.Sprint(time.Date(now.Year(), now.Month(), now.Day()-30, 0, 0, 0, 0, time.Local).Unix())
+		} else if scd.PublishTime == "thisyear" { //去年
+			starttime = fmt.Sprint(time.Date(now.Year()-1, 1, 1, 0, 0, 0, 0, time.Local).Unix())
+			endtime = fmt.Sprint(time.Date(now.Year()-1, 12, 31, 23, 59, 59, 0, time.Local).Unix())
+		} else if strings.Contains(scd.PublishTime, "_") { //设置检索日期
+			starttime = strings.Split(scd.PublishTime, "_")[0]
+			etime := strings.Split(scd.PublishTime, "_")[1]
+			etTime := time.Now()
+			if etime != "" {
+				et, _ := strconv.ParseInt(etime, 0, 64)
+				etTime = time.Unix(et, 0)
+				//如果结束日期大于comeintime,则使用comeintime
+				if et < now.Unix() {
+					endtime = etime
+				}
+			}
+			endtime = fmt.Sprint(time.Date(etTime.Year(), etTime.Month(), etTime.Day()+1, 0, 0, 0, 0, time.Local).Unix())
+		}
+		timequery := `{"range":{"publishtime":{`
+		if starttime != "" {
+			timequery += `"gte":` + starttime
+		}
+		if starttime != "" && endtime != "" {
+			timequery += `,`
+		}
+		if endtime != "" {
+			timequery += `"lt":` + endtime
+		}
+		timequery += `}}}`
+		musts = append(musts, timequery)
+	}
+
+	if scd.Subtype != "" {
+		subquery := `{"terms":{"subtype":[`
+		for k, v := range strings.Split(scd.Subtype, ",") {
+			if k > 0 {
+				subquery += `,`
+			}
+			subquery += `"` + v + `"`
+		}
+		subquery += `]}}`
+		musts = append(musts, subquery)
+	}
+	if len(scd.Industry) > 0 {
+		musts = append(musts, fmt.Sprintf(query_bool_must, "s_subscopeclass", `"`+strings.Join(scd.Industry, `","`)+`"`))
+	}
+	if len(scd.Buyer) > 0 {
+		musts = append(musts, fmt.Sprintf(query_bool_must, "buyer", `"`+strings.Join(scd.Buyer, `","`)+`"`))
+	}
+	if len(scd.Winner) > 0 {
+		musts = append(musts, fmt.Sprintf(query_bool_must, "s_winner", `"`+strings.Join(scd.Winner, `","`)+`"`))
+	}
+	_minPrice := ""
+	_maxPrice := ""
+	if scd.MinPrice != "" || scd.MaxPrice != "" {
+		sq := ``
+		if scd.MinPrice != "" {
+			min, _ := strconv.ParseFloat(scd.MinPrice, 64)
+			_minPrice = fmt.Sprintf("%.0f", min*10000)
+			if _minPrice == "0" {
+				_minPrice = ""
+			}
+		}
+		if scd.MaxPrice != "" {
+			max, _ := strconv.ParseFloat(scd.MaxPrice, 64)
+			_maxPrice = fmt.Sprintf("%.0f", max*10000)
+			if _maxPrice == "0" {
+				_maxPrice = ""
+			}
+		}
+		if _minPrice != "" {
+			sq += fmt.Sprintf(gte, _minPrice)
+		}
+		if _minPrice != "" && _maxPrice != "" {
+			sq += `,`
+		}
+		if _maxPrice != "" {
+			sq += fmt.Sprintf(lte, _maxPrice)
+		}
+		query_price := fmt.Sprintf(query_bool_should, fmt.Sprintf(query_bools_must, sq, sq, sq))
+		musts = append(musts, query_price)
+	}
+	boolsNum := 0
+	//should
+	if len(scd.Keyword) > 0 {
+		boolsNum = 1
+		if scd.SelectType == "" || scd.SelectType == "all" {
+			scd.SelectType = "detail\", \"title"
+		}
+		multi_match = fmt.Sprintf(multi_match, "%s", "\""+scd.SelectType+"\"")
+
+		if scd.Comeinfrom == "supersearchPage" {
+			var keywordArr []string
+			if strings.Contains(scd.Keyword[0].Keyword, "+") {
+				keywordArr = strings.Split(scd.Keyword[0].Keyword, "+")
+			} else if strings.Contains(scd.Keyword[0].Keyword, " ") {
+				keywordArr = strings.Split(scd.Keyword[0].Keyword, " ")
+			}
+			if len(keywordArr) > 1 {
+				KeyWordSearch := KeyWord{}
+				for _, v := range keywordArr {
+					KeyWordSearch.Appended = append(KeyWordSearch.Appended, v)
+				}
+				scd.Keyword = []KeyWord{KeyWordSearch}
+			}
+		}
+
+		for _, v := range scd.Keyword {
+			shoulds := []string{}
+			must_not := []string{}
+			//附加词
+			if v.Keyword != "" {
+				shoulds = append(shoulds, fmt.Sprintf(multi_match, "\""+v.Keyword+"\""))
+			}
+
+			for _, vv := range v.Appended {
+				shoulds = append(shoulds, fmt.Sprintf(multi_match, "\""+vv+"\""))
+			}
+
+			//排除词
+			for _, vv := range v.Exclude {
+				must_not = append(must_not, fmt.Sprintf(multi_match, "\""+vv+"\""))
+			}
+
+			//添加
+			if len(shoulds) > 0 {
+				notStr := ""
+				if len(must_not) > 0 {
+					notStr = fmt.Sprintf(`,"must_not":[%s]`, strings.Join(must_not, ","))
+				}
+				bools = append(bools, fmt.Sprintf(query_bool_must_and, strings.Join(shoulds, ","), notStr))
+			}
+		}
+	}
+
+	qstr := fmt.Sprintf(query, strings.Join(musts, ","), strings.Join(bools, ","), boolsNum)
+	log.Println("------qstr", qstr)
+	return qstr
+}
+
+func getSqlObjFromId(_id string) *SieveCondition {
+	var (
+		query *map[string]interface{}
+		ok    bool
+	)
+	if query, ok = util.MQFW.FindById(ExportTable, _id, nil); !ok {
+		return nil
+	}
+	return &SieveCondition{
+		Keyword:     getKeyWordArrFromDbResult((*query)["keywords"]),
+		Industry:    getStringArrFromDbResult((*query)["industry"]),
+		MinPrice:    qutil.ObjToString((*query)["minprice"]),
+		MaxPrice:    qutil.ObjToString((*query)["maxprice"]),
+		Subtype:     qutil.ObjToString((*query)["subtype"]),
+		Area:        getStringArrFromDbResult((*query)["area"]),
+		City:        getStringArrFromDbResult((*query)["city"]),
+		SelectType:  qutil.ObjToString((*query)["selectType"]),
+		PublishTime: qutil.ObjToString((*query)["publishtime"]),
+		Buyer:       getStringArrFromDbResult((*query)["buyer"]),
+		Winner:      getStringArrFromDbResult((*query)["winner"]),
+		ComeInTime:  qutil.Int64All((*query)["comeintime"]),
+		Comeinfrom:  qutil.ObjToString((*query)["comeinfrom"]),
+	}
+}
+
+//数据导出-查询结果数量
+func GetDataExportSearchCountUseId(_id string) (count int) {
+	scd := getSqlObjFromId(_id)
+	qstr := getDataExportSql(scd)
+	if isNullSearch(scd) {
+		return ExConf.MsgMaxCount
+	}
+	count = int(elastic.Count(INDEX, TYPE, qstr))
+	//超级搜索一致的检索(防止数据导出和超级搜索数据量不一致)
+	if scd.Comeinfrom == "supersearchPage" {
+		if len(scd.Keyword) != 0 {
+			searchTextSize := 0
+			if len(scd.Keyword) > 0 {
+				searchTextSize = len([]rune(scd.Keyword[0].Keyword))
+			}
+			if searchTextSize > 3 && count < 50 {
+				var res *[]map[string]interface{}
+				if count > 0 {
+					res = doSearch(qstr, 0, count, "")
+				}
+				secondKWS := jy.HttpEs(scd.Keyword[0].Keyword, "ik_smart", config.Config.Elasticsearch)
+				scd.Keyword[0].Keyword = secondKWS
+				scd.SelectType = "title"
+				qstr = getDataExportSql(scd)
+				res2 := doSearch(qstr, 0, 100-count, "")
+				log.Println(len(*res2))
+				return len(*delRepeatMapArr(res, res2))
+			}
+			return
+		}
+	}
+	return
+}
+
+//合并map数据,去重
+func delRepeatMapArr(res *[]map[string]interface{}, res2 *[]map[string]interface{}) *[]map[string]interface{} {
+	if res != nil {
+		for _, v := range *res {
+			for n, m := range *res2 {
+				if qutil.ObjToString(v["_id"]) == qutil.ObjToString(m["_id"]) {
+					*res2 = append((*res2)[0:n], (*res2)[n+1:]...)
+					break
+				}
+			}
+		}
+		*res = append(*res, *res2...)
+	} else {
+		res = res2
+	}
+	return res
+}
+
+//查询条件是否为空
+func isNullSearch(scd *SieveCondition) (isNull bool) {
+	if scd.PublishTime == "" && len(scd.Area) == 0 && len(scd.Industry) == 0 && len(scd.Keyword) == 0 && len(scd.Buyer) == 0 && len(scd.Winner) == 0 && scd.MinPrice == "" && scd.MaxPrice == "" && scd.Subtype == "" && len(scd.City) == 0 {
+		isNull = true
+	}
+	return isNull
+}
+
+/*
+ * 数据导出 查询结果
+ * _id 数据库查询条件记录id
+ * dataType 1-普通字段 2-高级字段
+ * webdomain 三级页域名
+ * count 返回数量 (-1:预览数据查询)
+ */
+func GetDataExportSearchResultUseId(_id, dataType string, count int) (*[]map[string]interface{}, []KeyWord) {
+	defer qutil.Catch()
+	var res []map[string]interface{}
+	var kws []KeyWord
+	scd := getSqlObjFromId(_id)
+	//获取查询语句
+	qstr := getDataExportSql(scd)
+
+	kws = scd.Keyword
+	if count == -1 {
+		//数据预览数据查询
+		if scd.Comeinfrom == "supersearchPage" && len(scd.Keyword) == 0 && len(scd.Industry) == 0 {
+			//空查询
+			obj := redis.Get("other", "export_news")
+			if obj != nil {
+				res = qutil.ObjArrToMapArr(obj.([]interface{}))
+			} else {
+				res = *doSearch(qstr, 0, 500, "2")
+				if len(res) > 0 {
+					redis.Put("other", "export_news", res, 7200)
+				}
+			}
+			return &res, kws
+		} else if scd.Comeinfrom == "supersearchPage" {
+			//超级搜索非空查询
+			count = int(elastic.Count(INDEX, TYPE, qstr))
+			searchTextSize := 0
+			if len(scd.Keyword) > 0 {
+				searchTextSize = len([]rune(scd.Keyword[0].Keyword))
+			}
+			if searchTextSize > 3 && count < 50 {
+				var res *[]map[string]interface{}
+				if count > 0 {
+					res = doSearch(qstr, 0, count, "")
+				}
+				secondKWS := jy.HttpEs(scd.Keyword[0].Keyword, "ik_smart", config.Config.Elasticsearch)
+				scd.Keyword[0].Keyword = secondKWS
+				scd.SelectType = "title"
+				qstr = getDataExportSql(scd)
+				res2 := doSearch(qstr, 0, 100-count, "")
+				return delRepeatMapArr(res, res2), kws
+			}
+		}
+		//非空查询
+		res = *doSearch(qstr, 0, 500, dataType)
+
+	} else {
+		//数据导出数据查询
+		if count > onceSearchCount {
+			for t := 0; t < 3; t++ {
+				for n := 0; n*onceSearchCount < count; n++ {
+					searchWaitGroup.Add(1)
+					searchPool <- true
+					go func(start int) {
+						defer func() {
+							searchWaitGroup.Done()
+							<-searchPool
+						}()
+						r := doSearch(qstr, start*onceSearchCount, onceSearchCount, dataType)
+						if r != nil {
+							res = append(res, *r...)
+							log.Println("第", start+1, "页数据加载完成!")
+						}
+					}(n)
+				}
+				searchWaitGroup.Wait()
+				//校验数量(预览数据查询不需要校验数据量)
+				if len(res) == count {
+					break
+				}
+				log.Println("第", t+1, "次加载数据完成,数据总数", len(res), ",由于数据量不够,重新加载!")
+			}
+		} else {
+			res = *doSearch(qstr, 0, count, dataType)
+		}
+
+		//和超级搜索同步
+		if scd.Comeinfrom == "supersearchPage" && (len(scd.Keyword) != 0 || len(scd.Industry) != 0) {
+			num := len(res)
+			searchTextSize := 0
+			if len(scd.Keyword) > 0 {
+				searchTextSize = len([]rune(scd.Keyword[0].Keyword))
+			}
+			if searchTextSize > 3 && num < 50 {
+				secondKWS := jy.HttpEs(scd.Keyword[0].Keyword, "ik_smart", config.Config.Elasticsearch)
+				scd.Keyword[0].Keyword = secondKWS
+				scd.SelectType = "title"
+				qstr = getDataExportSql(scd)
+				res2 := doSearch(qstr, 0, 100-num, "")
+				res = *delRepeatMapArr(&res, res2)
+			}
+		}
+		res = *FormatExportData(&res, config.Config.WebDomain, dataType, false)
+	}
+	return &res, kws
+}
+
+func FormatExportData(data *[]map[string]interface{}, webdomain string, dataType string, isBreviary bool) *[]map[string]interface{} {
+	//格式化输出
+	for _, v := range *data {
+		//====================字段补漏=========================
+		if v["toptype"] == "结果" && dataType == "2" && !(v["agency"] != nil && v["budget"] != nil && v["buyerperson"] != nil && v["buyertel"] != nil) {
+			r := elastic.Get("projectset", "projectset", fmt.Sprintf(`{"query":{"term":{"list.infoid":"%s"}},"_source": ["list"]}`, v["_id"]))
+			if len(*r) > 0 {
+				MsgList := (*r)[0]["list"]
+				if MsgList != nil {
+					list := qutil.ObjArrToMapArr(MsgList.([]interface{}))
+					for _, vv := range list {
+						if vv["subtype"] == "招标" {
+							if v["agency"] == nil && vv["agency"] != nil {
+								v["agency"] = vv["agency"]
+							}
+							if v["budget"] == nil && vv["budget"] != nil {
+								v["budget"] = vv["budget"]
+							}
+							if v["buyerperson"] == nil && vv["buyerperson"] != nil {
+								v["buyerperson"] = vv["buyerperson"]
+							}
+							if v["buyertel"] == nil && vv["buyertel"] != nil {
+								v["buyertel"] = vv["buyertel"]
+							}
+							break
+						}
+					}
+				}
+			}
+		}
+		if v["area"] == "A" {
+			v["area"] = "全国"
+		}
+		if v["bidamount"] != nil {
+			v["bidamount"] = fmt.Sprintf("%g", qutil.Float64All(v["bidamount"])*10000/100000000)
+		}
+		if v["budget"] != nil {
+			v["budget"] = fmt.Sprintf("%g", qutil.Float64All(v["budget"])*10000/100000000)
+		}
+		if v["publishtime"] != nil {
+			date := v["publishtime"]
+			v["publishtime"] = qutil.FormatDateWithObj(&date, qutil.Date_Short_Layout)
+		}
+		if v["bidopentime"] != nil {
+			date := v["bidopentime"]
+			v["bidopentime"] = qutil.FormatDateWithObj(&date, qutil.Date_Short_Layout)
+		}
+		if v["_id"] != nil {
+			v["url"] = webdomain + "/article/content/" + qutil.CommonEncodeArticle("content", v["_id"].(string)) + ".html"
+		}
+		if v["currency"] == "" || v["currency"] == nil {
+			v["currency"] = "人民币"
+		}
+		if v["projectscope"] != "" && v["projectscope"] != nil {
+			if isBreviary {
+				str := ClearHtml.ReplaceAllString(v["projectscope"].(string), "")
+				str = ClearOther.ReplaceAllString(str, "")
+				str = strings.Replace(str, " ", "", -1)
+				if len([]rune(str)) > 100 {
+					str = qutil.SubString(str, 0, 100) + "..."
+				}
+				v["projectscope"] = str
+			}
+		}
+		if v["detail"] != "" && v["detail"] != nil {
+			if isBreviary {
+				str := ClearHtml.ReplaceAllString(v["detail"].(string), "")
+				str = ClearOther.ReplaceAllString(str, "")
+				str = strings.Replace(str, " ", "", -1)
+				if len([]rune(str)) > 100 {
+					str = qutil.SubString(str, 0, 100) + "..."
+				}
+				v["detail"] = str
+			}
+		}
+		if v["subtype"] == nil && v["toptype"] != nil {
+			v["subtype"] = v["toptype"]
+		}
+	}
+	return data
+}
+func doSearch(sql string, start, count int, dataType string) *[]map[string]interface{} {
+	if sql != "" {
+		//筛选字段
+		if dataType != "" {
+			dataexport_field := `"_id","title","detail","area","city","publishtime","projectname","buyer","s_winner","bidamount","subtype","toptype"`
+			if dataType == "2" {
+				dataexport_field += `,"href","projectcode","buyerperson","buyertel","budget","bidopentime","agency","projectscope"`
+			}
+			sql = sql[:len(sql)-1] + `,"_source":[` + dataexport_field + "]}"
+		}
+		//分页排序
+		sql = sql[:len(sql)-1] + `,"sort": {"publishtime":"desc"},"from":` + strconv.Itoa(start) + `,"size":` + strconv.Itoa(count) + "}"
+	}
+	//	log.Println("sql----", sql)
+
+	return elastic.Get(INDEX, TYPE, sql)
+}
+
+func getKeyWordArrFromDbResult(k interface{}) (arr []KeyWord) {
+	if k == nil {
+		return
+	}
+	kArr := k.([]interface{})
+	for _, v := range kArr {
+		kw := KeyWord{}
+		b, e := json.Marshal(v)
+		if e != nil {
+			log.Println(e.Error())
+		}
+		json.Unmarshal(b, &kw)
+		arr = append(arr, kw)
+	}
+	return
+}
+
+func getStringArrFromDbResult(c interface{}) (arr []string) {
+	if c != nil {
+		cArr := c.([]interface{})
+		arr = qutil.ObjArrToStringArr(cArr)
+	}
+	return
+}
+
+//获取结果,空字段最少的数据
+func ScreenData(arr *[]map[string]interface{}, dataType string, resultNum int, kws []KeyWord) (res []map[string]interface{}) {
+	AllMap := map[int][]map[string]interface{}{}
+
+	NoKwsMap := map[int][]map[string]interface{}{}
+	lastNum := resultNum
+	for _, v := range *arr {
+		emptyNum := countOfTheEmpty(v, dataType)
+		if emptyNum == -1 {
+			continue
+		}
+		//		log.Println(util.ObjToString(v["title"]), "----", kws[0].Keyword)
+		if len(kws) > 0 && kws[0].Keyword != "" {
+			var kwsFlag = true
+			for _, vk := range kws {
+				if strings.Contains(qutil.ObjToString(v["title"]), strings.Replace(vk.Keyword, "+", "", -1)) {
+					kwsFlag = false
+					continue
+				}
+			}
+			if kwsFlag {
+				if NoKwsMap[emptyNum] == nil {
+					NoKwsMap[emptyNum] = []map[string]interface{}{v}
+				} else {
+					NoKwsMap[emptyNum] = append(NoKwsMap[emptyNum], v)
+				}
+				continue
+			}
+		}
+		if AllMap[emptyNum] == nil {
+			AllMap[emptyNum] = []map[string]interface{}{v}
+			continue
+		}
+		AllMap[emptyNum] = append(AllMap[emptyNum], v)
+	}
+	//获取key
+	keys := []int{}
+	for k, _ := range AllMap {
+		keys = append(keys, k)
+	}
+	sort.Ints(keys)
+	log.Println("空字段数量", keys)
+	//选取结果
+	for _, v := range keys {
+		if len(AllMap[v]) >= resultNum {
+			return append(res, AllMap[v][:resultNum]...)
+		} else {
+			resultNum = resultNum - len(AllMap[v])
+			tmp := append(res, AllMap[v][:len(AllMap[v])]...)
+			res = tmp
+		}
+	}
+	if len(res) < lastNum {
+		resultNum = lastNum - len(res)
+		//获取key
+		Nokeys := []int{}
+		for k, _ := range NoKwsMap {
+			Nokeys = append(Nokeys, k)
+		}
+		sort.Ints(Nokeys)
+		log.Println("没关键词的空字段数量", Nokeys)
+		//选取结果
+		for _, v := range Nokeys {
+			if len(NoKwsMap[v]) >= resultNum {
+				return append(res, NoKwsMap[v][:resultNum]...)
+			} else {
+				resultNum = resultNum - len(NoKwsMap[v])
+				tmp := append(res, NoKwsMap[v][:len(NoKwsMap[v])]...)
+				res = tmp
+			}
+		}
+	}
+	return res
+}
+func countOfTheEmpty(m map[string]interface{}, dataType string) int {
+	MsgType := m["subtype"]
+	if MsgType == "拟建" {
+		return -1
+	}
+	//计算空字段数量
+	var count int = 0
+	//高级字段包
+	if dataType == "2" {
+		if m["href"] == "" || m["href"] == nil {
+			count++
+		}
+		if m["projectcode"] == "" || m["projectcode"] == nil {
+			count++
+		}
+		if m["buyerperson"] == "" || m["buyerperson"] == nil {
+			count++
+		}
+		if m["buyertel"] == "" || m["buyertel"] == nil {
+			count++
+		}
+		if m["budget"] == "" || m["budget"] == nil {
+			count++
+		}
+		if m["bidopentime"] == "" || m["bidopentime"] == nil {
+			count++
+		}
+		if m["agency"] == "" || m["agency"] == nil {
+			count++
+		}
+		if m["projectscope"] == "" || m["projectscope"] == nil {
+			count++
+		}
+	}
+	if m["city"] == "" || m["city"] == nil {
+		count++
+	}
+	if m["publishtime"] == "" || m["publishtime"] == nil {
+		count++
+	}
+	if m["projectname"] == "" || m["projectname"] == nil {
+		count++
+	}
+	if m["buyer"] == "" || m["buyer"] == nil {
+		count++
+	}
+	if m["s_winner"] == "" || m["s_winner"] == nil {
+		if MsgType != "招标" {
+			count++
+		}
+	}
+	if m["bidamount"] == "" || m["bidamount"] == nil {
+		if MsgType != "招标" {
+			count++
+		}
+	}
+	if m["subtype"] == "" || m["subtype"] == nil {
+		count++
+	}
+	return count
+}

+ 41 - 0
src/jfw/modules/subscribepay/src/entity/dataReportStruct.go

@@ -0,0 +1,41 @@
+package  entity
+
+import (
+	"config"
+	qutil "qfw/util"
+	"time"
+	"util"
+)
+
+//数据报告
+type dataReportStruct struct {}
+
+var JyDataReportStruct dataReportStruct
+
+func (this *dataReportStruct)PayCallBack(param *CallBackParam)(update bool){
+	orderdata := util.Mysql.FindOne("jy_datareport_order", map[string]interface{}{
+		"out_trade_no":  param.OutTradeno,
+		"order_money":  param.TotalFee,
+	}, "order_status,report_id,user_mail", "")
+
+	if orderdata != nil {
+		now := time.Now()
+		order_status := qutil.IntAll((*orderdata)["order_status"])
+		if order_status == 0 {
+			update = util.Mysql.Update("jy_datareport_order", map[string]interface{}{
+				"out_trade_no": param.OutTradeno,
+				"order_money":  param.TotalFee,
+			}, map[string]interface{}{
+				"pay_money":    param.CashFee,
+				"pay_time":     qutil.FormatDate(&now, qutil.Date_Full_Layout),
+				"order_status": 1,
+				//"pay_way":      "wx_js",
+			})
+			if update {
+				//发送数据
+				go SendDatareportMailToPayUser(qutil.IntAll((*orderdata)["report_id"]), param.OutTradeno, qutil.ObjToString((*orderdata)["user_mail"]), config.GmailAuth)
+			}
+		}
+	}
+	return
+}

+ 668 - 0
src/jfw/modules/subscribepay/src/entity/dataexport.go

@@ -0,0 +1,668 @@
+package entity
+
+import (
+	"bytes"
+	"config"
+	"encoding/json"
+	"fmt"
+	"log"
+	"os"
+	qutil "qfw/util"
+	"qfw/util/mail"
+	"regexp"
+	"strings"
+	"sync"
+	"time"
+	"util"
+
+	"github.com/tealeg/xlsx"
+)
+
+var ExConf *DataexportConfig
+
+func init()  {
+	qutil.ReadConfig("./dataexport.json", &ExConf)
+}
+
+//价格配置文件
+type DataexportConfig struct {
+	UnitPrice_normal             float64           `json:"unitPrice_normal"`
+	UnitPrice_senior             float64           `json:"unitPrice_senior"`
+	Discount                     float64           `json:"discount"`
+	OrderMinPrice                float64           `json:"orderMinPrice"`
+	MsgMaxCount                  int               `json:"msgMaxCount"`
+	Standard_Fields              *Dataexport_Field `json:"standard"`
+	Senior_Fields                *Dataexport_Field `json:"senior"`
+	Mail_attach_content          string            `json:"mail_attach_content"`
+	Mail_attach_content_key      string            `json:"mail_attach_content_key"`
+	Mail_notice_content          string            `json:"mail_notice_content"`
+	Mail_notice_title            string            `json:"mail_notice_title"`
+	Mail_retry                   int               `json:"mail_retry"`
+	AuditPersons                 []string          `json:"auditPersons"`
+	Font                         Font              `json:"font"`
+	Mail_invoice_finance_content string            `json:"mail_invoice_finance_content"` //to北京财务订单内容
+	Mail_order_finance_content   string            `json:"mail_order_finance_content"`   //to北京财务申请发票内容
+	Finance_emails               []string          `json:"finance_emails"`
+	Qmxdomain                    string            `json:"qmxdomain"`
+	DataReportContent            string            `json:"dataReportContent"`
+}
+type Dataexport_Field struct {
+	Names  []string  `json:"names"`
+	Fields []string  `json:"fields"`
+	Widths []float64 `json:"widths"`
+}
+
+type Font struct {
+	Enabled                 bool   `json:"enabled"`
+	ConvertVersionDefault   string `json:"convertVersionDefault"`
+	UnConvertVersionDefault string `json:"unConvertVersionDefault"`
+	MappingFileExt          string `json:"mappingFileExt"`
+	MappingFilePath         string `json:"mappingFilePath"`
+	RedisPool               string `json:"redisPool"`
+	RedisKey                string `json:"redisKey"`
+}
+
+type myWrite struct {
+	Byte *bytes.Buffer
+}
+
+func (m *myWrite) Write(p []byte) (n int, err error) {
+	n, err = m.Byte.Write(p)
+	return
+}
+
+type dataExportStruct struct {}
+
+var JyDataExportStruct dataExportStruct
+
+//数据导出支付完成回调方法
+func (d *dataExportStruct) PayCallBack(param *CallBackParam) bool{
+	now := time.Now()
+	update:=false
+	orderdata := util.Mysql.FindOne("dataexport_order", map[string]interface{}{
+		"out_trade_no": param.OutTradeno,
+		"order_money":  param.TotalFee,
+	}, "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_way", "")
+	pay_time := qutil.FormatDate(&now, qutil.Date_Full_Layout)
+	if orderdata != nil {
+		filename := fmt.Sprintf("%s.xlsx", fmt.Sprintf("%s_%s_%s", time.Now().Format("20060102150405"), qutil.ObjToString((*orderdata)["order_code"]), qutil.GetLetterRandom(5)))
+		download_url := fmt.Sprintf("/res/dataexport/%s", filename)
+		order_status := qutil.IntAll((*orderdata)["order_status"])
+		if order_status == 0 {
+			update = util.Mysql.Update("dataexport_order", map[string]interface{}{
+				"order_status": 0,
+				"out_trade_no":  param.OutTradeno ,
+				"order_money":  param.TotalFee ,
+				//"user_openid":  openid,
+			}, map[string]interface{}{
+				"pay_money":    param.CashFee,
+				"pay_time":     pay_time,
+				"order_status": 1,
+				"download_url": download_url,
+			})
+			if update {
+				//先发个通知
+				go SendNotice(orderdata, float64(param.CashFee) / 100, pay_time, download_url, config.GmailAuth)
+				go SendMailToPayUser(orderdata, float64(param.CashFee) / 100, pay_time, filename, download_url, config.GmailAuth)
+				go SendMailToBJFinance(orderdata, pay_time, param.TransactionId, 1, config.GmailAuth)
+			}
+		} else {
+			update = true
+		}
+	}
+	return update
+}
+
+
+//发送邮箱验证码
+func SendMailIdentCode(to, code string, auth []*mail.GmailAuth) bool {
+	html := fmt.Sprintf(`<div>
+		<div>
+			%s,您好!
+		</div>
+		<div style="padding: 20px 70px 10px 70px;">
+			<p>您正在进行导出邮箱地址验证,请在邮件验证码输入框输入下方验证码:</p>
+			<span style="font-weight: bold;font-size: x-large;">%s</span>
+			<p>请勿向任何人泄露您收到的验证码。</p>
+			<p>如果您没有使用剑鱼标讯,请忽略此邮件。</p>
+			<p>此为系统邮件,请勿回复。</p>
+			<p>如有疑问,请联系客服 400-108-6670。</p>
+		</div>
+		<div>
+			<p>此致</p>
+			<p>剑鱼标讯</p>
+		</div>	
+	</div>`, to, code)
+
+	for k, v := range auth {
+		if mail.GSendMail("剑鱼标讯", to, "", "", "剑鱼标讯邮箱校验", html, "", "", v) {
+			log.Println(to, fmt.Sprintf("使用%s发送邮件成功", v.User))
+			return true
+		}
+		if k < len(auth)-1 {
+			log.Println(to, fmt.Sprintf("使用%s发送邮件失败!3s后使用其他邮箱尝试", v.User))
+		} else {
+			log.Println(to, fmt.Sprintf("使用%s发送邮件失败!", v.User))
+		}
+		time.Sleep(time.Second * 3)
+	}
+
+	return false
+}
+
+//发送通知
+func SendNotice(order *map[string]interface{}, order_money float64, pay_time, download_url string, auth []*mail.GmailAuth) {
+	order_code := qutil.ObjToString((*order)["order_code"])
+	user_mail := qutil.ObjToString((*order)["user_mail"])
+	url := fmt.Sprintf("%s%s", config.Config.WebDomain, download_url)
+	for _, audit := range ExConf.AuditPersons {
+		if regexp.MustCompile("^\\d+$").MatchString(audit) {
+			util.SendSMS("2828100", audit, map[string]string{
+				"name":     order_code,
+				"username": user_mail,
+				"tel":      url,
+			})
+		}
+	}
+}
+
+var finaceLock *sync.Mutex = &sync.Mutex{}
+
+//给北京财务人员发邮件
+func SendMailToBJFinance(order *map[string]interface{}, pay_time, transaction_id string, mailType int, auth []*mail.GmailAuth) {
+	defer qutil.Catch()
+	finaceLock.Lock()
+	defer finaceLock.Unlock()
+	order_code := qutil.ObjToString((*order)["order_code"])
+	user_mail := qutil.ObjToString((*order)["user_mail"])
+	user_phone := qutil.ObjToString((*order)["user_phone"])
+	data_spec := qutil.ObjToString((*order)["data_spec"])
+	data_count := qutil.IntAll((*order)["data_count"])
+	pay_way := qutil.ObjToString((*order)["pay_way"])
+
+	if strings.Contains(pay_way, "wx") {
+		pay_way = "微信"
+	} else if strings.Contains(pay_way, "ali") {
+		pay_way = "支付宝"
+	}
+
+	create_time := qutil.ObjToString((*order)["create_time"])
+	if create_time != "" {
+		create_time = strings.Replace(create_time, "-", ".", -1)
+		create_time = regexp.MustCompile(":[^:]+$").ReplaceAllString(create_time, "")
+	}
+	//
+	product_type := qutil.ObjToString((*order)["product_type"]) + "导出"
+	//
+	order_money := float64(qutil.IntAll((*order)["order_money"])) / 100
+
+	if transaction_id == "" {
+		transaction_id = func() string {
+			table := ""
+			if pay_way == "微信" {
+				table = "weixin_pay"
+			} else if pay_way == "支付宝" {
+				table = "ali_pay"
+			} else {
+				return ""
+			}
+			out_trade_no := qutil.ObjToString((*order)["out_trade_no"])
+			wxpaydata := util.Mysql.FindOne(table, map[string]interface{}{
+				"out_trade_no": out_trade_no,
+			}, "transaction_id", "")
+			if wxpaydata != nil && len(*wxpaydata) > 0 { //线下支付没有微信订单编号
+				return qutil.ObjToString((*wxpaydata)["transaction_id"])
+			}
+			return ""
+		}()
+	}
+	isShowTransaction := "" //支付订单号为空,邮件不显示此字段
+	if transaction_id == "" {
+		isShowTransaction = "none"
+	}
+	mailcontent := ""
+	var mail_title = ""
+	selectType := "title"
+	if mailType == 1 { //支付完成后给北京财务发送导出数据接口信息的邮件
+		filter := qutil.ObjToString((*order)["filter"])
+		buyer, winner, subtype := "", "", ""
+		publishtime, region, industry, keys := "", "", "", ""
+		sc_money := ""
+		sc := new(SieveCondition)
+		err := json.Unmarshal([]byte(filter), &sc)
+		if err == nil && sc != nil {
+			selectType = qutil.ObjToString(sc.SelectType)
+			if selectType == "title" {
+				selectType = "标题匹配"
+			} else {
+				selectType = "全文匹配"
+			}
+			//
+			if pay_time != "" {
+				pay_time = strings.Replace(pay_time, "-", ".", -1)
+				pay_time = regexp.MustCompile(":[^:]+$").ReplaceAllString(pay_time, "")
+			}
+			sc_money = GetPriceDes_SieveCondition(sc.MinPrice, sc.MaxPrice)
+			pts := strings.Split(sc.PublishTime, "_")
+			if len(pts) == 2 {
+				startTime, endTime := qutil.Int64All(pts[0]), qutil.Int64All(pts[1])
+				if startTime != 0 && endTime != 0 {
+					publishtime = fmt.Sprintf("%s-%s", qutil.FormatDateByInt64(&startTime, qutil.Date_yyyyMMdd_Point), qutil.FormatDateByInt64(&endTime, qutil.Date_yyyyMMdd_Point))
+				} else if startTime == 0 && endTime != 0 {
+					publishtime = fmt.Sprintf("%s前全部", qutil.FormatDateByInt64(&endTime, qutil.Date_yyyyMMdd_Point))
+				} else if startTime != 0 && endTime == 0 {
+					publishtime = fmt.Sprintf("%s-%s", qutil.FormatDateByInt64(&startTime, qutil.Date_yyyyMMdd_Point), create_time[:10])
+				}
+			}
+			//超级搜索页面 筛选区域为 area 		没有region    移动端数据导出改
+			if sc.Region == nil {
+				region = strings.Join(sc.Area, " ")
+			} else {
+				region = strings.Join(sc.Region, " ")
+			}
+			var industryBuffer bytes.Buffer
+			for k, v := range sc.Industry {
+				if k > 0 {
+					industryBuffer.WriteString(" ")
+				}
+				vs := strings.Split(v, "_")
+				if len(vs) == 1 {
+					industryBuffer.WriteString(vs[0])
+				} else {
+					industryBuffer.WriteString(vs[1])
+				}
+			}
+			industry = industryBuffer.String()
+			var keysBuffer bytes.Buffer
+			for _, v := range sc.Keyword {
+				keysBuffer.WriteString(fmt.Sprintf(ExConf.Mail_attach_content_key, v.Keyword, strings.Join(v.Appended, " "), strings.Join(v.Exclude, " ")))
+			}
+			keys = keysBuffer.String()
+			buyer = strings.Join(sc.Buyer, " ")
+			winner = strings.Join(sc.Winner, " ")
+			subtype = strings.Replace(sc.Subtype, ",", " ", -1)
+		} else {
+			log.Println("用户筛选条件错误", err, sc)
+		}
+		mail_title = "剑鱼标讯历史数据订单【" + order_code + "】,请查收"
+		mailcontent = fmt.Sprintf(ExConf.Mail_order_finance_content, order_code, create_time, pay_time, product_type, isShowTransaction, pay_way, transaction_id, data_spec, data_count, order_money, user_mail, user_phone, publishtime, region, industry, keys, selectType, sc_money, subtype, buyer, winner)
+	} else {
+		//申请发票
+		pay_time = qutil.ObjToString((*order)["pay_time"])
+		if pay_time != "" {
+			pay_time = strings.Replace(pay_time, "-", ".", -1)
+			pay_time = regexp.MustCompile(":[^:]+$").ReplaceAllString(pay_time, "")
+		}
+		applybill_type := qutil.IntAll((*order)["applybill_type"])
+		bill_title := "个人"
+		bill_company := ""
+		bill_taxnum := ""
+		company_flag := "none"
+		taxnum_flag := "none"
+		if applybill_type != 0 {
+			bill_title = "单位"
+			bill_company = qutil.ObjToString((*order)["applybill_company"])
+			bill_taxnum = qutil.ObjToString((*order)["applybill_taxnum"])
+			company_flag = "flex"
+			taxnum_flag = "flex"
+		}
+		//线下支付获取凭证照片
+		offlineImgSrc := ""
+		if (*order)["pay_way"] == "线下支付" {
+			offlinePayMap := map[string]interface{}{}
+			offlinePayMap["out_trade_no"] = (*order)["out_trade_no"]
+			offlinePay := util.Mysql.FindOne("offline_pay", offlinePayMap, "", "create_time desc")
+			if imgs := qutil.ObjToString((*offlinePay)["img_src"]); imgs != "" {
+				ImgArr := strings.Split(imgs, ",")
+				offlineImgSrc = "<p style='margin: 0px 0px 1px; font-size: 14px; color: rgb(29, 29, 29);'>线下支付凭证:%s</p>"
+				for k, v := range ImgArr {
+					var add = ",%s"
+					if k == len(ImgArr)-1 {
+						add = ""
+					}
+					pz := fmt.Sprintf("<a href='%s'>凭证%d</a>%s", ExConf.Qmxdomain+v, k+1, add)
+					offlineImgSrc = fmt.Sprintf(offlineImgSrc, pz)
+				}
+			}
+		}
+		mail_title = "电子发票申请,剑鱼标讯历史数据订单【" + order_code + "】,请查收"
+		mailcontent = fmt.Sprintf(ExConf.Mail_invoice_finance_content, bill_title, company_flag, bill_company, taxnum_flag, bill_taxnum, order_code, create_time, pay_time, product_type, isShowTransaction, pay_way, transaction_id, offlineImgSrc, data_spec, data_count, order_money, user_mail, user_phone)
+	}
+	//发送邮件
+	for _, finance_mail := range ExConf.Finance_emails {
+		if regexp.MustCompile("^\\d+$").MatchString(finance_mail) {
+			continue
+		}
+		if finance_mail != "" {
+			finance_remark := "剑鱼标讯历史数据订单支付邮件"
+			if mailType == 2 {
+				finance_remark = "剑鱼标讯历史数据订单发票申请邮件"
+			}
+			if SendRetryMail(ExConf.Mail_retry, finance_mail, mail_title, mailcontent, "", nil, auth) {
+				log.Println(finance_mail, "北京财务:"+finance_remark+"发送成功!")
+			} else {
+				log.Println(finance_mail, "北京财务:"+finance_remark+"发送失败!")
+			}
+		} else {
+			log.Println(finance_mail, "北京财务:邮件地址为空")
+		}
+	}
+}
+
+//给已经付费的用户发邮件
+func SendMailToPayUser(order *map[string]interface{}, order_money float64, pay_time, filename, download_url string, auth []*mail.GmailAuth) {
+	defer qutil.Catch()
+	log.Println("给已经付费的用户发邮件")
+	order_id := qutil.Int64All((*order)["id"])
+	order_code := qutil.ObjToString((*order)["order_code"])
+	user_mail := qutil.ObjToString((*order)["user_mail"])
+	user_phone := qutil.ObjToString((*order)["user_phone"])
+	data_spec := qutil.ObjToString((*order)["data_spec"])
+	data_count := qutil.IntAll((*order)["data_count"])
+	//
+	filter_id := qutil.ObjToString((*order)["filter_id"])
+	filter := qutil.ObjToString((*order)["filter"])
+	product_type := qutil.ObjToString((*order)["product_type"]) + "导出"
+	//
+	create_time := qutil.ObjToString((*order)["create_time"])
+	if create_time != "" {
+		create_time = strings.Replace(create_time, "-", ".", -1)
+		create_time = regexp.MustCompile(":[^:]+$").ReplaceAllString(create_time, "")
+	}
+	//
+	file := xlsx.NewFile()
+	sheet, _ := file.AddSheet("Sheet1")
+	var row *xlsx.Row
+	var cell *xlsx.Cell
+	//边框
+	border := xlsx.Border{
+		Left:        "thin",
+		LeftColor:   "00A6A6A6",
+		Right:       "thin",
+		RightColor:  "00A6A6A6",
+		Top:         "thin",
+		TopColor:    "00A6A6A6",
+		Bottom:      "thin",
+		BottomColor: "00A6A6A6",
+	}
+	//对齐方式
+	alignment := xlsx.Alignment{
+		Horizontal: "center",
+		Vertical:   "center",
+		WrapText:   true,
+	}
+	//增加标题
+	row = sheet.AddRow()
+	row.SetHeight(30)
+	var names []string
+	var fields []string
+	var widths []float64
+	dataType := "1"
+	if data_spec == "标准字段包" {
+		names = ExConf.Standard_Fields.Names
+		fields = ExConf.Standard_Fields.Fields
+		widths = ExConf.Standard_Fields.Widths
+	} else if data_spec == "高级字段包" {
+		dataType = "2"
+		names = ExConf.Senior_Fields.Names
+		fields = ExConf.Senior_Fields.Fields
+		widths = ExConf.Senior_Fields.Widths
+	}
+	style1 := &xlsx.Style{
+		Fill:      *xlsx.NewFill("solid", "00DDD9C4", "00DDD9C4"),
+		Border:    border,
+		Alignment: alignment,
+	}
+	for k, name := range names {
+		cell = row.AddCell()
+		cell.SetString(name)
+		cell.SetStyle(style1)
+		if k < len(widths) {
+			sheet.Col(k).Width = widths[k]
+		}
+	}
+	//增加其他
+	style2 := &xlsx.Style{
+		Border:    border,
+		Alignment: alignment,
+	}
+	list, _ := GetDataExportSearchResultUseId(filter_id, dataType, data_count)
+	if list != nil {
+		for _, v := range *list {
+			row = sheet.AddRow()
+			row.SetHeight(50)
+			for _, field := range fields {
+				cell = row.AddCell()
+				cell.SetValue(v[field])
+				cell.SetStyle(style2)
+			}
+		}
+	} else {
+		log.Println(user_mail, "数据导出邮件没有获取到数据!")
+	}
+	dir := "./web/staticres/res/dataexport"
+	if strings.Contains(download_url, "jyapp") {
+		dir = "./web/staticres/jyapp/res/dataexport"
+	}
+	_, path_error := os.Stat(dir)
+	if path_error != nil && os.IsNotExist(path_error) {
+		// 创建文件夹
+		os.MkdirAll(dir, os.ModePerm)
+	}
+	err := file.Save(dir + "/" + filename)
+	if err != nil {
+		log.Println(user_mail, filename, "生成附件文件错误:", err)
+	}
+	//	mw := &myWrite{
+	//		Byte: &bytes.Buffer{},
+	//	}
+	//	err = file.Write(mw)
+	//	if err != nil {
+	//		log.Println(user_mail, "数据导出生成excel失败!", err)
+	//	}
+	//	bt := mw.Byte.Bytes()
+	now := time.Now()
+	//fname := fmt.Sprintf("%s.xlsx", order_code)
+	//
+	mailcontent := ""
+	buyer, winner, subtype := "", "", ""
+	publishtime, region, industry, keys := "", "", "", ""
+	sc_money := ""
+	sc := new(SieveCondition)
+	err = json.Unmarshal([]byte(filter), &sc)
+	selectType := "title"
+	if err == nil && sc != nil {
+		selectType = qutil.ObjToString(sc.SelectType)
+		if selectType == "title" {
+			selectType = "标题匹配"
+		} else {
+			selectType = "全文匹配"
+		}
+		//
+		if pay_time != "" {
+			pay_time = strings.Replace(pay_time, "-", ".", -1)
+			pay_time = regexp.MustCompile(":[^:]+$").ReplaceAllString(pay_time, "")
+		}
+		sc_money = GetPriceDes_SieveCondition(sc.MinPrice, sc.MaxPrice)
+		pts := strings.Split(sc.PublishTime, "_")
+		if len(pts) == 2 {
+			startTime, endTime := qutil.Int64All(pts[0]), qutil.Int64All(pts[1])
+			if startTime != 0 && endTime != 0 {
+				publishtime = fmt.Sprintf("%s-%s", qutil.FormatDateByInt64(&startTime, qutil.Date_yyyyMMdd_Point), qutil.FormatDateByInt64(&endTime, qutil.Date_yyyyMMdd_Point))
+			} else if startTime == 0 && endTime != 0 {
+				publishtime = fmt.Sprintf("%s前全部", qutil.FormatDateByInt64(&endTime, qutil.Date_yyyyMMdd_Point))
+			} else if startTime != 0 && endTime == 0 {
+				publishtime = fmt.Sprintf("%s-%s", qutil.FormatDateByInt64(&startTime, qutil.Date_yyyyMMdd_Point), create_time[:10])
+			}
+		}
+		//超级搜索页面 筛选区域为 area 		没有region    移动端数据导出改
+		if sc.Region == nil {
+			region = strings.Join(sc.Area, " ")
+		} else {
+			region = strings.Join(sc.Region, " ")
+		}
+		var industryBuffer bytes.Buffer
+		for k, v := range sc.Industry {
+			if k > 0 {
+				industryBuffer.WriteString(" ")
+			}
+			vs := strings.Split(v, "_")
+			if len(vs) == 1 {
+				industryBuffer.WriteString(vs[0])
+			} else {
+				industryBuffer.WriteString(vs[1])
+			}
+		}
+		industry = industryBuffer.String()
+		var keysBuffer bytes.Buffer
+		for _, v := range sc.Keyword {
+			keysBuffer.WriteString(fmt.Sprintf(ExConf.Mail_attach_content_key, v.Keyword, strings.Join(v.Appended, " "), strings.Join(v.Exclude, " ")))
+		}
+		keys = keysBuffer.String()
+		buyer = strings.Join(sc.Buyer, " ")
+		winner = strings.Join(sc.Winner, " ")
+		subtype = strings.Replace(sc.Subtype, ",", " ", -1)
+	} else {
+		log.Println("用户筛选条件错误", err, sc)
+	}
+	downloadurl := fmt.Sprintf("%s%s", config.Config.WebDomain, download_url)
+	mailcontent = fmt.Sprintf(ExConf.Mail_attach_content, downloadurl, order_code, create_time, pay_time, product_type, data_spec, data_count, order_money, user_mail, user_phone, publishtime, region, industry, keys, selectType, sc_money, subtype, buyer, winner)
+	//发送邮件
+	if user_mail != "" {
+		if SendRetryMail(ExConf.Mail_retry, user_mail, "历史数据", mailcontent, "", nil, auth) {
+			log.Println(user_mail, "用户:数据导出附件邮件发送成功!")
+			util.Mysql.Update("dataexport_order", map[string]interface{}{
+				"id": order_id,
+			}, map[string]interface{}{
+				"service_status": 1,
+				"service_time":   qutil.FormatDate(&now, qutil.Date_Full_Layout),
+			})
+		} else {
+			log.Println(user_mail, "用户:数据导出邮件发送失败!")
+		}
+	} else {
+		log.Println(user_mail, "用户:用户邮件地址为空")
+	}
+	for _, audit := range ExConf.AuditPersons {
+		if regexp.MustCompile("^\\d+$").MatchString(audit) {
+			continue
+		}
+		if SendRetryMail(ExConf.Mail_retry, audit, "历史数据", mailcontent, "", nil, auth) {
+			log.Println(audit, "管理员:数据导出附件邮件发送成功!")
+		} else {
+			log.Println(audit, "管理员:数据导出邮件发送失败!")
+		}
+	}
+}
+
+func GetWaitPayToken(orderid int64, order_money int, ordercode, payway, userid string) string {
+	return qutil.GetMd5String(fmt.Sprintf("%d_%d_%s_%s_%s", orderid, order_money, ordercode, payway, userid))
+}
+func SendRetryMail(retry int, user_mail, subject, content, fname string, bt []byte, auth []*mail.GmailAuth) bool {
+	for i := 1; i <= retry; i++ {
+		for _, v := range auth { //使用多个邮箱尝试发送
+			if mail.GSendMail_B("剑鱼标讯", user_mail, "", "", subject, content, fname, bt, v) {
+				return true
+			}
+			t := time.Duration(i) * 30 * time.Second
+			log.Println(user_mail, fmt.Sprintf("第%d轮,使用%s发送邮件失败!%v后重试", i, v.User, t))
+			time.Sleep(t)
+		}
+		if i == retry {
+			log.Println(user_mail, fmt.Sprintf("发送邮件失败"))
+		}
+	}
+	return false
+}
+
+/*
+	获取-筛选条件-金额
+*/
+func GetPriceDes_SieveCondition(minPrice, maxPrice string) string {
+	des := ""
+	unit := "万元"
+	if minPrice != "" && maxPrice != "" {
+		des = minPrice + unit + "—" + maxPrice + unit
+	} else if minPrice != "" {
+		des = "大于" + minPrice + unit
+	} else if maxPrice != "" {
+		des = "小于" + maxPrice + unit
+	}
+	return des
+}
+
+//数据报告发送邮件
+func SendDatareportMailToPayUser(report_id int, out_trade_no, user_mail string, auth []*mail.GmailAuth) {
+	res := util.Mysql.FindOne("jy_datareport", map[string]interface{}{
+		"report_id": report_id,
+	}, "s_url", "")
+	if res == nil || (*res)["s_url"] == "" {
+		log.Println("%d:未知数据报告\n", report_id)
+		return
+	}
+	mailcontent := fmt.Sprintf(ExConf.DataReportContent, config.Config.WebDomain+(*res)["s_url"].(string))
+	if SendRetryMail(ExConf.Mail_retry, user_mail, "数据报告", mailcontent, "", nil, auth) {
+		log.Printf("用户%s:数据报告附件邮件发送成功!数据报告id:%d\n", user_mail, report_id)
+		now := time.Now()
+		util.Mysql.Update("jy_datareport_order", map[string]interface{}{
+			"out_trade_no": out_trade_no,
+			"report_id":    report_id,
+		}, map[string]interface{}{
+			"service_status": 1,
+			"service_time":   qutil.FormatDate(&now, qutil.Date_Full_Layout),
+		})
+	} else {
+		log.Printf("%s数据报告发送邮件出错,数据报告id:%d\n", out_trade_no, report_id)
+	}
+}
+
+//数据报告回显信息
+func GetBrforeMsg(userId, openId string) (name, phone, company, email string) {
+	order := util.Mysql.FindOne("jy_datareport_order", map[string]interface{}{
+		"user_id": userId,
+	}, "user_name,user_mail,user_phone,user_company", "create_time desc")
+	if order != nil {
+		name = qutil.ObjToString((*order)["user_name"])
+		phone = qutil.ObjToString((*order)["user_phone"])
+		company = qutil.ObjToString((*order)["user_company"])
+		email = qutil.ObjToString((*order)["user_mail"])
+	} else {
+		//之前没有数据报告订单查询数据导出 带出公司 手机号 邮箱字段
+		res := util.Mysql.FindOne("dataexport_order", map[string]interface{}{
+			"user_id": userId,
+		}, "user_mail,user_phone,applybill_company", "create_time desc")
+		if res != nil {
+			email = qutil.ObjToString((*res)["user_mail"])
+			phone = qutil.ObjToString((*res)["user_phone"])
+			company = qutil.ObjToString((*res)["applybill_company"])
+			log.Println(email, ",", phone)
+		}
+		if email == "" || phone == "" || openId == "" {
+			userData, _ := util.MQFW.FindById("user", userId, `{"o_jy":1,"s_phone":1,"s_m_openid":1}`)
+			if userData != nil {
+				if email == "" {
+					o_jy := qutil.ObjToMap((*userData)["o_jy"])
+					email = qutil.ObjToString((*o_jy)["s_email"])
+				}
+				if phone == "" {
+					phone = qutil.ObjToString((*userData)["s_phone"])
+				}
+				if openId == "" {
+					openId = qutil.ObjToString((*userData)["s_m_openid"])
+				}
+			}
+		}
+		//查询开通推送公司名称
+		if openId != "" && (company == "" || phone == "") {
+			if myapply, ok := util.MQFW.FindOne("applysub_user", `{"s_openid":"`+openId+`"}`); ok {
+				if company == "" {
+					company = qutil.ObjToString((*myapply)["s_company"])
+				}
+				if phone == "" {
+					phone = qutil.ObjToString((*myapply)["s_phone"])
+				}
+			}
+		}
+	}
+	return
+}

+ 63 - 0
src/jfw/modules/subscribepay/src/entity/payCalbackStrust.go

@@ -0,0 +1,63 @@
+package entity
+
+import (
+	qutil "qfw/util"
+	"time"
+	"util"
+)
+
+type CallBackParam struct {
+	TotalFee int //订单价格
+	CashFee int //支付金额
+	OutTradeno string //订单号
+	TimeEnd string //支付时间
+	TransactionId string//商户单号
+	Openid string //位置用户标识(仅微信有)
+}
+
+func (param *CallBackParam) SaveWxPayRecord() (insert bool){
+	pay_count := util.Mysql.Count("weixin_pay", map[string]interface{}{
+		"transaction_id": param.TransactionId,
+		"out_trade_no":   param.OutTradeno,
+		"user_openid":    param.Openid,
+	})
+	if pay_count == 0 {
+		now := time.Now()
+		insert = util.Mysql.Insert("weixin_pay", map[string]interface{}{
+			"transaction_id": param.TransactionId,
+			"out_trade_no":   param.OutTradeno,
+			"user_openid":    param.Openid,
+			"create_time":    qutil.FormatDate(&now, qutil.Date_Full_Layout),
+			"total_fee":      param.TotalFee,
+			"cash_fee":       param.CashFee,
+			"time_end":       param.TimeEnd,
+		}) > 0
+	} else if pay_count > 0 {
+		insert = true
+	}
+	return
+}
+
+func (param *CallBackParam) SaveAliPayRecord() (insert bool){
+	//支付完成插入
+	pay_count := util.Mysql.Count("ali_pay", map[string]interface{}{
+		"transaction_id": param.TransactionId,
+		"out_trade_no":   param.OutTradeno,
+	})
+	if pay_count == 0 {
+		now := time.Now()
+		insert = util.Mysql.Insert("ali_pay", map[string]interface{}{
+			"transaction_id": param.TransactionId,
+			"out_trade_no":   param.OutTradeno,
+			"create_time":    qutil.FormatDate(&now, qutil.Date_Full_Layout),
+			"total_fee":      param.TotalFee,
+			"cash_fee":      param.CashFee,
+			"time_end":       param.TimeEnd,
+		}) > 0
+	}else{
+		insert=true
+	}
+	return
+}
+
+

+ 29 - 0
src/jfw/modules/subscribepay/src/entity/reWardStruct.go

@@ -0,0 +1,29 @@
+package entity
+
+import (
+	"time"
+	"util"
+)
+
+//打赏
+
+type reWardStruct struct{}
+
+var JyReWardStruct reWardStruct
+
+//打赏回调方法
+func (r *reWardStruct) PayCallBack(param *CallBackParam)bool{
+	query := map[string]interface{}{
+		"s_tradeno":  param.OutTradeno,
+		"i_totalfee":  param.TotalFee,
+		"i_status":   0,
+	}
+	return util.MQFW.Update("reward", query, map[string]interface{}{
+		"$set": map[string]interface{}{
+			"i_status":        1,
+			"s_timeend":       param.TimeEnd,
+			"l_updatetime":    time.Now().Unix(),
+			"s_transactionid": param.TransactionId,
+		},
+	}, false, false)
+}

+ 182 - 0
src/jfw/modules/subscribepay/src/entity/subscribeVip.go

@@ -0,0 +1,182 @@
+package entity
+//vip订阅公共方法
+import (
+	"log"
+	"time"
+	"util"
+
+	"gopkg.in/mgo.v2/bson"
+
+	qutil "qfw/util"
+)
+
+//设置开始试用
+func StartTrial(userId string, area *map[string]interface{}, industry []string) bool {
+	//计算服务时间
+	startTime := time.Now()
+	endTime := startTime.AddDate(0, 0, 7)
+	if !util.MQFW.UpdateById("user", userId,
+		bson.M{"$set": bson.M{
+			"o_vipjy.i_trial":      -1,                //已激活试用
+			"o_vipjy.o_area":       area,              //试用设置地区
+			"o_vipjy.a_buyerclass": industry,          //试用设置行业
+			"o_vipjy.a_buyset":     []int{-1, -1, -1}, //购买内容 城市、省份、行业数量
+			"l_vip_starttime":      startTime.Unix(),  //开始时间
+			"l_vip_endtime":        endTime.Unix(),    //结束时间
+			"i_vip_status":         1,                 //1试用 2正式
+		}}) {
+		return false
+	}
+	return true
+}
+
+//查询是否有试用权限
+func CanTrial(userId string) bool {
+	m, ok := util.MQFW.FindById("user", userId, `{"o_vipjy":1}`)
+	if m == nil || len(*m) == 0 || !ok {
+		return false
+	}
+	obj := qutil.ObjToMap((*m)["o_vipjy"])
+	if qutil.IntAll((*obj)["i_trial"]) != 1 {
+		return false
+	}
+	return true
+}
+
+//设置已试用
+func SetTrialed(userId string) {
+	if !util.MQFW.UpdateById("user", userId, bson.M{"$set": bson.M{"o_vipjy.i_trial": -1}}) {
+		log.Println(userId, "更新使用状态出错")
+	}
+}
+
+//获取省份,城市,行业购买数量;-1为全部
+//[省份,城市,行业]
+func GetBuySet(userId string) (result [3]int) {
+	mData, ok := util.MQFW.FindById("user", userId, `{"o_vipjy":1}`)
+	if !ok || len(*mData) == 0 || mData == nil {
+		return
+	}
+	tmp, _ := (*qutil.ObjToMap((*mData)["o_vipjy"]))["a_buyset"].([]interface{})
+	for k, v := range tmp {
+		result[k] = qutil.IntAll(v)
+	}
+	return
+}
+
+//根据区域获取城市和省份数量
+func GetBuyAreaCount(area map[string]interface{}) (result [2]int) {
+	p := []interface{}{} //省份
+	c := []interface{}{} //城市
+	for k, v := range area {
+		tmp := v.([]interface{})
+		if len(tmp) == 0 { //省份
+			result[0]++
+			p = append(p, k)
+		} else { //城市
+			result[1] += len(tmp)
+			c = append(c, tmp...)
+		}
+	}
+	log.Println(p, c)
+	return
+}
+
+//计算价格
+func GetSubVipPrice(area *map[string]interface{}, industry []string, count, unit int) int {
+	if len(*area) == 0 { //全国
+		if len(industry) == 1 {
+			return getSetMealPrice(0, 1, unit) * count //全国1行业套餐
+		} else if len(industry) == 0 {
+			return getSetMealPrice(0, 0, unit) * count //全国全行业套餐
+		} else {
+			return getSetMealPrice(0, len(industry), unit) * count //全国多行业套餐
+		}
+	}
+	final_price := 0 //最终价格
+	for _, tmp := range *area {
+		thisPrice := 0
+		citys := qutil.ObjArrToStringArr(tmp.([]interface{}))
+		if len(citys) > 0 { //市
+			if len(citys) == 1 { //单城市
+				thisPrice = getSetMealPrice(2, len(industry), unit) * count
+			} else { //多城市
+				if len(industry) == 0 || len(industry) == 1 { //多城市 单行业
+					thisPrice = len(citys) * getSetMealPrice(2, len(industry), unit) * count
+				} else { //多行业 多行业
+					if count > 10 && unit == 2 { //月份十个月以上价格一样
+						count = 10
+					}
+					industry_Price := 580 * len(industry)
+					if 580*len(industry) > 1800 {
+						industry_Price = 1800
+					}
+					city_Price := len(citys) * 580
+					if len(citys)*580 > 1180 {
+						city_Price = 1180
+					}
+					thisPrice = (industry_Price + city_Price) * count
+					if unit == 1 { //年的价格是月的价格10倍
+						thisPrice *= 10
+					}
+				}
+			}
+		} else { //省
+			thisPrice = getSetMealPrice(1, len(industry), unit) * count
+		}
+		final_price += thisPrice
+	}
+	return final_price
+}
+
+/*
+vip订阅 套餐价格
+c(city) 全国:0 省:1 市:2
+i(industry) 全行业:0 行业:1 其他:多个行业
+u(unit) 年:1 月:2
+*/
+func getSetMealPrice(c, i, u int) int {
+	t := u == 2 //是否是月单位
+	icount := 1 //行业个数
+	if i > 1 {
+		icount = i
+	}
+	switch c {
+	case 0:
+		if i == 0 {
+			if t {
+				return 38800 //1月全国全行业
+			}
+			return 388000 //1年全国全行业
+		} else {
+			if t {
+				return 11800 * icount //1月全国icount个行业
+			}
+			return 118000 * icount //1年全国icount个行业
+		}
+	case 1:
+		if i == 0 {
+			if t {
+				return 3800 //1月1省全行业
+			}
+			return 38000 //1年1省全行业
+		} else {
+			if t {
+				return 1180 * icount //1月1省icount个行业
+			}
+			return 11800 * icount //1年1省icount个行业
+		}
+	default:
+		if i == 0 {
+			if t {
+				return 1800 //1月1市全行业
+			}
+			return 18000 //1年1市全行业
+		} else {
+			if t {
+				return 580 * icount //1月1市icount个行业
+			}
+			return 5800 * icount //1年1市icount个行业
+		}
+	}
+}

+ 5 - 0
src/jfw/modules/subscribepay/src/filter/sessionfilter.go

@@ -2,6 +2,7 @@ package filter
 
 import (
 	"net/http"
+	"strings"
 
 	"github.com/go-xweb/xweb"
 )
@@ -13,6 +14,10 @@ type sessionfilter struct {
 
 //继承过滤器方法
 func (l *sessionfilter) Do(w http.ResponseWriter, req *http.Request) bool {
+	rqu := req.URL.Path
+	if strings.HasPrefix(rqu,"/jypay/callback/"){//支付回调
+		return true
+	}
 	session := l.App.SessionManager.Session(req, w)
 	if session.Get("userId") == nil {
 		w.Write([]byte("{\"error\":\"需要登录!\"}"))

+ 222 - 0
src/jfw/modules/subscribepay/src/pay/aliPay.go

@@ -0,0 +1,222 @@
+package pay
+
+import (
+	"config"
+	"crypto"
+	"crypto/rsa"
+	"crypto/sha256"
+	"encoding/base64"
+	"encoding/json"
+	"fmt"
+	"io/ioutil"
+	"log"
+	"net/http"
+	"net/url"
+	qutil "qfw/util"
+	"strings"
+	"time"
+)
+
+type AliPayStruct struct {
+	Appid          string
+	PrivateKey     *rsa.PrivateKey //请求接口秘钥
+	AliPublicKey   *rsa.PublicKey  //支付完成回调,校验使用(取支付宝后台)
+	CallBackUrl    string          //支付完成回调地址
+	Requseturl     string          //接口请求地址
+	Subject_sjdc   string          //支付小标题
+	Subject_sjbg   string          //支付小标题
+	Subject_subvip string          //支付小标题
+}
+
+var Alipay *AliPayStruct
+
+func init() {
+	//加载本地私钥
+	privateKey, err := parsePrivateKey(qutil.ObjToString(config.AliPayConf["privateKey"]))
+	if err != nil {
+		panic(err)
+	}
+	//加载支付宝后台公钥
+	aliPublicKey, err := parseAliPayPublicKey(qutil.ObjToString(config.AliPayConf["callbackPublicKey"]))
+	if err != nil {
+		panic(err)
+	}
+	Alipay = &AliPayStruct{
+		Appid:          qutil.ObjToString(config.AliPayConf["appid"]),
+		PrivateKey:     privateKey,
+		AliPublicKey:   aliPublicKey,
+		CallBackUrl:    qutil.ObjToString(config.Config.WebDomain) + "/jypay/callback/aliPay",
+		Requseturl:     qutil.ObjToString(config.AliPayConf["reqUrl"]),
+		Subject_sjdc:   qutil.ObjToString(config.AliPayConf["Subject_sjdc"]),
+		Subject_sjbg:   qutil.ObjToString(config.AliPayConf["Subject_sjbg"]),
+		Subject_subvip: qutil.ObjToString(config.AliPayConf["Subject_subvip"]),
+	}
+}
+
+const (
+	ALI_DATAEXPORT_NATIVE = "z" //支付宝数据导出-扫码支付
+	ALI_DATAEXPORT_APP    = "Z" //支付宝数据导出-app支付
+	ALI_DATAREPORT_APP    = "X" //支付宝数据报告-app支付
+	ALI_SUBVIP_NATIVE     = "y" //支付宝vip订阅-扫码支付
+	ALI_SUBVIP_APP        = "Y" //支付宝数vip订阅--扫码支付
+)
+
+func (w *AliPayStruct) GetTradeno(tradenoSign string) (string, string) {
+	tradeno, subject := "", ""
+	if tradenoSign == ALI_DATAEXPORT_NATIVE || tradenoSign == ALI_DATAEXPORT_APP {
+		subject = w.Subject_sjdc
+	} else if tradenoSign == ALI_DATAREPORT_APP {
+		subject = w.Subject_sjbg
+	} else if tradenoSign == ALI_SUBVIP_NATIVE || tradenoSign == ALI_SUBVIP_APP {
+		subject = w.Subject_subvip
+	}
+	tradeno = fmt.Sprintf("%s_%d%s%s", tradenoSign, time.Now().UnixNano(), qutil.GetRandom(5), qutil.GetLetterRandom(6))
+	return tradeno, subject
+}
+
+//获取网页支付二维码地址
+func (a *AliPayStruct) GetOrderPayParam(order_money float64, time_expire, tradenoSign string) (string, string, error) {
+	//支付标题
+	tradeno, subject := a.GetTradeno(tradenoSign)
+	var bizByte []byte
+	methodStr := ""
+	if strings.ToUpper(tradenoSign) == tradenoSign { //app支付
+		bizContent := struct {
+			Subject        string  `json:"subject"`
+			OutTradeNo     string  `json:"out_trade_no"`
+			TotalAmount    float64 `json:"total_amount"`
+			ProductCode    string  `json:"product_code"`
+			TimeoutExpress string  `json:"timeout_express"`
+		}{
+			Subject:        subject,
+			OutTradeNo:     tradeno,
+			TotalAmount:    order_money / 100,
+			ProductCode:    "QUICK_MSECURITY_PAY",
+			TimeoutExpress: "2h",
+		}
+		bizByte, _ = json.Marshal(bizContent)
+		methodStr = "alipay.trade.app.pay"
+	} else { //扫码支付
+		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"`
+			Time_expire  string  `json:"time_expire"`
+		}{
+			Subject:      subject,
+			OutTradeNo:   tradeno,
+			TotalAmount:  order_money / 100,
+			ProductCode:  "FAST_INSTANT_TRADE_PAY",
+			Qr_pay_mode:  "4",
+			Qrcode_width: 250,
+			Time_expire:  time_expire,
+		}
+		bizByte, _ = json.Marshal(bizContent)
+		methodStr = "alipay.trade.page.pay"
+	}
+
+	var data = url.Values{}
+	data.Add("app_id", Alipay.Appid)
+	data.Add("method", methodStr)
+	data.Add("notify_url", a.CallBackUrl) //支付完成回调地址
+	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)
+	if strings.ToUpper(tradenoSign) == tradenoSign { //app支付
+		return data.Encode(), tradeno, nil
+	} else {
+		return a.Requseturl + "?" + data.Encode(), tradeno, nil
+	}
+}
+
+//校验回调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 *AliPayStruct) CloseOrder(tradeno string) bool {
+	toClose := struct {
+		OutTradeNo string `json:"out_trade_no"`
+	}{
+		OutTradeNo: tradeno,
+	}
+	bizbyte, err := json.Marshal(toClose)
+	if err != nil {
+		log.Println()
+		return false
+	}
+	var data = url.Values{}
+	data.Add("app_id", Alipay.Appid)
+	data.Add("method", "alipay.trade.close")
+	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())
+	log.Println(signContentBytes)
+	signature, err := a.getSign([]byte(signContentBytes))
+	if err != nil {
+		log.Println(tradeno, "获取签名出错", err)
+		return false
+	}
+	data.Add("sign", signature)
+
+	url := a.Requseturl + "?" + data.Encode()
+	//clien 优化
+	client := http.Client{Jar: nil}
+	req, _ := http.NewRequest("POST", url, nil)
+	res, err := client.Do(req)
+	if err != nil {
+		log.Printf("%s支付宝关闭订单  请求出错%v\n", tradeno, err)
+		return false
+	}
+	bArr, err := ioutil.ReadAll(res.Body)
+	if err != nil {
+		log.Printf("%s支付宝关闭订单  读取相应出错%v\n", tradeno, err)
+		return false
+	}
+	m := map[string]interface{}{}
+	err = json.Unmarshal(bArr, &m)
+	if err != nil {
+		log.Println(string(bArr))
+		log.Println("%s支付宝关闭订单   解析相应参数出错%v\n", tradeno, err)
+	}
+	msg := (*qutil.ObjToMap(m["alipay_trade_close_response"]))["sub_msg"]
+	log.Printf("%s msg:%s 订单关闭相应参数  %+v", tradeno, msg, m)
+	if msg == "交易状态不合法" || msg == "REASON_ILLEGAL_STATUS" { //已支付
+		return false
+	}
+	return true
+}

+ 75 - 0
src/jfw/modules/subscribepay/src/pay/util.go

@@ -0,0 +1,75 @@
+package pay
+
+import (
+	"crypto"
+	"crypto/rand"
+	"crypto/rsa"
+	"crypto/sha256"
+	"crypto/x509"
+	"encoding/base64"
+	"encoding/pem"
+	"errors"
+	"hash"
+	"strings"
+	"time"
+	qutil "qfw/util"
+	"fmt"
+)
+
+
+
+
+//创建订单号
+func GetOrderCode(id string) string {
+	return fmt.Sprintf("%s%s", time.Now().Format("150405"), qutil.GetRandom(6))
+}
+
+//加载秘钥
+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
+}

+ 225 - 0
src/jfw/modules/subscribepay/src/pay/wxPay.go

@@ -0,0 +1,225 @@
+package pay
+
+import (
+	"config"
+	"encoding/json"
+	"encoding/xml"
+	"fmt"
+	"log"
+	"net/rpc"
+	"qfw/util"
+	"time"
+)
+
+const (
+	WX_REWARD_JSAPI      = "a" //微信打赏
+	WX_DATAEXPORT_NATIVE = "b" //数据导出-扫码支付
+	WX_DATAEXPORT_JSAPI  = "c" //数据导出-微信js支付
+	WX_DATAEXPORT_APP    = "C" //数据导出-微信app支付
+	WX_DATAREPORT_JSAPI  = "d" //数据报告-微信js支付
+	WX_DATAREPORT_APP    = "D" //数据报告-微信app支付
+	WX_SUBVIP_JSAPI      = "e" //VIP订阅-js支付
+	WX_SUBVIP_APP        = "E" //VIP订阅-APP支付
+)
+
+var WxStruct *WeixinStruct
+
+type WeixinStruct struct {
+	Appid             string
+	Mchid             string
+	Appid_app         string //微信支付和app支付appid不一致
+	Key               string
+	Dashang_attachmsg string
+	Dashang_bodymsg   string
+	Dashang_detailmsg string
+	sjdc_msg          string
+	Sjbg_msg          string
+	Subvip_msg        string
+	OpenidSwitch      *map[string]interface{}
+}
+
+func init() {
+	payConfig := config.WxPayConf["pay"].(map[string]interface{})
+
+	WxStruct = &WeixinStruct{
+		Appid:             util.ObjToString(config.WxPayConf["appid"]),
+		Appid_app:         util.ObjToString(config.WxPayConf["appid_app"]),
+		Mchid:             util.ObjToString(payConfig["mchid"]),
+		Key:               util.ObjToString(payConfig["key"]),
+		Dashang_attachmsg: util.ObjToString(payConfig["attachmsg"]),
+		Dashang_bodymsg:   util.ObjToString(payConfig["bodymsg"]),
+		Dashang_detailmsg: util.ObjToString(payConfig["detailmsg"]),
+		sjdc_msg:          util.ObjToString(payConfig["sjdc_msg"]),
+		Sjbg_msg:          util.ObjToString(payConfig["sjbg_msg"]),
+		Subvip_msg:        util.ObjToString(payConfig["subvip_msg"]),
+		OpenidSwitch:      util.ObjToMap(config.WxPayConf["openidSwitch"]),
+	}
+}
+
+func (w *WeixinStruct) GetTradeno(tp string) string {
+	return fmt.Sprintf("%s_%d%s%s", tp, time.Now().UnixNano(), util.GetRandom(5), util.GetLetterRandom(6))
+}
+
+//tradeno a:打赏 b:pc端数据导出 c:移动端微信数据导出 C:app数据导出  d:微信端数据报告 D:app端数据报告
+func (w *WeixinStruct) CreatePrepayOrder(tradeno, ip, openid, detailmsg string, totalfee int) (string, *map[string]string) {
+	defer util.Catch()
+	notifyUrl := config.Config.WebDomain + "/jypay/callback/wxPay"
+	//获取支付标题
+	attachmsg, bodymsg := "", ""
+	if tradeno == WX_REWARD_JSAPI { //打赏
+		attachmsg, bodymsg = w.Dashang_attachmsg, w.Dashang_bodymsg
+	} else if tradeno == WX_DATAEXPORT_NATIVE || tradeno == WX_DATAEXPORT_JSAPI || tradeno == WX_DATAEXPORT_APP { //数据导出
+		attachmsg, bodymsg, detailmsg = w.sjdc_msg, w.sjdc_msg, w.sjdc_msg
+	} else if tradeno == WX_DATAREPORT_JSAPI || tradeno == WX_DATAREPORT_APP { //数据报告
+		attachmsg, bodymsg, detailmsg = w.Sjbg_msg, w.Sjbg_msg, w.Sjbg_msg
+	} else if tradeno == WX_SUBVIP_JSAPI || tradeno == WX_SUBVIP_APP { //vip订阅
+		attachmsg, bodymsg, detailmsg = w.Subvip_msg, w.Subvip_msg, w.Subvip_msg
+	}
+	//支付类型分类
+
+	tradeType,appid := "",w.Appid
+	if tradeno == WX_REWARD_JSAPI || tradeno == WX_DATAEXPORT_JSAPI || tradeno == WX_DATAREPORT_JSAPI || tradeno == WX_SUBVIP_JSAPI { //微信js支付
+		tradeType = "JSAPI"
+	} else if tradeno == WX_DATAEXPORT_APP || tradeno == WX_DATAREPORT_APP || tradeno == WX_SUBVIP_APP { //app支付
+		tradeType = "APP"
+		appid=w.Appid_app
+	} else if tradeno == WX_DATAEXPORT_NATIVE { //扫码支付
+		tradeType = "NATIVE"
+	}
+	tradeno = w.GetTradeno(tradeno)
+	//测试环境微信支付需要转换对应的正式环境的openid
+	if w.OpenidSwitch != nil {
+		if oid, ok := (*(w.OpenidSwitch))[openid]; ok {
+			openid = oid.(string)
+		}
+	}
+
+	//获取预订单号
+	ret, _ := w.GetPrepayId(config.Config.Weixinrpc, map[string]string{
+		"attachmsg":  attachmsg,
+		"bodymsg":    bodymsg,
+		"detailmsg":  detailmsg,
+		"useropenid": openid,
+		"tradeno":    tradeno,
+		"userip":     ip,
+		"totalfee":   fmt.Sprint(totalfee),
+		"mchid":      w.Mchid,
+		"key":        w.Key,
+		"notifyUrl":  notifyUrl,
+		"appid":      appid,
+		"tradeType":  tradeType, //NATIVE JSAPI APP
+	})
+	return tradeno, ret
+}
+
+//取得预生成订单编号,我们的系统要控制下,别订单重复了
+func (w *WeixinStruct) GetPrepayId(weixinrpc string, param map[string]string) (res *map[string]string, e error) {
+	util.Try(func() {
+		client, err := rpc.DialHTTP("tcp", weixinrpc)
+		defer client.Close()
+		if err != nil {
+			e = err
+			log.Println(err.Error())
+			return
+		}
+		var ret []byte
+		err = client.Call("WeiXinRpc.GetPrepayId", param, &ret)
+		if err != nil {
+			e = err
+			log.Println(err.Error())
+		} else {
+			json.Unmarshal(ret, &res)
+		}
+	}, func(e interface{}) {})
+	return
+}
+
+//微信支付订单关闭
+func (w *WeixinStruct) CloseOrder(weixinrpc, tradeno string) (r bool) {
+	util.Try(func() {
+		client, err := rpc.DialHTTP("tcp", weixinrpc)
+		defer client.Close()
+		if err != nil {
+			return
+		}
+		err = client.Call("WeiXinRpc.CloseOrder",
+			map[string]string{
+				"tradeno": tradeno,
+				"key":     w.Key,
+				"mchid":   w.Mchid,
+				"appid":   w.Appid,
+			}, &r)
+		if err != nil {
+			log.Println(err.Error())
+			return
+		}
+	}, func(e interface{}) {})
+	return r
+}
+
+//微信js支付获取支付参数
+func (w *WeixinStruct) GetWxjsPaySign(prepayid string) string {
+	timestamp := time.Now().Unix()
+	nonceStr := util.GetRandom(16) + util.GetLetterRandom(16)
+	sign := util.WxSign(fmt.Sprintf("appId=%s&nonceStr=%s&package=%s&signType=%s&timeStamp=%d&key=%s", w.Appid, nonceStr, "prepay_id="+prepayid, "MD5", timestamp, w.Key))
+	res := map[string]interface{}{
+		"appId":     w.Appid,
+		"timestamp": fmt.Sprint(timestamp),
+		"signType":  "MD5",
+		"sign":      sign,
+		"nonceStr":  nonceStr,
+		"prepayId":  "prepay_id=" + prepayid,
+	}
+	byteArr, _ := json.Marshal(res)
+	return string(byteArr)
+}
+
+//微信app支付 获取支付串
+func (wx *WeixinStruct) GetAppWxPayStr(prepayid string) string {
+	data := struct {
+		XMLName    xml.Name `xml:"xml"`
+		Appid      string   `xml:"appid"`
+		Partnerid  string   `xml:"partnerid"` //微信支付分配的商户号
+		Prepayid   string   `xml:"prepayid"`  //微信返回的支付交易会话ID
+		PackageStr string   `xml:"package"`   //暂填写固定值Sign=WXPay
+		Noncestr   string   `xml:"noncestr"`  //随机字符串,不长于32位。
+		Timestamp  string   `xml:"timestamp"` //时间戳
+		Sign       string   `xml:"sign"`      //签名
+	}{
+		Appid:      wx.Appid_app,
+		Partnerid:  wx.Mchid,
+		Prepayid:   prepayid,
+		PackageStr: "Sign=WXPay",
+		Noncestr:   util.GetRandom(16) + util.GetLetterRandom(16),
+		Timestamp:  fmt.Sprintf("%d", time.Now().Unix()),
+	}
+	data.Sign = util.CreateWxSign(fmt.Sprintf("&key=%s", wx.Key), data)
+
+	byteArr, err := json.Marshal(data)
+	if err != nil {
+		log.Printf("CreatePrepayOrder Marshal %v\n", err)
+		return ""
+	}
+	return string(byteArr)
+}
+//获取js支付参数(为方便存库返回string,前端需要转成json)
+func GetWxJsPayStr(prepayid string) string {
+	//获取订单支付字符串
+	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", WxStruct.Appid, nonceStr, "prepay_id="+prepayid, "MD5", timestamp, WxStruct.Key))
+	m := map[string]interface{}{
+		"appId":     WxStruct.Appid,
+		"timestamp": fmt.Sprint(timestamp),
+		"signType":  "MD5",
+		"sign":      sign,
+		"nonceStr":  nonceStr,
+		"prepayId":  "prepay_id=" + prepayid,
+	}
+	byteArr, err := json.Marshal(m)
+	if err != nil {
+		log.Println("GetWxJsPayStr ", err)
+		return ""
+	}
+	return string(byteArr)
+}

+ 31 - 0
src/jfw/modules/subscribepay/src/pay_config.json

@@ -0,0 +1,31 @@
+{
+	"wxPay": {
+        "appid": "wxd66e9589c9fecff6",
+        "appid_app": "wx0e6a5b18f4cfd10d",
+		"appsecret": "4d9d4b9ddab59e65fcb7bed125fbd342",
+		"pay": {
+			"mchid": "1418321102",
+			"key": "topnet2016topnet2016topnet2016ab",
+            "attachmsg": "剑鱼标讯打赏",
+            "bodymsg": "剑鱼标讯-招标信息打赏",
+            "detailmsg": "招标推送信息[%s] 打赏%s元钱",
+            "sjdc_msg": "剑鱼标讯-历史数据",
+            "sjbg_msg": "剑鱼标讯-数据报告",
+            "subvip_msg":"剑鱼标讯-vip订阅"
+        },
+        "openidSwitch": {
+            "oIMvJvrVXG89597EFmYiSiznbyyY": "oHwE_wEQlEBvjZJOyZeNnQcgKQMo",
+            "ouCYjw4BJMbpdMRYrTTLb9nFi2RE": "oHwE_wNA1V0DURDO0h7wAriz0qIY",
+            "oIMvJvhl7CntkeLe3jEukHWhuKRc":"oHwE_wPk1VERbfcK2GRYtFWaStpk"
+        }
+    },
+    "aliPay": {
+        "appid": "2019062465625929",
+        "reqUrl":"https://openapi.alipay.com/gateway.do",
+        "Subject_sjdc": "剑鱼数据导出",
+        "Subject_sjbg": "剑鱼数据报告",
+        "Subject_subvip": "剑鱼VIP订阅",
+        "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":"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqFZfev75+sa7O0f29qwuWeqWRQ+p59c8hz2s4aeh5Ohc08P1ls5e8UmPhaN9ZTkGwabOKN658pOhmVoa16ldKFZQ5j1hLTDS6yfKcvVs/hf1mQvsbUjtZgCfMQx5NNf1R4MsTvAqbl2l6DXMu7gHjAhKNR0QQBELv7HmYuWPE35ELQqBH0eVcvWSNV3/3zOansftY5NIT749B+Bv1uirE8PNMp20sWWqx8fMNi2EZksnWNUmnVldBqUwMJIxcXolBH/RGX5ZjBlBenoIB3PVQ8/+SPz9Hip7+QNH8utSnUlrh2AsJVtdNKIQk74Eevkn+Q+WyUVGoY0ca9DzGwh4hQIDAQAB"
+    }
+}

+ 58 - 0
src/jfw/modules/subscribepay/src/rpc/rpc.go

@@ -0,0 +1,58 @@
+package rpc
+
+/*
+//数据导出线下支付完成调用
+func (c *MyfollowRpc) DateExportOrderFinishByOffline(param *frpc.DateExportData, ret *string) error {
+	log.Println("DateExportOrderFinishByOffline---", param)
+	util.Try(func() {
+		*ret = "1"
+		//查询订单
+		orderdata := public.Mysql.FindOne("dataexport_order", map[string]interface{}{
+			"order_code": param.OrderCode,
+		}, "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", "")
+
+		if orderdata == nil {
+			*ret = "order_nofind"
+			return
+		}
+		if util.Int64All((*orderdata)["order_status"]) != 0 {
+			*ret = "order_errStat"
+			return
+		}
+		//插入数据
+		now := time.Now()
+		pay_time := util.FormatDate(&now, util.Date_Full_Layout)
+
+		insertNum := public.Mysql.Insert("offline_pay", map[string]interface{}{
+			"out_trade_no": (*orderdata)["out_trade_no"],
+			"create_time":  pay_time,
+			"img_src":      param.ImgSrc,
+		})
+		if insertNum == 0 {
+			*ret = "order_errInsert"
+			return
+		}
+		//修改订单状态
+		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)
+		updateNum := public.Mysql.Update("dataexport_order", map[string]interface{}{
+			"order_code": param.OrderCode,
+		}, map[string]interface{}{
+			"pay_time":     pay_time,
+			"order_status": 1,
+			"pay_way":      "线下支付",
+			"download_url": download_url,
+		})
+		if !updateNum {
+			*ret = "order_errUpdate"
+			return
+		}
+		*ret = "y"
+		order_money := util.IntAll((*orderdata)["order_money"])
+		ordermoney := float64(order_money) / 100
+		go public.SendNotice(orderdata, ordermoney, pay_time, download_url, config.GmailAuth)
+		go public.SendMailToPayUser(orderdata, ordermoney, pay_time, filename, download_url, config.GmailAuth)
+		go public.SendMailToBJFinance(orderdata, pay_time, "", 1, config.GmailAuth)
+	}, func(e interface{}) {})
+	return nil
+}*/

+ 108 - 0
src/jfw/modules/subscribepay/src/service/commonAction.go

@@ -0,0 +1,108 @@
+package service
+
+import (
+	"config"
+	"entity"
+	"github.com/go-xweb/xweb"
+	qutil "qfw/util"
+	"time"
+	"util"
+)
+
+//付费公用方法
+type CommonAction struct {
+	*xweb.Action
+	applyInvoice xweb.Mapper `xweb:"/applyInvoice"`          //申请发票
+	isPaySuccess xweb.Mapper `xweb:"/isPaySuccess"`          //数据导出是否支付成功
+	paySuccess   xweb.Mapper `xweb:"/dataReport/paySuccess"` //数据报告支付完成
+}
+
+//----------------------------申请发票------------------------------------
+func (d *CommonAction) ApplyInvoice() error {
+	var applyBill_status int
+	var order_code, applyBill_company, applyBill_taxnum, applyBill_type string
+	var updateBl bool = false
+	order_code = d.GetString("order_code")
+	//获取数据
+	applyBill_type = d.GetString("demo-radio") //个人 单位
+	queryMap := map[string]interface{}{
+		"order_code": order_code,
+	}
+	if applyBill_type == "个人" {
+		applyBill_status = 1
+		updateBl = util.Mysql.Update("dataexport_order", queryMap, map[string]interface{}{"applyBill_status": applyBill_status})
+
+	} else if applyBill_type == "单位" {
+		applyBill_status = 1                                 //状态
+		applyBill_company = d.GetString("applyBill_company") //公司名
+		applyBill_taxnum = d.GetString("applyBill_taxnum")   //纳税人识别号
+		updateBl = util.Mysql.Update("dataexport_order", queryMap, map[string]interface{}{
+			"applyBill_company": applyBill_company,
+			"applyBill_taxnum":  applyBill_taxnum,
+			"applyBill_status":  applyBill_status,
+			"applyBill_type":    1,
+		})                                                   //修改操作
+	}
+	//判断条件
+	if updateBl {
+		go func() {
+			orderdata := util.Mysql.FindOne("dataexport_order", map[string]interface{}{
+				"order_code": order_code,
+			}, "id,filter,user_mail,user_phone,product_type,data_spec,filter_id,order_code,data_count,order_status,order_money,out_trade_no,applybill_type,applybill_company,applybill_taxnum,user_openid,create_time,pay_time,pay_way", "")
+			tt := time.Now()
+			pay_time := qutil.FormatDate(&tt, qutil.Date_Full_Layout)
+			entity.SendMailToBJFinance(orderdata, pay_time, "", 2, config.GmailAuth)
+		}()
+	}
+	d.ServeJson(map[string]interface{}{
+		"flag": updateBl,
+	})
+	return nil
+}
+
+//数据导出-是否支付完成
+func (p *CommonAction) IsPaySuccess() {
+	defer qutil.Catch()
+	code := p.GetString("code")
+	userId, _ := p.GetSession("userId").(string)
+	if code != "" || userId != "" {
+		data := util.Mysql.FindOne("dataexport_order", map[string]interface{}{
+			"order_code": code,
+			"user_id":    userId,
+		}, "order_status,pay_time,user_mail,pay_way", "")
+		if data != nil && qutil.IntAll((*data)["order_status"]) == 1 {
+			t, _ := time.ParseInLocation(qutil.Date_Full_Layout, qutil.ObjToString((*data)["pay_time"]), time.Local)
+			pay_way := "微信"
+			if qutil.ObjToString((*data)["pay_way"]) == "ali_app" {
+				pay_way = "支付宝"
+			}
+			p.ServeJson(map[string]interface{}{
+				"success":   true,
+				"email":     qutil.ObjToString((*data)["user_mail"]),
+				"payTime":   t.Unix(),
+				"pay_way":   pay_way,
+				"orderCode": code,
+			})
+		}
+	}
+	p.ServeJson(map[string]interface{}{
+		"success": false,
+	})
+}
+
+//数据报告-是否支付完成
+func (d *CommonAction) PaySuccess() {
+	userId := qutil.ObjToString(d.GetSession("userId"))
+	payOrderId := d.GetString("payOrderId")
+	success := false
+	orderdata := util.Mysql.FindOne("jy_datareport_order", map[string]interface{}{
+		"user_id": userId,
+		"id":      payOrderId,
+	}, "order_status", "")
+	if orderdata != nil && qutil.IntAll((*orderdata)["order_status"]) == 1 {
+		success = true
+	}
+	d.ServeJson(map[string]interface{}{
+		"success": success,
+	})
+}

+ 602 - 0
src/jfw/modules/subscribepay/src/service/dataExportPay_mobile.go

@@ -0,0 +1,602 @@
+package service
+
+import (
+	"bytes"
+	"encoding/json"
+	"entity"
+	"fmt"
+
+	"pay"
+
+	"github.com/go-xweb/xweb"
+	"log"
+	qutil "qfw/util"
+	"time"
+	"util"
+)
+
+var local, _ = time.LoadLocation("Local")
+
+type DataExportPayMobile struct {
+	*xweb.Action
+	createOrder           xweb.Mapper `xweb:"/dataExport/app/createOrder"`    //创建订单——支付
+	wxSacnPay_CreateOrder xweb.Mapper `xweb:"/dataExport/weixin/createOrder"` //微信端-创建订单
+	getPayParm            xweb.Mapper `xweb:"/dataExport/weixin/getPayParm"`  //微信数据导出-获取微信支付参数
+}
+
+func (p *DataExportPayMobile) CreateOrder() {
+	defer qutil.Catch()
+	userId, _ := p.GetSession("userId").(string)
+	openId, _ := p.GetSession("s_m_openid").(string)
+	pay_way := p.GetString("pay_way")
+
+	payStr, ordercode, errMsg, ok := func() (string, string, string, bool) {
+		id := qutil.SE.Decode4Hex(p.GetString("id"))
+		if userId == "" || id == "" || !(pay_way == "wx_app" || pay_way == "ali_app") {
+			return "", "", fmt.Sprintf("请求出错 id:%s,pay_way:%s \n", id, pay_way), false
+		}
+		data_spec := p.GetString("data_spec")
+		if data_spec == "standard" {
+			data_spec = "标准字段包"
+		} else if data_spec == "senior" {
+			data_spec = "高级字段包"
+		}
+		user_mail_status := qutil.ObjToString(p.GetSession("DataExportVerifyEmail_val")) != ""
+		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 := util.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,pay_way,code_url,user_openid", "")
+
+		//非新订单
+		if oldOrder != nil {
+			if user_mail != "" && user_mail != qutil.ObjToString((*oldOrder)["user_mail"]) {
+				util.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 != qutil.ObjToString((*oldOrder)["user_phone"]) {
+				util.Mysql.Update("dataexport_order", map[string]interface{}{
+					"user_id":   userId,
+					"filter_id": id,
+				}, map[string]interface{}{
+					"user_phone": user_phone,
+				})
+			}
+			if qutil.IntAll((*oldOrder)["order_status"]) != 0 {
+				return "", "", fmt.Sprintf("该订单已存在,订单状态不允许支付!"), false
+			}
+			//订单未超时两小时内 订单未改变
+			local, _ := time.LoadLocation("Local")
+			prepayTime, _ := time.ParseInLocation(qutil.Date_Full_Layout, qutil.ObjToString((*oldOrder)["prepay_time"]), local)
+			now := time.Now()
+			if data_spec != "" && data_spec == qutil.ObjToString((*oldOrder)["data_spec"]) && qutil.ObjToString((*oldOrder)["pay_way"]) == pay_way && now.Before(prepayTime.Add(time.Hour*2)) {
+				log.Println("支付取数据库")
+				return qutil.ObjToString((*oldOrder)["code_url"]), qutil.ObjToString((*oldOrder)["order_code"]), "", true
+			} else {
+				//价格变动需重新生预支付订单 更新原来得库的信息
+				data_count := entity.GetDataExportSearchCountUseId(id)
+				if data_count > entity.ExConf.MsgMaxCount {
+					data_count = entity.ExConf.MsgMaxCount
+				}
+				order_money_, original_price_ := float64(0), float64(0)
+				if data_spec == "标准字段包" {
+					original_price_ = float64(data_count) * entity.ExConf.UnitPrice_normal
+				} else if data_spec == "高级字段包" {
+					original_price_ = float64(data_count) * entity.ExConf.UnitPrice_senior
+				}
+				order_money_ = float64(original_price_) * entity.ExConf.Discount
+				if order_money_ < entity.ExConf.OrderMinPrice {
+					order_money_ = entity.ExConf.OrderMinPrice
+				}
+				if original_price_ < entity.ExConf.OrderMinPrice {
+					original_price_ = entity.ExConf.OrderMinPrice
+				}
+				order_money := int(order_money_ * 100)
+				original_price := int(original_price_ * 100)
+				payStr, tradeno, prepayid := "", "", ""
+				if pay_way == "wx_app" {
+					var ret *map[string]string
+					tradeno, ret = pay.WxStruct.CreatePrepayOrder("C", p.IP(), "", "", order_money)
+					if ret == nil || (*ret)["status"] != "1" {
+						return "", "", fmt.Sprintf("%s生成订单出错", pay_way), false
+					}
+					prepayid = qutil.ObjToString((*ret)["prepayid"])
+					payStr = pay.WxStruct.GetAppWxPayStr(prepayid)
+					if payStr == "" {
+						return "", "", fmt.Sprintf("%s生成签名出错出错", pay_way), false
+					}
+				} else if pay_way == "ali_app" {
+					var err error
+					payStr, tradeno, err = pay.Alipay.GetOrderPayParam((qutil.Float64All(order_money)), "", pay.ALI_DATAEXPORT_APP)
+					if err != nil {
+						return "", "", fmt.Sprintf("支付宝订单生成出错%v"), false
+					}
+				}
+
+				//更新数据库
+				if util.Mysql.Update("dataexport_order", map[string]interface{}{
+					"user_id":   userId,
+					"filter_id": id,
+				}, map[string]interface{}{
+					"data_spec":      data_spec,
+					"order_money":    order_money,
+					"original_price": original_price,
+					"prepay_time":    qutil.FormatDate(&now, qutil.Date_Full_Layout),
+					"pay_way":        pay_way,
+					"prepay_id":      prepayid,
+					"code_url":       payStr,
+					"out_trade_no":   tradeno,
+				}) {
+					//(*oldOrder)["order_money"] = order_money
+					return payStr, qutil.ObjToString((*oldOrder)["order_code"]), "", true
+				} else {
+					return "", "", fmt.Sprintf("更新数据库状态出错"), false
+				}
+			}
+		}
+
+		data_count := entity.GetDataExportSearchCountUseId(id)
+		if data_count > entity.ExConf.MsgMaxCount {
+			data_count = entity.ExConf.MsgMaxCount
+		}
+		order_money_, original_price_ := float64(0), float64(0)
+		if data_spec == "标准字段包" {
+			original_price_ = float64(data_count) * entity.ExConf.UnitPrice_normal
+		} else if data_spec == "高级字段包" {
+			original_price_ = float64(data_count) * entity.ExConf.UnitPrice_senior
+		}
+		order_money_ = float64(original_price_) * entity.ExConf.Discount
+		if order_money_ < entity.ExConf.OrderMinPrice {
+			order_money_ = entity.ExConf.OrderMinPrice
+		}
+		if original_price_ < entity.ExConf.OrderMinPrice {
+			original_price_ = entity.ExConf.OrderMinPrice
+		}
+		order_money := int(order_money_ * 100)
+		original_price := int(original_price_ * 100)
+
+		filter_keys, filter_publishtime, filter := "", "", ""
+
+		isPass := func() bool {
+			if 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 := util.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(qutil.ObjToString(vm["keyword"]))
+				}
+				filter_keys = buffer.String()
+				filter_publishtime = qutil.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
+		}()
+
+		if !isPass {
+			return "", "", "创建新订单参数异常", false
+		}
+
+		prepayid, payStr, tradeno := "", "", ""
+		if pay_way == "wx_app" {
+			var ret *map[string]string
+			tradeno, ret = pay.WxStruct.CreatePrepayOrder("C", p.IP(), "", "", order_money)
+			if ret == nil || (*ret)["status"] != "1" {
+				return "", "", fmt.Sprintf("%s创建订单出错", pay_way), false
+			}
+			prepayid = qutil.ObjToString((*ret)["prepayid"])
+			payStr = pay.WxStruct.GetAppWxPayStr(qutil.ObjToString((*ret)["prepayid"]))
+			if payStr == "" {
+				return "", "", fmt.Sprintf("%s创建订单生成签名出错", pay_way), false
+			}
+		} else if pay_way == "ali_app" {
+			var err error
+			payStr, tradeno, err = pay.Alipay.GetOrderPayParam((qutil.Float64All(order_money)), "", pay.ALI_DATAEXPORT_APP)
+			if err != nil {
+				return "", "", fmt.Sprintf("支付宝订单生成出错%v"), false
+			}
+		}
+		nickname, _ := p.GetSession("s_nickname").(string)
+		now := time.Now()
+		code := pay.GetOrderCode(userId)
+		orderid := util.Mysql.Insert("dataexport_order", map[string]interface{}{
+			"order_money":        order_money,
+			"order_status":       0,
+			"service_status":     0,
+			"user_nickname":      nickname,
+			"filter":             filter,
+			"prepay_id":          prepayid,
+			"code_url":           payStr,
+			"out_trade_no":       tradeno,
+			"order_code":         code,
+			"product_type":       "历史数据",
+			"create_time":        qutil.FormatDate(&now, qutil.Date_Full_Layout),
+			"prepay_time":        qutil.FormatDate(&now, qutil.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
+			"user_openid":        openId,
+		})
+		if orderid == 0 {
+			return "", "", fmt.Sprintf("数据插入出错"), false
+		}
+		return payStr, code, "", true
+	}()
+	if errMsg != "" {
+		log.Println(userId, errMsg)
+	}
+	p.ServeJson(map[string]interface{}{
+		"success": ok,
+		"data":    payStr,
+		"order":   ordercode,
+	})
+}
+
+//微信端创建订单
+func (p *DataExportPayMobile) WxSacnPay_CreateOrder() {
+	defer qutil.Catch()
+	openId, _ := p.GetSession("s_m_openid").(string)
+	userId, _ := p.GetSession("userId").(string)
+	pay_way := p.GetString("pay_way")
+	id := qutil.SE.Decode4Hex(p.GetString("id"))
+	if userId == "" || id == "" || pay_way != "wx_js" {
+		log.Println("userId,id,pay_way错误", userId, id, pay_way)
+		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 := qutil.ObjToString(p.GetSession("DataExportVerifyEmail_val")) != ""
+
+	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 := util.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,pay_way,out_trade_no", "")
+	if oldOrder != nil {
+		if user_mail != "" && user_mail != qutil.ObjToString((*oldOrder)["user_mail"]) {
+			util.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 != qutil.ObjToString((*oldOrder)["user_phone"]) {
+			util.Mysql.Update("dataexport_order", map[string]interface{}{
+				"user_id":   userId,
+				"filter_id": id,
+			}, map[string]interface{}{
+				"user_phone": user_phone,
+			})
+		}
+		//如果已支付,则返回
+		if qutil.IntAll((*oldOrder)["order_status"]) != 0 {
+			log.Println("该订单已存在,订单状态不允许支付!", openId)
+			p.ServeJson(map[string]interface{}{
+				"status": "n",
+			})
+			return
+		}
+		var res map[string]interface{}
+		if data_spec != "" && data_spec == qutil.ObjToString((*oldOrder)["data_spec"]) && qutil.ObjToString((*oldOrder)["pay_way"]) == "wx_js" {
+			//订单未改变
+			nonceStr := qutil.GetRandom(16) + qutil.GetLetterRandom(16)
+			timestamp := time.Now().Unix()
+			sign := qutil.WxSign(fmt.Sprintf("appId=%s&nonceStr=%s&package=%s&signType=%s&timeStamp=%d&key=%s", pay.WxStruct.Appid, nonceStr, "prepay_id="+qutil.ObjToString((*oldOrder)["prepay_id"]), "MD5", timestamp, pay.WxStruct.Key))
+			res = map[string]interface{}{
+				"appId":     pay.WxStruct.Appid,
+				"timestamp": fmt.Sprint(timestamp),
+				"signType":  "MD5",
+				"sign":      sign,
+				"nonceStr":  nonceStr,
+				"prepayId":  "prepay_id=" + qutil.ObjToString((*oldOrder)["prepay_id"]),
+			}
+		} else {
+			//在此关闭之前的订单
+			if !CloseDataExportOrder(qutil.ObjToString((*oldOrder)["pay_way"]), qutil.ObjToString((*oldOrder)["out_trade_no"]), qutil.ObjToString((*oldOrder)["prepay_time"])) {
+				p.ServeJson(map[string]interface{}{
+					"status": "n",
+				})
+				return
+			}
+			//价格变动需重新生预支付订单 更新原来得库的信息
+			data_count := entity.GetDataExportSearchCountUseId(id)
+			if data_count > entity.ExConf.MsgMaxCount {
+				data_count = entity.ExConf.MsgMaxCount
+			}
+			order_money_, original_price_ := float64(0), float64(0)
+			if data_spec == "标准字段包" {
+				original_price_ = float64(data_count) * entity.ExConf.UnitPrice_normal
+			} else if data_spec == "高级字段包" {
+				original_price_ = float64(data_count) * entity.ExConf.UnitPrice_senior
+			}
+			order_money_ = float64(original_price_) * entity.ExConf.Discount
+			if order_money_ < entity.ExConf.OrderMinPrice {
+				order_money_ = entity.ExConf.OrderMinPrice
+			}
+			if original_price_ < entity.ExConf.OrderMinPrice {
+				original_price_ = entity.ExConf.OrderMinPrice
+			}
+			order_money := int(order_money_ * 100)
+			original_price := int(original_price_ * 100)
+			now := time.Now()
+			tradeno, ret := pay.WxStruct.CreatePrepayOrder("c", p.IP(), openId, "", order_money)
+			nonceStr := qutil.GetRandom(16) + qutil.GetLetterRandom(16)
+			timestamp := time.Now().Unix()
+			sign := qutil.WxSign(fmt.Sprintf("appId=%s&nonceStr=%s&package=%s&signType=%s&timeStamp=%d&key=%s", pay.WxStruct.Appid, nonceStr, "prepay_id="+qutil.ObjToString((*ret)["prepayid"]), "MD5", timestamp, pay.WxStruct.Key))
+			res = map[string]interface{}{
+				"appId":     pay.WxStruct.Appid,
+				"timestamp": fmt.Sprint(timestamp),
+				"signType":  "MD5",
+				"sign":      sign,
+				"nonceStr":  nonceStr,
+				"prepayId":  "prepay_id=" + qutil.ObjToString((*ret)["prepayid"]),
+			}
+			util.Mysql.Update("dataexport_order", map[string]interface{}{
+				"user_id":   userId,
+				"filter_id": id,
+			}, map[string]interface{}{
+				"data_spec":      data_spec,
+				"order_money":    order_money,
+				"original_price": original_price,
+				"prepay_time":    qutil.FormatDate(&now, qutil.Date_Full_Layout),
+				"pay_way":        pay_way,
+				"prepay_id":      (*ret)["prepayid"],
+				"code_url":       (*ret)["codeurl"],
+				"out_trade_no":   tradeno,
+			})
+			(*oldOrder)["order_money"] = order_money
+		}
+		p.ServeJson(map[string]interface{}{
+			"status": "y",
+			"code":   qutil.ObjToString((*oldOrder)["order_code"]),
+			"token":  entity.GetWaitPayToken(qutil.Int64All((*oldOrder)["id"]), qutil.IntAll((*oldOrder)["order_money"]), qutil.ObjToString((*oldOrder)["order_code"]), pay_way, userId),
+			"res":    res,
+		})
+		return
+	}
+	//
+	data_count := entity.GetDataExportSearchCountUseId(id)
+	if data_count > entity.ExConf.MsgMaxCount {
+		data_count = entity.ExConf.MsgMaxCount
+	}
+	order_money_, original_price_ := float64(0), float64(0)
+	if data_spec == "标准字段包" {
+		original_price_ = float64(data_count) * entity.ExConf.UnitPrice_normal
+	} else if data_spec == "高级字段包" {
+		original_price_ = float64(data_count) * entity.ExConf.UnitPrice_senior
+	}
+	order_money_ = float64(original_price_) * entity.ExConf.Discount
+	if order_money_ < entity.ExConf.OrderMinPrice {
+		order_money_ = entity.ExConf.OrderMinPrice
+	}
+	if original_price_ < entity.ExConf.OrderMinPrice {
+		original_price_ = entity.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 := util.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(qutil.ObjToString(vm["keyword"]))
+			}
+			filter_keys = buffer.String()
+			filter_publishtime = qutil.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 := pay.WxStruct.CreatePrepayOrder("c", p.IP(), openId, "", order_money)
+		log.Println("支付交易单", openId, ret)
+		if ret != nil && (*ret)["status"] == "1" {
+			now := time.Now()
+			ordercode := pay.GetOrderCode(openId)
+			orderid := util.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":        qutil.FormatDate(&now, qutil.Date_Full_Layout),
+				"prepay_time":        qutil.FormatDate(&now, qutil.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 := qutil.GetRandom(16) + qutil.GetLetterRandom(16)
+				timestamp := time.Now().Unix()
+				sign := qutil.WxSign(fmt.Sprintf("appId=%s&nonceStr=%s&package=%s&signType=%s&timeStamp=%d&key=%s", pay.WxStruct.Appid, nonceStr, "prepay_id="+qutil.ObjToString((*ret)["prepayid"]), "MD5", timestamp, pay.WxStruct.Key))
+				res = map[string]interface{}{
+					"appId":     pay.WxStruct.Appid,
+					"timestamp": fmt.Sprint(timestamp),
+					"signType":  "MD5",
+					"sign":      sign,
+					"nonceStr":  nonceStr,
+					"prepayId":  "prepay_id=" + qutil.ObjToString((*ret)["prepayid"]),
+				}
+				p.SetSession("DataExportVerifyPhone_val", user_phone)
+				result["status"] = "y"
+				result["code"] = ordercode
+				result["token"] = entity.GetWaitPayToken(orderid, order_money, ordercode, pay_way, userId)
+				result["res"] = res
+			}
+		} else {
+			log.Println("生成微信预支付交易单失败", ret)
+		}
+	}
+	p.ServeJson(result)
+}
+
+//
+func (w *DataExportPayMobile) GetPayParm() error {
+	defer qutil.Catch()
+	userid := qutil.ObjToString(w.GetSession("userId"))
+	openid := qutil.ObjToString(w.GetSession("s_m_openid"))
+	filterid := qutil.SE.Decode4Hex(w.GetString("filterid"))
+	id := w.GetString("id")
+	if userid == "" || openid == "" || id == "" {
+		log.Println("userid,id 有误!")
+		w.ServeJson(map[string]interface{}{
+			"status": 0,
+		})
+		return nil
+	}
+	token := w.GetString("token")
+	//查看创建过的预支付订单
+	Order := util.Mysql.FindOne("dataexport_order", map[string]interface{}{
+		"user_id":   userid,
+		"filter_id": filterid,
+		"id":        id,
+	}, "prepay_id,order_code,order_money,id,prepay_time,pay_way,out_trade_no,user_mail", "")
+	if Order == nil {
+		log.Println("查不到订单!")
+		w.ServeJson(map[string]interface{}{
+			"status": -1,
+		})
+		return nil
+	}
+	prepayId := qutil.ObjToString((*Order)["prepay_id"])
+	//	if prepayId == "" {
+	//		log.Println("订单有误!")
+	//		w.ServeJson(map[string]interface{}{
+	//			"status": -2,
+	//		})
+	//		return nil
+	//	}
+	pay_way := qutil.ObjToString((*Order)["pay_way"])
+	order_code := qutil.ObjToString((*Order)["order_code"])
+	orderid := qutil.Int64All((*Order)["id"])
+	orderMoney := qutil.IntAll((*Order)["order_money"])
+	user_mail := qutil.ObjToString((*Order)["user_mail"])
+
+	realToken := entity.GetWaitPayToken(orderid, orderMoney, order_code, pay_way, userid)
+	if realToken != token && pay_way == "wx_js" {
+		log.Println("token错误!", userid, realToken, token, order_code, orderMoney, orderid, pay_way)
+		return nil
+	}
+	prepayTime, err := time.ParseInLocation(qutil.Date_Full_Layout, qutil.ObjToString((*Order)["prepay_time"]), time.Local)
+	surplus_second := prepayTime.Unix() + 7200 - time.Now().Unix()
+	if (err == nil && surplus_second <= 0) || prepayId == "" || pay_way != "wx_js" {
+		//在此关闭之前的订单
+		/*if !pay.CloseDataExportOrder(util.ObjToString((*Order)["pay_way"]), util.ObjToString((*Order)["out_trade_no"]), util.ObjToString((*Order)["prepay_time"])) {
+			w.ServeJson(map[string]interface{}{
+				"status": "n",
+			})
+			return nil
+		}*/
+		log.Println("订单过期或支付pc端订单,重新生成预订单!", userid)
+		tradeno, ret := pay.WxStruct.CreatePrepayOrder("c", w.IP(), openid, "", orderMoney)
+		if ret != nil {
+			now := time.Now()
+			if util.Mysql.Update("dataexport_order", map[string]interface{}{
+				"id": orderid,
+			}, map[string]interface{}{
+				"prepay_time":  qutil.FormatDate(&now, qutil.Date_Full_Layout),
+				"prepay_id":    (*ret)["prepayid"],
+				"out_trade_no": tradeno,
+				"pay_way":      "wx_js",
+			}) {
+				prepayId = (*ret)["prepayid"]
+			}
+		}
+	}
+	timestamp := time.Now().Unix()
+	nonceStr := qutil.GetRandom(16) + qutil.GetLetterRandom(16)
+	sign := qutil.WxSign(fmt.Sprintf("appId=%s&nonceStr=%s&package=%s&signType=%s&timeStamp=%d&key=%s", pay.WxStruct.Appid, nonceStr, "prepay_id="+prepayId, "MD5", timestamp, pay.WxStruct.Key))
+	w.ServeJson(map[string]interface{}{
+		"status":     1,
+		"appId":      pay.WxStruct.Appid,
+		"timestamp":  fmt.Sprint(timestamp),
+		"signType":   "MD5",
+		"sign":       sign,
+		"nonceStr":   nonceStr,
+		"prepayId":   "prepay_id=" + prepayId,
+		"order_code": order_code,
+		"user_mail":  user_mail,
+	})
+	return nil
+}

+ 483 - 0
src/jfw/modules/subscribepay/src/service/dataExportPay_pc.go

@@ -0,0 +1,483 @@
+package service
+
+import (
+	"bytes"
+	"config"
+	"encoding/base64"
+	"encoding/json"
+	"entity"
+	"log"
+	"pay"
+	"regexp"
+	"time"
+	"util"
+
+	"github.com/SKatiyar/qr"
+	"github.com/go-xweb/xweb"
+
+	qutil "qfw/util"
+)
+
+type DataExportPayPC struct {
+	*xweb.Action
+	waitPayMsg            xweb.Mapper `xweb:"/dataExport/sacnPay/waitPayMsg"`     //pc端创建订单获取二维码 前后端分离
+	sacnPay_CreateOrder   xweb.Mapper `xweb:"/dataExport/sacnPay/createOrder"`    //pc端生成数据导出订单
+	getOrderPayMsg        xweb.Mapper `xweb:"/dataexport/getOrderPayMsg"`         //我的订单页面获取支付二维码
+}
+
+var reg *regexp.Regexp //匹配特殊字符
+
+func init() {
+	xweb.AddAction(&DataExportPayPC{})
+	reg, _ = regexp.Compile("[^A-Za-z0-9\u4e00-\u9fa5]")
+}
+
+//pc端创建订单获取二维码 前后端分离
+func (p *DataExportPayPC) WaitPayMsg() {
+	defer qutil.Catch()
+	openid, _ := p.GetSession("s_m_openid").(string)
+	userId, _ := p.GetSession("userId").(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 := util.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 qutil.IntAll((*data)["order_status"]) != 0 {
+			log.Println("订单状态不允许支付!", openid)
+			return 0, 0, "", ""
+		}
+		orderid := qutil.Int64All((*data)["id"])
+		orderMoney := qutil.IntAll((*data)["order_money"])
+		//orderMoney = 1
+		pay_way := qutil.ObjToString((*data)["pay_way"])
+		realToken := entity.GetWaitPayToken(orderid, orderMoney, code, pay_way, userId)
+		if realToken != token {
+			log.Println("token错误!", openid, realToken, token)
+			return 0, 0, "", ""
+		}
+		prepayTime, err := time.ParseInLocation(qutil.Date_Full_Layout, qutil.ObjToString((*data)["prepay_time"]), time.Local)
+		surplus_second := prepayTime.Unix() + 7200 - time.Now().Unix()
+		codeUrl := qutil.ObjToString((*data)["code_url"])
+		if err == nil && surplus_second <= 0 { //重新生成预订单
+			log.Println("二维码已失效,重新生成预订单!", openid)
+			surplus_second = 0
+			now := time.Now()
+			if pay_way == "wx_pc" {
+				tradeno, ret := pay.WxStruct.CreatePrepayOrder("b", p.IP(), openid, "", orderMoney)
+				if ret != nil {
+					if util.Mysql.Update("dataexport_order", map[string]interface{}{
+						"id": orderid,
+					}, map[string]interface{}{
+						"prepay_time":  qutil.FormatDate(&now, qutil.Date_Full_Layout),
+						"prepay_id":    (*ret)["prepayid"],
+						"code_url":     (*ret)["codeurl"],
+						"out_trade_no": tradeno,
+					}) {
+						surplus_second = 7200
+						codeUrl = qutil.ObjToString((*ret)["codeurl"])
+					}
+				}
+			} else if pay_way == "ali_pc" {
+				payOutTime := now.Add(time.Hour * 2)
+				if qr_url, tradeno, err := pay.Alipay.GetOrderPayParam(qutil.Float64All(orderMoney), qutil.FormatDate(&payOutTime, qutil.Date_Full_Layout), pay.ALI_DATAEXPORT_NATIVE); err == nil {
+					if util.Mysql.Update("dataexport_order", map[string]interface{}{
+						"id": orderid,
+					}, map[string]interface{}{
+						"prepay_time":  qutil.FormatDate(&now, qutil.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 == "wx_pc" {
+		r, _ := qr.Encode(qrcode, qr.M)
+		pngdat := r.PNG()
+		qrcode = base64.StdEncoding.EncodeToString(pngdat)
+	}
+	p.ServeJson(map[string]interface{}{
+		"money":          float64(money) / 100,
+		"surplus_second": surplus,
+		"qrcode":         qrcode,
+		"ordercode":      code,
+		"pay_way":        pay_way,
+	})
+}
+
+
+//pc端生成数据导出订单
+func (p *DataExportPayPC) SacnPay_CreateOrder() {
+	defer qutil.Catch()
+	openId, _ := p.GetSession("s_m_openid").(string)
+	userId, _ := p.GetSession("userId").(string)
+	id := qutil.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")
+	if data_spec == "standard" {
+		data_spec = "标准字段包"
+	} else if data_spec == "senior" {
+		data_spec = "高级字段包"
+	}
+	user_mail_status := qutil.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 := util.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,pay_way,out_trade_no", "")
+	if oldOrder != nil {
+		if user_mail != "" && user_mail != qutil.ObjToString((*oldOrder)["user_mail"]) {
+			util.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 != qutil.ObjToString((*oldOrder)["user_phone"]) {
+			util.Mysql.Update("dataexport_order", map[string]interface{}{
+				"user_id":   userId,
+				"filter_id": id,
+			}, map[string]interface{}{
+				"user_phone": user_phone,
+			})
+		}
+		//如果已支付,则返回
+		if qutil.IntAll((*oldOrder)["order_status"]) != 0 {
+			log.Println("该订单已存在,订单状态不允许支付!", openId)
+			p.ServeJson(map[string]interface{}{
+				"status": "n",
+			})
+			return
+		}
+		//价格支付方式变动需要重新生成订单二维码(关闭之前的订单)
+		if (data_spec != "" && data_spec != qutil.ObjToString((*oldOrder)["data_spec"])) || pay_way != qutil.ObjToString((*oldOrder)["pay_way"]) {
+			//在此关闭之前的订单
+			if !CloseDataExportOrder(qutil.ObjToString((*oldOrder)["pay_way"]), qutil.ObjToString((*oldOrder)["out_trade_no"]), qutil.ObjToString((*oldOrder)["prepay_time"])) {
+				p.ServeJson(map[string]interface{}{
+					"status": "n",
+				})
+				return
+			}
+			data_count := entity.GetDataExportSearchCountUseId(id)
+			if data_count > entity.ExConf.MsgMaxCount {
+				data_count = entity.ExConf.MsgMaxCount
+			}
+			order_money_, original_price_ := float64(0), float64(0)
+			if data_spec == "标准字段包" {
+				original_price_ = float64(data_count) * entity.ExConf.UnitPrice_normal
+			} else if data_spec == "高级字段包" {
+				original_price_ = float64(data_count) * entity.ExConf.UnitPrice_senior
+			}
+			order_money_ = float64(original_price_) * entity.ExConf.Discount
+			if order_money_ < entity.ExConf.OrderMinPrice {
+				order_money_ = entity.ExConf.OrderMinPrice
+			}
+			if original_price_ < entity.ExConf.OrderMinPrice {
+				original_price_ = entity.ExConf.OrderMinPrice
+			}
+			order_money := int(order_money_ * 100)
+			original_price := int(original_price_ * 100)
+			prepayTime, _ := time.ParseInLocation(qutil.Date_Full_Layout, qutil.ObjToString((*oldOrder)["prepay_time"]), time.Local)
+			surplus_second := prepayTime.Unix() - 7200 //价格变动  支付二维码更新成超时状态--重新生订单二维码
+			util.Mysql.Update("dataexport_order", map[string]interface{}{
+				"user_id":   userId,
+				"filter_id": id,
+			}, map[string]interface{}{
+				"data_spec":      data_spec,
+				"order_money":    order_money,
+				"original_price": original_price,
+				"prepay_time":    qutil.FormatDateByInt64(&surplus_second, qutil.Date_Full_Layout),
+				"pay_way":        pay_way,
+			})
+			(*oldOrder)["order_money"] = order_money
+			p.ServeJson(map[string]interface{}{
+				"status": "y",
+				"code":   qutil.ObjToString((*oldOrder)["order_code"]),
+				"token":  entity.GetWaitPayToken(qutil.Int64All((*oldOrder)["id"]), qutil.IntAll((*oldOrder)["order_money"]), qutil.ObjToString((*oldOrder)["order_code"]), pay_way, userId),
+			})
+			return
+		}
+	}
+	//
+	data_count := entity.GetDataExportSearchCountUseId(id)
+	if data_count > entity.ExConf.MsgMaxCount {
+		data_count = entity.ExConf.MsgMaxCount
+	}
+	order_money_, original_price_ := float64(0), float64(0)
+	if data_spec == "标准字段包" {
+		original_price_ = float64(data_count) * entity.ExConf.UnitPrice_normal
+	} else if data_spec == "高级字段包" {
+		original_price_ = float64(data_count) * entity.ExConf.UnitPrice_senior
+	}
+	order_money_ = float64(original_price_) * entity.ExConf.Discount
+	if order_money_ < entity.ExConf.OrderMinPrice {
+		order_money_ = entity.ExConf.OrderMinPrice
+	}
+	if original_price_ < entity.ExConf.OrderMinPrice {
+		original_price_ = entity.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 := util.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(qutil.ObjToString(vm["keyword"]))
+			}
+			filter_keys = buffer.String()
+			filter_publishtime = qutil.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)
+	//过滤特殊字符
+	nickname = reg.ReplaceAllString(nickname, "")
+	result := map[string]interface{}{
+		"status": "n",
+	}
+	if isPass {
+		//创建微信预支付订单
+		if pay_way == "wx_pc" {
+			tradeno, ret := pay.WxStruct.CreatePrepayOrder("b", p.IP(), openId, "", order_money)
+			if ret != nil && (*ret)["status"] == "1" {
+				now := time.Now()
+				ordercode := pay.GetOrderCode(openId)
+				orderid := util.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":        qutil.FormatDate(&now, qutil.Date_Full_Layout),
+					"prepay_time":        qutil.FormatDate(&now, qutil.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 {
+					p.SetSession("DataExportVerifyPhone_val", user_phone)
+					result["status"] = "y"
+					result["code"] = ordercode
+					result["token"] = entity.GetWaitPayToken(orderid, order_money, ordercode, pay_way, userId)
+				}
+			} else {
+				log.Println("生成微信预支付交易单失败", ret)
+			}
+		} else if pay_way == "ali_pc" {
+			now := time.Now()
+			payOutTime := now.Add(time.Hour * 2)
+			if qr_url, tradeno, err := pay.Alipay.GetOrderPayParam(qutil.Float64All(order_money), qutil.FormatDate(&payOutTime, qutil.Date_Full_Layout), pay.ALI_DATAEXPORT_NATIVE); err == nil {
+				ordercode := pay.GetOrderCode(openId)
+				orderid := util.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":        qutil.FormatDate(&now, qutil.Date_Full_Layout),
+					"prepay_time":        qutil.FormatDate(&now, qutil.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 {
+					p.SetSession("DataExportVerifyPhone_val", user_phone)
+					result["status"] = "y"
+					result["code"] = ordercode
+					result["token"] = entity.GetWaitPayToken(orderid, order_money, ordercode, pay_way, userId)
+				}
+			} else {
+				log.Println("生成支付宝预支付交易单失败")
+			}
+		}
+	}
+	p.ServeJson(result)
+}
+
+func (p *DataExportPayPC) GetOrderPayMsg() {
+	openid := qutil.ObjToString(p.GetSession("s_m_openid"))
+	userId := qutil.ObjToString(p.GetSession("userId"))
+	code := p.GetString("orderCode")
+	pay_way := p.GetString("payway")
+	prepay_time := p.GetString("prepaytime")
+	payUrl, errMsg, ok := func() (string, string, bool) {
+		if openid == "" && userId == "" {
+			return "", "用户异常", false
+		}
+		if code == "" || pay_way == "" {
+			return "", "参数异常", false
+		}
+		queryOrder := util.Mysql.FindOne("dataexport_order", map[string]interface{}{
+			"user_id":    userId,
+			"order_code": code,
+		}, "id,order_status,order_money,out_trade_no,pay_way,prepay_time", "")
+
+		if queryOrder == nil {
+			return "", "订单异常", false
+		}
+		if qutil.IntAll((*queryOrder)["order_status"]) != 0 {
+			return "", "订单状态异常", false
+		}
+		//在此关闭没有超时之前的订单 在pc端支付微信端订单,pay_way是wx_js 先进行关闭,再重新创建订单的时候,pay_way需要修改成wx_pc。
+		if !CloseDataExportOrder(qutil.ObjToString((*queryOrder)["pay_way"]), qutil.ObjToString((*queryOrder)["out_trade_no"]), qutil.ObjToString((*queryOrder)["prepay_time"])) {
+			return "", "订单关闭异常", false
+		}
+		//修改支付方式
+		orderid := qutil.Int64All((*queryOrder)["id"])
+		orderMoney := qutil.IntAll((*queryOrder)["order_money"])
+		codeUrl := ""
+		now := time.Now()
+		prepay_time = qutil.FormatDate(&now, qutil.Date_Full_Layout)
+		if pay_way == "wx_pc" || pay_way == "wx_js" {
+			pay_way = "wx_pc" //pc端重生支付码 更新数据库
+			tradeno, ret := pay.WxStruct.CreatePrepayOrder("b", p.IP(), openid, "", orderMoney)
+			if ret != nil && (*ret)["status"] == "1" {
+				if util.Mysql.Update("dataexport_order", map[string]interface{}{
+					"id": orderid,
+				}, map[string]interface{}{
+					"prepay_time":  prepay_time,
+					"prepay_id":    (*ret)["prepayid"],
+					"code_url":     (*ret)["codeurl"],
+					"out_trade_no": tradeno,
+					"pay_way":      pay_way,
+				}) {
+					r, _ := qr.Encode(qutil.ObjToString((*ret)["codeurl"]), qr.M)
+					pngdat := r.PNG()
+					codeUrl = base64.StdEncoding.EncodeToString(pngdat)
+				} else {
+					return "", pay_way + "更新数据库出错", false
+				}
+			} else {
+				return "", "创建微信订单出错", false
+			}
+		} else if pay_way == "ali_pc" {
+			payOutTime := now.Add(time.Hour * 2)
+			if qr_url, tradeno, err := pay.Alipay.GetOrderPayParam(qutil.Float64All(orderMoney), qutil.FormatDate(&payOutTime, qutil.Date_Full_Layout), pay.ALI_DATAEXPORT_NATIVE); err == nil {
+				if util.Mysql.Update("dataexport_order", map[string]interface{}{
+					"id": orderid,
+				}, map[string]interface{}{
+					"prepay_time":  prepay_time,
+					"prepay_id":    "",
+					"code_url":     qr_url,
+					"out_trade_no": tradeno,
+					"pay_way":      pay_way,
+				}) {
+					codeUrl = qr_url
+				} else {
+					return "", pay_way + "更新数据库出错", false
+				}
+
+			} else {
+				return "", "创建支付宝订单出错", false
+			}
+		}
+		return codeUrl, "", true
+	}()
+	if errMsg != "" {
+		log.Printf("用户%s 订单号%s 出错%s", openid, code, errMsg)
+	}
+	p.ServeJson(map[string]interface{}{
+		"success":     ok,
+		"payUrl":      payUrl,
+		"errMsg":      errMsg,
+		"prepay_time": prepay_time,
+	})
+
+}
+func CloseDataExportOrder(payWay, tradeno, prepayTime string) (status bool) {
+	//如果订单超时 则不用关闭订单
+	local, _ := time.LoadLocation("Local")
+	t, err := time.ParseInLocation(qutil.Date_Full_Layout, prepayTime, local)
+	//t, err := time.Parse(util.Date_Full_Layout, prepayTime)
+	if err == nil {
+		if t.Add(time.Hour * 2).Before(time.Now()) {
+			return true
+		}
+	}
+	log.Printf("%s取消订单,订单号%s\n", payWay, tradeno)
+	if payWay == "ali_pc" {
+		status = pay.Alipay.CloseOrder(tradeno)
+	} else if payWay == "wx_pc" || payWay == "wx_js" {
+		status = pay.WxStruct.CloseOrder(config.Config.Weixinrpc, tradeno)
+	} else {
+		//非扫码支付 暂不处理
+		status = true
+	}
+	if !status {
+		log.Printf("%s订单关闭失败:%s\n", payWay, tradeno)
+	}
+	return status
+}

+ 141 - 0
src/jfw/modules/subscribepay/src/service/dataReport.go

@@ -0,0 +1,141 @@
+package service
+
+import (
+	"errors"
+	"fmt"
+	"github.com/go-xweb/xweb"
+	"log"
+	"pay"
+	qutil "qfw/util"
+	"regexp"
+	"strings"
+	"time"
+	"util"
+)
+
+type DataReport struct {
+	*xweb.Action
+	toWxjsPay    xweb.Mapper `xweb:"/dataReport/getPayParam"`    //获取支付
+}
+
+func init() {
+	xweb.AddAction(&DataReport{})
+}
+
+func (d *DataReport) ToWxjsPay() {
+	name := d.GetString("s_name")
+	company := d.GetString("s_company")
+	phone := d.GetString("s_phone")
+	email := d.GetString("s_email")
+	reportId := d.GetString("s_reportId")
+	pay_way := d.GetString("s_payway")
+	userId := qutil.ObjToString(d.GetSession("userId"))
+	var payOrderId int64 //可重复支付修改
+	payStr, errMsg := func() (string, error) {
+		if !checkUserName(name) || !checkCompany(company) || !checkEmail(email) || !checkPhone(phone) {
+			return "", errors.New("输入校验不通过")
+		}
+		if !(pay_way=="wx_app"||pay_way=="ali_app"||pay_way=="wx_js"){
+			return "", errors.New("未知支付")
+		}
+		//检索订单
+		datareport := util.Mysql.FindOne("jy_datareport", map[string]interface{}{
+			"report_id": reportId,
+		}, "i_price", "")
+		if datareport == nil {
+			return "", errors.New("未知数据报告")
+		}
+		order_money := qutil.IntAll((*datareport)["i_price"])
+		now := time.Now()
+
+		tradeno, prepayid, orderPay := "", "", ""
+		if pay_way == "wx_app" { //"wx_app" 微信支付
+			var ret *map[string]string
+			tradeno, ret = pay.WxStruct.CreatePrepayOrder("D", d.IP(), "", "", order_money)
+			if ret == nil || (*ret)["status"] != "1" {
+				return "", errors.New("微信生成订单出错")
+			}
+			prepayid = qutil.ObjToString((*ret)["prepayid"])
+			orderPay = pay.WxStruct.GetAppWxPayStr(prepayid)
+		} else if pay_way=="ali_app" { //"ali_app"支付宝支付
+			var err error
+			orderPay, tradeno, err = pay.Alipay.GetOrderPayParam((qutil.Float64All(order_money)), "",pay.ALI_DATAREPORT_APP)
+			if err != nil {
+				return "", errors.New(fmt.Sprintf("支付宝订单生成出错:%v", err))
+			}
+		}else{ //wx_js支付
+			var ret *map[string]string
+			openId := qutil.ObjToString(d.GetSession("s_m_openid"))
+			tradeno, ret = pay.WxStruct.CreatePrepayOrder("d", d.IP(), openId, "", order_money)
+			if ret == nil || (*ret)["status"] != "1" {
+				return "", errors.New("微信生成订单出错")
+			}
+			prepayid = qutil.ObjToString((*ret)["prepayid"])
+			orderPay = pay.WxStruct.GetWxjsPaySign(prepayid)
+		}
+		insertValue := map[string]interface{}{
+			"order_money":    order_money,
+			"order_status":   0,
+			"service_status": 0,
+			"user_name":      name,
+			"prepay_id":      prepayid,
+			"order_pay":      orderPay,
+			"out_trade_no":   tradeno,
+			"report_id":      reportId,
+			"product_type":   "数据报告",
+			"create_time":    qutil.FormatDate(&now, qutil.Date_Full_Layout),
+			"prepay_time":    qutil.FormatDate(&now, qutil.Date_Full_Layout),
+			"user_mail":      email,
+			"user_phone":     phone,
+			"pay_way":        pay_way,
+			"user_id":        userId,
+			"user_company":   company,
+		}
+		if payOrderId = util.Mysql.Insert("jy_datareport_order", insertValue); payOrderId == 0 {
+			return "", errors.New(fmt.Sprintf("插入数据库出错:%+v", insertValue))
+		}
+		return orderPay, nil
+		//}
+	}()
+	errMsgStr := ""
+	if errMsg != nil {
+		log.Printf("%s CreateOlder 生成支付出错:%s", userId, errMsg.Error())
+		errMsgStr = strings.Split(errMsg.Error(), ":")[0]
+	}
+	d.ServeJson(map[string]interface{}{
+		"success":    qutil.If(errMsg == nil, true, false).(bool),
+		"payStr":     payStr,
+		"showErr":    errMsgStr,
+		"payOrderId": payOrderId,
+	})
+}
+
+
+func checkUserName(value string) bool {
+	if value == "" {
+		return false
+	}
+	value = strings.Replace(value, " ", "", -1)
+	if len([]rune(value)) < 2 || len([]rune(value)) > 50 {
+		return false
+	}
+	return true
+}
+func checkCompany(value string) bool {
+	if value == "" {
+		return false
+	}
+	value = strings.Replace(value, " ", "", -1)
+	if len([]rune(value)) < 2 || len([]rune(value)) > 100 {
+		return false
+	}
+	return true
+}
+func checkEmail(value string) bool {
+	var emailPattern = regexp.MustCompile("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$")
+	return emailPattern.MatchString(value)
+}
+func checkPhone(value string) bool {
+	var phonePattern = regexp.MustCompile("^[1][3-9][0-9]{9}$")
+	return phonePattern.MatchString(value)
+}

+ 0 - 346
src/jfw/modules/subscribepay/src/service/orderListDetails.go

@@ -1,346 +0,0 @@
-package service
-
-import (
-	"config"
-	"errors"
-	"log"
-	"strconv"
-	"strings"
-	"time"
-	"util"
-
-	qutil "qfw/util"
-
-	"github.com/go-xweb/xweb"
-	"gopkg.in/mgo.v2/bson"
-)
-
-type OrderListDetails struct {
-	*xweb.Action
-	getOrderPayAllMsg xweb.Mapper `xweb:"/orderListDetails/getOrderPayAllMsg"` //订单数据展示(订单详情页面)vip
-	myOrder           xweb.Mapper `xweb:"/orderListDetails/myOrder"`           //查询订单首页
-	myOrderPaging     xweb.Mapper `xweb:"/orderListDetails/myOrderPaging"`     //查询订单分页
-	deleteOrder       xweb.Mapper `xweb:"/orderListDetails/deleteOrder"`       //删除订单
-	applyInvoice      xweb.Mapper `xweb:"/orderListDetails/applyInvoice"`      //开发票
-	payCancel         xweb.Mapper `xweb:"/orderListDetails/payCancel"`         //支付成功后,其余订单改为已取消
-}
-
-var (
-	layout_date             = "2006.01.02"
-	orderStatus_unPaid      = "0"                //订单状态-待支付
-	orderStatus_paid        = "1"                //订单状态-已完成
-	orderStatus_deleted     = "-1"               //订单状态-已删除
-	orderStatus_cancel      = "-2"               //订单状态-已取消
-	tableName_order         = "dataexport_order" //订单表
-	order_pageSize          = 10
-	pagesize_max        int = 10
-)
-
-//订单数据展示(订单详情页面)
-func (this *OrderListDetails) GetOrderPayAllMsg() {
-	orderCode := this.GetString("orderCode")
-	userId := qutil.ObjToString(this.GetSession("userId"))
-	r := func() *orderResult {
-		if orderCode == "" {
-			return &orderResult{false, errors.New("订单号不能为空"), nil}
-		}
-		query := map[string]interface{}{
-			"user_id":    "5db11594f4e498161c85fcf2",
-			"order_code": orderCode,
-			//"order_status": 1,
-		}
-		oData := util.Mysql.FindOne("dataexport_order", query, "prepay_time,pay_time,pay_way,original_price,applybill_status,out_trade_no,filter,product_type,order_status,applybill_type,applybill_taxnum,applybill_company", "")
-		log.Println("odata:", oData)
-		//查询订单信息
-		if oData == nil || len(*oData) == 0 {
-			return &orderResult{false, errors.New("未找到此订单"), nil}
-		}
-		//已支付订单查询有效时间   -已取消的也查看有效时间 用于判断再次购买
-		uData, ok := util.MQFW.FindById("user", userId, `{"l_vip_starttime":1,"l_vip_endtime":1}`)
-		if uData == nil || len(*uData) == 0 || !ok {
-			return &orderResult{false, errors.New("数据库查询异常"), nil}
-		}
-		//
-		if qutil.IntAll((*oData)["order_status"]) != 1 {
-			return &orderResult{true, nil, map[string]interface{}{
-				"order": oData,
-				"time":  uData,
-			}}
-		}
-		delete(*uData, "_id")
-		return &orderResult{true, nil, map[string]interface{}{
-			"order":          oData,
-			"time":           uData,
-			"transaction_id": getPayTransactionId(qutil.ObjToString((*oData)["pay_way"]), qutil.ObjToString((*oData)["out_trade_no"])),
-		}}
-	}()
-	if r.Err != nil {
-		log.Printf("%s CreateOrder err:%v\n", userId, r.Err.Error())
-	}
-	this.ServeJson(r.Format())
-}
-
-//订单列表首页
-func (o *OrderListDetails) MyOrder() error {
-	//每页显示数
-	userId := o.Session().Get("userId")
-	openid := o.Session().Get("s_m_openid")
-	queryM := map[string]interface{}{}
-	if userId == nil || openid == nil {
-		return errors.New("未登录")
-	} else {
-		queryM["user_id"] = userId
-	}
-	// 0全部 1未支付 2已支付
-	typ := o.GetString("type")
-	if typ != "0" && typ != "" {
-		var status string
-		if typ == "1" {
-			status = orderStatus_unPaid
-		} else if typ == "2" {
-			status = orderStatus_paid
-		} else if typ == "3" {
-			status = orderStatus_cancel
-		}
-		queryM["order_status"] = status
-	} else {
-		queryM["order_status"] = map[string]interface{}{"ne": orderStatus_deleted}
-	}
-	//总数
-	haveNextPage, res, _ := o.Datas(queryM, 1)
-	if res != nil {
-		o.SetRes(res, queryM)
-	}
-	o.ServeJson(map[string]interface{}{
-		"res":         res,
-		"pageSize":    order_pageSize,
-		"hasNextPage": haveNextPage,
-	})
-	return nil
-}
-
-//订单列表分页
-func (o *OrderListDetails) MyOrderPaging() error {
-	userId := o.Session().Get("userId")
-	openid := o.Session().Get("s_m_openid")
-	queryM := map[string]interface{}{}
-	if userId == nil || openid == nil {
-		return errors.New("未登录")
-	} else {
-		queryM["user_id"] = userId
-	}
-	// 0全部 1未支付 2已支付
-	typ := o.GetString("type")
-	pageNum, _ := o.GetInteger("pageNum")
-	if typ != "0" && typ != "" {
-		var status string
-		if typ == "1" {
-			status = orderStatus_unPaid
-		} else if typ == "2" {
-			status = orderStatus_paid
-		} else if typ == "3" {
-			status = orderStatus_cancel
-		}
-		queryM["order_status"] = status
-	} else {
-		queryM["order_status"] = map[string]interface{}{"ne": orderStatus_deleted}
-	}
-	haveNextPage, res, _ := o.Datas(queryM, pageNum)
-	if res != nil {
-		o.SetRes(res, queryM)
-	}
-	o.ServeJson(map[string]interface{}{
-		"hasNextPage": haveNextPage,
-		"res":         res,
-	})
-	return nil
-}
-
-//删除或取消订单
-func (o *OrderListDetails) DeleteOrder() error {
-	if userId := o.GetSession("userId"); userId != nil {
-		queryMap := map[string]interface{}{
-			"id":      o.GetString("id"),
-			"user_id": userId.(string),
-		}
-		queryM := map[string]interface{}{}
-		queryM["user_id"] = userId
-		nextPage := false
-		// 0全部 1未支付 2已支付
-		typ := o.GetString("type")
-		cancel := o.GetString("cancel")
-		pageNum, _ := o.GetInteger("pageNum")
-		if typ != "0" && typ != "" {
-			var status string
-			if typ == "1" {
-				status = orderStatus_unPaid
-			} else if typ == "2" {
-				status = orderStatus_paid
-			} else if typ == "3" {
-				status = orderStatus_cancel
-			}
-			queryM["order_status"] = status
-		} else {
-			queryM["order_status"] = map[string]interface{}{"ne": orderStatus_deleted}
-		}
-		haveNextPage, res, _ := o.Datas(queryM, pageNum)
-		if len(res) > 0 {
-			res = res[0:1]
-			//用于删除订单后 判断新增的订单之后 是否有下一页
-			nextPage = true
-		}
-		if res != nil {
-			o.SetRes(res, queryM)
-		}
-		var boo = false
-		if cancel == "cancel" {
-			//取消订单
-			boo = util.Mysql.Update(tableName_order, queryMap, map[string]interface{}{"order_status": -2})
-		} else {
-			//删除订单
-			boo = util.Mysql.Update(tableName_order, queryMap, map[string]interface{}{"order_status": -1})
-		}
-		o.ServeJson(map[string]interface{}{
-			"success":     boo,
-			"res":         res,
-			"hasNextPage": haveNextPage,
-			"nextPage":    nextPage,
-		})
-	}
-	return nil
-}
-
-//开发票
-func (o *OrderListDetails) ApplyInvoice() error {
-	var applyBill_status int
-	var order_code, applyBill_company, applyBill_taxnum, applyBill_type string
-	var updateBl bool = false
-	order_code = o.GetString("order_code")
-	//获取数据
-	applyBill_type = o.GetString("demo-radio") //个人 单位
-	queryMap := map[string]interface{}{
-		"order_code": order_code,
-	}
-	if applyBill_type == "个人" {
-		applyBill_status = 1
-		updateBl = util.Mysql.Update(tableName_order, queryMap, map[string]interface{}{"applyBill_status": applyBill_status})
-
-	} else if applyBill_type == "单位" {
-		applyBill_status = 1                                 //状态
-		applyBill_company = o.GetString("applyBill_company") //公司名
-		applyBill_taxnum = o.GetString("applyBill_taxnum")   //纳税人识别号
-		updateBl = util.Mysql.Update(tableName_order, queryMap, map[string]interface{}{
-			"applyBill_company": applyBill_company,
-			"applyBill_taxnum":  applyBill_taxnum,
-			"applyBill_status":  applyBill_status,
-			"applyBill_type":    1,
-		}) //修改操作
-	}
-	//判断条件
-	if updateBl {
-		go func() {
-			orderdata := util.Mysql.FindOne(tableName_order, map[string]interface{}{
-				"order_code": order_code,
-			}, "id,filter,user_mail,user_phone,product_type,data_spec,filter_id,order_code,data_count,order_status,order_money,out_trade_no,applybill_type,applybill_company,applybill_taxnum,user_openid,create_time,pay_time,pay_way", "")
-			tt := time.Now()
-			pay_time := qutil.FormatDate(&tt, qutil.Date_Full_Layout)
-			util.SendMailToBJFinance(orderdata, pay_time, "", 2, config.GmailAuth)
-		}()
-	}
-	o.ServeJson(map[string]interface{}{
-		"flag": updateBl,
-	})
-	return nil
-}
-
-//支付成功后,将该订单以外的所有订单状态改为已取消状态 已取消:-2
-func (o *OrderListDetails) PayCancel() bool {
-	order_code := o.GetString("order_code")
-	userId := qutil.ObjToString(o.GetSession("userId"))
-	//参数:查询语句,不等语句,修改条件
-	bl := util.Mysql.UpdateByNotEqual(tableName_order, bson.M{
-		"user_id":      userId,
-		"product_type": "vip订阅",
-	}, bson.M{
-		"order_code":   order_code,
-		"order_status": orderStatus_deleted, //已删除
-	}, bson.M{
-		"order_status": orderStatus_paid, //已购买
-	}, bson.M{
-		"order_status": orderStatus_cancel,
-	})
-	log.Println("bl:", bl)
-	return bl
-}
-
-func (o *OrderListDetails) SetRes(res []map[string]interface{}, queryM map[string]interface{}) {
-	//获取最后一次购买的vip订单
-	lastbuy := *util.Mysql.Find(tableName_order, queryM, "order_code,pay_time", "pay_time desc", -1, 0)
-	queryM["product_type"] = "vip订阅"
-	lastbuy_code := ""
-	if len(lastbuy) > 0 && lastbuy != nil {
-		lastbuy_code = qutil.ObjToString(lastbuy[0]["order_code"])
-	}
-	for _, v := range res {
-		if v["filter_publishtime"] != nil {
-			filter_publishtime := v["filter_publishtime"]
-			if filter_publishtime != nil {
-				timeArr := strings.Split(filter_publishtime.(string), "_")
-				if len(timeArr) == 2 {
-					start, err := strconv.ParseInt(timeArr[0], 10, 64)
-					end, erro := strconv.ParseInt(timeArr[1], 10, 64)
-					if err == nil && erro == nil {
-						v["filter_publishtime"] = qutil.FormatDateByInt64(&start, layout_date) + "-" + qutil.FormatDateByInt64(&end, layout_date)
-					}
-				}
-			}
-		}
-		if v["filter_id"] != nil {
-			v["filter_id"] = qutil.SE.Encode2Hex(v["filter_id"].(string))
-		}
-		orderMoney := v["order_money"]
-		if orderMoney != nil {
-			v["order_money"] = float64(orderMoney.(int64)) / 100
-		}
-		if v["id"] != nil && v["order_money"] != nil && v["order_code"] != nil {
-			v["token"] = util.GetWaitPayToken(v["id"].(int64), int(orderMoney.(int64)), v["order_code"].(string), v["pay_way"].(string), queryM["user_id"].(string))
-		}
-		if lastbuy_code == v["order_code"] {
-			v["lastbuy_code"] = lastbuy_code
-		}
-		if v["pay_time"] != nil && v["product_type"] == "vip订阅" {
-			//TODO 还没录入数据
-			data, err := util.MQFW.FindOne("user", bson.M{"_id": queryM["user_id"]})
-			if len(*data) > 0 && err {
-				v["i_vip_status"] = qutil.ObjToString((*data)["i_vip_status"])
-				v["l_vip_starttime"] = qutil.ObjToString((*data)["l_vip_starttime"])
-				v["l_vip_endtime"] = qutil.ObjToString((*data)["l_vip_endtime"])
-			} else {
-				/*
-					0:暂不使用vip订阅 1:试用 2:正式 -1:试用到期 -2:正式到期
-				*/
-				v["i_vip_status"] = "1"
-				v["l_vip_starttime"] = "1571991460"
-				v["l_vip_endtime"] = "1572596260"
-			}
-		}
-	}
-	log.Println(res)
-}
-
-//查询数据
-func (o *OrderListDetails) Datas(queryM map[string]interface{}, pageNum int) (haveNextPage bool, result []map[string]interface{}, err error) {
-	res := *util.Mysql.Find(tableName_order, queryM, "id,order_code,filter_publishtime,create_time,data_spec,filter_id,filter_keys,order_money,data_count,order_status,pay_way,product_type,filter,pay_time", "create_time desc", -1, 0)
-	if len(res) > 0 {
-		start := (pageNum - 1) * pagesize_max
-		end := pageNum * pagesize_max
-		if end > len(res) {
-			end = len(res)
-		}
-		if start < len(res) {
-			result = res[start:end]
-		}
-	}
-	haveNextPage = len(result) >= pagesize_max
-	return
-}

+ 122 - 0
src/jfw/modules/subscribepay/src/service/payCallback.go

@@ -0,0 +1,122 @@
+package service
+
+import (
+	"config"
+	"entity"
+	"fmt"
+	"github.com/go-xweb/xweb"
+	"log"
+	"net/url"
+	"pay"
+	qutil "qfw/util"
+	"qfw/util/redis"
+	"strings"
+)
+
+type PayCallBackAction struct {
+	*xweb.Action
+	aliPayCallback xweb.Mapper `xweb:"/callback/aliPay"` //支付宝支付完成回调
+	wxPayCallback  xweb.Mapper `xweb:"/callback/wxPay"`  //微信支付回调
+}
+
+//支付宝支付成功后回调
+func (a *PayCallBackAction) AliPayCallback() {
+	checkSign := a.GetForm()
+	sign := checkSign.Get("sign") //待验证签名
+	checkSign.Del("sign")
+	checkSign.Del("sign_type")
+	signContentBytes, _ := url.QueryUnescape(checkSign.Encode())
+	if !pay.Alipay.CheckCallBackSign(signContentBytes, sign) { //验签
+		log.Println("支付宝签名验证失败")
+		return
+	}
+	//校验
+	if checkSign.Get("app_id") != qutil.ObjToString(config.AliPayConf["appid"]) ||
+		!(checkSign.Get("trade_status") == "TRADE_SUCCESS") || (checkSign.Get("trade_status") == "TRADE_FINISHED ") {
+		return
+	}
+
+	thisParam := &entity.CallBackParam{
+		qutil.IntAll(qutil.Float64All(checkSign.Get("total_amount")) * 100),
+		qutil.IntAll(qutil.Float64All(checkSign.Get("receipt_amount")) * 100),
+		qutil.ObjToString(checkSign.Get("out_trade_no")),
+		qutil.ObjToString(checkSign.Get("gmt_payment")),
+		qutil.ObjToString(checkSign.Get("trade_no")),
+		"",
+	}
+
+	if strings.HasPrefix(thisParam.OutTradeno, pay.ALI_DATAEXPORT_NATIVE) || strings.HasPrefix(thisParam.OutTradeno, pay.ALI_DATAEXPORT_APP) { //数据导出
+		if !entity.JyDataExportStruct.PayCallBack(thisParam) {
+			log.Printf("支付宝数据导出更新执行出错 %+v\n", thisParam)
+		}
+	} else if strings.HasPrefix(thisParam.OutTradeno, pay.ALI_DATAREPORT_APP) { //数据报告
+		if !entity.JyDataReportStruct.PayCallBack(thisParam) {
+			log.Printf("支付宝数据报告更新执行出错 %+v\n", thisParam)
+		}
+	} else if strings.HasPrefix(thisParam.OutTradeno, pay.ALI_SUBVIP_APP) || strings.HasPrefix(thisParam.OutTradeno, pay.ALI_DATAEXPORT_NATIVE) { //vip订阅
+
+	}
+	if !thisParam.SaveAliPayRecord() {
+		log.Printf("支付宝支付保存支付记录出错 %+v\n", thisParam)
+	}
+}
+
+//微信支付成功后回调
+func (p *PayCallBackAction) WxPayCallback() {
+	defer qutil.Catch()
+	by := p.Body()
+	ret := qutil.XmlToMap(string(by))
+
+	thisParam := &entity.CallBackParam{
+		qutil.IntAll(ret["total_fee"]),
+		qutil.IntAll(ret["cash_fee"]),
+		qutil.ObjToString(ret["out_trade_no"]),
+		qutil.ObjToString(ret["time_end"]),
+		qutil.ObjToString(ret["transaction_id"]),
+		qutil.ObjToString(ret["openid"]),
+	}
+
+	ok := func() bool {
+		if ret["return_code"] != "SUCCESS" || !(ret["appid"] == pay.WxStruct.Appid ||ret["appid"] == pay.WxStruct.Appid_app)|| ret["mch_id"] != pay.WxStruct.Mchid {
+			return false
+		}
+		if thisParam.Openid != "" {
+			redis.Put("push", "remind&&"+thisParam.Openid, "4", 172800)
+		}
+		if ret["sign"] != qutil.CreateWxSign(fmt.Sprintf("&key=%s", pay.WxStruct.Key), ret) {
+			return false
+		}
+		update, insert := false, false;
+		if strings.HasPrefix(thisParam.OutTradeno, pay.WX_REWARD_JSAPI) { //打赏
+			if update = entity.JyReWardStruct.PayCallBack(thisParam); !update {
+				log.Printf("微信打赏更新执行出错 %+v\n", thisParam)
+			}
+		} else if strings.HasPrefix(thisParam.OutTradeno, pay.WX_DATAEXPORT_NATIVE) || strings.HasPrefix(thisParam.OutTradeno, pay.WX_DATAEXPORT_APP) || strings.HasPrefix(thisParam.OutTradeno, pay.WX_DATAEXPORT_JSAPI) { //订阅数据导出
+			if update = entity.JyDataExportStruct.PayCallBack(thisParam); !update {
+				log.Printf("微信数据导出更新执行出错 %+v\n", thisParam)
+			}
+		} else if strings.HasPrefix(thisParam.OutTradeno, pay.WX_DATAREPORT_APP) || strings.HasPrefix(thisParam.OutTradeno, pay.WX_DATAREPORT_JSAPI) { //数据报告
+			if update = entity.JyDataReportStruct.PayCallBack(thisParam); !update {
+				log.Printf("微信数据报告更新执行出错 %+v\n", thisParam)
+			}
+		} else if strings.HasPrefix(thisParam.OutTradeno, pay.WX_SUBVIP_APP) || strings.HasPrefix(thisParam.OutTradeno, pay.WX_SUBVIP_JSAPI) { //vip订阅
+
+		}
+		if insert = thisParam.SaveWxPayRecord(); !insert {
+			log.Printf("微信支付保存支付记录出错 %+v\n", thisParam)
+		}
+		return update && insert
+	}()
+
+	if ok {
+		p.Write(`<xml>
+			  	<return_code><![CDATA[SUCCESS]]></return_code>
+			  	<return_msg><![CDATA[OK]]></return_msg>
+			</xml>`)
+	} else {
+		p.Write(`<xml>
+				<return_code><![CDATA[FAIL]]></return_code>
+				<return_msg><![CDATA[ERROR]]></return_msg>
+			</xml>`)
+	}
+}

+ 144 - 0
src/jfw/modules/subscribepay/src/service/reward.go

@@ -0,0 +1,144 @@
+package service
+
+//打赏
+import (
+	"config"
+	"pay"
+
+	"fmt"
+
+	"net/http"
+	qutil "qfw/util"
+	"util"
+
+	"time"
+
+	"github.com/SKatiyar/qr"
+	"github.com/go-xweb/xweb"
+)
+
+type RewardPayAction struct {
+	*xweb.Action
+	//打赏
+	redirectOauth xweb.Mapper `xweb:"/weixin/reward/redirect"`    //微信支付授权
+	getUserInfo   xweb.Mapper `xweb:"/weixin/reward/getUserInfo"` //微信支付获取用户信息
+	qr            xweb.Mapper `xweb:"/weixin/reward/qr/([^.]*)"`  //生成二维码图片
+	wxPay         xweb.Mapper `xweb:"/weixin/reward/pay"`         //微信支付
+}
+
+//转发
+func (p *RewardPayAction) RedirectOauth() {
+	defer qutil.Catch()
+	param := p.GetString("source") + "_" + p.GetString("id")
+	openId, _ := p.GetSession("payOpenId").(string)
+	if openId != "" {
+		p.Redirect(config.Config.WebDomain+"/weixin/reward/index?param="+param, http.StatusFound)
+		return
+	}
+	urlstr := fmt.Sprintf(config.Wxoauth, fmt.Sprintf("%s/jypay/weixin/reward/getUserInfo?param=%s", config.Config.WebDomain, param), "1")
+	p.Redirect(urlstr, http.StatusFound)
+}
+
+//取用户信息,取完以后再跳转到实际支付页面
+func (p *RewardPayAction) GetUserInfo() {
+	//传入openid,进入支付页面,正常情况下应该存入session
+	p.SetSession("payOpenId", util.Getopenid(p.GetString("code")))
+	p.Redirect("/weixin/reward/index?param="+p.GetString("param"), http.StatusFound)
+}
+
+
+func (p *RewardPayAction) WxPay() error {
+	defer qutil.Catch()
+	openId, _ := p.GetSession("payOpenId").(string)
+	if openId == "" {
+		p.ServeJson(map[string]interface{}{
+			"status": 0,
+		})
+		return nil
+	}
+	reqType := p.GetString("reqType")
+	if reqType == "getPrepayId" {
+		tf, _ := p.GetFloat("totalfee")
+		if tf <= 0 {
+			p.ServeJson(map[string]interface{}{
+				"status": 0,
+			})
+			return nil
+		}
+		totalfee := qutil.IntAll(tf * 100)
+		title := p.GetString("title")
+		detailmsg := fmt.Sprintf(pay.WxStruct.Dashang_detailmsg, title, fmt.Sprint(float64(totalfee)/100))
+		tradeno, ret := pay.WxStruct.CreatePrepayOrder("a", p.IP(), openId, detailmsg, totalfee)
+		if ret == nil {
+			p.ServeJson(map[string]interface{}{
+				"status": -1,
+			})
+			return nil
+		}
+		prepayId := (*ret)["prepayid"]
+		if prepayId == "" {
+			p.ServeJson(map[string]interface{}{
+				"status": qutil.IntAll((*ret)["status"]),
+			})
+			return nil
+		}
+		nonceStr := qutil.GetRandom(16) + qutil.GetLetterRandom(16)
+		timestamp := time.Now().Unix()
+		sign := qutil.WxSign(fmt.Sprintf("appId=%s&nonceStr=%s&package=%s&signType=%s&timeStamp=%d&key=%s", pay.WxStruct.Appid, nonceStr, "prepay_id="+prepayId, "MD5", timestamp, pay.WxStruct.Key))
+		//保存记录
+		now := time.Now()
+		util.MQFW.Save("reward", map[string]interface{}{
+			"s_source":     p.GetString("source"),
+			"s_prepayid":   prepayId,
+			"s_title":      title,
+			"s_id":         p.GetString("id"),
+			"l_createtime": now.Unix(),
+			"l_updatetime": now.Unix(),
+			"s_openid":     openId,
+			"i_year":       now.Year(),
+			"i_month":      now.Month(),
+			"i_day":        now.Day(),
+			"i_hour":       now.Hour(),
+			"i_minute":     now.Minute(),
+			"i_status":     0,
+			"i_totalfee":   totalfee,
+			"s_tradeno":    tradeno,
+			"i_operation":  0,
+		})
+		p.ServeJson(map[string]interface{}{
+			"status":    1,
+			"appId":     pay.WxStruct.Appid,
+			"timestamp": fmt.Sprint(timestamp),
+			"signType":  "MD5",
+			"sign":      sign,
+			"nonceStr":  nonceStr,
+			"prepayId":  "prepay_id=" + prepayId,
+		})
+	} else if reqType == "updateOrder" {
+		operation, _ := p.GetInteger("operation")
+		prepayId := p.GetString("prepayId")
+		if operation == 1 || operation == -1 {
+			util.MQFW.Update("reward", `{"s_openid":"`+openId+`","s_prepayid":"`+prepayId+`"}`, map[string]interface{}{
+				"$set": map[string]interface{}{
+					"i_operation":  operation,
+					"l_updatetime": time.Now().Unix(),
+				},
+			}, false, false)
+		}
+	}
+	return nil
+}
+
+//打赏二维码图片
+func (c *RewardPayAction) Qr(code string) error {
+	w := c.ResponseWriter
+	w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
+	w.Header().Set("Pragma", "no-cache")
+	w.Header().Set("Expires", "0")
+	w.Header().Set("Content-Type", "image/png")
+	data := fmt.Sprintf("%s/jypay/weixin/reward/redirect?id=%s&source=p", config.Config.WebDomain, code)
+	r, _ := qr.Encode(data, qr.M)
+	pngdat := r.PNG()
+	_, err := w.Write(pngdat)
+	return err
+}

+ 0 - 16
src/jfw/modules/subscribepay/src/service/test.go

@@ -1,16 +0,0 @@
-package service
-
-import "github.com/go-xweb/xweb"
-
-func init() {
-
-}
-
-type Test struct {
-	*xweb.Action
-	test xweb.Mapper `xweb:"/test"`
-}
-
-func (t *Test) Test() {
-	t.Write("yes!")
-}

+ 3 - 2
src/jfw/modules/subscribepay/src/service/editSub.go → src/jfw/modules/subscribepay/src/service/vipSubscribeEdit.go

@@ -2,6 +2,7 @@ package service
 
 import (
 	"encoding/json"
+	"entity"
 	"errors"
 	"log"
 	qutil "qfw/util"
@@ -74,7 +75,7 @@ func (this *EditSub) SaveSubEdit() {
 			return &editSubResult{false, errors.New("修改次数已达上限"), nil}
 		}
 		//获取购买数量
-		buyset := util.GetBuySet(userId)
+		buyset := entity.GetBuySet(userId)
 		switch doType {
 		case "area":
 			areaNew := map[string]interface{}{}
@@ -84,7 +85,7 @@ func (this *EditSub) SaveSubEdit() {
 			if err != nil {
 				return &editSubResult{false, errors.New("数据格式错误"), nil}
 			}
-			count := util.GetBuyAreaCount(areaNew)
+			count := entity.GetBuyAreaCount(areaNew)
 			if (count[0] > buyset[0] || count[1] > buyset[1]) && buyset[0] != -1 {
 				return &editSubResult{false, errors.New("非法操作"), nil}
 			}

+ 29 - 145
src/jfw/pay/vipSubscribePay.go → src/jfw/modules/subscribepay/src/service/vipSubscribePay.go

@@ -1,15 +1,16 @@
-package pay
+package service
 
 import (
 	"encoding/json"
+	"entity"
 	"errors"
 	"fmt"
-	"jfw/config"
-	"jfw/public"
 	"log"
+	"pay"
 	qutil "qfw/util"
 	"strconv"
 	"strings"
+	"util"
 
 	"time"
 
@@ -19,33 +20,16 @@ import (
 //订单结构
 type Order struct {
 	*xweb.Action
-	createOrder xweb.Mapper `xweb:"/front/vipsubscribe/createOrder"` //创建订单并支付
-	orderToPay  xweb.Mapper `xweb:"/front/vipsubscribe/orderToPay"`  //支付已创建订单
+	createOrder xweb.Mapper `xweb:"/jypay/vipsubscribe/createOrder"` //创建订单并支付
+	orderToPay  xweb.Mapper `xweb:"/jypay/vipsubscribe/orderToPay"`  //支付已创建订单
 }
 
 func init() {
 	xweb.AddAction(&Order{})
 }
 
-type orderResult struct {
-	Success bool  //是否成功
-	Err     error //错误
-	Data    map[string]interface{}
-}
 
-func (o *orderResult) Format() *map[string]interface{} {
-	errStr := ""
-	if o.Err != nil {
-		errStr = o.Err.Error()
-	}
-	return &map[string]interface{}{
-		"success": o.Success,
-		"errMsg":  errStr,
-		"data":    o.Data,
-	}
-}
-
-//创建订单并支付
+//创建订单返回支付串
 func (this *Order) CreateOrder() {
 	area := qutil.ObjToMap(this.GetString("area"))
 	industry := strings.Split(this.GetString("industry"), ",")
@@ -53,7 +37,7 @@ func (this *Order) CreateOrder() {
 	payWay := this.GetString("payWay")
 	userId := qutil.ObjToString(this.GetSession("userId"))
 	openId := qutil.ObjToString(this.GetSession("s_m_openid"))
-	r := func() *orderResult {
+	r := func() *entity.FuncResult {
 		now := time.Now()
 		//数据校验
 		if len(industry) == 1 { //去掉[""]
@@ -61,11 +45,11 @@ func (this *Order) CreateOrder() {
 		}
 		date_count, date_unit, err := checkReqDate(date)
 		if err != nil {
-			return &orderResult{false, err, nil}
+			return &entity.FuncResult{false, err, nil}
 		}
 		log.Println(area, industry, date, payWay)
 		//插入订单表
-		mog_id := public.MQFW.Save("subvip_select", map[string]interface{}{
+		mog_id := util.MQFW.Save("subvip_select", map[string]interface{}{
 			"o_area":       area,     //地区(对象)
 			"a_industry":   industry, //行业(数组)
 			"s_userid":     userId,
@@ -75,12 +59,12 @@ func (this *Order) CreateOrder() {
 			"i_comeintime": now.Unix(),
 		})
 		if mog_id == "" {
-			return &orderResult{false, errors.New("创建订单出错"), nil}
+			return &entity.FuncResult{false, errors.New("创建订单出错"), nil}
 		}
 		//计算价格
-		totalfee := getSubVipPrice(area, industry, date_count, date_unit)
+		totalfee := entity.GetSubVipPrice(area, industry, date_count, date_unit)
 		//创建订单
-		tradeno, ret := public.WxStruct.CreatePrepayOrder(config.Sysconfig["weixinrpc"].(string), "e", this.IP(), openId, "", totalfee)
+		tradeno, ret := pay.WxStruct.CreatePrepayOrder( "e", this.IP(), openId, "", totalfee)
 		if ret == nil || (*ret)["status"] != "1" {
 			errMsg := "创建微信订单出错"
 			if (*ret)["errcodedes"] != "" {
@@ -88,12 +72,12 @@ func (this *Order) CreateOrder() {
 			} else if (*ret)["errcode"] != "" {
 				errMsg = (*ret)["errcode"]
 			}
-			return &orderResult{false, errors.New(errMsg), nil}
+			return &entity.FuncResult{false, errors.New(errMsg), nil}
 		}
 		//存入订单表
-		ordercode := public.GetOrderCode(openId)
+		ordercode := pay.GetOrderCode(openId)
 		prepayid := qutil.ObjToString((*ret)["prepayid"])
-		jsPayParam := GetWxJsPayStr(prepayid)
+		jsPayParam := pay.GetWxJsPayStr(prepayid)
 
 		filter := map[string]interface{}{
 			"_id":        mog_id,
@@ -104,7 +88,7 @@ func (this *Order) CreateOrder() {
 		}
 		filterStr, _ := json.Marshal(filter)
 
-		orderid := public.Mysql.Insert("dataexport_order", map[string]interface{}{
+		orderid := util.Mysql.Insert("dataexport_order", map[string]interface{}{
 			"order_money":    totalfee,
 			"order_status":   0,
 			"user_nickname":  qutil.ObjToString(this.GetSession("s_nickname")),
@@ -123,9 +107,9 @@ func (this *Order) CreateOrder() {
 			"filter":         string(filterStr), //筛选
 		})
 		if orderid == -1 {
-			return &orderResult{false, errors.New("数据库操作异常"), nil}
+			return &entity.FuncResult{false, errors.New("数据库操作异常"), nil}
 		}
-		return &orderResult{true, nil, map[string]interface{}{
+		return &entity.FuncResult{true, nil, map[string]interface{}{
 			"code": ordercode,
 			"res":  jsPayParam,
 		}}
@@ -140,30 +124,30 @@ func (this *Order) CreateOrder() {
 func (this *Order) OrderToPay() {
 	orderCode := qutil.ObjToString(this.GetString("orderCode"))
 	userId := qutil.ObjToString(this.GetSession("userId"))
-	r := func() *orderResult {
+	r := func() *entity.FuncResult {
 		//根据订单号获取订单数据
 		query := map[string]interface{}{
 			"user_id":      userId,
 			"order_code":   orderCode,
 			"order_status": 0,
 		}
-		oData := public.Mysql.FindOne("dataexport_order", query, "", "")
+		oData := util.Mysql.FindOne("dataexport_order", query, "", "")
 		if oData == nil || len(*oData) == 0 {
-			return &orderResult{false, errors.New("未知订单"), nil}
+			return &entity.FuncResult{false, errors.New("未知订单"), nil}
 		}
 		//判断订单是否超过两小时
 		prepayTime, _ := time.ParseInLocation(qutil.Date_Full_Layout, qutil.ObjToString((*oData)["prepay_time"]), time.Local)
 		jsPayParam := qutil.ObjToString((*oData)["code_url"])
 		if time.Now().Before(prepayTime.Add(time.Hour*2)) && jsPayParam != "" {
 			//未过期
-			return &orderResult{true, nil, map[string]interface{}{
+			return &entity.FuncResult{true, nil, map[string]interface{}{
 				"res": jsPayParam,
 			}}
 		}
 		//重新生成订单
 		openId := qutil.ObjToString((*oData)["user_openid"])
 		totalfee := qutil.IntAll((*oData)["order_money"])
-		tradeno, ret := public.WxStruct.CreatePrepayOrder(config.Sysconfig["weixinrpc"].(string), "e", this.IP(), openId, "", totalfee)
+		tradeno, ret := pay.WxStruct.CreatePrepayOrder("e", this.IP(), openId, "", totalfee)
 		if ret == nil || (*ret)["status"] != "1" {
 			errMsg := "创建微信订单出错"
 			if (*ret)["errcodedes"] != "" {
@@ -171,24 +155,22 @@ func (this *Order) OrderToPay() {
 			} else if (*ret)["errcode"] != "" {
 				errMsg = (*ret)["errcode"]
 			}
-			return &orderResult{false, errors.New(errMsg), nil}
+			return &entity.FuncResult{false, errors.New(errMsg), nil}
 		}
 		prepayid := qutil.ObjToString((*ret)["prepayid"])
-		jsPayParam = GetWxJsPayStr(prepayid)
+		jsPayParam = pay.GetWxJsPayStr(prepayid)
 		//更新订单表
 		now := time.Now()
-		ok := public.Mysql.Update("dataexport_order", query, map[string]interface{}{
+		ok := util.Mysql.Update("dataexport_order", query, map[string]interface{}{
 			"code_url":     jsPayParam,
 			"prepay_time":  qutil.FormatDate(&now, qutil.Date_Full_Layout),
 			"out_trade_no": tradeno,
 			"prepay_id":    prepayid,
 		})
 		if !ok {
-			return &orderResult{false, errors.New("数据库操作异常"), nil}
+			return &entity.FuncResult{false, errors.New("数据库操作异常"), nil}
 		}
-		return &orderResult{true, nil, map[string]interface{}{
-			"res": jsPayParam,
-		}}
+		return &entity.FuncResult{true, nil, map[string]interface{}{"res": jsPayParam	}}
 	}()
 	if r.Err != nil {
 		log.Printf("%s CreateOrder err:%v\n", userId, r.Err.Error())
@@ -219,101 +201,3 @@ func checkReqDate(dateStr string) (cyclecount, cycleunit int, err error) {
 	return -1, -1, errors.New(fmt.Sprintf("日期%s格式化出错", dateStr))
 }
 
-//计算价格
-func getSubVipPrice(area *map[string]interface{}, industry []string, count, unit int) int {
-	if len(*area) == 0 { //全国
-		if len(industry) == 1 {
-			return getSetMealPrice(0, 1, unit) * count //全国1行业套餐
-		} else if len(industry) == 0 {
-			return getSetMealPrice(0, 0, unit) * count //全国全行业套餐
-		} else {
-			return getSetMealPrice(0, len(industry), unit) * count //全国多行业套餐
-		}
-	}
-	final_price := 0 //最终价格
-	for _, tmp := range *area {
-		thisPrice := 0
-		citys := qutil.ObjArrToStringArr(tmp.([]interface{}))
-		if len(citys) > 0 { //市
-			if len(citys) == 1 { //单城市
-				thisPrice = getSetMealPrice(2, len(industry), unit) * count
-			} else { //多城市
-				if len(industry) == 0 || len(industry) == 1 { //多城市 单行业
-					thisPrice = len(citys) * getSetMealPrice(2, len(industry), unit) * count
-				} else { //多行业 多行业
-					if count > 10 && unit == 2 { //月份十个月以上价格一样
-						count = 10
-					}
-					industry_Price := 580 * len(industry)
-					if 580*len(industry) > 1800 {
-						industry_Price = 1800
-					}
-					city_Price := len(citys) * 580
-					if len(citys)*580 > 1180 {
-						city_Price = 1180
-					}
-					thisPrice = (industry_Price + city_Price) * count
-					if unit == 1 { //年的价格是月的价格10倍
-						thisPrice *= 10
-					}
-				}
-			}
-		} else { //省
-			thisPrice = getSetMealPrice(1, len(industry), unit) * count
-		}
-		final_price += thisPrice
-	}
-	return final_price
-}
-
-/*
-vip订阅 套餐价格
-c(city) 全国:0 省:1 市:2
-i(industry) 全行业:0 行业:1 其他:多个行业
-u(unit) 年:1 月:2
-*/
-func getSetMealPrice(c, i, u int) int {
-	t := u == 2 //是否是月单位
-	icount := 1 //行业个数
-	if i > 1 {
-		icount = i
-	}
-	switch c {
-	case 0:
-		if i == 0 {
-			if t {
-				return 38800 //1月全国全行业
-			}
-			return 388000 //1年全国全行业
-		} else {
-			if t {
-				return 11800 * icount //1月全国icount个行业
-			}
-			return 118000 * icount //1年全国icount个行业
-		}
-	case 1:
-		if i == 0 {
-			if t {
-				return 3800 //1月1省全行业
-			}
-			return 38000 //1年1省全行业
-		} else {
-			if t {
-				return 1180 * icount //1月1省icount个行业
-			}
-			return 11800 * icount //1年1省icount个行业
-		}
-	default:
-		if i == 0 {
-			if t {
-				return 1800 //1月1市全行业
-			}
-			return 18000 //1年1市全行业
-		} else {
-			if t {
-				return 580 * icount //1月1市icount个行业
-			}
-			return 5800 * icount //1年1市icount个行业
-		}
-	}
-}

+ 17 - 59
src/jfw/modules/subscribepay/src/service/order.go → src/jfw/modules/subscribepay/src/service/vipSubscribeTrial.go

@@ -2,7 +2,9 @@ package service
 
 import (
 	"encoding/json"
+	"entity"
 	"errors"
+	"pay"
 
 	"log"
 
@@ -16,33 +18,14 @@ import (
 )
 
 //订单结构
-type Order struct {
+type TrialOrder struct {
 	*xweb.Action
-	getOrderPayMsg xweb.Mapper `xweb:"/order/getOrderPayMsg"` //订单数据展示(支付成功页面)
-	trialPay       xweb.Mapper `xweb:"/order/trialPay"`       //试用用户创建订单
-
-}
-
-type orderResult struct {
-	Success bool  //是否成功
-	Err     error //错误
-	Data    map[string]interface{}
-}
-
-func (o *orderResult) Format() *map[string]interface{} {
-	errStr := ""
-	if o.Err != nil {
-		errStr = o.Err.Error()
-	}
-	return &map[string]interface{}{
-		"success": o.Success,
-		"errMsg":  errStr,
-		"data":    o.Data,
-	}
+	getTrialOrderPayMsg xweb.Mapper `xweb:"/order/getTrialOrderPayMsg"` //订单数据展示(支付成功页面)
+	trialPay            xweb.Mapper `xweb:"/order/trialPay"`            //试用用户创建订单
 }
 
 //订单数据展示(支付成功页面)
-func (this *Order) GetOrderPayMsg() {
+func (this *TrialOrder) GetTrialOrderPayMsg() {
 	orderCode := this.GetString("orderCode")
 	userId := this.GetSession("userId")
 	query := map[string]interface{}{
@@ -64,36 +47,13 @@ func (this *Order) GetOrderPayMsg() {
 
 }
 
-//获取支付单号
-func getPayTransactionId(payWay, tradeNo string) (transaction_id string) {
-	if payWay == "" || tradeNo == "" {
-		return
-	}
-	table := ""
-	if strings.HasPrefix(payWay, "wx") {
-		table = "weixin_pay"
-	} else if strings.HasPrefix(payWay, "ali") {
-		table = "ali_pay"
-	} else {
-		return
-	}
-	query := map[string]interface{}{
-		"out_trade_no": tradeNo,
-	}
-	r := util.Mysql.FindOne(table, query, "transaction_id", "")
-	if r != nil {
-		transaction_id = qutil.ObjToString((*r)["transaction_id"])
-	}
-	return
-}
-
 //试用用户 创建订单
-func (this *Order) TrialPay() {
+func (this *TrialOrder) TrialPay() {
 	area := qutil.ObjToMap(this.GetString("area"))
 	industry := strings.Split(this.GetString("industry"), ",")
 	userId := qutil.ObjToString(this.GetSession("userId"))
 	openId := qutil.ObjToString(this.GetSession("s_m_openid"))
-	r := func() *orderResult {
+	r := func() *entity.FuncResult {
 		date_count, date_unit := 7, 3
 		now := time.Now()
 		//数据校验
@@ -112,14 +72,14 @@ func (this *Order) TrialPay() {
 			"i_comeintime": now.Unix(),
 		})
 		if mog_id == "" {
-			return &orderResult{false, errors.New("创建订单出错"), nil}
+			return &entity.FuncResult{false, errors.New("创建订单出错"), nil}
 		}
-		if !util.CanTrial(userId) {
-			return &orderResult{false, errors.New("无试用权限"), nil}
+		if !entity.CanTrial(userId) {
+			return &entity.FuncResult{false, errors.New("无试用权限"), nil}
 		}
 		//计算价格
 		totalfee := 0
-		ordercode := util.GetOrderCode(userId)
+		ordercode := pay.GetOrderCode(userId)
 		//存入订单表
 		filter := map[string]interface{}{
 			"_id":        mog_id,
@@ -148,17 +108,15 @@ func (this *Order) TrialPay() {
 			"pay_time":       qutil.FormatDate(&now, qutil.Date_Full_Layout),
 		})
 		if orderid == -1 {
-			return &orderResult{false, errors.New("数据保存异常"), nil}
+			return &entity.FuncResult{false, errors.New("数据保存异常"), nil}
 		}
-		if !util.StartTrial(userId, area, industry) { //设置开始试用
-			return &orderResult{false, errors.New("开通试用异常"), nil}
+		if !entity.StartTrial(userId, area, industry) { //设置开始试用
+			return &entity.FuncResult{false, errors.New("开通试用异常"), nil}
 		}
-		return &orderResult{true, nil, map[string]interface{}{
-			"code": ordercode,
-		}}
+		return &entity.FuncResult{true, nil, map[string]interface{}{"code": ordercode}}
 	}()
 	if r.Err != nil {
-		log.Printf("%s CreateOrder err:%v\n", userId, r.Err.Error())
+		log.Printf("%s CreateTrialOrder err:%v\n", userId, r.Err.Error())
 	}
 	this.ServeJson(r.Format())
 }

+ 0 - 842
src/jfw/modules/subscribepay/src/util/dataexport.go

@@ -1,842 +0,0 @@
-package util
-
-import (
-	"bytes"
-	"encoding/json"
-	"encoding/xml"
-	"fmt"
-	"jfw/config"
-	"log"
-	"net/rpc"
-	"qfw/util"
-	"qfw/util/mail"
-	"regexp"
-	"strings"
-	"sync"
-	"time"
-)
-
-var ExConf *DataexportConfig
-var WxStruct *WeixinStruct
-
-//价格配置文件
-type DataexportConfig struct {
-	UnitPrice_normal             float64           `json:"unitPrice_normal"`
-	UnitPrice_senior             float64           `json:"unitPrice_senior"`
-	Discount                     float64           `json:"discount"`
-	OrderMinPrice                float64           `json:"orderMinPrice"`
-	MsgMaxCount                  int               `json:"msgMaxCount"`
-	Standard_Fields              *Dataexport_Field `json:"standard"`
-	Senior_Fields                *Dataexport_Field `json:"senior"`
-	Mail_attach_content          string            `json:"mail_attach_content"`
-	Mail_attach_content_key      string            `json:"mail_attach_content_key"`
-	Mail_notice_content          string            `json:"mail_notice_content"`
-	Mail_notice_title            string            `json:"mail_notice_title"`
-	Mail_retry                   int               `json:"mail_retry"`
-	AuditPersons                 []string          `json:"auditPersons"`
-	Font                         Font              `json:"font"`
-	Mail_invoice_finance_content string            `json:"mail_invoice_finance_content"` //to北京财务订单内容
-	Mail_order_finance_content   string            `json:"mail_order_finance_content"`   //to北京财务申请发票内容
-	Finance_emails               []string          `json:"finance_emails"`
-	Qmxdomain                    string            `json:"qmxdomain"`
-	DataReportContent            string            `json:"dataReportContent"`
-}
-type Dataexport_Field struct {
-	Names  []string  `json:"names"`
-	Fields []string  `json:"fields"`
-	Widths []float64 `json:"widths"`
-}
-
-type Font struct {
-	Enabled                 bool   `json:"enabled"`
-	ConvertVersionDefault   string `json:"convertVersionDefault"`
-	UnConvertVersionDefault string `json:"unConvertVersionDefault"`
-	MappingFileExt          string `json:"mappingFileExt"`
-	MappingFilePath         string `json:"mappingFilePath"`
-	RedisPool               string `json:"redisPool"`
-	RedisKey                string `json:"redisKey"`
-}
-
-type WeixinStruct struct {
-	Appid             string
-	Mchid             string
-	Key               string
-	Dashang_attachmsg string
-	Dashang_bodymsg   string
-	Dashang_detailmsg string
-	Sjdc_attachmsg    string
-	Sjdc_bodymsg      string
-	Sjdc_detailmsg    string
-	Sjbg_msg          string
-	Subvip_msg        string
-	OpenidSwitch      *map[string]interface{}
-}
-
-/*筛选条件--关键词*/
-type KeyWord struct {
-	Keyword  string   `json:"keyword"`  //关键词
-	Appended []string `json:"appended"` //附加词
-	Exclude  []string `json:"exclude"`  //排除词
-}
-
-/*筛选条件*/
-type SieveCondition struct {
-	Id          string    `json:"id"`
-	PublishTime string    `json:"publishtime"` //发布时间
-	Area        []string  `json:"area"`        //地区-省份
-	City        []string  `json:"city"`        //地区-城市
-	Region      []string  `json:"region"`      //地区-省份+城市
-	Industry    []string  `json:"industry"`    //行业
-	Keyword     []KeyWord `json:"keywords"`    //关键词
-	Buyer       []string  `json:"buyer"`       //招标单位(采购单位)
-	Winner      []string  `json:"winner"`      //中标单位
-	ComeInTime  int64     `json:"comeintime"`  //入库时间(秒)
-	OpenId      string    `json:"openid"`      //用户openid
-	MinPrice    string    `json:"minprice"`    //金额——最少
-	MaxPrice    string    `json:"maxprice"`    //金额——最多
-	SelectType  string    `json:"selectType"`  //筛选(正文 or 标题)
-	Subtype     string    `json:"subtype"`     //信息类型
-	Comeinfrom  string    `json:"comeinfrom"`  //查询来源
-}
-
-func (w *WeixinStruct) GetTradeno(tp string) string {
-	return fmt.Sprintf("%s_%d%s%s", tp, time.Now().UnixNano(), util.GetRandom(5), util.GetLetterRandom(6))
-}
-
-//tradeno a:打赏 b:pc端数据导出 c:移动端微信数据导出 C:app数据导出  d:微信端数据报告 D:app端数据报告
-func (w *WeixinStruct) CreatePrepayOrder(weixinrpc, tradeno, ip, openid, detailmsg string, totalfee int) (string, *map[string]string) {
-	defer util.Catch()
-	attachmsg, bodymsg := "", ""
-	tradeType := ""
-	notifyUrl := ""
-
-	if tradeno == "a" { //打赏
-		tradeType = "JSAPI"
-		attachmsg, bodymsg = w.Dashang_attachmsg, w.Dashang_bodymsg
-		notifyUrl = config.Sysconfig["webdomain"].(string) + "/weixin/pay/callback"
-	} else if tradeno == "b" { //数据导出
-		tradeType = "NATIVE"
-		attachmsg, bodymsg, detailmsg = w.Sjdc_attachmsg, w.Sjdc_bodymsg, w.Sjdc_detailmsg
-		notifyUrl = config.Sysconfig["webdomain"].(string) + "/weixin/pay/callback"
-	} else if tradeno == "c" || tradeno == "C" { //移动端数据导出支付C:APP c:wx
-		if tradeno == "c" {
-			tradeType = "JSAPI"
-			notifyUrl = config.Sysconfig["webdomain"].(string) + "/weixin/pay/callback"
-		} else {
-			tradeType = "APP"
-			notifyUrl = config.Sysconfig["webdomain"].(string) + "/jyapp/dataExport/wxpay/callback"
-		}
-		attachmsg, bodymsg, detailmsg = w.Sjdc_attachmsg, w.Sjdc_bodymsg, w.Sjdc_detailmsg
-	} else if tradeno == "d" || tradeno == "D" { //数据报告 d:公众号支付  D:App
-		attachmsg, bodymsg, detailmsg = w.Sjbg_msg, w.Sjbg_msg, w.Sjbg_msg
-		if tradeno == "d" {
-			tradeType = "JSAPI"
-			notifyUrl = config.Sysconfig["webdomain"].(string) + "/front/dataReport/payCallback"
-		} else {
-			tradeType = "APP"
-			notifyUrl = config.Sysconfig["webdomain"].(string) + "/jyapp/dataReport/wxpay/callback"
-		}
-	} else if tradeno == "e" || tradeno == "E" { //vip订阅
-		attachmsg, bodymsg, detailmsg = w.Subvip_msg, w.Subvip_msg, w.Subvip_msg
-		if tradeno == "e" {
-			tradeType = "JSAPI"
-			notifyUrl = config.Sysconfig["webdomain"].(string) + "/weixin/pay/callback"
-		} else if tradeno == "E" {
-			tradeType = "APP"
-			notifyUrl = config.Sysconfig["webdomain"].(string) + "/jyapp/dataReport/wxpay/callback"
-		}
-	}
-	tradeno = w.GetTradeno(tradeno)
-	//测试环境微信支付需要转换对应的正式环境的openid
-	if w.OpenidSwitch != nil {
-		if oid, ok := (*(w.OpenidSwitch))[openid]; ok {
-			openid = oid.(string)
-		}
-	}
-	//获取预订单号
-	ret, _ := w.GetPrepayId(weixinrpc, map[string]string{
-		"attachmsg":  attachmsg,
-		"bodymsg":    bodymsg,
-		"detailmsg":  detailmsg,
-		"useropenid": openid,
-		"tradeno":    tradeno,
-		"userip":     ip,
-		"totalfee":   fmt.Sprint(totalfee),
-		"mchid":      w.Mchid,
-		"key":        w.Key,
-		"notifyUrl":  notifyUrl,
-		"appid":      w.Appid,
-		"tradeType":  tradeType, //NATIVE JSAPI APP
-	})
-	return tradeno, ret
-}
-
-//取得预生成订单编号,我们的系统要控制下,别订单重复了
-func (w *WeixinStruct) GetPrepayId(weixinrpc string, param map[string]string) (res *map[string]string, e error) {
-	util.Try(func() {
-		client, err := rpc.DialHTTP("tcp", weixinrpc)
-		defer client.Close()
-		if err != nil {
-			e = err
-			log.Println(err.Error())
-			return
-		}
-		var ret []byte
-		err = client.Call("WeiXinRpc.GetPrepayId", param, &ret)
-		if err != nil {
-			e = err
-			log.Println(err.Error())
-		} else {
-			json.Unmarshal(ret, &res)
-		}
-	}, func(e interface{}) {})
-	return
-}
-
-func init() {
-	util.ReadConfig("./dataexport.json", &ExConf)
-}
-
-type myWrite struct {
-	Byte *bytes.Buffer
-}
-
-func (m *myWrite) Write(p []byte) (n int, err error) {
-	n, err = m.Byte.Write(p)
-	return
-}
-
-//发送邮箱验证码
-func SendMailIdentCode(to, code string, auth []*mail.GmailAuth) bool {
-	html := fmt.Sprintf(`<div>
-		<div>
-			%s,您好!
-		</div>
-		<div style="padding: 20px 70px 10px 70px;">
-			<p>您正在进行导出邮箱地址验证,请在邮件验证码输入框输入下方验证码:</p>
-			<span style="font-weight: bold;font-size: x-large;">%s</span>
-			<p>请勿向任何人泄露您收到的验证码。</p>
-			<p>如果您没有使用剑鱼标讯,请忽略此邮件。</p>
-			<p>此为系统邮件,请勿回复。</p>
-			<p>如有疑问,请联系客服 400-108-6670。</p>
-		</div>
-		<div>
-			<p>此致</p>
-			<p>剑鱼标讯</p>
-		</div>	
-	</div>`, to, code)
-
-	for k, v := range auth {
-		if mail.GSendMail("剑鱼标讯", to, "", "", "剑鱼标讯邮箱校验", html, "", "", v) {
-			log.Println(to, fmt.Sprintf("使用%s发送邮件成功", v.User))
-			return true
-		}
-		if k < len(auth)-1 {
-			log.Println(to, fmt.Sprintf("使用%s发送邮件失败!3s后使用其他邮箱尝试", v.User))
-		} else {
-			log.Println(to, fmt.Sprintf("使用%s发送邮件失败!", v.User))
-		}
-		time.Sleep(time.Second * 3)
-	}
-
-	return false
-}
-
-//发送通知
-func SendNotice(order *map[string]interface{}, order_money float64, pay_time, download_url string, auth []*mail.GmailAuth) {
-	//order_id := util.Int64All((*order)["id"])
-	order_code := util.ObjToString((*order)["order_code"])
-	user_mail := util.ObjToString((*order)["user_mail"])
-	//data_spec := util.ObjToString((*order)["data_spec"])
-	//data_count := util.IntAll((*order)["data_count"])
-	url := fmt.Sprintf("%s%s", config.Sysconfig["webdomain"].(string), download_url)
-	//	content := fmt.Sprintf(ExConf.Mail_notice_content, order_id, order_code, data_count, data_spec, order_money, pay_time, user_mail, url, url)
-	for _, audit := range ExConf.AuditPersons {
-		if regexp.MustCompile("^\\d+$").MatchString(audit) {
-			SendSMS("2828100", audit, map[string]string{
-				"name":     order_code,
-				"username": user_mail,
-				"tel":      url,
-			})
-		} else {
-			//			if SendRetryMail(5, audit, ExConf.Mail_notice_title, content, "", nil, auth) {
-			//				log.Println(audit, "数据导出通知邮件发送成功")
-			//			}
-		}
-	}
-}
-
-var finaceLock *sync.Mutex = &sync.Mutex{}
-
-//给北京财务人员发邮件
-func SendMailToBJFinance(order *map[string]interface{}, pay_time, transaction_id string, mailType int, auth []*mail.GmailAuth) {
-	defer util.Catch()
-	finaceLock.Lock()
-	defer finaceLock.Unlock()
-	order_code := util.ObjToString((*order)["order_code"])
-	user_mail := util.ObjToString((*order)["user_mail"])
-	user_phone := util.ObjToString((*order)["user_phone"])
-	data_spec := util.ObjToString((*order)["data_spec"])
-	data_count := util.IntAll((*order)["data_count"])
-	pay_way := util.ObjToString((*order)["pay_way"])
-
-	if strings.Contains(pay_way, "wx") {
-		pay_way = "微信"
-	} else if strings.Contains(pay_way, "ali") {
-		pay_way = "支付宝"
-	}
-
-	create_time := util.ObjToString((*order)["create_time"])
-	if create_time != "" {
-		create_time = strings.Replace(create_time, "-", ".", -1)
-		create_time = regexp.MustCompile(":[^:]+$").ReplaceAllString(create_time, "")
-	}
-	//
-	product_type := util.ObjToString((*order)["product_type"]) + "导出"
-	//
-	order_money := float64(util.IntAll((*order)["order_money"])) / 100
-
-	if transaction_id == "" {
-		transaction_id = func() string {
-			table := ""
-			if pay_way == "微信" {
-				table = "weixin_pay"
-			} else if pay_way == "支付宝" {
-				table = "ali_pay"
-			} else {
-				return ""
-			}
-			out_trade_no := util.ObjToString((*order)["out_trade_no"])
-			wxpaydata := Mysql.FindOne(table, map[string]interface{}{
-				"out_trade_no": out_trade_no,
-			}, "transaction_id", "")
-			if wxpaydata != nil && len(*wxpaydata) > 0 { //线下支付没有微信订单编号
-				return util.ObjToString((*wxpaydata)["transaction_id"])
-			}
-			return ""
-		}()
-	}
-	isShowTransaction := "" //支付订单号为空,邮件不显示此字段
-	if transaction_id == "" {
-		isShowTransaction = "none"
-	}
-	mailcontent := ""
-	var mail_title = ""
-	selectType := "title"
-	if mailType == 1 { //支付完成后给北京财务发送导出数据接口信息的邮件
-		filter := util.ObjToString((*order)["filter"])
-		buyer, winner, subtype := "", "", ""
-		publishtime, region, industry, keys := "", "", "", ""
-		sc_money := ""
-		sc := new(SieveCondition)
-		err := json.Unmarshal([]byte(filter), &sc)
-		if err == nil && sc != nil {
-			selectType = util.ObjToString(sc.SelectType)
-			if selectType == "title" {
-				selectType = "标题匹配"
-			} else {
-				selectType = "全文匹配"
-			}
-			//
-			if pay_time != "" {
-				pay_time = strings.Replace(pay_time, "-", ".", -1)
-				pay_time = regexp.MustCompile(":[^:]+$").ReplaceAllString(pay_time, "")
-			}
-			sc_money = GetPriceDes_SieveCondition(sc.MinPrice, sc.MaxPrice)
-			pts := strings.Split(sc.PublishTime, "_")
-			if len(pts) == 2 {
-				startTime, endTime := util.Int64All(pts[0]), util.Int64All(pts[1])
-				if startTime != 0 && endTime != 0 {
-					publishtime = fmt.Sprintf("%s-%s", util.FormatDateByInt64(&startTime, util.Date_yyyyMMdd_Point), util.FormatDateByInt64(&endTime, util.Date_yyyyMMdd_Point))
-				} else if startTime == 0 && endTime != 0 {
-					publishtime = fmt.Sprintf("%s前全部", util.FormatDateByInt64(&endTime, util.Date_yyyyMMdd_Point))
-				} else if startTime != 0 && endTime == 0 {
-					publishtime = fmt.Sprintf("%s-%s", util.FormatDateByInt64(&startTime, util.Date_yyyyMMdd_Point), create_time[:10])
-				}
-			}
-			//超级搜索页面 筛选区域为 area 		没有region    移动端数据导出改
-			if sc.Region == nil {
-				region = strings.Join(sc.Area, " ")
-			} else {
-				region = strings.Join(sc.Region, " ")
-			}
-			var industryBuffer bytes.Buffer
-			for k, v := range sc.Industry {
-				if k > 0 {
-					industryBuffer.WriteString(" ")
-				}
-				vs := strings.Split(v, "_")
-				if len(vs) == 1 {
-					industryBuffer.WriteString(vs[0])
-				} else {
-					industryBuffer.WriteString(vs[1])
-				}
-			}
-			industry = industryBuffer.String()
-			var keysBuffer bytes.Buffer
-			for _, v := range sc.Keyword {
-				keysBuffer.WriteString(fmt.Sprintf(ExConf.Mail_attach_content_key, v.Keyword, strings.Join(v.Appended, " "), strings.Join(v.Exclude, " ")))
-			}
-			keys = keysBuffer.String()
-			buyer = strings.Join(sc.Buyer, " ")
-			winner = strings.Join(sc.Winner, " ")
-			subtype = strings.Replace(sc.Subtype, ",", " ", -1)
-		} else {
-			log.Println("用户筛选条件错误", err, sc)
-		}
-		mail_title = "剑鱼标讯历史数据订单【" + order_code + "】,请查收"
-		mailcontent = fmt.Sprintf(ExConf.Mail_order_finance_content, order_code, create_time, pay_time, product_type, isShowTransaction, pay_way, transaction_id, data_spec, data_count, order_money, user_mail, user_phone, publishtime, region, industry, keys, selectType, sc_money, subtype, buyer, winner)
-	} else if mailType == 2 {
-		//申请发票
-		pay_time = util.ObjToString((*order)["pay_time"])
-		if pay_time != "" {
-			pay_time = strings.Replace(pay_time, "-", ".", -1)
-			pay_time = regexp.MustCompile(":[^:]+$").ReplaceAllString(pay_time, "")
-		}
-		applybill_type := util.IntAll((*order)["applybill_type"])
-		bill_title := "个人"
-		bill_company := ""
-		bill_taxnum := ""
-		company_flag := "none"
-		taxnum_flag := "none"
-		if applybill_type != 0 {
-			bill_title = "单位"
-			bill_company = util.ObjToString((*order)["applybill_company"])
-			bill_taxnum = util.ObjToString((*order)["applybill_taxnum"])
-			company_flag = "flex"
-			taxnum_flag = "flex"
-		}
-		//线下支付获取凭证照片
-		offlineImgSrc := ""
-		if (*order)["pay_way"] == "线下支付" {
-			offlinePayMap := map[string]interface{}{}
-			offlinePayMap["out_trade_no"] = (*order)["out_trade_no"]
-			offlinePay := Mysql.FindOne("offline_pay", offlinePayMap, "", "create_time desc")
-			if imgs := util.ObjToString((*offlinePay)["img_src"]); imgs != "" {
-				ImgArr := strings.Split(imgs, ",")
-				offlineImgSrc = "<p style='margin: 0px 0px 1px; font-size: 14px; color: rgb(29, 29, 29);'>线下支付凭证:%s</p>"
-				for k, v := range ImgArr {
-					var add = ",%s"
-					if k == len(ImgArr)-1 {
-						add = ""
-					}
-					pz := fmt.Sprintf("<a href='%s'>凭证%d</a>%s", ExConf.Qmxdomain+v, k+1, add)
-					offlineImgSrc = fmt.Sprintf(offlineImgSrc, pz)
-				}
-			}
-		}
-		mail_title = "电子发票申请,剑鱼标讯历史数据订单【" + order_code + "】,请查收"
-		mailcontent = fmt.Sprintf(ExConf.Mail_invoice_finance_content, bill_title, company_flag, bill_company, taxnum_flag, bill_taxnum, order_code, create_time, pay_time, product_type, isShowTransaction, pay_way, transaction_id, offlineImgSrc, data_spec, data_count, order_money, user_mail, user_phone)
-	} else if mailType == 3 {
-		//2.8.5给北京财务发邮件内容
-	}
-	//发送邮件
-	for _, finance_mail := range ExConf.Finance_emails {
-		if regexp.MustCompile("^\\d+$").MatchString(finance_mail) {
-			continue
-		}
-		if finance_mail != "" {
-			finance_remark := "剑鱼标讯历史数据订单支付邮件"
-			if mailType == 2 {
-				finance_remark = "剑鱼标讯历史数据订单发票申请邮件"
-			}
-			if SendRetryMail(ExConf.Mail_retry, finance_mail, mail_title, mailcontent, "", nil, auth) {
-				log.Println(finance_mail, "北京财务:"+finance_remark+"发送成功!")
-			} else {
-				log.Println(finance_mail, "北京财务:"+finance_remark+"发送失败!")
-			}
-		} else {
-			log.Println(finance_mail, "北京财务:邮件地址为空")
-		}
-	}
-}
-
-////给已经付费的用户发邮件
-//func SendMailToPayUser(order *map[string]interface{}, order_money float64, pay_time, filename, download_url string, auth []*mail.GmailAuth) {
-//	defer util.Catch()
-//	log.Println("给已经付费的用户发邮件")
-//	order_id := util.Int64All((*order)["id"])
-//	order_code := util.ObjToString((*order)["order_code"])
-//	user_mail := util.ObjToString((*order)["user_mail"])
-//	user_phone := util.ObjToString((*order)["user_phone"])
-//	data_spec := util.ObjToString((*order)["data_spec"])
-//	data_count := util.IntAll((*order)["data_count"])
-//	//
-//	filter_id := util.ObjToString((*order)["filter_id"])
-//	filter := util.ObjToString((*order)["filter"])
-//	product_type := util.ObjToString((*order)["product_type"]) + "导出"
-//	//
-//	create_time := util.ObjToString((*order)["create_time"])
-//	if create_time != "" {
-//		create_time = strings.Replace(create_time, "-", ".", -1)
-//		create_time = regexp.MustCompile(":[^:]+$").ReplaceAllString(create_time, "")
-//	}
-//	//
-//	file := xlsx.NewFile()
-//	sheet, _ := file.AddSheet("Sheet1")
-//	var row *xlsx.Row
-//	var cell *xlsx.Cell
-//	//边框
-//	border := xlsx.Border{
-//		Left:        "thin",
-//		LeftColor:   "00A6A6A6",
-//		Right:       "thin",
-//		RightColor:  "00A6A6A6",
-//		Top:         "thin",
-//		TopColor:    "00A6A6A6",
-//		Bottom:      "thin",
-//		BottomColor: "00A6A6A6",
-//	}
-//	//对齐方式
-//	alignment := xlsx.Alignment{
-//		Horizontal: "center",
-//		Vertical:   "center",
-//		WrapText:   true,
-//	}
-//	//增加标题
-//	row = sheet.AddRow()
-//	row.SetHeight(30)
-//	var names []string
-//	var fields []string
-//	var widths []float64
-//	dataType := "1"
-//	if data_spec == "标准字段包" {
-//		names = ExConf.Standard_Fields.Names
-//		fields = ExConf.Standard_Fields.Fields
-//		widths = ExConf.Standard_Fields.Widths
-//	} else if data_spec == "高级字段包" {
-//		dataType = "2"
-//		names = ExConf.Senior_Fields.Names
-//		fields = ExConf.Senior_Fields.Fields
-//		widths = ExConf.Senior_Fields.Widths
-//	}
-//	style1 := &xlsx.Style{
-//		Fill:      *xlsx.NewFill("solid", "00DDD9C4", "00DDD9C4"),
-//		Border:    border,
-//		Alignment: alignment,
-//	}
-//	for k, name := range names {
-//		cell = row.AddCell()
-//		cell.SetString(name)
-//		cell.SetStyle(style1)
-//		if k < len(widths) {
-//			sheet.Col(k).Width = widths[k]
-//		}
-//	}
-//	//增加其他
-//	style2 := &xlsx.Style{
-//		Border:    border,
-//		Alignment: alignment,
-//	}
-//	list, _ := GetDataExportSearchResultUseId(filter_id, dataType, data_count)
-//	if list != nil {
-//		for _, v := range *list {
-//			row = sheet.AddRow()
-//			row.SetHeight(50)
-//			for _, field := range fields {
-//				cell = row.AddCell()
-//				cell.SetValue(v[field])
-//				cell.SetStyle(style2)
-//			}
-//		}
-//	} else {
-//		log.Println(user_mail, "数据导出邮件没有获取到数据!")
-//	}
-//	dir := "./web/staticres/res/dataexport"
-//	if strings.Contains(download_url, "jyapp") {
-//		dir = "./web/staticres/jyapp/res/dataexport"
-//	}
-//	_, path_error := os.Stat(dir)
-//	if path_error != nil && os.IsNotExist(path_error) {
-//		// 创建文件夹
-//		os.MkdirAll(dir, os.ModePerm)
-//	}
-//	err := file.Save(dir + "/" + filename)
-//	if err != nil {
-//		log.Println(user_mail, filename, "生成附件文件错误:", err)
-//	}
-//	//	mw := &myWrite{
-//	//		Byte: &bytes.Buffer{},
-//	//	}
-//	//	err = file.Write(mw)
-//	//	if err != nil {
-//	//		log.Println(user_mail, "数据导出生成excel失败!", err)
-//	//	}
-//	//	bt := mw.Byte.Bytes()
-//	now := time.Now()
-//	//fname := fmt.Sprintf("%s.xlsx", order_code)
-//	//
-//	mailcontent := ""
-//	buyer, winner, subtype := "", "", ""
-//	publishtime, region, industry, keys := "", "", "", ""
-//	sc_money := ""
-//	sc := new(SieveCondition)
-//	err = json.Unmarshal([]byte(filter), &sc)
-//	selectType := "title"
-//	if err == nil && sc != nil {
-//		selectType = util.ObjToString(sc.SelectType)
-//		if selectType == "title" {
-//			selectType = "标题匹配"
-//		} else {
-//			selectType = "全文匹配"
-//		}
-//		//
-//		if pay_time != "" {
-//			pay_time = strings.Replace(pay_time, "-", ".", -1)
-//			pay_time = regexp.MustCompile(":[^:]+$").ReplaceAllString(pay_time, "")
-//		}
-//		sc_money = GetPriceDes_SieveCondition(sc.MinPrice, sc.MaxPrice)
-//		pts := strings.Split(sc.PublishTime, "_")
-//		if len(pts) == 2 {
-//			startTime, endTime := util.Int64All(pts[0]), util.Int64All(pts[1])
-//			if startTime != 0 && endTime != 0 {
-//				publishtime = fmt.Sprintf("%s-%s", util.FormatDateByInt64(&startTime, util.Date_yyyyMMdd_Point), util.FormatDateByInt64(&endTime, util.Date_yyyyMMdd_Point))
-//			} else if startTime == 0 && endTime != 0 {
-//				publishtime = fmt.Sprintf("%s前全部", util.FormatDateByInt64(&endTime, util.Date_yyyyMMdd_Point))
-//			} else if startTime != 0 && endTime == 0 {
-//				publishtime = fmt.Sprintf("%s-%s", util.FormatDateByInt64(&startTime, util.Date_yyyyMMdd_Point), create_time[:10])
-//			}
-//		}
-//		//超级搜索页面 筛选区域为 area 		没有region    移动端数据导出改
-//		if sc.Region == nil {
-//			region = strings.Join(sc.Area, " ")
-//		} else {
-//			region = strings.Join(sc.Region, " ")
-//		}
-//		var industryBuffer bytes.Buffer
-//		for k, v := range sc.Industry {
-//			if k > 0 {
-//				industryBuffer.WriteString(" ")
-//			}
-//			vs := strings.Split(v, "_")
-//			if len(vs) == 1 {
-//				industryBuffer.WriteString(vs[0])
-//			} else {
-//				industryBuffer.WriteString(vs[1])
-//			}
-//		}
-//		industry = industryBuffer.String()
-//		var keysBuffer bytes.Buffer
-//		for _, v := range sc.Keyword {
-//			keysBuffer.WriteString(fmt.Sprintf(ExConf.Mail_attach_content_key, v.Keyword, strings.Join(v.Appended, " "), strings.Join(v.Exclude, " ")))
-//		}
-//		keys = keysBuffer.String()
-//		buyer = strings.Join(sc.Buyer, " ")
-//		winner = strings.Join(sc.Winner, " ")
-//		subtype = strings.Replace(sc.Subtype, ",", " ", -1)
-//	} else {
-//		log.Println("用户筛选条件错误", err, sc)
-//	}
-//	downloadurl := fmt.Sprintf("%s%s", config.Sysconfig["webdomain"].(string), download_url)
-//	mailcontent = fmt.Sprintf(ExConf.Mail_attach_content, downloadurl, order_code, create_time, pay_time, product_type, data_spec, data_count, order_money, user_mail, user_phone, publishtime, region, industry, keys, selectType, sc_money, subtype, buyer, winner)
-//	//发送邮件
-//	if user_mail != "" {
-//		if SendRetryMail(ExConf.Mail_retry, user_mail, "历史数据", mailcontent, "", nil, auth) {
-//			log.Println(user_mail, "用户:数据导出附件邮件发送成功!")
-//			Mysql.Update("dataexport_order", map[string]interface{}{
-//				"id": order_id,
-//			}, map[string]interface{}{
-//				"service_status": 1,
-//				"service_time":   util.FormatDate(&now, util.Date_Full_Layout),
-//			})
-//		} else {
-//			log.Println(user_mail, "用户:数据导出邮件发送失败!")
-//		}
-//	} else {
-//		log.Println(user_mail, "用户:用户邮件地址为空")
-//	}
-//	for _, audit := range ExConf.AuditPersons {
-//		if regexp.MustCompile("^\\d+$").MatchString(audit) {
-//			continue
-//		}
-//		if SendRetryMail(ExConf.Mail_retry, audit, "历史数据", mailcontent, "", nil, auth) {
-//			log.Println(audit, "管理员:数据导出附件邮件发送成功!")
-//		} else {
-//			log.Println(audit, "管理员:数据导出邮件发送失败!")
-//		}
-//	}
-//}
-
-func GetWaitPayToken(orderid int64, order_money int, ordercode, payway, userid string) string {
-	return util.GetMd5String(fmt.Sprintf("%d_%d_%s_%s_%s", orderid, order_money, ordercode, payway, userid))
-}
-func GetOrderCode_(id string) string {
-	return fmt.Sprintf("%s%s", time.Now().Format("150405"), util.GetRandom(6))
-}
-func SendRetryMail(retry int, user_mail, subject, content, fname string, bt []byte, auth []*mail.GmailAuth) bool {
-	for i := 1; i <= retry; i++ {
-		for _, v := range auth { //使用多个邮箱尝试发送
-			if mail.GSendMail_B("剑鱼标讯", user_mail, "", "", subject, content, fname, bt, v) {
-				return true
-			}
-			t := time.Duration(i) * 30 * time.Second
-			log.Println(user_mail, fmt.Sprintf("第%d轮,使用%s发送邮件失败!%v后重试", i, v.User, t))
-			time.Sleep(t)
-		}
-		if i == retry {
-			log.Println(user_mail, fmt.Sprintf("发送邮件失败"))
-		}
-	}
-	return false
-}
-
-/*
-	获取-筛选条件-金额
-*/
-func GetPriceDes_SieveCondition(minPrice, maxPrice string) string {
-	des := ""
-	unit := "万元"
-	if minPrice != "" && maxPrice != "" {
-		des = minPrice + unit + "—" + maxPrice + unit
-	} else if minPrice != "" {
-		des = "大于" + minPrice + unit
-	} else if maxPrice != "" {
-		des = "小于" + maxPrice + unit
-	}
-	return des
-}
-
-//微信支付订单关闭
-func (w *WeixinStruct) CloseOrder(weixinrpc, tradeno string) (r bool) {
-	util.Try(func() {
-		client, err := rpc.DialHTTP("tcp", weixinrpc)
-		defer client.Close()
-		if err != nil {
-			return
-		}
-		err = client.Call("WeiXinRpc.CloseOrder",
-			map[string]string{
-				"tradeno": tradeno,
-				"key":     w.Key,
-				"mchid":   w.Mchid,
-				"appid":   w.Appid,
-			}, &r)
-		if err != nil {
-			log.Println(err.Error())
-			return
-		}
-	}, func(e interface{}) {})
-	return r
-}
-
-//微信js支付获取支付参数
-func (w *WeixinStruct) GetWxjsPaySign(prepayid string) string {
-	timestamp := time.Now().Unix()
-	nonceStr := util.GetRandom(16) + util.GetLetterRandom(16)
-	sign := util.WxSign(fmt.Sprintf("appId=%s&nonceStr=%s&package=%s&signType=%s&timeStamp=%d&key=%s", w.Appid, nonceStr, "prepay_id="+prepayid, "MD5", timestamp, w.Key))
-	res := map[string]interface{}{
-		"appId":     w.Appid,
-		"timestamp": fmt.Sprint(timestamp),
-		"signType":  "MD5",
-		"sign":      sign,
-		"nonceStr":  nonceStr,
-		"prepayId":  "prepay_id=" + prepayid,
-	}
-	byteArr, _ := json.Marshal(res)
-	return string(byteArr)
-}
-
-//微信app支付 获取支付串
-func (wx *WeixinStruct) GetAppWxPayStr(prepayid string) string {
-	data := struct {
-		XMLName    xml.Name `xml:"xml"`
-		Appid      string   `xml:"appid"`
-		Partnerid  string   `xml:"partnerid"` //微信支付分配的商户号
-		Prepayid   string   `xml:"prepayid"`  //微信返回的支付交易会话ID
-		PackageStr string   `xml:"package"`   //暂填写固定值Sign=WXPay
-		Noncestr   string   `xml:"noncestr"`  //随机字符串,不长于32位。
-		Timestamp  string   `xml:"timestamp"` //时间戳
-		Sign       string   `xml:"sign"`      //签名
-	}{
-		Appid:      wx.Appid,
-		Partnerid:  wx.Mchid,
-		Prepayid:   prepayid,
-		PackageStr: "Sign=WXPay",
-		Noncestr:   util.GetRandom(16) + util.GetLetterRandom(16),
-		Timestamp:  fmt.Sprintf("%d", time.Now().Unix()),
-	}
-	data.Sign = util.CreateWxSign(fmt.Sprintf("&key=%s", wx.Key), data)
-
-	byteArr, err := json.Marshal(data)
-	if err != nil {
-		log.Printf("CreatePrepayOrder Marshal %v\n", err)
-		return ""
-	}
-	return string(byteArr)
-}
-
-//数据报告发送邮件
-func SendDatareportMailToPayUser(report_id int, out_trade_no, user_mail string, auth []*mail.GmailAuth) {
-	res := Mysql.FindOne("jy_datareport", map[string]interface{}{
-		"report_id": report_id,
-	}, "s_url", "")
-	if res == nil || (*res)["s_url"] == "" {
-		log.Println("%d:未知数据报告\n", report_id)
-		return
-	}
-	mailcontent := fmt.Sprintf(ExConf.DataReportContent, config.Sysconfig["webdomain"].(string)+(*res)["s_url"].(string))
-	if SendRetryMail(ExConf.Mail_retry, user_mail, "数据报告", mailcontent, "", nil, auth) {
-		log.Printf("用户%s:数据报告附件邮件发送成功!数据报告id:%d\n", user_mail, report_id)
-		now := time.Now()
-		Mysql.Update("jy_datareport_order", map[string]interface{}{
-			"out_trade_no": out_trade_no,
-			"report_id":    report_id,
-		}, map[string]interface{}{
-			"service_status": 1,
-			"service_time":   util.FormatDate(&now, util.Date_Full_Layout),
-		})
-	} else {
-		log.Printf("%s数据报告发送邮件出错,数据报告id:%d\n", out_trade_no, report_id)
-	}
-}
-
-//数据报告回显信息
-func GetBrforeMsg(userId, openId string) (name, phone, company, email string) {
-	order := Mysql.FindOne("jy_datareport_order", map[string]interface{}{
-		"user_id": userId,
-	}, "user_name,user_mail,user_phone,user_company", "create_time desc")
-	if order != nil {
-		name = util.ObjToString((*order)["user_name"])
-		phone = util.ObjToString((*order)["user_phone"])
-		company = util.ObjToString((*order)["user_company"])
-		email = util.ObjToString((*order)["user_mail"])
-	} else {
-		//之前没有数据报告订单查询数据导出 带出公司 手机号 邮箱字段
-		res := Mysql.FindOne("dataexport_order", map[string]interface{}{
-			"user_id": userId,
-		}, "user_mail,user_phone,applybill_company", "create_time desc")
-		if res != nil {
-			email = util.ObjToString((*res)["user_mail"])
-			phone = util.ObjToString((*res)["user_phone"])
-			company = util.ObjToString((*res)["applybill_company"])
-			log.Println(email, ",", phone)
-		}
-		if email == "" || phone == "" || openId == "" {
-			userData, _ := MQFW.FindById("user", userId, `{"o_jy":1,"s_phone":1,"s_m_openid":1}`)
-			if userData != nil {
-				if email == "" {
-					o_jy := util.ObjToMap((*userData)["o_jy"])
-					email = util.ObjToString((*o_jy)["s_email"])
-				}
-				if phone == "" {
-					phone = util.ObjToString((*userData)["s_phone"])
-				}
-				if openId == "" {
-					openId = util.ObjToString((*userData)["s_m_openid"])
-				}
-			}
-		}
-		//查询开通推送公司名称
-		if openId != "" && (company == "" || phone == "") {
-			if myapply, ok := MQFW.FindOne("applysub_user", `{"s_openid":"`+openId+`"}`); ok {
-				if company == "" {
-					company = util.ObjToString((*myapply)["s_company"])
-				}
-				if phone == "" {
-					phone = util.ObjToString((*myapply)["s_phone"])
-				}
-			}
-		}
-	}
-	return
-}

+ 3 - 0
src/jfw/modules/subscribepay/src/util/db.go

@@ -2,6 +2,7 @@ package util
 
 import (
 	. "config"
+	"qfw/util/elastic"
 	mg "qfw/util/mongodb"
 	"qfw/util/mysql"
 	"qfw/util/redis"
@@ -40,4 +41,6 @@ func init() {
 		DBName:   Config.Mysql.DbName,
 	}
 	Mysql.Init()
+	//
+	elastic.InitElasticSize(Config.Elasticsearch, Config.ElasticPoolSize)
 }

+ 0 - 21
src/jfw/modules/subscribepay/src/util/public.go

@@ -1,12 +1,8 @@
 package util
 
 import (
-	"fmt"
-
-	qutil "qfw/util"
 	"qfw/util/sms"
 	"strings"
-	"time"
 )
 
 //根据模板发送短信,模板是运营商设定的。
@@ -20,20 +16,3 @@ func SendSMS(tplcode /*模板代码*/, mobile /*手机号码*/ string, param map
 	sms.SendSms(mobile, tplcode, text)
 }
 
-//创建订单号
-func GetOrderCode(id string) string {
-	return fmt.Sprintf("%s%s", time.Now().Format("150405"), qutil.GetRandom(6))
-}
-
-//查询是否有试用权限
-func CanTrial(userId string) bool {
-	m, ok := MQFW.FindById("user", userId, `{"o_vipjy":1}`)
-	if m == nil || len(*m) == 0 || !ok {
-		return false
-	}
-	obj := qutil.ObjToMap((*m)["o_vipjy"])
-	if qutil.IntAll((*obj)["i_trial"]) != 1 {
-		return false
-	}
-	return true
-}

+ 0 - 69
src/jfw/modules/subscribepay/src/util/subutil.go

@@ -1,69 +0,0 @@
-package util
-
-import (
-	"log"
-
-	qutil "qfw/util"
-	"time"
-
-	"gopkg.in/mgo.v2/bson"
-)
-
-//设置开始试用
-func StartTrial(userId string, area *map[string]interface{}, industry []string) bool {
-	//计算服务时间
-	startTime := time.Now()
-	endTime := startTime.AddDate(0, 0, 7)
-	if !MQFW.UpdateById("user", userId,
-		bson.M{"$set": bson.M{
-			"o_vipjy.i_trial":      -1,                //已激活试用
-			"o_vipjy.o_area":       area,              //试用设置地区
-			"o_vipjy.a_buyerclass": industry,          //试用设置行业
-			"o_vipjy.a_buyset":     []int{-1, -1, -1}, //购买内容 城市、省份、行业数量
-			"l_vip_starttime":      startTime.Unix(),  //开始时间
-			"l_vip_endtime":        endTime.Unix(),    //结束时间
-			"i_vip_status":         1,                 //1试用 2正式
-		}}) {
-		return false
-	}
-	return true
-}
-
-//设置已试用
-func SetTrialed(userId string) {
-	if !MQFW.UpdateById("user", userId, bson.M{"$set": bson.M{"o_vipjy.i_trial": -1}}) {
-		log.Println(userId, "更新使用状态出错")
-	}
-}
-
-//获取省份,城市,行业购买数量;-1为全部
-//[省份,城市,行业]
-func GetBuySet(userId string) (result [3]int) {
-	mData, ok := MQFW.FindById("user", userId, `{"o_vipjy":1}`)
-	if !ok || len(*mData) == 0 || mData == nil {
-		return
-	}
-	tmp, _ := (*qutil.ObjToMap((*mData)["o_vipjy"]))["a_buyset"].([]interface{})
-	for k, v := range tmp {
-		result[k] = qutil.IntAll(v)
-	}
-	return
-}
-
-//根据区域获取城市和省份数量
-func GetBuyAreaCount(area map[string]interface{}) (result [2]int) {
-	p := []interface{}{} //省份
-	c := []interface{}{} //城市
-	for k, v := range area {
-		tmp := v.([]interface{})
-		if len(tmp) == 0 { //省份
-			result[0]++
-			p = append(p, k)
-		} else { //城市
-			result[1] += len(tmp)
-			c = append(c, tmp...)
-		}
-	}
-	log.Println(p, c)
-	return
-}

+ 60 - 0
src/jfw/modules/subscribepay/src/util/wx.go

@@ -0,0 +1,60 @@
+package util
+
+import (
+	"config"
+	"encoding/json"
+	"fmt"
+	"io/ioutil"
+	"log"
+	"net/http"
+	"net/rpc"
+	"qfw/util"
+	"qfw/util/redis"
+)
+
+func SignJSSDK(url string) []string {
+	util.Catch()
+	var signature []string
+	var key = "wxsignature_" + url
+	if ret := redis.Get("other", key); ret != nil {
+		if d, err := json.Marshal(ret); err == nil {
+			json.Unmarshal(d, &signature)
+		}
+	}
+	if signature == nil || len(signature) == 0 {
+		util.Try(func() {
+			client, err := rpc.DialHTTP("tcp", util.ObjToString(config.Config.Weixinrpc))
+			defer client.Close()
+			if err != nil {
+				log.Println(err.Error())
+				return
+			}
+			err = client.Call("WeiXinRpc.GetJSInterfaceParam", url, &signature)
+			if err != nil {
+				log.Println(err.Error())
+			}
+		}, func(e interface{}) {})
+		if signature == nil || len(signature) != 4 || signature[3] == "" {
+			signature = []string{"", "", "", ""}
+		} else {
+			redis.Put("other", key, signature, 90*60)
+		}
+	}
+	return signature
+}
+//wx获取用户openid
+func Getopenid(code string) (openid string) {
+	defer util.Catch()
+	recturl := fmt.Sprintf(config.Wxoauthinfo, code)
+	resp, err := http.Get(recturl)
+	if err != nil {
+		log.Println(err.Error())
+		return
+	}
+	defer resp.Body.Close()
+	bs, _ := ioutil.ReadAll(resp.Body)
+	data := map[string]interface{}{}
+	json.Unmarshal(bs, &data)
+	openid, _ = data["openid"].(string)
+	return
+}

二进制
src/jfw/modules/subscribepay/src/web/staticres/res/dataexport/20191101111057_110751943118_YiwEl.xlsx


二进制
src/jfw/modules/subscribepay/src/web/staticres/res/dataexport/20191101111643_111625569281_ncpRN.xlsx


二进制
src/jfw/modules/subscribepay/src/web/staticres/res/dataexport/20191102102441_102419312529_GbsLn.xlsx


二进制
src/jfw/modules/subscribepay/src/web/staticres/res/dataexport/20191102103704_103411306790_jwzPW.xlsx


二进制
src/jfw/modules/subscribepay/src/web/staticres/res/dataexport/20191102104505_104459602072_ArZWk.xlsx


二进制
src/jfw/modules/subscribepay/src/web/staticres/res/dataexport/20191102142336_112752020479_cgMbr.xlsx


二进制
src/jfw/modules/subscribepay/src/web/staticres/res/dataexport/20191102142618_142558530331_pOGGw.xlsx


二进制
src/jfw/modules/subscribepay/src/web/staticres/res/dataexport/20191102143022_143006774983_mVjxm.xlsx


二进制
src/jfw/modules/subscribepay/src/web/staticres/res/dataexport/20191102144321_144312451130_xyeJQ.xlsx


二进制
src/jfw/modules/subscribepay/src/web/staticres/res/dataexport/20191102145809_145756817218_xfYgY.xlsx


二进制
src/jfw/modules/subscribepay/src/web/staticres/res/dataexport/20191102145853_145845017344_HMKbP.xlsx


+ 5 - 5
src/jfw/modules/weixin/src/config.json

@@ -8,11 +8,11 @@
     "weixinrpcport": "8083",
     "webrpcport": "127.0.0.1:8084",
     "jyop_webrpcport": "127.0.0.1:8012",
-    "webdomain": "http://web-jydev-xzh.jianyu360.cn",
-    "appid": "wx41a95e706276804d",
-    "apptoken": "topnet2018topnet2018",
-    "appsecret": "1b385c7dd14274c5e0898b9b208580b7",
-    "proxysess": "http://web-jydev-xzh.jianyu360.cn/front/sess/%s",
+    "webdomain": "http://web-jydev-ws.jianyu360.cn",
+	"appid": "wx5b1c6e7cc4dac0e4",
+    "apptoken": "top2015top2015",
+    "appsecret": "b026103ffebd2291b3edb7a269612112",
+	"proxysess": "http://web-jydev-ws.jianyu360.cn/front/sess/%s",
     "followCompany": 10,
     "welcomemsg": "用剑鱼标讯,所有功能完全免费,\n和传统的会员制说再见!\n\n<a href='%s'>点击这里</a>设置关键词,或直接回复“订阅 关键词”,如“订阅 教学设备”,您将随时随地接收招标信息!\n\n剑鱼标讯,让投标无限可能!",
     "tpl_subscribe_push_id": "IY_RWWzMlwDK6hcd6RAzTec6qre8n5r8PNOOUM_hgk0",

二进制
src/jfw/modules/weixin/src/src


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

@@ -1,333 +0,0 @@
-package pay
-
-import (
-	"crypto"
-	"crypto/rand"
-	"crypto/rsa"
-	"crypto/sha256"
-	"crypto/x509"
-	"encoding/base64"
-	"encoding/json"
-	"encoding/pem"
-	"errors"
-	"fmt"
-	"hash"
-	"io/ioutil"
-	"jfw/config"
-	"jfw/public"
-	"log"
-	"net/http"
-	"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"`
-	Time_expire  string  `json:"time_expire"` //支付超时时间yyyy-MM-dd HH:mm:ss
-}
-
-//支付订单关闭请求参数
-type CloseContent struct {
-	OutTradeNo string `json:"out_trade_no"`
-}
-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, time_expire string) (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,
-		Time_expire:  time_expire,
-	}
-	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()
-	log.Printf("支付宝支付完成-回调  订单号%s\n", out_trade_no)
-	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_way", "")
-	changeOrderStatus, insertAliPay := false, false
-	if orderdata != nil {
-		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)
-		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":      "ali_pc",
-				"download_url": download_url,
-			})
-			if changeOrderStatus {
-				log.Println("pay_way----------------", (*orderdata)["pay_way"])
-				//先发个通知
-				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)
-	}
-}
-
-//支付宝关闭订单(生成的订单二维码,未扫码无法关闭订单)
-func (a *AliPayStruct) CloseOrder(tradeno string) bool {
-	toClose := CloseContent{
-		OutTradeNo: tradeno,
-	}
-	bizbyte, err := json.Marshal(toClose)
-	if err != nil {
-		log.Println()
-		return false
-	}
-	var data = url.Values{}
-	data.Add("app_id", Alipay.Appid)
-	data.Add("method", "alipay.trade.close")
-	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())
-	log.Println(signContentBytes)
-	signature, err := a.getSign([]byte(signContentBytes))
-	if err != nil {
-		log.Println(tradeno, "获取签名出错", err)
-		return false
-	}
-	data.Add("sign", signature)
-
-	url := a.Requseturl + "?" + data.Encode()
-	//clien 优化
-	client := http.Client{Jar: nil}
-	req, _ := http.NewRequest("POST", url, nil)
-	res, err := client.Do(req)
-	if err != nil {
-		log.Printf("%s支付宝关闭订单  请求出错%v\n", tradeno, err)
-		return false
-	}
-	bArr, err := ioutil.ReadAll(res.Body)
-	if err != nil {
-		log.Printf("%s支付宝关闭订单  读取相应出错%v\n", tradeno, err)
-		return false
-	}
-	m := map[string]interface{}{}
-	err = json.Unmarshal(bArr, &m)
-	if err != nil {
-		log.Println(string(bArr))
-		log.Println("%s支付宝关闭订单   解析相应参数出错%v\n", tradeno, err)
-	}
-	msg := (*util.ObjToMap(m["alipay_trade_close_response"]))["sub_msg"]
-	log.Printf("%s msg:%s 订单关闭相应参数  %+v", tradeno, msg, m)
-	if msg == "交易状态不合法" || msg == "REASON_ILLEGAL_STATUS" { //已支付
-		return false
-	}
-	return true
-}

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

@@ -1,753 +0,0 @@
-package pay
-
-import (
-	"bytes"
-	"encoding/base64"
-	"encoding/json"
-	"fmt"
-	"jfw/config"
-	"jfw/public"
-	"log"
-	"qfw/util"
-	"regexp"
-	"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"`       //是否支付成功
-	getOrderPayMsg        xweb.Mapper `xweb:"/dataexport/getOrderPayMsg"`         //我的订单页面获取支付二维码
-	wxSacnPay_CreateOrder xweb.Mapper `xweb:"/dataExport/wx_sacnPay/createOrder"` //微信端-创建订单
-}
-
-var reg *regexp.Regexp //匹配特殊字符
-
-func init() {
-	xweb.AddAction(&DataExportPayAction{})
-	reg, _ = regexp.Compile("[^A-Za-z0-9\u4e00-\u9fa5]")
-}
-
-//微信端创建订单
-func (p *DataExportPayAction) WxSacnPay_CreateOrder() {
-	defer util.Catch()
-	openId, _ := p.GetSession("s_m_openid").(string)
-	userId, _ := p.GetSession("userId").(string)
-	pay_way := p.GetString("pay_way")
-	id := util.SE.Decode4Hex(p.GetString("id"))
-	if userId == "" || id == "" || pay_way != "wx_js" {
-		log.Println("userId,id,pay_way错误", userId, id, pay_way)
-		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 := util.ObjToString(p.GetSession("DataExportVerifyEmail_val")) != ""
-
-	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,pay_way,out_trade_no", "")
-	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
-		}
-		var res map[string]interface{}
-		if data_spec != "" && data_spec == util.ObjToString((*oldOrder)["data_spec"]) && util.ObjToString((*oldOrder)["pay_way"]) == "wx_js" {
-			//订单未改变
-			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"]),
-			}
-		} else {
-			//在此关闭之前的订单
-			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)
-			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)
-			now := time.Now()
-			tradeno, ret := public.WxStruct.CreatePrepayOrder(config.Sysconfig["weixinrpc"].(string), "c", p.IP(), openId, "", order_money)
-			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"]),
-			}
-			public.Mysql.Update("dataexport_order", map[string]interface{}{
-				"user_id":   userId,
-				"filter_id": id,
-			}, map[string]interface{}{
-				"data_spec":      data_spec,
-				"order_money":    order_money,
-				"original_price": original_price,
-				"prepay_time":    util.FormatDate(&now, util.Date_Full_Layout),
-				"pay_way":        pay_way,
-				"prepay_id":      (*ret)["prepayid"],
-				"code_url":       (*ret)["codeurl"],
-				"out_trade_no":   tradeno,
-			})
-			(*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, 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)
-	userId, _ := p.GetSession("userId").(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, userId)
-		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 == "wx_pc" {
-				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 == "ali_pc" {
-				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 == "wx_pc" {
-		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")
-	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,pay_way,out_trade_no", "")
-	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"])) || pay_way != util.ObjToString((*oldOrder)["pay_way"]) {
-			//在此关闭之前的订单
-			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)
-			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_id":   userId,
-				"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, userId),
-			})
-			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)
-	//过滤特殊字符
-	nickname = reg.ReplaceAllString(nickname, "")
-	result := map[string]interface{}{
-		"status": "n",
-	}
-	if isPass {
-		//创建微信预支付订单
-		if pay_way == "wx_pc" {
-			tradeno, ret := public.WxStruct.CreatePrepayOrder(config.Sysconfig["weixinrpc"].(string), "b", p.IP(), openId, "", order_money)
-			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 {
-					p.SetSession("DataExportVerifyPhone_val", user_phone)
-					result["status"] = "y"
-					result["code"] = ordercode
-					result["token"] = public.GetWaitPayToken(orderid, order_money, ordercode, pay_way, userId)
-				}
-			} else {
-				log.Println("生成微信预支付交易单失败", ret)
-			}
-		} else if pay_way == "ali_pc" {
-			now := time.Now()
-			payOutTime := now.Add(time.Hour * 2)
-			if qr_url, tradeno, err := Alipay.GetPayUrl(util.Float64All(order_money), util.FormatDate(&payOutTime, util.Date_Full_Layout)); err == nil {
-				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,
-					"user_id":            userId, //20190719 移动端数据导出 生订单添加用户id
-				})
-				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, userId)
-				}
-			} else {
-				log.Println("生成支付宝预支付交易单失败")
-			}
-		}
-	}
-	p.ServeJson(result)
-}
-
-func (p *DataExportPayAction) IsPaySuccess() {
-	defer util.Catch()
-	code := p.GetString("code")
-	//openid, _ := p.GetSession("s_m_openid").(string)
-	userId, _ := p.GetSession("userId").(string)
-	status := "n"
-	if code != "" || userId != "" {
-		data := public.Mysql.FindOne("dataexport_order", map[string]interface{}{
-			"order_code": code,
-			"user_id":    userId,
-		}, "order_status", "")
-		if data != nil && util.IntAll((*data)["order_status"]) == 1 {
-			status = "y"
-		} else if util.IntAll((*data)["order_status"]) == -1 {
-			status = "-1"
-		}
-	}
-	p.ServeJson(map[string]interface{}{
-		"status": status,
-	})
-}
-
-func (p *DataExportPayAction) GetOrderPayMsg() {
-	openid := util.ObjToString(p.GetSession("s_m_openid"))
-	userId := util.ObjToString(p.GetSession("userId"))
-	code := p.GetString("orderCode")
-	pay_way := p.GetString("payway")
-	prepay_time := p.GetString("prepaytime")
-	payUrl, errMsg, ok := func() (string, string, bool) {
-		if openid == "" && userId == "" {
-			return "", "用户异常", false
-		}
-		if code == "" || pay_way == "" {
-			return "", "参数异常", false
-		}
-		queryOrder := public.Mysql.FindOne("dataexport_order", map[string]interface{}{
-			"user_id":    userId,
-			"order_code": code,
-		}, "id,order_status,order_money,out_trade_no,pay_way,prepay_time", "")
-
-		if queryOrder == nil {
-			return "", "订单异常", false
-		}
-		if util.IntAll((*queryOrder)["order_status"]) != 0 {
-			return "", "订单状态异常", false
-		}
-		//在此关闭没有超时之前的订单 在pc端支付微信端订单,pay_way是wx_js 先进行关闭,再重新创建订单的时候,pay_way需要修改成wx_pc。
-		if !CloseDataExportOrder(util.ObjToString((*queryOrder)["pay_way"]), util.ObjToString((*queryOrder)["out_trade_no"]), util.ObjToString((*queryOrder)["prepay_time"])) {
-			return "", "订单关闭异常", false
-		}
-		//修改支付方式
-		orderid := util.Int64All((*queryOrder)["id"])
-		orderMoney := util.IntAll((*queryOrder)["order_money"])
-		codeUrl := ""
-		now := time.Now()
-		prepay_time = util.FormatDate(&now, util.Date_Full_Layout)
-		if pay_way == "wx_pc" || pay_way == "wx_js" {
-			pay_way = "wx_pc" //pc端重生支付码 更新数据库
-			tradeno, ret := public.WxStruct.CreatePrepayOrder(config.Sysconfig["weixinrpc"].(string), "b", p.IP(), openid, "", orderMoney)
-			if ret != nil && (*ret)["status"] == "1" {
-				if public.Mysql.Update("dataexport_order", map[string]interface{}{
-					"id": orderid,
-				}, map[string]interface{}{
-					"prepay_time":  prepay_time,
-					"prepay_id":    (*ret)["prepayid"],
-					"code_url":     (*ret)["codeurl"],
-					"out_trade_no": tradeno,
-					"pay_way":      pay_way,
-				}) {
-					r, _ := qr.Encode(util.ObjToString((*ret)["codeurl"]), qr.M)
-					pngdat := r.PNG()
-					codeUrl = base64.StdEncoding.EncodeToString(pngdat)
-				} else {
-					return "", pay_way + "更新数据库出错", false
-				}
-			} else {
-				return "", "创建微信订单出错", false
-			}
-		} else if pay_way == "ali_pc" {
-			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":  prepay_time,
-					"prepay_id":    "",
-					"code_url":     qr_url,
-					"out_trade_no": tradeno,
-					"pay_way":      pay_way,
-				}) {
-					codeUrl = qr_url
-				} else {
-					return "", pay_way + "更新数据库出错", false
-				}
-
-			} else {
-				return "", "创建支付宝订单出错", false
-			}
-		}
-		return codeUrl, "", true
-	}()
-	if errMsg != "" {
-		log.Printf("用户%s 订单号%s 出错%s", openid, code, errMsg)
-	}
-	p.ServeJson(map[string]interface{}{
-		"success":     ok,
-		"payUrl":      payUrl,
-		"errMsg":      errMsg,
-		"prepay_time": prepay_time,
-	})
-
-}
-func CloseDataExportOrder(payWay, tradeno, prepayTime string) (status bool) {
-	//如果订单超时 则不用关闭订单
-	local, _ := time.LoadLocation("Local")
-	t, err := time.ParseInLocation(util.Date_Full_Layout, prepayTime, local)
-	//t, err := time.Parse(util.Date_Full_Layout, prepayTime)
-	if err == nil {
-		if t.Add(time.Hour * 2).Before(time.Now()) {
-			return true
-		}
-	}
-	log.Printf("%s取消订单,订单号%s\n", payWay, tradeno)
-	if payWay == "ali_pc" {
-		status = Alipay.CloseOrder(tradeno)
-	} else if payWay == "wx_pc" || payWay == "wx_js" {
-		status = public.WxStruct.CloseOrder(config.Sysconfig["weixinrpc"].(string), tradeno)
-	} else {
-		//非扫码支付 暂不处理
-		status = true
-	}
-	if !status {
-		log.Printf("%s订单关闭失败:%s\n", payWay, tradeno)
-	}
-	return status
-}

+ 0 - 323
src/jfw/pay/weixin.go

@@ -1,323 +0,0 @@
-package pay
-
-import (
-	"encoding/json"
-	"fmt"
-	"jfw/config"
-	"jfw/jyutil"
-	"jfw/public"
-	"jfw/wx"
-	"log"
-	"net/http"
-	"qfw/util"
-	"qfw/util/redis"
-	"strings"
-	"time"
-
-	"github.com/SKatiyar/qr"
-	"github.com/go-xweb/xweb"
-)
-
-type WxPayAction struct {
-	*xweb.Action
-	//打赏
-	redirectOauth xweb.Mapper `xweb:"/front/pay/redirect"`    //微信支付授权
-	getUserInfo   xweb.Mapper `xweb:"/front/pay/getUserInfo"` //微信支付获取用户信息
-	qr            xweb.Mapper `xweb:"/front/pay/qr/([^.]*)"`  //生成二维码图片
-	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"` //创建订单
-	//统一回调函数
-	payCallback xweb.Mapper `xweb:"/weixin/pay/callback"` //微信支付回调
-}
-
-func init() {
-	xweb.AddAction(&WxPayAction{})
-	payConfig := config.WeixinConfig["pay"].(map[string]interface{})
-	public.WxStruct = &public.WeixinStruct{
-		Appid:             util.ObjToString(config.WeixinConfig["appid"]),
-		Mchid:             util.ObjToString(payConfig["mchid"]),
-		Key:               util.ObjToString(payConfig["key"]),
-		Dashang_attachmsg: util.ObjToString(payConfig["attachmsg"]),
-		Dashang_bodymsg:   util.ObjToString(payConfig["bodymsg"]),
-		Dashang_detailmsg: util.ObjToString(payConfig["detailmsg"]),
-		Sjdc_attachmsg:    util.ObjToString(payConfig["sjdc_attachmsg"]),
-		Sjdc_bodymsg:      util.ObjToString(payConfig["sjdc_bodymsg"]),
-		Sjdc_detailmsg:    util.ObjToString(payConfig["sjdc_detailmsg"]),
-		Sjbg_msg:          util.ObjToString(payConfig["sjbd_msg"]),
-		Subvip_msg:        util.ObjToString(payConfig["subvip_msg"]),
-		OpenidSwitch:      util.ObjToMap(config.WeixinConfig["openidSwitch"]),
-	}
-}
-
-//转发
-func (p *WxPayAction) RedirectOauth() {
-	defer util.Catch()
-	param := p.GetString("source") + "_" + p.GetString("id")
-	webdomain := config.Sysconfig["webdomain"].(string)
-	openId, _ := p.GetSession("payOpenId").(string)
-	if openId != "" {
-		p.Redirect(webdomain+"/weixin/pay/index?param="+param, http.StatusFound)
-		return
-	}
-	urlstr := fmt.Sprintf(config.Wxoauth, fmt.Sprintf("%s/front/pay/getUserInfo?param=%s", webdomain, param), "1")
-	p.Redirect(urlstr, http.StatusFound)
-}
-
-//取用户信息,取完以后再跳转到实际支付页面
-func (p *WxPayAction) GetUserInfo() {
-	//传入openid,进入支付页面,正常情况下应该存入session
-	p.SetSession("payOpenId", jyutil.Getopenid(p.GetString("code")))
-	p.Redirect("/weixin/pay/index?param="+p.GetString("param"), http.StatusFound)
-}
-
-func (p *WxPayAction) PayIndex() error {
-	defer util.Catch()
-	param := p.GetString("param")
-	params := strings.Split(param, "_")
-	id := util.DecodeArticleId2ByCheck(params[1])[0]
-	title := ""
-	if id != "" {
-		data, ok := public.MQFW.FindById("bidding", id, `{"title":1}`)
-		if ok && (data == nil || *data == nil || len(*data) == 0) {
-			data, ok = public.MQFW.FindById("bidding_back", id, `{"title":1}`)
-		}
-		if ok && data != nil && len(*data) > 0 {
-			title, _ = (*data)["title"].(string)
-		}
-	}
-	p.T["source"] = params[0]
-	p.T["id"] = id
-	p.T["pid"] = params[1]
-	p.T["title"] = title
-	p.T["signature"] = wx.SignJSSDK(p.Site() + p.Url())
-	return p.Render("/weixin/pay.html", &p.T)
-}
-func (p *WxPayAction) WxPay() error {
-	defer util.Catch()
-	openId, _ := p.GetSession("payOpenId").(string)
-	if openId == "" {
-		p.ServeJson(map[string]interface{}{
-			"status": 0,
-		})
-		return nil
-	}
-	reqType := p.GetString("reqType")
-	if reqType == "getPrepayId" {
-		tf, _ := p.GetFloat("totalfee")
-		if tf <= 0 {
-			p.ServeJson(map[string]interface{}{
-				"status": 0,
-			})
-			return nil
-		}
-		totalfee := util.IntAll(tf * 100)
-		title := p.GetString("title")
-		detailmsg := fmt.Sprintf(public.WxStruct.Dashang_detailmsg, title, fmt.Sprint(float64(totalfee)/100))
-		tradeno, ret := public.WxStruct.CreatePrepayOrder(config.Sysconfig["weixinrpc"].(string), "a", p.IP(), openId, detailmsg, totalfee)
-		if ret == nil {
-			p.ServeJson(map[string]interface{}{
-				"status": -1,
-			})
-			return nil
-		}
-		prepayId := (*ret)["prepayid"]
-		if prepayId == "" {
-			p.ServeJson(map[string]interface{}{
-				"status": util.IntAll((*ret)["status"]),
-			})
-			return nil
-		}
-		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="+prepayId, "MD5", timestamp, public.WxStruct.Key))
-		//保存记录
-		now := time.Now()
-		public.MQFW.Save("reward", map[string]interface{}{
-			"s_source":     p.GetString("source"),
-			"s_prepayid":   prepayId,
-			"s_title":      title,
-			"s_id":         p.GetString("id"),
-			"l_createtime": now.Unix(),
-			"l_updatetime": now.Unix(),
-			"s_openid":     openId,
-			"i_year":       now.Year(),
-			"i_month":      now.Month(),
-			"i_day":        now.Day(),
-			"i_hour":       now.Hour(),
-			"i_minute":     now.Minute(),
-			"i_status":     0,
-			"i_totalfee":   totalfee,
-			"s_tradeno":    tradeno,
-			"i_operation":  0,
-		})
-		p.ServeJson(map[string]interface{}{
-			"status":    1,
-			"appId":     public.WxStruct.Appid,
-			"timestamp": fmt.Sprint(timestamp),
-			"signType":  "MD5",
-			"sign":      sign,
-			"nonceStr":  nonceStr,
-			"prepayId":  "prepay_id=" + prepayId,
-		})
-	} else if reqType == "updateOrder" {
-		operation, _ := p.GetInteger("operation")
-		prepayId := p.GetString("prepayId")
-		if operation == 1 || operation == -1 {
-			public.MQFW.Update("reward", `{"s_openid":"`+openId+`","s_prepayid":"`+prepayId+`"}`, map[string]interface{}{
-				"$set": map[string]interface{}{
-					"i_operation":  operation,
-					"l_updatetime": time.Now().Unix(),
-				},
-			}, false, false)
-		}
-	}
-	return nil
-}
-
-//微信支付成功后回调
-func (p *WxPayAction) PayCallback() {
-	defer util.Catch()
-	by := p.Body()
-	fmt.Println("回调通知参数", string(by))
-	ret := util.XmlToMap(string(by))
-	flag := false
-	if ret["return_code"] == "SUCCESS" && ret["appid"] == public.WxStruct.Appid && ret["mch_id"] == public.WxStruct.Mchid {
-		//剑鱼标讯订阅提醒  (1:关注事件,2:扫码事件,3:发送客服消息处理,4:支付操作)
-		openid := ret["openid"]
-		if openid != "" {
-			redis.Put("push", "remind&&"+openid, "4", 172800)
-		}
-		if ret["sign"] == util.CreateWxSign(fmt.Sprintf("&key=%s", public.WxStruct.Key), ret) {
-			if strings.HasPrefix(ret["out_trade_no"], "a_") { //打赏
-				query := map[string]interface{}{
-					//"s_openid":   ret["openid"],
-					"s_tradeno":  ret["out_trade_no"],
-					"i_totalfee": util.IntAll(ret["total_fee"]),
-					"i_status":   0,
-				}
-				flag = public.MQFW.Update("reward", query, map[string]interface{}{
-					"$set": map[string]interface{}{
-						"i_status":        1,
-						"s_timeend":       ret["time_end"],
-						"l_updatetime":    time.Now().Unix(),
-						"s_transactionid": ret["transaction_id"],
-					},
-				}, false, false)
-			} else if strings.HasPrefix(ret["out_trade_no"], "b_") || strings.HasPrefix(ret["out_trade_no"], "c_") { //订阅数据导出
-				now := time.Now()
-				flag_1, flag_2 := false, false
-				//
-				orderdata := public.Mysql.FindOne("dataexport_order", map[string]interface{}{
-					"out_trade_no": ret["out_trade_no"],
-					"order_money":  util.IntAll(ret["total_fee"]),
-				}, "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_way", "")
-				order_money := util.IntAll(ret["total_fee"])
-				pay_time := util.FormatDate(&now, util.Date_Full_Layout)
-				if orderdata != nil {
-					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)
-					order_status := util.IntAll((*orderdata)["order_status"])
-					if order_status == 0 {
-						flag_1 = public.Mysql.Update("dataexport_order", map[string]interface{}{
-							"order_status": 0,
-							"out_trade_no": ret["out_trade_no"],
-							"order_money":  order_money,
-							//"user_openid":  ret["openid"],
-						}, map[string]interface{}{
-							"pay_money":    util.IntAll(ret["cash_fee"]),
-							"pay_time":     pay_time,
-							"order_status": 1,
-							//"pay_way":      "微信",
-							"download_url": download_url,
-						})
-						if flag_1 {
-							//先发个通知
-							ordermoney := float64(order_money) / 100
-							go public.SendNotice(orderdata, ordermoney, pay_time, download_url, config.GmailAuth)
-							go public.SendMailToPayUser(orderdata, ordermoney, pay_time, filename, download_url, config.GmailAuth)
-							go public.SendMailToBJFinance(orderdata, pay_time, ret["transaction_id"], 1, config.GmailAuth)
-						}
-					} else {
-						flag_1 = true
-					}
-				}
-				//
-				pay_count := public.Mysql.Count("weixin_pay", map[string]interface{}{
-					"transaction_id": ret["transaction_id"],
-					"out_trade_no":   ret["out_trade_no"],
-					"user_openid":    ret["openid"],
-				})
-				if pay_count == 0 {
-					flag_2 = public.Mysql.Insert("weixin_pay", map[string]interface{}{
-						"transaction_id": ret["transaction_id"],
-						"out_trade_no":   ret["out_trade_no"],
-						"user_openid":    ret["openid"],
-						"create_time":    util.FormatDate(&now, util.Date_Full_Layout),
-						"total_fee":      util.IntAll(ret["total_fee"]),
-						"cash_fee":       util.IntAll(ret["cash_fee"]),
-						"time_end":       ret["time_end"],
-					}) > 0
-				} else if pay_count > 0 {
-					flag_2 = true
-				}
-				flag = flag_1 && flag_2
-			} else {
-				flag = true
-			}
-		} else {
-			log.Println("支付回调签名校验未通过!", ret["openid"])
-		}
-	} else {
-		log.Println("支付回调参数校验未通过!", ret["openid"])
-	}
-	if flag {
-		p.Write(`<xml>
-			  	<return_code><![CDATA[SUCCESS]]></return_code>
-			  	<return_msg><![CDATA[OK]]></return_msg>
-			</xml>`)
-	} else {
-		p.Write(`<xml>
-				<return_code><![CDATA[FAIL]]></return_code>
-				<return_msg><![CDATA[ERROR]]></return_msg>
-			</xml>`)
-	}
-}
-
-//打赏二维码图片
-func (c *WxPayAction) Qr(code string) error {
-	w := c.ResponseWriter
-	w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
-	w.Header().Set("Pragma", "no-cache")
-	w.Header().Set("Expires", "0")
-	w.Header().Set("Content-Type", "image/png")
-	data := fmt.Sprintf("%s/front/pay/redirect?id=%s&source=p", config.Sysconfig["webdomain"].(string), code)
-	r, _ := qr.Encode(data, qr.M)
-	pngdat := r.PNG()
-	_, err := w.Write(pngdat)
-	return err
-}
-
-//获取js支付参数(未方便存库返回string,前端需要转成json)
-func GetWxJsPayStr(prepayid string) string {
-	//获取订单支付字符串
-	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="+prepayid, "MD5", timestamp, public.WxStruct.Key))
-	m := map[string]interface{}{
-		"appId":     public.WxStruct.Appid,
-		"timestamp": fmt.Sprint(timestamp),
-		"signType":  "MD5",
-		"sign":      sign,
-		"nonceStr":  nonceStr,
-		"prepayId":  "prepay_id=" + prepayid,
-	}
-	byteArr, err := json.Marshal(m)
-	if err != nil {
-		log.Println("GetWxJsPayStr ", err)
-		return ""
-	}
-	return string(byteArr)
-}

+ 6 - 674
src/jfw/public/dataexport.go

@@ -1,53 +1,24 @@
 package public
 
 import (
-	"bytes"
-	"encoding/json"
-	"encoding/xml"
 	"fmt"
-	"jfw/config"
 	"log"
-	"net/rpc"
-	"os"
 	"qfw/util"
 	"qfw/util/mail"
-	"regexp"
-	"strings"
 	"sync"
 	"time"
-
-	"github.com/tealeg/xlsx"
 )
 
 var ExConf *DataexportConfig
-var WxStruct *WeixinStruct
 
 //价格配置文件
 type DataexportConfig struct {
-	UnitPrice_normal             float64           `json:"unitPrice_normal"`
-	UnitPrice_senior             float64           `json:"unitPrice_senior"`
-	Discount                     float64           `json:"discount"`
-	OrderMinPrice                float64           `json:"orderMinPrice"`
-	MsgMaxCount                  int               `json:"msgMaxCount"`
-	Standard_Fields              *Dataexport_Field `json:"standard"`
-	Senior_Fields                *Dataexport_Field `json:"senior"`
-	Mail_attach_content          string            `json:"mail_attach_content"`
-	Mail_attach_content_key      string            `json:"mail_attach_content_key"`
-	Mail_notice_content          string            `json:"mail_notice_content"`
-	Mail_notice_title            string            `json:"mail_notice_title"`
-	Mail_retry                   int               `json:"mail_retry"`
-	AuditPersons                 []string          `json:"auditPersons"`
-	Font                         Font              `json:"font"`
-	Mail_invoice_finance_content string            `json:"mail_invoice_finance_content"` //to北京财务订单内容
-	Mail_order_finance_content   string            `json:"mail_order_finance_content"`   //to北京财务申请发票内容
-	Finance_emails               []string          `json:"finance_emails"`
-	Qmxdomain                    string            `json:"qmxdomain"`
-	DataReportContent            string            `json:"dataReportContent"`
-}
-type Dataexport_Field struct {
-	Names  []string  `json:"names"`
-	Fields []string  `json:"fields"`
-	Widths []float64 `json:"widths"`
+	UnitPrice_normal float64 `json:"unitPrice_normal"`
+	UnitPrice_senior float64 `json:"unitPrice_senior"`
+	Discount         float64 `json:"discount"`
+	OrderMinPrice    float64 `json:"orderMinPrice"`
+	MsgMaxCount      int     `json:"msgMaxCount"`
+	Font             Font    `json:"font"`
 }
 
 type Font struct {
@@ -60,128 +31,10 @@ type Font struct {
 	RedisKey                string `json:"redisKey"`
 }
 
-type WeixinStruct struct {
-	Appid             string
-	Mchid             string
-	Key               string
-	Dashang_attachmsg string
-	Dashang_bodymsg   string
-	Dashang_detailmsg string
-	Sjdc_attachmsg    string
-	Sjdc_bodymsg      string
-	Sjdc_detailmsg    string
-	Sjbg_msg          string
-	Subvip_msg        string
-	OpenidSwitch      *map[string]interface{}
-}
-
-func (w *WeixinStruct) GetTradeno(tp string) string {
-	return fmt.Sprintf("%s_%d%s%s", tp, time.Now().UnixNano(), util.GetRandom(5), util.GetLetterRandom(6))
-}
-
-//tradeno a:打赏 b:pc端数据导出 c:移动端微信数据导出 C:app数据导出  d:微信端数据报告 D:app端数据报告
-func (w *WeixinStruct) CreatePrepayOrder(weixinrpc, tradeno, ip, openid, detailmsg string, totalfee int) (string, *map[string]string) {
-	defer util.Catch()
-	attachmsg, bodymsg := "", ""
-	tradeType := ""
-	notifyUrl := ""
-
-	if tradeno == "a" { //打赏
-		tradeType = "JSAPI"
-		attachmsg, bodymsg = w.Dashang_attachmsg, w.Dashang_bodymsg
-		notifyUrl = config.Sysconfig["webdomain"].(string) + "/weixin/pay/callback"
-	} else if tradeno == "b" { //数据导出
-		tradeType = "NATIVE"
-		attachmsg, bodymsg, detailmsg = w.Sjdc_attachmsg, w.Sjdc_bodymsg, w.Sjdc_detailmsg
-		notifyUrl = config.Sysconfig["webdomain"].(string) + "/weixin/pay/callback"
-	} else if tradeno == "c" || tradeno == "C" { //移动端数据导出支付C:APP c:wx
-		if tradeno == "c" {
-			tradeType = "JSAPI"
-			notifyUrl = config.Sysconfig["webdomain"].(string) + "/weixin/pay/callback"
-		} else {
-			tradeType = "APP"
-			notifyUrl = config.Sysconfig["webdomain"].(string) + "/jyapp/dataExport/wxpay/callback"
-		}
-		attachmsg, bodymsg, detailmsg = w.Sjdc_attachmsg, w.Sjdc_bodymsg, w.Sjdc_detailmsg
-	} else if tradeno == "d" || tradeno == "D" { //数据报告 d:公众号支付  D:App
-		attachmsg, bodymsg, detailmsg = w.Sjbg_msg, w.Sjbg_msg, w.Sjbg_msg
-		if tradeno == "d" {
-			tradeType = "JSAPI"
-			notifyUrl = config.Sysconfig["webdomain"].(string) + "/front/dataReport/payCallback"
-		} else {
-			tradeType = "APP"
-			notifyUrl = config.Sysconfig["webdomain"].(string) + "/jyapp/dataReport/wxpay/callback"
-		}
-	} else if tradeno == "e" || tradeno == "E" { //vip订阅
-		attachmsg, bodymsg, detailmsg = w.Subvip_msg, w.Subvip_msg, w.Subvip_msg
-		if tradeno == "e" {
-			tradeType = "JSAPI"
-			notifyUrl = config.Sysconfig["webdomain"].(string) + "/weixin/pay/callback"
-		} else if tradeno == "E" {
-			tradeType = "APP"
-			notifyUrl = config.Sysconfig["webdomain"].(string) + "/jyapp/dataReport/wxpay/callback"
-		}
-	}
-	tradeno = w.GetTradeno(tradeno)
-	//测试环境微信支付需要转换对应的正式环境的openid
-	if w.OpenidSwitch != nil {
-		if oid, ok := (*(w.OpenidSwitch))[openid]; ok {
-			openid = oid.(string)
-		}
-	}
-	//获取预订单号
-	ret, _ := w.GetPrepayId(weixinrpc, map[string]string{
-		"attachmsg":  attachmsg,
-		"bodymsg":    bodymsg,
-		"detailmsg":  detailmsg,
-		"useropenid": openid,
-		"tradeno":    tradeno,
-		"userip":     ip,
-		"totalfee":   fmt.Sprint(totalfee),
-		"mchid":      w.Mchid,
-		"key":        w.Key,
-		"notifyUrl":  notifyUrl,
-		"appid":      w.Appid,
-		"tradeType":  tradeType, //NATIVE JSAPI APP
-	})
-	return tradeno, ret
-}
-
-//取得预生成订单编号,我们的系统要控制下,别订单重复了
-func (w *WeixinStruct) GetPrepayId(weixinrpc string, param map[string]string) (res *map[string]string, e error) {
-	util.Try(func() {
-		client, err := rpc.DialHTTP("tcp", weixinrpc)
-		defer client.Close()
-		if err != nil {
-			e = err
-			log.Println(err.Error())
-			return
-		}
-		var ret []byte
-		err = client.Call("WeiXinRpc.GetPrepayId", param, &ret)
-		if err != nil {
-			e = err
-			log.Println(err.Error())
-		} else {
-			json.Unmarshal(ret, &res)
-		}
-	}, func(e interface{}) {})
-	return
-}
-
 func init() {
 	util.ReadConfig("./dataexport.json", &ExConf)
 }
 
-type myWrite struct {
-	Byte *bytes.Buffer
-}
-
-func (m *myWrite) Write(p []byte) (n int, err error) {
-	n, err = m.Byte.Write(p)
-	return
-}
-
 //发送邮箱验证码
 func SendMailIdentCode(to, code string, auth []*mail.GmailAuth) bool {
 	html := fmt.Sprintf(`<div>
@@ -218,441 +71,14 @@ func SendMailIdentCode(to, code string, auth []*mail.GmailAuth) bool {
 	return false
 }
 
-//发送通知
-func SendNotice(order *map[string]interface{}, order_money float64, pay_time, download_url string, auth []*mail.GmailAuth) {
-	//order_id := util.Int64All((*order)["id"])
-	order_code := util.ObjToString((*order)["order_code"])
-	user_mail := util.ObjToString((*order)["user_mail"])
-	//data_spec := util.ObjToString((*order)["data_spec"])
-	//data_count := util.IntAll((*order)["data_count"])
-	url := fmt.Sprintf("%s%s", config.Sysconfig["webdomain"].(string), download_url)
-	//	content := fmt.Sprintf(ExConf.Mail_notice_content, order_id, order_code, data_count, data_spec, order_money, pay_time, user_mail, url, url)
-	for _, audit := range ExConf.AuditPersons {
-		if regexp.MustCompile("^\\d+$").MatchString(audit) {
-			SendSMS("2828100", audit, map[string]string{
-				"name":     order_code,
-				"username": user_mail,
-				"tel":      url,
-			})
-		} else {
-			//			if SendRetryMail(5, audit, ExConf.Mail_notice_title, content, "", nil, auth) {
-			//				log.Println(audit, "数据导出通知邮件发送成功")
-			//			}
-		}
-	}
-}
-
 var finaceLock *sync.Mutex = &sync.Mutex{}
 
-//给北京财务人员发邮件
-func SendMailToBJFinance(order *map[string]interface{}, pay_time, transaction_id string, mailType int, auth []*mail.GmailAuth) {
-	defer util.Catch()
-	finaceLock.Lock()
-	defer finaceLock.Unlock()
-	order_code := util.ObjToString((*order)["order_code"])
-	user_mail := util.ObjToString((*order)["user_mail"])
-	user_phone := util.ObjToString((*order)["user_phone"])
-	data_spec := util.ObjToString((*order)["data_spec"])
-	data_count := util.IntAll((*order)["data_count"])
-	pay_way := util.ObjToString((*order)["pay_way"])
-
-	if strings.Contains(pay_way, "wx") {
-		pay_way = "微信"
-	} else if strings.Contains(pay_way, "ali") {
-		pay_way = "支付宝"
-	}
-
-	create_time := util.ObjToString((*order)["create_time"])
-	if create_time != "" {
-		create_time = strings.Replace(create_time, "-", ".", -1)
-		create_time = regexp.MustCompile(":[^:]+$").ReplaceAllString(create_time, "")
-	}
-	//
-	product_type := util.ObjToString((*order)["product_type"]) + "导出"
-	//
-	order_money := float64(util.IntAll((*order)["order_money"])) / 100
-
-	if transaction_id == "" {
-		transaction_id = func() string {
-			table := ""
-			if pay_way == "微信" {
-				table = "weixin_pay"
-			} else if pay_way == "支付宝" {
-				table = "ali_pay"
-			} else {
-				return ""
-			}
-			out_trade_no := util.ObjToString((*order)["out_trade_no"])
-			wxpaydata := Mysql.FindOne(table, map[string]interface{}{
-				"out_trade_no": out_trade_no,
-			}, "transaction_id", "")
-			if wxpaydata != nil && len(*wxpaydata) > 0 { //线下支付没有微信订单编号
-				return util.ObjToString((*wxpaydata)["transaction_id"])
-			}
-			return ""
-		}()
-	}
-	isShowTransaction := "" //支付订单号为空,邮件不显示此字段
-	if transaction_id == "" {
-		isShowTransaction = "none"
-	}
-	mailcontent := ""
-	var mail_title = ""
-	selectType := "title"
-	if mailType == 1 { //支付完成后给北京财务发送导出数据接口信息的邮件
-		filter := util.ObjToString((*order)["filter"])
-		buyer, winner, subtype := "", "", ""
-		publishtime, region, industry, keys := "", "", "", ""
-		sc_money := ""
-		sc := new(SieveCondition)
-		err := json.Unmarshal([]byte(filter), &sc)
-		if err == nil && sc != nil {
-			selectType = util.ObjToString(sc.SelectType)
-			if selectType == "title" {
-				selectType = "标题匹配"
-			} else {
-				selectType = "全文匹配"
-			}
-			//
-			if pay_time != "" {
-				pay_time = strings.Replace(pay_time, "-", ".", -1)
-				pay_time = regexp.MustCompile(":[^:]+$").ReplaceAllString(pay_time, "")
-			}
-			sc_money = GetPriceDes_SieveCondition(sc.MinPrice, sc.MaxPrice)
-			pts := strings.Split(sc.PublishTime, "_")
-			if len(pts) == 2 {
-				startTime, endTime := util.Int64All(pts[0]), util.Int64All(pts[1])
-				if startTime != 0 && endTime != 0 {
-					publishtime = fmt.Sprintf("%s-%s", util.FormatDateByInt64(&startTime, util.Date_yyyyMMdd_Point), util.FormatDateByInt64(&endTime, util.Date_yyyyMMdd_Point))
-				} else if startTime == 0 && endTime != 0 {
-					publishtime = fmt.Sprintf("%s前全部", util.FormatDateByInt64(&endTime, util.Date_yyyyMMdd_Point))
-				} else if startTime != 0 && endTime == 0 {
-					publishtime = fmt.Sprintf("%s-%s", util.FormatDateByInt64(&startTime, util.Date_yyyyMMdd_Point), create_time[:10])
-				}
-			}
-			//超级搜索页面 筛选区域为 area 		没有region    移动端数据导出改
-			if sc.Region == nil {
-				region = strings.Join(sc.Area, " ")
-			} else {
-				region = strings.Join(sc.Region, " ")
-			}
-			var industryBuffer bytes.Buffer
-			for k, v := range sc.Industry {
-				if k > 0 {
-					industryBuffer.WriteString(" ")
-				}
-				vs := strings.Split(v, "_")
-				if len(vs) == 1 {
-					industryBuffer.WriteString(vs[0])
-				} else {
-					industryBuffer.WriteString(vs[1])
-				}
-			}
-			industry = industryBuffer.String()
-			var keysBuffer bytes.Buffer
-			for _, v := range sc.Keyword {
-				keysBuffer.WriteString(fmt.Sprintf(ExConf.Mail_attach_content_key, v.Keyword, strings.Join(v.Appended, " "), strings.Join(v.Exclude, " ")))
-			}
-			keys = keysBuffer.String()
-			buyer = strings.Join(sc.Buyer, " ")
-			winner = strings.Join(sc.Winner, " ")
-			subtype = strings.Replace(sc.Subtype, ",", " ", -1)
-		} else {
-			log.Println("用户筛选条件错误", err, sc)
-		}
-		mail_title = "剑鱼标讯历史数据订单【" + order_code + "】,请查收"
-		mailcontent = fmt.Sprintf(ExConf.Mail_order_finance_content, order_code, create_time, pay_time, product_type, isShowTransaction, pay_way, transaction_id, data_spec, data_count, order_money, user_mail, user_phone, publishtime, region, industry, keys, selectType, sc_money, subtype, buyer, winner)
-	} else {
-		//申请发票
-		pay_time = util.ObjToString((*order)["pay_time"])
-		if pay_time != "" {
-			pay_time = strings.Replace(pay_time, "-", ".", -1)
-			pay_time = regexp.MustCompile(":[^:]+$").ReplaceAllString(pay_time, "")
-		}
-		applybill_type := util.IntAll((*order)["applybill_type"])
-		bill_title := "个人"
-		bill_company := ""
-		bill_taxnum := ""
-		company_flag := "none"
-		taxnum_flag := "none"
-		if applybill_type != 0 {
-			bill_title = "单位"
-			bill_company = util.ObjToString((*order)["applybill_company"])
-			bill_taxnum = util.ObjToString((*order)["applybill_taxnum"])
-			company_flag = "flex"
-			taxnum_flag = "flex"
-		}
-		//线下支付获取凭证照片
-		offlineImgSrc := ""
-		if (*order)["pay_way"] == "线下支付" {
-			offlinePayMap := map[string]interface{}{}
-			offlinePayMap["out_trade_no"] = (*order)["out_trade_no"]
-			offlinePay := Mysql.FindOne("offline_pay", offlinePayMap, "", "create_time desc")
-			if imgs := util.ObjToString((*offlinePay)["img_src"]); imgs != "" {
-				ImgArr := strings.Split(imgs, ",")
-				offlineImgSrc = "<p style='margin: 0px 0px 1px; font-size: 14px; color: rgb(29, 29, 29);'>线下支付凭证:%s</p>"
-				for k, v := range ImgArr {
-					var add = ",%s"
-					if k == len(ImgArr)-1 {
-						add = ""
-					}
-					pz := fmt.Sprintf("<a href='%s'>凭证%d</a>%s", ExConf.Qmxdomain+v, k+1, add)
-					offlineImgSrc = fmt.Sprintf(offlineImgSrc, pz)
-				}
-			}
-		}
-		mail_title = "电子发票申请,剑鱼标讯历史数据订单【" + order_code + "】,请查收"
-		mailcontent = fmt.Sprintf(ExConf.Mail_invoice_finance_content, bill_title, company_flag, bill_company, taxnum_flag, bill_taxnum, order_code, create_time, pay_time, product_type, isShowTransaction, pay_way, transaction_id, offlineImgSrc, data_spec, data_count, order_money, user_mail, user_phone)
-	}
-	//发送邮件
-	for _, finance_mail := range ExConf.Finance_emails {
-		if regexp.MustCompile("^\\d+$").MatchString(finance_mail) {
-			continue
-		}
-		if finance_mail != "" {
-			finance_remark := "剑鱼标讯历史数据订单支付邮件"
-			if mailType == 2 {
-				finance_remark = "剑鱼标讯历史数据订单发票申请邮件"
-			}
-			if SendRetryMail(ExConf.Mail_retry, finance_mail, mail_title, mailcontent, "", nil, auth) {
-				log.Println(finance_mail, "北京财务:"+finance_remark+"发送成功!")
-			} else {
-				log.Println(finance_mail, "北京财务:"+finance_remark+"发送失败!")
-			}
-		} else {
-			log.Println(finance_mail, "北京财务:邮件地址为空")
-		}
-	}
-}
-
-//给已经付费的用户发邮件
-func SendMailToPayUser(order *map[string]interface{}, order_money float64, pay_time, filename, download_url string, auth []*mail.GmailAuth) {
-	defer util.Catch()
-	log.Println("给已经付费的用户发邮件")
-	order_id := util.Int64All((*order)["id"])
-	order_code := util.ObjToString((*order)["order_code"])
-	user_mail := util.ObjToString((*order)["user_mail"])
-	user_phone := util.ObjToString((*order)["user_phone"])
-	data_spec := util.ObjToString((*order)["data_spec"])
-	data_count := util.IntAll((*order)["data_count"])
-	//
-	filter_id := util.ObjToString((*order)["filter_id"])
-	filter := util.ObjToString((*order)["filter"])
-	product_type := util.ObjToString((*order)["product_type"]) + "导出"
-	//
-	create_time := util.ObjToString((*order)["create_time"])
-	if create_time != "" {
-		create_time = strings.Replace(create_time, "-", ".", -1)
-		create_time = regexp.MustCompile(":[^:]+$").ReplaceAllString(create_time, "")
-	}
-	//
-	file := xlsx.NewFile()
-	sheet, _ := file.AddSheet("Sheet1")
-	var row *xlsx.Row
-	var cell *xlsx.Cell
-	//边框
-	border := xlsx.Border{
-		Left:        "thin",
-		LeftColor:   "00A6A6A6",
-		Right:       "thin",
-		RightColor:  "00A6A6A6",
-		Top:         "thin",
-		TopColor:    "00A6A6A6",
-		Bottom:      "thin",
-		BottomColor: "00A6A6A6",
-	}
-	//对齐方式
-	alignment := xlsx.Alignment{
-		Horizontal: "center",
-		Vertical:   "center",
-		WrapText:   true,
-	}
-	//增加标题
-	row = sheet.AddRow()
-	row.SetHeight(30)
-	var names []string
-	var fields []string
-	var widths []float64
-	dataType := "1"
-	if data_spec == "标准字段包" {
-		names = ExConf.Standard_Fields.Names
-		fields = ExConf.Standard_Fields.Fields
-		widths = ExConf.Standard_Fields.Widths
-	} else if data_spec == "高级字段包" {
-		dataType = "2"
-		names = ExConf.Senior_Fields.Names
-		fields = ExConf.Senior_Fields.Fields
-		widths = ExConf.Senior_Fields.Widths
-	}
-	style1 := &xlsx.Style{
-		Fill:      *xlsx.NewFill("solid", "00DDD9C4", "00DDD9C4"),
-		Border:    border,
-		Alignment: alignment,
-	}
-	for k, name := range names {
-		cell = row.AddCell()
-		cell.SetString(name)
-		cell.SetStyle(style1)
-		if k < len(widths) {
-			sheet.Col(k).Width = widths[k]
-		}
-	}
-	//增加其他
-	style2 := &xlsx.Style{
-		Border:    border,
-		Alignment: alignment,
-	}
-	list, _ := GetDataExportSearchResultUseId(filter_id, dataType, data_count)
-	if list != nil {
-		for _, v := range *list {
-			row = sheet.AddRow()
-			row.SetHeight(50)
-			for _, field := range fields {
-				cell = row.AddCell()
-				cell.SetValue(v[field])
-				cell.SetStyle(style2)
-			}
-		}
-	} else {
-		log.Println(user_mail, "数据导出邮件没有获取到数据!")
-	}
-	dir := "./web/staticres/res/dataexport"
-	if strings.Contains(download_url, "jyapp") {
-		dir = "./web/staticres/jyapp/res/dataexport"
-	}
-	_, path_error := os.Stat(dir)
-	if path_error != nil && os.IsNotExist(path_error) {
-		// 创建文件夹
-		os.MkdirAll(dir, os.ModePerm)
-	}
-	err := file.Save(dir + "/" + filename)
-	if err != nil {
-		log.Println(user_mail, filename, "生成附件文件错误:", err)
-	}
-	//	mw := &myWrite{
-	//		Byte: &bytes.Buffer{},
-	//	}
-	//	err = file.Write(mw)
-	//	if err != nil {
-	//		log.Println(user_mail, "数据导出生成excel失败!", err)
-	//	}
-	//	bt := mw.Byte.Bytes()
-	now := time.Now()
-	//fname := fmt.Sprintf("%s.xlsx", order_code)
-	//
-	mailcontent := ""
-	buyer, winner, subtype := "", "", ""
-	publishtime, region, industry, keys := "", "", "", ""
-	sc_money := ""
-	sc := new(SieveCondition)
-	err = json.Unmarshal([]byte(filter), &sc)
-	selectType := "title"
-	if err == nil && sc != nil {
-		selectType = util.ObjToString(sc.SelectType)
-		if selectType == "title" {
-			selectType = "标题匹配"
-		} else {
-			selectType = "全文匹配"
-		}
-		//
-		if pay_time != "" {
-			pay_time = strings.Replace(pay_time, "-", ".", -1)
-			pay_time = regexp.MustCompile(":[^:]+$").ReplaceAllString(pay_time, "")
-		}
-		sc_money = GetPriceDes_SieveCondition(sc.MinPrice, sc.MaxPrice)
-		pts := strings.Split(sc.PublishTime, "_")
-		if len(pts) == 2 {
-			startTime, endTime := util.Int64All(pts[0]), util.Int64All(pts[1])
-			if startTime != 0 && endTime != 0 {
-				publishtime = fmt.Sprintf("%s-%s", util.FormatDateByInt64(&startTime, util.Date_yyyyMMdd_Point), util.FormatDateByInt64(&endTime, util.Date_yyyyMMdd_Point))
-			} else if startTime == 0 && endTime != 0 {
-				publishtime = fmt.Sprintf("%s前全部", util.FormatDateByInt64(&endTime, util.Date_yyyyMMdd_Point))
-			} else if startTime != 0 && endTime == 0 {
-				publishtime = fmt.Sprintf("%s-%s", util.FormatDateByInt64(&startTime, util.Date_yyyyMMdd_Point), create_time[:10])
-			}
-		}
-		//超级搜索页面 筛选区域为 area 		没有region    移动端数据导出改
-		if sc.Region == nil {
-			region = strings.Join(sc.Area, " ")
-		} else {
-			region = strings.Join(sc.Region, " ")
-		}
-		var industryBuffer bytes.Buffer
-		for k, v := range sc.Industry {
-			if k > 0 {
-				industryBuffer.WriteString(" ")
-			}
-			vs := strings.Split(v, "_")
-			if len(vs) == 1 {
-				industryBuffer.WriteString(vs[0])
-			} else {
-				industryBuffer.WriteString(vs[1])
-			}
-		}
-		industry = industryBuffer.String()
-		var keysBuffer bytes.Buffer
-		for _, v := range sc.Keyword {
-			keysBuffer.WriteString(fmt.Sprintf(ExConf.Mail_attach_content_key, v.Keyword, strings.Join(v.Appended, " "), strings.Join(v.Exclude, " ")))
-		}
-		keys = keysBuffer.String()
-		buyer = strings.Join(sc.Buyer, " ")
-		winner = strings.Join(sc.Winner, " ")
-		subtype = strings.Replace(sc.Subtype, ",", " ", -1)
-	} else {
-		log.Println("用户筛选条件错误", err, sc)
-	}
-	downloadurl := fmt.Sprintf("%s%s", config.Sysconfig["webdomain"].(string), download_url)
-	mailcontent = fmt.Sprintf(ExConf.Mail_attach_content, downloadurl, order_code, create_time, pay_time, product_type, data_spec, data_count, order_money, user_mail, user_phone, publishtime, region, industry, keys, selectType, sc_money, subtype, buyer, winner)
-	//发送邮件
-	if user_mail != "" {
-		if SendRetryMail(ExConf.Mail_retry, user_mail, "历史数据", mailcontent, "", nil, auth) {
-			log.Println(user_mail, "用户:数据导出附件邮件发送成功!")
-			Mysql.Update("dataexport_order", map[string]interface{}{
-				"id": order_id,
-			}, map[string]interface{}{
-				"service_status": 1,
-				"service_time":   util.FormatDate(&now, util.Date_Full_Layout),
-			})
-		} else {
-			log.Println(user_mail, "用户:数据导出邮件发送失败!")
-		}
-	} else {
-		log.Println(user_mail, "用户:用户邮件地址为空")
-	}
-	for _, audit := range ExConf.AuditPersons {
-		if regexp.MustCompile("^\\d+$").MatchString(audit) {
-			continue
-		}
-		if SendRetryMail(ExConf.Mail_retry, audit, "历史数据", mailcontent, "", nil, auth) {
-			log.Println(audit, "管理员:数据导出附件邮件发送成功!")
-		} else {
-			log.Println(audit, "管理员:数据导出邮件发送失败!")
-		}
-	}
-}
-
 func GetWaitPayToken(orderid int64, order_money int, ordercode, payway, userid string) string {
 	return util.GetMd5String(fmt.Sprintf("%d_%d_%s_%s_%s", orderid, order_money, ordercode, payway, userid))
 }
 func GetOrderCode(id string) string {
 	return fmt.Sprintf("%s%s", time.Now().Format("150405"), util.GetRandom(6))
 }
-func SendRetryMail(retry int, user_mail, subject, content, fname string, bt []byte, auth []*mail.GmailAuth) bool {
-	for i := 1; i <= retry; i++ {
-		for _, v := range auth { //使用多个邮箱尝试发送
-			if mail.GSendMail_B("剑鱼标讯", user_mail, "", "", subject, content, fname, bt, v) {
-				return true
-			}
-			t := time.Duration(i) * 30 * time.Second
-			log.Println(user_mail, fmt.Sprintf("第%d轮,使用%s发送邮件失败!%v后重试", i, v.User, t))
-			time.Sleep(t)
-		}
-		if i == retry {
-			log.Println(user_mail, fmt.Sprintf("发送邮件失败"))
-		}
-	}
-	return false
-}
 
 /*
 	获取-筛选条件-金额
@@ -670,100 +96,6 @@ func GetPriceDes_SieveCondition(minPrice, maxPrice string) string {
 	return des
 }
 
-//微信支付订单关闭
-func (w *WeixinStruct) CloseOrder(weixinrpc, tradeno string) (r bool) {
-	util.Try(func() {
-		client, err := rpc.DialHTTP("tcp", weixinrpc)
-		defer client.Close()
-		if err != nil {
-			return
-		}
-		err = client.Call("WeiXinRpc.CloseOrder",
-			map[string]string{
-				"tradeno": tradeno,
-				"key":     w.Key,
-				"mchid":   w.Mchid,
-				"appid":   w.Appid,
-			}, &r)
-		if err != nil {
-			log.Println(err.Error())
-			return
-		}
-	}, func(e interface{}) {})
-	return r
-}
-
-//微信js支付获取支付参数
-func (w *WeixinStruct) GetWxjsPaySign(prepayid string) string {
-	timestamp := time.Now().Unix()
-	nonceStr := util.GetRandom(16) + util.GetLetterRandom(16)
-	sign := util.WxSign(fmt.Sprintf("appId=%s&nonceStr=%s&package=%s&signType=%s&timeStamp=%d&key=%s", w.Appid, nonceStr, "prepay_id="+prepayid, "MD5", timestamp, w.Key))
-	res := map[string]interface{}{
-		"appId":     w.Appid,
-		"timestamp": fmt.Sprint(timestamp),
-		"signType":  "MD5",
-		"sign":      sign,
-		"nonceStr":  nonceStr,
-		"prepayId":  "prepay_id=" + prepayid,
-	}
-	byteArr, _ := json.Marshal(res)
-	return string(byteArr)
-}
-
-//微信app支付 获取支付串
-func (wx *WeixinStruct) GetAppWxPayStr(prepayid string) string {
-	data := struct {
-		XMLName    xml.Name `xml:"xml"`
-		Appid      string   `xml:"appid"`
-		Partnerid  string   `xml:"partnerid"` //微信支付分配的商户号
-		Prepayid   string   `xml:"prepayid"`  //微信返回的支付交易会话ID
-		PackageStr string   `xml:"package"`   //暂填写固定值Sign=WXPay
-		Noncestr   string   `xml:"noncestr"`  //随机字符串,不长于32位。
-		Timestamp  string   `xml:"timestamp"` //时间戳
-		Sign       string   `xml:"sign"`      //签名
-	}{
-		Appid:      wx.Appid,
-		Partnerid:  wx.Mchid,
-		Prepayid:   prepayid,
-		PackageStr: "Sign=WXPay",
-		Noncestr:   util.GetRandom(16) + util.GetLetterRandom(16),
-		Timestamp:  fmt.Sprintf("%d", time.Now().Unix()),
-	}
-	data.Sign = util.CreateWxSign(fmt.Sprintf("&key=%s", wx.Key), data)
-
-	byteArr, err := json.Marshal(data)
-	if err != nil {
-		log.Printf("CreatePrepayOrder Marshal %v\n", err)
-		return ""
-	}
-	return string(byteArr)
-}
-
-//数据报告发送邮件
-func SendDatareportMailToPayUser(report_id int, out_trade_no, user_mail string, auth []*mail.GmailAuth) {
-	res := Mysql.FindOne("jy_datareport", map[string]interface{}{
-		"report_id": report_id,
-	}, "s_url", "")
-	if res == nil || (*res)["s_url"] == "" {
-		log.Println("%d:未知数据报告\n", report_id)
-		return
-	}
-	mailcontent := fmt.Sprintf(ExConf.DataReportContent, config.Sysconfig["webdomain"].(string)+(*res)["s_url"].(string))
-	if SendRetryMail(ExConf.Mail_retry, user_mail, "数据报告", mailcontent, "", nil, auth) {
-		log.Printf("用户%s:数据报告附件邮件发送成功!数据报告id:%d\n", user_mail, report_id)
-		now := time.Now()
-		Mysql.Update("jy_datareport_order", map[string]interface{}{
-			"out_trade_no": out_trade_no,
-			"report_id":    report_id,
-		}, map[string]interface{}{
-			"service_status": 1,
-			"service_time":   util.FormatDate(&now, util.Date_Full_Layout),
-		})
-	} else {
-		log.Printf("%s数据报告发送邮件出错,数据报告id:%d\n", out_trade_no, report_id)
-	}
-}
-
 //数据报告回显信息
 func GetBrforeMsg(userId, openId string) (name, phone, company, email string) {
 	order := Mysql.FindOne("jy_datareport_order", map[string]interface{}{

+ 0 - 59
src/jfw/rpcfollow/rpc.go

@@ -2,11 +2,8 @@
 package rpcfollow
 
 import (
-	"fmt"
-	"jfw/config"
 	"jfw/front"
 	public "jfw/public"
-	"log"
 	"qfw/util"
 	"qfw/util/elastic"
 	frpc "qfw/util/rpc"
@@ -128,59 +125,3 @@ func setMyFollowKey(openid, projectname string) string {
 	}
 	return rep
 }
-
-//数据导出线下支付完成调用
-func (c *MyfollowRpc) DateExportOrderFinishByOffline(param *frpc.DateExportData, ret *string) error {
-	log.Println("DateExportOrderFinishByOffline---", param)
-	util.Try(func() {
-		*ret = "1"
-		//查询订单
-		orderdata := public.Mysql.FindOne("dataexport_order", map[string]interface{}{
-			"order_code": param.OrderCode,
-		}, "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", "")
-
-		if orderdata == nil {
-			*ret = "order_nofind"
-			return
-		}
-		if util.Int64All((*orderdata)["order_status"]) != 0 {
-			*ret = "order_errStat"
-			return
-		}
-		//插入数据
-		now := time.Now()
-		pay_time := util.FormatDate(&now, util.Date_Full_Layout)
-
-		insertNum := public.Mysql.Insert("offline_pay", map[string]interface{}{
-			"out_trade_no": (*orderdata)["out_trade_no"],
-			"create_time":  pay_time,
-			"img_src":      param.ImgSrc,
-		})
-		if insertNum == 0 {
-			*ret = "order_errInsert"
-			return
-		}
-		//修改订单状态
-		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)
-		updateNum := public.Mysql.Update("dataexport_order", map[string]interface{}{
-			"order_code": param.OrderCode,
-		}, map[string]interface{}{
-			"pay_time":     pay_time,
-			"order_status": 1,
-			"pay_way":      "线下支付",
-			"download_url": download_url,
-		})
-		if !updateNum {
-			*ret = "order_errUpdate"
-			return
-		}
-		*ret = "y"
-		order_money := util.IntAll((*orderdata)["order_money"])
-		ordermoney := float64(order_money) / 100
-		go public.SendNotice(orderdata, ordermoney, pay_time, download_url, config.GmailAuth)
-		go public.SendMailToPayUser(orderdata, ordermoney, pay_time, filename, download_url, config.GmailAuth)
-		go public.SendMailToBJFinance(orderdata, pay_time, "", 1, config.GmailAuth)
-	}, func(e interface{}) {})
-	return nil
-}

+ 2 - 2
src/main.go

@@ -2,11 +2,11 @@ package main
 
 import (
 	_ "jfw/active"
-	. "jfw/config"
 	_ "jfw/filter"
 	"jfw/front"
 	_ "jfw/nodemgr"
-	_ "jfw/pay"
+
+	//_ "jfw/pay"
 	"jfw/public"
 	"jfw/qrmanager"
 	"jfw/rpcfollow"

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

@@ -506,7 +506,7 @@ function isWechat() {
 	<div class="reward-dialog">
 		<img src="{{Msg "seo" "cdn"}}/images/reward-close.png" class="reward-close">
 		<front>请微信扫码</front><br>
-		<img src="/front/pay/qr/{{.T.obj._id}}" class="qrcode">
+		<img src="/jypay/weixin/reward/qr/{{.T.obj._id}}" class="qrcode">
 	</div>
 </div>
 <!--<script type="text/javascript">

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

@@ -607,7 +607,7 @@ function isWechat() {
 	<div class="reward-dialog">
 		<img src="{{Msg "seo" "cdn"}}/images/reward-close.png" class="reward-close">
 		<front>请微信扫码</front><br>
-		<img src="/front/pay/qr/{{.T.obj._id}}" class="qrcode">
+		<img src="/jypay/weixin/reward/qr/{{.T.obj._id}}" class="qrcode">
 	</div>
 </div>
 <!--<script type="text/javascript">

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

@@ -437,7 +437,7 @@
 			param.data_spec=dataType==2?"senior":"standard";
 			param.id={{.T._id}}
 			
-			$.post("/dataExport/sacnPay/createOrder",param,function(data){
+			$.post("/jypay/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,""));

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

@@ -329,7 +329,7 @@ function updateAjax(){
 	if (submitBl){
 		$.ajax({
 			type:'post',
-			url:'/front/dataExport/applyInvoice',
+			url:'/jypay/applyInvoice',
 			data:formParam,
 			cache:false,
 			dataType:'json', 

+ 72 - 56
src/web/templates/pc/waitpay.html

@@ -122,7 +122,7 @@
             <div class="text fl">订单提交成功,请尽快支付!</div>
             <div class="fr money">
                 <div class="clearfix">
-                    <p class="fr">应付总额:<span>¥{{.T.money}}</span></p>
+                    <p class="fr">应付总额:<span id="payCount"></span></p>
                 </div>
             </div>
         </div>
@@ -131,32 +131,21 @@
             <div class="center clearfix">
                 <div class="fl">
 					<div style="position:relative;width: 300px;height: 300px;user-select: none;">
-            {{if eq .T.pay_way "wx_pc"}}
-						  {{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 "ali_pc"}}
-              <iframe src={{.T.qrcode}} style="width: 330px;height:330px;border:none;padding-left: 25px;padding-top: 25px;">
+						  <img class="show_wx" id="wxPay" src="" style="width: 330px;position:relative;left:-15px;top:-15px;display:none">
+              <iframe class="show_ali" id="aliPay" src="" style="width: 330px;height:330px;border:none;padding-left: 25px;padding-top: 25px;display:none">
               </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;">
-			            {{if eq .T.pay_way "wx_pc"}}
-			            <span>使用手机微信扫描二维码支付</span>
-			            {{end}}
-			            {{if eq .T.pay_way "ali_pc"}}
-			            <span>使用手机支付宝扫描二维码支付</span>
-			            {{end}}
+			            <span class="show_wx" style="display:none">使用手机微信扫描二维码支付</span>
+			            <span class="show_ali" style="display:none">使用手机支付宝扫描二维码支付</span>
+
 					</div>
                 </div>
                 <div class="fr">
-                {{if eq .T.pay_way "wx_pc"}}
-                    <img src="{{Msg "seo" "cdn"}}/dataExport/image/phone_wx.png" alt="">
-                {{end}}
-                {{if eq .T.pay_way "ali_pc"}}
-                     <img src="{{Msg "seo" "cdn"}}/dataExport/image/phone_zfb.png" alt="">
-                {{end}}
+                    <img class="show_wx" style="display:none" src="{{Msg "seo" "cdn"}}/dataExport/image/phone_wx.png" alt="">
+                    <img class="show_ali" style="display:none" src="{{Msg "seo" "cdn"}}/dataExport/image/phone_zfb.png" alt="">
                 </div>
             </div>
         </div>
@@ -165,43 +154,70 @@
 {{include "/common/pcbottom.html"}}
 {{include "/common/baiducc.html"}}
 <script>
-	selcetIndexNav(4);
-	haslogin("10");
-	$(".logo img").attr("src","{{Msg "seo" "cdn"}}/images/swordfish/sf_01_new.png");
-	var surplus_second = {{.T.surplus_second}};
-	if(surplus_second > 0){
-		surplus_second-=5;
-		if(surplus_second > 0){
-			var interval = setInterval(function(){
-                var h = Math.floor(surplus_second/60/60%24);
-                var m = Math.floor(surplus_second/60%60);
-                var s = Math.floor(surplus_second%60);
-				var text = "";
-				if(h>0){
-					text+=h+"时";
-				}
-				if(m>0){
-					text+=m+"分";
-				}
-				text+=s+"秒";
-				$("#surplus_second").text(text);
-				if(surplus_second <= 0){
-					clearInterval(interval);
-					$("#surplus_second").parent().text("二维码已过期,请重新刷新页面获取二维码");
-				}
-				surplus_second--;
-			},1000);
-		}else{
-			$("#surplus_second").parent().text("二维码已过期,请重新刷新页面获取二维码");
-		}
-	}
-	setInterval(function(){
-		$.post("/dataExport/pay/isPaySuccess",{code:{{.T.ordercode}}},function(r){
-			if(r.status == "y"){
-				window.location.href = "/front/dataExport/paysuccess?code="+{{.T.ordercode}};
-			}
-		});
-	},3000);
+  $(function(){
+    haslogin("10");
+    selcetIndexNav(4);
+  	$(".logo img").attr("src","{{Msg "seo" "cdn"}}/images/swordfish/sf_01_new.png");
+    $.post("/jypay/dataExport/sacnPay/waitPayMsg",{"code":getParam("code"),"token":getParam("token")},function(r){
+      if(!r.money||!r.pay_way){
+        return
+      }
+      $("#payCount").text("¥"+r.money);
+      if(r.pay_way.indexOf("wx")>-1){
+        $(".show_wx").css("display","");
+        $("#wxPay").attr("src","data:image/png;base64,"+r.qrcode);
+      }else{
+        $(".show_ali").css("display","");
+        $("#aliPay").attr("src",r.qrcode);
+      }
+      var surplus_second = r.surplus_second;
+      var ordercode=r.ordercode;
+    	if(surplus_second > 0){
+    		surplus_second-=5;
+    		if(surplus_second > 0){
+    			var interval = setInterval(function(){
+            var h = Math.floor(surplus_second/60/60%24);
+            var m = Math.floor(surplus_second/60%60);
+            var s = Math.floor(surplus_second%60);
+    				var text = "";
+    				if(h>0){
+    					text+=h+"时";
+    				}
+    				if(m>0){
+    					text+=m+"分";
+    				}
+    				text+=s+"秒";
+    				$("#surplus_second").text(text);
+    				if(surplus_second <= 0){
+    					clearInterval(interval);
+    					$("#surplus_second").parent().text("二维码已过期,请重新刷新页面获取二维码");
+    				}
+    				surplus_second--;
+    			},1000);
+    		}else{
+    			$("#surplus_second").parent().text("二维码已过期,请重新刷新页面获取二维码");
+    		}
+    	}
+    	setInterval(function(){
+    		$.post("/jypay/isPaySuccess",{code:ordercode},function(r){
+    			if(r.success){
+    				window.location.href = "/front/dataExport/paysuccess?code="+ordercode;
+    			}
+    		});
+    	},3000);
+
+    })
+  })
+   function getParam(name) {
+        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
+        var r = window.location.search.substr(1).match(reg); //获取url中"?"符后的字符串并正则匹配
+        var context = "";
+        if (r != null)
+            context = r[2];
+        reg = null;
+        r = null;
+        return context == null || context == "" || context == "undefined" ? "" : context;
+    }
 </script>
 </body>
 </html>

+ 1 - 1
src/web/templates/weixin/dataExport/dataExport_payOrder.html

@@ -750,7 +750,7 @@
 					param.data_spec=dataType==2?"senior":"standard";
 					param.id={{.T._id}}
 					//先去创建预支付订单
-					$.post("/dataExport/wx_sacnPay/createOrder",param,function(data){
+					$.post("/jypay/dataExport/weixin/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,""));

+ 1 - 1
src/web/templates/weixin/dataExport/dataExport_toMyOrder.html

@@ -288,7 +288,7 @@
 					return;
 				}
 				isReqing = true;
-				$.post("/front/wx_dataExport/getPayParm",{"filterid":filterid,"id":id,"token":token},function(res){
+				$.post("/jypay/dataExport/weixin/getPayParm",{"filterid":filterid,"id":id,"token":token},function(res){
 					isReqing = false;
 					gopayIndex = $(e).parent().parent().index();
 					if(res.status == 1){

+ 1 - 1
src/web/templates/weixin/dataExport/dataExport_toOrderDetail.html

@@ -100,7 +100,7 @@
 					return;
 				}
 				isReqing = true;
-				$.post("/front/wx_dataExport/getPayParm", {
+				$.post("/jypay/front/wx_dataExport/getPayParm", {
 					"filterid": filterid,
 					"id": id,
 					"token": token

+ 3 - 2
src/web/templates/weixin/datareport/dataReport_info.html

@@ -202,12 +202,13 @@
                     return
                   }
                   canpay=false
-                  $.post("/front/dataReport/toWxjsPay", {
+                  $.post("/jypay/dataReport/getPayParam", {
                       "s_name": s_name,
                       "s_phone": s_phone,
                       "s_email": s_email,
                       "s_reportId": {{.T.reportId}},
                       "s_company": s_company,
+                      "s_payway":"wx_js",
                   },function(r) {
                       if (r.success) {
                         onBridgeReady(JSON.parse(r.payStr))
@@ -224,7 +225,7 @@
                   clearInterval(interval);
                 }
                 interval=setInterval(function() {
-                  $.post("/front/dataReport/isPaySuccess",{"payOrderId":orderid},function(r){
+                  $.post("/jypay/dataReport/paySuccess",{"payOrderId":orderid},function(r){
                     if(r.success){
                       window.location.href = "/front/dataReport/paySuccess?email="+s_email+"&title="+{{.T.title}};
                     }

+ 3 - 3
src/web/templates/weixin/pay.html

@@ -18,7 +18,7 @@ var interflag = true;
 calcViewport("full");
 if(signature && signature.length == 4){
 	wx.config({
-	    debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
+	    debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
 	    appId: signature[0], // 必填,公众号的唯一标识
 	    timestamp:signature[1], // 必填,生成签名的时间戳
 	    nonceStr: signature[2], // 必填,生成签名的随机串
@@ -138,7 +138,7 @@ function pay(totalfee){
 		return;
 	}
 	isReqing = true;
-	$.post("/weixin/pay/pay",{"reqType":"getPrepayId","totalfee":totalfee,"title":title,"id":id,"source":source},function(res){
+	$.post("/jypay/weixin/reward/pay",{"reqType":"getPrepayId","totalfee":totalfee,"title":title,"id":id,"source":source},function(res){
 		isReqing = false;
 		if(res.status == 1){
 			onBridgeReady(res);
@@ -171,7 +171,7 @@ function onBridgeReady(res){
 			}else if(r.err_msg == "get_brand_wcpay_request:cancel"){
 				operation = -1;
 			}
-			$.post("/weixin/pay/pay",{"reqType":"updateOrder","prepayId":res["prepayId"].replace("prepay_id=",""),"operation":operation},function(){
+			$.post("/jypay/weixin/reward/pay",{"reqType":"updateOrder","prepayId":res["prepayId"].replace("prepay_id=",""),"operation":operation},function(){
 				if(operation == 1 && source == "m"){
 					if(sessionStorage){
 						sessionStorage.rewardStatus = 1;

+ 1 - 1
src/web/templates/weixin/wxinfocontent.html

@@ -1353,7 +1353,7 @@ $(function(){
 	});
 })
 function reward(){
-	window.location.href = "/front/pay/redirect?id={{.T.obj._id}}&source=m";
+	window.location.href = "/jypay/weixin/reward/redirect?id={{.T.obj._id}}&source=m";
 }
 function remask(su){
 	var state = "F";

+ 1 - 1
src/web/templates/weixin/wxinfocontent_rec.html

@@ -1657,7 +1657,7 @@ $(function(){
 	});
 })
 function reward(){
-	window.location.href = "/front/pay/redirect?id={{.T.obj._id}}&source=m";
+	window.location.href = "/jypay/weixin/reward/redirect?id={{.T.obj._id}}&source=m";
 }
 
 //

部分文件因为文件数量过多而无法显示