优化财务汇总统计

master
chenzhi 4 years ago
parent 0c11ddb004
commit b73e3fea84

@ -14,16 +14,6 @@ class FinancialSummaryController extends AdminController
"outer_count"=>"外团",
"outer_branch_count"=>"外团-分发",
"other_group_count"=>"无归属团",
// "inside_count"=>"内团",
// "outer_count"=>"外团",
"gfwx_count"=>"官方-微信",
"gfzfb_count"=>"官方-支付宝",
"sqzfb_count"=>"双乾-支付宝",
"sqkj_count"=>"双乾-快捷",
"wx_count"=>"微信",
"zfb_count"=>"支付宝",
"kj_count"=>"快捷",
"ybzf_count"=>"易宝支付",
);
public function _initialize()
{
@ -43,6 +33,9 @@ class FinancialSummaryController extends AdminController
//获取指定年份数据
public function getYearData()
{
$Channel = D("PaymentMerchant")->Channel;
$Ways = D("PaymentMerchant")->Ways;
$senddata = array(
"income"=>[
"count"=>['0.00','0.00','0.00','0.00','0.00','0.00','0.00','0.00','0.00','0.00','0.00','0.00','0.00']
@ -65,10 +58,16 @@ class FinancialSummaryController extends AdminController
//将商户插入到默认数组中
foreach ($merchant_data as $key => $value) {
$identifier = (string)$value['identifier'];
$this->keyname[$identifier] = $value['name'];
}
//其他信息插入默认
foreach ($Channel as $key => $value) {
$this->keyname["c".$key] = $value;
}
foreach ($Ways as $key => $value) {
$this->keyname["w".$key] = $value;
}
$data = [];
//初始化数据
@ -110,7 +109,6 @@ class FinancialSummaryController extends AdminController
$data[$v['key_name']]["money"][((int)$v['count_month']-1)] = $v['sum_money'];
# code...
}
foreach ($senddata as $k => $v) {
foreach ($v as $ke => $va) {
if($ke !='count'){
@ -127,7 +125,6 @@ class FinancialSummaryController extends AdminController
}
ksort($senddata[$k]['count']);
}
$this->assign('data', $senddata);
}
//获取历史年份

@ -53,7 +53,7 @@ class FinancialSummarySetController extends \Think\Controller
$this->month= $tarry[1];
$this->beginThismonth=mktime(0,0,0,$tarry[1],1,$tarry[0]);
$this->endThismonth=mktime(0,0,0,$tarry[1]-0+1,1,$tarry[0])-1;
$this->reCount();
$this->setFinancialSummary();
}
@ -344,22 +344,19 @@ class FinancialSummarySetController extends \Think\Controller
}
public function setChannelMoney(){
$Channel = D("PaymentMerchant")->Channel;
foreach( $Channel as $k=>&$v){
$v = 0;
}
$this->getChannelCount($Channel);
$Channel = $this->getChannelCount($Channel);
foreach( $Channel as $k=>$v){
$this->adddata[] = array(
"key_name"=>$k,
"type"=>4,
"sort"=>$k,
"sum_money"=>number_format($v/100, 2, '.', '')
"sum_money"=>number_format($v, 2, '.', '')
);
}
}
//获取Channel
protected function getChannelCount(&$Channel){
protected function getChannelCount(){
$map = array(
"s.payed_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)),
"s.pay_status"=>1,
@ -425,29 +422,26 @@ class FinancialSummarySetController extends \Think\Controller
->where($to_map)
->select();
$dbres = array_merge($spres,$ssres,$dpres,$cores,$tores);
$Channel = [];
foreach ($dbres as $k=>$v){
$Channel[$v['channel']] = $Channel[$v['channel']]-0;
$Channel[$v['channel']] += $v['pay_amount'];
$Channel["c".$v['channel']] += $v['pay_amount'];
}
return $Channel;
}
public function setPaywayMoney(){
$Ways = D("PaymentMerchant")->Ways;
foreach( $Ways as $k=>&$v){
$v = 0;
}
$this->getPaywayCount($Ways);
$Ways = $this->getPaywayCount();
foreach($Ways as $k=>$v){
$this->adddata[] = array(
"key_name"=>$k,
"type"=>5,
"sort"=>$k,
"sum_money"=>number_format($v/100, 2, '.', '')
"sum_money"=>number_format($v, 2, '.', '')
);
}
}
//获取Channel
protected function getPaywayCount(&$Ways){
protected function getPaywayCount(){
$map = array(
"s.payed_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)),
"s.pay_status"=>1,
@ -509,10 +503,11 @@ class FinancialSummarySetController extends \Think\Controller
->select();
$dbres = array_merge($spres,$ssres,$dpres,$cores,$tores);
$Ways = [];
foreach ($dbres as $k=>$v){
$Ways[$v['merchant_way']] = $Ways[$v['merchant_way']]-0;
$Ways[$v['merchant_way']] += $v['pay_amount'];
$Ways["w".$v['merchant_way']] += $v['pay_amount'];
}
return $Ways;
}
public function addDb()

Loading…
Cancel
Save