|
@@ -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;
|
|
|
}
|