| | |
| | | package com.stylefeng.guns.modular.huifu.biz; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.huifu.bspay.sdk.opps.core.BasePay; |
| | | import com.huifu.bspay.sdk.opps.core.config.MerConfig; |
| | |
| | | cardInfo.put("cert_validity_type", "1"); |
| | | } |
| | | paramsInfo.put("card_info", cardInfo.toJSONString()); |
| | | // 结算卡信息 |
| | | JSONArray cashConfigArr = new JSONArray(); |
| | | JSONObject cashConfig = new JSONObject(); |
| | | /** |
| | | * T1:下一工作日到银行账户; |
| | | * D1:下一自然日到银行账户; |
| | | * D0:当日到银行账户;默认D0; |
| | | * DM:当日到账;到账资金不包括当天的交易资金; |
| | | * 示例值:T1 |
| | | */ |
| | | cashConfig.put("cash_type", "D1"); |
| | | cashConfig.put("fix_amt", "0.00"); |
| | | cashConfig.put("weekday_fix_amt", "0.00"); |
| | | cashConfig.put("weekday_fee_rate", "0.00"); |
| | | cashConfigArr.add(cashConfig); |
| | | paramsInfo.put("cash_config", cashConfigArr.toJSONString()); |
| | | log.info("用户业务入驻返回参数:{}", paramsInfo); |
| | | // 3. 发起API调用 |
| | | Map<String, Object> response = BasePayRequest.requestBasePay("v2/user/busi/open", paramsInfo, null, false);; |
| | |
| | | cardInfo.put("cert_validity_type", "1"); |
| | | } |
| | | paramsInfo.put("card_info", cardInfo.toJSONString()); |
| | | // 结算卡信息 |
| | | JSONArray cashConfigArr = new JSONArray(); |
| | | JSONObject cashConfig = new JSONObject(); |
| | | /** |
| | | * T1:下一工作日到银行账户; |
| | | * D1:下一自然日到银行账户; |
| | | * D0:当日到银行账户;默认D0; |
| | | * DM:当日到账;到账资金不包括当天的交易资金; |
| | | * 示例值:T1 |
| | | */ |
| | | cashConfig.put("cash_type", "D1"); |
| | | cashConfig.put("fix_amt", "0.00"); |
| | | cashConfig.put("weekday_fix_amt", "0.00"); |
| | | cashConfig.put("weekday_fee_rate", "0.00"); |
| | | cashConfigArr.add(cashConfig); |
| | | paramsInfo.put("cash_config", cashConfigArr.toJSONString()); |
| | | log.info("用户业务入驻修改返回参数:{}", paramsInfo); |
| | | // 3. 发起API调用 |
| | | Map<String, Object> response = BasePayRequest.requestBasePay("v2/user/busi/modify", paramsInfo, null, false);; |
| | |
| | | cardInfo.put("area_id", enterpriseWithdrawal.getBankCardCityCode()); |
| | | cardInfo.put("branch_code", enterpriseWithdrawal.getBankBranchCode()); |
| | | paramsInfo.put("card_info", cardInfo.toJSONString()); |
| | | // 结算卡信息 |
| | | JSONArray cashConfigArr = new JSONArray(); |
| | | JSONObject cashConfig = new JSONObject(); |
| | | /** |
| | | * T1:下一工作日到银行账户; |
| | | * D1:下一自然日到银行账户; |
| | | * D0:当日到银行账户;默认D0; |
| | | * DM:当日到账;到账资金不包括当天的交易资金; |
| | | * 示例值:T1 |
| | | */ |
| | | cashConfig.put("cash_type", "D1"); |
| | | cashConfig.put("fix_amt", "0.00"); |
| | | cashConfig.put("weekday_fix_amt", "0.00"); |
| | | cashConfig.put("weekday_fee_rate", "0.00"); |
| | | cashConfigArr.add(cashConfig); |
| | | paramsInfo.put("cash_config", cashConfigArr.toJSONString()); |
| | | log.info("企业业务入驻返回参数:{}", paramsInfo); |
| | | // 3. 发起API调用 |
| | | Map<String, Object> response = BasePayRequest.requestBasePay("v2/user/busi/open", paramsInfo, null, false); |
| | |
| | | cardInfo.put("area_id", enterpriseWithdrawal.getBankCardCityCode()); |
| | | cardInfo.put("branch_code", enterpriseWithdrawal.getBankBranchCode()); |
| | | paramsInfo.put("card_info", cardInfo.toJSONString()); |
| | | // 结算卡信息 |
| | | JSONArray cashConfigArr = new JSONArray(); |
| | | JSONObject cashConfig = new JSONObject(); |
| | | /** |
| | | * T1:下一工作日到银行账户; |
| | | * D1:下一自然日到银行账户; |
| | | * D0:当日到银行账户;默认D0; |
| | | * DM:当日到账;到账资金不包括当天的交易资金; |
| | | * 示例值:T1 |
| | | */ |
| | | cashConfig.put("cash_type", "D1"); |
| | | cashConfig.put("fix_amt", "0.00"); |
| | | cashConfig.put("weekday_fix_amt", "0.00"); |
| | | cashConfig.put("weekday_fee_rate", "0.00"); |
| | | cashConfigArr.add(cashConfig); |
| | | paramsInfo.put("cash_config", cashConfigArr.toJSONString()); |
| | | log.info("企业业务入驻修改返回参数:{}", paramsInfo); |
| | | // 3. 发起API调用 |
| | | Map<String, Object> response = BasePayRequest.requestBasePay("v2/user/busi/modify", paramsInfo, null, false); |
| | |
| | | public class DouGongRefundBiz { |
| | | @Autowired |
| | | private HuiFuProperties huiFuProperties; |
| | | @Autowired |
| | | private RestTemplate restTemplate; |
| | | |
| | | @Value("${callbackPath}") |
| | | private String callbackPath; |
| | | |
| | | private static final String REFUND_URL = "https://api.huifu.com/v4/trade/payment/scanpay/refund"; |
| | | /** |
| | | * 公共参数 |
| | | * sys_id 系统号 String 32 Y 渠道商/商户的huifu_id |
| | | * (1)当主体为渠道商时,此字段填写渠道商huifu_id; |
| | | * (2)当主体为直连商户时,此字段填写商户huifu_id; |
| | | * 示例值:6666000108854952 |
| | | * product_id 产品号 String 32 Y 汇付分配的产品号,示例值:YYZY |
| | | * sign 加签结果 String 512 Y 接口加签验签说明 |
| | | * data 数据 Json Y 业务请求参数,具体值参考API文档 |
| | | * |
| | | * 请求参数 |
| | | * req_date 请求日期 String 8 Y 格式yyyyMMdd;示例值:20220925 |
| | | * req_seq_id 请求流水号 String 128 Y 同一huifu_id下当天唯一;示例值:rQ2021121311173944175651 |
| | | * huifu_id 商户号 String 32 Y 示例值:6666000123120001 |
| | | * ord_amt 申请退款金额 String 14 Y 单位元,需保留小数点后两位;示例值:1.00,最低传入0.01 |
| | | * 注意:如果是原交易是延时交易,退款金额必须小于等于待确认金额 |
| | | * org_req_date 原交易请求日期 String 8 Y 格式:yyyyMMdd;示例值:20220925 |
| | | * org_hf_seq_id 原交易全局流水号 String 128 N org_hf_seq_id,org_party_order_id,org_req_seq_id三选一; |
| | | * 示例值:0030default220825182711P099ac1f343f00000 |
| | | * org_party_order_id 原交易微信支付宝的商户单号 String 64 N org_hf_seq_id,org_party_order_id,org_req_seq_id三选一; |
| | | * 示例值:03232109190255105603561;参见用户账单说明 |
| | | * org_req_seq_id 原交易请求流水号 String 128 N org_hf_seq_id,org_party_order_id,org_req_seq_id三选一; |
| | | * 示例值:202110210012100005 |
| | | * remark 备注 String 84 N 原样返回;示例值:备注 |
| | | * notify_url 异步通知地址 String 512 N 示例值: http://service.example.com/to/path |
| | | * |
| | | * 响应内容 |
| | | * resp_code 业务响应码 String 8 Y 业务返回码 |
| | | * resp_desc 业务响应信息 String 512 Y 业务返回描述 |
| | | * product_id 产品号 String 32 Y 交易时传入,原样返回;示例值:YYZY |
| | | * huifu_id 商户号 String 32 Y 示例值:6666000108854952 |
| | | * org_hf_seq_id 原交易全局流水号 String 128 N 示例值:00470topo1A221019132207P068ac1362af00000 |
| | | * org_req_date 原交易请求日期 String 8 N 格式为yyyyMMdd,示例值:20220925 |
| | | * org_req_seq_id 原交易请求流水号 String 128 N 示例值:rQ202112131149875651 |
| | | * trans_date 退款交易发生日期 String 8 N 格式为yyyyMMdd,示例值:20220925 |
| | | * trans_time 退款交易发生时间 String 6 N 格式:HHMMSS,示例值:091010 代表9点10分10秒 |
| | | * trans_finish_time 退款完成时间 String 14 N 格式yyyyMMddHHmmss;示例值:20091225091010 |
| | | * trans_stat 交易状态 String 1 N P:处理中、S:成功、F:失败;示例值:S |
| | | * ord_amt 退款金额(元) String 14 Y 需保留小数点后两位;示例值:1.00,最低传入0.01 |
| | | * actual_ref_amt 实际退款金额(元) String 14 N 需保留小数点后两位,示例值:1.00,最低传入0.01 |
| | | * remark 备注 String 84 N 原样返回;示例值:备注 |
| | | * bank_message 通道返回描述 String 256 N 示例值:SUCCESS |
| | | * fund_freeze_stat 资金冻结状态 String 16 N FREEZE:冻结;UNFREEZE:解冻;示例值:UNFREEZE |
| | | * 退款发生时,对应原交易的资金冻结状态。 |
| | | * pay_channel 交易通道 String 1 N 枚举值:A-支付宝、T-微信、U-银联二维码、D-数字货币 |
| | | * fee_amount 退款返还手续费 String 14 N 单位元,保留小数点后两位,示例值:1.00 |
| | | * trade_type 交易类型 String N TRANS_REFUND:交易退款;目前仅该一个枚举值; |
| | | * 示例值:TRANS_REFUND |
| | | */ |
| | | |
| | | /** |
| | | * 交易退款接口 |
| | |
| | | data.put("notify_url", callbackPath + notifyUrl); |
| | | |
| | | // 发送HTTP请求 - POST JSON格式 |
| | | Map<String, Object> response = BasePayRequest.requestBasePay(REFUND_URL, data, null, false); |
| | | Map<String, Object> response = BasePayRequest.requestBasePay("v4/trade/payment/scanpay/refund", data, null, false); |
| | | log.info("斗拱退款接口响应内容: {}", JSONObject.toJSONString(response)); |
| | | return response; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 创建错误结果 |
| | | */ |
| | | private JSONObject createErrorResult(String errorMsg) { |
| | | JSONObject result = new JSONObject(); |
| | | result.put("resp_code", "9999"); |
| | | result.put("resp_desc", errorMsg); |
| | | result.put("success", false); |
| | | return result; |
| | | } |
| | | public static String sign(String data, String privateKeyBase64) { |
| | | // Base64 --> Key |
| | | try { |
| | | byte[] bytes = Base64.getDecoder().decode(privateKeyBase64); |
| | | PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(bytes); |
| | | KeyFactory keyFactory; |
| | | keyFactory = KeyFactory.getInstance("RSA"); |
| | | PrivateKey privateKey = keyFactory.generatePrivate(keySpec); |
| | | // Sign |
| | | Signature signature = Signature.getInstance("SHA256WithRSA"); |
| | | signature.initSign(privateKey); |
| | | signature.update(data.getBytes("UTF-8")); |
| | | return Base64.getEncoder().encodeToString(signature.sign()); |
| | | } catch (Exception e) { |
| | | return null; |
| | | } |
| | | } |
| | | } |
| | |
| | | public class DouGongWithdrawBiz { |
| | | @Autowired |
| | | private HuiFuProperties huiFuProperties; |
| | | @Autowired |
| | | private RestTemplate restTemplate; |
| | | |
| | | @Value("${callbackPath}") |
| | | private String callbackPath; |
| | | |
| | | private static final String ENCASHMENT_URL = "https://api.huifu.com/v2/trade/settlement/encashment"; |
| | | /** |
| | | * 请求参数 |
| | | * req_date 请求日期 String 8 Y 格式yyyyMMdd;示例值:20210917 |
| | | * req_seq_id 请求流水号 String 128 Y 示例值:2021091708126665001 |
| | | * cash_amt 取现金额 String 14 Y 单位元,需保留小数点后两位,示例值:1.00 |
| | | * huifu_id 取现方ID号 String 32 Y 提现发起方的汇付ID。支持已配置取现规则的商户、用户。 |
| | | * 示例值:6666000109812123 |
| | | * acct_id 账户号 String 32 N 可指定账户号,仅支持基本户、现金户,不填默认为基本户; |
| | | * 示例值:F00598600 |
| | | * into_acct_date_type 到账日期类型 String 3 Y D0:当日到账;当日交易资金当天可取现到账; |
| | | * T1:次工作日到账; |
| | | * D1:次自然日到账; |
| | | * DM:当日到账;到账资金不包括当天的交易资金; |
| | | * 示例值:D0 |
| | | * token_no 取现卡序列号 String 20 Y 绑定取现卡后可获取取现卡序列号;示例值:10004053462 |
| | | * enchashment_channel 取现渠道 String 2 N 00:汇付(为空默认); 10:中信e账通;示例值:00 |
| | | * remark 备注 String 100 N 示例值:备注 |
| | | * notify_url 异步通知地址 String 128 N 示例值:http://service.example.com/to/path |
| | | */ |
| | | /** |
| | | * 主动取现接口 |
| | | * |
| | |
| | | Map<String, Object> response = BasePayRequest.requestBasePay("v2/trade/settlement/encashment", data, null, false); |
| | | log.info("斗拱提现接口响应内容: {}", JSONObject.toJSONString(response)); |
| | | return response; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 创建错误结果 |
| | | */ |
| | | private JSONObject createErrorResult(String errorMsg) { |
| | | JSONObject result = new JSONObject(); |
| | | result.put("resp_code", "9999"); |
| | | result.put("resp_desc", errorMsg); |
| | | result.put("success", false); |
| | | return result; |
| | | } |
| | | public static String sign(String data, String privateKeyBase64) { |
| | | // Base64 --> Key |
| | | try { |
| | | byte[] bytes = Base64.getDecoder().decode(privateKeyBase64); |
| | | PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(bytes); |
| | | KeyFactory keyFactory; |
| | | keyFactory = KeyFactory.getInstance("RSA"); |
| | | PrivateKey privateKey = keyFactory.generatePrivate(keySpec); |
| | | // Sign |
| | | Signature signature = Signature.getInstance("SHA256WithRSA"); |
| | | signature.initSign(privateKey); |
| | | signature.update(data.getBytes("UTF-8")); |
| | | return Base64.getEncoder().encodeToString(signature.sign()); |
| | | } catch (Exception e) { |
| | | return null; |
| | | } |
| | | } |
| | | } |
| | |
| | | import com.stylefeng.guns.modular.huifu.properties.HuiFuProperties; |
| | | import com.stylefeng.guns.modular.system.model.TCompanyWithdraw; |
| | | import com.stylefeng.guns.modular.system.model.TEnterpriseWithdrawal; |
| | | import com.stylefeng.guns.modular.system.model.TOrderCrossCity; |
| | | import com.stylefeng.guns.modular.system.model.TOrderLogistics; |
| | | import com.stylefeng.guns.modular.system.model.TPubWithdrawal; |
| | | import com.stylefeng.guns.modular.system.service.ITCompanyWithdrawService; |
| | | import com.stylefeng.guns.modular.system.service.ITEnterpriseWithdrawalService; |
| | | import com.stylefeng.guns.modular.system.service.ITOrderCrossCityService; |
| | | import com.stylefeng.guns.modular.system.service.ITOrderLogisticsService; |
| | | import com.stylefeng.guns.modular.system.service.ITPubWithdrawalService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | |
| | | public class DouGongNotifyController { |
| | | @Autowired |
| | | private HuiFuProperties huiFuProperties; |
| | | |
| | | @Autowired |
| | | private ITCompanyWithdrawService companyWithdrawService; |
| | | |
| | | @Autowired |
| | | private ITPubWithdrawalService pubWithdrawalService; |
| | | |
| | | @Autowired |
| | | private ITOrderCrossCityService orderCrossCityService; |
| | | |
| | | @Autowired |
| | | private ITOrderLogisticsService orderLogisticsService; |
| | | |
| | | /** |
| | | * 斗拱主动取现接口企业回调 |
| | |
| | | * @param response |
| | | */ |
| | | @PostMapping("/ent/encashment") |
| | | public ResponseEntity<String> entEncashment(HttpServletRequest request, HttpServletResponse response) { |
| | | public void entEncashment(HttpServletRequest request, HttpServletResponse response) { |
| | | String sign =request.getParameter("sign"); |
| | | String resp_data = request.getParameter("resp_data"); |
| | | log.info("斗拱企业提现响应内容:{}", resp_data); |
| | | log.info("斗拱企业提现回调响应内容:{}", resp_data); |
| | | // 使用汇付公钥验签 |
| | | resp_data = resp_data.replaceAll("& #40;", "(").replaceAll("& #41;",")"); |
| | | boolean verify = RsaUtils.verify(resp_data, huiFuProperties.getRsaPublicKey(), sign); |
| | |
| | | String transStat = respDataJson.getString("trans_stat");//S:成功 F:失败 P:处理中;示例值:S |
| | | TCompanyWithdraw companyWithdraw = companyWithdrawService.selectOne(new EntityWrapper<TCompanyWithdraw>().eq("reqSeqId", reqSeqId).or().eq("hfSeqId", hfSeqId).last("limit 1")); |
| | | if (Objects.isNull(companyWithdraw)) { |
| | | return ResponseEntity.ok(""); |
| | | return; |
| | | } |
| | | if ("S".equalsIgnoreCase(transStat)) { |
| | | companyWithdraw.setStatus(1); |
| | |
| | | } |
| | | companyWithdrawService.updateById(companyWithdraw); |
| | | log.info("更新企业提现记录成功,更新内容“{}", JSONObject.toJSON(companyWithdraw)); |
| | | return ResponseEntity.ok("RECV_ORD_ID_" + reqSeqId); |
| | | PrintWriter writer = null; |
| | | try { |
| | | writer = response.getWriter(); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | writer.print("200"); |
| | | writer.close(); |
| | | } |
| | | return null; |
| | | } |
| | | /** |
| | | * 斗拱主动取现接口回调 |
| | |
| | | * @param response |
| | | */ |
| | | @PostMapping("/user/encashment") |
| | | public ResponseEntity<String> userEncashment(HttpServletRequest request, HttpServletResponse response) { |
| | | public void userEncashment(HttpServletRequest request, HttpServletResponse response) { |
| | | String sign =request.getParameter("sign"); |
| | | String resp_data = request.getParameter("resp_data"); |
| | | log.info("斗拱企业提现响应内容:{}", resp_data); |
| | | log.info("斗拱用户提现回调响应内容:{}", resp_data); |
| | | // 使用汇付公钥验签 |
| | | resp_data = resp_data.replaceAll("& #40;", "(").replaceAll("& #41;",")"); |
| | | boolean verify = RsaUtils.verify(resp_data, huiFuProperties.getRsaPublicKey(), sign); |
| | |
| | | String transStat = respDataJson.getString("trans_stat");//S:成功 F:失败 P:处理中;示例值:S |
| | | TPubWithdrawal pubWithdrawal = pubWithdrawalService.selectOne(new EntityWrapper<TPubWithdrawal>().eq("reqSeqId", reqSeqId).or().eq("hfSeqId", hfSeqId).last("limit 1")); |
| | | if (Objects.isNull(pubWithdrawal)) { |
| | | return ResponseEntity.ok(""); |
| | | return; |
| | | } |
| | | if ("S".equalsIgnoreCase(transStat)) { |
| | | pubWithdrawal.setState(2); |
| | |
| | | } |
| | | pubWithdrawalService.updateById(pubWithdrawal); |
| | | log.info("更新用户/司机提现记录成功,更新内容“{}", JSONObject.toJSON(pubWithdrawal)); |
| | | return ResponseEntity.ok("RECV_ORD_ID_" + reqSeqId); |
| | | PrintWriter writer = null; |
| | | try { |
| | | writer = response.getWriter(); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | writer.print("200"); |
| | | writer.close(); |
| | | } |
| | | return null; |
| | | } |
| | | /** |
| | | * 斗拱主动取现接口回调 |
| | | * @param request |
| | | * @param response |
| | | */ |
| | | @PostMapping("/refund-logistics") |
| | | public void refundLogistics(HttpServletRequest request, HttpServletResponse response) { |
| | | String sign =request.getParameter("sign"); |
| | | String resp_data = request.getParameter("resp_data"); |
| | | log.info("斗拱用户提现回调响应内容:{}", resp_data); |
| | | // 使用汇付公钥验签 |
| | | resp_data = resp_data.replaceAll("& #40;", "(").replaceAll("& #41;",")"); |
| | | boolean verify = RsaUtils.verify(resp_data, huiFuProperties.getRsaPublicKey(), sign); |
| | | if(verify){ |
| | | JSONObject respDataJson = JSONObject.parseObject(resp_data); |
| | | String reqSeqId = respDataJson.getString("req_seq_id"); |
| | | String orgReqSeqId = respDataJson.getString("org_req_seq_id"); |
| | | String transStat = respDataJson.getString("trans_stat");//S:成功 F:失败 P:处理中;示例值:S |
| | | TOrderLogistics orderLogistics = orderLogisticsService.selectOne(new EntityWrapper<TOrderLogistics>() |
| | | .eq("refundReqSeqId", reqSeqId).or().eq("outTradeNo", orgReqSeqId).last("limit 1")); |
| | | if (Objects.isNull(orderLogistics)) { |
| | | return; |
| | | } |
| | | if ("S".equalsIgnoreCase(transStat)) { |
| | | orderLogistics.setState(10); |
| | | } |
| | | orderLogisticsService.updateById(orderLogistics); |
| | | log.info("更新小件物流取消订单状态成功,更新内容“{}", JSONObject.toJSON(orderLogistics)); |
| | | PrintWriter writer = null; |
| | | try { |
| | | writer = response.getWriter(); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | writer.print("200"); |
| | | writer.close(); |
| | | } |
| | | } |
| | | /** |
| | | * 斗拱主动取现接口回调 |
| | | * @param request |
| | | * @param response |
| | | */ |
| | | @PostMapping("/refund-crosscity") |
| | | public void refundCrossCity(HttpServletRequest request, HttpServletResponse response) { |
| | | String sign =request.getParameter("sign"); |
| | | String resp_data = request.getParameter("resp_data"); |
| | | log.info("斗拱用户提现回调响应内容:{}", resp_data); |
| | | // 使用汇付公钥验签 |
| | | resp_data = resp_data.replaceAll("& #40;", "(").replaceAll("& #41;",")"); |
| | | boolean verify = RsaUtils.verify(resp_data, huiFuProperties.getRsaPublicKey(), sign); |
| | | if(verify){ |
| | | JSONObject respDataJson = JSONObject.parseObject(resp_data); |
| | | String reqSeqId = respDataJson.getString("req_seq_id"); |
| | | String orgReqSeqId = respDataJson.getString("org_req_seq_id"); |
| | | String transStat = respDataJson.getString("trans_stat");//S:成功 F:失败 P:处理中;示例值:S |
| | | TOrderCrossCity orderCrossCity = orderCrossCityService.selectOne(new EntityWrapper<TOrderCrossCity>() |
| | | .eq("refundReqSeqId", reqSeqId).or().eq("outTradeNo", orgReqSeqId).last("limit 1")); |
| | | if (Objects.isNull(orderCrossCity)) { |
| | | return; |
| | | } |
| | | if ("S".equalsIgnoreCase(transStat)) { |
| | | orderCrossCity.setState(10); |
| | | } |
| | | orderCrossCityService.updateById(orderCrossCity); |
| | | log.info("更新跨城订单取消订单状态成功,更新内容“{}", JSONObject.toJSON(orderCrossCity)); |
| | | PrintWriter writer = null; |
| | | try { |
| | | writer = response.getWriter(); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | writer.print("200"); |
| | | writer.close(); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | if(orderCrossCity.getState() > 5 && orderCrossCity.getState() != 11 && orderCrossCity.getState() != 7){ |
| | | return ResultUtil.error("订单状态不在可取消范围内"); |
| | | } |
| | | Integer orgState = orderCrossCity.getState(); |
| | | orderCrossCity.setState(10); |
| | | tOrderCrossCityService.updateById(orderCrossCity); |
| | | |
| | |
| | | String refundReqSeqId = RequestSeqUtil.generate("TK"); |
| | | Map<String, Object> refund = douGongRefundBiz.refund(refundReqSeqId, BigDecimal.valueOf(query.getAmount()), DateUtil.format(query.getInsertTime(), "yyyyMMdd"), orderCrossCity.getOutTradeNo(), 1); |
| | | orderCrossCity.setRefundReqSeqId(refundReqSeqId); |
| | | if (!"00000000".equals(refund.get("resp_code")) && "S".equals(refund.get("trans_stat"))) { |
| | | orderCrossCity.setState(orgState); |
| | | if ("00000000".equals(refund.get("resp_code")) && "S".equals(refund.get("trans_stat"))) { |
| | | orderCrossCity.setState(10); |
| | | }else if (!"00000000".equals(refund.get("resp_code"))) { |
| | | return ResultUtil.error("订单取消失败:" + refund.get("resp_desc").toString()); |
| | | } |
| | | tOrderCrossCityService.updateById(orderCrossCity); |
| | |
| | | String refundReqSeqId = RequestSeqUtil.generate("TK"); |
| | | Map<String, Object> refund = douGongRefundBiz.refund(refundReqSeqId, BigDecimal.valueOf(query.getAmount()), DateUtil.format(query.getInsertTime(), "yyyyMMdd"), orderCrossCity.getOutTradeNo(), 1); |
| | | orderCrossCity.setRefundReqSeqId(refundReqSeqId); |
| | | if (!"00000000".equals(refund.get("resp_code")) && "S".equals(refund.get("trans_stat"))) { |
| | | orderCrossCity.setState(orgState); |
| | | if ("00000000".equals(refund.get("resp_code")) && "S".equals(refund.get("trans_stat"))) { |
| | | orderCrossCity.setState(10); |
| | | }else if (!"00000000".equals(refund.get("resp_code"))) { |
| | | return ResultUtil.error("订单取消失败:" + refund.get("resp_desc").toString()); |
| | | } |
| | | tOrderCrossCityService.updateById(orderCrossCity); |
| | |
| | | try{ |
| | | ShiroUser user = ShiroKit.getUser(); |
| | | TOrderLogistics tOrderLogistics = tOrderLogisticsService.selectById(tOrderLogisticsId); |
| | | Integer orgState = tOrderLogistics.getState(); |
| | | tOrderLogistics.setState(10); |
| | | |
| | | //已支付的情况下进行退款操作 |
| | |
| | | String refundReqSeqId = RequestSeqUtil.generate("TK"); |
| | | Map<String, Object> refund = douGongRefundBiz.refund(refundReqSeqId, BigDecimal.valueOf(query.getAmount()), DateUtil.format(query.getInsertTime(), "yyyyMMdd"), orderLogistics.getOutTradeNo(), 1); |
| | | orderLogistics.setRefundReqSeqId(refundReqSeqId); |
| | | if (!"00000000".equals(refund.get("resp_code")) && "S".equals(refund.get("trans_stat"))) { |
| | | orderLogistics.setState(orgState); |
| | | tOrderLogistics.setState(orgState); |
| | | if ("00000000".equals(refund.get("resp_code")) && "S".equals(refund.get("trans_stat"))) { |
| | | orderLogistics.setState(10); |
| | | tOrderLogistics.setState(10); |
| | | }else if (!"00000000".equals(refund.get("resp_code"))) { |
| | | return ResultUtil.error("订单取消失败:" + refund.get("resp_desc").toString()); |
| | | } |
| | | tOrderLogisticsService.updateById(orderLogistics); |
| | |
| | | package com.stylefeng.guns.modular.huifu.biz; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.google.gson.JsonObject; |
| | | import com.huifu.bspay.sdk.opps.core.BasePay; |
| | | import com.huifu.bspay.sdk.opps.core.config.MerConfig; |
| | | import com.huifu.bspay.sdk.opps.core.exception.BasePayException; |
| | | import com.huifu.bspay.sdk.opps.core.net.BasePayRequest; |
| | | import com.huifu.bspay.sdk.opps.core.utils.RsaUtils; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.account.req.UserWithdrawalReq; |
| | | import com.stylefeng.guns.modular.huifu.properties.HuiFuProperties; |
| | | import com.stylefeng.guns.core.util.RequestSeqUtil; |
| | | import com.stylefeng.guns.modular.huifu.properties.HuiFuProperties; |
| | | import com.stylefeng.guns.modular.system.model.UserWithdrawal; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.security.KeyFactory; |
| | | import java.security.PrivateKey; |
| | | import java.security.Signature; |
| | | import java.security.spec.PKCS8EncodedKeySpec; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Base64; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | |
| | | /** |
| | | * 斗拱进件业务 |
| | |
| | | cardInfo.put("cert_validity_type", "1"); |
| | | } |
| | | paramsInfo.put("card_info", cardInfo.toJSONString()); |
| | | // 结算卡信息 |
| | | JSONArray cashConfigArr = new JSONArray(); |
| | | JSONObject cashConfig = new JSONObject(); |
| | | /** |
| | | * T1:下一工作日到银行账户; |
| | | * D1:下一自然日到银行账户; |
| | | * D0:当日到银行账户;默认D0; |
| | | * DM:当日到账;到账资金不包括当天的交易资金; |
| | | * 示例值:T1 |
| | | */ |
| | | cashConfig.put("cash_type", "D1"); |
| | | cashConfig.put("fix_amt", "0.00"); |
| | | cashConfig.put("weekday_fix_amt", "0.00"); |
| | | cashConfig.put("weekday_fee_rate", "0.00"); |
| | | cashConfigArr.add(cashConfig); |
| | | paramsInfo.put("cash_config", cashConfigArr.toJSONString()); |
| | | log.info("用户业务入驻返回参数:{}", paramsInfo); |
| | | // 3. 发起API调用 |
| | | Map<String, Object> response = BasePayRequest.requestBasePay("v2/user/busi/open", paramsInfo, null, false);; |
| | |
| | | paramsInfo.put("req_seq_id", RequestSeqUtil.generateForHuiFu()); |
| | | // 请求日期 |
| | | paramsInfo.put("req_date", DateUtil.format(new Date(),"yyyyMMdd")); |
| | | // 渠道商/商户汇付Id |
| | | paramsInfo.put("upper_huifu_id", huiFuProperties.getUpperHuifuId()); |
| | | // 结算卡信息 |
| | | JSONObject cardInfo = new JSONObject(); |
| | | cardInfo.put("card_type", "1"); |
| | |
| | | cardInfo.put("cert_validity_type", "1"); |
| | | } |
| | | paramsInfo.put("card_info", cardInfo.toJSONString()); |
| | | // 结算卡信息 |
| | | JSONArray cashConfigArr = new JSONArray(); |
| | | JSONObject cashConfig = new JSONObject(); |
| | | /** |
| | | * T1:下一工作日到银行账户; |
| | | * D1:下一自然日到银行账户; |
| | | * D0:当日到银行账户;默认D0; |
| | | * DM:当日到账;到账资金不包括当天的交易资金; |
| | | * 示例值:T1 |
| | | */ |
| | | cashConfig.put("switch_state", "1"); |
| | | cashConfig.put("cash_type", "D1"); |
| | | cashConfig.put("fix_amt", "0.00"); |
| | | cashConfig.put("weekday_fix_amt", "0.00"); |
| | | cashConfig.put("weekday_fee_rate", "0.00"); |
| | | cashConfigArr.add(cashConfig); |
| | | paramsInfo.put("cash_config", cashConfigArr.toJSONString()); |
| | | log.info("用户业务入驻修改返回参数:{}", paramsInfo); |
| | | |
| | | // 3. 发起API调用 |
| | | Map<String, Object> response = BasePayRequest.requestBasePay("v2/user/busi/modify", paramsInfo, null, false);; |
| | | log.info("用户业务入驻修改返回参数:{}", response); |