提交 42a00f24 编写于 作者: D devil

订单列表优化

上级 2e8825e8
......@@ -98,12 +98,12 @@ class Goods extends Common
];
// 获取列表
$data_params = array(
$data_params = [
'm' => 0,
'n' => 1,
'where' => $where,
'is_category' => 1,
);
];
$ret = GoodsService::GoodsList($data_params);
$data = (empty($ret['data']) || empty($ret['data'][0])) ? [] : $ret['data'][0];
$this->assign('data', $data);
......
......@@ -51,52 +51,28 @@ class Order extends Common
*/
public function Index()
{
// 参数
$params = input();
$params['user_type'] = 'admin';
// 分页
$number = MyC('admin_page_number', 10, true);
// 条件
$where = OrderService::OrderListWhere($params);
// 获取总数
$total = OrderService::OrderTotal($where);
// 总数
$total = OrderService::OrderTotal($this->form_where);
// 分页
$page_params = array(
'number' => $number,
'number' => $this->page_size,
'total' => $total,
'where' => $params,
'page' => isset($params['page']) ? intval($params['page']) : 1,
'where' => $this->data_request,
'page' => $this->page,
'url' => MyUrl('admin/order/index'),
);
$page = new \base\Page($page_params);
$this->assign('page_html', $page->GetPageHtml());
// 获取列表
$data_params = array(
'm' => $page->GetPageStarNumber(),
'n' => $number,
'where' => $where,
'n' => $this->page_size,
'where' => $this->form_where,
'is_public' => 0,
'user_type' => 'admin',
);
$data = OrderService::OrderList($data_params);
$this->assign('data_list', $data['data']);
// 状态
$this->assign('common_order_admin_status', lang('common_order_admin_status'));
// 支付状态
$this->assign('common_order_pay_status', lang('common_order_pay_status'));
// 订单模式
$this->assign('common_site_type_list', lang('common_site_type_list'));
// 快递公司
$this->assign('express_list', ExpressService::ExpressList());
$ret = OrderService::OrderList($data_params);
// 发起支付 - 支付方式
$pay_where = [
......@@ -104,17 +80,10 @@ class Order extends Common
];
$this->assign('buy_payment_list', PaymentService::BuyPaymentList($pay_where));
// 支付方式
$this->assign('payment_list', PaymentService::PaymentList());
// 评价状态
$this->assign('common_comments_status_list', lang('common_comments_status_list'));
// 平台
$this->assign('common_platform_type', lang('common_platform_type'));
// 参数
$this->assign('params', $params);
$this->assign('params', $this->data_request);
$this->assign('page_html', $page->GetPageHtml());
$this->assign('data_list', $ret['data']);
return $this->fetch();
}
......@@ -127,27 +96,26 @@ class Order extends Common
*/
public function Detail()
{
// 参数
$params = input();
$params['user_type'] = 'admin';
// 条件
$where = OrderService::OrderListWhere($params);
// 获取列表
$data_params = array(
'm' => 0,
'n' => 1,
'where' => $where,
'is_public' => 0,
'user_type' => 'admin',
);
$ret = OrderService::OrderList($data_params);
$data = (empty($ret['data']) || empty($ret['data'][0])) ? [] : $ret['data'][0];
$this->assign('data', $data);
// 参数
$this->assign('params', $params);
if(!empty($this->data_request['id']))
{
// 条件
$where = [
['is_delete_time', '=', 0],
['id', '=', intval($this->data_request['id'])],
];
// 获取列表
$data_params = [
'm' => 0,
'n' => 1,
'where' => $where,
'is_public' => 0,
'user_type' => 'admin',
];
$ret = OrderService::OrderList($data_params);
$data = (empty($ret['data']) || empty($ret['data'][0])) ? [] : $ret['data'][0];
$this->assign('data', $data);
}
return $this->fetch();
}
......
......@@ -16,7 +16,7 @@ use app\service\RegionService;
use app\service\BrandService;
/**
* 商品动态表
* 商品动态表
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
......@@ -164,12 +164,12 @@ class Goods
'view_type' => 'field',
'view_key' => 'category_text',
'search_config' => [
'form_type' => 'module',
'template' => 'lib/module/goods_category',
'form_name' => 'id',
'where_type' => 'in',
'where_custom' => 'WhereValueGoodsCategory',
'data' => GoodsService::GoodsCategoryAll(),
'form_type' => 'module',
'template' => 'lib/module/goods_category',
'form_name' => 'id',
'where_type' => 'in',
'where_handle_custom' => 'WhereValueGoodsCategory',
'data' => GoodsService::GoodsCategoryAll(),
],
],
[
......@@ -206,7 +206,14 @@ class Goods
'view_key' => 'add_time',
'search_config' => [
'form_type' => 'datetime',
'form_name' => 'add_time',
],
],
[
'label' => '更新时间',
'view_type' => 'field',
'view_key' => 'upd_time',
'search_config' => [
'form_type' => 'datetime',
],
],
[
......@@ -227,7 +234,7 @@ class Goods
* @version 1.0.0
* @date 2020-06-03
* @desc description
* @param [string] $name [字段名称]
* @param [array] $value [条件值]
* @param [array] $params [输入参数]
*/
public function WhereValueGoodsCategory($value, $params = [])
......@@ -241,14 +248,15 @@ class Goods
}
// 获取分类下的所有分类 id
$category_ids = GoodsService::GoodsCategoryItemsIds($value, 1);
$cids = GoodsService::GoodsCategoryItemsIds($value, 1);
// 获取商品 id
$goods_ids = Db::name('GoodsCategoryJoin')->where(['category_id'=>$category_ids])->column('goods_id');
$ids = Db::name('GoodsCategoryJoin')->where(['category_id'=>$cids])->column('goods_id');
// 避免空条件造成无效的错觉
return empty($goods_ids) ? [0] : $goods_ids;
return empty($ids) ? [0] : $ids;
}
return $value;
}
}
\ No newline at end of file
}
?>
\ No newline at end of file
......@@ -11,17 +11,15 @@
namespace app\admin\form;
use think\Db;
use app\service\GoodsService;
use app\service\RegionService;
use app\service\BrandService;
use app\service\PaymentService;
use app\service\ExpressService;
/**
* 订单动态表
* 订单动态表
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-05-16
* @date 2020-06-08
* @desc description
*/
class Order
......@@ -36,7 +34,7 @@ class Order
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-05-16
* @date 2020-06-08
* @desc description
* @param [array] $params [输入参数]
*/
......@@ -78,11 +76,12 @@ class Order
'view_key' => 'order/module/info',
'grid_size' => 'lg',
'search_config' => [
'form_type' => 'input',
'form_name' => 'id',
'where_type' => 'in',
'placeholder' => '请输入商品名称/型号',
'where_custom' => 'WhereValueBaseInfo',
'form_type' => 'input',
'form_name' => 'id',
'where_type' => 'like',
'where_type_custom' => 'in',
'where_handle_custom' => 'WhereValueBaseInfo',
'placeholder' => '请输入商品名称/型号',
],
],
[
......@@ -91,11 +90,12 @@ class Order
'view_key' => 'order/module/user',
'grid_size' => 'sm',
'search_config' => [
'form_type' => 'input',
'form_name' => 'user_id',
'where_type' => 'in',
'placeholder' => '请输入用户名/昵称/手机/邮箱',
'where_custom' => 'WhereValueUserInfo',
'form_type' => 'input',
'form_name' => 'user_id',
'where_type' => 'like',
'where_type_custom' => 'in',
'where_handle_custom' => 'WhereValueUserInfo',
'placeholder' => '请输入用户名/昵称/手机/邮箱',
],
],
[
......@@ -104,24 +104,24 @@ class Order
'view_key' => 'order/module/address',
'grid_size' => 'sm',
'search_config' => [
'form_type' => 'input',
'form_name' => 'user_id',
'where_type' => 'in',
'placeholder' => '请输入收件姓名/电话/地址',
'where_custom' => 'WhereValueAddressInfo',
'form_type' => 'input',
'form_name' => 'id',
'where_type' => 'like',
'where_type_custom' => 'in',
'where_handle_custom' => 'WhereValueAddressInfo',
],
],
[
'label' => '取货信息',
'view_type' => 'module',
'view_key' => 'order/module/take',
'width' => 120,
'width' => 125,
'search_config' => [
'form_type' => 'input',
'form_name' => 'id',
'where_type' => '=',
'placeholder' => '请输入取货码',
'where_custom' => 'WhereValueAddressInfo',
'form_type' => 'input',
'form_name' => 'id',
'where_type' => 'like',
'where_type_custom' => 'in',
'where_handle_custom' => 'WhereValueTakeInfo',
],
],
[
......@@ -164,7 +164,7 @@ class Order
'form_name' => 'order_model',
'where_type' => 'in',
'data' => lang('common_site_type_list'),
'data_key' => 'id',
'data_key' => 'value',
'data_name' => 'name',
'is_multiple' => 1,
],
......@@ -179,7 +179,7 @@ class Order
'form_name' => 'client_type',
'where_type' => 'in',
'data' => lang('common_platform_type'),
'data_key' => 'id',
'data_key' => 'value',
'data_name' => 'name',
'is_multiple' => 1,
],
......@@ -272,15 +272,26 @@ class Order
],
],
[
'label' => '快递信息',
'view_type' => 'module',
'view_key' => 'order/module/express',
'grid_size' => 'sm',
'label' => '快递公司',
'view_type' => 'field',
'view_key' => 'express_name',
'search_config' => [
'form_type' => 'select',
'form_name' => 'express_id',
'data' => ExpressService::ExpressList(),
'where_type' => 'in',
'data_key' => 'id',
'data_name' => 'name',
'is_multiple' => 1,
],
],
[
'label' => '快递单号',
'view_type' => 'field',
'view_key' => 'express_number',
'search_config' => [
'form_type' => 'input',
'form_name' => 'express_number',
'where_type' => 'like',
'placeholder' => '请输入快递单号',
],
],
[
......@@ -289,6 +300,22 @@ class Order
'view_key' => 'order/module/aftersale',
'grid_size' => 'sm',
],
[
'label' => '创建时间',
'view_type' => 'field',
'view_key' => 'add_time',
'search_config' => [
'form_type' => 'datetime',
],
],
[
'label' => '更新时间',
'view_type' => 'field',
'view_key' => 'upd_time',
'search_config' => [
'form_type' => 'datetime',
],
],
[
'label' => '操作',
'view_type' => 'operate',
......@@ -301,34 +328,95 @@ class Order
}
/**
* 商品分类条件处理
* 取货码条件处理
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-06-08
* @desc description
* @param [string] $value [条件值]
* @param [array] $params [输入参数]
*/
public function WhereValueTakeInfo($value, $params = [])
{
if(!empty($value))
{
// 获取订单 id
$ids = Db::name('OrderExtractionCode')->where('code', '=', $value)->column('order_id');
// 避免空条件造成无效的错觉
return empty($ids) ? [0] : $ids;
}
return $value;
}
/**
* 收件地址条件处理
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-06-08
* @desc description
* @param [string] $value [条件值]
* @param [array] $params [输入参数]
*/
public function WhereValueAddressInfo($value, $params = [])
{
if(!empty($value))
{
// 获取订单 id
$ids = Db::name('OrderAddress')->where('name|tel|address', 'like', '%'.$value.'%')->column('order_id');
// 避免空条件造成无效的错觉
return empty($ids) ? [0] : $ids;
}
return $value;
}
/**
* 用户信息条件处理
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-06-03
* @date 2020-06-08
* @desc description
* @param [string] $name [字段名称]
* @param [string] $value [条件值]
* @param [array] $params [输入参数]
*/
public function WhereValueGoodsCategory($value, $params = [])
public function WhereValueUserInfo($value, $params = [])
{
if(!empty($value))
{
// 是否为数组
if(!is_array($value))
{
$value = [$value];
}
// 获取用户 id
$ids = Db::name('User')->where('username|nickname|mobile|email', 'like', '%'.$value.'%')->column('id');
// 获取分类下的所有分类 id
$category_ids = GoodsService::GoodsCategoryItemsIds($value, 1);
// 避免空条件造成无效的错觉
return empty($ids) ? [0] : $ids;
}
return $value;
}
// 获取商品 id
$goods_ids = Db::name('GoodsCategoryJoin')->where(['category_id'=>$category_ids])->column('goods_id');
/**
* 基础信息条件处理
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-06-08
* @desc description
* @param [string] $value [条件值]
* @param [array] $params [输入参数]
*/
public function WhereValueBaseInfo($value, $params = [])
{
if(!empty($value))
{
// 获取订单详情搜索的订单 id
$ids = Db::name('OrderDetail')->where('title|model', 'like', '%'.$value.'%')->column('order_id');
// 避免空条件造成无效的错觉
return empty($goods_ids) ? [0] : $goods_ids;
return empty($ids) ? [0] : $ids;
}
return $value;
}
}
\ No newline at end of file
}
?>
\ No newline at end of file
......@@ -31,10 +31,10 @@
<dt>基础信息</dt>
<dd>
{{foreach $data.items as $vs}}
<div class="goods-item">
<div class="base">
<div class="am-nbfc am-padding-vertical-xs">
<div class="base am-nbfc">
<a href="{{:MyUrl('index/goods/index', ['id'=>$vs['goods_id']])}}" target="_blank" title="{{$vs.title}}">
<img src="{{$vs['images']}}" class="am-img-thumbnail am-radius goods-images" />
<img src="{{$vs['images']}}" class="am-img-thumbnail am-radius am-margin-right-xs am-fl" width="60" height="60" />
</a>
<a href="{{:MyUrl('index/goods/index', ['id'=>$vs['goods_id']])}}" target="_blank" title="{{$vs.title}}" {{if !empty($vs['title_color'])}} style="color:{{$vs.title_color}};" {{/if}} class="am-nowrap-initial">{{$vs.title}}</a>
</div>
......@@ -59,10 +59,10 @@
编码:{{$vs.spec_coding}}
</span>
{{/if}}
<span class="am-fr">{{$vs.price}}x{{$vs.buy_number}}</span>
{{if $vs['returned_quantity'] gt 0 or $vs['refund_price'] gt 0}}
<span class="am-text-danger am-fr am-margin-left-sm">已退 {{$vs.returned_quantity}} / {{$vs.refund_price}}</span>
<span class="am-text-danger am-fr am-margin-right-lg">已退 {{$vs.returned_quantity}} / {{$vs.refund_price}}</span>
{{/if}}
<span class="am-fr">{{$vs.price}}x{{$vs.buy_number}}</span>
</div>
<hr data-am-widget="divider" class="am-divider am-divider-dashed am-margin-vertical-0" />
</div>
......@@ -115,7 +115,7 @@
</p>
{{if !empty($data['extraction_data']['images'])}}
<p class="am-margin-top-xs">
<img class="am-img-thumbnail" src="{{$data.extraction_data.images}}" alt="取货码" />
<img class="am-img-thumbnail" src="{{$data.extraction_data.images}}" alt="取货码" width="150" height="150" />
</p>
{{/if}}
{{else /}}
......
<!-- 快递信息 -->
{{if !empty($module_data) and !empty($module_data['express_name'])}}
<p>快递:{{$module_data.express_name}}</p>
<p>单号:{{$module_data.express_number}}</p>
{{/if}}
\ No newline at end of file
<!-- 订单基础信息 -->
{{if !empty($module_data) and !empty($module_data['items'])}}
{{foreach $module_data.items as $item}}
<div class="am-nbfc am-padding-vertical-xs">
<div class="base am-nbfc">
<a href="{{:MyUrl('index/goods/index', ['id'=>$item['goods_id']])}}" target="_blank" title="{{$item.title}}">
<img src="{{$item['images']}}" class="am-img-thumbnail am-radius am-margin-right-xs am-fl" width="60" height="60" />
</a>
<a href="{{:MyUrl('index/goods/index', ['id'=>$item['goods_id']])}}" target="_blank" title="{{$item.title}}" {{if !empty($item['title_color'])}} style="color:{{$item.title_color}};" {{/if}} class="am-nowrap-initial">{{$item.title}}</a>
</div>
<div class="other am-nbfc">
<span class="am-fl am-text-xs am-nowrap-initial">
{{if !empty($item.spec_text)}}
{{$item.spec_text}}
{{foreach $module_data.items as $key=>$item}}
{{if $key eq 0}}
<div class="am-nbfc am-padding-vertical-xs">
<div class="base am-nbfc">
<a href="{{:MyUrl('index/goods/index', ['id'=>$item['goods_id']])}}" target="_blank" title="{{$item.title}}">
<img src="{{$item['images']}}" class="am-img-thumbnail am-radius am-margin-right-xs am-fl" width="60" height="60" />
</a>
<a href="{{:MyUrl('index/goods/index', ['id'=>$item['goods_id']])}}" target="_blank" title="{{$item.title}}" {{if !empty($item['title_color'])}} style="color:{{$item.title_color}};" {{/if}} class="am-nowrap-initial">{{$item.title}}</a>
</div>
<div class="other am-nbfc">
<span class="am-fl am-text-xs am-nowrap-initial">
{{if !empty($item.spec_text)}}
{{$item.spec_text}}
{{/if}}
</span>
<span class="am-fr">{{$item.price}}x{{$item.buy_number}}</span>
{{if $item['returned_quantity'] gt 0 or $item['refund_price'] gt 0}}
<span class="am-text-danger am-fr am-margin-right-lg">已退 {{$item.returned_quantity}} / {{$item.refund_price}}</span>
{{/if}}
</span>
<span class="am-fr">{{$item.price}}x{{$item.buy_number}}</span>
{{if $item['returned_quantity'] gt 0 or $item['refund_price'] gt 0}}
<span class="am-text-danger am-fr am-margin-right-lg">已退 {{$item.returned_quantity}} / {{$item.refund_price}}</span>
{{/if}}
</div>
</div>
</div>
<hr data-am-widget="divider" class="am-divider am-divider-dashed am-margin-vertical-0" />
<hr data-am-widget="divider" class="am-divider am-divider-dashed am-margin-vertical-0" />
{{/if}}
{{php}}break;{{/php}}
{{/foreach}}
<div class="am-margin-top-sm">{{$module_data.describe}}</div>
{{if count($module_data.items) gt 1}}
<div class="am-text-center">
<button type="button" class="am-btn am-btn-link am-btn-xs am-radius submit-popup" data-url="{{:MyUrl('admin/order/detail', ['id'=>$module_data['id']])}}">
<i class="am-icon-caret-down"></i>
<span>查看更多</span>
</button>
</div>
{{/if}}
{{/if}}
\ No newline at end of file
......@@ -3,7 +3,7 @@
<p>
<span>取货码:</span>
{{if empty($module_data['extraction_data']['code'])}}
<span class="am-text-danger">取货码不存在、请联系管理员</span>
<span class="am-text-danger"></span>
{{else /}}
<span class="am-badge am-badge-success am-radius">{{$module_data.extraction_data.code}}</span>
{{/if}}
......
......@@ -102,7 +102,7 @@ return array(
'common_order_admin_status' => array(
0 => array('id' => 0, 'name' => '待确认', 'checked' => true),
1 => array('id' => 1, 'name' => '已确认/待支付'),
2 => array('id' => 2, 'name' => '已支付/待发货/待取货'),
2 => array('id' => 2, 'name' => '待发货/待取货'),
3 => array('id' => 3, 'name' => '已发货/待收货'),
4 => array('id' => 4, 'name' => '已完成'),
5 => array('id' => 5, 'name' => '已取消'),
......
......@@ -248,8 +248,11 @@ class FormHandleModule
$name = $v['search_config']['form_name'];
// 条件类型
$type = isset($v['search_config']['where_type']) ? $v['search_config']['where_type'] : $v['search_config']['form_type'];
// 是否自定义条件类型
$type_custom = isset($v['search_config']['where_type_custom']) ? $v['search_config']['where_type_custom'] : $type;
// 是否自定义条件处理方法
$custom = isset($v['search_config']['where_custom']) ? $v['search_config']['where_custom'] : '';
$handle_custom = isset($v['search_config']['where_handle_custom']) ? $v['search_config']['where_handle_custom'] : '';
// 根据条件类型处理
switch($type)
{
......@@ -267,16 +270,16 @@ class FormHandleModule
$this->where_params[$form_key] = $value;
// 条件值处理
$value = $this->WhereValueHandle($value, $custom);
$value = $this->WhereValueHandle($value, $handle_custom);
// 是否 like 条件
if($type == 'like')
if($type == 'like' && is_string($value))
{
$value = '%'.$value.'%';
}
// 条件
$this->where[] = [$name, $type, $value];
$this->where[] = [$name, $type_custom, $value];
}
break;
......@@ -293,7 +296,7 @@ class FormHandleModule
$this->where_params[$form_key] = $value;
// 条件
$this->where[] = [$name, $type, $this->WhereValueHandle($value, $custom)];
$this->where[] = [$name, $type_custom, $this->WhereValueHandle($value, $handle_custom)];
}
break;
......@@ -308,7 +311,7 @@ class FormHandleModule
$this->where_params[$key_min] = $value;
// 条件
$this->where[] = [$name, '>=', $this->WhereValueHandle($value, $custom, ['is_min'=>1])];
$this->where[] = [$name, '>=', $this->WhereValueHandle($value, $handle_custom, ['is_min'=>1])];
}
if(array_key_exists($key_max, $this->out_params) && $this->out_params[$key_max] !== null && $this->out_params[$key_max] !== '')
{
......@@ -317,7 +320,7 @@ class FormHandleModule
$this->where_params[$key_max] = $value;
// 条件
$this->where[] = [$name, '<=', $this->WhereValueHandle($value, $custom, ['is_end'=>1])];
$this->where[] = [$name, '<=', $this->WhereValueHandle($value, $handle_custom, ['is_end'=>1])];
}
break;
......@@ -333,7 +336,7 @@ class FormHandleModule
$this->where_params[$key_start] = $value;
// 条件
$this->where[] = [$name, '>=', $this->WhereValueHandle(strtotime($value), $custom, ['is_start'=>1])];
$this->where[] = [$name, '>=', $this->WhereValueHandle(strtotime($value), $handle_custom, ['is_start'=>1])];
}
if(array_key_exists($key_end, $this->out_params) && $this->out_params[$key_end] !== null && $this->out_params[$key_end] !== '')
{
......@@ -342,7 +345,7 @@ class FormHandleModule
$this->where_params[$key_end] = $value;
// 条件
$this->where[] = [$name, '<=', $this->WhereValueHandle(strtotime($value), $custom, ['is_end'=>1])];
$this->where[] = [$name, '<=', $this->WhereValueHandle(strtotime($value), $handle_custom, ['is_end'=>1])];
}
break;
......@@ -434,15 +437,15 @@ class FormHandleModule
* @date 2020-06-04
* @desc description
* @param [mixed] $value [条件值]
* @param [mixed] $custom [自定义处理方法名称]
* @param [string] $action [自定义处理方法名称]
* @param [array] $params [输入参数]
*/
function WhereValueHandle($value, $custom = '', $params = [])
function WhereValueHandle($value, $action = '', $params = [])
{
// 模块是否自定义方法处理条件
if(!empty($custom) && method_exists($this->module_obj, $custom))
if(!empty($action) && method_exists($this->module_obj, $action))
{
return $this->module_obj->$custom($value, $params);
return $this->module_obj->$action($value, $params);
}
// 默认直接返回值
......
......@@ -853,7 +853,7 @@ class OrderService
$v['add_time'] = date('Y-m-d H:i:s', $v['add_time']);
// 更新时间
$v['upd_time'] = date('Y-m-d H:i:s', $v['upd_time']);
$v['upd_time'] = empty($v['upd_time']) ? null : date('Y-m-d H:i:s', $v['upd_time']);
// 确认时间
$v['confirm_time'] = empty($v['confirm_time']) ? null : date('Y-m-d H:i:s', $v['confirm_time']);
......
/**
* 商品列表
*/
.goods-images { width: 60px; height: 60px; float: left; margin-right: 5px; }
.goods-item,
.goods-item .base,
.goods-item .other { overflow: hidden; }
/**
* 业务弹窗
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册