Browse Source

fix:productCode配置添加

duxin 3 years ago
parent
commit
183fa430e0
4 changed files with 65 additions and 4 deletions
  1. 0 1
      config/config.go
  2. 19 1
      etc/config.yaml
  3. 22 2
      handler/activity/lotteryService.go
  4. 24 0
      rpc/integral.go

+ 0 - 1
config/config.go

@@ -46,7 +46,6 @@ var (
 type LotteryReceiveReq struct {
 	UserName     string `json:"userName"`
 	UserId       string `json:"userId"`
-	AppId        string `json:"appId"`
 	LotteryIdArr string `json:"lotteryIdArr"`
 }
 type pushConfig struct {

+ 19 - 1
etc/config.yaml

@@ -12,6 +12,14 @@ etcd:
       address:
         - 192.168.3.206:2379
 
+    # 销售服务
+    activeServer:
+      # 销售中台配置
+      integral:
+        key: activity.rpc
+        address:
+          - 192.168.3.206:2379
+
 #消息队列
 nsq:
   topic: jy_event
@@ -99,4 +107,14 @@ jyactivity: # 临时活动
       limit: 500 #每日数量限制
 
 #优惠券领取及查询接口
-lotteryUrl: https://192.168.3.206:8090
+lotteryUrl: http://192.168.3.206:8090
+
+#优惠券Rpc查询接口
+lotteryRpcUrl: 192.168.3.206:8090
+
+productCode:
+  subscription: 101
+  subscriptionWeek: 1011
+  subscriptionMonth: 1012
+  subscriptionQuarter: 1013
+  subscriptionYear: 1014

+ 22 - 2
handler/activity/lotteryService.go

@@ -14,8 +14,10 @@ import (
 )
 
 //ActivityLottery 获取活动下的奖券 receivingLocation 奖券形式0落地页 1付款页 999全部 3 我的奖券 productCode 活动code
-func ActivityLottery(userId, appId, receivingLocation, productCode string) (map[string]interface{}, error) {
+func ActivityLottery(userId, receivingLocation string) (map[string]interface{}, error) {
 	//url := config.PushConfig.ActivityUrl + "/activityLottery?userId=" + userId + "&appId=" + appId + "&activityId=" + activityId + "&receivingLocation=" + receivingLocation + "&productCode=" + productCode
+	appId := gcfg.Instance().MustGet(gctx.New(), "appid").String()
+	productCode := gcfg.Instance().MustGet(gctx.New(), "productCode.subscriptionMonth").String()
 	url := gcfg.Instance().MustGet(gctx.New(), "lotteryUrl").String() + "/activityLottery?userId=" + userId + "&appId=" + appId + "&receivingLocation=" + receivingLocation + "&productCode=" + productCode
 
 	log.Println(url)
@@ -36,10 +38,28 @@ func ActivityLottery(userId, appId, receivingLocation, productCode string) (map[
 	return info, err
 }
 
+//ActivityUser
+/*func ActivityUser(userId string, model int64) []*activityclient.LotteryJson {
+	appId := gcfg.Instance().MustGet(gctx.New(), "appid").String()
+	//参数结构体
+	activeReq := activityclient.Request{
+		ReceivingLocation: 0,
+		Model:             model,
+		UserId:            userId,
+		AppId:             appId,
+	}
+	//调用卡卷中台rpc  查询此用户下的卡卷信息
+	rpc.UserHarvest = &rpc.UserLottery{}
+	resp := rpc.UserHarvest.HarvestFunc(activeReq)
+	return resp.Data
+}*/
+
 //LotteryReceive 奖卷领取 LotteryIdArr 奖券id 支持多个逗号拼接
 func LotteryReceive(lotteryRep config.LotteryReceiveReq) (int, string) {
+	appId := gcfg.Instance().MustGet(gctx.New(), "appid").String()
+
 	userNameStr := url2.PathEscape(lotteryRep.UserName)
-	url := gcfg.Instance().MustGet(gctx.New(), "lotteryUrl").String() + "/lotteryReceive?userName=" + userNameStr + "&userId=" + lotteryRep.UserId + "&appId=" + lotteryRep.AppId + "&lotteryIdArr=" + lotteryRep.LotteryIdArr
+	url := gcfg.Instance().MustGet(gctx.New(), "lotteryUrl").String() + "/lotteryReceive?userName=" + userNameStr + "&userId=" + lotteryRep.UserId + "&appId=" + appId + "&lotteryIdArr=" + lotteryRep.LotteryIdArr
 	log.Println(url)
 	request, err := http.NewRequest("POST", url, nil)
 	if err != nil {

+ 24 - 0
rpc/integral.go

@@ -1,10 +1,12 @@
 package rpc
 
 import (
+	"app.yhyue.com/moapp/jyMarketing/rpc/activityclient"
 	"app.yhyue.com/moapp/jyPoints/rpc/integral"
 	"app.yhyue.com/moapp/jyPoints/rpc/integralclient"
 	"app.yhyue.com/moapp/jybase/date"
 	"app.yhyue.com/moapp/jybase/go-logger/logger"
+	"context"
 	"fmt"
 	"github.com/gogf/gf/v2/os/gcfg"
 	"github.com/gogf/gf/v2/os/gctx"
@@ -15,6 +17,7 @@ import (
 )
 
 var zrpcClient zrpc.Client
+var activeLib activityclient.Activity
 
 func init() {
 	var err error
@@ -27,6 +30,15 @@ func init() {
 	if err != nil {
 		log.Fatalln(err)
 	}
+
+	client := zrpc.MustNewClient(zrpc.RpcClientConf{
+		Etcd: discov.EtcdConf{
+			Hosts: gcfg.Instance().MustGet(gctx.New(), "etcd.activeServer.integral.address", nil).Strings(),
+			Key:   gcfg.Instance().MustGet(gctx.New(), "etcd.activeServer.integral.key", nil).String(),
+		},
+	})
+	// defer client.Conn().Close()
+	activeLib = activityclient.NewActivity(client)
 }
 
 // IntegralHarvest 积分奖励发放
@@ -51,3 +63,15 @@ func IntegralHarvest(userId string, pNum, pType, dateStamp int64) error {
 		return fmt.Errorf(fmt.Sprintf("%+v", req), "增加", pNum, "积分失败", "Code", resp.Code, "Message", resp.Message)
 	}
 }
+
+type UserLottery struct{}
+
+var UserHarvest *UserLottery
+
+func (this *UserLottery) HarvestFunc(activeReq activityclient.Request) (resp activityclient.ActivityLotteryResp) {
+	_resp, err := activeLib.UserLottery(context.Background(), &activeReq)
+	if err != nil {
+		log.Println("UserHarvest error:", err)
+	}
+	return *_resp
+}