From 7ae08f0615ef2fddcb8d2f5690edc8fca4b06edf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Sun, 29 Jan 2023 14:03:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20#10000=20=E5=AD=98=E5=82=A8=E5=9B=A2?= =?UTF-8?q?=E8=B4=AD=E5=95=86=E5=93=81=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Shop/ShopsController.php | 2 +- app/Models/BusinessGoodsSku.php | 1 + app/Services/Business/KuaiTuanTuan/Goods.php | 3 ++- app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php | 10 +++++----- ...2_08_05_030834_create_business_goods_skus_table.php | 1 + 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/Shop/ShopsController.php b/app/Http/Controllers/Shop/ShopsController.php index 7cfdc36..6fc6b4d 100644 --- a/app/Http/Controllers/Shop/ShopsController.php +++ b/app/Http/Controllers/Shop/ShopsController.php @@ -177,7 +177,7 @@ class ShopsController extends Controller $res = $business->queryGroup(); if (isset($res['ktt_group_query_list_response'])) { foreach ($res['ktt_group_query_list_response']['activity_list'] as $activity) { - $business->downloadGoodsListAndBind($activity['activity_no']); + $business->downloadGoodsListAndBind($activity['activity_no'], $activity['title']); } } diff --git a/app/Models/BusinessGoodsSku.php b/app/Models/BusinessGoodsSku.php index c01053f..328c559 100644 --- a/app/Models/BusinessGoodsSku.php +++ b/app/Models/BusinessGoodsSku.php @@ -38,6 +38,7 @@ class BusinessGoodsSku extends Model ]; protected $fillable = [ + 'title', 'shop_id', 'activity_no', 'update_time', diff --git a/app/Services/Business/KuaiTuanTuan/Goods.php b/app/Services/Business/KuaiTuanTuan/Goods.php index 4e6d225..1c1fa23 100644 --- a/app/Services/Business/KuaiTuanTuan/Goods.php +++ b/app/Services/Business/KuaiTuanTuan/Goods.php @@ -23,7 +23,7 @@ class Goods return [$type, $appendParams]; } - public static function bindGoods(array $goodsList, $shopId) + public static function bindGoods(array $goodsList, $shopId, $title = '') { foreach ($goodsList as $businessGood) { $skuList = $businessGood['sku_list']; @@ -35,6 +35,7 @@ class Goods $sku['is_sync'] = 0; } $data = array_merge($businessGood, $sku); + $data['title'] = $title; $businessGoodSku = BusinessGoodsSku::firstOrNew( ['shop_id' => $shopId, 'goods_id' => $businessGood['goods_id'], 'sku_id' => $sku['sku_id']], $data diff --git a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php index 5d62b47..2ccccdd 100644 --- a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php +++ b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php @@ -40,21 +40,21 @@ class KuaiTuanTuan extends BusinessClient return $this->shop; } - public function downloadGoodsListAndBind($activityNo, $page = 1) + public function downloadGoodsListAndBind($activityNo, $title = '', $page = 1) { [$type, $appendParams] = Goods::downloadGoods($activityNo, $page); $res = $this->doRequest($type, $appendParams); $goods = $res['ktt_goods_query_list_response']['goods_list']; - $this->bindGoods($goods); + $this->bindGoods($goods, $title); $pageNum = ceil($res['ktt_goods_query_list_response']['total'] / $appendParams['size']); if ($pageNum > $page && 60 >= $page) { - $this->downloadGoodsListAndBind($activityNo, $page + 1); + $this->downloadGoodsListAndBind($activityNo, $title, $page + 1); } } - public function bindGoods($goods) + public function bindGoods($goods, $title = '') { - Goods::bindGoods($goods, $this->shop->id); + Goods::bindGoods($goods, $this->shop->id, $title); } public function incrQuantity($businessGoodsSku, $num, $incremental) diff --git a/database/migrations/2022_08_05_030834_create_business_goods_skus_table.php b/database/migrations/2022_08_05_030834_create_business_goods_skus_table.php index c768bc7..f295ee6 100644 --- a/database/migrations/2022_08_05_030834_create_business_goods_skus_table.php +++ b/database/migrations/2022_08_05_030834_create_business_goods_skus_table.php @@ -17,6 +17,7 @@ class CreateBusinessGoodsSkusTable extends Migration $table->bigIncrements('id'); $table->bigInteger('shop_id'); $table->bigInteger('self_sku_id')->nullable(); + $table->text('title')->nullable(); $table->string('activity_no')->nullable(); $table->string('category_name')->nullable(); $table->bigInteger('create_time')->nullable();