Commit 4c1578c3 authored by liudong1993's avatar liudong1993

1

parent a69f23cc
......@@ -1320,95 +1320,6 @@ namespace Mall.Module.Product
item.Final_Price = gmodel.MemberPrice * (item.Number ?? 0);
#region 运费
decimal Express = 0;
if (defModel.Id > 0 && demodel.DeliveryMethod == OrderDeliveryMethodEnum.ExpressDistribution)
{
if (!((gmodel.FullNumPinkage > 0 && item.Number >= gmodel.FullNumPinkage) || (gmodel.FullMoneyPinkage > 0 && item.Final_Price >= gmodel.FullMoneyPinkage)))
{
int FreightId2 = gmodel.FreightId ?? 0;
if (gmodel.FreightId == 0)
{
FreightId2 = DefFreightId;
}
if (FreightId2 > 0)
{
var rulesModel = rulesList.Where(x => x.ID == FreightId2).FirstOrDefault();
List<Model.Extend.BaseSetUp.RB_Logistics_RulesPrice_Extend> priceList2 = priceList.Where(x => x.RulesId == FreightId2).ToList();
if (priceList2.Any())
{
var priceIds = priceList2.Select(x => x.ID).ToList();
var regionList2 = regionList.Where(x => priceIds.Contains(x.RulesPriceId)).ToList();
var regionModel = regionList2.Where(x => disList.Contains(x.RegionId)).FirstOrDefault();
if (regionModel != null)
{
var pmodel = priceList2.Where(x => x.ID == regionModel.RulesPriceId).FirstOrDefault();
if (pmodel != null && rulesModel != null)
{
if (rulesModel.ChargeMode == Common.Enum.MallBase.ChargeModeEnum.Num)
{
//按件计费
if (item.Number <= pmodel.First)
{
Express = pmodel.FirstPrice;
}
else
{
if (pmodel.Second > 0)
{
if (((item.Number ?? 0) - pmodel.First) % pmodel.Second == 0)
{
Express = pmodel.FirstPrice + (((item.Number ?? 0) - pmodel.First) / pmodel.Second) * pmodel.SecondPrice;
}
else
{
Express = pmodel.FirstPrice + (((item.Number ?? 0) - pmodel.First) / pmodel.Second + 1) * pmodel.SecondPrice;
}
}
else
{
Express = pmodel.FirstPrice;
}
}
}
else
{
//重量计费
int TotalW = (item.Number ?? 0) * GoodsWeight;
if (TotalW <= pmodel.First)
{
Express = pmodel.FirstPrice;
}
else
{
if (pmodel.Second > 0)
{
if ((TotalW - pmodel.First) % pmodel.Second == 0)
{
Express = pmodel.FirstPrice + ((TotalW - pmodel.First) / pmodel.Second) * pmodel.SecondPrice;
}
else
{
Express = pmodel.FirstPrice + ((TotalW - pmodel.First) / pmodel.Second + 1) * pmodel.SecondPrice;
}
}
else
{
Express = pmodel.FirstPrice;
}
}
}
}
}
}
}
}
}
TotalExpress += Express;
item.Final_Price += Express;
#endregion
#region 积分
if (umodel.Integral > 0 && gmodel.PointsDeduction > 0 && integralModel.IntegralNum > 0)
{
......@@ -1565,6 +1476,95 @@ namespace Mall.Module.Product
}
#endregion
#region 运费
decimal Express = 0;
if (defModel.Id > 0 && demodel.DeliveryMethod == OrderDeliveryMethodEnum.ExpressDistribution)
{
if (!((gmodel.FullNumPinkage > 0 && item.Number >= gmodel.FullNumPinkage) || (gmodel.FullMoneyPinkage > 0 && item.Final_Price >= gmodel.FullMoneyPinkage)))
{
int FreightId2 = gmodel.FreightId ?? 0;
if (gmodel.FreightId == 0)
{
FreightId2 = DefFreightId;
}
if (FreightId2 > 0)
{
var rulesModel = rulesList.Where(x => x.ID == FreightId2).FirstOrDefault();
List<Model.Extend.BaseSetUp.RB_Logistics_RulesPrice_Extend> priceList2 = priceList.Where(x => x.RulesId == FreightId2).ToList();
if (priceList2.Any())
{
var priceIds = priceList2.Select(x => x.ID).ToList();
var regionList2 = regionList.Where(x => priceIds.Contains(x.RulesPriceId)).ToList();
var regionModel = regionList2.Where(x => disList.Contains(x.RegionId)).FirstOrDefault();
if (regionModel != null)
{
var pmodel = priceList2.Where(x => x.ID == regionModel.RulesPriceId).FirstOrDefault();
if (pmodel != null && rulesModel != null)
{
if (rulesModel.ChargeMode == Common.Enum.MallBase.ChargeModeEnum.Num)
{
//按件计费
if (item.Number <= pmodel.First)
{
Express = pmodel.FirstPrice;
}
else
{
if (pmodel.Second > 0)
{
if (((item.Number ?? 0) - pmodel.First) % pmodel.Second == 0)
{
Express = pmodel.FirstPrice + (((item.Number ?? 0) - pmodel.First) / pmodel.Second) * pmodel.SecondPrice;
}
else
{
Express = pmodel.FirstPrice + (((item.Number ?? 0) - pmodel.First) / pmodel.Second + 1) * pmodel.SecondPrice;
}
}
else
{
Express = pmodel.FirstPrice;
}
}
}
else
{
//重量计费
int TotalW = (item.Number ?? 0) * GoodsWeight;
if (TotalW <= pmodel.First)
{
Express = pmodel.FirstPrice;
}
else
{
if (pmodel.Second > 0)
{
if ((TotalW - pmodel.First) % pmodel.Second == 0)
{
Express = pmodel.FirstPrice + ((TotalW - pmodel.First) / pmodel.Second) * pmodel.SecondPrice;
}
else
{
Express = pmodel.FirstPrice + ((TotalW - pmodel.First) / pmodel.Second + 1) * pmodel.SecondPrice;
}
}
else
{
Express = pmodel.FirstPrice;
}
}
}
}
}
}
}
}
}
TotalExpress += Express;
item.Final_Price += Express;
#endregion
Total_integral_price += (item.IntegralMoney ?? 0);
Total_use_integral += (item.IntegralNumber ?? 0);
TotalGoodsMoney += item.Final_Price ?? 0;
......
......@@ -3906,7 +3906,7 @@ namespace Mall.Module.Product
goodsRepository.Update(keyValues1, wheres1);
}
}
else if (goodsModel.IsProxy == 2 && demodel.IsProxy == 1 && demodel.GoodsStatus == 1)
else if ((goodsModel.IsProxy == 2 || goodsModel.IsProxy == 1) && demodel.IsProxy == 1 && demodel.GoodsStatus == 1)
{
//启用代理 检测是否有已代理的 同步数据 并采购商品状态
var plist = goods_ProxyRepository.GetList(new RB_Goods_Proxy_Extend() { GoodsId = demodel.Id, MallBaseId = goodsModel.MallBaseId, TenantId = goodsModel.TenantId });
......@@ -3924,6 +3924,7 @@ namespace Mall.Module.Product
{ nameof(RB_Goods.IsGoodsNegotiable),demodel.IsGoodsNegotiable},
{ nameof(RB_Goods.GoodsNumbers),demodel.GoodsNumbers},
{ nameof(RB_Goods.GoodsWeight),demodel.GoodsWeight},
{ nameof(RB_Goods.ProcurementStatus),1},
{ nameof(RB_Goods.UpdateDate),demodel.UpdateDate}
};
List<WhereHelper> wheres2 = new List<WhereHelper>() {
......@@ -3942,15 +3943,16 @@ namespace Mall.Module.Product
}
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 });
var splist = goods_SpecificationPriceRepository.GetList(new RB_Goods_SpecificationPrice_Extend() { GoodsId = item.Id, TenantId = item.TenantId, MallBaseId = item.MallBaseId });
//删除
goods_SpecificationRepository.DeleteBatch(slist);
goods_SpecificationValueRepository.DeleteBatch(svlist);
goods_SpecificationPriceRepository.DeleteBatch(splist);
}
}
}
else if (goodsModel.IsProxy == 1 && demodel.IsProxy == 1 && demodel.GoodsStatus == 1)
{
//修改所有采购商品 成本价格 规格
}
#endregion
}
......@@ -4704,6 +4706,9 @@ namespace Mall.Module.Product
if (goodsModel == null) {
return ApiResult.Failed("采购商品不存在");
}
if (goodsModel.GoodsStatus != 1) {
return ApiResult.Failed("该商品未上架,无法采购");
}
if (goodsModel.IsProxy != 1) {
return ApiResult.Failed("采购商品不可代理");
}
......@@ -4779,6 +4784,19 @@ namespace Mall.Module.Product
}, trans);
if (Id > 0)
{
goods_ProxyRepository.Insert(new RB_Goods_Proxy()
{
CreateDate = DateTime.Now,
GoodsId = goodsId,
Id = 0,
MallBaseId = goodsModel.MallBaseId,
TenantId = goodsModel.TenantId,
ProxyGoodsId = Id,
ProxyMallBaseId = mallBaseId,
ProxyTenantId = tenantId,
Remark = "新增采购",
Status = 0
}, trans);
//商品分类
foreach (var item in categoryList) {
goods_CategoryRepository.Insert(new RB_Goods_Category()
......@@ -4891,6 +4909,65 @@ namespace Mall.Module.Product
return flag;
}
/// <summary>
/// 设置采购商品上下架
/// </summary>
/// <param name="goodsId"></param>
/// <param name="type">类型 1上架 2下架</param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public bool SetGoodsProxyStatus(int goodsId, int type, int tenantId, int mallBaseId)
{
var goodsModel = goodsRepository.GetEntity(goodsId);
if (goodsModel == null)
{
return false;
}
if (goodsModel.IsProcurement != 1) {
return false;
}
if (goodsModel.ProcurementStatus != 1) {
return false;
}
int GoodsStatus = 1;
if (type == 1)
{
if (goodsModel.GoodsStatus != 2)
{
return false;
}
}
else {
if (goodsModel.GoodsStatus != 1)
{
return false;
}
GoodsStatus = 2;
}
var pModel = goods_ProxyRepository.GetList(new RB_Goods_Proxy_Extend() { ProxyGoodsId = goodsId, ProxyMallBaseId = mallBaseId, ProxyTenantId = tenantId }).FirstOrDefault();
if (pModel == null) { return false; }
var gModel = goodsRepository.GetEntity(pModel.GoodsId);
if (gModel == null) { return false; }
if (gModel.GoodsStatus == 1 && gModel.IsProxy == 1)
{
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Goods.GoodsStatus),GoodsStatus},
{ nameof(RB_Goods.UpdateDate),DateTime.Now}
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods.Id),
FiledValue=goodsModel.Id,
OperatorEnum=OperatorEnum.Equal
}
};
return goodsRepository.Update(keyValues1, wheres1);
}
return false;
}
#endregion
#region 商品导入
......
......@@ -1984,6 +1984,7 @@ namespace Mall.WebApi.Controllers.MallBase
//demodel.MallBaseId = parms.MallBaseId;
demodel.IsProxy = 1;
demodel.IsProcurement = 2;
demodel.GoodsStatus = 1;
var list = productModule.GetProductGoodsProxyPageList(pagelist.pageIndex, pagelist.pageSize, out long count, demodel);
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list.Select(x => new
......@@ -2020,7 +2021,8 @@ namespace Mall.WebApi.Controllers.MallBase
if (GoodsId <= 0) {
return ApiResult.ParamIsNull("请传递商品id");
}
if (string.IsNullOrEmpty(CategoryStr)) {
if (string.IsNullOrEmpty(CategoryStr) || CategoryStr == "[]")
{
return ApiResult.ParamIsNull("请选择分类");
}
List<int> CategoryList = JsonConvert.DeserializeObject<List<int>>(CategoryStr);
......@@ -2054,6 +2056,32 @@ namespace Mall.WebApi.Controllers.MallBase
}
}
/// <summary>
/// 采购商品上下架
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetGoodsProxyStatus() {
var req = RequestParm;
JObject parms = JObject.Parse(req.msg.ToString());
int GoodsId = parms.GetInt("GoodsId", 0);
int Type = parms.GetInt("Type", 1);//类型 1上架 2下架
if (GoodsId <= 0)
{
return ApiResult.ParamIsNull("请传递商品id");
}
bool flag = productModule.SetGoodsProxyStatus(GoodsId, Type, req.TenantId, req.MallBaseId);
if (flag)
{
return ApiResult.Success();
}
else
{
return ApiResult.Failed();
}
}
#endregion
#region 商品导入
......
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