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();