Browse Source

Revert "删除冗余代码"

This reverts commit c3dc9d12ef519732d6fcf4b606af044d5c1a4ae5.
DuGuYang 3 years ago
parent
commit
bc5a1d85a6

+ 75 - 0
AppStart/Helper/TimeOutPosChargeReturnService.cs

@@ -0,0 +1,75 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Threading;
+using MySystem.Models;
+using Library;
+
+namespace MySystem
+{
+    /// <summary>
+    /// 过期购买机具循环截止时间超过15天激活扣费退还
+    /// </summary>
+    public class TimeOutPosChargeReturnService
+    {
+        public readonly static TimeOutPosChargeReturnService Instance = new TimeOutPosChargeReturnService();
+        private TimeOutPosChargeReturnService()
+        { }
+
+        public void Start()
+        {
+            Thread th = new Thread(doSomething);
+            th.IsBackground = true;
+            th.Start();
+        }
+
+        public void doSomething()
+        {
+            while (true)
+            {
+                if (DateTime.Now.Hour < 18)
+                {
+                    try
+                    {
+                        string check = function.ReadInstance("/TimeOutPosChargeReturn/check" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt");
+                        if (string.IsNullOrEmpty(check))
+                        {
+                            function.WritePage("/TimeOutPosChargeReturn/", "check" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt", DateTime.Now.ToString("HH:mm:ss"));
+                            WebCMSEntities db = new WebCMSEntities();
+                            DataTable dt = CustomerSqlConn.dtable("SELECT a.Id Id FROM ToChargeBackRecord a LEFT JOIN PosMachinesTwo b ON a.Remark=b.PosSn WHERE a.`Status`=1 AND b.PosSnType=0  AND b.BindingState=1 AND b.ActivationState=1", MysqlConn.connstr);//循环过期超过15天激活机具退费创客
+                            foreach (DataRow item in dt.Rows)
+                            {
+                                int Id = int.Parse(item["Id"].ToString());
+                                var toChargeBackRecord = db.ToChargeBackRecord.FirstOrDefault(m => m.Id == Id && m.Status == 1) ?? new ToChargeBackRecord();
+                                if (toChargeBackRecord.Id > 0)
+                                {
+                                    var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == toChargeBackRecord.UserId) ?? new UserAccount();
+                                    var userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord
+                                    {
+                                        CreateDate = DateTime.Now,
+                                        UserId = toChargeBackRecord.UserId,
+                                        BeforeBalanceAmount = userAccount.BalanceAmount,
+                                        AfterBalanceAmount = userAccount.BalanceAmount + toChargeBackRecord.ChargeAmount,
+                                        ChangeAmount = toChargeBackRecord.ChargeAmount,
+                                        ChangeType = 126,//过期购买机具超过15天激活扣费退还
+                                        Remark = "机具货款退还",
+
+                                    }).Entity;
+                                    toChargeBackRecord.Status = 2;//过期购买机具循环截止时间超过15天激活扣费退还标识
+                                    userAccount.BalanceAmount += toChargeBackRecord.ChargeAmount;
+                                    db.SaveChanges();
+                                }
+                            }
+                        }
+                    }
+                    catch (Exception ex)
+                    {
+                        function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "过期购买机具超过15天激活扣费退还");
+                    }
+                }
+                Thread.Sleep(1000);
+            }
+        }
+    }
+}

+ 133 - 0
AppStart/Helper/TimeOutPosChargeService.cs

@@ -0,0 +1,133 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Threading;
+using MySystem.Models;
+using Library;
+
+namespace MySystem
+{
+    /// <summary>
+    /// 过期机具执行扣费
+    /// </summary>
+    public class TimeOutPosChargeService
+    {
+        public readonly static TimeOutPosChargeService Instance = new TimeOutPosChargeService();
+        private TimeOutPosChargeService()
+        { }
+
+        public void Start()
+        {
+            Thread th = new Thread(doSomething);
+            th.IsBackground = true;
+            th.Start();
+        }
+
+        public void doSomething()
+        {
+            while (true)
+            {
+                if (DateTime.Now.Hour < 20)
+                {
+                    try
+                    {
+                        string check = function.ReadInstance("/TimeOutPosCharge/check" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt");
+                        if (string.IsNullOrEmpty(check))
+                        {
+                            function.WritePage("/TimeOutPosCharge/", "check" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt", DateTime.Now.ToString("HH:mm:ss"));
+                            WebCMSEntities db = new WebCMSEntities();
+                            var date = DateTime.Now.AddDays(-15).ToString("yyyy-MM-dd 00:00:00");//过期限制时间
+                            var time = DateTime.Parse(date);//过期限制时间
+
+                            DataTable dt = CustomerSqlConn.dtable("SELECT BuyUserId FROM PosMachinesTwo WHERE `Status`>-1 AND BuyUserId>0 AND BindingState=0 AND ActivationState=0 AND ScanQrTrade=0 AND RecycEndDate <'" + date + "' GROUP BY BuyUserId", MysqlConn.connstr);//扣费创客
+                            var query = db.PosMachinesTwo.Where(m => m.Status > -1 && m.BuyUserId > 0 && m.BindingState == 0 && m.ActivationState == 0 && m.ScanQrTrade == 0 && m.RecycEndDate < time).ToList();//循环过期超过15天机具
+                            var brandInfo = db.KqProducts.ToList();
+                            foreach (DataRow item in dt.Rows)
+                            {
+                                int BuyUserId = int.Parse(item["BuyUserId"].ToString());
+                                function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "---48:", "过期机具执行扣费时间");
+                                var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == BuyUserId) ?? new UserAccount();
+                                function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "---50:", "过期机具执行扣费时间");
+                                var posInfo = query.Where(m => m.BuyUserId == BuyUserId);
+                                var amount = 0;
+                                foreach (var pos in posInfo)
+                                {
+                                    function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "---56:", "过期机具执行扣费时间");
+                                    var poss = db.PosMachinesTwo.FirstOrDefault(m => m.Id == pos.Id) ?? new PosMachinesTwo();
+                                    function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "---57:", "过期机具执行扣费时间");
+                                    poss.ScanQrTrade = 999;
+                                    function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "---59:", "过期机具执行扣费时间");
+                                    var Brand = brandInfo.FirstOrDefault(m => m.Id == pos.BrandId);
+                                    function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "---61:", "过期机具执行扣费时间");
+                                    if (Brand.Name.Contains("电签"))
+                                    {
+                                        amount = 200;
+                                    }
+                                    if (Brand.Name.Contains("大POS"))
+                                    {
+                                        amount = 300;
+                                    }
+                                    userAccount.ToChargeAmount += amount;//增加预扣款
+                                    function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "---71:", "过期机具执行扣费时间");
+                                    var toChargeBackRecord = db.ToChargeBackRecord.Add(new ToChargeBackRecord
+                                    {
+                                        CreateDate = DateTime.Now,
+                                        UserId = BuyUserId,
+                                        ChargeAmount = amount,
+                                        ChargeType = 124,//过期机具货款扣费
+                                        Remark = pos.PosSn,
+
+                                    }).Entity;
+                                    function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "---82:", "过期机具执行扣费时间");
+                                }
+                            }
+                            db.SaveChanges();
+
+                            function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "---85:", "过期机具执行扣费时间");
+                            var info = db.ToChargeBackRecord.Where(m => m.Status == 0).ToList();//过期机具扣费记录
+                            function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "---87:", "过期机具执行扣费时间");
+                            foreach (var items in info)
+                            {
+                                function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "---90:", "过期机具执行扣费时间");
+                                var userAccount = db.UserAccount.FirstOrDefault(m => m.Id == items.UserId) ?? new UserAccount();
+                                function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "---92:", "过期机具执行扣费时间");
+                                var record = info.FirstOrDefault(m => m.Id == items.Id);
+                                function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "---94:", "过期机具执行扣费时间");
+                                if (userAccount.BalanceAmount >= record.ChargeAmount)
+                                {
+                                    function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "---97:", "过期机具执行扣费时间");
+                                    var userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord
+                                    {
+                                        CreateDate = DateTime.Now,
+                                        UserId = items.UserId,
+                                        BeforeBalanceAmount = userAccount.BalanceAmount,
+                                        AfterBalanceAmount = userAccount.BalanceAmount - record.ChargeAmount,
+                                        ChangeAmount = record.ChargeAmount,
+                                        ChangeType = 124,//过期机具货款扣费
+                                        Remark = "扣机具货款",
+
+                                    }).Entity;
+                                    record.Status = 1;
+                                    if (userAccount.ToChargeAmount >= record.ChargeAmount)
+                                    {
+                                        userAccount.ToChargeAmount -= record.ChargeAmount;//扣减预扣款
+                                    }
+                                    userAccount.BalanceAmount -= record.ChargeAmount;//扣减余额
+                                    function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "---116:", "过期机具执行扣费时间");
+                                }
+                            }
+                            db.SaveChanges();
+
+                        }
+                    }
+                    catch (Exception ex)
+                    {
+                        function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "过期机具执行扣费异常");
+                    }
+                }
+                Thread.Sleep(1000);
+            }
+        }
+    }
+}

+ 83 - 0
AppStart/Helper/TimeOutPosSendMessageService.cs

@@ -0,0 +1,83 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Threading;
+using MySystem.Models;
+using Library;
+
+namespace MySystem
+{
+    /// <summary>
+    /// 过期机具预扣费消息推送
+    /// </summary>
+    public class TimeOutPosSendMessageService
+    {
+        public readonly static TimeOutPosSendMessageService Instance = new TimeOutPosSendMessageService();
+        private TimeOutPosSendMessageService()
+        { }
+
+        public void Start()
+        {
+            Thread th = new Thread(doSomething);
+            th.IsBackground = true;
+            th.Start();
+        }
+
+        public void doSomething()
+        {
+            while (true)
+            {
+                if (DateTime.Now.Hour < 20)
+                {
+                    try
+                    {
+                        string check = function.ReadInstance("/TimeOutPosSendMessage/check" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt");
+                        if (string.IsNullOrEmpty(check))
+                        {
+                            function.WritePage("/TimeOutPosSendMessage/", "check" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt", DateTime.Now.ToString("HH:mm:ss"));
+                            WebCMSEntities db = new WebCMSEntities();
+                            var date = DateTime.Now.AddDays(-10).ToString("yyyy-MM-dd 00:00:00");//过期限制时间
+                            var time = DateTime.Parse(date);//过期限制时间
+
+                            DataTable dt = CustomerSqlConn.dtable("SELECT BuyUserId FROM PosMachinesTwo WHERE `Status`>-1 AND BuyUserId>0 AND BindingState=0 AND ActivationState=0 AND ScanQrTrade=0 AND RecycEndDate <'" + date + "' GROUP BY BuyUserId", MysqlConn.connstr);//消息推送创客
+                            var query = db.PosMachinesTwo.Where(m => m.Status > -1 && m.BuyUserId > 0 && m.BindingState == 0 && m.ActivationState == 0 && m.ScanQrTrade == 0 && m.RecycEndDate < time).ToList();//循环过期超过10天机具
+                            var brandInfo = db.KqProducts.ToList();
+                            foreach (DataRow item in dt.Rows)
+                            {
+                                int BuyUserId = int.Parse(item["BuyUserId"].ToString());
+                                var BrandName = "";
+                                var PosSn = "";
+                                var SendInfo = "";
+                                foreach (var items in brandInfo)
+                                {
+                                    int BrandId = int.Parse(items.Id.ToString());
+                                    BrandName = items.Name.ToString();
+                                    var posInfo = query.Where(m => m.BuyUserId == BuyUserId && m.BrandId == BrandId);
+                                    foreach (var pos in posInfo)
+                                    {
+                                        PosSn += BrandName +":"+pos.PosSn + "," + "<br/>";
+                                    }
+                                }
+                                SendInfo = PosSn.TrimEnd(',') + "<br/>";
+                                RedisDbconn.Instance.AddList("MsgPersonalQueue", Newtonsoft.Json.JsonConvert.SerializeObject(new MsgPersonal()
+                                {
+                                    UserId = BuyUserId, //创客
+                                    Title = "机具循环过期提醒", //标题
+                                    Content = "<div class='f16'>尊敬的创客您好:<br/>您的" + SendInfo + "循环已过期十天以上,请在五日内完成激活或通过机具回收回寄该机具。</ div > ",//内容
+                                    Summary = "系统检测到您的部分机具可回收,请打开我的-回收机具及时处理!",
+                                    CreateDate = DateTime.Now,
+                                }));
+                            }
+                        }
+                    }
+                    catch (Exception ex)
+                    {
+                        function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "过期机具预扣费消息推送异常");
+                    }
+                }
+                Thread.Sleep(1000);
+            }
+        }
+    }
+}

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

@@ -923,7 +923,7 @@ namespace MySystem.Areas.Admin.Controllers
 
                 //实际押金
                 string SeoKeyword = dic["SeoKeyword"].ToString();
-                if (SeoKeyword.Length > 3)
+                if (SeoKeyword.Length > 2)
                 {
                     SeoKeyword = (decimal.Parse(SeoKeyword) / 100).ToString();
                 }

+ 0 - 30
Areas/Admin/Controllers/MainServer/PosMerchantInfoListController.cs

@@ -177,7 +177,6 @@ namespace MySystem.Areas.Admin.Controllers
 
             Dictionary<string, string> Fields = new Dictionary<string, string>();
 
-            decimal ReturnAmounts = 0.00M;
             string condition = " and Status>-1 and StandardStatus=-2";
             //身份证号
             if (!string.IsNullOrEmpty(MerIdcardNo))
@@ -258,36 +257,7 @@ namespace MySystem.Areas.Admin.Controllers
                 int MerUserType = int.Parse(dic["MerUserType"].ToString());
                 if (MerUserType == 0) dic["MerUserType"] = "非商户型创客";
                 if (MerUserType == 1) dic["MerUserType"] = "商户型创客";
-
-                var KqSnNo = dic["KqSnNo"].ToString();
-                var pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == KqSnNo) ?? new PosMachinesTwo();
-                //实际押金
-                string SeoKeyword = pos.SeoKeyword.ToString();
-                ReturnAmounts += decimal.Parse(function.CheckNum(SeoKeyword));
-                if (SeoKeyword.Length > 3)
-                {
-                    SeoKeyword = (decimal.Parse(SeoKeyword) / 100).ToString();
-                }
-                dic["SeoKeyword"] = SeoKeyword;
-
-                //设置押金
-                string PrizeParams = "0";
-                if (!string.IsNullOrEmpty(pos.PrizeParams))
-                {
-                    PrizeParams = pos.PrizeParams.ToString();
-                }
-                dic["PrizeParams"] = PrizeParams;
             }
-            Dictionary<string, object> other = new Dictionary<string, object>();
-            decimal ReturnAmount = 0.00M;
-            DataTable dt = OtherMySqlConn.dtable("SELECT SUM(Remark) FROM PosMerchantInfo WHERE 1=1" + condition);
-            if (dt.Rows.Count > 0)
-            {
-                ReturnAmount = decimal.Parse(function.CheckNum(dt.Rows[0][0].ToString()));
-            }
-            other.Add("ReturnAmount", ReturnAmount.ToString("f2"));
-            other.Add("ReturnAmounts", ReturnAmounts.ToString("f2"));
-            obj.Add("other", other);
             return Json(obj);
         }
 

+ 16 - 27
Areas/Admin/Views/MainServer/PosMerchantInfoList/Indexrg.cshtml

@@ -4,40 +4,33 @@
 }
 <!DOCTYPE html>
 <html>
-
 <head>
     <meta charset="utf-8">
     <title>人工已退商户列表</title>
     <meta name="renderer" content="webkit">
     <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
-    <meta name="viewport"
-        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
     <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
     <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
     <script src="/admin/js/jquery-1.10.1.min.js"></script>
     <style>
-        .layui-input-inline {
+        .layui-input-inline{
             width: 175px !important;
         }
-
-        .layui-form-label {
+        .layui-form-label{
             width: 85px !important;
         }
-
-        .layui-inline {
+        .layui-inline{
             margin-right: 0px !important;
-        }
-
-        .w100 {
+        }        
+        .w100{
             width: 100px !important;
         }
-
-        .ml50 {
+        .ml50{
             margin-left: 50px !important;
         }
     </style>
 </head>
-
 <body>
     <div class="layui-fluid">
         <div class="layui-card">
@@ -47,28 +40,29 @@
                     <div class="layui-inline">
                         <label class="layui-form-label">身份证号</label>
                         <div class="layui-input-inline">
-                            <input class="layui-input" type="text" name="MerIdcardNo" placeholder="请输入身份证号"
-                                autocomplete="off">
+                            <input class="layui-input" type="text" name="MerIdcardNo" 
+                                placeholder="请输入身份证号" autocomplete="off">
                         </div>
                     </div>
                     <div class="layui-inline">
                         <label class="layui-form-label">商户姓名</label>
                         <div class="layui-input-inline">
-                            <input class="layui-input" type="text" name="MerchantName" placeholder="请输入商户姓名"
-                                autocomplete="off">
+                            <input class="layui-input" type="text" name="MerchantName" 
+                                placeholder="请输入商户姓名" autocomplete="off">
                         </div>
                     </div>
                     <div class="layui-inline">
                         <label class="layui-form-label">手机号</label>
                         <div class="layui-input-inline">
-                            <input class="layui-input" type="text" name="MerchantMobile" placeholder="请输入手机号"
-                                autocomplete="off">
+                            <input class="layui-input" type="text" name="MerchantMobile" 
+                                placeholder="请输入手机号" autocomplete="off">
                         </div>
                     </div>
                     <div class="layui-inline">
                         <label class="layui-form-label">机具号</label>
                         <div class="layui-input-inline">
-                            <input class="layui-input" type="text" name="PosSn" placeholder="请输入机具号" autocomplete="off">
+                            <input class="layui-input" type="text" name="PosSn" 
+                                placeholder="请输入机具号" autocomplete="off">
                         </div>
                     </div>
                     <div class="layui-inline ml50">
@@ -85,9 +79,6 @@
                             </button>
                         }
                     </div>
-                    <blockquote class="layui-elem-quote layui-text">
-                        退押总金额:<span style="color: #f00;" id="ReturnAmounts">0.00</span> | 实际总金额:<span style="color: #f00;" id="ReturnAmount">0.00</span>
-                    </blockquote>
                 </div>
             </div>
 
@@ -98,8 +89,6 @@
     </div>
 
     <script src="/layuiadmin/layui/layui.js"></script>
-    <script
-        src="/layuiadmin/modules_main/PosMerchantInforgList_Admin.js?r=@DateTime.Now.ToString("yyyyMMddHHmmss")"></script>
+    <script src="/layuiadmin/modules_main/PosMerchantInforgList_Admin.js?r=@DateTime.Now.ToString("yyyyMMddHHmmss")"></script>
 </body>
-
 </html>

+ 0 - 4
wwwroot/layuiadmin/modules_main/PosMerchantInforgList_Admin.js

@@ -124,8 +124,6 @@ layui.config({
             , { field: 'MerchantName', width: 200, title: '商户名称', sort: true }
             , { 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: 'Remark', width: 220, title: '已退金额', sort: true }
         ]]
         , where: {
@@ -135,8 +133,6 @@ layui.config({
         , height: 'full-' + String($('.layui-card-header').height() + 130)
         , text: '对不起,加载出现异常!'
         , done: function (res, curr, count) {
-            $("#ReturnAmount").text(res.other.ReturnAmount);
-            $("#ReturnAmounts").text(res.other.ReturnAmounts);
             $(".layui-none").text("无数据");
         }
     });