123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Library;
- using MySystem.Models.Main;
- namespace MySystem
- {
- public class PosPushDataNewHelper
- {
- public readonly static PosPushDataNewHelper Instance = new PosPushDataNewHelper();
- private PosPushDataNewHelper()
- { }
-
- public static void Bind(MerchantAddInfo mer, MerchantInfo m)
- {
- try
- {
- Dictionary<string, object> dataContent = new Dictionary<string, object>();
-
- dataContent.Add("mer_no", mer.MchtNo);
- dataContent.Add("id_card", mer.IdCardNumber);
- dataContent.Add("mer_name", mer.CertMerchantName);
- dataContent.Add("mer_mobile", mer.MobilePhone);
- dataContent.Add("request_id", getRequestId(mer.Id, "bind"));
- dataContent.Add("bind_time", mer.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss"));
- if(mer.BrandId == 1)
- {
- dataContent.Add("brand", 29);
- }
- else
- {
- dataContent.Add("brand", 101);
- }
- dataContent.Add("user_id", m.UserId);
- Push("qr_bind", dataContent);
- }
- catch (Exception ex)
- {
- function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n\n", "推送绑定数据异常");
- }
- }
-
- public static void Trade(ConsumerOrders trade, MerchantAddInfo mer)
- {
- try
- {
- int QrPayFlag = 0;
- int BankCardType = 1;
- List<string> BrandIds = new List<string>();
- decimal TradeAmount = trade.PayMoney;
- Dictionary<string, object> dataContent = new Dictionary<string, object>();
- dataContent.Add("pos_sn", trade.SnNo);
- dataContent.Add("mer_no", mer.MchtNo);
- dataContent.Add("request_id", trade.OrderNo);
- dataContent.Add("trade_amount", TradeAmount);
- dataContent.Add("trade_time", trade.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss"));
- dataContent.Add("brand", 101);
-
-
- dataContent.Add("fee_rate", trade.IsAct == 1 ? 0.6M : 0.63M);
- dataContent.Add("fee_amt", trade.IsAct == 1 ? 0 : 3);
- Push("lkb_trade", dataContent);
- }
- catch (Exception ex)
- {
- function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n\n", "推送交易数据异常");
- }
- }
- public static void Push(string dataType, Dictionary<string, object> dataContent)
- {
- Dictionary<string, object> data = new Dictionary<string, object>();
- data.Add("data_type", dataType);
- data.Add("data_content", dataContent);
- KxsRedisDbconn.Instance.AddList("KxsPosDataQueue", Newtonsoft.Json.JsonConvert.SerializeObject(data));
- }
- public static string getRequestId(int id, string type)
- {
- if(id > 0)
- {
- return function.MD5_32(id.ToString() + type);
- }
- return DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);
- }
- }
- }
|