|
@@ -35,7 +35,7 @@ namespace MySystem
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "public_service");
|
|
|
+ function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "商城订单支付回调异常");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -80,18 +80,46 @@ namespace MySystem
|
|
|
db.SaveChanges();
|
|
|
RedisDbconn.Instance.Set("Orders:" + order.Id, order);
|
|
|
|
|
|
+ //机具券逻辑
|
|
|
OrderProduct pro = db.OrderProduct.FirstOrDefault(m => m.OrderId == OrderId);
|
|
|
if (pro != null)
|
|
|
{
|
|
|
- KqProducts brand = db.KqProducts.FirstOrDefault(m => m.Sort == pro.ProductId);
|
|
|
- if (brand != null)
|
|
|
+ if (pro.ProductId == 10 || pro.ProductId == 11 || pro.ProductId == 12 || pro.ProductId == 13)
|
|
|
{
|
|
|
order.Status = 2;
|
|
|
db.SaveChanges();
|
|
|
int BuyCount = pro.ProductCount;
|
|
|
int Kind = 0;
|
|
|
- if(pro.ProductPrice == 200) Kind = 1;
|
|
|
- if(pro.ProductPrice == 300) Kind = 2;
|
|
|
+ if (pro.ProductId == 10)
|
|
|
+ {
|
|
|
+ Kind = 1;
|
|
|
+ }
|
|
|
+ else if (pro.ProductId == 11)
|
|
|
+ {
|
|
|
+ Kind = 2;
|
|
|
+ }
|
|
|
+ else if (pro.ProductId == 12)
|
|
|
+ {
|
|
|
+ if (pro.NormId == "12")
|
|
|
+ {
|
|
|
+ Kind = 1;
|
|
|
+ }
|
|
|
+ else if (pro.NormId == "13")
|
|
|
+ {
|
|
|
+ Kind = 2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (pro.ProductId == 13)
|
|
|
+ {
|
|
|
+ if (pro.NormId == "14")
|
|
|
+ {
|
|
|
+ Kind = 1;
|
|
|
+ }
|
|
|
+ else if (pro.NormId == "15")
|
|
|
+ {
|
|
|
+ Kind = 2;
|
|
|
+ }
|
|
|
+ }
|
|
|
string Codes = "";
|
|
|
var coupons = db.PosCoupons.Where(m => m.IsLock == 0 && m.IsUse == 0 && m.UserId == 0 && m.QueryCount == Kind).OrderBy(m => m.Id).Take(BuyCount).ToList();
|
|
|
foreach (var coupon in coupons)
|
|
@@ -143,6 +171,70 @@ namespace MySystem
|
|
|
db.SaveChanges();
|
|
|
RedisDbconn.Instance.Clear("Orders:" + order.Id);
|
|
|
}
|
|
|
+
|
|
|
+ //推荐下单奖励
|
|
|
+ if (pro.ProductId == 10 || pro.ProductId == 11)
|
|
|
+ {
|
|
|
+ bool SelfBuy = db.OrderProduct.Any(m => m.UserId == order.UserId && m.OrderId != OrderId && (m.ProductId == 10 || m.ProductId == 11));
|
|
|
+ if (!SelfBuy)
|
|
|
+ {
|
|
|
+ Users user = db.Users.FirstOrDefault(m => m.Id == order.UserId);
|
|
|
+ if (user != null)
|
|
|
+ {
|
|
|
+ int ParentUserId = user.ParentUserId;
|
|
|
+ bool ParentBuy = db.OrderProduct.Any(m => m.UserId == ParentUserId && (m.ProductId == 10 || m.ProductId == 11));
|
|
|
+ if (ParentBuy)
|
|
|
+ {
|
|
|
+ UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == ParentUserId);
|
|
|
+ if (account == null)
|
|
|
+ {
|
|
|
+ account = db.UserAccount.Add(new UserAccount()
|
|
|
+ {
|
|
|
+ Id = ParentUserId,
|
|
|
+ UserId = ParentUserId,
|
|
|
+ }).Entity;
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+ decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
|
|
|
+ decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
|
|
|
+ decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
|
|
|
+ account.BalanceAmount += 100;
|
|
|
+ account.TotalAmount += 100;
|
|
|
+ decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
|
|
|
+ decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
|
|
|
+ decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
|
|
|
+ UserAccountRecord userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
|
|
|
+ {
|
|
|
+ CreateDate = DateTime.Now,
|
|
|
+ UpdateDate = DateTime.Now,
|
|
|
+ UserId = ParentUserId, //创客
|
|
|
+ ChangeType = 112, //变动类型
|
|
|
+ ChangeAmount = 100, //变更金额
|
|
|
+ BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
|
|
|
+ AfterTotalAmount = AfterTotalAmount, //变更后总金额
|
|
|
+ BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
|
|
|
+ AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
|
|
|
+ BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
|
|
|
+ AfterBalanceAmount = AfterBalanceAmount, //变更后余额
|
|
|
+ }).Entity;
|
|
|
+ db.SaveChanges();
|
|
|
+ RedisDbconn.Instance.Set("UserAccount:" + ParentUserId, account);
|
|
|
+
|
|
|
+ //推荐下单上级获得30天的机具循环天数
|
|
|
+ var posList = db.PosMachinesTwo.Select(m => new { m.Id, m.UserId, m.BindingState, m.RecycEndDate }).Where(m => m.UserId == ParentUserId && m.BindingState == 0 && m.RecycEndDate != null);
|
|
|
+ foreach (var subPos in posList)
|
|
|
+ {
|
|
|
+ PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == subPos.Id);
|
|
|
+ if (pos != null)
|
|
|
+ {
|
|
|
+ pos.RecycEndDate = pos.RecycEndDate.Value.AddDays(30);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|