Răsfoiți Sursa

查询机具信息添加广电卡注销/欠费条件限制
添加导入数据方式

DuGuYang 2 ani în urmă
părinte
comite
f2564e72ac

+ 265 - 28
AppStart/Helper/SIMPosMerchantTradeService.cs

@@ -48,7 +48,8 @@ namespace MySystem
                         while (DoCount < list.Rows.Count)
                         {
                             WebCMSEntities db = new WebCMSEntities();
-                            //导入人工已退
+                            SpModels.WebCMSEntities spdb = new SpModels.WebCMSEntities();
+                            //导激活
                             if (_Kind == "1")
                             {
                                 var tran = db.Database.BeginTransaction();
@@ -63,37 +64,273 @@ namespace MySystem
                                     for (int i = DoCount; i < DoCount + Size; i++)
                                     {
                                         DataRow dr = list.Rows[i];
-                                        string PosSn = dr[0].ToString().Replace("机具SN:", "");// 退押机具Sn
-                                        string Statuss = dr[1].ToString(); // 结果
-                                        string SeoDescription = dr[2].ToString();// 备注
-                                        int Status = 0;
-                                        if (Statuss == "SUCCESS")//成功
+                                        string OrderNo = dr["订单编码"].ToString();
+                                        string CreateDate = dr["订单创建时间"].ToString();
+                                        string PhoneNumber = dr["选择号码"].ToString();
+                                        string HasFirstCharge = dr["是否有首充"].ToString();
+                                        string FirstChargeAmount = dr["首充金额(元)"].ToString();
+                                        string Province = dr["号码归属省份"].ToString();
+                                        string City = dr["号码归属地市"].ToString();
+                                        string ProductName = dr["商品名称"].ToString();
+                                        string ActiveName = dr["促销活动名称"].ToString();
+                                        string ProductType = dr["商品类型名称"].ToString();
+                                        string ActualAmount = dr["实付金额(元)"].ToString();
+                                        string OrderStatus = dr["订单状态"].ToString();
+                                        string ActStatus = dr["激活状态名称"].ToString();
+                                        string ActDate = dr["激活时间"].ToString();
+                                        string WorkNo = dr["BOSS员工工号"].ToString();
+                                        string AccountName = dr["账号姓名"].ToString();
+                                        string SimNo = dr["SIM卡号"].ToString();
+
+                                        // PosMerchantInfo checkMer = db.PosMerchantInfo.FirstOrDefault(m => m.KqMerNo == PhoneNumber && m.Field5 == ActStatus);
+                                        // if (checkMer == null)
+                                        // {
+                                        string json = "{";
+                                        json += "\"OrderNo\":\"" + OrderNo + "\",";
+                                        json += "\"CreateDate\":\"" + CreateDate + "\",";
+                                        json += "\"PhoneNumber\":\"" + PhoneNumber + "\",";
+                                        json += "\"HasFirstCharge\":\"" + HasFirstCharge + "\",";
+                                        json += "\"FirstChargeAmount\":\"" + FirstChargeAmount + "\",";
+                                        json += "\"Province\":\"" + Province + "\",";
+                                        json += "\"City\":\"" + City + "\",";
+                                        json += "\"ProductName\":\"" + ProductName + "\",";
+                                        json += "\"ActiveName\":\"" + ActiveName + "\",";
+                                        json += "\"ProductType\":\"" + ProductType + "\",";
+                                        json += "\"ActualAmount\":\"" + ActualAmount + "\",";
+                                        json += "\"OrderStatus\":\"" + OrderStatus + "\",";
+                                        json += "\"ActStatus\":\"" + ActStatus + "\",";
+                                        json += "\"ActDate\":\"" + ActDate + "\",";
+                                        json += "\"WorkNo\":\"" + WorkNo + "\",";
+                                        json += "\"AccountName\":\"" + AccountName + "\",";
+                                        json += "\"SimNo\":\"" + SimNo + "\"";
+                                        json += "}";
+
+                                        spdb.BindRecord.Add(new SpModels.BindRecord()
                                         {
-                                            Status = 1;
-                                        }
-                                        if (Statuss == "FAIL")//失败
+                                            CreateDate = DateTime.Parse(CreateDate),
+                                            UpdateTime = DateTime.Parse(CreateDate), //机具绑定、解绑时间
+                                            CreateTime = DateTime.Parse(CreateDate), //商户操作时间
+                                            MerNewSnNo = PhoneNumber, //商户手机号
+                                            MerSnNo = SimNo, //序列号
+                                            MerName = AccountName, //商户名称
+                                            MerNo = PhoneNumber, //商户编号
+                                            Remark = ProductType,
+                                            Field1 = Province,
+                                            Field2 = ActiveName,
+                                            Field3 = ProductName,
+                                            Field4 = WorkNo,
+                                            Field5 = ActStatus,
+                                            SeoTitle = ActualAmount,
+                                            SeoKeyword = ActDate,
+                                            SeoDescription = json,
+                                            ProductType = "14",
+                                            Status = 1,
+                                        });
+
+                                        spdb.Merchants.Add(new SpModels.Merchants()
                                         {
-                                            Status = 2;
-                                        }
-                                        var pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == PosSn) ?? new PosMachinesTwo();
-                                        var merchantDepositReturns = db.MerchantDepositReturns.FirstOrDefault(m => m.MerchantId == pos.BindMerchantId && m.Status == 0) ?? new MerchantDepositReturns();
-                                        if (merchantDepositReturns.Id == 0)
+                                            SnNo = SimNo,
+                                            CreateTime = DateTime.Parse(CreateDate),
+                                            UpdateTime = DateTime.Parse(CreateDate),
+                                            AgentName = AccountName,
+                                            MerRealName = AccountName,
+                                            MerMobile = PhoneNumber,
+                                            MerNo = PhoneNumber,
+                                            MerName = AccountName,
+                                            ProductType = "14",
+                                            Status = 1,
+                                        });
+                                        SuccessCount += 1;
+                                    }
+                                    DoCount += Size;
+                                    db.SaveChanges();
+                                    tran.Commit();
+                                    if (DoCount >= list.Rows.Count)
+                                    {
+                                        RedisDbconn.Instance.Set("SIMPosMerchantTradeCheckImport:" + checkKey, "success|" + SuccessCount);
+                                        RedisDbconn.Instance.SetExpire("SIMPosMerchantTradeCheckImport:" + checkKey, 60000);
+                                    }
+                                }
+                                catch (Exception ex)
+                                {
+                                    DoCount = list.Rows.Count;
+                                    function.WriteLog(ex.ToString(), "导入广电卡激活数据");
+                                    tran.Rollback();
+                                    ErrorMsg msg = new ErrorMsg()
+                                    {
+                                        Time = DateTime.Now,
+                                        ErrorContent = ex.ToString(),
+                                    };
+                                    function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(msg), "导入广电卡激活数据Excel文件异常");
+                                }
+                                tran.Dispose();
+                            }
+                            //导交易
+                            if (_Kind == "2")
+                            {
+                                var tran = db.Database.BeginTransaction();
+                                try
+                                {
+                                    int Size = 100;
+                                    if (list.Rows.Count - DoCount < 100)
+                                    {
+                                        Size = list.Rows.Count - DoCount;
+                                    }
+                                    Dictionary<string, int> storeData = new Dictionary<string, int>();
+                                    for (int i = DoCount; i < DoCount + Size; i++)
+                                    {
+                                        DataRow dr = list.Rows[i];
+                                        string Mobile = dr["用户手机号"].ToString();
+                                        string SimNo = dr["SIM卡号"].ToString();
+                                        string CreateMonth = dr["入网月份"].ToString();
+                                        string SettleMonth = dr["结算月份"].ToString();
+                                        string SettleTime = dr["结算账期"].ToString();
+                                        string SettleSpace = dr["结算场景"].ToString();
+                                        string BusinessType = dr["业务类型"].ToString();
+                                        string Province = dr["用户省份"].ToString();
+                                        string City = dr["用户地市"].ToString();
+                                        string Team = dr["团队归属"].ToString();
+                                        string WorkName = dr["行销宝姓名"].ToString();
+                                        string WorkNo = dr["行销宝工号"].ToString();
+                                        string ProductName = dr["商品名称"].ToString();
+                                        string TotalAmount = dr["账单总金额"].ToString();
+                                        string InAmount = dr["套内金额"].ToString();
+                                        string OutAmount = dr["套外金额"].ToString();
+                                        string UserStatus = dr["用户状态"].ToString();
+                                        string ChannelCode = dr["渠道编码"].ToString();
+                                        string ChannelName = dr["渠道名称"].ToString();
+                                        string OrderCreateTime = dr["订单创建时间"].ToString();
+                                        string OrderStatus = dr["订单状态"].ToString();
+                                        string ActTime = dr["激活时间"].ToString();
+                                        string SourceProductName = dr["原订单商品名称"].ToString();
+                                        string ProductType = dr["商品类型名称"].ToString();
+                                        string ActivityName = dr["促销活动名称"].ToString();
+                                        string Percent = dr["分成比例"].ToString();
+                                        string OrgDivi = dr["机构分成"].ToString();
+
+                                        string json = "{";
+                                        json += "\"Mobile\":\"" + Mobile + "\",";
+                                        json += "\"SimNo\":\"" + SimNo + "\",";
+                                        json += "\"CreateMonth\":\"" + CreateMonth + "\",";
+                                        json += "\"SettleMonth\":\"" + SettleMonth + "\",";
+                                        json += "\"SettleTime\":\"" + SettleTime + "\",";
+                                        json += "\"SettleSpace\":\"" + SettleSpace + "\",";
+                                        json += "\"BusinessType\":\"" + BusinessType + "\",";
+                                        json += "\"Province\":\"" + Province + "\",";
+                                        json += "\"City\":\"" + City + "\",";
+                                        json += "\"Team\":\"" + Team + "\",";
+                                        json += "\"WorkName\":\"" + WorkName + "\",";
+                                        json += "\"WorkNo\":\"" + WorkNo + "\",";
+                                        json += "\"ProductName\":\"" + ProductName + "\",";
+                                        json += "\"TotalAmount\":\"" + TotalAmount + "\",";
+                                        json += "\"InAmount\":\"" + InAmount + "\",";
+                                        json += "\"OutAmount\":\"" + OutAmount + "\",";
+                                        json += "\"UserStatus\":\"" + UserStatus + "\",";
+                                        json += "\"ChannelCode\":\"" + ChannelCode + "\",";
+                                        json += "\"ChannelName\":\"" + ChannelName + "\",";
+                                        json += "\"OrderCreateTime\":\"" + OrderCreateTime + "\",";
+                                        json += "\"OrderStatus\":\"" + OrderStatus + "\",";
+                                        json += "\"ActTime\":\"" + ActTime + "\",";
+                                        json += "\"SourceProductName\":\"" + SourceProductName + "\",";
+                                        json += "\"ProductType\":\"" + ProductType + "\",";
+                                        json += "\"ActivityName\":\"" + ActivityName + "\",";
+                                        json += "\"Percent\":\"" + Percent + "\",";
+                                        json += "\"OrgDivi\":\"" + OrgDivi + "\"";
+                                        json += "}";
+
+                                        bool op = true;
+                                        string OrderNo = DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);
+                                        decimal TotalAmountNum = decimal.Parse(function.CheckNum(numberString: TotalAmount));
+                                        DateTime CreateDate = DateTime.Parse(OrderCreateTime);
+                                        string CheckDate = DateTime.Now.AddMonths(-3).ToString("yyyyMM");
+                                        if (int.Parse(CreateMonth) >= int.Parse(CheckDate)) op = false;
+                                        if (OrderStatus == "待激活") op = false;
+                                        if (UserStatus.Contains("注销") || UserStatus.Contains("欠费"))
                                         {
-                                            RedisDbconn.Instance.AddList("ErrList" + checkKey, "以下操作失败,机具" + PosSn + ',' + "对应的退押订单" + merchantDepositReturns.SeoKeyword + "该订单未找到或不符合规则");
+                                            op = false;
+                                            SimposMerchantInfo checkSimMer = db.SimposMerchantInfo.FirstOrDefault(m => m.KqMerNo == Mobile && m.KqSnNo == SimNo);
+                                            if (checkSimMer != null)
+                                            {
+                                                checkSimMer.Status = -1;
+                                                if (UserStatus.Contains("欠费") && checkSimMer.Status != -1)
+                                                {
+                                                    checkSimMer.Status = -2;
+                                                }
+                                                db.SaveChanges();
+                                            }
+                                            PosMerchantInfo checkMer = db.PosMerchantInfo.FirstOrDefault(m => m.KqMerNo == Mobile && m.KqSnNo == SimNo);
+                                            if (checkMer != null)
+                                            {
+                                                checkMer.Status = -1;
+                                                if (UserStatus.Contains("欠费") && checkMer.Status != -1)
+                                                {
+                                                    checkMer.Status = -2;
+                                                }
+                                                db.SaveChanges();
+                                            }
+                                            PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == SimNo);
+                                            if (pos != null)
+                                            {
+                                                pos.Status = -1;
+                                                if (UserStatus.Contains("欠费") && pos.Status != -1)
+                                                {
+                                                    pos.Status = -2;
+                                                }
+                                                db.SaveChanges();
+                                            }
                                         }
-                                        else
+                                        if (UserStatus.Contains("正常"))
                                         {
-                                            //失败
-                                            if (Status == 2)
+                                            SimposMerchantInfo checkSimMer = db.SimposMerchantInfo.FirstOrDefault(m => m.KqMerNo == Mobile && m.KqSnNo == SimNo);
+                                            if (checkSimMer != null)
+                                            {
+                                                if (checkSimMer.Status == -2) checkSimMer.Status = 0;
+                                                db.SaveChanges();
+                                            }
+                                            PosMerchantInfo checkMer = db.PosMerchantInfo.FirstOrDefault(m => m.KqMerNo == Mobile && m.KqSnNo == SimNo);
+                                            if (checkMer != null)
+                                            {
+                                                if (checkMer.Status == -2) checkMer.Status = 1;
+                                                db.SaveChanges();
+                                            }
+
+                                            PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == SimNo);
+                                            if (pos != null && pos.Status < 0)
                                             {
-                                                var posm = db.PosMerchantInfo.FirstOrDefault(m => m.Id == merchantDepositReturns.MerchantId) ?? new PosMerchantInfo();
-                                                posm.StandardStatus = 101;
+                                                if (pos.Status == -2)
+                                                {
+                                                    pos.Status = 0;
+                                                }
+                                                db.SaveChanges();
                                             }
-                                            merchantDepositReturns.Status = Status;
-                                            merchantDepositReturns.UpdateDate = DateTime.Now;
-                                            merchantDepositReturns.SeoDescription = SeoDescription;
-                                            merchantDepositReturns.SeoTitle = Operator;
-                                            SuccessCount += 1;
+                                        }
+
+                                        if (TotalAmountNum > 0 && op)
+                                        {
+                                            spdb.TradeRecord.Add(new SpModels.TradeRecord()
+                                            {
+                                                CreateDate = DateTime.Now.AddMonths(-1), //创建时间
+                                                TradeSerialNo = OrderNo, //订单编号
+                                                AgentNo = WorkName + WorkNo, //一级服务商编号
+                                                MerNo = Mobile, //商户编
+                                                TradeSnNo = SimNo, //sim卡号
+                                                ChannelSerial = OrderNo, //请求号
+                                                TradeAmount = TotalAmountNum, //账单总金额
+                                                TradeStatus = OrderStatus, //订单状态
+                                                TradeDate = CreateMonth,
+                                                TradeTime = CreateDate.ToString("yyyyMMdd"),
+                                                BankCardType = "01",
+                                                TradeType = "01",
+                                                ProductType = "14",
+                                                Status = 1,
+                                                Field1 = ProductName,
+                                                Field2 = SourceProductName,
+                                                Field3 = ProductType,
+                                                Field4 = BusinessType,
+                                                SeoDescription = json,
+                                            });
+
+                                            spdb.SaveChanges();
                                         }
                                     }
                                     DoCount += Size;
@@ -101,21 +338,21 @@ namespace MySystem
                                     tran.Commit();
                                     if (DoCount >= list.Rows.Count)
                                     {
-                                        RedisDbconn.Instance.Set("SIMPosMerchantTradeCheckImport:" + checkKey, "success|" + SuccessCount);
+                                        RedisDbconn.Instance.Set("SIMPosMerchantTradeCheckImport:" + checkKey, "success|");
                                         RedisDbconn.Instance.SetExpire("SIMPosMerchantTradeCheckImport:" + checkKey, 60000);
                                     }
                                 }
                                 catch (Exception ex)
                                 {
                                     DoCount = list.Rows.Count;
-                                    function.WriteLog(ex.ToString(), "导入首台服务费退还结果");
+                                    function.WriteLog(ex.ToString(), "导入广电卡交易数据");
                                     tran.Rollback();
                                     ErrorMsg msg = new ErrorMsg()
                                     {
                                         Time = DateTime.Now,
                                         ErrorContent = ex.ToString(),
                                     };
-                                    function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(msg), "导入首台服务费退还结果Excel文件异常");
+                                    function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(msg), "导入广电卡交易数据Excel文件异常");
                                 }
                                 tran.Dispose();
                             }

+ 1 - 1
Areas/Admin/Controllers/MainServer/SysToolsController.cs

@@ -1209,7 +1209,7 @@ namespace MySystem.Areas.Admin.Controllers
             {
                 return "机具SN不存在";
             }
-            if (pos.Status == -1)
+            if (pos.Status < 0 && pos.BrandId != 14)
             {
                 Users posUsers = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId) ?? new Users();
                 decimal Deposits = decimal.Parse(function.CheckNum(pos.SeoKeyword));

+ 2 - 9
Areas/Admin/Controllers/MainServer/TradeRecordController.cs

@@ -510,10 +510,11 @@ namespace MySystem.Areas.Admin.Controllers
         #endregion
 
         #region 导入交易数据
-        public IActionResult ImportTrade(string right)
+        public IActionResult ImportTrade(string right, string ExcelKind)
         {
             ViewBag.RightInfo = RightInfo;
             ViewBag.right = right;
+            ViewBag.ExcelKind = ExcelKind;
             return View();
         }
         /// <summary>
@@ -690,14 +691,6 @@ namespace MySystem.Areas.Admin.Controllers
 
 
         #region 通过队列导入数据
-
-        public IActionResult ImportByQueue(string right, string ExcelKind)
-        {
-            ViewBag.RightInfo = RightInfo;
-            ViewBag.right = right;
-            ViewBag.ExcelKind = ExcelKind;
-            return View();
-        }
         /// <summary>
         /// 通过队列导入数据
         /// </summary>

+ 2 - 0
Startup.cs

@@ -141,6 +141,7 @@ namespace MySystem
 
             if(Env == "Develop")
             {
+                SIMPosMerchantTradeService.Instance.Start(); //导入广电卡数据
             }
             if(Env == "Production")
             {
@@ -150,6 +151,7 @@ namespace MySystem
                 SycnHelpProfitService.Instance.Start();
                 ExcelHelper.Instance.Start();
                 OpExcelHelper.Instance.Start();
+                SIMPosMerchantTradeService.Instance.Start(); //导入广电卡数据
                 SycnUserMachineCountHelper.Instance.Start(); //重置创客机具数量
 
                 TestHelper.Instance.Start(); //生成兑换券

+ 55 - 8
wwwroot/layuiadmin/modules_main/TradeRecord_Admin.js

@@ -41,6 +41,7 @@ function CheckImport(table, key, loadindex, index) {
         data: "key=" + key,
         dataType: "json",
         success: function (data) {
+            console.log(data);
             if (data.status == 1) {
                 layer.msg("成功操作" + data.data + "条", {
                     time: 2000
@@ -405,10 +406,57 @@ layui.config({
             layer.full(perContent);
         }
         , Import: function () {
+            // var perContent = layer.open({
+            //     type: 2,
+            //     title: '导激活',
+            //     content: 'Import',
+            //     maxmin: true,
+            //     area: ['650px', '350px'],
+            //     btn: ['确定', '取消'],
+            //     yes: function (index, layero) {
+            //         var iframeWindow = window['layui-layer-iframe' + index],
+            //             submitID = 'LAY-list-front-submit',
+            //             submit = layero.find('iframe').contents().find('#' + submitID);
+
+
+            //         //监听提交
+            //         iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
+            //             var field = data.field; //获取提交的字段
+            //             var userdata = "";
+            //             for (var prop in field) {
+            //                 userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
+            //             }
+            //             //提交 Ajax 成功后,静态更新表格中的数据
+            //             //$.ajax({});
+            //             var loadindex = layer.load(1, {
+            //                 shade: [0.5, '#000']
+            //             });
+            //             $.ajax({
+            //                 type: "POST",
+            //                 url: "/Admin/TradeRecord/ImportPost?r=" + Math.random(1),
+            //                 data: userdata,
+            //                 dataType: "text",
+            //                 success: function (data) {
+            //                     layer.close(loadindex);
+            //                     if (data == 'success') {
+            //                         layer.msg('导入成功', {time:2000}, function(){
+            //                             window.location.reload();
+            //                         });
+            //                     } else {
+            //                         layer.msg(data);
+            //                     }
+            //                 }
+            //             });
+            //         });
+
+            //         submit.trigger('click');
+            //     }
+            // });
+
             var perContent = layer.open({
                 type: 2,
                 title: '导激活',
-                content: 'Import',
+                content: 'ImportTrade?ExcelKind=1',
                 maxmin: true,
                 area: ['650px', '350px'],
                 btn: ['确定', '取消'],
@@ -432,15 +480,14 @@ layui.config({
                         });
                         $.ajax({
                             type: "POST",
-                            url: "/Admin/TradeRecord/ImportPost?r=" + Math.random(1),
+                            url: "/Admin/TradeRecord/ImportByQueuePost?r=" + Math.random(1),
                             data: userdata,
                             dataType: "text",
                             success: function (data) {
-                                layer.close(loadindex);
-                                if (data == 'success') {
-                                    layer.msg('导入成功', {time:2000}, function(){
-                                        window.location.reload();
-                                    });
+                                if (data.indexOf("success") == 0) {
+                                    var datalist = data.split('|');
+                                    var key = datalist[1];
+                                    CheckImport(table, key, loadindex, index);
                                 } else {
                                     layer.msg(data);
                                 }
@@ -502,7 +549,7 @@ layui.config({
             var perContent = layer.open({
                 type: 2,
                 title: '导交易',
-                content: 'ImportTrade?ExcelKind=1',
+                content: 'ImportTrade?ExcelKind=2',
                 maxmin: true,
                 area: ['650px', '350px'],
                 btn: ['确定', '取消'],