财务比较2

master
chenzhi 5 years ago
parent ea69ecb086
commit def286ec80

@ -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...
}
}

@ -54,9 +54,12 @@
</td>
</tr>
<tr>
<td class="l"><i class="mustmark" style="margin-left:-7px">*</i>文件上传:</td>
<td class="r table_radio">
<input type="file" id="fileinput" name="file">
<td class="l"><i class="mustmark" style="margin-left:-7px">*</i>Excel文件上传:</td>
<td class="r">
<div class="input-list" style="margin-left: 0;">
<input type="file" id="fileinput" name="file">
</div>
<span class="notice-text" style="margin-left: 0;">暂只支持.xls .xlsx 格式文件</span>
</td>
</tr>
@ -128,7 +131,9 @@ $(function(){
type: 'binary'
});
}
console.log(wb.Sheets[wb.SheetNames[0]])
console.log(wb.Sheets[wb.SheetNames[0]])
console.log(wb.Sheets[wb.SheetNames[0]]["A1"]["v"])
console.log(wb.Sheets[wb.SheetNames[0]]["B1"]["v"])
console.log(XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]) )
// document.getElementById("demo").innerHTML= JSON.stringify( XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]) );
};

@ -1529,4 +1529,39 @@ CREATE TABLE `tab_pay_intention_num` (
`num` int(11) NULL DEFAULT 0 COMMENT '支付意愿支付次数',
`pay_order_number` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '支付单号',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = INNODB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Dynamic;
) ENGINE = INNODB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Dynamic;
-- chenzhi 20200325
CREATE TABLE `tab_finance_compare` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`begin_time` int(11) NULL DEFAULT 0 COMMENT '验证开始时间',
`end_time` int(11) NULL DEFAULT 0 COMMENT '验证结束时间',
`pay_way` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '1:支付宝 2微信 3易宝',
`diff_count` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '异常数量',
`diff_money` decimal(10,2) unsigned NOT NULL DEFAULT '0' COMMENT '异常金额',
`check_count` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '对比数量',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`check_status` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '是否验证结束',
PRIMARY KEY (`id`),
KEY `pay_way` (`pay_way`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='财务导入对账表';
-- chenzhi 20200325
CREATE TABLE `tab_finance_compare_info` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`pay_order_number` varchar(255) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '订单号',
`pay_way` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '1:支付宝 2微信 3易宝',
`pt_pay_amount` decimal(10,2) unsigned NOT NULL DEFAULT '0' COMMENT '平台金额',
`sj_pay_amount` decimal(10,2) unsigned NOT NULL DEFAULT '0' COMMENT '商家金额',
`diff_money` decimal(10,2) unsigned NOT NULL DEFAULT '0' COMMENT '异常金额',
`type` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '0:正常;1:金额不符;2:商家数据缺失;3:平台数据缺失;4:状态不符;5:渠道不符',
`compare_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '父表id',
`is_read` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否已处理',
PRIMARY KEY (`id`),
KEY `is_read` (`is_read`) USING BTREE,
KEY `pay_order_number` (`pay_order_number`) USING BTREE,
KEY `compare_id` (`compare_id`) USING BTREE,
KEY `compare_type` (`compare_id`,`type`) USING BTREE,
KEY `pay_way` (`pay_way`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='财务导入对账详情表';

Loading…
Cancel
Save