新增导入

master
chenzhi 5 years ago
parent 399c3b37cf
commit 24f2b76bd6

@ -141,6 +141,36 @@ class ExcelPaymentController extends BaseController
{
$this->display();
}
//
public function loopAdd()
{
$p = $_REQUEST;
$statement_begin_time = strtotime($p['statement_begin_time']);
$statement_end_time = strtotime($p['statement_end_time'])+86399;
$batch = $p['batch'];
$checkarr = $p['checkarr'];
//循环获取添加
if(count($checkarr) < 1){
$this->ajaxReturn(["status"=>1,"msg"=>"ok"]);
}
$ExcelStatementInfo = M('ExcelStatementInfo',"tab_");
foreach ($checkarr as $k => &$v) {
$v['statement_begin_time'] = $statement_begin_time;
$v['statement_end_time'] = $statement_end_time;
$v['batch_num'] = $batch;
$v['statement_info'] = json_encode($v['statement_info'],JSON_UNESCAPED_UNICODE);
$v['company_info'] = json_encode($v['company_info'],JSON_UNESCAPED_UNICODE);
$v['company_type'] = 2;
$v['create_time'] = time();
$v['statement_num'] = "JS_".date('Ymd').date('His').$v['company_id'].sp_random_string(5);
$res = $ExcelStatementInfo->add($v);
if($res === false){
M('ExcelStatementInfo')->where("statement_num = '{$v['statement_num']}'")->delete();
$this->ajaxReturn(["status"=>0,"msg"=>"添加失败"]);
}
}
$this->ajaxReturn(["status"=>1,"msg"=>"ok"]);
}
//查看
public function viewPool()
{

@ -29,7 +29,31 @@
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="l"><i class="mustmark" style="margin-left:-7px">*</i>Excel文件上传:</td>
<td class="l">本次批次号:</td>
<td class="r">
<div class="input-list" id="batch" style="margin-left: 0;line-height: 30px;font-size: 16px;">
</div>
<span class="notice-text" style="margin-left: 20px;">用于检索使用</span>
</td>
</tr>
<tr>
<td class="l"><i class="mustmark" style="margin-left:-7px">*</i>结算时间:</td>
<td class="r">
<div class="input-list" style="margin-left: 0;">
<input type="text" readonly id="time_start" name="time_start" class=""
value="{:I('time_start')}" placeholder="开始时间" />
&nbsp;-&nbsp;
<div class="input-append date" id="datetimepicker" style="display:inline-block">
<input type="text" readonly id="time_end" name="time_end" class=""
value="{:I('time_end')}" placeholder="结束时间" />
<span class="add-on"><i class="icon-th"></i></span>
</div>
</div>
<span class="notice-text" style="margin-left: 0;">用于检索及唯一值检验</span>
</td>
</tr>
<tr>
<td class="l"><i class="mustmark" style="margin-left:-7px">*</i>文件上传:</td>
<td class="r">
<div class="input-list" style="margin-left: 0;">
<input type="file" id="fileinput" name="file">
@ -37,6 +61,7 @@
<span class="notice-text" style="margin-left: 0;">暂只支持.xls .xlsx 格式文件</span>
</td>
</tr>
</tbody>
</table>
</div>
@ -52,12 +77,12 @@
</div>
<div style="margin-top: 60px;">
<div style="margin-top: 60px;" id="firle">
<div style="width: 100%;height: 45px;font-size: 16px;">
文件格式参考:<span style="color: #777;font-size: 12px;margin-left: 20px;">请严格按此格式,文件的第一行必须是字段名,且字段名不允许修改</span>
</div>
<style>
td,th{
#firle td,#firle th{
padding: 10px 5px;
}
</style>
@ -144,11 +169,11 @@
url: url,
data:senddata,
success: function(data) {
if(data.success){
callback(data.data);
if(data.status == 1){
callback();
}else{
MSG.hidemsg();
layer.alert(data.error);
layer.alert(data.msg);
return false;
}
@ -160,102 +185,69 @@
}
});
},
//创建面单
creatCompare:function(senddata,callback){
COMPARE.publiucAjax("{:U('creatCompare')}",senddata,function(data){
sendDefaultData.compare_id = data.id;
MSG.showmsg("初始化完成,开始比较数据 [0/"+sendDefaultData.filedata_count+"] ......");
callback();
});
},
//循环比较
loopCheck:function(page,callback){
if(page > sendDefaultData.check_page){
MSG.showmsg("生成平台 游戏流水比对订单,此过程需要较长时间,请耐心等待......");
MSG.showmsg("添加成功,执行跳转中");
callback();
return;
}
var senddata = {
keys:sendDefaultData.keys,
compare_id:sendDefaultData.compare_id,
pay_way:sendDefaultData.pay_way,
statement_begin_time:sendDefaultData.begin_time,
statement_end_time:sendDefaultData.end_time,
batch:sendDefaultData.batch,
checkarr:sendDefaultData.filedata.splice(0,check_size)
}
COMPARE.publiucAjax("{:U('compareData')}",senddata,function(data){
COMPARE.publiucAjax("{:U('loopAdd')}",senddata,function(data){
var checkok = page*check_size > sendDefaultData.filedata_count ? sendDefaultData.filedata_count : page*check_size;
MSG.showmsg("比较数据 ["+checkok+"/"+sendDefaultData.filedata_count+"] ......");
MSG.showmsg("数据插入 ["+checkok+"/"+sendDefaultData.filedata_count+"] ......");
page++;
COMPARE.loopCheck(page,callback)
});
},
//生成游戏订单平台缺失订单
checkSpendData:function(callback){
var senddata = {
compare_id:sendDefaultData.compare_id,
pay_way:sendDefaultData.pay_way,
begin_time:sendDefaultData.begin_time,
end_time:sendDefaultData.end_time,
}
COMPARE.publiucAjax("{:U('checkSpendData')}",senddata,function(data){
MSG.showmsg("生成平台 平台币比对订单......");
console.log(data)
callback();
});
},
//生成游戏订单平台缺失订单
checkDepositData:function(callback){
var senddata = {
compare_id:sendDefaultData.compare_id,
pay_way:sendDefaultData.pay_way,
begin_time:sendDefaultData.begin_time,
end_time:sendDefaultData.end_time,
}
COMPARE.publiucAjax("{:U('checkDepositData')}",senddata,function(data){
MSG.showmsg("生成最后比较统计......");
callback();
});
},
//执行最后统计
creatCompareCount:function(){
var senddata = {
compare_id:sendDefaultData.compare_id,
};
COMPARE.publiucAjax("{:U('creatCompareCount')}",senddata,function(data){
MSG.showmsg("导入比较成功,执行跳转中......");
setTimeout(function(){
window.location.href = "{:U('index')}";
},2000)
});
}
}
</script>
<script type="text/javascript">
var isfile = false;
var rABS = false; //是否将文件读取为二进制字符串
var check_size = "{$page_size}";//每次验证的数量
var check_size = 10;//每次验证的数量
var batch = getNowDate();
var sendDefaultData = {
"keys": [],
"filedata_count": 0,
"compare_id": 0,
"check_page":0,
"filedata":[],
"pay_way":-1,
"begin_time":0,
"end_time":0
"end_time":0,
"batch":batch
}
$("#batch").html(batch);
$(function () {
$("#submit_btn").on("click", function () {
var start = $("#time_start").val();
var end = $("#time_end").val();
var sdate = Date.parse(start) / 1000;
var edate = Date.parse(end) / 1000;
if (start == '' || end == '') {
layer.msg('开始时间与结束时间都不允许为空');
return false;
}
if (sdate > edate) {
layer.msg('开始时间必须小于等于结束时间');
return false;
}
//获取文件
if (!isfile) {
layer.msg('excel文件不能为空');
return false;
}
sendDefaultData.begin_time = start;
sendDefaultData.end_time = end;
//执行
readFileInput(function () {
if(sendDefaultData.filedata_count == 0){
@ -265,24 +257,11 @@
}
//获取需要循环的次数
sendDefaultData.check_page = Math.ceil(sendDefaultData.filedata_count/check_size);
sendDefaultData.pay_way = paychannel;
sendDefaultData.begin_time = start;
sendDefaultData.end_time = end;
//创建面单
var senddata = {
begin_time:start,
end_time:end,
pay_way:paychannel,
check_count:sendDefaultData.filedata_count
}
COMPARE.creatCompare(senddata,function(){
COMPARE.loopCheck(1,function(){
COMPARE.checkSpendData(function(){
COMPARE.checkDepositData(function(){
COMPARE.creatCompareCount();
})
})
})
COMPARE.loopCheck(1,function(){
})
})
@ -329,10 +308,9 @@
}
// console.log(wb);
try {
sendDefaultData.filedata = resetCount(XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]));
var filedata = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]);
sendDefaultData.filedata = resetCount(filedata);
sendDefaultData.filedata_count = sendDefaultData.filedata.length;
console.log(sendDefaultData);
return false;
callback();
} catch (error) {
MSG.hidemsg();
@ -367,12 +345,18 @@
"开户支行": "opening_bank",
"账户类型": "bank_type",
"支付宝真实姓名": "ali_user",
"支付宝账号": "ali_account"
"支付宝账号": "ali_account",
"备注": "remark",
}
var data = [];
//临时公司
var temp ={
statement_info:[]
statement_money:0,
platform_amount:0,
fine:0,
reward:0,
statement_info:[],
company_info:{}
};
var game_name = '';
var game_type= '';
@ -381,8 +365,19 @@
//全量公司
if (e.hasOwnProperty("序号")) {
if(index != 0){
temp.statement_money = temp.statement_money/100;
temp.platform_amount = temp.platform_amount/100;
temp.fine = temp.fine/100;
temp.reward = temp.reward/100;
data.push(temp);//上次的走掉
temp ={statement_info:[]};//重置
temp ={
statement_money:0,
platform_amount:0,
fine:0,
reward:0,
statement_info:[],
company_info:{}
};//重置
}
var acc = {
game_list:[]
@ -394,7 +389,17 @@
}else if(k=="产品" || k=="产品类型" || k == "结算时间" || k == "推广流水" || k == "分成比例" || k == "补点" || k == "奖励" || k == "罚款" || k == "结算金额"){
if(k=="产品") game_name = e[k];
if(k=="产品类型") game_type = e[k];
if(k=="奖励") temp.reward += Math.round(e[k]*100);
if(k=="罚款") temp.fine += Math.round(e[k]*100);
if(k=="推广流水") temp.platform_amount +=Math.round(e[k]*100);
if(k=="结算金额") temp.statement_money += Math.round(e[k]*100);
if(k == "推广流水" || k == "奖励" || k == "罚款" || k == "结算金额"){
e[k] = Math.round(e[k]*100)/100;
}
gamet[titleKey[k]] = e[k];
}else if(k=="市场员" || k=="下游性质" || k == "账户名" || k == "银行卡号" || k == "开户支行" || k == "账户类型" || k == "支付宝真实姓名" || k == "支付宝账号"){
temp.company_info[titleKey[k]] = e[k];
}else{
temp[titleKey[k]] = e[k];
}
@ -423,7 +428,16 @@
}else if(k=="产品" || k=="产品类型" || k == "结算时间" || k == "推广流水" || k == "分成比例" || k == "补点" || k == "奖励" || k == "罚款" || k == "结算金额"){
if(k=="产品") game_name = e[k];
if(k=="产品类型") game_type = e[k];
if(k=="奖励") temp.reward += Math.round(e[k]*100);
if(k=="罚款") temp.fine += Math.round(e[k]*100);
if(k=="推广流水") temp.platform_amount += Math.round(e[k]*100);
if(k=="结算金额") temp.statement_money += Math.round(e[k]*100);
if(k == "推广流水" || k == "奖励" || k == "罚款" || k == "结算金额"){
e[k] = Math.round(e[k]*100)/100;
}
gamet[titleKey[k]] = e[k];
}else if(k=="市场员" || k=="下游性质" || k == "账户名" || k == "银行卡号" || k == "开户支行" || k == "账户类型" || k == "支付宝真实姓名" || k == "支付宝账号"){
temp.company_info[titleKey[k]] = e[k];
}else{
temp[titleKey[k]] = e[k];
}
@ -447,7 +461,16 @@
}else if(k=="产品" || k=="产品类型" || k == "结算时间" || k == "推广流水" || k == "分成比例" || k == "补点" || k == "奖励" || k == "罚款" || k == "结算金额"){
if(k=="产品") game_name = e[k];
if(k=="产品类型") game_type = e[k];
if(k=="奖励") temp.reward += Math.round(e[k]*100);
if(k=="罚款") temp.fine += Math.round(e[k]*100);
if(k=="推广流水") temp.platform_amount +=Math.round(e[k]*100);
if(k=="结算金额") temp.statement_money += Math.round(e[k]*100);
if(k == "推广流水" || k == "奖励" || k == "罚款" || k == "结算金额"){
e[k] = Math.round(e[k]*100)/100;
}
gamet[titleKey[k]] = e[k];
}else if(k=="市场员" || k=="下游性质" || k == "账户名" || k == "银行卡号" || k == "开户支行" || k == "账户类型" || k == "支付宝真实姓名" || k == "支付宝账号"){
temp.company_info[titleKey[k]] = e[k];
}else{
temp[titleKey[k]] = e[k];
}
@ -462,10 +485,25 @@
temp.statement_info[temp.statement_info.length-1].game_list.push(gamet);
}
//判断
temp.statement_money = temp.statement_money/100;
temp.platform_amount = temp.platform_amount/100;
temp.fine = temp.fine/100;
temp.reward = temp.reward/100;
data.push(temp);//最后一次
return data;
}
function getNowDate(){
var da = new Date();
var trade =da.getFullYear();
var mt =da.getMonth() + 1 >10 ? da.getMonth() + 1 : "0"+(da.getMonth() + 1);
var dt =da.getDate() >=10 ? da.getDate() : "0"+da.getDate();
var dh =da.getHours() >=10 ? da.getHours() : "0"+da.getHours();
var dm =da.getMinutes() >=10 ? da.getMinutes() : "0"+da.getMinutes();
var ds =da.getSeconds() >=10 ? da.getSeconds() : "0"+da.getSeconds();
var dms =(Array(3).join(0) + da.getMilliseconds()).slice(-3);
return trade+=""+mt+""+dt+""+dh+""+dm+""+ds+''+dms;
}
function fixdata(data) { //文件流转BinaryString
var o = "",

@ -2085,7 +2085,6 @@ CREATE TABLE `tab_excel_statement_info` (
`company_name` varchar(60) NOT NULL DEFAULT '' COMMENT '对账公司名称',
`company_info` text NOT NULL COMMENT '公司其他信息json',
`statement_money` decimal(10,2) DEFAULT '0.00' COMMENT '对账金额',
`pay_amount` decimal(10,2) DEFAULT '0.00' COMMENT '总计',
`platform_amount` decimal(10,2) DEFAULT '0.00' COMMENT '平台流水金额',
`fine` decimal(10,2) DEFAULT '0.00' COMMENT '罚款',
`reward` decimal(10,2) DEFAULT '0.00' COMMENT '奖励',

Loading…
Cancel
Save