Merge pull request !141 from 赵世界/develop
This commit is contained in:
赵世界 2023-01-29 06:04:49 +00:00 committed by Gitee
commit e7915375f6
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 10 additions and 7 deletions

View File

@ -177,7 +177,7 @@ class ShopsController extends Controller
$res = $business->queryGroup(); $res = $business->queryGroup();
if (isset($res['ktt_group_query_list_response'])) { if (isset($res['ktt_group_query_list_response'])) {
foreach ($res['ktt_group_query_list_response']['activity_list'] as $activity) { foreach ($res['ktt_group_query_list_response']['activity_list'] as $activity) {
$business->downloadGoodsListAndBind($activity['activity_no']); $business->downloadGoodsListAndBind($activity['activity_no'], $activity['title']);
} }
} }

View File

@ -38,6 +38,7 @@ class BusinessGoodsSku extends Model
]; ];
protected $fillable = [ protected $fillable = [
'title',
'shop_id', 'shop_id',
'activity_no', 'activity_no',
'update_time', 'update_time',

View File

@ -23,7 +23,7 @@ class Goods
return [$type, $appendParams]; return [$type, $appendParams];
} }
public static function bindGoods(array $goodsList, $shopId) public static function bindGoods(array $goodsList, $shopId, $title = '')
{ {
foreach ($goodsList as $businessGood) { foreach ($goodsList as $businessGood) {
$skuList = $businessGood['sku_list']; $skuList = $businessGood['sku_list'];
@ -35,6 +35,7 @@ class Goods
$sku['is_sync'] = 0; $sku['is_sync'] = 0;
} }
$data = array_merge($businessGood, $sku); $data = array_merge($businessGood, $sku);
$data['title'] = $title;
$businessGoodSku = BusinessGoodsSku::firstOrNew( $businessGoodSku = BusinessGoodsSku::firstOrNew(
['shop_id' => $shopId, 'goods_id' => $businessGood['goods_id'], 'sku_id' => $sku['sku_id']], ['shop_id' => $shopId, 'goods_id' => $businessGood['goods_id'], 'sku_id' => $sku['sku_id']],
$data $data

View File

@ -40,21 +40,21 @@ class KuaiTuanTuan extends BusinessClient
return $this->shop; return $this->shop;
} }
public function downloadGoodsListAndBind($activityNo, $page = 1) public function downloadGoodsListAndBind($activityNo, $title = '', $page = 1)
{ {
[$type, $appendParams] = Goods::downloadGoods($activityNo, $page); [$type, $appendParams] = Goods::downloadGoods($activityNo, $page);
$res = $this->doRequest($type, $appendParams); $res = $this->doRequest($type, $appendParams);
$goods = $res['ktt_goods_query_list_response']['goods_list']; $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']); $pageNum = ceil($res['ktt_goods_query_list_response']['total'] / $appendParams['size']);
if ($pageNum > $page && 60 >= $page) { 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) public function incrQuantity($businessGoodsSku, $num, $incremental)

View File

@ -17,6 +17,7 @@ class CreateBusinessGoodsSkusTable extends Migration
$table->bigIncrements('id'); $table->bigIncrements('id');
$table->bigInteger('shop_id'); $table->bigInteger('shop_id');
$table->bigInteger('self_sku_id')->nullable(); $table->bigInteger('self_sku_id')->nullable();
$table->text('title')->nullable();
$table->string('activity_no')->nullable(); $table->string('activity_no')->nullable();
$table->string('category_name')->nullable(); $table->string('category_name')->nullable();
$table->bigInteger('create_time')->nullable(); $table->bigInteger('create_time')->nullable();