优化数据

master
chenzhi 4 years ago
parent b6c87bfefe
commit 90de336434

@ -1082,6 +1082,6 @@ function is_subsiteTable($tableName,$is_subsiteTable=false)
*/
function addSubsiteWhere(&$map,$field){
if(IS_SUBSITE){
$map[$field] = PARTNER_TYPE;
$map[$field] = ["in",[0,PARTNER_TYPE]];
}
}

@ -99,7 +99,7 @@ class FinancialSummaryController extends AdminController
"count_year"=>$_REQUEST['year'],
"type"=>array("IN","1,{$_REQUEST['type']},4,5,6")
);
$dbres = M("FinancialSummary","tab_")->field("*")->where($map)->select();
$dbres = SM("FinancialSummary","tab_")->field("*")->where($map)->select();
foreach ($dbres as $k => $v) {
if($v['type'] == 1){

@ -31,7 +31,7 @@ class FinancialSummarySetController extends \Think\Controller
$this->date = $this->year."-".$this->month;
$this->nowdata =time();
$this->FinancialSummaryModel =M("FinancialSummary",'tab_');
$this->FinancialSummaryModel =SM("FinancialSummary",'tab_');
$this->DepositModel =M("Deposit",'tab_');
$this->SpendModel = M("Spend",'tab_');
$this->GameSupersignModel = M("GameSupersign",'tab_');
@ -134,6 +134,7 @@ class FinancialSummarySetController extends \Think\Controller
"payed_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)),
"pay_status"=>1
);
D("Spend")->addSubsiteWhere($map);
$res = $this->SpendModel
->field("IFNULL(SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END),0) as cash_count,IFNULL(SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END),0) as balance_coin_count")
->where($map)
@ -225,6 +226,7 @@ class FinancialSummarySetController extends \Think\Controller
$map2 = array(
"pay_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth))
);
addSubsiteWhere($map2,"partner_type");
$test_pay_amount = $this->TestOrderModel->where($map2)->field("IFNULL(sum(pay_amount),0) pay_amount")->find()['pay_amount'];
$temparr['sum_money'] = number_format(($test_pay_amount*100 )/100, 2, '.', '');
@ -267,6 +269,7 @@ class FinancialSummarySetController extends \Think\Controller
"payed_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)),
"pay_status"=>1
);
D("Spend")->addSubsiteWhere($map,"s");
$res = $this->SpendModel
->alias('s')
->field("IFNULL(SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END),0) as cash_count,
@ -368,6 +371,7 @@ class FinancialSummarySetController extends \Think\Controller
"s.pay_status"=>1,
"s.merchant_id"=>["GT","0"]
);
D("Spend")->addSubsiteWhere($map,"s");
$spres=$this->SpendModel
->alias("s")
->field("SUM(s.pay_amount) pay_amount,p.channel")
@ -394,6 +398,7 @@ class FinancialSummarySetController extends \Think\Controller
"s.payed_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)),
"s.pay_status"=>1
];
D("Deposit")->addSubsiteWhere($dp_map,"s");
$dpres=$this->DepositModel
->alias("s")
->field("SUM(s.pay_amount) pay_amount,p.channel")
@ -420,6 +425,7 @@ class FinancialSummarySetController extends \Think\Controller
"s.pay_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)),
"s.merchant_id"=>["GT","0"]
];
addSubsiteWhere($to_map,"partner_type");
$tores=$this->TestOrderModel
->alias("s")
->field("SUM(s.pay_amount) pay_amount,p.channel")
@ -453,6 +459,7 @@ class FinancialSummarySetController extends \Think\Controller
"s.pay_status"=>1,
"s.merchant_id"=>["GT","0"]
);
D("Spend")->addSubsiteWhere($map,"s");
$spres=$this->SpendModel
->alias("s")
->field("SUM(s.pay_amount) pay_amount,s.merchant_way")
@ -477,6 +484,7 @@ class FinancialSummarySetController extends \Think\Controller
"s.payed_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)),
"s.pay_status"=>1
];
D("Deposit")->addSubsiteWhere($dp_map,"s");
$dpres=$this->DepositModel
->alias("s")
->field("SUM(s.pay_amount) pay_amount,s.merchant_way")
@ -501,6 +509,7 @@ class FinancialSummarySetController extends \Think\Controller
"s.pay_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)),
"s.merchant_id"=>["GT","0"]
];
addSubsiteWhere($to_map,"partner_type");
$tores=$this->TestOrderModel
->alias("s")
->field("SUM(s.pay_amount) pay_amount,s.merchant_way")
@ -535,7 +544,7 @@ class FinancialSummarySetController extends \Think\Controller
$map = [];
$map['payed_time'] = ['BETWEEN',[$this->beginThismonth, $this->endThismonth]];
addSubsiteWhere($map,"partner_type");
//游戏充值金额
$data = M("spend use index(pay_channel)","tab_")
->field("SUM(CASE WHEN merchant.id is not null and tab_test_white_list.user_id is null THEN pay_amount ELSE 0 END) as cash_amount,
@ -574,6 +583,9 @@ class FinancialSummarySetController extends \Think\Controller
->select(false);
$map['pay_time'] = $map['payed_time'];
unset($map['payed_time']);
if(isset($map['partner_type'])){
unset($map['partner_type']);
}
//推广后台
$spreadData = M("coin_pay_order","tab_")
->field("0 cash_amount,0 test_amount,0 coin_amount,0 offcial_amount,
@ -600,6 +612,7 @@ class FinancialSummarySetController extends \Think\Controller
->select(false);
//测试环境内网平台订单
addSubsiteWhere($map,"partner_type");
$testOrder = M('test_order', 'tab_')
->where(['tab_test_order.pay_way'=>['egt',1]])
->field('0 cash_amount,0 test_amount,0 coin_amount,0 offcial_amount,0 spread_amount,0 supersign_amount,

@ -530,9 +530,13 @@ class OldCountController extends \Think\Controller
*/
public function FinancialSummaryInit()
{
//清空数据库
$sql = "truncate table tab_financial_summary";
$res = M()->execute($sql);
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();

@ -62,7 +62,7 @@ class DepositModel extends Model {
$field = "partner_type";
!empty($alias) && $field = $alias.".".$field;
if(IS_SUBSITE){
$map[$field] = PARTNER_TYPE;
$map[$field] = ["in",[0,PARTNER_TYPE]];
}
}

@ -77,7 +77,7 @@ class SpendModel extends Model
$field = "partner_type";
!empty($alias) && $field = $alias.".".$field;
if(IS_SUBSITE){
$map[$field] = PARTNER_TYPE;
$map[$field] = ["in",[0,PARTNER_TYPE]];
}
}

Loading…
Cancel
Save