Просмотр исходного кода

调整导入功能,统计,查询条件

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

+ 153 - 26
Areas/Admin/Controllers/MainServer/PosMachinesFeeChangeRecordController.cs

@@ -59,14 +59,10 @@ namespace MySystem.Areas.Admin.Controllers
             Fields.Add("CreateDate", "3"); //时间
             Fields.Add("PosSn", "1"); //机具SN
             Fields.Add("MerNo", "1"); //商户号
-            Fields.Add("Sort", "0"); //
+            Fields.Add("Sort", "0"); //品牌
 
 
             string condition = " and Status>=-1";
-            if (!string.IsNullOrEmpty(StatusSelect))
-            {
-                condition += " and Status=" + StatusSelect;
-            }
             //创客创客编号
             if (!string.IsNullOrEmpty(UserIdMakerCode))
             {
@@ -87,6 +83,21 @@ namespace MySystem.Areas.Admin.Controllers
             {
                 condition += " and PosUserId in (select PosUserId from UsersForRealName where RealName='" + PosUserIdRealName + "')";
             }
+            //品牌
+            if (data.Sort == 0)
+            {
+                condition += " and Sort = 1";
+            }
+            if (data.Sort != 0)
+            {
+                condition += " and Sort = " + data.Sort;
+            }
+            if (data.Status > 0)
+            {
+                if(data.Status == 2) data.Status = 0;
+                if(data.Status == 3) data.Status = -1;
+                condition += " and Status = " + data.Status;
+            }
 
 
             Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PosMachinesFeeChangeRecord", Fields, "Id desc", "0", page, limit, condition);
@@ -297,6 +308,113 @@ namespace MySystem.Areas.Admin.Controllers
         }
         #endregion
 
+
+        #region 导入费率调整结果
+        /// <summary>
+        /// 导入费率调整结果
+        /// </summary>
+        /// <param name="ExcelData"></param>
+        public string ImportEnd(string ExcelData)
+        {
+            ExcelData = HttpUtility.UrlDecode(ExcelData);
+            JsonData list = JsonMapper.ToObject(ExcelData);
+
+            List<int> dnposIds = new List<int>();
+            string userIds = "";
+            string warning = "";
+
+            for (int i = 1; i < list.Count; i++)
+            {
+                JsonData dr = list[i];
+                string PosNo = dr[0].ToString(); // 机具Sn
+                var Amount = double.Parse(dr[1].ToString()); // 调整费率
+                int Kind = int.Parse(dr[2].ToString()); // 1 调升 2 调低
+                var pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == PosNo) ?? new PosMachinesTwo();
+                if (pos.UpFeeFlag == 1)
+                {
+                    if (Kind != 2 || Amount != 0.6)
+                    {
+                        warning += PosNo + ",该机具调低费率数值或类型不正确,请检查好后全部重新导入";
+                    }
+                    else
+                    {
+                        if (Kind == 2 && Amount == 0.6)
+                        {
+                            pos.DownFeeFlag = 1;
+                            pos.DownFeeDate = DateTime.Now;
+                            pos.DownFeeMan = SysUserName + "_" + SysRealName;
+                            var poschange = db.PosMachinesFeeChangeRecord.FirstOrDefault(m => m.PosId == pos.Id);
+                            poschange.Status = 1;
+                            db.SaveChanges();
+                            dnposIds.Add(pos.Id);
+
+                        }
+                        if (!userIds.Contains(pos.BuyUserId.ToString()))
+                        {
+                            userIds += pos.BuyUserId + ",";
+                        }
+                    }
+                }
+
+                else
+                {
+                    warning += PosNo + ",该机具不符合调低条件,请检查好后全部重新导入";
+                }
+            }
+            if (!string.IsNullOrEmpty(warning))
+            {
+                return "waning |" + warning;
+            }
+            string[] lists = userIds.TrimEnd(',').Split(new char[] { ',' });
+            int times = lists.ToList().Count;
+            if (dnposIds.Count > 0)
+            {
+                //调降
+                for (int i = 0; i < times; i++)
+                {
+                    var UserId = lists[i];
+                    var posInfo = db.PosMachinesTwo.Where(m => dnposIds.Contains(m.Id) && m.BuyUserId == Convert.ToInt32(UserId)).ToList();
+                    string snhtml = "<div style='margin-bottom: .48rem;'>";
+                    foreach (var items in posInfo)
+                    {
+                        var mer = db.PosMerchantInfo.FirstOrDefault(m => m.Id == items.BindMerchantId);
+                        string Name = mer.MerchantName;
+                        if (mer.BrandId == 2)
+                        {
+                            if (Name.Contains("-"))
+                            {
+                                Name = Name.Split('-')[1];
+                            }
+                            else if (Name.Contains("_"))
+                            {
+                                Name = Name.Split('_')[1];
+                            }
+                        }
+                        var brand = db.KqProducts.FirstOrDefault(m => m.Id == items.BrandId);
+                        snhtml += "<div style='margin-bottom: .48rem;'><div class='f16'>商户姓名:" + Name + "</div>";
+                        snhtml += "<div class='f16'>机具品牌:" + brand.Name + "</div>";
+                        snhtml += "<div class='f16'>SN:" + items.PosSn + "</div>";
+                        snhtml += "<div class='f16'>当前费率:0.6%</div>";
+                        snhtml += "<div class='f16'>费率调整时间:" + items.DownFeeDate + "</div></div>";
+                    }
+                    snhtml += "</div>";
+                    RedisDbconn.Instance.AddList("MsgPersonalQueue", Newtonsoft.Json.JsonConvert.SerializeObject(new MsgPersonal()
+                    {
+                        UserId = Convert.ToInt32(UserId), //创客
+                        Title = "商户费率变更通知", //标题
+                        Content = "<div class='f16' style='margin-bottom: .72rem'>您的商户刷卡交易费率已变更成功!</div>" + snhtml, //内容
+                        Summary = "您的商户刷卡交易费率已变更成功!",
+                        CreateDate = DateTime.Now,
+
+                    }));
+                }
+            }
+            AddSysLog("0", "PosMachinesTwoChange", "ImportEnd");
+            return "success";
+        }
+        #endregion
+
+
         #region 导入数据
         /// <summary>
         /// 导入数据
@@ -335,9 +453,10 @@ namespace MySystem.Areas.Admin.Controllers
             Fields.Add("CreateDate", "3"); //时间
             Fields.Add("PosSn", "1"); //机具SN
             Fields.Add("MerNo", "1"); //商户号
+            Fields.Add("Sort", "0"); //品牌
 
 
-            string condition = " and Status>-1";
+            string condition = " and Status>-1 and Sort = " + data.Sort + "";
             //创客创客编号
             if (!string.IsNullOrEmpty(UserIdMakerCode))
             {
@@ -358,24 +477,33 @@ namespace MySystem.Areas.Admin.Controllers
             {
                 condition += " and PosUserId in (select PosUserId from UsersForRealName where RealName='" + PosUserIdRealName + "')";
             }
+            if (data.Status > 0)
+            {
+                if(data.Status == 2) data.Status = 0;
+                if(data.Status == 3) data.Status = -1;
+                condition += " and Status = " + data.Status;
+            }
 
-
-            Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PosMachinesFeeChangeRecord", Fields, "Id desc", "0", 1, 20000, condition, "UserId,ChangeFee,PosSn,MerNo,PosUserId", false);
+            Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PosMachinesFeeChangeRecord", Fields, "Id desc", "0", 1, 20000, condition, "PosSn,ChangeFee", false);
             List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
             foreach (Dictionary<string, object> dic in diclist)
             {
-                //创客
-                int UserId = int.Parse(function.CheckInt(dic["UserId"].ToString()));
-                Users userid_Users = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
-                dic["UserIdMakerCode"] = userid_Users.MakerCode;
-                dic["UserIdRealName"] = userid_Users.RealName;
-                dic.Remove("UserId");
-                //机具所属人
-                int PosUserId = int.Parse(function.CheckInt(dic["PosUserId"].ToString()));
-                Users posuserid_Users = db.Users.FirstOrDefault(m => m.Id == PosUserId) ?? new Users();
-                dic["PosUserIdMakerCode"] = posuserid_Users.MakerCode;
-                dic["PosUserIdRealName"] = posuserid_Users.RealName;
-                dic.Remove("PosUserId");
+                // //创客
+                // int UserId = int.Parse(function.CheckInt(dic["UserId"].ToString()));
+                // Users userid_Users = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
+                // dic["UserIdMakerCode"] = userid_Users.MakerCode;
+                // dic["UserIdRealName"] = userid_Users.RealName;
+                // dic.Remove("UserId");
+                // //机具所属人
+                // int PosUserId = int.Parse(function.CheckInt(dic["PosUserId"].ToString()));
+                // Users posuserid_Users = db.Users.FirstOrDefault(m => m.Id == PosUserId) ?? new Users();
+                // dic["PosUserIdMakerCode"] = posuserid_Users.MakerCode;
+                // dic["PosUserIdRealName"] = posuserid_Users.RealName;
+                // dic.Remove("PosUserId");
+
+                var PosSn = dic["PosSn"].ToString();
+                var ChangeFee = function.CheckNum(dic["ChangeFee"].ToString());
+                dic.Add("Kind", "2");
 
             }
 
@@ -384,13 +512,12 @@ namespace MySystem.Areas.Admin.Controllers
             result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
             result.Add("Obj", diclist);
             Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
-            ReturnFields.Add("UserIdMakerCode", "创客创客编号");
-            ReturnFields.Add("UserIdRealName", "创客真实姓名");
-            ReturnFields.Add("ChangeFee", "调整费率");
+            // ReturnFields.Add("UserIdMakerCode", "创客创客编号");
+            // ReturnFields.Add("UserIdRealName", "创客真实姓名");
+            // ReturnFields.Add("ChangeFee", "调整费率");
             ReturnFields.Add("PosSn", "机具SN");
-            ReturnFields.Add("MerNo", "商户号");
-            ReturnFields.Add("PosUserIdMakerCode", "机具所属人创客编号");
-            ReturnFields.Add("PosUserIdRealName", "机具所属人真实姓名");
+            ReturnFields.Add("ChangeFee", "调整费率");
+            ReturnFields.Add("Kind", "调整类型(2-调降)");
 
             result.Add("Fields", ReturnFields);
             AddSysLog("0", "PosMachinesFeeChangeRecord", "ExportExcel");

+ 15 - 3
Areas/Admin/Controllers/MainServer/PosMachinesTwoChangeController.cs

@@ -91,7 +91,14 @@ namespace MySystem.Areas.Admin.Controllers
                 condition += " and StoreId in (select StoreId from StoreForName where Name='" + StoreIdName + "')";
             }
             //品牌
-            // condition += " and BrandId = " + data.BrandId;
+            if (data.BrandId == 0)
+            {
+                condition += " and BrandId = 1";
+            }
+            if (data.BrandId != 0)
+            {
+                condition += " and BrandId = " + data.BrandId;
+            }
             if (!string.IsNullOrEmpty(UpFeeFlagSelect))
             {
                 condition += " and UpFeeFlag = " + UpFeeFlagSelect;
@@ -789,13 +796,13 @@ namespace MySystem.Areas.Admin.Controllers
         /// 导出Excel
         /// </summary>
         /// <returns></returns>
-        public JsonResult ExportExcel(PosMachinesTwo data, string BindingStateSelect, string ActivationStateSelect, string UserIdMakerCode, string UserIdRealName, string StoreIdCode, string StoreIdName)
+        public JsonResult ExportExcel(PosMachinesTwo data, string BindingStateSelect, string ActivationStateSelect, string UserIdMakerCode, string UserIdRealName, string StoreIdCode, string StoreIdName, string UpFeeFlagSelect)
         {
             Dictionary<string, string> Fields = new Dictionary<string, string>();
             Fields.Add("PosSn", "1"); //SN编号
             Fields.Add("BrandId", "0"); //品牌
 
-            string condition = " and Status>-1";
+            string condition = " and Status>-1 and BrandId = " + data.BrandId + " ";
             //绑定状态
             if (!string.IsNullOrEmpty(BindingStateSelect))
             {
@@ -826,6 +833,11 @@ namespace MySystem.Areas.Admin.Controllers
             {
                 condition += " and StoreId in (select StoreId from StoreForName where Name='" + StoreIdName + "')";
             }
+            //是否调整
+            if (!string.IsNullOrEmpty(UpFeeFlagSelect))
+            {
+                condition += " and UpFeeFlag = " + UpFeeFlagSelect;
+            }
 
 
             Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PosMachinesTwo", Fields, "Id desc", "0", 1, 20000, condition, "BindingState,ActivationState,UserId,StoreId,PosSn,BrandId,ActivityList,BindMerchantId,PosSnType,DeviceType,BindingTime,UpFeeDate,DownFeeDate,ActivationTime,TransferTime", false);

+ 12 - 7
Areas/Admin/Views/MainServer/PosMachinesFeeChangeRecord/Index.cshtml

@@ -89,7 +89,7 @@
                     </div>
                     @{
                         Dictionary<string, string> ProfitObjectsActivesDic = new
-                    MySystem.DictionaryClass().getKqProductBrandDic();
+            MySystem.DictionaryClass().getKqProductBrandDic();
                     }
                     <div class="layui-inline">
                         <label class="layui-form-label">品牌</label>
@@ -98,7 +98,7 @@
                                 <option value="">全部...</option>
                                 @foreach (string key in ProfitObjectsActivesDic.Keys)
                                 {
-                                    <option value="@key">@ProfitObjectsActivesDic[key]</option>
+                                    <option value="@key" @(key == "1" ? "selected=selected" : "")>@ProfitObjectsActivesDic[key]</option>
                                 }
                             </select>
                         </div>
@@ -108,9 +108,9 @@
                         <div class="layui-input-inline">
                             <select id="StatusSelect" name="StatusSelect" lay-search="">
                                 <option value="">全部...</option>
-                                <option value="0">处理中</option>
+                                <option value="2">处理中</option>
                                 <option value="1">成功</option>
-                                <option value="-1">失败</option>
+                                <option value="3">失败</option>
                             </select>
                         </div>
                     </div>
@@ -143,20 +143,25 @@
                         @* <button class="layui-btn" data-type="ImportData"><i
                             class="layui-icon layui-icon-upload layuiadmin-button-btn"></i>导入</button> *@
                         <button class="layui-btn" data-type="ExportExcel"><i
-                            class="layui-icon layui-icon-export layuiadmin-button-btn"></i>导出</button>
+                            class="layui-icon layui-icon-export layuiadmin-button-btn"></i>导出费率调低申请记录</button>
 
                     }
+                    @if (RightInfo.Contains("," + right + "_import,"))
+                    {
+                        <button class="layui-btn" data-type="ImportData"><i
+                            class="layui-icon layui-icon-upload layuiadmin-button-btn"></i>导入调整结果</button>
+                    }
                 </div>
 
                 <table id="LAY-list-manage" lay-filter="LAY-list-manage"></table>
                 <script type="text/html" id="table-list-tools">
                     @if (RightInfo.Contains("," + right + "_edit,"))
                     {
-                        <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
+                            <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
                     }
                     @if (RightInfo.Contains("," + right + "_delete,"))
                     {
-                        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
+                            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
                     }
                     @if (RightInfo.Contains("," + right + "_edit,"))
                     {

+ 3 - 3
Areas/Admin/Views/MainServer/PosMachinesTwoChange/Index.cshtml

@@ -129,7 +129,7 @@
                                 <option value="">全部...</option>
                                 @foreach (string key in ProfitObjectsActivesDic.Keys)
                                 {
-                                    <option value="@key">@ProfitObjectsActivesDic[key]</option>
+                                    <option value="@key" @(key == "1" ? "selected=selected" : "")>@ProfitObjectsActivesDic[key]</option>
                                 }
                             </select>
                         </div>
@@ -155,8 +155,8 @@
                         {
                             @* <button class="layui-btn" data-type="ImportData"><i class="layui-icon layui-icon-export
                                 layuiadmin-button-btn"></i>导入机具费率</button> *@
-                            <button class="layui-btn" data-type="ImportData"><i
-                                class="layui-icon layui-icon-upload layuiadmin-button-btn"></i>导入机具费率</button>
+                            @* <button class="layui-btn" data-type="ImportData"><i
+                                class="layui-icon layui-icon-upload layuiadmin-button-btn"></i>导入调低机具费率</button> *@
                         }
                     </div>
                 </div>

+ 9 - 5
wwwroot/layuiadmin/modules_main/PosMachinesFeeChangeRecord_Admin.js

@@ -1,8 +1,8 @@
-var ExcelData, ExcelKind;
+var ExcelData;
 function ConfirmImport() {
     $.ajax({
         type: "POST",
-        url: "/Admin/PosMachinesFeeChangeRecord/Import?r=" + Math.random(1),
+        url: "/Admin/PosMachinesFeeChangeRecord/ImportEnd?r=" + Math.random(1),
         data: "ExcelData=" + encodeURIComponent(JSON.stringify(ExcelData)),
         dataType: "text",
         success: function (data) {
@@ -10,6 +10,11 @@ function ConfirmImport() {
                 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);
             }
@@ -64,7 +69,7 @@ layui.config({
     $('#ExcelFile').change(function (e) {
         var files = e.target.files;
         excel.importExcel(files, {}, function (data) {
-            ExcelData = data[0].sheet1;
+            ExcelData = data[0].Sheet1;
         });
     });
 
@@ -314,7 +319,6 @@ layui.config({
             layer.full(perContent);
         }
         , ImportData: function () {
-            ExcelKind = 1;
             layer.open({
                 type: 1,
                 title: '导入',
@@ -324,7 +328,7 @@ layui.config({
                 cancel: function () {
                 }
             });
-            $("#excelTemp").html('<a href="/excelfile/模板文件.xlsx">点击下载模板文件</a>');
+            $("#excelTemp").html('<a href="/users/机具费率调整模版.xlsx">点击下载机具费率调整模板</a>');
         }
         , ExportExcel: function () {
             var userdata = '';