|
|
@@ -52,7 +52,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
/// 待扣款明细列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
- public JsonResult IndexData(ToChargeBackRecord data, string UserIdMakerCode, string PosSn, string CreateDateData, string ChargeTypeSelect, string StatusSelect, int page = 1, int limit = 30)
|
|
|
+ public JsonResult IndexData(ToChargeBackRecord data, string UserIdMakerCode, string PosSn, string CreateDateData, string ChargeTypeSelect, string KindSelect, string StatusSelect, int page = 1, int limit = 30)
|
|
|
{
|
|
|
|
|
|
Dictionary<string, string> Fields = new Dictionary<string, string>();
|
|
|
@@ -81,6 +81,11 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
{
|
|
|
condition += " and ChargeType=" + ChargeTypeSelect;
|
|
|
}
|
|
|
+ //待扣类别
|
|
|
+ if (!string.IsNullOrEmpty(KindSelect))
|
|
|
+ {
|
|
|
+ condition += " and Kind=" + KindSelect;
|
|
|
+ }
|
|
|
//扣款状态
|
|
|
if (!string.IsNullOrEmpty(StatusSelect))
|
|
|
{
|
|
|
@@ -103,10 +108,16 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
//待扣类型
|
|
|
int ChargeType = int.Parse(dic["ChargeType"].ToString());
|
|
|
if (ChargeType == 124) dic["ChargeTypeName"] = "过期机具扣款";
|
|
|
- if (ChargeType == 1) dic["ChargeTypeName"] = "创客预扣款";
|
|
|
+ if (ChargeType == 1) dic["ChargeTypeName"] = "普通预扣款";
|
|
|
if (ChargeType == 2) dic["ChargeTypeName"] = "分期预扣款";
|
|
|
if (ChargeType == 0) dic["ChargeTypeName"] = "";
|
|
|
|
|
|
+ //待扣类别
|
|
|
+ int Kind = int.Parse(dic["Kind"].ToString());
|
|
|
+ if (Kind == 0) dic["KindName"] = "创客预扣款";
|
|
|
+ if (Kind == 1) dic["KindName"] = "盟主预扣款";
|
|
|
+ if (Kind == 2) dic["KindName"] = "运营中心预扣款";
|
|
|
+
|
|
|
//扣款状态
|
|
|
int Status = int.Parse(dic["Status"].ToString());
|
|
|
if (Status == 0) dic["StatusName"] = "待扣款";
|
|
|
@@ -169,6 +180,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
Fields.Add("UserId", user.Id); //创客Id
|
|
|
Fields.Add("ChargeAmount", data.ChargeAmount); //待扣金额
|
|
|
Fields.Add("ChargeType", 1); //待扣类型
|
|
|
+ Fields.Add("Kind", data.Kind); //待扣别
|
|
|
Fields.Add("Remark", data.Remark); //备注
|
|
|
Fields.Add("Field1", data.Field1); //备用字段
|
|
|
|
|
|
@@ -192,7 +204,9 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
}).Entity;
|
|
|
db.SaveChanges();
|
|
|
}
|
|
|
- userAccount.ToChargeAmount += decimal.Parse(data.ChargeAmount.ToString());
|
|
|
+ if (data.Kind == 0) userAccount.ToChargeAmount += decimal.Parse(data.ChargeAmount.ToString());
|
|
|
+ if (data.Kind == 1) userAccount.LeaderToChargeAmount += decimal.Parse(data.ChargeAmount.ToString());
|
|
|
+ if (data.Kind == 2) userAccount.OperateToChargeAmount += decimal.Parse(data.ChargeAmount.ToString());
|
|
|
}
|
|
|
AddSysLog(data.Id.ToString(), "ToChargeBackRecord", "add");
|
|
|
db.SaveChanges();
|
|
|
@@ -236,17 +250,25 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
var info = db.ToChargeBackRecord.FirstOrDefault(m => m.Id == data.Id) ?? new ToChargeBackRecord();
|
|
|
if (info.ChargeAmount != data.ChargeAmount)
|
|
|
{
|
|
|
- var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == info.UserId) ?? new UserAccount();
|
|
|
- if (info.ChargeAmount > data.ChargeAmount)
|
|
|
- {
|
|
|
- userAccount.ToChargeAmount -= info.ChargeAmount - data.ChargeAmount;
|
|
|
- }
|
|
|
- if (info.ChargeAmount < data.ChargeAmount)
|
|
|
+ if (info.Kind != data.Kind)
|
|
|
{
|
|
|
- userAccount.ToChargeAmount += data.ChargeAmount - info.ChargeAmount;
|
|
|
+ var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == info.UserId) ?? new UserAccount();
|
|
|
+ if (info.ChargeAmount > data.ChargeAmount)
|
|
|
+ {
|
|
|
+ if (data.Kind == 0) userAccount.ToChargeAmount -= info.ChargeAmount - data.ChargeAmount;
|
|
|
+ if (data.Kind == 1) userAccount.LeaderToChargeAmount -= info.ChargeAmount - data.ChargeAmount;
|
|
|
+ if (data.Kind == 2) userAccount.OperateToChargeAmount -= info.ChargeAmount - data.ChargeAmount;
|
|
|
+ }
|
|
|
+ if (info.ChargeAmount < data.ChargeAmount)
|
|
|
+ {
|
|
|
+ if (data.Kind == 0) userAccount.ToChargeAmount += data.ChargeAmount - info.ChargeAmount;
|
|
|
+ if (data.Kind == 1) userAccount.LeaderToChargeAmount += data.ChargeAmount - info.ChargeAmount;
|
|
|
+ if (data.Kind == 2) userAccount.OperateToChargeAmount += data.ChargeAmount - info.ChargeAmount;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
Fields.Add("ChargeAmount", data.ChargeAmount); //待扣金额
|
|
|
+ Fields.Add("Kind", data.Kind); //待扣金额
|
|
|
Fields.Add("SeoDescription", data.SeoDescription);
|
|
|
if (info.ChargeType != 124)
|
|
|
{
|
|
|
@@ -276,7 +298,9 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
int id = int.Parse(subid);
|
|
|
var toChargeBackRecord = db.ToChargeBackRecord.FirstOrDefault(m => m.Id == id) ?? new ToChargeBackRecord();
|
|
|
var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == toChargeBackRecord.UserId) ?? new UserAccount();
|
|
|
- userAccount.ToChargeAmount -= toChargeBackRecord.ChargeAmount;//删除预扣款记录时扣减相应预扣额度
|
|
|
+ if (toChargeBackRecord.Kind == 0) userAccount.ToChargeAmount -= toChargeBackRecord.ChargeAmount;//删除预扣款记录时扣减相应预扣额度
|
|
|
+ if (toChargeBackRecord.Kind == 1) userAccount.LeaderToChargeAmount -= toChargeBackRecord.ChargeAmount;//删除预扣款记录时扣减相应预扣额度
|
|
|
+ if (toChargeBackRecord.Kind == 2) userAccount.OperateToChargeAmount -= toChargeBackRecord.ChargeAmount;//删除预扣款记录时扣减相应预扣额度
|
|
|
Dictionary<string, object> Fields = new Dictionary<string, object>();
|
|
|
Fields.Add("Status", -1);
|
|
|
new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("ToChargeBackRecord", Fields, id);
|
|
|
@@ -416,6 +440,8 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
string Name = itemJson.Contains("\"B\"") ? dr["B"].ToString() : "";
|
|
|
string Amount = itemJson.Contains("\"C\"") ? dr["C"].ToString() : "";
|
|
|
string Remark = itemJson.Contains("\"D\"") ? dr["D"].ToString() : "";
|
|
|
+ string KindName = itemJson.Contains("\"E\"") ? dr["E"].ToString() : "";
|
|
|
+ int Kind = 0;
|
|
|
var userForMakerCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode) ?? new UserForMakerCode();
|
|
|
var users = db.Users.FirstOrDefault(m => m.Id == userForMakerCode.UserId && m.RealName == Name) ?? new Users();
|
|
|
var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == users.Id);
|
|
|
@@ -434,7 +460,21 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
}).Entity;
|
|
|
db.SaveChanges();
|
|
|
}
|
|
|
- userAccount.ToChargeAmount += decimal.Parse(Amount);
|
|
|
+ if (KindName == "创客预扣款")
|
|
|
+ {
|
|
|
+ Kind = 0;
|
|
|
+ userAccount.ToChargeAmount += decimal.Parse(Amount);
|
|
|
+ }
|
|
|
+ if (KindName == "盟主预扣款")
|
|
|
+ {
|
|
|
+ Kind = 1;
|
|
|
+ userAccount.LeaderToChargeAmount += decimal.Parse(Amount);
|
|
|
+ }
|
|
|
+ if (KindName == "运营中心预扣款")
|
|
|
+ {
|
|
|
+ Kind = 2;
|
|
|
+ userAccount.OperateToChargeAmount += decimal.Parse(Amount);
|
|
|
+ }
|
|
|
var ToChargeBackRecord = db.ToChargeBackRecord.Add(new ToChargeBackRecord
|
|
|
{
|
|
|
CreateDate = DateTime.Now,
|
|
|
@@ -442,6 +482,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
SeoDescription = Remark,
|
|
|
Remark = Remark,
|
|
|
ChargeType = 1,
|
|
|
+ Kind = Kind,
|
|
|
ChargeAmount = decimal.Parse(Amount),
|
|
|
UserId = users.Id,
|
|
|
}).Entity;
|
|
|
@@ -589,7 +630,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
/// 导出Excel
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
- public JsonResult ExportExcel(ToChargeBackRecord data, string CreateDateData, string UserIdMakerCode, string ChargeTypeSelect, string StatusSelect)
|
|
|
+ public JsonResult ExportExcel(ToChargeBackRecord data, string CreateDateData, string UserIdMakerCode, string ChargeTypeSelect, string KindSelect, string StatusSelect)
|
|
|
{
|
|
|
Dictionary<string, string> Fields = new Dictionary<string, string>();
|
|
|
// Fields.Add("CreateDate", "3"); //时间
|
|
|
@@ -612,6 +653,11 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
{
|
|
|
condition += " and ChargeType=" + ChargeTypeSelect;
|
|
|
}
|
|
|
+ //待扣类别
|
|
|
+ if (!string.IsNullOrEmpty(KindSelect))
|
|
|
+ {
|
|
|
+ condition += " and Kind=" + KindSelect;
|
|
|
+ }
|
|
|
//扣款状态
|
|
|
if (!string.IsNullOrEmpty(StatusSelect))
|
|
|
{
|
|
|
@@ -619,7 +665,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
}
|
|
|
|
|
|
|
|
|
- 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);
|
|
|
+ Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("ToChargeBackRecord", Fields, "Id desc", "0", 1, 20000, condition, "Id,UserId,ChargeAmount,ChargeType,Kind,Remark", false);
|
|
|
List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
|
|
|
foreach (Dictionary<string, object> dic in diclist)
|
|
|
{
|
|
|
@@ -633,6 +679,15 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
//待扣类型
|
|
|
int ChargeType = int.Parse(dic["ChargeType"].ToString());
|
|
|
if (ChargeType == 124) dic["ChargeType"] = "过期机具扣款";
|
|
|
+ if (ChargeType == 1) dic["ChargeType"] = "普通预扣款";
|
|
|
+ if (ChargeType == 2) dic["ChargeType"] = "分期预扣款";
|
|
|
+ if (ChargeType == 0) dic["ChargeType"] = "";
|
|
|
+
|
|
|
+ //待扣类别
|
|
|
+ int Kind = int.Parse(dic["Kind"].ToString());
|
|
|
+ if (Kind == 0) dic["Kind"] = "创客预扣款";
|
|
|
+ if (Kind == 1) dic["Kind"] = "盟主预扣款";
|
|
|
+ if (Kind == 2) dic["Kind"] = "运营中心预扣款";
|
|
|
|
|
|
int Id = int.Parse(function.CheckInt(dic["Id"].ToString()));
|
|
|
var toChargeBackRecord = db.ToChargeBackRecord.FirstOrDefault(m => m.Id == Id) ?? new ToChargeBackRecord();
|
|
|
@@ -661,7 +716,8 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
result.Add("Obj", diclist);
|
|
|
Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
|
|
|
ReturnFields.Add("Id", "Id");
|
|
|
- ReturnFields.Add("ChargeType", "类型");
|
|
|
+ ReturnFields.Add("ChargeType", "待扣类型");
|
|
|
+ ReturnFields.Add("Kind", "待扣类别");
|
|
|
ReturnFields.Add("Remark", "机具sn");
|
|
|
ReturnFields.Add("BrandId", "品牌");
|
|
|
ReturnFields.Add("PosSnType", "机具类型");
|
|
|
@@ -692,7 +748,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
|
- public string QuickExportExcelDo(string UserIdMakerCode, string PosSn, string CreateDateData, string ChargeTypeSelect, string StatusSelect)
|
|
|
+ public string QuickExportExcelDo(string UserIdMakerCode, string PosSn, string CreateDateData, string ChargeTypeSelect, string KindSelect, string StatusSelect)
|
|
|
{
|
|
|
|
|
|
string SqlString = " where 1=1 and a.Status>-1";
|
|
|
@@ -712,6 +768,11 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
{
|
|
|
SqlString += " and a.Remark=" + PosSn;
|
|
|
}
|
|
|
+ //待扣类别
|
|
|
+ if (!string.IsNullOrEmpty(KindSelect))
|
|
|
+ {
|
|
|
+ SqlString += " and a.Kind=" + KindSelect;
|
|
|
+ }
|
|
|
//待扣类型
|
|
|
if (!string.IsNullOrEmpty(ChargeTypeSelect))
|
|
|
{
|
|
|
@@ -722,7 +783,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
{
|
|
|
SqlString += " and a.Status=" + StatusSelect;
|
|
|
}
|
|
|
- var Sql = "SELECT b.MakerCode '创客编号',b.RealName '创客真实姓名',b.Mobile '手机号',DATE_FORMAT(a.CreateDate,'%Y-%m-%d %H:%i:%s') '创建时间',a.ChargeAmount '扣款金额',(CASE WHEN a.ChargeType=124 THEN '过期机具扣款' WHEN a.ChargeType=1 THEN '创客预扣款' WHEN a.ChargeType=2 THEN '分期预扣款' ELSE '' end) '扣款类型',DATE_FORMAT(a.UpdateDate,'%Y-%m-%d %H:%i:%s') '扣款/更新时间',(CASE WHEN a.`Status`=0 THEN '待扣款' WHEN a.`Status`=1 THEN '已扣款' WHEN a.`Status`=2 THEN '已退还' WHEN a.`Status`=3 THEN '暂停扣款' ELSE '' end) '扣款状态',a.Remark '机具Sn',a.SeoDescription '备注',a.SeoTitle '操作人' FROM ToChargeBackRecord a LEFT JOIN Users b ON a.UserId=b.Id " + SqlString + "";
|
|
|
+ var Sql = "SELECT b.MakerCode '创客编号',b.RealName '创客真实姓名',b.Mobile '手机号',DATE_FORMAT(a.CreateDate,'%Y-%m-%d %H:%i:%s') '创建时间',a.ChargeAmount '扣款金额',(CASE WHEN a.ChargeType=124 THEN '过期机具扣款' WHEN a.ChargeType=1 THEN '普通预扣款' WHEN a.ChargeType=2 THEN '分期预扣款' ELSE '' end) '扣款类型',(CASE WHEN a.Kind=0 THEN '创客预扣款' WHEN a.Kind=1 THEN '盟主预扣款' WHEN a.Kind=2 THEN '运营中心预扣款' ELSE '' end) '扣款类别',DATE_FORMAT(a.UpdateDate,'%Y-%m-%d %H:%i:%s') '扣款/更新时间',(CASE WHEN a.`Status`=0 THEN '待扣款' WHEN a.`Status`=1 THEN '已扣款' WHEN a.`Status`=2 THEN '已退还' WHEN a.`Status`=3 THEN '暂停扣款' ELSE '' end) '扣款状态',a.Remark '机具Sn',a.SeoDescription '备注',a.SeoTitle '操作人' FROM ToChargeBackRecord a LEFT JOIN Users b ON a.UserId=b.Id " + SqlString + "";
|
|
|
var sysAdmin = bsdb.SysAdmin.FirstOrDefault(m => m.AdminName == SysUserName && m.Status > -1);
|
|
|
var FileName = "创客预扣款记录" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
string SendData = "{\"Operater\":\"" + sysAdmin.Id + "\",\"SqlString\":\"" + Sql + "\",\"FileName\":\"" + FileName + "\",\"MaxCount\":\"0\"}";
|