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

机具申请样式部分修改

“DuGuYang” 4 лет назад
Родитель
Сommit
bdcaaff20e

+ 70 - 110
Areas/Admin/Controllers/MainServer/StoreMachineApplyController.cs

@@ -284,8 +284,6 @@ namespace MySystem.Areas.Admin.Controllers
         /// <returns></returns>
         public string Cancel(int Id)
         {
-            AddSysLog(Id, "StoreMachineApply", "cancel");
-            AddSysLog(Id, "Orders", "cancel");
             StoreMachineApply storeMachineApply = db.StoreMachineApply.FirstOrDefault(m => m.Id == Id);
             Orders order = db.Orders.FirstOrDefault(m => m.Id == storeMachineApply.OrderId);
             if (storeMachineApply != null && order != null)
@@ -295,104 +293,9 @@ namespace MySystem.Areas.Admin.Controllers
                 db.Orders.Remove(order);
                 db.SaveChanges();
             }
+            AddSysLog(Id, "StoreMachineApply", "cancel");
+            AddSysLog(Id, "Orders", "cancel");
             return "success";
-            // if (storeMachineApply != null)
-            // {
-            //     Orders order = db.Orders.FirstOrDefault(m => m.Id == storeMachineApply.OrderId);
-            //     if (order != null)
-            //     {
-            //         string SwapSnExpand = storeMachineApply.SwapSnExpand;
-            //         if (!string.IsNullOrEmpty(SwapSnExpand))
-            //         {
-            //             string[] list = SwapSnExpand.TrimEnd('\n').Split('\n');
-            //             if (storeMachineApply.Sort > 0)
-            //             {
-            //                 int Kind = storeMachineApply.Sort - 1;
-            //                 string ChangeRecordNo = "SC" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);
-            //                 int CouponCount = 0;
-            //                 foreach (string sub in list)
-            //                 {
-            //                     PosCoupons coupon = db.PosCoupons.FirstOrDefault(m => m.ExchangeCode == sub && m.UserId == order.UserId && m.IsUse == 1);
-            //                     if (coupon != null)
-            //                     {
-            //                         coupon.IsUse = 0;
-            //                         coupon.IsLock = 0;
-            //                         coupon.UseDate = DateTime.Parse("1900-01-01");
-            //                         PosCouponRecord query = db.PosCouponRecord.Add(new PosCouponRecord()
-            //                         {
-            //                             QueryCount = Kind,
-            //                             CreateDate = DateTime.Now,
-            //                             ChangeKind = 1,
-            //                             OrderNo = ChangeRecordNo,
-            //                             ToUserId = order.UserId,
-            //                             FromUserId = order.UserId,
-            //                             PosCouponId = coupon.Id,
-            //                         }).Entity;
-            //                         CouponCount += 1;
-            //                     }
-            //                 }
-            //                 if (CouponCount > 0)
-            //                 {
-            //                     PosCouponForUser forUser = db.PosCouponForUser.FirstOrDefault(m => m.Id == order.UserId);
-            //                     if (forUser == null)
-            //                     {
-            //                         forUser = db.PosCouponForUser.Add(new PosCouponForUser()
-            //                         {
-            //                             Id = order.UserId,
-            //                         }).Entity;
-            //                         db.SaveChanges();
-            //                     }
-            //                     int BeforeOut = forUser.OutNum;
-            //                     int BeforeTotal = forUser.TotalNum;
-            //                     int BeforeStock = forUser.StockNum;
-            //                     forUser.StockNum += CouponCount;
-            //                     int AfterOut = forUser.OutNum;
-            //                     int AfterTotal = forUser.TotalNum;
-            //                     int AfterStock = forUser.StockNum;
-            //                     PosCouponOrders stat = db.PosCouponOrders.Add(new PosCouponOrders()
-            //                     {
-            //                         QueryCount = Kind,
-            //                         CreateDate = DateTime.Now,
-            //                         ChangeKind = 1,
-            //                         ChangeCount = CouponCount,
-            //                         AfterOut = AfterOut,
-            //                         AfterTotal = AfterTotal,
-            //                         AfterStock = AfterStock,
-            //                         BeforeOut = BeforeOut,
-            //                         BeforeTotal = BeforeTotal,
-            //                         BeforeStock = BeforeStock,
-            //                         OrderNo = ChangeRecordNo,
-            //                         ToUserId = order.UserId,
-            //                         FromUserId = order.UserId,
-            //                     }).Entity;
-            //                 }
-            //                 function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(storeMachineApply) + "#cut#" + Newtonsoft.Json.JsonConvert.SerializeObject(order) + "#cut#" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "机具申请订单取消日志");
-            //                 db.StoreMachineApply.Remove(storeMachineApply);
-            //                 db.Orders.Remove(order);
-            //                 db.SaveChanges();
-            //             }
-            //             else
-            //             {
-            //                 foreach (string sub in list)
-            //                 {
-            //                     string SourcePosSn = sub.Split(':')[0];
-            //                     MachineForSnNo forSnNo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == SourcePosSn) ?? new MachineForSnNo();
-            //                     PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == forSnNo.SnId);
-            //                     if (pos != null)
-            //                     {
-            //                         function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(storeMachineApply) + "#cut#" + Newtonsoft.Json.JsonConvert.SerializeObject(order) + "#cut#" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "机具申请订单取消日志");
-            //                         pos.IsPurchase = 0;
-            //                         RedisDbconn.Instance.Clear("PosMachinesTwo:" + pos.Id);
-            //                     }
-            //                 }
-            //                 db.StoreMachineApply.Remove(storeMachineApply);
-            //                 db.Orders.Remove(order);
-            //                 db.SaveChanges();
-            //             }
-            //         }
-            //     }
-            // }
-            // return "success";
         }
 
         #endregion
@@ -457,7 +360,7 @@ namespace MySystem.Areas.Admin.Controllers
         }
         #endregion
 
-         #region 导入数据
+        #region 导入数据
 
         public IActionResult Import(string right, string ExcelKind)
         {
@@ -471,12 +374,34 @@ namespace MySystem.Areas.Admin.Controllers
         /// </summary>
         /// <param name="ExcelData"></param>
         [HttpPost]
-        public string ImportPost(string ExcelPath, int Kind = 0)
+        public string ImportPost(string ExcelData)
         {
-            // RedisDbconn.Instance.AddList("ExcelImport", ExcelPath + "#cut#" + Kind);
-            string key = function.MD5_16(Guid.NewGuid().ToString());
-            RedisDbconn.Instance.AddList("ExcelImportV2", ExcelPath + "#cut#" + Kind + "#cut#" + key);
-            return "success|" + key;
+            // // RedisDbconn.Instance.AddList("ExcelImport", ExcelPath + "#cut#" + Kind);
+            // string key = function.MD5_16(Guid.NewGuid().ToString());
+            // RedisDbconn.Instance.AddList("ExcelImportV2", ExcelPath + "#cut#" + Kind + "#cut#" + key);
+            // return "success|" + key;
+            ExcelData = HttpUtility.UrlDecode(ExcelData);
+            JsonData list = JsonMapper.ToObject(ExcelData);
+            for (int i = 1; i < list.Count; i++)
+            {
+                JsonData dr = list[i];
+                // string SwapSnExpand = dr[0].ToString();
+                var temp = dr[0].ToString();
+                temp = temp.Substring(1);
+                temp = temp.Substring(0, temp.Length - 1);
+                var SwapSnExpand = temp.Split(",,");
+                // StoreMachineApply storeMachineApply = db.StoreMachineApply.FirstOrDefault(m => m.MakerCode == MakerCode);
+                // if (UserCode != null)
+                // {
+                //     Users User = db.Users.FirstOrDefault(m => m.Id == UserCode.UserId);
+                //     if (User != null)
+                //     {
+                //         User.SettleAmount = decimal.Parse(function.CheckInt(SettleAmount));
+                //     }
+                // }
+            }
+            db.SaveChanges();
+            return "success";
         }
         #endregion
 
@@ -625,8 +550,8 @@ namespace MySystem.Areas.Admin.Controllers
 
             Users users = db.Users.FirstOrDefault(m => m.Id == editData.UserId) ?? new Users();
             StoreHouse storeHouse = db.StoreHouse.FirstOrDefault(m => m.Id == editData.StoreId) ?? new StoreHouse();
-            ViewBag.MakerCode=users.MakerCode;
-            ViewBag.RealName=users.RealName;
+            ViewBag.MakerCode = users.MakerCode;
+            ViewBag.RealName = users.RealName;
 
             return View();
         }
@@ -648,6 +573,35 @@ namespace MySystem.Areas.Admin.Controllers
             StoreMachineApply apply = db.StoreMachineApply.FirstOrDefault(m=>m.Id == data.Id) ?? new StoreMachineApply();
             StoreHouse tostore = db.StoreHouse.FirstOrDefault(m=>m.Id == apply.StoreId) ?? new StoreHouse();
             int BrandId = apply.BrandId.Value;
+            var FromStoreId = 0;
+            if (BrandId==1)
+            {
+                FromStoreId=7;
+            }
+            else if (BrandId==2)
+            {
+                FromStoreId=721;
+            }
+            else if (BrandId==3)
+            {
+                FromStoreId=697;
+            }
+            else if (BrandId==4)
+            {
+                FromStoreId=774;
+            }
+            else if (BrandId==5)
+            {
+                FromStoreId=775;
+            }
+            else if (BrandId==6)
+            {
+                FromStoreId=871;
+            }
+            else if (BrandId==7)
+            {
+                FromStoreId=0;
+            }
             ExcelData = HttpUtility.UrlDecode(ExcelData);
             JsonData list = JsonMapper.ToObject(ExcelData);            
             Dictionary<string, int> storeData = new Dictionary<string, int>();
@@ -659,6 +613,11 @@ namespace MySystem.Areas.Admin.Controllers
                 string SnNo = itemJson.Contains("\"A\"") ? dr["A"].ToString() : "";
                 string BatchNo = itemJson.Contains("\"B\"") ? dr["B"].ToString() : "";
                 string OutNote = itemJson.Contains("\"C\"") ? dr["B"].ToString() : "";
+                StoreMachineApply storeMachineApply = db.StoreMachineApply.FirstOrDefault(m=>m.Id == data.Id);
+                if (storeMachineApply != null)
+                {
+                    storeMachineApply.SwapSnExpand = function.CheckString(SnNo)+',';
+                }
                 MachineForSnNo machinefor = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == SnNo) ?? new MachineForSnNo();
                 PosMachinesTwo machine = db.PosMachinesTwo.FirstOrDefault(m => m.Id == machinefor.SnId && m.StoreId != apply.StoreId && m.BuyUserId == 0 && m.UserId == 0) ?? new PosMachinesTwo();
                 if (machine.Id > 0)
@@ -666,7 +625,7 @@ namespace MySystem.Areas.Admin.Controllers
                     StoreStockChange stockchange = db.StoreStockChange.Add(new StoreStockChange()
                     {
                         CreateDate = DateTime.Now,
-                        StoreId = 7, //出货仓库
+                        StoreId = FromStoreId, //出货仓库
                         BrandId = BrandId, //产品类型
                         ProductName = RelationClass.GetKqProductBrandInfo(BrandId), //产品名称
                         BizBatchNo = BatchNo, //业务批次号
@@ -742,7 +701,9 @@ namespace MySystem.Areas.Admin.Controllers
                     db.SaveChanges();
                 }
             }
-            int StoreId = 7;
+            db.SaveChanges();
+
+            int StoreId = FromStoreId;
             int OpStoreNum = list.Count - 1;
             StoreHouse store = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new StoreHouse();
             StoreBalance balance = db.StoreBalance.Add(new StoreBalance()
@@ -813,7 +774,6 @@ namespace MySystem.Areas.Admin.Controllers
             }
 
         }
-
         #endregion
 
     }

+ 28 - 17
Areas/Admin/Views/MainServer/StoreMachineApply/AuditSend.cshtml

@@ -26,6 +26,7 @@
 
     <div class="layui-form" lay-filter="layuiadmin-form-useradmin" id="layuiadmin-form-useradmin">
         <input type="hidden" name="Id" value="@editData.Id" />
+        <input type="hidden" name="ExcelData" value="ExcelData" />
 
         <div class="layui-card">
             <div class="layui-card-body">
@@ -76,13 +77,6 @@
                                     </script>
                                 </div>
                             </div>
-                            @* <div class="layui-form-item layui-form-text">
-                                <label class="layui-form-label">*SN编号</label>
-                                <div class="layui-input-block">
-                                <textarea class="layui-textarea" id="SwapSnExpand" name="SwapSnExpand"
-                                lay-verify="required|" placeholder="请输入SN号,多个以逗号隔开">@editData.SwapSnExpand</textarea>
-                                </div>
-                                </div> *@
                             <div class="layui-form-item layui-form-text">
                                 <label class="layui-form-label">申请描述</label>
                                 <div class="layui-input-block">
@@ -91,18 +85,23 @@
                                         placeholder="请输入申请描述">@editData.SeoDescription</textarea>
                                 </div>
                             </div>
-                            @* <div class="layui-form-item"">
-                                <label class=" layui-form-label">模板下载</label>
-                                <div class="layui-form-mid layui-word-aux" id="excelTemp">
-                                </div>
-                                </div> *@
                         </div>
                         <div class="layui-form-item"">
-                                <label class=" layui-form-label">导入机具SN</label>
-                            <div class=" layui-input-block">
+                            <div class=" layui-tab-item layui-show">
+                            <div class="layui-form-item">
+                                <label class="layui-form-label">模板下载</label>
+                                <div class="layui-form-mid layui-word-aux">
+                                    <a href="/users/批量添加机具SN模版.xlsx">点击下载批量添加机具SN模版</a>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                    <div class="layui-form-item"">
+                        <label class=" layui-form-label">导入机具SN</label>
+                        <div class=" layui-input-block">
                             <div class="layui-upload">
-                                @* <input type="hidden" id="SwapSnExpand" name="SwapSnExpand" value=""> *@
-                                <button class="layui-btn" type="button" id="ExcelPathBtn">选择</button>
+                                <input type="file" id="ExcelFile" name="ExcelFile" value="">
+                                @* <button class="layui-btn" type="button" id="ExcelPathBtn">选择</button> *@
                                 <div class="layui-inline layui-word-aux"></div>
                             </div>
                             <div class="mt10" id="ExcelPathFile">
@@ -146,11 +145,13 @@
         var tree;
         var element;
         var upload;
+        var excel;
+        var ExcelData;
         layui.config({
             base: '/layuiadmin/' //静态资源所在路径
         }).extend({
             index: 'lib/index' //主入口模块
-        }).use(['index', 'form', 'upload', 'layedit', 'laydate', 'element', 'croppers', 'transfer', 'tree', 'util'], function () {
+        }).use(['index', 'form', 'upload', 'layedit', 'laydate', 'excel', 'element', 'croppers', 'transfer', 'tree', 'util'], function () {
             var $ = layui.$
                 , form = layui.form
                 , layer = layui.layer
@@ -170,6 +171,16 @@
                 location.hash = 'test=' + $(this).attr('lay-id');
             });
 
+            //excel导入
+            excel = layui.excel;
+            $('#ExcelFile').change(function (e) {
+                var files = e.target.files;
+                excel.importExcel(files, {}, function (data) {
+                    ExcelData = data[0].sheet1;
+                });
+            });
+
+
             //日期
 
 

+ 2 - 0
wwwroot/layuiadmin/modules_main/StoreMachineApply_Admin.js

@@ -20,6 +20,8 @@ function ConfirmImport() {
     });
 }
 
+$("#excelTemp").html('<a href="/users/批量添加机具SN模版.xlsx">点击下载批量添加机具SN模版</a>');
+
 var excel;
 layui.config({
     base: '/layuiadmin/' //静态资源所在路径

BIN
wwwroot/users/批量添加机具SN模版.xlsx