lcl 2 лет назад
Родитель
Сommit
41b887b1b8

+ 139 - 0
Areas/Admin/Controllers/MainServer/TradeRecordController.cs

@@ -509,6 +509,145 @@ namespace MySystem.Areas.Admin.Controllers
         }
         #endregion
 
+        #region 导入交易数据
+        public IActionResult ImportTrade(string right)
+        {
+            ViewBag.RightInfo = RightInfo;
+            ViewBag.right = right;
+            return View();
+        }
+        /// <summary>
+        /// 导入数据
+        /// </summary>
+        /// <param name="ExcelData"></param>
+        public string ImportTradePost(string ExcelPath)
+        {
+            string FullExcelPath = function.getPath(ExcelPath);
+            FullExcelPath = FullExcelPath.Replace("//", "/");
+            DataTable list = new PublicFunction().ExcelToDataTable(FullExcelPath);
+            foreach (DataRow dr in list.Rows)
+            {
+                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);
+
+                if(CreateDate < DateTime.Now.AddMonths(-3)) op = false;
+                if(OrderStatus == "待激活") op = false;
+                if(UserStatus == "已注销" || UserStatus.Contains("欠费"))
+                {
+                    op = false;
+                    SimposMerchantInfo checkMer = db.SimposMerchantInfo.FirstOrDefault(m => m.KqMerNo == Mobile && m.KqSnNo == SimNo);
+                    if(checkMer != null)
+                    {
+                        checkMer.Status = -1;
+                        if(UserStatus.Contains("欠费"))
+                        {
+                            checkMer.Status = -2;
+                        }
+                        db.SaveChanges();
+                    }
+                }
+                if(UserStatus == "正常")
+                {
+                    SimposMerchantInfo checkMer = db.SimposMerchantInfo.FirstOrDefault(m => m.KqMerNo == Mobile && m.KqSnNo == SimNo);
+                    if(checkMer != null)
+                    {
+                        checkMer.Status = 0;
+                        db.SaveChanges();
+                    }
+                }
+
+                if(TotalAmountNum > 0 && op)
+                {
+                    spdb.TradeRecord.Add(new SpModels.TradeRecord()
+                    {
+                        CreateDate = CreateDate, //创建时间
+                        TradeSerialNo = OrderNo, //订单编号
+                        AgentNo = WorkName + WorkNo, //一级服务商编号
+                        MerNo = Mobile, //商户编
+                        TradeSnNo = SimNo, //sim卡号
+                        ChannelSerial = OrderNo, //请求号
+                        TradeAmount = TotalAmountNum, //账单总金额
+                        TradeStatus = OrderStatus, //订单状态
+                        TradeTime = CreateDate.ToString("yyyyMMdd"),
+                        BankCardType = "01",
+                        TradeType = "01",
+                        ProductType = "14",
+                        Status = 1,
+                        Field1 = ProductName,
+                        Field2 = SourceProductName,
+                        Field3 = ProductType,
+                        Field4 = BusinessType,
+                        SeoDescription = json,
+                    });
+
+                    spdb.SaveChanges();
+                }
+            }
+            AddSysLog("0", "TradeRecord", "Import");
+            return "success";
+        }
+        #endregion
+
         #region 导出Excel
 
         /// <summary>

+ 129 - 0
Areas/Admin/Views/MainServer/TradeRecord/ImportTrade.cshtml

@@ -0,0 +1,129 @@
+@{
+    string RightInfo = ViewBag.RightInfo as string;
+    string right = ViewBag.right as string;
+    string ExcelKind = ViewBag.ExcelKind 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>
+    <style>
+        .layui-form-label{
+            width: 135px !important;
+        }
+        .layui-form-item .layui-input-block{
+            margin-left: 165px !important;
+        }
+    </style>
+</head>
+<body>
+
+    <div class="layui-form" lay-filter="layuiadmin-form-useradmin" id="layuiadmin-form-useradmin">
+        <input type="hidden" name="Kind" value="@ExcelKind" />
+        
+        <div class="layui-card">
+          <div class="layui-card-body">
+            <div class="layui-tab" lay-filter="mytabbar">
+                <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-form-mid layui-word-aux" id="excelTemp">
+                                <a href="https://kexiaoshuang.oss-cn-chengdu.aliyuncs.com/ExcelTmplate/">点击下载入库模版</a>
+                            </div>
+                        </div>
+                        <div class="layui-form-item">
+                            <label class="layui-form-label">excel文件</label>
+                            <div class="layui-input-block">
+                                <div class="layui-upload">
+                                    <input type="hidden" id="ExcelPath" name="ExcelPath" value="">
+                                    <button class="layui-btn" type="button" id="ExcelPathBtn">选择</button>
+                                    <div class="layui-inline layui-word-aux"></div>
+                                </div>
+                                <div class="mt10" id="ExcelPathFile">
+                                </div>
+                            </div>
+                        </div>
+                        
+                    </div>
+
+                </div>
+            </div>
+            <div class="layui-form-item layui-hide">
+                <input type="button" lay-submit lay-filter="LAY-list-front-submit" id="LAY-list-front-submit" value="确认">
+            </div>
+          </div>
+        </div>
+    </div>
+
+    <script src="/layuiadmin/layui/layui.js"></script>
+    <script src="/other/oss/upload-min.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>
+        
+                    
+        //编辑器
+        KindEditor.ready(function (K) {
+            
+        });
+
+        
+        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');
+            });
+    
+            //日期
+            
+
+            //上传文件
+            WebUploadJs('ExcelPathBtn', '@(Library.ConfigurationManager.AppSettings["Database"].ToString())/upload/v2', {width:0,height:0,quality:0},{max_file_size:1048576},  function (filename) {
+                $('#ExcelPathFile').html(filename);
+                $('#ExcelPath').val(filename);
+            });
+
+            //穿梭框
+            
+            
+
+            //TreeView,比如权限管理
+            
+
+            //省市区
+
+        });
+
+    </script>
+</body>
+</html>

+ 18 - 0
wwwroot/layuiadmin/modules_main/TradeRecord_Admin.js

@@ -17,6 +17,24 @@ function ConfirmImport() {
     });
 }
 
+function ConfirmImportTrade() {
+    $.ajax({
+        type: "POST",
+        url: "/Admin/TradeRecord/ImportTrade?r=" + Math.random(1),
+        data: "ExcelData=" + encodeURIComponent(JSON.stringify(ExcelData)),
+        dataType: "text",
+        success: function (data) {
+            if (data == "success") {
+                layer.msg("导入成功", { time: 2000 }, function () {
+                    window.location.reload();
+                });
+            } else {
+                layer.msg(data);
+            }
+        }
+    });
+}
+
 var excel;
 layui.config({
     base: '/layuiadmin/' //静态资源所在路径