My.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <?php
  2. namespace Shop\Src;
  3. use Dever;
  4. use Main\Lib\Core;
  5. class My extends Core
  6. {
  7. public function __construct()
  8. {
  9. parent::__construct();
  10. $this->checkLogin();
  11. }
  12. public function getInfo()
  13. {
  14. $this->data['user'] = $this->user;
  15. # 获取拥有的优惠券数量
  16. $this->data['coupon_num'] = Dever::db('shop/user_coupon')->total(array('uid' => $this->uid, 'status' => 1));
  17. $this->data['card_num'] = Dever::db('goods/card_code')->total(array('uid' => $this->uid));
  18. $this->data['score'] = Dever::load('score/lib/core')->getUserScore($this->uid);
  19. $this->data['msg'] = Dever::load('message/lib/data')->num($this->uid);
  20. $this->data['level'] = 'Lv1';
  21. return $this->data;
  22. }
  23. # 我的优惠券列表
  24. public function coupon()
  25. {
  26. $this->data = Dever::db('shop/user_coupon')->getAllPage(array('uid' => $this->uid));
  27. if ($this->data) {
  28. $time = time();
  29. foreach ($this->data as $k => $v) {
  30. if ($time > $v['edate']) {
  31. $this->data[$k]['status'] = 3;
  32. }
  33. $this->data[$k]['edate'] = date('Y-m-d', $v['edate']);
  34. $this->data[$k]['info'] = Dever::db('goods/coupon')->find($v['coupon_id']);
  35. $this->data[$k]['shop'] = array();
  36. $this->data[$k]['method'] = $this->data[$k]['info']['method'];
  37. $this->data[$k] = Dever::load('shop/lib/coupon')->getShop($this->data[$k], false, true);
  38. }
  39. }
  40. return $this->data;
  41. }
  42. # 我的礼品卡列表
  43. public function card()
  44. {
  45. $this->data['card'] = Dever::db('goods/card_code')->select_page(array('uid' => $this->uid));
  46. if ($this->data['card']) {
  47. $status = Dever::db('goods/card_code')->config['status'];
  48. $time = time();
  49. foreach ($this->data['card'] as $k => $v) {
  50. if ($v['status'] == 1 && $time > $v['edate']) {
  51. $v['status'] = 4;
  52. Dever::db('goods/card_code')->update(array('where_id' => $v['id'], 'status' => 4));
  53. }
  54. $this->data['card'][$k]['status_name'] = $status[$v['status']];
  55. $this->data['card'][$k]['edate'] = date('Y-m-d', $v['edate']);
  56. $this->data['card'][$k]['goods'] = array();
  57. $info = Dever::db('goods/card')->find($v['card_id']);
  58. $goods = Dever::array_decode($info['goods']);
  59. foreach ($goods as $k1 => $v1) {
  60. $this->data['card'][$k]['goods'][$k1] = Dever::db('goods/info')->find($v1['goods_id']);
  61. $this->data['card'][$k]['goods'][$k1]['num'] = $v1['num'];
  62. }
  63. if (($v['status'] == 2 || $v['status'] == 3) && $v['order_id'] > 0) {
  64. # 查找订单
  65. $order = Dever::db('shop/sell_order')->find($v['order_id']);
  66. $this->data['card'][$k]['order_num'] = $order['order_num'];
  67. } else {
  68. $this->data['card'][$k]['order_num'] = '';
  69. }
  70. }
  71. }
  72. return $this->data;
  73. }
  74. # 检测礼品卡
  75. public function dh_card()
  76. {
  77. $city = Dever::input('city');
  78. $lng = Dever::input('lng');
  79. $lat = Dever::input('lat');
  80. $data['shop'] = Dever::load('shop/lib/info')->get($city, $lng, $lat);
  81. if (!$data['shop']) {
  82. Dever::alert('没有门店');
  83. }
  84. $data['card'] = Dever::load('shop/lib/sell')->set(1, 1)->card($this->uid, $data['shop']);
  85. return $data;
  86. }
  87. # 我的订单列表
  88. public function order()
  89. {
  90. return Dever::load('shop/lib/sell')->set(1, 1)->getList($this->uid);
  91. }
  92. # 查看订单详情
  93. public function order_view()
  94. {
  95. $id = Dever::input('order_id');
  96. return Dever::load('shop/lib/sell')->set(1, 2)->getView($this->uid, $id);
  97. }
  98. # 取消订单
  99. public function order_cancel_commit()
  100. {
  101. $order_id = Dever::input('order_id');
  102. return Dever::load('shop/lib/sell')->set(1, 2)->cancel($this->uid, $order_id);
  103. }
  104. # 用户退款
  105. public function order_tui_commit()
  106. {
  107. $order_id = Dever::input('order_id');
  108. return Dever::load('shop/lib/refund')->set('sell')->apply(1, $this->uid, $order_id, false, 1, 0, '用户自行取消退款');
  109. }
  110. # 获取订单退款记录
  111. public function order_tui_log()
  112. {
  113. $order_id = Dever::input('order_id');
  114. return Dever::load('shop/lib/refund')->set('sell')->getList(1, $this->uid, $order_id);
  115. }
  116. # 我的消息列表
  117. public function msg()
  118. {
  119. $data = Dever::load('message/lib/data')->read($this->uid, false, true);
  120. if ($data) {
  121. foreach ($data as $k => $v) {
  122. $data[$k]['cdate_string'] = Dever::ddate($v['cdate']);
  123. if ($v['param']) {
  124. $data[$k]['param'] = Dever::json_decode($v['param']);
  125. }
  126. }
  127. }
  128. return $data;
  129. }
  130. # 删除消息
  131. public function msg_delete()
  132. {
  133. $id = Dever::input('id');
  134. Dever::db('message/inbox')->delete(array('id' => $id, 'uid' => $this->uid));
  135. return $this->msg();
  136. }
  137. # 查看我的消息 废弃
  138. public function view_msg()
  139. {
  140. $id = Dever::input('id');
  141. $data = Dever::load('message/lib/data')->view($this->uid, $id);
  142. if ($data) {
  143. $data['cdate_string'] = Dever::ddate($data['cdate']);
  144. $type = Dever::db('message/type')->one($data['type']);
  145. $data['type_name'] = $type['name'];
  146. }
  147. return $data;
  148. }
  149. # 我的地址列表
  150. public function address()
  151. {
  152. return Dever::load('passport/address')->getAddress($this->uid);
  153. }
  154. # 获取单个地址信息
  155. public function getAddress()
  156. {
  157. $id = Dever::input('id');
  158. return Dever::load('passport/address')->getOne($this->uid, $id);
  159. }
  160. # 删除单个地址信息
  161. public function delAddress()
  162. {
  163. $id = Dever::input('id');
  164. return Dever::load('passport/address')->del($this->uid, $id, 2);
  165. }
  166. # 我的发票列表
  167. public function invoice()
  168. {
  169. return Dever::load('passport/invoice')->get($this->uid);
  170. }
  171. # 获取单个发票信息
  172. public function getInvoice()
  173. {
  174. $id = Dever::input('id');
  175. return Dever::load('passport/invoice')->getOne($this->uid, $id);
  176. }
  177. # 删除单个发票信息
  178. public function delInvoice()
  179. {
  180. $id = Dever::input('id');
  181. return Dever::load('passport/invoice')->del($this->uid, $id, 2);
  182. }
  183. # 提交反馈
  184. public function feedback()
  185. {
  186. $data['uid'] = $this->uid;
  187. $data['shop_id'] = Dever::input('shop_id');
  188. $data['mobile'] = Dever::input('mobile');
  189. $data['truename'] = Dever::input('truename');
  190. $data['content'] = Dever::input('content');
  191. return Dever::db('shop/feedback')->insert($data);
  192. }
  193. # 领取优惠券
  194. public function take_coupon()
  195. {
  196. }
  197. }