diff --git a/Application/Admin/Controller/PromoteController.class.php b/Application/Admin/Controller/PromoteController.class.php
index b614a3a2d..c16003a1b 100644
--- a/Application/Admin/Controller/PromoteController.class.php
+++ b/Application/Admin/Controller/PromoteController.class.php
@@ -193,6 +193,7 @@ unset($_REQUEST['parent_id']);
empty(I('post.password')) ? : $data['password'] =I('post.password');
empty(I('post.second_pwd')) ? : $data['second_pwd'] =I('post.second_pwd');
empty(I('post.status')) ? : $data['status'] =I('post.status');
+ empty(I('post.child_game_permission')) ? : $data['child_game_permission'] =I('post.child_game_permission');
empty(I('post.mark1')) ? : $data['mark1'] =I('post.mark1');
empty(I('post.mark2')) ? : $data['mark2'] = I('post.mark2');
$data['ba_id'] = I('ba_id');
diff --git a/Application/Admin/View/Promote/edit.html b/Application/Admin/View/Promote/edit.html
index a6383bec5..1cafd2b15 100644
--- a/Application/Admin/View/Promote/edit.html
+++ b/Application/Admin/View/Promote/edit.html
@@ -66,6 +66,21 @@
+
+
+ 下级游戏展示: |
+
+
+
+
+
+ |
+
+
真实姓名: |
diff --git a/Application/Home/Common/function.php b/Application/Home/Common/function.php
index 11fb95b30..1bf7886f3 100644
--- a/Application/Home/Common/function.php
+++ b/Application/Home/Common/function.php
@@ -965,6 +965,14 @@ function getParentPromoteId($promoteId)
return D('Promote')->where($map)->getField('parent_id');
}
+//获会长渠道ID
+function getGrandPromoteId($promoteId)
+{
+ $map['id'] = $promoteId;
+
+ return D('Promote')->where($map)->getField('grand_id');
+}
+
function getGamePermission($gameId)
{
$gameData = M('Game', 'tab_')
@@ -1170,4 +1178,10 @@ function promoteCan($promoteId, \Closure $callback)
{
$level = get_promote_level(session('promote_auth.pid'));
return $callback($level);
+}
+
+//获取下级游戏添加权限
+function getChildGameAddPermission($promoteId)
+{
+ return D('Promote')->where(array('id' => $promoteId))->getField('child_game_permission');
}
\ No newline at end of file
diff --git a/Application/Home/Controller/ApplyController.class.php b/Application/Home/Controller/ApplyController.class.php
index a7e554662..5bce38ea2 100644
--- a/Application/Home/Controller/ApplyController.class.php
+++ b/Application/Home/Controller/ApplyController.class.php
@@ -65,13 +65,11 @@ class ApplyController extends BaseController
$promoteId = empty(I('promote_id')) ? PID : I('promote_id');//搜索的渠道ID
$promoteRole = empty(I('promote_role')) ? 1 : I('promote_role');//渠道角色
$parentPromoteId = getParentPromoteId($promoteId);//上级渠道ID
+ $grandPromoteId = getGrandPromoteId($promoteId);
+ $grandPromoteId = empty($grandPromoteId) ? $parentPromoteId : $grandPromoteId;//本账号会长渠道ID
+ $childGameAddPermission = getChildGameAddPermission($grandPromoteId);//游戏添加权限
$thisParentPromoteId = getParentPromoteId(PID);//本账号上级渠道ID
-// $addPermission = 1;//是否有添加游戏权限
-// if ($thisParentPromoteId == 0 && $promoteRole == 3) {
-// $addPermission = 0;
-// }
-
$map['tab_game.online_status'] = 1;//开发者游戏上线状态
$map['tab_game.down_port'] = 1;//游戏端口 第三方接口不能申请
$map['tab_game.game_status'] = 1;//游戏状态
@@ -103,7 +101,7 @@ class ApplyController extends BaseController
case 10:
$group = 'tab_game.relation_game_id';
- if ($parentPromoteId > 0) {
+ if ($parentPromoteId > 0 && $childGameAddPermission == 0) {
$gameRelationGameIdList = M('Game', 'tab_')->group('relation_game_id')->having('count(id) = 2')->getField('relation_game_id', true);
if (count($gameRelationGameIdList) > 0) {
$gameRelationGameIdList = implode(',', $gameRelationGameIdList);
@@ -136,14 +134,14 @@ class ApplyController extends BaseController
}
$join = '';
- if ($parentPromoteId > 0) {
- $map['tab_apply.promote_id'] = PID;
+ if ($parentPromoteId > 0 && $childGameAddPermission == 0) {
+ $map['tab_apply.promote_id'] = $grandPromoteId;
if (!empty($where)) {
$map['_logic'] = 'and';
$map['_complex'] = $where;
}
- $join = 'inner join tab_apply on tab_game.id = tab_apply.game_id and tab_apply.offline_status = 0';//查询上级游戏
+ $join = 'tab_apply on tab_game.id = tab_apply.game_id and tab_apply.offline_status = 0';//查询上级游戏
}
$data = M('Game', 'tab_')
@@ -155,6 +153,7 @@ class ApplyController extends BaseController
->where($map)
->group($group)
->order('tab_game.sort desc,tab_game.id desc')
+// ->fetchSql(true)
->page($page, $row)
->select();
@@ -190,7 +189,6 @@ class ApplyController extends BaseController
$this->assign('promoteRole', $promoteRole);
$this->assign('pID', PID);
$this->assign('promoteData', getAllPromoteListByType($promoteRole));
-// $this->assign('addPermission', $addPermission);
$this->assign('type', $type);
$this->assign('myGame', ($serverType == 1) ? 'specialMyGameList' : 'myGameList');
$this->assign('game', ($serverType == 1) ? 'gameSpecialList' : 'gameList');
@@ -614,6 +612,9 @@ class ApplyController extends BaseController
}
$map['tab_apply.promote_id'] = $promoteId;
+ $map['tab_game.online_status'] = 1;//开发者游戏上线状态
+ $map['tab_game.down_port'] = 1;//游戏端口 第三方接口不能申请
+ $map['tab_game.game_status'] = 1;//游戏状态
$map['tab_game.server_type'] = $serverType;//游戏服务器类型
if ($_REQUEST['game_id'] != null) {
@@ -1008,13 +1009,16 @@ class ApplyController extends BaseController
}
$promoteData = D('Promote')->where(array('id' => $promoteId))->find();
+ $grandPromoteId = getGrandPromoteId($promoteId);
+ $grandPromoteId = empty($grandPromoteId) ? $promoteData['parent_id'] : $grandPromoteId;//本账号会长渠道ID
+ $childGameAddPermission = getChildGameAddPermission($grandPromoteId);//游戏添加权限
if ($_POST['sdk_type'] > 0) {
- if ($promoteData['parent_id'] > 0) {
+ if ($promoteData['parent_id'] > 0 && $childGameAddPermission == 0) {
$gameRelationName = M('game', 'tab_')->where(array('id' => $_POST['game_id']))->getField('relation_game_name');
$gameData = M('game', 'tab_')
->field('tab_game.*')
- ->join('tab_apply on tab_game.id = tab_apply.game_id and tab_apply.offline_status = 0 and tab_apply.promote_id = ' . PID)
+ ->join('tab_apply on tab_game.id = tab_apply.game_id and tab_apply.offline_status = 0 and tab_apply.promote_id = ' . $grandPromoteId)
->where(array('tab_game.relation_game_name' => $gameRelationName))
->select();
} else {
@@ -1024,10 +1028,10 @@ class ApplyController extends BaseController
->select();
}
} else {
- if ($promoteData['parent_id'] > 0) {
+ if ($promoteData['parent_id'] > 0 && $childGameAddPermission == 0) {
$gameData = M('game', 'tab_')
->field('tab_game.*')
- ->join('tab_apply on tab_game.id = tab_apply.game_id and tab_apply.offline_status = 0 and tab_apply.promote_id = ' . PID)
+ ->join('tab_apply on tab_game.id = tab_apply.game_id and tab_apply.offline_status = 0 and tab_apply.promote_id = ' . $grandPromoteId)
->where($gameMap)->select();
} else {
$gameData = M('game', 'tab_')->where($gameMap)->select();
diff --git a/Application/Home/Controller/PromoteController.class.php b/Application/Home/Controller/PromoteController.class.php
index 95934e419..86764e041 100644
--- a/Application/Home/Controller/PromoteController.class.php
+++ b/Application/Home/Controller/PromoteController.class.php
@@ -33,7 +33,7 @@ use Base\Service\ApplyService;
class PromoteController extends BaseController
{
//系统首页
- public function index($p=1)
+ public function index($p = 1)
{
$this->meta_title = "首页";
$this->display('prepare');
@@ -45,24 +45,24 @@ class PromoteController extends BaseController
$this->redirect("Home/Index/index");
}
- $quick_menu_list = M("quick_menu qmn","tab_")
- ->join("tab_promote_quick_menu as pqmn on qmn.id=pqmn.quick_menu_id and promote_id=".get_pid())
+ $quick_menu_list = M("quick_menu qmn", "tab_")
+ ->join("tab_promote_quick_menu as pqmn on qmn.id=pqmn.quick_menu_id and promote_id=" . get_pid())
->field("qmn.*")
->where("qmn.status=0")
->order("create_time desc")
->limit("0,10")
->select();
- $game_list = M("game","tab_")->field("id,game_name")->order("id desc")->select();
- $gg_list = M("document","sys_")->limit('0,5')->where("category_id=56 and status=1")->order("update_time desc")->select(); //游戏公告
- $zx_list = M("document","sys_")->limit('0,5')->where("category_id=51 and status=1")->order("update_time desc")->select(); //游戏咨询
+ $game_list = M("game", "tab_")->field("id,game_name")->order("id desc")->select();
+ $gg_list = M("document", "sys_")->limit('0,5')->where("category_id=56 and status=1")->order("update_time desc")->select(); //游戏公告
+ $zx_list = M("document", "sys_")->limit('0,5')->where("category_id=51 and status=1")->order("update_time desc")->select(); //游戏咨询
$xx_list = null;
$today_start = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
$today_end = mktime(0, 0, 0, date('m'), date('d') + 1, date('Y')) - 1;
- $today_open_server_list = M("server as sv","tab_")->where(
- array("sv.start_time"=>array("BETWEEN", array($today_start, $today_end)),
- "sv.show_status"=>1))
+ $today_open_server_list = M("server as sv", "tab_")->where(
+ array("sv.start_time" => array("BETWEEN", array($today_start, $today_end)),
+ "sv.show_status" => 1))
->join("left join tab_game gm on gm.id=sv.game_id")
->field('sv.*,gm.icon')
->order("sv.start_time desc")
@@ -71,51 +71,51 @@ class PromoteController extends BaseController
$count = M("server", "tab_")
->where(
- array("start_time"=>array("BETWEEN", array($today_start, $today_end)),
- "show_status"=>1))
+ array("start_time" => array("BETWEEN", array($today_start, $today_end)),
+ "show_status" => 1))
->count();
- $page = $this->ajax_page($count,20,'seach');
- $this->assign("_page",$page);
+ $page = $this->ajax_page($count, 20, 'seach');
+ $this->assign("_page", $page);
- $user_count = M("user","tab_")->where("promote_id=".get_pid())->count();
- $total_money = $this->pay_total(0,0);
+ $user_count = M("user", "tab_")->where("promote_id=" . get_pid())->count();
+ $total_money = $this->pay_total(0, 0);
$today_add_user_money = $this->pay_total(1);
$month_add_user_money = $this->pay_total(3);
$yesterday_start = mktime(0, 0, 0, date('m'), date('d') - 1, date('Y'));
$yesterday_end = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
- $yesterday_user_regist_count = M("user","tab_")->where(
- array("promote_id"=>get_pid(),
- "register_time"=>array("BETWEEN", array($yesterday_start, $yesterday_end))))
+ $yesterday_user_regist_count = M("user", "tab_")->where(
+ array("promote_id" => get_pid(),
+ "register_time" => array("BETWEEN", array($yesterday_start, $yesterday_end))))
->count();
- $yesterday_total_money = $this->pay_total(5,0);
- $yesterday_regist_user_count = M("user","tab_")
- ->where(array("promote_id"=>get_pid(),
- "register_time"=>array("BETWEEN", array($yesterday_start, $yesterday_end))))
+ $yesterday_total_money = $this->pay_total(5, 0);
+ $yesterday_regist_user_count = M("user", "tab_")
+ ->where(array("promote_id" => get_pid(),
+ "register_time" => array("BETWEEN", array($yesterday_start, $yesterday_end))))
->count();
- $yesterday_total_money = $this->pay_total(1,0);
- $this->assign("user_count",$user_count);
+ $yesterday_total_money = $this->pay_total(1, 0);
+ $this->assign("user_count", $user_count);
$this->assign("total_money", $total_money);
$this->assign("today_add_user_money", $today_add_user_money);
$this->assign("month_add_user_money", $month_add_user_money);
- $this->assign("yesterday_user_regist_count",$yesterday_user_regist_count);
- $this->assign("yesterday_total_money",$yesterday_total_money);
- $this->assign("yesterday_regist_user_count",$yesterday_regist_user_count);
- $this->assign("yesterday_total_money",$yesterday_total_money);
+ $this->assign("yesterday_user_regist_count", $yesterday_user_regist_count);
+ $this->assign("yesterday_total_money", $yesterday_total_money);
+ $this->assign("yesterday_regist_user_count", $yesterday_regist_user_count);
+ $this->assign("yesterday_total_money", $yesterday_total_money);
$this->assign("menu_list", $quick_menu_list);
$this->assign("gg_list", $gg_list);
$this->assign("zx_list", $zx_list);
$this->assign("xx_list", $xx_list);
$this->assign("today_open_server_list", $today_open_server_list);
- $this->assign("game_list",$game_list);
+ $this->assign("game_list", $game_list);
$this->meta_title = "首页";
$this->display();
}
- private function pay_total($type=0,$newadd=1)
+ private function pay_total($type = 0, $newadd = 1)
{
if ($_REQUEST['promote_id'] === null || $_REQUEST['promote_id'] === '0') {
$map['parent_id'] = get_pid();
@@ -133,49 +133,56 @@ class PromoteController extends BaseController
$where['spend.pay_status'] = 1;
$where['spend.is_check'] = array('NEQ', 2);
switch ($type) {
- case 1: { // 今天
- $start = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
- $end = mktime(0, 0, 0, date('m'), date('d') + 1, date('Y')) - 1;
- };
+ case 1:
+ { // 今天
+ $start = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
+ $end = mktime(0, 0, 0, date('m'), date('d') + 1, date('Y')) - 1;
+ };
+ break;
+ case 3:
+ {
+ // 本月
+ $start = mktime(0, 0, 0, date('m'), 1, date('Y'));
+ $end = mktime(0, 0, 0, date('m') + 1, 1, date('Y')) - 1;
+ };
break;
- case 3: {
- // 本月
- $start = mktime(0, 0, 0, date('m'), 1, date('Y'));
- $end = mktime(0, 0, 0, date('m') + 1, 1, date('Y')) - 1;
- };
+ case 4:
+ {
+ // 本年
+ $start = mktime(0, 0, 0, 1, 1, date('Y'));
+ $end = mktime(0, 0, 0, 1, 1, date('Y') + 1) - 1;
+ };
break;
- case 4: {
- // 本年
- $start = mktime(0, 0, 0, 1, 1, date('Y'));
- $end = mktime(0, 0, 0, 1, 1, date('Y') + 1) - 1;
- };
+ case 5:
+ { // 昨天
+ $start = mktime(0, 0, 0, date('m'), date('d') - 1, date('Y'));
+ $end = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
+ };
break;
- case 5: { // 昨天
- $start = mktime(0, 0, 0, date('m'), date('d') - 1, date('Y'));
- $end = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
- };
+ case 6:
+ {
+ $start = mktime(0, 0, 0, date('m') - 1, 1, date('Y'));
+ $end = mktime(0, 0, 0, date('m'), 1, date('Y')) - 1;
+ };
break;
- case 6:{
- $start = mktime(0,0,0,date('m')-1,1,date('Y'));
- $end = mktime(0,0,0,date('m'),1,date('Y'))-1;
- };break;
- case 9: { // 前七天
- $start = mktime(0, 0, 0, date('m'), date('d') - 6, date('Y'));
- $end = mktime(date('H'), date('m'), date('s'), date('m'), date('d'), date('Y'));
- };
+ case 9:
+ { // 前七天
+ $start = mktime(0, 0, 0, date('m'), date('d') - 6, date('Y'));
+ $end = mktime(date('H'), date('m'), date('s'), date('m'), date('d'), date('Y'));
+ };
break;
default:
;
}
if (isset($start) && isset($end)) {
$where['spend.pay_time'] = array("BETWEEN", array($start, $end));
- if($newadd==1){
+ if ($newadd == 1) {
$where['user.register_time'] = array("BETWEEN", array($start, $end));
}
}
- if($newadd==1){
+ if ($newadd == 1) {
$total = M('spend as spend', "tab_")->field("SUM(spend.pay_amount) as amount")->join("right join tab_user user on user.id=spend.user_id")->where($where)->select();
- }else{
+ } else {
$total = M('spend as spend', "tab_")->field("SUM(spend.pay_amount) as amount")->where($where)->select();
}
@@ -203,27 +210,28 @@ class PromoteController extends BaseController
}
- public function home_read_data(){
- $type = I("type","0");
+ public function home_read_data()
+ {
+ $type = I("type", "0");
$game_id = I("game_id");
- $pg = I("page","0");
+ $pg = I("page", "0");
$today_start = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
$today_end = mktime(0, 0, 0, date('m'), date('d') + 1, date('Y')) - 1;
- if($game_id){
+ if ($game_id) {
$map['sv.game_id'] = $game_id;
- $count_map['game_id']= $game_id;
+ $count_map['game_id'] = $game_id;
}
- if($type>0){
- $map['sv.start_time']=array("GT", $today_end);
- $count_map['start_time']= array("GT", $today_end);
- }else{
- $map['sv.start_time']=array("BETWEEN", array($today_start, $today_end));
- $count_map['start_time']= array("BETWEEN", array($today_start, $today_end));
+ if ($type > 0) {
+ $map['sv.start_time'] = array("GT", $today_end);
+ $count_map['start_time'] = array("GT", $today_end);
+ } else {
+ $map['sv.start_time'] = array("BETWEEN", array($today_start, $today_end));
+ $count_map['start_time'] = array("BETWEEN", array($today_start, $today_end));
}
$map['sv.show_status'] = 1;
$count_map['show_status'] = 1;
- $open_server_list = M("server as sv","tab_")->where($map)
+ $open_server_list = M("server as sv", "tab_")->where($map)
->join("left join tab_game gm on gm.id=sv.game_id")
->field('sv.*,gm.icon')
->order("sv.start_time desc")
@@ -234,81 +242,84 @@ class PromoteController extends BaseController
->where($count_map)
->count();
//var_dump($count);
- $page = $this->ajax_page($count,20,'seach',$pg);
+ $page = $this->ajax_page($count, 20, 'seach', $pg);
//$this->assign("_page",$page);
//$count = M("server", "tab_")->where($map)->count();
- foreach ($open_server_list as $key => $server){
- $open_server_list[$key]['icon']=get_cover($server['icon'],'path');
- if($server['pay_type']==1){
- $open_server_list[$key]['pay_type']='安卓';
- }elseif ($server['pay_type']==1){
- $open_server_list[$key]['pay_type']='iOS';
- }else{
- $open_server_list[$key]['pay_type']='安卓、iOS';
+ foreach ($open_server_list as $key => $server) {
+ $open_server_list[$key]['icon'] = get_cover($server['icon'], 'path');
+ if ($server['pay_type'] == 1) {
+ $open_server_list[$key]['pay_type'] = '安卓';
+ } elseif ($server['pay_type'] == 1) {
+ $open_server_list[$key]['pay_type'] = 'iOS';
+ } else {
+ $open_server_list[$key]['pay_type'] = '安卓、iOS';
}
$open_server_list[$key]['pay_type'];
- $open_server_list[$key]['start_time'] = date('Y-m-s h:i',$server['start_time']);
+ $open_server_list[$key]['start_time'] = date('Y-m-s h:i', $server['start_time']);
}
//$content = $this->fetch('Promote/home_read_data');
- $this->ajaxReturn(['status'=>1,'info'=>'调用成功','data'=>$open_server_list,'_page'=>$page],"JSON");
+ $this->ajaxReturn(['status' => 1, 'info' => '调用成功', 'data' => $open_server_list, '_page' => $page], "JSON");
}
- public function quick_menu_list(){
- $data_list = M("quick_menu qmn","tab_")
- ->join("left join tab_promote_quick_menu as pqmn on qmn.id=pqmn.quick_menu_id and promote_id=".get_pid())
+ public function quick_menu_list()
+ {
+ $data_list = M("quick_menu qmn", "tab_")
+ ->join("left join tab_promote_quick_menu as pqmn on qmn.id=pqmn.quick_menu_id and promote_id=" . get_pid())
->field("qmn.*,pqmn.id as exist_id")
->where("qmn.status=0")
->order("qmn.id asc")
->select();
- $this->assign("data_list",$data_list);
+ $this->assign("data_list", $data_list);
$this->meta_title = "快捷菜单";
$this->display();
}
- public function quick_menu_set(){
+ public function quick_menu_set()
+ {
$menu_id = I("menu_id");
- $info = M("promote_quick_menu ","tab_")
+ $info = M("promote_quick_menu ", "tab_")
->where(
- array("quick_menu_id"=>$menu_id,
- "promote_id"=>get_pid())
+ array("quick_menu_id" => $menu_id,
+ "promote_id" => get_pid())
)
->find();
- if($info){
- M("promote_quick_menu ","tab_")->where(
- array("quick_menu_id"=>$menu_id,
- "promote_id"=>get_pid())
+ if ($info) {
+ M("promote_quick_menu ", "tab_")->where(
+ array("quick_menu_id" => $menu_id,
+ "promote_id" => get_pid())
)->delete();
- $this->ajaxReturn(['status'=>1,'info'=>'移除成功'],"JSON");
- }else{
- M("promote_quick_menu ","tab_")->add(
- array("quick_menu_id"=>$menu_id,
- "promote_id"=>get_pid(),
- "create_time"=>time())
+ $this->ajaxReturn(['status' => 1, 'info' => '移除成功'], "JSON");
+ } else {
+ M("promote_quick_menu ", "tab_")->add(
+ array("quick_menu_id" => $menu_id,
+ "promote_id" => get_pid(),
+ "create_time" => time())
);
- $this->ajaxReturn(['status'=>1,'info'=>'添加成功'],"JSON");
+ $this->ajaxReturn(['status' => 1, 'info' => '添加成功'], "JSON");
}
}
// 消息列表
- public function msg_list($type=56,$p=0){
+ public function msg_list($type = 56, $p = 0)
+ {
if (isset($_REQUEST['row'])) {
$row = $_REQUEST['row'];
} else {
$row = 10;
}
$page = $p ? $p : 1; //默认显示第一页数据
- if($type==51){
- $data_list = M("document","sys_")->where("category_id=51 and status=1")->order("update_time desc") ->page($page, $row)->select(); //游戏咨询
- $count = M("document","sys_")->where("category_id=51 and status=1")->count();
- }elseif ($type==50){
+ if ($type == 51) {
+ $data_list = M("document", "sys_")->where("category_id=51 and status=1")->order("update_time desc")->page($page, $row)->select(); //游戏咨询
+ $count = M("document", "sys_")->where("category_id=51 and status=1")->count();
+ } elseif ($type == 50) {
$data_list = null;
$count = 0;
- }else{
- $data_list = M("document","sys_")->limit('0,50')->where("category_id=56 and status=1")->order("update_time desc")->page($page, $row)->select(); //游戏公告
- $count = M("document","sys_")->where("category_id=56 and status=1")->count();
+ } else {
+ $data_list = M("document", "sys_")->limit('0,50')->where("category_id=56 and status=1")->order("update_time desc")->page($page, $row)->select(); //游戏公告
+ $count = M("document", "sys_")->where("category_id=56 and status=1")->count();
}
$parameter['p'] = I('get.p', 1);
$parameter['row'] = I('get.row');
@@ -368,24 +379,25 @@ class PromoteController extends BaseController
// $this->error('请输入昵称', U('Promote/base_info'));
// exit();
//}
- if ( empty($_REQUEST['real_name']) ) {
+ if (empty($_REQUEST['real_name'])) {
$this->error('请输入联系人姓名', U('Promote/base_info'));
exit();
}
$pattern = "/^[\x{4e00}-\x{9fa5}]+$/u";
- if(!preg_match($pattern,$_REQUEST['real_name'])){
+ if (!preg_match($pattern, $_REQUEST['real_name'])) {
$this->error('联系人姓名错误', U('Promote/base_info'));
exit();
}
- if ( empty($_REQUEST['email'])) {
+ if (empty($_REQUEST['email'])) {
$this->error('请输入电子邮箱', U('Promote/base_info'));
exit();
}
$pattern = "/^([0-9A-Za-z\\-_\\.]+)@([0-9a-z]+\\.[a-z]{2,3}(\\.[a-z]{2})?)$/i";
- if ( !preg_match( $pattern, $_REQUEST['email'] ) ){
- $this->error('邮箱地址错误', U('Promote/base_info'));exit;
+ if (!preg_match($pattern, $_REQUEST['email'])) {
+ $this->error('邮箱地址错误', U('Promote/base_info'));
+ exit;
}
// if (empty($_REQUEST['alipay_account']) ) {
// $this->error('请输入支付宝账号', U('Promote/base_info'));
@@ -399,12 +411,12 @@ class PromoteController extends BaseController
break;
case 1:
- if(empty($_REQUEST['mobile_phone']) ){
+ if (empty($_REQUEST['mobile_phone'])) {
$this->error('结算手机号不能为空', U('Promote/base_info'));
return false;
}
$pattern = "/^1[3|5|7|8]\\d{9}$/i";
- if ( !preg_match( $pattern, $_REQUEST['mobile_phone'] ) ){
+ if (!preg_match($pattern, $_REQUEST['mobile_phone'])) {
$this->error('您输入的手机号码格式不合法', U('Promote/base_info'));
}
if ($_REQUEST['s_county'] === "市、县级市") {
@@ -412,47 +424,47 @@ class PromoteController extends BaseController
return false;
exit();
}
- if(empty($_REQUEST['account_openin']) ){
+ if (empty($_REQUEST['account_openin'])) {
$this->error('开户网点不能为空', U('Promote/base_info'));
return false;
}
$account_openin_pattern = "/^[\x{4e00}-\x{9fa5}]{2,}$/u";
- if(!preg_match($account_openin_pattern,$_REQUEST['account_openin'])){
+ if (!preg_match($account_openin_pattern, $_REQUEST['account_openin'])) {
$this->error('开户网点错误', U('Promote/base_info'));
exit();
}
- if(empty($_REQUEST['bank_name']) ){
+ if (empty($_REQUEST['bank_name'])) {
$this->error('收款银行不能为空', U('Promote/base_info'));
return false;
}
- if(empty($_REQUEST['bank_card']) ){
+ if (empty($_REQUEST['bank_card'])) {
$this->error('银行卡号不能为空', U('Promote/base_info'));
return false;
}
- if(!is_numeric($_REQUEST['bank_card'])){
+ if (!is_numeric($_REQUEST['bank_card'])) {
$this->error('卡号格式错误', U('Promote/base_info'));
return false;
}
$bank_card_pattern = "/^\d{10,19}$/u";
- if(!preg_match($bank_card_pattern,$_REQUEST['bank_card'])){
+ if (!preg_match($bank_card_pattern, $_REQUEST['bank_card'])) {
$this->error('卡号格式错误', U('Promote/base_info'));
exit();
}
- if(empty($_REQUEST['bank_account']) ){
+ if (empty($_REQUEST['bank_account'])) {
$this->error('银行户名不能为空', U('Promote/base_info'));
return false;
}
$bank_account_pattern = "/^[\x{4e00}-\x{9fa5}]{2,}$/u";
- if(!preg_match($bank_account_pattern,$_REQUEST['bank_account'])){
+ if (!preg_match($bank_account_pattern, $_REQUEST['bank_account'])) {
$this->error('银行卡开户人姓名错误', U('Promote/base_info'));
exit();
}
- if(empty($_REQUEST['idcard']) ){
+ if (empty($_REQUEST['idcard'])) {
$this->error('证件号码不能为空', U('Promote/base_info'));
exit();
}
- if(!is_idcard($_REQUEST['idcard'])) {
+ if (!is_idcard($_REQUEST['idcard'])) {
$this->error('证件号码错误', U('Promote/base_info'));
exit();
}
@@ -467,39 +479,39 @@ class PromoteController extends BaseController
$se['idcard'] = $_REQUEST['idcard'];
break;
case 2:
- if($_REQUEST['old_password'] !="0" && empty($_REQUEST['old_password']) ){
+ if ($_REQUEST['old_password'] != "0" && empty($_REQUEST['old_password'])) {
$this->error('旧密码不能为空', U('Promote/base_info'));
return false;
}
- if(strlen($_REQUEST['old_password']) <6 ){
+ if (strlen($_REQUEST['old_password']) < 6) {
$this->error('旧密码不正确', U('Promote/base_info'));
return false;
}
- if($_REQUEST['password'] != "0" && empty($_REQUEST['password']) ){
+ if ($_REQUEST['password'] != "0" && empty($_REQUEST['password'])) {
$this->error('新密码不能为空', U('Promote/base_info'));
return false;
}
- if(strlen($_REQUEST['password']) <6 ){
+ if (strlen($_REQUEST['password']) < 6) {
$this->error('新密码最短6位', U('Promote/base_info'));
return false;
}
- if( empty($_REQUEST['confirm_password'])){
+ if (empty($_REQUEST['confirm_password'])) {
$this->error('确认密码不能为空', U('Promote/base_info'));
return false;
}
- if(strlen($_REQUEST['confirm_password'])<6 ){
+ if (strlen($_REQUEST['confirm_password']) < 6) {
$this->error('确认密码最短6位', U('Promote/base_info'));
return false;
}
$prp = M("promote", "tab_")->where($map)->find();
$ue = new UserApi();
- if($_REQUEST['password'] !== $_REQUEST['confirm_password']){
+ if ($_REQUEST['password'] !== $_REQUEST['confirm_password']) {
$this->error('新密码和确认密码不一致', U('Promote/base_info'));
return false;
} else {
$se['password'] = $this->think_ucenter_md5($_REQUEST['confirm_password'], UC_AUTH_KEY);
}
- if($this->think_ucenter_md5($_REQUEST['old_password'], UC_AUTH_KEY) !== $prp['password']) {
+ if ($this->think_ucenter_md5($_REQUEST['old_password'], UC_AUTH_KEY) !== $prp['password']) {
$this->error('请输入正确的旧密码', U('Promote/base_info'));
return false;
exit();
@@ -509,28 +521,28 @@ class PromoteController extends BaseController
case 3:
$prp = M("promote", "tab_")->where($map)->find();
$ue = new UserApi();
- if($_REQUEST['old_second_pwd'] != "0" && empty($_REQUEST['old_second_pwd']) && !empty($prp['second_pwd'])){
+ if ($_REQUEST['old_second_pwd'] != "0" && empty($_REQUEST['old_second_pwd']) && !empty($prp['second_pwd'])) {
$this->error('旧二级密码不能为空', U('Promote/base_info'));
return false;
}
- if(strlen($_REQUEST['old_second_pwd']) <6 && !empty($prp['second_pwd'])){
+ if (strlen($_REQUEST['old_second_pwd']) < 6 && !empty($prp['second_pwd'])) {
$this->error('旧二级密码不正确', U('Promote/base_info'));
return false;
}
- if($_REQUEST['second_pwd'] !="0" && empty($_REQUEST['second_pwd']) ){
+ if ($_REQUEST['second_pwd'] != "0" && empty($_REQUEST['second_pwd'])) {
$this->error('新二级密码不能为空', U('Promote/base_info'));
return false;
}
- if(strlen($_REQUEST['second_pwd']) <6 ){
+ if (strlen($_REQUEST['second_pwd']) < 6) {
$this->error('新二级密码长度不能小于6', U('Promote/base_info'));
return false;
}
- if (empty($_REQUEST['confirm_second_pwd'])){
+ if (empty($_REQUEST['confirm_second_pwd'])) {
$this->error('请输入确认密码', U('Promote/base_info'));
return false;
}
- if ($_REQUEST[''] != $_REQUEST['']){
+ if ($_REQUEST[''] != $_REQUEST['']) {
$this->error('新耳机密码和确认密码不一致', U('Promote/base_info'));
return false;
}
@@ -568,9 +580,9 @@ class PromoteController extends BaseController
$this->wxQrcode($data);
$user = D('Promote')->isLogin();
if (empty($user)) {
- $this->redirect("Home/Index/index");
+ $this->redirect("Home/Index/index");
}
- $promoteUrl = "https://m.wmtxkj.com/mobile.php?s=Ssg/login/promote_id/".$user['pid'];
+ $promoteUrl = "https://m.wmtxkj.com/mobile.php?s=Ssg/login/promote_id/" . $user['pid'];
$this->assign("promote_url", $promoteUrl);
$this->display();
@@ -597,7 +609,7 @@ class PromoteController extends BaseController
$model = new PromoteModel();
$promotes = $model->field(['id', 'account'])->where('parent_id=' . $promoteId)->select();
- $subPromotes = $model->field(['id', 'account'])->where('parent_id='. $promoteId . ' or grand_id=' . $promoteId . ' or id=' . $promoteId)->select();
+ $subPromotes = $model->field(['id', 'account'])->where('parent_id=' . $promoteId . ' or grand_id=' . $promoteId . ' or id=' . $promoteId)->select();
$map = [];
if ($account) {
@@ -617,7 +629,7 @@ class PromoteController extends BaseController
}
$map['parent_id'] = session("promote_auth.pid");
- $appendCallback = function($data) {
+ $appendCallback = function ($data) {
$promote = new PromoteModel();
$player = new UserPlayModel();
$ids = array_column($data, 'id');
@@ -635,7 +647,7 @@ class PromoteController extends BaseController
$parentList = $promote->field(['id', 'account'])->where(['id' => ['in', $parentIds]])->select();
$parentPromotes = [];
- foreach($parentList as $parent) {
+ foreach ($parentList as $parent) {
$parentPromotes[$parent['id']] = $parent['account'];
}
@@ -671,7 +683,7 @@ class PromoteController extends BaseController
$promoteId = session("promote_auth.pid");
$model = new PromoteModel();
$promotes = $model->field(['id', 'account'])->where('parent_id=' . $promoteId)->select();
- $subPromotes = $model->field(['id', 'account'])->where('parent_id='. $promoteId . ' or grand_id=' . $promoteId . ' or id=' . $promoteId)->select();
+ $subPromotes = $model->field(['id', 'account'])->where('parent_id=' . $promoteId . ' or grand_id=' . $promoteId . ' or id=' . $promoteId)->select();
$map = [];
if ($account) {
@@ -700,7 +712,7 @@ class PromoteController extends BaseController
$map['parent_id'] = session("promote_auth.pid");
}
- $appendCallback = function($data) use($promote) {
+ $appendCallback = function ($data) use ($promote) {
$promoteModel = new PromoteModel();
$player = new UserPlayModel();
$ids = array_column($data, 'id');
@@ -716,12 +728,12 @@ class PromoteController extends BaseController
$parentList = $promoteModel->field(['id', 'account'])->where(['id' => ['in', $parentIds]])->select();
$parentPromotes = [];
- foreach($parentList as $parent) {
+ foreach ($parentList as $parent) {
$parentPromotes[$parent['id']] = $parent['account'];
}
$list = [];
- foreach($data as $key => $item) {
+ foreach ($data as $key => $item) {
if ($promote['parent_id'] > 0 && $promote['grand_id'] == 0) {
$item['idcard'] = hideStar($item['idcard'], 4, 10);
$item['mobile_phone'] = hideStar($item['mobile_phone'], 3, 4);
@@ -753,7 +765,7 @@ class PromoteController extends BaseController
$parentId = 0;
if (isset($_POST['promote_type']) && $_POST['promote_type'] == 2 && isset($_POST['parent_id'])) {
if ($_POST['parent_id'] == 0) {
- $this->ajaxReturn(array('status'=>-1,'msg'=>'请选择上级渠道'));
+ $this->ajaxReturn(array('status' => -1, 'msg' => '请选择上级渠道'));
}
$parentId = $_POST['parent_id'];
} else {
@@ -763,7 +775,7 @@ class PromoteController extends BaseController
$user = new PromoteApi();
$promote = D('promote')->where(['id' => $parentId])->find();
- $status = promoteCan(session('promote_auth.pid'), function($level) use ($promote) {
+ $status = promoteCan(session('promote_auth.pid'), function ($level) use ($promote) {
if ($level == 1) {
return true;
} elseif ($level == 2) {
@@ -773,40 +785,40 @@ class PromoteController extends BaseController
}
});
if (!$status) {
- $this->ajaxReturn(array('status'=>-1, 'msg'=>'无权限操作'));
+ $this->ajaxReturn(array('status' => -1, 'msg' => '无权限操作'));
}
$_POST['ba_id'] = $promote['ba_id'];
$_POST['parent_id'] = $parentId;
$_POST['parent_account'] = $promote['account'];
//三级渠道
- if($promote['parent_id']>0){
+ if ($promote['parent_id'] > 0) {
$_POST['grand_id'] = $promote['parent_id'];
$_POST['grand_account'] = $promote['promote_account'];
}
if (isset($_POST['mobile_phone'])) {
- if(!preg_match("/^1[3456789]{1}\d{9}$/", $_POST['mobile_phone'])){
- $this->ajaxReturn(array('status'=>-1,'msg'=>'手机号格式错误'));
+ if (!preg_match("/^1[3456789]{1}\d{9}$/", $_POST['mobile_phone'])) {
+ $this->ajaxReturn(array('status' => -1, 'msg' => '手机号格式错误'));
}
}
if (isset($_POST['idcard'])) {
- if(!$this->isIdcard($_POST['idcard'])){
- $this->ajaxReturn(array('status'=>-1,'msg'=>'身份证格式错误'));
+ if (!$this->isIdcard($_POST['idcard'])) {
+ $this->ajaxReturn(array('status' => -1, 'msg' => '身份证格式错误'));
}
}
$res = $user->promote_add($_POST);
if (is_numeric($res)) {
$ba = new \Admin\Model\BusinessAffairsModel();
- $ba->add_child($_POST['ba_id'],$res);
- $this->ajaxReturn(array('status'=>1,'msg'=>"添加成功"));
+ $ba->add_child($_POST['ba_id'], $res);
+ $this->ajaxReturn(array('status' => 1, 'msg' => "添加成功"));
} else {
- $msg = $res =="渠道账号已存在"?"子渠道账号已存在":$res;
- $this->ajaxReturn(array('status'=>-1,'msg'=>$msg));
+ $msg = $res == "渠道账号已存在" ? "子渠道账号已存在" : $res;
+ $this->ajaxReturn(array('status' => -1, 'msg' => $msg));
}
} else {
$type = I('type', 0);
- $status = promoteCan(session('promote_auth.pid'), function($level) use ($type) {
+ $status = promoteCan(session('promote_auth.pid'), function ($level) use ($type) {
if ($level == 1) {
return true;
} elseif ($level == 2) {
@@ -835,14 +847,14 @@ class PromoteController extends BaseController
{
$promoteId = I('promote_id', 0);
if ($promoteId == 0) {
- $this->ajaxReturn(['status'=>0,'msg'=>"参数错误"]);
+ $this->ajaxReturn(['status' => 0, 'msg' => "参数错误"]);
}
$promoteService = new PromoteService();
if ($password = $promoteService->resetPassword($promoteId)) {
- $this->ajaxReturn(['status'=>1, 'msg'=> '重置密码成功', 'data' => ['password' => $password]]);
+ $this->ajaxReturn(['status' => 1, 'msg' => '重置密码成功', 'data' => ['password' => $password]]);
} else {
- $this->ajaxReturn(['status'=>0, 'msg'=> '重置密码失败']);
+ $this->ajaxReturn(['status' => 0, 'msg' => '重置密码失败']);
}
}
@@ -850,13 +862,13 @@ class PromoteController extends BaseController
{
$promoteId = I('promote_id', 0);
if ($promoteId == 0) {
- $this->ajaxReturn(['status'=>0,'msg'=>"参数错误"]);
+ $this->ajaxReturn(['status' => 0, 'msg' => "参数错误"]);
}
$promoteService = new PromoteService();
if ($promoteService->froze($promoteId)) {
- $this->ajaxReturn(['status'=>1, 'msg'=> '冻结成功']);
+ $this->ajaxReturn(['status' => 1, 'msg' => '冻结成功']);
} else {
- $this->ajaxReturn(['status'=>0, 'msg'=> '冻结失败']);
+ $this->ajaxReturn(['status' => 0, 'msg' => '冻结失败']);
}
}
@@ -864,13 +876,13 @@ class PromoteController extends BaseController
{
$promoteId = I('promote_id', 0);
if ($promoteId == 0) {
- $this->ajaxReturn(['status'=>0,'msg'=>"参数错误"]);
+ $this->ajaxReturn(['status' => 0, 'msg' => "参数错误"]);
}
$promoteService = new PromoteService();
if ($promoteService->unfreeze($promoteId)) {
- $this->ajaxReturn(['status'=>1, 'msg'=> '解冻成功']);
+ $this->ajaxReturn(['status' => 1, 'msg' => '解冻成功']);
} else {
- $this->ajaxReturn(['status'=>0, 'msg'=> '解冻失败']);
+ $this->ajaxReturn(['status' => 0, 'msg' => '解冻失败']);
}
}
@@ -885,49 +897,49 @@ class PromoteController extends BaseController
}
switch ($type) {
case 0:
- if (empty($_REQUEST['nickname']) ) {
- $this->error('子账号昵称不能为空', U('Promote/edit_chlid',array('id'=>$id,'type'=>I('type',0))));
+ if (empty($_REQUEST['nickname'])) {
+ $this->error('子账号昵称不能为空', U('Promote/edit_chlid', array('id' => $id, 'type' => I('type', 0))));
exit();
}
if ($_POST['password'] != "0" && empty($_POST['password'])) {
unset($_POST['password']);
- }else{
- if(strlen($_REQUEST['password'])<6 ){
- $this->error('登录密码不能小于6位字符', U('Promote/edit_chlid',array('id'=>$id,'type'=>I('type',0))));
+ } else {
+ if (strlen($_REQUEST['password']) < 6) {
+ $this->error('登录密码不能小于6位字符', U('Promote/edit_chlid', array('id' => $id, 'type' => I('type', 0))));
return false;
}
}
- if ( empty($_REQUEST['real_name']) ) {
- $this->error('联系人姓名不能为空', U('Promote/edit_chlid',array('id'=>$id,'type'=>I('type',0))));
+ if (empty($_REQUEST['real_name'])) {
+ $this->error('联系人姓名不能为空', U('Promote/edit_chlid', array('id' => $id, 'type' => I('type', 0))));
exit();
}
$pattern = "/^[\x{4e00}-\x{9fa5}]+$/u";
- if(!preg_match($pattern,$_REQUEST['real_name'])){
- $this->error('您输入的联系人姓名格式不正确', U('Promote/edit_chlid',array('id'=>$id,'type'=>I('type',0))));
+ if (!preg_match($pattern, $_REQUEST['real_name'])) {
+ $this->error('您输入的联系人姓名格式不正确', U('Promote/edit_chlid', array('id' => $id, 'type' => I('type', 0))));
exit();
}
- if(empty($_REQUEST['mobile_phone']) ){
- $this->error('手机号不能为空', U('Promote/edit_chlid',array('id'=>$id,'type'=>I('type',0))));
+ if (empty($_REQUEST['mobile_phone'])) {
+ $this->error('手机号不能为空', U('Promote/edit_chlid', array('id' => $id, 'type' => I('type', 0))));
return false;
}
$pattern = "/^1[3|5|7|8]\\d{9}$/i";
- if ( !preg_match( $pattern, $_REQUEST['mobile_phone'] ) ){
- $this->error('您输入的手机号码格式不合法', U('Promote/edit_chlid',array('id'=>$id,'type'=>I('type',0))));
+ if (!preg_match($pattern, $_REQUEST['mobile_phone'])) {
+ $this->error('您输入的手机号码格式不合法', U('Promote/edit_chlid', array('id' => $id, 'type' => I('type', 0))));
}
- if(empty($_REQUEST['email']) ){
- $this->error('电子邮箱不能为空', U('Promote/edit_chlid',array('id'=>$id,'type'=>I('type',0))));
+ if (empty($_REQUEST['email'])) {
+ $this->error('电子邮箱不能为空', U('Promote/edit_chlid', array('id' => $id, 'type' => I('type', 0))));
return false;
}
$pattern = "/^([0-9A-Za-z\\-_\\.]+)@([0-9a-z]+\\.[a-z]{2,3}(\\.[a-z]{2})?)$/i";
- if ( !preg_match( $pattern, $_REQUEST['email'] ) ){
- $this->error('您输入的电子邮箱地址不合法', U('Promote/edit_chlid',array('id'=>$id,'type'=>I('type',0))));
+ if (!preg_match($pattern, $_REQUEST['email'])) {
+ $this->error('您输入的电子邮箱地址不合法', U('Promote/edit_chlid', array('id' => $id, 'type' => I('type', 0))));
};
$user = new PromoteApi();
@@ -941,42 +953,42 @@ class PromoteController extends BaseController
break;
case 1:
if ($_REQUEST['s_county'] === "市、县级市") {
- $this->error('开户城市填写不完整',U('Promote/edit_chlid',array('id'=>$id,'type'=>I('type',1))));
+ $this->error('开户城市填写不完整', U('Promote/edit_chlid', array('id' => $id, 'type' => I('type', 1))));
return false;
exit();
}
- if(empty($_REQUEST['account_openin']) ){
- $this->error('开户网点不能为空', U('Promote/edit_chlid',array('id'=>$id,'type'=>I('type',1))));
+ if (empty($_REQUEST['account_openin'])) {
+ $this->error('开户网点不能为空', U('Promote/edit_chlid', array('id' => $id, 'type' => I('type', 1))));
return false;
}
- if(empty($_REQUEST['bank_name']) ){
- $this->error('收款银行不能为空', U('Promote/edit_chlid',array('id'=>$id,'type'=>I('type',1))));
+ if (empty($_REQUEST['bank_name'])) {
+ $this->error('收款银行不能为空', U('Promote/edit_chlid', array('id' => $id, 'type' => I('type', 1))));
return false;
}
- if(empty($_REQUEST['bank_card']) ){
- $this->error('银行卡号不能为空', U('Promote/edit_chlid',array('id'=>$id,'type'=>I('type',1))));
+ if (empty($_REQUEST['bank_card'])) {
+ $this->error('银行卡号不能为空', U('Promote/edit_chlid', array('id' => $id, 'type' => I('type', 1))));
return false;
}
- if(!is_numeric($_REQUEST['bank_card']) ){
- $this->error('请输入正确的银行卡号', U('Promote/edit_chlid',array('id'=>$id,'type'=>I('type',1))));
+ if (!is_numeric($_REQUEST['bank_card'])) {
+ $this->error('请输入正确的银行卡号', U('Promote/edit_chlid', array('id' => $id, 'type' => I('type', 1))));
return false;
}
- if(empty($_REQUEST['bank_account']) ){
- $this->error('银行户名不能为空', U('Promote/edit_chlid',array('id'=>$id,'type'=>I('type',1))));
+ if (empty($_REQUEST['bank_account'])) {
+ $this->error('银行户名不能为空', U('Promote/edit_chlid', array('id' => $id, 'type' => I('type', 1))));
return false;
}
- $se['mobile_phone'] = $_REQUEST['mobile_phone'];
- $se['bank_name'] = $_REQUEST['bank_name'];
- $se['bank_card'] = $_REQUEST['bank_card'];
- $se['bank_account'] = $_REQUEST['bank_account'];
+ $se['mobile_phone'] = $_REQUEST['mobile_phone'];
+ $se['bank_name'] = $_REQUEST['bank_name'];
+ $se['bank_card'] = $_REQUEST['bank_card'];
+ $se['bank_account'] = $_REQUEST['bank_account'];
$se['account_openin'] = $_REQUEST['account_openin'];
- $se['bank_area'] = $_REQUEST['s_province'] . ',' . $_REQUEST['s_city'] . ',' . $_REQUEST['s_county'];
+ $se['bank_area'] = $_REQUEST['s_province'] . ',' . $_REQUEST['s_city'] . ',' . $_REQUEST['s_county'];
$res = M("promote", "tab_")->where($map)->save($se);
if ($res !== false) {
- $this->success("修改成功", U('Promote/edit_chlid',array('id'=>$id,'type'=>$type)));
+ $this->success("修改成功", U('Promote/edit_chlid', array('id' => $id, 'type' => $type)));
} else {
- $this->error('修改失败', U('Promote/edit_chlid',array('id'=>$id,'type'=>$type)));
+ $this->error('修改失败', U('Promote/edit_chlid', array('id' => $id, 'type' => $type)));
}
break;
}
@@ -993,9 +1005,10 @@ class PromoteController extends BaseController
* @param int $level
* @param int $size
*/
- public function qrcode($level=3,$size=4,$url=""){
+ public function qrcode($level = 3, $size = 4, $url = "")
+ {
Vendor('phpqrcode.phpqrcode');
- $errorCorrectionLevel =intval($level) ;//容错级别
+ $errorCorrectionLevel = intval($level);//容错级别
$matrixPointSize = intval($size);//生成图片大小
//生成二维码图片
ob_clean();
@@ -1003,34 +1016,36 @@ class PromoteController extends BaseController
echo $object->png(base64_decode(base64_decode($url)), false, $errorCorrectionLevel, $matrixPointSize, 2);
}
- public function checkAccount($account){
+ public function checkAccount($account)
+ {
$user = get_promote_entity($account, true);
- if($user){
- $this->ajaxReturn(array('status'=>1));
- }else{
- $this->ajaxReturn(array('status'=>0));
+ if ($user) {
+ $this->ajaxReturn(array('status' => 1));
+ } else {
+ $this->ajaxReturn(array('status' => 0));
}
}
- public function balance() {
+
+ public function balance()
+ {
if (IS_POST) {
$real_amount = $amount = I('amount');
-
- if(!is_numeric($amount)){
+ if (!is_numeric($amount)) {
$res_msg = '充值金额不是数字';
$this->show_balance();
echo ";
return false;";
- $this->redirect('balance', array('status'=>1), 3, '');
+ $this->redirect('balance', array('status' => 1), 3, '');
}
- if($amount<0) {
+ if ($amount < 0) {
$res_msg = '充值金额不正确';
$this->show_balance();
echo ";
return false;";
- $this->redirect('balance', array('status'=>1), 3, '');
+ $this->redirect('balance', array('status' => 1), 3, '');
}
$amount = abs($amount);
// $amount = 0.01;//测试金额
@@ -1096,21 +1111,21 @@ class PromoteController extends BaseController
exit();
}
- if(empty(C('goldpig.partner'))||empty(C('goldpig.wooolid'))) {
+ if (empty(C('goldpig.partner')) || empty(C('goldpig.wooolid'))) {
$this->error("网站未配置金猪充值", '', 1);
exit();
}
- if($amount<1) {
+ if ($amount < 1) {
$this->error("单笔金额不小于1", '', 1);
exit();
}
- $sign=think_encrypt(md5($real_amount.$order_no));
+ $sign = think_encrypt(md5($real_amount . $order_no));
$create['pay_way'] = 8;
$this->add_balance($user, $create);
- file_put_contents("./Application/Home/OrderNo/".$order_no.'.txt',json_encode($create));
- redirect(U('goldpig_pay',array('userid'=>$user['id'],'account' =>$user['account'],'pay_amount'=>$real_amount,'sign'=>$sign,'pay_order_number'=>$order_no)));
+ file_put_contents("./Application/Home/OrderNo/" . $order_no . '.txt', json_encode($create));
+ redirect(U('goldpig_pay', array('userid' => $user['id'], 'account' => $user['account'], 'pay_amount' => $real_amount, 'sign' => $sign, 'pay_order_number' => $order_no)));
break;
default:
//判断是否开启支付宝充值
@@ -1126,33 +1141,33 @@ class PromoteController extends BaseController
}
-
} else {
$model = M('Promote', 'tab_');
$data = $model->find(session("promote_auth.pid"));
$data['bank_area'] = explode(',', $data['bank_area']);
- $this->assign('data',$data);
+ $this->assign('data', $data);
$this->meta_title = '账户余额';
$this->display();
}
}
- public function balance_recharge() {
+ public function balance_recharge()
+ {
if (IS_POST) {
- $real_amount = $amount = I('amount',0,'intval');
+ $real_amount = $amount = I('amount', 0, 'intval');
//$real_amount = $amount = 0.01;
- if(!is_numeric($amount)){
+ if (!is_numeric($amount)) {
- $this->ajaxReturn(['status'=>0,'info'=>'充值金额不是数字']);
+ $this->ajaxReturn(['status' => 0, 'info' => '充值金额不是数字']);
}
- if($amount<0){
+ if ($amount < 0) {
- $this->ajaxReturn(['status'=>0,'info'=>'充值金额错误']);
+ $this->ajaxReturn(['status' => 0, 'info' => '充值金额错误']);
}
@@ -1184,7 +1199,7 @@ class PromoteController extends BaseController
case 'swiftpass':
//判断是否开启微信充值
if (pay_set_status('wei_xin') == 0 && pay_set_status('weixin') == 0) {
- $this->ajaxReturn(['status'=>0,'info'=>'网站未开启微信充值']);
+ $this->ajaxReturn(['status' => 0, 'info' => '网站未开启微信充值']);
}
if (get_wx_type() == 0) {
$weixn = new Weixin();
@@ -1198,7 +1213,7 @@ class PromoteController extends BaseController
$create['pay_way'] = 2;
$this->add_balance($user, $create);
- $this->ajaxReturn(['status'=>1,'info'=>'','data'=>$json_]);
+ $this->ajaxReturn(['status' => 1, 'info' => '', 'data' => $json_]);
} else {
$vo->setService("pay.weixin.native")
@@ -1207,26 +1222,25 @@ class PromoteController extends BaseController
$all = $pay->buildRequestForm($vo);
$all['amount'] = $vo->getMoney();
- $this->ajaxReturn(['status'=>1,'info'=>'','data'=>$all]);
+ $this->ajaxReturn(['status' => 1, 'info' => '', 'data' => $all]);
}
break;
default:
//判断是否开启支付宝充值
if (pay_set_status('alipay') == 0) {
- $this->ajaxReturn(['status'=>0,'info'=>'网站未开启支付宝充值']);
+ $this->ajaxReturn(['status' => 0, 'info' => '网站未开启支付宝充值']);
}
$vo->setService("create_direct_pay_by_user")
->setPayWay(1);
$pay = new \Think\Pay('alipay', C('alipay'));
$url = $pay->buildRequestForm($vo);
- $this->ajaxReturn(['status'=>1,'info'=>'','url'=>$url]);
+ $this->ajaxReturn(['status' => 1, 'info' => '', 'url' => $url]);
}
-
} else {
- $this->ajaxReturn(['status'=>0,'info'=>'请求有误']);
+ $this->ajaxReturn(['status' => 0, 'info' => '请求有误']);
}
}
@@ -1237,22 +1251,25 @@ class PromoteController extends BaseController
* @return [type] [description]
* @author cb <[email address]>
*/
- public function goldpig_pay(){
- if(IS_POST){
+ public function goldpig_pay()
+ {
+ if (IS_POST) {
SafeFilter($_POST);
- $msign=think_encrypt(md5($_POST['amount'].$_POST['pay_order_number']));
- if($msign!==$_POST['sign']){
- $this->error('验证失败',U('promote/balance'));exit;
+ $msign = think_encrypt(md5($_POST['amount'] . $_POST['pay_order_number']));
+ if ($msign !== $_POST['sign']) {
+ $this->error('验证失败', U('promote/balance'));
+ exit;
}
- if($_POST['amount']<=0){
+ if ($_POST['amount'] <= 0) {
$this->error('金额有误');
}
- $url="./Application/Home/OrderNo/".$_POST['pay_order_number'].'.txt';
- if(!file_exists($url) ){
- $this->error('操作有误',U('promote/balance'));exit;
+ $url = "./Application/Home/OrderNo/" . $_POST['pay_order_number'] . '.txt';
+ if (!file_exists($url)) {
+ $this->error('操作有误', U('promote/balance'));
+ exit;
}
- $user = M('Promote','tab_')->field('id,account')->where(['account'=>$_POST['UserName']])->find();
+ $user = M('Promote', 'tab_')->field('id,account')->where(['account' => $_POST['UserName']])->find();
if (empty($user)) {
$this->error("账号不存在");
@@ -1264,9 +1281,10 @@ class PromoteController extends BaseController
$url = $baseurl . "UserName={$_POST['UserName']}&Price={$_POST['amount']}&shouji={$_POST['shouji']}&PayID={$_POST['PayID']}&userid={$_POST['userid']}&wooolID={$_POST['wooolID']}&jinzhua={$_POST['pay_order_number']}&jinzhub={$_POST['jinzhub']}&jinzhuc={$_POST['jinzhuc']}&jinzhue={$_POST['pay_order_number']}";
- redirect($url);exit;
+ redirect($url);
+ exit;
- }else{
+ } else {
$this->display();
}
@@ -1274,57 +1292,61 @@ class PromoteController extends BaseController
}
- public function show_balance() {
+ public function show_balance()
+ {
$model = M('Promote', 'tab_');
$data = $model->find(session("promote_auth.pid"));
$data['bank_area'] = explode(',', $data['bank_area']);
- $this->assign('data',$data);
+ $this->assign('data', $data);
$this->meta_title = '账户余额';
$this->display('balance');
}
- public function checkOrder($order_number){
+ public function checkOrder($order_number)
+ {
$map['pay_order_number'] = $order_number;
- $data = M('Balance','tab_')
+ $data = M('Balance', 'tab_')
->where($map)
->field('pay_status')
->find();
- if ($data['pay_status'] == 1){
+ if ($data['pay_status'] == 1) {
$this->success('支付成功');
- }else{
+ } else {
$this->error('暂未支付');
}
}
- public function add_balance($promote,$data){
- $balance = M("Balance","tab_");
- $balance_data['order_number'] = "";
- $balance_data['pay_order_number'] = $data['pay_order_number'];
- $balance_data['money'] = $data['amount'];
- $balance_data['balance'] = $promote['balance_coin'];
- $balance_data['pay_status'] = 0;
- $balance_data['recharge_type'] = $data['pay_way'];
- $balance_data['create_time'] = time();
- $balance_data['recharge_id'] = $promote['id'];
- $balance_data['recharge_account'] = $promote['account'];
- $balance_data['promote_id'] = PID;
- $balance_data['promote_account'] = PROMOTE_ACCOUNT;
+ public function add_balance($promote, $data)
+ {
+ $balance = M("Balance", "tab_");
+ $balance_data['order_number'] = "";
+ $balance_data['pay_order_number'] = $data['pay_order_number'];
+ $balance_data['money'] = $data['amount'];
+ $balance_data['balance'] = $promote['balance_coin'];
+ $balance_data['pay_status'] = 0;
+ $balance_data['recharge_type'] = $data['pay_way'];
+ $balance_data['create_time'] = time();
+ $balance_data['recharge_id'] = $promote['id'];
+ $balance_data['recharge_account'] = $promote['account'];
+ $balance_data['promote_id'] = PID;
+ $balance_data['promote_account'] = PROMOTE_ACCOUNT;
$balance->create($balance_data);
$result = $balance->add();
return $result;
}
- public function wxQrcode($promote='') {
- if (C('wechat.status')>0) {
- $appid = C('wechat.appid');
+ public function wxQrcode($promote = '')
+ {
+ if (C('wechat.status') > 0) {
+ $appid = C('wechat.appid');
$appsecret = C('wechat.appsecret');
$token = session("token");
- if($token){
+ if ($token) {
$auth = new WechatAuth($appid, $appsecret, $token);
} else {
- $auth = new WechatAuth($appid, $appsecret);
+ $auth = new WechatAuth($appid, $appsecret);
$token = $auth->getAccessToken();
session(array('expire' => $token['expires_in']));
@@ -1334,29 +1356,30 @@ class PromoteController extends BaseController
$promote = D('promote')->detail();
}
- $sign = $promote['weixin_openid_sign']?$promote['weixin_openid_sign']:rand(1,99999);
+ $sign = $promote['weixin_openid_sign'] ? $promote['weixin_openid_sign'] : rand(1, 99999);
- $ticket = $auth->qrcodeCreate($sign,604800);
+ $ticket = $auth->qrcodeCreate($sign, 604800);
- $this->assign('wxQrcodeUrl',$ticket['url']);
+ $this->assign('wxQrcodeUrl', $ticket['url']);
} else {
- $this->assign('wxQrcodeUrl',null);
+ $this->assign('wxQrcodeUrl', null);
}
}
- public function wxQrcodeRedirect() {
+ public function wxQrcodeRedirect()
+ {
$xml_str = $GLOBALS['HTTP_RAW_POST_DATA'];
$this->logger($xml_str);
- if(!empty($xml_str)){
+ if (!empty($xml_str)) {
libxml_disable_entity_loader(true);
$request_xml = simplexml_load_string($xml_str, 'SimpleXMLElement', LIBXML_NOCDATA);
- switch ($request_xml->MsgType){
+ switch ($request_xml->MsgType) {
case 'event':
$this->_setOpenid($request_xml);
break;
@@ -1368,84 +1391,102 @@ class PromoteController extends BaseController
}
- public function _setOpenid($data,$type) {
+ public function _setOpenid($data, $type)
+ {
$event = strtolower($data->Event);
$openid = $data->FromUserName; // 用户
- $auth = new WechatAuth(C('wechat.appid'), C('wechat.appsecret'));
+ $auth = new WechatAuth(C('wechat.appid'), C('wechat.appsecret'));
$model = D('Promote');
$promote = $model->detail();
- $data = array('id'=>$promote['id']);
+ $data = array('id' => $promote['id']);
$user = $auth->userInfo($openid);
- switch($event) {
- case 'subscribe':{
- // 关注事件
- if (!empty($promote['weixin_openid'])) {
- $auth->setText($openid,date('Y-m-d H:i:s').' 请先解绑微信');exit;
- }
- if (str_replace('qrscene_', '', $data['EventKey']) != $promote['weixin_openid_sign']) {
- $auth->setText($openid,date('Y-m-d H:i:s').' 页面错误,请刷新页面重试');exit;
- }
- $data['weixin_account']=emoji_encode($user['nickname']);
- $data['weixin_openid']=$openid;
- $res = $model->update($data);
- if ($res) {
- $auth->sendText($openid,date('Y-m-d H:i:s').' 微信绑定成功');
- } else {
- $auth->sendText($openid,date('Y-m-d H:i:s').' 微信绑定失败');
- }
- };break;
- case 'scan':{
- // 关注以后
- if ($user['subscribe'] != 1) {$auth->setText($openid,date('Y-m-d H:i:s').' 你未关注微信');exit;}
- if (empty($promote['weixin_openid'])) {
- $auth->setText($openid,date('Y-m-d H:i:s').' 请先绑定微信');exit;
- }
+ switch ($event) {
+ case 'subscribe':
+ {
+ // 关注事件
+ if (!empty($promote['weixin_openid'])) {
+ $auth->setText($openid, date('Y-m-d H:i:s') . ' 请先解绑微信');
+ exit;
+ }
+ if (str_replace('qrscene_', '', $data['EventKey']) != $promote['weixin_openid_sign']) {
+ $auth->setText($openid, date('Y-m-d H:i:s') . ' 页面错误,请刷新页面重试');
+ exit;
+ }
+ $data['weixin_account'] = emoji_encode($user['nickname']);
+ $data['weixin_openid'] = $openid;
+ $res = $model->update($data);
+ if ($res) {
+ $auth->sendText($openid, date('Y-m-d H:i:s') . ' 微信绑定成功');
+ } else {
+ $auth->sendText($openid, date('Y-m-d H:i:s') . ' 微信绑定失败');
+ }
+ };
+ break;
+ case 'scan':
+ {
+ // 关注以后
+ if ($user['subscribe'] != 1) {
+ $auth->setText($openid, date('Y-m-d H:i:s') . ' 你未关注微信');
+ exit;
+ }
+ if (empty($promote['weixin_openid'])) {
+ $auth->setText($openid, date('Y-m-d H:i:s') . ' 请先绑定微信');
+ exit;
+ }
- };break;
- case 'unsubscribe':{
- // 取消关注
- if ($promote['weixin_openid'] != $openid) {
- $auth->setText($openid,date('Y-m-d H:i:s').' 对不起,你没有权限');exit;
- }
- if (str_replace('qrscene_', '', $data['EventKey']) != $promote['weixin_openid_sign']) {
- $auth->setText($openid,date('Y-m-d H:i:s').' 页面错误,请刷新页面重试');exit;
- }
- if (empty($promote['weixin_openid'])) {
- $auth->setText($openid,date('Y-m-d H:i:s').' 暂未绑定微信');exit;
- }
- $data['weixin_account']='';
- $data['weixin_openid']='';
- $res = $model->update($data);
- if ($res) {
- $auth->sendText($openid,date('Y-m-d H:i:s').' 微信解绑成功');
- } else {
- $auth->sendText($openid,date('Y-m-d H:i:s').' 微信解绑失败');
- }
+ };
+ break;
+ case 'unsubscribe':
+ {
+ // 取消关注
+ if ($promote['weixin_openid'] != $openid) {
+ $auth->setText($openid, date('Y-m-d H:i:s') . ' 对不起,你没有权限');
+ exit;
+ }
+ if (str_replace('qrscene_', '', $data['EventKey']) != $promote['weixin_openid_sign']) {
+ $auth->setText($openid, date('Y-m-d H:i:s') . ' 页面错误,请刷新页面重试');
+ exit;
+ }
+ if (empty($promote['weixin_openid'])) {
+ $auth->setText($openid, date('Y-m-d H:i:s') . ' 暂未绑定微信');
+ exit;
+ }
+ $data['weixin_account'] = '';
+ $data['weixin_openid'] = '';
+ $res = $model->update($data);
+ if ($res) {
+ $auth->sendText($openid, date('Y-m-d H:i:s') . ' 微信解绑成功');
+ } else {
+ $auth->sendText($openid, date('Y-m-d H:i:s') . ' 微信解绑失败');
+ }
- };break;
+ };
+ break;
}
}
- public function logger($log_content) {
- $fg_str="\n============================================================\n";
+ public function logger($log_content)
+ {
+ $fg_str = "\n============================================================\n";
$max_size = 500000;
- $log_filename = __ROOT__."/Uploads/Logs/log".date('Ymd').".xml";
- if(file_exists($log_filename) and (abs(filesize($log_filename)) > $max_size)){
+ $log_filename = __ROOT__ . "/Uploads/Logs/log" . date('Ymd') . ".xml";
+ if (file_exists($log_filename) and (abs(filesize($log_filename)) > $max_size)) {
unlink($log_filename);
}
- if(is_array($log_content)){
- file_put_contents($log_filename, date('Y-m-d H:i:s')."\n".json_encode($log_content).$fg_str, FILE_APPEND);
+ if (is_array($log_content)) {
+ file_put_contents($log_filename, date('Y-m-d H:i:s') . "\n" . json_encode($log_content) . $fg_str, FILE_APPEND);
- }else{
- file_put_contents($log_filename, date('Y-m-d H:i:s')."\n".$log_content.$fg_str, FILE_APPEND);
+ } else {
+ file_put_contents($log_filename, date('Y-m-d H:i:s') . "\n" . $log_content . $fg_str, FILE_APPEND);
}
}
- public function promoteList($p=1){
+ public function promoteList($p = 1)
+ {
switch ($_GET['type']) {
case '':
@@ -1460,31 +1501,33 @@ class PromoteController extends BaseController
// 推广员列表
const model_name = 'Promote';
- public function promoteLists($p){
+
+ public function promoteLists($p)
+ {
$map = [];
- $map['_string'] = 'id='. session('promote_auth.pid')
+ $map['_string'] = 'id=' . session('promote_auth.pid')
. ' or parent_id=' . session('promote_auth.pid')
. ' or grand_id=' . session('promote_auth.pid');
$selectMap = $map;
- if(isset($_REQUEST['promote_id'])){
+ if (isset($_REQUEST['promote_id'])) {
$promoteid = $_REQUEST['promote_id'];
unset($_REQUEST['promote_id']);
- if(isset($_REQUEST['parent_id'])) {
+ if (isset($_REQUEST['parent_id'])) {
$parent_id = $_REQUEST['parent_id'];
unset($_REQUEST['parent_id']);
- if($promoteid == $parent_id) {
+ if ($promoteid == $parent_id) {
$map['id'] = $promoteid;
} else {
$maps['parent_id'] = $parent_id;
$maps['grand_id'] = $parent_id;
$maps['_logic'] = 'or';
- $pro = M('promote','tab_')->field('id,account')->where([array('id'=>$promoteid),$maps])->select();
+ $pro = M('promote', 'tab_')->field('id,account')->where([array('id' => $promoteid), $maps])->select();
- if (!empty($pro_ids)){
- $map['id'] = array('eq',-1);
+ if (!empty($pro_ids)) {
+ $map['id'] = array('eq', -1);
}
}
@@ -1506,35 +1549,35 @@ class PromoteController extends BaseController
}
} else {
if (isset($_REQUEST['parent_id'])) {
- if ($_REQUEST['parent_id']=='全部') {
+ if ($_REQUEST['parent_id'] == '全部') {
unset($_REQUEST['parent_id']);
}
- $zid=get_zi_promote_id($_REQUEST['parent_id']);
- if($zid){
- $zid=$zid.','.$_REQUEST['parent_id'];
- }else{
- $zid=$_REQUEST['parent_id'];
+ $zid = get_zi_promote_id($_REQUEST['parent_id']);
+ if ($zid) {
+ $zid = $zid . ',' . $_REQUEST['parent_id'];
+ } else {
+ $zid = $_REQUEST['parent_id'];
}
- $map['id']=array('in',$zid);
+ $map['id'] = array('in', $zid);
unset($_REQUEST['parent_id']);
}
}
- if(isset($_REQUEST['admin_id'])){
- if($_REQUEST['admin_id']=="全部"){
+ if (isset($_REQUEST['admin_id'])) {
+ if ($_REQUEST['admin_id'] == "全部") {
unset($_REQUEST['admin']);
- }else{
- $map['ba_id']=$_REQUEST['admin_id'];
+ } else {
+ $map['ba_id'] = $_REQUEST['admin_id'];
}
}
- if(I('promote_level') == 1){
+ if (I('promote_level') == 1) {
$map['parent_id'] = 0;
- }elseif(I('promote_level') == 2){
- $map['parent_id'] = ['neq',0];
+ } elseif (I('promote_level') == 2) {
+ $map['parent_id'] = ['neq', 0];
$map['grand_id'] = 0;
- }elseif (I('promote_level') == 3) {
- $map['parent_id'] = ['neq',0];
- $map['grand_id'] = ['neq',0];
+ } elseif (I('promote_level') == 3) {
+ $map['parent_id'] = ['neq', 0];
+ $map['grand_id'] = ['neq', 0];
}
$model = new PromoteModel();
@@ -1547,12 +1590,13 @@ class PromoteController extends BaseController
/**
* [数组分页,二维数组字段排序]
* @param [type] $model [description]
- * @param integer $p [description]
- * @param array $extend_map [description]
+ * @param integer $p [description]
+ * @param array $extend_map [description]
* @return [type] [description]
* @author [yyh] <[email address]>
*/
- public function order_lists($model = null, $p = 0,$extend_map = array()){
+ public function order_lists($model = null, $p = 0, $extend_map = array())
+ {
$model || $this->error('模型名标识必须!');
$page = intval($p);
$page = $page ? $page : 1; //默认显示第一页数据
@@ -1562,28 +1606,30 @@ class PromoteController extends BaseController
$model || $this->error('模型不存在!');
//解析列表规则
$fields = array();
- $grids = preg_split('/[;\r\n]+/s', trim($model['list_grid']));
+ $grids = preg_split('/[;\r\n]+/s', trim($model['list_grid']));
foreach ($grids as &$value) {
- if(trim($value) === ''){
+ if (trim($value) === '') {
continue;
}
// 字段:标题:链接
- $val = explode(':', $value);
+ $val = explode(':', $value);
// 支持多个字段显示
- $field = explode(',', $val[0]);
- $value = array('field' => $field, 'title' => $val[1]);
- if(isset($val[2])){
+ $field = explode(',', $val[0]);
+ $value = array('field' => $field, 'title' => $val[1]);
+ if (isset($val[2])) {
// 链接信息
- $value['href'] = $val[2];
+ $value['href'] = $val[2];
// 搜索链接信息中的字段信息
- preg_replace_callback('/\[([a-z_]+)\]/', function($match) use(&$fields){$fields[]=$match[1];}, $value['href']);
+ preg_replace_callback('/\[([a-z_]+)\]/', function ($match) use (&$fields) {
+ $fields[] = $match[1];
+ }, $value['href']);
}
- if(strpos($val[1],'|')){
+ if (strpos($val[1], '|')) {
// 显示格式定义
- list($value['title'],$value['format']) = explode('|',$val[1]);
+ list($value['title'], $value['format']) = explode('|', $val[1]);
}
- foreach($field as $val){
- $array = explode('|',$val);
+ foreach ($field as $val) {
+ $array = explode('|', $val);
$fields[] = $array[0];
}
}
@@ -1591,33 +1637,37 @@ class PromoteController extends BaseController
$fields[] = 'grand_id';
// 过滤重复字段信息
- $fields = array_unique($fields);
+ $fields = array_unique($fields);
// 关键字搜索
- $map = $extend_map;
- $key = $model['search_key']?$model['search_key']:'title';
- if(isset($_REQUEST[$key])){
- $map[$key] = array('like','%'.$_GET[$key].'%');
+ $map = $extend_map;
+ $key = $model['search_key'] ? $model['search_key'] : 'title';
+ if (isset($_REQUEST[$key])) {
+ $map[$key] = array('like', '%' . $_GET[$key] . '%');
unset($_REQUEST[$key]);
}
// 条件搜索
- foreach($_REQUEST as $name=>$val){
- if(in_array($name,$fields)){
- $map[$name] = $val;
+ foreach ($_REQUEST as $name => $val) {
+ if (in_array($name, $fields)) {
+ $map[$name] = $val;
}
}
- if(isset($_REQUEST['row'])) {$row = $_REQUEST['row'];}else{$row = 10;}
+ if (isset($_REQUEST['row'])) {
+ $row = $_REQUEST['row'];
+ } else {
+ $row = 10;
+ }
//读取模型数据列表
- if($model['extend']){
- $name = get_table_name($model['id']);
+ if ($model['extend']) {
+ $name = get_table_name($model['id']);
$parent = get_table_name($model['extend']);
- $fix = C("DB_PREFIX");
+ $fix = C("DB_PREFIX");
$key = array_search('id', $fields);
- if(false === $key){
+ if (false === $key) {
array_push($fields, "{$fix}{$parent}.id as id");
} else {
$fields[$key] = "{$fix}{$parent}.id as id";
@@ -1627,7 +1677,7 @@ class PromoteController extends BaseController
$count = D($parent)->join("INNER JOIN {$fix}{$name} ON {$fix}{$parent}.id = {$fix}{$name}.id")->where($map)->count();
// 查询数据
- $data = D($parent)
+ $data = D($parent)
->join("INNER JOIN {$fix}{$name} ON {$fix}{$parent}.id = {$fix}{$name}.id")
/* 查询指定字段,不指定则查询所有字段 */
->field(empty($fields) ? true : $fields)
@@ -1641,7 +1691,7 @@ class PromoteController extends BaseController
->select();
} else {
- if($model['need_pk']){
+ if ($model['need_pk']) {
in_array('id', $fields) || array_push($fields, 'id');
}
$name = parse_name(get_table_name($model['id']), true);
@@ -1651,7 +1701,7 @@ class PromoteController extends BaseController
// 查询条件
->where($map)
/* 默认通过id逆序排列 */
- ->order(empty($map['order'])?"id desc":$map['order'])
+ ->order(empty($map['order']) ? "id desc" : $map['order'])
/* 数据分页 */
// ->page($page, $row)//需要查询所有数据 后面用数组分页,原因: 页面要排序
/* 执行查询 */
@@ -1661,38 +1711,40 @@ class PromoteController extends BaseController
}
//分页
- $page = set_pagination($count,$row);
- if($page) {$this->assign('_page', $page);}
+ $page = set_pagination($count, $row);
+ if ($page) {
+ $this->assign('_page', $page);
+ }
- $data = $this->parseDocumentList($data,$model['id']);
- if(isset($extend_map['for_show_pic_list'])){
- if($extend_map['for_show_pic_list']=='icon'){
+ $data = $this->parseDocumentList($data, $model['id']);
+ if (isset($extend_map['for_show_pic_list'])) {
+ if ($extend_map['for_show_pic_list'] == 'icon') {
foreach ($data as $key => $value) {
- $data[$key]['pic_path']=get_cover($value['icon'],'path');
+ $data[$key]['pic_path'] = get_cover($value['icon'], 'path');
}
}
- if($extend_map['for_show_pic_list']=='novice'){
+ if ($extend_map['for_show_pic_list'] == 'novice') {
foreach ($data as $key => $value) {
- $data[$key]['novice']=arr_count($value['novice']);
+ $data[$key]['novice'] = arr_count($value['novice']);
}
}
}
- if($_REQUEST['data_order']!=''){
- $data_order=reset(explode(',',$_REQUEST['data_order']));
- $data_order_type=end(explode(',',$_REQUEST['data_order']));
- $this->assign('userarpu_order',$data_order);
- $this->assign('userarpu_order_type',$data_order_type);
+ if ($_REQUEST['data_order'] != '') {
+ $data_order = reset(explode(',', $_REQUEST['data_order']));
+ $data_order_type = end(explode(',', $_REQUEST['data_order']));
+ $this->assign('userarpu_order', $data_order);
+ $this->assign('userarpu_order_type', $data_order_type);
}
- $data=my_sort($data,$data_order_type,(int)$data_order);
- $size=$row;//每页显示的记录数
+ $data = my_sort($data, $data_order_type, (int)$data_order);
+ $size = $row;//每页显示的记录数
$pnum = ceil(count($data) / $size); //总页数,ceil()函数用于求大于数字的最小整数
//用array_slice(array,offset,length) 函数在数组中根据条件取出一段值;array(数组),offset(元素的开始位置),length(组的长度)
- $data = array_slice($data, ($arraypage-1)*$size, $size);
+ $data = array_slice($data, ($arraypage - 1) * $size, $size);
$this->assign('model', $model);
$this->assign('list_grids', $grids);
$this->assign('list_data', $data);
- $this->meta_title = $model['title'].'列表';
+ $this->meta_title = $model['title'] . '列表';
$this->display($model['template_list']);
}
@@ -1701,31 +1753,32 @@ class PromoteController extends BaseController
* @param array $list 列表数据
* @param integer $model_id 模型id
*/
- protected function parseDocumentList($list,$model_id=null){
+ protected function parseDocumentList($list, $model_id = null)
+ {
$model_id = $model_id ? $model_id : 1;
- $attrList = get_model_attribute($model_id,false,'id,name,type,extra');
+ $attrList = get_model_attribute($model_id, false, 'id,name,type,extra');
// 对列表数据进行显示处理
- if(is_array($list)){
- foreach ($list as $k=>$data){
- foreach($data as $key=>$val){
- if(isset($attrList[$key])){
- $extra = $attrList[$key]['extra'];
- $type = $attrList[$key]['type'];
- if('select'== $type || 'checkbox' == $type || 'radio' == $type || 'bool' == $type) {
+ if (is_array($list)) {
+ foreach ($list as $k => $data) {
+ foreach ($data as $key => $val) {
+ if (isset($attrList[$key])) {
+ $extra = $attrList[$key]['extra'];
+ $type = $attrList[$key]['type'];
+ if ('select' == $type || 'checkbox' == $type || 'radio' == $type || 'bool' == $type) {
// 枚举/多选/单选/布尔型
- $options = parse_field_attr($extra);
- if($options && array_key_exists($val,$options)) {
- $data[$key] = $options[$val];
+ $options = parse_field_attr($extra);
+ if ($options && array_key_exists($val, $options)) {
+ $data[$key] = $options[$val];
}
- }elseif('date'==$type){ // 日期型
- $data[$key] = date('Y-m-d',$val);
- }elseif('datetime' == $type){ // 时间型
- $data[$key] = date('Y-m-d H:i:s',$val);
+ } elseif ('date' == $type) { // 日期型
+ $data[$key] = date('Y-m-d', $val);
+ } elseif ('datetime' == $type) { // 时间型
+ $data[$key] = date('Y-m-d H:i:s', $val);
}
}
}
$data['model_id'] = $model_id;
- $list[$k] = $data;
+ $list[$k] = $data;
}
}
return $list;
@@ -1759,17 +1812,16 @@ class PromoteController extends BaseController
$id = strtoupper($id);
$regx = "/(^\d{15}$)|(^\d{17}([0-9]|X)$)/";
$arr_split = array();
- if(!preg_match($regx, $id)) {
+ if (!preg_match($regx, $id)) {
return false;
}
- if (15==strlen($id)) {
+ if (15 == strlen($id)) {
$regx = "/^(\d{6})+(\d{2})+(\d{2})+(\d{2})+(\d{3})$/";
@preg_match($regx, $id, $arr_split);
//检查生日日期是否正确
- $dtm_birth = "19".$arr_split[2] . '/' . $arr_split[3]. '/' .$arr_split[4];
- if(!strtotime($dtm_birth))
- {
+ $dtm_birth = "19" . $arr_split[2] . '/' . $arr_split[3] . '/' . $arr_split[4];
+ if (!strtotime($dtm_birth)) {
return false;
} else {
return true;
@@ -1777,8 +1829,8 @@ class PromoteController extends BaseController
} else {
$regx = "/^(\d{6})+(\d{4})+(\d{2})+(\d{2})+(\d{3})([0-9]|X)$/";
@preg_match($regx, $id, $arr_split);
- $dtm_birth = $arr_split[2] . '/' . $arr_split[3]. '/' .$arr_split[4];
- if(!strtotime($dtm_birth)) {
+ $dtm_birth = $arr_split[2] . '/' . $arr_split[3] . '/' . $arr_split[4];
+ if (!strtotime($dtm_birth)) {
return false;
} else {
//检验18位身份证的校验码是否正确。
@@ -1786,14 +1838,14 @@ class PromoteController extends BaseController
$arr_int = array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
$arr_ch = array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
$sign = 0;
- for ( $i = 0; $i < 17; $i++ ) {
- $b = (int) $id{$i};
+ for ($i = 0; $i < 17; $i++) {
+ $b = (int)$id{$i};
$w = $arr_int[$i];
$sign += $b * $w;
}
$n = $sign % 11;
$val_num = $arr_ch[$n];
- if ($val_num != substr($id,17, 1)) {
+ if ($val_num != substr($id, 17, 1)) {
return false;
} else {
return true;
@@ -1803,20 +1855,63 @@ class PromoteController extends BaseController
}
- function ajax_page($count, $row,$ajax_func='index',$current=1) {
+ function ajax_page($count, $row, $ajax_func = 'index', $current = 1)
+ {
$aside = '';
- $count=$count?$count:0;
- $row=$row?$row:10;
+ $count = $count ? $count : 0;
+ $row = $row ? $row : 10;
if ($count > $row) {
- $p = new \Think\AjaxPage($count,$row,$ajax_func);
- $p->nowpage($count,$row,$current,$ajax_func);
+ $p = new \Think\AjaxPage($count, $row, $ajax_func);
+ $p->nowpage($count, $row, $current, $ajax_func);
$p->setConfig('theme', '%first% %upPage% %linkPage% %downPage% %end% %header%');
//产生分页信息
- $html=$p->show();
- return " ".$html." ";
+ $html = $p->show();
+ return "" . $html . " ";
} else {
//return '' .$aside. '共 '.$count.' 条记录 ';
- return '共 '.$count.' 条记录 ';
+ return '共 ' . $count . ' 条记录 ';
+ }
+ }
+
+ public function setChildGamePermission()
+ {
+ $parentId = getParentPromoteId(PID);//上级ID
+ if ($parentId > 0) {
+ $this->error('权限异常');
+ }
+
+ $securityCode = empty(session('game_divide_second_pwd')) ? '' : session('game_divide_second_pwd');//安全密码
+ $model = new PromoteApi();
+ $res = $model->verify_er_User(PID, $securityCode);//验证安全密码
+ if ($_POST) {
+ if (!$res) {
+ $data['status'] = 0;
+ $data['msg'] = '权限异常';
+
+ $this->ajaxReturn($data);
+ }
+
+ $save['child_game_permission'] = I('post.child_game_permission');
+ $saveRes = D('Promote')->where(array('id' => PID))->save($save);
+ if ($saveRes === false) {
+ $data['status'] = 0;
+ $data['msg'] = '保存失败';
+ } else {
+ $data['status'] = 1;
+ $data['msg'] = '保存成功';
+ }
+
+ $this->ajaxReturn($data);
+ } else {
+ if ($res) {
+ $map['id'] = PID;
+ $promoteData = D('Promote')->field('id,child_game_permission')->where($map)->find();
+
+ $this->assign('data', $promoteData);
+ }
+
+ $this->meta_title = "设置";
+ $this->display();
}
}
}
diff --git a/Application/Home/View/default/Promote/setChildGamePermission.html b/Application/Home/View/default/Promote/setChildGamePermission.html
new file mode 100644
index 000000000..7f17c1423
--- /dev/null
+++ b/Application/Home/View/default/Promote/setChildGamePermission.html
@@ -0,0 +1,240 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 设置
+
+ 安全密码
+
+
+
+
+
+
+
+
+
+
diff --git a/Application/Home/View/default/Public/promote_base.html b/Application/Home/View/default/Public/promote_base.html
index fb122b97d..3e10f21ae 100644
--- a/Application/Home/View/default/Public/promote_base.html
+++ b/Application/Home/View/default/Public/promote_base.html
@@ -74,6 +74,7 @@
混服管理
分成比例
+ 设置
diff --git a/Data/update.sql b/Data/update.sql
index 6183e6438..df9376f92 100644
--- a/Data/update.sql
+++ b/Data/update.sql
@@ -67,4 +67,9 @@ alter table tab_game_source add column `org_plist_url` varchar(255) NOT NULL def
-- 2019-10-08 cxj
-- ----------------------------
ALTER TABLE `tab_game` ADD COLUMN `server_type` tinyint(2) NOT NULL DEFAULT 1 COMMENT '1-专服 2-混服' AFTER `support_ratio`;
-ALTER TABLE `tab_game` ADD COLUMN `detail_content` MEDIUMTEXT NULL DEFAULT NULL COMMENT '游戏资料介绍' AFTER `features`;
\ No newline at end of file
+ALTER TABLE `tab_game` ADD COLUMN `detail_content` MEDIUMTEXT NULL DEFAULT NULL COMMENT '游戏资料介绍' AFTER `features`;
+
+-- ----------------------------
+-- 2019-10-10 cxj
+-- ----------------------------
+ALTER TABLE `tab_promote` ADD COLUMN `child_game_permission` tinyint(2) NOT NULL DEFAULT 0 COMMENT '下级游戏添加权限 0-本账号已添加游戏 1-所有游戏' AFTER `idcard`;
|