PosPushDataNewHelper.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  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 (Utils.Instance.IsWifi(int.Parse(ProductType)))
  445. {
  446. FeeRate = "0.60";
  447. FeeAmt = trade.ErrorMsg;
  448. }
  449. Dictionary<string, string> fee = GetFee(trade.TradeSnNo, FeeRate, FeeAmt, ProductType);
  450. FeeRate = fee["FeeRate"];
  451. FeeAmt = fee["FeeAmt"];
  452. Dictionary<string, object> dataContent = new Dictionary<string, object>();
  453. if(ProductType != "51")
  454. {
  455. dataContent.Add("pos_sn", trade.TradeSnNo); //机具sn
  456. }
  457. dataContent.Add("mer_no", trade.MerNo); //商户号
  458. dataContent.Add("request_id", trade.TradeSerialNo); //流水号
  459. dataContent.Add("trade_amount", TradeAmount); //交易金额
  460. dataContent.Add("trade_time", trade.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss")); //交易时间
  461. dataContent.Add("brand", int.Parse(function.CheckInt(ProductType))); //品牌
  462. dataContent.Add("card_type", BankCardType); //卡类型
  463. dataContent.Add("qr_pay_flag", QrPayFlag); //云闪付标记
  464. dataContent.Add("fee_rate", FeeRate); //费率
  465. dataContent.Add("fee_amt", FeeAmt); //秒到费
  466. if(ProductType == "14")
  467. {
  468. dataContent.Add("is_first", 1);
  469. }
  470. if(ProductType == "23" || ProductType == "24" || ProductType == "25" || ProductType == "26" || ProductType == "32")
  471. {
  472. dataContent.Add("ext_field", trade.ChannelSerial);
  473. }
  474. if(ProductType == "51")
  475. {
  476. Push("lkb_trade", dataContent);
  477. }
  478. else
  479. {
  480. Push("trade", dataContent);
  481. }
  482. }
  483. catch (Exception ex)
  484. {
  485. Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n\n", "推送交易数据异常");
  486. }
  487. }
  488. public static void Push(string dataType, Dictionary<string, object> dataContent)
  489. {
  490. Dictionary<string, object> data = new Dictionary<string, object>();
  491. data.Add("data_type", dataType);
  492. data.Add("data_content", dataContent);
  493. // if(RedisDbconn.Instance.Get<string>("KxsPosDataQueueStatus") == "1")
  494. // {
  495. // RedisDbconn.Instance.AddList("KxsPosDataQueue", Newtonsoft.Json.JsonConvert.SerializeObject(data));
  496. // }
  497. PosPushHelper.Instance.DoSomeThing(Newtonsoft.Json.JsonConvert.SerializeObject(data));
  498. }
  499. public static string getRequestId(int id, string type)
  500. {
  501. if(id > 0)
  502. {
  503. return function.MD5_32(id.ToString() + type);
  504. }
  505. return DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);
  506. }
  507. public static string getRequestId(string str, string type)
  508. {
  509. return function.MD5_32(str + type);
  510. }
  511. public static string GetLiShuaBrand(string PosSn)
  512. {
  513. string brand = "22";
  514. JavaProductModels.WebCMSEntities db = new JavaProductModels.WebCMSEntities();
  515. JavaProductModels.KxsMachine pos = db.KxsMachine.FirstOrDefault(m => m.PosSn == PosSn);
  516. if(pos != null)
  517. {
  518. brand = pos.BrandId.ToString();
  519. }
  520. db.Dispose();
  521. return brand;
  522. }
  523. public static Dictionary<string, string> GetFee(string PosSn, string FeeRate, string FeeAmt, string ProductType)
  524. {
  525. Dictionary<string, string> result = new Dictionary<string, string>();
  526. try
  527. {
  528. if(decimal.Parse(FeeRate) > 0.63M) FeeRate = "0.63";
  529. List<int> BrandIds = new List<int>();
  530. BrandIds.Add(7);
  531. BrandIds.Add(10);
  532. BrandIds.Add(11);
  533. BrandIds.Add(12);
  534. BrandIds.Add(13);
  535. BrandIds.Add(15);
  536. BrandIds.Add(16);
  537. BrandIds.Add(22);
  538. Utils.WriteLog("start");
  539. bool op = false;
  540. if(ProductType == "1" || ProductType == "27")
  541. {
  542. op = true;
  543. }
  544. else if(BrandIds.Contains(int.Parse(ProductType)))
  545. {
  546. PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
  547. op = db.TmpTradeNo.Any(m => m.RecordNo == PosSn);
  548. db.Dispose();
  549. }
  550. if(op)
  551. {
  552. PosFeeItem pos = RedisDbconn.Instance.Get<PosFeeItem>("PosFee:" + PosSn);
  553. if(pos == null)
  554. {
  555. JavaProductModels.WebCMSEntities db = new JavaProductModels.WebCMSEntities();
  556. JavaProductModels.KxsMachine p = db.KxsMachine.FirstOrDefault(m => m.PosSn == PosSn && BrandIds.Contains(m.BrandId));
  557. pos = new PosFeeItem() { PosSn = p.PosSn, FeeRate = p.MachineRatio, FeeAmt = p.SecondFee };
  558. RedisDbconn.Instance.Set("PosFee:" + PosSn, pos);
  559. db.Dispose();
  560. }
  561. if(pos != null)
  562. {
  563. result.Add("FeeRate", pos.FeeRate.ToString("f2"));
  564. result.Add("FeeAmt", pos.FeeAmt.ToString("f2"));
  565. }
  566. else
  567. {
  568. result.Add("FeeRate", FeeRate);
  569. result.Add("FeeAmt", FeeAmt);
  570. }
  571. }
  572. else
  573. {
  574. result.Add("FeeRate", FeeRate);
  575. result.Add("FeeAmt", FeeAmt);
  576. }
  577. Utils.WriteLog("end");
  578. }
  579. catch
  580. {
  581. result.Add("FeeRate", FeeRate);
  582. result.Add("FeeAmt", FeeAmt);
  583. }
  584. return result;
  585. }
  586. public static Dictionary<string, string> GetFee2(string PosSn, string FeeRate, string FeeAmt, string ProductType)
  587. {
  588. Dictionary<string, string> result = new Dictionary<string, string>();
  589. try
  590. {
  591. if(decimal.Parse(FeeRate) > 0.63M) FeeRate = "0.63";
  592. List<int> BrandIds = new List<int>();
  593. BrandIds.Add(1);
  594. BrandIds.Add(7);
  595. BrandIds.Add(10);
  596. BrandIds.Add(11);
  597. BrandIds.Add(15);
  598. BrandIds.Add(16);
  599. BrandIds.Add(27);
  600. Utils.WriteLog("start");
  601. if(BrandIds.Contains(int.Parse(ProductType)))
  602. {
  603. JavaProductModels.WebCMSEntities db = new JavaProductModels.WebCMSEntities();
  604. JavaProductModels.KxsMachine pos = db.KxsMachine.FirstOrDefault(m => m.PosSn == PosSn && BrandIds.Contains(m.BrandId));
  605. if(pos != null)
  606. {
  607. result.Add("FeeRate", pos.MachineRatio.ToString("f2"));
  608. result.Add("FeeAmt", pos.SecondFee.ToString("f2"));
  609. }
  610. else
  611. {
  612. result.Add("FeeRate", FeeRate);
  613. result.Add("FeeAmt", FeeAmt);
  614. }
  615. }
  616. else
  617. {
  618. result.Add("FeeRate", FeeRate);
  619. result.Add("FeeAmt", FeeAmt);
  620. }
  621. Utils.WriteLog("end");
  622. }
  623. catch
  624. {
  625. result.Add("FeeRate", FeeRate);
  626. result.Add("FeeAmt", FeeAmt);
  627. }
  628. return result;
  629. }
  630. }
  631. }