Commit 4554fa9d authored by 吴春's avatar 吴春

提交代码

parent cfb7aaee
......@@ -3229,11 +3229,13 @@ namespace Mall.Module.Product
{
AllClist.Add(item.Id);
var TwoList = clist.Where(x => x.ParentId == item.Id).ToList();
if (TwoList.Any()) {
if (TwoList.Any())
{
AllClist.AddRange(TwoList.Select(x => x.Id).Distinct().ToList());
}
}
if (AllClist.Any()) {
if (AllClist.Any())
{
demodel.CategoryIds = string.Join(",", AllClist);
}
}
......@@ -3298,7 +3300,8 @@ namespace Mall.Module.Product
item.GoodsBuyNum = olist.Where(x => x.GoodsId == item.Id).FirstOrDefault()?.OrderNum ?? 0;
item.IsProcurement = 2;
item.ProcurementGoodsId = 0;
if (ProxyList.Where(x => x.GoodsId == item.Id).Any()) {
if (ProxyList.Where(x => x.GoodsId == item.Id).Any())
{
item.IsProcurement = 1;
item.ProcurementGoodsId = ProxyList.Where(x => x.GoodsId == item.Id).FirstOrDefault()?.GoodsId ?? 0;
}
......@@ -3411,7 +3414,8 @@ namespace Mall.Module.Product
{
//bool IsSyncProxy = false;
var goodsModel = new RB_Goods();
if (demodel.Id > 0) {
if (demodel.Id > 0)
{
goodsModel = goodsRepository.GetEntity(demodel.Id);
if (goodsModel == null)
{
......@@ -3429,9 +3433,11 @@ namespace Mall.Module.Product
{
return false;
}
if (goodsModel.IsCustomSpecification == 1) {
if (goodsModel.IsCustomSpecification == 1)
{
var splist = goods_SpecificationPriceRepository.GetList(new RB_Goods_SpecificationPrice_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
if (splist.Count() != demodel.SpecificationPriceList.Count() || splist.Count() != demodel.SpecificationPriceList.Where(x => splist.Select(y => y.SpecificationSort).Contains(x.SpecificationSort)).Count()) {
if (splist.Count() != demodel.SpecificationPriceList.Count() || splist.Count() != demodel.SpecificationPriceList.Where(x => splist.Select(y => y.SpecificationSort).Contains(x.SpecificationSort)).Count())
{
return false;
}
}
......@@ -3491,7 +3497,8 @@ namespace Mall.Module.Product
{ nameof(RB_Goods.ProxyRises),demodel.ProxyRises},
{ nameof(RB_Goods.ProxyMoney),demodel.ProxyMoney},
};
if (goodsModel.IsProcurement == 1) {
if (goodsModel.IsProcurement == 1)
{
//采购商品可修改
keyValues = new Dictionary<string, object>() {
{ nameof(RB_Goods.Name),demodel.Name},
......@@ -3754,7 +3761,8 @@ namespace Mall.Module.Product
}
}
}
else {
else
{
//只更新规格价格
var splist = goods_SpecificationPriceRepository.GetList(new RB_Goods_SpecificationPrice_Extend() { GoodsId = demodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
//价格新增/更新
......@@ -3994,13 +4002,15 @@ namespace Mall.Module.Product
}
};
bool flag2 = goodsRepository.Update(keyValues2, wheres2);
if (flag2) {
if (flag2)
{
//检测规格更新
if (demodel.IsCustomSpecification == 1)
{
}
else {
else
{
//删除规格
var slist = goods_SpecificationRepository.GetList(new RB_Goods_Specification_Extend() { GoodsId = item.Id, TenantId = item.TenantId, MallBaseId = item.MallBaseId });
var svlist = goods_SpecificationValueRepository.GetList(new RB_Goods_SpecificationValue_Extend() { GoodsId = item.Id, TenantId = item.TenantId, MallBaseId = item.MallBaseId });
......@@ -4745,7 +4755,15 @@ namespace Mall.Module.Product
/// <summary>
/// 获取列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Goods_Extend> GetGoodsList(RB_Goods_Extend dmodel)
{
return goodsRepository.GetList(dmodel);
}
#endregion
#region 商品代理
......@@ -4761,26 +4779,33 @@ namespace Mall.Module.Product
public ApiResult SetProductGoodsProxy(int goodsId, List<int> categoryList, int tenantId, int mallBaseId)
{
var plist = goods_ProxyRepository.GetList(new RB_Goods_Proxy_Extend() { GoodsId = goodsId, ProxyMallBaseId = mallBaseId, ProxyTenantId = tenantId });
if (plist.Any()) {
if (plist.Any())
{
return ApiResult.Failed("该商品已存在采购");
}
var goodsModel = goodsRepository.GetEntity(goodsId);
if (goodsModel == null) {
if (goodsModel == null)
{
return ApiResult.Failed("采购商品不存在");
}
if (goodsModel.GoodsStatus != 1) {
if (goodsModel.GoodsStatus != 1)
{
return ApiResult.Failed("该商品未上架,无法采购");
}
if (goodsModel.IsProxy != 1) {
if (goodsModel.IsProxy != 1)
{
return ApiResult.Failed("采购商品不可代理");
}
if (goodsModel.IsProcurement == 1) {
if (goodsModel.IsProcurement == 1)
{
return ApiResult.Failed("采购商品不可代理");
}
if (goodsModel.TenantId == tenantId) {
if (goodsModel.TenantId == tenantId)
{
return ApiResult.Failed("不可采购同商户商品");
}
if ((goodsModel.ProxyMoney ?? 0) <= 0) {
if ((goodsModel.ProxyMoney ?? 0) <= 0)
{
return ApiResult.Failed("采购商品有误");
}
......@@ -4860,7 +4885,8 @@ namespace Mall.Module.Product
Status = 0
}, trans);
//商品分类
foreach (var item in categoryList) {
foreach (var item in categoryList)
{
goods_CategoryRepository.Insert(new RB_Goods_Category()
{
CategoryId = item,
......@@ -4875,7 +4901,8 @@ namespace Mall.Module.Product
//复制规格
var slist = goods_SpecificationRepository.GetList(new RB_Goods_Specification_Extend() { GoodsId = goodsId });
var svlist = goods_SpecificationValueRepository.GetList(new RB_Goods_SpecificationValue_Extend() { GoodsId = goodsId });
foreach (var item in slist) {
foreach (var item in slist)
{
goods_SpecificationRepository.Insert(new RB_Goods_Specification()
{
EnabledImage = item.EnabledImage,
......@@ -4889,7 +4916,8 @@ namespace Mall.Module.Product
TenantId = tenantId
}, trans);
}
foreach (var item in svlist) {
foreach (var item in svlist)
{
goods_SpecificationValueRepository.Insert(new RB_Goods_SpecificationValue()
{
TenantId = tenantId,
......@@ -4934,10 +4962,12 @@ namespace Mall.Module.Product
{
plist = goods_ProxyRepository.GetList(new RB_Goods_Proxy_Extend() { GoodsId = goodsId, ProxyMallBaseId = mallBaseId, ProxyTenantId = tenantId });
}
else {
else
{
plist = goods_ProxyRepository.GetList(new RB_Goods_Proxy_Extend() { ProxyGoodsId = goodsId, ProxyMallBaseId = mallBaseId, ProxyTenantId = tenantId });
}
if (!plist.Any()) {
if (!plist.Any())
{
return false;
}
var pModel = plist.FirstOrDefault();
......@@ -4953,7 +4983,8 @@ namespace Mall.Module.Product
}
};
bool flag = goods_ProxyRepository.Update(keyValues, wheres);
if (flag) {
if (flag)
{
//删除商品
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Goods.Status),1},
......@@ -4986,10 +5017,12 @@ namespace Mall.Module.Product
{
return false;
}
if (goodsModel.IsProcurement != 1) {
if (goodsModel.IsProcurement != 1)
{
return false;
}
if (goodsModel.ProcurementStatus != 1) {
if (goodsModel.ProcurementStatus != 1)
{
return false;
}
int GoodsStatus = 1;
......@@ -5000,7 +5033,8 @@ namespace Mall.Module.Product
return false;
}
}
else {
else
{
if (goodsModel.GoodsStatus != 1)
{
return false;
......@@ -5573,5 +5607,21 @@ namespace Mall.Module.Product
}
#endregion
#region 分销商
/// <summary>
/// 获取列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Distributor_Info_Extend> GetDistributorInfoList(RB_Distributor_Info_Extend dmodel)
{
return distributor_InfoRepository.GetList(dmodel);
}
#endregion
}
}
......@@ -2,9 +2,11 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Google.Protobuf.WellKnownTypes;
using Mall.Common;
using Mall.Common.API;
using Mall.Common.Plugin;
using Mall.Model.Extend.Product;
using Mall.Model.Extend.User;
using Mall.Model.Query;
using Mall.Module.MarketingCenter;
......@@ -253,6 +255,92 @@ namespace Mall.WebApi.Controllers.AppletWeChat
}
}
/// <summary>
/// 获取商品
/// </summary>
/// <param name="requestMsg"></param>
/// <returns></returns>
[HttpPost]
[AllowAnonymous]
public ApiResult GetGoodsList(object requestMsg)
{
var requestParm = JsonConvert.DeserializeObject<RequestParm>(requestMsg.ToString());
var query = JsonConvert.DeserializeObject<RB_Goods_Extend>(requestParm.msg.ToString());
query.TenantId = requestParm.TenantId;
query.MallBaseId = requestParm.MallBaseId;
var oldLogisticsList = productModule.GetGoodsList(query).Take(15);
return ApiResult.Success("", oldLogisticsList);
}
/// <summary>
/// 获取分销商
/// </summary>
/// <param name="requestMsg"></param>
/// <returns></returns>
[HttpPost]
[AllowAnonymous]
public ApiResult GetDistributorInfoList(object requestMsg)
{
var requestParm = JsonConvert.DeserializeObject<RequestParm>(requestMsg.ToString());
var query = JsonConvert.DeserializeObject<RB_Distributor_Info_Extend>(requestParm.msg.ToString());
query.TenantId = requestParm.TenantId;
query.MallBaseId = requestParm.MallBaseId;
var oldLogisticsList = productModule.GetDistributorInfoList(query).Take(15);
return ApiResult.Success("", oldLogisticsList);
}
/// <summary>
/// 获取分销商
/// </summary>
/// <param name="requestMsg"></param>
/// <returns></returns>
[HttpPost]
[AllowAnonymous]
public ApiResult GetTotalOrderProfitLoss(object requestMsg)
{
var requestParm = JsonConvert.DeserializeObject<RequestParm>(requestMsg.ToString());
OrderStatistics_Query demodel = JsonConvert.DeserializeObject<OrderStatistics_Query>(requestParm.msg.ToString());
demodel.TenantId = requestParm.TenantId;
demodel.MallBaseId = requestParm.MallBaseId;
var list = statisticsModule.GetAllOrderProfitLossList(demodel);
foreach (var item in list)
{
item.ALLCommission = item.CostFreight + item.CostMoney + item.PackingMoney + item.GoodsFreight + item.OneCommission + item.TwoCommission + item.OtherPrice;
item.NoPaid = item.ALLCommission - item.Paid;
item.GrossProfit = item.AllPrice - item.ALLCommission;
item.GrossProfitRate = item.AllPrice == 0 ? 0 : Math.Round((item.GrossProfit / item.AllPrice), 2, MidpointRounding.AwayFromZero);
}
var retult = new
{
TotalFinal_Price = list.Sum(x => x.Final_Price),//结算款小计
TotalFreightMoney = list.Sum(x => string.IsNullOrWhiteSpace(x.FreightMoney) ? 0 : Convert.ToDecimal(x.FreightMoney)),//运费小计
TotalAllPrice = list.Sum(x => x.AllPrice),//已收小计
TotalNoAllPrice = list.Sum(x => 0),//未收小计
TotalPay = list.Sum(x => x.AllPrice),//合计小计
TotalCostMoney = list.Sum(x => x.CostMoney),//采购成本小计
TotalPackingMoney = list.Sum(x => x.PackingMoney),//包装费摊销小计
TotalCostFreight = list.Sum(x => x.CostFreight),//快递成本小计
TotalGoodsFreight = list.Sum(x => x.GoodsFreight),//商品运费小计
TotalBranchCommission = list.Sum(x => x.BranchCommission),//分公司小计
TotalGeneralAgentCommission = list.Sum(x => x.GeneralAgentCommission),//总代理小计
TotalSpecialCommission = list.Sum(x => x.SpecialCommission),//特一级小计
TotalOneCommission = list.Sum(x => x.OneCommission),//一级返佣小计
TotalOneTwoCommission = list.Sum(x => x.TwoCommission),//二级返佣小计
TotalOneOtherPrice = list.Sum(x => x.OtherPrice),//其他费用小计
TotalALLCommission = list.Sum(x => x.ALLCommission),//营业合计小计
TotalPaid = list.Sum(x => x.Paid),//已付小计
TotalNoPaid = list.Sum(x => x.NoPaid),//未付小计
TotalGrossProfit = list.Sum(x => x.GrossProfit),//毛利小计
};
return ApiResult.Success("", retult);
}
#endregion
}
}
\ No newline at end of file
......@@ -256,8 +256,8 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A
WBMoney = (result.Sum(x => x.FinanceType == 1 ? (x.Final_Price ?? 0) : (x.FreightMoney ?? 0))) - OriginalFee,
RB_Branch_Id = Config.IncomeBranchId,
RemitterName = item.RemitterName,
TradeDate = System.DateTime.Now.ToString("yyyy-MM-dd"),
AccountNumber = System.DateTime.Now.ToString("yyyyMMdd"),
TradeDate = System.DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"),
AccountNumber = System.DateTime.Now.AddDays(-1).ToString("yyyyMMdd"),
TemplateId = item.WorkFlowId,
OrderSource = 16,
Remark = System.DateTime.Now.ToString("yyyy年MM月dd日") + "自动生成财务单据",
......
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