feat: #10000 测试完成

This commit is contained in:
赵世界 2023-04-22 15:56:53 +08:00
parent 27b56f9f4e
commit afa5d3e866
5 changed files with 19 additions and 20 deletions

View File

@ -131,17 +131,20 @@ class BusinessGoodsSkusController extends Controller
if ($todayPrice->isEmpty()) {
exit('今日价格数据未找到,请先上传');
}
$todayGoodsPrice = [];
$shopNames = $todayGoodsPrice = [];
foreach ($todayPrice as $item) {
$shopPrice = json_decode($item['shop_price'], true);
$todayGoodsPrice[$item['external_sku_id']] = [
'goods_name' => $item['goodsSku']['goods']['title'] . $item['goodsSku']['title'],
'external_sku_id' => $item['external_sku_id'],
'shop_price' => json_decode($item['shop_price'], true),
'shop_price' => $shopPrice,
];
$shopNames = $shopNames ?: array_keys($shopNames);
}
$shops = Shop::query()
->where('plat_id', Shop::$PLAT_KTT)
->where('expires_at', '>', time())
->whereIn('name', $shopNames)
->get();
$data = [];
foreach ($shops as $shop) {

View File

@ -19,13 +19,16 @@ class GoodsCombinationController extends Controller
{
public function index(Request $request)
{
// ToDo
// 可通过子商城查找主商品
$skus = GoodsSku::query()
->where('is_combination', 1)
->with([
'combinationGoods:id,goods_sku_id,item_id,item_num',
'combinationGoods.goodsSkuItem:id,goods_id,title,stock,external_sku_id,updated_at,yesterday_num,reference_price,status',
'combinationGoods.goodsSkuItem.goods:id,title,img_url',
])
->where('is_combination', 1)
->filter()
->paginate($request->get('per_page'));
foreach ($skus as &$item) {
$items = [];
@ -106,7 +109,7 @@ class GoodsCombinationController extends Controller
CombinationGood::query()->create(['goods_sku_id' => $sku->id, 'item_id' => $item['item_id'], 'item_num' => $item['item_num']]);
}
DB::commit();
event(new StockUpdateEvent($sku));
// event(new StockUpdateEvent($sku, 0, true));
} catch (\Exception $exception) {
DB::rollBack();
$this->res = [

View File

@ -66,7 +66,7 @@ class CombinationGoodsImport implements ToArray, SkipsEmptyRows, WithStartRow
$stock = $num;
}
}
$sku = GoodsSku::query()->firstOrCreate(
$sku = GoodsSku::query()->updateOrCreate(
['external_sku_id' => $info['external_sku_id'], 'is_combination' => 1],
['title' => $info['title'], 'goods_id' => 0, 'sku_code' => $info['external_sku_id'], 'stock' => $stock]
);
@ -77,7 +77,7 @@ class CombinationGoodsImport implements ToArray, SkipsEmptyRows, WithStartRow
CombinationGood::query()->create(['goods_sku_id' => $sku->id, 'item_id' => $skus[$item['item_code']]['id'], 'item_num' => $item['item_num']]);
}
DB::commit();
event(new StockUpdateEvent($sku));
// event(new StockUpdateEvent($sku, 0, true));
} catch (\Exception $exception) {
DB::rollBack();
}

View File

@ -29,7 +29,8 @@ class GoodsSku extends Model
'reference_price',
'reserve',
'thumb_url',
'external_sku_id'
'external_sku_id',
'is_combination',
];
protected $hidden = ['created_at'];

View File

@ -2,20 +2,19 @@
<div>
<el-card :body-style="{ padding: '20px 20px 0 20px' }">
<div class="goods">
<el-form ref="form" :inline="true" :model="searchForm">
<el-form ref="searchForm" :inline="true" :model="searchForm">
<el-form-item label="商品名称:">
<el-input v-model="searchForm.goods_title" placeholder="商品名称" style="width: 100px"></el-input>
<el-input v-model="searchForm.sku_title" placeholder="商品名称" style="width: 100px"></el-input>
</el-form-item>
<el-form-item label="商品编码:">
<el-input v-model="searchForm.external_sku_id" placeholder="商品编码" style="width: 100px"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleChoose(1)">筛选</el-button>
<el-button plain @click="handleReChoose()">重置筛选</el-button>
<el-upload ref="myUpload" action="/api/combination/goods" :multiple="false" name="combinationGoods"
:show-file-list="false" :on-success="uploadSuccess" :before-upload="beforeUpload"
:on-error="uploadError" style="display:inline-block;margin: 0 10px 0 10px;">
<el-button type="primary" plain>商品货架导入</el-button>
<el-button type="primary" plain>组合商品导入</el-button>
</el-upload>
</el-form-item>
</el-form>
@ -112,7 +111,7 @@ export default {
tableData: [], //
searchForm: {
external_sku_id: "",
goods_title: "", //
sku_title: "", //
},
Paginationdata: {}, //
current_page: 1, //
@ -163,13 +162,6 @@ export default {
};
this.getList(this.searchForm);
},
//
handleReChoose() {
this.form = {
external_sku_id: "",
goods_title: "", //
};
},
//
handleSizeChange(val) {
//