From 354715505a66c19a27fd1443570bba43df2c35c6 Mon Sep 17 00:00:00 2001 From: lqmac Date: Thu, 13 Jun 2024 23:16:31 +0800 Subject: [PATCH] 1 --- app/api/controller/Square.php | 5 ++ app/api/model/Goods.php | 7 ++- app/api/service/Cart.php | 9 ++++ app/common/model/Goods.php | 32 ------------- app/common/service/Suning.php | 2 +- app/job/service/goods/Collector.php | 10 ++-- app/store/controller/Goods.php | 72 +++++++++++++++++++++++++++++ app/store/model/Goods.php | 45 +++++++++++++++++- app/store/model/goods/Import.php | 3 +- config/app.php | 1 + 10 files changed, 145 insertions(+), 41 deletions(-) diff --git a/app/api/controller/Square.php b/app/api/controller/Square.php index b3ed276b..b306cd2e 100644 --- a/app/api/controller/Square.php +++ b/app/api/controller/Square.php @@ -101,6 +101,11 @@ class Square extends Controller $files = UploadFile::getFileList($img_ids); $list['data'][$kr]['imgs'] = $files ?: null; } + if ($r['files']) { + $img_ids = explode(",", $r['files']); + $files = UploadFile::getFileList($img_ids); + $list['data'][$kr]['files'] = $files ?: null; + } if ($r['user_name']) { $files = UploadFile::getFileList([$user['avatar_id']]); $list['data'][$kr]['avatar_url'] = $files ?: null; diff --git a/app/api/model/Goods.php b/app/api/model/Goods.php index 673141e1..33715cfd 100644 --- a/app/api/model/Goods.php +++ b/app/api/model/Goods.php @@ -465,7 +465,7 @@ class Goods extends GoodsModel } $goodsInfo['merchant'] = null; //商户信息 - if ($goodsInfo['merchant_id'] && !in_array($goodsInfo['channel'], ['jd','jd1','jd2','sn','sn2','xqtx'])) { + if ($goodsInfo['merchant_id'] && !in_array($goodsInfo['channel'], config('app.not_show_merchant'))) { //if ($goodsInfo['merchant_id']) { $merchant = \app\common\model\Merchant::detail($goodsInfo['merchant_id'], $goodsInfo->store_id); if ($merchant) { @@ -484,6 +484,11 @@ class Goods extends GoodsModel } else { $goodsInfo['merchant_id'] = 0; } + //处理苏宁商品,京东价拖的问题 + if (in_array($goodsInfo['channel'], ['sn','sn1']) && $goodsInfo['link_other']) { + $goodsInfo['link'] = $goodsInfo['link_other']; + $goodsInfo['goods_no'] = $goodsInfo['goods_no_other']; + } //加入足迹 $userId = UserService::getCurrentLoginUserId(false) ?? ''; if ($userId) { diff --git a/app/api/service/Cart.php b/app/api/service/Cart.php index 2f8475f2..68b895b7 100644 --- a/app/api/service/Cart.php +++ b/app/api/service/Cart.php @@ -50,6 +50,15 @@ class Cart extends BaseService foreach ($cartList as $cartIdx => $item) { // 查找商品, 商品不存在则删除该购物车记录 $result = $this->findGoods($goodsList, $item, $enableGradeMoney); + //商户信息处理 + if ($result['merchant_id'] && !in_array($result['channel'], config('app.not_show_merchant'))) { + $merchant = \app\common\model\Merchant::detail($result['merchant_id'], $result->store_id); + $result['merchant'] = $merchant; + } else { + $result['merchant_id'] = 0; + $result['merchant'] = null; + } + if ($result !== false) { $cartList[$cartIdx]['goods'] = $result; } else { diff --git a/app/common/model/Goods.php b/app/common/model/Goods.php index 571eb105..10c30cb6 100644 --- a/app/common/model/Goods.php +++ b/app/common/model/Goods.php @@ -299,38 +299,6 @@ class Goods extends BaseModel } } - // if (!empty($order)) { - // if ($order == 1) { - // $sort = ['goods_price_min' => 'asc']; - // } - // if ($order == 2) { - // $sort = ['goods_price_min' => 'desc']; - // } - - // if ($order == 3) { - // $sort = ['discount' => 'asc']; - // } - // if ($order == 4) { - // $sort = ['discount' => 'desc']; - // } - - // if ($order == 5) { - // $sort = ['goods_sales' => 'asc']; - - // } - // if ($order == 6) { - // $sort = ['goods_sales' => 'desc']; - // } - - // if ($order == 7) { - // $sort = ['goods_sales' => 'asc']; - // } - // if ($order == 8) { - // $sort = ['goods_sales' => 'desc']; - // } - // } - - $field = $this->getAliasFields($this->name, ['content']); $field[] = 'selling_point'; diff --git a/app/common/service/Suning.php b/app/common/service/Suning.php index 1b790003..e11bdac7 100644 --- a/app/common/service/Suning.php +++ b/app/common/service/Suning.php @@ -219,7 +219,7 @@ class Suning extends BaseService { foreach ($data as $key => &$value) { //$goods = GoodsModel::where('goods_id', $sku['goods_id'])->find(); $arr = [ - 'state'=> $value['state'] == 1 ? "有货" : "无货", + 'state'=> (isset($value['state']) &&$value['state'] == 1) ? "有货" : "无货", //'goods_name'=> $goods['goods_name'], //'goods_id'=> $goods['goods_id'], ]; diff --git a/app/job/service/goods/Collector.php b/app/job/service/goods/Collector.php index 9e13cb7b..7790a67f 100644 --- a/app/job/service/goods/Collector.php +++ b/app/job/service/goods/Collector.php @@ -279,8 +279,8 @@ class Collector extends BaseService if (!$goods || !$url) { return true; } - //新阙通信的抓取过了,就不抓取了 - if ($goods['channel'] == 'xqtx' && $goods['content']) { + //新阙通信的抓取过了,就不抓取了;京东价拖抓取过了就不抓取了 + if (($goods['channel'] == 'xqtx' && $goods['content']) || $goods->goods_no_other) { return true; } try { @@ -320,9 +320,9 @@ class Collector extends BaseService $this->errorLog[] = ['url' => trim($url), 'message' => $e->getMessage()]; return false; } - if ($original['goods_price'] == 0) { - return false; - } + // if ($original['goods_price'] == 0) { + // return false; + // } $original['cost_price'] = $form['cost_price_min']; $data['link_other'] = $url; diff --git a/app/store/controller/Goods.php b/app/store/controller/Goods.php index 6bd08b15..79448708 100644 --- a/app/store/controller/Goods.php +++ b/app/store/controller/Goods.php @@ -208,7 +208,79 @@ class Goods extends Controller } return $this->renderSuccess('操作成功'); } + /** + * 修改商品状态(上下架) + * @param array $goodsIds 商品id集 + * @param bool $state 为true表示上架 + * @return Json + */ + public function setBrand(array $goodsIds, bool $is_brand): Json + { + $model = new GoodsModel; + if (!$model->setBrand($goodsIds, $is_brand)) { + return $this->renderError($model->getError() ?: '操作失败'); + } + return $this->renderSuccess('操作成功'); + } + /** + * 修改商品状态(上下架) + * @param array $goodsIds 商品id集 + * @param bool $state 为true表示上架 + * @return Json + */ + public function setNew(array $goodsIds, bool $is_new): Json + { + $model = new GoodsModel; + if (!$model->setNew($goodsIds, $is_new)) { + return $this->renderError($model->getError() ?: '操作失败'); + } + return $this->renderSuccess('操作成功'); + } + /** + * 修改商品状态(上下架) + * @param array $goodsIds 商品id集 + * @param bool $state 为true表示上架 + * @return Json + */ + public function setInstore(array $goodsIds, bool $is_in_store): Json + { + $model = new GoodsModel; + if (!$model->setInstore($goodsIds, $is_in_store)) { + return $this->renderError($model->getError() ?: '操作失败'); + } + return $this->renderSuccess('操作成功'); + } + /** + * 修改商品状态(上下架) + * @param array $goodsIds 商品id集 + * @param bool $state 为true表示上架 + * @return Json + */ + public function setRank(array $goodsIds, int $paihang): Json + { + $model = new GoodsModel; + if (!$model->setRank($goodsIds, $paihang)) { + return $this->renderError($model->getError() ?: '操作失败'); + } + return $this->renderSuccess('操作成功'); + } + /** + * 商品归类 + * @param array $goodsIds 商品id集 + * @param bool $state 为true表示上架 + * @return Json + */ + public function category(array $goodsIds, array $categoryIds): Json + { + $model = new GoodsModel; + foreach ($goodsIds as $key => $goodsId) { + $categoryIds = $model->dealCategory($categoryIds); + \app\store\model\GoodsCategoryRel::updates($goodsId, $categoryIds); + } + $model->whereIn('goods_id', $goodsIds)->update(['cate_status'=>1,'update_time' => time()]); + return $this->renderSuccess('操作成功'); + } /** * 删除商品 * @param array $goodsIds diff --git a/app/store/model/Goods.php b/app/store/model/Goods.php index 58ded193..40d2f971 100644 --- a/app/store/model/Goods.php +++ b/app/store/model/Goods.php @@ -220,7 +220,50 @@ class Goods extends GoodsModel // 批量更新记录 return static::updateBase(['status' => $state ? 10 : 20], [['goods_id', 'in', $goodsIds]]); } - + /** + * 修改商品状态 + * @param array $goodsIds 商品id集 + * @param bool $state 为true表示上架 + * @return bool|false + */ + public function setBrand(array $goodsIds, bool $is_brand): bool + { + // 批量更新记录 + return static::updateBase(['is_brand' => $is_brand], [['goods_id', 'in', $goodsIds]]); + } + /** + * 修改商品状态 + * @param array $goodsIds 商品id集 + * @param bool $state 为true表示上架 + * @return bool|false + */ + public function setNew(array $goodsIds, bool $is_new): bool + { + // 批量更新记录 + return static::updateBase(['is_new' => $is_new], [['goods_id', 'in', $goodsIds]]); + } + /** + * 修改商品状态 + * @param array $goodsIds 商品id集 + * @param bool $state 为true表示上架 + * @return bool|false + */ + public function setInstore(array $goodsIds, bool $is_in_store): bool + { + // 批量更新记录 + return static::updateBase(['is_in_store' => $is_in_store], [['goods_id', 'in', $goodsIds]]); + } + /** + * 修改商品状态 + * @param array $goodsIds 商品id集 + * @param bool $state 为true表示上架 + * @return bool|false + */ + public function setRank(array $goodsIds, int $is_paihang): bool + { + // 批量更新记录 + return static::updateBase(['paihang' => $is_paihang], [['goods_id', 'in', $goodsIds]]); + } /** * 软删除 * @param array $goodsIds diff --git a/app/store/model/goods/Import.php b/app/store/model/goods/Import.php index 27b8f530..97a9a3cd 100644 --- a/app/store/model/goods/Import.php +++ b/app/store/model/goods/Import.php @@ -86,7 +86,7 @@ class Import extends ImportModel // exit(); // 验证导入的商品数量是否合法 $this->checkLimit($execlData); - + self::$merchantId = $form['merchant_id'] ?? 0; self::$storeId = $form['store_id'] ?? 0; foreach ($execlData as &$value) { $value['B'] = $form['channel']??'zy'; @@ -197,6 +197,7 @@ class Import extends ImportModel $this->checkLimit($execlData); self::$storeId = $form['store_id'] ?? 0; + self::$merchantId = $form['merchant_id'] ?? 0; // $obj = new \app\job\service\goods\GoodsUpdateImport(); // $service = new \app\job\service\goods\Collector(); // foreach ($execlData as $item) { diff --git a/config/app.php b/config/app.php index d4bd10f7..c1a0c144 100644 --- a/config/app.php +++ b/config/app.php @@ -46,4 +46,5 @@ return [ 'pdd' => "拼多多", 'xqtx' => "新阕通信", ], + 'not_show_merchant' => ['jd','jd1','jd2','sn','sn1','xqtx'], ];