|
@@ -51,7 +51,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
/// 待扣款明细列表
|
|
/// 待扣款明细列表
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
|
- public JsonResult IndexData(ToChargeBackRecord data, string UserIdMakerCode, string UserIdRealName, string ChargeTypeSelect, int page = 1, int limit = 30)
|
|
|
|
|
|
|
+ public JsonResult IndexData(ToChargeBackRecord data, string UserIdMakerCode, string ChargeTypeSelect, string StatusSelect, int page = 1, int limit = 30)
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
Dictionary<string, string> Fields = new Dictionary<string, string>();
|
|
Dictionary<string, string> Fields = new Dictionary<string, string>();
|
|
@@ -60,21 +60,21 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
|
|
|
|
|
|
|
|
|
|
string condition = " and Status>-1";
|
|
string condition = " and Status>-1";
|
|
|
- //创客创客编号
|
|
|
|
|
|
|
+ //创客编号
|
|
|
if (!string.IsNullOrEmpty(UserIdMakerCode))
|
|
if (!string.IsNullOrEmpty(UserIdMakerCode))
|
|
|
{
|
|
{
|
|
|
- condition += " and UserId in (select UserId from UsersForMakerCode where MakerCode='" + UserIdMakerCode + "')";
|
|
|
|
|
- }
|
|
|
|
|
- //创客真实姓名
|
|
|
|
|
- if (!string.IsNullOrEmpty(UserIdRealName))
|
|
|
|
|
- {
|
|
|
|
|
- condition += " and UserId in (select UserId from UsersForRealName where RealName='" + UserIdRealName + "')";
|
|
|
|
|
|
|
+ condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
|
|
|
}
|
|
}
|
|
|
//待扣类型
|
|
//待扣类型
|
|
|
if (!string.IsNullOrEmpty(ChargeTypeSelect))
|
|
if (!string.IsNullOrEmpty(ChargeTypeSelect))
|
|
|
{
|
|
{
|
|
|
condition += " and ChargeType=" + ChargeTypeSelect;
|
|
condition += " and ChargeType=" + ChargeTypeSelect;
|
|
|
}
|
|
}
|
|
|
|
|
+ //扣款状态
|
|
|
|
|
+ if (!string.IsNullOrEmpty(StatusSelect))
|
|
|
|
|
+ {
|
|
|
|
|
+ condition += " and Status=" + StatusSelect;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("ToChargeBackRecord", Fields, "Id desc", "0", page, limit, condition);
|
|
Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("ToChargeBackRecord", Fields, "Id desc", "0", page, limit, condition);
|
|
@@ -89,9 +89,15 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
dic.Remove("UserId");
|
|
dic.Remove("UserId");
|
|
|
//待扣类型
|
|
//待扣类型
|
|
|
int ChargeType = int.Parse(dic["ChargeType"].ToString());
|
|
int ChargeType = int.Parse(dic["ChargeType"].ToString());
|
|
|
- if (ChargeType == 1) dic["ChargeType"] = "过期机具扣款";
|
|
|
|
|
- if (ChargeType == 2) dic["ChargeType"] = "人工预扣";
|
|
|
|
|
- if (ChargeType == 0) dic["ChargeType"] = "";
|
|
|
|
|
|
|
+ if (ChargeType == 124) dic["ChargeType"] = "过期机具扣款";
|
|
|
|
|
+ // if (ChargeType == 2) dic["ChargeType"] = "人工预扣";
|
|
|
|
|
+ // if (ChargeType == 0) dic["ChargeType"] = "";
|
|
|
|
|
+
|
|
|
|
|
+ //扣款状态
|
|
|
|
|
+ int Status = int.Parse(dic["Status"].ToString());
|
|
|
|
|
+ if (Status == 0) dic["Status"] = "待扣款";
|
|
|
|
|
+ if (Status == 1) dic["Status"] = "已扣款";
|
|
|
|
|
+ if (Status == 2) dic["Status"] = "已退还";
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
return Json(obj);
|
|
return Json(obj);
|
|
@@ -286,18 +292,43 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
{
|
|
{
|
|
|
ExcelData = HttpUtility.UrlDecode(ExcelData);
|
|
ExcelData = HttpUtility.UrlDecode(ExcelData);
|
|
|
JsonData list = JsonMapper.ToObject(ExcelData);
|
|
JsonData list = JsonMapper.ToObject(ExcelData);
|
|
|
|
|
+ var info = "";
|
|
|
|
|
+ var error = "";
|
|
|
|
|
+ if (!string.IsNullOrEmpty(error))
|
|
|
|
|
+ {
|
|
|
|
|
+ return "Warning|" + error;
|
|
|
|
|
+ }
|
|
|
for (int i = 1; i < list.Count; i++)
|
|
for (int i = 1; i < list.Count; i++)
|
|
|
{
|
|
{
|
|
|
JsonData dr = list[i];
|
|
JsonData dr = list[i];
|
|
|
-
|
|
|
|
|
- db.ToChargeBackRecord.Add(new ToChargeBackRecord()
|
|
|
|
|
|
|
+ string PosSn = dr[0].ToString(); // 机具Sn
|
|
|
|
|
+ var toChargeBackRecord = db.ToChargeBackRecord.FirstOrDefault(m => m.Status == 1 && m.Remark == PosSn) ?? new ToChargeBackRecord();
|
|
|
|
|
+ if (toChargeBackRecord.Id == 0)
|
|
|
{
|
|
{
|
|
|
- CreateDate = DateTime.Now,
|
|
|
|
|
- UpdateDate = DateTime.Now,
|
|
|
|
|
-
|
|
|
|
|
- });
|
|
|
|
|
- db.SaveChanges();
|
|
|
|
|
|
|
+ error += "以下操作失败" + PosSn + ',' + "不符合退还条件" + '\n';
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == toChargeBackRecord.UserId) ?? new UserAccount();
|
|
|
|
|
+ var userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord
|
|
|
|
|
+ {
|
|
|
|
|
+ CreateDate = DateTime.Now,
|
|
|
|
|
+ UserId = toChargeBackRecord.UserId,
|
|
|
|
|
+ BeforeBalanceAmount = userAccount.BalanceAmount,
|
|
|
|
|
+ AfterBalanceAmount = userAccount.BalanceAmount + toChargeBackRecord.ChargeAmount,
|
|
|
|
|
+ ChangeAmount = toChargeBackRecord.ChargeAmount,
|
|
|
|
|
+ ChangeType = 126,
|
|
|
|
|
+ Remark = "机具货款退还",
|
|
|
|
|
+
|
|
|
|
|
+ }).Entity;
|
|
|
|
|
+ userAccount.BalanceAmount += toChargeBackRecord.ChargeAmount;
|
|
|
|
|
+ toChargeBackRecord.Status = 2;
|
|
|
|
|
+ info += toChargeBackRecord.Remark + "," + toChargeBackRecord.ChargeAmount + "<br/>";
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+ string text = string.Format("退款信息: '" + info + "',Time'" + DateTime.Now + "'");
|
|
|
|
|
+ function.WriteLog(text, "人工退还过期机具扣款");//人工退还过期机具扣款
|
|
|
|
|
+ db.SaveChanges();
|
|
|
AddSysLog("0", "ToChargeBackRecord", "Import");
|
|
AddSysLog("0", "ToChargeBackRecord", "Import");
|
|
|
return "success";
|
|
return "success";
|
|
|
}
|
|
}
|
|
@@ -309,59 +340,93 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
/// 导出Excel
|
|
/// 导出Excel
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
|
- public JsonResult ExportExcel(ToChargeBackRecord data, string UserIdMakerCode, string UserIdRealName, string ChargeTypeSelect)
|
|
|
|
|
|
|
+ public JsonResult ExportExcel(ToChargeBackRecord data, string CreateDateData, string UserIdMakerCode, string ChargeTypeSelect, string StatusSelect)
|
|
|
{
|
|
{
|
|
|
Dictionary<string, string> Fields = new Dictionary<string, string>();
|
|
Dictionary<string, string> Fields = new Dictionary<string, string>();
|
|
|
- Fields.Add("CreateDate", "3"); //时间
|
|
|
|
|
-
|
|
|
|
|
|
|
+ // Fields.Add("CreateDate", "3"); //时间
|
|
|
|
|
|
|
|
string condition = " and Status>-1";
|
|
string condition = " and Status>-1";
|
|
|
- //创客创客编号
|
|
|
|
|
- if (!string.IsNullOrEmpty(UserIdMakerCode))
|
|
|
|
|
|
|
+ if (!string.IsNullOrEmpty(CreateDateData))
|
|
|
{
|
|
{
|
|
|
- condition += " and UserId in (select UserId from UsersForMakerCode where MakerCode='" + UserIdMakerCode + "')";
|
|
|
|
|
|
|
+ string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
|
|
|
|
|
+ string start = datelist[0];
|
|
|
|
|
+ string end = datelist[1];
|
|
|
|
|
+ condition += " and CreateDate>='" + start + " 00:00:00' and CreateDate<='" + end + " 23:59:59'";
|
|
|
}
|
|
}
|
|
|
- //创客真实姓名
|
|
|
|
|
- if (!string.IsNullOrEmpty(UserIdRealName))
|
|
|
|
|
|
|
+ //创客编号
|
|
|
|
|
+ if (!string.IsNullOrEmpty(UserIdMakerCode))
|
|
|
{
|
|
{
|
|
|
- condition += " and UserId in (select UserId from UsersForRealName where RealName='" + UserIdRealName + "')";
|
|
|
|
|
|
|
+ condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
|
|
|
}
|
|
}
|
|
|
//待扣类型
|
|
//待扣类型
|
|
|
if (!string.IsNullOrEmpty(ChargeTypeSelect))
|
|
if (!string.IsNullOrEmpty(ChargeTypeSelect))
|
|
|
{
|
|
{
|
|
|
condition += " and ChargeType=" + ChargeTypeSelect;
|
|
condition += " and ChargeType=" + ChargeTypeSelect;
|
|
|
}
|
|
}
|
|
|
|
|
+ //扣款状态
|
|
|
|
|
+ if (!string.IsNullOrEmpty(StatusSelect))
|
|
|
|
|
+ {
|
|
|
|
|
+ condition += " and Status=" + StatusSelect;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
- Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("ToChargeBackRecord", Fields, "Id desc", "0", 1, 20000, condition, "UserId,ChargeAmount,ChargeType,Remark,Field1", false);
|
|
|
|
|
|
|
+ Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("ToChargeBackRecord", Fields, "Id desc", "0", 1, 20000, condition, "Id,UserId,ChargeAmount,ChargeType,Remark", false);
|
|
|
List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
|
|
List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
|
|
|
foreach (Dictionary<string, object> dic in diclist)
|
|
foreach (Dictionary<string, object> dic in diclist)
|
|
|
{
|
|
{
|
|
|
|
|
+ // 机具sn 机具品牌 机具类型 循环过期时间 创客编号 创客姓名 创客手机号 应扣金额 实扣金额 是否已返还
|
|
|
//创客
|
|
//创客
|
|
|
int UserId = int.Parse(function.CheckInt(dic["UserId"].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 = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
|
|
|
dic["UserIdMakerCode"] = userid_Users.MakerCode;
|
|
dic["UserIdMakerCode"] = userid_Users.MakerCode;
|
|
|
dic["UserIdRealName"] = userid_Users.RealName;
|
|
dic["UserIdRealName"] = userid_Users.RealName;
|
|
|
|
|
+ dic["UserIdMobile"] = userid_Users.Mobile;
|
|
|
dic.Remove("UserId");
|
|
dic.Remove("UserId");
|
|
|
//待扣类型
|
|
//待扣类型
|
|
|
int ChargeType = int.Parse(dic["ChargeType"].ToString());
|
|
int ChargeType = int.Parse(dic["ChargeType"].ToString());
|
|
|
- if (ChargeType == 1) dic["ChargeType"] = "过期机具扣款";
|
|
|
|
|
- if (ChargeType == 2) dic["ChargeType"] = "人工预扣";
|
|
|
|
|
- if (ChargeType == 0) dic["ChargeType"] = "";
|
|
|
|
|
|
|
+ if (ChargeType == 124) dic["ChargeType"] = "过期机具扣款";
|
|
|
|
|
+ // if (ChargeType == 2) dic["ChargeType"] = "人工预扣";
|
|
|
|
|
+ // if (ChargeType == 0) dic["ChargeType"] = "";
|
|
|
|
|
+
|
|
|
|
|
+ int Id = int.Parse(function.CheckInt(dic["Id"].ToString()));
|
|
|
|
|
+ var toChargeBackRecord = db.ToChargeBackRecord.FirstOrDefault(m => m.Id == Id) ?? new ToChargeBackRecord();
|
|
|
|
|
+ //扣款状态
|
|
|
|
|
+ if (toChargeBackRecord.Status == 0) dic["Status"] = "待扣款未返还";
|
|
|
|
|
+ if (toChargeBackRecord.Status == 1) dic["Status"] = "已扣款未返还";
|
|
|
|
|
+ if (toChargeBackRecord.Status == 2) dic["Status"] = "已返还";
|
|
|
|
|
+ decimal ChargeAmount = decimal.Parse(dic["ChargeAmount"].ToString());//应扣金额
|
|
|
|
|
+ decimal ChargeAmountf = 0;//实扣金额
|
|
|
|
|
+ dic["ChargeAmountf"] = "";
|
|
|
|
|
+ if (toChargeBackRecord.Status == 1)//已扣款
|
|
|
|
|
+ {
|
|
|
|
|
+ ChargeAmountf = ChargeAmount;
|
|
|
|
|
+ dic["ChargeAmountf"] = ChargeAmountf;
|
|
|
|
|
+ }
|
|
|
|
|
+ var pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == toChargeBackRecord.Remark) ?? new PosMachinesTwo();
|
|
|
|
|
+ dic["BrandId"] = RelationClass.GetKqProductBrandInfo(pos.BrandId);
|
|
|
|
|
+ if (pos.PosSnType == 0) dic["PosSnType"] = "购买机";
|
|
|
|
|
+ if (pos.PosSnType == 1) dic["PosSnType"] = "循环机";
|
|
|
|
|
+ dic["RecycEndDate"] = pos.RecycEndDate;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Dictionary<string, object> result = new Dictionary<string, object>();
|
|
Dictionary<string, object> result = new Dictionary<string, object>();
|
|
|
- result.Add("Status", "1");
|
|
|
|
|
|
|
+ // result.Add("Status", "1");
|
|
|
result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
|
|
result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
|
|
|
result.Add("Obj", diclist);
|
|
result.Add("Obj", diclist);
|
|
|
Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
|
|
Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
|
|
|
- ReturnFields.Add("UserIdMakerCode", "创客创客编号");
|
|
|
|
|
- ReturnFields.Add("UserIdRealName", "创客真实姓名");
|
|
|
|
|
- ReturnFields.Add("ChargeAmount", "待扣金额");
|
|
|
|
|
- ReturnFields.Add("ChargeType", "待扣类型");
|
|
|
|
|
- ReturnFields.Add("Remark", "备注");
|
|
|
|
|
- ReturnFields.Add("Field1", "备用字段");
|
|
|
|
|
|
|
+ ReturnFields.Add("Id", "Id");
|
|
|
|
|
+ ReturnFields.Add("ChargeType", "类型");
|
|
|
|
|
+ ReturnFields.Add("Remark", "机具sn");
|
|
|
|
|
+ ReturnFields.Add("BrandId", "品牌");
|
|
|
|
|
+ ReturnFields.Add("PosSnType", "机具类型");
|
|
|
|
|
+ ReturnFields.Add("RecycEndDate", "循环过期时间");
|
|
|
|
|
+ ReturnFields.Add("UserIdMakerCode", "创客编号");
|
|
|
|
|
+ ReturnFields.Add("UserIdRealName", "创客姓名");
|
|
|
|
|
+ ReturnFields.Add("UserIdMobile", "创客手机号");
|
|
|
|
|
+ ReturnFields.Add("ChargeAmount", "应扣金额");
|
|
|
|
|
+ ReturnFields.Add("ChargeAmountf", "实扣金额");
|
|
|
|
|
+ ReturnFields.Add("Status", "扣款状态");
|
|
|
|
|
|
|
|
result.Add("Fields", ReturnFields);
|
|
result.Add("Fields", ReturnFields);
|
|
|
AddSysLog("0", "ToChargeBackRecord", "ExportExcel");
|
|
AddSysLog("0", "ToChargeBackRecord", "ExportExcel");
|