From 42a00f24f9cbb2bb70d11de5702ea36f3e916c16 Mon Sep 17 00:00:00 2001 From: devil Date: Mon, 8 Jun 2020 14:03:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=88=97=E8=A1=A8=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Goods.php | 4 +- application/admin/controller/Order.php | 94 +++------ application/admin/form/Goods.php | 34 ++-- application/admin/form/Order.php | 188 +++++++++++++----- .../admin/view/default/order/detail.html | 12 +- .../view/default/order/module/express.html | 5 - .../admin/view/default/order/module/info.html | 49 +++-- .../admin/view/default/order/module/take.html | 2 +- application/lang/zh-cn.php | 2 +- application/module/FormHandleModule.php | 29 +-- application/service/OrderService.php | 2 +- public/static/admin/default/css/order.css | 8 - 12 files changed, 247 insertions(+), 182 deletions(-) delete mode 100644 application/admin/view/default/order/module/express.html diff --git a/application/admin/controller/Goods.php b/application/admin/controller/Goods.php index 002b99b06..2e8866342 100755 --- a/application/admin/controller/Goods.php +++ b/application/admin/controller/Goods.php @@ -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); diff --git a/application/admin/controller/Order.php b/application/admin/controller/Order.php index 22ba34392..dd5cab985 100755 --- a/application/admin/controller/Order.php +++ b/application/admin/controller/Order.php @@ -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(); } diff --git a/application/admin/form/Goods.php b/application/admin/form/Goods.php index 1b478856b..79aed7e2f 100644 --- a/application/admin/form/Goods.php +++ b/application/admin/form/Goods.php @@ -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 diff --git a/application/admin/form/Order.php b/application/admin/form/Order.php index af3561a71..a61ed8147 100644 --- a/application/admin/form/Order.php +++ b/application/admin/form/Order.php @@ -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 diff --git a/application/admin/view/default/order/detail.html b/application/admin/view/default/order/detail.html index d47aad337..6313c007e 100644 --- a/application/admin/view/default/order/detail.html +++ b/application/admin/view/default/order/detail.html @@ -31,10 +31,10 @@
基础信息
{{foreach $data.items as $vs}} -
-
+
+ @@ -59,10 +59,10 @@ 编码:{{$vs.spec_coding}} {{/if}} + {{$vs.price}}x{{$vs.buy_number}} {{if $vs['returned_quantity'] gt 0 or $vs['refund_price'] gt 0}} - 已退 {{$vs.returned_quantity}} / {{$vs.refund_price}} + 已退 {{$vs.returned_quantity}} / {{$vs.refund_price}} {{/if}} - {{$vs.price}}x{{$vs.buy_number}}

@@ -115,7 +115,7 @@

{{if !empty($data['extraction_data']['images'])}}

- 取货码 + 取货码

{{/if}} {{else /}} diff --git a/application/admin/view/default/order/module/express.html b/application/admin/view/default/order/module/express.html deleted file mode 100644 index 946f316d9..000000000 --- a/application/admin/view/default/order/module/express.html +++ /dev/null @@ -1,5 +0,0 @@ - -{{if !empty($module_data) and !empty($module_data['express_name'])}} -

快递:{{$module_data.express_name}}

-

单号:{{$module_data.express_number}}

-{{/if}} \ No newline at end of file diff --git a/application/admin/view/default/order/module/info.html b/application/admin/view/default/order/module/info.html index 98487a86a..acfb77a64 100644 --- a/application/admin/view/default/order/module/info.html +++ b/application/admin/view/default/order/module/info.html @@ -1,26 +1,37 @@ {{if !empty($module_data) and !empty($module_data['items'])}} - {{foreach $module_data.items as $item}} -
- -
- - {{if !empty($item.spec_text)}} - {{$item.spec_text}} + {{foreach $module_data.items as $key=>$item}} + {{if $key eq 0}} +
+ +
+ + {{if !empty($item.spec_text)}} + {{$item.spec_text}} + {{/if}} + + {{$item.price}}x{{$item.buy_number}} + {{if $item['returned_quantity'] gt 0 or $item['refund_price'] gt 0}} + 已退 {{$item.returned_quantity}} / {{$item.refund_price}} {{/if}} - - {{$item.price}}x{{$item.buy_number}} - {{if $item['returned_quantity'] gt 0 or $item['refund_price'] gt 0}} - 已退 {{$item.returned_quantity}} / {{$item.refund_price}} - {{/if}} +
-
-
+
+ {{/if}} + {{php}}break;{{/php}} {{/foreach}}
{{$module_data.describe}}
+ {{if count($module_data.items) gt 1}} +
+ +
+ {{/if}} {{/if}} \ No newline at end of file diff --git a/application/admin/view/default/order/module/take.html b/application/admin/view/default/order/module/take.html index d6856e909..1e8092e4b 100644 --- a/application/admin/view/default/order/module/take.html +++ b/application/admin/view/default/order/module/take.html @@ -3,7 +3,7 @@

取货码: {{if empty($module_data['extraction_data']['code'])}} - 取货码不存在、请联系管理员 + {{else /}} {{$module_data.extraction_data.code}} {{/if}} diff --git a/application/lang/zh-cn.php b/application/lang/zh-cn.php index 4a0909393..0a79b0d4a 100755 --- a/application/lang/zh-cn.php +++ b/application/lang/zh-cn.php @@ -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' => '已取消'), diff --git a/application/module/FormHandleModule.php b/application/module/FormHandleModule.php index 14984980d..29b81fb24 100644 --- a/application/module/FormHandleModule.php +++ b/application/module/FormHandleModule.php @@ -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); } // 默认直接返回值 diff --git a/application/service/OrderService.php b/application/service/OrderService.php index 32b17b4ce..df7516917 100755 --- a/application/service/OrderService.php +++ b/application/service/OrderService.php @@ -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']); diff --git a/public/static/admin/default/css/order.css b/public/static/admin/default/css/order.css index f944f3528..8fc2f83fb 100755 --- a/public/static/admin/default/css/order.css +++ b/public/static/admin/default/css/order.css @@ -1,11 +1,3 @@ -/** - * 商品列表 - */ -.goods-images { width: 60px; height: 60px; float: left; margin-right: 5px; } -.goods-item, -.goods-item .base, -.goods-item .other { overflow: hidden; } - /** * 业务弹窗 */ -- GitLab