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 ...@@ -11,11 +11,11 @@ namespace Mall.Common.Plugin
public class KdApiSearchDemo public class KdApiSearchDemo
{ {
//电商ID //电商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 //请求url
private string ReqURL = "http://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx"; //private string ReqURL = "http://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx";
/// <summary> /// <summary>
/// Json方式 查询订单物流轨迹 /// Json方式 查询订单物流轨迹
...@@ -24,9 +24,9 @@ namespace Mall.Common.Plugin ...@@ -24,9 +24,9 @@ namespace Mall.Common.Plugin
/// <param name="LogisticCode"></param> /// <param name="LogisticCode"></param>
/// <param name="OrderCode"></param> /// <param name="OrderCode"></param>
/// <returns></returns> /// <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>(); Dictionary<string, string> param = new Dictionary<string, string>();
param.Add("RequestData", HttpUtility.UrlEncode(requestData, Encoding.UTF8)); 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 ...@@ -326,5 +326,9 @@ namespace Mall.Model.Entity.Product
/// </summary> /// </summary>
public int StoresId { get; set; } public int StoresId { get; set; }
/// <summary>
/// 购买抵扣佣金金额
/// </summary>
public decimal? DeductionCommission { get; set; }
} }
} }
...@@ -124,6 +124,10 @@ namespace Mall.Model.Entity.Product ...@@ -124,6 +124,10 @@ namespace Mall.Model.Entity.Product
/// </summary> /// </summary>
public int? IsRemit { get; set; } public int? IsRemit { get; set; }
/// <summary>
/// 购买抵扣佣金
/// </summary>
public decimal? DeductionCommission { get; set; }
} }
......
...@@ -356,6 +356,9 @@ namespace Mall.Model.Entity.Product ...@@ -356,6 +356,9 @@ namespace Mall.Model.Entity.Product
public int? ServicepersonalId { get; set; } public int? ServicepersonalId { get; set; }
/// <summary> /// <summary>
/// 购买抵扣佣金金额
/// </summary>
public decimal? DeductionCommission { get; set; }
/// 服务日期 /// 服务日期
/// </summary> /// </summary>
public string ServiceDate { get; set; } public string ServiceDate { get; set; }
......
...@@ -167,5 +167,10 @@ namespace Mall.Model.Entity.User ...@@ -167,5 +167,10 @@ namespace Mall.Model.Entity.User
/// 粉象等级图标 /// 粉象等级图标
/// </summary> /// </summary>
public string Icon { get; set; } public string Icon { get; set; }
/// <summary>
/// 返佣类型 1正常返佣 2购买抵扣
/// </summary>
public int? CommissionType { get; set; }
} }
} }
...@@ -31,6 +31,10 @@ namespace Mall.Module.BaseSetUp ...@@ -31,6 +31,10 @@ namespace Mall.Module.BaseSetUp
private readonly RB_FreeShippingRepository freeShippingRepository = new RB_FreeShippingRepository(); private readonly RB_FreeShippingRepository freeShippingRepository = new RB_FreeShippingRepository();
private readonly RB_MicroShop_BasicsRepository microShopBasicsRepository = new RB_MicroShop_BasicsRepository(); 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 ...@@ -956,6 +960,80 @@ namespace Mall.Module.BaseSetUp
} }
#endregion #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 分类包邮规则 #region 分类包邮规则
/// <summary> /// <summary>
......
This diff is collapsed.
...@@ -5358,6 +5358,7 @@ namespace Mall.Module.User ...@@ -5358,6 +5358,7 @@ namespace Mall.Module.User
{ nameof(RB_Distributor_FXGrade.DecimalType),demodel.DecimalType}, { nameof(RB_Distributor_FXGrade.DecimalType),demodel.DecimalType},
{ nameof(RB_Distributor_FXGrade.Description),demodel.Description}, { nameof(RB_Distributor_FXGrade.Description),demodel.Description},
{ nameof(RB_Distributor_FXGrade.Icon),demodel.Icon}, { nameof(RB_Distributor_FXGrade.Icon),demodel.Icon},
{ nameof(RB_Distributor_FXGrade.CommissionType),demodel.CommissionType}
}; };
List<WhereHelper> wheres = new List<WhereHelper>() { List<WhereHelper> wheres = new List<WhereHelper>() {
new 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"; ...@@ -83,7 +83,7 @@ where {where} order by oc.Id asc";
where += $@" and oc.{nameof(RB_Goods_OrderCommission.OrderId)} in({dmodel.OrderIds})"; 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) 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"; 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(); return Get<RB_Goods_OrderCommission_Extend>(sql).ToList();
......
...@@ -43,5 +43,30 @@ namespace Mall.Repository.Product ...@@ -43,5 +43,30 @@ namespace Mall.Repository.Product
string sql = $@"select * from RB_Goods_SpecificationValue where {where} order by Id asc"; string sql = $@"select * from RB_Goods_SpecificationValue where {where} order by Id asc";
return Get<RB_Goods_SpecificationValue_Extend>(sql).ToList(); 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 ...@@ -1254,5 +1254,79 @@ namespace Mall.WebApi.Controllers.MallBase
return ApiResult.Success("获取成功", microShopBasics); return ApiResult.Success("获取成功", microShopBasics);
} }
#endregion #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,20 +1547,52 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -1547,20 +1547,52 @@ namespace Mall.WebApi.Controllers.MallBase
return ApiResult.Failed("快递不存在"); return ApiResult.Failed("快递不存在");
} }
var jsonStr = orderModule.GetOrderExpressInfo(model.ExpressCode, ExpressNumber); //获取快递配置
JObject Rparms = JObject.Parse(jsonStr);
if (Rparms.GetStringValue("Success").ToLower() == "true") var configModel = orderModule.GetExpressConfig(userInfo.TenantId, userInfo.MallBaseId);
if (configModel == null) {
return ApiResult.Failed("未配置快递参数,无法查询");
}
if (configModel.Type == 1)
{ {
List<Model.Query.ExpressTraces> list = JsonConvert.DeserializeObject<List<Model.Query.ExpressTraces>>(Rparms.GetStringValue("Traces")); string alimsg = orderModule.GetOrderExpressInfoForAliyun(ExpressNumber, model.ExpressCode, configModel.AppCode, configModel.RquUrl);
if (list.Any()) 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
{ {
list = list.OrderByDescending(x => x.AcceptTime).ToList(); return ApiResult.Failed("未能查询到该快递信息");
} }
return ApiResult.Success("", list);
} }
else else if (configModel.Type == 2)
{ {
return ApiResult.Failed("未能查询到该快递信息"); 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")
{
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 {
return ApiResult.Failed("未查询到快递配置");
} }
} }
catch (Exception ex) catch (Exception ex)
......
...@@ -95,6 +95,7 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -95,6 +95,7 @@ namespace Mall.WebApi.Controllers.MallBase
x.Income, x.Income,
x.FreightMoney, x.FreightMoney,
x.PaymentWay, x.PaymentWay,
DeductionCommission = x.DeductionCommission ?? 0,
PaymentWayName = x.PaymentWay.GetEnumName(), PaymentWayName = x.PaymentWay.GetEnumName(),
CouponMoney = x.CouponMoney ?? 0, CouponMoney = x.CouponMoney ?? 0,
IntegralMoney = (x.DetailList != null && x.DetailList.Any()) ? (x.DetailList.Sum(x => x.IntegralMoney ?? 0)) : 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 ...@@ -137,6 +138,7 @@ namespace Mall.WebApi.Controllers.MallBase
InsuranceCostMoney = y.InsuranceCostMoney ?? 0, InsuranceCostMoney = y.InsuranceCostMoney ?? 0,
IntegralMoney = y.IntegralMoney ?? 0, IntegralMoney = y.IntegralMoney ?? 0,
IntegralNumber = y.IntegralNumber ?? 0, IntegralNumber = y.IntegralNumber ?? 0,
DeductionCommission = y.DeductionCommission ?? 0,
SFinanceList = y.FinanceList.Where(z => z.Type == 1).Select(z => new SFinanceList = y.FinanceList.Where(z => z.Type == 1).Select(z => new
{ {
z.FrID, z.FrID,
...@@ -2467,7 +2469,8 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -2467,7 +2469,8 @@ namespace Mall.WebApi.Controllers.MallBase
z.Mobile, z.Mobile,
z.Name, z.Name,
z.Commission, z.Commission,
z.CommissionState z.CommissionState,
DeductionCommission = z.DeductionCommission ?? 0
}), }),
x.TenantId, x.TenantId,
x.MallBaseId, x.MallBaseId,
......
...@@ -2741,6 +2741,7 @@ namespace Mall.WebApi.Controllers.User ...@@ -2741,6 +2741,7 @@ namespace Mall.WebApi.Controllers.User
x.UpgradeId, x.UpgradeId,
x.Description, x.Description,
x.Icon, x.Icon,
x.CommissionType,
UpdateDate = x.UpdateDate.HasValue ? x.UpdateDate.Value.ToString("yyyy-MM-dd") : "" UpdateDate = x.UpdateDate.HasValue ? x.UpdateDate.Value.ToString("yyyy-MM-dd") : ""
}); });
return ApiResult.Success("", pagelist); 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