DuGuYang %!s(int64=3) %!d(string=hai) anos
pai
achega
8f7a447421

+ 39 - 8
Areas/Admin/Controllers/MainServer/SysToolsController.cs

@@ -3797,17 +3797,29 @@ namespace MySystem.Areas.Admin.Controllers
             }
             var SnIds = "";
             string[] PosSnList = PosSn.Replace("\r", "").Replace("\n", ",").Split(',');
+            string error = "";
             foreach (string Sn in PosSnList)
             {
-                var machineForSnNo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == Sn) ?? new MachineForSnNo();
-                var posInfo = db.PosMachinesTwo.FirstOrDefault(m => m.Id == machineForSnNo.SnId) ?? new PosMachinesTwo();
+                var posInfo = db.PosMachinesTwo.FirstOrDefault(m => m.Status > -1 && m.BindingState == 0 && m.ActivationState == 0 && m.PosSn == Sn && (m.BuyUserId == fUserId.Id || m.UserId == fUserId.Id)) ?? new PosMachinesTwo();
                 if (posInfo.Id == 0)
                 {
-                    return "机具" + PosSn + "不存在";
+                    error += "以下操作失败" + PosSn + ',' + "不存在或者不符合条件" + '\n';
                 }
-                if (posInfo.BindingState == 0)
+                else
                 {
                     SnIds += posInfo.Id + ",";
+                }
+            }
+            if (!string.IsNullOrEmpty(error))
+            {
+                return "Warning|" + error;
+            }
+            else
+            {
+                var posList = db.PosMachinesTwo.Where(m => SnIds.Contains("," + m.Id + ",")).ToList();
+                foreach (var Sn in posList)
+                {
+                    var posInfo = posList.FirstOrDefault(m => m.Id == Sn.Id) ?? new PosMachinesTwo();
                     if (posInfo.UserId == 0 || posInfo.BuyUserId == posInfo.UserId)
                     {
                         posInfo.BuyUserId = tUserId.Id;
@@ -3823,12 +3835,31 @@ namespace MySystem.Areas.Admin.Controllers
                     fUserPos.UnBindCount -= 1;
                     tUserPos.TotalMachineCount += 1;
                     tUserPos.UnBindCount += 1;
+                    db.StoreChangeHistory.Add(new StoreChangeHistory()
+                    {
+                        CreateDate = DateTime.Now,
+                        UserId = fUserId.Id, //创客
+                        BrandId = posInfo.BrandId,//产品类型
+                        ChangeRecordNo = "HBJJ" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8), //变更记录单号
+                        TransType = 1, //交易类型
+                        SnNo = posInfo.PosSn, //SN编号
+                        SnType = posInfo.PosSnType, //SN机具类型
+                        StockOpDirect = 1, //库存操作方向
+                        DeviceVendor = posInfo.DeviceName, //设备厂商
+                        DeviceModel = posInfo.DeviceKind, //设备型号
+                        DeviceType = posInfo.DeviceType, //设备类型
+                        FromUserId = fUserId.Id, //出货创客
+                        FromDate = DateTime.Now, //出库时间
+                        FromRemark = "划拨创客机具", //出库备注
+                        SourceStoreId = posInfo.SourceStoreId, //源仓库
+                        ToUserId = tUserId.Id,//收货创客
+                    });
                 }
+                var query = SnIds + ";" + FromMakerCode + ";" + ToMakerCode;
+                function.WriteLog(DateTime.Now.ToString() + ":请求参数," + query + ":" + SysUserName + "-" + SysRealName, "划拨创客机具");
+                db.SaveChanges();
+                db.Dispose();
             }
-            var query = SnIds + ";" + FromMakerCode + ";" + ToMakerCode;
-            function.WriteLog(DateTime.Now.ToString() + ":请求参数," + query + ":" + SysUserName + "-" + SysRealName, "划拨创客机具");
-            db.SaveChanges();
-            db.Dispose();
 
             return "success";
         }

+ 11 - 4
Areas/Admin/Views/MainServer/SysTools/TransferPos.cshtml

@@ -33,14 +33,15 @@
                                 @* <div class="layui-form-item">
                                     <label class="layui-form-label">机具SN</label>
                                     <div class="layui-input-inline">
-                                        <input class="layui-input" type="text" id="PosSn" name="PosSn" maxlength="50"
-                                            lay-verify="required|" autocomplete="off" placeholder="请输入机具SN">
+                                    <input class="layui-input" type="text" id="PosSn" name="PosSn" maxlength="50"
+                                    lay-verify="required|" autocomplete="off" placeholder="请输入机具SN">
                                     </div>
-                                </div> *@
+                                    </div> *@
                                 <div class="layui-form-item">
                                     <label class="layui-form-label">机具SN</label>
                                     <div class="layui-input-block">
-                                        <textarea class="layui-textarea" lay-verify="required|" name="PosSn" id="PosSn" placeholder="请输入机具SN,多个机具SN用回车隔开"></textarea>
+                                        <textarea class="layui-textarea" lay-verify="required|" name="PosSn" id="PosSn"
+                                            placeholder="请输入机具SN,多个机具SN用回车隔开"></textarea>
                                     </div>
                                 </div>
                                 <div class="layui-form-item">
@@ -111,6 +112,12 @@
                                 }, function () {
                                     window.location.reload();
                                 });
+                            } else if (data.indexOf("Warning") == 0) {
+                                var datalist = data.split('|');
+                                layer.close(indexs); //关闭弹层
+                                layer.alert(datalist[1], { time: 20000 }, function () {
+                                    window.location.reload();
+                                });
                             } else {
                                 layer.close(indexs); //关闭弹层
                                 layer.msg(data);

+ 1 - 1
wwwroot/layuiadmin/modules_main/PosMerchantInforgList_Admin.js

@@ -125,7 +125,7 @@ layui.config({
             , { field: 'MerchantMobile', width: 200, title: '手机号', sort: true }
             , { field: 'KqSnNo', width: 220, title: '机具SN号', sort: true }
             , { field: 'SeoKeyword', width: 220, title: '实际押金', sort: true }
-            , { field: 'PrizeParams', width: 220, title: '设置押金', sort: true }
+            // , { field: 'PrizeParams', width: 220, title: '设置押金', sort: true }
             , { field: 'Remark', width: 220, title: '已退金额', sort: true }
         ]]
         , where: {