DuGuYang 3 лет назад
Родитель
Сommit
3bdc3befa0

+ 69 - 6
Areas/Admin/Controllers/MainServer/ToChargeBackRecordController.cs

@@ -290,7 +290,7 @@ namespace MySystem.Areas.Admin.Controllers
         }
         #endregion
 
-        #region 导入数据
+        #region 机具扣款退还
         /// <summary>
         /// 导入数据
         /// </summary>
@@ -301,10 +301,6 @@ namespace MySystem.Areas.Admin.Controllers
             JsonData list = JsonMapper.ToObject(ExcelData);
             var info = "";
             var error = "";
-            if (!string.IsNullOrEmpty(error))
-            {
-                return "Warning|" + error;
-            }
             for (int i = 1; i < list.Count; i++)
             {
                 JsonData dr = list[i];
@@ -333,14 +329,81 @@ namespace MySystem.Areas.Admin.Controllers
                     info += toChargeBackRecord.Remark + "," + toChargeBackRecord.ChargeAmount + "<br/>";
                 }
             }
+            if (!string.IsNullOrEmpty(error))
+            {
+                return "Warning|" + error;
+            }
+            string text = string.Format("退款信息: '" + info + "',Time'" + DateTime.Now + "'");
+            function.WriteLog(text, "机具扣款退还");//机具扣款退还
+            db.SaveChanges();
+            AddSysLog("0", "ToChargeBackRecord", "Import");
+            return "success";
+        }
+        #endregion
+
+
+        #region 机具回收确认退还
+        /// <summary>
+        /// 导入数据
+        /// </summary>
+        /// <param name="ExcelData"></param>
+        public string Imports(string ExcelData)
+        {
+            ExcelData = HttpUtility.UrlDecode(ExcelData);
+            JsonData list = JsonMapper.ToObject(ExcelData);
+            var info = "";
+            var error = "";
+            for (int i = 1; i < list.Count; i++)
+            {
+                JsonData dr = list[i];
+                string PosSn = dr[0].ToString(); // 机具Sn
+                var toChargeBackRecord = db.ToChargeBackRecord.FirstOrDefault(m => m.Remark == PosSn) ?? new ToChargeBackRecord();
+                var recycMachineOrderPos = db.RecycMachineOrderPos.FirstOrDefault(m => m.Status == 1 && m.SnNo == PosSn) ?? new RecycMachineOrderPos();
+                if (recycMachineOrderPos.Id == 0)
+                {
+                    error += "以下操作失败" + PosSn + ',' + "不符合退还条件" + '\n';
+                }
+                else
+                {
+                    var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == toChargeBackRecord.UserId) ?? new UserAccount();
+                    //已扣款
+                    if (toChargeBackRecord.Status == 1)
+                    {
+                        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/>";
+                    }
+                    //未扣款
+                    if (toChargeBackRecord.Status == 0)
+                    {
+                        toChargeBackRecord.Status = 2;
+                    }
+                }
+            }
+            if (!string.IsNullOrEmpty(error))
+            {
+                return "Warning|" + error;
+            }
             string text = string.Format("退款信息: '" + info + "',Time'" + DateTime.Now + "'");
-            function.WriteLog(text, "人工退还过期机具扣款");//人工退还过期机具扣款
+            function.WriteLog(text, "机具回收确认退还");//机具回收确认退还
             db.SaveChanges();
             AddSysLog("0", "ToChargeBackRecord", "Import");
             return "success";
         }
         #endregion
 
+
         #region 导出Excel
 
         /// <summary>

+ 5 - 0
Areas/Admin/Views/MainServer/ToChargeBackRecord/Index.cshtml

@@ -112,6 +112,11 @@
                         <button class="layui-btn" data-type="ImportData"><i
                             class="layui-icon layui-icon-upload layuiadmin-button-btn"></i>机具扣款退还</button>
                     }
+                    @if (RightInfo.Contains("," + right + "_import,"))
+                    {
+                        <button class="layui-btn" data-type="ImportDatas"><i
+                            class="layui-icon layui-icon-upload layuiadmin-button-btn"></i>机具回收确认退还</button>
+                    }
                 </div>
 
                 <table id="LAY-list-manage" lay-filter="LAY-list-manage"></table>

BIN
wwwroot/.DS_Store


+ 38 - 0
wwwroot/layuiadmin/modules_main/ToChargeBackRecord_Admin.js

@@ -1,4 +1,5 @@
 var ExcelData, ExcelKind;
+//机具扣款退还
 function ConfirmImport() {
     $.ajax({
         type: "POST",
@@ -22,6 +23,30 @@ function ConfirmImport() {
     });
 }
 
+//机具回收确认退还
+function ConfirmImport() {
+    $.ajax({
+        type: "POST",
+        url: "/Admin/ToChargeBackRecord/Imports?r=" + Math.random(1),
+        data: "ExcelData=" + encodeURIComponent(JSON.stringify(ExcelData)),
+        dataType: "text",
+        success: function (data) {
+            if (data == "success") {
+                layer.msg("导入成功", { time: 2000 }, function () {
+                    window.location.reload();
+                });
+            } else if (data.indexOf("warning") == 0) {
+                var datalist = data.split('|');
+                layer.alert(datalist[0], { time: 20000 }, function () {
+                    window.location.reload();
+                });
+            } else {
+                layer.msg(data);
+            }
+        }
+    });
+}
+
 var excel;
 layui.config({
     base: '/layuiadmin/' //静态资源所在路径
@@ -330,6 +355,19 @@ layui.config({
             });
             $("#excelTemp").html('<a href="/users/机具扣款退还模版.xlsx">点击下载机具扣款退还模版文件</a>');
         }
+        , ImportDatas: function () {
+            ExcelKind = 1;
+            layer.open({
+                type: 1,
+                title: '导入',
+                maxmin: false,
+                area: ['460px', '280px'],
+                content: $('#excelForm'),
+                cancel: function () {
+                }
+            });
+            $("#excelTemp").html('<a href="/users/机具扣款退还模版.xlsx">点击下载机具扣款退还模版文件</a>');
+        }
         , ExportExcel: function () {
             var userdata = '';
             $(".layuiadmin-card-header-auto input").each(function (i) {