鲜花2.0-采购流程变更
This commit is contained in:
parent
a43d8b0c81
commit
7fb90a77f9
@ -59,8 +59,9 @@ class CheckSkuQualityPeriod extends Command
|
||||
$updateIds = [];
|
||||
foreach ($purchaseRecords as $v) {
|
||||
// 单独采购单后续总和小于库存表示该sku没有卖完
|
||||
$totalPurchaseNum = PurchaseRecords::query()->where('id', '>=', $v->id)
|
||||
->where('external_sku_id',"=",$v->external_sku_id)->sum('num');
|
||||
$totalPurchaseNum = PurchaseRecords::query()->where('date', '>=', $v->date)
|
||||
->where('external_sku_id', "=", $v->external_sku_id)
|
||||
->where("status", 1)->sum('num');
|
||||
if ($totalPurchaseNum < $v->stock) {
|
||||
$messageService->skuQualityPeriodNoticeMessage((array)$v);
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@ class DailyStockRecordReport extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'daily:report:stock_record';
|
||||
protected $signature = 'daily:report:stock_record {date?}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
@ -46,7 +46,10 @@ class DailyStockRecordReport extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$date = $this->argument('date');
|
||||
if (is_null($date)) {
|
||||
$date = Carbon::yesterday()->format('Y-m-d');
|
||||
}
|
||||
$startDateTime = Carbon::parse($date)->startOfDay()->toDateTimeString();
|
||||
$endDateTime = Carbon::parse($date)->endOfDay()->toDateTimeString();
|
||||
//统计订单数量
|
||||
@ -63,12 +66,13 @@ class DailyStockRecordReport extends Command
|
||||
//统计采购单数量
|
||||
$purchaseRecords = PurchaseRecords::query()
|
||||
->select(DB::raw("sum(num) as arrived_today_num"), "external_sku_id")
|
||||
->whereBetween("created_at", [$startDateTime, $endDateTime])
|
||||
->whereBetween("date", [$startDateTime, $endDateTime])
|
||||
->where("status",1)
|
||||
->groupBy("external_sku_id")->get()->pluck(null, "external_sku_id")->toArray();
|
||||
//统计报损数量
|
||||
$lossRecords = LossRecords::query()
|
||||
->select(DB::raw("sum(num) as loss_num"), "external_sku_id")
|
||||
->whereBetween("created_at", [$startDateTime, $endDateTime])
|
||||
->whereBetween("date", [$startDateTime, $endDateTime])
|
||||
->groupBy("external_sku_id")->get()->pluck(null, "external_sku_id")->toArray();
|
||||
Log::info("{$date}每日库存记录", ["orderItems" => $orderItems
|
||||
, "purchaseRecords" => $purchaseRecords, "lossRecords" => $lossRecords]);
|
||||
|
||||
@ -135,7 +135,6 @@ class LossRecordController extends Controller
|
||||
|
||||
public function lossBatchStore(Request $request)
|
||||
{
|
||||
\Illuminate\Support\Facades\Log::info("test", (array)$request->all());
|
||||
$validator = Validator::make($request->all(), [
|
||||
'lossOrders' => 'required|array',
|
||||
'lossOrders.*.external_sku_id' => 'required|string',
|
||||
|
||||
@ -145,6 +145,9 @@ class PurchaseRecordController extends Controller
|
||||
if (!empty($allParams['expire_time'])) {
|
||||
$purchaseRecords->expire_time = Carbon::parse($allParams['expire_time'])->toDateTimeString();
|
||||
}
|
||||
if (!empty($allParams['date'])) {
|
||||
$purchaseRecords->date = Carbon::parse($allParams['date'])->toDateString();
|
||||
}
|
||||
if (!empty($allParams['arrived_time'])) {
|
||||
$purchaseRecords->arrived_time = Carbon::parse($allParams['arrived_time'])->toDateTimeString();
|
||||
}
|
||||
@ -264,16 +267,30 @@ class PurchaseRecordController extends Controller
|
||||
'purchaseOrders.*.status' => 'required|in:1,2']);
|
||||
$allUpdateIds = [];
|
||||
foreach ($params['purchaseOrders'] as $v) {
|
||||
$purchaseRecords = PurchaseRecords::query()->with("goodsSku")->where("id", $v['id'])->first();
|
||||
if (empty($purchaseRecords)) {
|
||||
$purchaseRecordBuilder = PurchaseRecords::query()->with("goodsSku")->where("id", $v['id'])->first();
|
||||
if (empty($purchaseRecordBuilder)) {
|
||||
continue;
|
||||
}
|
||||
$purchaseRecords->status = $v['status'];
|
||||
$purchaseRecords->save();
|
||||
$purchaseRecords = $purchaseRecordBuilder->toArray();
|
||||
if (empty($purchaseRecords['goods_sku'])) {
|
||||
continue;
|
||||
}
|
||||
if ($purchaseRecords['status'] == $v['status']) {
|
||||
throw new \Exception("id:{$v["id"]}状态未变更,请勿重复操作");
|
||||
}
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
if (PurchaseStatusEnum::CHECK_SUCCESS == $v['status']) {
|
||||
$updateIds = GoodSkuService::computeSkuStock($v['goodsSku'], $v, TargetTypeEnum::PURCHASE);
|
||||
$updateIds = GoodSkuService::computeSkuStock($purchaseRecords['goods_sku'], $purchaseRecords, TargetTypeEnum::PURCHASE);
|
||||
$allUpdateIds = array_merge($allUpdateIds, $updateIds);
|
||||
}
|
||||
$purchaseRecordBuilder->status = $v['status'];
|
||||
$purchaseRecordBuilder->save();
|
||||
DB::commit();
|
||||
} catch (\Exception $exception) {
|
||||
DB::rollBack();
|
||||
\Illuminate\Support\Facades\Log::error("质检审核事务异常", ["error" => $exception->getMessage()]);
|
||||
}
|
||||
}
|
||||
if (!empty($allUpdateIds)) {
|
||||
event(new BatchStockUpdateEvent(collect($allUpdateIds)->unique()->toArray()));
|
||||
|
||||
@ -74,6 +74,11 @@ class PurchaseImport implements ToArray, SkipsEmptyRows
|
||||
if (!empty($row[6])) {
|
||||
$purchaseRecords->date = DateTimeUtils::excelUploadDateToString($row[6], $today);
|
||||
}
|
||||
if (!empty($row[7])) {
|
||||
$purchaseRecords->arrived_time = DateTimeUtils::excelUploadDateToString($row[7], $today,"Y-m-d H:i:s");
|
||||
}else{
|
||||
$purchaseRecords->arrived_time = $today;
|
||||
}
|
||||
$purchaseRecords->buyer_user_id = $buyerUserIdKeyByNameMap[$row[4]] ?? 0;
|
||||
$purchaseRecords->buyer_name = $row[4] ?? '';
|
||||
$purchaseRecords->supplier_name = $row[5] ?? '';
|
||||
|
||||
@ -14,6 +14,7 @@ class PurchaseRecords extends Model
|
||||
protected $guarded = [];
|
||||
public $fieldSearchable = [
|
||||
'external_sku_id',
|
||||
'status'
|
||||
];
|
||||
|
||||
public function goodsSku()
|
||||
|
||||
@ -33,6 +33,10 @@ class MiaoXuan extends BusinessClient
|
||||
{
|
||||
}
|
||||
|
||||
public function downloadAfterSaleOrdersAndSave($beginTime, $endTime, $page = 1){
|
||||
|
||||
}
|
||||
|
||||
public function batchIncrQuantity($businessGoodsSkus, $num, $incremental)
|
||||
{
|
||||
$batchAppendParams = [];
|
||||
|
||||
@ -52,12 +52,17 @@ class DateTimeUtils
|
||||
return $d && $d->format($format) === $date;
|
||||
}
|
||||
|
||||
public static function excelUploadDateToString($excelData, $defaultTime)
|
||||
public static function excelUploadDateToString($excelData, $defaultTime, $format = "Y-m-d")
|
||||
{
|
||||
|
||||
try {
|
||||
return date("Y-m-d", ($excelData - 25569) * 24 * 3600);
|
||||
$time = ($excelData - 25569) * 24 * 3600;
|
||||
if ($format == "Y-m-d H:i:s") {
|
||||
$time = $time - 8 * 3600;
|
||||
}
|
||||
return date($format, $time);
|
||||
} catch (\Exception $exception) {
|
||||
Log::error("时间转化出错", $exception->getMessage());
|
||||
Log::error("时间转化出错", [$exception->getMessage()]);
|
||||
}
|
||||
return $defaultTime;
|
||||
|
||||
|
||||
@ -532,54 +532,54 @@ return [
|
||||
],
|
||||
'PURCHASE_RECORD' => [
|
||||
'id' => 192,
|
||||
'name' => '入库采购',
|
||||
'name' => '商品采购',
|
||||
'parent_id' => 19,
|
||||
'show' => 1,
|
||||
],
|
||||
'purchase_record.index' => [
|
||||
'id' => 1921,
|
||||
'name' => '入库采购首页',
|
||||
'name' => '商品采购首页',
|
||||
'parent_id' => 192
|
||||
],
|
||||
'purchase_record.update' => [
|
||||
'id' => 1922,
|
||||
'name' => '入库采购更新',
|
||||
'name' => '商品采购更新',
|
||||
'parent_id' => 192
|
||||
],
|
||||
'purchase_record.store' => [
|
||||
'id' => 1923,
|
||||
'name' => '入库采购新增',
|
||||
'name' => '商品采购新增',
|
||||
'parent_id' => 192
|
||||
],
|
||||
'purchase_record.purchase_import' => [
|
||||
'id' => 1924,
|
||||
'name' => '入库采购批量导入',
|
||||
'name' => '商品采购批量导入',
|
||||
'parent_id' => 192
|
||||
],
|
||||
'purchase_record.purchase_batch_store' => [
|
||||
'id' => 1925,
|
||||
'name' => '入库采购批量导入',
|
||||
'name' => '商品采购批量导入',
|
||||
'parent_id' => 192
|
||||
],
|
||||
'LOSS_RECORD' => [
|
||||
'id' => 193,
|
||||
'name' => '报损记录',
|
||||
'name' => '仓库报损',
|
||||
'parent_id' => 19,
|
||||
'show' => 1,
|
||||
],
|
||||
'loss_record.index' => [
|
||||
'id' => 1931,
|
||||
'name' => '报损记录首页',
|
||||
'name' => '仓库报损首页',
|
||||
'parent_id' => 193
|
||||
],
|
||||
'loss_record.update' => [
|
||||
'id' => 1932,
|
||||
'name' => '报损记录更新',
|
||||
'name' => '仓库报损更新',
|
||||
'parent_id' => 193
|
||||
],
|
||||
'loss_record.store' => [
|
||||
'id' => 1933,
|
||||
'name' => '报损记录新增',
|
||||
'name' => '仓库报损新增',
|
||||
'parent_id' => 193
|
||||
],
|
||||
'loss_record.loss_import' => [
|
||||
@ -594,30 +594,41 @@ return [
|
||||
],
|
||||
'DAILY_STOCK_RECORD' => [
|
||||
'id' => 194,
|
||||
'name' => '盘点记录',
|
||||
'name' => '库存盘点',
|
||||
'parent_id' => 19,
|
||||
'show' => 1,
|
||||
],
|
||||
'daily_stock_record.index' => [
|
||||
'id' => 1941,
|
||||
'name' => '盘点记录首页',
|
||||
'name' => '库存盘点首页',
|
||||
'parent_id' => 194
|
||||
],
|
||||
'daily_stock_record.store' => [
|
||||
'id' => 1942,
|
||||
'name' => '盘点记录新增',
|
||||
'name' => '库存盘点新增',
|
||||
'parent_id' => 194
|
||||
],
|
||||
'daily_stock_record.inventory_import' => [
|
||||
'id' => 1943,
|
||||
'name' => '盘点记录批量导入',
|
||||
'name' => '库存盘点批量导入',
|
||||
'parent_id' => 194
|
||||
],
|
||||
'daily_stock_record.inventory_batch_store' => [
|
||||
'id' => 1944,
|
||||
'name' => '盘点记录批量导入',
|
||||
'name' => '库存盘点批量导入',
|
||||
'parent_id' => 194
|
||||
],
|
||||
'PURCHASE_RECORD_CHECK' => [
|
||||
'id' => 195,
|
||||
'name' => '质检入库',
|
||||
'parent_id' => 19,
|
||||
'show' => 1,
|
||||
],
|
||||
'purchase_record.purchase_batch_check' => [
|
||||
'id' => 1951,
|
||||
'name' => '质检审核',
|
||||
'parent_id' => 195,
|
||||
],
|
||||
'sale_statistics' => [
|
||||
'id' => 181,
|
||||
'name' => 'sku销售统计',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user