public static Dictionary <string, string> refund(string _2, string _4, string _59, TradeRecord tradeRecord, string secondShopNo) { string theOrderNo = Wanton.GetOrderNo(); string termailNo = SysConfigHelper.readerNode("ClientNo"); string shopNo = SysConfigHelper.readerNode("ShopNo"); tradeRecord.amount = _4; tradeRecord.batch_no = "" + "|" + SysBLL.getMMDDHHMMSSTime() + "|" + _2; tradeRecord.order_no = theOrderNo; tradeRecord.termail_no = termailNo; tradeRecord.lkl_wt_shop_no = shopNo; Dictionary <string, string> map = new Dictionary <string, string>(); Dictionary <int, string> data = new Dictionary <int, string>(); data.Add(2, _2); data.Add(3, "200000"); data.Add(4, wtPayUtils.ConvertMoney(_4)); data.Add(11, theOrderNo); map.Add("11", data[11]); data.Add(22, "051"); data.Add(25, "00"); data.Add(41, termailNo); map.Add("41", data[41]); data.Add(42, shopNo); data.Add(48, "TC_ONE|Y00000001|" + secondShopNo); //data.Add(48, "Y00000001"); data.Add(49, "156"); data.Add(59, _59); data.Add(60, "22000003000"); data.Add(63, "01"); byte[] countMacData = EncryptWT.countMacData("0200", EncryptWT.encryptLKL(data, null)); byte[] mac = PasswordBLL.GetMac(2, countMacData); byte[] sendData = EncryptWT.EncryptData("0200", "6000000000", EncryptWT.encryptLKL(data, mac)); //byte[] sendData = EncryptWT.EncryptData("0200", "6000000000", EncryptWT.encryptLKL(data, calculateMac(data, "0200"))); Console.WriteLine(); Console.WriteLine(BCDUtil.byteArrToString(sendData)); AnalysisBaseWT lk = new AnalysisBaseWT(); byte[] result = Client(LakalaIp, LakalaPort, sendData); //接收的数据 string receiveStr1 = BCDUtil.byteArrToString(result); log.Write("tuikuan的数据:" + receiveStr1); Dictionary <string, ResultData> ret = lk.analysis(result); string recode = Wanton.handleDataMac(ret); //发送数据 if ("00".Equals(recode)) { tradeRecord.lkl_wt_state = "1"; tradeRecord.order_state = "1"; } else { tradeRecord.lkl_wt_state = "2"; tradeRecord.order_state = "0"; } //发送的数据 string sendStr = BCDUtil.byteArrToString(sendData); //接收的数据 string receiveStr = BCDUtil.byteArrToString(result); map.Add("recode", recode); map.Add("sendStr", sendStr); map.Add("receiveStr", receiveStr); map.Add("ShopNo", data[11] + "|" + data[41] + "|" + data[42]); map.Add("39", ret["39"].value); log.Write("万通卡退款交易返回" + ret["39"].value); string serialStr = JsonConvert.SerializeObject(map); tradeRecord.data_id = serialStr; TradeBLL.SendOrderRefundRecord(tradeRecord); return(map); //if (result.Length > 0) //{ // return lk.analysis(result); //发送数据 //} //else //{ // return null; //} }
public static Dictionary <string, string> pay(WintopPayParam param, TradeRecord tradeRecord, string secondShopNo) { try { tradeRecord.shop_type = "1"; tradeRecord.order_type = "1"; tradeRecord.order_no = param.orderNo; tradeRecord.relation_order = ""; tradeRecord.amount = param.price; Dictionary <string, string> map = new Dictionary <string, string>(); Dictionary <int, string> data = new Dictionary <int, string>(); data.Add(2, param.wintopNo); //万通卡号 data.Add(3, "000000"); data.Add(4, wtPayUtils.ConvertMoney(param.price)); //交易金额 data.Add(11, param.orderNo); //POS终端交易流水 map.Add("11", data[11]); data.Add(25, "00"); data.Add(41, SysConfigHelper.readerNode("ClientNo"));//终端代码 map.Add("41", data[41]); tradeRecord.termail_no = data[41]; data.Add(42, SysConfigHelper.readerNode("ShopNo")); //商户代码 data.Add(48, "TC_ONE|Y00000001|" + secondShopNo); //data.Add(48, "TC_ONE|Y00000001|"+secondShopNo); //data.Add(48, "Y00000001"); data.Add(49, "156"); data.Add(62, param.ExpressPwd);//明文,卡号 data.Add(63, "01"); byte[] countMacData = EncryptWT.countMacData("0200", EncryptWT.encryptLKL(data, null)); byte[] mac = PasswordBLL.GetMac(2, countMacData); byte[] sendData = EncryptWT.EncryptData("0200", "6000000000", EncryptWT.encryptLKL(data, mac)); //发送的数据 string sendStr = BCDUtil.byteArrToString(sendData); log.Write("发送支付的数据:" + sendStr); //Console.WriteLine(); //Console.WriteLine(BCDUtil.byteArrToString(sendData)); AnalysisBaseWT lk = new AnalysisBaseWT(); byte[] result = Client(LakalaIp, LakalaPort, sendData); //接收的数据 string receiveStr = BCDUtil.byteArrToString(result); log.Write("接收支付的数据:" + receiveStr); Dictionary <string, ResultData> ret = lk.analysis(result); string recode = Wanton.handleDataMac(ret); //发送数据 log.Write("支付返回码:" + recode); if ("00".Equals(recode)) { tradeRecord.lkl_wt_state = "1"; tradeRecord.batch_no = ret["59"].value + "|" + SysBLL.getMMDDHHMMSSTime() + "|" + param.wintopNo; } else if ("A0".Equals(recode)) { DeviceState.SendState("333333"); } else { tradeRecord.lkl_wt_state = "2"; } map.Add("recode", recode); map.Add("sendStr", sendStr); map.Add("receiveStr", receiveStr); map.Add("ShopNo", param.orderNo + "|" + data[41] + "|" + data[42]); map.Add("money", param.price); if (ret.ContainsKey("2")) { map.Add("2", ret["2"].value); } map.Add("4", param.price); if (ret.ContainsKey("59")) { map.Add("59", ret["59"].value); map.Add("cloudOrderNo", ret["59"].value); } string serialStr = JsonConvert.SerializeObject(map); tradeRecord.data_id = serialStr; TradeBLL.SendOrderPayRecord(tradeRecord); return(map); } catch (WtException e) { throw e; } catch (Exception e) { throw new WtException(WtExceptionCode.Bus.WT_PAY, e.Message); } }