Browse Source

一些功能

Kirin 3 năm trước cách đây
mục cha
commit
e128ad678f
33 tập tin đã thay đổi với 4285 bổ sung130 xóa
  1. 6 0
      app/admin/controller/AuthController.php
  2. 307 0
      app/admin/controller/merchant/SystemStore.php
  3. 17 0
      app/admin/controller/order/StoreOrder.php
  4. 12 0
      app/admin/controller/store/StoreProduct.php
  5. 303 7
      app/admin/controller/system/SystemStore.php
  6. 8 0
      app/admin/model/order/StoreOrder.php
  7. 103 89
      app/admin/model/store/StoreProduct.php
  8. 33 2
      app/admin/model/system/SystemStore.php
  9. 254 0
      app/admin/model/system/SystemStoreBill.php
  10. 324 0
      app/admin/model/system/SystemStoreExtract.php
  11. 160 0
      app/admin/model/system/SystemStorePoint.php
  12. 194 0
      app/admin/model/system/SystemStoreProductStock.php
  13. 115 0
      app/admin/model/system/SystemStoreProductStockLog.php
  14. 72 0
      app/admin/view/merchant/system_store/bill.php
  15. 207 0
      app/admin/view/merchant/system_store/children_store.php
  16. 112 0
      app/admin/view/merchant/system_store/index.php
  17. 60 0
      app/admin/view/merchant/system_store/info.php
  18. 874 0
      app/admin/view/merchant/system_store/order.php
  19. 88 0
      app/admin/view/merchant/system_store/write_order.php
  20. 5 3
      app/admin/view/order/store_order/index.php
  21. 9 0
      app/admin/view/system/system_store/add.php
  22. 210 0
      app/admin/view/system/system_store/add_point.php
  23. 58 18
      app/admin/view/system/system_store/index.php
  24. 137 0
      app/admin/view/system/system_store/product_list.php
  25. 60 0
      app/admin/view/system/system_store/stock_log.php
  26. 65 0
      app/admin/view/system/system_store/store_bill_log.php
  27. 185 0
      app/admin/view/system/system_store/store_point.php
  28. 207 0
      app/admin/view/system/system_store/store_product_info.php
  29. 20 0
      app/api/controller/PublicController.php
  30. 3 3
      app/api/controller/order/StoreOrderController.php
  31. 14 7
      app/models/store/StoreOrder.php
  32. 62 1
      app/models/system/SystemStore.php
  33. 1 0
      route/api/route.php

+ 6 - 0
app/admin/controller/AuthController.php

@@ -25,6 +25,7 @@ class AuthController extends SystemBasic
      * @var
      */
     protected $adminId;
+    protected $storeId;
 
     /**
      * 当前管理员权限
@@ -34,6 +35,10 @@ class AuthController extends SystemBasic
 
     protected $skipLogController = ['index', 'common'];
 
+    /**
+     * @var mixed
+     */
+
     protected function initialize()
     {
         parent::initialize();
@@ -45,6 +50,7 @@ class AuthController extends SystemBasic
         }
         $this->adminInfo = $adminInfo;
         $this->adminId = $adminInfo['id'];
+        $this->storeId = $adminInfo['store_id'];
         $this->getActiveAdminInfo();
         $this->auth = SystemAdmin::activeAdminAuthOrFail();
         $this->adminInfo->level === 0 || $this->checkAuth();

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

@@ -0,0 +1,307 @@
+<?php
+
+namespace app\admin\controller\merchant;
+
+use app\admin\controller\AuthController;
+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\ump\StorePink;
+use app\admin\model\user\User;
+use crmeb\repositories\OrderRepository;
+use crmeb\services\FormBuilder;
+use crmeb\services\JsonService;
+use app\admin\model\system\SystemStore as SystemStoreModel;
+use crmeb\services\UtilService;
+use Exception;
+use think\db\exception\DataNotFoundException;
+use think\db\exception\DbException;
+use think\db\exception\ModelNotFoundException;
+use think\facade\Route;
+use think\facade\Session;
+
+/**
+ * 门店后台控制器
+ * Class SystemAttachment
+ * @package app\admin\controller\system
+ *
+ */
+class SystemStore extends AuthController
+{
+
+    private $store_id;
+
+    public function initialize()
+    {
+        parent::initialize(); // TODO: Change the autogenerated stub
+        $this->store_id = Session::get('store_id', 0);
+        if ($this->storeId) $this->store_id = $this->storeId;
+    }
+
+    /**
+     * 门店列表
+     * @throws Exception
+     */
+    public function list()
+    {
+        $where = UtilService::getMore([
+            ['page', 1],
+            ['limit', 20],
+            ['name', ''],
+            ['level', ''],
+            ['excel', 0],
+            ['parent_id', $this->request->param('pid', '')],
+            ['type', $this->request->param('type')]
+        ]);
+        JsonService::successlayui(SystemStoreModel::getStoreList($where));
+    }
+
+    /**
+     * 选择门店
+     * @param string $origin
+     * @return string
+     * @throws Exception
+     */
+    public function index($origin = '')
+    {
+//        var_dump($origin);
+//        Session::delete('store_id');
+        if ($this->storeId) {
+            $this->redirect($origin ?: 'order');
+        }
+        if ($this->request->get('store_id', 0)) {
+            Session::set('store_id', $this->request->get('store_id', 0));
+            $this->redirect($origin ?: 'index');
+        }
+
+        $type = $this->request->param('type');
+        $show = SystemStoreModel::where('is_show', 1)->where('is_del', 0)->count();//显示中的门店
+        $hide = SystemStoreModel::where('is_show', 0)->count();//隐藏的门店
+        $recycle = SystemStoreModel::where('is_del', 1)->count();//删除的门店
+        if ($type == null) $type = 1;
+//        $this->assign('pid', $this->request->get('pid', 0));
+        $this->assign(compact('type', 'show', 'hide', 'recycle'));
+        $this->assign('origin', url($origin ?: 'index'));
+//        $this->assign('level_list', $new);
+        return $this->fetch();
+    }
+
+    /**
+     * @return string
+     * @throws Exception
+     */
+    public function order()
+    {
+//        var_dump($this->storeId);
+        if (!$this->store_id) {
+            $this->redirect(url('index', array('origin' => 'order'))->build());
+        }
+        $this->assign([
+            'year' => get_month(),
+            'store_name' => SystemStoreModel::get($this->store_id)['name'],
+            'real_name' => $this->request->get('real_name', ''),
+            'status' => $this->request->param('status', ''),
+            'orderCount' => StoreOrderModel::orderCount($this->store_id),
+            'payTypeCount' => StoreOrderModel::payTypeCount($this->store_id),
+        ]);
+        $this->assign('store_id', $this->store_id);
+        return $this->fetch();
+    }
+
+    /**
+     * 核销码核销
+     * @param string $verify_code
+     * @param int $is_confirm
+     * @return string
+     * @throws DataNotFoundException
+     * @throws DbException
+     * @throws ModelNotFoundException
+     * @throws Exception
+     */
+    public function write_order($verify_code = '', $is_confirm = 0)
+    {
+
+        if ($this->request->isAjax()) {
+            if (!$this->store_id) {
+                JsonService::fail('未知门店');
+            }
+            if (!$verify_code) JsonService::fail('缺少核销码!');
+            StoreOrderModel::beginTrans();
+            $orderInfo = StoreOrderModel::where('store_id', $this->store_id)->where('verify_code', $verify_code)->where('paid', 1)->where('refund_status', 0)->find();
+            if (!$orderInfo) JsonService::fail('核销订单不存在!');
+            if ($orderInfo->status > 0) JsonService::fail('订单已核销!');
+            if ($orderInfo->combination_id && $orderInfo->pink_id) {
+                $res = StorePink::where('id', $orderInfo->pink_id)->where('status', '<>', 2)->count();
+                if ($res) JsonService::fail('拼团订单暂未成功无法核销!');
+            }
+            if ($is_confirm == 0) {
+                $orderInfo['nickname'] = User::where(['uid' => $orderInfo['uid']])->value('nickname');
+                JsonService::successful($orderInfo);
+            }
+            $orderInfo->status = 2;
+            if ($orderInfo->save()) {
+                OrderRepository::storeProductOrderTakeDeliveryAdmin($orderInfo);
+                StoreOrderStatus::setStatus($orderInfo->id, 'take_delivery', '已核销');
+                //发送短信
+                event('ShortMssageSend', [$orderInfo['order_id'], 'Receiving']);
+                StoreOrderModel::commitTrans();
+                JsonService::successful('核销成功!');
+            } else {
+                StoreOrderModel::rollbackTrans();
+                JsonService::fail('核销失败');
+            }
+        } else {
+            if (!$this->store_id) {
+                $this->redirect(url('index', array('origin' => 'order'))->build());
+            }
+            $this->assign('is_layui', 1);
+            return $this->fetch();
+        }
+    }
+
+
+    /**
+     * 获取订单列表
+     * return json
+     */
+    public function order_list()
+    {
+        if (!$this->store_id) {
+            JsonService::fail('未知门店');
+        }
+        $where = UtilService::getMore([
+            ['status', ''],
+            ['real_name', $this->request->param('real_name', '')],
+            ['is_del', 0],
+            ['data', ''],
+            ['type', ''],
+            ['pay_type', ''],
+            ['order', ''],
+            ['page', 1],
+            ['limit', 20],
+            ['excel', 0]
+        ]);
+        $where['store_id'] = $this->store_id;
+        JsonService::successlayui(StoreOrderModel::OrderList($where));
+    }
+
+    /**
+     *
+     */
+    public function getOrderBadge()
+    {
+        if (!$this->store_id) {
+            JsonService::fail('未知门店');
+        }
+        $where = UtilService::postMore([
+            ['status', ''],
+            ['real_name', ''],
+            ['is_del', 0],
+            ['data', ''],
+            ['type', ''],
+            ['pay_type', ''],
+            ['order', '']
+        ]);
+        $where['store_id'] = $this->store_id;
+        JsonService::successful(StoreOrderModel::getBadge($where));
+    }
+
+
+    /**
+     * @return string
+     * @throws Exception
+     */
+    public function bill()
+    {
+        if (!$this->store_id) {
+            $this->redirect(url('index', array('origin' => 'bill'))->build());
+        }
+        $this->assign('store_info', SystemStoreModel::get($this->store_id));
+        $this->assign('id', $this->store_id);
+        return $this->fetch();
+    }
+
+    public function store_bill_log_list($id)
+    {
+        $where = UtilService::getMore([
+            ['page', 1],
+            ['limit', 20],
+        ]);
+        JsonService::successlayui(SystemStoreBill::getList($where, $id));
+    }
+
+    /**
+     * @return string
+     * @throws Exception
+     */
+    public function cash()
+    {
+        if (!$this->store_id) {
+            $this->redirect(url('index', array('origin' => 'cash'))->build());
+        }
+        $store_info = SystemStoreModel::get($this->store_id);
+        $f = array();
+        $f[] = FormBuilder::radio('extract_type', '提现方式', 'bank')->setOptions([['label' => '银行', 'value' => 'bank'],
+//            ['label' => '支付宝', 'value' => 'alipay'], ['label' => '微信', 'value' => 'weixin']
+        ]);
+        $f[] = FormBuilder::number('money', '提现金额', 0)->col(24)->step(0.01)->min(0)->max($store_info['brokerage_price']);
+        $f[] = FormBuilder::input('name', '姓名', $store_info['leader']);
+        $f[] = FormBuilder::input('bankname', '开户银行', $store_info['bank_name']);
+        $f[] = FormBuilder::input('cardnum', '银行卡号', $store_info['bank_card']);
+//        $f[] = FormBuilder::input('alipay_code', '支付宝账号');
+//        $f[] = FormBuilder::input('weixin', '微信号');
+        $form = FormBuilder::make_post_form('发起提现', $f, Route::buildUrl('cash_save'));
+        $this->assign(compact('form'));
+        return $this->fetch('public/form-builder');
+    }
+
+
+    /**
+     * 提现申请
+     */
+    public function cash_save()
+    {
+        if (!$this->store_id) {
+            JsonService::fail('店铺异常');
+        }
+        $extractInfo = UtilService::postMore([
+            ['alipay_code', ''],
+            ['extract_type', ''],
+            ['money', 0],
+            ['name', ''],
+            ['bankname', ''],
+            ['cardnum', ''],
+            ['weixin', ''],
+        ], $this->request);
+        if (!preg_match('/^(([1-9]\d*)|0)(\.\d{1-2})?$/', $extractInfo['money'])) JsonService::fail('提现金额输入有误');
+        $store = SystemStoreModel::get($this->store_id);
+        if ($extractInfo['money'] > $store['brokerage_price']) JsonService::fail('可提现佣金不足');
+        if (!$extractInfo['cardnum'] == '')
+            if (!preg_match('/^([1-9]{1})(\d{14}|\d{18})$/', $extractInfo['cardnum']))
+                JsonService::fail('银行卡号输入有误');
+        if (SystemStoreExtract::userExtract($store, $extractInfo))
+            JsonService::successful('申请提现成功!');
+        else
+            JsonService::fail(SystemStoreExtract::getErrorInfo('提现失败'));
+    }
+
+    /**
+     * @return string
+     * @throws Exception
+     */
+    public function info()
+    {
+        if (!$this->store_id) {
+            $this->redirect(url('index', array('origin' => 'info'))->build());
+        }
+        $this->assign('store_info', SystemStoreModel::getStoreInfo($this->store_id) ?: []);
+        return $this->fetch();
+    }
+
+
+    //TODO 自提点管理
+
+
+    //TODO 库存管理
+}

+ 17 - 0
app/admin/controller/order/StoreOrder.php

@@ -10,6 +10,7 @@ namespace app\admin\controller\order;
 use app\admin\controller\AuthController;
 use app\admin\model\order\StoreOrderCartInfo;
 use app\admin\model\system\Express;
+use app\admin\model\system\SystemStoreBill;
 use crmeb\repositories\OrderRepository;
 use crmeb\repositories\ShortLetterRepositories;
 use crmeb\services\{
@@ -599,11 +600,27 @@ class StoreOrder extends AuthController
             }
             StoreOrderStatus::setStatus($id, 'refund_price', '退款给用户' . $refund_price . '元');
 
+            SystemStoreBill::where('category', 'brokerage_price')
+                //->where('type', 'brokerage')
+                ->where('link_id', $id)
+                ->where('pm', 1)
+                ->where('status', 0)
+                ->update(['status' => -1]);
+
+
+            UserBill::where('category', 'now_money')
+                ->where('type', 'brokerage')
+                ->where('link_id', $id)
+                ->where('pm', 1)
+                ->where('status', 0)
+                ->update(['status' => -1]);
+
             //退佣金
             $brokerage_list = UserBill::where('category', 'now_money')
                 ->where('type', 'brokerage')
                 ->where('link_id', $id)
                 ->where('pm', 1)
+                ->where('status', 1)
                 ->select();
 
             if ($brokerage_list) {

+ 12 - 0
app/admin/controller/store/StoreProduct.php

@@ -86,6 +86,18 @@ class StoreProduct extends AuthController
         return Json::successlayui(ProductModel::ProductList($where));
     }
 
+    public function product_unique_ist()
+    {
+        $where = Util::getMore([
+            ['page', 1],
+            ['limit', 20],
+            ['store_name', ''],
+            ['cate_id', ''],
+            ['type', $this->request->param('type')]
+        ]);
+        Json::successlayui(ProductModel::ProductUniqueList($where));
+    }
+
     /**
      * 设置单个产品上架|下架
      *

+ 303 - 7
app/admin/controller/system/SystemStore.php

@@ -3,10 +3,20 @@
 namespace app\admin\controller\system;
 
 use app\admin\controller\AuthController;
+use app\admin\model\store\StoreCategory;
+use app\admin\model\system\SystemAdmin;
+use app\admin\model\system\SystemStoreBill;
+use app\admin\model\system\SystemStorePoint;
+use app\admin\model\system\SystemStoreProductStock;
+use app\admin\model\system\SystemStoreProductStockLog;
+use crmeb\services\FormBuilder;
 use crmeb\services\JsonService;
 use crmeb\services\JsonService as Json;
 use app\admin\model\system\SystemStore as SystemStoreModel;
 use crmeb\services\UtilService;
+use think\db\exception\DataNotFoundException;
+use think\db\exception\ModelNotFoundException;
+use think\facade\Route;
 
 /**
  * 门店管理控制器
@@ -29,7 +39,7 @@ class SystemStore extends AuthController
             ['excel', 0],
             ['type', $this->request->param('type')]
         ]);
-        return JsonService::successlayui(SystemStoreModel::getStoreList($where));
+        JsonService::successlayui(SystemStoreModel::getStoreList($where));
     }
 
     /**
@@ -127,12 +137,14 @@ class SystemStore extends AuthController
             ['latlng', ''],
             ['valid_time', []],
             ['day_time', []],
+            ['leader', ''],
+            ['pictures', []],
         ]);
         SystemStoreModel::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])) return JsonService::fail('请选择门店位置');
+            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']);
@@ -142,28 +154,312 @@ class SystemStore extends AuthController
                 $site_url = sys_config('site_url');
                 $data['image'] = $site_url . $data['image'];
             }
+            $new = [];
+            foreach ($data['pictures'] as $v) {
+                $site_url = sys_config('site_url');
+                $new[] = $site_url . $v;
+            }
+            $data['pictures'] = implode(',', $new);
             if ($id) {
                 if (SystemStoreModel::where('id', $id)->update($data)) {
                     SystemStoreModel::commitTrans();
-                    return JsonService::success('修改成功');
+                    JsonService::success('修改成功');
                 } else {
                     SystemStoreModel::rollbackTrans();
-                    return JsonService::fail('修改失败或者您没有修改什么!');
+                    JsonService::fail('修改失败或者您没有修改什么!');
                 }
             } else {
                 $data['add_time'] = time();
                 $data['is_show'] = 1;
                 if ($res = SystemStoreModel::create($data)) {
+                    SystemAdmin::create([
+                        'account' => 'store_admin_' . $res->id,
+                        'pwd' => md5('123456'),
+                        'real_name' => $data['leader'],
+                        'roles' => sys_config('default_store_admin', 1),
+                        'add_time' => time(),
+                        'status' => 1,
+                        'level' => 2,
+                        'store_id' => $res->id,
+                    ]);
                     SystemStoreModel::commitTrans();
-                    return JsonService::success('保存成功', ['id' => $res->id]);
+                    JsonService::success('保存成功', ['id' => $res->id]);
                 } else {
                     SystemStoreModel::rollbackTrans();
-                    return JsonService::fail('保存失败!');
+                    JsonService::fail('保存失败!');
                 }
             }
         } catch (\Exception $e) {
             SystemStoreModel::rollbackTrans();
-            return JsonService::fail($e->getMessage());
+            JsonService::fail($e->getMessage());
+        }
+    }
+
+    /**
+     * @param $id
+     * @return string
+     * @throws Exception
+     */
+    public function storeProductInfo($id)
+    {
+        $this->assign('id', $id);
+        $this->assign('year', get_month());
+        return $this->fetch();
+    }
+
+
+    public function stock_list($id)
+    {
+        $where = UtilService::getMore([
+            ['page', 1],
+            ['data', ''],
+            ['limit', 20],
+            ['product_id', ''],
+            ['excel', 0],
+        ]);
+        JsonService::successlayui(SystemStoreProductStock::getStockList($where, $id));
+    }
+
+
+    public function add_stock($id)
+    {
+        if (!$id) {
+            return $this->failed('请选择门店');
+        }
+        $where = UtilService::getMore([
+            ['product_id', 0],
+            ['unique', ''],
+        ]);
+        if (!$where['product_id'] || !$where['unique']) {
+            $field = [];
+            $field[] = FormBuilder::frameImages('product', '选择商品', Route::buildUrl('productList', array('fodder' => 'product')))->icon('plus')->width('100%')->height('500px');
+            $field[] = FormBuilder::hidden('product_id', '');
+            $field[] = FormBuilder::hidden('unique', '');
+        } else {
+            $field = [];
+            $field[] = FormBuilder::hidden('product_id', $where['product_id']);
+            $field[] = FormBuilder::hidden('unique', $where['unique']);
+        }
+        $field[] = FormBuilder::number('stock', '库存增加量', 0);
+        $form = FormBuilder::make_post_form('添加库存', $field, Route::buildUrl('save_stock', ['id' => $id]), 3);
+        $this->assign(compact('form'));
+        return $this->fetch('public/form-builder');
+    }
+
+    /**
+     * @return string
+     * @throws DataNotFoundException
+     * @throws ModelNotFoundException
+     * @throws Exception
+     */
+    public function productList()
+    {
+        $cate = StoreCategory::getTierList(null, 1);
+        $this->assign('cate', $cate);
+        return $this->fetch();
+    }
+
+    public function save_stock($id)
+    {
+        if (!$id) {
+            Json::fail('请选择门店');
+        }
+        list($product_id, $unique, $stock) = UtilService::postMore([['product_id', []], ['unique', []], ['stock', 0]], $this->request, true);
+        if (!count($product_id)) {
+            Json::fail('请选择补货商品');
+        }
+        $res = true;
+        SystemStoreProductStockLog::beginTrans();
+        foreach ($product_id as $k => $v) {
+            if ($stock > 0) {
+                $res = $res && SystemStoreProductStockLog::income($id, $v, $unique[$k], 'add_stock', 0, $stock, $this->adminId, '后台补货' . $stock . '件', 1);
+            } else {
+                $res = $res && SystemStoreProductStockLog::expend($id, $v, $unique[$k], 'dec_stock', 0, abs($stock), $this->adminId, '后台减货' . $stock . '件', 1);
+            }
+        }
+        if ($res) {
+            SystemStoreProductStockLog::commitTrans();
+            Json::success('补货成功');
+        } else {
+            SystemStoreProductStockLog::rollbackTrans();
+            Json::fail(SystemStoreProductStockLog::getErrorInfo('补货失败'));
+        }
+    }
+
+    /**
+     * @param $id
+     * @return string
+     * @throws Exception
+     */
+    public function stock_log($id)
+    {
+        $this->assign('id', $id);
+        return $this->fetch();
+    }
+
+    public function stock_log_list($id)
+    {
+        $where = UtilService::getMore([
+            ['page', 1],
+            ['limit', 20],
+        ]);
+        JsonService::successlayui(SystemStoreProductStockLog::getList($where, $id));
+    }
+
+    /**
+     * @param $id
+     * @return string
+     * @throws Exception
+     */
+    public function store_bill_log($id)
+    {
+        $this->assign('id', $id);
+        $this->assign('all', SystemStoreModel::get($id)['brokerage_price']);
+        return $this->fetch();
+    }
+
+    public function store_bill_log_list($id)
+    {
+        $where = UtilService::getMore([
+            ['page', 1],
+            ['limit', 20],
+        ]);
+        JsonService::successlayui(SystemStoreBill::getList($where, $id));
+    }
+
+    /**
+     * @param $id
+     * @return string
+     * @throws Exception
+     */
+    public function store_point($id)
+    {
+
+        $type = $this->request->param('type');
+        $show = SystemStorePoint::where('store_id', $id)->where('is_show', 1)->where('is_del', 0)->count();//显示中的门店
+        $hide = SystemStorePoint::where('store_id', $id)->where('is_show', 0)->count();//隐藏的门店
+        $recycle = SystemStorePoint::where('store_id', $id)->where('is_del', 1)->count();//删除的门店
+        if ($type == null) $type = 1;
+        $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));
+    }
+
+    /**
+     * 门店添加
+     * @param int $id
+     * @return string
+     */
+    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 Json::fail(SystemStorePoint::getErrorInfo('恢复失败,请稍候再试!'));
+            else
+                return Json::successful('恢复门店成功!');
+        } else {
+            $data['is_del'] = 1;
+            if (!SystemStorePoint::edit($data, $id))
+                return Json::fail(SystemStorePoint::getErrorInfo('删除失败,请稍候再试!'));
+            else
+                return Json::successful('删除门店成功!');
         }
     }
 }

+ 8 - 0
app/admin/model/order/StoreOrder.php

@@ -7,6 +7,8 @@
 
 namespace app\admin\model\order;
 
+use app\admin\model\system\SystemStore;
+use app\admin\model\system\SystemStorePoint;
 use crmeb\basic\BaseModel;
 use crmeb\traits\ModelTrait;
 use think\facade\Route as Url;
@@ -85,6 +87,9 @@ class StoreOrder extends BaseModel
                 unset($cart_info);
             }
             $item['_info'] = $_info;
+            $item['store'] = SystemStore::where('id', $item['store_id'])->value('name') ?: '--';
+            $item['point'] = SystemStorePoint::where('id', $item['point_id'])->value('name') ?: '--';
+            $item['_info'] = $_info;
             $item['spread_nickname'] = User::where('uid', $item['spread_uid'])->value('nickname');
             $item['add_time'] = $item['add_time'] ? date('Y-m-d H:i:s', $item['add_time']) : '';
             $item['back_integral'] = $item['back_integral'] ?: 0;
@@ -484,6 +489,9 @@ HTML;
         if (isset($where['status']) && $where['status'] != '') {
             $model = self::statusByWhere($where['status'], $model, $aler);
         }
+        if (isset($where['store_id']) && $where['store_id'] != '') {
+            $model = $model->where($aler . 'store_id', $where['store_id']);
+        }
         if (isset($where['is_del']) && $where['is_del'] != '' && $where['is_del'] != -1) $model = $model->where($aler . 'is_del', $where['is_del']);
         if (isset($where['combination_id'])) {
             if ($where['combination_id'] == '普通订单') {

+ 103 - 89
app/admin/model/store/StoreProduct.php

@@ -142,7 +142,7 @@ class StoreProduct extends BaseModel
     protected static function getCateSql($cateid)
     {
         $lcateid = $cateid . ',%';//匹配最前面的cateid
-        $ccatid  = '%,' . $cateid . ',%';//匹配中间的cateid
+        $ccatid = '%,' . $cateid . ',%';//匹配中间的cateid
         $ratidid = '%,' . $cateid;//匹配后面的cateid
         return " `cate_id` LIKE '$lcateid' OR `cate_id` LIKE '$ccatid' OR `cate_id` LIKE '$ratidid' OR `cate_id`=$cateid";
     }
@@ -172,14 +172,14 @@ class StoreProduct extends BaseModel
         if ($where['excel'] == 0) $model = $model->page((int)$where['page'], (int)$where['limit']);
         $data = ($data = $model->select()) && count($data) ? $data->toArray() : [];
         foreach ($data as &$item) {
-            $cateName           = CategoryModel::where('id', 'IN', $item['cate_id'])->column('cate_name', 'id');
-            $item['cate_name']  = is_array($cateName) ? implode(',', $cateName) : '';
-            $item['collect']    = StoreProductRelation::where('product_id', $item['id'])->where('type', 'collect')->count();//收藏
-            $item['like']       = StoreProductRelation::where('product_id', $item['id'])->where('type', 'like')->count();//点赞
-            $item['stock']      = self::getStock($item['id']) > 0 ? self::getStock($item['id']) : $item['stock'];//库存
+            $cateName = CategoryModel::where('id', 'IN', $item['cate_id'])->column('cate_name', 'id');
+            $item['cate_name'] = is_array($cateName) ? implode(',', $cateName) : '';
+            $item['collect'] = StoreProductRelation::where('product_id', $item['id'])->where('type', 'collect')->count();//收藏
+            $item['like'] = StoreProductRelation::where('product_id', $item['id'])->where('type', 'like')->count();//点赞
+            $item['stock'] = self::getStock($item['id']) > 0 ? self::getStock($item['id']) : $item['stock'];//库存
             $item['stock_attr'] = self::getStock($item['id']) > 0 ? true : false;//库存
             $item['sales_attr'] = self::getSales($item['id']);//属性销量
-            $item['visitor']    = StoreVisit::where('product_id', $item['id'])->where('product_type', 'product')->count();
+            $item['visitor'] = StoreVisit::where('product_id', $item['id'])->where('product_type', 'product')->count();
         }
         unset($item);
         if ($where['excel'] == 1) {
@@ -205,23 +205,37 @@ class StoreProduct extends BaseModel
         return compact('count', 'data');
     }
 
+    public static function ProductUniqueList($where)
+    {
+        $ids = self::getModelObject($where)->column('id');
+        $model = StoreProductAttrValue::where('type', 0)->where('product_id', 'in', $ids)->order('product_id', 'desc');
+        $count = $model->count();
+        if (isset($where['page']) && isset($where['limit'])) $model->page((int)$where['page'], (int)$where['limit']);
+        $data = ($data = $model->select()) && count($data) ? $data->toArray() : [];
+        foreach ($data as &$item) {
+            $item['store_name'] = self::get($item['product_id'])['store_name'];
+        }
+        unset($item);
+        return compact('count', 'data');
+    }
+
     public static function getChatrdata($type, $data)
     {
-        $legdata   = ['销量', '数量', '点赞', '收藏'];
-        $model     = self::setWhereType(self::order('un_time asc,id desc'), $type);
-        $list      = self::getModelTime(compact('data'), $model)
+        $legdata = ['销量', '数量', '点赞', '收藏'];
+        $model = self::setWhereType(self::order('un_time asc,id desc'), $type);
+        $list = self::getModelTime(compact('data'), $model)
             ->field('FROM_UNIXTIME(add_time,"%Y-%c-%d") as un_time,count(id) as count,sum(sales) as sales')
             ->group('un_time')
             ->distinct(true)
             ->select()
             ->each(function ($item) use ($data) {
                 $item['collect'] = self::getModelTime(compact('data'), new StoreProductRelation)->where('type', 'collect')->count();
-                $item['like']    = self::getModelTime(compact('data'), new StoreProductRelation)->where('type', 'like')->count();
+                $item['like'] = self::getModelTime(compact('data'), new StoreProductRelation)->where('type', 'like')->count();
             })->toArray();
         $chatrList = [];
-        $datetime  = [];
+        $datetime = [];
         $data_item = [];
-        $itemList  = [0 => [], 1 => [], 2 => [], 3 => []];
+        $itemList = [0 => [], 1 => [], 2 => [], 3 => []];
         foreach ($list as $item) {
             $itemList[0][] = $item['sales'];
             $itemList[1][] = $item['count'];
@@ -233,7 +247,7 @@ class StoreProduct extends BaseModel
             $data_item['name'] = $leg;
             $data_item['type'] = 'line';
             $data_item['data'] = $itemList[$key];
-            $chatrList[]       = $data_item;
+            $chatrList[] = $data_item;
             unset($data_item);
         }
         unset($leg);
@@ -248,13 +262,13 @@ class StoreProduct extends BaseModel
     {
         $replenishment_num = sys_config('replenishment_num');
         $replenishment_num = $replenishment_num > 0 ? $replenishment_num : 20;
-        $sum               = [];
-        $lack              = 0;
+        $sum = [];
+        $lack = 0;
 
         //获取普通产品缺货
-        $stock1    = self::getModelTime($where, new self())->where('stock', '<', $replenishment_num)->column('stock', 'id');
+        $stock1 = self::getModelTime($where, new self())->where('stock', '<', $replenishment_num)->column('stock', 'id');
         $sum_stock = self::where('stock', '<', $replenishment_num)->column('stock', 'id');
-        $stk       = [];
+        $stk = [];
         foreach ($stock1 as $item) {
             $stk[] = $replenishment_num - $item;
         }
@@ -265,9 +279,9 @@ class StoreProduct extends BaseModel
         unset($stk, $sum_stock, $stock1);
 
         //获取砍价缺货产品
-        $stock1    = self::getModelTime($where, new StoreBargain())->where('stock', '<', $replenishment_num)->column('stock', 'id');
+        $stock1 = self::getModelTime($where, new StoreBargain())->where('stock', '<', $replenishment_num)->column('stock', 'id');
         $sum_stock = StoreBargain::where('stock', '<', $replenishment_num)->column('stock', 'id');
-        $stk       = [];
+        $stk = [];
         foreach ($stock1 as $item) {
             $stk[] = $replenishment_num - $item;
         }
@@ -278,9 +292,9 @@ class StoreProduct extends BaseModel
         unset($stk, $sum_stock, $stock1);
 
         //获取拼团缺货产品
-        $stock1    = self::getModelTime($where, new StoreCombination())->where('stock', '<', $replenishment_num)->column('stock', 'id');
+        $stock1 = self::getModelTime($where, new StoreCombination())->where('stock', '<', $replenishment_num)->column('stock', 'id');
         $sum_stock = StoreCombination::where('stock', '<', $replenishment_num)->column('stock', 'id');
-        $stk       = [];
+        $stk = [];
         foreach ($stock1 as $item) {
             $stk[] = $replenishment_num - $item;
         }
@@ -292,40 +306,40 @@ class StoreProduct extends BaseModel
 
         return [
             [
-                'name'             => '商品种类',
-                'field'            => '件',
-                'count'            => self::setWhereType(new self(), $type)->where('add_time', '<', mktime(0, 0, 0, date('m'), date('d'), date('Y')))->count(),
-                'content'          => '商品数量总数',
+                'name' => '商品种类',
+                'field' => '件',
+                'count' => self::setWhereType(new self(), $type)->where('add_time', '<', mktime(0, 0, 0, date('m'), date('d'), date('Y')))->count(),
+                'content' => '商品数量总数',
                 'background_color' => 'layui-bg-blue',
-                'sum'              => self::count(),
-                'class'            => 'fa fa fa-ioxhost',
+                'sum' => self::count(),
+                'class' => 'fa fa fa-ioxhost',
             ],
             [
-                'name'             => '商品总数',
-                'field'            => '件',
-                'count'            => self::setWhereType(self::getModelTime($where, new self), $type)->sum('stock'),
-                'content'          => '商品总数',
+                'name' => '商品总数',
+                'field' => '件',
+                'count' => self::setWhereType(self::getModelTime($where, new self), $type)->sum('stock'),
+                'content' => '商品总数',
                 'background_color' => 'layui-bg-cyan',
-                'sum'              => self::where('is_new', 1)->sum('stock'),
-                'class'            => 'fa fa-line-chart',
+                'sum' => self::where('is_new', 1)->sum('stock'),
+                'class' => 'fa fa-line-chart',
             ],
             [
-                'name'             => '活动商品',
-                'field'            => '件',
-                'count'            => self::getActivityProductSum($where),
-                'content'          => '活动商品总数',
+                'name' => '活动商品',
+                'field' => '件',
+                'count' => self::getActivityProductSum($where),
+                'content' => '活动商品总数',
                 'background_color' => 'layui-bg-green',
-                'sum'              => self::getActivityProductSum(),
-                'class'            => 'fa fa-bar-chart',
+                'sum' => self::getActivityProductSum(),
+                'class' => 'fa fa-bar-chart',
             ],
             [
-                'name'             => '缺货商品',
-                'field'            => '件',
-                'count'            => $lack,
-                'content'          => '总商品数量',
+                'name' => '缺货商品',
+                'field' => '件',
+                'count' => $lack,
+                'content' => '总商品数量',
                 'background_color' => 'layui-bg-orange',
-                'sum'              => array_sum($sum),
-                'class'            => 'fa fa-cube',
+                'sum' => array_sum($sum),
+                'class' => 'fa fa-cube',
             ],
         ];
     }
@@ -338,11 +352,11 @@ class StoreProduct extends BaseModel
     {
         if ($where) {
             $bargain = self::getModelTime($where, new StoreBargain())->sum('stock');
-            $pink    = self::getModelTime($where, new StoreCombination())->sum('stock');
+            $pink = self::getModelTime($where, new StoreCombination())->sum('stock');
             $seckill = self::getModelTime($where, new StoreSeckill())->sum('stock');
         } else {
             $bargain = StoreBargain::sum('stock');
-            $pink    = StoreCombination::sum('stock');
+            $pink = StoreCombination::sum('stock');
             $seckill = StoreSeckill::sum('stock');
         }
         return bcadd(bcadd($bargain, $pink, 0), $seckill, 0);
@@ -381,15 +395,15 @@ class StoreProduct extends BaseModel
     public static function getMaxList($where)
     {
         $classs = ['layui-bg-red', 'layui-bg-orange', 'layui-bg-green', 'layui-bg-blue', 'layui-bg-cyan'];
-        $model  = StoreOrder::alias('a')->join('StoreOrderCartInfo c', 'a.id=c.oid')->join('store_product b', 'b.id=c.product_id');
-        $list   = self::getModelTime($where, $model, 'a.add_time')
+        $model = StoreOrder::alias('a')->join('StoreOrderCartInfo c', 'a.id=c.oid')->join('store_product b', 'b.id=c.product_id');
+        $list = self::getModelTime($where, $model, 'a.add_time')
             ->group('c.product_id')
             ->order('p_count desc')
             ->limit(10)
             ->field(['count(c.product_id) as p_count', 'b.store_name', 'sum(b.price) as sum_price'])
             ->select();
         if (count($list)) $list = $list->toArray();
-        $maxList   = [];
+        $maxList = [];
         $sum_count = 0;
         $sum_price = 0;
         foreach ($list as $item) {
@@ -398,13 +412,13 @@ class StoreProduct extends BaseModel
         }
         unset($item);
         foreach ($list as $key => &$item) {
-            $item['w']          = bcdiv($item['p_count'], $sum_count, 2) * 100;
-            $item['class']      = isset($classs[$key]) ? $classs[$key] : (isset($classs[$key - count($classs)]) ? $classs[$key - count($classs)] : '');
+            $item['w'] = bcdiv($item['p_count'], $sum_count, 2) * 100;
+            $item['class'] = isset($classs[$key]) ? $classs[$key] : (isset($classs[$key - count($classs)]) ? $classs[$key - count($classs)] : '');
             $item['store_name'] = self::getSubstrUTf8($item['store_name']);
         }
         $maxList['sum_count'] = $sum_count;
         $maxList['sum_price'] = $sum_price;
-        $maxList['list']      = $list;
+        $maxList['list'] = $list;
         return $maxList;
     }
 
@@ -412,7 +426,7 @@ class StoreProduct extends BaseModel
     public static function ProfityTop10($where)
     {
         $classs = ['layui-bg-red', 'layui-bg-orange', 'layui-bg-green', 'layui-bg-blue', 'layui-bg-cyan'];
-        $model  = StoreOrder::alias('a')
+        $model = StoreOrder::alias('a')
             ->join('StoreOrderCartInfo c', 'a.id=c.oid')
             ->join('store_product b', 'b.id=c.product_id')
             ->where('b.is_show', 1)
@@ -424,7 +438,7 @@ class StoreProduct extends BaseModel
             ->field(['count(c.product_id) as p_count', 'b.store_name', 'sum(b.price) as sum_price', '(b.price-b.cost) as profity'])
             ->select();
         if (count($list)) $list = $list->toArray();
-        $maxList   = [];
+        $maxList = [];
         $sum_count = 0;
         $sum_price = 0;
         foreach ($list as $item) {
@@ -432,13 +446,13 @@ class StoreProduct extends BaseModel
             $sum_price = bcadd($sum_price, $item['sum_price'], 2);
         }
         foreach ($list as $key => &$item) {
-            $item['w']          = bcdiv($item['sum_price'], $sum_price, 2) * 100;
-            $item['class']      = isset($classs[$key]) ? $classs[$key] : (isset($classs[$key - count($classs)]) ? $classs[$key - count($classs)] : '');
+            $item['w'] = bcdiv($item['sum_price'], $sum_price, 2) * 100;
+            $item['class'] = isset($classs[$key]) ? $classs[$key] : (isset($classs[$key - count($classs)]) ? $classs[$key - count($classs)] : '');
             $item['store_name'] = self::getSubstrUTf8($item['store_name'], 30);
         }
         $maxList['sum_count'] = $sum_count;
         $maxList['sum_price'] = $sum_price;
-        $maxList['list']      = $list;
+        $maxList['list'] = $list;
         return $maxList;
     }
 
@@ -447,7 +461,7 @@ class StoreProduct extends BaseModel
     {
         $replenishment_num = sys_config('replenishment_num');
         $replenishment_num = $replenishment_num > 0 ? $replenishment_num : 20;
-        $list              = self::where('stock', '<', $replenishment_num)->field(['id', 'store_name', 'stock', 'price'])->page((int)$where['page'], (int)$where['limit'])->order('stock asc')->select();
+        $list = self::where('stock', '<', $replenishment_num)->field(['id', 'store_name', 'stock', 'price'])->page((int)$where['page'], (int)$where['limit'])->order('stock asc')->select();
         if (count($list)) $list = $list->toArray();
         $count = self::where('stock', '<', $replenishment_num)->count();
         return ['count' => $count, 'data' => $list];
@@ -480,7 +494,7 @@ class StoreProduct extends BaseModel
         if (count($perd)) $perd = $perd->toArray();
         foreach ($perd as &$item) {
             $item['store_name'] = self::where(['id' => $item['id']])->value('store_name');
-            $item['price']      = self::where(['id' => $item['id']])->value('price');
+            $item['price'] = self::where(['id' => $item['id']])->value('price');
         }
         return $perd;
     }
@@ -536,7 +550,7 @@ class StoreProduct extends BaseModel
      */
     public static function getSaleslists($where)
     {
-        $data  = self::setWhere($where)
+        $data = self::setWhere($where)
             ->where('a.is_pay', 1)
             ->group('a.product_id')
             ->field(['sum(a.cart_num) * b.price as sum_price', 'sum(a.cart_num) as num_product', 'b.store_name',
@@ -549,13 +563,13 @@ class StoreProduct extends BaseModel
             ->page((int)$where['page'], (int)$where['limit'])
             ->select();
         $count = self::setWhere($where)->where('a.is_pay', 1)->group('a.product_id')->count();
-        $data  = count($data) ? $data->toArray() : [];
+        $data = count($data) ? $data->toArray() : [];
         return compact('data', 'count');
     }
 
     public static function SaveProductExport($where)
     {
-        $list   = self::setWhere($where)
+        $list = self::setWhere($where)
             ->where('a.is_pay', 1)
             ->field(['sum(a.cart_num) as num_product', 'b.store_name', 'b.image', 'b.price', 'b.id'])
             ->order('num_product desc')
@@ -585,7 +599,7 @@ class StoreProduct extends BaseModel
     public static function getProductBadgeList($id, $where)
     {
         $data['data'] = $where;
-        $list         = self::setWhere($data)
+        $list = self::setWhere($data)
             ->field(['sum(a.cart_num) as num_product', 'b.id', 'b.price'])
             ->where('a.is_pay', 1)
             ->group('a.product_id')
@@ -599,12 +613,12 @@ class StoreProduct extends BaseModel
         $list_price = [];
         foreach ($list as $key => $item) {
             if ($item['id'] == $id) {
-                $ranking   = $key + 1;
+                $ranking = $key + 1;
                 $xiaoliang = $item['num_product'];
             }
             $value['sum_price'] = $item['price'] * $item['num_product'];
-            $value['id']        = $item['id'];
-            $list_price[]       = $value;
+            $value['id'] = $item['id'];
+            $list_price[] = $value;
         }
         //排序
         $list_price = self::my_sort($list_price, 'sum_price', SORT_DESC);
@@ -615,7 +629,7 @@ class StoreProduct extends BaseModel
         if ($list_price !== false && is_array($list_price)) {
             foreach ($list_price as $key => $item) {
                 if ($item['id'] == $id) {
-                    $num_price  = $item['sum_price'];
+                    $num_price = $item['sum_price'];
                     $rank_price = $key + 1;
                     continue;
                 }
@@ -623,35 +637,35 @@ class StoreProduct extends BaseModel
         }
         return [
             [
-                'name'             => '销售额排名',
-                'field'            => '名',
-                'count'            => $rank_price,
+                'name' => '销售额排名',
+                'field' => '名',
+                'count' => $rank_price,
                 'background_color' => 'layui-bg-blue',
             ],
             [
-                'name'             => '销量排名',
-                'field'            => '名',
-                'count'            => $ranking,
+                'name' => '销量排名',
+                'field' => '名',
+                'count' => $ranking,
                 'background_color' => 'layui-bg-blue',
             ],
             [
-                'name'             => '商品销量',
-                'field'            => '名',
-                'count'            => $xiaoliang,
+                'name' => '商品销量',
+                'field' => '名',
+                'count' => $xiaoliang,
                 'background_color' => 'layui-bg-blue',
             ],
             [
-                'name'             => '点赞次数',
-                'field'            => '个',
-                'count'            => StoreProductRelation::where('product_id', $id)->where('type', 'like')->count(),
+                'name' => '点赞次数',
+                'field' => '个',
+                'count' => StoreProductRelation::where('product_id', $id)->where('type', 'like')->count(),
                 'background_color' => 'layui-bg-blue',
             ],
             [
-                'name'             => '销售总额',
-                'field'            => '元',
-                'count'            => $num_price,
+                'name' => '销售总额',
+                'field' => '元',
+                'count' => $num_price,
                 'background_color' => 'layui-bg-blue',
-                'col'              => 12,
+                'col' => 12,
             ],
         ];
     }
@@ -687,7 +701,7 @@ class StoreProduct extends BaseModel
      */
     public static function getProductCurve($where)
     {
-        $list       = self::setWhere($where)
+        $list = self::setWhere($where)
             ->where('a.product_id', $where['id'])
             ->where('a.is_pay', 1)
             ->field(['FROM_UNIXTIME(a.add_time,"%Y-%m-%d") as _add_time', 'sum(a.cart_num) as num'])
@@ -695,10 +709,10 @@ class StoreProduct extends BaseModel
             ->order('_add_time asc')
             ->select();
         $seriesdata = [];
-        $date       = [];
-        $zoom       = '';
+        $date = [];
+        $zoom = '';
         foreach ($list as $item) {
-            $date[]       = $item['_add_time'];
+            $date[] = $item['_add_time'];
             $seriesdata[] = $item['num'];
         }
         if (count($date) > $where['limit']) $zoom = $date[$where['limit'] - 5];

+ 33 - 2
app/admin/model/system/SystemStore.php

@@ -3,6 +3,7 @@
 
 namespace app\admin\model\system;
 
+use app\admin\model\order\StoreOrder;
 use crmeb\traits\ModelTrait;
 use crmeb\basic\BaseModel;
 use crmeb\services\PHPExcelService;
@@ -59,6 +60,7 @@ class SystemStore extends BaseModel
             $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['pictures'] = $storeInfo['pictures'] ? explode(',', $storeInfo['pictures']) : [];
         } else {
             $storeInfo['latlng'] = [];
             $storeInfo['valid_time'] = [];
@@ -88,7 +90,18 @@ class SystemStore extends BaseModel
             $model = $model->where($data);
         }
         $count = $model->count();
-        $data = $model->page((int)$where['page'], (int)$where['limit'])->select();
+        $data = $model->page((int)$where['page'], (int)$where['limit'])->select()->each(function ($item) {
+            $item['deposit'] = StoreOrder::where('store_id', $item['id'])
+                ->where('paid', 1)
+                ->where('is_del', 0)
+                ->where('is_system_del', 0)
+                ->where('refund_status', 0)->sum('deposit');
+            $item['deposit_back'] = StoreOrder::where('store_id', $item['id'])
+                ->where('paid', 1)
+                ->where('is_del', 0)
+                ->where('is_system_del', 0)
+                ->where('refund_status', 0)->sum('deposit_back');
+        });
         if ($where['excel'] == 1) {
             $export = [];
             foreach ($data as $index => $item) {
@@ -96,12 +109,14 @@ class SystemStore extends BaseModel
                     $item['name'],
                     $item['phone'],
                     $item['address'] .= ' ' . $item['detailed_address'],
+                    $item['deposit'],
+                    $item['deposit_back'],
                     $item['introduction'],
                     $item['day_time'],
                     $item['valid_time']
                 ];
             }
-            PHPExcelService::setExcelHeader(['门店名称', '门店电话', '门店地址', '门店简介', '营业时间', '核销日期'])
+            PHPExcelService::setExcelHeader(['门店名称', '门店电话', '门店地址', '总押金', '已退押金', '门店简介', '营业时间', '核销日期'])
                 ->setExcelTile('门店导出', '门店信息' . time(), ' 生成时间:' . date('Y-m-d H:i:s', time()))
                 ->setExcelContent($export)
                 ->ExcelSave();
@@ -138,4 +153,20 @@ class SystemStore extends BaseModel
             ->toArray();
         return $list;
     }
+
+    //获取某用户的详细信息
+    public static function getStoreInfo($uid)
+    {
+        $item = self::get($uid);
+        $Address = '';
+        return [
+            ['image' => false, 'col' => 12, 'name' => '门店名称', 'value' => $item['name'] ?: ''],
+            ['image' => true, 'col' => 12, 'name' => 'LOGO', 'value' => $item['image'] ?: ''],
+            ['image' => false, 'col' => 12, 'name' => '门店地址', 'value' => $item['address'] ?: '' . ' ' . ($item['detailed_address' ?: ''])],
+            ['image' => false, 'name' => '门店坐标', 'value' => '[' . ($item['latitude'] ?: 0) . ',' . ($item['longitude'] ?: 0) . ']'],
+            ['image' => false, 'name' => '营业时间', 'value' => $item['day_time'] ?: ''],
+            ['image' => false, 'name' => '门店佣金', 'value' => $item['brokerage_price'] ?: 0],
+            ['image' => false, 'col' => 12, 'name' => '简介', 'value' => $item['introduction'] ?: ''],
+        ];
+    }
 }

+ 254 - 0
app/admin/model/system/SystemStoreBill.php

@@ -0,0 +1,254 @@
+<?php
+
+namespace app\admin\model\system;
+
+use crmeb\traits\ModelTrait;
+use crmeb\basic\BaseModel;
+use think\facade\Db;
+
+/**
+ * 店铺消费新增金额明细 model
+ * Class User
+ * @package app\admin\model\user
+ */
+class SystemStoreBill extends BaseModel
+{
+    /**
+     * 数据表主键
+     * @var string
+     */
+    protected $pk = 'id';
+
+    /**
+     * 模型名称
+     * @var string
+     */
+    protected $name = 'system_store_bill';
+
+    use ModelTrait;
+
+    /*
+     * 获取总佣金
+     * */
+    public static function getBrokerage($uid, $category = 'brokerage_price', $type = '', $where = [])
+    {
+        $model = self::where('store_id', 'in', $uid)->where('category', $category)
+            ->where('pm', 1)->where('status', 1);
+        if ($type) $model = $model->where('type', $type);
+        return self::getModelTime($where, $model)->sum('number');
+    }
+
+    //修改积分减少积分记录
+    public static function expend($title, $store_id, $category, $type, $number, $link_id = 0, $balance = 0, $mark = '', $status = 1)
+    {
+        $pm = 0;
+        $add_time = time();
+        return self::create(compact('title', 'store_id', 'link_id', 'category', 'type', 'number', 'balance', 'mark', 'status', 'pm', 'add_time'));
+    }
+
+    //修改积分增加积分记录
+    public static function income($title, $store_id, $category, $type, $number, $link_id = 0, $balance = 0, $mark = '', $status = 1)
+    {
+        $pm = 1;
+        $add_time = time();
+        return self::create(compact('title', 'store_id', 'link_id', 'category', 'type', 'number', 'balance', 'mark', 'status', 'pm', 'add_time'));
+    }
+
+    public static function getList($where, $store_id)
+    {
+        $model = self::where('store_id', $store_id);
+        if (isset($where['time']) && $where['time'] != '') {
+            $start_time = strtotime($where['time']);
+            $end_time = strtotime('+1month', strtotime($where['time']));
+            $model = $model->where('add_time', 'between', [$start_time, $end_time]);
+        }
+        if (isset($where['type']) && $where['type'] != '') {
+            $model = $model->where('type', $where['type']);
+        }
+        $count = $model->count();
+        $data = $model->order('add_time', 'desc')->page((int)$where['page'], (int)$where['limit'])->select()->each(function ($item) {
+            $item['_add_time'] = date('Y-m-d H:i:s', $item['add_time']);
+            $item['_status'] = ($item['status'] == 1 ? '已结算' : ($item['status'] == 2 ? '已失效' : '待结算'));
+        });
+        return compact('count', 'data');
+    }
+
+
+    //获取柱状图和饼状图数据
+    public static function getUserBillChart($where, $category = 'now_money', $type = 'brokerage', $pm = 1, $zoom = 15)
+    {
+        $model = self::getModelTime($where, new self());
+        $list = $model->field('FROM_UNIXTIME(add_time,"%Y-%c-%d") as un_time,sum(number) as sum_number')
+            ->order('un_time asc')
+            ->where('category', $category)
+            ->where('type', $type)
+            ->where('pm', $pm)
+            ->group('un_time')
+            ->select();
+        if (count($list)) $list = $list->toArray();
+        $legdata = [];
+        $listdata = [];
+        $dataZoom = '';
+        foreach ($list as $item) {
+            $legdata[] = $item['un_time'];
+            $listdata[] = $item['sum_number'];
+        }
+        if (count($legdata) >= $zoom) $dataZoom = $legdata[$zoom - 1];
+        //获取用户分布钱数
+        $fenbulist = self::getModelTime($where, new self(), 'a.add_time')
+            ->alias('a')
+            ->join('system_store r', 'a.store_id=r.id')
+            ->field('a.store_id,sum(a.number) as sum_number,r.name')
+            ->where('a.category', $category)
+            ->where('a.type', $type)
+            ->where('a.pm', $pm)
+            ->order('sum_number desc')
+            ->group('a.store_id')
+            ->limit(8)
+            ->select();
+        //获取用户当前时间段总钱数
+        $sum_number = self::getModelTime($where, new self())
+            ->alias('a')
+            ->where('a.category', $category)
+            ->where('a.type', $type)
+            ->where('a.pm', $pm)
+            ->sum('number');
+        if (count($fenbulist)) $fenbulist = $fenbulist->toArray();
+        $fenbudate = [];
+        $fenbu_legend = [];
+        $color = ['#ffcccc', '#99cc00', '#fd99cc', '#669966', '#66CDAA', '#ADFF2F', '#00BFFF', '#00CED1', '#66cccc', '#ff9900', '#ffcc00', '#336699', '#cccc00', '#99ccff', '#990066'];
+        foreach ($fenbulist as $key => $value) {
+            $fenbu_legend[] = $value['nickname'];
+            $items['name'] = $value['nickname'];
+            $items['value'] = bcdiv($value['sum_number'], $sum_number, 2) * 100;
+            $items['itemStyle']['color'] = $color[$key];
+            $fenbudate[] = $items;
+        }
+        return compact('legdata', 'listdata', 'fenbudate', 'fenbu_legend', 'dataZoom');
+    }
+
+    //获取头部信息
+    public static function getRebateBadge($where)
+    {
+        $datawhere = ['category' => 'now_money', 'type' => 'brokerage', 'pm' => 1];
+        return [
+            [
+                'name' => '返利数(笔)',
+                'field' => '个',
+                'count' => self::getModelTime($where, new self())->where($datawhere)->count(),
+                'content' => '返利总笔数',
+                'background_color' => 'layui-bg-blue',
+                'sum' => self::where($datawhere)->count(),
+                'class' => 'fa fa-bar-chart',
+            ],
+            [
+                'name' => '返利金额(元)',
+                'field' => '个',
+                'count' => self::getModelTime($where, new self())->where($datawhere)->sum('number'),
+                'content' => '返利总金额',
+                'background_color' => 'layui-bg-cyan',
+                'sum' => self::where($datawhere)->sum('number'),
+                'class' => 'fa fa-line-chart',
+            ],
+        ];
+    }
+
+    //获取返佣用户信息列表
+    public static function getFanList($where)
+    {
+        $list = self::alias('a')->join('system_store r', 'a.store_id=r.id')
+            ->where('a.category', 'now_money')
+            ->where('a.type', 'brokerage')
+            ->where('a.pm', 1)
+            ->order('a.number desc')
+            ->join('store_order o', 'o.id=a.link_id')
+            ->field('o.order_id,FROM_UNIXTIME(a.add_time,"%Y-%c-%d") as add_time,a.store_id,o.uid as down_uid,r.name,r.image,a.number')
+            ->page((int)$where['page'], (int)$where['limit'])
+            ->select();
+        if (count($list)) $list = $list->toArray();
+        return $list;
+    }
+
+    //获取返佣用户总人数
+    public static function getFanCount()
+    {
+        return self::alias('a')->join('system_store r', 'a.store_id=r.id')->join('store_order o', 'o.id=a.link_id')->where('a.category', 'now_money')->where('a.type', 'brokerage')->where('a.pm', 1)->count();
+    }
+
+    //获取佣金提现列表
+    public static function getExtrctOneList($where, $uid)
+    {
+        $list = self::setOneWhere($where, $uid)
+            ->field('number,link_id,mark,FROM_UNIXTIME(add_time,"%Y-%m-%d %H:%i:%s") as _add_time,status')
+            ->select();
+        count($list) && $list = $list->toArray();
+        $count = self::setOneWhere($where, $uid)->count();
+        foreach ($list as &$value) {
+            $value['order_id'] = Db::name('store_order')->where('order_id', $value['link_id'])->value('order_id');
+        }
+        return ['data' => $list, 'count' => $count];
+    }
+
+    //设置单个用户查询
+    public static function setOneWhere($where, $uid)
+    {
+        $model = self::where('store_id', $uid)->where('category', 'now_money')->where('type', 'brokerage');
+        $time['data'] = '';
+        if (strlen(trim($where['start_time'])) && strlen(trim($where['end_time']))) {
+            $time['data'] = $where['start_time'] . ' - ' . $where['end_time'];
+            $model = self::getModelTime($time, $model);
+        }
+        if (strlen(trim($where['nickname']))) {
+            $model = $model->where('link_id|mark', 'like', "%$where[nickname]%");
+        }
+        return $model;
+    }
+
+    //查询个人余额变动记录
+    public static function getOneBalanceChangList($where)
+    {
+        $list = self::setWhereList(
+            $where, '',
+//            ['system_add','pay_product','extract','pay_product_refund','system_sub','brokerage','recharge','user_recharge_refund'],
+            ['FROM_UNIXTIME(add_time,"%Y-%m-%d") as add_time', 'title', 'type', 'mark', 'number', 'balance', 'pm', 'status'],
+            'now_money'
+        );
+        foreach ($list as &$item) {
+            switch ($item['type']) {
+                case 'extract':
+                    $item['_type'] = '提现';
+                    break;
+                case 'brokerage':
+                    $item['_type'] = '系统返佣';
+                    break;
+            }
+            $item['_pm'] = $item['pm'] == 1 ? '获得' : '支出';
+        }
+        return $list;
+    }
+
+    //设置where条件分页.返回数据
+    public static function setWhereList($where, $type = '', $field = [], $category = 'integral')
+    {
+        $models = self::where('store_id', $where['store_id'])
+            ->where('category', $category)
+            ->page((int)$where['page'], (int)$where['limit'])
+            ->order('id', 'desc')
+            ->field($field);
+        if (is_array($type)) {
+            $models = $models->where('type', 'in', $type);
+        } else {
+            if (!empty($type)) $models = $models->where('type', $type);
+        }
+        return ($list = $models->select()) && count($list) ? $list->toArray() : [];
+    }
+
+    /**
+     * 用户获得总佣金
+     * @return float
+     */
+    public static function getBrokerageCount()
+    {
+        return self::where('type', 'brokerage')->where('category', 'now_money')->where('status', 1)->where('pm', 1)->sum('number');
+    }
+}

+ 324 - 0
app/admin/model/system/SystemStoreExtract.php

@@ -0,0 +1,324 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: lianghuan
+ * Date: 2018-03-03
+ * Time: 16:47
+ */
+
+namespace app\admin\model\system;
+
+use app\admin\model\wechat\WechatUser;
+use app\models\routine\RoutineTemplate;
+use think\facade\Route as Url;
+use crmeb\traits\ModelTrait;
+use crmeb\basic\BaseModel;
+use crmeb\services\WechatTemplateService;
+
+/**
+ * 门店提现管理 model
+ * Class User
+ * @package app\admin\model\user
+ */
+class SystemStoreExtract extends BaseModel
+{
+    /**
+     * 数据表主键
+     * @var string
+     */
+    protected $pk = 'id';
+
+    /**
+     * 模型名称
+     * @var string
+     */
+    protected $name = 'system_store_extract';
+
+    protected static $extractType = ['alipay', 'bank', 'weixin'];
+
+    use ModelTrait;
+
+    /**
+     * 获得用户提现总金额
+     * @param $uid
+     * @return mixed
+     */
+    public static function userExtractTotalPrice($uid, $status = 1, $where = [])
+    {
+        return self::getModelTime($where, self::where('store_id', 'in', $uid)->where('status', $status))->sum('extract_price') ?: 0;
+    }
+
+    public static function extractStatistics()
+    {
+        //待提现金额
+        $data['price'] = floatval(self::where('status', 0)->sum('extract_price'));
+        //佣金总金额
+        $data['brokerage_count'] = floatval(SystemStoreBill::getBrokerageCount());
+        //已提现金额
+        $data['priced'] = floatval(self::where('status', 1)->sum('extract_price'));
+        //未提现金额
+        $data['brokerage_not'] = bcsub(bcsub($data['brokerage_count'], $data['priced'], 2), $data['price'], 2);
+        return compact('data');
+    }
+
+    /**
+     * @param $where
+     * @return array
+     */
+    public static function systemPage($where)
+    {
+        $model = new self;
+        if ($where['date'] != '') {
+            list($startTime, $endTime) = explode(' - ', $where['date']);
+            $model = $model->where('a.add_time', '>', strtotime($startTime));
+            $model = $model->where('a.add_time', '<', (int)bcadd(strtotime($endTime), 86400, 0));
+        }
+        if ($where['status'] != '') $model = $model->where('a.status', $where['status']);
+        if ($where['extract_type'] != '') $model = $model->where('a.extract_type', $where['extract_type']);
+        if ($where['nireid'] != '') $model = $model->where('a.real_name|a.id|b.name|a.bank_code|a.alipay_code', 'like', "%$where[nireid]%");
+        $model = $model->alias('a');
+        $model = $model->field('a.*,b.name');
+        $model = $model->join('system_store b', 'b.id=a.store_id', 'LEFT');
+        $model = $model->order('a.id desc');
+        return self::page($model, $where);
+    }
+
+    public static function changeFail($id, $fail_msg)
+    {
+        $fail_time = time();
+        $data = self::get($id);
+        $extract_number = $data['extract_price'];
+        $mark = '提现失败,退回佣金' . $extract_number . '元';
+        $uid = $data['store_id'];
+        $status = -1;
+        $User = SystemStore::where('id', $uid)->find()->toArray();
+        SystemStoreBill::income('提现失败', $uid, 'brokerage_price', 'extract', $extract_number, $id, bcadd($User['brokerage_price'], $extract_number, 2), $mark);
+        SystemStore::bcInc($uid, 'brokerage_price', $extract_number, 'id');
+        return self::edit(compact('fail_time', 'fail_msg', 'status'), $id);
+    }
+
+    public static function changeSuccess($id)
+    {
+        return self::edit(['status' => 1], $id);
+    }
+
+
+    public static function userExtract($userInfo, $data)
+    {
+        if (!in_array($data['extract_type'], self::$extractType))
+            return self::setErrorInfo('提现方式不存在');
+        $userInfo = SystemStore::get($userInfo['id']);
+        $extractPrice = $userInfo['brokerage_price'];
+        if ($extractPrice < 0) return self::setErrorInfo('提现佣金不足' . $data['money']);
+        if ($data['money'] > $extractPrice) return self::setErrorInfo('提现佣金不足' . $data['money']);
+        if ($data['money'] <= 0) return self::setErrorInfo('提现佣金大于0');
+        $balance = bcsub($userInfo['brokerage_price'], $data['money'], 2);
+        if ($balance < 0) $balance = 0;
+        $insertData = [
+            'store_id' => $userInfo['id'],
+            'extract_type' => $data['extract_type'],
+            'extract_price' => $data['money'],
+            'add_time' => time(),
+            'balance' => $balance,
+            'status' => 0
+        ];
+        if (isset($data['name']) && strlen(trim($data['name']))) $insertData['real_name'] = $data['name'];
+        else $insertData['real_name'] = $userInfo['name'];
+        if (isset($data['cardnum'])) $insertData['bank_code'] = $data['cardnum'];
+        else $insertData['bank_code'] = '';
+        if (isset($data['bankname'])) $insertData['bank_address'] = $data['bankname'];
+        else $insertData['bank_address'] = '';
+        if (isset($data['weixin'])) $insertData['wechat'] = $data['weixin'];
+        else $insertData['wechat'] = $userInfo['name'];
+        if ($data['extract_type'] == 'alipay') {
+            if (!$data['alipay_code']) return self::setErrorInfo('请输入支付宝账号');
+            $insertData['alipay_code'] = $data['alipay_code'];
+            $mark = '使用支付宝提现' . $insertData['extract_price'] . '元';
+        } else if ($data['extract_type'] == 'bank') {
+            if (!$data['cardnum']) return self::setErrorInfo('请输入银行卡账号');
+            if (!$data['bankname']) return self::setErrorInfo('请输入开户行信息');
+            $mark = '使用银联卡' . $insertData['bank_code'] . '提现' . $insertData['extract_price'] . '元';
+        } else if ($data['extract_type'] == 'weixin') {
+            if (!$data['weixin']) return self::setErrorInfo('请输入微信账号');
+            $mark = '使用微信提现' . $insertData['extract_price'] . '元';
+        }
+        self::beginTrans();
+        try {
+            $res1 = self::create($insertData);
+            if (!$res1) return self::setErrorInfo('提现失败');
+            $res2 = SystemStore::edit(['brokerage_price' => $balance], $userInfo['id'], 'id');
+            $res3 = SystemStoreBill::expend('佣金提现', $userInfo['id'], 'brokerage_price', 'extract', $data['money'], $res1['id'], $balance, $mark ?? '');
+            $res = $res2 && $res3;
+            if ($res) {
+                self::commitTrans();
+                return true;
+            } else return self::setErrorInfo('提现失败!');
+        } catch (\Exception $e) {
+            self::rollbackTrans();
+            return self::setErrorInfo('提现失败!');
+        }
+    }
+
+
+    //获取头部提现信息
+    public static function getExtractHead()
+    {
+        //本月提现人数
+        $month = self::getModelTime(['data' => 'month'], self::where('status', 1))->group('store_id')->count();
+        //本月提现笔数
+        $new_month = self::getModelTime(['data' => 'month'], self::where('status', 1))->distinct(true)->count();
+        //上月提现人数
+        $last_month = self::whereTime('add_time', 'last month')->where('status', 1)->group('store_id')->distinct(true)->count();
+        //上月提现笔数
+        $last_count = self::whereTime('add_time', 'last month')->where('status', 1)->count();
+        //本月提现金额
+        $extract_price = self::getModelTime(['data' => 'month'], self::where('status', 1))->sum('extract_price');
+        //上月提现金额
+        $last_extract_price = self::whereTime('add_time', 'last month')->where('status', 1)->sum('extract_price');
+
+        return [
+            [
+                'name' => '总提现店铺数',
+                'field' => '个',
+                'count' => self::where('status', 1)->group('store_id')->count(),
+                'content' => '',
+                'background_color' => 'layui-bg-blue',
+                'sum' => '',
+                'class' => 'fa fa-bar-chart',
+            ],
+            [
+                'name' => '总提现笔数',
+                'field' => '笔',
+                'count' => self::where('status', 1)->distinct(true)->count(),
+                'content' => '',
+                'background_color' => 'layui-bg-cyan',
+                'sum' => '',
+                'class' => 'fa fa-line-chart',
+            ],
+            [
+                'name' => '本月提现店铺数',
+                'field' => '人',
+                'count' => $month,
+                'content' => '',
+                'background_color' => 'layui-bg-orange',
+                'sum' => '',
+                'class' => 'fa fa-line-chart',
+            ],
+            [
+                'name' => '本月提现笔数',
+                'field' => '笔',
+                'count' => $new_month,
+                'content' => '',
+                'background_color' => 'layui-bg-green',
+                'sum' => '',
+                'class' => 'fa fa-line-chart',
+            ],
+            [
+                'name' => '本月提现金额',
+                'field' => '元',
+                'count' => $extract_price,
+                'content' => '提现总金额',
+                'background_color' => 'layui-bg-cyan',
+                'sum' => self::where('status', 1)->sum('extract_price'),
+                'class' => 'fa fa-line-chart',
+            ],
+            [
+                'name' => '上月提现店铺数',
+                'field' => '个',
+                'count' => $last_month,
+                'content' => '环比增幅',
+                'background_color' => 'layui-bg-blue',
+                'sum' => $last_month == 0 ? '100%' : bcdiv($month, $last_month, 2) * 100,
+                'class' => $last_month == 0 ? 'fa fa-level-up' : 'fa fa-level-down',
+            ],
+            [
+                'name' => '上月提现笔数',
+                'field' => '笔',
+                'count' => $last_count,
+                'content' => '环比增幅',
+                'background_color' => 'layui-bg-black',
+                'sum' => $last_count == 0 ? '100%' : bcdiv($new_month, $last_count, 2) * 100,
+                'class' => $last_count == 0 ? 'fa fa-level-up' : 'fa fa-level-down',
+            ],
+            [
+                'name' => '上月提现金额',
+                'field' => '元',
+                'count' => $last_extract_price,
+                'content' => '环比增幅',
+                'background_color' => 'layui-bg-gray',
+                'sum' => $last_extract_price == 0 ? '100%' : bcdiv($extract_price, $last_extract_price, 2) * 100,
+                'class' => $last_extract_price == 0 ? 'fa fa-level-up' : 'fa fa-level-down',
+            ],
+        ];
+    }
+
+    //获取提现分布图和提现人数金额曲线图
+    public static function getExtractList($where, $limit = 15)
+    {
+        $legdata = ['提现店铺数', '提现金额'];
+        $list = self::getModelTime($where, self::where('status', 1))
+            ->field('FROM_UNIXTIME(add_time,"%Y-%c-%d") as un_time,count(store_id) as count,sum(extract_price) as sum_price')->group('un_time')->order('un_time asc')->select();
+        if (count($list)) $list = $list->toArray();
+        $xdata = [];
+        $itemList = [0 => [], 1 => []];
+        $chatrList = [];
+        $zoom = '';
+        foreach ($list as $value) {
+            $xdata[] = $value['un_time'];
+            $itemList[0][] = $value['count'];
+            $itemList[1][] = $value['sum_price'];
+        }
+        foreach ($legdata as $key => $name) {
+            $item['name'] = $name;
+            $item['type'] = 'line';
+            $item['data'] = $itemList[$key];
+            $chatrList[] = $item;
+        }
+        unset($item, $name, $key);
+        if (count($xdata) > $limit) $zoom = $xdata[$limit - 5];
+        //饼状图
+        $cake = ['支付宝', '银行卡', '微信'];
+        $fenbulist = self::getModelTime($where, self::where('status', 1))
+            ->field('count(store_id) as count,extract_type')->group('extract_type')->order('count asc')->select();
+        if (count($fenbulist)) $fenbulist = $fenbulist->toArray();
+        $sum_count = self::getModelTime($where, self::where('status', 1))->count();
+        $color = ['#FB7773', '#81BCFE', '#91F3FE'];
+        $fenbudata = [];
+        foreach ($fenbulist as $key => $item) {
+            if ($item['extract_type'] == 'bank') {
+                $item_date['name'] = '银行卡';
+            } else if ($item['extract_type'] == 'alipay') {
+                $item_date['name'] = '支付宝';
+            } else if ($item['extract_type'] == 'weixin') {
+                $item_date['name'] = '微信';
+            }
+            $item_date['value'] = bcdiv($item['count'], $sum_count, 2) * 100;
+            $item_date['itemStyle']['color'] = $color[$key];
+            $fenbudata[] = $item_date;
+        }
+        return compact('xdata', 'chatrList', 'legdata', 'zoom', 'cake', 'fenbudata');
+    }
+
+    /**
+     * 获取用户累计提现金额
+     * @param int $uid
+     * @return int|mixed
+     */
+    public static function getUserCountPrice($uid = 0)
+    {
+        if (!$uid) return 0;
+        $price = self::where('store_id', $uid)->where('status', 1)->sum('extract_price');
+        return $price ? $price : 0;
+    }
+
+    /**
+     * 获取用户累计提现次数
+     * @param int $uid
+     * @return int|string
+     */
+    public static function getUserCountNum($uid = 0)
+    {
+        if (!$uid) return 0;
+        return self::where('store_id', $uid)->count();
+    }
+}

+ 160 - 0
app/admin/model/system/SystemStorePoint.php

@@ -0,0 +1,160 @@
+<?php
+
+
+namespace app\admin\model\system;
+
+use app\admin\model\order\StoreOrder;
+use crmeb\traits\ModelTrait;
+use crmeb\basic\BaseModel;
+use crmeb\services\PHPExcelService;
+
+/**
+ * 门店自提 model
+ * Class SystemStore
+ * @package app\admin\model\system
+ */
+class SystemStorePoint extends BaseModel
+{
+    use ModelTrait;
+
+    /**
+     * 数据表主键
+     * @var string
+     */
+    protected $pk = 'id';
+
+    /**
+     * 模型名称
+     * @var string
+     */
+    protected $name = 'system_store_point';
+
+
+    public static function getLatlngAttr($value, $data)
+    {
+        return $data['latitude'] . ',' . $data['longitude'];
+    }
+
+    public static function verificWhere()
+    {
+        return self::where('is_show', 1)->where('is_del', 0);
+    }
+
+    /**
+     * 获取门店信息
+     * @param int $id
+     * @return array|\think\Model|null
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public static function getStoreDispose($id = 0)
+    {
+        if ($id)
+            $storeInfo = self::verificWhere()->where('id', $id)->find();
+        else
+//            $storeInfo = self::verificWhere()->find();
+            $storeInfo = [];
+        if ($storeInfo) {
+            $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']) : [];
+        } else {
+            $storeInfo['latlng'] = [];
+            $storeInfo['valid_time'] = [];
+            $storeInfo['day_time'] = [];
+            $storeInfo['address'] = [];
+            $storeInfo['id'] = 0;
+        }
+        return $storeInfo;
+    }
+
+    /**
+     * 获取门店列表
+     * @param $where
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public static function getStoreList($where)
+    {
+        $model = new self();
+        if (isset($where['store_id']) && $where['store_id'] != '') {
+            $model = $model->where('store_id', $where['store_id']);
+        }
+        if (isset($where['name']) && $where['name'] != '') {
+            $model = $model->where('id|name', 'like', '%' . $where['name'] . '%');
+        }
+        if (isset($where['type']) && $where['type'] != '' && ($data = self::setData($where['type']))) {
+            $model = $model->where($data);
+        }
+        $count = $model->count();
+        $data = $model->page((int)$where['page'], (int)$where['limit'])->select()->each(function ($item) {
+            $item['deposit'] = StoreOrder::where('store_id', $item['store_id'])
+                ->where('point_id', $item['id'])
+                ->where('paid', 1)
+                ->where('is_del', 0)
+                ->where('is_system_del', 0)
+                ->where('refund_status', 0)->sum('deposit');
+            $item['deposit_back'] = StoreOrder::where('store_id', $item['store_id'])
+                ->where('point_id', $item['id'])
+                ->where('paid', 1)
+                ->where('is_del', 0)
+                ->where('is_system_del', 0)
+                ->where('refund_status', 0)->sum('deposit_back');
+            $item['store'] = SystemStore::get($item['store_id'])->value('name');
+        });
+        if ($where['excel'] == 1) {
+            $export = [];
+            foreach ($data as $index => $item) {
+                $export[] = [
+                    $item['name'],
+                    $item['store'],
+                    $item['phone'],
+                    $item['address'] .= ' ' . $item['detailed_address'],
+                    $item['deposit'],
+                    $item['deposit_back'],
+                    $item['day_time'],
+                    $item['valid_time']
+                ];
+            }
+            PHPExcelService::setExcelHeader(['自提点名称', '所属门店', '自提点电话', '自提点地址', '总押金', '已退押金', '营业时间', '核销日期'])
+                ->setExcelTile('自提点导出', '自提点信息' . time(), ' 生成时间:' . date('Y-m-d H:i:s', time()))
+                ->setExcelContent($export)
+                ->ExcelSave();
+        }
+        return compact('count', 'data');
+    }
+
+    /**
+     * 获取连表查询条件
+     * @param $type
+     * @return array
+     */
+    public static function setData($type)
+    {
+        switch ((int)$type) {
+            case 1:
+                $data = ['is_show' => 1, 'is_del' => 0];
+                break;
+            case 2:
+                $data = ['is_show' => 0, 'is_del' => 0];
+                break;
+            case 3:
+                $data = ['is_del' => 1];
+                break;
+        };
+        return isset($data) ? $data : [];
+    }
+
+    public static function dropList()
+    {
+        $model = new self();
+        $model = $model->where('is_del', 0);
+        $list = $model->select()
+            ->toArray();
+        return $list;
+    }
+}

+ 194 - 0
app/admin/model/system/SystemStoreProductStock.php

@@ -0,0 +1,194 @@
+<?php
+
+namespace app\admin\model\system;
+
+use app\admin\model\order\StoreOrder;
+use app\admin\model\store\StoreProduct;
+use app\admin\model\store\StoreProductAttrValue;
+use app\admin\model\ump\StoreSeckill;
+use app\models\store\StoreCart;
+use crmeb\services\PHPExcelService;
+use crmeb\traits\ModelTrait;
+use crmeb\basic\BaseModel;
+use think\facade\Db;
+use think\session\Store;
+
+/**
+ * 店铺仓库明细 model
+ * Class User
+ * @package app\admin\model\user
+ */
+class SystemStoreProductStock extends BaseModel
+{
+    /**
+     * 数据表主键
+     * @var string
+     */
+    protected $pk = 'id';
+
+    /**
+     * 模型名称
+     * @var string
+     */
+    protected $name = 'system_store_product_stock';
+
+    use ModelTrait;
+
+
+    public static function getStockList($where, $store_id)
+    {
+        $model = self::alias('s')
+            ->field('s.*')
+            ->join('store_product p', 's.product_id = p.id', 'right')
+            ->join('store_product_attr_value pv', 's.unique = pv.unique', 'right')
+            ->where('s.store_id', $store_id);
+        if (isset($where['product_id']) && $where['product_id'] != '') {
+            $model = $model->where('s.product_id', $where['product_id']);
+        }
+        if (isset($where['type']) && $where['type'] != '') {
+            switch ($where['type']) {
+                case 1:
+                    $model = $model->where('s.stock', '<=', sys_config('store_stock') > 0 ? sys_config('store_stock') : 20);
+                    break;
+            }
+        }
+        $count = $model->count();
+        $model = $model->order('s.product_id asc,s.id desc');
+        if (!(isset($where['excel']) && $where['excel'] == 1)) {
+            $model = $model->page((int)$where['page'], (int)$where['limit']);
+        }
+        $data = $model->select()->each(function ($item) use ($store_id, $where) {
+            $item['product_info'] = StoreProduct::get($item['product_id']);
+            if ($item['product_info'])
+                $item['product_info']['product_attr_info'] = StoreProductAttrValue::get(['unique' => $item['unique']]);
+
+            if (!(isset($where['start_time']) && $where['start_time'] != '')) {
+                $where['start_time'] = 0;
+            } else {
+                $where['start_time'] = strtotime($where['start_time']);
+            }
+            if (!(isset($where['end_time']) && $where['end_time'] != '')) {
+                $where['end_time'] = 9999999999;
+            } else {
+                $where['end_time'] = strtotime($where['end_time']);
+            }
+
+            $deal_function = function ($type) use ($store_id, $where, $item) {
+                $sum = 0;
+                if (isset($where['data']) && $where['data'] != '') {
+                    $model = StoreOrder::getModelTime($where, new StoreOrder(), 'pay_time');
+                } else {
+                    $model = new StoreOrder();
+                }
+                if (!(isset($where['data']) && $where['data'] != '')) {
+                    $model = $model->where('pay_time', 'between', [$where['start_time'], $where['end_time']]);
+                }
+                if ($type == 'wait') {
+                    $orders = $model
+                        ->where('store_id', $store_id)
+                        ->where('paid', 1)
+                        ->where('status', 0)
+                        ->where('is_del',0)
+                        ->where('is_system_del',0)
+                        ->where('refund_status', 0)
+                        ->select();
+                } else if ($type == "wait_check") {
+                    $orders = $model
+                        ->where('store_id', $store_id)
+                        ->where('paid', 1)
+                        ->where('shipping_type', 2)
+                        ->where('status', 0)
+                        ->where('refund_status', 0)
+                        ->select();
+                } else if ($type == "wait_send") {
+                    $orders = $model
+                        ->where('store_id', $store_id)
+                        ->where('paid', 1)
+                        ->where('status', 0)
+                        ->where('refund_status', 0)
+                        ->select();
+                } else {
+                    $orders = $model->where('store_id', $store_id)
+                        ->where('paid', 1)
+                        ->where('refund_status', 0)
+                        ->select();
+                }
+                foreach ($orders as $v) {
+                    if (!$v['seckill_id'] && !$v['bargain_id'] && !$v['combination_id'] && !$v['integral_id'])
+                        $sum += StoreCart::where('is_del', 0)
+                            ->where('is_pay', 1)
+                            ->where('id', 'in', json_decode($v['cart_id'], true))
+                            ->where('product_id', $item['product_id'])
+                            ->where('product_attr_unique', $item['unique'])
+                            ->sum('cart_num');
+                    else {
+                        $info = StoreProductAttrValue::where(['unique' => $item['unique']])->find();
+                        $type = 0;
+                        $product_id = $item['product_id'];
+                        if ($v['seckill_id']) {
+                            $type = 1;
+                            $product_id = $v['seckill_id'];
+                        }
+                        if ($v['bargain_id']) {
+                            $type = 2;
+                            $product_id = $v['bargain_id'];
+                        }
+                        if ($v['combination_id']) {
+                            $type = 3;
+                            $product_id = $v['combination_id'];
+                        }
+                        if ($v['integral_id']) {
+                            $type = 4;
+                            $product_id = $v['integral_id'];
+                        }
+                        $unique = StoreProductAttrValue::where('suk', $info['suk'])->where('product_id', $product_id)->where('type', $type)->value('unique');
+                        $sum += StoreCart::where('is_del', 0)
+                            ->where('is_pay', 1)
+                            ->where('id', 'in', json_decode($v['cart_id'], true))
+                            ->where('product_id', $item['product_id'])
+                            ->where('product_attr_unique', $unique)
+                            ->sum('cart_num');
+                    }
+                }
+                return $sum;
+            };
+            $wait = $deal_function('wait');
+            $wait_check = $deal_function('wait_check');
+            $wait_send = $deal_function('wait_send');
+            $sales = $deal_function('sales');
+
+            $item['wait'] = $wait;
+            $item['wait_check'] = $wait_check;
+            $item['wait_send'] = $wait_send;
+            $item['sales'] = $sales;
+        });
+        if (isset($where['excel']) && $where['excel'] == 1) {
+            $export = [];
+            foreach ($data as $index => $item) {
+                $export[] = [
+                    $item['product_info']['store_name'],
+                    $item['product_info']['product_attr_info']['suk'],
+                    $item['stock'],
+                    $item['wait_check'],
+                    $item['wait_send'],
+                    $item['sales'],
+                ];
+            }
+            PHPExcelService::setExcelHeader(['商品名称', '规格', '库存', '待核销', '待送货', '销量'])
+                ->setExcelTile('门店库存导出', '门店库存信息' . time(), ' 生成时间:' . date('Y-m-d H:i:s', time()))
+                ->setExcelContent($export)
+                ->ExcelSave();
+        }
+        return compact('count', 'data');
+    }
+
+    public static function getWarning($store_id)
+    {
+        $model = self::where('store_id', $store_id);
+        $model = $model->where('stock', '<=', sys_config('store_stock') > 0 ? sys_config('store_stock') : 20);
+        $count = $model->count();
+        return $count;
+    }
+
+
+}

+ 115 - 0
app/admin/model/system/SystemStoreProductStockLog.php

@@ -0,0 +1,115 @@
+<?php
+
+namespace app\admin\model\system;
+
+use app\admin\model\store\StoreProductAttrValue;
+use app\admin\model\ump\StoreBargain;
+use app\admin\model\ump\StoreCombination;
+use app\admin\model\ump\StoreFree;
+use app\admin\model\ump\StoreLimit;
+use app\admin\model\ump\StoreSeckill;
+use app\models\store\StoreProduct;
+use crmeb\traits\ModelTrait;
+use crmeb\basic\BaseModel;
+use think\facade\Db;
+
+/**
+ * 店铺仓库明细 model
+ * Class User
+ * @package app\admin\model\user
+ */
+class SystemStoreProductStockLog extends BaseModel
+{
+    /**
+     * 数据表主键
+     * @var string
+     */
+    protected $pk = 'id';
+
+    /**
+     * 模型名称
+     * @var string
+     */
+    protected $name = 'system_store_product_stock_log';
+
+    use ModelTrait;
+
+
+    //修改库存减少库存记录
+    public static function expend($store_id, $product_id, $unique, $type, $link_id, $number, $adder_id, $mark = '', $status = 1)
+    {
+        $info = StoreProductAttrValue::where(['unique' => $unique])->find();
+        if (!$info) {
+            return self::setErrorInfo('找不到对应商品规格');
+        }
+        if ($info['type'] > 0) {
+            $unique = StoreProductAttrValue::where('product_id', $product_id)->where('suk', $info['suk'])->where('type', 0)->value('unique');
+        }
+        if (!$unique) {
+            return self::setErrorInfo('找不到对应商品规格');
+        }
+        $stock = SystemStoreProductStock::where(['product_id' => $product_id, 'unique' => $unique, 'store_id' => $store_id])->find();
+        if (!$stock) {
+            $stock = SystemStoreProductStock::create(['product_id' => $product_id, 'unique' => $unique, 'store_id' => $store_id, 'add_time' => time(), 'stock' => 0, 'in_use' => 0]);
+        }
+        if (!$stock['in_use']) return self::setErrorInfo('所选门店未上架' . StoreProduct::get($product_id)['store_name'] . '[' . $info['suk'] . ']');
+        if ($number > 0) {
+            $balance = $stock['stock'] - $number;
+            if ($balance < 0) {
+                return self::setErrorInfo('所选门店' . StoreProduct::get($product_id)['store_name'] . '[' . $info['suk'] . ']库存不足');
+            }
+            SystemStoreProductStock::where('id', $stock['id'])->dec('stock', $number)->update();
+            $pm = 0;
+            $add_time = time();
+            $stock_id = $stock['id'];
+            return self::create(compact('stock_id', 'link_id', 'type', 'number', 'balance', 'mark', 'status', 'pm', 'add_time', 'adder_id'));
+        } else {
+            return true;
+        }
+    }
+
+    //修改库存增加库存记录
+    public static function income($store_id, $product_id, $unique, $type, $link_id, $number, $adder_id, $mark = '', $status = 1)
+    {
+        $info = StoreProductAttrValue::where(['unique' => $unique])->find();
+        if (!$info) {
+            return self::setErrorInfo('找不到对应商品规格');
+        }
+        if ($info['type'] > 0) {
+            $unique = StoreProductAttrValue::where('product_id', $product_id)->where('suk', $info['suk'])->where('type', 0)->value('unique');
+        }
+        if (!$unique) {
+            return self::setErrorInfo('找不到对应商品规格');
+        }
+        $stock = SystemStoreProductStock::where(['product_id' => $product_id, 'unique' => $unique, 'store_id' => $store_id])->find();
+        if (!$stock) {
+            $stock = SystemStoreProductStock::create(['product_id' => $product_id, 'unique' => $unique, 'store_id' => $store_id, 'add_time' => time(), 'stock' => 0, 'in_use' => 1]);
+        }
+        if ($number > 0) {
+            $balance = $stock['stock'] + $number;
+            SystemStoreProductStock::where('id', $stock['id'])->inc('stock', $number)->update();
+            $pm = 1;
+            $add_time = time();
+            $stock_id = $stock['id'];
+            return self::create(compact('stock_id', 'link_id', 'type', 'number', 'balance', 'mark', 'status', 'pm', 'add_time', 'adder_id'));
+        } else {
+            return true;
+        }
+    }
+
+    /**
+     * @param $where
+     * @param $store_id
+     * @return array
+     */
+    public static function getList($where, $store_id)
+    {
+        $model = self::where('stock_id', $store_id);
+        $count = $model->count();
+        $data = $model->order('add_time', 'desc')->page((int)$where['page'], (int)$where['limit'])->select()->each(function ($item) {
+            $item['_add_time'] = date('Y-m-d H:i:s', $item['add_time']);
+            $item['adder'] = SystemAdmin::where('id', $item['adder_id'])->value('real_name') ?: '--';
+        });
+        return compact('count', 'data');
+    }
+}

+ 72 - 0
app/admin/view/merchant/system_store/bill.php

@@ -0,0 +1,72 @@
+{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-row layui-col-space15">
+        <div class="layui-col-md12">
+            <div class="layui-card">
+                <div class="layui-card-body">
+                    <div class="alert alert-success alert-dismissable">
+                        <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
+                        门店名称:{$store_info.name}&nbsp;&nbsp;&nbsp;总佣金:{$store_info.brokerage_price}
+                    </div>
+                    <form class="layui-form layui-form-pane" action="">
+                        <div class="layui-inline">
+                            <div class="layui-input-inline">
+                                <button class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="search"
+                                        lay-filter="cash">
+                                    <i class="layui-icon layui-icon-dollar"></i>发起提现
+                                </button>
+                                <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>
+                            </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">
+                <table class="layui-hide" id="List" lay-filter="List"></table>
+                <script type="text/html" id="number">
+                    {{# if(d.pm === 1){ }}
+                    <font color="green">+{{d.number}}</font>
+                    {{# }else{ }}
+                    <font color="red">-{{d.number}}</font>
+                    {{# } }}
+                </script>
+            </div>
+        </div>
+    </div>
+</div>
+</div>
+<script src="{__ADMIN_PATH}js/layuiList.js"></script>
+{/block}
+{block name="script"}
+<script>
+    layList.tableList('List', "{:Url('store_bill_log_list',array('id'=>$id))}", function () {
+        return [
+            {field: 'id', title: 'ID', sort: true, event: 'id', width: '4%'},
+            {field: '_add_time', title: '添加时间', width: '16%'},
+            {field: 'title', title: '类型', width: '15%'},
+            {field: 'mark', title: '事件', width: '40%'},
+            {field: '_status', title: '状态', width: '15%'},
+            {field: 'number', title: '数值', width: '10%', templet: '#number'},
+        ];
+    });
+    //查询条件
+    layList.search('cash', function (where) {
+        $eb.createModalFrame('发起提现', layList.U({a: 'cash'}), {h: 700, w: 1100});
+    });
+    layList.search('search', function (where) {
+        layList.reload(where);
+    });
+</script>
+{/block}

+ 207 - 0
app/admin/view/merchant/system_store/children_store.php

@@ -0,0 +1,207 @@
+{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('index',['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('index',['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('index',['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">
+                                <label class="layui-form-label">等级</label>
+                                <div class="layui-input-block">
+                                    <select name="level" class="layui-input" style="display: block">
+                                        <option value="">全部</option>
+                                        {volist name="level_list" id="vo"}
+                                        <option value="{$vo.value}" class="layui-select">{$vo.label}</option>
+                                        {/volist}
+                                    </select>
+                                </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">
+                    <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='stock'>-->
+                        <!--                            门店库存-->
+                        <!--                        </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?>;
+    layList.tableList('List', "{:Url('children_list',['type'=>$type])}", function () {
+        return [
+            {field: 'id', title: 'ID', sort: true, event: 'id', width: '4%'},
+            {field: 'image', title: '门店图片', templet: '#headimgurl', width: '6%'},
+            {field: 'name', title: '门店名称', width: '10%'},
+            {field: 'level_text', title: '门店等级', width: '10%'},
+            {field: 'phone', title: '门店电话', width: '10%'},
+            {field: 'address', title: '地址', templet: '#address'},
+            {field: 'day_time', title: '营业时间', width: '15%'},
+            // {field: 'valid_time', title: '核销有效日期', width: '11%'},
+            // {field: 'status', title: '是否显示', templet: "#checkboxstatus", width: '8%'},
+            {field: 'right', title: '操作', align: 'center', toolbar: '#act', width: '14%'},
+        ];
+    });
+    //查询条件
+    layList.search('search', function (where) {
+        layList.reload(where);
+    });
+    //excel下载
+    layList.search('export', function (where) {
+        where.excel = 1;
+        location.href = layList.U({c: 'merchant.system_store', a: 'children_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_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_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: '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({
+                    c: 'system.system_store',
+                    a: 'add',
+                    q: {id: data.id}
+                }), {h: 700, w: 1100});
+                break;
+            case 'stock':
+                $eb.createModalFrame(data.name + '-库存', layList.U({
+                    c: 'system.system_store',
+                    a: 'storeProductInfo',
+                    q: {id: data.id}
+                }), {
+                    h: 700,
+                    w: 1100
+                });
+                break;
+            case 'bill':
+                $eb.createModalFrame(data.name + '-佣金', layList.U({
+                    c: 'system.system_store',
+                    a: 'store_bill_log',
+                    q: {id: data.id}
+                }), {
+                    h: 700,
+                    w: 1100
+                });
+                break;
+        }
+    })
+</script>
+{/block}

+ 112 - 0
app/admin/view/merchant/system_store/index.php

@@ -0,0 +1,112 @@
+{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('index',['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('index',['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('index',['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>
+                                </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">
+                    <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="act">
+                        <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" lay-event='chose'>
+                            选择门店
+                        </button>
+                    </script>
+                    <script type="text/html" id="pid">
+                        <a href="{:Url('index')}?pid={{d.id}}">查看</a>
+                    </script>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+<script src="{__ADMIN_PATH}js/layuiList.js"></script>
+{/block}
+{block name="script"}
+<script>
+    var type =<?=$type?>;
+    let origin = "{$origin}";
+    layList.tableList('List', "{:Url('list',['type'=>$type])}", function () {
+        return [
+            {field: 'id', title: 'ID', sort: true, event: 'id', width: '4%'},
+            {field: 'image', title: '门店图片', templet: '#headimgurl', width: '6%'},
+            {field: 'name', title: '门店名称', width: '10%'},
+            {field: 'leader', title: '门店店长', width: '8%'},
+            {field: 'phone', title: '门店电话', width: '8%'},
+            {field: 'deposit', title: '总押金', width: '6%'},
+            {field: 'deposit_back', title: '已退押金', width: '6%'},
+            {field: 'address', title: '地址', templet: '#address'},
+            {field: 'day_time', title: '营业时间', width: '10%'},
+            // {field: 'valid_time', title: '核销有效日期', width: '11%'},
+            // {field: 'status', title: '是否显示', templet: "#checkboxstatus", width: '8%'},
+            {field: 'right', title: '操作', align: 'center', toolbar: '#act', width: '14%'},
+        ];
+    });
+    //查询条件
+    layList.search('search', function (where) {
+        layList.reload(where);
+    });
+    //点击事件绑定
+    layList.tool(function (event, data, obj) {
+        switch (event) {
+            case 'chose':
+                var url = layList.U({c: 'merchant.system_store', a: 'index', q: {store_id: data.id, origin: origin}});
+                location.href = url;
+                break;
+            case 'open_image':
+                $eb.openImage(data.image);
+                break;
+        }
+    })
+</script>
+{/block}

+ 60 - 0
app/admin/view/merchant/system_store/info.php

@@ -0,0 +1,60 @@
+{extend name="public/container"}
+{block name="content"}
+<style>
+    .backlog-body {
+        padding: 10px 15px;
+        background-color: #f8f8f8;
+        color: #999;
+        border-radius: 2px;
+        transition: all .3s;
+        text-align: center;
+        -webkit-transition: all .3s;
+        overflow: hidden;
+        max-height: 100%;
+    }
+
+    .backlog-body h3 {
+        margin-bottom: 10px;
+    }
+
+
+    .backlog-body p cite {
+        font-style: normal;
+        font-size: 17px;
+        font-weight: 300;
+        color: #009688;
+    }
+</style>
+<div class="layui-fluid">
+    <div class="layui-row layui-col-space15">
+        <div class="layui-col-md12 layui-col-sm12 layui-col-lg12">
+            <div class="layui-card">
+                <div class="layui-card-header">门店详情</div>
+                <div class="layui-card-body">
+                    <ul class="layui-row layui-col-space10 layui-this">
+                        {volist name='store_info' id='vo'}
+                        {if trim($vo.value)}
+                        <li class="layui-col-xs<?= isset($vo['col']) ? $vo['col'] : 4 ?>">
+                            <div class="backlog-body">
+                                <h3>{$vo.name}</h3>
+                                <p>
+                                    <cite {if isset($vo['color'])} style="color: {$vo['color']}" {/if}>
+                                    {if $vo['image']}
+                                    <img src="{$vo.value}" style="width: 100px">
+                                    {else /}
+                                    {$vo.value}
+                                    {/if}
+                                    </cite>
+                                </p>
+                            </div>
+                        </li>
+                        {/if}
+                        {/volist}
+                    </ul>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+<script src="{__ADMIN_PATH}js/layuiList.js"></script>
+{/block}

+ 874 - 0
app/admin/view/merchant/system_store/order.php

@@ -0,0 +1,874 @@
+{extend name="public/container"}
+{block name="head_top"}
+
+{/block}
+{block name="content"}
+<style>
+    .btn-outline {
+        border: none;
+    }
+
+    .btn-outline:hover {
+        background-color: #0e9aef;
+        color: #fff;
+    }
+
+    .layui-form-item .layui-btn {
+        margin-top: 5px;
+        margin-right: 10px;
+    }
+
+    .layui-btn-primary {
+        margin-right: 10px;
+        margin-left: 0 !important;
+    }
+
+    label {
+        margin-bottom: 0 !important;
+        margin-top: 4px;
+    }
+</style>
+<div class="layui-fluid">
+    <div class="layui-row layui-col-space15" id="app">
+        <!--搜索条件-->
+        <div class="layui-col-md12">
+            <div class="layui-card">
+                <div class="layui-card-header">搜索条件</div>
+                <div class="layui-card-body">
+                    <div class="layui-carousel layadmin-carousel layadmin-shortcut" lay-anim="" lay-indicator="inside"
+                         lay-arrow="none" style="background:none">
+                        <div class="layui-card-body">
+                            <div class="layui-row layui-col-space10 layui-form-item">
+                                <div class="layui-col-lg12">
+                                    <label class="layui-form-label">订单状态:</label>
+                                    <div class="layui-input-block" v-cloak="">
+                                        <button class="layui-btn layui-btn-sm"
+                                                :class="{'layui-btn-primary':where.status!==item.value}"
+                                                @click="where.status = item.value" type="button"
+                                                v-for="item in orderStatus">{{item.name}}
+                                            <span v-if="item.count!=undefined"
+                                                  :class="item.class!=undefined ? 'layui-badge': 'layui-badge layui-bg-gray' ">{{item.count}}</span>
+                                        </button>
+                                    </div>
+                                </div>
+                                <div class="layui-col-lg12">
+                                    <label class="layui-form-label">订单类型:</label>
+                                    <div class="layui-input-block" v-cloak="">
+                                        <button class="layui-btn layui-btn-sm"
+                                                :class="{'layui-btn-primary':where.type!=item.value}"
+                                                @click="where.type = item.value" type="button"
+                                                v-for="item in orderType">{{item.name}}
+                                            <span v-if="item.count!=undefined" class="layui-badge layui-bg-gray">{{item.count}}</span>
+                                        </button>
+                                    </div>
+                                </div>
+                                <div class="layui-col-lg12">
+                                    <label class="layui-form-label">支付方式:</label>
+                                    <div class="layui-input-block" v-cloak="">
+                                        <button class="layui-btn layui-btn-sm"
+                                                :class="{'layui-btn-primary':where.pay_type!=item.value}"
+                                                @click="where.pay_type = item.value" type="button"
+                                                v-for="item in payType">{{item.name}}
+                                            <span v-if="item.count!=undefined" class="layui-badge layui-bg-gray">{{item.count}}</span>
+                                        </button>
+                                    </div>
+                                </div>
+                                <div class="layui-col-lg12">
+                                    <label class="layui-form-label">创建时间:</label>
+                                    <div class="layui-input-block" data-type="data" v-cloak="">
+                                        <button class="layui-btn layui-btn-sm" type="button" v-for="item in dataList"
+                                                @click="setData(item)"
+                                                :class="{'layui-btn-primary':where.data!=item.value}">{{item.name}}
+                                        </button>
+                                        <button class="layui-btn layui-btn-sm" type="button" ref="time"
+                                                @click="setData({value:'zd',is_zd:true})"
+                                                :class="{'layui-btn-primary':where.data!='zd'}">自定义
+                                        </button>
+                                        <button type="button" class="layui-btn layui-btn-sm layui-btn-primary"
+                                                v-show="showtime==true" ref="date_time">{$year.0} - {$year.1}
+                                        </button>
+                                    </div>
+                                </div>
+                                <div class="layui-col-lg12">
+                                    <label class="layui-form-label">订单号:</label>
+                                    <div class="layui-input-block">
+                                        <input type="text" name="real_name" style="width: 50%" v-model="where.real_name"
+                                               placeholder="请输入姓名、电话、订单编号" class="layui-input">
+                                    </div>
+                                </div>
+                                <div class="layui-col-lg12">
+                                    <div class="layui-input-block">
+                                        <button @click="search" type="button"
+                                                class="layui-btn layui-btn-sm layui-btn-normal">
+                                            <i class="layui-icon layui-icon-search"></i>搜索
+                                        </button>
+                                        <button @click="excel" type="button"
+                                                class="layui-btn layui-btn-warm layui-btn-sm export" type="button">
+                                            <i class="fa fa-floppy-o" style="margin-right: 3px;"></i>导出
+                                        </button>
+                                        <button @click="refresh" type="reset"
+                                                class="layui-btn layui-btn-primary layui-btn-sm">
+                                            <i class="layui-icon layui-icon-refresh"></i>刷新
+                                        </button>
+                                    </div>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+        <!--end-->
+        <!-- 中间详细信息-->
+        <div :class="item.col!=undefined ? 'layui-col-sm'+item.col+' '+'layui-col-md'+item.col:'layui-col-sm6 layui-col-md3'"
+             v-for="item in badge" v-cloak="" v-if="item.count > 0">
+            <div class="layui-card">
+                <div class="layui-card-header">
+                    {{item.name}}
+                    <span class="layui-badge layuiadmin-badge" :class="item.background_color">{{item.field}}</span>
+                </div>
+                <div class="layui-card-body">
+                    <p class="layuiadmin-big-font">{{item.count}}</p>
+                    <p v-show="item.content!=undefined">
+                        {{item.content}}
+                        <span class="layuiadmin-span-color">{{item.sum}}<i :class="item.class"></i></span>
+                    </p>
+                </div>
+            </div>
+        </div>
+        <!--enb-->
+    </div>
+    <!--列表-->
+    <div class="layui-row layui-col-space15">
+        <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" id="container-action">
+                        <button class="layui-btn layui-btn-sm" data-type="del_order">批量删除订单</button>
+                        <button class="layui-btn layui-btn-sm layui-btn-warm" data-type="write_order">订单核销</button>
+                    </div>
+                    <table class="layui-hide" id="List" lay-filter="List"></table>
+                    <!--订单-->
+                    <script type="text/html" id="order_id">
+                        {{d.order_id}}<br/>
+                        <span style="color: {{d.color}};">{{d.pink_name}}</span><br/> 
+                        {{#  if(d.is_del == 1){ }}<span style="color: {{d.color}};">用户已删除</span>{{# } }} 
+                    </script>
+                    <!--用户信息-->
+                    <script type="text/html" id="userinfo">
+                        {{d.nickname==null ? '暂无信息':d.nickname}}/{{d.uid}}
+                    </script>
+                    <!--分销员信息-->
+                    <script type="text/html" id="spread_uid">
+                        {{# if(d.spread_uid != 0){ }}
+                        <button class="btn-xs btn-outline" type="button"
+                                onclick="$eb.createModalFrame('推荐人信息','{:Url('order_spread_user')}?uid={{d.spread_uid}}',{w:600,h:400})">
+                            {{d.spread_nickname}}
+                        </button>
+                        {{# }else{ }}无{{# } }}
+                    </script>
+                    <!--支付状态-->
+                    <script type="text/html" id="paid">
+                        {{#  if(d.pay_type==1){ }}
+                        <p>{{d.pay_type_name}}</p>
+                        {{#  }else{ }}
+                        {{# if(d.pay_type_info!=undefined){ }}
+                        <p><span>线下支付</span></p>
+                        {{# }else{ }}
+                        <p>{{d.pay_type_name}}</p>
+                        {{# } }}
+                        {{# }; }}
+                    </script>
+                    <!--订单状态-->
+                    <script type="text/html" id="status">
+                        {{d.status_name}}
+                    </script>
+                    <!--商品信息-->
+                    <script type="text/html" id="info">
+                        {{#  layui.each(d._info, function(index, item){ }}
+                        {{#  if(item.cart_info.productInfo.attrInfo!=undefined){ }}
+                        <div>
+                            <span>
+                                <img style="width: 30px;height: 30px;margin:0;cursor: pointer;"
+                                     src="{{item.cart_info.productInfo.attrInfo.image}}">
+                            </span>
+                            <span>{{item.cart_info.productInfo.store_name}}&nbsp;{{item.cart_info.productInfo.attrInfo.suk}}</span>
+                            <span> | ¥{{item.cart_info.truePrice}}×{{item.cart_info.cart_num}}</span>
+                        </div>
+                        {{#  }else{ }}
+                        <div>
+                            <span><img style="width: 30px;height: 30px;margin:0;cursor: pointer;"
+                                       src="{{item.cart_info.productInfo.image}}"></span>
+                            <span>{{item.cart_info.productInfo.store_name}}</span><span> | ¥{{item.cart_info.truePrice}}×{{item.cart_info.cart_num}}</span>
+                        </div>
+                        {{# } }}
+                        {{#  }); }}
+                    </script>
+
+                    <script type="text/html" id="act">
+                        {{# if(d._status==0){ }}
+                        <button class="layui-btn layui-btn-xs" type="button" lay-event="verify">
+                            <i class="fa fa-calendar"></i> 立即核销
+                        </button>
+                        <button type="button" class="layui-btn layui-btn-xs" onclick="dropdown(this)">操作 <span
+                                    class="caret"></span></button>
+                        <ul class="layui-nav-child layui-anim layui-anim-upbit">
+                            <li>
+                                <a href="javascript:void(0);" lay-event='order_info'>
+                                    <i class="fa fa-file-text"></i> 订单详情
+                                </a>
+                            </li>
+                            <li>
+                                <a href="javascript:void(0);"
+                                   onclick="$eb.createModalFrame('修改订单','{:Url('order.StoreOrder/edit')}?id={{d.id}}')">
+                                    <i class="fa fa-edit"></i> 修改订单
+                                </a>
+                            </li>
+                            {{# if(d.refund_status ==1){ }}
+
+                            {{# if(parseFloat(d.pay_price) > parseFloat(d.refund_price)){ }}
+                            <li>
+                                <a href="javascript:void(0);"
+                                   onclick="$eb.createModalFrame('退款','{:Url('order.StoreOrder/refund_y')}?id={{d.id}}',{w:400,h:300})">
+                                    <i class="fa fa-history"></i>立即退款
+                                </a>
+                            </li>
+                            {{# } ;}}
+                            <li>
+                                <a href="javascript:void(0);"
+                                   onclick="$eb.createModalFrame('不退款','{:Url('order.StoreOrder/refund_n')}?id={{d.id}}',{w:400,h:300})">
+                                    <i class="fa fa-openid"></i> 不退款
+                                </a>
+                            </li>
+                            {{# } ;}}
+                            <li>
+                                <a lay-event='marke' href="javascript:void(0);">
+                                    <i class="fa fa-edit"></i> 订单备注
+                                </a>
+                            </li>
+                            <li>
+                                <a href="javascript:void(0);"
+                                   onclick="$eb.createModalFrame('订单记录','{:Url('order.StoreOrder/order_status')}?oid={{d.id}}')">
+                                    <i class="fa fa-newspaper-o"></i> 订单记录
+                                </a>
+                            </li>
+                        </ul>
+                        {{#  }else if(d._status==1){ }}
+                        {{# if(d.paid == 0 && d.pay_type == 'offline'){ }}
+                        <button class="btn btn-danger btn-xs" type="button" lay-event="order_paid">
+                            <i class="fa fa-calendar"></i> 立即支付
+                        </button>
+                        {{# } ;}}
+                        <button type="button" class="layui-btn layui-btn-xs" onclick="dropdown(this)">操作 <span
+                                    class="caret"></span></button>
+                        <ul class="layui-nav-child layui-anim layui-anim-upbit">
+                            <li>
+                                <a href="javascript:void(0);" lay-event='order_info'>
+                                    <i class="fa fa-file-text"></i> 订单详情
+                                </a>
+                            </li>
+                            <li>
+                                <a href="javascript:void(0);"
+                                   onclick="$eb.createModalFrame('修改订单','{:Url('order.StoreOrder/edit')}?id={{d.id}}')">
+                                    <i class="fa fa-edit"></i> 修改订单
+                                </a>
+                            </li>
+                            <li>
+                                <a lay-event='marke' href="javascript:void(0);">
+                                    <i class="fa fa-edit"></i> 订单备注
+                                </a>
+                            </li>
+                            <li>
+                                <a href="javascript:void(0);"
+                                   onclick="$eb.createModalFrame('订单记录','{:Url('order.StoreOrder/order_status')}?oid={{d.id}}')">
+                                    <i class="fa fa-newspaper-o"></i> 订单记录
+                                </a>
+                            </li>
+                        </ul>
+                        {{#  }else if(d._status==2){ }}
+                        {{# if(d.shipping_type==1){ }}
+                        <button class="btn btn-primary btn-xs" type="button"
+                                onclick="$eb.createModalFrame('发送货','{:Url('order.StoreOrder/order_goods')}?id={{d.id}}',{w:400,h:250})">
+                            <i class="fa fa-cart-plus"></i> 发送货
+                        </button>
+                        {{# } }}
+                        <button type="button" class="layui-btn layui-btn-xs" onclick="dropdown(this)">操作 <span
+                                    class="caret"></span></button>
+                        <ul class="layui-nav-child layui-anim layui-anim-upbit">
+                            <li>
+                                <a href="javascript:void(0);" lay-event='order_print'>
+                                    <i class="fa fa-file-text"></i> 打印订单
+                                </a>
+                            </li>
+                            <li>
+                                <a href="javascript:void(0);" lay-event='order_info'>
+                                    <i class="fa fa-file-text"></i> 订单详情
+                                </a>
+                            </li>
+                            <li>
+                                <a lay-event='marke' href="javascript:void(0);">
+                                    <i class="fa fa-paste"></i> 订单备注
+                                </a>
+                            </li>
+                            {{# if(parseFloat(d.pay_price) > parseFloat(d.refund_price)){ }}
+                            <li>
+                                <a href="javascript:void(0);"
+                                   onclick="$eb.createModalFrame('退款','{:Url('order.StoreOrder/refund_y')}?id={{d.id}}',{w:400,h:300})">
+                                    <i class="fa fa-history"></i> 立即退款
+                                </a>
+                            </li>
+                            {{# } ;}}
+                            {{# if(d.use_integral > 0 && d.use_integral >= d.back_integral){ }}
+                            <li>
+                                <a href="javascript:void(0);"
+                                   onclick="$eb.createModalFrame('退积分','{:Url('order.StoreOrder/integral_back')}?id={{d.id}}')">
+                                    <i class="fa fa-history"></i> 退积分
+                                </a>
+                            </li>
+                            {{# } ;}}
+                            {{# if(parseFloat(d.deposit) > parseFloat(d.deposit_back)){ }}
+                            <li>
+                                <a href="javascript:void(0);"
+                                   onclick="$eb.createModalFrame('退押金','{:Url('order.StoreOrder/refund_deposit_y')}?id={{d.id}}')">
+                                    <i class="fa fa-history"></i> 退押金
+                                </a>
+                            </li>
+                            {{# } }}
+                            <li>
+                                <a href="javascript:void(0);"
+                                   onclick="$eb.createModalFrame('订单记录','{:Url('order.StoreOrder/order_status')}?oid={{d.id}}')">
+                                    <i class="fa fa-newspaper-o"></i> 订单记录
+                                </a>
+                            </li>
+                        </ul>
+                        {{#  }else if(d._status==3){ }}
+                        <button type="button" class="layui-btn layui-btn-xs" onclick="dropdown(this)">操作 <span
+                                    class="caret"></span></button>
+                        <ul class="layui-nav-child layui-anim layui-anim-upbit">
+                            <li>
+                                <a href="javascript:void(0);" lay-event='order_print'>
+                                    <i class="fa fa-file-text"></i> 打印订单
+                                </a>
+                            </li>
+                            <li>
+                                <a href="javascript:void(0);" lay-event='order_info'>
+                                    <i class="fa fa-file-text"></i> 订单详情
+                                </a>
+                            </li>
+                            <li>
+                                <a href="javascript:void(0);"
+                                   onclick="$eb.createModalFrame('去送货','{:Url('order.StoreOrder/delivery')}?id={{d.id}}',{w:400,h:300})">
+                                    <i class="fa fa-motorcycle"></i> 去送货
+                                </a>
+                            </li>
+                            {{# if(parseFloat(d.deposit) > parseFloat(d.deposit_back)){ }}
+                            <li>
+                                <a href="javascript:void(0);"
+                                   onclick="$eb.createModalFrame('退押金','{:Url('order.StoreOrder/refund_deposit_y')}?id={{d.id}}')">
+                                    <i class="fa fa-history"></i> 退押金
+                                </a>
+                            </li>
+                            {{# } }}
+                            <li>
+                                <a lay-event='marke' href="javascript:void(0);">
+                                    <i class="fa fa-paste"></i> 订单备注
+                                </a>
+                            </li>
+                            {{# if(parseFloat(d.use_integral) > 0 && parseFloat(d.use_integral) >
+                            parseFloat(d.back_integral)){ }}
+                            <li>
+                                <a href="javascript:void(0);"
+                                   onclick="$eb.createModalFrame('退积分','{:Url('order.StoreOrder/integral_back')}?id={{d.id}}',{w:400,h:300})">
+                                    <i class="fa fa-history"></i> 退积分
+                                </a>
+                            </li>
+                            {{# };}}
+                            {{# if(parseFloat(d.pay_price) > parseFloat(d.refund_price)){ }}
+                            <li>
+                                <a href="javascript:void(0);"
+                                   onclick="$eb.createModalFrame('退款','{:Url('order.StoreOrder/refund_y')}?id={{d.id}}',{w:400,h:300})">
+                                    <i class="fa fa-history"></i>立即退款
+                                </a>
+                            </li>
+                            {{# } ;}}
+                            <li>
+                                <a href="javascript:void(0);"
+                                   onclick="$eb.createModalFrame('不退款','{:Url('order.StoreOrder/refund_n')}?id={{d.id}}',{w:400,h:300})">
+                                    <i class="fa fa-openid"></i> 不退款
+                                </a>
+                            </li>
+                            <li>
+                                <a href="javascript:void(0);"
+                                   onclick="$eb.createModalFrame('订单记录','{:Url('order.StoreOrder/order_status')}?oid={{d.id}}')">
+                                    <i class="fa fa-newspaper-o"></i> 订单记录
+                                </a>
+                            </li>
+
+                        </ul>
+                        {{#  }else if(d._status==4){ }}
+                        <button class="btn btn-default btn-xs" type="button"
+                                onclick="$eb.createModalFrame('配送信息','{:Url('order.StoreOrder/distribution')}?id={{d.id}}')">
+                            <i class="fa fa-cart-arrow-down"></i> 配送信息
+                        </button>
+                        <button type="button" class="layui-btn layui-btn-xs" onclick="dropdown(this)">操作 <span
+                                    class="caret"></span></button>
+                        <ul class="layui-nav-child layui-anim layui-anim-upbit">
+                            <li>
+                                <a href="javascript:void(0);" lay-event='order_print'>
+                                    <i class="fa fa-file-text"></i> 打印订单
+                                </a>
+                            </li>
+                            <li>
+                                <a href="javascript:void(0);" lay-event='order_info'>
+                                    <i class="fa fa-file-text"></i> 订单详情
+                                </a>
+                            </li>
+                            <li>
+                                <a lay-event='marke' href="javascript:void(0);">
+                                    <i class="fa fa-paste"></i> 订单备注
+                                </a>
+                            </li>
+                            <li>
+                                <a lay-event='danger' href="javascript:void(0);">
+                                    <i class="fa fa-cart-arrow-down"></i> 已收货
+                                </a>
+                            </li>
+                            {{# if(parseFloat(d.pay_price) > parseFloat(d.refund_price)){ }}
+                            <li>
+                                <a href="javascript:void(0);"
+                                   onclick="$eb.createModalFrame('退款','{:Url('order.StoreOrder/refund_y')}?id={{d.id}}')">
+                                    <i class="fa fa-history"></i> 立即退款
+                                </a>
+                            </li>
+                            {{# if(parseFloat(d.deposit) > parseFloat(d.deposit_back)){ }}
+                            <li>
+                                <a href="javascript:void(0);"
+                                   onclick="$eb.createModalFrame('退押金','{:Url('order.StoreOrder/refund_deposit_y')}?id={{d.id}}')">
+                                    <i class="fa fa-history"></i> 退押金
+                                </a>
+                            </li>
+                            {{# } }}
+                            {{# }else if(parseFloat(d.use_integral) > 0 && parseFloat(d.use_integral) >
+                            parseFloat(d.back_integral)){ }}
+                            <li>
+                                <a href="javascript:void(0);"
+                                   onclick="$eb.createModalFrame('退积分','{:Url('order.StoreOrder/integral_back')}?id={{d.id}}')">
+                                    <i class="fa fa-history"></i> 退积分
+                                </a>
+                            </li>
+                            {{# } }}
+                            <li>
+                                <a href="javascript:void(0);"
+                                   onclick="$eb.createModalFrame('订单记录','{:Url('order.StoreOrder/order_status')}?oid={{d.id}}')">
+                                    <i class="fa fa-newspaper-o"></i> 订单记录
+                                </a>
+                            </li>
+                        </ul>
+                        {{#  }else if(d._status==5 || d._status==6){ }}
+                        <button type="button" class="layui-btn layui-btn-xs" onclick="dropdown(this)">操作 <span
+                                    class="caret"></span></button>
+                        <ul class="layui-nav-child layui-anim layui-anim-upbit">
+                            <li>
+                                <a href="javascript:void(0);" lay-event='order_print'>
+                                    <i class="fa fa-file-text"></i> 打印订单
+                                </a>
+                            </li>
+                            <li>
+                                <a href="javascript:void(0);" lay-event='order_info'>
+                                    <i class="fa fa-file-text"></i> 订单详情
+                                </a>
+                            </li>
+                            <li>
+                                <a lay-event='marke' href="javascript:void(0);">
+                                    <i class="fa fa-paste"></i> 订单备注
+                                </a>
+                            </li>
+                            {{# if(parseFloat(d.pay_price) > parseFloat(d.refund_price)){ }}
+                            <li>
+                                <a href="javascript:void(0);"
+                                   onclick="$eb.createModalFrame('退款','{:Url('order.StoreOrder/refund_y')}?id={{d.id}}')">
+                                    <i class="fa fa-history"></i> 立即退款
+                                </a>
+                            </li>
+                            {{# };}}
+                            {{# if(parseFloat(d.deposit) > parseFloat(d.deposit_back)){ }}
+                            <li>
+                                <a href="javascript:void(0);"
+                                   onclick="$eb.createModalFrame('退押金','{:Url('order.StoreOrder/refund_deposit_y')}?id={{d.id}}')">
+                                    <i class="fa fa-history"></i> 退押金
+                                </a>
+                            </li>
+                            {{# } }}
+                            {{# if(parseFloat(d.use_integral) > 0 && parseFloat(d.use_integral) >
+                            parseFloat(d.back_integral)){ }}
+                            <li>
+                                <a href="javascript:void(0);"
+                                   onclick="$eb.createModalFrame('退积分','{:Url('order.StoreOrder/integral_back')}?id={{d.id}}')">
+                                    <i class="fa fa-history"></i> 退积分
+                                </a>
+                            </li>
+                            {{# } }}
+                            <li>
+                                <a href="javascript:void(0);"
+                                   onclick="$eb.createModalFrame('订单记录','{:Url('order.StoreOrder/order_status')}?oid={{d.id}}')">
+                                    <i class="fa fa-newspaper-o"></i> 订单记录
+                                </a>
+                            </li>
+                        </ul>
+                        {{#  }else if(d._status==7){ }}
+                        <button type="button" class="layui-btn layui-btn-xs" onclick="dropdown(this)">操作 <span
+                                    class="caret"></span></button>
+                        <ul class="layui-nav-child layui-anim layui-anim-upbit">
+                            <!--                            <li>-->
+                            <!--                                <a href="javascript:void(0);" lay-event='order_print'>-->
+                            <!--                                    <i class="fa fa-file-text"></i> 打印订单-->
+                            <!--                                </a>-->
+                            <!--                            </li>-->
+                            <li>
+                                <a href="javascript:void(0);" lay-event='order_info'>
+                                    <i class="fa fa-file-text"></i> 订单详情
+                                </a>
+                            </li>
+                            <li>
+                                <a lay-event='marke' href="javascript:void(0);">
+                                    <i class="fa fa-paste"></i> 订单备注
+                                </a>
+                            </li>
+                            {{# if(parseFloat(d.pay_price) > parseFloat(d.refund_price)){ }}
+                            <li>
+                                <a href="javascript:void(0);"
+                                   onclick="$eb.createModalFrame('退款','{:Url('order.StoreOrder/refund_y')}?id={{d.id}}')">
+                                    <i class="fa fa-history"></i> 立即退款
+                                </a>
+                            </li>
+                            {{# } }}
+                            {{# if(parseFloat(d.deposit) > parseFloat(d.deposit_back)){ }}
+                            <li>
+                                <a href="javascript:void(0);"
+                                   onclick="$eb.createModalFrame('退押金','{:Url('order.StoreOrder/refund_deposit_y')}?id={{d.id}}')">
+                                    <i class="fa fa-history"></i> 退押金
+                                </a>
+                            </li>
+                            {{# } }}
+                            {{# if(parseFloat(d.use_integral) > 0 && parseFloat(d.use_integral) >=
+                            parseFloat(d.back_integral)){ }}
+                            <li>
+                                <a href="javascript:void(0);"
+                                   onclick="$eb.createModalFrame('退积分','{:Url('order.StoreOrder/integral_back')}?id={{d.id}}')">
+                                    <i class="fa fa-history"></i> 退积分
+                                </a>
+                            </li>
+                            {{# } }}
+                            <li>
+                                <a href="javascript:void(0);"
+                                   onclick="$eb.createModalFrame('订单记录','{:Url('order.StoreOrder/order_status')}?oid={{d.id}}')">
+                                    <i class="fa fa-newspaper-o"></i> 订单记录
+                                </a>
+                            </li>
+                        </ul>
+                        {{#  }; }}
+                    </script>
+                </div>
+            </div>
+        </div>
+    </div>
+    <!--end-->
+</div>
+<script src="{__ADMIN_PATH}js/layuiList.js"></script>
+{/block}
+{block name="script"}
+<script>
+    layList.tableList('List', "{:Url('order_list',['real_name'=>$real_name])}", function () {
+        return [
+            {type: 'checkbox'},
+            {field: 'order_id', title: '订单号', sort: true, event: 'order_id', width: '11%', templet: '#order_id'},
+            {field: 'nickname', title: '用户信息', templet: '#userinfo', width: '6%', align: 'center'},
+            {field: 'store', title: '门店', width: '6%', align: 'center'},
+            {field: 'point', title: '自提点', width: '6%', align: 'center'},
+            {field: 'spread_uid', title: '推荐人信息', templet: '#spread_uid', width: '8%', align: 'center'},
+            {field: 'info', title: '商品信息', templet: "#info", height: 'full-20'},
+            {field: 'pay_price', title: '支付金额', width: '6%', align: 'center'},
+            {field: 'deposit', title: '支付押金', width: '6%', align: 'center'},
+            {field: 'deposit_back', title: '已退押金', width: '6%', align: 'center'},
+            {field: 'use_integral', title: '使用积分', width: '6%', align: 'center'},
+            {field: 'paid', title: '支付状态', templet: '#paid', width: '6%', align: 'center'},
+            {field: 'status', title: '订单状态', templet: '#status', width: '6%', align: 'center'},
+            {field: 'add_time', title: '下单时间', width: '6%', sort: true, align: 'center'},
+            {field: 'right', title: '操作', align: 'center', toolbar: '#act', width: '10%'},
+        ];
+    });
+    layList.tool(function (event, data, obj) {
+        switch (event) {
+            case 'order_paid':
+                var url = layList.U({c: 'order.store_order', a: 'offline', p: {id: data.id}});
+                $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);
+                        } else
+                            return Promise.reject(res.data.msg || '修改失败')
+                    }).catch(function (err) {
+                        $eb.$swal('error', err);
+                    });
+                }, {'title': '您确定要修改支付状态吗?', 'text': '修改后将无法恢复,请谨慎操作!', 'confirm': '是的,我要修改'})
+                break;
+            case 'verify':
+                var url = layList.U({c: 'order.store_order', a: 'verify', p: {id: data.id}});
+                $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);
+                        } else
+                            return Promise.reject(res.data.msg || '核销失败')
+                    }).catch(function (err) {
+                        $eb.$swal('error', err);
+                    });
+                }, {'title': '您确定核销该订单吗?', 'text': '修改后将无法恢复,请谨慎操作!', 'confirm': '是的,我要核销'})
+                break;
+            case 'marke':
+                var url = layList.U({c: 'order.store_order', a: 'remark'}),
+                    id = data.id,
+                    make = data.remark;
+                $eb.$alert('textarea', {title: '请修改内容', value: make}, function (result) {
+                    if (result) {
+                        $.ajax({
+                            url: url,
+                            data: 'remark=' + result + '&id=' + id,
+                            type: 'post',
+                            dataType: 'json',
+                            success: function (res) {
+                                if (res.code == 200) {
+                                    $eb.$swal('success', res.msg);
+                                } else
+                                    $eb.$swal('error', res.msg);
+                            }
+                        })
+                    } else {
+                        $eb.$swal('error', '请输入要备注的内容');
+                    }
+                });
+                break;
+            case 'danger':
+                var url = layList.U({c: 'order.store_order', a: 'take_delivery', p: {id: data.id}});
+                $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);
+                        } else
+                            return Promise.reject(res.data.msg || '收货失败')
+                    }).catch(function (err) {
+                        $eb.$swal('error', err);
+                    });
+                }, {'title': '您确定要修改收货状态吗?', 'text': '修改后将无法恢复,请谨慎操作!', 'confirm': '是的,我要修改'})
+                break;
+            case 'order_info':
+                $eb.createModalFrame(data.nickname + '订单详情', layList.U({c: 'order.store_order',a: 'order_info', q: {oid: data.id}}));
+                break;
+            case 'order_print':
+                var url = layList.U({c: 'order.store_order', a: 'order_print', p: {id: data.id}});
+                $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);
+                        } else
+                            return Promise.reject(res.data.msg || '核销失败')
+                    }).catch(function (err) {
+                        $eb.$swal('error', err);
+                    });
+                }, {'title': '确认打印订单?', 'text': '是否确认打印!', 'confirm': '确定'})
+                break;
+        }
+    })
+    var action = {
+        del_order: function () {
+            var ids = layList.getCheckData().getIds('id');
+            if (ids.length) {
+                var url = layList.U({c: 'order.store_order', a: 'del_order'});
+                $eb.$swal('delete', function () {
+                    $eb.axios.post(url, {ids: ids}).then(function (res) {
+                        if (res.status == 200 && res.data.code == 200) {
+                            $eb.$swal('success', res.data.msg);
+                        } else
+                            return Promise.reject(res.data.msg || '删除失败')
+                    }).catch(function (err) {
+                        $eb.$swal('error', err);
+                    });
+                }, {'title': '您确定要修删除订单吗?', 'text': '删除后将无法恢复,请谨慎操作!', 'confirm': '是的,我要删除'})
+            } else {
+                layList.msg('请选择要删除的订单');
+            }
+        },
+        write_order: function () {
+            return $eb.createModalFrame('订单核销', layList.U({a: 'write_order'}), {w: 500, h: 400});
+        },
+    };
+    $('#container-action').find('button').each(function () {
+        $(this).on('click', function () {
+            var act = $(this).data('type');
+            action[act] && action[act]();
+        });
+    })
+    //下拉框
+    $(document).click(function (e) {
+        $('.layui-nav-child').hide();
+    })
+
+    function dropdown(that) {
+        var oEvent = arguments.callee.caller.arguments[0] || event;
+        oEvent.stopPropagation();
+        var offset = $(that).offset();
+        var top = offset.top - $(window).scrollTop();
+        var index = $(that).parents('tr').data('index');
+        $('.layui-nav-child').each(function (key) {
+            if (key != index) {
+                $(this).hide();
+            }
+        })
+        if ($(document).height() < top + $(that).next('ul').height()) {
+            $(that).next('ul').css({
+                'padding': 10,
+                'top': -($(that).parents('td').height() / 2 + $(that).height() + $(that).next('ul').height() / 2),
+                'min-width': 'inherit',
+                'position': 'absolute'
+            }).toggle();
+        } else {
+            $(that).next('ul').css({
+                'padding': 10,
+                'top': $(that).parents('td').height() / 2 + $(that).height(),
+                'min-width': 'inherit',
+                'position': 'absolute'
+            }).toggle();
+        }
+    }
+
+    var real_name = '<?=$real_name?>';
+    var orderCount = <?=json_encode($orderCount)?>, payTypeCount = <?=json_encode($payTypeCount)?>,
+        status = <?=$status ? $status : "''"?>;
+    require(['vue'], function (Vue) {
+        new Vue({
+            el: "#app",
+            data: {
+                badge: [],
+                payType: [
+                    {name: '全部', value: ''},
+                    {name: '微信支付', value: 1, count: payTypeCount.weixin},
+                    {name: '余额支付', value: 2, count: payTypeCount.yue},
+                    {name: '线下支付', value: 3, count: payTypeCount.offline},
+                ],
+                orderType: [
+                    {name: '全部', value: ''},
+                    {name: '普通订单', value: 1, count: orderCount.general},
+                    {name: '拼团订单', value: 2, count: orderCount.pink},
+                    {name: '秒杀订单', value: 3, count: orderCount.seckill},
+                    {name: '砍价订单', value: 4, count: orderCount.bargain},
+                    {name: '积分订单', value: 5, count: orderCount.integral},
+                    // {name: '限购订单', value: 6, count: orderCount.limit},
+                ],
+                orderStatus: [
+                    {name: '全部', value: ''},
+                    {name: '已卖出', value: 9, count: orderCount.ys},
+                    {name: '未发货', value: 1, count: orderCount.wf, class: true},
+                    {name: '待核销', value: 5, count: orderCount.write_off, class: true},
+                    {name: '未支付', value: 0, count: orderCount.wz},
+                    {name: '待收货', value: 2, count: orderCount.ds},
+                    {name: '待评价', value: 3, count: orderCount.dp},
+                    {name: '交易完成', value: 4, count: orderCount.jy},
+                    {name: '退款中', value: -1, count: orderCount.tk, class: true},
+                    {name: '已退款', value: -2, count: orderCount.yt},
+                    {name: '已删除', value: -4, count: orderCount.del},
+                ],
+                dataList: [
+                    {name: '全部', value: ''},
+                    {name: '今天', value: 'today'},
+                    {name: '昨天', value: 'yesterday'},
+                    {name: '最近7天', value: 'lately7'},
+                    {name: '最近30天', value: 'lately30'},
+                    {name: '本月', value: 'month'},
+                    {name: '本年', value: 'year'},
+                ],
+                where: {
+                    data: '',
+                    status: status,
+                    type: '',
+                    pay_type: '',
+                    real_name: real_name || '',
+                    excel: 0,
+                },
+                showtime: false,
+            },
+            watch: {
+                'where.status': function () {
+                    this.where.excel = 0;
+                    this.getBadge();
+                    layList.reload(this.where, true);
+                },
+                'where.data': function () {
+                    this.where.excel = 0;
+                    this.getBadge();
+                    layList.reload(this.where, true);
+                },
+                'where.type': function () {
+                    this.where.excel = 0;
+                    this.getBadge();
+                    layList.reload(this.where, true);
+                },
+                'where.pay_type': function () {
+                    this.where.excel = 0;
+                    this.getBadge();
+                    layList.reload(this.where, true);
+                }
+            },
+            methods: {
+                setData: function (item) {
+                    var that = this;
+                    if (item.is_zd == true) {
+                        that.showtime = true;
+                        this.where.data = this.$refs.date_time.innerText;
+                    } else {
+                        this.showtime = false;
+                        this.where.data = item.value;
+                    }
+                },
+                getBadge: function () {
+                    var that = this;
+                    layList.basePost(layList.Url({
+                        c: 'merchant.system_store',
+                        a: 'getOrderBadge'
+                    }), this.where, function (rem) {
+                        that.badge = rem.data;
+                    });
+                },
+                search: function () {
+                    this.where.excel = 0;
+                    this.getBadge();
+                    layList.reload(this.where, true);
+                },
+                refresh: function () {
+                    layList.reload();
+                    this.getBadge();
+                },
+                excel: function () {
+                    this.where.excel = 1;
+                    location.href = layList.U({c: 'merchant.system_store', a: 'order_list', q: this.where});
+                    this.where.excel = 0;
+                }
+            },
+            mounted: function () {
+                var that = this;
+                that.getBadge();
+                window.formReload = this.search;
+                layList.laydate.render({
+                    elem: this.$refs.date_time,
+                    trigger: 'click',
+                    eventElem: this.$refs.time,
+                    range: true,
+                    change: function (value) {
+                        that.where.data = value;
+                    }
+                });
+            }
+        })
+    });
+</script>
+{/block}

+ 88 - 0
app/admin/view/merchant/system_store/write_order.php

@@ -0,0 +1,88 @@
+{extend name="public/container"}
+{block name="content"}
+<div class="layui-fluid">
+    <div class="layui-row layui-col-space15"  id="app">
+        <!--搜索条件-->
+        <div class="layui-col-md12" v-cloak="">
+            <div class="layui-card">
+                <div class="layui-card-body">
+                    <div class="layui-form-item" style="padding-top: 20px;">
+                        <input style="height: 50px;line-height: 1.5;display: inline;width: 80%;" v-model="verify_code" type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入核销码" class="layui-input">
+                        <button style="height: 50px;border-radius: 15px;" type="button" class="layui-btn layui-btn-normal" @click="verify">验证</button>
+                    </div>
+                    <fieldset class="layui-elem-field" v-if="orderInfo.uid">
+                        <legend>订单信息</legend>
+                        <div class="layui-field-box">
+                            <div class="layui-form">
+                                <table class="layui-table">
+                                    <tbody>
+                                        <tr>
+                                            <td>订 单 号</td>
+                                            <td>{{orderInfo.order_id}}</td>
+                                        </tr>
+                                        <tr>
+                                            <td>购买金额</td>
+                                            <td>{{orderInfo.pay_price}}</td>
+                                        </tr>
+                                        <tr>
+                                            <td>购买用户</td>
+                                            <td>{{orderInfo.nickname}}</td>
+                                        </tr>
+                                    </tbody>
+                                </table>
+                            </div>
+                        </div>
+                    </fieldset>
+                    <div class="layui-form-item" style="padding-top: 50px;text-align: center;padding-bottom: 30px;">
+                        <button type="button" class="layui-btn layui-btn-normal" @click="confirm">立即核销</button>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+<script src="{__ADMIN_PATH}js/layuiList.js"></script>
+{/block}
+{block name='script'}
+<script>
+    require(['vue'],function(Vue) {
+        new Vue({
+            el: "#app",
+            data: {
+                verify_code:'',
+                orderInfo:{},
+                is_confirm:false,
+            },
+            methods:{
+                verify:function(){
+                    var that = this;
+                    var reg = /[0-9]{12}/;
+                    if(!this.verify_code) return layList.msg('请填写核销码!');
+                    if(!reg.test(this.verify_code)) return layList.msg('请填写正确的核销码!');
+                    layList.baseGet(layList.U({a:'write_order',q:{verify_code:this.verify_code,is_confirm:0}}),function (res) {
+                        that.orderInfo = res.data;
+                        that.is_confirm = true;
+                    },function (res) {
+                        layList.msg(res.msg);
+                    });
+                },
+                confirm:function () {
+                    var that = this;
+                    if(that.is_confirm === false) return layList.msg('请先验证订单!');
+                    layList.baseGet(layList.U({a:'write_order',q:{verify_code:that.verify_code,is_confirm:1}}),function (res) {
+                        layList.msg(res.msg,function () {
+                            parent.$(".J_iframe:visible")[0].contentWindow.formReload();
+                            parent.layer.close(parent.layer.getFrameIndex(window.name));
+                        });
+                    },function (res) {
+                        layList.msg(res.msg);
+                    });
+                }
+            },
+            mounted:function () {
+
+            }
+        })
+    })
+</script>
+{/block}

+ 5 - 3
app/admin/view/order/store_order/index.php

@@ -578,8 +578,10 @@
     layList.tableList('List', "{:Url('order_list',['real_name'=>$real_name])}", function () {
         return [
             {type: 'checkbox'},
-            {field: 'order_id', title: '订单号', sort: true, event: 'order_id', width: '12%', templet: '#order_id'},
-            {field: 'nickname', title: '用户信息', templet: '#userinfo', width: '8%', align: 'center'},
+            {field: 'order_id', title: '订单号', sort: true, event: 'order_id', width: '11%', templet: '#order_id'},
+            {field: 'nickname', title: '用户信息', templet: '#userinfo', width: '6%', align: 'center'},
+            {field: 'store', title: '门店', width: '6%', align: 'center'},
+            {field: 'point', title: '自提点', width: '6%', align: 'center'},
             {field: 'spread_uid', title: '推荐人信息', templet: '#spread_uid', width: '8%', align: 'center'},
             {field: 'info', title: '商品信息', templet: "#info", height: 'full-20'},
             {field: 'pay_price', title: '支付金额', width: '6%', align: 'center'},
@@ -588,7 +590,7 @@
             {field: 'use_integral', title: '使用积分', width: '6%', align: 'center'},
             {field: 'paid', title: '支付状态', templet: '#paid', width: '6%', align: 'center'},
             {field: 'status', title: '订单状态', templet: '#status', width: '6%', align: 'center'},
-            {field: 'add_time', title: '下单时间', width: '10%', sort: true, align: 'center'},
+            {field: 'add_time', title: '下单时间', width: '6%', sort: true, align: 'center'},
             {field: 'right', title: '操作', align: 'center', toolbar: '#act', width: '10%'},
         ];
     });

+ 9 - 0
app/admin/view/system/system_store/add.php

@@ -36,6 +36,14 @@
                                     </i-Col>
                                 </Row>
                             </Form-Item>
+                            <Form-Item>
+                                <Row>
+                                    <i-Col span="13">
+                                        <span>门店店长:</span>
+                                        <i-Input placeholder="门店店长" v-model="form.leader" style="width: 80%" type="text"></i-Input>
+                                    </i-Col>
+                                </Row>
+                            </Form-Item>
                             <Form-Item>
                                 <Row>
                                     <i-Col span="13">
@@ -153,6 +161,7 @@
                     form:{
                         name:storeData.name || '',
                         introduction:storeData.introduction || '',
+                        leader:storeData.leader || '',
                         phone:storeData.phone || '',
                         address:storeData.address || [],
                         image:storeData.image || '',

+ 210 - 0
app/admin/view/system/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>

+ 58 - 18
app/admin/view/system/system_store/index.php

@@ -6,14 +6,17 @@
 <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('index',['type'=>1])}{/eq}">显示中的门店({$show})</a>
+            <li lay-id="list" {eq name='type' value='1' }class="layui-this" {
+            /eq}>
+            <a href="{eq name='type' value='1'}javascript:;{else}{:Url('index',['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('index',['type'=>2])}{/eq}">隐藏中的门店({$hide})</a>
+            <li lay-id="list" {eq name='type' value='2' }class="layui-this" {
+            /eq}>
+            <a href="{eq name='type' value='2'}javascript:;{else}{:Url('index',['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('index',['type'=>3])}{/eq}">回收站的门店({$recycle})</a>
+            <li lay-id="list" {eq name='type' value='3' }class="layui-this" {
+            /eq}>
+            <a href="{eq name='type' value='3'}javascript:;{else}{:Url('index',['type'=>3])}{/eq}">回收站的门店({$recycle})</a>
             </li>
         </ul>
     </div>
@@ -32,10 +35,14 @@
                             </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>
+                                    <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>
@@ -45,7 +52,7 @@
         </div>
         <div class="layui-col-md12">
             <div class="layui-card">
-<!--                <div class="layui-card-header">门店列表</div>-->
+                <!--                <div class="layui-card-header">门店列表</div>-->
                 <div class="layui-card-body">
                     <div class="layui-btn-container">
                         <button class="layui-btn layui-btn-sm"
@@ -67,6 +74,18 @@
                         <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='stock'>
+                            门店库存
+                        </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='pick_point'>
+                            自提点列表
+                        </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){ }}
                             恢复门店
@@ -84,28 +103,31 @@
 {/block}
 {block name="script"}
 <script>
-    var type=<?=$type?>;
+    var type = <?=$type?>;
     layList.tableList('List', "{:Url('list',['type'=>$type])}", function () {
         return [
             {field: 'id', title: 'ID', sort: true, event: 'id', width: '4%'},
             {field: 'image', title: '门店图片', templet: '#headimgurl', width: '6%'},
             {field: 'name', title: '门店名称', width: '10%'},
-            {field: 'phone', title: '门店电话', width: '10%'},
+            {field: 'leader', title: '门店店长', width: '8%'},
+            {field: 'phone', title: '门店电话', width: '8%'},
+            {field: 'deposit', title: '总押金', width: '6%'},
+            {field: 'deposit_back', title: '已退押金', width: '6%'},
             {field: 'address', title: '地址', templet: '#address'},
-            {field: 'day_time', title: '营业时间', width: '15%'},
+            {field: 'day_time', title: '营业时间', width: '10%'},
             // {field: 'valid_time', title: '核销有效日期', width: '11%'},
             {field: 'status', title: '是否显示', templet: "#checkboxstatus", width: '8%'},
             {field: 'right', title: '操作', align: 'center', toolbar: '#act', width: '14%'},
         ];
     });
     //查询条件
-    layList.search('search',function(where){
+    layList.search('search', function (where) {
         layList.reload(where);
     });
     //excel下载
-    layList.search('export',function(where){
+    layList.search('export', function (where) {
         where.excel = 1;
-        location.href=layList.U({c:'system.system_store',a:'list',q:where});
+        location.href = layList.U({c: 'system.system_store', a: 'list', q: where});
     })
     //门店是否显示
     layList.switch('is_show', function (odj, value) {
@@ -136,7 +158,7 @@
         switch (event) {
             case 'del':
                 var url = layList.U({c: 'system.system_store', a: 'delete', q: {id: data.id}});
-                if(data.is_del) var code = {title:"操作提示",text:"确定恢复门店吗?",type:'info',confirm:'是的,恢复该门店'};
+                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) {
@@ -157,6 +179,24 @@
             case 'edit':
                 $eb.createModalFrame(data.name + '-编辑', layList.U({a: 'add', q: {id: data.id}}), {h: 700, w: 1100});
                 break;
+            case 'stock':
+                $eb.createModalFrame(data.name + '-库存', layList.U({a: 'storeProductInfo', q: {id: data.id}}), {
+                    h: 700,
+                    w: 1100
+                });
+                break;
+            case 'pick_point':
+                $eb.createModalFrame(data.name + '-自提点', layList.U({a: 'store_point', q: {id: data.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>

+ 137 - 0
app/admin/view/system/system_store/product_list.php

@@ -0,0 +1,137 @@
+{extend name="public/container"}
+{block name="content"}
+<style type="text/css">
+    .form-add {
+        position: fixed;
+        left: 0;
+        bottom: 0;
+        width: 100%;
+    }
+
+    .form-add .sub-btn {
+        border-radius: 0;
+        width: 100%;
+        padding: 6px 0;
+        font-size: 14px;
+        outline: none;
+        border: none;
+        color: #fff;
+        background-color: #2d8cf0;
+    }
+</style>
+<div class="layui-fluid">
+    <div class="layui-row layui-col-space15" id="app">
+        <div class="layui-col-md12">
+            <div class="layui-card">
+                <div class="layui-card-header">搜索条件</div>
+                <div class="layui-card-body">
+                    <form class="layui-form layui-form-pane" action="">
+                        <div class="layui-inline">
+                            <label class="layui-form-label">所有分类</label>
+                            <div class="layui-input-block">
+                                <select name="cate_id">
+                                    <option value=" ">全部</option>
+                                    {volist name='cate' id='vo'}
+                                    <option value="{$vo.id}">{$vo.html}{$vo.cate_name}</option>
+                                    {/volist}
+                                </select>
+                            </div>
+                        </div>
+                        <div class="layui-inline">
+                            <label class="layui-form-label">商品名称</label>
+                            <div class="layui-input-block">
+                                <input type="text" name="store_name" class="layui-input" placeholder="请输入商品名称,关键字,编号">
+                            </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>
+                            </div>
+                        </div>
+                    </form>
+                </div>
+            </div>
+        </div>
+        <div class="layui-col-md12">
+            <div class="layui-card">
+                <div class="layui-card-body">
+                    <div class="layui-btn-container" id="container-action">
+                        <button class="layui-btn layui-btn-sm" data-type="yes_it_is">批量选择</button>
+                    </div>
+                    <table class="layui-hide" id="List" lay-filter="List"></table>
+                    <!--图片-->
+                    <script type="text/html" id="image">
+                        <img style="cursor: pointer" lay-event="open_image" src="{{d.image}}">
+                    </script>
+                    <!--操作-->
+                    <script type="text/html" id="act">
+                        <button type="button" class="layui-btn layui-btn-normal layui-btn-sm select" lay-event='select'>
+                            选择
+                        </button>
+                    </script>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+<script src="{__ADMIN_PATH}js/layuiList.js"></script>
+{/block}
+{block name='script'}
+<script>
+    var parentinputname = '{$Request.param.fodder}';
+    layList.form.render();
+    //加载列表
+    layList.tableList('List', "{:Url('store.store_product/product_unique_ist',['type'=>1])}", function () {
+        return [
+            {type: 'checkbox'},
+            // {field: 'product_id', title: 'ID', sort: true, event: 'id', width: '8%'},
+            {field: 'image', title: '商品图片', templet: '#image', width: '12%'},
+            {field: 'store_name', title: '商品名称', templet: '#store_name', width: '30%'},
+            {field: 'suk', title: '规格', width: '20%'},
+            {field: 'right', title: '操作', align: 'center', toolbar: '#act'}
+        ]
+    });
+    //点击事件绑定
+    layList.tool(function (event, data) {
+        switch (event) {
+            case 'select':
+                parent.$f.changeField('product', [data.image]);
+                parent.$f.changeField('product_id', [data.product_id]);
+                parent.$f.changeField('unique', [data.unique]);
+                parent.$f.closeModal(parentinputname);
+                break;
+        }
+    })
+    //查询
+    layList.search('search', function (where) {
+        layList.reload(where);
+    });
+    var action = {
+        yes_it_is: function () {
+            var uniques = layList.getCheckData().getIds('unique');
+            var product_ids = layList.getCheckData().getIds('product_id');
+            var product = layList.getCheckData().getIds('image');
+            if (uniques.length) {
+                // console.log(uniques)
+                // console.log(product_ids)
+                // console.log(product)
+                parent.$f.changeField('product', product);
+                parent.$f.changeField('product_id', product_ids);
+                parent.$f.changeField('unique', uniques);
+                parent.$f.closeModal(parentinputname);
+            } else {
+                layList.msg('请选择商品');
+            }
+        },
+    };
+    $('#container-action').find('button').each(function () {
+        $(this).on('click', function () {
+            var act = $(this).data('type');
+            action[act] && action[act]();
+        });
+    })
+</script>
+{/block}

+ 60 - 0
app/admin/view/system/system_store/stock_log.php

@@ -0,0 +1,60 @@
+{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-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-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>
+                            </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">
+                <table class="layui-hide" id="List" lay-filter="List"></table>
+                <script type="text/html" id="number">
+                    {{# if(d.pm === 1){ }}
+                    <font color="green">+{{d.number}}</font>
+                    {{# }else{ }}
+                    <font color="red">-{{d.number}}</font>
+                    {{# } }}
+                </script>
+            </div>
+        </div>
+    </div>
+</div>
+</div>
+<script src="{__ADMIN_PATH}js/layuiList.js"></script>
+{/block}
+{block name="script"}
+<script>
+    layList.tableList('List', "{:Url('stock_log_list',array('id'=>$id))}", function () {
+        return [
+            {field: 'id', title: 'ID', sort: true, event: 'id', width: '4%'},
+            {field: '_add_time', title: '添加时间', width: '26%'},
+            {field: 'adder', title: '添加人', width: '10%'},
+            {field: 'mark', title: '事件', width: '50%'},
+            {field: 'number', title: '数值', width: '10%', templet: '#number'},
+        ];
+    });
+    //查询条件
+    layList.search('search', function (where) {
+        layList.reload(where);
+    });
+</script>
+{/block}

+ 65 - 0
app/admin/view/system/system_store/store_bill_log.php

@@ -0,0 +1,65 @@
+{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-row layui-col-space15">
+        <div class="layui-col-md12">
+            <div class="layui-card">
+                <div class="layui-card-body">
+                    <div class="alert alert-success alert-dismissable">
+                        <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
+                        总佣金:{$all}
+                    </div>
+                    <form class="layui-form layui-form-pane" action="">
+                        <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>
+                            </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">
+                <table class="layui-hide" id="List" lay-filter="List"></table>
+                <script type="text/html" id="number">
+                    {{# if(d.pm === 1){ }}
+                    <font color="green">+{{d.number}}</font>
+                    {{# }else{ }}
+                    <font color="red">-{{d.number}}</font>
+                    {{# } }}
+                </script>
+            </div>
+        </div>
+    </div>
+</div>
+</div>
+<script src="{__ADMIN_PATH}js/layuiList.js"></script>
+{/block}
+{block name="script"}
+<script>
+    layList.tableList('List', "{:Url('store_bill_log_list',array('id'=>$id))}", function () {
+        return [
+            {field: 'id', title: 'ID', sort: true, event: 'id', width: '4%'},
+            {field: '_add_time', title: '添加时间', width: '16%'},
+            {field: 'title', title: '类型', width: '15%'},
+            {field: 'mark', title: '事件', width: '40%'},
+            {field: '_status', title: '状态', width: '15%'},
+            {field: 'number', title: '数值', width: '10%', templet: '#number'},
+        ];
+    });
+    //查询条件
+    layList.search('search', function (where) {
+        layList.reload(where);
+    });
+</script>
+{/block}

+ 185 - 0
app/admin/view/system/system_store/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('store_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('store_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('store_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}

+ 207 - 0
app/admin/view/system/system_store/store_product_info.php

@@ -0,0 +1,207 @@
+{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-row layui-col-space15">
+        <div class="layui-col-md12" id="app">
+            <div class="layui-card">
+                <div class="layui-card-body">
+                    <form class="layui-form layui-form-pane" action="">
+                        <div class="layui-col-lg12">
+                            <label class="layui-form-label">创建时间:</label>
+                            <div class="layui-input-block" data-type="data" v-cloak="">
+                                <button class="layui-btn layui-btn-sm" style="margin-top: auto;height: 38px;"
+                                        type="button" v-for="item in dataList"
+                                        @click="setData(item)"
+                                        :class="{'layui-btn-primary':where.data!=item.value}">{{item.name}}
+                                </button>
+                                <button class="layui-btn layui-btn-sm" style="margin-top: auto;height: 38px;"
+                                        type="button" ref="time"
+                                        @click="setData({value:'zd',is_zd:true})"
+                                        :class="{'layui-btn-primary':where.data!='zd'}">自定义
+                                </button>
+                                <button type="button" style="margin-top: auto;height: 38px;"
+                                        class="layui-btn layui-btn-sm layui-btn-primary"
+                                        v-show="showtime==true" ref="date_time">{$year.0} - {$year.1}
+                                </button>
+                            </div>
+                        </div>
+                    </form>
+                    <br/>
+                    <div class="layui-inline">
+                        <div class="layui-input-inline">
+                            <button class="layui-btn layui-btn-sm layui-btn-normal" @click="search()">
+                                <i class="layui-icon layui-icon-search"></i>搜索
+                            </button>
+                            <button class="layui-btn layui-btn-primary layui-btn-sm export" @click="excel()">
+                                <i class="fa fa-floppy-o" style="margin-right: 3px;"></i>导出
+                            </button>
+                        </div>
+                    </div>
+                </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_stock',array('id'=>$id))}',{h:700,w:1100})">
+                            添加库存
+                        </button>
+                    </div>
+                    <table class="layui-hide" id="List" lay-filter="List"></table>
+                    <script type="text/html" id="store_name">
+                        {{d.product_info.store_name}}
+                    </script>
+                    <script type="text/html" id="suk">
+                        {{d.product_info.product_attr_info.suk}}
+                    </script>
+                    <script type="text/html" id="headimgurl">
+                        <img style="cursor: pointer" lay-event='open_image'
+                             src="{{d.product_info.product_attr_info.image}}">
+                    </script>
+                    <script type="text/html" id="act">
+                        <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" lay-event='add'>
+                            补货
+                        </button>
+                        <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" lay-event='log'>
+                            记录
+                        </button>
+                    </script>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+<script src="{__ADMIN_PATH}js/layuiList.js"></script>
+{/block}
+{block name="script"}
+<script>
+    let store_id = "{$id}";
+    layList.tableList('List', "{:Url('stock_list',array('id'=>$id))}", function () {
+        return [
+            {field: 'id', title: 'ID', sort: true, event: 'id', width: '4%'},
+            {field: 'image', title: '商品图片', templet: '#headimgurl', width: '6%'},
+            {field: 'store_name', title: '商品名称', templet: '#store_name'},
+            {field: 'suk', title: '规格', templet: '#suk', width: '10%'},
+            {field: 'stock', title: '库存', width: '8%'},
+            {field: 'wait_check', title: '待核销', width: '8%'},
+            {field: 'wait_send', title: '待送货', width: '8%'},
+            {field: 'sales', title: '销量', width: '8%'},
+            {field: 'right', title: '操作', align: 'center', toolbar: '#act', width: '10%'},
+        ];
+    });
+    // //查询条件
+    // layList.search('search', function (where) {
+    //     layList.reload(where);
+    // });
+    // layList.search('export', function (where) {
+    //     where.excel = 1;
+    //     where.id = store_id;
+    //     location.href = layList.U({c: 'system.system_store', a: 'stock_list', q: where});
+    // })
+    //点击事件绑定
+    layList.tool(function (event, data, obj) {
+        switch (event) {
+            case 'open_image':
+                $eb.openImage(data.image);
+                break;
+            case 'add':
+                $eb.createModalFrame(data.product_info.store_name + '-添加库存', layList.U({
+                    a: 'add_stock',
+                    q: {id: data.store_id, product_id: data.product_id, unique: data.unique}
+                }), {
+                    h: 700,
+                    w: 1100
+                });
+                break;
+            case 'log':
+                $eb.createModalFrame(data.product_info.store_name + '-库存记录', layList.U({
+                    a: 'stock_log',
+                    q: {id: data.id}
+                }), {
+                    h: 700,
+                    w: 1100
+                });
+                break;
+        }
+    })
+
+    require(['vue'], function (Vue) {
+        new Vue({
+            el: "#app",
+            data: {
+                dataList: [
+                    {name: '全部', value: ''},
+                    {name: '今天', value: 'today'},
+                    {name: '昨天', value: 'yesterday'},
+                    {name: '最近7天', value: 'lately7'},
+                    {name: '最近30天', value: 'lately30'},
+                    {name: '本月', value: 'month'},
+                    {name: '本年', value: 'year'},
+                ],
+                where: {
+                    data: '',
+                    product_id: '',
+                    excel: 0,
+                    id: store_id,
+                },
+                showtime: false,
+            },
+            // watch: {
+            //     'where.data': function () {
+            //         this.where.excel = 0;
+            //         console.log(this.where)
+            //         layList.reload(this.where, true);
+            //     },
+            // },
+            methods: {
+                setData: function (item) {
+                    var that = this;
+                    if (item.is_zd == true) {
+                        that.showtime = true;
+                        this.where.data = this.$refs.date_time.innerText;
+                    } else {
+                        this.showtime = false;
+                        this.where.data = item.value;
+                    }
+                },
+                search: function () {
+                    // try {
+                    this.where.excel = 0;
+                    // this.where.id = store_id;
+                    //     let where = Object.assign({}, this.where)
+                    //     console.log(where)
+                    layList.reload(this.where, true);
+                    // } catch (e) {
+                    //     console.log(e)
+                    // }
+                },
+                excel: function () {
+                    this.where.excel = 1;
+                    // this.where.id = store_id;
+                    location.href = layList.U({c: 'system.system_store', a: 'stock_list', q: this.where});
+                    this.where.excel = 0;
+                }
+            },
+            mounted: function () {
+                var that = this;
+                window.formReload = this.search;
+                layList.laydate.render({
+                    elem: this.$refs.date_time,
+                    trigger: 'click',
+                    eventElem: this.$refs.time,
+                    range: true,
+                    change: function (value) {
+                        that.where.data = value;
+                    }
+                });
+            }
+        })
+    });
+</script>
+{/block}

+ 20 - 0
app/api/controller/PublicController.php

@@ -299,6 +299,26 @@ class PublicController
         return app('json')->successful($data);
     }
 
+
+    /**
+     * 门店列表
+     * @return mixed
+     */
+    public function point_list($id, Request $request)
+    {
+        list($latitude, $longitude, $page, $limit) = UtilService::getMore([
+            ['latitude', ''],
+            ['longitude', ''],
+            ['page', 1],
+            ['limit', 10],
+        ], $request, true);
+        $list = SystemStore::point_lst($latitude, $longitude, $page, $limit, $id);
+        if (!$list) $list = [];
+        $data['list'] = $list;
+        $data['tengxun_map_key'] = sys_config('tengxun_map_key');
+        return app('json')->successful($data);
+    }
+
     /**
      * 查找城市数据
      * @param Request $request

+ 3 - 3
app/api/controller/order/StoreOrderController.php

@@ -164,9 +164,9 @@ class StoreOrderController
         $uid = $request->uid();
         if (StoreOrder::be(['order_id|unique' => $key, 'uid' => $uid, 'is_del' => 0]))
             return app('json')->status('extend_order', '订单已生成', ['orderId' => $key, 'key' => $key]);
-        list($addressId, $couponId, $payType, $useIntegral, $mark, $combinationId, $pinkId, $seckill_id, $integral_id, $formId, $bargainId, $from, $shipping_type, $real_name, $phone, $storeId) = UtilService::postMore([
+        list($addressId, $couponId, $payType, $useIntegral, $mark, $combinationId, $pinkId, $seckill_id, $integral_id, $formId, $bargainId, $from, $shipping_type, $real_name, $phone, $storeId, $pointId) = UtilService::postMore([
             'addressId', 'couponId', 'payType', ['useIntegral', 0], 'mark', ['combinationId', 0], ['pinkId', 0], ['seckill_id', 0], ['integral_id', 0], ['formId', ''], ['bargainId', ''], ['from', 'weixin'],
-            ['shipping_type', 1], ['real_name', ''], ['phone', ''], ['store_id', 0]
+            ['shipping_type', 1], ['real_name', ''], ['phone', ''], ['store_id', 0], ['point_id', 0]
         ], $request, true);
         $payType = strtolower($payType);
         if ($bargainId) {
@@ -189,7 +189,7 @@ class StoreOrderController
             $isChannel = 0;
         elseif ($from == 'weixinh5')
             $isChannel = 2;
-        $order = StoreOrder::cacheKeyCreateOrder($request->uid(), $key, $addressId, $payType, (int)$useIntegral, $couponId, $mark, $combinationId, $pinkId, $seckill_id, $bargainId, $integral_id, false, $isChannel, $shipping_type, $real_name, $phone, $storeId);
+        $order = StoreOrder::cacheKeyCreateOrder($request->uid(), $key, $addressId, $payType, (int)$useIntegral, $couponId, $mark, $combinationId, $pinkId, $seckill_id, $bargainId, $integral_id, false, $isChannel, $shipping_type, $real_name, $phone, $storeId, $pointId);
         if ($order === false) return app('json')->fail(StoreOrder::getErrorInfo('订单生成失败'));
         $orderId = $order['order_id'];
         $info = compact('orderId', 'key');

+ 14 - 7
app/models/store/StoreOrder.php

@@ -9,6 +9,7 @@ namespace app\models\store;
 
 use app\admin\model\system\ShippingTemplatesFree;
 use app\admin\model\system\ShippingTemplatesRegion;
+use app\admin\model\system\SystemStorePoint;
 use crmeb\basic\BaseModel;
 use think\db\exception\DataNotFoundException;
 use think\db\exception\DbException;
@@ -276,7 +277,7 @@ class StoreOrder extends BaseModel
      * @throws \think\exception\DbException
      */
 
-    public static function cacheKeyCreateOrder($uid, $key, $addressId, $payType, $useIntegral = false, $couponId = 0, $mark = '', $combinationId = 0, $pinkId = 0, $seckill_id = 0, $bargain_id = 0, $integral_id = 0, $test = false, $isChannel = 0, $shipping_type = 1, $real_name = '', $phone = '', $storeId = 0)
+    public static function cacheKeyCreateOrder($uid, $key, $addressId, $payType, $useIntegral = false, $couponId = 0, $mark = '', $combinationId = 0, $pinkId = 0, $seckill_id = 0, $bargain_id = 0, $integral_id = 0, $test = false, $isChannel = 0, $shipping_type = 1, $real_name = '', $phone = '', $storeId = 0, $pointId = 0)
     {
         self::beginTrans();
         try {
@@ -375,9 +376,9 @@ class StoreOrder extends BaseModel
                 //门店自提没有邮费支付
                 $priceGroup['storePostage'] = 0;
                 $payPostage = 0;
-//                if (!$storeId && !$test) {
-//                    return self::setErrorInfo('请选择门店', true);
-//                }
+                if (!$pointId && !$test) {
+                    return self::setErrorInfo('请选择自提点', true);
+                }
             }
 
 
@@ -464,11 +465,17 @@ class StoreOrder extends BaseModel
                 'deposit_back' => 0,
                 'deposit_status' => 0,
             ];
-//            if ($shipping_type === 2) {
-            $orderInfo['verify_code'] = self::getStoreCode();
             $orderInfo['store_id'] = SystemStore::getStoreDispose($storeId, 'id');
             if (!$orderInfo['store_id']) return self::setErrorInfo('暂无门店无法选择门店!', true);
-//            }
+            if ($shipping_type === 2) {
+                $orderInfo['verify_code'] = self::getStoreCode();
+                $orderInfo['point_id'] = SystemStorePoint::verificWhere()->where('store_id', $orderInfo['store_id'])->where('id', $pointId)->value('id');
+                if (!$orderInfo['point_id']) return self::setErrorInfo('找不到对应自提点!', true);
+            }
+            //门店库存
+            $res4 = SystemStore::decStock($orderInfo);
+            if (!$res4) return self::setErrorInfo(SystemStore::getErrorInfo(), true);
+
             $order = self::create($orderInfo);
             if (!$order) return self::setErrorInfo('订单生成失败!', true);
             $res5 = true;

+ 62 - 1
app/models/system/SystemStore.php

@@ -3,8 +3,15 @@
 
 namespace app\models\system;
 
+use app\admin\model\system\SystemStorePoint;
+use app\admin\model\system\SystemStoreProductStockLog;
+use app\models\store\StoreOrderCartInfo;
+use app\models\user\User;
 use crmeb\traits\ModelTrait;
 use crmeb\basic\BaseModel;
+use think\db\exception\DataNotFoundException;
+use think\db\exception\DbException;
+use think\db\exception\ModelNotFoundException;
 
 /**
  * 门店自提 model
@@ -148,7 +155,7 @@ class SystemStore extends BaseModel
     {
         $model = new self();
         $model = $model->where('is_del', 0);
-        $model = $model->where('is_show',1);
+        $model = $model->where('is_show', 1);
         if ($latitude && $longitude) {
             $model = $model->field(['*', self::distanceSql($latitude, $longitude)])->order('distance asc');
         }
@@ -169,4 +176,58 @@ class SystemStore extends BaseModel
         return $list;
     }
 
+    /**
+     * 门店列表
+     * @return mixed
+     */
+    public static function point_lst($latitude, $longitude, $page, $limit, $store_id)
+    {
+        $model = new SystemStorePoint();
+        $model = $model->where('is_del', 0);
+        $model = $model->where('store_id', $store_id);
+        $model = $model->where('is_show', 1);
+        if ($latitude && $longitude) {
+            $model = $model->field(['*', self::distanceSql($latitude, $longitude)])->order('distance asc');
+        }
+        $list = $model->page((int)$page, (int)$limit)
+            ->select()
+            ->hidden(['is_show', 'is_del'])
+            ->toArray();
+        if ($latitude && $longitude) {
+            foreach ($list as &$value) {
+                //计算距离
+                $value['distance'] = sqrt((pow((($latitude - $value['latitude']) * 111000), 2)) + (pow((($longitude - $value['longitude']) * 111000), 2)));
+                //转换单位
+                $value['range'] = bcdiv($value['distance'], 1000, 1);
+            }
+//            $distanceKey = array_column($list, 'distance');
+//            array_multisort($distanceKey, SORT_ASC, $list);
+        }
+        return $list;
+    }
+
+
+    /**
+     * @param $orderInfo
+     * @return bool
+     * @throws DataNotFoundException
+     * @throws DbException
+     * @throws ModelNotFoundException
+     */
+    public static function decStock($orderInfo)
+    {
+        $res = true;
+        if (!$orderInfo['store_id']) return $res;
+        $cartId = is_string($orderInfo['cart_id']) ? json_decode($orderInfo['cart_id'], true) : $orderInfo['cart_id'];
+        $cartInfo = StoreOrderCartInfo::whereIn('cart_id', $cartId)->column('cart_info');
+        $userInfo = User::getUserInfo($orderInfo['uid']);
+        foreach ($cartInfo as $value) {
+            $product = json_decode($value, true);
+            $cartNum = $product['cart_num'] ?? 0;
+            if (isset($product['productInfo'])) {
+                $res = SystemStoreProductStockLog::expend($orderInfo['store_id'], $product['product_id'], $product['product_attr_unique'], 'sale', $orderInfo['id'], $cartNum, 0, '用户' . $userInfo['nickname'] . '购买订单完成');
+            }
+        }
+        return $res ? $res : self::setErrorInfo(SystemStoreProductStockLog::getErrorInfo());
+    }
 }

+ 1 - 0
route/api/route.php

@@ -230,6 +230,7 @@ Route::group(function () {
 
     //门店列表
     Route::get('store_list', 'PublicController/store_list')->name('storeList');
+    Route::get('point_list/:id', 'PublicController/point_list')->name('pointList');
     //获取城市列表
     Route::get('city_list', 'PublicController/city_list')->name('cityList');