moonsflyer преди 2 месеца
родител
ревизия
1478e5472c
променени са 100 файла, в които са добавени 0 реда и са изтрити 15828 реда
  1. 0 24
      app/kefuapi/config/route.php
  2. 0 67
      app/kefuapi/controller/Account.php
  3. 0 166
      app/kefuapi/controller/Chat.php
  4. 0 47
      app/kefuapi/controller/File.php
  5. 0 109
      app/kefuapi/http/middleware/Login.php
  6. 0 346
      app/kefuapi/logic/ChatLogic.php
  7. 0 129
      app/kefuapi/logic/LoginLogic.php
  8. 0 29
      app/kefuapi/validate/ChatValidate.php
  9. 0 122
      app/kefuapi/validate/LoginValidate.php
  10. 0 106
      app/kefuapi/validate/TokenValidate.php
  11. 0 26
      app/shop/config/project.php
  12. 0 143
      app/shop/controller/Admin.php
  13. 0 96
      app/shop/controller/Alipay.php
  14. 0 103
      app/shop/controller/Bank.php
  15. 0 52
      app/shop/controller/Common.php
  16. 0 22
      app/shop/controller/Dispatch.php
  17. 0 200
      app/shop/controller/File.php
  18. 0 168
      app/shop/controller/Freight.php
  19. 0 79
      app/shop/controller/Index.php
  20. 0 63
      app/shop/controller/Login.php
  21. 0 114
      app/shop/controller/Role.php
  22. 0 165
      app/shop/controller/Seckill.php
  23. 0 72
      app/shop/controller/Statistics.php
  24. 0 43
      app/shop/controller/Store.php
  25. 0 63
      app/shop/controller/Upload.php
  26. 0 131
      app/shop/controller/activity_area/Goods.php
  27. 0 190
      app/shop/controller/after_sale/AfterSale.php
  28. 0 249
      app/shop/controller/bargain/Bargain.php
  29. 0 169
      app/shop/controller/coupon/Coupon.php
  30. 0 147
      app/shop/controller/decoration/Ad.php
  31. 0 33
      app/shop/controller/decoration/Index.php
  32. 0 41
      app/shop/controller/distribution/Center.php
  33. 0 73
      app/shop/controller/distribution/Goods.php
  34. 0 27
      app/shop/controller/distribution/Order.php
  35. 0 23
      app/shop/controller/distribution/Record.php
  36. 0 94
      app/shop/controller/express_assistant/FaceSheetOrder.php
  37. 0 113
      app/shop/controller/express_assistant/FaceSheetSender.php
  38. 0 65
      app/shop/controller/express_assistant/FaceSheetSetting.php
  39. 0 127
      app/shop/controller/express_assistant/FaceSheetTpl.php
  40. 0 84
      app/shop/controller/finance/Settlement.php
  41. 0 51
      app/shop/controller/finance/Shop.php
  42. 0 121
      app/shop/controller/finance/Withdrawal.php
  43. 0 44
      app/shop/controller/free_shipping/FreeShipping.php
  44. 0 129
      app/shop/controller/goods/Category.php
  45. 0 36
      app/shop/controller/goods/Comment.php
  46. 0 302
      app/shop/controller/goods/Goods.php
  47. 0 109
      app/shop/controller/goods/Supplier.php
  48. 0 160
      app/shop/controller/kefu/Kefu.php
  49. 0 109
      app/shop/controller/kefu/KefuLang.php
  50. 0 117
      app/shop/controller/live/LiveGoods.php
  51. 0 169
      app/shop/controller/live/LiveRoom.php
  52. 0 135
      app/shop/controller/order/DeliveryBatch.php
  53. 0 95
      app/shop/controller/order/Invoice.php
  54. 0 410
      app/shop/controller/order/Order.php
  55. 0 70
      app/shop/controller/printer/Config.php
  56. 0 140
      app/shop/controller/printer/Printer.php
  57. 0 57
      app/shop/controller/printer/Template.php
  58. 0 113
      app/shop/controller/seckill/SeckillGoods.php
  59. 0 39
      app/shop/controller/setting/CustomerService.php
  60. 0 167
      app/shop/controller/team/Activity.php
  61. 0 93
      app/shop/controller/team/Found.php
  62. 0 33
      app/shop/controller/user/User.php
  63. 0 181
      app/shop/logic/AdminLogic.php
  64. 0 111
      app/shop/logic/AlipayLogic.php
  65. 0 139
      app/shop/logic/BankLogic.php
  66. 0 98
      app/shop/logic/CommonLogic.php
  67. 0 502
      app/shop/logic/FileLogic.php
  68. 0 100
      app/shop/logic/LoginLogic.php
  69. 0 242
      app/shop/logic/RoleLogic.php
  70. 0 208
      app/shop/logic/SeckillLogic.php
  71. 0 194
      app/shop/logic/StatisticsLogic.php
  72. 0 121
      app/shop/logic/StoreLogic.php
  73. 0 105
      app/shop/logic/activity_area/AreaLogic.php
  74. 0 231
      app/shop/logic/activity_area/GoodsLogic.php
  75. 0 600
      app/shop/logic/after_sale/AfterSaleLogic.php
  76. 0 722
      app/shop/logic/bargain/BargainLogic.php
  77. 0 454
      app/shop/logic/coupon/CouponLogic.php
  78. 0 46
      app/shop/logic/decoration/IndexLogic.php
  79. 0 126
      app/shop/logic/decoration/ShopAdLogic.php
  80. 0 113
      app/shop/logic/distribution/CenterLogic.php
  81. 0 346
      app/shop/logic/distribution/GoodsLogic.php
  82. 0 114
      app/shop/logic/distribution/OrderLogic.php
  83. 0 86
      app/shop/logic/distribution/RecordLogic.php
  84. 0 302
      app/shop/logic/express_assistant/FaceSheetOrderLogic.php
  85. 0 180
      app/shop/logic/express_assistant/FaceSheetSenderLogic.php
  86. 0 192
      app/shop/logic/express_assistant/FaceSheetTplLogic.php
  87. 0 366
      app/shop/logic/finance/SettlementLogic.php
  88. 0 126
      app/shop/logic/finance/ShopLogic.php
  89. 0 409
      app/shop/logic/finance/WithdrawalLogic.php
  90. 0 133
      app/shop/logic/free_shipping/FreeShippingLogic.php
  91. 0 82
      app/shop/logic/goods/CategoryLogic.php
  92. 0 132
      app/shop/logic/goods/CommentLogic.php
  93. 0 862
      app/shop/logic/goods/GoodsLogic.php
  94. 0 112
      app/shop/logic/goods/SupplierLogic.php
  95. 0 263
      app/shop/logic/index/StatLogic.php
  96. 0 103
      app/shop/logic/kefu/KefuLangLogic.php
  97. 0 242
      app/shop/logic/kefu/KefuLogic.php
  98. 0 196
      app/shop/logic/live/LiveGoodsLogic.php
  99. 0 325
      app/shop/logic/live/LiveRoomLogic.php
  100. 0 145
      app/shop/logic/order/DeliveryBatchLogic.php

+ 0 - 24
app/kefuapi/config/route.php

@@ -1,24 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop100%开源免费商用商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | 开源版本可自由商用,可去除界面版权logo
-// | 商业版本务必购买商业授权,以免引起法律纠纷
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop团队 版权所有 拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshopTeam
-// +----------------------------------------------------------------------
-
-return [
-    'middleware' => [
-        app\kefuapi\http\middleware\Login::class,//登录验证
-    ],
-];

+ 0 - 67
app/kefuapi/controller/Account.php

@@ -1,67 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-namespace app\kefuapi\controller;
-
-use app\common\basics\KefuBase;
-use app\kefuapi\logic\LoginLogic;
-use app\common\server\JsonServer;
-use app\kefuapi\validate\LoginValidate;
-
-/**
- * 客服账号登录
- * Class Account
- * @package app\shopapi\controller
- */
-class Account extends KefuBase
-{
-
-    public $like_not_need_login = ['login'];
-
-
-    /**
-     * @notes 账号密码登录
-     * @return \think\response\Json
-     * @author 段誉
-     * @date 2021/11/9 16:21
-     */
-    public function login()
-    {
-        $post = $this->request->post();
-        (new LoginValidate())->goCheck();
-        $result = LoginLogic::accountLogin($post);
-        return JsonServer::success('登录成功', $result);
-    }
-
-
-
-    /**
-     * @notes 退出登录
-     * @return \think\response\Json
-     * @author 段誉
-     * @date 2021/11/9 15:49
-     */
-    public function logout()
-    {
-        LoginLogic::logout($this->kefu_id, $this->client);
-        return JsonServer::success();
-    }
-
-
-}

+ 0 - 166
app/kefuapi/controller/Chat.php

@@ -1,166 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-namespace app\kefuapi\controller;
-
-use app\common\basics\KefuBase;
-use app\kefuapi\logic\ChatLogic;
-use app\common\server\JsonServer;
-use app\kefuapi\validate\ChatValidate;
-
-
-class Chat extends KefuBase
-{
-
-    public $like_not_need_login = ['config'];
-
-    /**
-     * @notes 用户列表
-     * @return \think\response\Json
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2021/12/14 15:42
-     */
-    public function user()
-    {
-        $get = $this->request->get('');
-        // 对话过的用户
-        $result = ChatLogic::getChatUserList($this->kefu_id, $this->shop_id, $get, $this->page_no, $this->page_size);
-        return JsonServer::success('', $result);
-    }
-
-
-
-    /**
-     * @notes 指定用户聊天记录
-     * @return \think\response\Json
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2021/12/14 15:43
-     */
-    public function record()
-    {
-        $user_id = $this->request->get('user_id/d');
-        (new ChatValidate())->goCheck();
-        $result = ChatLogic::getChatRecord($this->kefu_id, $user_id, $this->shop_id, $this->page_no, $this->page_size);
-        return JsonServer::success('', $result);
-    }
-
-
-
-    /**
-     * @notes 在线的客服
-     * @return \think\response\Json
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2021/12/14 15:43
-     */
-    public function online()
-    {
-        $result = ChatLogic::getOnlineKefu($this->kefu_id, $this->shop_id);
-        return JsonServer::success('', $result);
-    }
-
-
-
-    /**
-     * @notes 快捷回复
-     * @return \think\response\Json
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2021/12/15 11:07
-     */
-    public function reply()
-    {
-        $keyword = $this->request->get('keyword');
-        $result = ChatLogic::getReplyLists($this->shop_id, $keyword, $this->page_no, $this->page_size);
-        return JsonServer::success('', $result);
-    }
-
-
-    /**
-     * @notes 用户详情接口
-     * @return \think\response\Json
-     * @author 段誉
-     * @date 2021/12/15 15:05
-     */
-    public function userInfo()
-    {
-        $user_id = $this->request->get('user_id/d');
-        $result = ChatLogic::getUserInfo($user_id);
-        if (false === $result) {
-            return JsonServer::error(ChatLogic::getError() ?: '系统错误');
-        }
-        return JsonServer::success('', $result);
-    }
-
-
-    /**
-     * @notes 获取指定订单列表
-     * @return \think\response\Json
-     * @author 段誉
-     * @date 2021/12/15 16:04
-     */
-    public function order()
-    {
-        $get = $this->request->get();
-        $result = ChatLogic::getOrderLists($get, $this->shop_id, $this->page_no, $this->page_size);
-        if (false === $result) {
-            return JsonServer::error(ChatLogic::getError() ?: '系统错误');
-        }
-        return JsonServer::success('', $result);
-    }
-
-
-    /**
-     * @notes 客服详情
-     * @return \think\response\Json
-     * @author 段誉
-     * @date 2021/12/15 17:34
-     */
-    public function kefuInfo()
-    {
-        $result = ChatLogic::getKefuInfo($this->kefu_id);
-        return JsonServer::success('', $result);
-    }
-
-
-    /**
-     * @notes 配置
-     * @return \think\response\Json
-     * @author 段誉
-     * @date 2021/12/16 17:06
-     */
-    public function config()
-    {
-        $result = ChatLogic::getConfig();
-        return JsonServer::success('', $result);
-    }
-
-
-
-}

+ 0 - 47
app/kefuapi/controller/File.php

@@ -1,47 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-
-namespace app\kefuapi\controller;
-
-use app\common\basics\KefuBase;
-use app\common\server\FileServer;
-use app\common\server\JsonServer;
-
-class File extends KefuBase
-{
-
-    public $like_not_need_login = [];
-
-    /**
-     * @notes upload
-     * @return \think\response\Json
-     * @author 段誉
-     * @date 2021/12/16 11:11
-     */
-    public function formImage()
-    {
-        try{
-            $data = FileServer::image(0, $this->shop_id, 0, 'uploads/kefu/'.$this->kefu_id);
-            return JsonServer::success('上传成功', $data);
-        }catch(\Exception $e) {
-            return JsonServer::error($e->getMessage());
-        }
-    }
-}

+ 0 - 109
app/kefuapi/http/middleware/Login.php

@@ -1,109 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-namespace app\kefuapi\http\middleware;
-
-
-use app\common\model\kefu\Kefu;
-use think\exception\ValidateException;
-use app\kefuapi\validate\TokenValidate;
-
-class Login
-{
-    /**
-     * 登录验证
-     * @param $request
-     * @param \Closure $next
-     * @return mixed|\think\response\Redirect
-     */
-    public function handle($request, \Closure $next)
-    {
-        //允许跨域调用
-        header('Access-Control-Allow-Origin: *');
-        header("Access-Control-Allow-Headers: Authorization, Sec-Fetch-Mode, DNT, X-Mx-ReqToken, Keep-Alive, User-Agent, If-Match, If-None-Match, If-Unmodified-Since, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Accept-Language, Origin, Accept-Encoding,Access-Token,token");
-        header('Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE');
-        header('Access-Control-Max-Age: 1728000');
-        header('Access-Control-Allow-Credentials:true');
-
-        if (strtoupper($request->method()) == "OPTIONS") {
-            return response();
-        }
-
-        $token = $request->header('token');
-
-        // 无需登录
-        if (empty($token) && $this->isNotNeedLogin($request)) {
-            return $next($request);
-        }
-
-        $validateError = '';
-        try {
-            validate(TokenValidate::class)->check(['token' => $token]);
-            $kefu_info = (new Kefu())->alias('k')
-                ->join('kefu_session ks', 'k.id = ks.kefu_id')
-                ->where(['ks.token' => $token])
-                ->field('k.*,ks.token,ks.client')
-                ->hidden(['password'])
-                ->findOrEmpty();
-
-            $kefu_info = $kefu_info ? $kefu_info->toArray() : [];
-
-            // 设置用户信息
-            $request->kefu_info = $kefu_info;
-
-            return $next($request);
-
-        } catch (ValidateException $e) {
-            $validateError = $e->getError();
-        }
-
-        //无需要登录,带token的情况
-        if ($this->isNotNeedLogin($request) && $token) {
-            return $next($request);
-        }
-
-        //登录失败
-        $result = array(
-            'code' => -1,
-            'show' => 1,
-            'msg' => $validateError,
-            'data' => []
-        );
-        return json($result);
-    }
-
-
-    /**
-     * @notes 是否需要登录
-     * @param $request
-     * @return bool // false-需要; true-不需要
-     * @author 段誉
-     * @date 2021/11/10 11:10
-     */
-    private function isNotNeedLogin($request)
-    {
-        $controllerObj = invoke('\\app\\kefuapi\\controller\\' . $request->controller());
-        $data = $controllerObj->like_not_need_login;
-        if (empty($data)) {
-            return false;
-        }
-        return in_array($request->action(), $data);
-    }
-
-}

+ 0 - 346
app/kefuapi/logic/ChatLogic.php

@@ -1,346 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-namespace app\kefuapi\logic;
-
-use app\common\basics\Logic;
-use app\common\enum\ChatRecordEnum;
-use app\common\model\kefu\ChatRecord;
-USE app\common\logic\ChatLogic as CommonChatLogic;
-use app\common\model\kefu\ChatRelation;
-use app\common\model\kefu\Kefu;
-use app\common\model\kefu\KefuLang;
-use app\common\model\order\Order;
-use app\common\model\user\User;
-use app\common\server\ConfigServer;
-use app\common\server\UrlServer;
-
-
-class ChatLogic extends Logic
-{
-
-    /**
-     * @notes 曾对话过的用户
-     * @param $kefu_id
-     * @param $shop_id
-     * @param $get
-     * @param $page
-     * @param $size
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2021/12/14 12:11
-     */
-    public static function getChatUserList($kefu_id, $shop_id, $get, $page, $size)
-    {
-        $where[] = ['kefu_id', '=', $kefu_id];
-        $where[] = ['shop_id', '=', $shop_id];
-
-        if (isset($get['nickname']) && $get['nickname']) {
-            $where[] = ['nickname', 'like', '%' . $get['nickname'] . '%'];
-        }
-
-        $online_user = CommonChatLogic::getOnlineUser();
-
-        $exp = 'update_time desc';
-        if (!empty($online_user)) {
-            $user_id = implode(",", $online_user);
-            $exp = "field(user_id," . $user_id . ") desc, update_time desc";
-        }
-
-        // 当前客服曾聊天的记录
-        $lists = ChatRelation::where($where)
-            ->page($page, $size)
-            ->orderRaw($exp)
-            ->select();
-
-        $count = ChatRelation::where($where)->count();
-
-        foreach ($lists as &$item) {
-            $item['online'] = 0;
-            if (in_array($item['user_id'], $online_user)) {
-                $item['online'] = 1;
-            }
-
-            if (empty($item['msg'])) {
-                $item['update_time'] = '';
-            }
-        }
-
-        return [
-            'list' => $lists->toArray(),
-            'page' => $page,
-            'size' => $size,
-            'count' => $count,
-            'more' => is_more($count, $page, $size)
-        ];
-    }
-
-
-    /**
-     * @notes 客服与用户的聊天记录
-     * @param $kefu_id
-     * @param $user_id
-     * @param $shop_id
-     * @param $page
-     * @param $size
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2021/12/14 14:41
-     */
-    public static function getChatRecord($kefu_id, $user_id, $shop_id, $page, $size)
-    {
-        $map1 = [
-            ['shop_id', '=', $shop_id],
-            ['from_id', '=', $kefu_id],
-            ['from_type', '=', 'kefu'],
-            ['to_id', '=', $user_id],
-            ['type', '=', ChatRecordEnum::TYPE_NORMAL]
-        ];
-        $map2 = [
-            ['shop_id', '=', $shop_id],
-            ['to_id', '=', $kefu_id],
-            ['to_type', '=', 'kefu'],
-            ['from_id', '=', $user_id],
-            ['type', '=', ChatRecordEnum::TYPE_NORMAL]
-        ];
-
-        // 聊天记录
-        $records = ChatRecord::whereOr([$map1, $map2])
-            ->order('id desc')
-            ->page($page, $size)
-            ->select()->toArray();
-
-        $count = ChatRecord::whereOr([$map1, $map2])->count();
-
-        $records = CommonChatLogic::formatChatRecords($records, $count, $page, $size);
-
-        return $records;
-    }
-
-
-    /**
-     * @notes 获取在线客服
-     * @param $shop_id
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2021/12/14 14:39
-     */
-    public static function getOnlineKefu($kefu_id, $shop_id)
-    {
-        $online = CommonChatLogic::getOnlineKefu($shop_id);
-
-        if (empty($online)) {
-            return [];
-        }
-
-        $map = [
-            ['id', 'in', $online],
-            ['id', '<>', $kefu_id],
-            ['shop_id', '=', $shop_id]
-        ];
-
-        $lists = Kefu::where($map)
-            ->field('id,nickname,avatar')
-            ->select()
-            ->toArray();
-
-        foreach ($lists as &$item) {
-            $item['avatar'] = UrlServer::getFileUrl($item['avatar']);
-        }
-        return $lists;
-    }
-
-
-    /**
-     * @notes 快捷回复列表
-     * @param $shop_id
-     * @param $keyword
-     * @param $page
-     * @param $size
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2021/12/15 11:07
-     */
-    public static function getReplyLists($shop_id, $keyword, $page, $size)
-    {
-        $condition[] = ['title', 'like', '%' . $keyword . '%'];
-
-        $lists = KefuLang::where(['shop_id' => $shop_id])
-            ->where($condition)
-            ->page($page, $size)
-            ->order('sort')
-            ->select();
-
-        $count = KefuLang::where(['shop_id' => $shop_id])->count();
-
-        return [
-            'list' => $lists,
-            'page' => $page,
-            'size' => $size,
-            'count' => $count,
-            'more' => is_more($count, $page, $size)
-        ];
-    }
-
-
-    /**
-     * @notes 用户信息接口
-     * @param $user_id
-     * @return array|bool
-     * @author 段誉
-     * @date 2021/12/15 15:05
-     */
-    public static function getUserInfo($user_id)
-    {
-        try {
-            $user = User::where(['id' => $user_id, 'del' => 0])->field([
-                'id', 'sn', 'nickname', 'avatar',
-                'level', 'mobile', 'total_order_amount',
-                'birthday', 'client', 'create_time'
-            ])->findOrEmpty()->append(['level_name', 'client_desc'])->toArray();
-
-            if (empty($user)) {
-                throw new \Exception('用户不存在');
-            }
-
-            $user['birthday'] = empty($user['birthday']) ? '-' : $user['birthday'];
-            $user['avatar'] = empty($user['avatar']) ? '' : UrlServer::getFileUrl($user['avatar']);
-            $user['mobile'] = empty($user['mobile']) ? '-' : substr_replace($user['mobile'],'****',3,4);
-
-            return $user;
-
-        } catch (\Exception $e) {
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-
-    /**
-     * @notes 订单列表
-     * @param $get
-     * @param $shop_id
-     * @param $page
-     * @param $size
-     * @return array|bool
-     * @author 段誉
-     * @date 2021/12/15 16:04
-     */
-    public static function getOrderLists($get, $shop_id, $page, $size)
-    {
-        try{
-            if (empty($get['user_id'])) {
-                throw new \Exception('参数缺失');
-            }
-
-            $condition[] = ['user_id', '=', $get['user_id']];
-            $condition[] = ['del', '=', 0];
-
-            if ($shop_id > 0) {
-                $condition[] = ['shop_id', '=', $shop_id];
-            }
-
-            if (isset($get['order_sn']) && $get['order_sn'] != '') {
-                $condition[] = ['order_sn', 'like', '%' . $get['order_sn'] . '%'];
-            }
-
-            $order = new Order();
-
-            $count = $order->with('order_goods')->where($condition)->count();
-
-            $lists = $order
-                ->where($condition)
-                ->with('order_goods')
-                ->field(['id', 'order_sn', 'order_type', 'order_status', 'order_amount', 'create_time'])
-                ->append(['order_status_text', 'order_type_text'])
-                ->page($page, $size)
-                ->order('id desc')
-                ->select()->toArray();
-
-            return [
-                'list' => $lists,
-                'page' => $page,
-                'size' => $size,
-                'count' => $count,
-                'more' => is_more($count, $page, $size)
-            ];
-
-        } catch (\Exception $e) {
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-
-    /**
-     * @notes 客服详情
-     * @param $id
-     * @return array
-     * @author 段誉
-     * @date 2021/12/15 17:34
-     */
-    public static function getKefuInfo($id)
-    {
-        $res = Kefu::where(['id' => $id])
-            ->field(['id', 'shop_id', 'nickname', 'avatar'])
-            ->findOrEmpty()
-            ->toArray();
-        $res['avatar'] = empty($res['avatar']) ? '' : UrlServer::getFileUrl($res['avatar']);
-
-        $online = CommonChatLogic::getOnlineKefu($res['shop_id']);
-
-        $res['online'] = 0;
-        if(in_array($res['id'], $online)) {
-            $res['online'] = 1;
-        }
-
-        return $res;
-    }
-
-
-    /**
-     * @notes 上传文件域名
-     * @return array
-     * @author 段誉
-     * @date 2021/12/16 17:05
-     */
-    public static function getConfig()
-    {
-        $web_favicon = ConfigServer::get('website', 'web_favicon');
-        return [
-            'base_domain' => UrlServer::getFileUrl(),
-            'web_favicon' => !empty($web_favicon) ? UrlServer::getFileUrl($web_favicon) : $web_favicon,
-            'company_name' => ConfigServer::get('copyright', 'company_name'),
-            'ws_domain' => env('project.ws_domain', 'ws:127.0.0.1')
-        ];
-    }
-
-}

+ 0 - 129
app/kefuapi/logic/LoginLogic.php

@@ -1,129 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-namespace app\kefuapi\logic;
-
-use app\common\basics\Logic;
-use app\common\enum\KefuEnum;
-use app\common\model\Admin;
-use app\common\model\kefu\KefuSession;
-use app\common\model\shop\ShopAdmin;
-use app\common\server\UrlServer;
-use think\facade\Config;
-
-/**
- * 客服登录逻辑
- * Class LoginLogic
- * @package app\shopapi\logic
- */
-class LoginLogic extends Logic
-{
-
-    /**
-     * @notes 账号密码登录
-     * @param $params
-     * @return mixed
-     * @throws \think\Exception
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2021/11/9 16:37
-     */
-    public static function accountLogin($params)
-    {
-        if (KefuEnum::TYPE_SHOP == $params['type']) {
-            $kefu = (new ShopAdmin())->alias('a')
-                ->field(['k.id', 'k.nickname', 'k.avatar', 'k.shop_id', 'a.account'])
-                ->join('kefu k', 'a.id = k.admin_id and a.shop_id = k.shop_id')
-                ->where(['a.account' => $params['account'], 'k.del' => 0])
-                ->findOrEmpty()->toArray();
-        } else {
-            $kefu = (new Admin())->alias('a')
-                ->field(['k.id', 'k.nickname', 'k.avatar', 'k.shop_id', 'a.account'])
-                ->join('kefu k', 'a.id = k.admin_id')
-                ->where(['a.account' => $params['account'], 'k.shop_id' => 0, 'k.del' => 0])
-                ->findOrEmpty()->toArray();
-        }
-
-        $kefu['avatar'] = !empty($kefu['avatar']) ? UrlServer::getFileUrl($kefu['avatar']) : "";
-
-        $kefu['token'] = self::createSession($kefu['id'], $kefu['shop_id'], $params['client']);
-
-        return $kefu;
-    }
-
-
-    /**
-     * @notes 退出登录
-     * @param $user_id
-     * @param $client
-     * @return KefuSession
-     * @author 段誉
-     * @date 2021/11/23 17:14
-     */
-    public static function logout($user_id, $client)
-    {
-        return (new KefuSession())
-            ->where(['kefu_id' => $user_id, 'client' => $client])
-            ->update(['update_time' => time(), 'expire_time' => time()]);
-    }
-
-
-    /**
-     * @notes 创建会话
-     * @param $admin_id
-     * @param $client
-     * @return string
-     * @author 段誉
-     * @date 2021/11/9 16:38
-     */
-    public static function createSession($kefu_id, $shop_id, $client)
-    {
-        $result = KefuSession::where(['kefu_id' => $kefu_id, 'client' => $client])->findOrEmpty();
-
-        $time = time();
-        $expire_time = $time + Config::get('project.token_expire_time');
-
-        // 新token
-        $token = md5($kefu_id . $client . $time);
-
-        $data = [
-            'shop_id' => $shop_id,
-            'kefu_id' => $kefu_id,
-            'token' => $token,
-            'client' => $client,
-            'update_time' => $time,
-            'expire_time' => $expire_time,
-        ];
-
-        if ($result->isEmpty()) {
-            KefuSession::create($data);
-        } else {
-            KefuSession::where([
-                'kefu_id' => $kefu_id,
-                'shop_id' => $shop_id,
-                'client' => $client,
-            ])->update($data);
-        }
-
-        return $token;
-    }
-
-
-}

+ 0 - 29
app/kefuapi/validate/ChatValidate.php

@@ -1,29 +0,0 @@
-<?php
-
-namespace app\kefuapi\validate;
-
-use app\common\basics\Validate;
-use app\common\model\user\User;
-
-
-class ChatValidate extends Validate
-{
-    protected $rule = [
-        'user_id' => 'require|checkUser',
-    ];
-
-    protected $message = [
-        'user_id.require' => '参数缺失',
-    ];
-
-    protected function checkUser($value, $rule, $data=[])
-    {
-        $user = User::where(['id' => $value])->findOrEmpty();
-
-        if ($user->isEmpty() || $user['del']) {
-            return '用户不存在';
-        }
-        return true;
-    }
-
-}

+ 0 - 122
app/kefuapi/validate/LoginValidate.php

@@ -1,122 +0,0 @@
-<?php
-
-namespace app\kefuapi\validate;
-
-use app\common\basics\Validate;
-use app\common\enum\KefuEnum;
-use app\common\logic\ChatLogic;
-use app\common\model\Admin;
-use app\common\model\shop\ShopAdmin;
-use think\facade\Cache;
-
-/**
- * 客服登录验证
- * Class LoginValidate
- * @package app\shopapi\validate
- */
-class LoginValidate extends Validate
-{
-    protected $rule = [
-        'type' => 'require',
-        'client' => 'require',
-        'account' => 'require',
-        'password' => 'require|checkPassword',
-    ];
-
-    protected $message = [
-        'type.require' => '参数缺失',
-        'account.require' => '请输入账号',
-        'password.require' => '请输入密码',
-        'password.checkPassword' => '账号或密码错误',
-        'client.require' => '请输入客户端'
-    ];
-
-
-    /**
-     * @notes 校验密码
-     * @param $password
-     * @param $other
-     * @param $data
-     * @return bool|string
-     * @author 段誉
-     * @date 2021/11/9 16:02
-     */
-    protected function checkPassword($password, $other, $data)
-    {
-        $field = 'k.id, k.shop_id, a.account, a.salt, a.password,
-         k.disable as kefu_disable, a.disable as admin_disable';
-
-        $condition = ['a.account' => $data['account'], 'k.del' => 0, 'a.del' => 0];
-
-        if (KefuEnum::TYPE_SHOP == $data['type']) {
-            $isPlatform = false;
-            $chat = (new ShopAdmin())->alias('a')
-                ->field($field)
-                ->join('kefu k', 'a.id = k.admin_id and a.shop_id = k.shop_id')
-                ->where($condition)
-                ->findOrEmpty();
-        } else {
-            $isPlatform = true;
-            $chat = (new Admin())->alias('a')
-                ->field($field)
-                ->join('kefu k', 'k.admin_id = a.id')
-                ->where(['k.shop_id' => 0])
-                ->where($condition)
-                ->findOrEmpty();
-        }
-
-        if (false === $this->safe(false, $isPlatform)) {
-            $this->message['password.password'] .= ':多次输入错误';
-            return false;
-        }
-
-        if ($chat->isEmpty()) {
-            $this->safe(true, $isPlatform);
-            return '账号不存在';
-        }
-
-        if ($chat['kefu_disable'] || $chat['admin_disable']) {
-            return '账号被禁用';
-        }
-
-        $password = generatePassword($password, $chat['salt']);
-        if ($password != $chat['password']) {
-            $this->safe(true, $isPlatform);
-            return false;
-        }
-
-        // 检查后台配置是否开启,当前缓存驱动是否redis
-        if (false === ChatLogic::checkConfig($chat['shop_id'])) {
-            return ChatLogic::getError() ?: '请联系管理员设置后台配置';
-        }
-
-        return true;
-    }
-
-    /**
-     * 连续30分钟内15次输错密码,无法登录
-     * @param bool $add
-     * @return bool
-     */
-    protected function safe($status = false, $isPlatform = false)
-    {
-        if ($isPlatform) {
-            $errorCount = 'platform_kefu_error_count' . request()->ip();
-        } else {
-            $errorCount = 'shop_kefu_error_count' . request()->ip();
-        }
-
-        if ($status) {
-            $loginErrorCount = Cache::get($errorCount);
-            $loginErrorCount++;
-            Cache::tag('kefu_login_error_count')->set($errorCount, $loginErrorCount, 1800);
-        }
-
-        $count = Cache::get($errorCount);
-
-        if (!empty($count) && $count >= 15) {
-            return false;
-        }
-        return true;
-    }
-}

+ 0 - 106
app/kefuapi/validate/TokenValidate.php

@@ -1,106 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-namespace app\kefuapi\validate;
-
-
-use app\common\basics\Validate;
-use app\common\model\Admin;
-use app\common\model\kefu\Kefu;
-use app\common\model\kefu\KefuSession;
-use app\common\model\shop\ShopAdmin;
-
-/**
- * 客服登录验证
- * Class TokenValidate
- * @package app\kefu\validate
- */
-class TokenValidate extends Validate
-{
-    protected $rule = [
-        'token' => 'require|valid|chat',
-    ];
-
-    /**
-     * @notes token验证
-     * @param $token
-     * @param $other
-     * @param $data
-     * @return bool|string
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2021/11/23 10:55
-     */
-    protected function valid($token, $other, $data)
-    {
-        $session = KefuSession::where(['token' => $token])->find();
-        if (empty($session)) {
-            return '会话失效,请重新登录';
-        }
-        if ($session['expire_time'] <= time()) {
-            return '登录超时,请重新登录';
-        }
-        return true;
-    }
-
-
-    /**
-     * @notes 用户验证
-     * @param $token
-     * @param $other
-     * @param $data
-     * @return bool|string
-     * @author 段誉
-     * @date 2021/11/23 17:29
-     */
-    protected function chat($token, $other, $data)
-    {
-        $kefu = (new Kefu())->alias('k')
-            ->join('kefu_session ks', 'k.id = ks.kefu_id')
-            ->where(['ks.token' => $token, 'k.del' => 0])
-            ->field('k.*,ks.token,ks.client')
-            ->hidden(['password'])
-            ->findOrEmpty();
-
-        if ($kefu->isEmpty()) {
-            return '用户不存在';
-        }
-
-        // 获取客服对应的管理员信息
-        if ($kefu['shop_id'] > 0) {
-            $kefu_admin = (new ShopAdmin())->where(['id' => $kefu['admin_id']])->findOrEmpty();
-        } else {
-            $kefu_admin = (new Admin())->where(['id' => $kefu['admin_id']])->findOrEmpty();
-        }
-
-        if ($kefu_admin->isEmpty()) {
-            return '关联管理员不存在';
-        }
-
-        if ($kefu['disable'] == 1 || $kefu_admin['disable'] == 1) {
-            return '用户被禁用';
-        }
-
-        return true;
-    }
-
-
-}

+ 0 - 26
app/shop/config/project.php

@@ -1,26 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-return [
-    //样式显示
-    'env_name' => env('project.env_name', '本地环境-'),
-    'admin_name' => env('project.admin_name', '商家后台'),
-    'theme_color' => 'layui-bg-blue',
-    'theme_button' => 'layui-btn-normal',
-];

+ 0 - 143
app/shop/controller/Admin.php

@@ -1,143 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-
-namespace app\shop\controller;
-
-
-use app\shop\logic\AdminLogic;
-use app\shop\validate\AdminPasswordValidate;
-use app\shop\validate\AdminValidate;
-use app\common\basics\ShopBase;
-use app\common\model\shop\ShopRole;
-use app\common\model\shop\ShopAdmin;
-use app\common\server\JsonServer;
-
-class Admin extends ShopBase
-{
-    /**
-     * Notes: 列表
-     * @author 段誉(2021/4/10 16:44)
-     * @return string|\think\response\Json
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     */
-    public function lists()
-    {
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            return JsonServer::success('获取成功', AdminLogic::lists($get, $this->shop_id));
-        }
-        return view('', ['role_lists' => (new ShopRole())->getRoleLists()]);
-    }
-
-
-    /**
-     * Notes: 添加
-     * @author 段誉(2021/4/10 16:44)
-     * @return string|\think\response\Json
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     */
-    public function add()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            $post['disable'] = isset($post['disable']) && $post['disable'] == 'on' ? 0 : 1;
-            (new AdminValidate())->goCheck('add');
-            if (AdminLogic::addAdmin($this->shop_id, $post)) {
-                return JsonServer::success('操作成功');
-            }
-            return JsonServer::error(AdminLogic::getError() ?: '操作失败');
-        }
-        return view('', [
-            'role_lists' => (new ShopRole())->getRoleLists(['shop_id' => $this->shop_id])
-        ]);
-    }
-
-    /**
-     * Notes: 编辑
-     * @author 段誉(2021/4/10 16:45)
-     * @return string
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     */
-    public function edit()
-    {
-        $id = $this->request->get('admin_id');
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            $post['disable'] = isset($post['disable']) && $post['disable'] == 'on' ? 0 : 1;
-            (new AdminValidate())->goCheck('edit');
-            if (AdminLogic::editAdmin($this->shop_id, $post)) {
-                return JsonServer::success('操作成功');
-            }
-            return JsonServer::error(AdminLogic::getError() ?: '操作失败');
-        }
-        return view('', [
-            'detail' => ShopAdmin::find($id),
-            'role_lists' => (new ShopRole())->getRoleLists(['shop_id' => $this->shop_id])
-        ]);
-    }
-
-
-    /**
-     * Notes: 删除
-     * @author 段誉(2021/4/14 15:25)
-     * @return \think\response\Json
-     */
-    public function del()
-    {
-        if ($this->request->isAjax()) {
-            $id = $this->request->post('admin_id');
-            if (AdminLogic::delAdmin($this->shop_id, $id)) {
-                return JsonServer::success('操作成功');
-            }
-            return JsonServer::error(AdminLogic::getError() ?: '操作失败');
-        }
-    }
-
-
-
-    /**
-     * Notes: 修改密码
-     * @author 段誉(2021/4/30 12:03)
-     * @return \think\response\Json|\think\response\View
-     */
-    public function password()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            $post['admin_id'] = $this->admin_id;
-            (new AdminPasswordValidate())->goCheck('', $post);
-            $res = AdminLogic::updatePassword($post['password'], $this->admin_id, $this->shop_id);
-            if ($res) {
-                return JsonServer::success('操作成功');
-            }
-            return JsonServer::error(AdminLogic::getError() ?: '系统错误');
-        }
-        return view('', [
-            'account' => $this->shop['account']
-        ]);
-    }
-
-}

+ 0 - 96
app/shop/controller/Alipay.php

@@ -1,96 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-namespace app\shop\controller;
-
-use app\common\basics\ShopBase;
-use app\common\server\JsonServer;
-use app\shop\logic\AlipayLogic;
-use app\shop\validate\AlipayValidate;
-
-class Alipay extends ShopBase
-{
-    function lists()
-    {
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            $lists = AlipayLogic::lists($get, $this->shop_id);
-            return JsonServer::success('获取成功', $lists);
-        }
-        
-        return view();
-    }
-    
-    function detail()
-    {
-        return view('', [
-            'detail'    => AlipayLogic::detail($this->request->get('id')),
-        ]);
-    }
-    
-    function add()
-    {
-        if ($this->request->isAjax()) {
-            (new AlipayValidate())->goCheck('add');
-            $post = $this->request->post();
-            $res = AlipayLogic::add($post, $this->shop_id);
-            if ($res === false) {
-                $error = AlipayLogic::getError() ?: '新增失败';
-                return JsonServer::error($error);
-            }
-            return JsonServer::success('新增成功');
-        }
-        
-        return view();
-    }
-    
-    function edit()
-    {
-        if ($this->request->isAjax()) {
-            (new AlipayValidate())->goCheck('edit');
-            $post = $this->request->post();
-            $res = AlipayLogic::edit($post, $this->shop_id);
-            if ($res === false) {
-                $error = AlipayLogic::getError() ?: '编辑失败';
-                return JsonServer::error($error);
-            }
-            return JsonServer::success('编辑成功');
-        }
-        
-        $id = $this->request->get('id');
-        return view('', [
-            'detail' => AlipayLogic::detail($id)
-        ]);
-    }
-    
-    function del()
-    {
-        if ($this->request->isAjax()) {
-            (new AlipayValidate())->goCheck('id');
-            $id = $this->request->post('id');
-            $res = AlipayLogic::del($id, $this->shop_id);
-            if ($res === false) {
-                $error = AlipayLogic::getError() ?: '删除失败';
-                return JsonServer::error($error);
-            }
-            return JsonServer::success('删除成功');
-        }
-        
-        return JsonServer::error('异常');
-    }
-}

+ 0 - 103
app/shop/controller/Bank.php

@@ -1,103 +0,0 @@
-<?php
-
-
-namespace app\shop\controller;
-
-
-use app\common\basics\ShopBase;
-use app\common\server\JsonServer;
-use app\shop\logic\BankLogic;
-use app\shop\validate\BankValidate;
-use think\facade\View;
-
-class Bank extends ShopBase
-{
-    /**
-     * @Notes: 银行卡列表
-     * @Author: 张无忌
-     */
-    public function lists()
-    {
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            $lists = BankLogic::lists($get, $this->shop_id);
-            return JsonServer::success('获取成功', $lists);
-        }
-
-        return view();
-    }
-
-    /**
-     * @Notes: 账号详细
-     * @Author: 张无忌
-     */
-    public function detail()
-    {
-        $id = $this->request->get('id');
-        View::assign('detail', BankLogic::detail($id));
-        return view();
-    }
-
-    /**
-     * @Notes: 新增银行卡
-     * @Author: 张无忌
-     */
-    public function add()
-    {
-        if ($this->request->isAjax()) {
-            (new BankValidate())->goCheck('add');
-            $post = $this->request->post();
-            $res = BankLogic::add($post, $this->shop_id);
-            if ($res === false) {
-                $error = BankLogic::getError() ?: '新增失败';
-                return JsonServer::error($error);
-            }
-            return JsonServer::success('新增成功');
-        }
-
-        return view();
-    }
-
-    /**
-     * @Notes: 编辑银行卡
-     * @Author: 张无忌
-     */
-    public function edit()
-    {
-        if ($this->request->isAjax()) {
-            (new BankValidate())->goCheck('edit');
-            $post = $this->request->post();
-            $res = BankLogic::edit($post);
-            if ($res === false) {
-                $error = BankLogic::getError() ?: '编辑失败';
-                return JsonServer::error($error);
-            }
-            return JsonServer::success('编辑成功');
-        }
-
-        $id = $this->request->get('id');
-        return view('', [
-            'detail' => BankLogic::detail($id)
-        ]);
-    }
-
-    /**
-     * @Notes: 删除银行卡
-     * @Author: 张无忌
-     */
-    public function del()
-    {
-        if ($this->request->isAjax()) {
-            (new BankValidate())->goCheck('id');
-            $id = $this->request->post('id');
-            $res = BankLogic::del($id);
-            if ($res === false) {
-                $error = BankLogic::getError() ?: '删除失败';
-                return JsonServer::error($error);
-            }
-            return JsonServer::success('删除成功');
-        }
-
-        return JsonServer::error('异常');
-    }
-}

+ 0 - 52
app/shop/controller/Common.php

@@ -1,52 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-namespace app\shop\controller;
-use app\common\server\JsonServer;
-use app\shop\logic\goods\CategoryLogic;
-use app\common\basics\ShopBase;
-use app\shop\logic\CommonLogic;
-
-class Common extends ShopBase{
-    public function selectGoods(){
-        if ($this->request->isAjax()){
-            $get = $this->request->get();
-            $get['shop_id'] = $this->shop_id;
-            $data = CommonLogic::getGoodsList($get);
-            return JsonServer::success('', $data);
-        }
-
-        $category_list = CategoryLogic::listAll($this->shop_id);
-        return view('', [
-            'category_list' => $category_list
-        ]);
-    }
-
-    public function selectGoodsTwo(){
-        if ($this->request->isAjax()){
-            $get = $this->request->get();
-            $get['shop_id'] = $this->shop_id;
-            $goods_list = CommonLogic::getGoodsListTwo($get,true);
-            return JsonServer::success('', $goods_list);
-        }
-        $category_list = CategoryLogic::listAll($this->shop_id);
-        return view('', [
-            'category_list' => $category_list
-        ]);
-    }
-}

+ 0 - 22
app/shop/controller/Dispatch.php

@@ -1,22 +0,0 @@
-<?php
-
-
-namespace app\shop\controller;
-
-
-use think\facade\View;
-
-class Dispatch
-{
-    /**
-     * @Notes: 错误提示
-     * @Author: 张无忌
-     * @param $msg
-     * @return \think\response\View
-     */
-    public static function dispatch_error($msg)
-    {
-        View::assign('msg', $msg);
-        return view('dispatch_error');
-    }
-}

+ 0 - 200
app/shop/controller/File.php

@@ -1,200 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-namespace app\shop\controller;
-
-
-use app\shop\logic\FileLogic;
-use app\common\basics\ShopBase;
-use app\common\server\JsonServer;
-
-class File extends ShopBase
-{
-    /**
-     * NOTE: 图片列表
-     * @author: 张无忌
-     */
-    public function lists()
-    {
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            $get['shop_id'] = $this->shop_id;
-            $lists = FileLogic::getFile($get);
-            return JsonServer::success('获取成功', $lists);
-        }
-        
-        $get = $this->request->get();
-        $get['type'] = $get['type'] ?? 10;
-        $get['shop_id'] = $get['shop_id'] ?? $this->shop_id;
-
-        return view('', [
-            'type'     => $get['type'],
-            'category' => json_encode(FileLogic::getCate($get))
-        ]);
-    }
-
-    /**
-     * NOTE: 移动文件
-     * @author: 张无忌
-     */
-    public function move()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            $res = FileLogic::move($post);
-            if ($res) {
-                return JsonServer::success('移动成功', FileLogic::getCate($post["type"]));
-            }
-
-            $error = FileLogic::getError() ?: '移动失败';
-            return JsonServer::error($error);
-        }
-
-        $get = $this->request->get();
-        $get['type'] = $get['type'] ?? 10; // 10 图片
-        $get['shop_id'] = $get['shop_id'] ?? $this->shop_id;
-        return view('', [
-            'categoryTree' => FileLogic::categoryToSelectThree($get)
-        ]);
-    }
-
-    /**
-     * NOTE: 删除文件
-     * @author: 张无忌
-     */
-    public function del()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            $res = FileLogic::del($post);
-            $data = [
-                'shop_id' => $this->shop_id,
-                'type' => $post['type']
-            ];
-            if ($res) {
-                return JsonServer::success('删除成功', FileLogic::getCate($data));
-            }
-
-            $error = FileLogic::getError() ?: '删除失败';
-            return JsonServer::error($error);
-        }
-
-        return JsonServer::error("请求异常");
-    }
-
-    /** ======================== 华丽的分割线, 下面是文件分类相关 ========================**/
-
-    /**
-     * NOTE: 新增分类
-     * @author: 张无忌
-     */
-    public function addCate()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            $post['shop_id'] = $this->shop_id;
-            $res = FileLogic::addCate($post);
-            $data = [
-                'type' => $post['type'],
-                'shop_id' => $this->shop_id
-            ];
-            if ($res) {
-                return JsonServer::success('新增成功', FileLogic::getCate($data));
-            }
-
-            $error = FileLogic::getError() ?: '新增失败';
-            return JsonServer::error($error);
-        }
-        $get = $this->request->get();
-        $get['type'] = $get['type'] ?? 10; // 10 图片
-        $get['shop_id'] = $get['shop_id'] ?? $this->shop_id;
-        return view('addCate', [
-            'categoryTree' => FileLogic::categoryToSelect($get)
-        ]);
-    }
-
-    /**
-     * NOTE: 编辑分类
-     * @author: 张无忌
-     */
-    public function editCate()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            $res = FileLogic::editCate($post);
-            if ($res) {
-                $data = [
-                    'type' => $post["type"],
-                    'shop_id' => $this->shop_id
-                ];
-                return JsonServer::success('编辑成功', FileLogic::getCate($data));
-            }
-
-            $error = FileLogic::getError() ?: '编辑失败';
-            return JsonServer::error($error);
-        }
-
-        $get = $this->request->get();
-        $get['shop_id'] = $this->shop_id;
-        return view('editCate', [
-            'detail'       => FileLogic::getCateById($get['id']),
-            'categoryTree' => FileLogic::categoryToSelect($get)
-        ]);
-    }
-
-    /**
-     * NOTE: 删除分类
-     * @author: 张无忌
-     */
-    public function delCate()
-    {
-        if ($this->request->isAjax()) {
-            $id = $this->request->post('id');
-            $type = $this->request->post('type');
-            $res = FileLogic::delCate($id);
-            $data = [
-                'shop_id' => $this->shop_id,
-                'type' => $type
-            ];
-            if ($res) {
-                return JsonServer::success('删除成功', FileLogic::getCate($data));
-            }
-
-            $error = FileLogic::getError() ?: '删除失败';
-            return JsonServer::error($error, FileLogic::getCate($data));
-        }
-
-        return JsonServer::error('请求异常');
-    }
-
-    /**
-     * 上传视频列表
-     */
-    public function videoList()
-    {
-        $get = [
-            'type' => 20,
-            'shop_id' => $this->shop_id
-        ];
-        return view('', [
-            'type'     => $get['type'], // 视频
-            'category' => json_encode(FileLogic::getCate($get))
-        ]);
-    }
-}

+ 0 - 168
app/shop/controller/Freight.php

@@ -1,168 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-namespace app\shop\controller;
-
-use app\common\logic\ExpressLogic;
-use app\common\logic\FreightLogic;
-use app\common\model\Freight as FreightModel;
-use app\admin\validate\FreightValidate;
-use app\common\basics\ShopBase;
-use app\common\server\ConfigServer;
-use app\common\server\JsonServer;
-use think\exception\ValidateException;
-
-
-/**
- * 运费模板设置
- * Class Freight
- * @package app\shop\controller
- */
-class Freight extends ShopBase
-{
-
-    /**
-     * User: 意象信息科技 mjf
-     * Desc: 设置快递方式
-     */
-    public function set()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            $post['type'] = isset($post['type']) && $post['type'] == 'on' ? 1 : 0;
-            ConfigServer::set('express', 'is_express', $post['type']);
-            return JsonServer::success('操作成功');
-        }
-        $type = ConfigServer::get('express', 'is_express');
-        return view('', [
-            'type' => $type
-        ]);
-    }
-
-    /**
-     * User: 意象信息科技 mjf
-     * Desc: 运费模板列表
-     */
-    public function lists()
-    {
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            $get['shop_id'] = $this->shop_id;
-            return JsonServer::success('获取成功', FreightLogic::lists($get));//运费模板页
-        }
-        return view('index', [
-            'charge_way_lists' => FreightModel::getChargeWay(true),
-            'config'=>ExpressLogic::getExpress()
-        ]);
-    }
-
-    /**
-     * User: 意象信息科技 mjf
-     * Desc: 添加运费模板
-     */
-    public function add()
-    {
-        if ($this->request->isAjax()) {
-            try {
-                $post = $this->request->post();
-                validate(FreightValidate::class)->scene('add')->check($post);
-                $post['shop_id'] = $this->shop_id;
-                FreightLogic::add($post);
-                return JsonServer::success('添加成功');
-            } catch (ValidateException $e) {
-                return JsonServer::error($e->getMessage());
-            }
-        }
-        return view('',[]);
-    }
-
-    /**
-     * User: 意象信息科技 mjf
-     * Desc: 删除运费模板
-     */
-    public function del()
-    {
-        if ($this->request->isAjax()) {
-            try {
-                $post = $this->request->post();
-                validate(FreightValidate::class)->scene('del')->check($post);
-                FreightLogic::del($post);
-                return JsonServer::success('删除成功');
-            } catch (ValidateException $e) {
-                return JsonServer::error($e->getMessage());
-            }
-        }
-        return view('',[]);
-    }
-
-    /**
-     * User: 意象信息科技 mjf
-     * Desc: 运费模板详情
-     */
-    public function detail()
-    {
-        $id = $this->request->get('id');
-        $detail = FreightLogic::detail($id);
-        return view('',[
-            'detail'=>$detail
-        ]);
-    }
-
-
-    /**
-     * User: 意象信息科技 mjf
-     * Desc: 运费模板编辑
-     */
-    public function edit()
-    {
-        if ($this->request->isAjax()) {
-            try {
-                $post = $this->request->post();
-                validate(FreightValidate::class)->scene('edit')->check($post);
-                FreightLogic::edit($post);
-                return JsonServer::success('编辑成功');
-            } catch (ValidateException $e) {
-                return JsonServer::error($e->getMessage());
-            }
-
-        }
-        $id = $this->request->get('id');
-
-        $detail = FreightLogic::detail($id);
-
-        return view('',[
-            'detail'=>$detail
-        ]);
-    }
-
-
-
-    public function area()
-    {
-        return view();
-    }
-
-    //编辑页的地区选择
-    public function areaEdit()
-    {
-        return view();
-    }
-
-
-}

+ 0 - 79
app/shop/controller/Index.php

@@ -1,79 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-
-namespace app\shop\controller;
-
-
-use app\common\basics\ShopBase;
-use app\common\model\shop\ShopRole;
-use app\common\server\ConfigServer;
-use app\common\server\JsonServer;
-use app\shop\logic\index\StatLogic;
-use app\shop\server\MenuServer;
-use think\facade\Config;
-
-class Index extends ShopBase
-{
-    /**
-     * 后台前端全局界面
-     * @return mixed
-     */
-    public function index()
-    {
-        return view('', [
-            'config' => [
-                'name' => ConfigServer::get('website', 'name'),
-                'web_favicon' => ConfigServer::get('website', 'web_favicon'),
-                'backstage_logo' => ConfigServer::get('website_shop', 'shop_admin_logo'),//主页左上角logo
-            ],
-            'menu' => MenuServer::getMenuTree($this->shop['role_id']), // 菜单渲染
-            'view_app_trace' => Config::get('app.app_trace'), // 开启右上角前端示例
-            'admin_name' => $this->shop['name'],//管理员名称
-            'shop_name' => $this->shop_name,//门店名称
-            'role_name' => (new ShopRole())->getRoleName($this->shop['role_id']), // 角色名称
-        ]);
-    }
-
-    /**
-     * 工作台
-     * @return mixed
-     */
-    public function stat()
-    {
-        if($this->request->isAjax()){
-            return JsonServer::success('', StatLogic::graphData($this->shop_id));
-        }
-        return view('', [
-            'res' => StatLogic::stat($this->shop_id)
-        ]);
-    }
-    
-    /**
-     * 工作台商品数据
-     * @return mixed
-     */
-    public function shop()
-    {
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            return JsonServer::success('', StatLogic::goodsLists($get,$this->shop_id));
-        }
-    }
-}

+ 0 - 63
app/shop/controller/Login.php

@@ -1,63 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-
-namespace app\shop\controller;
-
-
-use app\shop\logic\LoginLogic;
-use app\shop\validate\LoginValidate;
-use app\common\basics\ShopBase;
-use app\common\server\JsonServer;
-
-class Login extends ShopBase
-{
-    public $like_not_need_login = ['login'];
-
-    /**
-     * Notes: 登录
-     * @author FZR(2021/1/28 15:08)
-     */
-    public function login()
-    {
-        if ($this->request->isAjax()) {
-            $post = request()->post();
-            (new LoginValidate())->goCheck();
-            if (LoginLogic::login($post)){
-                return JsonServer::success('登录成功');
-            }
-            $error = LoginLogic::getError() ?: '登录失败';
-            return JsonServer::error($error);
-        }
-        return view('', [
-            'account'  => cookie('account'),
-            'config'  => LoginLogic::config(),
-        ]);
-    }
-
-    /**
-     * Notes: 退出登录
-     * @author FZR(2021/1/28 18:44)
-     */
-    public function logout()
-    {
-        LoginLogic::logout();
-        $this->redirect(url('login/login'));
-    }
-}

+ 0 - 114
app/shop/controller/Role.php

@@ -1,114 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-
-namespace app\shop\controller;
-
-use app\shop\logic\RoleLogic;
-use app\shop\validate\RoleValidate;
-use app\common\basics\ShopBase;
-use app\common\server\JsonServer;
-
-class Role extends ShopBase
-{
-    /**
-     * Notes: 列表
-     * @author 段誉(2021/4/13 10:34)
-     * @return string|\think\response\Json
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     */
-    public function lists()
-    {
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            return JsonServer::success('', RoleLogic::lists($this->shop_id, $get));
-        }
-        return view();
-    }
-
-
-    /**
-     * Notes: 添加
-     * @author 段誉(2021/4/13 10:34)
-     * @return string|\think\response\Json
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     */
-    public function add()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            (new RoleValidate())->goCheck('add');
-            $result = RoleLogic::addRole($this->shop_id, $post);
-            if ($result !== true) {
-                return JsonServer::error(RoleLogic::getError() ?: '操作失败');
-            }
-            return JsonServer::success('操作成功');
-        }
-        return view('', [
-            'auth_tree' => json_encode(RoleLogic::authTree(), true)
-        ]);
-    }
-
-
-    /**
-     * Notes: 编辑
-     * @param string $role_id
-     * @author 段誉(2021/4/13 10:34)
-     * @return string|\think\response\Json
-     * @throws \think\Exception
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     */
-    public function edit($role_id = '')
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            (new RoleValidate())->goCheck('edit');
-            $result = RoleLogic::editRole($this->shop_id, $post);
-            if ($result !== true) {
-                return JsonServer::error(RoleLogic::getError() ?: '操作失败');
-            }
-            return JsonServer::success('操作成功');
-        }
-        $auth_tree = RoleLogic::authTree($role_id);
-
-        return view('', [
-            'info' => RoleLogic::roleInfo($role_id),
-            'auth_tree' => json_encode($auth_tree),
-        ]);
-    }
-
-    /**
-     * Notes: 删除
-     * @param $role_id
-     * @author 段誉(2021/4/13 10:35)
-     * @return \think\response\Json
-     * @throws \think\Exception
-     */
-    public function del($id)
-    {
-        if ($this->request->isAjax()) {
-            (new RoleValidate())->goCheck('del');
-            RoleLogic::delRole($this->shop_id, $id);
-            return JsonServer::success('删除成功');
-        }
-    }
-}

+ 0 - 165
app/shop/controller/Seckill.php

@@ -1,165 +0,0 @@
-<?php
-declare (strict_types = 1);
-
-namespace app\shop\controller;
-
-use app\common\basics\ShopBase;
-use think\Request;
-use app\shop\logic\SeckillLogic;
-
-class Seckill extends ShopBase
-{
-    public function lists(){
-        //  xxxx/shop/controller/method
-        $seckill_time = SeckillLogic::getTimeAll();
-        $this->assign('seckill',$seckill_time);
-        return $this->fetch();
-    }
-    /**
-     * note 秒杀商品
-     * create_time 2020/11/13 16:01
-     */
-    public function goodsLists(){
-        if($this->request->isAjax()){
-            $get = $this->request->get();
-            $list = SeckillLogic::goodsList($get);
-            $this->_success('',$list);
-        }
-    }
-    /**
-     * note 秒杀时间
-     * create_time 2020/11/13 16:01
-     */
-    public function timeLists(){
-        if($this->request->isAjax()){
-            $get= $this->request->get();
-            $list = SeckillLogic::timeList($get);
-            $this->_success('',$list);
-        }
-    }
-    /**
-     * note 添加秒杀时间段
-     * create_time 2020/11/13 16:01
-     */
-    public function addTime(){
-        if($this->request->isAjax()){
-            $post = $this->request->post();
-            $result = $this->validate($post, 'app\admin\validate\SeckillTime');
-            if($result === true){
-                SeckillLogic::addTime($post);
-                $this->_success('新增成功','');
-            }
-            $this->_error($result,'');
-
-
-        }
-        return $this->fetch();
-    }
-
-    /**
-     * note 编辑秒杀时间段
-     * create_time 2020/11/13 16:02
-     */
-    public function editTime($id){
-        if($this->request->isAjax()){
-            $post = $this->request->post();
-            $result = $this->validate($post, 'app\admin\validate\SeckillTime');
-            if($result === true){
-                SeckillLogic::editTime($post);
-                $this->_success('编辑成功','');
-            }
-            $this->_error($result,'');
-        }
-        $this->assign('detail',SeckillLogic::getTime($id));
-        return $this->fetch();
-    }
-
-    /**
-     * note 删除秒杀时间段
-     * create_time 2020/11/13 16:02
-     */
-    public function delTime(){
-        if($this->request->isAjax()){
-            $id = $this->request->post('id');
-            $result = SeckillLogic::delTime($id);
-
-            if($result == true){
-                $this->_success('删除成功','');
-            }
-            return $this->_error('删除失败','');
-
-
-        }
-    }
-    /**
-     * note 添加秒杀商品
-     * create_time 2020/11/13 16:02
-     */
-    public function addGoods(){
-        if($this->request->isAjax()){
-            $post = $this->request->post();
-            $post['item'] = form_to_linear($post);
-            $result = $this->validate($post,'app\admin\validate\SeckillGoods.add');
-            if($result === true){
-                $result = SeckillLogic::addGoods($post);
-                if($result){
-                    $this->_success('新增成功','');
-                }
-                $result = '新增失败';
-            }
-            $this->_error($result);
-
-        }
-
-        $seckill_time = SeckillLogic::getTimeAll();
-        $this->assign('seckill',$seckill_time);
-        return $this->fetch();
-    }
-    /**
-     * note 编辑秒杀商品
-     * create_time 2020/11/13 16:02
-     */
-    public function editGoods(){
-        if($this->request->isAjax()){
-            $post = $this->request->post();
-            $post['item'] = form_to_linear($post);
-            $result = $this->validate($post,'app\admin\validate\SeckillGoods.edit');
-            if($result === true){
-                $result = SeckillLogic::editGoods($post);
-                if($result){
-                    $this->_success('编辑成功','');
-                }
-                $result = '编辑失败';
-            }
-            $this->_error($result);
-
-
-        }
-        $id = $this->request->get('id');
-        $seckill_id = $this->request->get('seckill_id');
-
-        $detail = SeckillLogic::getSeckillGoods($id,$seckill_id);
-        $seckill_time = SeckillLogic::getTimeAll();
-        $this->assign('seckill',$seckill_time);
-        $this->assign('detail',$detail);
-        return $this->fetch();
-    }
-
-    /**
-     * note 删除秒杀商品
-     * create_time 2020/11/13 16:05
-     */
-    public function delGoods(){
-        if($this->request->isAjax()){
-            $id = $this->request->post('id');
-            $seckill_id = $this->request->post('seckill_id');
-            $result = SeckillLogic::delGoods($id,$seckill_id);
-
-            if($result == true){
-                $this->_success('删除成功','');
-            }
-            return $this->_error('删除失败','');
-        }
-    }
-
-}

+ 0 - 72
app/shop/controller/Statistics.php

@@ -1,72 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-
-namespace app\shop\controller;
-
-
-use app\common\basics\ShopBase;
-use app\common\server\JsonServer;
-use app\shop\logic\StatisticsLogic;
-
-
-/**
- * 数据统计
- * Class Statistics
- * @package app\admin\controller
- */
-class Statistics extends ShopBase
-{
-   
-    //交易分析
-    public function trading()
-    {
-        if($this->request->isAjax()){
-            $post = $this->request->post();
-            $res = StatisticsLogic::trading($post,$this->shop_id);
-            return JsonServer::success('',$res);
-        }
-        return view();
-    }
-
-
-    //访问分析
-    public function visit()
-    {
-        if($this->request->isAjax()){
-            $post = $this->request->post();
-            $res = StatisticsLogic::visit($post,$this->shop_id);
-            return JsonServer::success('',$res);
-        }
-        return view();
-    }
-
-
-    //商品分析
-    public function goods()
-    {
-        if($this->request->isAjax()){
-            $get= $this->request->get();
-            $res = StatisticsLogic::goods($get,$this->shop_id);
-            return JsonServer::success('',$res);
-        }
-        return view();
-    }
-
-}

+ 0 - 43
app/shop/controller/Store.php

@@ -1,43 +0,0 @@
-<?php
-
-
-namespace app\shop\controller;
-
-
-use app\common\basics\ShopBase;
-use app\common\server\ConfigServer;
-use app\common\server\JsonServer;
-use app\shop\logic\StoreLogic;
-
-class Store extends ShopBase
-{
-    /**
-     * @Notes: 商家设置
-     * @Author: 张无忌
-     */
-    public function index()
-    {
-        return view('', [
-            'detail' => StoreLogic::detail($this->shop_id),
-            'tx_map_key' => ConfigServer::get('map', 'tx_map_key')
-        ]);
-    }
-
-    /**
-     * @Notes: 编辑商家
-     * @Author: 张无忌
-     */
-    public function edit()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            $res = StoreLogic::edit($post);
-            if ($res === false) {
-                $error = StoreLogic::getError() ?: '更新失败';
-                return JsonServer::error($error);
-            }
-            return JsonServer::success('更新成功');
-        }
-        return JsonServer::error('异常');
-    }
-}

+ 0 - 63
app/shop/controller/Upload.php

@@ -1,63 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-namespace app\shop\controller;
-
-
-use app\common\basics\ShopBase;
-use app\common\server\FileServer;
-use app\common\server\JsonServer;
-use Exception;
-
-class Upload extends ShopBase
-{
-//    public $like_not_need_login = ['image'];
-
-    /**
-     * NOTE: 上传图片
-     * @author: 张无忌
-     */
-    public function image()
-    {
-        try {
-
-            $cid = $this->request->post('cid');
-            $result = FileServer::image($cid, $this->shop_id);
-
-            return JsonServer::success("上传成功", $result);
-        } catch (Exception $e) {
-            return JsonServer::error($e->getMessage());
-        }
-    }
-
-    /**
-     * 上传视频
-     */
-    public function video()
-    {
-        try {
-            $cid = $this->request->post('cid');
-            $result = FileServer::video($cid, $this->shop_id);
-
-            return JsonServer::success("上传成功", $result);
-        } catch (Exception $e) {
-            return JsonServer::error($e->getMessage());
-        }
-    }
-}

+ 0 - 131
app/shop/controller/activity_area/Goods.php

@@ -1,131 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-namespace app\shop\controller\activity_area;
-
-use app\common\basics\ShopBase;
-use app\common\server\JsonServer;
-use think\facade\View;
-use app\shop\logic\activity_area\AreaLogic;
-use app\shop\logic\activity_area\GoodsLogic;
-use app\shop\validate\activity_area\ActivityGoodsValidate;
-
-/**
- * Class Goods
- * @package app\shop\controller\activity_area
- */
-class Goods extends ShopBase
-{
-
-    /**
-     * @notes 活动专区商品列表
-     * @return \think\response\Json|\think\response\View
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author suny
-     * @date 2021/7/14 10:12 上午
-     */
-    public function lists()
-    {
-
-        $shop_id = $this->shop_id;
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            $get['shop_id'] = $shop_id;
-            $list = GoodsLogic::lists($get);
-            return JsonServer::success('获取成功', $list);
-        }
-        $activity_area = AreaLogic::getActivityAreaAll();
-        $num = GoodsLogic::getNum($shop_id);
-        View::assign('num', $num);
-        View::assign('activity_area', $activity_area);
-        return View();
-    }
-
-    /**
-     * @notes 新增活动专区商品
-     * @return \think\response\Json|\think\response\View
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author suny
-     * @date 2021/7/14 10:12 上午
-     */
-    public function add()
-    {
-
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            $shop_id = $this->shop_id;
-            $post['shop_id'] = $shop_id;
-            $post['del'] = 0;
-
-            (new ActivityGoodsValidate())->goCheck('add', $post);
-            GoodsLogic::add($post);
-            return JsonServer::success('添加成功');
-        }
-        $activity_area = AreaLogic::getActivityAreaAll();
-        View::assign('activity_area', $activity_area);
-        return View();
-    }
-
-    /**
-     * @notes 编辑活动商品
-     * @return \think\response\Json|\think\response\View
-     * @author suny
-     * @date 2021/7/14 10:12 上午
-     */
-    public function edit()
-    {
-
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            $post['del'] = 0;
-            (new ActivityGoodsValidate())->goCheck('edit', $post);
-            $result = GoodsLogic::edit($post);
-            if ($result) {
-                return JsonServer::success('编辑成功');
-            }
-            return JsonServer::error('编辑失败');
-        }
-        $goods_id = $this->request->get('goods_id');
-        $activity_id = $this->request->get('activity_id');
-        View::assign('activity_list', GoodsLogic::getActivityList());
-        View::assign('info', GoodsLogic::getActivityGoods($goods_id, $activity_id));
-        return View();
-    }
-
-    /**
-     * @notes 删除活动商品
-     * @return \think\response\Json
-     * @author suny
-     * @date 2021/7/14 10:12 上午
-     */
-    public function del()
-    {
-
-        $id = $this->request->post('id', '', 'intval');
-        $result = GoodsLogic::del($id);
-        if ($result == true) {
-            return JsonServer::success('删除成功');
-        }
-        return JsonServer::error('删除失败');
-    }
-
-}

+ 0 - 190
app/shop/controller/after_sale/AfterSale.php

@@ -1,190 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-
-namespace app\shop\controller\after_sale;
-
-
-use app\common\basics\ShopBase;
-use app\common\server\JsonServer;
-use app\common\model\after_sale\AfterSale as AfterSaleModel;
-use app\shop\logic\after_sale\AfterSaleLogic;
-
-
-/**
- * 售后退款管理
- * Class Goods
- */
-class AfterSale extends ShopBase
-{
-    /**
-     * @notes 售后列表
-     * @return \think\response\Json|\think\response\View
-     * @author suny
-     * @date 2021/7/14 10:12 上午
-     */
-    public function lists()
-    {
-
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            return JsonServer::success('', AfterSaleLogic::list($get, $this->shop_id));
-        }
-        $data = AfterSaleLogic::list([], $this->shop_id);
-        // 售后状态
-        $status = AfterSaleModel::getStatusDesc(true);
-        $status = AfterSaleLogic::getStatus($status, $this->shop_id);
-        $all = AfterSaleLogic::getAll($this->shop_id);
-        return view('', [
-            'data' => $data,
-            'all' => $all,
-            'status' => $status
-        ]);
-    }
-
-    /**
-     * @notes 售后详情
-     * @return \think\response\View
-     * @author suny
-     * @date 2021/7/14 10:13 上午
-     */
-    public function detail()
-    {
-
-        $id = $this->request->get('id');
-        $detail = AfterSaleLogic::getDetail($id,$this->shop_id);
-        return view('', [
-            'detail' => $detail
-        ]);
-    }
-
-    /**
-     * @notes 同意
-     * @return \think\response\Json
-     * @author suny
-     * @date 2021/7/14 10:13 上午
-     */
-    public function agree()
-    {
-
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            $data = AfterSaleLogic::agree($post['id'], $this->shop_id);
-            if($data !== false){
-                return JsonServer::success('操作成功');
-            }else{
-                return JsonServer::error('该退款申请已撤销');
-            }
-        }
-    }
-
-    /**
-     * @notes 拒绝
-     * @return \think\response\Json
-     * @author suny
-     * @date 2021/7/14 10:13 上午
-     */
-    public function refuse()
-    {
-
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            AfterSaleLogic::refuse($post, $this->shop_id);
-            return JsonServer::success('操作成功');
-        }
-
-    }
-
-    /**
-     * @notes 收货
-     * @return \think\response\Json
-     * @author suny
-     * @date 2021/7/14 10:13 上午
-     */
-    public function take()
-    {
-
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            AfterSaleLogic::takeGoods($post, $this->admin_id);
-            return JsonServer::success('操作成功');
-        }
-    }
-
-    /**
-     * @notes 拒绝收货
-     * @return \think\response\Json
-     * @author suny
-     * @date 2021/7/14 10:13 上午
-     */
-    public function refuseGoods()
-    {
-
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            AfterSaleLogic::refuseGoods($post, $this->admin_id);
-            return JsonServer::success('操作成功');
-        }
-    }
-
-
-    /**
-     * @notes 确认退款
-     * @return \think\response\Json|\think\response\View
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
-     * @author suny
-     * @date 2021/7/14 10:13 上午
-     */
-    public function confirm()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            $confirm = AfterSaleLogic::confirm($post, $this->admin_id);
-            if($confirm !== true){
-                return JsonServer::error($confirm,[],0,0);
-            }
-            return JsonServer::success('操作成功');
-        }
-        $id = $this->request->get('id');
-        $refund_price = $this->request->get('refund_price');
-        return view('',['id'=>$id,'refund_price'=>$refund_price]);
-    }
-
-
-    /**
-     * @notes 导出Excel
-     * @return \think\response\Json
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2022/4/24 10:20
-     */
-    public function export()
-    {
-        $params = $this->request->get();
-        $result = AfterSaleLogic::list($params, $this->shop_id, true);
-        if(false === $result) {
-            return JsonServer::error(AfterSaleLogic::getError() ?: '导出失败');
-        }
-        return JsonServer::success('', $result);
-    }
-}

+ 0 - 249
app/shop/controller/bargain/Bargain.php

@@ -1,249 +0,0 @@
-<?php
-
-namespace app\shop\controller\bargain;
-
-use app\common\basics\ShopBase;
-use app\common\server\ConfigServer;
-use app\common\server\JsonServer;
-use app\shop\logic\bargain\BargainLogic;
-use think\facade\View;
-use app\shop\validate\BargainValidate;
-
-/**
- * Class Bargain
- * @package app\shop\controller\bargain
- */
-class Bargain extends ShopBase
-{
-
-    /**
-     * @notes 砍价活动 商品列表
-     * @return string|\think\response\Json
-     * @author suny
-     * @date 2021/7/14 10:13 上午
-     */
-    public function activity()
-    {
-
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            $get['shop_id'] = $this->shop_id;
-            $lists = BargainLogic::activity($get);
-            return JsonServer::success('获取成功', $lists);
-        }
-        $num = BargainLogic::getNum($this->shop_id);
-        View::assign('num', $num);
-        return View::fetch('bargain/activity');
-    }
-
-    /**
-     * @notes 新增砍价活动 商品
-     * @return string|\think\response\Json
-     * @author suny
-     * @date 2021/7/14 10:13 上午
-     */
-    public function add()
-    {
-
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            $post['shop_id'] = $this->shop_id;
-            (new BargainValidate())->goCheck('add', $post);
-            $result = BargainLogic::add($post);
-            if ($result) {
-                return JsonServer::success('新增成功');
-            } else {
-                $error = BargainLogic::getError() ?? '新增失败';
-                return JsonServer::error($error);
-            }
-        }
-        return View::fetch('bargain/add');
-    }
-
-    /**
-     * @notes 编辑活动 商品
-     * @return string|\think\response\Json
-     * @author suny
-     * @date 2021/7/14 10:14 上午
-     */
-    public function edit()
-    {
-
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            (new BargainValidate())->goCheck('edit', $post);
-            if (BargainLogic::edit($post)) {
-                return JsonServer::success('编辑成功');
-            } else {
-                $error = BargainLogic::getError() ?? '编辑失败';
-                return JsonServer::error($error);
-            }
-        }
-
-        $id = $this->request->get('id');
-        $detail = BargainLogic::getDetail($id);
-        View::assign('detail', $detail);
-        return View::fetch('bargain/edit');
-    }
-
-    /**
-     * @notes 停止活动
-     * @return \think\response\Json
-     * @author suny
-     * @date 2021/7/14 10:14 上午
-     */
-    public function stop()
-    {
-
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            if (BargainLogic::stop($post)) {
-                return JsonServer::success('更新成功');
-            } else {
-                $error = BargainLogic::getError() ?? '更新失败';
-                return JsonServer::error($error);
-            }
-        }
-    }
-
-    /**
-     * @notes 开启活动
-     * @return \think\response\Json
-     * @author suny
-     * @date 2021/7/14 10:14 上午
-     */
-    public function start()
-    {
-
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            if (BargainLogic::start($post)) {
-                return JsonServer::success('更新成功');
-            } else {
-                $error = BargainLogic::getError() ?? '更新失败';
-                return JsonServer::error($error);
-            }
-        }
-    }
-
-    /**
-     * @notes 砍价订单列表
-     * @return string|\think\response\Json
-     * @author suny
-     * @date 2021/7/14 10:14 上午
-     */
-    public function launch()
-    {
-
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            $get['shop_id'] = $this->shop_id;
-            $lists = BargainLogic::getLaunch($get);
-            return JsonServer::success('OK', $lists);
-        }
-
-        $bargain_id = $this->request->get('bargain_id', 0);
-        View::assign('bargain_id', $bargain_id);
-        return View::fetch('bargain/launch');
-    }
-
-    /**
-     * @notes 砍价订单详情
-     * @return string
-     * @author suny
-     * @date 2021/7/14 10:14 上午
-     */
-    public function detail()
-    {
-
-        $id = $this->request->get('id');
-        $detail = BargainLogic::getLaunchDetail($id);
-        View::assign('detail', $detail);
-        return View::fetch('bargain/detail');
-    }
-
-    /**
-     * @notes 砍价订单记录
-     * @return \think\response\Json
-     * @author suny
-     * @date 2021/7/14 10:14 上午
-     */
-    public function knifeOrderRecord()
-    {
-
-        $launch_id = $this->request->get('launch_id');
-        $get = $this->request->get();
-        $lists = BargainLogic::getKnifeOrderRecord($launch_id, $get);
-        return JsonServer::success('获取成功', $lists);
-    }
-
-    /**
-     * @notes 砍价助力记录
-     * @return \think\response\Json
-     * @author suny
-     * @date 2021/7/14 10:14 上午
-     */
-    public function knifeRecord()
-    {
-
-        $launch_id = $this->request->get('launch_id');
-        $get = $this->request->get();
-        $lists = BargainLogic::getKnifeRecord($launch_id, $get);
-        return JsonServer::success('获取成功', $lists);
-    }
-
-    /**
-     * @notes 砍价活动详情
-     * @return \think\response\View
-     * @author suny
-     * @date 2021/7/14 10:14 上午
-     */
-    public function bargain_detail()
-    {
-
-        $get = $this->request->get();
-        $detail = BargainLogic::detail($get);
-        View::assign('detail', $detail);
-        return View('bargain/bargain_detail');
-    }
-
-    /**
-     * @notes 删除
-     * @return \think\response\Json
-     * @author suny
-     * @date 2021/7/14 10:14 上午
-     */
-    public function del()
-    {
-
-        if ($this->request->isAjax()) {
-            $id = $this->request->post('id');
-            if (BargainLogic::softDelete($id)) {
-                return JsonServer::success('删除成功');
-            } else {
-                $error = BargainLogic::getError() ?? '删除失败';
-                return JsonServer::error($error);
-            }
-        }
-    }
-
-    /**
-     * @notes 结束砍价
-     * @return \think\response\Json
-     * @author suny
-     * @date 2021/7/14 10:14 上午
-     */
-    public function close()
-    {
-
-        if ($this->request->isAjax()) {
-            $id = $this->request->post('id');
-            if (BargainLogic::close($id)) {
-                return JsonServer::success('结束砍价成功');
-            } else {
-                $error = BargainLogic::getError() ?? '结束砍价失败';
-                return JsonServer::error($error);
-            }
-        }
-    }
-}

+ 0 - 169
app/shop/controller/coupon/Coupon.php

@@ -1,169 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-namespace app\shop\controller\coupon;
-
-use app\common\basics\ShopBase;
-use app\common\server\JsonServer;
-use app\shop\logic\coupon\CouponLogic;
-use app\shop\validate\coupon\CouponValidate;
-use think\exception\ValidateException;
-
-class Coupon extends ShopBase{
-    /**
-     * note 优惠券列表
-     */
-    public function lists(){
-        if($this->request->isAjax()){
-            $get = $this->request->get();
-            $get['shop_id'] = $this->shop_id;
-            $data = CouponLogic::lists($get);
-            return JsonServer::success('', $data);
-        }
-
-        return view();
-    }
-    /**
-     * note 添加优惠券
-     */
-    public function add(){
-        if($this->request->isAjax()){
-            $post = $this->request->post();
-            try{
-                validate(CouponValidate::class)->check($post);
-            }catch(ValidateException $e) {
-                return JsonServer::error($e->getError());
-            }
-            $post['shop_id'] = $this->shop_id;
-            $result = CouponLogic::add($post);
-            if($result === true) {
-                return JsonServer::success('新增成功');
-            }
-            return JsonServer::error(CouponLogic::getError());
-        }
-
-        return view();
-    }
-    /**
-     * note 编辑优惠券
-     */
-    public function edit(){
-        if($this->request->isAjax()){
-            $post = $this->request->post();
-            try{
-                validate(CouponValidate::class)->check($post);
-            }catch(ValidateException $e) {
-                return JsonServer::error($e->getError());
-            }
-            $post['shop_id'] = $this->shop_id;
-            $result = CouponLogic::edit($post);
-            if($result === true) {
-                return JsonServer::success('编辑成功');
-            }
-            return JsonServer::error(CouponLogic::getError());
-
-        }
-        $id = $this->request->get('id', '', 'intval');
-        $detail = CouponLogic::getCoupon($id,true);
-        return view('', [
-            'detail' => json_encode($detail, JSON_UNESCAPED_UNICODE)
-        ]);
-    }
-
-    /**
-     * note 优惠券详情
-     */
-    public function detail(){
-        $id = $this->request->get('id');
-        $detail = CouponLogic::getCoupon($id,true);
-        return view('', [
-            'detail' => json_encode($detail,JSON_UNESCAPED_UNICODE)
-        ]);
-    }
-
-    /**
-     * note 优惠券发放记录
-     */
-    public function log(){
-        if($this->request->isAjax()){
-            $get = $this->request->get();
-            $data = CouponLogic::log($get);
-            return JsonServer::success('', $data);
-        }
-
-        $id = $this->request->get('id');
-        return view('', [
-            'id' => $id
-        ]);
-    }
-
-    /**
-     * 上下架
-     */
-    public function changeStatus()
-    {
-        $id = $this->request->post('id');
-        $result = CouponLogic::changeStatus($id);
-        if($result === true) {
-            return JsonServer::success('操作成功');
-        }
-        return JsonServer::error(CouponLogic::getError());
-    }
-
-
-    /**
-     * note 删除优惠券
-     */
-    public function del(){
-        if($this->request->isAjax()){
-            $id = $this->request->post('id');
-            $result = CouponLogic::del($id);
-            if($result === true){
-                return JsonServer::success('删除成功');
-            }
-            return JsonServer::error(CouponLogic::getError());
-        }
-    }
-
-
-    /**
-     * 发放优惠券
-     */
-    public function sendCouponList(){
-        return view();
-    }
-
-    public function getShopCouponList()
-    {
-        $get = $this->request->get();
-        $get['shop_id'] = $this->shop_id;
-        $data = CouponLogic::getShopCouponList($get);
-        return JsonServer::success('', $data);
-    }
-
-    public function sendCoupon(){
-        if($this->request->isAjax()){
-            $post = $this->request->post();
-            $result = CouponLogic::sendCoupon($post);
-            if($result === true){
-                return JsonServer::success('发放成功');
-            }
-            return JsonServer::error(CouponLogic::getError());
-        }
-    }
-}

+ 0 - 147
app/shop/controller/decoration/Ad.php

@@ -1,147 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-namespace app\shop\controller\decoration;
-
-use app\common\basics\ShopBase;
-use app\common\enum\ShopAdEnum;
-use app\common\model\shop\ShopAd;
-use app\common\model\shop\ShopCategory;
-use app\common\model\shop\ShopGoodsCategory;
-use app\common\server\JsonServer;
-use app\shop\logic\decoration\ShopAdLogic;
-use think\response\Json;
-use think\response\View;
-
-class Ad extends ShopBase
-{
-    /**
-     * @notes 广告列表
-     * @return Json|View
-     * @author lbzy
-     * @datetime 2023-12-05 10:06:46
-     */
-    function lists()
-    {
-        if ($this->request->isAjax()) {
-            return JsonServer::success('', ShopAdLogic::lists($this->request->get(), $this->shop_id));
-        }
-        
-        return view();
-    }
-    
-    /**
-     * @notes 新增广告
-     * @return Json|View
-     * @author lbzy
-     * @datetime 2023-12-05 11:58:07
-     */
-    function add()
-    {
-        if ($this->request->isAjax()) {
-            $result = ShopAdLogic::add(input(), $this->shop_id);
-            if ($result) {
-                return JsonServer::success('添加成功');
-            }
-            
-            return JsonServer::error(ShopAdLogic::getError() ? : '添加失败');
-        }
-        
-        return view('', [
-            'placeList'     => ShopAdEnum::getPlaceDesc(),
-            'terminalList'  => ShopAdEnum::getTerminal(),
-        ]);
-    }
-    
-    /**
-     * @notes 编辑广告
-     * @return Json|View
-     * @author lbzy
-     * @datetime 2023-12-05 11:58:17
-     */
-    function edit()
-    {
-        
-        if ($this->request->isAjax()) {
-            $result = ShopAdLogic::edit(input(), $this->shop_id);
-            if ($result) {
-                return JsonServer::success('编辑成功');
-            }
-        
-            return JsonServer::error(ShopAdLogic::getError() ? : '编辑失败');
-        }
-        
-        
-        return view('', [
-            'info'          => ShopAd::where('id', input('id/d'))->where('shop_id', $this->shop_id)->findOrEmpty()->toArray(),
-            'placeList'     => ShopAdEnum::getPlaceDesc(),
-            'terminalList'  => ShopAdEnum::getTerminal(),
-        ]);
-    }
-    
-    /**
-     * @notes 设置状态
-     * @return Json
-     * @author lbzy
-     * @datetime 2023-12-05 11:59:01
-     */
-    function status()
-    {
-        if ($this->request->isAjax()) {
-            ShopAdLogic::status(input(), $this->shop_id);
-            return JsonServer::success('成功');
-        }
-    }
-    
-    /**
-     * @notes 删除广告
-     * @return Json
-     * @author lbzy
-     * @datetime 2023-12-05 11:58:34
-     */
-    function delete()
-    {
-        if ($this->request->isAjax()) {
-            ShopAdLogic::delete(input(), $this->shop_id);
-            return JsonServer::success('成功');
-        }
-    }
-    
-    /**
-     * @notes 选择链接
-     * @return Json|View
-     * @author lbzy
-     * @datetime 2023-12-05 18:33:00
-     */
-    function select_link()
-    {
-        if ($this->request->isAjax()) {
-            
-            return JsonServer::success('');
-        }
-        
-        return view('', [
-            'links'             => ShopAdEnum::getLinkPage(),
-            'shopLinkPaths'     => ShopAdEnum::getShopLinkPaths(),
-            'goodsCategoryList' => ShopGoodsCategory::where('shop_id', $this->shop_id)->where('is_show', 1)->select()->toArray(),
-            'select_link'       => input('link/s', ''),
-            'getShopGoodsListPath'      => ShopAdEnum::getShopGoodsListPath(),
-            'getShopGoodsCategoryPath'  => ShopAdEnum::getShopGoodsCategoryPath(),
-        ]);
-    }
-}

+ 0 - 33
app/shop/controller/decoration/Index.php

@@ -1,33 +0,0 @@
-<?php
-namespace app\shop\controller\decoration;
-
-use app\common\basics\ShopBase;
-use app\shop\logic\decoration\IndexLogic;
-use app\common\server\JsonServer;
-
-class Index extends  ShopBase
-{
-    public function set()
-    {
-        if($this->request->isAjax()) {
-            $post = $this->request->post();
-            $post['shop_id'] = $this->shop_id;
-            if(!isset($post['logo']) || !isset($post['background'])) {
-                return JsonServer::error('商家logo或背景图不能空');
-            }
-            if(!isset($post['pc_cover'])) {
-                return JsonServer::error('PC端店铺封面不能空');
-            }
-            $result = IndexLogic::set($post);
-            if($result === true) {
-                return JsonServer::success('设置成功');
-            }
-            return JsonServer::error(IndexLogic::getError());
-        }
-        $shopSet = IndexLogic::getShopSet($this->shop_id);
-        return view('', [
-            'shopSet' => $shopSet
-        ]);
-
-    }
-}

+ 0 - 41
app/shop/controller/distribution/Center.php

@@ -1,41 +0,0 @@
-<?php
-namespace app\shop\controller\distribution;
-
-use app\common\basics\ShopBase;
-use app\common\server\JsonServer;
-use app\common\model\distribution\DistributionOrderGoods;
-use app\shop\logic\distribution\CenterLogic;
-
-class Center extends ShopBase
-{
-    public function data()
-    {
-        // 已结算: 已结算
-        $settled = DistributionOrderGoods::where([
-            ['status', '=', '2'],
-            ['shop_id', '=', $this->shop_id]
-        ])->sum('money');
-
-
-        // 预估: 待返佣 + 已结算
-        $estimate = DistributionOrderGoods::where([
-            ['status', 'in', [1, 2]],
-            ['shop_id', '=', $this->shop_id]
-        ])->sum('money');
-        return view('', [
-            'settled' => $settled,
-            'estimate' => $estimate
-        ]);
-    }
-
-    /**
-     * @notes 分销概况
-     * @author Tab
-     * @date 2021/9/3 15:53
-     */
-    public function center()
-    {
-        $data = CenterLogic::center($this->shop_id);
-        return view('', ['data' => $data]);
-    }
-}

+ 0 - 73
app/shop/controller/distribution/Goods.php

@@ -1,73 +0,0 @@
-<?php
-namespace app\shop\controller\distribution;
-
-use app\common\basics\ShopBase;
-use app\admin\logic\goods\CategoryLogic as MallCategoryLogic;
-use app\common\server\JsonServer;
-use app\shop\logic\distribution\GoodsLogic;
-use app\shop\logic\goods\CategoryLogic as ShopCategoryLogic;
-
-class Goods extends ShopBase
-{
-    /**
-     * @notes 分销商品列表页
-     * @return \think\response\View
-     * @author Tab
-     * @date 2021/9/1 17:11
-     */
-    public function index()
-    {
-        if ($this->request->isPost()) {
-            $params = $this->request->post();
-            $params['shop_id'] = $this->shop_id;
-            $lists = GoodsLogic::lists($params);
-            return JsonServer::success('', $lists);
-        }
-        // 显示分销商品列表页
-        $cate_list = MallCategoryLogic::categoryTreeeTree();
-        $shop_cate_list = ShopCategoryLogic::listAll($this->shop_id);
-        return view('', [
-            'cate_list' => $cate_list,
-            'shop_cate_list' => $shop_cate_list
-        ]);
-    }
-
-    /**
-     * @notes 设置佣金
-     * @return \think\response\View
-     * @author Tab
-     * @date 2021/9/1 19:59
-     */
-    public function set()
-    {
-        if ($this->request->isPost()) {
-            $params = $this->request->post();
-            $params['shop_id'] = $this->shop_id;
-            $result = GoodsLogic::set($params);
-            if ($result) {
-                return JsonServer::success('设置成功');
-            }
-            return JsonServer::error(GoodsLogic::getError());
-        }
-        $params = $this->request->get();
-        $detail = GoodsLogic::detail($params);
-        return view('', ['detail' => $detail]);
-    }
-
-    /**
-     * @notes 参与分销/取消分销
-     * @return \think\response\Json
-     * @author Tab
-     * @date 2021/9/2 10:03
-     */
-    public function isDistribution()
-    {
-        $params = $this->request->post();
-        $params['shop_id'] = $this->shop_id;
-        $result = GoodsLogic::isDistribution($params);
-        if ($result) {
-            return JsonServer::success('操作成功');
-        }
-        return JsonServer::error(GoodsLogic::getError());
-    }
-}

+ 0 - 27
app/shop/controller/distribution/Order.php

@@ -1,27 +0,0 @@
-<?php
-namespace app\shop\controller\distribution;
-
-use app\common\basics\ShopBase;
-use app\common\server\JsonServer;
-use app\shop\logic\distribution\OrderLogic;
-
-
-class Order extends ShopBase
-{
-    /**
-     * @notes 分销订单列表
-     * @return \think\response\View
-     * @author Tab
-     * @date 2021/9/3 14:38
-     */
-    public function index()
-    {
-        if($this->request->isPost()) {
-            $params = $this->request->post();
-            $params['shop_id'] = $this->shop_id;
-            $result = OrderLogic::lists($params);
-            return JsonServer::success('', $result);
-        }
-        return view();
-    }
-}

+ 0 - 23
app/shop/controller/distribution/Record.php

@@ -1,23 +0,0 @@
-<?php
-namespace app\shop\controller\distribution;
-
-use app\shop\logic\distribution\RecordLogic;
-use app\common\basics\ShopBase;
-use app\common\server\JsonServer;
-use app\common\utils\Time;
-
-class Record extends ShopBase
-{
-    public function lists()
-    {
-        if($this->request->isAjax()) {
-            $get = $this->request->get();
-            $get['shop_id'] = $this->shop_id;
-            $data = RecordLogic::lists($get);
-            return JsonServer::success('', $data);
-        }
-        return view('', [
-            'time' => Time::getTime()
-        ]);
-    }
-}

+ 0 - 94
app/shop/controller/express_assistant/FaceSheetOrder.php

@@ -1,94 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop100%开源免费商用商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | 开源版本可自由商用,可去除界面版权logo
-// | 商业版本务必购买商业授权,以免引起法律纠纷
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop团队 版权所有 拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshopTeam
-// +----------------------------------------------------------------------
-
-namespace app\shop\controller\express_assistant;
-
-use app\common\basics\ShopBase;
-use app\common\server\JsonServer;
-use app\shop\logic\express_assistant\FaceSheetOrderLogic;
-use app\shop\logic\express_assistant\FaceSheetSenderLogic;
-use app\shop\logic\express_assistant\FaceSheetTplLogic;
-use app\shop\validate\express_assistant\FaceSheetOrderValidate;
-
-/**
- * 打印订单
- * Class FaceSheetOrder
- * @package app\shop\controller\express_assistant
- */
-class FaceSheetOrder extends ShopBase
-{
-
-    /**
-     * @notes 获取待发货订单列表
-     * @return \think\response\Json|\think\response\View
-     * @author 段誉
-     * @date 2023/2/13 16:56
-     */
-    public function lists()
-    {
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            $lists = FaceSheetOrderLogic::lists($get, $this->shop_id);
-            return JsonServer::success("", $lists);
-        }
-        return view();
-    }
-
-
-    /**
-     * @notes 选择打印模板
-     * @return \think\response\View
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2023/2/13 16:55
-     */
-    public function select()
-    {
-        return view("", [
-            'template' => FaceSheetTplLogic::allTpl($this->shop_id),
-            'sender' => FaceSheetSenderLogic::allSender($this->shop_id),
-        ]);
-    }
-
-
-    /**
-     * @notes 打印
-     * @return \think\response\Json
-     * @author 段誉
-     * @date 2023/2/13 16:56
-     */
-    public function print()
-    {
-        if (!$this->request->isAjax()) {
-            return JsonServer::error('请求异常');
-        }
-        $params = (new FaceSheetOrderValidate())->goCheck(null, [
-            'shop_id' => $this->shop_id,
-            'admin_id' => $this->admin_id
-        ]);
-        $result = FaceSheetOrderLogic::print($params);
-        if ($result !== true) {
-            return JsonServer::error(FaceSheetOrderLogic::getError());
-        }
-        return JsonServer::success('操作成功');
-
-    }
-}

+ 0 - 113
app/shop/controller/express_assistant/FaceSheetSender.php

@@ -1,113 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop100%开源免费商用商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | 开源版本可自由商用,可去除界面版权logo
-// | 商业版本务必购买商业授权,以免引起法律纠纷
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop团队 版权所有 拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshopTeam
-// +----------------------------------------------------------------------
-
-namespace app\shop\controller\express_assistant;
-
-
-use app\common\basics\ShopBase;
-use app\common\server\JsonServer;
-use app\shop\logic\express_assistant\FaceSheetSenderLogic;
-
-/**
- * 发件人模板
- * Class FaceSheetSender
- * @package app\shop\controller\express_assistant
- */
-class FaceSheetSender extends ShopBase
-{
-
-    /**
-     * @notes 发件人列表
-     * @return \think\response\Json|\think\response\View
-     * @author 段誉
-     * @date 2023/2/13 16:39
-     */
-    public function lists()
-    {
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            $list = FaceSheetSenderLogic::lists($get, $this->shop_id);
-            return JsonServer::success("", $list);
-        }
-        return view();
-    }
-
-
-    /**
-     * @notes 新增发件人模板
-     * @return \think\response\Json|\think\response\View
-     * @author 段誉
-     * @date 2023/2/13 16:39
-     */
-    public function add()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            $result = FaceSheetSenderLogic::add($post, $this->shop_id);
-            if ($result !== true) {
-                return JsonServer::error($result);
-            }
-            return JsonServer::success("操作成功");
-        }
-        return view();
-    }
-
-
-    /**
-     * @notes 编辑发件人
-     * @return \think\response\Json|\think\response\View
-     * @author 段誉
-     * @date 2023/2/13 16:40
-     */
-    public function edit()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            $result = FaceSheetSenderLogic::edit($post, $this->shop_id);
-            if ($result !== true) {
-                return JsonServer::error($result);
-            }
-            return JsonServer::success("操作成功");
-        }
-
-        $id = $this->request->get('id');
-        return view('', [
-            'detail' => FaceSheetSenderLogic::detail($id, $this->shop_id)
-        ]);
-    }
-
-
-    /**
-     * @notes 删除发件人
-     * @return \think\response\Json|void
-     * @author 段誉
-     * @date 2023/2/13 16:40
-     */
-    public function del()
-    {
-        if ($this->request->isAjax()) {
-            $id = $this->request->post('id');
-            $result = FaceSheetSenderLogic::del($id, $this->shop_id);
-            if ($result !== true) {
-                return JsonServer::error($result);
-            }
-            return JsonServer::success("操作成功");
-        }
-    }
-}

+ 0 - 65
app/shop/controller/express_assistant/FaceSheetSetting.php

@@ -1,65 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop100%开源免费商用商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | 开源版本可自由商用,可去除界面版权logo
-// | 商业版本务必购买商业授权,以免引起法律纠纷
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop团队 版权所有 拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshopTeam
-// +----------------------------------------------------------------------
-
-namespace app\shop\controller\express_assistant;
-
-
-use app\common\basics\ShopBase;
-use app\common\server\ConfigServer;
-use app\common\server\JsonServer;
-
-
-/**
- * 面单
- * Class FaceSheet
- * @package app\shop\controller\express_assistant
- */
-class FaceSheetSetting extends ShopBase
-{
-
-    /**
-     * @notes 面单设置
-     * @return \think\response\Json|\think\response\View
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2023/2/13 14:38
-     */
-    public function setting()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            ConfigServer::set('faceSheet', 'type', $post['type'], $this->shop_id);
-            ConfigServer::set('kd100', 'kd100_key', $post['kd100_key'], $this->shop_id);
-            ConfigServer::set('kd100', 'kd100_secret', $post['kd100_secret'], $this->shop_id);
-            ConfigServer::set('kd100', 'kd100_siid', $post['kd100_siid'], $this->shop_id);
-            return JsonServer::success('修改成功');
-        }
-
-        $faceSheet = ConfigServer::get('faceSheet', null,null, $this->shop_id);
-        $detail = ConfigServer::get('kd100', null, null, $this->shop_id);
-        return view('', [
-            'detail' => $detail,
-            'faceSheet' => $faceSheet
-        ]);
-    }
-
-
-}

+ 0 - 127
app/shop/controller/express_assistant/FaceSheetTpl.php

@@ -1,127 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop100%开源免费商用商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | 开源版本可自由商用,可去除界面版权logo
-// | 商业版本务必购买商业授权,以免引起法律纠纷
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop团队 版权所有 拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshopTeam
-// +----------------------------------------------------------------------
-
-namespace app\shop\controller\express_assistant;
-
-use app\common\basics\ShopBase;
-use app\common\server\JsonServer;
-use app\shop\logic\express_assistant\FaceSheetTplLogic;
-
-
-/**
- * 面单模板
- * Class FaceSheetTpl
- * @package app\shop\controller\express_assistant
- */
-class FaceSheetTpl extends ShopBase
-{
-
-    /**
-     * @notes 电子面单模板列表
-     * @return \think\response\Json|\think\response\View
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2023/2/13 16:02
-     */
-    public function lists()
-    {
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            $list = FaceSheetTplLogic::lists($get, $this->shop_id);
-            return JsonServer::success('', $list);
-        }
-        return view();
-    }
-
-
-    /**
-     * @notes 新增电子面单模板
-     * @return \think\response\Json|\think\response\View
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2023/2/13 16:01
-     */
-    public function add()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            $result = FaceSheetTplLogic::add($post, $this->shop_id);
-            if ($result !== true) {
-                return JsonServer::error($result);
-            }
-            return JsonServer::success('操作成功');
-        }
-
-        return view('', [
-            'express' => FaceSheetTplLogic::allExpress()
-        ]);
-    }
-
-
-    /**
-     * @notes 编辑电子面单模板
-     * @return \think\response\Json|\think\response\View
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2023/2/13 16:01
-     */
-    public function edit()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            $result = FaceSheetTplLogic::edit($post, $this->shop_id);
-            if ($result !== true) {
-                return JsonServer::error($result);
-            }
-            return JsonServer::success('操作成功');
-        }
-
-        $id = $this->request->get('id');
-        return view('', [
-            'detail' => FaceSheetTplLogic::detail($id, $this->shop_id),
-            'express' => FaceSheetTplLogic::allExpress(),
-        ]);
-    }
-
-
-    /**
-     * @notes 删除电子面单模板
-     * @return \think\response\Json|void
-     * @author 段誉
-     * @date 2023/2/13 16:01
-     */
-    public function del()
-    {
-        if ($this->request->isAjax()) {
-            $id = $this->request->post('id');
-            $result = FaceSheetTplLogic::del($id, $this->shop_id);
-            if ($result !== true) {
-                return JsonServer::error($result);
-            }
-            return JsonServer::success('操作成功');
-        }
-    }
-
-}

+ 0 - 84
app/shop/controller/finance/Settlement.php

@@ -1,84 +0,0 @@
-<?php
-
-
-namespace app\shop\controller\finance;
-
-
-use app\common\basics\ShopBase;
-use app\common\server\JsonServer;
-use app\shop\logic\finance\SettlementLogic;
-use think\facade\View;
-
-/**
- * 商家结算
- * Class Settlement
- * @package app\shop\controller\finance
- */
-class Settlement extends ShopBase
-{
-    /**
-     * @Notes: 结算列表
-     * @Author: 张无忌
-     */
-    public function lists()
-    {
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            $lists = SettlementLogic::lists($get, $this->shop_id);
-            return JsonServer::success('获取成功', $lists);
-        }
-
-        $statistics = SettlementLogic::statistics($this->shop_id);
-        View::assign('statistics', $statistics);
-        return view();
-    }
-
-    /**
-     * @Notes: 提交结算
-     * @Author: 张无忌
-     */
-    public function add()
-    {
-        $res = SettlementLogic::add($this->shop_id);
-        if ($res === false) {
-            $message = SettlementLogic::getError() ?: '结算失败';
-            return JsonServer::error($message);
-        }
-
-        return JsonServer::success('结算成功');
-    }
-
-    /**
-     * @Notes: 结算详细
-     * @Author: 张无忌
-     */
-    public function detail()
-    {
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            $lists = SettlementLogic::detail($get);
-            return JsonServer::success('获取成功', $lists);
-        }
-
-        $settle_id = $this->request->get('settle_id');
-        View::assign('settle_id', $settle_id);
-        return view();
-    }
-
-
-    /**
-     * @notes 导出Excel
-     * @return \think\response\Json
-     * @author 段誉
-     * @date 2022/4/24 11:57
-     */
-    public function export()
-    {
-        $params = $this->request->get();
-        $result = SettlementLogic::lists($params, $this->shop_id, true);
-        if(false === $result) {
-            return JsonServer::error(SettlementLogic::getError() ?: '导出失败');
-        }
-        return JsonServer::success('', $result);
-    }
-}

+ 0 - 51
app/shop/controller/finance/Shop.php

@@ -1,51 +0,0 @@
-<?php
-
-
-namespace app\shop\controller\finance;
-
-
-use app\common\basics\ShopBase;
-use app\common\server\JsonServer;
-use app\shop\logic\finance\ShopLogic;
-
-/**
- * 账号明细
- * Class Shop
- * @package app\shop\controller\finance
- */
-class Shop extends ShopBase
-{
-
-    /**
-     * @Notes: 账户明细列表
-     * @Author: 张无忌
-     */
-    public function account()
-    {
-        if($this->request->isAjax()){
-            $get= $this->request->get();
-            $lists = ShopLogic::account($get, $this->shop_id);
-            return JsonServer::success('获取成功', $lists);
-        }
-
-        return view();
-    }
-
-
-    /**
-     * @notes 导出Excel
-     * @return \think\response\Json
-     * @author 段誉
-     * @date 2022/4/24 11:57
-     */
-    public function export()
-    {
-        $params = $this->request->get();
-        $result = ShopLogic::account($params, $this->shop_id, true);
-        if(false === $result) {
-            return JsonServer::error(ShopLogic::getError() ?: '导出失败');
-        }
-        return JsonServer::success('', $result);
-    }
-
-}

+ 0 - 121
app/shop/controller/finance/Withdrawal.php

@@ -1,121 +0,0 @@
-<?php
-
-
-namespace app\shop\controller\finance;
-
-
-use app\common\basics\ShopBase;
-use app\common\enum\ShopWithdrawEnum;
-use app\common\logic\SettingLogic;
-use app\common\model\shop\Shop;
-use app\common\server\ConfigServer;
-use app\common\server\JsonServer;
-use app\shop\logic\AlipayLogic;
-use app\shop\logic\BankLogic;
-use app\shop\logic\finance\WithdrawalLogic;
-use think\facade\View;
-
-class Withdrawal extends ShopBase
-{
-    /**
-     * @Notes: 提现列表
-     * @Author: 张无忌
-     */
-    public function lists()
-    {
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            $lists = WithdrawalLogic::lists($get, $this->shop_id);
-            return JsonServer::success('获取成功', $lists);
-        }
-
-        View::assign('statistics', WithdrawalLogic::statistics($this->shop_id));
-        
-        return view();
-    }
-
-    /**
-     * @Notes: 选项卡数据统计
-     * @Author: 张无忌
-     */
-    public function statistics()
-    {
-        if ($this->request->isAjax()) {
-            $statistics = WithdrawalLogic::statistics($this->shop_id);
-            return JsonServer::success('获取成功', $statistics);
-        }
-        return JsonServer::error('异常');
-    }
-
-    /**
-     * @Notes: 申请提现
-     * @Author: 张无忌
-     */
-    public function add()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            $res = WithdrawalLogic::add($post, $this->shop_id);
-            if ($res === false) {
-                $error = BankLogic::getError() ?: '申请失败';
-                return JsonServer::error($error);
-            }
-            return JsonServer::success('申请成功');
-        }
-    
-        $shopWithdrawConfig = SettingLogic::getShopWithdraw();
-        
-        return view('', [
-            'withdrawal_service_charge' => $shopWithdrawConfig['withdrawal_service_charge'],
-            'shop'                      => (new Shop())->findOrEmpty($this->shop_id)->toArray(),
-            'types'                     => ShopWithdrawEnum::type_text_arr3($shopWithdrawConfig['withdrawal_type']),
-        ]);
-    }
-    
-    /**
-     * @notes 申请提现 账号选择
-     * @return \think\response\Json|void
-     * @author lbzy
-     * @datetime 2023-06-09 19:00:31
-     */
-    function add_accounts()
-    {
-        $type = input('type/d', -999);
-        
-        if ($type == ShopWithdrawEnum::TYPE_BANK) {
-            return JsonServer::success('', BankLogic::getBankByShopId($this->shop_id));
-        }
-    
-        if ($type == ShopWithdrawEnum::TYPE_ALIPAY) {
-            return JsonServer::success('', AlipayLogic::getAlipayByShopId($this->shop_id));
-        }
-    }
-
-    /**
-     * @Notes: 申请详细
-     * @Author: 张无忌
-     */
-    public function detail()
-    {
-        $id = $this->request->get('id');
-        View::assign('detail', WithdrawalLogic::detail($id, $this->shop_id));
-        return view();
-    }
-
-
-    /**
-     * @notes 导出Excel
-     * @return \think\response\Json
-     * @author 段誉
-     * @date 2022/4/24 11:57
-     */
-    public function export()
-    {
-        $params = $this->request->get();
-        $result = WithdrawalLogic::lists($params, $this->shop_id, true);
-        if(false === $result) {
-            return JsonServer::error(WithdrawalLogic::getError() ?: '导出失败');
-        }
-        return JsonServer::success('', $result);
-    }
-}

+ 0 - 44
app/shop/controller/free_shipping/FreeShipping.php

@@ -1,44 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-namespace app\shop\controller\free_shipping;
-
-use app\common\basics\ShopBase;
-use app\common\server\JsonServer;
-use app\shop\logic\free_shipping\FreeShippingLogic;
-
-class FreeShipping extends ShopBase
-{
-    public function index()
-    {
-        // 保存设置
-        if ($this->request->isPost()) {
-            $params = $this->request->post();
-            $params['shop_id'] = $this->shop_id;
-            $result = FreeShippingLogic::index($params);
-            if ($result) {
-                return JsonServer::success('保存成功');
-            }
-            return JsonServer::error(FreeShippingLogic::getError());
-        }
-        // 显示设置页
-        $data = FreeShippingLogic::getData($this->shop_id);
-        return view('', $data);
-    }
-}

+ 0 - 129
app/shop/controller/goods/Category.php

@@ -1,129 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-namespace app\shop\controller\goods;
-
-use app\common\basics\ShopBase;
-use app\common\server\JsonServer;
-use think\exception\ValidateException;
-use think\facade\View;
-use app\shop\logic\goods\CategoryLogic;
-use app\shop\validate\goods\GoodsCategoryValidate;
-
-/**
- * 店铺商品分类
- * Class Category
- */
-class Category extends ShopBase
-{
-  /**
-   * 列表
-   */
-  public function lists(){
-    if($this->request->isAjax()) {
-      $get = $this->request->get();
-      $get['shop_id'] = $this->shop_id;
-      $data = CategoryLogic::lists($get);
-      return JsonServer::success('获取列表成功', $data);
-    }
-    return view();
-  }
-
-  /**
-   * 添加
-   */
-  public function add(){
-    if($this->request->isAjax()) {
-      $post = $this->request->post();
-      $post['del'] = 0;
-      $post['shop_id'] = $this->shop_id;
-      try {
-        validate(GoodsCategoryValidate::class)->scene('add')->check($post);
-      } catch (ValidateException $e) {
-          return JsonServer::error($e->getError());
-      }
-      $res = CategoryLogic::add($post);
-      if($res) {
-        return JsonServer::success('分类添加成功');
-      }else{
-        return JsonServer::error('分类添加失败');
-      }
-    }
-
-    return view();
-  }
-
-  /**
-   * 删除
-   */
-  public function del(){
-    $post = $this->request->post();
-    try {
-      validate(GoodsCategoryValidate::class)->scene('del')->check($post);
-    } catch (ValidateException $e) {
-        return JsonServer::error($e->getError());
-    }
-    $res = CategoryLogic::del($post);
-    if($res) {
-      return JsonServer::success('删除分类成功');
-    }else{
-      return JsonServer::error('删除分类失败');
-    }
-  }
-
-
-  /**
-   * 编辑
-   */
-  public function edit(){
-    if ($this->request->isAjax()) {
-      $post = $this->request->post();
-      $post['del'] = 0;
-      $post['shop_id'] = $this->shop_id;
-      try {
-        validate(GoodsCategoryValidate::class)->scene('edit')->check($post);
-      } catch (ValidateException $e) {
-          return JsonServer::error($e->getError());
-      }
-      $res = CategoryLogic::edit($post);
-      if($res) {
-        return JsonServer::success('编辑分类成功');
-      }else{
-        return JsonServer::error('编辑分类失败');
-      }
-    }
-
-    $id = $this->request->get('id');
-    $detail = CategoryLogic::getCategory($id);
-    return view('edit', ['detail' => $detail]);
-  }
-
-  /**
-   * 修改显示状态
-   */
-  public function switchStatus(){
-    $post = $this->request->post();
-    $res = CategoryLogic::switchStatus($post);
-    if($res) {
-      return JsonServer::success('修改成功');
-    }else{
-      return JsonServer::error('修改失败');
-    }
-  }
-}

+ 0 - 36
app/shop/controller/goods/Comment.php

@@ -1,36 +0,0 @@
-<?php
-namespace app\shop\controller\goods;
-
-use app\shop\logic\goods\CommentLogic;
-use app\common\basics\ShopBase;
-use app\common\server\JsonServer;
-
-class Comment extends ShopBase
-{
-    /**
-     * 评价列表
-     */
-    public function lists()
-    {
-        if($this->request->isAjax()) {
-            $get = $this->request->get();
-            $get['shop_id'] = $this->shop_id;
-            $data = CommentLogic::lists($get);
-            return JsonServer::success('', $data);
-        }
-        return view();
-    }
-
-    /**
-     * 商家回复
-     */
-    public function reply()
-    {
-        $post = $this->request->post();
-        $result = CommentLogic::reply($post);
-        if($result === true) {
-            return JsonServer::success('操作成功');
-        }
-        return JsonServer::error(CommentLogic::getError());
-    }
-}

+ 0 - 302
app/shop/controller/goods/Goods.php

@@ -1,302 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-
-namespace app\shop\controller\goods;
-
-
-use app\common\basics\ShopBase;
-use app\common\enum\GoodsEnum;
-use app\common\model\goods\GoodsBrand;
-use app\common\model\goods\GoodsUnit;
-use app\common\model\Freight;
-use app\common\model\goods\Supplier;
-use app\common\model\goods\Goods as GoodsModel;
-use app\common\logic\CommonLogic;
-use app\common\server\ArrayServer;
-use app\common\server\JsonServer;
-use app\shop\logic\goods\GoodsLogic;
-use app\shop\validate\goods\GoodsMoreSpec;
-use app\shop\validate\goods\GoodsMoreSpecLists;
-use app\shop\validate\goods\GoodsOneSpec;
-use app\shop\validate\goods\GoodsStatusValidate;
-use app\shop\validate\goods\GoodsValidate;
-use app\admin\logic\goods\CategoryLogic as MallCategoryLogic;
-use app\shop\logic\goods\CategoryLogic as ShopCategoryLogic;
-
-
-
-/**
- * 商品管理
- * Class Goods
- * @package app\shop\controller\goods
- */
-class Goods extends ShopBase
-{
-    /**
-     * Notes: 列表
-     * @author 段誉(2021/4/15 10:49)
-     */
-    public function lists()
-    {
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            $get['shop_id'] = $this->shop_id;
-            return JsonServer::success('', GoodsLogic::lists($get));
-        }
-        $cate_list = MallCategoryLogic::categoryTreeeTree();
-        $shop_cate_list = ShopCategoryLogic::listAll($this->shop_id);
-        $statistics = GoodsLogic::statistics($this->shop_id);
-        return view('', [
-            'statistics'        => $statistics,
-            'cate_list'         => $cate_list, //平台分类
-            'shop_cate_list'    => $shop_cate_list, //商家分类
-            'goods_type'        => GoodsEnum::getTypeDesc()
-        ]);
-    }
-
-
-    /**
-     * Notes: 添加
-     * @author 段誉(2021/4/15 10:49)
-     */
-    public function add()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            $post['shop_id'] = $this->shop_id;
-
-            //主表验证
-            (new GoodsValidate())->goCheck('add', ['shop_id' => $this->shop_id]);
-
-            //单规格验证
-            if ($post['spec_type'] == 1) {
-                (new GoodsOneSpec())->goCheck();
-            }
-
-            //多规格验证
-            $spec_lists = [];
-            if ($post['spec_type'] == 2) {
-                $spec_lists = $post;
-                unset($spec_lists['goods_image']);
-                unset($spec_lists['spec_id']);
-                unset($spec_lists['spec_name']);
-                unset($spec_lists['spec_values']);
-                unset($spec_lists['spec_value_ids']);
-                unset($spec_lists['delivery_type']);
-
-                $spec_lists = ArrayServer::form_to_linear($spec_lists);
-
-                //规格验证
-                if (empty($spec_lists)) {
-                    return JsonServer::error('至少添加一个规格');
-                }
-                // 规格项及规格值是否重复验证
-                (new GoodsMoreSpec())->goCheck();
-
-                //规格商品列表验证
-                foreach ($spec_lists as $v) {
-                    (new GoodsMoreSpecLists())->goCheck('', $v);
-                }
-                // 校验规格
-                $total_stock = array_sum(array_column($spec_lists, 'stock'));
-                if ($total_stock <= 0) {
-                    return JsonServer::error('至少有一个规格的库存大于0');
-                }
-            }
-
-           // 添加商品
-            $result = GoodsLogic::add($this->shop_id, $post, $spec_lists);
-
-            if (true !== $result) {
-                return JsonServer::error(GoodsLogic::getError() ?: '操作失败');
-            }
-            return JsonServer::success('添加成功');
-        }
-
-        return view('', [
-            'category_lists' => json_encode(MallCategoryLogic::getAllTree(), JSON_UNESCAPED_UNICODE),
-            'shop_category_lists' => json_encode(ShopCategoryLogic::listAll($this->shop_id), JSON_UNESCAPED_UNICODE),
-            'brand_lists' => json_encode(GoodsBrand::getNameColumn(), JSON_UNESCAPED_UNICODE),
-            'supplier_lists' => json_encode(Supplier::getNameColumn($this->shop_id), JSON_UNESCAPED_UNICODE),
-            'unit_lists' => json_encode(GoodsUnit::getNameColumn(), JSON_UNESCAPED_UNICODE),
-            'freight_lists' => json_encode(Freight::getNameColumn($this->shop_id), JSON_UNESCAPED_UNICODE),
-        ]);
-    }
-
-
-    /**
-     * @notes 编辑
-     * @return \think\response\Json|\think\response\View
-     * @author 段誉
-     * @date 2021/4/15 10:49
-     */
-    public function edit()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            $post['del'] = 0;
-            $post['id'] = $post['goods_id'];
-
-            //主表验证
-            (new GoodsValidate())->goCheck(null, ['shop_id' => $this->shop_id]);
-
-            //单规格验证
-            if ($post['spec_type'] == 1) {
-                (new GoodsOneSpec())->goCheck();
-            }
-
-            //多规格验证
-            $spec_lists = [];
-            if ($post['spec_type'] == 2) {
-                $spec_lists = $post;
-                unset($spec_lists['goods_image']);
-                unset($spec_lists['spec_name']);
-                unset($spec_lists['spec_values']);
-                unset($spec_lists['spec_id']);
-                unset($spec_lists['spec_value_ids']);
-                unset($spec_lists['delivery_type']);
-                $spec_lists = ArrayServer::form_to_linear($spec_lists);
-
-                //规格验证
-                if (empty($spec_lists)) {
-                    return JsonServer::error('至少添加一个规格');
-                }
-                // 规格项验证
-                (new GoodsMoreSpec())->goCheck();
-                //规格商品列表验证
-                foreach ($spec_lists as $v) {
-                    (new GoodsMoreSpecLists())->goCheck('', $v);
-                }
-                // 校验规格
-                $total_stock = array_sum(array_column($spec_lists, 'stock'));
-                if ($total_stock <= 0) {
-                    return JsonServer::error('至少有一个规格的库存大于0');
-                }
-            }
-            $result = GoodsLogic::edit($post, $spec_lists);
-            if (true !== $result) {
-                return JsonServer::error(GoodsLogic::getError() ?: '操作失败');
-            }
-            return JsonServer::success(GoodsLogic::getError() ? : '编辑成功');
-        }
-
-        $goods_id = $this->request->get('goods_id');
-
-        return view('goods/goods/add', [
-            'category_lists' => json_encode(MallCategoryLogic::getAllTree(), JSON_UNESCAPED_UNICODE),
-            'shop_category_lists' => json_encode(ShopCategoryLogic::listAll($this->shop_id), JSON_UNESCAPED_UNICODE),
-            'brand_lists' => json_encode(GoodsBrand::getNameColumn(), JSON_UNESCAPED_UNICODE),
-            'supplier_lists' => json_encode(Supplier::getNameColumn($this->shop_id), JSON_UNESCAPED_UNICODE),
-            'unit_lists' => json_encode(GoodsUnit::getNameColumn(), JSON_UNESCAPED_UNICODE),
-            'freight_lists' => json_encode(Freight::getNameColumn($this->shop_id), JSON_UNESCAPED_UNICODE),
-            'info' => json_encode(GoodsLogic::info($goods_id),JSON_UNESCAPED_UNICODE)
-        ]);
-    }
-
-    /**
-     * Notes: 删除
-     * @author 段誉(2021/4/15 10:49)
-     * @return \think\response\Json
-     */
-    public function del()
-    {
-        if ($this->request->isAjax()) {
-            $id = $this->request->post('id');
-            (new GoodsValidate())->goCheck('del', ['goods_id' => $id, 'shop_id' => $this->shop_id]);
-            $result = GoodsLogic::del($this->shop_id, $id);
-            if($result) {
-                return JsonServer::success('删除成功');
-            }
-            return JsonServer::error(GoodsLogic::getError());
-        }
-    }
-
-    /**
-     * Notes:修改商品字段(上下架、新品推荐、好物优选、猜你喜欢)
-     * @throws \think\Exception
-     * @throws \think\exception\PDOException
-     */
-    public function changeFields(){
-        $table = 'goods';
-        $pk_name = 'id';
-        $pk_value = $this->request->post('id');
-        $field = $this->request->post('field');
-        $field_value = $this->request->post('value');
-
-        // 库存校验
-        $stock = GoodsModel::where('id', $pk_value)->value('stock');
-        if($field_value == 1 && $stock <= 0) {
-            return JsonServer::error('库存为0的商品不允许上架');
-        }
-        $result = CommonLogic::changeTableValue($table,$pk_name,$pk_value,$field,$field_value);
-        if($result){
-            event('UpdateCollect', ['goods_id' => $pk_value]);
-            return JsonServer::success('操作成功');
-        }
-        return JsonServer::error('操作失败');
-    }
-
-    /**
-     * 放回仓库
-     */
-    public function backToWarehouse(){
-        $id = $this->request->post('id', '', 'intval');
-        if(empty($id)) {
-            return JsonServer::error('id不存在');
-        }
-        $result = GoodsLogic::backToWarehouse($id);
-        if($result) {
-            return JsonServer::success('操作成功');
-        }
-        return JsonServer::error('操作失败');
-    }
-
-    /**
-     * @notes 获取统计数据
-     * @author Tab
-     * @date 2021/7/13 18:03
-     */
-    public function totalCount()
-    {
-        if ($this->request->isAjax()) {
-            return JsonServer::success('获取成功', GoodsLogic::statistics($this->shop_id));
-        }
-    }
-
-
-    /**
-     * @notes 批量更新上下架状态
-     * @return \think\response\Json|void
-     * @author 段誉
-     * @date 2022/3/17 11:53
-     */
-    public function setStatus()
-    {
-        if ($this->request->isAjax()) {
-            $params = (new GoodsStatusValidate())->goCheck(null, ['shop_id' => $this->shop_id]);
-            $result = GoodsLogic::setStatus($params['ids'], $params['status']);
-            if($result) {
-                return JsonServer::success('操作成功');
-            }
-            return JsonServer::error(GoodsLogic::getError());
-        }
-    }
-
-}

+ 0 - 109
app/shop/controller/goods/Supplier.php

@@ -1,109 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-
-namespace app\shop\controller\goods;
-
-
-use app\shop\logic\goods\SupplierLogic;
-use app\shop\validate\goods\SupplierValidate;
-use app\common\basics\ShopBase;
-use app\common\model\goods\Supplier as SupplierModel;
-use app\common\server\JsonServer;
-
-
-/**
- * 供应商
- * Class GoodsBrand
- * @package app\admin\controller
- */
-class Supplier extends ShopBase
-{
-    /**
-     * Notes: 列表
-     * @author 段誉(2021/4/15 10:49)
-     * @return string|\think\response\Json
-     */
-    public function lists()
-    {
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            return JsonServer::success('获取成功', SupplierLogic::lists($this->shop_id, $get));
-        }
-        return view();
-    }
-
-
-    /**
-     * Notes: 添加
-     * @author 段誉(2021/4/15 10:49)
-     * @return string|\think\response\Json
-     */
-    public function add()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            (new SupplierValidate())->goCheck('add');
-            if (SupplierLogic::add($this->shop_id, $post)) {
-                return JsonServer::success('操作成功');
-            }
-            return JsonServer::error(SupplierLogic::getError() ?: '操作失败');
-        }
-        return view('', ['capital' => getCapital()]);
-    }
-
-    /**
-     * Notes: 编辑
-     * @author 段誉(2021/4/15 10:49)
-     * @return string|\think\response\Json
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     */
-    public function edit()
-    {
-        $id = $this->request->get('id');
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            (new SupplierValidate())->goCheck('edit');
-            if (SupplierLogic::edit($this->shop_id, $post)) {
-                return JsonServer::success('操作成功');
-            }
-            return JsonServer::error(SupplierLogic::getError() ?: '操作失败');
-        }
-        return view('', ['detail' => SupplierModel::find($id)]);
-    }
-
-    /**
-     * Notes: 删除
-     * @author 段誉(2021/4/15 10:49)
-     * @return \think\response\Json
-     */
-    public function del()
-    {
-        if ($this->request->isAjax()) {
-            $id = $this->request->post('id');
-            (new SupplierValidate())->goCheck('del');
-            if (SupplierLogic::del($this->shop_id, $id)) {
-                return JsonServer::success('操作成功');
-            }
-            return JsonServer::error(SupplierLogic::getError() ?: '操作失败');
-        }
-    }
-}

+ 0 - 160
app/shop/controller/kefu/Kefu.php

@@ -1,160 +0,0 @@
-<?php
-
-namespace app\shop\controller\kefu;
-
-
-use app\common\basics\ShopBase;
-use app\common\model\shop\ShopRole;
-use app\shop\logic\kefu\KefuLogic;
-use app\shop\validate\kefu\KefuValidate;
-use app\common\server\JsonServer;
-use app\shop\validate\kefu\LoginValidate;
-
-/**
- * 客服管理控制器
- * Class Kefu
- * @package app\admin\controller\kefu
- */
-class Kefu extends ShopBase
-{
-
-    /**
-     * @notes 客服列表
-     * @return \think\response\Json|\think\response\View
-     * @author 段誉
-     * @date 2021/11/26 18:40
-     */
-    public function lists()
-    {
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            $lists = KefuLogic::getLists($get, $this->shop_id);
-            return JsonServer::success('获取成功', $lists);
-        }
-        return view();
-    }
-
-    /**
-     * @notes 添加客服
-     * @return \think\response\Json|\think\response\View
-     * @author 段誉
-     * @date 2021/11/26 18:04
-     */
-    public function add()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            $post['disable'] = isset($post['disable']) && $post['disable'] == 'on' ? 0 : 1;
-            $post['shop_id'] = $this->shop_id;
-            (new KefuValidate())->goCheck('add', $post);
-            $res = KefuLogic::add($post, $this->shop_id);
-            if (false === $res) {
-                $error = KefuLogic::getError() ?: '操作失败';
-                return JsonServer::error($error);
-            }
-            return JsonServer::success('操作成功');
-        }
-        return view();
-    }
-
-
-    /**
-     * @notes 编辑客服
-     * @return \think\response\Json|\think\response\View
-     * @author 段誉
-     * @date 2021/11/27 10:45
-     */
-    public function edit()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            $post['disable'] = isset($post['disable']) && $post['disable'] == 'on' ? 0 : 1;
-            (new KefuValidate())->goCheck('edit', $post);
-            $res = KefuLogic::edit($post, $this->shop_id);
-            if (false === $res) {
-                $error = KefuLogic::getError() ?: '操作失败';
-                return JsonServer::error($error);
-            }
-            return JsonServer::success('操作成功');
-        }
-
-        $id = $this->request->get('id');
-        return view('', [
-            'detail'   => KefuLogic::detail($id, $this->shop_id),
-        ]);
-    }
-
-
-
-    /**
-     * @notes 删除客服
-     * @return \think\response\Json|void
-     * @author 段誉
-     * @date 2021/11/26 18:53
-     */
-    public function del()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            (new KefuValidate())->goCheck('del');
-            KefuLogic::del($post, $this->shop_id);
-            return JsonServer::success('操作成功');
-        }
-    }
-
-
-    /**
-     * @notes 管理员列表
-     * @return \think\response\Json|\think\response\View
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2021/11/26 18:01
-     */
-    public function adminLists()
-    {
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            return JsonServer::success('', KefuLogic::getAdminLists($get, $this->shop_id));
-        }
-        return view('', ['role_lists' => (new ShopRole())->getRoleLists(['shop_id' => $this->shop_id])]);
-    }
-
-
-    /**
-     * @notes 设置状态
-     * @return \think\response\Json|void
-     * @author 段誉
-     * @date 2021/11/26 18:40
-     */
-    public function status()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            KefuLogic::setStatus($post, $this->shop_id);
-            return JsonServer::success('操作成功');
-        }
-    }
-
-
-    /**
-     * @notes 登录工作台
-     * @return \think\response\Json|void
-     * @author 段誉
-     * @date 2021/12/20 10:46
-     */
-    public function login()
-    {
-        if ($this->request->isAjax()) {
-            $id = $this->request->post('id/d');
-            (new LoginValidate())->goCheck('', ['shop_id' =>$this->shop_id]);
-            $res = KefuLogic::login($id, $this->shop_id);
-            if (false === $res) {
-                return JsonServer::error(KefuLogic::getError() ?: '系统错误');
-            }
-            return JsonServer::success('', ['url' => $res]);
-        }
-    }
-
-}

+ 0 - 109
app/shop/controller/kefu/KefuLang.php

@@ -1,109 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop100%开源免费商用商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | 开源版本可自由商用,可去除界面版权logo
-// | 商业版本务必购买商业授权,以免引起法律纠纷
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop团队 版权所有 拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshopTeam
-// +----------------------------------------------------------------------
-namespace app\shop\controller\kefu;
-use app\shop\logic\kefu\KefuLangLogic;
-use app\shop\validate\kefu\KefuLangValidate;
-use app\common\basics\ShopBase;
-use app\common\server\JsonServer;
-
-/**
- * 客服术语
- * Class KefuLang
- * @package app\admin\controller\kefu
- */
-class KefuLang extends ShopBase
-{
-    /**
-     * @notes 列表
-     * @return \think\response\Json|\think\response\View
-     * @throws \think\db\exception\DbException
-     * @author cjhao
-     * @date 2021/11/29 15:20
-     */
-    public function lists()
-    {
-        if($this->request->isAjax()){
-            $page = $this->request->get('page', 1);
-            $limit = $this->request->get('limit', 10);
-            $lists = KefuLangLogic::lists($this->shop_id,$limit,$page);
-            return JsonServer::success('获取成功', $lists);
-        }
-        return view();
-    }
-
-
-    /**
-     * @notes 添加话术
-     * @return \think\response\Json|\think\response\View
-     * @author cjhao
-     * @date 2021/11/29 15:59
-     */
-    public function add()
-    {
-        if($this->request->isAjax()){
-            $post= (new KefuLangValidate())->goCheck('add',['shop_id'=>$this->shop_id]);
-            $result = KefuLangLogic::add($this->shop_id,$post);
-            if($result){
-                return JsonServer::success('新增成功', []);
-            }
-            return JsonServer::error('新增失败');
-        }
-        return view();
-
-    }
-
-    /**
-     * @notes 编辑话术
-     * @return \think\response\Json|\think\response\View
-     * @author cjhao
-     * @date 2021/11/29 15:59
-     */
-    public function edit()
-    {
-        if($this->request->isAjax()){
-            $post= (new KefuLangValidate())->goCheck(null,['shop_id'=>$this->shop_id]);
-            $result = KefuLangLogic::edit($post);
-            if($result){
-                return JsonServer::success('修改成功', []);
-            }
-            return JsonServer::error('修改失败');
-        }
-        $id = $this->request->get('id');
-        return view('', [
-            'detail'   => KefuLangLogic::detail($this->shop_id,$id),
-        ]);
-
-    }
-
-    /**
-     * @notes 删除话术
-     * @return \think\response\Json
-     * @author cjhao
-     * @date 2021/11/29 16:46
-     */
-    public function del()
-    {
-        $post= (new KefuLangValidate())->goCheck('del',['shop_id'=>$this->shop_id]);
-        $result = KefuLangLogic::del($this->shop_id,$post['id']);
-        if($result){
-            return JsonServer::success('删除成功', []);
-        }
-        return JsonServer::error('删除失败');
-    }
-}

+ 0 - 117
app/shop/controller/live/LiveGoods.php

@@ -1,117 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop100%开源免费商用商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | 开源版本可自由商用,可去除界面版权logo
-// | 商业版本务必购买商业授权,以免引起法律纠纷
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop团队 版权所有 拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshopTeam
-// +----------------------------------------------------------------------
-
-namespace app\shop\controller\live;
-
-
-use app\common\basics\ShopBase;
-use app\common\enum\LiveRoomEnum;
-use app\common\server\JsonServer;
-use app\shop\logic\live\LiveGoodsLogic;
-use app\shop\validate\live\LiveGoodsValidate;
-
-
-/**
- * 直播商品
- * Class LiveGoods
- * @package app\shop\controller\live
- */
-class LiveGoods extends ShopBase
-{
-
-    /**
-     * @notes 直播间列表
-     * @return \think\response\Json|\think\response\View
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2023/2/16 10:38
-     */
-    public function lists()
-    {
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            $get['shop_id'] = $this->shop_id;
-            $lists = LiveGoodsLogic::lists($get);
-            return JsonServer::success('', $lists);
-        }
-        return view('', [
-            'live_status' => LiveRoomEnum::getLiveStatusDesc()
-        ]);
-    }
-
-
-    /**
-     * @notes 添加直播商品
-     * @return \think\response\Json|\think\response\View
-     * @throws \GuzzleHttp\Exception\GuzzleException
-     * @author 段誉
-     * @date 2023/2/16 10:38
-     */
-    public function add()
-    {
-        if ($this->request->isAjax()) {
-            $params = (new LiveGoodsValidate())->goCheck('add', ['shop_id' => $this->shop_id]);
-            $result = LiveGoodsLogic::add($params);
-            if ($result !== true) {
-                return JsonServer::error(LiveGoodsLogic::getError());
-            }
-            return JsonServer::success('操作成功');
-        }
-        return view();
-    }
-
-
-    /**
-     * @notes 直播商品详情
-     * @return \think\response\View
-     * @author 段誉
-     * @date 2023/2/16 16:40
-     */
-    public function detail()
-    {
-        $params = (new LiveGoodsValidate())->goCheck('detail', ['shop_id' => $this->shop_id]);
-        return view('', [
-            'detail' => LiveGoodsLogic::detail($params),
-        ]);
-    }
-
-
-
-    /**
-     * @notes 删除直播间
-     * @return \think\response\Json|void
-     * @author 段誉
-     * @date 2023/2/16 10:38
-     */
-    public function del()
-    {
-        if ($this->request->isAjax()) {
-            $params = (new LiveGoodsValidate())->goCheck('del', ['shop_id' => $this->shop_id]);
-            $result = LiveGoodsLogic::del($params);
-            if ($result !== true) {
-                return JsonServer::error(LiveGoodsLogic::getError());
-            }
-            return JsonServer::success('操作成功');
-        }
-    }
-
-
-}

+ 0 - 169
app/shop/controller/live/LiveRoom.php

@@ -1,169 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop100%开源免费商用商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | 开源版本可自由商用,可去除界面版权logo
-// | 商业版本务必购买商业授权,以免引起法律纠纷
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop团队 版权所有 拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshopTeam
-// +----------------------------------------------------------------------
-
-namespace app\shop\controller\live;
-
-
-use app\common\basics\ShopBase;
-use app\common\enum\LiveGoodsEnum;
-use app\common\enum\LiveRoomEnum;
-use app\common\server\JsonServer;
-use app\shop\logic\live\LiveGoodsLogic;
-use app\shop\logic\live\LiveRoomLogic;
-use app\shop\validate\live\LiveRoomValidate;
-
-
-/**
- * 直播间
- * Class LiveRoom
- * @package app\shop\controller\live
- */
-class LiveRoom extends ShopBase
-{
-
-    /**
-     * @notes 直播间列表
-     * @return \think\response\Json|\think\response\View
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2023/2/16 10:38
-     */
-    public function lists()
-    {
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            $get['shop_id'] = $this->shop_id;
-            $lists = LiveRoomLogic::lists($get);
-            return JsonServer::success('', $lists);
-        }
-        return view('', [
-            'live_status' => LiveRoomEnum::getLiveStatusDesc()
-        ]);
-    }
-
-
-    /**
-     * @notes 添加直播间
-     * @return \think\response\Json|\think\response\View
-     * @throws \GuzzleHttp\Exception\GuzzleException
-     * @author 段誉
-     * @date 2023/2/16 10:38
-     */
-    public function add()
-    {
-        if ($this->request->isAjax()) {
-            $params = (new LiveRoomValidate())->goCheck('add', ['shop_id' => $this->shop_id]);
-            $result = LiveRoomLogic::add($params);
-            if ($result !== true) {
-                return JsonServer::error(LiveRoomLogic::getError());
-            }
-            return JsonServer::success('操作成功');
-        }
-        return view();
-    }
-
-
-    /**
-     * @notes 编辑直播间
-     * @return \think\response\Json|\think\response\View
-     * @throws \GuzzleHttp\Exception\GuzzleException
-     * @author 段誉
-     * @date 2023/2/16 10:38
-     */
-    public function edit()
-    {
-        if ($this->request->isAjax()) {
-            $params = (new LiveRoomValidate())->goCheck('edit', ['shop_id' => $this->shop_id]);
-            $result = LiveRoomLogic::edit($params);
-            if ($result !== true) {
-                return JsonServer::error(LiveRoomLogic::getError());
-            }
-            return JsonServer::success('操作成功');
-        }
-        $id = $this->request->get('id');
-        return view('', [
-            'detail' => LiveRoomLogic::detail($id),
-        ]);
-    }
-
-
-    /**
-     * @notes 删除直播间
-     * @return \think\response\Json|void
-     * @author 段誉
-     * @date 2023/2/16 10:38
-     */
-    public function del()
-    {
-        if ($this->request->isAjax()) {
-            $params = (new LiveRoomValidate())->goCheck('del', ['shop_id' => $this->shop_id]);
-            $result = LiveRoomLogic::del($params);
-            if ($result !== true) {
-                return JsonServer::error(LiveRoomLogic::getError());
-            }
-            return JsonServer::success('操作成功');
-        }
-    }
-
-
-    /**
-     * @notes 导入商品选择
-     * @return \think\response\Json|\think\response\View
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2023/2/17 12:08
-     */
-    public function selectGoods()
-    {
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            $get['shop_id'] = $this->shop_id;
-            $get['status'] = 'success';
-            $list = LiveGoodsLogic::lists($get);
-            return JsonServer::success('',$list);
-        }
-        return view();
-    }
-
-
-    /**
-     * @notes 导入直播商品
-     * @return \think\response\Json|void
-     * @throws \GuzzleHttp\Exception\GuzzleException
-     * @author 段誉
-     * @date 2023/2/17 14:26
-     */
-    public function importGoods()
-    {
-        if ($this->request->isAjax()) {
-            $params = $this->request->post();
-            $result = LiveRoomLogic::importGoods($params);
-            if ($result !== true) {
-                return JsonServer::error(LiveRoomLogic::getError());
-            }
-            return JsonServer::success('操作成功');
-        }
-    }
-
-
-}

+ 0 - 135
app/shop/controller/order/DeliveryBatch.php

@@ -1,135 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-namespace app\shop\controller\order;
-
-use app\common\basics\ShopBase;
-use app\common\server\excel\Excel;
-use app\common\server\JsonServer;
-use app\shop\logic\order\DeliveryBatchLogic;
-use app\shop\validate\order\DeliveryBatchImportValidate;
-use PhpOffice\PhpSpreadsheet\Cell\DataType;
-use PhpOffice\PhpSpreadsheet\IOFactory;
-use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
-
-class DeliveryBatch extends ShopBase
-{
-    /**
-     * @notes 批量发货列表
-     * @return \think\response\Json|\think\response\View
-     * @author lbzy
-     * @datetime 2025-03-06 18:10:51
-     */
-    function lists()
-    {
-        if ($this->request->isAjax()) {
-            return JsonServer::success('', DeliveryBatchLogic::lists(input()));
-        }
-        
-        return view();
-    }
-    
-    /**
-     * @notes 批量发货详情
-     * @return \think\response\Json
-     * @author lbzy
-     * @datetime 2025-03-06 18:10:39
-     */
-    function detail()
-    {
-        return JsonServer::success('', [ 'detail' => DeliveryBatchLogic::detail(input('id/d')) ]);
-    }
-    
-    /**
-     * @notes 下载默认文件等
-     * @return string|\think\response\File
-     * @author lbzy
-     * @datetime 2025-03-06 17:35:44
-     */
-    function down()
-    {
-        $filename = pathinfo(input('file/s'), PATHINFO_FILENAME);
-        $path = app()->getRootPath() . 'public/static/excel/' . $filename . '.xls';
-        
-        if (! file_exists($path)) {
-            return '文件不存在';
-        }
-        
-        return download($path, $filename);
-    }
-    
-    /**
-     * @notes 下载导入失败的
-     * @return void
-     * @author lbzy
-     * @datetime 2025-03-06 18:20:45
-     */
-    function down2()
-    {
-        $lists = DeliveryBatchLogic::getFailInfoLists(input('id/d'));
-        
-        Excel::out($lists, [
-            [ 'field' => 'sn', 'title' => '订单编号', 'excel_data_type' => DataType::TYPE_STRING ],
-            [ 'field' => 'express_name', 'title' => '快递公司名称' ],
-            [ 'field' => 'express_no', 'title' => '快递单号' ],
-            [ 'field' => 'fail_content', 'title' => '失败原因' ],
-        ], '','', '导入失败订单');
-        exit;
-    }
-    
-    /**
-     * @notes 立即导入
-     * @return \think\response\Json
-     * @author lbzy
-     * @datetime 2025-03-06 17:56:34
-     */
-    function import()
-    {
-        $sheet = IOFactory::load($_FILES['file']['tmp_name'])->getActiveSheet();
-        $sheet->getStyle('A')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
-        $sheet->getStyle('B')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
-        $sheet->getStyle('C')->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
-        $lists  = $sheet->toArray(null, true, true, true);
-        
-        (new DeliveryBatchImportValidate())->goCheck('', [ 'lists' => $lists ]);
-        
-        $result = DeliveryBatchLogic::importLists($lists, $_FILES['file']['name']);
-        
-        return is_array($result) ? JsonServer::success('', $result) : JsonServer::error($result);
-    }
-    
-    /**
-     * @notes 执行导入页面
-     * @return \think\response\Json|\think\response\View
-     * @author lbzy
-     * @datetime 2025-03-06 18:08:52
-     */
-    function delivery()
-    {
-        $detail = DeliveryBatchLogic::detail(input('id/d'));
-        
-        if ($this->request->isAjax()) {
-            DeliveryBatchLogic::delivery($detail);
-            return JsonServer::success('');
-        }
-        
-        return view('', [
-            'detail'    => $detail
-        ]);
-    }
-}

+ 0 - 95
app/shop/controller/order/Invoice.php

@@ -1,95 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-
-namespace app\shop\controller\order;
-
-use app\common\basics\ShopBase;
-use app\common\model\order\Order;
-use app\common\server\JsonServer;
-use app\shop\logic\order\InvoiceLogic;
-use app\shop\validate\order\OrderInvoiceValidate;
-
-
-/**
- * 发票管理
- * Class Invoice
- * @package app\shop\controller\order
- */
-class Invoice extends ShopBase
-{
-
-    /**
-     * @notes 发票列表
-     * @return \think\response\Json|\think\response\View
-     * @author 段誉
-     * @date 2022/4/12 17:34
-     */
-    public function lists()
-    {
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            return JsonServer::success('', InvoiceLogic::getInvoiceLists($get, $this->shop_id));
-        }
-        return view('', [
-            'order_status' => order::getOrderStatus(true)
-        ]);
-    }
-
-
-    /**
-     * @notes 开票
-     * @return \think\response\Json|\think\response\View
-     * @author 段誉
-     * @date 2022/4/12 19:00
-     */
-    public function setInvoice()
-    {
-        if ($this->request->isAjax()) {
-            $params = (new OrderInvoiceValidate())->goCheck();
-            InvoiceLogic::setInvoice($params);
-            return JsonServer::success('操作成功');
-        }
-        $id = $this->request->get('id/d');
-        return view('detail', [
-            'detail' => InvoiceLogic::detail($id)
-        ]);
-    }
-
-
-    /**
-     * @notes 导出Excel
-     * @return \think\response\Json
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2022/4/24 10:20
-     */
-    public function export()
-    {
-        $params = $this->request->get();
-        $result = InvoiceLogic::export($params, $this->shop_id);
-        if(false === $result) {
-            return JsonServer::error(InvoiceLogic::getError() ?: '导出失败');
-        }
-        return JsonServer::success('', $result);
-    }
-
-}

+ 0 - 410
app/shop/controller/order/Order.php

@@ -1,410 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-
-namespace app\shop\controller\order;
-
-
-use app\common\basics\ShopBase;
-use app\common\model\order\OrderLog;
-use app\common\model\order\Order as OrderModel;
-use app\common\server\JsonServer;
-use app\shop\logic\order\OrderLogic;
-use app\common\model\Client_;
-use app\common\enum\PayEnum;
-use app\shop\validate\order\OrderPrintValidate;
-use app\shop\validate\order\VerificationValidate;
-use app\shop\validate\order\VirtualDeliveryValidate;
-use think\response\Json;
-
-/**
- * 订单管理
- * Class Goods
- */
-class Order extends ShopBase
-{
-
-    /**
-     * @notes 订单列表
-     * @return Json|\think\response\View
-     * @author suny
-     * @date 2021/7/14 10:15 上午
-     */
-    public function lists()
-    {
-        $data = OrderLogic::statistics(input(), $this->shop_id);
-    
-        // 订单状态
-        $order_status = OrderModel::getOrderStatus();
-        // 拼装数量统计
-        $order_status   = OrderLogic::getStat($order_status, $this->shop_id);
-        $all            = OrderLogic::getAll($this->shop_id);
-    
-        if ($this->request->isAjax()) {
-            $data['statistics'] = [
-                'all'           => $all,
-                'order_status'  => $order_status,
-            ];
-            return JsonServer::success('', $data);
-        }
-    
-        return view('', [
-            'all'           => $all,
-            'statistics'    => $data,
-            'order_status'  => $order_status,
-            'order_type'    => OrderModel::getOrderType(true),
-            'order_source'  => Client_::getClient(),
-            'pay_way'       => PayEnum::getPayWay(),
-            'delivery_type' => OrderModel::getDeliveryType(true),
-        ]);
-    }
-
-    public function totalCount()
-    {
-        if ($this->request->isAjax()) {
-            return JsonServer::success('获取成功', OrderLogic::totalCount($this->shop_id));
-        }
-    }
-
-    /**
-     * @notes 订单详情
-     * @return \think\response\View
-     * @author suny
-     * @date 2021/7/14 10:15 上午
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
-     * @throws \think\db\exception\DataNotFoundException
-     */
-
-    public function detail()
-    {
-
-        $id = $this->request->get('id');
-        $detail = OrderLogic::getDetail($id);
-        $order_log = OrderLog::getOrderLog($id);
-        return view('', [
-            'detail' => $detail,
-            'logs' => $order_log
-        ]);
-    }
-
-    /**
-     * @notes 物流信息
-     * @return \think\response\View
-     * @author suny
-     * @date 2021/7/14 10:15 上午
-     */
-    public function express()
-    {
-
-        $id = $this->request->get('id');
-        $detail = OrderLogic::getDetail($id);
-        $detail['shipping'] = OrderLogic::shippingInfo($detail['id']);
-        return view('', [
-            'detail' => $detail
-        ]);
-    }
-    
-    /**
-     * @notes 修改物流单号
-     * @return Json|\think\response\View
-     * @author lbzy
-     * @datetime 2024-04-03 11:02:33
-     */
-    function delivery_change()
-    {
-        if ($this->request->isAjax()) {
-            $result = OrderLogic::change_invoice_no(input());
-            
-            if ($result !== true) {
-                return JsonServer::error((string) $result);
-            }
-            
-            return JsonServer::success('修改成功');
-        }
-    
-        $id = $this->request->get('id');
-        $detail = OrderLogic::getDetail($id);
-        $express = OrderLogic::express();
-        $detail['shipping'] = OrderLogic::shippingInfo($detail['id']);
-        return view('', [
-            'detail' => $detail,
-            'express' => $express
-        ]);
-    }
-
-    /**
-     * @notes 发货
-     * @return \think\response\View
-     * @author suny
-     * @date 2021/7/14 10:15 上午
-     */
-    public function delivery()
-    {
-        $id = $this->request->get('id');
-        $detail = OrderLogic::getDetail($id);
-        $express = OrderLogic::express();
-        return view('', [
-            'detail' => $detail,
-            'express' => $express
-        ]);
-    }
-
-    /**
-     * @notes 发货操作
-     * @return Json
-     * @author suny
-     * @date 2021/7/14 10:15 上午
-     * @throws \think\exception\DbException
-     */
-    public function deliveryHandle()
-    {
-
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            
-            $check = (OrderLogic::checkDelivery($post));
-            
-            if (true !== $check) {
-                return JsonServer::error((string) $check);
-            }
-            
-            OrderLogic::deliveryHandle($post, $this->admin_id);
-            return JsonServer::success('发货成功');
-        }
-    }
-
-    /**
-     * @notes 确认收货
-     * @return Json
-     * @author suny
-     * @date 2021/7/14 10:16 上午
-     */
-    public function confirm()
-    {
-
-        if ($this->request->isAjax()) {
-            $post = $this->request->post('');
-            OrderLogic::confirm($post['order_id'], $this->admin_id);
-            return JsonServer::success('确认成功');
-        }
-    }
-
-    /**
-     * @notes 取消订单
-     * @return Json
-     * @author suny
-     * @date 2021/7/14 10:16 上午
-     */
-    public function cancel()
-    {
-
-        if ($this->request->isAjax()) {
-            $post = $this->request->post('');
-            $result = (OrderLogic::checkCancel($post));
-            if($result !== true){
-                return JsonServer::error($result,[],0,0);
-            }
-            $result = OrderLogic::cancel($post['order_id'], $this->admin_id);
-            if($result !== true){
-                return JsonServer::error($result,[],0,0);
-            }
-            return JsonServer::success('取消成功');
-        }
-    }
-
-    /**
-     * @notes 删除订单
-     * @return Json
-     * @author suny
-     * @date 2021/7/14 10:16 上午
-     */
-    public function del()
-    {
-
-        if ($this->request->isAjax()) {
-            $post = $this->request->post('');
-            (OrderLogic::checkDel($post));
-            OrderLogic::del($post['order_id'], $this->admin_id);
-            return JsonServer::success('删除成功');
-        }
-    }
-
-    /**
-     * @notes 商家备注
-     * @return Json
-     * @throws \think\Exception
-     * @author suny
-     * @date 2021/7/14 10:16 上午
-     */
-    public function remarks()
-    {
-
-        // 获取的
-        if ($this->request->isAjax() && $this->request->isGet()) {
-            $get = $this->request->get();
-            $detail = OrderLogic::remarks($get, 'get');
-            return JsonServer::success('获取成功', [$detail]);
-        }
-        // 提交的
-        if ($this->request->isAjax() && $this->request->isPost()) {
-            $post = $this->request->post();
-            $result = OrderLogic::remarks($post, 'post');
-            return json(['code' => 1, 'show' => 0, 'msg' => '修改成功', 'data' => $result]);
-        }
-    }
-
-
-    /**
-     * @notes 小票打印
-     * @return Json
-     * @author 段誉
-     * @date 2022/1/20 11:15
-     */
-    public function orderPrint()
-    {
-        $post = $this->request->post();
-        $post['shop_id'] = $this->shop_id;
-        (new OrderPrintValidate())->goCheck('', $post);
-        $result = OrderLogic::orderPrint($post['id'], $this->shop_id);
-        if (true === $result) {
-            return JsonServer::success('打印成功,如未出小票,请检查打印机是否在线');
-        }
-        return JsonServer::error($result);
-    }
-
-    /**
-     * @notes 修改地址
-     * @return \think\response\View
-     * @author suny
-     * @date 2021/7/14 10:16 上午
-     */
-    public function change_address()
-    {
-
-        // 获取的
-        $get = $this->request->get();
-        $data = OrderLogic::change_address($get);
-        $id = json_decode($data['info'], true)['id'];
-        return view('', [
-            'id' => $id,
-            'info' => $data['info'],
-            'address_tree' => $data['address_tree']
-        ]);
-    }
-
-    /**
-     * @notes 修改地址提交
-     * @return Json
-     * @author suny
-     * @date 2021/7/14 10:16 上午
-     */
-    public function change_address_post()
-    {
-
-        // 提交的
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            OrderLogic::change_address_post($post);
-            return JsonServer::success('修改地址成功');
-        }
-    }
-
-
-    /**
-     * @notes 虚拟发货
-     * @return Json|void
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2022/4/7 17:47
-     */
-    public function virtualDelivery()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            (new VirtualDeliveryValidate())->goCheck();
-            $result = OrderLogic::virtualDelivery($post, $this->admin_id);
-            if (false == $result) {
-                return JsonServer::error(OrderLogic::getError() ?: '发货失败');
-            }
-            return JsonServer::success('发货成功');
-        }
-    }
-
-
-    /**
-     * @notes 导出Excel
-     * @return Json
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2022/4/24 10:20
-     */
-    public function export()
-    {
-        $params = $this->request->get();
-        $result = OrderLogic::statistics($params, $this->shop_id, true);
-        if(false === $result) {
-            return JsonServer::error(OrderLogic::getError() ?: '导出失败');
-        }
-        return JsonServer::success('', $result);
-    }
-
-
-    /**
-     * @notes 提货核销
-     * @return Json|void
-     * @author 段誉
-     * @date 2022/11/2 15:52
-     */
-    public function verification()
-    {
-        if ($this->request->isAjax()) {
-            $params = $this->request->post();
-            (new VerificationValidate())->goCheck();
-            $result = OrderLogic::verification($params, $this->shop);
-            if(false === $result) {
-                return JsonServer::error(OrderLogic::getError() ?: '操作失败');
-            }
-            return JsonServer::success('操作成功');
-        }
-    }
-
-
-    /**
-     * @notes 确认付款
-     * @return Json|void
-     * @author ljj
-     * @date 2024/7/19 下午6:33
-     */
-    public function confirmPay()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post('');
-            $result = OrderLogic::confirmPay($post['order_id'], $this->admin_id);
-            if(true !== $result) {
-                return JsonServer::error($result);
-            }
-            return JsonServer::success('确认成功');
-        }
-    }
-}

+ 0 - 70
app/shop/controller/printer/Config.php

@@ -1,70 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-namespace app\shop\controller\printer;
-
-use app\common\basics\ShopBase;
-use app\shop\logic\printer\ConfigLogic;
-use app\shop\validate\printer\ConfigValidate;
-use app\common\server\JsonServer;
-
-/**
- * 打印设置控制器
- * Class Config
- * @package app\admin\controller\printer
- */
-class Config extends ShopBase
-{
-
-    /**
-     * @notes 打印机配置列表
-     * @return \think\response\Json|\think\response\View
-     * @author 段誉
-     * @date 2022/1/19 17:09
-     */
-    public function lists()
-    {
-        if ($this->request->isAjax()) {
-            $result = ConfigLogic::lists($this->shop_id);
-            return JsonServer::success('',  $result);
-        }
-        return view();
-    }
-
-    /**
-     * @notes 编辑打印机配置
-     * @return \think\response\Json|\think\response\View
-     * @author 段誉
-     * @date 2022/1/19 17:09
-     */
-    public function edit()
-    {
-        $id = $this->request->get('id/d');
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            (new ConfigValidate())->goCheck();
-            ConfigLogic::editConfig($post, $this->shop_id);
-            return JsonServer::success('修改成功');
-        }
-        return view('', [
-            'detail' => ConfigLogic::getDetail($id, $this->shop_id),
-        ]);
-    }
-
-}

+ 0 - 140
app/shop/controller/printer/Printer.php

@@ -1,140 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-namespace app\shop\controller\printer;
-
-use app\common\basics\ShopBase;
-use app\shop\logic\printer\PrinterLogic;
-use app\common\server\JsonServer;
-use app\shop\validate\printer\PrinterValidate;
-
-/**
- * 打印机管理控制器
- * Class Printer
- * @package app\admin\controller\printer
- */
-class Printer extends ShopBase
-{
-
-    /**
-     * @notes 打印机列表
-     * @return \think\response\Json|\think\response\View
-     * @author 段誉
-     * @date 2022/1/19 10:34
-     */
-    public function lists()
-    {
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            $result = PrinterLogic::lists($get, $this->shop_id);
-            return JsonServer::success('', $result);
-        }
-        return view();
-    }
-
-    /**
-     * Notes:添加打印机
-     * @return mixed
-     */
-    public function add()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            $post['del'] = 0;
-            $post['shop_id'] = $this->shop_id;
-            (new PrinterValidate())->goCheck('add', $post);
-            $result = PrinterLogic::add($post, $this->shop_id);
-            if (true === $result) {
-                return JsonServer::success('操作成功');
-            }
-            return JsonServer::error($result);
-        }
-        return view('', [
-            'type_list' => PrinterLogic::getTypeList($this->shop_id)
-        ]);
-    }
-
-
-    /**
-     * @notes 编辑打印机
-     * @return \think\response\Json|\think\response\View
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2022/1/20 10:59
-     */
-    public function edit()
-    {
-        $id = $this->request->get('id/d');
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            $post['del'] = 0;
-            $post['shop_id'] = $this->shop_id;
-            (new PrinterValidate())->goCheck('', $post);
-            $result = PrinterLogic::edit($post, $this->shop_id);
-            if (true === $result) {
-                return JsonServer::success('操作成功');
-            }
-            return JsonServer::error($result);
-        }
-        return view('', [
-            'type_list' => PrinterLogic::getTypeList($this->shop_id),
-            'detail' => PrinterLogic::getPrinter($id, $this->shop_id)
-        ]);
-    }
-
-
-    /**
-     * @notes 删除打印机
-     * @return \think\response\Json
-     * @author 段誉
-     * @date 2022/1/20 11:00
-     */
-    public function del()
-    {
-        if ($this->request->isAjax()) {
-            $id = $this->request->post('id');
-            (new PrinterValidate())->goCheck('del');
-            $result = PrinterLogic::del($id, $this->shop_id);
-            if (true === $result) {
-                return JsonServer::success('操作成功');
-            }
-            return JsonServer::error($result);
-        }
-        return JsonServer::error('操作失败');
-    }
-
-    
-    public function testPrint()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->post();
-            $post['shop_id'] = $this->shop_id;
-            (new PrinterValidate())->goCheck('config', $post);
-            $result = PrinterLogic::testPrint($post, $this->shop_id);
-            if (true === $result) {
-                return JsonServer::success('打印成功');
-            }
-            return JsonServer::error($result);
-        }
-        return JsonServer::error('操作失败');
-    }
-
-}

+ 0 - 57
app/shop/controller/printer/Template.php

@@ -1,57 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-namespace app\shop\controller\printer;
-
-use app\common\basics\ShopBase;
-use app\shop\logic\printer\TemplateLogic;
-use app\shop\validate\printer\TemplateValidate;
-use app\common\server\JsonServer;
-
-/**
- * 小票模板控制器
- * Class Template
- * @package app\admin\controller\printer
- */
-class Template extends ShopBase
-{
-    /**
-     * @notes 编辑小票模板
-     * @return \think\response\Json|\think\response\View
-     * @author 段誉
-     * @date 2022/1/19 16:45
-     */
-    public function edit()
-    {
-        if($this->request->isAjax()){
-            $post = $this->request->post();
-            (new TemplateValidate())->goCheck();
-            $res = TemplateLogic::edit($post, $this->shop_id);
-            if (true === $res) {
-                return JsonServer::success('操作成功');
-            }
-            return JsonServer::error($res);
-        }
-        return view('', [
-            'detail' => TemplateLogic::getDetail($this->shop_id),
-        ]);
-    }
-
-
-}

+ 0 - 113
app/shop/controller/seckill/SeckillGoods.php

@@ -1,113 +0,0 @@
-<?php
-namespace app\shop\controller\seckill;
-
-use app\common\basics\ShopBase;
-use app\common\server\JsonServer;
-use app\shop\logic\seckill\SeckillGoodsLogic;
-use think\exception\ValidateException;
-use app\shop\validate\SeckillGoodsValidate;
-
-class SeckillGoods extends ShopBase
-{
-    public function lists()
-    {
-        $statistics = SeckillGoodsLogic::statistics($this->shop_id);
-        $seckill_time = SeckillGoodsLogic::getTimeAll();
-        return view('', [
-            'statistics' => $statistics,
-            'seckill_time' => $seckill_time
-        ]);
-    }
-
-    public function addGoods(){
-        if($this->request->isAjax()){
-            $post = $this->request->post();
-            $post['item'] = form_to_linear($post);
-            $post['shop_id'] = $this->shop_id;
-            try{
-                validate(SeckillGoodsValidate::class)->scene('add')->check($post);
-            }catch(ValidateException $e) {
-                return JsonServer::error($e->getError());
-            }
-            $result = SeckillGoodsLogic::addGoods($post);
-            if($result === true) {
-                return JsonServer::success('新增成功');
-            }
-            return JsonServer::error(SeckillGoodsLogic::getError());
-        }
-
-        $seckill_time = SeckillGoodsLogic::getTimeAll();
-        return view('', [
-            'seckill' => $seckill_time
-        ]);
-    }
-
-    public function goodsLists(){
-        if($this->request->isAjax()){
-            $get = $this->request->get();
-            $get['shop_id'] = $this->shop_id;
-            $list = SeckillGoodsLogic::goodsList($get);
-            return JsonServer::success('', $list);
-        }
-    }
-
-    public function editGoods(){
-        if($this->request->isAjax()){
-            $post = $this->request->post();
-            $post['item'] = form_to_linear($post);
-            $post['shop_id'] = $this->shop_id;
-            try{
-                validate(SeckillGoodsValidate::class)->scene('edit')->check($post);
-            }catch(ValidateException $e) {
-                return JsonServer::error($e->getError());
-            }
-            $result = SeckillGoodsLogic::editGoods($post);
-            if($result === true) {
-                return JsonServer::success('编辑成功');
-            }
-            return JsonServer::error(SeckillGoodsLogic::getError());
-        }
-
-
-        $id = $this->request->get('id');
-        $seckill_id = $this->request->get('seckill_id');
-        $start_date = $this->request->get('start_date');
-        $end_date = $this->request->get('end_date');
-
-        $detail = SeckillGoodsLogic::getSeckillGoods($id,$seckill_id,$start_date,$end_date);
-        $seckill_time = SeckillGoodsLogic::getTimeAll();
-        return view('', [
-            'seckill' => $seckill_time,
-            'detail' => $detail
-        ]);
-    }
-
-    public function delGoods(){
-        if($this->request->isAjax()){
-            $id = $this->request->post('id');
-            $seckill_id = $this->request->post('seckill_id');
-            $start_date = $this->request->post('start_date');
-            $end_date = $this->request->post('end_date');
-            $shop_id = $this->shop_id;
-
-            $result = SeckillGoodsLogic::delGoods($id,$seckill_id,$start_date,$end_date,$shop_id);
-            if($result === true) {
-                return JsonServer::success('删除成功');
-            }
-            return JsonServer::error(SeckillGoodsLogic::getError());
-        }
-    }
-
-    /**
-     * @notes 获取统计数据
-     * @return \think\response\Json
-     * @author Tab
-     * @date 2021/7/29 10:00
-     */
-    public function totalCount()
-    {
-        if ($this->request->isAjax()) {
-            return JsonServer::success('获取成功', SeckillGoodsLogic::statistics($this->shop_id));
-        }
-    }
-}

+ 0 - 39
app/shop/controller/setting/CustomerService.php

@@ -1,39 +0,0 @@
-<?php
-namespace app\shop\controller\setting;
-
-use app\common\basics\ShopBase;
-use app\common\server\ConfigServer;
-use app\common\server\JsonServer;
-use app\common\server\UrlServer;
-
-class CustomerService extends ShopBase
-{
-    public function index()
-    {
-        $image = ConfigServer::get('shop_customer_service', 'image', '', $this->shop_id);
-        $image = $image ? UrlServer::getFileUrl($image) : '';
-        $config = [
-            'type'              => ConfigServer::get('shop_customer_service', 'type', 1,$this->shop_id),
-            'wechat' => ConfigServer::get('shop_customer_service', 'wechat', '', $this->shop_id),
-            'phone' => ConfigServer::get('shop_customer_service', 'phone', '', $this->shop_id),
-            'business_time' => ConfigServer::get('shop_customer_service', 'business_time', '', $this->shop_id),
-            'image' => $image,
-        ];
-        return view('', [
-            'config' => $config
-        ]);
-    }
-
-    public function set()
-    {
-        $post = $this->request->post();
-        ConfigServer::set('shop_customer_service', 'type', $post['type'], $this->shop_id);
-        ConfigServer::set('shop_customer_service', 'wechat', $post['wechat'], $this->shop_id);
-        ConfigServer::set('shop_customer_service', 'phone', $post['phone'], $this->shop_id);
-        ConfigServer::set('shop_customer_service', 'business_time', $post['business_time'], $this->shop_id);
-        if(isset($post['image'])){
-            ConfigServer::set('shop_customer_service', 'image', clearDomain($post['image']), $this->shop_id);
-        }
-        return JsonServer::success('设置成功');
-    }
-}

+ 0 - 167
app/shop/controller/team/Activity.php

@@ -1,167 +0,0 @@
-<?php
-
-
-namespace app\shop\controller\team;
-
-
-use app\common\basics\ShopBase;
-use app\common\server\JsonServer;
-use app\shop\logic\team\ActivityLogic;
-use app\shop\validate\TeamValidate;
-use think\facade\View;
-
-class Activity extends ShopBase
-{
-    /**
-     * @Notes: 拼团活动列表
-     * @Author: 张无忌
-     */
-    public function lists()
-    {
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            $lists = ActivityLogic::lists($get, $this->shop_id);
-            return JsonServer::success('获取成功', $lists);
-        }
-
-        View::assign('statistics', ActivityLogic::statistics($this->shop_id));
-        return view();
-    }
-
-    /**
-     * @Notes: 选择拼团商品
-     * @Author: 张无忌
-     */
-    public function select()
-    {
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            $lists = ActivityLogic::select($get, $this->shop_id);
-            return JsonServer::success('获取成功', $lists);
-        }
-
-        return view();
-    }
-
-    /**
-     * @Notes: 数据统计
-     * @Author: 张无忌
-     */
-    public function statistics()
-    {
-        if ($this->request->isAjax()) {
-            $detail = ActivityLogic::statistics($this->shop_id);
-            return JsonServer::success('获取成功', $detail);
-        }
-        return JsonServer::error('异常');
-    }
-
-    /**
-     * @Notes: 拼团活动详细
-     * @Author: 张无忌
-     */
-    public function detail()
-    {
-        $id = $this->request->get('id');
-        View::assign('detail', ActivityLogic::detail($id));
-        return view();
-    }
-
-    /**
-     * @Notes: 新增拼团活动
-     * @Author: 张无忌
-     */
-    public function add()
-    {
-        if ($this->request->isAjax()) {
-            (new TeamValidate())->goCheck('add');
-            $post = $this->request->post();
-            $lists = ActivityLogic::add($post, $this->shop_id);
-            if ($lists === false) {
-                $message = ActivityLogic::getError() ?: '新增失败';
-                return JsonServer::error($message);
-            }
-            return JsonServer::success('新增成功');
-        }
-
-        return view();
-    }
-
-    /**
-     * @Notes: 编辑拼团活动
-     * @Author: 张无忌
-     */
-    public function edit()
-    {
-        if ($this->request->isAjax()) {
-            (new TeamValidate())->goCheck('edit');
-            $post = $this->request->post();
-            $lists = ActivityLogic::edit($post, $this->shop_id);
-            if ($lists === false) {
-                $message = ActivityLogic::getError() ?: '编辑失败';
-                return JsonServer::error($message);
-            }
-            return JsonServer::success('编辑成功');
-        }
-
-        $id = $this->request->get('id');
-        View::assign('detail', ActivityLogic::detail($id));
-        return view();
-    }
-
-    /**
-     * @Notes: 删除拼团活动
-     * @Author: 张无忌
-     */
-    public function del()
-    {
-        if ($this->request->isAjax()) {
-            (new TeamValidate())->goCheck('id');
-            $id = $this->request->post('id');
-            $lists = ActivityLogic::del($id);
-            if ($lists === false) {
-                $message = ActivityLogic::getError() ?: '删除失败';
-                return JsonServer::error($message);
-            }
-            return JsonServer::success('删除成功');
-        }
-        return JsonServer::error('请求异常');
-    }
-
-    /**
-     * @Notes: 停止活动
-     * @Author: 张无忌
-     */
-    public function stop()
-    {
-        if ($this->request->isAjax()) {
-            (new TeamValidate())->goCheck('id');
-            $id = $this->request->post('id');
-            $lists = ActivityLogic::stop($id);
-            if ($lists === false) {
-                $message = ActivityLogic::getError() ?: '停止失败';
-                return JsonServer::error($message);
-            }
-            return JsonServer::success('停止成功');
-        }
-        return JsonServer::error('请求异常');
-    }
-
-    /**
-     * @Notes: 开启拼团活动
-     * @Author: 张无忌
-     */
-    public function open()
-    {
-        if ($this->request->isAjax()) {
-            $id = $this->request->post('id');
-            $lists = ActivityLogic::open($id);
-            if ($lists === false) {
-                $message = ActivityLogic::getError() ?: '开启失败';
-                return JsonServer::error($message);
-            }
-            return JsonServer::success('开启成功');
-        }
-        return JsonServer::error('请求异常');
-    }
-}

+ 0 - 93
app/shop/controller/team/Found.php

@@ -1,93 +0,0 @@
-<?php
-
-
-namespace app\shop\controller\team;
-
-use app\common\basics\ShopBase;
-use app\common\server\JsonServer;
-use app\shop\logic\team\FoundLogic;
-use think\facade\View;
-
-/**
- * 拼团记录管理
- * Class Record
- * @package app\shop\controller\team
- */
-class Found extends ShopBase
-{
-    /**
-     * @Notes: 拼团记录
-     * @Author: 张无忌
-     */
-    public function lists()
-    {
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            $lists = FoundLogic::lists($get, $this->shop_id);
-            return JsonServer::success('获取成功', $lists);
-        }
-
-        $team_activity_id = $this->request->get('team_activity_id', 0);
-        View::assign('team_activity_id', $team_activity_id);
-        View::assign('statistics', FoundLogic::statistics($this->shop_id, $team_activity_id));
-        return view();
-    }
-
-    /**
-     * @Notes: 数据统计
-     * @Author: 张无忌
-     */
-    public function statistics()
-    {
-        if ($this->request->isAjax()) {
-            $team_activity_id = $this->request->get('team_activity_id', 0);
-            $detail = FoundLogic::statistics($this->shop_id, $team_activity_id);
-            return JsonServer::success('获取成功', $detail);
-        }
-        return JsonServer::error('异常');
-    }
-
-
-    /**
-     * @Notes: 拼团记录详细
-     * @Author: 张无忌
-     */
-    public function detail()
-    {
-        $id = $this->request->get('id');
-        View::assign('detail', FoundLogic::detail($id));
-        return view();
-    }
-
-    /**
-     * @Notes: 参团列表
-     * @Author: 张无忌
-     */
-    public function join()
-    {
-        if ($this->request->isAjax()) {
-            $get = $this->request->get();
-            $lists = FoundLogic::join($get);
-            return JsonServer::success('获取成功', $lists);
-        }
-        return JsonServer::error('请求异常');
-    }
-
-    /**
-     * @Notes: 结束拼团
-     * @Author: 张无忌
-     */
-    public function end()
-    {
-        if ($this->request->isAjax()) {
-            $team_id = $this->request->post('team_id');
-            $res = FoundLogic::end($team_id);
-            if ($res === false) {
-                $message = FoundLogic::getError() ?: '结束失败';
-                return JsonServer::error($message);
-            }
-            return JsonServer::success('结束成功');
-        }
-        return JsonServer::error('请求异常');
-    }
-}

+ 0 - 33
app/shop/controller/user/User.php

@@ -1,33 +0,0 @@
-<?php
-namespace app\shop\controller\user;
-
-use app\common\basics\ShopBase;
-use app\common\enum\ClientEnum;
-use app\common\server\JsonServer;
-use app\shop\logic\user\UserLogic;
-
-class User extends ShopBase
-{
-    public function lists()
-    {
-        if($this->request->isAjax()) {
-            $get = $this->request->get();
-            $get['shop_id'] = $this->shop_id;
-            $data = UserLogic::lists($get);
-            return JsonServer::success('', $data);
-        }
-
-        return view('', [
-            'client_list' => ClientEnum::getClient(true)
-        ]);
-    }
-
-    public function info()
-    {
-        $id = $this->request->get('id', '', 'intval');
-        $detail = UserLogic::getInfo($id);
-        return view('', [
-            'detail' => $detail
-        ]);
-    }
-}

+ 0 - 181
app/shop/logic/AdminLogic.php

@@ -1,181 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-
-namespace app\shop\logic;
-
-
-use app\common\basics\Logic;
-use app\common\model\Admin;
-use app\common\model\shop\ShopAdmin;
-use app\common\model\shop\ShopRole;
-
-class AdminLogic extends Logic
-{
-
-    /**
-     * Notes: 列表
-     * @param $get
-     * @author 段誉(2021/4/10 11:05)
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     */
-    public static function lists($get, $shop_id)
-    {
-        $roleModel = new  ShopRole();
-        $adminModel = new ShopAdmin();
-
-        $role_column = $roleModel->getNameColumn();
-
-        $where[] = ['del', '=', 0];
-        $where[] = ['shop_id', '=', $shop_id];
-        if (isset($get['role_id']) && $get['role_id']) {
-            $where[] = ['role_id', '=', $get['role_id']];
-        }
-        if (isset($get['name']) && $get['name']) {
-            $where[] = ['name', 'like', "%{$get['name']}%"];
-        }
-        if (isset($get['account']) && $get['account']) {
-            $where[] = ['account', 'like', "%{$get['account']}%"];
-        }
-
-        $result = $adminModel->where($where)
-            ->hidden(['password', 'salt'])
-            ->paginate([
-                'list_rows'=> $get['limit'],
-                'page'=> $get['page']
-            ]);
-
-        foreach ($result as $k => $item) {
-            if ($item['root'] == 1) {
-                $role = '超级管理员';
-            } else {
-                $role = $role_column[$item['role_id']] ?? '';
-            }
-            $result[$k]['role'] = $role;
-        }
-        return ['count' => $result->total(), 'lists' => $result->getCollection()];
-    }
-
-
-    /**
-     * Notes: 添加管理员
-     * @param $post
-     * @author 段誉(2021/4/10 16:14)
-     * @return Admin|\think\Model
-     */
-    public static function addAdmin($shop_id, $post)
-    {
-        $time = time();
-        $salt = substr(md5($time . $post['name']), 0, 4);//随机4位密码盐
-        $password = generatePassword($post['password'], $salt);//生成密码
-        return ShopAdmin::create([
-            'name'     => $post['name'],
-            'shop_id'  => $shop_id,
-            'root'     => 0,
-            'account'  => $post['account'],
-            'password' => $password,
-            'salt'     => $salt,
-            'role_id'  => $post['role_id'],
-            'disable'   => $post['disable']
-        ]);
-    }
-
-
-    /**
-     * Notes: 更新管理员
-     * @param $post
-     * @author 段誉(2021/4/10 17:11)
-     * @return bool
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     */
-    public static function editAdmin($shop_id, $post)
-    {
-        $admin = ShopAdmin::where('shop_id', $shop_id)->find($post['id']);
-
-        if(empty($admin)) {
-            self::$error = '未找到相关管理员';
-            return false;
-        }
-
-        $data = [
-            'name'          => $post['name'],
-            'account'       => $post['account'],
-            'role_id'       => $post['role_id'],
-            'update_time'   => time(),
-            'disable'       => $post['disable']
-        ];
-
-        //生成密码
-        if ($post['password']) {
-            $data['password'] = generatePassword($post['password'], $admin['salt']);
-        }
-
-        //TODO 禁用管理员并强制下线
-        if (1 == $post['disable'] || $admin['role_id'] != $post['role_id']) {
-
-        }
-
-        return $admin->save($data);
-    }
-
-
-    /**
-     * Notes: 删除
-     * @param $shop_id
-     * @param $id
-     * @author 段誉(2021/5/7 11:11)
-     * @return ShopAdmin
-     */
-    public static function delAdmin($shop_id, $id)
-    {
-        return ShopAdmin::update([
-            'account' => time() . '_' . $id,
-            'del' => 1,
-            'shop_id' => $shop_id
-        ], ['id' => $id]);
-    }
-
-
-    /**
-     * Notes: 修改密码
-     * @param $password
-     * @param $admin_id
-     * @param $shop_id
-     * @author 段誉(2021/5/7 11:15)
-     * @return bool
-     */
-    public static function updatePassword($password, $admin_id, $shop_id)
-    {
-        try {
-            $admin = ShopAdmin::where(['id' => $admin_id, 'shop_id' => $shop_id])->find();
-            $admin->password = generatePassword($password, $admin['salt']);
-            $admin->save();
-            return true;
-        } catch (\Exception $e) {
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-}

+ 0 - 111
app/shop/logic/AlipayLogic.php

@@ -1,111 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-namespace app\shop\logic;
-
-use app\common\basics\Logic;
-use app\common\model\shop\ShopAlipay;
-
-class AlipayLogic extends Logic
-{
-    static function lists($get, $shop_id)
-    {
-        try {
-            $model = new ShopAlipay();
-            $lists = $model->field(true)
-                ->where(['del' => 0, 'shop_id'=>$shop_id])
-                ->order('id', 'desc')
-                ->paginate([
-                    'page'      => $get['page'] ?? 1,
-                    'list_rows' => $get['limit'] ?? 20,
-                    'var_page'  => 'page'
-                ])->toArray();
-            
-            return [ 'count'=>$lists['total'], 'lists'=>$lists['data'] ];
-        } catch (\Exception $e) {
-            return [ 'error'=>$e->getMessage() ];
-        }
-    }
-    
-    static function detail($id)
-    {
-        $model = new ShopAlipay();
-        return $model->field(true)->findOrEmpty($id);
-    }
-    
-    static function add($post, $shop_id)
-    {
-        try {
-            ShopAlipay::create([
-                'shop_id'   => $shop_id,
-                'account'   => $post['account'],
-                'username'  => $post['username'],
-                'del'       => 0,
-            ]);
-            
-            return true;
-        } catch (\Exception $e) {
-            static::$error = $e->getMessage();
-            return false;
-        }
-    }
-    
-    static function edit($post, $shop_id)
-    {
-        try {
-            ShopAlipay::update([
-                'account'   => $post['account'],
-                'username'  => $post['username'],
-                'del'       => 0,
-            ], [ 'id' => $post['id'], 'shop_id' => $shop_id ]);
-            
-            return true;
-        } catch (\Exception $e) {
-            static::$error = $e->getMessage();
-            return false;
-        }
-    }
-    
-    static function del($id, $shop_id)
-    {
-        try {
-            ShopAlipay::update([
-                'del'         => 1,
-                'update_time' => time()
-            ], [ 'id' => $id, 'shop_id' => $shop_id ]);
-            
-            return true;
-        } catch (\Exception $e) {
-            static::$error = $e->getMessage();
-            return false;
-        }
-    }
-    
-    static function getAlipayByShopId($shop_id)
-    {
-        try {
-            $model = new ShopAlipay();
-            return $model->field(true)
-                ->where(['del' => 0, 'shop_id'=>$shop_id])
-                ->order('id', 'desc')
-                ->select()->toArray();
-        } catch (\Exception $e) {
-            return ['error'=>$e->getMessage()];
-        }
-    }
-}

+ 0 - 139
app/shop/logic/BankLogic.php

@@ -1,139 +0,0 @@
-<?php
-
-
-namespace app\shop\logic;
-
-
-use app\common\basics\Logic;
-use app\common\model\shop\ShopBank;
-
-class BankLogic extends Logic
-{
-    /**
-     * @Notes: 银行列表
-     * @Author: 张无忌
-     * @param $get
-     * @param $shop_id
-     * @return array
-     */
-    public static function lists($get, $shop_id)
-    {
-        try {
-            $model = new ShopBank();
-            $lists = $model->field(true)
-                ->where(['del' => 0, 'shop_id'=>$shop_id])
-                ->order('id', 'desc')
-                ->paginate([
-                    'page' => $get['page'] ?? 1,
-                    'list_rows' => $get['limit'] ?? 20,
-                    'var_page' => 'page'
-                ])->toArray();
-
-            return ['count'=>$lists['total'], 'lists'=>$lists['data']];
-        } catch (\Exception $e) {
-            return ['error'=>$e->getMessage()];
-        }
-    }
-
-    /**
-     * @Notes: 获取商家银行卡账号列表
-     * @Author: 张无忌
-     * @param $shop_id
-     * @return array
-     */
-    public static function getBankByShopId($shop_id)
-    {
-        try {
-            $model = new ShopBank();
-            return $model->field(true)
-                ->where(['del' => 0, 'shop_id'=>$shop_id])
-                ->order('id', 'desc')
-                ->select()->toArray();
-        } catch (\Exception $e) {
-            return ['error'=>$e->getMessage()];
-        }
-    }
-
-    /**
-     * @Notes: 银行卡详细
-     * @Author: 张无忌
-     * @param $id
-     * @return array
-     */
-    public static function detail($id)
-    {
-        $model = new ShopBank();
-        return $model->field(true)->findOrEmpty($id);
-    }
-
-    /**
-     * @Notes: 新增银行卡账号
-     * @Author: 张无忌
-     * @param $post
-     * @param $shop_id
-     * @return bool
-     */
-    public static function add($post, $shop_id)
-    {
-        try {
-            ShopBank::create([
-                'shop_id'  => $shop_id,
-                'name'     => $post['name'],
-                'branch'   => $post['branch'],
-                'nickname' => $post['nickname'],
-                'account'  => $post['account'],
-                'del'      => 0
-            ]);
-
-            return true;
-        } catch (\Exception $e) {
-            static::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-    /**
-     * @Notes: 编辑银行卡
-     * @Author: 张无忌
-     * @param $post
-     * @return bool
-     */
-    public static function edit($post)
-    {
-        try {
-            ShopBank::update([
-                'name'     => $post['name'],
-                'branch'   => $post['branch'],
-                'nickname' => $post['nickname'],
-                'account'  => $post['account'],
-                'del'      => 0
-            ], ['id'=>$post['id']]);
-
-            return true;
-        } catch (\Exception $e) {
-            static::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-    /**
-     * @Notes: 删除银行卡
-     * @Author: 张无忌
-     * @param $id
-     * @return bool
-     */
-    public static function del($id)
-    {
-        try {
-            ShopBank::update([
-                'del'         => 1,
-                'update_time' => time()
-            ], ['id'=>$id]);
-
-            return true;
-        } catch (\Exception $e) {
-            static::$error = $e->getMessage();
-            return false;
-        }
-    }
-}

+ 0 - 98
app/shop/logic/CommonLogic.php

@@ -1,98 +0,0 @@
-<?php
-namespace  app\shop\logic;
-
-use app\common\basics\Logic;
-use app\common\model\goods\Goods;
-use app\common\model\goods\GoodsItem;
-use app\common\server\UrlServer;
-use app\common\enum\GoodsEnum;
-
-class CommonLogic extends Logic
-{
-    public static function getGoodsList($get)
-    {
-        $where = [
-            ['shop_id', '=', $get['shop_id']],
-            ['del', '=', GoodsEnum::DEL_NORMAL], // 未删除
-            ['audit_status', '=', GoodsEnum::AUDIT_STATUS_OK], // 审核通过
-            ['status', '=', GoodsEnum::STATUS_SHELVES], // 上架中
-            ['type', '=', GoodsEnum::TYPE_ACTUAL] // 实物商品才参与
-        ];
-        if(!empty($get['keyword'])) {
-            $where[] = ['name', 'like','%'. $get['keyword'].'%'];
-        }
-        if(!empty($get['cid'])) {
-            $where[] = ['shop_cate_id', '=', $get['cid']];
-        }
-
-        $lists = Goods::field('id,name,image,min_price as min_max_price,min_price,max_price,stock')
-            ->where($where)
-            ->order('id', 'desc')
-            ->page($get['page'], $get['limit'])
-            ->select()
-            ->toArray();
-
-        $count = Goods::field('id,name,image,min_price,max_price,stock')
-            ->where($where)
-            ->count();
-
-        foreach($lists as &$item) {
-           $item['image'] = UrlServer::getFileUrl($item['image']);
-        }
-
-        return [
-            'count' => $count,
-            'lists' => $lists
-        ];
-    }
-
-    //获取商品列表
-    public static function getGoodsListTwo($get,$is_item = false){
-        $where = [
-            ['shop_id', '=', $get['shop_id']],
-            ['del', '=', GoodsEnum::DEL_NORMAL], // 未删除
-            ['audit_status', '=', GoodsEnum::AUDIT_STATUS_OK], // 审核通过
-            ['status', '=', GoodsEnum::STATUS_SHELVES], // 上架中
-            ['type', '=', GoodsEnum::TYPE_ACTUAL] // 实物商品才参与
-        ];
-
-        if (isset($get['keyword']) && $get['keyword']) {
-            $where[] = ['name', 'like', '%' . $get['keyword'] . '%'];
-        }
-        if(!empty($get['cid'])) {
-            $where[] = ['shop_cate_id', '=', $get['cid']];
-        }
-
-        $goods_count = Goods::where($where)->count();
-
-        $goods_list = Goods::where($where)
-            ->page($get['page'], $get['limit'])
-            ->column('*','id');
-
-        foreach ($goods_list as &$item) {
-            $item['goods_item'] = [];
-            $item['price'] = '¥'.$item['min_price'];
-            if($item['max_price'] != $item['min_price']){
-                $item['price'] = '¥'.$item['min_price'].'~'.'¥'.$item['max_price'];
-            }
-            $item['create_time_desc'] = date('Y-m-d H:i:s',$item['create_time']);
-            $item['image'] = UrlServer::getFileUrl($item['image']);
-        }
-
-        if($is_item){
-            $goods_ids = array_keys($goods_list);
-            $goods_item = GoodsItem::where(['goods_id'=>$goods_ids])->select()->toArray();
-            foreach ($goods_item as $items){
-                if(isset($goods_list[$items['goods_id']])){
-                    if($items['image']){
-                        $items['image'] = UrlServer::getFileUrl($items['image']);
-                    }else{
-                        $items['image'] = $goods_list[$items['goods_id']]['image'];
-                    }
-                    $goods_list[$items['goods_id']]['goods_item'][] = $items;
-                }
-            }
-        }
-        return ['count' => $goods_count, 'list' =>array_values($goods_list)];
-    }
-}

+ 0 - 502
app/shop/logic/FileLogic.php

@@ -1,502 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-namespace app\shop\logic;
-
-
-use app\common\basics\Logic;
-use app\common\enum\FileEnum;
-use app\common\model\File;
-use app\common\model\FileCate;
-use Exception;
-
-class FileLogic extends Logic
-{
-
-    /**
-     * NOTE: 获取文件列表
-     * @author: 张无忌
-     * @param $get
-     * @return array|\think\Paginator
-     */
-    public static function getFile($get)
-    {
-        try {
-            $where = [
-                ['del', '=', 0],
-                ['type', '=', $get['type'] ?? FileEnum::IMAGE_TYPE],
-                ['shop_id', '=', $get['shop_id']]
-            ];
-
-            if (!empty($get['cid']) and $get['cid'] > 0) {
-                $lists = FileCate::where(['del'=>0 ])->select();
-                $lists = !empty($lists) ? $lists->toArray() : [];
-                $childs = self::getChildCid($lists, $get['cid'], true);
-                array_push($childs, $get['cid']);
-                $where[] = ['cid', 'in', $childs];
-            }
-
-            $model = new File();
-            return $model->field(true)
-                ->where($where)
-                ->order('id', 'desc')
-                ->paginate([
-                    'page'      => $get['page'] ?? 1,
-                    'list_rows' => $get['limit'] ?? 20,
-                    'var_page' => 'page'
-                ])->toArray();
-
-        } catch (Exception $e) {
-            return [];
-        }
-    }
-
-    /**
-     * NOTE: 获取后代分类
-     * @author: 张无忌
-     * @param $cid
-     * @param array $ids
-     */
-    public static function getChildCid($lists, $cid, $clear)
-    {
-        static $temp = [];
-        if($clear) {
-            $temp = [];
-        }
-        foreach($lists as $item) {
-            if($item['pid'] == $cid) {
-                $temp[] = $item['id'];
-                self::getChildCid($lists, $item['id'], false);
-            }
-        }
-        return $temp;
-    }
-
-    /**
-     * NOTE: 移动文件
-     * @param $post
-     * @return bool
-     * @author: 张无忌
-     */
-    public static function move($post)
-    {
-        try {
-            $model = new File();
-//            $file = $model->field(true)->findOrEmpty($post['file_ids'][0])->toArray();
-//            if ($file['cid'] == $post['cid'] and $post['cid'] != 0) {
-//                static::$error = '文件已在当前目录,无需移动';
-//                return false;
-//            }
-
-            $model->whereIn('id', $post['file_ids'])
-                ->update(['cid' => $post['cid']]);
-
-            return true;
-        } catch (Exception $e) {
-            static::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-    /**
-     * NOTE: 删除文件
-     * @param $post
-     * @return bool
-     * @author: 张无忌
-     */
-    public static function del($post)
-    {
-        try {
-            $model = new File();
-            $model->whereIn('id', $post['file_ids'])
-                ->update(['del' => 1]);
-
-            return true;
-        } catch (Exception $e) {
-            static::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-    /** ======================== 华丽的分割线, 下面是文件分类相关 ========================**/
-
-    /**
-     * NOTE: 获取分类列表
-     * @param $type (类型: 10=图片, 20=视频, 30=文件)
-     * @return array
-     * @author: 张无忌
-     */
-    public static function getCate($get)
-    {
-        try {
-            $lists = FileCate::where([
-                ['del', '=', 0],
-                ['type', '=', $get['type']],
-                ['shop_id', '=', $get['shop_id']],
-            ])->order('id', 'asc')->order('sort', 'desc')->select();
-            $tree = self::cateListToTree($lists, 0);
-
-            $all = [
-                'id'       => 0,
-                'field'    => 'all',
-                'title'    => '全部',
-                'children' => [],
-            ];
-
-            array_unshift($tree, $all);
-            return $tree;
-        } catch (Exception $e) {
-            return [];
-        }
-    }
-
-    /**
-     * NOTE: 分类列表转树形结构
-     * @author: 张无忌
-     * @param $lists
-     * @param int $pid
-     * @return array
-     */
-    public static function cateListToTree($lists, $pid = 0)
-    {
-        $tree = [];
-        foreach ($lists as $k => $v) {
-            if ($v['pid'] == $pid) {
-                $temp['id'] = $v['id'];
-                $temp['field'] = 'id';
-                $temp['title'] = $v['name'];
-                $temp['children'] = self::cateListToTree($lists, $v['id']);
-                $temp['spread'] = true;
-                $tree[] = $temp;
-            }
-        }
-        return $tree;
-    }
-
-    /**
-     * NOTE: 分类详细
-     * @author: 张无忌
-     * @param $id
-     * @return array
-     */
-    public static function getCateById($id)
-    {
-        $model = new FileCate();
-        return $model->field(true)
-            ->findOrEmpty($id)->toArray();
-    }
-
-    /**
-     * NOTE: 新增分类
-     * @author: 张无忌
-     * @param $post
-     * @return bool
-     */
-    public static function addCate($post)
-    {
-        try {
-            if($post['pid'] == 0) {
-                $level = 1;
-            }else{
-                $parent = FileCate::find($post['pid']);
-                $level = $parent['level'] + 1;
-            }
-            if($post['sort'] < 0) {
-                throw new \think\Exception('排序值不能为负数');
-            }
-            FileCate::create([
-                'name' => $post['name'],
-                'pid'  => $post['pid'],
-                'sort' => $post['sort'],
-                'shop_id' => $post['shop_id'],
-                'level' => $level,
-                'type' => $post['type']
-            ]);
-
-            return true;
-        } catch (Exception $e) {
-            static::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-
-    /**
-     * NOTE: 编辑分类
-     * @author: 张无忌
-     * @param $post
-     * @return bool
-     */
-    public static function editCate($post)
-    {
-        try {
-            self::checkEdit($post);
-
-            FileCate::update([
-                'name' => $post['name'],
-                'pid'  => $post['cid'],
-                'sort' => $post['sort'],
-                'update_time' => time()
-            ], ['id'=>$post['id']]);
-
-            self::updateLevel($post['id']);
-
-            return true;
-        } catch (Exception $e) {
-            static::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-    /**
-     * NOTE: 删除分类
-     * @author: 张无忌
-     * @param $id
-     * @return bool
-     */
-    public static function delCate($id)
-    {
-        try {
-            self::checkDel($id);
-
-            FileCate::update([
-                'del' => 1,
-                'update_time' => time()
-            ], ['id'=>$id]);
-
-            return true;
-        } catch (Exception $e) {
-            static::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-    /**
-     * NOTE: 下拉框树状结构
-     * @param $type
-     * @return array
-     * @author: 张无忌
-     */
-    public static function categoryToSelect($get)
-    {
-        try {
-            $model = new FileCate();
-            $lists = $model->field(true)
-                ->where('del', '=', 0)
-                ->where('type', '=', $get['type'])
-                ->where('shop_id', '=', $get['shop_id'])
-                ->order('id', 'asc')
-                ->select();
-
-            $tree = [];
-            foreach ($lists as $val) {
-
-                if ($val['pid'] != 0) {
-                    continue;
-                }
-
-                $tree[$val['id']] = "|----" . $val['name'];
-                foreach ($lists as $val2) {
-                    if ($val2['pid'] == $val['id']) {
-                        $tree[$val2['id']] = "|--------" . $val2['name'];
-                    }
-                }
-
-            }
-
-            return $tree;
-        } catch (Exception $e) {
-            return [];
-        }
-    }
-
-    public static function categoryToSelectThree($get)
-    {
-        try {
-            $model = new FileCate();
-            $lists = $model->field(true)
-                ->where('del', '=', 0)
-                ->where('type', '=', $get['type'])
-                ->where('shop_id', '=', $get['shop_id'])
-                ->order('id', 'asc')
-                ->select();
-
-            $tree = [];
-            foreach ($lists as $val) {
-
-                if ($val['pid'] != 0) {
-                    continue;
-                }
-
-                $tree[$val['id']] = "|----" . $val['name'];
-                foreach ($lists as $val2) {
-                    if ($val2['pid'] == $val['id']) {
-                        $tree[$val2['id']] = "|--------" . $val2['name'];
-                        foreach($lists as $val3) {
-                            if($val3['pid'] == $val2['id']) {
-                                $tree[$val3['id']] = "|------------" . $val3['name'];
-                            }
-                        }
-                    }
-                }
-
-            }
-
-            return $tree;
-        } catch (Exception $e) {
-            return [];
-        }
-    }
-
-    /**
-     * 编辑验证
-     */
-    public static function checkEdit($post)
-    {
-        if(empty(trim($post['name']))) {
-            throw new \think\Exception('分类名称不能为空');
-        }
-
-        if($post['id'] == $post['cid']) {
-            throw new \think\Exception('上级不能是自己');
-        }
-        
-        if($post['sort'] < 0) {
-            throw new \think\Exception('排序值不能为负数');
-        }
-
-        // 获取后代分类
-        $lists = FileCate::where(['del'=>0 ])->select();
-        $lists = !empty($lists) ? $lists->toArray() : [];
-        $childs = self::getChildCid($lists, $post['id'], true);
-        if(in_array($post['cid'], $childs)) {
-            throw new \think\Exception('上级不能自己的后代分类');
-        }
-
-        //层次结构不能超过三层
-        $level = self::calcLevel($post['id']);
-        $parent = FileCate::find($post['cid']);
-        if($level + $parent['level'] > 3) {
-            throw new \think\Exception('分类不允许超过三级');
-        }
-    }
-
-    /**
-     * 计算当前分类下共有多少层分类
-     * @param $lists
-     * @param $pid
-     * @return int
-     */
-    public static function calcLevel($id)
-    {
-        $level = 1;
-        $two_ids = FileCate::where(['pid' => $id, 'del' => 0])->column('id');
-        if ($two_ids) {
-            $level = 2;
-            $three_ids = FileCate::where([
-                ['del', '=', 0],
-                ['pid', 'in', $two_ids]
-            ])->column('id');
-            if ($three_ids) $level = 3;
-        }
-        return $level;
-    }
-
-    /**
-     * 更新自己及后代分类的level
-     */
-    public static function updateLevel($id)
-    {
-        $me = FileCate::find($id);
-        if($me['pid'] == 0) { // 上级为顶级分类
-            FileCate::update([
-                'id' => $id,
-                'level' => 1,
-                'update_time' => time()
-            ]);
-            $two_ids = FileCate::where([
-                'pid' => $id,
-                'del' => 0
-            ])->column('id');
-            if($two_ids) {
-                FileCate::where('id', 'in', $two_ids)->update([
-                    'level' => 2,
-                    'update_time' => time()
-                ]);
-                $three_ids = FileCate::where([
-                    ['pid', 'in', $two_ids],
-                    ['del', '=', 0]
-                ])->column('id');
-                if($three_ids) {
-                    FileCate::where('id', 'in', $three_ids)->update([
-                        'level' => 3,
-                        'update_time' => time()
-                    ]);
-                }
-            }
-        }else{
-            $parent = FileCate::find($me['pid']);
-            if($parent['level'] == 1) {
-                FileCate::update([
-                    'id' => $id,
-                    'level' => 2,
-                    'update_time' => time()
-                ]);
-                $three_ids = FileCate::where([
-                    'pid' => $id,
-                    'del' => 0
-                ])->column('id');
-                if($three_ids) {
-                    FileCate::where('id', 'in', $three_ids)->update([
-                        'level' => 3,
-                        'update_time' => time()
-                    ]);
-                }
-            }else if($parent['level'] == 2){
-                FileCate::update([
-                    'id' => $id,
-                    'level' => 3,
-                    'update_time' => time()
-                ]);
-            }
-
-        }
-    }
-
-    /**
-     * 删除验证
-     */
-    public static function checkDel($id)
-    {
-        $file = File::where([
-            'cid' => $id,
-            'del' => 0
-        ])->findOrEmpty();
-        if(!$file->isEmpty()) {
-            throw new \think\Exception('有文件正在使用当前分类,不允许删除');
-        }
-        $son = FileCate::where([
-            'del' => 0,
-            'pid' => $id
-        ])->findOrEmpty();
-        if(!$son->isEmpty()){
-            throw new \think\Exception('分类下还有子分类,不允许删除');
-        }
-    }
-}

+ 0 - 100
app/shop/logic/LoginLogic.php

@@ -1,100 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-
-namespace app\shop\logic;
-
-
-use app\common\basics\Logic;
-use app\common\model\shop\ShopAdmin;
-use app\common\server\ConfigServer;
-use think\facade\Cookie;
-
-/**
- * 商家登录逻辑
- * Class LoginLogic
- * @package app\shop\logic
- */
-class LoginLogic extends Logic
-{
-
-    /**
-     * Notes: 登录
-     * @param $post
-     * @author 段誉(2021/4/10 10:40)
-     * @return bool
-     */
-    public static function login($post)
-    {
-        $adminModel = new ShopAdmin();
-        $admin_info = $adminModel->alias('a')
-            ->join('shop s', 's.id = a.shop_id')
-            ->field(['a.id', 'a.account', 'a.name', 'role_id', 'shop_id', 's.name' => 'shop_name'])
-            ->where(['a.account' => $post['account'], 'a.del' => 0])
-            ->findOrEmpty()->toArray();
-
-        //session
-        session('shop_info', $admin_info);
-
-        //登录信息更新
-        $adminModel->where(['account' => $post['account']])
-            ->update([
-                'login_ip' => request()->ip(),
-                'login_time' => time()
-            ]);
-
-        //记住账号
-        if (isset($post['remember_account']) && $post['remember_account'] == 'on') {
-            Cookie::set('account', $post['account']);
-        } else {
-            Cookie::delete('account');
-        }
-        return true;
-    }
-
-    /**
-     * Notes: 退出
-     * @author 段誉(2021/4/10 10:40)
-     */
-    public static function logout()
-    {
-        session('shop_info', null);
-    }
-
-
-
-    public static function config()
-    {
-        $config = [
-            'company_name' => ConfigServer::get('copyright', 'company_name'),
-            'number' => ConfigServer::get('copyright', 'number'),
-            'link' => ConfigServer::get('copyright', 'link'),
-
-            'login_logo' => ConfigServer::get('website_shop', 'shop_login_logo'),
-            'login_image' => ConfigServer::get('website_shop', 'shop_login_image'),
-            'login_title' => ConfigServer::get('website_shop', 'shop_login_title'),
-
-            'name' => ConfigServer::get('website', 'name'),
-            'web_favicon' => ConfigServer::get('website', 'web_favicon'),
-        ];
-        return $config;
-    }
-
-
-}

+ 0 - 242
app/shop/logic/RoleLogic.php

@@ -1,242 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-
-namespace app\shop\logic;
-
-
-use app\common\basics\Logic;
-use app\common\model\shop\ShopAuth;
-use app\common\model\shop\ShopRole;
-use app\common\model\shop\ShopRoleAuthIndex;
-use think\facade\Db;
-
-class RoleLogic extends Logic
-{
-
-    /**
-     * Notes: 角色列表
-     * @author 段誉(2021/4/13 10:35)
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     */
-    public static function lists($shop_id, $get)
-    {
-        $relationModel = new ShopRoleAuthIndex();
-        $result = $relationModel->alias('r')
-            ->join('dev_shop_auth m', 'r.menu_auth_id=m.id')
-            ->where(['m.del' => 0])
-            ->order(['sort' => 'desc'])
-            ->field(['m.name' => 'name', 'r.role_id' => 'role_id'])
-            ->select();
-        $role_id_menu_auth_names = [];
-
-        foreach ($result as $k => $v) {
-            if (isset($role_id_menu_auth_names[$v['role_id']])) {
-                $role_id_menu_auth_names[$v['role_id']] .= $v['name'] . ',';
-            } else {
-                $role_id_menu_auth_names[$v['role_id']] = $v['name'] . ',';
-            }
-        }
-
-        $lists = ShopRole::where(['del' => 0, 'shop_id' => $shop_id])
-            ->paginate([
-                'list_rows'=> $get['limit'],
-                'page'=> $get['page']
-            ]);
-
-        foreach ($lists as $k => $v) {
-            $lists[$k]['auth_str'] = isset($role_id_menu_auth_names[$v['id']]) ? $role_id_menu_auth_names[$v['id']] : '';
-            $lists[$k]['auth_str'] = rtrim($lists[$k]['auth_str'], ',');
-        }
-
-        return ['lists' => $lists->getCollection(), 'count' => $lists->total()];
-    }
-
-    /**
-     * Notes: 详情
-     * @param $role_id
-     * @author 段誉(2021/4/13 10:35)
-     * @return array|\think\Model|null
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     */
-    public static function roleInfo($role_id)
-    {
-        return ShopRole::where(['id' => $role_id])->field(['id', 'name', 'desc'])->find();
-    }
-
-
-    /**
-     * Notes: 添加
-     * @param $post
-     * @author 段誉(2021/4/13 10:35)
-     * @return bool
-     */
-    public static function addRole($shop_id, $post)
-    {
-        $data = [
-            'name' => $post['name'],
-            'desc' => $post['desc'],
-            'shop_id' => $shop_id,
-            'create_time' => time(),
-        ];
-
-        try {
-            Db::startTrans();
-
-            $roleModel = new ShopRole();
-            $roleAuthIndexModel = new ShopRoleAuthIndex();
-
-            $role_id = $roleModel->insertGetId($data);
-
-            $data = [];
-            $post['auth_ids'] = empty($post['auth_ids'])?[]:$post['auth_ids'];
-            foreach ($post['auth_ids'] as $k => $v) {
-                $data[] = [
-                    'role_id' => $role_id,
-                    'menu_auth_id' => $v,
-                ];
-            }
-            $roleAuthIndexModel->insertAll($data);
-            Db::commit();
-            return true;
-        } catch (\Exception $e) {
-            Db::rollback();
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-
-    /**
-     * Notes: 编辑
-     * @param $post
-     * @author 段誉(2021/4/13 10:36)
-     * @return bool
-     */
-    public static function editRole($shop_id, $post)
-    {
-        $data = [
-            'name' => $post['name'],
-            'desc' => $post['desc'],
-            'update_time' => time(),
-        ];
-        try {
-            Db::startTrans();
-
-            $roleModel = new ShopRole();
-            $roleAuthIndexModel = new ShopRoleAuthIndex();
-
-            $roleModel->where(['del' => 0, 'id' => $post['id'], 'shop_id' => $shop_id])->update($data);
-            $roleAuthIndexModel->where(['role_id' => $post['id']])->delete();
-
-            $data = [];
-            $post['auth_ids'] = empty($post['auth_ids'])?[]:$post['auth_ids'];
-            foreach ($post['auth_ids'] as $k => $v) {
-                $data[] = [
-                    'role_id' => $post['id'],
-                    'menu_auth_id' => $v,
-                ];
-            }
-            $roleAuthIndexModel->insertAll($data);
-
-            Db::commit();
-            return true;
-        } catch (\Exception $e) {
-            Db::rollback();
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-
-    /**
-     * Notes: 删除
-     * @param $role_id
-     * @author 段誉(2021/4/13 10:36)
-     * @return ShopRole
-     */
-    public static function delRole($shop_id, $role_id)
-    {
-        return ShopRole::where([
-            'del' => 0,
-            'id' => $role_id,
-            'shop_id' => $shop_id
-        ])->update(['del' => 1, 'update_time' => time()]);
-    }
-
-
-    /**
-     * Notes: 获取菜单权限树
-     * @param string $role_id
-     * @author 段誉(2021/4/13 10:36)
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     */
-    public static function authTree($role_id = '')
-    {
-        $lists = ShopAuth::where(['disable' => 0, 'del' => 0])->select();
-        $pids = ShopAuth::where(['disable' => 0, 'type' => 1, 'del' => 0])->column('pid');
-
-        foreach ($lists as $k => $v) {
-            $lists[$k]['spread'] = in_array($v['id'], $pids) ? true : false;
-        }
-
-        $menu_auth_ids = [];
-        if ($role_id) {
-            $menu_auth_ids = ShopRoleAuthIndex::where(['role_id' => $role_id])
-                ->column('menu_auth_id');
-        }
-
-        return self::authListToTree($lists, 0, $menu_auth_ids);
-    }
-
-
-    /**
-     * Notes: 列表结构转换成树形结构
-     * @param $lists
-     * @param int $pid
-     * @param array $menu_auth_ids
-     * @author 段誉(2021/4/13 10:36)
-     * @return array
-     */
-    public static function authListToTree($lists, $pid = 0, $menu_auth_ids = [])
-    {
-        $tree = [];
-        foreach ($lists as $k => $v) {
-            if ($v['pid'] == $pid) {
-                $temp['id'] = $v['id'];
-                $temp['field'] = 'auth_ids[' . $v['id'] . ']';
-                $temp['title'] = $v['name'];
-                $temp['children'] = self::authListToTree($lists, $v['id'], $menu_auth_ids);
-                $temp['checked'] = in_array($v['id'], $menu_auth_ids) && empty($temp['children']) ? true : false;
-                $temp['spread'] = $v['spread'];
-                $tree[] = $temp;
-            }
-        }
-        return $tree;
-    }
-
-}

+ 0 - 208
app/shop/logic/SeckillLogic.php

@@ -1,208 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-namespace app\shop\logic;
-use app\common\server\UrlServer;
-use think\Db;
-
-class SeckillLogic{
-
-    public static function goodsList($get){
-        $where = [];
-        $where[] = ['sg.del','=',0];
-        $where[] = ['g.del','=',0];
-        if(isset($get['name']) && $get['name']) {
-            $where[] = ['name','like','%'.$get['name'].'%'];
-        }
-
-        if(isset($get['seckill_id']) && $get['seckill_id']){
-            $where[] = ['seckill_id','=',$get['seckill_id']];
-        }
-
-        $count = Db::name('seckill_goods sg')
-            ->join('goods g','sg.goods_id = g.id')
-            ->where($where)
-            ->group('goods_id,seckill_id')
-            ->count();
-
-
-        $list = Db::name('seckill_goods sg')
-            ->join('goods g','sg.goods_id = g.id')
-            ->where($where)
-            ->group('goods_id,seckill_id')
-            ->field('sg.id,seckill_id,goods_id,g.name,g.image,g.max_price,g.min_price,sg.sales_sum')
-            ->page($get['page'], $get['limit'])
-            ->order('sg.id desc')
-            ->select();
-        $goods_ids = array_column($list,'goods_id');
-        $seckill_goods_list = Db::name('seckill_goods')->where(['goods_id'=>$goods_ids])->column('*','id');
-
-        $seckill = Db::name('seckill_time')->where(['del'=>0])->column('*','id');
-        foreach ($list as &$item){
-            $price_array = [];
-            $item['image'] = UrlServer::getFileUrl($item['image']);
-            $item['goods_price'] = '¥'.$item['min_price'];
-            if($item['max_price'] != $item['min_price']){
-                $item['goods_price'] = '¥'.$item['min_price'].' ~ '.'¥'.$item['max_price'];
-            }
-            if(isset($seckill[$item['seckill_id']])){
-                $item['start_time'] = $seckill[$item['seckill_id']]['start_time'];
-                $item['end_time'] = $seckill[$item['seckill_id']]['end_time'];
-            }
-            //该秒杀商品的全部规格
-            $seckill_goods_item = Db::name('seckill_goods')
-                            ->where(['seckill_id'=>$item['seckill_id'],'goods_id'=>$item['goods_id']])
-                            ->column('*','id');
-            foreach ($seckill_goods_item as $seckill_id => $seckill_item){
-
-                if(isset($seckill_goods_list[$seckill_id])){
-                    $price_array[] = $seckill_goods_list[$seckill_id]['price'];
-                }
-            }
-
-            $max_price = max($price_array);
-            $min_price = min($price_array);
-
-            $item['seckill_price'] = '¥'.$max_price;
-            if($max_price != $min_price){
-                $item['seckill_price'] =  '¥'.$min_price.' ~ '.'¥'.$max_price;
-            }
-        }
-
-        return ['count' => $count, 'list' => $list];
-    }
-
-    public static function timeList($get){
-        $where = [];
-        $where[] = ['del','=',0];
-        $count = Db::name('seckill_time')->where($where)->count();
-        $list = Db::name('seckill_time')
-            ->where($where)
-            ->order('start_time asc')
-            ->page($get['page'], $get['limit'])
-            ->select();
-        foreach ($list as &$item){
-            $item['time'] = $item['start_time'].' ~ '.$item['end_time'];
-        }
-        return ['count' => $count, 'list' => $list];
-
-    }
-
-
-
-    public static function addTime($post){
-        $post['create_time'] = time();
-        $post['update_time'] = time();
-        return Db::name('seckill_time')->insert($post);
-    }
-
-
-
-    public static function editTime($post){
-        $post['update_time'] = time();
-        return Db::name('seckill_time')->where(['id'=>$post['id']])->update($post);
-    }
-
-    public static function addGoods($post){
-        $now = time();
-        $add_data = [];
-
-        foreach ($post['item'] as  $item){
-            $add_data[] =[
-                'seckill_id'        => $post['seckill_id'],
-                'goods_id'          => $item['goods_id'],
-                'item_id'           => $item['item_id'],
-                'price'             => $item['price'],
-                'create_time'       => $now,
-                'sales_sum'         => 0,
-                'update_time'       => $now,
-                'del'               => 0,
-            ];
-        }
-        return Db::name('seckill_goods')->insertAll($add_data);
-    }
-
-    public static function editGoods($post){
-        $now = time();
-
-        foreach ($post['item'] as  $goods){
-
-            $update_data = [
-                'seckill_id'    => $post['seckill_id'],
-                'price'         => $goods['price'],
-                'update_time'   => $now,
-            ];
-            Db::name('seckill_goods')->where(['id'=>$goods['id']])->update($update_data);
-        }
-
-        return true;
-    }
-
-    public static function delGoods($id,$seckill_id){
-        $update_data = [
-            'update_time'   => time(),
-            'del'           => 1,
-        ];
-        return Db::name('seckill_goods')->where(['del'=>0,'goods_id'=>$id,'seckill_id'=>$seckill_id])->update($update_data);
-    }
-
-
-    public static function delTime($id){
-        $update_data = [
-            'update_time'   => time(),
-            'del'           => 1,
-        ];
-        Db::name('seckill_time')->where(['id'=>$id])->update($update_data);
-        Db::name('seckill_goods')->where(['del'=>0,'seckill_id'=>$id])->update($update_data);
-        return true;
-    }
-
-    public static function getTime($id){
-        return Db::name('seckill_time')->where(['del'=>0,'id'=>$id])->find();
-    }
-
-    public static function getTimeAll(){
-
-        $time_list =  Db::name('seckill_time')->where(['del'=>0])->order('start_time asc')->select();
-        foreach ($time_list as &$item){
-            $item['time'] = $item['start_time'].' ~ '.$item['end_time'];
-        }
-        return $time_list;
-    }
-
-    public static function getSeckillGoods($id,$seckill_id){
-        $skill_goods = Db::name('seckill_goods sg')
-            ->join('goods_item gi','sg.item_id = gi.id')
-            ->where(['del'=>0,'sg.goods_id'=>$id,'sg.seckill_id'=>$seckill_id ])
-            ->field('sg.*,gi.image,gi.spec_value_str,gi.price as goods_price')
-            ->select();
-
-        $goods_id = $skill_goods[0]['goods_id'];
-        $goods = Db::name('goods')->where(['del'=>0,'id'=>$goods_id])->field('image,name')->find();
-
-        foreach ($skill_goods as &$item){
-            $item['name'] = $goods['name'];
-            if(!$item['image']){
-                $item['image'] = $goods['image'];
-            }
-        }
-
-        return $skill_goods;
-    }
-
-}

+ 0 - 194
app/shop/logic/StatisticsLogic.php

@@ -1,194 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-
-namespace app\shop\logic;
-
-use app\common\basics\Logic;
-use app\common\server\UrlServer;
-use app\common\enum\PayEnum;
-use think\facade\Db;
-
-class StatisticsLogic extends Logic
-{
-
-    /**
-     * Notes: 访问分析
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     */
-    public static function visit($post,$shop_id)
-    {
-        //获取今天的时间戳 
-        $today = strtotime('today');
-        //近七天的开始日期
-        $start_time = $today - 86400 * 7;
-        //近七天的结束日期
-        $end_time = $today - 1;
-
-        if (isset($post['start_time']) && $post['start_time'] && isset($post['end_time']) && $post['end_time']) {
-            $start_time = strtotime($post['start_time']);
-            $end_time   = strtotime($post['end_time']);
-        }
-        $user_count = Db::name('shop_stat')
-            ->where([['create_time', 'between', [$start_time, $end_time]],['shop_id', '=', $shop_id]])
-            ->count('id');
-        //当前时间戳
-        $start_t = time();
-        //echarts图表数据
-        $echarts_count = [];
-        $echarts_add = [];
-        $dates = [];
-        for ($i = 15; $i >= 1; $i--) {
-            $where_start = strtotime("- " . $i . "day", $start_t);
-            $dates[] = date('m-d', $where_start);
-            $start_now = strtotime(date('Y-m-d', $where_start));
-            $end_now = strtotime(date('Y-m-d 23:59:59', $where_start));
-
-            $add = Db::name('shop_stat')
-                ->where([['create_time', 'between', [$start_now, $end_now]],['shop_id', '=', $shop_id]])
-                ->count('id');
-            $echarts_count[] = 0;
-            $echarts_add[] = $add;
-        }
-
-        return [
-            'user_count'      => $user_count,
-            'start_time'      => date('Y-m-d H:i:s', $start_time),
-            'end_time'        => date('Y-m-d H:i:s', $end_time),
-            'echarts_count'   => $echarts_count,
-            'echarts_add'     => $echarts_add,
-            'days'            => $dates,
-        ];
-    }
-
-    /**
-     * Notes: 交易分析
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     */
-    public static function trading($post,$shop_id)
-    {
-
-        //获取今天的时间戳 
-        $today = strtotime('today');
-        //近七天的开始日期
-        $start_time = $today - 86400 * 7;
-        //近七天的结束日期
-        $end_time = $today - 1;
-
-        if (isset($post['start_time']) && $post['start_time'] && isset($post['end_time']) && $post['end_time']) {
-            $start_time = strtotime($post['start_time']);
-            $end_time   = strtotime($post['end_time']);
-        }
-        $order_num = Db::name('order')
-            ->where([['create_time', 'between', [$start_time, $end_time]], ['pay_status', '>', PayEnum::UNPAID],['shop_id', '=', $shop_id]])
-            ->count('id');
-        $order_amount = Db::name('order')
-            ->where([['create_time', 'between', [$start_time, $end_time]], ['pay_status', '>', PayEnum::UNPAID],['shop_id', '=', $shop_id]])
-            ->sum('order_amount') ?? 0;
-
-        //当前时间戳
-        $start_t = time();
-        //echarts图表数据
-        $echarts_count = [];
-        $echarts_order_num_add = [];
-        $echarts_order_amount_add = [];
-        $dates = [];
-        for ($i = 15; $i >= 1; $i--) {
-            $where_start = strtotime("- " . $i . "day", $start_t);
-            $dates[] = date('m-d', $where_start);
-            $start_now = strtotime(date('Y-m-d', $where_start));
-            $end_now = strtotime(date('Y-m-d 23:59:59', $where_start));
-
-            $order_num_add = Db::name('order')
-                ->where([['create_time', 'between', [$start_now, $end_now]], ['pay_status', '>', PayEnum::UNPAID],['shop_id', '=', $shop_id]])
-                ->count('id');
-            $order_amount_add = Db::name('order')
-                ->where([['create_time', 'between', [$start_now, $end_now]], ['pay_status', '>', PayEnum::UNPAID],['shop_id', '=', $shop_id]])
-                ->sum('order_amount') ?? 0;
-
-            $echarts_count[] = 0;
-            $echarts_order_num_add[] = $order_num_add;
-            $echarts_order_amount_add[] = sprintf("%.2f",substr(sprintf("%.3f", $order_amount_add), 0, -2));
-        }
-
-        return [
-            'order_num'                    => $order_num,
-            'order_amount'                 => '¥'.number_format($order_amount,2),
-            'start_time'                   => date('Y-m-d H:i:s', $start_time),
-            'end_time'                     => date('Y-m-d H:i:s', $end_time),
-            'echarts_count'                => $echarts_count,
-            'echarts_order_num_add'        => $echarts_order_num_add,
-            'echarts_order_amount_add'     => $echarts_order_amount_add,
-            'days'                         => $dates,
-        ];
-    }
-
-
-    /**
-     * Notes: 商品分析
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     */
-    public static function goods($get,$shop_id)
-    {
-        if (!isset($get['search_key'])) {
-            $get['search_key'] = 'sales_volume';
-        }
-
-        // 商品列表      
-        $goods_count = Db::name('order')->alias('o')
-            ->join('order_goods og', 'og.order_id = o.id')
-            ->join('shop s', 's.id = o.shop_id')
-            ->where([['o.pay_status', '=', 1],['o.shop_id', '=', $shop_id]])
-            ->group('og.goods_id')
-            ->count();
-
-        $goods_list = Db::name('order')->alias('o')
-            ->join('order_goods og', 'og.order_id = o.id')
-            ->join('shop s', 's.id = o.shop_id')
-            ->where([['o.pay_status', '=', 1],['o.shop_id', '=', $shop_id]])
-            ->group('og.goods_id')
-            ->page($get['page'], $get['limit'])
-            ->order($get['search_key'].' desc')
-            ->column('s.id,s.logo,s.type,s.name,o.shop_id,count(o.id) as sales_volume,sum(o.order_amount) as sales_price,og.image,og.goods_name');
-
-        foreach ($goods_list as $k => $item) {
-            $goods_list[$k]['number'] = $k + 1;
-            $goods_list[$k]['sales_price'] = '¥' . number_format($item['sales_price'], 2);
-            $goods_list[$k]['goods_image'] = UrlServer::getFileUrl($item['image']);
-            $goods_list[$k]['logo'] = UrlServer::getFileUrl($item['logo']);
-
-            if ($item['type'] == 1) {
-                $goods_list[$k]['type_desc'] = '官方自营';
-            } else {
-                $goods_list[$k]['type_desc'] = '入驻商家';
-            }
-        }
-
-        return ['count' => $goods_count, 'lists' => $goods_list];
-    }
-}

+ 0 - 121
app/shop/logic/StoreLogic.php

@@ -1,121 +0,0 @@
-<?php
-
-
-namespace app\shop\logic;
-
-
-use app\common\basics\Logic;
-use app\common\enum\ShopEnum;
-use app\common\model\shop\Shop;
-use app\common\server\UrlServer;
-
-class StoreLogic extends Logic
-{
-    /**
-     * @Notes: 获取商家详细
-     * @Author: 张无忌
-     * @param $shop_id
-     * @return array
-     */
-    public static function detail($shop_id)
-    {
-        $model = new Shop();
-        $detail = $model->field(true)
-            ->with(['category'])
-            ->json(['other_qualifications'],true)
-            ->findOrEmpty($shop_id)->toArray();
-
-        $detail['category'] = $detail['category']['name'] ?? '未知';
-        $detail['type'] = ShopEnum::getShopTypeDesc($detail['type']);
-        $detail['run_start_time'] = $detail['run_start_time'] ? date('H:i:s', $detail['run_start_time']) : '';
-        $detail['run_end_time'] = $detail['run_end_time'] ? date('H:i:s', $detail['run_end_time']) : '';
-        $detail['business_license'] = $detail['business_license'] ? UrlServer::getFileUrl($detail['business_license']) : '';
-        if (!empty($detail['other_qualifications'])) {
-            foreach ($detail['other_qualifications'] as &$val) {
-                $val = UrlServer::getFileUrl($val);
-            }
-        }
-        return $detail;
-    }
-
-    /**
-     * @Notes: 修改商家信息
-     * @Author: 张无忌
-     * @param $post
-     * @return bool
-     */
-    public static function edit($post)
-    {
-        try {
-            $num = count($post['other_qualifications'] ?? []);
-            if ($num > 5) {
-                throw new \Exception('其他资质图片不能超过五张', 10006);
-            }
-
-            // 校验配送方式
-            self::checkDeliveryType($post);
-
-            Shop::update([
-                'nickname'       => $post['nickname'],
-                'mobile'         => $post['mobile'],
-                'keywords'       => $post['keywords'] ?? '',
-                'intro'          => $post['intro'] ?? '',
-                'is_run'         => $post['is_run'],
-//                'service_mobile' => $post['service_mobile'],
-                'weekdays'       => $post['weekdays'] ?? '',
-                'province_id'    => $post['province_id'] ?? 0,
-                'city_id'        => $post['city_id'] ?? 0,
-                'district_id'    => $post['district_id'] ?? 0,
-                'address'        => $post['address'] ?? '',
-                'longitude'      => $post['longitude'] ?? '',
-                'latitude'       => $post['latitude'] ?? '',
-                'run_start_time' => empty($post['run_start_time']) ? '' : strtotime($post['run_start_time']),
-                'run_end_time'   => empty($post['run_end_time']) ? '' : strtotime($post['run_end_time']),
-                'refund_address' => json_encode([
-                    'nickname'    => $post['refund_nickname'],
-                    'mobile'      => $post['refund_mobile'],
-                    'province_id' => $post['refund_province_id'],
-                    'city_id'     => $post['refund_city_id'],
-                    'district_id' => $post['refund_district_id'],
-                    'address'     => $post['refund_address'],
-                ], JSON_UNESCAPED_UNICODE),
-                'business_license'   => empty($post['business_license']) ? '' : UrlServer::setFileUrl($post['business_license']),
-                'other_qualifications' => isset($post['other_qualifications']) ? json_encode($post['other_qualifications'], JSON_UNESCAPED_UNICODE) : '',
-                'open_invoice'  => $post['open_invoice'] ?? 0,
-                'spec_invoice'  => $post['spec_invoice'] ?? 0,
-                'delivery_type' => $post['delivery_type']
-            ], ['id'=>$post['id']]);
-
-            return true;
-        } catch (\Exception $e) {
-            static::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-
-    /**
-     * @notes 校验配送方式
-     * @param $post
-     * @return bool
-     * @throws \Exception
-     * @author 段誉
-     * @date 2022/11/1 11:30
-     */
-    public static function checkDeliveryType($post)
-    {
-        // 校验配送方式
-        if (empty($post['delivery_type'])) {
-            throw new \Exception('至少选择一种配送方式');
-        }
-
-        // 线下自提时,商家地址必填
-        if (in_array(ShopEnum::DELIVERY_SELF, $post['delivery_type'])) {
-            if (empty($post['province_id']) || empty($post['city_id']) || empty($post['district_id']) || empty($post['address'])) {
-                throw new \Exception('线下自提需完善商家地址');
-            }
-        }
-        return true;
-    }
-
-}

+ 0 - 105
app/shop/logic/activity_area/AreaLogic.php

@@ -1,105 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-namespace app\shop\logic\activity_area;
-use app\common\basics\Logic;
-use app\common\server\JsonServer;
-use think\facade\Db;
-use app\common\model\activity_area\ActivityArea;
-use app\common\model\activity_area\ActivityAreaGoods;
-use app\common\server\UrlServer;
-
-
-class  AreaLogic extends Logic {
-
-    /**
-     * Notes:活动专区列表
-     * @param $get
-     * @return array
-     * @author: cjhao 2021/4/15 16:25
-     */
-    public static function lists($get){
-        $where[] = ['del','=',0];
-        $lists = ActivityArea::where($where)
-            ->page($get['page'],$get['limit'])
-            ->select();
-
-        $count = ActivityArea::where($where)
-            ->page($get['page'],$get['limit'])
-            ->count();
-
-        return ['count'=>$count,'lists'=>$lists];
-    }
-
-    /**
-     * Notes:添加活动专区
-     * @param $post
-     * @return int|string
-     * @author: cjhao 2021/4/15 17:25
-     */
-    public static function add($post){
-        $post['create_time'] = time();
-        if($post['status'] == 'on'){
-            $post['status'] = 1; //专区显示
-        }else{
-            $post['status'] = 0; //专区隐藏
-        }
-        $post['image'] = UrlServer::setFileUrl($post['image']);
-        return ActivityArea::insert($post);
-    }
-
-    /**
-     * Notes:获取活动专区
-     * @param $id
-     * @return array|\think\Model|null
-     * @author: cjhao 2021/4/15 17:29
-     */
-    public static function getActivityArea($id){
-        return ActivityArea::where(['id'=>$id,'del'=>0])->find();
-    }
-
-    /***
-     * 获取所有活动专区
-     * @return \think\Collection
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     */
-    public static function getActivityAreaAll(){
-        return ActivityArea::where(['del'=>0])
-            ->select();
-    }
-
-    /***
-     * @param $post
-     * @return ActivityArea
-     */
-    public static function edit($post){
-        $post['image'] = UrlServer::setFileUrl($post['image']);
-        return ActivityArea::update($post);
-    }
-
-    /***
-     * @param $id
-     * @return ActivityArea
-     */
-    public static function del($id){
-
-        return ActivityArea::update(['del'=>1,'id'=>$id]);
-    }
-}

+ 0 - 231
app/shop/logic/activity_area/GoodsLogic.php

@@ -1,231 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-namespace app\shop\logic\activity_area;
-
-use app\common\model\activity_area\ActivityAreaGoods;
-use app\common\basics\Logic;
-use think\facade\Db;
-
-/**
- * Class GoodsLogic
- * @package app\shop\logic\activity_area
- */
-class GoodsLogic extends Logic
-{
-
-    /**
-     * @notes 活动专区商品列表
-     * @param $get
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author suny
-     * @date 2021/7/14 10:17 上午
-     */
-    public static function lists($get)
-    {
-
-        $where[] = ['AG.del', '=', 0];
-        $where[] = ['AG.shop_id', '=', $get['shop_id']];
-
-        switch ($get['type']) {
-            case 1:
-                $audit_status = ActivityAreaGoods::AUDIT_STATUS_PASS;
-                break;
-            case 0:
-                $audit_status = ActivityAreaGoods::AUDIT_STATUS_WAIT;
-                break;
-            case 2:
-                $audit_status = ActivityAreaGoods::AUDIT_STATUS_REFUSE;
-                break;
-        }
-        $where[] = ['AG.audit_status', '=', $audit_status];
-
-        if (isset($get['goods_name']) && $get['goods_name']) {
-            $where[] = ['G.name', 'like', '%' . $get['goods_name'] . '%'];
-        }
-        if (isset($get['activity_area']) && $get['activity_area']) {
-            $where[] = ['AA.id', '=', $get['activity_area']];
-        }
-        $count = ActivityAreaGoods::alias('AG')
-            ->join('activity_area AA', 'AG.activity_area_id = AA.id')
-            ->join('goods G', 'AG.Goods_id = G.id')
-            ->where($where)
-            ->count();
-
-        $lists = ActivityAreaGoods::alias('AG')
-            ->join('activity_area AA', 'AG.activity_area_id = AA.id')
-            ->join('goods G', 'AG.Goods_id = G.id')
-            ->where($where)
-            ->field('AG.id,AG.goods_id,AG.activity_area_id,AG.audit_status,AA.name as activity_area_name,G.name,G.image,G.min_price,G.max_price')
-            ->order('AG.id desc')
-            ->select();
-
-        return ['count' => $count, 'lists' => $lists];
-    }
-
-    /**
-     * @notes 获取活动专区商品
-     * @param $id
-     * @return \think\Collection
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author suny
-     * @date 2021/7/14 10:18 上午
-     */
-    public static function getActivityAreaGoods($id)
-    {
-
-        return ActivityAreaGoods::where(['del' => 0, 'id' => $id])
-            ->select();
-    }
-
-    /**
-     * @notes 添加活动商品
-     * @param $post
-     * @return int|string
-     * @author suny
-     * @date 2021/7/14 10:18 上午
-     */
-    public static function add($post)
-    {
-
-        $new = time();
-        $add_data = [];
-        $add_data[] = [
-            'activity_area_id' => $post['activity_id'],
-            'goods_id' => $post['goods_id'][0],
-            'item_id' => $post['item_id'][0],
-            'shop_id' => $post['shop_id'],
-            'audit_status' => 0, //待审核
-            'status' => 1, //显示
-            'del' => 0,
-            'create_time' => $new,
-        ];
-
-        return ActivityAreaGoods::insertAll($add_data);
-    }
-
-    /**
-     * @notes 删除活动商品
-     * @param $id
-     * @return ActivityAreaGoods
-     * @author suny
-     * @date 2021/7/14 10:18 上午
-     */
-    public static function del($id)
-    {
-
-        $update_data = [
-            'update_time' => time(),
-            'del' => 1,
-        ];
-        return ActivityAreaGoods::where(['id' => $id])->update($update_data);
-    }
-
-    /**
-     * @notes 编辑活动商品
-     * @param $post
-     * @return ActivityAreaGoods
-     * @author suny
-     * @date 2021/7/14 10:18 上午
-     */
-    public static function edit($post)
-    {
-
-        $new = time();
-        $update_data = [
-            'activity_id' => $post['activity_id'],
-            'update_time' => $new,
-        ];
-
-        return ActivityAreaGoods::where(['id' => $post['id'], 'activity_id' => $post['activity_id']])
-            ->update($update_data);
-
-    }
-
-    /**
-     * @notes 获取全部的活动专区
-     * @return array
-     * @author suny
-     * @date 2021/7/14 10:18 上午
-     */
-    public static function getActivityList()
-    {
-
-        return Db::name('activity_area')
-            ->where(['del' => 0])
-            ->column('name', 'id');
-
-    }
-
-    /**
-     * @notes 获取活动商品详情
-     * @param $goods_id
-     * @param $activity_id
-     * @return array|\PDOStatement|string|\think\Collection|\think\model\Collection
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
-     * @author suny
-     * @date 2021/7/14 10:18 上午
-     */
-    public static function getActivityGoods($goods_id, $activity_id)
-    {
-
-        $activity_list = Db::name('activity_area_goods')->alias('AG')
-            ->join('goods_item GI', 'AG.item_id = GI.id')
-            ->where(['activity_area_id' => $activity_id, 'AG.goods_id' => $goods_id])
-            ->field('AG.*,GI.price,GI.spec_value_str,GI.image,GI.price')
-            ->select();
-        $goods_id = $activity_list[0]['goods_id'];
-        $goods = Db::name('goods')->where(['del' => 0, 'id' => $goods_id])->field('image,name')->find();
-
-        foreach ($activity_list as &$item) {
-            $item['name'] = $goods['name'];
-            if (empty($item['image'])) {
-                $item['image'] = $goods['image'];
-            }
-        }
-        return $activity_list;
-    }
-
-    /**
-     * @notes 获取各列表数量
-     * @param $shop_id
-     * @return array
-     * @author suny
-     * @date 2021/7/14 10:18 上午
-     */
-    public static function getNum($shop_id)
-    {
-
-        $unaudit = ActivityAreaGoods::where(['audit_status' => 0, 'del' => 0, 'shop_id' => $shop_id])->count('id');
-        $audit_pass = ActivityAreaGoods::where(['audit_status' => 1, 'del' => 0, 'shop_id' => $shop_id])->count('id');
-        $audit_refund = ActivityAreaGoods::where(['audit_status' => 2, 'del' => 0, 'shop_id' => $shop_id])->count('id');
-        $num = [
-            'unaudit' => $unaudit,
-            'audit_pass' => $audit_pass,
-            'audit_refund' => $audit_refund
-        ];
-        return $num;
-    }
-}

+ 0 - 600
app/shop/logic/after_sale/AfterSaleLogic.php

@@ -1,600 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-
-namespace app\shop\logic\after_sale;
-
-
-use app\common\basics\Logic;
-use app\common\enum\AfterSaleEnum;
-use app\common\enum\NoticeEnum;
-use app\common\enum\OrderGoodsEnum;
-use app\common\enum\OrderRefundEnum;
-use app\common\enum\PayEnum;
-use app\common\model\after_sale\{AfterSale, AfterSaleLog};
-use app\common\logic\AfterSaleLogLogic;
-use app\common\logic\OrderRefundLogic;
-use app\common\model\order\Order as OrderModel;
-use app\common\model\order\Order;
-use app\common\model\order\OrderGoods;
-use app\common\model\shop\Shop;
-use app\common\server\AreaServer;
-use app\common\server\ExportExcelServer;
-use app\common\server\UrlServer;
-use think\facade\Db;
-
-
-/**
- * 售后管理-逻辑
- * Class GoodsLogic
- * @package app\shop\logic\goods
- */
-class AfterSaleLogic extends Logic
-{
-
-    /**
-     * @notes 售后列表
-     * @param array $get
-     * @param $shop_id
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
-     * @author suny
-     * @date 2021/7/14 10:19 上午
-     */
-    public static function list($get = [], $shop_id = 0, $is_export = false)
-    {
-
-        $after_sale = new AfterSale();
-        $where = [];
-        $page = '1';
-        $limit = '10';
-        $where[] = ['o.delete', '=', 0];
-        $where[] = ['a.del', '=', 0];
-        $where[] = ['o.shop_id', '=', $shop_id];
-        //订单类型
-        if (isset($get['type']) && $get['type'] != '') {
-            $where[] = ['a.status', '=', $get['type']];
-        }
-
-        //订单搜素
-        if (!empty($get['search_key']) && !empty($get['keyword'])) {
-            $keyword = $get['keyword'];
-            switch ($get['search_key']) {
-                case 'sn':
-                    $where[] = ['a.sn', 'like', '%' . $keyword . '%'];
-                    break;
-                case 'order_sn':
-                    $where[] = ['o.order_sn', 'like', '%' . $keyword . '%'];
-                    break;
-                case 'goods_name':
-                    $where[] = ['g.goods_name', 'like', '%' . $keyword . '%'];
-                    break;
-                case 'user_sn':
-                    $where[] = ['u.sn', 'like', '%' . $keyword . '%'];
-                    break;
-                case 'nickname':
-                    $where[] = ['u.nickname', 'like', '%' . $keyword . '%'];
-                    break;
-                case 'user_mobile':
-                    $where[] = ['u.mobile', 'like', '%' . $keyword . '%'];
-                    break;
-            }
-        }
-
-        if (isset($get['status']) && $get['status'] != '') {
-            $where[] = ['a.status', '=', $get['status']];
-        }
-
-        //下单时间
-        if (isset($get['start_time']) && $get['start_time'] != '') {
-            $where[] = ['a.create_time', '>=', strtotime($get['start_time'])];
-        }
-        if (isset($get['end_time']) && $get['end_time'] != '') {
-            $where[] = ['a.create_time', '<=', strtotime($get['end_time'])];
-        }
-
-        if (isset($get['page']) && $get['page'] != '') {
-            $page = $get['page'];
-        }
-
-        if (isset($get['limit']) && $get['limit'] != '') {
-            $limit = $get['limit'];
-        }
-
-        // 导出excel
-        if (true === $is_export) {
-            return self::export($where);
-        }
-
-        $field = 'a.id,a.sn,a.status,a.order_id,a.order_goods_id,
-        a.user_id,a.refund_type,a.create_time,a.refund_price,
-        o.order_status,o.shop_id,o.pay_way';
-
-        $count = $after_sale
-            ->alias('a')
-            ->join('order o', 'o.id = a.order_id')
-            ->join('user u', 'u.id = a.user_id')
-            ->join('order_goods g', 'g.id = a.order_goods_id')
-            ->with(['order_goods', 'user', 'order'])
-            ->where($where)
-            ->group('a.id')
-            ->count();
-
-        $lists = $after_sale
-            ->alias('a')
-            ->field($field)
-            ->join('order o', 'o.id = a.order_id')
-            ->join('user u', 'u.id = a.user_id')
-            ->join('order_goods g', 'g.id = a.order_goods_id')
-            ->with(['order_goods', 'user', 'order'])
-            ->where($where)
-            ->page($page, $limit)
-            ->order('a.id desc')
-            ->append(['user.base_avatar', 'order_goods.base_image'])
-            ->group('a.id')
-            ->select()->toArray();
-        foreach ($lists as &$list) {
-            $list['order']['pay_way'] = PayEnum::getPayWay($list['order']['pay_way']);
-            $list['order']['order_status'] = OrderModel::getOrderStatus($list['order']['order_status']);
-            $list['refund_type'] = AfterSale::getRefundTypeDesc($list['refund_type']);
-            $list['status'] = AfterSale::getStatusDesc($list['status']);
-            $list['user']['avatar'] = UrlServer::getFileUrl($list['user']['avatar']);
-            foreach ($list['order_goods'] as &$good) {
-                $good['image'] = empty($good['spec_image']) ?
-                    UrlServer::getFileUrl($good['image']) : UrlServer::getFileUrl($good['spec_image']);
-            }
-        }
-        return ['count' => $count, 'lists' => $lists];
-    }
-
-    /**
-     * @notes 售后详情
-     * @param $id
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author suny
-     * @date 2021/7/14 10:19 上午
-     */
-    public static function getDetail($id,$shop_id)
-    {
-
-        $after_sale = new AfterSale();
-        $result = $after_sale
-            ->with(['order_goods', 'user', 'order', 'logs'])
-            ->where('id', $id)
-            ->find()->toArray();
-        $result['refund_type_text'] = AfterSale::getRefundTypeDesc($result['refund_type']);
-        $result['status_text'] = AfterSale::getStatusDesc($result['status']);
-        $result['order']['pay_way'] = PayEnum::getPayWay($result['order']['pay_way']);
-        $result['order']['order_status'] = OrderModel::getOrderStatus($result['order']['order_status']);
-
-        foreach ($result['order_goods'] as &$good) {
-            $good['image'] = empty($good['spec_image']) ?
-                UrlServer::getFileUrl($good['image']) : UrlServer::getFileUrl($good['spec_image']);
-        }
-
-        foreach ($result['logs'] as &$log) {
-
-            $log['log_img'] = '';
-            $log['log_remark'] = '';
-            switch ($log['channel']) {
-                //会员申请售后
-                case AfterSaleLog::USER_APPLY_REFUND:
-                    $log['log_img'] = empty($result['refund_image']) ? '' : UrlServer::getFileUrl($result['refund_image']);
-                    $refund_reason = empty($result['refund_reason']) ? '未知' : $result['refund_reason'];
-                    $refund_remark = empty($result['refund_remark']) ? '暂无' : $result['refund_remark'];
-                    $log['log_remark'] = '退款原因(' . $refund_reason . ')' . '退款说明(' . $refund_remark . ')';
-                    break;
-                //会员发快递
-                case AfterSaleLog::USER_SEND_EXPRESS:
-                    $log['log_img'] = empty($result['express_image']) ? '' : UrlServer::getFileUrl($result['express_image']);
-                    $express_name = $result['express_name'];
-                    $invoice_no = $result['invoice_no'];
-                    $express_remark = empty($result['express_remark']) ? '暂无' : $result['express_remark'];
-                    $log['log_remark'] = '快递公司(' . $express_name . ')' . '单号(' . $invoice_no . ')' . '备注说明(' . $express_remark . ')';
-                    break;
-                //商家拒绝退款 //商家拒绝收货
-                case AfterSaleLog::SHOP_REFUSE_REFUND:
-                case AfterSaleLog::SHOP_REFUSE_TAKE_GOODS:
-                    $admin_remark = empty($result['admin_remark']) ? '暂无' : $result['admin_remark'];
-                    $log['log_remark'] = '备注:' . $admin_remark;
-                    break;
-            }
-
-        }
-
-        $result['shop_address'] = self::getShopAddress($shop_id);
-        return $result;
-    }
-
-    /**
-     * @notes 获取商家地址
-     * @return string
-     * @author suny
-     * @date 2021/7/14 10:19 上午
-     */
-    public static function getShopAddress($shop_id)
-    {
-
-        $shop_info = Shop::where('id', $shop_id)->find();
-
-        $refund_address = $shop_info['refund_address'];
-        $shop_province = $refund_address['province_id'] ?? ''; //省份
-        $shop_city = $refund_address['city_id'] ?? ''; //城市
-        $shop_district = $refund_address['district_id'] ?? ''; //县区
-        $shop_address = $refund_address['address'] ?? ''; //详细地址
-        $shop_contact = $refund_address['nickname'] ?? ''; //联系人
-        $shop_mobile = $refund_address['mobile'] ?? ''; //联系电话
-
-        //组装退货地址
-        if (empty($shop_province) || empty($shop_city) || empty($shop_district)) {
-            $arr = [];
-        } else {
-            $arr = [$shop_province, $shop_city, $shop_district];
-        }
-        $shop_address = AreaServer::getAddress($arr, $shop_address);
-
-        return $shop_address . '(' . $shop_contact . ',' . $shop_mobile . ')';
-    }
-
-    /**
-     * @notes 商家同意售后
-     * @param $id
-     * @param $shop_id
-     * @return false
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author suny
-     * @date 2021/7/14 10:19 上午
-     */
-    public static function agree($id, $shop_id)
-    {
-
-        $after_sale = AfterSale::find($id);
-        if ($after_sale['del'] == 1) {
-            return false;
-        }
-        $after_sale->update_time = time();
-        //仅退款
-        if ($after_sale['refund_type'] == AfterSale::TYPE_ONLY_REFUND) {
-            $after_sale->status = AfterSale::STATUS_WAIT_REFUND;//更新为等待退款状态
-        }
-
-        //退款退货
-        if ($after_sale['refund_type'] == AfterSale::TYPE_REFUND_RETURN) {
-            $after_sale->status = AfterSale::STATUS_WAIT_RETURN_GOODS;//更新为商品待退货状态
-        }
-
-        $after_sale->save();
-        //记录日志
-        AfterSaleLogLogic::record(
-            AfterSaleLog::TYPE_SHOP,
-            AfterSaleLog::SHOP_AGREE_REFUND,
-            $after_sale['order_id'],
-            $after_sale['id'],
-            $shop_id,
-            AfterSaleLog::SHOP_AGREE_REFUND
-        );
-
-        // 仅退款;更新订单商品为等待退款
-        if ($after_sale['refund_type'] == AfterSale::TYPE_ONLY_REFUND) {
-            $order_goods = OrderGoods::find(['id' => $after_sale['order_goods_id']]);
-            $order_goods->refund_status = OrderGoodsEnum::REFUND_STATUS_WAIT;//等待退款
-            $order_goods->save();
-        }
-
-        $mobile = Order::where(['id' => $after_sale['order_id']])->value('mobile');
-
-        //通知用户
-        event('Notice', [
-            'scene' => NoticeEnum::AFTER_SALE_NOTICE,
-            'mobile' => $mobile,
-            'params' => [
-                'after_sale_sn' => $after_sale['sn'],
-                'user_id' => $after_sale['user_id'],
-                'after_sale_result' => AfterSaleLog::getLogDesc(AfterSaleLog::SHOP_AGREE_REFUND),
-                'after_sale_remark' => AfterSaleLog::getLogDesc(AfterSaleLog::SHOP_AGREE_REFUND),
-                'time' => date('Y-m-d H:i:s', time())
-            ]
-        ]);
-    }
-
-
-    /**
-     * @notes 商家拒绝
-     * @param $post
-     * @param $shop_id
-     * @return false
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author suny
-     * @date 2021/7/14 10:19 上午
-     */
-    public static function refuse($post, $shop_id)
-    {
-
-        $id = $post['id'];
-        $after_sale = AfterSale::find($id);
-        if ($after_sale['del'] == 1) {
-            return false;
-        }
-        $after_sale->update_time = time();
-        $after_sale->status = AfterSale::STATUS_REFUSE_REFUND;//更新为拒绝退款状态
-        $after_sale->admin_remark = isset($post['remark']) ? $post['remark'] : '';
-        $after_sale->save();
-        //记录日志
-        AfterSaleLogLogic::record(
-            AfterSaleLog::TYPE_SHOP,
-            AfterSaleLog::SHOP_REFUSE_REFUND,
-            $after_sale['order_id'],
-            $after_sale['id'],
-            $shop_id,
-            AfterSaleLog::SHOP_REFUSE_REFUND
-        );
-
-        $mobile = Order::where(['id' => $after_sale['order_id']])->value('mobile');
-
-        //通知用户
-        event('Notice', [
-            'scene' => NoticeEnum::AFTER_SALE_NOTICE,
-            'mobile' => $mobile,
-            'params' => [
-                'after_sale_sn' => $after_sale['sn'],
-                'user_id' => $after_sale['user_id'],
-                'after_sale_result' => AfterSaleLog::getLogDesc(AfterSaleLog::SHOP_REFUSE_REFUND),
-                'after_sale_remark' => AfterSaleLog::getLogDesc(AfterSaleLog::SHOP_REFUSE_REFUND),
-                'time' => date('Y-m-d H:i:s', time())
-            ]
-        ]);
-    }
-
-
-    /**
-     * @notes 商家收货
-     * @param $post
-     * @param $admin_id
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author suny
-     * @date 2021/7/14 10:20 上午
-     */
-    public static function takeGoods($post, $admin_id)
-    {
-
-        $id = $post['id'];
-        $after_sale = AfterSale::find($id);
-        $after_sale->update_time = time();
-        $after_sale->status = AfterSale::STATUS_WAIT_REFUND;//更新为等待退款状态
-        $after_sale->save();
-        //记录日志
-        AfterSaleLogLogic::record(
-            AfterSaleLog::TYPE_SHOP,
-            AfterSaleLog::SHOP_TAKE_GOODS,
-            $after_sale['order_id'],
-            $after_sale['id'],
-            $admin_id,
-            AfterSaleLog::SHOP_TAKE_GOODS
-        );
-        //更新订单商品为等待退款状态
-        $order_goods = OrderGoods::find(['id' => $after_sale['order_goods_id']]);
-        $order_goods->refund_status = OrderGoodsEnum::REFUND_STATUS_WAIT;//等待退款
-        $order_goods->save();
-    }
-
-
-    /**
-     * @notes 商家拒绝收货
-     * @param $post
-     * @param $admin_id
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author suny
-     * @date 2021/7/14 10:20 上午
-     */
-    public static function refuseGoods($post, $admin_id)
-    {
-
-        $id = $post['id'];
-        $after_sale = AfterSale::find($id);
-        $after_sale->update_time = time();
-        $after_sale->status = AfterSale::STATUS_REFUSE_RECEIVE_GOODS;//更新为拒绝收货状态
-        $after_sale->admin_remark = isset($post['remark']) ? $post['remark'] : '';
-        $after_sale->save();
-        //记录日志
-        AfterSaleLogLogic::record(
-            AfterSaleLog::TYPE_SHOP,
-            AfterSaleLog::SHOP_REFUSE_TAKE_GOODS,
-            $after_sale['order_id'],
-            $after_sale['id'],
-            $admin_id,
-            AfterSaleLog::SHOP_REFUSE_TAKE_GOODS
-        );
-    }
-
-
-    /**
-     * @notes 确认退款 ===> 退款
-     * @param $id
-     * @param $admin_id
-     * @return bool|string
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
-     * @throws \think\exception\PDOException
-     * @author suny
-     * @date 2021/7/14 10:20 上午
-     */
-    public static function confirm($post, $admin_id)
-    {
-
-        //售后记录状态
-        $after_sale = AfterSale::find($post['id']);
-
-        if($after_sale['del'] == 1){
-            return '该售后已经撤销';
-        }
-        if($after_sale['status'] != AfterSaleEnum::STATUS_WAITING){
-            return '售后状态错误';
-        }
-        $order = OrderModel::find(['id' => $after_sale['order_id']]);
-        $order_goods = OrderGoods::find(['id' => $after_sale['order_goods_id']]);
-
-        Db::startTrans();
-        try {
-            //更新售后为退款成功状态
-            $after_sale->update_time = time();
-            $after_sale->status = AfterSale::STATUS_SUCCESS_REFUND;
-            $after_sale->save();
-            //售后日志
-            AfterSaleLogLogic::record(
-                AfterSaleLog::TYPE_SHOP,
-                AfterSaleLog::REFUND_SUCCESS,
-                $after_sale['order_id'],
-                $after_sale['id'],
-                $admin_id,
-                AfterSaleLog::REFUND_SUCCESS
-            );
-            //更新订单和订单商品状态
-            OrderRefundLogic::afterSaleRefundUpdate($order, $order_goods['id'], $admin_id);
-
-            //线下支付订单原路退回不做处理
-            if ($post['refund_way'] != OrderRefundEnum::REFUND_WAY_ORIGINAL || $order['pay_way'] != PayEnum::OFFLINE_PAY) {
-                //订单退款
-                OrderRefundLogic::refund($order, $order['order_amount'], $after_sale['refund_price'],$post['refund_way']);
-            }
-
-            Db::commit();
-            return true;
-        } catch (\Exception $e) {
-            Db::rollback();
-            //增加退款失败记录
-            OrderRefundLogic::addErrorRefund($order, $e->getMessage());
-            //记录日志
-            AfterSaleLogLogic::record(
-                AfterSaleLog::TYPE_SHOP,
-                AfterSaleLog::REFUND_ERROR,//退款失败
-                $after_sale['order_id'],
-                $after_sale['id'],
-                $admin_id,
-                AfterSaleLog::REFUND_ERROR,//退款失败
-                $e->getMessage()
-            );
-            return $e->getMessage();
-        }
-    }
-
-    /**
-     * @notes 全部数量
-     * @return int
-     * @author suny
-     * @date 2021/7/13 3:53 下午
-     */
-    public static function getAll($shop_id)
-    {
-
-        return AfterSale::alias('a')
-            ->where(['a.del' => 0, 'shop_id' => $shop_id])
-            ->join('order o', 'a.order_id = o.id')
-            ->count('a.id');
-    }
-
-    /**
-     * @notes 获取统计数量
-     * @param $status
-     * @return array
-     * @author suny
-     * @date 2021/7/13 4:07 下午
-     */
-    public static function getStatus($status, $shop_id)
-    {
-
-        foreach ($status as $key => $value) {
-            $count = AfterSale::alias('a')
-                ->join('order o', 'a.order_id = o.id')
-                ->where(['status' => $key, 'a.del' => 0, 'shop_id' => $shop_id])
-                ->count('a.id');
-            $data[] = $value . "(" . $count . ")";
-        }
-        return $data;
-    }
-
-
-    /**
-     * @notes 导出Excel
-     * @param array $condition
-     * @return array|false
-     * @author 段誉
-     * @date 2022/4/24 10:10
-     */
-    public static function export($condition = [])
-    {
-        try {
-            $field = 'a.sn,a.refund_type,a.refund_price,a.status,a.create_time,
-            u.nickname,o.order_sn';
-
-            $lists = (new AfterSale())
-                ->alias('a')
-                ->field($field)
-                ->join('order o', 'o.id = a.order_id')
-                ->join('user u', 'u.id = a.user_id')
-                ->join('order_goods g', 'g.id = a.order_goods_id')
-                ->with(['order_goods', 'user', 'order'])
-                ->where($condition)
-                ->order('a.id desc')
-                ->group('a.id')
-                ->select()->toArray();
-
-            foreach ($lists as &$list) {
-                $list['refund_type'] = AfterSale::getRefundTypeDesc($list['refund_type']);
-                $list['status'] = AfterSale::getStatusDesc($list['status']);
-            }
-
-            $excelFields = [
-                'sn' => '售后单号',
-                'nickname' => '用户昵称',
-                'order_sn' => '订单编号',
-                'refund_type' => '售后方式',
-                'refund_price' => '售后金额',
-                'status' => '售后状态',
-                'create_time' => '申请时间',
-            ];
-
-            $export = new ExportExcelServer();
-            $export->setFileName('售后');
-            $result = $export->createExcel($excelFields, $lists);
-
-            return ['url' => $result];
-
-        } catch (\Exception $e) {
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-}

+ 0 - 722
app/shop/logic/bargain/BargainLogic.php

@@ -1,722 +0,0 @@
-<?php
-
-namespace app\shop\logic\bargain;
-
-use app\common\basics\Logic;
-use app\common\model\bargain\Bargain;
-use app\common\model\bargain\BargainItem;
-use app\common\model\bargain\BargainKnife;
-use app\common\model\bargain\BargainLaunch;
-use app\common\model\goods\Goods as GoodsModel;
-use app\common\model\user\User;
-use app\common\model\order\Order;
-use app\common\enum\BargainEnum;
-use app\common\model\team\TeamActivity as TeamActivityModel;
-use app\common\server\UrlServer;
-use app\common\model\seckill\SeckillGoods;
-use think\facade\Db;
-use think\Model;
-
-/**
- * Class BargainLogic
- * @package app\shop\logic\bargain
- */
-class BargainLogic extends Logic
-{
-
-    /**
-     * @notes 砍价活动列表
-     * @param $get
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author suny
-     * @date 2021/7/14 10:20 上午
-     */
-    public static function activity($get)
-    {
-
-        $where = [
-            ['del', '=', 0],
-            ['shop_id', '=', $get['shop_id']]
-        ];
-
-        // 查询条件
-        if (!empty($get['goods_name']) and $get['goods_name'] !== '') {
-            $goodsModel = new GoodsModel();
-            $ids = $goodsModel->field('id,name')->where([
-                ['name', 'like', '%' . $get['goods_name'] . '%']
-            ])->column('id');
-
-            $where[] = ['goods_id', 'in', $ids];
-        }
-
-        if (isset($get['status']) and is_numeric($get['status'])) {
-            $where[] = ['status', '=', (int)$get['status']];
-        }
-
-        //审核状态
-        if (isset($get['type']) && $get['type'] != "") {
-            $where[] = ['audit_status', '=', $get['type']];
-        } else if ($get['type'] == "") {
-            $where[] = ['audit_status', '=', 1];
-        }
-
-        $bargainModel = new Bargain();
-        $count = $bargainModel->where($where)->count('id');
-        $lists = $bargainModel->field(true)
-            ->where($where)
-            ->with(['goods'])
-            ->append(['status_text'])
-            ->withCount(['launchPeopleNumber', 'successKnifePeopleNumber', 'knifePeopleNumber'])
-            ->page($get['page'], $get['limit'])
-            ->select()->toArray();
-
-        foreach ($lists as &$item) {
-            $item['info']['launch_people_number_count'] = $item['launch_people_number_count'];
-            $item['info']['success_knife_people_number_count'] = $item['success_knife_people_number_count'];
-            $item['info']['knife_people_number_count'] = $item['knife_people_number_count'];
-            $item['goods']['image'] = UrlServer::getFileUrl($item['goods']['image']);
-            $item['activity_start_time'] = date('Y-m-d H:i:s', $item['activity_start_time']);
-            $item['activity_end_time'] = date('Y-m-d H:i:s', $item['activity_end_time']);
-        }
-
-        return ['count' => $count, 'lists' => $lists];
-    }
-
-
-    /**
-     * @notes 新增砍价活动
-     * @param $post
-     * @return bool
-     * @throws \think\exception\PDOException
-     * @author suny
-     * @date 2021/7/14 10:21 上午
-     */
-    public static function add($post)
-    {
-
-        Db::startTrans();
-        try {
-            // 校验拼团活动是否存在
-            $teamActivityModel = new TeamActivityModel();
-            $team = $teamActivityModel->where([
-                'goods_id' => intval($post['goods_id']),
-                'del' => 0
-            ])->find();
-
-            if ($team) {
-                static::$error = '商品正在参与拼团活动, 请先移除活动再添加';
-                return false;
-            }
-
-            //秒杀验证
-            $seckill_goods = SeckillGoods::where(['goods_id' => intval($post['goods_id']), 'del' => 0])
-                ->find();
-            if ($seckill_goods) {
-                static::$error = '商品正在参与秒杀活动,无法修改';
-                return false;
-            }
-
-            // 每刀金额(随机 / 固定)
-            $knife_price = 0;
-            if ($post['knife_type'] == 1) {
-                $knife_price = [$post['min_knife_price'], $post['max_knife_price']];
-                $knife_price = implode(',', $knife_price);
-            } else {
-                $knife_price = $post['fixed_knife_price'];
-            }
-
-            // 查出最大低价和最少价格
-            $bargain_price = [];
-            foreach ($post['floor_price'] as $key => $value) {
-                foreach ($value as $K => $item) {
-                    array_push($bargain_price, $item);
-                }
-            }
-            $bargain_max_price = !empty($bargain_price) ? max($bargain_price) : 0;
-            $bargain_min_price = !empty($bargain_price) ? min($bargain_price) : 0;
-
-            // 新增砍价活动
-            $bargainModel = new Bargain();
-            $bargain_id = $bargainModel->insertGetId([
-                'goods_id' => $post['goods_id'],
-                'shop_id' => $post['shop_id'],
-                'audit_status' => 0, //待审核
-                'time_limit' => $post['time_limit'],
-                'activity_start_time' => strtotime($post['activity_start_time']),
-                'activity_end_time' => strtotime($post['activity_end_time']),
-                'bargain_min_price' => $bargain_min_price,
-                'bargain_max_price' => $bargain_max_price,
-                'share_title' => empty($post['share_title']) ? '' : $post['share_title'],
-                'share_intro' => empty($post['share_intro']) ? '' : $post['share_intro'],
-                'payment_where' => $post['payment_where'],
-                'knife_type' => $post['knife_type'],
-                'knife_price' => $knife_price,
-                'status' => $post['status'],
-                'del' => 0,
-            ]);
-
-            // 新增砍价商品SKU
-            $lists = [];
-            foreach ($post['floor_price'] as $key => $value) {
-                foreach ($value as $K => $item) {
-                    $lists[] = [
-                        'bargain_id' => $bargain_id,
-                        'goods_id' => $key,
-                        'item_id' => $K,
-                        'floor_price' => $item,
-                        'first_knife_price' => $post['first_knife_price'][$key][$K]
-                    ];
-                }
-            }
-            if (!empty($lists)) {
-                $bargainItemModel = new BargainItem();
-                $bargainItemModel->saveAll($lists);
-            }
-
-            Db::commit();
-            return true;
-        } catch (\Exception $e) {
-            static::$error = $e->getMessage();
-            Db::rollback();
-            return false;
-        }
-    }
-
-    /**
-     * @notes 编辑砍价活动
-     * @param $post
-     * @return bool
-     * @throws \think\exception\PDOException
-     * @author suny
-     * @date 2021/7/14 10:21 上午
-     */
-    public static function edit($post)
-    {
-
-        Db::startTrans();
-        try {
-            // 查询商品信息
-            $goodsModel = new GoodsModel();
-            $goods = $goodsModel->field('id,name,image')
-                ->where(['id' => (int)$post['goods_id']])->find();
-
-            if (!$goods) {
-                static::$error = '选择的商品已不存在,可能已被删除';
-                return false;
-            }
-
-            // 每刀金额(随机 / 固定)
-            $knife_price = 0;
-            if ($post['knife_type'] == 1) {
-                $knife_price = [$post['min_knife_price'], $post['max_knife_price']];
-                $knife_price = implode(',', $knife_price);
-            } else {
-                $knife_price = $post['fixed_knife_price'];
-            }
-
-            // 查出最大低价和最少价格
-            $bargain_price = [];
-            foreach ($post['floor_price'] as $key => $value) {
-                foreach ($value as $K => $item) {
-                    array_push($bargain_price, $item);
-                }
-            }
-            $bargain_max_price = !empty($bargain_price) ? max($bargain_price) : 0;
-            $bargain_min_price = !empty($bargain_price) ? min($bargain_price) : 0;
-
-            // 更新砍价活动
-            $bargainModel = new Bargain();
-            $checkAudit = self::checkAudit((int)$post['id']);
-            if (false === $checkAudit) {
-                $audit_status = BargainEnum::TO_BE_REVIEWED; //待审核
-            } else {
-                $audit_status = BargainEnum::AUDIT_PASS; //审核通过
-            }
-            $bargainModel->where(['id' => (int)$post['id']])->update([
-                'goods_id' => $post['goods_id'],
-                'time_limit' => $post['time_limit'],
-                'activity_start_time' => strtotime($post['activity_start_time']),
-                'activity_end_time' => strtotime($post['activity_end_time']),
-                'bargain_min_price' => $bargain_min_price,
-                'bargain_max_price' => $bargain_max_price,
-                'share_title' => empty($post['share_title']) ? '' : $post['share_title'],
-                'share_intro' => empty($post['share_intro']) ? '' : $post['share_intro'],
-                'payment_where' => $post['payment_where'],
-                'knife_type' => $post['knife_type'],
-                'knife_price' => $knife_price,
-                'status' => $post['status'],
-                'audit_status' => $audit_status,
-            ]);
-
-            // 删除旧的SKU
-            $bargainItemModel = new BargainItem();
-            $bargainItemModel->where(['bargain_id' => (int)$post['id']])->delete();
-
-            // 更新砍价商品SKU
-            $lists = [];
-            foreach ($post['floor_price'] as $key => $value) {
-                foreach ($value as $K => $item) {
-                    $lists[] = [
-                        'bargain_id' => $post['id'],
-                        'goods_id' => $key,
-                        'item_id' => $K,
-                        'floor_price' => $item,
-                        'first_knife_price' => $post['first_knife_price'][$key][$K]
-                    ];
-                }
-            }
-            if (!empty($lists)) {
-                $bargainItemModel->saveAll($lists);
-            }
-
-            Db::commit();
-            return true;
-        } catch (\Exception $e) {
-            static::$error = $e->getMessage();
-            Db::rollback();
-            return false;
-        }
-    }
-
-    /**
-     * @notes 验证审核状态
-     * @param $id
-     * @return bool
-     * @author suny
-     * @date 2021/7/14 10:21 上午
-     */
-    public static function checkAudit($id)
-    {
-
-        $audit_status = Bargain::where('id', $id)->value('audit_status');
-        if ($audit_status == BargainEnum::TO_BE_REVIEWED || $audit_status == BargainEnum::AUDIT_REFUND) {
-            return false;
-        } else {
-            return true;
-        }
-    }
-
-    /**
-     * @notes 获取砍价活动详情
-     * @param $id
-     * @return array|Model|null
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author suny
-     * @date 2021/7/14 10:21 上午
-     */
-    public static function getDetail($id)
-    {
-
-        $bargainModel = new Bargain();
-        $bargainItemModel = new BargainItem();
-
-        $detail = $bargainModel->field(true)
-            ->where(['id' => (int)$id])
-            ->with(['goods'])
-            ->find();
-
-        $goodItem = $bargainItemModel->field('t.*,gi.id as spec_item_id,
-            gi.spec_value_str, gi.price as spec_item_price, gi.stock')
-            ->where(['bargain_id' => (int)$id])
-            ->alias('t')
-            ->rightJoin('goods_item gi', 'gi.id = t.item_id')
-            ->select();
-
-        $detail['min_knife_price'] = 0;
-        $detail['max_knife_price'] = 0;
-        $detail['fixed_knife_price'] = 0;
-        if ($detail['knife_type'] == 1) {
-            $knife_price_arr = explode(',', $detail['knife_price']);
-            $detail['min_knife_price'] = empty($knife_price_arr[0]) ? 0 : $knife_price_arr[0];
-            $detail['max_knife_price'] = empty($knife_price_arr[1]) ? 0 : $knife_price_arr[1];
-        } else {
-            $detail['fixed_knife_price'] = $detail['knife_price'];
-        }
-
-        // 处理判断商品规格是否已发生变化, 没变化是true, 否则false
-        $detail['is_goods_item'] = true;
-        foreach ($goodItem as $item) {
-            if (!$item['spec_value_str'] || $item['spec_value_str'] == ''
-                || $item['spec_item_price'] == '') {
-                $detail['is_goods_item'] = false;
-                break;
-            }
-        }
-
-        $detail['item'] = $goodItem;
-        $detail['goods']['image'] = UrlServer::getFileUrl($detail['goods']['image']);
-        $detail['activity_start_time'] = date('Y-m-d H:i:s', $detail['activity_start_time']);
-        $detail['activity_end_time'] = date('Y-m-d H:i:s', $detail['activity_end_time']);
-
-        return $detail;
-    }
-
-    /**
-     * @notes 停止活动
-     * @param $post
-     * @return bool
-     * @throws \think\exception\PDOException
-     * @author suny
-     * @date 2021/7/14 10:21 上午
-     */
-    public static function stop($post)
-    {
-
-        Db::startTrans();
-        try {
-            $bargainModel = new Bargain();
-            // 切换状态
-            $bargainModel->where(['id' => (int)$post['id']])
-                ->update(['status' => 0]);//停止
-            // 关闭活动未完成的
-            $bargainLaunchModel = new BargainLaunch();
-            $bargainLaunchModel->where(['bargain_id' => $post['id'], 'status' => 0])
-                ->update(['status' => 2]);//砍价失败
-            Db::commit();
-            return true;
-        } catch (\Exception $e) {
-            static::$error = $e->getMessage();
-            Db::rollback();
-            return false;
-        }
-    }
-
-    /**
-     * @notes 开启活动
-     * @param $post
-     * @return Bargain
-     * @author suny
-     * @date 2021/7/14 10:21 上午
-     */
-    public static function start($post)
-    {
-
-        $bargainModel = new Bargain();
-        // 切换状态
-        return $bargainModel->where(['id' => (int)$post['id']])
-            ->update(['status' => 1]);//开启
-    }
-
-    /**
-     * @notes 切换状态
-     * @param $post
-     * @return bool
-     * @throws \think\exception\PDOException
-     * @author suny
-     * @date 2021/7/14 10:22 上午
-     */
-    public static function switchStatus($post)
-    {
-
-        Db::startTrans();
-        try {
-            $bargainModel = new Bargain();
-            // 切换状态
-            $bargainModel->where(['id' => (int)$post['id']])
-                ->update([$post['field'] => $post['status']]);
-            // 关闭活动未完成的
-            if ($post['status']) {
-                $bargainLaunchModel = new BargainLaunch();
-                $bargainLaunchModel->where(['bargain_id' => $post['id'], 'status' => 0])
-                    ->update(['status' => 2]);//砍价失败
-            }
-
-            Db::commit();
-            return true;
-        } catch (\Exception $e) {
-            static::$error = $e->getMessage();
-            Db::rollback();
-            return false;
-        }
-    }
-
-    /**
-     * @notes 砍价列表
-     * @param $get
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
-     * @author suny
-     * @date 2021/7/14 10:22 上午
-     */
-    public static function getLaunch($get)
-    {
-
-        // 查询条件
-        $where = [];
-        $where[] = ['shop_id', '=', $get['shop_id']];
-
-        if (isset($get['bargain_id']) and $get['bargain_id']) {
-            $where[] = ['bargain_id', '=', (int)$get['bargain_id']];
-        }
-
-        if (isset($get['goods_name']) and $get['goods_name'] !== '') {
-            $goodsModel = new GoodsModel();
-            $ids = $goodsModel->field('id,name')->where([
-                ['name', 'like', '%' . $get['goods_name'] . '%']
-            ])->column('id');
-            $where[] = ['goods_id', 'in', $ids];
-        }
-        if (isset($get['status']) and is_numeric($get['status'])) {
-            $where[] = ['status', '=', (int)$get['status']];
-        }
-
-        if (isset($get['launch_start_time']) and $get['launch_start_time'] !== '') {
-            $where[] = ['launch_start_time', '>=', strtotime($get['launch_start_time'])];
-        }
-
-        if (isset($get['launch_end_time']) and $get['launch_end_time'] !== '') {
-            $where[] = ['launch_end_time', '<=', strtotime($get['launch_end_time'])];
-        }
-
-        if (isset($get['keyword_type']) and $get['keyword_type'] !== '') {
-            if (isset($get['keyword']) and $get['keyword'] !== '') {
-                switch ($get['keyword_type']) {
-                    case 'sn':
-                        $uid = User::where('sn', '=', $get['keyword'])->column('id');
-                        $where[] = ['user_id', 'in', $uid];
-                        break;
-                    case 'nickname':
-                        $uid = User::where('nickname', 'like', '%' . $get['keyword'] . '%')->column('id');
-                        $where[] = ['user_id', 'in', $uid];
-                        break;
-                }
-            }
-        }
-        $model = new BargainLaunch();
-        $count = $model->where($where)->count('id');
-        $lists = $model->field(true)
-            ->where($where)
-            ->with(['user.level'])
-            ->order('id', 'desc')
-            ->page($get['page'], $get['limit'])
-            ->select()->toArray();
-
-        foreach ($lists as &$item) {
-            if (!empty($item['user']['avatar'])) {
-                $item['user']['avatar'] = UrlServer::getFileUrl($item['user']['avatar']);
-            }
-
-            $item['launch_start_time'] = date('Y-m-d H:i:s', $item['launch_start_time']);
-            $item['launch_end_time'] = date('Y-m-d H:i:s', $item['launch_end_time']);
-            $item['domain'] = UrlServer::getFileUrl('/');
-            $item['status'] = BargainLaunch::getStatusDesc($item['status']);
-            $item['goods_image'] = $item['goods_snap']['image'] == "" ? $item['goods_snap']['goods_iamge'] : $item['goods_snap']['image'];
-        }
-
-        return ['count' => $count, 'lists' => $lists];
-    }
-
-    /**
-     * @notes 砍价订单详情
-     * @param $id
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author suny
-     * @date 2021/7/14 10:22 上午
-     */
-    public static function getLaunchDetail($id)
-    {
-
-        $model = new BargainLaunch();
-        $detail = $model->field(true)
-            ->where(['id' => (int)$id])
-            ->with(['user.level'])
-            ->find()->toArray();
-
-        $detail['domain'] = UrlServer::getFileUrl();
-        $detail['launch_start_time'] = date('Y-m-d H:i:s', $detail['launch_start_time']);
-        $detail['launch_end_time'] = date('Y-m-d H:i:s', $detail['launch_end_time']);
-        $detail['payment_where'] = $detail['bargain_snap']['payment_where'] == 1 ? '砍到底价可购买' : '任意金额可购买';
-        $detail['status'] = BargainLaunch::getStatusDesc($detail['status']);
-        return $detail;
-    }
-
-    /**
-     * @notes 砍价订单
-     * @param $launch_id
-     * @param $get
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author suny
-     * @date 2021/7/14 10:22 上午
-     */
-    public static function getKnifeOrderRecord($launch_id, $get)
-    {
-
-        $model = new BargainLaunch();
-        $count = $model->where(['id' => (int)$launch_id])
-            ->where('order_id', '>', 0)->count('id');
-        $lists = $model->field(true)
-            ->where(['id' => (int)$launch_id])
-            ->where('order_id', '>', 0)
-            ->with(['user.level', 'order'])
-            ->page($get['page'], $get['limit'])
-            ->select();
-
-        foreach ($lists as &$item) {
-            $item['order_status'] = Order::getOrderStatus($item['order']['order_status']);
-        }
-
-        return ['count' => $count, 'lists' => $lists];
-    }
-
-    /**
-     * @notes 砍价记录
-     * @param $launch_id
-     * @param $get
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author suny
-     * @date 2021/7/14 10:22 上午
-     */
-    public static function getKnifeRecord($launch_id, $get)
-    {
-
-        $model = new BargainKnife();
-
-        $count = $model->where(['launch_id' => (int)$launch_id])->count();
-        $lists = $model->field(true)
-            ->where(['launch_id' => (int)$launch_id])
-            ->with(['user.level'])
-            ->page($get['page'], $get['limit'])
-            ->select();
-
-        foreach ($lists as &$item) {
-            $item['help_time'] = date('Y-m-d H:i:s', $item['help_time']);
-            $item['help_price'] = '¥' . $item['help_price'];
-            $item['surplus_price'] = '¥' . $item['surplus_price'];
-        }
-
-        return ['count' => $count, 'lists' => $lists];
-    }
-
-    /**
-     * @notes 砍价详情
-     * @param $get
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author suny
-     * @date 2021/7/14 10:22 上午
-     */
-    public static function detail($get)
-    {
-
-        $where = [];
-        $where['b.id'] = $get['id'];
-        $info = Bargain::alias('b')
-            ->join('goods g', 'b.goods_id = g.id')
-            ->join('shop s', 's.id = b.shop_id')
-            ->where($where)
-            ->field('b.id,b.goods_id,b.audit_status,b.audit_remark,b.time_limit,b.payment_where,b.share_title,b.share_intro,g.image,g.name,g.min_price,g.max_price,s.id as sid,s.name as shop_name,s.type')
-            ->find()->toArray();
-
-        switch ($info['type']) {
-            case 1 :
-                $info['type'] = '官方自营';
-                break;
-            case 2 :
-                $info['type'] = '入驻商家';
-                break;
-        }
-
-        switch ($info['audit_status']) {
-            case 0 :
-                $info['audit_status'] = '待审核';
-                break;
-            case 1 :
-                $info['audit_status'] = '审核通过';
-                break;
-            case 2 :
-                $info['audit_status'] = '审核拒绝';
-                break;
-        }
-        $info['image'] = UrlServer::getFileUrl($info['image']);
-        return $info;
-    }
-
-    /**
-     * @notes 删除
-     * @param int $id
-     * @return bool
-     * @throws \think\exception\PDOException
-     * @author suny
-     * @date 2021/7/14 10:22 上午
-     */
-    public static function softDelete(int $id)
-    {
-
-        Db::startTrans();
-        try {
-            $bargainModel = new Bargain();
-            $bargainModel->where(['id' => (int)$id])->update(['del' => 1]);
-
-            // 关闭活动未完成的
-            $bargainLaunchModel = new BargainLaunch();
-            $bargainLaunchModel->where(['bargain_id' => $id, 'status' => 0])
-                ->update(['status' => 2]);
-
-            Db::commit();
-            return true;
-        } catch (\Exception $e) {
-            Db::rollback();
-            static::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-    /**
-     * @notes 关闭砍价
-     * @param $id
-     * @return BargainLaunch
-     * @author suny
-     * @date 2021/7/14 10:22 上午
-     */
-    public static function close($id)
-    {
-
-        $data = [
-            'launch_end_time' => time(),
-            'status' => BargainEnum::STATUS_FAIL,
-        ];
-        return BargainLaunch::where('id', $id)->update($data);
-    }
-
-    /**
-     * @notes 获取各列表数量
-     * @param $shop_id
-     * @return array
-     * @author suny
-     * @date 2021/7/14 10:23 上午
-     */
-    public static function getNum($shop_id)
-    {
-
-        $all = Bargain::where(['del' => 0, 'shop_id' => $shop_id])->count('id');
-        $unaudit = Bargain::where(['audit_status' => 0, 'del' => 0, 'shop_id' => $shop_id])->count('id');
-        $audit_pass = Bargain::where(['audit_status' => 1, 'del' => 0, 'shop_id' => $shop_id])->count('id');
-        $audit_refund = Bargain::where(['audit_status' => 2, 'del' => 0, 'shop_id' => $shop_id])->count('id');
-        $num = [
-            'all' => $all,
-            'unaudit' => $unaudit,
-            'audit_pass' => $audit_pass,
-            'audit_refund' => $audit_refund
-        ];
-        return $num;
-    }
-}

+ 0 - 454
app/shop/logic/coupon/CouponLogic.php

@@ -1,454 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-namespace app\shop\logic\coupon;
-
-use app\common\model\user\User;
-use app\common\server\UrlServer;
-use app\common\basics\Logic;
-use think\facade\Db;
-use app\common\model\coupon\Coupon;
-use app\common\model\coupon\CouponGoods;
-use app\common\model\coupon\CouponList;
-use app\common\model\user\UserLevel;
-
-
-class CouponLogic extends Logic{
-    public static function lists($get){
-        // 下架本店过了发放时间的优惠券
-        $now = time();
-        $updateWhere = [
-            ['send_time_start','<',$now],
-            ['send_time_end','<',$now],
-            ['status','=',1],
-            ['shop_id', '=', $get['shop_id']]
-        ];
-        Coupon::where($updateWhere)
-            ->update(['status'=>0,'update_time'=>$now]);
-
-        $where = [
-            ['del','=',0],
-            ['shop_id','=', $get['shop_id']]
-        ];
-
-        if(empty($get['type'])) {
-            // 已下架
-            $where[] = ['status', '=', '0'];
-        }else{
-            $where[] = ['status', '=', '1'];
-        }
-
-        // 名称
-        if(isset($get['name']) && !empty($get['name'])) {
-            $where[] = ['name', 'like', '%'.trim($get['name']).'%' ];
-        }
-
-        // 领取方式
-        if(isset($get['get_type']) && !empty($get['get_type'])) {
-            $where[] = ['get_type', '=', $get['get_type'] ];
-        }
-
-        // 创建时间
-        if(isset($get['start_time']) && !empty($get['start_time'])) {
-            $where[] = ['create_time', '>=', strtotime($get['start_time']) ];
-        }
-
-        if(isset($get['end_time']) && !empty($get['end_time'])) {
-            $where[] = ['create_time', '<=', strtotime($get['end_time']) ];
-        }
-
-        $coupon_count = Coupon::where($where)->count();
-
-        $coupon_list = Coupon::field('id,name,money,use_goods_type,use_goods_type as use_goods_type_desc,condition_type,condition_money,condition_type as condition_type_desc,send_total_type,send_total_type as send_total_type_desc,send_total,get_type,get_type as get_type_desc,status,status as statusDesc,send_time_start,send_time_end,send_time_start as send_time,use_time_type,use_time_start,use_time_end,use_time,use_time_type as use_time_desc,create_time')
-            ->where($where)
-            ->page($get['page'], $get['limit'])
-            ->order('id desc')
-            ->select()
-            ->toArray();
-
-        return ['count' => $coupon_count, 'list' => $coupon_list];
-
-    }
-
-    //新增优惠券
-    public static function add($post){
-        $time = time();
-        //拼接数据
-        $add_data = [
-            'shop_id'           => $post['shop_id'],
-            'name'              => trim($post['name']),
-            'money'             => $post['money'],
-            'send_time_start'   => strtotime($post['send_time_start']),
-            'send_time_end'     => strtotime($post['send_time_end']),
-            'send_total_type'   => $post['send_total_type'],
-            'send_total'        => $post['send_total_type'] == 2 ? $post['send_total'] : '',
-            'condition_type'    => $post['condition_type'],
-            'condition_money'   => $post['condition_type'] == 2 ? $post['condition_money'] : '',
-            'use_time_type'     => $post['use_time_type'],
-            'use_time_start'    => $post['use_time_type'] == 1 ? strtotime($post['use_time_start']) : '',
-            'use_time_end'      => $post['use_time_type'] == 1 ? strtotime($post['use_time_end']) : '',
-            'use_time'          => $post['use_time_type'] == 2 ? $post['use_time'] : '',
-            'get_type'          => $post['get_type'],
-            'get_num_type'      => $post['get_num_type'],
-            'get_num'           => $post['get_num'],
-            'use_goods_type'    => $post['use_goods_type'],
-            'status'            => $post['status'],
-            'create_time'       => $time,
-            'update_time'       => $time,
-        ];
-        //用券时间
-        if($post['use_time_type'] == 3){
-            $update_data['use_time'] = $post['tomorrow_use_time'];
-        }
-        //领取次数
-        if($post['get_num_type'] == 3){
-            $update_data['get_num'] = $post['day_get_num'];
-        }
-
-        //提交订单
-        Db::startTrans();
-        try {
-            $coupon = Coupon::create($add_data);
-            if($coupon && $coupon['use_goods_type'] != 1){
-                $goods_coupon = [];
-                $now = time();
-                foreach ($post['goods_ids'] as $item){
-                    $goods_coupon[] = [
-                        'coupon_id'     => $coupon->id,
-                        'goods_id'      => $item,
-                        'create_time'   => $now,
-                    ];
-                }
-                $couponGoods = new CouponGoods();
-                $couponGoods->saveAll($goods_coupon);
-            }
-            Db::commit();
-            return true;
-        } catch (\Exception $e) {
-            Db::rollback();
-            self::$error = $e->getMessage();
-            return false;
-        }
-
-    }
-    public static function edit($post){
-        //拼接数据
-        $update_data = [
-            'shop_id'           => $post['shop_id'],
-            'name'              => $post['name'],
-            'money'             => $post['money'],
-            'send_time_start'   => strtotime($post['send_time_start']),
-            'send_time_end'     => strtotime($post['send_time_end']),
-            'send_total_type'   => $post['send_total_type'],
-            'send_total'        => $post['send_total_type'] == 2 ? $post['send_total'] : '',
-            'condition_type'    => $post['condition_type'],
-            'condition_money'   => $post['condition_type'] == 2 ? $post['condition_money'] : '',
-            'use_time_type'     => $post['use_time_type'],
-            'use_time_start'    => $post['use_time_type'] == 1 ? strtotime($post['use_time_start']) : '',
-            'use_time_end'      => $post['use_time_type'] == 1 ? strtotime($post['use_time_end']) : '',
-            'use_time'          => $post['use_time_type'] == 2 ? $post['use_time'] : '',
-            'get_type'          => $post['get_type'],
-            'get_num_type'      => $post['get_num_type'],
-            'get_num'           => $post['get_num_type'] == 2 ? $post['get_num'] : '',
-            'use_goods_type'    => $post['use_goods_type'],
-            'status'            => $post['status'],
-            'update_time'       => time()
-        ];
-        //用券时间
-        if($post['use_time_type'] == 3){
-            $update_data['use_time'] = $post['tomorrow_use_time'];
-        }
-        //领取次数
-        if($post['get_num_type'] == 3){
-            $update_data['get_num'] = $post['day_get_num'];
-        }
-
-        Db::startTrans();
-        try {
-            $coupon = Coupon::update($update_data,['id'=>$post['id']]);
-            CouponGoods::where(['coupon_id'=>$post['id']])->delete();
-
-            if($coupon && $coupon['use_goods_type'] != 1){
-                $goods_coupon = [];
-                $now = time();
-                foreach ($post['goods_ids'] as $item){
-                    $goods_coupon[] = [
-                        'coupon_id'     => $post['id'],
-                        'goods_id'      => $item,
-                        'create_time'   => $now,
-                    ];
-                }
-                $couponGoods = new CouponGoods();
-                $couponGoods->saveAll($goods_coupon);
-            }
-            Db::commit();
-            return true;
-        } catch (\Exception $e) {
-            Db::rollback();
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-    public static function getCoupon($id,$get_data = false){
-        $coupon = Coupon::findOrEmpty($id);
-        $coupon['goods_coupon'] = [];
-        if($get_data) {
-            $coupon = $coupon->getData();
-            $coupon['send_time_start'] = date('Y-m-d H:i:s',$coupon['send_time_start']);
-            $coupon['send_time_end'] = date('Y-m-d H:i:s',$coupon['send_time_end']);
-            if($coupon['use_goods_type'] != 1){ // 非全部商品
-                $goods_coupon= CouponGoods::alias('cg')
-                    ->join('goods g','cg.goods_id = g.id')
-                    ->where(['coupon_id'=>$id])
-                    ->field('g.id,name,max_price,min_price,stock')
-                    ->select();
-                foreach ($goods_coupon as &$item){
-                    $item['price'] = '¥'.$item['min_price'].'~'.'¥'.$item['max_price'];
-                    if($item['max_price'] == $item['min_price']){
-                        $item['price'] = '¥'.$item['min_price'];
-                    }
-                }
-                $coupon['goods_coupon'] = $goods_coupon;
-            }
-            if($coupon['use_time_start']){
-                $coupon['use_time_start'] = date('Y-m-d H:i:s',$coupon['use_time_start']);
-                $coupon['use_time_end'] = date('Y-m-d H:i:s',$coupon['use_time_end']);
-            }
-        }
-
-        return $coupon;
-    }
-
-    /*
- * 发放记录
- */
-    public static function log($get){
-        $where[] = ['cl.del','=',0];
-        $where[] = ['cl.coupon_id','=',$get['id']];
-
-        if(isset($get['keyword']) && $get['keyword']){
-            switch($get['search_type']) {
-                case 'sn';
-                    $where[] = ['u.sn', '=', $get['keyword']];
-                    break;
-                case 'nickname';
-                    $where[] = ['u.nickname', '=', $get['keyword']];
-                    break;
-                case 'mobile';
-                    $where[] = ['u.mobile', '=', $get['keyword']];
-                    break;
-            }
-        }
-
-        if(isset($get['status']) && $get['status'] != '') {
-            $where[] = ['cl.status', '=', $get['status']];
-        }
-
-        $log_count = CouponList::alias('cl')
-            ->join('user u','cl.user_id = u.id')
-            ->where($where)
-            ->count();
-
-        $log_list = CouponList::alias('cl')
-            ->join('user u','cl.user_id = u.id')
-            ->where($where)
-            ->field('cl.coupon_id,cl.status as cl_status,coupon_code,cl.create_time as cl_create_time,cl.use_time,u.nickname,u.avatar,u.mobile,u.sn,u.level')
-            ->page($get['page'], $get['limit'])
-            ->select();
-        $coupon_list = Coupon::where(['del'=>0])->column('name','id');
-        $level_name =  UserLevel::where(['del'=>0])->column('name','id');
-        foreach ($log_list as &$item)
-        {
-            $item['coupon_name'] = $coupon_list[$item['coupon_id']] ?? '';
-            $item['avatar'] = UrlServer::getFileUrl($item['avatar']);
-            $item['level_name'] = $level_name[$item['level']] ?? '';
-            $item['status_desc'] = $item['cl_status'] ? '已使用' : '未使用';
-            $item['cl_create_time'] = date('Y-m-d H:i:s',$item['cl_create_time']);
-            $item['use_time_desc'] = $item['use_time'] ? date('Y-m-d H:i:s',$item['use_time']) : '';
-        }
-        return ['count'=>$log_count , 'lists'=>$log_list];
-    }
-
-    public static function changeStatus($id)
-    {
-        try{
-            $coupon = Coupon::findOrEmpty($id);
-            if ($coupon['send_time_end'] <= time() && $coupon['status'] == 0) {
-                throw new \Exception('已过发放时间,无法上架');
-            }
-            $coupon->status = $coupon->status ? 0 : 1;
-            $coupon->update_time = time();
-            $coupon->save();
-            return true;
-        }catch(\Exception $e) {
-            self::$error = $e->getMessage();
-            return false;
-        }
-
-    }
-
-    /*
-     * 删除优惠券  删除已领取用户的优惠券
-     */
-    public static function del($id){
-        Db::startTrans();
-        try{
-            $time = time();
-            // 优惠券主表
-            Coupon::update([
-                'id' => $id,
-                'del' => 1,
-                'update_time' => $time
-            ]);
-            // 已发放的优惠券
-            CouponList::where(['coupon_id'=>$id])->update([
-                'del' => 1,
-                'update_time' => $time
-            ]);
-            Db::commit();
-            return true;
-        }catch(\Exception $e) {
-            Db::rollback();
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-    /**
-     * 发放优惠券
-     */
-    public static function sendCoupon($post){
-        $user_ids = $post['user_ids'];
-        $coupon_ids = $post['coupon_ids'];
-        $coupon_list = Coupon::where('id', 'in', $coupon_ids)->column('*', 'id');
-        $user_list = User::where('id', 'in', $user_ids)->column('id,nickname', 'id');
-
-        // 判断是否会超发
-        foreach($coupon_ids as $coupon_id) {
-            $coupon = $coupon_list[$coupon_id];
-            if($coupon['send_total_type'] == 2) { // 限制数量的券
-                $already_issue = CouponList::where([
-                    ['coupon_id','=',$coupon_id],
-                    ['del','=',0]
-                ])->count(); // 已发放数量
-                $target_issue = count($user_ids) + $already_issue; // 目标发放总数(若能正常发放的话)
-                if($target_issue > $coupon['send_total']) {
-                    self::$error = $coupon['name'].'的发放数量已达到限制';
-                    return false;
-                }
-            }
-        }
-
-        // 判断用户是否超出领取数量
-        foreach($coupon_ids as $coupon_id) {
-            $coupon = $coupon_list[$coupon_id];
-            if($coupon['get_num_type'] == 2) { // 限制次数
-                foreach($user_ids as $user_id) {
-                    $count = CouponList::where([
-                        'user_id' => $user_id,
-                        'coupon_id' => $coupon_id,
-                        'del' => 0,
-                    ])->count();
-                    if($count >= $coupon['get_num']) {
-                        self::$error = $user_list[$user_id]['nickname'].'已超出领取的限制次数';
-                        return false;
-                    }
-                }
-            }
-            if($coupon['get_num_type'] == 3) { // 每天领取次数限制
-                $timeStr = date('Y-m-d', time());
-                $today = strtotime($timeStr.' 00:00:00');
-                foreach($user_ids as $user_id) {
-                    $count = CouponList::where([
-                        ['user_id', '=', $user_id],
-                        ['coupon_id', '=', $coupon_id],
-                        ['del', '=', 0],
-                        ['create_time', '>', $today],
-                    ])->count();
-                    if($count >= $coupon['get_num']) {
-                        self::$error = $user_list[$user_id]['nickname'].'已超出每日领取的限制次数';
-                        return false;
-                    }
-                }
-            }
-        }
-
-
-        try{
-            $addData = [];
-            $time = time();
-            foreach ($coupon_ids as $coupon_id){
-                foreach ($user_ids  as $user_id){
-                    $addData[] = [
-                        'user_id'       => $user_id,
-                        'coupon_id'     => $coupon_id,
-                        'status'        => 0,
-                        'coupon_code'   => create_coupon_code(),
-                        'create_time'   => $time,
-                        'update_time'   => $time
-                    ];
-                }
-            }
-            // 批量添加
-            $couponList = new CouponList();
-            $couponList->saveAll($addData);
-
-            return true;
-        }catch(\Exception $e){
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-    public static function getShopCouponList($get)
-    {
-        $where = [
-            ['del', '=', 0],  // 未删除
-            ['status', '=', 1], // 上架中
-            ['get_type', '=', 2], // 商家赠送
-            ['send_time_start', '<=', time()], // 开始发放时间早于或等于当前时间
-            ['send_time_end', '>', time()], // 结束发放时间大于当前时间
-            ['shop_id', '=', $get['shop_id']]
-        ];
-
-        if(isset($get['name']) && !empty($get['name'])) {
-            $where[] = ['name', 'like', '%'.trim($get['name']).'%'];
-        }
-
-        if(isset($get['use_goods_type']) && !empty($get['use_goods_type'])) {
-            $where[] = ['use_goods_type', '=', $get['use_goods_type']];
-        }
-
-        $lists = Coupon::field('id,name,send_time_start,send_time_end,send_time_start as send_time,money,get_type as get_type_desc,condition_type as condition_type_desc_two,condition_money,send_total_type as send_info,send_total,use_goods_type as use_goods_type_desc,use_time_type,use_time_start,use_time_end,use_time,use_time as use_time_desc,status as status_desc,create_time')
-            ->where($where)
-            ->page($get['page'], $get['limit'])
-            ->order('id', 'desc')
-            ->select()
-            ->toArray();
-
-        $count = Coupon::field('id,name,send_time_start,send_time_end,money,get_type,condition_type,send_total_type')
-            ->where($where)
-            ->count();
-
-        return [
-            'count' => $count,
-            'lists' => $lists
-        ];
-    }
-}

+ 0 - 46
app/shop/logic/decoration/IndexLogic.php

@@ -1,46 +0,0 @@
-<?php
-namespace app\shop\logic\decoration;
-
-use app\common\basics\Logic;
-use app\common\model\shop\Shop;
-use app\common\enum\ShopEnum;
-use app\common\server\ConfigServer;
-use app\common\server\UrlServer;
-
-class IndexLogic extends Logic
-{
-    public static function getShopSet($shop_id)
-    {
-        $shop = Shop::field('logo,background,cover,banner')->findOrEmpty($shop_id)->toArray();
-        $shop['logo'] = UrlServer::getFileUrl(!empty($shop['logo']) ? $shop['logo'] : ShopEnum::DEFAULT_LOGO);
-        $shop['background'] = UrlServer::getFileUrl(!empty($shop['background']) ? $shop['background'] : ShopEnum::DEFAULT_BG);
-        $shop['pc_cover'] = UrlServer::getFileUrl(!empty($shop['cover']) ? $shop['cover'] : ShopEnum::DEFAULT_COVER);
-        $shop['pc_banner'] = UrlServer::getFileUrl(!empty($shop['banner']) ? $shop['banner'] : ShopEnum::DEFAULT_BANNER);
-        $shop['dome_background'] = UrlServer::getFileUrl(ShopEnum::DOME_BG);
-        $shop['dome_cover'] = UrlServer::getFileUrl(ShopEnum::DOME_COVER);
-        $shop['dome_banner'] = UrlServer::getFileUrl(ShopEnum::DOME_BANNER);
-        return $shop;
-    }
-
-    public static function set($post)
-    {
-        try{
-            $update = [
-                'logo' => clearDomain($post['logo']),
-                'background' => clearDomain($post['background']),
-                'cover' => clearDomain($post['pc_cover']),
-                'banner' => isset($post['pc_banner']) ? clearDomain($post['pc_banner']) : '',
-                'update_time' => time()
-            ];
-            $where = [
-                'id' => $post['shop_id'],
-                'del' => 0
-            ];
-            Shop::where($where)->update($update);
-            return true;
-        }catch(\Exception $e) {
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-}

+ 0 - 126
app/shop/logic/decoration/ShopAdLogic.php

@@ -1,126 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-namespace app\shop\logic\decoration;
-
-use app\common\basics\Logic;
-use app\common\enum\ShopAdEnum;
-use app\common\model\distribution\DistributionGoods;
-use app\common\model\shop\ShopAd;
-use app\common\server\FileServer;
-use think\facade\Validate;
-
-class ShopAdLogic extends Logic
-{
-    static function lists($params, $shop_id)
-    {
-        $where  = [
-            [ 'shop_id', '=', $shop_id ],
-        ];
-        $page   = $params['page'] ?? 1;
-        $limit  = $params['limit'] ?? 10;
-        
-        $append = [ 'place_name', 'terminal_name','status_name' ];
-        
-        $lists = ShopAd::where($where)->page($page, $limit)->append($append)->order('id desc')->select()->toArray();
-        $count = ShopAd::where($where)->count();
-    
-        return [ 'count' => $count, 'lists' => $lists ];
-    }
-    
-    static function add($params, $shop_id)
-    {
-        
-        if (empty($params['terminal']) || ! isset(ShopAdEnum::getTerminal()[$params['terminal']])) {
-            static::$error = '终端必须选择';
-            return false;
-        }
-        
-        if (empty($params['image'])) {
-            static::$error = '广告图片必须';
-            return false;
-        }
-        
-        $params['shop_id'] = $shop_id;
-        ShopAd::create($params, [
-            'shop_id',
-            'title',
-            'place',
-            'terminal',
-            'image',
-            'sort',
-            'link',
-            'status',
-        ]);
-        return true;
-    }
-    
-    static function edit($params, $shop_id)
-    {
-        
-        if (empty($params['terminal']) || ! isset(ShopAdEnum::getTerminal()[$params['terminal']])) {
-            static::$error = '终端必须选择';
-            return false;
-        }
-        
-        if (empty($params['image'])) {
-            static::$error = '广告图片必须';
-            return false;
-        }
-        
-        $where = [
-            [ 'id', '=', $params['id'] ],
-            [ 'shop_id', '=', $shop_id ],
-        ];
-        
-        ShopAd::update($params, $where, [
-            'shop_id',
-            'title',
-            'place',
-            'terminal',
-            'image',
-            'sort',
-            'link',
-            'status',
-        ]);
-        
-        return true;
-    }
-    
-    static function status($params, $shop_id)
-    {
-        $where = [
-            [ 'id', '=', $params['id'] ],
-            [ 'shop_id', '=', $shop_id ],
-        ];
-    
-        ShopAd::update($params, $where, [ 'status' ]);
-        
-        return true;
-    }
-    
-    static function delete($params, $shop_id)
-    {
-        ShopAd::destroy(function ($query) use ($params, $shop_id) {
-            $query->where('shop_id', $shop_id)->where('id', $params['id']);
-        });
-        
-        return true;
-    }
-    
-}

+ 0 - 113
app/shop/logic/distribution/CenterLogic.php

@@ -1,113 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +------------------------------------------------------------------------
-
-namespace app\shop\logic\distribution;
-
-use app\common\basics\Logic;
-use app\common\model\distribution\DistributionOrderGoods;
-
-class CenterLogic extends Logic
-{
-    /**
-     * @notes 分销概况
-     * @author Tab
-     * @date 2021/9/3 15:55
-     */
-    public static function center($shopId)
-    {
-        // 佣金数据
-        $earnings = self::earnings($shopId);
-        // 排行榜
-        $top = self::top($shopId);
-
-        return [
-            'earnings' => $earnings,
-            'top' => $top,
-        ];
-    }
-
-    /**
-     * @notes 分销商品排行榜
-     * @param $shopId
-     * @return mixed
-     * @author Tab
-     * @date 2021/9/3 16:07
-     */
-    public static function top($shopId)
-    {
-        $field = [
-            'sum(dog.money)' => 'total_money',
-            'og.image' => 'goods_image',
-            'og.goods_name',
-        ];
-        $where = [
-            'dog.shop_id' => $shopId,
-            'dog.status' => 2, // 已入账
-        ];
-        $top = DistributionOrderGoods::alias('dog')
-            ->leftJoin('order_goods og', 'og.id = dog.order_goods_id')
-            ->field($field)
-            ->where($where)
-            ->group('dog.money,og.image,og.goods_name')
-            ->order('total_money', 'desc')
-            ->limit(10)
-            ->select()
-            ->toArray();
-
-        return $top;
-    }
-
-    /**
-     * @notes 佣金数据
-     * @param $shopId
-     * @return array
-     * @author Tab
-     * @date 2021/9/3 16:13
-     */
-    public static function earnings($shopId)
-    {
-        // 累计已入账佣金
-        $totalSuccess = DistributionOrderGoods::where([
-            'shop_id' => $shopId,
-            'status' => 2,
-        ])->sum('money');
-        // 今日已入账佣金
-        $totalTodaySuccess = DistributionOrderGoods::where([
-            'shop_id' => $shopId,
-            'status' => 2,
-        ])->whereDay('settlement_time')->sum('money');
-        // 累计待结算佣金
-        $totalWait = DistributionOrderGoods::where([
-            'shop_id' => $shopId,
-            'status' => 1,
-        ])->sum('money');
-        // 今日待结算佣金
-        $totalTodayWait = DistributionOrderGoods::where([
-            'shop_id' => $shopId,
-            'status' => 1,
-        ])->whereDay('create_time')->sum('money');
-
-        return [
-            'total_success' => $totalSuccess,
-            'total_today_success' => $totalTodaySuccess,
-            'total_wait' => $totalWait,
-            'total_today_wait' => $totalTodayWait,
-        ];
-    }
-}

+ 0 - 346
app/shop/logic/distribution/GoodsLogic.php

@@ -1,346 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +------------------------------------------------------------------------
-
-namespace app\shop\logic\distribution;
-
-use app\common\basics\Logic;
-use app\common\model\distribution\DistributionGoods;
-use app\common\model\distribution\DistributionLevel;
-use app\common\model\goods\Goods;
-use app\common\model\shop\Shop;
-use app\common\server\ConfigServer;
-use think\facade\Db;
-
-class GoodsLogic extends Logic
-{
-    /**
-     * @notes 分销商品列表
-     * @param $params
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author Tab
-     * @date 2021/9/1 18:02
-     */
-    public static function lists($params)
-    {
-        $where = [
-            ['del', '<>', '1'],
-            ['shop_id', '=', $params['shop_id']]
-        ];
-        // 商品信息
-        if (isset($params['keyword']) && !empty($params['keyword'])) {
-            $where[] = ['name|code', 'like', '%'. $params['keyword']. '%'];
-        }
-        // 平台商品分类
-        if (isset($params['platform_cate_id']) && $params['platform_cate_id'] != 'all') {
-            $where[] = ['first_cate_id|second_cate_id|third_cate_id', '=', $params['platform_cate_id']];
-        }
-        // 商家商品分类
-        if (isset($params['shop_cate_id']) && $params['shop_cate_id'] != 'all') {
-            $where[] = ['shop_cate_id', '=', $params['shop_cate_id']];
-        }
-
-        $field = [
-            'id',
-            'code',
-            'name',
-            'image',
-            'max_price',
-            'min_price',
-            'id' => 'distribution_flag',
-        ];
-        $lists = Goods::field($field)
-            ->where($where)
-            ->withSearch('is_distribution', $params)
-            ->page($params['page'], $params['limit'])
-            ->order('id', 'desc')
-            ->select()
-            ->toArray();
-        $count = Goods::field($field)
-            ->where($where)
-            ->withSearch('is_distribution', $params)
-            ->count();
-
-        return [
-            'count' => $count,
-            'lists' => $lists
-        ];
-    }
-
-    /**
-     * @notes 商品详情
-     * @param $params
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author Tab
-     * @date 2021/9/1 19:59
-     */
-    public static function detail($params)
-    {
-        // 商品信息
-        $goods = Goods::field('id,code,name')->with('goods_item')->findOrEmpty($params['id'])->toArray();
-        // 分销等级信息
-        $distributionLevelLists = DistributionLevel::order('weights', 'asc')->select()->toArray();
-        // 商品分销信息
-        $distributionGoods = DistributionGoods::where('goods_id', $params['id'])->select()->toArray();
-        if(empty($distributionGoods)) {
-            // 未参与分销
-            $goods['is_distribution'] = 0;
-            $goods['rule'] = 1;
-            $ratio = self::formatLevel($distributionLevelLists, $goods);
-        } else {
-            $goods['is_distribution'] = $distributionGoods[0]['is_distribution'];
-            $goods['rule'] = $distributionGoods[0]['rule'];
-            if($distributionGoods[0]['rule'] == 1) {
-                $ratio = self::formatLevel($distributionLevelLists, $goods);
-            } else {
-                $ratio = self::formatGoods($distributionLevelLists, $goods);
-            }
-        }
-
-        return [
-            'goods' => $goods,
-            'ratio' => $ratio
-        ];
-    }
-
-    /**
-     * @notes 拼装分销等级佣金比例
-     * @param $distributionLevelLists
-     * @param $goods
-     * @return array
-     * @author Tab
-     * @date 2021/9/1 19:44
-     */
-    public static function formatLevel($distributionLevelLists, $goods)
-    {
-        $ratio = [];
-        foreach($distributionLevelLists as $level) {
-            foreach($goods['goods_item'] as $item) {
-                $temp = [
-                    'level_id' => $level['id'],
-                    'level_name' => $level['name'],
-                    'first_ratio' => $level['first_ratio'],
-                    'second_ratio' => $level['second_ratio'],
-                    'goods_id' => $item['goods_id'],
-                    'item_id' => $item['id'],
-                    'spec_value_str' => $item['spec_value_str'],
-                    'price' => $item['price']
-                ];
-                $ratio[] = $temp;
-            }
-        }
-        return $ratio;
-    }
-
-    /**
-     * @notes 拼装单独设置的佣金比例
-     * @param $distributionLevelLists
-     * @param $goods
-     * @param $distributionGoods
-     * @return array
-     * @author Tab
-     * @date 2021/9/2 9:28
-     */
-    public static function formatGoods($distributionLevelLists, $goods)
-    {
-        $ratio = [];
-        foreach($distributionLevelLists as $level) {
-            foreach($goods['goods_item'] as $item) {
-                $record = DistributionGoods::where([
-                    'level_id' => $level['id'],
-                    'item_id' =>  $item['id'],
-                ])->findOrEmpty()->toArray();
-                $temp = [
-                    'level_id' => $level['id'],
-                    'level_name' => $level['name'],
-                    'first_ratio' => $record['first_ratio'] ?? 0,
-                    'second_ratio' => $record['second_ratio'] ?? 0,
-                    'goods_id' => $item['goods_id'],
-                    'item_id' => $item['id'],
-                    'spec_value_str' => $item['spec_value_str'],
-                    'price' => $item['price']
-                ];
-                $ratio[] = $temp;
-            }
-        }
-        return $ratio;
-    }
-
-    /**
-     * @notes 设置佣金
-     * @param $params
-     * @return bool
-     * @author Tab
-     * @date 2021/9/1 20:52
-     */
-    public static function set($params)
-    {
-        Db::startTrans();
-        try {
-            if (false === self::ableDistribution($params['shop_id'])) {
-                throw new \Exception('平台已关闭分销功能');
-            }
-
-            switch($params['rule']) {
-                // 根据分销会员等级比例分佣
-                case 1:
-                    self::setRuleOne($params);
-                    break;
-
-                // 单独设置
-                case 2:
-                    self::setRuleTwo($params);
-                    break;
-            }
-
-            Db::commit();
-            return true;
-        }catch(\Exception $e) {
-            Db::rollback();
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-    /**
-     * @notes 设置佣金 - 根据分销会员等级比例分佣
-     * @param $params
-     * @author Tab
-     * @date 2021/9/1 21:04
-     */
-    public static function setRuleOne($params)
-    {
-        // 删除旧数据
-        $deleteIds = DistributionGoods::where('goods_id', $params['id'])->column('id');
-        DistributionGoods::destroy($deleteIds);
-
-        // 生成新数据
-        $data = [
-            'shop_id' => $params['shop_id'],
-            'goods_id' => $params['id'],
-            'is_distribution' => $params['is_distribution'],
-            'rule' => $params['rule'],
-        ];
-        DistributionGoods::create($data);
-    }
-
-    /**
-     * @notes 设置佣金 - 单独自定义
-     * @param $params
-     * @throws \Exception
-     * @author Tab
-     * @date 2021/9/1 21:04
-     */
-    public static function setRuleTwo($params)
-    {
-        // 删除旧数据
-        $deleteIds = DistributionGoods::where('goods_id', $params['id'])->column('id');
-        DistributionGoods::destroy($deleteIds);
-
-        // 生成新数据
-        $data= [];
-        foreach($params['first_ratio'] as $k => $v) {
-            if ($params['first_ratio'][$k] < 0 || $params['second_ratio'][$k] < 0) {
-                throw new \Exception('分销比例不能小于0');
-            }
-            $temp = [
-                'shop_id' => $params['shop_id'],
-                'goods_id' => $params['id'],
-                'item_id' => $params['items'][$k],
-                'level_id' => $params['levels'][$k],
-                'first_ratio' => !empty($params['first_ratio'][$k]) ? round($params['first_ratio'][$k], 2) : 0,
-                'second_ratio' => !empty($params['second_ratio'][$k]) ? round($params['second_ratio'][$k], 2) : 0,
-                'is_distribution' => $params['is_distribution'],
-                'rule' => $params['rule'],
-            ];
-            $data[] = $temp;
-        }
-        (new DistributionGoods())->saveAll($data);
-    }
-
-    /**
-     * @notes 参与分销/取消分销
-     * @param $params
-     * @return bool
-     * @author Tab
-     * @date 2021/9/2 10:11
-     */
-    public static function isDistribution($params)
-    {
-        Db::startTrans();
-        try{
-            if (false === self::ableDistribution($params['shop_id'])) {
-                throw new \Exception('平台已关闭分销功能');
-            }
-
-            $existedIds = DistributionGoods::distinct(true)->column('goods_id');
-            $updateIds = array_intersect($params['ids'], $existedIds);
-            $insertIds = array_diff($params['ids'], $existedIds);
-
-            // 有分销数据,直接修改
-            DistributionGoods::where('goods_id', 'in', $updateIds)->update(['is_distribution' => $params['is_distribution']]);
-
-            // 无分销数据,新增
-            $insertData = [];
-            foreach($insertIds as $id) {
-                $item['goods_id'] = $id;
-                $item['is_distribution'] = $params['is_distribution'];
-                $item['rule'] = 1;
-                $item['shop_id'] = $params['shop_id'];
-                $insertData[] = $item;
-            }
-
-            (new DistributionGoods())->saveAll($insertData);
-
-            Db::commit();
-            return true;
-        }catch(\Exception $e) {
-            Db::rollback();
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-
-    /**
-     * @notes 能否参与分销
-     * @param $shopId
-     * @return bool
-     * @author 段誉
-     * @date 2022/8/1 16:04
-     */
-    public static function ableDistribution($shopId)
-    {
-        // 平台分销功能开关
-        $open = ConfigServer::get('distribution', 'is_open', 0);
-        // 商家信息-获取商家是否被禁用分销功能(is_distribution)
-        $shop = Shop::findOrEmpty($shopId)->toArray();
-
-        if (!$open || !$shop['is_distribution']) {
-            return false;
-        }
-        return true;
-    }
-
-}

+ 0 - 114
app/shop/logic/distribution/OrderLogic.php

@@ -1,114 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +------------------------------------------------------------------------
-
-namespace app\shop\logic\distribution;
-
-use app\common\basics\Logic;
-use app\common\model\distribution\DistributionLevel;
-use app\common\model\distribution\DistributionOrderGoods;
-use app\common\model\user\User;
-use app\common\server\UrlServer;
-
-class OrderLogic extends Logic
-{
-    /**
-     * @notes 分销订单列表
-     * @param $params
-     * @return int[]
-     * @author Tab
-     * @date 2021/9/3 14:53
-     */
-    public static function lists($params)
-    {
-        $where[] = ['dog.shop_id', '=', $params['shop_id']];
-        // 订单信息
-        if (isset($params['order_keyword']) && !empty($params['order_keyword'])) {
-            $where[] = ['o.order_sn', '=', $params['order_keyword']];
-        }
-        // 商品名称
-        if (isset($params['goods_keyword']) && !empty($params['goods_keyword'])) {
-            $where[] = ['og.goods_name', 'like', '%'.$params['goods_keyword'].'%'];
-        }
-        // 分销会员
-        if (isset($params['distribution_keyword']) && !empty($params['distribution_keyword'])) {
-            $where[] = ['u.sn|u.nickname', 'like', '%'.$params['distribution_keyword'].'%'];
-        }
-        // 佣金状态
-        if (isset($params['status']) && !empty($params['status'])) {
-            $where[] = ['dog.status', '=', $params['status']];
-        }
-
-        $field = [
-            'o.id' => 'order_id',
-            'o.order_sn',
-            'o.create_time' => 'order_create_time',
-            'o.user_id' => 'order_user_id',
-            'u.id' => 'distribution_user_id',
-            'u.avatar' => 'distribution_avatar',
-            'u.sn' => 'distribution_sn',
-            'u.nickname' => 'distribution_nickname',
-            'og.image' => 'goods_image',
-            'og.goods_name' => 'goods_name',
-            'og.spec_value' => 'spec_value',
-            'og.goods_num' => 'goods_num',
-            'og.total_pay_price' => 'total_pay_price',
-            'dog.level_id',
-            'dog.level',
-            'dog.ratio',
-            'dog.money',
-            'dog.status' => 'status_desc',
-            'dog.settlement_time'
-        ];
-
-        $lists = DistributionOrderGoods::alias('dog')
-            ->leftJoin('order o', 'o.id = dog.order_id')
-            ->leftJoin('user u', 'u.id = dog.user_id')
-            ->leftJoin('order_goods og', 'og.id = dog.order_goods_id')
-            ->leftJoin('distribution_level dl', 'dl.id = dog.level_id')
-            ->field($field)
-            ->where($where)
-            ->order('dog.id', 'desc')
-            ->page($params['page'], $params['limit'])
-            ->select()
-            ->toArray();
-
-        $count = DistributionOrderGoods::alias('dog')
-            ->leftJoin('order o', 'o.id = dog.order_id')
-            ->leftJoin('user u', 'u.id = dog.user_id')
-            ->leftJoin('order_goods og', 'og.id = dog.order_goods_id')
-            ->leftJoin('distribution_level dl', 'dl.id = dog.level_id')
-            ->field($field)
-            ->where($where)
-            ->count();
-
-        foreach($lists as &$item) {
-            $item['order_create_time'] = date('Y-m-d H:i:s', $item['order_create_time']);
-            $item['user_info'] = User::getUserInfo($item['order_user_id']);
-            $item['distribution_avatar'] = empty($item['distribution_avatar']) ? '' : UrlServer::getFileUrl($item['distribution_avatar']);
-            $item['user_info']['avatar'] = empty($item['user_info']['avatar']) ? '' : UrlServer::getFileUrl($item['user_info']['avatar']);
-            $item['level_name'] = DistributionLevel::getLevelName($item['level_id']);
-            $item['goods_image'] = empty($item['goods_image']) ? '' : UrlServer::getFileUrl($item['goods_image']);
-        }
-
-        return [
-            'count' => $count,
-            'lists' => $lists
-        ];
-    }
-}

+ 0 - 86
app/shop/logic/distribution/RecordLogic.php

@@ -1,86 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-namespace app\shop\logic\distribution;
-
-use app\common\basics\Logic;
-use app\common\model\distribution\DistributionOrderGoods;
-
-class RecordLogic extends Logic
-{
-    public static function lists($get)
-    {
-        $where = [
-            ['dog.shop_id', '=', $get['shop_id']]
-        ];
-        // 搜索
-        if(!empty($get['keyword'])) {
-            $fieldDesc = '';
-            switch($get['keyword_type']) {
-                case 'order_sn':
-                    $fieldDesc = 'o.order_sn';
-                    break;
-                case 'user_nickname':
-                    $fieldDesc = 'u.nickname';
-                    break;
-                case 'user_sn':
-                    $fieldDesc = 'u.sn';
-                    break;
-                case 'user_mobile':
-                    $fieldDesc = 'u.mobile';
-                    break;
-            }
-            $where[] = [$fieldDesc, '=', trim($get['keyword'])];
-        }
-        // 佣金状态
-        if(!empty($get['status'])) {
-            $where[] = ['dog.status', '=', $get['status']];
-        }
-        // 记录时间
-        if(!empty($get['start_time'])) {
-            $where[] = ['dog.create_time', '>=', strtotime($get['start_time'])];
-        }
-        if(!empty($get['end_time'])) {
-            $where[] = ['dog.create_time', '<=', strtotime($get['end_time'])];
-        }
-        $lists = DistributionOrderGoods::alias('dog')
-            ->field('dog.money, dog.status as status_desc,dog.create_time as distribution_create_time,u.nickname as user_nickname,u.sn as user_sn,u.mobile as user_mobile,og.total_pay_price,o.order_sn')
-            ->leftJoin('user u', 'u.id=dog.user_id')
-            ->leftJoin('order_goods og', 'og.id=dog.order_goods_id')
-            ->leftJoin('order o', 'o.id=og.order_id')
-            ->where($where)
-            ->order('dog.create_time', 'desc')
-            ->page($get['page'], $get['limit'])
-            ->select()
-            ->toArray();
-
-        $count = DistributionOrderGoods::alias('dog')
-            ->field('dog.money, dog.status as status_desc,dog.create_time as distribution_create_time,u.nickname as user_nickname,u.sn as user_sn,u.mobile as user_mobile,og.total_pay_price,o.order_sn')
-            ->leftJoin('user u', 'u.id=dog.user_id')
-            ->leftJoin('order_goods og', 'og.id=dog.order_goods_id')
-            ->leftJoin('order o', 'o.id=og.order_id')
-            ->where($where)
-            ->count();
-
-        return [
-            'count' => $count,
-            'lists' => $lists
-        ];
-    }
-}

+ 0 - 302
app/shop/logic/express_assistant/FaceSheetOrderLogic.php

@@ -1,302 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop100%开源免费商用商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | 开源版本可自由商用,可去除界面版权logo
-// | 商业版本务必购买商业授权,以免引起法律纠纷
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop团队 版权所有 拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshopTeam
-// +----------------------------------------------------------------------
-
-namespace app\shop\logic\express_assistant;
-
-
-use app\api\controller\Team;
-use app\common\basics\Logic;
-use app\common\enum\NoticeEnum;
-use app\common\enum\OrderEnum;
-use app\common\enum\OrderLogEnum;
-use app\common\enum\PayEnum;
-use app\common\enum\TeamEnum;
-use app\common\logic\OrderLogLogic;
-use app\common\model\Delivery;
-use app\common\model\goods\GoodsItem;
-use app\common\model\order\Order;
-use app\common\model\face_sheet\FaceSheetSender;
-use app\common\model\face_sheet\FaceSheetTemplate;
-use app\common\model\Express;
-use app\common\model\order\OrderGoods;
-use app\common\model\team\TeamJoin;
-use app\common\model\user\User;
-use app\common\server\AreaServer;
-use app\common\server\printing\Kuaidi100;
-use app\common\server\UrlServer;
-use think\facade\Db;
-
-/**
- * 电子面单订单打印
- * Class FaceSheetOrderLogic
- * @package app\shop\logic\express_assistant
- */
-class FaceSheetOrderLogic extends Logic
-{
-
-    /**
-     * @notes 获取待发货订单列表
-     * @param $get
-     * @param $shop_id
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2023/2/13 17:32
-     */
-    public static function lists($get, $shop_id)
-    {
-        $where = [
-            ['O.order_status', '=', OrderEnum::ORDER_STATUS_DELIVERY],
-            ['O.pay_status', '=', PayEnum::ISPAID],
-            ['O.delivery_type', '=', OrderEnum::DELIVERY_TYPE_EXPRESS],
-            ['O.shop_id', '=', $shop_id],
-        ];
-
-        if (!empty($get['keyword_type']) and !empty($get['keyword'])) {
-            switch ($get['keyword_type']) {
-                case 'order_sn':
-                    $where[] = ['O.order_sn', '=', $get['keyword']];
-                    break;
-                case 'user_sn':
-                    $where[] = ['U.sn', 'like', '%' . $get['keyword'] . '%'];
-                    break;
-                case 'nickname':
-                    $where[] = ['U.nickname', 'like', '%' . $get['keyword'] . '%'];
-                    break;
-                case 'consignee':
-                    $where[] = ['O.consignee', 'like', '%' . $get['keyword'] . '%'];
-                    break;
-                case 'consignee_mobile':
-                    $where[] = ['O.mobile', '=', $get['keyword']];
-                    break;
-            }
-        }
-
-        if (!empty($get['goods_name']) and $get['goods_name']) {
-            $where[] = ['OG.goods_name', 'like', '%' . $get['goods_name'] . '%'];
-        }
-
-        if (!empty($get['start_time']) and $get['start_time']) {
-            $where[] = ['O.create_time', '>=', strtotime($get['start_time'])];
-        }
-
-        if (!empty($get['end_time']) and $get['end_time']) {
-            $where[] = ['O.create_time', '<=', strtotime($get['end_time'])];
-        }
-
-        // 排除未拼团成功订单
-        $exclude = TeamJoin::where('status', '<>', TeamEnum::TEAM_STATUS_SUCCESS)->column('order_id');
-        $exclude = array_unique($exclude);
-        
-        $count = Order::where($where)->alias('O')
-            ->join('user U', 'U.id = O.user_id')
-            ->join('orderGoods OG', 'OG.order_id = O.id')
-            ->leftJoin('team_join TJ', "TJ.order_id = O.id and TJ.status = " . TeamEnum::TEAM_STATUS_SUCCESS)
-            ->whereNotIn('O.id', $exclude)
-            ->count('O.id');
-
-        $lists = Order::alias('O')
-            ->field(
-                'O.id,O.user_id,O.order_type,O.order_sn,O.order_status,O.total_num,
-                O.order_amount,O.delivery_type,O.consignee,O.mobile,O.province,O.city,O.district,
-                O.address,O.create_time,TJ.status as team_join_status'
-            )
-            ->where($where)
-            ->whereNotIn('O.id', $exclude)
-            ->join('user U', 'U.id = O.user_id')
-            ->join('orderGoods OG', 'OG.order_id = O.id')
-            ->leftJoin('team_join TJ', "TJ.order_id = O.id and TJ.status = " . TeamEnum::TEAM_STATUS_SUCCESS)
-            ->order(['O.id' => 'desc'])
-            ->page($get['page'], $get['limit'])
-            ->select();
-
-        foreach ($lists as &$item) {
-            $user = User::field('nickname,sn')->where(['id' => $item['user_id']])->find();
-            $item['user'] = $user['nickname'];
-
-            $item['order_type'] = Order::getOrderType($item['order_type']);
-            $item['order_status'] = Order::getOrderStatus($item['order_status']);
-            $item['delivery_type'] = Order::getDeliveryType($item['delivery_type']);
-            $item['address'] = AreaServer::getAddress([$item['province'], $item['city'], $item['district']], $item['address']);
-
-            $orderGoods = OrderGoods::where(['order_id' => $item['id']])->select();
-
-            $orderGoodsData = [];
-            foreach ($orderGoods as $og) {
-                $orderGoodsData[] = [
-                    'id' => $og['id'],
-                    'goods_price' => $og['goods_price'],
-                    'goods_num' => $og['goods_num'],
-                    'goods_name' => $og['goods_name'],
-                    'spec_value_str' => $og['spec_value'],
-                    'image' => UrlServer::getFileUrl($og['image']),
-                ];
-            }
-            $item['orderGoods'] = $orderGoodsData;
-        }
-
-        return ['count' => $count, 'lists' => $lists];
-    }
-
-
-    /**
-     * @notes 打印
-     * @param $params
-     * @return bool
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2023/2/13 18:46
-     */
-    public static function print($params)
-    {
-        $template = FaceSheetTemplate::findOrEmpty($params['template_id'])->toArray();
-        $sender = FaceSheetSender::findOrEmpty($params['sender_id'])->toArray();
-        $express = Express::findOrEmpty($template['express_id'])->toArray();
-        $order = Order::with('orderGoods')
-            ->where('shop_id', $params['shop_id'])
-            ->where('id', $params['order_id'])
-            ->findOrEmpty()
-            ->toArray();
-
-        $result = self::singlePrint($order, $template, $sender, $express, $params['admin_id'], $params['shop_id']);
-        if ($result !== true) {
-            // 打印电子面单出错,中断打印
-            self::$error = '订单' . $order['order_sn'] . '打印出错:' . $result;
-            return false;
-        }
-
-        return true;
-    }
-
-
-    /**
-     * @notes 打印
-     * @param $order
-     * @param $template
-     * @param $sender
-     * @param $express
-     * @param $admin_id
-     * @return bool|string
-     * @author 段誉
-     * @date 2023/2/13 18:46
-     */
-    public static function singlePrint($order, $template, $sender, $express, $admin_id, $shop_id)
-    {
-        Db::startTrans();
-        try {
-            $goodsName = '';
-            $totalWeight = 0;
-            foreach($order['orderGoods'] as $item) {
-                if (empty($item['weight'])) {
-                    $item['weight'] = GoodsItem::where('id', $item['item_id'])->value('weight');
-                }
-                $totalWeight += $item['weight'];
-                $goodsName .= $item['goods_name'] . ' (' . $item['spec_value'] . $item['goods_num'] . '件)\n';
-            }
-
-            // 打印电子面单
-            $result = (new Kuaidi100($shop_id))->print([
-                'order'         => $order,
-                'template'      => $template,
-                'sender'        => $sender,
-                'express'       => $express,
-                'total_weight'   => round($totalWeight, 2),
-                'remark'        => $goodsName,
-            ]);
-
-            // 添加发货记录
-            self::orderDelivery($result, $order, $express, $admin_id);
-
-            Db::commit();
-            return true;
-        } catch (\Exception $e) {
-            Db::rollback();
-            return $e->getMessage();
-        }
-    }
-
-
-    /**
-     * @notes 发货
-     * @param $print
-     * @param $order
-     * @param $express
-     * @param $admin_id
-     * @author 段誉
-     * @date 2023/2/13 18:44
-     */
-    public static function orderDelivery($print, $order, $express, $admin_id)
-    {
-        //添加发货单
-        $delivery_id = (new Delivery())->insertGetId([
-            'order_id' => $order['id'],
-            'order_sn' => $order['order_sn'],
-            'user_id' => $order['user_id'],
-            'admin_id' => $admin_id,
-            'consignee' => $order['consignee'],
-            'mobile' => $order['mobile'],
-            'province' => $order['province'],
-            'city' => $order['city'],
-            'district' => $order['district'],
-            'address' => $order['address'],
-            'invoice_no' => $print['data']['kuaidinum'],
-            'send_type' => 1,
-            'shipping_id' => $express['id'],
-            'shipping_name' => $express['name'],
-            'shipping_status' => 1,
-            'create_time' => time(),
-        ]);
-
-        //更新订单下商品的发货状态
-        Order::where('id', $order['id'])->update([
-            'order_status' => Order::STATUS_WAIT_RECEIVE,
-            'delivery_id' => $delivery_id,
-            'shipping_status' => 1,
-            'update_time'     => time(),
-            'shipping_time' => time(),
-        ]);
-
-        //订单日志
-        OrderLogLogic::record(
-            OrderLogEnum::TYPE_SHOP,
-            OrderLogEnum::SHOP_DELIVERY_ORDER,
-            $order['id'],
-            $admin_id,
-            OrderLogEnum::SHOP_DELIVERY_ORDER
-        );
-
-        //通知用户发货
-        if (!empty($order['mobile'])) {
-            event('Notice', [
-                'scene' => NoticeEnum::ORDER_DELIVERY_NOTICE,
-                'mobile' => $order['mobile'],
-                'params' => [
-                    'order_id' => $order['id'],
-                    'user_id' => $order['user_id'],
-                    'shipping_name' => $express['name'],
-                    'invoice_no' => $print['data']['kuaidinum'],
-                ]
-            ]);
-        }
-    }
-}

+ 0 - 180
app/shop/logic/express_assistant/FaceSheetSenderLogic.php

@@ -1,180 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop100%开源免费商用商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | 开源版本可自由商用,可去除界面版权logo
-// | 商业版本务必购买商业授权,以免引起法律纠纷
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop团队 版权所有 拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshopTeam
-// +----------------------------------------------------------------------
-
-namespace app\shop\logic\express_assistant;
-
-
-use app\common\basics\Logic;
-use app\common\model\face_sheet\FaceSheetSender;
-use app\common\server\AreaServer;
-use Exception;
-
-/**
- * 发件人模板
- * Class FaceSheetSenderLogic
- * @package app\shop\logic\express_assistant
- */
-class FaceSheetSenderLogic extends Logic
-{
-
-    /**
-     * @notes 获取发件人列表
-     * @param $get
-     * @param $shop_id
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2023/2/13 16:41
-     */
-    public static function lists($get, $shop_id)
-    {
-        $where = ['shop_id' => $shop_id];
-        $model = new FaceSheetSender();
-        $count = $model->where($where)->count('id');
-        $lists = $model->where($where)->order('id', 'desc')
-            ->page($get['page'], $get['limit'])
-            ->select();
-
-        foreach ($lists as &$item) {
-            $item['region'] = AreaServer::getAddress([
-                $item['province_id'],
-                $item['city_id'],
-                $item['district_id'],
-            ]);
-        }
-
-        return ['count' => $count, 'lists' => $lists];
-    }
-
-
-    /**
-     * @notes 所有发件人模板
-     * @param $shop_id
-     * @return \think\Collection
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2023/2/13 16:41
-     */
-    public static function allSender($shop_id)
-    {
-        $model = new FaceSheetSender();
-        return $model->where(['shop_id' => $shop_id])
-            ->order('id', 'desc')
-            ->select();
-    }
-
-
-    /**
-     * @notes 获取发件人模板详细
-     * @param $id
-     * @param $shop_id
-     * @return array|\think\Model|null
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2023/2/13 16:40
-     */
-    public static function detail($id, $shop_id)
-    {
-        return FaceSheetSender::where(['id'=>$id, 'shop_id' => $shop_id])->find();
-    }
-
-
-    /**
-     * @notes 新增发件人模板
-     * @param $post
-     * @param $shop_id
-     * @return bool|string
-     * @author 段誉
-     * @date 2023/2/13 16:40
-     */
-    public static function add($post, $shop_id)
-    {
-        try {
-            FaceSheetSender::create([
-                'shop_id'     => $shop_id,
-                'name'        => $post['name'],
-                'mobile'      => $post['mobile'],
-                'province_id' => $post['province_id'],
-                'city_id'     => $post['city_id'],
-                'district_id' => $post['district_id'],
-                'address'     => $post['address'],
-                'create_time' => time(),
-                'update_time' => time(),
-            ]);
-
-            return true;
-        } catch (Exception $e) {
-            return $e->getMessage();
-        }
-    }
-
-
-    /**
-     * @notes 编辑发件人模板
-     * @param $post
-     * @param $shop_id
-     * @return bool|string
-     * @author 段誉
-     * @date 2023/2/13 16:40
-     */
-    public static function edit($post, $shop_id)
-    {
-        try {
-            FaceSheetSender::update([
-                'name'        => $post['name'],
-                'mobile'      => $post['mobile'],
-                'province_id' => $post['province_id'],
-                'city_id'     => $post['city_id'],
-                'district_id' => $post['district_id'],
-                'address'     => $post['address'],
-                'update_time' => time(),
-            ], ['id'=>$post['id'], 'shop_id' => $shop_id]);
-
-            return true;
-        } catch (Exception $e) {
-            return $e->getMessage();
-        }
-    }
-
-
-    /**
-     * @notes 删除发件人模板
-     * @param $id
-     * @param $shop_id
-     * @return bool|string
-     * @author 段誉
-     * @date 2023/2/13 16:40\
-     */
-    public static function del($id, $shop_id)
-    {
-        try {
-            FaceSheetSender::where(['shop_id' => $shop_id, 'id' => $id])
-                ->delete();
-            return true;
-        } catch (Exception $e) {
-            return $e->getMessage();
-        }
-    }
-}

+ 0 - 192
app/shop/logic/express_assistant/FaceSheetTplLogic.php

@@ -1,192 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop100%开源免费商用商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | 开源版本可自由商用,可去除界面版权logo
-// | 商业版本务必购买商业授权,以免引起法律纠纷
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop团队 版权所有 拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshopTeam
-// +----------------------------------------------------------------------
-
-namespace app\shop\logic\express_assistant;
-
-
-use app\common\basics\Logic;
-use app\common\model\Express;
-use app\common\model\face_sheet\FaceSheetTemplate;
-use Exception;
-
-/**
- * 面单模板
- * Class FaceSheetTplLogic
- * @package app\shop\logic\express_assistant
- */
-class FaceSheetTplLogic extends Logic
-{
-
-    /**
-     * @notes 获取电子面单模板列表
-     * @param $get
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2023/2/13 15:29
-     */
-    public static function lists($get, $shop_id)
-    {
-        $where = ['shop_id' => $shop_id];
-        $model = new FaceSheetTemplate();
-        $count = $model->where($where)->count('id');
-        $lists = $model->order('id', 'desc')
-            ->where($where)
-            ->page($get['page'], $get['limit'])
-            ->select();
-
-        foreach ($lists as &$item) {
-            $item['express'] = Express::where(['id'=>$item['express_id']])->value('name') ?? '未知';
-        }
-
-        return ['count' => $count, 'lists' => $lists];
-    }
-
-
-    /**
-     * @notes 获取电子面单模板详细
-     * @param $id
-     * @param $shop_id
-     * @return array|\think\Model|null
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2023/2/13 15:34
-     */
-    public static function detail($id, $shop_id)
-    {
-        return FaceSheetTemplate::where(['id' => intval($id), 'shop_id' => $shop_id])->find();
-    }
-
-
-    /**
-     * @notes 新增电子面单模板
-     * @param $post
-     * @param $shop_id
-     * @return bool|string
-     * @author 段誉
-     * @date 2023/2/13 15:31
-     */
-    public static function add($post, $shop_id)
-    {
-        try {
-            FaceSheetTemplate::create([
-                'shop_id'     => $shop_id,
-                'express_id'  => $post['express_id'],
-                'name'        => $post['name'],
-                'template_id' => $post['template_id'],
-                'partner_id'  => $post['partner_id'],
-                'partner_key' => $post['partner_key'],
-                'net'         => $post['net'],
-                'pay_type'    => $post['pay_type'],
-                'create_time' => time(),
-                'update_time' => time()
-            ]);
-
-            return true;
-        } catch (Exception $e) {
-            return $e->getMessage();
-        }
-    }
-
-
-    /**
-     * @notes 编辑电子面单模板
-     * @param $post
-     * @return bool|string
-     * @author 段誉
-     * @date 2023/2/13 15:32
-     */
-    public static function edit($post, $shop_id)
-    {
-        try {
-            FaceSheetTemplate::update([
-                'express_id'  => $post['express_id'],
-                'name'        => $post['name'],
-                'template_id' => $post['template_id'],
-                'partner_id'  => $post['partner_id'],
-                'partner_key' => $post['partner_key'],
-                'net'         => $post['net'],
-                'pay_type'    => $post['pay_type'],
-                'update_time' => time()
-            ], ['id' => $post['id'], 'shop_id' => $shop_id]);
-
-            return true;
-        } catch (Exception $e) {
-            return $e->getMessage();
-        }
-    }
-
-
-    /**
-     * @notes 删除电子面单模板
-     * @param $id
-     * @param $shop_id
-     * @return bool|string
-     * @author 段誉
-     * @date 2023/2/13 15:32
-     */
-    public static function del($id, $shop_id)
-    {
-        try {
-            FaceSheetTemplate::where(['shop_id' => $shop_id, 'id' => $id])
-                ->delete();
-            return true;
-        } catch (Exception $e) {
-            return $e->getMessage();
-        }
-    }
-
-
-    /**
-     * @notes 快递公司
-     * @return \think\Collection
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2023/2/13 15:13
-     */
-    public static function allExpress()
-    {
-        return Express::where(['del' => 0])->select();
-    }
-
-
-    /**
-     * @notes 所有电子面单模板
-     * @return \think\Collection
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2023/2/13 16:02
-     */
-    public static function allTpl($shop_id)
-    {
-        $model = new FaceSheetTemplate();
-        return $model->where(['shop_id' => $shop_id])
-            ->order('id', 'desc')
-            ->select();
-    }
-
-}

+ 0 - 366
app/shop/logic/finance/SettlementLogic.php

@@ -1,366 +0,0 @@
-<?php
-
-
-namespace app\shop\logic\finance;
-
-
-use app\common\basics\Logic;
-use app\common\enum\OrderEnum;
-use app\common\enum\PayEnum;
-use app\common\model\AfterSale;
-use app\common\model\order\Order;
-use app\common\model\shop\Shop;
-use app\common\model\shop\ShopAccountLog;
-use app\common\model\shop\ShopSettlement;
-use app\common\model\shop\ShopSettlementRecord;
-use app\common\server\ConfigServer;
-use app\common\server\ExportExcelServer;
-use think\Exception;
-use think\facade\Db;
-
-class SettlementLogic extends Logic
-{
-    /**
-     * @Notes: 结算列表
-     * @Author: 张无忌
-     * @param $get
-     * @param $shop_id
-     * @return array
-     */
-    public static function lists($get, $shop_id, $is_export = false)
-    {
-        try {
-            $where[] = ['shop_id', '=', $shop_id];
-            if (!empty($get['start_time']) and $get['start_time'])
-                $where[] = ['start_time', '>=', strtotime($get['start_time'])];
-            if (!empty($get['end_time']) and $get['end_time'])
-                $where[] = ['end_time', '>=', strtotime($get['end_time'])];
-
-            // 导出Excel
-            if (true === $is_export) {
-                return self::export($where);
-            }
-
-            $model = new ShopSettlement();
-            $lists = $model->field(true)
-                ->where($where)
-                ->order('id', 'desc')
-                ->paginate([
-                    'page'      => $get['page'],
-                    'list_rows' => $get['limit'],
-                    'var_page' => 'page'
-                ])
-                ->toArray();
-
-            return ['count'=>$lists['total'], 'lists'=>$lists['data']];
-        } catch (\Exception $e) {
-            return ['error'=>$e->getMessage()];
-        }
-    }
-
-    /**
-     * @Notes: 结算详细
-     * @Author: 张无忌
-     * @param $get
-     * @return array
-     */
-    public static function detail($get)
-    {
-        try {
-            $where[] = ['settle_id', '=', (int)$get['settle_id']];
-            if (!empty($get['order_sn']) and $get['order_sn'])
-                $where[] = ['order_sn', 'like', '%'.$get['order_sn'].'%'];
-
-            $model = new ShopSettlementRecord();
-            $lists = $model->field(true)
-                ->where($where)
-                ->order('id', 'asc')
-                ->paginate([
-                    'page'      => $get['page'],
-                    'list_rows' => $get['limit'],
-                    'var_page' => 'page'
-                ])
-                ->toArray();
-
-            return ['count'=>$lists['total'], 'lists'=>$lists['data']];
-        } catch (\Exception $e) {
-            return ['error'=>$e->getMessage()];
-        }
-    }
-
-    /**
-     * @Notes: 提交结算
-     * @Author: 张无忌
-     * @param $shop_id
-     * @return bool
-     */
-    public static function add($shop_id)
-    {
-        Db::startTrans();
-        try {
-            // 1、获取售后时长时间搓
-            $time = time();
-            $afterSaleTime = ConfigServer::get('transaction', 'order_after_sale_days', 7);
-            $afterSaleTime = intval($afterSaleTime * 24 * 60 * 60);
-
-             // 2、查询所有可结算订单
-            $orders = (new Order())->field([
-                'id,order_sn,order_status,pay_status,refund_status,is_cancel',
-                'order_amount,refund_amount,distribution_money,confirm_take_time'
-                ])
-                ->whereRaw("confirm_take_time+$afterSaleTime < $time")
-                ->where([
-                    ['shop_id', '=', $shop_id],
-                    ['settle_id', '=', 0],
-                    ['order_status', '=', OrderEnum::ORDER_STATUS_COMPLETE],
-                    ['pay_status', '=', OrderEnum::PAY_STATUS_PAID],
-                    ['confirm_take_time', '>', 0]
-                ])->select()->toArray();
-
-            if (!$orders) throw new Exception('暂无可结算订单金额');
-
-            // 3、检测订单是否再售后
-            $afterSale = (new AfterSale())->whereIn('order_id', array_column($orders, 'id'))
-                ->whereIn('status', [
-                    AfterSale::STATUS_APPLY_REFUND,
-                    AfterSale::STATUS_WAIT_RETURN_GOODS,
-                    AfterSale::STATUS_WAIT_RECEIVE_GOODS,
-                    AfterSale::STATUS_WAIT_REFUND
-                ])->where('del', 0)->select()->toArray();
-
-            $afterSaleOrderIds = array_column($afterSale, 'order_id');
-            $afterSaleOrderIds = array_unique($afterSaleOrderIds);
-            if (!empty($afterSaleOrderIds)) {
-                $orderIds = array_column($orders, 'id');
-                if (count($orderIds) <= count($afterSaleOrderIds)) {
-                    throw new Exception('暂无可结算订单金额!');
-                }
-            }
-
-            // 4、生成结算批次记录
-            $settleSn = createSn('shop_settlement', 'settle_sn', 'JS');
-            $settle = ShopSettlement::create(['shop_id'=>$shop_id, 'settle_sn'=>$settleSn, 'create_time'=>$time,]);
-            $data = self::handleSettlementByOrder($orders, $settle, $time);
-
-            // 5、回调更新结算批次信息
-            ShopSettlement::update([
-                'deal_order_count'    => $data['dealOrderCount'],
-                'business_money'      => $data['businessMoney'] ,
-                'refund_order_money'  => $data['refundOrderMoney'],
-                'after_sales_money'   => $data['afterSalesMoney'],
-                'distribution_money'  => $data['distributionMoney'],
-                'entry_account_money' => $data['entryAccountMoney'],
-                'trade_service_fee'   => $data['totalTradeServiceFee'],
-                'trade_service_ratio' => $data['trade_service_ratio'],
-            ], ['id'=>$settle['id']]);
-
-            // 6、记录商家结算流水记录
-            $logType = ShopAccountLog::settlement_add_money;
-            ShopAccountLog::incData($shop_id, $logType, $data['entryAccountMoney'], -1, [
-                'source_id' => $settle['id'],
-                'source_sn' => $settleSn,
-                'remark'    => '商家对账结算'
-            ]);
-
-            // 7、把钱记录到商家钱包
-            Shop::update(['wallet'=>['inc', $data['entryAccountMoney']]], ['id'=>$shop_id]);
-
-            Db::commit();
-            return true;
-        } catch (\Exception $e) {
-            Db::rollback();
-            static::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-    /**
-     * @Notes: 对订单进行结算
-     * 实际入账金额 = (订单实付金额 - 分销金额 - 退款金额) * 交易服务费比例
-     * @Author: 张无忌
-     * @param $orders (订单列表数据)
-     * @param $settle (结算单信息)
-     * @param $time (当前时间戳)
-     * @return array
-     * @throws \Exception
-     */
-    private static function handleSettlementByOrder($orders, $settle, $time)
-    {
-        // 1、获取交易服务费比例
-        $tradeServiceRatio = (new Shop())->where(['id'=>$settle['shop_id']])->value('trade_service_fee') ?? 0;
-
-        // 2、结算数据汇总统计
-        $data = [
-            'dealOrderCount'       => 0, //总已结算成交订单数
-            'businessMoney'        => 0, //总已结算营业额
-            'refundOrderMoney'     => 0, //总退款订单金额
-            'afterSalesMoney'      => 0, //总售后退款金额
-            'distributionMoney'    => 0, //总已结算分销佣金金额
-            'entryAccountMoney'    => 0, //总已结算入账金额
-            'totalTradeServiceFee' => 0, //总交易服务费费用
-            'trade_service_ratio'  => $tradeServiceRatio //交易服务费比例(%)
-        ];
-
-        // 3、处理结算每个订单
-        $settle_record = [];
-        $orders_update = [];
-        foreach ($orders as $order) {
-            $afterSale = (new AfterSale())->where(['order_id'=>$order['id']])
-                ->whereIn('status', [
-                    AfterSale::STATUS_APPLY_REFUND,
-                    AfterSale::STATUS_WAIT_RETURN_GOODS,
-                    AfterSale::STATUS_WAIT_RECEIVE_GOODS,
-                    AfterSale::STATUS_WAIT_REFUND
-                ])->where('del',0)->findOrEmpty();
-
-            if (!$afterSale->isEmpty()) {
-                continue;
-            }
-
-            $data['dealOrderCount']    += 1;
-            $data['businessMoney']     += $order['order_amount'];
-            $data['refundOrderMoney']  += $order['is_cancel'] ? $order['refund_amount'] : 0;
-            $data['afterSalesMoney']   += $order['is_cancel'] ? 0 : $order['refund_amount'];
-            $data['distributionMoney'] += $order['distribution_money'];
-
-            $orderMoney      = $order['order_amount'] - $order['distribution_money'] - ($order['refund_amount'] ?: 0);
-            $orderMoney      = $orderMoney < 0 ? 0 : $orderMoney;
-            $tradeServiceFee = $orderMoney * ($tradeServiceRatio / 100); // 本单交易服务费
-            $actualGetMoney  = $orderMoney - $tradeServiceFee;   // 实际到账金额
-            $entryAmount     = $actualGetMoney;
-            $data['entryAccountMoney']    += $actualGetMoney;
-            $data['totalTradeServiceFee'] += $tradeServiceFee;
-
-            $settle_record[] = [
-                'settle_id'     => $settle['id'],
-                'order_id'      => $order['id'],
-                'settle_sn'     => $settle['settle_sn'],
-                'order_sn'      => $order['order_sn'],
-                'order_amount'  => $order['order_amount'],
-                'refund_amount'        => $order['is_cancel'] ? ($order['refund_amount'] ? : 0) : 0,
-                'after_sales_amount'   => $order['is_cancel'] ? 0 : ($order['refund_amount'] ? : 0),
-                'distribution_amount'  => $order['distribution_money'],
-                'entry_account_amount' => $entryAmount,
-                'trade_service_fee'    => $tradeServiceFee,
-                'trade_service_ratio'  => $tradeServiceRatio,
-                'order_complete_time'  => $order['confirm_take_time'],
-                'create_time'          => $time
-            ];
-
-            $orders_update[] = [
-                'id'            => $order['id'],
-                'settle_id'     => $settle['id'],
-                'settle_amount' => $entryAmount,
-                'update_time'   => $time
-            ];
-        }
-
-        // 4、保存更新
-        if (!empty($settle_record)) {
-            (new ShopSettlementRecord())->saveAll($settle_record);
-            (new Order())->saveAll($orders_update);
-        }
-        // 5、返回汇总数据
-        return $data;
-    }
-
-    
-    /**
-     * @Notes: 结算统计
-     * @return array
-     */
-    public static function statistics($shop_id = 0)
-    {
-        $where[] = ['shop_id', '=' , $shop_id];
-                   
-        $modelOrder = new Order();;
-
-        //已结算成交订单数
-        $modelShopSettlement = new ShopSettlement();
-        $settleOrederNum = $modelShopSettlement
-                ->where($where)
-                ->sum('deal_order_count');
-
-        //已结算营业额
-        $settleOrederAmount = $modelShopSettlement
-                ->where($where)
-                ->sum('business_money');
-
-        //待结算营业额
-        $settleOrederAmountWait = $modelOrder
-                ->where([
-                    ['shop_id', '=' , $shop_id],
-                    ['pay_status', '>', PayEnum::UNPAID],
-                    ['settle_id', '=', OrderEnum::SETTLE_WAIT]
-                ])
-                ->sum('order_amount');
-        
-        //已结算分销佣金金额
-        $settleDistributionAmount = $modelShopSettlement
-                ->where($where)
-                ->sum('distribution_money');
-                        
-        //已结算入账金额
-        $settleWithdrawalAmount = $modelShopSettlement
-                ->where($where)
-                ->sum('entry_account_money');  
-
-        //已结算交易服务费
-        $settlePoundageAmount = $modelShopSettlement
-                ->where($where)
-                ->sum('trade_service_fee');     
-
-        return [
-            'settleOrederNum'               =>  $settleOrederNum, //已结算成交订单数
-            'settleOrederAmount'            =>  $settleOrederAmount, //已结算营业额
-            'settleOrederAmountWait'        =>  $settleOrederAmountWait, //待结算营业额
-            'settleDistributionAmount'      =>  $settleDistributionAmount, //已结算分销佣金金额
-            'settleWithdrawalAmount'        =>  $settleWithdrawalAmount, //已结算入账金额
-            'settlePoundageAmount'          =>  $settlePoundageAmount, //已结算交易服务费
-        ];
-    }
-
-
-
-
-    /**
-     * @notes 导出
-     * @param $where
-     * @return array|false
-     * @author 段誉
-     * @date 2022/4/24 11:59
-     */
-    public static function export($where)
-    {
-        try {
-            $model = new ShopSettlement();
-            $lists = $model->field(true)
-                ->where($where)
-                ->order('id', 'desc')
-                ->select()
-                ->toArray();
-
-            $excelFields = [
-                'settle_sn' => '结算批次号',
-                'deal_order_count' => '已结算成交订单数',
-                'business_money' => '已结算营业额',
-                'refund_order_money' => '退款订单金额',
-                'after_sales_money' => '售后退款金额',
-                'distribution_money' => '已结算分销佣金金额',
-                'entry_account_money' => '已结算入账金额',
-                'create_time' => '结算时间',
-            ];
-
-            $export = new ExportExcelServer();
-            $export->setFileName('财务结算');
-            $export->setExportNumber(['settle_sn']);
-            $result = $export->createExcel($excelFields, $lists);
-
-            return ['url' => $result];
-
-        } catch (\Exception $e) {
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-}

+ 0 - 126
app/shop/logic/finance/ShopLogic.php

@@ -1,126 +0,0 @@
-<?php
-
-
-namespace app\shop\logic\finance;
-
-
-use app\common\basics\Logic;
-use app\common\enum\ShopEnum;
-use app\common\model\shop\ShopAccountLog;
-use app\common\server\ExportExcelServer;
-use app\common\server\UrlServer;
-
-class ShopLogic extends Logic
-{
-    /**
-     * @Notes: 账户明细
-     * @param $get
-     * @param $shop_id (商家ID)
-     * @return array
-     */
-    public static function account($get, $shop_id, $is_export = false)
-    {
-        $where[] = ['shop_id', '=', (int)$shop_id];
-        if (isset($get['search_key']) && $get['search_key']) {
-            switch($get['search_key']){
-                case 'settle':
-                    $where[] = ['SAL.source_type', '=', ShopAccountLog::settlement_add_money];
-                    break;
-                case 'withdrawal':
-                    $where[] = ['SAL.source_type', '=', ShopAccountLog::withdrawal_dec_money];
-                    break;
-                case 'withdrawal_stay':
-                    $where[] = ['SAL.source_type', '=', ShopAccountLog::withdrawal_stay_money];
-                    break;
-                case 'withdrawal_error':
-                    $where[] = ['SAL.source_type', '=', ShopAccountLog::withdrawal_fail_money];
-                    break;
-            }
-        }
-
-        if (!empty($get['start_time']) and $get['start_time']) {
-            $where[] = ['SAL.create_time', '>=', strtotime($get['start_time'])];
-        }
-
-        if (!empty($get['end_time']) and $get['end_time']) {
-            $where[] = ['SAL.create_time', '<=', strtotime($get['end_time'])];
-        }
-
-        if (true === $is_export) {
-            return self::export($where);
-        }
-
-        $model = new ShopAccountLog();
-        $lists = $model->alias('SAL')
-            ->field(['SAL.*', 'S.name,S.logo,S.type'])
-            ->join('shop S', 'S.id = SAL.shop_id')
-            ->where($where)
-            ->order('create_time','desc')
-            ->paginate([
-                'page'      => $get['page'],
-                'list_rows' => $get['limit'],
-                'var_page'  => 'page'
-            ])->toArray();
-
-
-        foreach ($lists['data'] as &$item) {
-            $item['type'] = ShopEnum::getShopTypeDesc($item['type']);
-            $item['source_type'] = ShopAccountLog::getSourceType($item['source_type']);
-            $symbol = $item['change_type'] === 1 ? '+' : '-';
-            $item['change_amount'] = $symbol.$item['change_amount'];
-            $item['logo'] = UrlServer::getFileUrl($item['logo']);
-        }
-
-        return ['count'=>$lists['total'], 'lists'=>$lists['data']];
-    }
-
-
-    /**
-     * @notes 导出
-     * @param $where
-     * @return array|false
-     * @author 段誉
-     * @date 2022/4/24 11:59
-     */
-    public static function export($where)
-    {
-        try {
-            $lists = (new ShopAccountLog())->alias('SAL')
-                ->field(['SAL.*', 'S.name,S.logo,S.type'])
-                ->join('shop S', 'S.id = SAL.shop_id')
-                ->where($where)
-                ->order('create_time','desc')
-                ->select()->toArray();
-
-            foreach ($lists as &$item) {
-                $item['type'] = ShopEnum::getShopTypeDesc($item['type']);
-                $item['source_type'] = ShopAccountLog::getSourceType($item['source_type']);
-                $symbol = $item['change_type'] === 1 ? '+' : '-';
-                $item['change_amount'] = $symbol.$item['change_amount'];
-            }
-
-            $excelFields = [
-                'name' => '商家名称',
-                'type' => '商家类型',
-                'log_sn' => '明细流水号',
-                'source_sn' => '来源单号',
-                'source_type' => '明细类型',
-                'change_amount' => '变动金额',
-                'left_amount' => '剩余金额',
-                'create_time' => '记录时间',
-            ];
-
-            $export = new ExportExcelServer();
-            $export->setFileName('账户明细');
-            $export->setExportNumber(['log_sn', 'source_sn']);
-            $result = $export->createExcel($excelFields, $lists);
-
-            return ['url' => $result];
-
-        } catch (\Exception $e) {
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-}

+ 0 - 409
app/shop/logic/finance/WithdrawalLogic.php

@@ -1,409 +0,0 @@
-<?php
-
-
-namespace app\shop\logic\finance;
-
-
-use app\common\basics\Logic;
-use app\common\enum\NoticeEnum;
-use app\common\enum\OrderEnum;
-use app\common\enum\ShopEnum;
-use app\common\enum\PayEnum;
-use app\common\enum\OrderRefundEnum;
-use app\common\enum\ShopWithdrawEnum;
-use app\common\enum\WithdrawalEnum;
-use app\common\enum\AfterSaleEnum;
-use app\common\model\order\Order;
-use app\common\model\shop\Shop;
-use app\common\model\shop\ShopAccountLog;
-use app\common\model\shop\ShopAlipay;
-use app\common\model\shop\ShopBank;
-use app\common\model\shop\ShopWithdrawal;
-use app\common\model\shop\ShopSettlement;
-use app\common\server\ConfigServer;
-use app\common\server\ExportExcelServer;
-use think\Exception;
-use think\facade\Db;
-
-class WithdrawalLogic extends Logic
-{
-    /**
-     * @Notes: 商家提现列表
-     * @Author: 张无忌
-     * @param $get
-     * @param $shop_id
-     * @return array
-     */
-    public static function lists($get, $shop_id, $is_export = false)
-    {
-        try {
-            $where[] = ['shop_id', '=', $shop_id];
-            $where[] = ['status', '=', $get['type'] ?? 0];
-
-            if (!empty($get['start_time']) and $get['start_time']) {
-                $where[] = ['create_time', '>=', strtotime($get['start_time'])];
-            }
-
-            if (!empty($get['end_time']) and $get['end_time']) {
-                $where[] = ['create_time', '<=', strtotime($get['end_time'])];
-            }
-
-            // 导出
-            if (true === $is_export) {
-                return self::export($where);
-            }
-
-            $model = new ShopWithdrawal();
-            $lists = $model->field(true)
-                ->where($where)
-                ->order('id desc')
-                ->paginate([
-                    'page'      => $get['page'],
-                    'list_rows' => $get['limit'],
-                    'var_page' => 'page'
-                ])->toArray();
-
-            foreach ($lists['data'] as &$item) {
-                $item['status'] = WithdrawalEnum::getStatusDesc($item['status']);
-            }
-
-            return ['count' => $lists['total'], 'lists' => $lists['data']];
-        } catch (\Exception $e) {
-            return ['error' => $e->getMessage()];
-        }
-    }
-
-    /**
-     * @Notes: 财务汇总
-     * @Author: 张无忌
-     * @param $shop_id
-     */
-    public static function summary($shop_id)
-    {
-        $orderModel = new Order();
-
-        // 成交订单笔数
-        $detail['dealOrderCount'] = $orderModel->where(['shop_id' => $shop_id, 'pay_status' => OrderEnum::PAY_STATUS_PAID])->count();
-        // 商家营业金额
-        $detail['businessMoney'] = $orderModel->where(['shop_id' => $shop_id, 'pay_status' => OrderEnum::PAY_STATUS_PAID])->sum('order_amount');
-        // 退款订单金额
-        $detail['refundMoney'] = $orderModel->where(['shop_id' => $shop_id])->where('refund_status', '>', 0)->sum('order_amount');
-    }
-
-    /**
-     * @Notes: 提现详细
-     * @Author: 张无忌
-     * @param $id
-     * @param $shop_id
-     * @return array
-     */
-    public static function detail($id, $shop_id)
-    {
-        $withdrawal = (new ShopWithdrawal())->findOrEmpty($id)->toArray();
-        $shop       = (new Shop())->with(['category'])->findOrEmpty($shop_id)->toArray();
-        $bank       = (new ShopBank())->findOrEmpty($withdrawal['bank_id'])->toArray();
-        $alipay     = (new ShopAlipay())->findOrEmpty($withdrawal['alipay_id'])->toArray();
-
-        $shop['type']               = ShopEnum::getShopTypeDesc($shop['type']);
-        $withdrawal['status_text']  = WithdrawalEnum::getStatusDesc($withdrawal['status']);
-        $withdrawal['type_text']    = ShopWithdrawEnum::getTypeText($withdrawal['type']);
-
-        return [ 'withdrawal' => $withdrawal, 'shop' => $shop, 'bank' => $bank, 'alipay' => $alipay ];
-    }
-
-    /**
-     * @Notes: 选项卡与汇总统计详细
-     * @param $shop_id
-     * @return array
-     */
-    public static function statistics($shop_id)
-    {
-        $model = new ShopWithdrawal();
-        $apply   = $model->where(['status' => WithdrawalEnum::APPLY_STATUS, 'shop_id' => $shop_id])->count();
-        $handle  = $model->where(['status' => WithdrawalEnum::HANDLE_STATUS, 'shop_id' => $shop_id])->count();
-        $success = $model->where(['status' => WithdrawalEnum::SUCCESS_STATUS, 'shop_id' => $shop_id])->count();
-        $error   = $model->where(['status' => WithdrawalEnum::ERROR_STATUS, 'shop_id' => $shop_id])->count();
-
-        //成交订单笔数
-        $modelOrder = new Order();
-        $modelShopWithdrawal = new ShopWithdrawal();
-        $orderNum = $modelOrder
-            ->where([
-                ['shop_id', '=', $shop_id],
-                ['pay_status', '>', PayEnum::UNPAID]
-            ])
-            ->count('id');
-        //营业额
-        $orderAmount = $modelOrder
-            ->where([
-                ['shop_id', '=', $shop_id],
-                ['pay_status', '>', PayEnum::UNPAID]
-            ])
-            ->sum('order_amount');
-
-        //退款订单金额
-        $refundAmount = $modelOrder
-            ->where([
-                ['shop_id', '=', $shop_id],
-                ['shipping_status', '=', OrderEnum::SHIPPING_NO],
-                ['pay_status', '=', PayEnum::REFUNDED],
-                ['refund_status', 'in', [OrderEnum::REFUND_STATUS_PART_REFUND, OrderEnum::REFUND_STATUS_ALL_REFUND]],
-            ])
-            ->sum('refund_amount');
-
-        //待退款订单金额
-        $refundAmountIng = $modelOrder->alias('o')
-            ->join('order_refund or', 'or.order_id = o.id')
-            ->where([
-                ['o.shop_id', '=', $shop_id],
-                ['o.shipping_status', '=', OrderEnum::SHIPPING_NO],
-                ['or.refund_status', '<>', OrderRefundEnum::REFUND_STATUS_COMPLETE]
-            ])
-            ->sum('or.refund_amount');
-
-        //售后退款金额
-        $salesRefundAmount = $modelOrder->alias('o')
-            ->join('after_sale as', 'as.order_id = o.id')
-            ->where([
-                ['o.shop_id', '=', $shop_id],
-                ['o.shipping_status', '=', OrderEnum::SHIPPING_FINISH],
-                ['as.status', '=', AfterSaleEnum::STATUS_COMPLETE]
-            ])
-            ->sum('as.refund_price');
-
-        //待售后退款金额
-        $salesRefundAmountIng = $modelOrder->alias('o')
-            ->join('after_sale as', 'as.order_id = o.id')
-            ->where([
-                ['o.shop_id', '=', $shop_id],
-                ['o.shipping_status', '=', OrderEnum::SHIPPING_FINISH],
-                ['as.status', '=', AfterSaleEnum::STATUS_WAITING]
-            ])
-            ->sum('as.refund_price');
-
-        //已结算成交订单数
-        $modelShopSettlement = new ShopSettlement();
-        $settleOrederNum = $modelShopSettlement
-            ->where([
-                ['shop_id', '=', $shop_id],
-            ])
-            ->sum('deal_order_count');
-
-        //已结算营业额
-        $settleOrederAmount = $modelShopSettlement
-            ->where([
-                ['shop_id', '=', $shop_id],
-            ])
-            ->sum('business_money');
-
-        //待结算营业额
-        $settleOrederAmountWait = $modelOrder
-            ->where([
-                ['shop_id', '=', $shop_id],
-                ['refund_status', '=', 0 ],
-                ['settle_id', '=', OrderEnum::SETTLE_WAIT]
-            ])
-            ->sum('order_amount');
-
-        //已结算分销佣金金额
-        $settleDistributionAmount = $modelShopSettlement
-            ->where([
-                ['shop_id', '=', $shop_id],
-            ])
-            ->sum('distribution_money');
-
-        //已结算入账金额
-        $settleWithdrawalAmount = $modelShopSettlement
-            ->where([
-                ['shop_id', '=', $shop_id],
-            ])
-            ->sum('entry_account_money');
-
-        //已结算交易服务费
-        $settlePoundageAmount = $modelShopSettlement
-            ->where([
-                ['shop_id', '=', $shop_id],
-            ])
-            ->sum('trade_service_fee');
-
-        //已提现金额    
-        $withdrawaLeftamount = $modelShopWithdrawal
-            ->where([
-                ['shop_id', '=', $shop_id],
-                ['status', '=', WithdrawalEnum::SUCCESS_STATUS]
-            ])
-            ->sum('apply_amount');
-
-        //提现中金额
-        $withdrawaLeftamountIng = $modelShopWithdrawal
-            ->where([
-                ['shop_id', '=', $shop_id],
-                ['status', 'in', [WithdrawalEnum::APPLY_STATUS, WithdrawalEnum::HANDLE_STATUS]]
-            ])
-            ->sum('apply_amount');
-
-        //可提现金额       
-        $modelShop = new Shop();
-        $shopWallet = $modelShop
-            ->where([
-                ['id', '=', $shop_id]
-            ])
-            ->sum('wallet');
-
-        //提现手续费
-        $procedMoney = $modelShopWithdrawal
-            ->where([
-                ['shop_id', '=', $shop_id],
-                ['status', '=', WithdrawalEnum::SUCCESS_STATUS]
-            ])
-            ->sum('poundage_amount');
-
-
-        return [
-            'apply'                         =>  $apply,
-            'handle'                        =>  $handle,
-            'success'                       =>  $success,
-            'error'                         =>  $error,
-            'orderNum'                      =>  $orderNum, //成交订单笔数
-            'orderAmount'                   =>  $orderAmount, //营业额
-            'refundAmount'                  =>  $refundAmount, //退款订单金额
-            'refundAmountIng'               =>  $refundAmountIng, //待退款订单金额
-            'salesRefundAmount'             =>  $salesRefundAmount, //售后退款金额
-            'salesRefundAmountIng'          =>  $salesRefundAmountIng, //待售后退款金额
-            'settleOrederNum'               =>  $settleOrederNum, //已结算成交订单数
-            'settleOrederAmount'            =>  $settleOrederAmount, //已结算营业额
-            'settleOrederAmountWait'        =>  $settleOrederAmountWait, //待结算营业额
-            'settleDistributionAmount'      =>  $settleDistributionAmount, //已结算分销佣金金额
-            'settleWithdrawalAmount'        =>  $settleWithdrawalAmount, //已结算入账金额
-            'settlePoundageAmount'          =>  $settlePoundageAmount, //已结算交易服务费
-            'withdrawaLeftamount'           =>  $withdrawaLeftamount, //已提现金额
-            'procedMoney'                   =>  $procedMoney, //提现手续费
-            'withdrawaLeftamountIng'        =>  $withdrawaLeftamountIng, //提现中金额
-            'shopWallet'                    =>  $shopWallet, //可提现金额
-        ];
-    }
-
-    /**
-     * @Notes: 申请提现
-     * @Author: 张无忌
-     * @param $post
-     * @param $shop_id
-     * @return bool
-     */
-    public static function add($post, $shop_id)
-    {
-        Db::startTrans();
-        try {
-            // 1、获取提现条件
-            $min_withdrawal_money = ConfigServer::get('shop_withdrawal', 'min_withdrawal_money', 0);
-            $max_withdrawal_money = ConfigServer::get('shop_withdrawal', 'max_withdrawal_money', 0);
-            $withdrawal_service_charge = ConfigServer::get('shop_withdrawal', 'withdrawal_service_charge', 0);
-
-            // 2、获取商家信息
-            $shop   = (new Shop())->findOrEmpty($shop_id)->toArray();
-            $wallet = $shop['wallet'];
-
-            // 3、验证条件是否满足
-            if (floatval($post['apply_amount']) > $wallet)
-                throw new Exception('账户余额不足');
-            if (floatval($post['apply_amount']) < $min_withdrawal_money)
-                throw new Exception('最低提现金额不能少于' . $min_withdrawal_money . '元');
-            if (floatval($post['apply_amount']) > $max_withdrawal_money)
-                throw new Exception('最高提现金额不能大于' . $max_withdrawal_money . '元');
-
-            // 4、获取商家提现手续费
-            $poundage_amount   = 0;
-            if ($withdrawal_service_charge > 0) {
-                $proportion = $withdrawal_service_charge / 100;
-                $poundage_amount = $post['apply_amount'] * $proportion;
-                $poundage_amount = $poundage_amount <= 0 ? 0 : $poundage_amount;
-            }
-
-            // 5、创建申请记录
-            $withdrawal = ShopWithdrawal::create([
-                'sn'              => createSn('shop_withdrawal', 'sn'),
-                'bank_id'         => $post['bank_id'] ?? 0,
-                'alipay_id'       => $post['alipay_id'] ?? 0,
-                'type'            => $post['type'],
-                'shop_id'         => $shop_id,
-                'apply_amount'    => floatval($post['apply_amount']),
-                'left_amount'     => $post['apply_amount'] - $poundage_amount,
-                'poundage_amount' => $poundage_amount,
-                'poundage_ratio'  => $withdrawal_service_charge,
-                'status'          => WithdrawalEnum::APPLY_STATUS
-            ]);
-            // 6、扣除商家可提现金额
-            Shop::update([
-                'wallet'      => ['dec', floatval($post['apply_amount'])],
-                'update_time' => time()
-            ], ['id' => $shop_id]);
-            $left_amount =  Shop::where(['id' => $shop_id])->value('wallet');
-            // 7、增加提现流水记录(待提现)
-            $logType = ShopAccountLog::withdrawal_stay_money;
-            ShopAccountLog::decData($shop_id, $logType, $post['apply_amount'], $left_amount, [
-                'source_id' => $withdrawal['id'],
-                'source_sn' => $withdrawal['sn'],
-                'remark'    => '商家提现'
-            ]);
-
-            $platform_contacts = ConfigServer::get('website_platform', 'platform_mobile');
-            if (!empty($platform_contacts)) {
-                event('Notice', [
-                    'scene' => NoticeEnum::SHOP_WITHDRAWAL_NOTICE_PLATFORM,
-                    'mobile' => $platform_contacts,
-                    'params' => [
-                        'shop_withdrawal_sn' => $withdrawal['sn'],
-                        'shop_name' => $shop['name'],
-                    ]
-                ]);
-            }
-
-            Db::commit();
-            return true;
-        } catch (\Exception $e) {
-            Db::rollback();
-            static::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-    /**
-     * @notes 导出
-     * @param $where
-     * @return array|false
-     * @author 段誉
-     * @date 2022/4/24 11:59
-     */
-    public static function export($where)
-    {
-        try {
-            $lists = (new ShopWithdrawal())
-                ->field(true)
-                ->where($where)
-                ->select()->toArray();
-
-            foreach ($lists as &$item) {
-                $item['status'] = WithdrawalEnum::getStatusDesc($item['status']);
-            }
-
-            $excelFields = [
-                'sn' => '提现单号',
-                'apply_amount' => '提现金额',
-                'poundage_amount' => '提现手续费',
-                'left_amount' => '到账金额',
-                'status' => '提现状态',
-                'create_time' => '提现时间',
-            ];
-
-            $export = new ExportExcelServer();
-            $export->setFileName('财务中心');
-            $result = $export->createExcel($excelFields, $lists);
-
-            return ['url' => $result];
-
-        } catch (\Exception $e) {
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-}

+ 0 - 133
app/shop/logic/free_shipping/FreeShippingLogic.php

@@ -1,133 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-namespace app\shop\logic\free_shipping;
-
-use app\common\basics\Logic;
-use app\common\server\ConfigServer;
-use think\facade\Db;
-
-class FreeShippingLogic extends Logic
-{
-    public static function index($params)
-    {
-        Db::startTrans();
-        try {
-            // 保存设置
-            $config = Db::name('free_shipping_config')->where([
-                'shop_id' => $params['shop_id'],
-                'del' => 0
-            ])->findOrEmpty();
-            if (empty($config)) {
-                // 无则添加
-                Db::name('free_shipping_config')->save([
-                    'shop_id' => $params['shop_id'],
-                    'status' => $params['status'],
-                    'goods_type' => $params['goods_type'],
-                    'free_rule' => $params['free_rule'],
-                    'create_time' => time(),
-                    'del' => 0,
-                ]);
-            } else {
-                // 有则更新
-                Db::name('free_shipping_config')->where([
-                    'shop_id' => $params['shop_id'],
-                    'del' => 0
-                ])->update([
-                    'status' => $params['status'],
-                    'goods_type' => $params['goods_type'],
-                    'free_rule' => $params['free_rule'],
-                    'update_time' => time()
-                ]);
-            }
-            // 先清除旧数据
-            Db::name('free_shipping_region')->where([
-                'shop_id' => $params['shop_id'],
-                'del' => 0
-            ])->update(['del' => 1]);
-            // 保存活动区域
-            $data = [];
-            $time = time();
-            $del = 0;
-            foreach($params['region'] as $key => $value) {
-                if($params['order_amount'][$key] < 0) {
-                    throw new \Exception('订单金额不能小于0');
-                }
-                $data[] = ['shop_id' => $params['shop_id'], 'region' => $value, 'order_amount' => $params['order_amount'][$key], 'create_time' => $time, 'del' => $del];
-            }
-
-            Db::name('free_shipping_region')->insertAll($data);
-
-            Db::commit();
-            return true;
-        } catch (\Exception $e) {
-            Db::rollback();
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-    public static function getData($shopId)
-    {
-        $config = Db::name('free_shipping_config')
-            ->field('status,goods_type,free_rule')
-            ->where([
-            'shop_id' => $shopId,
-            'del' => 0,
-        ])->findOrEmpty();
-        if(empty($config)) {
-            // 默认值
-            $config = [
-                'status' => 0,
-                'goods_type' => 1,
-                'free_rule' => 1,
-            ];
-        }
-        $regionArr = Db::name('free_shipping_region')->field('region,order_amount')
-            ->where([
-                'shop_id' => $shopId,
-                'del' => 0,
-            ])->select()->toArray();
-
-        $regions = Db::name('dev_region')->column('name', 'id');
-
-        foreach ($regionArr as &$item) {
-            $item['region_name'] = '';
-
-            if ($item['region'] == 'all'){
-                $item['region_name'] = '全国地区默认规则';
-                continue;
-            }
-
-            $region = explode(',', $item['region']);
-
-            foreach ($region as $v) {
-                if (isset($regions[$v])) {
-                    $item['region_name'] .= $regions[$v] . ',';
-                }
-            }
-            $item['region_name'] = rtrim($item['region_name'], ',');
-        }
-
-        return [
-            'config' => $config,
-            'region' => $regionArr,
-        ];
-    }
-}

+ 0 - 82
app/shop/logic/goods/CategoryLogic.php

@@ -1,82 +0,0 @@
-<?php
-namespace app\shop\logic\goods;
-
-use app\common\model\shop\ShopGoodsCategory as ShopGoodsCategoryModel;
-
-class CategoryLogic
-{
-  public static function lists($get)
-  {
-    $lists = ShopGoodsCategoryModel::where(['del' => 0, 'shop_id' => $get['shop_id']])
-      ->page($get['page'], $get['limit'])
-      ->order('sort', 'asc')
-      ->select();
-    $count = ShopGoodsCategoryModel::where(['del' => 0, 'shop_id' => $get['shop_id']])->count();
-    if($lists) {
-      $lists = $lists->toArray();
-    }
-    $data = [
-      'count' => $count,
-      'lists' => $lists
-    ];
-    return $data;
-  }
-
-  /**
-   * 添加
-   */
-  public static function add($post)
-  {
-    $post['create_time'] = time();
-    return ShopGoodsCategoryModel::create($post);
-  }
-
-  /**
-   * 获取商品分类信息
-   */
-  public static function getCategory($id)
-  {
-    return ShopGoodsCategoryModel::find($id);
-  }
-
-  /**
-   * 编辑商品分类
-   */
-  public static function edit($post)
-  {
-    $post['update_time'] = time();
-    return ShopGoodsCategoryModel::update($post);
-  }
-
-  /**
-   * 删除商品分类
-   */
-  public static function del($post)
-  {
-    $post['update_time'] = time();
-    $post['del'] = 1;
-    return ShopGoodsCategoryModel::update($post);
-  }
-
-  /**
-   * 修改是否显示状态
-   */
-  public static function switchStatus($post)
-  {
-    $post['is_show'] = $post['status'];
-    unset($post['status']);
-    return ShopGoodsCategoryModel::update($post);
-  }
-
-  /**
-   * 店铺商品分类
-   */
-  public static function listAll($shop_id)
-  {
-    $lists = ShopGoodsCategoryModel::field('id,name')->where([
-        'del'=>0,
-        'shop_id' => $shop_id
-    ])->order('id', 'asc')->select();
-    return empty($lists) ? [] : $lists->toArray();
-  }
-}

+ 0 - 132
app/shop/logic/goods/CommentLogic.php

@@ -1,132 +0,0 @@
-<?php
-namespace app\shop\logic\goods;
-
-use app\common\basics\Logic;
-use app\common\model\goods\GoodsComment;
-use app\common\model\user\UserLevel;
-use app\common\server\UrlServer;
-
-class CommentLogic extends Logic
-{
-    public static function lists($get)
-    {
-        $where = [
-            ['gc.shop_id', '=', $get['shop_id']],
-            ['gc.del', '=', 0],
-        ];
-
-        if($get['type'] == 0) { // 待回复
-            $where[] = ['reply', '=', ''];
-        }else{ // 已回复
-            $where[] = ['reply', '<>', ''];
-        }
-
-        // 评价信息
-        if(isset($get['search_word']) && !empty($get['search_word'])) {
-            switch($get['search_type']) {
-                case 'name':
-                    $where[] = ['g.name', 'like', '%'. trim($get['search_word']) . '%'];
-                    break;
-                case 'sn':
-                    $where[] = ['u.sn', '=', trim($get['search_word'])];
-                    break;
-                case 'nickname':
-                    $where[] = ['u.nickname', '=', trim($get['search_word'])];
-                    break;
-            }
-        }
-
-        // 评价等级
-        if(isset($get['goods_comment']) && !empty($get['goods_comment'])) {
-            switch ($get['goods_comment']) {
-                case 1:
-                    $where[] = ['gc.goods_comment', '>', 3];
-                    break;
-                case 2:
-                    $where[] = ['gc.goods_comment', '=', 3];
-                    break;
-                case 3:
-                    $where[] = ['gc.goods_comment', '<', 3];
-                    break;
-            }
-        }
-
-        // 显示状态
-        if(isset($get['status']) && !empty($get['status'])) {
-            switch ($get['status']) {
-                case 1:
-                    $where[] = ['gc.status', '=', 1];
-                    break;
-                case 2: // 隐藏状态  前端不使用0的原因:empty()时0会被认为false
-                    $where[] = ['gc.status', '=', 0];
-                    break;
-            }
-        }
-
-        // 日期范围
-        if(isset($get['start_end']) && !empty($get['start_end'])) {
-            $arr = explode('~', $get['start_end']);
-            $start_time = strtotime($arr[0]);
-            $end_time = strtotime($arr[1]);
-            $where[] = ['gc.create_time', '>=', $start_time];
-            $where[] = ['gc.create_time', '<=', $end_time];
-        }
-
-        $lists = GoodsComment::alias('gc')
-            ->with(['goods_comment_image'])
-            ->field('gc.id,gc.goods_comment,gc.goods_comment as goods_comment_desc,gc.comment,gc.reply,gc.status,gc.status as status_desc,gc.create_time,u.sn,u.nickname,u.avatar,u.level,g.name as goods_name,g.image as goods_image,gi.image as item_image,gi.spec_value_str')
-            ->leftJoin('user u', 'u.id=gc.user_id')
-            ->leftJoin('goods g', 'g.id=gc.goods_id')
-            ->leftJoin('goods_item gi', 'gi.id=gc.item_id')
-            ->where($where)
-            ->order('gc.create_time', 'desc')
-            ->page($get['page'], $get['limit'])
-            ->select()
-            ->toArray();
-
-        $count = GoodsComment::alias('gc')
-            ->field('gc.id,gc.goods_comment,gc.goods_comment as goods_comment_desc,gc.comment,gc.reply,gc.status,gc.status as status_desc,gc.create_time,u.sn,u.nickname,u.avatar,u.level,g.name as goods_name,g.image as goods_image,gi.image as item_image,gi.spec_value_str')
-            ->leftJoin('user u', 'u.id=gc.user_id')
-            ->leftJoin('goods g', 'g.id=gc.goods_id')
-            ->leftJoin('goods_item gi', 'gi.id=gc.item_id')
-            ->where($where)
-            ->count();
-
-        $levelArr = UserLevel::where('del', 0)->column('name', 'id');
-
-        foreach($lists as &$item) {
-            // 类型
-            $item['type'] = $get['type'];
-            // 头像
-            $item['avatar'] = UrlServer::getFileUrl($item['avatar']);
-            // 会员等级
-            $item['levelName'] = $levelArr[$item['level']] ?? '无等级';
-            // 评价图片
-            $item['comment_image'] = array_column($item['goods_comment_image'], 'uri');
-            foreach($item['comment_image'] as $key => $subItem) {
-                $item['comment_image'][$key] = UrlServer::getFileUrl($subItem);
-            }
-            $item['goods_image'] = UrlServer::getFileUrl($item['goods_image']);
-            $item['item_image'] = empty($item['item_image']) ? '' : UrlServer::getFileUrl($item['item_image']);
-        }
-
-        return [
-            'count' => $count,
-            'lists' => $lists
-        ];
-    }
-
-    public static function reply($post)
-    {
-        try{
-            GoodsComment::where('id', $post['id'])->update([
-                'reply' => trim($post['reply']),
-                'update_time' => time()
-            ]);
-            return true;
-        }catch(\Exception $e) {
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-}

+ 0 - 862
app/shop/logic/goods/GoodsLogic.php

@@ -1,862 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-
-namespace app\shop\logic\goods;
-
-
-use app\common\basics\Logic;
-use app\common\enum\GoodsEnum;
-use app\common\model\distribution\DistributionGoods;
-use app\common\model\goods\Goods;
-use app\common\model\goods\GoodsImage;
-use app\common\model\goods\GoodsItem;
-use app\common\model\goods\GoodsSpec;
-use app\common\model\goods\GoodsSpecValue;
-use app\common\server\JsonServer;
-use app\common\server\UrlServer;
-use think\facade\Db;
-use app\common\model\shop\Shop;
-use think\facade\Validate;
-
-
-/**
- * 商品管理-逻辑
- * Class GoodsLogic
- * @package app\shop\logic\goods
- */
-class GoodsLogic extends Logic
-{
-    /**
-     * @notes 商品统计
-     * @param $shop_id
-     * @return int[]
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2022/4/7 11:57
-     */
-    public static function statistics($shop_id){
-        $where = [
-            ['del', '<>', GoodsEnum::DEL_TRUE],
-            ['shop_id', '=', $shop_id]
-        ];
-
-        return [
-            // 销售中商品
-            // 销售状态:上架中;删除状态:正常; 审核状态: 审核通过
-            'sell'      => Goods::where($where)
-                ->where('del', GoodsEnum::DEL_NORMAL)
-                ->where('status', GoodsEnum::STATUS_SHELVES)
-                ->where('audit_status', GoodsEnum::AUDIT_STATUS_OK)
-                ->where('stock', '>=', Db::raw('stock_warn'))
-                ->count(),
-            // 库存预警商品
-            // 销售状态:上架中;删除状态:正常; 审核状态: 审核通过;总库存 < 库存预警
-            'warn'      => Goods::where($where)
-                ->where('del', GoodsEnum::DEL_NORMAL)
-                ->where('status', GoodsEnum::STATUS_SHELVES)
-                ->where('audit_status', GoodsEnum::AUDIT_STATUS_OK)
-                ->where('stock', '<', Db::raw('stock_warn'))
-                ->count(),
-            // 仓库中商品
-            // 销售状态:仓库中;删除状态:正常; 审核状态: 审核通过
-            'warehouse' => Goods::where($where)
-                ->where('del', GoodsEnum::DEL_NORMAL)
-                ->where('status', GoodsEnum::STATUS_SOLD_OUT)
-                ->where('audit_status', GoodsEnum::AUDIT_STATUS_OK)
-                ->count(),
-            // 回收站商品
-            // 销售状态:任意;删除状态:回收站; 审核状态: 审核通过
-            'recycle'   => Goods::where($where)
-                ->where('del', GoodsEnum::DEL_RECYCLE)
-                ->where('audit_status', GoodsEnum::AUDIT_STATUS_OK)
-                ->count(),
-            // 待审核商品
-            // 销售状态:任意;删除状态:排除已删除; 审核状态: 待审核
-            'audit_stay' => Goods::where($where)
-                ->where('del', '<>', GoodsEnum::DEL_TRUE)
-                ->where('audit_status', GoodsEnum::AUDIT_STATUS_STAY)
-                ->count(),
-            // 审核未通过商品
-            // 销售状态:任意;删除状态:排除已删除; 审核状态: 审核未通过
-            'audit_refuse'=> Goods::where($where)
-                ->where('del', '<>', GoodsEnum::DEL_TRUE)
-                ->where('audit_status', GoodsEnum::AUDIT_STATUS_REFUSE)
-                ->count(),
-        ];
-    }
-
-
-    /**
-     * Notes: 列表
-     * @param $get
-     * @author 段誉(2021/4/15 10:53)
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     */
-    public static function lists($get)
-    {
-        $where = [
-            ['shop_id', '=', $get['shop_id']]
-        ];
-        if(isset($get['goods_name']) && $get['goods_name']) {
-            $where[] = ['name','like','%'.$get['goods_name'].'%'];
-        }
-        if(!empty($get['platform_cate_id'])) {
-            $where[] = ['first_cate_id|second_cate_id|third_cate_id','=', $get['platform_cate_id']];
-        }
-
-        if(!empty($get['shop_cate_id'])) {
-            $where[] = ['shop_cate_id','=', $get['shop_cate_id']];
-        }
-
-        if(isset($get['goods_type']) && $get['goods_type'] != '') {
-            $where[] = ['type','=', $get['goods_type']];
-        }
-        
-        if (Validate::must($get['is_distribution'] ?? '')) {
-            $where[] = [ 'is_distribution', '=', $get['is_distribution'] ];
-        }
-        
-        if (Validate::must($get['is_member'] ?? '')) {
-            $where[] = [ 'is_member', '=', $get['is_member'] ];
-        }
-
-        $type = $get['type'] ?? 0;
-
-        switch ($type) {
-            case 1:     //销售中
-                $where[] = ['status', '=', GoodsEnum::STATUS_SHELVES];//上架
-                $where[] = ['del', '=', GoodsEnum::DEL_NORMAL];
-                $where[] = ['audit_status', '=', GoodsEnum::AUDIT_STATUS_OK];//审核通过
-                $where[] = ['stock','exp', Db::raw('>=stock_warn')];
-                break;
-            case 2:     //库存预警
-                $where[] = ['status', '=', GoodsEnum::STATUS_SHELVES];//上架
-                $where[] = ['del', '=', GoodsEnum::DEL_NORMAL];
-                $where[] = ['audit_status', '=', GoodsEnum::AUDIT_STATUS_OK];//审核通过
-                $where[] = ['stock','exp', Db::raw('<stock_warn')];
-                break;
-            case 3:      //仓库中
-                $where[] = ['status', '=', GoodsEnum::STATUS_SOLD_OUT];//下架
-                $where[] = ['del', '=', GoodsEnum::DEL_NORMAL];
-                $where[] = ['audit_status', '=', GoodsEnum::AUDIT_STATUS_OK];//审核通过
-                break;
-            case 4:     //回收站
-                $where[] = ['del', '=', GoodsEnum::DEL_RECYCLE];
-                $where[] = ['audit_status', '=', GoodsEnum::AUDIT_STATUS_OK];//审核通过
-                break;
-            case 5:  //待审核
-                $where[] = ['del', '<>', GoodsEnum::DEL_TRUE];
-                $where[] = ['audit_status', '=', GoodsEnum::AUDIT_STATUS_STAY];
-                break;
-            case 6: //审核未通过
-                $where[] = ['del', '<>', GoodsEnum::DEL_TRUE];
-                $where[] = ['audit_status', '=', GoodsEnum::AUDIT_STATUS_REFUSE];
-                break;
-            default:
-                $where[] = ['del', '=', GoodsEnum::DEL_NORMAL];
-        }
-
-        $order = [
-            'sort' => 'asc',
-            'id' => 'desc'
-        ];
-
-        $lists = Goods::where($where)
-            ->append([ 'is_distribution_desc', 'is_member_desc' ])
-            ->page($get['page'], $get['limit'])
-            ->order($order)
-            ->select();
-        $count = Goods::where($where)->count();
-        if($count) {
-            $lists = $lists->toArray();
-        }else{
-            $lists = [];
-        }
-        foreach ($lists as &$item) {
-            // 处理价格格式
-            $item['price'] = $item['spec_type'] == 1 ? $item["min_price"] : $item["min_price"] . " ~ " . $item["max_price"];
-        }
-        return ['count' => $count, 'lists' => $lists];
-    }
-
-
-    /**
-     * Notes: 添加商品
-     * @param $shop_id
-     * @param $post
-     * @param $spec_lists
-     * @author 段誉(2021/4/20 15:14)
-     * @return bool
-     */
-    public static function add($shop_id, $post, $spec_lists)
-    {
-        Db::startTrans();
-        try {
-            // 图片去除域名
-            $post['image'] = UrlServer::setFileUrl($post['image']);
-            $post['goods_image'] = array_map(function($value) {
-                return UrlServer::setFileUrl($value);
-            }, $post['goods_image']);
-
-            //添加商品主表
-            $goods_id = self::addGoods($shop_id, $post);
-
-            //添加商品轮播图
-            self::addGoodsImage($goods_id,$post);
-
-            //添加规格项、规格值、SKU
-            if ($post['spec_type'] == 1) {
-                self::addOneSpec($goods_id, $post);
-            } else {
-                self::addMoreSpec($goods_id, $post, $spec_lists);
-            }
-            Db::commit();
-            return true;
-        } catch (\Exception $e) {
-            Db::rollback();
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-
-    /**
-     * @notes 删除
-     * @param $shop_id
-     * @param $id
-     * @return Goods
-     * @author 段誉
-     * @date 2022/2/14 18:51
-     */
-    public static function del($shop_id, $id)
-    {
-        $result = Goods::update(['del' => 1], ['id' => $id, 'shop_id' => $shop_id]);
-        event('UpdateCollect', ['goods_id' => $id]);
-        return $result;
-    }
-
-
-    /**
-     * 获取商品信息
-     * @param $goods_id
-     * @return array
-     */
-    public static function info($goods_id)
-    {
-        // 商品主表
-        $info['base'] = Goods::where(['id' => $goods_id])
-            ->withAttr('abs_image', function ($value, $data) {
-                return UrlServer::getFileUrl($data['image']);
-            })
-            ->withAttr('content', function ($value){
-                $preg = '/(<img .*?src=")[^https|^http](.*?)(".*?>)/is';
-                $local_url = UrlServer::getFileUrl('/');
-                return  preg_replace($preg, "\${1}$local_url\${2}\${3}",$value);
-            })
-            ->withAttr('poster', function ($value){
-                return empty($value) ? '' : UrlServer::getFileUrl($value);
-            })
-            ->withAttr('abs_video',function ($value,$data){
-                if($data['video']){
-                    return UrlServer::getFileUrl($data['video']);
-                }
-                return '';
-            })->append(['abs_image','abs_video'])->find();
-
-        // 商品轮播图
-        $info['base']['goods_image'] = GoodsImage::where(['goods_id' => $goods_id])
-            ->withAttr('abs_image', function ($value, $data) {
-                return UrlServer::getFileUrl($data['uri']);})
-            ->append(['abs_image'])
-            ->select();
-        // 商品SKU
-        $info['item'] =GoodsItem::where(['goods_id' => $goods_id])
-            ->withAttr('abs_image', function ($value, $data) {
-                return $data['image'] ? UrlServer::getFileUrl($data['image']) : '';
-            })->append(['abs_image'])
-            ->select();
-        // 商品规格项
-        $info['spec'] = GoodsSpec::where(['goods_id' => $goods_id])->select();
-        // 商品规格值
-        $spec_value = GoodsSpecValue::where(['goods_id' => $goods_id])->select();
-
-        $data = [];
-        foreach ($spec_value as $k => $v) {
-            $data[$v['spec_id']][] = $v;
-        }
-        foreach ($info['spec'] as $k => $v) {
-            $info['spec'][$k]['values'] = isset($data[$v['id']]) ? $data[$v['id']] : [];
-        }
-        return $info;
-    }
-
-
-    /**
-     * 编辑
-     */
-    public static function edit($post, $spec_lists)
-    {
-        Db::startTrans();
-        try {
-    
-            $oldItemIds = GoodsItem::where('goods_id', $post['id'])->column('id');
-            
-            //计算最大最小价格
-            if ($post['spec_type'] == 1) {
-                $max_price = $post['one_price'];
-                $min_price = $post['one_price'];
-                $market_price = $post['one_market_price'];
-                $total_stock = $post['one_stock'];
-            } else {
-                $max_price = max($post['price']);
-                $min_price = min($post['price']);
-                $min_price_key = array_search($min_price,$post['price']);
-                $market_price = $post['market_price'][$min_price_key];
-                $total_stock = array_sum($post['stock']);
-            }
-
-            // 库存校验
-            if($post['status'] == GoodsEnum::STATUS_SHELVES && $total_stock == 0) {
-                throw new \Exception('库存为0不允许上架');
-            }
-
-            $old_spec_type = Goods::where('id', $post['goods_id'])->value('spec_type');
-
-            // 格式化数据
-            $post = self::formatGoodsData($post);
-
-            //更新主表
-            $data = [
-                'name'                      => $post['name'],
-                'code'                      => $post['code'],
-                'shop_cate_id'              => $post['shop_cate_id'],
-                'first_cate_id'             => $post['first_cate_id'],
-                'second_cate_id'            => $post['second_cate_id'],
-                'third_cate_id'             => $post['third_cate_id'],
-                'brand_id'                  => $post['brand_id'],
-                'unit_id'                   => $post['unit_id'],
-                'supplier_id'               => $post['supplier_id'],
-                'status'                    => $post['status'],
-                'image'                     => clearDomain($post['image']),
-                'video'                     => $post['video'] ?? '',
-                'remark'                    => $post['remark'],
-                'content'                   => $post['content'],
-                'sort'                      => $post['sort'],
-                'spec_type'                 => $post['spec_type'],
-                'max_price'                 => $max_price,
-                'min_price'                 => $min_price,
-                'market_price'              => $market_price,
-                'stock'                     => $total_stock,
-                'express_type'              => $post['express_type'],
-                'express_money'             => $post['express_money'],
-                'express_template_id'       => $post['express_template_id'],
-                'is_recommend'              => $post['is_recommend'],
-                'update_time'               => time(),
-                'stock_warn'                => $post['stock_warn'],
-                'poster'                    => isset($post['poster']) ? clearDomain($post['poster']) : '',
-                'is_show_stock'             => $post['is_show_stock'],
-                'is_member'                 => $post['is_member'],
-                'delivery_type'             => implode(',', $post['delivery_type']),
-                'after_pay'                 => $post['after_pay'] ?? 0,
-                'after_delivery'            => $post['after_delivery'] ?? 0,
-                'delivery_content'          => $post['delivery_content'] ?? '',
-            ];
-
-            // 判断是否为未审核通过的商品
-            $audit_status = Goods::where(['id' => $post['goods_id']])->value('audit_status');
-            if($audit_status == GoodsEnum::AUDIT_STATUS_REFUSE) {
-                $data['audit_status'] = GoodsEnum::AUDIT_STATUS_STAY; // 编辑后未审核通过的商品状态置为待审核
-            }
-
-            Goods::where(['id' => $post['goods_id']])->update($data);
-
-            if ($data['status'] != GoodsEnum::STATUS_SHELVES) {
-                event('UpdateCollect', ['goods_id' => $post['goods_id']]);
-            }
-
-            //先删除再重新添加轮播图
-            GoodsImage::where(['goods_id' => $post['goods_id']])->delete();
-            $data = [];
-            foreach ($post['goods_image'] as $k => $v) {
-                $data[] = [
-                    'goods_id' => $post['goods_id'],
-                    'uri' => clearDomain($v),
-                ];
-            }
-            (new GoodsImage())->saveAll($data);
-
-            //写入规格表
-            if ($post['spec_type'] == 1) {
-                //单规格写入
-                if ($old_spec_type == 1) {
-                    //原来是单规格
-                    $data = [
-                        'image'             => isset($post['one_spec_image']) ? clearDomain($post['one_spec_image']) : '',
-                        'market_price'      => $post['one_market_price'],
-                        'price'             => $post['one_price'],
-                        'chengben_price'    => $post['one_chengben_price'],
-                        'stock'             => $post['one_stock'],
-                        'weight'            => $post['one_weight'],
-                        'volume'            => $post['one_volume'],
-                        'bar_code'          => $post['one_bar_code'],
-                    ];
-                    GoodsItem::where(['goods_id' => $post['goods_id']])->update($data);
-                } else {
-                    //原来多规格
-                    //删除多规格
-                    GoodsSpec::where('goods_id', $post['goods_id'])->delete();
-                    GoodsSpecValue::where('goods_id', $post['goods_id'])->delete();
-                    GoodsItem::where('goods_id', $post['goods_id'])->delete();
-                    $goodsSpec = GoodsSpec::create(['goods_id' => $post['goods_id'], 'name' => '默认']);
-                    $goods_spec_id = $goodsSpec->id;
-                    $goodsSpecValue = GoodsSpecValue::create(['spec_id' => $goods_spec_id, 'goods_id' => $post['goods_id'], 'value' => '默认']);
-                    $goods_spec_value_id = $goodsSpecValue->id;
-                    $data = [
-                        'image'             => isset($post['one_spec_image']) ? clearDomain($post['one_spec_image']) : '',
-                        'goods_id'          => $post['goods_id'],
-                        'spec_value_ids'    => $goods_spec_value_id,
-                        'spec_value_str'    => '默认',
-                        'market_price'      => $post['one_market_price'],
-                        'price'             => $post['one_price'],
-                        'chengben_price'    => $post['one_chengben_price'],
-                        'stock'             => $post['one_stock'],
-                        'volume'            => $post['one_volume'],
-                        'weight'            => $post['one_weight'],
-                        'bar_code'          => $post['one_bar_code'],
-                    ];
-                    GoodsItem::create($data);
-                }
-            } else {
-                // 多规格写入
-                $goods_specs = [];
-                foreach ($post['spec_name'] as $k => $v) {
-                    $temp = ['goods_id' => $post['goods_id'], 'name' => $v, 'spec_id' => $post['spec_id'][$k]];
-                    $goods_specs[] = $temp;
-                }
-                $new_spec_name_ids = [];
-                foreach ($goods_specs as $k => $v) {
-                    if ($v['spec_id']) {
-                        //更新规格名
-                        GoodsSpec::where(['goods_id' => $post['goods_id'], 'id' => $v['spec_id']])
-                            ->update(['name' => $v['name']]);
-                        $new_spec_name_ids[] = $v['spec_id'];
-                    } else {
-                        //添加规格名
-                        $goodsSpec = GoodsSpec::create(['goods_id' => $post['goods_id'], 'name' => $v['name']]);
-                        $new_spec_name_ids[] = $goodsSpec->id;
-                    }
-                }
-                //删除规格项
-                $all_spec_ids = GoodsSpec::where('goods_id', $post['goods_id'])->column('id');
-                $del_spec_name_ids = array_diff($all_spec_ids, $new_spec_name_ids);
-                if (!empty($del_spec_name_ids)) {
-                    GoodsSpec::where('goods_id', $post['goods_id'])
-                        ->where('id', 'in', $del_spec_name_ids)
-                        ->delete();
-                }
-
-                $new_spec_value_ids = [];
-                $goods_spec_name_key_id = Db::name('goods_spec')
-                    ->where(['goods_id' => $post['goods_id']])
-                    ->where('name', 'in', $post['spec_name'])
-                    ->column('id', 'name');
-                foreach ($post['spec_values'] as $k => $v) {
-                    $value_id_row = explode(',', $post['spec_value_ids'][$k]);
-                    $value_row = explode(',', $v);
-                    foreach ($value_row as $k2 => $v2) {
-                        $temp = [
-                            'goods_id' => $post['goods_id'],
-                            'spec_id' => $goods_spec_name_key_id[$post['spec_name'][$k]],
-                            'value' => $v2,
-                        ];
-                        if ($value_id_row[$k2]) {
-                            //更新规格值
-                            Db::name('goods_spec_value')
-                                ->where(['id' => $value_id_row[$k2]])
-                                ->update($temp);
-                            $new_spec_value_ids[] = $value_id_row[$k2];
-                        } else {
-                            //添加规格值
-                            $new_spec_value_ids[] = Db::name('goods_spec_value')
-                                ->insertGetId($temp);
-                        }
-                    }
-                }
-                $all_spec_value_ids = Db::name('goods_spec_value')
-                    ->where('goods_id', $post['goods_id'])
-                    ->column('id');
-                $del_spec_value_ids = array_diff($all_spec_value_ids, $new_spec_value_ids);
-                if (!empty($del_spec_value_ids)) {
-                    //删除规格值
-                    Db::name('goods_spec_value')
-                        ->where('goods_id', $post['goods_id'])
-                        ->where('id', 'in', $del_spec_value_ids)
-                        ->delete();
-                }
-
-                $new_item_id = [];
-                $goods_spec_name_value_id = Db::name('goods_spec_value')
-                    ->where(['goods_id' => $post['goods_id']])
-                    ->column('id', 'value');
-                foreach ($spec_lists as $k => $v) {
-                    $spec_lists[$k]['spec_value_ids'] = '';
-                    $temp = explode(',', $v['spec_value_str']);
-                    foreach ($temp as $k2 => $v2) {
-                        $spec_lists[$k]['spec_value_ids'] .= $goods_spec_name_value_id[$v2] . ',';
-                    }
-                    $spec_lists[$k]['spec_value_ids'] = trim($spec_lists[$k]['spec_value_ids'], ',');
-                    if(isset($spec_lists[$k]['spec_image'])) {
-                        $spec_lists[$k]['image'] = clearDomain($spec_lists[$k]['spec_image']);
-                    }
-
-                    unset($spec_lists[$k]['spec_image']);
-                    $spec_lists[$k]['goods_id'] = $post['goods_id'];
-                    unset($spec_lists[$k]['spec_id']);
-                    $item_id = $spec_lists[$k]['item_id'];
-                    unset($spec_lists[$k]['item_id']);
-                    if ($item_id) {
-                        Db::name('goods_item')
-                            ->where(['id' => $item_id])
-                            ->update($spec_lists[$k]);
-                        $new_item_id[] = $item_id;
-                    } else {
-                        $new_item_id[] = Db::name('goods_item')
-                            ->insertGetId($spec_lists[$k]);
-                    }
-                }
-                $all_item_id = Db::name('goods_item')
-                    ->where('goods_id', $post['goods_id'])
-                    ->column('id');
-                $del_item_ids = array_diff($all_item_id, $new_item_id);
-                if (!empty($del_item_ids)) {
-                    //删除规格值
-                    Db::name('goods_item')
-                        ->where('goods_id', $post['goods_id'])
-                        ->where('id', 'in', $del_item_ids)
-                        ->delete();
-                }
-            }
-    
-            $newItemIds = GoodsItem::where('goods_id', $post['id'])->column('id');
-            $destroyIds = DistributionGoods::where('goods_id', $post['goods_id'])->column('id');
-    
-            // 删除原来的分销设置
-            if ($oldItemIds != $newItemIds && $destroyIds) {
-                DistributionGoods::destroy($destroyIds);
-                self::$error = '商品信息修改成功,该商品属于分销商品,请重新设置分销信息';
-            }
-            
-            Db::commit();
-            return true;
-        } catch (\Exception $e) {
-            Db::rollback();
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-
-    /**
-     * 放回仓库
-     */
-    public static function backToWarehouse($id)
-    {
-        $updateData = [
-            'id' => $id,
-            'status' => GoodsEnum::STATUS_SOLD_OUT,
-            'del' => GoodsEnum::DEL_NORMAL
-        ];
-        return Goods::update($updateData);
-    }
-
-
-    /**
-     * @notes 批量更新商品状态
-     * @param $ids
-     * @param $status
-     * @return Goods|false
-     * @author 段誉
-     * @date 2022/3/17 11:51
-     */
-    public static function setStatus($ids, $status)
-    {
-        try {
-            $result = Goods::whereIn('id', $ids)->update([
-                'status'      => $status,
-                'update_time' => time()
-            ]);
-
-            if (!$status) {
-                // 下架商品,更新商品收藏
-                event('UpdateCollect', ['goods_id' => $ids]);
-            }
-
-            return $result;
-        } catch (\Exception $e) {
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-
-    /**
-     * @notes 添加基础商品信息
-     * @param $shop_id
-     * @param $post
-     * @return mixed
-     * @throws \Exception
-     * @author 段誉
-     * @date 2022/4/7 11:55
-     */
-    public static function addGoods($shop_id, $post)
-    {
-        //算出最大最小价格
-        if ($post['spec_type'] == 1) {
-            $max_price = $post['one_price'];
-            $min_price = $post['one_price'];
-            $market_price = $post['one_market_price'];
-            $total_stock = $post['one_stock'];
-        } else { // 多规格
-            $max_price = max($post['price']);
-            $min_price = min($post['price']);
-            $min_price_key = array_search($min_price,$post['price']);
-            $market_price = $post['market_price'][$min_price_key];
-            $total_stock = array_sum($post['stock']);
-        }
-
-        // 总库存为0的商品不允许上架
-        if($post['status'] == GoodsEnum::STATUS_SHELVES && $total_stock == 0) {
-            throw new \Exception('库存为0不允许上架');
-        }
-
-        // 判断商品是否需要审核
-        $is_product_audit = Shop::where('id', $shop_id)->value('is_product_audit'); // 0-无需审核 1-需审核
-        $audit_status = $is_product_audit ? 0 : 1;
-
-        // 处理商品数据
-        $post = self::formatGoodsData($post);
-
-        //写入主表
-        $data = [
-            'type'                      => $post['type'],
-            'name'                      => trim($post['name']),
-            'code'                      => trim($post['code']) ? trim($post['code']) : create_goods_code($shop_id),
-            'shop_id'                   => $shop_id,
-            'shop_cate_id'              => $post['shop_cate_id'],
-            'first_cate_id'             => $post['first_cate_id'],
-            'second_cate_id'            => $post['second_cate_id'],
-            'third_cate_id'             => $post['third_cate_id'],
-            'unit_id'                   => $post['unit_id'],
-            'brand_id'                  => $post['brand_id'],
-            'supplier_id'               => $post['supplier_id'],
-            'status'                    => $post['status'],
-            'image'                     => $post['image'],
-            'video'                     => $post['video'] ?? '',
-            'remark'                    => $post['remark'],
-            'content'                   => $post['content'],
-            'sort'                      => $post['sort'],
-            'spec_type'                 => $post['spec_type'],
-            'max_price'                 => $max_price,
-            'min_price'                 => $min_price,
-            'market_price'              => $market_price,
-            'stock'                     => $total_stock, // 总库存
-            'express_type'              => $post['express_type'] ?? 0,
-            'express_money'             => $post['express_money'],
-            'express_template_id'       => $post['express_template_id'],
-            'is_recommend'              => $post['is_recommend'],
-            'create_time'               => time(),
-            'update_time'               => time(),
-            'stock_warn'                => $post['stock_warn'],
-            'poster'                    => isset($post['poster']) ? UrlServer::setFileUrl($post['poster']) : '',
-            'is_show_stock'             => $post['is_show_stock'],
-            'is_member'                 => $post['is_member'],
-            'audit_status'              => $audit_status,
-            'delivery_type'             => implode(',', $post['delivery_type']),
-            'after_pay'                 => $post['after_pay'] ?? 0,
-            'after_delivery'            => $post['after_delivery'] ?? 0,
-            'delivery_content'          => $post['delivery_content'] ?? '',
-        ];
-        $goods = Goods::create($data);
-        return $goods->id;
-    }
-
-
-    /**
-     * @notes 添加商品图片
-     * @param $goods_id
-     * @param $post
-     * @throws \Exception
-     * @author 段誉
-     * @date 2022/4/7 11:56
-     */
-    public static function addGoodsImage($goods_id, $post)
-    {
-        $data = [];
-        foreach ($post['goods_image'] as $k => $v) {
-            $data[] = [
-                'goods_id' => $goods_id,
-                'uri' => $v,
-            ];
-        }
-        (new GoodsImage())->saveAll($data);
-    }
-
-
-    /**
-     * @notes 添加单个规格
-     * @param $goods_id
-     * @param $post
-     * @author 段誉
-     * @date 2022/4/7 11:56
-     */
-    public static function addOneSpec($goods_id, $post)
-    {
-        //添加商品规格
-        $goods_spec_id = (new GoodsSpec())->insertGetId([
-            'goods_id' => $goods_id,
-            'name' => '默认'
-        ]);
-
-        //添加商品规格值
-        $goods_spec_value_id = (new GoodsSpecValue())->insertGetId([
-            'spec_id' => $goods_spec_id,
-            'goods_id' => $goods_id,
-            'value' => '默认'
-        ]);
-
-        if(isset($post['one_spec_image'])) {
-            $post['one_spec_image'] = str_replace(request()->domain(), '',  $post['one_spec_image']);
-        }
-        //商品sku
-        GoodsItem::create([
-            'image'             => $post['one_spec_image'] ?? $post['image'],
-            'goods_id'          => $goods_id,
-            'spec_value_ids'    => $goods_spec_value_id,
-            'spec_value_str'    => '默认',
-            'market_price'      => $post['one_market_price'],
-            'price'             => $post['one_price'],
-            'stock'             => $post['one_stock'],
-            'volume'            => $post['one_volume'],
-            'weight'            => $post['one_weight'],
-            'bar_code'          => $post['one_bar_code'],
-            'chengben_price'    => $post['one_chengben_price'],
-        ]);
-    }
-
-
-    /**
-     * @notes 添加多个规格
-     * @param $goods_id
-     * @param $post
-     * @param $spec_lists
-     * @author 段誉
-     * @date 2022/4/7 11:56
-     */
-    public static function addMoreSpec($goods_id, $post, $spec_lists)
-    {
-        // 添加规格项
-        $goods_specs = [];
-        foreach ($post['spec_name'] as $k => $v) {
-            $temp = ['goods_id' => $goods_id, 'name' => $v];
-            $goods_specs[] = $temp;
-        }
-        (new GoodsSpec())->insertAll($goods_specs);
-
-        // 规格项id及名称 例:['颜色'=>1, '尺码'=>2]
-        $goods_spec_name_key_id = GoodsSpec::where(['goods_id' => $goods_id])
-            ->where('name', 'in', $post['spec_name'])
-            ->column('id', 'name');
-
-        // 添加规格值
-        $data = [];
-        foreach ($post['spec_values'] as $k => $v) {
-            $row = explode(',', $v);
-            foreach ($row as $k2 => $v2) {
-                $temp = [
-                    'goods_id' => $goods_id,
-                    'spec_id' => $goods_spec_name_key_id[$post['spec_name'][$k]],
-                    'value' => $v2,
-                ];
-                $data[] = $temp;
-            }
-        }
-        (new GoodsSpecValue())->insertAll($data);
-
-        // 规格值id及名称   例:['红色'=>1,'蓝色'=>2,'S码'=>3,'M码'=>4]
-        $goods_spec_name_value_id = GoodsSpecValue::where(['goods_id' => $goods_id])->column('id', 'value');
-
-        // 添加SKU
-        foreach ($spec_lists as $k => $v) {
-            $spec_lists[$k]['spec_value_ids'] = '';
-            $temp = explode(',', $v['spec_value_str']); // 例:"红色,S码" => ["红色", "S码"]
-
-            // 组装SKU的spec_value_ids 例:"红色,S码" => ["红色", "S码"] => "1,3"
-            foreach ($temp as $k2 => $v2) {
-                $spec_lists[$k]['spec_value_ids'] .= $goods_spec_name_value_id[$v2] . ',';
-            }
-            $spec_lists[$k]['spec_value_ids'] = trim($spec_lists[$k]['spec_value_ids'], ',');
-            if(isset($spec_lists[$k]['spec_image'])) {
-                $spec_lists[$k]['spec_image'] = str_replace(request()->domain(), '',  $spec_lists[$k]['spec_image']);
-            }
-            $spec_lists[$k]['image'] = $spec_lists[$k]['spec_image'] ?? $post['image'];
-            $spec_lists[$k]['goods_id'] = $goods_id;
-            if(isset($spec_lists[$k]['spec_image'])) {
-                unset($spec_lists[$k]['spec_image']);
-            }
-            unset($spec_lists[$k]['spec_id']);
-            unset($spec_lists[$k]['item_id']);
-        }
-        (new GoodsItem())->insertAll($spec_lists);
-    }
-
-
-    /**
-     * @notes 格式化商品数据
-     * @param array $data
-     * @return array
-     * @author 段誉
-     * @date 2022/4/7 10:12
-     */
-    public static function formatGoodsData(array $data) : array
-    {
-        // 虚拟商品类型数据
-        if ($data['type'] == GoodsEnum::TYPE_VIRTUAL) {
-            $data['after_pay'] = !empty($data['after_pay']) ? $data['after_pay'] : 0;
-            $data['after_delivery'] = !empty($data['after_delivery']) ? $data['after_delivery'] : 0;
-            $data['delivery_content'] = !empty($data['delivery_content']) ? $data['delivery_content'] : '';
-        }
-
-        // 替换内容中图片地址
-        $domain = UrlServer::getFileUrl('/');
-        $data['content'] = str_replace($domain, '/', $data['content']);
-
-        // 运费处理
-        $data['express_money'] = $data['express_type'] == GoodsEnum::EXPRESS_TYPE_UNIFIED ? $data['express_money'] : 0;
-        $data['express_template_id'] = $data['express_type'] == GoodsEnum::EXPRESS_TYPE_TEMPLATE ? $data['express_template_id'] : 0;
-
-        return $data;
-    }
-
-}

+ 0 - 112
app/shop/logic/goods/SupplierLogic.php

@@ -1,112 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-
-namespace app\shop\logic\goods;
-
-
-use app\common\basics\Logic;
-use app\common\model\goods\Supplier;
-
-
-/**
- * 供应商
- * Class SupplierLogic
- * @package app\admin\logic
- */
-class SupplierLogic extends Logic
-{
-
-    /**
-     * Notes: 列表
-     * @param $shop_id
-     * @param $get
-     * @author 段誉(2021/4/15 10:53)
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     */
-    public static function lists($shop_id, $get)
-    {
-        $where[] = ['del', '=', 0];
-        $where[] = ['shop_id', '=', $shop_id];
-        if(isset($get['keyword']) && $get['keyword']){
-            $where[] = ['name','like','%'.$get['keyword'].'%'];
-        }
-
-        $result = Supplier::where($where)
-            ->paginate([
-                'list_rows'=> $get['limit'],
-                'page'=> $get['page']
-            ]);
-
-        return ['count' => $result->total(), 'lists' => $result->getCollection()];
-    }
-
-
-    /**
-     * Notes: 添加
-     * @param $post
-     * @author 段誉(2021/4/15 10:54)
-     * @return Supplier|\think\Model
-     */
-    public static function add($shop_id, $post)
-    {
-        return Supplier::create([
-            'shop_id'  => $shop_id,
-            'name'     => $post['name'],
-            'contact'  => $post['contact'],
-            'mobile'   => $post['mobile'],
-            'address'  => $post['address'],
-            'remark'   => $post['remark'] ?? '',
-        ]);
-    }
-
-
-    /**
-     * Notes: 编辑
-     * @param $post
-     * @author 段誉(2021/4/15 10:54)
-     * @return Supplier
-     */
-    public static function edit($shop_id, $post)
-    {
-        return Supplier::update([
-            'name'     => $post['name'],
-            'contact'  => $post['contact'],
-            'mobile'   => $post['mobile'],
-            'address'  => $post['address'],
-            'remark'   => $post['remark'] ?? '',
-        ], ['id' => $post['id'], 'shop_id' => $shop_id]);
-    }
-
-
-    /**
-     * Notes: 删除
-     * @param $id
-     * @author 段誉(2021/4/15 10:54)
-     * @return Supplier
-     */
-    public static function del($shop_id, $id)
-    {
-        return Supplier::update(['del' => 1], ['id' => $id, 'shop_id' => $shop_id]);
-    }
-
-}

+ 0 - 263
app/shop/logic/index/StatLogic.php

@@ -1,263 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-namespace app\shop\logic\index;
-
-use app\common\basics\Logic;
-use app\common\server\UrlServer;
-use app\common\enum\PayEnum;
-use think\facade\Db;
-
-/**
- * 工作台统计
- * Class StatLogic
- * @package app\admin\logic\index
- */
-class StatLogic extends Logic
-{
-    //工作台基本数据 TODO
-    public static function stat($shop_id)
-    {
-        //更新时间
-        $time = date('Y-m-d H:i:s', time());
-        //头部数据统计
-        $data = $where = [];
-        $where[] = ['pay_status', '>', PayEnum::UNPAID];
-        $where[] = ['shop_id','=',$shop_id];
-
-        //成交笔数
-        $order_num_all        = Db::name('order')
-                                ->where($where)
-                                ->count('id');
-        $order_num_yesterday  = Db::name('order')
-                                ->where($where)
-                                ->whereTime('create_time', 'yesterday')
-                                ->count('id');
-        $order_num_today      = Db::name('order')
-                                ->where($where)
-                                ->whereTime('create_time', 'today')
-                                ->count('id');
-        $order_num_change_red = 0;
-        $order_num_change_add = $order_num_today - $order_num_yesterday;
-        if($order_num_change_add < 0){
-            $order_num_change_red = abs($order_num_change_add);
-        }
-
-        //销售金额
-        $order_price_all       = Db::name('order')
-                                ->where($where)
-                                ->sum('order_amount') ?? 0;
-        $order_price_yesterday = Db::name('order')
-                                ->where($where)
-                                ->whereTime('create_time', 'yesterday')
-                                ->sum('order_amount') ?? 0;
-        $order_price_today     = Db::name('order')
-                                ->where($where)
-                                ->whereTime('create_time', 'today')
-                                ->sum('order_amount') ?? 0;
-        $order_price_change_red = 0;
-        $order_price_change_add = $order_price_today - $order_price_yesterday;
-        if($order_price_change_add < 0){
-            $order_price_change_red = abs($order_price_change_add);
-        }
-
-        $where = [];
-        $where[] = ['shop_id','=',$shop_id];
-        //进店人数
-        $add_user_all       = Db::name('shop_stat')
-                                ->where($where)
-                                ->group(['ip'])
-                                ->count('id');
-        $add_user_yesterday = Db::name('shop_stat')
-                                ->where($where)
-                                ->whereTime('create_time', 'yesterday')
-                                ->group(['ip'])
-                                ->count('id');
-        $add_user_today     = Db::name('shop_stat')
-                                ->where($where)
-                                ->whereTime('create_time', 'today')
-                                ->group(['ip'])
-                                ->count('id');
-        $add_user_change_red = 0;
-        $add_user_change_add = $add_user_today - $add_user_yesterday;
-        if($add_user_change_add < 0){
-            $add_user_change_red = abs($add_user_change_add);
-        }
-
-        //商品浏览人数
-        $visit_user_all       = Db::name('goods_click')
-                                ->where($where)
-                                ->group(['user_id'])
-                                ->count('id');
-        $visit_user_yesterday = Db::name('goods_click')
-                                ->where($where)
-                                ->whereTime('create_time', 'yesterday')
-                                ->group(['user_id'])
-                                ->count('id');
-        $visit_user_today     = Db::name('goods_click')
-                                ->where($where)
-                                ->whereTime('create_time', 'today')
-                                ->group(['user_id'])
-                                ->count('id');
-        $visit_user_change_red = 0;
-        $visit_user_change_add = $visit_user_today - $visit_user_yesterday;
-        if($visit_user_change_add < 0){
-            $visit_user_change_red = abs($visit_user_change_add);
-        }
-
-
-        
-        $data = [
-            'order_num'         => [
-                'yesterday'  => $order_num_yesterday,
-                'today'      => $order_num_today,
-                'change_add' => $order_num_change_add,
-                'change_red' => $order_num_change_red,
-                'all_num'    => $order_num_all
-            ],
-            'order_price'       => [
-                'yesterday'  => number_format($order_price_yesterday,2),
-                'today'      => number_format($order_price_today,2),
-                'change_add' => number_format($order_price_change_add,2),
-                'change_red' => number_format($order_price_change_red,2),
-                'all_price'  => number_format($order_price_all,2)
-            ],
-            'add_user_num'      => [
-                'yesterday'  => $add_user_yesterday,
-                'today'      => $add_user_today,
-                'change_add' => $add_user_change_add,
-                'change_red' => $add_user_change_red,
-                'all_num'    => $add_user_all
-            ],
-            'visit_user_num'    => [
-                'yesterday'  => $visit_user_yesterday,
-                'today'      => $visit_user_today,
-                'change_add' => $visit_user_change_add,
-                'change_red' => $visit_user_change_red,
-                'all_num'    => $visit_user_all
-            ],
-        ];
-
-
-
-               
-        return [
-            'time'      => $time,
-            'data'      => $data,
-        ];
-    }
-
-
-
-   
-    //图标数据 TODO
-    public static function graphData($shop_id)
-    {
-        //当前时间戳
-        $start_t = time();
-        //echarts图表数据
-        $echarts_order_amount = [];
-        $echarts_user_pv = [];
-        $dates = [];
-        for ($i = 15; $i >= 1; $i--) {
-            $where_start = strtotime("- ".$i."day", $start_t);
-            $dates[] = date('m-d',$where_start);
-            $start_now = strtotime(date('Y-m-d',$where_start));
-            $end_now = strtotime(date('Y-m-d 23:59:59',$where_start));
-            $amount = Db::name('order')
-                    ->where([['shop_id','=',$shop_id],['create_time','between',[$start_now, $end_now]],['pay_status','>',PayEnum::UNPAID]])
-                    ->sum('order_amount');
-            $pv = Db::name('shop_stat')
-                    ->where([['shop_id','=',$shop_id],['create_time','between',[$start_now, $end_now]]])
-                    ->group('ip')
-                    ->count('id');
-            $echarts_order_amount[] = sprintf("%.2f",substr(sprintf("%.3f", $amount), 0, -2));
-            $echarts_user_pv[] = $pv;
-        }
-        return [
-            'echarts_order_amount'  => $echarts_order_amount,
-            'echarts_user_visit'    => $echarts_user_pv,
-            'dates'                 => $dates,
-        ];
-    }
-
-
-    // 工作台商品数据
-    public static function goodsLists($get,$shop_id)
-    {
-        $goods_list = [];
-        // 销冠商品、人气商品的商品列表
-        if($get['type'] == 1){
-            // 销冠商品
-            $goods_list = Db::name('order')->alias('o')
-                    ->join('order_goods og','og.order_id = o.id')
-                    ->where([['o.shop_id','=',$shop_id],['o.pay_status','>',PayEnum::UNPAID]])
-                    ->group('og.goods_id')
-                    ->limit(5)
-                    ->order('order_amount desc')
-                    ->column('sum(o.order_amount) as order_amount, og.goods_id');
-                  
-                    foreach($goods_list as $k => $item){
-                        $goods_list[$k]['number'] = $k+1;
-                        $goods_list[$k]['order_amount'] = '¥'.number_format($item['order_amount'],2);
-                        $goods_list[$k]['image'] = '';
-                        $goods_list[$k]['name'] = '';
-
-                        $goods_info = Db::name('goods')
-                                    ->where(['id'=>$item['goods_id']])
-                                    ->field('name,image')
-                                    ->find();
-                        if($goods_info){
-                            $goods_list[$k]['image'] = UrlServer::getFileUrl($goods_info['image']);
-                            $goods_list[$k]['name'] = $goods_info['name'];
-                        }
-                    }
-        }else{
-            // 人气商品
-            $goods_list = Db::name('goods_click')
-                                ->where([['shop_id','=',$shop_id]])
-                                ->group(['goods_id'])
-                                ->field('goods_id,count(DISTINCT user_id) as visited_num')
-                                ->order('visited_num desc')
-                                ->limit(5)
-                                ->select()
-                                ->toArray();
-            
-            $num = 0;
-            foreach($goods_list as $k => $item){
-                if($item['visited_num']){
-                    $num++;
-                    $goods_list[$k]['number'] = $num;
-                    $goods_list[$k]['logo'] = $goods_list[$k]['name'] = '';
-                    $goods = Db::name('goods')
-                            ->where(['id'=>$item['goods_id']])
-                            ->field('name,image')
-                            ->find();
-                    if($goods){
-                        $goods_list[$k]['image'] = UrlServer::getFileUrl($goods['image']);
-                        $goods_list[$k]['name'] = $goods['name'];
-                    }
-                }else{
-                    unset($goods_list[$k]);
-                }
-            }
-        }
-        return ['count'=>0,'lists'=>$goods_list];
-    }
-}

+ 0 - 103
app/shop/logic/kefu/KefuLangLogic.php

@@ -1,103 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop100%开源免费商用商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | 开源版本可自由商用,可去除界面版权logo
-// | 商业版本务必购买商业授权,以免引起法律纠纷
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop团队 版权所有 拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshopTeam
-// +----------------------------------------------------------------------
-namespace app\shop\logic\kefu;
-
-use app\common\model\kefu\KefuLang;
-
-/**
- * 客服术语逻辑层
- * Class KefuLangLogic
- * @package app\admin\logic\kefu
- */
-class KefuLangLogic
-{
-
-    /**
-     * @notes 获取列表
-     * @param $limit
-     * @param $page
-     * @return array
-     * @throws \think\db\exception\DbException
-     * @author cjhao
-     * @date 2021/11/29 15:11
-     */
-    public static function lists(int $shop_id,int $limit,int $page)
-    {
-        $list = KefuLang::where(['shop_id'=>$shop_id])->order('sort asc')->paginate([
-                'list_rows' => $limit,
-                'page'      => $page,
-            ]);
-        return ['count' => $list->total(), 'lists' => $list->getCollection()];
-    }
-
-
-    /**
-     * @notes 新增话术
-     * @param $post
-     * @return bool
-     * @author cjhao
-     * @date 2021/11/29 15:54
-     */
-    public static function add(int $shop_id,array $post)
-    {
-        $kefu_lang = new KefuLang();
-        $kefu_lang->shop_id = $shop_id;
-        $kefu_lang->title   = $post['title'];
-        $kefu_lang->content = $post['content'];
-        $kefu_lang->sort    = $post['sort'];
-        return $kefu_lang->save();
-    }
-
-    /**
-     * @notes 编辑话术
-     * @param $post
-     * @return bool
-     * @author cjhao
-     * @date 2021/11/29 15:59
-     */
-    public static function edit(array $post){
-        return KefuLang::update($post);
-    }
-
-
-    /**
-     * @notes 获取话术
-     * @param $id
-     * @return array|\think\Model|null
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author cjhao
-     * @date 2021/11/29 16:02
-     */
-    public static function detail(int $shop_id,int $id){
-        return KefuLang::where(['id'=>$id,'shop_id'=>$shop_id])->find();
-    }
-
-    /**
-     * @notes 删除话术
-     * @param int $id
-     * @return bool
-     * @author cjhao
-     * @date 2021/11/29 16:11
-     */
-    public static function del(int $shop_id,int $id){
-        return KefuLang::where(['id'=>$id,'shop_id'=>$shop_id])->delete();
-    }
-}

+ 0 - 242
app/shop/logic/kefu/KefuLogic.php

@@ -1,242 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-
-namespace app\shop\logic\kefu;
-
-use app\common\basics\Logic;
-use app\common\enum\KefuEnum;
-use app\common\logic\ChatLogic;
-use app\common\model\Client_;
-use app\common\model\kefu\Kefu;
-use app\common\model\shop\ShopAdmin;
-use app\common\model\shop\ShopRole;
-use app\common\server\UrlServer;
-use app\kefuapi\logic\LoginLogic;
-
-
-/** 客服逻辑
- * Class KefuLogic
- * @package app\shop\logic\kefu
- */
-class KefuLogic extends Logic
-{
-
-    /**
-     * @notes 客服列表
-     * @param $get
-     * @return array
-     * @author 段誉
-     * @date 2021/11/26 18:44
-     */
-    public static function getLists($get, $shop_id)
-    {
-        $result = (new Kefu())->alias('k')
-            ->field("k.*,a.account")
-            ->join('shop_admin a', 'a.id = k.admin_id')
-            ->where(['a.del' => 0, 'k.del' => 0, 'k.shop_id' => $shop_id])
-            ->order('sort asc')->paginate([
-                'list_rows' => $get['limit'],
-                'page' => $get['page'],
-            ]);
-
-        foreach ($result as $value) {
-            $value['avatar'] = empty($value['avatar']) ? "" : UrlServer::getFileUrl($value['avatar']);
-        }
-
-        return ['count' => $result->total(), 'lists' => $result->getCollection()];
-    }
-
-
-    /**
-     * @notes 添加客服
-     * @param $post
-     * @param $shop_id
-     * @return Kefu|false|\think\Model
-     * @author 段誉
-     * @date 2021/11/27 11:38
-     *
-     */
-    public static function add($post, $shop_id)
-    {
-        try {
-            return (new Kefu())->insertKefu($post, $shop_id);
-        } catch (\Exception $e) {
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-
-    /**
-     * @notes 编辑客服
-     * @param $post
-     * @param $shop_id
-     * @return Kefu|false
-     * @author 段誉
-     * @date 2021/11/27 10:44
-     */
-    public static function edit($post, $shop_id)
-    {
-        try {
-
-            if ($post['disable'] == 1) {
-                ChatLogic::setChatDisable($shop_id, $post['id']);
-            }
-
-            return (new Kefu())->updateKefu($post['id'], $post, $shop_id);
-
-        } catch (\Exception $e) {
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-
-    /**
-     * @notes 详情
-     * @param $id
-     * @param $shop_id
-     * @return mixed
-     * @author 段誉
-     * @date 2021/11/27 10:44
-     */
-    public static function detail($id, $shop_id)
-    {
-        $detail = (new Kefu())->alias('k')
-            ->field("k.*, a.account, a.name")
-            ->join('shop_admin a', 'a.id = k.admin_id')
-            ->where(['k.id' => $id, 'k.shop_id' => $shop_id])
-            ->findOrEmpty();
-
-        $detail['avatar'] = !empty($detail['avatar']) ? UrlServer::getFileUrl($detail['avatar']) : '';
-       return $detail;
-    }
-
-
-    /**
-     * @notes 删除客服
-     * @param $postq
-     * @param $shop_id
-     * @return Kefu
-     * @author 段誉
-     * @date 2021/11/27 10:48
-     */
-    public static function del($post, $shop_id)
-    {
-        return (new Kefu())->delKefu($post['id'], $shop_id);
-    }
-
-
-    /**
-     * @notes 管理员列表
-     * @param $get
-     * @param $shop_id
-     * @return array
-     * @throws \think\db\exception\DbException
-     * @author 段誉
-     * @date 2021/11/26 18:00
-     */
-    public static function getAdminLists($get, $shop_id)
-    {
-        // 角色名称
-        $role_column = (new ShopRole())->getNameColumn();
-
-        // 已有客服列表
-        $kefu = (new Kefu())->where(['del' => 0, 'shop_id' => $shop_id])->column("admin_id");
-
-        // 查询条件
-        $where[] = ['del', '=', 0];
-        $where[] = ['id', 'not in', $kefu];
-        $where[] = ['shop_id', '=', $shop_id];
-        if (isset($get['role_id']) && $get['role_id'] != '') {
-            $where[] = ['role_id', '=', $get['role_id']];
-        }
-        if (isset($get['name']) && $get['name'] != '') {
-            $where[] = ['name', 'like', "%{$get['name']}%"];
-        }
-
-        $result = (new ShopAdmin())->where($where)
-            ->hidden(['password', 'salt'])
-            ->paginate([
-                'list_rows' => $get['limit'],
-                'page' => $get['page'],
-            ]);
-
-        foreach ($result as $k => $item) {
-            if ($item['root'] == 1) {
-                $role = '超级管理员';
-            } else {
-                $role = $role_column[$item['role_id']] ?? '';
-            }
-            $result[$k]['role'] = $role;
-        }
-        return ['count' => $result->total(), 'lists' => $result->getCollection()];
-    }
-
-
-    /**
-     * @notes 设置客服状态
-     * @param $post
-     * @param $shop_id
-     * @return Kefu
-     * @author 段誉
-     * @date 2021/11/26 18:32
-     */
-    public static function setStatus($post, $shop_id)
-    {
-        if ($post['disable'] == 1) {
-            ChatLogic::setChatDisable($shop_id, $post['id']);
-        }
-        return (new Kefu())->updateStatus($post['id'], $post['disable'], $shop_id);
-    }
-
-
-    /**
-     * @notes 登录工作台
-     * @param $id
-     * @param $shop_id
-     * @return false|string
-     * @author 段誉
-     * @date 2021/12/20 10:45
-     */
-    public static function login($id, $shop_id)
-    {
-        try{
-            $kefu = (new ShopAdmin())->alias('a')
-                ->field(['k.id', 'k.nickname', 'k.avatar', 'k.shop_id', 'a.account'])
-                ->join('kefu k', 'a.id = k.admin_id and a.shop_id = k.shop_id')
-                ->where(['k.id' => $id, 'k.del' => 0, 'k.shop_id' => $shop_id])
-                ->findOrEmpty()->toArray();
-
-            if(empty($kefu)) {
-                throw new \Exception('该客服信息缺失');
-            }
-
-            $token = LoginLogic::createSession($kefu['id'], $shop_id, Client_::pc);
-
-            return request()->domain() . '/kefu?token='. $token . '&type=' . KefuEnum::TYPE_SHOP;
-
-        } catch(\Exception $e) {
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-
-}

+ 0 - 196
app/shop/logic/live/LiveGoodsLogic.php

@@ -1,196 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop100%开源免费商用商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | 开源版本可自由商用,可去除界面版权logo
-// | 商业版本务必购买商业授权,以免引起法律纠纷
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop团队 版权所有 拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshopTeam
-// +----------------------------------------------------------------------
-namespace app\shop\logic\live;
-
-use app\common\basics\Logic;
-use app\common\enum\LiveGoodsEnum;
-use app\common\model\live\LiveGoods;
-use app\common\server\FileServer;
-use app\common\server\UrlServer;
-use app\common\server\WxMnpLiveServer;
-use think\facade\Db;
-
-
-/**
- * 直播商品逻辑层
- * Class LiveGoodsLogic
- * @package app\adminapi\logic\live
- */
-class LiveGoodsLogic extends Logic
-{
-
-    /**
-     * @notes 直播商品列表
-     * @param $params
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2023/2/15 19:00
-     */
-    public static function lists($params)
-    {
-        $where[] = ['del', '=', 0];
-        $where[] = ['shop_id', '=', $params['shop_id']];
-        if (!empty($params['goods_name'])) {
-            $where[] = ['name', 'like', '%' . $params['goods_name'] . '%'];
-        }
-
-        if (!empty($params['status'])) {
-            if ($params['status'] == 'ing') {
-                $where[] = ['sys_audit_status', 'in', [
-                    LiveGoodsEnum::SYS_AUDIT_STATUS_WAIT_PLATFORM,
-                    LiveGoodsEnum::SYS_AUDIT_STATUS_WAIT_WECHAT
-                ]];
-            }
-            if ($params['status'] == 'success') {
-                $where[] = ['sys_audit_status', '=', LiveGoodsEnum::SYS_AUDIT_STATUS_SUCCESS];
-            }
-            if ($params['status'] == 'fail') {
-                $where[] = ['sys_audit_status', '=', LiveGoodsEnum::SYS_AUDIT_STATUS_FAIL];
-            }
-        }
-
-        $count = LiveGoods::where($where)->count();
-        $lists = LiveGoods::where($where)
-            ->order(['id' => 'desc'])
-            ->page($params['page'], $params['limit'])
-            ->append(['audit_status_text', 'price_text', 'goods_stock'])
-            ->select()->toArray();
-
-        foreach ($lists as &$item) {
-            $item['cover_img'] = UrlServer::getFileUrl($item['cover_img']);
-        }
-        return ['count' => $count, 'lists' => $lists];
-    }
-
-
-    /**
-     * @notes 添加直播商品
-     * @param array $params
-     * @return bool
-     * @throws \GuzzleHttp\Exception\GuzzleException
-     * @author 段誉
-     * @date 2023/2/15 18:26
-     */
-    public static function add(array $params)
-    {
-        try {
-            $price = 0;
-            $price2 = 0;
-            switch ($params['price_type']) {
-                case LiveGoodsEnum::PRICE_ONE:
-                    $price = $params['price'];
-                    break;
-                case LiveGoodsEnum::PRICE_RANGE:
-                    $price = $params['section_price_start'];
-                    $price2 = $params['section_price_end'];
-                    break;
-                case LiveGoodsEnum::PRICE_DISCOUNT:
-                    $price = $params['discount_price_start'];
-                    $price2 = $params['discount_price_end'];
-                    break;
-            }
-
-            $data = [
-                'shop_id' => $params['shop_id'],
-                'source_type' => LiveGoodsEnum::SOURCE_TYPE_SELF,
-                'name' => $params['name'],
-                'price_type' => $params['price_type'],
-                'price' => $price,
-                'price2' => $price2,
-                'url' => $params['url'],
-                'cover_img_url' => FileServer::wechatLiveMaterial($params['cover_img']),
-                'cover_img' => UrlServer::setFileUrl($params['cover_img']),
-            ];
-
-            if (isset($params['source_type']) && $params['source_type'] == LiveGoodsEnum::SOURCE_TYPE_GOODS) {
-                $data['source_id'] = $params['source_id'];
-                $data['source_type'] = LiveGoodsEnum::SOURCE_TYPE_GOODS;
-            }
-
-            LiveGoods::create($data);
-            return true;
-        } catch (\Exception $e) {
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-
-
-    /**
-     * @notes 直播商品详情
-     * @param $id
-     * @return array
-     * @author 段誉
-     * @date 2023/2/16 10:42
-     */
-    public static function detail($params)
-    {
-        $detail = LiveGoods::where(['id' => $params['id'], 'shop_id' => $params['shop_id']])
-            ->append(['price_type_text', 'price_tips', 'source_type_text', 'audit_status_text'])
-            ->findOrEmpty()->toArray();
-        $detail['cover_img'] = UrlServer::getFileUrl($detail['cover_img']);
-        return $detail;
-    }
-
-
-    /**
-     * @notes 删除直播商品
-     * @param array $params
-     * @return bool|string
-     * @author 段誉
-     * @date 2023/2/16 10:37
-     */
-    public static function del(array $params)
-    {
-        Db::startTrans();
-        try {
-            $goods = LiveGoods::findOrEmpty($params['id'])->toArray();
-            if ($goods['sys_audit_status'] < LiveGoodsEnum::SYS_AUDIT_STATUS_WAIT_WECHAT) {
-                throw new \Exception('当前商品暂不可删除');
-            }
-
-            $where = [
-                'id' => $params['id'],
-                'shop_id' => $params['shop_id']
-            ];
-            LiveGoods::where($where)->update([
-                'del' => 1,
-                'update_time' => time()
-            ]);
-
-            // 删除微信商品库
-            if (!empty($goods['wx_goods_id'])) {
-                (new WxMnpLiveServer())->handle('delGoods', $goods['wx_goods_id']);
-            }
-
-            Db::commit();
-            return true;
-        } catch (\Exception $e) {
-            Db::rollback();
-            return $e->getMessage();
-        }
-    }
-
-
-
-}

+ 0 - 325
app/shop/logic/live/LiveRoomLogic.php

@@ -1,325 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop100%开源免费商用商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | 开源版本可自由商用,可去除界面版权logo
-// | 商业版本务必购买商业授权,以免引起法律纠纷
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop团队 版权所有 拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshopTeam
-// +----------------------------------------------------------------------
-namespace app\shop\logic\live;
-
-use app\common\basics\Logic;
-use app\common\enum\LiveRoomEnum;
-use app\common\model\live\LiveGoods;
-use app\common\model\live\LiveRoom;
-use app\common\server\FileServer;
-use app\common\server\UrlServer;
-use app\common\server\WxMnpLiveServer;
-use think\facade\Db;
-
-
-/**
- * 直播间逻辑层
- * Class LiveRoomLogic
- * @package app\adminapi\logic\live
- */
-class LiveRoomLogic extends Logic
-{
-
-    /**
-     * @notes 直播间列表
-     * @param $params
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @author 段誉
-     * @date 2023/2/15 19:00
-     */
-    public static function lists($params)
-    {
-        $where[] = ['del', '=', 0];
-        $where[] = ['shop_id', '=', $params['shop_id']];
-        if (isset($params['status']) && in_array($params['status'], LiveRoomEnum::AUDIT_STATUS)) {
-            $where[] = ['audit_status', '=', $params['status']];
-        }
-        if (!empty($params['live_info'])) {
-            $where[] = ['name|anchor_name', 'like', '%' . $params['live_info'] . '%'];
-        }
-        if (!empty($params['live_status'])) {
-            $where[] = ['live_status', '=', $params['live_status']];
-        }
-        // 创建时间
-        if (isset($params['start_time']) && !empty($params['start_time'])) {
-            $where[] = ['start_time', '>=', strtotime($params['start_time'])];
-        }
-        if (isset($params['end_time']) && !empty($params['end_time'])) {
-            $where[] = ['end_time', '<=', strtotime($params['end_time'])];
-        }
-
-        $count = LiveRoom::where($where)->count();
-        $lists = LiveRoom::where($where)
-            ->order(['id' => 'desc'])
-            ->page($params['page'], $params['limit'])
-            ->append(['live_time_text', 'live_status_text', 'audit_status_text'])
-            ->select()->toArray();
-
-        foreach ($lists as &$item) {
-            $item['share_img'] = UrlServer::getFileUrl($item['share_img']);
-            $item['feeds_img'] = UrlServer::getFileUrl($item['feeds_img']);
-            $item['cover_img'] = UrlServer::getFileUrl($item['cover_img']);
-        }
-        return ['count' => $count, 'lists' => $lists];
-    }
-
-
-    /**
-     * @notes 添加直播间
-     * @param array $params
-     * @return bool
-     * @throws \GuzzleHttp\Exception\GuzzleException
-     * @author 段誉
-     * @date 2023/2/15 18:26
-     */
-    public static function add(array $params)
-    {
-        try {
-            $params = self::formatParams($params);
-            LiveRoom::create([
-                'shop_id' => $params['shop_id'],
-                'name' => $params['name'],
-                'type' => $params['type'],
-                'start_time' => $params['start_time'],
-                'end_time' => $params['end_time'],
-                'anchor_name' => $params['anchor_name'],
-                'anchor_wechat' => $params['anchor_wechat'],
-                'share_img' => UrlServer::setFileUrl($params['share_img']),
-                'feeds_img' => UrlServer::setFileUrl($params['feeds_img']),
-                'cover_img' => UrlServer::setFileUrl($params['cover_img']),
-                'share_img_id' => FileServer::wechatLiveMaterial($params['share_img']),
-                'feeds_img_id' => FileServer::wechatLiveMaterial($params['feeds_img']),
-                'cover_img_id' => FileServer::wechatLiveMaterial($params['cover_img']),
-                'is_feeds_public' => $params['is_feeds_public'],
-                'close_like' => $params['close_like'],
-                'close_goods' => $params['close_goods'],
-                'close_comment' => $params['close_comment'],
-                'close_replay' => $params['close_replay'],
-                'close_share' => $params['close_share'],
-                'close_kf' => $params['close_kf'],
-            ]);
-            return true;
-        } catch (\Exception $e) {
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-
-    /**
-     * @notes 编辑
-     * @param array $params
-     * @return bool
-     * @throws \GuzzleHttp\Exception\GuzzleException
-     * @author 段誉
-     * @date 2023/2/16 10:34
-     */
-    public static function edit(array $params)
-    {
-        Db::startTrans();
-        try {
-            $params = self::formatParams($params);
-            $room = LiveRoom::findOrEmpty($params['id']);
-
-            $updateData = [
-                'name' => $params['name'],
-                'type' => $params['type'],
-                'start_time' => $params['start_time'],
-                'end_time' => $params['end_time'],
-                'anchor_name' => $params['anchor_name'],
-                'anchor_wechat' => $params['anchor_wechat'],
-                'share_img' => UrlServer::setFileUrl($params['share_img']),
-                'feeds_img' => UrlServer::setFileUrl($params['feeds_img']),
-                'cover_img' => UrlServer::setFileUrl($params['cover_img']),
-                'share_img_id' => FileServer::wechatLiveMaterial($params['share_img']),
-                'feeds_img_id' => FileServer::wechatLiveMaterial($params['feeds_img']),
-                'cover_img_id' => FileServer::wechatLiveMaterial($params['cover_img']),
-                'is_feeds_public' => $params['is_feeds_public'],
-                'close_like' => $params['close_like'],
-                'close_goods' => $params['close_goods'],
-                'close_comment' => $params['close_comment'],
-                'close_replay' => $params['close_replay'],
-                'close_share' => $params['close_share'],
-                'close_kf' => $params['close_kf'],
-            ];
-
-            if ($room['audit_status'] == LiveRoomEnum::AUDIT_STATUS_FAIL) {
-                $updateData['audit_status'] = LiveRoomEnum::AUDIT_STATUS_WAIT;
-            }
-
-            LiveRoom::where(['id' => $params['id']])->update($updateData);
-
-            if (!empty($room['wx_room_id'])) {
-                (new WxMnpLiveServer())->handle('editRoom', [
-                    'id' => $room['wx_room_id'],
-                    'name' => $room['name'],
-                    'startTime' => $room['start_time'],
-                    'endTime' => $room['end_time'],
-                    'anchorName' => $room['anchor_name'],
-                    'anchorWechat' => $room['anchor_wechat'],
-                    'createrWechat' => $room['anchor_wechat'],
-                    'shareImg' => $room['share_img_id'],
-                    'feedsImg' => $room['feeds_img_id'],
-                    'coverImg' => $room['cover_img_id'],
-                    'type' => $room['type'],
-                    'isFeedsPublic' => $room['is_feeds_public'],
-                    'closeLike' => $room['close_like'],
-                    'closeGoods' => $room['close_goods'],
-                    'closeComment' => $room['close_comment'],
-                    'closeReplay' => $room['close_replay'],
-                    'closeShare' => $room['close_share'],
-                    'closeKf' => $room['close_kf'],
-                ]);
-            }
-
-            Db::commit();
-            return true;
-        } catch (\Exception $e) {
-            Db::rollback();
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-
-    /**
-     * @notes 直播间详情
-     * @param $id
-     * @return array
-     * @author 段誉
-     * @date 2023/2/16 10:42
-     */
-    public static function detail($id)
-    {
-        $detail = LiveRoom::where(['id' => $id])->findOrEmpty()->toArray();
-        $detail['start_time'] = date('Y-m-d H:i:s', $detail['start_time']);
-        $detail['end_time'] = date('Y-m-d H:i:s', $detail['end_time']);
-        $detail['share_img'] = UrlServer::getFileUrl($detail['share_img']);
-        $detail['feeds_img'] = UrlServer::getFileUrl($detail['feeds_img']);
-        $detail['cover_img'] = UrlServer::getFileUrl($detail['cover_img']);
-        return $detail;
-    }
-
-
-    /**
-     * @notes 删除直播间
-     * @param array $params
-     * @return bool|string
-     * @author 段誉
-     * @date 2023/2/16 10:37
-     */
-    public static function del(array $params)
-    {
-        Db::startTrans();
-        try {
-            $where = [
-                'id' => $params['id'],
-                'shop_id' => $params['shop_id']
-            ];
-            LiveRoom::where($where)->update([
-                'del' => 1,
-                'update_time' => time()
-            ]);
-
-            $room = LiveRoom::findOrEmpty($params['id']);
-            if (!empty($room['wx_room_id'])) {
-                (new WxMnpLiveServer())->handle('delRoom', $room['wx_room_id']);
-            }
-            Db::commit();
-            return true;
-        } catch (\Exception $e) {
-            Db::rollback();
-            return $e->getMessage();
-        }
-    }
-
-
-    /**
-     * @notes 格式化参数
-     * @param $params
-     * @return mixed
-     * @author 段誉
-     * @date 2023/2/15 16:04
-     */
-    public static function formatParams($params)
-    {
-        if (!empty($params['start_time'])) {
-            $params['start_time'] = strtotime($params['start_time']);
-        }
-
-        if (!empty($params['end_time'])) {
-            $params['end_time'] = strtotime($params['end_time']);
-        }
-
-        $params['is_feeds_public'] = empty($params['is_feeds_public']) ? 0 : 1;
-        $params['close_like'] = empty($params['close_like']) ? 1 : 0;
-        $params['close_goods'] = empty($params['close_goods']) ? 1 : 0;
-        $params['close_comment'] = empty($params['close_comment']) ? 1 : 0;
-        $params['close_replay'] = empty($params['close_replay']) ? 1 : 0;
-        $params['close_share'] = empty($params['close_share']) ? 1 : 0;
-        $params['close_kf'] = empty($params['close_kf']) ? 1 : 0;
-
-        return $params;
-    }
-
-
-    /**
-     * @notes 导入商品
-     * @param $params
-     * @return bool
-     * @throws \GuzzleHttp\Exception\GuzzleException
-     * @author 段誉
-     * @date 2023/2/17 14:25
-     */
-    public static function importGoods($params)
-    {
-        try {
-            if (empty($params['id'])) {
-                throw new \Exception('直播间参数缺失');
-            }
-
-            if (empty($params['goods_ids'])) {
-                throw new \Exception('请选择直播商品');
-            }
-
-            $room = LiveRoom::where(['id' => $params['id']])->findOrEmpty();
-            if (empty($room['wx_room_id'])) {
-                throw new  \Exception('当前直播间暂不可导入商品');
-            }
-
-            $goods_ids = LiveGoods::whereIn('id', $params['goods_ids'])
-                ->column('wx_goods_id');
-
-            //addGoods
-            (new WxMnpLiveServer())->handle('importGoods', [
-                'ids' => $goods_ids,
-                'roomId' => $room['wx_room_id']
-            ]);
-
-            return true;
-        } catch (\Exception $e) {
-            self::$error = $e->getMessage();
-            return false;
-        }
-    }
-
-}

+ 0 - 145
app/shop/logic/order/DeliveryBatchLogic.php

@@ -1,145 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeshop开源商城系统
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | gitee下载:https://gitee.com/likeshop_gitee
-// | github下载:https://github.com/likeshop-github
-// | 访问官网:https://www.likeshop.cn
-// | 访问社区:https://home.likeshop.cn
-// | 访问手册:http://doc.likeshop.cn
-// | 微信公众号:likeshop技术社区
-// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
-// |  likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
-// | 禁止对系统程序代码以任何目的,任何形式的再发布
-// | likeshop团队版权所有并拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeshop.cn.team
-// +----------------------------------------------------------------------
-namespace app\shop\logic\order;
-
-use app\common\basics\Logic;
-use app\common\model\Express;
-use app\common\model\order\DeliveryBatch;
-use app\common\model\order\DeliveryBatchInfo;
-use app\common\model\order\Order;
-use app\shopapi\validate\OrderValidate;
-use think\facade\Db;
-
-class DeliveryBatchLogic extends Logic
-{
-    static function lists($get)
-    {
-        $lists = DeliveryBatch::where('shop_id', session('shop_info.shop_id'))
-            ->order('id desc')
-            ->paginate([
-                'page'      => $get['page'] ?? 1,
-                'list_rows' => $get['limit'] ?? 10,
-                'var_page'  => 'page'
-            ])->toArray();
-        
-        return [ 'count'=>$lists['total'], 'lists'=>$lists['data'] ];
-    }
-    
-    static function detail($id)
-    {
-        return DeliveryBatch::findOrEmpty($id)->append([ 'progress' ])->toArray();
-    }
-    
-    static function getFailInfoLists($id)
-    {
-        return DeliveryBatchInfo::where('batch_id', $id)->where('status', 2)->select()->toArray();
-    }
-    
-    static function delivery($detail)
-    {
-        if ($detail['status'] == 1) {
-            return true;
-        }
-        $infoLists = DeliveryBatchInfo::where('batch_id', $detail['id'])->select()->toArray();
-        foreach ($infoLists as $info) {
-            // 订单
-            $order = Order::where('order_sn', $info['sn'])->find();
-            if (empty($order['id'])) {
-                DeliveryBatch::update([ 'fail' => Db::raw('fail+1') ], [ [ 'id' ,'=', $detail['id'] ] ]);
-                DeliveryBatchInfo::update([ 'status' => 2, 'fail_content' => '订单不存在' ], [ [ 'id', '=', $info['id'] ] ]);
-                continue;
-            }
-            // 快递
-            $express = Express::where('name', $info['express_name'])->find();
-            if (empty($express['id'])) {
-                DeliveryBatch::update([ 'fail' => Db::raw('fail+1') ], [ [ 'id' ,'=', $detail['id'] ] ]);
-                DeliveryBatchInfo::update([ 'status' => 2, 'fail_content' => '快递公司不存在' ], [ [ 'id', '=', $info['id'] ] ]);
-                continue;
-            }
-            // 检测
-            $validate = new orderValidate;
-            $data = [
-                'id'            => $order['id'],
-                'send_type'     => 1,
-                'shipping_id'   => $express['id'],
-                'invoice_no'    => $info['express_no'],
-                'shop_id'       => session('shop_info.shop_id'),
-                'order_id'      => $order['id'],
-            ];
-            if (true !== $validate->scene('delivery')->check($data)) {
-                DeliveryBatch::update([ 'fail' => Db::raw('fail+1') ], [ [ 'id' ,'=', $detail['id'] ] ]);
-                DeliveryBatchInfo::update([ 'status' => 2, 'fail_content' => $validate->getError() ], [ [ 'id', '=', $info['id'] ] ]);
-                continue;
-            }
-            
-            // 发货
-            OrderLogic::deliveryHandle($data, session('admin_info.id'));
-            // 成功
-            DeliveryBatch::update([ 'success' => Db::raw('success+1') ], [ [ 'id' ,'=', $detail['id'] ] ]);
-            DeliveryBatchInfo::update([ 'status' => 1 ], [ [ 'id', '=', $info['id'] ] ]);
-        }
-        
-        // 更新 已执行导入
-        DeliveryBatch::update([ 'status' => 1 ], [ [ 'id' ,'=', $detail['id'] ] ]);
-        
-        return true;
-    }
-    
-    static function importLists(array $lists, $filename)
-    {
-        try {
-            Db::startTrans();
-            
-            array_shift($lists);
-            $lists  = array_values($lists);
-            $nums   = count($lists);
-            
-            $batch = DeliveryBatch::create([
-                'filename'  => $filename,
-                'nums'      => $nums,
-                'success'   => 0,
-                'fail'      => 0,
-                'shop_id'   => session('shop_info.shop_id')
-            ]);
-            
-            $batchInfoArrays    = [];
-            
-            foreach ($lists as $info) {
-                
-                $batchInfoArrays[] = [
-                    'batch_id'      => $batch->id,
-                    'sn'            => trim($info['A']),
-                    'express_name'  => trim($info['B']),
-                    'express_no'    => trim($info['C']),
-                    'status'        => 0,
-                    'fail_content'  => '',
-                    'shop_id'   => session('shop_info.shop_id')
-                ];
-            }
-            
-            (new DeliveryBatchInfo())->saveAll($batchInfoArrays);
-            
-            Db::commit();
-            return [ 'id' => $batch->id ];
-        } catch(\Throwable $e) {
-            Db::rollback();
-            return $e->getMessage();
-        }
-    }
-}

Някои файлове не бяха показани, защото твърде много файлове са промени