123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Text;
- using System.Threading;
- using Common;
- using Infrastructure;
- using LitJson;
- using Microsoft.AspNetCore.Mvc;
- using Model;
- using Services;
- using Util;
- public class HaoDaHelper
- {
- public readonly static HaoDaHelper Instance = new HaoDaHelper();
- private HaoDaHelper()
- { }
- public void Start()
- {
- Thread th = new Thread(DoWorks);
- th.IsBackground = true;
- th.Start();
- }
- public void DoWorks()
- {
- while (true)
- {
- string content = RedisServer.Cache.RPop<string>("hd:notice:order");
- if(!string.IsNullOrEmpty(content))
- {
- DoQueue(content);
- }
- else
- {
- Thread.Sleep(5000);
- }
- }
- }
- public void DoQueue(string content)
- {
- try
- {
- string[] dataArray = content.Split(new string[]{ "#cut#" }, StringSplitOptions.None);
- JsonData header = JsonMapper.ToObject(dataArray[0]);
- content = dataArray[1];
- string signstr = header["X-Sign"][0].ToString();
- SortedList<string, string> dic = Newtonsoft.Json.JsonConvert.DeserializeObject<SortedList<string, string>>(content);
- string sign = Function.BuildQueryString(dic);
- bool checkSign = HaoDa.Instance.VerifySign(sign, signstr);
- if(checkSign)
- {
- var item = Newtonsoft.Json.JsonConvert.DeserializeObject<HdTradeRecord>(content);
- var tradeService = App.GetService<IHdTradeRecordService>();
- tradeService.addHdTradeRecord(item);
- // 商户号,设备号,终端类型,订单号,支付方式,交易类型,交易金额,交易手续费,交易时间,结算周期,费率
- // {"agentId": "039034", "merchId": "015110201559354", "merchName": "测试商户号", "ordId": "20230324H00030016535Y", "transAmt": "100.0", "feeAmt": "0.65", "feeRate": "0.65", "cardType": "C", "devId": "00000002213MDE119333", "transStat": "S", "transType": "51", "paymentMethod": "0", "settleType": "0", "transDate": "20230324", "transTime": "20230324111954", "quickPassFlag": "0", "simFee": "36.00", "servFee": "36.65"}
-
- if(item.transType == "31")
- {
- string paymentMethod = item.paymentMethod;
- if(paymentMethod == "0") paymentMethod = "刷卡";
- if(paymentMethod == "1") paymentMethod = "微信";
- if(paymentMethod == "2") paymentMethod = "支付宝";
- if(paymentMethod == "7") paymentMethod = "银联二维码";
- string settleType = item.settleType;
- if(settleType == "0") settleType = "S0";
- if(settleType == "1") settleType = "T1";
- if(settleType == "2") settleType = "D1";
- string data = item.merchId + "," + item.devId + ",好哒设备," + item.ordId + "," + paymentMethod + "," + item.transType + "," + item.transAmt + "," + item.feeAmt + "," + item.transTime + "," + settleType + "," + item.feeRate;
- RedisServer.Cache.LPush("ListenTradeDataByOneQueue", data);
- }
- else if(item.transType == "40")
- {
- }
- }
- }
- catch (Exception ex)
- {
- Function.WriteLog(DateTime.Now.ToString() + "\n" + ex, "好哒订单入库异常");
- }
- }
- }
|