更新spen root

master
chenzhi 5 years ago
parent f6f47748bc
commit 50efce9315

@ -19,7 +19,7 @@ class SpendCountSetController extends \Think\Controller
$this->endThismonth = mktime(0,0,0,date('m')-1,date('t'),date('Y'))-1;
$this->date = date('Y')."-".((date('m')-1) > 9 ? (date('m')-1) : "0".(date('m')-1));
$this->nowdata =time();
$this->model =M("spend",'tab_');
$this->model =M("spend_count",'tab_');
}
public function initCount()
{
@ -27,8 +27,8 @@ class SpendCountSetController extends \Think\Controller
if($countRes > 0){
die("init error");
}
$nowdate = date('Y')."-".(date('m') > 9 ? date('m') : "0".date('m'));
// $nowdate = "2017-10";
// $nowdate = date('Y')."-".(date('m') > 9 ? date('m') : "0".date('m'));
$nowdate = "2017-10";
//获取所有的月份 pay_time
$res = M("spend",'tab_')->field("FROM_UNIXTIME(pay_time,'%Y-%m') AS pay_time")->buildSql();
$res = M()->table($res.' a')->group('pay_time')->select();
@ -48,7 +48,8 @@ class SpendCountSetController extends \Think\Controller
$this->getBalanceData();
$this->getBingData();
$this->getInsideData();
$this->setRoot();
$this->model->commit();
}
}
@ -69,7 +70,7 @@ class SpendCountSetController extends \Think\Controller
$this->getBalanceData();
$this->getBingData();
$this->getInsideData();
$this->setRoot();
$this->model->commit();
die("success");
}
@ -254,6 +255,37 @@ class SpendCountSetController extends \Think\Controller
}
// return true;
}
public function setRoot()
{
if(!$this->continue){
die("api error");
}
$map = array(
"parent_id"=>array("GT",0),
"count_date"=>$this->date
);
$user = $this->model->field("parent_id,promote_id")->where($map)->group("promote_id")->select();
$Promote=M("promote","tab_");
for ($i=0; $i < count($user); $i++) {
# code...
$map['id']=$user[$i]['parent_id'];
$root=$Promote->field('IFNULL(parent_id,0) root_id,parent_name root_name')->where($map)->find();
if(!$root){
$root['root_id']=0;
$root['root_name']='官方渠道';
}
//保存
$where = array(
"promote_id"=>$user[$i]['promote_id'],
"count_date"=>$this->date
);
$tempdbres = $this->model->where($where)->save($root);
if(!$tempdbres){
$this->model->rollback();
die("setRoot error");
}
}
}

@ -197,6 +197,8 @@ CREATE TABLE `tab_spend_count` (
`promote_account` varchar(30) DEFAULT '' COMMENT '推广员账号',
`parent_id` int(11) DEFAULT '0' COMMENT '父类ID',
`parent_name` varchar(30) DEFAULT NULL COMMENT '父类名称',
`root_id` int(11) DEFAULT 0 COMMENT '根ID',
`root_name` varchar(30) DEFAULT NULL COMMENT '根名称',
`game_id` int(11) NOT NULL DEFAULT '0' COMMENT '游戏id',
`game_name` varchar(30) DEFAULT '' COMMENT '游戏名称',
`partner_id` int(11) DEFAULT '0' COMMENT '合作方id',

Loading…
Cancel
Save