Commit d2fbe0b4 by guanzhenshan

调整平台余额导入

parent c2018ff8
...@@ -915,37 +915,98 @@ namespace Bailun.DC.Services ...@@ -915,37 +915,98 @@ namespace Bailun.DC.Services
{ {
foreach (var item in list) foreach (var item in list)
{ {
var m = cn.QueryFirstOrDefault<dc_platform_balance>($"select * from dc_platform_balance where platformcode='{item.platformcode}' and currency='{item.currency}' and delstatus=0 and `day` <'{item.day.ToString("yyyy-MM-dd")}' order by day desc limit 1"); var m = cn.QueryFirstOrDefault<dc_platform_balance>($"select * from dc_platform_balance where account='{item.account}' and platformcode='{item.platformcode}' and currency='{item.currency}' and delstatus=0 and `day` <'{item.day.ToString("yyyy-MM-dd")}' order by day desc limit 1");
if (item.platformcode.ToUpper() != "EBAY" && item.platformcode.ToUpper() != "ALIEXPRESS") //if (item.platformcode.ToUpper() != "EBAY" && item.platformcode.ToUpper() != "ALIEXPRESS")
//{
// if (m != null && m.userable_amount == item.userable_amount)
// {
// //item.amount = m.amount + item.amount_sales - item.withdraw_amount; //本期期末=上一期期末+本期销售额-本期提现额
// //item.amount_rmb = item.amount * item.exchangerate;
// item.before_balance = m.end_balance;
// item.end_balance = m.end_balance + item.amount_sales - item.withdraw_amount;
// }
// else if (m == null || (m != null && m.userable_amount != item.userable_amount))
// {
// //item.amount = item.userable_amount + item.amount_sales - item.withdraw_amount;
// //item.amount_rmb = item.amount * item.exchangerate;
// item.before_balance = item.userable_amount;
// item.end_balance = item.userable_amount + item.amount_sales - item.withdraw_amount;
// }
//}
//else
//{
// //item.amount = item.userable_amount;
// //item.amount_rmb = item.userable_amount * item.exchangerate;
// item.before_balance = item.userable_amount;
// item.end_balance = item.userable_amount;
//}
//if (item.amount < 0 || item.amount_sales<0 || item.before_balance<0||item.userable_amount<0||item.withdraw_amount<0)
//{
// return "金额必须大于0";
//}
if (m == null)
{ {
if (m != null && m.userable_amount == item.userable_amount) m = new dc_platform_balance
{ {
//item.amount = m.amount + item.amount_sales - item.withdraw_amount; //本期期末=上一期期末+本期销售额-本期提现额 day = item.day,
//item.amount_rmb = item.amount * item.exchangerate; account = item.account,
item.before_balance = m.end_balance; amount = item.amount,
item.end_balance = m.end_balance + item.amount_sales - item.withdraw_amount; amount_rmb = item.amount_rmb,
} amount_sales = 0,
else if (m == null || (m != null && m.userable_amount != item.userable_amount)) freeze_amount = item.freeze_amount,
{ freeze_amount_rmb = item.freeze_amount_rmb,
//item.amount = item.userable_amount + item.amount_sales - item.withdraw_amount;
//item.amount_rmb = item.amount * item.exchangerate; fromsource = "",
item.before_balance = item.userable_amount; before_balance = 0,
item.end_balance = item.userable_amount + item.amount_sales - item.withdraw_amount; createtime = DateTime.Now,
} createuserid = item.createuserid,
createusername = item.createusername,
currency = item.currency,
delstatus = 0,
end_balance = item.amount_rmb,
exchangerate = item.exchangerate,
notes = item.notes,
platformcode = item.platformcode,
platformname = item.platformname,
puttime = item.puttime,
paycompanyid = item.paycompanyid,
saleday = null,
userable_amount = item.userable_amount,
userable_amount_rmb = item.userable_amount_rmb,
withdraw_amount = 0,
};
} }
else else
{ {
//item.amount = item.userable_amount; m.amount = item.amount;
//item.amount_rmb = item.userable_amount * item.exchangerate; m.amount_rmb = item.amount_rmb;
item.before_balance = item.userable_amount; m.amount_sales = 0;
item.end_balance = item.userable_amount; m.before_balance = 0;
m.end_balance = item.amount_rmb;
m.exchangerate = item.exchangerate;
m.freeze_amount = item.freeze_amount;
m.freeze_amount_rmb = item.freeze_amount_rmb;
m.fromsource = item.fromsource;
m.notes = item.notes;
m.paycompanyid = item.paycompanyid;
m.platformcode = item.platformcode;
m.platformname = item.platformname;
m.puttime = item.puttime;
m.saleday = null;
m.userable_amount = item.userable_amount;
m.userable_amount_rmb = item.userable_amount_rmb;
m.withdraw_amount = 0;
} }
if (item.amount < 0 || item.amount_sales<0 || item.before_balance<0||item.userable_amount<0||item.withdraw_amount<0)
{
return "金额必须大于0";
}
if (item.id <= 0) if (item.id <= 0)
......
...@@ -3683,8 +3683,8 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -3683,8 +3683,8 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
} }
//var account = row["平台账号"].ToString(); //var account = row["平台账号"].ToString();
var currency = row["币种"].ToString(); var currency = row["币种"].ToString();
var day = DateTime.Parse(row["销售额统计日期"].ToString()); var day = DateTime.Parse(row["日期"].ToString());
if (string.IsNullOrEmpty(platformcode)) if (string.IsNullOrEmpty(platformcode))
{ {
...@@ -3733,116 +3733,63 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -3733,116 +3733,63 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
var m = new Services.FinanceReportServices().GetPlatformBalance(platformcode, currency, day,account); var m = new Services.FinanceReportServices().GetPlatformBalance(platformcode, currency, day,account);
//区分销售和财务
if ((row["平台每日到账额"].ToString() == "")) //销售
{
var amount = decimal.Parse(row["总余额"].ToString().Trim());
var userable = decimal.Parse(row["可用余额"].ToString().Trim());
var freezeamount = decimal.Parse(row["冻结余额"].ToString().Trim());
var saleday = DateTime.Parse(row["初始额统计日期"].ToString());
var puttime = DateTime.Parse(row["放款时间"].ToString());
var dailysale = decimal.Parse(row["平台每天总销售额"].ToString().Trim());
var notes = row["备注"].ToString();
if (puttime < DateTime.Parse("1999-01-01"))
{
return Json(new
{
success = false,
msg = "请填写正确的放款时间!",
});
}
if (m != null && m.amount_sales > 0) var amount = decimal.Parse(row["当日余额"].ToString().Trim());
{ var userable = decimal.Parse(row["可用余额"].ToString().Trim());
return Json(new { var freezeamount = decimal.Parse(row["冻结余额"].ToString().Trim());
success = false, //var saleday = DateTime.Parse(row["初始额统计日期"].ToString());
msg = "平台【"+platformcode+"】,币种【"+m.currency+"】在"+day.ToShortDateString()+"已经导入了数据,请删除该数据后重新导入。" //var puttime = DateTime.Parse(row["放款时间"].ToString());
}); //var dailysale = decimal.Parse(row["平台每天总销售额"].ToString().Trim());
} var notes = row["备注"].ToString();
list.Add(new dc_platform_balance //if (puttime < DateTime.Parse("1999-01-01"))
{
id= (m!=null?m.id:0),
account = account,
currency = currency,
amount = amount,
exchangerate = rate.Item2,
freeze_amount = freezeamount,
userable_amount = userable,
day = day,
delstatus = 0,
platformcode = objplatform.english_name,
platformname = objplatform.china_name,
paycompanyid = 2, //默认设置香港百伦
amount_rmb = amount * rate.Item2,
freeze_amount_rmb = freezeamount * rate.Item2,
userable_amount_rmb = userable * rate.Item2,
puttime = puttime,
notes = notes,
saleday = saleday,
fromsource = "",
amount_sales = dailysale,
withdraw_amount = (m!=null?m.withdraw_amount:0),
before_balance = (m!=null?m.before_balance:0),
createtime = DateTime.Now,
createuserid = uid,
createusername = username,
});
}
else
{
var withdrawamount = decimal.Parse(row["平台每日到账额"].ToString());
if (m != null && m.withdraw_amount != 0)
{
return Json(new
{
success = false,
msg = "平台【" + platformcode + "】在" + day + "已经导入了数据,请删除该数据后重新导入。"
});
}
list.Add(new dc_platform_balance {
id = (m!=null?m.id:0),
account = account,
currency = currency,
amount = (m!=null?m.amount:0),
amount_rmb = (m!=null?m.amount_rmb:0),
amount_sales = (m!=null?m.amount_sales:0),
before_balance = (m!=null?m.before_balance:0),
day = day,
delstatus = 0,
exchangerate = rate.Item2,
freeze_amount =(m!=null?m.freeze_amount:0),
freeze_amount_rmb=(m!=null?m.freeze_amount_rmb:0),
fromsource = (m!=null?m.fromsource:""),
notes = (m!=null?m.notes:""),
paycompanyid = (m!=null?m.paycompanyid:0),
platformcode = objplatform.english_name,
platformname = objplatform.china_name,
puttime = (m!=null?m.puttime: DateTime.Parse("1999-01-01")),
saleday = (m!=null?m.saleday: DateTime.Parse("1999-01-01")),
userable_amount = (m!=null?m.userable_amount:0),
userable_amount_rmb = (m!=null?m.userable_amount_rmb:0),
withdraw_amount = withdrawamount,
createtime = DateTime.Now,
createuserid = uid,
createusername = username
});
}
//if (string.IsNullOrEmpty(account))
//{ //{
// return Json(new // return Json(new
// { // {
// success = false, // success = false,
// msg = "平台帐号不能为空!", // msg = "请填写正确的放款时间!",
// }); // });
//} //}
if (m != null && m.amount_sales > 0)
{
return Json(new {
success = false,
msg = "平台【"+platformcode+"】,币种【"+m.currency+"】在"+day.ToShortDateString()+"已经导入了数据,请删除该数据后重新导入。"
});
}
list.Add(new dc_platform_balance
{
id= (m!=null?m.id:0),
account = account,
currency = currency,
amount = amount,
exchangerate = rate.Item2,
freeze_amount = freezeamount,
userable_amount = userable,
day = day,
delstatus = 0,
platformcode = objplatform.english_name,
platformname = objplatform.china_name,
paycompanyid = 2, //默认设置香港百伦
amount_rmb = amount * rate.Item2,
freeze_amount_rmb = freezeamount * rate.Item2,
userable_amount_rmb = userable * rate.Item2,
puttime = DateTime.Parse("1990-01-01"),
notes = notes,
saleday = DateTime.Parse("1990-01-01"),
fromsource = "",
amount_sales = 0,
withdraw_amount = (m!=null?m.withdraw_amount:0),
before_balance = (m!=null?m.before_balance:0),
createtime = DateTime.Now,
createuserid = uid,
createusername = username,
end_balance = amount * rate.Item2,
});
} }
catch (Exception ex) catch (Exception ex)
......
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
{ field: 'amount', title: '总金额(原币)', width: '140', sortable: true}, { field: 'amount', title: '总金额(原币)', width: '140', sortable: true},
{ field: 'userable_amount', title: '可用余额(原币)', width: '140', sortable: true}, { field: 'userable_amount', title: '可用余额(原币)', width: '140', sortable: true},
{ field: 'freeze_amount', title: '冻结余额(原币)', width: '140', sortable: true}, { field: 'freeze_amount', title: '冻结余额(原币)', width: '140', sortable: true},
{ field: 'puttime', title: '放款时间', width: '130', sortable: true }, //{ field: 'puttime', title: '放款时间', width: '130', sortable: true },
{ field: 'exchangerate', title: '汇率', width: '100'}, { field: 'exchangerate', title: '汇率', width: '100'},
{ field: 'amount_rmb', title: '总余额(人民币)', width: '150', sortable: true}, { field: 'amount_rmb', title: '总余额(人民币)', width: '150', sortable: true},
{ field: 'userable_amount_rmb', title: '可用余额(人民币)', width: '140', sortable: true}, { field: 'userable_amount_rmb', title: '可用余额(人民币)', width: '140', sortable: true},
...@@ -91,19 +91,19 @@ ...@@ -91,19 +91,19 @@
return '<p class="mules" title="' + data.notes + '">' + data.notes + '</p>'; return '<p class="mules" title="' + data.notes + '">' + data.notes + '</p>';
} }
}, },
{ field: 'before_balance', title: '上一期期末', width: '140', sortable: true }, //{ field: 'before_balance', title: '上一期期末', width: '140', sortable: true },
{ field: 'amount_sales', title: '平台每日销售额', width: '140', sortable: true }, //{ field: 'amount_sales', title: '平台每日销售额', width: '140', sortable: true },
{ //{
field: 'withdraw_amount', title: '平台每日到账额', width: '160', sortable: true, formatter: function (idx, data) { // field: 'withdraw_amount', title: '平台每日到账额', width: '160', sortable: true, formatter: function (idx, data) {
if (data.fromsource == "oms") { // if (data.fromsource == "oms") {
return '<input id="withdraw_amount_' + data.id + '" type="number" style="width:100px;" value="' + data.withdraw_amount + '" />'; // return '<input id="withdraw_amount_' + data.id + '" type="number" style="width:100px;" value="' + data.withdraw_amount + '" />';
} // }
else { // else {
return (data.withdraw_amount); // return (data.withdraw_amount);
} // }
} // }
}, //},
{ field: 'saleday', title: '初始额统计日期', width: '140', sortable: true }, //{ field: 'saleday', title: '初始额统计日期', width: '140', sortable: true },
{ {
field: 'option', title: '操作', width: '140px', formatter: function (idx, data) { field: 'option', title: '操作', width: '140px', formatter: function (idx, data) {
var s = ''; var s = '';
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<div class="form-group"> <div class="form-group">
<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="btn_Upload" class="btn btn-success">导入</button> <button id="btn_Upload" class="btn btn-success">导入</button>
<a id="btn_UpdateTemplate" class="btn btn-default" href="@Url.Content("~/templatefile/accountTemplate.xls")" target="_blank">下载导入模版</a> <a id="btn_UpdateTemplate" class="btn btn-default" href="@Url.Content("~/templatefile/accountTemplate1.xls")" target="_blank">下载导入模版</a>
</div> </div>
</div> </div>
</form> </form>
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
{ field: 'amount', title: '总金额(原币)', width: '140', sortable: true, iscount: true }, { field: 'amount', title: '总金额(原币)', width: '140', sortable: true, iscount: true },
{ field: 'userable_amount', title: '可用余额(原币)', width: '140', sortable: true, iscount: true }, { field: 'userable_amount', title: '可用余额(原币)', width: '140', sortable: true, iscount: true },
{ field: 'freeze_amount', title: '冻结余额(原币)', width: '140', sortable: true, iscount: true }, { field: 'freeze_amount', title: '冻结余额(原币)', width: '140', sortable: true, iscount: true },
{ field: 'puttime', title: '放款时间', width: '130' }, //{ field: 'puttime', title: '放款时间', width: '130' },
{ field: 'exchangerate', title: '汇率', width: '100'}, { field: 'exchangerate', title: '汇率', width: '100'},
{ field: 'amount_rmb', title: '总余额(人民币)', width: '150', sortable: true, iscount: true }, { field: 'amount_rmb', title: '总余额(人民币)', width: '150', sortable: true, iscount: true },
{ field: 'userable_amount_rmb', title: '可用余额(人民币)', width: '140', sortable: true, iscount: true }, { field: 'userable_amount_rmb', title: '可用余额(人民币)', width: '140', sortable: true, iscount: true },
......
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
{ field: 'amount_rmb', title: '总余额(人民币)', width: '160', sortable: true }, { field: 'amount_rmb', title: '总余额(人民币)', width: '160', sortable: true },
{ field: 'userable_amount_rmb', title: '可用余额(人民币)', width: '160', sortable: true }, { field: 'userable_amount_rmb', title: '可用余额(人民币)', width: '160', sortable: true },
{ field: 'freeze_amount_rmb', title: '冻结余额(人民币)', width: '160', sortable: true }, { field: 'freeze_amount_rmb', title: '冻结余额(人民币)', width: '160', sortable: true },
{ field: 'puttime', title: '放款日期', width: '110', sortable: false }, //{ field: 'puttime', title: '放款日期', width: '110', sortable: false },
{ field: 'day', title: '统计日期', width: '110', sortable: false }, { field: 'day', title: '统计日期', width: '110', sortable: false },
]; ];
......
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