wangkaiyue 5 năm trước cách đây
mục cha
commit
bfb45e7bdd
27 tập tin đã thay đổi với 333 bổ sung291 xóa
  1. 11 11
      src/jfw/modules/subscribepay/src/a/init.go
  2. 3 2
      src/jfw/modules/subscribepay/src/config.json
  3. 5 10
      src/jfw/modules/subscribepay/src/config/config.go
  4. 6 9
      src/jfw/modules/subscribepay/src/entity/subscribeVip.go
  5. 16 2
      src/jfw/modules/subscribepay/src/main.go
  6. 27 15
      src/jfw/modules/subscribepay/src/rpcfollow/rpc.go
  7. 1 1
      src/jfw/modules/subscribepay/src/service/orderListDetails.go
  8. 0 176
      src/jfw/modules/subscribepay/src/service/trial.go
  9. 5 5
      src/jfw/modules/subscribepay/src/service/vipSubscribePay.go
  10. 161 3
      src/jfw/modules/subscribepay/src/service/vipSubscribeTrial.go
  11. BIN
      src/jfw/modules/subscribepay/src/web/staticres/res/dataexport/20191102164927_144238100357_zxkMq.xlsx
  12. 1 0
      src/jfw/modules/subscribepay/src/web/staticres/res/dataexport/a.txt
  13. 1 1
      src/jfw/rpcfollow/rpc.go
  14. 12 7
      src/web/staticres/vipsubscribe/css/choose_area.css
  15. 9 3
      src/web/staticres/vipsubscribe/css/choose_industry.css
  16. 8 0
      src/web/staticres/vipsubscribe/css/trial_info.css
  17. 6 4
      src/web/staticres/vipsubscribe/css/vip_introduce.css
  18. 2 0
      src/web/staticres/vipsubscribe/css/vip_pay_success.css
  19. 4 0
      src/web/staticres/vipsubscribe/css/vip_purchase.css
  20. 3 0
      src/web/templates/weixin/vipsubscribe/choose_area.html
  21. 2 0
      src/web/templates/weixin/vipsubscribe/choose_industry.html
  22. 1 1
      src/web/templates/weixin/vipsubscribe/modal.html
  23. 1 1
      src/web/templates/weixin/vipsubscribe/trial_info.html
  24. 1 1
      src/web/templates/weixin/vipsubscribe/vip_introduce.html
  25. 27 23
      src/web/templates/weixin/vipsubscribe/vip_order_detail.html
  26. 16 14
      src/web/templates/weixin/vipsubscribe/vip_pay_success.html
  27. 4 2
      src/web/templates/weixin/vipsubscribe/vip_purchase.html

+ 11 - 11
src/jfw/modules/subscribepay/src/a/init.go

@@ -21,21 +21,21 @@ func init() {
 	xweb.RootApp().AppConfig.SessionTimeout = 30 * time.Minute
 	xweb.RootApp().Logger.SetOutputLevel(1) //输出日志,改为4则不输出任何日志
 	//
-	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("/subscribepay", &service.AfterPay{})
+	xweb.AddRouter("/subscribepay", &service.TrialOrder{})     //试用&订单
+	xweb.AddRouter("/subscribepay", &service.SubVipPayOrder{}) //付费&订单
+	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.DataExportPayMobile{})
+	xweb.AddRouter("/jypay", &service.DataExportPayPC{})
+	xweb.AddRouter("/jypay", &service.RewardPayAction{})
 	//数据报告
-	xweb.AddRouter("/jypay",&service.DataReport{})
+	xweb.AddRouter("/jypay", &service.DataReport{})
 	//支付回调
-	xweb.AddRouter("/jypay",&service.PayCallBackAction{})
+	xweb.AddRouter("/jypay", &service.PayCallBackAction{})
 	//支付成功&申请等
-	xweb.AddRouter("/jypay",&service.CommonAction{})
+	xweb.AddRouter("/jypay", &service.CommonAction{})
 
 }

+ 3 - 2
src/jfw/modules/subscribepay/src/config.json

@@ -1,11 +1,12 @@
 {
-	"mongodbServers": "192.168.3.128:27080",
+	"mongodbServers": "192.168.3.11:27080",
     "mongodbPoolSize": 25,
     "mongodbName": "qfw",
     "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",
+    "elasticsearch": "http://192.168.3.11:9800",
     "elasticPoolSize": 30,
     "webport": "86",
+    "webrpcport": "8600",
     "weixinrpc": "127.0.0.1:8083",
     "cassandra": {
         "log": {

+ 5 - 10
src/jfw/modules/subscribepay/src/config/config.go

@@ -13,6 +13,7 @@ type config struct {
 	ElasticPoolSize int
 	Redisaddrs      string
 	Webport         string
+	Webrpcport      string
 	Weixinrpc       string
 	Cassandra       struct {
 		Host []string
@@ -26,11 +27,11 @@ type config struct {
 		PassWord string
 	}
 	AppPushServiceRpc string
-	WebDomain string
-	Mail []struct{
+	WebDomain         string
+	Mail              []struct {
 		Addr string
 		Port int
-		Pwd string
+		Pwd  string
 		User string
 	}
 }
@@ -43,7 +44,7 @@ var PayConf map[string]interface{}
 var AliPayConf map[string]interface{}
 var WxPayConf map[string]interface{}
 
-var Wxoauth,Wxoauthinfo string
+var Wxoauth, Wxoauthinfo string
 
 func init() {
 	//程序配置文件
@@ -66,9 +67,3 @@ func init() {
 	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`
 
 }
-
-
-
-
-
-

+ 6 - 9
src/jfw/modules/subscribepay/src/entity/subscribeVip.go

@@ -32,22 +32,19 @@ func StartTrial(userId string, area *map[string]interface{}, industry []string)
 
 //查询是否有试用权限
 func CanTrial(userId string) bool {
-	m, ok := util.MQFW.FindById("user", userId, `{"o_vipjy":1}`)
+	m, ok := util.MQFW.FindById("user", userId, `{"o_vipjy":1,"i_vip_status":1}`)
 	if m == nil || len(*m) == 0 || !ok {
 		return false
 	}
 	obj := qutil.ObjToMap((*m)["o_vipjy"])
-	if qutil.IntAll((*obj)["i_trial"]) != 1 {
+	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, "更新使用状态出错")
+	//是否使用过(使用过VIP订阅功能,就不能试用)
+	if qutil.IntAll((*m)["i_vip_status"])!=0{  //开启状态:0-暂不使用vip订阅 1-试用 2-正式 -1-试用到期 -2-正式到期
+		return false
 	}
+	return true
 }
 
 //获取省份,城市,行业购买数量;-1为全部

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

@@ -4,15 +4,29 @@ import (
 	_ "a"
 	. "config"
 	_ "filter"
+	"github.com/go-xweb/xweb"
+	"log"
 	"net/http"
+	"net/rpc"
+	"rpcfollow"
 	_ "service"
 	"timetask"
 	_ "util"
-
-	"github.com/go-xweb/xweb"
 )
 
 func main() {
+
+	go func() {
+		frpc := new(rpcfollow.JyPayRpc)
+		rpc.Register(frpc)
+		rpc.HandleHTTP()
+
+		err := http.ListenAndServe(":"+Config.Webrpcport, nil)
+		if err != nil {
+			log.Println("ListenAndServe: ", err)
+		}
+	}()
+
 	go timetask.Run()
 	mux1 := http.NewServeMux()
 	xweb.RunBase(":"+Config.Webport, mux1)

+ 27 - 15
src/jfw/modules/subscribepay/src/rpc/rpc.go → src/jfw/modules/subscribepay/src/rpcfollow/rpc.go

@@ -1,13 +1,25 @@
-package rpc
+package rpcfollow
+
+import (
+	"config"
+	"entity"
+	qutil "qfw/util"
+	"util"
+	"time"
+	"log"
+	"fmt"
+	frpc "qfw/util/rpc"
+)
+
+type JyPayRpc struct{}
 
-/*
 //数据导出线下支付完成调用
-func (c *MyfollowRpc) DateExportOrderFinishByOffline(param *frpc.DateExportData, ret *string) error {
+func (c *JyPayRpc) DateExportOrderFinishByOffline(param *frpc.DateExportData, ret *string) error {
 	log.Println("DateExportOrderFinishByOffline---", param)
-	util.Try(func() {
+	qutil.Try(func() {
 		*ret = "1"
 		//查询订单
-		orderdata := public.Mysql.FindOne("dataexport_order", map[string]interface{}{
+		orderdata := util.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", "")
 
@@ -15,15 +27,15 @@ func (c *MyfollowRpc) DateExportOrderFinishByOffline(param *frpc.DateExportData,
 			*ret = "order_nofind"
 			return
 		}
-		if util.Int64All((*orderdata)["order_status"]) != 0 {
+		if qutil.Int64All((*orderdata)["order_status"]) != 0 {
 			*ret = "order_errStat"
 			return
 		}
 		//插入数据
 		now := time.Now()
-		pay_time := util.FormatDate(&now, util.Date_Full_Layout)
+		pay_time := qutil.FormatDate(&now, qutil.Date_Full_Layout)
 
-		insertNum := public.Mysql.Insert("offline_pay", map[string]interface{}{
+		insertNum := util.Mysql.Insert("offline_pay", map[string]interface{}{
 			"out_trade_no": (*orderdata)["out_trade_no"],
 			"create_time":  pay_time,
 			"img_src":      param.ImgSrc,
@@ -33,9 +45,9 @@ func (c *MyfollowRpc) DateExportOrderFinishByOffline(param *frpc.DateExportData,
 			return
 		}
 		//修改订单状态
-		filename := fmt.Sprintf("%s.xlsx", fmt.Sprintf("%s_%s_%s", time.Now().Format("20060102150405"), util.ObjToString((*orderdata)["order_code"]), util.GetLetterRandom(5)))
+		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)
-		updateNum := public.Mysql.Update("dataexport_order", map[string]interface{}{
+		updateNum := util.Mysql.Update("dataexport_order", map[string]interface{}{
 			"order_code": param.OrderCode,
 		}, map[string]interface{}{
 			"pay_time":     pay_time,
@@ -48,11 +60,11 @@ func (c *MyfollowRpc) DateExportOrderFinishByOffline(param *frpc.DateExportData,
 			return
 		}
 		*ret = "y"
-		order_money := util.IntAll((*orderdata)["order_money"])
+		order_money := qutil.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)
+		go entity.SendNotice(orderdata, ordermoney, pay_time, download_url, config.GmailAuth)
+		go entity.SendMailToPayUser(orderdata, ordermoney, pay_time, filename, download_url, config.GmailAuth)
+		go entity.SendMailToBJFinance(orderdata, pay_time, "", 1, config.GmailAuth)
 	}, func(e interface{}) {})
 	return nil
-}*/
+}

+ 1 - 1
src/jfw/modules/subscribepay/src/service/orderListDetails.go

@@ -302,7 +302,7 @@ func (o *OrderListDetails) SetEmail() {
 					o.SetSession("CreatEVerifyTime", time.Now().Unix())
 					log.Println("==========", verifyStr, "================", o.GetSession("CreatEVerifyTime"), "==============")
 					//发送邮箱验证码
-					go util.SendMailIdentCode(email, verifyStr, config.GmailAuth)
+					go entity.SendMailIdentCode(email, verifyStr, config.GmailAuth)
 					o.T["success"] = true
 				} else {
 					o.T["success"] = false

+ 0 - 176
src/jfw/modules/subscribepay/src/service/trial.go

@@ -1,176 +0,0 @@
-package service
-
-import (
-	"log"
-	qutil "qfw/util"
-	"regexp"
-	"time"
-	"util"
-
-	"github.com/go-xweb/httpsession"
-
-	"github.com/dchest/captcha"
-	"github.com/go-xweb/xweb"
-	"gopkg.in/mgo.v2/bson"
-)
-
-//试用用户接口
-type Trial struct {
-	*xweb.Action
-	getUserPhone     xweb.Mapper `xweb:"/trial/GetUserPhone"`     //获取用户手机号码
-	captcha          xweb.Mapper `xweb:"/trial/captcha"`          //图形验证码
-	sendPhoneCaptcha xweb.Mapper `xweb:"/trial/sendPhoneCaptcha"` //发送手机验证码
-	submitApply      xweb.Mapper `xweb:"/trial/submitApply"`      //提交申请信息
-}
-
-var (
-	phoneReg = regexp.MustCompile("^[1][3-9][0-9]{9}$")
-	nameReg  = regexp.MustCompile("^[\u4E00-\u9FA5A-Za-z\\s]+(·[\u4E00-\u9FA5A-Za-z]+)*$")
-)
-
-//获取之前用户信息
-func (t *Trial) GetUserPhone() {
-	var phoneNum string
-	userId := qutil.ObjToString(t.GetSession("userId"))
-	if userId != "" {
-		m, ok := util.MQFW.FindById("user", userId, `{"s_phone":1}`)
-		if ok && len(*m) > 0 {
-			phoneNum = qutil.ObjToString((*m)["s_phone"])
-		}
-	}
-	if phoneNum == "" {
-		openid := qutil.ObjToString(t.GetSession("s_m_openid"))
-		if openid != "" {
-			m, ok := util.MQFW.FindOneByField("applysub_user", bson.M{"s_openid": openid}, `{"s_phone":1}`)
-			if ok && len(*m) > 0 {
-				phoneNum = qutil.ObjToString((*m)["s_phone"])
-			}
-		}
-	}
-	t.ServeJson(map[string]interface{}{
-		"success":  qutil.If(phoneNum == "", false, true).(bool),
-		"phoneNum": phoneNum,
-	})
-}
-
-//试用用户图片验证码
-func (t *Trial) Captcha() error {
-	id := captcha.NewLen(4)
-	t.SetSession("subvip_trial_imgCode", id)
-	w := t.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")
-	return captcha.WriteImage(w, id, 90, 30)
-}
-
-//发送手机验证码
-func (t *Trial) SendPhoneCaptcha() {
-	phoneNum := t.GetString("phoneNum")
-	imgcode_req := t.GetString("imgCancode")
-	ok, errMsg := func() (bool, string) {
-		if !phoneReg.MatchString(phoneNum) {
-			return false, "手机格式不正确"
-		}
-		imgcode_sess := qutil.ObjToString(t.GetSession("subvip_trial_imgCode"))
-		if !captcha.VerifyString(imgcode_sess, imgcode_req) || imgcode_req == "" {
-			return false, "验证码不正确"
-		}
-		//获取上次发送验证码时间
-		lastSend := qutil.Int64All(t.GetSession("subvip_trial_lastSend"))
-		if time.Now().Unix()-lastSend < 60 {
-			return false, "信息已发送"
-		}
-		//判断手机号是否存在
-		if isExist(phoneNum) {
-			return false, "手机号已使用"
-		}
-		MsgCode := qutil.GetRandom(6)
-		t.SetSession("subvip_trial_MsgCode", MsgCode)
-		t.SetSession("subvip_trial_phoneNum", phoneNum)
-		t.SetSession("subvip_trial_lastSend", time.Now().Unix())
-		log.Printf("%s 发送短信验证码 %s\n", t.GetSession("userId"), MsgCode)
-		go func() {
-			util.SendSMS("2828060", phoneNum, map[string]string{"code": MsgCode})
-		}()
-		return true, ""
-	}()
-	t.ServeJson(map[string]interface{}{
-		"success": ok,
-		"errMsg":  errMsg,
-	})
-}
-
-//提交申请信息
-func (t *Trial) SubmitApply() {
-	name := t.GetString("name")
-	tel := t.GetString("tel")
-	code := t.GetString("code")
-	company := t.GetString("company")
-	job := t.GetString("job")
-	ok, errMsg := func() (bool, string) {
-		//校验数据
-		if !nameReg.MatchString(name) || code == "" || company == "" {
-			return false, "输入校验不通过"
-		}
-		//校验验证码
-		lastSend := qutil.Int64All(t.GetSession("subvip_trial_lastSend"))
-		if time.Now().Unix()-lastSend > 60*5 {
-			return false, "短信验证码已过期"
-		}
-		code_sess := qutil.ObjToString(t.GetSession("subvip_trial_MsgCode"))
-		tel_sess := qutil.ObjToString(t.GetSession("subvip_trial_phoneNum"))
-		if code != code_sess || tel != tel_sess {
-			log.Println(code, code_sess, tel, tel_sess)
-			return false, "短信验证码错误"
-		}
-		if isExist(tel_sess) {
-			return false, "手机号已使用"
-		}
-		//储存数据
-		userId := qutil.ObjToString(t.GetSession("userId"))
-		flag := util.MQFW.Save("user_msg", map[string]interface{}{
-			"s_userId":  userId,
-			"s_name":    name,
-			"s_phone":   tel,
-			"s_openid":  t.GetSession("s_m_openid"),
-			"s_company": company,
-			"s_job":     job,
-			"i_time":    time.Now().Unix(),
-			"s_source":  "vipsub_trial",
-		})
-		if flag == "" {
-			return false, "稍后重试"
-		}
-		go func() {
-			//更新user表可试用
-			if !util.MQFW.UpdateById("user", userId, bson.M{"$set": bson.M{"o_vipjy.i_trial": 1}}) {
-				log.Println("更新使用状态出错", userId)
-			}
-		}()
-		clearTrialSession(t.Session())
-		return true, ""
-	}()
-	t.ServeJson(map[string]interface{}{
-		"success": ok,
-		"errMsg":  errMsg,
-	})
-}
-
-//查询手机号是否存在
-func isExist(phone string) bool {
-	res, ok := util.MQFW.FindOne("user_msg", bson.M{"s_phone": phone})
-	if ok && len(*res) > 0 {
-		return true
-	}
-	return false
-}
-
-//清除session
-func clearTrialSession(session *httpsession.Session) {
-	session.Del("subvip_trial_MsgCode")
-	session.Del("subvip_trial_phoneNum")
-	session.Del("subvip_trial_lastSend")
-	session.Del("subvip_trial_imgCode")
-}

+ 5 - 5
src/jfw/modules/subscribepay/src/service/vipSubscribePay.go

@@ -17,20 +17,20 @@ import (
 	"github.com/go-xweb/xweb"
 )
 
-//订单结构
-type Order struct {
+//vip订阅付费
+type SubVipPayOrder struct {
 	*xweb.Action
 	createOrder xweb.Mapper `xweb:"/jypay/vipsubscribe/createOrder"` //创建订单并支付
 	orderToPay  xweb.Mapper `xweb:"/jypay/vipsubscribe/orderToPay"`  //支付已创建订单
 }
 
 func init() {
-	xweb.AddAction(&Order{})
+	xweb.AddAction(&SubVipPayOrder{})
 }
 
 
 //创建订单返回支付串
-func (this *Order) CreateOrder() {
+func (this *SubVipPayOrder) CreateOrder() {
 	area := qutil.ObjToMap(this.GetString("area"))
 	industry := strings.Split(this.GetString("industry"), ",")
 	date := this.GetString("time")
@@ -121,7 +121,7 @@ func (this *Order) CreateOrder() {
 }
 
 //支付已创建订单
-func (this *Order) OrderToPay() {
+func (this *SubVipPayOrder) OrderToPay() {
 	orderCode := qutil.ObjToString(this.GetString("orderCode"))
 	userId := qutil.ObjToString(this.GetSession("userId"))
 	r := func() *entity.FuncResult {

+ 161 - 3
src/jfw/modules/subscribepay/src/service/vipSubscribeTrial.go

@@ -4,7 +4,11 @@ import (
 	"encoding/json"
 	"entity"
 	"errors"
+	"github.com/dchest/captcha"
+	"github.com/go-xweb/httpsession"
+	"gopkg.in/mgo.v2/bson"
 	"pay"
+	"regexp"
 
 	"log"
 
@@ -17,11 +21,166 @@ import (
 	"github.com/go-xweb/xweb"
 )
 
-//订单结构
+//试用用户
 type TrialOrder struct {
 	*xweb.Action
-	getTrialOrderPayMsg xweb.Mapper `xweb:"/order/getTrialOrderPayMsg"` //订单数据展示(支付成功页面)
+	getUserPhone        xweb.Mapper `xweb:"/trial/GetUserPhone"`        //获取用户手机号码
+	captcha             xweb.Mapper `xweb:"/trial/captcha"`             //图形验证码
+	sendPhoneCaptcha    xweb.Mapper `xweb:"/trial/sendPhoneCaptcha"`    //发送手机验证码
+	submitApply         xweb.Mapper `xweb:"/trial/submitApply"`         //提交申请信息
 	trialPay            xweb.Mapper `xweb:"/order/trialPay"`            //试用用户创建订单
+	getTrialOrderPayMsg xweb.Mapper `xweb:"/order/getTrialOrderPayMsg"` //订单数据展示(支付成功页面)
+}
+
+var (
+	phoneReg = regexp.MustCompile("^[1][3-9][0-9]{9}$")
+	nameReg  = regexp.MustCompile("^[\u4E00-\u9FA5A-Za-z\\s]+(·[\u4E00-\u9FA5A-Za-z]+)*$")
+)
+//获取之前用户信息
+func (t *TrialOrder) GetUserPhone() {
+	var phoneNum string
+	userId := qutil.ObjToString(t.GetSession("userId"))
+	if userId != "" {
+		m, ok := util.MQFW.FindById("user", userId, `{"s_phone":1}`)
+		if ok && len(*m) > 0 {
+			phoneNum = qutil.ObjToString((*m)["s_phone"])
+		}
+	}
+	if phoneNum == "" {
+		openid := qutil.ObjToString(t.GetSession("s_m_openid"))
+		if openid != "" {
+			m, ok := util.MQFW.FindOneByField("applysub_user", bson.M{"s_openid": openid}, `{"s_phone":1}`)
+			if ok && len(*m) > 0 {
+				phoneNum = qutil.ObjToString((*m)["s_phone"])
+			}
+		}
+	}
+	t.ServeJson(map[string]interface{}{
+		"success":  qutil.If(phoneNum == "", false, true).(bool),
+		"phoneNum": phoneNum,
+	})
+}
+
+//试用用户图片验证码
+func (t *TrialOrder) Captcha() error {
+	id := captcha.NewLen(4)
+	t.SetSession("subvip_trial_imgCode", id)
+	w := t.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")
+	return captcha.WriteImage(w, id, 90, 30)
+}
+
+//发送手机验证码
+func (t *TrialOrder) SendPhoneCaptcha() {
+	phoneNum := t.GetString("phoneNum")
+	imgcode_req := t.GetString("imgCancode")
+	ok, errMsg := func() (bool, string) {
+		if !phoneReg.MatchString(phoneNum) {
+			return false, "手机格式不正确"
+		}
+		imgcode_sess := qutil.ObjToString(t.GetSession("subvip_trial_imgCode"))
+		if !captcha.VerifyString(imgcode_sess, imgcode_req) || imgcode_req == "" {
+			return false, "验证码不正确"
+		}
+		//获取上次发送验证码时间
+		lastSend := qutil.Int64All(t.GetSession("subvip_trial_lastSend"))
+		if time.Now().Unix()-lastSend < 60 {
+			return false, "信息已发送"
+		}
+		//判断手机号是否存在
+		if isExist(phoneNum) {
+			return false, "手机号已使用"
+		}
+		MsgCode := qutil.GetRandom(6)
+		t.SetSession("subvip_trial_MsgCode", MsgCode)
+		t.SetSession("subvip_trial_phoneNum", phoneNum)
+		t.SetSession("subvip_trial_lastSend", time.Now().Unix())
+		log.Printf("%s 发送短信验证码 %s\n", t.GetSession("userId"), MsgCode)
+		go func() {
+			util.SendSMS("2828060", phoneNum, map[string]string{"code": MsgCode})
+		}()
+		return true, ""
+	}()
+	t.ServeJson(map[string]interface{}{
+		"success": ok,
+		"errMsg":  errMsg,
+	})
+}
+
+//提交申请信息
+func (t *TrialOrder) SubmitApply() {
+	name := t.GetString("name")
+	tel := t.GetString("tel")
+	code := t.GetString("code")
+	company := t.GetString("company")
+	job := t.GetString("job")
+	ok, errMsg := func() (bool, string) {
+		//校验数据
+		if !nameReg.MatchString(name) || code == "" || company == "" {
+			return false, "输入校验不通过"
+		}
+		//校验验证码
+		lastSend := qutil.Int64All(t.GetSession("subvip_trial_lastSend"))
+		if time.Now().Unix()-lastSend > 60*5 {
+			return false, "短信验证码已过期"
+		}
+		code_sess := qutil.ObjToString(t.GetSession("subvip_trial_MsgCode"))
+		tel_sess := qutil.ObjToString(t.GetSession("subvip_trial_phoneNum"))
+		if code != code_sess || tel != tel_sess {
+			log.Println(code, code_sess, tel, tel_sess)
+			return false, "短信验证码错误"
+		}
+		if isExist(tel_sess) {
+			return false, "手机号已使用"
+		}
+		//储存数据
+		userId := qutil.ObjToString(t.GetSession("userId"))
+		flag := util.MQFW.Save("user_msg", map[string]interface{}{
+			"s_userId":  userId,
+			"s_name":    name,
+			"s_phone":   tel,
+			"s_openid":  t.GetSession("s_m_openid"),
+			"s_company": company,
+			"s_job":     job,
+			"i_time":    time.Now().Unix(),
+			"s_source":  "vipsub_trial",
+		})
+		if flag == "" {
+			return false, "稍后重试"
+		}
+		go func() {
+			//更新user表可试用
+			if !util.MQFW.UpdateById("user", userId, bson.M{"$set": bson.M{"o_vipjy.i_trial": 1}}) {
+				log.Println("更新使用状态出错", userId)
+			}
+		}()
+		clearTrialSession(t.Session())
+		return true, ""
+	}()
+	t.ServeJson(map[string]interface{}{
+		"success": ok,
+		"errMsg":  errMsg,
+	})
+}
+
+//查询手机号是否存在
+func isExist(phone string) bool {
+	res, ok := util.MQFW.FindOne("user_msg", bson.M{"s_phone": phone})
+	if ok && len(*res) > 0 {
+		return true
+	}
+	return false
+}
+
+//清除session
+func clearTrialSession(session *httpsession.Session) {
+	session.Del("subvip_trial_MsgCode")
+	session.Del("subvip_trial_phoneNum")
+	session.Del("subvip_trial_lastSend")
+	session.Del("subvip_trial_imgCode")
 }
 
 //订单数据展示(支付成功页面)
@@ -60,7 +219,6 @@ func (this *TrialOrder) TrialPay() {
 		if len(industry) == 1 { //去掉[""]
 			industry = []string{}
 		}
-		log.Println(area, industry)
 		//插入订单表
 		mog_id := util.MQFW.Save("subvip_select", map[string]interface{}{
 			"o_area":       area,     //地区(对象)

BIN
src/jfw/modules/subscribepay/src/web/staticres/res/dataexport/20191102164927_144238100357_zxkMq.xlsx


+ 1 - 0
src/jfw/modules/subscribepay/src/web/staticres/res/dataexport/a.txt

@@ -0,0 +1 @@
+asdasd

+ 1 - 1
src/jfw/rpcfollow/rpc.go

@@ -1,4 +1,4 @@
-// rpc
+// rpcfollow
 package rpcfollow
 
 import (

+ 12 - 7
src/web/staticres/vipsubscribe/css/choose_area.css

@@ -63,11 +63,13 @@
 }
 
 .tips_btn {
-  display: flex;
-  position: relative;
-  flex-direction: column;
-  align-items: center;
-  justify-content: space-between;
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    justify-content: space-between;
+    position: fixed;
+    width: 100%;
+    bottom: 0;
 }
 
 .tips_btn .tips_discount {
@@ -406,10 +408,13 @@
 }
 
 #choose_area .result {
-  position: relative;
+  position: fixed;
   padding: .2rem .3rem;
   font-size: .26rem;
   text-align: justify;
+  width:100%;
+  background:rgba(245,244,249,1);
+  z-index:999;
 }
 
 #choose_area .result .result_text {
@@ -452,7 +457,7 @@
 }
 
 #choose_area .select-area-box {
-  padding-bottom: .94rem;
+  padding-bottom: 1.44rem;
 }
 
 #choose_area .select-area-box .tab {

+ 9 - 3
src/web/staticres/vipsubscribe/css/choose_industry.css

@@ -64,10 +64,12 @@
 
 .tips_btn {
   display: flex;
-  position: relative;
+  position: fixed;
+  bottom: 0;
   flex-direction: column;
   align-items: center;
   justify-content: space-between;
+  width: 100%;
 }
 
 .tips_btn .tips_discount {
@@ -402,6 +404,10 @@
 
 .choose_industry .result {
   padding: .2rem .3rem;
+  background:rgba(245,244,249,1);
+  z-index:999;
+  position: fixed;
+  width:100%;	 
 }
 
 .choose_industry .form {
@@ -410,7 +416,7 @@
 }
 
 .choose_industry .slide {
-  position: absolute;
+  position: fixed;
   top: 50%;
   right: 0;
   display: flex;
@@ -425,7 +431,7 @@
 }
 
 .choose_industry .select-area-box {
-  padding-bottom: .94rem;
+  padding-bottom: 1.44rem;
   background-color: #fff;
   min-height: 100%;
 }

+ 8 - 0
src/web/staticres/vipsubscribe/css/trial_info.css

@@ -2,6 +2,7 @@
   width: 100%;
   height: 100%;
   overflow: hidden;
+  padding-bottom: .94rem;
 }
 
 .trial_info .form {
@@ -178,3 +179,10 @@
 .custom-toast .weui-toast__content {
   margin: 0;
 }
+
+.trial_info .trial_btn{
+	position: fixed;
+	bottom: 0;
+	width: 100%;
+	background: #fff;
+}

+ 6 - 4
src/web/staticres/vipsubscribe/css/vip_introduce.css

@@ -34,6 +34,7 @@
   display: flex;
   flex-direction: column;
   justify-content: space-between;
+  margin-bottom: .94rem;
 }
 
 .vip_introduce .main {
@@ -168,10 +169,11 @@
 }
 
 .vip_introduce .menu {
-  position: relative;
-  width: 100%;
-  height: .94rem;
-  line-height: .94rem;
+   position: fixed;
+   width: 100%;
+   height: .94rem;
+   bottom: 0;
+   line-height: .94rem;
 }
 
 .vip_introduce .menu:after {

+ 2 - 0
src/web/staticres/vipsubscribe/css/vip_pay_success.css

@@ -26,6 +26,8 @@
   align-items: center;
   width: 100%;
   height: .94rem;
+  position: fixed;
+  bottom: 0;
 }
 
 .bottom_button .left_btn,

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

@@ -417,6 +417,7 @@
   height: 100%;
   flex-direction: column;
   justify-content: space-between;
+  padding-bottom: 2.5rem;
 }
 
 .vip_purchase .choose_condition::-webkit-scrollbar {
@@ -559,7 +560,10 @@
 }
 
 .vip_purchase .fixed-bottom-box {
+  width: 100%;	
   background-color: #fff;
+  position: fixed;
+  bottom: 0;
 }
 
 .vip_purchase .fixed-bottom-box .price {

+ 3 - 0
src/web/templates/weixin/vipsubscribe/choose_area.html

@@ -592,6 +592,7 @@
           let pHeight = $('.result_text').height()
           let minHeight = $('.result_text').css('min-height')
           let rows = Math.round(Math.round(pHeight)/ parseFloat(minHeight));
+          $(".select-area-box .area-list").css("margin-top",$('.result_text').height()+20);
           console.log("高度:"+ pHeight,"最小高度"+ minHeight,"行数:" + rows)
           if(rows == 1){
               $('.packup').hide()
@@ -618,12 +619,14 @@
                 $(".result").css("padding-bottom","0.3rem")
                 $(this).hide();
                 $('.packup').show()
+                $(".select-area-box .area-list").css("margin-top",$('.result_text').height()+20);
             })
             $('.packup').click(function () { 
                 $(".result").css("padding-bottom","0.2rem")
                 $('.result_text').addClass('line_two')
                 $(this).hide();
                 $('.detail').show()
+                $(".select-area-box .area-list").css("margin-top",$('.result_text').height()+20);
             })
             $("body").on('click','.slide a',function(){
                 var s = $(this).html()

+ 2 - 0
src/web/templates/weixin/vipsubscribe/choose_industry.html

@@ -300,6 +300,8 @@
                     // 除全部行业外所有按钮都被选中了
                     $('#all button').trigger('click');
                 }
+                //调整高度
+                $(".select-area-box .list").css("margin-top",$(".result").height()+20);
             }
                       
             function showSelect(arr,canclick){

+ 1 - 1
src/web/templates/weixin/vipsubscribe/modal.html

@@ -8,7 +8,7 @@ $(function(){
 	})
 	$(".toast_but").on("click",function(){
 		$("#myModal").modal("hide");
-        window.location.href="/front/vipsubscribe/tailInfo"
+        window.location.href="/front/vipsubscribe/trialInfo"
 	})
 })
 </script>

+ 1 - 1
src/web/templates/weixin/vipsubscribe/trial_info.html

@@ -67,7 +67,7 @@
                 <!-- 未完善个人信息展示的按钮 type类型为submit-->
                 <button class="btn" disabled type="submit">申请免费试用</button>
                 <!-- 已完善过个人信息 展示的按钮 type类型为button -->
-                <button type="button" style="display: none;" onclick="window.location.href='./vip_purchase.html'">申请免费试用</button>
+                <button type="button" style="display: none;" onclick="window.location.href='/front/vipsubscribe/introducePage'">申请免费试用</button>
             </div>
             
         </form>

+ 1 - 1
src/web/templates/weixin/vipsubscribe/vip_introduce.html

@@ -133,7 +133,7 @@
                 </div>
         </div>
         <div class="menu">
-            <a href="/front/vipsubscribe/trialInfo" class="try_btn">试用7天</a>
+            <a href="/front/vipsubscribe/toPurchasePage/trial" class="try_btn">试用7天</a>
             <a href="/front/vipsubscribe/toPurchasePage/new" class="subscribe_btn">去订阅</a>
         </div>
     </div>

+ 27 - 23
src/web/templates/weixin/vipsubscribe/vip_order_detail.html

@@ -106,29 +106,33 @@
 <script src="/vipsubscribe/js/fastclick.js?v={{Msg "seo" "version"}}"></script>
 <script src="/vipsubscribe/js/weui.min.js?v={{Msg "seo" "version"}}"></script>
 <script>
-var signature = {{.T.signature}};
-var isConfigSuccess = true;
-var id = {{.T._id}}
-if(signature && signature.length == 4){
-	wx.config({
-	    debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
-	    appId: signature[0], // 必填,公众号的唯一标识
-	    timestamp:signature[1], // 必填,生成签名的时间戳
-	    nonceStr: signature[2], // 必填,生成签名的随机串
-	    signature: signature[3],// 必填,签名,见附录1
-	    jsApiList: ['chooseWXPay','hideAllNonBaseMenuItem'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
-	});
-	wx.ready(function () {
-		if(!isConfigSuccess){
-			return;
-		}
-		wx.hideAllNonBaseMenuItem();
-    });
-	wx.error(function(res){
-	    //config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
-		//alert(res);
-		isConfigSuccess = false;
-	});
+try{
+  var signature = {{.T.signature}};
+  var isConfigSuccess = true;
+  var id = {{.T._id}}
+  if(signature && signature.length == 4){
+  	wx.config({
+  	    debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
+  	    appId: signature[0], // 必填,公众号的唯一标识
+  	    timestamp:signature[1], // 必填,生成签名的时间戳
+  	    nonceStr: signature[2], // 必填,生成签名的随机串
+  	    signature: signature[3],// 必填,签名,见附录1
+  	    jsApiList: ['chooseWXPay','hideAllNonBaseMenuItem'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
+  	});
+  	wx.ready(function () {
+  		if(!isConfigSuccess){
+  			return;
+  		}
+  		wx.hideAllNonBaseMenuItem();
+      });
+  	wx.error(function(res){
+  	    //config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
+  		//alert(res);
+  		isConfigSuccess = false;
+  	});
+  }
+}catch(e){
+  console.log(e)
 }
 </script>
 <script>

+ 16 - 14
src/web/templates/weixin/vipsubscribe/vip_pay_success.html

@@ -50,26 +50,28 @@
       })
       //设置关键词
       $(".right_btn").on("click",function(){
-        window.location.href ='/front/vipsubscribe/toSetKeyWordPage'
+        window.location.href ='/front/vipsubscribe/toSetPage'
       }) 
       
       var orderCode=decodeURIComponent(getParam("orderCode"));
       $(".orderCode").text(orderCode);
-      $DoPost("/subscribepay/order/getOrderPayMsg",{"orderCode":orderCode},function(r){
+      $DoPost("/subscribepay/orderListDetails/getOrderPayAllMsg",{"orderCode":orderCode},function(r){
         if(r.success){
-          if(r.pay_time){
-            $(".paytime").text(r.pay_time.replace("-","/").replace("-","/"));
-          }
-          if(r.pay_way){
-            var payway
-            if(r.pay_way.indexOf("wx")>-1){
-              payway="微信支付";
-            }else if(r.pay_way.indexOf("ali")>-1){
-              payway="支付宝支付";
-            }else{
-              $(".pay_mode").css("display","none");
+          if(r.data.order.order_status==1){
+            if(r.data.order.pay_time){
+              $(".paytime").text(r.data.order.pay_time.replace("-","/").replace("-","/"));
+            }
+            if(r.data.order.pay_way){
+              var payway
+              if(r.data.order.pay_way.indexOf("wx")>-1){
+                payway="微信支付";
+              }else if(r.data.order.pay_way.indexOf("ali")>-1){
+                payway="支付宝支付";
+              }else{
+                $(".pay_mode").css("display","none");
+              }
+              $(".payway").text(payway);
             }
-            $(".payway").text(payway);
           }
         }
       })

+ 4 - 2
src/web/templates/weixin/vipsubscribe/vip_purchase.html

@@ -14,6 +14,7 @@
 </head>
 
 <body>
+  <div>
     <div class="vip_purchase">
         <div class="choose_condition">
             <ul class="chooseList">
@@ -364,7 +365,7 @@
             }
           }
           
-          if(!$.isEmptyObject(data)){
+          if(!$.isEmptyObject(data)&&!this.areaSelect["一个省"]){
             $(".choose_area").val(provinceArr.join(" ")+" "+cityArr.join(" "));
           }
 
@@ -380,7 +381,7 @@
         },
         showIndustry:function(){
           let data = this.industrySelect;
-          if(data.length>0){
+          if(data.length>0&&data[0]!="一个行业"){
             $(".choose_industry").val(data.join(" "));
           }
           if(this.industrySelect.length>0&&this.industrySelect[0]!="全部行业"&&this.industrySelect[0]!="一个行业"){ //选择有行业信息
@@ -665,6 +666,7 @@
         }
                    
     </script>
+  </div>  
 </body>
 
 </html>