作者 jinglong

增加后台服务订单管理

... ... @@ -29,7 +29,7 @@ class AdminCommon extends Backend
foreach ($expCellName as $k=>$v) {
$sheet->setCellValue($cellKey[$k].$topNumber, $v[1]);//设置表头数据
// $spreadsheet->getActiveSheet()->freezePane($cellKey[$k].($topNumber+1));//冻结窗口
$sheet->getStyle($cellKey[$k].$topNumber)->getFont()->setBold(true);//设置是否加粗
$sheet->getStyle($cellKey[$k].$topNumber)->getFont()->setBold(false);//设置是否加粗
}
//处理数据
//设置单元格居中显示
... ...
... ... @@ -239,7 +239,7 @@ class Free extends Backend
return;
}
$ids = explode(',',$ids);
$expTableData = Common::selectWhereData('free',['id'=>['in',$ids]],'id,user_name,mobile,province,city,district,address,advice,status,createtime');
$expTableData = Common::selectWhereData('free',['id'=>['in',$ids]],'id,user_name,mobile,province,city,district,address,advice,status,createtime','id asc');
$expCellName = [
['id','ID',5],
['user_name','姓名',10],
... ...
... ... @@ -54,7 +54,6 @@ class Order extends Backend
->order($sort, $order)
->limit($offset, $limit)
->select();
$list = collection($list)->toArray();
$result = array("total" => $total, "rows" => $list);
... ...
... ... @@ -178,7 +178,7 @@ class Registers extends Backend
$order_flag = 0;
}else{
//服务订单表
$this->model = new \app\admin\model\Order();
$this->model = new \app\admin\model\ServiceOrder();
$order_flag = 1;
}
$importHeadType = isset($this->importHeadType) ? $this->importHeadType : 'comment';
... ... @@ -213,21 +213,41 @@ class Registers extends Backend
}
if($order_flag == 0){
//套餐订单表
//根据手机号查询会员注册id
$res = Db::name('registers')->where('mobile',$values[7])->field('id')->find();
$row['r_id'] = $res['id'];
//判断是新增还是更新
$res1 = Db::name('order')->where(['order_sn'=>$row['order_sn']])->field('id')->find();
if($res1){
//更新
$row['id'] = $res1['id'];
}
//根据手机号查询会员注册id
$res = Db::name('registers')->where('mobile',$values[7])->field('id')->find();
if($res){
$row['r_id'] = $res['id'];
}else{
$row['r_id'] = 0;
}
}else{
//服务订单表
//判断是新增还是更新
$res1 = Db::name('service_order')->where(['order_sn'=>$row['order_sn']])->field('id')->find();
if($res1){
//更新
$row['id'] = $res1['id'];
}
//根据手机号查询会员注册id
$res = Db::name('registers')->where('mobile',$values[7])->field('id')->find();
if($res){
$row['r_id'] = $res['id'];
}else{
$row['r_id'] = 0;
}
}
if ($row) {
if(isset($row['price']) && !empty($row['price'])){
$insert[] = $row;
if($row['r_id'] != 0){
//如果订单金额为空,则视为该条数据为空
if(isset($row['order_sn']) && !empty($row['order_sn'])){
$insert[] = $row;
}
}
}
}
... ... @@ -275,7 +295,7 @@ class Registers extends Backend
return;
}
$ids = explode(',',$ids);
$expTableData = Common::selectWhereData('order',['r_id'=>['in',$ids]],'r_id,order_sn,price,content,total_num,use_num,not_use_num,advice,address,organization,pin_user,mark');
$expTableData = Common::selectWhereData('order',['r_id'=>['in',$ids]],'r_id,order_sn,price,content,total_num,use_num,not_use_num,advice,address,organization,pin_user,mark','id asc');
//查询手机号
$r_ids = array_unique(array_column($expTableData,'r_id'));
$res_mobile = Common::selectWhereData('registers',['id'=>['in',$r_ids]],'id,mobile');
... ...
<?php
namespace app\admin\controller;
use app\common\controller\Backend;
/**
* 服务订单管理
*
* @icon fa fa-circle-o
*/
class ServiceOrder extends Backend
{
/**
* ServiceOrder模型对象
* @var \app\admin\model\ServiceOrder
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\ServiceOrder;
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
public function order($ids)
{
//设置过滤方法
$this->request->filter(['strip_tags']);
if ($this->request->isAjax()) {
//如果发送的来源是Selectpage,则转发到Selectpage
if ($this->request->request('keyField')) {
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$total = $this->model
->where($where)
->where('r_id',$ids)
->order($sort, $order)
->count();
$list = $this->model
->where($where)
->where('r_id',$ids)
->order($sort, $order)
->limit($offset, $limit)
->select();
$list = collection($list)->toArray();
$result = array("total" => $total, "rows" => $list);
return json($result);
}
$this->assignconfig("r_id",$ids);
return $this->view->fetch();
}
}
... ...
<?php
return [
'Id' => 'ID',
'R_id' => '注册VIP人员id',
'Order_sn' => '服务订单编号',
'Customer_name' => '客户姓名',
'Service_time' => '服务时间',
'Service_content' => '服务项目',
'Service_name' => '服务员',
'Assess' => '评价',
'Mark' => '备注',
'Createtime' => '创建时间',
'Updatetime' => '更新时间'
];
... ...
<?php
namespace app\admin\model;
use think\Model;
class ServiceOrder extends Model
{
// 表名
protected $name = 'service_order';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = false;
// 追加属性
protected $append = [
'service_time_text'
];
public function getServiceTimeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['service_time']) ? $data['service_time'] : '');
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
}
protected function setServiceTimeAttr($value)
{
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
}
}
... ...
<?php
namespace app\admin\validate;
use think\Validate;
class ServiceOrder extends Validate
{
/**
* 验证规则
*/
protected $rule = [
];
/**
* 提示消息
*/
protected $message = [
];
/**
* 验证场景
*/
protected $scene = [
'add' => [],
'edit' => [],
];
}
... ...
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('R_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-r_id" data-rule="required" data-source="r/index" class="form-control selectpage" name="row[r_id]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Order_sn')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-order_sn" data-rule="required" class="form-control" name="row[order_sn]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Customer_name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-customer_name" data-rule="required" class="form-control" name="row[customer_name]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Service_time')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-service_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[service_time]" type="text" value="{:date('Y-m-d H:i:s')}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Service_content')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-service_content" data-rule="required" class="form-control" name="row[service_content]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Service_name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-service_name" data-rule="required" class="form-control" name="row[service_name]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Assess')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-assess" data-rule="required" class="form-control" name="row[assess]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Mark')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-mark" data-rule="required" class="form-control" name="row[mark]" type="text" value="">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('R_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-r_id" data-rule="required" data-source="r/index" class="form-control selectpage" name="row[r_id]" type="text" value="{$row.r_id|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Order_sn')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-order_sn" data-rule="required" class="form-control" name="row[order_sn]" type="text" value="{$row.order_sn|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Customer_name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-customer_name" data-rule="required" class="form-control" name="row[customer_name]" type="text" value="{$row.customer_name|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Service_time')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-service_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[service_time]" type="text" value="{:$row.service_time?datetime($row.service_time):''}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Service_content')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-service_content" data-rule="required" class="form-control" name="row[service_content]" type="text" value="{$row.service_content|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Service_name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-service_name" data-rule="required" class="form-control" name="row[service_name]" type="text" value="{$row.service_name|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Assess')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-assess" data-rule="required" class="form-control" name="row[assess]" type="text" value="{$row.assess|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Mark')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-mark" data-rule="required" class="form-control" name="row[mark]" type="text" value="{$row.mark|htmlentities}">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<div class="panel panel-default panel-intro">
{:build_heading()}
<div class="panel-body">
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="one">
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<!--<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('service_order/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>-->
<!--<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('service_order/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>-->
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('service_order/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<!--<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('service_order/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>-->
<!--<div class="dropdown btn-group {:$auth->check('service_order/multi')?'':'hide'}">-->
<!--<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>-->
<!--<ul class="dropdown-menu text-left" role="menu">-->
<!--<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>-->
<!--<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>-->
<!--</ul>-->
<!--</div>-->
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('service_order/edit')}"
data-operate-del="{:$auth->check('service_order/del')}"
width="100%">
</table>
</div>
</div>
</div>
</div>
</div>
... ...
... ... @@ -5,7 +5,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'order/index' + location.search,
index_url: 'order/order' + location.search,
add_url: 'order/add',
// edit_url: 'order/edit',
del_url: 'order/del',
... ...
... ... @@ -114,13 +114,21 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
}
},
{
name: 'offline',
text: '订单列表',
title: '订单列表',
name: 'order_list',
text: '套餐订单列表',
title: '套餐订单列表',
icon: 'fa fa-list',
classname: 'btn btn-xs btn-success btn-dialog',
url: "order/order"
},
{
name: 'service_list',
text: '服务订单列表',
title: '服务订单列表',
icon: 'fa fa-list',
classname: 'btn btn-xs btn-success btn-dialog',
url: "service_order/order"
},
]}
]
]
... ...
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
order: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'service_order/order' + location.search,
add_url: 'service_order/add',
// edit_url: 'service_order/edit',
del_url: 'service_order/del',
multi_url: 'service_order/multi',
table: 'service_order',
},
queryParams: function (params) { //自定义搜索条件
params.ids = Config.r_id;//将搜索过滤器和操作方法 都转为JSON字符串
return params;
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
showExport: false,//隐藏导出
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
// {field: 'r_id', title: __('R_id')},
{field: 'order_sn', title: __('Order_sn')},
{field: 'customer_name', title: __('Customer_name')},
{field: 'service_time', title: __('Service_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'service_content', title: __('Service_content')},
{field: 'service_name', title: __('Service_name')},
{field: 'assess', title: __('Assess')},
{field: 'mark', title: __('Mark')},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
// {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});
\ No newline at end of file
... ...