using System; using System.Collections.Generic; using System.Linq; using Library; using MySystem.MpMainModels2; namespace MySystem { public class PosPushDataNewHelper { public readonly static PosPushDataNewHelper Instance = new PosPushDataNewHelper(); private PosPushDataNewHelper() { } //绑定数据 public static void Bind(SpModels.BindRecord mer) { try { Dictionary dataContent = new Dictionary(); dataContent.Add("pos_sn", mer.MerSnNo); //机具sn dataContent.Add("mer_no", mer.MerNo); //商户号 dataContent.Add("id_card", ""); //商户身份证 dataContent.Add("mer_name", mer.MerName); //商户姓名 dataContent.Add("mer_mobile", ""); //商户手机号 dataContent.Add("request_id", getRequestId(mer.Id, "bind")); //流水号 dataContent.Add("bind_time", mer.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss")); //绑定时间 dataContent.Add("brand", int.Parse(function.CheckInt(mer.ProductType))); //品牌 Push("bind", dataContent); } catch (Exception ex) { function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n\n", "推送绑定数据异常"); } } //押金数据 public static void Deposit(SpModels.ActivateRecord act) { try { List BrandIds = new List(); decimal TradeAmount = decimal.Parse(function.CheckNum(act.SeoTitle)); Dictionary dataContent = new Dictionary(); dataContent.Add("pos_sn", act.SnNo); //机具sn dataContent.Add("mer_no", act.MerNo); //商户号 dataContent.Add("request_id", getRequestId(act.Id, "deposit")); //流水号 dataContent.Add("deposit_amount", TradeAmount); //押金金额 dataContent.Add("trade_time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); //交易时间 dataContent.Add("card_type", 1); //卡类型 dataContent.Add("brand", int.Parse(function.CheckInt(act.ProductType))); //品牌 Push("deposit", dataContent); } catch (Exception ex) { function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n\n", "推送押金数据异常"); } } //交易数据 public static void Trade(ConsumerOrders trade, string kind) { try { int brand = 18; if(kind.Contains("好哒语音王")) brand = 18; if(kind.Contains("收款王M820")) brand = 19; if(kind.Contains("收款王M826")) brand = 20; if(kind.Contains("S312")) brand = 21; if(kind.Contains("好哒扫码通")) brand = 29; if(kind.Contains("好哒二维码")) brand = 20; Dictionary dataContent = new Dictionary(); dataContent.Add("pos_sn", trade.SnNo); //机具sn dataContent.Add("mer_no", trade.TradePayNo); //商户号 dataContent.Add("request_id", trade.OrderNo); //流水号 dataContent.Add("trade_amount", trade.PayMoney); //交易金额 dataContent.Add("trade_time", trade.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss")); //交易时间 dataContent.Add("brand", brand); //品牌 dataContent.Add("is_act", trade.IsAct); //品牌 dataContent.Add("card_type", 1); //卡类型 if(kind.Contains("好哒二维码")) { dataContent.Add("qr_pay_flag", 1); //云闪付标记 } else { dataContent.Add("qr_pay_flag", 0); //云闪付标记 } dataContent.Add("fee_rate", trade.IsAct == 1 ? 0.6M : 0.63M); // 费率 dataContent.Add("fee_amt", trade.IsAct == 1 ? 0 : 3); // 秒到费 Push("trade", dataContent); } catch (Exception ex) { function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n\n", "推送交易数据异常"); } } public static void Push(string dataType, Dictionary dataContent) { Dictionary data = new Dictionary(); data.Add("data_type", dataType); data.Add("data_content", dataContent); RedisDbconn.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); } } }