Commit b15c49bc authored by 吴春's avatar 吴春

合并东哥代码

parents 2ebb5782 6a8e8c98
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Net;
using System.IO;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
namespace Mall.Common.Plugin
{
public class AliyunApiSearchDemo
{
//private const String host = "https://wdexpress.market.alicloudapi.com";
//private const String path = "/gxali";
private const String method = "GET";
//private const String appcode = "82a534b5a9d04bbca2358715436b48ff";//开通服务后 买家中心-查看AppCode
public static string GetExpressInfo(string ExpressNo,string ExpressType,string AppCode,string ReqUrl)
{
String querys = @$"n={ExpressNo}&t={ExpressType}";
String bodys = "";
String url = ReqUrl;
HttpWebRequest httpRequest = null;
HttpWebResponse httpResponse = null;
if (0 < querys.Length)
{
url = url + "?" + querys;
}
if (ReqUrl.Contains("https://"))
{
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));
}
else
{
httpRequest = (HttpWebRequest)WebRequest.Create(url);
}
httpRequest.Method = method;
httpRequest.Headers.Add("Authorization", "APPCODE " + AppCode);
if (0 < bodys.Length)
{
byte[] data = Encoding.UTF8.GetBytes(bodys);
using (Stream stream = httpRequest.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
}
try
{
httpResponse = (HttpWebResponse)httpRequest.GetResponse();
}
catch (WebException ex)
{
httpResponse = (HttpWebResponse)ex.Response;
}
Stream st = httpResponse.GetResponseStream();
StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
return reader.ReadToEnd();
}
public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
return true;
}
}
}
......@@ -11,11 +11,11 @@ namespace Mall.Common.Plugin
public class KdApiSearchDemo
{
//电商ID
private string EBusinessID = "1644004";
//private string EBusinessID = "1644004";
//电商加密私钥,快递鸟提供,注意保管,不要泄漏
private string AppKey = "1cff9561-518d-42b3-b4a0-889faeda6111";
//private string AppKey = "1cff9561-518d-42b3-b4a0-889faeda6111";
//请求url
private string ReqURL = "http://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx";
//private string ReqURL = "http://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx";
/// <summary>
/// Json方式 查询订单物流轨迹
......@@ -24,9 +24,9 @@ namespace Mall.Common.Plugin
/// <param name="LogisticCode"></param>
/// <param name="OrderCode"></param>
/// <returns></returns>
public string getOrderTracesByJson(string ShipperCode, string LogisticCode, string OrderCode = "")
public string getOrderTracesByJson(string ShipperCode, string LogisticCode, string EBusinessID, string AppKey, string ReqURL)
{
string requestData = "{'OrderCode':'" + OrderCode + "','ShipperCode':'" + ShipperCode + "','LogisticCode':'" + LogisticCode + "'}";
string requestData = "{'OrderCode':'','ShipperCode':'" + ShipperCode + "','LogisticCode':'" + LogisticCode + "'}";
Dictionary<string, string> param = new Dictionary<string, string>();
param.Add("RequestData", HttpUtility.UrlEncode(requestData, Encoding.UTF8));
......
using VT.FW.DB;
using Mall.Common.Enum.MallBase;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.BaseSetUp
{
/// <summary>
/// 快递配置
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Express_Config
{
public int Id { get; set; }
/// <summary>
/// 别名
/// </summary>
public string Name { get; set; }
/// <summary>
/// 快递类型1-阿里,2-快递鸟
/// </summary>
public int? Type { get; set; }
/// <summary>
/// appid
/// </summary>
public string AppID { get; set; }
/// <summary>
/// key
/// </summary>
public string AppKey { get; set; }
/// <summary>
/// 秘钥
/// </summary>
public string AppSecret { get; set; }
/// <summary>
/// code
/// </summary>
public string AppCode { get; set; }
/// <summary>
/// 请求
/// </summary>
public string RquUrl { get; set; }
/// <summary>
/// 商户id
/// </summary>
public int TenantId { get; set; }
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId { get; set; }
/// <summary>
/// 1-是 2否
/// </summary>
public int? IsDefault { get; set; }
public int? Status { get; set; }
public DateTime CreateDate { get; set; }
public DateTime UpdateDate { get; set; }
}
}
......@@ -326,5 +326,9 @@ namespace Mall.Model.Entity.Product
/// </summary>
public int StoresId { get; set; }
/// <summary>
/// 购买抵扣佣金金额
/// </summary>
public decimal? DeductionCommission { get; set; }
}
}
......@@ -124,6 +124,10 @@ namespace Mall.Model.Entity.Product
/// </summary>
public int? IsRemit { get; set; }
/// <summary>
/// 购买抵扣佣金
/// </summary>
public decimal? DeductionCommission { get; set; }
}
......
......@@ -356,6 +356,9 @@ namespace Mall.Model.Entity.Product
public int? ServicepersonalId { get; set; }
/// <summary>
/// 购买抵扣佣金金额
/// </summary>
public decimal? DeductionCommission { get; set; }
/// 服务日期
/// </summary>
public string ServiceDate { get; set; }
......
......@@ -167,5 +167,10 @@ namespace Mall.Model.Entity.User
/// 粉象等级图标
/// </summary>
public string Icon { get; set; }
/// <summary>
/// 返佣类型 1正常返佣 2购买抵扣
/// </summary>
public int? CommissionType { get; set; }
}
}
......@@ -31,6 +31,10 @@ namespace Mall.Module.BaseSetUp
private readonly RB_FreeShippingRepository freeShippingRepository = new RB_FreeShippingRepository();
private readonly RB_MicroShop_BasicsRepository microShopBasicsRepository = new RB_MicroShop_BasicsRepository();
/// <summary>
/// 快递配置
/// </summary>
private readonly RB_Express_ConfigRepository express_ConfigRepository = new RB_Express_ConfigRepository();
......@@ -956,6 +960,80 @@ namespace Mall.Module.BaseSetUp
}
#endregion
#region 快递配置
/// <summary>
/// 获取列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Express_Config> GetExpressConfigList(RB_Express_Config query)
{
return express_ConfigRepository.GetListRepository(query);
}
/// <summary>
/// 新增修改快递配置
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public bool SetExpressConfig(RB_Express_Config query)
{
if (query.IsDefault == 1)
{
//所有的先默认为非默认
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Express_Config.IsDefault),2}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Express_Config.TenantId),
FiledValue=query.TenantId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Express_Config.MallBaseId),
FiledValue=query.MallBaseId,
OperatorEnum=OperatorEnum.Equal
}
};
express_ConfigRepository.Update(keyValues, wheres);
}
if (query.Id > 0)
{
//所有的先默认为非默认
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Express_Config.Name),query.Name},
{ nameof(RB_Express_Config.IsDefault),query.IsDefault},
{ nameof(RB_Express_Config.AppID),query.AppID},
{ nameof(RB_Express_Config.AppKey),query.AppKey},
{ nameof(RB_Express_Config.AppSecret),query.AppSecret},
{ nameof(RB_Express_Config.AppCode),query.AppCode},
{ nameof(RB_Express_Config.RquUrl),query.RquUrl},
{ nameof(RB_Express_Config.UpdateDate),DateTime.Now}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Express_Config.TenantId),
FiledValue=query.TenantId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Express_Config.MallBaseId),
FiledValue=query.MallBaseId,
OperatorEnum=OperatorEnum.Equal
}
};
return express_ConfigRepository.Update(keyValues, wheres);
}
else
{
return express_ConfigRepository.Insert(query) > 0;
}
}
#endregion
#region 分类包邮规则
/// <summary>
......
......@@ -311,6 +311,10 @@ namespace Mall.Module.Product
/// 车辆颜色
/// </summary>
private RB_GuideCar_CarColorRepository guideCar_CarColorRepository = new RB_GuideCar_CarColorRepository();
/// <summary>
/// 快递配置
/// </summary>
private RB_Express_ConfigRepository express_ConfigRepository = new RB_Express_ConfigRepository();
/// <summary>
/// 教育订单对应的老师
......@@ -470,6 +474,10 @@ namespace Mall.Module.Product
var sModel = speciList.Where(x => x.GoodsId == item.GoodsId).ToList()[i];
var svModel = speciVList.Where(x => x.GoodsId == item.GoodsId && x.SpecificationId == sModel.Id && x.Sort == Convert.ToInt32(KeyArr[i])).FirstOrDefault();
item.SpecificationList.Add(sModel.Name + ":" + svModel.Name);
if (i == 0 && !string.IsNullOrEmpty(svModel.Image))
{
item.CoverImage = svModel.Image;
}
}
}
var speciPModel = speciPList.Where(x => x.GoodsId == item.GoodsId && x.SpecificationSort == item.SpecificationSort).FirstOrDefault();
......@@ -913,6 +921,7 @@ namespace Mall.Module.Product
model.Mobile,
model.DistrictAddress,
model.ShoppingAddress,
DeductionCommission = model.DeductionCommission ?? 0,
IsHaveExpress = erlist.Any() ? 1 : 2,
DetailList = model.DetailList.Select(x => new
{
......@@ -1550,6 +1559,20 @@ namespace Mall.Module.Product
bool address_enable = true;//地址Ok
List<object> goods_list = new List<object>();
List<FreeShippingGoodsDetail> SatisfiedGoodsList = new List<FreeShippingGoodsDetail>();//可包邮的商品
#region 提示无上级不返佣
bool PromptNoSuperiorFY = false;
var disbaseModel = distributor_BasicsRepository.GetList(new RB_Distributor_Basics_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }).FirstOrDefault();
if ((disbaseModel?.IsEnableFXGrade ?? 2) == 1 && (disbaseModel?.IsEnableNoSuperiorFY ?? 1) == 2)
{
if ((umodel.SuperiorId ?? 0) == 0)
{
PromptNoSuperiorFY = true;
}
}
bool IsDeductionCommission = false;//是否抵扣佣金
decimal TotalDeductionCommission = 0;//粉象购买抵扣佣金
#endregion
if (demodel.DetailList.Any())
{
string GoodsIds = string.Join(",", demodel.DetailList.Select(x => x.GoodsId));
......@@ -1674,7 +1697,7 @@ namespace Mall.Module.Product
}
#region 图片
gmodel.CoverImage = "";
item.CoverImage = "";
//轮播
gmodel.CarouselImageList = new List<RB_ImageCommonModel>();
if (!string.IsNullOrEmpty(gmodel.CarouselImage) && gmodel.CarouselImage != "[]")
......@@ -1693,7 +1716,7 @@ namespace Mall.Module.Product
});
}
//封面图
gmodel.CoverImage = CarouselIdList[0];
item.CoverImage = CarouselIdList[0];
}
#endregion
......@@ -1719,6 +1742,7 @@ namespace Mall.Module.Product
}
}
item.CommissionPrice = gmodel.Commission;
//规格赋值
//gmodel.SpecificationNameList = new List<string>();
item.SpecificationNameList = new List<string>();
......@@ -1789,6 +1813,10 @@ namespace Mall.Module.Product
attr_id = svModel.Id,
attr_name = svModel.Name
});
if (i == 0 && !string.IsNullOrEmpty(svModel.Image))
{
item.CoverImage = svModel.Image;//规格图片赋值
}
}
}
var speciPModel = speciPList.Where(x => x.GoodsId == item.GoodsId && x.SpecificationSort == item.SpecificationSort).FirstOrDefault();
......@@ -1800,6 +1828,7 @@ namespace Mall.Module.Product
{
return ApiResult.Failed("商品库存不足:" + gmodel.Name);
}
item.CommissionPrice = speciPModel?.Commission ?? 0;
if (demodel.SmallShopsId > 0)
{
......@@ -2127,6 +2156,57 @@ namespace Mall.Module.Product
}
#endregion
#region 购买抵扣佣金
if ((disbaseModel?.IsEnableFXGrade ?? 2) == 1)
{
if (((disbaseModel?.IsEnableNoSuperiorFY ?? 1) == 1) || ((disbaseModel?.IsEnableNoSuperiorFY ?? 1) == 2 && (umodel.SuperiorId ?? 0) > 0))
{
//验证用户必须是分销商 最低普通会员 不是以普通会员处理
var disModel = distributor_InfoRepository.GetList(new RB_Distributor_Info_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId, UserId = umodel.Id, AuditStatus = Common.Enum.User.DistributorAuditStatusEnum.Audited }).FirstOrDefault();
if (disModel != null)
{
if (disModel.FXGradeId > 0)
{
var FXModel = distributor_FXGradeRepository.GetEntity(disModel.FXGradeId);
//购买直接抵扣佣金
if (FXModel != null && FXModel.CommissionType == 2)
{
IsDeductionCommission = true;
//开始慢慢找 注 同级返佣数量 返佣建子表可以无限级返佣了 --2020/10/16 未使用课程卡的才能返佣
var DetailList = demodel.DetailList.Where(x => x.CommissionPrice > 0 && (x.EducationCouponId ?? 0) == 0).ToList();
foreach (var item in DetailList)
{
if ((item.PresentFXGrade ?? 0) > 0)
{
//是赠送VIP等级的 暂直接表示 反购买VIP佣金 2020-08-03 ld
continue;
}
//第一个进来 按等级的返佣比例给佣金
decimal DcommionMoney = 0;
if (FXModel.DecimalType == 1)
{
DcommionMoney = Math.Ceiling(item.CommissionPrice * (FXModel.CommissionRatio ?? 0) / 100);
}
else
{
DcommionMoney = Math.Ceiling(item.CommissionPrice * (FXModel.CommissionRatio ?? 0)) / 100;
}
item.TCommissionMoney = DcommionMoney * (item.Number ?? 0);
}
TotalDeductionCommission = DetailList.Sum(x => x.TCommissionMoney);
}
}
}
else
{
LogHelper.Write("粉象返佣 用户分销商信息不存在:UserId:" + umodel.Id);
}
}
}
#endregion
List<int> ExpressGoodsId = new List<int>();
//赋值
foreach (var item in demodel.DetailList)
......@@ -2439,6 +2519,7 @@ namespace Mall.Module.Product
freeShipping_Use = FreeShipping_Use,
freight_id = gmodel.FreightId,
express_price = item.Express,
deduction_commission = item.TCommissionMoney,
unit_price = item.Unit_Price,
total_original_price = (item.Original_Price ?? 0) * (item.Number ?? 0),
total_price = (item.Unit_Price ?? 0) * (item.Number ?? 0),//优惠券(有平摊情况) 积分抵扣 (默认从第一个商品抵扣)
......@@ -2452,7 +2533,7 @@ namespace Mall.Module.Product
original_price = item.Original_Price ?? 0,
no = gmodel.GoodsNumbers,
weight = item.GoodsWeight,
pic_url = gmodel.CoverImage,
pic_url = item.CoverImage,
individual_share = umodel?.IsDistributor ?? 2,// 是否分销商
share_type = gmodel.SeparateDistributionMoneyType,//分销佣金类型,
member_price = item.MemberPrice,
......@@ -2463,7 +2544,7 @@ namespace Mall.Module.Product
//extra= [],
//goods_warehouse_id = 19813,
name = gmodel.Name,
cover_pic = gmodel.CoverImage,
cover_pic = item.CoverImage,
detail = gmodel.GoodsDetails,
pic_list = gmodel.CarouselImageList.Select(x => new
{
......@@ -2483,7 +2564,7 @@ namespace Mall.Module.Product
attr_list = item.Attr_list,
discounts = item.Discounts,
member_discount = ((item.Unit_Price ?? 0) * (item.Number ?? 0)) - (item.MemberPrice * (item.Number ?? 0)),
cover_pic = gmodel.CoverImage,
cover_pic = item.CoverImage,
is_level_alone = gmodel.SeparateSetMember,//是否单独设置会员价
//custom_currency= [],
is_level = gmodel.EnjoyMember,//是否销售会员价格
......@@ -2545,19 +2626,7 @@ namespace Mall.Module.Product
}
}
#region 提示无上级不返佣
bool PromptNoSuperiorFY = false;
var disbaseModel = distributor_BasicsRepository.GetList(new RB_Distributor_Basics_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }).FirstOrDefault();
if ((disbaseModel?.IsEnableFXGrade ?? 2) == 1 && (disbaseModel?.IsEnableNoSuperiorFY ?? 1) == 2)
{
if ((umodel.SuperiorId ?? 0) == 0)
{
PromptNoSuperiorFY = true;
}
}
#endregion
TotalGoodsMoney -= TotalDeductionCommission;//总额 减去抵扣佣金
mch_list.Add(new
{
mch = new
......@@ -2585,10 +2654,8 @@ namespace Mall.Module.Product
//store= null,
store_select_enable = true,
total_price = TotalGoodsMoney,
//pick_up_enable= true,
//pick_up_price= null,
//diff_goods_form_count= 0,
//has_goods_form= false
is_deduction_commission = IsDeductionCommission,
deduction_commission = TotalDeductionCommission
});
//minModel
......@@ -2923,6 +2990,7 @@ namespace Mall.Module.Product
}
#endregion
List<FreeShippingGoodsDetail> SatisfiedGoodsList = new List<FreeShippingGoodsDetail>();//可包邮的商品
decimal DeductionCommission = 0;//购买抵扣金额
if (demodel.DetailList.Any())
{
//积分
......@@ -3100,6 +3168,13 @@ namespace Mall.Module.Product
item.ProductCode = gmodel.GoodsNumbers;
item.CategoryIdList = categoryList.Select(x => x.CategoryId ?? 0).ToList();
int GoodsWeight = gmodel.GoodsWeight ?? 0;//商品重量
item.CoverImage = "";
if (!string.IsNullOrEmpty(gmodel.CarouselImage) && gmodel.CarouselImage != "[]")
{
List<string> CarouselIdList = JsonConvert.DeserializeObject<List<string>>(gmodel.CarouselImage);
//封面图
item.CoverImage = CarouselIdList[0];
}
#region 规格
//验证规格是否已失效
......@@ -3136,6 +3211,13 @@ namespace Mall.Module.Product
return ApiResult.Failed("商品库存不足:" + gmodel.Name);
}
item.CommissionPrice = speciPModel?.Commission ?? 0;
#region 查询规格图片
string simage = goods_SpecificationValueRepository.GetSpecificationImage(item.GoodsId ?? 0, item.SpecificationSort);
if (!string.IsNullOrEmpty(simage))
{
item.CoverImage = simage;//规格图片赋值
}
#endregion
item.SmallShopsCostPrice = gmodel.SellingPrice ?? 0;
if (demodel.SmallShopsId > 0)
......@@ -3448,13 +3530,6 @@ namespace Mall.Module.Product
TotalMoney += (item.Final_Price ?? 0);
item.OrderType = gmodel.GoodsType;
item.GoodsName = gmodel.Name;
item.CoverImage = "";
if (!string.IsNullOrEmpty(gmodel.CarouselImage) && gmodel.CarouselImage != "[]")
{
List<string> CarouselIdList = JsonConvert.DeserializeObject<List<string>>(gmodel.CarouselImage);
//封面图
item.CoverImage = CarouselIdList[0];
}
item.SeparateDistribution = gmodel.SeparateDistribution;
item.SeparateDistributionType = gmodel.SeparateDistributionType;
item.SeparateDistributionMoneyType = gmodel.SeparateDistributionMoneyType;
......@@ -3516,6 +3591,58 @@ namespace Mall.Module.Product
freeShippingList = freeShippingRepository.GetFreeShippingListByCategoryIds(new RB_FreeShipping_Extend { MallBaseId = demodel.MallBaseId, TenantId = demodel.TenantId, CategoryIds = categoryIds });
}
#endregion
#region 购买抵扣佣金
var disbaseModel = distributor_BasicsRepository.GetList(new RB_Distributor_Basics_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }).FirstOrDefault();
if ((disbaseModel?.IsEnableFXGrade ?? 2) == 1)
{
if (((disbaseModel?.IsEnableNoSuperiorFY ?? 1) == 1) || ((disbaseModel?.IsEnableNoSuperiorFY ?? 1) == 2 && (umodel.SuperiorId ?? 0) > 0))
{
//验证用户必须是分销商 最低普通会员 不是以普通会员处理
var disModel = distributor_InfoRepository.GetList(new RB_Distributor_Info_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId, UserId = umodel.Id, AuditStatus = Common.Enum.User.DistributorAuditStatusEnum.Audited }).FirstOrDefault();
if (disModel != null)
{
if (disModel.FXGradeId > 0)
{
var FXModel = distributor_FXGradeRepository.GetEntity(disModel.FXGradeId);
//购买直接抵扣佣金
if (FXModel != null && FXModel.CommissionType == 2)
{
//开始慢慢找 注 同级返佣数量 返佣建子表可以无限级返佣了 --2020/10/16 未使用课程卡的才能返佣
var DetailList = demodel.DetailList.Where(x => x.CommissionPrice > 0 && (x.EducationCouponId ?? 0) == 0).ToList();
foreach (var item in DetailList)
{
if ((item.PresentFXGrade ?? 0) > 0)
{
//是赠送VIP等级的 暂直接表示 反购买VIP佣金 2020-08-03 ld
continue;
}
//第一个进来 按等级的返佣比例给佣金
decimal DcommionMoney = 0;
if (FXModel.DecimalType == 1)
{
DcommionMoney = Math.Ceiling(item.CommissionPrice * (FXModel.CommissionRatio ?? 0) / 100);
}
else
{
DcommionMoney = Math.Ceiling(item.CommissionPrice * (FXModel.CommissionRatio ?? 0)) / 100;
}
item.DeductionCommission = DcommionMoney * (item.Number ?? 0);
}
DeductionCommission = DetailList.Sum(x => x.DeductionCommission ?? 0);
}
}
}
else
{
LogHelper.Write("粉象返佣 用户分销商信息不存在:UserId:" + umodel.Id);
}
}
}
#endregion
List<int> ExpressGoodsId = new List<int>();//同商品 多规格
foreach (var item in demodel.DetailList)
{
......@@ -3787,8 +3914,12 @@ namespace Mall.Module.Product
{
return ApiResult.Failed("优惠金额计算有误");
}
if (DeductionCommission != (demodel.DeductionCommission ?? 0))
{
return ApiResult.Failed("抵扣佣金不正确");
}
//验证总额
if (demodel.Income != (TotalMoney + TotalExpress))
if (demodel.Income != (TotalMoney + TotalExpress - DeductionCommission))
{
return ApiResult.Failed("订单合计金额不正确");
}
......@@ -6125,10 +6256,11 @@ namespace Mall.Module.Product
});
Num++;
TotalCommission -= DcommionMoney;
RB_Goods_OrderCommission gocModel = new RB_Goods_OrderCommission()
{
Id = 0,
Commission = DcommionMoney,
Commission = FXModel.CommissionType == 2 ? 0 : DcommionMoney,//下单抵扣了 返佣金额=0
CommissionState = 1,
CreateDate = DateTime.Now,
Grade = FXModel.Id,
......@@ -6136,12 +6268,13 @@ namespace Mall.Module.Product
MallBaseId = demodel.MallBaseId,
OrderDetailId = item.Id,
OrderId = OrderId,
Remark = "粉象 " + FXModel.GradeName + "下单返佣,返佣比例:" + (FXModel.CommissionRatio ?? 0) + "%",
Remark = "粉象 " + FXModel.GradeName + "下单返佣,返佣比例:" + (FXModel.CommissionRatio ?? 0) + "%;" + (FXModel.CommissionType == 2 ? "已抵扣" + (DcommionMoney * (item.Number ?? 0)) + "金额" : ""),
TenantId = demodel.TenantId,
UpdateDate = DateTime.Now,
UserId = numodel.Id,
Type = 3,
IsRemit = 0
IsRemit = 0,
DeductionCommission = (DcommionMoney * (item.Number ?? 0))
};
gocList.Add(gocModel);
}
......@@ -7081,6 +7214,7 @@ namespace Mall.Module.Product
InsuranceFinanceId = 0,
CommentGiveIntegral = item.CommentGiveIntegral,
EducationCouponId = item.EducationCouponId,
DeductionCommission = item.DeductionCommission,
ServiceDate = item.ServiceDate,
ServicepersonalId = item.ServicepersonalId,
ServiceTime = item.ServiceTime,
......@@ -12590,6 +12724,7 @@ namespace Mall.Module.Product
model.SmallShopsId,
storeName = storeModel?.Name ?? "",
storeAddress = storeModel?.Address ?? "",
DeductionCommission = model.DeductionCommission ?? 0,
OrderExpressList = oeList.Select(x => new
{
x.Id,
......@@ -12615,7 +12750,8 @@ namespace Mall.Module.Product
x.GradeDescription,
x.UserName,
x.Mobile,
x.Commission
x.Commission,
DeductionCommission = x.DeductionCommission ?? 0
}),
VipCommissionInfo = clist.Select(x => new
{
......@@ -12652,6 +12788,7 @@ namespace Mall.Module.Product
x.IsBindExpress,
x.FreeShippingRemarks,
x.SmallShopsCostPrice,
x.DeductionCommission,
CouponMoney = x.CouponMoney ?? 0,
InsuranceMoney = x.InsuranceMoney ?? 0,
IntegralMoney = x.IntegralMoney ?? 0,
......@@ -14204,9 +14341,28 @@ namespace Mall.Module.Product
/// <param name="expressCode"></param>
/// <param name="expressNumber"></param>
/// <returns></returns>
public string GetOrderExpressInfo(string expressCode, string expressNumber)
public string GetOrderExpressInfo(string expressCode, string expressNumber, string EBusinessID, string AppKey, string ReqURL)
{
return new KdApiSearchDemo().getOrderTracesByJson(expressCode, expressNumber);
return new KdApiSearchDemo().getOrderTracesByJson(expressCode, expressNumber, EBusinessID, AppKey, ReqURL);
}
/// <summary>
/// 查询物流信息
/// </summary>
/// <param name="expressCode"></param>
/// <param name="expressNumber"></param>
/// <returns></returns>
public string GetOrderExpressInfoForAliyun(string expressNumber, string expressCode, string AppCode, string ReqUrl)
{
return AliyunApiSearchDemo.GetExpressInfo(expressNumber, expressCode, AppCode, ReqUrl);
}
/// <summary>
/// 获取快递配置
/// </summary>
/// <returns></returns>
public Model.Entity.BaseSetUp.RB_Express_Config GetExpressConfig(int tenantId,int mallBaseId) {
return express_ConfigRepository.GetListRepository(new Model.Entity.BaseSetUp.RB_Express_Config() { TenantId = tenantId, MallBaseId = mallBaseId, IsDefault = 1 }).FirstOrDefault();
}
#endregion
......
......@@ -5358,6 +5358,7 @@ namespace Mall.Module.User
{ nameof(RB_Distributor_FXGrade.DecimalType),demodel.DecimalType},
{ nameof(RB_Distributor_FXGrade.Description),demodel.Description},
{ nameof(RB_Distributor_FXGrade.Icon),demodel.Icon},
{ nameof(RB_Distributor_FXGrade.CommissionType),demodel.CommissionType}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
......
using Mall.Model.Entity.BaseSetUp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mall.Repository.BaseSetUp
{
/// <summary>
/// 快递配置仓储层
/// </summary>
public class RB_Express_ConfigRepository : BaseRepository<RB_Express_Config>
{
/// <summary>
/// 获取上传存储信息
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Express_Config> GetListRepository(RB_Express_Config query)
{
StringBuilder builder = new StringBuilder();
builder.Append($" SELECT * FROM RB_Express_Config WHERE {nameof(RB_Express_Config.Status)}=0");
if (query != null)
{
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_Express_Config.TenantId)}={query.TenantId}");
}
if (query.MallBaseId > 0)
{
builder.Append($" AND {nameof(RB_Express_Config.MallBaseId)}={query.MallBaseId}");
}
if (query.Type > 0)
{
builder.Append($" AND {nameof(RB_Express_Config.Type)}={query.Type}");
}
if (query.IsDefault > 0)
{
builder.Append($" AND {nameof(RB_Express_Config.IsDefault)}={query.IsDefault}");
}
}
return Get<RB_Express_Config>(builder.ToString()).ToList();
}
}
}
......@@ -83,7 +83,7 @@ where {where} order by oc.Id asc";
where += $@" and oc.{nameof(RB_Goods_OrderCommission.OrderId)} in({dmodel.OrderIds})";
}
string sql = $@"SELECT oc.OrderId,oc.UserId,oc.Grade,oc.Type,oc.CommissionState,SUM(oc.Commission) as Commission FROM RB_Goods_OrderCommission oc
string sql = $@"SELECT oc.OrderId,oc.UserId,oc.Grade,oc.Type,oc.CommissionState,SUM(oc.Commission) as Commission,SUM(oc.DeductionCommission) as DeductionCommission FROM RB_Goods_OrderCommission oc
left join rb_goods_orderaftersale oa on oc.OrderDetailId= oa.OrderDetialId and oa.Type=1 and oa.Status=0 and oa.ReOrderStatus in (2,3,4,5)
where {where} group by oc.OrderId,oc.UserId,oc.Grade,oc.Type order by oc.Grade asc";
return Get<RB_Goods_OrderCommission_Extend>(sql).ToList();
......
......@@ -43,5 +43,30 @@ namespace Mall.Repository.Product
string sql = $@"select * from RB_Goods_SpecificationValue where {where} order by Id asc";
return Get<RB_Goods_SpecificationValue_Extend>(sql).ToList();
}
/// <summary>
/// 获取规格值图片
/// </summary>
/// <param name="goodsId"></param>
/// <param name="specificationSort"></param>
/// <returns></returns>
public string GetSpecificationImage(int goodsId, string specificationSort)
{
try
{
int Sort = Convert.ToInt32(specificationSort.Split(":")[0]);
string sql = $@"select * from RB_Goods_SpecificationValue where Status=0 and GoodsId={goodsId} and Sort={Sort} and Image<> '' order by Id asc limit 1";
var model = Get<RB_Goods_SpecificationValue_Extend>(sql).FirstOrDefault();
if (model != null)
{
return model.Image ?? "";
}
return "";
}
catch (Exception)
{
return "";
}
}
}
}
......@@ -1254,5 +1254,79 @@ namespace Mall.WebApi.Controllers.MallBase
return ApiResult.Success("获取成功", microShopBasics);
}
#endregion
#region 快递配置
/// <summary>
/// 获取快递配置列表
/// </summary>
/// <returns></returns>
public ApiResult GetExpressConfigList()
{
var parms = RequestParm;
var query = new RB_Express_Config();
query.TenantId = parms.TenantId;
query.MallBaseId = parms.MallBaseId;
var list = mallBaseModule.GetExpressConfigList(query);
return ApiResult.Success("获取成功", list.Select(x => new
{
x.Id,
x.Name,
x.AppCode,
x.AppID,
x.AppKey,
x.AppSecret,
x.IsDefault,
x.RquUrl,
x.Type
}));
}
/// <summary>
/// 新增/修改快递配置
/// </summary>
/// <returns></returns>
public ApiResult SetExpressConfig()
{
var parms = RequestParm;
var query = JsonConvert.DeserializeObject<RB_Express_Config>(RequestParm.msg.ToString());
query.TenantId = parms.TenantId;
query.MallBaseId = parms.MallBaseId;
if (query.Type == 1)
{
if (string.IsNullOrEmpty(query.AppCode))
{
return ApiResult.ParamIsNull("请传递appcode");
}
}
else if (query.Type == 2)
{
if (string.IsNullOrEmpty(query.AppID))
{
return ApiResult.ParamIsNull("请传递appid");
}
}
if (string.IsNullOrEmpty(query.Name)) {
return ApiResult.ParamIsNull("请输入别名");
}
if (string.IsNullOrEmpty(query.RquUrl)) {
return ApiResult.ParamIsNull("请传递请求地址");
}
query.CreateDate = DateTime.Now;
query.Status = 0;
bool flag = mallBaseModule.SetExpressConfig(query);
if (flag)
{
return ApiResult.Success();
}
else {
return ApiResult.Failed();
}
}
#endregion
}
}
\ No newline at end of file
......@@ -1547,7 +1547,35 @@ namespace Mall.WebApi.Controllers.MallBase
return ApiResult.Failed("快递不存在");
}
var jsonStr = orderModule.GetOrderExpressInfo(model.ExpressCode, ExpressNumber);
//获取快递配置
var configModel = orderModule.GetExpressConfig(userInfo.TenantId, userInfo.MallBaseId);
if (configModel == null) {
return ApiResult.Failed("未配置快递参数,无法查询");
}
if (configModel.Type == 1)
{
string alimsg = orderModule.GetOrderExpressInfoForAliyun(ExpressNumber, model.ExpressCode, configModel.AppCode, configModel.RquUrl);
LogHelper.Write(alimsg);
JObject Rparms = JObject.Parse(alimsg);
if (Rparms.GetStringValue("Success").ToLower() == "true")
{
List<Model.Query.ExpressTraces> list = JsonConvert.DeserializeObject<List<Model.Query.ExpressTraces>>(Rparms.GetStringValue("Traces"));
if (list.Any())
{
list = list.OrderByDescending(x => x.AcceptTime).ToList();
}
return ApiResult.Success("", list);
}
else
{
return ApiResult.Failed("未能查询到该快递信息");
}
}
else if (configModel.Type == 2)
{
var jsonStr = orderModule.GetOrderExpressInfo(model.ExpressCode, ExpressNumber, configModel.AppID, configModel.AppKey, configModel.RquUrl);
LogHelper.Write(jsonStr);
JObject Rparms = JObject.Parse(jsonStr);
if (Rparms.GetStringValue("Success").ToLower() == "true")
{
......@@ -1563,6 +1591,10 @@ namespace Mall.WebApi.Controllers.MallBase
return ApiResult.Failed("未能查询到该快递信息");
}
}
else {
return ApiResult.Failed("未查询到快递配置");
}
}
catch (Exception ex)
{
LogHelper.Write(ex, "GetOrderExpressInfo");
......
......@@ -95,6 +95,7 @@ namespace Mall.WebApi.Controllers.MallBase
x.Income,
x.FreightMoney,
x.PaymentWay,
DeductionCommission = x.DeductionCommission ?? 0,
PaymentWayName = x.PaymentWay.GetEnumName(),
CouponMoney = x.CouponMoney ?? 0,
IntegralMoney = (x.DetailList != null && x.DetailList.Any()) ? (x.DetailList.Sum(x => x.IntegralMoney ?? 0)) : 0,
......@@ -137,6 +138,7 @@ namespace Mall.WebApi.Controllers.MallBase
InsuranceCostMoney = y.InsuranceCostMoney ?? 0,
IntegralMoney = y.IntegralMoney ?? 0,
IntegralNumber = y.IntegralNumber ?? 0,
DeductionCommission = y.DeductionCommission ?? 0,
SFinanceList = y.FinanceList.Where(z => z.Type == 1).Select(z => new
{
z.FrID,
......@@ -2467,7 +2469,8 @@ namespace Mall.WebApi.Controllers.MallBase
z.Mobile,
z.Name,
z.Commission,
z.CommissionState
z.CommissionState,
DeductionCommission = z.DeductionCommission ?? 0
}),
x.TenantId,
x.MallBaseId,
......
......@@ -2741,6 +2741,7 @@ namespace Mall.WebApi.Controllers.User
x.UpgradeId,
x.Description,
x.Icon,
x.CommissionType,
UpdateDate = x.UpdateDate.HasValue ? x.UpdateDate.Value.ToString("yyyy-MM-dd") : ""
});
return ApiResult.Success("", pagelist);
......
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