|
@@ -13,7 +13,7 @@ using Microsoft.AspNetCore.Mvc;
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
using Microsoft.Extensions.Options;
|
|
|
-using MySystem.Models;
|
|
|
+using MySystem.KxsMainModels;
|
|
|
using Library;
|
|
|
using LitJson;
|
|
|
using MySystemLib;
|
|
@@ -70,7 +70,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
Fields.Add("TopUserId", "0");
|
|
|
|
|
|
|
|
|
- string condition = " and Status>-1 and ProductId=49";
|
|
|
+ string condition = " and Status>-1 and ProductId=52";
|
|
|
//平台订单号
|
|
|
if (!string.IsNullOrEmpty(OrderNo))
|
|
|
{
|
|
@@ -211,7 +211,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
dic["ErpInfo"] = dic["ErpCode"].ToString() + "<br />" + dic["ErpName"].ToString();
|
|
|
//创客
|
|
|
int UserId = int.Parse(function.CheckInt(dic["UserId"].ToString()));
|
|
|
- Users userid_Users = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
|
|
|
+ Users userid_Users = kxsdb.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
|
|
|
dic["UserInfo"] = userid_Users.MakerCode + "<br />" + userid_Users.RealName;
|
|
|
dic.Remove("UserId");
|
|
|
//物流名称
|
|
@@ -224,7 +224,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
if (PayMode == 0) dic["PayMode"] = "";
|
|
|
//仓库
|
|
|
int StoreId = int.Parse(function.CheckInt(dic["StoreId"].ToString()));
|
|
|
- StoreHouse storeid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new StoreHouse();
|
|
|
+ StoreHouse storeid_StoreHouse = kxsdb.StoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new StoreHouse();
|
|
|
//仓库类型
|
|
|
int StoreType = int.Parse(dic["StoreType"].ToString());
|
|
|
if (StoreType == 0) dic["StoreType"] = "总仓";
|
|
@@ -258,17 +258,17 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
|
|
|
//商品名称
|
|
|
int Id = int.Parse(function.CheckInt(dic["Id"].ToString()));
|
|
|
- OrderProduct orderProducts = db.OrderProduct.FirstOrDefault(m => m.OrderId == Id) ?? new OrderProduct();
|
|
|
+ OrderProduct orderProducts = kxsdb.OrderProduct.FirstOrDefault(m => m.OrderId == Id) ?? new OrderProduct();
|
|
|
dic["ProductName"] = orderProducts.ProductName;
|
|
|
|
|
|
//仓库归属创客
|
|
|
int StoreUserId = int.Parse(function.CheckInt(dic["StoreUserId"].ToString()));
|
|
|
- Users storeuserid_Users = db.Users.FirstOrDefault(m => m.Id == StoreUserId) ?? new Users();
|
|
|
+ Users storeuserid_Users = kxsdb.Users.FirstOrDefault(m => m.Id == StoreUserId) ?? new Users();
|
|
|
dic["StoreFrom"] = storeuserid_Users.MakerCode + "<br />" + storeid_StoreHouse.StoreName;
|
|
|
dic.Remove("StoreUserId");
|
|
|
//顶级创客
|
|
|
int TopUserId = int.Parse(function.CheckInt(dic["TopUserId"].ToString()));
|
|
|
- Users topuserid_Users = db.Users.FirstOrDefault(m => m.Id == TopUserId) ?? new Users();
|
|
|
+ Users topuserid_Users = kxsdb.Users.FirstOrDefault(m => m.Id == TopUserId) ?? new Users();
|
|
|
dic["TopUserInfo"] = topuserid_Users.MakerCode + "<br />" + topuserid_Users.RealName;
|
|
|
dic.Remove("TopUserId");
|
|
|
//支付状态
|
|
@@ -415,7 +415,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
Fields.Add("SeoDescription", data.SeoDescription);
|
|
|
int Id = new AdminContentOther(_accessor.HttpContext, PublicFunction.KxsMainTables).Add("Orders", Fields, 0);
|
|
|
AddSysLog(data.Id.ToString(), "Orders", "add");
|
|
|
- db.SaveChanges();
|
|
|
+ kxsdb.SaveChanges();
|
|
|
|
|
|
return "success";
|
|
|
}
|
|
@@ -434,7 +434,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
ViewBag.right = right;
|
|
|
|
|
|
|
|
|
- Orders editData = db.Orders.FirstOrDefault(m => m.Id == Id) ?? new Orders();
|
|
|
+ Orders editData = kxsdb.Orders.FirstOrDefault(m => m.Id == Id) ?? new Orders();
|
|
|
ViewBag.data = editData;
|
|
|
return View();
|
|
|
}
|
|
@@ -463,7 +463,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
Fields.Add("SeoDescription", data.SeoDescription);
|
|
|
new AdminContentOther(_accessor.HttpContext, PublicFunction.KxsMainTables).Edit("Orders", Fields, data.Id);
|
|
|
AddSysLog(data.Id.ToString(), "Orders", "update");
|
|
|
- db.SaveChanges();
|
|
|
+ kxsdb.SaveChanges();
|
|
|
|
|
|
return "success";
|
|
|
}
|
|
@@ -477,17 +477,17 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
ViewBag.RightInfo = RightInfo;
|
|
|
ViewBag.right = right;
|
|
|
|
|
|
- Orders editData = db.Orders.FirstOrDefault(m => m.Id == Id) ?? new Orders();
|
|
|
+ Orders editData = kxsdb.Orders.FirstOrDefault(m => m.Id == Id) ?? new Orders();
|
|
|
ViewBag.data = editData;
|
|
|
|
|
|
- Users user = db.Users.FirstOrDefault(m => m.Id == editData.UserId) ?? new Users();
|
|
|
+ Users user = kxsdb.Users.FirstOrDefault(m => m.Id == editData.UserId) ?? new Users();
|
|
|
ViewBag.MakerCode = user.MakerCode;
|
|
|
ViewBag.RealName = user.RealName;
|
|
|
|
|
|
- StoreHouse store = db.StoreHouse.FirstOrDefault(m => m.Id == editData.StoreId) ?? new StoreHouse();
|
|
|
+ StoreHouse store = kxsdb.StoreHouse.FirstOrDefault(m => m.Id == editData.StoreId) ?? new StoreHouse();
|
|
|
ViewBag.StoreName = store.StoreName;
|
|
|
|
|
|
- List<OrderProduct> products = db.OrderProduct.Where(m => m.OrderId == editData.Id).ToList();
|
|
|
+ List<OrderProduct> products = kxsdb.OrderProduct.Where(m => m.OrderId == editData.Id).ToList();
|
|
|
ViewBag.products = products;
|
|
|
return View();
|
|
|
}
|
|
@@ -509,34 +509,30 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
|
|
|
string[] Ids = IdList.TrimEnd('#').Split('#');
|
|
|
string[] StoreIds = StoreIdList.TrimEnd('#').Split('#');
|
|
|
- string[] SnNoss = SnNosList.TrimEnd('#').Split('#');
|
|
|
+ string[] SnNoss = SnNosList.TrimEnd('\n').Split('\n');
|
|
|
+ string err = "";
|
|
|
for (int i = 0; i < Ids.Length; i++)
|
|
|
{
|
|
|
- int Id = int.Parse(Ids[i]);
|
|
|
- int StoreId = int.Parse(StoreIds[i]);
|
|
|
string SnNos = SnNoss[i];
|
|
|
- OrderProduct pro = db.OrderProduct.FirstOrDefault(m => m.Id == Id);
|
|
|
- if (pro != null)
|
|
|
- {
|
|
|
- pro.StoreId = StoreId;
|
|
|
- pro.SnNos = SnNos;
|
|
|
- }
|
|
|
- PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == SnNos);
|
|
|
- if(pos != null)
|
|
|
+ bool check = db.PosMachinesTwo.Any(m => m.PosSn == SnNos);
|
|
|
+ if(!check)
|
|
|
{
|
|
|
- pos.StoreId = StoreId;
|
|
|
- pos.TransferTime = DateTime.Now;
|
|
|
- pos.BuyUserId = data.UserId;
|
|
|
- pos.UserId = data.UserId;
|
|
|
- }
|
|
|
- if (i == 0)
|
|
|
- {
|
|
|
- Fields.Add("StoreId", StoreId);
|
|
|
+ err += SnNos + "不存在\n";
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ if(!string.IsNullOrEmpty(err))
|
|
|
+ {
|
|
|
+ return err;
|
|
|
+ }
|
|
|
+ int StoreId = 1;
|
|
|
+ if(StoreIds.Length > 0) StoreId = int.Parse(StoreIds[0]);
|
|
|
+ Fields.Add("StoreId", StoreId);
|
|
|
new AdminContentOther(_accessor.HttpContext, PublicFunction.KxsMainTables).Edit("Orders", Fields, data.Id);
|
|
|
+
|
|
|
+ PublicFunction.StatUserMachineData(data.UserId, 0, SnNoss.Length);
|
|
|
+ PublicFunction.SendRecord(db, 0, data.UserId, StoreId, SnNoss);
|
|
|
AddSysLog(data.Id.ToString(), "Orders", "Send");
|
|
|
+ kxsdb.SaveChanges();
|
|
|
db.SaveChanges();
|
|
|
|
|
|
return "success";
|
|
@@ -552,7 +548,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
ViewBag.right = right;
|
|
|
|
|
|
|
|
|
- Orders editData = db.Orders.FirstOrDefault(m => m.Id == Id) ?? new Orders();
|
|
|
+ Orders editData = kxsdb.Orders.FirstOrDefault(m => m.Id == Id) ?? new Orders();
|
|
|
ViewBag.data = editData;
|
|
|
return View();
|
|
|
}
|
|
@@ -565,7 +561,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
public string Return(Orders data)
|
|
|
{
|
|
|
AddSysLog(data.Id.ToString(), "Orders", "Return");
|
|
|
- Orders order = db.Orders.FirstOrDefault(m => m.Id == data.Id);
|
|
|
+ Orders order = kxsdb.Orders.FirstOrDefault(m => m.Id == data.Id);
|
|
|
if (order != null)
|
|
|
{
|
|
|
// TODO: 调用支付接口退款,需要测试
|
|
@@ -582,7 +578,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
order.RefundActAmount = data.RefundActAmount;
|
|
|
order.RefundReason = data.RefundReason;
|
|
|
order.RefundStatus = 1;
|
|
|
- db.SaveChanges();
|
|
|
+ kxsdb.SaveChanges();
|
|
|
return "success";
|
|
|
}
|
|
|
// }
|
|
@@ -603,10 +599,10 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
ViewBag.RightInfo = RightInfo;
|
|
|
ViewBag.right = right;
|
|
|
|
|
|
- Orders editData = db.Orders.FirstOrDefault(m => m.Id == Id) ?? new Orders();
|
|
|
+ Orders editData = kxsdb.Orders.FirstOrDefault(m => m.Id == Id) ?? new Orders();
|
|
|
ViewBag.data = editData;
|
|
|
|
|
|
- Users user = db.Users.FirstOrDefault(m => m.Id == editData.UserId) ?? new Users();
|
|
|
+ Users user = kxsdb.Users.FirstOrDefault(m => m.Id == editData.UserId) ?? new Users();
|
|
|
ViewBag.MakerCode = user.MakerCode;
|
|
|
ViewBag.RealName = user.RealName;
|
|
|
|
|
@@ -647,7 +643,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
if (DeliveryType == 1) ViewBag.DeliveryType = "邮寄到付";
|
|
|
if (DeliveryType == 2) ViewBag.DeliveryType = "上门自提";
|
|
|
|
|
|
- List<OrderProduct> products = db.OrderProduct.Where(m => m.OrderId == editData.Id).ToList();
|
|
|
+ List<OrderProduct> products = kxsdb.OrderProduct.Where(m => m.OrderId == editData.Id).ToList();
|
|
|
List<Dictionary<string, object>> ProductList = new List<Dictionary<string, object>>();
|
|
|
foreach (OrderProduct product in products)
|
|
|
{
|
|
@@ -686,7 +682,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
Fields.Add("Status", -1);
|
|
|
new AdminContentOther(_accessor.HttpContext, PublicFunction.KxsMainTables).Edit("Orders", Fields, id);
|
|
|
}
|
|
|
- db.SaveChanges();
|
|
|
+ kxsdb.SaveChanges();
|
|
|
|
|
|
return "success";
|
|
|
}
|
|
@@ -710,7 +706,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
Fields.Add("Status", 1);
|
|
|
new AdminContentOther(_accessor.HttpContext, PublicFunction.KxsMainTables).Edit("Orders", Fields, id);
|
|
|
}
|
|
|
- db.SaveChanges();
|
|
|
+ kxsdb.SaveChanges();
|
|
|
return "success";
|
|
|
}
|
|
|
|
|
@@ -733,7 +729,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
Fields.Add("Status", 0);
|
|
|
new AdminContentOther(_accessor.HttpContext, PublicFunction.KxsMainTables).Edit("Orders", Fields, id);
|
|
|
}
|
|
|
- db.SaveChanges();
|
|
|
+ kxsdb.SaveChanges();
|
|
|
return "success";
|
|
|
}
|
|
|
|
|
@@ -766,13 +762,13 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
{
|
|
|
JsonData dr = list[i];
|
|
|
|
|
|
- db.Orders.Add(new Orders()
|
|
|
+ kxsdb.Orders.Add(new Orders()
|
|
|
{
|
|
|
CreateDate = DateTime.Now,
|
|
|
UpdateDate = DateTime.Now,
|
|
|
|
|
|
});
|
|
|
- db.SaveChanges();
|
|
|
+ kxsdb.SaveChanges();
|
|
|
}
|
|
|
AddSysLog("0", "Orders", "Import");
|
|
|
return "success";
|
|
@@ -799,7 +795,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
Fields.Add("SnNos", "2"); //SN编号
|
|
|
Fields.Add("TopUserId", "0");
|
|
|
|
|
|
- string condition = " and Status>-1 and ProductId=49";
|
|
|
+ string condition = " and Status>-1 and ProductId=52";
|
|
|
//创客编号
|
|
|
if (!string.IsNullOrEmpty(UserIdMakerCode))
|
|
|
{
|
|
@@ -906,7 +902,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
i += 1;
|
|
|
//创客
|
|
|
int UserId = int.Parse(function.CheckInt(dic["UserId"].ToString()));
|
|
|
- Users userid_Users = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
|
|
|
+ Users userid_Users = kxsdb.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
|
|
|
dic["UserIdMakerCode"] = userid_Users.MakerCode;
|
|
|
dic["UserIdRealName"] = userid_Users.RealName;
|
|
|
dic.Remove("UserId");
|
|
@@ -920,7 +916,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
if (PayMode == 0) dic["PayMode"] = "";
|
|
|
//仓库
|
|
|
int StoreId = int.Parse(function.CheckInt(dic["StoreId"].ToString()));
|
|
|
- StoreHouse storeid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new StoreHouse();
|
|
|
+ StoreHouse storeid_StoreHouse = kxsdb.StoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new StoreHouse();
|
|
|
dic["StoreIdStoreNo"] = storeid_StoreHouse.StoreNo;
|
|
|
dic["StoreIdStoreName"] = storeid_StoreHouse.StoreName;
|
|
|
dic.Remove("StoreId");
|
|
@@ -946,13 +942,13 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
if (StoreType == 1) dic["StoreType"] = "分仓";
|
|
|
//仓库归属创客
|
|
|
int StoreUserId = int.Parse(function.CheckInt(dic["StoreUserId"].ToString()));
|
|
|
- Users storeuserid_Users = db.Users.FirstOrDefault(m => m.Id == StoreUserId) ?? new Users();
|
|
|
+ Users storeuserid_Users = kxsdb.Users.FirstOrDefault(m => m.Id == StoreUserId) ?? new Users();
|
|
|
dic["StoreUserIdMakerCode"] = storeuserid_Users.MakerCode;
|
|
|
dic["StoreUserIdRealName"] = storeuserid_Users.RealName;
|
|
|
dic.Remove("StoreUserId");
|
|
|
//顶级创客
|
|
|
int TopUserId = int.Parse(function.CheckInt(dic["TopUserId"].ToString()));
|
|
|
- Users topuserid_Users = db.Users.FirstOrDefault(m => m.Id == TopUserId) ?? new Users();
|
|
|
+ Users topuserid_Users = kxsdb.Users.FirstOrDefault(m => m.Id == TopUserId) ?? new Users();
|
|
|
dic["TopUserIdMakerCode"] = topuserid_Users.MakerCode;
|
|
|
dic["TopUserIdRealName"] = topuserid_Users.RealName;
|
|
|
dic.Remove("TopUserId");
|
|
@@ -965,7 +961,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
if (PayStatus == 4) dic["PayStatus"] = "支付处理中";
|
|
|
|
|
|
int OrderId = int.Parse(dic["Id"].ToString());
|
|
|
- List<OrderProduct> products = db.OrderProduct.Where(m => m.OrderId == OrderId).ToList();
|
|
|
+ List<OrderProduct> products = kxsdb.OrderProduct.Where(m => m.OrderId == OrderId).ToList();
|
|
|
foreach (OrderProduct product in products)
|
|
|
{
|
|
|
dic["ProductCode"] = product.ProductCode; //商品编号
|
|
@@ -1171,7 +1167,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
{
|
|
|
//创客
|
|
|
int UserId = int.Parse(function.CheckInt(dic["UserId"].ToString()));
|
|
|
- Users userid_Users = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
|
|
|
+ Users userid_Users = kxsdb.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
|
|
|
dic["UserIdMakerCode"] = userid_Users.MakerCode;
|
|
|
dic["UserIdRealName"] = userid_Users.RealName;
|
|
|
dic.Remove("UserId");
|
|
@@ -1185,7 +1181,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
if (PayMode == 0) dic["PayMode"] = "";
|
|
|
//仓库
|
|
|
int StoreId = int.Parse(function.CheckInt(dic["StoreId"].ToString()));
|
|
|
- StoreHouse storeid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new StoreHouse();
|
|
|
+ StoreHouse storeid_StoreHouse = kxsdb.StoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new StoreHouse();
|
|
|
dic["StoreIdStoreNo"] = storeid_StoreHouse.StoreNo;
|
|
|
dic["StoreIdStoreName"] = storeid_StoreHouse.StoreName;
|
|
|
dic.Remove("StoreId");
|
|
@@ -1211,13 +1207,13 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
if (StoreType == 1) dic["StoreType"] = "分仓";
|
|
|
//仓库归属创客
|
|
|
int StoreUserId = int.Parse(function.CheckInt(dic["StoreUserId"].ToString()));
|
|
|
- Users storeuserid_Users = db.Users.FirstOrDefault(m => m.Id == StoreUserId) ?? new Users();
|
|
|
+ Users storeuserid_Users = kxsdb.Users.FirstOrDefault(m => m.Id == StoreUserId) ?? new Users();
|
|
|
dic["StoreUserIdMakerCode"] = storeuserid_Users.MakerCode;
|
|
|
dic["StoreUserIdRealName"] = storeuserid_Users.RealName;
|
|
|
dic.Remove("StoreUserId");
|
|
|
//顶级创客
|
|
|
int TopUserId = int.Parse(function.CheckInt(dic["TopUserId"].ToString()));
|
|
|
- Users topuserid_Users = db.Users.FirstOrDefault(m => m.Id == TopUserId) ?? new Users();
|
|
|
+ Users topuserid_Users = kxsdb.Users.FirstOrDefault(m => m.Id == TopUserId) ?? new Users();
|
|
|
dic["TopUserIdMakerCode"] = topuserid_Users.MakerCode;
|
|
|
dic["TopUserIdRealName"] = topuserid_Users.RealName;
|
|
|
dic.Remove("TopUserId");
|
|
@@ -1230,7 +1226,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
if (PayStatus == 4) dic["PayStatus"] = "支付处理中";
|
|
|
|
|
|
int OrderId = int.Parse(dic["Id"].ToString());
|
|
|
- List<OrderProduct> products = db.OrderProduct.Where(m => m.OrderId == OrderId).ToList();
|
|
|
+ List<OrderProduct> products = kxsdb.OrderProduct.Where(m => m.OrderId == OrderId).ToList();
|
|
|
foreach (OrderProduct product in products)
|
|
|
{
|
|
|
dic["ProductCode"] = product.ProductCode; //商品编号
|
|
@@ -1289,141 +1285,5 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
- #region 查询直推奖励100
|
|
|
-
|
|
|
- public Dictionary<string, string> Prize100(int Id)
|
|
|
- {
|
|
|
- Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
|
- string result = "";
|
|
|
- Orders order = db.Orders.FirstOrDefault(m => m.Id == Id) ?? new Orders();
|
|
|
- if (order.PayStatus < 1)
|
|
|
- {
|
|
|
- result += "未付款\n";
|
|
|
- dic.Add("code", "1");
|
|
|
- dic.Add("result", result);
|
|
|
- return dic;
|
|
|
- }
|
|
|
- Users user = db.Users.FirstOrDefault(m => m.Id == order.UserId) ?? new Users();
|
|
|
- Users puser = db.Users.FirstOrDefault(m => m.Id == user.ParentUserId) ?? new Users();
|
|
|
- result += "订单号:" + order.OrderNo + "\n";
|
|
|
- result += "下单创客\n创客编号:" + user.MakerCode + ",姓名:" + user.RealName + ",手机号:" + user.Mobile + "\n";
|
|
|
- result += "上级创客\n创客编号:" + puser.MakerCode + ",姓名:" + puser.RealName + ",手机号:" + puser.Mobile + "\n";
|
|
|
- int machineCount = db.PosMachinesTwo.Count(m => m.UserId == puser.Id && m.PosSnType == 0); //判断是否拥有3台兑换机
|
|
|
- int ActiveCount = db.PosMachinesTwo.Count(m => m.UserId == puser.Id && m.ActivationState == 1); //判断是否拥有3台激活机(不限购买或赠送)
|
|
|
- if (machineCount + ActiveCount >= 3)
|
|
|
- {
|
|
|
- string IsGet = "未发放";
|
|
|
- int ToUserId = 0;
|
|
|
- UserAccountRecord item = db.UserAccountRecord.FirstOrDefault(m => m.QueryCount == Id);
|
|
|
- if (item == null)
|
|
|
- {
|
|
|
- DateTime start = order.PayDate.Value.AddMinutes(-2);
|
|
|
- DateTime end = order.PayDate.Value.AddMinutes(2);
|
|
|
- item = db.UserAccountRecord.FirstOrDefault(m => m.UserId == puser.Id && m.ChangeType == 112 && m.ChangeAmount == 100 && m.CreateDate >= start && m.CreateDate <= end);
|
|
|
- }
|
|
|
- if (item != null)
|
|
|
- {
|
|
|
- IsGet = "已发放(发放时间:" + item.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss") + ")";
|
|
|
- ToUserId = item.UserId;
|
|
|
- dic.Add("code", "1");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- dic.Add("code", "0");
|
|
|
- }
|
|
|
- Users touser = db.Users.FirstOrDefault(m => m.Id == ToUserId) ?? new Users();
|
|
|
- result += "是否发放:" + IsGet + "\n";
|
|
|
- result += "应该发放对象\n创客编号:" + puser.MakerCode + ",姓名:" + puser.RealName + ",手机号:" + puser.Mobile + "\n";
|
|
|
- result += "实际发放对象\n创客编号:" + touser.MakerCode + ",姓名:" + touser.RealName + ",手机号:" + touser.Mobile + "\n";
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- result += "上级创客未满足条件\n兑换机:" + machineCount + "台,激活机:" + ActiveCount + "台\n";
|
|
|
- dic.Add("code", "1");
|
|
|
- }
|
|
|
- dic.Add("result", result);
|
|
|
- return dic;
|
|
|
- }
|
|
|
- public string AddPrize100(int Id)
|
|
|
- {
|
|
|
- Orders order = db.Orders.FirstOrDefault(m => m.Id == Id);
|
|
|
- if (order != null)
|
|
|
- {
|
|
|
- //机具券逻辑
|
|
|
- OrderProduct pro = db.OrderProduct.FirstOrDefault(m => m.OrderId == Id);
|
|
|
- if (pro != null)
|
|
|
- {
|
|
|
- //推荐下单奖励
|
|
|
- if (pro.ProductId == 10 || pro.ProductId == 11)
|
|
|
- {
|
|
|
- Users user = db.Users.FirstOrDefault(m => m.Id == order.UserId);
|
|
|
- if (user != null)
|
|
|
- {
|
|
|
- int ParentUserId = user.ParentUserId;
|
|
|
- int machineCount = db.PosMachinesTwo.Count(m => m.UserId == ParentUserId && m.PosSnType == 0); //判断是否拥有3台兑换机
|
|
|
- int ActiveCount = db.PosMachinesTwo.Count(m => m.UserId == ParentUserId && m.ActivationState == 1); //判断是否拥有3台激活机(不限购买或赠送)
|
|
|
- if (machineCount + ActiveCount >= 3)
|
|
|
- {
|
|
|
- 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, //变更后余额
|
|
|
- QueryCount = order.Id,
|
|
|
- }).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).ToList();
|
|
|
- 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();
|
|
|
- return "success";
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- return "上级创客未满足条件:兑换机:" + machineCount + "台,激活机:" + ActiveCount + "台";
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return "操作失败";
|
|
|
- }
|
|
|
-
|
|
|
- #endregion
|
|
|
}
|
|
|
}
|