feat: #10000 修改
This commit is contained in:
parent
6ad2379046
commit
cf3f7fad4d
@ -28,11 +28,7 @@ class BusinessOrdersUpdate
|
|||||||
*/
|
*/
|
||||||
public function __construct($item, $num)
|
public function __construct($item, $num)
|
||||||
{
|
{
|
||||||
if (is_array($item)) {
|
$this->businessGoods = $item->toArray();
|
||||||
$this->businessGoods = $item;
|
|
||||||
} else {
|
|
||||||
$this->businessGoods = $item->toArray();
|
|
||||||
}
|
|
||||||
$this->num = $num;
|
$this->num = $num;
|
||||||
$this->updateStock();
|
$this->updateStock();
|
||||||
}
|
}
|
||||||
@ -41,10 +37,6 @@ class BusinessOrdersUpdate
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->goodsSku = GoodsSku::query()
|
$this->goodsSku = GoodsSku::query()
|
||||||
->with([
|
|
||||||
'combinationGoods',
|
|
||||||
'combinationGoods.goodsSkuItem:id,external_sku_id',
|
|
||||||
])
|
|
||||||
->where('external_sku_id', $this->businessGoods['external_sku_id'])
|
->where('external_sku_id', $this->businessGoods['external_sku_id'])
|
||||||
->first();
|
->first();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -54,10 +46,6 @@ class BusinessOrdersUpdate
|
|||||||
if ($this->goodsSku) {
|
if ($this->goodsSku) {
|
||||||
$this->goodsSku->stock += $this->num;
|
$this->goodsSku->stock += $this->num;
|
||||||
$this->goodsSku->save();
|
$this->goodsSku->save();
|
||||||
foreach ($this->goodsSku->combinationGoods as $item) {
|
|
||||||
$this->businessGoods['external_sku_id'] = $item['goodsSkuItem']['external_sku_id'];
|
|
||||||
event(new BusinessOrdersUpdate($this->businessGoods, 0 - $item['item_num']));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -53,7 +53,7 @@ class GoodsSkusController extends Controller
|
|||||||
}])
|
}])
|
||||||
->where('is_combination', 0)
|
->where('is_combination', 0)
|
||||||
->orderByDesc('stock')
|
->orderByDesc('stock')
|
||||||
->paginate(10);
|
->paginate($request->get('per_page'));
|
||||||
$fields = implode(',', [
|
$fields = implode(',', [
|
||||||
'shop_id',
|
'shop_id',
|
||||||
'external_sku_id',
|
'external_sku_id',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user