fix(发货核算): 保持数字单号查询使用文本索引 (#1640)
This commit is contained in:
parent
439ae94021
commit
97d4d2a998
@ -378,7 +378,7 @@ class ShippingFreightService
|
||||
foreach (array_chunk(array_keys($nos), 500) as $chunk) {
|
||||
$variants = [];
|
||||
foreach ($chunk as $l) {
|
||||
$variants[] = $l;
|
||||
$variants[] = (string) $l;
|
||||
$variants[] = '@' . $l;
|
||||
}
|
||||
foreach ($this->db->table('jst_oms_shipping')->whereIn('express_no', $variants)
|
||||
@ -446,7 +446,7 @@ class ShippingFreightService
|
||||
$to = date('Y-m-d H:i:s', strtotime((string) $max) + 15 * 86400);
|
||||
$hit = [];
|
||||
foreach (array_chunk(array_keys($trades), 500) as $chunk) {
|
||||
foreach ($this->db->table('jst_oms_shipping')->whereIn('trade_no', $chunk)
|
||||
foreach ($this->db->table('jst_oms_shipping')->whereIn('trade_no', array_map('strval', $chunk))
|
||||
->where('ship_time', '>=', $from)->where('ship_time', '<', $to)
|
||||
->whereNotNull('express_no')->where('express_no', '<>', '')
|
||||
->distinct()->pluck('trade_no') as $t) {
|
||||
|
||||
@ -275,6 +275,35 @@ class ShippingFreightServiceTest extends FeatureTestCase
|
||||
$this->assertEquals(7.0, $details['ZTX']['qc_freight']);
|
||||
}
|
||||
|
||||
public function test_numeric_waybills_and_trade_numbers_are_queried_as_strings(): void
|
||||
{
|
||||
$this->version('QB-922', '新北中通', '2026-10-01', null, [['省份', '面单', '费率'], ['江苏', 3.0, 1.0]]);
|
||||
$db = DB::connection('business_mirror');
|
||||
$base = ['sku_source_id' => 1, 'express_name1' => '新北中通', 'warehouse_name' => '简尚-崔桥工厂仓',
|
||||
'receiver_state' => '江苏省', 'ship_time' => '2026-11-05 10:00:00', 'pkg_count' => '1/1', 'qty' => 1];
|
||||
$db->table('jst_oms_shipping')->insert([
|
||||
$base + ['source_id' => 41, 'express_no' => '123456789012', 'trade_no' => '9876543210', 'barcode' => 'A', 'online_weight' => 4.0],
|
||||
$base + ['source_id' => 42, 'express_no' => '123456789012', 'trade_no' => '9876543211', 'barcode' => 'B', 'online_weight' => null],
|
||||
$base + ['source_id' => 43, 'express_no' => null, 'trade_no' => '9876543210', 'barcode' => null, 'online_weight' => null],
|
||||
]);
|
||||
$bindings = [];
|
||||
$db->listen(function ($query) use (&$bindings): void {
|
||||
if (str_contains($query->sql, 'where "express_no" in') || str_contains($query->sql, 'where "trade_no" in')) {
|
||||
$bindings[] = $query->bindings;
|
||||
}
|
||||
});
|
||||
app(ShippingFreightService::class)->recalculate('2026-11-01', '2026-12-01');
|
||||
$this->assertNotEmpty($bindings);
|
||||
foreach ($bindings as $values) {
|
||||
foreach ($values as $value) {
|
||||
$this->assertIsString($value);
|
||||
}
|
||||
}
|
||||
$this->assertEquals(7.0, $db->table('jst_oms_shipping_freight')->where('source_id', 41)->value('freight'));
|
||||
$this->assertEquals(0.0, $db->table('jst_oms_shipping_freight')->where('source_id', 42)->value('freight'));
|
||||
$this->assertEquals(0.0, $db->table('jst_oms_shipping_freight')->where('source_id', 43)->value('freight'));
|
||||
}
|
||||
|
||||
public function test_imported_measured_weights_take_priority_when_every_barcode_is_measured(): void
|
||||
{
|
||||
$this->version('QB-911', '新北中通', '2026-10-01', null, [['省份', '面单', '费率'], ['江苏', 3.0, 1.0]]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user