Commit 84f2e737 authored by liudong1993's avatar liudong1993
parents 9e9a8fab 28f4937d
using Mall.CacheManager.DataStatistic;
using Mall.Common.Plugin.Redis;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.CacheManager.AppletWeChat
{
public class OrderPayReidsCache
{
static RedisHelper redis = new RedisHelper(DataStatistic.DataConstant.REDIS_DB2, DataStatistic.DataConstant.DATA_OrderPayId);
/// <summary>
/// 设置缓存
/// </summary>
/// <param name="value"></param>
public static void Set(string cacheKey, string value, TimeSpan ts)
{
try
{
// TimeSpan ts = DateTime.Now.AddMinutes(10) - DateTime.Now;
redis.StringSet(cacheKey, value, ts);
}
catch (Exception ex)
{
Common.Plugin.LogHelper.Write(ex, "DATA_OrderPayId");
}
}
/// <summary>
/// 获取缓存
/// </summary>
/// <returns></returns>
public static string Get(string Key)
{
string cacheKey = DataConstant.DATA_OrderPayId + Key;
try
{
Object obj = redis.Get(cacheKey);
if (obj != null)
{
return obj.ToString();
}
}
catch (Exception ex)
{
//再获取一次缓存
try
{
System.Threading.Thread.Sleep(500);
Object obj = redis.Get(cacheKey);
if (obj != null)
{
return obj.ToString();
}
}
catch (Exception ex2)
{
Common.Plugin.LogHelper.Write(ex2, "DATA_OrderPayId2");
}
Common.Plugin.LogHelper.Write(ex, "DATA_OrderPayId");
}
return "";
}
}
}
...@@ -21,5 +21,11 @@ namespace Mall.CacheManager.DataStatistic ...@@ -21,5 +21,11 @@ namespace Mall.CacheManager.DataStatistic
/// 微信小程序token /// 微信小程序token
/// </summary> /// </summary>
public static readonly string DATA_WeiXinToken = "DATA_WeiXinToken_"; public static readonly string DATA_WeiXinToken = "DATA_WeiXinToken_";
/// <summary>
///订单支付缓存
/// </summary>
public static readonly string DATA_OrderPayId = "DATA_OrderPayId_";
} }
} }
...@@ -30,6 +30,12 @@ namespace Mall.Model.Entity.MarketingCenter ...@@ -30,6 +30,12 @@ namespace Mall.Model.Entity.MarketingCenter
public DateTime CreateDate { get; set; } public DateTime CreateDate { get; set; }
public DateTime UpdateDate { get; set; } public DateTime UpdateDate { get; set; }
/// <summary>
/// 是否显示充值余额按钮0-否,1-是 2020-07-01 add By:w
/// </summary>
public int IsOpenBtn { get; set; }
/// <summary> /// <summary>
/// 开启余额功能0-否,1-是 /// 开启余额功能0-否,1-是
/// </summary> /// </summary>
......
...@@ -48,6 +48,7 @@ namespace Mall.WebApi.App_Code ...@@ -48,6 +48,7 @@ namespace Mall.WebApi.App_Code
/// <returns></returns> /// <returns></returns>
public static string GetMinUnifiedOrder(string sOrderNo, string sProductName, decimal dPrice, string CustomerId, string openid, string notify_url, RB_MiniProgram_Extend model, IHttpContextAccessor _accessor, string IPAddress) public static string GetMinUnifiedOrder(string sOrderNo, string sProductName, decimal dPrice, string CustomerId, string openid, string notify_url, RB_MiniProgram_Extend model, IHttpContextAccessor _accessor, string IPAddress)
{ {
DateTime time_start = DateTime.Now;
var req = new Common.Pay.WeChatPat.RequestHandler(); var req = new Common.Pay.WeChatPat.RequestHandler();
req.SetKey(model.WeChatApiSecret); req.SetKey(model.WeChatApiSecret);
req.SetParameter("appid", model.MiniAppId);//微信开放平台审核通过的应用APPID req.SetParameter("appid", model.MiniAppId);//微信开放平台审核通过的应用APPID
...@@ -58,8 +59,8 @@ namespace Mall.WebApi.App_Code ...@@ -58,8 +59,8 @@ namespace Mall.WebApi.App_Code
req.SetParameter("out_trade_no", sOrderNo); req.SetParameter("out_trade_no", sOrderNo);
req.SetParameter("total_fee", (dPrice * 100).ToString("f0")); req.SetParameter("total_fee", (dPrice * 100).ToString("f0"));
req.SetParameter("spbill_create_ip", IPAddress); req.SetParameter("spbill_create_ip", IPAddress);
req.SetParameter("time_start", DateTime.Now.ToString("yyyyMMddHHmmss")); req.SetParameter("time_start", time_start.ToString("yyyyMMddHHmmss"));
req.SetParameter("time_expire", DateTime.Now.AddMinutes(10).ToString("yyyyMMddHHmmss")); req.SetParameter("time_expire", time_start.AddMinutes(10).ToString("yyyyMMddHHmmss"));
req.SetParameter("notify_url", notify_url); req.SetParameter("notify_url", notify_url);
req.SetParameter("trade_type", "JSAPI"); req.SetParameter("trade_type", "JSAPI");
req.SetParameter("openid", openid); req.SetParameter("openid", openid);
...@@ -79,6 +80,11 @@ namespace Mall.WebApi.App_Code ...@@ -79,6 +80,11 @@ namespace Mall.WebApi.App_Code
LogHelper.Write(null, "订单号【" + sOrderNo + "】成功回调:" + xe); LogHelper.Write(null, "订单号【" + sOrderNo + "】成功回调:" + xe);
try try
{ {
//存入缓存,方便自动取消的时候不被清理
TimeSpan ts = time_start.AddMinutes(10) - time_start;
string orderId = sOrderNo[17..];
System.Threading.Tasks.Task.Run(() => CacheManager.AppletWeChat.OrderPayReidsCache.Set(orderId, orderId, ts));
var prepayId = xe.GetElement("prepay_id").Value; var prepayId = xe.GetElement("prepay_id").Value;
var payReq = new RequestHandler(); var payReq = new RequestHandler();
......
...@@ -121,7 +121,7 @@ namespace Mall.WebApi.Controllers.AppletWeChat ...@@ -121,7 +121,7 @@ namespace Mall.WebApi.Controllers.AppletWeChat
item.ALLCommission = item.CostFreight + item.CostMoney + item.PackingMoney + item.GoodsFreight + item.OneCommission + item.TwoCommission + item.OtherPrice; item.ALLCommission = item.CostFreight + item.CostMoney + item.PackingMoney + item.GoodsFreight + item.OneCommission + item.TwoCommission + item.OtherPrice;
item.NoPaid = item.ALLCommission - item.Paid; item.NoPaid = item.ALLCommission - item.Paid;
item.GrossProfit = item.AllPrice - item.ALLCommission; item.GrossProfit = item.AllPrice - item.ALLCommission;
item.GrossProfitRate = item.AllPrice == 0 ? 0 : item.GrossProfit / item.AllPrice; item.GrossProfitRate = item.AllPrice == 0 ? 0 : Math.Round((item.GrossProfit / item.AllPrice), 2, MidpointRounding.AwayFromZero);
} }
pagelist.count = Convert.ToInt32(count); pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list; pagelist.pageData = list;
...@@ -183,7 +183,7 @@ namespace Mall.WebApi.Controllers.AppletWeChat ...@@ -183,7 +183,7 @@ namespace Mall.WebApi.Controllers.AppletWeChat
item.ALLCommission = item.CostFreight + item.CostMoney + item.PackingMoney + item.GoodsFreight + item.OneCommission + item.TwoCommission + item.OtherPrice; item.ALLCommission = item.CostFreight + item.CostMoney + item.PackingMoney + item.GoodsFreight + item.OneCommission + item.TwoCommission + item.OtherPrice;
item.NoPaid = item.ALLCommission - item.Paid; item.NoPaid = item.ALLCommission - item.Paid;
item.GrossProfit = item.AllPrice - item.ALLCommission; item.GrossProfit = item.AllPrice - item.ALLCommission;
item.GrossProfitRate = item.AllPrice == 0 ? 0 : item.GrossProfit / item.AllPrice; item.GrossProfitRate = item.AllPrice == 0 ? 0 : Math.Round((item.GrossProfit / item.AllPrice), 2, MidpointRounding.AwayFromZero);
} }
#region 组装数据 #region 组装数据
int Num = 0; int Num = 0;
......
...@@ -285,6 +285,8 @@ namespace Mall.WebApi.Controllers.AppletWeChat ...@@ -285,6 +285,8 @@ namespace Mall.WebApi.Controllers.AppletWeChat
#region 测试接口 #region 测试接口
public ApiResult TestReturn() public ApiResult TestReturn()
{ {
RB_MiniProgram_Extend miniProgram = new RB_MiniProgram_Extend(); //2020年5月26号新增 RB_MiniProgram_Extend miniProgram = new RB_MiniProgram_Extend(); //2020年5月26号新增
...@@ -302,6 +304,24 @@ namespace Mall.WebApi.Controllers.AppletWeChat ...@@ -302,6 +304,24 @@ namespace Mall.WebApi.Controllers.AppletWeChat
} }
public ApiResult TestWeChatPay()
{
RB_MiniProgram_Extend miniProgram = new RB_MiniProgram_Extend(); //2020年5月26号新增
miniProgram = new RB_MiniProgram_Extend { MiniAppId = "wxacd9f8cc3480d29e", WeChatApiSecret = "936110e2c2214340b9829a3608bde6b0", WeChatPayMerchants = "1562277941" }; // programModule.GetMiniProgramModule(new RB_MiniProgram_Extend { MallBaseId = 1, TenantId =1 });
string RefundOrderNo = "2020052916044326411";
var pram = new Common.Pay.WeChatPat.PayParam()
{
TotalFee = Convert.ToInt32(0.01 * 100),
RefundFee = Convert.ToInt32(0.01 * 100),
OrderNumber = "202005291604432641",
RefundNumber = RefundOrderNo
};
string sOrderNo = (System.DateTime.Now.ToString("yyyyMMddHHmmssfff")) + "1001";
App_Code.PayUtil.GetMinUnifiedOrder(sOrderNo, "测试",Convert.ToDecimal(0.05), "1","", Config.sTenpayNotify, miniProgram, _accessor, System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList.FirstOrDefault(address => address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)?.ToString());
return ApiResult.Success("");
}
public ApiResult TestTransfersOrder() public ApiResult TestTransfersOrder()
{ {
RB_MiniProgram_Extend miniProgram = new RB_MiniProgram_Extend(); //2020年5月26号新增 RB_MiniProgram_Extend miniProgram = new RB_MiniProgram_Extend(); //2020年5月26号新增
......
...@@ -51,6 +51,11 @@ namespace Mall.WebApi.Controllers ...@@ -51,6 +51,11 @@ namespace Mall.WebApi.Controllers
/// </summary> /// </summary>
private static IntegralModule integralModule = new IntegralModule(); private static IntegralModule integralModule = new IntegralModule();
/// <summary>
/// 充值设置
/// </summary>
private static RechargeModule rechargeModule = new RechargeModule();
/// <summary> /// <summary>
/// 用户处理类 /// 用户处理类
/// </summary> /// </summary>
...@@ -171,7 +176,7 @@ namespace Mall.WebApi.Controllers ...@@ -171,7 +176,7 @@ namespace Mall.WebApi.Controllers
TenantId = TenantId, TenantId = TenantId,
MallBaseId = MallBaseId, MallBaseId = MallBaseId,
GoodsIds = Ids, GoodsIds = Ids,
GoodsStatus=1 GoodsStatus = 1
}); });
List<GoodsDetailsItem2> newGoodsList = new List<GoodsDetailsItem2>(); List<GoodsDetailsItem2> newGoodsList = new List<GoodsDetailsItem2>();
...@@ -182,7 +187,7 @@ namespace Mall.WebApi.Controllers ...@@ -182,7 +187,7 @@ namespace Mall.WebApi.Controllers
{ {
lastItem.id = tempGood.Id; lastItem.id = tempGood.Id;
lastItem.name = tempGood.Name; lastItem.name = tempGood.Name;
lastItem.price = Math.Round((tempGood?.SellingPrice??0), 2); lastItem.price = Math.Round((tempGood?.SellingPrice ?? 0), 2);
lastItem.picUrl = tempGood?.CoverImage != null ? Common.Config.GetFileUrl(tempGood.CoverImage) : ""; lastItem.picUrl = tempGood?.CoverImage != null ? Common.Config.GetFileUrl(tempGood.CoverImage) : "";
lastItem.OriginalPrice = Math.Round((tempGood?.OriginalPrice ?? 0), 2); lastItem.OriginalPrice = Math.Round((tempGood?.OriginalPrice ?? 0), 2);
newGoodsList.Add(lastItem); newGoodsList.Add(lastItem);
...@@ -746,7 +751,7 @@ namespace Mall.WebApi.Controllers ...@@ -746,7 +751,7 @@ namespace Mall.WebApi.Controllers
{ {
TenantId = Convert.ToInt32(miniProgram.TenantId), TenantId = Convert.ToInt32(miniProgram.TenantId),
MallBaseId = miniProgram.MallBaseId, MallBaseId = miniProgram.MallBaseId,
GoodsStatus=1, GoodsStatus = 1,
}); });
if (goodsList != null && goodsList.Count > 0) if (goodsList != null && goodsList.Count > 0)
{ {
...@@ -865,7 +870,7 @@ namespace Mall.WebApi.Controllers ...@@ -865,7 +870,7 @@ namespace Mall.WebApi.Controllers
h = 1, h = 1,
x = 0, x = 0,
y = 0, y = 0,
link = new List<rubikLinkItem>() link = new List<rubikLinkItem>()
{ {
new rubikLinkItem() new rubikLinkItem()
{ {
...@@ -923,7 +928,7 @@ namespace Mall.WebApi.Controllers ...@@ -923,7 +928,7 @@ namespace Mall.WebApi.Controllers
h = 12, h = 12,
x = 10, x = 10,
y = 0, y = 0,
link = new List<rubikLinkItem>() link = new List<rubikLinkItem>()
{ {
new rubikLinkItem() new rubikLinkItem()
{ {
...@@ -981,7 +986,7 @@ namespace Mall.WebApi.Controllers ...@@ -981,7 +986,7 @@ namespace Mall.WebApi.Controllers
h = 6, h = 6,
x = 10, x = 10,
y = 0, y = 0,
link = new List<rubikLinkItem>() link = new List<rubikLinkItem>()
{ {
new rubikLinkItem() new rubikLinkItem()
{ {
...@@ -1039,7 +1044,7 @@ namespace Mall.WebApi.Controllers ...@@ -1039,7 +1044,7 @@ namespace Mall.WebApi.Controllers
h = 24, h = 24,
x = 0, x = 0,
y = 0, y = 0,
link = new List<rubikLinkItem>() link = new List<rubikLinkItem>()
{ {
new rubikLinkItem() new rubikLinkItem()
{ {
...@@ -1065,7 +1070,7 @@ namespace Mall.WebApi.Controllers ...@@ -1065,7 +1070,7 @@ namespace Mall.WebApi.Controllers
h = 12, h = 12,
x = 20, x = 20,
y = 0, y = 0,
link = new List<rubikLinkItem>() link = new List<rubikLinkItem>()
{ {
new rubikLinkItem() new rubikLinkItem()
{ {
...@@ -1091,7 +1096,7 @@ namespace Mall.WebApi.Controllers ...@@ -1091,7 +1096,7 @@ namespace Mall.WebApi.Controllers
h = 12, h = 12,
x = 20, x = 20,
y = 12, y = 12,
link = new List<rubikLinkItem>() link = new List<rubikLinkItem>()
{ {
new rubikLinkItem() new rubikLinkItem()
{ {
...@@ -1117,7 +1122,7 @@ namespace Mall.WebApi.Controllers ...@@ -1117,7 +1122,7 @@ namespace Mall.WebApi.Controllers
h = 12, h = 12,
x = 35, x = 35,
y = 12, y = 12,
link = new List<rubikLinkItem>() link = new List<rubikLinkItem>()
{ {
new rubikLinkItem() new rubikLinkItem()
{ {
...@@ -1149,7 +1154,7 @@ namespace Mall.WebApi.Controllers ...@@ -1149,7 +1154,7 @@ namespace Mall.WebApi.Controllers
h = 16, h = 16,
x = 0, x = 0,
y = 0, y = 0,
link = new List<rubikLinkItem>() link = new List<rubikLinkItem>()
{ {
new rubikLinkItem() new rubikLinkItem()
{ {
...@@ -1207,7 +1212,7 @@ namespace Mall.WebApi.Controllers ...@@ -1207,7 +1212,7 @@ namespace Mall.WebApi.Controllers
h = 24, h = 24,
x = 0, x = 0,
y = 0, y = 0,
link = new List<rubikLinkItem>() link = new List<rubikLinkItem>()
{ {
new rubikLinkItem() new rubikLinkItem()
{ {
...@@ -1318,7 +1323,7 @@ namespace Mall.WebApi.Controllers ...@@ -1318,7 +1323,7 @@ namespace Mall.WebApi.Controllers
h = 1, h = 1,
x = 1, x = 1,
y = 0, y = 0,
link = new List<rubikLinkItem>() link = new List<rubikLinkItem>()
{ {
new rubikLinkItem() new rubikLinkItem()
{ {
...@@ -1555,6 +1560,13 @@ namespace Mall.WebApi.Controllers ...@@ -1555,6 +1560,13 @@ namespace Mall.WebApi.Controllers
{ {
integralModel = new RB_Integral_Settings(); integralModel = new RB_Integral_Settings();
} }
//充值信息
var rechargeModel = rechargeModule.GetRechargeSettingsList(new RB_Recharge_Settings { TenantId = miniProgram.TenantId ?? 0, MallBaseId = miniProgram.MallBaseId }).FirstOrDefault();
if (rechargeModel == null)
{
rechargeModel = new RB_Recharge_Settings();
}
List<string> payment_type = new List<string>(); List<string> payment_type = new List<string>();
if (!string.IsNullOrWhiteSpace(mallBaseModel.PayWay)) if (!string.IsNullOrWhiteSpace(mallBaseModel.PayWay))
{ {
...@@ -1620,7 +1632,7 @@ namespace Mall.WebApi.Controllers ...@@ -1620,7 +1632,7 @@ namespace Mall.WebApi.Controllers
} }
//商城风格 //商城风格
var mallStyle = new object(); var mallStyle = new object();
ResultMallShopStyle resultMallShopStyle = new ResultMallShopStyle(); ResultMallShopStyle resultMallShopStyle = new ResultMallShopStyle();
switch (miniProgram.MallShopStyle) switch (miniProgram.MallShopStyle)
{ {
...@@ -1660,7 +1672,7 @@ namespace Mall.WebApi.Controllers ...@@ -1660,7 +1672,7 @@ namespace Mall.WebApi.Controllers
resultMallShopStyle?.main, resultMallShopStyle?.main,
resultMallShopStyle?.secondary, resultMallShopStyle?.secondary,
}; };
var setting = new var setting = new
{ {
mallStyle, mallStyle,
...@@ -1710,8 +1722,8 @@ namespace Mall.WebApi.Controllers ...@@ -1710,8 +1722,8 @@ namespace Mall.WebApi.Controllers
is_quick_map = mallBaseModel?.ShortcutNavigation, is_quick_map = mallBaseModel?.ShortcutNavigation,
quick_map_pic = mallBaseModel?.ShortcutNavigationIco, quick_map_pic = mallBaseModel?.ShortcutNavigationIco,
quick_map_address = mallBaseModel?.Address, quick_map_address = mallBaseModel?.Address,
longitude =!string.IsNullOrWhiteSpace(mallBaseModel.LongAndLat)? mallBaseModel?.LongAndLat.Split(",")[0]:"", longitude = !string.IsNullOrWhiteSpace(mallBaseModel.LongAndLat) ? mallBaseModel?.LongAndLat.Split(",")[0] : "",
latitude = !string.IsNullOrWhiteSpace(mallBaseModel.LongAndLat) ? mallBaseModel?.LongAndLat.Split(",")[1]:"", latitude = !string.IsNullOrWhiteSpace(mallBaseModel.LongAndLat) ? mallBaseModel?.LongAndLat.Split(",")[1] : "",
is_quick_home = mallBaseModel?.BackTopNavigation, is_quick_home = mallBaseModel?.BackTopNavigation,
quick_home_pic = mallBaseModel?.BackTopNavigationIco, quick_home_pic = mallBaseModel?.BackTopNavigationIco,
logo = "", logo = "",
...@@ -1753,7 +1765,8 @@ namespace Mall.WebApi.Controllers ...@@ -1753,7 +1765,8 @@ namespace Mall.WebApi.Controllers
quick_customize_link_url = mallBaseModel?.TurnLink, quick_customize_link_url = mallBaseModel?.TurnLink,
quick_customize_new_params = "", quick_customize_new_params = "",
theme_color = "", theme_color = "",
latitude_longitude = mallBaseModel?.LongAndLat latitude_longitude = mallBaseModel?.LongAndLat,
IsShowRecharge = rechargeModel.IsOpenBtn
}; };
#endregion #endregion
return setting; return setting;
...@@ -1799,7 +1812,7 @@ namespace Mall.WebApi.Controllers ...@@ -1799,7 +1812,7 @@ namespace Mall.WebApi.Controllers
} }
} }
var share_setting = new var share_setting = new
{ {
level = distributorBasics?.DistributorTier, level = distributorBasics?.DistributorTier,
is_rebate = distributorBasics?.InPurchasing, is_rebate = distributorBasics?.InPurchasing,
......
...@@ -340,7 +340,7 @@ namespace Mall.WebApi.Controllers.MarketingCenter ...@@ -340,7 +340,7 @@ namespace Mall.WebApi.Controllers.MarketingCenter
item.ALLCommission = item.CostFreight + item.CostMoney + item.PackingMoney + item.GoodsFreight + item.OneCommission + item.TwoCommission + item.OtherPrice; item.ALLCommission = item.CostFreight + item.CostMoney + item.PackingMoney + item.GoodsFreight + item.OneCommission + item.TwoCommission + item.OtherPrice;
item.NoPaid = item.ALLCommission - item.Paid; item.NoPaid = item.ALLCommission - item.Paid;
item.GrossProfit = item.AllPrice - item.ALLCommission; item.GrossProfit = item.AllPrice - item.ALLCommission;
item.GrossProfitRate = item.AllPrice == 0 ? 0 : item.GrossProfit / item.AllPrice; item.GrossProfitRate = item.AllPrice == 0 ? 0 : Math.Round((item.GrossProfit / item.AllPrice), 2, MidpointRounding.AwayFromZero);
} }
pagelist.count = Convert.ToInt32(count); pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list; pagelist.pageData = list;
...@@ -402,7 +402,7 @@ namespace Mall.WebApi.Controllers.MarketingCenter ...@@ -402,7 +402,7 @@ namespace Mall.WebApi.Controllers.MarketingCenter
item.ALLCommission = item.CostFreight + item.CostMoney + item.PackingMoney + item.GoodsFreight + item.OneCommission + item.TwoCommission + item.OtherPrice; item.ALLCommission = item.CostFreight + item.CostMoney + item.PackingMoney + item.GoodsFreight + item.OneCommission + item.TwoCommission + item.OtherPrice;
item.NoPaid = item.ALLCommission - item.Paid; item.NoPaid = item.ALLCommission - item.Paid;
item.GrossProfit = item.AllPrice - item.ALLCommission; item.GrossProfit = item.AllPrice - item.ALLCommission;
item.GrossProfitRate = item.AllPrice == 0 ? 0 : item.GrossProfit / item.AllPrice; item.GrossProfitRate = item.AllPrice == 0 ? 0 : Math.Round((item.GrossProfit / item.AllPrice), 2, MidpointRounding.AwayFromZero);
} }
#region 组装数据 #region 组装数据
int Num = 0; int Num = 0;
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Mall.CacheManager\Mall.CacheManager.csproj" />
<ProjectReference Include="..\Mall.Common\Mall.Common.csproj" /> <ProjectReference Include="..\Mall.Common\Mall.Common.csproj" />
<ProjectReference Include="..\Mall.DataAccess\Mall.DataAccess.csproj" /> <ProjectReference Include="..\Mall.DataAccess\Mall.DataAccess.csproj" />
<ProjectReference Include="..\Mall.Model\Mall.Model.csproj" /> <ProjectReference Include="..\Mall.Model\Mall.Model.csproj" />
......
using DapperExtensions.Lambda; using DapperExtensions.Lambda;
using Mall.CacheManager.AppletWeChat;
using Mall.Common; using Mall.Common;
using Mall.Common.Enum.Goods; using Mall.Common.Enum.Goods;
using Mall.Common.Enum.User; using Mall.Common.Enum.User;
...@@ -322,11 +323,14 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A ...@@ -322,11 +323,14 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A
{ {
try try
{ {
Dictionary<string, object> keyValues = new Dictionary<string, object>() { }; string cacheOrderId = OrderPayReidsCache.Get(qitem.OrderId.ToString());
keyValues.Add(nameof(RB_Goods_Order_Extend.OrderStatus), OrderStatusEnum.Cancel); if (string.IsNullOrWhiteSpace(cacheOrderId))
keyValues.Add(nameof(RB_Goods_Order_Extend.CancelTime), DateTime.Now); {
Dictionary<string, object> keyValues = new Dictionary<string, object>() { };
keyValues.Add(nameof(RB_Goods_Order_Extend.OrderStatus), OrderStatusEnum.Cancel);
keyValues.Add(nameof(RB_Goods_Order_Extend.CancelTime), DateTime.Now);
List<WhereHelper> wheres = new List<WhereHelper>() { List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){ new WhereHelper(){
FiledName=nameof(RB_Goods_Order_Extend.OrderId), FiledName=nameof(RB_Goods_Order_Extend.OrderId),
FiledValue=qitem.OrderId, FiledValue=qitem.OrderId,
...@@ -348,155 +352,156 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A ...@@ -348,155 +352,156 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A
OperatorEnum=OperatorEnum.Equal OperatorEnum=OperatorEnum.Equal
} }
}; };
bool flag = goods_OrderRepository.Update(keyValues, wheres); bool flag = goods_OrderRepository.Update(keyValues, wheres);
if (flag) if (flag)
{
//回滚商品库存
if (true)
{ {
int tenantId = item.TenantId; //回滚商品库存
int mallBaseId = item.MallBaseId; if (true)
int TotalIntegralNumber = 0;
var detailList = goodsOrderDetailRepository.GetOrderDetailList(new RB_Goods_OrderDetail_Extend() { OrderId = qitem.OrderId, TenantId = tenantId, MallBaseId = mallBaseId });
if (detailList.Any())
{ {
string goodsIds = string.Join(",", detailList.Select(x => x.GoodsId ?? 0).Distinct()); int tenantId = item.TenantId;
var goodsList = goodsRepository.GetList(new RB_Goods_Extend() { GoodsIds = goodsIds, TenantId = tenantId, MallBaseId = mallBaseId }); int mallBaseId = item.MallBaseId;
var speciPList = goods_SpecificationPriceRepository.GetList(new RB_Goods_SpecificationPrice_Extend() { GoodsIds = goodsIds, TenantId = tenantId, MallBaseId = mallBaseId }); int TotalIntegralNumber = 0;
var detailList = goodsOrderDetailRepository.GetOrderDetailList(new RB_Goods_OrderDetail_Extend() { OrderId = qitem.OrderId, TenantId = tenantId, MallBaseId = mallBaseId });
foreach (var ditem in detailList) if (detailList.Any())
{ {
var gmodel = goodsList.Where(x => x.Id == ditem.GoodsId).FirstOrDefault(); string goodsIds = string.Join(",", detailList.Select(x => x.GoodsId ?? 0).Distinct());
if (gmodel == null) var goodsList = goodsRepository.GetList(new RB_Goods_Extend() { GoodsIds = goodsIds, TenantId = tenantId, MallBaseId = mallBaseId });
{ var speciPList = goods_SpecificationPriceRepository.GetList(new RB_Goods_SpecificationPrice_Extend() { GoodsIds = goodsIds, TenantId = tenantId, MallBaseId = mallBaseId });
continue;
} foreach (var ditem in detailList)
if (string.IsNullOrEmpty(ditem.SpecificationSort))
{ {
if (gmodel.IsCustomSpecification == 1) var gmodel = goodsList.Where(x => x.Id == ditem.GoodsId).FirstOrDefault();
if (gmodel == null)
{ {
continue; continue;
} }
} if (string.IsNullOrEmpty(ditem.SpecificationSort))
else
{
if (gmodel.IsCustomSpecification != 1)
{ {
continue; if (gmodel.IsCustomSpecification == 1)
{
continue;
}
} }
var speciPModel = speciPList.Where(x => x.GoodsId == ditem.GoodsId && x.SpecificationSort == ditem.SpecificationSort).FirstOrDefault(); else
if (speciPModel == null)
{ {
continue; if (gmodel.IsCustomSpecification != 1)
} {
//更新商品规格表库存 + 商品表总库存 continue;
Dictionary<string, object> keyValues2 = new Dictionary<string, object>() { }
var speciPModel = speciPList.Where(x => x.GoodsId == ditem.GoodsId && x.SpecificationSort == ditem.SpecificationSort).FirstOrDefault();
if (speciPModel == null)
{
continue;
}
//更新商品规格表库存 + 商品表总库存
Dictionary<string, object> keyValues2 = new Dictionary<string, object>() {
{ nameof(RB_Goods_SpecificationPrice_Extend.InventoryNum), (speciPModel.InventoryNum??0)+(ditem.Number??0)} { nameof(RB_Goods_SpecificationPrice_Extend.InventoryNum), (speciPModel.InventoryNum??0)+(ditem.Number??0)}
}; };
List<WhereHelper> wheres2 = new List<WhereHelper>() { List<WhereHelper> wheres2 = new List<WhereHelper>() {
new WhereHelper(){ new WhereHelper(){
FiledName=nameof(RB_Goods_SpecificationPrice_Extend.Id), FiledName=nameof(RB_Goods_SpecificationPrice_Extend.Id),
FiledValue=speciPModel.Id, FiledValue=speciPModel.Id,
OperatorEnum=OperatorEnum.Equal OperatorEnum=OperatorEnum.Equal
} }
}; };
goods_SpecificationPriceRepository.Update(keyValues2, wheres2); goods_SpecificationPriceRepository.Update(keyValues2, wheres2);
} }
//更新商品表库存 //更新商品表库存
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() { Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Goods_Extend.InventoryNum), (gmodel.InventoryNum??0)+(ditem.Number??0)} { nameof(RB_Goods_Extend.InventoryNum), (gmodel.InventoryNum??0)+(ditem.Number??0)}
}; };
List<WhereHelper> wheres1 = new List<WhereHelper>() { List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){ new WhereHelper(){
FiledName=nameof(RB_Goods_Extend.Id), FiledName=nameof(RB_Goods_Extend.Id),
FiledValue=gmodel.Id, FiledValue=gmodel.Id,
OperatorEnum=OperatorEnum.Equal OperatorEnum=OperatorEnum.Equal
} }
}; };
goodsRepository.Update(keyValues1, wheres1); goodsRepository.Update(keyValues1, wheres1);
goods_LogRepository.Insert(new Mall.Model.Entity.Product.RB_Goods_Log() goods_LogRepository.Insert(new Mall.Model.Entity.Product.RB_Goods_Log()
{ {
Id = 0, Id = 0,
Type = 2, Type = 2,
SourceId = ditem.GoodsId, SourceId = ditem.GoodsId,
Content = $"取消订单{qitem.OrderId},还原商品库存:" + ditem.Number, Content = $"取消订单{qitem.OrderId},还原商品库存:" + ditem.Number,
CreateDate = DateTime.Now, CreateDate = DateTime.Now,
MallBaseId = mallBaseId, MallBaseId = mallBaseId,
TenantId = tenantId TenantId = tenantId
}); });
if (ditem.IntegralNumber > 0) if (ditem.IntegralNumber > 0)
{ {
TotalIntegralNumber += (ditem.IntegralNumber ?? 0); TotalIntegralNumber += (ditem.IntegralNumber ?? 0);
}
} }
} }
} var umodel = member_UserRepository.GetEntity(qitem.UserId);
var umodel = member_UserRepository.GetEntity(qitem.UserId); //积分抵扣回滚
//积分抵扣回滚 if (TotalIntegralNumber > 0)
if (TotalIntegralNumber > 0) {
{ Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Member_User_Extend.Integral),umodel.Integral + TotalIntegralNumber} { nameof(RB_Member_User_Extend.Integral),umodel.Integral + TotalIntegralNumber}
}; };
List<WhereHelper> wheres1 = new List<WhereHelper>() { List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){ new WhereHelper(){
FiledName=nameof(RB_Member_User_Extend.Id), FiledName=nameof(RB_Member_User_Extend.Id),
FiledValue=umodel.Id, FiledValue=umodel.Id,
OperatorEnum=OperatorEnum.Equal OperatorEnum=OperatorEnum.Equal
} }
}; };
bool flag2 = member_UserRepository.Update(keyValues1, wheres1); bool flag2 = member_UserRepository.Update(keyValues1, wheres1);
if (flag2) if (flag2)
{
member_IntegralRepository.Insert(new Mall.Model.Entity.User.RB_Member_Integral()
{ {
Id = 0, member_IntegralRepository.Insert(new Mall.Model.Entity.User.RB_Member_Integral()
CreateDate = DateTime.Now, {
Description = "订单取消返回积分抵扣,订单号:" + qitem.OrderNo, Id = 0,
Image = 0, CreateDate = DateTime.Now,
Integral = TotalIntegralNumber, Description = "订单取消返回积分抵扣,订单号:" + qitem.OrderNo,
MallBaseId = item.MallBaseId, Image = 0,
PlatformType = qitem.OrderSource, Integral = TotalIntegralNumber,
Remarks = "", MallBaseId = item.MallBaseId,
TenantId = item.TenantId, PlatformType = qitem.OrderSource,
Type = Common.Enum.MarketingCenter.RecordTypeEnum.Income, Remarks = "",
UserId = qitem.UserId, TenantId = item.TenantId,
OrderId = qitem.OrderId Type = Common.Enum.MarketingCenter.RecordTypeEnum.Income,
}); UserId = qitem.UserId,
OrderId = qitem.OrderId
});
}
} }
} //优惠券回滚
//优惠券回滚 if (!string.IsNullOrEmpty(qitem.CouponsIds))
if (!string.IsNullOrEmpty(qitem.CouponsIds))
{
var cList = member_CouponRepository.GetList(new RB_Member_DiscountCoupon_Extend() { UseState = 1, Ids = qitem.CouponsIds, UserId = qitem.UserId, TenantId = item.TenantId, MallBaseId = item.MallBaseId });
foreach (var citem in cList)
{ {
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() { var cList = member_CouponRepository.GetList(new RB_Member_DiscountCoupon_Extend() { UseState = 1, Ids = qitem.CouponsIds, UserId = qitem.UserId, TenantId = item.TenantId, MallBaseId = item.MallBaseId });
foreach (var citem in cList)
{
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Member_DiscountCoupon_Extend.UseState),0} { nameof(RB_Member_DiscountCoupon_Extend.UseState),0}
}; };
List<WhereHelper> wheres1 = new List<WhereHelper>() { List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){ new WhereHelper(){
FiledName=nameof(RB_Member_DiscountCoupon_Extend.Id), FiledName=nameof(RB_Member_DiscountCoupon_Extend.Id),
FiledValue=citem.Id, FiledValue=citem.Id,
OperatorEnum=OperatorEnum.Equal OperatorEnum=OperatorEnum.Equal
} }
}; };
member_CouponRepository.Update(keyValues1, wheres1); member_CouponRepository.Update(keyValues1, wheres1);
}
} }
} //余额支付回滚
//余额支付回滚
}
goods_LogRepository.Insert(new Mall.Model.Entity.Product.RB_Goods_Log()
{
Id = 0,
Type = 1,
SourceId = qitem.OrderId,
Content = "订单超时,自动取消订单",
CreateDate = DateTime.Now,
MallBaseId = item.MallBaseId,
TenantId = item.TenantId
});
} }
goods_LogRepository.Insert(new Mall.Model.Entity.Product.RB_Goods_Log()
{
Id = 0,
Type = 1,
SourceId = qitem.OrderId,
Content = "订单超时,自动取消订单",
CreateDate = DateTime.Now,
MallBaseId = item.MallBaseId,
TenantId = item.TenantId
});
} }
} }
catch (Exception ex) catch (Exception ex)
......
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