Browse Source

后台设置机具费率绣花

lcl 2 years ago
parent
commit
d2a2af9288

+ 28 - 30
Areas/Admin/Controllers/MainServer/SysToolsController.cs

@@ -4027,28 +4027,22 @@ namespace MySystem.Areas.Admin.Controllers
         }
 
         [HttpPost]
-        public string SetPosFeeDo(string PosSn, string FeeType)
+        public string SetPosFeeDo(string PosSn, int FeeType, int RecordFlag = 0)
         {
             if (string.IsNullOrEmpty(PosSn))
             {
                 return "请输入机具SN";
             }
-            if (string.IsNullOrEmpty(FeeType))
+            if (FeeType == 0)
             {
                 return "请输入选择费率";
             }
-            if (FeeType == "0")
+            string Fee = "0.63";
+            if(FeeType == 3)
             {
-                FeeType = "0.6";
+                Fee = "0.6";
             }
-            if (FeeType == "1")
-            {
-                FeeType = "0.63";
-            }
-
             string[] PosSnList = PosSn.Replace("\r", "").Split('\n');
-            var PosId = "";
-            var RecordId = "";
             var error = "";
             foreach (var item in PosSnList)
             {
@@ -4056,21 +4050,30 @@ namespace MySystem.Areas.Admin.Controllers
                 var posInfo = db.PosMachinesTwo.FirstOrDefault(m => m.Id == pos.SnId) ?? new PosMachinesTwo();
                 if (posInfo.Id > 0)
                 {
-                    var query = db.PosMachinesFeeChangeRecord.Add(new PosMachinesFeeChangeRecord()
+                    string RecordId = "";
+                    if(RecordFlag == 1)
                     {
-                        Sort = posInfo.BrandId,
-                        CreateDate = DateTime.Now,
-                        PosId = posInfo.Id,
-                        PosSn = posInfo.PosSn,
-                        PosUserId = posInfo.UserId,
-                        MerchantId = posInfo.BindMerchantId,
-                        UserId = posInfo.UserId,
-                        ChangeFee = decimal.Parse(FeeType),
-
-                    }).Entity;
-                    db.SaveChanges();
-                    PosId += posInfo.Id + ",";
-                    RecordId += query.Id + ",";
+                        decimal ChangeFee = decimal.Parse(Fee);
+                        PosMachinesFeeChangeRecord query = db.PosMachinesFeeChangeRecord.FirstOrDefault(m => m.PosId == posInfo.Id && m.ChangeFee == ChangeFee && m.Status == 0);
+                        if(query == null)
+                        {
+                            query = db.PosMachinesFeeChangeRecord.Add(new PosMachinesFeeChangeRecord()
+                            {
+                                Sort = posInfo.BrandId,
+                                CreateDate = DateTime.Now,
+                                PosId = posInfo.Id,
+                                PosSn = posInfo.PosSn,
+                                PosUserId = posInfo.UserId,
+                            }).Entity;
+                            db.SaveChanges();
+                        }
+                        query.MerchantId = posInfo.BindMerchantId;
+                        query.UserId = posInfo.UserId;
+                        query.ChangeFee = ChangeFee;
+                        RecordId = query.Id.ToString();
+                    }
+                    string data = "{\"RecordId\":\"" + RecordId + "\",\"PosId\":\"" + posInfo.Id + "\",\"Fee\": \"" + Fee + "\",\"Kind\": \"" + FeeType + "\",\"OpMan\": \"系统\"}";
+                    RedisDbconn.Instance.AddList("SetDepositPostQueue", data);
                 }
                 else
                 {
@@ -4081,11 +4084,6 @@ namespace MySystem.Areas.Admin.Controllers
             {
                 return "Warning|" + error;
             }
-            PosId = PosId.TrimEnd(',');
-            function.WriteLog(DateTime.Now.ToString() + ":请求参数," + PosId + ":" + SysUserName + "-" + SysRealName, "根据机具号设置费率");
-
-            string data = "{\"RecordId\":\"" + RecordId + "\",\"PosId\":\"" + PosId + "\",\"Fee\": \"" + FeeType + "\",\"Kind\": \"2\",\"OpMan\": \"系统\"}";
-            RedisDbconn.Instance.AddList("SetDepositPostQueue", data);
             return "success";
         }
         #endregion

+ 13 - 2
Areas/Admin/Views/MainServer/SysTools/SetPosFee.cshtml

@@ -40,8 +40,19 @@
                                 <div class="layui-form-item">
                                     <label class="layui-form-label">费率类</label>
                                     <div class="layui-input-inline">
-                                        <select id="FeeType" name="FeeType" lay-search="" lay-filter="FeeType">
-                                            <option value="0" selected="selected">0.6</option>
+                                        <select id="FeeType" name="FeeType" lay-search="">
+                                            <option value="1" selected="selected">0.63+3</option>
+                                            <option value="2">0.63+0</option>
+                                            <option value="3">0.60+0</option>
+                                        </select>
+                                    </div>
+                                </div>
+                                <div class="layui-form-item">
+                                    <label class="layui-form-label">是否加记录</label>
+                                    <div class="layui-input-inline">
+                                        <select id="RecordFlag" name="RecordFlag" lay-search="">
+                                            <option value="0" selected="selected">否</option>
+                                            <option value="1">是</option>
                                         </select>
                                     </div>
                                 </div>