mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-12-01 14:40:44 +00:00
feat: #10000 优化快团团商品关联使用
This commit is contained in:
parent
79ccb1a5b1
commit
6d9fbe57e1
@ -29,6 +29,7 @@ class BusinessGoodsSkusController extends Controller
|
|||||||
{
|
{
|
||||||
$businessGoodsSkus = BusinessGoodsSku::query()
|
$businessGoodsSkus = BusinessGoodsSku::query()
|
||||||
->filter()
|
->filter()
|
||||||
|
->where('quantity_type', 0)
|
||||||
->with(['shop:id,name'])
|
->with(['shop:id,name'])
|
||||||
->paginate($request->get('per_page'));
|
->paginate($request->get('per_page'));
|
||||||
|
|
||||||
@ -77,7 +78,7 @@ class BusinessGoodsSkusController extends Controller
|
|||||||
|
|
||||||
public function syncStock($id, Request $request)
|
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);
|
[$goodsCode, $skuCode] = explode('_', $businessGoodsSku->external_sku_id);
|
||||||
$sku = GoodsSku::query()->where('sku_code', $skuCode)
|
$sku = GoodsSku::query()->where('sku_code', $skuCode)
|
||||||
->whereHas('goods', function ($query) use ($goodsCode) {
|
->whereHas('goods', function ($query) use ($goodsCode) {
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
namespace App\Http\Controllers\Shop;
|
namespace App\Http\Controllers\Shop;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\BusinessGoodsSku;
|
||||||
use App\Models\GoodsSku;
|
use App\Models\GoodsSku;
|
||||||
use App\Models\Shop;
|
use App\Models\Shop;
|
||||||
use App\Http\Resources\ShopsResource;
|
use App\Http\Resources\ShopsResource;
|
||||||
@ -171,6 +172,8 @@ class ShopsController extends Controller
|
|||||||
public function downloadGoods($id, Request $request)
|
public function downloadGoods($id, Request $request)
|
||||||
{
|
{
|
||||||
$shop = Shop::query()->find($id);
|
$shop = Shop::query()->find($id);
|
||||||
|
// 删除已下载的商品数据
|
||||||
|
BusinessGoodsSku::query()->where('shop_id', $shop->id)->delete();
|
||||||
$business = BusinessFactory::init()->make($shop->plat_id);
|
$business = BusinessFactory::init()->make($shop->plat_id);
|
||||||
$business->setShop($shop);
|
$business->setShop($shop);
|
||||||
$business->downloadGoodsListAndBind();
|
$business->downloadGoodsListAndBind();
|
||||||
|
|||||||
@ -62,7 +62,7 @@ class UpdateBusinessGoodsStock implements ShouldQueue
|
|||||||
|
|
||||||
foreach ($shops as $shop) {
|
foreach ($shops as $shop) {
|
||||||
$num = $event->goodsSku->stock;
|
$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) {
|
foreach ($businessGoodsSkus as $businessGoodsSku) {
|
||||||
BusinessGoodsSkuIncrQuantity::dispatch($shop, $businessGoodsSku->toArray(), $num, false);
|
BusinessGoodsSkuIncrQuantity::dispatch($shop, $businessGoodsSku->toArray(), $num, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,6 +70,7 @@ class BusinessGoodsSku extends Model
|
|||||||
'theoretically_refund_amount',
|
'theoretically_refund_amount',
|
||||||
'thumb_url',
|
'thumb_url',
|
||||||
'verification_number',
|
'verification_number',
|
||||||
|
'quantity_type'
|
||||||
];
|
];
|
||||||
|
|
||||||
public function shop()
|
public function shop()
|
||||||
|
|||||||
@ -31,6 +31,9 @@ class Goods
|
|||||||
$businessGood['goods_image_list'] = json_encode($businessGood['goods_image_list'], 256);
|
$businessGood['goods_image_list'] = json_encode($businessGood['goods_image_list'], 256);
|
||||||
foreach ($skuList as $sku) {
|
foreach ($skuList as $sku) {
|
||||||
$sku['spec_list'] = json_encode($sku['spec_list'], 256);
|
$sku['spec_list'] = json_encode($sku['spec_list'], 256);
|
||||||
|
if ((int)$businessGood['quantity_type']) {
|
||||||
|
$businessGood['is_sync'] = 0;
|
||||||
|
}
|
||||||
$data = array_merge($businessGood, $sku);
|
$data = array_merge($businessGood, $sku);
|
||||||
$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']],
|
||||||
|
|||||||
@ -123,12 +123,6 @@ class KuaiTuanTuan extends BusinessClient
|
|||||||
$publicParams['sign'] = $this->getSign($publicParams);
|
$publicParams['sign'] = $this->getSign($publicParams);
|
||||||
$res = $this->formDataPostRequest($url, $publicParams);
|
$res = $this->formDataPostRequest($url, $publicParams);
|
||||||
if (isset($res['error_response'])) {
|
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));
|
Log::info(json_encode($res, 256));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user