|
@@ -2,6 +2,7 @@ package logic
|
|
|
|
|
|
import (
|
|
|
"app.yhyue.com/moapp/jyMarketing/util"
|
|
|
+ "app.yhyue.com/moapp/jybase/common"
|
|
|
"context"
|
|
|
"time"
|
|
|
|
|
@@ -31,79 +32,97 @@ func (l *GetAllActivityLogic) GetAllActivity(in *activity.Request) (*activity.Ac
|
|
|
code, msg, activityData := activityServiceNew.GetAllActivity(in)
|
|
|
var activityArr []*activity.ActivityJson
|
|
|
for _, activityValue := range activityData {
|
|
|
- activityJson := activity.ActivityJson{}
|
|
|
+ activityEntity := activity.ActivityJson{}
|
|
|
timeBool := util.ActivityTime(activityValue.BeginDate) && !util.ActivityTimeOther(activityValue.EndDate)
|
|
|
- var userLotteryList []*activity.LotteryJson
|
|
|
+ var lotteryList []*activity.LotteryJson
|
|
|
for _, value := range activityValue.LotteryData {
|
|
|
- userLottery := activity.LotteryJson{}
|
|
|
- userLottery.LotteryId = value.LotteryId
|
|
|
- userLottery.LotteryName = value.Name
|
|
|
- userLottery.IsReceive = false
|
|
|
+ lottery := activity.LotteryJson{}
|
|
|
+ lottery.LotteryId = value.LotteryId
|
|
|
+ lottery.LotteryName = value.Name
|
|
|
+ lottery.IsReceive = false
|
|
|
//IsReceive 是否可以领取true可以领取false不可领取
|
|
|
//IsUser 是否使用 true 使用 false未使用
|
|
|
if activityValue.ActivityType < 2 {
|
|
|
if timeBool {
|
|
|
if value.StockNumber == 0 {
|
|
|
//库存不足
|
|
|
- userLottery.IsReceive = false
|
|
|
+ lottery.IsReceive = false
|
|
|
} else {
|
|
|
//还有库存
|
|
|
- if value.Count > 0 {
|
|
|
- userLottery.IsReceive = false
|
|
|
+ if value.IsLimitNumber == 0 {
|
|
|
+ if value.AllUserCount >= common.Int64All(value.LimitNumber) {
|
|
|
+ lottery.IsReceive = false
|
|
|
+ } else {
|
|
|
+ if value.UserCount >= common.Int64All(value.LimitNumber) {
|
|
|
+ lottery.IsReceive = false
|
|
|
+ } else {
|
|
|
+ lottery.IsReceive = true
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
- userLottery.IsReceive = true
|
|
|
+ if value.UserCount == 0 {
|
|
|
+ lottery.IsReceive = true
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- userLottery.IsUser = false
|
|
|
+ lottery.IsUser = false
|
|
|
if value.UserCount > 0 {
|
|
|
- userLottery.IsUser = true
|
|
|
+ lottery.IsUser = true
|
|
|
}
|
|
|
- userLottery.LotteryBeginDate = value.BeginDate
|
|
|
- userLottery.LotteryendDate = value.EndDate
|
|
|
+ lottery.LotteryBeginDate = value.BeginDate
|
|
|
+ lottery.LotteryendDate = value.EndDate
|
|
|
} else {
|
|
|
- userLottery.PromotionalPrice = value.PromotionalPrice
|
|
|
- userLottery.GiftCode = value.GiftCode
|
|
|
+ if timeBool {
|
|
|
+ if value.StockNumber == 0 {
|
|
|
+ //库存不足
|
|
|
+ lottery.IsReceive = false
|
|
|
+ } else {
|
|
|
+ lottery.IsReceive = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ lottery.PromotionalPrice = value.PromotionalPrice
|
|
|
+ lottery.GiftCode = value.GiftCode
|
|
|
}
|
|
|
- userLottery.LotteryType = value.LotteryType
|
|
|
- userLottery.Instructions = value.Instructions
|
|
|
- userLottery.StockNumber = value.StockNumber
|
|
|
- userLottery.ReceiveNumber = value.ReceiveNumber
|
|
|
- userLottery.Full = value.Full
|
|
|
- userLottery.Reduce = value.Reduce
|
|
|
- userLottery.Remark = value.Remark
|
|
|
- userLottery.Discount = float32(value.Discount)
|
|
|
- userLotteryList = append(userLotteryList, &userLottery)
|
|
|
+ lottery.LotteryType = value.LotteryType
|
|
|
+ lottery.Instructions = value.Instructions
|
|
|
+ lottery.StockNumber = value.StockNumber
|
|
|
+ lottery.ReceiveNumber = value.ReceiveNumber
|
|
|
+ lottery.Full = value.Full
|
|
|
+ lottery.Reduce = value.Reduce
|
|
|
+ lottery.Remark = value.Remark
|
|
|
+ lottery.Discount = float32(value.Discount)
|
|
|
+ lotteryList = append(lotteryList, &lottery)
|
|
|
}
|
|
|
- activityJson.LotteryJson = userLotteryList
|
|
|
+ activityEntity.LotteryJson = lotteryList
|
|
|
endDate, _ := time.ParseInLocation("2006-01-02 15:04:05", activityValue.EndDate, time.Local)
|
|
|
- activityJson.ActivityendDate = endDate.Format("2006年01月02日 15时04分05秒")
|
|
|
+ activityEntity.ActivityendDate = endDate.Format("2006年01月02日 15时04分05秒")
|
|
|
beginDate, _ := time.ParseInLocation("2006-01-02 15:04:05", activityValue.BeginDate, time.Local)
|
|
|
- activityJson.ActivityBeginDate = beginDate.Format("2006年01月02日 15时04分05秒")
|
|
|
- activityJson.ActivityName = activityValue.Name
|
|
|
- activityJson.ActivityDesc = activityValue.ActivityDesc
|
|
|
- activityJson.ReceivingLocation = activityValue.ReceivingLocation
|
|
|
+ activityEntity.ActivityBeginDate = beginDate.Format("2006年01月02日 15时04分05秒")
|
|
|
+ activityEntity.ActivityName = activityValue.Name
|
|
|
+ activityEntity.ActivityDesc = activityValue.ActivityDesc
|
|
|
+ activityEntity.ReceivingLocation = activityValue.ReceivingLocation
|
|
|
switch activityValue.ActivityType {
|
|
|
case 0:
|
|
|
- activityJson.ActivityType = "满减券"
|
|
|
+ activityEntity.ActivityType = "满减券"
|
|
|
case 1:
|
|
|
- activityJson.ActivityType = "满折券"
|
|
|
+ activityEntity.ActivityType = "满折券"
|
|
|
case 2:
|
|
|
- activityJson.ActivityType = "满赠"
|
|
|
+ activityEntity.ActivityType = "满赠"
|
|
|
case 3:
|
|
|
- activityJson.ActivityType = "促销"
|
|
|
+ activityEntity.ActivityType = "促销"
|
|
|
case 4:
|
|
|
- activityJson.ActivityType = "限时折扣"
|
|
|
+ activityEntity.ActivityType = "限时折扣"
|
|
|
case 5:
|
|
|
- activityJson.ActivityType = "限时减免"
|
|
|
+ activityEntity.ActivityType = "限时减免"
|
|
|
}
|
|
|
if activityValue.PreheatingTime == "" {
|
|
|
- activityJson.PreheatingTime = 0
|
|
|
+ activityEntity.PreheatingTime = 0
|
|
|
} else {
|
|
|
PreheatingTime, _ := time.ParseInLocation("2006-01-02 15:04:05", activityValue.PreheatingTime, time.Local)
|
|
|
- activityJson.PreheatingTime = PreheatingTime.Unix()
|
|
|
+ activityEntity.PreheatingTime = PreheatingTime.Unix()
|
|
|
}
|
|
|
- activityArr = append(activityArr, &activityJson)
|
|
|
+ activityArr = append(activityArr, &activityEntity)
|
|
|
}
|
|
|
result.Code = code
|
|
|
result.Message = msg
|