1188 lines
57 KiB
C#
1188 lines
57 KiB
C#
using HZQR.Common;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
using MSPB = SuperMap.RealEstate.MobileServicePlatform.Business;
|
||
using CMB = SuperMap.RealEstate.Coop.Merchant.Business;
|
||
using SuperMap.RealEstate.ServiceModel;
|
||
using HWSB = SuperMap.RealEstate.HighWay.Storage.Business;
|
||
using Model = EShang.Common.Model;
|
||
using RedisHelp;
|
||
using System.Data;
|
||
using System.Configuration;
|
||
using System.Web;
|
||
using Newtonsoft.Json.Linq;
|
||
using System.IO;
|
||
|
||
namespace EShang.Common
|
||
{
|
||
/// <summary>
|
||
/// 基本信息(小程序信息、业主单位信息、图库等)
|
||
/// </summary>
|
||
public class Base
|
||
{
|
||
/// <summary>
|
||
/// 合作商户平台Url,用于上传的图片线上url用
|
||
/// </summary>
|
||
protected static string _CoopMerchantUrl = ConfigurationManager.AppSettings["CoopMerchantUrls"].ToString();
|
||
/// <summary>
|
||
/// EShangPlatformApi站点Url
|
||
/// </summary>
|
||
protected static string _EShangPlatformApiUrls = ConfigurationManager.AppSettings["EShangPlatformApiUrls"];
|
||
|
||
#region 方法 -> 获取业主单位信息
|
||
/// <summary>
|
||
/// 获取业主单位信息
|
||
/// </summary>
|
||
/// <param name="transaction"></param>
|
||
/// <param name="ownerUnitId"></param>
|
||
/// <returns></returns>
|
||
public static Model.OwnerUnit GetOwnerUnitInfo(Transaction transaction, int ownerUnitId)
|
||
{
|
||
//从Redis中获取业主单位
|
||
string key = ownerUnitId.ToString();
|
||
Model.OwnerUnit ownerUnitModel = Redis.HashGet<Model.OwnerUnit>(5, "OwnerUnit", key);
|
||
if (ownerUnitModel == null)
|
||
{
|
||
ownerUnitModel = new Model.OwnerUnit();
|
||
//Redis中不存在则查询数据库
|
||
CMB.OWNERUNIT ownerUnit = new CMB.OWNERUNIT(transaction);
|
||
ownerUnit.OWNERUNIT_ID = ownerUnitId;
|
||
if (ownerUnit.Select())
|
||
{
|
||
ownerUnitModel.ownerUnitId = ownerUnit.OWNERUNIT_ID.TryParseToInt();
|
||
ownerUnitModel.ownerName = ownerUnit.OWNERUNIT_NAME;
|
||
ownerUnitModel.provinceCode = ownerUnit.PROVINCE_CODE.TryParseToInt();
|
||
ownerUnitModel.isSupportPoint = ownerUnit.ISSUPPORTPOINT.TryParseToInt();
|
||
//写入Redis的db5数据库
|
||
Redis.HashSet(5, "OwnerUnit", key, ownerUnitModel);
|
||
}
|
||
}
|
||
return ownerUnitModel;
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 获取小程序信息
|
||
/// <summary>
|
||
/// 获取小程序信息
|
||
/// </summary>
|
||
/// <param name="transaction"></param>
|
||
/// <param name="wechatAppAppId"></param>
|
||
/// <returns></returns>
|
||
public static Model.WeChatAppSign GetWechatAppSignInfo(Transaction transaction, string wechatAppAppId)
|
||
{
|
||
//从Redis中获取小程序信息
|
||
string key = wechatAppAppId;
|
||
Model.WeChatAppSign weChatAppSignModel = Redis.HashGet<Model.WeChatAppSign>(5, "WechatApp", key);
|
||
if (weChatAppSignModel == null)
|
||
{
|
||
weChatAppSignModel = new Model.WeChatAppSign();
|
||
MSPB.WECHATAPPSIGN wechatAppSign = new MSPB.WECHATAPPSIGN(transaction);
|
||
//Redis中不存在则查询数据库
|
||
wechatAppSign.AddSearchParameter("WECHATAPP_APPID", wechatAppAppId);
|
||
if (wechatAppSign.Search())
|
||
{
|
||
//写入Redis的db6数据库
|
||
weChatAppSignModel.weChatAppSignId = wechatAppSign.WECHATAPPSIGN_ID.TryParseToInt();
|
||
weChatAppSignModel.weChatAppSignName = wechatAppSign.WECHATAPPSIGN_NAME;
|
||
weChatAppSignModel.weChatAppSignAppId = wechatAppSign.WECHATAPP_APPID;
|
||
weChatAppSignModel.wechatAppAppSecret = wechatAppSign.WECHATAPP_APPSECRET;
|
||
weChatAppSignModel.ownerUnitId = wechatAppSign.OWNERUNIT_ID.TryParseToInt();
|
||
weChatAppSignModel.weChatPublicSignId = wechatAppSign.WECHATPUBLICSIGN_ID.TryParseToInt();
|
||
//写入Redis的db5数据库
|
||
Redis.HashSet(5, "WechatApp", key, weChatAppSignModel);
|
||
}
|
||
}
|
||
return weChatAppSignModel;
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 获取服务区商户列表
|
||
/// <summary>
|
||
/// 获取服务区商户列表
|
||
/// </summary>
|
||
/// <param name="transaction">事务</param>
|
||
/// <param name="totalCount">总数</param>
|
||
/// <param name="provinceCode">省份编码,可为空</param>
|
||
/// <param name="serverpartId">服务区Id,可为空</param>
|
||
/// <param name="scancodeOrder">是否支持在线,可为空</param>
|
||
/// <param name="isShow">是否显示在小程序发现页</param>
|
||
/// <param name="sorts">排序字段,默认按排序索引+商户名称</param>
|
||
/// <param name="rn">数据开始开始行</param>
|
||
/// <param name="rowNum">数据行数</param>
|
||
/// <returns></returns>
|
||
public static DataTable SellerList(Transaction transaction, ref int totalCount,
|
||
string provinceCode = "", int? serverpartId = null, int? scancodeOrder = null,
|
||
int? isShow = null, string sorts = "SELLER_INDEX ASC,SELLER_NAME ASC",
|
||
int? rn = null, int? rowNum = null)
|
||
{
|
||
#region 查询条件
|
||
string sqlWhere = "";
|
||
if (!string.IsNullOrEmpty(provinceCode))
|
||
{
|
||
sqlWhere += " AND A.PROVINCE_CODE = '" + provinceCode + "'";//省份编码
|
||
}
|
||
if (serverpartId != null)
|
||
{
|
||
sqlWhere += " AND A.SERVERPART_ID = " + serverpartId;//服务区Id
|
||
}
|
||
if (scancodeOrder != null)
|
||
{
|
||
sqlWhere += " AND B.SCANCODE_ORDER = " + scancodeOrder;//是否支持在线
|
||
}
|
||
if (isShow != null)
|
||
{
|
||
sqlWhere += " AND B.ISSHOW = " + isShow;//是否显示在小程序发现页
|
||
}
|
||
#endregion
|
||
//总记录数
|
||
string sqlCount = string.Format(@"
|
||
SELECT
|
||
Count(0) AS Count
|
||
FROM MOBILESERVICE_PLATFORM.T_SERVERPARTSELLER A
|
||
WHERE A.ISVALID= 1 AND A.ISSHOW = 1 {0}", sqlWhere);
|
||
totalCount = new MSPB.SERVERPARTSHOP(transaction).ExecuteDataTable(sqlCount).Rows[0]["Count"].TryParseToInt();
|
||
//查询服务区商户信息
|
||
string sql = string.Format(@"
|
||
SELECT
|
||
A.SELLER_ID,A.SELLER_NAME,A.SELLER_TELEPHONE,SELLER_INDEX,
|
||
Round(NVL(SELLER_SCORE, 5), 1) AS SELLER_SCORE,
|
||
A.SERVERPART_ID,A.PROVINCE_CODE,SERVERPARTSHOP_IDS,
|
||
A.COMMENT_COUNT,A.SHOPTRADE,
|
||
MAX(B.SCANCODE_ORDER) AS SCANCODE_ORDER,
|
||
A.MONTHLYSALES,A.CASHPAY,A.PERCAPITA,ISSHOW,SELF_COMMENT
|
||
FROM MOBILESERVICE_PLATFORM.T_SERVERPARTSELLER A,MOBILESERVICE_PLATFORM.T_SERVERPARTSHOP B
|
||
WHERE A.PROVINCE_CODE = B.PROVINCE_CODE AND A.SERVERPART_ID = B.SERVERPART_ID AND
|
||
A.SELLER_ID = B.SELLER_ID AND A.ISVALID= 1 AND A.ISSHOW = 1 {0}
|
||
GROUP BY SHOW_HOME,SHOW_HOME_INDEX,SELLER_INDEX,
|
||
A.SELLER_ID,A.SELLER_NAME,A.SELLER_TELEPHONE,
|
||
A.SELLER_ADDRESS,SELLER_DESC,A.BUS_STARTDATE,SELLER_SCORE,
|
||
A.SERVERPART_ID,A.PROVINCE_CODE,SERVERPARTSHOP_IDS,A.COMMENT_COUNT,A.SHOPTRADE,
|
||
A.MONTHLYSALES,A.CASHPAY,A.PERCAPITA,ISSHOW,SELF_COMMENT
|
||
ORDER BY {1}", sqlWhere, sorts);
|
||
if (rn != null && rowNum != null)
|
||
{
|
||
//分页查询
|
||
sql = string.Format(@"
|
||
SELECT * FROM (
|
||
SELECT ROWNUM RN,N.* FROM ({0}) N WHERE ROWNUM<={1}
|
||
) M WHERE M.RN>{2}", sql, rowNum, rn);
|
||
}
|
||
DataTable dt = new MSPB.SERVERPARTSHOP(transaction).ExecuteDataTable(sql);
|
||
return dt;
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 获取服务区商户详情
|
||
/// <summary>
|
||
/// 获取服务区商户详情
|
||
/// </summary>
|
||
/// <param name="transaction">事务</param>
|
||
/// <param name="sellerId">商户Id</param>
|
||
/// <returns></returns>
|
||
public static MSPB.SERVERPARTSELLER SellerDetail(Transaction transaction, int sellerId)
|
||
{
|
||
//查询服务区商户详情
|
||
MSPB.SERVERPARTSELLER _SERVERPARTSELLER = new MSPB.SERVERPARTSELLER(transaction);
|
||
_SERVERPARTSELLER.SELLER_ID = sellerId;//服务区商户Id
|
||
_SERVERPARTSELLER.Select();
|
||
return _SERVERPARTSELLER;
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 查询服务区编码对应业主单位
|
||
/// <summary>
|
||
/// 查询服务区编码对应业主单位
|
||
/// </summary>
|
||
/// <param name="transaction">事务</param>
|
||
/// <param name="serverparCode">服务区门店编码</param>
|
||
/// <returns></returns>
|
||
public static int GetOwnerUnitId(Transaction transaction, string serverparCode)
|
||
{
|
||
int ownerUnitId = 0;
|
||
try
|
||
{
|
||
string sql = string.Format(@"
|
||
SELECT
|
||
A.OWNERUNIT_ID
|
||
FROM
|
||
MOBILESERVICE_PLATFORM.T_OWNERSERVERPART A,COOP_MERCHANT.T_OWNERUNIT@CM B
|
||
WHERE
|
||
A.OWNERUNIT_ID = B.OWNERUNIT_ID AND B.OWNERUNIT_NATURE = 1000 AND
|
||
A.SERVERPART_CODE='{0}'", serverparCode);
|
||
DataTable dt = new MSPB.OWNERSERVERPART(transaction).ExecuteDataTable(sql);
|
||
if (dt.Rows.Count > 0 && dt.Rows[0][0] != DBNull.Value)
|
||
{
|
||
ownerUnitId = dt.Rows[0]["OWNERUNIT_ID"].TryParseToInt();
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
SuperMap.RealEstate.Utility.ErrorLogHelper.Write(ex, "Base", "查询服务区编码对应业主单位" + serverparCode);
|
||
}
|
||
return ownerUnitId;
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 根据业主单位编码获取服务区编码集合
|
||
/// <summary>
|
||
/// 根据业主单位编码获取服务区编码集合
|
||
/// </summary>
|
||
/// <param name="transaction">事务管理器</param>
|
||
/// <param name="ProvinceCode">业主单位编码</param>
|
||
/// <returns></returns>
|
||
public static List<string> GetServerpartCodebyProvinceCode(Transaction transaction, string ProvinceCode)
|
||
{
|
||
List<string> ServerpartCodeList = new List<string>();
|
||
//从服务区表查询服务区集合
|
||
DataTable dtServerpart = new MSPB.SERVERPART(transaction).FillDataTable("WHERE PROVINCE_CODE = " + ProvinceCode);
|
||
foreach (DataRow dataRow in dtServerpart.Rows)
|
||
{
|
||
ServerpartCodeList.Add(dataRow["SERVERPART_CODE"].ToString());
|
||
}
|
||
|
||
return ServerpartCodeList;
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 获取图库图片
|
||
/// <summary>
|
||
/// 根据业务表查询图库
|
||
/// </summary>
|
||
/// <param name="transaction">事务</param>
|
||
/// <param name="tableName">表名</param>
|
||
/// <returns></returns>
|
||
public static DataTable ImageList(Transaction transaction, string tableName)
|
||
{
|
||
//根据业务表查询图库
|
||
DataTable dtImage = new CMB.IMAGE(transaction).FillDataTable(
|
||
"WHERE TABLE_NAME = '" + tableName + "'");
|
||
return dtImage;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取图片路径
|
||
/// </summary>
|
||
/// <param name="dt">图库DataTable</param>
|
||
/// <param name="tableId">业务表ID</param>
|
||
/// <param name="imageType">图片类型(1000:商户Logo,2000:商户门头图)</param>
|
||
/// <returns></returns>
|
||
public static string GetImgUrl(DataTable dt, int tableId, int imageType)
|
||
{
|
||
string imgUrl = "";
|
||
DataRow[] drs = dt.Select("TABLE_ID = " + tableId +
|
||
" AND IMAGE_TYPE = " + imageType);
|
||
if (drs.Length > 0)
|
||
{
|
||
imgUrl = _CoopMerchantUrl + drs[0]["IMAGE_PATH"].TryParseToString();
|
||
}
|
||
return imgUrl;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取图片路径
|
||
/// </summary>
|
||
/// <param name="transaction">事务</param>
|
||
/// <param name="tableName">业务表名</param>
|
||
/// <param name="tableId">业务表ID</param>
|
||
/// <returns></returns>
|
||
public static string GetImgUrl(Transaction transaction, string tableName, int tableId)
|
||
{
|
||
//查询图片路劲
|
||
string ImagePath = "";
|
||
DataTable ImageTable = new CMB.IMAGE(transaction).FillDataTable(
|
||
"WHERE TABLE_ID = " + tableId + " AND TABLE_NAME = '" + tableName + "'");
|
||
if (ImageTable.Rows.Count > 0)
|
||
{
|
||
ImagePath = _CoopMerchantUrl + ImageTable.Rows[0]["IMAGE_PATH"];
|
||
}
|
||
return ImagePath;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取图片集合
|
||
/// </summary>
|
||
/// <param name="dt">图片数据源</param>
|
||
/// <param name="tableId">业务ID</param>
|
||
/// <param name="imageType">图片类型</param>
|
||
/// <returns></returns>
|
||
public static List<Model.ImagePath> GetImgUrls(DataTable dt, int tableId, int? imageType = null)
|
||
{
|
||
string where = "TABLE_ID = " + tableId;
|
||
if (imageType != null)
|
||
{
|
||
where += " AND IMAGE_TYPE = " + imageType;//图片类型
|
||
}
|
||
DataRow[] drs = dt.Select(where);
|
||
List<Model.ImagePath> ImageList = new List<Model.ImagePath>();
|
||
foreach (DataRow dr in drs)
|
||
{
|
||
Model.ImagePath imagePath = new Model.ImagePath();
|
||
imagePath.ImagPath = dr["IMAGE_URL"].ToString();
|
||
ImageList.Add(imagePath);
|
||
}
|
||
return ImageList;
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 人保接口请求
|
||
/// <summary>
|
||
/// 人保接口请求
|
||
/// </summary>
|
||
/// <param name="ActionName">接口请求名称</param>
|
||
/// <param name="parameters">参数</param>
|
||
/// <returns></returns>
|
||
|
||
public static Result PiccAction(string ActionName, string parameters)
|
||
{
|
||
string url = HttpContext.Current.Request.Url.ToString();
|
||
string urlHost = HttpContext.Current.Request.Url.Host.ToString();
|
||
string port = HttpContext.Current.Request.Url.Port.ToString();
|
||
string httpUrl = url.Substring(0, url.IndexOf(":"));
|
||
//string parameters = ActionName + "?orderNo=" + orderNo +
|
||
//"&cuponNo=" + cuponNo + "&username=" + username + "&outerOrderId=" + outerOrderId;
|
||
//string _BaseUrl = httpUrl + "://" + urlHost +
|
||
//(!string.IsNullOrEmpty(port) ? ":" + port : "") + "/" + ActionName;
|
||
string _BaseUrl = httpUrl + "://" + urlHost + ":" + port + "/" + ActionName;
|
||
string RequestUrl = _BaseUrl;
|
||
string jsonStr = HttpUtil.HttpUrlPost(parameters, RequestUrl + parameters);
|
||
Result result = new Result();
|
||
JObject jObj = new JObject();
|
||
try
|
||
{
|
||
jObj = JObject.Parse(jsonStr);
|
||
result.Result_Code = jObj["Result_Code"].TryParseToInt();
|
||
result.Result_Desc = jObj["Result_Desc"].TryParseToString();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
SuperMap.RealEstate.Utility.ErrorLogHelper.Write(ex, "接口【PiccAction】",
|
||
"请求参数:" + parameters + "||" + jsonStr);
|
||
}
|
||
return result;
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 获取服务区业态品牌营收
|
||
/// <summary>
|
||
/// 获取服务区业态品牌营收
|
||
/// 修改记录:
|
||
/// 2021.10.29显示0营收的门店
|
||
/// </summary>
|
||
/// <param name="transaction">事务</param>
|
||
/// <param name="staticticsTime">统计时间</param>
|
||
/// <param name="serverpartId">服务区Id,可为空</param>
|
||
/// <param name="businessType">门店业态,可为空</param>
|
||
/// <param name="bussinessBrand">门店品牌,可为空</param>
|
||
/// <returns></returns>
|
||
public static DataTable GetBusinessBrandList(Transaction transaction, DateTime staticticsTime,
|
||
int? serverpartId = null, string businessType = null, string bussinessBrand = null)
|
||
{
|
||
#region 查询条件
|
||
string sqlWhere = "";
|
||
string sqlWhere2 = "";
|
||
//过滤统计日期
|
||
if (staticticsTime != DateTime.MinValue)
|
||
{
|
||
sqlWhere2 += " AND B.ENDACCOUNT_DATE >= TO_DATE('" + staticticsTime.ToString("yyyy/MM/dd") +
|
||
"','YYYY/MM/DD') AND B.ENDACCOUNT_DATE < TO_DATE('" + staticticsTime.ToString("yyyy/MM/dd") + "','YYYY/MM/DD') + 1";
|
||
}
|
||
if (serverpartId != null)
|
||
{
|
||
sqlWhere += " AND A.SERVERPART_ID = " + serverpartId;//服务区Id
|
||
}
|
||
if (businessType != null)
|
||
{
|
||
sqlWhere += " AND NVL(A.BUSINESS_TRADE,-1) IN ('" + businessType.Replace(",", "','") + "')";//门店业态
|
||
}
|
||
if (bussinessBrand != null)
|
||
{
|
||
sqlWhere += " AND NVL(A.BUSINESS_BRAND,-1) = " + bussinessBrand;//门店品牌
|
||
}
|
||
#endregion
|
||
|
||
//查询服务区商户信息
|
||
DataTable dataTable = new HWSB.SERVERPARTSHOP(transaction).ExecuteDataTable($@"
|
||
SELECT
|
||
NVL(A.BUSINESS_TRADE,-1) AS BUSINESS_TRADE,
|
||
NVL(A.BUSINESS_BRAND,-1) AS BUSINESS_BRAND,
|
||
NVL(A.BRAND_NAME,'其他') AS BRAND_NAME,
|
||
NVL(A.BUSINESS_TRADENAME,'其他') AS BUSINESS_TRADENAME,
|
||
SUM(NVL(B.CASHPAY,0)) AS FACTAMOUNT,A.SERVERPART_ID,A.SERVERPART_NAME
|
||
FROM
|
||
HIGHWAY_STORAGE.T_SERVERPARTSHOP A,
|
||
HIGHWAY_SELLDATA.T_ENDACCOUNT_TEMP B
|
||
WHERE
|
||
A.SERVERPART_ID = B.SERVERPART_ID AND A.SHOPCODE = B.SHOPCODE AND
|
||
A.STATISTIC_TYPE = 1000 AND A.ISVALID = 1 AND B.VALID = 1 AND
|
||
A.SHOPTRADE IS NOT NULL {sqlWhere2} {sqlWhere}
|
||
GROUP BY
|
||
NVL(A.BUSINESS_TRADE,-1),NVL(A.BUSINESS_BRAND,-1),NVL(A.BRAND_NAME,'其他'),
|
||
NVL(A.BUSINESS_TRADENAME,'其他'),A.SERVERPART_ID,A.SERVERPART_NAME");
|
||
|
||
return dataTable;
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 获取服务区业态营收
|
||
/// <summary>
|
||
/// 获取经营业态营收额
|
||
/// </summary>
|
||
/// <param name="BrandTable">经营品牌营收额数据</param>
|
||
/// <param name="BusinessDetilsTable">经营业态列表数据</param>
|
||
/// <returns></returns>
|
||
public static DataTable GetBusinessList(DataTable BrandTable, DataTable BusinessDetilsTable)
|
||
{
|
||
DataTable BusinessTable = new DataTable();
|
||
BusinessTable.Columns.Add("BUSINESS_TRADE", typeof(string)); //当前品牌所属业态
|
||
BusinessTable.Columns.Add("BUSINESS_TRADENAME", typeof(string)); //当前品牌所属业态名称
|
||
BusinessTable.Columns.Add("BUSINESS_TRADE_PID", typeof(int)); //当前品牌所属父级业态
|
||
BusinessTable.Columns.Add("BUSINESS_TRADENAME_P", typeof(string)); //当前品牌所属父级业态名称
|
||
BusinessTable.Columns.Add("FACTAMOUNT", typeof(decimal)); //当前品牌所属业态合计销售额
|
||
|
||
#region 统计经营业态营收额
|
||
var query = from t in BrandTable.AsEnumerable()
|
||
group t by new
|
||
{
|
||
t1 = t.Field<string>("BUSINESS_TRADE")
|
||
} into m
|
||
select new
|
||
{
|
||
BUSINESS_TRADE = m.Key.t1,
|
||
BUSINESS_TRADENAME = "",
|
||
BUSINESS_TRADE_PID = 0,
|
||
BUSINESS_TRADENAME_P = "",
|
||
FACTAMOUNT = m.Sum(n => n.Field<decimal>("FACTAMOUNT"))
|
||
};
|
||
if (query.ToList().Count > 0)
|
||
{
|
||
query.ToList().ForEach(q =>
|
||
{
|
||
DataRow _DataRow = BusinessTable.NewRow();
|
||
|
||
_DataRow["BUSINESS_TRADE"] = q.BUSINESS_TRADE;
|
||
if (!string.IsNullOrWhiteSpace(q.BUSINESS_TRADE) &&
|
||
BusinessDetilsTable.Select("AUTOSTATISTICS_ID = " + q.BUSINESS_TRADE).Length > 0)
|
||
{
|
||
//当前品牌所属经营业态数据
|
||
DataRow drBusinessTrade = BusinessDetilsTable.Select("AUTOSTATISTICS_ID = " + q.BUSINESS_TRADE)[0];
|
||
_DataRow["BUSINESS_TRADENAME"] = drBusinessTrade["AUTOSTATISTICS_NAME"];
|
||
//父级经营业态数据
|
||
if (drBusinessTrade["AUTOSTATISTICS_PID"].ToString() != "-1" && BusinessDetilsTable.Select(
|
||
"AUTOSTATISTICS_ID = " + drBusinessTrade["AUTOSTATISTICS_PID"]).Length > 0)
|
||
{
|
||
DataRow drBusinessTrade_P = BusinessDetilsTable.Select(
|
||
"AUTOSTATISTICS_ID = " + drBusinessTrade["AUTOSTATISTICS_PID"])[0];
|
||
_DataRow["BUSINESS_TRADE_PID"] = drBusinessTrade_P["AUTOSTATISTICS_ID"];
|
||
_DataRow["BUSINESS_TRADENAME_P"] = drBusinessTrade_P["AUTOSTATISTICS_NAME"];
|
||
}
|
||
}
|
||
_DataRow["FACTAMOUNT"] = q.FACTAMOUNT;
|
||
|
||
BusinessTable.Rows.Add(_DataRow);
|
||
});
|
||
}
|
||
#endregion
|
||
|
||
return BusinessTable;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取父级经营业态营收
|
||
/// </summary>
|
||
/// <param name="BusinessTable">经营业态营收额</param>
|
||
/// <returns></returns>
|
||
public static DataTable GetBusinessList(DataTable BusinessTable)
|
||
{
|
||
DataTable BusinessTable_P = new DataTable();
|
||
BusinessTable_P.Columns.Add("BUSINESS_TRADE", typeof(int)); //当前品牌所属父级业态
|
||
BusinessTable_P.Columns.Add("BUSINESS_TRADENAME", typeof(string)); //当前品牌所属父级业态名称
|
||
BusinessTable_P.Columns.Add("BUSINESS_TRADE_LIST", typeof(string)); //当前品牌所属业态内码集合
|
||
BusinessTable_P.Columns.Add("FACTAMOUNT", typeof(decimal)); //当前品牌所属父级业态合计销售额
|
||
|
||
#region 统计经营业态营收额
|
||
var query = from t in BusinessTable.AsEnumerable()
|
||
group t by new
|
||
{
|
||
t1 = t.Field<int?>("BUSINESS_TRADE_PID"),
|
||
t2 = t.Field<string>("BUSINESS_TRADENAME_P")
|
||
} into m
|
||
select new
|
||
{
|
||
BUSINESS_TRADE = m.Key.t1 == null ? -1 : m.Key.t1,
|
||
BUSINESS_TRADENAME = string.IsNullOrWhiteSpace(m.Key.t2) ? "其他" : m.Key.t2,
|
||
BUSINESS_TRADE_LIST = string.Join(",", m.Select(n => n.Field<string>("BUSINESS_TRADE")).ToArray()),
|
||
FACTAMOUNT = m.Sum(n => n.Field<decimal>("FACTAMOUNT"))
|
||
};
|
||
if (query.ToList().Count > 0)
|
||
{
|
||
query.ToList().ForEach(q =>
|
||
{
|
||
DataRow _DataRow = BusinessTable_P.NewRow();
|
||
|
||
_DataRow["BUSINESS_TRADE"] = q.BUSINESS_TRADE;
|
||
_DataRow["BUSINESS_TRADENAME"] = q.BUSINESS_TRADENAME;
|
||
_DataRow["BUSINESS_TRADE_LIST"] = q.BUSINESS_TRADE_LIST;
|
||
_DataRow["FACTAMOUNT"] = q.FACTAMOUNT;
|
||
|
||
BusinessTable_P.Rows.Add(_DataRow);
|
||
});
|
||
}
|
||
#endregion
|
||
|
||
return BusinessTable_P;
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 获取门店营收信息
|
||
/// <summary>
|
||
/// 获取门店营收信息
|
||
/// </summary>
|
||
/// <param name="transaction"></param>
|
||
/// <param name="staticticsTime">统计时间</param>
|
||
/// <param name="serverpartId">服务区内码</param>
|
||
/// <param name="businessType">门店业态</param>
|
||
/// <param name="bussinessBrand">门店品牌</param>
|
||
/// <returns></returns>
|
||
public static List<Model.BrandShopModel> GetBrandShopRevenue(Transaction transaction, DateTime staticticsTime,
|
||
int? serverpartId = null, string businessType = null, string bussinessBrand = null)
|
||
{
|
||
List<Model.BrandShopModel> listModel = new List<Model.BrandShopModel>();
|
||
|
||
string SQLString = " AND B.SERVERPART_ID = " + serverpartId;
|
||
|
||
if (!string.IsNullOrWhiteSpace(businessType))
|
||
{
|
||
SQLString += " AND NVL(B.BUSINESS_TRADE,-1) IN ('" + businessType.Replace(",", "','") + "')";
|
||
}
|
||
if (!string.IsNullOrWhiteSpace(bussinessBrand))
|
||
{
|
||
SQLString += " AND NVL(B.BUSINESS_BRAND,-1) = " + bussinessBrand;
|
||
}
|
||
if (staticticsTime != DateTime.MinValue)
|
||
{
|
||
SQLString += " AND A.ENDACCOUNT_DATE >= TO_DATE('" + staticticsTime.ToString("yyyy/MM/dd") +
|
||
"','YYYY/MM/DD') AND A.ENDACCOUNT_DATE < TO_DATE('" + staticticsTime.ToString("yyyy/MM/dd") + "','YYYY/MM/DD') + 1";
|
||
}
|
||
|
||
DataTable _DataTable = new HWSB.SERVERPART(transaction).ExecuteDataTable($@"
|
||
SELECT
|
||
B.SERVERPARTSHOP_ID,A.ENDACCOUNT_DATE,A.SERVERPART_ID,A.SERVERPART_NAME,
|
||
A.SHOPNAME,B.BUSINESS_TYPE,A.WORKER_NAME,A.DESCRIPTION_STAFF,B.STATISTICS_TYPE,
|
||
A.ENDACCOUNT_STARTDATE,A.DIFFERENCE_REASON,A.APPROVE_STAFF,A.APPROVE_DATE,
|
||
A.APPROVED_INFO,A.FACTAMOUNT_SALE,A.FACTAMOUNT_CIGARETTE,A.CHECK_COUNT,
|
||
A.DIFFERENT_PRICE,A.CASHPAY_DOWNLORD,A.MOBILEPAYMENT,A.CASHPAY,A.TOTALSELLAMOUNT,
|
||
B.SHOPREGION,B.SHOPTRADE,B.SHOPCODE,A.EXCEPTION_COUNT,A.ENDACCOUNT_ID,A.DESCRIPTION_DATE
|
||
FROM
|
||
HIGHWAY_SELLDATA.V_ENDACCOUNT_TEMP_REVENUE A,
|
||
HIGHWAY_STORAGE.T_SERVERPARTSHOP B
|
||
WHERE
|
||
A.SERVERPART_ID = B.SERVERPART_ID AND A.SHOPCODE = B.SHOPCODE AND
|
||
B.ISVALID = 1 AND B.STATISTIC_TYPE = 1000 AND B.SHOPTRADE IS NOT NULL {SQLString}");
|
||
|
||
if (_DataTable.Rows.Count > 0)
|
||
{
|
||
#region 绑定门店结账清单
|
||
//按照服务区、门店方位、门店业态、门店编码、结账时间排序
|
||
_DataTable.DefaultView.Sort = "SERVERPART_NAME,SHOPREGION,SHOPTRADE,SHOPCODE,ENDACCOUNT_DATE";
|
||
_DataTable = _DataTable.DefaultView.ToTable();
|
||
Model.BrandShopModel _ShopEndaccount = new Model.BrandShopModel();
|
||
string _SERVERPARTSHOP_ID = "";
|
||
foreach (DataRow _DataRow in _DataTable.Rows)
|
||
{
|
||
bool ChangeFlag = false; //门店信息变化标识
|
||
if (string.IsNullOrWhiteSpace(_SERVERPARTSHOP_ID))
|
||
{
|
||
listModel.Add(_ShopEndaccount);
|
||
ChangeFlag = true;
|
||
}
|
||
else if (_SERVERPARTSHOP_ID != _DataRow["SERVERPARTSHOP_ID"].ToString())
|
||
{
|
||
_ShopEndaccount = new Model.BrandShopModel();
|
||
listModel.Add(_ShopEndaccount);
|
||
ChangeFlag = true;
|
||
}
|
||
if (ChangeFlag)
|
||
{
|
||
_SERVERPARTSHOP_ID = _DataRow["SERVERPARTSHOP_ID"].ToString();
|
||
|
||
#region 绑定门店信息
|
||
_ShopEndaccount.ENDACCOUNT_DATE = _DataRow["ENDACCOUNT_DATE"].ToString();
|
||
_ShopEndaccount.SERVERPART_ID = _DataRow["SERVERPART_ID"].TryParseToInt();
|
||
_ShopEndaccount.SERVERPART_NAME = _DataRow["SERVERPART_NAME"].ToString();
|
||
_ShopEndaccount.SERVERPARTSHOP_ID = _DataRow["SERVERPARTSHOP_ID"].TryParseToInt();
|
||
_ShopEndaccount.SHOPNAME = _DataRow["SHOPNAME"].ToString();
|
||
_ShopEndaccount.BUSINESS_TYPE = _DataRow["BUSINESS_TYPE"].TryParseToInt();
|
||
switch (_ShopEndaccount.BUSINESS_TYPE)
|
||
{
|
||
case 1000:
|
||
_ShopEndaccount.BUSINESS_TYPENAME = "自营";
|
||
_ShopEndaccount.SHOPNAME += "【自】";
|
||
break;
|
||
case 2000:
|
||
_ShopEndaccount.BUSINESS_TYPENAME = "合作经营";
|
||
_ShopEndaccount.SHOPNAME += "【合】";
|
||
break;
|
||
case 3000:
|
||
_ShopEndaccount.BUSINESS_TYPENAME = "固定租金";
|
||
_ShopEndaccount.SHOPNAME += "【固】";
|
||
break;
|
||
case 4000:
|
||
_ShopEndaccount.BUSINESS_TYPENAME = "展销";
|
||
_ShopEndaccount.SHOPNAME += "【展】";
|
||
break;
|
||
}
|
||
_ShopEndaccount.CASHPAY_TOTAL = 0;
|
||
_ShopEndaccount.ShopEndAccountList = new List<Model.WPDShopEndAccountList>();
|
||
#endregion
|
||
|
||
if (_DataTable.Select("SERVERPARTSHOP_ID = " + _SERVERPARTSHOP_ID + " AND ENDACCOUNT_ID <> 0").Length == 0)
|
||
{
|
||
_ShopEndaccount.UNACCOUNT_SIGN = 0;
|
||
_ShopEndaccount.SHOWSCAN_SIGN = 0;
|
||
_ShopEndaccount.SHOWLESS_SIGN = 0;
|
||
_ShopEndaccount.SHOWMORE_SIGN = 0;
|
||
_ShopEndaccount.SHOWABNORMAL_SIGN = 0;
|
||
_ShopEndaccount.INTERFACE_SIGN = 0;
|
||
_ShopEndaccount.SHOWSSUPPLY_SIGN = 0;
|
||
_ShopEndaccount.SHOWCHECK_SIGN = 0;
|
||
_ShopEndaccount.SHOWDEAL_SIGN = 0;
|
||
}
|
||
else
|
||
{
|
||
_ShopEndaccount.UNACCOUNT_SIGN = 1;
|
||
if (_DataTable.Select("SERVERPARTSHOP_ID = " + _SERVERPARTSHOP_ID + " AND EXCEPTION_COUNT > 0").Length > 0)
|
||
{
|
||
_ShopEndaccount.SHOWABNORMAL_SIGN = 1;
|
||
}
|
||
|
||
if (_DataTable.Select("SERVERPARTSHOP_ID = " + _SERVERPARTSHOP_ID +
|
||
" AND (WORKER_NAME LIKE '%【扫】%' OR WORKER_NAME LIKE '%【扫码】%')").Length > 0)
|
||
{
|
||
_ShopEndaccount.SHOWSCAN_SIGN = 1;
|
||
_ShopEndaccount.INTERFACE_SIGN = 0;
|
||
}
|
||
else
|
||
{
|
||
if (_DataTable.Select("SERVERPARTSHOP_ID = " + _SERVERPARTSHOP_ID + " AND STATISTICS_TYPE LIKE '%1020%'").Length > 0)
|
||
{
|
||
_ShopEndaccount.SHOWSCAN_SIGN = 0;
|
||
_ShopEndaccount.INTERFACE_SIGN = 1;
|
||
}
|
||
else
|
||
{
|
||
_ShopEndaccount.SHOWSCAN_SIGN = 0;
|
||
_ShopEndaccount.INTERFACE_SIGN = 0;
|
||
}
|
||
}
|
||
|
||
if (_DataTable.Select("SERVERPARTSHOP_ID = " + _SERVERPARTSHOP_ID +
|
||
" AND DESCRIPTION_STAFF LIKE '%【补】%'").Length > 0)
|
||
{
|
||
_ShopEndaccount.SHOWSSUPPLY_SIGN = 1;
|
||
}
|
||
|
||
if (_DataTable.Select("SERVERPARTSHOP_ID = " + _SERVERPARTSHOP_ID + " AND CHECK_COUNT > 0").Length > 0)
|
||
{
|
||
_ShopEndaccount.SHOWCHECK_SIGN = 1;
|
||
}
|
||
|
||
if (_DataTable.Select("SERVERPARTSHOP_ID = " + _SERVERPARTSHOP_ID + " AND CHECK_COUNT IS NOT NULL").Length > 0)
|
||
{
|
||
_ShopEndaccount.SHOWDEAL_SIGN = 1;
|
||
}
|
||
}
|
||
}
|
||
Model.WPDShopEndAccountList _WPDShopEndAccountList = new Model.WPDShopEndAccountList();
|
||
if (_DataRow["WORKER_NAME"].ToString().Contains("【扫】"))
|
||
{
|
||
_WPDShopEndAccountList.TRANSFER_TYPE = 1;
|
||
}
|
||
else if (_DataRow["DESCRIPTION_STAFF"].ToString().Contains("【补】"))
|
||
{
|
||
_WPDShopEndAccountList.TRANSFER_TYPE = 2;
|
||
}
|
||
else if (!string.IsNullOrWhiteSpace(_DataRow["STATISTICS_TYPE"].ToString()) &&
|
||
_DataRow["STATISTICS_TYPE"].ToString().Contains("1020"))
|
||
{
|
||
_WPDShopEndAccountList.TRANSFER_TYPE = 3;
|
||
}
|
||
_WPDShopEndAccountList.ENDACCOUNT_STARTDATE = _DataRow["ENDACCOUNT_STARTDATE"].ToString();
|
||
_WPDShopEndAccountList.ENDACCOUNT_DATE = _DataRow["ENDACCOUNT_DATE"].ToString();
|
||
_WPDShopEndAccountList.DESCRIPTION_STAFF = _DataRow["DESCRIPTION_STAFF"].ToString();
|
||
_WPDShopEndAccountList.DIFFERENCE_REASON = _DataRow["DIFFERENCE_REASON"].ToString();
|
||
_WPDShopEndAccountList.DESCRIPTION_DATE = _DataRow["DESCRIPTION_DATE"].ToString();
|
||
_WPDShopEndAccountList.APPROVE_STAFF = _DataRow["APPROVE_STAFF"].ToString();
|
||
_WPDShopEndAccountList.APPROVED_INFO = _DataRow["APPROVED_INFO"].ToString();
|
||
_WPDShopEndAccountList.APPROVE_DATE = _DataRow["APPROVE_DATE"].ToString();
|
||
if (!string.IsNullOrWhiteSpace(_DataRow["FACTAMOUNT_SALE"].ToString()))
|
||
{
|
||
_WPDShopEndAccountList.FACTAMOUNT_SALE = _DataRow["FACTAMOUNT_SALE"].ToString().TryParseToDecimal();
|
||
}
|
||
if (!string.IsNullOrWhiteSpace(_DataRow["FACTAMOUNT_CIGARETTE"].ToString()))
|
||
{
|
||
_WPDShopEndAccountList.FACTAMOUNT_CIGARETTE = _DataRow["FACTAMOUNT_CIGARETTE"].ToString().TryParseToDecimal();
|
||
}
|
||
if (!string.IsNullOrWhiteSpace(_DataRow["CHECK_COUNT"].ToString()))
|
||
{
|
||
_WPDShopEndAccountList.CHECK_COUNT = _DataRow["CHECK_COUNT"].ToString().TryParseToDecimal();
|
||
}
|
||
_WPDShopEndAccountList.DIFFERENT_PRICE = _DataRow["DIFFERENT_PRICE"].ToString().TryParseToDecimal();
|
||
_WPDShopEndAccountList.CASHPAY_DOWNLORD = _DataRow["CASHPAY_DOWNLORD"].ToString().TryParseToDecimal();//现金缴款金额
|
||
_WPDShopEndAccountList.MOBILEPAYMENT = _DataRow["MOBILEPAYMENT"].ToString().TryParseToDecimal();
|
||
_WPDShopEndAccountList.CASHPAY = _DataRow["CASHPAY"].ToString().TryParseToDecimal();
|
||
_ShopEndaccount.CASHPAY_TOTAL += _WPDShopEndAccountList.CASHPAY;
|
||
|
||
bool AbnormalState = Math.Abs(_DataRow["DIFFERENT_PRICE"].ToString().TryParseToDouble() /
|
||
_DataRow["TOTALSELLAMOUNT"].ToString().TryParseToDouble()) > 0.003;
|
||
if (AbnormalState)
|
||
{
|
||
if (_WPDShopEndAccountList.DIFFERENT_PRICE > 0)
|
||
{
|
||
_ShopEndaccount.SHOWMORE_SIGN = 2;
|
||
}
|
||
else if (_WPDShopEndAccountList.DIFFERENT_PRICE < 0)
|
||
{
|
||
_ShopEndaccount.SHOWLESS_SIGN = 2;
|
||
}
|
||
}
|
||
else if (_ShopEndaccount.SHOWMORE_SIGN == 0)
|
||
{
|
||
if (_WPDShopEndAccountList.DIFFERENT_PRICE > 0)
|
||
{
|
||
_ShopEndaccount.SHOWMORE_SIGN = 1;
|
||
}
|
||
else if (_WPDShopEndAccountList.DIFFERENT_PRICE < 0)
|
||
{
|
||
_ShopEndaccount.SHOWLESS_SIGN = 1;
|
||
}
|
||
}
|
||
if (_ShopEndaccount.ShopEndAccountList == null)
|
||
{
|
||
_ShopEndaccount.ShopEndAccountList = new List<Model.WPDShopEndAccountList>();
|
||
}
|
||
_ShopEndaccount.ShopEndAccountList.Add(_WPDShopEndAccountList);
|
||
}
|
||
#endregion
|
||
}
|
||
|
||
return listModel;
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 获取服务区营收信息
|
||
/// <summary>
|
||
/// 获取服务区营收信息
|
||
/// </summary>
|
||
/// <param name="transaction">事务</param>
|
||
/// <param name="staticticsTime">统计时间</param>
|
||
/// <param name="serverpartId">服务区Id,可为空</param>
|
||
/// <returns></returns>
|
||
public static DataTable GetServerpartRevenue(Transaction transaction, DateTime staticticsTime, int? serverpartId = null)
|
||
{
|
||
#region 查询条件
|
||
string sqlWhere = "";
|
||
string sqlWhere2 = "";
|
||
if (serverpartId != null)
|
||
{
|
||
sqlWhere += " AND A.SERVERPART_ID = " + serverpartId;//服务区Id
|
||
}
|
||
if (staticticsTime != DateTime.MinValue)
|
||
{
|
||
sqlWhere2 += " AND TRUNC(C.ENDACCOUNT_DATE) = TRUNC(TO_DATE('" + staticticsTime + "','YYYY/MM/DD HH24:MI:SS'))";//结账时间
|
||
}
|
||
#endregion
|
||
|
||
//查询服务区商户信息
|
||
DataTable dataTable = new HWSB.SERVERPARTSHOP(transaction).ExecuteDataTable($@"
|
||
SELECT
|
||
SUM(FACTAMOUNT) AS FACTAMOUNT,SERVERPART_ID,SERVERPART_NAME
|
||
FROM
|
||
(
|
||
SELECT
|
||
A.SERVERPART_ID,A.SERVERPART_NAME,NVL(C.CASHPAY,0) AS FACTAMOUNT
|
||
FROM
|
||
HIGHWAY_STORAGE.T_SERVERPART A,
|
||
HIGHWAY_STORAGE.T_SERVERPARTSHOP B
|
||
LEFT JOIN
|
||
HIGHWAY_SELLDATA.T_ENDACCOUNT_TEMP C
|
||
ON
|
||
B.SERVERPART_ID = C.SERVERPART_ID AND C.VALID = 1 AND
|
||
B.SHOPCODE = C.SHOPCODE {sqlWhere2}
|
||
WHERE
|
||
A.SERVERPART_ID = B.SERVERPART_ID AND B.ISVALID = 1 AND B.BUSINESS_STATE = 1000 AND
|
||
B.STATISTIC_TYPE = 1000 AND B.SHOPTRADE IS NOT NULL {sqlWhere}
|
||
UNION ALL
|
||
SELECT
|
||
A.SERVERPART_ID,A.SERVERPART_NAME,NVL(C.CASHPAY,0) AS FACTAMOUNT
|
||
FROM
|
||
HIGHWAY_STORAGE.T_SERVERPART A,
|
||
HIGHWAY_STORAGE.T_SERVERPARTSHOP B,
|
||
HIGHWAY_SELLDATA.T_ENDACCOUNT_TEMP C
|
||
WHERE
|
||
A.SERVERPART_ID = B.SERVERPART_ID AND B.ISVALID = 1 AND B.STATISTIC_TYPE = 1000 AND
|
||
B.SERVERPART_ID = C.SERVERPART_ID AND C.VALID = 1 AND B.SHOPCODE = C.SHOPCODE AND
|
||
B.BUSINESS_STATE != 1000 AND B.SHOPTRADE IS NOT NULL AND NVL(C.CASHPAY,0)> 0
|
||
{sqlWhere2} {sqlWhere}
|
||
)
|
||
GROUP BY
|
||
SERVERPART_ID,SERVERPART_NAME");
|
||
return dataTable;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 统计服务区营收信息
|
||
/// </summary>
|
||
/// <param name="BrandTable">经营品牌营收额数据</param>
|
||
/// <returns></returns>
|
||
public static DataTable GetServerpartRevenue(DataTable BrandTable)
|
||
{
|
||
DataTable ServerpartTable = new DataTable();
|
||
ServerpartTable.Columns.Add("SERVERPART_ID", typeof(decimal)); //当前服务区内码
|
||
ServerpartTable.Columns.Add("SERVERPART_NAME", typeof(string)); //当前服务区名称
|
||
ServerpartTable.Columns.Add("FACTAMOUNT", typeof(decimal)); //当前服务区营收信息
|
||
|
||
#region 统计经营业态营收额
|
||
var query = from t in BrandTable.AsEnumerable()
|
||
group t by new
|
||
{
|
||
t1 = t.Field<decimal>("SERVERPART_ID"),
|
||
t2 = t.Field<string>("SERVERPART_NAME")
|
||
} into m
|
||
select new
|
||
{
|
||
SERVERPART_ID = m.Key.t1,
|
||
SERVERPART_NAME = m.Key.t2,
|
||
FACTAMOUNT = m.Sum(n => n.Field<decimal>("FACTAMOUNT"))
|
||
};
|
||
if (query.ToList().Count > 0)
|
||
{
|
||
query.ToList().ForEach(q =>
|
||
{
|
||
DataRow _DataRow = ServerpartTable.NewRow();
|
||
|
||
_DataRow["SERVERPART_ID"] = q.SERVERPART_ID;
|
||
_DataRow["SERVERPART_NAME"] = q.SERVERPART_NAME;
|
||
_DataRow["FACTAMOUNT"] = q.FACTAMOUNT;
|
||
|
||
ServerpartTable.Rows.Add(_DataRow);
|
||
});
|
||
}
|
||
#endregion
|
||
|
||
return ServerpartTable;
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 获取服务区业态品牌列表
|
||
/// <summary>
|
||
/// 获取服务区业态品牌列表
|
||
/// </summary>
|
||
/// <param name="transaction">事务</param>
|
||
/// <param name="pushProvinceCode">省份编码</param>
|
||
/// <returns></returns>
|
||
public static DataTable GetBrandList(Transaction transaction, string pushProvinceCode = "")
|
||
{
|
||
//查询服务区商户信息
|
||
DataTable dataTable = new CMB.BRAND(transaction).FillDataTable("WHERE BRAND_STATE = 1" +
|
||
(string.IsNullOrWhiteSpace(pushProvinceCode) ? "" : " AND PROVINCE_CODE = " + pushProvinceCode));
|
||
return dataTable;
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 获取服务区经营业态列表
|
||
/// <summary>
|
||
/// 获取服务区业态品牌列表
|
||
/// </summary>
|
||
/// <param name="transaction">事务</param>
|
||
/// <param name="pushProvinceCode">省份编码</param>
|
||
/// <returns></returns>
|
||
public static DataTable GetBusinessList(Transaction transaction, string pushProvinceCode = "")
|
||
{
|
||
//查询服务区商户信息
|
||
DataTable dataTable = new CMB.AUTOSTATISTICS(transaction).FillDataTable("WHERE AUTOSTATISTICS_TYPE = 2000" +
|
||
(string.IsNullOrWhiteSpace(pushProvinceCode) ? "" : " AND PROVINCE_CODE = " + pushProvinceCode));
|
||
return dataTable;
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 获取服务区上级业态信息
|
||
/// <summary>
|
||
/// 获取服务区上级业态信息
|
||
/// </summary>
|
||
/// <param name="transaction">事务</param>
|
||
/// <param name="businessTypeLevel">业态等级</param>
|
||
/// <param name="pushProvinceCode">省份</param>
|
||
/// <returns></returns>
|
||
public static DataTable GetBusinessInfo(Transaction transaction, int businessTypeLevel, string pushProvinceCode)
|
||
{
|
||
DataTable businessTypeTable = new DataTable();
|
||
businessTypeTable.Columns.Add("AUTOSTATISTICS_NAME");
|
||
businessTypeTable.Columns.Add("AUTOSTATISTICS_ID");
|
||
businessTypeTable.Columns.Add("AUTOSTATISTICS_IDS");
|
||
|
||
//查询服务区业态信息
|
||
DataTable dataTable = new CMB.AUTOSTATISTICS(transaction).ExecuteDataTable($@"
|
||
SELECT
|
||
A.AUTOSTATISTICS_NAME,A.AUTOSTATISTICS_ID,A.AUTOSTATISTICS_PID,
|
||
WM_CONCAT(B.AUTOSTATISTICS_ID) AS AUTOSTATISTICS_IDS
|
||
FROM
|
||
COOP_MERCHANT.T_AUTOSTATISTICS A
|
||
LEFT JOIN
|
||
COOP_MERCHANT.T_AUTOSTATISTICS B
|
||
ON
|
||
A.AUTOSTATISTICS_ID = B.AUTOSTATISTICS_PID
|
||
WHERE
|
||
A.PROVINCE_CODE = {pushProvinceCode} AND A.AUTOSTATISTICS_TYPE = 2000
|
||
GROUP BY
|
||
A.AUTOSTATISTICS_NAME,A.AUTOSTATISTICS_ID,A.AUTOSTATISTICS_PID");
|
||
|
||
string Pid = "-1";
|
||
for (int i = 0; i < businessTypeLevel; i++)
|
||
{
|
||
DataRow[] _Row = dataTable.Select("AUTOSTATISTICS_PID IN (" + Pid + ") ");
|
||
if (_Row.Length > 0)
|
||
{
|
||
Pid = "";
|
||
foreach (DataRow _DataRow in _Row)
|
||
{
|
||
Pid += (Pid == "" ? "" : ",") + _DataRow["AUTOSTATISTICS_ID"];
|
||
}
|
||
}
|
||
}
|
||
|
||
foreach (string _AUTOSTATISTICS_ID in Pid.Split(','))
|
||
{
|
||
DataRow dataRow = businessTypeTable.NewRow();
|
||
DataRow[] _Row = dataTable.Select("AUTOSTATISTICS_ID = " + _AUTOSTATISTICS_ID);
|
||
dataRow["AUTOSTATISTICS_NAME"] = _Row[0]["AUTOSTATISTICS_NAME"];
|
||
dataRow["AUTOSTATISTICS_ID"] = _Row[0]["AUTOSTATISTICS_ID"];
|
||
dataRow["AUTOSTATISTICS_IDS"] = _Row[0]["AUTOSTATISTICS_IDS"].ToString() == "" ?
|
||
_Row[0]["AUTOSTATISTICS_ID"] : _Row[0]["AUTOSTATISTICS_IDS"];
|
||
businessTypeTable.Rows.Add(dataRow);
|
||
}
|
||
|
||
DataRow NewRowS = businessTypeTable.NewRow();
|
||
NewRowS["AUTOSTATISTICS_NAME"] = "其他类";
|
||
NewRowS["AUTOSTATISTICS_ID"] = -1;
|
||
NewRowS["AUTOSTATISTICS_IDS"] = "-1";
|
||
businessTypeTable.Rows.Add(NewRowS);
|
||
|
||
return businessTypeTable;
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 上传HighWay图片数据
|
||
/// <summary>
|
||
/// 上传HighWay图片数据
|
||
/// </summary>
|
||
/// <param name="_Transaction">事务管理器</param>
|
||
/// <param name="Base64Str">base64位码字符串</param>
|
||
/// <param name="Table_Id">表内码</param>
|
||
/// <param name="Table_Name">表名</param>
|
||
/// <param name="FilePath">文件存储路径</param>
|
||
public static void UploadHWSImage(Transaction _Transaction,
|
||
string Base64Str, int Table_Id, string Table_Name, string FilePath)
|
||
{
|
||
#region 上传图片
|
||
if (!string.IsNullOrEmpty(Base64Str))
|
||
{
|
||
try
|
||
{
|
||
//解析传入的base64位码,并存储图片于服务器
|
||
foreach (string _base64str in Base64Str.Split('|'))
|
||
{
|
||
string ImgStr = _base64str;
|
||
HWSB.IMAGE _IMAGE = new HWSB.IMAGE(_Transaction);
|
||
_IMAGE.IMAGE_TYPE = 1000;
|
||
//获取当前接口url地址
|
||
Uri URLAddress = HttpContext.Current.Request.Url;
|
||
if (ImgStr.Split(";base64,").Length > 1)
|
||
{
|
||
ImgStr = ImgStr.Split(";base64,")[1];
|
||
}
|
||
//去除base64码中特殊字符(【%->空】【,->空】【 ->+】)
|
||
ImgStr = ImgStr.Trim().Replace("%", "").Replace(",", "").Replace(" ", "+");
|
||
//以当前时间戳命名文件名称,防止文件出现重名导致保存失败
|
||
string FileName = DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss_ffff");
|
||
byte[] _byte = Convert.FromBase64String(ImgStr);
|
||
if (!Directory.Exists(HttpContext.Current.Server.MapPath("~" + FilePath)))
|
||
{
|
||
Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~" + FilePath));
|
||
}
|
||
//将图片保存至服务器本地
|
||
bool flag = UploadImg(_byte, HttpContext.Current.Server.MapPath("~" + FilePath), FileName);
|
||
//图片路径
|
||
_IMAGE.IMAGE_PATH = FilePath + FileName + ".jpg";
|
||
//图片完整地址
|
||
_IMAGE.IMAGE_URL = URLAddress.Scheme + "://" + URLAddress.Authority + _IMAGE.IMAGE_PATH;
|
||
if (flag)
|
||
{
|
||
//图片地址:补充图片名称
|
||
_IMAGE.IMAGE_PATH = FilePath + FileName + ".jpg";
|
||
//图片完整路径:补充图片名称
|
||
_IMAGE.IMAGE_URL = _EShangPlatformApiUrls + _IMAGE.IMAGE_PATH;
|
||
//图片名称
|
||
_IMAGE.IMAGE_TITLE = FileName;
|
||
//存储结账单内码
|
||
_IMAGE.Table_ID = Table_Id;
|
||
//存储结账单表名
|
||
_IMAGE.Table_Name = Table_Name;
|
||
//图片上传时间
|
||
_IMAGE.IMAGE_DATE = DateTime.Now;
|
||
_IMAGE.ISVALID = 1;
|
||
_IMAGE.Insert();
|
||
}
|
||
else
|
||
{
|
||
_Transaction.Rollback();
|
||
}
|
||
}
|
||
}
|
||
catch { }
|
||
}
|
||
#endregion
|
||
}
|
||
|
||
#region 方法 -> 存储图片文件
|
||
/// <summary>
|
||
/// 存储图片文件
|
||
/// </summary>
|
||
/// <param name="fileBytes"></param>
|
||
/// <param name="FilePath"></param>
|
||
/// <param name="FileName"></param>
|
||
/// <returns></returns>
|
||
public static bool UploadImg(byte[] fileBytes, string FilePath, string FileName)
|
||
{
|
||
bool flag = false;
|
||
try
|
||
{
|
||
string filePath = FilePath + FileName + ".jpg"; //图片要保存的路径及文件名
|
||
using (MemoryStream memoryStream = new MemoryStream(fileBytes))//1.定义并实例化一个内存流,以存放提交上来的字节数组。
|
||
{
|
||
using (FileStream fileUpload = new FileStream(filePath, FileMode.Create))//2.定义实际文件对象,保存上载的文件。
|
||
{
|
||
memoryStream.WriteTo(fileUpload); //3.把内存流里的数据写入物理文件
|
||
flag = true;
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
SuperMap.RealEstate.Utility.ErrorLogHelper.Write(ex);
|
||
}
|
||
return flag;
|
||
}
|
||
#endregion
|
||
|
||
#endregion
|
||
|
||
#region 方法 -> 上传小程序商品详情图片数据
|
||
/// <summary>
|
||
/// 上传HighWay图片数据
|
||
/// </summary>
|
||
/// <param name="_Transaction">事务管理器</param>
|
||
/// <param name="Base64Str">base64位码字符串</param>
|
||
/// <param name="Table_Id">表内码</param>
|
||
/// <param name="Table_Name">表名</param>
|
||
/// <param name="FilePath">路径</param>
|
||
public static void AppletUploadImage(Transaction _Transaction,
|
||
string Base64Str, int Table_Id, string Table_Name, string FilePath)
|
||
{
|
||
#region 上传图片
|
||
if (!string.IsNullOrEmpty(Base64Str))
|
||
{
|
||
try
|
||
{
|
||
//解析传入的base64位码,并存储图片于服务器
|
||
foreach (string _base64str in Base64Str.Split('|'))
|
||
{
|
||
string ImgStr = _base64str;
|
||
CMB.IMAGE _IMAGE = new CMB.IMAGE(_Transaction);
|
||
_IMAGE.IMAGE_TYPE = 2000;
|
||
//获取当前接口url地址
|
||
Uri URLAddress = HttpContext.Current.Request.Url;
|
||
if (ImgStr.Split(";base64,").Length > 1)
|
||
{
|
||
ImgStr = ImgStr.Split(";base64,")[1];
|
||
}
|
||
//去除base64码中特殊字符(【%->空】【,->空】【 ->+】)
|
||
ImgStr = ImgStr.Trim().Replace("%", "").Replace(",", "").Replace(" ", "+");
|
||
//以当前时间戳命名文件名称,防止文件出现重名导致保存失败
|
||
string FileName = DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss_ffff");
|
||
byte[] _byte = Convert.FromBase64String(ImgStr);
|
||
if (!Directory.Exists(HttpContext.Current.Server.MapPath("~" + FilePath)))
|
||
{
|
||
Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~" + FilePath));
|
||
}
|
||
//将图片保存至服务器本地
|
||
bool flag = AppletUploadImg(_byte, HttpContext.Current.Server.MapPath("~" + FilePath), FileName);
|
||
//图片路径
|
||
_IMAGE.IMAGE_PATH = FilePath + FileName + ".jpg";
|
||
//图片完整地址
|
||
_IMAGE.IMAGE_URL = URLAddress.Scheme + "://" + URLAddress.Authority + _IMAGE.IMAGE_PATH;
|
||
if (flag)
|
||
{
|
||
//图片地址:补充图片名称
|
||
_IMAGE.IMAGE_PATH = FilePath + FileName + ".jpg";
|
||
//图片完整路径:补充图片名称
|
||
_IMAGE.IMAGE_URL = _EShangPlatformApiUrls + _IMAGE.IMAGE_PATH;
|
||
//图片名称
|
||
_IMAGE.IMAGE_TITLE = FileName;
|
||
//存储商品ID
|
||
_IMAGE.TABLE_ID = Table_Id;
|
||
//存储商品表名
|
||
_IMAGE.TABLE_NAME = Table_Name;
|
||
//图片上传时间
|
||
_IMAGE.IMAGE_DATE = DateTime.Now;
|
||
_IMAGE.ISVALID = 1;
|
||
_IMAGE.Insert();
|
||
}
|
||
else
|
||
{
|
||
_Transaction.Rollback();
|
||
}
|
||
}
|
||
}
|
||
catch { }
|
||
}
|
||
#endregion
|
||
}
|
||
|
||
#region 方法 -> 存储图片文件
|
||
/// <summary>
|
||
/// 存储图片文件
|
||
/// </summary>
|
||
/// <param name="fileBytes"></param>
|
||
/// <param name="FilePath"></param>
|
||
/// <param name="FileName"></param>
|
||
/// <returns></returns>
|
||
public static bool AppletUploadImg(byte[] fileBytes, string FilePath, string FileName)
|
||
{
|
||
bool flag = false;
|
||
try
|
||
{
|
||
string filePath = FilePath + FileName + ".jpg"; //图片要保存的路径及文件名
|
||
using (MemoryStream memoryStream = new MemoryStream(fileBytes))//1.定义并实例化一个内存流,以存放提交上来的字节数组。
|
||
{
|
||
using (FileStream fileUpload = new FileStream(filePath, FileMode.Create))//2.定义实际文件对象,保存上载的文件。
|
||
{
|
||
memoryStream.WriteTo(fileUpload); ///3.把内存流里的数据写入物理文件
|
||
flag = true;
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
SuperMap.RealEstate.Utility.ErrorLogHelper.Write(ex);
|
||
}
|
||
return flag;
|
||
}
|
||
#endregion
|
||
|
||
#endregion
|
||
}
|
||
}
|