feat: #10000 优化快团团店铺商品下载

This commit is contained in:
赵世界 2023-01-29 11:29:48 +08:00
parent 73285afbc1
commit 011cbec842
9 changed files with 22 additions and 37 deletions

View File

@ -174,7 +174,12 @@ class ShopsController extends Controller
$shop = Shop::query()->find($id); $shop = Shop::query()->find($id);
$business = BusinessFactory::init()->make($shop->plat_id); $business = BusinessFactory::init()->make($shop->plat_id);
$business->setShop($shop); $business->setShop($shop);
$business->downloadGoodsListAndBind(); $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']);
}
}
return response($this->res, $this->res['httpCode']); return response($this->res, $this->res['httpCode']);
} }

View File

@ -41,11 +41,6 @@ class BusinessGoodsSku extends Model
'create_time' 'create_time'
]; ];
/**
* 不可批量赋值的属性。为空则所有熟悉都可以批量赋值
*
* @var array
*/
protected $fillable = [ protected $fillable = [
'shop_id', 'shop_id',
'business_order_id', 'business_order_id',

View File

@ -4,11 +4,6 @@ namespace App\Models;
class BusinessOrder extends Model class BusinessOrder extends Model
{ {
/**
* 不可批量赋值的属性。为空则所有熟悉都可以批量赋值
*
* @var array
*/
protected $fillable = [ protected $fillable = [
'shop_id', 'shop_id',
'receiver_address_detail', 'receiver_address_detail',

View File

@ -4,11 +4,6 @@ namespace App\Models;
class BusinessOrderItem extends Model class BusinessOrderItem extends Model
{ {
/**
* 不可批量赋值的属性。为空则所有熟悉都可以批量赋值
*
* @var array
*/
protected $fillable = [ protected $fillable = [
'shop_id', 'shop_id',
'business_order_id', 'business_order_id',

View File

@ -15,11 +15,6 @@ class GoodsSku extends Model
'exclude_ids' 'exclude_ids'
]; ];
/**
* 不可批量赋值的属性。为空则所有熟悉都可以批量赋值
*
* @var array
*/
protected $fillable = [ protected $fillable = [
'goods_id', 'goods_id',
'title', 'title',

View File

@ -23,7 +23,7 @@ abstract class BusinessClient
abstract public function auth(); abstract public function auth();
abstract public function downloadGoodsListAndBind(); abstract public function downloadGoodsListAndBind($activityNo);
abstract public function downloadGoods($skuId); abstract public function downloadGoods($skuId);

View File

@ -11,7 +11,7 @@ class Goods
{ {
$type = 'pdd.ktt.goods.query.list'; $type = 'pdd.ktt.goods.query.list';
$appendParams = [ $appendParams = [
// 'activity_no' => $activityNo, // 非必填,团号(团号和创建时间只能传一个) 'activity_no' => $activityNo, // 非必填,团号(团号和创建时间只能传一个)
'page' => $page, 'page' => $page,
'size' => $size, 'size' => $size,
// 'update_time_end' => '', // 非必填,结束最后更新时间(毫秒级时间戳) // 'update_time_end' => '', // 非必填,结束最后更新时间(毫秒级时间戳)

View File

@ -40,15 +40,15 @@ class KuaiTuanTuan extends BusinessClient
return $this->shop; return $this->shop;
} }
public function downloadGoodsListAndBind($page = 1) public function downloadGoodsListAndBind($activityNo, $page = 1)
{ {
[$type, $appendParams] = Goods::downloadGoods($this->shop->owner_id, $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);
$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($page + 1); $this->downloadGoodsListAndBind($activityNo, $page + 1);
} }
} }
@ -221,16 +221,16 @@ class KuaiTuanTuan extends BusinessClient
{ {
[$type, $appendParams] = Groups::queryGroup(); [$type, $appendParams] = Groups::queryGroup();
$res = $this->doRequest($type, $appendParams); $res = $this->doRequest($type, $appendParams);
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) {
$group = GroupsModel::query()->where('activity_no', $activity['activity_no'])->first(); // $group = GroupsModel::query()->where('activity_no', $activity['activity_no'])->first();
if ($group) { // if ($group) {
$group->is_help_sell = $activity['']; // $group->is_help_sell = $activity[''];
$group->status = $activity['']; // $group->status = $activity[''];
$group->save(); // $group->save();
} // }
} // }
} // }
return $res; return $res;
} }

View File

@ -13,7 +13,7 @@ class MiaoXuan extends BusinessClient
// TODO: Implement auth() method. // TODO: Implement auth() method.
} }
public function downloadGoodsListAndBind() public function downloadGoodsListAndBind($activityNo)
{ {
} }