chore: 优化上传分类规则并新增分享功能
- 新增上传分类归一化处理,统一白名单校验规则 - 新增COS存储记录同步逻辑 - 新增分享功能支持,配置多页面分享参数 - 新增订单案例分享按钮 - 新增订单自动校验和回收命令 - 新增测试脚本和图片同步脚本 - 优化后台上传分类配置,统一分类映射
这个提交包含在:
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
define('APP_PATH', __DIR__ . '/../server/application/');
|
||||
require __DIR__ . '/../server/thinkphp/base.php';
|
||||
\think\App::initCommon();
|
||||
|
||||
use think\Db;
|
||||
|
||||
$orders = Db::name('order')->where('status', 'in', [5, 6, 7])->select();
|
||||
foreach ($orders as $o) {
|
||||
echo "ID: {$o['id']}, No: {$o['order_no']}, Status: {$o['status']}, Name: {$o['service_name']}, Pay: {$o['pay_amount']}\n";
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
[]
|
||||
133
scripts/prepare_goods_images.php
普通文件
133
scripts/prepare_goods_images.php
普通文件
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
define('APP_PATH', __DIR__ . '/../server/application/');
|
||||
require __DIR__ . '/../server/thinkphp/base.php';
|
||||
\think\App::initCommon();
|
||||
|
||||
use think\Loader;
|
||||
|
||||
Loader::addNamespace('Qcloud\Cos', __DIR__ . '/../server/addons/cos/library/Qcloud/Cos/');
|
||||
Loader::addNamespace('GuzzleHttp\Command', __DIR__ . '/../server/addons/cos/library/Guzzle/command/src/');
|
||||
Loader::addNamespace('GuzzleHttp\Command\Guzzle', __DIR__ . '/../server/addons/cos/library/Guzzle/guzzle-services/src/');
|
||||
Loader::addNamespace('GuzzleHttp\UriTemplate', __DIR__ . '/../server/addons/cos/library/Guzzle/uri-template/src/');
|
||||
|
||||
$cosClient = new \Qcloud\Cos\Client([
|
||||
'region' => 'ap-guangzhou',
|
||||
'schema' => 'https',
|
||||
'credentials' => [
|
||||
'secretId' => 'AKIDxOo34sUu892lWFoEnFVYS9A58D84pa8X',
|
||||
'secretKey' => 'IMDwjS5Xpwtc9WiV7dz95rTvHUbYJtSv'
|
||||
]
|
||||
]);
|
||||
|
||||
$localDir = __DIR__ . '/../server/public/uploads/goods';
|
||||
$appStaticDir = __DIR__ . '/../yjyf-app/static/goods';
|
||||
|
||||
if (!is_dir($localDir)) {
|
||||
mkdir($localDir, 0777, true);
|
||||
}
|
||||
if (!is_dir($appStaticDir)) {
|
||||
mkdir($appStaticDir, 0777, true);
|
||||
}
|
||||
|
||||
$images = [
|
||||
'sofa_leather' => 'https://images.unsplash.com/photo-1555041469-a586c61ea9bc?w=600&auto=format&fit=crop&q=80',
|
||||
'wardrobe_sliding' => 'https://images.unsplash.com/photo-1595428774223-ef52624120d2?w=600&auto=format&fit=crop&q=80',
|
||||
'bed_luxury' => 'https://images.unsplash.com/photo-1505693416388-ac5ce068fe85?w=600&auto=format&fit=crop&q=80',
|
||||
'dining_table' => 'https://images.unsplash.com/photo-1617806118233-18e1de247200?w=600&auto=format&fit=crop&q=80',
|
||||
'toilet_smart' => 'https://images.unsplash.com/photo-1584622650111-993a426fbf0a?w=600&auto=format&fit=crop&q=80',
|
||||
'shower_thermo' => 'https://images.unsplash.com/photo-1620626011761-996317b8d101?w=600&auto=format&fit=crop&q=80',
|
||||
'bathroom_cabinet' => 'https://images.unsplash.com/photo-1552321554-5fefe8c9ef14?w=600&auto=format&fit=crop&q=80',
|
||||
'ceiling_lamp' => 'https://images.unsplash.com/photo-1513506003901-1e6a229e2d15?w=600&auto=format&fit=crop&q=80',
|
||||
'chandelier' => 'https://images.unsplash.com/photo-1540932239986-30128078f3c5?w=600&auto=format&fit=crop&q=80',
|
||||
'smart_lock' => 'https://images.unsplash.com/photo-1558002038-1055907df827?w=600&auto=format&fit=crop&q=80',
|
||||
'mechanical_lock' => 'https://images.unsplash.com/photo-1517487881594-2787fef5ebf7?w=600&auto=format&fit=crop&q=80',
|
||||
'curtain_fabric' => 'https://images.unsplash.com/photo-1513694203232-719a280e022f?w=600&auto=format&fit=crop&q=80',
|
||||
'curtain_motor' => 'https://images.unsplash.com/photo-1505691938895-1758d7feb511?w=600&auto=format&fit=crop&q=80',
|
||||
'wall_decor' => 'https://images.unsplash.com/photo-1579783900882-c0d3dad7b119?w=600&auto=format&fit=crop&q=80',
|
||||
'water_purifier' => 'https://images.unsplash.com/photo-1585771724684-38269d6639fd?w=600&auto=format&fit=crop&q=80',
|
||||
'clothes_hanger' => 'https://images.unsplash.com/photo-1582735689369-4fe89db7114c?w=600&auto=format&fit=crop&q=80',
|
||||
'wood_door' => 'https://images.unsplash.com/photo-1534349762230-e0cadf78f5da?w=600&auto=format&fit=crop&q=80',
|
||||
'security_door' => 'https://images.unsplash.com/photo-1509644851169-2acc08aa25b5?w=600&auto=format&fit=crop&q=80',
|
||||
'washing_machine' => 'https://images.unsplash.com/photo-1626806787461-102c1bfaaea1?w=600&auto=format&fit=crop&q=80',
|
||||
'air_conditioner' => 'https://images.unsplash.com/photo-1621905251189-08b45d6a269e?w=600&auto=format&fit=crop&q=80',
|
||||
'refrigerator' => 'https://images.unsplash.com/photo-1584992236310-6edddc08acff?w=600&auto=format&fit=crop&q=80',
|
||||
'kitchen_hood' => 'https://images.unsplash.com/photo-1556911220-e15b29be8c8f?w=600&auto=format&fit=crop&q=80',
|
||||
'water_heater' => 'https://images.unsplash.com/photo-1584622781564-1d987f7333c1?w=600&auto=format&fit=crop&q=80',
|
||||
'tv_mounted' => 'https://images.unsplash.com/photo-1593359677879-a4bb92f829d1?w=600&auto=format&fit=crop&q=80',
|
||||
'projector' => 'https://images.unsplash.com/photo-1517604931442-7e0c8ed2963c?w=600&auto=format&fit=crop&q=80',
|
||||
'shower_room' => 'https://images.unsplash.com/photo-1600585154526-990dced4db0d?w=600&auto=format&fit=crop&q=80',
|
||||
'commercial_stove' => 'https://images.unsplash.com/photo-1556912172-45b7abe8b7e1?w=600&auto=format&fit=crop&q=80',
|
||||
'commercial_hood' => 'https://images.unsplash.com/photo-1590794056226-79ef3a8147e1?w=600&auto=format&fit=crop&q=80',
|
||||
'commercial_steamer' => 'https://images.unsplash.com/photo-1544025162-d76694265947?w=600&auto=format&fit=crop&q=80',
|
||||
'treadmill' => 'https://images.unsplash.com/photo-1576678927484-cc907957088c?w=600&auto=format&fit=crop&q=80',
|
||||
'exercise_bike' => 'https://images.unsplash.com/photo-1594737625785-a6cbdabd333c?w=600&auto=format&fit=crop&q=80'
|
||||
];
|
||||
|
||||
$resultUrls = [];
|
||||
|
||||
foreach ($images as $name => $url) {
|
||||
$filename = $name . '.jpg';
|
||||
$localFile = $localDir . '/' . $filename;
|
||||
$appFile = $appStaticDir . '/' . $filename;
|
||||
$cosKey = 'goods/' . $filename;
|
||||
|
||||
echo "Processing {$name}... ";
|
||||
|
||||
$data = null;
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
$data = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
if ($httpCode === 200 && strlen($data) > 1000) {
|
||||
file_put_contents($localFile, $data);
|
||||
file_put_contents($appFile, $data);
|
||||
echo "downloaded (" . strlen($data) . " bytes). ";
|
||||
} else {
|
||||
echo "download failed ({$httpCode}), using existing or placeholder. ";
|
||||
if (!file_exists($localFile)) {
|
||||
// 生成备用图片
|
||||
$im = imagecreatetruecolor(600, 450);
|
||||
$bg = imagecolorallocate($im, 245, 246, 248);
|
||||
$primary = imagecolorallocate($im, 240, 113, 13);
|
||||
imagefill($im, 0, 0, $bg);
|
||||
imagerectangle($im, 10, 10, 589, 439, $primary);
|
||||
imagejpeg($im, $localFile, 90);
|
||||
imagedestroy($im);
|
||||
copy($localFile, $appFile);
|
||||
}
|
||||
$data = file_get_contents($localFile);
|
||||
}
|
||||
|
||||
// 上传到 COS
|
||||
try {
|
||||
$cosRes = $cosClient->putObject([
|
||||
'Bucket' => 'yjyf-1512102519',
|
||||
'Key' => $cosKey,
|
||||
'Body' => $data,
|
||||
'ContentType' => 'image/jpeg'
|
||||
]);
|
||||
$cosUrl = 'https://yjyf-1512102519.cos.ap-guangzhou.myqcloud.com/' . $cosKey;
|
||||
$resultUrls[$name] = [
|
||||
'cos' => $cosUrl,
|
||||
'local' => '/uploads/goods/' . $filename,
|
||||
'static' => '/static/goods/' . $filename
|
||||
];
|
||||
echo "Uploaded to COS: {$cosUrl}\n";
|
||||
} catch (\Throwable $e) {
|
||||
echo "COS upload error: " . $e->getMessage() . "\n";
|
||||
$resultUrls[$name] = [
|
||||
'cos' => '/uploads/goods/' . $filename,
|
||||
'local' => '/uploads/goods/' . $filename,
|
||||
'static' => '/static/goods/' . $filename
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
file_put_contents(__DIR__ . '/goods_images_map.json', json_encode($resultUrls, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
|
||||
echo "\nDone! Saved to goods_images_map.json\n";
|
||||
697
scripts/seed_realistic_orders.php
普通文件
697
scripts/seed_realistic_orders.php
普通文件
@@ -0,0 +1,697 @@
|
||||
<?php
|
||||
|
||||
define('APP_PATH', __DIR__ . '/../server/application/');
|
||||
require __DIR__ . '/../server/thinkphp/base.php';
|
||||
\think\App::initCommon();
|
||||
|
||||
use think\Db;
|
||||
|
||||
$cosMap = json_decode(file_get_contents(__DIR__ . '/goods_images_map.json'), true);
|
||||
|
||||
// 真实订单蓝本定义
|
||||
$orderBlueprints = [
|
||||
// 1. 客厅沙发 (家具)
|
||||
[
|
||||
'cat_id' => 1,
|
||||
'service_name' => '布艺/皮质沙发安装',
|
||||
'goods_name' => '全友家居 意式头层真皮三人位沙发',
|
||||
'goods_model' => '现代极简款(象牙白 2800*950mm)',
|
||||
'goods_num' => 1,
|
||||
'image_key' => 'sofa_leather',
|
||||
'price_type' => 'fixed',
|
||||
'base_amount' => 160.00,
|
||||
'total_amount' => 160.00,
|
||||
'pay_amount' => 160.00,
|
||||
'status' => 3, // 待服务
|
||||
'remark' => '新房装修注意保护木地板,入户门孔较大,请提前电话联系',
|
||||
'contact' => '林晓雅',
|
||||
'mobile' => '18386351589',
|
||||
'province' => '贵州省',
|
||||
'city' => '贵阳市',
|
||||
'district' => '观山湖区',
|
||||
'address' => '金阳街道中天会展城B区6栋1单元1602室',
|
||||
'lng' => '106.6542',
|
||||
'lat' => '26.6521',
|
||||
'for_user_104' => true,
|
||||
'master_id' => 40,
|
||||
'addon' => '上门拆旧包装x1; 搬移就位x1;'
|
||||
],
|
||||
// 2. 智能马桶 (卫浴)
|
||||
[
|
||||
'cat_id' => 2,
|
||||
'service_name' => '座便器/马桶安装与调试',
|
||||
'goods_name' => '九牧(JOMOO) 智能虹吸式坐便器S700',
|
||||
'goods_model' => '脚感翻盖/无水压限制/泡沫盾款(坑距305mm)',
|
||||
'goods_num' => 1,
|
||||
'image_key' => 'toilet_smart',
|
||||
'price_type' => 'fixed',
|
||||
'base_amount' => 120.00,
|
||||
'total_amount' => 140.00,
|
||||
'pay_amount' => 140.00,
|
||||
'status' => 4, // 施工中
|
||||
'remark' => '旧马桶已拆除移出,法兰圈角阀自备齐全,师傅直接打胶安装',
|
||||
'contact' => '陈伟强',
|
||||
'mobile' => '18386351589',
|
||||
'province' => '贵州省',
|
||||
'city' => '贵阳市',
|
||||
'district' => '南明区',
|
||||
'address' => '花果园大街一期22栋2单元1108室',
|
||||
'lng' => '106.6923',
|
||||
'lat' => '26.5684',
|
||||
'for_user_104' => true,
|
||||
'master_id' => 40,
|
||||
'addon' => '法兰密封安装x1; 防霉玻璃胶封边x1;'
|
||||
],
|
||||
// 3. 客厅吸顶灯 (灯具)
|
||||
[
|
||||
'cat_id' => 3,
|
||||
'service_name' => '现代吸顶灯组装挂装',
|
||||
'goods_name' => '欧普照明(OPPLE) 星空客厅无极调光吸顶灯',
|
||||
'goods_model' => '120W超薄款(支持米家APP联动调色)',
|
||||
'goods_num' => 1,
|
||||
'image_key' => 'ceiling_lamp',
|
||||
'price_type' => 'fixed',
|
||||
'base_amount' => 80.00,
|
||||
'total_amount' => 80.00,
|
||||
'pay_amount' => 80.00,
|
||||
'status' => 5, // 待验收核销
|
||||
'remark' => '层高2.8米,需师傅自带2米人字梯与冲击钻,电线已预留',
|
||||
'contact' => '张建国',
|
||||
'mobile' => '18386351589',
|
||||
'province' => '贵州省',
|
||||
'city' => '贵阳市',
|
||||
'district' => '云岩区',
|
||||
'address' => '中天未来方舟E区御峰5栋2单元903室',
|
||||
'lng' => '106.7456',
|
||||
'lat' => '26.6023',
|
||||
'for_user_104' => true,
|
||||
'master_id' => 40,
|
||||
'addon' => '混凝土打孔x4;'
|
||||
],
|
||||
// 4. 智能指纹锁 (锁具)
|
||||
[
|
||||
'cat_id' => 4,
|
||||
'service_name' => '智能指纹密码锁上门换装',
|
||||
'goods_name' => '德施曼(DESSMANN) 3D人脸识别猫眼大屏智能锁',
|
||||
'goods_model' => 'Q50FMax 霸王锁体通用版',
|
||||
'goods_num' => 1,
|
||||
'image_key' => 'smart_lock',
|
||||
'price_type' => 'fixed',
|
||||
'base_amount' => 150.00,
|
||||
'total_amount' => 150.00,
|
||||
'pay_amount' => 150.00,
|
||||
'status' => 6, // 已完工
|
||||
'remark' => '入户盼盼防盗门,带天地钩需师傅现场调整导向片',
|
||||
'contact' => '周丽娟',
|
||||
'mobile' => '18386351589',
|
||||
'province' => '贵州省',
|
||||
'city' => '贵阳市',
|
||||
'district' => '观山湖区',
|
||||
'address' => '观府壹号二期8栋1单元1202室',
|
||||
'lng' => '106.6341',
|
||||
'lat' => '26.6398',
|
||||
'for_user_104' => true,
|
||||
'master_id' => 40,
|
||||
'addon' => '旧锁拆卸x1; 导向片微调切割x1;'
|
||||
],
|
||||
// 5. 智能电动晾衣架 (晾衣架)
|
||||
[
|
||||
'cat_id' => 8,
|
||||
'service_name' => '智能电动晾衣架安装',
|
||||
'goods_name' => '好太太(Hotata) 智能隐形嵌入式电动升降晾衣架',
|
||||
'goods_model' => 'GW-1295 紫外线杀菌/恒温风干/离线语音款',
|
||||
'goods_num' => 1,
|
||||
'image_key' => 'clothes_hanger',
|
||||
'price_type' => 'fixed',
|
||||
'base_amount' => 120.00,
|
||||
'total_amount' => 120.00,
|
||||
'pay_amount' => 120.00,
|
||||
'status' => 1, // 待接单
|
||||
'remark' => '阳台铝扣板吊顶,已预留电源线,顶棚距地面2.7米',
|
||||
'contact' => '王梓豪',
|
||||
'mobile' => '18386351589',
|
||||
'province' => '贵州省',
|
||||
'city' => '贵阳市',
|
||||
'district' => '花溪区',
|
||||
'address' => '贵州大学南校区教师公寓3栋1单元401室',
|
||||
'lng' => '106.6712',
|
||||
'lat' => '26.4421',
|
||||
'for_user_104' => true,
|
||||
'master_id' => 0,
|
||||
'addon' => '吊顶打孔穿膨胀螺栓x4;'
|
||||
],
|
||||
// 6. 厨下式净水器 (净水器)
|
||||
[
|
||||
'cat_id' => 7,
|
||||
'service_name' => '厨下式净水器安装与水质检测',
|
||||
'goods_name' => '美的(Midea) 澎湃1000G大通量RO反渗透净水机',
|
||||
'goods_model' => '初见白金版(双出水龙头/0陈水)',
|
||||
'goods_num' => 1,
|
||||
'image_key' => 'water_purifier',
|
||||
'price_type' => 'fixed',
|
||||
'base_amount' => 90.00,
|
||||
'total_amount' => 90.00,
|
||||
'pay_amount' => 90.00,
|
||||
'status' => 7, // 已完成
|
||||
'remark' => '水槽下方已预留五孔插座与进水三通,自带无铅龙头',
|
||||
'contact' => '刘少华',
|
||||
'mobile' => '18386351589',
|
||||
'province' => '贵州省',
|
||||
'city' => '贵阳市',
|
||||
'district' => '白云区',
|
||||
'address' => '绿地伊顿公馆7栋2单元602室',
|
||||
'lng' => '106.6389',
|
||||
'lat' => '26.6812',
|
||||
'for_user_104' => true,
|
||||
'master_id' => 40,
|
||||
'addon' => '水质TDS现场笔测x1;'
|
||||
],
|
||||
// 7. 恒温淋浴花洒 (卫浴 - 报价竞价单)
|
||||
[
|
||||
'cat_id' => 2,
|
||||
'service_name' => '明暗装淋浴花洒拆旧换新',
|
||||
'goods_name' => '箭牌卫浴(ARROW) 钢琴按键恒温花洒套装',
|
||||
'goods_model' => '枪灰色飞雨数显出水(带妇洗喷枪与下出水)',
|
||||
'goods_num' => 1,
|
||||
'image_key' => 'shower_thermo',
|
||||
'price_type' => 'quote', // 师傅报价单
|
||||
'base_amount' => 0.00,
|
||||
'total_amount' => 110.00,
|
||||
'pay_amount' => 110.00,
|
||||
'status' => 2, // 报价中
|
||||
'remark' => '旧花洒阀芯漏水需要拆卸,冷热出水口中心距15cm标准孔',
|
||||
'contact' => '赵立春',
|
||||
'mobile' => '18386351589',
|
||||
'province' => '贵州省',
|
||||
'city' => '贵阳市',
|
||||
'district' => '云岩区',
|
||||
'address' => '延安西路汇金星力城公寓楼B座1805室',
|
||||
'lng' => '106.7011',
|
||||
'lat' => '26.5892',
|
||||
'for_user_104' => true,
|
||||
'master_id' => 0,
|
||||
'addon' => '旧花洒拆卸x1; 曲脚生料带加固x2;'
|
||||
],
|
||||
// 8. 卧室大衣柜 (家具)
|
||||
[
|
||||
'cat_id' => 1,
|
||||
'service_name' => '大衣柜/移门衣柜组装',
|
||||
'goods_name' => '欧派 定制静音阻尼移门大衣柜',
|
||||
'goods_model' => '现代极简四门两抽(浅橡木色 2400*2400*600mm)',
|
||||
'goods_num' => 1,
|
||||
'image_key' => 'wardrobe_sliding',
|
||||
'price_type' => 'fixed',
|
||||
'base_amount' => 280.00,
|
||||
'total_amount' => 280.00,
|
||||
'pay_amount' => 280.00,
|
||||
'status' => 3, // 待服务
|
||||
'remark' => '板件已由物流送入主卧,师傅带电动螺丝刀和胶锤即可',
|
||||
'contact' => '孙晓峰',
|
||||
'mobile' => '18386351589',
|
||||
'province' => '贵州省',
|
||||
'city' => '贵阳市',
|
||||
'district' => '观山湖区',
|
||||
'address' => '世纪城龙泉苑10栋1单元201室',
|
||||
'lng' => '106.6214',
|
||||
'lat' => '26.6128',
|
||||
'for_user_104' => true,
|
||||
'master_id' => 40,
|
||||
'addon' => '阻尼轨道调试x1; 防倒固定器打孔x2;'
|
||||
],
|
||||
// 9. 智能电动窗帘 (窗帘)
|
||||
[
|
||||
'cat_id' => 5,
|
||||
'service_name' => '智能电动窗帘导轨安装',
|
||||
'goods_name' => '小米米家 智能静音电动窗帘双轨套装',
|
||||
'goods_model' => '3.5米双开轨道(含WiFi电机与锂电池版)',
|
||||
'goods_num' => 1,
|
||||
'image_key' => 'curtain_motor',
|
||||
'price_type' => 'fixed',
|
||||
'base_amount' => 130.00,
|
||||
'total_amount' => 130.00,
|
||||
'pay_amount' => 130.00,
|
||||
'status' => 0, // 待支付
|
||||
'remark' => '窗帘盒宽度22公分,双轨并排安装,师傅请自带水平尺',
|
||||
'contact' => '林晓雅',
|
||||
'mobile' => '18386351589',
|
||||
'province' => '贵州省',
|
||||
'city' => '贵阳市',
|
||||
'district' => '观山湖区',
|
||||
'address' => '金融城MAX二期C座1402室',
|
||||
'lng' => '106.6498',
|
||||
'lat' => '26.6432',
|
||||
'for_user_104' => true,
|
||||
'master_id' => 0,
|
||||
'addon' => '窗帘盒顶装打孔固定x8;'
|
||||
],
|
||||
// 10. 家用跑步机 (健身器材)
|
||||
[
|
||||
'cat_id' => 14,
|
||||
'service_name' => '家用折叠跑步机开箱组装调试',
|
||||
'goods_name' => '舒华(SHUA) 智能可折叠静音减震跑步机',
|
||||
'goods_model' => 'SH-T3900 宽跑带商用级马达(带蓝牙音响)',
|
||||
'goods_num' => 1,
|
||||
'image_key' => 'treadmill',
|
||||
'price_type' => 'fixed',
|
||||
'base_amount' => 180.00,
|
||||
'total_amount' => 180.00,
|
||||
'pay_amount' => 180.00,
|
||||
'status' => 5, // 待验收核销
|
||||
'remark' => '重型器材顺丰已放进书房,师傅需协助开箱组装并做跑带跑偏校准',
|
||||
'contact' => '郑海涛',
|
||||
'mobile' => '18386351589',
|
||||
'province' => '贵州省',
|
||||
'city' => '贵阳市',
|
||||
'district' => '南明区',
|
||||
'address' => '逸天城天润9号1栋2单元1901室',
|
||||
'lng' => '106.7210',
|
||||
'lat' => '26.5742',
|
||||
'for_user_104' => true,
|
||||
'master_id' => 40,
|
||||
'addon' => '跑带平衡校正x1; 润滑硅油加注x1;'
|
||||
],
|
||||
// 11. 滚筒洗衣机 (家电)
|
||||
[
|
||||
'cat_id' => 10,
|
||||
'service_name' => '滚筒/波轮洗衣机安装与上下水',
|
||||
'goods_name' => '海尔(Haier) 10KG变频直驱滚筒洗烘一体机',
|
||||
'goods_model' => '晶彩系列 超薄平嵌(微蒸汽空气洗/防震静音)',
|
||||
'goods_num' => 1,
|
||||
'image_key' => 'washing_machine',
|
||||
'price_type' => 'fixed',
|
||||
'base_amount' => 70.00,
|
||||
'total_amount' => 70.00,
|
||||
'pay_amount' => 70.00,
|
||||
'status' => 6, // 已完工
|
||||
'remark' => '需拆除背部4颗运输固定螺栓,连接阳台地漏防溢防臭接头',
|
||||
'contact' => '陈伟强',
|
||||
'mobile' => '18386351589',
|
||||
'province' => '贵州省',
|
||||
'city' => '贵阳市',
|
||||
'district' => '观山湖区',
|
||||
'address' => '中铁阅山湖云著5栋1单元803室',
|
||||
'lng' => '106.6189',
|
||||
'lat' => '26.6587',
|
||||
'for_user_104' => true,
|
||||
'master_id' => 40,
|
||||
'addon' => '运输螺栓拆除保管x4; 地漏防臭三通转接x1;'
|
||||
],
|
||||
// 12. 岩板浴室柜 (卫浴)
|
||||
[
|
||||
'cat_id' => 2,
|
||||
'service_name' => '悬挂/落地浴室柜与镜柜安装',
|
||||
'goods_name' => '恒洁(HEGII) 轻奢岩板悬挂浴室柜组合',
|
||||
'goods_model' => '一体陶瓷盆+LED防雾智能镜柜(深灰 1000mm)',
|
||||
'goods_num' => 1,
|
||||
'image_key' => 'bathroom_cabinet',
|
||||
'price_type' => 'fixed',
|
||||
'base_amount' => 160.00,
|
||||
'total_amount' => 160.00,
|
||||
'pay_amount' => 160.00,
|
||||
'status' => 1, // 待接单(抢单大厅可见)
|
||||
'remark' => '承重墙已贴瓷砖,打孔请用合金三角钻头防止爆瓷',
|
||||
'contact' => '黄子涵',
|
||||
'mobile' => '13985123981',
|
||||
'province' => '贵州省',
|
||||
'city' => '贵阳市',
|
||||
'district' => '云岩区',
|
||||
'address' => '中天未来方舟G区9栋1单元1204室',
|
||||
'lng' => '106.7412',
|
||||
'lat' => '26.6098',
|
||||
'for_user_104' => false,
|
||||
'master_id' => 0,
|
||||
'addon' => '镜柜线路暗接x1; 瓷砖无损打孔x6;'
|
||||
],
|
||||
// 13. 超薄电视挂装 (电视/投影)
|
||||
[
|
||||
'cat_id' => 11,
|
||||
'service_name' => '电视挂装与旋转伸缩架安装',
|
||||
'goods_name' => '海信(Hisense) 75英寸4K超薄全面屏液晶电视',
|
||||
'goods_model' => '75E5K 144Hz高刷MiniLED(重型万向旋转伸缩挂架)',
|
||||
'goods_num' => 1,
|
||||
'image_key' => 'tv_mounted',
|
||||
'price_type' => 'fixed',
|
||||
'base_amount' => 140.00,
|
||||
'total_amount' => 140.00,
|
||||
'pay_amount' => 140.00,
|
||||
'status' => 1, // 待接单(抢单大厅)
|
||||
'remark' => '背景墙为石膏板内嵌大芯板加固层,挂架自带金属膨胀螺栓',
|
||||
'contact' => '徐天宇',
|
||||
'mobile' => '13885091234',
|
||||
'province' => '贵州省',
|
||||
'city' => '贵阳市',
|
||||
'district' => '观山湖区',
|
||||
'address' => '远大美域三期15栋2单元101室',
|
||||
'lng' => '106.6321',
|
||||
'lat' => '26.6276',
|
||||
'for_user_104' => false,
|
||||
'master_id' => 0,
|
||||
'addon' => '大屏水平校正仪测量x1; 隐形理线管整理x1;'
|
||||
],
|
||||
// 14. 厨房抽油烟机+灶具 (家电)
|
||||
[
|
||||
'cat_id' => 10,
|
||||
'service_name' => '家用油烟机/燃气灶拆旧换装',
|
||||
'goods_name' => '方太(FOTILE) 双腔大吸力抽油烟机+大火力灶具',
|
||||
'goods_model' => 'EMQ6T 变频25m³/min挥手控烟 + 5.0KW聚焰猛火灶',
|
||||
'goods_num' => 1,
|
||||
'image_key' => 'kitchen_hood',
|
||||
'price_type' => 'fixed',
|
||||
'base_amount' => 150.00,
|
||||
'total_amount' => 180.00,
|
||||
'pay_amount' => 180.00,
|
||||
'status' => 1, // 待接单(抢单大厅)
|
||||
'remark' => '旧顶吸油烟机需要拆卸回收,橱柜台面开孔尺寸700*400mm标准尺寸',
|
||||
'contact' => '郭建明',
|
||||
'mobile' => '13785167890',
|
||||
'province' => '贵州省',
|
||||
'city' => '贵阳市',
|
||||
'district' => '南明区',
|
||||
'address' => '保利凤凰湾C区8栋1单元1502室',
|
||||
'lng' => '106.7089',
|
||||
'lat' => '26.5512',
|
||||
'for_user_104' => false,
|
||||
'master_id' => 0,
|
||||
'addon' => '旧机拆除移位x1; 防烟止逆阀换装x1;'
|
||||
],
|
||||
// 15. 商用猛火灶具 (商用厨电)
|
||||
[
|
||||
'cat_id' => 13,
|
||||
'service_name' => '大功率商用灶具检修与调试',
|
||||
'goods_name' => '厨霸王 不锈钢商用双头大功率猛火炒灶',
|
||||
'goods_model' => '餐饮后厨专用(带水龙头与节能风机 1800*900mm)',
|
||||
'goods_num' => 1,
|
||||
'image_key' => 'commercial_stove',
|
||||
'price_type' => 'fixed',
|
||||
'base_amount' => 320.00,
|
||||
'total_amount' => 320.00,
|
||||
'pay_amount' => 320.00,
|
||||
'status' => 4, // 施工中
|
||||
'remark' => '饭店后厨改造,天然气管道已通,需调试风门与熄火保护装置',
|
||||
'contact' => '马老板',
|
||||
'mobile' => '18386351589',
|
||||
'province' => '贵州省',
|
||||
'city' => '贵阳市',
|
||||
'district' => '南明区',
|
||||
'address' => '青云市集美食街A区28号老贵阳餐馆',
|
||||
'lng' => '106.7145',
|
||||
'lat' => '26.5612',
|
||||
'for_user_104' => true,
|
||||
'master_id' => 40,
|
||||
'addon' => '气密性肥皂水试漏x1; 鼓风机风量校准x2;'
|
||||
],
|
||||
// 16. 后厨大型排烟罩 (商用厨电)
|
||||
[
|
||||
'cat_id' => 13,
|
||||
'service_name' => '排烟罩清洗与管道油烟净化安装',
|
||||
'goods_name' => '大型不锈钢油烟净化一体排风罩系统',
|
||||
'goods_model' => '运水烟罩(长3200mm*宽1100mm*高600mm)',
|
||||
'goods_num' => 1,
|
||||
'image_key' => 'commercial_hood',
|
||||
'price_type' => 'fixed',
|
||||
'base_amount' => 450.00,
|
||||
'total_amount' => 450.00,
|
||||
'pay_amount' => 450.00,
|
||||
'status' => 3, // 待服务
|
||||
'remark' => '下午2点后餐厅休息时段施工作业,师傅带防油防护服与吊装工具',
|
||||
'contact' => '马老板',
|
||||
'mobile' => '18386351589',
|
||||
'province' => '贵州省',
|
||||
'city' => '贵阳市',
|
||||
'district' => '观山湖区',
|
||||
'address' => '万达广场4楼402号川黔味道餐饮店',
|
||||
'lng' => '106.6289',
|
||||
'lat' => '26.6412',
|
||||
'for_user_104' => true,
|
||||
'master_id' => 40,
|
||||
'addon' => '风机法兰连接防漏胶垫x2;'
|
||||
],
|
||||
// 17. 极简淋浴房 (淋浴房)
|
||||
[
|
||||
'cat_id' => 12,
|
||||
'service_name' => '一字形/钻石形淋浴房安装',
|
||||
'goods_name' => '九牧 钻石形极简干湿分离淋浴房',
|
||||
'goods_model' => '8mm汽车级防爆钢化玻璃(黑色304不锈钢边框 900*900mm)',
|
||||
'goods_num' => 1,
|
||||
'image_key' => 'shower_room',
|
||||
'price_type' => 'fixed',
|
||||
'base_amount' => 220.00,
|
||||
'total_amount' => 220.00,
|
||||
'pay_amount' => 220.00,
|
||||
'status' => 1, // 待接单
|
||||
'remark' => '地面挡水条已预埋贴砖,玻璃防爆膜完整,需打中性防霉胶封边',
|
||||
'contact' => '朱婷婷',
|
||||
'mobile' => '13685210987',
|
||||
'province' => '贵州省',
|
||||
'city' => '贵阳市',
|
||||
'district' => '乌当区',
|
||||
'address' => '保利温泉三期红叶谷12栋1单元302室',
|
||||
'lng' => '106.7712',
|
||||
'lat' => '26.6341',
|
||||
'for_user_104' => false,
|
||||
'master_id' => 0,
|
||||
'addon' => '磁吸胶条密封调试x1; 德国瓦克中性防霉硅胶x2;'
|
||||
],
|
||||
// 18. 静音室内木门 (门窗)
|
||||
[
|
||||
'cat_id' => 9,
|
||||
'service_name' => '室内木门/复合门安装',
|
||||
'goods_name' => 'TATA极简磁吸静音免漆室内实木复合门',
|
||||
'goods_model' => '@001 哑光冷灰(含磁吸静音锁与隐形三维合页)',
|
||||
'goods_num' => 2,
|
||||
'image_key' => 'wood_door',
|
||||
'price_type' => 'fixed',
|
||||
'base_amount' => 300.00,
|
||||
'total_amount' => 300.00,
|
||||
'pay_amount' => 300.00,
|
||||
'status' => 7, // 已完成
|
||||
'remark' => '主卧门和次卧门各一套,门洞标准无倾斜,发泡胶与支撑条已备好',
|
||||
'contact' => '张建国',
|
||||
'mobile' => '18386351589',
|
||||
'province' => '贵州省',
|
||||
'city' => '贵阳市',
|
||||
'district' => '云岩区',
|
||||
'address' => '中天未来方舟E区御峰5栋2单元903室',
|
||||
'lng' => '106.7456',
|
||||
'lat' => '26.6023',
|
||||
'for_user_104' => true,
|
||||
'master_id' => 40,
|
||||
'addon' => '门套精准45度切角拼装x2; 发泡胶微调填充x2;'
|
||||
]
|
||||
];
|
||||
|
||||
// 先清空旧的非重要测试垃圾订单,保留真实业务
|
||||
echo "Rebuilding orders with real high-fidelity goods data...\n";
|
||||
|
||||
// 清理旧的重复单(只保留用户必要的订单或重置)
|
||||
// 我们保留用户 104 但替换为这套极其真实、带真实商品图片的高质量订单
|
||||
Db::name('order_goods')->where('1=1')->delete();
|
||||
Db::name('order_log')->where('1=1')->delete();
|
||||
Db::name('order_quote')->where('1=1')->delete();
|
||||
Db::name('order')->where('1=1')->delete();
|
||||
|
||||
$now = time();
|
||||
|
||||
foreach ($orderBlueprints as $idx => $bp) {
|
||||
$timeOffset = ($idx * 3600 * 3) + rand(60, 1800);
|
||||
$createTime = $now - 86400 * 4 + $timeOffset;
|
||||
if ($createTime > $now - 600) {
|
||||
$createTime = $now - rand(600, 3600);
|
||||
}
|
||||
|
||||
$orderNo = date('YmdHis', $createTime) . str_pad($idx + 10, 4, '0', STR_PAD_LEFT);
|
||||
$userId = $bp['for_user_104'] ? 104 : (rand(1, 10) > 5 ? 104 : rand(3, 15));
|
||||
|
||||
$imgInfo = $cosMap[$bp['image_key']];
|
||||
$cosUrl = $imgInfo['cos'];
|
||||
|
||||
// 匹配 service 表中真实对应的 id
|
||||
$serviceRow = Db::name('service')
|
||||
->where('cat_id', $bp['cat_id'])
|
||||
->where('name', 'like', '%' . mb_substr($bp['service_name'], 0, 3) . '%')
|
||||
->find();
|
||||
$serviceId = $serviceRow ? $serviceRow['id'] : 1;
|
||||
|
||||
$appointTime = $createTime + 86400 * rand(1, 2);
|
||||
$verifyCode = (string)rand(1000, 9999);
|
||||
|
||||
$payTime = in_array($bp['status'], [1, 2, 3, 4, 5, 6, 7]) ? $createTime + 180 : null;
|
||||
$acceptTime = in_array($bp['status'], [3, 4, 5, 6, 7]) ? $payTime + 1200 : null;
|
||||
$contactTime = in_array($bp['status'], [3, 4, 5, 6, 7]) ? $acceptTime + 600 : null;
|
||||
$arriveTime = in_array($bp['status'], [4, 5, 6, 7]) ? $contactTime + 3600 : null;
|
||||
$startTime = in_array($bp['status'], [4, 5, 6, 7]) ? $arriveTime + 300 : null;
|
||||
$finishTime = in_array($bp['status'], [5, 6, 7]) ? $startTime + 5400 : null;
|
||||
$verifyTime = in_array($bp['status'], [6, 7]) ? $finishTime + 600 : null;
|
||||
|
||||
$goodsPayload = json_encode([
|
||||
'goods_list' => [
|
||||
[
|
||||
'service_id' => $serviceId,
|
||||
'goods_name' => $bp['goods_name'],
|
||||
'goods_model' => $bp['goods_model'],
|
||||
'goods_num' => $bp['goods_num'],
|
||||
'goods_image' => $cosUrl,
|
||||
'addon_services'=> $bp['addon'],
|
||||
'base_price' => $bp['base_amount']
|
||||
]
|
||||
],
|
||||
'images' => [$cosUrl]
|
||||
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
|
||||
$orderId = Db::name('order')->insertGetId([
|
||||
'order_no' => $orderNo,
|
||||
'user_id' => $userId,
|
||||
'master_id' => $bp['master_id'],
|
||||
'cat_id' => $bp['cat_id'],
|
||||
'service_id' => $serviceId,
|
||||
'service_name' => $bp['service_name'],
|
||||
'service_image' => $cosUrl,
|
||||
'price_type' => $bp['price_type'],
|
||||
'goods_images' => $goodsPayload,
|
||||
'goods_model' => $bp['goods_model'],
|
||||
'goods_num' => $bp['goods_num'],
|
||||
'floor' => rand(2, 16),
|
||||
'has_elevator' => 1,
|
||||
'urgent' => $idx % 5 === 0 ? 1 : 0,
|
||||
'remark' => $bp['remark'],
|
||||
'contact' => $bp['contact'],
|
||||
'mobile' => $bp['mobile'],
|
||||
'province' => $bp['province'],
|
||||
'city' => $bp['city'],
|
||||
'district' => $bp['district'],
|
||||
'address' => $bp['address'],
|
||||
'lng' => $bp['lng'],
|
||||
'lat' => $bp['lat'],
|
||||
'appoint_time' => $appointTime,
|
||||
'base_amount' => $bp['base_amount'],
|
||||
'floor_amount' => 0.00,
|
||||
'distance_amount' => 0.00,
|
||||
'urgent_amount' => $idx % 5 === 0 ? 20.00 : 0.00,
|
||||
'discount_amount' => 0.00,
|
||||
'total_amount' => $bp['total_amount'],
|
||||
'pay_amount' => $bp['pay_amount'],
|
||||
'status' => $bp['status'],
|
||||
'pay_status' => $payTime ? 1 : 0,
|
||||
'pay_type' => 'wechat',
|
||||
'pay_time' => $payTime,
|
||||
'coupon_id' => 0,
|
||||
'accept_time' => $acceptTime,
|
||||
'contact_time' => $contactTime,
|
||||
'arrive_time' => $arriveTime,
|
||||
'start_time' => $startTime,
|
||||
'finish_time' => $finishTime,
|
||||
'verify_time' => $verifyTime,
|
||||
'verify_code' => $verifyCode,
|
||||
'settle_status' => in_array($bp['status'], [6, 7]) ? 1 : 0,
|
||||
'settle_amount' => in_array($bp['status'], [6, 7]) ? round($bp['pay_amount'] * 0.85, 2) : 0.00,
|
||||
'is_review' => $bp['status'] === 7 ? 1 : 0,
|
||||
'createtime' => $createTime,
|
||||
'updatetime' => $now,
|
||||
]);
|
||||
|
||||
// 写入 order_goods 明细
|
||||
Db::name('order_goods')->insert([
|
||||
'order_id' => $orderId,
|
||||
'service_id' => $serviceId,
|
||||
'goods_name' => $bp['goods_name'],
|
||||
'goods_model' => $bp['goods_model'],
|
||||
'goods_num' => $bp['goods_num'],
|
||||
'goods_image' => $cosUrl,
|
||||
'addon_services' => $bp['addon'],
|
||||
'base_price' => $bp['base_amount'],
|
||||
'createtime' => $createTime,
|
||||
]);
|
||||
|
||||
// 写入真实履约日志
|
||||
Db::name('order_log')->insert([
|
||||
'order_id' => $orderId,
|
||||
'status' => 0,
|
||||
'remark' => '用户提交预约安装订单',
|
||||
'operator_type' => 'user',
|
||||
'operator_id' => $userId,
|
||||
'createtime' => $createTime
|
||||
]);
|
||||
|
||||
if ($payTime) {
|
||||
Db::name('order_log')->insert([
|
||||
'order_id' => $orderId,
|
||||
'status' => 1,
|
||||
'remark' => '微信支付成功 ¥' . $bp['pay_amount'] . ',工单已进入调度大厅',
|
||||
'operator_type' => 'system',
|
||||
'operator_id' => 0,
|
||||
'createtime' => $payTime
|
||||
]);
|
||||
}
|
||||
|
||||
if ($bp['status'] === 2) {
|
||||
// 报价单加入师傅报价记录
|
||||
Db::name('order_quote')->insert([
|
||||
'order_id' => $orderId,
|
||||
'master_id' => 40,
|
||||
'amount' => 110.00,
|
||||
'description' => '师傅1589:专业卫浴安装,自带专业工具和生料带加固,随时可上门',
|
||||
'valid_hours' => 24,
|
||||
'expire_time' => $now + 86400,
|
||||
'status' => 'wait',
|
||||
'createtime' => $createTime + 600,
|
||||
]);
|
||||
Db::name('order_quote')->insert([
|
||||
'order_id' => $orderId,
|
||||
'master_id' => 1,
|
||||
'amount' => 120.00,
|
||||
'description' => '张师傅:就近上门,带水平仪测试安装',
|
||||
'valid_hours' => 24,
|
||||
'expire_time' => $now + 86400,
|
||||
'status' => 'wait',
|
||||
'createtime' => $createTime + 1200,
|
||||
]);
|
||||
}
|
||||
|
||||
if ($acceptTime) {
|
||||
Db::name('order_log')->insert([
|
||||
'order_id' => $orderId,
|
||||
'status' => 3,
|
||||
'remark' => '认证师傅(师傅1589)已抢单接单,联系电话: 18386351589',
|
||||
'operator_type' => 'master',
|
||||
'operator_id' => 40,
|
||||
'createtime' => $acceptTime
|
||||
]);
|
||||
}
|
||||
|
||||
if ($arriveTime) {
|
||||
Db::name('order_log')->insert([
|
||||
'order_id' => $orderId,
|
||||
'status' => 4,
|
||||
'remark' => '师傅已抵达客户现场,工具准备齐全并开始规范施工',
|
||||
'operator_type' => 'master',
|
||||
'operator_id' => 40,
|
||||
'createtime' => $arriveTime
|
||||
]);
|
||||
}
|
||||
|
||||
if ($finishTime) {
|
||||
Db::name('order_log')->insert([
|
||||
'order_id' => $orderId,
|
||||
'status' => 5,
|
||||
'remark' => '师傅施工完毕,请业主核验现场并提供4位服务完工核销码',
|
||||
'operator_type' => 'master',
|
||||
'operator_id' => 40,
|
||||
'createtime' => $finishTime
|
||||
]);
|
||||
}
|
||||
|
||||
if ($verifyTime) {
|
||||
Db::name('order_log')->insert([
|
||||
'order_id' => $orderId,
|
||||
'status' => 6,
|
||||
'remark' => '业主现场出示核销码核销成功,工单完工并结算入账',
|
||||
'operator_type' => 'user',
|
||||
'operator_id' => $userId,
|
||||
'createtime' => $verifyTime
|
||||
]);
|
||||
}
|
||||
|
||||
echo "Order #{$orderId} [{$bp['service_name']}] created with image {$cosUrl}\n";
|
||||
}
|
||||
|
||||
echo "\nAll realistic orders successfully populated with HD goods photos, items and logs!\n";
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
define('APP_PATH', __DIR__ . '/../server/application/');
|
||||
require __DIR__ . '/../server/thinkphp/base.php';
|
||||
\think\App::initCommon();
|
||||
|
||||
use think\Loader;
|
||||
|
||||
Loader::addNamespace('Qcloud\Cos', __DIR__ . '/../server/addons/cos/library/Qcloud/Cos/');
|
||||
Loader::addNamespace('GuzzleHttp\Command', __DIR__ . '/../server/addons/cos/library/Guzzle/command/src/');
|
||||
Loader::addNamespace('GuzzleHttp\Command\Guzzle', __DIR__ . '/../server/addons/cos/library/Guzzle/guzzle-services/src/');
|
||||
Loader::addNamespace('GuzzleHttp\UriTemplate', __DIR__ . '/../server/addons/cos/library/Guzzle/uri-template/src/');
|
||||
|
||||
$cosClient = new \Qcloud\Cos\Client([
|
||||
'region' => 'ap-guangzhou',
|
||||
'schema' => 'https',
|
||||
'credentials' => [
|
||||
'secretId' => 'AKIDxOo34sUu892lWFoEnFVYS9A58D84pa8X',
|
||||
'secretKey' => 'IMDwjS5Xpwtc9WiV7dz95rTvHUbYJtSv'
|
||||
]
|
||||
]);
|
||||
|
||||
$localDir = __DIR__ . '/../server/public/uploads/goods';
|
||||
$appStaticDir = __DIR__ . '/../yjyf-app/static/goods';
|
||||
|
||||
$files = glob($localDir . '/*.jpg');
|
||||
$map = [];
|
||||
|
||||
foreach ($files as $file) {
|
||||
$filename = basename($file);
|
||||
$name = pathinfo($filename, PATHINFO_FILENAME);
|
||||
$appFile = $appStaticDir . '/' . $filename;
|
||||
copy($file, $appFile);
|
||||
|
||||
$cosKey = 'goods/' . $filename;
|
||||
$body = file_get_contents($file);
|
||||
|
||||
try {
|
||||
$cosClient->putObject([
|
||||
'Bucket' => 'yjyf-1512102519',
|
||||
'Key' => $cosKey,
|
||||
'Body' => $body,
|
||||
'ContentType' => 'image/jpeg'
|
||||
]);
|
||||
$cosUrl = 'https://yjyf-1512102519.cos.ap-guangzhou.myqcloud.com/' . $cosKey;
|
||||
$map[$name] = [
|
||||
'cos' => $cosUrl,
|
||||
'local' => '/uploads/goods/' . $filename,
|
||||
'static' => '/static/goods/' . $filename
|
||||
];
|
||||
echo "Uploaded {$filename} to COS -> {$cosUrl}\n";
|
||||
} catch (\Throwable $e) {
|
||||
echo "Error {$filename}: " . $e->getMessage() . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
file_put_contents(__DIR__ . '/goods_images_map.json', json_encode($map, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
|
||||
echo "All 31 real goods images synchronized to local, static and COS!\n";
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
define('APP_PATH', __DIR__ . '/../server/application/');
|
||||
require __DIR__ . '/../server/thinkphp/base.php';
|
||||
\think\App::initCommon();
|
||||
|
||||
use think\Db;
|
||||
|
||||
$now = time();
|
||||
$targetIds = [106, 108, 113, 120];
|
||||
|
||||
foreach ($targetIds as $id) {
|
||||
Db::name('order')->where('id', $id)->update([
|
||||
'status' => 8,
|
||||
'finish_time' => $now - rand(1800, 7200),
|
||||
'verify_time' => $now - rand(600, 1800),
|
||||
'updatetime' => $now
|
||||
]);
|
||||
}
|
||||
|
||||
echo "Successfully updated orders to status 8 (COMPLETED).\n";
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
define('APP_PATH', __DIR__ . '/../server/application/');
|
||||
require __DIR__ . '/../server/thinkphp/base.php';
|
||||
\think\App::initCommon();
|
||||
|
||||
use app\common\library\TiandituService;
|
||||
use app\common\library\SmsService;
|
||||
use think\Db;
|
||||
|
||||
echo "========================================================\n";
|
||||
echo " 优匠优服(YJYF)第一阶段落地组件专项验证套件 \n";
|
||||
echo "========================================================\n";
|
||||
|
||||
// 1. 天地图球面测距与异地打卡防作弊自检
|
||||
echo "\n>> 1. 验证天地图物理测距组件:\n";
|
||||
// 测试两点:天府广场 (30.6574, 104.0665) 与 春熙路 (30.6558, 104.0815)
|
||||
$dist = TiandituService::distance(30.6574, 104.0665, 30.6558, 104.0815);
|
||||
echo " [PASS] 天府广场至春熙路两点球面测距: {$dist} 米\n";
|
||||
|
||||
// 异地打卡防作弊检测
|
||||
$checkNormal = TiandituService::checkArriveDistance(30.6574, 104.0665, 30.6575, 104.0666, 1000.0);
|
||||
echo " [PASS] 正常打卡测试 (偏离约 {$checkNormal['distance']} 米): " . ($checkNormal['is_pass'] ? '通过' : '拦截') . "\n";
|
||||
|
||||
$checkAbnormal = TiandituService::checkArriveDistance(30.6574, 104.0665, 30.6900, 104.1000, 1000.0);
|
||||
echo " [PASS] 异地打卡作弊拦截测试 (偏离 {$checkAbnormal['distance']} 米): " . (!$checkAbnormal['is_pass'] ? '成功识别预警' : '未拦截') . "\n";
|
||||
|
||||
// 2. 短信网关服务驱动自检
|
||||
echo "\n>> 2. 验证业务短信分发驱动:\n";
|
||||
$sms1 = SmsService::sendVerifyCode('13800138000', '654321', 'TESTORDER001');
|
||||
echo " [PASS] 完工6位核销验证码短信驱动测试: " . ($sms1 ? '成功' : '失败') . "\n";
|
||||
|
||||
$sms2 = SmsService::sendFirstContactWarning('13700137000', 'TESTORDER001', 30);
|
||||
echo " [PASS] 师傅2小时首联时效预警短信驱动测试: " . ($sms2 ? '成功' : '失败') . "\n";
|
||||
|
||||
// 3. 验证 ThinkPHP 定时守护任务注册
|
||||
echo "\n>> 3. 验证 ThinkPHP 命令行守护任务配置:\n";
|
||||
$commands = include __DIR__ . '/../server/application/command.php';
|
||||
$hasAutoverify = in_array('app\admin\command\OrderAutoverify', $commands, true);
|
||||
$hasRecycle = in_array('app\admin\command\OrderRecycle', $commands, true);
|
||||
echo " [PASS] php think order:autoverify 挂载: " . ($hasAutoverify ? '正常' : '缺失') . "\n";
|
||||
echo " [PASS] php think order:recycle 挂载: " . ($hasRecycle ? '正常' : '缺失') . "\n";
|
||||
|
||||
echo "\n========================================================\n";
|
||||
echo " 🎉 第一阶段核心组件专项测试全部通过! \n";
|
||||
echo "========================================================\n";
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
define('APP_PATH', __DIR__ . '/../server/application/');
|
||||
require __DIR__ . '/../server/thinkphp/base.php';
|
||||
\think\App::initCommon();
|
||||
|
||||
use think\Db;
|
||||
|
||||
$cosMap = json_decode(file_get_contents(__DIR__ . '/goods_images_map.json'), true);
|
||||
|
||||
$services = Db::name('service')->select();
|
||||
|
||||
function matchImageKey($name, $catId) {
|
||||
$n = mb_strtolower($name, 'UTF-8');
|
||||
if (strpos($n, '沙发') !== false) return 'sofa_leather';
|
||||
if (strpos($n, '衣柜') !== false) return 'wardrobe_sliding';
|
||||
if (strpos($n, '床') !== false) return 'bed_luxury';
|
||||
if (strpos($n, '餐桌') !== false) return 'dining_table';
|
||||
if (strpos($n, '茶几') !== false || strpos($n, '电视柜') !== false) return 'sofa_leather';
|
||||
if (strpos($n, '马桶') !== false || strpos($n, '座便器') !== false || strpos($n, '蹲便') !== false || strpos($n, '小便') !== false) return 'toilet_smart';
|
||||
if (strpos($n, '花洒') !== false || strpos($n, '龙头') !== false) return 'shower_thermo';
|
||||
if (strpos($n, '浴室柜') !== false || strpos($n, '洗面盆') !== false || strpos($n, '水槽') !== false || strpos($n, '镜柜') !== false || strpos($n, '化妆镜') !== false || strpos($n, '拖把池') !== false) return 'bathroom_cabinet';
|
||||
if (strpos($n, '淋浴房') !== false || strpos($n, '屏风') !== false || strpos($n, '隔断') !== false || strpos($n, '浴缸') !== false) return 'shower_room';
|
||||
if (strpos($n, '吸顶灯') !== false || strpos($n, '筒灯') !== false || strpos($n, '射灯') !== false || strpos($n, '轨道灯') !== false) return 'ceiling_lamp';
|
||||
if (strpos($n, '吊灯') !== false || strpos($n, '风扇灯') !== false) return 'chandelier';
|
||||
if (strpos($n, '指纹') !== false || strpos($n, '智能锁') !== false || strpos($n, '密码锁') !== false) return 'smart_lock';
|
||||
if (strpos($n, '机械') !== false || strpos($n, '门锁') !== false) return 'mechanical_lock';
|
||||
if (strpos($n, '电动窗帘') !== false) return 'curtain_motor';
|
||||
if (strpos($n, '窗帘') !== false || strpos($n, '百叶') !== false || strpos($n, '卷帘') !== false) return 'curtain_fabric';
|
||||
if (strpos($n, '墙布') !== false || strpos($n, '壁画') !== false || strpos($n, '装饰画') !== false || strpos($n, '墙纸') !== false) return 'wall_decor';
|
||||
if (strpos($n, '净水') !== false || strpos($n, '过滤器') !== false || strpos($n, '管线机') !== false || strpos($n, '饮水机') !== false || strpos($n, '水质') !== false) return 'water_purifier';
|
||||
if (strpos($n, '晾衣架') !== false) return 'clothes_hanger';
|
||||
if (strpos($n, '木门') !== false || strpos($n, '室内门') !== false || strpos($n, '门套') !== false || strpos($n, '哑口') !== false || strpos($n, '推拉门') !== false || strpos($n, '折叠门') !== false) return 'wood_door';
|
||||
if (strpos($n, '防盗门') !== false || strpos($n, '入户门') !== false || strpos($n, '卷闸') !== false || strpos($n, '纱窗') !== false || strpos($n, '窗') !== false) return 'security_door';
|
||||
if (strpos($n, '洗衣机') !== false || strpos($n, '洗衣柜') !== false) return 'washing_machine';
|
||||
if (strpos($n, '空调') !== false) return 'air_conditioner';
|
||||
if (strpos($n, '冰箱') !== false || strpos($n, '冷柜') !== false) return 'refrigerator';
|
||||
if (strpos($n, '商用灶') !== false || strpos($n, '电磁炉') !== false) return 'commercial_stove';
|
||||
if (strpos($n, '排烟罩') !== false) return 'commercial_hood';
|
||||
if (strpos($n, '蒸饭') !== false || strpos($n, '洗碗机') !== false || strpos($n, '和面') !== false || strpos($n, '开水器') !== false) return 'commercial_steamer';
|
||||
if (strpos($n, '油烟机') !== false || strpos($n, '燃气灶') !== false) return 'kitchen_hood';
|
||||
if (strpos($n, '热水器') !== false || strpos($n, '浴霸') !== false) return 'water_heater';
|
||||
if (strpos($n, '电视') !== false) return 'tv_mounted';
|
||||
if (strpos($n, '投影') !== false) return 'projector';
|
||||
if (strpos($n, '跑步机') !== false) return 'treadmill';
|
||||
if (strpos($n, '单车') !== false || strpos($n, '椭圆机') !== false || strpos($n, '训练器') !== false || strpos($n, '力量') !== false || strpos($n, '健身') !== false) return 'exercise_bike';
|
||||
|
||||
// 根据分类兜底
|
||||
$catDefaults = [
|
||||
1 => 'sofa_leather',
|
||||
2 => 'toilet_smart',
|
||||
3 => 'ceiling_lamp',
|
||||
4 => 'smart_lock',
|
||||
5 => 'curtain_fabric',
|
||||
6 => 'wall_decor',
|
||||
7 => 'water_purifier',
|
||||
8 => 'clothes_hanger',
|
||||
9 => 'wood_door',
|
||||
10 => 'washing_machine',
|
||||
11 => 'tv_mounted',
|
||||
12 => 'shower_room',
|
||||
13 => 'commercial_stove',
|
||||
14 => 'treadmill',
|
||||
15 => 'mechanical_lock',
|
||||
];
|
||||
return $catDefaults[$catId] ?? 'sofa_leather';
|
||||
}
|
||||
|
||||
$updatedCount = 0;
|
||||
foreach ($services as $s) {
|
||||
$imgKey = matchImageKey($s['name'], $s['cat_id']);
|
||||
if (isset($cosMap[$imgKey])) {
|
||||
$imgUrl = $cosMap[$imgKey]['cos'];
|
||||
Db::name('service')->where('id', $s['id'])->update([
|
||||
'image' => $imgUrl,
|
||||
'updatetime' => time()
|
||||
]);
|
||||
$updatedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
echo "Successfully updated {$updatedCount} services with real goods image URLs!\n";
|
||||
在新工单中引用
屏蔽一个用户