lyh 3 роки тому
батько
коміт
9a79f1b109

+ 11 - 12
app/admin/controller/Ajax.php

@@ -38,7 +38,7 @@ class Ajax extends AdminController
             return json($cacheData);
         }
         $menuService = new MenuService(session('admin.id'));
-        $data = [
+        $data        = [
             'logoInfo' => [
                 'title' => sysconfig('site', 'logo_title'),
                 'image' => sysconfig('site', 'logo_image'),
@@ -81,8 +81,6 @@ class Ajax extends AdminController
             'file|文件'              => "require|file|fileExt:{$uploadConfig['upload_allow_ext']}|fileSize:{$uploadConfig['upload_allow_size']}",
         ];
 
-
-
         $this->validate($data, $rule);
         try {
             $upload = Uploadfile::instance()
@@ -91,8 +89,9 @@ class Ajax extends AdminController
                 ->setFile($data['file'])
                 ->save();
         } catch (\Exception $e) {
-            $this->error($e->getMessage());
+            $this->error($e->getMessage() . $e->getLine(). $e->getFile());
         }
+
         if ($upload['save'] == true) {
             $this->success($upload['msg'], ['url' => $upload['url']]);
         } else {
@@ -107,7 +106,7 @@ class Ajax extends AdminController
     public function uploadEditor()
     {
         $this->checkPostRequest();
-        $data = [
+        $data         = [
             'upload_type' => $this->request->post('upload_type'),
             'file'        => $this->request->file('upload'),
         ];
@@ -151,24 +150,24 @@ class Ajax extends AdminController
      */
     public function getUploadFiles()
     {
-        $get = $this->request->get();
-        $page = isset($get['page']) && !empty($get['page']) ? $get['page'] : 1;
-        $limit = isset($get['limit']) && !empty($get['limit']) ? $get['limit'] : 10;
-        $title = isset($get['title']) && !empty($get['title']) ? $get['title'] : null;
+        $get         = $this->request->get();
+        $page        = isset($get['page']) && !empty($get['page']) ? $get['page'] : 1;
+        $limit       = isset($get['limit']) && !empty($get['limit']) ? $get['limit'] : 10;
+        $title       = isset($get['title']) && !empty($get['title']) ? $get['title'] : null;
         $this->model = new SystemUploadfile();
-        $count = $this->model
+        $count       = $this->model
             ->where(function (Query $query) use ($title) {
                 !empty($title) && $query->where('original_name', 'like', "%{$title}%");
             })
             ->count();
-        $list = $this->model
+        $list        = $this->model
             ->where(function (Query $query) use ($title) {
                 !empty($title) && $query->where('original_name', 'like', "%{$title}%");
             })
             ->page($page, $limit)
             ->order($this->sort)
             ->select();
-        $data = [
+        $data        = [
             'code'  => 0,
             'msg'   => '',
             'count' => $count,

+ 46 - 76
app/admin/controller/mall/Goods.php

@@ -3,6 +3,10 @@
 
 namespace app\admin\controller\mall;
 
+use app\admin\logic\ShopGoodsLogic;
+use app\admin\logic\ShopGoodsTypeLogic;
+use app\admin\logic\ShopHotKeywordsLogic;
+use app\admin\logic\ShopSupplierLogic;
 use app\common\model\ShopGoods as ShopGoods;
 use app\common\model\ShopGoodsSpec;
 use app\admin\traits\Curd;
@@ -27,7 +31,7 @@ class Goods extends AdminController
 
     protected $relationSearch = true;
 
-    public function __construct (App $app)
+    public function __construct(App $app)
     {
         parent::__construct($app);
         $this->model = new ShopGoods();
@@ -36,7 +40,7 @@ class Goods extends AdminController
     /**
      * @NodeAnotation(title="列表")
      */
-    public function index ()
+    public function index()
     {
         if ($this->request->isAjax()) {
             if (input('selectFields')) {
@@ -44,60 +48,26 @@ class Goods extends AdminController
             }
             list($page, $limit, $where) = $this->buildTableParames();
 
-//            foreach ($where as $key=>$val){
-//                if ($val[0] == 'status'){
-//                    $where[$key][0] = 'o.status';
-//                }
-//            }
-//            return $where;
 
-            $count = $this->model
-                ->withJoin(['supplier','cate'], 'LEFT')
-                ->where($where)
-                ->count();
+            list($count, $list) = ShopGoodsLogic::getList($page, $limit, $where);
 
-            $list = $this->model
-                ->withJoin(['supplier','cate'], 'LEFT')
-                ->where($where)
-                ->page($page, $limit)
-                ->order('goods_id desc')
-                ->select()->toArray();
-            foreach ($list as $k => &$v) {
-                $v['id'] = $v['goods_id'];
-//                $v['supplier'] = Db::name('shop_supplier')->where(['id'=>$v['supplier']])->value('name');
-                $v['goods_type'] = Db::name('shop_goods_type')->where(['id'=>$v['goods_type']])->value('name');
-            }
             $data = [
-                'code' => 0,
-                'msg' => '',
+                'code'  => 0,
+                'msg'   => '',
                 'count' => $count,
-                'data' => $list,
+                'data'  => $list,
             ];
             return json($data);
         }
         return $this->fetch();
     }
 
-    public function goodsBase ($id)
+    public function goodsBase($id)
     {
-        $data = $this->model->where(['goods_id' => $id])->findOrEmpty()->toArray();
-        if ($data['goods_img_banner']) {
-            $data['goods_img_banner'] = implode('|', json_decode($data['goods_img_banner'], true));
-        }
-        $data['goods_remark'] = htmlspecialchars_decode($data['goods_remark']);
-        $specRelation = Db::name('shop_goods_spec_relation')->where(['goods_id' => $id])->select()->toArray();
-        $specAttrId = Db::name('shop_goods_spec_type')->where(['id' => $specRelation[0]['spec_id']])->value('pid');
-        if ($data['is_exist_many_spec'] == 0) {
-            $data['defaultSku'] = Db::name('shop_goods_spec')->where(['goods_id' => $id])->find();
-        }
-        $hot_keywords = Db::name('shop_hot_keywords')->select()->toArray();
-        $shop_supplier = Db::name('shop_supplier')->select()->toArray();
-        $shop_goods_type = Db::name('shop_goods_type')->field('id,name')->select()->toArray();
+        list($data, $hot_keywords, $shop_goods_type, $shop_supplier,$specAttrId) = ShopGoodsLogic::getGoodsBase($id);
 
         $this->assign('shop_goods_type', $shop_goods_type);
-
         $this->assign('box_type', system_box_typesetting());
-
         $this->assign('hot_keywords', $hot_keywords);
         $this->assign('shop_supplier', $shop_supplier);
         $this->assign('specAttrId', $specAttrId);
@@ -114,14 +84,14 @@ class Goods extends AdminController
      * @throws \think\db\exception\ModelNotFoundException
      * 获取商品规格,商品sku
      */
-    public function getGoodsSpecData ($goodsId, $attriId)
+    public function getGoodsSpecData($goodsId, $attriId)
     {
         if ($this->request->isAjax()) {
             $specRelation = Db::name('shop_goods_spec_relation')->where(['goods_id' => $goodsId])->select()->toArray();
-            $specAttrId = Db::name('shop_goods_spec_type')->where(['id' => $specRelation[0]['spec_id']])->value('pid');
-            $specType = Db::name('shop_goods_spec_type')->select()->toArray();
-            $specType = app()->make(Tree::class)->DeepTree($specType, 'child');
-            $specTypeArr = [];
+            $specAttrId   = Db::name('shop_goods_spec_type')->where(['id' => $specRelation[0]['spec_id']])->value('pid');
+            $specType     = Db::name('shop_goods_spec_type')->select()->toArray();
+            $specType     = app()->make(Tree::class)->DeepTree($specType, 'child');
+            $specTypeArr  = [];
             foreach ($specType as $k => $v) {
                 if ($v['id'] == $specAttrId) {
                     if (isset($v['child']))
@@ -136,7 +106,7 @@ class Goods extends AdminController
 
             $specRelationArr = array_column($specRelationArr, 'id');
             foreach ($specTypeArr as $k => &$v) {
-                if(isset($v['child'])) {
+                if (isset($v['child'])) {
                     foreach ($v['child'] as $ck => &$cv) {
                         if (in_array($cv['id'], $specRelationArr)) {
                             $cv['checked'] = true;
@@ -148,21 +118,21 @@ class Goods extends AdminController
             }
 
             $goodsSkuArr = [];
-            $goodsSku = Db::name('shop_goods_spec')->where(['goods_id' => $goodsId])->select()->toArray();
+            $goodsSku    = Db::name('shop_goods_spec')->where(['goods_id' => $goodsId])->select()->toArray();
             foreach ($goodsSku as $sk => $sv) {
-                $goodsSkuArr['skus[' . $sv['spec_ids'] . '][picture]'] = $sv['picture'];
-                $goodsSkuArr['skus[' . $sv['spec_ids'] . '][price]'] = $sv['price'];
-                $goodsSkuArr['skus[' . $sv['spec_ids'] . '][cost_price]'] = $sv['cost_price'];
-                $goodsSkuArr['skus[' . $sv['spec_ids'] . '][weight]'] = $sv['weight'];
-                $goodsSkuArr['skus[' . $sv['spec_ids'] . '][stock]'] = $sv['stock'];
+                $goodsSkuArr['skus[' . $sv['spec_ids'] . '][picture]']      = $sv['picture'];
+                $goodsSkuArr['skus[' . $sv['spec_ids'] . '][price]']        = $sv['price'];
+                $goodsSkuArr['skus[' . $sv['spec_ids'] . '][cost_price]']   = $sv['cost_price'];
+                $goodsSkuArr['skus[' . $sv['spec_ids'] . '][weight]']       = $sv['weight'];
+                $goodsSkuArr['skus[' . $sv['spec_ids'] . '][stock]']        = $sv['stock'];
                 $goodsSkuArr['skus[' . $sv['spec_ids'] . '][rebate_score]'] = $sv['rebate_score'];
             }
 
             $data = [
                 'code' => 0,
-                'msg' => '',
+                'msg'  => '',
                 'spec' => $specTypeArr,
-                'sku' => $goodsSkuArr
+                'sku'  => $goodsSkuArr
             ];
             return json($data);
         }
@@ -175,25 +145,25 @@ class Goods extends AdminController
     {
         if ($this->request->isAjax()) {
             $goods = $this->request->post();
-           Db::startTrans();
-           try {
-               if (!isset($goods['is_exist_many_spec'])) {
-                   $flag = ShopGoods::singleSpecGoods($goods);
-               } else {
-                   $flag = ShopGoods::manySpecGoods($goods);
-               }
-               Db::commit();
+            Db::startTrans();
+            try {
+                if (!isset($goods['is_exist_many_spec'])) {
+                    $flag = ShopGoods::singleSpecGoods($goods);
+                } else {
+                    $flag = ShopGoods::manySpecGoods($goods);
+                }
+                Db::commit();
 
-           }catch (\Exception $e){
-               Db::rollback();
-               $this->error($e->getMessage());
-           }
+            } catch (\Exception $e) {
+                Db::rollback();
+                $this->error($e->getMessage());
+            }
 
             $this->success('成功');
 //            return $flag ? json(['code' => 1, 'msg' => '发布成功']) :
 //                json(['code' => 0, 'msg' => '发布失败']);
         }
-        $hot_keywords = Db::name('shop_hot_keywords')->select()->toArray();
+        $hot_keywords  = Db::name('shop_hot_keywords')->select()->toArray();
         $shop_supplier = Db::name('shop_supplier')->select()->toArray();
         $this->assign('hot_keywords', $hot_keywords);
         $this->assign('shop_supplier', $shop_supplier);
@@ -203,7 +173,7 @@ class Goods extends AdminController
     /**
      * @NodeAnotation(title="商品编辑")
      */
-    public function edit ($id)
+    public function edit($id)
     {
         if ($this->request->isAjax()) {
             $goods = $this->request->post();
@@ -215,7 +185,7 @@ class Goods extends AdminController
                     ShopGoods::manySpecGoods($goods);
                 }
                 Db::commit();
-            }catch (\Exception $e){
+            } catch (\Exception $e) {
                 Db::rollback();
                 $this->error($e->getMessage());
             }
@@ -227,7 +197,7 @@ class Goods extends AdminController
     }
 
 
-    public function copy ($id)
+    public function copy($id)
     {
         if ($this->request->isAjax()) {
             $goods = $this->request->post();
@@ -239,7 +209,7 @@ class Goods extends AdminController
                     $flag = ShopGoods::manySpecGoods($goods);
                 }
                 Db::commit();
-            }catch (\Exception $e){
+            } catch (\Exception $e) {
                 Db::rollback();
                 $this->error($e->getMessage());
             }
@@ -255,7 +225,7 @@ class Goods extends AdminController
     /**
      * @NodeAnotation(title="入库")
      */
-    public function stock ($id)
+    public function stock($id)
     {
         $sku = Db::name('shop_goods_spec')->where(['goods_id' => $id])->select()->toArray();
         $this->assign('sku', $sku);
@@ -270,11 +240,11 @@ class Goods extends AdminController
             foreach ($data as $k => $v) {
                 $stock[] = [
                     'goods_spec_id' => explode('_', $k)[1],
-                    'stock' => $v
+                    'stock'         => $v
                 ];
             }
             $ShopGoodsSpec = new ShopGoodsSpec();
-            $flag = $ShopGoodsSpec->saveAll($stock);
+            $flag          = $ShopGoodsSpec->saveAll($stock);
 
             return $flag ? json(['code' => 1, 'msg' => '保存成功']) :
                 json(['code' => 0, 'msg' => '保存失败']);

+ 1 - 2
app/admin/controller/mall/ShopHotKeywords.php

@@ -2,6 +2,7 @@
 
 namespace app\admin\controller\mall;
 
+use app\admin\logic\ShopHotKeywordsLogic;
 use app\common\controller\AdminController;
 use EasyAdmin\annotation\ControllerAnnotation;
 use EasyAdmin\annotation\NodeAnotation;
@@ -20,8 +21,6 @@ class ShopHotKeywords extends AdminController
         parent::__construct($app);
 
         $this->model = new \app\common\model\ShopHotKeywords();
-        
     }
 
-    
 }

+ 5 - 69
app/admin/controller/mall/ShopOrder.php

@@ -11,6 +11,7 @@ use EasyAdmin\annotation\NodeAnotation;
 use think\App;
 use think\exception\ValidateException;
 use think\facade\Db;
+use app\admin\model\dao\ShopOrder as ShopOrderDao;
 
 /**
  * @ControllerAnnotation(title="shop_order")
@@ -34,78 +35,11 @@ class ShopOrder extends AdminController
     public function index()
     {
         if ($this->request->isAjax()) {
-//            if (input('selectFields')) {
-//                return $this->selectList();
-//            }
-//            return json_decode(htmlspecialchars_decode($this->request->param('filter')));
-//            return $this->reque('filter');
-//            return json_decode(input('op'));
 
             list($page, $limit, $where) = $this->buildTableParames();
 
-            foreach ($where as $key => $val) {
-                if ($val[0] == 'status') {
-                    $where[$key][0] = 'o.status';
-                }
-                if ($val[0] == 'created_time') {
-                    $where[$key][0] = 'o.created_time';
-                    $where[$key][2] = sr_getcurtime($where[$key][2]);
-                }
+            list($count, $list) = ShopOrderLogic::getList($page, $limit, $where);
 
-                if ($val[0] == 'order_type') {
-                    $where[$key][0] = 'o.order_type';
-                }
-
-            }
-
-            $count = $this->model
-                ->alias('o')
-                ->with(['goods'])
-                ->where($where)
-//                ->where('o.status', '<>', 3)
-                ->leftJoin('user u', 'u.id = o.user_id')
-                ->leftJoin('shop_order_shipping s', 's.order_id = o.order_id')
-                ->field('o.*,u.mobile,s.sp_id,s.sp_name,s.sp_mergename,s.sp_mobile')
-                ->count();
-
-            $list = $this->model
-                ->alias('o')
-                ->with(['goods'])
-                ->where($where)
-//                ->where('o.status', '<>', 3)
-                ->leftJoin('user u', 'u.id = o.user_id')
-                ->leftJoin('shop_order_shipping s', 's.order_id = o.order_id')
-                ->field('o.*,u.mobile,s.sp_id,s.sp_name,s.sp_mergename,s.sp_mobile')
-                ->order('o.order_id desc')
-                ->withAttr('order_sn', function ($val, $data) {
-                    return '编号:' . $val;
-                })
-                ->page($page, $limit)
-                ->select()->toArray();
-
-
-            foreach ($list as $k => $v) {
-                $goods_id   = $v['goods'][0]['goods_id'];
-                $goods_info = Db::name('shop_goods')->where('goods_id', $goods_id)->find();
-                if ($goods_info) {
-                    $list[$k]['cost_price'] = $goods_info['cost_price'];
-                } else {
-                    $list[$k]['cost_price'] = 0;
-                }
-
-                if ($v['status'] == 5 || $v['status'] == 6) {
-                    // 新的地址
-                    $ygOrderInfo              = Db::name('yg_order')->where('order_sn', str_replace('编号:', '', $v['order_sn']))->find();
-                    $newAddress_info          = Db::name('user_address')->where('id', $ygOrderInfo['address_id'])->find();
-                    $list[$k]['sp_id']        = 99999;
-                    $list[$k]['sp_mobile']    = $newAddress_info['mobile'];
-                    $list[$k]['sp_name']      = $newAddress_info['name'];
-                    $list[$k]['sp_mergename'] = $newAddress_info['mergename'];
-
-                }
-
-
-            }
             $data = [
                 'code'  => 0,
                 'msg'   => '',
@@ -142,7 +76,7 @@ class ShopOrder extends AdminController
             $this->success('设置成功');
         }
 
-        $row = $this->model->where('order_id', $id)->find();
+        $row = ShopOrderDao::getOrderById($id);
         $this->assign('info', $row);
 
         return $this->fetch();
@@ -199,6 +133,7 @@ class ShopOrder extends AdminController
     }
 
     /**
+     * 订单配送列表(疑似无效)
      * @NodeAnotation(title="列表")
      */
     public function delivery($orderId)
@@ -222,6 +157,7 @@ class ShopOrder extends AdminController
     }
 
     /**
+     * 订单配送设置物流信息(疑似无效)
      * @NodeAnotation(title="列表")
      */
     public function deliverySave()

+ 56 - 4
app/admin/logic/ShopGoodsLogic.php

@@ -2,8 +2,13 @@
 
 namespace app\admin\logic;
 
+use app\admin\model\dao\ShopGoodsSpec;
+use app\admin\model\dao\ShopGoodsSpecRelation;
+use app\admin\model\dao\ShopGoodsSpecType;
+use app\admin\model\dao\ShopGoodsType;
 use app\common\model\ShopGoods;
 use think\facade\Cache;
+use think\facade\Db;
 
 /**
  * 商城商品
@@ -20,10 +25,10 @@ class ShopGoodsLogic
     public static function getCount()
     {
         $cacheKey = "caches:goods:counts";
-        if(!Cache::has($cacheKey)){
-            $data = ShopGoods::where(['on_sale'=>1])->count('goods_id');
-            if($data){
-                Cache::set($cacheKey, $data, rand(3,5));
+        if (!Cache::has($cacheKey)) {
+            $data = ShopGoods::where(['on_sale' => 1])->count('goods_id');
+            if ($data) {
+                Cache::set($cacheKey, $data, rand(3, 5));
             }
 
             return $data;
@@ -32,4 +37,51 @@ class ShopGoodsLogic
         return Cache::get($cacheKey);
     }
 
+    public static function getList($page, $limit, $where)
+    {
+        $model = new ShopGoods();
+        $count = $model
+            ->withJoin(['supplier', 'cate'], 'LEFT')
+            ->where($where)
+            ->count();
+
+        $list = $model
+            ->withJoin(['supplier', 'cate'], 'LEFT')
+            ->where($where)
+            ->page($page, $limit)
+            ->order('goods_id desc')
+            ->select()->toArray();
+        foreach ($list as $k => &$v) {
+            $v['id'] = $v['goods_id'];
+//                $v['supplier'] = Db::name('shop_supplier')->where(['id'=>$v['supplier']])->value('name');
+            $v['goods_type'] = ShopGoodsTypeLogic::getNameByCache($v['goods_type']);
+        }
+        return [$count, $list];
+    }
+
+    public static function getGoodsOrEmpty($id)
+    {
+    }
+
+    public static function getGoodsBase($id)
+    {
+        $model = new ShopGoods();
+        $data  = $model->where(['goods_id' => $id])->findOrEmpty()->toArray();
+
+        if ($data['goods_img_banner']) {
+            $data['goods_img_banner'] = implode('|', json_decode($data['goods_img_banner'], true));
+        }
+        $data['goods_remark'] = htmlspecialchars_decode($data['goods_remark']);
+        $specRelation         = ShopGoodsSpecRelation::getArrListByGoodsId($id);
+        $specAttrId           = ShopGoodsSpecType::getPidById($specRelation[0]['spec_id']);
+        if ($data['is_exist_many_spec'] == 0) {
+            $data['defaultSku'] = ShopGoodsSpec::getGoodsSpecByGoodId($id);
+        }
+
+        $hot_keywords    = ShopHotKeywordsLogic::getCacheList();
+        $shop_supplier   = ShopSupplierLogic::getCacheList();
+        $shop_goods_type = ShopGoodsTypeLogic::getCacheList();
+        return [$data, $hot_keywords, $shop_goods_type, $shop_supplier, $specAttrId];
+    }
+
 }

+ 49 - 0
app/admin/logic/ShopGoodsTypeLogic.php

@@ -0,0 +1,49 @@
+<?php
+
+
+namespace app\admin\logic;
+
+
+use app\admin\model\dao\ShopGoodsType;
+use think\facade\Cache;
+use think\facade\Db;
+
+class ShopGoodsTypeLogic
+{
+    private static $CACHE_NAME_KEY = "SHOPGOODSTYPENAME";
+
+    private static $CACHE_LIST_KEY = "cache:shop_goods_type:list";
+
+    public function __construct()
+    {
+    }
+
+
+    public static function getNameByCache($goodsType)
+    {
+        $key = self::$CACHE_NAME_KEY . $goodsType;
+        if (Cache::has($key)) {
+            return Cache::get($key);
+        }
+        $name = ShopGoodsType::getValueById($goodsType);
+        Cache::set($key, $name, 5 * 60);
+        return $name;
+    }
+
+    public static function getCacheList()
+    {
+        $key = self::$CACHE_LIST_KEY;
+        if (Cache::has($key)) {
+            return Cache::get($key);
+        }
+        $name = ShopGoodsType::getList();
+        Cache::set($key, $name, 10 * 60);
+        return $name;
+    }
+
+    public static function delCache()
+    {
+        $key = self::$CACHE_LIST_KEY;
+        Cache::delete($key);
+    }
+}

+ 35 - 0
app/admin/logic/ShopHotKeywordsLogic.php

@@ -0,0 +1,35 @@
+<?php
+
+namespace app\admin\logic;
+
+use app\admin\model\dao\ShopGoodsType;
+use app\admin\model\dao\ShopHotKeywords;
+use app\common\model\ShopGoods;
+use think\facade\Cache;
+
+/**
+ * 商城商品
+ * Class ShopGoodsLogic
+ * @package app\admin\logic
+ */
+class ShopHotKeywordsLogic
+{
+    private static $CACHE_LIST_KEY = "cache:shop_host_keywords:list";
+
+    public static function getCacheList()
+    {
+        $key = self::$CACHE_LIST_KEY;
+        if (Cache::has($key)) {
+            return Cache::get($key);
+        }
+        $name = ShopHotKeywords::getList();
+        Cache::set($key, $name, 10 * 60);
+        return $name;
+    }
+
+    public static function delCache()
+    {
+        $key = self::$CACHE_LIST_KEY;
+        Cache::delete($key);
+    }
+}

+ 72 - 0
app/admin/logic/ShopOrderLogic.php

@@ -3,7 +3,9 @@
 
 namespace app\admin\logic;
 
+use app\admin\model\dao\ShopGoods;
 use app\admin\model\dao\ShopOrder;
+use app\admin\model\dao\UserAddress;
 use think\facade\Db;
 
 class ShopOrderLogic
@@ -52,5 +54,75 @@ class ShopOrderLogic
         return true;
     }
 
+    public static function getList($page, $limit, $where)
+    {
+
+        $model = new \app\common\model\ShopOrder();
+        foreach ($where as $key => $val) {
+            if ($val[0] == 'status') {
+                $where[$key][0] = 'o.status';
+            }
+            if ($val[0] == 'created_time') {
+                $where[$key][0] = 'o.created_time';
+                $where[$key][2] = sr_getcurtime($where[$key][2]);
+            }
+
+            if ($val[0] == 'order_type') {
+                $where[$key][0] = 'o.order_type';
+            }
+
+        }
+
+        $count = $model
+            ->alias('o')
+            ->with(['goods'])
+            ->where($where)
+//                ->where('o.status', '<>', 3)
+            ->leftJoin('user u', 'u.id = o.user_id')
+            ->leftJoin('shop_order_shipping s', 's.order_id = o.order_id')
+            ->field('o.*,u.mobile,s.sp_id,s.sp_name,s.sp_mergename,s.sp_mobile')
+            ->count();
+
+        $list = $model
+            ->alias('o')
+            ->with(['goods'])
+            ->where($where)
+//                ->where('o.status', '<>', 3)
+            ->leftJoin('user u', 'u.id = o.user_id')
+            ->leftJoin('shop_order_shipping s', 's.order_id = o.order_id')
+            ->field('o.*,u.mobile,s.sp_id,s.sp_name,s.sp_mergename,s.sp_mobile')
+            ->order('o.order_id desc')
+            ->withAttr('order_sn', function ($val, $data) {
+                return '编号:' . $val;
+            })
+            ->page($page, $limit)
+            ->select()->toArray();
+
+
+        foreach ($list as $k => $v) {
+            $goods_id   = $v['goods'][0]['goods_id'];
+            $goods_info = ShopGoods::getGoodsById($goods_id);
+            if ($goods_info) {
+                $list[$k]['cost_price'] = $goods_info['cost_price'];
+            } else {
+                $list[$k]['cost_price'] = 0;
+            }
+
+            if ($v['status'] == 5 || $v['status'] == 6) {
+                // 新的地址
+                $ygOrderInfo              = Db::name('yg_order')->where('order_sn', str_replace('编号:', '', $v['order_sn']))->find();
+                $newAddress_info          = UserAddress::getUserAddress($ygOrderInfo['address_id']);
+                $list[$k]['sp_id']        = 99999;
+                $list[$k]['sp_mobile']    = $newAddress_info['mobile'];
+                $list[$k]['sp_name']      = $newAddress_info['name'];
+                $list[$k]['sp_mergename'] = $newAddress_info['mergename'];
+
+            }
+
+
+        }
+        return [$count, $list];
+    }
+
 
 }

+ 33 - 0
app/admin/logic/ShopSupplierLogic.php

@@ -0,0 +1,33 @@
+<?php
+
+namespace app\admin\logic;
+
+use app\admin\model\dao\ShopSupplier;
+use think\facade\Cache;
+
+/**
+ * 商城商品
+ * Class ShopGoodsLogic
+ * @package app\admin\logic
+ */
+class ShopSupplierLogic
+{
+    private static $CACHE_LIST_KEY = "cache:shop_supplier:list";
+
+    public static function getCacheList()
+    {
+        $key = self::$CACHE_LIST_KEY;
+        if (Cache::has($key)) {
+            return Cache::get($key);
+        }
+        $name = ShopSupplier::getList();
+        Cache::set($key, $name, 10 * 60);
+        return $name;
+    }
+
+    public static function delCache()
+    {
+        $key = self::$CACHE_LIST_KEY;
+        Cache::delete($key);
+    }
+}

+ 27 - 0
app/admin/model/dao/ShopGoods.php

@@ -0,0 +1,27 @@
+<?php
+
+
+namespace app\admin\model\dao;
+
+
+use think\facade\Cache;
+use think\facade\Db;
+
+class ShopGoods extends BaseDao
+{
+    public static $table = "db_shop_goods";
+
+    public function __construct()
+    {
+    }
+
+    public static function getList()
+    {
+        return Db::table(self::$table)->select()->toArray();
+    }
+
+    public static function getGoodsById($goods_id)
+    {
+        return Db::table(self::$table)->where('goods_id', $goods_id)->find();
+    }
+}

+ 27 - 0
app/admin/model/dao/ShopGoodsSpec.php

@@ -0,0 +1,27 @@
+<?php
+
+
+namespace app\admin\model\dao;
+
+
+use think\facade\Cache;
+use think\facade\Db;
+
+class ShopGoodsSpec extends BaseDao
+{
+    public static $table = "db_shop_goods_spec";
+
+    public function __construct()
+    {
+    }
+
+    public static function getList()
+    {
+        return Db::table(self::$table)->select()->toArray();
+    }
+
+    public static function getGoodsSpecByGoodId($id)
+    {
+        return Db::table(self::$table)->where(['goods_id' => $id])->find();
+    }
+}

+ 24 - 0
app/admin/model/dao/ShopGoodsSpecRelation.php

@@ -0,0 +1,24 @@
+<?php
+
+
+namespace app\admin\model\dao;
+
+
+use think\facade\Cache;
+use think\facade\Db;
+
+class ShopGoodsSpecRelation extends BaseDao
+{
+    public static $table = "db_shop_goods_spec_relation";
+
+    public function __construct()
+    {
+    }
+
+    public static function getArrListByGoodsId($id)
+    {
+        return Db::table(self::$table)->where(['goods_id' => $id])->select()->toArray();
+    }
+
+
+}

+ 24 - 0
app/admin/model/dao/ShopGoodsSpecType.php

@@ -0,0 +1,24 @@
+<?php
+
+
+namespace app\admin\model\dao;
+
+
+use think\facade\Cache;
+use think\facade\Db;
+
+class ShopGoodsSpecType extends BaseDao
+{
+    public static $table = "db_shop_goods_spec_type";
+
+    public function __construct()
+    {
+    }
+
+    public static function getPidById($spec_id)
+    {
+        return Db::table(self::$table)->where(['id' => $spec_id])->value('pid');
+    }
+
+
+}

+ 27 - 0
app/admin/model/dao/ShopGoodsType.php

@@ -0,0 +1,27 @@
+<?php
+
+
+namespace app\admin\model\dao;
+
+
+use think\facade\Cache;
+use think\facade\Db;
+
+class ShopGoodsType extends BaseDao
+{
+    public static $table = "db_shop_goods_type";
+
+    public function __construct()
+    {
+    }
+
+    public static function getValueById($goodsType)
+    {
+        return Db::table(self::$table)->where(['id' => $goodsType])->value('name');
+    }
+
+    public static function getList()
+    {
+        return Db::table(self::$table)->select()->toArray();
+    }
+}

+ 22 - 0
app/admin/model/dao/ShopHotKeywords.php

@@ -0,0 +1,22 @@
+<?php
+
+
+namespace app\admin\model\dao;
+
+
+use think\facade\Cache;
+use think\facade\Db;
+
+class ShopHotKeywords extends BaseDao
+{
+    public static $table = "db_shop_hot_keywords";
+
+    public function __construct()
+    {
+    }
+
+    public static function getList()
+    {
+        return Db::table(self::$table)->select()->toArray();
+    }
+}

+ 0 - 1
app/admin/model/dao/ShopOrder.php

@@ -34,5 +34,4 @@ class ShopOrder extends BaseDao
     {
         return Db::table(self::$table)->where(['order_id' => $orderId])->find();
     }
-
 }

+ 22 - 0
app/admin/model/dao/ShopSupplier.php

@@ -0,0 +1,22 @@
+<?php
+
+
+namespace app\admin\model\dao;
+
+
+use think\facade\Cache;
+use think\facade\Db;
+
+class ShopSupplier extends BaseDao
+{
+    public static $table = "db_shop_supplier";
+
+    public function __construct()
+    {
+    }
+
+    public static function getList()
+    {
+        return Db::table(self::$table)->select()->toArray();
+    }
+}

+ 1 - 1
app/admin/model/dao/User.php

@@ -115,7 +115,7 @@ class User extends BaseDao
 
     public static function updateTotalTeamWithdraw($path, $apply_money)
     {
-        Db::name('user')->whereIn('id', $path)->inc('total_team_withdraw', $apply_money)->update();
+        Db::table(self::$table)->whereIn('id', $path)->inc('total_team_withdraw', $apply_money)->update();
     }
 
     public function getUserDetail($id)

+ 27 - 0
app/admin/model/dao/UserAddress.php

@@ -0,0 +1,27 @@
+<?php
+
+
+namespace app\admin\model\dao;
+
+
+use app\common\model\UserModel;
+use think\facade\Db;
+
+class UserAddress extends BaseDao
+{
+
+
+    protected $model;
+
+    public static $table = "db_user_address";
+
+    public function __construct()
+    {
+    }
+
+    public static function getUserAddress($address_id)
+    {
+        return Db::table(self::$table)->where('id', $address_id)->find();
+    }
+
+}

+ 2 - 2
app/admin/model/dao/WithdrawLog.php

@@ -37,12 +37,12 @@ class WithdrawLog extends BaseDao
     public static function update($id, $updateData)
     {
         $updateData['update_at'] = sr_getcurtime(time());
-        Db::name('withdraw_log')->where('id', $id)->update($updateData);
+        Db::table(self::$table)->where('id', $id)->update($updateData);
     }
 
     public static function SumPracticalMoneyByStatus($int)
     {
-        return Db::name('withdraw_log')->where('status', $int)->sum('practical_money');
+        return Db::table(self::$table)->where('status', $int)->sum('practical_money');
     }
 
 }

+ 15 - 0
app/common/model/ShopGoodsTypeModel.php

@@ -2,7 +2,9 @@
 
 namespace app\common\model;
 
+use app\admin\logic\ShopGoodsTypeLogic;
 use app\common\model\TimeModel;
+use think\Model;
 
 class ShopGoodsTypeModel extends TimeModel
 {
@@ -10,6 +12,19 @@ class ShopGoodsTypeModel extends TimeModel
     protected $name = "shop_goods_type";
 
 
+    public static function onAfterUpdate($model){
+        ShopGoodsTypeLogic::delCache();
+    }
+
+    public static function onAfterInsert(Model $model): void
+    {
+        ShopGoodsTypeLogic::delCache();
+    }
+
+    public static function onAfterDelete(Model $model): void
+    {
+        ShopGoodsTypeLogic::delCache();
+    }
 
 
 

+ 14 - 2
app/common/model/ShopHotKeywords.php

@@ -2,7 +2,9 @@
 
 namespace app\common\model;
 
+use app\admin\logic\ShopHotKeywordsLogic;
 use app\common\model\TimeModel;
+use think\Model;
 
 class ShopHotKeywords extends TimeModel
 {
@@ -11,7 +13,17 @@ class ShopHotKeywords extends TimeModel
 
     protected $deleteTime = false;
 
-    
-    
+    public static function onAfterUpdate($model){
+        ShopHotKeywordsLogic::delCache();
+    }
 
+    public static function onAfterInsert(Model $model): void
+    {
+        ShopHotKeywordsLogic::delCache();
+    }
+
+    public static function onAfterDelete(Model $model): void
+    {
+        ShopHotKeywordsLogic::delCache();
+    }
 }

+ 17 - 1
app/common/model/ShopSupplier.php

@@ -2,7 +2,10 @@
 
 namespace app\common\model;
 
+use app\admin\logic\ShopHotKeywordsLogic;
+use app\admin\logic\ShopSupplierLogic;
 use app\common\model\TimeModel;
+use think\Model;
 
 class ShopSupplier extends TimeModel
 {
@@ -11,7 +14,20 @@ class ShopSupplier extends TimeModel
 
     protected $deleteTime = false;
 
-    
+
+    public static function onAfterUpdate($model){
+        ShopSupplierLogic::delCache();
+    }
+
+    public static function onAfterInsert(Model $model): void
+    {
+        ShopSupplierLogic::delCache();
+    }
+
+    public static function onAfterDelete(Model $model): void
+    {
+        ShopSupplierLogic::delCache();
+    }
     
 
 }

+ 83 - 0
vendor/composer/installed.json

@@ -1712,6 +1712,49 @@
         ]
     },
     {
+        "name": "league/flysystem-cached-adapter",
+        "version": "1.1.0",
+        "version_normalized": "1.1.0.0",
+        "dist": {
+            "type": "zip",
+            "url": "https://mirrors.cloud.tencent.com/repository/composer/league/flysystem-cached-adapter/1.1.0/league-flysystem-cached-adapter-1.1.0.zip",
+            "reference": "d1925efb2207ac4be3ad0c40b8277175f99ffaff",
+            "shasum": ""
+        },
+        "require": {
+            "league/flysystem": "~1.0",
+            "psr/cache": "^1.0.0"
+        },
+        "require-dev": {
+            "mockery/mockery": "~0.9",
+            "phpspec/phpspec": "^3.4",
+            "phpunit/phpunit": "^5.7",
+            "predis/predis": "~1.0",
+            "tedivm/stash": "~0.12"
+        },
+        "suggest": {
+            "ext-phpredis": "Pure C implemented extension for PHP"
+        },
+        "time": "2020-07-25T15:56:04+00:00",
+        "type": "library",
+        "installation-source": "dist",
+        "autoload": {
+            "psr-4": {
+                "League\\Flysystem\\Cached\\": "src/"
+            }
+        },
+        "license": [
+            "MIT"
+        ],
+        "authors": [
+            {
+                "name": "frankdejonge",
+                "email": "info@frenky.net"
+            }
+        ],
+        "description": "An adapter decorator to enable meta-data caching."
+    },
+    {
         "name": "league/mime-type-detection",
         "version": "1.11.0",
         "version_normalized": "1.11.0.0",
@@ -3309,6 +3352,46 @@
         "description": "captcha package for thinkphp"
     },
     {
+        "name": "topthink/think-filesystem",
+        "version": "v1.0.3",
+        "version_normalized": "1.0.3.0",
+        "dist": {
+            "type": "zip",
+            "url": "https://mirrors.tencent.com/repository/composer/topthink/think-filesystem/v1.0.3/topthink-think-filesystem-v1.0.3.zip",
+            "reference": "29f19f140a9267c717fecd7ccb22c84c2d72382e",
+            "shasum": ""
+        },
+        "require": {
+            "league/flysystem": "^1.1.4",
+            "league/flysystem-cached-adapter": "^1.0",
+            "php": ">=7.2.5",
+            "topthink/framework": "^6.1|^8.0"
+        },
+        "require-dev": {
+            "mikey179/vfsstream": "^1.6",
+            "mockery/mockery": "^1.2",
+            "phpunit/phpunit": "^8.0"
+        },
+        "time": "2023-02-08T01:25:15+00:00",
+        "type": "library",
+        "installation-source": "dist",
+        "autoload": {
+            "psr-4": {
+                "think\\": "src"
+            }
+        },
+        "license": [
+            "Apache-2.0"
+        ],
+        "authors": [
+            {
+                "name": "yunwuxin",
+                "email": "448901948@qq.com"
+            }
+        ],
+        "description": "The ThinkPHP6.1 Filesystem Package"
+    },
+    {
         "name": "topthink/think-helper",
         "version": "v3.1.6",
         "version_normalized": "3.1.6.0",