鲜花2.0-接口测试bug修复

This commit is contained in:
杨建炊 2024-08-07 16:23:04 +08:00
parent cca19547d2
commit 489a0050c4
5 changed files with 15 additions and 9 deletions

View File

@ -53,21 +53,25 @@ class CheckSkuQualityPeriod extends Command
->leftJoin('goods_skus as b', 'a.sku_id', '=', 'b.id')
->where("a.status", "=", 0)
->whereBetween('a.expire_time', [$startTime, $endTime])->get();
Log::info('purchaseRecords',(array)$purchaseRecords);
if ($purchaseRecords->isNotEmpty()) {
$messageService = new MessageService();
$updateIds = [];
foreach ($purchaseRecords as $v) {
// 单独采购单后续总和小于库存表示该sku没有卖完
$totalPurchaseNum = PurchaseRecords::query()->where('id', '>=', $v->id)
->where('sku_id',"=",$v->sku_id)->sum('num');
if ($totalPurchaseNum < $v->stock) {
Log::info("触发通知{$totalPurchaseNum}:",(array)$v);
$messageService->skuQualityPeriodNoticeMessage((array)$v);
}
$updateIds[] = $v->id;
//更新下状态
PurchaseRecords::query()->where('id', '=', $v->id)->update([
"status" => 1
]);
}
PurchaseRecords::query()->whereIn('id', $updateIds)->update([
"status" => 1
]);
}
Log::info('任务完成:check-CheckSkuQualityPeriod');

View File

@ -90,8 +90,7 @@ class MessageService
$arr['role_id'] = $v;
$arr['unique_key'] = $date . "-" . $goodsSku['id'] . "-" . $v;//这个场景下实际是采购单的id
$arr['type'] = MessageTypeEnum::QUALITY_PERIOD_EXPIRE_NOTICE;
$arr['content'] = $date . "规格{$goodsSku['title']}编码{$goodsSku['external_sku_id']},即将过期,目前实际库存{$goodsSku['stock']}
,当时采购数量为{$goodsSku['num']},录入采购时间为{$goodsSku['created_at']}";
$arr['content'] = $date . "规格{$goodsSku['title']}编码{$goodsSku['external_sku_id']},即将过期,目前实际库存{$goodsSku['stock']},当时采购数量为{$goodsSku['num']},录入采购时间为{$goodsSku['created_at']}";
$this->saveWebsiteMessages($arr);
}

View File

@ -10,6 +10,7 @@ use App\Models\TodayPrice;
use App\Services\GoodSku\GoodSkuService;
use App\Utils\DateTimeUtils;
use Exception;
use Illuminate\Support\Facades\Log;
use Maatwebsite\Excel\Concerns\SkipsEmptyRows;
use Maatwebsite\Excel\Concerns\ToArray;
use App\Utils\ArrayUtils;
@ -42,7 +43,7 @@ class InventoryImport implements ToArray, SkipsEmptyRows
return $v;
}
})->toArray();
Log::info("goodsSkus",$goodsSkus);
$goodSkuService = new GoodSkuService();
$goodSkuService->inventory($goodsSkus);
}

View File

@ -37,7 +37,7 @@ class PurchaseImport implements ToArray, SkipsEmptyRows
$updateIds = [];
$hasGoodsSkus = GoodsSku::query()
->whereIn('external_sku_id', $externalSkuIds)
->get(['id', 'status', 'external_sku_id', 'stock'])
->get(['id', 'status', 'external_sku_id', 'stock', "sale_stock", "cost"])
->toArray();
$hasGoodsSkus = ArrayUtils::index($hasGoodsSkus, 'external_sku_id');
$expireDay = DeveloperConfigService::getDefaultExpireDay();
@ -56,7 +56,8 @@ class PurchaseImport implements ToArray, SkipsEmptyRows
$purchaseRecords->cost = $row[3];
$purchaseRecords->buyer_name = $row[4] ?? '';
$purchaseRecords->supplier_name = $row[5] ?? '';
$purchaseRecords->expire_time = $row[6] ?? Carbon::now()->addDays($expireDay)->toDateTimeString();
$purchaseRecords->expire_time = !empty($row[6]) ? Carbon::parse($row[6])->toDateTimeString()
: Carbon::now()->addDays($expireDay)->toDateTimeString();
$purchaseRecords->save();
$updateIds = GoodSkuService::computeSkuStock($goodsSkuItem, ["num" => $row[2], 'cost' => $row[3]]);

View File

@ -89,6 +89,7 @@ class GoodSkuService
if (!empty($unshippedData[$v['external_sku_id']])) {
$v['inventory'] = $v['inventory'] - $unshippedData[$v['external_sku_id']]['goods_total']
+ $unshippedData[$v['external_sku_id']]['cancel_total'];
}
return $v;
})->toArray();