Commit 5af8ff51 authored by liudong1993's avatar liudong1993

下单

parent 1747dd22
...@@ -61,6 +61,11 @@ namespace Mall.Common.Enum.Goods ...@@ -61,6 +61,11 @@ namespace Mall.Common.Enum.Goods
/// 商品预售 /// 商品预售
/// </summary> /// </summary>
[EnumField("商品预售")] [EnumField("商品预售")]
GoodsToBooking = 10 GoodsToBooking = 10,
/// <summary>
/// 司导商品
/// </summary>
[EnumField("司导商品")]
SDGoods = 11
} }
} }
...@@ -23,5 +23,9 @@ namespace Mall.Model.Extend.Product ...@@ -23,5 +23,9 @@ namespace Mall.Model.Extend.Product
/// 日期 /// 日期
/// </summary> /// </summary>
public string DateTime { get; set; } public string DateTime { get; set; }
/// <summary>
/// 月份
/// </summary>
public string Month { get; set; }
} }
} }
...@@ -1767,7 +1767,6 @@ namespace Mall.Module.Product ...@@ -1767,7 +1767,6 @@ namespace Mall.Module.Product
#endregion #endregion
} }
/// <summary> /// <summary>
/// 获取小程序司导商品结算页面详情 /// 获取小程序司导商品结算页面详情
/// </summary> /// </summary>
...@@ -2462,6 +2461,33 @@ namespace Mall.Module.Product ...@@ -2462,6 +2461,33 @@ namespace Mall.Module.Product
return ApiResult.Success("", Robj); return ApiResult.Success("", Robj);
} }
/// <summary>
/// 获取商品可预定日期列表
/// </summary>
/// <param name="goodsId"></param>
/// <param name="month"></param>
/// <returns></returns>
public object GetAppletSDGoodsTargetDateList(int goodsId, string month)
{
var model = goodsRepository.GetEntity(goodsId);
var targetList = goods_TargetDateRepository.GetList(new RB_Goods_TargetDate_Extend() { GoodsId = goodsId, Month = month });
if (model.AdvanceDay > 0)
{
DateTime Mindate = Convert.ToDateTime(DateTime.Now.AddDays(model.AdvanceDay ?? 0).ToString("yyyy-MM-dd"));
targetList = targetList.Where(x => x.Date >= Mindate).ToList();
}
return targetList.Select(x => new
{
x.Id,
x.GoodsId,
Date = x.Date.Value.ToString("yyyy-MM-dd"),
x.IsReserve,
x.ReserveNum,
SurplusNum = (model.RideNum ?? 0) - x.ReserveNum
});
}
#endregion #endregion
#region 站点配置 #region 站点配置
......
...@@ -276,6 +276,10 @@ namespace Mall.Module.Product ...@@ -276,6 +276,10 @@ namespace Mall.Module.Product
/// 微店信息 /// 微店信息
/// </summary> /// </summary>
private readonly RB_SmallShops_InfoRepository smallShopsInfoRepository = new RB_SmallShops_InfoRepository(); private readonly RB_SmallShops_InfoRepository smallShopsInfoRepository = new RB_SmallShops_InfoRepository();
/// <summary>
/// 商品可预定日期
/// </summary>
private readonly RB_Goods_TargetDateRepository goods_TargetDateRepository = new RB_Goods_TargetDateRepository();
#region 购物车 #region 购物车
...@@ -3729,188 +3733,837 @@ namespace Mall.Module.Product ...@@ -3729,188 +3733,837 @@ namespace Mall.Module.Product
} }
/// <summary> /// <summary>
/// 赠送粉象等级 /// 司导下单
/// </summary> /// </summary>
/// <param name="demodel"></param> /// <param name="demodel"></param>
/// <param name="umodel"></param> /// <returns></returns>
/// <param name="OrderId"></param> public ApiResult SetAppletSDGoodsOrderInfo(RB_Goods_Order_Extend demodel)
private void InsertPresentFXGrade(RB_Goods_Order_Extend demodel, int UserId, int OrderId)
{ {
var basicModel = distributor_BasicsRepository.GetList(new RB_Distributor_Basics_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }).FirstOrDefault(); var umodel = member_UserRepository.GetEntity(demodel.UserId);
if ((basicModel?.IsEnableFXGrade ?? 2) == 1) if (umodel == null)
{ {
var disModel = distributor_InfoRepository.GetList(new RB_Distributor_Info_Extend() { UserId = UserId, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }).FirstOrDefault(); return ApiResult.Failed("用户不存在");
if (disModel == null) }
{ if (demodel.SmallShopsId == 0)
LogHelper.Write("该用户分销商等级不存在,UserId:" + UserId); {
} demodel.SmallShopsId = umodel.SmallShopId;
if (demodel.DetailList.Where(x => x.PresentFXGrade > 0).Any() && disModel != null) }
if (umodel.Blacklist == 1)
{
return ApiResult.Failed("您在黑名单状态无法下单,请联系管理员核实");
}
List<int> disList = new List<int>();
disList.Add(demodel.Province ?? 0);
disList.Add(demodel.City ?? 0);
disList.Add(demodel.District ?? 0);
decimal TotalMoney = 0;
string GoodsIds = "";
int TotalIntegralNumber = 0;//总使用积分
decimal TotalIntegralMoney = 0;//总使用积分抵扣金额
List<RB_Goods_CouponModel> GoodsCouponList = new List<RB_Goods_CouponModel>();//商品优惠卷 价格(每个商品优惠的价格)
decimal CouponsMoney = 0;//优惠卷验证
#region 优惠卷初始化
List<RB_Member_DiscountCoupon_Extend> cList = new List<RB_Member_DiscountCoupon_Extend>();
List<Model.Extend.MarketingCenter.RB_DiscountCoupon_Extend> dcList = new List<Model.Extend.MarketingCenter.RB_DiscountCoupon_Extend>();
List<Model.Extend.MarketingCenter.RB_DiscountCoupon_Product_Extend> dcpList = new List<Model.Extend.MarketingCenter.RB_DiscountCoupon_Product_Extend>();
demodel.CouponsIds = "";
bool IsCommissionCoupons = true;// 是否通用优惠券 2020-08-13 ld
if (demodel.User_Coupon_Id > 0)
{
demodel.CouponsIds = demodel.User_Coupon_Id.ToString();
if (!string.IsNullOrEmpty(demodel.CouponsIds))
{ {
var FXList = distributor_FXGradeRepository.GetList(new RB_Distributor_FXGrade_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }); cList = member_CouponRepository.GetList(new RB_Member_DiscountCoupon_Extend() { UseState = 0, Ids = demodel.CouponsIds, UserId = umodel.Id, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
var VIPModel = FXList.Where(x => x.IsGuest == 3).FirstOrDefault(); if (cList.Any())
List<int> GradeList = new List<int>();//等级列表
int VIPMonths = 0;//vip赠送月份
foreach (var item in demodel.DetailList)
{ {
if (item.PresentFXGrade > 0) string cIds = string.Join(",", cList.Select(x => x.CouponId).Distinct());
dcList = discountCouponRepository.GetDiscountCouponList(new Model.Extend.MarketingCenter.RB_DiscountCoupon_Extend() { CouponIds = cIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }, true);
dcpList = discountCoupon_ProductRepository.GetListByDiscountCouponIds(new Model.Entity.MarketingCenter.RB_DiscountCoupon() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }, cIds, true);
if (dcList.Any())
{ {
//查询是否有申请退款 foreach (var item in cList)
var afterSaleList = goods_OrderAfterSaleRepository.GetList(new RB_Goods_OrderAfterSale_Extend() { OrderDetialId = item.Id, Type = 1, MallBaseId = demodel.MallBaseId, TenantId = demodel.TenantId });
if (!afterSaleList.Any())
{ {
//有赠送粉象等级 if (item.CouponId > 0)
GradeList.Add(item.PresentFXGrade ?? 0);
if (item.PresentFXGrade == (VIPModel?.Id ?? 0))
{ {
VIPMonths += (item.PresentFXMonth ?? 0) * (item.Number ?? 0); if (!dcList.Where(x => x.ID == item.CouponId).Any())
{
return ApiResult.Failed("优惠券不存在,请核实后再试");
}
} }
} }
}
} if (dcList.Where(x => x.SmallShopId > 0).Any())
if (GradeList.Any())
{
//判断等级 取最高级别
int MaxGradeId = 0;
int MaxGrade = 0;
if (GradeList.Distinct().Count() > 1)
{
//说明有两种级别 取最高的
foreach (var item in GradeList.Distinct())
{ {
var fxmodel = FXList.Where(x => x.Id == item).FirstOrDefault(); IsCommissionCoupons = false;
MaxGrade = (fxmodel.Grade ?? 0) > MaxGrade ? (fxmodel.Grade ?? 0) : MaxGrade;
} }
MaxGradeId = FXList.Where(x => x.Grade == MaxGrade).FirstOrDefault()?.Id ?? 0;
}
else
{
MaxGradeId = GradeList.FirstOrDefault();
var fxmodel = FXList.Where(x => x.Id == MaxGradeId).FirstOrDefault();
MaxGrade = (fxmodel.Grade ?? 0) > MaxGrade ? (fxmodel.Grade ?? 0) : MaxGrade;
} }
var oldGrade = FXList.Where(x => x.Id == disModel.FXGradeId).FirstOrDefault()?.Grade ?? 0; }
}
}
#endregion
if (demodel.DetailList.Any())
{
//积分
Model.Entity.MarketingCenter.RB_Integral_Settings integralModel = new Model.Entity.MarketingCenter.RB_Integral_Settings();
if (demodel.Use_Integral == 1 && umodel.Integral > 0)
{
integralModel = integral_SettingsRepository.GetIntegralSettingsList(new Model.Entity.MarketingCenter.RB_Integral_Settings() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }).FirstOrDefault();
}
GoodsIds = string.Join(",", demodel.DetailList.Select(x => x.GoodsId));
var gList = goodsRepository.GetList(new RB_Goods_Extend() { GoodsIds = GoodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
var clist = goods_CategoryRepository.GetList(new RB_Goods_Category_Extend() { GoodsIds = GoodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
var mpriceList = goods_MemberPriceRepository.GetList(new RB_Goods_MemberPrice_Extend() { GoodsIds = GoodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
var mallbaseModel = mallBaseRepository.GetListRepository(new Model.Extend.BaseSetUp.RB_MallBase_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }).FirstOrDefault();
try #region 微店价格
RB_SmallShops_Info_Extend smallModel = new RB_SmallShops_Info_Extend();
List<RB_SmallShops_Price_Extend> smallPList = new List<RB_SmallShops_Price_Extend>();
if (demodel.SmallShopsId > 0)
{
smallModel = smallShops_InfoRepository.GetEntity<RB_SmallShops_Info_Extend>(demodel.SmallShopsId);
smallPList = smallShops_PriceRepository.GetList(new RB_SmallShops_Price_Extend() { SmallShopsId = demodel.SmallShopsId, GoodsIds = GoodsIds });
}
#endregion
foreach (var item in demodel.DetailList)
{
var gmodel = gList.Where(x => x.Id == item.GoodsId).FirstOrDefault();
if (gmodel == null || gmodel.GoodsStatus != 1 || gmodel.GoodsClassify !=1)
{
return ApiResult.Failed("有商品不存在或者商品已失效");
}
if (gmodel.CarType != demodel.CarType)
{
return ApiResult.Failed("商品服务类型不一致");
}
var targetList = goods_TargetDateRepository.GetList(new RB_Goods_TargetDate_Extend() { GoodsId = gmodel.Id, IsReserve = 1, DateTime = demodel.TripSTime.Value.ToString("yyyy-MM-dd") });
if (gmodel.AdvanceDay > 0)
{
DateTime Mindate = Convert.ToDateTime(DateTime.Now.AddDays(gmodel.AdvanceDay ?? 0).ToString("yyyy-MM-dd"));
targetList = targetList.Where(x => x.Date >= Mindate).ToList();
}
if (!targetList.Any()) {
return ApiResult.Failed("商品已被他人购买,无法下单");
}
var targetModel = targetList.FirstOrDefault();
if ((gmodel.RideNum ?? 0) - (targetModel.ReserveNum) < (item.Number ?? 0)) {
return ApiResult.Failed("商品剩余座位数不足,剩余:" + ((gmodel.RideNum ?? 0) - (targetModel.ReserveNum)));
}
var categoryList = clist.Where(x => x.GoodsId == item.GoodsId).ToList();
item.CommissionPrice = gmodel.Commission;// 粉象 返佣金额
item.CostMoney = gmodel.CostPrice ?? 0;
item.ProductCode = gmodel.GoodsNumbers;
item.CategoryIdList = categoryList.Select(x => x.CategoryId ?? 0).ToList();
#region 微店价格
item.SmallShopsCostPrice = gmodel.SellingPrice ?? 0;
if (demodel.SmallShopsId > 0)
{
if ((smallModel.UpPrice ?? 0) > 0 || smallPList.Where(x => x.GoodsId == item.GoodsId && x.UpPrice > 0).Any())
{ {
bool UpdateGrade = false; var sspModel = smallPList.Where(x => x.GoodsId == item.GoodsId && x.SpecificationKey == "").FirstOrDefault();
if (MaxGradeId > 0 && MaxGrade >= oldGrade && MaxGradeId == (VIPModel?.Id ?? 0)) if (sspModel != null)
{ {
UpdateGrade = true; //单商品设置的
string MaxGradeName = FXList.Where(x => x.Id == MaxGradeId).FirstOrDefault()?.GradeName ?? ""; if (sspModel.PriceType == 1)
//vip
var VipExpiryDate = DateTime.Now.AddMonths(VIPMonths);
if (VIPMonths >= 1)
{
VipExpiryDate = Convert.ToDateTime(VipExpiryDate.AddDays(-1).ToString("yyyy-MM-dd 23:59:59"));
}
if (MaxGrade == oldGrade && disModel.VipExpiryDate.HasValue)
{ {
if (disModel.VipExpiryDate > DateTime.Now) gmodel.SellingPrice += Math.Ceiling((gmodel.SellingPrice ?? 0) * (sspModel.UpPrice ?? 0) / 100);
{
VipExpiryDate = disModel.VipExpiryDate.Value.AddMonths(VIPMonths);
}
} }
Dictionary<string, object> keyValues1 = new Dictionary<string, object> else if (sspModel.PriceType == 2)
{
{ nameof(RB_Distributor_Info_Extend.FXGradeId), MaxGradeId },
{ nameof(RB_Distributor_Info_Extend.VipExpiryDate), VipExpiryDate }
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Distributor_Info_Extend.Id),
FiledValue=disModel.Id,
OperatorEnum=OperatorEnum.Equal
}
};
bool gflag = distributor_InfoRepository.Update(keyValues1, wheres1);
if (gflag)
{ {
//新增vip赠送记录表 gmodel.SellingPrice += (sspModel.UpPrice ?? 0);
Random R1 = new Random();
int Rstr1 = R1.Next(111, 999);
string OrderNo1 = DateTime.Now.ToString("yyyyMMddHHmmssfff") + Rstr1;
vip_BuyRepository.Insert(new Model.Entity.User.RB_Vip_Buy()
{
CreateDate = DateTime.Now,
ExpiryDate = VipExpiryDate,
GradeId = MaxGradeId,
GradeName = MaxGradeName,
Id = 0,
MallBaseId = demodel.MallBaseId,
MerchantsNo = "",
Money = 0,
OrderNo = OrderNo1,
PayState = 1,
PayTime = null,
PayWay = 1,
Remark = "下单赠送,订单号:" + demodel.OrderNo + "(" + OrderId + ")",
Status = 0,
TenantId = demodel.TenantId,
UserId = UserId
});
} }
} }
else if (MaxGradeId > 0 && MaxGrade > oldGrade) else
{ {
UpdateGrade = true; if ((smallModel.UpPrice ?? 0) > 0)
string MaxGradeName = FXList.Where(x => x.Id == MaxGradeId).FirstOrDefault()?.GradeName ?? "";
//比vip高级
Dictionary<string, object> keyValues1 = new Dictionary<string, object>
{
{ nameof(RB_Distributor_Info_Extend.FXGradeId), MaxGradeId }
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Distributor_Info_Extend.Id),
FiledValue=disModel.Id,
OperatorEnum=OperatorEnum.Equal
}
};
bool gflag = distributor_InfoRepository.Update(keyValues1, wheres1);
if (gflag)
{ {
//新增vip赠送记录表 if (smallModel.PriceType == 1)
Random R1 = new Random();
int Rstr1 = R1.Next(111, 999);
string OrderNo1 = DateTime.Now.ToString("yyyyMMddHHmmssfff") + Rstr1;
vip_BuyRepository.Insert(new Model.Entity.User.RB_Vip_Buy()
{ {
CreateDate = DateTime.Now, gmodel.SellingPrice += Math.Ceiling((gmodel.SellingPrice ?? 0) * (smallModel.UpPrice ?? 0) / 100);
ExpiryDate = null, }
GradeId = MaxGradeId, else if (smallModel.PriceType == 2)
GradeName = MaxGradeName, {
Id = 0, gmodel.SellingPrice += (smallModel.UpPrice ?? 0);
MallBaseId = demodel.MallBaseId, }
MerchantsNo = "",
Money = 0,
OrderNo = OrderNo1,
PayState = 1,
PayTime = null,
PayWay = 1,
Remark = "下单赠送,订单号:" + demodel.OrderNo + "(" + OrderId + ")",
Status = 0,
TenantId = demodel.TenantId,
UserId = UserId
});
} }
} }
if (UpdateGrade)
{
new UserCommonModule().FXAutoUpgradeUserDistributorGrade(UserId, demodel.TenantId, demodel.MallBaseId);
}
}
catch (Exception ex)
{
LogHelper.Write(ex, "InsertPresentFXGrade赠送粉象分销等级失败,OrderId:" + OrderId);
} }
} }
} #endregion
}
}
/// <summary> #region 会员价格
/// 其他付款 gmodel.MemberPrice = gmodel.SellingPrice ?? 0;
/// </summary> if (umodel.MemberGrade > 0)
{
if (gmodel.EnjoyMember == 1 && gmodel.SeparateSetMember == 1)
{
gmodel.MemberPrice = mpriceList.Where(x => x.GoodsId == item.GoodsId && x.MemberGrade == umodel.MemberGrade && x.SpecificationSort == item.SpecificationSort).FirstOrDefault()?.MemberPrice ?? 0;
item.IsMemberPrice = 1;
item.SmallShopsCostPrice = gmodel.MemberPrice;
if (demodel.SmallShopsId > 0)
{
if ((smallModel.UpPrice ?? 0) > 0 || smallPList.Where(x => x.GoodsId == item.GoodsId && x.UpPrice > 0).Any())
{
var sspModel = smallPList.Where(x => x.GoodsId == item.GoodsId && x.SpecificationKey == item.SpecificationSort).FirstOrDefault();
if (sspModel != null)
{
//单商品设置的
if (sspModel.PriceType == 1)
{
gmodel.MemberPrice += Math.Ceiling((gmodel.MemberPrice) * (sspModel.UpPrice ?? 0) / 100);
}
else if (sspModel.PriceType == 2)
{
gmodel.MemberPrice += (sspModel.UpPrice ?? 0);
}
}
else
{
if ((smallModel.UpPrice ?? 0) > 0)
{
if (smallModel.PriceType == 1)
{
gmodel.MemberPrice += Math.Ceiling((gmodel.MemberPrice) * (smallModel.UpPrice ?? 0) / 100);
}
else if (smallModel.PriceType == 2)
{
gmodel.MemberPrice += (smallModel.UpPrice ?? 0);
}
}
}
}
}
}
else
{
//求会员等级折扣
var gradeModel = member_GradeRepository.GetList(new RB_Member_Grade_Extend() { Grade = umodel.MemberGrade, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }).FirstOrDefault();
gmodel.MemberPrice = Math.Round((gmodel.SellingPrice ?? 0) * (gradeModel?.Discount ?? 10) / 10, 2, MidpointRounding.AwayFromZero);
item.SmallShopsCostPrice = Math.Round((item.SmallShopsCostPrice ?? 0) * (gradeModel?.Discount ?? 10) / 10, 2, MidpointRounding.AwayFromZero);
item.DiscountRate = gradeModel?.Discount ?? 10;
}
}
if (umodel.MemberGrade > 0)
{
item.Final_Price = gmodel.MemberPrice * (item.Number ?? 0);
}
else
{
item.Final_Price = (gmodel.SellingPrice ?? 0) * (item.Number ?? 0);
}
#endregion
#region 直播返佣
item.LiveCommission = 0;
item.LiveFinanceIds = "";
if (gmodel.IsLiveGoods == 1)
{
item.LiveCommission = (item.CommissionPrice / 4) * (item.Number ?? 0);
}
#endregion
item.SmallShopsCostPrice = (item.SmallShopsCostPrice ?? 0) * (item.Number ?? 0);
item.NorGoodsMoney = item.Final_Price ?? 0;//用于计算 运费的 202-08-05 ld
item.Unit_Price = gmodel.SellingPrice ?? 0;
item.Original_Price = (item.Unit_Price) * (item.Number);
#region 积分
if (umodel.Integral > 0 && gmodel.PointsDeduction > 0 && integralModel.IntegralNum > 0)
{
decimal SingleMaxMoney = 0, MultMaxMoney = 0;
if (gmodel.PointsDeductionType == 1)
{
SingleMaxMoney = Math.Round(gmodel.MemberPrice * (gmodel.PointsDeduction ?? 0) / 100, 2, MidpointRounding.AwayFromZero);
MultMaxMoney = Math.Round(gmodel.MemberPrice * (item.Number ?? 0) * (gmodel.PointsDeduction ?? 0) / 100, 2, MidpointRounding.AwayFromZero);
}
if (gmodel.IsMultipleDeduction == 1)
{
//可以多件商品可累计抵扣
if (gmodel.PointsDeductionType == 1)
{
int MaxInterral = Convert.ToInt32(MultMaxMoney * integralModel.IntegralNum);
//最多可抵扣积分
if (umodel.Integral > MaxInterral)
{
item.IntegralNumber = MaxInterral;
item.IntegralMoney = Math.Round(Convert.ToDecimal(MaxInterral) / integralModel.IntegralNum, 2, MidpointRounding.AwayFromZero);
umodel.Integral -= MaxInterral;
}
else
{
item.IntegralNumber = umodel.Integral;
item.IntegralMoney = Math.Round(Convert.ToDecimal(umodel.Integral ?? 0) / integralModel.IntegralNum, 2, MidpointRounding.AwayFromZero);
umodel.Integral = 0;
}
}
else
{
int MaxInterral = Convert.ToInt32((gmodel.PointsDeduction ?? 0) * integralModel.IntegralNum * (item.Number ?? 0));
//最多可抵扣积分
if (umodel.Integral > MaxInterral)
{
item.IntegralNumber = MaxInterral;
item.IntegralMoney = Math.Round(Convert.ToDecimal(MaxInterral) / integralModel.IntegralNum, 2, MidpointRounding.AwayFromZero);
umodel.Integral -= MaxInterral;
}
else
{
item.IntegralNumber = umodel.Integral;
item.IntegralMoney = Math.Round(Convert.ToDecimal(umodel.Integral ?? 0) / integralModel.IntegralNum, 2, MidpointRounding.AwayFromZero);
umodel.Integral = 0;
}
}
}
else
{
//单件商品
if (gmodel.PointsDeductionType == 1)
{
int MaxInterral = Convert.ToInt32(SingleMaxMoney * integralModel.IntegralNum);
//最多可抵扣积分
if (umodel.Integral > MaxInterral)
{
item.IntegralNumber = MaxInterral;
item.IntegralMoney = Math.Round(Convert.ToDecimal(MaxInterral) / integralModel.IntegralNum, 2, MidpointRounding.AwayFromZero);
umodel.Integral -= MaxInterral;
}
else
{
item.IntegralNumber = umodel.Integral;
item.IntegralMoney = Math.Round(Convert.ToDecimal(umodel.Integral ?? 0) / integralModel.IntegralNum, 2, MidpointRounding.AwayFromZero);
umodel.Integral = 0;
}
}
else
{
int MaxInterral = Convert.ToInt32((gmodel.PointsDeduction ?? 0) * integralModel.IntegralNum);
//最多可抵扣积分
if (umodel.Integral > MaxInterral)
{
item.IntegralNumber = MaxInterral;
item.IntegralMoney = Math.Round(Convert.ToDecimal(MaxInterral) / integralModel.IntegralNum, 2, MidpointRounding.AwayFromZero);
umodel.Integral -= MaxInterral;
}
else
{
item.IntegralNumber = umodel.Integral;
item.IntegralMoney = Math.Round(Convert.ToDecimal(umodel.Integral ?? 0) / integralModel.IntegralNum, 2, MidpointRounding.AwayFromZero);
umodel.Integral = 0;
}
}
}
}
if (demodel.Use_Integral == 1)
{
TotalIntegralNumber += (item.IntegralNumber ?? 0);
TotalIntegralMoney += (item.IntegralMoney ?? 0);
item.Final_Price -= (item.IntegralMoney ?? 0);
item.SmallShopsCostPrice -= (item.IntegralMoney ?? 0);
}
#endregion
#region 优惠券
if (demodel.User_Coupon_Id > 0)
{
var ccmodel = cList.Where(x => x.Id == demodel.User_Coupon_Id).FirstOrDefault();
string couponItem = (ccmodel?.CouponId ?? 0).ToString();
if (!string.IsNullOrEmpty(couponItem))
{
var dcModel = dcList.Where(x => x.ID == Convert.ToInt32(couponItem)).FirstOrDefault();
if (dcModel == null)
{
return ApiResult.Failed("优惠卷不存在,亲核实后再试");
}
dcModel.DiscountsPrice = dcModel.DiscountsPrice == 0 ? 10 : dcModel.DiscountsPrice;
if (dcModel.UseType == Common.Enum.MarketingCenter.UseTypeEnum.Category) //指定分类
{
var categoryList1 = dcpList.Where(x => x.DiscountCouponId == Convert.ToInt32(couponItem) && x.DiscountCouponType == Common.Enum.MarketingCenter.UseTypeEnum.Category).Select(x => x.ProductId).ToList();//获取特殊优惠卷
if (categoryList.Select(x => x.Id).Where(x => categoryList1.Contains(x)).Any())
{
GoodsCouponList.Add(new RB_Goods_CouponModel()
{
GoodsId = item.GoodsId ?? 0,
Key = item.SpecificationSort,
TotalMoney = item.Final_Price ?? 0,
CouponMoney = 0
});
}
}
else if (dcModel.UseType == Common.Enum.MarketingCenter.UseTypeEnum.Product)//指定商品
{
var goodsList = dcpList.Where(x => x.DiscountCouponId == Convert.ToInt32(couponItem) && x.DiscountCouponType == Common.Enum.MarketingCenter.UseTypeEnum.Product).Select(x => x.ProductId).ToList();//获取特殊优惠卷
if (goodsList.Contains(item.GoodsId ?? 0))
{
GoodsCouponList.Add(new RB_Goods_CouponModel()
{
GoodsId = item.GoodsId ?? 0,
Key = item.SpecificationSort,
TotalMoney = item.Final_Price ?? 0,
CouponMoney = 0
});
}
}
else
{
GoodsCouponList.Add(new RB_Goods_CouponModel()
{
GoodsId = item.GoodsId ?? 0,
Key = item.SpecificationSort,
TotalMoney = item.Final_Price ?? 0,
CouponMoney = 0
});
}
}
}
#endregion
TotalMoney += (item.Final_Price ?? 0);
item.OrderType = gmodel.GoodsType;
item.GoodsName = gmodel.Name;
item.CoverImage = "";
if (!string.IsNullOrEmpty(gmodel.CarouselImage) && gmodel.CarouselImage != "[]")
{
List<string> CarouselIdList = JsonConvert.DeserializeObject<List<string>>(gmodel.CarouselImage);
//封面图
item.CoverImage = CarouselIdList[0];
}
item.SeparateDistribution = gmodel.SeparateDistribution;
item.SeparateDistributionType = gmodel.SeparateDistributionType;
item.SeparateDistributionMoneyType = gmodel.SeparateDistributionMoneyType;
item.IntegralPresent = gmodel.IntegralPresent;
item.IntegralPresentType = gmodel.IntegralPresentType;
}
if (demodel.User_Coupon_Id > 0 && GoodsCouponList.Any())
{
decimal FinalMoney = GoodsCouponList.Sum(x => x.TotalMoney);
var ccmodel = cList.Where(x => x.Id == demodel.User_Coupon_Id).FirstOrDefault();
var dcModel = dcList.Where(x => x.ID == (ccmodel?.CouponId ?? 0)).FirstOrDefault();
if (dcModel == null)
{
return ApiResult.Failed("优惠卷不存在,亲核实后再试");
}
if (dcModel.MinConsumePrice > 0)
{
if (FinalMoney < dcModel.MinConsumePrice)
{
FinalMoney = 0;
}
}
if (dcModel.CouponType == Common.Enum.MarketingCenter.CouponTypeEnum.FullReduction && FinalMoney > 0)
{
CouponsMoney = dcModel.DiscountsPrice;
}
else if (dcModel.CouponType == Common.Enum.MarketingCenter.CouponTypeEnum.Discount && FinalMoney > 0)
{
decimal disMoney = Math.Round(FinalMoney * (10 - dcModel.DiscountsPrice) / 10, 2, MidpointRounding.AwayFromZero);
if (dcModel.MaxDiscountsPrice > 0 && dcModel.MaxDiscountsPrice < disMoney)
{
disMoney = dcModel.MaxDiscountsPrice;
}
CouponsMoney = disMoney;
}
//每个商品优惠券分摊金额
if (CouponsMoney > 0)
{
foreach (var item in GoodsCouponList)
{
item.CouponMoney = Math.Round((item.TotalMoney / FinalMoney) * CouponsMoney, 2, MidpointRounding.AwayFromZero);
}
if (CouponsMoney != GoodsCouponList.Sum(x => x.CouponMoney))
{
//四舍五入存在差值
decimal diffMoney = CouponsMoney - GoodsCouponList.Sum(x => x.CouponMoney);
var gcModel = GoodsCouponList.OrderBy(x => x.CouponMoney).Take(1).FirstOrDefault();
gcModel.CouponMoney += diffMoney;
}
}
}
foreach (var item in demodel.DetailList)
{
var gmodel = gList.Where(x => x.Id == item.GoodsId).FirstOrDefault();
if (gmodel == null || gmodel.GoodsStatus != 1)
{
continue;
}
item.SupplierId = gmodel.SupplierId;
item.CouponMoney = 0;
var couponModel = GoodsCouponList.Where(x => x.GoodsId == item.GoodsId).FirstOrDefault();
if (couponModel != null)
{
item.CouponMoney = couponModel.CouponMoney;
TotalMoney -= (item.CouponMoney ?? 0);//总价格需减去优惠券金额
item.Final_Price -= (item.CouponMoney ?? 0);
if (IsCommissionCoupons)
{
//通用优惠券
item.SmallShopsCostPrice -= (item.CouponMoney ?? 0);
}
}
item.FreightMoney = 0;
}
}
if (CouponsMoney != demodel.CouponMoney)
{
return ApiResult.Failed("优惠金额计算有误");
}
//验证总额
if (demodel.Income != TotalMoney)
{
return ApiResult.Failed("订单合计金额不正确");
}
demodel.PreferPrice = TotalMoney + CouponsMoney;
#region 手续费计算
decimal ServiceCharge = Convert.ToDecimal(Config.SettlementRate) / 100;
if (ServiceCharge > 0)
{
decimal TotalFee = Math.Round((demodel.Income ?? 0) * ServiceCharge, 2, MidpointRounding.AwayFromZero);
if (demodel.DetailList.Any())
{
int dcount = demodel.DetailList.Count();
decimal avgFee = Math.Round(TotalFee / dcount, 2, MidpointRounding.AwayFromZero);
foreach (var item in demodel.DetailList)
{
item.ServiceCharge = avgFee;
}
if (avgFee * dcount != TotalFee)
{
//多余的 直接算在第一个商品里
var detailmodel = demodel.DetailList.FirstOrDefault();
detailmodel.ServiceCharge += (TotalFee - avgFee * dcount);
}
}
}
#endregion
var trans = goods_OrderRepository.DbTransaction;
try
{
Random R = new Random();
int Rstr = R.Next(111, 999);
demodel.OrderNo = DateTime.Now.ToString("yyyyMMddHHmmssfff") + Rstr;
demodel.PaymentWay = OrderPaymentTypeEnum.OnlinePayment;//先默认在线支付
demodel.Remark ??= "";
demodel.ApplyForCancelStatus ??= 0;
demodel.OrderType = (int)OrderTypeEnum.SDGoods;
int OrderId = goods_OrderRepository.Insert(demodel, trans);
if (OrderId > 0)
{
#region 公司比例
demodel.CompanyProfitRate = 0;
demodel.CompanyId = 0;
var pUserId = member_UserRepository.GetMemberFristParentren(demodel.UserId ?? 0);
if (pUserId > 0)
{
var pumodel = member_UserRepository.GetEntity(pUserId);
demodel.CompanyProfitRate = pumodel.CompanyProfitRate;
demodel.CompanyId = pUserId;
}
#endregion
//插入订单明细+ 商品库存更新
InsertOrderDetail(demodel, trans, OrderId, new List<FreeShippingGoodsDetail>());
//用户订单数增加
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Member_User_Extend.OrderNum),(umodel.OrderNum??0)+1}
};
//优惠券使用
if (cList.Any())
{
foreach (var item in cList)
{
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Member_DiscountCoupon_Extend.UseDate),DateTime.Now},
{ nameof(RB_Member_DiscountCoupon_Extend.UseState),1}
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Member_DiscountCoupon_Extend.Id),
FiledValue=item.Id,
OperatorEnum=OperatorEnum.Equal
}
};
member_CouponRepository.Update(keyValues1, wheres1, trans);
umodel.CouponsNum = (umodel.CouponsNum ?? 0) - 1;
}
if (umodel.CouponsNum < 0) { umodel.CouponsNum = 0; }
keyValues.Add(nameof(RB_Member_User_Extend.CouponsNum), umodel.CouponsNum);
}
if (demodel.Use_Integral == 1 && TotalIntegralNumber > 0)
{
keyValues.Add(nameof(RB_Member_User_Extend.Integral), (umodel.Integral ?? 0));
member_IntegralRepository.Insert(new Model.Entity.User.RB_Member_Integral()
{
Id = 0,
CreateDate = DateTime.Now,
Description = "订单使用积分抵扣" + TotalIntegralMoney + "元,订单号:" + demodel.OrderNo,
Image = 0,
Integral = TotalIntegralNumber,
MallBaseId = demodel.MallBaseId,
PlatformType = demodel.OrderSource,
Remarks = "",
TenantId = demodel.TenantId,
Type = Common.Enum.MarketingCenter.RecordTypeEnum.Expend,
UserId = demodel.UserId,
OrderId = OrderId
}, trans);
}
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Member_User_Extend.Id),
FiledValue=umodel.Id,
OperatorEnum=OperatorEnum.Equal
}
};
member_UserRepository.Update(keyValues, wheres, trans);
//下线
if (umodel.DownlineCondition == Common.Enum.User.DistrbutorReferralsEnum.SCXD && umodel.IsBeDownline == 2)
{
//首次下单成为下线
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{nameof(RB_Member_User_Extend.SuperiorId),umodel.WaitSuperiorId },
{nameof(RB_Member_User_Extend.IsBeDownline),1 },
{nameof(RB_Member_User_Extend.BeDownlineDate),DateTime.Now },
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Member_User_Extend.Id),
FiledValue=umodel.Id,
OperatorEnum=OperatorEnum.Equal
}
};
member_UserRepository.Update(keyValues1, wheres1, trans);
}
//任务执行返佣 失败查看日志,手动返佣(空闲可增加手动返佣接口)
if (demodel.User_Coupon_Id > 0 && demodel.CouponMoney > 0)
{
demodel.CouponDestription = "使用" + (IsCommissionCoupons ? "通用" : "店铺") + "优惠券抵扣";
}
Task.Run(() => InsertOrderCommission(demodel, umodel, GoodsIds, OrderId));
//记录日志
goods_LogRepository.Insert(new RB_Goods_Log()
{
Id = 0,
Type = 1,
SourceId = OrderId,
Content = "新增司导订单",
CreateDate = DateTime.Now,
MallBaseId = demodel.MallBaseId,
TenantId = demodel.TenantId
});
}
goods_OrderRepository.DBSession.Commit();
return ApiResult.Success("", new { OrderId });
}
catch (Exception ex)
{
LogHelper.Write(ex, "SetAppletGoodsOrderInfo");
goods_OrderRepository.DBSession.Rollback("SetAppletGoodsOrderInfo");
return ApiResult.Failed();
}
}
/// <summary>
/// 赠送粉象等级
/// </summary>
/// <param name="demodel"></param>
/// <param name="umodel"></param>
/// <param name="OrderId"></param>
private void InsertPresentFXGrade(RB_Goods_Order_Extend demodel, int UserId, int OrderId)
{
var basicModel = distributor_BasicsRepository.GetList(new RB_Distributor_Basics_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }).FirstOrDefault();
if ((basicModel?.IsEnableFXGrade ?? 2) == 1)
{
var disModel = distributor_InfoRepository.GetList(new RB_Distributor_Info_Extend() { UserId = UserId, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }).FirstOrDefault();
if (disModel == null)
{
LogHelper.Write("该用户分销商等级不存在,UserId:" + UserId);
}
if (demodel.DetailList.Where(x => x.PresentFXGrade > 0).Any() && disModel != null)
{
var FXList = distributor_FXGradeRepository.GetList(new RB_Distributor_FXGrade_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
var VIPModel = FXList.Where(x => x.IsGuest == 3).FirstOrDefault();
List<int> GradeList = new List<int>();//等级列表
int VIPMonths = 0;//vip赠送月份
foreach (var item in demodel.DetailList)
{
if (item.PresentFXGrade > 0)
{
//查询是否有申请退款
var afterSaleList = goods_OrderAfterSaleRepository.GetList(new RB_Goods_OrderAfterSale_Extend() { OrderDetialId = item.Id, Type = 1, MallBaseId = demodel.MallBaseId, TenantId = demodel.TenantId });
if (!afterSaleList.Any())
{
//有赠送粉象等级
GradeList.Add(item.PresentFXGrade ?? 0);
if (item.PresentFXGrade == (VIPModel?.Id ?? 0))
{
VIPMonths += (item.PresentFXMonth ?? 0) * (item.Number ?? 0);
}
}
}
}
if (GradeList.Any())
{
//判断等级 取最高级别
int MaxGradeId = 0;
int MaxGrade = 0;
if (GradeList.Distinct().Count() > 1)
{
//说明有两种级别 取最高的
foreach (var item in GradeList.Distinct())
{
var fxmodel = FXList.Where(x => x.Id == item).FirstOrDefault();
MaxGrade = (fxmodel.Grade ?? 0) > MaxGrade ? (fxmodel.Grade ?? 0) : MaxGrade;
}
MaxGradeId = FXList.Where(x => x.Grade == MaxGrade).FirstOrDefault()?.Id ?? 0;
}
else
{
MaxGradeId = GradeList.FirstOrDefault();
var fxmodel = FXList.Where(x => x.Id == MaxGradeId).FirstOrDefault();
MaxGrade = (fxmodel.Grade ?? 0) > MaxGrade ? (fxmodel.Grade ?? 0) : MaxGrade;
}
var oldGrade = FXList.Where(x => x.Id == disModel.FXGradeId).FirstOrDefault()?.Grade ?? 0;
try
{
bool UpdateGrade = false;
if (MaxGradeId > 0 && MaxGrade >= oldGrade && MaxGradeId == (VIPModel?.Id ?? 0))
{
UpdateGrade = true;
string MaxGradeName = FXList.Where(x => x.Id == MaxGradeId).FirstOrDefault()?.GradeName ?? "";
//vip
var VipExpiryDate = DateTime.Now.AddMonths(VIPMonths);
if (VIPMonths >= 1)
{
VipExpiryDate = Convert.ToDateTime(VipExpiryDate.AddDays(-1).ToString("yyyy-MM-dd 23:59:59"));
}
if (MaxGrade == oldGrade && disModel.VipExpiryDate.HasValue)
{
if (disModel.VipExpiryDate > DateTime.Now)
{
VipExpiryDate = disModel.VipExpiryDate.Value.AddMonths(VIPMonths);
}
}
Dictionary<string, object> keyValues1 = new Dictionary<string, object>
{
{ nameof(RB_Distributor_Info_Extend.FXGradeId), MaxGradeId },
{ nameof(RB_Distributor_Info_Extend.VipExpiryDate), VipExpiryDate }
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Distributor_Info_Extend.Id),
FiledValue=disModel.Id,
OperatorEnum=OperatorEnum.Equal
}
};
bool gflag = distributor_InfoRepository.Update(keyValues1, wheres1);
if (gflag)
{
//新增vip赠送记录表
Random R1 = new Random();
int Rstr1 = R1.Next(111, 999);
string OrderNo1 = DateTime.Now.ToString("yyyyMMddHHmmssfff") + Rstr1;
vip_BuyRepository.Insert(new Model.Entity.User.RB_Vip_Buy()
{
CreateDate = DateTime.Now,
ExpiryDate = VipExpiryDate,
GradeId = MaxGradeId,
GradeName = MaxGradeName,
Id = 0,
MallBaseId = demodel.MallBaseId,
MerchantsNo = "",
Money = 0,
OrderNo = OrderNo1,
PayState = 1,
PayTime = null,
PayWay = 1,
Remark = "下单赠送,订单号:" + demodel.OrderNo + "(" + OrderId + ")",
Status = 0,
TenantId = demodel.TenantId,
UserId = UserId
});
}
}
else if (MaxGradeId > 0 && MaxGrade > oldGrade)
{
UpdateGrade = true;
string MaxGradeName = FXList.Where(x => x.Id == MaxGradeId).FirstOrDefault()?.GradeName ?? "";
//比vip高级
Dictionary<string, object> keyValues1 = new Dictionary<string, object>
{
{ nameof(RB_Distributor_Info_Extend.FXGradeId), MaxGradeId }
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Distributor_Info_Extend.Id),
FiledValue=disModel.Id,
OperatorEnum=OperatorEnum.Equal
}
};
bool gflag = distributor_InfoRepository.Update(keyValues1, wheres1);
if (gflag)
{
//新增vip赠送记录表
Random R1 = new Random();
int Rstr1 = R1.Next(111, 999);
string OrderNo1 = DateTime.Now.ToString("yyyyMMddHHmmssfff") + Rstr1;
vip_BuyRepository.Insert(new Model.Entity.User.RB_Vip_Buy()
{
CreateDate = DateTime.Now,
ExpiryDate = null,
GradeId = MaxGradeId,
GradeName = MaxGradeName,
Id = 0,
MallBaseId = demodel.MallBaseId,
MerchantsNo = "",
Money = 0,
OrderNo = OrderNo1,
PayState = 1,
PayTime = null,
PayWay = 1,
Remark = "下单赠送,订单号:" + demodel.OrderNo + "(" + OrderId + ")",
Status = 0,
TenantId = demodel.TenantId,
UserId = UserId
});
}
}
if (UpdateGrade)
{
new UserCommonModule().FXAutoUpgradeUserDistributorGrade(UserId, demodel.TenantId, demodel.MallBaseId);
}
}
catch (Exception ex)
{
LogHelper.Write(ex, "InsertPresentFXGrade赠送粉象分销等级失败,OrderId:" + OrderId);
}
}
}
}
}
/// <summary>
/// 其他付款
/// </summary>
/// <param name="orderId"></param> /// <param name="orderId"></param>
/// <param name="type"></param> /// <param name="type"></param>
/// <param name="userInfo"></param> /// <param name="userInfo"></param>
...@@ -5077,7 +5730,7 @@ namespace Mall.Module.Product ...@@ -5077,7 +5730,7 @@ namespace Mall.Module.Product
/// <param name="demodel"></param> /// <param name="demodel"></param>
/// <param name="trans"></param> /// <param name="trans"></param>
/// <param name="OrderId"></param> /// <param name="OrderId"></param>
private void InsertOrderDetail(RB_Goods_Order_Extend demodel, System.Data.IDbTransaction trans, int OrderId, List<FreeShippingGoodsDetail> SatisfiedGoodsList) private void InsertOrderDetail(RB_Goods_Order_Extend demodel, System.Data.IDbTransaction trans, int OrderId, List<FreeShippingGoodsDetail> SatisfiedGoodsList,bool IsSDGoods= false)
{ {
foreach (var item in demodel.DetailList) foreach (var item in demodel.DetailList)
{ {
...@@ -5229,6 +5882,13 @@ namespace Mall.Module.Product ...@@ -5229,6 +5882,13 @@ namespace Mall.Module.Product
TenantId = demodel.TenantId TenantId = demodel.TenantId
}, trans); }, trans);
} }
#region 更新司导商品预约时间
if (IsSDGoods) {
//通过下单时间范围 查询出所有的日期 线路的看是否可以拼车 增加人数 更新日期预定状态
goods_TargetDateRepository.GetList(new RB_Goods_TargetDate_Extend() { GoodsId = item.GoodsId??0, });
}
#endregion
} }
//if (IntegralPresentTotal > 0) //if (IntegralPresentTotal > 0)
//{ //{
......
...@@ -34,6 +34,10 @@ namespace Mall.Repository.Product ...@@ -34,6 +34,10 @@ namespace Mall.Repository.Product
if (!string.IsNullOrEmpty(dmodel.DateTime)) { if (!string.IsNullOrEmpty(dmodel.DateTime)) {
where += $@" and {nameof(RB_Goods_TargetDate.Date)} ='{dmodel.DateTime}'"; where += $@" and {nameof(RB_Goods_TargetDate.Date)} ='{dmodel.DateTime}'";
} }
if (!string.IsNullOrEmpty(dmodel.Month))
{
where += $@" and DATE_FORMAT(Date,'%Y-%m') ='{dmodel.Month}'";
}
if (dmodel.IsReserve > 0) { if (dmodel.IsReserve > 0) {
where += $@" and {nameof(RB_Goods_TargetDate.IsReserve)}={dmodel.IsReserve}"; where += $@" and {nameof(RB_Goods_TargetDate.IsReserve)}={dmodel.IsReserve}";
} }
......
...@@ -70,7 +70,6 @@ namespace Mall.WebApi.Controllers.Product ...@@ -70,7 +70,6 @@ namespace Mall.WebApi.Controllers.Product
[HttpPost] [HttpPost]
public ApiResult GetAppletSDGoodsTargetDateList() { public ApiResult GetAppletSDGoodsTargetDateList() {
var req = RequestParm; var req = RequestParm;
var userInfo = AppletUserInfo;
JObject parms = JObject.Parse(req.msg.ToString()); JObject parms = JObject.Parse(req.msg.ToString());
int GoodsId = parms.GetInt("GoodsId", 0); int GoodsId = parms.GetInt("GoodsId", 0);
string Month = parms.GetStringValue("Month"); string Month = parms.GetStringValue("Month");
...@@ -78,8 +77,10 @@ namespace Mall.WebApi.Controllers.Product ...@@ -78,8 +77,10 @@ namespace Mall.WebApi.Controllers.Product
return ApiResult.ParamIsNull("请传递商品id"); return ApiResult.ParamIsNull("请传递商品id");
} }
return ApiResult.Success(); var list = guideCarModule.GetAppletSDGoodsTargetDateList(GoodsId, Month);
return ApiResult.Success("", list);
} }
#endregion #endregion
} }
......
...@@ -507,6 +507,86 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -507,6 +507,86 @@ namespace Mall.WebApi.Controllers.MallBase
return orderModule.SetAppletGoodsOrderInfo(demodel); return orderModule.SetAppletGoodsOrderInfo(demodel);
} }
/// <summary>
/// 司导下单
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetAppletSDGoodsOrderInfo()
{
var req = RequestParm;
var userInfo = AppletUserInfo;
RB_Goods_Order_Extend demodel = JsonConvert.DeserializeObject<RB_Goods_Order_Extend>(req.msg.ToString());
if (string.IsNullOrEmpty(demodel.Consignee))
{
return ApiResult.ParamIsNull("请传递联系人");
}
if (string.IsNullOrEmpty(demodel.Mobile))
{
return ApiResult.ParamIsNull("请传递联系人手机号码");
}
demodel.DeliveryMethod = Common.Enum.Goods.OrderDeliveryMethodEnum.VerificationShop;
if ((demodel.District ?? 0) <= 0)
{
return ApiResult.ParamIsNull("接送地址有误");
}
if (string.IsNullOrEmpty(demodel.ShoppingAddress))
{
return ApiResult.ParamIsNull("接送地址地址不能为空");
}
if (!demodel.TripSTime.HasValue)
{
return ApiResult.ParamIsNull("请传递出发时间");
}
if (demodel.DetailList == null || !demodel.DetailList.Any())
{
return ApiResult.ParamIsNull("请传递商品信息");
}
foreach (var item in demodel.DetailList)
{
if ((item.GoodsId ?? 0) <= 0)
{
return ApiResult.ParamIsNull("请传递商品id");
}
if ((item.Number ?? 0) <= 0)
{
return ApiResult.ParamIsNull("请传递商品数量");
}
}
if ((demodel.Income ?? 0) <= 0)
{
return ApiResult.ParamIsNull("订单金额不正确");
}
demodel.BuyerMessage ??= "";//买家留言
demodel.OrderSource ??= Common.Enum.User.UserSourceEnum.WeiXin;
#region 赋默认值
demodel.TenantId = userInfo.TenantId;
demodel.MallBaseId = userInfo.MallBaseId;
demodel.Country ??= 2;
demodel.OrderStatus = Common.Enum.Goods.OrderStatusEnum.NonPayment;
demodel.CreateDate = DateTime.Now;
demodel.Fee ??= 0;
demodel.FreightMoney ??= 0;
demodel.HistoryOrderStatus ??= 0;
demodel.IsApplyForCancel ??= 2;
demodel.IsOrderCommission ??= 2;
demodel.MerchantsNo ??= "";
demodel.Recycled ??= 2;
demodel.Refund ??= 0;
demodel.Status = 0;
demodel.AnchorName ??= "";
demodel.UpdateDate = DateTime.Now;
demodel.UserId = userInfo.UserId;
demodel.SmallShopsId = req.SmallShopsId;
#endregion
return orderModule.SetAppletSDGoodsOrderInfo(demodel);
}
/// <summary> /// <summary>
/// 返佣初始化 /// 返佣初始化
/// </summary> /// </summary>
......
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