dever 3 năm trước cách đây
mục cha
commit
3650287356

+ 42 - 42
app/mshop/src/Data.php

@@ -15,12 +15,27 @@ class Data extends Core
         }
 
         $where['start'] = Dever::maketime($day . ' 00:00:00');
-        $where['end'] = Dever::maketime($day . '23:59:59');
+        $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);
+        $this->data['num_order'] = round(Dever::db('shop/sell_order')->getOrderNum($where), 2);
+        $cash = Dever::db('shop/sell_order')->getCashNum($where);
+        if ($cash) {
+        	$this->data['num_cash'] = $cash['total'];
+        }
+        if (!$this->data['num_cash']) {
+        	$this->data['num_cash'] = 0;
+        }
+        $goods = Dever::db('shop/sell_order')->getGoodsNum($where);
+        if ($goods) {
+        	$this->data['num_goods'] = $goods['total'];
+        }
+        if (!$this->data['num_goods']) {
+        	$this->data['num_goods'] = 0;
+        }
+
+        $this->data['num_cash'] = round($this->data['num_cash'], 2);
+        $this->data['num_goods'] = round($this->data['num_goods'], 2);
 
         return $this->data;
     }
@@ -29,11 +44,32 @@ class Data extends Core
     public function sell_order()
     {
         $where['shop_id'] = $this->shop_id;
+        $mobile = Dever::input('mobile');
+        if ($mobile) {
+        	$where['mobile'] = $mobile;
+        }
+        $status = Dever::input('status');
+        if ($status) {
+        	$where['status'] = $status;
+        }
 
-        $day = Dever::input('day');
+        $method = Dever::input('method');
+        if ($method) {
+        	$where['method'] = $method;
+        }
+
+        $pay_method = Dever::input('pay_method');
+        if ($pay_method) {
+        	$where['pay_method'] = $pay_method;
+        }
 
+        $day = Dever::input('day');
+        if ($day) {
+        	$where['start'] = Dever::maketime($day . ' 00:00:00');
+        	$where['end'] = Dever::maketime($day . ' 23:59:59');
+        }
         
-        $this->data = Dever::db('shop/sell_order')->page($where);
+        $this->data = Dever::db('shop/sell_order')->getAll($where);
 
         if ($this->data) {
             $this->config = Dever::db('shop/sell_order')->config;
@@ -44,40 +80,4 @@ class Data extends Core
 
         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;
-    }
 }

+ 19 - 21
app/mshop/src/Main.php

@@ -4,7 +4,7 @@ namespace Mshop\Src;
 
 use Dever;
 
-class Main extends Core
+class Main
 {
     # 登录
     public function login()
@@ -14,17 +14,20 @@ class Main extends Core
         $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['uid'] = $user[0]['id'];
+            $this->data['signature'] = Dever::login($this->data['uid']);
             $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'];
+                $shop = Dever::db('shop/info')->getOne($v['shop_id']);
+                if ($shop) {
+                    $this->data['shop'][] = Dever::db('shop/info')->getOne($v['shop_id']);
+                    $this->data['shop_id'] = $v['shop_id'];
+                }
             }
 
+            $this->data['shop_num'] = count($this->data['shop']);
+
             return $this->data;
         } else {
             Dever::alert('登录失败,手机号不存在');
@@ -34,7 +37,7 @@ class Main extends Core
     # 获取验证码
     public function mcode()
     {
-        $mobile = Dever::load('passport/reg')->checkMobileExists(1, -1, 'shop/member');
+        $mobile = Dever::load('passport/reg')->checkMobileExists(1, true, 'shop/member');
 
         $msg = Dever::load('passport/reg')->getMcode_action($mobile);
         
@@ -47,7 +50,6 @@ class Main extends Core
         $data['name'] = Dever::input('name');
         $data['mobile'] = Dever::input('mobile');
         $data['city'] = Dever::input('city');
-        $data['uid'] = $this->uid;
 
         if (!$data['name']) {
             Dever::alert('请输入姓名');
@@ -64,23 +66,19 @@ class Main extends Core
         if (!$info) {
             $data['truename'] = $data['name'];
             # 根据城市查找省份
+            $county = Dever::db('area/county')->find($data['city']);
+            if ($county) {
+                $data['city'] = $county['city_id'];
+            }
             $city = Dever::db('area/city')->find($data['city']);
             $data['province'] = $city['province_id'];
             $data['area'] = $data['province'] . ',' . $data['city'];
+            if ($county) {
+                $data['area'] .= ',' . $county['id'];
+            }
 
             # 获取经纬度
-            $url = 'https://restapi.amap.com/v3/geocode/geo';
-            $param['key'] = 'f18cb42560b8aa54e3b53a6265bfd764';
-            $param['city'] = $data['city'];
-            $param['address'] = $city['name'];
-            $result = json_decode(Dever::curl($url, $param), true);
-
-            if (isset($result['geocodes'][0]['location']) && $result['geocodes'][0]['location']) {
-                $data['map'] = $city['name'] . ',' . $result['geocodes'][0]['location'] . ',11';
-                $temp = explode(',', $result['geocodes'][0]['location']);
-                $data['lng'] = $temp[0];
-                $data['lat'] = $temp[1];
-            }
+            list($data['lng'], $data['lat'], $data['map']) = Dever::load('shop/lib/info')->geo($data['city'], $city['name']);
 
             $data['status'] = 3;
             Dever::db('shop/info')->insert($data);

+ 7 - 1
app/shop/database/sell_order.php

@@ -356,7 +356,13 @@ return array
             'option' => array
             (
                 'uid' => 'yes',
-                'status' => 'yes',
+                'shop_id' => 'yes',
+                'mobile' => 'yes',
+                'method' => 'yes',
+                'pay_method' => 'yes',
+                'start' => array('yes-cdate', '>='),
+                'end' => array('yes-cdate', '<='),
+                'status' => array('yes', 'in'),
                 'state' => 1,
             ),
             'type' => 'all',

+ 27 - 1
app/shop/lib/Info.php

@@ -22,7 +22,11 @@ class Info
         }
 
         if (!$lng || !$lat) {
-            Dever::alert('请传入用户坐标');
+            $city_info = Dever::db('area/city')->find($city);
+            list($lng, $lat) = Dever::load('shop/lib/info')->geo($city, $city_info['name']);
+            if (!$lng || !$lat) {
+                Dever::alert('请传入用户坐标');
+            }
         }
 
         $data = $this->fetch(false, $city, $lng, $lat, 1, $name, $method);
@@ -186,4 +190,26 @@ class Info
             return 0;
         }
     }
+
+    # 获取经纬度
+    public function geo($code, $name)
+    {
+        # 获取经纬度
+        $url = 'https://restapi.amap.com/v3/geocode/geo';
+        $param['key'] = 'f18cb42560b8aa54e3b53a6265bfd764';
+        $param['city'] = $code;
+        $param['address'] = $name;
+        $result = json_decode(Dever::curl($url, $param), true);
+        $lng = 0;
+        $lat = 0;
+        $map = '';
+        if (isset($result['geocodes'][0]['location']) && $result['geocodes'][0]['location']) {
+            $map = $code . ',' . $result['geocodes'][0]['location'] . ',11';
+            $temp = explode(',', $result['geocodes'][0]['location']);
+            $lng = $temp[0];
+            $lat = $temp[1];
+        }
+
+        return array($lng, $lat, $map);
+    }
 }

+ 6 - 2
app/shop/lib/Manage.php

@@ -50,8 +50,12 @@ class Manage
             $temp = is_string($area) ? explode(',', $area) : $area;
             $update['province'] = $temp[0];
             $update['city'] = $temp[1];
-            $update['county'] = $temp[2];
-            $update['town'] = $temp[3];
+            if (isset($temp[2])) {
+                $update['county'] = $temp[2];
+            }
+            if (isset($temp[3])) {
+                $update['town'] = $temp[3];
+            }
         }
 
         $map = Dever::param('map', $data);

+ 84 - 0
app/shop/lib/Order.php

@@ -0,0 +1,84 @@
+<?php
+
+namespace Shop\Lib;
+
+use Dever;
+
+class Order
+{
+    # 获取订单详细信息
+    public function order_info($info, $type = 1)
+    {
+        if ($info['status'] == 1) {
+            # 15分钟内支付,900秒
+            $m = 9000;
+            # 支付倒计时
+            $info['time'] = time() - $info['cdate'];
+            if ($info['time'] >= $m) {
+                # 已过期,自动取消
+                $info['time'] = -1;
+                Dever::db('shop/sell_order')->update(array('where_id' => $info['id'], 'status' => 11));
+                $info['status'] = 11;
+            } else {
+                $info['time'] = $m - $info['time'];
+            }
+        }
+
+        $info['status_name'] = $this->config['status'][$info['status']];
+        $info['method_name'] = $this->config['method'][$info['method']];
+        $info['pay_method_name'] = $this->config['pay_method'][$info['pay_method']];
+
+        if ($info['status'] == 2) {
+            $info['status_name'] = '待处理';
+        }
+        if ($info['status'] == 3) {
+            if ($info['method'] == 1) {
+                $info['status_name'] = '待自提';
+            } else {
+                $info['status_name'] = '配送中';
+            }
+        }
+
+        if ($info['method'] == 2) {
+            $info['ps_info'] = Dever::db('shop/sell_order_ps')->find(array('order_id' => $info['id']));
+            if ($info['ps_info']) {
+                $info['ps_info']['service_name'] = '商家自送';
+                if ($info['ps_info']['service_id'] > 0) {
+                    //暂时还没有
+                }
+            }
+        }
+
+        $info['goods'] = Dever::db('shop/sell_order_goods')->select(array('order_id' => $info['id']));
+        $info['shop'] = Dever::db('shop/info')->getOne($info['shop_id']);
+        $info['cdate'] = date('Y-m-d H:i', $info['cdate']);
+
+        if ($type == 2) {
+            foreach ($info['goods'] as $k => $v) {
+                $info['goods'][$k]['info'] = Dever::load('goods/lib/info')->getPayInfo($v['goods_id'], $v['sku_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['user_coupon_id']) {
+                $coupon = Dever::db('shop/user_coupon')->find($info['user_coupon_id']);
+                if ($coupon) {
+                    $info['coupon'] = Dever::db('goods/coupon')->find($coupon['coupon_id']);
+                }
+            }
+        } else {
+            foreach ($info['goods'] as $k => $v) {
+                $goods = Dever::db('goods/info')->one($v['goods_id']);
+                $info['goods'][$k]['name'] = $goods['name'];
+                $info['goods'][$k]['cover'] = $goods['cover'];
+            }
+        }
+
+        return $info;
+    }
+}

+ 1 - 1
app/shop/src/Main.php

@@ -74,7 +74,7 @@ class Main extends Core
 
         # 获取门店
         $this->data['shop'] = array();
-        if ($city && $lng && $lat) {
+        if ($city) {
             $this->data['shop'] = Dever::load('shop/lib/info')->get($city, $lng, $lat, $name, 'fetchAll', $shop_id);
         }
 

+ 3 - 2
app/shop/src/My.php

@@ -129,7 +129,7 @@ class My extends Core
         if ($this->data) {
             $this->config = Dever::db('shop/sell_order')->config;
             foreach ($this->data as $k => $v) {
-                $this->data[$k] = $this->order_info($v);
+                $this->data[$k] = Dever::load('shop/lib/order')->order_info($v);
             }
         }
 
@@ -147,7 +147,7 @@ class My extends Core
         }
 
         $this->config = Dever::db('shop/sell_order')->config;
-        $this->data = $this->order_info($this->data, 2);
+        $this->data = Dever::load('shop/lib/order')->order_info($this->data, 2);
 
         return $this->data;
     }
@@ -172,6 +172,7 @@ class My extends Core
 
         $info['status_name'] = $this->config['status'][$info['status']];
         $info['method_name'] = $this->config['method'][$info['method']];
+        $info['pay_method_name'] = $this->config['pay_method'][$info['pay_method']];
 
         if ($info['status'] == 2) {
             $info['status_name'] = '支付成功';