You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.3 KiB
35 lines
1.3 KiB
using SiNan.Common.Log;
|
|
using SiNan.Common.Models;
|
|
using SiNan.Model.Db;
|
|
using SiNan.Model.Dto;
|
|
using Yitter.IdGenerator;
|
|
|
|
namespace SiNan.Business
|
|
{
|
|
public class ProductBusiness : BaseBusiness, IDenpendency
|
|
{
|
|
public ProductBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator) : base(fsql, nLogManager, idGenerator)
|
|
{
|
|
|
|
}
|
|
|
|
public void SetMaxDeficitThreshold(SetMaxDeficitThresholdRequest request)
|
|
{
|
|
var _temp = fsql.Select<ProductSku>(request.Sku).ToOne();
|
|
if (_temp == null)
|
|
throw new BusinessException("未查询到sku");
|
|
var productSkuList = fsql.Select<ProductSku>().Where(ps => ps.ProductId == _temp.ProductId).ToList();
|
|
|
|
var productSku = productSkuList.FirstOrDefault(ps => ps.Id == request.Sku);
|
|
productSku.MaxDeficitThreshold = request.MaxDeficitThreshold;
|
|
|
|
var spuMaxDeficitThreshold = productSkuList.Sum(ps => ps.MaxDeficitThreshold);
|
|
|
|
fsql.Transaction(() =>
|
|
{
|
|
fsql.Update<Product>(_temp.ProductId).Set(p => p.MaxDeficitThreshold, spuMaxDeficitThreshold).ExecuteAffrows();
|
|
fsql.Update<ProductSku>(request.Sku).Set(p => p.MaxDeficitThreshold, spuMaxDeficitThreshold).ExecuteAffrows();
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|