ActivityService.go 19 KB

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