Kirin 4 éve
szülő
commit
dc8528ad0c

+ 140 - 0
app/admin/controller/merchant/SystemStore.php

@@ -7,6 +7,7 @@ use app\admin\model\order\StoreOrder as StoreOrderModel;
 use app\admin\model\order\StoreOrderStatus;
 use app\admin\model\system\SystemStoreBill;
 use app\admin\model\system\SystemStoreExtract;
+use app\admin\model\system\SystemStorePoint;
 use app\admin\model\ump\StorePink;
 use app\admin\model\user\User;
 use crmeb\repositories\OrderRepository;
@@ -109,6 +110,14 @@ class SystemStore extends AuthController
         return $this->fetch();
     }
 
+    public function add_order()
+    {
+        if (!$this->store_id) {
+            $this->failed('未知门店');
+        }
+
+    }
+
     /**
      * 核销码核销
      * @param string $verify_code
@@ -302,6 +311,137 @@ class SystemStore extends AuthController
 
     //TODO 自提点管理
 
+    /**
+     * @return string
+     * @throws Exception
+     */
+    public function point()
+    {
+        if (!$this->store_id) {
+            $this->redirect(url('index', array('origin' => 'point'))->build());
+        }
+        $type = $this->request->param('type');
+        $show = SystemStorePoint::where('store_id', $this->store_id)->where('is_show', 1)->where('is_del', 0)->count();//显示中的门店
+        $hide = SystemStorePoint::where('store_id', $this->store_id)->where('is_show', 0)->count();//隐藏的门店
+        $recycle = SystemStorePoint::where('store_id', $this->store_id)->where('is_del', 1)->count();//删除的门店
+        if ($type == null) $type = 1;
+        $id = $this->store_id;
+        $this->assign(compact('type', 'show', 'hide', 'recycle', 'id'));
+        return $this->fetch();
+    }
+
+    public function store_point_list($id)
+    {
+        $where = UtilService::getMore([
+            ['page', 1],
+            ['limit', 20],
+            ['name', ''],
+            ['excel', 0],
+            ['type', $this->request->param('type')]
+        ]);
+        $where['store_id'] = $id;
+        JsonService::successlayui(SystemStorePoint::getStoreList($where));
+    }
+
+    public function add_point($id = 0, $store_id = 0)
+    {
+        $store = SystemStorePoint::getStoreDispose($id);
+        $this->assign(compact('store', 'store_id'));
+        return $this->fetch();
+    }
+
+    /**
+     * 保存修改门店信息
+     * @param int $id
+     */
+    public function save_point($id = 0)
+    {
+        $data = UtilService::postMore([
+            ['name', ''],
+            ['phone', ''],
+            ['address', ''],
+            ['detailed_address', ''],
+            ['latlng', ''],
+            ['valid_time', []],
+            ['day_time', []],
+            ['store_id', 0],
+        ]);
+//        var_dump($data['store_id']);
+        if (!$data['store_id'] || !SystemStoreModel::getStoreDispose($data['store_id'])) JsonService::fail('无效门店');
+        SystemStorePoint::beginTrans();
+        try {
+            $data['address'] = implode(',', $data['address']);
+            $data['latlng'] = is_string($data['latlng']) ? explode(',', $data['latlng']) : $data['latlng'];
+            if (!isset($data['latlng'][0]) || !isset($data['latlng'][1])) JsonService::fail('请选择门店位置');
+            $data['latitude'] = $data['latlng'][0];
+            $data['longitude'] = $data['latlng'][1];
+            $data['valid_time'] = implode(' - ', $data['valid_time']);
+            $data['day_time'] = implode(' - ', $data['day_time']);
+            unset($data['latlng']);
+            if ($id) {
+                if (SystemStorePoint::where('id', $id)->update($data)) {
+                    SystemStorePoint::commitTrans();
+                    JsonService::success('修改成功');
+                } else {
+                    SystemStorePoint::rollbackTrans();
+                    JsonService::fail('修改失败或者您没有修改什么!');
+                }
+            } else {
+                $data['add_time'] = time();
+                $data['is_show'] = 1;
+                if ($res = SystemStorePoint::create($data)) {
+                    SystemStorePoint::commitTrans();
+                    JsonService::success('保存成功', ['id' => $res->id]);
+                } else {
+                    SystemStorePoint::rollbackTrans();
+                    JsonService::fail('保存失败!');
+                }
+            }
+        } catch (\Exception $e) {
+            SystemStorePoint::rollbackTrans();
+            JsonService::fail($e->getMessage());
+        }
+    }
+
+    /**
+     * 设置单个门店是否显示
+     * @param string $is_show
+     * @param string $id
+     * @return json
+     */
+    public function set_point_show($is_show = '', $id = '')
+    {
+        ($is_show == '' || $id == '') && JsonService::fail('缺少参数');
+        $res = SystemStorePoint::where(['id' => $id])->update(['is_show' => (int)$is_show]);
+        if ($res) {
+            return JsonService::successful($is_show == 1 ? '设置显示成功' : '设置隐藏成功');
+        } else {
+            return JsonService::fail($is_show == 1 ? '设置显示失败' : '设置隐藏失败');
+        }
+    }
+
+    /**
+     * 删除恢复门店
+     * @param $id
+     */
+    public function point_delete($id)
+    {
+        if (!$id) return $this->failed('数据不存在');
+        if (!SystemStorePoint::be(['id' => $id])) return $this->failed('数据不存在');
+        if (SystemStorePoint::be(['id' => $id, 'is_del' => 1])) {
+            $data['is_del'] = 0;
+            if (!SystemStorePoint::edit($data, $id))
+                return JsonService::fail(SystemStorePoint::getErrorInfo('恢复失败,请稍候再试!'));
+            else
+                return JsonService::successful('恢复门店成功!');
+        } else {
+            $data['is_del'] = 1;
+            if (!SystemStorePoint::edit($data, $id))
+                return JsonService::fail(SystemStorePoint::getErrorInfo('删除失败,请稍候再试!'));
+            else
+                return JsonService::successful('删除门店成功!');
+        }
+    }
 
     //TODO 库存管理
 }

+ 1 - 1
app/admin/controller/system/SystemStore.php

@@ -176,7 +176,7 @@ class SystemStore extends AuthController
                         'account' => 'store_admin_' . $res->id,
                         'pwd' => md5('123456'),
                         'real_name' => $data['leader'],
-                        'roles' => sys_config('default_store_admin', 1),
+                        'roles' => sys_config('default_store_admin', 7),
                         'add_time' => time(),
                         'status' => 1,
                         'level' => 2,

+ 24 - 17
app/admin/model/order/StoreOrder.php

@@ -41,23 +41,27 @@ class StoreOrder extends BaseModel
 
     use ModelTrait;
 
-    public static function orderCount()
+    public static function orderCount($store_id = '')
     {
-        $data['ys'] = self::statusByWhere(9, new self())->where(['is_system_del' => 0])->count();
-        $data['wz'] = self::statusByWhere(0, new self())->where(['is_system_del' => 0])->count();
-        $data['wf'] = self::statusByWhere(1, new self())->where(['is_system_del' => 0, 'shipping_type' => 1])->count();
-        $data['ds'] = self::statusByWhere(2, new self())->where(['is_system_del' => 0, 'shipping_type' => 1])->count();
-        $data['dp'] = self::statusByWhere(3, new self())->where(['is_system_del' => 0])->count();
-        $data['jy'] = self::statusByWhere(4, new self())->where(['is_system_del' => 0])->count();
-        $data['tk'] = self::statusByWhere(-1, new self())->where(['is_system_del' => 0])->count();
-        $data['yt'] = self::statusByWhere(-2, new self())->where(['is_system_del' => 0])->count();
-        $data['del'] = self::statusByWhere(-4, new self())->where(['is_system_del' => 0])->count();
-        $data['write_off'] = self::statusByWhere(5, new self())->where(['is_system_del' => 0])->count();
-        $data['general'] = self::where(['pink_id' => 0, 'integral_id' => 0, 'combination_id' => 0, 'seckill_id' => 0, 'bargain_id' => 0, 'is_system_del' => 0])->count();
-        $data['pink'] = self::where('pink_id|combination_id', '>', 0)->where('is_system_del', 0)->count();
-        $data['seckill'] = self::where('seckill_id', '>', 0)->where('is_system_del', 0)->count();
-        $data['bargain'] = self::where('bargain_id', '>', 0)->where('is_system_del', 0)->count();
-        $data['integral'] = self::where('integral_id', '>', 0)->where('is_system_del', 0)->count();
+        $where = [];
+        if ($store_id != '') {
+            $where['store_id'] = $store_id;
+        }
+        $data['ys'] = self::statusByWhere(9, new self())->where($where)->where(['is_system_del' => 0])->count();
+        $data['wz'] = self::statusByWhere(0, new self())->where($where)->where(['is_system_del' => 0])->count();
+        $data['wf'] = self::statusByWhere(1, new self())->where($where)->where(['is_system_del' => 0, 'shipping_type' => 1])->count();
+        $data['ds'] = self::statusByWhere(2, new self())->where($where)->where(['is_system_del' => 0, 'shipping_type' => 1])->count();
+        $data['dp'] = self::statusByWhere(3, new self())->where($where)->where(['is_system_del' => 0])->count();
+        $data['jy'] = self::statusByWhere(4, new self())->where($where)->where(['is_system_del' => 0])->count();
+        $data['tk'] = self::statusByWhere(-1, new self())->where($where)->where(['is_system_del' => 0])->count();
+        $data['yt'] = self::statusByWhere(-2, new self())->where($where)->where(['is_system_del' => 0])->count();
+        $data['del'] = self::statusByWhere(-4, new self())->where($where)->where(['is_system_del' => 0])->count();
+        $data['write_off'] = self::statusByWhere(5, new self())->where($where)->where(['is_system_del' => 0])->count();
+        $data['general'] = self::where(['pink_id' => 0, 'integral_id' => 0, 'combination_id' => 0, 'seckill_id' => 0, 'bargain_id' => 0, 'is_system_del' => 0])->where($where)->count();
+        $data['pink'] = self::where('pink_id|combination_id', '>', 0)->where('is_system_del', 0)->where($where)->count();
+        $data['seckill'] = self::where('seckill_id', '>', 0)->where('is_system_del', 0)->where($where)->count();
+        $data['bargain'] = self::where('bargain_id', '>', 0)->where('is_system_del', 0)->where($where)->count();
+        $data['integral'] = self::where('integral_id', '>', 0)->where('is_system_del', 0)->where($where)->count();
         return $data;
     }
 
@@ -1279,7 +1283,7 @@ HTML;
      * 订单数量 支付方式
      * @return array
      */
-    public static function payTypeCount()
+    public static function payTypeCount($store_id = '')
     {
         $where['status'] = 8;
         $where['is_del'] = 0;
@@ -1288,6 +1292,9 @@ HTML;
         $where['type'] = '';
         $where['order'] = '';
         $where['pay_type'] = 1;
+        if ($store_id != '') {
+            $where['store_id'] = $store_id;
+        }
         $weixin = self::getOrderWhere($where, new self)->count();
         $where['pay_type'] = 2;
         $yue = self::getOrderWhere($where, new self)->count();

+ 8 - 1
app/admin/model/system/SystemStorePoint.php

@@ -48,24 +48,31 @@ class SystemStorePoint extends BaseModel
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    public static function getStoreDispose($id = 0)
+    public static function getStoreDispose($id = 0, $store_id = 0)
     {
         if ($id)
             $storeInfo = self::verificWhere()->where('id', $id)->find();
         else
 //            $storeInfo = self::verificWhere()->find();
             $storeInfo = [];
+
         if ($storeInfo) {
+            if ($store_id && $store_id != $storeInfo) {
+                goto end;
+            }
             $storeInfo['latlng'] = self::getLatlngAttr(null, $storeInfo);
             $storeInfo['valid_time'] = $storeInfo['valid_time'] ? explode(' - ', $storeInfo['valid_time']) : [];
             $storeInfo['day_time'] = $storeInfo['day_time'] ? explode(' - ', $storeInfo['day_time']) : [];
             $storeInfo['address'] = $storeInfo['address'] ? explode(',', $storeInfo['address']) : [];
+            $storeInfo['store'] = SystemStore::get($storeInfo['store_id'])->toArray();
         } else {
+            end:
             $storeInfo['latlng'] = [];
             $storeInfo['valid_time'] = [];
             $storeInfo['day_time'] = [];
             $storeInfo['address'] = [];
             $storeInfo['id'] = 0;
+            $storeInfo['store'] = [];
         }
         return $storeInfo;
     }

+ 210 - 0
app/admin/view/merchant/system_store/add_point.php

@@ -0,0 +1,210 @@
+<!DOCTYPE html>
+<html lang="zh-CN">
+<head>
+    {include file="public/head"}
+
+    <link href="/system/frame/css/bootstrap.min.css?v=3.4.0" rel="stylesheet">
+    <link href="/system/frame/css/style.min.css?v=3.0.0" rel="stylesheet">
+    <title>{$title|default=''}</title>
+    <style></style>
+</head>
+<body>
+<div class="wrapper wrapper-content">
+    <div class="row">
+        <div class="col-sm-12">
+            <div class="ibox float-e-margins">
+                <div class="ibox-title">
+                    <h5>自提点设置</h5>
+                </div>
+                <div id="store-attr" class="mp-form" v-cloak="">
+                    <i-Form :label-width="80" style="width: 100%">
+                        <template>
+                            <Form-Item>
+                                <Row>
+                                    <i-Col span="13">
+                                        <span>自提点名称:</span>
+                                        <i-Input placeholder="自提点名称" v-model="form.name" style="width: 80%"
+                                                 type="text"></i-Input>
+                                    </i-Col>
+                                </Row>
+                            </Form-Item>
+                            <Form-Item>
+                                <Row>
+                                    <i-Col span="13">
+                                        <span>自提点手机号:</span>
+                                        <i-Input placeholder="自提点手机号" v-model="form.phone" style="width: 80%"
+                                                 type="text"></i-Input>
+                                    </i-Col>
+                                </Row>
+                            </Form-Item>
+                            <Form-Item>
+                                <Row>
+                                    <i-Col span="13">
+                                        <span>自提点地址:</span>
+                                        <Cascader :data="addresData" :value.sync="form.address"
+                                                  @on-change="handleChange"
+                                                  style="width: 80%;display: inline-block;"></Cascader>
+                                    </i-Col>
+                                </Row>
+                            </Form-Item>
+                            <Form-Item>
+                                <Row>
+                                    <i-Col span="13">
+                                        <span>详细地址:</span>
+                                        <i-Input placeholder="详细地址" v-model="form.detailed_address" style="width: 80%"
+                                                 type="text"></i-Input>
+                                    </i-Col>
+                                </Row>
+                            </Form-Item>
+                            <Form-Item>
+                                <Row>
+                                    <i-Col span="13">
+                                        <span>营业时间:</span>
+                                        <Time-picker type="timerange" @on-change="changeDayTime" placement="bottom-end"
+                                                     :value="form.day_time" placeholder="选择时间"></Time-picker>
+                                    </i-Col>
+                                </Row>
+                            </Form-Item>
+                            <Form-Item>
+                                <Row>
+                                    <i-Col span="13">
+                                        <span style="float: left">经纬度:</span>
+                                        <Tooltip content="请点击查找位置进行选择位置">
+                                            <i-Input placeholder="经纬度" v-model="form.latlng" :readonly="true"
+                                                     style="width: 80%">
+                                                <span slot="append"
+                                                      @click="openWindows('查找位置','{:Url('select_address')}',{w:400,h:700})"
+                                                      style="cursor:pointer">查找位置</span>
+                                            </i-Input>
+                                        </Tooltip>
+                                    </i-Col>
+                                </Row>
+                            </Form-Item>
+                        </template>
+                        <Form-Item>
+                            <Row>
+                                <i-Col span="8" offset="6">
+                                    <i-Button type="primary" @click="submit">提交</i-Button>
+                                </i-Col>
+                            </Row>
+                        </Form-Item>
+                    </i-Form>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+<script src="{__PLUG_PATH}city.js"></script>
+<script>
+    var storeData = {:json_encode($store)};
+    var store_id = {$store_id};
+    mpFrame.start(function (Vue) {
+        $.each(city, function (key, item) {
+            city[key].value = item.label;
+            if (item.children && item.children.length) {
+                $.each(item.children, function (i, v) {
+                    city[key].children[i].value = v.label;
+                    if (v.children && v.children.length) {
+                        $.each(v.children, function (k, val) {
+                            city[key].children[i].children[k].value = val.label;
+                        });
+                    }
+                });
+            }
+        });
+        new Vue({
+            data: function () {
+                return {
+                    id: storeData.id || 0,
+                    addresData: city,
+                    form: {
+                        name: storeData.name || '',
+                        phone: storeData.phone || '',
+                        address: storeData.address || [],
+                        detailed_address: storeData.detailed_address || '',
+                        latlng: storeData.latlng || '',
+                        valid_time: storeData.valid_time || [],
+                        day_time: storeData.day_time || [],
+                        store_id: store_id,
+                    },
+                    visible: false,
+                }
+            },
+            methods: {
+                changeDayTime: function (date) {
+                    this.$set(this.form, 'day_time', date);
+                },
+                changeValidTime: function (date) {
+                    this.$set(this.form, 'valid_time', date);
+                },
+                createFrame: function (title, src, opt) {
+                    opt === undefined && (opt = {});
+                    var h = parent.document.body.clientHeight - 100;
+                    return layer.open({
+                        type: 2,
+                        title: title,
+                        area: [(opt.w || 700) + 'px', (opt.h || h) + 'px'],
+                        fixed: false, //不固定
+                        maxmin: true,
+                        moveOut: false,//true  可以拖出窗外  false 只能在窗内拖
+                        anim: 5,//出场动画 isOutAnim bool 关闭动画
+                        offset: 'auto',//['100px','100px'],//'auto',//初始位置  ['100px','100px'] t[ 上 左]
+                        shade: 0,//遮罩
+                        resize: true,//是否允许拉伸
+                        content: src,//内容
+                        move: '.layui-layer-title'
+                    });
+                },
+                handleChange: function (value, selectedData) {
+                    var that = this;
+                    that.form.address = [];
+                    $.each(selectedData, function (key, item) {
+                        that.form.address.push(item.label);
+                    });
+                    that.$set(that.form, 'address', that.form.address);
+                },
+                openWindows: function (title, url, opt) {
+                    return this.createFrame(title, url, opt);
+                },
+                changeIMG: function (name, url) {
+                    this.form[name] = url;
+                },
+                isPhone: function (test) {
+                    var reg = /^1[3456789]\d{9}$/;
+                    return reg.test(test);
+                },
+                submit: function () {
+                    var that = this;
+                    if (!that.form.name) return $eb.message('error', '请填写名称');
+                    if (!that.form.phone) return $eb.message('error', '请输入手机号码');
+                    if (!that.isPhone(that.form.phone)) return $eb.message('error', '请输入正确的手机号码');
+                    if (!that.form.address) return $eb.message('error', '请选择地址');
+                    if (!that.form.detailed_address) return $eb.message('error', '请填写详细地址');
+                    if (!that.form.valid_time) return $eb.message('error', '请选择核销时效');
+                    if (!that.form.day_time) return $eb.message('error', '请选择营业时间');
+                    if (!that.form.latlng) return $eb.message('error', '请选择经纬度!');
+                    if (!that.form.store_id) return $eb.message('error', '请选择所属门店!');
+                    var index = layer.load(1, {
+                        shade: [0.5, '#fff']
+                    });
+                    $eb.axios.post('{:Url("save_point")}' + (that.id ? '?id=' + that.id : ''), that.form).then(function (res) {
+                        layer.close(index);
+                        layer.msg(res.data.msg);
+                        if (res.data.data.id) that.id = res.data.data.id;
+                    }).catch(function (err) {
+                        console.log(err);
+                        layer.close(index);
+                    })
+                },
+                selectAdderss: function (data) {
+                    //lat 纬度 lng 经度
+                    this.form.latlng = data.latlng.lat + ',' + data.latlng.lng;
+                }
+            },
+            mounted: function () {
+                window.changeIMG = this.changeIMG;
+                window.selectAdderss = this.selectAdderss;
+            }
+        }).$mount(document.getElementById('store-attr'))
+    })
+</script>

+ 185 - 0
app/admin/view/merchant/system_store/point.php

@@ -0,0 +1,185 @@
+{extend name="public/container"}
+{block name="head_top"}
+
+{/block}
+{block name="content"}
+<div class="layui-fluid" style="background: #fff;margin-top: -10px;">
+    <div class="layui-tab layui-tab-brief" lay-filter="tab">
+        <ul class="layui-tab-title">
+            <li lay-id="list" {eq name='type' value='1' }class="layui-this" {
+            /eq}>
+            <a href="{eq name='type' value='1'}javascript:;{else}{:Url('point',['id'=>$id,'type'=>1])}{/eq}">显示中的自提点({$show})</a>
+            </li>
+            <li lay-id="list" {eq name='type' value='2' }class="layui-this" {
+            /eq}>
+            <a href="{eq name='type' value='2'}javascript:;{else}{:Url('point',['id'=>$id,'type'=>2])}{/eq}">隐藏中的自提点({$hide})</a>
+            </li>
+            <li lay-id="list" {eq name='type' value='3' }class="layui-this" {
+            /eq}>
+            <a href="{eq name='type' value='3'}javascript:;{else}{:Url('point',['id'=>$id,'type'=>3])}{/eq}">回收站的自提点({$recycle})</a>
+            </li>
+        </ul>
+    </div>
+    <div class="layui-row layui-col-space15">
+        <div class="layui-col-md12">
+            <div class="layui-card">
+                <div class="layui-card-body">
+                    <form class="layui-form layui-form-pane" action="">
+                        <div class="layui-form-item">
+                            <div class="layui-inline">
+                                <label class="layui-form-label">自提点名称</label>
+                                <div class="layui-input-block">
+                                    <input type="text" name="name" class="layui-input" placeholder="请输入自提点名称,关键字,编号">
+                                    <input type="hidden" name="type" value="{$type}">
+                                </div>
+                            </div>
+                            <div class="layui-inline">
+                                <div class="layui-input-inline">
+                                    <button class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="search"
+                                            lay-filter="search">
+                                        <i class="layui-icon layui-icon-search"></i>搜索
+                                    </button>
+                                    <button class="layui-btn layui-btn-primary layui-btn-sm export" lay-submit="export"
+                                            lay-filter="export">
+                                        <i class="fa fa-floppy-o" style="margin-right: 3px;"></i>导出
+                                    </button>
+                                </div>
+                            </div>
+                        </div>
+                    </form>
+                </div>
+            </div>
+        </div>
+        <div class="layui-col-md12">
+            <div class="layui-card">
+                <!--                <div class="layui-card-header">门店列表</div>-->
+                <div class="layui-card-body">
+                    <div class="layui-btn-container">
+                        <button class="layui-btn layui-btn-sm"
+                                onclick="$eb.createModalFrame(this.innerText,'{:Url('add_point',['store_id'=>$id])}',{h:700,w:1100})">
+                            添加自提点
+                        </button>
+                    </div>
+                    <table class="layui-hide" id="List" lay-filter="List"></table>
+                    <script type="text/html" id="headimgurl">
+                        <img style="cursor: pointer" lay-event='open_image' src="{{d.image}}">
+                    </script>
+                    <script type="text/html" id="address">
+                        {{d.address}} {{d.detailed_address}}
+                    </script>
+                    <script type="text/html" id="checkboxstatus">
+                        <input type='checkbox' name='id' lay-skin='switch' value="{{d.id}}" lay-filter='is_show'
+                               lay-text='显示|隐藏' {{ d.is_show== 1 ? 'checked' : '' }}>
+                    </script>
+                    <script type="text/html" id="act">
+                        <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" lay-event='edit'>
+                            编辑自提点
+                        </button>
+                        <!--                        <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" lay-event='bill'>-->
+                        <!--                            门店佣金-->
+                        <!--                        </button>-->
+                        <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" lay-event='del'>
+                            {{# if(d.is_del){ }}
+                            恢复自提点
+                            {{# }else{ }}
+                            删除自提点
+                            {{# } }}
+                        </button>
+                    </script>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+<script src="{__ADMIN_PATH}js/layuiList.js"></script>
+{/block}
+{block name="script"}
+<script>
+    var type = <?=$type?>;
+    var store_id = <?=$id?>;
+    layList.tableList('List', "{:Url('store_point_list',['id'=>$id,'type'=>$type])}", function () {
+        return [
+            {field: 'id', title: 'ID', sort: true, event: 'id', width: '4%'},
+            {field: 'name', title: '自提点名称', width: '10%'},
+            {field: 'phone', title: '自提点电话', width: '8%'},
+            {field: 'deposit', title: '总押金', width: '6%'},
+            {field: 'deposit_back', title: '已退押金', width: '6%'},
+            {field: 'address', title: '地址', templet: '#address'},
+            {field: 'status', title: '是否显示', templet: "#checkboxstatus", width: '8%'},
+            {field: 'right', title: '操作', align: 'center', toolbar: '#act', width: '14%'},
+        ];
+    });
+    //查询条件
+    layList.search('search', function (where) {
+        where.store_id = store_id;
+        layList.reload(where);
+    });
+    //excel下载
+    layList.search('export', function (where) {
+        where.excel = 1;
+        where.store_id = store_id;
+        location.href = layList.U({c: 'system.system_store', a: 'store_point_list', q: where});
+    })
+    //门店是否显示
+    layList.switch('is_show', function (odj, value) {
+        if (odj.elem.checked == true) {
+            layList.baseGet(layList.Url({
+                c: 'system.system_store',
+                a: 'set_point_show',
+                p: {is_show: 1, id: value}
+            }), function (res) {
+                layList.msg(res.msg, function () {
+                    layList.reload();
+                });
+            });
+        } else {
+            layList.baseGet(layList.Url({
+                c: 'system.system_store',
+                a: 'set_point_show',
+                p: {is_show: 0, id: value}
+            }), function (res) {
+                layList.msg(res.msg, function () {
+                    layList.reload();
+                });
+            });
+        }
+    });
+    //点击事件绑定
+    layList.tool(function (event, data, obj) {
+        switch (event) {
+            case 'del':
+                var url = layList.U({c: 'system.system_store', a: 'point_delete', q: {id: data.id}});
+                if (data.is_del) var code = {title: "操作提示", text: "确定恢复自提点吗?", type: 'info', confirm: '是的,恢复该自提点'};
+                else var code = {title: "操作提示", text: "确定将该自提点删除吗?", type: 'info', confirm: '是的,删除该自提点'};
+                $eb.$swal('delete', function () {
+                    $eb.axios.get(url).then(function (res) {
+                        if (res.status == 200 && res.data.code == 200) {
+                            $eb.$swal('success', res.data.msg);
+                            obj.del();
+                            location.reload();
+                        } else
+                            return Promise.reject(res.data.msg || '删除失败')
+                    }).catch(function (err) {
+                        $eb.$swal('error', err);
+                    });
+                }, code)
+                break;
+            case 'open_image':
+                $eb.openImage(data.image);
+                break;
+            case 'edit':
+                $eb.createModalFrame(data.name + '-编辑', layList.U({
+                    a: 'add_point',
+                    q: {id: data.id, store_id: store_id}
+                }), {h: 700, w: 1100});
+                break;
+            // case 'bill':
+            //     $eb.createModalFrame(data.name + '-佣金', layList.U({a: 'store_bill_log', q: {id: data.id}}), {
+            //         h: 700,
+            //         w: 1100
+            //     });
+            //     break;
+        }
+    })
+</script>
+{/block}

+ 354 - 137
app/api/controller/admin/StoreOrderController.php

@@ -2,7 +2,15 @@
 
 namespace app\api\controller\admin;
 
+use app\admin\model\system\SystemStoreBill;
+use app\admin\model\system\SystemStoreExtract;
+use app\admin\model\system\SystemStorePoint;
+use app\admin\model\system\SystemStoreProductStock;
+use app\models\system\SystemStore;
 use app\Request;
+use think\db\exception\DataNotFoundException;
+use think\db\exception\DbException;
+use think\db\exception\ModelNotFoundException;
 use app\models\user\{
     User, UserBill
 };
@@ -23,18 +31,225 @@ use app\models\system\SystemStoreStaff;
  */
 class StoreOrderController
 {
+
+    public function pointList(Request $request)
+    {
+        $uid = $request->uid();
+        $where = UtilService::getMore([
+            ['page', 1],
+            ['limit', 20],
+            ['type', 1]
+        ]);
+        $info = SystemStoreStaff::where('uid', $uid)->where('status', 1)->find();
+        if (!$info) {
+            return app('json')->fail('权限不足');
+        }
+//        var_dump($info->toArray());
+        $where['store_id'] = $info['store_id'];
+        $where['excel'] = 0;
+//        $where['type'] = $info['store_id'];
+        return app('json')->successful('ok', SystemStorePoint::getStoreList($where));
+    }
+
+    public function pointDetail($id, Request $request)
+    {
+        $uid = $request->uid();
+        $info = SystemStoreStaff::where('uid', $uid)->where('status', 1)->find();
+        if (!$info) {
+            return app('json')->fail('权限不足');
+        }
+        return app('json')->successful('ok', ['data' => SystemStorePoint::getStoreDispose($id)]);
+    }
+
+    public function addDetail(Request $request, $id = 0)
+    {
+        $uid = $request->uid();
+        $info = SystemStoreStaff::where('uid', $uid)->where('status', 1)->find();
+        if (!$info) {
+            return app('json')->fail('权限不足');
+        }
+        $data = UtilService::postMore([
+            ['name', ''],
+            ['phone', ''],
+            ['address', ''],
+            ['detailed_address', ''],
+            ['latlng', ''],
+            ['valid_time', []],
+            ['day_time', []],
+            ['is_show', 0],
+        ]);
+        $data['store_id'] = $info['store_id'];
+        $data['address'] = implode(',', $data['address']);
+        $data['latlng'] = is_string($data['latlng']) ? explode(',', $data['latlng']) : $data['latlng'];
+        if (!isset($data['latlng'][0]) || !isset($data['latlng'][1])) return app('json')->fail('请选择门店位置');
+        $data['latitude'] = $data['latlng'][0];
+        $data['longitude'] = $data['latlng'][1];
+        $data['valid_time'] = implode(' - ', $data['valid_time']);
+        $data['day_time'] = implode(' - ', $data['day_time']);
+        unset($data['latlng']);
+        if ($id) {
+            $store_info = SystemStorePoint::get($id);
+            if ($store_info['store_id'] != $info['store_id']) {
+                return app('json')->fail('权限不足');
+            }
+            if (SystemStorePoint::where('id', $id)->update($data)) {
+                SystemStorePoint::commitTrans();
+                return app('json')->successful('修改成功');
+            } else {
+                SystemStorePoint::rollbackTrans();
+                return app('json')->fail('修改失败或者您没有修改什么!');
+            }
+        } else {
+            $data['add_time'] = time();
+            $data['is_show'] = 1;
+            if ($res = SystemStorePoint::create($data)) {
+                SystemStorePoint::commitTrans();
+                return app('json')->successful('保存成功', ['id' => $res->id]);
+            } else {
+                SystemStorePoint::rollbackTrans();
+                return app('json')->fail('保存失败!');
+            }
+        }
+    }
+
+
+    /**
+     * 删除恢复门店
+     * @param $id
+     */
+    public function point_delete($id, Request $request)
+    {
+        if (!$id) return app('json')->fail('数据不存在');
+        if (!SystemStorePoint::be(['id' => $id])) return app('json')->fail('数据不存在');
+        $uid = $request->uid();
+        $info = SystemStoreStaff::where('uid', $uid)->where('status', 1)->find();
+        if (!$info) {
+            return app('json')->fail('权限不足');
+        }
+        $store_info = SystemStorePoint::get($id);
+        if ($store_info['store_id'] != $info['store_id']) {
+            return app('json')->fail('权限不足');
+        }
+        if (SystemStorePoint::be(['id' => $id, 'is_del' => 1])) {
+            $data['is_del'] = 0;
+            if (!SystemStorePoint::edit($data, $id))
+                return app('json')->fail(SystemStorePoint::getErrorInfo('恢复失败,请稍候再试!'));
+            else
+                return app('json')->success('恢复门店成功!');
+        } else {
+            $data['is_del'] = 1;
+            if (!SystemStorePoint::edit($data, $id))
+                return app('json')->fail(SystemStorePoint::getErrorInfo('删除失败,请稍候再试!'));
+            else
+                return app('json')->success('删除门店成功!');
+        }
+    }
+
+    public function stockList(Request $request)
+    {
+        $uid = $request->uid();
+        $where = UtilService::getMore([
+            ['type', ''],
+            ['page', 1],
+            ['limit', 20],
+            ['start_time', ''],
+            ['end_time', ''],
+        ]);
+
+        $info = SystemStoreStaff::where('uid', $uid)->where('status', 1)->find();
+        if (!$info) {
+            return app('json')->fail('权限不足');
+        }
+        return app('json')->successful('ok', ['warning' => SystemStoreProductStock::getWarning($info['store_id']), 'data' => SystemStoreProductStock::getStockList($where, $info['store_id'])]);
+    }
+
+    public function billList(Request $request)
+    {
+        $uid = $request->uid();
+        $where = UtilService::getMore([
+            ['page', 1],
+            ['limit', 20],
+            ['type', ''],
+            ['time', ''],
+        ]);
+        $info = SystemStoreStaff::where('uid', $uid)->where('status', 1)->find();
+        if (!$info) {
+            return app('json')->fail('权限不足');
+        }
+        return app('json')->successful('ok', ['switch' => sys_config('withdraw_switch', 0), 'all' => SystemStore::get($info['store_id'])['brokerage_price'], 'data' => SystemStoreBill::getList($where, $info['store_id'])]);
+    }
+
+    public function cash(Request $request)
+    {
+        $uid = $request->uid();
+        $info = SystemStoreStaff::where('uid', $uid)->where('status', 1)->find();
+        if (!$info) {
+            return app('json')->fail('权限不足');
+        }
+        if (!in_array(sys_config('default_store_admin', 7), explode(',', $request->admin_info()['roles']))) {
+            return app('json')->fail('权限不足');
+        }
+        $store = SystemStore::get($info['store_id']);
+        $extractInfo = UtilService::postMore([
+            ['money', 0],
+        ], $request);
+        $extractInfo['extract_type'] = 'bank';
+        $extractInfo['name'] = $store['leader'];
+        $extractInfo['bankname'] = $store['bank_name'];
+        $extractInfo['cardnum'] = $store['bank_card'];
+        if (!preg_match('/^(([1-9]\d*)|0)(\.\d{1-2})?$/', $extractInfo['money'])) app('json')->fail('提现金额输入有误');
+        $store = SystemStore::get($info['store_id']);
+        if ($extractInfo['money'] > $store['brokerage_price']) return app('json')->fail('可提现佣金不足');
+        if (!$extractInfo['cardnum'] == '')
+            if (!preg_match('/^([1-9]{1})(\d{14}|\d{18})$/', $extractInfo['cardnum']))
+                return app('json')->fail('银行卡号有误');
+        if (SystemStoreExtract::userExtract($store, $extractInfo))
+            return app('json')->successful('申请提现成功!');
+        else
+            return app('json')->fail(SystemStoreExtract::getErrorInfo('提现失败'));
+    }
+
+    public function childrenList(Request $request)
+    {
+        $uid = $request->uid();
+        $info = SystemStoreStaff::where('uid', $uid)->where('status', 1)->find();
+        if (!$info) {
+            return app('json')->fail('权限不足');
+        }
+        $where = UtilService::getMore([
+            ['page', 1],
+            ['limit', 20],
+            ['name', ''],
+            ['level', ''],
+            ['excel', 0],
+            ['type', ''],
+            ['parent_id', 0],
+        ]);
+        $where['self_store'] = $info['store_id'];
+        return app('json')->successful('ok', \app\admin\model\system\SystemStore::getStoreList($where));
+    }
+
+
     /**
      *  订单数据统计
      * @param Request $request
      * @return mixed
+     * @throws DataNotFoundException
+     * @throws DbException
+     * @throws ModelNotFoundException
      */
     public function statistics(Request $request)
     {
         $uid = $request->uid();
-        if (!StoreService::orderServiceStatus($uid))
-            return app('json')->fail('权限不足');
-        $dataCount = StoreOrder::getOrderDataAdmin();
-        $dataPrice = StoreOrder::getOrderTimeData();
+//        if (!StoreService::orderServiceStatus($uid))
+//            return app('json')->fail('权限不足');
+        $where = [];
+        $info = SystemStoreStaff::where('uid', $uid)->where('status', 1)->find();
+        if ($info) {
+            $where['store_id'] = $info['store_id'];
+        }
+        $dataCount = StoreOrder::getOrderDataAdmin($where);
+        $dataPrice = StoreOrder::getOrderTimeData($where);
         $data = array_merge($dataCount, $dataPrice);
         return app('json')->successful($data);
     }
@@ -43,20 +258,28 @@ class StoreOrderController
      * 订单每月统计数据
      * @param Request $request
      * @return mixed
+     * @throws DataNotFoundException
+     * @throws DbException
+     * @throws ModelNotFoundException
      */
     public function data(Request $request)
     {
         $uid = $request->uid();
-        if (!StoreService::orderServiceStatus($uid))
-            return app('json')->fail('权限不足');
+//        if (!StoreService::orderServiceStatus($uid))
+//            return app('json')->fail('权限不足');
         list($page, $limit, $start, $stop) = UtilService::getMore([
             ['page', 1],
             ['limit', 7],
             ['start', ''],
             ['stop', '']
         ], $request, true);
+        $where = [];
+        $info = SystemStoreStaff::where('uid', $uid)->where('status', 1)->find();
+        if ($info) {
+            $where['store_id'] = $info['store_id'];
+        }
         if (!$limit) return app('json')->successful([]);
-        $data = StoreOrder::getOrderDataPriceCount($page, $limit, $start, $stop);
+        $data = StoreOrder::getOrderDataPriceCount($page, $limit, $start, $stop, $where);
         if ($data) return app('json')->successful($data->toArray());
         return app('json')->successful([]);
     }
@@ -65,21 +288,29 @@ class StoreOrderController
      * 订单列表
      * @param Request $request
      * @return mixed
+     * @throws DataNotFoundException
+     * @throws DbException
+     * @throws ModelNotFoundException
      */
     public function lst(Request $request)
     {
         $uid = $request->uid();
-        if (!StoreService::orderServiceStatus($uid))
-            return app('json')->fail('权限不足');
+//        if (!StoreService::orderServiceStatus($uid))
+//            return app('json')->fail('权限不足');
         $where = UtilService::getMore([
             ['status', ''],
             ['is_del', 0],
             ['data', ''],
             ['type', ''],
+            ['shipping_type', ''],
             ['order', ''],
             ['page', 0],
             ['limit', 0]
         ], $request);
+        $info = SystemStoreStaff::where('uid', $uid)->where('status', 1)->find();
+        if ($info) {
+            $where['store_id'] = $info['store_id'];
+        }
         if (!$where['limit']) return app('json')->successful([]);
         return app('json')->successful(StoreOrder::orderList($where));
     }
@@ -89,17 +320,21 @@ class StoreOrderController
      * @param Request $request
      * @param $orderId
      * @return mixed
-     * @throws \think\Exception
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @throws DataNotFoundException
+     * @throws ModelNotFoundException
+     * @throws DbException
      */
     public function detail(Request $request, $orderId)
     {
         $uid = $request->uid();
-        if (!StoreService::orderServiceStatus($uid))
-            return app('json')->fail('权限不足');
-        $order = StoreOrder::getAdminOrderDetail($orderId, 'id,uid,order_id,add_time,status,total_num,total_price,total_postage,pay_price,pay_postage,paid,refund_status,remark,pink_id,combination_id,mark,seckill_id,bargain_id,delivery_type,pay_type,real_name,user_phone,user_address,coupon_price,freight_price,delivery_name,delivery_type,delivery_id');
+//        if (!StoreService::orderServiceStatus($uid))
+//            return app('json')->fail('权限不足');
+        $where = [];
+        $info = SystemStoreStaff::where('uid', $uid)->where('status', 1)->find();
+        if ($info) {
+            $where['store_id'] = $info['store_id'];
+        }
+        $order = StoreOrder::getAdminOrderDetail($orderId, 'id,uid,order_id,add_time,status,total_num,total_price,total_postage,pay_price,pay_postage,paid,refund_status,remark,pink_id,combination_id,mark,seckill_id,bargain_id,delivery_type,pay_type,real_name,user_phone,user_address,coupon_price,freight_price,delivery_name,delivery_type,delivery_id', $where);
         if (!$order) return app('json')->fail('订单不存在');
         $order = $order->toArray();
         $nickname = User::getUserInfo($order['uid'], 'nickname')['nickname'];
@@ -114,17 +349,21 @@ class StoreOrderController
      * @param Request $request
      * @param $orderId
      * @return mixed
-     * @throws \think\Exception
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @throws DataNotFoundException
+     * @throws ModelNotFoundException
+     * @throws DbException
      */
     public function delivery_gain(Request $request, $orderId)
     {
         $uid = $request->uid();
-        if (!StoreService::orderServiceStatus($uid))
-            return app('json')->fail('权限不足');
-        $order = StoreOrder::getAdminOrderDetail($orderId, 'real_name,user_phone,user_address,order_id,uid,status,paid');
+//        if (!StoreService::orderServiceStatus($uid))
+//            return app('json')->fail('权限不足');
+        $where = [];
+        $info = SystemStoreStaff::where('uid', $uid)->where('status', 1)->find();
+        if ($info) {
+            $where['store_id'] = $info['store_id'];
+        }
+        $order = StoreOrder::getAdminOrderDetail($orderId, 'real_name,user_phone,user_address,order_id,uid,status,paid', $where);
         if (!$order) return app('json')->fail('订单不存在');
         if ($order['paid']) {
             $order['nickname'] = User::getUserInfo($order['uid'], 'nickname')['nickname'];
@@ -138,25 +377,31 @@ class StoreOrderController
      * 订单发货
      * @param Request $request
      * @return mixed
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
+     * @throws DataNotFoundException
+     * @throws ModelNotFoundException
      * @throws \think\exception\DbException
+     * @throws DbException
      */
     public function delivery_keep(Request $request)
     {
         $uid = $request->uid();
-        if (!StoreService::orderServiceStatus($uid))
-            return app('json')->fail('权限不足');
+//        if (!StoreService::orderServiceStatus($uid))
+//            return app('json')->fail('权限不足');
         list($order_id, $delivery_type, $delivery_name, $delivery_id) = UtilService::postMore([
             ['order_id', ''],
             ['delivery_type', 0],
             ['delivery_name', ''],
             ['delivery_id', ''],
         ], $request, true);
-        $order = StoreOrder::getAdminOrderDetail($order_id, 'id,status,paid');
+        $where = [];
+        $info = SystemStoreStaff::where('uid', $uid)->where('status', 1)->find();
+        if ($info) {
+            $where['store_id'] = $info['store_id'];
+        }
+        $order = StoreOrder::getAdminOrderDetail($order_id, 'id,status,paid', $where);
         if (!$order) return app('json')->fail('订单不存在');
         if (!$order['status'] && $order['paid']) {
-            $deliveryTypeArr = ['send', 'express', 'fictitious'];
+            $deliveryTypeArr = isset($where['store_id']) ? ['send'] : ['send', 'express', 'fictitious'];
             if (!strlen(trim($delivery_type))) return app('json')->fail('请填写发货方式');
             if (!in_array($delivery_type, $deliveryTypeArr)) return app('json')->fail('发货方式错误');
             if ($delivery_type == 'express') {
@@ -191,20 +436,25 @@ class StoreOrderController
      * 订单改价
      * @param Request $request
      * @return mixed
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @throws DataNotFoundException
+     * @throws ModelNotFoundException
+     * @throws DbException
      */
     public function price(Request $request)
     {
         $uid = $request->uid();
-        if (!StoreService::orderServiceStatus($uid))
-            return app('json')->fail('权限不足');
+//        if (!StoreService::orderServiceStatus($uid))
+//            return app('json')->fail('权限不足');
         list($order_id, $price) = UtilService::postMore([
             ['order_id', ''],
             ['price', '']
         ], $request, true);
-        $order = StoreOrder::getAdminOrderDetail($order_id, 'id,paid,user_phone,pay_price,order_id,total_price,total_postage,pay_postage,gain_integral');
+        $where = [];
+        $info = SystemStoreStaff::where('uid', $uid)->where('status', 1)->find();
+        if ($info) {
+            $where['store_id'] = $info['store_id'];
+        }
+        $order = StoreOrder::getAdminOrderDetail($order_id, 'id,paid,user_phone,pay_price,order_id,total_price,total_postage,pay_postage,gain_integral', $where);
         if (!$order) return app('json')->fail('订单不存在');
         $order = $order->toArray();
         if (!$order['paid']) {
@@ -231,20 +481,25 @@ class StoreOrderController
      * 订单备注
      * @param Request $request
      * @return mixed
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @throws DataNotFoundException
+     * @throws ModelNotFoundException
+     * @throws DbException
      */
     public function remark(Request $request)
     {
         $uid = $request->uid();
-        if (!StoreService::orderServiceStatus($uid))
-            return app('json')->fail('权限不足');
+//        if (!StoreService::orderServiceStatus($uid))
+//            return app('json')->fail('权限不足');
         list($order_id, $remark) = UtilService::postMore([
             ['order_id', ''],
             ['remark', '']
         ], $request, true);
-        $order = StoreOrder::getAdminOrderDetail($order_id, 'id');
+        $where = [];
+        $info = SystemStoreStaff::where('uid', $uid)->where('status', 1)->find();
+        if ($info) {
+            $where['store_id'] = $info['store_id'];
+        }
+        $order = StoreOrder::getAdminOrderDetail($order_id, 'id', $where);
         if (!$order) return app('json')->fail('订单不存在');
         $order = $order->toArray();
         if (!strlen(trim($remark))) return app('json')->fail('请填写备注内容');
@@ -261,13 +516,18 @@ class StoreOrderController
     public function time(Request $request)
     {
         $uid = $request->uid();
-        if (!StoreService::orderServiceStatus($uid))
-            return app('json')->fail('权限不足');
+//        if (!StoreService::orderServiceStatus($uid))
+//            return app('json')->fail('权限不足');
         list($start, $stop, $type) = UtilService::getMore([
             ['start', strtotime(date('Y-m'))],
             ['stop', time()],
             ['type', 1]
         ], $request, true);
+        $where = [];
+        $info = SystemStoreStaff::where('uid', $uid)->where('status', 1)->find();
+        if ($info) {
+            $where['store_id'] = $info['store_id'];
+        }
         if ($start == $stop) {
             return app('json')->fail('开始时间不能等于结束时间');
         }
@@ -279,9 +539,9 @@ class StoreOrderController
         $space = bcsub($stop, $start, 0);//间隔时间段
         $front = bcsub($start, $space, 0);//第一个时间段
         if ($type == 1) {//销售额
-            $frontPrice = StoreOrder:: getOrderTimeBusinessVolumePrice($front, $start);
-            $afterPrice = StoreOrder:: getOrderTimeBusinessVolumePrice($start, $stop);
-            $chartInfo = StoreOrder::chartTimePrice($start, $stop);
+            $frontPrice = StoreOrder:: getOrderTimeBusinessVolumePrice($front, $start, $where);
+            $afterPrice = StoreOrder:: getOrderTimeBusinessVolumePrice($start, $stop, $where);
+            $chartInfo = StoreOrder::chartTimePrice($start, $stop, $where);
             $data['chart'] = $chartInfo;//营业额图表数据
             $data['time'] = $afterPrice;//时间区间营业额
             $increase = (float)bcsub($afterPrice, $frontPrice, 2); //同比上个时间区间增长营业额
@@ -292,9 +552,9 @@ class StoreOrderController
             $data['increase_time'] = abs($increase); //同比上个时间区间增长营业额
             $data['increase_time_status'] = $increase >= 0 ? 1 : 2; //同比上个时间区间增长营业额增长 1 减少 2
         } else {//订单数
-            $frontNumber = StoreOrder:: getOrderTimeBusinessVolumeNumber($front, $start);
-            $afterNumber = StoreOrder:: getOrderTimeBusinessVolumeNumber($start, $stop);
-            $chartInfo = StoreOrder::chartTimeNumber($start, $stop);
+            $frontNumber = StoreOrder:: getOrderTimeBusinessVolumeNumber($front, $start, $where);
+            $afterNumber = StoreOrder:: getOrderTimeBusinessVolumeNumber($start, $stop, $where);
+            $chartInfo = StoreOrder::chartTimeNumber($start, $stop, $where);
             $data['chart'] = $chartInfo;//订单数图表数据
             $data['time'] = $afterNumber;//时间区间订单数
             $increase = (int)bcsub($afterNumber, $frontNumber, 0); //同比上个时间区间增长订单数
@@ -312,14 +572,20 @@ class StoreOrderController
      * 订单支付
      * @param Request $request
      * @return mixed
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @throws DataNotFoundException
+     * @throws ModelNotFoundException
+     * @throws DbException
      */
     public function offline(Request $request)
     {
+        $uid = $request->uid();
         list($orderId) = UtilService::postMore([['order_id', '']], $request, true);
-        $orderInfo = StoreOrder::getAdminOrderDetail($orderId, 'id');
+        $where = [];
+        $info = SystemStoreStaff::where('uid', $uid)->where('status', 1)->find();
+        if ($info) {
+            $where['store_id'] = $info['store_id'];
+        }
+        $orderInfo = StoreOrder::getAdminOrderDetail($orderId, 'id', $where);
         if (!$orderInfo) return app('json')->fail('参数错误');
         $id = $orderInfo->id;
         $res = StoreOrder::updateOffline($id);
@@ -336,19 +602,25 @@ class StoreOrderController
      * @param Request $request
      * @return mixed
      * @throws \think\Exception
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
+     * @throws DataNotFoundException
+     * @throws ModelNotFoundException
+     * @throws DbException
      */
     public function refund(Request $request)
     {
+        $uid = $request->uid();
         list($orderId, $price, $type) = UtilService::postMore([
             ['order_id', ''],
             ['price', 0],
             ['type', 1],
         ], $request, true);
+        $where = [];
+        $info = SystemStoreStaff::where('uid', $uid)->where('status', 1)->find();
+        if ($info) {
+            $where['store_id'] = $info['store_id'];
+        }
         if (!strlen(trim($orderId))) return app('json')->fail('参数错误');
-        $orderInfo = StoreOrder::getAdminOrderDetail($orderId);
+        $orderInfo = StoreOrder::getAdminOrderDetail($orderId, '*', $where);
         if (!$orderInfo) return app('json')->fail('数据不存在!');
         $orderInfo = $orderInfo->toArray();
         if ($type == 1)
@@ -411,12 +683,26 @@ class StoreOrderController
                 return app('json')->fail($e->getMessage());
             }
             StoreOrderStatus::status($orderInfo['id'], 'refund_price', '退款给用户' . $price . '元');
+            SystemStoreBill::where('category', 'brokerage_price')
+                //->where('type', 'brokerage')
+                ->where('link_id', $orderId)
+                ->where('pm', 1)
+                ->where('status', 0)
+                ->update(['status' => -1]);
 
+
+            \app\admin\model\user\UserBill::where('category', 'now_money')
+                ->where('type', 'brokerage')
+                ->where('link_id', $orderId)
+                ->where('pm', 1)
+                ->where('status', 0)
+                ->update(['status' => -1]);
             //退佣金
             $brokerage_list = UserBill::where('category', 'now_money')
                 ->where('type', 'brokerage')
                 ->where('link_id', $orderId)
                 ->where('pm', 1)
+                ->where('status', 1)
                 ->select()->toArray();
             if ($brokerage_list)
                 foreach ($brokerage_list as $item) {
@@ -433,94 +719,24 @@ class StoreOrderController
         }
     }
 
-
-    /**
-     * 订单退押金
-     * @param Request $request
-     * @return mixed
-     * @throws \think\Exception
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
-     */
-    public function back_deposit(Request $request)
-    {
-        list($orderId, $price, $type) = UtilService::postMore([
-            ['order_id', ''],
-            ['price', 0],
-            ['type', 1],
-        ], $request, true);
-        if (!strlen(trim($orderId))) return app('json')->fail('参数错误');
-        $orderInfo = StoreOrder::getAdminOrderDetail($orderId);
-        if (!$orderInfo) return app('json')->fail('数据不存在!');
-        $orderInfo = $orderInfo->toArray();
-        if ($type == 1)
-            $data['deposit_status'] = 1;
-        else if ($type == 2) {
-            $data['deposit_status'] = 0;
-        } else
-            return app('json')->fail('退款修改状态错误');
-        if ($orderInfo['deposit'] == 0 || $type == 2) {
-            StoreOrder::update($data, ['order_id' => $orderId]);
-            return app('json')->successful('修改退款状态成功!');
-        }
-        if ($orderInfo['deposit'] == $orderInfo['deposit_back']) return app('json')->fail('已退完押金!不能再退了');
-        if (!$price) return app('json')->fail('请输入退押金额');
-        $data['deposit_back'] = bcadd($price, $orderInfo['deposit_back'], 2);
-        $bj = bccomp((float)$orderInfo['deposit'], (float)$data['deposit_back'], 2);
-        if ($bj < 0) return app('json')->fail('退款押金大于支付押金,请修改退款押金');
-        $refundData['pay_price'] = bcadd($orderInfo['pay_price'], $orderInfo['deposit'], 2);
-        $refundData['refund_price'] = $price;
-        if ($orderInfo['pay_type'] == 'weixin') {
-            if ($orderInfo['is_channel'] == 1) {// 小程序
-                try {
-                    MiniProgramService::payOrderRefund($orderInfo['order_id'], $refundData);
-                } catch (\Exception $e) {
-                    return app('json')->fail($e->getMessage());
-                }
-            } else {// 公众号
-                try {
-                    WechatService::payOrderRefund($orderInfo['order_id'], $refundData);
-                } catch (\Exception $e) {
-                    return app('json')->fail($e->getMessage());
-                }
-            }
-        } else if ($orderInfo['pay_type'] == 'yue') {//余额
-            StoreOrder::beginTrans();
-            $userInfo = User::getUserInfo($orderInfo['uid'], 'now_money');
-            if (!$userInfo) {
-                StoreOrder::rollbackTrans();
-                return app('json')->fail('订单用户不存在');
-            }
-            $res1 = User::bcInc($orderInfo['uid'], 'now_money', $price, 'uid');
-            $res2 = UserBill::income('商品退押金', $orderInfo['uid'], 'now_money', 'pay_deposit_refund', $price, $orderInfo['id'], bcadd($userInfo['now_money'], $price, 2), '订单退押金到余额' . floatval($price) . '元');
-            $res = $res1 && $res2;
-            StoreOrder::checkTrans($res);
-            if (!$res) return app('json')->fail('余额退押金失败!');
-        }
-        $resEdit = StoreOrder::edit($data, $orderInfo['id'], 'id');
-        if ($resEdit) {
-            StoreOrderStatus::status($orderInfo['id'], 'refund_deposit', '退押金给用户' . $price . '元');
-            return app('json')->successful('修改成功!');
-        } else {
-            StoreOrderStatus::status($orderInfo['id'], 'refund_deposit', '退押金给用户' . $price . '元失败');
-            return app('json')->successful('修改失败!');
-        }
-    }
-
     /**
      * 门店核销
      * @param Request $request
+     * @return
+     * @throws DataNotFoundException
+     * @throws DbException
+     * @throws ModelNotFoundException
      */
     public function order_verific(Request $request)
     {
+        $uid = $request->uid();
         list($verify_code, $is_confirm) = UtilService::postMore([
             ['verify_code', ''],
             ['is_confirm', 0]
         ], $request, true);
         if (!$verify_code) return app('json')->fail('缺少核销码');
-        $orderInfo = StoreOrder::where('verify_code', $verify_code)->where('paid', 1)->where('refund_status', 0)->find();
-        if (!$orderInfo) return app('json')->fail('核销的订单不存在或未支付或已退款');
+        $orderInfo = StoreOrder::where('verify_code', $verify_code)->where('store_id', $storeStaff = SystemStoreStaff::where('uid', $uid)->value('store_id'))->where('paid', 1)->where('refund_status', 0)->find();
+        if (!$orderInfo) return app('json')->fail('核销的订单不存在于该门店或未支付或已退款');
         if ($orderInfo->status > 0) return app('json')->fail('订单已经核销');
         if ($orderInfo->combination_id && $orderInfo->pink_id) {
             $res = StorePink::where('id', $orderInfo->pink_id)->where('status', '<>', 2)->count();
@@ -532,9 +748,8 @@ class StoreOrderController
         }
         StoreOrder::beginTrans();
         try {
-            $uid = $request->uid();
             if (SystemStoreStaff::verifyStatus($uid) && ($storeStaff = SystemStoreStaff::where('uid', $uid)->field(['store_id', 'id'])->find())) {
-                $orderInfo->store_id = $storeStaff['store_id'];
+//                $orderInfo->store_id = $storeStaff['store_id'];
                 $orderInfo->clerk_id = $storeStaff['id'];
             }
             $orderInfo->status = 2;
@@ -551,8 +766,10 @@ class StoreOrderController
         } catch (\PDOException $e) {
             StoreOrder::rollbackTrans();
             return app('json')->fail($e->getMessage());
+        } catch (\Exception $e) {
+            StoreOrder::rollbackTrans();
+            return app('json')->fail($e->getMessage());
         }
     }
 
-
 }

+ 88 - 0
app/api/controller/user/UserController.php

@@ -2,9 +2,14 @@
 
 namespace app\api\controller\user;
 
+use app\admin\model\system\SystemAdmin;
 use app\http\validates\user\AddressValidate;
 use app\models\system\SystemCity;
+use app\models\system\SystemStore;
+use app\models\system\SystemStoreStaff;
 use app\models\user\UserVisit;
+use crmeb\basic\BaseModel;
+use crmeb\services\workerman\Response;
 use think\db\exception\DataNotFoundException;
 use think\db\exception\DbException;
 use think\db\exception\ModelNotFoundException;
@@ -610,4 +615,87 @@ class UserController
         $puid = $request->post('puid/d', 0);
         return app('json')->success(User::setSpread($puid, $request->uid()));
     }
+
+    /**
+     * 绑定后台账号
+     * @param Request $request
+     * @return Response
+     */
+    public function bindAdmin(Request $request)
+    {
+        $admin_account = $request->post('admin_account');
+        $admin_password = $request->post('admin_password');
+        $admin = SystemAdmin::where('account', $admin_account)->where('is_del', 0)->where('status', 1)->find();
+        if (!$admin) {
+            return app('json')->fail('账号不存在');
+        }
+        if (md5($admin_password) !== $admin['pwd']) {
+            return app('json')->fail('密码错误');
+        }
+        if (!$admin['store_id']) {
+            return app('json')->fail('账号非门店账号');
+        }
+        if (User::be(['admin_id' => $admin['id']])) {
+            return app('json')->fail('门店账号已有绑定用户');
+        }
+        if (User::where('uid', $request->uid())->value('admin_id')) {
+            return app('json')->fail('已有绑定门店账号');
+        }
+        BaseModel::beginTrans();
+        try {
+            $res = User::where('uid', $request->uid())->update(['admin_id' => $admin['id']]);
+
+            //生成客服信息
+            $old = SystemStoreStaff::where('uid', $request->uid())->find();
+            if ($old) {
+                if ($old['store_id'] != $admin['store_id']) {
+                    $data = [
+                        'uid' => $request->uid(),
+                        'store_id' => $admin['store_id'],
+                    ];
+                    $data['add_time'] = time();
+                    $res = $res && SystemStoreStaff::edit($data, $old['id']);
+                }
+            } else {
+                $data = [
+                    'uid' => $request->uid(),
+                    'avatar' => $request->user()['avatar'],
+                    'store_id' => $admin['store_id'],
+                    'staff_name' => $request->user()['nickname'],
+                    'phone' => $request->user()['phone'],
+                    'verify_status' => 1,
+                    'status' => 1
+                ];
+                $data['add_time'] = time();
+                $res = $res && SystemStoreStaff::create($data);
+            }
+            if ($res) {
+                BaseModel::commitTrans();
+                return app('json')->successful('绑定成功');
+            } else {
+                BaseModel::rollbackTrans();
+                return app('json')->fail('绑定失败');
+            }
+        } catch (\Exception $e) {
+            BaseModel::rollbackTrans();
+            return app('json')->fail('绑定失败:' . $e->getMessage());
+        }
+
+    }
+
+    /**
+     * 获取我所属的门店
+     * @param Request $request
+     * @return mixed
+     * @throws DataNotFoundException
+     * @throws DbException
+     * @throws ModelNotFoundException
+     *
+     */
+    public function getMyStore(Request $request)
+    {
+        $admin_indo = $request->admin_info();
+        return app('json')->success('ok', SystemStore::getStoreDispose($admin_indo['store_id']) ? SystemStore::getStoreDispose($admin_indo['store_id'])->toArray() : []);
+    }
+
 }

+ 21 - 0
app/http/middleware/AuthTokenMiddleware.php

@@ -4,6 +4,9 @@
 namespace app\http\middleware;
 
 
+use app\admin\model\system\SystemAdmin;
+use app\models\system\SystemStore;
+use app\models\system\SystemStoreArea;
 use app\models\user\User;
 use app\models\user\UserToken;
 use app\Request;
@@ -32,6 +35,21 @@ class AuthTokenMiddleware implements MiddlewareInterface
         if (!$token) $token = trim(ltrim($request->header('Authorization'), 'Bearer'));//正式版,删除此行,某些服务器无法获取到token调整为 Authori-zation
         try {
             $authInfo = UserRepository::parseToken($token);
+            $authInfo['user']['store_info'] = [];
+            if ($authInfo['user']->admin_id) {
+                $adminInfo = SystemAdmin::get($authInfo['user']->admin_id);
+                if (!$adminInfo || !$adminInfo['status']) {
+                    $adminInfo = [];
+                } else {
+                    $adminInfo = $adminInfo->toArray();
+                    if (in_array(sys_config('default_store_admin', 7), explode(',', $adminInfo['roles']))) {
+                        $authInfo['user']['store_info'] = SystemStore::verificWhere()->where('id', $adminInfo['store_id'])->find();
+                    }
+//                    $adminInfo['auth'] = $adminInfo['level'] === 0 ? SystemRole::getAllAuth() : SystemRole::rolesByAuth($adminInfo['roles']);
+                }
+            } else {
+                $adminInfo = [];
+            }
         } catch (AuthException $e) {
             if ($force)
                 return app('json')->make($e->getCode(), $e->getMessage());
@@ -51,6 +69,9 @@ class AuthTokenMiddleware implements MiddlewareInterface
         Request::macro('isLogin', function () use (&$authInfo) {
             return !is_null($authInfo);
         });
+        Request::macro('admin_info', function () use (&$adminInfo) {
+            return $adminInfo;
+        });
         Request::macro('uid', function () use (&$authInfo) {
             return is_null($authInfo) ? 0 : $authInfo['user']->uid;
         });

+ 31 - 28
app/models/store/StoreOrder.php

@@ -1351,26 +1351,27 @@ class StoreOrder extends BaseModel
 
     /**
      * 获取 今日 昨日 本月 订单金额
+     * @param array $where
      * @return mixed
      */
-    public static function getOrderTimeData()
+    public static function getOrderTimeData($where = [])
     {
         $to_day = strtotime(date('Y-m-d'));//今日
         $pre_day = strtotime(date('Y-m-d', strtotime('-1 day')));//昨日
         $now_month = strtotime(date('Y-m'));//本月
         //今日成交额
 //        $data['todayPrice'] = (float)number_format(self::where('is_del', 0)->where('pay_time', '>=', $to_day)->where('paid', 1)->where('refund_status', 0)->value('sum(pay_price)'), 2) ?? 0;
-        $data['todayPrice'] = number_format(self::where('is_del', 0)->where('pay_time', '>=', $to_day)->where('paid', 1)->where('refund_status', 0)->value('sum(pay_price)'), 2) ?? 0;
+        $data['todayPrice'] = number_format(self::where('is_del', 0)->where($where)->where('pay_time', '>=', $to_day)->where('paid', 1)->where('refund_status', 0)->value('sum(pay_price)'), 2) ?? 0;
         //今日订单数
-        $data['todayCount'] = self::where('is_del', 0)->where('pay_time', '>=', $to_day)->where('paid', 1)->where('refund_status', 0)->count();
+        $data['todayCount'] = self::where('is_del', 0)->where($where)->where('pay_time', '>=', $to_day)->where('paid', 1)->where('refund_status', 0)->count();
         //昨日成交额
-        $data['proPrice'] = number_format(self::where('is_del', 0)->where('pay_time', '<', $to_day)->where('pay_time', '>=', $pre_day)->where('paid', 1)->where('refund_status', 0)->value('sum(pay_price)'), 2) ?? 0;
+        $data['proPrice'] = number_format(self::where('is_del', 0)->where($where)->where('pay_time', '<', $to_day)->where('pay_time', '>=', $pre_day)->where('paid', 1)->where('refund_status', 0)->value('sum(pay_price)'), 2) ?? 0;
         //昨日订单数
-        $data['proCount'] = self::where('is_del', 0)->where('pay_time', '<', $to_day)->where('pay_time', '>=', $pre_day)->where('paid', 1)->where('refund_status', 0)->count();
+        $data['proCount'] = self::where('is_del', 0)->where($where)->where('pay_time', '<', $to_day)->where('pay_time', '>=', $pre_day)->where('paid', 1)->where('refund_status', 0)->count();
         //本月成交额
-        $data['monthPrice'] = number_format(self::where('is_del', 0)->where('pay_time', '>=', $now_month)->where('paid', 1)->where('refund_status', 0)->value('sum(pay_price)'), 2) ?? 0;
+        $data['monthPrice'] = number_format(self::where('is_del', 0)->where($where)->where('pay_time', '>=', $now_month)->where('paid', 1)->where('refund_status', 0)->value('sum(pay_price)'), 2) ?? 0;
         //本月订单数
-        $data['monthCount'] = self::where('is_del', 0)->where('pay_time', '>=', $now_month)->where('paid', 1)->where('refund_status', 0)->count();
+        $data['monthCount'] = self::where('is_del', 0)->where($where)->where('pay_time', '>=', $now_month)->where('paid', 1)->where('refund_status', 0)->count();
         return $data;
     }
 
@@ -1406,24 +1407,24 @@ class StoreOrder extends BaseModel
      * @param $uid
      * @return mixed
      */
-    public static function getOrderDataAdmin()
+    public static function getOrderDataAdmin($where = [])
     {
         //订单支付没有退款 数量
-        $data['order_count'] = self::where('is_del', 0)->where('paid', 1)->where('refund_status', 0)->count();
+        $data['order_count'] = self::where('is_del', 0)->where($where)->where('paid', 1)->where('refund_status', 0)->count();
         //订单支付没有退款 支付总金额
-        $data['sum_price'] = self::where('is_del', 0)->where('paid', 1)->where('refund_status', 0)->sum('pay_price');
+        $data['sum_price'] = self::where('is_del', 0)->where($where)->where('paid', 1)->where('refund_status', 0)->sum('pay_price');
         //订单待支付 数量
-        $data['unpaid_count'] = self::statusByWhere(0, 0)->where('is_del', 0)->count();
+        $data['unpaid_count'] = self::statusByWhere(0, 0)->where($where)->where('is_del', 0)->count();
         //订单待发货 数量
-        $data['unshipped_count'] = self::statusByWhere(1, 0)->where('is_del', 0)->count();
+        $data['unshipped_count'] = self::statusByWhere(1, 0)->where($where)->where('is_del', 0)->count();
         //订单待收货 数量
-        $data['received_count'] = self::statusByWhere(2, 0)->where('is_del', 0)->count();
+        $data['received_count'] = self::statusByWhere(2, 0)->where($where)->where('is_del', 0)->count();
         //订单待评价 数量
-        $data['evaluated_count'] = self::statusByWhere(3, 0)->where('is_del', 0)->count();
+        $data['evaluated_count'] = self::statusByWhere(3, 0)->where($where)->where('is_del', 0)->count();
         //订单已完成 数量
-        $data['complete_count'] = self::statusByWhere(4, 0)->where('is_del', 0)->count();
+        $data['complete_count'] = self::statusByWhere(4, 0)->where($where)->where('is_del', 0)->count();
         //订单退款 数量
-        $data['refund_count'] = self::statusByWhere(-3, 0)->where('is_del', 0)->count();
+        $data['refund_count'] = self::statusByWhere(-3, 0)->where($where)->where('is_del', 0)->count();
         return $data;
     }
 
@@ -1662,10 +1663,10 @@ class StoreOrder extends BaseModel
      * @param $limit
      * @return array
      */
-    public static function getOrderDataPriceCount($page, $limit, $start, $stop)
+    public static function getOrderDataPriceCount($page, $limit, $start, $stop, $where = [])
     {
         if (!$limit) return [];
-        $model = new self;
+        $model = self::where($where);
         if ($start != '' && $stop != '') $model = $model->where('pay_time', '>', $start)->where('pay_time', '<=', $stop);
         $model = $model->field('sum(pay_price) as price,count(id) as count,FROM_UNIXTIME(pay_time, \'%m-%d\') as time');
         $model = $model->where('is_del', 0);
@@ -1980,6 +1981,8 @@ class StoreOrder extends BaseModel
             return $model->where($alert . 'paid', 0)->where($alert . 'status', 0)->where($alert . 'refund_status', 0);
         else if ($status == 1)//已支付 未发货
             return $model->where($alert . 'paid', 1)->where($alert . 'status', 0)->where($alert . 'refund_status', 0);
+        else if ($status == 5)//待核销
+            return $model->where($alert . 'paid', 1)->where('shipping_type', 2)->where($alert . 'status', 0)->where($alert . 'refund_status', 0);
         else if ($status == 2)//已支付  待收货
             return $model->where($alert . 'paid', 1)->where($alert . 'status', 1)->where($alert . 'refund_status', 0);
         else if ($status == 3)// 已支付  已收货  待评价
@@ -2005,9 +2008,9 @@ class StoreOrder extends BaseModel
      * @throws ModelNotFoundException
      * @throws \think\exception\DbException
      */
-    public static function getAdminOrderDetail($orderId, $field = '*')
+    public static function getAdminOrderDetail($orderId, $field = '*', $other_where = [])
     {
-        return self::where('order_id', $orderId)->field($field)->find();
+        return self::where('order_id', $orderId)->where($other_where)->field($field)->find();
     }
 
     /**
@@ -2016,9 +2019,9 @@ class StoreOrder extends BaseModel
      * @param $stop
      * @return float
      */
-    public static function getOrderTimeBusinessVolumePrice($start, $stop)
+    public static function getOrderTimeBusinessVolumePrice($start, $stop, $where = [])
     {
-        return self::where('is_del', 0)->where('paid', 1)->where('refund_status', 0)->where('add_time', '>=', $start)->where('add_time', '<', $stop)->sum('pay_price');
+        return self::where('is_del', 0)->where($where)->where('paid', 1)->where('refund_status', 0)->where('add_time', '>=', $start)->where('add_time', '<', $stop)->sum('pay_price');
     }
 
     /**
@@ -2027,9 +2030,9 @@ class StoreOrder extends BaseModel
      * @param $stop
      * @return float
      */
-    public static function getOrderTimeBusinessVolumeNumber($start, $stop)
+    public static function getOrderTimeBusinessVolumeNumber($start, $stop, $where = [])
     {
-        return self::where('is_del', 0)->where('paid', 1)->where('refund_status', 0)->where('add_time', '>=', $start)->where('add_time', '<', $stop)->count();
+        return self::where('is_del', 0)->where($where)->where('paid', 1)->where('refund_status', 0)->where('add_time', '>=', $start)->where('add_time', '<', $stop)->count();
     }
 
     /**
@@ -2038,9 +2041,9 @@ class StoreOrder extends BaseModel
      * @param $stop  结束时间
      * @return mixed
      */
-    public static function chartTimePrice($start, $stop)
+    public static function chartTimePrice($start, $stop, $where = [])
     {
-        $model = new self;
+        $model = self::where($where);
         $model = $model->field('sum(pay_price) as num,FROM_UNIXTIME(add_time, \'%Y-%m-%d\') as time');
         $model = $model->where('is_del', 0);
         $model = $model->where('paid', 1);
@@ -2058,9 +2061,9 @@ class StoreOrder extends BaseModel
      * @param $stop  结束时间
      * @return mixed
      */
-    public static function chartTimeNumber($start, $stop)
+    public static function chartTimeNumber($start, $stop, $where = [])
     {
-        $model = new self;
+        $model = self::where($where);
         $model = $model->field('count(id) as num,FROM_UNIXTIME(add_time, \'%Y-%m-%d\') as time');
         $model = $model->where('is_del', 0);
         $model = $model->where('paid', 1);

+ 13 - 0
route/api/route.php

@@ -47,11 +47,24 @@ Route::group(function () {
     Route::post('admin/order/refund', 'admin.StoreOrderController/refund')->name('adminOrderRefund');//订单退款
     Route::post('admin/order/back_deposit', 'admin.StoreOrderController/back_deposit')->name('adminOrderBackDeposit');//退押金
     Route::post('order/order_verific', 'admin.StoreOrderController/order_verific')->name('order');//订单核销
+
+    Route::get('order/stock', 'admin.StoreOrderController/stockList')->name('stock');//商品列表
+    Route::get('order/bill', 'admin.StoreOrderController/billList')->name('bill');//营收
+    Route::post('order/cash', 'admin.StoreOrderController/cash')->name('cash');//提现
+    Route::get('admin/point', 'admin.StoreOrderController/pointList')->name('pointList');//自提点列表
+    Route::get('admin/point/:id', 'admin.StoreOrderController/pointDetail')->name('pointDetail');//自提点详情
+    Route::post('admin/point/:id', 'admin.StoreOrderController/addDetail')->name('addDetail');//添加/修改自提点
+    Route::delete('admin/point/:id', 'admin.StoreOrderController/point_delete')->name('point_delete');//删除/回复自提点
 })->middleware(\app\http\middleware\AllowOriginMiddleware::class)->middleware(\app\http\middleware\AuthTokenMiddleware::class, true)->middleware(\app\http\middleware\CustomerMiddleware::class);
 
 //会员授权接口
 Route::group(function () {
 
+    //门店相关
+    Route::get('my_store', 'user.UserController/getMyStore')->name('my_store');//获取我的门店
+    Route::post('bind_admin', 'user.UserController/bindAdmin')->name('bindAdmin');//绑定后台账号
+
+
     Route::get('logout', 'AuthController/logout')->name('logout');// 退出登录
     Route::post('switch_h5', 'AuthController/switch_h5')->name('switch_h5');// 切换账号
     Route::post('binding', 'AuthController/binding_phone')->name('bindingPhone');// 绑定手机号