|
|
|
@ -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");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|