- 聚水潭奇门客户端与发货同步器骨架:QimenClient(签名+POST)、ShippingDataSynchronizer(erp.sctrade.query 列表 + erp.sradesku.query 明细 + upsert + modified 水位) - 发货明细扁平展示表 jst_oms_shipping(对齐工作平台发货数据 47 列/顺序,用于快递运费核算);原始表 jst_sctrade/_items/_skus/_receiver + jst_sync_state - 快递应付新增「发货数据」页:Pages.contentForShippingData + 视图 + business_navigation 导航项(slug=shipping-data) - ShippingOrderRepository 读展示表;artisan jushuitan:sync-shipping + 每10分钟增量调度(JST_SYNC_ENABLED 默认关) - 落库连接 jushuitan_local(本地容器,env 可覆盖);演示 Seeder(6 条家具发货样例);.env.jushuitan.example Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014nvGZkg27YMEdhRy6EiUwf
69 lines
5.2 KiB
PHP
69 lines
5.2 KiB
PHP
<?php
|
||
|
||
namespace Database\Seeds;
|
||
|
||
use Illuminate\Database\Seeder;
|
||
use Illuminate\Support\Facades\DB;
|
||
|
||
/**
|
||
* 发货明细演示数据(仅本地看界面用)。写入 jst_oms_shipping(47 列)。
|
||
* php artisan db:seed --class="Database\Seeds\JushuitanShippingDemoSeeder"
|
||
* 联调真实接口后清空即可(source_id 以 9000000 起)。
|
||
*/
|
||
class JushuitanShippingDemoSeeder extends Seeder
|
||
{
|
||
public function run(): void
|
||
{
|
||
$db = DB::connection((string) config('jushuitan.connection', 'jushuitan_local'));
|
||
$now = now();
|
||
|
||
$samples = [
|
||
// 快递单号, 交易单号, 商品ID, 条码, 商品名称, 数量, 省, 市, 区, 收货人, 手机, 店铺, 快递, 仓库, 供应商, 平台, 货号, 运费, 线上重, 实称重, 长,宽,高, 结算运费
|
||
['JDV028245430835','3545486005885966','10035038189982','GNSF000504','折叠床 单人 1.2m 奶白色',2,'北京','北京','朝阳区','张三','138****0001','京喜自营工厂店','京喜京东快运','浙江华韵代发仓','华韵','京东商城','ZDC-001',12.00,18.5,19.0,80,78,68,15.20],
|
||
['YT7788990011223','3310398519776020','10062860613','GNSF000208','藤椅躺椅 加大款 棕色',1,'浙江省','杭州市','余杭区','李四','139****0002','优选家居旗舰店','圆通速递','南昌樵舍仓','简尚集采','天猫','TYY-001',6.50,8.0,8.2,60,55,40,7.80],
|
||
['SF1234567890123','3310398951698084','10061046499','GNSF000112','康米特椅 户外折叠 军绿',1,'广东省','深圳市','南山区','王五','137****0003','京选家具专营','顺丰速运','常州总仓','固图家居','京东','TYK-002',9.20,3.2,3.4,55,42,12,9.20],
|
||
['ZTO5566778899001','3310851253260175','10061042791','GNSF000377','儿童学习椅 可升降 粉',1,'四川省','成都市','武侯区','赵六','135****0004','儿童学习专营店','中通快递','南昌樵舍仓','绒灿家居','拼多多','EXX-006',6.40,6.4,6.6,52,40,45,6.40],
|
||
['YD9900112233445','3311032908970014','10061082943','GNSF000501','折叠床 双人 1.5m 胡桃',1,'山东省','青岛市','市南区','孙七','136****0005','家具工厂直营店','韵达快递','常州总仓','华韵','淘宝','ZDC-002',15.80,15.8,16.1,90,70,20,16.50],
|
||
['JD0088123456789','3545486009911223','10035038777','GNSF000733','鳄鱼椅 网布透气 黑',2,'江苏省','常州市','武进区','周八','133****0006','亿家木旗舰店','京东快递','浙江华韵代发仓','简尚集采','京东商城','EYY-009',10.00,9.0,9.3,58,46,48,10.00],
|
||
];
|
||
|
||
$i = 0;
|
||
foreach ($samples as $r) {
|
||
[$expno,$tradeno,$itemid,$barcode,$pname,$qty,$prov,$city,$dist,$rname,$mobile,$shop,$express,$wh,$supplier,$platform,$procode,$freight,$onlineW,$actualW,$L,$W,$H,$settleFreight] = $r;
|
||
$shipTime = $now->copy()->subHours(++$i);
|
||
$vol = $L * $W * $H;
|
||
$sid = 9000000 + $i;
|
||
|
||
$db->table('jst_oms_shipping')->updateOrInsert(
|
||
['source_id' => $sid, 'sku_source_id' => $sid],
|
||
[
|
||
'express_no' => $expno, 'trade_no' => $tradeno, 'item_id' => $itemid, 'barcode' => $barcode,
|
||
'product_name' => $pname, 'qty' => $qty, 'receiver_state' => $prov, 'buyer_nick' => '',
|
||
'receiver_name' => $rname, 'shop_name' => $shop, 'express_name1' => $express, 'warehouse_name' => $wh,
|
||
'ship_time' => $shipTime, 'freight' => $freight, 'online_weight' => $onlineW, 'actual_weight' => $actualW,
|
||
'length_cm' => $L, 'width_cm' => $W, 'height_cm' => $H, 'volume_cm3' => $vol,
|
||
'receiver_city' => $city, 'receiver_district' => $dist, 'supplier_name' => $supplier,
|
||
'receiver_address' => $prov.$city.$dist.'示例路'.($i*7).'号', 'receiver_mobile' => $mobile, 'receiver_phone' => '',
|
||
'express_name2' => $express, 'platform' => $platform, 'buyer_memo' => '', 'seller_memo' => '',
|
||
'package_no' => 'PH'.$shipTime->format('Ymd').str_pad((string)$i,4,'0',STR_PAD_LEFT),
|
||
'amount' => round($actualW * 9.9 + 39, 2), 'product_code' => $procode,
|
||
'download_time' => $shipTime->copy()->addMinutes(30), 'pay_time' => $shipTime->copy()->subHours(3),
|
||
'freight_rate' => 1.0, 'freight_formula' => '首重+续重',
|
||
'weight_kg' => $actualW, 'settle_weight_kg' => max($actualW, round($vol/6000, 4)),
|
||
'settle_volume_cm3' => $vol, 'recon_weight_kg' => $actualW, 'recon_volume_cm3' => $vol,
|
||
'finished_barcode' => '', 'finished_name' => $pname, 'finished_supplier' => $supplier,
|
||
'settle_freight' => $settleFreight, 'front_no' => '',
|
||
'modified' => $shipTime, 'synced_at' => $now,
|
||
]
|
||
);
|
||
}
|
||
|
||
$db->table('jst_sync_state')->updateOrInsert(['dataset_key' => 'jst.sctrade'], [
|
||
'watermark' => $now, 'status' => 'succeeded', 'last_succeeded_at' => $now,
|
||
'updated_at' => $now, 'created_at' => $now,
|
||
]);
|
||
|
||
$this->command?->info('已写入 ' . count($samples) . ' 条发货明细演示数据(47 列,source_id 9000001 起)。');
|
||
}
|
||
}
|