热门城市 - X
-全国城市
-功能简介:
-1、支持地址 精确/模糊 查询;
-2、支持POI点坐标显示;
-3、坐标鼠标跟随显示;
-使用说明:
-在搜索框搜索关键词后,地图上会显示相应poi点,同时左侧显示对应该点的信息,点击某点或某信息,右上角会显示相应该点的坐标和地址。
-diff --git a/bak_/btgym.xingtongworld.com_ka4TLL.tar.gz b/bak_/btgym.xingtongworld.com_ka4TLL.tar.gz new file mode 100644 index 0000000..a387632 Binary files /dev/null and b/bak_/btgym.xingtongworld.com_ka4TLL.tar.gz differ diff --git a/source/application/store/common.php b/source/application/store/common.php deleted file mode 100644 index c6b068c..0000000 --- a/source/application/store/common.php +++ /dev/null @@ -1,20 +0,0 @@ -checkPrivilege($url, $strict); - } catch (\Exception $e) { - return false; - } -} diff --git a/source/application/store/config.php b/source/application/store/config.php deleted file mode 100644 index 1920814..0000000 --- a/source/application/store/config.php +++ /dev/null @@ -1,33 +0,0 @@ - 'html', - - // 默认全局过滤方法 用逗号分隔多个 - 'default_filter' => 'trim,htmlspecialchars', - - // 模板设置 - 'template' => [ - // layout布局 - 'layout_on' => true, - 'layout_name' => 'layouts/layout', - // 模板引擎类型 支持 php think 支持扩展 - 'type' => 'think', - // 模板路径 - 'view_path' => '', - // 模板后缀 - 'view_suffix' => 'php', - // 模板文件名分隔符 - 'view_depr' => DS, - // 模板引擎普通标签开始标记 - 'tpl_begin' => '{{', - // 模板引擎普通标签结束标记 - 'tpl_end' => '}}', - // 标签库标签开始标记 - 'taglib_begin' => '{{', - // 标签库标签结束标记 - 'taglib_end' => '}}', - ], -]; diff --git a/source/application/store/controller/Controller.php b/source/application/store/controller/Controller.php deleted file mode 100644 index 1ef4192..0000000 --- a/source/application/store/controller/Controller.php +++ /dev/null @@ -1,229 +0,0 @@ -store = Session::get('yoshop_store'); - // 当前路由信息 - $this->getRouteinfo(); - // 验证登录状态 - $this->checkLogin(); - // 验证当前页面权限 - $this->checkPrivilege(); - // 全局layout - $this->layout(); - } - - /** - * 验证当前页面权限 - * @throws BaseException - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - */ - private function checkPrivilege() - { - if ($this->routeUri === 'index/index') { - return true; - } - if (!Auth::getInstance()->checkPrivilege($this->routeUri)) { - throw new BaseException(['msg' => '很抱歉,没有访问权限']); - } - return true; - } - - /** - * 全局layout模板输出 - * @throws \think\exception\DbException - * @throws \Exception - */ - private function layout() - { - // 验证当前请求是否在白名单 - if (!in_array($this->routeUri, $this->notLayoutAction)) { - // 输出到view - $this->assign([ - 'base_url' => base_url(), // 当前域名 - 'store_url' => url('/store'), // 后台模块url - 'group' => $this->group, // 当前控制器分组 - 'menus' => $this->menus(), // 后台菜单 - 'store' => $this->store, // 商家登录信息 - 'setting' => Setting::getAll() ?: null, // 当前商城设置 - 'request' => Request::instance(), // Request对象 - 'version' => get_version(), // 系统版本号 - ]); - } - } - - /** - * 解析当前路由参数 (分组名称、控制器名称、方法名) - */ - protected function getRouteinfo() - { - // 控制器名称 - $this->controller = toUnderScore($this->request->controller()); - // 方法名称 - $this->action = $this->request->action(); - // 控制器分组 (用于定义所属模块) - $groupstr = strstr($this->controller, '.', true); - $this->group = $groupstr !== false ? $groupstr : $this->controller; - // 当前uri - $this->routeUri = $this->controller . '/' . $this->action; - } - - /** - * 后台菜单配置 - * @return mixed - * @throws \think\exception\DbException - */ - protected function menus() - { - static $menus = []; - if (empty($menus)) { - $menus = Menus::getInstance()->getMenus($this->routeUri, $this->group); - } - return $menus; - } - - /** - * 验证登录状态 - * @return bool - */ - private function checkLogin() - { - // 验证当前请求是否在白名单 - if (in_array($this->routeUri, $this->allowAllAction)) { - return true; - } - // 验证登录状态 - if (empty($this->store) - || (int)$this->store['is_login'] !== 1 - || !isset($this->store['wxapp']) - || empty($this->store['wxapp']) - ) { - $this->redirect('passport/login'); - return false; - } - return true; - } - - /** - * 获取当前wxapp_id - */ - protected function getWxappId() - { - return $this->store['wxapp']['wxapp_id']; - } - - /** - * 返回封装后的 API 数据到客户端 - * @param int $code - * @param string $msg - * @param string $url - * @param array $data - * @return array - */ - protected function renderJson($code = 1, $msg = '', $url = '', $data = []) - { - return compact('code', 'msg', 'url', 'data'); - } - - /** - * 返回操作成功json - * @param string $msg - * @param string $url - * @param array $data - * @return array - */ - protected function renderSuccess($msg = 'success', $url = '', $data = []) - { - return $this->renderJson(1, $msg, $url, $data); - } - - /** - * 返回操作失败json - * @param string $msg - * @param string $url - * @param array $data - * @return array|bool - */ - protected function renderError($msg = 'error', $url = '', $data = []) - { - if ($this->request->isAjax()) { - return $this->renderJson(0, $msg, $url, $data); - } - $this->error($msg); - return false; - } - - /** - * 获取post数据 (数组) - * @param $key - * @return mixed - */ - protected function postData($key = null) - { - return $this->request->post(is_null($key) ? '' : $key . '/a'); - } - - /** - * 获取post数据 (数组) - * @param $key - * @return mixed - */ - protected function getData($key = null) - { - return $this->request->get(is_null($key) ? '' : $key); - } - -} diff --git a/source/application/store/controller/Goods.php b/source/application/store/controller/Goods.php deleted file mode 100644 index dfec8fb..0000000 --- a/source/application/store/controller/Goods.php +++ /dev/null @@ -1,144 +0,0 @@ -getList($goods_status, $category_id, $goods_name); - return $this->fetch('index', compact('list', 'catgory')); - } - - /** - * 添加商品 - * @return array|mixed - * @throws \think\exception\PDOException - */ - public function add() - { - if (!$this->request->isAjax()) { - // 商品分类 - $catgory = Category::getCacheTree(); - // 配送模板 - $delivery = Delivery::getAll(); - return $this->fetch('add', compact('catgory', 'delivery')); - } - $model = new GoodsModel; - if ($model->add($this->postData('goods'))) { - return $this->renderSuccess('添加成功', url('goods/index')); - } - return $this->renderError($model->getError() ?: '添加失败'); - } - - /** - * 一键复制 - * @param $goods_id - * @return array|mixed - * @throws \think\exception\PDOException - */ - public function copy($goods_id) - { - // 商品详情 - $model = GoodsModel::detail($goods_id); - if (!$this->request->isAjax()) { - // 商品分类 - $catgory = Category::getCacheTree(); - // 配送模板 - $delivery = Delivery::getAll(); - // 商品sku数据 - $specData = 'null'; - if ($model['spec_type'] == 20) { - $specData = json_encode($model->getManySpecData($model['spec_rel'], $model['sku']), JSON_UNESCAPED_SLASHES); - } - return $this->fetch('edit', compact('model', 'catgory', 'delivery', 'specData')); - } - $model = new GoodsModel; - if ($model->add($this->postData('goods'))) { - return $this->renderSuccess('添加成功', url('goods/index')); - } - return $this->renderError($model->getError() ?: '添加失败'); - } - - /** - * 商品编辑 - * @param $goods_id - * @return array|mixed - * @throws \think\exception\PDOException - */ - public function edit($goods_id) - { - // 商品详情 - $model = GoodsModel::detail($goods_id); - if (!$this->request->isAjax()) { - // 商品分类 - $catgory = Category::getCacheTree(); - // 配送模板 - $delivery = Delivery::getAll(); - // 商品sku数据 - $specData = 'null'; - if ($model['spec_type'] == 20) { - $specData = json_encode($model->getManySpecData($model['spec_rel'], $model['sku']), JSON_UNESCAPED_SLASHES); - } - return $this->fetch('edit', compact('model', 'catgory', 'delivery', 'specData')); - } - // 更新记录 - if ($model->edit($this->postData('goods'))) { - return $this->renderSuccess('更新成功', url('goods/index')); - } - return $this->renderError($model->getError() ?: '更新失败'); - } - - /** - * 修改商品状态 - * @param $goods_id - * @param boolean $state - * @return array - */ - public function state($goods_id, $state) - { - // 商品详情 - $model = GoodsModel::detail($goods_id); - if (!$model->setStatus($state)) { - return $this->renderError('操作失败'); - } - return $this->renderSuccess('操作成功'); - } - - /** - * 删除商品 - * @param $goods_id - * @return array - */ - public function delete($goods_id) - { - // 商品详情 - $model = GoodsModel::detail($goods_id); - if (!$model->setDelete()) { - return $this->renderError('删除失败'); - } - return $this->renderSuccess('删除成功'); - } - -} diff --git a/source/application/store/controller/Index.php b/source/application/store/controller/Index.php deleted file mode 100644 index 75f9025..0000000 --- a/source/application/store/controller/Index.php +++ /dev/null @@ -1,32 +0,0 @@ -menus(); - $url = current(array_values($menus))['index']; - if ($url !== 'index/index') { - $this->redirect($url); - } - $model = new StoreModel; - return $this->fetch('index', ['data' => $model->getHomeData()]); - } - -} diff --git a/source/application/store/controller/Order.php b/source/application/store/controller/Order.php deleted file mode 100644 index c1c4123..0000000 --- a/source/application/store/controller/Order.php +++ /dev/null @@ -1,147 +0,0 @@ -getList('待发货订单列表', 'delivery'); - } - - /** - * 待收货订单列表 - * @return mixed - * @throws \think\exception\DbException - */ - public function receipt_list() - { - return $this->getList('待收货订单列表', 'receipt'); - } - - /** - * 待付款订单列表 - * @return mixed - * @throws \think\exception\DbException - */ - public function pay_list() - { - return $this->getList('待付款订单列表', 'pay'); - } - - /** - * 已完成订单列表 - * @return mixed - * @throws \think\exception\DbException - */ - public function complete_list() - { - return $this->getList('已完成订单列表', 'complete'); - } - - /** - * 已取消订单列表 - * @return mixed - * @throws \think\exception\DbException - */ - public function cancel_list() - { - return $this->getList('已取消订单列表', 'cancel'); - } - - /** - * 全部订单列表 - * @return mixed - * @throws \think\exception\DbException - */ - public function all_list() - { - return $this->getList('全部订单列表', 'all'); - } - - /** - * 订单详情 - * @param $order_id - * @return mixed - * @throws \think\exception\DbException - */ - public function detail($order_id) - { - // 订单详情 - $detail = OrderModel::detail($order_id); - // 物流公司列表 - $expressList = ExpressModel::getAll(); - // 门店店员列表 - $shopClerkList = (new ShopClerkModel)->getList(true); - return $this->fetch('detail', compact( - 'detail', - 'expressList', - 'shopClerkList' - )); - } - - /** - * 确认发货 - * @param $order_id - * @return array - * @throws \app\common\exception\BaseException - * @throws \think\Exception - * @throws \think\exception\DbException - */ - public function delivery($order_id) - { - $model = OrderModel::detail($order_id); - if ($model->delivery($this->postData('order'))) { - return $this->renderSuccess('发货成功'); - } - return $this->renderError($model->getError() ?: '发货失败'); - } - - /** - * 修改订单价格 - * @param $order_id - * @return array - * @throws \think\exception\DbException - */ - public function updatePrice($order_id) - { - $model = OrderModel::detail($order_id); - if ($model->updatePrice($this->postData('order'))) { - return $this->renderSuccess('修改成功'); - } - return $this->renderError($model->getError() ?: '修改失败'); - } - - /** - * 订单列表 - * @param string $title - * @param string $dataType - * @return mixed - * @throws \think\exception\DbException - */ - private function getList($title, $dataType) - { - // 订单列表 - $model = new OrderModel; - $list = $model->getList($dataType, $this->request->param()); - // 自提门店列表 - $shopList = ShopModel::getAllList(); - return $this->fetch('index', compact('title', 'dataType', 'list', 'shopList')); - } - -} diff --git a/source/application/store/controller/Passport.php b/source/application/store/controller/Passport.php deleted file mode 100644 index 8c18522..0000000 --- a/source/application/store/controller/Passport.php +++ /dev/null @@ -1,45 +0,0 @@ -request->isAjax()) { - $model = new StoreUser; - if ($model->login($this->postData('User'))) { - return $this->renderSuccess('登录成功', url('index/index')); - } - return $this->renderError($model->getError() ?: '登录失败'); - } - $this->view->engine->layout(false); - return $this->fetch('login'); - } - - /** - * 退出登录 - */ - public function logout() - { - Session::clear('yoshop_store'); - $this->redirect('passport/login'); - } - -} diff --git a/source/application/store/controller/Setting.php b/source/application/store/controller/Setting.php deleted file mode 100644 index 45ddc1d..0000000 --- a/source/application/store/controller/Setting.php +++ /dev/null @@ -1,132 +0,0 @@ -updateEvent('store'); - } - - /** - * 交易设置 - * @return mixed - * @throws \think\exception\DbException - */ - public function trade() - { - return $this->updateEvent('trade'); - } - - /** - * 短信通知 - * @return mixed - * @throws \think\exception\DbException - */ - public function sms() - { - return $this->updateEvent('sms'); - } - - /** - * 发送订阅消息 - * @return mixed - * @throws \think\exception\DbException - */ - public function tplMsg() - { - return $this->updateEvent('tplMsg'); - } - - /** - * 发送短信通知测试 - * @param $AccessKeyId - * @param $AccessKeySecret - * @param $sign - * @param $msg_type - * @param $template_code - * @param $accept_phone - * @return array - * @throws \think\Exception - */ - public function smsTest($AccessKeyId, $AccessKeySecret, $sign, $msg_type, $template_code, $accept_phone) - { - $SmsDriver = new SmsDriver([ - 'default' => 'aliyun', - 'engine' => [ - 'aliyun' => [ - 'AccessKeyId' => $AccessKeyId, - 'AccessKeySecret' => $AccessKeySecret, - 'sign' => $sign, - $msg_type => compact('template_code', 'accept_phone'), - ], - ], - ]); - $templateParams = []; - if ($msg_type === 'order_pay') { - $templateParams = ['order_no' => '2018071200000000']; - } - if ($SmsDriver->sendSms($msg_type, $templateParams, true)) { - return $this->renderSuccess('发送成功'); - } - return $this->renderError('发送失败 ' . $SmsDriver->getError()); - } - - /** - * 上传设置 - * @return mixed - * @throws \think\exception\DbException - */ - public function storage() - { - return $this->updateEvent('storage'); - } - - /** - * 小票打印设置 - * @return mixed - * @throws \think\exception\DbException - */ - public function printer() - { - // 获取打印机列表 - $printerList = PrinterModel::getAll(); - return $this->updateEvent('printer', compact('printerList')); - } - - /** - * 更新商城设置事件 - * @param $key - * @param $vars - * @return array|mixed - * @throws \think\exception\DbException - */ - private function updateEvent($key, $vars = []) - { - if (!$this->request->isAjax()) { - $vars['values'] = SettingModel::getItem($key); - return $this->fetch($key, $vars); - } - $model = new SettingModel; - if ($model->edit($key, $this->postData($key))) { - return $this->renderSuccess('操作成功'); - } - return $this->renderError($model->getError() ?: '操作失败'); - } - -} diff --git a/source/application/store/controller/Shop.php b/source/application/store/controller/Shop.php deleted file mode 100644 index a2a8ed8..0000000 --- a/source/application/store/controller/Shop.php +++ /dev/null @@ -1,90 +0,0 @@ -getList($this->request->get()); - return $this->fetch('index', compact('list')); - } - - /** - * 腾讯地图坐标选取器 - * @return mixed - */ - public function getpoint() - { - $this->view->engine->layout(false); - return $this->fetch('getpoint'); - } - - /** - * 添加门店 - * @return array|bool|mixed - * @throws \Exception - */ - public function add() - { - $model = new ShopModel; - if (!$this->request->isAjax()) { - return $this->fetch('add'); - } - // 新增记录 - if ($model->add($this->postData('shop'))) { - return $this->renderSuccess('添加成功', url('shop/index')); - } - return $this->renderError($model->getError() ?: '添加失败'); - } - - /** - * 编辑门店 - * @param $shop_id - * @return array|bool|mixed - * @throws \think\exception\DbException - */ - public function edit($shop_id) - { - // 门店详情 - $model = ShopModel::detail($shop_id); - if (!$this->request->isAjax()) { - return $this->fetch('edit', compact('model')); - } - // 新增记录 - if ($model->edit($this->postData('shop'))) { - return $this->renderSuccess('更新成功', url('shop/index')); - } - return $this->renderError($model->getError() ?: '更新失败'); - } - - /** - * 删除门店 - * @param $shop_id - * @return array - * @throws \think\exception\DbException - */ - public function delete($shop_id) - { - // 门店详情 - $model = ShopModel::detail($shop_id); - if (!$model->setDelete()) { - return $this->renderError($model->getError() ?: '删除失败'); - } - return $this->renderSuccess('删除成功'); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/Upload.php b/source/application/store/controller/Upload.php deleted file mode 100644 index e5484d8..0000000 --- a/source/application/store/controller/Upload.php +++ /dev/null @@ -1,88 +0,0 @@ -config = SettingModel::getItem('storage'); - } - - /** - * 图片上传接口 - * @param int $group_id - * @return array - * @throws \think\Exception - */ - public function image($group_id = -1) - { - // 实例化存储驱动 - $StorageDriver = new StorageDriver($this->config); - // 设置上传文件的信息 - $StorageDriver->setUploadFile('iFile'); - // 上传图片 - if (!$StorageDriver->upload()) { - return json(['code' => 0, 'msg' => '图片上传失败' . $StorageDriver->getError()]); - } - - // 图片上传路径 - $fileName = $StorageDriver->getFileName(); - // 图片信息 - $fileInfo = $StorageDriver->getFileInfo(); - // 添加文件库记录 - $uploadFile = $this->addUploadFile($group_id, $fileName, $fileInfo, 'image'); - // 图片上传成功 - return json(['code' => 1, 'msg' => '图片上传成功', 'data' => $uploadFile]); - } - - /** - * 添加文件库上传记录 - * @param $group_id - * @param $fileName - * @param $fileInfo - * @param $fileType - * @return UploadFile - */ - private function addUploadFile($group_id, $fileName, $fileInfo, $fileType) - { - // 存储引擎 - $storage = $this->config['default']; - // 存储域名 - $fileUrl = isset($this->config['engine'][$storage]['domain']) - ? $this->config['engine'][$storage]['domain'] : ''; - // 添加文件库记录 - $model = new UploadFile; - $model->add([ - 'group_id' => $group_id > 0 ? (int)$group_id : 0, - 'storage' => $storage, - 'file_url' => $fileUrl, - 'file_name' => $fileName, - 'file_size' => $fileInfo['size'], - 'file_type' => $fileType, - 'extension' => pathinfo($fileInfo['name'], PATHINFO_EXTENSION), - ]); - return $model; - } - -} diff --git a/source/application/store/controller/User.php b/source/application/store/controller/User.php deleted file mode 100644 index 734b951..0000000 --- a/source/application/store/controller/User.php +++ /dev/null @@ -1,61 +0,0 @@ -getList($nickName, $gender); - return $this->fetch('index', compact('list')); - } - - /** - * 删除用户 - * @param $user_id - * @return array - * @throws \think\exception\DbException - */ - public function delete($user_id) - { - // 用户详情 - $model = UserModel::detail($user_id); - if (!$model->setDelete()) { - return $this->renderSuccess('删除成功'); - } - return $this->renderError($model->getError() ?: '删除失败'); - } - - /** - * 用户充值 - * @param $user_id - * @return array|bool - * @throws \think\Exception - * @throws \think\exception\DbException - */ - public function recharge($user_id) - { - // 用户详情 - $model = UserModel::detail($user_id); - if ($model->recharge($this->store['user']['user_name'], $this->postData('recharge'))) { - return $this->renderSuccess('操作成功'); - } - return $this->renderError($model->getError() ?: '操作失败'); - } - -} diff --git a/source/application/store/controller/Wxapp.php b/source/application/store/controller/Wxapp.php deleted file mode 100644 index f2f7770..0000000 --- a/source/application/store/controller/Wxapp.php +++ /dev/null @@ -1,33 +0,0 @@ -request->isAjax()) { - return $this->fetch('setting', compact('model')); - } - // 更新小程序设置 - if ($model->edit($this->postData('wxapp'))) { - return $this->renderSuccess('更新成功'); - } - return $this->renderError($model->getError() ?: '更新失败'); - } - -} diff --git a/source/application/store/controller/apps/dealer/Apply.php b/source/application/store/controller/apps/dealer/Apply.php deleted file mode 100644 index 0c4e42f..0000000 --- a/source/application/store/controller/apps/dealer/Apply.php +++ /dev/null @@ -1,44 +0,0 @@ -fetch('index', [ - 'list' => $model->getList($search), - ]); - } - - /** - * 分销商审核 - * @param $apply_id - * @return array|bool - * @throws \think\exception\DbException - */ - public function submit($apply_id) - { - $model = ApplyModel::detail($apply_id); - if ($model->submit($this->postData('apply'))) { - return $this->renderSuccess('操作成功'); - } - return $this->renderError($model->getError() ?: '操作失败'); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/apps/dealer/Order.php b/source/application/store/controller/apps/dealer/Order.php deleted file mode 100644 index 9b6664c..0000000 --- a/source/application/store/controller/apps/dealer/Order.php +++ /dev/null @@ -1,29 +0,0 @@ -getList($user_id, $is_settled); - return $this->fetch('index', compact('list')); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/apps/dealer/Setting.php b/source/application/store/controller/apps/dealer/Setting.php deleted file mode 100644 index 38bd1e1..0000000 --- a/source/application/store/controller/apps/dealer/Setting.php +++ /dev/null @@ -1,59 +0,0 @@ -request->isAjax()) { - $data = SettingModel::getAll(); - // 购买指定商品成为分销商:商品列表 - $goodsList = (new GoodsModel)->getListByIds($data['condition']['values']['become__buy_goods_ids']); - return $this->fetch('index', compact('data', 'goodsList')); - } - $model = new SettingModel; - if ($model->edit($this->postData('setting'))) { - return $this->renderSuccess('更新成功'); - } - return $this->renderError($model->getError() ?: '更新失败'); - } - - /** - * 分销海报 - * @return array|mixed - * @throws \think\exception\PDOException - */ - public function qrcode() - { - if (!$this->request->isAjax()) { - $data = SettingModel::getItem('qrcode'); - return $this->fetch('qrcode', [ - 'data' => json_encode($data, JSON_UNESCAPED_UNICODE) - ]); - } - $model = new SettingModel; - if ($model->edit(['qrcode' => $this->postData('qrcode')])) { - return $this->renderSuccess('更新成功'); - } - return $this->renderError($model->getError() ?: '更新失败'); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/apps/dealer/User.php b/source/application/store/controller/apps/dealer/User.php deleted file mode 100644 index 44200c7..0000000 --- a/source/application/store/controller/apps/dealer/User.php +++ /dev/null @@ -1,90 +0,0 @@ -fetch('index', [ - 'list' => $model->getList($search), - 'basicSetting' => SettingModel::getItem('basic'), - ]); - } - - /** - * 分销商用户列表 - * @param string $user_id - * @param int $level - * @return mixed - * @throws \think\exception\DbException - */ - public function fans($user_id, $level = -1) - { - $model = new RefereeModel; - return $this->fetch('fans', [ - 'list' => $model->getList($user_id, $level), - 'basicSetting' => SettingModel::getItem('basic'), - ]); - } - - /** - * 删除分销商 - * @param $dealer_id - * @return array - * @throws \think\exception\DbException - */ - public function delete($dealer_id) - { - $model = UserModel::detail($dealer_id); - if (!$model->setDelete()) { - return $this->renderError('删除失败'); - } - return $this->renderSuccess('删除成功'); - } - - /** - * 分销商二维码 - * @param $dealer_id - * @throws \app\common\exception\BaseException - * @throws \think\exception\DbException - * @throws \Exception - */ - public function qrcode($dealer_id) - { - $model = UserModel::detail($dealer_id); - $Qrcode = new Poster($model); - $this->redirect($Qrcode->getImage()); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/apps/dealer/Withdraw.php b/source/application/store/controller/apps/dealer/Withdraw.php deleted file mode 100644 index 0070d97..0000000 --- a/source/application/store/controller/apps/dealer/Withdraw.php +++ /dev/null @@ -1,79 +0,0 @@ -fetch('index', [ - 'list' => $model->getList($user_id, $apply_status, $pay_type, $search) - ]); - } - - /** - * 提现审核 - * @param $id - * @return array - * @throws \think\exception\DbException - */ - public function submit($id) - { - $model = WithdrawModel::detail($id); - if ($model->submit($this->postData('withdraw'))) { - return $this->renderSuccess('操作成功'); - } - return $this->renderError($model->getError() ?: '操作失败'); - } - - /** - * 确认打款 - * @param $id - * @return array - * @throws \think\exception\DbException - */ - public function money($id) - { - $model = WithdrawModel::detail($id); - if ($model->money()) { - return $this->renderSuccess('操作成功'); - } - return $this->renderError($model->getError() ?: '操作失败'); - } - - /** - * 分销商提现:微信支付企业付款 - * @param $id - * @return array|bool - * @throws \app\common\exception\BaseException - * @throws \think\Exception - * @throws \think\exception\DbException - */ - public function wechat_pay($id) - { - $model = WithdrawModel::detail($id); - if ($model->wechatPay()) { - return $this->renderSuccess('操作成功'); - } - return $this->renderError($model->getError() ?: '操作失败'); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/apps/live/Room.php b/source/application/store/controller/apps/live/Room.php deleted file mode 100644 index b21932f..0000000 --- a/source/application/store/controller/apps/live/Room.php +++ /dev/null @@ -1,60 +0,0 @@ -getList($search); - return $this->fetch('index', compact('list')); - } - - /** - * 同步刷新直播间列表 - * @return array|bool - * @throws \app\common\exception\BaseException - * @throws \think\exception\DbException - */ - public function refresh() - { - $model = new LiveRoomModel; - if ($model->refreshLiveList()) { - return $this->renderSuccess('同步成功'); - } - return $this->renderError($model->getError() ?: '同步失败'); - } - - /** - * 修改直播间置顶状态 - * @param int $id - * @param int $is_top - * @return array|bool - * @throws \think\exception\DbException - */ - public function settop($id, $is_top) - { - // 直播间详情 - $model = LiveRoomModel::detail($id); - if (!$model->setIsTop($is_top)) { - return $this->renderError('操作失败'); - } - return $this->renderSuccess('操作成功'); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/apps/sharing/Active.php b/source/application/store/controller/apps/sharing/Active.php deleted file mode 100644 index ff167c4..0000000 --- a/source/application/store/controller/apps/sharing/Active.php +++ /dev/null @@ -1,42 +0,0 @@ -getList($active_id); - return $this->fetch('index', compact('list')); - } - - /** - * - * @param $active_id - * @return mixed - * @throws \think\exception\DbException - */ - public function users($active_id) - { - $model = new ActiveUsersModel; - $list = $model->getList($active_id); - return $this->fetch('users', compact('list')); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/apps/sharing/Category.php b/source/application/store/controller/apps/sharing/Category.php deleted file mode 100644 index dadaa6a..0000000 --- a/source/application/store/controller/apps/sharing/Category.php +++ /dev/null @@ -1,82 +0,0 @@ -getCacheTree(); - return $this->fetch('index', compact('list')); - } - - /** - * 添加商品分类 - * @return array|mixed - */ - public function add() - { - $model = new CategoryModel; - if (!$this->request->isAjax()) { - // 获取所有地区 - $list = $model->getCacheTree(); - return $this->fetch('add', compact('list')); - } - // 新增记录 - if ($model->add($this->postData('category'))) { - return $this->renderSuccess('添加成功', url('apps.sharing.category/index')); - } - return $this->renderError($model->getError() ?: '添加失败'); - } - - /** - * 编辑商品分类 - * @param $category_id - * @return array|mixed - * @throws \think\exception\DbException - */ - public function edit($category_id) - { - // 模板详情 - $model = CategoryModel::detail($category_id); - if (!$this->request->isAjax()) { - // 获取所有地区 - $list = $model->getCacheTree(); - return $this->fetch('edit', compact('model', 'list')); - } - // 更新记录 - if ($model->edit($this->postData('category'))) { - return $this->renderSuccess('更新成功', url('apps.sharing.category/index')); - } - return $this->renderError($model->getError() ?: '更新失败'); - } - - /** - * 删除商品分类 - * @param $category_id - * @return array - * @throws \think\exception\DbException - */ - public function delete($category_id) - { - $model = CategoryModel::detail($category_id); - if (!$model->remove($category_id)) { - return $this->renderError($model->getError() ?: '删除失败'); - } - return $this->renderSuccess('删除成功'); - } - -} diff --git a/source/application/store/controller/apps/sharing/Comment.php b/source/application/store/controller/apps/sharing/Comment.php deleted file mode 100644 index 0e5fa7a..0000000 --- a/source/application/store/controller/apps/sharing/Comment.php +++ /dev/null @@ -1,62 +0,0 @@ -getList(); - return $this->fetch('index', compact('list')); - } - - /** - * 评价详情 - * @param $comment_id - * @return array|mixed - * @throws \think\exception\DbException - */ - public function detail($comment_id) - { - // 评价详情 - $model = CommentModel::detail($comment_id); - if (!$this->request->isAjax()) { - return $this->fetch('detail', compact('model')); - } - // 更新记录 - if ($model->edit($this->postData('comment'))) { - return $this->renderSuccess('更新成功', url('apps.sharing.comment/index')); - } - return $this->renderError($model->getError() ?: '更新失败'); - } - - /** - * 删除评价 - * @param $comment_id - * @return array - * @throws \think\exception\DbException - */ - public function delete($comment_id) - { - $model = CommentModel::get($comment_id); - if (!$model->setDelete()) { - return $this->renderError('删除失败'); - } - return $this->renderSuccess('删除成功'); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/apps/sharing/Goods.php b/source/application/store/controller/apps/sharing/Goods.php deleted file mode 100644 index e1b5fd0..0000000 --- a/source/application/store/controller/apps/sharing/Goods.php +++ /dev/null @@ -1,178 +0,0 @@ -getList($goods_status, $category_id, $goods_name); - return $this->fetch('index', compact('list', 'catgory')); - } - - /** - * 添加商品 - * @return array|mixed - * @throws \think\exception\PDOException - */ - public function add() - { - if (!$this->request->isAjax()) { - // 商品分类 - $catgory = CategoryModel::getCacheTree(); - // 配送模板 - $delivery = DeliveryModel::getAll(); - return $this->fetch('add', compact('catgory', 'delivery')); - } - $model = new GoodsModel; - if ($model->add($this->postData('goods'))) { - return $this->renderSuccess('添加成功', url('apps.sharing.goods/index')); - } - return $this->renderError($model->getError() ?: '添加失败'); - } - - /** - * 复制主商城商品 - * @param $goods_id - * @return array|mixed - * @throws \think\exception\PDOException - */ - public function copy_master($goods_id) - { - // 商品详情 - $model = \app\store\model\Goods::detail($goods_id); - if (!$model || $model['is_delete']) { - return $this->renderError('商品信息不存在'); - } - if (!$this->request->isAjax()) { - // 商品分类 - $catgory = CategoryModel::getCacheTree(); - // 配送模板 - $delivery = DeliveryModel::getAll(); - // 商品sku数据 - $specData = 'null'; - if ($model['spec_type'] == 20) { - $specData = json_encode($model->getManySpecData($model['spec_rel'], $model['sku']), JSON_UNESCAPED_SLASHES); - } - return $this->fetch('copy_master', compact('model', 'catgory', 'delivery', 'specData')); - } - // 新增拼团商品 - $model = new GoodsModel; - if ($model->add($this->postData('goods'))) { - return $this->renderSuccess('添加成功', url('apps.sharing.goods/index')); - } - return $this->renderError($model->getError() ?: '添加失败'); - } - - /** - * 一键复制 - * @param $goods_id - * @return array|mixed - * @throws \think\exception\PDOException - */ - public function copy($goods_id) - { - // 商品详情 - $model = GoodsModel::detail($goods_id); - if (!$this->request->isAjax()) { - // 商品分类 - $catgory = CategoryModel::getCacheTree(); - // 配送模板 - $delivery = DeliveryModel::getAll(); - // 商品sku数据 - $specData = 'null'; - if ($model['spec_type'] == 20) { - $specData = json_encode($model->getManySpecData($model['spec_rel'], $model['sku']), JSON_UNESCAPED_SLASHES); - } - return $this->fetch('edit', compact('model', 'catgory', 'delivery', 'specData')); - } - $model = new GoodsModel; - if ($model->add($this->postData('goods'))) { - return $this->renderSuccess('添加成功', url('apps.sharing.goods/index')); - } - return $this->renderError($model->getError() ?: '添加失败'); - } - - /** - * 商品编辑 - * @param $goods_id - * @return array|mixed - * @throws \think\exception\PDOException - */ - public function edit($goods_id) - { - // 商品详情 - $model = GoodsModel::detail($goods_id); - if (!$this->request->isAjax()) { - // 商品分类 - $catgory = CategoryModel::getCacheTree(); - // 配送模板 - $delivery = DeliveryModel::getAll(); - // 商品sku数据 - $specData = 'null'; - if ($model['spec_type'] == 20) { - $specData = json_encode($model->getManySpecData($model['spec_rel'], $model['sku']), JSON_UNESCAPED_SLASHES); - } - return $this->fetch('edit', compact('model', 'catgory', 'delivery', 'specData')); - } - // 更新记录 - if ($model->edit($this->postData('goods'))) { - return $this->renderSuccess('更新成功', url('apps.sharing.goods/index')); - } - return $this->renderError($model->getError() ?: '更新失败'); - } - - /** - * 修改商品状态 - * @param $goods_id - * @param boolean $state - * @return array - */ - public function state($goods_id, $state) - { - // 商品详情 - $model = GoodsModel::detail($goods_id); - if (!$model->setStatus($state)) { - return $this->renderError('操作失败'); - } - return $this->renderSuccess('操作成功'); - } - - /** - * 删除商品 - * @param $goods_id - * @return array - */ - public function delete($goods_id) - { - // 商品详情 - $model = GoodsModel::detail($goods_id); - if (!$model->setDelete()) { - return $this->renderError('删除失败'); - } - return $this->renderSuccess('删除成功'); - } - -} diff --git a/source/application/store/controller/apps/sharing/Order.php b/source/application/store/controller/apps/sharing/Order.php deleted file mode 100644 index 8b06509..0000000 --- a/source/application/store/controller/apps/sharing/Order.php +++ /dev/null @@ -1,87 +0,0 @@ -getList($dataType, $this->request->param()); - // 自提门店列表 - $shopList = ShopModel::getAllList(); - return $this->fetch('index', compact('dataType', 'list', 'shopList')); - } - - /** - * 订单详情 - * @param $order_id - * @return mixed - * @throws \think\exception\DbException - */ - public function detail($order_id) - { - // 订单详情 - $detail = OrderModel::detail($order_id); - // 物流公司列表 - $expressList = ExpressModel::getAll(); - // 门店店员列表 - $shopClerkList = (new ShopClerkModel)->getList(true); - return $this->fetch('detail', compact( - 'detail', - 'expressList', - 'shopClerkList' - )); - } - - /** - * 确认发货 - * @param $order_id - * @return array - * @throws \app\common\exception\BaseException - * @throws \think\Exception - * @throws \think\exception\DbException - */ - public function delivery($order_id) - { - $model = OrderModel::detail($order_id); - if ($model->delivery($this->postData('order'))) { - return $this->renderSuccess('发货成功'); - } - return $this->renderError($model->getError() ?: '发货失败'); - } - - /** - * 修改订单价格 - * @param $order_id - * @return array - * @throws \think\exception\DbException - */ - public function updatePrice($order_id) - { - $model = OrderModel::detail($order_id); - if ($model->updatePrice($this->postData('order'))) { - return $this->renderSuccess('修改成功'); - } - return $this->renderError($model->getError() ?: '修改失败'); - } - -} diff --git a/source/application/store/controller/apps/sharing/Setting.php b/source/application/store/controller/apps/sharing/Setting.php deleted file mode 100644 index 8a8f94f..0000000 --- a/source/application/store/controller/apps/sharing/Setting.php +++ /dev/null @@ -1,33 +0,0 @@ -request->isAjax()) { - $values = SettingModel::getItem('basic'); - return $this->fetch('index', compact('values')); - } - $model = new SettingModel; - if ($model->edit('basic', $this->postData('basic'))) { - return $this->renderSuccess('更新成功'); - } - return $this->renderError($model->getError() ?: '更新失败'); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/apps/sharing/order/Operate.php b/source/application/store/controller/apps/sharing/order/Operate.php deleted file mode 100644 index 2ac6fb8..0000000 --- a/source/application/store/controller/apps/sharing/order/Operate.php +++ /dev/null @@ -1,115 +0,0 @@ -model = new OrderModel; - } - - /** - * 订单导出 - * @param string $dataType - * @throws \think\exception\DbException - */ - public function export($dataType) - { - return $this->model->exportList($dataType, $this->request->param()); - } - - /** - * 批量发货 - * @return array|mixed - * @throws \app\common\exception\BaseException - * @throws \think\exception\PDOException - */ - public function batchDelivery() - { - if (!$this->request->isAjax()) { - return $this->fetch('batchDelivery', [ - 'express_list' => ExpressModel::getAll() - ]); - } - if ($this->model->batchDelivery($this->postData('order'))) { - return $this->renderSuccess('发货成功'); - } - return $this->renderError($this->model->getError() ?: '发货失败'); - } - -// /** -// * 批量发货模板 -// */ -// public function deliveryTpl() -// { -// return $this->model->deliveryTpl(); -// } - - /** - * 审核:用户取消订单 - * @param $order_id - * @return array|bool - * @throws \think\exception\DbException - */ - public function confirmCancel($order_id) - { - $model = OrderModel::detail($order_id); - if ($model->confirmCancel($this->postData('order'))) { - return $this->renderSuccess('操作成功'); - } - return $this->renderError($model->getError() ?: '操作失败'); - } - - /** - * 拼团失败手动退款 - * @param $order_id - * @return array - * @throws \app\common\exception\BaseException - * @throws \think\exception\DbException - */ - public function refund($order_id) - { - $model = OrderModel::detail($order_id); - if ($model->refund()) { - return $this->renderSuccess('操作成功'); - } - return $this->renderError($model->getError() ?: '操作失败'); - } - /** - * 门店自提核销 - * @param $order_id - * @return array|bool - * @throws \think\exception\DbException - */ - public function extract($order_id) - { - $model = OrderModel::detail($order_id); - $data = $this->postData('order'); - if ($model->extract($data['extract_clerk_id'])) { - return $this->renderSuccess('核销成功'); - } - return $this->renderError($model->getError() ?: '核销失败'); - } - -} diff --git a/source/application/store/controller/apps/sharing/order/Refund.php b/source/application/store/controller/apps/sharing/order/Refund.php deleted file mode 100644 index 00addc1..0000000 --- a/source/application/store/controller/apps/sharing/order/Refund.php +++ /dev/null @@ -1,82 +0,0 @@ -getList($this->getData()); - return $this->fetch('index', compact('list')); - } - - /** - * 售后单详情 - * @param $order_refund_id - * @return mixed - * @throws \think\exception\DbException - */ - public function detail($order_refund_id) - { - // 售后单详情 - $detail = OrderRefundModel::detail($order_refund_id); - // 订单详情 - $order = OrderModel::detail($detail['order_id']); - // 退货地址 - $address = (new ReturnAddressModel)->getAll(); - return $this->fetch('detail', compact('detail', 'order', 'address')); - } - - /** - * 商家审核 - * @param $order_refund_id - * @return array|bool - * @throws \think\exception\DbException - */ - public function audit($order_refund_id) - { - if (!$this->request->isAjax()) { - return false; - } - $model = OrderRefundModel::detail($order_refund_id); - if ($model->audit($this->postData('refund'))) { - return $this->renderSuccess('操作成功'); - } - return $this->renderError($model->getError() ?: '操作失败'); - } - - /** - * 确认收货并退款 - * @param $order_refund_id - * @return array|bool - * @throws \think\exception\DbException - */ - public function receipt($order_refund_id) - { - if (!$this->request->isAjax()) { - return false; - } - $model = OrderRefundModel::detail($order_refund_id); - if ($model->receipt($this->postData('refund'))) { - return $this->renderSuccess('操作成功'); - } - return $this->renderError($model->getError() ?: '操作失败'); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/content/Article.php b/source/application/store/controller/content/Article.php deleted file mode 100644 index 425d280..0000000 --- a/source/application/store/controller/content/Article.php +++ /dev/null @@ -1,85 +0,0 @@ -getList(); - return $this->fetch('index', compact('list')); - } - - /** - * 添加文章 - * @return array|mixed - */ - public function add() - { - $model = new ArticleModel; - if (!$this->request->isAjax()) { - // 文章分类 - $catgory = CategoryModel::getAll(); - return $this->fetch('add', compact('catgory')); - } - // 新增记录 - if ($model->add($this->postData('article'))) { - return $this->renderSuccess('添加成功', url('content.article/index')); - } - return $this->renderError($model->getError() ?: '添加失败'); - } - - /** - * 更新文章 - * @param $article_id - * @return array|mixed - * @throws \think\exception\DbException - */ - public function edit($article_id) - { - // 文章详情 - $model = ArticleModel::detail($article_id); - if (!$this->request->isAjax()) { - // 文章分类 - $catgory = CategoryModel::getAll(); - return $this->fetch('edit', compact('model', 'catgory')); - } - // 更新记录 - if ($model->edit($this->postData('article'))) { - return $this->renderSuccess('更新成功', url('content.article/index')); - } - return $this->renderError($model->getError() ?: '更新失败'); - } - - /** - * 删除文章 - * @param $article_id - * @return array - * @throws \think\exception\DbException - */ - public function delete($article_id) - { - // 文章详情 - $model = ArticleModel::detail($article_id); - if (!$model->setDelete()) { - return $this->renderError($model->getError() ?: '删除失败'); - } - return $this->renderSuccess('删除成功'); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/content/Files.php b/source/application/store/controller/content/Files.php deleted file mode 100644 index e5a472b..0000000 --- a/source/application/store/controller/content/Files.php +++ /dev/null @@ -1,88 +0,0 @@ -getList(-1, '', 0); - return $this->fetch('index', compact('list')); - } - - /** - * 回收站列表 - * @return mixed - * @throws \think\exception\DbException - */ - public function recycle() - { - $model = new UploadFileModel; - $list = $model->getList(-1, '', 1); - return $this->fetch('recycle', compact('list')); - } - - /** - * 移入回收站 - * @param $file_id - * @return array - * @throws \think\exception\DbException - */ - public function recovery($file_id) - { - // 文章详情 - $model = UploadFileModel::detail($file_id); - if (!$model->setRecycle(true)) { - return $this->renderError($model->getError() ?: '操作失败'); - } - return $this->renderSuccess('操作成功'); - } - - /** - * 移出回收站 - * @param $file_id - * @return array - * @throws \think\exception\DbException - */ - public function restore($file_id) - { - // 商品详情 - $model = UploadFileModel::detail($file_id); - if (!$model->setRecycle(false)) { - return $this->renderError('操作失败'); - } - return $this->renderSuccess('操作成功'); - } - - /** - * 删除文件 - * @param $file_id - * @return array|bool - * @throws \think\Exception - * @throws \think\exception\DbException - */ - public function delete($file_id) - { - // 商品详情 - $model = UploadFileModel::detail($file_id); - if (!$model->setDelete()) { - return $this->renderError($model->getError() ?: '操作失败'); - } - return $this->renderSuccess('操作成功'); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/content/article/Category.php b/source/application/store/controller/content/article/Category.php deleted file mode 100644 index 9e6ca07..0000000 --- a/source/application/store/controller/content/article/Category.php +++ /dev/null @@ -1,78 +0,0 @@ -getAll(); - return $this->fetch('index', compact('list')); - } - - /** - * 添加文章分类 - * @return array|mixed - */ - public function add() - { - $model = new CategoryModel; - if (!$this->request->isAjax()) { - return $this->fetch('add'); - } - // 新增记录 - if ($model->add($this->postData('category'))) { - return $this->renderSuccess('添加成功', url('content.article.category/index')); - } - return $this->renderError($model->getError() ?: '添加失败'); - } - - /** - * 编辑文章分类 - * @param $category_id - * @return array|mixed - * @throws \think\exception\DbException - */ - public function edit($category_id) - { - // 分类详情 - $model = CategoryModel::detail($category_id); - if (!$this->request->isAjax()) { - return $this->fetch('edit', compact('model')); - } - // 更新记录 - if ($model->edit($this->postData('category'))) { - return $this->renderSuccess('更新成功', url('content.article.category/index')); - } - return $this->renderError($model->getError() ?: '更新失败'); - } - - /** - * 删除文章分类 - * @param $category_id - * @return array - * @throws \think\exception\DbException - */ - public function delete($category_id) - { - $model = CategoryModel::detail($category_id); - if (!$model->remove($category_id)) { - return $this->renderError($model->getError() ?: '删除失败'); - } - return $this->renderSuccess('删除成功'); - } - -} diff --git a/source/application/store/controller/content/files/Group.php b/source/application/store/controller/content/files/Group.php deleted file mode 100644 index 1fff87c..0000000 --- a/source/application/store/controller/content/files/Group.php +++ /dev/null @@ -1,81 +0,0 @@ -getList(); - return $this->fetch('index', compact('list')); - } - - /** - * 添加文件分组 - * @return array|mixed - */ - public function add() - { - $model = new GroupModel; - if (!$this->request->isAjax()) { - return $this->fetch('add'); - } - // 新增记录 - if ($model->add($this->postData('group'))) { - return $this->renderSuccess('添加成功', url('content.files.group/index')); - } - return $this->renderError($model->getError() ?: '添加失败'); - } - - /** - * 编辑文件分组 - * @param $group_id - * @return array|mixed - * @throws \think\exception\DbException - */ - public function edit($group_id) - { - // 分组详情 - $model = GroupModel::detail($group_id); - if (!$this->request->isAjax()) { - return $this->fetch('edit', compact('model')); - } - // 更新记录 - if ($model->edit($this->postData('group'))) { - return $this->renderSuccess('更新成功', url('content.files.group/index')); - } - return $this->renderError($model->getError() ?: '更新失败'); - } - - /** - * 删除文件分组 - * @param $group_id - * @return array - * @throws \think\exception\DbException - */ - public function delete($group_id) - { - $model = GroupModel::detail($group_id); - if (!$model->remove()) { - return $this->renderError($model->getError() ?: '删除失败'); - } - return $this->renderSuccess('删除成功'); - } - -} diff --git a/source/application/store/controller/data/Goods.php b/source/application/store/controller/data/Goods.php deleted file mode 100644 index 4e647bf..0000000 --- a/source/application/store/controller/data/Goods.php +++ /dev/null @@ -1,44 +0,0 @@ -model = new GoodsModel; - $this->view->engine->layout(false); - } - - /** - * 商品列表 - * @param null $status - * @return mixed - * @throws \think\exception\DbException - */ - public function lists($status = null) - { - $list = $this->model->getList($status); - return $this->fetch('list', compact('list')); - } - -} diff --git a/source/application/store/controller/data/Shop.php b/source/application/store/controller/data/Shop.php deleted file mode 100644 index a1bbe22..0000000 --- a/source/application/store/controller/data/Shop.php +++ /dev/null @@ -1,38 +0,0 @@ -model = new ShopModel; - $this->view->engine->layout(false); - } - - /** - * 门店列表 - * @return mixed - * @throws \think\exception\DbException - */ - public function lists() - { - $list = $this->model->getList($this->request->get()); - return $this->fetch('list', compact('list')); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/data/User.php b/source/application/store/controller/data/User.php deleted file mode 100644 index 7de8da1..0000000 --- a/source/application/store/controller/data/User.php +++ /dev/null @@ -1,43 +0,0 @@ -model = new UserModel; - $this->view->engine->layout(false); - } - - /** - * 用户列表 - * @return mixed - * @throws \think\exception\DbException - */ - public function lists() - { - $list = $this->model->getList(); - return $this->fetch('list', compact('list')); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/data/sharing/Goods.php b/source/application/store/controller/data/sharing/Goods.php deleted file mode 100644 index 65f8938..0000000 --- a/source/application/store/controller/data/sharing/Goods.php +++ /dev/null @@ -1,44 +0,0 @@ -model = new GoodsModel; - $this->view->engine->layout(false); - } - - /** - * 商品列表 - * @param null $status - * @return mixed - * @throws \think\exception\DbException - */ - public function lists($status = null) - { - $list = $this->model->getList($status); - return $this->fetch('list', compact('list')); - } - -} diff --git a/source/application/store/controller/goods/Category.php b/source/application/store/controller/goods/Category.php deleted file mode 100644 index 2ceb76d..0000000 --- a/source/application/store/controller/goods/Category.php +++ /dev/null @@ -1,83 +0,0 @@ -getCacheTree(); - return $this->fetch('index', compact('list')); - } - - /** - * 删除商品分类 - * @param $category_id - * @return array|bool - * @throws \think\Exception - * @throws \think\exception\DbException - */ - public function delete($category_id) - { - $model = CategoryModel::get($category_id); - if (!$model->remove($category_id)) { - return $this->renderError($model->getError() ?: '删除失败'); - } - return $this->renderSuccess('删除成功'); - } - - /** - * 添加商品分类 - * @return array|mixed - */ - public function add() - { - $model = new CategoryModel; - if (!$this->request->isAjax()) { - // 获取所有地区 - $list = $model->getCacheTree(); - return $this->fetch('add', compact('list')); - } - // 新增记录 - if ($model->add($this->postData('category'))) { - return $this->renderSuccess('添加成功', url('goods.category/index')); - } - return $this->renderError($model->getError() ?: '添加失败'); - } - - /** - * 编辑商品分类 - * @param $category_id - * @return array|mixed - * @throws \think\exception\DbException - */ - public function edit($category_id) - { - // 模板详情 - $model = CategoryModel::get($category_id, ['image']); - if (!$this->request->isAjax()) { - // 获取所有地区 - $list = $model->getCacheTree(); - return $this->fetch('edit', compact('model', 'list')); - } - // 更新记录 - if ($model->edit($this->postData('category'))) { - return $this->renderSuccess('更新成功', url('goods.category/index')); - } - return $this->renderError($model->getError() ?: '更新失败'); - } - -} diff --git a/source/application/store/controller/goods/Comment.php b/source/application/store/controller/goods/Comment.php deleted file mode 100644 index 2f9cf09..0000000 --- a/source/application/store/controller/goods/Comment.php +++ /dev/null @@ -1,62 +0,0 @@ -getList(); - return $this->fetch('index', compact('list')); - } - - /** - * 评价详情 - * @param $comment_id - * @return array|mixed - * @throws \think\exception\DbException - */ - public function detail($comment_id) - { - // 评价详情 - $model = CommentModel::detail($comment_id); - if (!$this->request->isAjax()) { - return $this->fetch('detail', compact('model')); - } - // 更新记录 - if ($model->edit($this->postData('comment'))) { - return $this->renderSuccess('更新成功', url('goods.comment/index')); - } - return $this->renderError($model->getError() ?: '更新失败'); - } - - /** - * 删除评价 - * @param $comment_id - * @return array - * @throws \think\exception\DbException - */ - public function delete($comment_id) - { - $model = CommentModel::get($comment_id); - if (!$model->setDelete()) { - return $this->renderError('删除失败'); - } - return $this->renderSuccess('删除成功'); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/goods/Spec.php b/source/application/store/controller/goods/Spec.php deleted file mode 100644 index 874ff45..0000000 --- a/source/application/store/controller/goods/Spec.php +++ /dev/null @@ -1,93 +0,0 @@ -SpecModel = new SpecModel; - $this->SpecValueModel = new SpecValueModel; - } - - /** - * 添加规则组 - * @param $spec_name - * @param $spec_value - * @return array - */ - public function addSpec($spec_name, $spec_value) - { - // 判断规格组是否存在 - if (!$specId = $this->SpecModel->getSpecIdByName($spec_name)) { - // 新增规格组and规则值 - if ($this->SpecModel->add($spec_name) - && $this->SpecValueModel->add($this->SpecModel['spec_id'], $spec_value)) - return $this->renderSuccess('', '', [ - 'spec_id' => (int)$this->SpecModel['spec_id'], - 'spec_value_id' => (int)$this->SpecValueModel['spec_value_id'], - ]); - return $this->renderError(); - } - // 判断规格值是否存在 - if ($specValueId = $this->SpecValueModel->getSpecValueIdByName($specId, $spec_value)) { - return $this->renderSuccess('', '', [ - 'spec_id' => (int)$specId, - 'spec_value_id' => (int)$specValueId, - ]); - } - // 添加规则值 - if ($this->SpecValueModel->add($specId, $spec_value)) - return $this->renderSuccess('', '', [ - 'spec_id' => (int)$specId, - 'spec_value_id' => (int)$this->SpecValueModel['spec_value_id'], - ]); - return $this->renderError(); - } - - /** - * 添加规格值 - * @param $spec_id - * @param $spec_value - * @return array - */ - public function addSpecValue($spec_id, $spec_value) - { - // 判断规格值是否存在 - if ($specValueId = $this->SpecValueModel->getSpecValueIdByName($spec_id, $spec_value)) { - return $this->renderSuccess('', '', [ - 'spec_value_id' => (int)$specValueId, - ]); - } - // 添加规则值 - if ($this->SpecValueModel->add($spec_id, $spec_value)) - return $this->renderSuccess('', '', [ - 'spec_value_id' => (int)$this->SpecValueModel['spec_value_id'], - ]); - return $this->renderError(); - } - -} diff --git a/source/application/store/controller/market/Basic.php b/source/application/store/controller/market/Basic.php deleted file mode 100644 index 82c5dd6..0000000 --- a/source/application/store/controller/market/Basic.php +++ /dev/null @@ -1,39 +0,0 @@ -request->isAjax()) { - $values = SettingModel::getItem('full_free'); - return $this->fetch('full_free', [ - 'goodsList' => (new Goods)->getListByIds($values['notin_goods']), - 'regionData' => RegionModel::getCacheTree(), // 所有地区 - 'values' => $values - ]); - } - $model = new SettingModel; - if ($model->edit('full_free', $this->postData('model'))) { - return $this->renderSuccess('操作成功'); - } - return $this->renderError($model->getError() ?: '操作失败'); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/market/Coupon.php b/source/application/store/controller/market/Coupon.php deleted file mode 100644 index bd3ac1c..0000000 --- a/source/application/store/controller/market/Coupon.php +++ /dev/null @@ -1,108 +0,0 @@ -model = new CouponModel; - } - - /** - * 优惠券列表 - * @return mixed - * @throws \think\exception\DbException - */ - public function index() - { - $list = $this->model->getList(); - return $this->fetch('index', compact('list')); - } - - /** - * 添加优惠券 - * @return array|mixed - */ - public function add() - { - if (!$this->request->isAjax()) { - return $this->fetch('add'); - } - // 新增记录 - if ($this->model->add($this->postData('coupon'))) { - return $this->renderSuccess('添加成功', url('market.coupon/index')); - } - return $this->renderError($this->model->getError() ?: '添加失败'); - } - - /** - * 更新优惠券 - * @param $coupon_id - * @return array|mixed - * @throws \think\exception\DbException - */ - public function edit($coupon_id) - { - // 优惠券详情 - $model = CouponModel::detail($coupon_id); - if (!$this->request->isAjax()) { - return $this->fetch('edit', compact('model')); - } - // 更新记录 - if ($model->edit($this->postData('coupon'))) { - return $this->renderSuccess('更新成功', url('market.coupon/index')); - } - return $this->renderError($model->getError() ?: '更新失败'); - } - - /** - * 删除优惠券 - * @param $coupon_id - * @return array|mixed - * @throws \think\exception\DbException - */ - public function delete($coupon_id) - { - // 优惠券详情 - $model = CouponModel::detail($coupon_id); - // 更新记录 - if ($model->setDelete()) { - return $this->renderSuccess('删除成功', url('market.coupon/index')); - } - return $this->renderError($model->getError() ?: '删除成功'); - } - - /** - * 领取记录 - * @return mixed - * @throws \think\exception\DbException - */ - public function receive() - { - $model = new UserCouponModel; - $list = $model->getList(); - return $this->fetch('receive', compact('list')); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/market/Push.php b/source/application/store/controller/market/Push.php deleted file mode 100644 index afa00b9..0000000 --- a/source/application/store/controller/market/Push.php +++ /dev/null @@ -1,47 +0,0 @@ -request->isAjax()) { - return $this->fetch('send'); - } - // 执行发送 - $MessageService = new MessageService; - $MessageService->send($this->postData('send')); - return $this->renderSuccess('', '', [ - 'stateSet' => $MessageService->getStateSet() - ]); - } - - /** - * 活跃用户列表 - * @return mixed - * @throws \think\exception\DbException - */ - public function user() - { - $list = (new FormidModel)->getUserList(); - return $this->fetch('user', compact('list')); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/market/Recharge.php b/source/application/store/controller/market/Recharge.php deleted file mode 100644 index 59c3ba5..0000000 --- a/source/application/store/controller/market/Recharge.php +++ /dev/null @@ -1,28 +0,0 @@ -request->isAjax()) { - $values = SettingModel::getItem('recharge'); - return $this->fetch('setting', ['values' => $values]); - } - $model = new SettingModel; - if ($model->edit('recharge', $this->postData('recharge'))) { - return $this->renderSuccess('操作成功'); - } - return $this->renderError($model->getError() ?: '操作失败'); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/market/recharge/Plan.php b/source/application/store/controller/market/recharge/Plan.php deleted file mode 100644 index d9a61f6..0000000 --- a/source/application/store/controller/market/recharge/Plan.php +++ /dev/null @@ -1,95 +0,0 @@ -model = new PlanModel; - } - - /** - * 充值套餐列表 - * @return mixed - * @throws \think\exception\DbException - */ - public function index() - { - $list = $this->model->getList(); - return $this->fetch('index', compact('list')); - } - - /** - * 添加充值套餐 - * @return array|mixed - */ - public function add() - { - if (!$this->request->isAjax()) { - return $this->fetch('add'); - } - // 新增记录 - if ($this->model->add($this->postData('plan'))) { - return $this->renderSuccess('添加成功', url('market.recharge.plan/index')); - } - return $this->renderError($this->model->getError() ?: '添加失败'); - } - - /** - * 更新充值套餐 - * @param $plan_id - * @return array|mixed - * @throws \think\exception\DbException - */ - public function edit($plan_id) - { - // 充值套餐详情 - $model = PlanModel::detail($plan_id); - if (!$this->request->isAjax()) { - return $this->fetch('edit', compact('model')); - } - // 更新记录 - if ($model->edit($this->postData('plan'))) { - return $this->renderSuccess('更新成功', url('market.recharge.plan/index')); - } - return $this->renderError($model->getError() ?: '更新失败'); - } - - /** - * 删除充值套餐 - * @param $plan_id - * @return array|mixed - * @throws \think\exception\DbException - */ - public function delete($plan_id) - { - // 套餐详情 - $model = PlanModel::detail($plan_id); - // 更新记录 - if ($model->setDelete()) { - return $this->renderSuccess('删除成功', url('market.recharge.plan/index')); - } - return $this->renderError($model->getError() ?: '删除成功'); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/order/Operate.php b/source/application/store/controller/order/Operate.php deleted file mode 100644 index 0af2c4a..0000000 --- a/source/application/store/controller/order/Operate.php +++ /dev/null @@ -1,100 +0,0 @@ -model = new OrderModel; - } - - /** - * 订单导出 - * @param string $dataType - * @throws \think\exception\DbException - */ - public function export($dataType) - { - return $this->model->exportList($dataType, $this->request->param()); - } - - /** - * 批量发货 - * @return array|mixed - * @throws \app\common\exception\BaseException - * @throws \think\exception\PDOException - */ - public function batchDelivery() - { - if (!$this->request->isAjax()) { - return $this->fetch('batchDelivery', [ - 'express_list' => ExpressModel::getAll() - ]); - } - if ($this->model->batchDelivery($this->postData('order'))) { - return $this->renderSuccess('发货成功'); - } - return $this->renderError($this->model->getError() ?: '发货失败'); - } - - /** - * 批量发货模板 - */ - public function deliveryTpl() - { - return $this->model->deliveryTpl(); - } - - /** - * 审核:用户取消订单 - * @param $order_id - * @return array|bool - * @throws \think\exception\DbException - */ - public function confirmCancel($order_id) - { - $model = OrderModel::detail($order_id); - if ($model->confirmCancel($this->postData('order'))) { - return $this->renderSuccess('操作成功'); - } - return $this->renderError($model->getError() ?: '操作失败'); - } - - /** - * 门店自提核销 - * @param $order_id - * @return array|bool - * @throws \think\exception\DbException - */ - public function extract($order_id) - { - $model = OrderModel::detail($order_id); - $data = $this->postData('order'); - if ($model->extract($data['extract_clerk_id'])) { - return $this->renderSuccess('核销成功'); - } - return $this->renderError($model->getError() ?: '核销失败'); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/order/Refund.php b/source/application/store/controller/order/Refund.php deleted file mode 100644 index 83ef7d1..0000000 --- a/source/application/store/controller/order/Refund.php +++ /dev/null @@ -1,82 +0,0 @@ -getList($this->getData()); - return $this->fetch('index', compact('list')); - } - - /** - * 售后单详情 - * @param $order_refund_id - * @return mixed - * @throws \think\exception\DbException - */ - public function detail($order_refund_id) - { - // 售后单详情 - $detail = OrderRefundModel::detail($order_refund_id); - // 订单详情 - $order = OrderModel::detail($detail['order_id']); - // 退货地址 - $address = (new ReturnAddressModel)->getAll(); - return $this->fetch('detail', compact('detail', 'order', 'address')); - } - - /** - * 商家审核 - * @param $order_refund_id - * @return array|bool - * @throws \think\exception\DbException - */ - public function audit($order_refund_id) - { - if (!$this->request->isAjax()) { - return false; - } - $model = OrderRefundModel::detail($order_refund_id); - if ($model->audit($this->postData('refund'))) { - return $this->renderSuccess('操作成功'); - } - return $this->renderError($model->getError() ?: '操作失败'); - } - - /** - * 确认收货并退款 - * @param $order_refund_id - * @return array|bool - * @throws \think\exception\DbException - */ - public function receipt($order_refund_id) - { - if (!$this->request->isAjax()) { - return false; - } - $model = OrderRefundModel::detail($order_refund_id); - if ($model->receipt($this->postData('refund'))) { - return $this->renderSuccess('操作成功'); - } - return $this->renderError($model->getError() ?: '操作失败'); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/setting/Address.php b/source/application/store/controller/setting/Address.php deleted file mode 100644 index c5efa4e..0000000 --- a/source/application/store/controller/setting/Address.php +++ /dev/null @@ -1,79 +0,0 @@ -getList(); - return $this->fetch('index', compact('list')); - } - - /** - * 添加退货地址 - * @return array|mixed - */ - public function add() - { - if (!$this->request->isAjax()) { - return $this->fetch('add'); - } - // 新增记录 - $model = new ReturnAddressModel; - if ($model->add($this->postData('address'))) { - return $this->renderSuccess('添加成功', url('setting.address/index')); - } - return $this->renderError($model->getError() ?: '添加失败'); - } - - /** - * 编辑退货地址 - * @param $address_id - * @return array|mixed - * @throws \think\exception\DbException - */ - public function edit($address_id) - { - // 模板详情 - $model = ReturnAddressModel::detail($address_id); - if (!$this->request->isAjax()) { - return $this->fetch('edit', compact('model')); - } - // 更新记录 - if ($model->edit($this->postData('address'))) { - return $this->renderSuccess('更新成功', url('setting.address/index')); - } - return $this->renderError($model->getError() ?: '更新失败'); - } - - /** - * 删除退货地址 - * @param $address_id - * @return array - * @throws \think\exception\DbException - */ - public function delete($address_id) - { - $model = ReturnAddressModel::detail($address_id); - if (!$model->remove()) { - return $this->renderError($model->getError() ?: '删除失败'); - } - return $this->renderSuccess('删除成功'); - } - -} diff --git a/source/application/store/controller/setting/Cache.php b/source/application/store/controller/setting/Cache.php deleted file mode 100644 index 6ad76ae..0000000 --- a/source/application/store/controller/setting/Cache.php +++ /dev/null @@ -1,137 +0,0 @@ -request->isAjax()) { - $data = $this->postData('cache'); - $this->rmCache($data['keys']); - return $this->renderSuccess('操作成功'); - } - return $this->fetch('clear', [ - 'cacheList' => $this->getItems() - ]); - } - - /** - * 数据缓存项目 - * @return array - */ - private function getItems() - { - $wxapp_id = $this->store['wxapp']['wxapp_id']; - return [ - 'category' => [ - 'type' => 'cache', - 'key' => 'category_' . $wxapp_id, - 'name' => '商品分类' - ], - 'setting' => [ - 'type' => 'cache', - 'key' => 'setting_' . $wxapp_id, - 'name' => '商城设置' - ], - 'wxapp' => [ - 'type' => 'cache', - 'key' => 'wxapp_' . $wxapp_id, - 'name' => '小程序设置' - ], - 'dealer' => [ - 'type' => 'cache', - 'key' => 'dealer_setting_' . $wxapp_id, - 'name' => '分销设置' - ], - 'sharing' => [ - 'type' => 'cache', - 'key' => 'sharing_setting_' . $wxapp_id, - 'name' => '拼团设置' - ], - 'temp' => [ - 'type' => 'file', - 'name' => '临时图片', - 'dirPath' => [ - 'web' => WEB_PATH . 'temp/' . $wxapp_id . '/', - 'runtime' => RUNTIME_PATH . '/' . 'image/' . $wxapp_id . '/' - ] - ], - ]; - } - - /** - * 删除缓存 - * @param $keys - */ - private function rmCache($keys) - { - $cacheList = $this->getItems(); - $keys = array_intersect(array_keys($cacheList), $keys); - foreach ($keys as $key) { - $item = $cacheList[$key]; - if ($item['type'] === 'cache') { - Driver::has($item['key']) && Driver::rm($item['key']); - } elseif ($item['type'] === 'file') { - $this->deltree($item['dirPath']); - } - } - } - - /** - * 删除目录下所有文件 - * @param $dirPath - * @return bool - */ - private function deltree($dirPath) - { - if (is_array($dirPath)) { - foreach ($dirPath as $path) - $this->deleteFolder($path); - } else { - return $this->deleteFolder($dirPath); - } - return true; - } - - /** - * 递归删除指定目录下所有文件 - * @param $path - * @return bool - */ - private function deleteFolder($path) - { - if (!is_dir($path)) - return false; - // 扫描一个文件夹内的所有文件夹和文件 - foreach (scandir($path) as $val) { - // 排除目录中的.和.. - if (!in_array($val, ['.', '..'])) { - // 如果是目录则递归子目录,继续操作 - if (is_dir($path . $val)) { - // 子目录中操作删除文件夹和文件 - $this->deleteFolder($path . $val . DS); - // 目录清空后删除空文件夹 - rmdir($path . $val . DS); - } else { - // 如果是文件直接删除 - unlink($path . $val); - } - } - } - return true; - } - -} diff --git a/source/application/store/controller/setting/Delivery.php b/source/application/store/controller/setting/Delivery.php deleted file mode 100644 index 08dbc3e..0000000 --- a/source/application/store/controller/setting/Delivery.php +++ /dev/null @@ -1,92 +0,0 @@ -getList(); - return $this->fetch('index', compact('list')); - } - - /** - * 删除模板 - * @param $delivery_id - * @return array - * @throws \think\Exception - * @throws \think\exception\DbException - * @throws \think\exception\PDOException - */ - public function delete($delivery_id) - { - $model = DeliveryModel::detail($delivery_id); - if (!$model->remove()) { - return $this->renderError($model->getError() ?: '删除失败'); - } - return $this->renderSuccess('删除成功'); - } - - /** - * 添加配送模板 - * @return array|mixed - * @throws \think\Exception - * @throws \think\exception\PDOException - */ - public function add() - { - if (!$this->request->isAjax()) { - // 获取所有地区 - $regionData = json_encode(Region::getCacheTree()); - return $this->fetch('add', compact('regionData')); - } - // 新增记录 - $model = new DeliveryModel; - if ($model->add($this->postData('delivery'))) { - return $this->renderSuccess('添加成功', url('setting.delivery/index')); - } - return $this->renderError($model->getError() ?: '添加失败'); - } - - /** - * 编辑配送模板 - * @param $delivery_id - * @return array|mixed - * @throws \think\Exception - * @throws \think\exception\DbException - * @throws \think\exception\PDOException - */ - public function edit($delivery_id) - { - // 模板详情 - $model = DeliveryModel::detail($delivery_id); - if (!$this->request->isAjax()) { - // 获取所有地区 - $regionData = json_encode(Region::getCacheTree()); - // 获取配送区域及运费设置项 - $formData = json_encode($model->getFormList()); - return $this->fetch('add', compact('model', 'regionData', 'formData')); - } - // 更新记录 - if ($model->edit($this->postData('delivery'))) { - return $this->renderSuccess('更新成功', url('setting.delivery/index')); - } - return $this->renderError($model->getError() ?: '更新失败'); - } - -} diff --git a/source/application/store/controller/setting/Express.php b/source/application/store/controller/setting/Express.php deleted file mode 100644 index e82a849..0000000 --- a/source/application/store/controller/setting/Express.php +++ /dev/null @@ -1,89 +0,0 @@ -getList(); - return $this->fetch('index', compact('list')); - } - - /** - * 删除物流公司 - * @param $express_id - * @return array - * @throws \think\exception\DbException - */ - public function delete($express_id) - { - $model = ExpressModel::detail($express_id); - if (!$model->remove()) { - $error = $model->getError() ?: '删除失败'; - return $this->renderError($error); - } - return $this->renderSuccess('删除成功'); - } - - /** - * 添加物流公司 - * @return array|mixed - */ - public function add() - { - if (!$this->request->isAjax()) { - return $this->fetch('add'); - } - // 新增记录 - $model = new ExpressModel; - if ($model->add($this->postData('express'))) { - return $this->renderSuccess('添加成功', url('setting.express/index')); - } - return $this->renderError($model->getError() ?: '添加失败'); - } - - /** - * 编辑物流公司 - * @param $express_id - * @return array|mixed - * @throws \think\exception\DbException - */ - public function edit($express_id) - { - // 模板详情 - $model = ExpressModel::detail($express_id); - if (!$this->request->isAjax()) { - return $this->fetch('edit', compact('model')); - } - // 更新记录 - if ($model->edit($this->postData('express'))) { - return $this->renderSuccess('更新成功', url('setting.express/index')); - } - return $this->renderError($model->getError() ?: '更新失败'); - } - - /** - * 物流公司编码表 - * @return mixed - */ - public function company() - { - return $this->fetch('company'); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/setting/Help.php b/source/application/store/controller/setting/Help.php deleted file mode 100644 index 5ebaaab..0000000 --- a/source/application/store/controller/setting/Help.php +++ /dev/null @@ -1,19 +0,0 @@ -fetch('tplMsg'); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/setting/Printer.php b/source/application/store/controller/setting/Printer.php deleted file mode 100644 index 30914a7..0000000 --- a/source/application/store/controller/setting/Printer.php +++ /dev/null @@ -1,99 +0,0 @@ -getList(); - return $this->fetch('index', compact('list')); - } - - /** - * 添加打印机 - * @return array|mixed - */ - public function add() - { - $model = new PrinterModel; - if (!$this->request->isAjax()) { - // 打印机类型列表 - $printerType = $model::getPrinterTypeList(); - return $this->fetch('add', compact('printerType')); - } - // 新增记录 - if ($model->add($this->postData('printer'))) { - return $this->renderSuccess('添加成功', url('setting.printer/index')); - } - return $this->renderError($model->getError() ?: '添加失败'); - } - - /** - * 编辑打印机 - * @param $printer_id - * @return array|mixed - * @throws \think\exception\DbException - */ - public function edit($printer_id) - { - // 模板详情 - $model = PrinterModel::detail($printer_id); - if (!$this->request->isAjax()) { - // 打印机类型列表 - $printerType = $model::getPrinterTypeList(); - return $this->fetch('edit', compact('model', 'printerType')); - } - // 更新记录 - if ($model->edit($this->postData('printer'))) { - return $this->renderSuccess('更新成功', url('setting.printer/index')); - } - return $this->renderError($model->getError() ?: '更新失败'); - } - - /** - * 删除打印机 - * @param $printer_id - * @return array - * @throws \think\exception\DbException - */ - public function delete($printer_id) - { - $model = PrinterModel::detail($printer_id); - if (!$model->setDelete()) { - return $this->renderError($model->getError() ?: '删除失败'); - } - return $this->renderSuccess('删除成功'); - } - - /** - * 测试打印接口 - * @param int $order_id - * @throws \app\common\exception\BaseException - * @throws \think\exception\DbException - */ - public function test($order_id = 180) - { - // 订单信息 - $order = \app\store\model\Order::detail($order_id); - // 实例化打印机驱动 - $Printer = new \app\common\service\order\Printer(); - $Printer->printTicket($order, \app\common\enum\OrderStatus::ORDER_PAYMENT); - } - - -} \ No newline at end of file diff --git a/source/application/store/controller/setting/Science.php b/source/application/store/controller/setting/Science.php deleted file mode 100644 index bd5dbc3..0000000 --- a/source/application/store/controller/setting/Science.php +++ /dev/null @@ -1,171 +0,0 @@ - '', - 'warning' => 'am-active', - 'danger' => 'am-danger' - ]; - - /** - * 环境检测 - */ - public function index() - { - return $this->fetch('index', [ - 'statusClass' => $this->statusClass, - 'phpinfo' => $this->phpinfo(), // 服务器信息 - 'server' => $this->server(), // PHP环境要求 - 'writeable' => $this->writeable(), // 目录权限监测 - ]); - } - - /** - * 服务器信息 - * @return array - */ - private function server() - { - return [ - 'system' => [ - 'name' => '服务器操作系统', - 'value' => PHP_OS, - 'status' => PHP_SHLIB_SUFFIX === 'dll' ? 'warning' : 'normal', - 'remark' => '建议使用 Linux 系统以提升程序性能' - ], - 'webserver' => [ - 'name' => 'Web服务器环境', - 'value' => $this->request->server('SERVER_SOFTWARE'), - 'status' => PHP_SAPI === 'isapi' ? 'warning' : 'normal', - 'remark' => '建议使用 Apache 或 Nginx 以提升程序性能' - ], - 'php' => [ - 'name' => 'PHP版本', - 'value' => PHP_VERSION, - 'status' => version_compare(PHP_VERSION, '5.4.0') === -1 ? 'danger' : 'normal', - 'remark' => 'PHP版本必须为 5.4.0 以上' - ], - 'upload_max' => [ - 'name' => '文件上传限制', - 'value' => @ini_get('file_uploads') ? ini_get('upload_max_filesize') : 'unknow', - 'status' => 'normal', - 'remark' => '' - ], - 'web_path' => [ - 'name' => '程序运行目录', - 'value' => WEB_PATH, - 'status' => 'normal', - 'remark' => '' - ], - ]; - } - - /** - * PHP环境要求 - * @return array - */ - private function phpinfo() - { - return [ - 'php_version' => [ - 'name' => 'PHP版本', - 'value' => '5.4.0及以上', - 'status' => version_compare(PHP_VERSION, '5.4.0') === -1 ? 'danger' : 'normal', - 'remark' => 'PHP版本必须为 5.4.0及以上' - ], - 'curl' => [ - 'name' => 'CURL', - 'value' => '支持', - 'status' => extension_loaded('curl') && function_exists('curl_init') ? 'normal' : 'danger', - 'remark' => '您的PHP环境不支持CURL, 系统无法正常运行' - ], - 'openssl' => [ - 'name' => 'OpenSSL', - 'value' => '支持', - 'status' => extension_loaded('openssl') ? 'normal' : 'danger', - 'remark' => '没有启用OpenSSL, 将无法访问微信平台的接口' - ], - 'pdo' => [ - 'name' => 'PDO', - 'value' => '支持', - 'status' => extension_loaded('PDO') && extension_loaded('pdo_mysql') ? 'normal' : 'danger', - 'remark' => '您的PHP环境不支持PDO, 系统无法正常运行' - ], - 'bcmath' => [ - 'name' => 'BCMath', - 'value' => '支持', - 'status' => extension_loaded('bcmath') ? 'normal' : 'danger', - 'remark' => '您的PHP环境不支持BCMath, 系统无法正常运行' - ], - ]; - - } - - /** - * 目录权限监测 - */ - private function writeable() - { - $paths = [ - 'uploads' => realpath(WEB_PATH) . '/uploads/', - 'wxpay_log' => realpath(APP_PATH) . '/common/library/wechat/logs/', - 'behavior_log' => realpath(APP_PATH) . '/task/behavior/logs/', - ]; - return [ - 'uploads' => [ - 'name' => '文件上传目录', - 'value' => $paths['uploads'], - 'status' => $this->checkWriteable($paths['uploads']) ? 'normal' : 'danger', - 'remark' => '目录不可写,系统将无法正常上传文件' - ], - 'wxpay_log' => [ - 'name' => '微信支付日志目录', - 'value' => $paths['wxpay_log'], - 'status' => $this->checkWriteable($paths['wxpay_log']) ? 'normal' : 'danger', - 'remark' => '目录不可写,系统将无法正常上传文件' - ], - 'behavior_log' => [ - 'name' => '自动任务日志目录', - 'value' => $paths['behavior_log'], - 'status' => $this->checkWriteable($paths['behavior_log']) ? 'normal' : 'danger', - 'remark' => '目录不可写,系统将无法正常上传文件' - ], - ]; - - } - - /** - * 检查目录是否可写 - * @param $path - * @return bool - */ - private function checkWriteable($path) - { - try { - !is_dir($path) && mkdir($path, 0755); - if (!is_dir($path)) - return false; - $fileName = $path . '/_test_write.txt'; - if ($fp = fopen($fileName, 'w')) { - return fclose($fp) && unlink($fileName); - } - } catch (\Exception $e) { - } - return false; - } - -} diff --git a/source/application/store/controller/shop/Clerk.php b/source/application/store/controller/shop/Clerk.php deleted file mode 100644 index 3f464be..0000000 --- a/source/application/store/controller/shop/Clerk.php +++ /dev/null @@ -1,91 +0,0 @@ -getList(-1, $shop_id, $search); - // 门店列表 - $shopList = ShopModel::getAllList(); - return $this->fetch('index', compact('list', 'shopList')); - } - - /** - * 添加店员 - * @return array|bool|mixed - * @throws \Exception - */ - public function add() - { - $model = new ClerkModel; - if (!$this->request->isAjax()) { - // 门店列表 - $shopList = ShopModel::getAllList(); - return $this->fetch('add', compact('shopList')); - } - // 新增记录 - if ($model->add($this->postData('clerk'))) { - return $this->renderSuccess('添加成功', url('shop.clerk/index')); - } - return $this->renderError($model->getError() ?: '添加失败'); - } - - /** - * 编辑店员 - * @param $clerk_id - * @return array|bool|mixed - * @throws \think\exception\DbException - */ - public function edit($clerk_id) - { - // 店员详情 - $model = ClerkModel::detail($clerk_id); - if (!$this->request->isAjax()) { - // 门店列表 - $shopList = ShopModel::getAllList(); - return $this->fetch('edit', compact('model', 'shopList')); - } - // 新增记录 - if ($model->edit($this->postData('clerk'))) { - return $this->renderSuccess('更新成功', url('shop.clerk/index')); - } - return $this->renderError($model->getError() ?: '更新失败'); - } - - /** - * 删除店员 - * @param $clerk_id - * @return array - * @throws \think\exception\DbException - */ - public function delete($clerk_id) - { - // 店员详情 - $model = ClerkModel::detail($clerk_id); - if (!$model->setDelete()) { - return $this->renderError($model->getError() ?: '删除失败'); - } - return $this->renderSuccess('删除成功'); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/shop/Order.php b/source/application/store/controller/shop/Order.php deleted file mode 100644 index c8d0cfa..0000000 --- a/source/application/store/controller/shop/Order.php +++ /dev/null @@ -1,33 +0,0 @@ -getList($shop_id, $search); - // 门店列表 - $shopList = ShopModel::getAllList(); - return $this->fetch('index', compact('list', 'shopList')); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/store/Role.php b/source/application/store/controller/store/Role.php deleted file mode 100644 index 6365243..0000000 --- a/source/application/store/controller/store/Role.php +++ /dev/null @@ -1,100 +0,0 @@ -getList(); - return $this->fetch('index', compact('list')); - } - - /** - * 添加角色 - * @return array|mixed - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - * @throws \Exception - */ - public function add() - { - $model = new RoleModel; - if (!$this->request->isAjax()) { - // 权限列表 - $accessList = (new AccessModel)->getJsTree(); - // 角色列表 - $roleList = $model->getList(); - return $this->fetch('add', compact('accessList', 'roleList')); - } - // 新增记录 - if ($model->add($this->postData('role'))) { - return $this->renderSuccess('添加成功', url('store.role/index')); - } - return $this->renderError($model->getError() ?: '添加失败'); - } - - /** - * 更新角色 - * @param $role_id - * @return array|mixed - * @throws \think\Exception - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - * @throws \think\exception\PDOException - */ - public function edit($role_id) - { - // 角色详情 - $model = RoleModel::detail($role_id); - if (!$this->request->isAjax()) { - // 权限列表 - $accessList = (new AccessModel)->getJsTree($model['role_id']); - // 角色列表 - $roleList = $model->getList(); - return $this->fetch('edit', compact('model', 'accessList', 'roleList')); - } - // 更新记录 - if ($model->edit($this->postData('role'))) { - return $this->renderSuccess('更新成功', url('store.role/index')); - } - return $this->renderError($model->getError() ?: '更新失败'); - } - - /** - * 删除角色 - * @param $role_id - * @return array - * @throws \think\exception\DbException - */ - public function delete($role_id) - { - // 角色详情 - $model = RoleModel::detail($role_id); - if (!$model->remove()) { - return $this->renderError($model->getError() ?: '删除失败'); - } - return $this->renderSuccess('删除成功'); - } - -} diff --git a/source/application/store/controller/store/User.php b/source/application/store/controller/store/User.php deleted file mode 100644 index 781d139..0000000 --- a/source/application/store/controller/store/User.php +++ /dev/null @@ -1,115 +0,0 @@ -getList(); - return $this->fetch('index', compact('list')); - } - - /** - * 添加管理员 - * @return array|mixed - * @throws \think\Exception - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - */ - public function add() - { - $model = new StoreUserModel; - if (!$this->request->isAjax()) { - // 角色列表 - $roleList = (new RoleModel)->getList(); - return $this->fetch('add', compact('roleList')); - } - // 新增记录 - if ($model->add($this->postData('user'))) { - return $this->renderSuccess('添加成功', url('store.user/index')); - } - return $this->renderError($model->getError() ?: '添加失败'); - } - - /** - * 更新管理员 - * @param $user_id - * @return array|mixed - * @throws \think\Exception - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - */ - public function edit($user_id) - { - // 管理员详情 - $model = StoreUserModel::detail($user_id); - $model['roleIds'] = UserRole::getRoleIds($model['store_user_id']); - if (!$this->request->isAjax()) { - return $this->fetch('edit', [ - 'model' => $model, - // 角色列表 - 'roleList' => (new RoleModel)->getList(), - // 所有角色id - 'roleIds' => UserRole::getRoleIds($model['store_user_id']), - ]); - } - // 更新记录 - if ($model->edit($this->postData('user'))) { - return $this->renderSuccess('更新成功', url('store.user/index')); - } - return $this->renderError($model->getError() ?: '更新失败'); - } - - /** - * 删除管理员 - * @param $user_id - * @return array - * @throws \think\exception\DbException - */ - public function delete($user_id) - { - // 管理员详情 - $model = StoreUserModel::detail($user_id); - if (!$model->setDelete()) { - return $this->renderError($model->getError() ?: '删除失败'); - } - return $this->renderSuccess('删除成功'); - } - - /** - * 更新当前管理员信息 - * @return array|mixed - * @throws \think\exception\DbException - */ - public function renew() - { - // 管理员详情 - $model = StoreUserModel::detail($this->store['user']['store_user_id']); - if ($this->request->isAjax()) { - if ($model->renew($this->postData('user'))) { - return $this->renderSuccess('更新成功'); - } - return $this->renderError($model->getError() ?: '更新失败'); - } - return $this->fetch('renew', compact('model')); - } -} diff --git a/source/application/store/controller/upload/Library.php b/source/application/store/controller/upload/Library.php deleted file mode 100644 index b322262..0000000 --- a/source/application/store/controller/upload/Library.php +++ /dev/null @@ -1,104 +0,0 @@ -getList($type); - // 文件列表 - $file_list = (new UploadFileModel)->getlist(intval($group_id), $type); - return $this->renderSuccess('success', '', compact('group_list', 'file_list')); - } - - /** - * 新增分组 - * @param $group_name - * @param string $group_type - * @return array - */ - public function addGroup($group_name, $group_type = 'image') - { - $model = new UploadGroupModel; - if ($model->add(compact('group_name', 'group_type'))) { - $group_id = $model->getLastInsID(); - return $this->renderSuccess('添加成功', '', compact('group_id', 'group_name')); - } - return $this->renderError($model->getError() ?: '添加失败'); - } - - /** - * 编辑分组 - * @param $group_id - * @param $group_name - * @return array - * @throws \think\exception\DbException - */ - public function editGroup($group_id, $group_name) - { - $model = UploadGroupModel::detail($group_id); - if ($model->edit(compact('group_name'))) { - return $this->renderSuccess('修改成功'); - } - return $this->renderError($model->getError() ?: '修改失败'); - } - - /** - * 删除分组 - * @param $group_id - * @return array - * @throws \think\exception\DbException - */ - public function deleteGroup($group_id) - { - $model = UploadGroupModel::detail($group_id); - if ($model->remove()) { - return $this->renderSuccess('删除成功'); - } - return $this->renderError($model->getError() ?: '删除失败'); - } - - /** - * 批量删除文件 - * @param $fileIds - * @return array - */ - public function deleteFiles($fileIds) - { - $model = new UploadFileModel; - if ($model->softDelete($fileIds)) { - return $this->renderSuccess('删除成功'); - } - return $this->renderError($model->getError() ?: '删除失败'); - } - - /** - * 批量移动文件分组 - * @param $group_id - * @param $fileIds - * @return array - */ - public function moveFiles($group_id, $fileIds) - { - $model = new UploadFileModel; - if ($model->moveGroup($group_id, $fileIds) !== false) { - return $this->renderSuccess('移动成功'); - } - return $this->renderError($model->getError() ?: '移动失败'); - } -} diff --git a/source/application/store/controller/user/Balance.php b/source/application/store/controller/user/Balance.php deleted file mode 100644 index 4247abe..0000000 --- a/source/application/store/controller/user/Balance.php +++ /dev/null @@ -1,31 +0,0 @@ -fetch('log', [ - // 充值记录列表 - 'list' => $model->getList($this->request->param()), - // 属性集 - 'attributes' => $model::getAttributes(), - ]); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/user/Recharge.php b/source/application/store/controller/user/Recharge.php deleted file mode 100644 index 7de910b..0000000 --- a/source/application/store/controller/user/Recharge.php +++ /dev/null @@ -1,31 +0,0 @@ -fetch('order', [ - // 充值记录列表 - 'list' => $model->getList($this->request->param()), - // 属性集 - 'attributes' => $model::getAttributes(), - ]); - } - -} \ No newline at end of file diff --git a/source/application/store/controller/wxapp/Help.php b/source/application/store/controller/wxapp/Help.php deleted file mode 100644 index 1196ec2..0000000 --- a/source/application/store/controller/wxapp/Help.php +++ /dev/null @@ -1,82 +0,0 @@ -getList(); - return $this->fetch('index', compact('list')); - } - - /** - * 添加帮助 - * @return array|mixed - */ - public function add() - { - $model = new WxappHelpModel; - if (!$this->request->isAjax()) { - return $this->fetch('add'); - } - // 新增记录 - if ($model->add($this->postData('help'))) { - return $this->renderSuccess('添加成功', url('wxapp.help/index')); - } - return $this->renderError($model->getError() ?: '添加失败'); - } - - /** - * 更新帮助 - * @param $help_id - * @return array|mixed - * @throws \think\exception\DbException - */ - public function edit($help_id) - { - // 帮助详情 - $model = WxappHelpModel::detail($help_id); - if (!$this->request->isAjax()) { - return $this->fetch('edit', compact('model')); - } - // 更新记录 - if ($model->edit($this->postData('help'))) { - return $this->renderSuccess('更新成功', url('wxapp.help/index')); - } - return $this->renderError($model->getError() ?: '更新失败'); - } - - /** - * 删除帮助 - * @param $help_id - * @return array - * @throws \think\exception\DbException - */ - public function delete($help_id) - { - // 帮助详情 - $model = WxappHelpModel::detail($help_id); - if (!$model->remove()) { - return $this->renderError($model->getError() ?: '删除失败'); - } - return $this->renderSuccess('删除成功'); - } - -} diff --git a/source/application/store/controller/wxapp/Page.php b/source/application/store/controller/wxapp/Page.php deleted file mode 100644 index 35ee006..0000000 --- a/source/application/store/controller/wxapp/Page.php +++ /dev/null @@ -1,145 +0,0 @@ -getList(); - return $this->fetch('index', compact('list')); - } - - /** - * 新增页面 - * @return array|mixed - */ - public function add() - { - $model = new WxappPageModel; - if (!$this->request->isAjax()) { - return $this->fetch('edit', [ - 'defaultData' => json_encode($model->getDefaultItems()), - 'jsonData' => json_encode(['page' => $model->getDefaultPage(), 'items' => []]), - 'opts' => json_encode([ - 'catgory' => CategoryModel::getCacheTree(), - 'sharingCatgory' => SharingCategoryModel::getCacheTree(), - 'articleCatgory' => ArticleCategoryModel::getALL(), - ]) - ]); - } - // 接收post数据 - $post = $this->request->post('data', null, null); - if (!$model->add(json_decode($post, true))) { - return $this->renderError('添加失败'); - } - return $this->renderSuccess('添加成功', url('wxapp.page/index')); - } - - /** - * 编辑页面 - * @param $page_id - * @return array|mixed - * @throws \think\exception\DbException - */ - public function edit($page_id) - { - $model = WxappPageModel::detail($page_id); - if (!$this->request->isAjax()) { - return $this->fetch('edit', [ - 'defaultData' => json_encode($model->getDefaultItems()), - 'jsonData' => json_encode($model['page_data']), - 'opts' => json_encode([ - 'catgory' => CategoryModel::getCacheTree(), - 'sharingCatgory' => SharingCategoryModel::getCacheTree(), - 'articleCatgory' => ArticleCategoryModel::getALL(), - ]) - ]); - } - // 接收post数据 - $post = $this->request->post('data', null, null); - if (!$model->edit(json_decode($post, true))) { - return $this->renderError('更新失败'); - } - return $this->renderSuccess('更新成功'); - } - - /** - * 删除页面 - * @param $page_id - * @return array - * @throws \think\exception\DbException - */ - public function delete($page_id) - { - // 帮助详情 - $model = WxappPageModel::detail($page_id); - if (!$model->setDelete()) { - return $this->renderError($model->getError() ?: '删除失败'); - } - return $this->renderSuccess('删除成功'); - } - - /** - * 设置默认首页 - * @param $page_id - * @return array - * @throws \think\exception\DbException - */ - public function setHome($page_id) - { - // 帮助详情 - $model = WxappPageModel::detail($page_id); - if (!$model->setHome()) { - return $this->renderError($model->getError() ?: '设置失败'); - } - return $this->renderSuccess('设置成功'); - } - - /** - * 分类模板 - * @return array|mixed - * @throws \think\exception\DbException - */ - public function category() - { - $model = WxappCategoryModel::detail(); - if ($this->request->isAjax()) { - if ($model->edit($this->postData('category'))) { - return $this->renderSuccess('更新成功'); - } - return $this->renderError($model->getError() ?: '更新失败'); - } - return $this->fetch('category', compact('model')); - } - - /** - * 页面链接 - * @return mixed - */ - public function links() - { - return $this->fetch('links'); - } - -} diff --git a/source/application/store/controller/wxapp/Submsg.php b/source/application/store/controller/wxapp/Submsg.php deleted file mode 100644 index 7f172f0..0000000 --- a/source/application/store/controller/wxapp/Submsg.php +++ /dev/null @@ -1,50 +0,0 @@ -request->isAjax()) { - $values = SettingModel::getItem('submsg'); - return $this->fetch('index', compact('values')); - } - $model = new SettingModel; - if ($model->edit('submsg', $this->postData('submsg'))) { - return $this->renderSuccess('操作成功'); - } - return $this->renderError($model->getError() ?: '操作失败'); - } - - /** - * 一键添加订阅消息 - * @return array - * @throws \app\common\exception\BaseException - * @throws \think\Exception - * @throws \think\exception\DbException - */ - public function shuttle() - { - $SubMsgService = new SubMsgService; - if ($SubMsgService->shuttle()) { - return $this->renderSuccess('操作成功'); - } - return $this->renderError($SubMsgService->getError() ?: '操作失败'); - } - -} \ No newline at end of file diff --git a/source/application/store/extra/menus.php b/source/application/store/extra/menus.php deleted file mode 100644 index f053b92..0000000 --- a/source/application/store/extra/menus.php +++ /dev/null @@ -1,668 +0,0 @@ - [ - * 'name' => '首页', // 菜单名称 - * 'icon' => 'icon-home', // 图标 (class) - * 'index' => 'index/index', // 链接 - * ], - */ -return [ - 'index' => [ - 'name' => '首页', - 'icon' => 'icon-home', - 'index' => 'index/index', - ], - 'store' => [ - 'name' => '管理员', - 'icon' => 'icon-guanliyuan', - 'index' => 'store.user/index', - 'submenu' => [ - [ - 'name' => '管理员列表', - 'index' => 'store.user/index', - 'uris' => [ - 'store.user/index', - 'store.user/add', - 'store.user/edit', - 'store.user/delete', - ], - ], - [ - 'name' => '角色管理', - 'index' => 'store.role/index', - 'uris' => [ - 'store.role/index', - 'store.role/add', - 'store.role/edit', - 'store.role/delete', - ], - ], - ] - ], - 'goods' => [ - 'name' => '商品管理', - 'icon' => 'icon-goods', - 'index' => 'goods/index', - 'submenu' => [ - [ - 'name' => '商品列表', - 'index' => 'goods/index', - 'uris' => [ - 'goods/index', - 'goods/add', - 'goods/edit', - 'goods/copy' - ], - ], - [ - 'name' => '商品分类', - 'index' => 'goods.category/index', - 'uris' => [ - 'goods.category/index', - 'goods.category/add', - 'goods.category/edit', - ], - ], - [ - 'name' => '商品评价', - 'index' => 'goods.comment/index', - 'uris' => [ - 'goods.comment/index', - 'goods.comment/detail', - ], - ] - ], - ], - 'order' => [ - 'name' => '订单管理', - 'icon' => 'icon-order', - 'index' => 'order/all_list', - 'submenu' => [ - [ - 'name' => '全部订单', - 'index' => 'order/all_list', - ], - [ - 'name' => '待发货', - 'index' => 'order/delivery_list', - ], - [ - 'name' => '待收货', - 'index' => 'order/receipt_list', - ], - [ - 'name' => '待付款', - 'index' => 'order/pay_list', - ], - [ - 'name' => '已完成', - 'index' => 'order/complete_list', - - ], - [ - 'name' => '已取消', - 'index' => 'order/cancel_list', - ], - [ - 'name' => '售后管理', - 'index' => 'order.refund/index', - 'uris' => [ - 'order.refund/index', - 'order.refund/detail', - ] - ], - ] - ], - 'user' => [ - 'name' => '用户管理', - 'icon' => 'icon-user', - 'index' => 'user/index', - 'submenu' => [ - [ - 'name' => '用户列表', - 'index' => 'user/index', - ], - [ - 'name' => '会员等级', - 'active' => true, - 'submenu' => [ - [ - 'name' => '等级管理', - 'index' => 'user.grade/index', - 'uris' => [ - 'user.grade/index', - 'user.grade/add', - 'user.grade/edit', - 'user.grade/delete', - ] - ], - ] - ], - [ - 'name' => '余额记录', - 'active' => true, - 'submenu' => [ - [ - 'name' => '充值记录', - 'index' => 'user.recharge/order', - ], - [ - 'name' => '余额明细', - 'index' => 'user.balance/log', - ], - ] - ], - ] - ], - 'shop' => [ - 'name' => '门店管理', - 'icon' => 'icon-shop', - 'index' => 'shop/index', - 'submenu' => [ - [ - 'name' => '门店管理', - 'active' => true, - 'index' => 'shop/index', - 'submenu' => [ - [ - 'name' => '门店列表', - 'index' => 'shop/index', - 'uris' => [ - 'shop/index', - 'shop/add', - 'shop/edit', - ] - ], - [ - 'name' => '店员管理', - 'index' => 'shop.clerk/index', - 'uris' => [ - 'shop.clerk/index', - 'shop.clerk/add', - 'shop.clerk/edit', - ] - ], - ] - ], - [ - 'name' => '订单核销记录', - 'index' => 'shop.order/index', - ] - ] - ], - 'content' => [ - 'name' => '内容管理', - 'icon' => 'icon-wenzhang', - 'index' => 'content.article/index', - 'submenu' => [ - [ - 'name' => '文章管理', - 'active' => true, - 'submenu' => [ - [ - 'name' => '文章列表', - 'index' => 'content.article/index', - 'uris' => [ - 'content.article/index', - 'content.article/add', - 'content.article/edit', - ] - ], - [ - 'name' => '文章分类', - 'index' => 'content.article.category/index', - 'uris' => [ - 'content.article.category/index', - 'content.article.category/add', - 'content.article.category/edit', - ] - ], - ] - ], - [ - 'name' => '文件库管理', - 'submenu' => [ - [ - 'name' => '文件分组', - 'index' => 'content.files.group/index', - 'uris' => [ - 'content.files.group/index', - 'content.files.group/add', - 'content.files.group/edit', - ] - ], - [ - 'name' => '文件列表', - 'index' => 'content.files/index' - ], - [ - 'name' => '回收站', - 'index' => 'content.files/recycle', - ], - ] - ], - ] - ], - 'market' => [ - 'name' => '营销管理', - 'icon' => 'icon-marketing', - 'index' => 'market.coupon/index', - 'submenu' => [ - [ - 'name' => '优惠券', -// 'active' => true, - 'submenu' => [ - [ - 'name' => '优惠券列表', - 'index' => 'market.coupon/index', - 'uris' => [ - 'market.coupon/index', - 'market.coupon/add', - 'market.coupon/edit', - ] - ], - [ - 'name' => '领取记录', - 'index' => 'market.coupon/receive' - ], - ] - ], - [ - 'name' => '用户充值', - 'submenu' => [ - [ - 'name' => '充值套餐', - 'index' => 'market.recharge.plan/index', - 'uris' => [ - 'market.recharge.plan/index', - 'market.recharge.plan/add', - 'market.recharge.plan/edit', - ] - ], - [ - 'name' => '充值设置', - 'index' => 'market.recharge/setting' - ], - ] - ], - [ - 'name' => '积分管理', - 'submenu' => [ - [ - 'name' => '积分设置', - 'index' => 'market.points/setting' - ], - [ - 'name' => '积分明细', - 'index' => 'market.points/log' - ], - ] - ], - [ - 'name' => '消息推送', - 'submenu' => [ - [ - 'name' => '发送消息', - 'index' => 'market.push/send', - ], - [ - 'name' => '活跃用户', - 'index' => 'market.push/user', - ], -// [ -// 'name' => '发送日志', -// 'index' => 'market.push/log', -// ], - ] - ], - [ - 'name' => '满额包邮', - 'index' => 'market.basic/full_free', - ], - ], - ], - 'statistics' => [ - 'name' => '数据统计', - 'icon' => 'icon-qushitu', - 'index' => 'statistics.data/index', - ], - 'wxapp' => [ - 'name' => '小程序', - 'icon' => 'icon-wxapp', - 'color' => '#36b313', - 'index' => 'wxapp/setting', - 'submenu' => [ - [ - 'name' => '小程序设置', - 'index' => 'wxapp/setting', - ], - [ - 'name' => '页面管理', - 'active' => true, - 'submenu' => [ - [ - 'name' => '页面设计', - 'index' => 'wxapp.page/index', - 'uris' => [ - 'wxapp.page/index', - 'wxapp.page/add', - 'wxapp.page/edit', - ] - ], - [ - 'name' => '分类模板', - 'index' => 'wxapp.page/category' - ], - [ - 'name' => '页面链接', - 'index' => 'wxapp.page/links' - ] - ] - ], - [ - 'name' => '订阅消息', - 'index' => 'wxapp.submsg/index', - 'uris' => [ - 'wxapp.submsg/index', - ] - ], - [ - 'name' => '帮助中心', - 'index' => 'wxapp.help/index', - 'uris' => [ - 'wxapp.help/index', - 'wxapp.help/add', - 'wxapp.help/edit' - ] - ], - ], - ], - 'apps' => [ - 'name' => '应用中心', - 'icon' => 'icon-application', - 'is_svg' => true, // 多色图标 - 'index' => 'apps.dealer.apply/index', - 'submenu' => [ - [ - 'name' => '分销中心', - 'submenu' => [ - [ - 'name' => '入驻申请', - 'index' => 'apps.dealer.apply/index', - ], - [ - 'name' => '分销商用户', - 'index' => 'apps.dealer.user/index', - 'uris' => [ - 'apps.dealer.user/index', - 'apps.dealer.user/edit', - 'apps.dealer.user/fans', - ] - ], - [ - 'name' => '分销订单', - 'index' => 'apps.dealer.order/index', - ], - [ - 'name' => '提现申请', - 'index' => 'apps.dealer.withdraw/index', - ], - [ - 'name' => '分销设置', - 'index' => 'apps.dealer.setting/index', - ], - [ - 'name' => '分销海报', - 'index' => 'apps.dealer.setting/qrcode', - ], - ] - ], - [ - 'name' => '拼团管理', - 'submenu' => [ - [ - 'name' => '商品分类', - 'index' => 'apps.sharing.category/index', - 'uris' => [ - 'apps.sharing.category/index', - 'apps.sharing.category/add', - 'apps.sharing.category/edit', - ] - ], - [ - 'name' => '商品列表', - 'index' => 'apps.sharing.goods/index', - 'uris' => [ - 'apps.sharing.goods/index', - 'apps.sharing.goods/add', - 'apps.sharing.goods/edit', - 'apps.sharing.goods/copy', - 'apps.sharing.goods/copy_master', - ] - ], - [ - 'name' => '拼单管理', - 'index' => 'apps.sharing.active/index', - 'uris' => [ - 'apps.sharing.active/index', - 'apps.sharing.active/users', - ] - ], - [ - 'name' => '订单管理', - 'index' => 'apps.sharing.order/index', - 'uris' => [ - 'apps.sharing.order/index', - 'apps.sharing.order/detail', - 'apps.sharing.order.operate/batchdelivery' - ] - ], - [ - 'name' => '售后管理', - 'index' => 'apps.sharing.order.refund/index', - 'uris' => [ - 'apps.sharing.order.refund/index', - 'apps.sharing.order.refund/detail', - ] - ], - [ - 'name' => '商品评价', - 'index' => 'apps.sharing.comment/index', - 'uris' => [ - 'apps.sharing.comment/index', - 'apps.sharing.comment/detail', - ], - ], - [ - 'name' => '拼团设置', - 'index' => 'apps.sharing.setting/index' - ] - ] - ], - [ - 'name' => '砍价活动', - 'index' => 'apps.bargain.active/index', - 'submenu' => [ - [ - 'name' => '活动列表', - 'index' => 'apps.bargain.active/index', - 'uris' => [ - 'apps.bargain.active/index', - 'apps.bargain.active/add', - 'apps.bargain.active/edit', - 'apps.bargain.active/delete', - ], - ], - [ - 'name' => '砍价记录', - 'index' => 'apps.bargain.task/index', - 'uris' => [ - 'apps.bargain.task/index', - 'apps.bargain.task/add', - 'apps.bargain.task/edit', - 'apps.bargain.task/delete', - 'apps.bargain.task/help', - ], - ], - [ - 'name' => '砍价设置', - 'index' => 'apps.bargain.setting/index', - ] - ] - ], - [ - 'name' => '整点秒杀', - 'index' => 'apps.sharp.goods/index', - 'submenu' => [ - [ - 'name' => '秒杀商品', - 'index' => 'apps.sharp.goods/index', - 'uris' => [ - 'apps.sharp.goods/index', - 'apps.sharp.goods/add', - 'apps.sharp.goods/select', - 'apps.sharp.goods/edit', - 'apps.sharp.goods/delete', - ], - ], - [ - 'name' => '活动会场', - 'index' => 'apps.sharp.active/index', - 'uris' => [ - 'apps.sharp.active/index', - 'apps.sharp.active/add', - 'apps.sharp.active/edit', - 'apps.sharp.active/state', - 'apps.sharp.active/delete', - - 'apps.sharp.active_time/index', - 'apps.sharp.active_time/add', - 'apps.sharp.active_time/edit', - 'apps.sharp.active_time/state', - 'apps.sharp.active_time/delete', - ], - ], - [ - 'name' => '基础设置', - 'index' => 'apps.sharp.setting/index', - ] - ] - ], - [ - 'name' => '好物圈', - 'index' => 'apps.wow.shoping/index', - 'submenu' => [ - [ - 'name' => '商品收藏', - 'index' => 'apps.wow.shoping/index', - ], - [ - 'name' => '订单信息', - 'index' => 'apps.wow.order/index', - ], - [ - 'name' => '基础设置', - 'index' => 'apps.wow.setting/index', - ] - ] - ], - [ - 'name' => '小程序直播', - 'index' => 'apps.live.room/index', - 'submenu' => [ - [ - 'name' => '直播间管理', - 'index' => 'apps.live.room/index', - ], - ] - ], - ] - ], - 'setting' => [ - 'name' => '设置', - 'icon' => 'icon-setting', - 'index' => 'setting/store', - 'submenu' => [ - [ - 'name' => '商城设置', - 'index' => 'setting/store', - ], - [ - 'name' => '交易设置', - 'index' => 'setting/trade', - ], - [ - 'name' => '运费模板', - 'index' => 'setting.delivery/index', - 'uris' => [ - 'setting.delivery/index', - 'setting.delivery/add', - 'setting.delivery/edit', - ], - ], - [ - 'name' => '物流公司', - 'index' => 'setting.express/index', - 'uris' => [ - 'setting.express/index', - 'setting.express/add', - 'setting.express/edit', - ], - ], - [ - 'name' => '短信通知', - 'index' => 'setting/sms' - ], - // [ - // 'name' => '模板消息', - // 'index' => 'setting/tplmsg', - // 'uris' => [ - // 'setting/tplmsg', - // 'setting.help/tplmsg' - // - // ], - // ], - [ - 'name' => '退货地址', - 'index' => 'setting.address/index', - 'uris' => [ - 'setting.address/index', - 'setting.address/add', - 'setting.address/edit', - ], - ], - [ - 'name' => '上传设置', - 'index' => 'setting/storage', - ], - [ - 'name' => '小票打印机', - 'submenu' => [ - [ - 'name' => '打印机管理', - 'index' => 'setting.printer/index', - 'uris' => [ - 'setting.printer/index', - 'setting.printer/add', - 'setting.printer/edit' - ] - ], - [ - 'name' => '打印设置', - 'index' => 'setting/printer' - ] - ] - ], - [ - 'name' => '其他', - 'submenu' => [ - [ - 'name' => '清理缓存', - 'index' => 'setting.cache/clear' - ] - ] - ] - ], - ], -]; diff --git a/source/application/store/model/Article.php b/source/application/store/model/Article.php deleted file mode 100644 index 7e5eb9e..0000000 --- a/source/application/store/model/Article.php +++ /dev/null @@ -1,88 +0,0 @@ -with(['image', 'category']) - ->where('is_delete', '=', 0) - ->order(['article_sort' => 'asc', 'create_time' => 'desc']) - ->paginate(15, false, [ - 'query' => request()->request() - ]); - - } - - /** - * 新增记录 - * @param $data - * @return false|int - */ - public function add($data) - { - if (empty($data['image_id'])) { - $this->error = '请上传封面图'; - return false; - } - if (empty($data['article_content'])) { - $this->error = '请输入文章内容'; - return false; - } - $data['wxapp_id'] = self::$wxapp_id; - return $this->allowField(true)->save($data); - } - - /** - * 更新记录 - * @param $data - * @return bool|int - */ - public function edit($data) - { - if (empty($data['image_id'])) { - $this->error = '请上传封面图'; - return false; - } - if (empty($data['article_content'])) { - $this->error = '请输入文章内容'; - return false; - } - return $this->allowField(true)->save($data) !== false; - } - - /** - * 软删除 - * @return false|int - */ - public function setDelete() - { - return $this->save(['is_delete' => 1]); - } - - /** - * 获取文章总数量 - * @param array $where - * @return int|string - */ - public static function getArticleTotal($where = []) - { - $model = new static; - !empty($where) && $model->where($where); - return $model->where('is_delete', '=', 0)->count(); - } - -} \ No newline at end of file diff --git a/source/application/store/model/Category.php b/source/application/store/model/Category.php deleted file mode 100644 index 5327c58..0000000 --- a/source/application/store/model/Category.php +++ /dev/null @@ -1,73 +0,0 @@ -deleteCache(); - return $this->allowField(true)->save($data); - } - - /** - * 编辑记录 - * @param $data - * @return bool|int - */ - public function edit($data) - { - $this->deleteCache(); - !array_key_exists('image_id', $data) && $data['image_id'] = 0; - return $this->allowField(true)->save($data) !== false; - } - - /** - * 删除商品分类 - * @param $category_id - * @return bool|int - * @throws \think\Exception - */ - public function remove($category_id) - { - // 判断是否存在商品 - if ($goodsCount = (new Goods)->getGoodsTotal(['category_id' => $category_id])) { - $this->error = '该分类下存在' . $goodsCount . '个商品,不允许删除'; - return false; - } - // 判断是否存在子分类 - if ((new self)->where(['parent_id' => $category_id])->count()) { - $this->error = '该分类下存在子分类,请先删除'; - return false; - } - $this->deleteCache(); - return $this->delete(); - } - - /** - * 删除缓存 - * @return bool - */ - private function deleteCache() - { - return Cache::rm('category_' . self::$wxapp_id); - } - -} diff --git a/source/application/store/model/Comment.php b/source/application/store/model/Comment.php deleted file mode 100644 index 7559c12..0000000 --- a/source/application/store/model/Comment.php +++ /dev/null @@ -1,32 +0,0 @@ -save(['is_delete' => 1]); - } - - /** - * 获取评价总数量 - * @return int|string - */ - public function getCommentTotal() - { - return $this->where(['is_delete' => 0])->count(); - } - -} \ No newline at end of file diff --git a/source/application/store/model/CommentImage.php b/source/application/store/model/CommentImage.php deleted file mode 100644 index f4704f0..0000000 --- a/source/application/store/model/CommentImage.php +++ /dev/null @@ -1,14 +0,0 @@ -where('is_delete', '=', 0) - ->order(['sort' => 'asc', 'create_time' => 'desc']) - ->paginate(15, false, [ - 'query' => request()->request() - ]); - } - - /** - * 添加新记录 - * @param $data - * @return false|int - */ - public function add($data) - { - $data['wxapp_id'] = self::$wxapp_id; - if ($data['expire_type'] == '20') { - $data['start_time'] = strtotime($data['start_time']); - $data['end_time'] = strtotime($data['end_time']); - } - return $this->allowField(true)->save($data); - } - - /** - * 更新记录 - * @param $data - * @return bool|int - */ - public function edit($data) - { - if ($data['expire_type'] == '20') { - $data['start_time'] = strtotime($data['start_time']); - $data['end_time'] = strtotime($data['end_time']); - } - return $this->allowField(true)->save($data) !== false; - } - - /** - * 删除记录 (软删除) - * @return bool|int - */ - public function setDelete() - { - return $this->save(['is_delete' => 1]) !== false; - } - -} \ No newline at end of file diff --git a/source/application/store/model/Delivery.php b/source/application/store/model/Delivery.php deleted file mode 100644 index 4bcc834..0000000 --- a/source/application/store/model/Delivery.php +++ /dev/null @@ -1,124 +0,0 @@ -error = '请选择可配送区域'; - return false; - } - $data['wxapp_id'] = self::$wxapp_id; - if ($this->allowField(true)->save($data)) { - return $this->createDeliveryRule($data['rule']); - } - return false; - } - - /** - * 编辑记录 - * @param $data - * @return bool|int - * @throws \think\Exception - * @throws \think\exception\PDOException - */ - public function edit($data) - { - if (!isset($data['rule']) || empty($data['rule'])) { - $this->error = '请选择可配送区域'; - return false; - } - if ($this->allowField(true)->save($data)) { - return $this->createDeliveryRule($data['rule']); - } - return false; - } - - /** - * 获取配送区域及运费设置项 - * @return array - */ - public function getFormList() - { - // 所有地区 - $regions = Region::getCacheAll(); - $list = []; - foreach ($this['rule'] as $rule) { - $citys = explode(',', $rule['region']); - $province = []; - foreach ($citys as $cityId) { - if (!in_array($regions[$cityId]['pid'], $province)) { - $province[] = $regions[$cityId]['pid']; - } - } - $list[] = [ - 'first' => $rule['first'], - 'first_fee' => $rule['first_fee'], - 'additional' => $rule['additional'], - 'additional_fee' => $rule['additional_fee'], - 'province' => $province, - 'citys' => $citys, - ]; - } - return $list; - } - - /** - * 添加模板区域及运费 - * @param $data - * @return int - * @throws \think\Exception - * @throws \think\exception\PDOException - */ - private function createDeliveryRule($data) - { - $save = []; - $connt = count($data['region']); - for ($i = 0; $i < $connt; $i++) { - $save[] = [ - 'region' => $data['region'][$i], - 'first' => $data['first'][$i], - 'first_fee' => $data['first_fee'][$i], - 'additional' => $data['additional'][$i], - 'additional_fee' => $data['additional_fee'][$i], - 'wxapp_id' => self::$wxapp_id - ]; - } - $this->rule()->delete(); - return $this->rule()->saveAll($save); - } - - /** - * 删除记录 - * @return int - * @throws \think\Exception - * @throws \think\exception\PDOException - */ - public function remove() - { - // 判断是否存在商品 - if ($goodsCount = (new Goods)->where(['delivery_id' => $this['delivery_id']])->count()) { - $this->error = '该模板被' . $goodsCount . '个商品使用,不允许删除'; - return false; - } - $this->rule()->delete(); - return $this->delete(); - } - -} diff --git a/source/application/store/model/DeliveryRule.php b/source/application/store/model/DeliveryRule.php deleted file mode 100644 index 2fa7e42..0000000 --- a/source/application/store/model/DeliveryRule.php +++ /dev/null @@ -1,55 +0,0 @@ - $citys) { - $str .= self::$regionTree[$provinceId]['name']; - if (count($citys) !== count(self::$regionTree[$provinceId]['city'])) { - $cityStr = ''; - foreach ($citys as $cityId) - $cityStr .= self::$regionTree[$provinceId]['city'][$cityId]['name']; - $str .= ' (' . mb_substr($cityStr, 0, -1, 'utf-8') . ')'; - } - $str .= '、'; - } - return mb_substr($str, 0, -1, 'utf-8'); - } - -} diff --git a/source/application/store/model/Express.php b/source/application/store/model/Express.php deleted file mode 100644 index d9dc09d..0000000 --- a/source/application/store/model/Express.php +++ /dev/null @@ -1,45 +0,0 @@ -allowField(true)->save($data); - } - - /** - * 编辑记录 - * @param $data - * @return bool|int - */ - public function edit($data) - { - return $this->allowField(true)->save($data); - } - - /** - * 删除记录 - * @return bool|int - */ - public function remove() - { - // 判断当前物流公司是否已被订单使用 - $Order = new Order; - if ($orderCount = $Order->where(['express_id' => $this['express_id']])->count()) { - $this->error = '当前物流公司已被' . $orderCount . '个订单使用,不允许删除'; - return false; - } - return $this->delete(); - } - -} \ No newline at end of file diff --git a/source/application/store/model/Goods.php b/source/application/store/model/Goods.php deleted file mode 100644 index 02056c7..0000000 --- a/source/application/store/model/Goods.php +++ /dev/null @@ -1,153 +0,0 @@ -error = '请上传商品图片'; - return false; - } - $data['content'] = isset($data['content']) ? $data['content'] : ''; - $data['wxapp_id'] = $data['sku']['wxapp_id'] = self::$wxapp_id; - - // 开启事务 - $this->startTrans(); - try { - // 添加商品 - $this->allowField(true)->save($data); - // 商品规格 - $this->addGoodsSpec($data); - // 商品图片 - $this->addGoodsImages($data['images']); - $this->commit(); - return true; - } catch (\Exception $e) { - $this->error = $e->getMessage(); - $this->rollback(); - return false; - } - } - - /** - * 添加商品图片 - * @param $images - * @return int - * @throws \think\Exception - * @throws \think\exception\PDOException - */ - private function addGoodsImages($images) - { - $this->image()->delete(); - $data = array_map(function ($image_id) { - return [ - 'image_id' => $image_id, - 'wxapp_id' => self::$wxapp_id - ]; - }, $images); - return $this->image()->saveAll($data); - } - - /** - * 编辑商品 - * @param $data - * @return bool - * @throws \think\exception\PDOException - */ - public function edit($data) - { - if (!isset($data['images']) || empty($data['images'])) { - $this->error = '请上传商品图片'; - return false; - } - $data['content'] = isset($data['content']) ? $data['content'] : ''; - $data['wxapp_id'] = $data['sku']['wxapp_id'] = self::$wxapp_id; - - // 开启事务 - $this->startTrans(); - try { - // 保存商品 - $this->allowField(true)->save($data); - // 商品规格 - $this->addGoodsSpec($data, true); - // 商品图片 - $this->addGoodsImages($data['images']); - $this->commit(); - return true; - } catch (\Exception $e) { - $this->rollback(); - $this->error = $e->getMessage(); - return false; - } - } - - /** - * 添加商品规格 - * @param $data - * @param $isUpdate - * @throws \Exception - */ - private function addGoodsSpec(&$data, $isUpdate = false) - { - // 更新模式: 先删除所有规格 - $model = new GoodsSku; - $isUpdate && $model->removeAll($this['goods_id']); - // 添加规格数据 - if ($data['spec_type'] == '10') { - // 单规格 - $this->sku()->save($data['sku']); - } else if ($data['spec_type'] == '20') { - // 添加商品与规格关系记录 - $model->addGoodsSpecRel($this['goods_id'], $data['spec_many']['spec_attr']); - // 添加商品sku - $model->addSkuList($this['goods_id'], $data['spec_many']['spec_list']); - } - } - - /** - * 修改商品状态 - * @param $state - * @return false|int - */ - public function setStatus($state) - { - return $this->save(['goods_status' => $state ? 10 : 20]) !== false; - } - - /** - * 软删除 - * @return false|int - */ - public function setDelete() - { - return $this->save(['is_delete' => 1]); - } - - /** - * 获取当前商品总数 - * @param array $where - * @return int|string - */ - public function getGoodsTotal($where = []) - { - $this->where('is_delete', '=', 0); - !empty($where) && $this->where($where); - return $this->count(); - } - -} diff --git a/source/application/store/model/GoodsImage.php b/source/application/store/model/GoodsImage.php deleted file mode 100644 index 01bb1bf..0000000 --- a/source/application/store/model/GoodsImage.php +++ /dev/null @@ -1,14 +0,0 @@ - $item['spec_sku_id'], - 'goods_id' => $goods_id, - 'wxapp_id' => self::$wxapp_id, - ]); - } - return $this->allowField(true)->saveAll($data); - } - - /** - * 添加商品规格关系记录 - * @param $goods_id - * @param $spec_attr - * @return array|false - * @throws \Exception - */ - public function addGoodsSpecRel($goods_id, $spec_attr) - { - $data = []; - array_map(function ($val) use (&$data, $goods_id) { - array_map(function ($item) use (&$val, &$data, $goods_id) { - $data[] = [ - 'goods_id' => $goods_id, - 'spec_id' => $val['group_id'], - 'spec_value_id' => $item['item_id'], - 'wxapp_id' => self::$wxapp_id, - ]; - }, $val['spec_items']); - }, $spec_attr); - $model = new GoodsSpecRel; - return $model->saveAll($data); - } - - /** - * 移除指定商品的所有sku - * @param $goods_id - * @return int - */ - public function removeAll($goods_id) - { - $model = new GoodsSpecRel; - $model->where('goods_id','=', $goods_id)->delete(); - return $this->where('goods_id','=', $goods_id)->delete(); - } - -} diff --git a/source/application/store/model/GoodsSpecRel.php b/source/application/store/model/GoodsSpecRel.php deleted file mode 100644 index c958492..0000000 --- a/source/application/store/model/GoodsSpecRel.php +++ /dev/null @@ -1,14 +0,0 @@ -setWhere($query); - // 获取数据列表 - return $this->with(['goods.image', 'address', 'user']) - ->alias('order') - ->field('order.*') - ->join('user', 'user.user_id = order.user_id') - ->where($this->transferDataType($dataType)) - ->where('order.is_delete', '=', 0) - ->order(['order.create_time' => 'desc']) - ->paginate(10, false, [ - 'query' => \request()->request() - ]); - } - - /** - * 订单列表(全部) - * @param $dataType - * @param array $query - * @return false|\PDOStatement|string|\think\Collection - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - */ - public function getListAll($dataType, $query = []) - { - // 检索查询条件 - !empty($query) && $this->setWhere($query); - // 获取数据列表 - return $this->with(['goods.image', 'address', 'user', 'extract', 'extract_shop']) - ->alias('order') - ->field('order.*') - ->join('user', 'user.user_id = order.user_id') - ->where($this->transferDataType($dataType)) - ->where('order.is_delete', '=', 0) - ->order(['order.create_time' => 'desc']) - ->select(); - } - - /** - * 订单导出 - * @param $dataType - * @param $query - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - */ - public function exportList($dataType, $query) - { - // 获取订单列表 - $list = $this->getListAll($dataType, $query); - // 导出csv文件 - return (new Exportservice)->orderList($list); - } - - /** - * 批量发货模板 - */ - public function deliveryTpl() - { - return (new Exportservice)->deliveryTpl(); - } - - /** - * 设置检索查询条件 - * @param $query - */ - private function setWhere($query) - { - if (isset($query['search']) && !empty($query['search'])) { - $this->where('order_no|user.nickName', 'like', '%' . trim($query['search']) . '%'); - } - if (isset($query['start_time']) && !empty($query['start_time'])) { - $this->where('order.create_time', '>=', strtotime($query['start_time'])); - } - if (isset($query['end_time']) && !empty($query['end_time'])) { - $this->where('order.create_time', '<', strtotime($query['end_time']) + 86400); - } - if (isset($query['delivery_type']) && !empty($query['delivery_type'])) { - $query['delivery_type'] > -1 && $this->where('delivery_type', '=', $query['delivery_type']); - } - if (isset($query['extract_shop_id']) && !empty($query['extract_shop_id'])) { - $query['extract_shop_id'] > -1 && $this->where('extract_shop_id', '=', $query['extract_shop_id']); - } - // 用户id - if (isset($query['user_id']) && $query['user_id'] > 0) { - $this->where('order.user_id', '=', (int)$query['user_id']); - } - } - - /** - * 转义数据类型条件 - * @param $dataType - * @return array - */ - private function transferDataType($dataType) - { - // 数据类型 - $filter = []; - switch ($dataType) { - case 'delivery': - $filter = [ - 'pay_status' => 20, - 'delivery_status' => 10, - 'order_status' => ['in', [10, 21]] - ]; - break; - case 'receipt': - $filter = [ - 'pay_status' => 20, - 'delivery_status' => 20, - 'receipt_status' => 10 - ]; - break; - case 'pay': - $filter = ['pay_status' => 10, 'order_status' => 10]; - break; - case 'complete': - $filter = ['order_status' => 30]; - break; - case 'cancel': - $filter = ['order_status' => 20]; - break; - case 'all': - $filter = []; - break; - } - return $filter; - } - - /** - * 确认发货(单独订单) - * @param $data - * @return array|bool|false - * @throws \app\common\exception\BaseException - * @throws \think\Exception - * @throws \think\exception\DbException - * @throws \Exception - */ - public function delivery($data) - { - // 转义为订单列表 - $orderList = [$this]; - // 验证订单是否满足发货条件 - if (!$this->verifyDelivery($orderList)) { - return false; - } - // 整理更新的数据 - $updateList = [[ - 'order_id' => $this['order_id'], - 'express_id' => $data['express_id'], - 'express_no' => $data['express_no'] - ]]; - // 更新订单发货状态 - if ($status = $this->updateToDelivery($updateList)) { - // 获取已发货的订单 - $completed = self::detail($this['order_id'], ['user', 'address', 'goods', 'express']); - // 发送消息通知 - $this->sendDeliveryMessage([$completed]); - // 同步好物圈订单 - (new WowService($this['wxapp_id']))->update([$completed]); - } - return $status; - } - - /** - * 批量发货 - * @param $data - * @return bool - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - * @throws \Exception - */ - public function batchDelivery($data) - { - // 获取csv文件中的数据 - if (!$csvData = $this->getCsvData()) { - return false; - } - // 整理订单id集 - $orderNos = helper::getArrayColumn($csvData, 0); - // 获取订单列表数据 - $orderList = helper::arrayColumn2Key($this->getListByOrderNos($orderNos), 'order_no'); - // 验证订单是否存在 - $tempArr = array_values(array_diff($orderNos, array_keys($orderList))); - if (!empty($tempArr)) { - $this->error = "订单号[{$tempArr[0]}] 不存在!"; - return false; - } - // 整理物流单号 - $updateList = []; - foreach ($csvData as $item) { - $updateList[] = [ - 'order_id' => $orderList[$item[0]]['order_id'], - 'express_id' => $data['express_id'], - 'express_no' => $item[1], - ]; - } - // 验证订单是否满足发货条件 - if (!$this->verifyDelivery($orderList)) { - return false; - } - // 更新订单发货状态(批量) - if ($status = $this->updateToDelivery($updateList)) { - // 获取已发货的订单 - $completed = $this->getListByOrderNos($orderNos, ['user', 'address', 'goods', 'express']); - // 发送消息通知 - $this->sendDeliveryMessage($completed); - // 同步好物圈订单 - (new WowService(self::$wxapp_id))->update($completed); - } - return $status; - } - - /** - * 确认发货后发送消息通知 - * @param $orderList - * @return bool - */ - private function sendDeliveryMessage($orderList) - { - // 发送消息通知 - foreach ($orderList as $item) { - MessageService::send('order.delivery', [ - 'order' => $item, - 'order_type' => OrderTypeEnum::MASTER, - ]); - } - return true; - } - - /** - * 更新订单发货状态(批量) - * @param $orderList - * @return array|false - * @throws \Exception - */ - private function updateToDelivery($orderList) - { - $data = []; - foreach ($orderList as $item) { - $data[] = [ - 'order_id' => $item['order_id'], - 'express_no' => $item['express_no'], - 'express_id' => $item['express_id'], - 'delivery_status' => 20, - 'delivery_time' => time(), - ]; - } - return $this->isUpdate()->saveAll($data); - } - - /** - * 验证订单是否满足发货条件 - * @param $orderList - * @return bool - */ - private function verifyDelivery($orderList) - { - foreach ($orderList as $order) { - if ( - $order['pay_status']['value'] != 20 - || $order['delivery_type']['value'] != DeliveryTypeEnum::EXPRESS - || $order['delivery_status']['value'] != 10 - ) { - $this->error = "订单号[{$order['order_no']}] 不满足发货条件!"; - return false; - } - } - return true; - } - - /** - * 获取csv文件中的数据 - * @return array|bool - */ - private function getCsvData() - { - // 获取表单上传文件 例如上传了001.jpg - $file = \request()->file('iFile'); - if (empty($file)) { - $this->error = '请上传发货模板'; - return false; - } - // 设置区域信息 - setlocale(LC_ALL, 'zh_CN'); - // 打开上传的文件 - $csvFile = fopen($file->getInfo()['tmp_name'], 'r'); - // 忽略第一行(csv标题) - fgetcsv($csvFile); - // 遍历并记录订单信息 - $orderList = []; - while ($item = fgetcsv($csvFile)) { - if (!isset($item[0]) || empty($item[0]) || !isset($item[1]) || empty($item[1])) { - $this->error = '模板文件数据不合法'; - return false; - } - $orderList[] = $item; - } - if (empty($orderList)) { - $this->error = '模板文件中没有订单数据'; - return false; - } - return $orderList; - } - - /** - * 修改订单价格 - * @param $data - * @return bool - */ - public function updatePrice($data) - { - if ($this['pay_status']['value'] != 10) { - $this->error = '该订单不合法'; - return false; - } - // 实际付款金额 - $payPrice = bcadd($data['update_price'], $data['update_express_price'], 2); - if ($payPrice <= 0) { - $this->error = '订单实付款价格不能为0.00元'; - return false; - } - return $this->save([ - 'order_no' => $this->orderNo(), // 修改订单号, 否则微信支付提示重复 - 'order_price' => $data['update_price'], - 'pay_price' => $payPrice, - 'update_price' => helper::bcsub($data['update_price'], helper::bcsub($this['total_price'], $this['coupon_money'])), - 'express_price' => $data['update_express_price'] - ]) !== false; - } - - /** - * 审核:用户取消订单 - * @param $data - * @return bool|mixed - * @throws \app\common\exception\BaseException - * @throws \think\exception\DbException - */ - public function confirmCancel($data) - { - // 判断订单是否有效 - if ($this['pay_status']['value'] != 20) { - $this->error = '该订单不合法'; - return false; - } - // 订单取消事件 - $status = $this->transaction(function () use ($data) { - if ($data['is_cancel'] == true) { - // 执行退款操作 - (new RefundService)->execute($this); - // 回退商品库存 - FactoryStock::getFactory($this['order_source'])->backGoodsStock($this['goods'], true); - // 回退用户优惠券 - $this['coupon_id'] > 0 && UserCouponModel::setIsUse($this['coupon_id'], false); - // 回退用户积分 - $User = UserModel::detail($this['user_id']); - $describe = "订单取消:{$this['order_no']}"; - $this['points_num'] > 0 && $User->setIncPoints($this['points_num'], $describe); - } - // 更新订单状态 - return $this->save(['order_status' => $data['is_cancel'] ? 20 : 10]); - }); - if ($status == true) { - // 同步好物圈订单 - (new WowService(self::$wxapp_id))->update([$this]); - } - return $status; - } - - /** - * 获取已付款订单总数 (可指定某天) - * @param null $startDate - * @param null $endDate - * @return int|string - * @throws \think\Exception - */ - public function getPayOrderTotal($startDate = null, $endDate = null) - { - $filter = [ - 'pay_status' => PayStatusEnum::SUCCESS, - 'order_status' => ['<>', OrderStatusEnum::CANCELLED], - ]; - if (!is_null($startDate) && !is_null($endDate)) { - $filter['pay_time'] = [ - ['>=', strtotime($startDate)], - ['<', strtotime($endDate) + 86400], - ]; - } - return $this->getOrderTotal($filter); - } - - /** - * 获取订单总数量 - * @param array $filter - * @return int|string - * @throws \think\Exception - */ - private function getOrderTotal($filter = []) - { - return $this->where($filter) - ->where('is_delete', '=', 0) - ->count(); - } - - /** - * 获取某天的总销售额 - * @param null $startDate - * @param null $endDate - * @return float|int - */ - public function getOrderTotalPrice($startDate = null, $endDate = null) - { - if (!is_null($startDate) && !is_null($endDate)) { - $this->where('pay_time', '>=', strtotime($startDate)) - ->where('pay_time', '<', strtotime($endDate) + 86400); - } - return $this->where('pay_status', '=', 20) - ->where('order_status', '<>', 20) - ->where('is_delete', '=', 0) - ->sum('pay_price'); - } - - /** - * 获取某天的下单用户数 - * @param $day - * @return float|int - */ - public function getPayOrderUserTotal($day) - { - $startTime = strtotime($day); - $userIds = $this->distinct(true) - ->where('pay_time', '>=', $startTime) - ->where('pay_time', '<', $startTime + 86400) - ->where('pay_status', '=', 20) - ->where('is_delete', '=', 0) - ->column('user_id'); - return count($userIds); - } - -} diff --git a/source/application/store/model/OrderAddress.php b/source/application/store/model/OrderAddress.php deleted file mode 100644 index a6393d3..0000000 --- a/source/application/store/model/OrderAddress.php +++ /dev/null @@ -1,15 +0,0 @@ -where('order.order_no', 'like', "%{$query['order_no']}%"); - } - // 查询条件:起始日期 - if (isset($query['start_time']) && !empty($query['start_time'])) { - $this->where('m.create_time', '>=', strtotime($query['start_time'])); - } - // 查询条件:截止日期 - if (isset($query['end_time']) && !empty($query['end_time'])) { - $this->where('m.create_time', '<', strtotime($query['end_time']) + 86400); - } - // 售后类型 - if (isset($query['type']) && $query['type'] > 0) { - $this->where('m.type', '=', $query['type']); - } - // 处理状态 - if (isset($query['state']) && is_numeric($query['state'])) { - $this->where('m.status', '=', $query['state']); - } - // 获取列表数据 - return $this->alias('m') - ->field('m.*, order.order_no') - ->with(['order_goods.image', 'orderMaster', 'user']) - ->join('order', 'order.order_id = m.order_id') - ->order(['m.create_time' => 'desc']) - ->paginate(10, false, [ - 'query' => \request()->request() - ]); - } - - /** - * 商家审核 - * @param $data - * @return bool - */ - public function audit($data) - { - if ($data['is_agree'] == 20 && empty($data['refuse_desc'])) { - $this->error = '请输入拒绝原因'; - return false; - } - if ($data['is_agree'] == 10 && empty($data['address_id'])) { - $this->error = '请选择退货地址'; - return false; - } - $this->transaction(function () use ($data) { - // 拒绝申请, 标记售后单状态为已拒绝 - $data['is_agree'] == 20 && $data['status'] = 10; - // 同意换货申请, 标记售后单状态为已完成 - $data['is_agree'] == 10 && $this['type']['value'] == 20 && $data['status'] = 20; - // 更新退款单状态 - $this->allowField(true)->save($data); - // 同意售后申请, 记录退货地址 - if ($data['is_agree'] == 10) { - (new OrderRefundAddress)->add($this['order_refund_id'], $data['address_id']); - } - // 订单详情 - $order = Order::detail($this['order_id']); - // 发送消息通知 - MessageService::send('order.refund', [ - 'refund' => $this, // 退款单信息 - 'order_no' => $order['order_no'], // 订单信息 - 'order_type' => OrderTypeEnum::MASTER, // 订单类型 - ]); - }); - return true; - } - - /** - * 确认收货并退款 - * @param $data - * @return bool - * @throws \think\exception\DbException - */ - public function receipt($data) - { - // 订单详情 - $order = Order::detail($this['order_id']); - if ($data['refund_money'] > min($order['pay_price'], $this['order_goods']['total_pay_price'])) { - $this->error = '退款金额不能大于商品实付款金额'; - return false; - } - $this->transaction(function () use ($order, $data) { - // 更新售后单状态 - $this->allowField(true)->save([ - 'refund_money' => $data['refund_money'], - 'is_receipt' => 1, - 'status' => 20 - ]); - // 消减用户的实际消费金额 - // 条件:判断订单是否已结算 - if ($order['is_settled'] == true) { - (new UserModel)->setDecUserExpend($order['user_id'], $data['refund_money']); - } - // 执行原路退款 - (new RefundService)->execute($order, $data['refund_money']); - // 发送消息通知 - MessageService::send('order.refund', [ - 'refund' => $this, // 退款单信息 - 'order_no' => $order['order_no'], // 订单信息 - 'order_type' => OrderTypeEnum::MASTER, // 订单类型 - ]); - }); - return true; - } - -} \ No newline at end of file diff --git a/source/application/store/model/OrderRefundAddress.php b/source/application/store/model/OrderRefundAddress.php deleted file mode 100644 index 7b1fa74..0000000 --- a/source/application/store/model/OrderRefundAddress.php +++ /dev/null @@ -1,33 +0,0 @@ -save([ - 'order_refund_id' => $order_refund_id, - 'name' => $detail['name'], - 'phone' => $detail['phone'], - 'detail' => $detail['detail'], - 'wxapp_id' => self::$wxapp_id - ]); - } - -} \ No newline at end of file diff --git a/source/application/store/model/OrderRefundImage.php b/source/application/store/model/OrderRefundImage.php deleted file mode 100644 index 635d155..0000000 --- a/source/application/store/model/OrderRefundImage.php +++ /dev/null @@ -1,10 +0,0 @@ -allowField(true)->save($data); - } - - /** - * 编辑记录 - * @param $data - * @return bool|int - */ - public function edit($data) - { - $data['printer_config'] = $data[$data['printer_type']]; - return $this->allowField(true)->save($data); - } - - /** - * 删除记录 - * @return bool|int - */ - public function setDelete() - { - return $this->save(['is_delete' => 1]); - } - -} \ No newline at end of file diff --git a/source/application/store/model/Region.php b/source/application/store/model/Region.php deleted file mode 100644 index dca2c32..0000000 --- a/source/application/store/model/Region.php +++ /dev/null @@ -1,15 +0,0 @@ -order(['sort' => 'asc', $this->getPk() => 'desc']) - ->where('is_delete', '=', 0) - ->paginate(15, false, [ - 'query' => \request()->request() - ]); - } - - /** - * 获取全部收货地址 - * @return false|\PDOStatement|string|\think\Collection - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - */ - public function getAll() - { - return $this->order(['sort' => 'asc', $this->getPk() => 'desc']) - ->where('is_delete', '=', 0) - ->select(); - } - - /** - * 添加新记录 - * @param $data - * @return false|int - */ - public function add($data) - { - $data['wxapp_id'] = self::$wxapp_id; - return $this->allowField(true)->save($data); - } - - /** - * 编辑记录 - * @param $data - * @return bool|int - */ - public function edit($data) - { - return $this->allowField(true)->save($data); - } - - /** - * 删除记录 - * @return bool|int - */ - public function remove() - { - return $this->save(['is_delete' => 1]); - } - -} \ No newline at end of file diff --git a/source/application/store/model/Setting.php b/source/application/store/model/Setting.php deleted file mode 100644 index 960ab1e..0000000 --- a/source/application/store/model/Setting.php +++ /dev/null @@ -1,76 +0,0 @@ -validValues($key, $values)) { - return false; - } - // 删除系统设置缓存 - Cache::rm('setting_' . self::$wxapp_id); - return $model->save([ - 'key' => $key, - 'describe' => SettingEnum::data()[$key]['describe'], - 'values' => $values, - 'wxapp_id' => self::$wxapp_id, - ]) !== false; - } - - /** - * 数据验证 - * @param $key - * @param $values - * @return bool - */ - private function validValues($key, $values) - { - // 验证小票打印机设置 - if ($key === 'printer') { - return $this->validPrinter($values); - } - return true; - } - - /** - * 验证小票打印机设置 - * @param $values - * @return bool - */ - private function validPrinter($values) - { - if ($values['is_open'] == false) { - return true; - } - if (!$values['printer_id']) { - $this->error = '请选择订单打印机'; - return false; - } - if (empty($values['order_status'])) { - $this->error = '请选择订单打印方式'; - return false; - } - return true; - } - -} diff --git a/source/application/store/model/Spec.php b/source/application/store/model/Spec.php deleted file mode 100644 index 25a52e5..0000000 --- a/source/application/store/model/Spec.php +++ /dev/null @@ -1,35 +0,0 @@ -value('spec_id'); - } - - /** - * 新增规格组 - * @param $spec_name - * @return false|int - */ - public function add($spec_name) - { - $wxapp_id = self::$wxapp_id; - return $this->save(compact('spec_name', 'wxapp_id')); - } - -} diff --git a/source/application/store/model/SpecValue.php b/source/application/store/model/SpecValue.php deleted file mode 100644 index 093383a..0000000 --- a/source/application/store/model/SpecValue.php +++ /dev/null @@ -1,38 +0,0 @@ -value('spec_value_id'); - } - - /** - * 新增规格值 - * @param $spec_id - * @param $spec_value - * @return false|int - */ - public function add($spec_id, $spec_value) - { - $wxapp_id = self::$wxapp_id; - return $this->save(compact('spec_value', 'spec_id', 'wxapp_id')); - } - -} diff --git a/source/application/store/model/Store.php b/source/application/store/model/Store.php deleted file mode 100644 index fe4606f..0000000 --- a/source/application/store/model/Store.php +++ /dev/null @@ -1,191 +0,0 @@ -GoodsModel = new Goods; - $this->OrderModel = new Order; - $this->UserModel = new User; - } - - /** - * 后台首页数据 - * @return array - * @throws \think\Exception - */ - public function getHomeData() - { - $today = date('Y-m-d'); - $yesterday = date('Y-m-d', strtotime('-1 day')); - // 最近七天日期 - $lately7days = $this->getLately7days(); - $data = [ - 'widget-card' => [ - // 商品总量 - 'goods_total' => $this->getGoodsTotal(), - // 用户总量 - 'user_total' => $this->getUserTotal(), - // 订单总量 - 'order_total' => $this->getOrderTotal(), - // 评价总量 - 'comment_total' => $this->getCommentTotal() - ], - 'widget-outline' => [ - // 销售额(元) - 'order_total_price' => [ - 'tday' => $this->getOrderTotalPrice($today), - 'ytd' => $this->getOrderTotalPrice($yesterday) - ], - // 支付订单数 - 'order_total' => [ - 'tday' => $this->getOrderTotal($today), - 'ytd' => $this->getOrderTotal($yesterday) - ], - // 新增用户数 - 'new_user_total' => [ - 'tday' => $this->getUserTotal($today), - 'ytd' => $this->getUserTotal($yesterday) - ], - // 下单用户数 - 'order_user_total' => [ - 'tday' => $this->getPayOrderUserTotal($today), - 'ytd' => $this->getPayOrderUserTotal($yesterday) - ] - ], - 'widget-echarts' => [ - // 最近七天日期 - 'date' => json_encode($lately7days), - 'order_total' => json_encode($this->getOrderTotalByDate($lately7days)), - 'order_total_price' => json_encode($this->getOrderTotalPriceByDate($lately7days)) - ] - ]; - return $data; - } - - /** - * 最近七天日期 - */ - private function getLately7days() - { - // 获取当前周几 - $date = []; - for ($i = 0; $i < 7; $i++) { - $date[] = date('Y-m-d', strtotime('-' . $i . ' days')); - } - return array_reverse($date); - } - - /** - * 获取商品总量 - * @return string - */ - private function getGoodsTotal() - { - return number_format($this->GoodsModel->getGoodsTotal()); - } - - /** - * 获取用户总量 - * @param null $day - * @return string - */ - private function getUserTotal($day = null) - { - return number_format($this->UserModel->getUserTotal($day)); - } - - /** - * 获取订单总量 - * @param null $day - * @return string - * @throws \think\Exception - */ - private function getOrderTotal($day = null) - { - return number_format($this->OrderModel->getPayOrderTotal($day)); - } - - /** - * 获取订单总量 (指定日期) - * @param $days - * @return array - * @throws \think\Exception - */ - private function getOrderTotalByDate($days) - { - $data = []; - foreach ($days as $day) { - $data[] = $this->getOrderTotal($day); - } - return $data; - } - - /** - * 获取评价总量 - * @return string - */ - private function getCommentTotal() - { - $model = new Comment; - return number_format($model->getCommentTotal()); - } - - /** - * 获取某天的总销售额 - * @param $day - * @return float|int - */ - private function getOrderTotalPrice($day) - { - return sprintf('%.2f', $this->OrderModel->getOrderTotalPrice($day)); - } - - /** - * 获取订单总量 (指定日期) - * @param $days - * @return array - */ - private function getOrderTotalPriceByDate($days) - { - $data = []; - foreach ($days as $day) { - $data[] = $this->getOrderTotalPrice($day); - } - return $data; - } - - /** - * 获取某天的下单用户数 - * @param $day - * @return float|int - */ - private function getPayOrderUserTotal($day) - { - return number_format($this->OrderModel->getPayOrderUserTotal($day)); - } - -} \ No newline at end of file diff --git a/source/application/store/model/StoreUser.php b/source/application/store/model/StoreUser.php deleted file mode 100644 index 34e9c69..0000000 --- a/source/application/store/model/StoreUser.php +++ /dev/null @@ -1,86 +0,0 @@ -with(['wxapp'])->where([ - 'user_name' => $data['user_name'], - 'password' => yoshop_hash($data['password']) - ])->find()) { - $this->error = '登录失败, 用户名或密码错误'; - return false; - } - if (empty($user['wxapp'])) { - $this->error = '登录失败, 未找到小程序信息'; - return false; - } - // 保存登录状态 - Session::set('yoshop_store', [ - 'user' => [ - 'store_user_id' => $user['store_user_id'], - 'user_name' => $user['user_name'], - ], - 'wxapp' => $user['wxapp']->toArray(), - 'is_login' => true, - ]); - return true; - } - - /** - * 商户信息 - * @param $store_user_id - * @return null|static - * @throws \think\exception\DbException - */ - public static function detail($store_user_id) - { - return self::get($store_user_id); - } - - /** - * 更新当前管理员信息 - * @param $data - * @return bool - */ - public function renew($data) - { - if ($data['password'] !== $data['password_confirm']) { - $this->error = '确认密码不正确'; - return false; - } - // 更新管理员信息 - if ($this->save([ - 'user_name' => $data['user_name'], - 'password' => yoshop_hash($data['password']), - ]) === false) { - return false; - } - // 更新session - Session::set('yoshop_store.user', [ - 'store_user_id' => $this['store_user_id'], - 'user_name' => $data['user_name'], - ]); - return true; - } - -} diff --git a/source/application/store/model/UploadFile.php b/source/application/store/model/UploadFile.php deleted file mode 100644 index 0e26ddd..0000000 --- a/source/application/store/model/UploadFile.php +++ /dev/null @@ -1,91 +0,0 @@ -where('group_id', '=', (int)$groupId); - // 文件类型 - !empty($fileType) && $this->where('file_type', '=', trim($fileType)); - // 是否在回收站 - $isRecycle > -1 && $this->where('is_recycle', '=', (int)$isRecycle); - // 查询列表数据 - return $this->where(['is_user' => 0, 'is_delete' => 0]) - ->order(['file_id' => 'desc']) - ->paginate(32, false, [ - 'query' => Request::instance()->request() - ]); - } - - /** - * 移入|移出回收站 - * @param bool $isRecycle - * @return false|int - */ - public function setRecycle($isRecycle = true) - { - return $this->save(['is_recycle' => (int)$isRecycle]); - } - - /** - * 删除文件 - * @return false|int - * @throws \think\Exception - */ - public function setDelete() - { - // 存储配置信息 - $config = SettingModel::getItem('storage'); - // 实例化存储驱动 - $StorageDriver = new StorageDriver($config, $this['storage']); - // 删除文件 - if (!$StorageDriver->delete($this['file_name'])) { - $this->error = '文件删除失败:' . $StorageDriver->getError(); - return false; - } - return $this->save(['is_delete' => 1]); - } - - /** - * 批量软删除 - * @param $fileIds - * @return $this - */ - public function softDelete($fileIds) - { - return $this->where('file_id', 'in', $fileIds)->update(['is_delete' => 1]); - } - - /** - * 批量移动文件分组 - * @param $group_id - * @param $fileIds - * @return $this - */ - public function moveGroup($group_id, $fileIds) - { - return $this->where('file_id', 'in', $fileIds)->update(compact('group_id')); - } - -} diff --git a/source/application/store/model/UploadFileUsed.php b/source/application/store/model/UploadFileUsed.php deleted file mode 100644 index e6018d9..0000000 --- a/source/application/store/model/UploadFileUsed.php +++ /dev/null @@ -1,38 +0,0 @@ -save($data); - } - - /** - * 移除记录 - * @param $from_type - * @param $file_id - * @param null $from_id - * @return int - */ - public function remove($from_type, $file_id, $from_id = null) - { - $where = compact('from_type', 'file_id'); - !is_null($from_id) && $where['from_id'] = $from_id; - return $this->where($where)->delete(); - } -} diff --git a/source/application/store/model/UploadGroup.php b/source/application/store/model/UploadGroup.php deleted file mode 100644 index a6e57b2..0000000 --- a/source/application/store/model/UploadGroup.php +++ /dev/null @@ -1,66 +0,0 @@ -where('group_type', '=', trim($groupType)); - return $this->where('is_delete', '=', 0) - ->order(['sort' => 'asc', 'create_time' => 'desc']) - ->select(); - } - - /** - * 添加新记录 - * @param $data - * @return false|int - */ - public function add($data) - { - return $this->save(array_merge([ - 'wxapp_id' => self::$wxapp_id, - 'sort' => 100 - ], $data)); - } - - /** - * 更新记录 - * @param $data - * @return bool|int - */ - public function edit($data) - { - return $this->allowField(true)->save($data) !== false; - } - - /** - * 删除记录 - * @return int - */ - public function remove() - { - // 更新该分组下的所有文件 - (new UploadFile)->where('group_id', '=', $this['group_id']) - ->update(['group_id' => 0]); - // 删除分组 - return $this->save(['is_delete' => 1]); - } - -} diff --git a/source/application/store/model/User.php b/source/application/store/model/User.php deleted file mode 100644 index 06d6e70..0000000 --- a/source/application/store/model/User.php +++ /dev/null @@ -1,97 +0,0 @@ -where('create_time', '>=', $startTime) - ->where('create_time', '<', $startTime + 86400); - } - return $this->where('is_delete', '=', '0')->count(); - } - - /** - * 获取用户列表 - * @param string $nickName - * @param int $gender - * @return \think\Paginator - * @throws \think\exception\DbException - */ - public function getList($nickName = '', $gender = -1) - { - // 检索条件:微信昵称 - !empty($nickName) && $this->where('nickName', 'like', "%$nickName%"); - // 检索条件:性别 - if ($gender !== '' && $gender > -1) { - $this->where('gender', '=', (int)$gender); - } - return $this->where('is_delete', '=', '0') - ->order(['create_time' => 'desc']) - ->paginate(15, false, [ - 'query' => \request()->request() - ]); - } - - /** - * 软删除 - * @return false|int - */ - public function setDelete() - { - return $this->save(['is_delete' => 1]); - } - - /** - * 用户充值 - * @param string $storeUserName 当前操作人用户名 - * @param $data - * @return bool - */ - public function recharge($storeUserName, $data) - { - if (!isset($data['money']) || $data['money'] === '' || $data['money'] < 0) { - $this->error = '请输入正确的金额'; - return false; - } - // 判断充值方式,计算最终金额 - if ($data['mode'] === 'inc') { - $diffMoney = $data['money']; - } elseif ($data['mode'] === 'dec') { - $diffMoney = -$data['money']; - } else { - $diffMoney = $data['money'] - $this['balance']; - } - // 更新记录 - $this->transaction(function () use ($storeUserName, $data, $diffMoney) { - // 更新账户余额 - $this->setInc('balance', $diffMoney); - // 新增余额变动记录 - BalanceLogModel::add(SceneEnum::ADMIN, [ - 'user_id' => $this['user_id'], - 'money' => $diffMoney, - 'remark' => $data['remark'], - ], [$storeUserName]); - }); - return true; - } - -} diff --git a/source/application/store/model/UserAddress.php b/source/application/store/model/UserAddress.php deleted file mode 100644 index 7db84c0..0000000 --- a/source/application/store/model/UserAddress.php +++ /dev/null @@ -1,15 +0,0 @@ -with(['user']) - ->order(['create_time' => 'desc']) - ->paginate(15, false, [ - 'query' => request()->request() - ]); - } - -} \ No newline at end of file diff --git a/source/application/store/model/Wxapp.php b/source/application/store/model/Wxapp.php deleted file mode 100644 index e52212c..0000000 --- a/source/application/store/model/Wxapp.php +++ /dev/null @@ -1,77 +0,0 @@ -startTrans(); - try { - // 删除wxapp缓存 - self::deleteCache(); - // 写入微信支付证书文件 - $this->writeCertPemFiles($data['cert_pem'], $data['key_pem']); - // 更新小程序设置 - $this->allowField(true)->save($data); - $this->commit(); - return true; - } catch (\Exception $e) { - $this->error = $e->getMessage(); - $this->rollback(); - return false; - } - } - - /** - * 写入cert证书文件 - * @param string $cert_pem - * @param string $key_pem - * @return bool - */ - private function writeCertPemFiles($cert_pem = '', $key_pem = '') - { - if (empty($cert_pem) || empty($key_pem)) { - return false; - } - // 证书目录 - $filePath = APP_PATH . 'common/library/wechat/cert/' . self::$wxapp_id . '/'; - // 目录不存在则自动创建 - if (!is_dir($filePath)) { - mkdir($filePath, 0755, true); - } - // 写入cert.pem文件 - if (!empty($cert_pem)) { - file_put_contents($filePath . 'cert.pem', $cert_pem); - } - // 写入key.pem文件 - if (!empty($key_pem)) { - file_put_contents($filePath . 'key.pem', $key_pem); - } - return true; - } - - /** - * 删除wxapp缓存 - * @return bool - */ - public static function deleteCache() - { - return Cache::rm('wxapp_' . self::$wxapp_id); - } - -} diff --git a/source/application/store/model/WxappCategory.php b/source/application/store/model/WxappCategory.php deleted file mode 100644 index 29984c6..0000000 --- a/source/application/store/model/WxappCategory.php +++ /dev/null @@ -1,24 +0,0 @@ -allowField(true)->save($data) !== false; - } - -} \ No newline at end of file diff --git a/source/application/store/model/WxappHelp.php b/source/application/store/model/WxappHelp.php deleted file mode 100644 index 7ee0b5b..0000000 --- a/source/application/store/model/WxappHelp.php +++ /dev/null @@ -1,43 +0,0 @@ -allowField(true)->save($data); - } - - /** - * 更新记录 - * @param $data - * @return bool|int - */ - public function edit($data) - { - return $this->allowField(true)->save($data) !== false; - } - - /** - * 删除记录 - * @return int - */ - public function remove() { - return $this->delete(); - } - -} diff --git a/source/application/store/model/WxappNavbar.php b/source/application/store/model/WxappNavbar.php deleted file mode 100644 index 347db7f..0000000 --- a/source/application/store/model/WxappNavbar.php +++ /dev/null @@ -1,26 +0,0 @@ -save($data) !== false; - } - -} diff --git a/source/application/store/model/WxappPage.php b/source/application/store/model/WxappPage.php deleted file mode 100644 index 0369561..0000000 --- a/source/application/store/model/WxappPage.php +++ /dev/null @@ -1,87 +0,0 @@ -where(['is_delete' => 0])->order(['create_time' => 'desc'])->select(); - } - - /** - * 新增页面 - * @param $data - * @return bool - */ - public function add($data) - { - // 删除wxapp缓存 - Wxapp::deleteCache(); - return $this->save([ - 'page_type' => 20, - 'page_name' => $data['page']['params']['name'], - 'page_data' => $data, - 'wxapp_id' => self::$wxapp_id - ]); - } - - /** - * 更新页面 - * @param $data - * @return bool - */ - public function edit($data) - { - // 删除wxapp缓存 - Wxapp::deleteCache(); - // 保存数据 - return $this->save([ - 'page_name' => $data['page']['params']['name'], - 'page_data' => $data - ]) !== false; - } - - /** - * 删除记录 - * @return int - */ - public function setDelete() - { - if ($this['page_type'] == 10) { - $this->error = '默认首页不可以删除'; - return false; - } - // 删除wxapp缓存 - Wxapp::deleteCache(); - return $this->save(['is_delete' => 1]); - } - - /** - * 设为默认首页 - * @return int - */ - public function setHome() - { - // 取消原默认首页 - $this->where(['page_type' => 10])->update(['page_type' => 20]); - // 删除wxapp缓存 - Wxapp::deleteCache(); - return $this->save(['page_type' => 10]); - } - -} diff --git a/source/application/store/model/article/Category.php b/source/application/store/model/article/Category.php deleted file mode 100644 index e96970f..0000000 --- a/source/application/store/model/article/Category.php +++ /dev/null @@ -1,76 +0,0 @@ -deleteCache(); - return $this->allowField(true)->save($data); - } - - /** - * 编辑记录 - * @param $data - * @return bool|int - */ - public function edit($data) - { - $this->deleteCache(); - return $this->allowField(true)->save($data); - } - - /** - * 删除商品分类 - * @param $category_id - * @return bool|int - */ - public function remove($category_id) - { - // 判断是否存在文章 - $articleCount = ArticleModel::getArticleTotal(['category_id' => $category_id]); - if ($articleCount > 0) { - $this->error = '该分类下存在' . $articleCount . '个文章,不允许删除'; - return false; - } - $this->deleteCache(); - return $this->delete(); - } - - /** - * 删除缓存 - * @return bool - */ - private function deleteCache() - { - return Cache::rm('article_category_' . self::$wxapp_id); - } - -} diff --git a/source/application/store/model/dealer/Apply.php b/source/application/store/model/dealer/Apply.php deleted file mode 100644 index 67160c9..0000000 --- a/source/application/store/model/dealer/Apply.php +++ /dev/null @@ -1,70 +0,0 @@ -alias('apply') - ->field('apply.*, user.nickName, user.avatarUrl') - ->with(['referee']) - ->join('user', 'user.user_id = apply.user_id') - ->order(['apply.create_time' => 'desc']); - // 查询条件 - !empty($search) && $this->where('user.nickName|apply.real_name|apply.mobile', 'like', "%$search%"); - // 获取列表数据 - return $this->paginate(15, false, [ - 'query' => \request()->request() - ]); - } - - /** - * 分销商入驻审核 - * @param $data - * @return bool - */ - public function submit($data) - { - if ($data['apply_status'] == ApplyStatusEnum::AUDIT_REJECT && empty($data['reject_reason'])) { - $this->error = '请填写驳回原因'; - return false; - } - $this->transaction(function () use ($data) { - if ($data['apply_status'] == ApplyStatusEnum::AUDIT_PASS) { - // 新增分销商用户 - User::add($this['user_id'], [ - 'real_name' => $this['real_name'], - 'mobile' => $this['mobile'], - 'referee_id' => $this['referee_id'], - ]); - } - // 更新申请记录 - $data['audit_time'] = time(); - $this->allowField(true)->save($data); - // 发送订阅消息 - MessageService::send('dealer.apply', [ - 'apply' => $this, // 申请记录 - 'user' => $this['user'], // 用户信息 - ]); - }); - return true; - } - -} \ No newline at end of file diff --git a/source/application/store/model/dealer/Capital.php b/source/application/store/model/dealer/Capital.php deleted file mode 100644 index 7822c5a..0000000 --- a/source/application/store/model/dealer/Capital.php +++ /dev/null @@ -1,15 +0,0 @@ - 1 && $this->where('first_user_id|second_user_id|third_user_id', '=', $user_id); - $is_settled > -1 && $this->where('is_settled', '=', !!$is_settled); - $data = $this->with([ - 'dealer_first.user', - 'dealer_second.user', - 'dealer_third.user' - ])->order(['create_time' => 'desc']) - ->paginate(10, false, [ - 'query' => \request()->request() - ]); - if ($data->isEmpty()) { - return $data; - } - // 整理订单信息 - $with = ['goods' => ['image', 'refund'], 'address', 'user']; - return OrderService::getOrderList($data, 'order_master', $with); - } - -} \ No newline at end of file diff --git a/source/application/store/model/dealer/Referee.php b/source/application/store/model/dealer/Referee.php deleted file mode 100644 index 1764bd2..0000000 --- a/source/application/store/model/dealer/Referee.php +++ /dev/null @@ -1,15 +0,0 @@ - '基础设置', - 'condition' => '分销商条件', - 'commission' => '佣金设置', - 'settlement' => '结算', - 'words' => '自定义文字', - 'license' => '申请协议', - 'background' => '页面背景图', - 'qrcode' => '分销海报', - ]; - - /** - * 更新系统设置 - * @param $data - * @return bool - * @throws \think\exception\PDOException - */ - public function edit($data) - { - $this->startTrans(); - try { - foreach ($data as $key => $values) - $this->saveValues($key, $values); - $this->commit(); - // 删除系统设置缓存 - Cache::rm('dealer_setting_' . self::$wxapp_id); - return true; - } catch (\Exception $e) { - $this->error = $e->getMessage(); - $this->rollback(); - return false; - } - } - - /** - * 保存设置项 - * @param $key - * @param $values - * @return false|int - * @throws BaseException - * @throws \think\exception\DbException - */ - private function saveValues($key, $values) - { - $model = self::detail($key) ?: new self; - // 数据验证 - if (!$this->validValues($key, $values)) { - throw new BaseException(['msg' => $this->error]); - } - return $model->save([ - 'key' => $key, - 'describe' => $this->describe[$key], - 'values' => $values, - 'wxapp_id' => self::$wxapp_id, - ]); - } - - /** - * 数据验证 - * @param $key - * @param $values - * @return bool - */ - private function validValues($key, $values) - { - if ($key === 'settlement') { - // 验证结算方式 - return $this->validSettlement($values); - } -// if ($key === 'condition') { -// // 验证分销商条件 -// return $this->validCondition($values); -// } - return true; - } - - /** - * 验证结算方式 - * @param $values - * @return bool - */ - private function validSettlement($values) - { - if (!isset($values['pay_type']) || empty($values['pay_type'])) { - $this->error = '请设置 结算-提现方式'; - return false; - } - return true; - } - -} \ No newline at end of file diff --git a/source/application/store/model/dealer/User.php b/source/application/store/model/dealer/User.php deleted file mode 100644 index ead8606..0000000 --- a/source/application/store/model/dealer/User.php +++ /dev/null @@ -1,79 +0,0 @@ -alias('dealer') - ->field('dealer.*, user.nickName, user.avatarUrl') - ->with(['referee']) - ->join('user', 'user.user_id = dealer.user_id') - ->where('dealer.is_delete', '=', 0) - ->order(['dealer.create_time' => 'desc']); - // 查询条件 - !empty($search) && $this->where('user.nickName|dealer.real_name|dealer.mobile', 'like', "%$search%"); - // 获取列表数据 - return $this->paginate(15, false, [ - 'query' => \request()->request() - ]); - } - - /** - * 软删除 - * @return false|int - */ - public function setDelete() - { - return $this->save(['is_delete' => 1]); - } - - /** - * 提现打款成功:累积提现佣金 - * @param $user_id - * @param $money - * @return false|int - * @throws \think\exception\DbException - */ - public static function totalMoney($user_id, $money) - { - $model = self::detail($user_id); - return $model->save([ - 'freeze_money' => $model['freeze_money'] - $money, - 'total_money' => $model['total_money'] + $money, - ]); - } - - /** - * 提现驳回:解冻分销商资金 - * @param $user_id - * @param $money - * @return false|int - * @throws \think\exception\DbException - */ - public static function backFreezeMoney($user_id, $money) - { - $model = self::detail($user_id); - return $model->save([ - 'money' => $model['money'] + $money, - 'freeze_money' => $model['freeze_money'] - $money, - ]); - } - - -} \ No newline at end of file diff --git a/source/application/store/model/dealer/Withdraw.php b/source/application/store/model/dealer/Withdraw.php deleted file mode 100644 index 0511897..0000000 --- a/source/application/store/model/dealer/Withdraw.php +++ /dev/null @@ -1,153 +0,0 @@ - 0 ? date('Y-m-d H:i:s', $value) : 0; - } - - /** - * 获取器:打款方式 - * @param $value - * @return mixed - */ - public function getPayTypeAttr($value) - { - return ['text' => PayTypeEnum::data()[$value]['name'], 'value' => $value]; - } - - /** - * 获取分销商提现列表 - * @param null $user_id - * @param int $apply_status - * @param int $pay_type - * @param string $search - * @return \think\Paginator - * @throws \think\exception\DbException - */ - public function getList($user_id = null, $apply_status = -1, $pay_type = -1, $search = '') - { - // 构建查询规则 - $this->alias('withdraw') - ->with(['user']) - ->field('withdraw.*, dealer.real_name, dealer.mobile, user.nickName, user.avatarUrl') - ->join('user', 'user.user_id = withdraw.user_id') - ->join('dealer_user dealer', 'dealer.user_id = withdraw.user_id') - ->order(['withdraw.create_time' => 'desc']); - // 查询条件 - $user_id > 0 && $this->where('withdraw.user_id', '=', $user_id); - !empty($search) && $this->where('dealer.real_name|dealer.mobile', 'like', "%$search%"); - $apply_status > 0 && $this->where('withdraw.apply_status', '=', $apply_status); - $pay_type > 0 && $this->where('withdraw.pay_type', '=', $pay_type); - // 获取列表数据 - return $this->paginate(15, false, [ - 'query' => \request()->request() - ]); - } - - /** - * 分销商提现审核 - * @param $data - * @return bool - */ - public function submit($data) - { - if ( - $data['apply_status'] == ApplyStatusEnum::AUDIT_REJECT - && empty($data['reject_reason']) - ) { - $this->error = '请填写驳回原因'; - return false; - } - $this->transaction(function () use ($data) { - // 更新申请记录 - $data['audit_time'] = time(); - $this->allowField(true)->save($data); - // 提现驳回:解冻分销商资金 - if ($data['apply_status'] == ApplyStatusEnum::AUDIT_REJECT) { - User::backFreezeMoney($this['user_id'], $this['money']); - } - // 发送消息通知 - MessageService::send('dealer.withdraw', [ - 'withdraw' => $this, - 'user' => UserModel::detail($this['user_id']), - ]); - }); - return true; - } - - /** - * 确认已打款 - * @return bool - */ - public function money() - { - $this->transaction(function () { - // 更新申请状态 - $this->allowField(true)->save([ - 'apply_status' => 40, - 'audit_time' => time(), - ]); - // 更新分销商累积提现佣金 - User::totalMoney($this['user_id'], $this['money']); - // 记录分销商资金明细 - Capital::add([ - 'user_id' => $this['user_id'], - 'flow_type' => 20, - 'money' => -$this['money'], - 'describe' => '申请提现', - ]); - }); - return true; - } - - /** - * 分销商提现:微信支付企业付款 - * @return bool - * @throws \app\common\exception\BaseException - * @throws \think\Exception - * @throws \think\exception\DbException - */ - public function wechatPay() - { - // 微信用户信息 - $user = $this['user']['user']; - // 生成付款订单号 - $orderNO = OrderService::createOrderNo(); - // 付款描述 - $desc = '分销商提现付款'; - // 微信支付api:企业付款到零钱 - $wxConfig = WxappModel::getWxappCache(); - $WxPay = new WxPay($wxConfig); - // 请求付款api - if ($WxPay->transfers($orderNO, $user['open_id'], $this['money'], $desc)) { - // 确认已打款 - $this->money(); - return true; - } - return false; - } - -} \ No newline at end of file diff --git a/source/application/store/model/recharge/Order.php b/source/application/store/model/recharge/Order.php deleted file mode 100644 index 7a9d169..0000000 --- a/source/application/store/model/recharge/Order.php +++ /dev/null @@ -1,61 +0,0 @@ -setQueryWhere($query); - // 获取列表数据 - return $this->with(['user', 'order_plan']) - ->alias('order') - ->field('order.*') - ->join('user', 'user.user_id = order.user_id') - ->order(['order.create_time' => 'desc']) - ->paginate(15, false, [ - 'query' => request()->request() - ]); - } - - /** - * 设置查询条件 - * @param $query - */ - private function setQueryWhere($query) - { - // 设置默认的检索数据 - $params = $this->setQueryDefaultValue($query, [ - 'user_id' => 0, - 'recharge_type' => '-1', - 'pay_status' => '-1', - ]); - // 用户ID - $params['user_id'] > 0 && $this->where('order.user_id', '=', $params['user_id']); - // 用户昵称/订单号 - !empty($params['search']) && $this->where('order.order_no|user.nickName', 'like', "%{$params['search']}%"); - // 充值方式 - $params['recharge_type'] > -1 && $this->where('order.recharge_type', '=', (int)$params['recharge_type']); - // 支付状态 - $params['pay_status'] > -1 && $this->where('order.pay_status', '=', (int)$params['pay_status']); - // 起始时间 - !empty($params['start_time']) && $this->where('order.create_time', '>=', strtotime($params['start_time'])); - // 截止时间 - !empty($params['end_time']) && $this->where('order.create_time', '<', strtotime($params['end_time']) + 86400); - } - -} \ No newline at end of file diff --git a/source/application/store/model/recharge/OrderPlan.php b/source/application/store/model/recharge/OrderPlan.php deleted file mode 100644 index 047fe56..0000000 --- a/source/application/store/model/recharge/OrderPlan.php +++ /dev/null @@ -1,15 +0,0 @@ -where('is_delete', '=', 0) - ->order(['sort' => 'asc', 'create_time' => 'desc']) - ->paginate(15, false, [ - 'query' => request()->request() - ]); - } - - /** - * 添加新记录 - * @param $data - * @return false|int - */ - public function add($data) - { - $data['wxapp_id'] = self::$wxapp_id; - return $this->allowField(true)->save($data); - } - - /** - * 更新记录 - * @param $data - * @return bool|int - */ - public function edit($data) - { - return $this->allowField(true)->save($data) !== false; - } - - /** - * 删除记录 (软删除) - * @return bool|int - */ - public function setDelete() - { - return $this->save(['is_delete' => 1]) !== false; - } - -} \ No newline at end of file diff --git a/source/application/store/model/sharing/Active.php b/source/application/store/model/sharing/Active.php deleted file mode 100644 index ed35fb8..0000000 --- a/source/application/store/model/sharing/Active.php +++ /dev/null @@ -1,30 +0,0 @@ - 0 && $this->where('active_id', '=', $active_id); - return $this->with(['goods.image.file', 'user']) - ->order(['create_time' => 'desc']) - ->paginate(15, false, [ - 'query' => request()->request() - ]); - } - -} diff --git a/source/application/store/model/sharing/ActiveUsers.php b/source/application/store/model/sharing/ActiveUsers.php deleted file mode 100644 index 7e543a3..0000000 --- a/source/application/store/model/sharing/ActiveUsers.php +++ /dev/null @@ -1,30 +0,0 @@ -with(['sharingOrder.address', 'user']) - ->where('active_id', '=', $active_id) - ->order(['create_time' => 'asc']) - ->paginate(15, false, [ - 'query' => request()->request() - ]); - } - -} diff --git a/source/application/store/model/sharing/Category.php b/source/application/store/model/sharing/Category.php deleted file mode 100644 index 949394d..0000000 --- a/source/application/store/model/sharing/Category.php +++ /dev/null @@ -1,79 +0,0 @@ -deleteCache(); - return $this->allowField(true)->save($data); - } - - /** - * 编辑记录 - * @param $data - * @return bool|int - */ - public function edit($data) - { - $this->deleteCache(); - return $this->allowField(true)->save($data); - } - - /** - * 删除商品分类 - * @param $category_id - * @return bool|int - */ - public function remove($category_id) - { - // 判断是否存在商品 - if ($goodsCount = (new Goods)->getGoodsTotal(['category_id' => $category_id])) { - $this->error = '该分类下存在' . $goodsCount . '个商品,不允许删除'; - return false; - } - // 判断是否存在子分类 - if ((new self)->where(['parent_id' => $category_id])->count()) { - $this->error = '该分类下存在子分类,请先删除'; - return false; - } - $this->deleteCache(); - return $this->delete(); - } - - /** - * 删除缓存 - * @return bool - */ - private function deleteCache() - { - return Cache::rm('sharing_category_' . self::$wxapp_id); - } - -} diff --git a/source/application/store/model/sharing/Comment.php b/source/application/store/model/sharing/Comment.php deleted file mode 100644 index 8681910..0000000 --- a/source/application/store/model/sharing/Comment.php +++ /dev/null @@ -1,91 +0,0 @@ -save(['is_delete' => 1]); - } - - /** - * 获取评价总数量 - * @return int|string - */ - public function getCommentTotal() - { - return $this->where(['is_delete' => 0])->count(); - } - - /** - * 更新记录 - * @param $data - * @return bool - * @throws \think\exception\PDOException - */ - public function edit($data) - { - // 开启事务 - $this->startTrans(); - try { - // 删除评价图片 - $this->image()->delete(); - // 添加评论图片 - isset($data['images']) && $this->addCommentImages($data['images']); - // 是否为图片评价 - $data['is_picture'] = !$this->image()->select()->isEmpty(); - // 更新评论记录 - $this->allowField(true)->save($data); - $this->commit(); - return true; - } catch (\Exception $e) { - $this->error = $e->getMessage(); - $this->rollback(); - return false; - } - } - - /** - * 添加评论图片 - * @param $images - * @return int - */ - private function addCommentImages($images) - { - $data = array_map(function ($image_id) { - return [ - 'image_id' => $image_id, - 'wxapp_id' => self::$wxapp_id - ]; - }, $images); - return $this->image()->saveAll($data); - } - - /** - * 获取评价列表 - * @return \think\Paginator - * @throws \think\exception\DbException - */ - public function getList() - { - return $this->with(['user', 'orderM', 'OrderGoods']) - ->where('is_delete', '=', 0) - ->order(['sort' => 'asc', 'create_time' => 'desc']) - ->paginate(15, false, [ - 'query' => request()->request() - ]); - } - -} \ No newline at end of file diff --git a/source/application/store/model/sharing/CommentImage.php b/source/application/store/model/sharing/CommentImage.php deleted file mode 100644 index 98d4f3e..0000000 --- a/source/application/store/model/sharing/CommentImage.php +++ /dev/null @@ -1,14 +0,0 @@ -error = '请上传商品图片'; - return false; - } - $data['content'] = isset($data['content']) ? $data['content'] : ''; - $data['wxapp_id'] = $data['sku']['wxapp_id'] = self::$wxapp_id; - // 开启事务 - $this->startTrans(); - try { - // 添加商品 - $this->allowField(true)->save($data); - // 商品规格 - $this->addGoodsSpec($data); - // 商品图片 - $this->addGoodsImages($data['images']); - $this->commit(); - return true; - } catch (\Exception $e) { - $this->error = $e->getMessage(); - $this->rollback(); - return false; - } - } - - /** - * 添加商品图片 - * @param $images - * @return int - * @throws \think\Exception - * @throws \think\exception\PDOException - */ - private function addGoodsImages($images) - { - $this->image()->delete(); - $data = array_map(function ($image_id) { - return [ - 'image_id' => $image_id, - 'wxapp_id' => self::$wxapp_id - ]; - }, $images); - return $this->image()->saveAll($data); - } - - /** - * 编辑商品 - * @param $data - * @return bool - * @throws \think\exception\PDOException - */ - public function edit($data) - { - if (!isset($data['images']) || empty($data['images'])) { - $this->error = '请上传商品图片'; - return false; - } - $data['content'] = isset($data['content']) ? $data['content'] : ''; - $data['wxapp_id'] = $data['sku']['wxapp_id'] = self::$wxapp_id; - // 开启事务 - $this->startTrans(); - try { - // 保存商品 - $this->allowField(true)->save($data); - // 商品规格 - $this->addGoodsSpec($data, true); - // 商品图片 - $this->addGoodsImages($data['images']); - $this->commit(); - return true; - } catch (\Exception $e) { - $this->rollback(); - $this->error = $e->getMessage(); - return false; - } - } - - /** - * 添加商品规格 - * @param $data - * @param $isUpdate - * @throws \Exception - */ - private function addGoodsSpec(&$data, $isUpdate = false) - { - // 更新模式: 先删除所有规格 - $model = new GoodsSku; - $isUpdate && $model->removeAll($this['goods_id']); - // 添加规格数据 - if ($data['spec_type'] == '10') { - // 单规格 - $this->sku()->save($data['sku']); - } else if ($data['spec_type'] == '20') { - // 添加商品与规格关系记录 - $model->addGoodsSpecRel($this['goods_id'], $data['spec_many']['spec_attr']); - // 添加商品sku - $model->addSkuList($this['goods_id'], $data['spec_many']['spec_list']); - } - } - - /** - * 修改商品状态 - * @param $state - * @return false|int - */ - public function setStatus($state) - { - return $this->save(['goods_status' => $state ? 10 : 20]) !== false; - } - - /** - * 软删除 - * @return false|int - */ - public function setDelete() - { - return $this->save(['is_delete' => 1]); - } - - /** - * 获取当前商品总数 - * @param array $where - * @return int|string - */ - public function getGoodsTotal($where = []) - { - $this->where('is_delete', '=', 0); - !empty($where) && $this->where($where); - return $this->count(); - } - - -} diff --git a/source/application/store/model/sharing/GoodsImage.php b/source/application/store/model/sharing/GoodsImage.php deleted file mode 100644 index ecde950..0000000 --- a/source/application/store/model/sharing/GoodsImage.php +++ /dev/null @@ -1,14 +0,0 @@ - $item['spec_sku_id'], - 'goods_id' => $goods_id, - 'wxapp_id' => self::$wxapp_id, - ]); - } - return $this->allowField(true)->saveAll($data); - } - - /** - * 添加商品规格关系记录 - * @param $goods_id - * @param $spec_attr - * @return array|false - * @throws \Exception - */ - public function addGoodsSpecRel($goods_id, $spec_attr) - { - $data = []; - array_map(function ($val) use (&$data, $goods_id) { - array_map(function ($item) use (&$val, &$data, $goods_id) { - $data[] = [ - 'goods_id' => $goods_id, - 'spec_id' => $val['group_id'], - 'spec_value_id' => $item['item_id'], - 'wxapp_id' => self::$wxapp_id, - ]; - }, $val['spec_items']); - }, $spec_attr); - $model = new GoodsSpecRel; - return $model->saveAll($data); - } - - /** - * 移除指定商品的所有sku - * @param $goods_id - * @return int - */ - public function removeAll($goods_id) - { - $model = new GoodsSpecRel; - $model->where('goods_id','=', $goods_id)->delete(); - return $this->where('goods_id','=', $goods_id)->delete(); - } - -} diff --git a/source/application/store/model/sharing/GoodsSpecRel.php b/source/application/store/model/sharing/GoodsSpecRel.php deleted file mode 100644 index 8014186..0000000 --- a/source/application/store/model/sharing/GoodsSpecRel.php +++ /dev/null @@ -1,14 +0,0 @@ -setWhere($query); - // 获取数据列表 - return $this->with(['active', 'goods.image', 'address', 'user']) - ->alias('order') - ->field('order.*, active.status as active_status') - ->join('user', 'user.user_id = order.user_id', 'LEFT') - ->join('sharing_active active', 'order.active_id = active.active_id', 'LEFT') - ->where($this->transferDataType($dataType)) - ->where('order.is_delete', '=', 0) - ->order(['order.create_time' => 'desc']) - ->paginate(10, false, [ - 'query' => \request()->request() - ]); - } - - /** - * 订单列表(全部) - * @param $dataType - * @param array $query - * @return false|\PDOStatement|string|\think\Collection - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - */ - public function getListAll($dataType, $query = []) - { - // 检索查询条件 - !empty($query) && $this->setWhere($query); - // 获取数据列表 - return $this->with(['goods.image', 'address', 'user', 'extract', 'extract_shop']) - ->alias('order') - ->field('order.*, active.status as active_status') - ->join('sharing_active active', 'order.active_id = active.active_id', 'LEFT') - ->where($this->transferDataType($dataType)) - ->where('order.is_delete', '=', 0) - ->order(['create_time' => 'desc']) - ->select(); - } - - /** - * 订单导出 - * @param $dataType - * @param $query - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - */ - public function exportList($dataType, $query) - { - // 获取订单列表 - $list = $this->getListAll($dataType, $query); - // 导出csv文件 - return (new Exportservice)->orderList($list); - } - - /** - * 批量发货模板 - */ - public function deliveryTpl() - { - return (new Exportservice)->deliveryTpl(); - } - - /** - * 设置检索查询条件 - * @param $query - */ - private function setWhere($query) - { - if (isset($query['search']) && !empty($query['search'])) { - $this->where('order_no|user.nickName', 'like', '%' . trim($query['search']) . '%'); - } - if (isset($query['start_time']) && !empty($query['start_time'])) { - $this->where('order.create_time', '>=', strtotime($query['start_time'])); - } - if (isset($query['end_time']) && !empty($query['end_time'])) { - $this->where('order.create_time', '<', strtotime($query['end_time']) + 86400); - } - if (isset($query['active_id']) && $query['active_id'] > 0) { - $this->where('order.active_id', '=', (int)$query['active_id']); - } - if (isset($query['delivery_type']) && !empty($query['delivery_type'])) { - $query['delivery_type'] > -1 && $this->where('delivery_type', '=', $query['delivery_type']); - } - if (isset($query['extract_shop_id']) && !empty($query['extract_shop_id'])) { - $query['extract_shop_id'] > -1 && $this->where('extract_shop_id', '=', $query['extract_shop_id']); - } - } - - /** - * 转义数据类型条件 - * @param $dataType - * @return array - */ - private function transferDataType($dataType) - { - // 数据类型 - $filter = []; - switch ($dataType) { - case 'all': - // 全部 - $filter = []; - break; - case 'pay': - // 待支付 - $filter = ['pay_status' => 10, 'order_status' => 10]; - break; - case 'sharing'; - // 拼团中 - $filter['active.status'] = 10; - break; - case 'sharing_succeed'; - // 拼团成功 - $filter['active.status'] = 20; - break; - case 'sharing_fail'; - // 拼团失败 - $filter['active.status'] = 30; - break; - case 'delivery': - // 待发货 - $this->where('IF ( (`order`.`order_type` = 20), (`active`.`status` = 20), TRUE)'); - $filter = [ - 'pay_status' => 20, - 'delivery_status' => 10, - 'order_status' => ['in', [10, 21]] - ]; - break; - case 'receipt': - // 待收货 - $filter = [ - 'pay_status' => 20, - 'delivery_status' => 20, - 'receipt_status' => 10 - ]; - break; - case 'complete': - // 已完成 - $filter = ['order_status' => 30]; - break; - case 'cancel': - // 已取消 - $filter = ['order_status' => 20]; - break; - } - return $filter; - } - - /** - * 确认发货(单独订单) - * @param $data - * @return array|bool|false - * @throws \think\Exception - * @throws \think\exception\DbException - * @throws \Exception - */ - public function delivery($data) - { - // 转义为订单列表 - $orderList = [$this]; - // 验证订单是否满足发货条件 - if (!$this->verifyDelivery($orderList)) { - return false; - } - // 整理更新的数据 - $updateList = [[ - 'order_id' => $this['order_id'], - 'express_id' => $data['express_id'], - 'express_no' => $data['express_no'] - ]]; - // 更新订单发货状态 - if ($status = $this->updateToDelivery($updateList)) { - // 获取已发货的订单 - $completed = self::detail($this['order_id'], ['user', 'address', 'goods', 'express']); - // 发送消息通知 - $this->sendDeliveryMessage([$completed]); - } - return $status; - } - - /** - * 批量发货 - * @param $data - * @return bool - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - * @throws \Exception - */ - public function batchDelivery($data) - { - // 获取csv文件中的数据 - if (!$csvData = $this->getCsvData()) { - return false; - } - // 整理订单id集 - $orderNos = helper::getArrayColumn($csvData, 0); - // 获取订单列表数据 - $orderList = helper::arrayColumn2Key($this->getListByOrderNos($orderNos), 'order_no'); - // 验证订单是否存在 - $tempArr = array_values(array_diff($orderNos, array_keys($orderList))); - if (!empty($tempArr)) { - $this->error = "订单号[{$tempArr[0]}] 不存在!"; - return false; - } - // 整理物流单号 - $updateList = []; - foreach ($csvData as $item) { - $updateList[] = [ - 'order_id' => $orderList[$item[0]]['order_id'], - 'express_id' => $data['express_id'], - 'express_no' => $item[1], - ]; - } - // 验证订单是否满足发货条件 - if (!$this->verifyDelivery($orderList)) { - return false; - } - // 更新订单发货状态(批量) - if ($status = $this->updateToDelivery($updateList)) { - // 获取已发货的订单 - $completed = $this->getListByOrderNos($orderNos, ['user', 'address', 'goods', 'express']); - // 发送消息通知 - $this->sendDeliveryMessage($completed); - } - return $status; - } - - /** - * 确认发货后发送消息通知 - * @param $orderList - * @return bool - */ - private function sendDeliveryMessage($orderList) - { - // 发送消息通知 - foreach ($orderList as $item) { - MessageService::send('order.delivery', [ - 'order' => $item, - 'order_type' => OrderTypeEnum::SHARING, - ]); - } - return true; - } - - /** - * 更新订单发货状态(批量) - * @param $orderList - * @return array|false - * @throws \Exception - */ - private function updateToDelivery($orderList) - { - $data = []; - foreach ($orderList as $item) { - $data[] = [ - 'order_id' => $item['order_id'], - 'express_no' => $item['express_no'], - 'express_id' => $item['express_id'], - 'delivery_status' => 20, - 'delivery_time' => time(), - ]; - } - return $this->isUpdate()->saveAll($data); - } - - /** - * 验证订单是否满足发货条件 - * @param $orderList - * @return bool - */ - private function verifyDelivery($orderList) - { - foreach ($orderList as $order) { - if ( - $order['pay_status']['value'] != 20 - || $order['delivery_type']['value'] != DeliveryTypeEnum::EXPRESS - || $order['delivery_status']['value'] != 10 - || ( - // 拼团订单验证拼单状态 - $order['order_type']['value'] == 20 - && $order['active']['status']['value'] != 20 - ) - ) { - $this->error = "订单号[{$order['order_no']}] 不满足发货条件!"; - return false; - } - } - return true; - } - - /** - * 获取csv文件中的数据 - * @return array|bool - */ - private function getCsvData() - { - // 获取表单上传文件 例如上传了001.jpg - $file = \request()->file('iFile'); - if (empty($file)) { - $this->error = '请上传发货模板'; - return false; - } - // 设置区域信息 - setlocale(LC_ALL, 'zh_CN'); - // 打开上传的文件 - $csvFile = fopen($file->getInfo()['tmp_name'], 'r'); - // 忽略第一行(csv标题) - fgetcsv($csvFile); - // 遍历并记录订单信息 - $orderList = []; - while ($item = fgetcsv($csvFile)) { - if (!isset($item[0]) || empty($item[0]) || !isset($item[1]) || empty($item[1])) { - $this->error = '模板文件数据不合法'; - return false; - } - $orderList[] = $item; - } - if (empty($orderList)) { - $this->error = '模板文件中没有订单数据'; - return false; - } - return $orderList; - } - - /** - * 修改订单价格 - * @param $data - * @return bool - */ - public function updatePrice($data) - { - if ($this['pay_status']['value'] != 10) { - $this->error = '该订单不合法'; - return false; - } - // 实际付款金额 - $payPrice = bcadd($data['update_price'], $data['update_express_price'], 2); - if ($payPrice <= 0) { - $this->error = '订单实付款价格不能为0.00元'; - return false; - } - return $this->save([ - 'order_no' => $this->orderNo(), // 修改订单号, 否则微信支付提示重复 - 'order_price' => $data['update_price'], - 'pay_price' => $payPrice, - 'update_price' => helper::bcsub($data['update_price'], helper::bcsub($this['total_price'], $this['coupon_money'])), - 'express_price' => $data['update_express_price'] - ]) !== false; - } - - /** - * 审核:用户取消订单 - * @param $data - * @return bool - */ - public function confirmCancel($data) - { - // 判断订单是否有效 - if ($this['pay_status']['value'] != 20) { - $this->error = '该订单不合法'; - return false; - } - // 订单取消事件 - return $this->transaction(function () use ($data) { - if ($data['is_cancel'] == true) { - // 执行退款操作 - (new RefundService)->execute($this); - // 回退商品库存 - (new OrderGoods)->backGoodsStock($this['goods'], true); - // 回退用户优惠券 - $this['coupon_id'] > 0 && UserCouponModel::setIsUse($this['coupon_id'], false); - // 回退用户积分 - $User = UserModel::detail($this['user_id']); - $describe = "订单取消:{$this['order_no']}"; - $this['points_num'] > 0 && $User->setIncPoints($this['points_num'], $describe); - } - // 更新订单状态 - return $this->save(['order_status' => $data['is_cancel'] ? 20 : 10]); - }); - } - - /** - * 拼团失败手动退款 - * @return bool|false|int - * @throws \app\common\exception\BaseException - * @throws \think\Exception - * @throws \think\exception\DbException - */ - public function refund() - { - if ( - $this['order_type']['value'] != 20 - || $this['pay_status']['value'] != 20 - || $this['active']['status']['value'] != 30 - || $this['is_refund'] == 1 - ) { - $this->error = '该订单不合法'; - return false; - } - // 执行退款操作 - (new RefundService)->execute($this); - // 更新订单状态 - return $this->save(['order_status' => 20, 'is_refund' => 1]); - } - - /** - * 获取已付款订单总数 (可指定某天) - * @param null $day - * @return int|string - * @throws \think\Exception - */ - public function getPayOrderTotal($day = null) - { - $filter = ['pay_status' => 20]; - if (!is_null($day)) { - $startTime = strtotime($day); - $filter['pay_time'] = [ - ['>=', $startTime], - ['<', $startTime + 86400], - ]; - } - return $this->getOrderTotal($filter); - } - - /** - * 获取订单总数量 - * @param array $filter - * @return int|string - * @throws \think\Exception - */ - public function getOrderTotal($filter = []) - { - return $this->where($filter) - ->where('is_delete', '=', 0) - ->count(); - } - - /** - * 获取某天的总销售额 - * @param $day - * @return float|int - */ - public function getOrderTotalPrice($day) - { - $startTime = strtotime($day); - return $this->where('pay_time', '>=', $startTime) - ->where('pay_time', '<', $startTime + 86400) - ->where('pay_status', '=', 20) - ->where('is_delete', '=', 0) - ->sum('pay_price'); - } - - /** - * 获取某天的下单用户数 - * @param $day - * @return float|int - */ - public function getPayOrderUserTotal($day) - { - $startTime = strtotime($day); - $userIds = $this->distinct(true) - ->where('pay_time', '>=', $startTime) - ->where('pay_time', '<', $startTime + 86400) - ->where('pay_status', '=', 20) - ->where('is_delete', '=', 0) - ->column('user_id'); - return count($userIds); - } - -} diff --git a/source/application/store/model/sharing/OrderAddress.php b/source/application/store/model/sharing/OrderAddress.php deleted file mode 100644 index 0909921..0000000 --- a/source/application/store/model/sharing/OrderAddress.php +++ /dev/null @@ -1,15 +0,0 @@ -where('order.order_no', 'like', "%{$query['order_no']}%"); - } - // 查询条件:起始日期 - if (isset($query['start_time']) && !empty($query['start_time'])) { - $this->where('m.create_time', '>=', strtotime($query['start_time'])); - } - // 查询条件:截止日期 - if (isset($query['end_time']) && !empty($query['end_time'])) { - $this->where('m.create_time', '<', strtotime($query['end_time']) + 86400); - } - // 售后类型 - if (isset($query['type']) && $query['type'] > 0) { - $this->where('m.type', '=', $query['type']); - } - // 处理状态 - if (isset($query['state']) && is_numeric($query['state'])) { - $this->where('m.status', '=', $query['state']); - } - // 获取列表数据 - return $this->alias('m') - ->field('m.*, order.order_no') - ->with(['order_goods.image', 'orderMaster', 'user']) - ->join('sharing_order order', 'order.order_id = m.order_id') - ->order(['m.create_time' => 'desc']) - ->paginate(10, false, [ - 'query' => \request()->request() - ]); - } - - /** - * 商家审核 - * @param $data - * @return bool - */ - public function audit($data) - { - if ($data['is_agree'] == 20 && empty($data['refuse_desc'])) { - $this->error = '请输入拒绝原因'; - return false; - } - if ($data['is_agree'] == 10 && empty($data['address_id'])) { - $this->error = '请选择退货地址'; - return false; - } - $this->transaction(function () use ($data) { - // 拒绝申请, 标记售后单状态为已拒绝 - $data['is_agree'] == 20 && $data['status'] = 10; - // 同意换货申请, 标记售后单状态为已完成 - $data['is_agree'] == 10 && $this['type']['value'] == 20 && $data['status'] = 20; - // 更新退款单状态 - $this->allowField(true)->save($data); - // 同意售后申请, 记录退货地址 - if ($data['is_agree'] == 10) { - (new OrderRefundAddress)->add($this['order_refund_id'], $data['address_id']); - } - // 订单详情 - $order = Order::detail($this['order_id']); - // 发送消息通知 - MessageService::send('order.refund', [ - 'refund' => $this, // 退款单信息 - 'order_no' => $order['order_no'], // 订单信息 - 'order_type' => OrderTypeEnum::SHARING, // 订单类型 - ]); - }); - return true; - } - - /** - * 确认收货并退款 - * @param $data - * @return bool - * @throws \think\exception\DbException - */ - public function receipt($data) - { - // 订单详情 - $order = Order::detail($this['order_id']); - if ($data['refund_money'] > min($order['pay_price'], $this['order_goods']['total_pay_price'])) { - $this->error = '退款金额不能大于商品实付款金额'; - return false; - } - $this->transaction(function () use ($order, $data) { - // 更新售后单状态 - $this->allowField(true)->save([ - 'refund_money' => $data['refund_money'], - 'is_receipt' => 1, - 'status' => 20 - ]); - // 消减用户的实际消费金额 - // 条件:判断订单是否已结算 - if ($order['is_settled'] == true) { - (new UserModel)->setDecUserExpend($order['user_id'], $data['refund_money']); - } - // 执行原路退款 - (new RefundService)->execute($order, $data['refund_money']); - // 发送消息通知 - MessageService::send('order.refund', [ - 'refund' => $this, // 退款单信息 - 'order_no' => $order['order_no'], // 订单信息 - 'order_type' => OrderTypeEnum::SHARING, // 订单类型 - ]); - }); - return true; - } - -} \ No newline at end of file diff --git a/source/application/store/model/sharing/OrderRefundAddress.php b/source/application/store/model/sharing/OrderRefundAddress.php deleted file mode 100644 index 5ec22a4..0000000 --- a/source/application/store/model/sharing/OrderRefundAddress.php +++ /dev/null @@ -1,34 +0,0 @@ -save([ - 'order_refund_id' => $order_refund_id, - 'name' => $detail['name'], - 'phone' => $detail['phone'], - 'detail' => $detail['detail'], - 'wxapp_id' => self::$wxapp_id - ]); - } - -} \ No newline at end of file diff --git a/source/application/store/model/sharing/OrderRefundImage.php b/source/application/store/model/sharing/OrderRefundImage.php deleted file mode 100644 index 9a7ac42..0000000 --- a/source/application/store/model/sharing/OrderRefundImage.php +++ /dev/null @@ -1,15 +0,0 @@ - '基础设置', - ]; - - /** - * 更新系统设置 - * @param $key - * @param $values - * @return bool - * @throws \think\exception\DbException - */ - public function edit($key, $values) - { - $model = self::detail($key) ?: $this; - // 删除系统设置缓存 - Cache::rm('sharing_setting_' . self::$wxapp_id); - return $model->save([ - 'key' => $key, - 'describe' => $this->describe[$key], - 'values' => $values, - 'wxapp_id' => self::$wxapp_id, - ]) !== false; - } - -} \ No newline at end of file diff --git a/source/application/store/model/store/Access.php b/source/application/store/model/store/Access.php deleted file mode 100644 index c01bb68..0000000 --- a/source/application/store/model/store/Access.php +++ /dev/null @@ -1,56 +0,0 @@ -getAll() as $item) { - $jsTree[] = [ - 'id' => $item['access_id'], - 'parent' => $item['parent_id'] > 0 ? $item['parent_id'] : '#', - 'text' => $item['name'], - 'state' => [ - 'selected' => (in_array($item['access_id'], $accessIds) && !$this->hasChildren($item['access_id'])) - ] - ]; - } - return json_encode($jsTree); - } - - /** - * 是否存在子集 - * @param $access_id - * @return bool - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - */ - private function hasChildren($access_id) - { - foreach (self::getAll() as $item) { - if ($item['parent_id'] == $access_id) - return true; - } - return false; - } - -} \ No newline at end of file diff --git a/source/application/store/model/store/Role.php b/source/application/store/model/store/Role.php deleted file mode 100644 index 710f49a..0000000 --- a/source/application/store/model/store/Role.php +++ /dev/null @@ -1,187 +0,0 @@ -getAll(); - return $this->formatTreeData($all); - } - - /** - * 新增记录 - * @param $data - * @return bool - * @throws \Exception - */ - public function add($data) - { - $data['wxapp_id'] = self::$wxapp_id; - if (empty($data['access'])) { - $this->error = '请选择权限'; - return false; - } - $this->startTrans(); - try { - // 新增角色记录 - $this->allowField(true)->save($data); - // 新增角色权限关系记录 - (new RoleAccess)->add($this['role_id'], $data['access']); - $this->commit(); - return true; - } catch (\Exception $e) { - $this->error = $e->getMessage(); - $this->rollback(); - return false; - } - } - - /** - * 更新记录 - * @param $data - * @return bool - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - * @throws \think\exception\PDOException - */ - public function edit($data) - { - if (empty($data['access'])) { - $this->error = '请选择权限'; - return false; - } - // 判断上级角色是否为当前子级 - if ($data['parent_id'] > 0) { - // 获取所有上级id集 - $parentIds = $this->getTopRoleIds($data['parent_id']); - if (in_array($this['role_id'], $parentIds)) { - $this->error = '上级角色不允许设置为当前子角色'; - return false; - } - } - $this->startTrans(); - try { - // 更新角色记录 - $this->allowField(true)->save($data); - // 更新角色权限关系记录 - (new RoleAccess)->edit($this['role_id'], $data['access']); - $this->commit(); - return true; - } catch (\Exception $e) { - $this->error = $e->getMessage(); - $this->rollback(); - return false; - } - } - - /** - * 获取所有上级id集 - * @param $role_id - * @param null $all - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - */ - private function getTopRoleIds($role_id, &$all = null) - { - static $ids = []; - is_null($all) && $all = $this->getAll(); - foreach ($all as $item) { - if ($item['role_id'] == $role_id && $item['parent_id'] > 0) { - $ids[] = $item['parent_id']; - $this->getTopRoleIds($item['parent_id'], $all); - } - } - return $ids; - } - - /** - * 删除记录 - * @return bool|int - * @throws \think\exception\DbException - */ - public function remove() - { - // 判断是否存在下级角色 - if (self::detail(['parent_id' => $this['role_id']])) { - $this->error = '当前角色下存在子角色,不允许删除'; - return false; - } - // 删除对应的权限关系 - RoleAccess::deleteAll(['role_id' => $this['role_id']]); - return $this->delete(); - } - - /** - * 获取所有角色 - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - */ - private function getAll() - { - $data = $this->order(['sort' => 'asc', 'create_time' => 'asc'])->select(); - return $data ? $data->toArray() : []; - } - - /** - * 获取权限列表 - * @param $all - * @param int $parent_id - * @param int $deep - * @return array - */ - private function formatTreeData(&$all, $parent_id = 0, $deep = 1) - { - static $tempTreeArr = []; - foreach ($all as $key => $val) { - if ($val['parent_id'] == $parent_id) { - // 记录深度 - $val['deep'] = $deep; - // 根据角色深度处理名称前缀 - $val['role_name_h1'] = $this->htmlPrefix($deep) . $val['role_name']; - $tempTreeArr[] = $val; - $this->formatTreeData($all, $val['role_id'], $deep + 1); - } - } - return $tempTreeArr; - } - - /** - * 角色名称 html格式前缀 - * @param $deep - * @return string - */ - private function htmlPrefix($deep) - { - // 根据角色深度处理名称前缀 - $prefix = ''; - if ($deep > 1) { - for ($i = 1; $i <= $deep - 1; $i++) { - $prefix .= ' ├ '; - } - $prefix .= ' '; - } - return $prefix; - } - -} \ No newline at end of file diff --git a/source/application/store/model/store/RoleAccess.php b/source/application/store/model/store/RoleAccess.php deleted file mode 100644 index 8f734f1..0000000 --- a/source/application/store/model/store/RoleAccess.php +++ /dev/null @@ -1,95 +0,0 @@ - $role_id, - 'access_id' => $access_id, - 'wxapp_id' => self::$wxapp_id, - ]; - } - return $this->saveAll($data); - } - - /** - * 更新关系记录 - * @param $role_id - * @param array $newAccess 新的权限集 - * @return array|false - * @throws \Exception - */ - public function edit($role_id, $newAccess) - { - // 已分配的权限集 - $assignAccessIds = self::getAccessIds($role_id); - - /** - * 找出删除的权限 - * 假如已有的权限集合是A,界面传递过得权限集合是B - * 权限集合A当中的某个权限不在权限集合B当中,就应该删除 - * 使用 array_diff() 计算补集 - */ - if ($deleteAccessIds = array_diff($assignAccessIds, $newAccess)) { - self::deleteAll(['role_id' => $role_id, 'access_id' => ['in', $deleteAccessIds]]); - } - - /** - * 找出添加的权限 - * 假如已有的权限集合是A,界面传递过得权限集合是B - * 权限集合B当中的某个权限不在权限集合A当中,就应该添加 - * 使用 array_diff() 计算补集 - */ - $newAccessIds = array_diff($newAccess, $assignAccessIds); - $data = []; - foreach ($newAccessIds as $access_id) { - $data[] = [ - 'role_id' => $role_id, - 'access_id' => $access_id, - 'wxapp_id' => self::$wxapp_id, - ]; - } - return $this->saveAll($data); - } - - /** - * 获取指定角色的所有权限id - * @param int|array $role_id 角色id (支持数组) - * @return array - */ - public static function getAccessIds($role_id) - { - $roleIds = is_array($role_id) ? $role_id : [(int)$role_id]; - return (new self)->where('role_id', 'in', $roleIds)->column('access_id'); - } - - /** - * 删除记录 - * @param $where - * @return int - */ - public static function deleteAll($where) - { - return self::destroy($where); - } - -} \ No newline at end of file diff --git a/source/application/store/model/store/Shop.php b/source/application/store/model/store/Shop.php deleted file mode 100644 index 7af9cd6..0000000 --- a/source/application/store/model/store/Shop.php +++ /dev/null @@ -1,123 +0,0 @@ -setListQueryWhere($param) - ->paginate(15, false, [ - 'query' => \request()->request() - ]); - } - - /** - * 获取所有门店列表 - * @param array $param - * @return false|\PDOStatement|string|\think\Collection - */ - public static function getAllList($param = []) - { - return (new static)->setListQueryWhere($param)->select(); - } - - /** - * 设置列表查询条件 - * @param array $param - * @return $this - */ - private function setListQueryWhere($param = []) - { - // 查询参数 - $param = array_merge(['is_check' => '', 'search' => '', 'status' => null,], $param); - is_numeric($param['is_check']) && $param['is_check'] > -1 && $this->where('is_check', '=', (int)$param['is_check']); - !empty($param['search']) && $this->where('shop_name|linkman|phone', 'like', "%{$param['search']}%"); - is_numeric($param['status']) && $this->where('status', '=', (int)$param['status']); - return $this->where('is_delete', '=', '0')->order(['sort' => 'asc', 'create_time' => 'desc']); - } - - /** - * 新增记录 - * @param $data - * @return bool - * @throws \Exception - */ - public function add($data) - { - if (!$this->validateForm($data)) { - return false; - } - return $this->allowField(true)->save($this->createData($data)); - } - - /** - * 编辑记录 - * @param $data - * @return false|int - */ - public function edit($data) - { - if (!$this->validateForm($data)) { - return false; - } - return $this->allowField(true)->save($this->createData($data)) !== false; - } - - /** - * 软删除 - * @return false|int - */ - public function setDelete() - { - return $this->save(['is_delete' => 1]); - } - - /** - * 创建数据 - * @param array $data - * @return array - */ - private function createData($data) - { - $data['wxapp_id'] = self::$wxapp_id; - // 格式化坐标信息 - $coordinate = explode(',', $data['coordinate']); - $data['latitude'] = $coordinate[0]; - $data['longitude'] = $coordinate[1]; - // 生成geohash - $Geohash = new Geohash; - $data['geohash'] = $Geohash->encode($data['longitude'], $data['latitude']); - return $data; - } - - /** - * 表单验证 - * @param $data - * @return bool - */ - private function validateForm($data) - { - if (!isset($data['logo_image_id']) || empty($data['logo_image_id'])) { - $this->error = '请选择门店logo'; - return false; - } - return true; - } - -} \ No newline at end of file diff --git a/source/application/store/model/store/User.php b/source/application/store/model/store/User.php deleted file mode 100644 index 3421137..0000000 --- a/source/application/store/model/store/User.php +++ /dev/null @@ -1,196 +0,0 @@ -getLoginUser($data['user_name'], $data['password'])) { - $this->error = '登录失败, 用户名或密码错误'; - return false; - } - if (empty($user['wxapp'])) { - $this->error = '登录失败, 未找到小程序信息'; - return false; - } - if ($user['wxapp']['is_recycle']) { - $this->error = '登录失败, 当前小程序商城已删除'; - return false; - } - // 保存登录状态 - $this->loginState($user); - return true; - } - - /** - * 获取登录用户信息 - * @param $user_name - * @param $password - * @return array|false|\PDOStatement|string|\think\Model - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - */ - private function getLoginUser($user_name, $password) - { - return self::useGlobalScope(false)->with(['wxapp'])->where([ - 'user_name' => $user_name, - 'password' => yoshop_hash($password), - 'is_delete' => 0 - ])->find(); - } - - /** - * 获取用户列表 - * @return \think\Paginator - * @throws \think\exception\DbException - */ - public function getList() - { - return $this->where('is_delete', '=', '0') - ->order(['create_time' => 'desc']) - ->paginate(15, false, [ - 'query' => \request()->request() - ]); - } - - /** - * 新增记录 - * @param $data - * @return bool|false|int - * @throws \think\exception\DbException - */ - public function add($data) - { - if (self::checkExist($data['user_name'])) { - $this->error = '用户名已存在'; - return false; - } - if ($data['password'] !== $data['password_confirm']) { - $this->error = '确认密码不正确'; - return false; - } - if (empty($data['role_id'])) { - $this->error = '请选择所属角色'; - return false; - } - $this->startTrans(); - try { - // 新增管理员记录 - $data['password'] = yoshop_hash($data['password']); - $data['wxapp_id'] = self::$wxapp_id; - $data['is_super'] = 0; - $this->allowField(true)->save($data); - // 新增角色关系记录 - (new UserRole)->add($this['store_user_id'], $data['role_id']); - $this->commit(); - return true; - } catch (\Exception $e) { - $this->error = $e->getMessage(); - $this->rollback(); - return false; - } - } - - /** - * 更新记录 - * @param array $data - * @return bool - * @throws \think\exception\DbException - */ - public function edit($data) - { - if ($this['user_name'] !== $data['user_name'] - && !!self::detail(['user_name' => $data['user_name']])) { - $this->error = '用户名已存在'; - return false; - } - if (!empty($data['password']) && ($data['password'] !== $data['password_confirm'])) { - $this->error = '确认密码不正确'; - return false; - } - if (empty($data['role_id'])) { - $this->error = '请选择所属角色'; - return false; - } - if (!empty($data['password'])) { - $data['password'] = yoshop_hash($data['password']); - } else { - unset($data['password']); - } - $this->startTrans(); - try { - // 更新管理员记录 - $this->allowField(true)->save($data); - // 更新角色关系记录 - (new UserRole)->edit($this['store_user_id'], $data['role_id']); - $this->commit(); - return true; - } catch (\Exception $e) { - $this->error = $e->getMessage(); - $this->rollback(); - return false; - } - } - - /** - * 软删除 - * @return false|int - */ - public function setDelete() - { - if ($this['is_super']) { - $this->error = '超级管理员不允许删除'; - return false; - } - // 删除对应的角色关系 - UserRole::deleteAll(['store_user_id' => $this['store_user_id']]); - return $this->save(['is_delete' => 1]); - } - - /** - * 更新当前管理员信息 - * @param $data - * @return bool - */ - public function renew($data) - { - if ($data['password'] !== $data['password_confirm']) { - $this->error = '确认密码不正确'; - return false; - } - // 更新管理员信息 - if ($this->save([ - 'user_name' => $data['user_name'], - 'password' => yoshop_hash($data['password']), - ]) === false) { - return false; - } - // 更新session - Session::set('yoshop_store.user', [ - 'store_user_id' => $this['store_user_id'], - 'user_name' => $data['user_name'], - ]); - return true; - } - -} diff --git a/source/application/store/model/store/UserRole.php b/source/application/store/model/store/UserRole.php deleted file mode 100644 index dec1e53..0000000 --- a/source/application/store/model/store/UserRole.php +++ /dev/null @@ -1,94 +0,0 @@ - $store_user_id, - 'role_id' => $role_id, - 'wxapp_id' => self::$wxapp_id, - ]; - } - return $this->saveAll($data); - } - - /** - * 更新关系记录 - * @param $store_user_id - * @param array $newRole 新的角色集 - * @return array|false - * @throws \Exception - */ - public function edit($store_user_id, $newRole) - { - // 已分配的角色集 - $assignRoleIds = self::getRoleIds($store_user_id); - - /** - * 找出删除的角色 - * 假如已有的角色集合是A,界面传递过得角色集合是B - * 角色集合A当中的某个角色不在角色集合B当中,就应该删除 - * 使用 array_diff() 计算补集 - */ - if ($deleteRoleIds = array_diff($assignRoleIds, $newRole)) { - self::deleteAll(['store_user_id' => $store_user_id, 'role_id' => ['in', $deleteRoleIds]]); - } - - /** - * 找出添加的角色 - * 假如已有的角色集合是A,界面传递过得角色集合是B - * 角色集合B当中的某个角色不在角色集合A当中,就应该添加 - * 使用 array_diff() 计算补集 - */ - $newRoleIds = array_diff($newRole, $assignRoleIds); - $data = []; - foreach ($newRoleIds as $role_id) { - $data[] = [ - 'store_user_id' => $store_user_id, - 'role_id' => $role_id, - 'wxapp_id' => self::$wxapp_id, - ]; - } - return $this->saveAll($data); - } - - /** - * 获取指定管理员的所有角色id - * @param $store_user_id - * @return array - */ - public static function getRoleIds($store_user_id) - { - return (new self)->where('store_user_id', '=', $store_user_id)->column('role_id'); - } - - /** - * 删除记录 - * @param $where - * @return int - */ - public static function deleteAll($where) - { - return self::destroy($where); - } - -} \ No newline at end of file diff --git a/source/application/store/model/store/shop/Clerk.php b/source/application/store/model/store/shop/Clerk.php deleted file mode 100644 index dee7372..0000000 --- a/source/application/store/model/store/shop/Clerk.php +++ /dev/null @@ -1,102 +0,0 @@ - -1 && $this->where('status', '=', (int)$status); - $shop_id > 0 && $this->where('shop_id', '=', (int)$shop_id); - !empty($search) && $this->where('real_name|mobile', 'like', "%{$search}%"); - // 查询列表数据 - return $this->with(['user', 'shop']) - ->where('is_delete', '=', '0') - ->order(['create_time' => 'desc']) - ->paginate(15, false, [ - 'query' => \request()->request() - ]); - } - - /** - * 新增记录 - * @param $data - * @return bool - * @throws \Exception - */ - public function add($data) - { - // 表单验证 - if (!$this->validateForm($data, self::FORM_SCENE_ADD)) { - return false; - } - $data['wxapp_id'] = self::$wxapp_id; - return $this->allowField(true)->save($data); - } - - /** - * 编辑记录 - * @param $data - * @return bool|false|int - * @throws \think\exception\DbException - */ - public function edit($data) - { - // 表单验证 - if (!$this->validateForm($data, self::FORM_SCENE_EDIT)) { - return false; - } - return $this->allowField(true)->save($data) !== false; - } - - /** - * 软删除 - * @return false|int - */ - public function setDelete() - { - return $this->save(['is_delete' => 1]); - } - - /** - * 表单验证 - * @param $data - * @param string $scene - * @return bool - * @throws \think\exception\DbException - */ - private function validateForm($data, $scene = self::FORM_SCENE_ADD) - { - if ($scene === self::FORM_SCENE_ADD) { - if (!isset($data['user_id']) || empty($data['user_id'])) { - $this->error = '请选择会员'; - return false; - } - if (self::detail(['user_id' => $data['user_id'], 'is_delete' => 0])) { - $this->error = '该会员已经是店员,无需重复添加'; - return false; - } - } - return true; - } - -} \ No newline at end of file diff --git a/source/application/store/model/store/shop/Order.php b/source/application/store/model/store/shop/Order.php deleted file mode 100644 index da3d12a..0000000 --- a/source/application/store/model/store/shop/Order.php +++ /dev/null @@ -1,42 +0,0 @@ - 0 && $this->where('clerk.shop_id', '=', (int)$shop_id); - !empty($search) && $this->where('clerk.real_name', 'like', "%{$search}%"); - // 查询列表数据 - $data = $this->alias('order') - ->with(['shop', 'clerk']) - ->join('store_shop_clerk clerk', 'clerk.clerk_id = order.clerk_id', 'INNER') - ->order(['order.create_time' => 'desc']) - ->paginate(15, false, [ - 'query' => \request()->request() - ]); - if ($data->isEmpty()) { - return $data; - } - // 整理订单信息 - return OrderService::getOrderList($data); - } - -} \ No newline at end of file diff --git a/source/application/store/model/user/BalanceLog.php b/source/application/store/model/user/BalanceLog.php deleted file mode 100644 index 737791b..0000000 --- a/source/application/store/model/user/BalanceLog.php +++ /dev/null @@ -1,64 +0,0 @@ -setQueryWhere($query); - // 获取列表数据 - return $this->with(['user']) - ->alias('log') - ->field('log.*') - ->join('user', 'user.user_id = log.user_id') - ->order(['log.create_time' => 'desc']) - ->paginate(15, false, [ - 'query' => request()->request() - ]); - } - - /** - * 设置查询条件 - * @param $query - */ - private function setQueryWhere($query) - { - // 设置默认的检索数据 - $params = $this->setQueryDefaultValue($query, [ - 'user_id' => 0, - 'scene' => -1, - 'recharge_type' => -1, - 'pay_status' => -1, - ]); - // 用户ID - $params['user_id'] > 0 && $this->where('log.user_id', '=', $params['user_id']); - // 用户昵称/订单号 - !empty($params['search']) && $this->where('user.nickName', 'like', "%{$params['search']}%"); - // 余额变动场景 - $params['scene'] > -1 && $this->where('log.scene', '=', (int)$params['scene']); - // 充值方式 - $params['recharge_type'] > -1 && $this->where('log.recharge_type', '=', (int)$params['recharge_type']); - // 支付状态 - $params['pay_status'] > -1 && $this->where('log.pay_status', '=', (int)$params['pay_status']); - // 起始时间 - !empty($params['start_time']) && $this->where('log.create_time', '>=', strtotime($params['start_time'])); - // 截止时间 - !empty($params['end_time']) && $this->where('log.create_time', '<', strtotime($params['end_time']) + 86400); - } - -} \ No newline at end of file diff --git a/source/application/store/model/wxapp/Formid.php b/source/application/store/model/wxapp/Formid.php deleted file mode 100644 index b57c979..0000000 --- a/source/application/store/model/wxapp/Formid.php +++ /dev/null @@ -1,15 +0,0 @@ -where('room_name|anchor_name', 'like', "%{$search}%"); - return $this->where('is_delete', '=', 0) - ->order([ - 'is_top' => 'desc', - 'live_status' => 'asc', - 'create_time' => 'desc' - ]) - ->paginate(15, false, [ - 'query' => \request()->request() - ]); - } - - /** - * 设置直播间置顶状态 - * @param $isTop - * @return false|int - */ - public function setIsTop($isTop) - { - return $this->save(['is_top' => (int)$isTop]); - } - - /** - * 刷新直播间列表(同步微信api) - * 每次拉取上限100条数据 - * @throws BaseException - * @throws \think\exception\DbException - * @throws \Exception - */ - public function refreshLiveList() - { - // 获取微信api最新直播间列表信息 - $originRoomList = $this->getOriginRoomList(); - // 获取微信直播间的房间id集 - $originRoomIds = $this->getOriginRoomIds($originRoomList); - // 已存储的所有房间id集 - $localRoomIds = $this->getLocalRoomIds(); - // 同步新增直播间 - $this->refreshLiveNew($localRoomIds, $originRoomIds, $originRoomList); - // 同步删除直播间 - $this->refreshLiveRemove($localRoomIds, $originRoomIds); - // 同步更新直播间 - $this->refreshLiveUpdate($localRoomIds, $originRoomIds, $originRoomList); - return true; - } - - /** - * 获取微信api最新直播间列表信息 - * @return array - * @throws BaseException - * @throws \think\Exception - * @throws \think\exception\DbException - */ - private function getOriginRoomList() - { - // 小程序配置信息 - $wxConfig = WxappModel::getWxappCache(); - // 请求api数据 - $LiveRoomApi = new LiveRoomApi($wxConfig['app_id'], $wxConfig['app_secret']); - $response = $LiveRoomApi->getLiveRoomList(); - if ($response === false) { - throw new BaseException(['msg' => '直播房间列表api请求失败:' . $LiveRoomApi->getError()]); - } - // 格式化返回的列表数据 - $originRoomList = []; - foreach ($response['room_info'] as $item) { - $originRoomList[$item['roomid']] = $item; - } - return $originRoomList; - } - - /** - * 获取微信直播间的房间id集 - * @param $originRoomList - * @return array - */ - private function getOriginRoomIds($originRoomList) - { - $originRoomIds = []; - foreach ($originRoomList as $item) { - $originRoomIds[] = $item['roomid']; - } - return $originRoomIds; - } - - /** - * 获取数据库中已存在的roomid - * @return array - */ - private function getLocalRoomIds() - { - return $this->where('is_delete', '=', 0)->column('room_id', 'id'); - } - - /** - * 同步新增直播间 - * @param array $localRoomIds 本地直播间id集 - * @param array $originRoomIds 最新直播间id集 - * @param array $originRoomList 最新直播间列表 - * @return array|bool|false - * @throws \Exception - */ - private function refreshLiveNew($localRoomIds, $originRoomIds, $originRoomList) - { - // 需要新增的直播间ID - $newLiveRoomIds = array_values(array_diff($originRoomIds, $localRoomIds)); - if (empty($newLiveRoomIds)) return true; - // 整理新增数据 - $saveData = []; - foreach ($newLiveRoomIds as $roomId) { - $item = $originRoomList[$roomId]; - $saveData[] = [ - 'room_id' => $roomId, - 'room_name' => $item['name'], - 'cover_img' => $item['cover_img'], - 'share_img' => $item['share_img'], - 'anchor_name' => $item['anchor_name'], - 'start_time' => $item['start_time'], - 'end_time' => $item['end_time'], - 'live_status' => $item['live_status'], - 'wxapp_id' => self::$wxapp_id, - ]; - } - // 批量新增直播间 - return $this->isUpdate(false)->saveAll($saveData, false); - } - - /** - * 同步更新直播间 - * @param array $localRoomIds 本地直播间id集 - * @param array $originRoomIds 最新直播间id集 - * @param array $originRoomList 最新直播间列表 - * @return array|bool|false - * @throws \Exception - */ - private function refreshLiveUpdate($localRoomIds, $originRoomIds, $originRoomList) - { - // 需要新增的直播间ID - $updatedLiveRoomIds = array_values(array_intersect($originRoomIds, $localRoomIds)); - if (empty($updatedLiveRoomIds)) return true; - // 根据直播间id获取主键id - $idArr = $this->getLocalIdsByRoomIds($localRoomIds); - // 整理新增数据 - $saveData = []; - foreach ($updatedLiveRoomIds as $roomId) { - $item = $originRoomList[$roomId]; - $saveData[] = [ - 'id' => $idArr[$roomId], - 'room_id' => $roomId, - 'room_name' => $item['name'], - 'cover_img' => $item['cover_img'], - 'share_img' => $item['share_img'], - 'anchor_name' => $item['anchor_name'], - 'start_time' => $item['start_time'], - 'end_time' => $item['end_time'], - 'live_status' => $item['live_status'], - 'wxapp_id' => self::$wxapp_id, - ]; - } - // 批量新增直播间 - return $this->isUpdate(true)->saveAll($saveData); - } - - /** - * 同步删除直播间 - * @param array $localRoomIds 本地直播间id集 - * @param array $originRoomIds 最新直播间id集 - * @return array|bool|false - * @throws \Exception - */ - private function refreshLiveRemove($localRoomIds, $originRoomIds) - { - // 需要删除的直播间ID - $removedLiveRoomIds = array_values(array_diff($localRoomIds, $originRoomIds)); - if (empty($removedLiveRoomIds)) return true; - // 根据直播间id获取主键id - $removedIds = $this->getLocalIdsByRoomIds($localRoomIds, $removedLiveRoomIds); - // 批量删除直播间 - return self::destroy(array_values($removedIds)); - } - - /** - * 根据直播间id获取主键id - * @param array $localRoomIds - * @param array $searchRoomIds - * @return array - */ - private function getLocalIdsByRoomIds($localRoomIds, $searchRoomIds = []) - { - $data = []; - foreach ($localRoomIds as $id => $roomId) { - if (empty($searchRoomIds) || in_array($roomId, $searchRoomIds)) { - $data[$roomId] = $id; - } - } - return $data; - } - -} \ No newline at end of file diff --git a/source/application/store/service/Auth.php b/source/application/store/service/Auth.php deleted file mode 100644 index c2a58c2..0000000 --- a/source/application/store/service/Auth.php +++ /dev/null @@ -1,173 +0,0 @@ -store = Session::get('yoshop_store'); - // 当前用户信息 - if (!empty($this->store)) { - $this->user = User::detail($this->store['user']['store_user_id']); - } - } - - /** - * 私有化克隆方法 - */ - private function __clone() - { - } - - /** - * 验证指定url是否有访问权限 - * @param string|array $url - * @param bool $strict 严格模式(必须全部通过才返回true) - * @return bool - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - */ - public function checkPrivilege($url, $strict = true) - { - if (!is_array($url)): - return $this->checkAccess($url); - else: - foreach ($url as $val): - if ($strict && !$this->checkAccess($val)) { - return false; - } - if (!$strict && $this->checkAccess($val)) { - return true; - } - endforeach; - endif; - return true; - } - - /** - * 验证url的权限 - * @param string $url - * @return bool - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - */ - private function checkAccess($url) - { - // 超级管理员无需验证 - if (!empty($this->user) && $this->user['is_super']) { - return true; - } - // 验证当前请求是否在白名单 - if (in_array($url, $this->allowAllAction)) { - return true; - } - // 通配符支持 - foreach ($this->allowAllAction as $action) { - if (strpos($action, '*') !== false - && preg_match('/^' . str_replace('/', '\/', $action) . '/', $url) - ) { - return true; - } - } - // 获取当前用户的权限url列表 - if (!in_array($url, $this->getAccessUrls())) { - return false; - } - return true; - } - - /** - * 获取当前用户的权限url列表 - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - */ - private function getAccessUrls() - { - if (empty($this->accessUrls)) { - // 获取当前用户的角色集 - $roleIds = UserRole::getRoleIds($this->user['store_user_id']); - // 根据已分配的权限 - $accessIds = RoleAccess::getAccessIds($roleIds); - // 获取当前角色所有权限链接 - $this->accessUrls = Access::getAccessUrls($accessIds); - } - return $this->accessUrls; - } - -} \ No newline at end of file diff --git a/source/application/store/service/Menus.php b/source/application/store/service/Menus.php deleted file mode 100644 index 94db761..0000000 --- a/source/application/store/service/Menus.php +++ /dev/null @@ -1,213 +0,0 @@ -auth = Auth::getInstance(); - } - - /** - * 私有化克隆方法 - */ - private function __clone() - { - } - - /** - * 后台菜单配置 - * @param $routeUri - * @param $group - * @return array|mixed - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - */ - public function getMenus($routeUri, $group) - { - // 菜单列表数据 - $menus = Config::get('menus'); - $this->first($menus, $routeUri, $group); -// pre($menus); - return $menus; - } - - /** - * 一级菜单 - * @param $menus - * @param $routeUri - * @param $group - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - */ - private function first(&$menus, $routeUri, $group) - { - foreach ($menus as $key => &$first) : - // 一级菜单索引url - $indexData = $this->getMenusIndexUrls($first, 1); - // 权限验证 - $first['index'] = $this->getAuthUrl($indexData); - if ($first['index'] === false) { - unset($menus[$key]); - continue; - } - // 菜单聚焦 - $first['active'] = $key === $group; - // 遍历:二级菜单 - if (isset($first['submenu'])) { - $this->second($first['submenu'], $routeUri); - } - endforeach; - } - - /** - * 二级菜单 - * @param array $menus - * @param $routeUri - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - */ - public function second(&$menus, $routeUri) - { - foreach ($menus as $key => &$second) : - // 二级菜单索引url - $indexData = $this->getMenusIndexUrls($second, 2); - // 权限验证 - $second['index'] = $this->getAuthUrl($indexData); - if ($second['index'] === false) { - unset($menus[$key]); - continue; - } - // 二级菜单所有uri - $secondUris = []; - // 遍历:三级菜单 - if (isset($second['submenu'])) { - $this->third($second['submenu'], $routeUri, $secondUris); - } else { - if (isset($second['uris'])) - $secondUris = array_merge($secondUris, $second['uris']); - else - $secondUris[] = $second['index']; - } - // 二级菜单:active - !isset($second['active']) && $second['active'] = in_array($routeUri, $secondUris); - endforeach; - // 删除空数组 - $menus = array_filter($menus); - } - - /** - * 三级菜单 - * @param array $menus - * @param $routeUri - * @param $secondUris - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - */ - private function third(&$menus, $routeUri, &$secondUris) - { - foreach ($menus as $key => &$third): - // 三级菜单索引url - $indexData = $this->getMenusIndexUrls($third, 3); - // 权限验证 - $third['index'] = $this->getAuthUrl($indexData); - if ($third['index'] === false) { - unset($menus[$key]); - continue; - } - // 三级菜单所有uri - $thirdUris = []; - if (isset($third['uris'])) { - $secondUris = array_merge($secondUris, $third['uris']); - $thirdUris = array_merge($thirdUris, $third['uris']); - } else { - $secondUris[] = $third['index']; - $thirdUris[] = $third['index']; - } - $third['active'] = in_array($routeUri, $thirdUris); - endforeach; - } - - /** - * 获取指定菜单下的所有索引url - * @param array $menus - * @param int $level - * @return array|null - */ - private function getMenusIndexUrls(&$menus, $level = 1) - { -// // 三级 -// if ($level === 3) { -// return isset($menus['index']) ? [$menus['index']] : null; -// } - // 判断是否存在url - if (!isset($menus['index']) && !isset($menus['submenu'])) { - return null; - } - $data = []; - if (isset($menus['index']) && !empty($menus['index'])) { - $data[] = $menus['index']; - } - if (isset($menus['submenu']) && !empty($menus['submenu'])) { - foreach ($menus['submenu'] as $submenu) { - $submenuIndex = $this->getMenusIndexUrls($submenu, ++$level); - !is_null($submenuIndex) && $data = array_merge($data, $submenuIndex); - } - } - return array_unique($data); - } - - /** - * 取出通过权限验证urk作为index - * @param $urls - * @return bool - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\ModelNotFoundException - * @throws \think\exception\DbException - */ - private function getAuthUrl($urls) - { - // 取出通过权限验证urk作为index - foreach ($urls as $url) { - if ($this->auth->checkPrivilege($url)) return $url; - } - return false; - } - -} \ No newline at end of file diff --git a/source/application/store/service/wxapp/Message.php b/source/application/store/service/wxapp/Message.php deleted file mode 100644 index f46b9ef..0000000 --- a/source/application/store/service/wxapp/Message.php +++ /dev/null @@ -1,115 +0,0 @@ -WxTplMsg = new WxTplMsg($config['app_id'], $config['app_secret']); - } - - /** - * 执行发送 - * @param $data - * @return bool - * @throws \app\common\exception\BaseException - * @throws \think\exception\DbException - */ - public function send($data) - { - // 用户id集 - $userIdsArr = !strstr($data['user_id'], self::SEPARATOR) ? [$data['user_id']] - : explode(self::SEPARATOR, $data['user_id']); - // 批量发送 - foreach ($userIdsArr as $userId) { - $this->sendTemplateMessage($userId, $data); - } - return true; - } - - /** - * 发送模板消息 - * @param $userId - * @param $data - * @return bool - * @throws \app\common\exception\BaseException - * @throws \think\exception\DbException - */ - private function sendTemplateMessage($userId, $data) - { - // 获取formid - if (!$formId = FormIdService::getAvailableFormId($userId)) { - $this->recordState("用户[ID:$userId] 无可用formid,无法发送模板消息!"); - return false; - } - // 获取用户信息 - $user = UserModel::detail($data['user_id']); - // 构建模板消息参数 - $params = [ - 'touser' => $user['open_id'], - 'template_id' => $data['template_id'], - 'page' => $data['page'], - 'form_id' => $formId['form_id'], - 'data' => [] - ]; - // 格式化模板内容 - foreach (array_filter($data['content']) as $key => $item) { - $params['data']['keyword' . ($key + 1)] = $item; - } - // 请求微信api:发送模板消息 - if ($status = $this->WxTplMsg->sendTemplateMessage($params)) { - $this->recordState("用户[ID:$userId] 发送成功!"); - } - // 标记formid已使用 - FormIdService::setIsUsed($formId['id']); - return $status; - } - - /** - * 获取状态集 - * @return array - */ - public function getStateSet() - { - return $this->stateSet; - } - - /** - * 记录状态集 - * @param $content - */ - private function recordState($content) - { - $this->stateSet[] = $content; - } - -} \ No newline at end of file diff --git a/source/application/store/service/wxapp/SubMsg.php b/source/application/store/service/wxapp/SubMsg.php deleted file mode 100644 index 92a4624..0000000 --- a/source/application/store/service/wxapp/SubMsg.php +++ /dev/null @@ -1,194 +0,0 @@ -WxSubMsg = new WxSubMsg($wxConfig['app_id'], $wxConfig['app_secret']); - } - - /** - * 一键添加订阅消息 - * @return bool - * @throws BaseException - * @throws \think\exception\DbException - */ - public function shuttle() - { - // 拉取我的模板列表 - $myList = $this->getMyTemplateList(); - // 筛选出未添加的模板 - $addedList = $this->getNotAddedTemplates($myList); - // 批量添加订阅消息模板 - $newList = $this->onBatchAdd($addedList); - // 全部模板列表 - $tplList = array_merge($newList, $myList); - // 保存全部模板id - return $this->saveAll($tplList); - - } - - /** - * 保存全部模板id - * @param $tplList - * @return bool - * @throws \think\exception\DbException - */ - private function saveAll($tplList) - { - // 整理模板id - $data = SettingModel::getItem('submsg'); - foreach ($data as &$group) { - foreach ($group as &$item) { - if (!isset($item['title'])) continue; - $tpl = helper::arraySearch($tplList, 'title', $item['title']); - $tpl != false && $item['template_id'] = $tpl['priTmplId']; - } - } - // 保存数据 - return (new SettingModel)->edit('submsg', $data); - } - - /** - * 批量添加订阅消息模板 - * [并且记录返回的priTmplId] - * @param $newList - * @return array - * @throws BaseException - */ - private function onBatchAdd($newList) - { - foreach ($newList as &$item) { - // 请求微信api, 添加模板记录 - $response = $this->WxSubMsg->addTemplate($item['tid'], $item['kidList'], $item['sceneDesc']); - if ($response === false) { - throw new BaseException(['msg' => "添加模板[{$item['sceneDesc']}]失败:" . $this->WxSubMsg->getError()]); - } - // 记录template_id - $item['priTmplId'] = $response['priTmplId']; - } - return $newList; - } - - /** - * 筛选出未添加的模板 - * @param $myList - * @return array - */ - private function getNotAddedTemplates($myList) - { - // 所有订阅消息模板列表 - $templateLists = $this->getTemplates(); - if (empty($myList)) return $templateLists; - // 整理未添加的 - $data = []; - foreach ($templateLists as $item) { - if (helper::arraySearch($myList, 'title', $item['title']) === false) { - $data[] = $item; - } - } - return $data; - } - - /** - * 所有订阅消息模板列表 - * @return array - */ - private function getTemplates() - { - return [ - // 支付成功通知 - [ - 'tid' => 9344, - 'title' => '新订单提醒', - 'kidList' => [1, 2, 4, 3], - 'sceneDesc' => '新订单提醒', - ], - // 订单发货通知 - [ - 'tid' => 855, - 'title' => '订单发货通知', - 'kidList' => [1, 2, 12, 11, 17], - 'sceneDesc' => '订单发货通知', - ], - // 售后状态通知 - [ - 'tid' => 5049, - 'title' => '售后状态通知', - 'kidList' => [1, 6, 2, 3, 4], - 'sceneDesc' => '售后状态通知', - ], - // 拼团进度通知 - [ - 'tid' => 5008, - 'title' => '拼团进度通知', - 'kidList' => [1, 5, 7, 3, 6], - 'sceneDesc' => '拼团进度通知', - ], - // 分销商入驻审核通知 - [ - 'tid' => 4050, - 'title' => '代理商入驻审核通知', - 'kidList' => [1, 2, 3, 4], - 'sceneDesc' => '分销商入驻审核通知', - ], - // 提现成功通知 - [ - 'tid' => 2001, - 'title' => '提现成功通知', - 'kidList' => [1, 3, 4], - 'sceneDesc' => '提现成功通知', - ], - // 提现失败通知 - [ - 'tid' => 3173, - 'title' => '提现失败通知', - 'kidList' => [1, 3, 4], - 'sceneDesc' => '提现失败通知', - ], - - ]; - } - - /** - * 拉取我的模板列表 - * @return mixed - * @throws BaseException - */ - private function getMyTemplateList() - { - $response = $this->WxSubMsg->getTemplateList(); - if ($response === false) { - throw new BaseException(['msg' => '拉取模板列表失败:' . $this->WxSubMsg->getError()]); - } - return $response['data']; - } - -} \ No newline at end of file diff --git a/source/application/store/view/apps/dealer/apply/index.php b/source/application/store/view/apps/dealer/apply/index.php deleted file mode 100644 index 7d246aa..0000000 --- a/source/application/store/view/apps/dealer/apply/index.php +++ /dev/null @@ -1,209 +0,0 @@ -
| - - | -商品ID | -商品图片 | -商品名称 | -商品分类 | -添加时间 | -|||
|---|---|---|---|---|---|---|---|---|
| - - | -= $item['goods_id'] ?> | -
-
- |
-
- = $item['goods_name'] ?> - |
- = $item['category']['name'] ?> | -= $item['create_time'] ?> | -|||
| 暂无记录 | -||||||||
| - - | -商品ID | -商品图片 | -商品名称 | -商品分类 | -成团人数 | -成团有效时长 | -添加时间 | -
|---|---|---|---|---|---|---|---|
| - - | -= $item['goods_id'] ?> | -
-
- |
-
- = $item['goods_name'] ?> - |
- = $item['category']['name'] ?> | -= $item['people'] ?> | -= $item['group_time'] ?>小时 | -= $item['create_time'] ?> | -
| 暂无记录 | -|||||||
| - - | -门店ID | -门店logo | -门店名称 | -自提核销 | -门店状态 | -创建时间 | -
|---|---|---|---|---|---|---|
| - - | -= $item['shop_id'] ?> | -
-
- |
- = $item['shop_name'] ?> | -- - = $item['is_check'] ? '支持' : '不支持' ?> - - | -- - = $item['status'] ? '启用' : '禁用' ?> - - | -= $item['create_time'] ?> | -
| 暂无记录 | -||||||
| - - | -微信头像 | -微信昵称 | -累积消费金额 | -性别 | -国家 | -省份 | -城市 | -注册时间 | -
|---|---|---|---|---|---|---|---|---|
| - - | -
-
- |
- = $item['nickName'] ?> | -= $item['money'] ?> | -= $item['gender'] ?> | -= $item['country'] ?: '--' ?> | -= $item['province'] ?: '--' ?> | -= $item['city'] ?: '--' ?> | -= $item['create_time'] ?> | -
| 暂无记录 | -||||||||
1、支持地址 精确/模糊 查询;
-2、支持POI点坐标显示;
-3、坐标鼠标跟随显示;
-在搜索框搜索关键词后,地图上会显示相应poi点,同时左侧显示对应该点的信息,点击某点或某信息,右上角会显示相应该点的坐标和地址。
-