作者 sgj
1 个管道 的构建 通过 耗费 2 秒

Merge remote-tracking branch 'origin/master'

... ... @@ -36,13 +36,15 @@ class AdminFaultAuditController extends AdminBaseController{
}
$data=Db::name('fault')
->alias('a')
->field('a.*,b.serial_number,b.hospital')
->field('a.*,b.serial_number,b.hospital,u.phone')
->join('equipment b','a.eq_name=b.name')
->join('users u','a.users_id=u.id')
->where($where)
->order('a.state','ase')
->order('a.create_time','desc')
->paginate(10);
$this->assign('page',$data->render());
$this->assign('data',$data);
$this->assign('fault_type', isset($param['fault_type']) ? $param['fault_type'] : '');
return $this->fetch();
... ...
... ... @@ -31,7 +31,7 @@ class AdminFaultController extends AdminBaseController{
public function index(){
$data=Db::name('fault')->alias('a')
->field('a.eq_name,b.hospital')
->field('a.eq_name,b.hospital,b.serial_number')
->join('equipment b','a.eq_name=b.name')
->group('a.eq_name')
->paginate(10)->each(function ($item){
... ...
... ... @@ -11,6 +11,7 @@ namespace app\portal\controller;
use app\portal\model\UsersModel;
use cmf\controller\AdminBaseController;
use think\Db;
/**
* Class AdminUsersController
* @package app\portal\controller
... ... @@ -27,8 +28,20 @@ use cmf\controller\AdminBaseController;
class AdminUsersController extends AdminBaseController{
public function index(){
$param=$this->request->param();
$where=[];
if (!empty($param['keyword'])){
$where['phone']=['like','%'.$param['keyword'].'%'];
}
$users=new UsersModel();
$data=$users->order('create_time','desc')->paginate(10);
$data=$users->where($where)->order('create_time','desc')->paginate(10)->each(function ($item) {
if ($item['is_use']==1){
$item['eq']=Db::name('order')->where(['users_id'=>$item['id'],'state'=>1])->find()['eq_name'];
}
return $item;
});
$data->appends($param);
$this->assign('keyword', isset($param['keyword']) ? $param['keyword'] : '');
$this->assign('data',$data);
return $this->fetch();
}
... ...
... ... @@ -36,7 +36,7 @@ class UsersController extends HomeBaseController{
* @author sgj
* @url /portal/users/changeorder
* @method GET
*
* @group 用户相关接口2
* @param name:id type:String require:1 default:无 other: desc:订单id
*
*/
... ... @@ -439,4 +439,55 @@ class UsersController extends HomeBaseController{
$return['fee']=\db('users')->where('id',$user_id)->value('fee');
$this->apiResponse(200,'success',$return);
}
/**
* @title 用户提现
* @description
* @author panhaowen
* @url /portal/users/withdraw
* @method GET
* @param name:user_id type:String require:1 default:无 other: desc:用户id
* @param name:fee type:int require:1 default:无 other: desc:用户id
*/
public function withdraw(){
$user_id=input('user_id');
$fee=$this->request->param('fee');
$user=Db::name('users')->where('id',$user_id)->find();
if ($user['fee']>=$fee) {
$order_sn=cmf_get_order_sn();
Db::startTrans();
try{
Db::name('users')->where('id',$user_id)->setDec('fee', $fee);
Db::name('withdraw')->insert([
'user_id'=>$user_id,
'money'=>$fee,
'create_time'=>time(),
'order_sn'=>$order_sn
]);
Db::commit();
}catch (\Exception $e) {
// 回滚事务
Db::rollback();
$this->apiResponse(301,'提现失败');
}
$app = new Application($this->options);
$merchantPay = $app->merchant_pay;
$merchantPayData = [
'partner_trade_no' => $order_sn, //随机字符串作为订单号,跟红包和支付一个概念。
'openid' => $user['open_id'], //收款人的openid
'check_name' => 'NO_CHECK', //文档中有三种校验实名的方法 NO_CHECK OPTION_CHECK FORCE_CHECK
// 're_user_name'=>'张三', //OPTION_CHECK FORCE_CHECK 校验实名的时候必须提交
'amount' => $fee * 100, //单位为分
// 'amount' => 100, //单位为分
'desc' => '企业付款',
'spbill_create_ip' => get_client_ip(0, true), //发起交易的IP地址
];
$re = $merchantPay->send($merchantPayData);
$this->apiResponse(200,'success',$re);
}else{
$this->apiResponse(300,'余额不足提现失败');
}
}
}
\ No newline at end of file
... ...
... ... @@ -29,6 +29,7 @@
<thead>
<tr>
<th>设备名称</th>
<th>设备锁编号</th>
<th>初始医院</th>
<th>计费故障次数</th>
<th>锁故障次数</th>
... ... @@ -40,6 +41,7 @@
<foreach name="data" item="vo">
<tr>
<td>{$vo.eq_name}</td>
<td>{$vo.serial_number}</td>
<td>{$vo.hospital}</td>
<td>{$vo.fault_time|default='0'}</td>
<td>{$vo.fault_lock|default='0'}</td>
... ... @@ -49,6 +51,7 @@
</tr>
</foreach>
</table>
<ul class="pagination">{$page|default=''}</ul>
</form>
</div>
<script src="__STATIC__/js/admin.js"></script>
... ...
... ... @@ -27,6 +27,7 @@
</label>
</th>
<th width="50">ID</th>
<th>上报人号码</th>
<th>设备名称</th>
<th>设备锁编号</th>
<th>所在医院</th>
... ... @@ -44,6 +45,7 @@
value="{$vo.id}" title="ID:{$vo.id}">
</td>
<td><b>{$vo.id}</b></td>
<td>{$vo.phone}</td>
<td>{$vo.eq_name}</td>
<td>{$vo.serial_number}</td>
<td>{$vo.hospital}</td>
... ... @@ -110,7 +112,7 @@
<!--{:lang('DELETE')}-->
<!--</button>-->
<!--</div>-->
<ul class="pagination">{$page|default=''}</ul>
<ul style="text-align: center">{$page|default=''}</ul>
</form>
</div>
<script src="__STATIC__/js/admin.js"></script>
... ...
... ... @@ -6,12 +6,7 @@
<li class="active"><a href="javascript:;">用户列表</a></li>
<!--<li><a href="{:url('AdminArticle/add')}">添加文章</a></li>-->
</ul>
<form class="well form-inline margin-top-20" method="post" action="{:url('AdminArticle/index')}">
分类:
<select class="form-control" name="category" style="width: 140px;">
<option value='0'>全部</option>
{$category_tree|default=''}
</select> &nbsp;&nbsp;
<form class="well form-inline margin-top-20" method="post" action="{:url('AdminUsers/index')}">
时间:
<input type="text" class="form-control js-bootstrap-datetime" name="start_time"
value="{$start_time|default=''}"
... ... @@ -21,9 +16,9 @@
style="width: 140px;" autocomplete="off"> &nbsp; &nbsp;
关键字:
<input type="text" class="form-control" name="keyword" style="width: 200px;"
value="{$keyword|default=''}" placeholder="请输入关键字...">
value="{$keyword|default=''}" placeholder="手机号">
<input type="submit" class="btn btn-primary" value="搜索"/>
<a class="btn btn-danger" href="{:url('AdminArticle/index')}">清空</a>
<a class="btn btn-danger" href="{:url('AdminUsers/index')}">清空</a>
</form>
<form class="js-ajax-form" action="" method="post">
<table class="table table-hover table-bordered table-list">
... ... @@ -41,6 +36,7 @@
<th>手机号</th>
<th>是否交了押金</th>
<th>押金</th>
<th>使用设备</th>
</tr>
</thead>
<foreach name="data" item="vo">
... ... @@ -67,6 +63,13 @@
<td>
{$vo.deposit|default='0'}
</td>
<td>
<eq name="vo.is_use" value="1">
{$vo.eq}
<else />
未使用
</eq>
</td>
</tr>
</foreach>
</table>
... ...