发货方式优化及消息功能优化
This commit is contained in:
@@ -438,6 +438,28 @@ class DemandService
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 规范化交付链接(只允许 1 个)
|
||||
* 支持数组或字符串,仅保留第一个 http(s) 开头的合法链接
|
||||
* @param array|string $links
|
||||
* @return array
|
||||
*/
|
||||
public static function normalizeDeliverLinks($links): array
|
||||
{
|
||||
if (is_string($links)) {
|
||||
$links = preg_split('/[,,\r\n]+/', $links) ?: [];
|
||||
}
|
||||
foreach ((array)$links as $item) {
|
||||
$url = is_array($item) ? trim($item['url'] ?? '') : trim((string)$item);
|
||||
if ($url && preg_match('/^https?:\/\//i', $url)) {
|
||||
//只保留第一个合法链接
|
||||
return [$url];
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* 开发者发货(交付开发成果)
|
||||
* 凭证截图、交付附件与备注写入订单发货表,尾款订单转为已发货(待收货)
|
||||
@@ -452,10 +474,13 @@ class DemandService
|
||||
$demandId = $requestData['demandId'] ?? 0;
|
||||
$images = array_values($requestData['images'] ?? []);
|
||||
$files = array_values($requestData['files'] ?? []);
|
||||
$links = self::normalizeDeliverLinks($requestData['links'] ?? '');
|
||||
$remark = trim($requestData['remark'] ?? '');
|
||||
Db::startTrans();
|
||||
if (!$images || !$files) {
|
||||
throw new \Exception('请上传开发完成的凭证截图和交付附件');
|
||||
//源码一般在企业微信沟通群直接交付(无大小限制),平台只登记发货状态,
|
||||
//故仅凭证截图必填,附件与交付链接均选填
|
||||
if (!$images) {
|
||||
throw new \Exception('请上传开发完成的凭证截图');
|
||||
}
|
||||
$demand = self::getOne(['id' => $demandId], ['winBidding']);
|
||||
if (!$demand) {
|
||||
@@ -477,7 +502,7 @@ class DemandService
|
||||
}
|
||||
//交付内容写入订单发货表
|
||||
$spuId = $finalOrder->orderGoods[0]->spu_id ?? 0;
|
||||
OrderShipService::createDemandDelivery($finalOrder->order_no, $spuId, $demandId, $images, $files, $remark);
|
||||
OrderShipService::createDemandDelivery($finalOrder->order_no, $spuId, $demandId, $images, $files, $remark, $links);
|
||||
//尾款订单改为已发货(待收货)
|
||||
$upRes = OrderService::where(['id' => $finalOrder->id])->update(['order_status' => OrderService::ORDER_STATUS_SHIPPED]);
|
||||
if (!$upRes) {
|
||||
|
||||
Reference in New Issue
Block a user