PosPushDataNewHelper.cs 26 KB

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