84 lines
3.5 KiB
C#
84 lines
3.5 KiB
C#
using MyCode.Project.Domain.Message.Act.BaoDian;
|
|
using MyCode.Project.Infrastructure.Exceptions;
|
|
using MyCode.Project.Domain.Model;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using SqlSugar;
|
|
using MyCode.Project.Domain.Repositories;
|
|
|
|
namespace MyCode.Project.Services.BLL
|
|
{
|
|
public class BaoDianBLL
|
|
{
|
|
#region 初始化
|
|
private readonly IRepository _repository;
|
|
public BaoDianBLL(IRepository repository)
|
|
{
|
|
_repository = repository;
|
|
}
|
|
#endregion
|
|
|
|
#region CheckSaveProductSalesSchedules 判断产品销售计划的保存
|
|
/// <summary>
|
|
/// 判断产品销售计划的保存
|
|
/// </summary>
|
|
/// <param name="act"></param>
|
|
public void CheckSaveProductSalesSchedules(ProductSalesScheduleAct act)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(act.PackageName)) { throw new BaseException("套餐名称不能为空"); }
|
|
if (act.EffectType == 0) { throw new BaseException("请选择功效"); }
|
|
if (act.PackageType == 0) { throw new BaseException("请选择所属类型"); }
|
|
if ((act.SkuList == null || act.SkuList.Count == 0) && (act.ServiceList == null || act.ServiceList.Count == 0)) { throw new BaseException("至少选择一个商品或服务"); }
|
|
act.SkuList.ForEach(x => {
|
|
if (x.Qty <= 0) { throw new BaseException($"{x.Name}的数量不能少于等于0"); }
|
|
});
|
|
}
|
|
#endregion
|
|
|
|
#region CheckSaveNewMemberSalesSchedule 判断新客销售计划的保存
|
|
/// <summary>
|
|
/// 判断新客销售计划的保存
|
|
/// </summary>
|
|
/// <param name="act"></param>
|
|
public void CheckSaveNewMemberSalesSchedule(NewMemberSalesScheduleAct act)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(act.PackageName)) { throw new BaseException("套餐名称不能为空"); }
|
|
if ((act.SkuList == null || act.SkuList.Count == 0)&&(act.ServiceList==null||act.ServiceList.Count==0)) { throw new BaseException("至少选择一个商品或服务"); }
|
|
}
|
|
#endregion
|
|
|
|
#region GetProductCode 获取产品计划套餐编码
|
|
/// <summary>
|
|
/// 获取产品计划套餐编码
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public string GetProductCode()
|
|
{
|
|
var code = _repository.Queryable<LxmProductSalesSchedule>().OrderBy(p => p.CreateTime, OrderByType.Desc).Select(p => p.Code).First();
|
|
//新店铺编码+1
|
|
if (!string.IsNullOrWhiteSpace(code)) { int codeNum = Convert.ToInt32(code.Replace('C', ' ').Replace('P', ' ')); code = $"CP{codeNum + 1}"; }
|
|
if (string.IsNullOrWhiteSpace(code)) { code = $"CP10001"; }
|
|
return code;
|
|
}
|
|
#endregion
|
|
|
|
#region GetNewMemberCode 获取新客计划套餐编码
|
|
/// <summary>
|
|
/// 获取新客计划套餐编码
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public string GetNewMemberCode()
|
|
{
|
|
var code = _repository.Queryable<LxmNewMemberSalesSchedule>().OrderBy(p => p.CreateTime, OrderByType.Desc).Select(p => p.Code).First();
|
|
//新店铺编码+1
|
|
if (!string.IsNullOrWhiteSpace(code)) { int codeNum = Convert.ToInt32(code.Replace('X', ' ').Replace('K', ' ')); code = $"XK{codeNum + 1}"; }
|
|
if (string.IsNullOrWhiteSpace(code)) { code = $"XK10001"; }
|
|
return code;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|