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
79ccb1a5b1
commit
6d9fbe57e1
@ -29,6 +29,7 @@ class BusinessGoodsSkusController extends Controller
|
||||
{
|
||||
$businessGoodsSkus = BusinessGoodsSku::query()
|
||||
->filter()
|
||||
->where('quantity_type', 0)
|
||||
->with(['shop:id,name'])
|
||||
->paginate($request->get('per_page'));
|
||||
|
||||
@ -77,7 +78,7 @@ class BusinessGoodsSkusController extends Controller
|
||||
|
||||
public function syncStock($id, Request $request)
|
||||
{
|
||||
$businessGoodsSku = BusinessGoodsSku::query()->find($id);
|
||||
$businessGoodsSku = BusinessGoodsSku::query()->where('is_sync', 1)->find($id);
|
||||
[$goodsCode, $skuCode] = explode('_', $businessGoodsSku->external_sku_id);
|
||||
$sku = GoodsSku::query()->where('sku_code', $skuCode)
|
||||
->whereHas('goods', function ($query) use ($goodsCode) {
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers\Shop;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\BusinessGoodsSku;
|
||||
use App\Models\GoodsSku;
|
||||
use App\Models\Shop;
|
||||
use App\Http\Resources\ShopsResource;
|
||||
@ -171,6 +172,8 @@ class ShopsController extends Controller
|
||||
public function downloadGoods($id, Request $request)
|
||||
{
|
||||
$shop = Shop::query()->find($id);
|
||||
// 删除已下载的商品数据
|
||||
BusinessGoodsSku::query()->where('shop_id', $shop->id)->delete();
|
||||
$business = BusinessFactory::init()->make($shop->plat_id);
|
||||
$business->setShop($shop);
|
||||
$business->downloadGoodsListAndBind();
|
||||
|
||||
@ -62,7 +62,7 @@ class UpdateBusinessGoodsStock implements ShouldQueue
|
||||
|
||||
foreach ($shops as $shop) {
|
||||
$num = $event->goodsSku->stock;
|
||||
$businessGoodsSkus = BusinessGoodsSku::query()->where('shop_id', $shop->id)->where('external_sku_id', $event->businessGoods['external_sku_id'])->get();
|
||||
$businessGoodsSkus = BusinessGoodsSku::query()->where('shop_id', $shop->id)->where('is_sync', 1)->where('external_sku_id', $event->businessGoods['external_sku_id'])->get();
|
||||
foreach ($businessGoodsSkus as $businessGoodsSku) {
|
||||
BusinessGoodsSkuIncrQuantity::dispatch($shop, $businessGoodsSku->toArray(), $num, false);
|
||||
}
|
||||
|
||||
@ -70,6 +70,7 @@ class BusinessGoodsSku extends Model
|
||||
'theoretically_refund_amount',
|
||||
'thumb_url',
|
||||
'verification_number',
|
||||
'quantity_type'
|
||||
];
|
||||
|
||||
public function shop()
|
||||
|
||||
@ -31,6 +31,9 @@ class Goods
|
||||
$businessGood['goods_image_list'] = json_encode($businessGood['goods_image_list'], 256);
|
||||
foreach ($skuList as $sku) {
|
||||
$sku['spec_list'] = json_encode($sku['spec_list'], 256);
|
||||
if ((int)$businessGood['quantity_type']) {
|
||||
$businessGood['is_sync'] = 0;
|
||||
}
|
||||
$data = array_merge($businessGood, $sku);
|
||||
$businessGoodSku = BusinessGoodsSku::firstOrNew(
|
||||
['shop_id' => $shopId, 'goods_id' => $businessGood['goods_id'], 'sku_id' => $sku['sku_id']],
|
||||
|
||||
@ -123,12 +123,6 @@ class KuaiTuanTuan extends BusinessClient
|
||||
$publicParams['sign'] = $this->getSign($publicParams);
|
||||
$res = $this->formDataPostRequest($url, $publicParams);
|
||||
if (isset($res['error_response'])) {
|
||||
// ToDo 重构异常处理
|
||||
if ('业务服务错误' === $res['error_response']['error_msg'] && '该店铺下不存在该商品' === $res['error_response']['sub_msg']) {
|
||||
BusinessGoodsSku::query()->where('goods_id', $appendParams['goods_id'])->where('sku_id', $appendParams['sku_id'])->delete();
|
||||
} else {
|
||||
// throw new \RuntimeException($res['error_response']['error_msg'] . ':' . $res['error_response']['error_msg']);
|
||||
}
|
||||
Log::info(json_encode($res, 256));
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user