fix: #0909 商品下载后同步库存

This commit is contained in:
赵世界 2022-09-14 15:59:27 +08:00
parent c4ce86cf10
commit efc6cb0281
2 changed files with 11 additions and 3 deletions

View File

@ -2,6 +2,7 @@
namespace App\Services\Business\KuaiTuanTuan;
use App\Events\BusinessOrdersUpdate;
use App\Models\BusinessGoodsSku;
class Goods
@ -31,10 +32,14 @@ class Goods
foreach ($skuList as $sku) {
$sku['spec_list'] = json_encode($sku['spec_list'], 256);
$data = array_merge($businessGood, $sku);
BusinessGoodsSku::updateOrCreate(
$businessGoodSku = BusinessGoodsSku::firstOrNew(
['shop_id' => $shopId, 'goods_id' => $businessGood['goods_id'], 'sku_id' => $sku['sku_id']],
$data
);
if (empty($businessGood->id)) {
$businessGoodSku->save();
event(new BusinessOrdersUpdate($businessGoodSku, 0));
}
}
}
}

View File

@ -400,12 +400,15 @@ export default {
mounted() {
this.gid = this.$route.query;
let page = {
per_page: 999,
};
//
goods_types().then((res) => {
goods_types(page).then((res) => {
this.cate = res.data.data;
});
//
Brand_goods_types().then((res) => {
Brand_goods_types(page).then((res) => {
this.brand = res.data.data;
});
this.handleList();