优化接口以及后台页面样式
This commit is contained in:
@@ -41,7 +41,18 @@ class MallAddress extends Model
|
||||
public function getregionTextAttr($value, $row): string
|
||||
{
|
||||
if ($row['region'] === '' || $row['region'] === null) return '';
|
||||
$cityNames = \support\think\Db::name('area')->whereIn('id', $row['region'])->column('name');
|
||||
$region = $row['region'];
|
||||
$ids = $region;
|
||||
if (!is_array($ids)) {
|
||||
$ids = explode(',', (string) $ids);
|
||||
}
|
||||
$ids = array_values(array_filter(array_map('trim', $ids), static function ($s) {
|
||||
return $s !== '';
|
||||
}));
|
||||
if (empty($ids)) {
|
||||
return '';
|
||||
}
|
||||
$cityNames = \support\think\Db::name('area')->whereIn('id', $ids)->column('name');
|
||||
return $cityNames ? implode(',', $cityNames) : '';
|
||||
}
|
||||
|
||||
@@ -49,4 +60,27 @@ class MallAddress extends Model
|
||||
{
|
||||
return $this->belongsTo(\app\common\model\MallUserAsset::class, 'playx_user_asset_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 实物订单收货快照(写入 mall_order.receiver_*,与 mall_address 当前内容一致)
|
||||
*
|
||||
* @return array{receiver_name: string, receiver_phone: string, receiver_address: string}
|
||||
*/
|
||||
public static function snapshotForPhysicalOrder(self $addr): array
|
||||
{
|
||||
$regionText = $addr->region_text ?? '';
|
||||
$parts = array_filter([
|
||||
trim($regionText),
|
||||
trim($addr->detail_address ?? ''),
|
||||
], static function ($s) {
|
||||
return $s !== '';
|
||||
});
|
||||
$receiverAddress = implode(' ', $parts);
|
||||
|
||||
return [
|
||||
'receiver_name' => trim($addr->receiver_name ?? ''),
|
||||
'receiver_phone' => trim($addr->phone ?? ''),
|
||||
'receiver_address' => $receiverAddress,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user