Commit 8ac3493b by guanzhenshan

解决导入英文格式因日期格式不统一出错的问题

parent d794e578
...@@ -4574,8 +4574,9 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -4574,8 +4574,9 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
/// <summary> /// <summary>
/// 导入Ebay收入明细 /// 导入Ebay收入明细
/// </summary> /// </summary>
/// <param name="formattype">1:中文账户,2:英文国外账户,3:英文国内账户 </param>
/// <returns></returns> /// <returns></returns>
public JsonResult UploadEbayIncome(int companyid,int isChs) public JsonResult UploadEbayIncome(int companyid,int formattype)
{ {
var result = ""; var result = "";
if (Request.Form.Files.Count == 0) if (Request.Form.Files.Count == 0)
...@@ -4603,6 +4604,8 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -4603,6 +4604,8 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
}); });
} }
try
{
var read = new System.IO.StreamReader(file.OpenReadStream()); var read = new System.IO.StreamReader(file.OpenReadStream());
var list = new List<dc_base_income_ebay_paypal>(); var list = new List<dc_base_income_ebay_paypal>();
...@@ -4620,7 +4623,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -4620,7 +4623,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
s = tempArr[0]; s = tempArr[0];
for (var i = 1; i < tempArr.Length - 1; i++) for (var i = 1; i < tempArr.Length - 1; i++)
{ {
if ((tempArr[i - 1]==""|| tempArr[i - 1].Substring(tempArr[i - 1].Length - 1, 1) == ",") && (tempArr[i + 1] == "" || tempArr[i + 1].Substring(0, 1) == ",") && tempArr[i].Length>1) if ((tempArr[i - 1] == "" || tempArr[i - 1].Substring(tempArr[i - 1].Length - 1, 1) == ",") && (tempArr[i + 1] == "" || tempArr[i + 1].Substring(0, 1) == ",") && tempArr[i].Length > 1)
{ {
tempArr[i] = tempArr[i].Replace(",", "||"); tempArr[i] = tempArr[i].Replace(",", "||");
} }
...@@ -4630,21 +4633,38 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -4630,21 +4633,38 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
} }
var arr = s.Split(','); var arr = s.Split(',');
if (arr.Length > 1) if (arr.Length > 1) //中文账户
{ {
var time = DateTime.Now; var time = DateTime.Now;
if (isChs == 1) if (formattype == 1)
{ {
time = DateTime.Parse(arr[0] + " " + arr[1]); time = DateTime.Parse(arr[0] + " " + arr[1]);
} }
else if (formattype == 2) //英文国外账户
{
var arrDate = arr[0].Split('/');
if (arrDate.Length == 3)
{
time = DateTime.Parse(arrDate[2] + "-" + arrDate[0] + "-" + arrDate[1] + " " + arr[1]);
}
else else
{ {
return Json(new
{
success = false,
msg = "第" + row_index + "行时间格式转换失败,请重试或联系管理员。",
});
}
}
else if (formattype == 3) //英文国内账户
{
var arrDate = arr[0].Split('/'); var arrDate = arr[0].Split('/');
if (arrDate.Length == 3) if (arrDate.Length == 3)
{ {
time = DateTime.Parse(arrDate[2]+"-"+arrDate[0]+"-"+arrDate[1]+" "+arr[1]); time = DateTime.Parse(arrDate[2] + "-" + arrDate[1] + "-" + arrDate[0] + " " + arr[1]);
} }
else else
{ {
...@@ -4681,9 +4701,9 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -4681,9 +4701,9 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
item_title = arr[15].Replace("||", ","), item_title = arr[15].Replace("||", ","),
item_id = arr[16], item_id = arr[16],
shipping_handling_amount = decimal.Parse(arr[17] ==""?"0":arr[17].Replace("||", ",")), shipping_handling_amount = decimal.Parse(arr[17] == "" ? "0" : arr[17].Replace("||", ",")),
insurance_amount = decimal.Parse(arr[18]==""?"0":arr[18].Replace("||", ",")), insurance_amount = decimal.Parse(arr[18] == "" ? "0" : arr[18].Replace("||", ",")),
sales_tax = decimal.Parse(arr[19]==""?"0":arr[19].Replace("||", ",")), sales_tax = decimal.Parse(arr[19] == "" ? "0" : arr[19].Replace("||", ",")),
option_name1 = arr[20].Replace("||", ","), option_name1 = arr[20].Replace("||", ","),
option_value1 = arr[21].Replace("||", ","), option_value1 = arr[21].Replace("||", ","),
option_name2 = arr[22].Replace("||", ","), option_name2 = arr[22].Replace("||", ","),
...@@ -4692,9 +4712,9 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -4692,9 +4712,9 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
invoice_number = arr[25], invoice_number = arr[25],
custom_number = arr[26], custom_number = arr[26],
quantity = int.Parse(arr[27]==""?"0": arr[27]), quantity = int.Parse(arr[27] == "" ? "0" : arr[27]),
receipt_id = arr[28], receipt_id = arr[28],
balance = decimal.Parse(arr[29]==""?"0":arr[29].Replace("||", ",")), balance = decimal.Parse(arr[29] == "" ? "0" : arr[29].Replace("||", ",")),
address_line1 = arr[30].Replace("||", ","), address_line1 = arr[30].Replace("||", ","),
address_line2 = arr[31].Replace("||", ","), address_line2 = arr[31].Replace("||", ","),
...@@ -4719,7 +4739,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -4719,7 +4739,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
return Json(new return Json(new
{ {
success = false, success = false,
msg = "第"+ row_index+"行出现异常,异常信息:"+ex.Message, msg = "第" + row_index + "行出现异常,异常信息:" + ex.Message,
}); });
} }
} }
...@@ -4735,46 +4755,22 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -4735,46 +4755,22 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
result = new Services.FinanceReportServices().SaveEbayPayPalInfo(list); result = new Services.FinanceReportServices().SaveEbayPayPalInfo(list);
} }
//Dictionary<string, DataTable> dic = Base.NpolHelper.ExcelToDataTable(file.OpenReadStream(), file.FileName, true); return Json(new
//if (dic.Count > 0) {
//{
// var tb = dic.FirstOrDefault();
// var service = new Services.FinanceReportServices();
// var listRate = new List<Tuple<string, decimal>>();
// for (var i = 0; i < tb.Value.Rows.Count; i++)
// {
// var row = tb.Value.Rows[i];
// try
// {
// if (isChs == 1)
// {
// list.Add(FormatTableRowForChs(objAccount, row,companyid));
// }
// else
// {
// list.Add(FormatTableRowForEnglish(objAccount, row,companyid));
// }
// }
// catch (Exception ex)
// {
// return Json(new {
// success = false,
// msg = "第" + (i + 1) + "行出现异常,异常信息:" + ex.Message
// });
// }
// }
//}
return Json(new {
success = string.IsNullOrEmpty(result), success = string.IsNullOrEmpty(result),
msg = result msg = result
}); });
} }
catch (Exception ex)
{
return Json(new
{
success = false,
msg = "解析出现异常,异常信息:" + ex.Message,
});
}
}
#region Private #region Private
......
...@@ -29,7 +29,8 @@ ...@@ -29,7 +29,8 @@
<label>&nbsp;</label> <label>&nbsp;</label>
<button type="button" class="btn btn-primary" onclick="list();"><i class="fa fa-search"></i>&nbsp;查询</button> <button type="button" class="btn btn-primary" onclick="list();"><i class="fa fa-search"></i>&nbsp;查询</button>
<button id="btnUpload_chs" type="button" class="btn btn-success">导入paypal中文数据</button> <button id="btnUpload_chs" type="button" class="btn btn-success">导入paypal中文数据</button>
<button id="btnUpload_en" type="button" class="btn btn-success">导入paypal英文数据</button> <button id="btnUpload_en_inside" type="button" class="btn btn-success">导入paypal英文【国内】账户</button>
<button id="btnUpload_en_outside" type="button" class="btn btn-success">导入paypal英文【国外】帐号</button>
</div> </div>
</div> </div>
</form> </form>
...@@ -89,22 +90,25 @@ ...@@ -89,22 +90,25 @@
function list() { function list() {
var columns = [ var columns = [
{ field: 'record_time', title: '报告日期', width: '150', sortable: true }, { field: 'record_time', title: '报告日期', width: '160', sortable: true },
{ field: 'account_name', title: '帐号', width: '180' }, { field: 'account_name', title: '帐号', width: '180' },
{ field: 'time_zone', title: '时区', width: '70'}, { field: 'time_zone', title: '时区', width: '70'},
{ field: 'type', title: '类型', width: '170'}, {
field: 'type', title: '类型', width: '190', formatter: function (idx, data) {
return '<div class="mules" title="' + data.type + '">' + data.type + '</div>';
}},
{ field: 'status', title: '状态', width: '120', iscount: true}, { field: 'status', title: '状态', width: '120', iscount: true},
{ field: 'currency', title: '币种', width: '70'}, { field: 'currency', title: '币种', width: '70'},
{ field: 'gross', title: '总额', width: '100', sortable: true, iscount: true }, { field: 'gross', title: '总额', width: '100', sortable: true, iscount: true },
{ field: 'fee', title: '费用', width: '90', sortable: true, iscount: true }, { field: 'fee', title: '费用', width: '90', sortable: true, iscount: true },
{ field: 'net', title: '净额', width: '90', sortable: true, iscount: true }, { field: 'net', title: '净额', width: '90', sortable: true, iscount: true },
{ {
field: 'from_email', title: '发件人邮箱地址', width: '180', formatter: function (idx, data) { field: 'from_email', title: '发件人邮箱地址', width: '190', formatter: function (idx, data) {
return '<div class="mules" title="' + data.from_email + '">' + data.from_email + '</div>'; return '<div class="mules" title="' + data.from_email + '">' + data.from_email + '</div>';
} }
}, },
{ {
field: 'to_email', title: '收件人邮箱地址', width: '160', formatter: function (idx, data) { field: 'to_email', title: '收件人邮箱地址', width: '190', formatter: function (idx, data) {
return '<div class="mules" title="' + data.to_email + '">' + data.to_email + '</div>'; return '<div class="mules" title="' + data.to_email + '">' + data.to_email + '</div>';
} }
}, },
...@@ -148,7 +152,7 @@ ...@@ -148,7 +152,7 @@
companyid = d.companyid; companyid = d.companyid;
uploadfile('btnUpload_chs', uploadfile('btnUpload_chs',
'@Url.Content("~/Reports/Finance/UploadEbayIncome")' + '?companyid=' + companyid +'&isChs=1', '@Url.Content("~/Reports/Finance/UploadEbayIncome")' + '?companyid=' + companyid +'&formattype=1',
function(result){ function(result){
if(result.success) if(result.success)
{ {
...@@ -160,8 +164,20 @@ ...@@ -160,8 +164,20 @@
} }
}); });
uploadfile('btnUpload_en', uploadfile('btnUpload_en_inside',
'@Url.Content("~/Reports/Finance/UploadEbayIncome")' + '?companyid=' + companyid +'&isChs=0', '@Url.Content("~/Reports/Finance/UploadEbayIncome")' + '?companyid=' + companyid +'&formattype=3',
function(result){
if(result.success)
{
alert('上传成功!');
}
else
{
alert(result.msg);
}
});
uploadfile('btnUpload_en_outside',
'@Url.Content("~/Reports/Finance/UploadEbayIncome")' + '?companyid=' + companyid +'&formattype=2',
function(result){ function(result){
if(result.success) if(result.success)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment