TradeDaySummaryService.cs 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. /*
  2. * 交易日汇总
  3. */
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Data;
  8. using MySystem.Models.Main;
  9. using Library;
  10. using LitJson;
  11. namespace MySystem.Service.Main
  12. {
  13. public class TradeDaySummaryService
  14. {
  15. static string _conn = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
  16. /// <summary>
  17. /// 查询列表
  18. /// </summary>
  19. /// <param name="relationData">关联表</param>
  20. /// <param name="condition">查询条件(sql语句)</param>
  21. /// <param name="count">总数(输出)</param>
  22. /// <param name="page">页码</param>
  23. /// <param name="limit">每页条数</param>
  24. /// <returns></returns>
  25. 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")
  26. {
  27. List<string> fields = new List<string>(); //要显示的列
  28. fields.Add("Id");
  29. fields.Add("CreateDate"); //添加时间
  30. fields.Add("Status"); //状态
  31. fields.Add("UserId"); //创客
  32. fields.Add("TradeDate"); //交易日
  33. fields.Add("TradeMonth"); //交易月
  34. fields.Add("NotHelpDirectTradeAmt"); //直营商户交易总额(非扶持期)
  35. fields.Add("NotHelpNonDirectTradeAmt"); //非直营商户交易总额(非扶持期)
  36. fields.Add("NotHelpDirectCreditTradeAmt"); //直营贷记卡交易总额(非扶持期)
  37. fields.Add("NotHelpNonDirectCreditTradeAmt"); //非直营贷记卡交易总额(非扶持期)
  38. fields.Add("NotHelpDirectQrCreditTradeAmt"); //直营云闪付贷记卡交易额(非扶持期)
  39. fields.Add("NotHelpNonDirectQrCreditTradeAmt"); //非直营云闪付贷记卡交易额(非扶持期)
  40. fields.Add("NotHelpDirectNonQrCreditTradeAmt"); //直营非云闪付贷记卡交易额(非扶持期)
  41. fields.Add("NotHelpNonDirectNonQrCreditTradeAmt"); //非直营非云闪付贷记卡交易额(非扶持期)
  42. fields.Add("NotHelpDirectDebitTradeAmt"); //直营商户借记卡交易总额(非扶持期)
  43. fields.Add("NotHelpDirectDebitCapTradeAmt"); //直营商户借记卡封顶交易总金额(非扶持期)
  44. fields.Add("NotHelpDirectDebitCapNum"); //直营商户借记卡封顶交易总数(非扶持期)
  45. fields.Add("NotHelpNonDirectDebitTradeAmt"); //非直营商户借记卡交易总额(非扶持期)
  46. fields.Add("NotHelpNonDirectDebitCapTradeAmt"); //非直营商户借记卡封顶交易总金额(非扶持期)
  47. fields.Add("NotHelpNonDirectDebitCapNum"); //非直营商户借记卡封顶交易总数(非扶持期)
  48. fields.Add("NotHelpDirectQrDebitTradeAmt"); //直营云闪付非封顶借记卡(非扶持期)
  49. fields.Add("NotHelpNonDirectQrDebitTradeAmt"); //非直营云闪付非封顶借记卡(非扶持期)
  50. fields.Add("NotHelpDirectNonQrDebitTradeAmt"); //直营非云闪付非封顶借记卡(非扶持期)
  51. fields.Add("NotHelpNonDirectNonQrDebitTradeAmt"); //非直营非云闪付非封顶借记卡(非扶持期)
  52. fields.Add("HelpDirectTradeAmt"); //直营商户交易总额(扶持期)
  53. fields.Add("HelpNonDirectTradeAmt"); //非直营商户交易总额(扶持期)
  54. fields.Add("HelpDirectCreditTradeAmt"); //直营贷记卡交易总额(扶持期)
  55. fields.Add("HelpNonDirectCreditTradeAmt"); //非直营贷记卡交易总额(扶持期)
  56. fields.Add("HelpDirectQrCreditTradeAmt"); //直营云闪付贷记卡交易额(扶持期)
  57. fields.Add("HelpNonDirectQrCreditTradeAmt"); //非直营云闪付贷记卡交易额(扶持期)
  58. fields.Add("HelpDirectNonQrCreditTradeAmt"); //直营非云闪付贷记卡交易额(扶持期)
  59. fields.Add("HelpNonDirectNonQrCreditTradeAmt"); //非直营非云闪付贷记卡交易额(扶持期)
  60. fields.Add("HelpDirectDebitTradeAmt"); //直营商户借记卡交易总额(扶持期)
  61. fields.Add("HelpDirectDebitCapTradeAmt"); //直营商户借记卡封顶交易总金额(扶持期)
  62. fields.Add("HelpDirectDebitCapNum"); //直营商户借记卡封顶交易总数(扶持期)
  63. fields.Add("HelpNonDirectDebitTradeAmt"); //非直营商户借记卡交易总额(扶持期)
  64. fields.Add("HelpNonDirectDebitCapTradeAmt"); //非直营商户借记卡封顶交易总金额(扶持期)
  65. fields.Add("HelpNonDirectDebitCapNum"); //非直营商户借记卡封顶交易总数(扶持期)
  66. fields.Add("HelpDirectQrDebitTradeAmt"); //直营云闪付非封顶借记卡(扶持期)
  67. fields.Add("HelpNonDirectQrDebitTradeAmt"); //非直营云闪付非封顶借记卡(扶持期)
  68. fields.Add("HelpDirectNonQrDebitTradeAmt"); //直营非云闪付非封顶借记卡(扶持期)
  69. fields.Add("HelpNonDirectNonQrDebitTradeAmt"); //非直营非云闪付非封顶借记卡(扶持期)
  70. fields.Add("VipFlag"); //会员标记
  71. fields.Add("PayType"); //支付方式
  72. fields.Add("ProfitDirectTradeAmt"); //直营商户交易总额(盈利期)
  73. fields.Add("ProfitNonDirectTradeAmt"); //非直营商户交易总额(盈利期)
  74. fields.Add("ProfitDirectCreditTradeAmt"); //直营贷记卡交易总额(盈利期)
  75. fields.Add("ProfitNonDirectCreditTradeAmt"); //非直营贷记卡交易总额(盈利期)
  76. fields.Add("ProfitDirectQrCreditTradeAmt"); //直营云闪付贷记卡交易额(盈利期)
  77. fields.Add("ProfitNonDirectQrCreditTradeAmt"); //非直营云闪付贷记卡交易额(盈利期)
  78. fields.Add("ProfitDirectNonQrCreditTradeAmt"); //直营非云闪付贷记卡交易额(盈利期)
  79. fields.Add("ProfitNonDirectNonQrCreditTradeAmt"); //非直营非云闪付贷记卡交易额(盈利期)
  80. fields.Add("ProfitDirectDebitTradeAmt"); //直营商户借记卡交易总额(盈利期)
  81. fields.Add("ProfitDirectDebitCapTradeAmt"); //直营商户借记卡封顶交易总金额(盈利期)
  82. fields.Add("ProfitDirectDebitCapNum"); //直营商户借记卡封顶交易总数(盈利期)
  83. fields.Add("ProfitNonDirectDebitTradeAmt"); //非直营商户借记卡交易总额(盈利期)
  84. fields.Add("ProfitNonDirectDebitCapTradeAmt"); //非直营商户借记卡封顶交易总金额(盈利期)
  85. fields.Add("ProfitNonDirectDebitCapNum"); //非直营商户借记卡封顶交易总数(盈利期)
  86. fields.Add("ProfitDirectQrDebitTradeAmt"); //直营云闪付非封顶借记卡(盈利期)
  87. fields.Add("ProfitNonDirectQrDebitTradeAmt"); //非直营云闪付非封顶借记卡(盈利期)
  88. fields.Add("ProfitDirectNonQrDebitTradeAmt"); //直营非云闪付非封顶借记卡(盈利期)
  89. fields.Add("ProfitNonDirectNonQrDebitTradeAmt"); //非直营非云闪付非封顶借记卡(盈利期)
  90. Dictionary<string, object> obj = new DbService(AppConfig.Base.mainTables, _conn).IndexData("TradeDaySummary", relationData, orderBy, page, limit, condition, fields);
  91. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  92. count = int.Parse(obj["count"].ToString());
  93. return diclist;
  94. }
  95. public static List<Dictionary<string, object>> List(List<RelationData> relationData, string condition, int page = 1, int limit = 30, string orderBy = "Sort desc,Id desc")
  96. {
  97. List<string> fields = new List<string>(); //要显示的列
  98. fields.Add("Id");
  99. fields.Add("CreateDate"); //添加时间
  100. fields.Add("Status"); //状态
  101. fields.Add("UserId"); //创客
  102. fields.Add("TradeDate"); //交易日
  103. fields.Add("TradeMonth"); //交易月
  104. fields.Add("NotHelpDirectTradeAmt"); //直营商户交易总额(非扶持期)
  105. fields.Add("NotHelpNonDirectTradeAmt"); //非直营商户交易总额(非扶持期)
  106. fields.Add("NotHelpDirectCreditTradeAmt"); //直营贷记卡交易总额(非扶持期)
  107. fields.Add("NotHelpNonDirectCreditTradeAmt"); //非直营贷记卡交易总额(非扶持期)
  108. fields.Add("NotHelpDirectQrCreditTradeAmt"); //直营云闪付贷记卡交易额(非扶持期)
  109. fields.Add("NotHelpNonDirectQrCreditTradeAmt"); //非直营云闪付贷记卡交易额(非扶持期)
  110. fields.Add("NotHelpDirectNonQrCreditTradeAmt"); //直营非云闪付贷记卡交易额(非扶持期)
  111. fields.Add("NotHelpNonDirectNonQrCreditTradeAmt"); //非直营非云闪付贷记卡交易额(非扶持期)
  112. fields.Add("NotHelpDirectDebitTradeAmt"); //直营商户借记卡交易总额(非扶持期)
  113. fields.Add("NotHelpDirectDebitCapTradeAmt"); //直营商户借记卡封顶交易总金额(非扶持期)
  114. fields.Add("NotHelpDirectDebitCapNum"); //直营商户借记卡封顶交易总数(非扶持期)
  115. fields.Add("NotHelpNonDirectDebitTradeAmt"); //非直营商户借记卡交易总额(非扶持期)
  116. fields.Add("NotHelpNonDirectDebitCapTradeAmt"); //非直营商户借记卡封顶交易总金额(非扶持期)
  117. fields.Add("NotHelpNonDirectDebitCapNum"); //非直营商户借记卡封顶交易总数(非扶持期)
  118. fields.Add("NotHelpDirectQrDebitTradeAmt"); //直营云闪付非封顶借记卡(非扶持期)
  119. fields.Add("NotHelpNonDirectQrDebitTradeAmt"); //非直营云闪付非封顶借记卡(非扶持期)
  120. fields.Add("NotHelpDirectNonQrDebitTradeAmt"); //直营非云闪付非封顶借记卡(非扶持期)
  121. fields.Add("NotHelpNonDirectNonQrDebitTradeAmt"); //非直营非云闪付非封顶借记卡(非扶持期)
  122. fields.Add("HelpDirectTradeAmt"); //直营商户交易总额(扶持期)
  123. fields.Add("HelpNonDirectTradeAmt"); //非直营商户交易总额(扶持期)
  124. fields.Add("HelpDirectCreditTradeAmt"); //直营贷记卡交易总额(扶持期)
  125. fields.Add("HelpNonDirectCreditTradeAmt"); //非直营贷记卡交易总额(扶持期)
  126. fields.Add("HelpDirectQrCreditTradeAmt"); //直营云闪付贷记卡交易额(扶持期)
  127. fields.Add("HelpNonDirectQrCreditTradeAmt"); //非直营云闪付贷记卡交易额(扶持期)
  128. fields.Add("HelpDirectNonQrCreditTradeAmt"); //直营非云闪付贷记卡交易额(扶持期)
  129. fields.Add("HelpNonDirectNonQrCreditTradeAmt"); //非直营非云闪付贷记卡交易额(扶持期)
  130. fields.Add("HelpDirectDebitTradeAmt"); //直营商户借记卡交易总额(扶持期)
  131. fields.Add("HelpDirectDebitCapTradeAmt"); //直营商户借记卡封顶交易总金额(扶持期)
  132. fields.Add("HelpDirectDebitCapNum"); //直营商户借记卡封顶交易总数(扶持期)
  133. fields.Add("HelpNonDirectDebitTradeAmt"); //非直营商户借记卡交易总额(扶持期)
  134. fields.Add("HelpNonDirectDebitCapTradeAmt"); //非直营商户借记卡封顶交易总金额(扶持期)
  135. fields.Add("HelpNonDirectDebitCapNum"); //非直营商户借记卡封顶交易总数(扶持期)
  136. fields.Add("HelpDirectQrDebitTradeAmt"); //直营云闪付非封顶借记卡(扶持期)
  137. fields.Add("HelpNonDirectQrDebitTradeAmt"); //非直营云闪付非封顶借记卡(扶持期)
  138. fields.Add("HelpDirectNonQrDebitTradeAmt"); //直营非云闪付非封顶借记卡(扶持期)
  139. fields.Add("HelpNonDirectNonQrDebitTradeAmt"); //非直营非云闪付非封顶借记卡(扶持期)
  140. fields.Add("VipFlag"); //会员标记
  141. fields.Add("PayType"); //支付方式
  142. fields.Add("ProfitDirectTradeAmt"); //直营商户交易总额(盈利期)
  143. fields.Add("ProfitNonDirectTradeAmt"); //非直营商户交易总额(盈利期)
  144. fields.Add("ProfitDirectCreditTradeAmt"); //直营贷记卡交易总额(盈利期)
  145. fields.Add("ProfitNonDirectCreditTradeAmt"); //非直营贷记卡交易总额(盈利期)
  146. fields.Add("ProfitDirectQrCreditTradeAmt"); //直营云闪付贷记卡交易额(盈利期)
  147. fields.Add("ProfitNonDirectQrCreditTradeAmt"); //非直营云闪付贷记卡交易额(盈利期)
  148. fields.Add("ProfitDirectNonQrCreditTradeAmt"); //直营非云闪付贷记卡交易额(盈利期)
  149. fields.Add("ProfitNonDirectNonQrCreditTradeAmt"); //非直营非云闪付贷记卡交易额(盈利期)
  150. fields.Add("ProfitDirectDebitTradeAmt"); //直营商户借记卡交易总额(盈利期)
  151. fields.Add("ProfitDirectDebitCapTradeAmt"); //直营商户借记卡封顶交易总金额(盈利期)
  152. fields.Add("ProfitDirectDebitCapNum"); //直营商户借记卡封顶交易总数(盈利期)
  153. fields.Add("ProfitNonDirectDebitTradeAmt"); //非直营商户借记卡交易总额(盈利期)
  154. fields.Add("ProfitNonDirectDebitCapTradeAmt"); //非直营商户借记卡封顶交易总金额(盈利期)
  155. fields.Add("ProfitNonDirectDebitCapNum"); //非直营商户借记卡封顶交易总数(盈利期)
  156. fields.Add("ProfitDirectQrDebitTradeAmt"); //直营云闪付非封顶借记卡(盈利期)
  157. fields.Add("ProfitNonDirectQrDebitTradeAmt"); //非直营云闪付非封顶借记卡(盈利期)
  158. fields.Add("ProfitDirectNonQrDebitTradeAmt"); //直营非云闪付非封顶借记卡(盈利期)
  159. fields.Add("ProfitNonDirectNonQrDebitTradeAmt"); //非直营非云闪付非封顶借记卡(盈利期)
  160. Dictionary<string, object> obj = new DbService(AppConfig.Base.mainTables, _conn).IndexData("TradeDaySummary", relationData, orderBy, page, limit, condition, fields);
  161. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  162. return diclist;
  163. }
  164. /// <summary>
  165. /// 查询一条记录
  166. /// </summary>
  167. /// <param name="Id">主键Id</param>
  168. /// <returns></returns>
  169. public static TradeDaySummary Query(int Id)
  170. {
  171. WebCMSEntities db = new WebCMSEntities();
  172. TradeDaySummary editData = db.TradeDaySummary.FirstOrDefault(m => m.Id == Id) ?? new TradeDaySummary();
  173. db.Dispose();
  174. return editData;
  175. }
  176. /// <summary>
  177. /// 查询创客交易额
  178. /// </summary>
  179. /// <param name="UserId"></param>
  180. /// <param name="sTradeDate"></param>
  181. /// <param name="eTradeDate"></param>
  182. /// <param name="BrandId"></param>
  183. /// <returns></returns>
  184. public static Dictionary<string, object> GetMonthTradeForBrand(int UserId, string sTradeDate, string eTradeDate, int BrandId)
  185. {
  186. WebCMSEntities db = new WebCMSEntities();
  187. string condition = " and Status>-1";
  188. string cons = " and Status>=-1";
  189. //产品类型
  190. if (!string.IsNullOrEmpty(BrandId.ToString()) && BrandId > 0)
  191. {
  192. condition += " and BrandId =" + BrandId;
  193. cons += " and BrandId =" + BrandId;
  194. }
  195. //创客Id
  196. if (!string.IsNullOrEmpty(UserId.ToString()))
  197. {
  198. condition += " and UserId =" + UserId;
  199. }
  200. //开始时间
  201. if (!string.IsNullOrEmpty(sTradeDate) && !string.IsNullOrEmpty(eTradeDate))
  202. {
  203. condition += " and TradeDate >=" + Convert.ToInt32(sTradeDate) + " and TradeDate <=" + Convert.ToInt32(eTradeDate);
  204. cons += " and SeoKeyword >=" + Convert.ToInt32(sTradeDate) + " and SeoKeyword <=" + Convert.ToInt32(eTradeDate);
  205. }
  206. //结束时间
  207. else
  208. {
  209. var start = DateTime.Now.ToString("yyyyMM") + "01";
  210. condition += " and TradeDate >=" + Convert.ToInt32(start) + " and TradeDate <=" + Convert.ToInt32(eTradeDate);
  211. cons += " and SeoKeyword >=" + Convert.ToInt32(start) + " and SeoKeyword <=" + Convert.ToInt32(eTradeDate);
  212. }
  213. //扶持期
  214. decimal TotalAmtfc = 0;
  215. decimal DAmtfc = 0;
  216. decimal JAmtfc = 0;
  217. decimal JfAmtfc = 0;
  218. int JCountfc = 0;
  219. decimal YAmtfc = 0;
  220. //稳定期
  221. decimal TotalAmtwd = 0;
  222. decimal DAmtwd = 0;
  223. decimal JAmtwd = 0;
  224. decimal JfAmtwd = 0;
  225. int JCountwd = 0;
  226. decimal YAmtwd = 0;
  227. //盈利期
  228. decimal TotalAmtyl = 0;
  229. decimal DAmtyl = 0;
  230. decimal JAmtyl = 0;
  231. decimal JfAmtyl = 0;
  232. int JCountyl = 0;
  233. decimal YAmtyl = 0;
  234. int BCount = 0;
  235. int ACount = 0;
  236. int PBCount = 0;
  237. int PACount = 0;
  238. int TBCount = 0;
  239. int TACount = 0;
  240. Dictionary<string, object> obj = new Dictionary<string, object>();
  241. DataTable dt = CustomerSqlConn.dtable("SELECT Sum(HelpNonDirectTradeAmt + HelpNonDirectDebitTradeAmt),Sum(if (QueryCount = 0,HelpNonDirectTradeAmt,0)),Sum(if (QueryCount = 0,HelpNonDirectDebitTradeAmt - HelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,HelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,HelpNonDirectDebitCapNum,0)),Sum(if (QueryCount = 1,HelpNonDirectTradeAmt,0)),Sum(NotHelpNonDirectTradeAmt + NotHelpNonDirectDebitTradeAmt),Sum(if (QueryCount = 0,NotHelpNonDirectTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpNonDirectDebitTradeAmt - NotHelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpNonDirectDebitCapNum,0)),Sum(if (QueryCount = 1,NotHelpNonDirectTradeAmt,0)),Sum(ProfitNonDirectTradeAmt + ProfitNonDirectDebitTradeAmt),Sum(if (QueryCount = 0,ProfitNonDirectTradeAmt,0)),Sum(if (QueryCount = 0,ProfitNonDirectDebitTradeAmt - ProfitNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,ProfitNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,ProfitNonDirectDebitCapNum,0)),Sum(if (QueryCount = 1,ProfitNonDirectTradeAmt,0))from TradeDaySummary where SeoTitle = 'team'" + condition, AppConfig.Base.SqlConnStr);
  242. if (dt.Rows.Count > 0)
  243. {
  244. TotalAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString()));
  245. DAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][1].ToString()));
  246. JAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][2].ToString()));
  247. JfAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][3].ToString()));
  248. JCountfc = Convert.ToInt32(function.CheckInt(dt.Rows[0][4].ToString()));
  249. YAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][5].ToString()));
  250. TotalAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][6].ToString()));
  251. DAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][7].ToString()));
  252. JAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][8].ToString()));
  253. JfAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][9].ToString()));
  254. JCountwd = Convert.ToInt32(function.CheckInt(dt.Rows[0][10].ToString()));
  255. YAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][11].ToString()));
  256. TotalAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][12].ToString()));
  257. DAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][13].ToString()));
  258. JAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][14].ToString()));
  259. JfAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][15].ToString()));
  260. JCountyl = Convert.ToInt32(function.CheckInt(dt.Rows[0][16].ToString()));
  261. YAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][17].ToString()));
  262. }
  263. //统计激活数(个人、团队)
  264. dt = CustomerSqlConn.dtable("SELECT SUM(if(SeoTitle='team',ActiveBuddyMerStatus,0)) FROM UserTradeMonthSummary WHERE UserId= '" + UserId + "'" + cons, AppConfig.Base.SqlConnStr);
  265. if (dt.Rows.Count > 0)
  266. {
  267. TACount = Convert.ToInt32(function.CheckNum(dt.Rows[0][0].ToString()));
  268. }
  269. obj.Add("TotalAmtfc", TotalAmtfc);
  270. obj.Add("DAmtfc", DAmtfc);
  271. obj.Add("JAmtfc", JAmtfc);
  272. obj.Add("JfAmtfc", JfAmtfc);
  273. obj.Add("JCountfc", JCountfc);
  274. obj.Add("YAmtfc", YAmtfc);
  275. obj.Add("TotalAmtwd", TotalAmtwd);
  276. obj.Add("DAmtwd", DAmtwd);
  277. obj.Add("JAmtwd", JAmtwd);
  278. obj.Add("JfAmtwd", JfAmtwd);
  279. obj.Add("JCountwd", JCountwd);
  280. obj.Add("YAmtwd", YAmtwd);
  281. obj.Add("TotalAmtyl", TotalAmtyl);
  282. obj.Add("DAmtyl", DAmtyl);
  283. obj.Add("JAmtyl", JAmtyl);
  284. obj.Add("JfAmtyl", JfAmtyl);
  285. obj.Add("JCountyl", JCountyl);
  286. obj.Add("YAmtyl", YAmtyl);
  287. obj.Add("BCount", BCount);
  288. obj.Add("ACount", ACount);
  289. obj.Add("PBCount", PBCount);
  290. obj.Add("PACount", PACount);
  291. obj.Add("TBCount", TBCount);
  292. obj.Add("TACount", TACount);
  293. db.Dispose();
  294. return obj;
  295. }
  296. /// <summary>
  297. /// 查询创客交易额统计
  298. /// </summary>
  299. /// <param name="UserId"></param>
  300. /// <param name="Con"></param>
  301. /// <param name="Cons"></param>
  302. /// <returns></returns>
  303. public static Dictionary<string, object> GetSumTitleMonthTrade(int UserId, string Con, string Cons)
  304. {
  305. WebCMSEntities db = new WebCMSEntities();
  306. //个人
  307. //扶持期
  308. decimal TotalAmtfc = 0;
  309. decimal DAmtfc = 0;
  310. decimal JAmtfc = 0;
  311. decimal JfAmtfc = 0;
  312. int JCountfc = 0;
  313. decimal YAmtfc = 0;
  314. //稳定期
  315. decimal TotalAmtwd = 0;
  316. decimal DAmtwd = 0;
  317. decimal JAmtwd = 0;
  318. decimal JfAmtwd = 0;
  319. int JCountwd = 0;
  320. decimal YAmtwd = 0;
  321. //盈利期
  322. decimal TotalAmtyl = 0;
  323. decimal DAmtyl = 0;
  324. decimal JAmtyl = 0;
  325. decimal JfAmtyl = 0;
  326. int JCountyl = 0;
  327. decimal YAmtyl = 0;
  328. //团队
  329. //扶持期
  330. decimal TotalAmtfc1 = 0;
  331. decimal DAmtfc1 = 0;
  332. decimal JAmtfc1 = 0;
  333. decimal JfAmtfc1 = 0;
  334. int JCountfc1 = 0;
  335. decimal YAmtfc1 = 0;
  336. //稳定期
  337. decimal TotalAmtwd1 = 0;
  338. decimal DAmtwd1 = 0;
  339. decimal JAmtwd1 = 0;
  340. decimal JfAmtwd1 = 0;
  341. int JCountwd1 = 0;
  342. decimal YAmtwd1 = 0;
  343. //盈利期
  344. decimal TotalAmtyl1 = 0;
  345. decimal DAmtyl1 = 0;
  346. decimal JAmtyl1 = 0;
  347. decimal JfAmtyl1 = 0;
  348. int JCountyl1 = 0;
  349. decimal YAmtyl1 = 0;
  350. int PBCount = 0;
  351. int PACount = 0;
  352. int TBCount = 0;
  353. int TACount = 0;
  354. Dictionary<string, object> obj = new Dictionary<string, object>();
  355. DataTable dt = CustomerSqlConn.dtable("SELECT Sum(HelpDirectTradeAmt + HelpDirectDebitTradeAmt),Sum(if (QueryCount = 0,HelpDirectTradeAmt,0)),Sum(if (QueryCount = 0,HelpDirectDebitTradeAmt - HelpDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,HelpDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,HelpDirectDebitCapNum,0)),Sum(if (QueryCount = 1,HelpDirectTradeAmt,0)),Sum(NotHelpDirectTradeAmt + NotHelpDirectDebitTradeAmt),Sum(if (QueryCount = 0,NotHelpDirectTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpDirectDebitTradeAmt - NotHelpDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpDirectDebitCapNum,0)),Sum(if (QueryCount = 1,NotHelpDirectTradeAmt,0)),Sum(ProfitDirectTradeAmt + ProfitDirectDebitTradeAmt),Sum(if (QueryCount = 0,ProfitDirectTradeAmt,0)),Sum(if (QueryCount = 0,ProfitDirectDebitTradeAmt - ProfitDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,ProfitDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,ProfitDirectDebitCapNum,0)),Sum(if (QueryCount = 1,ProfitDirectTradeAmt,0))from TradeDaySummary where SeoTitle = 'self' and UserId =" + UserId + "" + Con, AppConfig.Base.SqlConnStr);
  356. if (dt.Rows.Count > 0)
  357. {
  358. TotalAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString()));
  359. DAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][1].ToString()));
  360. JAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][2].ToString()));
  361. JfAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][3].ToString()));
  362. JCountfc = Convert.ToInt32(function.CheckInt(dt.Rows[0][4].ToString()));
  363. YAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][5].ToString()));
  364. TotalAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][6].ToString()));
  365. DAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][7].ToString()));
  366. JAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][8].ToString()));
  367. JfAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][9].ToString()));
  368. JCountwd = Convert.ToInt32(function.CheckInt(dt.Rows[0][10].ToString()));
  369. YAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][11].ToString()));
  370. TotalAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][12].ToString()));
  371. DAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][13].ToString()));
  372. JAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][14].ToString()));
  373. JfAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][15].ToString()));
  374. JCountyl = Convert.ToInt32(function.CheckInt(dt.Rows[0][16].ToString()));
  375. YAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][17].ToString()));
  376. }
  377. //统计激活数(个人、团队)
  378. dt = CustomerSqlConn.dtable("SELECT SUM(if(SeoTitle='self',ActiveBuddyMerStatus,0)),SUM(if(SeoTitle='team',ActiveBuddyMerStatus,0)) FROM UserTradeMonthSummary WHERE UserId= " + UserId + "" + Cons, AppConfig.Base.SqlConnStr);
  379. if (dt.Rows.Count > 0)
  380. {
  381. PACount = Convert.ToInt32(function.CheckNum(dt.Rows[0][0].ToString()));
  382. TACount = Convert.ToInt32(function.CheckNum(dt.Rows[0][1].ToString()));
  383. }
  384. DataTable dts = CustomerSqlConn.dtable("SELECT Sum(HelpNonDirectTradeAmt + HelpNonDirectDebitTradeAmt),Sum(if (QueryCount = 0,HelpNonDirectTradeAmt,0)),Sum(if (QueryCount = 0,HelpNonDirectDebitTradeAmt - HelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,HelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,HelpNonDirectDebitCapNum,0)),Sum(if (QueryCount = 1,HelpNonDirectTradeAmt,0)),Sum(NotHelpNonDirectTradeAmt + NotHelpNonDirectDebitTradeAmt),Sum(if (QueryCount = 0,NotHelpNonDirectTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpNonDirectDebitTradeAmt - NotHelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpNonDirectDebitCapNum,0)),Sum(if (QueryCount = 1,NotHelpNonDirectTradeAmt,0)),Sum(ProfitNonDirectTradeAmt + ProfitNonDirectDebitTradeAmt),Sum(if (QueryCount = 0,ProfitNonDirectTradeAmt,0)),Sum(if (QueryCount = 0,ProfitNonDirectDebitTradeAmt - ProfitNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,ProfitNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,ProfitNonDirectDebitCapNum,0)),Sum(if (QueryCount = 1,ProfitNonDirectTradeAmt,0))from TradeDaySummary where SeoTitle = 'team' and UserId =" + UserId + "" + Con, AppConfig.Base.SqlConnStr);
  385. if (dts.Rows.Count > 0)
  386. {
  387. TotalAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][0].ToString()));
  388. DAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][1].ToString()));
  389. JAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][2].ToString()));
  390. JfAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][3].ToString()));
  391. JCountfc1 = Convert.ToInt32(function.CheckInt(dts.Rows[0][4].ToString()));
  392. YAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][5].ToString()));
  393. TotalAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][6].ToString()));
  394. DAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][7].ToString()));
  395. JAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][8].ToString()));
  396. JfAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][9].ToString()));
  397. JCountwd1 = Convert.ToInt32(function.CheckInt(dts.Rows[0][10].ToString()));
  398. YAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][11].ToString()));
  399. TotalAmtyl1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][12].ToString()));
  400. DAmtyl1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][13].ToString()));
  401. JAmtyl1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][14].ToString()));
  402. JfAmtyl1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][15].ToString()));
  403. JCountyl1 = Convert.ToInt32(function.CheckInt(dts.Rows[0][16].ToString()));
  404. YAmtyl1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][17].ToString()));
  405. }
  406. obj.Add("TotalAmtfc", TotalAmtfc);
  407. obj.Add("DAmtfc", DAmtfc);
  408. obj.Add("JAmtfc", JAmtfc);
  409. obj.Add("JfAmtfc", JfAmtfc);
  410. obj.Add("JCountfc", JCountfc);
  411. obj.Add("YAmtfc", YAmtfc);
  412. obj.Add("TotalAmtwd", TotalAmtwd);
  413. obj.Add("DAmtwd", DAmtwd);
  414. obj.Add("JAmtwd", JAmtwd);
  415. obj.Add("JfAmtwd", JfAmtwd);
  416. obj.Add("JCountwd", JCountwd);
  417. obj.Add("YAmtwd", YAmtwd);
  418. obj.Add("TotalAmtyl", TotalAmtyl);
  419. obj.Add("DAmtyl", DAmtyl);
  420. obj.Add("JAmtyl", JAmtyl);
  421. obj.Add("JfAmtyl", JfAmtyl);
  422. obj.Add("JCountyl", JCountyl);
  423. obj.Add("YAmtyl", YAmtyl);
  424. obj.Add("TotalAmtfc1", TotalAmtfc1);
  425. obj.Add("DAmtfc1", DAmtfc1);
  426. obj.Add("JAmtfc1", JAmtfc1);
  427. obj.Add("JfAmtfc1", JfAmtfc1);
  428. obj.Add("JCountfc1", JCountfc1);
  429. obj.Add("YAmtfc1", YAmtfc1);
  430. obj.Add("TotalAmtwd1", TotalAmtwd1);
  431. obj.Add("DAmtwd1", DAmtwd1);
  432. obj.Add("JAmtwd1", JAmtwd1);
  433. obj.Add("JfAmtwd1", JfAmtwd1);
  434. obj.Add("JCountwd1", JCountwd1);
  435. obj.Add("YAmtwd1", YAmtwd1);
  436. obj.Add("TotalAmtyl1", TotalAmtyl1);
  437. obj.Add("DAmtyl1", DAmtyl1);
  438. obj.Add("JAmtyl1", JAmtyl1);
  439. obj.Add("JfAmtyl1", JfAmtyl1);
  440. obj.Add("JCountyl1", JCountyl1);
  441. obj.Add("YAmtyl1", YAmtyl1);
  442. obj.Add("PBCount", PBCount);
  443. obj.Add("PACount", PACount);
  444. obj.Add("TBCount", TBCount);
  445. obj.Add("TACount", TACount);
  446. db.Dispose();
  447. return obj;
  448. }
  449. /// <summary>
  450. /// 查询记录数
  451. /// </summary>
  452. /// <param name="Id">主键Id</param>
  453. /// <returns></returns>
  454. public static int Count(string condition = "")
  455. {
  456. int result = 0;
  457. DataTable dt = CustomerSqlConn.dtable("select count(Id) from TradeDaySummary where 1=1" + condition, _conn);
  458. if (dt.Rows.Count > 0)
  459. {
  460. result = int.Parse(function.CheckInt(dt.Rows[0][0].ToString()));
  461. }
  462. return result;
  463. }
  464. /// <summary>
  465. /// 查询是否存在
  466. /// </summary>
  467. /// <param name="Id">主键Id</param>
  468. /// <returns></returns>
  469. public static bool Exist(int Id)
  470. {
  471. WebCMSEntities db = new WebCMSEntities();
  472. bool check = db.TradeDaySummary.Any(m => m.Id == Id);
  473. db.Dispose();
  474. return check;
  475. }
  476. /// <summary>
  477. /// 添加数据
  478. /// </summary>
  479. /// <param name="Fields">要设置的字段</param>
  480. /// <returns></returns>
  481. public static AppResultJson Add(Dictionary<string, object> fields, bool check = true)
  482. {
  483. if (check)
  484. {
  485. }
  486. int Id = new DbService(AppConfig.Base.mainTables, _conn).Add("TradeDaySummary", fields, 0);
  487. return new AppResultJson() { Status = "1", Data = Id };
  488. }
  489. /// <summary>
  490. /// 修改数据
  491. /// </summary>
  492. /// <param name="Fields">要设置的字段</param>
  493. /// <param name="Id">主键Id</param>
  494. public static AppResultJson Edit(Dictionary<string, object> fields, int Id, bool check = true)
  495. {
  496. if (check)
  497. {
  498. }
  499. new DbService(AppConfig.Base.mainTables, _conn).Edit("TradeDaySummary", fields, Id);
  500. return new AppResultJson() { Status = "1", Data = Id };
  501. }
  502. /// <summary>
  503. /// 逻辑删除
  504. /// </summary>
  505. /// <param name="Id">主键Id</param>
  506. public static void Remove(int Id)
  507. {
  508. Dictionary<string, object> fields = new Dictionary<string, object>();
  509. fields.Add("Status", -1);
  510. new DbService(AppConfig.Base.mainTables, _conn).Edit("TradeDaySummary", fields, Id);
  511. }
  512. /// <summary>
  513. /// 删除数据
  514. /// </summary>
  515. /// <param name="Id">主键Id</param>
  516. public static void Delete(int Id)
  517. {
  518. new DbService(AppConfig.Base.mainTables, _conn).Delete("TradeDaySummary", Id);
  519. }
  520. /// <summary>
  521. /// 排序
  522. /// </summary>
  523. /// <param name="Id">主键Id</param>
  524. /// <param name="Sort">排序序号</param>
  525. public static void Sort(int Id, int Sort)
  526. {
  527. new DbService(AppConfig.Base.mainTables, _conn).Sort("TradeDaySummary", Sort, Id);
  528. }
  529. /// <summary>
  530. /// 导入数据
  531. /// </summary>
  532. /// <param name="ExcelData">json数据</param>
  533. public static void Import(string ExcelData)
  534. {
  535. WebCMSEntities db = new WebCMSEntities();
  536. JsonData list = JsonMapper.ToObject(ExcelData);
  537. for (int i = 1; i < list.Count; i++)
  538. {
  539. JsonData dr = list[i];
  540. db.TradeDaySummary.Add(new TradeDaySummary()
  541. {
  542. CreateDate = DateTime.Now,
  543. UpdateDate = DateTime.Now,
  544. });
  545. db.SaveChanges();
  546. }
  547. db.Dispose();
  548. }
  549. /// <summary>
  550. /// 导出excel表格
  551. /// </summary>
  552. /// <param name="fields">查询条件(单个字段)</param>
  553. /// <param name="condition">查询条件(sql语句)</param>
  554. /// <returns></returns>
  555. // public static void ExportExcel(List<RelationData> relationData, string condition)
  556. // {
  557. // }
  558. }
  559. }