123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- <?php
- namespace Shop\Src;
- use Dever;
- use Main\Lib\Core;
- class My extends Core
- {
- public function __construct()
- {
- parent::__construct();
- $this->checkLogin();
- }
- public function getInfo()
- {
- $this->data['user'] = $this->user;
- # 获取拥有的优惠券数量
- $this->data['coupon_num'] = Dever::db('shop/user_coupon')->total(array('uid' => $this->uid, 'status' => 1));
- $this->data['card_num'] = Dever::db('goods/card_code')->total(array('uid' => $this->uid));
- $this->data['score'] = Dever::load('score/lib/core')->getUserScore($this->uid);
- $this->data['msg'] = Dever::load('message/lib/data')->num($this->uid);
- $this->data['level'] = 'Lv1';
- return $this->data;
- }
- # 我的优惠券列表
- public function coupon()
- {
- $this->data = Dever::db('shop/user_coupon')->getAllPage(array('uid' => $this->uid));
- if ($this->data) {
- $time = time();
- foreach ($this->data as $k => $v) {
- if ($time > $v['edate']) {
- $this->data[$k]['status'] = 3;
- }
- $this->data[$k]['edate'] = date('Y-m-d', $v['edate']);
- $this->data[$k]['info'] = Dever::db('goods/coupon')->find($v['coupon_id']);
- $this->data[$k]['shop'] = array();
- $this->data[$k]['method'] = $this->data[$k]['info']['method'];
- $this->data[$k] = Dever::load('shop/lib/coupon')->getShop($this->data[$k], false, true);
- }
- }
- return $this->data;
- }
- # 我的礼品卡列表
- public function card()
- {
- $this->data['card'] = Dever::db('goods/card_code')->select_page(array('uid' => $this->uid));
- if ($this->data['card']) {
- $status = Dever::db('goods/card_code')->config['status'];
- $time = time();
- foreach ($this->data['card'] as $k => $v) {
- if ($v['status'] == 1 && $time > $v['edate']) {
- $v['status'] = 4;
- Dever::db('goods/card_code')->update(array('where_id' => $v['id'], 'status' => 4));
- }
- $this->data['card'][$k]['status_name'] = $status[$v['status']];
- $this->data['card'][$k]['edate'] = date('Y-m-d', $v['edate']);
- $this->data['card'][$k]['goods'] = array();
- $info = Dever::db('goods/card')->find($v['card_id']);
- $goods = Dever::array_decode($info['goods']);
- foreach ($goods as $k1 => $v1) {
- $this->data['card'][$k]['goods'][$k1] = Dever::db('goods/info')->find($v1['goods_id']);
- $this->data['card'][$k]['goods'][$k1]['num'] = $v1['num'];
- }
- if (($v['status'] == 2 || $v['status'] == 3) && $v['order_id'] > 0) {
- # 查找订单
- $order = Dever::db('shop/sell_order')->find($v['order_id']);
- $this->data['card'][$k]['order_num'] = $order['order_num'];
- } else {
- $this->data['card'][$k]['order_num'] = '';
- }
- }
- }
- return $this->data;
- }
- # 检测礼品卡
- public function dh_card()
- {
- $city = Dever::input('city');
- $lng = Dever::input('lng');
- $lat = Dever::input('lat');
- $data['shop'] = Dever::load('shop/lib/info')->get($city, $lng, $lat);
- if (!$data['shop']) {
- Dever::alert('没有门店');
- }
- $data['card'] = Dever::load('shop/lib/sell')->set(1, 1)->card($this->uid, $data['shop']);
-
- return $data;
- }
- # 我的订单列表
- public function order()
- {
- return Dever::load('shop/lib/sell')->set(1, 1)->getList($this->uid);
- }
- # 查看订单详情
- public function order_view()
- {
- $id = Dever::input('order_id');
- return Dever::load('shop/lib/sell')->set(1, 2)->getView($this->uid, $id);
- }
- # 取消订单
- public function order_cancel_commit()
- {
- $order_id = Dever::input('order_id');
- return Dever::load('shop/lib/sell')->set(1, 2)->cancel($this->uid, $order_id);
- }
- # 用户退款
- public function order_tui_commit()
- {
- $order_id = Dever::input('order_id');
- return Dever::load('shop/lib/refund')->set('sell')->apply(1, $this->uid, $order_id, false, 1, 0, '用户自行取消退款');
- }
- # 获取订单退款记录
- public function order_tui_log()
- {
- $order_id = Dever::input('order_id');
- return Dever::load('shop/lib/refund')->set('sell')->getList(1, $this->uid, $order_id);
- }
- # 我的消息列表
- public function msg()
- {
- $data = Dever::load('message/lib/data')->read($this->uid, false, true);
- if ($data) {
- foreach ($data as $k => $v) {
- $data[$k]['cdate_string'] = Dever::ddate($v['cdate']);
- if ($v['param']) {
- $data[$k]['param'] = Dever::json_decode($v['param']);
- }
- }
- }
- return $data;
- }
- # 删除消息
- public function msg_delete()
- {
- $id = Dever::input('id');
- Dever::db('message/inbox')->delete(array('id' => $id, 'uid' => $this->uid));
- return $this->msg();
- }
- # 查看我的消息 废弃
- public function view_msg()
- {
- $id = Dever::input('id');
- $data = Dever::load('message/lib/data')->view($this->uid, $id);
- if ($data) {
- $data['cdate_string'] = Dever::ddate($data['cdate']);
- $type = Dever::db('message/type')->one($data['type']);
- $data['type_name'] = $type['name'];
- }
- return $data;
- }
- # 我的地址列表
- public function address()
- {
- return Dever::load('passport/address')->getAddress($this->uid);
- }
- # 获取单个地址信息
- public function getAddress()
- {
- $id = Dever::input('id');
- return Dever::load('passport/address')->getOne($this->uid, $id);
- }
- # 删除单个地址信息
- public function delAddress()
- {
- $id = Dever::input('id');
- return Dever::load('passport/address')->del($this->uid, $id, 2);
- }
- # 我的发票列表
- public function invoice()
- {
- return Dever::load('passport/invoice')->get($this->uid);
- }
- # 获取单个发票信息
- public function getInvoice()
- {
- $id = Dever::input('id');
- return Dever::load('passport/invoice')->getOne($this->uid, $id);
- }
- # 删除单个发票信息
- public function delInvoice()
- {
- $id = Dever::input('id');
- return Dever::load('passport/invoice')->del($this->uid, $id, 2);
- }
- # 提交反馈
- public function feedback()
- {
- $data['uid'] = $this->uid;
- $data['shop_id'] = Dever::input('shop_id');
- $data['mobile'] = Dever::input('mobile');
- $data['truename'] = Dever::input('truename');
- $data['content'] = Dever::input('content');
- return Dever::db('shop/feedback')->insert($data);
- }
- # 领取优惠券
- public function take_coupon()
- {
-
- }
- }
|