Browse Source

Merge branch 'dev4.4' of ssh://192.168.3.207:10022/qmx/jy into dev4.4

yangfeng 4 years ago
parent
commit
a6c61233fa

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

@@ -46,12 +46,29 @@ type Subscribepay struct {
 
 	//预热活动链接跳转
 	preheatPoster xweb.Mapper `xweb:"/front/preheat/poster"` //预热活动链接跳转
+
+	upgradeDetail xweb.Mapper `xweb:"/front/vipsubscribe/upgradeDetail"` //新超级订阅介绍页
+	upgradePage   xweb.Mapper `xweb:"/front/vipsubscribe/upgradePage"`   //升级页面
+	//超级订阅企业搜索
+	entSearch xweb.Mapper `xweb:"/front/vipsubscribe/entSearch"` //企业搜索
 }
 
 func init() {
 	xweb.AddAction(&Subscribepay{})
 }
 
+func (s *Subscribepay) EntSearch() {
+	s.Render("/weixin/vipsubscribe/vip_entSearch.html")
+}
+
+func (s *Subscribepay) UpgradeDetail() {
+	s.Render("/weixin/vipsubscribe/vip_UpgradeDetail.html")
+}
+
+func (s *Subscribepay) UpgradePage() {
+	s.Render("/weixin/vipsubscribe/vip_UpgradePage.html")
+}
+
 var (
 	liveActiveStartTime = config.ActiveConfig.Live_Active_Start
 	liveActiveEndTime   = config.ActiveConfig.Live_Active_End

+ 11 - 0
src/jfw/modules/app/src/app/front/vipsubscribe.go

@@ -26,6 +26,9 @@ type Subscribepay struct {
 	toSetOtherKwsPage xweb.Mapper `xweb:"/jyapp/vipsubscribe/toSet(.*)Page"`     //订阅收费附加词和排除词设置
 	toVIPViewPage     xweb.Mapper `xweb:"/jyapp/vipsubscribe/toVIPViewPage"`     //订阅收费预览
 
+	upgradeDetail xweb.Mapper `xweb:"/jyapp/vipsubscribe/upgradeDetail"` //新超级订阅介绍页
+	upgradePage   xweb.Mapper `xweb:"/jyapp/vipsubscribe/upgradePage"`   //升级页面
+
 	//修改升级
 	toSetPage        xweb.Mapper `xweb:"/jyapp/vipsubscribe/toSubVipSetPage"`  //订阅收费设置
 	toChangeArea     xweb.Mapper `xweb:"/jyapp/vipsubscribe/toChangeArea"`     //修改区域
@@ -53,6 +56,14 @@ func (s *Subscribepay) EntSearch() {
 	s.Render("/vipsubscribe/vip_entSearch.html")
 }
 
+func (s *Subscribepay) UpgradeDetail() {
+	s.Render("/vipsubscribe/vip_UpgradeDetail.html")
+}
+
+func (s *Subscribepay) UpgradePage() {
+	s.Render("/vipsubscribe/vip_UpgradePage.html")
+}
+
 //推送设置
 func (s *Subscribepay) ToVIPViewPage() {
 	s.Render("/vipsubscribe/vip_viewPage.html")

+ 9 - 0
src/jfw/modules/app/src/web/staticres/jyapp/vipsubscribe/css/vip_renew.css

@@ -697,3 +697,12 @@
 .billing-price-container .yen {
   font-size: .32rem;
 }
+
+.area-industry .item-container .item {
+  justify-content: flex-start;
+}
+.area-industry .item-container .item .item-r {
+  width: unset;
+  flex: 1;
+  justify-content: flex-start;
+}

+ 213 - 0
src/jfw/modules/app/src/web/staticres/jyapp/vipsubscribe/js/vip_entSearch.js

@@ -0,0 +1,213 @@
+var vNode = {
+  delimiters: ['${', '}'],
+  el: '#ent-search',
+  data: {
+      sessStorageKey: '$data-ent_follow',
+      searchEntName: '',
+      conf: {
+          // 我关注的企业最大个数
+          maxLength: 500,
+          showAllInfo: true,
+          powerLoaded: false
+      },
+      listInfo: {
+          // 首次请求是否完成
+          firstLoaded: false,
+          loading: false,
+          finished: false,
+          refreshing: false,
+          pageNum: 0,
+          pageSize: 10,
+          scrollTop: 0
+      },
+      entList: [],
+      entFollowList: []
+  },
+  created: function () {
+      var recover = this.recover()
+      if (!recover) {
+          this.getPowerInfo()
+      }
+  },
+  mounted: function () {
+      $(this.$refs.jList).scrollTop(this.listInfo.scrollTop)
+      // this.adjustAddButtonPadding()
+  },
+  methods: {
+      recover: function () {
+          var excludeKey = ['sessStorageKey']
+          var $data = sessionStorage.getItem(this.sessStorageKey)
+          if ($data) {
+              $data = JSON.parse($data)
+              for (var key in $data) {
+                  if (excludeKey.indexOf(key) !== -1) {
+                      continue
+                  }
+                  this.$data[key] = $data[key]
+              }
+              sessionStorage.removeItem(this.sessStorageKey)
+          }
+          return !!$data
+      },
+      // 获取权限信息
+      getPowerInfo: function () {
+          var _this = this
+          $.ajax({
+              type: 'GET',
+              url: '/bigmember/use/isAdd',
+              success: function (res) {
+                  if (res.error_code == 0) {
+                      _this.conf.powerLoaded = true
+                      // if (res.data && res.data.memberStatus > 0) {
+                      //     _this.conf.showAllInfo = true
+                      // }
+                  } else {
+                      _this.$toast(res.error_msg)
+                  }
+              },
+              error: function (error) {
+                  console.log(error)
+              }
+          })
+      },
+      // 搜索联想
+      searchEnt: utils.debounce(function () {
+        var _this = this
+        var searchEntName = this.searchEntName.replace(/\s+/g, '')
+
+        if (!searchEntName) {
+          this.entList = []
+          return
+        }
+        $.ajax({
+            type: 'POST',
+            url: '/bigmember/follow/ent/association',
+            data: {
+                entName: searchEntName
+            },
+            success: function (res) {
+                if (res.error_code == 0) {
+                    if (res.data) {
+                        _this.entList = res.data
+                        // for (var index in res.data) {
+                        //     var item = res.data[index]
+                        //     _this.entList.push({
+                        //         entId: item.entId,
+                        //         entName: item.entName,
+                        //         follow: !!item.isFollow
+                        //     })
+                        // }
+                    }
+                } else {
+                    _this.$toast(res.error_msg)
+                }
+            },
+            error: function (error) {
+                console.log(error)
+                _this.$toast('请求失败')
+            }
+        })
+      }, 600),
+      // 关键字高亮
+      highlightText: function (str) {
+        return utils.replaceKeyword(str, this.searchEntName, '<span class="highlight-text">' + this.searchEntName + '</span>')
+      },
+      getEntFollowList: function () {
+          var _this = this
+          $.ajax({
+              type: 'POST',
+              url: '/bigmember/entinfo/bynames?t=' + new Date().getTime(),
+              data: {
+                  pageNum: _this.listInfo.pageNum,
+                  pageSize: _this.listInfo.pageSize,
+              },
+              success: function (res) {
+                  if (_this.listInfo.pageNum === 0) {
+                      _this.listInfo.firstLoaded = true
+                      _this.entFollowList = []
+                  }
+                  if (res && res.length > 0) {
+                    // 判断是否为刷新
+                    if (_this.listInfo.refreshing) {
+                        _this.entFollowList = []
+                        _this.listInfo.refreshing = false
+                    }
+
+                    // 加载状态结束
+                    _this.listInfo.loading = false
+                    // if (res.data.followMax) {
+                    //     _this.conf.maxLength = res.data.followMax
+                    // }
+
+                    // 列表赋值
+                    _this.entFollowList = _this.entFollowList.concat(res)
+                    _this.listInfo.finished = true
+                  }
+              },
+              error: function (error) {
+                  console.log(error)
+              }
+          })
+      },
+      onRefresh: function () {
+          // 重置数据
+          this.listInfo.pageNum = 0
+          // 解除加载完成状态
+          this.listInfo.finished = false
+          // 重新加载数据
+          // 将 loading 设置为 true,表示处于加载状态
+          this.listInfo.loading = true
+          // 请求数据
+          this.getEntFollowList()
+      },
+      connectEnt: function (phone) {
+          try {
+              JyObj.callPhone(phone)
+          } catch (error) {
+              console.log(error)
+          }
+      },
+      leavePage: function (item) {
+        console.log(item)
+          var scrollTop = $(this.$refs.jList).scrollTop()
+          // 如果滚动高度为0,或者entList长度为0,则不缓存数据(即返回刷新)
+          if (scrollTop == 0 || this.entFollowList.length === 0) {
+              // do something
+          } else {
+              this.listInfo.scrollTop = $(this.$refs.jList).scrollTop()
+              sessionStorage.setItem(this.sessStorageKey, JSON.stringify(this.$data))
+          }
+          location.href = './ent_portrait?eId=' + encodeURIComponent(item.entId)
+
+      },
+      formatArea: function (item) {
+          var s = []
+          if (item.company_area) {
+              s.push(item.company_area)
+          }
+          if (item.company_city) {
+              s.push(item.company_city)
+          }
+          if (s.length === 0) {
+              return '-'
+          } else {
+              return s.join(' ')
+          }
+      },
+      toEntDetail: function (item) {
+        sessionStorage.setItem(this.sessStorageKey, JSON.stringify(this.$data))
+        location.href = './ent_portrait?eId=' + encodeURIComponent(item.entId)
+      },
+      // 调整列表底部到按钮距离
+      // adjustAddButtonPadding: function () {
+      //     var refs = this.$refs
+      //     var keyListUl = $(refs.jList).find('.follow-list')
+      //     if (this.entFollowList.length < this.conf.maxLength) {
+      //         keyListUl.css({
+      //             'padding-bottom': '2.2rem'
+      //         })
+      //     }
+      // },
+  }
+}
+var vueComponent = new Vue(vNode)

+ 6 - 7
src/jfw/modules/app/src/web/staticres/jyapp/vipsubscribe/js/vip_renew.js

@@ -14,7 +14,6 @@ var purchase = {
         //已选择
         try {
             //即将到期 回显已购买
-            console.log(sessionStorage.getItem("pay_read_cache"))
             if (!sessionStorage.getItem("pay_read_cache")) {
                 $DoPost("/subscribepay/vipsubscribe/getSubBuyMsg", {}, function (r) {
                     if (r.success) {
@@ -96,7 +95,7 @@ var purchase = {
     showArea: function () {
         if (!$.isEmptyObject(this.areaSelect) && !this.areaSelect["一个省"]) { //有选择
             if (this.nowBuyset.areacount === -1) {
-                $(".selected-area").text("全国");
+                $(".area .item-r").text("全国");
             } else {
                 var tipTxt = "";
                 if (this.nowBuyset.areacount > 0) tipTxt += this.nowBuyset.areacount + " 个省";
@@ -109,10 +108,10 @@ var purchase = {
                     tipTxt += count + " 个市";
                     if (this.nowBuyset.citys.length > 1) tipTxt += "(分布在" + this.nowBuyset.citys.length + "个省内)"
                 }
-                $(".selected-area").text(tipTxt);
+                $(".area .item-r").text(tipTxt);
             }
         } else {
-            $(".selected-area").text("");
+            $(".area .item-r").text("");
         }
     },
     showPrice: function () {
@@ -133,13 +132,13 @@ var purchase = {
     showIndustry: function () {
         if (this.industrySelect.length > 0 && this.industrySelect[0] !== "一个行业") { //选择有行业信息
             if (this.nowBuyset.buyerclasscount === -1) {
-                $(".selected-industry-count").text("全部行业");
+                $(".industry .item-r").text("全部行业");
             } else {
                 var tipTxt = "";
-                $(".selected-industry-count").text(tipTxt + this.nowBuyset.buyerclasscount + " 个行业");
+                $(".industry .item-r").text(tipTxt + this.nowBuyset.buyerclasscount + " 个行业");
             }
         } else {
-            $(".selected-industry-count").text("");
+            $(".industry .item-r").text("");
         }
     },
     showTime: function () {

+ 58 - 0
src/jfw/modules/app/src/web/templates/vipsubscribe/vip_UpgradeDetail.html

@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html lang="zh-CN">
+
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport"
+          content="width=device-width, initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
+    <meta http-equiv="X-UA-Compatible" content="ie=edge">
+    <title>超级订阅续费</title>
+    <meta name="apple-mobile-web-app-capable" content="yes">
+    <meta name="apple-mobile-web-app-status-bar-style" content="black">
+    <script src='{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/local/rem.js'></script>
+    <link rel="stylesheet" type="text/css" href='{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/local/weui.min.css'/>
+    <link rel="stylesheet" type="text/css" href='{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/vipsubscribe/css/base2.css?v={{Msg "seo" "version"}}'/>
+    <link rel="stylesheet" type="text/css" href='{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/vipsubscribe/iconfont/iconfont.css?v={{Msg "seo" "version"}}'/>
+	<link rel="stylesheet" type="text/css" href='{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/vipsubscribe/css/public_.css?v={{Msg "seo" "version"}}'/>
+    <link rel="stylesheet" type="text/css" href='{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/local/layout.css'/>
+    <link rel="stylesheet" type="text/css" href='{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/css/font.css?v={{Msg "seo" "version"}}'/>
+    <style>
+        .content {
+            height: 100%;
+            display: flex;
+            align-items: center;
+            justify-content: center;
+        }
+    </style>
+</head>
+<body class="no-touch"  data-weui-theme="light">
+<div class="app-layout-header jy-app-header" style="z-index: 8;">
+    <span class="app-back jyapp-icon jyapp-icon-zuojiantou"></span>
+    <span>超级订阅升级</span>
+    <span></span>
+</div>
+<div class="app-layout-content-b">
+	<div class="j-container">
+        <div class="j-body">
+            <div class="content">超级订阅升级版介绍</div>
+        </div>
+        <div class="footer j-button-group">
+            <button class="j-button-confirm">升级</button>
+        </div>
+    </div>
+</div>
+<script src="{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/local/jquery.min.js"></script>
+<script src='{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/vipsubscribe/js/common.js?v={{Msg "seo" "version"}}'></script>
+<script src='{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/js/common.js?v={{Msg "seo" "mod_version"}}'></script>
+{{include "/common/iosJS.html"}}
+<script>
+$(function () {
+    $('.j-button-confirm').on('click', function () {
+        location.href = '/jyapp/vipsubscribe/upgradePage'
+    })
+})
+</script>
+{{include "/common/baiducc.html"}}
+</body>
+
+</html>

+ 172 - 0
src/jfw/modules/app/src/web/templates/vipsubscribe/vip_entSearch.html

@@ -0,0 +1,172 @@
+<!DOCTYPE html>
+<html lang="zh-CN" style="font-size: 50px;">
+<head>
+    <title>企业查询</title>
+
+    <!--引入公共资源头部-->
+    {{include "/big-member/meta.html"}}
+
+    <!--S-当前页必定需要预加载的资源-->
+    <link rel="preload" as="style" href=//cdn.jsdelivr.net/npm/reset-css@4.0.1/reset.min.css />
+    <link rel="preload" as="style" href=//cdn.jsdelivr.net/npm/vant@2.8.2/lib/index.css />
+    <link rel="preload" as="style" href=//cdn.jsdelivr.net/npm/vant@2.8.2/lib/icon/local.css />
+    <!--E-当前页必定需要预加载的资源-->
+
+    <!--S-当前页面的css资源-->
+    <link rel="stylesheet" href=//cdn.jsdelivr.net/npm/reset-css@4.0.1/reset.min.css />
+    <link rel="stylesheet" href=//cdn.jsdelivr.net/npm/vant@2.8.2/lib/index.css />
+    <link rel="stylesheet" href=//cdn.jsdelivr.net/npm/vant@2.8.2/lib/icon/local.css />
+    <link rel="stylesheet" href='{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/big-member/css/ent_follow.css?v={{Msg "seo" "mod_version"}}' />
+    <!--E-当前页面的css资源-->
+</head>
+<style>
+  #ent-search .search-container{
+    position: relative;
+  }
+  #ent-search .ent-list-container{
+    position: absolute;
+    bottom: -50px;
+    z-index: 1;
+    width: 100%;
+    background: #fff;
+  }
+  #ent-search .ent-list{
+    background: #fff;
+  }
+  #ent-search .van-search{
+    width: 100%;
+    padding: 7px 16px;
+  }
+  .van-search__content{
+    width: 100%;
+    height: 40px;
+    background: #f5f6f7;
+    border: 1px solid rgba(0,0,0,0.05);
+    border-radius: 9px;
+  }
+  .van-cell__value {
+    line-height: 28px;
+    font-size: 14px;
+    font-weight: 500;
+    color: #171826;
+  }
+  .van-cell__value::placeholder {
+    line-height: 28px;
+    font-size: 14px;
+    font-weight: 500;
+    color: #9b9ca3;
+  }
+  .ent-list-item {
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+    padding: .28rem .32rem;
+    font-size: .28rem;
+    line-height: .4rem;
+    color: #171826;
+  }
+  .ent-name {
+    flex: 1;
+    word-break: break-all;
+  }
+</style>
+<body>
+<div class="j-container">
+    {{include "/big-member/header.html"}}
+    <div id="ent-search" class="j-main" v-cloak>
+        <div class="j-container search-container" key="list">
+          <div class="j-header">
+            <van-search
+                v-model.trim="searchEntName"
+                placeholder="输入企业名称"
+                @input="searchEnt"
+            >
+                <template #left-icon>
+                    <span class="j-icon base-icon icon-search"></span>
+                </template>
+            </van-search>
+          </div>
+          <div class="j-container ent-list-container" v-if="entList.length !== 0" key="ent-list">
+            <ul class="ent-list">
+              <li
+                class="ent-list-item clickable border-line-b"
+                v-for="(item,index) in entList"
+                :key="index"
+                @click="toEntDetail(item)"
+                >
+                <span class="ent-name" v-html="highlightText(item.entName)"></span>
+              </li>
+            </ul>
+          </div>
+            <div class="j-main" ref="jList">
+                <div>
+                    <van-pull-refresh v-model="listInfo.refreshing" @refresh="onRefresh">
+                        <van-list
+                            v-model="listInfo.loading"
+                            :finished="listInfo.finished"
+                            finished-text=""
+                            @load="getEntFollowList"
+                            class="follow-list"
+                        >
+                            <div
+                                v-for="(item, index) in entFollowList"
+                                class="follow-item"
+                                :immediate-check="false"
+                                @click="leavePage(item)"
+                                :key="index">
+                                <div class="item-hd">
+                                    <span class="left-icons">
+                                        <span class="j-icon icon-company"></span>
+                                        <span class="dot-red" v-show="item.i_apppushunread == 1"></span>
+                                    </span>
+                                    <span class="item-ent-name">${item.entName}</span>
+                                </div>
+                                <div class="item-bd" v-if="conf.showAllInfo">
+                                    <span class="bd-content">
+                                        <span class="bd-c-label">成立日期</span>
+                                        <span class="bd-c-text">${ item.establish_date ? item.establish_date : '-' }</span>
+                                    </span>
+                                    <span class="bd-content">
+                                        <span class="bd-c-label">注册资本</span>
+                                        <span class="bd-c-text">${ item.capital ? item.capital+'万元' : '-' }</span>
+                                    </span>
+                                    <span class="bd-content">
+                                        <span class="bd-c-label">员工人数</span>
+                                        <span class="bd-c-text">${ item.employee_no ? item.employee_no+'人' : '-' }</span>
+                                    </span>
+                                </div>
+                                <div class="item-ft border-line-t" v-if="conf.showAllInfo">
+                                    <span class="ft-location">
+                                        <span class="location-label">企业所在地</span>
+                                        <span class="location-text highlight-text">${ formatArea(item) }</span>
+                                    </span>
+                                    <span class="ft-connect" v-if="item.company_phone" @click.stop="connectEnt(item.company_phone)">
+                                        <span class="j-icon icon-phone"></span>
+                                        <span class="location-r">联系企业</span>
+                                    </span>
+                                </div>
+                            </div>
+                        </van-list>
+                    </van-pull-refresh>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+
+<!--S-必定需要预加载的资源-->
+<script rel="preload" as="script" src=//cdn.jsdelivr.net/npm/vue@2.6.11/dist/vue.min.js></script>
+<script rel="preload" as="script" src=//cdn.jsdelivr.net/npm/vant@2.8.2/lib/vant.min.js></script>
+<script rel="preload" as="script" src=//cdn.jsdelivr.net/npm/zepto@1.2.0/dist/zepto.min.js></script>
+<!--E-必定需要预加载的资源-->
+
+<!--S-当前页面的资源-->
+<script src=//cdn.jsdelivr.net/npm/vue@2.6.11/dist/vue.min.js></script>
+<script src=//cdn.jsdelivr.net/npm/vant@2.8.2/lib/vant.min.js></script>
+<script src=//cdn.jsdelivr.net/npm/zepto@1.2.0/dist/zepto.min.js></script>
+{{include "/big-member/commonjs.html"}}
+<script src='{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/js/common.js?v={{Msg "seo" "version"}}'></script>
+<script src='{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/vipsubscribe/js/vip_entSearch.js?v={{Msg "seo" "mod_version"}}'></script>
+{{include "/common/baiducc.html"}}
+</body>
+</html>

+ 12 - 54
src/jfw/modules/app/src/web/templates/vipsubscribe/vip_renew.html

@@ -39,8 +39,9 @@
 <body class="no-touch"  data-weui-theme="light">
 <div class="app-layout-header jy-app-header" style="z-index: 8;">
     <span class="app-back jyapp-icon jyapp-icon-zuojiantou"></span>
-    超级订阅续费
-<span></span></div>
+    <span>超级订阅续费</span>
+    <span></span>
+</div>
 <div class="app-layout-content-b">
 	{{if not .T.isLiveActive}}
 	<div class="vip-renew">
@@ -54,33 +55,17 @@
         <div class="vip-body">
             <div class="j-notice-bar bar-red vip-bar" style="text-align: center;">限时续费,3个月起,续多久送多久!</div>
             <ul style="padding: .16rem .24rem;">
-                <li class="body-item area">
-                    <a class="item-container" href="/jyapp/vipsubscribe/toChooseArea">
-                        <div class="item">
-                        <span class="item-l">
-                            <span class="item-label">区域</span>
-                        </span>
-                            <span class="item-r">
-                            <span class="selected-area-name ellipsis"></span>
-                            <span class="iconfont icon-arrow"></span>
-                        </span>
+                <li class="body-item area-industry">
+                    <div class="item-container">
+                        <div class="item area">
+                            <span class="item-l">区域:</span>
+                            <span class="item-r"></span>
                         </div>
-                        <div class="sub-item text selected-area"></div>
-                    </a>
-                </li>
-                <li class="body-item industry">
-                    <a class="item-container" href="/jyapp/vipsubscribe/toChooseIndustry">
-                        <div class="item">
-                        <span class="item-l">
-                            <span class="item-label">采购单位行业</span>
-                        </span>
-                            <span class="item-r">
-                            <span class="selected-industry-name industry-text ellipsis"></span>
-                            <span class="iconfont icon-arrow"></span>
-                        </span>
+                        <div class="item industry">
+                            <span class="item-l">行业:</span>
+                            <span class="item-r"></span>
                         </div>
-                        <div class="sub-item text selected-industry-count"></div>
-                    </a>
+                    </div>
                 </li>
                 <li class="body-item select_cycle">
                     <a class="item-container" href="javascript:;">
@@ -103,33 +88,6 @@
                         </div>
                     </a>
                 </li>
-                <!-- <li class="body-item pay-mode">
-                    <a class="item-container" href="javascript:;">
-                        <div class="item">
-                            <span class="item-l">
-                                <span class="leading"></span>
-                                <span class="item-label">支付方式</span>
-                            </span>
-                            <span class="item-r">
-                                <span class="pay-mode-text">微信支付</span>
-                                <span class="iconfont icon-arrow"></span>
-                            </span>
-                        </div>
-                    </a>
-                </li> -->
-                <!--			<li class="body-item coupon-code-tx" style="display: none">-->
-                <!--			    <a class="item-container" href="javascript:;">-->
-                <!--			        <div class="item">-->
-                <!--			            <span class="item-l">-->
-                <!--			                <span class="item-label">优惠码</span>-->
-                <!--			            </span>-->
-                <!--			            <span class="item-r">-->
-                <!--			                <span class="keywords-text">输入优惠码</span>-->
-                <!--			                <span class="iconfont icon-arrow"></span>-->
-                <!--			            </span>-->
-                <!--			        </div>-->
-                <!--			    </a>-->
-                <!--			</li>-->
             </ul>
             <ul style="padding: 0 .24rem;display: none;" id="giveTimeBox">
                 <li class="body-item select_cycle">

+ 2 - 0
src/jfw/modules/bigmember/src/service/use/use.go

@@ -518,6 +518,7 @@ func (u *Use) IsAdd() {
 		d := map[string]interface{}{
 			"isUsed":          false,
 			"memberStatus":    0,
+			"vipStatus":       0,
 			"entname":         "",
 			"isSubCount":      false,
 			"is_member_trial": false,
@@ -537,6 +538,7 @@ func (u *Use) IsAdd() {
 		d["power"] = power
 		d["isUsed"] = bigPower.Used
 		d["memberStatus"] = bigPower.Status
+		d["viper"] = bigPower.Viper
 		d["isSubCount"] = bigPower.Pid != ""
 		d["is_member_trial"] = bigPower.HasTrial
 		uid := userid

+ 23 - 1
src/jfw/modules/common/src/qfw/util/jy/bigVipPower.go

@@ -14,6 +14,7 @@ import (
 //大会员状态redis缓存
 type BigVipBaseMsg struct {
 	Status   int          `json:"status"`    //大会员状态
+	Viper    bool         `json:"viper"`     //超级订阅状态
 	Used     bool         `json:"used"`      //是否首次使用大会员
 	PowerMap map[int]bool `json:"p_map"`     //权限列表
 	ProNum   int          `json:"p_num"`     //可关注项目数量
@@ -82,7 +83,7 @@ func GetBigVipUserBaseMsg(userId string, mysql *mysql.Mysql, mg MongodbSim) *Big
 		}
 	}
 	//大会员状态
-	data, ok := mg.FindById("user", userId, `{"i_member_status":1,"i_member_give":1,"s_member_mainid":1,"i_member_sub_status":1,"i_member_trial":1}`)
+	data, ok := mg.FindById("user", userId, `{"i_member_status":1,"i_member_give":1,"s_member_mainid":1,"i_member_sub_status":1,"i_member_trial":1,"i_vip_status":1,"o_vipjy":1}`)
 
 	if ok && *data != nil && len(*data) > 0 {
 		userPower.Status = qutil.IntAllDef((*data)["i_member_status"], 0)
@@ -97,6 +98,16 @@ func GetBigVipUserBaseMsg(userId string, mysql *mysql.Mysql, mg MongodbSim) *Big
 		if (*data)["i_member_trial"] != nil {
 			userPower.HasTrial = true
 		}
+		if vipStatus := qutil.IntAll((*data)["i_vip_status"]); vipStatus > 0 {
+			if o_vipjy := qutil.ObjToMap((*data)["o_vipjy"]); o_vipjy != nil {
+				if o_buyset := qutil.ObjToMap((*o_vipjy)["o_buyset"]); o_buyset != nil {
+					if qutil.IntAll((*o_buyset)["upgrade"]) == 1 {
+						userPower.Viper = true
+					}
+				}
+			}
+
+		}
 	}
 
 	//子账号查询父节点权限
@@ -121,6 +132,11 @@ func GetBigVipUserBaseMsg(userId string, mysql *mysql.Mysql, mg MongodbSim) *Big
 		userPower.ProNum = pCount
 	}
 
+	//升级版超级订阅查看画像权限
+	if userPower.Viper {
+
+	}
+
 	//存储缓存
 	go func() {
 		if bytes, err := json.Marshal(userPower); err == nil && bytes != nil {
@@ -132,10 +148,16 @@ func GetBigVipUserBaseMsg(userId string, mysql *mysql.Mysql, mg MongodbSim) *Big
 
 //权限判断
 func (this *BigVipBaseMsg) CheckBigVipFrontPower(reqFlag string) (pass bool) {
+	if this.Viper && reqFlag == "ent_portrait" {
+		return true
+	}
 	return this.checkPower(reqFlag, FrontService)
 }
 
 func (this *BigVipBaseMsg) CheckBigVipBackPower(reqFlag string) (pass bool) {
+	if this.Viper && reqFlag == "entPortrait" {
+		return true
+	}
 	return this.checkPower(reqFlag, BackService)
 }
 

+ 1 - 1
src/jfw/modules/subscribepay/src/entity/dataexport.go

@@ -389,7 +389,7 @@ func SendMailToBJFinance(order *map[string]interface{}, pay_time, transaction_id
 					} else {
 						vip_area := vf.Area    //区域
 						vip_ind := vf.Industry //行业
-						nbs := JyVipSubStruct.NewBuySet(&vip_area, vip_ind)
+						nbs := JyVipSubStruct.NewBuySet(&vip_area, vip_ind, qutil.IntAll(vf.NewBuyset["upgrade"]) == 1)
 						if nbs != nil {
 							if nbs.NewCitys != nil {
 								for _, v := range nbs.NewCitys {

+ 248 - 244
src/jfw/modules/subscribepay/src/entity/subscribeVip.go

@@ -9,6 +9,7 @@ import (
 	"log"
 	"pay"
 	qutil "qfw/util"
+	"qfw/util/jy"
 	"qfw/util/redis"
 	"time"
 	"util"
@@ -27,55 +28,68 @@ func init() {
 
 //价格表
 type subVipPrice struct {
-	Month struct {
-		OneCity_oneBuyerClass     int `json:"oneCity_oneBuyerClass"`     //一个城市一个行业
-		OneCity_allBuyerClass     int `json:"oneCity_allBuyerClass"`     //一个城市全部行业
-		OneProvince_oneBuyerClass int `json:"oneProvince_oneBuyerClass"` //一个省份一个行业
-		OneProvince_allBuyerClass int `json:"oneProvince_allBuyerClass"` //一个省份全部行业
-		AllProvince_oneBuyerClass int `json:"allProvince_oneBuyerClass"` //全国一个行业
-		AllProvince_allBuyerClass int `json:"allProvince_allBuyerClass"` //全国全行业
-	} `json:"month"`
-	Year struct {
-		OneCity_oneBuyerClass     int `json:"oneCity_oneBuyerClass"`     //一个城市一个行业
-		OneCity_allBuyerClass     int `json:"oneCity_allBuyerClass"`     //一个城市全部行业
-		OneProvince_oneBuyerClass int `json:"oneProvince_oneBuyerClass"` //一个省份一个行业
-		OneProvince_allBuyerClass int `json:"oneProvince_allBuyerClass"` //一个省份全部行业
-		AllProvince_oneBuyerClass int `json:"allProvince_oneBuyerClass"` //全国一个行业
-		AllProvince_allBuyerClass int `json:"allProvince_allBuyerClass"` //全国全行业
-	} `json:"year"`
-	CityPrice          int     `json:"cityPrice"`          //单个城市价格
-	ProvincePrice      int     `json:"provincePrice"`      //单个省份价格
-	BuyerClassPrice    int     `json:"buyerClassPrice"`    //单个行业价格
-	CityMaxCount       int     `json:"cityMaxCount"`       //单个省份城市可计价最大数量
-	ProvinceMaxCount   int     `json:"provinceMaxCount"`   //所有地区中省份可计价最大数量
-	BuyerClassMaxCount int     `json:"buyerClassMaxCount"` //行业价格可计价最大数量
-	MonthMaxCount      int     `json:"monthMaxCount"`      //月份可计价最大数量
-	Discount           float64 `json:"discount"`           //折扣(测试使用)
+	Old struct {
+		Month struct {
+			OneCity_oneBuyerClass     int `json:"oneCity_oneBuyerClass"`     //一个城市一个行业
+			OneCity_allBuyerClass     int `json:"oneCity_allBuyerClass"`     //一个城市全部行业
+			OneProvince_oneBuyerClass int `json:"oneProvince_oneBuyerClass"` //一个省份一个行业
+			OneProvince_allBuyerClass int `json:"oneProvince_allBuyerClass"` //一个省份全部行业
+			AllProvince_oneBuyerClass int `json:"allProvince_oneBuyerClass"` //全国一个行业
+			AllProvince_allBuyerClass int `json:"allProvince_allBuyerClass"` //全国全行业
+		} `json:"month"`
+		Year struct {
+			OneCity_oneBuyerClass     int `json:"oneCity_oneBuyerClass"`     //一个城市一个行业
+			OneCity_allBuyerClass     int `json:"oneCity_allBuyerClass"`     //一个城市全部行业
+			OneProvince_oneBuyerClass int `json:"oneProvince_oneBuyerClass"` //一个省份一个行业
+			OneProvince_allBuyerClass int `json:"oneProvince_allBuyerClass"` //一个省份全部行业
+			AllProvince_oneBuyerClass int `json:"allProvince_oneBuyerClass"` //全国一个行业
+			AllProvince_allBuyerClass int `json:"allProvince_allBuyerClass"` //全国全行业
+		} `json:"year"`
+		CityPrice          int `json:"cityPrice"`          //单个城市价格
+		ProvincePrice      int `json:"provincePrice"`      //单个省份价格
+		BuyerClassPrice    int `json:"buyerClassPrice"`    //单个行业价格
+		CityMaxCount       int `json:"cityMaxCount"`       //单个省份城市可计价最大数量
+		ProvinceMaxCount   int `json:"provinceMaxCount"`   //所有地区中省份可计价最大数量
+		BuyerClassMaxCount int `json:"buyerClassMaxCount"` //行业价格可计价最大数量
+		MonthMaxCount      int `json:"monthMaxCount"`      //月份可计价最大数量
+	} `json:"old"`
+	New struct {
+		Month struct {
+			OneProvince_allBuyerClass int `json:"oneProvince_allBuyerClass"` //一个省份全部行业
+			AllProvince_allBuyerClass int `json:"allProvince_allBuyerClass"` //全国全行业
+		} `json:"month"`
+		Year struct {
+			OneProvince_allBuyerClass int `json:"oneProvince_allBuyerClass"` //一个省份全部行业
+			AllProvince_allBuyerClass int `json:"allProvince_allBuyerClass"` //全国全行业
+		} `json:"year"`
+		ProvincePrice    int `json:"provincePrice"`    //单个省份价格
+		ProvinceMaxCount int `json:"provinceMaxCount"` //所有地区中省份可计价最大数量
+		MonthMaxCount    int `json:"monthMaxCount"`    //月份可计价最大数量
+	} `json:"new"`
+	Discount float64 `json:"discount"` //折扣(测试使用)
 }
 
 //订单简单信息
 type VipSimpleMsg struct {
-	Area             *map[string]interface{}  `json:"area"`             //选择地区
-	Industry         []string                 `json:"industry"`         //选择行业
-	Cyclecount       int                      `json:"cyclecount"`       //日期数量(订单详情展示使用)
-	Cycleunit        int                      `json:"cycleunit"`        //日期单位(订单详情展示使用)
-	OldBuyset        *SubvipBuySet            `json:"buyset"`           //旧购买详情
-	NewBuyset        *SubvipBuySet            `json:"newBuyset"`        //新购买详情
-	UpgradeSubtotail []map[string]interface{} `json:"upgradeSubtotail"` //升级清单(订单详情计价清单展示使用)
-	OrderType        int                      `json:"ordertype"`        //1,3,5   类型 1:订单 2:续费 3:立即升级 4:下月升级 5:即将到期(可升降级续费)6:升级订单未生效再次升级
-	//Addareacount       []int                    `json:"addareacount"`       //购买区域数量(订单详情展示使用)
-	//Addbuyerclasscount int                      `json:"addbuyerclasscount"` //购买行业数量(订单详情展示使用)
-	DisWord       string `json:"disWord"`                  //分销系统 口令
-	GiveCycle     int    `json:"give_cycle,omitempty"`     //双十一活动赠送周期
-	OriginalPrice int    `json:"original_price,omitempty"` //双十一活动原价价格
+	Area             *map[string]interface{}  `json:"area"`                     //选择地区
+	Industry         []string                 `json:"industry"`                 //选择行业
+	Cyclecount       int                      `json:"cyclecount"`               //日期数量(订单详情展示使用)
+	Cycleunit        int                      `json:"cycleunit"`                //日期单位(订单详情展示使用)
+	OldBuyset        *SubvipBuySet            `json:"buyset"`                   //旧购买详情
+	NewBuyset        *SubvipBuySet            `json:"newBuyset"`                //新购买详情
+	UpgradeSubtotail []map[string]interface{} `json:"upgradeSubtotail"`         //升级清单(订单详情计价清单展示使用)
+	OrderType        int                      `json:"ordertype"`                //1,3,5   类型 1:订单 2:续费 3:立即升级 4:下月升级 5:即将到期(可升降级续费)6:升级订单未生效再次升级
+	DisWord          string                   `json:"disWord"`                  //分销系统 口令
+	GiveCycle        int                      `json:"give_cycle,omitempty"`     //双十一活动赠送周期
+	OriginalPrice    int                      `json:"original_price,omitempty"` //双十一活动原价价格
 }
 
 //购买内容
 type SubvipBuySet struct {
+	Upgrade         int   `json:"upgrade"`         //是否是升级版;1是 其他不是
 	AreaCount       int   `json:"areacount"`       //-1 全国  >0 省份数量
 	NewCitys        []int `json:"newcitys"`        //城市数量(新)
 	BuyerclassCount int   `json:"buyerclasscount"` //行业数
-	//Citys           map[string]interface{} `json:"citys"`           //城市数量(旧)
 }
 
 //支付完成回调
@@ -148,14 +162,13 @@ func (this *vipSubscribeStruct) PayCallBack(param *CallBackParam) bool {
 	flag := false
 	if vmsg.OrderType == 1 { //新订单
 		flag = JyVipSubStruct.StartSubVip(userid, vmsg, startTime, endTime, false)
+	} else if vmsg.OrderType == 2 { //仅续费
+		flag = JyVipSubStruct.RenewSubVip(userid, qutil.ObjToString((*orderdata)["vip_endtime"]))
 	} else if vmsg.OrderType == 3 { //立即升级
 		flag = JyVipSubStruct.UpgradeSubVip(userid, vmsg, qutil.ObjToString((*orderdata)["vip_endtime"]))
 	} else if vmsg.OrderType == 5 { //续费(可升降级)
-		flag = JyVipSubStruct.RenewSubVip(userid, vmsg, qutil.ObjToString((*orderdata)["vip_starttime"]), qutil.ObjToString((*orderdata)["vip_endtime"]))
+		flag = JyVipSubStruct.WillNew(userid, vmsg, qutil.ObjToString((*orderdata)["vip_starttime"]), qutil.ObjToString((*orderdata)["vip_endtime"]))
 	}
-	//else if vmsg.OrderType == 2 { //续费
-	//	flag = JyVipSubStruct.RenewSubVip(userid, qutil.ObjToString((*orderdata)["vip_endtime"]))
-	//}
 	//支付成功后
 	if flag {
 		//支付提醒
@@ -226,12 +239,32 @@ func (this *vipSubscribeStruct) StartSubVip(userId string, vmsg VipSimpleMsg, st
 	go func() {
 		util.MergeKws(userId)                         //初始化vip订阅关键词
 		redis.Del("other", "p1_indexMessage_"+userId) //清除redis中vip状态
+		jy.ClearBigVipUserPower(userId)
 	}()
 	return true
 }
 
-//续费
-func (this *vipSubscribeStruct) RenewSubVip(userId string, vmsg VipSimpleMsg, start, end string) bool {
+//仅续费
+func (this *vipSubscribeStruct) RenewSubVip(userId string, end string) bool {
+	endTime, err := time.ParseInLocation(qutil.Date_Full_Layout, end, time.Local)
+	if err != nil {
+		log.Printf("%s格式化日期出错%s\n", userId, end)
+		return false
+	}
+	set := map[string]interface{}{
+		"l_vip_endtime":    endTime.Unix(),
+		"i_vip_expire_tip": 0,
+	}
+	if !util.MQFW.UpdateById("user", userId,
+		bson.M{"$set": set}) {
+		log.Printf("%s更新结束%d日期出错\n", userId, endTime.Unix())
+		return false
+	}
+	return true
+}
+
+//即将到期续费
+func (this *vipSubscribeStruct) WillNew(userId string, vmsg VipSimpleMsg, start, end string) bool {
 	startTime, err := time.ParseInLocation(qutil.Date_Full_Layout, start, time.Local)
 	endTime, err2 := time.ParseInLocation(qutil.Date_Full_Layout, end, time.Local)
 	if err != nil || err2 != nil {
@@ -287,52 +320,77 @@ func (this *vipSubscribeStruct) UpgradeSubVip(userId string, vmsg VipSimpleMsg,
 		log.Printf("%s vip_upgrade 更新失败\n", userId)
 		return false
 	}
-	value := bson.M{"$set": bson.M{
-		"o_vipjy.o_area":       vmsg.Area,     //设置地区
-		"o_vipjy.a_buyerclass": vmsg.Industry, //设置行业
-		"o_vipjy.o_buyset":     vmsg.NewBuyset,
-		"l_vip_endtime":        endTime.Unix(),
-		"i_vip_expire_tip":     0,
-	}}
-	ok := util.MQFW.UpdateById("user", userId, value)
-	if !ok {
-		log.Printf("%s更新用户出错 %+v\n", userId, value)
+	updata := map[string]interface{}{
+		"o_vipjy.o_buyset": vmsg.NewBuyset,
+		"l_vip_endtime":    endTime.Unix(),
+		"i_vip_expire_tip": 0,
+	}
+	if vmsg.Area != nil {
+		updata["o_vipjy.o_area"] = vmsg.Area //设置地区
+	}
+	if vmsg.Industry != nil {
+		updata["o_vipjy.a_buyerclass"] = vmsg.Industry //设置行业
+	}
+	if ok := util.MQFW.UpdateById("user", userId, map[string]interface{}{
+		"$set": updata,
+	}); !ok {
+		log.Printf("%s更新用户出错 %+v\n", userId, updata)
 		return false
 	} else {
+		go jy.ClearBigVipUserPower(userId)
 		return true
 	}
 }
 
-//根据行业和地区 返回*SubvipBuySet
-func (this *vipSubscribeStruct) NewBuySet(area *map[string]interface{}, industry []string) *SubvipBuySet {
+//超级订阅获取购买项
+func (this *vipSubscribeStruct) NewBuySet(area *map[string]interface{}, industry []string, isUpgrade bool) *SubvipBuySet {
 	buyset := SubvipBuySet{}
-	if len(*area) > 0 {
-		pCount := 0
-		citys := []int{}
-		for _, v := range *area {
-			tmp := v.([]interface{})
-			if len(tmp) == 0 || len(tmp) > SubVipPrice.CityMaxCount { //省份
-				pCount++
-			} else { //城市
-				citys = append(citys, len(tmp))
+	if !isUpgrade {
+		buyset.Upgrade = 0 //升级版超级订阅标识
+		if len(*area) > 0 {
+			pCount := 0
+			citys := []int{}
+			for _, v := range *area {
+				tmp := v.([]interface{})
+				if len(tmp) == 0 || len(tmp) > SubVipPrice.Old.CityMaxCount { //省份
+					pCount++
+				} else { //城市
+					citys = append(citys, len(tmp))
+				}
+			}
+			//省份数量自动转换全国
+			if pCount > SubVipPrice.Old.ProvinceMaxCount {
+				pCount = -1
+				citys = []int{}
 			}
+			buyset.NewCitys = citys   //城市
+			buyset.AreaCount = pCount //地区
+		} else {
+			buyset.AreaCount = -1 //全国
+			buyset.NewCitys = []int{}
 		}
-		//省份数量自动转换全国
-		if pCount > SubVipPrice.ProvinceMaxCount {
-			pCount = -1
-			citys = []int{}
+		//行业数量自动转换全行业
+		buyset.BuyerclassCount = len(industry)
+		if len(industry) > SubVipPrice.Old.BuyerClassMaxCount || len(industry) == 0 {
+			buyset.BuyerclassCount = -1
 		}
-		buyset.NewCitys = citys   //城市
-		buyset.AreaCount = pCount //地区
 	} else {
-		buyset.AreaCount = -1 //全国
-		buyset.NewCitys = []int{}
-	}
-	//行业数量自动转换全行业
-	buyset.BuyerclassCount = len(industry)
-	if len(industry) > SubVipPrice.BuyerClassMaxCount || len(industry) == 0 {
-		buyset.BuyerclassCount = -1
+		buyset.Upgrade = 1 //升级版超级订阅标识
+		if len(*area) > 0 {
+			pCount := len(*area)
+			//省份数量自动转换全国
+			if pCount > SubVipPrice.New.ProvinceMaxCount {
+				pCount = -1
+			}
+			buyset.NewCitys = []int{} //城市,4.4改版不支持购买城市
+			buyset.AreaCount = pCount //地区
+		} else {
+			buyset.AreaCount = -1 //全国
+			buyset.NewCitys = []int{}
+		}
+		buyset.BuyerclassCount = -1 //行业,4.4改版只能购买全行业
 	}
+
 	return &buyset
 }
 
@@ -405,99 +463,24 @@ func (this *vipSubscribeStruct) GetVipDetail(userId string) (*map[string]interfa
 	vipStatus := qutil.IntAll((*mData)["i_vip_status"])
 	tmp := qutil.ObjToMap((*qutil.ObjToMap((*mData)["o_vipjy"]))["o_buyset"])
 
-	//转换
-	areacount := qutil.IntAll((*tmp)["areacount"])
-	buyerclasscount := qutil.IntAll((*tmp)["buyerclasscount"])
 	newCity, ok := (*tmp)["newcitys"].([]interface{})
-	if !ok && (*tmp)["citys"] != nil { //旧程序
-		return mData, subvipBuySetFulsh(userId, areacount, buyerclasscount, qutil.ObjToMap((*tmp)["citys"])), vipStatus == 1 || vipStatus == 2
-	} else if (*tmp)["newCitys"] != nil { //错误转换
-		if tmp, ok := (*tmp)["newCitys"].([]interface{}); ok {
-			newCity = tmp
-			go func() {
-				ok := util.MQFW.UpdateById("user", userId, bson.M{"$set": bson.M{"o_vipjy.o_buyset": bson.M{"areacount": areacount, "buyerclasscount": buyerclasscount, "newcitys": tmp}}})
-				log.Printf("用户%s SubvipBuySet 二次转换 %v\n", userId, ok, tmp)
-			}()
-		}
-	}
+
 	return mData, &SubvipBuySet{
+		qutil.IntAll((*tmp)["upgrade"]),
 		qutil.IntAll((*tmp)["areacount"]),
 		util.ConfirmIntArr(newCity),
 		qutil.IntAll((*tmp)["buyerclasscount"]),
-	}, vipStatus == 1 || vipStatus == 2
+	}, vipStatus > 0
 }
 
-//旧SubvipBuySet转新SubvipBuySet
-func subvipBuySetFulsh(userId string, areaCount, buyerclasscount int, oldCitys *map[string]interface{}) *SubvipBuySet {
-	logAreaCount := areaCount
-	logBuyerclasscount := buyerclasscount
-	newCitys := []int{}
-	for _, v := range *oldCitys {
-		thisNum := qutil.IntAll(v)
-		if thisNum > SubVipPrice.CityMaxCount {
-			areaCount++
-		} else {
-			newCitys = append(newCitys, thisNum)
-		}
-	}
-	//省份数量自动转换全国
-	if areaCount > SubVipPrice.ProvinceMaxCount {
-		areaCount = -1
-		newCitys = []int{}
-	}
-	//行业数量自动转换全行业
-	if buyerclasscount > SubVipPrice.BuyerClassMaxCount {
-		buyerclasscount = -1
-	}
-	go func() { //更新o_buyset字段
-		ok := util.MQFW.UpdateById("user", userId, bson.M{"$set": bson.M{"o_vipjy.o_buyset": bson.M{"areacount": areaCount, "buyerclasscount": buyerclasscount, "newcitys": newCitys}}})
-		log.Printf("用户%s SubvipBuySet 自动转换 %v \n 旧:【省:%d 行业:%d 城市:%+v】\n 新:【省:%d 行业:%d 城市:%v】",
-			userId, ok, logAreaCount, logBuyerclasscount, oldCitys,
-			areaCount, buyerclasscount, newCitys)
-	}()
+func (this *vipSubscribeStruct) GetMergeNewBuyset(o_buyset map[string]interface{}) *SubvipBuySet {
 	return &SubvipBuySet{
-		areaCount,
-		newCitys,
-		buyerclasscount,
+		qutil.IntAll(o_buyset["upgrade"]),
+		qutil.IntAll(o_buyset["areacount"]),
+		util.ConfirmIntArr(o_buyset["newcitys"].([]interface{})),
+		qutil.IntAll(o_buyset["buyerclasscount"]),
 	}
-}
 
-//newFiled []int  oldFiled map
-func (this *vipSubscribeStruct) GetMergeNewBuyset(o_buyset map[string]interface{}) *SubvipBuySet {
-	if o_buyset["newcitys"] != nil { //新buyset
-		return &SubvipBuySet{
-			qutil.IntAll(o_buyset["areacount"]),
-			util.ConfirmIntArr(o_buyset["newcitys"].([]interface{})),
-			qutil.IntAll(o_buyset["buyerclasscount"]),
-		}
-	} else { //旧buyset
-		areaCount := qutil.IntAll(o_buyset["areacount"])
-		buyerclasscount := qutil.IntAll(o_buyset["buyerclasscount"])
-		oldCitys := qutil.ObjToMap(o_buyset["citys"])
-		newCitys := []int{}
-		for _, v := range *oldCitys {
-			thisNum := qutil.IntAll(v)
-			if thisNum > SubVipPrice.CityMaxCount {
-				areaCount++
-			} else {
-				newCitys = append(newCitys, thisNum)
-			}
-		}
-		//省份数量自动转换全国
-		if areaCount > SubVipPrice.ProvinceMaxCount {
-			areaCount = -1
-			newCitys = []int{}
-		}
-		//行业数量自动转换全行业
-		if buyerclasscount > SubVipPrice.BuyerClassMaxCount {
-			buyerclasscount = -1
-		}
-		return &SubvipBuySet{
-			areaCount,
-			newCitys,
-			buyerclasscount,
-		}
-	}
 }
 
 //保存筛选日志
@@ -515,25 +498,8 @@ func (this *vipSubscribeStruct) SaveSelectLog(userId, openId string, msg *VipSim
 }
 
 //计算价格
-// area具体省市名称
-//industry 具体行业
-//count 时间长度  unit 时间单位
-func (this *vipSubscribeStruct) GetSubVipPrice(area *map[string]interface{}, industry []string, count, unit int) int {
-	industryNum := len(industry) //行业数量
-	pCount := -1                 //省份数量
-	cityCountArr := []int{}      //购买省份中城市数量
-	if len(*area) > 0 {
-		pCount = 0
-		for _, v := range *area {
-			tmp := v.([]interface{})
-			if len(tmp) == 0 { //省份
-				pCount++
-			} else { //城市
-				cityCountArr = append(cityCountArr, len(tmp))
-			}
-		}
-	}
-	return this.GetSubVipPriceByBuySet(cityCountArr, pCount, industryNum, count, unit, true)
+func (this *vipSubscribeStruct) GetSubVipPrice(buyset *SubvipBuySet, count, unit int) int {
+	return this.GetSubVipPriceByBuySet(buyset, count, unit, true)
 }
 
 //cityCountMap 选择城市数量
@@ -541,62 +507,78 @@ func (this *vipSubscribeStruct) GetSubVipPrice(area *map[string]interface{}, ind
 //industryNum 选择行业数量
 //count 时间长度  unit 时间单位
 //isDiscount 测试环境是否打折
-func (this *vipSubscribeStruct) GetSubVipPriceByBuySet(cityCountArr []int, pCount, industryNum, count, unit int, isDiscount bool) int {
-	payMoney := func() int {
-		//城市选择过多时,转为省份
-		newCityArr := []int{} //防止操作cityCountArr 影响原数据
-		for _, cityCount := range cityCountArr {
-			if cityCount > SubVipPrice.CityMaxCount {
-				pCount++
-			} else {
-				newCityArr = append(newCityArr, cityCount)
+func (this *vipSubscribeStruct) GetSubVipPriceByBuySet(buySet *SubvipBuySet, count, unit int, isDiscount bool) int {
+	payMoney := func() (finalPrice int) {
+		pCount := buySet.AreaCount            //省份数量
+		industryNum := buySet.BuyerclassCount //行业数量
+		newCityArr := []int{}                 //选择城市数量 防止操作cityCountArr 影响原数据
+		if buySet.Upgrade != 1 {              //未升级超级订阅计价规则
+			//城市选择过多时,转为省份
+			for _, cityCount := range buySet.NewCitys {
+				if cityCount > SubVipPrice.Old.CityMaxCount {
+					pCount++
+				} else {
+					newCityArr = append(newCityArr, cityCount)
+				}
 			}
-		}
-		//
-		if industryNum == -1 {
-			industryNum = 0
-		}
-		//当行业数量大于最大值SubVipPrice.BuyerClassMaxCount 按照全行业计算
-		if industryNum > SubVipPrice.BuyerClassMaxCount {
-			industryNum = 0
-		}
-		//当选择月份大于  按照全年计算
-		if count > SubVipPrice.MonthMaxCount && unit == 2 { //月份十个月以上价格一样
-			count = 10
-		}
-		//当省份数量大于SubVipPrice.ProvinceMaxCount 按照全国计算
-		if pCount > SubVipPrice.ProvinceMaxCount {
-			pCount = -1
-		}
-		if pCount == -1 { //计算全国套餐价格
-			if industryNum == 1 {
-				return getSetMealPrice(0, 1, unit) * count //全国1行业套餐
-			} else if industryNum == 0 {
-				return getSetMealPrice(0, 0, unit) * count //全国全行业套餐
-			} else {
-				return getSetMealPrice(0, industryNum, unit) * count //全国多行业套餐
+			//
+			if industryNum == -1 {
+				industryNum = 0
 			}
-		}
-		//计算非全国套餐
-		finalPrice := 0
-		for _, cityCount := range newCityArr {
-			thisPrice := 0
-			if cityCount == 1 { //单城市
-				thisPrice = getSetMealPrice(2, industryNum, unit) * count
-			} else { //多城市
-				if industryNum == 0 || industryNum == 1 { //多城市 单行业
-					thisPrice = cityCount * getSetMealPrice(2, industryNum, unit) * count
-				} else { //多城市 多行业
-					if cityCount > SubVipPrice.CityMaxCount {
-						pCount++
-					} else {
-						thisPrice = getSetMealPrice(2, industryNum, unit) * cityCount * count
+			//当行业数量大于最大值SubVipPrice.BuyerClassMaxCount 按照全行业计算
+			if industryNum > SubVipPrice.Old.BuyerClassMaxCount {
+				industryNum = 0
+			}
+			//当选择月份大于  按照全年计算
+			if count > SubVipPrice.Old.MonthMaxCount && unit == 2 { //月份十个月以上价格一样
+				count = 10
+			}
+			//当省份数量大于SubVipPrice.ProvinceMaxCount 按照全国计算
+			if pCount > SubVipPrice.Old.ProvinceMaxCount {
+				pCount = -1
+			}
+			if pCount == -1 { //计算全国套餐价格
+				if industryNum == 1 {
+					return getSetMealPrice_old(0, 1, unit) * count //全国1行业套餐
+				} else if industryNum == 0 {
+					return getSetMealPrice_old(0, 0, unit) * count //全国全行业套餐
+				} else {
+					return getSetMealPrice_old(0, industryNum, unit) * count //全国多行业套餐
+				}
+			}
+			//计算非全国套餐
+			for _, cityCount := range newCityArr {
+				thisPrice := 0
+				if cityCount == 1 { //单城市
+					thisPrice = getSetMealPrice_old(2, industryNum, unit) * count
+				} else { //多城市
+					if industryNum == 0 || industryNum == 1 { //多城市 单行业
+						thisPrice = cityCount * getSetMealPrice_old(2, industryNum, unit) * count
+					} else { //多城市 多行业
+						if cityCount > SubVipPrice.Old.CityMaxCount {
+							pCount++
+						} else {
+							thisPrice = getSetMealPrice_old(2, industryNum, unit) * cityCount * count
+						}
 					}
 				}
+				finalPrice += thisPrice
+			}
+			finalPrice += pCount * getSetMealPrice_old(1, industryNum, unit) * count
+		} else { //升级版超级订阅计价规则
+			industryNum = 0 //全行业
+			if pCount > SubVipPrice.New.ProvinceMaxCount {
+				pCount = -1
+			}
+			if pCount == -1 {
+				pCount = 0
 			}
-			finalPrice += thisPrice
+			//当选择月份大于  按照全年计算
+			if count > SubVipPrice.New.MonthMaxCount && unit == 2 { //月份十个月以上价格一样
+				count = 10
+			}
+			return getSetMealPrice(pCount, unit) * count //全国1行业套餐
 		}
-		finalPrice += pCount * getSetMealPrice(1, industryNum, unit) * count
 		return finalPrice
 	}()
 	if isDiscount {
@@ -627,51 +609,73 @@ func (this *vipSubscribeStruct) GetVipLiveActive(userId string) bool {
 }
 
 /*
-vip订阅 套餐价格
+vip订阅 套餐价格 -非升级版
 c(city) 全国:0 省:1 市:2
 iCount(industry) 全行业:0 行业:1 其他:多个行业
 u(unit) 年:1 月:2
 */
-func getSetMealPrice(c, iCount, u int) int {
+func getSetMealPrice_old(c, iCount, u int) int {
 	t := u == 2 //是否是月单位
 	switch c {
 	case 0:
 		if iCount == 0 {
 			if t {
-				return SubVipPrice.Month.AllProvince_allBuyerClass // 38800 //1月全国全行业
+				return SubVipPrice.Old.Month.AllProvince_allBuyerClass // 38800 //1月全国全行业
 			}
-			return SubVipPrice.Year.AllProvince_allBuyerClass // 388000 //1年全国全行业
+			return SubVipPrice.Old.Year.AllProvince_allBuyerClass // 388000 //1年全国全行业
 		} else {
 			if t {
-				return SubVipPrice.Month.AllProvince_oneBuyerClass * iCount // 11800 * iCount //1月全国icount个行业
+				return SubVipPrice.Old.Month.AllProvince_oneBuyerClass * iCount // 11800 * iCount //1月全国icount个行业
 			}
-			return SubVipPrice.Year.AllProvince_oneBuyerClass * iCount //118000 * iCount //1年全国icount个行业
+			return SubVipPrice.Old.Year.AllProvince_oneBuyerClass * iCount //118000 * iCount //1年全国icount个行业
 		}
 	case 1:
 		if iCount == 0 {
 			if t {
-				return SubVipPrice.Month.OneProvince_allBuyerClass //3800 //1月1省全行业
+				return SubVipPrice.Old.Month.OneProvince_allBuyerClass //3800 //1月1省全行业
 			}
-			return SubVipPrice.Year.OneProvince_allBuyerClass //38000 //1年1省全行业
+			return SubVipPrice.Old.Year.OneProvince_allBuyerClass //38000 //1年1省全行业
 		} else {
 			if t {
-				return SubVipPrice.Month.OneProvince_oneBuyerClass * iCount //1180 * iCount //1月1省icount个行业
+				return SubVipPrice.Old.Month.OneProvince_oneBuyerClass * iCount //1180 * iCount //1月1省icount个行业
 			}
-			return SubVipPrice.Year.OneProvince_oneBuyerClass * iCount //1年1省icount个行业
+			return SubVipPrice.Old.Year.OneProvince_oneBuyerClass * iCount //1年1省icount个行业
 		}
 	default:
 		if iCount == 0 {
 			if t {
-				return SubVipPrice.Month.OneCity_allBuyerClass //1800 //1月1市全行业
+				return SubVipPrice.Old.Month.OneCity_allBuyerClass //1800 //1月1市全行业
 			}
-			return SubVipPrice.Year.OneCity_allBuyerClass //1年1市全行业
+			return SubVipPrice.Old.Year.OneCity_allBuyerClass //1年1市全行业
 		} else {
 			if t {
-				return SubVipPrice.Month.OneCity_oneBuyerClass * iCount // 580 * iCount //1月1市icount个行业
+				return SubVipPrice.Old.Month.OneCity_oneBuyerClass * iCount // 580 * iCount //1月1市icount个行业
 			}
-			return SubVipPrice.Year.OneCity_oneBuyerClass * iCount //5800 * iCount //1年1市icount个行业
+			return SubVipPrice.Old.Year.OneCity_oneBuyerClass * iCount //5800 * iCount //1年1市icount个行业
+		}
+	}
+}
+
+/*
+vip订阅 套餐价格 -升级版
+p(province) 全国:0 省:1
+u(unit) 年:1 月:2
+*/
+func getSetMealPrice(p, u int) int {
+	t := u == 2 //是否是月单位
+	switch p {
+	case 0:
+		if t {
+			return SubVipPrice.New.Month.AllProvince_allBuyerClass // 1月全国全行业
+		}
+		return SubVipPrice.New.Year.AllProvince_allBuyerClass //1年全国全行业
+	case 1:
+		if t {
+			return SubVipPrice.New.Month.OneProvince_allBuyerClass * p //1月1省全行业
 		}
+		return SubVipPrice.New.Year.OneProvince_allBuyerClass * p //1年1省全行业
 	}
+	return -1
 }
 
 //支付成功后,将该订单以外的所有订单状态改为已取消状态 已取消:-2  先关闭订单再改状态  --entname 企业商机管理订单会用到该参数 其他取消订单不需要

+ 267 - 301
src/jfw/modules/subscribepay/src/service/vipSubscribeChange.go

@@ -6,23 +6,23 @@ import (
 	"entity"
 	"errors"
 	"fmt"
+	"github.com/go-xweb/xweb"
+	"go.mongodb.org/mongo-driver/bson"
 	"log"
 	"math"
 	"pay"
 	qutil "qfw/util"
+	"qfw/util/jy"
 	"strings"
 	"time"
 	"util"
-
-	"github.com/go-xweb/xweb"
-	"go.mongodb.org/mongo-driver/bson"
 )
 
 //订阅修改 or 升级
 type SubscribeChange struct {
 	*xweb.Action
 	getSubBuyMsg  xweb.Mapper `xweb:"/vipsubscribe/getSubBuyMsg"`  //获取vip订阅详情
-	saveChange    xweb.Mapper `xweb:"/vipsubscribe/saveChange"`    //订阅修改 or 升级
+	saveChange    xweb.Mapper `xweb:"/vipsubscribe/saveChange"`    //订阅修改
 	mergeIndustry xweb.Mapper `xweb:"/vipsubscribe/mergeIndustry"` //行业合并
 }
 
@@ -71,21 +71,14 @@ func (this *SubscribeChange) GetSubBuyMsg() {
 	this.ServeJson(r.Format())
 }
 
-//修改 or 升级
+//订阅修改
 func (this *SubscribeChange) SaveChange() {
 	area := qutil.ObjToMap(this.GetString("area"))
 	industry := strings.Split(this.GetString("industry"), ",")
 	userId := qutil.ObjToString(this.GetSession("userId"))
-	timeRenew := this.GetString("time")
-	req_price, _ := this.GetInteger("price")
-	openId := qutil.ObjToString(this.GetSession("s_m_openid"))
-	//用户当前使用卡卷
-	userLotteryId := ""
-	//卡卷信息的id
-	lotteryId := this.GetString("lotteryId")
-	discount_price := 0
+
 	r := func() *entity.FuncResult {
-		if len(industry) == 1 && industry[0] == "" { //去掉[""]
+		if len(industry) == 1 && industry[0] == "" {
 			industry = []string{}
 		}
 		rData, oldBuyset, isVip := entity.JyVipSubStruct.GetVipDetail(userId)
@@ -95,20 +88,50 @@ func (this *SubscribeChange) SaveChange() {
 		if rData == nil || len(*rData) == 0 {
 			return &entity.FuncResult{false, errors.New("获取信息失败"), nil}
 		}
-		newBuyset := entity.JyVipSubStruct.NewBuySet(area, industry)
-		needUpgrade, upgradeBuyset := needUpgrade(newBuyset, oldBuyset)
-		log.Println(oldBuyset, newBuyset, upgradeBuyset)
+		newBuyset := entity.JyVipSubStruct.NewBuySet(area, industry, oldBuyset.Upgrade == 1)
+
+		if needUpgrade := needUpgrade(newBuyset, oldBuyset); needUpgrade {
+			return &entity.FuncResult{false, errors.New("订阅内容超出套餐"), nil}
+		}
+		if !entity.JyVipSubStruct.SubChange(userId, qutil.ObjToMap((*rData)["o_vipjy"]), area, industry) {
+			return &entity.FuncResult{false, errors.New("保存修改出错"), nil}
+		}
+		return &entity.FuncResult{true, nil, map[string]interface{}{
+			"doSuccess": true,
+		}}
+	}()
+	if r.Err != nil {
+		log.Printf("%s SaveChange err:%v\n", userId, r.Err.Error())
+	}
+	this.ServeJson(r.Format())
+}
+
+//升级订阅
+func (this *SubscribeChange) Upgrade() {
+	userId := qutil.ObjToString(this.GetSession("userId"))
+	r := func() *entity.FuncResult {
+		area := qutil.ObjToMap(this.GetString("area")) //地区
+		timeRenew := this.GetString("time")            //周期
+		req_price, _ := this.GetInteger("price")       //前端展示金额
+		openId := qutil.ObjToString(this.GetSession("s_m_openid"))
+		order_phone := this.GetString("order_phone") //p19.3用户信息采集 手机号
+
+		rData, oldBuyset, isVip := entity.JyVipSubStruct.GetVipDetail(userId)
+		if !isVip {
+			return &entity.FuncResult{false, errors.New("请求异常,非vip状态"), nil}
+		}
+
 		now := time.Now()
-		needRenew := false
-		date_count, date_unit := 0, 0
+		date_count, date_unit, needRenew := 0, 0, false
 		endUnix := qutil.Int64All((*rData)["l_vip_endtime"])
-		isTrail := qutil.IntAll((*rData)["i_vip_status"]) == 1
+
 		if timeRenew != "" {
 			var err error
 			date_count, date_unit, err = checkReqDate(timeRenew)
 			if err != nil {
 				return &entity.FuncResult{false, errors.New("格式化日期出错"), nil}
 			}
+			isTrail := qutil.IntAll((*rData)["i_vip_status"]) == 1
 			//校验是否超过三年
 			if time.Date(now.Year(), now.Month(), now.Day(), 23, 59, 59, 59, now.Location()).
 				AddDate(3, 0, 0).Before(util.GetDATE(date_unit, date_count, endUnix)) && !isTrail {
@@ -116,108 +139,58 @@ func (this *SubscribeChange) SaveChange() {
 			}
 			needRenew = true
 		}
-		//订阅修改(不需要升级,不需要续费)
-		if !needUpgrade && !needRenew {
-			if !entity.JyVipSubStruct.SubChange(userId, qutil.ObjToMap((*rData)["o_vipjy"]), area, industry) {
-				return &entity.FuncResult{false, errors.New("保存修改出错"), nil}
+
+		newBuyset := entity.JyVipSubStruct.NewBuySet(area, nil, true) //改版后只能购买升级版超级订阅
+
+		//升级校验
+		totalPrice, subtotail := getNewUpgradeDetail(userId, newBuyset, oldBuyset, endUnix, date_count, date_unit)
+		if totalPrice < 0 {
+			if totalPrice == -1 {
+				return &entity.FuncResult{false, errors.New("不能升级此状态"), nil}
+			} else {
+				return &entity.FuncResult{false, errors.New("查询续费订单出错"), nil}
 			}
-			return &entity.FuncResult{true, nil, map[string]interface{}{
-				"doSuccess": true,
-				"needPay":   false,
-			}}
 		}
 
-		//升级or续费
 		filter := entity.VipSimpleMsg{
 			Area:             area,
-			Industry:         industry,
+			Industry:         nil, //行业保存默认选择
 			Cyclecount:       date_count,
 			Cycleunit:        date_unit,
-			OldBuyset:        nil,
-			NewBuyset:        nil,
-			UpgradeSubtotail: nil,
-			OrderType:        0,
+			OldBuyset:        oldBuyset,
+			NewBuyset:        newBuyset,
+			UpgradeSubtotail: subtotail,
+			OrderType:        3,
 			DisWord:          "",
 		}
-		final_price := 0
 		var startTime, endTime time.Time
-		full_price, reduce_price := 0, 0
-		log.Println("lotteryId:", lotteryId)
-		if lotteryId != "" {
-			full_price, reduce_price, userLotteryId = util.GetCouponInfo(userId, lotteryId, config.CouponConfig.Products["超级订阅"])
-		}
-		if isTrail { //试用用户购买
-			if date_count == 0 || date_unit == 0 {
-				return &entity.FuncResult{false, errors.New("时间选择异常"), nil}
-			}
-			filter.OrderType = 1
-			filter.NewBuyset = newBuyset
-			final_price = entity.JyVipSubStruct.GetSubVipPriceByBuySet(newBuyset.NewCitys, newBuyset.AreaCount, newBuyset.BuyerclassCount, date_count, date_unit, false)
-			//双十一活动
-			if entity.JyVipSubStruct.IsActiving() && entity.JyVipSubStruct.IsHaveCycle(userId) {
-				filter.OriginalPrice = final_price * 2
-				if date_unit == 1 {
-					filter.GiveCycle = 12
-					if date_count > 1 {
-						filter.OriginalPrice = final_price / date_count * (date_count + 1)
-					}
-				} else if date_unit == 2 {
-					filter.GiveCycle = date_count
-				}
-			}
-		} else {
-			if !needUpgrade && needRenew { //只续费,不升级
-				//保存修改
-				if !entity.JyVipSubStruct.SubChange(userId, qutil.ObjToMap((*rData)["o_vipjy"]), area, industry) {
-					return &entity.FuncResult{false, errors.New("保存修改出错"), nil}
-				}
-				final_price = entity.JyVipSubStruct.GetSubVipPriceByBuySet(oldBuyset.NewCitys, oldBuyset.AreaCount, oldBuyset.BuyerclassCount, date_count, date_unit, false)
-				filter.OrderType = 5
-				filter.NewBuyset = oldBuyset
-
-				log.Println("续费", final_price)
-				//生效时间
-				startTime = time.Unix(endUnix, 0)
+		if needRenew {
+			startTime = now
+			if needRenew {
 				endTime = util.GetDATE(filter.Cycleunit, filter.Cyclecount, endUnix)
-			} else { //升级
-				//升级(若存在续费,升级单子必须高于每个续费单子;否则不能升级)
-				totalPrice, subtotail := getUpgradeDetail(userId, upgradeBuyset, oldBuyset, endUnix, date_count, date_unit)
-				if totalPrice < 0 {
-					if totalPrice == -1 {
-						return &entity.FuncResult{false, errors.New("不能升级此状态"), nil}
-					} else {
-						return &entity.FuncResult{false, errors.New("查询续费订单出错"), nil}
-					}
-				}
-
-				final_price = totalPrice
-				filter.OrderType = 3
-				filter.OldBuyset = oldBuyset
-				filter.NewBuyset = upgradeBuyset
-				filter.UpgradeSubtotail = subtotail
-
-				//生效时间
-				startTime = now
-				if needRenew {
-					endTime = util.GetDATE(filter.Cycleunit, filter.Cyclecount, endUnix)
-				} else {
-					endTime = time.Unix(endUnix, 0)
-				}
+			} else {
+				endTime = time.Unix(endUnix, 0)
 			}
 		}
+
+		final_price, discount_price := totalPrice, 0
+		if req_price != final_price {
+			log.Println(userId+" 前台计算", req_price, "后台计算", final_price)
+			return &entity.FuncResult{false, errors.New(fmt.Sprintf("金额校验异常[%d,%d]", final_price, req_price)), nil}
+		}
 		//卡卷使用
+		userLotteryId, lotteryId := "", this.GetString("lotteryId")
+		full_price, reduce_price := 0, 0
+
+		if lotteryId != "" {
+			full_price, reduce_price, userLotteryId = util.GetCouponInfo(userId, lotteryId, config.CouponConfig.Products["超级订阅"])
+		}
 		if reduce_price > 0 && full_price <= final_price {
 			final_price = final_price - reduce_price
 			discount_price = reduce_price
 		}
-		log.Println("reduce_price:", reduce_price)
-		log.Printf("是否需要升级%v,是否需要续费%v\n", needUpgrade, needRenew)
-		log.Printf("price: %d \n req_price:%d filter:%+v\n", final_price, req_price, filter)
-		//
-		if req_price != final_price {
-			log.Println(userId+" 前台计算", req_price, "后台计算", final_price)
-			return &entity.FuncResult{false, errors.New(fmt.Sprintf("金额校验异常[%d,%d]", final_price, req_price)), nil}
-		}
+
+		//测试打折
 		if entity.SubVipPrice.Discount < 1 {
 			tmp := float64(final_price) * entity.SubVipPrice.Discount
 			if tmp < 1 {
@@ -259,201 +232,44 @@ func (this *SubscribeChange) SaveChange() {
 			"dis_word":       disWord,
 			"discount_price": discount_price,
 			"d_relation_id":  userLotteryId,
-			//"vip_type":       qutil.If(filter.OrderType == 5, 1, 2), //1:续费 2:升级
+			"vip_type":       2, //1:续费 2:升级
+			"user_phone":     order_phone,
 		}
-		if filter.OrderType != 1 {
-			insertMap["vip_type"] = 2
+		if order_phone != "" {
+			if !jy.PhoneReg.MatchString(order_phone) {
+				return &entity.FuncResult{false, errors.New("手机号格式异常"), nil}
+			}
+			insertMap["user_phone"] = order_phone
 		}
+
 		orderid := util.Mysql.Insert("dataexport_order", insertMap)
 		if orderid == -1 {
 			return &entity.FuncResult{false, errors.New("数据库操作异常"), nil}
-		} else {
-			//绑定卡卷
-			if userLotteryId != "" && lotteryId != "" {
-				go func(userId, userLotteryId, order_code string) {
-					nickname, _ := this.Session().Get("s_nickname").(string)
-					if !util.UpdateCouponState(userId, userLotteryId, nickname, order_code, 3) {
-						log.Println(fmt.Sprintf("单号%s-绑定失败-卡卷%s", order_code, userLotteryId))
-					}
-				}(userId, userLotteryId, ordercode)
-			}
 		}
-		//支付提醒
-		util.MsgRemind.Add(qutil.IntAll(orderid), final_price, qutil.If(filter.OrderType == 5, 1, -1).(int), 0, ordercode, userId, now.Unix())
+		//绑定卡卷
+		if userLotteryId != "" && lotteryId != "" {
+			go func(userId, userLotteryId, order_code string) {
+				nickname, _ := this.Session().Get("s_nickname").(string)
+				if !util.UpdateCouponState(userId, userLotteryId, nickname, order_code, 3) {
+					log.Println(fmt.Sprintf("单号%s-绑定失败-卡卷%s", order_code, userLotteryId))
+				}
+			}(userId, userLotteryId, ordercode)
+		}
 		return &entity.FuncResult{true, nil, map[string]interface{}{"code": ordercode, "needPay": true}}
 	}()
 	if r.Err != nil {
-		log.Printf("%s CreateOrder err:%v\n", userId, r.Err.Error())
+		log.Printf("%s Upgrade err:%v\n", userId, r.Err.Error())
 	}
 	this.ServeJson(r.Format())
 }
 
-//是否需要升级
-func needUpgrade(newBuySet, oldBuySet *entity.SubvipBuySet) (bool, *entity.SubvipBuySet) {
-	BuyerclassUpgrade, AreaNeedUpgrade := false, false
-	UpgradeBuyset := &entity.SubvipBuySet{
-		oldBuySet.AreaCount,
-		oldBuySet.NewCitys,
-		oldBuySet.BuyerclassCount,
-	}
-	//UpgradeBuyset.BuyerclassCount = newBuySet.BuyerclassCount
-	//比较行业
-	if oldBuySet.BuyerclassCount != -1 {
-		//若当前买的不是全行业,并且当前行业数量小于新行业数量时
-		if oldBuySet.BuyerclassCount < newBuySet.BuyerclassCount || newBuySet.BuyerclassCount == -1 {
-			BuyerclassUpgrade = true
-			//计算升级后的buySet
-			UpgradeBuyset.BuyerclassCount = newBuySet.BuyerclassCount
-		}
-	}
-	//比较地区
-	if oldBuySet.AreaCount != -1 {
-		if newBuySet.AreaCount == -1 { //升级为全国
-			UpgradeBuyset.AreaCount = newBuySet.AreaCount
-			UpgradeBuyset.NewCitys = newBuySet.NewCitys
-			AreaNeedUpgrade = true
-		} else {
-			oldCitysBuyOne, oldCitysBuyTwo := 0, 0
-			newCitysBuyOne, newCitysBuyTwo := 0, 0
-			oldCopy := []int{} //复制(防止影响原数组)
-			for _, v := range oldBuySet.NewCitys {
-				if v == 1 {
-					oldCitysBuyOne++
-				} else {
-					oldCitysBuyTwo++
-				}
-				oldCopy = append(oldCopy, v)
-			}
-			UpgradeBuyset.NewCitys = oldCopy
-			for _, v := range newBuySet.NewCitys {
-				if v == 1 {
-					newCitysBuyOne++
-				} else {
-					newCitysBuyTwo++
-				}
-			}
-
-			p_Diff := newBuySet.AreaCount - oldBuySet.AreaCount
-			c_1_diff := newCitysBuyOne - oldCitysBuyOne
-			c_2_diff := newCitysBuyTwo - oldCitysBuyTwo
-
-			//log.Println(p_Diff, c_2_diff, c_1_diff)
-
-			if p_Diff > 0 {
-				UpgradeBuyset.AreaCount = newBuySet.AreaCount
-			}
-
-			if p_Diff > 0 || p_Diff+c_2_diff > 0 || p_Diff+c_2_diff+c_1_diff > 0 {
-				//有多余未使用名额保留
-				if p_Diff+c_2_diff+c_1_diff < 0 {
-					if c_1_diff < 0 && p_Diff+c_2_diff >= 0 {
-						c_1_diff = -(p_Diff + c_2_diff)
-					}
-					if c_2_diff < 0 && p_Diff+c_1_diff >= 0 {
-						c_2_diff = -(p_Diff + c_1_diff)
-					}
-				}
-
-				//需要升级
-				AreaNeedUpgrade = true
-				//计算升级后的buySet
-				if p_Diff < 0 { //有剩余省份未使用
-					if c_2_diff > 0 {
-						c_2_diff += p_Diff //转移给两个市使用
-					} else {
-						c_1_diff += p_Diff //转移给一个市使用
-					}
-				} else { //省份数量增加
-					UpgradeBuyset.AreaCount = newBuySet.AreaCount
-				}
-				del_2_flag, del_1_flag := 0, 0 //被占用
-				if c_2_diff < 0 {              //有两个城市的名额未使用完
-					if p_Diff > 0 {
-						//转移给一个省使用
-						if c_2_diff+p_Diff > 0 {
-							del_2_flag += -c_2_diff
-							c_2_diff = 0
-							//p_Diff -= -c_2_diff;
-						} else {
-							c_2_diff += p_Diff
-							del_2_flag += p_Diff
-							//p_Diff = 0
-						}
-					}
-					if c_1_diff > 0 && c_2_diff < 0 { //转移给一个市使用
-						c_1_diff += c_2_diff
-					}
-				}
-				if c_1_diff < 0 { //有一个城市的名额未使用完
-					if p_Diff > 0 {
-						if c_1_diff+p_Diff > 0 {
-							del_1_flag += -c_1_diff
-							c_1_diff = 0
-							//p_Diff -= -c_1_diff
-						} else {
-							c_1_diff += p_Diff
-							del_1_flag += p_Diff
-							//p_Diff = 0
-						}
-					}
-					if c_2_diff > 0 && c_1_diff < 0 {
-						if c_1_diff+c_2_diff > 0 {
-							del_1_flag += -c_1_diff
-							c_1_diff = 0
-							//c_2_diff -= -c_1_diff;
-						} else {
-							c_1_diff += c_2_diff
-							del_1_flag += c_2_diff
-							//c_2_diff = 0
-						}
-					}
-				}
-				//删除顶替
-				log.Println("start", UpgradeBuyset.NewCitys, del_2_flag, del_1_flag)
-				index_flag := 0
-				for del_2_flag > 0 || del_1_flag > 0 {
-					valueFlag := UpgradeBuyset.NewCitys[index_flag]
-					if del_2_flag > 0 && valueFlag == 2 {
-						UpgradeBuyset.NewCitys = append(UpgradeBuyset.NewCitys[:index_flag], UpgradeBuyset.NewCitys[index_flag+1:]...)
-						del_2_flag--
-						continue
-					} else if del_1_flag > 0 && valueFlag == 1 {
-						UpgradeBuyset.NewCitys = append(UpgradeBuyset.NewCitys[:index_flag], UpgradeBuyset.NewCitys[index_flag+1:]...)
-						del_1_flag--
-						continue
-					}
-					index_flag++
-				}
-				log.Println("end", UpgradeBuyset.NewCitys, c_2_diff, c_1_diff)
-				//增加新增
-				for i := c_2_diff; i > 0; i-- { //添加购买两个市数量
-					UpgradeBuyset.NewCitys = append(UpgradeBuyset.NewCitys, 2)
-				}
-
-				for i := c_1_diff; i > 0; i-- { //添加购买一个市数量
-					UpgradeBuyset.NewCitys = append(UpgradeBuyset.NewCitys, 1)
-				}
-			} else {
-				//不需要升级
-				AreaNeedUpgrade = false
-			}
-		}
-	}
-	if BuyerclassUpgrade || AreaNeedUpgrade {
-		return true, UpgradeBuyset
-	} else {
-		return false, nil
-	}
-}
-
-//升级详情单
-func getUpgradeDetail(userId string, newBuySet, oldBuySet *entity.SubvipBuySet, oldEndtime int64, count, unit int) (totalPrice int, subtotals []map[string]interface{}) {
+//获取新版超级订阅升级价格、清单
+func getNewUpgradeDetail(userId string, newBuySet, oldBuySet *entity.SubvipBuySet, oldEndtime int64, count, unit int) (totalPrice int, subtotals []map[string]interface{}) {
 	rResult, ok := util.MQFW.Find("vip_upgrade", &bson.M{"s_userid": userId, "i_isvalid": 0}, `{"l_validtime":1}`, `{"o_buyset":1,"l_validtime":1}`, false, -1, -1)
 	if !ok {
 		return -2, nil
 	}
 	nowEndTime := oldEndtime
-	//已经续费升级价格详单
 	if len(*rResult) != 0 {
 		for i := len(*rResult) - 1; i >= 0; i-- {
 			thisObj := qutil.ObjToMap((*rResult)[i])
@@ -494,7 +310,7 @@ func getUpgradeDetail(userId string, newBuySet, oldBuySet *entity.SubvipBuySet,
 	})
 	//此次新增续费价格计算
 	if count > 0 {
-		renew_price := entity.JyVipSubStruct.GetSubVipPriceByBuySet(newBuySet.NewCitys, newBuySet.AreaCount, newBuySet.BuyerclassCount, count, unit, false)
+		renew_price := entity.JyVipSubStruct.GetSubVipPriceByBuySet(newBuySet, count, unit, false)
 		if renew_price < 0 {
 			log.Println("~~~~~~~~3", renew_price)
 			return -1, nil
@@ -510,37 +326,187 @@ func getUpgradeDetail(userId string, newBuySet, oldBuySet *entity.SubvipBuySet,
 	return totalPrice, subtotals
 }
 
+//是否需要升级
+func needUpgrade(newBuySet, oldBuySet *entity.SubvipBuySet) bool {
+	BuyerclassUpgrade, AreaNeedUpgrade := false, false
+	UpgradeBuyset := &entity.SubvipBuySet{
+		oldBuySet.Upgrade,
+		oldBuySet.AreaCount,
+		oldBuySet.NewCitys,
+		oldBuySet.BuyerclassCount,
+	}
+	if newBuySet.Upgrade != 1 { //旧版本订阅是否需要升级校验
+		//比较行业
+		if oldBuySet.BuyerclassCount != -1 {
+			//若当前买的不是全行业,并且当前行业数量小于新行业数量时
+			if oldBuySet.BuyerclassCount < newBuySet.BuyerclassCount || newBuySet.BuyerclassCount == -1 {
+				BuyerclassUpgrade = true
+				//计算升级后的buySet
+				UpgradeBuyset.BuyerclassCount = newBuySet.BuyerclassCount
+			}
+		}
+		//比较地区
+		if oldBuySet.AreaCount != -1 {
+			if newBuySet.AreaCount == -1 { //升级为全国
+				UpgradeBuyset.AreaCount = newBuySet.AreaCount
+				UpgradeBuyset.NewCitys = newBuySet.NewCitys
+				AreaNeedUpgrade = true
+			} else {
+				oldCitysBuyOne, oldCitysBuyTwo := 0, 0
+				newCitysBuyOne, newCitysBuyTwo := 0, 0
+				oldCopy := []int{} //复制(防止影响原数组)
+				for _, v := range oldBuySet.NewCitys {
+					if v == 1 {
+						oldCitysBuyOne++
+					} else {
+						oldCitysBuyTwo++
+					}
+					oldCopy = append(oldCopy, v)
+				}
+				UpgradeBuyset.NewCitys = oldCopy
+				for _, v := range newBuySet.NewCitys {
+					if v == 1 {
+						newCitysBuyOne++
+					} else {
+						newCitysBuyTwo++
+					}
+				}
+
+				p_Diff := newBuySet.AreaCount - oldBuySet.AreaCount
+				c_1_diff := newCitysBuyOne - oldCitysBuyOne
+				c_2_diff := newCitysBuyTwo - oldCitysBuyTwo
+
+				if p_Diff > 0 {
+					UpgradeBuyset.AreaCount = newBuySet.AreaCount
+				}
+
+				if p_Diff > 0 || p_Diff+c_2_diff > 0 || p_Diff+c_2_diff+c_1_diff > 0 {
+					//有多余未使用名额保留
+					if p_Diff+c_2_diff+c_1_diff < 0 {
+						if c_1_diff < 0 && p_Diff+c_2_diff >= 0 {
+							c_1_diff = -(p_Diff + c_2_diff)
+						}
+						if c_2_diff < 0 && p_Diff+c_1_diff >= 0 {
+							c_2_diff = -(p_Diff + c_1_diff)
+						}
+					}
+
+					//需要升级
+					AreaNeedUpgrade = true
+					//计算升级后的buySet
+					if p_Diff < 0 { //有剩余省份未使用
+						if c_2_diff > 0 {
+							c_2_diff += p_Diff //转移给两个市使用
+						} else {
+							c_1_diff += p_Diff //转移给一个市使用
+						}
+					} else { //省份数量增加
+						UpgradeBuyset.AreaCount = newBuySet.AreaCount
+					}
+					del_2_flag, del_1_flag := 0, 0 //被占用
+					if c_2_diff < 0 {              //有两个城市的名额未使用完
+						if p_Diff > 0 {
+							//转移给一个省使用
+							if c_2_diff+p_Diff > 0 {
+								del_2_flag += -c_2_diff
+								c_2_diff = 0
+								//p_Diff -= -c_2_diff;
+							} else {
+								c_2_diff += p_Diff
+								del_2_flag += p_Diff
+								//p_Diff = 0
+							}
+						}
+						if c_1_diff > 0 && c_2_diff < 0 { //转移给一个市使用
+							c_1_diff += c_2_diff
+						}
+					}
+					if c_1_diff < 0 { //有一个城市的名额未使用完
+						if p_Diff > 0 {
+							if c_1_diff+p_Diff > 0 {
+								del_1_flag += -c_1_diff
+								c_1_diff = 0
+								//p_Diff -= -c_1_diff
+							} else {
+								c_1_diff += p_Diff
+								del_1_flag += p_Diff
+								//p_Diff = 0
+							}
+						}
+						if c_2_diff > 0 && c_1_diff < 0 {
+							if c_1_diff+c_2_diff > 0 {
+								del_1_flag += -c_1_diff
+								c_1_diff = 0
+								//c_2_diff -= -c_1_diff;
+							} else {
+								c_1_diff += c_2_diff
+								del_1_flag += c_2_diff
+								//c_2_diff = 0
+							}
+						}
+					}
+					//删除顶替
+					log.Println("start", UpgradeBuyset.NewCitys, del_2_flag, del_1_flag)
+					index_flag := 0
+					for del_2_flag > 0 || del_1_flag > 0 {
+						valueFlag := UpgradeBuyset.NewCitys[index_flag]
+						if del_2_flag > 0 && valueFlag == 2 {
+							UpgradeBuyset.NewCitys = append(UpgradeBuyset.NewCitys[:index_flag], UpgradeBuyset.NewCitys[index_flag+1:]...)
+							del_2_flag--
+							continue
+						} else if del_1_flag > 0 && valueFlag == 1 {
+							UpgradeBuyset.NewCitys = append(UpgradeBuyset.NewCitys[:index_flag], UpgradeBuyset.NewCitys[index_flag+1:]...)
+							del_1_flag--
+							continue
+						}
+						index_flag++
+					}
+					log.Println("end", UpgradeBuyset.NewCitys, c_2_diff, c_1_diff)
+					//增加新增
+					for i := c_2_diff; i > 0; i-- { //添加购买两个市数量
+						UpgradeBuyset.NewCitys = append(UpgradeBuyset.NewCitys, 2)
+					}
+
+					for i := c_1_diff; i > 0; i-- { //添加购买一个市数量
+						UpgradeBuyset.NewCitys = append(UpgradeBuyset.NewCitys, 1)
+					}
+				} else {
+					//不需要升级
+					AreaNeedUpgrade = false
+				}
+			}
+		}
+		if BuyerclassUpgrade || AreaNeedUpgrade {
+			return true
+		} else {
+			return false
+		}
+	} else {
+		return newBuySet.AreaCount > oldBuySet.AreaCount
+	}
+}
+
 //获取升级小计价格
 func getSubtotalPrice(oldBuyset, newBuyset *entity.SubvipBuySet, startTime, endtime int64) int {
 	//不能降级
-	oldCitysBuyTwo := 0
-	newCitysBuyTwo := 0
-	for _, v := range oldBuyset.NewCitys {
-		if v == 2 {
-			oldCitysBuyTwo++
-		}
+	pCount := oldBuyset.AreaCount
+	if oldBuyset.Upgrade != 1 {
+		pCount = oldBuyset.AreaCount + len(oldBuyset.NewCitys)
 	}
-	for _, v := range newBuyset.NewCitys {
-		if v == 2 {
-			newCitysBuyTwo++
-		}
-	}
-	if (oldBuyset.AreaCount != -1 && newBuyset.AreaCount != -1 && (oldBuyset.AreaCount > newBuyset.AreaCount || len(oldBuyset.NewCitys)+oldBuyset.AreaCount > len(newBuyset.NewCitys)+newBuyset.AreaCount || oldCitysBuyTwo+oldBuyset.AreaCount > newCitysBuyTwo+newBuyset.AreaCount)) ||
-		(oldBuyset.AreaCount == -1 && newBuyset.AreaCount != -1) || //旧套餐全国 新套餐非全国
-		(oldBuyset.BuyerclassCount != -1 && newBuyset.BuyerclassCount != -1 && oldBuyset.BuyerclassCount > newBuyset.BuyerclassCount) || //非全行业下 新套餐行业数量小于旧套餐数量
-		oldBuyset.BuyerclassCount == -1 && newBuyset.BuyerclassCount != -1 { //旧套餐全行业 新套餐非全行业
+	if newBuyset.AreaCount < pCount {
 		return -1
 	}
+
 	//计价方式为计算差额
 	beforePrice, newPrice := 0, 0
 	yearNum, monthNum := getDateSub(startTime, endtime)
 	if monthNum != 0 {
-		beforePrice += entity.JyVipSubStruct.GetSubVipPriceByBuySet(oldBuyset.NewCitys, oldBuyset.AreaCount, oldBuyset.BuyerclassCount, monthNum, 2, false)
-		newPrice += entity.JyVipSubStruct.GetSubVipPriceByBuySet(newBuyset.NewCitys, newBuyset.AreaCount, newBuyset.BuyerclassCount, monthNum, 2, false)
+		beforePrice += entity.JyVipSubStruct.GetSubVipPriceByBuySet(oldBuyset, monthNum, 2, false)
+		newPrice += entity.JyVipSubStruct.GetSubVipPriceByBuySet(newBuyset, monthNum, 2, false)
 	}
 	if yearNum != 0 {
-		beforePrice += entity.JyVipSubStruct.GetSubVipPriceByBuySet(oldBuyset.NewCitys, oldBuyset.AreaCount, oldBuyset.BuyerclassCount, yearNum, 1, false)
-		newPrice += entity.JyVipSubStruct.GetSubVipPriceByBuySet(newBuyset.NewCitys, newBuyset.AreaCount, newBuyset.BuyerclassCount, yearNum, 1, false)
+		beforePrice += entity.JyVipSubStruct.GetSubVipPriceByBuySet(oldBuyset, yearNum, 1, false)
+		newPrice += entity.JyVipSubStruct.GetSubVipPriceByBuySet(newBuyset, yearNum, 1, false)
 	}
 	log.Printf("old %+v \n new %+v \n %d-%d 相差%d年 %d个月\n price: %d-%d=%d  \n", oldBuyset, newBuyset, startTime, endtime, yearNum, monthNum, newPrice, beforePrice, newPrice-beforePrice)
 	return newPrice - beforePrice

+ 131 - 38
src/jfw/modules/subscribepay/src/service/vipSubscribePay.go

@@ -24,6 +24,8 @@ type SubVipPayOrder struct {
 	*xweb.Action
 	getPrice    xweb.Mapper `xweb:"/vipsubscribe/getPrice"`    //获取价格
 	createOrder xweb.Mapper `xweb:"/vipsubscribe/createOrder"` //创建订单并支付
+	upgrade     xweb.Mapper `xweb:"/vipsubscribe/upgrade"`     //升级超级订阅
+	renew       xweb.Mapper `xweb:"/vipsubscribe/renew"`       //续费超级订阅
 }
 
 func init() {
@@ -56,29 +58,27 @@ func (this *SubVipPayOrder) GetPrice() {
 }
 
 //新订单 或 即将到期续费
+//4.4 超级订阅升级 只能选择购买省份和全行业
 func (this *SubVipPayOrder) CreateOrder() {
-	area := qutil.ObjToMap(this.GetString("area"))
-	industry := strings.Split(this.GetString("industry"), ",")
-	date := this.GetString("time")
-	orderType, _ := this.GetInteger("orderType") //1 简单付费,5 升降级续费
 	userId := qutil.ObjToString(this.GetSession("userId"))
-	openId := qutil.ObjToString(this.GetSession("s_m_openid"))
-	disWord := this.GetString("disWord")
-	order_phone := this.GetString("order_phone") //p19.3用户信息采集 手机号
-	if disWord == "" {
-		start_time := TimeProcessing(time.Now().Format(DateFullLayout), -config.Config.TermValidity).Format(DateFullLayout)
-		stop_time := TimeProcessing(time.Now().Format(DateFullLayout), config.Config.TermValidity).Format(DateFullLayout)
-		infoList := util.Mysql.SelectBySql("select  * from  dis_word where userId=? and  ?<=start_time  and stop_time<? ORDER BY id ", userId, start_time, stop_time)
-		if len(*infoList) != 0 {
-			disWord = fmt.Sprint((*infoList)[0]["password"])
-		}
-	}
 	r := func() *entity.FuncResult {
-		now := time.Now()
-		//数据校验
-		if len(industry) == 1 && industry[0] == "" { //去掉[""]
-			industry = []string{}
+		area := qutil.ObjToMap(this.GetString("area"))
+		date := this.GetString("time")
+		orderType, _ := this.GetInteger("orderType") //1 简单付费,5 升降级续费
+		openId := qutil.ObjToString(this.GetSession("s_m_openid"))
+		disWord := this.GetString("disWord")
+		req_price, _ := this.GetInteger("price")     //前端展示金额
+		order_phone := this.GetString("order_phone") //p19.3用户信息采集 手机号
+
+		if disWord == "" {
+			start_time := TimeProcessing(time.Now().Format(DateFullLayout), -config.Config.TermValidity).Format(DateFullLayout)
+			stop_time := TimeProcessing(time.Now().Format(DateFullLayout), config.Config.TermValidity).Format(DateFullLayout)
+			infoList := util.Mysql.SelectBySql("select  * from  dis_word where userId=? and  ?<=start_time  and stop_time<? ORDER BY id ", userId, start_time, stop_time)
+			if len(*infoList) != 0 {
+				disWord = fmt.Sprint((*infoList)[0]["password"])
+			}
 		}
+		now := time.Now()
 		if !(orderType == 1 || orderType == 5) {
 			return &entity.FuncResult{false, errors.New("参数异常"), nil}
 		}
@@ -90,10 +90,10 @@ func (this *SubVipPayOrder) CreateOrder() {
 		if err != nil {
 			return &entity.FuncResult{false, err, nil}
 		}
-		buyset := entity.JyVipSubStruct.NewBuySet(area, industry)
+		buyset := entity.JyVipSubStruct.NewBuySet(area, nil, true) //改版后只能购买升级版超级订阅
 		filter := entity.VipSimpleMsg{
 			Area:       area,
-			Industry:   industry,
+			Industry:   []string{},
 			Cyclecount: date_count,
 			Cycleunit:  date_unit,
 			NewBuyset:  buyset,
@@ -110,6 +110,7 @@ func (this *SubVipPayOrder) CreateOrder() {
 				return &entity.FuncResult{false, errors.New("创建续费订单出错"), nil}
 			}
 			filter.OldBuyset = &entity.SubvipBuySet{
+				qutil.IntAll((*thisBuySet)["upgrade"]),
 				qutil.IntAll((*thisBuySet)["areacount"]),
 				util.ConfirmIntArr((*thisBuySet)["newcitys"].([]interface{})),
 				qutil.IntAll((*thisBuySet)["buyerclasscount"]),
@@ -121,30 +122,21 @@ func (this *SubVipPayOrder) CreateOrder() {
 			return &entity.FuncResult{false, errors.New("创建订单出错"), nil}
 		}
 		//计算价格
-		totalfee := entity.JyVipSubStruct.GetSubVipPrice(area, industry, date_count, date_unit)
+		totalfee := entity.JyVipSubStruct.GetSubVipPrice(buyset, date_count, date_unit)
+		if req_price != totalfee {
+			log.Println(userId+" 前台计算", req_price, "后台计算", totalfee)
+			return &entity.FuncResult{false, errors.New(fmt.Sprintf("金额校验异常[%d,%d]", totalfee, req_price)), nil}
+		}
 		//原价
 		original_price := totalfee
 		log.Printf("最终选择 地区:%+v   行业:%v\n 价格%d", filter.Area, filter.Industry, totalfee)
 		ordercode := pay.GetOrderCode(userId)
-		//双十一活动
-		if entity.JyVipSubStruct.IsActiving() && entity.JyVipSubStruct.IsHaveCycle(userId) {
-			filter.OriginalPrice = totalfee * 2
-			if date_unit == 1 {
-				filter.GiveCycle = 12
-				if date_count > 1 {
-					filter.OriginalPrice = totalfee / date_count * (date_count + 1)
-				}
-			} else if date_unit == 2 {
-				filter.GiveCycle = date_count
-			}
-		}
-		//用户当前使用卡卷
-		userLotteryId := ""
-		full_price, reduce_price := 0, 0
+
 		//卡卷信息的id
 		lotteryId := this.GetString("lotteryId")
-		discount_price := 0
+		discount_price, userLotteryId := 0, ""
 		if lotteryId != "" {
+			full_price, reduce_price := 0, 0
 			full_price, reduce_price, userLotteryId = util.GetCouponInfo(userId, lotteryId, config.CouponConfig.Products["超级订阅"])
 			if full_price <= totalfee {
 				totalfee = totalfee - reduce_price
@@ -214,6 +206,107 @@ func (this *SubVipPayOrder) CreateOrder() {
 	}
 	this.ServeJson(r.Format())
 }
+
+//续费
+func (this *SubVipPayOrder) Renew() {
+	userId := qutil.ObjToString(this.GetSession("userId"))
+	r := func() *entity.FuncResult {
+		disWord := this.GetString("disWord")
+		openId := qutil.ObjToString(this.GetSession("s_m_openid"))
+		req_price, _ := this.GetInteger("price") //前端展示金额
+		if disWord == "" {
+			start_time := TimeProcessing(time.Now().Format(DateFullLayout), -config.Config.TermValidity).Format(DateFullLayout)
+			stop_time := TimeProcessing(time.Now().Format(DateFullLayout), config.Config.TermValidity).Format(DateFullLayout)
+			infoList := util.Mysql.SelectBySql("select  * from  dis_word where userId=? and  ?<=start_time  and stop_time<? ORDER BY id ", userId, start_time, stop_time)
+			if len(*infoList) != 0 {
+				disWord = fmt.Sprint((*infoList)[0]["password"])
+			}
+		}
+		date := this.GetString("time")
+		date_count, date_unit, err := checkReqDate(date)
+		if err != nil {
+			return &entity.FuncResult{false, err, nil}
+		}
+		_, buyset, isVip := entity.JyVipSubStruct.GetVipDetail(userId)
+		if !isVip {
+			return &entity.FuncResult{false, errors.New("请求异常,非vip状态"), nil}
+		}
+		totalfee := entity.JyVipSubStruct.GetSubVipPriceByBuySet(buyset, date_count, date_unit, false)
+		if req_price != totalfee {
+			log.Println(userId+" 前台计算", req_price, "后台计算", totalfee)
+			return &entity.FuncResult{false, errors.New(fmt.Sprintf("金额校验异常[%d,%d]", totalfee, req_price)), nil}
+		}
+		filter := entity.VipSimpleMsg{
+			Area:       nil,
+			Industry:   nil,
+			Cyclecount: date_count,
+			Cycleunit:  date_unit,
+			NewBuyset:  buyset,
+			OrderType:  2,
+			DisWord:    disWord,
+		}
+		mog_id := entity.JyVipSubStruct.SaveSelectLog(userId, openId, &filter)
+		if mog_id == "" {
+			return &entity.FuncResult{false, errors.New("创建订单出错"), nil}
+		}
+		//原价
+		original_price := totalfee
+
+		//卡卷信息的id
+		lotteryId := this.GetString("lotteryId")
+		userLotteryId, discount_price := "", 0
+		if lotteryId != "" {
+			//用户当前使用卡卷
+			full_price, reduce_price := 0, 0
+			full_price, reduce_price, userLotteryId = util.GetCouponInfo(userId, lotteryId, config.CouponConfig.Products["超级订阅"])
+			if full_price <= totalfee {
+				totalfee = totalfee - reduce_price
+				discount_price = reduce_price
+			}
+		}
+		filterStr, _ := json.Marshal(filter)
+		ordercode := pay.GetOrderCode(userId)
+		now := time.Now()
+		insertMap := map[string]interface{}{
+			"order_money":    totalfee,
+			"order_status":   0,
+			"user_nickname":  qutil.ObjToString(this.GetSession("s_nickname")),
+			"user_openid":    openId,
+			"order_code":     ordercode,
+			"product_type":   "VIP订阅",
+			"create_time":    qutil.FormatDate(&now, qutil.Date_Full_Layout),
+			"original_price": original_price,
+			"filter_id":      mog_id,
+			"user_id":        userId,
+			"filter":         string(filterStr), //筛选
+			"dis_word":       disWord,           //分销口令
+			"discount_price": discount_price,
+			"d_relation_id":  userLotteryId,
+		}
+		orderid := util.Mysql.Insert("dataexport_order", insertMap)
+		if orderid == -1 {
+			return &entity.FuncResult{false, errors.New("数据库操作异常"), nil}
+		} else {
+			//绑定卡卷
+			if userLotteryId != "" && lotteryId != "" {
+				go func(userId, userLotteryId, order_code string) {
+					nickname, _ := this.Session().Get("s_nickname").(string)
+					if !util.UpdateCouponState(userId, userLotteryId, nickname, order_code, 3) {
+						log.Println(fmt.Sprintf("单号%s-绑定失败-卡卷%s", order_code, userLotteryId))
+					}
+				}(userId, userLotteryId, ordercode)
+			}
+		}
+		//支付提醒
+		util.MsgRemind.Add(qutil.IntAll(orderid), totalfee, -1, 0, ordercode, userId, now.Unix())
+		return &entity.FuncResult{true, nil, map[string]interface{}{"code": ordercode}}
+	}()
+	if r.Err != nil {
+		log.Printf("%s CreateOrder err:%v\n", userId, r.Err.Error())
+	}
+	this.ServeJson(r.Format())
+}
+
 func TimeProcessing(hour interface{}, duration int) time.Time {
 	todayZero, _ := time.ParseInLocation(DateFullLayout, fmt.Sprint(hour), time.Local)
 	mm, _ := time.ParseDuration(fmt.Sprint(duration) + "m")

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

@@ -279,7 +279,7 @@ func (this *TrialOrder) TrialPay() {
 		totalfee := 0
 		ordercode := pay.GetOrderCode(userId)
 		//存入订单表
-		buyset := entity.JyVipSubStruct.NewBuySet(area, industry)
+		buyset := entity.JyVipSubStruct.NewBuySet(area, industry, true) //试用用户
 		filter := entity.VipSimpleMsg{
 			Area:       area,
 			Industry:   industry,

+ 36 - 21
src/jfw/modules/subscribepay/src/subvip_price.json

@@ -1,26 +1,41 @@
 {
-  "month": {
-    "oneCity_oneBuyerClass": 580,
-    "oneCity_allBuyerClass": 1800,
-    "oneProvince_oneBuyerClass": 1180,
-    "oneProvince_allBuyerClass": 3800,
-    "allProvince_oneBuyerClass": 11800,
-    "allProvince_allBuyerClass": 38800
+  "old": {
+    "month": {
+      "oneCity_oneBuyerClass": 580,
+      "oneCity_allBuyerClass": 1800,
+      "oneProvince_oneBuyerClass": 1180,
+      "oneProvince_allBuyerClass": 3800,
+      "allProvince_oneBuyerClass": 11800,
+      "allProvince_allBuyerClass": 38800
+    },
+    "year": {
+      "oneCity_oneBuyerClass": 5800,
+      "oneCity_allBuyerClass": 18000,
+      "oneProvince_oneBuyerClass": 11800,
+      "oneProvince_allBuyerClass": 38000,
+      "allProvince_oneBuyerClass": 118000,
+      "allProvince_allBuyerClass": 388000
+    },
+    "cityPrice": 580,
+    "provincePrice": 1180,
+    "buyerClassPrice": 580,
+    "cityMaxCount": 2,
+    "provinceMaxCount": 9,
+    "buyerClassMaxCount": 3,
+    "monthMaxCount": 9
   },
-  "year": {
-    "oneCity_oneBuyerClass": 5800,
-    "oneCity_allBuyerClass": 18000,
-    "oneProvince_oneBuyerClass": 11800,
-    "oneProvince_allBuyerClass": 38000,
-    "allProvince_oneBuyerClass": 118000,
-    "allProvince_allBuyerClass": 388000
+  "new": {
+    "month": {
+      "oneProvince_allBuyerClass": 3800,
+      "allProvince_allBuyerClass": 59900
+    },
+    "year": {
+      "oneProvince_allBuyerClass": 38800,
+      "allProvince_allBuyerClass": 599900
+    },
+    "provincePrice": 3800,
+    "provinceMaxCount": 15,
+    "monthMaxCount": 9
   },
-  "cityPrice": 580,
-  "provincePrice": 1180,
-  "buyerClassPrice": 580,
-  "cityMaxCount": 2,
-  "provinceMaxCount": 9,
-  "buyerClassMaxCount": 3,
-  "monthMaxCount": 9,
   "discount": 1
 }

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

@@ -176,6 +176,7 @@ func syncVipUpgrade() {
 					},
 				})
 				log.Println("定时任务,同步vip升级数据成功", _id)
+				go jy.ClearBigVipUserPower(s_userid)
 			} else {
 				log.Println("定时任务,同步vip升级数据更新用户表失败", _id)
 			}
@@ -246,6 +247,7 @@ func checkIsExpire() {
 						}
 					}
 				}
+				go jy.ClearBigVipUserPower(_id)
 				log.Println("用户", _id, i_vip_status, l_vip_endtime, "修改已到期状态")
 				redis.Del("other", "p1_indexMessage_"+_id) //清除redis中vip状态
 			} else if l_vip_endtime-now_unix <= threeday && i_vip_expire_tip != 1 {

+ 9 - 0
src/web/staticres/vipsubscribe/css/vip_renew.css

@@ -707,3 +707,12 @@
 .origin-price .price-num {
   text-decoration: line-through;
 }
+
+.area-industry .item-container .item {
+  justify-content: flex-start;
+}
+.area-industry .item-container .item .item-r {
+  width: unset;
+  flex: 1;
+  justify-content: flex-start;
+}

+ 50 - 0
src/web/templates/weixin/vipsubscribe/vip_UpgradeDetail.html

@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html lang="zh-CN">
+
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport"
+          content="width=device-width, initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
+    <meta http-equiv="X-UA-Compatible" content="ie=edge">
+    <title>超级订阅续费</title>
+    <meta name="apple-mobile-web-app-capable" content="yes">
+    <meta name="apple-mobile-web-app-status-bar-style" content="black">
+    <script src="/vipsubscribe/js/rem.js"></script>
+    <link rel="stylesheet" type="text/css" href="/vipsubscribe/css/weui.min.css?v={{Msg "seo" "version"}}"/>
+    <link rel="stylesheet" type="text/css" href="/vipsubscribe/css/base2.css?v={{Msg "seo" "version"}}"/>
+    <link rel="stylesheet" type="text/css" href="/vipsubscribe/iconfont/iconfont.css?v={{Msg "seo" "version"}}"/>
+	<link rel="stylesheet" href="/vipsubscribe/css/public.css?v={{Msg "seo" "version"}}">
+    <link rel="stylesheet" type="text/css" href='/local/layout.css'/>
+    <link rel="stylesheet" type="text/css" href='/css/font.css?v={{Msg "seo" "version"}}'/>
+    <style>
+        .content {
+            height: 100%;
+            display: flex;
+            align-items: center;
+            justify-content: center;
+        }
+    </style>
+</head>
+<body class="no-touch"  data-weui-theme="light">
+    <div class="j-container">
+        <div class="j-body">
+            <div class="content">超级订阅升级版介绍</div>
+        </div>
+        <div class="footer j-button-group">
+            <button class="j-button-confirm">升级</button>
+        </div>
+    </div>
+<script src="/local/jquery.min.js"></script>
+<script src='/vipsubscribe/js/common.js?v={{Msg "seo" "version"}}'></script>
+<script src='/js/common.js?v={{Msg "seo" "mod_version"}}'></script>
+<script>
+$(function () {
+    $('.j-button-confirm').on('click', function () {
+        location.href = '/front/vipsubscribe/upgradePage'
+    })
+})
+</script>
+{{include "/common/baiducc.html"}}
+</body>
+
+</html>

+ 39 - 55
src/web/templates/weixin/vipsubscribe/vip_renew.html

@@ -47,58 +47,42 @@
             <span class="header-right">您的超级订阅服务即将到期,为不影响您的使用。请立即续费</span>
         </div>
         <div class="vip-body">
-             <div class="j-notice-bar bar-red vip-bar" style="text-align: center;">限时续费,3个月起,续多久送多久!</div>
+            <div class="j-notice-bar bar-red vip-bar" style="text-align: center;">限时续费,3个月起,续多久送多久!</div>
             <ul style="padding: .16rem .24rem;">
-                <li class="body-item area">
-                    <a class="item-container" href="/front/vipsubscribe/toChooseArea">
-                        <div class="item">
-                        <span class="item-l">
-                            <span class="item-label">区域</span>
-                        </span>
-                        <span class="item-r">
-                            <span class="selected-area-name ellipsis"></span>
-                            <span class="iconfont icon-arrow"></span>
-                        </span>
-                    </div>
-                    <div class="sub-item text selected-area"></div>
-                </a>
-            </li>
-            <li class="body-item industry">
-                <a class="item-container" href="/front/vipsubscribe/toChooseIndustry">
-                    <div class="item">
-                        <span class="item-l">
-                            <span class="item-label">采购单位行业</span>
-                        </span>
-                        <span class="item-r">
-                            <span class="selected-industry-name industry-text ellipsis"></span>
-                            <span class="iconfont icon-arrow"></span>
-                        </span>
-                    </div>
-                    <div class="sub-item text selected-industry-count"></div>
-                </a>
-            </li>
-            <li class="body-item select_cycle">
-                <a class="item-container" href="javascript:;">
-                    <div class="item">
-                        <span class="item-l">
-                            <span class="item-label">延长订阅周期</span>
-                        </span>
-                        <span class="item-r">
-                            <span class="buy-cycle text ellipsis">6个月</span>
-                            <span class="iconfont icon-arrow"></span>
-                        </span>
+                <li class="body-item area-industry">
+                    <div class="item-container">
+                        <div class="item area">
+                            <span class="item-l">区域:</span>
+                            <span class="item-r"></span>
+                        </div>
+                        <div class="item industry">
+                            <span class="item-l">行业:</span>
+                            <span class="item-r"></span>
+                        </div>
                     </div>
-                    <div class="sub-item text">
-                        <span class="sub-l">有效日期:</span>
-                        <span class="sub-r">
-                            <span class="ellipsis">
-                                (<span class="month">3个月</span>)<span class="duration"></span>
+                </li>
+                <li class="body-item select_cycle">
+                    <a class="item-container" href="javascript:;">
+                        <div class="item">
+                            <span class="item-l">
+                                <span class="item-label">延长订阅周期</span>
                             </span>
-                        </span>
-                    </div>
-                </a>
-            </li>
-        </ul>
+                            <span class="item-r">
+                                <span class="buy-cycle text ellipsis">6个月</span>
+                                <span class="iconfont icon-arrow"></span>
+                            </span>
+                        </div>
+                        <div class="sub-item text">
+                            <span class="sub-l">有效日期:</span>
+                            <span class="sub-r">
+                                <span class="ellipsis">
+                                    (<span class="month">3个月</span>)<span class="duration"></span>
+                                </span>
+                            </span>
+                        </div>
+                    </a>
+                </li>
+            </ul>
         <ul style="padding: 0 .24rem;display: none;" id="giveTimeBox">
                 <li class="body-item select_cycle">
                     <div class="item-container" href="javascript:;">
@@ -547,7 +531,7 @@
             showArea: function () {
                 if (!$.isEmptyObject(this.areaSelect) && !this.areaSelect["一个省"]) { //有选择
                     if (this.nowBuyset.areacount === -1) {
-                        $(".selected-area").text("全国");
+                        $(".area .item-r").text("全国");
                     } else {
                         var tipTxt = "";
                         if (this.nowBuyset.areacount > 0) tipTxt += this.nowBuyset.areacount + " 个省";
@@ -560,10 +544,10 @@
                             tipTxt += count + " 个市";
                             if (this.nowBuyset.citys.length > 1) tipTxt += "(分布在" + this.nowBuyset.citys.length + "个省内)"
                         }
-                        $(".selected-area").text(tipTxt);
+                        $(".area .item-r").text(tipTxt);
                     }
                 } else {
-                    $(".selected-area").text("");
+                    $(".area .item-r").text("");
                 }
             },
             showPrice: function () {
@@ -584,13 +568,13 @@
             showIndustry: function () {
                 if (this.industrySelect.length > 0 && this.industrySelect[0] != "一个行业") { //选择有行业信息
                     if (this.nowBuyset.buyerclasscount == -1) {
-                        $(".selected-industry-count").text("全部行业");
+                        $(".industry .item-r").text("全部行业");
                     } else {
                         var tipTxt = "";
-                        $(".selected-industry-count").text(tipTxt + this.nowBuyset.buyerclasscount + " 个行业");
+                        $(".industry .item-r").text(tipTxt + this.nowBuyset.buyerclasscount + " 个行业");
                     }
                 } else {
-                    $(".selected-industry-count").text("");
+                    $(".industry .item-r").text("");
                 }
             },
             showTime: function () {