退货地址支持根据订单所属仓库自动匹配仓库地址

This commit is contained in:
Devil 2021-07-08 19:10:26 +08:00
parent f72995bc94
commit f0ebb397ab
7 changed files with 77 additions and 4 deletions

View File

@ -24,6 +24,15 @@
<input type="text" name="{{$data.home_order_aftersale_return_goods_address.only_tag}}" placeholder="{{$data.home_order_aftersale_return_goods_address.name}}" data-validation-message="{{$data.home_order_aftersale_return_goods_address.error_tips}}" class="am-radius" {{if !empty($data)}}value="{{$data.home_order_aftersale_return_goods_address.value}}"{{/if}} />
</div>
<div class="am-form-group">
<label>{{$data.home_order_aftersale_is_use_warehouse_address.name}}<span class="am-form-group-label-tips">{{$data.home_order_aftersale_is_use_warehouse_address.describe}}</span></label>
<select name="{{$data.home_order_aftersale_is_use_warehouse_address.only_tag}}" class="am-radius chosen-select" data-validation-message="{{$data.home_order_aftersale_is_use_warehouse_address.error_tips}}" required>
{{foreach $common_is_text_list as $v}}
<option value="{{$v.id}}" {{if isset($data['home_order_aftersale_is_use_warehouse_address']['value']) and $data['home_order_aftersale_is_use_warehouse_address']['value'] eq $v['id']}}selected{{/if}}>{{$v.name}}</option>
{{/foreach}}
</select>
</div>
<div class="am-form-group">
<label>{{$data.home_order_aftersale_return_launch_day.name}}<span class="am-form-group-label-tips">{{$data.home_order_aftersale_return_launch_day.describe}}</span></label>
<div class="am-input-group am-input-group-sm">

View File

@ -129,6 +129,9 @@ class Orderaftersale extends Common
// 退款退货原因
$return_money_goods_reason = MyC('home_order_aftersale_return_money_goods_reason');
// 退货地址
$return_goods_address = OrderAftersaleService::OrderAftersaleReturnGoodsAddress($new_aftersale_data['order_id']);
// 返回数据
$result = [
'order_data' => $ret['data'],
@ -138,7 +141,7 @@ class Orderaftersale extends Common
'return_only_money_reason' => empty($return_only_money_reason) ? [] : explode("\n", $return_only_money_reason),
'return_money_goods_reason' => empty($return_money_goods_reason) ? [] : explode("\n", $return_money_goods_reason),
'aftersale_type_list' => lang('common_order_aftersale_type_list'),
'return_goods_address' => MyC('home_order_aftersale_return_goods_address', '管理员未填写', true),
'return_goods_address' => $return_goods_address,
'editor_path_type' => ResourcesService::EditorPathTypeValue(OrderAftersaleService::EditorAttachmentPathType($this->user['id'], $order_id, $order_detail_id)),
];
return SystemBaseService::DataReturn($result);

View File

@ -135,12 +135,19 @@ class Orderaftersale extends Common
$returned = OrderAftersaleService::OrderAftersaleCalculation($order_id, $order_detail_id);
$this->assign('returned_data', $returned['data']);
// 退货地址
$return_goods_address = OrderAftersaleService::OrderAftersaleReturnGoodsAddress($order_id);
$this->assign('return_goods_address', $return_goods_address);
// 静态数据
$this->assign('common_order_aftersale_type_list', lang('common_order_aftersale_type_list'));
// 编辑器文件存放地址
$this->assign('editor_path_type', ResourcesService::EditorPathTypeValue(OrderAftersaleService::EditorAttachmentPathType($this->user['id'], $order_id, $order_detail_id)));
// 浏览器名称
$this->assign('home_seo_site_title', SeoService::BrowserSeoTitle('订单售后详情', 1));
// 订单售后搜索form key
$this->assign('form_search_keywords_form_key', 'f0p');
$this->assign('params', $this->data_request);

View File

@ -7,7 +7,7 @@
<div class="am-popup-bd">
<div class="am-alert">
<span>退货地址:</span>
<span class="am-text-warning">{{:MyC('home_order_aftersale_return_goods_address', '管理员未填写', true)}}</span>
<span class="am-text-warning">{{$return_goods_address}}</span>
</div>
<form class="am-form form-validation view-save" action="{{:MyUrl('index/orderaftersale/delivery')}}" method="POST" request-type="ajax-reload">
<div class="am-form-group">

View File

@ -266,7 +266,7 @@
</div>
<div class="am-alert am-alert-warning">
<span>退货地址:</span>
<span class="am-text-primary">{{:MyC('home_order_aftersale_return_goods_address', '管理员未填写', true)}}</span>
<span class="am-text-primary">{{$return_goods_address}}</span>
</div>
{{include file="orderaftersale/delivery" /}}
{{else /}}

View File

@ -18,6 +18,7 @@ use app\service\RefundLogService;
use app\service\OrderService;
use app\service\MessageService;
use app\service\IntegralService;
use app\service\WarehouseService;
use app\plugins\wallet\service\WalletService;
/**
@ -1616,5 +1617,58 @@ class OrderAftersaleService
{
return 'order_aftersale-'.intval($user_id%(3*24)/24).'-'.$order_id.'-'.$order_detail_id;
}
/**
* 商品退货地址
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-07-08
* @desc description
* @param [int] $order_id [订单id]
*/
public static function OrderAftersaleReturnGoodsAddress($order_id)
{
// 退货地址信息
$data = MyC('home_order_aftersale_return_goods_address', '管理员未填写', true);
// 是否是否仓库地址
if(MyC('home_order_aftersale_is_use_warehouse_address', 0, true) == 1)
{
// 获取订单所属仓库id
$warehouse_id = Db::name('Order')->where(['id'=>intval($order_id)])->value('warehouse_id');
if(!empty($warehouse_id))
{
// 获取仓库信息
$where = [
['id', '=', $warehouse_id],
];
$data_params = [
'm' => 0,
'n' => 1,
'where' => $where,
];
$ret = WarehouseService::WarehouseList($data_params);
$warehouse = (empty($ret['data']) || empty($ret['data'][0])) ? [] : $ret['data'][0];
if(!empty($warehouse) && !empty($warehouse['contacts_name']) && !empty($warehouse['contacts_tel']) && !empty($warehouse['province_name']) && !empty($warehouse['city_name']) && !empty($warehouse['county_name']) && !empty($warehouse['address']))
{
$address = $warehouse['province_name'].$warehouse['city_name'].$warehouse['county_name'].$warehouse['address'];
$data = '收件人:'.$warehouse['contacts_name'].',电话:'.$warehouse['contacts_tel'].',地址:'.$address;
}
}
}
// 订单售后退货地址钩子
$hook_name = 'plugins_service_order_aftersale_return_address';
Hook::listen($hook_name, [
'hook_name' => $hook_name,
'is_backend' => true,
'order_id' => $order_id,
'data' => &$data,
]);
// 返回退货地址信息
return $data;
}
}
?>

View File

@ -64,7 +64,7 @@ class WarehouseService
// 基础数据
$data_key_field = empty($params['data_key_field']) ? 'id' : $params['data_key_field'];
// 获取商品信息
// 省市区
if(in_array('province', $keys) && in_array('city', $keys) && in_array('county', $keys))
{
// 地区数据