My.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  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. $card = Dever::db('card/code')->getData(array('dh_uid' => $this->uid));
  18. //$this->data['card_num'] = Dever::db('card/code')->total(array('dh_uid' => $this->uid));
  19. $this->data['card_num'] = 0;
  20. if ($card) {
  21. $time = time();
  22. foreach ($card as $k => $v) {
  23. $state = Dever::load('card/lib/code')->check($v);
  24. if ($state > 0) {
  25. $this->data['card_num']++;
  26. }
  27. }
  28. }
  29. $this->data['score'] = Dever::load('score/lib/core')->getUserScore($this->uid);
  30. $this->data['msg'] = Dever::load('message/lib/data')->num($this->uid);
  31. $this->data['level'] = 'Lv1';
  32. $this->getBindInfo();
  33. return $this->data;
  34. }
  35. # 获取钱包记录表
  36. public function getCash()
  37. {
  38. $this->data['config'] = Dever::db('main/sell_config')->find();
  39. $this->data['user'] = $this->user;
  40. $this->data['type'] = Dever::db('shop/user_money')->config['set']['type'];
  41. $this->data['status'] = Dever::db('shop/user_money')->config['set']['status'];
  42. $where['mid'] = $this->uid;
  43. $type = Dever::input('type');
  44. if ($type) {
  45. $where['type'] = $type;
  46. }
  47. $day = Dever::input('day');
  48. $this->data['list'] = Dever::db('shop/user_money')->getData($where);
  49. if ($this->data['list']) {
  50. foreach ($this->data['list'] as $k => $v) {
  51. $this->data['list'][$k]['type_name'] = Dever::status($this->data['type'], $v['type']);
  52. $this->data['list'][$k]['status_name'] = Dever::status($this->data['status'], $v['status']);
  53. if ($v['type'] == 11) {
  54. $tixian = Dever::db('bill/tixian')->find($v['type_id']);
  55. if ($tixian && $tixian['status'] == 2) {
  56. $this->data['list'][$k]['status_name'] .= '(已发放)';
  57. } else {
  58. $this->data['list'][$k]['status_name'] .= '(待发放)';
  59. }
  60. }
  61. $this->data['list'][$k]['cdate'] = date('Y-m-d H:i', $v['cdate']);
  62. if ($v['cash'] > 0) {
  63. $this->data['list'][$k]['cash'] = '+' . $v['cash'];
  64. }
  65. }
  66. }
  67. return $this->data;
  68. }
  69. public function getCashView()
  70. {
  71. $where['mid'] = $this->uid;
  72. $where['id'] = Dever::input('id');
  73. $this->data['info'] = Dever::db('shop/user_money')->find($where);
  74. $config = Dever::db('shop/user_money')->config['set'];
  75. if ($this->data['info']) {
  76. $this->data['info']['type_name'] = Dever::status($config['type'], $this->data['info']['type']);
  77. $this->data['info']['status_name'] = Dever::status($config['status'], $this->data['info']['status']);
  78. $this->data['info']['cdate'] = date('Y-m-d H:i', $this->data['info']['cdate']);
  79. if ($this->data['info']['cash'] > 0) {
  80. $this->data['info']['cash'] = '+' . $this->data['info']['cash'];
  81. }
  82. if ($this->data['info']['type'] == 11) {
  83. $tixian = Dever::db('bill/tixian')->find($this->data['info']['type_id']);
  84. if ($tixian && $tixian['status'] == 2) {
  85. $this->data['info']['status_name'] .= '(已发放)';
  86. } else {
  87. $this->data['info']['status_name'] .= '(待发放)';
  88. }
  89. }
  90. }
  91. return $this->data;
  92. }
  93. # 钱包充值
  94. public function payCash()
  95. {
  96. $num = Dever::input('num');
  97. if ($num <= 0) {
  98. Dever::alert('请输入充值金额');
  99. }
  100. return Dever::load('shop/lib/money')->pay($this->uid, $num);
  101. }
  102. # 提现
  103. public function tixian()
  104. {
  105. }
  106. public function getBindInfo()
  107. {
  108. # 获取代理商绑定信息
  109. $bind = Dever::db('agent/user_bind')->find(array('uid' => $this->uid));
  110. if ($bind && $bind['status'] == 2 && $bind['mid']) {
  111. $this->data['bind_info'] = $bind;
  112. $this->data['bind_status'] = $bind['status'];
  113. $this->data['bind_desc'] = $bind['audit_desc'];
  114. $this->data['agent'][] = Dever::load('agent/lib/member')->getInfo($bind['mid']);
  115. } elseif ($bind && $bind['status'] != 2) {
  116. $this->data['bind_info'] = $bind;
  117. $this->data['agent'][] = Dever::load('agent/lib/member')->getInfo($bind['mid']);
  118. $this->data['bind_status'] = $bind['status'];
  119. $this->data['bind_desc'] = $bind['audit_desc'];
  120. } else {
  121. $this->data['bind_status'] = 0;
  122. $this->data['bind_desc'] = '';
  123. }
  124. return $this->data;
  125. }
  126. # 我的优惠券列表
  127. public function coupon()
  128. {
  129. $this->data = Dever::db('shop/user_coupon')->getAllPage(array('uid' => $this->uid));
  130. if ($this->data) {
  131. $time = time();
  132. foreach ($this->data as $k => $v) {
  133. if ($time > $v['edate']) {
  134. $this->data[$k]['status'] = 3;
  135. }
  136. $this->data[$k]['edate'] = date('Y-m-d', $v['edate']);
  137. $this->data[$k]['info'] = Dever::db('goods/coupon')->find($v['coupon_id']);
  138. $this->data[$k]['shop'] = array();
  139. $this->data[$k]['method'] = $this->data[$k]['info']['method'];
  140. $this->data[$k] = Dever::load('shop/lib/coupon')->getShop($this->data[$k], false, true);
  141. }
  142. }
  143. return $this->data;
  144. }
  145. # 我的礼品卡列表 废弃
  146. public function card()
  147. {
  148. $this->data['card'] = Dever::db('goods/card_code')->select_page(array('uid' => $this->uid));
  149. if ($this->data['card']) {
  150. $status = Dever::db('goods/card_code')->config['status'];
  151. $time = time();
  152. foreach ($this->data['card'] as $k => $v) {
  153. if ($v['status'] == 1 && $time > $v['edate']) {
  154. $v['status'] = 4;
  155. Dever::db('goods/card_code')->update(array('where_id' => $v['id'], 'status' => 4));
  156. }
  157. $this->data['card'][$k]['status_name'] = $status[$v['status']];
  158. $this->data['card'][$k]['edate'] = date('Y-m-d', $v['edate']);
  159. $this->data['card'][$k]['goods'] = array();
  160. $info = Dever::db('goods/card')->find($v['card_id']);
  161. $goods = Dever::array_decode($info['goods']);
  162. foreach ($goods as $k1 => $v1) {
  163. $this->data['card'][$k]['goods'][$k1] = Dever::db('goods/info')->one($v1['goods_id']);
  164. $this->data['card'][$k]['goods'][$k1]['num'] = $v1['num'];
  165. }
  166. if (($v['status'] == 2 || $v['status'] == 3) && $v['order_id'] > 0) {
  167. # 查找订单
  168. $order = Dever::db('shop/sell_order')->find($v['order_id']);
  169. $this->data['card'][$k]['order_num'] = $order['order_num'];
  170. } else {
  171. $this->data['card'][$k]['order_num'] = '';
  172. }
  173. }
  174. }
  175. return $this->data;
  176. }
  177. # 检测礼品卡 废弃
  178. public function dh_card()
  179. {
  180. $city = Dever::input('city');
  181. $lng = Dever::input('lng');
  182. $lat = Dever::input('lat');
  183. $data['shop'] = Dever::load('shop/lib/info')->get($city, $lng, $lat);
  184. if (!$data['shop']) {
  185. Dever::alert('没有门店');
  186. }
  187. $data['card'] = Dever::load('shop/lib/sell')->set(1, 1)->card($this->uid, $data['shop']);
  188. return $data;
  189. }
  190. # 我的订单列表
  191. public function order()
  192. {
  193. return Dever::load('shop/lib/sell')->set(1, 1)->getList($this->uid);
  194. }
  195. # 查看订单详情
  196. public function order_view()
  197. {
  198. $id = Dever::input('order_id');
  199. return Dever::load('shop/lib/sell')->set(1, 2)->getView($this->uid, $id);
  200. }
  201. # 取消订单
  202. public function order_cancel_commit()
  203. {
  204. $order_id = Dever::input('order_id');
  205. return Dever::load('shop/lib/sell')->set(1, 2)->cancel($this->uid, $order_id);
  206. }
  207. # 用户退款
  208. public function order_tui_commit()
  209. {
  210. $order_id = Dever::input('order_id');
  211. return Dever::load('shop/lib/refund')->set('sell')->apply(1, $this->uid, $order_id, false, 1, 0, '用户自行取消退款');
  212. }
  213. # 获取订单退款记录
  214. public function order_tui_log()
  215. {
  216. $order_id = Dever::input('order_id');
  217. return Dever::load('shop/lib/refund')->set('sell')->getList(1, $this->uid, $order_id);
  218. }
  219. # 我的消息列表
  220. public function msg()
  221. {
  222. $data = Dever::load('message/lib/data')->read($this->uid, false, true);
  223. if ($data) {
  224. foreach ($data as $k => $v) {
  225. $data[$k]['cdate_string'] = Dever::ddate($v['cdate']);
  226. if ($v['param']) {
  227. $data[$k]['param'] = Dever::json_decode($v['param']);
  228. }
  229. }
  230. }
  231. return $data;
  232. }
  233. # 删除消息
  234. public function msg_delete()
  235. {
  236. $id = Dever::input('id');
  237. Dever::db('message/inbox')->delete(array('id' => $id, 'uid' => $this->uid));
  238. return $this->msg();
  239. }
  240. # 查看我的消息 废弃
  241. public function view_msg()
  242. {
  243. $id = Dever::input('id');
  244. $data = Dever::load('message/lib/data')->view($this->uid, $id);
  245. if ($data) {
  246. $data['cdate_string'] = Dever::ddate($data['cdate']);
  247. $type = Dever::db('message/type')->one($data['type']);
  248. $data['type_name'] = $type['name'];
  249. }
  250. return $data;
  251. }
  252. # 我的地址列表
  253. public function address()
  254. {
  255. return Dever::load('passport/address')->getAddress($this->uid);
  256. }
  257. # 获取单个地址信息
  258. public function getAddress()
  259. {
  260. $id = Dever::input('id');
  261. return Dever::load('passport/address')->getOne($this->uid, $id);
  262. }
  263. # 删除单个地址信息
  264. public function delAddress()
  265. {
  266. $id = Dever::input('id');
  267. return Dever::load('passport/address')->del($this->uid, $id, 2);
  268. }
  269. # 我的发票列表
  270. public function invoice()
  271. {
  272. return Dever::load('passport/invoice')->get($this->uid);
  273. }
  274. # 获取单个发票信息
  275. public function getInvoice()
  276. {
  277. $id = Dever::input('id');
  278. return Dever::load('passport/invoice')->getOne($this->uid, $id);
  279. }
  280. # 删除单个发票信息
  281. public function delInvoice()
  282. {
  283. $id = Dever::input('id');
  284. return Dever::load('passport/invoice')->del($this->uid, $id, 2);
  285. }
  286. # 提交反馈
  287. public function feedback()
  288. {
  289. $data['uid'] = $this->uid;
  290. $data['shop_id'] = Dever::input('shop_id');
  291. $data['mobile'] = Dever::input('mobile');
  292. $data['truename'] = Dever::input('truename');
  293. $data['content'] = Dever::input('content');
  294. return Dever::db('shop/feedback')->insert($data);
  295. }
  296. # 领取优惠券
  297. public function take_coupon()
  298. {
  299. }
  300. # 绑定代理商
  301. public function bind()
  302. {
  303. $data['mobile'] = Dever::input('mobile');
  304. $data['idcard'] = Dever::input('idcard');
  305. /*
  306. $data['type'] = Dever::input('type', 1);
  307. $data['name'] = Dever::input('name');
  308. $data['idcard'] = Dever::input('idcard');
  309. $data['idcard_front'] = Dever::input('idcard_front');
  310. $data['idcard_back'] = Dever::input('idcard_back');
  311. $data['company_name'] = Dever::input('company_name');
  312. $data['company_pic'] = Dever::input('company_pic');
  313. $data['company_number'] = Dever::input('company_number');
  314. if (!$data['name']) {
  315. Dever::alert('姓名不能为空');
  316. }
  317. */
  318. if (!$data['mobile']) {
  319. Dever::alert('手机号不能为空');
  320. }
  321. Dever::load('agent/lib/member')->checkMcode($data['mobile']);
  322. $member = Dever::db('agent/member')->find(array('mobile' => $data['mobile']));
  323. if (!$member) {
  324. Dever::alert('代理商还未注册');
  325. }
  326. if ($member['status'] != 2) {
  327. Dever::alert('代理商还未审核通过或已被禁用');
  328. }
  329. $data['mid'] = $member['id'];
  330. if (!$data['idcard']) {
  331. Dever::alert('身份证号不能为空');
  332. }
  333. if ($data['idcard'] != $member['idcard']) {
  334. Dever::alert('您填写的身份证号与代理商身份证号不一致');
  335. }
  336. /*
  337. if (!$data['idcard_front']) {
  338. Dever::alert('身份证正面不能为空');
  339. }
  340. if (!$data['idcard_back']) {
  341. Dever::alert('身份证反面不能为空');
  342. }
  343. if ($data['type'] == 2) {
  344. if (!$data['company_name']) {
  345. Dever::alert('公司名称不能为空');
  346. }
  347. if (!$data['company_pic']) {
  348. Dever::alert('营业执照照片不能为空');
  349. }
  350. if (!$data['company_number']) {
  351. Dever::alert('营业执照号码不能为空');
  352. }
  353. }
  354. */
  355. $info = Dever::db('agent/user_bind')->find(array('mid' => $data['mid'], 'status' => 2));
  356. if ($info) {
  357. Dever::alert('该代理商信息已绑定');
  358. }
  359. $info = Dever::db('agent/user_bind')->find(array('uid' => $this->uid));
  360. if (!$info) {
  361. $data['uid'] = $this->uid;
  362. $data['status'] = 2;
  363. Dever::db('agent/user_bind')->insert($data);
  364. return 'ok';
  365. } else {
  366. $data['where_id'] = $info['id'];
  367. $data['status'] = 2;
  368. Dever::db('agent/user_bind')->update($data);
  369. return 'ok';
  370. }
  371. }
  372. #资金账户列表
  373. public function record_list(){
  374. $shop_id = Dever::input('shop_id');
  375. $month = Dever::input('month');
  376. $shop = Dever::db('shop/info')->find($shop_id);
  377. $data = array();
  378. $data['price'] = $shop['price'];
  379. if($month){
  380. $start = $month .'-01 00:00:00';
  381. $end = date('Y-m-d', strtotime($start. ' +1 month -1 day')).' 23:59:59';
  382. }else{
  383. $start = strtotime(date('Y-m'));
  384. $end = strtotime(date('Y-m-d 23:59:59',strtotime(date('Y-m-01', $start)."+1 month - 1 day")));
  385. }
  386. $data['list'] = Dever::db('shop/record')->getAll(array('start'=>$start,'end'=>$end,'shop_id'=>$shop_id,'state'=>1));
  387. foreach($data['list'] as $k=>$v){
  388. if($v['type'] == 1 || $v['type'] == 3 || $v['type'] == 6 || $v['type'] == 7 || $v['type'] == 8){
  389. $data['list'][$k]['price'] = '+'.$v['price'];
  390. }else{
  391. $data['list'][$k]['price'] = '-'.$v['price'];
  392. }
  393. $data['list'][$k]['cdate'] = date('Y.m.d H:i',$v['cdate']);
  394. $typeconfig = Dever::db('shop/record')->config['config_type'];
  395. $data['list'][$k]['type_name'] = Dever::status($typeconfig,$v['type']);
  396. $config = Dever::db('shop/record')->config['config_status'];
  397. $data['list'][$k]['status_name'] = Dever::status($config,$v['status']);
  398. }
  399. $data['fund'] = Dever::db('main/manage_config')->getFund(array('state'=>1));
  400. return $data;
  401. }
  402. #资金账户详情页
  403. public function record_desc(){
  404. $id = Dever::input('id');
  405. $data = Dever::db('shop/record')->find($id);
  406. if($data['type'] == 1 || $data['type'] == 3 || $data['type'] == 6 || $data['type'] == 7 || $data['type'] == 8){
  407. $data['price'] = '+'.$data['price'];
  408. }else{
  409. $data['price'] = '-'.$data['price'];
  410. }
  411. $typeconfig = Dever::db('shop/record')->config['config_type'];
  412. $data['type_name'] = Dever::status($typeconfig,$data['type']);
  413. $config = Dever::db('shop/record')->config['config_status'];
  414. $data['status_name'] = Dever::status($config,$data['status']);
  415. $data['cdate'] = date('Y.m.d H:i',$data['cdate']);
  416. return $data;
  417. }
  418. }