chore: 优化上传分类规则并新增分享功能
- 新增上传分类归一化处理,统一白名单校验规则 - 新增COS存储记录同步逻辑 - 新增分享功能支持,配置多页面分享参数 - 新增订单案例分享按钮 - 新增订单自动校验和回收命令 - 新增测试脚本和图片同步脚本 - 优化后台上传分类配置,统一分类映射
这个提交包含在:
@@ -134,11 +134,15 @@ class Order extends Base
|
||||
$catId = $service ? (int)$service['cat_id'] : 1;
|
||||
$serviceImage = $service ? $service['image'] : '';
|
||||
if (!empty($goodsList) && is_array($goodsList)) {
|
||||
$firstG = reset($goodsList);
|
||||
if (!empty($firstG['cat_id'])) {
|
||||
$catId = (int)$firstG['cat_id'];
|
||||
}
|
||||
$names = [];
|
||||
$totalCount = 0;
|
||||
$allImages = [];
|
||||
foreach ($goodsList as $idx => $g) {
|
||||
$gName = isset($g['item_name']) ? $g['item_name'] : (isset($g['name']) ? $g['name'] : '服务项');
|
||||
$gName = !empty($g['custom_name']) ? $g['custom_name'] : (isset($g['item_name']) ? $g['item_name'] : (isset($g['goods_name']) ? $g['goods_name'] : (isset($g['name']) ? $g['name'] : '服务项')));
|
||||
$gNum = isset($g['num']) ? (int)$g['num'] : 1;
|
||||
$names[] = $gName . 'x' . $gNum;
|
||||
$totalCount += $gNum;
|
||||
@@ -163,6 +167,27 @@ class Order extends Base
|
||||
'has_elevator' => (int)$address['has_elevator'],
|
||||
'urgent' => $urgent,
|
||||
], $couponId, $this->uid(), $priceType, $userPrice, $goodsList);
|
||||
if (empty($serviceImage) && !empty($goodsList)) {
|
||||
foreach ($goodsList as $item) {
|
||||
if (!empty($item['goods_image'])) {
|
||||
$serviceImage = $item['goods_image'];
|
||||
break;
|
||||
} elseif (!empty($item['images']) && is_array($item['images'])) {
|
||||
$serviceImage = reset($item['images']);
|
||||
break;
|
||||
} elseif (!empty($item['service_id'])) {
|
||||
$subSvc = Db::name('service')->where('id', (int)$item['service_id'])->find();
|
||||
if ($subSvc && !empty($subSvc['image'])) {
|
||||
$serviceImage = $subSvc['image'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (empty($serviceImage) && $service && !empty($service['image'])) {
|
||||
$serviceImage = $service['image'];
|
||||
}
|
||||
|
||||
$amount['price_type'] = $priceType;
|
||||
|
||||
$orderNo = $this->makeOrderNo();
|
||||
@@ -209,7 +234,7 @@ class Order extends Base
|
||||
'discount_amount' => $amount['discount_amount'],
|
||||
'total_amount' => $amount['total_amount'],
|
||||
'pay_amount' => $amount['pay_amount'],
|
||||
'status' => OrderStatus::PENDING_PAY,
|
||||
'status' => $priceType === 'quote' ? OrderStatus::QUOTING : OrderStatus::PENDING_PAY,
|
||||
'pay_status' => 0,
|
||||
'coupon_id' => $amount['coupon'] ? (int)$amount['coupon']['id'] : 0,
|
||||
'verify_code' => $verifyCode,
|
||||
@@ -225,21 +250,65 @@ class Order extends Base
|
||||
];
|
||||
if (!empty($goodsList) && is_array($goodsList)) {
|
||||
foreach ($goodsList as $g) {
|
||||
// 商品名称快照:优先读取自填名称 custom_name 或 item_name,确保非标自填不丢失
|
||||
$finalGoodsName = '';
|
||||
if (!empty($g['custom_name'])) {
|
||||
$finalGoodsName = trim((string)$g['custom_name']);
|
||||
} elseif (!empty($g['item_name'])) {
|
||||
$finalGoodsName = trim((string)$g['item_name']);
|
||||
} elseif (!empty($g['goods_name'])) {
|
||||
$finalGoodsName = trim((string)$g['goods_name']);
|
||||
} else {
|
||||
$finalGoodsName = (string)$serviceName;
|
||||
}
|
||||
|
||||
// 规格型号快照:优先读取 spec_name 或 goods_model
|
||||
$finalSpecModel = '';
|
||||
if (!empty($g['spec_name'])) {
|
||||
$finalSpecModel = trim((string)$g['spec_name']);
|
||||
} elseif (!empty($g['goods_model'])) {
|
||||
$finalSpecModel = trim((string)$g['goods_model']);
|
||||
} else {
|
||||
$finalSpecModel = (string)$goodsModel;
|
||||
}
|
||||
|
||||
// 商品实物图/现场图
|
||||
$finalImage = '';
|
||||
if (!empty($g['goods_image'])) {
|
||||
$finalImage = (string)$g['goods_image'];
|
||||
} elseif (!empty($g['images']) && is_array($g['images'])) {
|
||||
$finalImage = (string)reset($g['images']);
|
||||
}
|
||||
|
||||
// 增项服务快照
|
||||
$addonStr = '';
|
||||
if (!empty($g['addon_services'])) {
|
||||
$addonStr = is_array($g['addon_services']) ? json_encode($g['addon_services'], JSON_UNESCAPED_UNICODE) : (string)$g['addon_services'];
|
||||
} elseif (!empty($g['extras']) && is_array($g['extras'])) {
|
||||
$hitExtras = array_filter($g['extras'], function($ex) {
|
||||
return !empty($ex['num']) && (int)$ex['num'] > 0;
|
||||
});
|
||||
if (!empty($hitExtras)) {
|
||||
$addonStr = json_encode(array_values($hitExtras), JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
}
|
||||
|
||||
Db::name('order_goods')->insert([
|
||||
'order_id' => (int)$id,
|
||||
'service_id' => isset($g['service_id']) ? (int)$g['service_id'] : (int)$serviceId,
|
||||
'goods_name' => isset($g['goods_name']) ? (string)$g['goods_name'] : (string)$serviceName,
|
||||
'goods_model' => isset($g['goods_model']) ? (string)$g['goods_model'] : (string)$goodsModel,
|
||||
'goods_num' => isset($g['goods_num']) ? max(1, (int)$g['goods_num']) : 1,
|
||||
'goods_image' => isset($g['goods_image']) ? (string)$g['goods_image'] : '',
|
||||
'addon_services' => isset($g['addon_services']) ? (string)$g['addon_services'] : '',
|
||||
'goods_name' => mb_substr($finalGoodsName, 0, 100),
|
||||
'goods_model' => mb_substr($finalSpecModel, 0, 100),
|
||||
'goods_num' => isset($g['num']) ? max(1, (int)$g['num']) : (isset($g['goods_num']) ? max(1, (int)$g['goods_num']) : 1),
|
||||
'goods_image' => mb_substr($finalImage, 0, 255),
|
||||
'addon_services' => mb_substr($addonStr, 0, 255),
|
||||
'base_price' => isset($g['base_price']) ? (float)$g['base_price'] : (float)$amount['base_amount'],
|
||||
'createtime' => time(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->addLog($id, OrderStatus::PENDING_PAY, '用户下单(' . (isset($modeText[$priceType]) ? $modeText[$priceType] : '一口价') . ')', 'user', $this->uid());
|
||||
$initStatus = $priceType === 'quote' ? OrderStatus::QUOTING : OrderStatus::PENDING_PAY;
|
||||
$this->addLog($id, $initStatus, '用户下单(' . (isset($modeText[$priceType]) ? $modeText[$priceType] : '一口价') . ')', 'user', $this->uid());
|
||||
|
||||
$this->success('下单成功', [
|
||||
'order_id' => (int)$id,
|
||||
@@ -446,7 +515,7 @@ class Order extends Base
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$orderId = (int)$this->request->param('id');
|
||||
$orderId = (int)$this->request->param('id') ?: (int)$this->request->param('order_id');
|
||||
if ($orderId <= 0) {
|
||||
$this->error('订单参数错误');
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户