新增文件读取

master
chenzhi 4 years ago
parent 8d32b5104e
commit 399c3b37cf

@ -14,8 +14,8 @@
</style> </style>
<div class="cf main-place top_nav_list navtab_list"> <div class="cf main-place top_nav_list navtab_list">
<h3 class="page_title">新增校验</h3> <h3 class="page_title">新增excel导入</h3>
<p class="description_text">说明:导入商家数据与平台数据校验</p> <p class="description_text">说明:导入预付款数据</p>
</div> </div>
@ -23,39 +23,11 @@
<!-- 标签页导航 --> <!-- 标签页导航 -->
<div class="tab-wrap" style="display: flex;"> <div class="tab-wrap" style="display: flex;">
<div class="tab-content tabcon1711" style="min-width:900px;min-height: 60vh;border-right: 1px solid #333;"> <div class="tab-content tabcon1711" style="min-width:700px;">
<!-- 基础文档模型 --> <!-- 基础文档模型 -->
<div id="tab1" class="tab-pane in tab1"> <div id="tab1" class="tab-pane in tab1">
<table border="0" cellspacing="0" cellpadding="0"> <table border="0" cellspacing="0" cellpadding="0">
<tbody> <tbody>
<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;">请选择不超过31天的时间</span>
</td>
</tr>
<tr>
<td class="l"><i class="mustmark" style="margin-left:-7px">*</i>支付渠道:</td>
<td class="r">
<select name="pay_way" id="pay_way">
<option value="-1">请选择支付渠道</option>
<option value="1">支付宝</option>
<option value="2">微信</option>
<option value="3">易宝</option>
</select>
</td>
</tr>
<tr> <tr>
<td class="l"><i class="mustmark" style="margin-left:-7px">*</i>Excel文件上传:</td> <td class="l"><i class="mustmark" style="margin-left:-7px">*</i>Excel文件上传:</td>
<td class="r"> <td class="r">
@ -65,8 +37,6 @@
<span class="notice-text" style="margin-left: 0;">暂只支持.xls .xlsx 格式文件</span> <span class="notice-text" style="margin-left: 0;">暂只支持.xls .xlsx 格式文件</span>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
@ -79,36 +49,63 @@
</a> </a>
</div> </div>
</div> </div>
<div style="width: 400px;margin-left: 50px;">
</div>
<div style="margin-top: 60px;">
<div style="width: 100%;height: 45px;font-size: 16px;">
文件格式参考:<span style="color: #777;font-size: 12px;margin-left: 20px;">请严格按此格式,文件的第一行必须是字段名,且字段名不允许修改</span>
</div>
<style> <style>
#cktable td,#cktable th{ td,th{
padding: 5px; padding: 10px 5px;
min-width: 100px;
} }
</style> </style>
<div style="width: 100%;height: 45px;font-size: 20px;">
文件格式参考:
</div>
<table id="cktable" style="width: 100%;margin: 0;padding: 0;text-align: center;border: 1px solid #777;" border="1px"> <table id="cktable" style="width: 100%;margin: 0;padding: 0;text-align: center;border: 1px solid #777;" border="1px">
<thead> <thead>
<tr> <tr>
<th>订单号</th> <th>序号</th>
<th>金额</th> <th>下游名称</th>
<th>会长账号</th>
<th>下游类型</th>
<th>市场员</th>
<th>下游性质</th>
<th>产品</th>
<th>结算时间</th>
<th>推广流水</th>
<th>分成比例</th>
<th>补点</th>
<th>奖励</th>
<th>罚款</th>
<th>结算金额</th>
<th>支付宝真实姓名</th>
<th>支付宝账号</th>
<th>备注</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td>SP_202003251032543yjX</td> <td>1</td>
<td>0.01</td> <td>海南万盟天下科技</td>
</tr> <td>leilihua</td>
<tr> <td>外团开发</td>
<td>PF_20200325103203fBPI</td> <td>小明</td>
<td>0.01</td> <td>个人</td>
<td>秦汉风云</td>
<td>策略</td>
<td>2020.6.22-2020.6.28 5626</td>
<td>1%</td>
<td>0%</td>
<td>0</td>
<td>0</td>
<td>56.26</td>
<td>小花</td>
<td>12345678910</td>
<td>不重要的备注</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
</div>
<div style="width: 100vw;height: 100vh;padding: 0;position: absolute;top: 0;z-index: 9999;display: none;" id="creat_msg"> <div style="width: 100vw;height: 100vh;padding: 0;position: absolute;top: 0;z-index: 9999;display: none;" id="creat_msg">
<div class="layui-layer layui-layer-dialog layui-layer-border layui-layer-msg layui-layer-hui" <div class="layui-layer layui-layer-dialog layui-layer-border layui-layer-msg layui-layer-hui"
type="dialog" times="1" showtime="50000" contype="string" style="z-index: 19891015; top:30%; left:30%;"> type="dialog" times="1" showtime="50000" contype="string" style="z-index: 19891015; top:30%; left:30%;">
@ -249,32 +246,11 @@
"end_time":0 "end_time":0
} }
$(function () { $(function () {
$("#submit_btn").on("click", 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 ((edate - sdate) > 2592000) {
layer.msg('时间间隔不能超过31天请重新选择日期');
return false;
}
//获取渠道
var paychannel = $("#pay_way option:selected").val();
if (paychannel == -1) {
layer.msg('请选择支付渠道');
return false;
}
//获取文件 //获取文件
if (!isfile) { if (!isfile) {
layer.msg('excel文件不能为空'); layer.msg('excel文件不能为空');
@ -351,11 +327,12 @@
type: 'binary' type: 'binary'
}); });
} }
// console.log(wb);
try { try {
sendDefaultData.keys.push(wb.Sheets[wb.SheetNames[0]]["A1"]["v"]); sendDefaultData.filedata = resetCount(XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]));
sendDefaultData.keys.push(wb.Sheets[wb.SheetNames[0]]["B1"]["v"]);
sendDefaultData.filedata = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]);
sendDefaultData.filedata_count = sendDefaultData.filedata.length; sendDefaultData.filedata_count = sendDefaultData.filedata.length;
console.log(sendDefaultData);
return false;
callback(); callback();
} catch (error) { } catch (error) {
MSG.hidemsg(); MSG.hidemsg();
@ -368,6 +345,127 @@
}; };
} }
function resetCount(fdata){
var titleKey={
"序号": "sort",
"下游名称": "company_name",
"会长账号": "account",
"下游类型": "company_relation_str",
"市场员": "nickname",
"下游性质": "company_type_str",
"产品": "game_name",
"产品类型": "game_type_name",
"结算时间": "statement_time",
"推广流水": "pay_amount",
"分成比例": "ratio",
"补点": "increment_ratio",
"奖励": "reward",
"罚款": "fine",
"结算金额":"sum_money",
"账户名": "payee_name",
"银行卡号": "bank_account",
"开户支行": "opening_bank",
"账户类型": "bank_type",
"支付宝真实姓名": "ali_user",
"支付宝账号": "ali_account"
}
var data = [];
//临时公司
var temp ={
statement_info:[]
};
var game_name = '';
var game_type= '';
for (let index = 0; index < fdata.length; index++) {
const e = fdata[index];
//全量公司
if (e.hasOwnProperty("序号")) {
if(index != 0){
data.push(temp);//上次的走掉
temp ={statement_info:[]};//重置
}
var acc = {
game_list:[]
};
var gamet = {}
for (const k in e) {
if(k == "会长账号"){
acc[titleKey[k]] = e[k];
}else if(k=="产品" || k=="产品类型" || k == "结算时间" || k == "推广流水" || k == "分成比例" || k == "补点" || k == "奖励" || k == "罚款" || k == "结算金额"){
if(k=="产品") game_name = e[k];
if(k=="产品类型") game_type = e[k];
gamet[titleKey[k]] = e[k];
}else{
temp[titleKey[k]] = e[k];
}
}
if(!gamet.hasOwnProperty("game_name")){
gamet.game_name =game_name;
}
if(!gamet.hasOwnProperty("game_type_name")){
gamet.game_type_name =game_type;
}
acc.game_list.push(gamet);
temp.statement_info.push(acc);
continue;
}
//含会长信息
if (e.hasOwnProperty("会长账号")) {
var acc = {
game_list:[]
};
var gamet = {}
for (const k in e) {
if(k == "会长账号"){
acc[titleKey[k]] = e[k];
}else if(k=="产品" || k=="产品类型" || k == "结算时间" || k == "推广流水" || k == "分成比例" || k == "补点" || k == "奖励" || k == "罚款" || k == "结算金额"){
if(k=="产品") game_name = e[k];
if(k=="产品类型") game_type = e[k];
gamet[titleKey[k]] = e[k];
}else{
temp[titleKey[k]] = e[k];
}
}
if(!gamet.hasOwnProperty("game_name")){
gamet.game_name =game_name;
}
if(!gamet.hasOwnProperty("game_type_name")){
gamet.game_type_name =game_type;
}
acc.game_list.push(gamet);
temp.statement_info.push(acc);
continue;
}
//只含有游戏的信息
var gamet = {}
for (const k in e) {
if(k == "会长账号"){
acc[titleKey[k]] = e[k];
}else if(k=="产品" || k=="产品类型" || k == "结算时间" || k == "推广流水" || k == "分成比例" || k == "补点" || k == "奖励" || k == "罚款" || k == "结算金额"){
if(k=="产品") game_name = e[k];
if(k=="产品类型") game_type = e[k];
gamet[titleKey[k]] = e[k];
}else{
temp[titleKey[k]] = e[k];
}
}
if(!gamet.hasOwnProperty("game_name")){
gamet.game_name =game_name;
}
if(!gamet.hasOwnProperty("game_type_name")){
gamet.game_type_name =game_type;
}
temp.statement_info[temp.statement_info.length-1].game_list.push(gamet);
}
//判断
data.push(temp);//最后一次
return data;
}
function fixdata(data) { //文件流转BinaryString function fixdata(data) { //文件流转BinaryString
var o = "", var o = "",

Loading…
Cancel
Save