互动
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
2.1 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. package lottery_service
  2. import (
  3. "hudongzhuanjia/models"
  4. "hudongzhuanjia/utils/define"
  5. "github.com/ouxuanserver/osmanthuswine/src/core"
  6. )
  7. func GetOrderLotteryUserIds(repeat string, activityId, ruleId, ladderId, rehearsalId, areaId, archId interface{}) ([]int, error) {
  8. var err error
  9. var userIds = make([]int, 0)
  10. var recordIds = make([]int, 0)
  11. if repeat == define.MODULE_BESIDE_REPEAT {
  12. //查询已经中奖的用户,剔除已经中奖的用户
  13. err = core.GetXormAuto().Table(&models.OrderDrawRecord{}).Select("user_id").
  14. Where("order_draw_rule_id=? and rehearsal_id=? and arch_id=? and is_delete=0",
  15. ruleId, rehearsalId, archId).Find(&recordIds)
  16. } else {
  17. err = core.GetXormAuto().Table(&models.OrderDrawRecord{}).Select("user_id").
  18. Where("order_draw_rule_ladder_id=? and rehearsal_id=? and arch_id=? and is_delete=0",
  19. ladderId, rehearsalId, archId).Find(&recordIds)
  20. }
  21. if err != nil {
  22. return nil, err
  23. }
  24. err = core.GetXormAuto().Table(&models.CustomerOrder{}).
  25. Select("id, buyer_id as user_id").Distinct("buyer_id").
  26. Where("activity_id=? and rehearsal_id=? and area_id=? and arch_id=? and is_delete=0",
  27. activityId, rehearsalId, areaId, archId).NotIn("buyer_id", recordIds).
  28. Find(&userIds)
  29. if err != nil {
  30. return nil, err
  31. }
  32. return userIds, nil
  33. }
  34. type OrderWinnersResult struct {
  35. UserId int `json:"user_id"`
  36. UserName string `json:"user_name"`
  37. UserPhone string `json:"user_phone"`
  38. Avatar string `json:"avatar"`
  39. PrizeName string `json:"prize_name"`
  40. EntryPersonName string `json:"entry_person_name"`
  41. }
  42. func GetOrderWinnersResult(ruleId, rehearsalId, archId interface{}) (result []*OrderWinnersResult, err error) {
  43. err = core.GetXormAuto().Table(&models.OrderDrawRecord{}).Alias("r").
  44. Select("r.order_entry_person_name as entry_person_name, r.user_id, u.nickname as user_name, "+
  45. " u.phone as user_phone, u.avatar, r.prize_name").Join("LEFT",
  46. (&models.User{}).Alias("u"), "u.id=r.user_id and u.is_delete=0").
  47. Where("r.is_delete=0 and r.order_draw_rule_id=? and r.rehearsal_id=? and r.arch_id=?",
  48. ruleId, rehearsalId, archId).Find(&result)
  49. return
  50. }