199 lines
8.2 KiB
C#
199 lines
8.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace PayService
|
|
{
|
|
class Builder
|
|
{
|
|
private static Random random = new Random();
|
|
|
|
public static Dictionary<string, string> buildpreCreate()
|
|
{
|
|
Dictionary<string, string> map = new Dictionary<string, string>();
|
|
|
|
map.Add("version", "1");
|
|
map.Add("ins_cd", Const.ins_cd);
|
|
map.Add("mchnt_cd", Const.mchnt_cd);
|
|
map.Add("term_id", "");
|
|
map.Add("random_str", Guid.NewGuid().ToString("N"));
|
|
map.Add("sign", "");
|
|
map.Add("order_type", "ALIPAY");
|
|
map.Add("goods_des", "卡盟测试");
|
|
map.Add("goods_detail", "");
|
|
map.Add("addn_inf", "");
|
|
map.Add("mchnt_order_no", DateTime.Now.ToString("yyyyMMddhhmmssfff") + (int)(random.NextDouble() * 100000));
|
|
map.Add("curr_type", "");
|
|
map.Add("order_amt", "1");
|
|
map.Add("term_ip", Const.term_ip);
|
|
map.Add("txn_begin_ts", DateTime.Now.ToString("yyyyMMddhhmmss"));
|
|
map.Add("goods_tag", "");
|
|
map.Add("notify_url", Const.notify_url);
|
|
map.Add("reserved_sub_appid", "");
|
|
map.Add("reserved_limit_pay", "");
|
|
|
|
return map;
|
|
}
|
|
|
|
#region 条码支付参数
|
|
/// <summary>
|
|
/// 条码支付参数
|
|
/// </summary>
|
|
/// <param name="order_type">支付方式</param>
|
|
/// <param name="goods_des">商品说明</param>
|
|
/// <param name="order_amt">交易金额</param>
|
|
/// <param name="mchnt_order_no">交易订单号</param>
|
|
/// <param name="auth_code">支付授权码</param>
|
|
/// <returns></returns>
|
|
public static Dictionary<string, string> buildmicropay(string order_type, string goods_des, string order_amt,
|
|
string mchnt_order_no, string auth_code, string _mchnt_cd = "", string _term_id = "")
|
|
{
|
|
string _SERVERPARTCODE = mchnt_order_no.Substring(0, 6);
|
|
string _SHOPCODE = mchnt_order_no.Length == 28 ? mchnt_order_no.Substring(8, 2) : mchnt_order_no.Substring(8, 4);
|
|
Const.mchnt_cd = _mchnt_cd;
|
|
Const.term_id = _term_id;
|
|
|
|
for (int i = 0; i < Const.ShopCode.Length; i++)
|
|
{
|
|
if (_SERVERPARTCODE == Const.ShopCode[i] || _SHOPCODE == Const.ShopCode[i] ||
|
|
(mchnt_order_no.Length == 28 && mchnt_order_no.Substring(6, 4) == Const.ShopCode[i]) ||
|
|
(mchnt_order_no.Length == 30 && mchnt_order_no.Substring(6, 6) == Const.ShopCode[i]))
|
|
{
|
|
if (string.IsNullOrEmpty(_mchnt_cd))
|
|
{
|
|
Const.mchnt_cd = Const.Business_Code[i];
|
|
}
|
|
if (string.IsNullOrEmpty(_term_id))
|
|
{
|
|
Const.term_id = Const.term_Code[i];
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
Dictionary<string, string> map = new Dictionary<string, string>();
|
|
|
|
map.Add("version", "1");
|
|
map.Add("ins_cd", Const.ins_cd);
|
|
map.Add("mchnt_cd", Const.mchnt_cd);
|
|
map.Add("term_id", Const.term_id);
|
|
map.Add("random_str", Guid.NewGuid().ToString("N"));
|
|
map.Add("sign", "");
|
|
map.Add("order_type", order_type);
|
|
map.Add("goods_des", goods_des);
|
|
map.Add("goods_detail", "");
|
|
map.Add("addn_inf", "");
|
|
map.Add("mchnt_order_no", mchnt_order_no);
|
|
map.Add("curr_type", "");
|
|
map.Add("order_amt", order_amt);
|
|
map.Add("term_ip", Const.term_ip);
|
|
map.Add("txn_begin_ts", DateTime.Now.ToString("yyyyMMddHHmmss"));
|
|
map.Add("goods_tag", "");
|
|
map.Add("auth_code", auth_code);
|
|
map.Add("sence", "1");
|
|
map.Add("reserved_sub_appid", "");
|
|
map.Add("reserved_limit_pay", "");
|
|
|
|
return map;
|
|
}
|
|
#endregion
|
|
|
|
#region 订单查询参数
|
|
/// <summary>
|
|
/// 订单查询参数
|
|
/// </summary>
|
|
/// <param name="order_type">支付方式</param>
|
|
/// <param name="mchnt_order_no">交易订单号</param>
|
|
/// <returns></returns>
|
|
public static Dictionary<string, string> querymicropay(string order_type, string mchnt_order_no,
|
|
string _mchnt_cd = "", string _term_id = "")
|
|
{
|
|
string _SERVERPARTCODE = mchnt_order_no.Substring(0, 6);
|
|
string _SHOPCODE = mchnt_order_no.Length == 28 ? mchnt_order_no.Substring(8, 2) : mchnt_order_no.Substring(8, 4);
|
|
Const.mchnt_cd = _mchnt_cd;
|
|
Const.term_id = _term_id;
|
|
|
|
for (int i = 0; i < Const.ShopCode.Length; i++)
|
|
{
|
|
if (_SERVERPARTCODE == Const.ShopCode[i] || _SHOPCODE == Const.ShopCode[i] ||
|
|
(mchnt_order_no.Length == 28 && mchnt_order_no.Substring(6, 4) == Const.ShopCode[i]) ||
|
|
(mchnt_order_no.Length == 30 && mchnt_order_no.Substring(6, 6) == Const.ShopCode[i]))
|
|
{
|
|
if (string.IsNullOrEmpty(_mchnt_cd))
|
|
{
|
|
Const.mchnt_cd = Const.Business_Code[i];
|
|
}
|
|
if (string.IsNullOrEmpty(_term_id))
|
|
{
|
|
Const.term_id = Const.term_Code[i];
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
Dictionary<string, string> map = new Dictionary<string, string>();
|
|
|
|
map.Add("version", "1");
|
|
map.Add("ins_cd", Const.ins_cd);
|
|
map.Add("mchnt_cd", Const.mchnt_cd);
|
|
map.Add("term_id", Const.term_id);
|
|
map.Add("mchnt_order_no", mchnt_order_no);
|
|
map.Add("order_type", order_type);
|
|
map.Add("random_str", Guid.NewGuid().ToString("N"));
|
|
map.Add("sign", "");
|
|
|
|
return map;
|
|
}
|
|
#endregion
|
|
|
|
#region 退款申请参数
|
|
/// <summary>
|
|
/// 退款参数
|
|
/// </summary>
|
|
/// <param name="mchnt_order_no">交易订单号</param>
|
|
/// <param name="refund_amt">交易金额</param>
|
|
/// <param name="refund_order_no">退货订单号</param>
|
|
/// <param name="order_type">支付方式</param>
|
|
/// <returns></returns>
|
|
public static Dictionary<string, string> refundmicropay(string mchnt_order_no, string refund_order_no,
|
|
string refund_amt, string order_type)
|
|
{
|
|
string _SERVERPARTCODE = mchnt_order_no.Substring(0, 6);
|
|
string _SHOPCODE = mchnt_order_no.Length == 28 ? mchnt_order_no.Substring(8, 2) : mchnt_order_no.Substring(8, 4);
|
|
Const.mchnt_cd = "";
|
|
Const.term_id = "";
|
|
|
|
for (int i = 0; i < Const.ShopCode.Length; i++)
|
|
{
|
|
if (_SERVERPARTCODE == Const.ShopCode[i] || _SHOPCODE == Const.ShopCode[i] ||
|
|
(mchnt_order_no.Length == 28 && mchnt_order_no.Substring(6, 4) == Const.ShopCode[i]) ||
|
|
(mchnt_order_no.Length == 30 && mchnt_order_no.Substring(6, 6) == Const.ShopCode[i]))
|
|
{
|
|
Const.mchnt_cd = Const.Business_Code[i];
|
|
Const.term_id = Const.term_Code[i];
|
|
break;
|
|
}
|
|
}
|
|
Dictionary<string, string> map = new Dictionary<string, string>();
|
|
|
|
map.Add("version", "1");
|
|
map.Add("ins_cd", Const.ins_cd);
|
|
map.Add("mchnt_cd", Const.mchnt_cd);
|
|
map.Add("term_id", Const.term_id);
|
|
map.Add("mchnt_order_no", mchnt_order_no);
|
|
map.Add("random_str", Guid.NewGuid().ToString("N"));
|
|
map.Add("sign", "");
|
|
map.Add("order_type", order_type);
|
|
map.Add("refund_order_no", refund_order_no);
|
|
map.Add("total_amt", refund_amt);
|
|
map.Add("refund_amt", refund_amt);
|
|
map.Add("operator_id", "");
|
|
|
|
return map;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|