Commit af6c9caa authored by liudong1993's avatar liudong1993

小程序商品详情

parent 78b54f99
...@@ -182,6 +182,7 @@ namespace Mall.CacheManager.User ...@@ -182,6 +182,7 @@ namespace Mall.CacheManager.User
MallBaseId = umodel.MallBaseId, MallBaseId = umodel.MallBaseId,
MallName = "", MallName = "",
Mobile = umodel.Moblie, Mobile = umodel.Moblie,
UserId = NewUserId,
TenantId = umodel.TenantId, TenantId = umodel.TenantId,
Name = umodel.Name, Name = umodel.Name,
OpenId = umodel.OpenId, OpenId = umodel.OpenId,
......
...@@ -29,6 +29,11 @@ namespace Mall.Common ...@@ -29,6 +29,11 @@ namespace Mall.Common
set; set;
} }
/// <summary>
/// 用户id
/// </summary>
public int UserId { get; set; }
/// <summary> /// <summary>
/// 唯一码 /// 唯一码
/// </summary> /// </summary>
......
...@@ -344,7 +344,7 @@ namespace Mall.Model.Entity.Product ...@@ -344,7 +344,7 @@ namespace Mall.Model.Entity.Product
set; set;
} }
/// <summary> /// <summary>
/// 分销佣金类型 1固定金额 2百分比 /// 分销佣金类型 2固定金额 1百分比
/// </summary> /// </summary>
public int? SeparateDistributionMoneyType public int? SeparateDistributionMoneyType
{ {
...@@ -371,6 +371,10 @@ namespace Mall.Model.Entity.Product ...@@ -371,6 +371,10 @@ namespace Mall.Model.Entity.Product
/// 是否加入快速购买 1是 2否 /// 是否加入快速购买 1是 2否
/// </summary> /// </summary>
public int? IsQuickBuy { get; set; } public int? IsQuickBuy { get; set; }
/// <summary>
/// 是否畅销 1是 2否
/// </summary>
public int? IsSellWell { get; set; }
/// <summary> /// <summary>
/// 商品类型 /// 商品类型
......
using Mall.Common.AOP;
using Mall.Common.Enum.User;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.User
{
/// <summary>
/// 用户收藏商品表实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Member_Collection
{
/// <summary>
/// Id
/// </summary>
public int Id
{
get;
set;
}
/// <summary>
/// 用户id
/// </summary>
public int? UserId
{
get;
set;
}
/// <summary>
/// 类型 1商品 2其他
/// </summary>
public int? Type { get; set; }
/// <summary>
/// 商品id
/// </summary>
public int? GoodsId
{
get;
set;
}
/// <summary>
/// 删除状态
/// </summary>
public int? Status
{
get;
set;
}
/// <summary>
/// 商户号
/// </summary>
public int TenantId
{
get;
set;
}
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId
{
get;
set;
}
/// <summary>
/// CreateDate
/// </summary>
public DateTime? CreateDate
{
get;
set;
}
/// <summary>
/// UpdateDate
/// </summary>
public DateTime? UpdateDate
{
get;
set;
}
}
}
...@@ -13,6 +13,14 @@ namespace Mall.Model.Extend.Product ...@@ -13,6 +13,14 @@ namespace Mall.Model.Extend.Product
[DB(ConnectionName = "DefaultConnection")] [DB(ConnectionName = "DefaultConnection")]
public class RB_Goods_Extend : RB_Goods public class RB_Goods_Extend : RB_Goods
{ {
/// <summary>
/// 小程序名称
/// </summary>
public string MallName { get; set; }
/// <summary>
/// 用户id
/// </summary>
public int? UserId { get; set; }
/// <summary> /// <summary>
/// 排序 /// 排序
/// </summary> /// </summary>
...@@ -86,5 +94,18 @@ namespace Mall.Model.Extend.Product ...@@ -86,5 +94,18 @@ namespace Mall.Model.Extend.Product
/// </summary> /// </summary>
public List<RB_Goods_MemberPrice_Extend> MemberPriceList { get; set; } public List<RB_Goods_MemberPrice_Extend> MemberPriceList { get; set; }
/// <summary>
/// 是否收藏 true/false
/// </summary>
public bool Favorite { get; set; }
/// <summary>
/// 快递费用
/// </summary>
public decimal Express { get; set; }
/// <summary>
/// 最高分销返佣
/// </summary>
public decimal MaxShare { get; set; }
} }
} }
using Mall.Common.AOP;
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.User;
namespace Mall.Model.Extend.User
{
/// <summary>
/// 用户收藏商品表扩展实体
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Member_Collection_Extend : RB_Member_Collection
{
}
}
...@@ -13,6 +13,9 @@ namespace Mall.Model.Extend.User ...@@ -13,6 +13,9 @@ namespace Mall.Model.Extend.User
[DB(ConnectionName = "DefaultConnection")] [DB(ConnectionName = "DefaultConnection")]
public class RB_Member_ShippingAddress_Extend : RB_Member_ShippingAddress public class RB_Member_ShippingAddress_Extend : RB_Member_ShippingAddress
{ {
/// <summary>
/// 区域地址
/// </summary>
public string DistrictAddress { get; set; }
} }
} }
...@@ -82,10 +82,22 @@ namespace Mall.Module.Product ...@@ -82,10 +82,22 @@ namespace Mall.Module.Product
/// </summary> /// </summary>
private readonly RB_Distributor_GradeRepository distributor_GradeRepository = new RB_Distributor_GradeRepository(); private readonly RB_Distributor_GradeRepository distributor_GradeRepository = new RB_Distributor_GradeRepository();
/// <summary> /// <summary>
/// 分销商
/// </summary>
private readonly RB_Distributor_InfoRepository distributor_InfoRepository = new RB_Distributor_InfoRepository();
/// <summary>
/// 分销基础配置
/// </summary>
private readonly RB_Distributor_BasicsRepository distributor_BasicsRepository = new RB_Distributor_BasicsRepository();
/// <summary>
/// 会员等级 /// 会员等级
/// </summary> /// </summary>
private readonly RB_Member_GradeRepository member_GradeRepository = new RB_Member_GradeRepository(); private readonly RB_Member_GradeRepository member_GradeRepository = new RB_Member_GradeRepository();
/// <summary> /// <summary>
/// 用户管理
/// </summary>
private readonly RB_Member_UserRepository member_UserRepository = new RB_Member_UserRepository();
/// <summary>
/// 商品分销佣金 /// 商品分销佣金
/// </summary> /// </summary>
private readonly RB_Goods_DistributionCommissionRepository goods_DistributionCommissionRepository = new RB_Goods_DistributionCommissionRepository(); private readonly RB_Goods_DistributionCommissionRepository goods_DistributionCommissionRepository = new RB_Goods_DistributionCommissionRepository();
...@@ -97,11 +109,35 @@ namespace Mall.Module.Product ...@@ -97,11 +109,35 @@ namespace Mall.Module.Product
/// 运费 /// 运费
/// </summary> /// </summary>
private readonly RB_Logistics_RulesRepository logistics_RulesRepository = new RB_Logistics_RulesRepository(); private readonly RB_Logistics_RulesRepository logistics_RulesRepository = new RB_Logistics_RulesRepository();
private readonly RB_Logistics_RulesRegionRepository logistics_RulesRegionRepository = new RB_Logistics_RulesRegionRepository();
private readonly RB_Logistics_RulesPriceRepository logistics_RulesPriceRepository = new RB_Logistics_RulesPriceRepository();
/// <summary>
/// 商户仓储层对象
/// </summary>
private Mall.Repository.User.RB_MiniProgramRepository programRepository = new Repository.User.RB_MiniProgramRepository();
/// <summary>
/// 商品收藏
/// </summary>
private readonly RB_Member_CollectionRepository member_CollectionRepository = new RB_Member_CollectionRepository();
/// <summary>
/// 收货地址
/// </summary>
private readonly RB_Member_ShippingAddressRepository member_ShippingAddressRepository = new RB_Member_ShippingAddressRepository();
#region 小程序接口 #region 小程序接口
/// <summary>
/// 获取用户信息
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public RB_Member_User_Extend GetMemberUserInfo(int userId)
{
return member_UserRepository.GetEntity(userId).RefMapperTo<RB_Member_User_Extend>();
}
/// <summary> /// <summary>
/// 获取小程序商品列表 /// 获取小程序商品列表
/// </summary> /// </summary>
...@@ -133,16 +169,22 @@ namespace Mall.Module.Product ...@@ -133,16 +169,22 @@ namespace Mall.Module.Product
/// 获取小程序商品详情 /// 获取小程序商品详情
/// </summary> /// </summary>
/// <param name="goodsId"></param> /// <param name="goodsId"></param>
/// <param name="UserId"></param>
/// <param name="TenantId"></param> /// <param name="TenantId"></param>
/// <param name="MallBaseId"></param> /// <param name="MallBaseId"></param>
/// <returns></returns> /// <returns></returns>
public RB_Goods_Extend GetAppletGoodsInfo(int goodsId, int TenantId, int MallBaseId) public RB_Goods_Extend GetAppletGoodsInfo(int goodsId, int UserId, int TenantId, int MallBaseId)
{ {
var model = goodsRepository.GetEntity(goodsId).RefMapperTo<RB_Goods_Extend>(); var model = goodsRepository.GetEntity(goodsId).RefMapperTo<RB_Goods_Extend>();
if (model == null || model.TenantId != TenantId || model.MallBaseId != MallBaseId) if (model == null || model.TenantId != TenantId || model.MallBaseId != MallBaseId)
{ {
return null; return null;
} }
//小程序名称
model.MallName = programRepository.GetEntity(model.MallBaseId)?.MallName ?? "";
#region 基本信息
decimal MaxSellMoney = model.SellingPrice ?? 0;
model.SpecificationList = new List<RB_Goods_Specification_Extend>(); model.SpecificationList = new List<RB_Goods_Specification_Extend>();
model.SpecificationPriceList = new List<RB_Goods_SpecificationPrice_Extend>(); model.SpecificationPriceList = new List<RB_Goods_SpecificationPrice_Extend>();
if (model.IsCustomSpecification == 1) if (model.IsCustomSpecification == 1)
...@@ -166,22 +208,27 @@ namespace Mall.Module.Product ...@@ -166,22 +208,27 @@ namespace Mall.Module.Product
} }
} }
model.SpecificationPriceList = goods_SpecificationPriceRepository.GetList(new RB_Goods_SpecificationPrice_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId }); model.SpecificationPriceList = goods_SpecificationPriceRepository.GetList(new RB_Goods_SpecificationPrice_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId });
MaxSellMoney = model.SpecificationPriceList.Max(x => x.SellingPrice ?? 0);
} }
//区域
model.AreaList = new List<RB_Goods_Area_Extend>(); model.AreaList = new List<RB_Goods_Area_Extend>();
if (model.IsAreaBuy == 1) if (model.IsAreaBuy == 1)
{ {
model.AreaList = goods_AreaRepository.GetList(new RB_Goods_Area_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId }); model.AreaList = goods_AreaRepository.GetList(new RB_Goods_Area_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId });
} }
//返佣
model.DistributionCommissionList = new List<RB_Goods_DistributionCommission_Extend>(); model.DistributionCommissionList = new List<RB_Goods_DistributionCommission_Extend>();
if (model.SeparateDistribution == 1) if (model.SeparateDistribution == 1)
{ {
model.DistributionCommissionList = goods_DistributionCommissionRepository.GetList(new RB_Goods_DistributionCommission_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId }); model.DistributionCommissionList = goods_DistributionCommissionRepository.GetList(new RB_Goods_DistributionCommission_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId });
} }
//会员价格
model.MemberPriceList = new List<RB_Goods_MemberPrice_Extend>(); model.MemberPriceList = new List<RB_Goods_MemberPrice_Extend>();
if (model.EnjoyMember == 1 && model.SeparateSetMember == 1) if (model.EnjoyMember == 1 && model.SeparateSetMember == 1)
{ {
model.MemberPriceList = goods_MemberPriceRepository.GetList(new RB_Goods_MemberPrice_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId }); model.MemberPriceList = goods_MemberPriceRepository.GetList(new RB_Goods_MemberPrice_Extend() { GoodsId = goodsId, TenantId = TenantId, MallBaseId = MallBaseId });
} }
//轮播
model.CarouselImageList = new List<RB_ImageCommonModel>(); model.CarouselImageList = new List<RB_ImageCommonModel>();
if (!string.IsNullOrEmpty(model.CarouselImage) && model.CarouselImage != "[]") if (!string.IsNullOrEmpty(model.CarouselImage) && model.CarouselImage != "[]")
{ {
...@@ -231,27 +278,149 @@ namespace Mall.Module.Product ...@@ -231,27 +278,149 @@ namespace Mall.Module.Product
Name = item.Name Name = item.Name
}); });
} }
}
//表单
if (model.FormsId > 0)
{
model.FormsName = "未建表";
}
else
{
model.FormsName = "默认表单";
}
#endregion
#region 是否收藏
model.Favorite = false;
if (UserId > 0)
{
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Member_Collection_Extend.UserId),
FiledValue=UserId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Member_Collection_Extend.GoodsId),
FiledValue=goodsId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Member_Collection_Extend.TenantId),
FiledValue=TenantId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Member_Collection_Extend.MallBaseId),
FiledValue=MallBaseId,
OperatorEnum=OperatorEnum.Equal
},
};
if (member_CollectionRepository.Exists(wheres))
{
model.Favorite = true;
}
} }
#endregion
#region 快递费用
//运费 //运费
Model.Entity.BaseSetUp.RB_Logistics_Rules rulesModel = new Model.Entity.BaseSetUp.RB_Logistics_Rules();
if (model.FreightId > 0) if (model.FreightId > 0)
{ {
model.FreightName = logistics_RulesRepository.GetEntity(model.FreightId)?.RulesName ?? ""; rulesModel = logistics_RulesRepository.GetEntity(model.FreightId);
model.FreightName = rulesModel?.RulesName ?? "";
} }
else else
{ {
model.FreightName = "默认运费"; model.FreightName = "默认运费";
} }
//表单 model.Express = 0;
if (model.FormsId > 0) if (UserId > 0 && model.FreightId > 0) {
{ var samodel = member_ShippingAddressRepository.GetList(new RB_Member_ShippingAddress_Extend() { TenantId = TenantId, MallBaseId = MallBaseId, UserId = UserId, IsDefault = 1 }).FirstOrDefault();
model.FormsName = "未建表"; var priceList = logistics_RulesPriceRepository.GetListRepository(new Model.Extend.BaseSetUp.RB_Logistics_RulesPrice_Extend() { TenantId = TenantId, MallBaseId = MallBaseId, RulesId = model.FreightId ?? 0 });
if (priceList.Any() && samodel != null) {
string priceIds = string.Join(",", priceList.Select(x => x.ID));
var regionList = logistics_RulesRegionRepository.GetListRepository(new Model.Extend.BaseSetUp.RB_Logistics_RulesRegion_Extend() { TenantId = TenantId, MallBaseId = MallBaseId, PriceIds = priceIds });
List<int> disList = new List<int>();
disList.Add(samodel.Province ?? 0);
disList.Add(samodel.City ?? 0);
disList.Add(samodel.District ?? 0);
var regionModel = regionList.Where(x => disList.Contains(x.RegionId)).FirstOrDefault();
if (regionModel != null) {
var pmodel = priceList.Where(x => x.ID == regionModel.RulesPriceId).FirstOrDefault();
if (pmodel != null && rulesModel != null)
{
if (rulesModel.ChargeMode == Common.Enum.MallBase.ChargeModeEnum.Num)
{
model.Express = pmodel.FirstPrice;
}
}
}
}
} }
else #endregion
#region 最高返佣
model.MaxShare = 0;
if (UserId > 0)
{ {
model.FormsName = "默认表单"; //获取分销商信息
var disModel = distributor_InfoRepository.GetList(new RB_Distributor_Info_Extend() { TenantId = TenantId, MallBaseId = MallBaseId, UserId = UserId, AuditStatus = Common.Enum.User.DistributorAuditStatusEnum.Audited }).FirstOrDefault();
if (disModel != null) {
var BasicsModel = distributor_BasicsRepository.GetList(new RB_Distributor_Basics_Extend() { TenantId = TenantId, MallBaseId = MallBaseId }).FirstOrDefault();
if (model.SeparateDistribution == 1) {
var dcList = model.DistributionCommissionList.Where(x => x.DistributorGrade == disModel.GradeId).ToList();
if ((BasicsModel?.IsCommissionResidue ?? 2) == 1) {
model.MaxShare = dcList.Max(x => (x.OneCommission ?? 0) + (x.TwoCommission ?? 0) + (x.ThreeCommission ?? 0));
}
else {
model.MaxShare = dcList.Max(x => x.OneCommission ?? 0);
}
// 这里需注意,可能需要分销 是否提所有返佣控制
if (model.SeparateDistributionMoneyType == 1) {
model.MaxShare = Math.Round(model.MaxShare * MaxSellMoney / 100, 2, MidpointRounding.AwayFromZero);
}
}
else {
if (disModel.GradeId == 0)
{
//拿分销基础配置
if ((BasicsModel?.IsCommissionResidue ?? 2) == 1)
{
model.MaxShare = (BasicsModel?.OneCommission ?? 0) + (BasicsModel?.TwoCommission ?? 0) + (BasicsModel?.ThreeCommission ?? 0);
}
else
{
model.MaxShare = BasicsModel?.OneCommission ?? 0;
}
if ((BasicsModel?.DistributorCommissionType ?? 2) == 1)
{
model.MaxShare = Math.Round(model.MaxShare * MaxSellMoney / 100, 2, MidpointRounding.AwayFromZero);
}
}
else if (disModel.GradeId > 0) {
//获取分销商等级
var disgradeModel = distributor_GradeRepository.GetEntity(disModel.GradeId);
if (disgradeModel != null) {
if ((BasicsModel?.IsCommissionResidue ?? 2) == 1)
{
model.MaxShare = (disgradeModel?.OneCommission ?? 0) + (disgradeModel?.TwoCommission ?? 0) + (disgradeModel?.ThreeCommission ?? 0);
}
else
{
model.MaxShare = disgradeModel?.OneCommission ?? 0;
}
if ((disgradeModel?.DistributionCommissionType ?? 2) == 1)
{
model.MaxShare = Math.Round(model.MaxShare * MaxSellMoney / 100, 2, MidpointRounding.AwayFromZero);
}
}
}
}
}
} }
#endregion
return model; return model;
} }
#endregion #endregion
......
...@@ -13,6 +13,7 @@ using Mall.Model.Extend.Product; ...@@ -13,6 +13,7 @@ using Mall.Model.Extend.Product;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.Json; using Microsoft.Extensions.Configuration.Json;
using Newtonsoft.Json; using Newtonsoft.Json;
using Mall.Repository.BaseSetUp;
namespace Mall.Module.User namespace Mall.Module.User
{ {
...@@ -69,6 +70,18 @@ namespace Mall.Module.User ...@@ -69,6 +70,18 @@ namespace Mall.Module.User
/// 收货地址 /// 收货地址
/// </summary> /// </summary>
private readonly RB_Member_ShippingAddressRepository member_ShippingAddressRepository = new RB_Member_ShippingAddressRepository(); private readonly RB_Member_ShippingAddressRepository member_ShippingAddressRepository = new RB_Member_ShippingAddressRepository();
/// <summary>
/// 区域
/// </summary>
private readonly Rb_destinationRepository destinationRepository = new Rb_destinationRepository();
/// <summary>
/// 商品
/// </summary>
private readonly RB_GoodsRepository goodsRepository = new RB_GoodsRepository();
/// <summary>
/// 收藏表
/// </summary>
private readonly RB_Member_CollectionRepository member_CollectionRepository = new RB_Member_CollectionRepository();
/// <summary> /// <summary>
...@@ -171,7 +184,7 @@ namespace Mall.Module.User ...@@ -171,7 +184,7 @@ namespace Mall.Module.User
}, },
}; };
return member_UserRepository.Exists(wheres); return member_UserRepository.Exists(wheres);
} }
/// <summary> /// <summary>
/// 获取列表 /// 获取列表
...@@ -202,7 +215,7 @@ namespace Mall.Module.User ...@@ -202,7 +215,7 @@ namespace Mall.Module.User
} }
} }
return list; return list;
} }
/// <summary> /// <summary>
/// 获取等级分页列表 /// 获取等级分页列表
...@@ -1571,7 +1584,31 @@ namespace Mall.Module.User ...@@ -1571,7 +1584,31 @@ namespace Mall.Module.User
/// <returns></returns> /// <returns></returns>
public List<RB_Member_ShippingAddress_Extend> GetUserShippingAddressPageList(int pageIndex, int pageSize, out long count, RB_Member_ShippingAddress_Extend demodel) public List<RB_Member_ShippingAddress_Extend> GetUserShippingAddressPageList(int pageIndex, int pageSize, out long count, RB_Member_ShippingAddress_Extend demodel)
{ {
return member_ShippingAddressRepository.GetPageList(pageIndex, pageSize, out count, demodel); var list = member_ShippingAddressRepository.GetPageList(pageIndex, pageSize, out count, demodel);
if (list.Any()) {
string areaIds1 = string.Join(",", list.Select(x => x.Province ?? 0).Distinct());
string areaIds2 = string.Join(",", list.Select(x => x.City ?? 0).Distinct());
string areaIds3 = string.Join(",", list.Select(x => x.District ?? 0).Distinct());
string areaIds = "0";
if (!string.IsNullOrEmpty(areaIds1))
{
areaIds += "," + areaIds1;
}
if (!string.IsNullOrEmpty(areaIds2))
{
areaIds += "," + areaIds2;
}
if (!string.IsNullOrEmpty(areaIds3))
{
areaIds += "," + areaIds3;
}
var arealist = destinationRepository.GetDictvalueListForIds(areaIds);
foreach (var item in list)
{
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 ?? "");
}
}
return list;
} }
/// <summary> /// <summary>
...@@ -1581,7 +1618,275 @@ namespace Mall.Module.User ...@@ -1581,7 +1618,275 @@ namespace Mall.Module.User
/// <returns></returns> /// <returns></returns>
public List<RB_Member_ShippingAddress_Extend> GetUserShippingAddressList(RB_Member_ShippingAddress_Extend demodel) public List<RB_Member_ShippingAddress_Extend> GetUserShippingAddressList(RB_Member_ShippingAddress_Extend demodel)
{ {
return member_ShippingAddressRepository.GetList(demodel); var list = member_ShippingAddressRepository.GetList(demodel);
if (list.Any())
{
string areaIds1 = string.Join(",", list.Select(x => x.Province ?? 0).Distinct());
string areaIds2 = string.Join(",", list.Select(x => x.City ?? 0).Distinct());
string areaIds3 = string.Join(",", list.Select(x => x.District ?? 0).Distinct());
string areaIds = "0";
if (!string.IsNullOrEmpty(areaIds1))
{
areaIds += "," + areaIds1;
}
if (!string.IsNullOrEmpty(areaIds2))
{
areaIds += "," + areaIds2;
}
if (!string.IsNullOrEmpty(areaIds3))
{
areaIds += "," + areaIds3;
}
var arealist = destinationRepository.GetDictvalueListForIds(areaIds);
foreach (var item in list)
{
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 ?? "");
}
}
return list;
}
/// <summary>
/// 获取收货地址详情
/// </summary>
/// <param name="addressId"></param>
/// <returns></returns>
public RB_Member_ShippingAddress_Extend GetUserShippingAddressInfo(int addressId)
{
var model = member_ShippingAddressRepository.GetEntity<RB_Member_ShippingAddress_Extend>(addressId);
model.DistrictAddress = (destinationRepository.GetEntity(model.Province)?.Name ?? "") + " " + (destinationRepository.GetEntity(model.City)?.Name ?? "") + " " + (destinationRepository.GetEntity(model.District)?.Name ?? "");
return model;
}
/// <summary>
/// 新增修改
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public bool SetUserShippingAddress(RB_Member_ShippingAddress_Extend demodel)
{
if (demodel.Id > 0)
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Member_ShippingAddress.Name),demodel.Name},
{ nameof(RB_Member_ShippingAddress.Mobile),demodel.Mobile},
{ nameof(RB_Member_ShippingAddress.Country),demodel.Country},
{ nameof(RB_Member_ShippingAddress.Province),demodel.Province},
{ nameof(RB_Member_ShippingAddress.City),demodel.City},
{ nameof(RB_Member_ShippingAddress.District),demodel.District},
{ nameof(RB_Member_ShippingAddress.Address),demodel.Address},
{ nameof(RB_Member_ShippingAddress.UpdateDate),demodel.UpdateDate}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper{
FiledName=nameof(RB_Member_ShippingAddress.TenantId),
FiledValue=demodel.TenantId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper{
FiledName=nameof(RB_Member_ShippingAddress.MallBaseId),
FiledValue=demodel.MallBaseId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper{
FiledName=nameof(RB_Member_ShippingAddress.UserId),
FiledValue=demodel.UserId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper{
FiledName=nameof(RB_Member_ShippingAddress.Id),
FiledValue=demodel.Id,
OperatorEnum=OperatorEnum.Equal
}
};
return member_ShippingAddressRepository.Update(keyValues, wheres);
}
else {
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper{
FiledName=nameof(RB_Member_ShippingAddress.TenantId),
FiledValue=demodel.TenantId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper{
FiledName=nameof(RB_Member_ShippingAddress.MallBaseId),
FiledValue=demodel.MallBaseId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper{
FiledName=nameof(RB_Member_ShippingAddress.UserId),
FiledValue=demodel.UserId,
OperatorEnum=OperatorEnum.Equal
},
};
if (!member_ShippingAddressRepository.Exists(wheres)) {
demodel.IsDefault = 1;
}
return member_ShippingAddressRepository.Insert(demodel) > 0;
}
}
/// <summary>
/// 设置默认
/// </summary>
/// <param name="addressId"></param>
/// <param name="userId"></param>
/// <returns></returns>
public bool SetUserShippingAddressDefault(int addressId, int userId)
{
var addmodel = member_ShippingAddressRepository.GetEntity(addressId);
int oldId = 0;
if (addmodel.IsDefault != 1) {
var defmodel = member_ShippingAddressRepository.GetList(new RB_Member_ShippingAddress_Extend() { UserId = userId, IsDefault = 1 }).FirstOrDefault();
oldId = defmodel.Id;
}
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Member_ShippingAddress.IsDefault),addmodel.IsDefault==1?2:1},
{ nameof(RB_Member_ShippingAddress.UpdateDate),DateTime.Now}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper{
FiledName=nameof(RB_Member_ShippingAddress.UserId),
FiledValue=userId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper{
FiledName=nameof(RB_Member_ShippingAddress.Id),
FiledValue=addressId,
OperatorEnum=OperatorEnum.Equal
}
};
bool flag = member_ShippingAddressRepository.Update(keyValues, wheres);
if (flag) {
//获取当前默认
if (addmodel.IsDefault != 1 && oldId > 0)
{
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Member_ShippingAddress.IsDefault),2},
{ nameof(RB_Member_ShippingAddress.UpdateDate),DateTime.Now}
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper{
FiledName=nameof(RB_Member_ShippingAddress.UserId),
FiledValue=userId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper{
FiledName=nameof(RB_Member_ShippingAddress.Id),
FiledValue=oldId,
OperatorEnum=OperatorEnum.Equal
}
};
member_ShippingAddressRepository.Update(keyValues1, wheres1);
}
}
return flag;
}
/// <summary>
/// 删除地址
/// </summary>
/// <param name="addressId"></param>
/// <param name="userId"></param>
/// <returns></returns>
public bool DelUserShippingAddressDefault(int addressId, int userId)
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Member_ShippingAddress.Status),1},
{ nameof(RB_Member_ShippingAddress.UpdateDate),DateTime.Now}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper{
FiledName=nameof(RB_Member_ShippingAddress.UserId),
FiledValue=userId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper{
FiledName=nameof(RB_Member_ShippingAddress.Id),
FiledValue=addressId,
OperatorEnum=OperatorEnum.Equal
}
};
return member_ShippingAddressRepository.Update(keyValues, wheres);
}
#endregion
#region 收藏商品
/// <summary>
/// 获取用户收藏商品分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <returns></returns>
public List<RB_Goods_Extend> GetUserCollectionPageList(int pageIndex, int pageSize, out long count, RB_Goods_Extend demodel)
{
var list = goodsRepository.GetMemberCollectGoodsPageList(pageIndex, pageSize, out count, demodel);
if (list.Any())
{
foreach (var item in list)
{
item.CoverImage = "";
if (!string.IsNullOrEmpty(item.CarouselImage) && item.CarouselImage != "[]")
{
List<int> CarouselIdList = JsonConvert.DeserializeObject<List<int>>(item.CarouselImage);
//封面图
item.CoverImage = material_InfoRepository.GetEntity(CarouselIdList[0])?.Path ?? "";
}
}
}
return list;
}
/// <summary>
/// 设置用户收藏商品
/// </summary>
/// <param name="goodsId"></param>
/// <param name="userId"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public bool SetUserCollectionInfo(int goodsId, int userId, int tenantId, int mallBaseId)
{
bool flag = true;
var list = member_CollectionRepository.GetList(new RB_Member_Collection_Extend() { UserId = userId, GoodsId = goodsId, TenantId = tenantId, MallBaseId = mallBaseId });
if (list.Any())
{
//取消收藏
foreach (var item in list) {
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Member_Collection.Status),1},
{ nameof(RB_Member_Collection.UpdateDate),DateTime.Now}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Member_Collection.Id),
FiledValue=item.Id,
OperatorEnum=OperatorEnum.Equal
}
};
flag = member_CollectionRepository.Update(keyValues, wheres);
}
}
else {
//新增收藏
flag = member_CollectionRepository.Insert(new RB_Member_Collection()
{
CreateDate = DateTime.Now,
GoodsId = goodsId,
Id = 0,
MallBaseId = mallBaseId,
Status = 0,
TenantId = tenantId,
Type = 1,
UpdateDate = DateTime.Now,
UserId = userId
}) > 0;
}
return flag;
} }
#endregion #endregion
......
...@@ -196,5 +196,66 @@ inner join rb_goods_category c on g.Id=c.GoodsId ...@@ -196,5 +196,66 @@ inner join rb_goods_category c on g.Id=c.GoodsId
where {where} group by g.Id {orderBy}"; where {where} group by g.Id {orderBy}";
return GetPage<RB_Goods_Extend>(pageIndex, pageSize, out count, sql).ToList(); return GetPage<RB_Goods_Extend>(pageIndex, pageSize, out count, sql).ToList();
} }
/// <summary>
/// 获取会员收藏商品分页列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="dmodel">查询条件</param>
/// <returns></returns>
public List<RB_Goods_Extend> GetMemberCollectGoodsPageList(int pageIndex, int pageSize, out long rowCount, RB_Goods_Extend dmodel)
{
string where = $" 1=1 and col.{nameof(RB_Goods_Extend.Status)}=0";
where += $" and col.Type=1 and col.UserId={dmodel.UserId} and g.{nameof(RB_Goods_Extend.Status)}=0 and g.{nameof(RB_Goods_Extend.GoodsStatus)}=1";
if (dmodel.TenantId > 0)
{
where += $@" and col.{nameof(RB_Goods_Extend.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0)
{
where += $@" and col.{nameof(RB_Goods_Extend.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.Id > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.Id)}={dmodel.Id}";
}
if (!string.IsNullOrEmpty(dmodel.GoodsIds))
{
where += $@" and g.{nameof(RB_Goods_Extend.Id)} in({dmodel.GoodsIds})";
}
if (!string.IsNullOrEmpty(dmodel.Name))
{
where += $@" and g.{nameof(RB_Goods_Extend.Name)} like '%{dmodel.Name}%'";
}
if (dmodel.GoodsStatus > 0)
{
where += $@" and g.{nameof(RB_Goods_Extend.GoodsStatus)}={dmodel.GoodsStatus}";
}
if (dmodel.IsSelectSellOut == 1)
{
where += $@" and g.{nameof(RB_Goods_Extend.InventoryNum)}<=0";
}
if (!string.IsNullOrEmpty(dmodel.CategoryIds))
{
where += $@" and c.{nameof(RB_Goods_Category.CategoryId)} in({dmodel.CategoryIds})";
}
if (!string.IsNullOrEmpty(dmodel.StartTime))
{
where += $@" and g.{nameof(RB_Goods_Extend.CreateDate)} >='{dmodel.StartTime}'";
}
if (!string.IsNullOrEmpty(dmodel.EndTime))
{
where += $@" and g.{nameof(RB_Goods_Extend.CreateDate)} <='{dmodel.EndTime + " 23:59:59"}'";
}
string sql = $@"select g.* from
rb_member_collection col
inner join RB_Goods g on col.GoodsId=g.Id
inner join rb_goods_category c on g.Id=c.GoodsId
where {where} group by g.Id order by col.Id desc";
return GetPage<RB_Goods_Extend>(pageIndex, pageSize, out rowCount, sql).ToList();
}
} }
} }
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Model.Entity.User;
using Mall.Model.Extend.User;
using System.Linq;
namespace Mall.Repository.User
{
/// <summary>
/// 用户收藏商品仓储层
/// </summary>
public class RB_Member_CollectionRepository : RepositoryBase<RB_Member_Collection>
{
/// <summary>
/// 分页列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="dmodel">查询条件</param>
/// <returns></returns>
public List<RB_Member_Collection_Extend> GetPageList(int pageIndex, int pageSize, out long rowCount, RB_Member_Collection_Extend dmodel)
{
string where = $" 1=1 and {nameof(RB_Member_Collection.Status)}=0 ";
if (dmodel.TenantId > 0) {
where += $@" and {nameof(RB_Member_Collection.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0)
{
where += $@" and {nameof(RB_Member_Collection.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.Type > 0) {
where += $@" and {nameof(RB_Member_Collection.Type)} ={dmodel.Type}";
}
if (dmodel.UserId > 0) {
where += $@" and {nameof(RB_Member_Collection.UserId)} ={dmodel.UserId}";
}
if (dmodel.GoodsId > 0)
{
where += $@" and {nameof(RB_Member_Collection.GoodsId)} ={dmodel.GoodsId}";
}
string sql = $@"select * from RB_Member_Collection where {where} order by Id desc";
return GetPage<RB_Member_Collection_Extend>(pageIndex, pageSize, out rowCount, sql).ToList();
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Member_Collection_Extend> GetList(RB_Member_Collection_Extend dmodel)
{
string where = $" 1=1 and {nameof(RB_Member_Collection.Status)}=0 ";
if (dmodel.TenantId > 0)
{
where += $@" and {nameof(RB_Member_Collection.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0)
{
where += $@" and {nameof(RB_Member_Collection.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.Type > 0)
{
where += $@" and {nameof(RB_Member_Collection.Type)} ={dmodel.Type}";
}
if (dmodel.UserId > 0)
{
where += $@" and {nameof(RB_Member_Collection.UserId)} ={dmodel.UserId}";
}
if (dmodel.GoodsId > 0)
{
where += $@" and {nameof(RB_Member_Collection.GoodsId)} ={dmodel.GoodsId}";
}
string sql = $@"select * from RB_Member_Collection where {where} order by Id desc";
return Get<RB_Member_Collection_Extend>(sql).ToList();
}
}
}
...@@ -37,6 +37,9 @@ namespace Mall.Repository.User ...@@ -37,6 +37,9 @@ namespace Mall.Repository.User
if (!string.IsNullOrEmpty(dmodel.Name)) { if (!string.IsNullOrEmpty(dmodel.Name)) {
where += $@" and {nameof(RB_Member_ShippingAddress.Name)} like '%{dmodel.Name}%'"; where += $@" and {nameof(RB_Member_ShippingAddress.Name)} like '%{dmodel.Name}%'";
} }
if (!string.IsNullOrEmpty(dmodel.Mobile)) {
where += $@" and {nameof(RB_Member_ShippingAddress.Mobile)} like '%{dmodel.Mobile}%'";
}
if (dmodel.UserId > 0) { if (dmodel.UserId > 0) {
where += $@" and {nameof(RB_Member_ShippingAddress.UserId)} ={(int)dmodel.UserId}"; where += $@" and {nameof(RB_Member_ShippingAddress.UserId)} ={(int)dmodel.UserId}";
} }
...@@ -68,6 +71,10 @@ namespace Mall.Repository.User ...@@ -68,6 +71,10 @@ namespace Mall.Repository.User
{ {
where += $@" and {nameof(RB_Member_ShippingAddress.Name)} like '%{dmodel.Name}%'"; where += $@" and {nameof(RB_Member_ShippingAddress.Name)} like '%{dmodel.Name}%'";
} }
if (!string.IsNullOrEmpty(dmodel.Mobile))
{
where += $@" and {nameof(RB_Member_ShippingAddress.Mobile)} like '%{dmodel.Mobile}%'";
}
if (dmodel.UserId > 0) if (dmodel.UserId > 0)
{ {
where += $@" and {nameof(RB_Member_ShippingAddress.UserId)} ={(int)dmodel.UserId}"; where += $@" and {nameof(RB_Member_ShippingAddress.UserId)} ={(int)dmodel.UserId}";
......
...@@ -59,24 +59,6 @@ namespace Mall.WebApi.Controllers ...@@ -59,24 +59,6 @@ namespace Mall.WebApi.Controllers
} }
} }
public RequestParm AppletRequestParm
{
get
{
#region 读取post参数
var requestMsg = Request.HttpContext.Items[GlobalKey.UserPostInfo];
var requestParm = JsonConvert.DeserializeObject<RequestParm>(requestMsg.ToString());
if (Request.HttpContext.Items[GlobalKey.TokenUserInfo] != null)
{
JObject parms = JObject.Parse(Request.HttpContext.Items[GlobalKey.TokenUserInfo].ToString());
requestParm.uid = parms.GetStringValue("uid");
}
#endregion
//根据token 获取uid
return requestParm;
}
}
/// <summary> /// <summary>
/// 小程序用户缓存 /// 小程序用户缓存
/// </summary> /// </summary>
......
...@@ -15,6 +15,7 @@ using Mall.CacheManager.User; ...@@ -15,6 +15,7 @@ using Mall.CacheManager.User;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Mall.Common; using Mall.Common;
using Mall.Module.Product; using Mall.Module.Product;
using Mall.Model.Extend.User;
namespace Mall.WebApi.Controllers.MallBase namespace Mall.WebApi.Controllers.MallBase
{ {
...@@ -166,101 +167,243 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -166,101 +167,243 @@ namespace Mall.WebApi.Controllers.MallBase
if (GoodsId <= 0) { if (GoodsId <= 0) {
return ApiResult.ParamIsNull(); return ApiResult.ParamIsNull();
} }
int UserId = prams.GetInt("UserId", 0);
RB_Member_User_Extend userModel = new RB_Member_User_Extend();
if (UserId > 0) {
userModel = productModule.GetMemberUserInfo(UserId);
}
var model = productModule.GetAppletGoodsInfo(GoodsId, req.TenantId, req.MallBaseId); RB_Goods_Extend model = productModule.GetAppletGoodsInfo(GoodsId, UserId, req.TenantId, req.MallBaseId);
return ApiResult.Success("", new
#region 组装价格
List<object> priceList = new List<object>();
if (model.IsCustomSpecification == 1) {
if (model.SpecificationPriceList.Any() && model.SpecificationList.Any()) {
foreach (var item in model.SpecificationPriceList) {
var ssarr = item.SpecificationSort.Split(':');
int Sort = Convert.ToInt32(ssarr[0]);
string pic_url = model.SpecificationList[0].SpecificationValueList.Where(x => x.Sort == Sort).FirstOrDefault()?.ImagePath;
List<object> attr_list = new List<object>();
for (int i = 0; i < ssarr.Length; i++) {
var smodel = model.SpecificationList[i];
var svmodel = smodel.SpecificationValueList.Where(x => x.Sort == Convert.ToInt32(ssarr[i])).FirstOrDefault();
attr_list.Add(new{
attr_group_name = smodel.Name,
attr_group_id = smodel.Sort,
attr_id = svmodel.Id,
attr_name = svmodel.Name
});
}
decimal price_member = item.SellingPrice ?? 0;//未设会员价格的话 就为销售价格
List<object> member_price_list = new List<object>();
if (model.EnjoyMember == 1 && model.SeparateSetMember == 1 && UserId > 0 && userModel.MemberGrade > 0) {
if (model.MemberPriceList.Any()) {
var mlist = model.MemberPriceList.Where(x => x.SpecificationSort == item.SpecificationSort).ToList();
foreach (var qitem in mlist) {
member_price_list.Add(new {
member_grade = qitem.MemberGrade,
member_price = qitem.MemberPrice
});
if (qitem.MemberGrade == userModel.MemberGrade) {
price_member = qitem.MemberPrice ?? 0;
}
}
}
}
priceList.Add(new {
id = item.Id,
goods_id = model.Id,
sign_id = item.SpecificationSort,
stock = item.InventoryNum,
price = item.SellingPrice,
no = item.GoodsNumbers,
weight = item.GoodsWeight,
pic_url,
is_delete = item.Status,
attr_list,
price_member,
member_price_list
});
}
}
}
#endregion
#region 赠送积分
int Integral = 0;
if (model.IntegralPresent > 0) {
Integral = model.IntegralPresent ?? 0;
if (model.IntegralPresentType == 2) {
Integral = Convert.ToInt32(Math.Floor((model.SellingPrice ?? 0) * (model.IntegralPresent ?? 0) / 100));
}
}
#endregion
#region 会员价格
decimal price_member_max = 0, price_member_min = 0, price_min = 0, price_max = 0;
if (model.EnjoyMember == 1 && model.SeparateSetMember == 1 && model.MemberPriceList.Any())
{ {
model.Id, price_member_min = model.MemberPriceList.Min(x => x.MemberPrice ?? 0);
model.Name, price_member_max = model.MemberPriceList.Max(x => x.MemberPrice ?? 0);
model.CarouselImage, if (userModel.MemberGrade > 0)
model.VideoAddress, {
model.CustomShareTitles, price_min = model.MemberPriceList.Where(x => x.MemberGrade == userModel.MemberGrade).Min(x => x.MemberPrice ?? 0);
model.CustomShareImage, price_max = model.MemberPriceList.Where(x => x.MemberGrade == userModel.MemberGrade).Max(x => x.MemberPrice ?? 0);
model.CustomShareImagePath, }
model.GoodsStatus, }
model.InventoryNum, else {
model.DefaultSpecificationName, var memeberList = productModule.GetMemberGradeList(new RB_Member_Grade_Extend() { TenantId = req.TenantId, MallBaseId = req.MallBaseId });
model.IsCustomSpecification, if (model.IsCustomSpecification == 1)
model.Sort, {
model.SellingPrice, price_member_min = price_min = model.SpecificationPriceList.Min(x => x.SellingPrice ?? 0);
model.OriginalPrice, price_member_max = price_max = model.SpecificationPriceList.Max(x => x.SellingPrice ?? 0);
model.Unit, }
model.CostPrice, else {
model.IsGoodsNegotiable, price_member_min = price_member_max = price_min = price_max = model.SellingPrice ?? 0;
model.SalesNum, }
model.GoodsNumbers, if (memeberList.Any())
model.GoodsWeight, {
model.IsDefaultService, List<decimal> pricelist = new List<decimal>();
model.GoodsService, foreach (var item in memeberList)
model.FreightId, {
model.FreightName, pricelist.Add(price_member_min * (item.Discount ?? 10) / 10);
model.FormsId, pricelist.Add(price_member_max * (item.Discount ?? 10) / 10);
model.FormsName, }
model.LimitBuyGoodsNum, price_member_min = pricelist.Min(x => x);
model.LimitBuyOrderNum, price_member_max = pricelist.Max(x => x);
model.FullNumPinkage, if (userModel.MemberGrade > 0)
model.FullMoneyPinkage, {
model.IsAreaBuy, if (price_min > (model.SellingPrice ?? 0)) { price_min = model.SellingPrice ?? 0; }
model.IntegralPresent, if (price_max < (model.SellingPrice ?? 0)) { price_max = model.SellingPrice ?? 0; }
model.IntegralPresentType, price_min = price_member_min * (memeberList.Where(x => x.Id == userModel.MemberGrade).FirstOrDefault()?.Discount ?? 10) / 10;
model.PointsDeduction, price_max = price_member_max * (memeberList.Where(x => x.Id == userModel.MemberGrade).FirstOrDefault()?.Discount ?? 10) / 10;
model.PointsDeductionType, }
model.IsMultipleDeduction, }
model.GoodsDetails, }
model.SeparateDistribution, price_member_max = Math.Round(price_member_max, 2, MidpointRounding.AwayFromZero);
model.SeparateDistributionType, price_member_min = Math.Round(price_member_min, 2, MidpointRounding.AwayFromZero);
model.SeparateDistributionMoneyType, price_min = Math.Round(price_min, 2, MidpointRounding.AwayFromZero);
model.EnjoyMember, price_max = Math.Round(price_max, 2, MidpointRounding.AwayFromZero);
model.SeparateSetMember, #endregion
model.IsQuickBuy,
CategoryList= model.CategoryList.Select(x=>new { return ApiResult.Success("success", new
x.Id, {
x.CategoryId, goods = new
x.CategoryName {
}), id = model.Id,
SpecificationList= model.SpecificationList.Select(x=>new { mall_id = model.MallBaseId,
x.Id, mch_id = model.TenantId,//暂 商户id
x.EnabledImage, //goods_warehouse_id = 0,//
x.Name, status = model.GoodsStatus,
x.Sort, price = model.SellingPrice,
SpecificationValueList= x.SpecificationValueList.Select(y=>new { use_attr = model.IsCustomSpecification,
y.Id, attr_groups = model.SpecificationList.Select(x => new
y.Image, {
y.ImagePath, attr_group_id = x.Sort,
y.Name, attr_group_name = x.Name,
y.Sort attr_list = x.SpecificationValueList.Select(z => new
}) {
}), attr_id = z.Sort,
SpecificationPriceList= model.SpecificationPriceList.Select(x=>new { attr_name = z.Name,
x.Id, pic_url = z.ImagePath
x.GoodsNumbers, })
x.GoodsWeight, }),
x.InventoryNum, goods_stock = model.InventoryNum,
x.SellingPrice, virtual_sales = model.SalesNum,
x.SpecificationSort confine_count = model.LimitBuyGoodsNum,
}), //pieces = 0,//
AreaList= model.AreaList.Select(x=>new { //forehead = 0,//
x.Id, freight_id = model.FreightId,
x.AreaId, give_integral = model.IntegralPresent,
x.AreaName, give_integral_type = model.IntegralPresentType,
x.AreaType forehead_integral = model.PointsDeduction,//暂 积分抵扣
}), forehead_integral_type = model.PointsDeductionType,//暂 积分抵扣类型
DistributionCommissionList= model.DistributionCommissionList.Select(x=>new { //accumulative = 0,//
x.Id, individual_share = userModel?.IsDistributor??2,// 是否分销商
x.DistributorGrade, //attr_setting_type = 0,//
x.OneCommission, //is_level = 1,//
x.SpecificationSort, //is_level_alone = 0,//
x.ThreeCommission, //share_type = 0,
x.TwoCommission //sign = "",
}), app_share_pic = model.CustomShareImagePath,
MemberPriceList= model.MemberPriceList.Select(x=>new { app_share_title = model.CustomShareTitles,
x.Id, is_default_services = model.IsDefaultService,
x.MemberGrade, sort = model.Sort,
x.MemberPrice, created_at = model.CreateDate.HasValue ? model.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
x.SpecificationSort updated_at = model.UpdateDate.HasValue ? model.UpdateDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
}), deleted_at = "",
model.CarouselImageList, is_delete = model.Status,
model.ServiceList payment_people = 0,//销售信息
payment_num = 0,//
payment_amount = 0,//
payment_order = 0,//
confine_order_count = model.LimitBuyOrderNum,
is_area_limit = model.IsAreaBuy,
area_limit = new List<object>() { new { list = model.AreaList.Select(x => new {
area_id=x.AreaId,
area_name=x.AreaName,
area_type=x.AreaType
}) } },
form_id = model.FormsId,
sales = model.SalesNum + 0,//已售出数量 + 订单数量//
name = model.Name,
original_price = model.OriginalPrice,
cover_pic = model.CoverImage,
unit = model.Unit,
detail = model.GoodsDetails,
video_url = model.VideoAddress,
//level_show = 2,//
is_sales = model.GoodsStatus == 1 && model.InventoryNum > 0 ? 1 : 2,//是否可购买
attr = priceList,
goods_num = model.InventoryNum,
goods_no = model.GoodsNumbers,
goods_weight = model.GoodsWeight,
services = model.ServiceList.Select(x => new
{
id = x.Id,
name = x.Name
}),
price_min,
price_max,
pic_url = model.CarouselImageList.Select(x => new
{
id = x.Id,
pic_url = x.Path
}),
share = model.MaxShare,//分销佣金
favorite = model.Favorite,//是否收藏
//goods_marketing = new
//{
// limit = "",
// pickup = "",
// shipping = ""
//},
goods_marketing_award = new
{
integral = new
{
title = "购买可得" + Integral + "积分"
}
},
//plugin_extra = new List<object>(),
express = model.Express,//快递费用 读取默认收货地址 如果没有为0 如果有 根据商品运费匹配 找出快递费用
price_member_max,
price_member_min,
extra_quick_share = new
{
share_pic = model.CarouselImageList.Select(x => new
{
id = x.Id,
pic_url = x.Path
}),
share_text = model.Name,
mall_name = model.MallName,
format_time = model.UpdateDate.HasValue ? model.UpdateDate.Value.ToString("yyyy-MM-dd") : ""
},
is_quick_shop = model.IsQuickBuy,
is_sell_well = model.IsSellWell,
is_negotiable = model.IsGoodsNegotiable,
//cats = new List<string>()
},
delivery = ""
}); });
} }
......
...@@ -1408,7 +1408,7 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -1408,7 +1408,7 @@ namespace Mall.WebApi.Controllers.MallBase
foreach (var qitem in item.SpecificationValueList) foreach (var qitem in item.SpecificationValueList)
{ {
for (var j = 1; j <= MGBJNum; j++) { for (var j = 1; j <= MGBJNum; j++) {
KeyList[KeyIndex] = KeyList[KeyIndex] + "," + qitem.Sort; KeyList[KeyIndex] = KeyList[KeyIndex] + ":" + qitem.Sort;
KeyIndex++; KeyIndex++;
} }
} }
...@@ -1650,6 +1650,7 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -1650,6 +1650,7 @@ namespace Mall.WebApi.Controllers.MallBase
} }
} }
demodel.IsQuickBuy ??= 2; demodel.IsQuickBuy ??= 2;
demodel.IsSellWell ??= 2;
demodel.GoodsType ??= Common.Enum.Goods.OrderTypeEnum.Mall; demodel.GoodsType ??= Common.Enum.Goods.OrderTypeEnum.Mall;
bool flag = productModule.SetProductGoodsInfo(demodel); bool flag = productModule.SetProductGoodsInfo(demodel);
......
...@@ -118,6 +118,7 @@ namespace Mall.WebApi.Controllers.User ...@@ -118,6 +118,7 @@ namespace Mall.WebApi.Controllers.User
MallBaseId = demodel.MallBaseId, MallBaseId = demodel.MallBaseId,
MallName = mmodel?.MallName ?? "", MallName = mmodel?.MallName ?? "",
Mobile = demodel.Moblie, Mobile = demodel.Moblie,
UserId = UserId,
TenantId = demodel.TenantId, TenantId = demodel.TenantId,
Name = demodel.Name, Name = demodel.Name,
OpenId = demodel.OpenId, OpenId = demodel.OpenId,
......
...@@ -14,6 +14,7 @@ using Mall.Common.Enum.User; ...@@ -14,6 +14,7 @@ using Mall.Common.Enum.User;
using Mall.CacheManager.User; using Mall.CacheManager.User;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Mall.Common; using Mall.Common;
using Mall.Model.Extend.Product;
namespace Mall.WebApi.Controllers.User namespace Mall.WebApi.Controllers.User
{ {
...@@ -38,6 +39,7 @@ namespace Mall.WebApi.Controllers.User ...@@ -38,6 +39,7 @@ namespace Mall.WebApi.Controllers.User
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(req.msg.ToString()); ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(req.msg.ToString());
RB_Member_ShippingAddress_Extend demodel = JsonConvert.DeserializeObject<RB_Member_ShippingAddress_Extend>(req.msg.ToString()); RB_Member_ShippingAddress_Extend demodel = JsonConvert.DeserializeObject<RB_Member_ShippingAddress_Extend>(req.msg.ToString());
demodel.UserId = userInfo.UserId;
demodel.TenantId = userInfo.TenantId; demodel.TenantId = userInfo.TenantId;
demodel.MallBaseId = userInfo.MallBaseId; demodel.MallBaseId = userInfo.MallBaseId;
var list = userModule.GetUserShippingAddressPageList(pagelist.pageIndex, pagelist.pageSize, out long count, demodel); var list = userModule.GetUserShippingAddressPageList(pagelist.pageIndex, pagelist.pageSize, out long count, demodel);
...@@ -51,6 +53,7 @@ namespace Mall.WebApi.Controllers.User ...@@ -51,6 +53,7 @@ namespace Mall.WebApi.Controllers.User
x.Province, x.Province,
x.City, x.City,
x.District, x.District,
x.DistrictAddress,
x.Address, x.Address,
x.PostCode, x.PostCode,
x.Lonlat, x.Lonlat,
...@@ -71,6 +74,7 @@ namespace Mall.WebApi.Controllers.User ...@@ -71,6 +74,7 @@ namespace Mall.WebApi.Controllers.User
var userInfo = AppletUserInfo; var userInfo = AppletUserInfo;
RB_Member_ShippingAddress_Extend demodel = JsonConvert.DeserializeObject<RB_Member_ShippingAddress_Extend>(req.msg.ToString()); RB_Member_ShippingAddress_Extend demodel = JsonConvert.DeserializeObject<RB_Member_ShippingAddress_Extend>(req.msg.ToString());
demodel.UserId = userInfo.UserId;
demodel.TenantId = userInfo.TenantId; demodel.TenantId = userInfo.TenantId;
demodel.MallBaseId = userInfo.MallBaseId; demodel.MallBaseId = userInfo.MallBaseId;
var list = userModule.GetUserShippingAddressList(demodel); var list = userModule.GetUserShippingAddressList(demodel);
...@@ -83,6 +87,7 @@ namespace Mall.WebApi.Controllers.User ...@@ -83,6 +87,7 @@ namespace Mall.WebApi.Controllers.User
x.Province, x.Province,
x.City, x.City,
x.District, x.District,
x.DistrictAddress,
x.Address, x.Address,
x.PostCode, x.PostCode,
x.Lonlat, x.Lonlat,
...@@ -104,8 +109,177 @@ namespace Mall.WebApi.Controllers.User ...@@ -104,8 +109,177 @@ namespace Mall.WebApi.Controllers.User
if (AddressId <= 0) { if (AddressId <= 0) {
return ApiResult.ParamIsNull("请传递收货地址"); return ApiResult.ParamIsNull("请传递收货地址");
} }
var model = userModule.GetUserShippingAddressInfo(AddressId);
if (model.TenantId != userInfo.TenantId || model.MallBaseId != userInfo.MallBaseId || model.UserId != userInfo.UserId)
{
return ApiResult.ParamIsNull("未查询到相关信息");
}
return ApiResult.Success("", new
{
model.Id,
model.Name,
model.Mobile,
model.Country,
model.Province,
model.City,
model.District,
model.DistrictAddress,
model.Address,
model.PostCode,
model.Lonlat,
model.IsDefault
});
}
/// <summary>
/// 新增修改地址
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetUserShippingAddress() {
var req = RequestParm;
var userInfo = AppletUserInfo;
RB_Member_ShippingAddress_Extend demodel = JsonConvert.DeserializeObject<RB_Member_ShippingAddress_Extend>(req.msg.ToString());
if (string.IsNullOrEmpty(demodel.Name)) {
return ApiResult.ParamIsNull("请输入收货人");
}
if (string.IsNullOrEmpty(demodel.Mobile)) {
return ApiResult.ParamIsNull("请输入联系电话");
}
if ((demodel.Province ?? 0) <= 0 || (demodel.City ?? 0) <= 0 || (demodel.District ?? 0) <= 0) {
return ApiResult.ParamIsNull("请选择区域");
}
if (string.IsNullOrEmpty(demodel.Address)) {
return ApiResult.ParamIsNull("请输入详细地址");
}
demodel.IsDefault ??= 2;
demodel.PostCode ??= "";
demodel.Lonlat ??= "";
demodel.Country ??= 2;
demodel.UserId = userInfo.UserId;
demodel.TenantId = userInfo.TenantId;
demodel.MallBaseId = userInfo.MallBaseId;
demodel.CreateDate = DateTime.Now;
demodel.UpdateDate = DateTime.Now;
demodel.Status = 0;
bool flag = userModule.SetUserShippingAddress(demodel);
if (flag)
{
return ApiResult.Success();
}
else {
return ApiResult.Failed();
}
}
/// <summary>
/// 设置地址默认
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetUserShippingAddressDefault() {
var req = RequestParm;
var userInfo = AppletUserInfo;
JObject prams = JObject.Parse(req.msg.ToString());
int AddressId = prams.GetInt("AddressId", 0);
if (AddressId <= 0) {
return ApiResult.ParamIsNull();
}
return ApiResult.Success(); bool flag = userModule.SetUserShippingAddressDefault(AddressId, userInfo.UserId);
if (flag)
{
return ApiResult.Success();
}
else {
return ApiResult.Failed();
}
}
/// <summary>
/// 删除地址
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult DelUserShippingAddress()
{
var req = RequestParm;
var userInfo = AppletUserInfo;
JObject prams = JObject.Parse(req.msg.ToString());
int AddressId = prams.GetInt("AddressId", 0);
if (AddressId <= 0)
{
return ApiResult.ParamIsNull();
}
bool flag = userModule.DelUserShippingAddressDefault(AddressId, userInfo.UserId);
if (flag)
{
return ApiResult.Success();
}
else
{
return ApiResult.Failed();
}
}
#endregion
#region 收藏商品
/// <summary>
/// 获取收藏商品分页列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetUserCollectionPageList()
{
var req = RequestParm;
var userInfo = AppletUserInfo;
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(req.msg.ToString());
RB_Goods_Extend demodel = JsonConvert.DeserializeObject<RB_Goods_Extend>(req.msg.ToString());
demodel.UserId = userInfo.UserId;
demodel.TenantId = userInfo.TenantId;
demodel.MallBaseId = userInfo.MallBaseId;
var list = userModule.GetUserCollectionPageList(pagelist.pageIndex, pagelist.pageSize, out long count, demodel);
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list.Select(x => new
{
x.Id,
x.Name,
x.CoverImage,
x.SellingPrice,
x.SalesNum
});
return ApiResult.Success("", pagelist);
}
/// <summary>
/// 用户收藏/取消收藏商品
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetUserCollectionInfo() {
var req = RequestParm;
var userInfo = AppletUserInfo;
JObject parms = JObject.Parse(req.msg.ToString());
int GoodsId = parms.GetInt("GoodsId", 0);
if (GoodsId <= 0) {
return ApiResult.ParamIsNull();
}
bool flag = userModule.SetUserCollectionInfo(GoodsId, userInfo.UserId, userInfo.TenantId, userInfo.MallBaseId);
if (flag)
{
return ApiResult.Success();
}
else {
return ApiResult.Failed();
}
} }
#endregion #endregion
......
...@@ -106,14 +106,14 @@ namespace Mall.WebApi.Filter ...@@ -106,14 +106,14 @@ namespace Mall.WebApi.Filter
actionContext.Result = new Microsoft.AspNetCore.Mvc.JsonResult(new ApiResult actionContext.Result = new Microsoft.AspNetCore.Mvc.JsonResult(new ApiResult
{ {
resultCode = (int)ResultCode.FormRepeatSubmit, resultCode = (int)ResultCode.FormRepeatSubmit,
message = "表单重复提交", message = "表单重复提交,请稍后再试",
data = null data = null
}); });
} }
else else
{ {
//默认3秒钟之内不能重复提交 //默认2秒钟之内不能重复提交
UserReidsCache.Set(cachedKey, 1, 3); UserReidsCache.Set(cachedKey, 1, 2);
} }
} }
catch catch
......
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