zhangxinlei1996 5 jaren geleden
bovenliggende
commit
ce320bbc64
100 gewijzigde bestanden met toevoegingen van 4758 en 5479 verwijderingen
  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. 45 17
      src/jfw/front/swordfish.go
  7. 6 0
      src/jfw/front/vipsubscribe.go
  8. 2 92
      src/jfw/front/ws_dataExport.go
  9. 0 43
      src/jfw/front/wxMyOrder.go
  10. 1 235
      src/jfw/modules/app/src/app/front/datareport.go
  11. 3 2
      src/jfw/modules/app/src/app/front/login.go
  12. 1 45
      src/jfw/modules/app/src/app/front/myorder.go
  13. 0 77
      src/jfw/modules/app/src/app/front/paycallbak.go
  14. 0 27
      src/jfw/modules/app/src/app/jyutil/rpccall.go
  15. 0 183
      src/jfw/modules/app/src/app/pay/alipay.go
  16. 0 462
      src/jfw/modules/app/src/app/pay/dataexport_pay.go
  17. 0 1
      src/jfw/modules/app/src/app/pay/wxpay.go
  18. 1 23
      src/jfw/modules/app/src/config.json
  19. 0 115
      src/jfw/modules/app/src/dataexport.json
  20. 2 1
      src/jfw/modules/app/src/main.go
  21. 4 4
      src/jfw/modules/app/src/web/templates/dataExport/dataExport_payOrder.html
  22. 2 2
      src/jfw/modules/app/src/web/templates/dataExport/dataExport_toMyOrder.html
  23. 2 2
      src/jfw/modules/app/src/web/templates/dataExport/dataExport_toOrderDetail.html
  24. 2 2
      src/jfw/modules/app/src/web/templates/datareport/dataReport_info.html
  25. 6 0
      src/jfw/modules/app/src/web/templates/weixin/search/mainSearch.html
  26. BIN
      src/jfw/modules/followent/src/src.exe~
  27. 1 1
      src/jfw/modules/pushent/src/followpush/push.go
  28. 0 27
      src/jfw/modules/pushent/src/rpccall/appPushServiceCall.go
  29. 4 18
      src/jfw/modules/pushent/src/rpccall/weixinrpc.go
  30. BIN
      src/jfw/modules/pushent/src/src
  31. 1 1
      src/jfw/modules/pushproject/src/followpush/push.go
  32. 0 27
      src/jfw/modules/pushproject/src/rpccall/appPushServiceCall.go
  33. 4 18
      src/jfw/modules/pushproject/src/rpccall/weixinrpc.go
  34. BIN
      src/jfw/modules/pushproject/src/src
  35. 3 2
      src/jfw/modules/pushsubscribe/src/match/config.json
  36. 15 14
      src/jfw/modules/pushsubscribe/src/match/config/config.go
  37. 1 4
      src/jfw/modules/pushsubscribe/src/match/job/freeuser.go
  38. 0 13
      src/jfw/modules/pushsubscribe/src/match/job/job.go
  39. 56 20
      src/jfw/modules/pushsubscribe/src/match/job/matchjob.go
  40. 6 3
      src/jfw/modules/pushsubscribe/src/match/job/vipuser.go
  41. 1 1
      src/jfw/modules/pushsubscribe/src/match/task.json
  42. 14 0
      src/jfw/modules/pushsubscribe/src/public/util.go
  43. 3 3
      src/jfw/modules/pushsubscribe/src/push/config.json
  44. 1 1
      src/jfw/modules/pushsubscribe/src/push/config/config.go
  45. 12 8
      src/jfw/modules/pushsubscribe/src/push/job/dopush.go
  46. BIN
      src/jfw/modules/pushsubscribe/src/push/push.exe~
  47. 5 34
      src/jfw/modules/pushsubscribe/src/push/util/rpccall.go
  48. 38 36
      src/jfw/modules/pushsubscribe/src/push/util/util.go
  49. 17 7
      src/jfw/modules/subscribepay/src/a/init.go
  50. 5 22
      src/jfw/modules/subscribepay/src/config.json
  51. 38 25
      src/jfw/modules/subscribepay/src/config/config.go
  52. 0 9
      src/jfw/modules/subscribepay/src/dataexport.json
  53. 20 0
      src/jfw/modules/subscribepay/src/entity/JsonRespStrust.go
  54. 696 0
      src/jfw/modules/subscribepay/src/entity/dataExportSearch.go
  55. 41 0
      src/jfw/modules/subscribepay/src/entity/dataReportStruct.go
  56. 668 0
      src/jfw/modules/subscribepay/src/entity/dataexport.go
  57. 63 0
      src/jfw/modules/subscribepay/src/entity/payCalbackStrust.go
  58. 29 0
      src/jfw/modules/subscribepay/src/entity/reWardStruct.go
  59. 182 0
      src/jfw/modules/subscribepay/src/entity/subscribeVip.go
  60. 5 0
      src/jfw/modules/subscribepay/src/filter/sessionfilter.go
  61. 2 0
      src/jfw/modules/subscribepay/src/main.go
  62. 222 0
      src/jfw/modules/subscribepay/src/pay/aliPay.go
  63. 75 0
      src/jfw/modules/subscribepay/src/pay/util.go
  64. 225 0
      src/jfw/modules/subscribepay/src/pay/wxPay.go
  65. 31 0
      src/jfw/modules/subscribepay/src/pay_config.json
  66. 58 0
      src/jfw/modules/subscribepay/src/rpc/rpc.go
  67. 10 6
      src/jfw/modules/subscribepay/src/service/afterPay.go
  68. 108 0
      src/jfw/modules/subscribepay/src/service/commonAction.go
  69. 602 0
      src/jfw/modules/subscribepay/src/service/dataExportPay_mobile.go
  70. 483 0
      src/jfw/modules/subscribepay/src/service/dataExportPay_pc.go
  71. 141 0
      src/jfw/modules/subscribepay/src/service/dataReport.go
  72. 32 8
      src/jfw/modules/subscribepay/src/service/orderListDetails.go
  73. 122 0
      src/jfw/modules/subscribepay/src/service/payCallback.go
  74. 144 0
      src/jfw/modules/subscribepay/src/service/reward.go
  75. 0 16
      src/jfw/modules/subscribepay/src/service/test.go
  76. 3 2
      src/jfw/modules/subscribepay/src/service/vipSubscribeEdit.go
  77. 29 145
      src/jfw/modules/subscribepay/src/service/vipSubscribePay.go
  78. 17 59
      src/jfw/modules/subscribepay/src/service/vipSubscribeTrial.go
  79. 38 0
      src/jfw/modules/subscribepay/src/timetask/timetask.go
  80. 0 842
      src/jfw/modules/subscribepay/src/util/dataexport.go
  81. 10 0
      src/jfw/modules/subscribepay/src/util/db.go
  82. 0 21
      src/jfw/modules/subscribepay/src/util/public.go
  83. 0 69
      src/jfw/modules/subscribepay/src/util/subutil.go
  84. 52 18
      src/jfw/modules/subscribepay/src/util/vrew.go
  85. 60 0
      src/jfw/modules/subscribepay/src/util/wx.go
  86. 5 5
      src/jfw/modules/weixin/src/config.json
  87. BIN
      src/jfw/modules/weixin/src/src
  88. 0 333
      src/jfw/pay/aliPay.go
  89. 0 753
      src/jfw/pay/dataExportPay.go
  90. 0 323
      src/jfw/pay/weixin.go
  91. 6 674
      src/jfw/public/dataexport.go
  92. 75 67
      src/jfw/public/historypush.go
  93. 0 18
      src/jfw/public/rpccall.go
  94. 0 59
      src/jfw/rpcfollow/rpc.go
  95. 2 1
      src/jfw/timetask/followtimetask.go
  96. 2 2
      src/main.go
  97. 10 2
      src/web/staticres/css/wxlist.css
  98. 4 4
      src/web/staticres/vipsubscribe/css/base.css
  99. 32 0
      src/web/staticres/vipsubscribe/css/public.css
  100. 114 11
      src/web/staticres/vipsubscribe/css/subscribe_list.css

+ 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"

File diff suppressed because it is too large
+ 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 = ""

+ 45 - 17
src/jfw/front/swordfish.go

@@ -2354,6 +2354,7 @@ func (f *Front) HasPushHistory() {
 	//获取时间
 	var formatTime string
 	selectTime := f.GetString("selectTime")
+	log.Println("selecttime:", selectTime)
 	lenStr := len([]rune(selectTime))
 	if selectTime != "" {
 		if selectTime != "undefined" && lenStr >= 10 {
@@ -2370,36 +2371,63 @@ func (f *Front) HasPushHistory() {
 		return
 	}
 	user, firstPushTime := public.HistoryPush.UserInfo(userId)
-	var o_jy map[string]interface{}
-	if user != nil {
-		o_jy, _ = (*user)["o_jy"].(map[string]interface{})
-	}
+	hasKeyFlag := false
+	isVipFlag := false
+	isPassCount := false
+	isExpire := 0
+	tedayNum := time.Unix(time.Now().Unix(), 1).Format("20060102")
+	isOnTail := 0
+	log.Println(tedayNum)
+	if util.IntAll((*user)["i_vip_status"]) == 1 || util.IntAll((*user)["i_vip_status"]) == 2 {
+		//
+		var threeRemind = int64(3 * 24 * 60 * 60)
+		var twoRemind = int64(2 * 24 * 60 * 60)
+		var oneRemind = int64(1 * 24 * 60 * 60)
+		var o_vipjy map[string]interface{}
+		o_vipjy, _ = (*user)["o_vipjy"].(map[string]interface{})
+		a_itmes := util.ObjArrToMapArr(o_vipjy["a_items"].([]interface{}))
+		hasKeyFlag = len(a_itmes) > 0
+		isVipFlag = true
+		isPassCount = redis.GetInt("pushcache_2_a", "oncecount_"+tedayNum+"_"+userId) > 2000
+		isOnTail = util.IntAll((*user)["i_vip_status"])
+		_endtime := (*user)["l_vip_endtime"]
+		//是否到期
+		if util.Int64All(_endtime)-time.Now().Unix() < threeRemind && util.Int64All(_endtime)-time.Now().Unix() >= twoRemind {
+			isExpire = 3 //即将到期
+		} else if util.Int64All(_endtime)-time.Now().Unix() < twoRemind && util.Int64All(_endtime)-time.Now().Unix() >= oneRemind {
+			isExpire = 2 //即将到期
+		} else if util.Int64All(_endtime)-time.Now().Unix() < oneRemind && util.Int64All(_endtime)-time.Now().Unix() >= 0 {
+			isExpire = 1 //即将到期
+		}
+	} else {
+		var o_jy map[string]interface{}
+		if user != nil {
+			o_jy, _ = (*user)["o_jy"].(map[string]interface{})
+		}
 
-	keyArr := []string{}
-	if o_jy != nil || len(o_jy) == 0 {
-		a_key, _ := o_jy["a_key"].([]interface{})
-		for _, vi := range a_key {
-			v, _ := vi.(map[string]interface{})
-			keys_a := v["key"].([]interface{})
-			if thiskey := strings.TrimSpace(strings.Join(util.ObjArrToStringArr(keys_a), "+")); thiskey != "" {
-				keyArr = append(keyArr, thiskey)
-			}
+		if o_jy != nil || len(o_jy) == 0 {
+			a_key, _ := o_jy["a_key"].([]interface{})
+			hasKeyFlag = len(a_key) > 0
 		}
+		isPassCount = redis.GetInt("pushcache_2_a", "oncecount_"+tedayNum+"_"+userId) > 50
 	}
 	hasNextPage, list, err := public.HistoryPush.Datas(userId, 1, firstPushTime, formatTime)
-	if err == nil && len(keyArr) > 0 && len(list) == 0 && formatTime == "" {
-		flag, data := public.HistoryPush.MakeHistoryDatas(userId, bidSearch_field_1, o_jy)
+	if err == nil && hasKeyFlag && len(list) == 0 && formatTime == "" && !isVipFlag {
+		flag, data := public.HistoryPush.MakeHistoryDatas(userId, bidSearch_field_1)
 		if flag && data != nil {
 			list = data
 		}
 	}
 	//
 	f.ServeJson(map[string]interface{}{
-		"haskey":      len(keyArr) > 0,
+		"haskey":      hasKeyFlag,
 		"data":        list,
 		"hasNextPage": hasNextPage,
 		"isInTSguide": isInTSguide(userId),
-		"keys":        keyArr,
+		"isVipSub":    isVipFlag,
+		"isPassCount": isPassCount,
+		"isExpire":    isExpire,
+		"isOnTail":    isOnTail,
 	})
 }
 

+ 6 - 0
src/jfw/front/vipsubscribe.go

@@ -20,6 +20,7 @@ type Subscribepay struct {
 	toSetInfoTypePage xweb.Mapper `xweb:"/front/vipsubscribe/toSetInfoTypePage"`   //订阅收费设置信息类型
 	toSetPushSetPage  xweb.Mapper `xweb:"/front/vipsubscribe/toSetPushSetPage"`    //订阅收费推送设置
 	toSetOtherKwsPage xweb.Mapper `xweb:"/front/vipsubscribe/toSet(.*)Page"`       //订阅收费附加词和排除词设置
+	toVIPViewPage     xweb.Mapper `xweb:"/front/vipsubscribe/toVIPViewPage"`       //订阅收费预览
 
 	//修改
 	toEditSubPage     xweb.Mapper `xweb:"/front/vipsubscribe/toEditSubPage"`     //订阅收费修改页面
@@ -44,6 +45,11 @@ func init() {
 	xweb.AddAction(&Subscribepay{})
 }
 
+//推送设置
+func (s *Subscribepay) ToVIPViewPage() {
+	s.Render("/weixin/vipsubscribe/vip_viewPage.html")
+}
+
 //附加词|排除词
 func (s *Subscribepay) ToSetOtherKwsPage(page string) {
 	s.Render("/weixin/vipsubscribe/" + page + "Word.html")

+ 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

@@ -28,7 +28,6 @@ type WxMyOrder struct {
 
 	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"`    //获取额外一条数据
@@ -562,48 +561,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

+ 3 - 2
src/jfw/modules/app/src/app/front/login.go

@@ -10,6 +10,7 @@ import (
 	"log"
 	"net/http"
 	qutil "qfw/util"
+	"qfw/util/jy"
 	"qfw/util/redis"
 	"regexp"
 	"strings"
@@ -912,7 +913,7 @@ func afterLogin(user map[string]interface{}, session *httpsession.Session, rid,
 				})
 				//
 				log.Println("踢人下线", old_ponetype, userid, old_rid, old_oid)
-				jyutil.AppPushServiceCall(map[string]interface{}{
+				jy.AppPush(config.Sysconfig["appPushServiceRpc"].(string), map[string]interface{}{
 					"type":        "signOut",
 					"descript":    kickedTip,
 					"jgPushId":    old_rid,
@@ -1086,7 +1087,7 @@ func checkRepeatLogin(user *map[string]interface{}, rid, oid string) {
 		//
 		go func() {
 			log.Println("踢人下线", ponetype, userid, jpushid, opushid)
-			jyutil.AppPushServiceCall(map[string]interface{}{
+			jy.AppPush(config.Sysconfig["appPushServiceRpc"].(string), map[string]interface{}{
 				"type":        "signOut",
 				"descript":    kickedTip,
 				"jgPushId":    jpushid,

+ 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 - 27
src/jfw/modules/app/src/app/jyutil/rpccall.go

@@ -1,27 +0,0 @@
-package jyutil
-
-import (
-	"encoding/json"
-	"jfw/config"
-	"log"
-	"net/rpc"
-	"qfw/util"
-)
-
-func AppPushServiceCall(m map[string]interface{}) bool {
-	defer util.Catch()
-	var repl string
-	client, err := rpc.DialHTTP("tcp", config.Sysconfig["appPushServiceRpc"].(string))
-	if err != nil {
-		log.Println(err.Error())
-		return false
-	}
-	defer client.Close()
-	b, _ := json.Marshal(m)
-	err = client.Call("Rpc.Push", b, &repl)
-	if err != nil {
-		log.Println(err.Error())
-		return false
-	}
-	return repl == "y"
-}

+ 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 - 1
src/jfw/modules/app/src/app/pay/wxpay.go

@@ -3,7 +3,6 @@ package pay
 import (
 	"jfw/config"
 	"jfw/public"
-	"log"
 	"qfw/util"
 )
 

+ 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",

File diff suppressed because it is too large
+ 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>

BIN
src/jfw/modules/followent/src/src.exe~


+ 1 - 1
src/jfw/modules/pushent/src/followpush/push.go

@@ -403,7 +403,7 @@ func push(fid, sname, userId string, res *[]map[string]interface{}) {
 					descriptAppend = fmt.Sprintf("\n...(共%d条)", pushnum)
 					jpushtitle = fmt.Sprintf("1. %s", jpushtitle)
 				}
-				isPushOk := rpccall.AppPushServiceCall(map[string]interface{}{
+				isPushOk := jy.AppPush(Sysconfig["appPushServiceRpc"].(string), map[string]interface{}{
 					"phoneType":      phoneType,
 					"otherPushId":    opushid,
 					"jgPushId":       jpushid,

+ 0 - 27
src/jfw/modules/pushent/src/rpccall/appPushServiceCall.go

@@ -1,27 +0,0 @@
-package rpccall
-
-import (
-	"config"
-	"encoding/json"
-	"log"
-	"net/rpc"
-	"qfw/util"
-)
-
-func AppPushServiceCall(m map[string]interface{}) bool {
-	defer util.Catch()
-	var repl string
-	client, err := rpc.DialHTTP("tcp", config.Sysconfig["appPushServiceRpc"].(string))
-	if err != nil {
-		log.Println(err.Error())
-		return false
-	}
-	defer client.Close()
-	b, _ := json.Marshal(m)
-	err = client.Call("Rpc.Push", b, &repl)
-	if err != nil {
-		log.Println(err.Error())
-		return false
-	}
-	return repl == "y"
-}

+ 4 - 18
src/jfw/modules/pushent/src/rpccall/weixinrpc.go

@@ -2,8 +2,7 @@ package rpccall
 
 import (
 	"config"
-	"log"
-	"net/rpc"
+	"qfw/util/jy"
 	qrpc "qfw/util/rpc"
 	"strings"
 	"time"
@@ -13,26 +12,13 @@ import (
 //微信远程调用,实现模板发送消息
 func SendWinXin(p *qrpc.NotifyMsg, userId string) bool {
 	time.Sleep(10 * time.Millisecond)
-	client, err := rpc.DialHTTP("tcp", config.Sysconfig["weixinRpcServer"].(string))
-	if err != nil {
-		log.Println(err.Error())
-		return false
-	}
-	defer client.Close()
-	var repl qrpc.RpcResult
-	err = client.Call("WeiXinRpc.SendPushMsg", p, &repl)
-	if err != nil {
-		log.Println(err.Error())
-		return false
-	}
-	res := string(repl)
-	if strings.Contains(res, "[46004]") || strings.Contains(res, "[65302]") || strings.Contains(res, "[43004]") || strings.Contains(res, "[40003]") {
+	ok, res := jy.WxPush(config.Sysconfig["weixinRpcServer"].(string), "WeiXinRpc.SendPushMsg", p)
+	if !ok && (strings.Contains(res, "[46004]") || strings.Contains(res, "[65302]") || strings.Contains(res, "[43004]") || strings.Contains(res, "[40003]")) {
 		tools.MQFW.UpdateById("user", userId, map[string]interface{}{
 			"$set": map[string]interface{}{
 				"i_ispush": 0,
 			},
 		})
-		return false
 	}
-	return repl == "Y"
+	return ok
 }

BIN
src/jfw/modules/pushent/src/src


+ 1 - 1
src/jfw/modules/pushproject/src/followpush/push.go

@@ -511,7 +511,7 @@ func push(fid interface{}, sname, scode, title, userId string, res *[]map[string
 							descriptAppend = fmt.Sprintf("\n...(共%d条)", pushnum)
 							jpushtitle = fmt.Sprintf("1. %s", jpushtitle)
 						}
-						isPushOk := rpccall.AppPushServiceCall(map[string]interface{}{
+						isPushOk := jy.AppPush(Sysconfig["appPushServiceRpc"].(string), map[string]interface{}{
 							"phoneType":      phoneType,
 							"otherPushId":    opushid,
 							"jgPushId":       jpushid,

+ 0 - 27
src/jfw/modules/pushproject/src/rpccall/appPushServiceCall.go

@@ -1,27 +0,0 @@
-package rpccall
-
-import (
-	"config"
-	"encoding/json"
-	"log"
-	"net/rpc"
-	"qfw/util"
-)
-
-func AppPushServiceCall(m map[string]interface{}) bool {
-	defer util.Catch()
-	var repl string
-	client, err := rpc.DialHTTP("tcp", config.Sysconfig["appPushServiceRpc"].(string))
-	if err != nil {
-		log.Println(err.Error())
-		return false
-	}
-	defer client.Close()
-	b, _ := json.Marshal(m)
-	err = client.Call("Rpc.Push", b, &repl)
-	if err != nil {
-		log.Println(err.Error())
-		return false
-	}
-	return repl == "y"
-}

+ 4 - 18
src/jfw/modules/pushproject/src/rpccall/weixinrpc.go

@@ -2,8 +2,7 @@ package rpccall
 
 import (
 	"config"
-	"log"
-	"net/rpc"
+	"qfw/util/jy"
 	qrpc "qfw/util/rpc"
 	"strings"
 	"time"
@@ -13,26 +12,13 @@ import (
 //微信远程调用,实现模板发送消息
 func SendWinXin(p *qrpc.NotifyMsg, userId string) bool {
 	time.Sleep(10 * time.Millisecond)
-	client, err := rpc.DialHTTP("tcp", config.Sysconfig["weixinRpcServer"].(string))
-	if err != nil {
-		log.Println(err.Error())
-		return false
-	}
-	defer client.Close()
-	var repl qrpc.RpcResult
-	err = client.Call("WeiXinRpc.SendPushMsg", p, &repl)
-	if err != nil {
-		log.Println(err.Error())
-		return false
-	}
-	res := string(repl)
-	if strings.Contains(res, "[46004]") || strings.Contains(res, "[65302]") || strings.Contains(res, "[43004]") || strings.Contains(res, "[40003]") {
+	ok, res := jy.WxPush(config.Sysconfig["weixinRpcServer"].(string), "WeiXinRpc.SendPushMsg", p)
+	if !ok && (strings.Contains(res, "[46004]") || strings.Contains(res, "[65302]") || strings.Contains(res, "[43004]") || strings.Contains(res, "[40003]")) {
 		tools.MQFW.UpdateById("user", userId, map[string]interface{}{
 			"$set": map[string]interface{}{
 				"i_ispush": 0,
 			},
 		})
-		return false
 	}
-	return repl == "Y"
+	return ok
 }

BIN
src/jfw/modules/pushproject/src/src


+ 3 - 2
src/jfw/modules/pushsubscribe/src/match/config.json

@@ -1,12 +1,13 @@
 {
 	"elasticPoolSize": 1,
 	"elasticSearch": "http://192.168.3.128:9800",
-	"redisServers": "pushcache_1=192.168.3.128:5000",
+	"redisServers": "pushcache_1=192.168.3.128:5000,pushcache_2_a=192.168.3.128:5001",
 	"maxPushSize": 50,
 	"maxSearch": 5000,
+	"vipOneDayMaxPushSize": 2000,
 	"mgoAddr": "192.168.3.128:27080",
 	"mgoSize": 10,
-	"testids": [],
+	"testids": ["5cee3e2a61fd002c800e2569"],
 	"filterWords":["项目","中标","公告"],
 	"matchPoolSize": 60,
 	"matchDuration": 1, 

+ 15 - 14
src/jfw/modules/pushsubscribe/src/match/config/config.go

@@ -5,20 +5,21 @@ import (
 )
 
 type sysConfig struct {
-	ElasticPoolSize int      `json:"elasticPoolSize"`
-	ElasticSearch   string   `json:"elasticSearch"`
-	RedisServers    string   `json:"redisServers"`
-	MaxPushSize     int      `json:"maxPushSize"`
-	MaxSearch       int      `json:"maxSearch"`
-	MgoAddr         string   `json:"mgoAddr"`
-	MgoSize         int      `json:"mgoSize"`
-	TestIds         []string `json:"testIds"`
-	FilterWords     []string `json:"filterWords"`
-	MatchPoolSize   int      `json:"matchPoolSize"`
-	MatchDuration   int64    `json:"matchDuration"`
-	UserBatch       int      `json:"userBatch"`
-	PcHelper        string   `json:"pcHelper"`
-	MailReg         string   `json:"mailReg"`
+	ElasticPoolSize      int      `json:"elasticPoolSize"`
+	ElasticSearch        string   `json:"elasticSearch"`
+	RedisServers         string   `json:"redisServers"`
+	MaxPushSize          int      `json:"maxPushSize"`
+	VipOneDayMaxPushSize int      `json:"vipOneDayMaxPushSize"`
+	MaxSearch            int      `json:"maxSearch"`
+	MgoAddr              string   `json:"mgoAddr"`
+	MgoSize              int      `json:"mgoSize"`
+	TestIds              []string `json:"testIds"`
+	FilterWords          []string `json:"filterWords"`
+	MatchPoolSize        int      `json:"matchPoolSize"`
+	MatchDuration        int64    `json:"matchDuration"`
+	UserBatch            int      `json:"userBatch"`
+	PcHelper             string   `json:"pcHelper"`
+	MailReg              string   `json:"mailReg"`
 }
 
 type taskConfig struct {

+ 1 - 4
src/jfw/modules/pushsubscribe/src/match/job/freeuser.go

@@ -7,14 +7,11 @@ import (
 
 //免费用户
 type FreeUser struct {
-	Users      map[*UserInfo]bool
 	Title_Pjob *Pjob
 }
 
 func NewFreeUser() *FreeUser {
-	return &FreeUser{
-		Users: map[*UserInfo]bool{},
-	}
+	return &FreeUser{}
 }
 func (f *FreeUser) Match(info *map[string]interface{}) *map[*UserInfo]*MatchUser {
 	title, _ := (*info)["title"].(string)

+ 0 - 13
src/jfw/modules/pushsubscribe/src/match/job/job.go

@@ -5,19 +5,6 @@ import (
 	"sync"
 )
 
-const (
-	BulkSize  = 200
-	ShowField = `"_id","title","detail","projectscope","publishtime","toptype","subtype","type","area","href","areaval","infoformat",` +
-		`"projectname","buyer","winner","budget","bidamount","bidopentime","s_subscopeclass"`
-	SortQuery         = `{"publishtime":"desc"}`
-	DB                = "bidding"
-	IDRange           = `{"range":{"id":{"gt":"%s","lte":"%s"}}},{"range":{"publishtime":{"gt": %d}}}`
-	TimeRange         = `{"range":{"comeintime":{"gte":%d,"lte":%d}}}`
-	MaxId             = `{"query":{"filtered":{"filter":{"bool":{"must":{"range":{"id":{"gt":"%s"}}}}}}},"_source":["_id","comeintime"],"sort":{"id":"desc"},"from":0,"size":1}`
-	Mongodb_ShowField = `{"title":1,"detail":1,"projectscope":1,"publishtime":1,"toptype":1,"subtype":1,"type":1,"area":1,"href":1,"areaval":1,"infoformat":1,"projectname":1,"buyer":1,"winner":1,"budget":1,"bidamount":1,"bidopentime":1,"s_subscopeclass":1}`
-	DbName            = "qfw"
-)
-
 type Job interface {
 	Execute()
 }

+ 56 - 20
src/jfw/modules/pushsubscribe/src/match/job/matchjob.go

@@ -23,10 +23,22 @@ import (
 )
 
 var (
-	SaveFields = []string{"_id", "area", "city", "bidamount", "bidopentime", "budget", "buyer", "buyerclass", "projectname", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "type", "winner"}
+	SaveFields = []string{"_id", "area", "city", "buyerclass", "publishtime", "s_subscopeclass", "subtype", "title", "toptype", "type"}
 	MailReg    = regexp.MustCompile(SysConfig.MailReg)
 )
 
+const (
+	BulkSize  = 200
+	ShowField = `"_id","title","detail","projectscope","publishtime","toptype","subtype","type","area","href","areaval","infoformat",` +
+		`"projectname","buyer","winner","budget","bidamount","bidopentime","s_subscopeclass"`
+	SortQuery = `{"publishtime":"desc"}`
+	DB        = "bidding"
+	IDRange   = `{"range":{"id":{"gt":"%s","lte":"%s"}}},{"range":{"publishtime":{"gt": %d}}}`
+	TimeRange = `{"range":{"comeintime":{"gte":%d,"lte":%d}}}`
+	MaxId     = `{"query":{"filtered":{"filter":{"bool":{"must":{"range":{"id":{"gt":"%s"}}}}}}},"_source":["_id","comeintime"],"sort":{"id":"desc"},"from":0,"size":1}`
+	DbName    = "qfw"
+)
+
 type Pjob struct {
 	InterestDfa    *dfa.DFA
 	NotInterestDfa *dfa.DFA
@@ -222,7 +234,19 @@ func (m *MatchJob) LoadBidding(lastId, newId string, lastTime int64) bool {
 	var res []map[string]interface{}
 	sess := mongodb.GetMgoConn()
 	defer mongodb.DestoryMongoConn(sess)
-	it := sess.DB(DbName).C("bidding").Find(c_query).Select(mongodb.ObjToOth(Mongodb_ShowField)).Sort("_id").Iter()
+	it := sess.DB(DbName).C("bidding").Find(c_query).Select(map[string]interface{}{
+		"title":           1,
+		"detail":          1,
+		"projectscope":    1,
+		"publishtime":     1,
+		"toptype":         1,
+		"subtype":         1,
+		"type":            1,
+		"area":            1,
+		"s_subscopeclass": 1,
+		"city":            1,
+		"buyerclass":      1,
+	}).Sort("_id").Iter()
 	index := 0
 	for tmp := make(map[string]interface{}); it.Next(&tmp); {
 		index++
@@ -275,7 +299,7 @@ func (m *MatchJob) OnceUserBatch(user_batch_index int) (int, *VipUser, *FreeUser
 		"_id":             1,
 		"o_jy":            1,
 		"o_vipjy":         1,
-		"i_vipstatus":     1,
+		"i_vip_status":    1,
 		"s_m_openid":      1,
 		"a_m_openid":      1,
 		"s_phone":         1,
@@ -302,7 +326,9 @@ func (m *MatchJob) OnceUserBatch(user_batch_index int) (int, *VipUser, *FreeUser
 	//免费用户
 	title_key_user := make(map[string]*[]*UserInfo)
 	title_notkey_user := make(map[string]*[]*UserInfo)
+	nowymd := util.NowFormat(util.Date_yyyyMMdd)
 	for temp := make(map[string]interface{}); query.Next(temp); {
+		userId := fmt.Sprintf("%x", string(temp["_id"].(bson.ObjectId)))
 		s_m_openid := util.ObjToString(temp["s_m_openid"])
 		a_m_openid := util.ObjToString(temp["a_m_openid"])
 		s_phone := util.ObjToString(temp["s_phone"])
@@ -314,23 +340,27 @@ func (m *MatchJob) OnceUserBatch(user_batch_index int) (int, *VipUser, *FreeUser
 		pchelperPush := 0
 		//公众号取关用户
 		if userType == 0 && isPush == 0 {
+			logger.Info("过滤掉,公众号取关用户", userId)
 			continue
 		} else if userType == 2 && jpushid == "" && (opushid == "" || appPhoneType == "") {
+			logger.Info("过滤掉,app用户没有登录", userId)
 			continue
 		} else if (userType == 1 || (userType == 5 && isPush == 0)) && jpushid == "" && (opushid == "" || appPhoneType == "") {
 			if s_phone == "" || !mutil.PcHelperIsOnLine(s_phone) {
+				logger.Info("过滤掉,s_phone为空或者pc助手s_phone不在线", userId)
 				continue
 			} else {
 				pchelperPush = 1
 			}
 		}
 		applystatus := util.IntAll(temp["i_applystatus"])
-		vipStatus := util.IntAll(temp["i_vipstatus"])
+		vipStatus := util.IntAll(temp["i_vip_status"])
+		isVipUser := IsVipUser(vipStatus)
 		var o_msgset map[string]interface{}
-		if !IsVipUser(vipStatus) {
-			o_msgset, _ = temp["o_jy"].(map[string]interface{})
-		} else {
+		if isVipUser {
 			o_msgset, _ = temp["o_vipjy"].(map[string]interface{})
+		} else {
+			o_msgset, _ = temp["o_jy"].(map[string]interface{})
 		}
 		wxpush, apppush, mailpush := mutil.ModeTransform(userType, o_msgset)
 		email := strings.TrimSpace(util.ObjToString(o_msgset["s_email"]))
@@ -338,14 +368,16 @@ func (m *MatchJob) OnceUserBatch(user_batch_index int) (int, *VipUser, *FreeUser
 			mailpush = 0
 		}
 		if wxpush != 1 && apppush != 1 && mailpush != 1 {
+			logger.Info("过滤掉,wxpush apppush mailpush 都不是1", userId, wxpush, apppush, mailpush)
 			continue
 		}
-		userId := fmt.Sprintf("%x", string(temp["_id"].(bson.ObjectId)))
 		var allKeySet []*KeySet
 		var err error
-		if !IsVipUser(vipStatus) {
-			allKeySet, err = m.GetKeySet(o_msgset["a_key"])
-		} else {
+		if isVipUser {
+			if dayCount := redis.GetInt("pushcache_2_a", DayCountKey(nowymd, userId)); dayCount >= SysConfig.VipOneDayMaxPushSize {
+				logger.Info("vip用户达到一天最大推送数量", userId, dayCount)
+				continue
+			}
 			vip_items, _ := o_msgset["a_items"].([]interface{})
 			for _, v := range vip_items {
 				vip_item, _ := v.(map[string]interface{})
@@ -356,6 +388,8 @@ func (m *MatchJob) OnceUserBatch(user_batch_index int) (int, *VipUser, *FreeUser
 				}
 				allKeySet = append(allKeySet, vip_keySet...)
 			}
+		} else {
+			allKeySet, err = m.GetKeySet(o_msgset["a_key"])
 		}
 		if err != nil {
 			logger.Error("获取用户关键词错误!", userId, err)
@@ -427,7 +461,8 @@ func (m *MatchJob) OnceUserBatch(user_batch_index int) (int, *VipUser, *FreeUser
 				key_infotype[upperKey][infotype] = true
 			}
 		}
-		if !IsVipUser(vipStatus) && len(originalKeys) == 0 {
+		if !isVipUser && len(originalKeys) == 0 {
+			logger.Info("过滤掉,没有关键词", userId)
 			continue
 		}
 		modifydate := ""
@@ -465,14 +500,7 @@ func (m *MatchJob) OnceUserBatch(user_batch_index int) (int, *VipUser, *FreeUser
 			VipStatus:    vipStatus,
 		}
 		/***************start*****************/
-		if !IsVipUser(vipStatus) {
-			user.O_jy = &O_jy{
-				Area:     key_area,
-				Infotype: key_infotype,
-			}
-			m.MakeKeyUser(keys, user, &title_key_user)
-			m.MakeKeyUser(notkeys, user, &title_notkey_user)
-		} else {
+		if isVipUser {
 			//vip付费-采购单位行业
 			vip_buyerclass, _ := o_msgset["a_buyerclass"].([]interface{})
 			if len(vip_buyerclass) == 0 {
@@ -528,6 +556,14 @@ func (m *MatchJob) OnceUserBatch(user_batch_index int) (int, *VipUser, *FreeUser
 				m.MakeKeyUser(keys, user, &vip_detail_key_user)
 				m.MakeKeyUser(notkeys, user, &vip_detail_notkey_user)
 			}
+			vipUser.Users[user] = true
+		} else {
+			user.O_jy = &O_jy{
+				Area:     key_area,
+				Infotype: key_infotype,
+			}
+			m.MakeKeyUser(keys, user, &title_key_user)
+			m.MakeKeyUser(notkeys, user, &title_notkey_user)
 		}
 		/***************end*****************/
 		m.lastUserId = user.Id

+ 6 - 3
src/jfw/modules/pushsubscribe/src/match/job/vipuser.go

@@ -38,6 +38,9 @@ func NewVipUser() *VipUser {
 func (v *VipUser) Match(info *map[string]interface{}) *map[*UserInfo]*MatchUser {
 	buyerclass, _ := (*info)["buyerclass"].(string)
 	area, _ := (*info)["area"].(string)
+	if area == "全国" {
+		area = ""
+	}
 	city, _ := (*info)["city"].(string)
 	toptype, _ := (*info)["toptype"].(string)
 	title, _ := (*info)["title"].(string)
@@ -70,12 +73,12 @@ func (v *VipUser) Match(info *map[string]interface{}) *map[*UserInfo]*MatchUser
 	users := map[*UserInfo]*MatchUser{}
 	for k, _ := range v.Users {
 		if (!v.BuyerclassUsers[""][k] && !v.BuyerclassUsers[buyerclass][k]) ||
-			(!v.AreaUsers[""][k] || !v.AreaUsers[area][k] || !v.AreaUsers[city][k]) ||
-			(!v.InfoTypeUsers[""][k] || !v.InfoTypeUsers[toptype][k]) {
+			(!v.AreaUsers[""][k] && !v.AreaUsers[area][k] && !v.AreaUsers[city][k]) ||
+			(!v.InfoTypeUsers[""][k] && !v.InfoTypeUsers[toptype][k]) {
 			continue
 		}
 		var matchUser *MatchUser
-		if len(k.OriginalKeys) > 0 {
+		if len(k.Keys) > 0 {
 			matchUser = (*title_users)[k]
 			if matchUser == nil {
 				matchUser = (*detail_users)[k]

+ 1 - 1
src/jfw/modules/pushsubscribe/src/match/task.json

@@ -1 +1 @@
-{"startTime":"","lastId":"4c754b91a5cb26b9b79a0ce8"}
+{"startTime":"","lastId":"5da69c3fa5cb26b9b77bec0d"}

+ 14 - 0
src/jfw/modules/pushsubscribe/src/public/util.go

@@ -1,8 +1,22 @@
 package public
 
+import (
+	"fmt"
+)
+
 func IsVipUser(vipStatus int) bool {
 	if vipStatus == 1 || vipStatus == 2 {
 		return true
 	}
 	return false
 }
+
+//一天的推送总数
+func DayCountKey(nowymd, id string) string {
+	return fmt.Sprintf("daycount_%s_%s", nowymd, id)
+}
+
+//今天最后一次的推送总数
+func OnceCountKey(nowymd, id string) string {
+	return fmt.Sprintf("oncecount_%s_%s", nowymd, id)
+}

+ 3 - 3
src/jfw/modules/pushsubscribe/src/push/config.json

@@ -8,7 +8,7 @@
 		"size": 5,
 		"timeout": 20
 	},
-	"redisServers": "pushcache_2_a=192.168.3.128:5000,pushcache_2_b=192.168.3.128:5000,other=192.168.3.128:5000",
+	"redisServers": "pushcache_2_a=192.168.3.128:5001,pushcache_2_b=192.168.3.128:5002",
 	"mail_content": "<tr><td><num>%d</num></td><td><div class='tit'><a style='color: #000;text-decoration: none;' href='%s?mail' >%s</a></div></td><td style='float: right;' class='infos' ><span class='%s'>%s</span><span class='%s'>%s</span><span class='%s'>%s</span><span class='time'>%s</span></td></tr>",
 	"mail_html": "<body><style> *,body,html{margin:0;padding:0;font-family: tahoma, arial, 'Hiragino Sans GB', 'Microsoft YaHei', 宋体, sans-serif;font-size:16px; }#all{margin:0 auto;width:1024px;overflow:hidden;}.head{margin:5x;margin-top:20px;}.des{padding-bottom:15px;border-bottom:1px solid #e8ecee;color: #686868;}td a:hover {color: #fe7379;text-decoration: underline;} .tit{width:560px;overflow: hidden;    white-space: nowrap;text-overflow: ellipsis;}.area {background-color: #2cb7ca;border-radius: 3px;color: #fff;padding: 1px 2px;}.type {background-color: #ffba00;border-radius: 3px;color: #fff;padding: 1px 2px;margin-left:5px;}.industry {background-color: #25c78c;border-radius: 3px;color: #fff;padding: 1px 2px;margin-left:5px;}.infos span{display:inline-block;margin-left:5px;}td{padding-top:8px;padding-bottom:8px;height:20px;line-height:20px;}num{padding:0 5px 0 0; font-size:16px;color:#2cb7ca;font-weight:bolder;}.keys{color:blue;} </style><div id='all'><div class='head'><IMG width='100px' src=http://www.zhaobiao.info/images/swordfish/sf_01.png /></div><div class='head des'>根据您设置的关键词 :<span class='keys'>%s</span>,剑鱼标讯为您推送30天之内的信息。点击标题可查看详情信息</div><table cellpadding='0' cellspacing='0'>%s</table></div> </body>",
 	"mail_title": "您有新的%s信息-剑鱼标讯",
@@ -34,8 +34,8 @@
 	"vipOneDayMaxPushSize": 2000,
 	"mgoAddr": "192.168.3.128:27080",
 	"mgoSize": 10,
-	"testids": ["5d6e142a25ef871f08a72662"],
-	"weixinRpcServer": "127.0.0.1:8083",
+	"testids": ["5cee3e2a61fd002c800e2569"],
+	"weixinRpcServer": "192.168.20.111:8083",
 	"wxColor": "#2cb7ca",
 	"wxGroup": "招标信息",
 	"wxTitle": "根据你订阅的关键词“%s”,剑鱼标讯为你推送以下信息。如果不想继续收到此类信息,可进入招标订阅的设置页面取消订阅。",

+ 1 - 1
src/jfw/modules/pushsubscribe/src/push/config/config.go

@@ -33,7 +33,7 @@ type sysConfig struct {
 	OncePushTime            string      `json:"oncePushTime"`
 	OtherPushTimes          []string    `json:"otherPushTimes"`
 	WxPollSize              int         `json:"wxPollSize"`
-	VipOneDayMaxPushSize    int64       `json:"vipOneDayMaxPushSize"`
+	VipOneDayMaxPushSize    int         `json:"vipOneDayMaxPushSize"`
 	AppPollSize             int         `json:"appPollSize"`
 	MailSleep               int         `json:"mailSleep"`
 	CassandraSleep          int         `json:"cassandraSleep"`

+ 12 - 8
src/jfw/modules/pushsubscribe/src/push/job/dopush.go

@@ -55,11 +55,13 @@ func (d *doPush) Do(taskType int, isSave bool, wxPush, appPush, mailPush int, k
 	jpushtitle := ""
 	lastInfoDate := int64(0)
 	TitleArray := []string{}
-	infos := []map[string]interface{}{}
+	infos := []*MatchInfo{}
 	publishTitle := map[string]bool{}
-	pushIds := []string{}
-	nowymd := util.NowFormat(util.Date_yyyyMMdd)
-	//邮件附件
+	dateymd := util.NowFormat(util.Date_yyyyMMdd)
+	dayCountKey := DayCountKey(dateymd, k.Id)
+	onceCountKey := DayCountKey(dateymd, k.Id)
+	dayCount := redis.GetInt("pushcache_2_a", dayCountKey)
+	isVipUser := IsVipUser(k.VipStatus)
 	for _, ks := range *sl {
 		k2 := *ks.Info
 		title := strings.Replace(k2["title"].(string), "\n", "", -1)
@@ -74,8 +76,7 @@ func (d *doPush) Do(taskType int, isSave bool, wxPush, appPush, mailPush int, k
 		}
 		publishTitle[newTitle] = true
 		i++
-		infos = append(infos, k2)
-		pushIds = append(pushIds, util.ObjToString(k2["_id"]))
+		infos = append(infos, ks)
 		TitleArray = append(TitleArray, newTitle)
 		if i == 1 {
 			jpushtitle = title
@@ -139,8 +140,8 @@ func (d *doPush) Do(taskType int, isSave bool, wxPush, appPush, mailPush int, k
 			}
 			mailContent += fmt.Sprintf(SysConfig.Mail_content, i, url, otitle, classArea, area, classType, infotype, industryclass, industry, dates)
 		}
-		if IsVipUser(k.VipStatus) {
-			if redis.Incr("other", fmt.Sprintf("daycount_%s_%s", nowymd, k.Id)) >= SysConfig.VipOneDayMaxPushSize {
+		if isVipUser {
+			if dayCount >= SysConfig.VipOneDayMaxPushSize {
 				break
 			}
 		} else {
@@ -149,11 +150,14 @@ func (d *doPush) Do(taskType int, isSave bool, wxPush, appPush, mailPush int, k
 				break
 			}
 		}
+		dayCount++
 	}
 	if i == 0 {
 		logger.Info("推送任务", taskType, "没有要推送的数据!", k.Id)
 		return
 	}
+	redis.Put("pushcache_2_a", dayCountKey, dayCount, 86400)
+	redis.Put("pushcache_2_a", onceCountKey, i, 86400)
 	//限制一分钟最大的推送数量
 	if d.fastigiumMinutePushPool != nil {
 		if hour := time.Now().Hour(); hour >= FastigiumStart && hour <= FastigiumEnd {

BIN
src/jfw/modules/pushsubscribe/src/push/push.exe~


+ 5 - 34
src/jfw/modules/pushsubscribe/src/push/util/rpccall.go

@@ -6,6 +6,7 @@ import (
 	. "public"
 	. "push/config"
 	"qfw/util"
+	"qfw/util/jy"
 	"qfw/util/mongodb"
 	qrpc "qfw/util/rpc"
 	"strconv"
@@ -25,13 +26,11 @@ var (
 func SendWeixin(k *UserInfo, remark, title string) bool {
 	wxPushPool <- true
 	defer func() {
-		util.Catch()
 		<-wxPushPool
 	}()
 	if SysConfig.WxSleep > 0 {
 		time.Sleep(time.Duration(SysConfig.WxSleep) * time.Millisecond)
 	}
-	var repl qrpc.RpcResult
 	now := time.Now()
 	p := &qrpc.NotifyMsg{
 		Openid:      k.S_m_openid,
@@ -44,53 +43,25 @@ func SendWeixin(k *UserInfo, remark, title string) bool {
 		DetailColor: SysConfig.WxDetailColor,
 		Url:         SysConfig.JianyuDomain + "/front/sess/" + Se.EncodeString(k.S_m_openid+",uid,"+strconv.Itoa(int(time.Now().Unix()))+",rssset"),
 	}
-	client, err := rpc.DialHTTP("tcp", SysConfig.WeixinRpcServer)
-	if err != nil {
-		logger.Error(err.Error())
-		return false
-	}
-	defer client.Close()
-	err = client.Call("WeiXinRpc.SubscribePush", p, &repl)
-	if err != nil {
-		logger.Error(err.Error())
-	}
-	res := string(repl)
-	if strings.Contains(res, "[46004]") || strings.Contains(res, "[65302]") || strings.Contains(res, "[43004]") || strings.Contains(res, "[40003]") {
+	ok, res := jy.WxPush(SysConfig.WeixinRpcServer, "WeiXinRpc.SubscribePush", p)
+	if !ok && (strings.Contains(res, "[46004]") || strings.Contains(res, "[65302]") || strings.Contains(res, "[43004]") || strings.Contains(res, "[40003]")) {
 		mongodb.Update("user", map[string]interface{}{"_id": bson.ObjectIdHex(k.Id)}, map[string]interface{}{
 			"$set": map[string]interface{}{
 				"i_ispush": 0,
 			},
 		}, false, false)
-		return true
-	}
-	if repl == "Y" {
-		return true
 	}
-	return false
+	return ok
 }
 func SendApp(m map[string]interface{}) bool {
 	appPushPool <- true
 	defer func() {
-		util.Catch()
 		<-appPushPool
 	}()
 	if SysConfig.AppSleep > 0 {
 		time.Sleep(time.Duration(SysConfig.AppSleep) * time.Millisecond)
 	}
-	var repl string
-	client, err := rpc.DialHTTP("tcp", SysConfig.AppPushServiceRpc)
-	if err != nil {
-		logger.Error(err.Error())
-		return false
-	}
-	defer client.Close()
-	b, _ := json.Marshal(m)
-	err = client.Call("Rpc.Push", b, &repl)
-	if err != nil {
-		logger.Error(err.Error())
-		return false
-	}
-	return repl == "y"
+	return jy.AppPush(SysConfig.AppPushServiceRpc, m)
 }
 
 //

+ 38 - 36
src/jfw/modules/pushsubscribe/src/push/util/util.go

@@ -106,7 +106,7 @@ func ModeTransform(userType int, o_msgset map[string]interface{}) (int, int, int
 }
 
 //保存发送信息
-func SaveSendInfo(k *UserInfo, infos []map[string]interface{}) string {
+func SaveSendInfo(k *UserInfo, infos []*MatchInfo) string {
 	cassandraPoll <- true
 	defer func() {
 		<-cassandraPoll
@@ -123,30 +123,32 @@ func SaveSendInfo(k *UserInfo, infos []map[string]interface{}) string {
 	}
 	date := now.Unix()
 	dateymd := now.Format(util.Date_yyyyMMdd)
-	var saves []map[string]interface{}
-	for _, info := range infos {
+	var saves []*map[string]interface{}
+	for _, v := range infos {
 		wxpush := map[string]interface{}{
 			"dateymd":    dateymd,
 			"uid":        k.Id,
 			"date":       date,
-			"pushinfo":   fmt.Sprint(info["_id"]),
-			"keys":       k.Keys,
-			"area":       util.ObjToString(info["area"]),
-			"city":       util.ObjToString(info["city"]),
-			"buyerclass": util.ObjToString(info["buyerclass"]),
+			"pushinfo":   fmt.Sprint((*v.Info)["_id"]),
+			"keys":       v.Keys,
+			"area":       util.ObjToString((*v.Info)["area"]),
+			"city":       util.ObjToString((*v.Info)["city"]),
+			"buyerclass": util.ObjToString((*v.Info)["buyerclass"]),
 		}
-		if ca.Save("jy_pushsubscribe", wxpush) {
-			saves = append(saves, info)
+		time.Sleep(200 * time.Millisecond)
+		if ca.Save("jy_pushhistory", wxpush) {
+			(*v.Info)["matchkeys"] = v.Keys
+			saves = append(saves, v.Info)
 		}
 	}
 	if len(saves) > 0 {
-		updateRedis(date, k, infos)
+		updateRedis(date, k, &saves)
 		return fmt.Sprint(date)
 	}
 	return ""
 }
 
-func updateRedis(date int64, k *UserInfo, infos []map[string]interface{}) {
+func updateRedis(date int64, k *UserInfo, infos *[]*map[string]interface{}) {
 	pc_a, pc_a_err := jy.HistoryPush.GetPushCache_A(k.Id)
 	pc_b, pc_b_err := jy.HistoryPush.GetPushCache_B(k.Id)
 	if pc_a_err != nil {
@@ -158,12 +160,12 @@ func updateRedis(date int64, k *UserInfo, infos []map[string]interface{}) {
 	}
 	list_a := []map[string]interface{}{}
 	list_b := []map[string]interface{}{}
-	for k, info := range infos {
+	for k, info := range *infos {
 		newInfo := jy.HistoryPush.InfoFormat(&jy.PushCa{
 			Date:   date,
-			InfoId: util.ObjToString(info["_id"]),
+			InfoId: util.ObjToString((*info)["_id"]),
 			Index:  k + 1,
-		}, &info)
+		}, info)
 		list_a = append(list_a, newInfo)
 	}
 	length_a := len(list_a) + len(pc_a.Infos)
@@ -171,13 +173,13 @@ func updateRedis(date int64, k *UserInfo, infos []map[string]interface{}) {
 	case 0, 1:
 		pc_a.Type = 1
 		list_a = append(list_a, pc_a.Infos...)
-		if length_a > 250 {
+		if length_a > 500 {
 			if pc_b != nil {
-				list_b = append(list_b, list_a[250:]...)
+				list_b = append(list_b, list_a[500:]...)
 			}
-			list_a = list_a[:250]
-			pc_a.Count = 250
-		} else if length_a == 250 {
+			list_a = list_a[:500]
+			pc_a.Count = 500
+		} else if length_a == 500 {
 			pc_a.Count = 0
 		} else {
 			pc_a.Count = length_a
@@ -186,38 +188,38 @@ func updateRedis(date int64, k *UserInfo, infos []map[string]interface{}) {
 	case 2:
 		list_a = append(list_a, pc_a.Infos...)
 		pc_a.Type = 3
-		if length_a > 250 {
+		if length_a > 500 {
 			if pc_b != nil {
-				list_b = append(list_b, list_a[250:]...)
+				list_b = append(list_b, list_a[500:]...)
 			}
-			list_a = list_a[:250]
-			pc_a.Count = 250 - len(infos)
-		} else if length_a == 250 {
+			list_a = list_a[:500]
+			pc_a.Count = 500 - len(*infos)
+		} else if length_a == 500 {
 			pc_a.Count = len(pc_a.Infos)
 		}
 		break
 	case 3:
-		if length_a > 250 {
+		if length_a > 500 {
 			if pc_a.Count > 0 && pc_a.Count < len(pc_a.Infos) {
-				pc_a_a := pc_a.Infos[:250-pc_a.Count]
-				pc_a_b := pc_a.Infos[250-pc_a.Count:]
+				pc_a_a := pc_a.Infos[:500-pc_a.Count]
+				pc_a_b := pc_a.Infos[500-pc_a.Count:]
 				list_a = append(list_a, pc_a_a...)
-				if len(list_a) > 250 {
+				if len(list_a) > 500 {
 					pc_a.Type = 1
-					pc_a.Count = 250
+					pc_a.Count = 500
 					if pc_b != nil {
-						list_b = append(list_b, list_a[250:]...)
+						list_b = append(list_b, list_a[500:]...)
 						list_b = append(list_b, pc_a_b...)
 					}
-					list_a = list_a[:250]
-				} else if len(list_a) == 250 {
+					list_a = list_a[:500]
+				} else if len(list_a) == 500 {
 					pc_a.Type = 1
 					pc_a.Count = 0
 					if pc_b != nil {
 						list_b = append(list_b, pc_a_b...)
 					}
 				} else {
-					needLength := 250 - len(list_a)
+					needLength := 500 - len(list_a)
 					if needLength > len(pc_a_b) {
 						list_a = append(list_a, pc_a_b...)
 						pc_a.Count = len(pc_a_b)
@@ -242,8 +244,8 @@ func updateRedis(date int64, k *UserInfo, infos []map[string]interface{}) {
 	jy.HistoryPush.PutPushCache_A(k.Id, pc_a)
 	if pc_b != nil {
 		list_b = append(list_b, pc_b...)
-		if len(list_b) > 750 {
-			list_b = list_b[:750]
+		if len(list_b) > 3500 {
+			list_b = list_b[:3500]
 		}
 		jy.HistoryPush.PutPushCache_B(k.Id, list_b)
 	}

+ 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{})
 
 }

+ 5 - 22
src/jfw/modules/subscribepay/src/config.json

@@ -1,8 +1,10 @@
 {
-	"mongodbServers": "192.168.3.11:27080",
+	"mongodbServers": "192.168.3.128: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.128: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"
 )
 
@@ -9,6 +9,8 @@ type config struct {
 	MongodbServers  string
 	MongodbPoolSize int
 	MongodbName     string
+	Elasticsearch   string
+	ElasticPoolSize int
 	Redisaddrs      string
 	Webport         string
 	Weixinrpc       string
@@ -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`
+
 }
+
+
+
+
+
+

File diff suppressed because it is too large
+ 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\":\"需要登录!\"}"))

+ 2 - 0
src/jfw/modules/subscribepay/src/main.go

@@ -6,12 +6,14 @@ import (
 	_ "filter"
 	"net/http"
 	_ "service"
+	"timetask"
 	_ "util"
 
 	"github.com/go-xweb/xweb"
 )
 
 func main() {
+	go timetask.Run()
 	mux1 := http.NewServeMux()
 	xweb.RunBase(":"+Config.Webport, mux1)
 }

+ 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
+}*/

+ 10 - 6
src/jfw/modules/subscribepay/src/service/afterPay.go

@@ -1,6 +1,7 @@
 package service
 
 import (
+	"fmt"
 	"log"
 	qutil "qfw/util"
 	"qfw/util/redis"
@@ -18,18 +19,21 @@ type AfterPay struct {
 	*xweb.Action
 	getUserInfo xweb.Mapper `xweb:"/afterPay/getUserInfo"` //获取用户当前支付后的信息
 	setUserInfo xweb.Mapper `xweb:"/afterPay/setUserInfo"` //保存用户当前支付后的信息
-	pushView    xweb.Mapper `xweb:"/afterPay/pushView"`    //VIP推送预览
+	getPushView xweb.Mapper `xweb:"/afterPay/getPushView"` //VIP推送预览
 }
 
 //
-func (a *AfterPay) PushView() error {
+func (a *AfterPay) GetPushView() error {
 	defer qutil.Catch()
 	userId, _ := a.GetSession("userId").(string)
 	if userId != "" {
-		sql := GetSqlObjFromId(userId)
-		log.Println(sql.Buyerclass)
-		qstr := GetVIPViewSql(sql)
-		log.Println("qstr:", qstr)
+		pageNum, _ := a.GetInteger("pageNum")
+		keys, list, hasNextPage := util.SubViewDatas(userId, "", pageNum)
+		a.ServeJson(map[string]interface{}{
+			"keys":        strings.Replace(strings.Trim(fmt.Sprint(keys), "[]"), " ", ",", -1),
+			"list":        list,
+			"hasNextPage": hasNextPage,
+		})
 	}
 	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)
+}

+ 32 - 8
src/jfw/modules/subscribepay/src/service/orderListDetails.go

@@ -2,6 +2,7 @@ package service
 
 import (
 	"config"
+	"entity"
 	"errors"
 	"fmt"
 	"log"
@@ -46,9 +47,9 @@ var (
 func (this *OrderListDetails) GetOrderPayAllMsg() {
 	orderCode := this.GetString("orderCode")
 	userId := qutil.ObjToString(this.GetSession("userId"))
-	r := func() *orderResult {
+	r := func() *entity.FuncResult {
 		if orderCode == "" {
-			return &orderResult{false, errors.New("订单号不能为空"), nil}
+			return &entity.FuncResult{false, errors.New("订单号不能为空"), nil}
 		}
 		query := map[string]interface{}{
 			"user_id":    userId,
@@ -59,22 +60,22 @@ func (this *OrderListDetails) GetOrderPayAllMsg() {
 		log.Println("odata:", oData)
 		//查询订单信息
 		if oData == nil || len(*oData) == 0 {
-			return &orderResult{false, errors.New("未找到此订单"), nil}
+			return &entity.FuncResult{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}
+			return &entity.FuncResult{false, errors.New("数据库查询异常"), nil}
 		}
 		//
 		if qutil.IntAll((*oData)["order_status"]) != 1 {
-			return &orderResult{true, nil, map[string]interface{}{
+			return &entity.FuncResult{true, nil, map[string]interface{}{
 				"order": oData,
 				"time":  uData,
 			}}
 		}
 		delete(*uData, "_id")
-		return &orderResult{true, nil, map[string]interface{}{
+		return &entity.FuncResult{true, nil, map[string]interface{}{
 			"order":          oData,
 			"time":           uData,
 			"transaction_id": getPayTransactionId(qutil.ObjToString((*oData)["pay_way"]), qutil.ObjToString((*oData)["out_trade_no"])),
@@ -250,7 +251,7 @@ func (o *OrderListDetails) ApplyInvoice() error {
 			}, "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)
+			entity.SendMailToBJFinance(orderdata, pay_time, "", 2, config.GmailAuth)
 		}()
 	}
 	o.ServeJson(map[string]interface{}{
@@ -409,7 +410,7 @@ func (o *OrderListDetails) SetRes(res []map[string]interface{}, queryM map[strin
 			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))
+			v["token"] = entity.GetWaitPayToken(v["id"].(int64), int(orderMoney.(int64)), v["order_code"].(string), v["pay_way"].(string), queryM["user_id"].(string))
 		}
 		//最后一次够买的vip订单
 		if lastbuy_code == v["order_code"] {
@@ -456,3 +457,26 @@ func isEmail(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 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
+}

+ 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())
 }

+ 38 - 0
src/jfw/modules/subscribepay/src/timetask/timetask.go

@@ -0,0 +1,38 @@
+package timetask
+
+import (
+	"time"
+)
+
+func Run() {
+	checkIsExpire()
+	expireRemind()
+}
+
+//每天0点 检查试用、vip服务是否到期
+func checkIsExpire() {
+	crontab(0, func() {
+
+	})
+}
+
+//即将到期或者已到期发推送消息
+func expireRemind() {
+	crontab(10, func() {
+
+	})
+}
+
+func crontab(hour int, f func()) {
+	go f()
+	now := time.Now()
+	t := time.Date(now.Year(), now.Month(), now.Day()+1, hour, 0, 0, 0, time.Local)
+	timer := time.NewTimer(t.Sub(now))
+	for {
+		select {
+		case <-timer.C:
+			go f()
+			timer.Reset(24 * time.Hour)
+		}
+	}
+}

+ 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
-}

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

@@ -2,6 +2,9 @@ package util
 
 import (
 	. "config"
+
+	qutil "qfw/util"
+	"qfw/util/elastic"
 	mg "qfw/util/mongodb"
 	"qfw/util/mysql"
 	"qfw/util/redis"
@@ -20,6 +23,11 @@ func init() {
 	// 	Config.Cassandra.Host,
 	// 	map[string]int{"port": Config.Cassandra.Port},
 	// )
+	//初始化elastic
+	elastic.InitElasticSize(
+		Config.Elasticsearch,
+		qutil.IntAllDef(Config.ElasticPoolSize, 30),
+	)
 	//初始化redis
 	redisConfig := Config.Redisaddrs
 	if redisConfig != "" {
@@ -40,4 +48,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
-}

+ 52 - 18
src/jfw/modules/subscribepay/src/service/vrew.go → src/jfw/modules/subscribepay/src/util/vrew.go

@@ -1,36 +1,68 @@
-package service
+package util
 
 import (
 	"encoding/json"
 	"fmt"
 	"log"
 	qutil "qfw/util"
+	"qfw/util/elastic"
 	"strconv"
 	"strings"
-	"util"
 
 	"gopkg.in/mgo.v2/bson"
 )
 
 /*已选条件--关键词*/
-type KeyWord struct {
+type ViewKeyWord struct {
 	Keyword  []string `json:"key"`       //关键词
 	Appended []string `json:"appendkey"` //附加词
 	Exclude  []string `json:"notkey"`    //排除词
 }
 
 /*已选条件*/
-type SieveCondition struct {
-	Area       []string  //地区-省份
-	City       []string  //地区-城市
-	Buyerclass []string  //采购行业
-	Keyword    []KeyWord //关键词
-	SelectType string    //筛选(正文 or 标题)
-	Subtype    []string  //信息类型
+type ViewCondition struct {
+	Area       []string      //地区-省份
+	City       []string      //地区-城市
+	Buyerclass []string      //采购行业
+	Keyword    []ViewKeyWord //关键词
+	SelectType string        //筛选(正文 or 标题)
+	Subtype    []string      //信息类型
+}
+
+const (
+	INDEX          = "bidding"
+	TYPE           = "bidding"
+	bidSearch_sort = `{"publishtime":-1}`
+	findfields     = `"title"`
+
+	view_maxPageNum = 20
+	view_pageSize   = 50
+	bidSearch_field = `"_id","title","publishtime","toptype","subtype","type","area","buyerclass"`
+)
+
+func SubViewDatas(userId, allquery string, pageNum int) (keys []interface{}, list *[]map[string]interface{}, hasNextPage bool) {
+	if userId == "" {
+		return
+	}
+	sql := GetSqlObjFromId(userId)
+	for _, v := range sql.Keyword {
+		for _, k := range v.Keyword {
+			keys = append(keys, k)
+		}
+	}
+	qstr := GetVIPViewSql(sql)
+	list = elastic.GetAllByNgram(INDEX, TYPE, qstr, findfields, bidSearch_sort, bidSearch_field, (pageNum-1)*view_pageSize, view_pageSize, 0, false)
+	if list != nil {
+		for _, v := range *list {
+			v["_id"] = qutil.EncodeArticleId2ByCheck(qutil.ObjToString(v["_id"]))
+		}
+	}
+	hasNextPage = list != nil && len(*list) == view_pageSize && pageNum < view_maxPageNum
+	return
 }
 
 //获取vip订阅预览的查询语句
-func GetVIPViewSql(scd *SieveCondition) string {
+func GetVIPViewSql(scd *ViewCondition) string {
 	query := `{"query":{"bool":{"must":[%s],"should":[%s],"minimum_should_match": %d}}}`
 	query_bool_should := `{"bool":{"should":[%s],"minimum_should_match": 1}}`
 	multi_match := `{"multi_match": {"query": %s,"type": "phrase", "fields": [%s]}}`
@@ -131,12 +163,14 @@ func GetVIPViewSql(scd *SieveCondition) string {
 	//	log.Println("------qstr", qstr)
 	return qstr
 }
-func GetSqlObjFromId(_id string) *SieveCondition {
+
+//
+func GetSqlObjFromId(_id string) *ViewCondition {
 	var (
 		query *map[string]interface{}
 		ok    bool
 	)
-	if query, ok = util.MQFW.FindById("user", _id, `{"o_vipjy":1}`); !ok {
+	if query, ok = MQFW.FindById("user", _id, `{"o_vipjy":1}`); !ok {
 		return nil
 	}
 	o_vipjy, _ := (*query)["o_vipjy"].(map[string]interface{})
@@ -144,7 +178,7 @@ func GetSqlObjFromId(_id string) *SieveCondition {
 	a_buyerclass := o_vipjy["a_buyerclass"].([]interface{})
 	a_infotype := o_vipjy["a_infotype"].([]interface{})
 	o_area := o_vipjy["o_area"].(map[string]interface{})
-	return &SieveCondition{
+	return &ViewCondition{
 		Keyword:    getKeyWordArrFromDbResult(a_items),
 		Buyerclass: qutil.ObjArrToStringArr(a_buyerclass),
 		Subtype:    qutil.ObjArrToStringArr(a_infotype),
@@ -177,14 +211,14 @@ func getStringArrFromDbResult(area map[string]interface{}, i int) (arr []string)
 }
 
 //关键词 附加词 排除词
-func getKeyWordArrFromDbResult(a_items []interface{}) (arr []KeyWord) {
+func getKeyWordArrFromDbResult(a_items []interface{}) (arr []ViewKeyWord) {
 	if a_items == nil {
 		return
 	}
 	for _, v := range a_items {
 		kwsArr := v.(map[string]interface{})["a_key"]
 		for _, k := range kwsArr.([]interface{}) {
-			kw := KeyWord{}
+			kw := ViewKeyWord{}
 			b, e := json.Marshal(k)
 			if e != nil {
 				log.Println(e.Error())
@@ -202,7 +236,7 @@ func MergeKws(userId string) {
 	if userId == "" {
 		return
 	}
-	data, ok := util.MQFW.FindById("user", userId, `{"o_jy":1,"o_vipjy":1}`)
+	data, ok := MQFW.FindById("user", userId, `{"o_jy":1,"o_vipjy":1}`)
 	var o_jy map[string]interface{}
 	var o_vipjy map[string]interface{}
 	if ok && data != nil && len(*data) > 0 {
@@ -222,7 +256,7 @@ func MergeKws(userId string) {
 			}
 			o_kws["a_key"] = _key
 			if o_kws != nil && len(o_kws) > 0 {
-				a := util.MQFW.UpdateById("user", userId, bson.M{
+				a := MQFW.UpdateById("user", userId, bson.M{
 					"$push": bson.M{"o_vipjy.a_items": o_kws},
 				})
 				log.Println(a)

+ 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
+}

+ 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",

BIN
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{}{

+ 75 - 67
src/jfw/public/historypush.go

@@ -43,7 +43,7 @@ func (h *historyPush) Datas(userId string, pageNum int, firstPushTime int64, sel
 			err = ps_a_err
 			log.Println("HistoryPush Datas Error", ps_a_err)
 		}
-		if pageNum <= 5 {
+		if pageNum <= 10 {
 			if pc_a == nil {
 				pc_a = &jy.PushSub{}
 				ids := h.halfYearDatas(userId)
@@ -52,23 +52,23 @@ func (h *historyPush) Datas(userId string, pageNum int, firstPushTime int64, sel
 					hyad := h.halfYearAgoDatas(userId, firstPushTime)
 					if hyad_length := len(hyad); hyad_length > 0 {
 						pc_a.Type = 2
-						if hyad_length > 250 {
-							hyad = hyad[:250]
-							pc_a.Count = 250
+						if hyad_length > 500 {
+							hyad = hyad[:500]
+							pc_a.Count = 500
 						} else {
 							pc_a.Count = hyad_length
 						}
 						pc_a.Infos = h.getInfoByIds(hyad)
 					}
-				} else if length == 250 {
+				} else if length == 500 {
 					pc_a.Type = 1
 					pc_a.Count = 0
 					pc_a.Infos = h.getInfoByIds(ids)
-				} else if length > 250 {
+				} else if length > 500 {
 					pc_a.Type = 1
-					pc_a.Count = 250
-					pc_a.Infos = h.getInfoByIds(ids[:250])
-				} else if length < 250 {
+					pc_a.Count = 500
+					pc_a.Infos = h.getInfoByIds(ids[:500])
+				} else if length < 500 {
 					pc_a.Type = 1
 					pc_a.Count = length
 					hyads := h.halfYearAgoDatas(userId, firstPushTime)
@@ -78,7 +78,7 @@ func (h *historyPush) Datas(userId string, pageNum int, firstPushTime int64, sel
 						} else {
 							pc_a.Type = 3
 						}
-						needLength := 250 - length
+						needLength := 500 - length
 						if hyads_length > needLength {
 							hyads = hyads[:needLength]
 							pc_a.Count = needLength
@@ -95,7 +95,7 @@ func (h *historyPush) Datas(userId string, pageNum int, firstPushTime int64, sel
 			}
 			infos = pc_a.Infos
 		} else {
-			pageNum -= 5
+			pageNum -= 10
 			pc_b, pc_b_err := jy.HistoryPush.GetPushCache_B(userId)
 			if pc_b_err != nil {
 				err = pc_b_err
@@ -108,28 +108,28 @@ func (h *historyPush) Datas(userId string, pageNum int, firstPushTime int64, sel
 					pc_b = []map[string]interface{}{}
 					ids := h.halfYearDatas(userId)
 					length := len(ids)
-					if length >= 250 {
-						pc_a_ids = ids[:250]
+					if length >= 500 {
+						pc_a_ids = ids[:500]
 						pc_a.Type = 1
-						if length == 250 {
+						if length == 500 {
 							pc_a.Count = 0
 						} else {
-							pc_a.Count = 250
+							pc_a.Count = 500
 						}
-						if length == 1000 {
-							pc_b = h.getInfoByIds(ids[250:])
+						if length == 4000 {
+							pc_b = h.getInfoByIds(ids[500:])
 						} else {
-							pc_b_ids := ids[250:]
+							pc_b_ids := ids[500:]
 							hyads := h.halfYearAgoDatas(userId, firstPushTime)
 							if len(hyads) > 0 {
 								pc_b_ids = append(pc_b_ids, hyads...)
-								if len(pc_b_ids) > 750 {
-									pc_b_ids = pc_b_ids[:750]
+								if len(pc_b_ids) > 3500 {
+									pc_b_ids = pc_b_ids[:3500]
 								}
 							}
 							pc_b = h.getInfoByIds(pc_b_ids)
 						}
-					} else if length < 250 {
+					} else if length < 500 {
 						pc_a_ids = ids
 						pc_a.Type = 1
 						pc_a.Count = length
@@ -140,13 +140,13 @@ func (h *historyPush) Datas(userId string, pageNum int, firstPushTime int64, sel
 							} else {
 								pc_a.Type = 3
 							}
-							needLength := 250 - length
+							needLength := 500 - length
 							if len(hyads) > needLength {
 								pc_a.Count = needLength
 								pc_a_ids = append(pc_a_ids, hyads[:needLength]...)
 								hyads = hyads[needLength:]
-								if len(hyads) > 750 {
-									hyads = hyads[:750]
+								if len(hyads) > 3500 {
+									hyads = hyads[:3500]
 								}
 								pc_b = h.getInfoByIds(hyads)
 							} else {
@@ -164,17 +164,17 @@ func (h *historyPush) Datas(userId string, pageNum int, firstPushTime int64, sel
 					case 1:
 						if pc_a.Count == 0 {
 							hyads := h.halfYearAgoDatas(userId, firstPushTime)
-							if len(hyads) > 750 {
-								hyads = hyads[:750]
+							if len(hyads) > 3500 {
+								hyads = hyads[:3500]
 							}
 							pc_b = h.getInfoByIds(hyads)
 						} else {
 							ids := h.halfYearDatas(userId)
 							if len(ids) > pc_a.Count {
 								ids = ids[pc_a.Count:]
-								if len(ids) < 750 {
+								if len(ids) < 3500 {
 									hyads := h.halfYearAgoDatas(userId, firstPushTime)
-									needLength := 750 - len(ids)
+									needLength := 3500 - len(ids)
 									if len(hyads) > needLength {
 										hyads = hyads[:needLength]
 									}
@@ -204,6 +204,7 @@ func (h *historyPush) Datas(userId string, pageNum int, firstPushTime int64, sel
 			infos = pc_b
 		}
 	}
+	log.Println(len(infos))
 	if len(infos) > 0 {
 		start := (pageNum - 1) * pageSize
 		end := pageNum * pageSize
@@ -223,7 +224,7 @@ func (h *historyPush) Datas(userId string, pageNum int, firstPushTime int64, sel
  * date 半年前的日期
  */
 func (h *historyPush) halfYearDatas(userId string) (pushCas []*jy.PushCa) {
-	datas := Ca_Push.Search("select * from jy_pushsubscribe where uid=? and date>=?", userId, h.halfYear())
+	datas := Ca_Push.Search("select * from jy_pushhistory where uid=? and date>=?", userId, h.halfYear())
 	pushCas = h.getJyPushs(datas)
 	return
 }
@@ -234,7 +235,7 @@ func (h *historyPush) halfYearDatas(userId string) (pushCas []*jy.PushCa) {
  * selectdate 选中的日期
  */
 func (h *historyPush) getSelectDateDatas(userId string, selectTime string) (pushCas []*jy.PushCa) {
-	datas := Ca_Push.Search("select * from jy_pushsubscribe where uid=? and dateymd=?", userId, selectTime)
+	datas := Ca_Push.Search("select * from jy_pushhistory where uid=? and dateymd=?", userId, selectTime)
 	pushCas = h.getJyPushs(datas)
 	return
 }
@@ -247,7 +248,7 @@ func (h *historyPush) halfYearAgoDatas(userId string, firstPushTime int64) (push
 	if firstPushTime == 0 || firstPushTime > h.halfYear() {
 		return
 	}
-	datas := Ca_Push.Search("select * from jy_pushsubscribe where uid=? and date<? limit 500", userId, h.halfYear())
+	datas := Ca_Push.Search("select * from jy_pushhistory where uid=? and date<? limit 1000", userId, h.halfYear())
 	pushCas = h.getJyPushs(datas)
 	return
 }
@@ -255,25 +256,30 @@ func (h *historyPush) halfYearAgoDatas(userId string, firstPushTime int64) (push
 func (h *historyPush) getJyPushs(datas []map[string]interface{}) (pushCas []*jy.PushCa) {
 	pushCas = []*jy.PushCa{}
 	for _, v := range datas {
-		openList := util.Int64All(v["openlist"])
-		for id_k, id_v := range strings.Split(util.ObjToString(v["pushinfo"]), ",") {
-			pushCas = append(pushCas, &jy.PushCa{
-				Date:   util.Int64All(v["date"]),
-				InfoId: id_v,
-				Visit:  h.isVisited(openList, id_k+1),
-				Index:  id_k + 1,
-			})
-			if len(pushCas) == 1000 {
-				return
-			}
+		isvisit := util.Int64All(v["isvisit"])
+		keys := v["keys"].([]string)
+		//		for id_k, id_v := range strings.Split(util.ObjToString(v["pushinfo"]), ",") {
+		pushCas = append(pushCas, &jy.PushCa{
+			Date:       util.Int64All(v["date"]),
+			InfoId:     util.ObjToString(v["pushinfo"]),
+			Visit:      h.isVisited(isvisit, 1),
+			Index:      1,
+			Area:       util.ObjToString(v["area"]),
+			City:       util.ObjToString(v["city"]),
+			Buyerclass: util.ObjToString(v["buyerclass"]),
+			Keys:       keys,
+		})
+		if len(pushCas) == 4000 {
+			return
 		}
+		//		}
 	}
 	return
 }
 
 //是否访问过
-func (h *historyPush) isVisited(openList int64, index int) int {
-	if uint64(openList)&(1<<uint64(index)) > 0 {
+func (h *historyPush) isVisited(isvisit int64, index int) int {
+	if uint64(isvisit)&(1<<uint64(index)) > 0 {
 		return 1
 	} else {
 		return 0
@@ -369,7 +375,7 @@ func (h *historyPush) getInfoByIds(pushCas []*jy.PushCa) []map[string]interface{
 }
 
 //保存最近7天的数据到历史记录
-func (h *historyPush) MakeHistoryDatas(userId, field string, o_jy map[string]interface{}) (bool, []map[string]interface{}) {
+func (h *historyPush) MakeHistoryDatas(userId, field string) (bool, []map[string]interface{}) {
 	allquery := `{"range":{"publishtime":{"gt":%s}}}`
 	allquery = fmt.Sprintf(allquery, fmt.Sprint(time.Now().AddDate(0, 0, -7).Unix()))
 	//allquery := ``
@@ -392,22 +398,22 @@ func (h *historyPush) MakeHistoryDatas(userId, field string, o_jy map[string]int
 		pushinfo = append(pushinfo, util.ObjToString(v["_id"]))
 
 		info := map[string]interface{}{
-			"area":              area_check,
-			"_id":               util.EncodeArticleId2ByCheck(util.ObjToString(v["_id"])),
-			"publishtime":       v["publishtime"],
-			"stype":             v["type"],
-			"toptype":           v["toptype"],
-			"subtype":           v["subtype"],
-			"s_subscopeclass":   v["s_subscopeclass"],
-			"buyer":             v["buyer"],
-			"projectname":       v["projectname"],
-			"budget":            v["budget"],
-			"bidopentime":       v["bidopentime"],
-			"winner":            v["winner"],
-			"bidamount":         v["bidamount"],
-			"title":             title,
-			"ca_openlist_index": k + 1,
-			"ca_date":           now.Unix(),
+			"area":             area_check,
+			"_id":              util.EncodeArticleId2ByCheck(util.ObjToString(v["_id"])),
+			"publishtime":      v["publishtime"],
+			"stype":            v["type"],
+			"toptype":          v["toptype"],
+			"subtype":          v["subtype"],
+			"s_subscopeclass":  v["s_subscopeclass"],
+			"buyer":            v["buyer"],
+			"projectname":      v["projectname"],
+			"budget":           v["budget"],
+			"bidopentime":      v["bidopentime"],
+			"winner":           v["winner"],
+			"bidamount":        v["bidamount"],
+			"title":            title,
+			"ca_isvisit_index": k + 1,
+			"ca_date":          now.Unix(),
 		}
 		area := util.ObjToString(info["area"])
 		if area == "A" {
@@ -457,13 +463,13 @@ func (h *historyPush) MakeHistoryDatas(userId, field string, o_jy map[string]int
 		"uid":      userId,
 		"pushinfo": strings.Join(pushinfo, ","),
 	}
-	flag := Ca_Push.SaveCacheByTimeOut("jy_pushsubscribe", wxpush, 10)
+	flag := Ca_Push.SaveCacheByTimeOut("jy_pushhistory", wxpush, 10)
 	return flag, result
 }
 
 //获取用户信息
 func (h *historyPush) UserInfo(userId string) (*map[string]interface{}, int64) {
-	user, ok := MQFW.FindById("user", userId, `{"s_m_openid":1,"a_m_openid":1,"s_phone":1,"a_mergeorder":1,"o_jy":1,"l_firstpushtime":1}`)
+	user, ok := MQFW.FindById("user", userId, `{"s_m_openid":1,"a_m_openid":1,"s_phone":1,"a_mergeorder":1,"o_jy":1,"l_firstpushtime":1,"i_vip_status":1,"l_vip_endtime":1,"o_vipjy":1}`)
 	if !ok || user == nil {
 		return nil, 0
 	}
@@ -472,12 +478,14 @@ func (h *historyPush) UserInfo(userId string) (*map[string]interface{}, int64) {
 
 //已访问过的,改变状态值
 func (h *historyPush) Visit(userId, infoId string, date int64, index int) {
+	log.Println(date, userId, index)
 	if date == 0 || userId == "" || index > 50 {
 		return
 	}
-	if res := Ca_Push.SearchOne("select openlist from jy_pushsubscribe where date=? and uid=? ", date, userId); len(res) > 0 {
-		saveValue := int64(uint64(util.Int64All(res["openlist"])) + 1<<uint64(index))
-		Ca_Push.CDB.Query("update jy_pushsubscribe set openlist = ? where uid=? and date=? ", saveValue, userId, date).Exec()
+	if res := Ca_Push.SearchOne("select isvisit from jy_pushhistory where date=? and uid=? ", date, userId); len(res) > 0 {
+		saveValue := int64(uint64(util.Int64All(res["isvisit"])) + 1<<uint64(index))
+		log.Println("saveValue:", saveValue)
+		Ca_Push.CDB.Query("update jy_pushhistory set isvisit = ? where uid=? and date=? ", saveValue, userId, date).Exec()
 		pc_a, err := jy.HistoryPush.GetPushCache_A(userId)
 		if err != nil {
 			log.Println(err)
@@ -510,7 +518,7 @@ func (h *historyPush) setVisit(date int64, infoId string, index int, list *[]map
 		if infoId != util.ObjToString(info["_id"]) {
 			continue
 		}
-		if index != util.IntAll(info["ca_openlist_index"]) {
+		if index != util.IntAll(info["ca_isvisit_index"]) {
 			continue
 		}
 		info["ca_visit"] = 1

+ 0 - 18
src/jfw/public/rpccall.go

@@ -166,21 +166,3 @@ func GetShareQRStr(url string) string {
 	}, func(e interface{}) {})
 	return ret
 }
-
-func AppPushServiceCall(m map[string]interface{}) bool {
-	defer util.Catch()
-	var repl string
-	client, err := rpc.DialHTTP("tcp", config.Sysconfig["appPushServiceRpc"].(string))
-	if err != nil {
-		log.Println(err.Error())
-		return false
-	}
-	defer client.Close()
-	b, _ := json.Marshal(m)
-	err = client.Call("Rpc.Push", b, &repl)
-	if err != nil {
-		log.Println(err.Error())
-		return false
-	}
-	return repl == "y"
-}

+ 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 - 1
src/jfw/timetask/followtimetask.go

@@ -7,6 +7,7 @@ import (
 	public "jfw/public"
 	"log"
 	"qfw/util"
+	"qfw/util/jy"
 	"qfw/util/redis"
 	rpc "qfw/util/rpc"
 	"strconv"
@@ -132,7 +133,7 @@ func tip() {
 		}
 		if jpushid != "" || opushid != "" {
 			phoneType, _ := (*userdata)["s_appponetype"].(string)
-			isPushOk := public.AppPushServiceCall(map[string]interface{}{
+			isPushOk := jy.AppPush(config.Sysconfig["appPushServiceRpc"].(string), map[string]interface{}{
 				"phoneType":   phoneType,
 				"otherPushId": opushid,
 				"jgPushId":    jpushid,

+ 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"

+ 10 - 2
src/web/staticres/css/wxlist.css

@@ -12,11 +12,19 @@
 	padding: 17px 0px 17px 0px;
 }
 .resnumb .two{
-	font-size:16px;
-	font-weight:500;
+	/*font-size:16px;*/
+	/*font-weight:500;*/
 	padding-left:25px;
 	float:left;
 	line-height:24px;
+	color: #1D1D1D;
+    font-size: .32rem;
+    text-align: justify;
+    text-overflow: ellipsis;
+    overflow: hidden;
+    display: -webkit-box;
+    -webkit-line-clamp: 2;
+    -webkit-box-orient: vertical;
 }
 .resnumb{
 	position: relative;

+ 4 - 4
src/web/staticres/vipsubscribe/css/base.css

@@ -12,15 +12,15 @@ body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fiel
 html,body {
     /* max-width: 750px; */
     -webkit-text-size-adjust: 100%;
-    margin: 0 auto;
+/*    margin: 0 auto;
     height: 100%;
-    overflow-x: hidden;
+    overflow-x: hidden;*/
     -webkit-box-sizing: border-box;
     box-sizing: border-box;
     font-size: .24rem;
-    background:rgba(245,244,249,1);;
+    background:rgba(245,244,249,1);
     color: #3d3d3d;
-    font-family:  "Microsoft YaHei","Helvetica Neue", "Roboto", "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
+    /*font-family:  "Microsoft YaHei","Helvetica Neue", "Roboto", "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;*/
 }
 
 ul,ol {

+ 32 - 0
src/web/staticres/vipsubscribe/css/public.css

@@ -378,3 +378,35 @@
 .custom-toast .weui-toast__content {
   margin: 0;
 }
+
+.jymobile-tab-triangle {
+  position: relative;
+}
+
+.jymobile-tab-triangle:after {
+  content: '';
+  position: absolute;
+  top: 50%;
+  right: 0;
+  width: 0;
+  height: 0;
+  font-size: 0;
+  line-height: 0;
+  border-style: solid;
+  border-width: .1rem;
+  border-color: #aaa transparent transparent transparent;
+  transform: translate(140%, -30%);
+}
+
+.jymobile-tab-triangle.active:after {
+  border-color: transparent transparent #2cb7ca transparent;
+  transform: translate(140%, -70%);
+}
+
+.jymobile-tab-triangle.current {
+  color: #2cb7ca;
+}
+
+.jymobile-tab-triangle.current:after {
+  border-color: #2cb7ca transparent transparent transparent;
+}

+ 114 - 11
src/web/staticres/vipsubscribe/css/subscribe_list.css

@@ -1,5 +1,7 @@
 @charset "UTF-8";
-.flex_alginC, .vip_banner .box .left, .filter_tab .tab_left, .filter_tab .tab_left .time_box, .filter_tab .tab_left .area_box, .filter_tab .tab_right .normal_set_box, .filter_tab .tab_right .vip_set_box, .filter_tab .area_container .area_wrap .area_data .p_item, .filter_tab .area_container .area_wrap .area_data .c_item, .list .list_item .item_type .time {
+.flex_alginC, .vip_banner .box .left, .filter_tab .tab_left, .filter_tab .tab_left .time_box,
+.filter_tab .tab_left .area_box, .filter_tab .tab_right .normal_set_box, .filter_tab .tab_right .vip_set_box, .filter_tab .area_container .area_wrap .area_data .p_item,
+.filter_tab .area_container .area_wrap .area_data .c_item, .list .list_item .item_type .time {
   display: flex;
   align-items: center;
 }
@@ -14,7 +16,97 @@
   box-sizing: border-box;
 }
 
-.free7days_pic {
+.jymobile-datePicker .weui-picker .weui-picker__hd #weui-picker-confirm {
+  color: #2CB7CA;
+}
+
+.jymobile-datePicker .weui-picker .weui-picker__hd .jymobile-picker__action {
+  flex: 1;
+  font-size: .32rem;
+  color: #1D1D1D;
+  text-align: left;
+}
+
+.jymobile-datePicker .weui-picker .weui-picker__bd {
+  font-size: .36rem;
+}
+
+.jymobile-datePicker .weui-picker .weui-picker__ft {
+  height: .88rem;
+  border-top: 1px solid #cecece;
+  background-color: #fff;
+}
+
+.jymobile-datePicker .weui-picker .weui-picker__ft .reset-time {
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  height: 100%;
+  color: #2CB7CA;
+  font-size: .32rem;
+  text-align: center;
+}
+
+.jymobile-setting-dialog {
+  font-size: .32rem;
+}
+
+.jymobile-setting-dialog .weui-dialog__hd {
+  padding: 0;
+  height: 0.82rem;
+  line-height: .82rem;
+  text-align: center;
+  background-color: #F5F4F9;
+}
+
+.jymobile-setting-dialog .weui-dialog__hd .weui-dialog__title {
+  font-size: .36rem;
+}
+
+.jymobile-setting-dialog .weui-dialog__bd {
+  padding: .37rem .1rem .38rem;
+  color: #1D1D1D;
+  font-size: .32rem;
+  text-align: center;
+}
+
+.jymobile-setting-dialog .weui-dialog__ft {
+  display: flex;
+  padding: 0 0 .38rem 0;
+  text-align: center;
+  justify-content: space-around;
+}
+
+.jymobile-setting-dialog .weui-dialog__ft:after {
+  border: none;
+}
+
+.jymobile-setting-dialog .weui-dialog__ft .weui-dialog__btn {
+  display: flex;
+  flex: none;
+  align-items: center;
+  justify-content: center;
+  width: 1.72rem;
+  height: .72rem;
+  color: #fff;
+  font-size: .32rem;
+  vertical-align: center;
+}
+
+.jymobile-setting-dialog .weui-dialog__ft .weui-dialog__btn_primary {
+  margin: 0;
+  margin-left: .3rem;
+  background-color: #2CB7CA;
+}
+
+.jymobile-setting-dialog .weui-dialog__ft .weui-dialog__btn_default {
+  margin: 0;
+  margin-right: .3rem;
+  background-color: #BFBFC3;
+}
+
+.free7days_pic,
+.noble_vip_pic {
   display: inline-block;
   margin-right: .2rem;
   padding-left: .4rem;
@@ -30,7 +122,7 @@
   top: -0.03rem;
   left: .05rem;
   display: inline-block;
-  width: .8rem;
+  padding: 0 .04rem;
   line-height: normal;
   font-size: 0.18rem;
   color: #fff;
@@ -88,22 +180,24 @@
   flex: 1;
 }
 
-.filter_tab .tab_left .time_box, .filter_tab .tab_left .area_box {
-  margin-right: .4rem;
+.filter_tab .tab_left .time {
+  margin-right: .15rem;
+}
+
+.filter_tab .tab_left .time_box,
+.filter_tab .tab_left .area_box {
+  margin-right: .3rem;
   color: #686868;
   font-size: .28rem;
 }
 
-.filter_tab .tab_left .time_box i, .filter_tab .tab_left .area_box i {
+.filter_tab .tab_left .time_box i,
+.filter_tab .tab_left .area_box i {
   font-size: .14rem;
   color: #aaa;
   margin-left: .08rem;
 }
 
-.filter_tab .tab_right {
-  flex: 1;
-}
-
 .filter_tab .tab_right .normal_set_box {
   font-size: .28rem;
   color: #1D1D1D;
@@ -171,13 +265,22 @@
   background: #F5F4F9;
 }
 
-.filter_tab .area_container .area_wrap .area_data .p_item, .filter_tab .area_container .area_wrap .area_data .c_item {
+.filter_tab .area_container .area_wrap .area_data .p_item,
+.filter_tab .area_container .area_wrap .area_data .c_item {
   position: relative;
   height: .88rem;
   line-height: .88rem;
   padding: 0 .3rem;
 }
 
+.filter_tab .area_container .area_wrap .area_data .p_item .city-count {
+  display: none;
+}
+
+.filter_tab .area_container .area_wrap .area_data .c_item .city-name {
+  flex: 1;
+}
+
 .filter_tab .area_container .area_wrap .area_data .p_item:after, .filter_tab .area_container .area_wrap .area_data .c_item:after {
   position: absolute;
   content: '';

Some files were not shown because too many files changed in this diff