Member.class.php 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <?php
  2. namespace Cas\Controller;
  3. use Cas\Dao\LotteryData;
  4. use Cas\Dao\LotteryEvents;
  5. use KIF\Core\Request;
  6. use Cas\Module\Lottery;
  7. use Cas\Dao\UserInfo;
  8. use Cas\Dao\LotteryUserFeedback;
  9. /**
  10. *
  11. * 用户资料设置
  12. */
  13. class Member extends EventsController {
  14. public function doDefault() {
  15. $this->tpl = 'member';
  16. }
  17. /**
  18. * 我的礼品
  19. */
  20. public function doGifts() {
  21. //填写收货地址 c=Express&lottery_data_id=3
  22. $objLottery = new Lottery();
  23. $thisTime = time();
  24. $plat_form_id = $this->getPlatFormId();
  25. # 获取用户信息
  26. $objUserData = new UserInfo();
  27. $uid = $this->getRunTimeUid();
  28. $userData = $objUserData -> get($uid);
  29. $this->setOutput('userData', $userData);
  30. $condition = array('audit' => 2, 'uid' => $uid,'scratch_receive' => LotteryData::EVENT_SCRATCH_RECEIVE_TRUE);
  31. $totals = $objLottery -> getLotteryDataListNum($condition);
  32. $offset = 0;
  33. $size = 6;
  34. $order = 'id desc';
  35. $data = $objLottery->getLotteryDataList($condition, "{$offset},{$size}", 'create_time desc');
  36. $newData = array();
  37. $events_ids = array();
  38. $objLotteryUserFeedback = new LotteryUserFeedback();
  39. foreach($data as $key=> $d){
  40. $data[$key]['feedback'] = 1;//不需要填写反馈
  41. $events_ids[$d['run_time_data']['events']['id']] = $d['run_time_data']['events']['id'];
  42. if (in_array($d['run_time_data']['events']['type'], array(4,0))) {
  43. $data[$key]['feedback'] = 2;//未填写反馈
  44. $where = array();
  45. $where['uid'] = $d['uid'];
  46. $where['events_id'] = $d['run_time_data']['events']['id'];
  47. $where['status'] = 1;
  48. $ids = $objLotteryUserFeedback->findIdsBy ( $where, 1, $order = ' id desc');
  49. if ($ids) {
  50. $data[$key]['feedback'] = 3;//已填写反馈
  51. }
  52. /*
  53. if (isset($d['express']) && $d['express']) {
  54. $data[$key]['feedback'] = 2;//未填写反馈
  55. $where = array();
  56. $where['uid'] = $d['uid'];
  57. $where['events_id'] = $d['run_time_data']['events']['id'];
  58. $where['status'] = 1;
  59. $ids = $objLotteryUserFeedback->findIdsBy ( $where, 1, $order = ' id desc');
  60. if ($ids) {
  61. $data[$key]['feedback'] = 3;//已填写反馈
  62. }
  63. } else {
  64. $data[$key]['feedback'] = 4;//未填写收货地址
  65. }
  66. */
  67. }
  68. }
  69. $objDLotteryEvents = new LotteryEvents();
  70. $eventsData = $objDLotteryEvents -> gets($events_ids);
  71. $time = time();
  72. foreach($data as $key=> $d){
  73. $eventsInfo = $eventsData[$d['run_time_data']['events']['id']];
  74. if ($v['feedback'] == 3) {
  75. # 查看是否过期
  76. if ($time > $eventsInfo['end_time']) {
  77. $data[$key]['feedback'] = 5;//未填写收货地址并且已经过期
  78. }
  79. }
  80. $newData[$key] = array();
  81. $newData[$key]['feedback'] = $d['feedback'];
  82. $thisEventID = $d['run_time_data']['events']['id'];
  83. $newData[$key]['prize_id'] = $d['prize_id'];
  84. $newData[$key]['prize_name'] = $d['run_time_data']['prize'][$d['prize_id']]['prize_name'];
  85. $newData[$key]['prize_type'] = $d['run_time_data']['prize'][$d['prize_id']]['type'];
  86. $newData[$key]['prize_express'] = $d['run_time_data']['prize'][$d['prize_id']]['express'];
  87. if ($d['run_time_data']['events']['type'] == LotteryEvents::TYPE_EVENTS_CODE) {
  88. //$newData[$key]['prize_img_url'] = $d['run_time_data']['events']['weixinShare']['imgUrl'];
  89. $newData[$key]['prize_img_url'] = $d['run_time_data']['prize'][$d['prize_id']]['img_url'];
  90. } else {
  91. $newData[$key]['prize_img_url'] = $d['run_time_data']['prize'][$d['prize_id']]['img_url'];
  92. }
  93. $newData[$key]['events_id'] = $thisEventID;
  94. $newData[$key]['events_delivery'] = $eventsData[$thisEventID]['delivery'];
  95. $newData[$key]['events_name'] = $eventsData[$thisEventID]['events_name'];
  96. $newData[$key]['events_type'] = $eventsData[$thisEventID]['type'];
  97. $newData[$key]['end_time_receive_prizes'] = $eventsData[$thisEventID]['end_time_receive_prizes'];
  98. $newData[$key]['virtual_data'] = $d['virtual_data'];
  99. $newData[$key]['express'] = $d['express'];
  100. $newData[$key]['lottery_data_id'] = $key;
  101. $newData[$key]['show_up_express_a'] = false;
  102. if($newData[$key]['end_time_receive_prizes'] < time() && empty($newData[$key]['express'])){
  103. $newData[$key]['show_up_express_a'] = true;
  104. }
  105. $newData[$key]['url'] = $objLottery -> getEventsUrl($eventsInfo['type'],$eventsInfo['create_time'],$this->platform['url']);
  106. }
  107. $this->tpl = 'gifts';
  108. $this->setOutput('thisTime', $thisTime);
  109. $this->setOutput('title', '我的奖品');
  110. $this->setOutput('data', $data);
  111. $this->setOutput('newData', $newData);
  112. $this->setOutput('totals', ceil($totals / $size));
  113. $this->setOutput('action', 'gift');
  114. $this->setOutput('display', 1);
  115. $this->setOutput('notShowWeixinShare', true);
  116. }
  117. /**
  118. * 事件:ajax翻页
  119. */
  120. public function doAjax() {
  121. $page = Request::varGetInt('page', 1);
  122. $thisTime = time();
  123. $objLottery = new Lottery();
  124. $uid = $this->getRunTimeUid();
  125. $condition = array('audit' => 2, 'uid' => $uid,'scratch_receive' => LotteryData::EVENT_SCRATCH_RECEIVE_TRUE);
  126. $totals = $objLottery -> getLotteryDataListNum($condition);
  127. $order = 'create_time desc';
  128. $size = 6;
  129. $offset = ($page - 1) * $size;
  130. $limit = "{$offset},{$size}";
  131. $data = $objLottery->getLotteryDataList($condition, "{$offset},{$size}", 'create_time desc');
  132. $newData = array();
  133. $events_ids = array();
  134. $objLotteryUserFeedback = new LotteryUserFeedback();
  135. foreach($data as $key=> $d){
  136. $data[$key]['feedback'] = 1;//不需要填写反馈
  137. $events_ids[$d['run_time_data']['events']['id']] = $d['run_time_data']['events']['id'];
  138. if (in_array($d['run_time_data']['events']['type'], array(4,0))) {
  139. $data[$key]['feedback'] = 2;//未填写反馈
  140. $where = array();
  141. $where['uid'] = $d['uid'];
  142. $where['events_id'] = $d['run_time_data']['events']['id'];
  143. $where['status'] = 1;
  144. $ids = $objLotteryUserFeedback->findIdsBy ( $where, 1, $order = ' id desc');
  145. $info = $objLotteryUserFeedback->gets ( $ids );
  146. if ($info) {
  147. $data[$key]['feedback'] = 3;//已填写反馈
  148. }
  149. /*
  150. if (isset($d['express']) && $d['express']) {
  151. $data[$key]['feedback'] = 2;//未填写反馈
  152. $where = array();
  153. $where['uid'] = $d['uid'];
  154. $where['events_id'] = $d['run_time_data']['events']['id'];
  155. $where['status'] = 1;
  156. $ids = $objLotteryUserFeedback->findIdsBy ( $where, 1, $order = ' id desc');
  157. $info = $objLotteryUserFeedback->gets ( $ids );
  158. if ($info) {
  159. $data[$key]['feedback'] = 3;//已填写反馈
  160. }
  161. } else {
  162. $data[$key]['feedback'] = 4;//未填写收货地址
  163. }
  164. */
  165. }
  166. }
  167. $objDLotteryEvents = new LotteryEvents();
  168. $eventsData = $objDLotteryEvents -> gets($events_ids);
  169. foreach($data as $key=> $d){
  170. $newData[$key] = array();
  171. $thisEventID = $d['run_time_data']['events']['id'];
  172. $newData[$key]['prize_id'] = $d['prize_id'];
  173. $newData[$key]['prize_name'] = $d['run_time_data']['prize'][$d['prize_id']]['prize_name'];
  174. $newData[$key]['prize_type'] = $d['run_time_data']['prize'][$d['prize_id']]['type'];
  175. $newData[$key]['prize_express'] = $d['run_time_data']['prize'][$d['prize_id']]['express'];
  176. if ($d['run_time_data']['events']['type'] == LotteryEvents::TYPE_EVENTS_CODE) {
  177. $newData[$key]['prize_img_url'] = $d['run_time_data']['events']['weixinShare']['imgUrl'];
  178. } else {
  179. $newData[$key]['prize_img_url'] = $d['run_time_data']['prize'][$d['prize_id']]['img_url'];
  180. }
  181. $newData[$key]['events_id'] = $thisEventID;
  182. $newData[$key]['events_delivery'] = $eventsData[$thisEventID]['delivery'];
  183. $newData[$key]['events_name'] = $eventsData[$thisEventID]['events_name'];
  184. $newData[$key]['events_type'] = $eventsData[$thisEventID]['type'];
  185. $newData[$key]['end_time_receive_prizes'] = $eventsData[$thisEventID]['end_time_receive_prizes'];
  186. $newData[$key]['virtual_data'] = $d['virtual_data'];
  187. $newData[$key]['express'] = $d['express'];
  188. $newData[$key]['lottery_data_id'] = $key;
  189. $newData[$key]['show_up_express_a'] = false;
  190. if($newData[$key]['end_time_receive_prizes'] < time() && empty($newData[$key]['express'])){
  191. $newData[$key]['show_up_express_a'] = true;
  192. }
  193. }
  194. $this->setOutput('data', $data);
  195. $this->setOutput('newData', $newData);
  196. $this->tpl = 'ajax_gifts';
  197. $this->ajax_success_exit($this->render(true));
  198. }
  199. public function display() {
  200. return $this->render();
  201. }
  202. }