459 lines
12 KiB
PHP
459 lines
12 KiB
PHP
<?php
|
||
// +----------------------------------------------------------------------
|
||
// | 小说系统订单管理
|
||
// +----------------------------------------------------------------------
|
||
|
||
namespace app\admin\controller;
|
||
use app\common\controller\Admin;
|
||
|
||
class Order extends Admin {
|
||
|
||
public function _initialize() {
|
||
parent::_initialize();
|
||
//$this->getContentMenu();
|
||
$this->model_id = $model_id =6;
|
||
//$this->model_id = $model_id = $this->request->param('model_id');
|
||
$list = db('Model')->column('*', 'id');
|
||
|
||
if (empty($list[$model_id])) {
|
||
return $this->error("无此模型!");
|
||
} else {
|
||
$this->modelInfo = $list[$model_id];
|
||
$this->model = M($this->modelInfo['name']);
|
||
}
|
||
|
||
$this->assign('model_id', $model_id);
|
||
$this->assign('model_list', $list);
|
||
}
|
||
|
||
/**
|
||
* 内容列表
|
||
* @return [html] [页面内容]
|
||
* @author netlife <40150501@qq.com>
|
||
*/
|
||
public function index() {
|
||
if ($this->modelInfo['list_grid'] == '') {
|
||
return $this->error("列表定义不正确!", url('admin/model/edit', array('id' => $this->modelInfo['id'])));
|
||
}
|
||
|
||
$status = input('status');
|
||
|
||
$keyword = input('keyword');
|
||
|
||
$spreadid = input('spreadid');
|
||
|
||
$wxkeywordid = input('wxkeywordid');
|
||
|
||
$grid_list = get_grid_list($this->modelInfo['list_grid']);
|
||
|
||
$username = input('username');
|
||
|
||
$startdata = input('startdata')?(strtotime(input('startdata'))+86399):mktime(0,0,0,date('m'),1,date('Y'));
|
||
|
||
$enddata = input('enddata')?(strtotime(input('enddata'))+86399):mktime(23,59,59,date('m'),date('t'),date('Y'));
|
||
|
||
$map['create_time'] = array(array('gt',$startdata),array('lt',$enddata));
|
||
|
||
if($username){
|
||
$unameid = db('member')->field('uid')->where('username',$username)->select();
|
||
$uidarr = array();
|
||
foreach($unameid as $k => $v){
|
||
$uidarr[]=$v['uid'];
|
||
}
|
||
//var_dump($uidarr);exit;
|
||
$map['uid'] = array('in',$uidarr);
|
||
}
|
||
// 关键字搜索
|
||
$search_key =$this->modelInfo['search_key']?$this->modelInfo['search_key']:'title';
|
||
if($keyword){
|
||
$map[$search_key] = array("LIKE", "%$keyword%");
|
||
}
|
||
$map['sourceid'] = 1;
|
||
if(isset($status)){
|
||
$map['status'] = $status;
|
||
}
|
||
$map['is_kouliang'] = 0;
|
||
if(isset($spreadid)){
|
||
$map['spreadid'] = $spreadid;
|
||
}
|
||
|
||
if(isset($wxkeywordid)){
|
||
$map['wxkeywordid'] = $wxkeywordid;
|
||
}
|
||
|
||
if(session('user_auth.group')!=999){
|
||
$map['agentid'] = array('in',$this->agentUser(session('user_auth.uid')));
|
||
|
||
if(session('wxmpid')){
|
||
$map['wxmpid'] = session('wxmpid');
|
||
}
|
||
}
|
||
|
||
|
||
$order = "id desc";
|
||
|
||
$field = array_filter($grid_list['fields']);
|
||
|
||
$list = $this->model->where($map)->where('iscontrol',0)->order($order)->paginate($this->modelInfo['list_row']);
|
||
|
||
$data = array(
|
||
'startdata' => $startdata,
|
||
'enddata' => $enddata,
|
||
'keyword' => $keyword,
|
||
'status'=>$status,
|
||
'spreadid'=>$spreadid,
|
||
'username'=>$username,
|
||
'grid' => $grid_list,
|
||
'list' => $list,
|
||
'page' => $list->render(),
|
||
);
|
||
|
||
$this->assign($data);
|
||
$this->setMeta("订单列表");
|
||
return $this->fetch();
|
||
}
|
||
|
||
/**
|
||
* 通道订单列表
|
||
* @return [html] [页面内容]
|
||
* @author netlife <40150501@qq.com>
|
||
*/
|
||
public function klindex() {
|
||
if ($this->modelInfo['list_grid'] == '') {
|
||
return $this->error("列表定义不正确!", url('admin/model/edit', array('id' => $this->modelInfo['id'])));
|
||
}
|
||
|
||
$status = input('status');
|
||
|
||
$keyword = input('keyword');
|
||
|
||
$spreadid = input('spreadid');
|
||
|
||
$wxkeywordid = input('wxkeywordid');
|
||
|
||
$grid_list = get_grid_list($this->modelInfo['list_grid']);
|
||
|
||
$startdata = input('startdata')?(strtotime(input('startdata'))+86399):mktime(0,0,0,date('m'),1,date('Y'));
|
||
|
||
$enddata = input('enddata')?(strtotime(input('enddata'))+86399):mktime(23,59,59,date('m'),date('t'),date('Y'));
|
||
|
||
$map['create_time'] = array(array('gt',$startdata),array('lt',$enddata));
|
||
|
||
// 关键字搜索
|
||
$search_key =$this->modelInfo['search_key']?$this->modelInfo['search_key']:'title';
|
||
if($keyword){
|
||
$map[$search_key] = array("LIKE", "%$keyword%");
|
||
}
|
||
$map['sourceid'] = 1;
|
||
if(isset($status)){
|
||
$map['status'] = $status;
|
||
}else{
|
||
$status = 1;
|
||
}
|
||
$map['is_kouliang'] = 1;
|
||
if(isset($spreadid)){
|
||
$map['spreadid'] = $spreadid;
|
||
}
|
||
|
||
if(isset($wxkeywordid)){
|
||
$map['wxkeywordid'] = $wxkeywordid;
|
||
}
|
||
|
||
if(session('user_auth.group')!=999){
|
||
$map['agentid'] = array('in',$this->agentUser(session('user_auth.uid')));
|
||
}
|
||
|
||
$order = "id desc";
|
||
|
||
$field = array_filter($grid_list['fields']);
|
||
|
||
$list = $this->model->where($map)->where('iscontrol',0)->order($order)->paginate($this->modelInfo['list_row']);
|
||
|
||
$data = array(
|
||
'startdata' => $startdata,
|
||
'enddata' => $enddata,
|
||
'status'=>$status,
|
||
'spreadid'=>$spreadid,
|
||
'grid' => $grid_list,
|
||
'list' => $list,
|
||
'page' => $list->render(),
|
||
);
|
||
|
||
$this->assign($data);
|
||
$this->setMeta("通道订单列表");
|
||
return $this->fetch('klindex');
|
||
}
|
||
|
||
|
||
/**
|
||
* app 订单列表
|
||
* @return [html] [页面内容]
|
||
* @author netlife <40150501@qq.com>
|
||
*/
|
||
public function appindex() {
|
||
if ($this->modelInfo['list_grid'] == '') {
|
||
return $this->error("列表定义不正确!", url('admin/model/edit', array('id' => $this->modelInfo['id'])));
|
||
}
|
||
|
||
$status = input('status');
|
||
|
||
$keyword = input('keyword');
|
||
|
||
$spreadid = input('spreadid');
|
||
|
||
$wxkeywordid = input('wxkeywordid');
|
||
|
||
$grid_list = get_grid_list($this->modelInfo['list_grid']);
|
||
|
||
$startdata = input('startdata')?strtotime(input('startdata')):mktime(0,0,0,date('m'),1,date('Y'));
|
||
|
||
$enddata = input('enddata')?strtotime(input('enddata')):mktime(0,0,0,date('m'),date('t'),date('Y'));
|
||
|
||
$map['create_time'] = array(array('gt',$startdata),array('lt',$enddata));
|
||
|
||
// 关键字搜索
|
||
$search_key =$this->modelInfo['search_key']?$this->modelInfo['search_key']:'title';
|
||
if($keyword){
|
||
$map[$search_key] = array("LIKE", "%$keyword%");
|
||
}
|
||
$map['sourceid'] = 2;
|
||
if(isset($status)){
|
||
$map['status'] = $status;
|
||
}
|
||
//$map['is_kouliang'] = 0;
|
||
if(isset($spreadid)){
|
||
$map['spreadid'] = $spreadid;
|
||
}
|
||
|
||
if(isset($wxkeywordid)){
|
||
$map['wxkeywordid'] = $wxkeywordid;
|
||
}
|
||
|
||
if(session('user_auth.group')!=999){
|
||
$map['agentid'] = array('in',$this->agentUser(session('user_auth.uid')));
|
||
}
|
||
|
||
$order = "id desc";
|
||
|
||
$field = array_filter($grid_list['fields']);
|
||
|
||
$list = $this->model->where($map)->where('iscontrol',0)->order($order)->paginate($this->modelInfo['list_row']);
|
||
|
||
$data = array(
|
||
'startdata' => $startdata,
|
||
'enddata' => $enddata,
|
||
'status'=>$status,
|
||
'spreadid'=>$spreadid,
|
||
'grid' => $grid_list,
|
||
'list' => $list,
|
||
'page' => $list->render(),
|
||
);
|
||
|
||
$this->assign($data);
|
||
$this->setMeta("APP订单列表");
|
||
return $this->fetch('index');
|
||
}
|
||
|
||
/**
|
||
* 内容删除
|
||
* @author netlife <40150501@qq.com>
|
||
*/
|
||
public function del() {
|
||
$id = $this->getArrayParam('id');
|
||
if (empty($id)) {
|
||
return $this->error("非法操作!");
|
||
}
|
||
|
||
$map['id'] = array('IN', $id);
|
||
$result = $this->model->where($map)->delete();
|
||
|
||
if (false !== $result) {
|
||
//记录行为
|
||
action_log('delete_content', 'content', $result, session('user_auth.uid'));
|
||
return $this->success("删除成功!");
|
||
} else {
|
||
return $this->error("删除失败!");
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* 获取字段信息
|
||
* @return array 字段数组
|
||
* @author netlife <40150501@qq.com>
|
||
*/
|
||
protected function getField() {
|
||
$field_group = parse_config_attr($this->modelInfo['attribute_group']);
|
||
|
||
$map['model_id'] = $this->modelInfo['id'];
|
||
if ($this->request->action() == 'add') {
|
||
$map['is_show'] = array('in', array('1', '2'));
|
||
} elseif ($this->request->action() == 'edit') {
|
||
$map['is_show'] = array('in', array('1', '3'));
|
||
}
|
||
|
||
//获得数组的第一条数组
|
||
$rows = model('Attribute')->getFieldlist($map, 'id');
|
||
if (!empty($rows)) {
|
||
foreach ($rows as $key => $value) {
|
||
$list[$value['group_id']][] = $value;
|
||
}
|
||
foreach ($field_group as $key => $value) {
|
||
$fields[$value] = isset($list[$key]) ? $list[$key] : array();
|
||
}
|
||
}else{
|
||
$fields = array();
|
||
}
|
||
return $fields;
|
||
}
|
||
|
||
/**
|
||
* 创建搜索
|
||
* @return [array] [查询条件]
|
||
*/
|
||
protected function buildMap($search_key) {
|
||
$map = array();
|
||
$data = $this->request->param();
|
||
|
||
foreach ($data as $key => $value) {
|
||
if ($value) {
|
||
if ($key == 'keyword') {
|
||
$map[$search_key] = array("LIKE", "%$value%");
|
||
} elseif ($key == 'category') {
|
||
$map['category_id'] = $value;
|
||
} elseif ($key == 'create_time') {
|
||
$map['create_time'] = array('BETWEEN', array(strtotime($value[0]), strtotime($value[1])));
|
||
} else {
|
||
$map[$key] = $value;
|
||
}
|
||
}
|
||
}
|
||
|
||
if (isset($map['page'])) {
|
||
unset($map['page']);
|
||
}
|
||
if (isset($map['model_id'])) {
|
||
unset($map['model_id']);
|
||
}
|
||
$this->assign($data);
|
||
return $map;
|
||
}
|
||
|
||
/**
|
||
* 检测需要动态判断的文档类目有关的权限
|
||
*
|
||
* @return boolean|null
|
||
* 返回true则表示当前访问有权限
|
||
* 返回false则表示当前访问无权限
|
||
* 返回null,则会进入checkRule根据节点授权判断权限
|
||
*
|
||
* @author 朱亚杰 <xcoolcc@gmail.com>
|
||
*/
|
||
protected function checkDynamic() {
|
||
$model_id = $this->request->param('model_id');
|
||
if (IS_ROOT) {
|
||
return true; //管理员允许访问任何页面
|
||
}
|
||
$models = model('AuthGroup')->getAuthModels(session('user_auth.uid'));
|
||
if (!$model_id) {
|
||
return false;
|
||
} elseif (in_array($model_id, $models)) {
|
||
//返回null继续判断操作权限
|
||
return null;
|
||
} else {
|
||
return false; //无权限
|
||
}
|
||
return false;
|
||
}
|
||
|
||
/**
|
||
* agentUser [各等级代理商用户]
|
||
*
|
||
* @return type
|
||
**/
|
||
protected function agentUser($uid) {
|
||
$member = db('member')->where('uid='.$uid)->find();
|
||
|
||
if($member['is_top']==1){
|
||
$map['s_uid'] = $uid;
|
||
}/***elseif($member['is_top']==0 && empty($member['t_uid'])){
|
||
$map['t_uid'] = $uid;
|
||
}***/else{
|
||
return $uid;
|
||
}
|
||
$map['status'] =1;
|
||
$map['group'] =array('IN','3,4');
|
||
|
||
$daili = db('member')->where($map)->column('uid');
|
||
$daili[]=$uid;
|
||
$agentid = implode(",",$daili);
|
||
return $agentid;
|
||
}
|
||
|
||
|
||
public function export() {
|
||
|
||
$status = 1;
|
||
$keyword = input('keyword');
|
||
|
||
$spreadid = input('spreadid');
|
||
|
||
$wxkeywordid = input('wxkeywordid');
|
||
|
||
$grid_list = get_grid_list($this->modelInfo['list_grid']);
|
||
|
||
$startdata = input('startdata')?strtotime(input('startdata')):mktime(0,0,0,date('m'),1,date('Y'));
|
||
|
||
$enddata = input('enddata')?strtotime(input('enddata')):mktime(0,0,0,date('m'),date('t'),date('Y'));
|
||
|
||
$map['create_time'] = array(array('gt',$startdata),array('lt',$enddata));
|
||
|
||
// 关键字搜索
|
||
$search_key =$this->modelInfo['search_key']?$this->modelInfo['search_key']:'title';
|
||
if($keyword){
|
||
$map[$search_key] = array("LIKE", "%$keyword%");
|
||
}
|
||
|
||
$map['sourceid'] = 1;
|
||
|
||
if(isset($status)){
|
||
$map['status'] = $status;
|
||
}
|
||
|
||
$map['is_kouliang'] = 0;
|
||
|
||
if(isset($spreadid)){
|
||
$map['spreadid'] = $spreadid;
|
||
}
|
||
|
||
if(isset($wxkeywordid)){
|
||
$map['wxkeywordid'] = $wxkeywordid;
|
||
}
|
||
|
||
if(session('user_auth.group')!=999){
|
||
$map['agentid'] = array('in',$this->agentUser(session('user_auth.uid')));
|
||
}
|
||
|
||
$order = "id desc";
|
||
|
||
$field = array_filter($grid_list['fields']);
|
||
|
||
$list = $this->model->where($map)->where('iscontrol',0)->order($order)->select();
|
||
|
||
$headarr = array("ID","订单号","交易号","订单类型","用户","金额","支付方式","创建日期");
|
||
if($list){
|
||
foreach($list as $k=>$v){
|
||
$data[$k]['id'] = $v['id'];
|
||
$data[$k]['out_trade_no'] = $v['out_trade_no'];
|
||
$data[$k]['transaction_id'] = $v['transaction_id'];
|
||
$data[$k]['type'] = get_field(6,'type',$v['type']);
|
||
$data[$k]['username'] = get_username($v['uid']);
|
||
$data[$k]['money'] = $v['money'];
|
||
$data[$k]['paytype'] = $v['paytype'];
|
||
$data[$k]['create_time'] =date('Y-m-d',$v['create_time']);
|
||
}
|
||
$this->xlsout("已支付订单列表",$headarr,$data);
|
||
}
|
||
}
|
||
|
||
} |