DuGuYang 1 년 전
부모
커밋
7501436764

+ 9 - 5
Areas/Api/Controllers/v1/MainServer/ConsumersController.cs

@@ -33,7 +33,7 @@ namespace MySystem.Areas.Api.Controllers.v1
             Dictionary<string, object> Obj = AmountInfoDo(value);
             return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
         }
-        private Dictionary<string, object> AmountInfoDo(string value)
+        public Dictionary<string, object> AmountInfoDo(string value)
         {
             JsonData data = JsonMapper.ToObject(value);
             string OpenId = data["OpenId"].ToString(); //微信或支付宝Id
@@ -41,10 +41,12 @@ namespace MySystem.Areas.Api.Controllers.v1
             if (Kind == 1)
             {
                 OpenId = AlipayMiniOpenIdDo(OpenId);
+                // OpenId = "okuWn5fKbcHEiYJRtKZQT8iF5W1Y";
             }
             if (Kind == 2)
             {
-                OpenId = WeChatMiniOpenIdDo(OpenId);
+                OpenId = AlipayMiniOpenIdDo(OpenId);
+                // OpenId = "okuWn5fKbcHEiYJRtKZQT8iF5W1Y";
             }
             Dictionary<string, object> Obj = new Dictionary<string, object>();
             var HeadPhoto = "";
@@ -52,8 +54,8 @@ namespace MySystem.Areas.Api.Controllers.v1
             var TotalAmount = 0.00M;
             var Amount = 0.00M;
             var Amount2 = 0.00M;
-            var consumer = Services.Main.ConsumersService.Query(" and WechatOpenId=" + OpenId + "");
-            var consumer2 = Services.Main2.ConsumersService.Query(" and WechatOpenId=" + OpenId + "");
+            var consumer = Services.Main.ConsumersService.Query(" and WechatOpenId='" + OpenId + "'");
+            var consumer2 = Services.Main2.ConsumersService.Query(" and WechatOpenId='" + OpenId + "'");
             Amount = Services.Main.ConsumerProfitService.Sum(" and ConsumerId=" + consumer.Id + "", "GetMoney");
             Amount2 = Services.Main.ConsumerProfitService.Sum(" and ConsumerId=" + consumer.Id + "", "GetMoney");
             TotalAmount = Amount + Amount2;
@@ -95,10 +97,12 @@ namespace MySystem.Areas.Api.Controllers.v1
             if (Kind == 1)
             {
                 OpenId = AlipayMiniOpenIdDo(OpenId);
+                // OpenId = "okuWn5fKbcHEiYJRtKZQT8iF5W1Y";
             }
             if (Kind == 2)
             {
-                OpenId = WeChatMiniOpenIdDo(OpenId);
+                OpenId = AlipayMiniOpenIdDo(OpenId);
+                // OpenId = "okuWn5fKbcHEiYJRtKZQT8iF5W1Y";
             }
             Dictionary<string, object> Obj = new Dictionary<string, object>();
             var consumer = maindb.Consumers.FirstOrDefault(m => m.WechatOpenId == OpenId) ?? new Consumers();

+ 63 - 25
Areas/Api/Controllers/v1/MainServer/MerchantInfoController.cs

@@ -8,6 +8,7 @@ using Microsoft.Extensions.Logging;
 using Microsoft.Extensions.Options;
 using Microsoft.AspNetCore.Authorization;
 using MySystem.MainModels;
+using MySystem.Services;
 using LitJson;
 using Library;
 
@@ -21,34 +22,39 @@ namespace MySystem.Areas.Api.Controllers.v1
         {
         }
 
-
         #region 首页-首页-商户门店信息-列表
-        [Authorize]
+        // [Authorize]
         public JsonResult MerchantInfoList(string value)
         {
             value = DesDecrypt(value);
             JsonData data = JsonMapper.ToObject(value);
-            List<Dictionary<string, object>> dataList = MerchantInfoListDo(value);
-            return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
+            Dictionary<string, object> Other = new Dictionary<string, object>();
+            List<Dictionary<string, object>> dataList = MerchantInfoListDo(value, out Other);
+            return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList, Other = Other });
         }
-        private List<Dictionary<string, object>> MerchantInfoListDo(string value)
+        private List<Dictionary<string, object>> MerchantInfoListDo(string value, out Dictionary<string, object> Other)
         {
             JsonData data = JsonMapper.ToObject(value);
             string Area = data["Area"].ToString(); //地区
             var Longitude = function.CheckNum(data["Longitude"].ToString()); //经度
             var Latitude = function.CheckNum(data["Latitude"].ToString()); //纬度
+            string SearchKey = data["SearchKey"].ToString(); //搜索关键词
             int Sort = int.Parse(data["Sort"].ToString()); //排序(1 人气值降序 2 距离升序)
             int pageSize = int.Parse(function.CheckInt(data["page_size"].ToString()));
             int pageNum = int.Parse(function.CheckInt(data["page_num"].ToString()));
             string condition = " WHERE 1=1";
             if (!string.IsNullOrEmpty(data["Area"].ToString()))
             {
-                condition += " AND s.Area=" + Area;
+                condition += " AND s.Areas like '%" + Area + "%'";
             }
             if (!string.IsNullOrEmpty(data["Sort"].ToString()))
             {
-                if (Sort == 1) condition += " AND ORDER BY s.Popularity DESC";
-                if (Sort == 2) condition += " AND ORDER BY s.distance";
+                if (Sort == 1) condition += " ORDER BY s.Popularity DESC";
+                if (Sort == 2) condition += " ORDER BY s.distance";
+            }
+            if (!string.IsNullOrEmpty(data["SearchKey"].ToString()))
+            {
+                condition += " AND s.Name like '%" + SearchKey + "%'";
             }
             string limitString = " LIMIT " + pageSize;
             if (pageNum > 1)
@@ -58,18 +64,24 @@ namespace MySystem.Areas.Api.Controllers.v1
             }
             condition += limitString;
             List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
-            DataTable dt = CustomerSqlConn.dtable("SELECT DISTINCT s.Name,s.Id,s.Kind,s.Areas,s.Address,s.Popularity,s.Longitude,s.Latitude,s.ServicePhone,s.CertMerchantName,s.MerchantShortname,s.StoreEntrancePic,s.BusinessName,s.distance FROM(SELECT aa.*, FORMAT(ST_DISTANCE(POINT(aa.Longitude, aa.Latitude), POINT(" + Longitude + ", " + Latitude + ")),2) AS distance FROM (SELECT a.Id,1 Kind,,a.Name,a.Areas,a.Address,a.Popularity,a.Longitude,a.Latitude,b.ServicePhone,b.CertMerchantName,b.MerchantShortname,b.StoreEntrancePic,b.QualificationType BusinessName FROM(SELECT Id,Name,Areas,Address,Popularity,Longitude,Latitude,Mobile FROM QrCodePlateMainServer.MerchantInfo WHERE IsAct=1 AND (Status=2 OR QueryCount=2))a LEFT JOIN (SELECT Id,ServicePhone,CertMerchantName,MerchantShortname,StoreEntrancePic,SalesScenesType,Qualifications,QualificationType,BizAddressCode,BizStoreAddress FROM QrCodePlateMainServer.MerchantAddInfo)b ON a.Id=b.Id UNION ALL SELECT a.Id,2 Kind,,a.Name,a.Areas,a.Address,a.Popularity,a.Longitude,a.Latitude,b.ServicePhone,b.CertMerchantName,b.MerchantShortname,b.StoreEntrancePic,c.Name BusinessName FROM(SELECT Id,Name,Areas,Address,Popularity,Longitude,Latitude,Mobile FROM QrCodePlateMainServer2.MerchantInfo WHERE IsAct=1 AND (Status=2 OR QueryCount=2))a LEFT JOIN (SELECT Id,ServicePhone,CertMerchantName,MerchantShortname,StoreEntrancePic,BusinessId,BizAddressCode,BizStoreAddress FROM QrCodePlateMainServer2.MerchantAddInfo)b ON a.Id=b.Id LEFT JOIN (SELECT * FROM BusinessScope)c ON b.BusinessId=c.Id)aa)s" + condition, AppConfig.Base.SqlConnStr);
+            DataTable dt = CustomerSqlConn.dtable("SELECT DISTINCT s.Name,s.Id,s.Kind,s.Areas,s.Address,s.Popularity,s.Longitude,s.Latitude,s.ServicePhone,s.CertMerchantName,s.MerchantShortname,s.StoreEntrancePic,s.BusinessName,s.distance FROM(SELECT aa.*, FORMAT(ST_DISTANCE(POINT(aa.Longitude, aa.Latitude), POINT(" + Longitude + ", " + Latitude + ")),2) AS distance FROM (SELECT a.Id,1 Kind,a.Name,a.Areas,a.Address,a.Popularity,a.Longitude,a.Latitude,b.ServicePhone,b.CertMerchantName,b.MerchantShortname,b.StoreEntrancePic,b.QualificationType BusinessName FROM(SELECT Id,Name,Areas,Address,Popularity,Longitude,Latitude,Mobile FROM QrCodePlateMainServer.MerchantInfo WHERE IsAct=1 AND (Status=2 OR QueryCount=2))a LEFT JOIN (SELECT Id,ServicePhone,CertMerchantName,MerchantShortname,StoreEntrancePic,SalesScenesType,Qualifications,QualificationType,BizAddressCode,BizStoreAddress FROM QrCodePlateMainServer.MerchantAddInfo)b ON a.Id=b.Id UNION ALL SELECT a.Id,2 Kind,a.Name,a.Areas,a.Address,a.Popularity,a.Longitude,a.Latitude,b.ServicePhone,b.CertMerchantName,b.MerchantShortname,b.StoreEntrancePic,c.Name BusinessName FROM(SELECT Id,Name,Areas,Address,Popularity,Longitude,Latitude,Mobile FROM QrCodePlateMainServer2.MerchantInfo WHERE IsAct=1 AND (Status=2 OR QueryCount=2))a LEFT JOIN (SELECT Id,ServicePhone,CertMerchantName,MerchantShortname,StoreEntrancePic,BusinessId,BizAddressCode,BizStoreAddress FROM QrCodePlateMainServer2.MerchantAddInfo)b ON a.Id=b.Id LEFT JOIN (SELECT * FROM BusinessScope)c ON b.BusinessId=c.Id)aa)s" + condition, AppConfig.Base.SqlConnStr);
             foreach (DataRow dr in dt.Rows)
             {
                 Dictionary<string, object> curData = new Dictionary<string, object>();
                 var Kind = int.Parse(dr["Kind"].ToString()); //商户类型(1 直连 2 银联)
                 string[] StoreEntrancePic = dr["StoreEntrancePic"].ToString().Split(',');
+                curData.Add("Id", int.Parse(dr["Id"].ToString())); //商户Id
                 curData.Add("Kind", Kind); //商户类型(1 直连 2 银联)
+                curData.Add("MerchantName", dr["Name"].ToString()); //商户名称
+                curData.Add("BusinessName", dr["BusinessName"].ToString()); //经营类型
                 curData.Add("StoreEntrancePic", StoreEntrancePic[0]); //门店门头照片
                 curData.Add("BizStoreAddress", dr["Areas"].ToString() + dr["Address"].ToString()); //门店地址
                 curData.Add("Popularity", dr["Popularity"].ToString()); //人气值
                 curData.Add("Distance", dr["distance"].ToString()); //距离
+                dataList.Add(curData);
             }
+            Other = new Dictionary<string, object>();
+            Other.Add("count", dt.Rows.Count);
             return dataList;
         }
         #endregion
@@ -89,28 +101,54 @@ namespace MySystem.Areas.Api.Controllers.v1
             JsonData data = JsonMapper.ToObject(value);
             int Id = int.Parse(data["Id"].ToString()); //商户Id
             int Kind = int.Parse(data["Kind"].ToString()); //商户类型(1 直连 2 银联)
-            MerchantAddInfo merAddInfo = new MerchantAddInfo();
-            MerchantInfo merInfo = new MerchantInfo();
+            Dictionary<string, object> Obj = new Dictionary<string, object>();
+            var BusinessName = "";
             if (Kind == 1)
             {
-                merAddInfo = Services.Main.MerchantAddInfoService.Query(Id);
-                merInfo = Services.Main.MerchantInfoService.Query(Id);
+                var merAddInfo = Services.Main.MerchantAddInfoService.Query(Id);
+                var merInfo = Services.Main.MerchantInfoService.Query(Id);
+                BusinessName = merAddInfo.QualificationType;
+
+                string[] Atlas = new string[0];
+                if (!string.IsNullOrEmpty(merAddInfo.StoreEntrancePic))
+                {
+                    Atlas = merAddInfo.StoreEntrancePic.Split(',');
+                }
+                Obj.Add("Atlas", Atlas); //图集
+                Obj.Add("MerchantName", merInfo.Name); //商户名称
+                Obj.Add("Popularity", merInfo.Popularity); //人气值
+                Obj.Add("BusinessName", BusinessName); //经营类型
+                Obj.Add("BusinessHours", merInfo.BusinessHours == null ? "周一至周五 09:00-22:00" : "周一至周五 09:00 - 22:00"); //营业时间
+                Obj.Add("MerchantMobile", merInfo.Mobile); //商户电话
+                Obj.Add("Introduction", merInfo.BriefIntroduction == null ? "待完善..." : "待完善..."); //商户简介
+                Obj.Add("Longitude", merInfo.Longitude); //经度
+                Obj.Add("Latitude", merInfo.Latitude); //纬度
+                Obj.Add("StoreEntrancePic", Atlas[0]); //门店门头照片
+                Obj.Add("BizStoreAddress", merInfo.Areas + merInfo.Address); //门店地址
             }
             if (Kind == 2)
             {
-                merAddInfo = Services.Main.MerchantAddInfoService.Query(Id);
-                merInfo = Services.Main.MerchantInfoService.Query(Id);
+                var merAddInfo = Services.Main2.MerchantAddInfoService.Query(Id);
+                var merInfo = Services.Main2.MerchantInfoService.Query(Id);
+                BusinessName = Services.Main2.BusinessScopeService.Query(merAddInfo.BusinessId).Name;
+
+                string[] Atlas = new string[0];
+                if (!string.IsNullOrEmpty(merAddInfo.StoreEntrancePic))
+                {
+                    Atlas = merAddInfo.StoreEntrancePic.Split(',');
+                }
+                Obj.Add("Atlas", Atlas); //图集
+                Obj.Add("MerchantName", merInfo.Name); //商户名称
+                Obj.Add("Popularity", merInfo.Popularity); //人气值
+                Obj.Add("BusinessName", BusinessName); //经营类型
+                Obj.Add("BusinessHours", merInfo.BusinessHours == null ? "周一至周五 09:00-22:00" : "周一至周五 09:00 - 22:00"); //营业时间
+                Obj.Add("MerchantMobile", merInfo.Mobile); //商户电话
+                Obj.Add("Introduction", merInfo.BriefIntroduction == null ? "待完善..." : "待完善..."); //商户简介
+                Obj.Add("Longitude", merInfo.Longitude); //经度
+                Obj.Add("Latitude", merInfo.Latitude); //纬度
+                Obj.Add("StoreEntrancePic", Atlas[0]); //门店门头照片
+                Obj.Add("BizStoreAddress", merInfo.Areas + merInfo.Address); //门店地址
             }
-            Dictionary<string, object> Obj = new Dictionary<string, object>();
-            var Atlas = merAddInfo.StoreEntrancePic.Split(',');
-            Obj.Add("Atlas", Atlas); //图集
-            Obj.Add("BusinessHours", merInfo.BusinessHours == null ? "周一至周五 09:00-22:00" : "周一至周五 09:00 - 22:00"); //营业时间
-            Obj.Add("MerchantMobile", merInfo.Mobile); //商户电话
-            Obj.Add("Introduction", merInfo.BriefIntroduction == null ? "暂无..." : "暂无..."); //商户简介
-            Obj.Add("Longitude", merInfo.Longitude); //经度
-            Obj.Add("Latitude", merInfo.Latitude); //纬度
-            Obj.Add("StoreEntrancePic", merAddInfo.StoreEntrancePic); //门店门头照片
-            Obj.Add("BizStoreAddress", merInfo.Areas + merInfo.Address); //门店地址
 
             return Obj;
         }

+ 319 - 0
Services/Main/BusinessScopeService.cs

@@ -0,0 +1,319 @@
+/*
+ * 经营类型
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Data;
+using MySystem.MainModels;
+using Library;
+using LitJson;
+
+namespace MySystem.Services.Main
+{
+    public class BusinessScopeService
+    {
+        static string _conn = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
+
+        /// <summary>
+        /// 查询列表(适合多表关联查询)
+        /// </summary>
+        /// <param name="relationData">关联表</param>
+        /// <param name="condition">查询条件(sql语句)</param>
+        /// <param name="count">总数(输出)</param>
+        /// <param name="page">页码</param>
+        /// <param name="limit">每页条数</param>
+        /// <returns></returns>
+        public static List<Dictionary<string, object>> List(List<RelationData> relationData, string condition, out int count, int page = 1, int limit = 30, string orderBy = "Sort desc,Id desc")
+        {
+            List<string> fields = new List<string>(); //要显示的列,不设置则返回全部字段
+            Dictionary<string, object> obj = new DbServiceNew(AppConfig.Base.mainTables, _conn).IndexData("BusinessScope", relationData, orderBy, page, limit, condition, fields);
+            List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
+            count = int.Parse(obj["count"].ToString());
+            return diclist;
+        }
+        public static List<Dictionary<string, object>> List(List<RelationData> relationData, string condition, int page = 1, int limit = 30, string orderBy = "Sort desc,Id desc")
+        {
+            List<string> fields = new List<string>(); //要显示的列,不设置则返回全部字段
+            Dictionary<string, object> obj = new DbServiceNew(AppConfig.Base.mainTables, _conn).IndexData("BusinessScope", relationData, orderBy, page, limit, condition, fields);
+            List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
+            return diclist;
+        }
+
+        /// <summary>
+        /// 查询列表(单表)
+        /// </summary>
+        /// <param name="fieldList">返回的字段</param>
+        /// <param name="condition">查询条件</param>
+        /// <param name="page">页码</param>
+        /// <param name="limit">每页条数</param>
+        /// <param name="orderBy">排序</param>
+        /// <returns></returns>
+        public static List<Dictionary<string, object>> List(string fieldList, string condition, int page = 1, int limit = 30, string orderBy = "Sort desc,Id desc")
+        {
+            List<string> fields = fieldList.Split(',').ToList(); //要显示的列
+            Dictionary<string, object> obj = new DbServiceNew(AppConfig.Base.mainTables, _conn).IndexData("BusinessScope", new List<RelationData>(), orderBy, page, limit, condition, fields);
+            List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
+            return diclist;
+        }
+
+        /// <summary>
+        /// 查询一条记录
+        /// </summary>
+        /// <param name="Id">主键Id</param>
+        /// <returns></returns>
+        public static BusinessScope Query(int Id)
+        {
+            Dictionary<string, object> obj = new DbServiceNew(AppConfig.Base.mainTables, _conn).Query("*", "BusinessScope", Id);
+            if (obj.Keys.Count > 0)
+            {
+                return Newtonsoft.Json.JsonConvert.DeserializeObject<BusinessScope>(Newtonsoft.Json.JsonConvert.SerializeObject(obj));
+            }
+            return new BusinessScope();
+        }
+
+        /// <summary>
+        /// 查询一条记录
+        /// </summary>
+        /// <param name="condition">查询条件(sql语句)</param>
+        /// <returns></returns>
+        public static BusinessScope Query(string condition)
+        {
+            Dictionary<string, object> obj = new DbServiceNew(AppConfig.Base.mainTables, _conn).Query("*", "BusinessScope", condition);
+            if (obj.Keys.Count > 0)
+            {
+                return Newtonsoft.Json.JsonConvert.DeserializeObject<BusinessScope>(Newtonsoft.Json.JsonConvert.SerializeObject(obj));
+            }
+            return new BusinessScope();
+        }
+
+        /// <summary>
+        /// 查询一条记录
+        /// </summary>
+        /// <param name="condition">查询条件(sql语句)</param>
+        /// <param name="fields">返回的字段</param>
+        /// <returns></returns>
+        public static Dictionary<string, object> Query(string condition, string fields)
+        {
+            Dictionary<string, object> obj = new DbServiceNew(AppConfig.Base.mainTables, _conn).Query(fields, "BusinessScope", condition);
+            return obj;
+        }
+
+        public static decimal Sum(string condition, string field)
+        {
+            decimal amount = 0;
+            Dictionary<string, object> obj = new DbServiceNew(AppConfig.Base.mainTables, _conn).Query("Sum(" + field + ") " + field + "", "BusinessScope", condition);
+            if (obj.Keys.Count > 0)
+            {
+                amount = decimal.Parse(function.CheckNum(obj[field].ToString()));
+            }
+            return amount;
+        }
+
+        /// <summary>
+        /// 查询记录数
+        /// </summary>
+        /// <param name="Id">主键Id</param>
+        /// <returns></returns>
+        public static int Count(string condition = "", string field = "Id")
+        {
+            int result = 0;
+            Dictionary<string, object> obj = new DbServiceNew(AppConfig.Base.mainTables, _conn).Query("count(" + field + ") " + field + "", "BusinessScope", condition);
+            if (obj.Keys.Count > 0)
+            {
+                result = int.Parse(function.CheckInt(obj[field].ToString()));
+            }
+            return result;
+        }
+
+        /// <summary>
+        /// 查询是否存在
+        /// </summary>
+        /// <param name="Id">主键Id</param>
+        /// <returns></returns>
+        public static bool Exist(string condition)
+        {
+            Dictionary<string, object> obj = new DbServiceNew(AppConfig.Base.mainTables, _conn).Query("1", "BusinessScope", condition);
+            if (obj.Keys.Count > 0)
+            {
+                return true;
+            }
+            return false;
+        }
+
+        /// <summary>
+        /// 添加数据
+        /// </summary>
+        /// <param name="Fields">要设置的字段</param>
+        /// <returns></returns>
+        public static AppResultJson Add(Dictionary<string, object> fields, bool check = true)
+        {
+            if (check)
+            {
+                if (string.IsNullOrEmpty(fields["Name"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写名称" };
+                }
+                if (string.IsNullOrEmpty(fields["Mobile"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写手机号" };
+                }
+                if (string.IsNullOrEmpty(fields["ActivationStatus"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写激活状态" };
+                }
+                if (string.IsNullOrEmpty(fields["ActMaxAmount"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写活动应返金额" };
+                }
+                if (!function.IsNum(fields["ActMaxAmount"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写正确的活动应返金额" };
+                }
+                if (string.IsNullOrEmpty(fields["ActCurrentAmount"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写活动已返金额" };
+                }
+                if (!function.IsNum(fields["ActCurrentAmount"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写正确的活动已返金额" };
+                }
+                if (!function.IsInt(fields["IsAct"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写正确的商户激活标记" };
+                }
+                if (!function.IsInt(fields["ExamineStatus"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写正确的服务费考核状态" };
+                }
+                if (!function.IsInt(fields["Months"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写正确的达标月数" };
+                }
+
+            }
+            int Id = new DbServiceNew(AppConfig.Base.mainTables, _conn).Add("BusinessScope", fields, 0);
+            return new AppResultJson() { Status = "1", Data = Id };
+        }
+
+        /// <summary>
+        /// 修改数据
+        /// </summary>
+        /// <param name="Fields">要设置的字段</param>
+        /// <param name="Id">主键Id</param>
+        public static AppResultJson Edit(Dictionary<string, object> fields, int Id, bool check = true)
+        {
+            if (check)
+            {
+                if (string.IsNullOrEmpty(fields["Name"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写名称" };
+                }
+                if (string.IsNullOrEmpty(fields["Mobile"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写手机号" };
+                }
+                if (string.IsNullOrEmpty(fields["ActivationStatus"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写激活状态" };
+                }
+                if (string.IsNullOrEmpty(fields["ActMaxAmount"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写活动应返金额" };
+                }
+                if (!function.IsNum(fields["ActMaxAmount"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写正确的活动应返金额" };
+                }
+                if (string.IsNullOrEmpty(fields["ActCurrentAmount"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写活动已返金额" };
+                }
+                if (!function.IsNum(fields["ActCurrentAmount"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写正确的活动已返金额" };
+                }
+                if (!function.IsInt(fields["IsAct"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写正确的商户激活标记" };
+                }
+                if (!function.IsInt(fields["ExamineStatus"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写正确的服务费考核状态" };
+                }
+                if (!function.IsInt(fields["Months"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写正确的达标月数" };
+                }
+
+            }
+            new DbServiceNew(AppConfig.Base.mainTables, _conn).Edit("BusinessScope", fields, Id);
+            return new AppResultJson() { Status = "1", Data = Id };
+        }
+
+        /// <summary>
+        /// 逻辑删除
+        /// </summary>
+        /// <param name="Id">主键Id</param>
+        public static void Remove(int Id)
+        {
+            Dictionary<string, object> fields = new Dictionary<string, object>();
+            fields.Add("Status", -1);
+            new DbServiceNew(AppConfig.Base.mainTables, _conn).Edit("BusinessScope", fields, Id);
+        }
+
+        /// <summary>
+        /// 删除数据
+        /// </summary>
+        /// <param name="Id">主键Id</param>
+        public static void Delete(int Id)
+        {
+            new DbServiceNew(AppConfig.Base.mainTables, _conn).Delete("BusinessScope", Id);
+        }
+
+        /// <summary>
+        /// 排序
+        /// </summary>
+        /// <param name="Id">主键Id</param>
+        /// <param name="Sort">排序序号</param>
+        public static void Sort(int Id, int Sort)
+        {
+            new DbServiceNew(AppConfig.Base.mainTables, _conn).Sort("BusinessScope", Sort, Id);
+        }
+
+        /// <summary>
+        /// 导入数据
+        /// </summary>
+        /// <param name="ExcelData">json数据</param>
+        public static void Import(string ExcelData)
+        {
+            // WebCMSEntities db = new WebCMSEntities();
+            // JsonData list = JsonMapper.ToObject(ExcelData);
+            // for (int i = 1; i < list.Count;i++ )
+            // {
+            //     JsonData dr = list[i];
+
+            //     db.BusinessScope.Add(new BusinessScope()
+            //     {
+            //         CreateDate = DateTime.Now,
+            //         UpdateDate = DateTime.Now,
+
+            //     });
+            //     db.SaveChanges();
+            // }
+            // db.Dispose();
+        }
+
+        /// <summary>
+        /// 导出excel表格
+        /// </summary>
+        /// <param name="fields">查询条件(单个字段)</param>
+        /// <param name="condition">查询条件(sql语句)</param>
+        /// <returns></returns>
+        // public static void ExportExcel(List<RelationData> relationData, string condition)
+        // {
+
+        // }
+    }
+}

+ 319 - 0
Services/Main2/BusinessScopeService.cs

@@ -0,0 +1,319 @@
+/*
+ * 经营类型
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Data;
+using MySystem.MainModels2;
+using Library;
+using LitJson;
+
+namespace MySystem.Services.Main2
+{
+    public class BusinessScopeService
+    {
+        static string _conn = ConfigurationManager.AppSettings["SqlConnStr2"].ToString();
+
+        /// <summary>
+        /// 查询列表(适合多表关联查询)
+        /// </summary>
+        /// <param name="relationData">关联表</param>
+        /// <param name="condition">查询条件(sql语句)</param>
+        /// <param name="count">总数(输出)</param>
+        /// <param name="page">页码</param>
+        /// <param name="limit">每页条数</param>
+        /// <returns></returns>
+        public static List<Dictionary<string, object>> List(List<RelationData> relationData, string condition, out int count, int page = 1, int limit = 30, string orderBy = "Sort desc,Id desc")
+        {
+            List<string> fields = new List<string>(); //要显示的列,不设置则返回全部字段
+            Dictionary<string, object> obj = new DbServiceNew(AppConfig.Base.main2Tables, _conn).IndexData("BusinessScope", relationData, orderBy, page, limit, condition, fields);
+            List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
+            count = int.Parse(obj["count"].ToString());
+            return diclist;
+        }
+        public static List<Dictionary<string, object>> List(List<RelationData> relationData, string condition, int page = 1, int limit = 30, string orderBy = "Sort desc,Id desc")
+        {
+            List<string> fields = new List<string>(); //要显示的列,不设置则返回全部字段
+            Dictionary<string, object> obj = new DbServiceNew(AppConfig.Base.main2Tables, _conn).IndexData("BusinessScope", relationData, orderBy, page, limit, condition, fields);
+            List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
+            return diclist;
+        }
+
+        /// <summary>
+        /// 查询列表(单表)
+        /// </summary>
+        /// <param name="fieldList">返回的字段</param>
+        /// <param name="condition">查询条件</param>
+        /// <param name="page">页码</param>
+        /// <param name="limit">每页条数</param>
+        /// <param name="orderBy">排序</param>
+        /// <returns></returns>
+        public static List<Dictionary<string, object>> List(string fieldList, string condition, int page = 1, int limit = 30, string orderBy = "Sort desc,Id desc")
+        {
+            List<string> fields = fieldList.Split(',').ToList(); //要显示的列
+            Dictionary<string, object> obj = new DbServiceNew(AppConfig.Base.main2Tables, _conn).IndexData("BusinessScope", new List<RelationData>(), orderBy, page, limit, condition, fields);
+            List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
+            return diclist;
+        }
+
+        /// <summary>
+        /// 查询一条记录
+        /// </summary>
+        /// <param name="Id">主键Id</param>
+        /// <returns></returns>
+        public static BusinessScope Query(int Id)
+        {
+            Dictionary<string, object> obj = new DbServiceNew(AppConfig.Base.main2Tables, _conn).Query("*", "BusinessScope", Id);
+            if (obj.Keys.Count > 0)
+            {
+                return Newtonsoft.Json.JsonConvert.DeserializeObject<BusinessScope>(Newtonsoft.Json.JsonConvert.SerializeObject(obj));
+            }
+            return new BusinessScope();
+        }
+
+        /// <summary>
+        /// 查询一条记录
+        /// </summary>
+        /// <param name="condition">查询条件(sql语句)</param>
+        /// <returns></returns>
+        public static BusinessScope Query(string condition)
+        {
+            Dictionary<string, object> obj = new DbServiceNew(AppConfig.Base.main2Tables, _conn).Query("*", "BusinessScope", condition);
+            if (obj.Keys.Count > 0)
+            {
+                return Newtonsoft.Json.JsonConvert.DeserializeObject<BusinessScope>(Newtonsoft.Json.JsonConvert.SerializeObject(obj));
+            }
+            return new BusinessScope();
+        }
+
+        /// <summary>
+        /// 查询一条记录
+        /// </summary>
+        /// <param name="condition">查询条件(sql语句)</param>
+        /// <param name="fields">返回的字段</param>
+        /// <returns></returns>
+        public static Dictionary<string, object> Query(string condition, string fields)
+        {
+            Dictionary<string, object> obj = new DbServiceNew(AppConfig.Base.main2Tables, _conn).Query(fields, "BusinessScope", condition);
+            return obj;
+        }
+
+        public static decimal Sum(string condition, string field)
+        {
+            decimal amount = 0;
+            Dictionary<string, object> obj = new DbServiceNew(AppConfig.Base.main2Tables, _conn).Query("Sum(" + field + ") " + field + "", "BusinessScope", condition);
+            if (obj.Keys.Count > 0)
+            {
+                amount = decimal.Parse(function.CheckNum(obj[field].ToString()));
+            }
+            return amount;
+        }
+
+        /// <summary>
+        /// 查询记录数
+        /// </summary>
+        /// <param name="Id">主键Id</param>
+        /// <returns></returns>
+        public static int Count(string condition = "", string field = "Id")
+        {
+            int result = 0;
+            Dictionary<string, object> obj = new DbServiceNew(AppConfig.Base.main2Tables, _conn).Query("count(" + field + ") " + field + "", "BusinessScope", condition);
+            if (obj.Keys.Count > 0)
+            {
+                result = int.Parse(function.CheckInt(obj[field].ToString()));
+            }
+            return result;
+        }
+
+        /// <summary>
+        /// 查询是否存在
+        /// </summary>
+        /// <param name="Id">主键Id</param>
+        /// <returns></returns>
+        public static bool Exist(string condition)
+        {
+            Dictionary<string, object> obj = new DbServiceNew(AppConfig.Base.main2Tables, _conn).Query("1", "BusinessScope", condition);
+            if (obj.Keys.Count > 0)
+            {
+                return true;
+            }
+            return false;
+        }
+
+        /// <summary>
+        /// 添加数据
+        /// </summary>
+        /// <param name="Fields">要设置的字段</param>
+        /// <returns></returns>
+        public static AppResultJson Add(Dictionary<string, object> fields, bool check = true)
+        {
+            if (check)
+            {
+                if (string.IsNullOrEmpty(fields["Name"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写名称" };
+                }
+                if (string.IsNullOrEmpty(fields["Mobile"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写手机号" };
+                }
+                if (string.IsNullOrEmpty(fields["ActivationStatus"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写激活状态" };
+                }
+                if (string.IsNullOrEmpty(fields["ActMaxAmount"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写活动应返金额" };
+                }
+                if (!function.IsNum(fields["ActMaxAmount"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写正确的活动应返金额" };
+                }
+                if (string.IsNullOrEmpty(fields["ActCurrentAmount"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写活动已返金额" };
+                }
+                if (!function.IsNum(fields["ActCurrentAmount"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写正确的活动已返金额" };
+                }
+                if (!function.IsInt(fields["IsAct"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写正确的商户激活标记" };
+                }
+                if (!function.IsInt(fields["ExamineStatus"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写正确的服务费考核状态" };
+                }
+                if (!function.IsInt(fields["Months"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写正确的达标月数" };
+                }
+
+            }
+            int Id = new DbServiceNew(AppConfig.Base.main2Tables, _conn).Add("BusinessScope", fields, 0);
+            return new AppResultJson() { Status = "1", Data = Id };
+        }
+
+        /// <summary>
+        /// 修改数据
+        /// </summary>
+        /// <param name="Fields">要设置的字段</param>
+        /// <param name="Id">主键Id</param>
+        public static AppResultJson Edit(Dictionary<string, object> fields, int Id, bool check = true)
+        {
+            if (check)
+            {
+                if (string.IsNullOrEmpty(fields["Name"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写名称" };
+                }
+                if (string.IsNullOrEmpty(fields["Mobile"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写手机号" };
+                }
+                if (string.IsNullOrEmpty(fields["ActivationStatus"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写激活状态" };
+                }
+                if (string.IsNullOrEmpty(fields["ActMaxAmount"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写活动应返金额" };
+                }
+                if (!function.IsNum(fields["ActMaxAmount"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写正确的活动应返金额" };
+                }
+                if (string.IsNullOrEmpty(fields["ActCurrentAmount"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写活动已返金额" };
+                }
+                if (!function.IsNum(fields["ActCurrentAmount"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写正确的活动已返金额" };
+                }
+                if (!function.IsInt(fields["IsAct"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写正确的商户激活标记" };
+                }
+                if (!function.IsInt(fields["ExamineStatus"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写正确的服务费考核状态" };
+                }
+                if (!function.IsInt(fields["Months"].ToString()))
+                {
+                    return new AppResultJson() { Status = "-1", Info = "请填写正确的达标月数" };
+                }
+
+            }
+            new DbServiceNew(AppConfig.Base.main2Tables, _conn).Edit("BusinessScope", fields, Id);
+            return new AppResultJson() { Status = "1", Data = Id };
+        }
+
+        /// <summary>
+        /// 逻辑删除
+        /// </summary>
+        /// <param name="Id">主键Id</param>
+        public static void Remove(int Id)
+        {
+            Dictionary<string, object> fields = new Dictionary<string, object>();
+            fields.Add("Status", -1);
+            new DbServiceNew(AppConfig.Base.main2Tables, _conn).Edit("BusinessScope", fields, Id);
+        }
+
+        /// <summary>
+        /// 删除数据
+        /// </summary>
+        /// <param name="Id">主键Id</param>
+        public static void Delete(int Id)
+        {
+            new DbServiceNew(AppConfig.Base.main2Tables, _conn).Delete("BusinessScope", Id);
+        }
+
+        /// <summary>
+        /// 排序
+        /// </summary>
+        /// <param name="Id">主键Id</param>
+        /// <param name="Sort">排序序号</param>
+        public static void Sort(int Id, int Sort)
+        {
+            new DbServiceNew(AppConfig.Base.main2Tables, _conn).Sort("BusinessScope", Sort, Id);
+        }
+
+        /// <summary>
+        /// 导入数据
+        /// </summary>
+        /// <param name="ExcelData">json数据</param>
+        public static void Import(string ExcelData)
+        {
+            // WebCMSEntities db = new WebCMSEntities();
+            // JsonData list = JsonMapper.ToObject(ExcelData);
+            // for (int i = 1; i < list.Count;i++ )
+            // {
+            //     JsonData dr = list[i];
+
+            //     db.BusinessScope.Add(new BusinessScope()
+            //     {
+            //         CreateDate = DateTime.Now,
+            //         UpdateDate = DateTime.Now,
+
+            //     });
+            //     db.SaveChanges();
+            // }
+            // db.Dispose();
+        }
+
+        /// <summary>
+        /// 导出excel表格
+        /// </summary>
+        /// <param name="fields">查询条件(单个字段)</param>
+        /// <param name="condition">查询条件(sql语句)</param>
+        /// <returns></returns>
+        // public static void ExportExcel(List<RelationData> relationData, string condition)
+        // {
+
+        // }
+    }
+}