From bb722423b193ac9589bf34b074df26f863cd6b1e Mon Sep 17 00:00:00 2001 From: lqmac Date: Sun, 19 May 2024 10:58:34 +0800 Subject: [PATCH 1/7] 1 --- app/admin/controller/Goods.php | 2 +- app/job/service/goods/GoodsStoreImport.php | 22 ++++++++++++++-------- app/store/model/Goods.php | 4 ++-- app/store/model/Store.php | 1 + config/allowapi.php | 4 ++++ 5 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 config/allowapi.php diff --git a/app/admin/controller/Goods.php b/app/admin/controller/Goods.php index aa057294..e161e755 100644 --- a/app/admin/controller/Goods.php +++ b/app/admin/controller/Goods.php @@ -231,7 +231,7 @@ class Goods extends Controller $categoryIds = $model->dealCategory($categoryIds); \app\store\model\GoodsCategoryRel::updates($goodsId, $categoryIds); } - $model->whereIn('goods_id', $goodsIds)->update(['cate_status'=>1]); + $model->whereIn('goods_id', $goodsIds)->update(['cate_status'=>1,'update_time' => time()]); return $this->renderSuccess('操作成功'); } /** diff --git a/app/job/service/goods/GoodsStoreImport.php b/app/job/service/goods/GoodsStoreImport.php index 5e79308c..e5c46f93 100644 --- a/app/job/service/goods/GoodsStoreImport.php +++ b/app/job/service/goods/GoodsStoreImport.php @@ -201,9 +201,6 @@ class GoodsStoreImport extends BaseService */ public function createData(array $original, int $storeId): array { - - //$channel = Channel::where('name', $original["B"])->find(); - //批量导入销售区域处理 $region = []; $region_text = []; @@ -227,7 +224,8 @@ class GoodsStoreImport extends BaseService foreach ($regions as $key => $value) { $regionsnew[$value['pid']][] = $value; } - + // echo "
";
+            // print_r($regionsnew);
             foreach ($regionsnew as $pid => $value) {
                 $privince = Region::withoutGlobalScope()->where('id', $pid)->find();
                 $region_text[$pid]['name'] = $privince['name'] ?? "";
@@ -239,11 +237,19 @@ class GoodsStoreImport extends BaseService
                 }
                 $region_text[$pid]['citys'] = $citys;
             }
+            unset($pid);
+
+            foreach ($region_text as $pid => &$item) {
+                //如果传入的是整个省份
+                if (count($item['citys']) == Region::withoutGlobalScope()->whereIn('pid', $pid)->count()) {
+                    $item['citys'] = [];
+                }
+            }
         }
-         // echo "
";
-         //    print_r($region_text);
-         //    print_r($region);
-         //    exit();
+        // echo "
";
+        //     print_r($region_text);
+        //     print_r($region);
+        //     exit();
         // 整理商品数据
         $data = [
             'cmmdty_model' => $original["A"],
diff --git a/app/store/model/Goods.php b/app/store/model/Goods.php
index c6086968..bd8d31c5 100644
--- a/app/store/model/Goods.php
+++ b/app/store/model/Goods.php
@@ -183,7 +183,7 @@ class Goods extends GoodsModel
     public function setIsPool(array $goodsIds, int $is_pool): bool
     {
         // 批量更新记录
-        return static::updateBase(['is_pool' => $is_pool], [['goods_id', 'in', $goodsIds]]);
+        return static::updateBase(['is_pool' => $is_pool,'update_time' => time()], [['goods_id', 'in', $goodsIds]]);
     }
     /**
      * 修改商品状态
@@ -194,7 +194,7 @@ class Goods extends GoodsModel
     public function setIsSale(array $goodsIds, int $is_sale): bool
     {
         // 批量更新记录
-        return static::updateBase(['is_sale' => $is_sale], [['goods_id', 'in', $goodsIds]]);
+        return static::updateBase(['is_sale' => $is_sale,'update_time' => time()], [['goods_id', 'in', $goodsIds]]);
     }
     /**
      * 修改商品状态
diff --git a/app/store/model/Store.php b/app/store/model/Store.php
index 3891ae32..0bbf86e5 100644
--- a/app/store/model/Store.php
+++ b/app/store/model/Store.php
@@ -30,6 +30,7 @@ class Store extends StoreModel
     {
         // 是否删除图片
         !isset($data['logo_image_id']) && $data['logo_image_id'] = 0;
+        $data['fliter_condition'] = json_encode($data['fliter_condition'], JSON_UNESCAPED_UNICODE);
         return $this->save($data) !== false;
     }
 }
diff --git a/config/allowapi.php b/config/allowapi.php
new file mode 100644
index 00000000..babc3798
--- /dev/null
+++ b/config/allowapi.php
@@ -0,0 +1,4 @@
+
Date: Tue, 21 May 2024 13:38:10 +0800
Subject: [PATCH 2/7] 1

---
 app/api/controller/Goods.php | 15 ++++++++-------
 app/api/model/Goods.php      | 21 +++++++++++++++++----
 app/api/model/Order.php      |  9 ++++++++-
 app/api/service/Cart.php     |  2 +-
 4 files changed, 34 insertions(+), 13 deletions(-)

diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php
index de318ad0..cd7e6057 100644
--- a/app/api/controller/Goods.php
+++ b/app/api/controller/Goods.php
@@ -24,6 +24,7 @@ use cores\exception\BaseException;
 use think\db\exception\DbException;
 use think\response\Json;
 use app\common\enum\goods\GoodsDeliveryTime;
+use think\facade\Cache;
 /**
  * 商品控制器
  * Class Goods
@@ -142,7 +143,7 @@ class Goods extends Controller
                     ];
                     break;
                 default:
-                    if ($goods->stock_total > ($value['num'] ?? 1)) {
+                    if ($goods->stock_total >= ($value['num'] ?? 1)) {
                         $res = "有货";
                     }
                     $data = [
@@ -288,13 +289,13 @@ class Goods extends Controller
     public function recommended(): Json
     {
         $service = new GoodsService;
-//        $cache_key = "goods_recommended".$this->storeId;
-//        if(Cache::has($cache_key)) {
-//            $goodsList = Cache::get($cache_key);
-//            return $this->renderSuccess(compact('goodsList'));
-//        }
+       $cache_key = "goods_recommended".$this->storeId;
+       if(Cache::has($cache_key)) {
+           $goodsList = Cache::get($cache_key);
+           return $this->renderSuccess(compact('goodsList'));
+       }
         $goodsList = $service->recommended();
-//        Cache::set($cache_key, $goodsList, 60*60);
+        Cache::set($cache_key, $goodsList, 60*60);
         return $this->renderSuccess(compact('goodsList'));
     }
 
diff --git a/app/api/model/Goods.php b/app/api/model/Goods.php
index 7094877f..d60de044 100644
--- a/app/api/model/Goods.php
+++ b/app/api/model/Goods.php
@@ -583,12 +583,25 @@ class Goods extends GoodsModel
      * @return \app\common\model\GoodsSku|array|null
      * @throws BaseException
      */
-    public static function getSkuInfo($goodsInfo, string $goodsSkuId, bool $enableGradeMoney = true)
+    public static function getSkuInfo($goods, string $goodsSkuId, bool $enableGradeMoney = true)
     {
-        $goodsInfo['skuInfo'] = GoodsService::getSkuInfo($goodsInfo['goods_id'], $goodsSkuId);
+        $goods['skuInfo'] = GoodsService::getSkuInfo($goods['goods_id'], $goodsSkuId);
         //$enableGradeMoney && (new static)->setGoodsGradeMoney($goodsInfo);
-        (new static)->setGoodsMoney($goodsInfo);
-        return $goodsInfo['skuInfo'];
+        
+        $catService = new GoodsCategoryRel();
+        $catIds = $catService->where(['goods_id' => $goods->goods_id])->column('category_id');
+        if ($goods->getAttr('skuInfo')) {
+            if (UserService::isPlusMember()) {
+                $goods['skuInfo']['goods_price'] = \app\common\model\PriceSet::membershipPrice($goods['skuInfo']['goods_price'], $goods['skuInfo']['cost_price'], $catIds);
+
+            } elseif (UserService::isDealerMember()) {
+                $priceArr = \app\common\model\PriceSet::distributionPrice($goods['skuInfo']['goods_price'], $goods['skuInfo']['cost_price'], $catIds);
+                $goods['skuInfo']['goods_price'] = $priceArr['distributionPrice'];
+            }
+
+        }
+        //(new static)->setGoodsMoney($goodsInfo);
+        return $goods['skuInfo'];
     }
 
     /**
diff --git a/app/api/model/Order.php b/app/api/model/Order.php
index a6f6c54c..2eb0b14e 100644
--- a/app/api/model/Order.php
+++ b/app/api/model/Order.php
@@ -80,9 +80,13 @@ class Order extends OrderModel
         // 获取商品列表
         $model = new GoodsModel;
         $goodsList = $model->setEnableGradeMoney(false)->getListByIdsFromApi([$goodsId]);
+        
         if ($goodsList->isEmpty()) {
             throwError('未找到商品信息');
         }
+        // echo "
";
+        // print_r($goodsList->toArray());
+        // exit();
         // 隐藏冗余的属性
         $goodsList->hidden(GoodsModel::getHidden(['content', 'goods_images', 'images']));
         foreach ($goodsList as &$item) {
@@ -92,7 +96,7 @@ class Order extends OrderModel
             $item['goods_image'] = $item['skuInfo']['goods_image'] ?: $item['goods_image'];
 
             // 商品单价
-            $item['goods_price'] = \app\api\service\Goods::getGoodsPrice($item['goods_id'], $item['skuInfo']['goods_price'], $item['skuInfo']['cost_price']);
+            $item['goods_price'] = $item['skuInfo']['goods_price'];//\app\api\service\Goods::getGoodsPrice($item['goods_id'], $item['skuInfo']['goods_price'], $item['skuInfo']['cost_price']);
             // 商品购买数量
             $item['total_num'] = $goodsNum;
             // 商品SKU索引
@@ -100,6 +104,9 @@ class Order extends OrderModel
             // 商品购买总金额
             $item['total_price'] = helper::bcmul($item['goods_price'], $goodsNum);
         }
+        // echo "
";
+        // print_r($goodsList->toArray());
+        // exit();
         return $goodsList;
     }
 
diff --git a/app/api/service/Cart.php b/app/api/service/Cart.php
index 89770cbc..2f8475f2 100644
--- a/app/api/service/Cart.php
+++ b/app/api/service/Cart.php
@@ -80,7 +80,7 @@ class Cart extends BaseService
             // 商品记录
             $goods = $item['goods'];
             // 商品单价
-            $goods['goods_price'] = \app\api\service\Goods::getGoodsPrice($item['goods_id'], $goods['skuInfo']['goods_price'], $goods['skuInfo']['cost_price']);
+            $goods['goods_price'] = $goods['skuInfo']['goods_price'];//\app\api\service\Goods::getGoodsPrice($item['goods_id'], $goods['skuInfo']['goods_price'], $goods['skuInfo']['cost_price']);
             //$goods['goods_price'] = $goods['skuInfo']['goods_price'];
             // 商品购买数量
             $goods['total_num'] = $item['goods_num'];

From 2f24517b8eb2e0ada943acd19e3dc633f9e0f9e5 Mon Sep 17 00:00:00 2001
From: wang hou sheng <76928547+wanghousheng@users.noreply.github.com>
Date: Tue, 21 May 2024 15:03:31 +0800
Subject: [PATCH 3/7] 1

---
 app/api/model/dealer/Order.php | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/app/api/model/dealer/Order.php b/app/api/model/dealer/Order.php
index 43ebd092..2f0d1a92 100644
--- a/app/api/model/dealer/Order.php
+++ b/app/api/model/dealer/Order.php
@@ -12,17 +12,17 @@ declare (strict_types=1);
 
 namespace app\api\model\dealer;
 
+use app\api\model\Order as OrderApiModel;
+use app\api\model\User as UserApiModel;
 use app\api\service\User as UserService;
 use app\common\enum\dealer\DealerUserEnum;
+use app\common\enum\order\PayStatus as PayStatusEnum;
 use app\common\enum\ServerEnum;
-use app\common\model\Order as OrderModel;
+use app\common\enum\user\UserTypeEnum;
 use app\common\model\dealer\Order as DealerOrderModel;
-use app\api\model\Order as OrderApiModel;
-use app\common\enum\order\PayStatus as PayStatusEnum;
+use app\common\model\Order as OrderModel;
 use app\common\model\UserAddress as UserAddessModel;
 use cores\exception\BaseException;
-use app\api\model\User as UserApiModel;
-use app\common\enum\user\UserTypeEnum;
 
 
 /**
@@ -64,11 +64,11 @@ class Order extends DealerOrderModel
             ->paginate(15);
         // 数据整理
         foreach ($list as &$item) {
-            $with = ['goods' => ['image'],'user','address'];
+            $with = ['goods' => ['image'], 'user', 'address'];
             $where = ['order_id' => $item['order_id']];
             // 查询订单记录
             $order_goods = OrderApiModel::detail($where, $with);
-            $address = UserAddessModel::where('address_id',$item['user']->address_id)->find();
+            $address = UserAddessModel::where('address_id', $item['user']->address_id)->find();
             // 我的佣金
             $money = [
                 $item['first_user_id'] => $item['first_money'],
@@ -76,7 +76,7 @@ class Order extends DealerOrderModel
                 $item['third_user_id'] => $item['third_money'],
             ];
             $item['goods'] = $order_goods['goods'] ?? [];
-            $item['address_name'] =$address['name'];
+            $item['address_name'] = $address['name'];
             $item['order_no'] = $item['order']['order_no'] ?? "";
             $item['my_money'] = $money[$userId];
         }
@@ -126,11 +126,13 @@ class Order extends DealerOrderModel
             return false;
         }
         //如果上级已经不是分销商
-        if(!User::isDealerUser($dealerUser['first_user_id'])){
+        if (!User::isDealerUser($dealerUser['first_user_id'])) {
             return false;
         }
         //如果上级已经不是分销商
-        if(!UserApiModel::where('user_id',$dealerUser['first_user_id'])->value('user_type') !== UserTypeEnum::DEALER){
+        $userModel = new UserApiModel;
+        $user_type = $userModel->where('user_id', $dealerUser['first_user_id'])->value('user_type');
+        if ($user_type && $user_type != UserTypeEnum::DEALER) {
             return false;
         }
         // 计算订单分销佣金

From 4d7b0d47c0d5b461a67d870b4bf8932f6e8c73b1 Mon Sep 17 00:00:00 2001
From: lqmac 
Date: Tue, 21 May 2024 16:04:56 +0800
Subject: [PATCH 4/7] 1

---
 app/job/service/goods/AdminImport.php      |  5 ++-
 app/job/service/goods/Collector.php        |  1 +
 app/job/service/goods/GoodsStoreImport.php |  5 ++-
 app/store/controller/Goods.php             | 51 ++++++++++++++++++++--
 4 files changed, 57 insertions(+), 5 deletions(-)

diff --git a/app/job/service/goods/AdminImport.php b/app/job/service/goods/AdminImport.php
index a4c769bc..784cda48 100644
--- a/app/job/service/goods/AdminImport.php
+++ b/app/job/service/goods/AdminImport.php
@@ -110,7 +110,10 @@ class AdminImport extends BaseService
                 continue;
             }
         	$data = $this->createData($item, $storeId);
-        	$service->single($item['D'], $data, $storeId);
+        	$ret = $service->single($item['D'], $data, $storeId);
+            if ($ret == false) {
+                continue;
+            }
             // 记录导入成功
             $this->successCount++;
         }
diff --git a/app/job/service/goods/Collector.php b/app/job/service/goods/Collector.php
index 0760b7d6..b59078f1 100644
--- a/app/job/service/goods/Collector.php
+++ b/app/job/service/goods/Collector.php
@@ -145,6 +145,7 @@ class Collector extends BaseService
     {
        
         try {
+            //var_dump($url);
             // 采集第三方商品数据
             $original = $this->collector($url, $storeId);
             if ($original['spec_type'] == 20) {
diff --git a/app/job/service/goods/GoodsStoreImport.php b/app/job/service/goods/GoodsStoreImport.php
index e5c46f93..d8e9dd38 100644
--- a/app/job/service/goods/GoodsStoreImport.php
+++ b/app/job/service/goods/GoodsStoreImport.php
@@ -110,7 +110,10 @@ class GoodsStoreImport extends BaseService
                 continue;
             }
         	$data = $this->createData($item, $storeId);
-        	$service->single($item['D'], $data, $storeId);
+        	$ret = $service->single($item['D'], $data, $storeId);
+            if ($ret == false) {
+                continue;
+            }
             // 记录导入成功
             $this->successCount++;
         }
diff --git a/app/store/controller/Goods.php b/app/store/controller/Goods.php
index 194130b5..aa9e368f 100644
--- a/app/store/controller/Goods.php
+++ b/app/store/controller/Goods.php
@@ -25,6 +25,7 @@ use app\common\model\GoodsCategoryRel;
  */
 class Goods extends Controller
 {
+    private static $show_content = "***";
     /**
      * 商品列表
      * @return Json
@@ -35,8 +36,25 @@ class Goods extends Controller
         // 获取列表记录
         $model = new GoodsModel;
         $params = $this->request->param();
-        $params['channel'] = 'zy';
-        $list= $model->getList($params, (int)$this->request->param('pageSize', 15));
+        //$params['channel'] = 'zy';
+        $list = $model->getList($params, (int)$this->request->param('pageSize', 15));
+        if ($list->isEmpty()) {
+            return $this->renderSuccess(compact('list'));
+        }
+        $list = $list->toArray();
+        
+        foreach ($list['data'] as &$value) {
+            if (!in_array($value['channel'], ['zy'])) {
+                $value['goods_price_min'] = self::$show_content;
+                $value['goods_price_max'] = self::$show_content;
+                $value['line_price_max'] = self::$show_content;
+                $value['line_price_min'] = self::$show_content;
+                $value['cost_price_min'] = self::$show_content;
+                $value['goods_no'] = self::$show_content;
+            }
+            
+        }
+        
         return $this->renderSuccess(compact('list'));
     }
 
@@ -67,6 +85,19 @@ class Goods extends Controller
         // 获取商品详情
         $model = new GoodsModel;
         $goodsInfo = $model->getDetail($goodsId);
+        if (!in_array($goodsInfo['channel'], ['zy'])) {
+            $goodsInfo['goods_price_min'] = self::$show_content;
+            $goodsInfo['goods_price_max'] = self::$show_content;
+            $goodsInfo['line_price_max'] = self::$show_content;
+            $goodsInfo['line_price_min'] = self::$show_content;
+            $goodsInfo['cost_price_min'] = self::$show_content;
+            $goodsInfo['goods_no'] = self::$show_content;
+            foreach ($goodsInfo['skuList'] as $key => &$value) {
+                $value['goods_price'] = self::$show_content;
+                $value['cost_price'] = self::$show_content;
+            }
+            
+        }
         return $this->renderSuccess(compact('goodsInfo'));
     }
 
@@ -117,8 +148,22 @@ class Goods extends Controller
     {
         // 商品详情
         $model = GoodsModel::detail($goodsId);
+        $params = $this->postForm();
+        if ($model->isEmpty()) {
+            return $this->renderError("该商品已不存在!");
+        }
+        if (!in_array($model->channel, ['zy'])) {
+            $params['goods_price'] = $model->goods_price_min;
+            $params['cost_price'] = $model->cost_price_min;
+            $params['goods_no'] = $model->goods_no;
+        }
+        
+        echo "
";
+        print_r($params);
+        print_r($model->toArray());
+        exit();
         // 更新记录
-        if ($model->edit($this->postForm())) {
+        if ($model->edit($params)) {
             return $this->renderSuccess('更新成功');
         }
         return $this->renderError($model->getError() ?: '更新失败');

From fad622eead03129e518d53c605ea9ddc829dd3c8 Mon Sep 17 00:00:00 2001
From: lqmac 
Date: Tue, 21 May 2024 18:29:58 +0800
Subject: [PATCH 5/7] q

---
 app/api/controller/Controller.php |  3 +++
 app/api/controller/Goods.php      |  5 ++++
 app/common/model/Goods.php        | 38 +++++++++++++++++++++++++------
 app/store/controller/Goods.php    |  8 +++----
 4 files changed, 43 insertions(+), 11 deletions(-)

diff --git a/app/api/controller/Controller.php b/app/api/controller/Controller.php
index 67127e6a..828292ed 100644
--- a/app/api/controller/Controller.php
+++ b/app/api/controller/Controller.php
@@ -32,6 +32,8 @@ class Controller extends BaseController
     // 当前商城ID
     protected int $storeId;
 
+    protected  $storeInfo;
+
     /**
      * API基类初始化
      * @throws BaseException
@@ -82,6 +84,7 @@ class Controller extends BaseController
         if ($store['is_recycle'] || $store['is_delete']) {
             throwError('很抱歉,当前商城已删除');
         }
+        $this->storeInfo = $store;
     }
 
     /**
diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php
index cd7e6057..d94d3570 100644
--- a/app/api/controller/Goods.php
+++ b/app/api/controller/Goods.php
@@ -39,9 +39,14 @@ class Goods extends Controller
      */
     public function list(): Json
     {
+
         // 获取列表数据
         $model = new GoodsModel;
         $param = $this->request->param();
+        //限制过滤条件-渠道
+        $param['channels'] = $this->storeInfo['open_channel'] ? array_merge(['zy'], explode(",", $this->storeInfo['open_channel'])) : [];
+        //分类利润-利润率
+        $param['fliter_condition'] = $this->storeInfo['fliter_condition'];
         $list = $model->getList($param);
         return $this->renderSuccess(compact('list'));
     }
diff --git a/app/common/model/Goods.php b/app/common/model/Goods.php
index 271ca05d..880bbc3b 100644
--- a/app/common/model/Goods.php
+++ b/app/common/model/Goods.php
@@ -329,13 +329,36 @@ class Goods extends BaseModel
                 $query = $query->whereRaw('goods_name like ? or goods_no like ?', ["%{$val}%", "%{$val}%"]);
             }
         }
-        // 执行查询
-        $list = $query->with(['images.file'])
-            ->alias($this->name)
-            ->field($field)
-            ->where('is_delete', '=', 0)
-            ->order($sort)
-            ->paginate($listRows);
+        if (isset($param['fliter_condition']) && $param['fliter_condition']) {
+            $fliter_condition = json_decode($param['fliter_condition'], true);
+            
+            $str = "";
+            foreach ($fliter_condition as $value) {
+                $strConditon = "(";
+                $strConditon .= "goods_category_rel.category_id in (".implode(",", $value['category']).")";
+                $strConditon .= " and goods.profit >= ".$value['profit'];
+                $strConditon .= " and goods.profit_rate >= ".$value['profit_rate'] . ") or ";
+                $str .= $strConditon;
+            }
+            $str = trim($str, "or ");
+            // 执行查询
+            $list = $query->with(['images.file'])
+                ->alias($this->name)
+                ->field($field)
+                ->where('is_delete', '=', 0)
+                ->where($str)
+                ->order($sort)
+                ->paginate($listRows);
+        } else {
+            // 执行查询
+            $list = $query->with(['images.file'])
+                ->alias($this->name)
+                ->field($field)
+                ->where('is_delete', '=', 0)
+                ->order($sort)
+                ->paginate($listRows);
+        }
+          
 
         // 整理列表数据并返回
         return $this->setGoodsListData($list);
@@ -526,6 +549,7 @@ class Goods extends BaseModel
         if (isset($param['is_has_detail']) && $param['is_has_detail'] !== '') {
             $filter[] = ['goods.is_has_detail', '=', $params['is_has_detail']];
         }
+
         // 实例化新查询对象
         return $query->where($filter);
     }
diff --git a/app/store/controller/Goods.php b/app/store/controller/Goods.php
index aa9e368f..03d3c89c 100644
--- a/app/store/controller/Goods.php
+++ b/app/store/controller/Goods.php
@@ -158,10 +158,10 @@ class Goods extends Controller
             $params['goods_no'] = $model->goods_no;
         }
         
-        echo "
";
-        print_r($params);
-        print_r($model->toArray());
-        exit();
+        // echo "
";
+        // print_r($params);
+        // print_r($model->toArray());
+        // exit();
         // 更新记录
         if ($model->edit($params)) {
             return $this->renderSuccess('更新成功');

From 1be278da4dd942685493280218d7c9e35e4018b1 Mon Sep 17 00:00:00 2001
From: lqmac 
Date: Wed, 22 May 2024 12:37:11 +0800
Subject: [PATCH 6/7] 1

---
 app/admin/controller/goods/Import.php | 2 +-
 app/api/controller/Goods.php          | 2 +-
 app/common/model/Goods.php            | 2 +-
 app/store/model/Store.php             | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/app/admin/controller/goods/Import.php b/app/admin/controller/goods/Import.php
index 9437a517..ba31bc5a 100644
--- a/app/admin/controller/goods/Import.php
+++ b/app/admin/controller/goods/Import.php
@@ -35,7 +35,7 @@ class Import extends Controller
         $params['store_id'] = 0;
         $model = new ImportModel;
         $platform = $this->getUserPlatform();
-        $params['channels'] = $platform ? array_column($platform->toArray(), "code") : [];
+        $params['channels'] = $this->admin['user']['role'] == 0 ? [] : ($platform ? array_column($platform->toArray(), "code") : []);
         $list = $model->getList($params);
         return $this->renderSuccess(compact('list'));
     }
diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php
index d94d3570..dee1faf1 100644
--- a/app/api/controller/Goods.php
+++ b/app/api/controller/Goods.php
@@ -411,7 +411,7 @@ class Goods extends Controller
         $wxConfig = WxappSettingModel::getConfigBasic($store_id);
         // 请求api获取短连接
         $link_obj = new ShortLink($wxConfig['app_id'], $wxConfig['app_secret']);
-        $url = $link_obj->shortUrl($page_url, $page_title);
+        $url = $link_obj->shortUrl($page_url, "");
         return $this->renderSuccess(['url' => $url]);
     }
 
diff --git a/app/common/model/Goods.php b/app/common/model/Goods.php
index 880bbc3b..286a6a82 100644
--- a/app/common/model/Goods.php
+++ b/app/common/model/Goods.php
@@ -584,7 +584,7 @@ class Goods extends BaseModel
     protected function setGoodsData($goodsInfo, callable $callback = null)
     {
         $channel = Channel::withoutGlobalScope()->where('code', $goodsInfo['channel'])->find();
-        $goodsInfo['channel_name'] = $channel['name'] ?? "";
+        $goodsInfo['channel_name'] = $channel['alias'] ?? "";
 
         $goodsInfo['goods_images'] = helper::getArrayColumn($goodsInfo['images'], 'file');
         // 商品主图
diff --git a/app/store/model/Store.php b/app/store/model/Store.php
index 0bbf86e5..32fcc630 100644
--- a/app/store/model/Store.php
+++ b/app/store/model/Store.php
@@ -30,7 +30,7 @@ class Store extends StoreModel
     {
         // 是否删除图片
         !isset($data['logo_image_id']) && $data['logo_image_id'] = 0;
-        $data['fliter_condition'] = json_encode($data['fliter_condition'], JSON_UNESCAPED_UNICODE);
+        $data['fliter_condition'] = isset($data['fliter_condition']) ? json_encode($data['fliter_condition'], JSON_UNESCAPED_UNICODE) : "";
         return $this->save($data) !== false;
     }
 }

From 3cf25d8c3f7bb5d496de363fe7a8670911e93b93 Mon Sep 17 00:00:00 2001
From: lqmac 
Date: Thu, 23 May 2024 01:09:26 +0800
Subject: [PATCH 7/7] 1

---
 app/api/controller/Controller.php | 4 +++-
 app/api/controller/Goods.php      | 6 +++---
 app/store/model/Goods.php         | 4 ++--
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/app/api/controller/Controller.php b/app/api/controller/Controller.php
index 828292ed..7a11aec1 100644
--- a/app/api/controller/Controller.php
+++ b/app/api/controller/Controller.php
@@ -34,6 +34,8 @@ class Controller extends BaseController
 
     protected  $storeInfo;
 
+    protected  $user;
+
     /**
      * API基类初始化
      * @throws BaseException
@@ -49,7 +51,7 @@ class Controller extends BaseController
         $this->checkStore();
         // 验证当前客户端状态
         $this->checkClient();
-        //$user = $this->getLoginUser();
+        $this->user = $this->getLoginUser(false);
 //        if ($user) {
 //            if ($user->user_type == 0 || $user->status == 0) {
 //                throwError('很抱歉,您没有权限进入系统');
diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php
index dee1faf1..c1fe2ced 100644
--- a/app/api/controller/Goods.php
+++ b/app/api/controller/Goods.php
@@ -294,11 +294,11 @@ class Goods extends Controller
     public function recommended(): Json
     {
         $service = new GoodsService;
-       $cache_key = "goods_recommended".$this->storeId;
-       if(Cache::has($cache_key)) {
+        $cache_key = "goods_recommended".$this->storeId.($this->user ? $this->user->user_type : 0);
+        if(Cache::has($cache_key)) {
            $goodsList = Cache::get($cache_key);
            return $this->renderSuccess(compact('goodsList'));
-       }
+        }
         $goodsList = $service->recommended();
         Cache::set($cache_key, $goodsList, 60*60);
         return $this->renderSuccess(compact('goodsList'));
diff --git a/app/store/model/Goods.php b/app/store/model/Goods.php
index bd8d31c5..09a2e1b2 100644
--- a/app/store/model/Goods.php
+++ b/app/store/model/Goods.php
@@ -183,7 +183,7 @@ class Goods extends GoodsModel
     public function setIsPool(array $goodsIds, int $is_pool): bool
     {
         // 批量更新记录
-        return static::updateBase(['is_pool' => $is_pool,'update_time' => time()], [['goods_id', 'in', $goodsIds]]);
+        return static::updateBase(['is_pool' => $is_pool,'update_time' => time(),'sale_time' => time()], [['goods_id', 'in', $goodsIds]]);
     }
     /**
      * 修改商品状态
@@ -194,7 +194,7 @@ class Goods extends GoodsModel
     public function setIsSale(array $goodsIds, int $is_sale): bool
     {
         // 批量更新记录
-        return static::updateBase(['is_sale' => $is_sale,'update_time' => time()], [['goods_id', 'in', $goodsIds]]);
+        return static::updateBase(['is_sale' => $is_sale,'update_time' => time(),'sale_time' => time()], [['goods_id', 'in', $goodsIds]]);
     }
     /**
      * 修改商品状态