PosPushDataNewHelper.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Library;
  5. using MySystem.SpModels;
  6. namespace MySystem
  7. {
  8. public class PosPushDataNewHelper
  9. {
  10. public readonly static PosPushDataNewHelper Instance = new PosPushDataNewHelper();
  11. private PosPushDataNewHelper()
  12. { }
  13. //绑定数据
  14. public static void Bind(Merchants mer, string rnd = "")
  15. {
  16. try
  17. {
  18. string ProductType = mer.ProductType;
  19. if (ProductType == "30" && mer.SeoTitle == "PAPER_CODE") ProductType = "51";
  20. if(ProductType == "22")
  21. {
  22. ProductType = GetLiShuaBrand(mer.SnNo);
  23. }
  24. string MerNo = mer.MerNo;
  25. if(ProductType == "51")
  26. {
  27. MerNo = mer.Field5;
  28. }
  29. Dictionary<string, object> dataContent = new Dictionary<string, object>();
  30. dataContent.Add("pos_sn", mer.SnNo); //机具sn
  31. dataContent.Add("mer_no", MerNo); //商户号
  32. dataContent.Add("id_card", mer.MerIdcardNo); //商户身份证
  33. dataContent.Add("mer_name", mer.MerName); //商户姓名
  34. dataContent.Add("mer_mobile", mer.MerMobile); //商户手机号
  35. dataContent.Add("request_id", getRequestId(mer.SnNo + MerNo + rnd, "bind")); //流水号
  36. dataContent.Add("bind_time", mer.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss")); //绑定时间
  37. dataContent.Add("brand", int.Parse(function.CheckInt(ProductType))); //品牌
  38. if(ProductType == "29")
  39. {
  40. dataContent.Add("user_id", mer.QueryCount); //创客ID
  41. }
  42. if(ProductType == "51")
  43. {
  44. Push("qr_bind", dataContent);
  45. }
  46. else
  47. {
  48. Push("bind", dataContent);
  49. }
  50. }
  51. catch (Exception ex)
  52. {
  53. Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n\n", "推送绑定数据异常");
  54. }
  55. }
  56. public static void Bind0(BindRecord mer)
  57. {
  58. try
  59. {
  60. if(mer.ProductType == "22")
  61. {
  62. mer.ProductType = GetLiShuaBrand(mer.MerSnNo);
  63. }
  64. Dictionary<string, object> dataContent = new Dictionary<string, object>();
  65. dataContent.Add("pos_sn", mer.MerSnNo); //机具sn
  66. dataContent.Add("mer_no", mer.MerNo); //商户号
  67. dataContent.Add("id_card", ""); //商户身份证
  68. dataContent.Add("mer_name", mer.MerName); //商户姓名
  69. dataContent.Add("mer_mobile", mer.MerNo); //商户手机号
  70. dataContent.Add("request_id", getRequestId(mer.Id, "bind")); //流水号
  71. dataContent.Add("bind_time", mer.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss")); //绑定时间
  72. dataContent.Add("brand", int.Parse(function.CheckInt(mer.ProductType))); //品牌
  73. Push("bind", dataContent);
  74. }
  75. catch (Exception ex)
  76. {
  77. Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n\n", "推送绑定数据异常");
  78. }
  79. }
  80. public static void Bind2(MerchantRecord mer)
  81. {
  82. try
  83. {
  84. if(mer.ProductType == "22")
  85. {
  86. mer.ProductType = GetLiShuaBrand(mer.MerSnNo);
  87. }
  88. Dictionary<string, object> dataContent = new Dictionary<string, object>();
  89. dataContent.Add("pos_sn", mer.MerSnNo); //机具sn
  90. dataContent.Add("mer_no", mer.MerNo); //商户号
  91. dataContent.Add("id_card", mer.LegalIdCard); //商户身份证
  92. dataContent.Add("mer_name", mer.MerName); //商户姓名
  93. dataContent.Add("mer_mobile", ""); //商户手机号
  94. dataContent.Add("request_id", getRequestId(mer.Id, "merchant")); //流水号
  95. dataContent.Add("bind_time", mer.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss")); //绑定时间
  96. dataContent.Add("brand", int.Parse(function.CheckInt(mer.ProductType))); //品牌
  97. Push("bind", dataContent);
  98. }
  99. catch (Exception ex)
  100. {
  101. Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n\n", "推送绑定数据异常");
  102. }
  103. }
  104. //解绑数据
  105. public static void UnBind(UnBindRecord mer)
  106. {
  107. try
  108. {
  109. Dictionary<string, object> dataContent = new Dictionary<string, object>();
  110. dataContent.Add("pos_sn", mer.MerSnNo); //机具sn
  111. dataContent.Add("mer_no", mer.MerNo); //商户号
  112. dataContent.Add("request_id", getRequestId(mer.Id, "unbind")); //流水号
  113. dataContent.Add("un_bind_time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); //绑定时间
  114. dataContent.Add("brand", int.Parse(function.CheckInt(mer.ProductType))); //品牌
  115. Push("un_bind", dataContent);
  116. }
  117. catch (Exception ex)
  118. {
  119. Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n\n", "推送解绑数据异常");
  120. }
  121. }
  122. //换绑数据
  123. public static void ChangeBind(ChangeBindRecord mer)
  124. {
  125. try
  126. {
  127. Dictionary<string, object> dataContent = new Dictionary<string, object>();
  128. dataContent.Add("request_id", getRequestId(mer.Id, "changebind")); //流水号
  129. dataContent.Add("mer_no", mer.MerNo); //商户号
  130. dataContent.Add("source_pos_sn", mer.MerSnNo); //来源机具sn
  131. dataContent.Add("source_brand", int.Parse(function.CheckInt(mer.ProductType))); //来源品牌
  132. dataContent.Add("to_pos_sn", mer.MerNewSnNo); //兑换机具sn
  133. dataContent.Add("to_brand", int.Parse(function.CheckInt(mer.ProductType))); //兑换品牌
  134. dataContent.Add("change_bind_time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); //换绑时间
  135. Push("change_bind", dataContent);
  136. }
  137. catch (Exception ex)
  138. {
  139. Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n\n", "推送换绑数据异常");
  140. }
  141. }
  142. //押金数据
  143. public static void Deposit(ActivateRecord act)
  144. {
  145. try
  146. {
  147. List<string> BrandIds = new List<string>();
  148. decimal TradeAmount = decimal.Parse(function.CheckNum(act.SeoTitle));
  149. BrandIds.Add("1");
  150. BrandIds.Add("4");
  151. BrandIds.Add("6");
  152. BrandIds.Add("8");
  153. BrandIds.Add("9");
  154. BrandIds.Add("15");
  155. BrandIds.Add("22");
  156. BrandIds.Add("27");
  157. BrandIds.Add("30");
  158. BrandIds.Add("33");
  159. if(BrandIds.Contains(act.ProductType))
  160. {
  161. TradeAmount = TradeAmount / 100;
  162. }
  163. if(act.ProductType == "22")
  164. {
  165. act.ProductType = GetLiShuaBrand(act.SnNo);
  166. }
  167. Dictionary<string, object> dataContent = new Dictionary<string, object>();
  168. dataContent.Add("pos_sn", act.SnNo); //机具sn
  169. dataContent.Add("mer_no", act.MerNo); //商户号
  170. if(Utils.Instance.IsWifi(int.Parse(act.ProductType)) || Utils.Instance.IsHaoDa(int.Parse(act.ProductType)))
  171. {
  172. dataContent.Add("request_id", getRequestId(act.SnNo + act.MerMobile, "deposit")); //流水号
  173. }
  174. else
  175. {
  176. dataContent.Add("request_id", getRequestId(act.Id, "deposit")); //流水号
  177. }
  178. if(act.ProductType == "14")
  179. {
  180. dataContent.Add("deposit_amount", 0); //押金金额
  181. }
  182. else
  183. {
  184. dataContent.Add("deposit_amount", TradeAmount); //押金金额
  185. }
  186. dataContent.Add("trade_time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); //交易时间
  187. dataContent.Add("card_type", 1); //卡类型
  188. dataContent.Add("brand", int.Parse(function.CheckInt(act.ProductType))); //品牌
  189. if(act.ProductType == "29")
  190. {
  191. dataContent.Add("ext_field", act.Field4); //押金活动编码
  192. }
  193. else if(act.ProductType == "36")
  194. {
  195. dataContent.Add("ext_field", act.Field3); //奖励金额
  196. }
  197. else if(act.ProductType == "14" && (function.CheckNull(act.SeoKeyword).Contains("双百套餐") || act.SnNo.StartsWith("CS")))
  198. {
  199. dataContent.Add("fee_amt", TradeAmount); //秒到费
  200. }
  201. Push("deposit", dataContent);
  202. }
  203. catch (Exception ex)
  204. {
  205. Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n\n", "推送押金数据异常");
  206. }
  207. }
  208. public static void Deposit(TradeRecord trade)
  209. {
  210. try
  211. {
  212. List<string> BrandIds = new List<string>();
  213. decimal TradeAmount = trade.TradeAmount;
  214. BrandIds.Add("1");
  215. BrandIds.Add("4");
  216. BrandIds.Add("6");
  217. // BrandIds.Add("7");
  218. BrandIds.Add("8");
  219. BrandIds.Add("9");
  220. BrandIds.Add("15");
  221. BrandIds.Add("22");
  222. BrandIds.Add("27");
  223. BrandIds.Add("30");
  224. BrandIds.Add("33");
  225. if(BrandIds.Contains(trade.ProductType))
  226. {
  227. TradeAmount = TradeAmount / 100;
  228. }
  229. if(trade.ProductType == "22")
  230. {
  231. trade.ProductType = GetLiShuaBrand(trade.TradeSnNo);
  232. }
  233. Dictionary<string, object> dataContent = new Dictionary<string, object>();
  234. dataContent.Add("pos_sn", trade.TradeSnNo); //机具sn
  235. dataContent.Add("mer_no", trade.MerNo); //商户号
  236. dataContent.Add("request_id", getRequestId(trade.Id, "deposit1")); //流水号
  237. dataContent.Add("deposit_amount", TradeAmount); //押金金额
  238. dataContent.Add("trade_time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); //交易时间
  239. dataContent.Add("card_type", 1); //卡类型
  240. dataContent.Add("brand", int.Parse(function.CheckInt(trade.ProductType))); //品牌
  241. Push("deposit", dataContent);
  242. }
  243. catch (Exception ex)
  244. {
  245. Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n\n", "推送押金数据异常");
  246. }
  247. }
  248. //激活数据
  249. public static void Active(ActivateRecord act)
  250. {
  251. try
  252. {
  253. if(act.ProductType == "22")
  254. {
  255. act.ProductType = GetLiShuaBrand(act.SnNo);
  256. }
  257. Dictionary<string, object> dataContent = new Dictionary<string, object>();
  258. dataContent.Add("pos_sn", act.SnNo); //机具sn
  259. dataContent.Add("mobile", act.MerMobile); //商户号
  260. dataContent.Add("request_id", getRequestId(act.Id, "active")); //流水号
  261. dataContent.Add("activation_time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); //激活时间
  262. dataContent.Add("brand", int.Parse(function.CheckInt(act.ProductType))); //品牌
  263. Push("active", dataContent);
  264. }
  265. catch (Exception ex)
  266. {
  267. Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n\n", "推送激活数据异常");
  268. }
  269. }
  270. //交易数据
  271. public static void Trade(TradeRecord trade)
  272. {
  273. try
  274. {
  275. string ProductType = trade.ProductType;
  276. if (ProductType == "30" && trade.TradeSnNo.StartsWith("LKLYSMZCFYH")) ProductType = "51";
  277. int QrPayFlag = 0;
  278. int BankCardType = 1;
  279. string FeeRate = function.CheckNum(trade.ErrorCode);
  280. string FeeAmt = function.CheckNum(trade.ErrorMsg);
  281. if (ProductType == "51")
  282. {
  283. FeeRate = "0.63";
  284. FeeAmt = "3";
  285. }
  286. List<string> BrandIds = new List<string>();
  287. decimal TradeAmount = trade.TradeAmount;
  288. BrandIds.Add("1");
  289. BrandIds.Add("4");
  290. BrandIds.Add("6");
  291. BrandIds.Add("7");
  292. BrandIds.Add("8");
  293. BrandIds.Add("9");
  294. BrandIds.Add("15");
  295. BrandIds.Add("22");
  296. BrandIds.Add("27");
  297. BrandIds.Add("30");
  298. BrandIds.Add("33");
  299. BrandIds.Add("51");
  300. if(BrandIds.Contains(ProductType))
  301. {
  302. TradeAmount = TradeAmount / 100;
  303. }
  304. if(ProductType == "22")
  305. {
  306. ProductType = GetLiShuaBrand(trade.TradeSnNo);
  307. }
  308. if (ProductType == "1" || ProductType == "27")
  309. {
  310. if (trade.TradeType == "02") QrPayFlag = 1;
  311. BankCardType = int.Parse(trade.BankCardType);
  312. decimal feeRateStr = decimal.Parse(FeeRate) * 100;
  313. FeeRate = feeRateStr.ToString().TrimEnd('0');
  314. if(FeeRate != "0") FeeRate = FeeRate.TrimEnd('0');
  315. if(FeeAmt != "0" && !string.IsNullOrEmpty(FeeAmt)) FeeAmt = FeeAmt.TrimEnd('0');
  316. }
  317. else if (ProductType == "2")
  318. {
  319. if (trade.TradeType == "CLOUD_PAY") QrPayFlag = 1;
  320. if (trade.TradeType == "CREDIT_BY_CARD")
  321. {
  322. BankCardType = 1;
  323. }
  324. else
  325. {
  326. BankCardType = 0;
  327. }
  328. FeeRate = FeeRate.Replace("0.00", "0.");
  329. }
  330. else if (ProductType == "4")
  331. {
  332. if (trade.TradeType == "200") QrPayFlag = 1;
  333. if (trade.BankCardType == "100")
  334. {
  335. BankCardType = 1;
  336. }
  337. else if (trade.BankCardType == "200")
  338. {
  339. BankCardType = 0;
  340. }
  341. decimal feeRateStr = decimal.Parse(FeeRate) / 10000;
  342. FeeRate = feeRateStr.ToString().TrimEnd('0');
  343. if(FeeRate != "0") FeeRate = FeeRate.TrimEnd('0');
  344. if(FeeAmt != "0" && !string.IsNullOrEmpty(FeeAmt)) FeeAmt = FeeAmt.TrimEnd('0');
  345. }
  346. else if (ProductType == "6" || ProductType == "22" || ProductType == "33")
  347. {
  348. if (trade.BankCardType == "02" || trade.BankCardType == "12" || trade.BankCardType == "30" || trade.BankCardType == "31" || trade.BankCardType == "M3" || trade.Field2 == "1517")
  349. {
  350. BankCardType = 1;
  351. }
  352. else
  353. {
  354. BankCardType = 0;
  355. }
  356. }
  357. else if (ProductType == "7")
  358. {
  359. if (trade.BankCardType == "OA" || trade.BankCardType == "CC" || trade.BankCardType == "SCC")
  360. {
  361. BankCardType = 1;
  362. }
  363. else
  364. {
  365. BankCardType = 0;
  366. }
  367. }
  368. else if (ProductType == "8" || ProductType == "9")
  369. {
  370. if (trade.TradeType == "200") QrPayFlag = 1;
  371. if (trade.BankCardType == "100")
  372. {
  373. BankCardType = 1;
  374. }
  375. else if (trade.BankCardType == "200")
  376. {
  377. BankCardType = 0;
  378. }
  379. decimal feeRateStr = decimal.Parse(FeeRate) / 10000;
  380. FeeRate = feeRateStr.ToString().TrimEnd('0');
  381. if(FeeRate != "0") FeeRate = FeeRate.TrimEnd('0');
  382. if(FeeAmt != "0" && !string.IsNullOrEmpty(FeeAmt)) FeeAmt = FeeAmt.TrimEnd('0');
  383. }
  384. else if (ProductType == "10" || ProductType == "11")
  385. {
  386. if (trade.TradeType == "F010") QrPayFlag = 1;
  387. if (trade.BankCardType == "01")
  388. {
  389. BankCardType = 1;
  390. }
  391. else if (trade.BankCardType == "00")
  392. {
  393. BankCardType = 0;
  394. }
  395. FeeRate = FeeRate.Replace("0.00", "0.");
  396. }
  397. else if (ProductType == "12") //盒易付
  398. {
  399. if (trade.Field3 == "1") QrPayFlag = 1;
  400. if (trade.BankCardType == "C" || trade.TradeType == "1" || trade.TradeType == "2" || trade.TradeType == "3")
  401. {
  402. BankCardType = 1;
  403. }
  404. else if (trade.BankCardType == "D")
  405. {
  406. BankCardType = 0;
  407. }
  408. }
  409. else if (ProductType == "15")
  410. {
  411. if (trade.BankCardType == "02")
  412. {
  413. BankCardType = 1;
  414. }
  415. else
  416. {
  417. BankCardType = 0;
  418. }
  419. if(FeeAmt != "0") FeeAmt = FeeAmt.TrimEnd('0');
  420. }
  421. else if (ProductType == "30" || ProductType == "51") //拉卡拉
  422. {
  423. if (trade.BankCardType == "01" || trade.BankCardType == "61" || trade.BankCardType == "91" || trade.BankCardType == "92")
  424. {
  425. BankCardType = 1;
  426. }
  427. else
  428. {
  429. BankCardType = 0;
  430. }
  431. }
  432. else if (ProductType == "34") //联动掌中宝
  433. {
  434. if (trade.TradeType == "QuickPass") QrPayFlag = 1;
  435. if (trade.BankCardType == "CC" || trade.TradeType == "AliPay" || trade.TradeType == "Wechat")
  436. {
  437. BankCardType = 1;
  438. }
  439. else
  440. {
  441. BankCardType = 0;
  442. }
  443. }
  444. else if (ProductType == "38") //国通星驿付
  445. {
  446. if (trade.BankCardType == "01" || trade.BankCardType == "02" || trade.BankCardType == "03" || trade.BankCardType == "04" || trade.BankCardType == "06" || trade.BankCardType == "30")
  447. {
  448. BankCardType = 1;
  449. }
  450. else
  451. {
  452. BankCardType = 0;
  453. }
  454. }
  455. else if (Utils.Instance.IsWifi(int.Parse(ProductType)))
  456. {
  457. FeeRate = "0.60";
  458. FeeAmt = trade.ErrorMsg;
  459. }
  460. Dictionary<string, string> fee = GetFee(trade.TradeSnNo, FeeRate, FeeAmt, ProductType);
  461. FeeRate = fee["FeeRate"];
  462. FeeAmt = fee["FeeAmt"];
  463. Dictionary<string, object> dataContent = new Dictionary<string, object>();
  464. if(ProductType != "51")
  465. {
  466. dataContent.Add("pos_sn", trade.TradeSnNo); //机具sn
  467. }
  468. dataContent.Add("mer_no", trade.MerNo); //商户号
  469. dataContent.Add("request_id", trade.TradeSerialNo); //流水号
  470. dataContent.Add("trade_amount", TradeAmount); //交易金额
  471. dataContent.Add("trade_time", trade.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss")); //交易时间
  472. dataContent.Add("brand", int.Parse(function.CheckInt(ProductType))); //品牌
  473. dataContent.Add("card_type", BankCardType); //卡类型
  474. dataContent.Add("qr_pay_flag", QrPayFlag); //云闪付标记
  475. dataContent.Add("fee_rate", FeeRate); //费率
  476. dataContent.Add("fee_amt", FeeAmt); //秒到费
  477. if(ProductType == "14")
  478. {
  479. dataContent.Add("is_first", 1);
  480. }
  481. if(ProductType == "23" || ProductType == "24" || ProductType == "25" || ProductType == "26" || ProductType == "32")
  482. {
  483. dataContent.Add("ext_field", trade.ChannelSerial);
  484. }
  485. if(ProductType == "51")
  486. {
  487. Push("lkb_trade", dataContent);
  488. }
  489. else
  490. {
  491. Push("trade", dataContent);
  492. }
  493. }
  494. catch (Exception ex)
  495. {
  496. Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n\n", "推送交易数据异常");
  497. }
  498. }
  499. public static void Push(string dataType, Dictionary<string, object> dataContent)
  500. {
  501. Dictionary<string, object> data = new Dictionary<string, object>();
  502. data.Add("data_type", dataType);
  503. data.Add("data_content", dataContent);
  504. // if(RedisDbconn.Instance.Get<string>("KxsPosDataQueueStatus") == "1")
  505. // {
  506. // RedisDbconn.Instance.AddList("KxsPosDataQueue", Newtonsoft.Json.JsonConvert.SerializeObject(data));
  507. // }
  508. PosPushHelper.Instance.DoSomeThing(Newtonsoft.Json.JsonConvert.SerializeObject(data));
  509. }
  510. public static string getRequestId(int id, string type)
  511. {
  512. if(id > 0)
  513. {
  514. return function.MD5_32(id.ToString() + type);
  515. }
  516. return DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);
  517. }
  518. public static string getRequestId(string str, string type)
  519. {
  520. return function.MD5_32(str + type);
  521. }
  522. public static string GetLiShuaBrand(string PosSn)
  523. {
  524. string brand = "22";
  525. JavaProductModels.WebCMSEntities db = new JavaProductModels.WebCMSEntities();
  526. JavaProductModels.KxsMachine pos = db.KxsMachine.FirstOrDefault(m => m.PosSn == PosSn);
  527. if(pos != null)
  528. {
  529. brand = pos.BrandId.ToString();
  530. }
  531. db.Dispose();
  532. return brand;
  533. }
  534. public static Dictionary<string, string> GetFee(string PosSn, string FeeRate, string FeeAmt, string ProductType)
  535. {
  536. Dictionary<string, string> result = new Dictionary<string, string>();
  537. try
  538. {
  539. if(decimal.Parse(FeeRate) > 0.63M) FeeRate = "0.63";
  540. List<int> BrandIds = new List<int>();
  541. BrandIds.Add(7);
  542. BrandIds.Add(10);
  543. BrandIds.Add(11);
  544. BrandIds.Add(12);
  545. BrandIds.Add(13);
  546. BrandIds.Add(15);
  547. BrandIds.Add(16);
  548. BrandIds.Add(22);
  549. Utils.WriteLog("start");
  550. bool op = false;
  551. if(ProductType == "1" || ProductType == "27")
  552. {
  553. op = true;
  554. }
  555. else if(BrandIds.Contains(int.Parse(ProductType)))
  556. {
  557. PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
  558. op = db.TmpTradeNo.Any(m => m.RecordNo == PosSn);
  559. db.Dispose();
  560. }
  561. if(op)
  562. {
  563. PosFeeItem pos = RedisDbconn.Instance.Get<PosFeeItem>("PosFee:" + PosSn);
  564. if(pos == null)
  565. {
  566. JavaProductModels.WebCMSEntities db = new JavaProductModels.WebCMSEntities();
  567. JavaProductModels.KxsMachine p = db.KxsMachine.FirstOrDefault(m => m.PosSn == PosSn && BrandIds.Contains(m.BrandId));
  568. pos = new PosFeeItem() { PosSn = p.PosSn, FeeRate = p.MachineRatio, FeeAmt = p.SecondFee };
  569. RedisDbconn.Instance.Set("PosFee:" + PosSn, pos);
  570. db.Dispose();
  571. }
  572. if(pos != null)
  573. {
  574. result.Add("FeeRate", pos.FeeRate.ToString("f2"));
  575. result.Add("FeeAmt", pos.FeeAmt.ToString("f2"));
  576. }
  577. else
  578. {
  579. result.Add("FeeRate", FeeRate);
  580. result.Add("FeeAmt", FeeAmt);
  581. }
  582. }
  583. else
  584. {
  585. result.Add("FeeRate", FeeRate);
  586. result.Add("FeeAmt", FeeAmt);
  587. }
  588. Utils.WriteLog("end");
  589. }
  590. catch
  591. {
  592. result.Add("FeeRate", FeeRate);
  593. result.Add("FeeAmt", FeeAmt);
  594. }
  595. return result;
  596. }
  597. public static Dictionary<string, string> GetFee2(string PosSn, string FeeRate, string FeeAmt, string ProductType)
  598. {
  599. Dictionary<string, string> result = new Dictionary<string, string>();
  600. try
  601. {
  602. if(decimal.Parse(FeeRate) > 0.63M) FeeRate = "0.63";
  603. List<int> BrandIds = new List<int>();
  604. BrandIds.Add(1);
  605. BrandIds.Add(7);
  606. BrandIds.Add(10);
  607. BrandIds.Add(11);
  608. BrandIds.Add(15);
  609. BrandIds.Add(16);
  610. BrandIds.Add(27);
  611. Utils.WriteLog("start");
  612. if(BrandIds.Contains(int.Parse(ProductType)))
  613. {
  614. JavaProductModels.WebCMSEntities db = new JavaProductModels.WebCMSEntities();
  615. JavaProductModels.KxsMachine pos = db.KxsMachine.FirstOrDefault(m => m.PosSn == PosSn && BrandIds.Contains(m.BrandId));
  616. if(pos != null)
  617. {
  618. result.Add("FeeRate", pos.MachineRatio.ToString("f2"));
  619. result.Add("FeeAmt", pos.SecondFee.ToString("f2"));
  620. }
  621. else
  622. {
  623. result.Add("FeeRate", FeeRate);
  624. result.Add("FeeAmt", FeeAmt);
  625. }
  626. }
  627. else
  628. {
  629. result.Add("FeeRate", FeeRate);
  630. result.Add("FeeAmt", FeeAmt);
  631. }
  632. Utils.WriteLog("end");
  633. }
  634. catch
  635. {
  636. result.Add("FeeRate", FeeRate);
  637. result.Add("FeeAmt", FeeAmt);
  638. }
  639. return result;
  640. }
  641. }
  642. }