Merge pull request 'feature/statement_warning_change' (#489) from feature/statement_warning_change into master

Reviewed-on: http://8.136.139.249:3000/wmtx/platform/pulls/489
master
廖金灵 3 years ago
commit 655c928278

@ -68,36 +68,13 @@ class MarketPercentageController extends ThinkController
$_REQUEST['promote_id'] ? ($map['promote_id'] = $_REQUEST['promote_id']) : '';
$_REQUEST['relation_game_id'] ? ($map['relation_game_id'] = $_REQUEST['relation_game_id']) : '';
// $_REQUEST['sdk_version']?($map['sdk_version'] = $_REQUEST['sdk_version']):'';
$_REQUEST['admin_id'] ? ($map['admin_id'] = $_REQUEST['admin_id']) : '';
$_REQUEST['admin_id'] ? ($map['_string'] .= " AND admin_id = {$_REQUEST['admin_id']}") : '';
($_REQUEST['company_id'] || $_REQUEST['company_id'] == '0') ? ($map['company_id'] = $_REQUEST['company_id']) : '';
$admin_id = $_SESSION['onethink_admin']['user_auth']['uid'];
$gid = session('user_group_id');
$markerGroup = $this->MarketEvent->isMarketAdminGroup($gid);
if($markerGroup){
$map['department_id'] =["in",[0,$markerGroup['department_id']]];
if( !$this->MarketEvent->isDepartmentLeder($markerGroup['department_id'],$admin_id)){
$map['admin_id'] = $admin_id ;
}
if($this->MarketEvent->getConfig('isMarket')){
$map['admin_id'] = ['in',$this->MarketEvent->getAdminidByLeaderid()] ;
}
// dd($map);
// $map['admin_id'] = $admin_id;
// if (is_administrator() || session('user_group_id') == 15 || session('user_group_id') == 14 || session('user_group_id') == 19 || session('user_group_id') == 23) {
// unset($map['admin_id']);
// $admin_data = M("member")
// ->field("access.uid admin_id")
// ->join("left join sys_auth_group_access access on sys_member.uid = access.uid")
// ->join("left join sys_auth_group auth on access.group_id=auth.id")
// ->where(['group_id' => ['in', '11,12,21,25']])
// ->select();
// if ($admin_data) {
// $map['admin_id'] = ['in', array_column($admin_data, 'admin_id')];
// }
// $_REQUEST['admin_id'] ? ($map['admin_id'] = $_REQUEST['admin_id']) : '';
// }
$search_date = [];
if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) {
@ -281,30 +258,20 @@ class MarketPercentageController extends ThinkController
public function indexuncaculate($row = 10, $p = 1)
{
$map = [];
$map = [
"_string"=>'1=1',
"is_settlement"=>0
];
// $_REQUEST['pay_time']?($map['pay_time'] = $_REQUEST['pay_time']):'';
$_REQUEST['promote_id'] ? ($map['promote_id'] = $_REQUEST['promote_id']) : '';
$_REQUEST['relation_game_id'] ? ($map['relation_game_id'] = $_REQUEST['relation_game_id']) : '';
$_REQUEST['sdk_version'] ? ($map['sdk_version'] = $_REQUEST['sdk_version']) : '';
$_REQUEST['admin_id'] ? ($map['admin_id'] = $_REQUEST['admin_id']) : '';
$_REQUEST['admin_id'] ? ($map['_string'] .= " AND admin_id = {$_REQUEST['admin_id']}") : '';
($_REQUEST['company_id'] || $_REQUEST['company_id'] == '0') ? ($map['company_id'] = $_REQUEST['company_id']) : '';
$admin_id = $_SESSION['onethink_admin']['user_auth']['uid'];
$map['admin_id'] = $admin_id;
$map['is_settlement'] = 0;
if (is_administrator() || session('user_group_id') == 15 || session('user_group_id') == 14 || session('user_group_id') == 19 || session('user_group_id') == 23) {
unset($map['admin_id']);
$admin_data = M("member")
->field("access.uid admin_id")
->join("left join sys_auth_group_access access on sys_member.uid = access.uid")
->join("left join sys_auth_group auth on access.group_id=auth.id")
->where(['group_id' => ['in', '11,12,21']])
->select();
if ($admin_data) {
$map['admin_id'] = ['in', array_column($admin_data, 'admin_id')];
}
$_REQUEST['admin_id'] ? ($map['admin_id'] = $_REQUEST['admin_id']) : '';
if($this->MarketEvent->getConfig('isMarket')){
$map['admin_id'] = ['in',$this->MarketEvent->getAdminidByLeaderid()] ;
}
$search_date = [];
@ -479,7 +446,7 @@ class MarketPercentageController extends ThinkController
}
$data = M("auth_group")
->where(['title' => ['like', '%市场专员%']])
->where(['department_id' => ['in', $this->MarketEvent->getConfig('MarketDepartmentId')]])
->select(false);
$member = M("auth_group_access")
@ -616,18 +583,17 @@ class MarketPercentageController extends ThinkController
} else {
$map['id'] =['in',A("Market","Event")->getNoLeaderMarketGroupId()];
$data = M("auth_group")
->where($map)
->select(false);
$map['sys_auth_group_access.uid'] =['in',$this->MarketEvent->getAdminidByLeaderid()];
$map['auth.id'] =['in',$this->MarketEvent->getNoLeaderMarketGroupId()];
$data = M("auth_group_access")
->field("sys_member.nickname,sys_member.real_name,sys_member.uid,sys_auth_group_access.group_id,IF(coefficient is not NULL, coefficient, 100) coefficient,sys_ucenter_member.leave_time")
->join("left join ({$data}) auth on auth.id = sys_auth_group_access.group_id")
->join("left join sys_auth_group auth on auth.id = sys_auth_group_access.group_id")
->join("left join sys_member on sys_member.uid = sys_auth_group_access.uid")
->join("left join sys_ucenter_member on sys_member.uid = sys_ucenter_member.id")
->join("left join tab_coefficient on tab_coefficient.admin_id = sys_member.uid and pay_time='{$pay_time}'")
->where("auth.title is not null")
->where($map)
->select();
$hideTime = strtotime(date('Y-m-01') . " - 1 month")-1;
foreach ($data as &$v) {
@ -652,23 +618,12 @@ class MarketPercentageController extends ThinkController
//获取权限
$marketPercentage = M("auth_group")->where($map)->getField("id,market_percentage");
$_REQUEST['admin_id'] ? ($map['admin_id'] = $_REQUEST['admin_id']) : '';
$_REQUEST['level'] ? ($map['level'] = $_REQUEST['level']) : '';
$admin_id = $_SESSION['onethink_admin']['user_auth']['uid'];
$gid = session('user_group_id');
$markerGroup = $this->MarketEvent->isMarketAdminGroup($gid);
if($markerGroup){
if( $this->MarketEvent->isDepartmentLeder($markerGroup['department_id'],$admin_id)){
$map['admin_id'] = ['in',$this->MarketEvent->getDepartmentUserId($markerGroup['department_id'])];
}else{
$map['admin_id'] = $admin_id ;
}
}
$_REQUEST['admin_id'] ? ($map['_string'] .= " AND admin_id = {$_REQUEST['admin_id']}") : '';
if($this->MarketEvent->getConfig('isMarket')){
$map['admin_id'] = ['in',$this->MarketEvent->getAdminidByLeaderid()] ;
}
$search_date = [];
if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) {
@ -1036,17 +991,10 @@ class MarketPercentageController extends ThinkController
}
}
$admin_id = $_SESSION['onethink_admin']['user_auth']['uid'];
$gid = session('user_group_id');
$markerGroup = $this->MarketEvent->isMarketAdminGroup($gid);
if($markerGroup){
if( $this->MarketEvent->isDepartmentLeder($markerGroup['department_id'],$admin_id)){
$map['admin_id'] = ['in',$this->MarketEvent->getDepartmentUserId($markerGroup['department_id'])];
}else{
$map['admin_id'] = $admin_id ;
}
}
$_REQUEST['admin_id'] ? ($map['_string'] .= " AND admin_id = {$_REQUEST['admin_id']}") : '';
if($this->MarketEvent->getConfig('isMarket')){
$map['admin_id'] = ['in',$this->MarketEvent->getAdminidByLeaderid()] ;
}
$search_date = [];

@ -15,68 +15,27 @@ class OldCountController extends \Think\Controller
public function moreDepartment()
{
//1.新增组
$manager = M('auth_group','sys_')->where("title = '高级市场专员'")->find();
$dbres = M('auth_group','sys_')->where("title LIKE '%市场%' AND id != 18")->select();
$dbres = M('auth_group','sys_')->where("department_id = 2 and department_level != 5")->select();
// $ids = '32,33,34,35';
$ids = '';
foreach ($dbres as &$v) {
if($v['id'] == 25){
$v['rules'] = $manager['rules'];
$v['data_empower_type'] =3;
$v['show_data'] =1;
$v['show_market_admin'] =1;
$v['show_promote'] =1;
}
if(mb_strpos($v['title'],"初级")){
$v['department_level'] = 1;
}
if(mb_strpos($v['title'],"中级")){
$v['department_level'] = 2;
}
if(mb_strpos($v['title'],"高级")){
$v['department_level'] = 3;
}
if(mb_strpos($v['title'],"经理")){
$v['department_level'] = 4;
}
if(mb_strpos($v['title'],"总监")){
$v['department_level'] = 5;
}
$v['title'] = "一部".$v['title'];
$v['department_id'] = 1;
$v['department_name'] = "市场一部";
M('auth_group','sys_')->save($v);
unset($v['id']);
$v['title'] = str_replace("一部","二部",$v['title']);
$v['department_id'] = 2;
$v['department_name'] = '市场二部';
M('auth_group','sys_')->add($v);
$v['title'] = str_replace("二部","长沙",$v['title']);
$v['department_id'] = 3;
$v['department_name'] = '长沙分部';
$ids .= ( M('auth_group','sys_')->add($v) . ",");
}
$ids = rtrim($ids,',');
//3.增加部门表数据
M("department")->add([
'id'=>1,
'name'=>'市场一部',
'group_ids'=>'11,12,14,21,25',
'id'=>3,
'name'=>'长沙分部',
'group_ids'=>$ids,
'leader_group'=>'14',
'create_time'=>time(),
'update_time'=>time()
]);
M("department")->add([
'id'=>2,
'name'=>'市场二部',
'group_ids'=>'26,27,28,29,30',
'leader_group'=>'28',
'create_time'=>time(),
'update_time'=>time()
]);
//4.修改旧等级
M("market_altogether","tab_")->where("level = 21")->save(['level'=>1]);
M("market_altogether","tab_")->where("level = 11")->save(['level'=>2]);
M("market_altogether","tab_")->where("level = 12")->save(['level'=>3]);
M("market_altogether","tab_")->where("level = 25")->save(['level'=>4]);
}
public function setDataPresidentInit()

@ -52,10 +52,12 @@ class StatementWarningController extends AdminController
}
private function getLastUpdate()
{
{
$preMonth = explode('-',date('Y-m',mktime(0,0,0,date('m',time()),1,date('Y',time()))-1));
$lastUpdate = $this->statementWarningModel->where([
'count_year'=>$_REQUEST['year'],
'count_month'=>date('m',time()),
'count_year'=>$preMonth[0],
'count_month'=>$preMonth[1],
"name"=>'wm_platm',
"type"=>1
])->field("create_time")->find();
@ -105,11 +107,11 @@ class StatementWarningController extends AdminController
}
}
//毛利
$data[3]['list']['费用'][12] = array_sum($data[3]['list']['费用']);
$data[3]['list']['其他收入'][12] = array_sum($data[3]['list']['其他收入']);
$data[3]['list']['cost'][12] = array_sum($data[3]['list']['cost']);
$data[3]['list']['other_income'][12] = array_sum($data[3]['list']['other_income']);
for ($i=0; $i < 13; $i++) {
$data[3]['count'][$i] = $data[1]['count'][$i]-$data[2]['count'][$i];
$data[4]['count'][$i] = ($data[3]['count'][$i]-$data[3]['list']['费用'][$i]+$data[3]['list']['其他收入'][$i]);
$data[4]['count'][$i] = ($data[3]['count'][$i]-$data[3]['list']['cost'][$i]+$data[3]['list']['other_income'][$i]);
if($data[1]['count'][$i] != 0){
$data[3]['list']['margin_ratio'][$i] = round( $data[3]['count'][$i]/$data[1]['count'][$i],4);
@ -134,13 +136,19 @@ class StatementWarningController extends AdminController
}
unset($data[$type]['list'][$name]);
if(isset($this->statementWarningKey[$name])){
if( in_array($name,['margin_ratio','profit_ratio']) ){
$data[$type]['list'][$name]['is_edit'] = 0;
}else{
$data[$type]['list'][$name]['is_edit'] = 1;
}
$data[$type]['list'][$name]['name'] = $this->statementWarningKey[$name];
$data[$type]['list'][$name]['list'] = $value;
$data[$type]['list'][$name]['is_edit'] = 0;
$data[$type]['list'][$name]['is_del'] = 0;
}else{
$data[$type]['list'][$name]['name'] = $name;
$data[$type]['list'][$name]['list'] = $value;
$data[$type]['list'][$name]['is_edit'] = 1;
$data[$type]['list'][$name]['is_del'] = 1;
}
}
}
@ -168,6 +176,7 @@ class StatementWarningController extends AdminController
if($act == 'add'){
$isEdit = 0;
$this->assign('is_edit', 0);
$this->assign('chenge_name', 1);
}else{
$this->assign('is_edit', 1);
}
@ -222,22 +231,32 @@ class StatementWarningController extends AdminController
}
private function resetWarningData()
{
//获取真实名称
$name = $_REQUEST['name'];
$sendData = [
'value'=>[0,0,0,0,0,0,0,0,0,0,0,0],
'ids'=>[0,0,0,0,0,0,0,0,0,0,0,0],
'chenge_name'=>1,
'count_year'=>$_REQUEST['count_year']
];
$key = array_flip($this->statementWarningKey);
if(isset($key[$_REQUEST['name']])){
$sendData['chenge_name'] = 0;
$sendData['orgin_name'] = $key[$_REQUEST['name']];
$sendData['name'] = $name;
$name = $key[$_REQUEST['name']];
}else{
$sendData['orgin_name'] = $name;
$sendData['name'] = $name;
}
$where = [
'name'=>$_REQUEST['name'],
'name'=>$name,
'count_year'=>$_REQUEST['count_year']
];
$data = $this->statementWarningModel->where($where)->select();
$sendData = [
'count_year'=>$data[0]['count_year'],
'type'=>$data[0]['type'],
'name'=>$data[0]['name'],
'value'=>[0,0,0,0,0,0,0,0,0,0,0,0],
'ids'=>[0,0,0,0,0,0,0,0,0,0,0,0]
];
$sendData['type'] = $data[0]['type'];
foreach ($data as $key => $value) {
$sendData['value'][$value['count_month']-1] = $value['money']/10000;
$sendData['value'][$value['count_month']-1] = round($value['money']/10000,2);
$sendData['ids'][$value['count_month']-1] = $value['id'];
}
$this->assign('data', $sendData);
@ -289,7 +308,9 @@ class StatementWarningController extends AdminController
{
if(!isset($_REQUEST['time'])) $this->error("参数错误");
$time = $_REQUEST['time'];
$time =strtotime($_REQUEST['time']."-1");
$time = date('Y-m',strtotime('+32 day',$time));
$params = "php ".SUBSITE_INDEX." StatementWarningSet/setFreeMonth/count_date/{$time}";
$r = D("CmdTasks")->addTask("StatementWarningSet",$params);
if($r){
@ -351,7 +372,7 @@ class StatementWarningController extends AdminController
private function getMonthLastUpdate($year,$month)
{
$lastUpdate = $this->statementWarningModel->where([
$lastUpdate = $this->statementWarningInfoModel->where([
'count_year'=>$year,
'count_month'=>$month,
])->field("MAX(create_time) create_time")->find();
@ -401,9 +422,11 @@ class StatementWarningController extends AdminController
$poolname = 'up_statement';
}
$preMonth = explode('-',date('Y-m',mktime(0,0,0,$info['count_month'],1,$info['count_year'])-1));
$this->statementWarningModel->where([
'count_year'=>$info['count_year'],
'count_month'=>$info['count_month'],
'count_year'=>$preMonth[0],
'count_month'=>$preMonth[1],
'name'=>$poolname,
])->setDec('money',$diffMoney);
}

@ -28,7 +28,9 @@ class StatementWarningSetController extends Controller {
'pc_statement'=>'下游内团',
'pu_statement'=>'下游外团',
'margin_ratio'=>'毛利率',
'profit_ratio'=>'利润率'
'profit_ratio'=>'利润率',
'cost'=>'费用',
'other_income'=>'其他收入'
];
private $statementWarningModel;
@ -66,19 +68,17 @@ class StatementWarningSetController extends Controller {
$count_date = date('Y',time()).'-'.(date('m',time()));
$this->configInit($count_date);
$preMonth = $this->getPreMonth();
$hasdb = $this->statementWarningModel->where([
'count_year'=>$this->year,
'count_month'=>$this->month,
'count_year'=>$preMonth[0],
'count_month'=>$preMonth[1],
"name"=>'wm_platm',
"type"=>1
])->find();
if(!$hasdb){
//第一次生成,同时上一次结扎
$year = date("Y",$this->beginThismonth-1);
$month = date("m",$this->beginThismonth-1);
$preMonth = $year."-".$month;
$params = "php ".SUBSITE_INDEX." StatementWarningSet/setFreeMonth/count_date/{$preMonth}";
$preCountMonth = $preMonth[0]."-".$preMonth[1];
$params = "php ".SUBSITE_INDEX." StatementWarningSet/setFreeMonth/count_date/{$preCountMonth}";
$time = time()+2*3600;
D("CmdTasks")->addScheduleTask("StatementWarningSet",$params,$time);
}
@ -130,13 +130,11 @@ class StatementWarningSetController extends Controller {
*/
private function setCompanyIsWm()
{
$year = date("Y",$this->beginThismonth-1);
$month = date("m",$this->beginThismonth-1);
$preMonth = $this->getPreMonth();
//cp
$preCpMonth = $this->statementWarningInfoModel->where([
'count_year'=>$year,
'count_month'=>$month,
'count_year'=>$preMonth[0],
'count_month'=>$preMonth[1],
'company_belong'=>9
])->getField('company_id,is_wm',true);
@ -157,8 +155,8 @@ class StatementWarningSetController extends Controller {
//下游
$preMonth = $this->statementWarningInfoModel->where([
'count_year'=>$year,
'count_month'=>$month,
'count_year'=>$preMonth[0],
'count_month'=>$preMonth[1],
'company_belong'=>['NEQ',9]
])->getField('company_id,is_wm',true);
@ -182,50 +180,24 @@ class StatementWarningSetController extends Controller {
*/
private function getAllWmAmount()
{
//获取官方渠道
$merchantIds = M("payment_merchant","tab_")->group('main_id')->where("main_id = 1")->getField("GROUP_CONCAT(id) ids");
$where = [
'partner_type'=>['in',[0,1]],
'merchant_id'=>['in',$merchantIds],
'pay_status'=>1,
'payed_time'=>['between',[$this->beginThismonth,$this->endThismonth]],
];
$amout = $this->spendModel->where($where)->getField("sum(pay_amount) amount");
$sWWhere = [
"count_month"=>$this->month,
"count_year"=>$this->year,
"name"=>'wm_platm',
"type"=>1
];
$hasDb = $this->statementWarningModel->where($sWWhere)->find();
$saveData = array_merge(['money'=>$amout,'create_time'=>time()],$sWWhere);
if($hasDb){
$saveData['id'] = $hasDb['id'];
$this->statementWarningModel->save($saveData);
}else{
$this->statementWarningModel->add($saveData);
}
$amout = $this->spendModel->where($where)->where(['pay_way'=>['GT',0],])->getField("sum(pay_amount) amount");
$despost = M("deposit","tab_")->where($where)->getField("sum(pay_amount) amount");
$this->addStatementWarning(1,'wm_platm',$amout-0+$despost);
}
/**
* 添加默认信息
*/
private function setDefaultStatementWarning()
{
$Where = [
"count_month"=>$this->month,
"count_year"=>$this->year,
"name"=>'费用',
"type"=>3
];
$hasDb = $this->statementWarningModel->where($Where)->find();
$saveData = array_merge(['money'=>700000,'create_time'=>time()],$Where);
if(!$hasDb){
$this->statementWarningModel->add($saveData);
}
$Where['name'] = '其他收入';
$hasDb = $this->statementWarningModel->where($Where)->find();
$saveData = array_merge(['money'=>26000,'create_time'=>time()],$Where);
if(!$hasDb){
$this->statementWarningModel->add($saveData);
}
$this->addStatementWarning(3,'cost',700000,false);
$this->addStatementWarning(3,'other_income',26000,false);
}
/**
* 获取上游的结算金额
@ -238,21 +210,8 @@ class StatementWarningSetController extends Controller {
$company = $this->getCpCompanyInfo(array_keys($gamedata));
$cpStatementAmount = $this->addCpStatementWarningInfo($company,$gamedata);
}
$savedata = [
'type'=>2,
'name'=>'up_statement',
'count_month'=>$this->month,
'count_year'=>$this->year
];
$hasDb = $this->statementWarningModel->where($savedata)->find();
$savedata = array_merge(['money'=>$cpStatementAmount,'create_time'=>time()],$savedata);
if($hasDb){
$savedata['id'] = $hasDb['id'];
$this->statementWarningModel->save($savedata);
}else{
$this->statementWarningModel->add($savedata);
}
$this->addStatementWarning(2,'up_statement',$cpStatementAmount);
}
/**
* 获取月份游戏结算额
@ -323,20 +282,8 @@ class StatementWarningSetController extends Controller {
$company = $this->getPromoteCompanyGameSpend($company,0);
$pcStatementAmount = $this->addStatementWarningInfo($company,0);
$savedata = [
'type'=>2,
'name'=>'pc_statement',
'count_month'=>$this->month,
'count_year'=>$this->year
];
$hasDb = $this->statementWarningModel->where($savedata)->find();
$savedata = array_merge(['money'=>$pcStatementAmount,'create_time'=>time()],$savedata);
if($hasDb){
$savedata['id'] = $hasDb['id'];
$this->statementWarningModel->save($savedata);
}else{
$this->statementWarningModel->add($savedata);
}
$this->addStatementWarning(2,'pc_statement',$pcStatementAmount);
}
private function getPromoteCompanyGameSpend($company,$companyBelong)
{
@ -416,17 +363,19 @@ class StatementWarningSetController extends Controller {
}
private function addStatementWarning($type,$name,$money)
private function addStatementWarning($type,$name,$money,$issave = true)
{
//汇总表差一个月
$preMonth = $this->getPreMonth();
$savedata = [
'type'=>$type,
'name'=>$name,
'count_month'=>$this->month,
'count_year'=>$this->year
'count_year'=>$preMonth[0],
'count_month'=>$preMonth[1]
];
$hasDb = $this->statementWarningModel->where($savedata)->find();
$savedata = array_merge(['money'=>$money,'create_time'=>time()],$savedata);
if($hasDb){
if($hasDb && $issave){
$savedata['id'] = $hasDb['id'];
$this->statementWarningModel->save($savedata);
}else{
@ -485,6 +434,12 @@ class StatementWarningSetController extends Controller {
return 1;
}
private function getPreMonth()
{
return explode('-',date("Y-m",$this->beginThismonth-1));
}

@ -5,7 +5,7 @@ use Think\Controller;
class MarketEvent extends Controller
{
private $MarketDepartmentId = "1,2";
private $MarketDepartmentId = "1,2,3";
private $ManagerLevel = "4";
private $DirectorLevel = "5";
private $LevelConfig = [
@ -14,7 +14,22 @@ class MarketEvent extends Controller
'3'=>'高级',
'4'=>'经理'
];
private $uid;
private $gid;
private $isMarket = false;
private $isInit = false;
public function defaultInit()
{
if($isInit) return $this;
$this->uid = $_SESSION['onethink_admin']['user_auth']['uid'];
$this->gid = session('user_group_id');
$info = $this->isMarketAdminGroup($this->gid);
if($info){
$this->isMarket = true;
}
return $this;
}
/**
* 获取所有市场部组id
*/
@ -78,7 +93,7 @@ class MarketEvent extends Controller
*/
public function getConfig($key)
{
return $this->$key;
return $this->defaultInit()->$key;
}
/**
* 获取等级名称
@ -87,6 +102,11 @@ class MarketEvent extends Controller
{
return $this->LevelConfig[$level];
}
/**
* 是否是市场专员
* @param [int] $gid 管理组id
* @return boolean
*/
public function isMarketAdminGroup($gid)
{
$where = [
@ -96,18 +116,6 @@ class MarketEvent extends Controller
return M('auth_group','sys_')->field("id,department_id,department_level")->where($where)->find();
}
public function isDepartmentLeder($department_id,$uid)
{
$gid = M("auth_group_access")->where("uid = '{$uid}'")->getField('group_id');
return M('department','sys_')->where("id = '{$department_id}' and leader_group = '$gid'")->field("id")->find();
}
public function isMarketLeder($uid)
{
$gid = M("auth_group_access")->where("uid = '{$uid}'")->getField('group_id');
return M("auth_group")->where("id = '{$gid}' and department_level = '{$this->DirectorLevel}'")->field("id")->find();
}
/**
* 添加部门总监的会长权限
* $uid,$promote_id
@ -239,5 +247,28 @@ class MarketEvent extends Controller
session('user_auth_company_ids', $companyIds);
return $companyIds;
}
/**
* 获取部门领导管辖的所有用户,非领导返回自己
*
* @param int $value uid/null时候为自己
* @param string $type uid/group_id
* @return array
*/
public function getAdminidByLeaderid($uid=null)
{
$this->defaultInit();
if($uid){
$gid = M("auth_group_access")->where("uid = '{$uid}'")->getField('group_id');
}else{
$uid = $this->uid;
$gid = $this->gid;
}
$group_ids = M('department','sys_')->where("leader_group = '{$gid}'")->getField("group_concat(group_ids) as group_ids");
if(!$group_ids) return $uid;
$adminIds = M("auth_group_access")->where("group_id in ({$group_ids})")->getField('uid',true);
return $adminIds ?? $uid;
}
}

@ -95,7 +95,7 @@
<div class="data_list box_mt" style="margin-top: 10px;0">
<div class="">
<form id="form" action="{:U('coefficientSave')}" method="post" class="form-horizontal">
<form id="form" method="post" class="form-horizontal">
<table id="exporttable">
<!-- 表头 -->
<thead>
@ -115,7 +115,7 @@
</tbody>
</table>
<div class="jssearch fr cf search_list" style="width: 100%;">
<a class="sch-btn" id="jssearch" url="{:U('coefficientSave')}" style="width: 120px;margin-top: 20px;margin-right: 20px;float: right;">提交保存</a>
<a class="sch-btn" id="confimBtn" url="{:U('coefficientSave')}" style="width: 120px;margin-top: 20px;margin-right: 20px;float: right;">提交保存</a>
</div>
</form>
</div>
@ -125,8 +125,7 @@
<script type="text/javascript">
$("#jssearch").click(function(){
$("#confimBtn").click(function(){
var url = $(this).attr('url');
var query = $('table').find('input').serialize();
query += "&" + $('table').find('select').serialize();
@ -140,8 +139,8 @@
}
url += '&is_get=1';
layer.confirm('【提示】是否确认财务部编辑保存', {
layer.confirm('【提示】是否绩效确认', {
btn: ['确认','取消'],
title:false
}, function(index){

@ -104,11 +104,10 @@
<if condition="$is_edit eq 1">
<input type="text" name="year" value="{$data['count_year']}" style="display: none;">
<input type="text" name="type" value="{$data['type']}" style="display: none;">
<if condition="$data['chenge_name'] eq 0">
<input type="text" name="name" value="{$data['orgin_name']}" style="display: none;">
</if>
</if>
<if condition="($data['name'] eq '费用') OR ($data.name eq '其他收入')">
<input type="text" name="name" value="{$data['name']}" style="display: none;">
</if>
<tr>
<td class="l"><i class="mustmark">*</i>年度:</td>
<td class="r table_radio">
@ -138,7 +137,7 @@
<td class="l"><i class="mustmark">*</i>类型名称:</td>
<td class="r table_radio">
<div style="float: left;">
<input type="text" class="txt ratio" name="name" id="name" value="{$data['name']}" placeholder="请输入名称" style="width: 150px;" <if condition="($data['name'] eq '费用') OR ($data.name eq '其他收入')">disabled</if>>
<input type="text" class="txt ratio" name="name" id="name" value="{$data['name']}" placeholder="请输入名称" style="width: 150px;" <if condition="($data['chenge_name'] eq 0) AND ($is_edit eq 1)">disabled</if>>
</div>
</td>
</tr>

@ -53,7 +53,7 @@
<div class="cf main-place top_nav_list navtab_list">
<h3 class="page_title">财务预警表</h3>
<p class="description_text">每日凌晨五点自动更新,如需获取时时数据,请手动进行【月份重算】</p>
<p class="description_text">每日凌晨五点自动更新,如需获取时时数据,请手动进行【月份重算】/ 预警月份与时时表差一个月</p>
</div>
<style>
@ -124,10 +124,9 @@
<td>
<if condition="$vo.is_edit eq 1 ">
<a href="{:U('edit?act=edit',array('name'=>$vo['name'],'count_year'=>I('year')))}">编辑</a>
<if condition="($vo['name'] neq '费用') AND ($vo.name neq '其他收入')">
<a style="color: red;" href="{:U('del',array('name'=>$vo['name'],'count_year'=>I('year')))}" class="confirm ajax-get">删除</a>
</if>
</if>
<if condition="$vo.is_del eq 1 ">
<a style="color: red;" href="{:U('del',array('name'=>$vo['name'],'count_year'=>I('year')))}" class="confirm ajax-get">删除</a>
</if>
</td>
</tr>
@ -241,8 +240,8 @@
layer.msg('要重算的月份必须小于当前时间');
return false;
}
if(subtimeArr[0] == year && subtimeArr[1] > month){
layer.msg('要重算的月份必须小于当前时间');
if(subtimeArr[0] == year && subtimeArr[1] >= month){
layer.msg('要重算的月份必须小于当前月份');
return false;
}

@ -41,26 +41,66 @@ class WxPaymentController extends BaseController
$params = I('get.');
$page = $params['p'] ? intval($params['p']) : 1;
$row = $params['row'] ? intval($params['row']) : 10;
$where = [];
$where = [
'_string'=>'1=1'
];
if(isset($_REQUEST['nickname'])){
$where['nickname'] = ["LIKE","%{$_REQUEST['nickname']}%"];
}
if(isset($_REQUEST['realname'])){
$where['realname'] = ["LIKE","%{$_REQUEST['realname']}%"];
}
if(isset($_REQUEST['type'])){
if($_REQUEST['type'] == 1){
$where['_string'] .= " AND realname = ''";
}
if($_REQUEST['type'] == 2){
$where['_string'] .= " AND realname != ''";
}
}
$data = M('mini_program_user', 'tab_')
->field("wx_json",true)
->where($where)
->page($page,$row)
->select();
foreach ($data as $key => $value) {
if(empty($value['realname'])){
$data[$key]['is_pay'] =0;
}else{
$data[$key]['is_pay'] =1;
}
$data[$key]['create_time'] = date('Y-m-d H:i:s',$value['create_time']);
}
$count = M('mini_program_user', 'tab_')->where($where)->count();
$page = set_pagination_all($count['count'], $row);
$page = set_pagination_all($count, $row);
if ($page) {
$this->assign('_page', $page);
}
$this->assign('data', $data);
$this->display();
}
public function updateRealname()
{
$params = I('post.');
M('mini_program_user', 'tab_')->save([
'id'=>$params['id'],
'realname'=>trim($params['realname'])
]);
$this->ajaxReturn([
'success'=>'ok'
]);
}
public function addPayList()
{
$params = I('post.');
$batch = date('Ymd').date('His').sp_random_num(3);
$item = M('mini_program_user',"tab_")->field('realname,openid')->where(['id'=>$params['id']])->find();
$item['statement_money'] = $params['statement_money'];
$this->addListItem($batch,$item);
$this->ajaxReturn(["status"=>1,"msg"=>"添加成功"]);
}
public function customerExport()
{
@ -90,7 +130,7 @@ class WxPaymentController extends BaseController
$line = 2;
//设置模板文件
foreach ($data as $key => $value) {
$objPHPExcel->getActiveSheet()->setCellValue('A'.$line, $line-1)->setCellValue('B'.$line, $value['openid']);
$objPHPExcel->getActiveSheet()->setCellValue('A'.$line, $line-1)->setCellValue('B'.$line, $value['openid'])->setCellValue('C'.$line, $value['realname']);
$line++;
}
@ -199,36 +239,41 @@ class WxPaymentController extends BaseController
if(count($checkarr) < 1){
$this->ajaxReturn(["status"=>1,"msg"=>"ok"]);
}
foreach ($checkarr as $k => &$v) {
$this->addListItem($batch,$v);
}
$this->ajaxReturn(["status"=>1,"msg"=>"ok"]);
}
private function addListItem($batch,$v)
{
$pinyin = new \Think\Pinyin();
$wxPayment = M('wx_payment',"tab_");
foreach ($checkarr as $k => &$v) {
if(!isset($v['realname']) || !isset($v['openid']) || !isset($v['statement_money']) || $v['realname'] == '' || $v['openid'] == '' || $v['statement_money'] <= 0){
$wxPayment->where("batch_num = '{$v['batch_num']}'")->delete();
$this->ajaxReturn(["status"=>0,"msg"=>"真实姓名,openid,打款金额均不允许为空"]);
}
if(!isset($v['realname']) || !isset($v['openid']) || !isset($v['statement_money']) || $v['realname'] == '' || $v['openid'] == '' || $v['statement_money'] <= 0){
$wxPayment->where("batch_num = '{$batch}'")->delete();
$this->ajaxReturn(["status"=>0,"msg"=>"真实姓名,openid,打款金额均不允许为空"]);
}
$num = mb_strlen($v['realname'], 'UTF8');
$short = '';
for ($i = 0; $i < $num; $i++) {
$str = mb_substr($v['realname'], $i, $i + 1, 'UTF8');
$short .= $pinyin->getFirstChar($str);
}
$num = mb_strlen($v['realname'], 'UTF8');
$short = '';
for ($i = 0; $i < $num; $i++) {
$str = mb_substr($v['realname'], $i, $i + 1, 'UTF8');
$short .= $pinyin->getFirstChar($str);
}
$v['batch_num'] = $batch;
$v['statement_num'] = "WX{$short}".date('Ymd').date('His').sp_random_string(5);
$v['create_time'] = time();
$res = $wxPayment->add($v);
if($res === false){
$wxPayment->where("batch_num = '{$v['batch_num']}'")->delete();
$this->ajaxReturn(["status"=>0,"msg"=>"添加失败"]);
}
$v['batch_num'] = $batch;
$v['statement_num'] = "WX{$short}".date('Ymd').date('His').sp_random_string(5);
$v['create_time'] = time();
$res = $wxPayment->add($v);
if($res === false){
$wxPayment->where("batch_num = '{$batch}'")->delete();
$this->ajaxReturn(["status"=>0,"msg"=>"添加失败"]);
}
$this->ajaxReturn(["status"=>1,"msg"=>"ok"]);
}
public function showPayment()
{
if(!isset($_REQUEST['ids'])) $this->error("参数错误");

@ -181,7 +181,7 @@
<script type="text/javascript">
var isfile = false;
var rABS = false; //是否将文件读取为二进制字符串
var check_size = 1;//每次验证的数量
var check_size = 5;//每次验证的数量
var batch = '{$batch}';
var sendDefaultData = {
"filedata_count": 0,

@ -142,6 +142,18 @@
<input type="text" name="nickname" class="" value="{:I('nickname')}" placeholder="昵称查找" style="width: 180px;"/>
</div>
<div class="input-list">
<input type="text" name="realname" class="" value="{:I('realname')}" placeholder="真实姓名查找" style="width: 180px;"/>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="type" name="type" class="select_gallery" style="width:150px;">
<option value="">是否实名</option>
<option value="1" <if condition="1 eq $_GET['type']">selected=selected</if>>未实名</option>
<option value="2" <if condition="2 eq $_GET['type']">selected=selected</if>>已实名</option>
</select>
</div>
<div class="input-list">
<a class="sch-btn" href="javascript:;" id="search" url="{:U('customerLists','model='.$model['name'] .'&row='.I('row'),false)}">搜索</a>
</div>
@ -163,10 +175,12 @@
<thead>
<tr>
<th><input class="check-all" type="checkbox"></th>
<th>昵称</th>
<th>openid</th>
<th>真实姓名</th>
<th>昵称</th>
<th>头像</th>
<th>添加时间</th>
<th>操作</th>
</tr>
</thead>
@ -181,10 +195,17 @@
<volist name="data" id="data">
<tr>
<td ><input class="ids" type="checkbox" value="{$data['ids']}" data-verify_id="{$data['id']}" name="ids[]"></td>
<td>{$data.nickname}</td>
<td>{$data.openid}</td>
<td>{$data.realname}</td>
<td>{$data.nickname}</td>
<td style="display: flex;justify-content:center"><img src="{$data.avatar}" style="width: 50px;height: auto;"></td>
<td>{$data.create_time}</td>
<td>
<a class="edit" data-id="{$data['id']}" data-realname="{$data.realname}">编辑</a>
<if condition="$data.is_pay eq 1 ">
<a class="pay" data-id="{$data['id']}" data-realname="{$data.realname}">打款</a>
</if>
</td>
</tr>
</volist>
</notemtpy>
@ -193,6 +214,44 @@
</div>
</div>
<script type="text/html" id="updateRealnameTpl">
<div style="padding:10px 40px 30px;">
<spend style="font-size:14px;color:#666;">
小程序用户实名修改
</spend>
<table border="0" cellspacing="0" cellpadding="0" style="margin-top:30px;">
<tr>
<td class="l noticeinfo" style="width:80px;">真实姓名:</td>
<td class="r table_radio">
<input type="text" id="realname" name="realname" autocomplete="off" placeholder="请输入真实姓名" />
</td>
</tr>
</table>
<button class="submit_btn mlspacing" id="updateStatementSubmit" type="submit" style="margin-top:30px;">
保存
</button>
</div>
</script>
<script type="text/html" id="payTpl">
<div style="padding:10px 40px 30px;">
<spend style="font-size:14px;color:#666;">
打款金额设置(单位元)
</spend>
<table border="0" cellspacing="0" cellpadding="0" style="margin-top:30px;">
<tr>
<td class="l noticeinfo" style="width:80px;">打款金额:</td>
<td class="r table_radio">
<input type="number" οninput="value=value.replace(/[^\w\.\/]/ig, '')" id="statement_money" name="statement_money" autocomplete="off" placeholder="请输入打款金额" />
</td>
</tr>
</table>
<button class="submit_btn mlspacing" id="paySubmit" type="submit" style="margin-top:30px;">
保存
</button>
</div>
</script>
<div class="page">
{$_page|default=''}
</div>
@ -222,6 +281,86 @@
highlight_subnav("{:U('customerLists')}");
$(function(){
$(".edit").on("click",function(){
var html = $("#updateRealnameTpl").html();
var orginData = $(this).data();
layer.open({
type: 1,
title: "编辑",
maxWidth:720,
closeBtn: 1,
shadeClose: true,
content: html,
success:function(){
$("#realname").val(orginData.realname);
$("#updateStatementSubmit").off("click");
$("#updateStatementSubmit").on("click",function() {
var realname= $("#realname").val();
$.ajax({
type: 'post',
url: "{:U('updateRealname')}",
data:{realname:realname,id:orginData.id},
success: function(data) {
if(data.success){
layer.alert('修改成功',function(){
window.location.reload();
});
}else{
layer.alert('修改失败');
}
},
error:function(){
layer.alert("网络错误或超时");
return false;
}
});
});
}
});
})
$(".pay").on("click",function(){
var html = $("#payTpl").html();
var orginData = $(this).data();
layer.open({
type: 1,
title:'向【'+orginData.realname+'】打款',
maxWidth:720,
closeBtn: 1,
shadeClose: true,
content: html,
success:function(){
$("#statement_money").val(0);
$("#paySubmit").off("click");
$("#paySubmit").on("click",function() {
var statement_money= $("#statement_money").val();
$.ajax({
type: 'post',
url: "{:U('addPayList')}",
data:{statement_money:statement_money,id:orginData.id},
success: function(data) {
if(data.status ==1){
layer.alert('添加成功',function(){
window.location.href = "{:U('lists')}";
});
}else{
layer.alert(data.msg);
}
},
error:function(){
layer.alert("网络错误或超时");
return false;
}
});
});
}
});
})
$("#customerExport").click(function () {
var flag = false;
var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) {

Loading…
Cancel
Save