作者 郭盛
1 个管道 的构建 通过 耗费 12 秒

修改充值订单

<?php
namespace app\admin\controller;
use app\common\controller\Backend;
use think\Db;
/**
* 充值订单管理
*
* @icon fa fa-circle-o
*/
class Toporder extends Backend
{
/**
* Order模型对象
* @var \app\admin\model\Order
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
// $this->model = new \app\admin\model\Order;
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
/**
* 查看
*/
public function index($ids = null)
{
//当前是否为关联查询
$this->relationSearch = true;
//设置过滤方法
$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();
$user = Db::name('user')->where('id',$ids)->find();
if($user['type'] == 1){
//以往的充值订单
$one = Db::name('toporder')
->where('user_id',$ids)
->where('status',2)
->count();
$one_info = Db::name('toporder')
->where('user_id',$ids)
->where('status',2)
->field('id,money,num,createtime')
->select();
//苹果充值订单
$two = Db::name('iphoneorder')
->where('user_id',$ids)
->where('status',2)
->count();
$two_info = Db::name('iphoneorder')
->where('user_id',$ids)
->where('status',2)
->field('id,money,num,createtime')
->select();
$total = $one + $two; //总条数
$list = array_merge($one_info,$two_info);
$result = array("total" => $total, "rows" => $list);
return json($result);
}else{
$total = Db::name('toporder')
->where('user_id',$ids)
->where('status',2)
->order($sort, $order)
->count();
$list = Db::name('toporder')
->where('user_id',$ids)
->where('status',2)
->order($sort, $order)
->limit($offset, $limit)
->select();
$list = collection($list)->toArray();
$result = array("total" => $total, "rows" => $list);
return json($result);
}
}
$this->assignconfig('ids',$ids);
return $this->view->fetch();
}
}
... ...
<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('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('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('order/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>-->
<!--<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('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('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('toporder/edit')}"
data-operate-del="{:$auth->check('toporder/del')}"
width="100%">
</table>
</div>
</div>
</div>
</div>
</div>
... ...
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'toporder/index' +'/ids/' + Config.ids + location.search,
table: 'toporder',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{field: 'id', title: __('Id'), operate:false},
{field: 'money', title: __('充值金额')},
{field: 'num', title: __('订单号'), operate:false},
{field: 'createtime', title: __('充值时间'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
]
]
});
// 为表格绑定事件
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
... ...
... ... @@ -29,28 +29,36 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
// {field: 'username', title: __('Username'), operate: 'LIKE'},
{field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
// {field: 'email', title: __('Email'), operate: 'LIKE'},
// {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
{field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
{field: 'avatar', title: __('Avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false},
// {field: 'level', title: __('Level'), operate: 'BETWEEN', sortable: true},
{field: 'gender', title: __('Gender'), visible: false, searchList: {1: __('Male'), 0: __('Female')}},
// {field: 'score', title: __('Score'), operate: 'BETWEEN', sortable: true},
{field: 'successions', title: __('Successions'), visible: false, operate: 'BETWEEN', sortable: true},
{field: 'maxsuccessions', title: __('Maxsuccessions'), visible: false, operate: 'BETWEEN', sortable: true},
{field: 'logintime', title: __('Logintime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
{field: 'loginip', title: __('Loginip'), formatter: Table.api.formatter.search},
{field: 'jointime', title: __('Jointime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
{field: 'joinip', title: __('Joinip'), formatter: Table.api.formatter.search},
// {field: 'logintime', title: __('Logintime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
// {field: 'loginip', title: __('Loginip'), formatter: Table.api.formatter.search},
// {field: 'jointime', title: __('Jointime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
// {field: 'joinip', title: __('Joinip'), formatter: Table.api.formatter.search},
{field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {normal: __('Normal'), hidden: __('Hidden')}},
{field: 'money', title: __('账号余额')},
{field: 'id', title: __('按钮组'), table: table, events: Table.api.events.operate, buttons:
[
{
text: '充值信息列表',
title: '充值信息列表',
icon: 'fa fa-list',
classname: 'btn btn-xs btn-primary btn-dialog',
url: 'toporder/index',
extend: 'data-area=\'["80%","80%"]\''
},
{
text: '购买信息列表',
title: '购买信息列表',
icon: 'fa fa-list',
classname: 'btn btn-xs btn-primary btn-dialog',
url: 'order_detail/index',
extend: 'data-area=\'["80%","80%"]\'',
extend: 'data-area=\'["80%","80%"]\''
}
], operate:false, formatter: Table.api.formatter.buttons
},
... ...