feat: #10000 测试完成
This commit is contained in:
parent
27b56f9f4e
commit
afa5d3e866
@ -131,17 +131,20 @@ class BusinessGoodsSkusController extends Controller
|
|||||||
if ($todayPrice->isEmpty()) {
|
if ($todayPrice->isEmpty()) {
|
||||||
exit('今日价格数据未找到,请先上传');
|
exit('今日价格数据未找到,请先上传');
|
||||||
}
|
}
|
||||||
$todayGoodsPrice = [];
|
$shopNames = $todayGoodsPrice = [];
|
||||||
foreach ($todayPrice as $item) {
|
foreach ($todayPrice as $item) {
|
||||||
|
$shopPrice = json_decode($item['shop_price'], true);
|
||||||
$todayGoodsPrice[$item['external_sku_id']] = [
|
$todayGoodsPrice[$item['external_sku_id']] = [
|
||||||
'goods_name' => $item['goodsSku']['goods']['title'] . $item['goodsSku']['title'],
|
'goods_name' => $item['goodsSku']['goods']['title'] . $item['goodsSku']['title'],
|
||||||
'external_sku_id' => $item['external_sku_id'],
|
'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()
|
$shops = Shop::query()
|
||||||
->where('plat_id', Shop::$PLAT_KTT)
|
->where('plat_id', Shop::$PLAT_KTT)
|
||||||
->where('expires_at', '>', time())
|
->where('expires_at', '>', time())
|
||||||
|
->whereIn('name', $shopNames)
|
||||||
->get();
|
->get();
|
||||||
$data = [];
|
$data = [];
|
||||||
foreach ($shops as $shop) {
|
foreach ($shops as $shop) {
|
||||||
|
|||||||
@ -19,13 +19,16 @@ class GoodsCombinationController extends Controller
|
|||||||
{
|
{
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
|
// ToDo
|
||||||
|
// 可通过子商城查找主商品
|
||||||
$skus = GoodsSku::query()
|
$skus = GoodsSku::query()
|
||||||
->where('is_combination', 1)
|
|
||||||
->with([
|
->with([
|
||||||
'combinationGoods:id,goods_sku_id,item_id,item_num',
|
'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:id,goods_id,title,stock,external_sku_id,updated_at,yesterday_num,reference_price,status',
|
||||||
'combinationGoods.goodsSkuItem.goods:id,title,img_url',
|
'combinationGoods.goodsSkuItem.goods:id,title,img_url',
|
||||||
])
|
])
|
||||||
|
->where('is_combination', 1)
|
||||||
|
->filter()
|
||||||
->paginate($request->get('per_page'));
|
->paginate($request->get('per_page'));
|
||||||
foreach ($skus as &$item) {
|
foreach ($skus as &$item) {
|
||||||
$items = [];
|
$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']]);
|
CombinationGood::query()->create(['goods_sku_id' => $sku->id, 'item_id' => $item['item_id'], 'item_num' => $item['item_num']]);
|
||||||
}
|
}
|
||||||
DB::commit();
|
DB::commit();
|
||||||
event(new StockUpdateEvent($sku));
|
// event(new StockUpdateEvent($sku, 0, true));
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
$this->res = [
|
$this->res = [
|
||||||
|
|||||||
@ -66,7 +66,7 @@ class CombinationGoodsImport implements ToArray, SkipsEmptyRows, WithStartRow
|
|||||||
$stock = $num;
|
$stock = $num;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sku = GoodsSku::query()->firstOrCreate(
|
$sku = GoodsSku::query()->updateOrCreate(
|
||||||
['external_sku_id' => $info['external_sku_id'], 'is_combination' => 1],
|
['external_sku_id' => $info['external_sku_id'], 'is_combination' => 1],
|
||||||
['title' => $info['title'], 'goods_id' => 0, 'sku_code' => $info['external_sku_id'], 'stock' => $stock]
|
['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']]);
|
CombinationGood::query()->create(['goods_sku_id' => $sku->id, 'item_id' => $skus[$item['item_code']]['id'], 'item_num' => $item['item_num']]);
|
||||||
}
|
}
|
||||||
DB::commit();
|
DB::commit();
|
||||||
event(new StockUpdateEvent($sku));
|
// event(new StockUpdateEvent($sku, 0, true));
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,7 +29,8 @@ class GoodsSku extends Model
|
|||||||
'reference_price',
|
'reference_price',
|
||||||
'reserve',
|
'reserve',
|
||||||
'thumb_url',
|
'thumb_url',
|
||||||
'external_sku_id'
|
'external_sku_id',
|
||||||
|
'is_combination',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $hidden = ['created_at'];
|
protected $hidden = ['created_at'];
|
||||||
|
|||||||
@ -2,20 +2,19 @@
|
|||||||
<div>
|
<div>
|
||||||
<el-card :body-style="{ padding: '20px 20px 0 20px' }">
|
<el-card :body-style="{ padding: '20px 20px 0 20px' }">
|
||||||
<div class="goods">
|
<div class="goods">
|
||||||
<el-form ref="form" :inline="true" :model="searchForm">
|
<el-form ref="searchForm" :inline="true" :model="searchForm">
|
||||||
<el-form-item label="商品名称:">
|
<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>
|
||||||
<el-form-item label="商品编码:">
|
<el-form-item label="商品编码:">
|
||||||
<el-input v-model="searchForm.external_sku_id" placeholder="商品编码" style="width: 100px"></el-input>
|
<el-input v-model="searchForm.external_sku_id" placeholder="商品编码" style="width: 100px"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="handleChoose(1)">筛选</el-button>
|
<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"
|
<el-upload ref="myUpload" action="/api/combination/goods" :multiple="false" name="combinationGoods"
|
||||||
:show-file-list="false" :on-success="uploadSuccess" :before-upload="beforeUpload"
|
:show-file-list="false" :on-success="uploadSuccess" :before-upload="beforeUpload"
|
||||||
:on-error="uploadError" style="display:inline-block;margin: 0 10px 0 10px;">
|
: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-upload>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
@ -112,7 +111,7 @@ export default {
|
|||||||
tableData: [], // 商品列表
|
tableData: [], // 商品列表
|
||||||
searchForm: {
|
searchForm: {
|
||||||
external_sku_id: "",
|
external_sku_id: "",
|
||||||
goods_title: "", // 商品名称
|
sku_title: "", // 商品名称
|
||||||
},
|
},
|
||||||
Paginationdata: {}, // 分页相关数据
|
Paginationdata: {}, // 分页相关数据
|
||||||
current_page: 1, // 当前页
|
current_page: 1, // 当前页
|
||||||
@ -163,13 +162,6 @@ export default {
|
|||||||
};
|
};
|
||||||
this.getList(this.searchForm);
|
this.getList(this.searchForm);
|
||||||
},
|
},
|
||||||
// 重置筛选
|
|
||||||
handleReChoose() {
|
|
||||||
this.form = {
|
|
||||||
external_sku_id: "",
|
|
||||||
goods_title: "", // 商品名称
|
|
||||||
};
|
|
||||||
},
|
|
||||||
// 分页功能
|
// 分页功能
|
||||||
handleSizeChange(val) {
|
handleSizeChange(val) {
|
||||||
// 当前条数
|
// 当前条数
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user