ActivityService.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. package service
  2. import (
  3. "app.yhyue.com/moapp/jyMarketing/entity"
  4. "app.yhyue.com/moapp/jyMarketing/rpc/activity"
  5. "app.yhyue.com/moapp/jyMarketing/util"
  6. "fmt"
  7. _ "github.com/garyburd/redigo/redis"
  8. "log"
  9. "time"
  10. )
  11. type ActivityService struct{}
  12. //奖券获取
  13. func (service *ActivityService) LotteryReceive(data *activity.LotteryOperation, code string) (int64, string) {
  14. orm := entity.Engine.NewSession()
  15. defer orm.Close()
  16. err := orm.Begin()
  17. bool := true
  18. if len(data.LotteryIdArr) == 0 {
  19. return entity.ErrorCode, "没有卷可以领取"
  20. }
  21. for _, lotteryId := range data.LotteryIdArr {
  22. if fool, _ := util.Exists(code, "lottery_"+fmt.Sprint(lotteryId)); !fool {
  23. orm.Rollback()
  24. return entity.ErrorCode, "奖卷领取失败"
  25. }
  26. log.Println(fmt.Sprint(lotteryId) + "Id奖券领取")
  27. //每种劵处理
  28. //1、先查询奖券信息
  29. prizeData := entity.PrizeJson{}
  30. bool, err = orm.Table("lottery").
  31. Alias("l").Select("l.name,l.full,l.reduce, l.prizeId,p.beginDate,p.endDate,p.isLimitNumber,p.limitNumber,p.validityDates,p.validityTimeType").
  32. Join("left", "prize p", "l.prizeId=p.id").
  33. Where("l.id=?", lotteryId).Get(&prizeData)
  34. if err != nil {
  35. log.Println("查询奖品信息:", err)
  36. orm.Rollback()
  37. return entity.ErrorCode, "奖品信息查询失败"
  38. }
  39. if !bool {
  40. log.Println("查询奖品信息:", err)
  41. orm.Rollback()
  42. return entity.ErrorCode, "奖品信息查询失败"
  43. }
  44. //2、查看活动是否开始
  45. activity := entity.Activity{}
  46. bool, err = orm.Table("activity").Where("prizeId=? and state=1", prizeData.PrizeId).Get(&activity)
  47. if !bool {
  48. log.Println("查询奖品信息:", err)
  49. orm.Rollback()
  50. return entity.ErrorCode, "奖品信息查询失败"
  51. }
  52. if !activityTime(activity.BeginDate) {
  53. log.Println("活动没有开始不可领劵", activity)
  54. orm.Rollback()
  55. return entity.ErrorCode, "活动没有开始不可领劵"
  56. }
  57. if activityTime(activity.EndDate) {
  58. log.Println("活动结束不可领劵", activity)
  59. orm.Rollback()
  60. return entity.ErrorCode, "活动结束不可领劵"
  61. }
  62. //3、先判断奖券是否可以重复领取,在判断之前是否领取过
  63. userLotteryList := []entity.UserPrize{}
  64. err = orm.Table("user_prize").
  65. Where("userId=? and appId=? and lotteryId=? and to_days(createTime) = to_days(now()) ", data.UserId, data.AppId, lotteryId).Find(&userLotteryList)
  66. if err != nil {
  67. log.Println("查询奖品信息:", err)
  68. orm.Rollback()
  69. return entity.ErrorCode, "查询领取次数失败"
  70. }
  71. if len(userLotteryList) >0 {
  72. orm.Rollback()
  73. return entity.ErrorCode, "你今日领取奖券数量已达上限"
  74. }
  75. if prizeData.IsLimitNumber == 0 {
  76. //查询之前是否领取过
  77. userLotteryList := []entity.UserPrize{}
  78. err = orm.Table("user_prize").
  79. Where("userId=? and appId=? and lotteryId=?", data.UserId, data.AppId, lotteryId).Find(&userLotteryList)
  80. if err != nil {
  81. log.Println("查询奖品信息:", err)
  82. orm.Rollback()
  83. return entity.ErrorCode, "查询领取次数失败"
  84. }
  85. if len(userLotteryList) >= prizeData.LimitNumber {
  86. orm.Rollback()
  87. return entity.ErrorCode, "你领取奖券数量已达上限"
  88. }
  89. }
  90. //5、领取奖券
  91. userLettry := entity.UserPrize{}
  92. userLettry.AppId = data.AppId
  93. userLettry.UserId = data.UserId
  94. userLettry.PrizeType = 0
  95. userLettry.CreateTime = time.Now().Local()
  96. userLettry.LotteryId = lotteryId
  97. userLettry.PrizeId = prizeData.PrizeId
  98. userLettry.ValidityDates = prizeData.ValidityDates
  99. userLettry.Name = prizeData.Name
  100. userLettry.Full = int64(prizeData.Full)
  101. userLettry.Reduce = int64(prizeData.Reduce)
  102. userLettry.UserName = data.UserName
  103. //0、有起止时间1、当天起几天可用2、次日起几天可用
  104. switch prizeData.ValidityTimeType {
  105. case 0:
  106. userLettry.EndDate = prizeData.EndDate
  107. userLettry.BeginDate = prizeData.BeginDate
  108. case 1:
  109. nowStr := time.Now().Format("2006-01-02")
  110. userLettry.BeginDate = nowStr
  111. userLettry.EndDate = service.ObtainAppointTimeString(nowStr, prizeData.ValidityDates)
  112. case 2:
  113. nowStr := time.Now().Format("2006-01-02")
  114. nextDayStr := service.ObtainAppointTimeString(nowStr, 1)
  115. userLettry.BeginDate = nextDayStr
  116. userLettry.EndDate = service.ObtainAppointTimeString(nextDayStr, prizeData.ValidityDates)
  117. }
  118. numb, err := orm.Table("user_prize").Insert(&userLettry)
  119. if err != nil || numb == int64(0) {
  120. log.Println("领取奖券失败:", err)
  121. orm.Rollback()
  122. return entity.ErrorCode, "领取奖券失败"
  123. }
  124. //6、修改redis余额
  125. if util.GetInt(code, "lottery_"+fmt.Sprint(lotteryId)) <= 0 {
  126. log.Println("奖券余额不足:", err)
  127. orm.Rollback()
  128. return entity.ErrorCode, "奖券余额不足"
  129. }
  130. if !util.DecrbyLimit(code, "lottery_"+fmt.Sprint(lotteryId), 1, 0) {
  131. log.Println("修改redis奖券库存失败:", err)
  132. orm.Rollback()
  133. return entity.ErrorCode, "修改redis奖券库存失败"
  134. }
  135. //7、修改奖券余额数量
  136. lottery := entity.Lottery{}
  137. lottery.Id = lotteryId
  138. _, err = orm.Exec("UPDATE lottery SET `stockNumber` = stockNumber-1, `receiveNumber` = receiveNumber+1 WHERE `id` = ?", lotteryId)
  139. if err != nil {
  140. log.Println("修改奖券库存失败:", err)
  141. orm.Rollback()
  142. return entity.ErrorCode, "修改奖券库存失败"
  143. }
  144. }
  145. orm.Commit()
  146. return entity.SuccessCode, "奖券领取成功"
  147. }
  148. //奖券使用
  149. func (service *ActivityService) ActivityUse(data *activity.LotteryOperation) (int64, string) {
  150. orm := entity.Engine.NewSession()
  151. defer orm.Close()
  152. err := orm.Begin()
  153. //nowStr := time.Now().Format("2006-01-02")
  154. for _, lotteryId := range data.LotteryIdArr {
  155. //1、先查看是否有这张奖券
  156. var userLottery entity.UserPrize
  157. bool := true
  158. bool, err = orm.Table("user_prize").
  159. Where("userId=? and appId=? and id=? ", data.UserId, data.AppId, lotteryId).Get(&userLottery)
  160. if err != nil {
  161. log.Println("查询奖券库存失败:", err)
  162. orm.Rollback()
  163. return entity.ErrorCode, "查询奖券库存失败"
  164. }
  165. if !bool {
  166. log.Println(data.UserId, "用户没有ID为", lotteryId, "的奖券")
  167. orm.Rollback()
  168. return entity.ErrorCode, "该用户没有此此奖券"
  169. }
  170. //2、奖券是否过期
  171. if activityTime(userLottery.EndDate) {
  172. log.Println(data.UserId, "此卷已过期不可使用", userLottery)
  173. orm.Rollback()
  174. return entity.ErrorCode, "此卷已过期不可使用"
  175. }
  176. //3、奖券状态改为已使用
  177. userLottery.UseDate = time.Now().Local()
  178. userLottery.PrizeType = 1
  179. numb, err := orm.Table("user_prize").ID(userLottery.Id).Cols("prizeType", "useDate").Update(userLottery)
  180. if err != nil || numb == 0 {
  181. log.Println("修改用户奖券失败:", err)
  182. orm.Rollback()
  183. return entity.ErrorCode, "修改用户奖券失败"
  184. }
  185. }
  186. orm.Commit()
  187. return entity.SuccessCode, "使用奖券成功"
  188. }
  189. //活动下的奖券
  190. func (service *ActivityService) ActivityLottery(in *activity.Request) (int64, string, []entity.LotteryJson, entity.Activity) {
  191. orm := entity.Engine.NewSession()
  192. //1、查找活动信息
  193. activityJson := entity.Activity{}
  194. _, err := orm.Table("activity").Alias("a").
  195. Where("id = ? ", in.ActivityId).Get(&activityJson)
  196. //2、先查找活动下的奖品Id
  197. lotteryJsonList := []entity.LotteryJson{}
  198. err = orm.Table("activity").Alias("a").
  199. Select("p.prizeType as lotteryType,l.full,l.reduce, p.beginDate,p.endDate,l.stockNumber,l.receiveNumber,p.limitNumber,( select count(up.id) FROM user_prize up where up.lotteryId = l.id AND up.userId ='"+in.UserId+"' ) AS count,( select count(up.id) FROM user_prize up where up.lotteryId = l.id AND up.userId ='"+in.UserId+"' and to_days(createTime) = to_days(now())) AS daycount,p.isLimitNumber,p.validityTimeType,p.validityDates,p.instructions,p.remark,l.id as lotteryId ,l.name ").
  200. Join("left", "prize p", " a.prizeId = p.Id").
  201. Join("left", "lottery l", " l.prizeId = p.id ").
  202. Where("a.id = ? and a.appId=? ", in.ActivityId, in.AppId).Find(&lotteryJsonList)
  203. if err != nil {
  204. log.Println("用户下的奖券查询失败:", err)
  205. return entity.ErrorCode, "用户下的奖券查询失败", lotteryJsonList, activityJson
  206. }
  207. for key, value := range lotteryJsonList {
  208. productList := []entity.ProductJson{}
  209. var code int64
  210. in.LotteryId=value.LotteryId
  211. code,_,productList=service.LotteryProduct(in)
  212. if (code==0){
  213. return entity.ErrorCode, "奖券对应商品查询失败", lotteryJsonList, activityJson
  214. }
  215. lotteryJsonList[key].UseProductList=productList
  216. }
  217. orm.Commit()
  218. return entity.SuccessCode, "活动下的奖券", lotteryJsonList, activityJson
  219. }
  220. //用户下的奖券(不包含待使用的 )
  221. func (service *ActivityService) UserLottery(data *activity.Request) (int64, string, []entity.UserPrizeJson, int64) {
  222. orm := entity.Engine.NewSession()
  223. defer orm.Close()
  224. err := orm.Begin()
  225. userLettryList := []entity.UserPrizeJson{}
  226. nowStr := time.Now().Format("2006-01-02")
  227. count := int64(0)
  228. switch data.Model {
  229. case 1:
  230. //查看可以使用的奖券(没有过期的)
  231. condition := ""
  232. if data.UserLottertId != 0 {
  233. condition = "( (up.prizeType=0 and up.beginDate<='" + nowStr + "' ) or up.id=" + fmt.Sprint(data.UserLottertId) + ") "
  234. } else {
  235. condition = " up.prizeType=0 and up.beginDate<='" + nowStr + "'"
  236. }
  237. count, err = orm.Table("user_prize").Alias("up").Select("up.*,p.instructions,p.remark,p.prizeType as lotteryType").
  238. Join("left", "activity a ", "a.prizeId=up.prizeId").
  239. Join("left", "prize p ", "a.prizeId=p.Id").
  240. Where("up.userId=? and up.appId=? and up.endDate>=?", data.UserId, data.AppId, nowStr).
  241. And(condition).
  242. Desc("up.createTime").
  243. FindAndCount(&userLettryList)
  244. case 0:
  245. //查看名下所有奖券
  246. count, err = orm.Table("user_prize").Alias("up").Select("up.*,p.instructions,p.remark,p.prizeType as lotteryType").
  247. Join("left", "activity a ", "a.prizeId=up.prizeId").
  248. Join("left", "prize p ", "a.prizeId=p.Id").
  249. Where("up.userId=? and up.appId=?", data.UserId, data.AppId).Desc("up.createTime").
  250. Limit(int(data.PageSize), (int(data.Page - 1))*int(data.PageSize)).
  251. FindAndCount(&userLettryList)
  252. case 2:
  253. //过期的奖券
  254. count, err = orm.Table("user_prize").Alias("up").Select("up.*,p.instructions,p.remark,p.prizeType as lotteryType").
  255. Join("left", "activity a ", "a.prizeId=up.prizeId").
  256. Join("left", "prize p ", "a.prizeId=p.Id").
  257. Where("up.userId=? and up.appId=? ", data.UserId, data.AppId ).
  258. And("up.prizeType=2").
  259. Desc("up.createTime").Limit(int(data.PageSize), (int(data.Page - 1))*int(data.PageSize)).
  260. FindAndCount(&userLettryList)
  261. case 3:
  262. //已用的奖券
  263. count, err = orm.Table("user_prize").Alias("up").Select("up.*,p.instructions,p.remark,p.prizeType as lotteryType").
  264. Join("left", "activity a ", "a.prizeId=up.prizeId").
  265. Join("left", "prize p ", "a.prizeId=p.Id").
  266. Where("up.userId=? and up.appId=? and (up.prizeType=1 or up.prizeType=3)", data.UserId, data.AppId, ).
  267. Desc("up.createTime").
  268. Limit(int(data.PageSize), (int(data.Page - 1))*int(data.PageSize)).FindAndCount(&userLettryList)
  269. case 4:
  270. //所有未使用奖券
  271. count, err = orm.Table("user_prize").Alias("up").Select("up.*,p.instructions,p.remark,p.prizeType as lotteryType").
  272. Join("left", "activity a ", "a.prizeId=up.prizeId").
  273. Join("left", "prize p ", "a.prizeId=p.Id").
  274. Where("up.userId=? and up.appId=? and up.endDate>=?", data.UserId, data.AppId, nowStr).
  275. And("up.prizeType=0").
  276. Limit(int(data.PageSize), (int(data.Page - 1))*int(data.PageSize)).
  277. Desc("up.createTime").
  278. FindAndCount(&userLettryList)
  279. }
  280. if err != nil {
  281. log.Println("用户下的奖券查询失败:", err)
  282. orm.Rollback()
  283. return entity.ErrorCode, "用户下的奖券查询失败", userLettryList, count
  284. }
  285. for key, value := range userLettryList {
  286. productList := []entity.ProductJson{}
  287. var code int64
  288. data.LotteryId=value.LotteryId
  289. code,_,productList=service.LotteryProduct(data)
  290. if (code==0){
  291. return entity.SuccessCode, "奖券对应商品查询失败", userLettryList, count
  292. }
  293. userLettryList[key].UseProductList=productList
  294. }
  295. orm.Commit()
  296. return entity.SuccessCode, "用户下的奖券查询成功", userLettryList, count
  297. }
  298. //计算几天之后的时间
  299. func (service *ActivityService) ObtainAppointTimeString(now string, beApartDay int) string {
  300. local, _ := time.LoadLocation("Local")
  301. t, _ := time.ParseInLocation("2006-01-02", now, local)
  302. stopTime := t.AddDate(0, 0, beApartDay)
  303. stopTimeStr := stopTime.Format("2006-01-02")
  304. return stopTimeStr
  305. }
  306. //查询过期的奖券改为已过期
  307. func (service *ActivityService) UpdateLottery(endDate string) (int64, string) {
  308. orm := entity.Engine.NewSession()
  309. defer orm.Close()
  310. err := orm.Begin()
  311. //1、先查找过期的奖券
  312. userPrizeList := []entity.UserPrize{}
  313. err = orm.Table("user_prize").
  314. Where("endDate<? and (prizeType=0 or prizeType=3) ", endDate).Find(&userPrizeList)
  315. if err != nil {
  316. log.Println("查询过期奖券失败:", err)
  317. orm.Rollback()
  318. return entity.ErrorCode, "查询过期奖券失败"
  319. }
  320. for _, value := range userPrizeList {
  321. value.PrizeType = 2
  322. numb, err := orm.Table("user_prize").ID(value.Id).Cols("prizeType").Update(value)
  323. if err != nil || numb == 0 {
  324. log.Println("修改奖券使用数量失败:", err)
  325. orm.Rollback()
  326. return entity.ErrorCode, "修改奖券使用数量失败"
  327. }
  328. }
  329. orm.Commit()
  330. return entity.SuccessCode, "过期奖券处理成功"
  331. }
  332. //活动创建及修改时间需大于当前时间
  333. func activityTime(beginDate interface{}) bool {
  334. timeData := time.Now().Format("2006-01-02")
  335. if timeData >= fmt.Sprint(beginDate) {
  336. return true
  337. }
  338. return false
  339. }
  340. //待使用与未使用状态之间变化
  341. func (service *ActivityService) LotteryStateChange(data *activity.UpdateStateReq) (int64, string) {
  342. orm := entity.Engine.NewSession()
  343. defer orm.Close()
  344. err := orm.Begin()
  345. //先查询奖券状态
  346. var userLottery entity.UserPrize
  347. bool := true
  348. bool, err = orm.Table("user_prize").
  349. Where("userId=? and appId=? and id=? ", data.UserId, data.AppId, data.UserLottertId).
  350. Asc("createTime").Get(&userLottery)
  351. if err != nil {
  352. log.Println("查询奖券库存失败:", err)
  353. orm.Rollback()
  354. return entity.ErrorCode, "查询奖券库存失败"
  355. }
  356. if !bool {
  357. log.Println(data.UserId, "用户没有ID为", data.UserLottertId, "的奖券")
  358. orm.Rollback()
  359. return entity.ErrorCode, "该用户没有此此奖券"
  360. }
  361. //未使用改为待使用
  362. if data.Model == 3 {
  363. if (userLottery.PrizeType == 0) {
  364. //奖券状态改为待使用
  365. userLottery.PrizeType = 3
  366. userLottery.OrderCode = data.OrderCode
  367. userLottery.UserName = data.UserName
  368. userLottery.UseDate = time.Now().Local()
  369. numb, err := orm.Table("user_prize").ID(userLottery.Id).Cols("prizeType", "orderCode", "userName", "useDate").Update(userLottery)
  370. if err != nil || numb == 0 {
  371. log.Println("修改用户奖券失败:", err)
  372. orm.Rollback()
  373. return entity.ErrorCode, "修改用户奖券失败"
  374. }
  375. //修改卷的使用量
  376. _, err = orm.Exec("UPDATE lottery SET `useNumber` = useNumber+1 WHERE `id` = ?", userLottery.LotteryId)
  377. if err != nil || numb == 0 {
  378. log.Println("修改奖券使用数量失败:", err)
  379. orm.Rollback()
  380. return entity.ErrorCode, "修改奖券使用数量失败"
  381. }
  382. orm.Commit()
  383. return entity.SuccessCode, "修改用户奖券成功"
  384. } else if userLottery.PrizeType == 3 {
  385. return entity.SuccessCode, "修改用户奖券成功"
  386. }
  387. return entity.ErrorCode, "该奖券状态不可修改"
  388. } else if data.Model == 0 {
  389. if (userLottery.PrizeType == 3) {
  390. //奖券状态改为未使用
  391. userLottery.PrizeType = 0
  392. userLottery.OrderCode = ""
  393. userLottery.UserName = ""
  394. numb, err := orm.Table("user_prize").ID(userLottery.Id).Cols("prizeType", "orderCode", "userName").Update(userLottery)
  395. if err != nil || numb == 0 {
  396. log.Println("修改用户奖券失败:", err)
  397. orm.Rollback()
  398. return entity.ErrorCode, "修改用户奖券失败"
  399. }
  400. //修改卷的使用量
  401. _, err = orm.Exec("UPDATE lottery SET `useNumber` = useNumber-1 WHERE `id` = ?", userLottery.LotteryId)
  402. if err != nil || numb == 0 {
  403. log.Println("修改奖券使用数量失败:", err)
  404. orm.Rollback()
  405. return entity.ErrorCode, "修改奖券使用数量失败"
  406. }
  407. orm.Commit()
  408. return entity.SuccessCode, "修改用户奖券成功"
  409. } else if (userLottery.PrizeType == 2) {
  410. orm.Commit()
  411. return entity.SuccessCode, "修改用户奖券成功"
  412. }
  413. return entity.ErrorCode, "该奖券状态不可修改"
  414. } else {
  415. //1、奖券是否过期
  416. if activityTime(userLottery.EndDate) {
  417. log.Println(data.UserId, "此卷已过期不可使用", userLottery)
  418. orm.Rollback()
  419. return entity.ErrorCode, "此卷已过期不可使用"
  420. }
  421. //2、奖券状态改为已使用
  422. userLottery.UseDate = time.Now().Local()
  423. userLottery.PrizeType = 1
  424. numb, err := orm.Table("user_prize").ID(userLottery.Id).Cols("prizeType", "useDate").Update(userLottery)
  425. if err != nil || numb == 0 {
  426. log.Println("修改用户奖券失败:", err)
  427. orm.Rollback()
  428. return entity.ErrorCode, "修改用户奖券失败"
  429. }
  430. orm.Commit()
  431. return entity.SuccessCode, "使用奖券成功"
  432. return entity.ErrorCode, "该奖券状态不可修改"
  433. }
  434. }
  435. //查询奖券对应的产品信息
  436. func (service *ActivityService)LotteryProduct(data *activity.Request) (int64, string, []entity.ProductJson) {
  437. orm := entity.Engine.NewSession()
  438. productList := []entity.ProductJson{}
  439. err := orm.Table("product").Alias("pr").
  440. Select("pr.*").
  441. Join("left", "activity a ", "FIND_IN_SET( pr.productCode,a.useProductList)").
  442. Join("left", "prize p ", "a.prizeId=p.Id").
  443. Join("left","lottery l" ,"l.prizeId=p.Id").
  444. Where("l.id=?", data.LotteryId).
  445. Find(&productList)
  446. if err != nil {
  447. log.Println("err:", err)
  448. return entity.ErrorCode, "查询奖券对应的产品信息失败", productList
  449. }
  450. return entity.SuccessCode, "查询奖券对应的产品信息成功", productList
  451. }
  452. //奖券的基本信息
  453. func (service *ActivityService)LotteryInfo(data *activity.Request) (int64, string, entity.UserPrizeJson) {
  454. orm := entity.Engine.NewSession()
  455. userLettryList := []entity.UserPrizeJson{}
  456. //已用的奖券
  457. err := orm.Table("user_prize").Alias("up").Select("up.*,p.instructions,p.remark,p.prizeType as lotteryType").
  458. Join("left", "activity a ", "a.prizeId=up.prizeId").
  459. Join("left", "prize p ", "a.prizeId=p.Id").
  460. Where("up.userId=? and up.appId=? and up.prizeType=0 and up.lotteryId=?",data.UserId,data.AppId,data.LotteryId).
  461. Find(&userLettryList)
  462. if err != nil {
  463. log.Println("err:", err)
  464. return entity.ErrorCode, "用户下的奖券查询失败", entity.UserPrizeJson{}
  465. }
  466. if len(userLettryList)==0{
  467. return entity.ErrorCode, "用户下的奖券查询失败", entity.UserPrizeJson{}
  468. }
  469. productList := []entity.ProductJson{}
  470. var code int64
  471. code,_,productList=service.LotteryProduct(data)
  472. if (code==0){
  473. return entity.ErrorCode, "查询奖券对应的产品信息失败", entity.UserPrizeJson{}
  474. }
  475. userLettryList[0].UseProductList=productList
  476. return entity.SuccessCode, "用户下的奖券查询成功", userLettryList[0]
  477. }