mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-12-01 06:30:49 +00:00
feat: #10000 存储团购商品信息
This commit is contained in:
parent
8f3ced4c28
commit
7ae08f0615
@ -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']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -38,6 +38,7 @@ class BusinessGoodsSku extends Model
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'shop_id',
|
||||
'activity_no',
|
||||
'update_time',
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user