Commit 43a7af41 authored by 吴春's avatar 吴春

提交

parent 3ab19f13
......@@ -204,12 +204,14 @@ namespace Mall.Module.Product
public List<RB_Goods_ShoppingCart_Extend> GetGoodsShoppingCartPageList(int pageIndex, int pageSize, out long count, RB_Goods_Extend demodel)
{
var umodel = member_UserRepository.GetEntity(demodel.UserId);
if (umodel == null) {
if (umodel == null)
{
count = 0;
return new List<RB_Goods_ShoppingCart_Extend>();
}
var list = goods_ShoppingCartRepository.GetPageList(pageIndex, pageSize, out count, demodel);
if (list.Any()) {
if (list.Any())
{
string goodsIds = string.Join(",", list.Select(x => x.GoodsId));
var speciList = goods_SpecificationRepository.GetList(new RB_Goods_Specification_Extend() { GoodsIds = goodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
var speciVList = goods_SpecificationValueRepository.GetList(new RB_Goods_SpecificationValue_Extend() { GoodsIds = goodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
......@@ -231,11 +233,13 @@ namespace Mall.Module.Product
{
item.GoodsStatus = 3;
}
if (!speciPList.Where(x => x.GoodsId == item.GoodsId && x.SpecificationSort == item.SpecificationSort).Any()) {
if (!speciPList.Where(x => x.GoodsId == item.GoodsId && x.SpecificationSort == item.SpecificationSort).Any())
{
item.GoodsStatus = 3;
}
}
else {
else
{
if (!string.IsNullOrEmpty(item.SpecificationSort))
{
item.GoodsStatus = 3;
......@@ -297,12 +301,15 @@ namespace Mall.Module.Product
if (gmodel.IsCustomSpecification == 1)
{
var speciPList = goods_SpecificationPriceRepository.GetList(new RB_Goods_SpecificationPrice_Extend() { GoodsId = demodel.GoodsId, SpecificationSort = demodel.SpecificationSort, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
if (!speciPList.Any()) {
if (!speciPList.Any())
{
return ApiResult.ParamIsNull("商品规格不正确");
}
}
else {
if (demodel.SpecificationSort != "") {
else
{
if (demodel.SpecificationSort != "")
{
return ApiResult.ParamIsNull("商品规格不正确");
}
}
......@@ -325,7 +332,8 @@ namespace Mall.Module.Product
};
flag = goods_ShoppingCartRepository.Update(keyValues, wheres);
}
else {
else
{
flag = goods_ShoppingCartRepository.Insert(new RB_Goods_ShoppingCart()
{
Id = 0,
......@@ -344,7 +352,8 @@ namespace Mall.Module.Product
{
return ApiResult.Success();
}
else {
else
{
return ApiResult.Failed();
}
}
......@@ -488,7 +497,8 @@ namespace Mall.Module.Product
//售后处理中
int AfterSaleNum = goods_OrderRepository.GetAppletGoodsOrderAfterSaleNum(userId, tenantId, mallBaseId);
return ApiResult.Success("",new {
return ApiResult.Success("", new
{
NonPayment = olist.Where(x => x.OrderStatus == OrderStatusEnum.NonPayment).FirstOrDefault()?.OrderNum ?? 0,
WaitSendGoods = olist.Where(x => x.OrderStatus == OrderStatusEnum.WaitSendGoods).FirstOrDefault()?.OrderNum ?? 0,
WaitReceiving = olist.Where(x => x.OrderStatus == OrderStatusEnum.WaitReceiving).FirstOrDefault()?.OrderNum ?? 0,
......@@ -522,7 +532,8 @@ namespace Mall.Module.Product
{
item.CoverImagePath = item.CoverImage;
item.IsApplyForAfterSale = 2;
if (oasList.Where(x => x.OrderDetialId == item.Id).Any()) {
if (oasList.Where(x => x.OrderDetialId == item.Id).Any())
{
item.IsApplyForAfterSale = 1;
}
}
......@@ -562,8 +573,9 @@ namespace Mall.Module.Product
model.Mobile,
model.DistrictAddress,
model.ShoppingAddress,
IsHaveExpress= erlist.Any()?1:2,
DetailList = model.DetailList.Select(x => new {
IsHaveExpress = erlist.Any() ? 1 : 2,
DetailList = model.DetailList.Select(x => new
{
DetailId = x.Id,
x.GoodsId,
x.GoodsName,
......@@ -636,7 +648,8 @@ namespace Mall.Module.Product
public ApiResult GetAppletMyOrderAfterSaleInfo(int orderDetailId, int userId, int tenantId, int mallBaseId)
{
var dModel = goods_OrderDetailRepository.GetEntity<RB_Goods_OrderDetail_Extend>(orderDetailId);
if (dModel == null) {
if (dModel == null)
{
return ApiResult.Failed("未查询到订单商品信息");
}
dModel.CoverImagePath = dModel.CoverImage;
......@@ -662,15 +675,19 @@ namespace Mall.Module.Product
public ApiResult GetAppletGoodsSettlementInfo(RB_Goods_Order_Extend demodel)
{
var umodel = member_UserRepository.GetEntity(demodel.UserId);
if (umodel == null) {
if (umodel == null)
{
return ApiResult.Failed("用户不存在");
}
//获取用户的默认收货地址
var defModel = member_ShippingAddressRepository.GetList(new RB_Member_ShippingAddress_Extend() { UserId = demodel.UserId, IsDefault = 1, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }).FirstOrDefault();
List<int> disList = new List<int>();
if (defModel == null) {
if (defModel == null)
{
defModel = new RB_Member_ShippingAddress_Extend();
} else {
}
else
{
string areaIds = (defModel.Province ?? 0) + "," + (defModel.City ?? 0) + "," + (defModel.District ?? 0);
var arealist = destinationRepository.GetDictvalueListForIds(areaIds);
defModel.DistrictAddress = (arealist.Where(x => x.ID == defModel.Province).FirstOrDefault()?.Name ?? "") + " " + (arealist.Where(x => x.ID == defModel.City).FirstOrDefault()?.Name ?? "") + " " + (arealist.Where(x => x.ID == defModel.District).FirstOrDefault()?.Name ?? "");
......@@ -682,7 +699,8 @@ namespace Mall.Module.Product
List<object> DList = new List<object>();
decimal TotalExpress = 0;
int DefFreightId = 0;
if (demodel.DetailList.Any()) {
if (demodel.DetailList.Any())
{
string 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 });
......@@ -694,9 +712,11 @@ namespace Mall.Module.Product
List<Model.Extend.BaseSetUp.RB_Logistics_Rules_Extend> rulesList = new List<Model.Extend.BaseSetUp.RB_Logistics_Rules_Extend>();
List<Model.Extend.BaseSetUp.RB_Logistics_RulesPrice_Extend> priceList = new List<Model.Extend.BaseSetUp.RB_Logistics_RulesPrice_Extend>();
List<Model.Extend.BaseSetUp.RB_Logistics_RulesRegion_Extend> regionList = new List<Model.Extend.BaseSetUp.RB_Logistics_RulesRegion_Extend>();
if (gList.Any() && defModel.Id>0) {
if (gList.Any() && defModel.Id > 0)
{
List<int> FreightIdList = new List<int>();
if (gList.Where(x => x.FreightId > 0).Any()) {
if (gList.Where(x => x.FreightId > 0).Any())
{
FreightIdList.AddRange(gList.Where(x => x.FreightId > 0).Select(x => x.FreightId ?? 0).ToList());
}
if (gList.Where(x => x.FreightId == 0).Any())
......@@ -718,9 +738,11 @@ namespace Mall.Module.Product
}
}
foreach (var item in demodel.DetailList) {
foreach (var item in demodel.DetailList)
{
var gmodel = gList.Where(x => x.Id == item.GoodsId).FirstOrDefault();
if (gmodel == null || gmodel.GoodsStatus != 1) {
if (gmodel == null || gmodel.GoodsStatus != 1)
{
continue;
}
var categoryList = clist.Where(x => x.GoodsId == item.Id).ToList();
......@@ -803,12 +825,15 @@ namespace Mall.Module.Product
}
//运费
decimal Express = 0;
if (defModel.Id > 0) {
if (defModel.Id > 0)
{
int FreightId2 = gmodel.FreightId ?? 0;
if (gmodel.FreightId == 0) {
if (gmodel.FreightId == 0)
{
FreightId2 = DefFreightId;
}
if (FreightId2 > 0) {
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())
......@@ -829,22 +854,27 @@ namespace Mall.Module.Product
{
Express = pmodel.FirstPrice;
}
else {
if (pmodel.Second > 0) {
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 {
else
{
Express = pmodel.FirstPrice + (((item.Number ?? 0) - pmodel.First) / pmodel.Second + 1) * pmodel.SecondPrice;
}
}
else {
else
{
Express = pmodel.FirstPrice;
}
}
}
else {
else
{
//重量计费
int TotalW = (item.Number ?? 0) * GoodsWeight;
if (TotalW <= pmodel.First)
......@@ -880,7 +910,8 @@ namespace Mall.Module.Product
item.GoodsId,
GoodsName = gmodel.Name,
gmodel.CoverImage,
CategoryList = categoryList.Select(x=>new {
CategoryList = categoryList.Select(x => new
{
x.Id,
x.CategoryName
}),
......@@ -930,7 +961,8 @@ namespace Mall.Module.Product
}
//积分
Model.Entity.MarketingCenter.RB_Integral_Settings integralModel = new Model.Entity.MarketingCenter.RB_Integral_Settings();
if (demodel.Use_Integral == 1 && umodel.Integral>0) {
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();
}
//快递默认
......@@ -955,7 +987,8 @@ namespace Mall.Module.Product
});
}
}
if (arr.Any() && demodel.DeliveryMethod == 0) {//设置默认发货方式
if (arr.Any() && demodel.DeliveryMethod == 0)
{//设置默认发货方式
var delmodel = DelivertList.Where(x => x.Value == arr[0]).FirstOrDefault();
demodel.DeliveryMethod = (OrderDeliveryMethodEnum)Convert.ToInt32(delmodel.Value);
}
......@@ -1019,7 +1052,7 @@ namespace Mall.Module.Product
var AreaList = goods_AreaRepository.GetList(new RB_Goods_Area_Extend() { GoodsIds = GoodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
//返佣
var DistributionCommissionList = new List<RB_Goods_DistributionCommission_Extend>();
if (demodel.DetailList.Where(x=>x.SeparateDistribution == 1).Any())
if (demodel.DetailList.Where(x => x.SeparateDistribution == 1).Any())
{
string goodsIds = string.Join(",", demodel.DetailList.Where(x => x.SeparateDistribution == 1).Select(x => x.GoodsId));
DistributionCommissionList = goods_DistributionCommissionRepository.GetList(new RB_Goods_DistributionCommission_Extend() { GoodsIds = goodsIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
......@@ -1070,7 +1103,8 @@ namespace Mall.Module.Product
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 });
dcpList = discountCoupon_ProductRepository.GetListByDiscountCouponIds(new Model.Entity.MarketingCenter.RB_DiscountCoupon() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }, cIds);
if (dcList.Any()) {
if (dcList.Any())
{
foreach (var item in cList)
{
if (item.CouponId > 0)
......@@ -1314,7 +1348,8 @@ namespace Mall.Module.Product
{
IsPointsDeduction = true;
decimal SingleMaxMoney = 0, MultMaxMoney = 0;
if (gmodel.PointsDeductionType == 1) {
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);
}
......@@ -1356,7 +1391,8 @@ namespace Mall.Module.Product
}
}
}
else {
else
{
//单件商品
if (gmodel.PointsDeductionType == 1)
{
......@@ -1368,13 +1404,15 @@ namespace Mall.Module.Product
item.IntegralMoney = Math.Round(Convert.ToDecimal(MaxInterral) / integralModel.IntegralNum, 2, MidpointRounding.AwayFromZero);
umodel.Integral -= MaxInterral;
}
else {
else
{
item.IntegralNumber = umodel.Integral;
item.IntegralMoney = Math.Round(Convert.ToDecimal(umodel.Integral ?? 0) / integralModel.IntegralNum, 2, MidpointRounding.AwayFromZero);
umodel.Integral = 0;
}
}
else {
else
{
int MaxInterral = Convert.ToInt32((gmodel.PointsDeduction ?? 0) * integralModel.IntegralNum);
//最多可抵扣积分
if (umodel.Integral > MaxInterral)
......@@ -1395,7 +1433,8 @@ namespace Mall.Module.Product
decimal integral_price = 0;
int use_integral = 0;
if (demodel.Use_Integral == 1) {
if (demodel.Use_Integral == 1)
{
integral_price = item.IntegralMoney ?? 0;
use_integral = item.IntegralNumber ?? 0;
......@@ -1405,7 +1444,8 @@ namespace Mall.Module.Product
#region 优惠券
//decimal CouponsMoney = 0;
if (demodel.User_Coupon_Id > 0) {
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))
......@@ -1433,7 +1473,7 @@ namespace Mall.Module.Product
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))
if (goodsList.Contains(item.GoodsId ?? 0))
{
GoodsCouponList.Add(new RB_Goods_CouponModel()
{
......@@ -1473,7 +1513,8 @@ namespace Mall.Module.Product
item.CategoryIdList = categoryList.Select(x => x.CategoryId ?? 0).ToList();
}
if (demodel.User_Coupon_Id > 0 && GoodsCouponList.Any()) {
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();
......@@ -1492,7 +1533,7 @@ namespace Mall.Module.Product
{
CouponsMoney = dcModel.DiscountsPrice;
}
else if(dcModel.CouponType == Common.Enum.MarketingCenter.CouponTypeEnum.Discount && FinalMoney > 0)
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)
......@@ -1502,11 +1543,14 @@ namespace Mall.Module.Product
CouponsMoney = disMoney;
}
//每个商品优惠券分摊金额
if (CouponsMoney > 0) {
foreach (var item in GoodsCouponList) {
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)) {
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();
......@@ -1545,14 +1589,16 @@ namespace Mall.Module.Product
decimal couponMoney = 0;//优惠金额
var couponModel = GoodsCouponList.Where(x => x.GoodsId == item.GoodsId).FirstOrDefault();
if (couponModel != null) {
if (couponModel != null)
{
couponMoney = couponModel.CouponMoney;
TotalGoodsMoney -= couponMoney;//总价格需减去优惠券金额
}
var areaGoods = AreaList.Where(x => x.GoodsId == item.GoodsId).ToList();
bool address_disabled = false;
if (!areaGoods.Where(x => disList.Contains(x.AreaId ?? 0)).Any()) {
if (!areaGoods.Where(x => disList.Contains(x.AreaId ?? 0)).Any())
{
address_disabled = true;
address_enable = false;
}
......@@ -1580,7 +1626,7 @@ namespace Mall.Module.Product
goods_id = gmodel.Id,
sign_id = item.SpecificationSort,
stock = gmodel.InventoryNum,
price = gmodel.SellingPrice??0,
price = gmodel.SellingPrice ?? 0,
original_price = gmodel.OriginalPrice ?? 0,
no = gmodel.GoodsNumbers,
weight = item.GoodsWeight,
......@@ -1588,8 +1634,8 @@ namespace Mall.Module.Product
individual_share = umodel?.IsDistributor ?? 2,// 是否分销商
share_type = gmodel.SeparateDistributionMoneyType,//分销佣金类型,
member_price = gmodel.MemberPrice,
integral_price=demodel.Use_Integral==1? item.IntegralMoney:0,//积分抵扣金额
use_integral= demodel.Use_Integral == 1 ? item.IntegralNumber:0,
integral_price = demodel.Use_Integral == 1 ? item.IntegralMoney : 0,//积分抵扣金额
use_integral = demodel.Use_Integral == 1 ? item.IntegralNumber : 0,
couponMoney,
//discount= [],
//extra= [],
......@@ -1597,12 +1643,14 @@ namespace Mall.Module.Product
name = gmodel.Name,
cover_pic = gmodel.CoverImage,
detail = gmodel.GoodsDetails,
pic_list = gmodel.CarouselImageList.Select(x => new {
pic_list = gmodel.CarouselImageList.Select(x => new
{
id = x.Id,
pic_url = x.Path
}),
number = item.Number,
goods_share_level = DistributionCommissionList.Where(x => x.GoodsId == gmodel.Id).Select(x => new {
goods_share_level = DistributionCommissionList.Where(x => x.GoodsId == gmodel.Id).Select(x => new
{
share_commission_first = x.OneCommission,
share_commission_second = x.TwoCommission,
share_commission_third = x.ThreeCommission,
......@@ -1610,7 +1658,7 @@ namespace Mall.Module.Product
}),
attr_setting_type = gmodel.SeparateDistributionType
},
attr_list= item.Attr_list,
attr_list = item.Attr_list,
discounts = item.Discounts,
member_discount = ((gmodel.SellingPrice ?? 0) * (item.Number ?? 0)) - (gmodel.MemberPrice * (item.Number ?? 0)),
cover_pic = gmodel.CoverImage,
......@@ -1659,51 +1707,55 @@ namespace Mall.Module.Product
mch_list.Add(new
{
mch=new {
id= minModel?.MallBaseId??0,
name= minModel?.MallName??""
mch = new
{
id = minModel?.MallBaseId ?? 0,
name = minModel?.MallName ?? ""
},
goods_list,
express_price = TotalExpress,
remark= "",
remark = "",
//order_form_data= [],
total_goods_price= TotalGoodsSellMoney,
total_goods_original_price= TotalGoodsOriginalMoney,
total_goods_price = TotalGoodsSellMoney,
total_goods_original_price = TotalGoodsOriginalMoney,
member_discount,
coupon= new{
enabled= true,
use= demodel.User_Coupon_Id>0? true:false,
coupon_discount= CouponsMoney,
user_coupon_id= demodel.User_Coupon_Id??0
coupon = new
{
enabled = true,
use = demodel.User_Coupon_Id > 0 ? true : false,
coupon_discount = CouponsMoney,
user_coupon_id = demodel.User_Coupon_Id ?? 0
},
integral= IntegralObj,
delivery= Delivery,
integral = IntegralObj,
delivery = Delivery,
//store= null,
store_select_enable= true,
total_price= TotalGoodsMoney,
store_select_enable = true,
total_price = TotalGoodsMoney,
//pick_up_enable= true,
//pick_up_price= null,
//diff_goods_form_count= 0,
//has_goods_form= false
});
var Robj = new {
var Robj = new
{
mch_list,
total_price= TotalGoodsMoney,
price_enable= true,
address= new{
id= defModel?.Id??0,
user_id= demodel.UserId,
name= defModel?.Name??"",
province_id= defModel?.Province??0,
province= defModel?.PName??"",
city_id= defModel?.City??0,
city= defModel?.CName??"",
district_id= defModel?.District??0,
district= defModel?.DName??"",
mobile= defModel?.Mobile??"",
detail= defModel?.Address??"",
is_default= defModel?.IsDefault??2,
total_price = TotalGoodsMoney,
price_enable = true,
address = new
{
id = defModel?.Id ?? 0,
user_id = demodel.UserId,
name = defModel?.Name ?? "",
province_id = defModel?.Province ?? 0,
province = defModel?.PName ?? "",
city_id = defModel?.City ?? 0,
city = defModel?.CName ?? "",
district_id = defModel?.District ?? 0,
district = defModel?.DName ?? "",
mobile = defModel?.Mobile ?? "",
detail = defModel?.Address ?? "",
is_default = defModel?.IsDefault ?? 2,
lonlat = defModel?.Lonlat
},
address_enable,
......@@ -1711,7 +1763,7 @@ namespace Mall.Module.Product
//custom_currency_all= [],
//allZiti= false,
//hasCity= false,
template_message_list= new List<string>() { "WPELErDfYO3JnizA5Zikta6Y8qrBBAgecuj2aLoucuY", "pCmTJwvTqNpyRREo7vvqIYBcrATNWoitfbLS61fLhzU", "i6QPsaOHgfNwlIRMwmvFGSCqX28g0cRa8XaLZ5_gpgc" }
template_message_list = new List<string>() { "WPELErDfYO3JnizA5Zikta6Y8qrBBAgecuj2aLoucuY", "pCmTJwvTqNpyRREo7vvqIYBcrATNWoitfbLS61fLhzU", "i6QPsaOHgfNwlIRMwmvFGSCqX28g0cRa8XaLZ5_gpgc" }
};
#endregion
return ApiResult.Success("", Robj);
......@@ -1818,7 +1870,8 @@ namespace Mall.Module.Product
return ApiResult.Failed("商品库存不足:" + gmodel.Name);
}
}
else {
else
{
if (item.Number > gmodel.InventoryNum)
{
return ApiResult.Failed("商品库存不足:" + gmodel.Name);
......@@ -1935,7 +1988,8 @@ namespace Mall.Module.Product
{
return ApiResult.Failed("用户不存在");
}
if (umodel.Blacklist == 1) {
if (umodel.Blacklist == 1)
{
return ApiResult.Failed("您在黑名单状态无法下单,请联系管理员核实");
}
List<int> disList = new List<int>();
......@@ -2075,7 +2129,8 @@ namespace Mall.Module.Product
return ApiResult.Failed("商品库存不足:" + gmodel.Name);
}
}
else {
else
{
if (item.Number > gmodel.InventoryNum)
{
return ApiResult.Failed("商品库存不足:" + gmodel.Name);
......@@ -2426,14 +2481,17 @@ namespace Mall.Module.Product
}
}
}
if (demodel.FreightMoney != TotalExpress) {
if (demodel.FreightMoney != TotalExpress)
{
return ApiResult.Failed("运费不正确");
}
if (CouponsMoney != demodel.CouponMoney) {
if (CouponsMoney != demodel.CouponMoney)
{
return ApiResult.Failed("优惠金额计算有误");
}
//验证总额
if (demodel.Income != (TotalMoney - (demodel.CouponMoney??0) + TotalExpress)) {
if (demodel.Income != (TotalMoney - (demodel.CouponMoney ?? 0) + TotalExpress))
{
return ApiResult.Failed("订单合计金额不正确");
}
demodel.PreferPrice = TotalMoney;
......@@ -2463,8 +2521,10 @@ namespace Mall.Module.Product
};
member_UserRepository.Update(keyValues, wheres, trans);
//优惠券使用
if (cList.Any()) {
foreach (var item in cList) {
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}
......@@ -2480,8 +2540,10 @@ namespace Mall.Module.Product
}
}
//来自购物车的话 需清除购物车数据
if (demodel.IsFormShoppingCart == 1) {
foreach (var cartItem in demodel.ShoppingCartIdList) {
if (demodel.IsFormShoppingCart == 1)
{
foreach (var cartItem in demodel.ShoppingCartIdList)
{
Dictionary<string, object> keyValues2 = new Dictionary<string, object>() {
{ nameof(RB_Goods_ShoppingCart.Status),1},
{ nameof(RB_Goods_ShoppingCart.UpdateDate),DateTime.Now}
......@@ -2512,7 +2574,8 @@ namespace Mall.Module.Product
}
}
//下线
if (umodel.DownlineCondition == Common.Enum.User.DistrbutorReferralsEnum.SCXD && umodel.IsBeDownline==2) {
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 },
......@@ -2602,20 +2665,25 @@ namespace Mall.Module.Product
OneUserId = umodel.Id;//设置了分销内购 并且自己是分销商 并且设置了和平等级 , 那么就是自购返佣
}
}
if (OneUserId != umodel.Id) {
if (OneUserId != umodel.Id)
{
//求其上级
disModel = distributor_InfoRepository.GetList(new RB_Distributor_Info_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId, UserId = OneUserId, AuditStatus = Common.Enum.User.DistributorAuditStatusEnum.Audited }).FirstOrDefault();
if (disModel != null && (disModel.HPGradeId ?? 0) > 0)
{
OneUserId = umodel.SuperiorId ?? 0;//其上级可返佣
}
else {
else
{
OneUserId = 0;
}
}
if (OneUserId > 0) {
foreach (var item in demodel.DetailList) {
if (item.CostMoney > 0) {
if (OneUserId > 0)
{
foreach (var item in demodel.DetailList)
{
if (item.CostMoney > 0)
{
//成本价格大于0的才进行返佣
string categoryids = string.Join(",", item.CategoryIdList);
var hpcList = distributor_HPCommissionRepository.GetList(new RB_Distributor_HPCommission_Extend() { CategoryIdsT = categoryids, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
......@@ -2675,11 +2743,13 @@ namespace Mall.Module.Product
{
ParentId = umodel.SuperiorId ?? 0;
}
else {
else
{
ParentId = member_UserRepository.GetEntity(umodel.SuperiorId ?? 0)?.SuperiorId ?? 0;
}
decimal ParentCommission = OneCommission;
while (ParentId > 0) {
while (ParentId > 0)
{
var disModel1 = distributor_InfoRepository.GetList(new RB_Distributor_Info_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId, UserId = ParentId, AuditStatus = Common.Enum.User.DistributorAuditStatusEnum.Audited }).FirstOrDefault();
if (disModel1 != null && (disModel1.HPGradeId ?? 0) > 0)
{
......@@ -3117,12 +3187,15 @@ namespace Mall.Module.Product
}, trans);
item.Id = detailId;
//积分
if (item.IntegralPresent > 0) {
if (item.IntegralPresent > 0)
{
int IntegralPresent = item.IntegralPresent ?? 0;
if (item.IntegralPresentType == 1) {
if (item.IntegralPresentType == 1)
{
IntegralPresent = Convert.ToInt32(((item.Final_Price ?? 0) + (item.FreightMoney ?? 0)) * (item.IntegralPresent ?? 0) / 100);
}
if (IntegralPresent > 0) {
if (IntegralPresent > 0)
{
IntegralPresentTotal += IntegralPresent;
}
}
......@@ -3193,7 +3266,8 @@ namespace Mall.Module.Product
}));
}
}
if (IntegralPresentTotal > 0) {
if (IntegralPresentTotal > 0)
{
member_IntegralRepository.Insert(new Model.Entity.User.RB_Member_Integral()
{
Id = 0,
......@@ -3224,7 +3298,8 @@ namespace Mall.Module.Product
public bool CancelAppletGoodsOrderInfo(int orderId, int type, string remark, int userId, int tenantId, int mallBaseId)
{
var omodel = goods_OrderRepository.GetEntity(orderId);
if (omodel == null) {
if (omodel == null)
{
return false;
}
if (type == 1)
......@@ -3234,13 +3309,16 @@ namespace Mall.Module.Product
return false;
}
}
else if (type == 2) {
if (omodel.OrderStatus != OrderStatusEnum.WaitSendGoods) {
else if (type == 2)
{
if (omodel.OrderStatus != OrderStatusEnum.WaitSendGoods)
{
return false;
}
//物流
var erlist = goods_ExpressRelevanceRepository.GetList(new RB_Goods_ExpressRelevance_Extend() { TenantId = tenantId, MallBaseId = mallBaseId, OrderId = orderId });
if (erlist.Any()) {
if (erlist.Any())
{
return false;//已有商品发货,无法退款
}
}
......@@ -3253,7 +3331,8 @@ namespace Mall.Module.Product
keyValues.Add(nameof(RB_Goods_Order.OrderStatus), OrderStatusEnum.Cancel);
keyValues.Add(nameof(RB_Goods_Order.CancelTime), DateTime.Now);
}
else {
else
{
keyValues.Add(nameof(RB_Goods_Order.OrderStatus), OrderStatusEnum.WaitDeal);
keyValues.Add(nameof(RB_Goods_Order.IsApplyForCancel), 1);
keyValues.Add(nameof(RB_Goods_Order.HistoryOrderStatus), (int)omodel.OrderStatus);
......@@ -3282,18 +3361,23 @@ namespace Mall.Module.Product
}
};
bool flag = goods_OrderRepository.Update(keyValues, wheres, trans);
if (flag) {
if (flag)
{
//回滚商品库存
if (type == 1) {
if (type == 1)
{
var detailList = goods_OrderDetailRepository.GetOrderDetailList(new RB_Goods_OrderDetail_Extend() { GoodsId = omodel.OrderId, TenantId = tenantId, MallBaseId = mallBaseId });
if (detailList.Any()) {
if (detailList.Any())
{
string goodsIds = string.Join(",", detailList.Select(x => x.GoodsId ?? 0).Distinct());
var goodsList = goodsRepository.GetList(new RB_Goods_Extend() { GoodsIds = goodsIds, TenantId = tenantId, MallBaseId = mallBaseId });
var speciPList = goods_SpecificationPriceRepository.GetList(new RB_Goods_SpecificationPrice_Extend() { GoodsIds = goodsIds, TenantId = tenantId, MallBaseId = mallBaseId });
foreach (var item in detailList) {
foreach (var item in detailList)
{
var gmodel = goodsList.Where(x => x.Id == item.GoodsId).FirstOrDefault();
if (gmodel == null) {
if (gmodel == null)
{
continue;
}
if (string.IsNullOrEmpty(item.SpecificationSort))
......@@ -3303,13 +3387,15 @@ namespace Mall.Module.Product
continue;
}
}
else {
else
{
if (gmodel.IsCustomSpecification != 1)
{
continue;
}
var speciPModel = speciPList.Where(x => x.GoodsId == item.GoodsId && x.SpecificationSort == item.SpecificationSort).FirstOrDefault();
if (speciPModel == null) {
if (speciPModel == null)
{
continue;
}
//更新商品规格表库存 + 商品表总库存
......@@ -3381,7 +3467,8 @@ namespace Mall.Module.Product
public bool SetAppletMyOrderAfterSale(RB_Goods_OrderAfterSale_Extend demodel)
{
var dModel = goods_OrderDetailRepository.GetEntity(demodel.OrderDetialId);
if (demodel.Type==1 && ((dModel.Final_Price??0)-(dModel.FreightMoney??0)) < demodel.Refund) {
if (demodel.Type == 1 && ((dModel.Final_Price ?? 0) - (dModel.FreightMoney ?? 0)) < demodel.Refund)
{
return false;
}
demodel.Income = dModel.Final_Price;
......@@ -3393,11 +3480,13 @@ namespace Mall.Module.Product
demodel.ReExpressId ??= 0;
demodel.ReExpressNumber ??= "";
var oasList = goods_OrderAfterSaleRepository.GetList(new RB_Goods_OrderAfterSale_Extend() { OrderDetialId = demodel.OrderDetialId, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
if (oasList.Any()) {
if (oasList.Any())
{
return false;
}
int Id = goods_OrderAfterSaleRepository.Insert(demodel);
if (Id > 0) {
if (Id > 0)
{
//流程
goods_OrderAfterSaleLogRepository.Insert(new RB_Goods_OrderAfterSaleLog()
{
......@@ -3424,42 +3513,50 @@ namespace Mall.Module.Product
public ApiResult GetAppletOrderBuyerToDeliverInfo(int reOrderId, int tenantId, int mallBaseId)
{
var omodel = goods_OrderAfterSaleRepository.GetEntity(reOrderId);
if (omodel == null) {
if (omodel == null)
{
return ApiResult.Failed("售后订单不存在");
}
if (omodel.ReOrderStatus != OrderAfterSaleStatusEnum.DeliveryToBuyer) {
if (omodel.ReOrderStatus != OrderAfterSaleStatusEnum.DeliveryToBuyer)
{
return ApiResult.Failed("状态不正确,刷新后再试");
}
if ((omodel.DeliveryId??0) <= 0) {
if ((omodel.DeliveryId ?? 0) <= 0)
{
return ApiResult.Failed("该订单出错啦,请联系管理员");
}
var delmodel = logistics_DeliveryRepository.GetEntity(omodel.DeliveryId);
if (delmodel == null) {
if (delmodel == null)
{
return ApiResult.Failed("收货地址有误,请联系管理员");
}
string DistrictAddress = (destinationRepository.GetEntity(delmodel.ProvinceId)?.Name ?? "") + " " + (destinationRepository.GetEntity(delmodel.CityId)?.Name ?? "") + " " + (destinationRepository.GetEntity(delmodel.DistrictId)?.Name ?? "");
var detailmodel = goods_OrderDetailRepository.GetEntity(omodel.OrderDetialId);
if (detailmodel == null) {
if (detailmodel == null)
{
return ApiResult.Failed("订单不存在,请联系管理员");
}
string ImagePath = detailmodel.CoverImage;
return ApiResult.Success("",new {
return ApiResult.Success("", new
{
omodel.ReOrderId,
omodel.ReOrderStatus,
ReOrderStatusName = omodel.ReOrderStatus.GetEnumName(),
omodel.Type,
omodel.Remark,
omodel.Refund,
VoucherList = string.IsNullOrEmpty(omodel.Voucher)?new List<string>() : JsonConvert.DeserializeObject<List<string>>(omodel.Voucher),
RecipientInfo = new {
VoucherList = string.IsNullOrEmpty(omodel.Voucher) ? new List<string>() : JsonConvert.DeserializeObject<List<string>>(omodel.Voucher),
RecipientInfo = new
{
delmodel.Name,
delmodel.Mobile,
DistrictAddress,
delmodel.Address,
delmodel.Remarks
},
OrderInfo = new {
OrderInfo = new
{
detailmodel.Id,
ImagePath,
detailmodel.GoodsName,
......@@ -3784,27 +3881,32 @@ namespace Mall.Module.Product
var arealist = destinationRepository.GetDictvalueListForIds(areaIds);
//分销情况
var oclist = goods_OrderCommissionRepository.GetListGroupByUser(new RB_Goods_OrderCommission_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId, OrderIds = string.Join(",", list.Select(x => x.OrderId)) });
if (oclist.Any()) {
if (oclist.Any())
{
//获取用户
var ulist = member_UserRepository.GetList(new RB_Member_User_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId, UserIds = string.Join(",", oclist.Select(x => x.UserId).Distinct()) });
//获取分销商
var dislist = distributor_InfoRepository.GetList(new RB_Distributor_Info_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId, UserIds = string.Join(",", oclist.Select(x => x.UserId).Distinct()) });
var HpgradeList = new List<RB_Distributor_HPGradeInfo_Extend>();
if (oclist.Where(x => x.Type == 2).Any()) {
if (oclist.Where(x => x.Type == 2).Any())
{
string gradeIds = string.Join(",", oclist.Where(x => x.Type == 2).Select(x => x.Grade).Distinct());
HpgradeList = distributor_HPGradeInfoRepository.GetList(new RB_Distributor_HPGradeInfo_Extend() { GradeIds = gradeIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }, true);
}
foreach (var item in oclist) {
foreach (var item in oclist)
{
var umodel = ulist.Where(x => x.Id == item.UserId).FirstOrDefault();
item.UserName = umodel?.Name ?? "";
item.Mobile = umodel?.Moblie ?? "";
item.Name = dislist.Where(x => x.UserId == item.UserId).FirstOrDefault()?.Name ?? "";
if (item.Type == 1) {
if (item.Type == 1)
{
if (item.Grade == 0)
{
item.GradeDescription = "自购返利";
}
else if (item.Grade == 1) {
else if (item.Grade == 1)
{
item.GradeDescription = "一级佣金";
}
else if (item.Grade == 2)
......@@ -3815,7 +3917,9 @@ namespace Mall.Module.Product
{
item.GradeDescription = "三级佣金";
}
} else if (item.Type == 2) {
}
else if (item.Type == 2)
{
var hpGModel = HpgradeList.Where(x => x.Id == item.Grade).FirstOrDefault();
item.GradeDescription = hpGModel?.GradeName ?? "暂无等级";
}
......@@ -3828,7 +3932,7 @@ namespace Mall.Module.Product
string areaName = (arealist.Where(x => x.ID == item.Province).FirstOrDefault()?.Name ?? "") + " " + (arealist.Where(x => x.ID == item.City).FirstOrDefault()?.Name ?? "") + " " + (arealist.Where(x => x.ID == item.District).FirstOrDefault()?.Name ?? "");
item.ShoppingAddress = areaName + " " + item.ShoppingAddress;
item.OrderCommissionList= oclist.Where(x => x.OrderId == item.OrderId).ToList();
item.OrderCommissionList = oclist.Where(x => x.OrderId == item.OrderId).ToList();
item.IsOrderCommission = item.OrderCommissionList.FirstOrDefault()?.IsGoodsDistribution ?? 2;
}
}
......@@ -3993,13 +4097,16 @@ namespace Mall.Module.Product
item.DistrictAddress = (arealist.Where(x => x.ID == item.Province).FirstOrDefault()?.Name ?? "") + " " + (arealist.Where(x => x.ID == item.City).FirstOrDefault()?.Name ?? "") + " " + (arealist.Where(x => x.ID == item.District).FirstOrDefault()?.Name ?? "");
}
List<Model.Entity.BaseSetUp.RB_Logistics_Express> ExpressList = new List<Model.Entity.BaseSetUp.RB_Logistics_Express>();
if (list.Where(x => x.ReExpressId > 0).Any()) {
if (list.Where(x => x.ReExpressId > 0).Any())
{
ExpressList = logistics_ExpressRepository.GetLogisticsExpressList(new Model.Entity.BaseSetUp.RB_Logistics_Express() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }, string.Join(",", list.Where(x => x.ReExpressId > 0).Select(x => x.ReExpressId)));
}
foreach (var item in list) {
foreach (var item in list)
{
item.OrderModel = gList.Where(x => x.OrderId == item.OrderId).FirstOrDefault();
item.OrderDetailModel = gdList.Where(x => x.Id == item.OrderDetialId).FirstOrDefault();
if (item.ReExpressId > 0) {
if (item.ReExpressId > 0)
{
item.ReExpressName = ExpressList.Where(x => x.ID == item.ReExpressId)?.FirstOrDefault()?.Name ?? "";
}
}
......@@ -4027,7 +4134,8 @@ namespace Mall.Module.Product
/// </summary>
/// <param name="OrderId"></param>
/// <returns></returns>
public RB_Goods_Order_Extend GetOrderInfo(int OrderId) {
public RB_Goods_Order_Extend GetOrderInfo(int OrderId)
{
return goods_OrderRepository.GetEntity(OrderId).RefMapperTo<RB_Goods_Order_Extend>();
}
......@@ -4041,15 +4149,18 @@ namespace Mall.Module.Product
public ApiResult GetOrderAfterSaleInfo(int reOrderId, int tenantId, int mallBaseId)
{
var model = goods_OrderAfterSaleRepository.GetEntity<RB_Goods_OrderAfterSale_Extend>(reOrderId);
if (model == null) {
if (model == null)
{
return ApiResult.ParamIsNull();
}
var gModel = goods_OrderRepository.GetEntity<RB_Goods_Order_Extend>(model.OrderId);
if (gModel == null) {
if (gModel == null)
{
return ApiResult.ParamIsNull("订单不存在");
}
var odModel = goods_OrderDetailRepository.GetEntity<RB_Goods_OrderDetail_Extend>(model.OrderDetialId);
if (odModel == null) {
if (odModel == null)
{
return ApiResult.ParamIsNull("订单明细不存在");
}
odModel.CoverImagePath = odModel.CoverImage;
......@@ -4058,18 +4169,20 @@ namespace Mall.Module.Product
var uModel = member_UserRepository.GetEntity(model.UserId);
//物流信息
List<object> ExpressList = new List<object>();
if (model.DeliveryId > 0) {
if (model.DeliveryId > 0)
{
var ldModel = logistics_DeliveryRepository.GetEntity(model.DeliveryId);
var leModel = logistics_ExpressRepository.GetEntity(model.ReExpressId);
ExpressList.Add(new
{
Name = ldModel.Name ?? "",
ExpressName = leModel.Name ?? "",
ExpressNumber= model.ReExpressNumber,
ExpressNumber = model.ReExpressNumber,
Type = 1
});
}
if (model.Type == 2) {
if (model.Type == 2)
{
var oeModel = goods_OrderExpressRepository.GetList(new RB_Goods_OrderExpress_Extend() { AfterSaleOrderId = model.ReOrderId, TenantId = tenantId, MallBaseId = mallBaseId }).FirstOrDefault();
if (oeModel.Type == 1)
{
......@@ -4082,7 +4195,8 @@ namespace Mall.Module.Product
Type = 1
});
}
else {
else
{
ExpressList.Add(new
{
Name = uModel.Name ?? "",
......@@ -4092,27 +4206,30 @@ namespace Mall.Module.Product
});
}
}
return ApiResult.Success("",new {
return ApiResult.Success("", new
{
model.ReOrderId,
model.ReOrderNo,
model.Type,
TypeName = model.Type==1?"退货退款":"换货",
TypeName = model.Type == 1 ? "退货退款" : "换货",
VoucherList = string.IsNullOrEmpty(model.Voucher) ? new List<string>() : JsonConvert.DeserializeObject<List<string>>(model.Voucher),
model.Income,
model.Refund,
model.RefundActual,
UserName = uModel?.Name??"",
UserName = uModel?.Name ?? "",
model.ReOrderStatus,
AuditTime = model.AuditTime.HasValue ? model.AuditTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
FinishTime = model.FinishTime.HasValue ? model.FinishTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
CreateDate = model.CreateDate.HasValue ? model.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
AfterSaleLoglist = slList.Select(x=>new {
AfterSaleLoglist = slList.Select(x => new
{
x.Id,
x.Type,
x.Content,
CreateDate = x.CreateDate.HasValue? x.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss"): ""
CreateDate = x.CreateDate.HasValue ? x.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""
}),
OrderInfo=new {
OrderInfo = new
{
odModel.OrderId,
odModel.CoverImagePath,
odModel.GoodsId,
......@@ -4143,10 +4260,12 @@ namespace Mall.Module.Product
public ApiResult SetOrderAfterSaleAudit(int reOrderId, int type, int tenantId, int mallBaseId)
{
var model = goods_OrderAfterSaleRepository.GetEntity(reOrderId);
if (model == null) {
if (model == null)
{
return ApiResult.Failed("售后订单不存在");
}
if (model.ReOrderStatus != OrderAfterSaleStatusEnum.Auditing) {
if (model.ReOrderStatus != OrderAfterSaleStatusEnum.Auditing)
{
return ApiResult.Failed("状态不正确");
}
Dictionary<string, object> keyValues = new Dictionary<string, object>() { };
......@@ -4155,7 +4274,8 @@ namespace Mall.Module.Product
keyValues.Add(nameof(RB_Goods_OrderAfterSale.ReOrderStatus), OrderAfterSaleStatusEnum.DeliveryToBuyer);
keyValues.Add(nameof(RB_Goods_OrderAfterSale.AuditTime), DateTime.Now);
}
else {
else
{
keyValues.Add(nameof(RB_Goods_OrderAfterSale.ReOrderStatus), OrderAfterSaleStatusEnum.Rejected);
keyValues.Add(nameof(RB_Goods_OrderAfterSale.AuditTime), DateTime.Now);
}
......@@ -4168,14 +4288,16 @@ namespace Mall.Module.Product
}
};
bool flag = goods_OrderAfterSaleRepository.Update(keyValues, wheres);
if (flag) {
if (flag)
{
//记录流程
string Content = "";
if (type == 1)
{
Content = "卖家同意售后";
}
else {
else
{
Content = "卖家拒绝售后";
}
goods_OrderAfterSaleLogRepository.Insert(new RB_Goods_OrderAfterSaleLog()
......@@ -4232,7 +4354,8 @@ namespace Mall.Module.Product
}
};
bool flag = goods_OrderAfterSaleRepository.Update(keyValues, wheres);
if (flag) {
if (flag)
{
goods_OrderAfterSaleLogRepository.Insert(new RB_Goods_OrderAfterSaleLog()
{
Id = 0,
......@@ -4253,7 +4376,8 @@ namespace Mall.Module.Product
/// </summary>
/// <param name="reOrderId"></param>
/// <returns></returns>
public RB_Goods_OrderAfterSale GetOrderAfterSaleEntity(int reOrderId) {
public RB_Goods_OrderAfterSale GetOrderAfterSaleEntity(int reOrderId)
{
return goods_OrderAfterSaleRepository.GetEntity(reOrderId);
}
......@@ -4264,7 +4388,8 @@ namespace Mall.Module.Product
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public int GetOrderRefundOnlineTradeNum(int OrderId, int tenantId, int mallBaseId) {
public int GetOrderRefundOnlineTradeNum(int OrderId, int tenantId, int mallBaseId)
{
var ReList = goods_Online_TradeRepository.GetList(new RB_Goods_Online_Trade_Extend() { OrderId = OrderId, Type = 2, TenantId = tenantId, MallBaseId = mallBaseId });
return ReList.Count();
}
......@@ -4274,7 +4399,8 @@ namespace Mall.Module.Product
/// </summary>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public RB_MiniProgram_Extend GetMiniProgramExtend(int mallBaseId) {
public RB_MiniProgram_Extend GetMiniProgramExtend(int mallBaseId)
{
return miniProgramRepository.GetEntity<RB_MiniProgram_Extend>(mallBaseId);
}
......@@ -4375,7 +4501,8 @@ namespace Mall.Module.Product
}
};
bool flag = goods_OrderAfterSaleRepository.Update(keyValues, wheres);
if (flag) {
if (flag)
{
//快递
demodel.OrderId = 0;
goods_OrderExpressRepository.Insert(demodel);
......@@ -4409,10 +4536,12 @@ namespace Mall.Module.Product
if (demodel.Id > 0)
{
var omodel = goods_OrderRepository.GetEntity(demodel.OrderId);
if (omodel == null) {
if (omodel == null)
{
return "订单不存在";
}
if (omodel.OrderStatus >= Common.Enum.Goods.OrderStatusEnum.Received) {
if (omodel.OrderStatus >= Common.Enum.Goods.OrderStatusEnum.Received)
{
return "已收货无法修改物流信息";
}
//修改物流信息
......@@ -4442,7 +4571,8 @@ namespace Mall.Module.Product
},
};
bool flag = goods_OrderExpressRepository.Update(keyValues, wheres, trans);
if (flag) {
if (flag)
{
goods_LogRepository.Insert(new RB_Goods_Log()
{
Content = "修改快递信息",
......@@ -4501,7 +4631,8 @@ namespace Mall.Module.Product
Type = 1
}, trans);
//判断商品是否已全部绑定快递, 是的话需要更新商品状态为已发货
if (erlist.Select(x => x.OrderDetailId).Distinct().Count() + demodel.OrderDetailIdList.Distinct().Count() == dlist.Count()) {
if (erlist.Select(x => x.OrderDetailId).Distinct().Count() + demodel.OrderDetailIdList.Distinct().Count() == dlist.Count())
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Goods_Order.OrderStatus),OrderStatusEnum.WaitReceiving},
{ nameof(RB_Goods_Order.DeliveryTime),DateTime.Now},
......@@ -4514,7 +4645,8 @@ namespace Mall.Module.Product
}
};
bool oflag = goods_OrderRepository.Update(keyValues, wheres, trans);
if (oflag) {
if (oflag)
{
goods_LogRepository.Insert(new RB_Goods_Log()
{
Content = "修改订单状态为:待收货",
......@@ -4572,7 +4704,8 @@ namespace Mall.Module.Product
keyValues.Add(nameof(RB_Goods_Order.OrderStatus), OrderStatusEnum.Cancel);
keyValues.Add(nameof(RB_Goods_Order.ApplyForCancelStatus), 1);
}
else {
else
{
keyValues.Add(nameof(RB_Goods_Order.ApplyForCancelStatus), 2);
keyValues.Add(nameof(RB_Goods_Order.OrderStatus), omodel.HistoryOrderStatus);
keyValues.Add(nameof(RB_Goods_Order.RejectRemark), remark);
......@@ -4599,7 +4732,8 @@ namespace Mall.Module.Product
bool flag = goods_OrderRepository.Update(keyValues, wheres, trans);
if (flag)
{
if (type == 1) {
if (type == 1)
{
//回滚商品库存
var detailList = goods_OrderDetailRepository.GetOrderDetailList(new RB_Goods_OrderDetail_Extend() { GoodsId = omodel.OrderId, TenantId = tenantId, MallBaseId = mallBaseId });
if (detailList.Any())
......@@ -4676,7 +4810,8 @@ namespace Mall.Module.Product
}
//记录日志
string Content = $"客人申请取消订单,审核:{(type == 1 ? "同意" : "拒绝")}";
if (type == 2) {
if (type == 2)
{
Content += ",拒绝理由:" + remark;
}
goods_LogRepository.Insert(new RB_Goods_Log()
......@@ -4709,7 +4844,8 @@ namespace Mall.Module.Product
public bool SetOrderShopingAddress(RB_Goods_Order_Extend demodel)
{
var omodel = goods_OrderRepository.GetEntity(demodel.OrderId);
if (omodel == null) {
if (omodel == null)
{
return false;
}
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
......@@ -4739,7 +4875,8 @@ namespace Mall.Module.Product
}
};
bool flag = goods_OrderRepository.Update(keyValues, wheres);
if (flag) {
if (flag)
{
//记录日志
goods_LogRepository.Insert(new RB_Goods_Log()
{
......@@ -4769,7 +4906,8 @@ namespace Mall.Module.Product
public bool SetOrderOperation(int orderId, int type, string remark, decimal income, string address, int tenantId, int mallBaseId)
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() { };
switch (type) {
switch (type)
{
case 1:
keyValues.Add(nameof(RB_Goods_Order.Remark), remark); break;
case 2:
......@@ -4809,8 +4947,9 @@ namespace Mall.Module.Product
OperatorEnum=OperatorEnum.Equal
}
};
bool flag= goods_OrderRepository.Update(keyValues, wheres);
if (flag) {
bool flag = goods_OrderRepository.Update(keyValues, wheres);
if (flag)
{
//记录日志
string Content = "";
switch (type)
......@@ -4844,8 +4983,10 @@ namespace Mall.Module.Product
});
//更新返佣为已返佣
var ocList = goods_OrderCommissionRepository.GetListGroupByUser(new RB_Goods_OrderCommission_Extend() { TenantId = tenantId, MallBaseId = mallBaseId, OrderId = orderId });
if (ocList.Any()) {
foreach (var item in ocList) {
if (ocList.Any())
{
foreach (var item in ocList)
{
//查询是否有申请退款
var afterSaleList = goods_OrderAfterSaleRepository.GetList(new RB_Goods_OrderAfterSale_Extend() { OrderDetialId = item.OrderDetailId, Type = 1, MallBaseId = mallBaseId, TenantId = tenantId });
if (!afterSaleList.Any())
......@@ -4902,11 +5043,13 @@ namespace Mall.Module.Product
public bool SetOrderDetialMoneyInfo(int orderDetailId, decimal income, int tenantId, int mallBaseId)
{
var detModel = goods_OrderDetailRepository.GetEntity(orderDetailId);
if (detModel == null) {
if (detModel == null)
{
return false;
}
var orderModel = goods_OrderRepository.GetEntity(detModel.OrderId);
if (orderModel == null) {
if (orderModel == null)
{
return false;
}
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
......@@ -4930,7 +5073,8 @@ namespace Mall.Module.Product
}
};
bool flag = goods_OrderDetailRepository.Update(keyValues, wheres);
if (flag) {
if (flag)
{
//修改订单付款总额
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Goods_Order.Income),orderModel.Income + (income - (detModel.Final_Price??0)) }
......@@ -5006,7 +5150,8 @@ namespace Mall.Module.Product
}
};
var flag = goods_OrderRepository.Update(keyValues1, wheres1);
if (flag) {
if (flag)
{
//记录日志
Task.Run(() => goods_LogRepository.Insert(new RB_Goods_Log()
{
......@@ -5022,6 +5167,118 @@ namespace Mall.Module.Product
return flag;
}
/// <summary>
/// 修改商品订单运费成本价
/// </summary>
/// <param name="orderId"></param>
/// <param name="income"></param>
/// <param name="freightMoney"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public bool SetOrderFreightCostMoney(int orderId, decimal freightMoney, int tenantId, int mallBaseId)
{
var orderModel = goods_OrderDetailRepository.GetEntity(orderId);
if (orderModel == null)
{
return false;
}
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Goods_OrderDetail.FreightMoney),freightMoney }
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods_OrderDetail.OrderId),
FiledValue=orderModel.OrderId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Goods_OrderDetail.TenantId),
FiledValue=tenantId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Goods_OrderDetail.MallBaseId),
FiledValue=mallBaseId,
OperatorEnum=OperatorEnum.Equal
}
};
var flag = goods_OrderDetailRepository.Update(keyValues1, wheres1);
if (flag)
{
//记录日志
Task.Run(() => goods_LogRepository.Insert(new RB_Goods_Log()
{
Content = "修改订单商品:" + orderModel.GoodsName + "运费成本:" + freightMoney + ";历史:价格:" + (orderModel.FreightCostMoney ?? 0).ToString(),
CreateDate = DateTime.Now,
Id = 0,
MallBaseId = mallBaseId,
SourceId = orderModel.OrderId,
TenantId = tenantId,
Type = 1
}));
}
return flag;
}
/// <summary>
/// 修改商品订单成本价
/// </summary>
/// <param name="orderId"></param>
/// <param name="income"></param>
/// <param name="freightMoney"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public bool SetOrderCostMoney(int orderId, decimal costMoney, int tenantId, int mallBaseId)
{
var orderModel = goods_OrderDetailRepository.GetEntity(orderId);
if (orderModel == null)
{
return false;
}
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Goods_OrderDetail.CostMoney),costMoney }
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods_OrderDetail.OrderId),
FiledValue=orderModel.OrderId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Goods_OrderDetail.TenantId),
FiledValue=tenantId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Goods_OrderDetail.MallBaseId),
FiledValue=mallBaseId,
OperatorEnum=OperatorEnum.Equal
}
};
var flag = goods_OrderDetailRepository.Update(keyValues1, wheres1);
if (flag)
{
//记录日志
Task.Run(() => goods_LogRepository.Insert(new RB_Goods_Log()
{
Content = "修改订单商品:" + orderModel.GoodsName + "成本:" + costMoney + ";历史:价格:" + (orderModel.CostMoney ?? 0).ToString(),
CreateDate = DateTime.Now,
Id = 0,
MallBaseId = mallBaseId,
SourceId = orderModel.OrderId,
TenantId = tenantId,
Type = 1
}));
}
return flag;
}
/// <summary>
/// 根据订单好获取物流id
/// </summary>
......@@ -5122,18 +5379,22 @@ namespace Mall.Module.Product
//物流
var erlist = goods_ExpressRelevanceRepository.GetList(new RB_Goods_ExpressRelevance_Extend() { TenantId = tenantId, MallBaseId = mallBaseId, OrderId = orderId });
List<RB_Goods_OrderExpress_Extend> oeList = new List<RB_Goods_OrderExpress_Extend>();
if (erlist.Any()) {
if (erlist.Any())
{
oeList = goods_OrderExpressRepository.GetList(new RB_Goods_OrderExpress_Extend() { TenantId = tenantId, MallBaseId = mallBaseId, OrderExpressIds = string.Join(",", erlist.Select(x => x.OrderExpressId)) });
foreach (var item in oeList) {
foreach (var item in oeList)
{
item.ExpressName = logistics_ExpressRepository.GetEntity(item.ExpressId)?.Name ?? "";
}
}
//获取返佣列表
var ocList = goods_OrderCommissionRepository.GetListGroupByUser(new RB_Goods_OrderCommission_Extend() { TenantId = tenantId, MallBaseId = mallBaseId, OrderId = orderId }).OrderBy(x => x.Grade).ToList();
if (ocList.Any()) {
if (ocList.Any())
{
var ulist = member_UserRepository.GetList(new RB_Member_User_Extend() { TenantId = tenantId, MallBaseId = mallBaseId, UserIds = string.Join(",", ocList.Select(x => x.UserId).Distinct()) });
foreach (var item in ocList) {
foreach (var item in ocList)
{
var umodel = ulist.Where(x => x.Id == item.UserId).FirstOrDefault();
item.UserName = umodel?.Name ?? "";
item.Mobile = umodel?.Moblie ?? "";
......@@ -5144,7 +5405,7 @@ namespace Mall.Module.Product
{
model.OrderId,
model.OrderStatus,
OrderStatusName= model.OrderStatus.GetEnumName(),
OrderStatusName = model.OrderStatus.GetEnumName(),
CreateDate = model.CreateDate.HasValue ? model.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
PaymentTime = model.PaymentTime.HasValue ? model.PaymentTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
DeliveryTime = model.DeliveryTime.HasValue ? model.DeliveryTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
......@@ -5156,14 +5417,15 @@ namespace Mall.Module.Product
model.Income,
model.CouponMoney,
model.FreightMoney,
OrderInfo=new {
OrderInfo = new
{
model.OrderNo,
model.MerchantsNo,
model.PaymentWay,
PaymentWayName= model.PaymentWay.GetEnumName(),
PaymentWayName = model.PaymentWay.GetEnumName(),
model.DeliveryMethod,
DeliveryMethodName= model.DeliveryMethod.GetEnumName(),
UserName= member_UserRepository.GetEntity(model.UserId)?.Name??"",
DeliveryMethodName = model.DeliveryMethod.GetEnumName(),
UserName = member_UserRepository.GetEntity(model.UserId)?.Name ?? "",
model.Consignee,
model.Mobile,
model.DistrictAddress,
......@@ -5172,7 +5434,8 @@ namespace Mall.Module.Product
model.Province,
model.City,
model.District,
OrderExpressList= oeList.Select(x=>new {
OrderExpressList = oeList.Select(x => new
{
x.Id,
x.ExpressId,
x.ExpressName,
......@@ -5180,7 +5443,8 @@ namespace Mall.Module.Product
x.PostCode,
x.Remark,
x.Type,
GoodsList=GetGoodsListForExpress(dlist,erlist,x.Id).Select(z=>new {
GoodsList = GetGoodsListForExpress(dlist, erlist, x.Id).Select(z => new
{
z.Id,
z.CoverImage,
z.CoverImagePath,
......@@ -5188,14 +5452,16 @@ namespace Mall.Module.Product
})
})
},
DistributionInfo= ocList.Select(x=>new {
DistributionInfo = ocList.Select(x => new
{
x.Id,
x.Grade,
x.UserName,
x.Mobile,
x.Commission
}),
DetailList= model.DetailList.Select(x=>new {
DetailList = model.DetailList.Select(x => new
{
x.Id,
x.GoodsName,
x.CoverImage,
......@@ -5265,7 +5531,8 @@ namespace Mall.Module.Product
};
return goods_CommentTemplateRepository.Update(keyValues, wheres);
}
else {
else
{
return goods_CommentTemplateRepository.Insert(demodel) > 0;
}
}
......@@ -5314,8 +5581,10 @@ namespace Mall.Module.Product
public List<RB_Goods_Comment_Extend> GetGoodsCommentPageList(int pageIndex, int pageSize, out long count, RB_Goods_Comment_Extend demodel)
{
var list = goods_CommentRepository.GetPageList(pageIndex, pageSize, out count, demodel);
if (list.Any()) {
foreach (var item in list) {
if (list.Any())
{
foreach (var item in list)
{
//商品图片
item.CoverImage = "";
if (!string.IsNullOrEmpty(item.CarouselImage) && item.CarouselImage != "[]")
......@@ -5326,7 +5595,8 @@ namespace Mall.Module.Product
}
//评论图片
item.CommentImgList = new List<string>();
if (!string.IsNullOrEmpty(item.CommentImage)) {
if (!string.IsNullOrEmpty(item.CommentImage))
{
item.CommentImgList = JsonConvert.DeserializeObject<List<string>>(item.CommentImage);
}
}
......@@ -5348,9 +5618,10 @@ namespace Mall.Module.Product
if (list.Any())
{
List<RB_Member_User_Extend> userList = new List<RB_Member_User_Extend>();
if (list.Where(x => x.UserId > 0).Any()) {
if (list.Where(x => x.UserId > 0).Any())
{
string uids = string.Join(",", list.Where(x => x.UserId > 0).Select(x => x.UserId ?? 0));
userList= member_UserRepository.GetList(new RB_Member_User_Extend() { UserIds = uids, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
userList = member_UserRepository.GetList(new RB_Member_User_Extend() { UserIds = uids, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
}
foreach (var item in list)
{
......@@ -5360,10 +5631,12 @@ namespace Mall.Module.Product
{
item.CommentImgList = JsonConvert.DeserializeObject<List<string>>(item.CommentImage);
}
if (item.UserId > 0) {
if (item.UserId > 0)
{
item.UserPhotoPath = userList.Where(x => x.Id == item.UserId).FirstOrDefault()?.Photo ?? "";
}
if (item.UserId == 0 && item.UserPhoto > 0) {
if (item.UserId == 0 && item.UserPhoto > 0)
{
item.UserPhotoPath = material_InfoRepository.GetEntity(item.UserPhoto)?.Path ?? "";
}
}
......@@ -5379,7 +5652,8 @@ namespace Mall.Module.Product
public bool SetGoodsCommentInfo(RB_Goods_Comment_Extend demodel)
{
int OrderId = 0;
if (demodel.OrderDetailId > 0) {
if (demodel.OrderDetailId > 0)
{
var dmodel = goods_OrderDetailRepository.GetEntity(demodel.OrderDetailId);
if (dmodel == null) { return false; }
OrderId = dmodel.OrderId ?? 0;
......@@ -5389,8 +5663,10 @@ namespace Mall.Module.Product
if (omodel.OrderStatus != OrderStatusEnum.Received) { return false; }
}
bool flag = goods_CommentRepository.Insert(demodel) > 0;
if (flag) {
if (demodel.OrderDetailId > 0) {
if (flag)
{
if (demodel.OrderDetailId > 0)
{
//更新订单商品为已评价
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Goods_OrderDetail.IsComment),1}
......@@ -5403,9 +5679,11 @@ namespace Mall.Module.Product
}
};
goods_OrderDetailRepository.Update(keyValues, wheres);
if (OrderId > 0) {
if (OrderId > 0)
{
var dlist = goods_OrderDetailRepository.GetOrderDetailList(new RB_Goods_OrderDetail_Extend() { OrderId = OrderId, IsComment = 2, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
if (!dlist.Any()) {
if (!dlist.Any())
{
//更新订单为已完成
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Goods_Order.OrderStatus),OrderStatusEnum.Completed}
......@@ -5516,7 +5794,8 @@ namespace Mall.Module.Product
keyValues.Add(nameof(RB_Goods_Comment.Status), 1);
keyValues.Add(nameof(RB_Goods_Comment.UpdateDate), DateTime.Now);
}
else {
else
{
return false;
}
......@@ -5552,7 +5831,8 @@ namespace Mall.Module.Product
var list = EnumHelper.GetEnumList(typeof(GoodsCommentTypeEnum));
var clist = goods_CommentRepository.GetAppletGoodsCommentStatistics(goodsId, tenantId, mallBaseId);
List<object> RList = new List<object>();
foreach (var item in list) {
foreach (var item in list)
{
var cmodel = clist.Where(x => (int)x.CommentGrade == Convert.ToInt32(item.Value)).FirstOrDefault();
RList.Add(new
{
......@@ -5561,8 +5841,9 @@ namespace Mall.Module.Product
Count = cmodel?.CommentNum ?? 0
});
}
return ApiResult.Success("", new {
TotalNum= clist.Sum(x=>x.CommentNum),
return ApiResult.Success("", new
{
TotalNum = clist.Sum(x => x.CommentNum),
List = RList
});
}
......@@ -5581,7 +5862,8 @@ namespace Mall.Module.Product
/// <returns></returns>
public string SetOrderBatchSendGoods(string path_server, int expressId, int tenantId, int mallBaseId)
{
if (!System.IO.File.Exists(path_server)) {
if (!System.IO.File.Exists(path_server))
{
return "导入文件已删除,请刷新后重新导入再试";
}
//处理文件内容读取
......@@ -5589,7 +5871,8 @@ namespace Mall.Module.Product
list = list.Where(x => !string.IsNullOrWhiteSpace(x.OrderNo)).ToList();
if (list.Any())
{
if (list.Count() != list.Select(x => x.OrderNo).Distinct().Count()) {
if (list.Count() != list.Select(x => x.OrderNo).Distinct().Count())
{
return "订单号有重复,请核实后再试";
}
string orderNos = string.Join(",", list.Select(x => "'" + x.OrderNo + "'"));
......@@ -5598,7 +5881,8 @@ namespace Mall.Module.Product
var detailList = goods_OrderDetailRepository.GetOrderDetailList(new RB_Goods_OrderDetail_Extend() { OrderIds = orderIds, TenantId = tenantId, MallBaseId = mallBaseId });
var erList = goods_ExpressRelevanceRepository.GetList(new RB_Goods_ExpressRelevance_Extend() { OrderIds = orderIds, TenantId = tenantId, MallBaseId = mallBaseId });
foreach (var item in list) {
foreach (var item in list)
{
var orderModel = orderList.Where(x => x.OrderNo == item.OrderNo).FirstOrDefault();
if (orderModel == null)
{
......@@ -5623,7 +5907,8 @@ namespace Mall.Module.Product
var ddList = dList.Where(x => !er2List.Select(y => y.OrderDetailId).Contains(x.Id)).ToList();
if (ddList.Any())
{
int eid = goods_OrderExpressRepository.Insert(new RB_Goods_OrderExpress() {
int eid = goods_OrderExpressRepository.Insert(new RB_Goods_OrderExpress()
{
Id = 0,
AfterSaleOrderId = 0,
CreateDate = dt,
......@@ -5635,8 +5920,9 @@ namespace Mall.Module.Product
TenantId = tenantId,
Type = 1,
UpdateDate = dt
},trans);
foreach (var qitem in ddList) {
}, trans);
foreach (var qitem in ddList)
{
goods_ExpressRelevanceRepository.Insert(new RB_Goods_ExpressRelevance()
{
CreateDate = dt,
......@@ -5647,7 +5933,7 @@ namespace Mall.Module.Product
OrderId = orderModel.OrderId,
UpdateDate = dt,
TenantId = tenantId
},trans);
}, trans);
}
Task.Run(() => goods_LogRepository.Insert(new RB_Goods_Log()
{
......@@ -5705,7 +5991,8 @@ namespace Mall.Module.Product
/// </summary>
/// <param name="expressId"></param>
/// <returns></returns>
public Model.Entity.BaseSetUp.RB_Logistics_Express GerExpressModel(int expressId) {
public Model.Entity.BaseSetUp.RB_Logistics_Express GerExpressModel(int expressId)
{
return logistics_ExpressRepository.GetEntity(expressId);
}
......@@ -5738,56 +6025,71 @@ namespace Mall.Module.Product
return "导入文件已删除,请刷新后重新导入再试";
}
int FileType = path_server.Contains(".csv") ? 1 : 2;//1 赞羊导入 2 和平导入
if (FileType != 1) {
if (FileType != 1)
{
return "暂不支持该格式导入";
}
//处理文件内容读取
List<RB_Goods_Order_Extend> list = DataHelper.GoodsOrderBetchDataHelper.ImportClaimData(path_server);
list = list.Where(x => !string.IsNullOrWhiteSpace(x.OrderNo)).ToList();
if (list.Any()) {
if (list.Any())
{
List<string> OrderNoList = new List<string>();
List<string> CityList = new List<string>();
foreach (var item in list) {
foreach (var item in list)
{
item.OrderNo = item.OrderNo.Replace("\t", "");
OrderNoList.Add(item.OrderNo);
#region 验证数据
if (string.IsNullOrEmpty(item.PlatformNameImport)) {
if (string.IsNullOrEmpty(item.PlatformNameImport))
{
return "订单所属平台为空,订单号:" + item.OrderNo;
}
if (string.IsNullOrEmpty(item.UserName)) {
if (string.IsNullOrEmpty(item.UserName))
{
return "订单下单用户为空,订单号:" + item.OrderNo;
}
if (string.IsNullOrEmpty(item.GoodsName)) {
if (string.IsNullOrEmpty(item.GoodsName))
{
return "订单商品名称为空,订单号:" + item.OrderNo;
}
if (string.IsNullOrEmpty(item.SpecificationImport)) {
if (string.IsNullOrEmpty(item.SpecificationImport))
{
return "订单规格为空,订单号:" + item.OrderNo;
}
if ((item.OrderNum??0) <= 0) {
if ((item.OrderNum ?? 0) <= 0)
{
return "订单数量为空,订单号:" + item.OrderNo;
}
if (string.IsNullOrEmpty(item.Consignee)) {
if (string.IsNullOrEmpty(item.Consignee))
{
return "订单收件人为空,订单号:" + item.OrderNo;
}
if (string.IsNullOrEmpty(item.Mobile)) {
if (string.IsNullOrEmpty(item.Mobile))
{
return "订单收件人电话为空,订单号:" + item.OrderNo;
}
if (string.IsNullOrEmpty(item.DistrictAddress)) {
if (string.IsNullOrEmpty(item.DistrictAddress))
{
return "订单收件人地址为空,订单号:" + item.OrderNo;
}
if ((item.Income ?? 0) < 0) {
if ((item.Income ?? 0) < 0)
{
return "订单实际付款为空,订单号:" + item.OrderNo;
}
if (string.IsNullOrEmpty(item.OrderStatusImport)) {
if (string.IsNullOrEmpty(item.OrderStatusImport))
{
return "订单状态为空,订单号:" + item.OrderNo;
}
#endregion
#region 处理地区
if (!string.IsNullOrEmpty(item.DistrictAddress)) {
if (!string.IsNullOrEmpty(item.DistrictAddress))
{
string[] arr = item.DistrictAddress.Split(' ');
if (arr.Length < 4) {
if (arr.Length < 4)
{
return "收件人地址不正确,订单号:" + item.OrderNo;
}
......@@ -5798,7 +6100,8 @@ namespace Mall.Module.Product
item.CName = arr[1].Replace("市", "");
item.DName = arr[2];
for (int i = 3; i < arr.Length; i++) {
for (int i = 3; i < arr.Length; i++)
{
item.ShoppingAddress += arr[i] + " ";
}
}
......@@ -5814,12 +6117,14 @@ namespace Mall.Module.Product
#endregion
}
if (OrderNoList.Any()) {
if (OrderNoList.Any())
{
//验证订单号是否有重复
var goList = goods_OrderRepository.GetOrderList(new RB_Goods_Order_Extend() { orderNos = string.Join(",", OrderNoList.Select(x => "'" + x + "'")), TenantId = tenantId, MallBaseId = mallBaseId });
if (goList.Any()) {
if (goList.Any())
{
string msg = string.Join(",", goList.Select(x => x.OrderNo));
return "订单号有重复,订单号:"+ msg;
return "订单号有重复,订单号:" + msg;
}
}
......@@ -5845,7 +6150,8 @@ namespace Mall.Module.Product
//根据订单号分组
List<RB_Goods_Order_Extend> OrderList = new List<RB_Goods_Order_Extend>();
OrderNoList = OrderNoList.Distinct().ToList();
foreach (var OrderNo in OrderNoList) {
foreach (var OrderNo in OrderNoList)
{
var DetailList = list.Where(x => x.OrderNo == OrderNo).ToList();
var OrderModel1 = DetailList.FirstOrDefault();
var OrderModel = new RB_Goods_Order_Extend()
......@@ -5934,7 +6240,8 @@ namespace Mall.Module.Product
OrderModel.OrderStatus = (OrderStatusEnum)(Convert.ToInt32(orderstatusMode.Value));
//支付方式
OrderModel.PaymentWay = OrderPaymentTypeEnum.OnlinePayment;
if (!string.IsNullOrEmpty(OrderModel.PaymentWayImport)) {
if (!string.IsNullOrEmpty(OrderModel.PaymentWayImport))
{
var payModel = PayWayList.Where(x => x.Key == OrderModel.PaymentWayImport).FirstOrDefault();
OrderModel.PaymentWay = (OrderPaymentTypeEnum)(Convert.ToInt32(payModel.Value));
}
......@@ -5985,19 +6292,24 @@ namespace Mall.Module.Product
OrderModel.DetailList = new List<RB_Goods_OrderDetail_Extend>();
//组装订单详情
foreach (var item in DetailList) {
foreach (var item in DetailList)
{
//商品
var goodsModel = goodsList.Where(x => x.Name == item.GoodsName).FirstOrDefault();
string CoverImage = "";
if (!string.IsNullOrEmpty(goodsModel?.CarouselImage) && (goodsModel?.CarouselImage??"")!="[]") {
if (!string.IsNullOrEmpty(goodsModel?.CarouselImage) && (goodsModel?.CarouselImage ?? "") != "[]")
{
List<string> carouseList = JsonConvert.DeserializeObject<List<string>>(goodsModel?.CarouselImage ?? "");
CoverImage = carouseList[0];
}
List<string> SpecificationList = new List<string>();
if (!string.IsNullOrEmpty(item.SpecificationImport)) {
if (!string.IsNullOrEmpty(item.SpecificationImport))
{
string[] arr = item.SpecificationImport.Split(',');
foreach (var qitem in arr) {
if (!string.IsNullOrEmpty(qitem)) {
foreach (var qitem in arr)
{
if (!string.IsNullOrEmpty(qitem))
{
SpecificationList.Add(qitem);
}
}
......@@ -6040,7 +6352,8 @@ namespace Mall.Module.Product
foreach (var item in OrderList)
{
bool flag = GoodsOrderInsert(item, trans);
if (flag == false) {
if (flag == false)
{
goods_OrderRepository.DBSession.Rollback();
return "请联系管理员,订单导入失败:" + item.OrderNo;
}
......@@ -6064,7 +6377,8 @@ namespace Mall.Module.Product
/// <param name="demodel"></param>
/// <param name="trans"></param>
/// <returns></returns>
public bool GoodsOrderInsert(RB_Goods_Order_Extend demodel,System.Data.IDbTransaction trans) {
public bool GoodsOrderInsert(RB_Goods_Order_Extend demodel, System.Data.IDbTransaction trans)
{
int OrderId = goods_OrderRepository.Insert(demodel, trans);
if (OrderId > 0)
{
......
......@@ -710,6 +710,45 @@ namespace Mall.WebApi.Controllers.MallBase
}));
}
#region 修改运费成本以及商品成本
/// <summary>
/// 修改订单商品成本运费
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetOrderFreightCostMoney()
{
var req = RequestParm;
JObject parms = JObject.Parse(req.msg.ToString());
int OrderId = parms.GetInt("Id", 0);
decimal FreightMoney = parms.GetDecimal("FreightCostMoney");
if (OrderId <= 0)
{
return ApiResult.ParamIsNull("请传递订单明细id");
}
if (FreightMoney < 0)
{
return ApiResult.ParamIsNull("请传递运费成本");
}
bool flag = orderModule.SetOrderFreightCostMoney(OrderId, FreightMoney, req.TenantId, req.MallBaseId);
if (flag)
{
return ApiResult.Success();
}
else
{
return ApiResult.Failed();
}
}
#endregion
#endregion
#region 会员购买
......
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.ServiceProcess.ServiceController" Version="4.7.0" />
</ItemGroup>
</Project>
using System;
namespace Mall.WindowsService
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
namespace Mall.WindowsService
{
public class WindowsService : ServiceBase
{
}
}
......@@ -39,6 +39,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mall.Module.MarketingCenter
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{E56AB52A-2396-4A34-82AE-344EBF51F248}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mall.WindowsService", "Mall.WindowsService\Mall.WindowsService.csproj", "{FC1D11B4-E016-485A-A5E3-906697362658}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -101,6 +103,10 @@ Global
{E56AB52A-2396-4A34-82AE-344EBF51F248}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E56AB52A-2396-4A34-82AE-344EBF51F248}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E56AB52A-2396-4A34-82AE-344EBF51F248}.Release|Any CPU.Build.0 = Release|Any CPU
{FC1D11B4-E016-485A-A5E3-906697362658}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FC1D11B4-E016-485A-A5E3-906697362658}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FC1D11B4-E016-485A-A5E3-906697362658}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FC1D11B4-E016-485A-A5E3-906697362658}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
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