Commit c17b5ba9 by guanzhenshan

1、增加分录明细页面,2、导入paypal收入明细时增加生成分录明细功能

parent cd61e3b2
......@@ -62,4 +62,16 @@ namespace Bailun.DC.Models
public DateTime createtime { get; set; }
}
/// <summary>
/// paypal收入统计模版
/// </summary>
public class mPaypalIncome
{
public string currency { get; set; }
public decimal gross { get; set; }
public string account { get; set; }
}
}
......@@ -2063,20 +2063,31 @@ namespace Bailun.DC.Services
{
foreach (var item in list)
{
str += $"('{item.account_name}','{item.record_time.ToString("yyyy-MM-dd HH:mm:ss")}','{item.time_zone}','{item.name.Replace("'","")}','{item.type}','{item.status}','{item.currency}','{item.gross}','{item.fee}','{item.net}','{item.from_email}','{item.to_email}','{item.transaction_id}','{item.shipping_address.Replace("'","")}','{item.address_status}','{item.item_title.Replace("'", "")}','{item.item_id}','{item.shipping_handling_amount}','{item.insurance_amount}','{item.sales_tax}','{item.option_name1}','{item.option_value1}','{item.option_name2}','{item.option_value2}','{item.reference_txn_id}','{item.invoice_number}','{item.custom_number}','{item.quantity}','{item.receipt_id}','{item.balance}','{item.address_line1.Replace("'", "")}','{item.address_line2.Replace("'", "")}','{item.town.Replace("'", "")}','{item.province.Replace("'", "")}','{item.postal_code}','{item.country}','{item.contact_phone_number.Replace("'", "")}','{item.subject.Replace("'", "")}','{item.note.Replace("'", "")}','{item.country_code}','{item.balance_impact}','{item.createtime.ToString("yyyy-MM-dd HH:mm:ss")}','{item.createuserid}','{item.createusername}',{item.company_id}),";
}
str = str.Substring(0, str.Length-1);
str += $"('{item.account_name}','{item.record_time.ToString("yyyy-MM-dd HH:mm:ss")}','{item.time_zone}','{item.name.Replace("'","").Replace("\\","")}','{item.type}','{item.status}','{item.currency}','{item.gross}','{item.fee}','{item.net}','{item.from_email.Replace("'","")}','{item.to_email}','{item.transaction_id}','{item.shipping_address.Replace("'","")}','{item.address_status}','{item.item_title.Replace("'", "")}','{item.item_id}','{item.shipping_handling_amount}','{item.insurance_amount}','{item.sales_tax}','{item.option_name1}','{item.option_value1}','{item.option_name2}','{item.option_value2}','{item.reference_txn_id}','{item.invoice_number}','{item.custom_number}','{item.quantity}','{item.receipt_id}','{item.balance}','{item.address_line1.Replace("'", "")}','{item.address_line2.Replace("'", "")}','{item.town.Replace("'", "")}','{item.province.Replace("'", "")}','{item.postal_code}','{item.country}','{item.contact_phone_number.Replace("'", "")}','{item.subject.Replace("'", "")}','{item.note.Replace("'", "")}','{item.country_code}','{item.balance_impact}','{item.createtime.ToString("yyyy-MM-dd HH:mm:ss")}','{item.createuserid}','{item.createusername}',{item.company_id}),";
if (index % pagesize == 0 || index == count)
{
str = str.Substring(0, str.Length - 1);
cn.Execute(sql + str);
str = "";
}
index++;
}
trans.Commit();
trans.Dispose();
cn.Dispose();
return "";
}
catch (Exception ex)
{
trans.Rollback();
cn.Dispose();
return ex.Message;
}
}
......@@ -2174,10 +2185,9 @@ namespace Bailun.DC.Services
catch (Exception ex)
{
throw;
return new List<dc_base_income_ebay_paypal>();
}
return new List<dc_base_income_ebay_paypal>();
}
}
......@@ -2217,98 +2227,20 @@ namespace Bailun.DC.Services
}
}
/// <summary>
/// 分析paypal明细,并出分录数据
/// </summary>
/// <param name="account">帐号</param>
/// <param name="start">开始时间</param>
/// <param name="end">结束时间</param>
/// <returns></returns>
public string Analyze_PaypalIncoming(string account, DateTime start, DateTime end)
{
/*
-- paypal 分录
select type from dc_base_income_ebay_paypal
group by type;
--1、预收款 'eBay竞拍付款','移动支付','普通付款'
select currency, sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and balance_impact = '贷记' and account_name = 'aublzhao18@126.com' and type in ('eBay竞拍付款', '移动支付', '普通付款') and record_time>= '2019-08-01' and record_time<'2019-09-01'
group by currency
;
--2、临时冻结 '冻结余额以调查争议'
select currency, sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = 'aublzhao18@126.com' and type in ('冻结余额以调查争议') and record_time>= '2019-08-01' and record_time<'2019-09-01'
group by currency
;
--付款撤销
select currency, sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = 'aublzhao18@126.com' and type in ('付款撤销') and record_time>= '2019-08-01' and record_time<'2019-09-01'
group by currency
;
--退单
select currency, sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = 'aublzhao18@126.com' and type in ('退单') and record_time>= '2019-08-01' and record_time<'2019-09-01'
group by currency
;
--退单撤销
select currency, sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = 'aublzhao18@126.com' and type in ('退单撤销') and record_time>= '2019-08-01' and record_time<'2019-09-01'
group by currency
;
--3、争议补偿
select currency,sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = 'aublzhao18@126.com' and type in ('取消冻结以解决争议') and record_time>= '2019-08-01' and record_time<'2019-09-01'
group by currency
;
--4、已发放退款
select currency,sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = 'aublzhao18@126.com' and type in ('付款退款') and record_time>= '2019-08-01' and record_time<'2019-09-01'
group by currency
;
--5、在线发送的付款
-- 已付款项
select currency,sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = 'aublzhao18@126.com' and type in ('普通付款') and record_time>= '2019-08-01' and record_time<'2019-09-01' and gross<0 and balance_impact = '借记'
group by currency
;
--第三方偿付
select currency, sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = 'aublzhao18@126.com' and type in ('第三方偿付') and record_time>= '2019-08-01' and record_time<'2019-09-01'
group by currency
-- 集中付款 分正数和负数,如果是正数则是其他帐号转进来的,如果是负数则是本帐号转出的
select currency,sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = 'aublzhao18@126.com' and type in ('集中付款') and record_time>= '2019-08-01' and record_time<'2019-09-01'
group by currency
;
--快速结账付款
select currency, sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = 'aublzhao18@126.com' and type in ('快速结账付款') and record_time>= '2019-08-01' and record_time<'2019-09-01'
group by currency
;
--费用
select currency, sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = 'aublzhao18@126.com' and type in ('费用') and record_time>= '2019-08-01' and record_time<'2019-09-01'
group by currency
;
--6、转账和提现
-- 币种兑换
select currency,sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = 'aublzhao18@126.com' and type in ('普通币种兑换') and record_time>= '2019-08-01' and record_time<'2019-09-01'
group by currency
;
select currency, sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = 'aublzhao18@126.com' and type in ('用户发起的币种兑换') and record_time>= '2019-08-01' and record_time<'2019-09-01'
group by currency
;
--提现
select currency, sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = 'aublzhao18@126.com' and type in ('普通提现') and record_time>= '2019-08-01' and record_time<'2019-09-01'
group by currency
;
*/
try
{
var sql = "";
using (var cn = new MySqlConnection())
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{
if (cn.State == ConnectionState.Closed)
{
......@@ -2319,90 +2251,832 @@ group by currency
sql = $@"select currency, sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and balance_impact = '贷记' and account_name = '{account}' and type in ('eBay竞拍付款', '移动支付', '普通付款') and record_time>= '{start.ToString("yyyy-MM-dd HH:MM:ss")}' and record_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}'
group by currency";
var objAdvanceReceive = cn.Query<string>(sql, null, null, true, 2 * 60);
var objAdvanceReceive = cn.Query<mPaypalIncome>(sql, null, null, true, 2 * 60);
//--2、临时冻结 '冻结余额以调查争议'
sql = $@"select currency, sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = '{account}' and type in ('冻结余额以调查争议') and record_time>= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and record_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}'
group by currency";
var objFreeze = cn.Query<string>(sql, null, null, true, 2 * 60);
var objFreeze = cn.Query<mPaypalIncome>(sql, null, null, true, 2 * 60);
//付款撤销 负数
sql = $@"select currency, sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = '{account}' and type in ('付款撤销') and record_time>= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and record_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}' and gross<0
group by currency";
var objPaymentCancel_n = cn.Query<mPaypalIncome>(sql, null, null, true, 2 * 60);
//付款撤销
sql = $@"select currency, sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = '{account}' and type in ('付款撤销') and record_time>= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and record_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}'
//付款撤销 正数
sql = $@"select currency, sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = '{account}' and type in ('付款撤销') and record_time>= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and record_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}' and gross>0
group by currency";
var objPaymentCancel = cn.Query<string>(sql, null, null, true, 2 * 60);
var objPaymentCancel_p = cn.Query<mPaypalIncome>(sql, null, null, true, 2 * 60);
//退单
sql = $@"select currency, sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = '{account}' and type in ('退单') and record_time>= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and record_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}'
sql = $@"select currency, sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = '{account}' and type in ('退单') and record_time>= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and record_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}' and gross<0
group by currency";
var objChargeback = cn.Query<string>(sql, null, null, true, 2 * 60);
var objChargeback = cn.Query<mPaypalIncome>(sql, null, null, true, 2 * 60);
//退单撤销
sql = $@"select currency, sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = '{account}' and type in ('退单撤销') and record_time>= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and record_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}'
sql = $@"select currency, sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = '{account}' and type in ('退单撤销') and record_time>= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and record_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}' and gross>0
group by currency";
var objCharebackCancel = cn.Query<string>(sql, null, null, true, 2 * 60);
var objCharebackCancel = cn.Query<mPaypalIncome>(sql, null, null, true, 2 * 60);
//--3、争议补偿
sql = $@"select currency,sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = '{account}' and type in ('取消冻结以解决争议') and record_time>= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and record_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}'
group by currency";
var objCompensationDispute = cn.Query<string>(sql, null, null, true, 2 * 60);
var objCompensationDispute = cn.Query<mPaypalIncome>(sql, null, null, true, 2 * 60);
//--4、已发放退款 负数
sql = $@"select currency,sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = '{account}' and type in ('付款退款') and record_time>= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and record_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}' and gross<0
group by currency";
var objRefundIssued_n = cn.Query<mPaypalIncome>(sql, null, null, true, 2 * 60);
//--4、已发放退款
sql = $@"select currency,sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = '{account}' and type in ('付款退款') and record_time>= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and record_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}'
//--4、已发放退款 正数
sql = $@"select currency,sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = '{account}' and type in ('付款退款') and record_time>= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and record_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}' and gross>0
group by currency";
var objRefundIssued = cn.Query<string>(sql, null, null, true, 2 * 60);
var objRefundIssued_p = cn.Query<mPaypalIncome>(sql, null, null, true, 2 * 60);
//--5、在线发送的付款
//-- 已付款项
sql = $@"select currency,sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = '{account}' and type in ('普通付款') and record_time>= '2019-08-01' and record_time<'2019-09-01' and gross<0 and balance_impact = '借记'
sql = $@"select currency,sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = '{account}' and type in ('普通付款') and record_time>= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and record_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}' and gross<0 and balance_impact = '借记' and gross<0
group by currency";
var objPayment = cn.Query<string>(sql, null, null, true, 2 * 60);
var objPayment = cn.Query<mPaypalIncome>(sql, null, null, true, 2 * 60);
//--第三方偿付
sql = $@"select currency, sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = '{account}' and type in ('第三方偿付') and record_time>= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and record_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}'
group by currency";
var objThirdPartyReimbursement = cn.Query<string>(sql, null, null, true, 2 * 60);
var objThirdPartyReimbursement = cn.Query<mPaypalIncome>(sql, null, null, true, 2 * 60);
//-- 集中付款 分正数和负数,如果是正数则是其他帐号转进来的,如果是负数则是本帐号转出的
sql = $@"select currency,sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = '{account}' and type in ('集中付款') and record_time>= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and record_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}'
group by currency";
var objCentralizedPayment = cn.Query<string>(sql, null, null, true, 2 * 60);
sql = $@"select currency,from_email as account,sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = '{account}' and type in ('集中付款') and record_time>= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and record_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}' and gross>0
group by currency,from_email";
var objCentralizedPayment_p = cn.Query<mPaypalIncome>(sql, null, null, true, 2 * 60);
//-- 集中付款 --负数
sql = $@"select currency,sum(gross) gross,to_email as account from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = '{account}' and type in ('集中付款') and record_time>= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and record_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}' and gross<0
group by currency,to_email";
var objCentralizedPayment_n = cn.Query<mPaypalIncome>(sql, null, null, true, 2 * 60);
//--快速结账付款
sql = $@"select currency, sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = '{account}' and type in ('快速结账付款') and record_time>= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and record_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}'
group by currency";
var objExpressPayment = cn.Query<string>(sql, null, null, true, 2 * 60);
var objExpressPayment = cn.Query<mPaypalIncome>(sql, null, null, true, 2 * 60);
//--费用
sql = $@"select currency, sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = '{account}' and type in ('费用') and record_time>= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and record_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}'
group by currency";
var objFee = cn.Query<string>(sql, null, null, true, 2 * 60);
var objFee = cn.Query<mPaypalIncome>(sql, null, null, true, 2 * 60);
//--6、转账和提现
//-- 币种兑换 普通币种兑换
sql = $@"select currency,sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = '{account}' and type in ('普通币种兑换') and record_time>= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and record_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}'
//-- 币种兑换 普通币种兑换 --负数
sql = $@"select currency,sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = '{account}' and type in ('普通币种兑换') and record_time>= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and record_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}' and gross<0
group by currency";
var objCurrencyConvert_n = cn.Query<mPaypalIncome>(sql, null, null, true, 2 * 60);
//-- 币种兑换 普通币种兑换 --正数
sql = $@"select currency,sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = '{account}' and type in ('普通币种兑换') and record_time>= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and record_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}' and gross>0
group by currency";
var objCurrencyConvert = cn.Query<string>(sql, null, null, true, 2 * 60);
var objCurrencyConvert_p = cn.Query<mPaypalIncome>(sql, null, null, true, 2 * 60);
//币种兑换 用户发起的币种兑换
sql = $@"select currency, sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = '{account}' and type in ('用户发起的币种兑换') and record_time>= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and record_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}'
//币种兑换 用户发起的币种兑换 --负数
sql = $@"select currency, sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = '{account}' and type in ('用户发起的币种兑换') and record_time>= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and record_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}' and gross<0
group by currency";
var objCurrencyConvertByCus_n = cn.Query<mPaypalIncome>(sql, null, null, true, 2 * 60);
//币种兑换 用户发起的币种兑换 --正数
sql = $@"select currency, sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = '{account}' and type in ('用户发起的币种兑换') and record_time>= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and record_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}' and gross>0
group by currency";
var objCurrencyConvertByCus = cn.Query<string>(sql, null, null,true,2 * 60);
var objCurrencyConvertByCus_p = cn.Query<mPaypalIncome>(sql, null, null, true, 2 * 60);
//--提现
sql = $@"select currency, sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and `status`= '已完成' and account_name = '{account}' and type in ('普通提现') and record_time>= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and record_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}'
sql = $@"select currency, sum(gross) gross from dc_base_income_ebay_paypal where company_id = 1 and account_name = '{account}' and type in ('普通提现') and record_time>= '{start.ToString("yyyy-MM-dd HH:mm:ss")}' and record_time<'{end.ToString("yyyy-MM-dd HH:mm:ss")}'
group by currency";
var objWithDraw = cn.Query<string>(sql,null,null,true,2*60);
var objWithDraw = cn.Query<mPaypalIncome>(sql, null, null, true, 2 * 60);
//已收款项
if (objAdvanceReceive.Count() > 0)
{
foreach (var item in objAdvanceReceive)
{
var m1 = new dc_mid_incoming_paypal
{
amount = item.gross,
createtime = DateTime.Now,
balance_impact = "借",
currency = item.currency,
paypal_account = account,
platform_bank = "paypal",
receive_account = account,
recordtime = start.ToString("yyyy-MM"),
account_subject = "预收货款",
note = "其他货币资金",
};
var m2 = new dc_mid_incoming_paypal
{
amount = item.gross,
createtime = DateTime.Now,
balance_impact = "贷",
currency = item.currency,
paypal_account = account,
platform_bank = "",
receive_account = account,
recordtime = start.ToString("yyyy-MM"),
account_subject = "预收货款",
note = "预收账款",
};
cn.Insert<dc_mid_incoming_paypal>(m1);
cn.Insert<dc_mid_incoming_paypal>(m2);
}
}
//临时冻结
if (objFreeze.Count() > 0)
{
foreach (var item in objFreeze)
{
var m1 = new dc_mid_incoming_paypal
{
account_subject = "临时冻结",
amount = item.gross,
balance_impact = "借",
createtime = DateTime.Now,
currency = item.currency,
note = "预收账款",
paypal_account = account,
platform_bank = "",
receive_account = account,
recordtime = start.ToString("yyyy-MM"),
};
var m2 = new dc_mid_incoming_paypal
{
account_subject = "临时冻结",
amount = item.gross,
balance_impact = "贷",
createtime = DateTime.Now,
currency = item.currency,
note = "其他货币资金",
paypal_account = account,
platform_bank = "paypal",
receive_account = account,
recordtime = start.ToString("yyyy-MM")
};
cn.Insert<dc_mid_incoming_paypal>(m1);
cn.Insert<dc_mid_incoming_paypal>(m2);
}
}
//付款撤销 负数
//付款撤销 正数
if (objPaymentCancel_p.Count() > 0)
{
foreach (var item in objPaymentCancel_p)
{
var m1 = new dc_mid_incoming_paypal
{
account_subject = "撤销正数",
amount = item.gross,
balance_impact = "借",
createtime = DateTime.Now,
currency = item.currency,
note = "其他货币资金",
paypal_account = account,
platform_bank = "paypal",
receive_account = account,
recordtime = start.ToString("yyyy-MM"),
};
var m2 = new dc_mid_incoming_paypal
{
account_subject = "撤销正数",
amount = item.gross,
balance_impact = "贷",
createtime = DateTime.Now,
currency = item.currency,
note = "营业外收入",
paypal_account = account,
platform_bank = "",
receive_account = account,
recordtime = start.ToString("yyyy-MM")
};
cn.Insert<dc_mid_incoming_paypal>(m1);
cn.Insert<dc_mid_incoming_paypal>(m2);
}
}
//退单
if (objChargeback.Count() > 0)
{
foreach (var item in objChargeback)
{
var m1 = new dc_mid_incoming_paypal
{
account_subject = "退单结算",
amount = item.gross,
balance_impact = "借",
createtime = DateTime.Now,
currency = item.currency,
note = "营业外支出",
paypal_account = account,
platform_bank = "paypal",
receive_account = account,
recordtime = start.ToString("yyyy-MM")
};
var m2 = new dc_mid_incoming_paypal
{
account_subject = "退单结算",
amount = item.gross,
balance_impact = "贷",
createtime = DateTime.Now,
currency = item.currency,
note = "其他货币资金",
paypal_account = account,
platform_bank = "",
receive_account = account,
recordtime = start.ToString("yyyy-MM"),
};
cn.Insert<dc_mid_incoming_paypal>(m1);
cn.Insert<dc_mid_incoming_paypal>(m2);
}
}
//退单撤销
if (objCharebackCancel.Count() > 0)
{
foreach (var item in objCharebackCancel)
{
var m1 = new dc_mid_incoming_paypal
{
account_subject = "退单撤销",
amount = item.gross,
balance_impact = "借",
createtime = DateTime.Now,
currency = item.currency,
note = "其他货币资金",
paypal_account = account,
platform_bank = "paypal",
receive_account = account,
recordtime = start.ToString("yyyy-MM")
};
var m2 = new dc_mid_incoming_paypal
{
account_subject = "退单撤销",
amount = item.gross,
balance_impact = "贷",
createtime = DateTime.Now,
currency = item.currency,
note = "营业外收入",
paypal_account = account,
platform_bank = "",
receive_account = account,
recordtime = start.ToString("yyyy-MM")
};
cn.Insert<dc_mid_incoming_paypal>(m1);
cn.Insert<dc_mid_incoming_paypal>(m2);
}
}
//争议补偿
if (objCompensationDispute.Count() > 0)
{
foreach (var item in objCompensationDispute)
{
var m1 = new dc_mid_incoming_paypal
{
account_subject = "更新为撤销",
amount = item.gross,
balance_impact = "借",
createtime = DateTime.Now,
currency = item.currency,
note = "其他货币资金",
paypal_account = account,
platform_bank = "paypal",
receive_account = account,
recordtime = start.ToString("yyyy-MM")
};
var m2 = new dc_mid_incoming_paypal
{
account_subject = "更新为撤销",
amount = item.gross,
balance_impact = "贷",
createtime = DateTime.Now,
currency = item.currency,
note = "预收账款",
paypal_account = account,
platform_bank = "",
receive_account = account,
recordtime = start.ToString("yyyy-MM")
};
cn.Insert<dc_mid_incoming_paypal>(m1);
cn.Insert<dc_mid_incoming_paypal>(m2);
}
}
//已发放退款 --负数
if (objRefundIssued_n.Count() > 0)
{
foreach (var item in objRefundIssued_n)
{
//主营业务收入 - 销售折扣与折让
//预收账款
var m1 = new dc_mid_incoming_paypal
{
account_subject = "退款和撤销",
amount = item.gross,
balance_impact = "借",
createtime = DateTime.Now,
currency = item.currency,
note = "预收账款",
paypal_account = account,
platform_bank = "",
receive_account = account,
recordtime = start.ToString("yyyy-MM")
};
//其他货币资金
var m2 = new dc_mid_incoming_paypal
{
account_subject = "退款和撤销",
amount = item.gross,
balance_impact = "贷",
createtime = DateTime.Now,
currency = item.currency,
note = "其他币种资金",
paypal_account = account,
platform_bank = "paypal",
receive_account = account,
recordtime = start.ToString("yyyy-MM")
};
cn.Insert<dc_mid_incoming_paypal>(m1);
cn.Insert<dc_mid_incoming_paypal>(m2);
}
}
//已发放退款 --正数
if (objRefundIssued_p.Count() > 0)
{
foreach (var item in objRefundIssued_p)
{
var m1 = new dc_mid_incoming_paypal
{
account_subject = "退款正数和撤销正数",
amount = item.gross,
balance_impact = "贷",
createtime = DateTime.Now,
currency = item.currency,
note = "其他货币资金",
paypal_account = account,
platform_bank = "ebay",
receive_account = account,
recordtime = start.ToString("yyyy-MM")
};
var m2 = new dc_mid_incoming_paypal
{
account_subject = "退款正数和撤销正数",
amount = item.gross,
balance_impact = "借",
createtime = DateTime.Now,
currency = item.currency,
note = "营业外收入",
paypal_account = account,
platform_bank = "",
receive_account = account,
recordtime = start.ToString("yyyy-MM")
};
cn.Insert<dc_mid_incoming_paypal>(m1);
cn.Insert<dc_mid_incoming_paypal>(m2);
}
}
//在线发送的付款
//已付款项
if (objPayment.Count() > 0)
{
foreach (var item in objPayment)
{
var m1 = new dc_mid_incoming_paypal
{
account_subject = "已付款项",
amount = item.gross,
balance_impact = "贷",
createtime = DateTime.Now,
currency = item.currency,
note = "主营业务收入-销售折扣与折让",
paypal_account = account,
platform_bank = "ebay",
receive_account = account,
recordtime = start.ToString("yyyy-MM")
};
var m2 = new dc_mid_incoming_paypal
{
account_subject = "已付款项",
amount = item.gross,
balance_impact = "借",
createtime = DateTime.Now,
currency = item.currency,
note = "其他货币资金",
paypal_account = account,
platform_bank = "",
receive_account = account,
recordtime = start.ToString("yyyy-MM"),
};
cn.Insert<dc_mid_incoming_paypal>(m1);
cn.Insert<dc_mid_incoming_paypal>(m2);
}
}
//第三方偿付
if (objThirdPartyReimbursement.Count() > 0)
{
foreach (var item in objThirdPartyReimbursement)
{
var m1 = new dc_mid_incoming_paypal
{
account_subject = "第三方偿付",
amount = item.gross,
balance_impact = "借",
createtime = DateTime.Now,
currency = item.currency,
note = "营业外支出",
paypal_account = account,
platform_bank = "paypal",
receive_account = account,
recordtime = start.ToString("yyyy-MM")
};
var m2 = new dc_mid_incoming_paypal
{
account_subject = "已付款项",
amount = item.gross,
balance_impact = "贷",
createtime = DateTime.Now,
currency = item.currency,
note = "其他货币资金",
paypal_account = account,
platform_bank = "",
receive_account = account,
recordtime = start.ToString("yyyy-MM")
};
cn.Insert<dc_mid_incoming_paypal>(m1);
cn.Insert<dc_mid_incoming_paypal>(m2);
}
}
//集中付款 -- 正数
if (objCentralizedPayment_p.Count() > 0)
{
foreach (var item in objCentralizedPayment_p)
{
var m1 = new dc_mid_incoming_paypal
{
account_subject = item.account + "转" + account,
amount = item.gross,
balance_impact = "借",
createtime = DateTime.Now,
currency = item.currency,
note = "其他货币资金",
paypal_account = account,
platform_bank = "paypal",
receive_account = account,
recordtime = start.ToString("yyyy-MM")
};
var m2 = new dc_mid_incoming_paypal
{
account_subject = item.account + "转" + account,
amount = item.gross,
balance_impact = "贷",
createtime = DateTime.Now,
currency = item.currency,
note = "其他货币资金",
paypal_account = account,
platform_bank = "paypal",
receive_account = item.account,
recordtime = start.ToString("yyyy-MM")
};
cn.Insert<dc_mid_incoming_paypal>(m1);
cn.Insert<dc_mid_incoming_paypal>(m2);
}
}
//集中付款 -- 负数
if (objCentralizedPayment_n.Count() > 0)
{
foreach (var item in objCentralizedPayment_n)
{
var m1 = new dc_mid_incoming_paypal
{
account_subject = account + "转" + item.account,
amount = item.gross,
balance_impact = "借",
createtime = DateTime.Now,
currency = item.currency,
note = "其他货币资金",
paypal_account = account,
platform_bank = "paypal",
receive_account = item.account,
recordtime = start.ToString("yyyy-MM")
};
var m2 = new dc_mid_incoming_paypal
{
account_subject = account + "转" + item.account,
amount = item.gross,
balance_impact = "贷",
createtime = DateTime.Now,
currency = item.currency,
note = "其他货币资金",
paypal_account = account,
platform_bank = "paypal",
receive_account = account,
recordtime = start.ToString("yyyy-MM"),
};
cn.Insert<dc_mid_incoming_paypal>(m1);
cn.Insert<dc_mid_incoming_paypal>(m2);
}
}
//快速结账付款
if (objExpressPayment.Count() > 0)
{
foreach (var item in objExpressPayment)
{
var m1 = new dc_mid_incoming_paypal
{
account_subject = "在线发送的付款",
amount = item.gross,
balance_impact = "借",
createtime = DateTime.Now,
currency = item.currency,
note = "销售费用-佣金及平台费",
paypal_account = account,
platform_bank = "ebay",
receive_account = account,
recordtime = start.ToString("yyyy-MM")
};
var m2 = new dc_mid_incoming_paypal
{
account_subject = "在线发送的付款",
amount = item.gross,
balance_impact = "贷",
createtime = DateTime.Now,
currency = item.currency,
note = "其他货币资金",
paypal_account = account,
platform_bank = "paypal",
receive_account = account,
recordtime = start.ToString("yyyy-MM"),
};
cn.Insert<dc_mid_incoming_paypal>(m1);
cn.Insert<dc_mid_incoming_paypal>(m2);
}
}
//费用
if (objFee.Count() > 0)
{
foreach (var item in objFee)
{
var m1 = new dc_mid_incoming_paypal
{
account_subject = "平台费用",
amount = item.gross,
balance_impact = "借",
createtime = DateTime.Now,
currency = item.currency,
note = "销售费用 - 佣金及平台费",
paypal_account = account,
platform_bank = "ebay",
receive_account = account,
recordtime = start.ToString("yyyy-MM")
};
var m2 = new dc_mid_incoming_paypal
{
account_subject = "平台费用",
amount = item.gross,
balance_impact = "贷",
createtime = DateTime.Now,
currency = item.currency,
note = "其他货币资金",
paypal_account = account,
platform_bank = "paypal",
receive_account = account,
recordtime = start.ToString("yyyy-MM")
};
cn.Insert<dc_mid_incoming_paypal>(m1);
cn.Insert<dc_mid_incoming_paypal>(m2);
}
}
//币种兑换 --负数
if (objCurrencyConvert_n.Count() > 0)
{
foreach (var item in objCurrencyConvert_n)
{
var m1 = new dc_mid_incoming_paypal
{
account_subject = "币种兑换",
amount = Math.Abs(item.gross),
balance_impact = (item.gross < 0 ? "贷" : "借"),
createtime = DateTime.Now,
currency = item.currency,
note = "其他货币资金",
paypal_account = account,
platform_bank = "paypal",
receive_account = account,
recordtime = start.ToString("yyyy-MM")
};
}
}
//币种兑换 --正数
if (objCurrencyConvert_p.Count() > 0)
{
foreach (var item in objCurrencyConvert_p)
{
var m1 = new dc_mid_incoming_paypal
{
account_subject = "币种兑换",
amount = Math.Abs(item.gross),
balance_impact = (item.gross < 0 ? "贷" : "借"),
createtime = DateTime.Now,
currency = item.currency,
note = "其他货币资金",
paypal_account = account,
platform_bank = "paypal",
receive_account = account,
recordtime = start.ToString("yyyy-MM")
};
cn.Insert<dc_mid_incoming_paypal>(m1);
}
}
//用户发起的币种兑换 --负数
if (objCurrencyConvertByCus_n.Count() > 0)
{
foreach (var item in objCurrencyConvertByCus_n)
{
var m1 = new dc_mid_incoming_paypal
{
account_subject = "币种兑换",
amount = Math.Abs(item.gross),
balance_impact = (item.gross < 0 ? "贷" : "借"),
createtime = DateTime.Now,
currency = item.currency,
note = "其他货币资金",
paypal_account = account,
platform_bank = "paypal",
receive_account = account,
recordtime = start.ToString("yyyy-MM")
};
cn.Insert<dc_mid_incoming_paypal>(m1);
}
}
//提现
if (objWithDraw.Count() > 0)
{
foreach (var item in objWithDraw)
{
var m1 = new dc_mid_incoming_paypal
{
account_subject = "提现",
amount = Math.Abs(item.gross),
balance_impact = "借",
createtime = DateTime.Now,
currency = item.currency,
note = "银行存款",
paypal_account = account,
platform_bank = "恒生银行",
receive_account = account,
recordtime = start.ToString("yyyy-MM"),
};
var m2 = new dc_mid_incoming_paypal
{
account_subject = "提现",
amount = Math.Abs(item.gross),
balance_impact = "贷",
createtime = DateTime.Now,
currency = item.currency,
note = "其他货币资金",
paypal_account = account,
platform_bank = "paypal",
receive_account = account,
recordtime = start.ToString("yyyy-MM")
};
cn.Insert<dc_mid_incoming_paypal>(m1);
cn.Insert<dc_mid_incoming_paypal>(m2);
}
}
}
return "";
}
catch (Exception ex)
{
return ex.Message;
}
}
/// <summary>
/// 获取Paypal分录明细
/// </summary>
/// <param name="parameter">分页信息</param>
/// <param name="month">月份</param>
/// <param name="account">帐号</param>
/// <param name="total">符合条件的记录数</param>
/// <returns></returns>
public List<dc_mid_incoming_paypal> ListPaypalIncoming(BtTableParameter parameter, string month, string account,ref int total)
{
var sqlparam = new DynamicParameters();
var sql = "select * from dc_mid_incoming_paypal where recordtime='"+month+"'";
if (!string.IsNullOrEmpty(account))
{
sql += " and paypal_account=@account";
sqlparam.Add("account", account);
}
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{
if (cn.State == ConnectionState.Closed)
{
cn.Open();
}
var obj = cn.Page<dc_mid_incoming_paypal>(parameter.pageIndex, parameter.limit, sql, ref total);
return obj.ToList();
}
}
#endregion
......
......@@ -4776,11 +4776,25 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
msg = new Services.FinanceReportServices().SaveEbayPayPalInfo(list);
}
//return Json(new
//{
// success = string.IsNullOrEmpty(result),
// msg = result
//});
if (string.IsNullOrEmpty(msg) && list.Count>0)
{
var objPaypal = list.OrderBy(a => a.record_time).FirstOrDefault();
if (objPaypal != null)
{
var firstDay = DateTime.Parse(objPaypal.record_time.ToString("yyyy-MM") + "-01");
var r = new Services.FinanceReportServices().Analyze_PaypalIncoming(accountname, firstDay,firstDay.AddMonths(1).AddDays(-1));
if (!string.IsNullOrEmpty(r))
{
return Json(new
{
success = false,
msg = "保存" + file.FileName + "成功,生成分录信息失败,异常信息:" + r,
});
}
}
}
if (!string.IsNullOrEmpty(msg))
{
......@@ -4809,6 +4823,49 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
});
}
public ActionResult ListPaypalIncomeAnalyze()
{
return View();
}
/// <summary>
/// paypal收入分录记录
/// </summary>
/// <param name="parameter">分页信息</param>
/// <param name="month">月份</param>
/// <param name="account">paypal帐号</param>
/// <returns></returns>
[BailunAuthentication(LoginMode.Enforce)]
public string ListPaypalIncomeAnalyzeJson(BtTableParameter parameter, string month, string account)
{
var companyid = HttpContextHelper.Current?.User?.GetCompanyId().ToInt32();
var total = 0;
var obj = new Services.FinanceReportServices().ListPaypalIncoming(parameter, month, account, ref total);
var list = obj.Select(a => new {
a.account_subject,
amount = a.amount.ToString("N0"),
a.balance_impact,
createtime = a.createtime.ToString("yyyy-MM-dd HH:mm:ss"),
a.currency,
a.note,
a.paypal_account,
a.platform_bank,
a.receive_account,
a.recordtime,
});
return JsonConvert.SerializeObject(new
{
total = total,
rows = list,
companyid
});
}
#region Private
/// <summary>
......

@{
ViewData["Title"] = "Paypal收入流水";
Layout = "~/Pages/Shared/_MainLayout.cshtml";
ViewBag.Nav = new string[] { "财务报表", "Paypal分录信息" };
}
<div class="row">
<div class="col-sm-12">
<div class="alert alert-warning">
说明:1、只支持csv文件格式导入。2、导入csv文件时,文件名需要增加帐号信息,如[download.csv],增加帐号后的文件名:[download==dudios.csv]
</div>
<div class="ibox-content m-b-sm border-bottom">
<form id="toolbar">
<div class="form-inline" style="line-height:40px;">
<div class="form-group">
<label>Paypal帐号:</label>
<select id="account" name="account" class="form-control" style="width:160px;">
<option value="">选择Paypal帐号</option>
</select>
</div>
<div class="form-group">
<label>分录月份</label>
<input id="month" name="month" type="text" class="form-control" style="width:130px;" value="@(DateTime.Now.ToString("yyyy-MM"))" />
</div>
<div class="form-group">
<label>&nbsp;</label>
<button type="button" class="btn btn-primary" onclick="list();"><i class="fa fa-search"></i>&nbsp;查询</button>
</div>
</div>
</form>
</div>
<div class="ibox-content m-b-sm border-bottom">
<table id="roletable" style="table-layout:fixed;"></table>
</div>
</div>
</div>
@section css{
<link href="~/css/bootstrap-table-fixed-columns.css" rel="stylesheet" />
<style>
.mules {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
}
@section scripts{
<script src="~/js/bootstrap-table-fixed-columns.js" type="text/javascript"></script>
<script type="text/javascript">
var tb;
var companyid = 0;
$(document).ready(function () {
laydate.render({ elem: '#month', type: 'month' });
var height = document.body.clientHeight;
$("#roletable").attr("data-height", (height - 170));
list();
listAccount();
})
function list() {
var columns = [
{ field: 'recordtime', title: '月份', width: '100', sortable: true },
{ field: 'paypal_account', title: '帐号', width: '150' },
{ field: 'note', title: '摘要', width: '150'},
{ field: 'account_subject', title: '会计科目', width: '230', iscount: true},
{ field: 'platform_bank', title: '平台|银行', width: '150'},
{ field: 'receive_account', title: '帐号', width: '130' },
{ field: 'currency', title: '币种', width: '80' },
{ field: 'balance_impact', title: '方向', width: '80' },
{ field: 'amount', title: '金额', width: '100' },
{ field: 'createtime', title: '创建时间', width: '130' }
];
var url = '@Url.Content("~/Reports/Finance/ListPaypalIncomeAnalyzeJson")' + '?' + $("#toolbar").serialize();
if (tb == undefined) {
tb = OnlyTable("roletable", columns, url, "", {
showfooter: true, loadsuccess: function (d) {
//替换汇总行的相关列值
var tr = $('.fixed-table-footer').find('tr');
for (var c in columns) {
var key = columns[c].field;
if (columns[c].iscount) {
for (var v in d.count_row) {
if (key == v) {
tr.find('td').eq(c).children('div').first().html(d.count_row[v]);
break;
}
}
}
}
companyid = d.companyid;
}
}, {
fixedcol: true,
fixedcolnum:2
});
}
else {
tb.bootstrapTable('refresh', { url: url });
}
}
function listAccount() {
$.submit({
url: '@Url.Content("~/Reports/Orders/ListPaypalAccount")',
type:'POST',
paramData: '',
func: function (result) {
if (result != null && result != undefined) {
$('#account').html('<option value="">选择Paypal帐号</option>');
for (var i = 0; i < result.length; i++) {
$('#account').append('<option value="' + result[i] + '">' + result[i]+'</option>');
}
}
}
})
}
function exportlist() {
if (confirm("确定要导出吗?")) {
window.open('@Url.Content("~/Reports/Orders/ExportEbayOrders")' + '?' + $("#toolbar").serialize(), '_blank');
}
}
</script>
}
......@@ -375,6 +375,9 @@
<li>
<a class="J_menuItem" href="@Url.Content("~/Reports/Finance/ListEbayIncome")" data-index="0">Paypal收入流水</a>
</li>
<li>
<a class="J_menuItem" href="@Url.Content("~/Reports/Finance/ListPaypalIncomeAnalyze")" data-index="0">Paypal分录信息</a>
</li>
</ul>
</li>
<li>
......
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