Browse Source

Merge branch 'dev2.8.5' of http://192.168.3.207:10080/qmx/jy into dev2.8.5

wangshan 5 năm trước cách đây
mục cha
commit
b4ab0efd49

+ 35 - 1
src/jfw/modules/subscribepay/src/config.json

@@ -26,5 +26,39 @@
         "userName": "root",
         "passWord": "Topnet123"
     },
-	"appPushServiceRpc": "127.0.0.1:5566"
+	"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"
+       }
+   },
+    "mail": [
+        {
+            "addr": "smtp.exmail.qq.com",
+            "port": 465,
+            "pwd": "ue9Rg9Sf4CVtdm5a",
+            "user": "public03@topnet.net.cn"
+        },
+        {
+            "addr": "smtp.exmail.qq.com",
+            "port": 465,
+            "pwd": "ue9Rg9Sf4CVtdm5a",
+            "user": "public03@topnet.net.cn"
+        }
+    ]
 }

+ 32 - 1
src/jfw/modules/subscribepay/src/config/config.go

@@ -1,6 +1,9 @@
 package config
 
-import "qfw/util"
+import (
+	"qfw/util"
+	"qfw/util/mail"
+)
 
 type config struct {
 	MongodbServers  string
@@ -25,6 +28,34 @@ type config struct {
 
 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
+
 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 {
+		mail := &mail.GmailAuth{
+			SmtpHost: v["addr"].(string),
+			SmtpPort: util.IntAll(v["port"]),
+			User:     v["user"].(string),
+			Pwd:      v["pwd"].(string),
+			//			PoolChan: nil,
+			//			PoolSize: 0,
+		}
+		GmailAuth = append(GmailAuth, mail)
+	}
 }

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 121 - 0
src/jfw/modules/subscribepay/src/dataexport.json


+ 21 - 7
src/jfw/modules/subscribepay/src/service/orderListDetails.go

@@ -1,16 +1,14 @@
 package service
 
 import (
+	"config"
 	"errors"
-	"jfw/config"
 	"log"
 	"strconv"
 	"strings"
 	"time"
 	"util"
 
-	"jfw/public"
-
 	qutil "qfw/util"
 
 	"github.com/go-xweb/xweb"
@@ -246,7 +244,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)
-			public.SendMailToBJFinance(orderdata, pay_time, "", 2, config.GmailAuth)
+			util.SendMailToBJFinance(orderdata, pay_time, "", 2, config.GmailAuth)
 		}()
 	}
 	o.ServeJson(map[string]interface{}{
@@ -259,20 +257,30 @@ func (o *OrderListDetails) ApplyInvoice() error {
 func (o *OrderListDetails) PayCancel() bool {
 	order_code := o.GetString("order_code")
 	userId := qutil.ObjToString(o.GetSession("userId"))
-	//	参数:查询语句,不等语句,修改条件
+	//参数:查询语句,不等语句,修改条件
 	bl := util.Mysql.UpdateByNotEqual(tableName_order, bson.M{
 		"user_id":      userId,
 		"product_type": "vip订阅",
 	}, bson.M{
 		"order_code":   order_code,
-		"order_status": orderStatus_deleted,
+		"order_status": orderStatus_deleted, //已删除
+	}, bson.M{
+		"order_status": orderStatus_paid, //已购买
 	}, bson.M{
 		"order_status": orderStatus_cancel,
 	})
+	log.Println("bl:", bl)
 	return bl
 }
 
 func (o *OrderListDetails) SetRes(res []map[string]interface{}, queryM map[string]interface{}) {
+	//获取最后一次购买的vip订单
+	lastbuy := *util.Mysql.Find(tableName_order, queryM, "order_code,pay_time", "pay_time desc", -1, 0)
+	queryM["product_type"] = "vip订阅"
+	lastbuy_code := ""
+	if len(lastbuy) > 0 && lastbuy != nil {
+		lastbuy_code = qutil.ObjToString(lastbuy[0]["order_code"])
+	}
 	for _, v := range res {
 		if v["filter_publishtime"] != nil {
 			filter_publishtime := v["filter_publishtime"]
@@ -295,7 +303,10 @@ 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"] = public.GetWaitPayToken(v["id"].(int64), int(orderMoney.(int64)), v["order_code"].(string), v["pay_way"].(string), queryM["user_id"].(string))
+			v["token"] = util.GetWaitPayToken(v["id"].(int64), int(orderMoney.(int64)), v["order_code"].(string), v["pay_way"].(string), queryM["user_id"].(string))
+		}
+		if lastbuy_code == v["order_code"] {
+			v["lastbuy_code"] = lastbuy_code
 		}
 		if v["pay_time"] != nil && v["product_type"] == "vip订阅" {
 			//TODO 还没录入数据
@@ -305,6 +316,9 @@ func (o *OrderListDetails) SetRes(res []map[string]interface{}, queryM map[strin
 				v["l_vip_starttime"] = qutil.ObjToString((*data)["l_vip_starttime"])
 				v["l_vip_endtime"] = qutil.ObjToString((*data)["l_vip_endtime"])
 			} else {
+				/*
+					0:暂不使用vip订阅 1:试用 2:正式 -1:试用到期 -2:正式到期
+				*/
 				v["i_vip_status"] = "1"
 				v["l_vip_starttime"] = "1571991460"
 				v["l_vip_endtime"] = "1572596260"

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

@@ -0,0 +1,842 @@
+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
+}

+ 1 - 0
src/web/staticres/vipsubscribe/css/vip_purchase.css

@@ -535,6 +535,7 @@
 
 .vip_purchase .choose_condition .vip_rules .vip_prise_table .table_title {
   margin-bottom: .3rem;
+  margin-top: .3rem;
 }
 
 .vip_purchase .choose_condition .vip_rules .vip_prise_table table {

+ 81 - 8
src/web/staticres/vipsubscribe/js/common.js

@@ -56,13 +56,86 @@ function getAreaClassArr(area){
     return [provinceArr,cityArr]
 }
 
-//选择行业是否发生改变
-function arrIsChange(arr1,arr2){
-	
-	return false
+/* vip订阅
+	area:地区 {}
+	industry:行业 []
+	time[count,unit] count:时间长度 unit 1:年 2:月
+   return 价格(单位:分)
+*/
+function getsubVipOrderPrice(area,industry,t){
+	if(industry[0] == "全部行业"){
+		industry= []
+	}
+	if(area["全国"]){
+		if(industry.length==1) return getSetMealPrice(0,1,t[1])*t[0]/100 //全国1行业套餐
+		if(industry.length==0) return getSetMealPrice(0,0,t[1])*t[0]/100 //全国全行业套餐
+		return	getSetMealPrice(0,0,t[1])*t[0]/100 //全国多行业套餐
+	}
+	var final_price	= 0//最终价格
+	for(var i in area) {
+		let thisPrice = 0;	
+		let citys = area[i]
+		if(citys.length>0){//市
+			if(citys.length==1){//单城市
+				thisPrice = getSetMealPrice(2,industry.length,t[1])*t[0];
+			}else{//多城市
+				if(industry.length==0||industry.length==1){//多城市 单行业
+					thisPrice = citys.length*getSetMealPrice(2,industry.length,t[1])*t[0];	
+				}else{//多行业 多行业
+					if(t[1]==2){//月
+						var industry_Price= 580*industry.length>1800?1800:580*industry.length;
+						var city_Price = citys.length*580>1180?1180:citys.length*580;
+						if(t[0]>10) t[0]=10 //月份十个月以上价格一样
+						thisPrice = (industry_Price + city_Price)*t[0];
+					}else{//年
+						var industry_Price= 5800*industry.length>18000?18000:5800*industry.length;
+						var city_Price = citys.length*5800>11800?11800:citys.length*5800;
+						thisPrice = (industry_Price + city_Price)*5800*t[0]/100;
+					}
+				}
+			}
+		}else{//省
+			thisPrice = getSetMealPrice(1,industry.length,t[1])*t[0];
+		}
+		//console.log("thisPrice",i,thisPrice)
+    	final_price += thisPrice;
+    }
+    return final_price/100
 }
-
-//选择地区是否发生改变
-function objIsChange(obj1,obj2){
-	
+//获取套餐价格
+//c(city) 全国:0 省:1 市:2 
+//i(industry) 全行业:0 行业:1 其他:多个行业
+//u(unit) 年:1 月:2
+function getSetMealPrice(c,i,u){
+	let t = u==2 //是否是月单位
+	let 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个行业
+		}
+	}
 }

+ 14 - 3
src/web/templates/weixin/dataExport/dataExport_toMyOrder.html

@@ -940,10 +940,11 @@
 	                        }else if(cycleunit_vip==2){
 	                        	effectiveduration_vip=cyclecount_vip+"个月"
 	                        }
-	                        if(obj.i_vip_status=="1"){		//试用
+	                        var vip_status =obj.i_vip_status;	// 1:试用 2:正式 -1:试用到期 -2:正式到期
+	                        if(obj.i_vip_status=="1"){			//试用
 	                        	effectiveduration_vip="7天";
 	                        }
-	                        //订单状态 0待支付 1已完成 -1删除
+	                        //订单状态 0待支付 1已完成 -1删除  
 	                        var orderStatus_vip =  obj.order_status;
 	                        var token_vip = obj.token;
 	                        if(sessionStorage&&sessionStorage.getItem("paySuccess_"+obj.order_code)!=null){
@@ -981,11 +982,21 @@
 	                        	orderStatus_vip="已完成";
 	                        	orderHtml=""
 	                        	orderHtml+='<span class="status">'+orderStatus_vip+'</span>'
+	                        	//最后一次购买完 1:试用 2:正式 -1:试用到期 -2:正式到期
+	                        	
 	                    		orderHtml+="<a class=\"shanchu iconfont  icon-shanchu\" title=\"删除订单\" onclick=\"deleteOrder(" + id_vip +",this)\"></a>";
 	                        	iconHtml=""
-	                        	iconHtml+='<div class="card-footer">'
+	                        	if((vip_status=="-1")||(vip_status=="-2")){
+	                        		iconHtml+='<div class="card-footer">'
 											+'<a  onclick="onceMore(this)" class="btn cancle">再次购买</a>'
 										+'</div>'
+	                        	}else if(vip_status=="2"){
+	                        		iconHtml+='<div class="card-footer">'
+											+'<a  onclick="onceMore(this)" class="btn cancle">续费</a>'
+										+'</div>'
+	                        	}else{
+	                        		
+	                        	}
 	                        }else if(orderStatus_vip==-2){
 	                        	orderStatus_vip="已取消";
 	                        	orderHtml="";

+ 39 - 13
src/web/templates/weixin/vipsubscribe/choose_area.html

@@ -384,34 +384,45 @@
     <script src="/vipsubscribe/js/jquery-2.1.4.js?v={{Msg "seo" "version"}}"></script>
     <script src="/vipsubscribe/js/fastclick.js?v={{Msg "seo" "version"}}"></script>
     <script src="/vipsubscribe/js/mapJSON.js?v={{Msg "seo" "version"}}"></script>
+    <script src="/vipsubscribe/js/common.js?v={{Msg "seo" "version"}}"></script>
     <script>
       var AreaChoose={
         selectObj:{},//已选择,未购买城市;
-        inintData:function(){ //初始化selectObj
+        selectedIndustryArr:["一个行业"],//计算价格临时变量
+        timeSelect:[1,2],//计算价格临时变量 timeSelect[0]时长  timeSelect[1] 1:年 2:月
+        vipSubisTrial:false,
+        inintData:function(){
           //已选择
           try{
             let select =sessionStorage.getItem("vipSubSelectArea");
             if(select){
               this.selectObj=JSON.parse(select);
             }
+            if(sessionStorage.getItem("vipSubSelectIndustry")){
+              this.selectedIndustryArr=JSON.parse(sessionStorage.getItem("vipSubSelectIndustry"));
+            }
+            if(sessionStorage.getItem("vipSubSelectTime")){
+              this.timeSelect=JSON.parse(sessionStorage.getItem("vipSubSelectTime"));
+            }
+            //是否试用界面
+            if(sessionStorage.getItem("vipSubisTrial")) this.vipSubisTrial=true;
           }catch(e){
             console.log(e);
             this.selectObj={};
           }
-          console.log(this.selectObj)
         },
         inintPage:function(){//初始化省份城市选项   
           $(".select-area-box ul li:not('.index')").each(function () {
-                var text = $(this).find(".province").text().trim()
-                var data = null
-                chinaMapJSON.some(function (v) {
-                    data = v
-                    return v.name.indexOf(text) !== -1
-                })
-                var box = $(this).find('div.tab_content')
-                var html = AreaChoose.createMoreCity(data.city)
-                box.html(html)
-            })
+              var text = $(this).find(".province").text().trim()
+              var data = null
+              chinaMapJSON.some(function (v) {
+                  data = v
+                  return v.name.indexOf(text) !== -1
+              })
+              var box = $(this).find('div.tab_content')
+              var html = AreaChoose.createMoreCity(data.city)
+              box.html(html)
+          })
         },
         createMoreCity:function(arr){
           var tempHtml = arr.map(function (v) {
@@ -453,6 +464,11 @@
           })
         },
         getResult:function(){   /* 选中结果 */
+          //如果选中所有,则转为全国
+          if($(".city").length==$(".city.active").length){
+            $(".checkbox.other").trigger("click");
+            return
+          }
           this.selectObj = {};
           $('.result_name').empty()
           var data = []; //定义一个总数组
@@ -513,7 +529,7 @@
               if( children.length >0){
                   // 判断每个省份下选中的城市长度,当大于等于4的时候 弹出"选择全省更划算的弹窗"
                   let childrenArr=[];
-                  if (children.length >= 4) {
+                  if (children.length >= 4 && !this.vipSubisTrial) {
                       $('.tips_btn .tips_d_text').show()
                   } 
                   html += `${result[i].name}(`
@@ -543,6 +559,8 @@
           console.log("this.selectObj:",this.selectObj)
           $('.result_name').append(html)
           AreaChoose.isOpen()
+          //刷新价格
+          AreaChoose.flushPrice();
         },
         submitArea:function(){
           let addCity = $('.result_name').text(); //新增的城市
@@ -703,6 +721,14 @@
             }else{
                 AreaChoose.getResult() 
             }
+        },
+        flushPrice:function(){
+          if(this.vipSubisTrial){
+            $('.tips_d_money').css("display","none");
+          }else{
+            var price=getsubVipOrderPrice(this.selectObj,this.selectedIndustryArr,this.timeSelect);
+            $('.tips_d_money').text('¥'+price);
+          }
         }
       }
       

+ 26 - 30
src/web/templates/weixin/vipsubscribe/choose_industry.html

@@ -243,6 +243,7 @@
         <script src="/vipsubscribe/js/jquery-2.1.4.js?v={{Msg "seo" "version"}}"></script>
         <script src="/vipsubscribe/js/fastclick.js?v={{Msg "seo" "version"}}"></script>
         <script src="/vipsubscribe/js/weui.min.js?v={{Msg "seo" "version"}}"></script>
+        <script src="/vipsubscribe/js/common.js?v={{Msg "seo" "version"}}"></script>
         <script>
               
            // 点击导航跳转
@@ -254,31 +255,6 @@
                 document.querySelector('#' + s).scrollIntoView({block:'center'});
             })
             
-            // 在续订里,要保存已经选中的数组并置灰,按需要拼接上选中的行业数组
-
-            // button一共有以下几个操作属性
-            // 1. class中有active,表示当前被选中
-            // 2. button具有自定义属性disabled,此时button不能触发click事件,可以在续订中用来表示不可选的按钮
-
-            // var slideLetters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
-
-            // 参数: (用数据创建行业的DOM)
-            // letter: 为首字母,大写
-            // industryArr: 该首字母下的行业数组,默认为[]/
-            // 格式类似:disabled为true则按钮置灰,不能被点击
-            // [
-            //     { name: '电力', disabled: true },
-            //     { name: '采矿业', disabled: true }
-            // ]
-            /* 
-            插入行业
-            var insertArr = [
-                { name: '医疗1', disabled: true },
-                { name: '医疗2', disabled: false },
-                { name: '医疗3', disabled: true }
-            ]
-            insertIndustryItem('E', insertArr)
-            */
             function insertIndustryItem (letter, industryArr = []) {
                 if (!letter) return
                 var query = `#${letter[0].toUpperCase()} .item_industry_list`
@@ -304,7 +280,7 @@
                 })
                 
                 // 显示隐藏优惠tips
-                if (selectedArr.length >= 4) {
+                if (selectedArr.length >= 4 && !vipSubisTrial) {
                     $('.tips_btn .tips_d_text').slideDown()
                 } else {
                     $('.tips_btn .tips_d_text').slideUp()
@@ -340,6 +316,15 @@
               })
             }
             
+            function flushPrice(){
+              if(vipSubisTrial){
+                $('.tips_d_money').css("display","none");
+              }else{
+                var price=getsubVipOrderPrice(selectedAreaObj,selectedIndustryArr,timeSelect);
+                $('.tips_d_money').text('¥'+price);
+              }
+            }
+            
             // 每个button的点击事件
             $('.select-area-box .list').on('click', 'button', function (e) {
                 $('.tips_btn .btns button').removeAttr('disabled')
@@ -352,8 +337,9 @@
                 } else {
                     $('#all button').removeClass('active')
                 }
-
+                
                 findSelectedIndustry()
+                flushPrice()
             })
 
             // 重置按钮事件
@@ -371,22 +357,32 @@
                 history.go(-1);
             })
                        
-            var selectedIndustryArr //已选择
-            
+            var selectedIndustryArr //已选择行业
+            var selectedAreaObj = {"一个省":["一个市"]} //计算价格临时变量
+            var timeSelect = [1,2]//计算价格临时变量 timeSelect[0]时长  timeSelect[1] 1:年 2:月
+            var vipSubisTrial = false;
             $(function(){
- 
               try{
                 if(sessionStorage.getItem("vipSubSelectIndustry")){
                   selectedIndustryArr=JSON.parse(sessionStorage.getItem("vipSubSelectIndustry"));
                 }else{
                   selectedIndustryArr=[];
                 }
+                if(sessionStorage.getItem("vipSubSelectArea")){
+                  selectedAreaObj=JSON.parse(sessionStorage.getItem("vipSubSelectArea"));
+                }
+                if(sessionStorage.getItem("vipSubSelectTime")){
+                  this.timeSelect=JSON.parse(sessionStorage.getItem("vipSubSelectTime"));
+                }
+                //是否试用界面
+                if(sessionStorage.getItem("vipSubisTrial")) vipSubisTrial=true;
               }catch(e){
                 console.log(e)
               }
               //已选择
               showSelect(selectedIndustryArr,true);
               findSelectedIndustry();
+              flushPrice();
             })
         </script>
     </body>

+ 78 - 27
src/web/templates/weixin/vipsubscribe/vip_purchase.html

@@ -72,7 +72,7 @@
                 </div>
                 {{end}}
                 <div class="vip_rules">
-                    {{if not .T.isTrial }}
+                    <!--
                       <div class="auto_renew weui-cells_checkbox radio-form">
                           <label class="weui-cell weui-check__label" for="auto-renew">
                               <div class="weui-cell__hd">
@@ -84,7 +84,7 @@
                               </div>
                           </label>
                       </div>
-                    {{end}}
+                    -->
                     <div class="vip_prise_table">
                         <table class="monthly">
                             <caption class="table_title">- VIP订阅价格 -</caption>
@@ -179,7 +179,7 @@
                             <label class="weui-cell weui-check__label monthly_label" for="monthly">
                                 <div class="weui-cell__hd">
                                     <input type="radio" class="weui-check monthly" name="time" value="month"
-                                        id="monthly" />
+                                        id="monthly"/>
                                     <i class="weui-icon-checked"></i>
                                 </div>
                                 <div class="weui-cell__bd">
@@ -209,7 +209,7 @@
                                 </div>
                             </label>
                             <div class="number_box" id="number_box_year" style="border: 0;">
-                                <span class="year_number active" data-id="1">1年</span>
+                                <span class="year_number" data-id="1">1年</span>
                                 <span class="year_number" data-id="2">2年</span>
                                 <span class="year_number" data-id="3">3年</span>
                             </div>
@@ -262,6 +262,7 @@
     <script>
       //微信支付start
       {{if not .T.isTrial }}
+      try{
   			var signature = {{.T.signature}};
   			var isConfigSuccess = true;
   			var id = {{.T._id}}
@@ -317,12 +318,19 @@
   				});
   			}        
       //微信支付end
+      }catch(e){
+        console.log(e)
+      }
+        sessionStorage.removeItem("vipSubisTrial");//非试用界面
       {{else}}
-      //试用
+        sessionStorage.setItem("vipSubisTrial","1");//试用界面
+        //试用用户
       {{end}}
       var purchase = {
-        areaSelect:{},//已选择地区
-        industrySelect:[],
+        areaSelect:{"一个省":["一个市"]},//已选择地区 {"一个省":["一个市"]}计算价格临时变量
+        industrySelect:["一个行业"],// 已选择行业 一个行业(计算价格临时变量)
+        timeSelect:[1,2],//已选择时间 timeSelect[0]时长  timeSelect[1] 1:年 2:月
+        vipSubisTrial:false,
         initData: function(){
           //已选择
           try{
@@ -332,8 +340,13 @@
             if(sessionStorage.getItem("vipSubSelectIndustry")){
               this.industrySelect=JSON.parse(sessionStorage.getItem("vipSubSelectIndustry"));
             }
+            if(sessionStorage.getItem("vipSubSelectTime")){
+              this.timeSelect=JSON.parse(sessionStorage.getItem("vipSubSelectTime"));
+            }
             //是否已经点击已读
-            if(sessionStorage.getItem("vipSub_read")=="true")$("#buy").prop("checked",true);
+            if(sessionStorage.getItem("vipSub_read")=="true") $("#buy").prop("checked",true);
+            //是否试用界面
+            if(sessionStorage.getItem("vipSubisTrial")) this.vipSubisTrial=true;
           }catch(e){
             console.log(e)
           }  
@@ -355,7 +368,7 @@
             $(".choose_area").val(provinceArr.join(" ")+" "+cityArr.join(" "));
           }
 
-          if(!$.isEmptyObject(this.areaSelect)&&!this.areaSelect["全国"]){ //选择有行业信息 且不是全国
+          if(!$.isEmptyObject(this.areaSelect)&&!this.areaSelect["全国"]&&!this.areaSelect["一个省"]){ //选择有行业信息 且不是全国
             var tipTxt="已选择 ";
             if(provinceArr.length>0)tipTxt+=provinceArr.length+" 个省级区域";
             if(cityArr.length>0){
@@ -370,10 +383,34 @@
           if(data.length>0){
             $(".choose_industry").val(data.join(" "));
           }
-          if(this.industrySelect.length>0&&this.industrySelect[0]!="全部行业"){ //选择有行业信息
+          if(this.industrySelect.length>0&&this.industrySelect[0]!="全部行业"&&this.industrySelect[0]!="一个行业"){ //选择有行业信息
             var tipTxt="已选择 ";
             $(".add_tips.industry").text(tipTxt+this.industrySelect.length+" 个行业").css("display","");
           }
+        },
+        showTime:function(){
+          let tmp = this.timeSelect[0];
+          if(this.timeSelect[1]==1){
+            tmp +="年"
+            $("#yearly").prop('checked', true);
+            $('.year_number:eq('+(this.timeSelect[0]-1)+')').addClass("active");
+            //$(".number_box:eq(1)").addClass("active");
+          }else{
+            tmp +="个月"
+            $("#monthly").prop('checked', true);
+            $(".number_box:eq(0)").addClass("active");
+            $("#number_box_month .month_number").text(this.timeSelect[0])
+          }
+          $(".info.choose_time").val(tmp);
+        },
+        flushPrice:function(){
+          if(this.vipSubisTrial){
+            $('.price strong').text('¥0.00');
+          }else{
+            var price=getsubVipOrderPrice(this.areaSelect,this.industrySelect,this.timeSelect);
+            $('.price strong').text('¥'+price);
+            $('.computed_price').html('¥' + price);
+          }
         }
       }
         
@@ -383,6 +420,8 @@
             purchase.initData();
             purchase.showArea();
             purchase.showIndustry();
+            purchase.showTime();
+            purchase.flushPrice();
             checkOk();
             var time_limit;//定义一个周期变量
             /*------ 关闭弹窗事件  点击取消或遮罩层 -----*/
@@ -426,9 +465,10 @@
             /* --------控制月份number_box的事件  点击加减号触发的事件------- */
             $('#number_box_month').on('click', 'button', function (e) {
                 // 点击加减号让input radio选中
-                $("#monthly").prop('checked', true);
+                $('#monthly').prop('checked', true);
                 $('#yearly').prop('checked', false);
                 $('.number_box span').removeClass('active')
+                $('#number_box_month').addClass('active')
 
                 var $number = $('#number_box_month span.month_number');
                 var $monthlyInput = $('#monthly');
@@ -457,8 +497,10 @@
                         .numboxStep;
                 }
                 $number.text(currentNum)
-                var price = (5.8 * currentNum).toFixed(1);
-                $('.computed_price').html('¥' + price)
+                purchase.timeSelect=[Number(currentNum),2];
+                purchase.flushPrice();
+                //var price = (5.8 * currentNum).toFixed(1);
+                //$('.computed_price').html('¥' + price)
                 var firstButton = $('#number_box_month button:first')
                 var lastButton = $('#number_box_month button:last')
                 if (currentNum >= 10) {
@@ -483,14 +525,18 @@
             /* -------- 控制年份number_box的事件  点击1年 2年 3年触发的事件------- */
             $('#number_box_year').on('click', 'span', function (e) {
                 console.log(e.target.dataset.id)
+                $('#number_box_month').removeClass('active')
                 let id = e.target.dataset.id;
                 $('.profit_tips').hide()
                 $(this).addClass('active').siblings().removeClass('active')
                 $('#yearly').prop('checked', true);
                 $("#monthly").prop('checked', false);
+
                 // 渲染结果 保留一位小数
-                let result = (Number(id) * 58).toFixed(1);
-                $('.computed_price').html('¥' + result)
+                //let result = (Number(id) * 58).toFixed(1);
+                //$('.computed_price').html('¥' + result)
+                purchase.timeSelect=[Number(id),1];
+                purchase.flushPrice();
             })
 
             /* -------- 选择按月订阅  radio触发的事件------- */
@@ -500,14 +546,15 @@
                 if (val >= 10) {
                     $('.profit_tips').show()
                 }
-                console.log(val)
                 if (!isChecked) {
                     $('#number_box_month button').attr('disabled', true)
                 } else {
                     $('#number_box_month button').removeAttr('disabled')
                 }
-                let result = (Number(val) * 5.8).toFixed(1);
-                $('.computed_price').html('¥' + result)
+                //let result = (Number(val) * 5.8).toFixed(1);
+                //$('.computed_price').html('¥' + result);
+                purchase.timeSelect=[Number(val),2];
+                purchase.flushPrice();
 
             })
             /* -------- 选择按年订阅  radio触发的事件------- */
@@ -516,13 +563,13 @@
                 // console.log($(this).is(':checked'))
                 let isChecked = $(this).is(':checked')
                 // 按年订阅默认选择1年 
-                let val = 1;
-                $('.computed_price').html('¥' + Number(val) * 58)
+                //let val = 1;
+                //$('.computed_price').html('¥' + Number(val) * 58)
                 if (isChecked) {
                     $('#number_box_year span:eq(0)').addClass('active').siblings().removeClass('active')
-
                 }
-
+                purchase.timeSelect=[Number(val),1];
+                purchase.flushPrice();
             })
 
             // 确认订阅周期
@@ -534,15 +581,18 @@
                         val = $('.active').html()
                         $('#time_cycle').hide(function () {
                             $('.choose_time').val(val)
-
                         })
+                        purchase.timeSelect=[parseInt(val[0]),1]
                     } else if ($(v).is(':checked') === true) {
                         val = $('.month_number').html();
                         $('#time_cycle').hide(function () {
                             $('.choose_time').val(val + '个月')
                         })
+                        purchase.timeSelect=[parseInt(val),2]
                     }
                 })
+                purchase.flushPrice();
+                sessionStorage.setItem("vipSubSelectTime",JSON.stringify(purchase.timeSelect));
             })
             $("input").bind("input propertychange change", function (event) {
               checkOk();  
@@ -577,6 +627,7 @@
                   $DoPost("/subscribepay/order/trialPay",{"area":JSON.stringify(area),"industry":industry.join(",")},function(r){
                     if(r.success){
                       clearSessionStorage();
+                      $("#payHandle").attr("disabled","disabled");  
                       window.location.replace("/front/vipsubscribe/toPaySuccessPage?orderCode="+r.data.code);
                     }
                   }) 
@@ -595,9 +646,9 @@
           var industry = $(".info:eq(1)").val().trim();
           var checked = $('#buy').prop('checked');
           if (area != '' && industry != '' && checked == true) {
-              $(".enter").removeAttr('disabled');
+              $("#payHandle").removeAttr('disabled');
           } else {
-              $(".enter").attr({
+              $("#payHandle").attr({
                   'disabled': 'true'
               });
           }
@@ -607,9 +658,9 @@
         function clearSessionStorage(){
           sessionStorage.removeItem("vipSubSelectArea");
 					sessionStorage.removeItem("vipSubSelectIndustry");
+					sessionStorage.removeItem("vipSubSelectTime");
 					sessionStorage.removeItem("vipSub_read");
-					$(".enter").attr("disabled","disabled");  
-        };
+        }
                    
     </script>
 </body>

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác