Commit be62b04c by jianshuqin

平台利润增加Etsy广告费

parent cd3c6fff
...@@ -6755,6 +6755,40 @@ namespace Bailun.DC.Services ...@@ -6755,6 +6755,40 @@ namespace Bailun.DC.Services
#endregion #endregion
public decimal ADFee(string platform, DateTime? start, DateTime? end, bool isUSD)
{
var sqlparam = new DynamicParameters();
var sql = $" select round(sum({(isUSD ? "amount_usd" : "amount_cny")}),2) as fee from dc_base_profit_ad where 1 = 1";
if (!string.IsNullOrWhiteSpace(platform))
{
sql += " and platform = @platform";
sqlparam.Add("platform", platform);
}
if (start.HasValue)
{
sql += " and ad_time >= @ad_time";
sqlparam.Add("ad_time", start.Value);
}
if (end.HasValue)
{
sql += " and ad_time < @edate";
sqlparam.Add("edate", end.Value.AddDays(1));
}
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString_Data))
{
if (cn.State == System.Data.ConnectionState.Closed)
{
cn.Open();
}
var obj = cn.QueryFirstOrDefault<decimal?>(sql, sqlparam, null, 2 * 60) ?? 0;
return obj;
}
}
#endregion #endregion
#region Paypal #region Paypal
......
...@@ -1673,6 +1673,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -1673,6 +1673,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
var ebayPutAwayNew = new dc_base_ebay_transaction(); //Ebay 上架费 var ebayPutAwayNew = new dc_base_ebay_transaction(); //Ebay 上架费
decimal shopifyFee = 0; //Shopify 广告费 decimal shopifyFee = 0; //Shopify 广告费
decimal etsyFee = 0; //Etsy 广告费
var ADfeeTypeNew = new string[] { var ADfeeTypeNew = new string[] {
"AD_FEE","PREMIUM_AD_FEES" "AD_FEE","PREMIUM_AD_FEES"
...@@ -1865,6 +1866,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -1865,6 +1866,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
//End Add //End Add
shopifyFee = _service.ShopifyAD(dtstart, dtend, currency.ToUpper() == "USD"); shopifyFee = _service.ShopifyAD(dtstart, dtend, currency.ToUpper() == "USD");
etsyFee = _service.ADFee("Etsy", dtstart, dtend, currency.ToUpper() == "USD");
} }
else else
{ {
...@@ -1915,6 +1917,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -1915,6 +1917,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
//End Add //End Add
shopifyFee = _service.ShopifyAD(dtstart, dtend, currency.ToUpper() == "USD"); shopifyFee = _service.ShopifyAD(dtstart, dtend, currency.ToUpper() == "USD");
etsyFee = _service.ADFee("Etsy", dtstart, dtend, currency.ToUpper() == "USD");
} }
else else
{ {
...@@ -2097,6 +2100,12 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -2097,6 +2100,12 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
item.profit_total = (item.profit_total - item.adfee ?? 0); item.profit_total = (item.profit_total - item.adfee ?? 0);
item.profit_rate = (item.amount_sales - item.amount_prepaid) != 0 ? Math.Round((item.profit_total / (item.amount_sales - item.amount_prepaid)), 2) : 0; item.profit_rate = (item.amount_sales - item.amount_prepaid) != 0 ? Math.Round((item.profit_total / (item.amount_sales - item.amount_prepaid)), 2) : 0;
} }
else if (item.platform_type.ToLower() == "etsy") //Shopify广告费
{
item.adfee = etsyFee;
item.profit_total = (item.profit_total - item.adfee ?? 0);
item.profit_rate = (item.amount_sales - item.amount_prepaid) != 0 ? Math.Round((item.profit_total / (item.amount_sales - item.amount_prepaid)), 2) : 0;
}
} }
else if (statistictype == 1) else if (statistictype == 1)
{ {
......
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