作者 潘浩文
1 个管道 的构建 通过 耗费 6 秒

XIAOPAN

@@ -29,8 +29,19 @@ use think\Db; @@ -29,8 +29,19 @@ use think\Db;
29 class AdminCostController extends AdminBaseController{ 29 class AdminCostController extends AdminBaseController{
30 30
31 public function index(){ 31 public function index(){
32 - $cost=Db::name('cost')->where('id',1)->find();  
33 - $interval = Db::name('interval')->where('id',1)->find(); 32 + $data=Db::name('cost')
  33 + ->alias('c')
  34 + ->join('interval i','c.hospital=i.hospital')
  35 + ->select();
  36 + $this->assign('list',$data);
  37 + return $this->fetch();
  38 + }
  39 +
  40 +
  41 + public function edit(){
  42 + $param=$this->request->param();
  43 + $cost=Db::name('cost')->where('id',$param['id'])->find();
  44 + $interval = Db::name('interval')->where('id',$param['id'])->find();
34 $this->assign('cost',$cost); 45 $this->assign('cost',$cost);
35 $this->assign('interval',$interval); 46 $this->assign('interval',$interval);
36 return $this->fetch(); 47 return $this->fetch();
@@ -57,8 +68,8 @@ class AdminCostController extends AdminBaseController{ @@ -57,8 +68,8 @@ class AdminCostController extends AdminBaseController{
57 ]; 68 ];
58 try{ 69 try{
59 Db::startTrans(); 70 Db::startTrans();
60 - Db::name('cost')->where('id',1)->update($cost);  
61 - Db::name('interval')->where('id',1)->update($interval); 71 + Db::name('cost')->where('id',$param['id'])->update($cost);
  72 + Db::name('interval')->where('id',$param['id'])->update($interval);
62 }catch (\Exception $exception){ 73 }catch (\Exception $exception){
63 Db::rollback(); 74 Db::rollback();
64 $this->error('保存失败'); 75 $this->error('保存失败');
@@ -499,12 +499,13 @@ class OrderController extends HomeBaseController{ @@ -499,12 +499,13 @@ class OrderController extends HomeBaseController{
499 * @param $users_id 499 * @param $users_id
500 * @param $start_time 500 * @param $start_time
501 * @param $end_time 501 * @param $end_time
  502 + * @param $hospital
502 * @return float|int|mixed 503 * @return float|int|mixed
503 * @throws \think\db\exception\DataNotFoundException 504 * @throws \think\db\exception\DataNotFoundException
504 * @throws \think\db\exception\ModelNotFoundException 505 * @throws \think\db\exception\ModelNotFoundException
505 * @throws \think\exception\DbException 506 * @throws \think\exception\DbException
506 */ 507 */
507 - public function onlyGetPrice($users_id,$start_time,$end_time){ 508 + public function onlyGetPrice($users_id,$start_time,$end_time,$hospital){
508 /*先获取跨越天数*/ 509 /*先获取跨越天数*/
509 // $users_id='11'; 510 // $users_id='11';
510 // $data=input(); 511 // $data=input();
@@ -514,8 +515,8 @@ class OrderController extends HomeBaseController{ @@ -514,8 +515,8 @@ class OrderController extends HomeBaseController{
514 if ($spend['min']!=0||$spend['sec']!=0){ 515 if ($spend['min']!=0||$spend['sec']!=0){
515 $spend['hour']++; 516 $spend['hour']++;
516 } 517 }
517 - $interval = Db::name('interval')->where('id',1)->find();  
518 - $cost=Db::name('cost')->where('id',1)->find(); 518 + $interval = Db::name('interval')->where('hospital',$hospital)->find();
  519 + $cost=Db::name('cost')->where('hospital',$hospital)->find();
519 $is_free=Db::name('users')->where('id',$users_id)->find()['is_free']; 520 $is_free=Db::name('users')->where('id',$users_id)->find()['is_free'];
520 $price=0; 521 $price=0;
521 $time=$start_time; 522 $time=$start_time;
@@ -234,7 +234,7 @@ class UsersController extends HomeBaseController{ @@ -234,7 +234,7 @@ class UsersController extends HomeBaseController{
234 $order= Db::name('order') 234 $order= Db::name('order')
235 ->alias('o') 235 ->alias('o')
236 ->join('equipment e','o.eq_name=e.name') 236 ->join('equipment e','o.eq_name=e.name')
237 - ->field('o.order_no,o.users_id,o.start_time,e.serial_number') 237 + ->field('o.order_no,o.users_id,o.start_time,e.serial_number,e.hospital')
238 ->where(['o.users_id'=>$users_id,'o.state'=>1,'o.type'=>1,'e.is_delete'=>0]) 238 ->where(['o.users_id'=>$users_id,'o.state'=>1,'o.type'=>1,'e.is_delete'=>0])
239 ->find(); 239 ->find();
240 if (empty($order)){ 240 if (empty($order)){
@@ -243,7 +243,7 @@ class UsersController extends HomeBaseController{ @@ -243,7 +243,7 @@ class UsersController extends HomeBaseController{
243 $order['end_time']=time(); 243 $order['end_time']=time();
244 $order['time']=ceil(($order['end_time']-$order['start_time'])/3600); 244 $order['time']=ceil(($order['end_time']-$order['start_time'])/3600);
245 $price=new OrderController(); 245 $price=new OrderController();
246 - $order['price']=$price->onlyGetPrice($users_id,$order['start_time'],$order['end_time']); 246 + $order['price']=$price->onlyGetPrice($users_id,$order['start_time'],$order['end_time'],$order['hospital']);
247 $time_info=$this->getTimeInfo($order['start_time'],$order['end_time']); 247 $time_info=$this->getTimeInfo($order['start_time'],$order['end_time']);
248 $order=array_merge($order,$time_info); 248 $order=array_merge($order,$time_info);
249 $this->apiResponse(200,'success',$order); 249 $this->apiResponse(200,'success',$order);
  1 +<include file="public@header"/>
  2 +<style type="text/css">
  3 + .pic-list li {
  4 + margin-bottom: 5px;
  5 + }
  6 +</style>
  7 +</head>
  8 +<body>
  9 +<div class="wrap js-check-wrap">
  10 + <ul class="nav nav-tabs">
  11 + <li><a href="{:url('AdminCost/index')}">费用管理</a></li>
  12 + <li class="active"><a>费用编辑</a></li>
  13 + </ul>
  14 + <!--js-ajax-form margin-top-20-->
  15 + <form action="{:url('AdminCost/editPost')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
  16 + <div class="row">
  17 + <div class="col-md-3">
  18 + <table class="table table-bordered">
  19 + <tr>
  20 + <td>
  21 + 医院名称<input style="width: 10rem" type="text" name="hospital" value="{$cost.hospital}">
  22 + </td>
  23 + </tr>
  24 + <tr>
  25 + <th>免费设置</th>
  26 + </tr>
  27 + <tr>
  28 + <td>
  29 + <input type="checkbox" name="free" value="1" <if condition="$cost.free eq 1">checked</if>>第一小时免费</label><br/>
  30 + </td>
  31 + </tr>
  32 + <tr>
  33 + <th>每小时费用</th>
  34 + </tr>
  35 + <tr>
  36 + <td>
  37 + 每小时费用<input style="width: 5rem" type="number" name="cost" value="{$cost.cost}">
  38 + </td>
  39 + </tr>
  40 + <tr>
  41 + <th>费用上限</th>
  42 + </tr>
  43 + <tr>
  44 + <td>
  45 + 每天费用上限<input style="width: 5rem" type="number" name="ceiling" value="{$cost.ceiling}">
  46 + </td>
  47 + </tr>
  48 + </table>
  49 + </div>
  50 + <div class="col-md-9">
  51 + <table class="table table-bordered">
  52 + <thead>
  53 + <tr>
  54 + <th colspan="6">固定收费时间段设置</th>
  55 + </tr>
  56 + </thead>
  57 + <tbody>
  58 + <tr>
  59 + <th>开始时间</th>
  60 + <td><input class="form-control" type="time" name="start_time" value="{$interval.start_time}"></td>
  61 + <th>结束时间</th>
  62 + <td><input class="form-control" type="time" name="end_time" value="{$interval.end_time}"></td>
  63 + <th>每小时费用</th>
  64 + <td><input class="form-control" type="number" name="price" value="{$interval.price}"></td>
  65 + </tr>
  66 + </tbody>
  67 + <tfoot>
  68 + <tr>
  69 + <!--<th colspan="6" style="text-align: right">-->
  70 + <!--<a class="btn btn-default btn-sm" id="addattr">添加属性</a>-->
  71 + <!--</th>-->
  72 + <th colspan="6">
  73 + <span class="form-required">
  74 + <p style="text-indent: 2em; text-align: left;">
  75 + 说明:此时间段设置为跨越夜间凌晨0点的时间段。如果您想要对不跨天的时间端进行设置时,请调转开始时间与结束时间。并将时间段的每小时费用与左侧的每小时费用进行对调。
  76 + </p>
  77 + <p style="text-indent: 2em; text-align: left;">
  78 + 例如:要设置9点到21点是金额为10元,其余时间的金额为5元。则在时间段的开始时间填入21点,结束时间填入9点,每小时金额为5元,并在左侧的每小时费用填入10元,即可达到您想要的效果。
  79 + </p>
  80 + </span>
  81 + </th>
  82 + </tr>
  83 + </tfoot>
  84 + </table>
  85 + </div>
  86 + </div>
  87 + <div class="form-group">
  88 + <div class="col-sm-offset-2 col-sm-10" style="text-align: center">
  89 + <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>
  90 + <a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
  91 + </div>
  92 + </div>
  93 + </form>
  94 +</div>
  95 +<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
  96 +<script type="text/javascript">
  97 + //编辑器路径定义
  98 + var editorURL = GV.WEB_ROOT;
  99 +</script>
  100 +<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
  101 +<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
  102 +<script type="text/javascript">
  103 + $(function () {
  104 +
  105 + editorcontent = new baidu.editor.ui.Editor();
  106 + editorcontent.render('content');
  107 + try {
  108 + editorcontent.sync();
  109 + } catch (err) {
  110 + }
  111 +
  112 + $('.btn-cancel-thumbnail').click(function () {
  113 + $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
  114 + $('#thumbnail').val('');
  115 + });
  116 +
  117 + $('#more-template-select').val("{$post.more.template|default=''}");
  118 + });
  119 +</script>
  120 +</body>
  121 +</html>
1 <include file="public@header"/> 1 <include file="public@header"/>
2 -<style type="text/css">  
3 - .pic-list li {  
4 - margin-bottom: 5px;  
5 - }  
6 -</style>  
7 </head> 2 </head>
8 <body> 3 <body>
9 <div class="wrap js-check-wrap"> 4 <div class="wrap js-check-wrap">
10 <ul class="nav nav-tabs"> 5 <ul class="nav nav-tabs">
11 - <li class="active"><a>费用管理</a></li> 6 + <li class="active"><a>费用管理</a></li>
  7 + <li ><a href="{:url('AdminCost/add')}">添加费用管理</a></li>
12 </ul> 8 </ul>
13 - <!--js-ajax-form margin-top-20-->  
14 - <form action="{:url('AdminCost/editPost')}" method="post" class="form-horizontal js-ajax-form margin-top-20">  
15 - <div class="row">  
16 - <div class="col-md-3">  
17 - <table class="table table-bordered">  
18 - <tr>  
19 - <th>免费设置</th>  
20 - </tr>  
21 - <tr>  
22 - <td>  
23 - <input type="checkbox" name="free" value="1" <if condition="$cost.free eq 1">checked</if>>第一小时免费</label><br/>  
24 - </td>  
25 - </tr>  
26 - <tr>  
27 - <th>每小时费用</th>  
28 - </tr>  
29 - <tr>  
30 - <td>  
31 - 每小时费用<input style="width: 5rem" type="number" name="cost" value="{$cost.cost}">  
32 - </td>  
33 - </tr>  
34 - <tr>  
35 - <th>费用上限</th>  
36 - </tr>  
37 - <tr>  
38 - <td>  
39 - 每天费用上限<input style="width: 5rem" type="number" name="ceiling" value="{$cost.ceiling}">  
40 - </td>  
41 - </tr>  
42 - </table>  
43 - </div>  
44 - <div class="col-md-9">  
45 - <table class="table table-bordered">  
46 - <thead>  
47 - <tr>  
48 - <th colspan="6">固定收费时间段设置</th>  
49 - </tr>  
50 - </thead>  
51 - <tbody>  
52 - <tr>  
53 - <th>开始时间</th>  
54 - <td><input class="form-control" type="time" name="start_time" value="{$interval.start_time}"></td>  
55 - <th>结束时间</th>  
56 - <td><input class="form-control" type="time" name="end_time" value="{$interval.end_time}"></td>  
57 - <th>每小时费用</th>  
58 - <td><input class="form-control" type="number" name="price" value="{$interval.price}"></td>  
59 - </tr>  
60 - </tbody>  
61 - <tfoot>  
62 - <tr>  
63 - <!--<th colspan="6" style="text-align: right">-->  
64 - <!--<a class="btn btn-default btn-sm" id="addattr">添加属性</a>-->  
65 - <!--</th>-->  
66 - <th colspan="6">  
67 - <span class="form-required">  
68 - <p style="text-indent: 2em; text-align: left;">  
69 - 说明:此时间段设置为跨越夜间凌晨0点的时间段。如果您想要对不跨天的时间端进行设置时,请调转开始时间与结束时间。并将时间段的每小时费用与左侧的每小时费用进行对调。  
70 - </p>  
71 - <p style="text-indent: 2em; text-align: left;">  
72 - 例如:要设置9点到21点是金额为10元,其余时间的金额为5元。则在时间段的开始时间填入21点,结束时间填入9点,每小时金额为5元,并在左侧的每小时费用填入10元,即可达到您想要的效果。  
73 - </p>  
74 - </span>  
75 - </th>  
76 - </tr>  
77 - </tfoot>  
78 - </table>  
79 - </div>  
80 - </div>  
81 - <div class="form-group">  
82 - <div class="col-sm-offset-2 col-sm-10" style="text-align: center">  
83 - <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>  
84 - <a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>  
85 - </div>  
86 - </div> 9 + <form class="js-ajax-form" action="" method="post">
  10 + <table class="table table-hover table-bordered table-list">
  11 + <thead>
  12 + <tr>
  13 + <th width="50">ID</th>
  14 + <th>医院名称</th>
  15 + <th>每小时费用</th>
  16 + <th>费用上限</th>
  17 + <th>操作</th>
  18 + </tr>
  19 + </thead>
  20 + <foreach name="list" item="vo">
  21 + <tr>
  22 + <td><b>{$vo.id}</b></td>
  23 + <td>{$vo.hospital}</td>
  24 + <td>{$vo.cost}</td>
  25 + <td>{$vo.ceiling}</td>
  26 + <td>
  27 + <a href="{:url('AdminCost/edit',array('id'=>$vo['id']))}">编辑</a>&nbsp;
  28 + <a href="{:url('AdminCost/delete',array('id'=>$vo['id']))}" class="js-ajax-dialog-btn">删除</a>
  29 + </td>
  30 + </tr>
  31 + </foreach>
  32 + <tfoot>
  33 + <tr>
  34 + <th width="50">ID</th>
  35 + <th>医院名称</th>
  36 + <th>每小时费用</th>
  37 + <th>费用上限</th>
  38 + <th>操作</th>
  39 + </tr>
  40 + </tfoot>
  41 + </table>
  42 + <ul class="pagination">{$page|default=''}</ul>
87 </form> 43 </form>
88 </div> 44 </div>
89 -<script type="text/javascript" src="__STATIC__/js/admin.js"></script>  
90 -<script type="text/javascript">  
91 - //编辑器路径定义  
92 - var editorURL = GV.WEB_ROOT;  
93 -</script>  
94 -<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>  
95 -<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>  
96 -<script type="text/javascript"> 45 +<script src="__STATIC__/js/admin.js"></script>
  46 +<script>
  47 +
  48 + function reloadPage(win) {
  49 + win.location.reload();
  50 + }
  51 +
97 $(function () { 52 $(function () {
  53 + setCookie("refersh_time", 0);
  54 + Wind.use('ajaxForm', 'artDialog', 'iframeTools', function () {
  55 + //批量复制
  56 + $('.js-articles-copy').click(function (e) {
  57 + var ids = [];
  58 + $("input[name='ids[]']").each(function () {
  59 + if ($(this).is(':checked')) {
  60 + ids.push($(this).val());
  61 + }
  62 + });
98 63
99 - editorcontent = new baidu.editor.ui.Editor();  
100 - editorcontent.render('content');  
101 - try {  
102 - editorcontent.sync();  
103 - } catch (err) {  
104 - } 64 + if (ids.length == 0) {
  65 + art.dialog.through({
  66 + id: 'error',
  67 + icon: 'error',
  68 + content: '您没有勾选信息,无法进行操作!',
  69 + cancelVal: '关闭',
  70 + cancel: true
  71 + });
  72 + return false;
  73 + }
105 74
106 - $('.btn-cancel-thumbnail').click(function () {  
107 - $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');  
108 - $('#thumbnail').val('');  
109 - }); 75 + ids = ids.join(',');
  76 + art.dialog.open("__ROOT__/index.php?g=portal&m=AdminArticle&a=copy&ids=" + ids, {
  77 + title: "批量复制",
  78 + width: "300px"
  79 + });
  80 + });
  81 + //批量移动
  82 + $('.js-articles-move').click(function (e) {
  83 + var ids = [];
  84 + $("input[name='ids[]']").each(function () {
  85 + if ($(this).is(':checked')) {
  86 + ids.push($(this).val());
  87 + }
  88 + });
110 89
111 - $('#more-template-select').val("{$post.more.template|default=''}"); 90 + if (ids.length == 0) {
  91 + art.dialog.through({
  92 + id: 'error',
  93 + icon: 'error',
  94 + content: '您没有勾选信息,无法进行操作!',
  95 + cancelVal: '关闭',
  96 + cancel: true
  97 + });
  98 + return false;
  99 + }
  100 +
  101 + ids = ids.join(',');
  102 + art.dialog.open("__ROOT__/index.php?g=portal&m=AdminArticle&a=move&old_term_id={$term.term_id|default=0}&ids=" + ids, {
  103 + title: "批量移动",
  104 + width: "300px"
  105 + });
  106 + });
  107 + });
112 }); 108 });
113 </script> 109 </script>
114 </body> 110 </body>