WH01243 4 سال پیش
والد
کامیت
072ef3f5d6

+ 33 - 16
api/activity.api

@@ -9,6 +9,7 @@ type Request {
 	Model         int64  `form:"model,optional"`         //1查看名下所有奖券 0查看可以使用的奖券(没有过期的) 2过期的奖券
 	UserName      string `form:"userName,optional"`      //用户名称
 	UserLottertId int64  `form:"userLottertId,optional"` //用户奖券标识
+	LotteryId     int64  `form:"lotteryId,optional"`
 }
 
 type LotteryOperation {
@@ -40,22 +41,22 @@ type ActivityLotteryResp {
 	Activity ActivityJson   `form:"Activity"` //活动信息
 }
 type LotteryJson {
-	LotteryId        int64  `form:"lotteryId"`        //奖券Id
-	LotteryName      string `form:"lotteryName"`      //奖券名字
-	LotteryBeginDate string `form:"lotteryBeginDate"` //活动时间起
-	LotteryendDate   string `form:"lotteryendDate"`   //活动时间止
-	IsReceive        bool   `form:"isReceive"`        //是否领取
-	UseProductList   string `form:"useProductList"`   //使用商品列表
-	Full             int64  `form:"full"`             //满多少
-	Reduce           int64  `form:"reduce"`           //减多少
-	Instructions     string `form:"instructions"`     //使用说明
-	Remark           string `form:"remark"`           //备注
-	UserLotteryId    int64  `form:"userLotteryId"`    //用户奖券标识
-	UseDate          string `form:"useDate"`          //使用时间
-	StockNumber      int64  `form:"stockNumber"`      //库存数
-	ReceiveNumber    int64  `form:"receiveNumber"`    //领取数
-	ValidityDates    int64  `form:"validityDates"`    //有效天数
-	ValidityTimeType int64  `form:"validityTimeType"` //有效时间类型0、有起止时间1、当天起几天可用2、次日起几天可用
+	LotteryId        int64         `form:"lotteryId"`        //奖券Id
+	LotteryName      string        `form:"lotteryName"`      //奖券名字
+	LotteryBeginDate string        `form:"lotteryBeginDate"` //活动时间起
+	LotteryendDate   string        `form:"lotteryendDate"`   //活动时间止
+	IsReceive        bool          `form:"isReceive"`        //是否领取
+	UseProductList   []ProductJson `form:"useProductList"`   //使用商品列表
+	Full             int64         `form:"full"`             //满多少
+	Reduce           int64         `form:"reduce"`           //减多少
+	Instructions     string        `form:"instructions"`     //使用说明
+	Remark           string        `form:"remark"`           //备注
+	UserLotteryId    int64         `form:"userLotteryId"`    //用户奖券标识
+	UseDate          string        `form:"useDate"`          //使用时间
+	StockNumber      int64         `form:"stockNumber"`      //库存数
+	ReceiveNumber    int64         `form:"receiveNumber"`    //领取数
+	ValidityDates    int64         `form:"validityDates"`    //有效天数
+	ValidityTimeType int64         `form:"validityTimeType"` //有效时间类型0、有起止时间1、当天起几天可用2、次日起几天可用
 }
 type ActivityJson {
 	ActivityName      string `form:"activityName"`      //活动名字
@@ -63,6 +64,19 @@ type ActivityJson {
 	ActivityendDate   string `form:"activityendDate"`   //活动时间止
 	ActivityDesc      string `form:"activityDesc"`      //活动描述
 }
+type ProductJson {
+	ProductName string `xorm:"productName" form:"productName" json:"productName"` //产品名称
+	PcPage      string `xorm:"pcPage" form:"pcPage" json:"pcPage"`                //pc端产品推广页地址
+	WxPage      string `xorm:"wxPage" form:"wxPage" json:"wxPage"`                //wx端产品推广页地址
+	AppPage     string `xorm:"appPage" form:"appPage" json:"appPage"`             //app端产品推广页地址
+	Describe    string `xorm:"describe" form:"describe" json:"describe"`          //描述
+}
+
+type LotteryResp {
+	Code    int64       `form:"code"`     //响应代码
+	Message string      `form:"message"`  //响应消息
+	Data    LotteryJson `form:"Activity"` //活动信息
+}
 service activity-api {
 	//查询活动下的奖券
 	@handler activityLotteryCheckHandler // TODO: set handler name and delete this comment
@@ -79,4 +93,7 @@ service activity-api {
 	//奖券使用
 	@handler activityUseCheckHandler // TODO: set handler name and delete this comment
 	post /activityUse (LotteryOperation) returns(Response)
+	//奖券详情
+	@handler lotteryInfoCheckHandler // TODO: set handler name and delete this comment
+	get /lotteryInfo (Request) returns(LotteryResp)
 }

+ 29 - 0
api/internal/handler/lotteryinfocheckhandler.go

@@ -0,0 +1,29 @@
+package handler
+
+import (
+	"net/http"
+
+	"app.yhyue.com/moapp/jyMarketing/api/internal/logic"
+	"app.yhyue.com/moapp/jyMarketing/api/internal/svc"
+	"app.yhyue.com/moapp/jyMarketing/api/internal/types"
+
+	"github.com/tal-tech/go-zero/rest/httpx"
+)
+
+func lotteryInfoCheckHandler(ctx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.Request
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.Error(w, err)
+			return
+		}
+
+		l := logic.NewLotteryInfoCheckLogic(r.Context(), ctx)
+		resp, err := l.LotteryInfoCheck(req)
+		if err != nil {
+			httpx.Error(w, err)
+		} else {
+			httpx.OkJson(w, resp)
+		}
+	}
+}

+ 5 - 0
api/internal/handler/routes.go

@@ -37,6 +37,11 @@ func RegisterHandlers(engine *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/activityUse",
 				Handler: activityUseCheckHandler(serverCtx),
 			},
+			{
+				Method:  http.MethodGet,
+				Path:    "/lotteryInfo",
+				Handler: lotteryInfoCheckHandler(serverCtx),
+			},
 		},
 	)
 }

+ 1 - 1
api/internal/logic/activitylotterychecklogic.go

@@ -44,7 +44,7 @@ func (l *ActivityLotteryCheckLogic) ActivityLotteryCheck(req types.Request) (*ty
 		userLottery.LotteryBeginDate=value.LotteryBeginDate
 		userLottery.LotteryendDate=value.LotteryendDate
 		userLottery.IsReceive=value.IsReceive
-		userLottery.UseProductList = value.UseProductList
+		//userLottery.UseProductList = value.UseProductList
 		userLottery.StockNumber=value.StockNumber
 		userLottery.ReceiveNumber=value.ReceiveNumber
 		userLottery.Instructions=value.Instructions

+ 61 - 0
api/internal/logic/lotteryinfochecklogic.go

@@ -0,0 +1,61 @@
+package logic
+
+import (
+	"app.yhyue.com/moapp/jyMarketing/rpc/activity"
+	"context"
+
+	"app.yhyue.com/moapp/jyMarketing/api/internal/svc"
+	"app.yhyue.com/moapp/jyMarketing/api/internal/types"
+
+	"github.com/tal-tech/go-zero/core/logx"
+)
+
+type LotteryInfoCheckLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewLotteryInfoCheckLogic(ctx context.Context, svcCtx *svc.ServiceContext) LotteryInfoCheckLogic {
+	return LotteryInfoCheckLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *LotteryInfoCheckLogic) LotteryInfoCheck(req types.Request) (*types.LotteryResp, error) {
+	result := &types.LotteryResp{}
+	lsi := l.svcCtx.Activity
+	resp, err := lsi.LotteryInfo(l.ctx, &activity.Request{
+		UserId:    req.UserId,
+		AppId:     req.AppId,
+		LotteryId: req.LotteryId,
+	})
+	if err != nil {
+		return nil, err
+	}
+	data:=resp.Data
+	var userLottery types.LotteryJson
+	userLottery.Full = data.Full
+	userLottery.Reduce = data.Reduce
+	userLottery.LotteryBeginDate = data.LotteryBeginDate
+	userLottery.LotteryendDate = data.LotteryendDate
+	userLottery.LotteryName = data.LotteryName
+	for _, value := range data.UseProductList {
+		productJson:=types.ProductJson{}
+		productJson.AppPage = value.AppPage
+		productJson.ProductName = value.ProductName
+		productJson.WxPage = value.WxPage
+		productJson.PcPage = value.PcPage
+		userLottery.UseProductList=append(userLottery.UseProductList,productJson)
+	}
+	userLottery.Instructions = data.Instructions
+	userLottery.Remark = data.Remark
+	userLottery.LotteryId = data.LotteryId
+	userLottery.UseDate = data.UseDate
+	result.Code=resp.Code
+	result.Message = resp.Message
+	result.Data = userLottery
+	return result, nil
+}

+ 1 - 1
api/internal/logic/userlotterychecklogic.go

@@ -44,7 +44,7 @@ func (l *UserLotteryCheckLogic) UserLotteryCheck(req types.Request) (*types.Acti
 		userLottery.Full = value.Full
 		userLottery.LotteryId = value.LotteryId
 		userLottery.LotteryName = value.LotteryName
-		userLottery.UseProductList = value.UseProductList
+		//userLottery.UseProductList = value.UseProductList
 		userLottery.UserLotteryId = value.UserLotteryId
 		userLottery.UseDate = value.UseDate
 		userLottery.Instructions=value.Instructions

+ 31 - 16
api/internal/types/types.go

@@ -10,6 +10,7 @@ type Request struct {
 	Model         int64  `form:"model,optional"`         //1查看名下所有奖券 0查看可以使用的奖券(没有过期的) 2过期的奖券
 	UserName      string `form:"userName,optional"`      //用户名称
 	UserLottertId int64  `form:"userLottertId,optional"` //用户奖券标识
+	LotteryId     int64  `form:"lotteryId,optional"`
 }
 
 type LotteryOperation struct {
@@ -44,22 +45,22 @@ type ActivityLotteryResp struct {
 }
 
 type LotteryJson struct {
-	LotteryId        int64  `form:"lotteryId"`        //奖券Id
-	LotteryName      string `form:"lotteryName"`      //奖券名字
-	LotteryBeginDate string `form:"lotteryBeginDate"` //活动时间起
-	LotteryendDate   string `form:"lotteryendDate"`   //活动时间止
-	IsReceive        bool   `form:"isReceive"`        //是否领取
-	UseProductList   string `form:"useProductList"`   //使用商品列表
-	Full             int64  `form:"full"`             //满多少
-	Reduce           int64  `form:"reduce"`           //减多少
-	Instructions     string `form:"instructions"`     //使用说明
-	Remark           string `form:"remark"`           //备注
-	UserLotteryId    int64  `form:"userLotteryId"`    //用户奖券标识
-	UseDate          string `form:"useDate"`          //使用时间
-	StockNumber      int64  `form:"stockNumber"`      //库存数
-	ReceiveNumber    int64  `form:"receiveNumber"`    //领取数
-	ValidityDates    int64  `form:"validityDates"`    //有效天数
-	ValidityTimeType int64  `form:"validityTimeType"` //有效时间类型0、有起止时间1、当天起几天可用2、次日起几天可用
+	LotteryId        int64         `form:"lotteryId"`        //奖券Id
+	LotteryName      string        `form:"lotteryName"`      //奖券名字
+	LotteryBeginDate string        `form:"lotteryBeginDate"` //活动时间起
+	LotteryendDate   string        `form:"lotteryendDate"`   //活动时间止
+	IsReceive        bool          `form:"isReceive"`        //是否领取
+	UseProductList   []ProductJson `form:"useProductList"`   //使用商品列表
+	Full             int64         `form:"full"`             //满多少
+	Reduce           int64         `form:"reduce"`           //减多少
+	Instructions     string        `form:"instructions"`     //使用说明
+	Remark           string        `form:"remark"`           //备注
+	UserLotteryId    int64         `form:"userLotteryId"`    //用户奖券标识
+	UseDate          string        `form:"useDate"`          //使用时间
+	StockNumber      int64         `form:"stockNumber"`      //库存数
+	ReceiveNumber    int64         `form:"receiveNumber"`    //领取数
+	ValidityDates    int64         `form:"validityDates"`    //有效天数
+	ValidityTimeType int64         `form:"validityTimeType"` //有效时间类型0、有起止时间1、当天起几天可用2、次日起几天可用
 }
 
 type ActivityJson struct {
@@ -68,3 +69,17 @@ type ActivityJson struct {
 	ActivityendDate   string `form:"activityendDate"`   //活动时间止
 	ActivityDesc      string `form:"activityDesc"`      //活动描述
 }
+
+type ProductJson struct {
+	ProductName string `xorm:"productName" form:"productName" json:"productName"` //产品名称
+	PcPage      string `xorm:"pcPage" form:"pcPage" json:"pcPage"`                //pc端产品推广页地址
+	WxPage      string `xorm:"wxPage" form:"wxPage" json:"wxPage"`                //wx端产品推广页地址
+	AppPage     string `xorm:"appPage" form:"appPage" json:"appPage"`             //app端产品推广页地址
+	Describe    string `xorm:"describe" form:"describe" json:"describe"`          //描述
+}
+
+type LotteryResp struct {
+	Code    int64       `form:"code"`     //响应代码
+	Message string      `form:"message"`  //响应消息
+	Data    LotteryJson `form:"Activity"` //活动信息
+}

+ 1 - 1
entity/activity.go

@@ -93,7 +93,7 @@ type UserPrizeJson struct {
 	Name           string      `xorm:"name" form:"name" json:"name"`                               //奖券名字
 	Full           int64       `xorm:"full" form:"full" json:"full"`                               //满多少
 	Reduce         int64       `xorm:"reduce" form:"reduce" json:"reduce"`                         //减多少
-	UseProductList []*ProductJson `xorm:"useProductList" form:"useProductList" json:"useProductList"` //使用商品列表
+	UseProductList []ProductJson `xorm:"useProductList" form:"useProductList" json:"useProductList"` //使用商品列表
 	Instructions   string      `xorm:"instructions" form:"instructions" json:"instructions"`       //使用说明
 	Remark         string      `xorm:"remark" form:"remark" json:"remark"`                         //备注
 }

+ 1 - 3
rpc/internal/logic/activitylotterylogic.go

@@ -37,14 +37,12 @@ func (l *ActivityLotteryLogic) ActivityLottery(in *activity.Request) (*activity.
 				userLottery.IsReceive=false
 			}
 		}
-		userLottery.UseProductList=value.UseProductList
+		//userLottery.UseProductList=value.UseProductList
 		userLottery.Instructions=value.Instructions
 		userLottery.StockNumber=value.StockNumber
 		userLottery.ReceiveNumber=value.ReceiveNumber
-		userLottery.UseProductList = value.UseProductList
 		userLottery.LotteryBeginDate=value.BeginDate
 		userLottery.LotteryendDate=value.EndDate
-		userLottery.UseProductList=value.UseProductList
 		userLottery.ValidityTimeType=int64(value.ValidityTimeType)
 		userLottery.ValidityDates=int64(value.ValidityDates)
 		userLottery.Full=value.Full

+ 11 - 9
rpc/internal/logic/lotteryinfologic.go

@@ -24,21 +24,23 @@ func NewLotteryInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Lotte
 }
 
 // 奖券对应的商品信息
-func (l *LotteryInfoLogic) LotteryInfo(in *activity.Request) (*activity.LotteryInfoReq, error) {
+func (l *LotteryInfoLogic) LotteryInfo(in *activity.Request) (*activity.LotteryResp, error) {
 	// todo: add your logic here and delete this line
-	result := &activity.LotteryInfoReq{}
+	result := &activity.LotteryResp{}
 	code, msg, data := activityService.LotteryInfo(in)
-	var userLottery *activity.LotteryJson
+	var userLottery activity.LotteryJson
 	userLottery.Full = data.Full
 	userLottery.Reduce = data.Reduce
 	userLottery.LotteryBeginDate = data.BeginDate
 	userLottery.LotteryendDate = data.EndDate
 	userLottery.LotteryName = data.Name
-	for key, value := range data.UseProductList {
-		userLottery.UseProductList[key].AppPage = (*value).AppPage
-		userLottery.UseProductList[key].ProductName = (*value).ProductName
-		userLottery.UseProductList[key].WxPage = (*value).WxPage
-		userLottery.UseProductList[key].PcPage = (*value).PcPage
+	for _, value := range data.UseProductList {
+		productJson:=activity.ProductJson{}
+		productJson.AppPage = value.AppPage
+		productJson.ProductName = value.ProductName
+		productJson.WxPage = value.WxPage
+		productJson.PcPage = value.PcPage
+		userLottery.UseProductList=append(userLottery.UseProductList,&productJson)
 	}
 	userLottery.UserLotteryId = data.Id
 	userLottery.Instructions = data.Instructions
@@ -48,6 +50,6 @@ func (l *LotteryInfoLogic) LotteryInfo(in *activity.Request) (*activity.LotteryI
 	userLottery.CreateTime = data.CreateTime.Format("2006-01-02 15:04:05")
 	result.Code = code
 	result.Message = msg
-	result.Data = userLotteryList
+	result.Data = &userLottery
 	return result, nil
 }

+ 1 - 1
rpc/internal/logic/userlotterylogic.go

@@ -37,7 +37,7 @@ func (l *UserLotteryLogic) UserLottery(in *activity.Request) (*activity.Activity
 		userLottery.LotteryBeginDate = value.BeginDate
 		userLottery.LotteryendDate = value.EndDate
 		userLottery.LotteryName = value.Name
-		userLottery.UseProductList = value.UseProductList
+		//userLottery.UseProductList = value.UseProductList
 		userLottery.UserLotteryId=value.Id
 		userLottery.Instructions=value.Instructions
 		userLottery.Remark=value.Remark

+ 9 - 0
rpc/test/test1_test.go

@@ -67,6 +67,15 @@ func Test_userLotteryState(t *testing.T)  {
 	log.Println("err ", err)
 	log.Println("req ", res)
 }
+//奖券基本信息
+func Test_LotteryInfo(t *testing.T)  {
+	ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
+	FileSystem :=activityclient.NewActivity(zrpc.MustNewClient(c.FileSystemConf))
+	req := &activity.Request{UserId: "ABC", AppId: "10000",LotteryId:56,Model:0}
+	res, err := FileSystem.LotteryInfo(ctx, req)
+	log.Println("err ", err)
+	log.Println("req ", res)
+}
 func Test_timme(t *testing.T)  {
 	tn:= time.Now().Format("2006-01-02 15:04:05")
 	fmt.Println(tn)

+ 5 - 6
service/ActivityService.go

@@ -410,9 +410,9 @@ func (service *ActivityService) LotteryStateChange(data *activity.UpdateStateReq
 	}
 }
 //查询奖券对应的产品信息
-func (service *ActivityService)LotteryProduct(data *activity.Request) (int64, string, []*entity.ProductJson) {
+func (service *ActivityService)LotteryProduct(data *activity.Request) (int64, string, []entity.ProductJson) {
 	orm := entity.Engine.NewSession()
-	productList := []*entity.ProductJson{}
+	productList := []entity.ProductJson{}
 	err := orm.Table("product").Alias("pr").
 		Select("pr.*").
 		Join("left", "activity a ", "FIND_IN_SET( pr.productCode,a.useProductList)").
@@ -431,11 +431,10 @@ func (service *ActivityService)LotteryInfo (data *activity.Request) (int64, stri
 	orm := entity.Engine.NewSession()
 	userLettryList := []entity.UserPrizeJson{}
 	//已用的奖券
-	err := orm.Table("user_prize").Alias("up").Select("up.*,a.useProductList,p.instructions,p.remark").
+	err := orm.Table("user_prize").Alias("up").Select("up.*,p.instructions,p.remark").
 	Join("left", "activity a ", "a.prizeId=up.prizeId").
 	Join("left", "prize p ", "a.prizeId=p.Id").
-	Where("up.userId=? and  up.appId=? and (up.prizeType=0) and  up.lotteryId=?", data.UserId, data.AppId,data.LotteryId).
-	Desc("up.createTime").
+	Where("up.userId=? and  up.appId=? and up.prizeType=0 and  up.lotteryId=?",data.UserId,data.AppId,data.LotteryId).
 	Find(&userLettryList)
 	if err != nil {
 		log.Println("err:", err)
@@ -444,7 +443,7 @@ func (service *ActivityService)LotteryInfo (data *activity.Request) (int64, stri
 	if  len(userLettryList)==0{
 		return entity.ErrorCode, "用户下的奖券查询失败", entity.UserPrizeJson{}
 	}
-	productList := []*entity.ProductJson{}
+	productList := []entity.ProductJson{}
 	var code int64
 	code,_,productList=service.LotteryProduct(data)
 	if (code==0){