Commit 561e6555 by guanzhenshan

1、修改sku利润服务,昨日销售额没有取到的问题

2、完成sku利润报表
3、增加获取ebay广告费、上架费接口
parent 7b6ae24d
using System;
using System.Collections.Generic;
using System.Text;
namespace Bailun.DC.Models.Orders
{
public class mEbayFeeInput
{
public DateTime start { get; set; }
public DateTime end { get; set; }
public int type { get; set; }
public int page { get; set; }
}
}
......@@ -2681,6 +2681,35 @@ namespace Bailun.DC.Services
}
/// <summary>
/// 获取Ebay的费用明细
/// </summary>
/// <param name="page"></param>
/// <param name="pagesize"></param>
/// <param name="start"></param>
/// <param name="end"></param>
/// <param name="feetype"></param>
/// <returns></returns>
public List<dc_base_finance_ebay> ListEbayFee(int page, int pagesize, DateTime start, DateTime end, string[] feetype)
{
var sqlparam = new DynamicParameters();
var sql = $"select account_entry_type,description,bj_date,gross_amount,item_id,account_id,currency,exchange_rate,company_id from dc_base_finance_ebay where bj_date>='{start.ToString("yyyy-MM-dd HH:mm:ss")}' and bj_date<'{end.ToString("yyyy-MM-dd HH:mm:ss")}' and account_entry_type in ('{string.Join("','",feetype)}') ";
var sqllimit = "limit " + (page - 1) * pagesize + "," + pagesize;
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{
if (cn.State == System.Data.ConnectionState.Closed)
{
cn.Open();
}
var list = cn.Query<dc_base_finance_ebay>(sql, null, null, true, 2 * 60);
return list.AsList();
}
}
/// <summary>
/// 获取Ebay的费用
/// </summary>
/// <param name="parameter"></param>
......@@ -2693,18 +2722,18 @@ namespace Bailun.DC.Services
public List<dc_base_finance_ebay> ListEbayFee(BtTableParameter parameter, int? companyid, DateTime? start, DateTime? end, ref int total, string[] feetype, string orderno,string account)
{
var sqlparam = new DynamicParameters();
var sql = "select t1.id,t1.account_entry_type,t1.description,t1.gmt_date,t1.gross_amount,t1.item_id,t1.net_amount,t1.vat_percent,t1.order_line_id,t1.currency,t1.exchange_rate,(t1.exchange_rate*t1.gross_amount) gross_amount_rmb,t2.account_name from dc_base_finance_ebay t1 ";
var sql = "select t1.id,t1.account_entry_type,t1.description,t1.bj_date as gmt_date,t1.gross_amount,t1.item_id,t1.net_amount,t1.vat_percent,t1.order_line_id,t1.currency,t1.exchange_rate,(t1.exchange_rate*t1.gross_amount) gross_amount_rmb,t2.account_name from dc_base_finance_ebay t1 ";
sql += " left join dc_base_company_account t2 on t1.company_id=t2.company_id and t1.account_id=t2.account_id ";
sql += " where 1=1 ";
if (start.HasValue)
{
sql += " and t1.gmt_date>=@start";
sql += " and t1.bj_date>=@start";
sqlparam.Add("start", start.Value);
}
if (end.HasValue)
{
sql += " and t1.gmt_date<@end";
sql += " and t1.bj_date<@end";
sqlparam.Add("end", end.Value);
}
......@@ -2788,12 +2817,12 @@ namespace Bailun.DC.Services
if (start.HasValue)
{
sql += " and t1.gmt_date>=@start";
sql += " and t1.bj_date>=@start";
sqlparam.Add("start", start.Value);
}
if (end.HasValue)
{
sql += " and t1.gmt_date<@end";
sql += " and t1.bj_date<@end";
sqlparam.Add("end", end.Value);
}
......
......@@ -67,9 +67,14 @@ namespace Bailun.DC.SkuProfitService
left join dc_mid_transit t4 on t.bailun_sku=t4.bailun_sku and t.warehouse_code=t4.warehouse_code"
,null,null,true,5*60);
//前一天销量
var list1day = cn.Query<Models.mSkuWarehouse>($@"select t1.bailun_sku,t1.warehouse_code,sum(t1.bailun_sku_quantity_ordered) count,sum(t1.profit_total) profit_total from dc_base_oms_sku t1
var list1day = cn.Query<Models.mSkuWarehouse>($@"select t.*,t2.unit_price,t2.category_id,t2.category_name,t3.usable_stock,t4.quantity_purchase,t4.quantity_transfer,t2.sku_title_cn from
(select t1.bailun_sku,t1.warehouse_code,t1.warehouse_name,sum(t1.bailun_sku_quantity_ordered) count,sum(t1.amount_sales*t1.bailun_sku_quantity_shipped*t1.seller_order_exchange_rate) amount,sum(t1.profit_total) profit_total from dc_base_oms_sku t1
where t1.bailun_order_status!='Canceled' and t1.has_delete=0 and t1.has_scalp=0 and t1.has_cancle=0 and t1.paid_time>='{end.AddDays(-1).ToString("yyyy-MM-dd")}' and paid_time<'{end.ToString("yyyy-MM-dd")}' and t1.warehouse_code!='' and t1.company_id=1
group by t1.bailun_sku,t1.warehouse_code", null, null, true, 5 * 60);
group by t1.bailun_sku,t1.warehouse_code) t
left join dc_base_sku t2 on t.bailun_sku=t2.bailun_sku
left join dc_base_stock t3 on t.bailun_sku=t3.bailun_sku and t.warehouse_code=t3.warehouse_code
left join dc_mid_transit t4 on t.bailun_sku=t4.bailun_sku and t.warehouse_code=t4.warehouse_code"
, null, null, true, 5 * 60);
//采购入库
var listPurchasePutin = cn.Query<Models.mPutIn>($@"select bailun_sku,warehouse_code,sum(count) count from dc_base_purchase_inbound where update_time>='{start.ToString("yyyy-MM-dd")}'and update_time<'{end.ToString("yyyy-MM-dd")}' and status=1 and bailun_sku in ('{string.Join("','", list30day.Select(a=>a.bailun_sku).Distinct())}')
group by bailun_sku,warehouse_code", null, null, true, 5 * 60);
......
......@@ -460,6 +460,8 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
if (t == 2) //按付款主体
{
var gogirlindex = -1; //广州歌戈儿生活科技有限公司
var gogirlindexarr = new List<int>(); //广州歌戈儿 相关付款主体
var clothindex = -1;
for (var i = 0; i<listCol.Count; i++)
{
......@@ -472,6 +474,15 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
{
index_Interest = i;
}
if (listCol[i] == "广州歌戈儿生活科技有限公司")
{
gogirlindex = i;
}
else if (listCol[i].Contains("歌戈儿"))
{
gogirlindexarr.Add(i);
}
}
//广州电子服装仓
......@@ -539,6 +550,74 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
obj.Item2[index_Interest] = gzblVal;
}
//Add by Allan at 201907091500
//合并广州歌戈儿相关付款主体到 广州歌戈儿生活科技有限公司
if (gogirlindexarr.Count > 0)
{
//降序排序,方便下面的删除操作,从数据后面开始删除
gogirlindexarr = gogirlindexarr.OrderByDescending(a => a).ToList();
if (gogirlindex > -1)
{
//附加数据到 广州歌戈儿生活科技有限公司
foreach (var item in listValue)
{
foreach (var index in gogirlindexarr)
{
item.Item2[gogirlindex] += item.Item2[index];
}
}
//按索引删除 值集合里面的值
foreach (var item in listValue)
{
foreach (var index in gogirlindexarr)
{
item.Item2.RemoveAt(index);
}
}
//按索引删除 列头
foreach (var index in gogirlindexarr)
{
listCol.RemoveAt(index);
}
}
else
{
listCol.Add("广州歌戈儿生活科技有限公司");
//增加一列
foreach (var item in listValue)
{
item.Item2.Add(0);
}
foreach (var index in gogirlindexarr)
{
foreach (var item in listValue)
{
item.Item2[item.Item2.Count-1]+=item.Item2[index];
}
}
//按索引删除 值集合里面的值
foreach (var item in listValue)
{
foreach (var index in gogirlindexarr)
{
item.Item2.RemoveAt(index);
}
}
//按索引删除 列头
foreach (var index in gogirlindexarr)
{
listCol.RemoveAt(index);
}
}
}
//End Add
}
else //按部门
{
......
......@@ -71,41 +71,42 @@
$("#roletable").attr("data-height", (height - 160));
list();
listwarehouse();
listcategory12();
})
function list() {
var columns = [
{ field: 'warehouse_code', title: '仓库名称', width: '100', sortable: false },
{ field: 'bailun_sku', title: 'sku', width: '80', sortable: false, iscount: true },
{ field: 'category_name', title: '品类', width: '100', sortable: true, iscount: true },
{ field: 'yd_sales_amount', title: '在库总数', width: '100', sortable: true, iscount: true },
{ field: 'cost_product', title: '采购在途数', width: '100', sortable: true, iscount: true },
{ field: 'cost_platform_fee', title: '采购在途金额', width: '110', sortable: true, iscount: true },
{ field: 'cost_paypal_fee', title: '调拨在途数', width: '110', sortable: true, iscount: true },
{ field: 'cost_first', title: '调拨在途金额', width: '100', sortable: true, iscount: true },
{ field: 'cost_tail', title: '昨日销售额', width: '100', sortable: true, iscount: true },
{ field: 'cost_handle_bailun', title: '昨日销售数量', width: '100', sortable: true, iscount: true },
{ field: 'loss_withdrawal', title: '昨日销售库存额', width: '100', sortable: false, iscount: true },
{ field: 'cost_total', title: '昨日销售毛利额', width: '110', sortable: true, iscount: true },
{ field: 'amount_refund', title: '昨日成本毛利率', width: '110', sortable: true, iscount: true },
{ field: 'amount_prepaid', title: '30天销售额', width: '120', sortable: true, iscount: true },
{ field: 'noshippingcount', title: '30天销售数量', width: '120', sortable: true, iscount: true},
{ field: 'profit_total', title: '30天销售库存额', width: '120', sortable: true, iscount: true },
{ field: 'profit_rate', title: '30天毛利额', width: '130', sortable: true, iscount: true },
{ field: 'profit_rate', title: '30天成本毛利率', width: '130', sortable: true, iscount: true },
{ field: 'profit_rate', title: '退货率', width: '130', sortable: true, iscount: true },
{ field: 'profit_rate', title: '30天金额库存周转率', width: '130', sortable: true, iscount: true },
{ field: 'profit_rate', title: '30天累积入库金额', width: '130', sortable: true, iscount: true },
{ field: 'profit_rate', title: '30天金额销进比', width: '130', sortable: true, iscount: true },
{ field: 'profit_rate', title: '30天件数库存周转率', width: '130', sortable: true, iscount: true },
{ field: 'profit_rate', title: '30天累积入库数', width: '130', sortable: true, iscount: true },
{ field: 'profit_rate', title: '30天件数销进比', width: '130', sortable: true, iscount: true },
{ field: 'profit_rate', title: '30天金额可售天数', width: '130', sortable: true, iscount: true },
{ field: 'profit_rate', title: '30天件数可售天数', width: '130', sortable: true, iscount: true },
{ field: 'warehouse_name', title: '仓库名称', width: '170', sortable: false },
//{ field: 'bailun_sku', title: 'sku', width: '80', sortable: false, iscount: true },
//{ field: 'category_name', title: '品类', width: '100', sortable: true, iscount: true },
{ field: 'usable_stock', title: '在库库存', width: '100', sortable: true, iscount: true },
{ field: 'usable_stock_amount', title: '在库金额', width: '100', sortable: true, iscount: true },
{ field: 'quantity_purchase', title: '采购在途数', width: '120', sortable: true, iscount: true },
{ field: 'quantity_purchase_amount', title: '采购在途金额', width: '130', sortable: true, iscount: true },
{ field: 'quantity_transfer', title: '调拨在途数', width: '120', sortable: true, iscount: true },
{ field: 'quantity_transfer_amount', title: '调拨在途金额', width: '130', sortable: true, iscount: true },
{ field: 'yd_sales_amount', title: '昨日销售额', width: '120', sortable: true, iscount: true },
{ field: 'yd_sales_count', title: '昨日销售数量', width: '130', sortable: true, iscount: true },
{ field: 'yd_sales_stockamount', title: '昨日销售库存额', width: '130', sortable: false, iscount: true },
{ field: 'yd_grossprofit', title: '昨日销售毛利额', width: '130', sortable: true, iscount: true },
{ field: 'yd_grossprofit_rate', title: '昨日成本毛利率', width: '130', sortable: true, iscount: true },
{ field: 'pre30_sales_amount', title: '30天销售额', width: '120', sortable: true, iscount: true },
{ field: 'pre30_sales_count', title: '30天销售数量', width: '120', sortable: true, iscount: true},
{ field: 'pre30_stockamount', title: '30天销售库存额', width: '140', sortable: true, iscount: true },
{ field: 'pre30_grossprofit', title: '30天毛利额', width: '130', sortable: true, iscount: true },
{ field: 'pre30_grossprofit_rate', title: '30天成本毛利率', width: '140', sortable: true, iscount: true },
{ field: 'pre30_return_rate', title: '退货率', width: '100', sortable: true, iscount: true },
{ field: 'pre30_stockamount_turn_rate', title: '30天金额库存周转率', width: '160', sortable: true, iscount: true },
{ field: 'pre30_stockamount_add', title: '30天累积入库金额', width: '150', sortable: true, iscount: true },
{ field: 'pre30_stockamount__rate', title: '30天金额销进比', width: '150', sortable: true, iscount: true },
{ field: 'pre30_stocknum_turn_rate', title: '30天件数库存周转率', width: '160', sortable: true, iscount: true },
{ field: 'pre30_stock_add_count', title: '30天累积入库数', width: '150', sortable: true, iscount: true },
{ field: 'pre30_stocknum_rate', title: '30天件数销进比', width: '150', sortable: true, iscount: true },
{ field: 'pre30_stockamount_vendibility_day', title: '30天金额可售天数', width: '150', sortable: true, iscount: true },
{ field: 'pre30_stocknum_vendibility_day', title: '30天件数可售天数', width: '150', sortable: true, iscount: true },
];
var s = '';
......@@ -116,7 +117,7 @@
s = '';
}
var url = '@Url.Content("~/Reports/Orders/StatisticsByWebsiteJson")' + '?' + $("#toolbar").serialize() + '&skucategoryids=' + s;
var url = '@Url.Content("~/Reports/Warehouse/ListWarehouseProfitJson")' + '?' + $("#toolbar").serialize() + '&skucategoryids=' + s;
if (tb == undefined) {
tb = OnlyTable("roletable", columns, url, "", { showfooter: true, showCount: true });
......@@ -126,7 +127,7 @@
}
}
function listwarehousetype() {
$.submit({
url: '@Url.Content("~/Home/ListWarehouseType")',
......@@ -206,7 +207,7 @@
return s;
}
</script>
......
......@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Bailun.DC.Models.Orders;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
......@@ -245,10 +246,87 @@ namespace Bailun.DC.Web.Controllers
msg = "",
list = list
});
}
/// <summary>
/// 获取ebay费用
/// </summary>
/// <param name="start">开始时间</param>
/// <param name="end">结束时间</param>
/// <param name="type">费用类型,1:上架费,2:广告费</param>
/// <param name="page">当前页</param>
/// <param name="companyid">所属公司</param>
/// <returns></returns>
[HttpPost]
public JsonResult ListEbayFee([FromBody]mEbayFeeInput m)
{
try
{
var pagesize = 1000;
var arrtype = new List<string>();
}
if (m.type == 1) //上架费
{
arrtype = new List<string> { "BuyItNowFee",
"CreditAuctionEndEarly",
"CreditCardOnFile",
"CreditInsertion",
"ExtendedDurationFee",
"FeeAuctionEndEarly",
"FeeBold",
"FeeGalleryPlus",
"FeeInsertion",
"FeeLargePicture",
"FeePicturePack",
"FeeReserve",
"FeeReturnShipping",
"PaymentCC",
"PaypalOnFile",
"PrivateListing",
"SubscriptionSMBasic",
"SubtitleFee"};
}
else if (m.type == 2) //广告费
{
arrtype = new List<string> {
"CustomCode",
"Unknown"
};
}
var obj = new Services.OrdersServices().ListEbayFee(m.page, pagesize, m.start, m.end, arrtype.ToArray());
var list = obj.Select(a => new {
a.account_entry_type,
a.description,
bj_date = a.bj_date.Value.ToString("yyyy-MM-dd HH:mm:ss"),
a.gross_amount,
a.item_id,
a.account_id,
a.currency,
a.exchange_rate,
a.company_id
});
return Json(new
{
success = true,
data = list,
msg = ""
});
}
catch (Exception ex)
{
return Json(new
{
success = false,
msg = "出现异常,异常信息:" + ex.Message
});
}
}
}
}
\ No newline at end of file
......@@ -300,6 +300,18 @@
</a>
</li>
<li>
<a class="J_menuItem" href="@Url.Content("~/Reports/WareHouse/ListWarehouseProfit")" data-index="0">
<i class="fa fa-money"></i>
<span>仓库利润统计</span>
</a>
</li>
<li>
<a class="J_menuItem" href="@Url.Content("~/Reports/WareHouse/ListSkuProfit")" data-index="0">
<i class="fa fa-money"></i>
<span>SKU利润统计</span>
</a>
</li>
<li>
<a class="J_menuItem" href="@Url.Content("~/Reports/Orders/ListReturn")" data-index="0">
<i class="fa fa-money"></i>
<span>平台退款流水</span>
......
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