123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494 |
- <?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));
- $card = Dever::db('card/code')->getData(array('dh_uid' => $this->uid));
- //$this->data['card_num'] = Dever::db('card/code')->total(array('dh_uid' => $this->uid));
- $this->data['card_num'] = 0;
- if ($card) {
- $time = time();
- foreach ($card as $k => $v) {
- $state = Dever::load('card/lib/code')->check($v);
- if ($state > 0) {
- $this->data['card_num']++;
- }
- }
- }
- $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';
- $this->getBindInfo();
- return $this->data;
- }
- # 获取钱包记录表
- public function getCash()
- {
- $this->data['config'] = Dever::db('main/sell_config')->find();
- $this->data['user'] = $this->user;
- $this->data['type'] = Dever::db('shop/user_money')->config['set']['type'];
- $this->data['status'] = Dever::db('shop/user_money')->config['set']['status'];
- $where['mid'] = $this->uid;
- $type = Dever::input('type');
- if ($type) {
- $where['type'] = $type;
- }
- $day = Dever::input('day');
- $this->data['list'] = Dever::db('shop/user_money')->getData($where);
- if ($this->data['list']) {
- foreach ($this->data['list'] as $k => $v) {
- $this->data['list'][$k]['type_name'] = Dever::status($this->data['type'], $v['type']);
- $this->data['list'][$k]['status_name'] = Dever::status($this->data['status'], $v['status']);
- if ($v['type'] == 11) {
- $tixian = Dever::db('bill/tixian')->find($v['type_id']);
- if ($tixian && $tixian['status'] == 2) {
- $this->data['list'][$k]['status_name'] .= '(已发放)';
- } else {
- $this->data['list'][$k]['status_name'] .= '(待发放)';
- }
- }
- $this->data['list'][$k]['cdate'] = date('Y-m-d H:i', $v['cdate']);
- if ($v['cash'] > 0) {
- $this->data['list'][$k]['cash'] = '+' . $v['cash'];
- }
- }
- }
- return $this->data;
- }
- public function getCashView()
- {
- $where['mid'] = $this->uid;
- $where['id'] = Dever::input('id');
- $this->data['info'] = Dever::db('shop/user_money')->find($where);
- $config = Dever::db('shop/user_money')->config['set'];
- if ($this->data['info']) {
- $this->data['info']['type_name'] = Dever::status($config['type'], $this->data['info']['type']);
- $this->data['info']['status_name'] = Dever::status($config['status'], $this->data['info']['status']);
- $this->data['info']['cdate'] = date('Y-m-d H:i', $this->data['info']['cdate']);
- if ($this->data['info']['cash'] > 0) {
- $this->data['info']['cash'] = '+' . $this->data['info']['cash'];
- }
- if ($this->data['info']['type'] == 11) {
- $tixian = Dever::db('bill/tixian')->find($this->data['info']['type_id']);
- if ($tixian && $tixian['status'] == 2) {
- $this->data['info']['status_name'] .= '(已发放)';
- } else {
- $this->data['info']['status_name'] .= '(待发放)';
- }
- }
- }
- return $this->data;
- }
- # 钱包充值
- public function payCash()
- {
- $num = Dever::input('num');
- if ($num <= 0) {
- Dever::alert('请输入充值金额');
- }
- return Dever::load('shop/lib/money')->pay($this->uid, $num);
- }
- # 提现
- public function tixian()
- {
-
- }
- public function getBindInfo()
- {
- # 获取代理商绑定信息
- $bind = Dever::db('agent/user_bind')->find(array('uid' => $this->uid));
- if ($bind && $bind['status'] == 2 && $bind['mid']) {
- $this->data['bind_info'] = $bind;
- $this->data['bind_status'] = $bind['status'];
- $this->data['bind_desc'] = $bind['audit_desc'];
- $this->data['agent'][] = Dever::load('agent/lib/member')->getInfo($bind['mid']);
- } elseif ($bind && $bind['status'] != 2) {
- $this->data['bind_info'] = $bind;
- $this->data['agent'][] = Dever::load('agent/lib/member')->getInfo($bind['mid']);
- $this->data['bind_status'] = $bind['status'];
- $this->data['bind_desc'] = $bind['audit_desc'];
- } else {
- $this->data['bind_status'] = 0;
- $this->data['bind_desc'] = '';
- }
- 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')->one($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()
- {
-
- }
- # 绑定代理商
- public function bind()
- {
- $data['mobile'] = Dever::input('mobile');
- $data['idcard'] = Dever::input('idcard');
- /*
- $data['type'] = Dever::input('type', 1);
- $data['name'] = Dever::input('name');
- $data['idcard'] = Dever::input('idcard');
- $data['idcard_front'] = Dever::input('idcard_front');
- $data['idcard_back'] = Dever::input('idcard_back');
- $data['company_name'] = Dever::input('company_name');
- $data['company_pic'] = Dever::input('company_pic');
- $data['company_number'] = Dever::input('company_number');
- if (!$data['name']) {
- Dever::alert('姓名不能为空');
- }
- */
- if (!$data['mobile']) {
- Dever::alert('手机号不能为空');
- }
- Dever::load('agent/lib/member')->checkMcode($data['mobile']);
- $member = Dever::db('agent/member')->find(array('mobile' => $data['mobile']));
- if (!$member) {
- Dever::alert('代理商还未注册');
- }
- if ($member['status'] != 2) {
- Dever::alert('代理商还未审核通过或已被禁用');
- }
-
- $data['mid'] = $member['id'];
-
- if (!$data['idcard']) {
- Dever::alert('身份证号不能为空');
- }
- if ($data['idcard'] != $member['idcard']) {
- Dever::alert('您填写的身份证号与代理商身份证号不一致');
- }
- /*
- if (!$data['idcard_front']) {
- Dever::alert('身份证正面不能为空');
- }
- if (!$data['idcard_back']) {
- Dever::alert('身份证反面不能为空');
- }
- if ($data['type'] == 2) {
- if (!$data['company_name']) {
- Dever::alert('公司名称不能为空');
- }
- if (!$data['company_pic']) {
- Dever::alert('营业执照照片不能为空');
- }
- if (!$data['company_number']) {
- Dever::alert('营业执照号码不能为空');
- }
- }
- */
- $info = Dever::db('agent/user_bind')->find(array('mid' => $data['mid'], 'status' => 2));
- if ($info) {
- Dever::alert('该代理商信息已绑定');
- }
- $info = Dever::db('agent/user_bind')->find(array('uid' => $this->uid));
- if (!$info) {
- $data['uid'] = $this->uid;
- $data['status'] = 2;
- Dever::db('agent/user_bind')->insert($data);
- return 'ok';
- } else {
- $data['where_id'] = $info['id'];
- $data['status'] = 2;
- Dever::db('agent/user_bind')->update($data);
- return 'ok';
- }
- }
- #资金账户列表
- public function record_list(){
- $shop_id = Dever::input('shop_id');
- $month = Dever::input('month');
- $shop = Dever::db('shop/info')->find($shop_id);
- $data = array();
- $data['price'] = $shop['price'];
- if($month){
- $start = $month .'-01 00:00:00';
- $end = date('Y-m-d', strtotime($start. ' +1 month -1 day')).' 23:59:59';
- }else{
- $start = strtotime(date('Y-m'));
- $end = strtotime(date('Y-m-d 23:59:59',strtotime(date('Y-m-01', $start)."+1 month - 1 day")));
- }
- $data['list'] = Dever::db('shop/record')->getAll(array('start'=>$start,'end'=>$end,'shop_id'=>$shop_id,'state'=>1));
- foreach($data['list'] as $k=>$v){
- if($v['type'] == 1 || $v['type'] == 3 || $v['type'] == 6 || $v['type'] == 7 || $v['type'] == 8){
- $data['list'][$k]['price'] = '+'.$v['price'];
- }else{
- $data['list'][$k]['price'] = '-'.$v['price'];
- }
- $data['list'][$k]['cdate'] = date('Y.m.d H:i',$v['cdate']);
- $typeconfig = Dever::db('shop/record')->config['config_type'];
- $data['list'][$k]['type_name'] = Dever::status($typeconfig,$v['type']);
- $config = Dever::db('shop/record')->config['config_status'];
- $data['list'][$k]['status_name'] = Dever::status($config,$v['status']);
- }
- $data['fund'] = Dever::db('main/manage_config')->getFund(array('state'=>1));
- return $data;
- }
- #资金账户详情页
- public function record_desc(){
- $id = Dever::input('id');
- $data = Dever::db('shop/record')->find($id);
- if($data['type'] == 1 || $data['type'] == 3 || $data['type'] == 6 || $data['type'] == 7 || $data['type'] == 8){
- $data['price'] = '+'.$data['price'];
- }else{
- $data['price'] = '-'.$data['price'];
- }
- $typeconfig = Dever::db('shop/record')->config['config_type'];
- $data['type_name'] = Dever::status($typeconfig,$data['type']);
- $config = Dever::db('shop/record')->config['config_status'];
- $data['status_name'] = Dever::status($config,$data['status']);
- $data['cdate'] = date('Y.m.d H:i',$data['cdate']);
- return $data;
- }
- }
|