mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-12-01 14:40:44 +00:00
commit
8ed4a0aa92
@ -40,7 +40,7 @@ class Test extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$shop = Shop::query()->find(1);
|
||||
$shop = Shop::query()->find(2);
|
||||
$business = BusinessFactory::init()->make($shop->plat_id);
|
||||
$business->setShop($shop);
|
||||
// 下载商品列表
|
||||
@ -53,9 +53,9 @@ class Test extends Command
|
||||
// $business->incrQuantity(1);
|
||||
|
||||
// 订单下载
|
||||
// $beginTime = DateTimeUtils::getMicroTime('2022-08-08');
|
||||
// $endTime = DateTimeUtils::getMicroTime('2022-08-09');
|
||||
// $business->downloadOrdersAndSave($beginTime, $endTime);
|
||||
$beginTime = DateTimeUtils::getMicroTime('2022-08-22 18:16:18');
|
||||
$endTime = DateTimeUtils::getMicroTime('2022-08-22 18:16:20');
|
||||
$business->downloadOrdersAndSave($beginTime, $endTime);
|
||||
|
||||
$this->info('执行测试成功');
|
||||
}
|
||||
|
||||
@ -45,10 +45,8 @@ class BusinessOrdersUpdate
|
||||
return false;
|
||||
}
|
||||
if ($this->goodsSku) {
|
||||
$stock = $this->goodsSku->stock + $this->num;
|
||||
if ($stock >= 0) {
|
||||
$this->goodsSku->stock += $this->num;
|
||||
} else {
|
||||
$this->goodsSku->stock += $this->num;
|
||||
if ($this->goodsSku->stock <= 0) {
|
||||
$this->goodsSku->status = 0;
|
||||
}
|
||||
$this->goodsSku->save();
|
||||
|
||||
@ -261,8 +261,9 @@ class GoodsSkusController extends Controller
|
||||
]);
|
||||
$sku->two_days_ago_num = $update['two_days_ago_num'];
|
||||
$sku->yesterday_num = $update['yesterday_num'];
|
||||
$sku->num = $update['two_days_ago_num'] + $update['yesterday_num'] + $update['arrived_today_num'];
|
||||
$sku->stock += ($update['two_days_ago_num'] + $update['yesterday_num'] + $update['arrived_today_num'] - $record->arrived_today_num - $sku->two_days_ago_num - $sku->yesterday_num);
|
||||
$num = $update['two_days_ago_num'] + $update['yesterday_num'] + $update['arrived_today_num'];
|
||||
$sku->num = $num;
|
||||
$sku->stock += ($num - $record->arrived_today_num - $sku->two_days_ago_num - $sku->yesterday_num);
|
||||
$sku->save();
|
||||
$record->arrived_today_num = $update['arrived_today_num'];
|
||||
$record->save();
|
||||
|
||||
@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use App\Models\BusinessGoodsSku;
|
||||
use App\Models\Log;
|
||||
use App\Models\Shop;
|
||||
use App\Services\Business\BusinessFactory;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use App\Events\BusinessOrdersUpdate;
|
||||
@ -60,7 +60,10 @@ class UpdateBusinessGoodsStock implements ShouldQueue
|
||||
$num = $event->goodsSku->stock;
|
||||
$isIncremental = false;
|
||||
}
|
||||
BusinessGoodsSkuIncrQuantity::dispatch($shop, $event->businessOrderItem, $num, $isIncremental);
|
||||
$businessGoodsSkus = BusinessGoodsSku::query()->where('shop_id', $shop->id)->where('external_sku_id', $event->businessOrderItem['external_sku_id'])->get();
|
||||
foreach ($businessGoodsSkus as $businessGoodsSku) {
|
||||
BusinessGoodsSkuIncrQuantity::dispatch($shop, $businessGoodsSku->toArray(), $num, $isIncremental);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ class CreateGoodsSkusTable extends Migration
|
||||
$table->string('sku_code', 32)->comment('规格编码');
|
||||
$table->unsignedTinyInteger('status')->default(0)->comment('规格状态(0-下架,1在售,2预警)');
|
||||
$table->unsignedInteger('num')->default(0)->comment('总量');
|
||||
$table->unsignedInteger('stock')->default(0)->comment('库存');
|
||||
$table->integer('stock')->default(0)->comment('库存');
|
||||
$table->unsignedDecimal('cost')->default(0)->comment('成本');
|
||||
$table->unsignedInteger('two_days_ago_num')->default(0)->comment('2天前库存');
|
||||
$table->unsignedInteger('yesterday_num')->default(0)->comment('1天前库存');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user