You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
673 lines
26 KiB
PHP
673 lines
26 KiB
PHP
<?php
|
|
|
|
//use Admin\FinancialSummarySetController;
|
|
namespace Admin\Controller;
|
|
|
|
/**
|
|
* 新功能之后还未来的急跑的脚本初始化数据
|
|
* @author chenzhi
|
|
*/
|
|
class OldCountController extends \Think\Controller
|
|
{
|
|
|
|
public function setLackStatementInfo() {
|
|
|
|
$arrkey = [
|
|
'A'=>'num',
|
|
'B'=>'company_name',
|
|
'C'=>'account',
|
|
'D'=>'company_belong_str',
|
|
'E'=>'company_relation_str',
|
|
'F'=>'nickname',
|
|
'G'=>'company_type',
|
|
'H'=>'game_name',
|
|
'I'=>'game_type_name',
|
|
'J'=>'time',
|
|
'K'=>'platform_amount',
|
|
'L'=>'refund',
|
|
'M'=>'ratio',
|
|
'N'=>'increment_ratio',
|
|
'O'=>'sum_money',
|
|
'P'=>'reward',
|
|
'Q'=>'fine',
|
|
'R'=>'withhold',
|
|
'S'=>'week_amount',
|
|
'T'=>'sum_money_s',
|
|
'U'=>'payee_name',
|
|
'V'=>'bank_account',
|
|
'W'=>'opening_bank',
|
|
'X'=>'is_payment',
|
|
'Y'=>'is_pay',
|
|
'Z'=>'remark'
|
|
];
|
|
|
|
header("Content-type: text/html; charset=utf-8");
|
|
error_reporting(E_ALL);
|
|
ini_set('display_errors', TRUE);
|
|
ini_set('display_startup_errors', TRUE);
|
|
|
|
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
|
|
|
date_default_timezone_set('Asia/Shanghai');
|
|
Vendor("PHPExcel.PHPExcel");
|
|
|
|
$objPHPExcel = new \PHPExcel();
|
|
$objReader = \PHPExcel_IOFactory::createReader('Excel2007');
|
|
|
|
//设置模板文件
|
|
$objPHPExcel = $objReader->load("Public/Admin/excel/set_info.xls");
|
|
|
|
$objWriter = new \PHPExcel_Writer_Excel5($objPHPExcel);
|
|
$currentSheet = $objPHPExcel->getSheet(0); //读取excel文件中的第一个工作表
|
|
$allColumn = 90; //取得最大的列号
|
|
$allRow = $currentSheet->getHighestRow(); //取得一共有多少行
|
|
$excelResult = []; //声明数组
|
|
// dump($allColumn);die();
|
|
$startRow = 3;
|
|
|
|
for ($j = $startRow; $j <= $allRow; $j++) {
|
|
//从A列读取数据
|
|
for ($k = 65; $k <= $allColumn; $k++) {
|
|
// 读取单元格
|
|
$excelResult[$j][$arrkey[chr($k)]] = (string)$objPHPExcel->getActiveSheet()->getCell(chr($k)."$j")->getValue();
|
|
}
|
|
}
|
|
|
|
$handle_data = [];
|
|
$pool_data = [];
|
|
// dump($excelResult);
|
|
|
|
foreach ($excelResult as $key => $value) {
|
|
$is_continue = 0;
|
|
$company_info = M("promote_company","tab_")->field("id company_id,company_type,bank_card,bank_cardname,bank_name,bank_address,ali_user,ali_account")->where(['company_name'=>$value['company_name']])->find();
|
|
|
|
if(!$company_info) {
|
|
continue;
|
|
}
|
|
|
|
$lack_data = M("company_lack_statement_info","tab_")
|
|
->where([
|
|
'company_id'=>$company_info['company_id']
|
|
])
|
|
->select();
|
|
$time = explode('-',$value['time']);
|
|
$game_data = M("game","tab_")->where(['relation_game_name'=>$value['game_name']])->find();
|
|
|
|
foreach ($lack_data as $lkey => $lvalue) {
|
|
|
|
$statement_info = json_decode($lvalue['statement_info'],true);
|
|
// dump($statement_info);
|
|
|
|
foreach ($statement_info as $skey => $svalue) {
|
|
|
|
|
|
|
|
$game_list = $svalue['game_list'];
|
|
foreach ($game_list as $gkey => $gvalue) {
|
|
// if($company_info['company_id'] == 73&&$gvalue['pay_amount']=='12.00' ) {
|
|
// dump($svalue);
|
|
// dump($gvalue['statement_begin_time'] == $time['0']);
|
|
// dump($gvalue['statement_end_time'] == $time['1']);
|
|
// dump($gvalue['relation_game_id'] == $game_data['relation_game_id']);
|
|
// dump($gvalue['pay_amount'] == number_format($value['platform_amount'],2,'.',''));
|
|
// }
|
|
//存在的游戏流水内部条件,如果存在不进行下列操作
|
|
if ($gvalue['statement_begin_time'] == $time['0']
|
|
&&$gvalue['statement_end_time'] == $time['1']
|
|
&&$gvalue['relation_game_id'] == $game_data['relation_game_id']
|
|
&&$gvalue['pay_amount'] == number_format($value['platform_amount'],2,'.','')) {
|
|
|
|
$is_continue = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
//已经存在的单子结算
|
|
if ($is_continue) {
|
|
continue;
|
|
}
|
|
|
|
$handle_data[$value['time'].$company_info['company_id']]['company_id'] = $company_info['company_id'];
|
|
$handle_data[$value['time'].$company_info['company_id']]['company_type'] = $company_info['company_type'];
|
|
$handle_data[$value['time'].$company_info['company_id']]['company_name'] = $value['company_name'];
|
|
|
|
$companyInfo = [
|
|
'account'=>$value['account'],
|
|
'company_relation_str'=>$value['company_relation_str'],
|
|
'company_belong_str'=>$value['company_belong_str'],
|
|
'company_type_str'=>$value['company_type'],
|
|
'nickname'=>'nickname',
|
|
];
|
|
|
|
$relation = M("company_relation","tab_")
|
|
->where("(first_company_id = {$company_info['company_id']} and first_company_type!=3) or (second_company_id = {$company_info['company_id']} and second_company_type!=3)")
|
|
->find();
|
|
|
|
if ($relation['is_payment'] == 1) {
|
|
$companyInfo['ali_user'] = $company_info['ali_user'];
|
|
$companyInfo['ali_account'] = $company_info['ali_account'];
|
|
} else {
|
|
$companyInfo['payee_name'] = $company_info['bank_address'];
|
|
$companyInfo['bank_account'] = $company_info['bank_card'];
|
|
$companyInfo['opening_bank'] = $company_info['bank_name'];
|
|
}
|
|
|
|
$handle_data[$value['time'].$company_info['company_id']]['statement_money'] += $value['sum_money']-$value['fine']+$value['reward']-$value['withhold'];
|
|
$handle_data[$value['time'].$company_info['company_id']]['pay_amount'] += $value['sum_money']-$value['fine']+$value['reward']-$value['withhold'];
|
|
$handle_data[$value['time'].$company_info['company_id']]['company_info'] = json_encode($companyInfo);
|
|
$handle_data[$value['time'].$company_info['company_id']]['platform_amount'] += $value['platform_amount'];
|
|
$handle_data[$value['time'].$company_info['company_id']]['fine'] += $value['fine'];
|
|
$handle_data[$value['time'].$company_info['company_id']]['reward'] += $value['reward'];
|
|
|
|
|
|
$handle_data[$value['time'].$company_info['company_id']]['statement_begin_time'] = strtotime(str_replace('.','-',$time['0']));
|
|
$handle_data[$value['time'].$company_info['company_id']]['statement_end_time'] = strtotime(str_replace('.','-',$time['1']))+86399;
|
|
|
|
$p_id = M("promote","tab_")->field("id")->where(['account'=>$value['account']])->find();
|
|
|
|
if ($handle_data[$value['time'].$company_info['company_id']]['statement_info']) {
|
|
$handle_data[$value['time'].$company_info['company_id']]['statement_info'][0]['game_list'][] =
|
|
[
|
|
'pay_amount'=>$value['platform_amount'],
|
|
'relation_game_id'=>$game_data['relation_game_id'],
|
|
'game_name'=>$game_data['relation_game_name'],
|
|
'p_id'=>$p_id['id'],
|
|
'all_pay_amount'=>$value['platform_amount'],
|
|
'game_type_name'=>$game_data['game_type_name'],
|
|
'ratio'=>$value['ratio']*100,
|
|
'sum_money'=>number_format($value['sum_money'],2,'.',''),
|
|
'fax_ratio'=>0,
|
|
'statement_begin_time'=>$time['0'],
|
|
'statement_end_time'=>$time['1'],
|
|
'fine'=>$value['fine'],
|
|
'reward'=>$value['reward'],
|
|
'statement_type'=>0,
|
|
'refund'=>$value['refund'],
|
|
'withhold'=>$value['withhold'],
|
|
'increment_ratio'=>$value['increment_ratio']*100
|
|
];
|
|
} else {
|
|
$handle_data[$value['time'].$company_info['company_id']]['statement_info'][] = [
|
|
"account"=>$value['account'],
|
|
"game_list"=>[
|
|
[
|
|
'pay_amount'=>$value['platform_amount'],
|
|
'relation_game_id'=>$game_data['relation_game_id'],
|
|
'game_name'=>$game_data['relation_game_name'],
|
|
'p_id'=>$p_id['id'],
|
|
'all_pay_amount'=>$value['platform_amount'],
|
|
'game_type_name'=>$game_data['game_type_name'],
|
|
'ratio'=>$value['ratio']*100,
|
|
'sum_money'=>number_format($value['sum_money'],2,'.',''),
|
|
'fax_ratio'=>0,
|
|
'statement_begin_time'=>$time['0'],
|
|
'statement_end_time'=>$time['1'],
|
|
'fine'=>$value['fine'],
|
|
'reward'=>$value['reward'],
|
|
'statement_type'=>0,
|
|
'refund'=>$value['refund'],
|
|
'withhold'=>$value['withhold'],
|
|
'increment_ratio'=>$value['increment_ratio']*100
|
|
]
|
|
]
|
|
];
|
|
}
|
|
|
|
|
|
// $handle_data[$value['time'].$company_info['company_id']]['statement_info'] = $statement_info;
|
|
// del_lack_ids
|
|
|
|
$company_statement_pool = M("company_statement_pool","tab_")
|
|
->field("statement_num,del_lack_ids")
|
|
->where([
|
|
'statement_begin_time'=>$handle_data[$value['time'].$company_info['company_id']]['statement_begin_time'],
|
|
'statement_end_time'=>$handle_data[$value['time'].$company_info['company_id']]['statement_end_time'],
|
|
'company_type'=>2,
|
|
'withdraw_type'=>['neq',3]
|
|
])
|
|
->find();
|
|
|
|
$handle_data[$value['time'].$company_info['company_id']]['statement_pool_num'] = $company_statement_pool['statement_num']?$company_statement_pool['statement_num']:"";
|
|
$handle_data[$value['time'].$company_info['company_id']]['is_payment'] = $relation['is_payment'];
|
|
$handle_data[$value['time'].$company_info['company_id']]['remark'] = $company_statement_pool['remark'];
|
|
|
|
}
|
|
$handle_data = array_values($handle_data);
|
|
|
|
// dump($handle_data);
|
|
|
|
foreach ($handle_data as $key => $value) {
|
|
|
|
$value['statement_info'] = json_encode($value['statement_info']);
|
|
$lack_id = M("company_lack_statement_info","tab_")->add($value);
|
|
$pool_data[$value['statement_pool_num']]['del_lack_ids'][] = $lack_id;
|
|
}
|
|
|
|
$lack_data324 = M("company_lack_statement_info","tab_")
|
|
->where([
|
|
'id'=>324
|
|
])
|
|
->find();
|
|
|
|
$lack_data324['fine'] = 5000;
|
|
$lack_data324['statement_money'] = $lack_data324['statement_money']-5000;
|
|
$lack_data324['pay_amount'] = $lack_data324['pay_amount']-5000;
|
|
$statement_info324 = json_decode($lack_data324['statement_info'],true);
|
|
$statement_info324[0]['game_list'][0]['fine'] = 5000;
|
|
$lack_data324['statement_info'] = json_encode($statement_info324);
|
|
M("company_lack_statement_info","tab_")
|
|
->where([
|
|
'id'=>324
|
|
])->save($lack_data324);
|
|
|
|
$lack_data334 = M("company_lack_statement_info","tab_")
|
|
->where([
|
|
'id'=>334
|
|
])
|
|
->find();
|
|
$lack_data334['fine'] = 2000;
|
|
$lack_data334['statement_money'] = $lack_data334['statement_money']-2000;
|
|
$lack_data334['pay_amount'] = $lack_data334['pay_amount']-2000;
|
|
$statement_info334 = json_decode($lack_data334['statement_info'],true);
|
|
$statement_info334[0]['game_list'][0]['fine'] = 2000;
|
|
$lack_data334['statement_info'] = json_encode($statement_info334);
|
|
M("company_lack_statement_info","tab_")
|
|
->where([
|
|
'id'=>334
|
|
])->save($lack_data334);
|
|
echo "success";
|
|
// foreach ($pool_data as $key => $value) {
|
|
//
|
|
// $pool_info = M("company_statement_pool","tab_")
|
|
// ->where(['statement_num'=>$key])
|
|
// ->find();
|
|
//
|
|
// $del_lack_ids = $pool_info['del_lack_ids'].','.implode(',',$value['del_lack_ids']);
|
|
// M("company_statement_pool","tab_")
|
|
// ->where(['statement_num'=>$key])
|
|
// ->save(['del_lack_ids'=>$del_lack_ids]);
|
|
//
|
|
// }
|
|
|
|
// M("company_lack_statement_info","tab_")->addAll($handle_data);
|
|
|
|
// dump($handle_data);
|
|
|
|
}
|
|
|
|
public function updateStatementInfo() {
|
|
|
|
$data = M("company_statement_info","tab_")
|
|
->where(['pay_status'=>['neq',0]])
|
|
->select();
|
|
|
|
foreach ($data as $key => $value) {
|
|
|
|
M("company_statement_info","tab_")
|
|
->where(['id'=>$value['id']])
|
|
->save([
|
|
'pay_verify_status'=>1,
|
|
'verify_time'=>$value['pay_time'],
|
|
'verify_member_id'=>1
|
|
]);
|
|
}
|
|
|
|
$data = M("excel_statement_info","tab_")
|
|
->where("1=1")
|
|
->select();
|
|
|
|
foreach ($data as $key => $value) {
|
|
$statement_info = json_decode($value['statement_info'],true);
|
|
$time = explode('-',$statement_info[0]['game_list'][0]['statement_time']);
|
|
$start = strtotime(str_replace('.','-',$time[0]));
|
|
$end = strtotime(str_replace('.','-',$time[1]));
|
|
|
|
M("excel_statement_info","tab_")
|
|
->where(['id'=>$value['id']])
|
|
->save([
|
|
'statement_begin_time'=>$start,
|
|
'statement_end_time'=>$end
|
|
]);
|
|
|
|
// dump($statement_info);
|
|
}
|
|
|
|
$data = M("excel_statement_info","tab_")
|
|
->where(['pay_status'=>['neq',0]])
|
|
->select();
|
|
|
|
foreach ($data as $key => $value) {
|
|
|
|
M("excel_statement_info","tab_")
|
|
->where(['id'=>$value['id']])
|
|
->save([
|
|
'verify_status'=>1,
|
|
'verify_time'=>$value['pay_time'],
|
|
'verify_member_id'=>1
|
|
]);
|
|
}
|
|
|
|
echo "success";
|
|
|
|
}
|
|
|
|
public function oldRewardChange() {
|
|
|
|
$data = M("company_lack_statement_info","tab_")
|
|
->where("(fine > 0 or reward > 0) and company_type = 2")
|
|
->select();
|
|
|
|
foreach ($data as $key => $value) {
|
|
|
|
$statement_info = json_decode($value['statement_info'],true);
|
|
$statement_info[0]['game_list'][0]['fine'] = $value['fine'];
|
|
$statement_info[0]['game_list'][0]['reward'] = $value['reward'];
|
|
$statement_info = json_encode($statement_info);
|
|
|
|
M("company_lack_statement_info","tab_")->where(['id'=>$value['id']])->save(['statement_info'=>$statement_info]);
|
|
|
|
}
|
|
|
|
echo "success";
|
|
|
|
}
|
|
|
|
public function changeCompanyGameidToPromoteGameid()
|
|
{
|
|
//默认设为
|
|
$Promote = M("Promote","tab_");
|
|
$PromoteCompany = M("promote_company","tab_");
|
|
$p_res = $PromoteCompany->field("id,game_ids")->select();
|
|
|
|
foreach ($p_res as $k => $v) {
|
|
if(!empty($v['game_ids'])){
|
|
$savedata['game_ids'] = $this->changeRelationGameidToGameid($v['game_ids']);
|
|
$Promote->where(["company_id"=>$v['id']])->save($savedata);
|
|
}
|
|
}
|
|
echo "changeCompanyGameidToPromoteGameid success";
|
|
}
|
|
|
|
public function changeDevelopTypeData() {
|
|
|
|
$is_save = M("promote","tab_")->where(['company_relation'=>2])->save(['company_relation'=>1]);
|
|
|
|
$is_save = M("promote_company","tab_")->where(['develop_type'=>2])->save(['develop_type'=>1]);
|
|
|
|
//更新tab_company_statement_info表的数据
|
|
$company_statement = M("company_statement_info","tab_")->field("id,company_info")->where(['company_info'=>['like',"%自主开发及维护%"]])->select();
|
|
|
|
foreach ($company_statement as $key => $value) {
|
|
|
|
$replace_statement = str_replace('自主开发及维护','自主开发',$value['company_info']);
|
|
|
|
M("company_statement_info","tab_")->where(['id'=>$value['id']])->save(['company_info'=>$replace_statement]);
|
|
|
|
}
|
|
|
|
//更新tab_company_lack_statement_info表的数据
|
|
$company_statement = M("company_lack_statement_info","tab_")->field("id,company_info")->where(['company_info'=>['like',"%自主开发及维护%"]])->select();
|
|
|
|
foreach ($company_statement as $key => $value) {
|
|
|
|
$replace_statement = str_replace('自主开发及维护','自主开发',$value['company_info']);
|
|
M("company_lack_statement_info","tab_")->where(['id'=>$value['id']])->save(['company_info'=>$replace_statement]);
|
|
|
|
}
|
|
|
|
echo "success\n";
|
|
|
|
}
|
|
|
|
/**
|
|
* 公会关系及游戏迁移
|
|
* 1. 迁移 公会company_relation到公司
|
|
* 2. 游戏 game_ids
|
|
* 3. 同步公司develop_type到公会
|
|
*/
|
|
public function changeOldCompanyRelation()
|
|
{
|
|
//默认设为
|
|
$Promote = M("Promote","tab_");
|
|
$PromoteCompany = M("promote_company","tab_");
|
|
$p_res = $Promote->field("id,account,game_ids,company_relation,company_id")->where("level = 1")->group("company_id")->select();
|
|
foreach ($p_res as $k => $v) {
|
|
|
|
if($v['id'] < 1) continue;
|
|
|
|
$savedata =[ "id"=>$v['company_id'] ];
|
|
if($v['company_relation'] == 1){
|
|
$savedata['develop_type'] = 3;
|
|
}else{
|
|
$savedata['develop_type'] = 2;
|
|
}
|
|
$savedata['game_ids'] = $this->changeGameidToRelationGameid($v['game_ids']);
|
|
$PromoteCompany->save($savedata);
|
|
|
|
$p_data = [
|
|
"company_relation"=>$savedata['develop_type']
|
|
];
|
|
$Promote->where("company_id = {$v['company_id']}")->save($p_data);
|
|
}
|
|
echo "changeOldCompanyRelation success";
|
|
}
|
|
protected function changeGameidToRelationGameid($ids,$type=false)
|
|
{
|
|
$rid = M('game', 'tab_')->field('relation_game_id')->where(["id"=>["in",$ids]])->group("relation_game_id")->select();
|
|
if($type){
|
|
return array_column($rid,'relation_game_id');
|
|
}else{
|
|
return implode(",",array_column($rid,'relation_game_id'));
|
|
}
|
|
}
|
|
protected function changeRelationGameidToGameid($ids,$type=false)
|
|
{
|
|
$rid = M('game', 'tab_')->field('id')->where(["relation_game_id"=>["in",$ids]])->select();
|
|
if($type){
|
|
return array_column($rid,'id');
|
|
}else{
|
|
return implode(",",array_column($rid,'id'));
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* 优化旧表数值,新表需要将 开票税点及渠道费 * 100
|
|
*/
|
|
public function ChangePartnerField_ChannelRateInvoiceRate()
|
|
{
|
|
if(time() > 1596211200){
|
|
die("该函数已失效");
|
|
}
|
|
$Partner = M("Partner","tab_");
|
|
$dbres = $Partner->field("id,channel_rate,invoice_rate")->select();
|
|
foreach ($dbres as $k => &$v) {
|
|
$v['channel_rate'] = $v['channel_rate']*100;
|
|
$v['invoice_rate'] = $v['invoice_rate']*100;
|
|
$Partner->save($v);
|
|
}
|
|
echo "ChangePartnerField_ChannelRateInvoiceRate success";
|
|
}
|
|
/**
|
|
* 新的游戏比例后的数据迁移
|
|
* 重复执行将会叠加数据,请勿重复执行
|
|
*/
|
|
public function PromoteToCompanyRatioInit()
|
|
{
|
|
//获取旧数据
|
|
$oldres = M("promote_game_ratio","tab_")->field("promote_id,relation_game_id,ratio,turnover_ratio,begin_time,end_time")->group("promote_id,relation_game_id")->select();
|
|
$adddata = [];
|
|
$CompanyGameRatio = M("company_game_ratio","tab_");
|
|
foreach ($oldres as $k => &$v) {
|
|
$comoany_id = $this->promoteIdToCompanyId($v['promote_id']);
|
|
unset($v['promote_id']);
|
|
$v['company_id'] = $comoany_id ;
|
|
$adddata[$comoany_id] = $v;
|
|
}
|
|
foreach($adddata as $k => &$v){
|
|
$map = [
|
|
"company_id"=>$v['company_id'],
|
|
"relation_game_id"=>$v['relation_game_id']
|
|
];
|
|
$cres = $CompanyGameRatio->where($map)->find();
|
|
if(empty($cres)){
|
|
$CompanyGameRatio->add($v);
|
|
}
|
|
}
|
|
echo "PromoteToCompanyRatioInit success";
|
|
}
|
|
protected function promoteIdToCompanyId($promote_id)
|
|
{
|
|
return M("promote","tab_")->field("company_id")->where("id='{$promote_id}'")->find()['company_id'];
|
|
}
|
|
|
|
/**
|
|
* 财务分类汇总统计旧数据聚合
|
|
*/
|
|
public function FinancialSummaryInit()
|
|
{
|
|
$sql = "truncate table tab_financial_summary";
|
|
if(IS_SUBSITE){
|
|
$res =M()->db(1,SUBSITE_DB)->execute($sql);
|
|
}else {
|
|
//清空数据库
|
|
$res = M()->execute($sql);
|
|
}
|
|
echo "tab_financial_summary 清空成功".PHP_EOL;
|
|
//获取19年9月到上个月的所有月份
|
|
$monthList = $this->getMonthsList();
|
|
$Financial = new FinancialSummarySetController();
|
|
foreach ($monthList as $k => $v) {
|
|
$Financial->setMonthFinancialSummary($v);
|
|
}
|
|
}
|
|
/*
|
|
*超级签订单新增识别微信或者支付宝2019-12-11
|
|
*/
|
|
public function gameSupersignPaywayInit()
|
|
{
|
|
$map = array(
|
|
"pay_status"=>1,
|
|
"pay_way"=>0
|
|
);
|
|
$GameSupersign = M("GameSupersign","tab_");
|
|
$dbres = $GameSupersign->field("id,trade_id")->where($map)->select();
|
|
$countdb = count($dbres);
|
|
if($countdb < 1){
|
|
die("No initialization required");
|
|
}
|
|
foreach ($dbres as $key => $value) {
|
|
$savedata = array(
|
|
"id"=>$value['id']
|
|
);
|
|
$tmp = (int)substr($value['trade_id'],0,4);
|
|
if($tmp > 3000){
|
|
$savedata['pay_way'] = 2; //微信
|
|
}else{
|
|
$savedata['pay_way'] = 1;//支付宝
|
|
}
|
|
$tres = $GameSupersign->save($savedata);
|
|
if($tres === false){
|
|
die("DB ERROR");
|
|
}
|
|
}
|
|
die("init ok");
|
|
}
|
|
/**
|
|
* mend表新增paymount字段用于统计补链前归属金额
|
|
*/
|
|
public function mendPayamountInit()
|
|
{
|
|
//获取符合条件的
|
|
$map = array("pay_amount"=>0);
|
|
$Mend = M("mend","tab_");
|
|
$Spend = M("Spend","tab_");
|
|
$Mend->where($map)->select();
|
|
$dbres = $Mend->field("id,user_account,promote_account,order_time,create_time")->where($map)->select();
|
|
$countdb = count($dbres);
|
|
if($countdb < 1) die("No initialization required");
|
|
echo "总需要统计数:{$countdb}".PHP_EOL;
|
|
foreach ($dbres as $key => $value) {
|
|
$savedata = array("id"=>$value['id']);
|
|
$saveflag = false;
|
|
//设置订单时间
|
|
$order_time = $value['order_time'];
|
|
if($value['order_time'] == 0){
|
|
$saveflag = true;
|
|
$savedata['order_time'] = $value['create_time'];
|
|
$order_time = $savedata['create_time'];
|
|
}
|
|
//获取金额
|
|
$smap = array(
|
|
"user_account"=>$value['user_account'],
|
|
"promote_account"=>$value['promote_account'],
|
|
"pay_time"=>array("LT",$order_time),
|
|
"pay_status"=>1
|
|
);
|
|
$pay_amount = $Spend->field("IFNULL(sum(pay_amount),0) pay_amount")->where($smap)->find()["pay_amount"];
|
|
if($pay_amount > 0){
|
|
$saveflag = true;
|
|
$savedata['pay_amount'] = $pay_amount;
|
|
}
|
|
if($saveflag){
|
|
$tres = $Mend->save($savedata);
|
|
if($tres === false){
|
|
die("DB ERROR");
|
|
}
|
|
}
|
|
if( $key % 20 == 0){
|
|
$j = (floor)($key/$countdb*100);
|
|
echo "当前进度:{$j}%".PHP_EOL;
|
|
}
|
|
|
|
}
|
|
die("init ok");
|
|
}
|
|
/**
|
|
* 修改公会内外团关系跟随公司 旧数据跟随 20200318
|
|
*/
|
|
public function promoteCompanyBelongInit()
|
|
{
|
|
//获取所有公司
|
|
$comoany = M("PromoteCompany","tab_")->field("id,company_belong,develop_type")->select();
|
|
$comoany[] = ["id"=>0,"company_belong"=>0,"develop_type"=>0]; //海南万盟
|
|
$count = count($comoany);
|
|
$promote = M("Promote","tab_");
|
|
for ($i=0; $i < $count; $i++) {
|
|
$savedata = array(
|
|
"company_belong"=>$comoany[$i]['company_belong'],
|
|
"company_relation"=>$comoany[$i]['develop_type'],
|
|
);
|
|
$tmpid = $comoany[$i]['id'];
|
|
$promote->where("company_id ='{$tmpid}'")->save($savedata);
|
|
}
|
|
die("promoteCompanyBelongInit success");
|
|
}
|
|
//获取公司月结所需要的所有月份截止至上个月
|
|
public function getMonthsList()
|
|
{
|
|
$start_month = "2019-09";
|
|
|
|
$temp = strtotime(date('Y-m-01 00:00:00',strtotime('-1 month')));
|
|
$end_month = date('Y',$temp)."-".date('m',$temp);
|
|
|
|
$time_arr = [];
|
|
$begin = new \DateTime($start_month);
|
|
$end = new \DateTime($end_month);
|
|
$end = $end->modify('+1 month');
|
|
$interval = new \DateInterval('P1M');
|
|
$daterange = new \DatePeriod($begin, $interval ,$end);
|
|
foreach($daterange as $date){
|
|
$time_arr[] = $date->format("Y-m");
|
|
}
|
|
return $time_arr;
|
|
}
|
|
|
|
|
|
|
|
}
|