dever 3 年之前
父節點
當前提交
810aa37791
共有 4 個文件被更改,包括 145 次插入79 次删除
  1. 1 1
      app/mshop/index.php
  2. 26 3
      app/mshop/src/Core.php
  3. 83 0
      app/mshop/src/Data.php
  4. 35 75
      app/mshop/src/Main.php

+ 1 - 1
app/mshop/index.php

@@ -1,7 +1,7 @@
 <?php
 
 define('DEVER_APP_NAME', 'mshop');
-define('DEVER_APP_LANG', '门店管理');
+define('DEVER_APP_LANG', '门店管理系统');
 define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
 define('DEVER_MANAGE_ORDER', 70);
 define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-component');

+ 26 - 3
app/mshop/src/Core.php

@@ -3,14 +3,21 @@
 namespace Mshop\Src;
 
 use Dever;
-use Main\Lib\Core as Base;
 
-class Core extends Base
+class Core
 {
     public function __construct()
     {
-        parent::__construct();
+        $this->uid = Dever::load('passport/user')->check(false);
+        if ($this->uid <= 0) {
+            $this->uid = 1;
+        }
+        if ($this->uid) {
+            $this->user = Dever::db('shop/member')->find($this->uid);
+        }
+
         $this->checkLogin();
+
         $this->shop_id = Dever::input('shop_id');
 
         if (!$this->shop_id) {
@@ -27,4 +34,20 @@ class Core extends Base
             Dever::alert('门店不存在');
         }
     }
+
+    public function checkLogin()
+    {
+        if (!$this->uid || $this->uid <= 0) {
+            Dever::alert('请先登录', -2);
+        }
+    }
+
+    public function alert($state)
+    {
+        if ($state) {
+            return array('msg' => 'ok');
+        } else {
+            Dever::alert('操作失败');
+        }
+    }
 }

+ 83 - 0
app/mshop/src/Data.php

@@ -0,0 +1,83 @@
+<?php
+
+namespace Mshop\Src;
+
+use Dever;
+
+class Data extends Core
+{
+    public function home()
+    {
+        $day = Dever::input('day');
+
+        if (!$day) {
+            $day = date('Y-m-d');
+        }
+
+        $where['start'] = Dever::maketime($day . ' 00:00:00');
+        $where['end'] = Dever::maketime($day . '23:59:59');
+        $where['shop_id'] = $this->shop_id;
+
+        $this->data['num_order'] = Dever::db('shop/sell_order')->getOrderNum($where);
+        $this->data['num_cash'] = Dever::db('shop/sell_order')->getCashNum($where);
+        $this->data['num_goods'] = Dever::db('shop/sell_order')->getGoodsNum($where);
+
+        return $this->data;
+    }
+
+    # 销售订单管理
+    public function sell_order()
+    {
+        $where['shop_id'] = $this->shop_id;
+
+        $day = Dever::input('day');
+
+        
+        $this->data = Dever::db('shop/sell_order')->page($where);
+
+        if ($this->data) {
+            $this->config = Dever::db('shop/sell_order')->config;
+            foreach ($this->data as $k => $v) {
+                $this->data[$k] = $this->order_info($v);
+            }
+        }
+
+        return $this->data;
+    }
+
+    # 获取订单详细信息
+    public function order_info($info, $type = 1)
+    {
+        $info['status_name'] = $this->config['status'][$info['status']];
+        $info['method_name'] = $this->config['method'][$info['method']];
+
+        if ($info['method'] == 1 && $info['status'] > 1) {
+
+        }
+        $info['goods'] = Dever::db('shop/sell_order_goods')->select(array('order_id' => $info['id']));
+        $info['shop'] = Dever::db('shop/info')->find($info['shop_id']);
+        $info['cdate'] = date('Y-m-d H:i', $info['cdate']);
+
+        if ($type == 2) {
+            foreach ($info['goods'] as $k => $v) {
+                $info['goods']['info'] = Dever::load('goods/lib/info')->getInfo($v['goods_id']);
+            }
+            if ($info['address_id']) {
+                $info['address'] = Dever::db('passport/address')->find($info['address_id']);
+            }
+
+            if ($info['invoice_id']) {
+                $info['invoice'] = Dever::db('passport/invoice')->find($info['invoice_id']);
+            }
+
+            if ($info['coupon_id']) {
+                $coupon = Dever::db('shop/user_coupon')->find($info['coupon_id']);
+                if ($coupon) {
+                    $info['coupon'] = Dever::db('goods/coupon')->find($coupon['coupon_id']);
+                }
+            }
+        }
+
+        return $info;
+    }
+}

+ 35 - 75
app/mshop/src/Main.php

@@ -6,6 +6,41 @@ use Dever;
 
 class Main extends Core
 {
+    # 登录
+    public function login()
+    {
+        $where['mobile'] = Dever::load('passport/reg')->checkMobileExists(false, -1, 'shop/member');
+
+        $user = Dever::db('shop/member')->select($where);
+
+        if ($user) {
+            $this->data['uid'] = $user['id'];
+            $this->data['signature'] = Dever::login($user['id']);
+            $this->data['user'] = $user;
+            $this->data['shop'] = array();
+            $this->data['shop_num'] = count($user);
+            $this->data['shop_id'] = false;
+            foreach ($user as $k => $v) {
+                $this->data['shop'][] = Dever::db('shop/info')->getOne($v['shop_id']);
+                $this->data['shop_id'] = $v['shop_id'];
+            }
+
+            return $this->data;
+        } else {
+            Dever::alert('登录失败,手机号不存在');
+        }
+    }
+
+    # 获取验证码
+    public function mcode()
+    {
+        $mobile = Dever::load('passport/reg')->checkMobileExists(1, -1, 'shop/member');
+
+        $msg = Dever::load('passport/reg')->getMcode_action($mobile);
+        
+        return $msg;
+    }
+
     # 申请合作
     public function apply()
     {
@@ -54,79 +89,4 @@ class Main extends Core
         $this->data['msg'] = '提交成功,我们会在3个工作日内与您联系,感谢您的信任。';
         return $this->data;
     }
-    
-    public function home()
-    {
-        $day = Dever::input('day');
-
-        if (!$day) {
-            $day = date('Y-m-d');
-        }
-
-        $where['start'] = Dever::maketime($day . ' 00:00:00');
-        $where['end'] = Dever::maketime($day . '59:59:59');
-        $where['shop_id'] = $this->shop_id;
-
-        $this->data['num_order'] = Dever::db('shop/sell_order')->getOrderNum($where);
-        $this->data['num_cash'] = Dever::db('shop/sell_order')->getCashNum($where);
-        $this->data['num_goods'] = Dever::db('shop/sell_order')->getGoodsNum($where);
-
-        return $this->data;
-    }
-
-    # 销售订单管理
-    public function sell_order()
-    {
-        $where['shop_id'] = $this->shop_id;
-
-        $day = Dever::input('day');
-
-        
-        $this->data = Dever::db('shop/sell_order')->page($where);
-
-        if ($this->data) {
-            $this->config = Dever::db('shop/sell_order')->config;
-            foreach ($this->data as $k => $v) {
-                $this->data[$k] = $this->order_info($v);
-            }
-        }
-
-        return $this->data;
-    }
-
-    # 获取订单详细信息
-    public function order_info($info, $type = 1)
-    {
-        $info['status_name'] = $this->config['status'][$info['status']];
-        $info['method_name'] = $this->config['method'][$info['method']];
-
-        if ($info['method'] == 1 && $info['status'] > 1) {
-
-        }
-        $info['goods'] = Dever::db('shop/sell_order_goods')->select(array('order_id' => $info['id']));
-        $info['shop'] = Dever::db('shop/info')->find($info['shop_id']);
-        $info['cdate'] = date('Y-m-d H:i', $info['cdate']);
-
-        if ($type == 2) {
-            foreach ($info['goods'] as $k => $v) {
-                $info['goods']['info'] = Dever::load('goods/lib/info')->getInfo($v['goods_id']);
-            }
-            if ($info['address_id']) {
-                $info['address'] = Dever::db('passport/address')->find($info['address_id']);
-            }
-
-            if ($info['invoice_id']) {
-                $info['invoice'] = Dever::db('passport/invoice')->find($info['invoice_id']);
-            }
-
-            if ($info['coupon_id']) {
-                $coupon = Dever::db('shop/user_coupon')->find($info['coupon_id']);
-                if ($coupon) {
-                    $info['coupon'] = Dever::db('goods/coupon')->find($coupon['coupon_id']);
-                }
-            }
-        }
-
-        return $info;
-    }
 }