Browse Source

移除未使用的STORE

master
453530270@qq.com 3 years ago
parent
commit
4d79828f29
  1. BIN
      bak_/btgym.xingtongworld.com_ka4TLL.tar.gz
  2. 20
      source/application/store/common.php
  3. 33
      source/application/store/config.php
  4. 229
      source/application/store/controller/Controller.php
  5. 144
      source/application/store/controller/Goods.php
  6. 32
      source/application/store/controller/Index.php
  7. 147
      source/application/store/controller/Order.php
  8. 45
      source/application/store/controller/Passport.php
  9. 132
      source/application/store/controller/Setting.php
  10. 90
      source/application/store/controller/Shop.php
  11. 88
      source/application/store/controller/Upload.php
  12. 61
      source/application/store/controller/User.php
  13. 33
      source/application/store/controller/Wxapp.php
  14. 44
      source/application/store/controller/apps/dealer/Apply.php
  15. 29
      source/application/store/controller/apps/dealer/Order.php
  16. 59
      source/application/store/controller/apps/dealer/Setting.php
  17. 90
      source/application/store/controller/apps/dealer/User.php
  18. 79
      source/application/store/controller/apps/dealer/Withdraw.php
  19. 60
      source/application/store/controller/apps/live/Room.php
  20. 42
      source/application/store/controller/apps/sharing/Active.php
  21. 82
      source/application/store/controller/apps/sharing/Category.php
  22. 62
      source/application/store/controller/apps/sharing/Comment.php
  23. 178
      source/application/store/controller/apps/sharing/Goods.php
  24. 87
      source/application/store/controller/apps/sharing/Order.php
  25. 33
      source/application/store/controller/apps/sharing/Setting.php
  26. 115
      source/application/store/controller/apps/sharing/order/Operate.php
  27. 82
      source/application/store/controller/apps/sharing/order/Refund.php
  28. 85
      source/application/store/controller/content/Article.php
  29. 88
      source/application/store/controller/content/Files.php
  30. 78
      source/application/store/controller/content/article/Category.php
  31. 81
      source/application/store/controller/content/files/Group.php
  32. 44
      source/application/store/controller/data/Goods.php
  33. 38
      source/application/store/controller/data/Shop.php
  34. 43
      source/application/store/controller/data/User.php
  35. 44
      source/application/store/controller/data/sharing/Goods.php
  36. 83
      source/application/store/controller/goods/Category.php
  37. 62
      source/application/store/controller/goods/Comment.php
  38. 93
      source/application/store/controller/goods/Spec.php
  39. 39
      source/application/store/controller/market/Basic.php
  40. 108
      source/application/store/controller/market/Coupon.php
  41. 47
      source/application/store/controller/market/Push.php
  42. 28
      source/application/store/controller/market/Recharge.php
  43. 95
      source/application/store/controller/market/recharge/Plan.php
  44. 100
      source/application/store/controller/order/Operate.php
  45. 82
      source/application/store/controller/order/Refund.php
  46. 79
      source/application/store/controller/setting/Address.php
  47. 137
      source/application/store/controller/setting/Cache.php
  48. 92
      source/application/store/controller/setting/Delivery.php
  49. 89
      source/application/store/controller/setting/Express.php
  50. 19
      source/application/store/controller/setting/Help.php
  51. 99
      source/application/store/controller/setting/Printer.php
  52. 171
      source/application/store/controller/setting/Science.php
  53. 91
      source/application/store/controller/shop/Clerk.php
  54. 33
      source/application/store/controller/shop/Order.php
  55. 100
      source/application/store/controller/store/Role.php
  56. 115
      source/application/store/controller/store/User.php
  57. 104
      source/application/store/controller/upload/Library.php
  58. 31
      source/application/store/controller/user/Balance.php
  59. 31
      source/application/store/controller/user/Recharge.php
  60. 82
      source/application/store/controller/wxapp/Help.php
  61. 145
      source/application/store/controller/wxapp/Page.php
  62. 50
      source/application/store/controller/wxapp/Submsg.php
  63. 668
      source/application/store/extra/menus.php
  64. 88
      source/application/store/model/Article.php
  65. 73
      source/application/store/model/Category.php
  66. 32
      source/application/store/model/Comment.php
  67. 14
      source/application/store/model/CommentImage.php
  68. 66
      source/application/store/model/Coupon.php
  69. 124
      source/application/store/model/Delivery.php
  70. 55
      source/application/store/model/DeliveryRule.php
  71. 45
      source/application/store/model/Express.php
  72. 153
      source/application/store/model/Goods.php
  73. 14
      source/application/store/model/GoodsImage.php
  74. 70
      source/application/store/model/GoodsSku.php
  75. 14
      source/application/store/model/GoodsSpecRel.php
  76. 476
      source/application/store/model/Order.php
  77. 15
      source/application/store/model/OrderAddress.php
  78. 15
      source/application/store/model/OrderGoods.php
  79. 134
      source/application/store/model/OrderRefund.php
  80. 33
      source/application/store/model/OrderRefundAddress.php
  81. 10
      source/application/store/model/OrderRefundImage.php
  82. 41
      source/application/store/model/Printer.php
  83. 15
      source/application/store/model/Region.php
  84. 72
      source/application/store/model/ReturnAddress.php
  85. 76
      source/application/store/model/Setting.php
  86. 35
      source/application/store/model/Spec.php
  87. 38
      source/application/store/model/SpecValue.php
  88. 191
      source/application/store/model/Store.php
  89. 86
      source/application/store/model/StoreUser.php
  90. 91
      source/application/store/model/UploadFile.php
  91. 38
      source/application/store/model/UploadFileUsed.php
  92. 66
      source/application/store/model/UploadGroup.php
  93. 97
      source/application/store/model/User.php
  94. 15
      source/application/store/model/UserAddress.php
  95. 28
      source/application/store/model/UserCoupon.php
  96. 77
      source/application/store/model/Wxapp.php
  97. 24
      source/application/store/model/WxappCategory.php
  98. 43
      source/application/store/model/WxappHelp.php
  99. 26
      source/application/store/model/WxappNavbar.php
  100. 87
      source/application/store/model/WxappPage.php

BIN
bak_/btgym.xingtongworld.com_ka4TLL.tar.gz

Binary file not shown.

20
source/application/store/common.php

@ -1,20 +0,0 @@
<?php
// 应用公共函数库文件
use app\store\service\Auth;
/**
* 验证指定url是否有访问权限
* @param string|array $url
* @param bool $strict 严格模式
* @return bool
*/
function checkPrivilege($url, $strict = true)
{
try {
return Auth::getInstance()->checkPrivilege($url, $strict);
} catch (\Exception $e) {
return false;
}
}

33
source/application/store/config.php

@ -1,33 +0,0 @@
<?php
return [
// 默认输出类型
'default_return_type' => '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' => '}}',
],
];

229
source/application/store/controller/Controller.php

@ -1,229 +0,0 @@
<?php
namespace app\store\controller;
use think\Request;
use think\Session;
use app\store\service\Auth;
use app\store\service\Menus;
use app\store\model\Setting;
use app\common\exception\BaseException;
/**
* 商户后台控制器基类
* Class BaseController
* @package app\store\controller
*/
class Controller extends \think\Controller
{
/** @var array $store 商家登录信息 */
protected $store;
/** @var string $route 当前控制器名称 */
protected $controller = '';
/** @var string $route 当前方法名称 */
protected $action = '';
/** @var string $route 当前路由uri */
protected $routeUri = '';
/** @var string $route 当前路由:分组名称 */
protected $group = '';
/** @var array $allowAllAction 登录验证白名单 */
protected $allowAllAction = [
// 登录页面
'passport/login',
];
/* @var array $notLayoutAction 无需全局layout */
protected $notLayoutAction = [
// 登录页面
'passport/login',
];
/**
* 后台初始化
* @throws BaseException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function _initialize()
{
// 商家登录信息
$this->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);
}
}

144
source/application/store/controller/Goods.php

@ -1,144 +0,0 @@
<?php
namespace app\store\controller;
use app\store\model\Category;
use app\store\model\Delivery;
use app\store\model\Goods as GoodsModel;
/**
* 商品管理控制器
* Class Goods
* @package app\store\controller
*/
class Goods extends Controller
{
/**
* 商品列表(出售中)
* @param null $goods_status
* @param null $category_id
* @param string $goods_name
* @return mixed
* @throws \think\exception\DbException
*/
public function index($goods_status = null, $category_id = null, $goods_name = '')
{
// 商品分类
$catgory = Category::getCacheTree();
// 商品列表
$model = new GoodsModel;
$list = $model->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('删除成功');
}
}

32
source/application/store/controller/Index.php

@ -1,32 +0,0 @@
<?php
namespace app\store\controller;
use app\store\model\Store as StoreModel;
/**
* 后台首页
* Class Index
* @package app\store\controller
*/
class Index extends Controller
{
/**
* 后台首页
* @return mixed
* @throws \think\Exception
* @throws \think\exception\DbException
*/
public function index()
{
// 当前用户菜单url
$menus = $this->menus();
$url = current(array_values($menus))['index'];
if ($url !== 'index/index') {
$this->redirect($url);
}
$model = new StoreModel;
return $this->fetch('index', ['data' => $model->getHomeData()]);
}
}

147
source/application/store/controller/Order.php

@ -1,147 +0,0 @@
<?php
namespace app\store\controller;
use app\store\model\Order as OrderModel;
use app\store\model\Express as ExpressModel;
use app\store\model\store\shop\Clerk as ShopClerkModel;
use app\store\model\store\Shop as ShopModel;
/**
* 订单管理
* Class Order
* @package app\store\controller
*/
class Order extends Controller
{
/**
* 待发货订单列表
* @return mixed
* @throws \think\exception\DbException
*/
public function delivery_list()
{
return $this->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'));
}
}

45
source/application/store/controller/Passport.php

@ -1,45 +0,0 @@
<?php
namespace app\store\controller;
use app\store\model\store\User as StoreUser;
use think\Session;
/**
* 商户认证
* Class Passport
* @package app\store\controller
*/
class Passport extends Controller
{
/**
* 商户后台登录
* @return array|mixed
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function login()
{
if ($this->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');
}
}

132
source/application/store/controller/Setting.php

@ -1,132 +0,0 @@
<?php
namespace app\store\controller;
use app\store\model\Printer as PrinterModel;
use app\store\model\Setting as SettingModel;
use app\common\library\sms\Driver as SmsDriver;
/**
* 系统设置
* Class Setting
* @package app\store\controller
*/
class Setting extends Controller
{
/**
* 商城设置
* @return mixed
* @throws \think\exception\DbException
*/
public function store()
{
return $this->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() ?: '操作失败');
}
}

90
source/application/store/controller/Shop.php

@ -1,90 +0,0 @@
<?php
namespace app\store\controller;
use app\store\model\store\Shop as ShopModel;
/**
* 门店管理
* Class Shop
* @package app\store\controller\store
*/
class Shop extends Controller
{
/**
* 门店列表
* @return mixed
* @throws \think\exception\DbException
*/
public function index()
{
$model = new ShopModel;
$list = $model->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('删除成功');
}
}

88
source/application/store/controller/Upload.php

@ -1,88 +0,0 @@
<?php
namespace app\store\controller;
use app\store\model\UploadFile;
use app\common\library\storage\Driver as StorageDriver;
use app\store\model\Setting as SettingModel;
/**
* 文件库管理
* Class Upload
* @package app\store\controller
*/
class Upload extends Controller
{
private $config;
/**
* 构造方法
* @throws \app\common\exception\BaseException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function _initialize()
{
parent::_initialize();
// 存储配置信息
$this->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;
}
}

61
source/application/store/controller/User.php

@ -1,61 +0,0 @@
<?php
namespace app\store\controller;
use app\store\model\User as UserModel;
/**
* 用户管理
* Class User
* @package app\store\controller
*/
class User extends Controller
{
/**
* 用户列表
* @param string $nickName
* @param null $gender
* @return mixed
* @throws \think\exception\DbException
*/
public function index($nickName = '', $gender = null)
{
$model = new UserModel;
$list = $model->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() ?: '操作失败');
}
}

33
source/application/store/controller/Wxapp.php

@ -1,33 +0,0 @@
<?php
namespace app\store\controller;
use app\store\model\Wxapp as WxappModel;
/**
* 小程序管理
* Class Wxapp
* @package app\store\controller
*/
class Wxapp extends Controller
{
/**
* 小程序设置
* @return mixed
* @throws \think\exception\DbException
*/
public function setting()
{
// 当前小程序信息
$model = WxappModel::detail();
if (!$this->request->isAjax()) {
return $this->fetch('setting', compact('model'));
}
// 更新小程序设置
if ($model->edit($this->postData('wxapp'))) {
return $this->renderSuccess('更新成功');
}
return $this->renderError($model->getError() ?: '更新失败');
}
}

44
source/application/store/controller/apps/dealer/Apply.php

@ -1,44 +0,0 @@
<?php
namespace app\store\controller\apps\dealer;
use app\store\controller\Controller;
use app\store\model\dealer\Apply as ApplyModel;
/**
* 分销商申请
* Class Setting
* @package app\store\controller\apps\dealer
*/
class Apply extends Controller
{
/**
* 分销商申请列表
* @param string $search
* @return mixed
* @throws \think\exception\DbException
*/
public function index($search = '')
{
$model = new ApplyModel;
return $this->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() ?: '操作失败');
}
}

29
source/application/store/controller/apps/dealer/Order.php

@ -1,29 +0,0 @@
<?php
namespace app\store\controller\apps\dealer;
use app\store\controller\Controller;
use app\store\model\dealer\Order as OrderModel;
/**
* 分销订单
* Class Order
* @package app\store\controller\apps\dealer
*/
class Order extends Controller
{
/**
* 分销订单列表
* @param null $user_id
* @param int $is_settled
* @return mixed
* @throws \think\exception\DbException
*/
public function index($user_id = null, $is_settled = -1)
{
$model = new OrderModel;
$list = $model->getList($user_id, $is_settled);
return $this->fetch('index', compact('list'));
}
}

59
source/application/store/controller/apps/dealer/Setting.php

@ -1,59 +0,0 @@
<?php
namespace app\store\controller\apps\dealer;
use app\store\controller\Controller;
use app\store\model\dealer\Setting as SettingModel;
use app\store\model\Goods as GoodsModel;
/**
* 分销设置
* Class Setting
* @package app\store\controller\apps\dealer
*/
class Setting extends Controller
{
/**
* 分销设置
* @return array|bool|mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function index()
{
if (!$this->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() ?: '更新失败');
}
}

90
source/application/store/controller/apps/dealer/User.php

@ -1,90 +0,0 @@
<?php
namespace app\store\controller\apps\dealer;
use app\store\controller\Controller;
use app\common\service\qrcode\Poster;
use app\store\model\dealer\User as UserModel;
use app\store\model\dealer\Referee as RefereeModel;
use app\store\model\dealer\Setting as SettingModel;
/**
* 分销商管理
* Class User
* @package app\store\controller\apps\dealer
*/
class User extends Controller
{
/**
* 构造方法
* @throws \app\common\exception\BaseException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function _initialize()
{
parent::_initialize();
}
/**
* 分销商用户列表
* @param string $search
* @return mixed
* @throws \think\exception\DbException
*/
public function index($search = '')
{
$model = new UserModel;
return $this->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());
}
}

79
source/application/store/controller/apps/dealer/Withdraw.php

@ -1,79 +0,0 @@
<?php
namespace app\store\controller\apps\dealer;
use app\store\controller\Controller;
use app\store\model\dealer\Withdraw as WithdrawModel;
/**
* 分销商提现申请
* Class Setting
* @package app\store\controller\apps\dealer
*/
class Withdraw extends Controller
{
/**
* 提现记录列表
* @param int $user_id
* @param int $apply_status
* @param int $pay_type
* @param string $search
* @return mixed
* @throws \think\exception\DbException
*/
public function index($user_id = null, $apply_status = -1, $pay_type = -1, $search = '')
{
$model = new WithdrawModel;
return $this->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() ?: '操作失败');
}
}

60
source/application/store/controller/apps/live/Room.php

@ -1,60 +0,0 @@
<?php
namespace app\store\controller\apps\live;
use app\store\controller\Controller;
use app\store\model\wxapp\LiveRoom as LiveRoomModel;
/**
* 小程序直播间管理
* Class Room
* @package app\store\controller\apps\live
*/
class Room extends Controller
{
/**
* 直播间列表页
* @param string $search 检索词
* @return mixed
* @throws \think\exception\DbException
*/
public function index($search = '')
{
$model = new LiveRoomModel;
$list = $model->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('操作成功');
}
}

42
source/application/store/controller/apps/sharing/Active.php

@ -1,42 +0,0 @@
<?php
namespace app\store\controller\apps\sharing;
use app\store\controller\Controller;
use app\store\model\sharing\Active as ActiveModel;
use app\store\model\sharing\ActiveUsers as ActiveUsersModel;
/**
* 拼单管理控制器
* Class Active
* @package app\store\controller\apps\sharing
*/
class Active extends Controller
{
/**
* 拼单列表
* @param null $active_id
* @return mixed
* @throws \think\exception\DbException
*/
public function index($active_id = null)
{
$model = new ActiveModel;
$list = $model->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'));
}
}

82
source/application/store/controller/apps/sharing/Category.php

@ -1,82 +0,0 @@
<?php
namespace app\store\controller\apps\sharing;
use app\store\controller\Controller;
use app\store\model\sharing\Category as CategoryModel;
/**
* 拼团商品分类
* Class Category
* @package app\store\controller\apps\sharing
*/
class Category extends Controller
{
/**
* 商品分类列表
* @return mixed
*/
public function index()
{
$model = new CategoryModel;
$list = $model->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('删除成功');
}
}

62
source/application/store/controller/apps/sharing/Comment.php

@ -1,62 +0,0 @@
<?php
namespace app\store\controller\apps\sharing;
use app\store\controller\Controller;
use app\store\model\sharing\Comment as CommentModel;
/**
* 商品评价管理
* Class Comment
* @package app\store\controller\apps\sharing
*/
class Comment extends Controller
{
/**
* 评价列表
* @return mixed
* @throws \think\exception\DbException
*/
public function index()
{
$model = new CommentModel;
$list = $model->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('删除成功');
}
}

178
source/application/store/controller/apps/sharing/Goods.php

@ -1,178 +0,0 @@
<?php
namespace app\store\controller\apps\sharing;
use app\store\controller\Controller;
use app\store\model\Delivery as DeliveryModel;
use app\store\model\sharing\Goods as GoodsModel;
use app\store\model\sharing\Category as CategoryModel;
/**
* 拼团商品管理控制器
* Class Goods
* @package app\store\controller\apps\sharing
*/
class Goods extends Controller
{
/**
* 商品列表(出售中)
* @param null $goods_status
* @param null $category_id
* @param string $goods_name
* @return mixed
* @throws \think\exception\DbException
*/
public function index($goods_status = null, $category_id = null, $goods_name = '')
{
// 商品分类
$catgory = CategoryModel::getCacheTree();
// 商品列表
$model = new GoodsModel;
$list = $model->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('删除成功');
}
}

87
source/application/store/controller/apps/sharing/Order.php

@ -1,87 +0,0 @@
<?php
namespace app\store\controller\apps\sharing;
use app\store\controller\Controller;
use app\store\model\Express as ExpressModel;
use app\store\model\store\Shop as ShopModel;
use app\store\model\sharing\Order as OrderModel;
use app\store\model\store\shop\Clerk as ShopClerkModel;
/**
* 订单管理
* Class Order
* @package app\store\controller
*/
class Order extends Controller
{
/**
* 全部订单列表
* @param string $dataType
* @return mixed
* @throws \think\exception\DbException
*/
public function index($dataType = 'all')
{
// 订单列表
$model = new OrderModel;
$list = $model->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() ?: '修改失败');
}
}

33
source/application/store/controller/apps/sharing/Setting.php

@ -1,33 +0,0 @@
<?php
namespace app\store\controller\apps\sharing;
use app\store\controller\Controller;
use app\store\model\sharing\Setting as SettingModel;
/**
* 拼团设置
* Class Setting
* @package app\store\controller\apps\dealer
*/
class Setting extends Controller
{
/**
* 拼团设置
* @return array|mixed
* @throws \think\exception\DbException
*/
public function index()
{
if (!$this->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() ?: '更新失败');
}
}

115
source/application/store/controller/apps/sharing/order/Operate.php

@ -1,115 +0,0 @@
<?php
namespace app\store\controller\apps\sharing\order;
use app\store\controller\Controller;
use app\store\model\sharing\Order as OrderModel;
use app\store\model\Express as ExpressModel;
/**
* 拼团订单操作控制器
* Class Operate
* @package app\store\controller\order
*/
class Operate extends Controller
{
/* @var OrderModel $model */
private $model;
/**
* 构造方法
* @throws \app\common\exception\BaseException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function _initialize()
{
parent::_initialize();
$this->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() ?: '核销失败');
}
}

82
source/application/store/controller/apps/sharing/order/Refund.php

@ -1,82 +0,0 @@
<?php
namespace app\store\controller\apps\sharing\order;
use app\store\controller\Controller;
use app\store\model\sharing\Order as OrderModel;
use app\store\model\sharing\OrderRefund as OrderRefundModel;
use app\store\model\ReturnAddress as ReturnAddressModel;
/**
* 售后管理
* Class Refund
* @package app\store\controller\order
*/
class Refund extends Controller
{
/**
* 帮助中心列表
* @return mixed
* @throws \think\exception\DbException
*/
public function index()
{
$model = new OrderRefundModel;
$list = $model->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() ?: '操作失败');
}
}

85
source/application/store/controller/content/Article.php

@ -1,85 +0,0 @@
<?php
namespace app\store\controller\content;
use app\store\controller\Controller;
use app\store\model\Article as ArticleModel;
use app\store\model\article\Category as CategoryModel;
/**
* 文章管理控制器
* Class article
* @package app\store\controller\content
*/
class Article extends Controller
{
/**
* 文章列表
* @return mixed
* @throws \think\exception\DbException
*/
public function index()
{
$model = new ArticleModel;
$list = $model->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('删除成功');
}
}

88
source/application/store/controller/content/Files.php

@ -1,88 +0,0 @@
<?php
namespace app\store\controller\content;
use app\store\controller\Controller;
use app\store\model\UploadFile as UploadFileModel;
/**
* 文件库管理
* Class Files
* @package app\store\controller
*/
class Files extends Controller
{
/**
* 文件列表
* @return mixed
* @throws \think\exception\DbException
*/
public function index()
{
$model = new UploadFileModel;
$list = $model->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('操作成功');
}
}

78
source/application/store/controller/content/article/Category.php

@ -1,78 +0,0 @@
<?php
namespace app\store\controller\content\article;
use app\store\controller\Controller;
use app\store\model\article\Category as CategoryModel;
/**
* 文章分类
* Class Category
* @package app\store\controller\content
*/
class Category extends Controller
{
/**
* 文章分类列表
* @return mixed
*/
public function index()
{
$model = new CategoryModel;
$list = $model->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('删除成功');
}
}

81
source/application/store/controller/content/files/Group.php

@ -1,81 +0,0 @@
<?php
namespace app\store\controller\content\files;
use app\store\controller\Controller;
use app\store\model\UploadGroup as GroupModel;
/**
* 文件分组
* Class Group
* @package app\store\controller\content
*/
class Group extends Controller
{
/**
* 文件分组列表
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function index()
{
$model = new GroupModel;
$list = $model->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('删除成功');
}
}

44
source/application/store/controller/data/Goods.php

@ -1,44 +0,0 @@
<?php
namespace app\store\controller\data;
use app\store\controller\Controller;
use app\store\model\Goods as GoodsModel;
/**
* 商品数据控制器
* Class Goods
* @package app\store\controller\data
*/
class Goods extends Controller
{
/* @var \app\store\model\Goods $model */
private $model;
/**
* 构造方法
* @throws \app\common\exception\BaseException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function _initialize()
{
parent::_initialize();
$this->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'));
}
}

38
source/application/store/controller/data/Shop.php

@ -1,38 +0,0 @@
<?php
namespace app\store\controller\data;
use app\store\controller\Controller;
use app\store\model\store\Shop as ShopModel;
class Shop extends Controller
{
/* @var ShopModel $model */
private $model;
/**
* 构造方法
* @throws \app\common\exception\BaseException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function _initialize()
{
parent::_initialize();
$this->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'));
}
}

43
source/application/store/controller/data/User.php

@ -1,43 +0,0 @@
<?php
namespace app\store\controller\data;
use app\store\controller\Controller;
use app\store\model\User as UserModel;
/**
* 用户数据控制器
* Class User
* @package app\store\controller\data
*/
class User extends Controller
{
/* @var \app\store\model\User $model */
private $model;
/**
* 构造方法
* @throws \app\common\exception\BaseException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function _initialize()
{
parent::_initialize();
$this->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'));
}
}

44
source/application/store/controller/data/sharing/Goods.php

@ -1,44 +0,0 @@
<?php
namespace app\store\controller\data\sharing;
use app\store\controller\Controller;
use app\store\model\sharing\Goods as GoodsModel;
/**
* 商品数据控制器
* Class Goods
* @package app\store\controller\data
*/
class Goods extends Controller
{
/* @var GoodsModel $model */
private $model;
/**
* 构造方法
* @throws \app\common\exception\BaseException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function _initialize()
{
parent::_initialize();
$this->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'));
}
}

83
source/application/store/controller/goods/Category.php

@ -1,83 +0,0 @@
<?php
namespace app\store\controller\goods;
use app\store\controller\Controller;
use app\store\model\Category as CategoryModel;
/**
* 商品分类
* Class Category
* @package app\store\controller\goods
*/
class Category extends Controller
{
/**
* 商品分类列表
* @return mixed
*/
public function index()
{
$model = new CategoryModel;
$list = $model->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() ?: '更新失败');
}
}

62
source/application/store/controller/goods/Comment.php

@ -1,62 +0,0 @@
<?php
namespace app\store\controller\goods;
use app\store\controller\Controller;
use app\store\model\Comment as CommentModel;
/**
* 商品评价管理
* Class Comment
* @package app\store\controller\goods
*/
class Comment extends Controller
{
/**
* 评价列表
* @return mixed
* @throws \think\exception\DbException
*/
public function index()
{
$model = new CommentModel;
$list = $model->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('删除成功');
}
}

93
source/application/store/controller/goods/Spec.php

@ -1,93 +0,0 @@
<?php
namespace app\store\controller\goods;
use app\store\controller\Controller;
use app\store\model\Spec as SpecModel;
use app\store\model\SpecValue as SpecValueModel;
/**
* 商品规格控制器
* Class Spec
* @package app\store\controller
*/
class Spec extends Controller
{
/* @var SpecModel $SpecModel */
private $SpecModel;
/* @var SpecValueModel $SpecModel */
private $SpecValueModel;
/**
* 构造方法
* @throws \app\common\exception\BaseException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function _initialize()
{
parent::_initialize();
$this->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();
}
}

39
source/application/store/controller/market/Basic.php

@ -1,39 +0,0 @@
<?php
namespace app\store\controller\market;
use app\store\controller\Controller;
use app\store\model\Goods;
use app\store\model\Region as RegionModel;
use app\store\model\Setting as SettingModel;
/**
* 营销设置-基本功能
* Class Basic
* @package app\store\controller
*/
class Basic extends Controller
{
/**
* 满额包邮设置
* @return array|bool|mixed
* @throws \think\exception\DbException
*/
public function full_free()
{
if (!$this->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() ?: '操作失败');
}
}

108
source/application/store/controller/market/Coupon.php

@ -1,108 +0,0 @@
<?php
namespace app\store\controller\market;
use app\store\controller\Controller;
use app\store\model\Coupon as CouponModel;
use app\store\model\UserCoupon as UserCouponModel;
/**
* 优惠券管理
* Class Coupon
* @package app\store\controller\market
*/
class Coupon extends Controller
{
/* @var CouponModel $model */
private $model;
/**
* 构造方法
* @throws \app\common\exception\BaseException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function _initialize()
{
parent::_initialize();
$this->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'));
}
}

47
source/application/store/controller/market/Push.php

@ -1,47 +0,0 @@
<?php
namespace app\store\controller\market;
use app\store\controller\Controller;
use app\store\model\wxapp\Formid as FormidModel;
use app\store\service\wxapp\Message as MessageService;
/**
* 消息推送 (废弃)
* Class Push
* @package app\store\controller\market
*/
class Push extends Controller
{
/**
* 发送消息
* @return array|mixed
* @throws \app\common\exception\BaseException
* @throws \think\Exception
* @throws \think\exception\DbException
*/
public function send()
{
if (!$this->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'));
}
}

28
source/application/store/controller/market/Recharge.php

@ -1,28 +0,0 @@
<?php
namespace app\store\controller\market;
use app\store\controller\Controller;
use app\store\model\Setting as SettingModel;
class Recharge extends Controller
{
/**
* 充值设置
* @return array|bool|mixed
* @throws \think\exception\DbException
*/
public function setting()
{
if (!$this->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() ?: '操作失败');
}
}

95
source/application/store/controller/market/recharge/Plan.php

@ -1,95 +0,0 @@
<?php
namespace app\store\controller\market\recharge;
use app\store\controller\Controller;
use app\store\model\recharge\Plan as PlanModel;
/**
* 充值套餐管理
* Class Coupon
* @package app\store\controller\market
*/
class Plan extends Controller
{
/* @var PlanModel $model */
private $model;
/**
* 构造方法
* @throws \app\common\exception\BaseException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function _initialize()
{
parent::_initialize();
$this->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() ?: '删除成功');
}
}

100
source/application/store/controller/order/Operate.php

@ -1,100 +0,0 @@
<?php
namespace app\store\controller\order;
use app\store\controller\Controller;
use app\store\model\Order as OrderModel;
use app\store\model\Express as ExpressModel;
/**
* 订单操作控制器
* Class Operate
* @package app\store\controller\order
*/
class Operate extends Controller
{
/* @var OrderModel $model */
private $model;
/**
* 构造方法
* @throws \app\common\exception\BaseException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function _initialize()
{
parent::_initialize();
$this->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() ?: '核销失败');
}
}

82
source/application/store/controller/order/Refund.php

@ -1,82 +0,0 @@
<?php
namespace app\store\controller\order;
use app\store\controller\Controller;
use app\store\model\Order as OrderModel;
use app\store\model\OrderRefund as OrderRefundModel;
use app\store\model\ReturnAddress as ReturnAddressModel;
/**
* 售后管理
* Class Refund
* @package app\store\controller\order
*/
class Refund extends Controller
{
/**
* 帮助中心列表
* @return mixed
* @throws \think\exception\DbException
*/
public function index()
{
$model = new OrderRefundModel;
$list = $model->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() ?: '操作失败');
}
}

79
source/application/store/controller/setting/Address.php

@ -1,79 +0,0 @@
<?php
namespace app\store\controller\setting;
use app\store\controller\Controller;
use app\store\model\ReturnAddress as ReturnAddressModel;
/**
* 退货地址
* Class Delivery
* @package app\store\controller\setting
*/
class Address extends Controller
{
/**
* 退货地址列表
* @return mixed
* @throws \think\exception\DbException
*/
public function index()
{
$model = new ReturnAddressModel;
$list = $model->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('删除成功');
}
}

137
source/application/store/controller/setting/Cache.php

@ -1,137 +0,0 @@
<?php
namespace app\store\controller\setting;
use app\store\controller\Controller;
use think\Cache as Driver;
/**
* 清理缓存
* Class Index
* @package app\store\controller
*/
class Cache extends Controller
{
/**
* 清理缓存
* @return mixed
*/
public function clear()
{
if ($this->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;
}
}

92
source/application/store/controller/setting/Delivery.php

@ -1,92 +0,0 @@
<?php
namespace app\store\controller\setting;
use app\store\controller\Controller;
use app\store\model\Region;
use app\store\model\Delivery as DeliveryModel;
/**
* 配送设置
* Class Delivery
* @package app\store\controller\setting
*/
class Delivery extends Controller
{
/**
* 配送模板列表
* @return mixed
* @throws \think\exception\DbException
*/
public function index()
{
$model = new DeliveryModel;
$list = $model->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() ?: '更新失败');
}
}

89
source/application/store/controller/setting/Express.php

@ -1,89 +0,0 @@
<?php
namespace app\store\controller\setting;
use app\store\controller\Controller;
use app\store\model\Express as ExpressModel;
/**
* 物流公司
* Class Express
* @package app\store\controller\setting
*/
class Express extends Controller
{
/**
* 物流公司列表
* @return mixed
* @throws \think\exception\DbException
*/
public function index()
{
$model = new ExpressModel;
$list = $model->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');
}
}

19
source/application/store/controller/setting/Help.php

@ -1,19 +0,0 @@
<?php
namespace app\store\controller\setting;
use app\store\controller\Controller;
/**
* 设置-帮助信息
* Class Help
* @package app\store\controller\setting
*/
class Help extends Controller
{
public function tplMsg()
{
return $this->fetch('tplMsg');
}
}

99
source/application/store/controller/setting/Printer.php

@ -1,99 +0,0 @@
<?php
namespace app\store\controller\setting;
use app\store\controller\Controller;
use app\store\model\Printer as PrinterModel;
/**
* 小票打印机管理
* Class Printer
* @package app\store\controller\setting
*/
class Printer extends Controller
{
/**
* 打印机列表
* @return mixed
* @throws \think\exception\DbException
*/
public function index()
{
$model = new PrinterModel;
$list = $model->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);
}
}

171
source/application/store/controller/setting/Science.php

@ -1,171 +0,0 @@
<?php
namespace app\store\controller\setting;
use app\store\controller\Controller;
/**
* 环境检测
* Class Science
* @package app\store\controller\setting
*/
class Science extends Controller
{
/**
* 状态class
* @var array
*/
private $statusClass = [
'normal' => '',
'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;
}
}

91
source/application/store/controller/shop/Clerk.php

@ -1,91 +0,0 @@
<?php
namespace app\store\controller\shop;
use app\store\controller\Controller;
use app\store\model\store\Shop as ShopModel;
use app\store\model\store\shop\Clerk as ClerkModel;
/**
* 门店店员控制器
* Class Clerk
* @package app\store\controller\shop
*/
class Clerk extends Controller
{
/**
* 店员列表
* @param int $shop_id
* @param string $search
* @return mixed
* @throws \think\exception\DbException
*/
public function index($shop_id = 0, $search = '')
{
// 店员列表
$model = new ClerkModel;
$list = $model->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('删除成功');
}
}

33
source/application/store/controller/shop/Order.php

@ -1,33 +0,0 @@
<?php
namespace app\store\controller\shop;
use app\store\controller\Controller;
use app\store\model\store\Shop as ShopModel;
use app\store\model\store\shop\Order as OrderModel;
/**
* 订单核销记录
* Class Order
* @package app\store\controller\shop
*/
class Order extends Controller
{
/**
* 订单核销记录列表
* @param int $shop_id
* @param string $search
* @return mixed
* @throws \think\exception\DbException
*/
public function index($shop_id = 0, $search = '')
{
// 核销记录列表
$model = new OrderModel;
$list = $model->getList($shop_id, $search);
// 门店列表
$shopList = ShopModel::getAllList();
return $this->fetch('index', compact('list', 'shopList'));
}
}

100
source/application/store/controller/store/Role.php

@ -1,100 +0,0 @@
<?php
namespace app\store\controller\store;
use app\store\controller\Controller;
use app\store\model\store\Role as RoleModel;
use app\store\model\store\Access as AccessModel;
/**
* 商家用户角色控制器
* Class StoreUser
* @package app\store\controller
*/
class Role extends Controller
{
/**
* 角色列表
* @return mixed
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function index()
{
$model = new RoleModel;
$list = $model->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('删除成功');
}
}

115
source/application/store/controller/store/User.php

@ -1,115 +0,0 @@
<?php
namespace app\store\controller\store;
use app\store\controller\Controller;
use app\store\model\store\Role as RoleModel;
use app\store\model\store\User as StoreUserModel;
use app\store\model\store\UserRole;
/**
* 商家用户控制器
* Class StoreUser
* @package app\store\controller
*/
class User extends Controller
{
/**
* 用户列表
* @return mixed
* @throws \think\exception\DbException
*/
public function index()
{
$model = new StoreUserModel;
$list = $model->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'));
}
}

104
source/application/store/controller/upload/Library.php

@ -1,104 +0,0 @@
<?php
namespace app\store\controller\upload;
use app\store\controller\Controller;
use app\store\model\UploadFile as UploadFileModel;
use app\store\model\UploadGroup as UploadGroupModel;
class Library extends Controller
{
/**
* 文件库列表
* @param string $type
* @param int $group_id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function fileList($type = 'image', $group_id = -1)
{
// 分组列表
$group_list = (new UploadGroupModel)->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() ?: '移动失败');
}
}

31
source/application/store/controller/user/Balance.php

@ -1,31 +0,0 @@
<?php
namespace app\store\controller\user;
use app\store\controller\Controller;
use app\store\model\user\BalanceLog as BalanceLogModel;
/**
* 余额明细
* Class Balance
* @package app\store\controller\user
*/
class Balance extends Controller
{
/**
* 充值记录
* @return mixed
* @throws \think\exception\DbException
*/
public function log()
{
$model = new BalanceLogModel;
return $this->fetch('log', [
// 充值记录列表
'list' => $model->getList($this->request->param()),
// 属性集
'attributes' => $model::getAttributes(),
]);
}
}

31
source/application/store/controller/user/Recharge.php

@ -1,31 +0,0 @@
<?php
namespace app\store\controller\user;
use app\store\controller\Controller;
use app\store\model\recharge\Order as OrderModel;
/**
* 余额记录
* Class Recharge
* @package app\store\controller\user
*/
class Recharge extends Controller
{
/**
* 充值记录
* @return mixed
* @throws \think\exception\DbException
*/
public function order()
{
$model = new OrderModel;
return $this->fetch('order', [
// 充值记录列表
'list' => $model->getList($this->request->param()),
// 属性集
'attributes' => $model::getAttributes(),
]);
}
}

82
source/application/store/controller/wxapp/Help.php

@ -1,82 +0,0 @@
<?php
namespace app\store\controller\wxapp;
use app\store\controller\Controller;
use app\store\model\WxappHelp as WxappHelpModel;
/**
* 小程序帮助中心
* Class help
* @package app\store\controller\wxapp
*/
class Help extends Controller
{
/**
* 帮助中心列表
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function index()
{
$model = new WxappHelpModel;
$list = $model->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('删除成功');
}
}

145
source/application/store/controller/wxapp/Page.php

@ -1,145 +0,0 @@
<?php
namespace app\store\controller\wxapp;
use app\store\controller\Controller;
use app\store\model\Category as CategoryModel;
use app\store\model\sharing\Category as SharingCategoryModel;
use app\store\model\article\Category as ArticleCategoryModel;
use app\store\model\WxappPage as WxappPageModel;
use app\store\model\WxappCategory as WxappCategoryModel;
/**
* 小程序页面管理
* Class Page
* @package app\store\controller\wxapp
*/
class Page extends Controller
{
/**
* 页面列表
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function index()
{
$model = new WxappPageModel;
$list = $model->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');
}
}

50
source/application/store/controller/wxapp/Submsg.php

@ -1,50 +0,0 @@
<?php
namespace app\store\controller\wxapp;
use app\store\controller\Controller;
use app\store\model\Setting as SettingModel;
use app\store\service\wxapp\SubMsg as SubMsgService;
/**
* 小程序订阅消息设置
* Class Submsg
* @package app\store\controller\wxapp
*/
class Submsg extends Controller
{
/**
* 小程序订阅消息设置
* @return array|bool|mixed
* @throws \think\exception\DbException
*/
public function index()
{
if (!$this->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() ?: '操作失败');
}
}

668
source/application/store/extra/menus.php

@ -1,668 +0,0 @@
<?php
/**
* 后台菜单配置
* 'home' => [
* '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'
]
]
]
],
],
];

88
source/application/store/model/Article.php

@ -1,88 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\Article as ArticleModel;
/**
* 文章模型
* Class Article
* @package app\store\model
*/
class Article extends ArticleModel
{
/**
* 获取文章列表
* @return \think\Paginator
* @throws \think\exception\DbException
*/
public function getList()
{
return $this->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();
}
}

73
source/application/store/model/Category.php

@ -1,73 +0,0 @@
<?php
namespace app\store\model;
use think\Cache;
use app\common\model\Category as CategoryModel;
/**
* 商品分类模型
* Class Category
* @package app\store\model
*/
class Category extends CategoryModel
{
/**
* 添加新记录
* @param $data
* @return false|int
*/
public function add($data)
{
$data['wxapp_id'] = self::$wxapp_id;
// if (!empty($data['image'])) {
// $data['image_id'] = UploadFile::getFildIdByName($data['image']);
// }
$this->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);
}
}

32
source/application/store/model/Comment.php

@ -1,32 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\Comment as CommentModel;
/**
* 商品评价模型
* Class Comment
* @package app\store\model
*/
class Comment extends CommentModel
{
/**
* 软删除
* @return false|int
*/
public function setDelete()
{
return $this->save(['is_delete' => 1]);
}
/**
* 获取评价总数量
* @return int|string
*/
public function getCommentTotal()
{
return $this->where(['is_delete' => 0])->count();
}
}

14
source/application/store/model/CommentImage.php

@ -1,14 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\CommentImage as CommentImageModel;
/**
* 商品图片模型
* Class GoodsImage
* @package app\store\model
*/
class CommentImage extends CommentImageModel
{
}

66
source/application/store/model/Coupon.php

@ -1,66 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\Coupon as CouponModel;
/**
* 优惠券模型
* Class Coupon
* @package app\store\model
*/
class Coupon extends CouponModel
{
/**
* 获取优惠券列表
* @return \think\Paginator
* @throws \think\exception\DbException
*/
public function getList()
{
return $this->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;
}
}

124
source/application/store/model/Delivery.php

@ -1,124 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\Delivery as DeliveryModel;
/**
* 配送模板模型
* Class Delivery
* @package app\common\model
*/
class Delivery extends DeliveryModel
{
/**
* 添加新记录
* @param $data
* @return bool|int
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function add($data)
{
if (!isset($data['rule']) || empty($data['rule'])) {
$this->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();
}
}

55
source/application/store/model/DeliveryRule.php

@ -1,55 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\DeliveryRule as DeliveryRuleModel;
/**
* 配送模板区域及运费模型
* Class DeliveryRule
* @package app\store\model
*/
class DeliveryRule extends DeliveryRuleModel
{
protected $append = ['region_content'];
static $regionAll;
static $regionTree;
/**
* 可配送区域
* @param $value
* @param $data
* @return string
*/
public function getRegionContentAttr($value, $data)
{
// 当前区域记录转换为数组
$regionIds = explode(',', $data['region']);
if (count($regionIds) === 373) return '全国';
// 所有地区
if (empty(self::$regionAll)) {
self::$regionAll = Region::getCacheAll();
self::$regionTree = Region::getCacheTree();
}
// 将当前可配送区域格式化为树状结构
$alreadyTree = [];
foreach ($regionIds as $regionId)
$alreadyTree[self::$regionAll[$regionId]['pid']][] = $regionId;
$str = '';
foreach ($alreadyTree as $provinceId => $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 .= ' (<span class="am-link-muted">' . mb_substr($cityStr, 0, -1, 'utf-8') . '</span>)';
}
$str .= '、';
}
return mb_substr($str, 0, -1, 'utf-8');
}
}

45
source/application/store/model/Express.php

@ -1,45 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\Express as ExpressModel;
class Express extends ExpressModel
{
/**
* 添加新记录
* @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()
{
// 判断当前物流公司是否已被订单使用
$Order = new Order;
if ($orderCount = $Order->where(['express_id' => $this['express_id']])->count()) {
$this->error = '当前物流公司已被' . $orderCount . '个订单使用,不允许删除';
return false;
}
return $this->delete();
}
}

153
source/application/store/model/Goods.php

@ -1,153 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\Goods as GoodsModel;
/**
* 商品模型
* Class Goods
* @package app\store\model
*/
class Goods extends GoodsModel
{
/**
* 添加商品
* @param array $data
* @return bool
* @throws \think\exception\PDOException
*/
public function add(array $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);
// 商品图片
$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();
}
}

14
source/application/store/model/GoodsImage.php

@ -1,14 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\GoodsImage as GoodsImageModel;
/**
* 商品图片模型
* Class GoodsImage
* @package app\store\model
*/
class GoodsImage extends GoodsImageModel
{
}

70
source/application/store/model/GoodsSku.php

@ -1,70 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\GoodsSku as GoodsSkuModel;
/**
* 商品规格模型
* Class GoodsSku
* @package app\store\model
*/
class GoodsSku extends GoodsSkuModel
{
/**
* 批量添加商品sku记录
* @param $goods_id
* @param $spec_list
* @return array|false
* @throws \Exception
*/
public function addSkuList($goods_id, $spec_list)
{
$data = [];
foreach ($spec_list as $item) {
$data[] = array_merge($item['form'], [
'spec_sku_id' => $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();
}
}

14
source/application/store/model/GoodsSpecRel.php

@ -1,14 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\GoodsSpecRel as GoodsSpecRelModel;
/**
* 商品规格关系模型
* Class GoodsSpecRel
* @package app\store\model
*/
class GoodsSpecRel extends GoodsSpecRelModel
{
}

476
source/application/store/model/Order.php

@ -1,476 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\Order as OrderModel;
use app\store\model\User as UserModel;
use app\store\model\UserCoupon as UserCouponModel;
use app\store\service\order\Export as Exportservice;
use app\common\library\helper;
use app\common\enum\OrderType as OrderTypeEnum;
use app\common\enum\DeliveryType as DeliveryTypeEnum;
use app\common\service\Message as MessageService;
use app\common\service\order\Refund as RefundService;
use app\common\service\wechat\wow\Order as WowService;
use app\common\service\goods\source\Factory as FactoryStock;
use app\common\enum\order\PayStatus as PayStatusEnum;
use app\common\enum\order\Status as OrderStatusEnum;
/**
* 订单管理
* Class Order
* @package app\store\model
*/
class Order extends OrderModel
{
/**
* 订单列表
* @param string $dataType
* @param array $query
* @return \think\Paginator
* @throws \think\exception\DbException
*/
public function getList($dataType, $query = [])
{
// 检索查询条件
!empty($query) && $this->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);
}
}

15
source/application/store/model/OrderAddress.php

@ -1,15 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\OrderAddress as OrderAddressModel;
/**
* 订单收货地址模型
* Class OrderAddress
* @package app\store\model
*/
class OrderAddress extends OrderAddressModel
{
}

15
source/application/store/model/OrderGoods.php

@ -1,15 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\OrderGoods as OrderGoodsModel;
/**
* 订单商品模型
* Class OrderGoods
* @package app\store\model
*/
class OrderGoods extends OrderGoodsModel
{
}

134
source/application/store/model/OrderRefund.php

@ -1,134 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\OrderRefund as OrderRefundModel;
use app\store\model\User as UserModel;
use app\common\service\Message as MessageService;
use app\common\service\order\Refund as RefundService;
use app\common\enum\OrderType as OrderTypeEnum;
/**
* 售后单模型
* Class OrderRefund
* @package app\api\model
*/
class OrderRefund extends OrderRefundModel
{
/**
* 获取售后单列表
* @param array $query
* @return \think\Paginator
* @throws \think\exception\DbException
*/
public function getList($query = [])
{
// 查询条件:订单号
if (isset($query['order_no']) && !empty($query['order_no'])) {
$this->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;
}
}

33
source/application/store/model/OrderRefundAddress.php

@ -1,33 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\OrderRefundAddress as OrderRefundAddressModel;
/**
* 售后单退货地址模型
* Class OrderRefundAddress
* @package app\store\model
*/
class OrderRefundAddress extends OrderRefundAddressModel
{
/**
* 新增售后单退货地址记录
* @param $order_refund_id
* @param $address_id
* @return false|int
* @throws \think\exception\DbException
*/
public function add($order_refund_id, $address_id)
{
$detail = ReturnAddress::detail($address_id);
return $this->save([
'order_refund_id' => $order_refund_id,
'name' => $detail['name'],
'phone' => $detail['phone'],
'detail' => $detail['detail'],
'wxapp_id' => self::$wxapp_id
]);
}
}

10
source/application/store/model/OrderRefundImage.php

@ -1,10 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\OrderRefundImage as OrderRefundImageModel;
class OrderRefundImage extends OrderRefundImageModel
{
}

41
source/application/store/model/Printer.php

@ -1,41 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\Printer as PrinterModel;
class Printer extends PrinterModel
{
/**
* 添加新记录
* @param $data
* @return false|int
*/
public function add($data)
{
$data['printer_config'] = $data[$data['printer_type']];
$data['wxapp_id'] = self::$wxapp_id;
return $this->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]);
}
}

15
source/application/store/model/Region.php

@ -1,15 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\Region as RegionModel;
/**
* 地区模型
* Class Region
* @package app\store\model
*/
class Region extends RegionModel
{
}

72
source/application/store/model/ReturnAddress.php

@ -1,72 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\ReturnAddress as ReturnAddressModel;
/**
* 退货地址模型
* Class ReturnAddress
* @package app\store\model
*/
class ReturnAddress extends ReturnAddressModel
{
/**
* 获取列表
* @return \think\Paginator
* @throws \think\exception\DbException
*/
public function getList()
{
return $this->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]);
}
}

76
source/application/store/model/Setting.php

@ -1,76 +0,0 @@
<?php
namespace app\store\model;
use think\Cache;
use app\common\model\Setting as SettingModel;
use app\common\enum\Setting as SettingEnum;
/**
* 系统设置模型
* Class Wxapp
* @package app\store\model
*/
class Setting extends SettingModel
{
/**
* 更新系统设置
* @param $key
* @param $values
* @return bool
* @throws \think\exception\DbException
*/
public function edit($key, $values)
{
$model = self::detail($key) ?: $this;
// 数据验证
if (!$this->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;
}
}

35
source/application/store/model/Spec.php

@ -1,35 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\Spec as SpecModel;
/**
* 规格/属性(组)模型
* Class Spec
* @package app\store\model
*/
class Spec extends SpecModel
{
/**
* 根据规格组名称查询规格id
* @param $spec_name
* @return mixed
*/
public function getSpecIdByName($spec_name)
{
return self::where(compact('spec_name'))->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'));
}
}

38
source/application/store/model/SpecValue.php

@ -1,38 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\SpecValue as SpecValueModel;
/**
* 规格/属性(值)模型
* Class SpecValue
* @package app\store\model
*/
class SpecValue extends SpecValueModel
{
/**
* 根据规格组名称查询规格id
* @param $spec_id
* @param $spec_value
* @return mixed
*/
public function getSpecValueIdByName($spec_id, $spec_value)
{
return self::where(compact('spec_id', 'spec_value'))->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'));
}
}

191
source/application/store/model/Store.php

@ -1,191 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\Store as StoreModel;
/**
* 商城模型
* Class Store
* @package app\store\model
*/
class Store extends StoreModel
{
/* @var Goods $GoodsModel */
private $GoodsModel;
/* @var Order $GoodsModel */
private $OrderModel;
/* @var User $GoodsModel */
private $UserModel;
/**
* 构造方法
*/
public function initialize()
{
parent::initialize();
/* 初始化模型 */
$this->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));
}
}

86
source/application/store/model/StoreUser.php

@ -1,86 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\StoreUser as StoreUserModel;
use think\Session;
/**
* 商家用户模型
* Class StoreUser
* @package app\store\model
*/
class StoreUser extends StoreUserModel
{
/**
* 商家用户登录
* @param $data
* @return bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function login($data)
{
// 验证用户名密码是否正确
if (!$user = self::useGlobalScope(false)->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;
}
}

91
source/application/store/model/UploadFile.php

@ -1,91 +0,0 @@
<?php
namespace app\store\model;
use think\Request;
use app\common\model\UploadFile as UploadFileModel;
use app\store\model\Setting as SettingModel;
use app\common\library\storage\Driver as StorageDriver;
/**
* 文件库模型
* Class UploadFile
* @package app\store\model
*/
class UploadFile extends UploadFileModel
{
/**
* 获取列表记录
* @param int $groupId 分组id
* @param string $fileType 文件类型
* @param bool|int $isRecycle
* @return \think\Paginator
* @throws \think\exception\DbException
*/
public function getList($groupId = -1, $fileType = '', $isRecycle = -1)
{
// 文件分组
$groupId != -1 && $this->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'));
}
}

38
source/application/store/model/UploadFileUsed.php

@ -1,38 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\UploadFileUsed as UploadFileUsedModel;
/**
* 已上传文件使用记录表MO型
* Class UploadFileUsed
* @package app\store\model
*/
class UploadFileUsed extends UploadFileUsedModel
{
protected $updateTime = false;
/**
* 新增记录
* @param $data
* @return false|int
*/
public function add($data) {
return $this->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();
}
}

66
source/application/store/model/UploadGroup.php

@ -1,66 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\UploadGroup as UploadGroupModel;
/**
* 文件库分组模型
* Class UploadGroup
* @package app\store\model
*/
class UploadGroup extends UploadGroupModel
{
/**
* 获取列表记录
* @param string $groupType
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getList($groupType = '')
{
!empty($groupType) && $this->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]);
}
}

97
source/application/store/model/User.php

@ -1,97 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\User as UserModel;
use app\store\model\user\BalanceLog as BalanceLogModel;
use app\common\enum\user\balanceLog\Scene as SceneEnum;
/**
* 用户模型
* Class User
* @package app\store\model
*/
class User extends UserModel
{
/**
* 获取当前用户总数
* @param null $day
* @return int|string
* @throws \think\Exception
*/
public function getUserTotal($day = null)
{
if (!is_null($day)) {
$startTime = strtotime($day);
$this->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;
}
}

15
source/application/store/model/UserAddress.php

@ -1,15 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\UserAddress as UserAddressModel;
/**
* 用户收货地址模型
* Class UserAddress
* @package app\store\model
*/
class UserAddress extends UserAddressModel
{
}

28
source/application/store/model/UserCoupon.php

@ -1,28 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\UserCoupon as UserCouponModel;
/**
* 用户优惠券模型
* Class UserCoupon
* @package app\store\model
*/
class UserCoupon extends UserCouponModel
{
/**
* 获取优惠券列表
* @return \think\Paginator
* @throws \think\exception\DbException
*/
public function getList()
{
return $this->with(['user'])
->order(['create_time' => 'desc'])
->paginate(15, false, [
'query' => request()->request()
]);
}
}

77
source/application/store/model/Wxapp.php

@ -1,77 +0,0 @@
<?php
namespace app\store\model;
use think\Cache;
use app\common\model\Wxapp as WxappModel;
/**
* 微信小程序模型
* Class Wxapp
* @package app\store\model
*/
class Wxapp extends WxappModel
{
/**
* 更新小程序设置
* @param $data
* @return bool
* @throws \think\exception\PDOException
*/
public function edit($data)
{
$this->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);
}
}

24
source/application/store/model/WxappCategory.php

@ -1,24 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\WxappCategory as WxappCategoryModel;
/**
* 微信小程序分类页模板
* Class WxappCategory
* @package app\store\model
*/
class WxappCategory extends WxappCategoryModel
{
/**
* 编辑记录
* @param $data
* @return bool|int
*/
public function edit($data)
{
return $this->allowField(true)->save($data) !== false;
}
}

43
source/application/store/model/WxappHelp.php

@ -1,43 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\WxappHelp as WxappHelpModel;
/**
* 小程序帮助中心
* Class WxappHelp
* @package app\store\model
*/
class WxappHelp extends WxappHelpModel
{
/**
* 新增记录
* @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 int
*/
public function remove() {
return $this->delete();
}
}

26
source/application/store/model/WxappNavbar.php

@ -1,26 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\WxappNavbar as WxappNavbarModel;
/**
* 微信小程序导航栏模型
* Class WxappNavbar
* @package app\common\model
*/
class WxappNavbar extends WxappNavbarModel
{
/**
* 更新页面数据
* @param $data
* @return bool
*/
public function edit($data)
{
// 删除wxapp缓存
Wxapp::deleteCache();
return $this->save($data) !== false;
}
}

87
source/application/store/model/WxappPage.php

@ -1,87 +0,0 @@
<?php
namespace app\store\model;
use app\common\model\WxappPage as WxappPageModel;
/**
* 微信小程序diy页面模型
* Class WxappPage
* @package app\common\model
*/
class WxappPage extends WxappPageModel
{
/**
* 获取列表
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getList()
{
return $this->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]);
}
}

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save