| | |
| | |
|
| | | import org.yeshi.utils.HttpUtil;
|
| | | import org.yeshi.utils.StringUtil;
|
| | | import org.yeshi.utils.entity.wx.RedPackParams;
|
| | |
|
| | | /**
|
| | | * 微信支付帮助类
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 发放微信红包
|
| | | * @param params
|
| | | * @param pwd
|
| | | * @param cert
|
| | | * @return
|
| | | */
|
| | | public static String redPackToOpenId(RedPackParams params, String pwd, InputStream cert) {
|
| | | // 转化成分
|
| | | BigDecimal money = params.getMoney();
|
| | | money = money.multiply(new BigDecimal(100)).setScale(0, BigDecimal.ROUND_DOWN);
|
| | | |
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("nonce_str", StringUtil.getRandomCode(32));
|
| | | map.put("sign", WXUtil.getSignMD5(map, params.getKey()));
|
| | | map.put("mch_billno", params.getBillno());
|
| | | map.put("mch_id", params.getMchId());
|
| | | map.put("wxappid", params.getWxappId());
|
| | | map.put("send_name", params.getSendName());
|
| | | map.put("re_openid", params.getOpenid());
|
| | | map.put("total_amount", money.toString());
|
| | | map.put("total_num", params.getTotalNum()+ "");
|
| | | map.put("wishing", params.getWishing());
|
| | | map.put("client_ip", params.getClientIp());
|
| | | map.put("act_name", params.getActName());
|
| | | map.put("remark", params.getRemark());
|
| | | map.put("scene_id", params.getSceneId());
|
| | | map.put("risk_info", params.getRiskInfo());
|
| | | String entity = WXUtil.loadWXMessage(map);
|
| | | try {
|
| | | String result = HttpUtil.httpsPost("https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack",
|
| | | entity, pwd, cert);
|
| | | return result;
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 查询红包领取记录
|
| | | * @param billno 商户订单号
|
| | | * @param mchId 商户号
|
| | | * @param key
|
| | | * @param appId Appid
|
| | | * @param pwd
|
| | | * @param cert
|
| | | * @return
|
| | | */
|
| | | public static String getRedPackRecord(String billno, String mchId, String appId, String key,
|
| | | String pwd, InputStream cert) {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("mch_billno", billno);
|
| | | map.put("mch_id", mchId);
|
| | | map.put("wxappid", appId);
|
| | | map.put("bill_type", "MCHT");
|
| | | map.put("nonce_str", StringUtil.getRandomCode(32));
|
| | | map.put("sign", WXUtil.getSignMD5(map, key));
|
| | | String entity = WXUtil.loadWXMessage(map);
|
| | | try {
|
| | | String result = HttpUtil.httpsPost("https://api.mch.weixin.qq.com/mmpaymkttransfers/gethbinfo",
|
| | | entity, pwd, cert);
|
| | | return result;
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | | }
|