diff --git a/Application/Admin/Common/function.php b/Application/Admin/Common/function.php index c7058b07a..8c4e50d16 100644 --- a/Application/Admin/Common/function.php +++ b/Application/Admin/Common/function.php @@ -1060,9 +1060,15 @@ function showNumPercent($num) //优化子站点实例化方法 function SM($name='', $tablePrefix='tab_',$is_subsiteTable=false) { - $tableName = strtolower($tablePrefix.unCamelize($name)); - if(is_subsiteTable($tableName) || $is_subsiteTable){ - return M($name, $tablePrefix,SUBSITE_DB); + if(empty($name)){ + if(IS_SUBSITE){ + return M($name, $tablePrefix,SUBSITE_DB); + } + }else{ + $tableName = strtolower($tablePrefix.unCamelize($name)); + if(is_subsiteTable($tableName) || $is_subsiteTable){ + return M($name, $tablePrefix,SUBSITE_DB); + } } return M($name, $tablePrefix); } diff --git a/Application/Admin/Controller/FinancialSummaryController.class.php b/Application/Admin/Controller/FinancialSummaryController.class.php index f6bdcabc0..5c64eec11 100644 --- a/Application/Admin/Controller/FinancialSummaryController.class.php +++ b/Application/Admin/Controller/FinancialSummaryController.class.php @@ -44,7 +44,7 @@ class FinancialSummaryController extends AdminController public function updateStatement() { $temp = date('Y',time()).'-'.(date('m',time())-1); - $params = "php admin.php FinancialSummarySet/setMonthFinancialSummary/recount/1/count_date/{$temp}"; + $params = "php ".SUBSITE_INDEX." FinancialSummarySet/setMonthFinancialSummary/recount/1/count_date/{$temp}"; $r = D("CmdTasks")->addTask("FinancialSummary",$params); if($r){ $this->ajaxReturn(["success"=>"ok"]); diff --git a/Application/Admin/Controller/MarketPercentageController.class.php b/Application/Admin/Controller/MarketPercentageController.class.php index 20fd27c4a..6730933d4 100644 --- a/Application/Admin/Controller/MarketPercentageController.class.php +++ b/Application/Admin/Controller/MarketPercentageController.class.php @@ -1026,6 +1026,8 @@ class MarketPercentageController extends ThinkController $map = []; $map['group_id'] = ['in','11,12,21']; + //获取权限 + $marketPercentage = M("auth_group")->where($map)->getField("id,market_percentage"); // $_REQUEST['pay_time']?($map['pay_time'] = $_REQUEST['pay_time']):''; // $_REQUEST['admin_id']?($map['admin_id'] = $_REQUEST['admin_id']):''; @@ -1105,10 +1107,8 @@ class MarketPercentageController extends ThinkController } } - $data = M("market_altogether","tab_") - ->field("tab_market_altogether.*,market_percentage") - ->join("left join sys_auth_group_access access on tab_market_altogether.admin_id = access.uid") - ->join("left join sys_auth_group auth on access.group_id=auth.id") + $data = SM("market_altogether","tab_") + ->field("*") ->where($map); if ($_REQUEST['export']) { @@ -1122,7 +1122,7 @@ class MarketPercentageController extends ThinkController ->select(); } - $count = M("market_altogether","tab_") + $count = SM("market_altogether","tab_") ->where($map) ->count(); @@ -1142,6 +1142,10 @@ class MarketPercentageController extends ThinkController $sum['wait_commission'] = 0; foreach ($data as $key => $value) { + $level = $value['level']; + if(isset($marketPercentage[$level])){ + $value['market_percentage'] = $marketPercentage[$level]; + } $data[$key]['start_time'] = date("Y-m-1",strtotime($value['pay_time'])); $data[$key]['end_time'] = date("Y-m-t",strtotime($value['pay_time'])); @@ -1262,7 +1266,7 @@ class MarketPercentageController extends ThinkController $this->ajaxReturn(['status'=>0,'msg'=>'数据错误']); } - $check_data = M("market_altogether","tab_") + $check_data = SM("market_altogether","tab_") ->where(['pay_time'=>$_REQUEST['pay_time'],'admin_id'=>$_REQUEST['admin_id']]) ->find(); @@ -1288,7 +1292,7 @@ class MarketPercentageController extends ThinkController $save['remark'] = '离职发放'; } - $is_save = M("market_altogether","tab_") + $is_save = SM("market_altogether","tab_") ->where($map) ->save($save); @@ -1311,7 +1315,7 @@ class MarketPercentageController extends ThinkController // var_dump("cd ".ROOTTT.";php admin.php timing/caculateMarketStream/time/{$pay_time} > /dev/null &");die(); - exec("source /etc/profile;cd ".ROOTTT.";php admin.php timing/caculateMarketStream/time/{$pay_time} > /dev/null &"); + exec("source /etc/profile;cd ".ROOTTT.";php ".SUBSITE_INDEX." timing/caculateMarketStream/time/{$pay_time} > /dev/null &"); $this->ajaxReturn(['status'=>1]); } @@ -1401,7 +1405,7 @@ class MarketPercentageController extends ThinkController } } - $data = M("market_altogether","tab_") + $data = SM("market_altogether","tab_") ->field("max(tab_market_altogether.pay_time) pay_time,tab_market_altogether.real_name,tab_market_altogether.admin_id,tab_market_altogether.nickname,level,sum(pay_amount) pay_amount,sum(extend_commission) extend_commission, sum(performance_commission) performance_commission,sum(achievement_bonus* IF(coefficient is not NULL, coefficient, 100)/100) achievement_bonus, sum(wait_performance_commission)+sum(wait_achievement_commission) wait_amount, @@ -1424,7 +1428,7 @@ class MarketPercentageController extends ThinkController ->select(false); } - $data = M()->table("({$data})a") + $data = SM()->table("({$data})a") ->field("max(pay_time) pay_time,real_name,admin_id,nickname,level,sum(pay_amount) pay_amount,sum(extend_commission) extend_commission, sum(performance_commission) performance_commission,sum(achievement_bonus) achievement_bonus,sum(wait_amount) wait_amount, sum(wait_extend_commission) wait_extend_commission,sum(wait_commission) wait_commission,remark,status") @@ -1492,11 +1496,12 @@ class MarketPercentageController extends ThinkController data2csv($data,'提成汇总结算单',$title); } - $count = M("market_altogether","tab_") + $count = SM("market_altogether","tab_") + ->field("admin_id") ->where($map) ->group("admin_id") - ->select(false); - $count = M()->table("({$count}) count")->count(); + ->select(); + $count = count($count); $page = set_pagination($count, $row); if ($page) { @@ -1575,7 +1580,7 @@ class MarketPercentageController extends ThinkController $admin = $_SESSION['onethink_admin']['user_auth']['username']; $market_check_detail = "市场部已确认({$admin})
".date("Y-m-d H:i:s",time()); - $is_save = M("market_altogether","tab_") + $is_save = SM("market_altogether","tab_") ->where(['id'=>['in',$ids],'market_check'=>0]) ->save(['market_check'=>1,'market_check_detail'=>$market_check_detail]); @@ -1598,7 +1603,7 @@ class MarketPercentageController extends ThinkController $admin = $_SESSION['onethink_admin']['user_auth']['username']; $finance_check_detail = "财务部已审批({$admin})
".date("Y-m-d H:i:s",time()); - $is_save = M("market_altogether","tab_") + $is_save = SM("market_altogether","tab_") ->where(['id'=>['in',$ids],'finance_check'=>0]) ->save(['finance_check'=>1,'finance_check_detail'=>$finance_check_detail]); diff --git a/Application/Admin/Model/CmdTasksModel.class.php b/Application/Admin/Model/CmdTasksModel.class.php index b3f15a73e..13705325f 100644 --- a/Application/Admin/Model/CmdTasksModel.class.php +++ b/Application/Admin/Model/CmdTasksModel.class.php @@ -8,6 +8,14 @@ use Think\Model; */ class CmdTasksModel extends Model{ protected $tablePrefix = 'tab_'; + public function __construct($model) + { + if(IS_SUBSITE){ + parent::__construct($model, $this->tablePrefix, SUBSITE_DB); + }else{ + parent::__construct($model, $this->tablePrefix); + } + } //获取待执行任务 public function getTask() {