diff --git a/Application/Admin/Controller/FinanceCompareController.class.php b/Application/Admin/Controller/FinanceCompareController.class.php index 28d89af17..578b2707b 100644 --- a/Application/Admin/Controller/FinanceCompareController.class.php +++ b/Application/Admin/Controller/FinanceCompareController.class.php @@ -2,14 +2,110 @@ namespace Admin\Controller; class FinanceCompareController extends ThinkController { + public $zfb = [1];//官方支付宝渠道id + public $wx = [2,3];//微信渠道id + public $ybzf = [17];//易宝渠道id + public function add() { $this->display(); # code... } + public function creatCompare() + { + + # code... + } public function compareData() { - $data = I('POST.'); + // $data = I('POST.'); + $keys = ["支付订单号","实付金额"]; + $compare_id = 1; + $pay_way = 1;//1支付宝 2微信 17易宝 + $data = [ + ["支付订单号"=> "SP_202003231152197Lhd_test","实付金额"=>0.01], + ["支付订单号"=> "SP_20200325103203fBPI_test","实付金额"=>0.01], + ["支付订单号"=> "SP_20200325102118dbIy_test","实付金额"=>0.01], + ["支付订单号"=> "SP_20200325102110Dpga_test","实付金额"=>0.01], + ["支付订单号"=> "PF_20200225170537PpOt","实付金额"=>1] + ]; //过滤数据 + $sp=[]; + $pf=[]; + $er=[]; + foreach($data as $k=>$v){ + $pay_where = substr($v[$keys[0]], 0, 2); + $tmp = [ + "pt_pay_amount"=>$v[$keys[1]], + "diff_money"=>$v[$keys[1]], + "sj_pay_amount"=>0, + "type"=>3, + "pay_order_number"=>$v[$keys[0]], + "compare_id"=>$compare_id, + "pay_way"=>$pay_way, + "is_read"=>0 + ]; + if($pay_where == 'SP'){ + $sp[$v[$keys[0]]] = $tmp; + }elseif($pay_where == 'PF'){ + $pf[$v[$keys[0]]] = $tmp; + }else{ + $er[$v[$keys[0]]] = $tmp; + } + } + //判断游戏流水 + if(count($sp) > 0){ + $keys = implode(",",array_keys($sp)); + $where = ["pay_order_number"=>["in",$keys]]; + $sres = M("Spend","tab_")->field("pay_order_number,pay_amount,pay_status,pay_way")->where($where)->select(); + if($sres){ + $this->setDiffData($sres,$sp); + } + } + + dump($sres); + } + protected function setDiffData($dbres,$ydata) + { + //type 1:金额不符 2:商家数据缺失 3:平台数据缺失 4:状态不符;5:渠道不符 + foreach ($dbres as $k => $v) { + if(array_key_exists($v['pay_order_number'],$ydata)){ + //存在 + $flag = true; + $ydata[$v['pay_order_number']]['sj_pay_amount'] = $v['pay_amount']; + $ydata[$v['pay_order_number']]['diff_money'] = abs($ydata[$v['pay_order_number']]['pt_pay_amount']-$v['pay_amount']); + + + $way = $ydata[$v['pay_order_number']]['pay_way']; + if ($way == 1) { + $checkarr = $this->$zfb; + }elseif($way == 2){ + $checkarr = $this->$wx; + }elseif($way == 3){ + $checkarr = $this->$ybzf; + } + + if(!in_array($way,$checkarr)){//渠道不符 + $ydata[$v['pay_order_number']]['type'] = 5; + $flag = false; + } + + if($ydata[$v['pay_order_number']]['pt_pay_amount'] != $v['pay_amount']){//金额不符 + $ydata[$v['pay_order_number']]['type'] = 1; + $flag = false; + } + if($v['pay_status'] != 1){//状态不符合 + $ydata[$v['pay_order_number']]['type'] = 4; + $ydata[$v['pay_order_number']]['diff_money'] = $v['pay_amount']; + $flag = false; + } + + if($flag){ + $ydata[$v['pay_order_number']]['type'] = 0; + } + } + } + dd($ydata); + # code... } } \ No newline at end of file diff --git a/Application/Admin/View/FinanceCompare/add.html b/Application/Admin/View/FinanceCompare/add.html index 1db497ac4..0ef195f39 100644 --- a/Application/Admin/View/FinanceCompare/add.html +++ b/Application/Admin/View/FinanceCompare/add.html @@ -54,9 +54,12 @@