Commit c149eb68 by guanzhenshan

平台利润统计报表增加ebay新接口获取到的ebay费

parent 2be67c7f
using System;
using System.Collections.Generic;
using System.Text;
namespace Bailun.DC.Models
{
public class dc_base_ebay_transaction
{
/// <summary>
///
/// </summary>
public double id { get; set; }
/// <summary>
///
/// </summary>
public string transaction_id { get; set; }
/// <summary>
///
/// </summary>
public string payout_id { get; set; }
/// <summary>
///
/// </summary>
public string sales_record_reference { get; set; }
/// <summary>
/// 买家名称
/// </summary>
public string username { get; set; }
/// <summary>
///
/// </summary>
public string transaction_type { get; set; }
/// <summary>
/// 费用金额
/// </summary>
public decimal value { get; set; }
/// <summary>
/// 费用rmb金额
/// </summary>
public decimal value_rmb { get; set; }
/// <summary>
/// 费用金额对应货币单位
/// </summary>
public string currency { get; set; }
/// <summary>
///
/// </summary>
public string booking_entry { get; set; }
/// <summary>
///
/// </summary>
public DateTime transaction_date { get; set; }
/// <summary>
///
/// </summary>
public string transaction_status { get; set; }
/// <summary>
///
/// </summary>
public string payments_entity { get; set; }
/// <summary>
///
/// </summary>
public string item_id { get; set; }
/// <summary>
///
/// </summary>
public string references_json { get; set; }
/// <summary>
///
/// </summary>
public string transaction_memo { get; set; }
/// <summary>
/// 费用类型
/// </summary>
public string fee_type { get; set; }
/// <summary>
///
/// </summary>
public string order_id { get; set; }
/// <summary>
/// YYYY-MM-DD
/// </summary>
public DateTime? transaction_date_short { get; set; }
/// <summary>
/// pams账号ID
/// </summary>
public int account_id { get; set; }
/// <summary>
/// 数据中心创建时间
/// </summary>
public DateTime bj_create { get; set; }
/// <summary>
/// 北京时间
/// </summary>
public DateTime transaction_date_bj { get; set; }
/// <summary>
/// 转人民币汇率,根据bj_date取值
/// </summary>
public decimal exchange_rate { get; set; }
/// <summary>
/// 转美元汇率
/// </summary>
public decimal exchange_rate_usd { get; set; }
}
}
......@@ -3695,6 +3695,104 @@ namespace Bailun.DC.Services
}
}
/// <summary>
/// ebay费 新接口
/// </summary>
/// <param name="companyid"></param>
/// <param name="start"></param>
/// <param name="end"></param>
/// <param name="feetype"></param>
/// <param name="description"></param>
/// <param name="orderno"></param>
/// <param name="account"></param>
/// <param name="isUSD"></param>
/// <param name="itemid"></param>
/// <param name="producttype"></param>
/// <param name="skusource"></param>
/// <param name="shippingstrategy"></param>
/// <param name="statistictype"></param>
/// <param name="platform"></param>
/// <param name="website"></param>
/// <returns></returns>
public dc_base_ebay_transaction EbayADFeeNew(int? companyid, DateTime? start, DateTime? end, string[] feetype, string[] description, string orderno, string account, bool isUSD, string itemid, int[] producttype, int? skusource, int? shippingstrategy, string platform, string website)
{
if (platform != null && platform.ToLower() != "ebay")
{
return new dc_base_ebay_transaction();
}
var sqlparam = new DynamicParameters();
var sql = $"select sum(if(booking_entry='CREDIT',-t1.value,t1.value)) value,sum(t1.{(isUSD ? "exchange_rate_usd" : "exchange_rate")}*(if(booking_entry='CREDIT',-t1.value,t1.value))) value_rmb from dc_base_ebay_transaction t1 ";
if (!string.IsNullOrWhiteSpace(account))
{
sql += " join dc_base_company_account t2 on t1.account_id=t2.account_id ";
sql += " and t2.account_name=@account_name ";
sqlparam.Add("account_name", account);
}
if ((producttype != null && producttype.Count() > 0) || skusource.HasValue || shippingstrategy.HasValue)
{
}
if (!string.IsNullOrEmpty(website))
{
sql += " join dc_base_company_account t20 on t20.account_id = t1.account_id and t20.company_id=1 and t20.status=1 and t20.site_en='" + website + "'";
}
sql += " where 1=1";
if (start.HasValue)
{
sql += " and t1.transaction_date_bj>=@start";
sqlparam.Add("start", start.Value);
}
if (end.HasValue)
{
sql += " and t1.transaction_date_bj<@end";
sqlparam.Add("end", end.Value.AddDays(1));
}
//if (companyid.HasValue && companyid.Value > 0)
//{
// sql += " and t1.company_id=@companyid";
// sqlparam.Add("companyid", companyid.Value);
//}
//if (!string.IsNullOrEmpty(orderno))
//{
// sql += " and t1.order_line_id=@orderno";
// sqlparam.Add("orderno", orderno);
//}
if (!string.IsNullOrWhiteSpace(itemid))
{
sql += " and t1.item_id=@item_id";
sqlparam.Add("item_id", itemid);
}
if (feetype != null && feetype.Length > 0)
{
sql += " and t1.fee_type in ('" + string.Join("','", feetype) + "')";
}
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString_read))
{
if (cn.State == System.Data.ConnectionState.Closed)
{
cn.Open();
}
var obj = cn.QueryFirstOrDefault<dc_base_ebay_transaction>(sql, sqlparam);
return obj;
}
}
/// <summary>
/// 获取汇损费用列表
......
......@@ -1642,6 +1642,17 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
var wishAD = new dc_base_finance_wish();
var aliexpressAD = new dc_base_finance_aliexpress();
//Add by Allan at 20210608 for Ebay 新接口
var ebayADFeeNew = new dc_base_ebay_transaction(); //Ebay 新广告费
var ebayPutAwayNew = new dc_base_ebay_transaction(); //Ebay 上架费
var ADfeeTypeNew = new string[] {
"AD_FEE"
};
var PutAwayFeeTypeNew = new string[] {
"INSERTION_FEE","SUBTITLE_FEE"
};
//End Add
var listebayADFee = new List<dc_base_finance_ebay>();
var listebayPutAway = new List<dc_base_finance_ebay>();
......@@ -1655,6 +1666,8 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
"BuyItNowFee","CreditInsertion","FeeGalleryPlus","PrivateListing","SubscriptioneBayStores","SubscriptionSMBasic","SubscriptionSMBasicPro","SubtitleFee"
};
var ADfeeDescription = new string[] { "廣告費", "Ad fee" };
var PutAwayFeeDescript = new string[] {
"Gallery Plus Fee","Insertion Fee","不公開出價者刊登費","副標題功能費","特大圖片瀏覽費用","物品刊登費","一口價刊登費","粗體字刊登費用","提早結束拍賣物品的費用"
......@@ -1813,6 +1826,12 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
aliexpressAD = _service.ListAliexpressADCount(companyid, "", dtstart, dtend, currency.ToUpper() == "USD");
wishAD = _service.ListWishADCount(companyid, null, dtstart, dtend, currency.ToUpper() == "USD");
//Add by Allan at 20210608 for ebay费新接口
ebayADFeeNew = _service.EbayADFeeNew(companyid, dtstart, dtend, ADfeeTypeNew, null, "", "", currency.ToUpper() == "USD", "", producttype, skusource, shippingstrategy, platform, website);
ebayPutAwayNew = _service.EbayADFeeNew(companyid, dtstart, dtend, PutAwayFeeTypeNew, null, "", "", currency.ToUpper() == "USD", "", producttype, skusource, shippingstrategy, platform, website);
//End Add
}
else
{
......@@ -1857,6 +1876,11 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
amazonAD = _service.ListAmazonADSkuCount("", dtstart, dtend, companyid, currency.ToUpper() == "USD", null, null, null,platform,website,null);
wishAD = _service.ListWishADCount(companyid, null, dtstart, dtend, currency.ToUpper() == "USD");
aliexpressAD = _service.ListAliexpressADCount(companyid, "", dtstart, dtend, currency.ToUpper() == "USD");
//Add by Allan at 20210608 for ebay费新接口
ebayADFeeNew = _service.EbayADFeeNew(companyid, dtstart, dtend, ADfeeTypeNew, null, "", "", currency.ToUpper() == "USD", "", producttype, skusource, shippingstrategy, platform, website);
ebayPutAwayNew = _service.EbayADFeeNew(companyid, dtstart, dtend, PutAwayFeeTypeNew, null, "", "", currency.ToUpper() == "USD", "", producttype, skusource, shippingstrategy, platform, website);
//End Add
}
else
{
......@@ -1999,8 +2023,8 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
//End Add
item.adfee = ebayADFee != null ? ebayADFee.gross_amount_rmb : 0;
item.putawayfee = ebayPutAway != null ? ebayPutAway.gross_amount_rmb : 0;
item.adfee = (ebayADFee != null ? ebayADFee.gross_amount_rmb : 0)+(ebayADFeeNew!=null?ebayADFeeNew.value_rmb:0);
item.putawayfee = (ebayPutAway != null ? ebayPutAway.gross_amount_rmb : 0)+ (ebayPutAwayNew != null ? ebayPutAwayNew.value_rmb : 0);
item.profit_total = (item.profit_total - (item.adfee ?? 0) - (item.putawayfee ?? 0));
item.profit_rate = item.amount_sales != 0 ? Math.Round((item.profit_total / item.amount_sales), 2) : 0;
......@@ -2087,34 +2111,34 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
}
//判断数据是否包含Etsy平台
var hasEtsy = result.Where(a => a.platform_type == "Etsy").FirstOrDefault();
if (hasEtsy == null)
{
var m = new Models.Orders.dc_base_oms_sku
{
platform_type = "Etsy",
order_count = 0,
amount_sales = 0,
customerprice = 0,
cost_platform_fee = 0,
profit_total =0 ,
profit_rate = 0,
amount_refund = 0,
amount_refund_rate = 0,
cost_first = 0,
cost_handle_bailun = 0,
cost_handle_platform = 0,
cost_tail = 0,
amount_prepaid = 0,
cost_product = 0,
noshippingcount = 0,
cost_fba_fee = 0,
cost_paypal_fee = 0,
adfee = 0,
putawayfee = 0
};
result.Add(m);
}
//var hasEtsy = result.Where(a => a.platform_type == "Etsy").FirstOrDefault();
//if (hasEtsy == null)
//{
// var m = new Models.Orders.dc_base_oms_sku
// {
// platform_type = "Etsy",
// order_count = 0,
// amount_sales = 0,
// customerprice = 0,
// cost_platform_fee = 0,
// profit_total =0 ,
// profit_rate = 0,
// amount_refund = 0,
// amount_refund_rate = 0,
// cost_first = 0,
// cost_handle_bailun = 0,
// cost_handle_platform = 0,
// cost_tail = 0,
// amount_prepaid = 0,
// cost_product = 0,
// noshippingcount = 0,
// cost_fba_fee = 0,
// cost_paypal_fee = 0,
// adfee = 0,
// putawayfee = 0
// };
// result.Add(m);
//}
if (result.Count > 0)
......
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