diff --git a/app/Console/Commands/DeleteGoodsSku.php b/app/Console/Commands/DeleteGoodsSku.php index 2595273..be910dd 100644 --- a/app/Console/Commands/DeleteGoodsSku.php +++ b/app/Console/Commands/DeleteGoodsSku.php @@ -52,8 +52,8 @@ class DeleteGoodsSku extends Command $goods = Goods::query()->where('goods_code', $goodsCode)->first(); $countSkus = GoodsSku::query()->where('goods_id', $goods->id)->count(); $sku = GoodsSku::query()->where('goods_id', $goods->id)->where('sku_code', $skuCode)->first(); - DailyStockRecord::where('sku_id', $sku->id)->delete(); - Log::where('module', 'goods')->where('target_type', 'goods_sku')->where('target_id', $sku->id)->delete(); + DailyStockRecord::query()->where('sku_id', $sku->id)->delete(); + Log::query()->where('module', 'goods')->where('target_type', 'goods_sku')->where('target_id', $sku->id)->delete(); $sku->delete(); if (1 === $countSkus) { $goods->delete(); diff --git a/app/Console/Commands/DeleteKttQuery.php b/app/Console/Commands/DeleteKttQuery.php index 9353336..2746f8f 100644 --- a/app/Console/Commands/DeleteKttQuery.php +++ b/app/Console/Commands/DeleteKttQuery.php @@ -38,27 +38,27 @@ class DeleteKttQuery extends Command */ public function handle() { - $count = Log::where('target_field', 'pdd.ktt.goods.query.list') + $count = Log::query()->where('target_field', 'pdd.ktt.goods.query.list') ->where('created_at', '<', date('Y-m-d H:i:s', strtotime('-1 day'))) ->delete(); $this->info('删除商品列表查询: ' . $count); - $count = Log::where('target_field', 'pdd.ktt.order.list') + $count = Log::query()->where('target_field', 'pdd.ktt.order.list') ->where('created_at', '<', date('Y-m-d H:i:s', strtotime('-2 day'))) ->delete(); $this->info('删除根据成交时间拉取订单列表: ' . $count); - $count = Log::where('target_field', 'pdd.ktt.increment.order.query') + $count = Log::query()->where('target_field', 'pdd.ktt.increment.order.query') ->where('created_at', '<', date('Y-m-d H:i:s', strtotime('-2 day'))) ->delete(); $this->info('删除增量查订单: ' . $count); - $count = Log::where('target_field', 'pdd.ktt.goods.incr.quantity') + $count = Log::query()->where('target_field', 'pdd.ktt.goods.incr.quantity') ->where('created_at', '<', date('Y-m-d H:i:s', strtotime('-2 day'))) ->delete(); $this->info('删除快团团更新库存: ' . $count); - $count = Log::where('target_field', '更新库存') + $count = Log::query()->where('target_field', '更新库存') ->where('created_at', '<', date('Y-m-d H:i:s', strtotime('-2 day'))) ->delete(); $this->info('删除妙选更新库存: ' . $count); diff --git a/app/Console/Commands/Inventory.php b/app/Console/Commands/Inventory.php index 1ef6060..265f63c 100644 --- a/app/Console/Commands/Inventory.php +++ b/app/Console/Commands/Inventory.php @@ -59,7 +59,7 @@ class Inventory extends Command 'sku_id' => $sku->id, 'day' => $date, ]; - GoodsSku::where('id', $sku->id)->update([ + GoodsSku::query()->where('id', $sku->id)->update([ 'yesterday_num' => $sku->stock, 'two_days_ago_num' => $sku->two_days_ago_num + $sku->yesterday_num, ]); diff --git a/app/Console/Commands/Test.php b/app/Console/Commands/Test.php index f10167b..6de1491 100644 --- a/app/Console/Commands/Test.php +++ b/app/Console/Commands/Test.php @@ -44,7 +44,7 @@ class Test extends Command public function handle() { // 下架商品 -// GoodsSku::where('status', '<>', 0)->update(['status' => 0]); +// GoodsSku::query()->where('status', '<>', 0)->update(['status' => 0]); // $this->info('全部下架'); // exit(); // 1-7 11 diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index dc42522..b4ac58d 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -69,7 +69,7 @@ class RegisterController extends Controller { $faker = new Faker(); - return User::create([ + return User::query()->create([ 'name' => $data['name'], 'email' => $data['email'] ?? $faker->unique()->safeEmail, 'password' => Hash::make($data['password']), diff --git a/app/Http/Controllers/Business/BusinessGoodsSkusController.php b/app/Http/Controllers/Business/BusinessGoodsSkusController.php index fd76e9f..70e1314 100644 --- a/app/Http/Controllers/Business/BusinessGoodsSkusController.php +++ b/app/Http/Controllers/Business/BusinessGoodsSkusController.php @@ -45,7 +45,7 @@ class BusinessGoodsSkusController extends Controller return response($this->res, $this->res['httpCode']); } - $sku = BusinessGoodsSku::find($id); + $sku = BusinessGoodsSku::query()->find($id); $this->setBeforeUpdate($sku->is_sync); $sku->is_sync = $request->input('is_sync'); $sku->save(); @@ -59,9 +59,9 @@ class BusinessGoodsSkusController extends Controller { DB::beginTransaction(); try { - $sku = BusinessGoodsSku::find($id); + $sku = BusinessGoodsSku::query()->find($id); $this->setBeforeUpdate($sku->toArray()); - BusinessOrderItem::where('goods_id', $sku->goods_id)->where('sku_id', $sku->sku_id)->delete(); + BusinessOrderItem::query()->where('goods_id', $sku->goods_id)->where('sku_id', $sku->sku_id)->delete(); $sku->delete(); $this->setAfterUpdate(''); $this->addLog($id, ''); @@ -77,7 +77,7 @@ class BusinessGoodsSkusController extends Controller public function syncStock($id, Request $request) { - $businessGoodsSku = BusinessGoodsSku::find($id); + $businessGoodsSku = BusinessGoodsSku::query()->find($id); [$goodsCode, $skuCode] = explode('_', $businessGoodsSku->external_sku_id); $sku = GoodsSku::query()->where('sku_code', $skuCode) ->whereHas('goods', function ($query) use ($goodsCode) { diff --git a/app/Imports/InventoryImport.php b/app/Imports/InventoryImport.php index ea4fa0f..9ffa4a6 100644 --- a/app/Imports/InventoryImport.php +++ b/app/Imports/InventoryImport.php @@ -53,7 +53,7 @@ class InventoryImport implements ToCollection, SkipsEmptyRows $goodsSku->stock = $row[6] + $row[7]; $goodsSku->save(); $updateIds[] = $goodsSku->id; - DailyStockRecord::where('sku_id', $goodsSku->id)->where('day', $day)->update([ + DailyStockRecord::query()->where('sku_id', $goodsSku->id)->where('day', $day)->update([ 'arrived_today_num' => $row[7], 'inventory' => $row[6], 'inventory_time' => $dateTime diff --git a/app/Listeners/StockWarning.php b/app/Listeners/StockWarning.php index c7a6361..b688d40 100644 --- a/app/Listeners/StockWarning.php +++ b/app/Listeners/StockWarning.php @@ -41,10 +41,10 @@ class StockWarning implements ShouldQueue } } if ($warningIds) { - GoodsSku::whereIn('id', $warningIds)->update(['status' => 2]); + GoodsSku::query()->whereIn('id', $warningIds)->update(['status' => 2]); } if ($normalIds) { - GoodsSku::whereIn('id', $normalIds)->update(['status' => 1]); + GoodsSku::query()->whereIn('id', $normalIds)->update(['status' => 1]); } } } diff --git a/app/Models/BusinessGoodsSku.php b/app/Models/BusinessGoodsSku.php index d584cf9..ba93acc 100644 --- a/app/Models/BusinessGoodsSku.php +++ b/app/Models/BusinessGoodsSku.php @@ -15,21 +15,6 @@ class BusinessGoodsSku extends Model 'shop_id', ]; - /** - * @var mixed - */ - public $goods_id; - - /** - * @var mixed - */ - public $sku_id; - - /** - * @var mixed - */ - public $external_sku_id; - protected $hidden = [ 'self_sku_id', 'activity_no', diff --git a/app/Models/BusinessOrderItem.php b/app/Models/BusinessOrderItem.php index 3bf86fd..a656040 100644 --- a/app/Models/BusinessOrderItem.php +++ b/app/Models/BusinessOrderItem.php @@ -4,14 +4,6 @@ namespace App\Models; class BusinessOrderItem extends Model { - /** - * @var mixed - */ - public $shop_id; - /** - * @var mixed - */ - public $external_sku_id; /** * 不可批量赋值的属性。为空则所有熟悉都可以批量赋值 * diff --git a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php index 6ec762c..e7ebc08 100644 --- a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php +++ b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php @@ -122,7 +122,7 @@ class KuaiTuanTuan extends BusinessClient if (isset($res['error_response'])) { // ToDo 重构异常处理 if ('业务服务错误' === $res['error_response']['error_msg'] && '该店铺下不存在该商品' === $res['error_response']['sub_msg']) { - BusinessGoodsSku::where('goods_id', $appendParams['goods_id'])->where('sku_id', $appendParams['sku_id'])->delete(); + 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']); }