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

Merge branch 'feature-dgy-辅助工具直营团队补录' into DuGuYang

DuGuYang 3 лет назад
Родитель
Сommit
79fa31340f

+ 280 - 0
Areas/Admin/Controllers/MainServer/SysToolsController.cs

@@ -590,6 +590,286 @@ namespace MySystem.Areas.Admin.Controllers
             db.SaveChanges();
             return "success";
         }
+
+
+        public IActionResult CheckMachineForTeam1(string right)//直营团队机具补录
+        {
+            ViewBag.RightInfo = RightInfo;
+            ViewBag.right = right;
+
+            return View();
+        }
+
+        [HttpPost]
+        public string CheckMachineForTeam1Do(string MakerCode, string PosSn, int AddActPrize = 0, int IsSend = 0)
+        {
+            if (string.IsNullOrEmpty(MakerCode))
+            {
+                return "请输入创客编号";
+            }
+            if (string.IsNullOrEmpty(PosSn))
+            {
+                return "请输入机具SN";
+            }
+
+            var MerNo = "";
+            PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == PosSn);
+            KqProducts kqProducts = db.KqProducts.FirstOrDefault(m => m.Id == pos.BrandId);
+            if (pos == null)
+            {
+                return "机具SN不存在";
+            }
+            Users user = db.Users.FirstOrDefault(m => m.MakerCode == MakerCode);
+            if (user == null)
+            {
+                return "创客编号不存在";
+            }
+            if (pos.PreUserId > 0)
+            {
+                if (pos.BuyUserId == 0)
+                {
+                    pos.BuyUserId = user.Id;
+                }
+                if (pos.UserId == 0)
+                {
+                    pos.UserId = user.Id;
+                }
+            }
+            if (pos.BindingState == 0)
+            {
+                SpModels.BindRecord bind = spdb.BindRecord.FirstOrDefault(m => m.MerSnNo == PosSn);
+                if (bind != null)
+                {
+                    pos.BindingState = 1;
+                    pos.BindingTime = bind.CreateTime;
+                    db.SaveChanges();
+                    MerNo = bind.MerNo;
+                }
+            }
+            decimal CreditTrade = 0;
+            string BindingTime = pos.BindingTime == null ? DateTime.Now.AddMonths(-1).ToString("yyyyMM") : pos.BindingTime.Value.ToString("yyyyMM");
+            string SpTradeRecordId = function.ReadInstance("/PublicParams/SpTradeRecordId" + BindingTime + ".txt");
+            int StartId = int.Parse(function.CheckInt(SpTradeRecordId));
+            bool check = spdb.TradeRecord.Any(m => m.Id > StartId && m.TradeSnNo == pos.PosSn);
+            if (check)
+            {
+                if (pos.BrandId == 1)
+                {
+                    CreditTrade = spdb.TradeRecord.Where(m => m.Id > StartId && m.TradeSnNo == pos.PosSn && m.ProductType == "1" && m.SerEntryMode != "N" && m.MerNo.StartsWith("M700")).Sum(m => m.TradeAmount) / 100;
+                }
+                else if (pos.BrandId == 2)
+                {
+                    CreditTrade = spdb.TradeRecord.Where(m => m.Id > StartId && m.TradeSnNo == pos.PosSn && m.ProductType == "2").Sum(m => m.TradeAmount);
+                }
+                else if (pos.BrandId == 3)
+                {
+                    CreditTrade = spdb.TradeRecord.Where(m => m.Id > StartId && m.TradeSnNo == pos.PosSn && m.ProductType == "1" && m.SerEntryMode != "N" && m.MerNo.StartsWith("M900")).Sum(m => m.TradeAmount) / 100;
+                }
+                else if (pos.BrandId == 4 || pos.BrandId == 5)
+                {
+                    CreditTrade = spdb.TradeRecord.Where(m => m.Id > StartId && m.TradeSnNo == pos.PosSn && m.ProductType == "4").Sum(m => m.TradeAmount) / 100;
+                }
+                else if (pos.BrandId == 6)
+                {
+                    CreditTrade = spdb.TradeRecord.Where(m => m.Id > StartId && m.TradeSnNo == pos.PosSn && m.ProductType == "6").Sum(m => m.TradeAmount) / 100;
+                }
+                else if (pos.BrandId == 7)
+                {
+                    CreditTrade = spdb.TradeRecord.Where(m => m.Id > StartId && m.TradeSnNo == pos.PosSn && m.ProductType == "7" && m.TradeStatus == "00").Sum(m => m.TradeAmount) / 100;
+                }
+                else if (pos.BrandId == 8)
+                {
+                    CreditTrade = spdb.TradeRecord.Where(m => m.Id > StartId && m.TradeSnNo == pos.PosSn && m.ProductType == "8").Sum(m => m.TradeAmount) / 100;
+                }
+                else if (pos.BrandId == 9)
+                {
+                    CreditTrade = spdb.TradeRecord.Where(m => m.Id > StartId && m.TradeSnNo == pos.PosSn && m.ProductType == "9").Sum(m => m.TradeAmount) / 100;
+                }
+                else if (pos.BrandId == 10 || pos.BrandId == 11)
+                {
+                    CreditTrade = spdb.TradeRecord.Where(m => m.Id > StartId && m.TradeSnNo == pos.PosSn && m.ProductType == "10").Sum(m => m.TradeAmount);
+                }
+                else if (pos.BrandId == 12)
+                {
+                    CreditTrade = spdb.TradeRecord.Where(m => m.Id > StartId && m.TradeSnNo == pos.PosSn && m.ProductType == "12").Sum(m => m.TradeAmount);
+                }
+                pos.CreditTrade = CreditTrade;
+                db.SaveChanges();
+            }
+            if (AddActPrize == 1)
+            {
+                if (pos.BuyUserId == 0)
+                {
+                    return "机具未划拨,无法补录激活奖励";
+                }
+                if (string.IsNullOrEmpty(pos.SeoKeyword) || pos.SeoKeyword == "0")
+                {
+                    bool has = spdb.ActivateRecord.Any(m => m.SnNo == pos.PosSn);
+                    if (has)
+                    {
+                        SpModels.ActivateRecord chkAct = spdb.ActivateRecord.Where(m => m.SnNo == pos.PosSn).OrderByDescending(m => m.Id).FirstOrDefault() ?? new SpModels.ActivateRecord();
+                        pos.SeoKeyword = chkAct.SeoTitle;
+                        db.SaveChanges();
+                    }
+                }
+                if (pos.BindingTime != null && pos.ActivationTime != null)
+                {
+                    // TimeSpan ts = pos.ActivationTime.Value - pos.BindingTime.Value;
+                    // if (ts.TotalDays <= 30 || SysUserName == "admin")
+                    // {
+                    //     AddAct(pos.Id);
+                    // }
+
+                    AddAct(pos.Id);
+                }
+            }
+            decimal CheckMoney = 1000;
+            if (pos.BrandId == 6)
+            {
+                CheckMoney = 5000;
+            }
+            if (pos.BuyUserId > 0)
+            {
+                if (pos.CreditTrade < CheckMoney)
+                {
+                    return "该机具贷记卡累计交易不足" + CheckMoney;
+                }
+                // if (pos.BindingTime != null && pos.ActivationTime != null)
+                // {
+                //     TimeSpan ts = pos.ActivationTime.Value - pos.BindingTime.Value;
+                //     if (ts.TotalDays > 30 && SysUserName != "admin")
+                //     {
+                //         return "机具划拨后已超过30天";
+                //     }
+                // }
+                if (pos.CreditTrade >= CheckMoney && pos.ActivationState == 0)
+                {
+                    pos.ActivationState = 1;
+                    pos.ActivationTime = DateTime.Now;
+                    PosMerchantInfo mer = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId);
+                    if (pos.ActivationState == 1 && mer != null)
+                    {
+                        mer.ActiveStatus = 1;
+                        mer.MerStandardDate = DateTime.Now;
+                    }
+                }
+                else if (pos.CreditTrade >= CheckMoney && pos.ActivationState == 1)
+                {
+                    if (AddActPrize == 1)
+                    {
+                        if (IsSend == 1)
+                        {
+                            RedisDbconn.Instance.AddList("MsgPersonalQueue", Newtonsoft.Json.JsonConvert.SerializeObject(new MsgPersonal()
+                            {
+                                UserId = pos.BuyUserId, //接收创客
+                                MsgType = 2,
+                                Title = "补录成功通知", //标题
+                                Summary = "您的 " + kqProducts.Name + " SN:" + pos.PosSn + "已经成功补录,请查收。",
+                                CreateDate = DateTime.Now,
+
+                            }));
+                        }
+                        return "激活奖励已补录";
+                    }
+                    else
+                    {
+                        return "数据正常,无需补录";
+                    }
+                }
+                db.SaveChanges();
+                return "success";
+            }
+            pos.UserId = user.Id;
+            pos.BuyUserId = user.Id;
+            // if (pos.CreditTrade >= CheckMoney && pos.ActivationState == 0 && (pos.BindingTime > DateTime.Now.AddDays(-30) || SysUserName == "admin"))
+            if (pos.CreditTrade >= CheckMoney && pos.ActivationState == 0)
+            {
+                pos.ActivationState = 1;
+                pos.ActivationTime = DateTime.Now;
+            }
+            PosMerchantInfo merchant = new PosMerchantInfo();
+
+            if (!string.IsNullOrEmpty(MerNo))
+            {
+                merchant = db.PosMerchantInfo.FirstOrDefault(m => m.KqMerNo == MerNo);
+                if (merchant == null)
+                {
+                    int TopUserId = 0;
+                    if (!string.IsNullOrEmpty(user.ParentNav))
+                    {
+                        TopUserId = int.Parse(user.ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
+                    }
+                    SpModels.BindRecord bind = spdb.BindRecord.FirstOrDefault(m => m.MerNo == MerNo);
+                    if (bind == null)
+                    {
+                        return "该机具尚未绑定";
+                    }
+                    SpModels.Merchants Mer = spdb.Merchants.FirstOrDefault(m => m.MerNo == MerNo);
+                    if (Mer == null)
+                    {
+                        return "该机具尚未绑定";
+                    }
+                    PosMerchantInfo add = db.PosMerchantInfo.Add(new PosMerchantInfo()
+                    {
+                        CreateDate = Mer.CreateTime,
+                        UpdateDate = Mer.UpdateTime,
+                        TopUserId = TopUserId,
+                        MerUserType = user.MerchantType,
+                        BrandId = int.Parse(Mer.ProductType),
+                        SnStoreId = pos.StoreId,
+                        SnType = pos.PosSnType,
+                        UserId = user.Id,
+                        MgrName = Mer.AgentName,
+                        MerStatus = 1,
+                        KqSnNo = Mer.SnNo,
+                        KqMerNo = Mer.MerNo,
+                        MerIdcardNo = Mer.MerIdcardNo,
+                        MerRealName = Mer.MerRealName,
+                        MerchantMobile = Mer.MerMobile,
+                        MerchantName = Mer.MerName,
+                        MerchantNo = Mer.MerNo,
+                    }).Entity;
+                    MachineForMerNo forMerNo = db.MachineForMerNo.FirstOrDefault(m => m.MerNo == Mer.MerNo);
+                    if (forMerNo == null)
+                    {
+                        forMerNo = db.MachineForMerNo.Add(new MachineForMerNo()
+                        {
+                            MerNo = Mer.MerNo,
+                            SnId = pos.Id,
+                        }).Entity;
+                    }
+                    else
+                    {
+                        forMerNo.SnId = pos.Id;
+                    }
+                }
+            }
+            else
+            {
+                if (pos.BindMerchantId > 0)
+                {
+                    merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId);
+                }
+                else
+                {
+                    return "找不到机具所属商户";
+                }
+            }
+            merchant.UserId = user.Id;
+            if (pos.ActivationState == 1)
+            {
+                merchant.ActiveStatus = 1;
+                merchant.MerStandardDate = DateTime.Now;
+            }
+            if (pos.BindMerchantId == 0)
+            {
+                pos.BindMerchantId = merchant.Id;
+            }
+            db.SaveChanges();
+            function.WriteLog(DateTime.Now.ToString() + "\n" + SysUserName + "\nMakerCode:" + MakerCode + ", PosSn:" + PosSn + ", MerNo:" + MerNo + ", AddActPrize:" + AddActPrize, "机具补录日志");
+            return "success";
+        }
+
         public void AddAct(int posid = 0)
         {
             WebCMSEntities db = new WebCMSEntities();

+ 278 - 0
Areas/Admin/Views/MainServer/SysTools/CheckMachineForTeam1.cshtml

@@ -0,0 +1,278 @@
+@{
+    string RightInfo = ViewBag.RightInfo as string;
+    string right = ViewBag.right as string;
+
+}
+<!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">
+    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
+    <script src="/admin/js/jquery-1.10.1.min.js"></script>
+    <script src="/admin/js/LAreaData2.js"></script>
+</head>
+
+<body>
+
+    <div class="layui-form" lay-filter="layuiadmin-form-useradmin" id="layuiadmin-form-useradmin">
+        <form class="layui-form" id="confirmFrm">
+            <div class="layui-card">
+                <div class="layui-card-body">
+                    <div class="layui-tab" lay-filter="mytabbar">
+                        <ul class="layui-tab-title">
+                            <li class="layui-this" lay-id="1">基本信息</li>
+                        </ul>
+                        <div class="layui-tab-content mt20">
+                            <div class="layui-tab-item layui-show">
+                                <div class="layui-form-item">
+                                    <label class="layui-form-label">创客编号</label>
+                                    <div class="layui-input-inline">
+                                        <input class="layui-input" type="text" id="MakerCode" name="MakerCode"
+                                            maxlength="10" lay-verify="required|" autocomplete="off"
+                                            placeholder="请输入创客编号">
+                                    </div>
+                                </div>
+                                <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">
+                                    </div>
+                                </div>
+                                @* <div class="layui-form-item">
+                                <label class="layui-form-label">商户编号</label>
+                                <div class="layui-input-inline">
+                                <input class="layui-input" type="text" id="MerNo"
+                                name="MerNo" maxlength="50" autocomplete="off" placeholder="请输入商户编号">
+                                </div>
+                                </div> *@
+                                <div class="layui-form-item">
+                                    <label class="layui-form-label">补激活奖励</label>
+                                    <div class="layui-input-block">
+                                        <input type="checkbox" id="AddActPrize" name="AddActPrize" value="1"
+                                            lay-skin="switch" lay-filter="switchTest" title="开关">
+                                    </div>
+                                </div>
+                                @* <div class="layui-form-item">
+                                <label class="layui-form-label">是否预发机</label>
+                                <div class="layui-input-block">
+                                <input type="checkbox" id="IsPre" name="IsPre" value="1"
+                                lay-skin="switch" lay-filter="switchTest" title="开关">
+                                </div>
+                                </div> *@
+                                <div class="layui-form-item">
+                                    <label class="layui-form-label">是否推送消息</label>
+                                    <div class="layui-input-block">
+                                        <input type="checkbox" id="IsSend" name="IsSend" value="1" lay-skin="switch"
+                                            lay-filter="switchTest" title="开关">
+                                    </div>
+                                </div>
+                            </div>
+
+                        </div>
+                    </div>
+                    <div class="layui-form-item ml10">
+                        <div class="layui-input-block">
+                            <button type="button" class="layui-btn" onclick="save()">提交</button>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </form>
+    </div>
+
+    <script src="/layuiadmin/layui/layui.js"></script>
+    <script
+        src="/other/oss/upload-min@(MySystem.OssHelper.Instance.OssStatus ? "-oss" : "").js?r=@DateTime.Now.ToString("yyyyMMddHHmmss")"></script>
+    <script src="/other/mybjq/kindeditor-min.js"></script>
+    <script src="/other/mybjq/lang/zh_CN.js"></script>
+    <script>
+        var clickflag = 0
+        function save() {
+            var index = layer.load(1, {
+                shade: [0.5, '#000']
+            });
+            var userdata = $("#confirmFrm").serialize();
+            if (clickflag == 0) {
+                clickflag = 1;
+                $.ajax({
+                    type: "POST",
+                    url: "/Admin/SysTools/CheckMachineForTeam1Do?r=" + Math.random(1),
+                    data: userdata,
+                    dataType: "text",
+                    success: function (data) {
+                        clickflag = 0;
+                        layer.close(index); //关闭弹层
+                        if (data == "success") {
+                            layer.msg("补录成功");
+                        } else {
+                            layer.msg(data);
+                        }
+                    }
+                });
+            }
+        }
+
+
+        //编辑器
+        KindEditor.ready(function (K) {
+
+        });
+
+        var ids = "";
+        function getChildren(obj) {
+            $.each(obj, function (index, value) {
+                var id = obj[index].id;
+                ids += id + ",";
+                var children = obj[index].children;
+                if (children) {
+                    getChildren(children);
+                }
+            });
+        }
+
+        function AreasProvinceInit(tagId, areasVal, form) {
+            for (var i = 0; i < provs_data.length; i++) {
+                var sel = "";
+                if (areasVal.indexOf(provs_data[i].text) > -1) {
+                    sel = " selected=selected";
+                }
+                $("#" + tagId + "Province").append('<option value="' + provs_data[i].value + '"' + sel + '>' + provs_data[i].text + '</option>');
+            }
+            form.render();
+        }
+
+        function AreasProvinceSelected(tagId, areasVal, form, value) {
+            $("#" + tagId + "City").html('<option value="">市</option>');
+            var list = citys_data[value];
+            for (var i = 0; i < list.length; i++) {
+                var sel = "";
+                if (areasVal.indexOf(list[i].text) > -1) {
+                    sel = " selected=selected";
+                }
+                $("#" + tagId + "City").append('<option value="' + list[i].value + '"' + sel + '>' + list[i].text + '</option>');
+            }
+            $("#" + tagId + "Area").html('<option value="">县/区</option>');
+            form.render();
+            $("#" + tagId + "").val($("#" + tagId + "Province option:selected").text() + "," + $("#" + tagId + "City option:selected").text() + "," + $("#" + tagId + "Area option:selected").text());
+        }
+
+        function AreasCitySelected(tagId, areasVal, form, value) {
+            $("#" + tagId + "Area").html('<option value="">县/区</option>');
+            var list = dists_data[value];
+            for (var i = 0; i < list.length; i++) {
+                var sel = "";
+                if (areasVal.indexOf(list[i].text) > -1) {
+                    sel = " selected=selected";
+                }
+                $("#" + tagId + "Area").append('<option value="' + list[i].value + '"' + sel + '>' + list[i].text + '</option>');
+            }
+            form.render();
+            $("#" + tagId + "").val($("#" + tagId + "Province option:selected").text() + "," + $("#" + tagId + "City option:selected").text() + "," + $("#" + tagId + "Area option:selected").text());
+        }
+
+        function AreasAreaSelected(tagId, form) {
+            form.render();
+            $("#" + tagId + "").val($("#" + tagId + "Province option:selected").text() + "," + $("#" + tagId + "City option:selected").text() + "," + $("#" + tagId + "Area option:selected").text());
+        }
+        function movePrev(obj, tagId) {
+            $(obj).parent().prev().insertAfter($(obj).parent());
+            checkPics(tagId);
+        }
+        function moveNext(obj, tagId) {
+            $(obj).parent().next().insertBefore($(obj).parent());
+            checkPics(tagId);
+        }
+        function deletePic(obj, tagId) {
+            $(obj).parent().remove();
+            checkPics(tagId);
+        }
+        function checkPics(tagId) {
+            var pics = "";
+            var texts = "";
+            $("#" + tagId + "Image div img").each(function (i) {
+                pics += $(this).attr("src").replace(osshost, '') + "|";
+            });
+            $("#" + tagId + "Image div input").each(function (i) {
+                texts += $(this).val() + "|";
+            });
+            if (pics == "") {
+                $("#" + tagId).val("");
+            } else {
+                pics = pics.substring(0, pics.length - 1);
+                texts = texts.substring(0, pics.length - 1);
+                $("#" + tagId).val(pics + "#cut#" + texts);
+            }
+        }
+        function checkBox(tagId) {
+            var text = "";
+            $("input[type=checkbox][name=" + tagId + "List]:checked").each(function (i) {
+                text += $(this).val() + ",";
+            });
+            $("#" + tagId).val(text);
+        }
+        function showBigPic(picpath) {
+            parent.layer.open({
+                type: 1,
+                title: false,
+                closeBtn: 0,
+                shadeClose: true,
+                area: ['auto', 'auto'],
+                content: '<img src="' + picpath + '" style="max-width:800px; max-height:800px;" />'
+            });
+        }
+
+
+        var tree;
+        var element;
+        var upload;
+        layui.config({
+            base: '/layuiadmin/' //静态资源所在路径
+        }).extend({
+            index: 'lib/index' //主入口模块
+        }).use(['index', 'form', 'upload', 'layedit', 'laydate', 'element', 'croppers', 'transfer', 'tree', 'util'], function () {
+            var $ = layui.$
+                , form = layui.form
+                , layer = layui.layer
+                , layedit = layui.layedit
+                , laydate = layui.laydate
+                , croppers = layui.croppers
+                , transfer = layui.transfer
+                , util = layui.util;
+            tree = layui.tree;
+            element = layui.element;
+            upload = layui.upload;
+
+            //Hash地址的定位
+            var layid = location.hash.replace(/^#test=/, '');
+            element.tabChange('test', layid);
+            element.on('tab(test)', function (elem) {
+                location.hash = 'test=' + $(this).attr('lay-id');
+            });
+
+            //日期
+
+
+            //上传文件
+
+
+            //穿梭框
+
+
+            //TreeView,比如权限管理
+
+
+            //省市区
+
+        })
+
+    </script>
+</body>
+
+</html>