Pārlūkot izejas kodu

Merge branch 'feature/v4.8.0' of http://192.168.3.207:8080/qmx/jy into feature/v4.8.0

tsz 2 gadi atpakaļ
vecāks
revīzija
d2edb15b62

+ 2 - 1
src/config.json

@@ -410,5 +410,6 @@
     "homeUrl": "/jySchool/strategy",
     "towUrl": "/jySchool/%s/index.html"
   },
-  "dataMarketShowAB": 0
+  "dataMarketShowAB": 0,
+  "activityApi": "http://127.0.0.1:8888"
 }

+ 3 - 2
src/config.yaml

@@ -1,7 +1,8 @@
 etcd:
   hosts:
-  - 192.168.3.149:2379
+  - 192.168.3.206:2379
 userCenterKey: "usercenter.rpc" #用户中台rpc
 powerCheckCenterKey: "powercheck.rpc" #权益校验中台
 resourceCenterKey: "resource.rpc" #资源中台
-entManageApplication: "entmanageapplication.rpc" #企业管理中台
+entManageApplication: "entmanageapplication.rpc" #企业管理中台
+activityKey: "activity.rpc" #营销中台rpc

+ 1 - 1
src/go.mod

@@ -3,6 +3,7 @@ module jy/src
 go 1.18
 
 require (
+	app.yhyue.com/moapp/jyMarketing v0.0.2-0.20230307011807-2ef7ef8e0c09
 	app.yhyue.com/moapp/jybase v0.0.0-20230117032034-ad7c00ffe11a
 	app.yhyue.com/moapp/jypkg v0.0.0-20230309102709-f1b34292afaa
 	bp.jydev.jianyu360.cn/BaseService/userCenter v1.2.13
@@ -16,7 +17,6 @@ require (
 
 require (
 	app.yhyue.com/moapp/esv1 v0.0.0-20220414031211-3da4123e648d // indirect
-	app.yhyue.com/moapp/jyMarketing v0.0.2-0.20230304035551-21bb1eedf547 // indirect
 	app.yhyue.com/moapp/message v0.0.0-20221223100203-6402e389d9ae // indirect
 	bp.jydev.jianyu360.cn/BaseService/entManageApplication v0.0.0-20230214091519-89a98c01ab0e // indirect
 	bp.jydev.jianyu360.cn/BaseService/powerCheckCenter v0.0.0-20230222052351-9d6fad062447 // indirect

+ 2 - 2
src/go.sum

@@ -1,7 +1,7 @@
 app.yhyue.com/moapp/esv1 v0.0.0-20220414031211-3da4123e648d h1:WPsYuuptAd3UEgN+jPzpnsDe/OvcshDUUtOTZPYGSJ8=
 app.yhyue.com/moapp/esv1 v0.0.0-20220414031211-3da4123e648d/go.mod h1:91/lSD/hS+ckMVP3WdidRzDhC60lLMdyce9QHy0cSMA=
-app.yhyue.com/moapp/jyMarketing v0.0.2-0.20230304035551-21bb1eedf547 h1:cCmWQW8DUBD2nuZNDz9aIe6MrlioxTbdaA2YiJhlzjY=
-app.yhyue.com/moapp/jyMarketing v0.0.2-0.20230304035551-21bb1eedf547/go.mod h1:JvIs8uKjdT963+7JnZGIEcL4ctBiBjwkoz0kNyigE78=
+app.yhyue.com/moapp/jyMarketing v0.0.2-0.20230307011807-2ef7ef8e0c09 h1:ckax2O7nHCFa0RD1qM7cUYaPNQQpR9j+kimXdyDOiQk=
+app.yhyue.com/moapp/jyMarketing v0.0.2-0.20230307011807-2ef7ef8e0c09/go.mod h1:JvIs8uKjdT963+7JnZGIEcL4ctBiBjwkoz0kNyigE78=
 app.yhyue.com/moapp/jyPoints v1.1.1/go.mod h1:SvP8p5L3jGrejHiH2LXfgCg/NPlFiKBC5Yd0gsI12FU=
 app.yhyue.com/moapp/jybase v0.0.0-20220427020729-974c1a148186/go.mod h1:qNRA0sHuYqcLoYoP8irpaWnW9YsXixe6obBIkwaXpD0=
 app.yhyue.com/moapp/jybase v0.0.0-20230117032034-ad7c00ffe11a h1:wD4aWPSYdiX1cIP4lzzPD2s7fYhKa3muIf97l9tonJE=

+ 113 - 11
src/jfw/jyutil/classroomiInfo.go

@@ -1,18 +1,26 @@
 package jyutil
 
 import (
+	"app.yhyue.com/moapp/jyMarketing/rpc/activity"
 	util "app.yhyue.com/moapp/jybase/common"
 	. "app.yhyue.com/moapp/jybase/date"
 	mgo "app.yhyue.com/moapp/jybase/mongodb"
 	"app.yhyue.com/moapp/jybase/redis"
 	"bytes"
+	"context"
 	"encoding/json"
 	"fmt"
+	"github.com/gogf/gf/v2/frame/g"
+	"github.com/gogf/gf/v2/os/gcfg"
+	"github.com/gogf/gf/v2/os/gctx"
+	"github.com/zeromicro/go-zero/core/discov"
+	"github.com/zeromicro/go-zero/zrpc"
 	"go.mongodb.org/mongo-driver/bson/primitive"
 	"html/template"
 	"io/ioutil"
 	"jy/src/jfw/config"
 	"log"
+	"math"
 	"math/rand"
 	"net/http"
 	"sort"
@@ -41,6 +49,7 @@ type HelpColumn struct {
 }
 
 func init() {
+	go ActivityInit()
 	log.Println("开始初始化column")
 	ColumnRelationship = make(map[string]Navigation)
 	industryInfoUrl, _ := config.Sysconfig["industryInfoUrl"].(map[string]interface{})
@@ -80,12 +89,45 @@ func init() {
 	}
 }
 
+var Activity activity.Activity
+
+// 活动初始化
+func ActivityInit() {
+	log.Println("开始初始化活动rpc")
+	g.Cfg().GetAdapter().(*gcfg.AdapterFile).SetFileName("config.yaml")
+	var ctx = gctx.New()
+	Activity = activity.NewActivity(zrpc.MustNewClient(zrpc.RpcClientConf{
+		Etcd: discov.EtcdConf{
+			Hosts: g.Cfg().MustGet(ctx, "etcd.hosts").Strings(),
+			Key:   g.Cfg().MustGet(ctx, "activityKey").String(),
+		},
+	}))
+}
+
+func ActivityData() map[string][]*activity.LotteryJson {
+	resp, err := Activity.GetAllLottery(context.Background(), &activity.Request{
+		AppId:       "10000",
+		ProductCode: "111",
+	})
+	log.Println(resp, err)
+	if err != nil {
+		log.Println("奖券获取失败")
+		return nil
+	}
+	lotteryMap := map[string][]*activity.LotteryJson{}
+	for _, activityValue := range resp.ActivityJson {
+		for _, lotteryValue := range activityValue.LotteryJson {
+			for _, productValue := range lotteryValue.UseProductList {
+				lotteryValue.UseProductList = []*activity.ProductJson{}
+				lotteryMap[productValue.ProductCode] = append(lotteryMap[productValue.ProductCode], lotteryValue)
+			}
+		}
+	}
+	return lotteryMap
+}
+
 // Course 剑鱼课堂首页课程 & 帮助中心热门视频 classify:0:中标比听课视频 1:帮助中心视频(获取所有)
 func Course(num, iType int) *[]map[string]interface{} {
-	if data := redis.Get("other", fmt.Sprintf("course_%d_%d", num, iType)); data != nil {
-		dataMap, _ := data.([]map[string]interface{})
-		return &dataMap
-	}
 	//热门课程
 	/*var HotCourse *[]map[string]interface{}
 	  hotQuery := map[string]interface{}{"i_type": 3, "i_status": 1, "l_endtime": map[string]interface{}{"$gt": time.Now().Unix()}, "l_publishtime": map[string]interface{}{"$lt": time.Now().Unix()}}
@@ -106,6 +148,7 @@ func Course(num, iType int) *[]map[string]interface{} {
 		num = -1
 	}
 	//最新课程
+	lotteryMap := ActivityData()
 	var LatestCourses *[]map[string]interface{}
 	latestQuery := map[string]interface{}{"i_type": iType, "i_status": 1, "l_endtime": map[string]interface{}{"$gt": time.Now().Unix()}, "l_publishtime": map[string]interface{}{"$lt": time.Now().Unix()}}
 	LatestCourses, _ = mongodb.Find("jy_course", latestQuery, `{"l_publishtime":-1}`, "", false, page, num)
@@ -118,6 +161,12 @@ func Course(num, iType int) *[]map[string]interface{} {
 			} else {
 				(*LatestCourses)[key]["isExpired"] = false
 			}
+			productPrice := util.Float64All(value["i_price"])
+			fool, discountPrice := OptimalSelection(util.InterfaceToStr(value["_id"]), productPrice, lotteryMap)
+			(*LatestCourses)[key]["isDiscount"] = fool
+			if fool {
+				(*LatestCourses)[key]["discountPrice"] = productPrice - discountPrice
+			}
 		}
 	}
 
@@ -141,11 +190,69 @@ func Course(num, iType int) *[]map[string]interface{} {
 	  	}
 	  }*/
 	//IdFormat(LatestCourses)
-	redis.Put("other", fmt.Sprintf("course_%d_%d", num, iType), *LatestCourses, 60*5)
-
 	return LatestCourses
 }
 
+// 奖券详情
+func OptimalSelection(id string, price float64, lotteryMap map[string][]*activity.LotteryJson) (bool, float64) {
+	discountPrice := float64(0)
+
+	lotteryStr := lotteryMap[id]
+	if lotteryStr == nil {
+		return false, discountPrice
+	}
+	for _, lottery := range lotteryStr {
+		lotteryType := lottery.LotteryType
+		full := util.Float64All(lottery.Full)
+		full *= 100
+		//类型:0满减、1折扣券、2满赠、3促销、4限时折扣、5限时减免
+		switch lotteryType {
+		case 1: //满折
+			if full <= price {
+				discount := util.Float64All(lottery.Discount)
+				preferential := (1 - discount/10) * price
+				preferential = math.Trunc(preferential*1e0 + 0.5)
+				if preferential > discountPrice {
+					discountPrice = preferential
+				}
+			}
+			break
+		case 3: //3促销
+			promotionalPrice := util.Float64All(lottery.PromotionalPrice)
+			if util.Float64All(price-promotionalPrice) > discountPrice {
+				discountPrice = util.Float64All(price - promotionalPrice)
+			}
+			break
+		case 4: //4限时折扣
+			discount := util.Float64All(lottery.Discount)
+			preferential := (1 - discount/10) * price
+			preferential = math.Trunc(preferential*1e0 + 0.5)
+			if preferential > discountPrice {
+				discountPrice = preferential
+			}
+			break
+		case 5: //5限时减免
+			reduce := util.Float64All(lottery.Reduce)
+			if reduce > discountPrice {
+				discountPrice = reduce
+			}
+			break
+		default:
+			if full <= price {
+				reduce := util.Float64All(lottery.Reduce) * 100
+				if reduce > discountPrice {
+					discountPrice = reduce
+				}
+			}
+			break
+		}
+	}
+	if discountPrice > 0 {
+		return true, discountPrice
+	}
+	return false, discountPrice
+}
+
 // Library 文库
 func Library(num int) (map[string]interface{}, error) {
 	if data := redis.Get("other", fmt.Sprintf("library_%d", num)); data != nil {
@@ -213,10 +320,6 @@ func FormatSize(size float64, unit string) string {
 
 // GuidelineAndInformation t:一级栏目 s二级栏目 (首页剑鱼攻略与行业资讯首页公用)
 func GuidelineAndInformation(t, s string, num int) *[]map[string]interface{} {
-	if data := redis.Get("other", fmt.Sprintf("guideline_information_%d_%s_%s", num, t, s)); data != nil {
-		dataMap, _ := data.([]map[string]interface{})
-		return &dataMap
-	}
 	query := map[string]interface{}{"s_contenttype": t, "s_secondclassifytype": s, "i_status": 1, "releasetime": map[string]interface{}{"$lt": time.Now().Unix()}}
 	data, _ := mongodb.Find("content", query, `{"releasetime":-1,"l_createdate":-1}`, `{"_id":1,"i_viewnum":1,s_title":1,"s_pic1":1,"s_pic":1,"releasetime":1,"s_description":1,"l_createdate":1,"s_contenttype":1,"s_secondclassifytype":1}`, false, 0, num)
 	if data != nil {
@@ -234,7 +337,6 @@ func GuidelineAndInformation(t, s string, num int) *[]map[string]interface{} {
 			v["s_pic1"] = SPic(util.InterfaceToStr(v["s_pic1"]))
 		}
 	}
-	redis.Put("other", fmt.Sprintf("guideline_information_%d_%s_%s", num, t, s), *data, 5*60)
 	//IdFormat(data)
 	return data
 }

+ 3 - 0
src/web/staticres/site/page/helpCenter/css/feedback.css

@@ -94,4 +94,7 @@
   text-align: center;
   font-size: 16px;
   color: #fff;
+}
+.f-btn[disabled]{
+  cursor: not-allowed;
 }

+ 5 - 4
src/web/staticres/site/page/helpCenter/css/index.css

@@ -88,6 +88,9 @@
   font-size: 16px;
   line-height: 24px;
   color: #1D1D1D;
+  white-space: nowrap;
+  overflow: hidden;
+  text-overflow: ellipsis;
 }
 .card .list-middle > a:hover{
   color: #2ABED1;
@@ -187,11 +190,9 @@
   font-size: 16px;
   color: #fff;
   text-align: center;
+  cursor: pointer;
 }
-.feedback .feedback-btn:hover,
-.feedback .feedback-btn:active{
-  color: #fff;
-}
+
 .hot-handel{
   padding: 80px 0;
 }

+ 1 - 0
src/web/staticres/site/page/helpCenter/css/summary.css

@@ -33,6 +33,7 @@ body{
   line-height: 22px;
   color: #686868;
   cursor: pointer;
+  word-break: break-all;
 }
 .s-tree .tree-item:hover{
   color:#2ABED1;

+ 4 - 0
src/web/staticres/site/page/jySchool/css/index.css

@@ -226,6 +226,10 @@
   line-height: 22px;
   color: #FF3A20;
 }
+.card-main .expired{
+  color: #686868;
+  font-size: 14px;
+}
 .course-card:hover .card-main .c-m-title{
   color: #2ABED1;
 }

+ 1 - 2
src/web/templates/site/common/pc-school-head.html

@@ -1,5 +1,4 @@
-<!-- <link rel="stylesheet" href='{{Msg "seo" "cdn"}}/site/common/css/pc-school-head.css?v={{Msg "seo" "version"}}'> -->
-<link rel="stylesheet" href='{{Msg "seo" "cdn"}}/public-pc/css/header-nav.css?v={{Msg "seo" "version"}}'>
+<link rel="stylesheet" href='{{Msg "seo" "cdn"}}/site/common/css/pc-school-head.css?v={{Msg "seo" "version"}}'>
 <link rel="stylesheet" href='{{Msg "seo" "cdn"}}/common-module/ad/css/index.css?v={{Msg "seo" "version"}}'>
 
 <section class="public-nav" id="public-nav" style="display: none">

+ 15 - 2
src/web/templates/site/page/helpCenter/feedback.html

@@ -72,6 +72,14 @@
         $('.entered-count').text($(this).val().length)
       })
       $('#submit').on('click',function (){
+        if ($('#textarea').val().length < 10) {
+          showToast('请至少填写10个字的反馈,谢谢')
+          $(this).attr("disabled","disabled")
+          setTimeout(function() {
+            $('#submit').removeAttr('disabled')
+          }, 2000)
+          return
+        }
         $(this).attr("disabled","disabled")
         let content=$("textarea").val()
         let mold=$("[name='type']:checked").val()
@@ -79,9 +87,14 @@
           {mold:mold,content:content},
           function (res){
             if(res.data){
-              window.history.go(-1)
+              showToast('提交成功')
+              setTimeout(function() {
+                $('#submit').removeAttr('disabled')
+                $('#textarea').val('')
+                $('#account').prop('checked', 'checked')
+              }, 2000)
             }else {
-              alert(res.error_msg)
+              showToast(res.error_msg)
             }
         })
       })

+ 11 - 3
src/web/templates/site/page/helpCenter/index.html

@@ -56,9 +56,9 @@
             <ul class="f-content">
               {{range $kk,$vv:=$v.SeedData}}
               <li>
-                <a href="{{$vv.Href}}" title="{{$vv.Name}}">•  {{$vv.Name}}</a>
+                <a href="{{$vv.Href}}" title="{{$vv.Name}}" target="_blank">•  {{$vv.Name}}</a>
                 {{if eq (Add $kk 1) (len $v.SeedData)}}
-                <a class="faq-more" href="{{$v.Href}}">更多</a>
+                <a class="faq-more" href="{{$v.Href}}" target="_blank">更多</a>
                 {{end}}
               </li>
               {{end}}
@@ -69,7 +69,7 @@
           <div class="feedback">
             <h3 class="f-title">意见反馈</h3>
             <div class="f-content">请把您的意见与建议反馈给我们</div>
-            <a class="feedback-btn" target="_blank" href="/helpCenter/feedback">立即反馈</a>
+            <span class="feedback-btn" data-href="/helpCenter/feedback">立即反馈</span>
           </div>
         </div>
         <div class="hot-handel">
@@ -114,6 +114,14 @@
           }
         }
       })
+      $('.feedback-btn').on('click', function() {
+        if (!loginflag){
+          openLoginDig()
+        } else {
+          var url = $(this).attr('data-href')
+          window.open(url)
+        }
+      })
     })
   </script>
   {{include "/common/baiducc.html"}}

+ 7 - 3
src/web/templates/site/page/jySchool/index.html

@@ -68,10 +68,14 @@
               </p>
               <p class="c-m-cp">
                 <span class="hot-count">{{$v.i_clickRate}}</span>
-                {{if eq $v.i_price 0}}
-                <span class="hot-price">免费</span>
+                {{if $v.isExpired}}
+                <span class="expired">已过期</span>
                 {{else}}
-                <span class="hot-price" style="font-size:18px;line-height: 28px;"><em style="font-size:12px;line-height: 18px;">¥</em>{{Division $v.i_price 100}}</span>
+                  {{if eq $v.i_price 0}}
+                  <span class="hot-price">免费</span>
+                  {{else}}
+                  <span class="hot-price" style="font-size:18px;line-height: 28px;"><em style="font-size:12px;line-height: 18px;">¥</em>{{Division $v.i_price 100}}</span>
+                  {{end}}
                 {{end}}
               </p>
             </div>