| New file |
| | |
| | | package com.stylefeng.guns.modular.huifu.biz; |
| | | |
| | | import com.alibaba.fastjson.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.stylefeng.guns.core.util.DateUtil; |
| | | import com.stylefeng.guns.modular.huifu.properties.HuiFuProperties; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.HttpMethod; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.ResponseEntity; |
| | | 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; |
| | | |
| | | /** |
| | | * 斗拱提现业务 |
| | | * @author mitao |
| | | * @date 2025/11/21 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | 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 |
| | | */ |
| | | |
| | | /** |
| | | * 交易退款接口 |
| | | * |
| | | * @param reqSeqId 请求流水号,同一huifu_id下当天唯一 |
| | | * @param ordAmt 申请退款金额,单位元 |
| | | * @param orgReqDate 原交易请求日期,格式yyyyMMdd |
| | | * @param orgReqSeqId 原交易请求流水号(三选一) |
| | | * @param type 类型 1:小件物流;2:跨城出行 |
| | | * @return 请求结果 |
| | | */ |
| | | public Map<String, Object> refund(String reqSeqId, BigDecimal ordAmt, String orgReqDate, String orgReqSeqId, Integer type) throws Exception { |
| | | log.info("开始调用斗拱退款接口, 退款金额: {}", ordAmt); |
| | | // 1. 数据初始化,填入对应的商户配置 |
| | | MerConfig merConfig = new MerConfig(); |
| | | merConfig.setProcutId(huiFuProperties.getProductId()); |
| | | merConfig.setSysId(huiFuProperties.getSysId()); |
| | | merConfig.setRsaPrivateKey(huiFuProperties.getRsaPrivateKey()); |
| | | merConfig.setRsaPublicKey(huiFuProperties.getRsaPublicKey()); |
| | | BasePay.initWithMerConfig(merConfig); |
| | | // 构建业务参数data |
| | | // 2.组装请求参数 |
| | | Map<String, Object> data = new HashMap<>(); |
| | | data.put("req_date", DateUtil.format(new Date(),"yyyyMMdd")); |
| | | data.put("req_seq_id", reqSeqId); |
| | | data.put("huifu_id", huiFuProperties.getSysId()); |
| | | data.put("ord_amt", ordAmt.setScale(2, RoundingMode.HALF_UP).toString()); |
| | | data.put("org_req_date", orgReqDate); |
| | | // 三选一参数:org_hf_seq_id,org_party_order_id,org_req_seq_id |
| | | data.put("org_req_seq_id", orgReqSeqId); |
| | | String notifyUrl = type.equals(1) ? "/base/dougong/refund-logistics" : "/base/dougong/refund-crosscity"; |
| | | data.put("notify_url", callbackPath + notifyUrl); |
| | | |
| | | // 发送HTTP请求 - POST JSON格式 |
| | | Map<String, Object> response = BasePayRequest.requestBasePay(REFUND_URL, 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; |
| | | } |
| | | } |
| | | } |
| | |
| | | package com.stylefeng.guns.modular.huifu.biz; |
| | | |
| | | import com.alibaba.fastjson.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.stylefeng.guns.modular.huifu.properties.HuiFuProperties; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | 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.text.SimpleDateFormat; |
| | | import java.util.Base64; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 斗拱提现业务 |
| | |
| | | private RestTemplate restTemplate; |
| | | |
| | | @Value("${callbackPath}") |
| | | private static String callbackPath; |
| | | private String callbackPath; |
| | | |
| | | private static final String ENCASHMENT_URL = "https://api.huifu.com/v2/trade/settlement/encashment"; |
| | | /** |
| | |
| | | * @param type 提现类型 1:企业 2:用户/司机 |
| | | * @return 请求结果 |
| | | */ |
| | | public JSONObject encashment(String reqSeqId,BigDecimal cashAmt, String huifuId, String tokenNo, Integer type) { |
| | | try { |
| | | log.info("开始调用斗拱提现接口,取现方ID: {}, 取现金额: {}", huifuId, cashAmt); |
| | | public Map<String,Object> encashment(String reqSeqId,BigDecimal cashAmt, String huifuId, String tokenNo, Integer type) throws Exception { |
| | | log.info("开始调用斗拱提现接口,取现方ID: {}, 取现金额: {}", huifuId, cashAmt); |
| | | // 1. 数据初始化,填入对应的商户配置 |
| | | MerConfig merConfig = new MerConfig(); |
| | | merConfig.setProcutId(huiFuProperties.getProductId()); |
| | | merConfig.setSysId(huiFuProperties.getSysId()); |
| | | merConfig.setRsaPrivateKey(huiFuProperties.getRsaPrivateKey()); |
| | | merConfig.setRsaPublicKey(huiFuProperties.getRsaPublicKey()); |
| | | BasePay.initWithMerConfig(merConfig); |
| | | // 2.组装请求参数 |
| | | Map<String, Object> data = new HashMap<>(); |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); |
| | | String reqDate = dateFormat.format(new Date()); |
| | | |
| | | // 构建业务参数data |
| | | JSONObject data = new JSONObject(); |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); |
| | | String reqDate = dateFormat.format(new Date()); |
| | | |
| | | data.put("req_date", reqDate); |
| | | data.put("req_seq_id", reqSeqId); |
| | | data.put("cash_amt", cashAmt.toString()); |
| | | data.put("huifu_id", huifuId); |
| | | /** |
| | | * D0:当日到账;当日交易资金当天可取现到账; |
| | | * T1:次工作日到账; |
| | | * D1:次自然日到账; |
| | | * DM:当日到账;到账资金不包括当天的交易资金; |
| | | * 示例值:D0 |
| | | */ |
| | | data.put("into_acct_date_type", "D1"); |
| | | data.put("token_no", tokenNo); |
| | | String notifyUrl = type.equals(1) ? "/base/dougong/ent/encashment" : "/base/dougong/user/encashment"; |
| | | data.put("notify_url", callbackPath + notifyUrl); |
| | | |
| | | String dataStr = data.toJSONString(); |
| | | log.info("业务参数data: {}", dataStr); |
| | | |
| | | // 构建完整请求参数 |
| | | JSONObject requestJson = new JSONObject(); |
| | | requestJson.put("sys_id", huiFuProperties.getHuifuId()); // 使用配置中的huifuId作为sys_id |
| | | requestJson.put("product_id", huiFuProperties.getProductId()); |
| | | requestJson.put("data", dataStr); |
| | | |
| | | // 生成签名 - 对整个报文进行签名 |
| | | String signData = requestJson.toJSONString(); |
| | | log.info("待签名报文: {}", signData); |
| | | |
| | | String signature = sign(signData, huiFuProperties.getRsaPrivateKey()); |
| | | if (signature == null) { |
| | | log.error("签名生成失败"); |
| | | return createErrorResult("签名生成失败"); |
| | | } |
| | | |
| | | requestJson.put("sign", signature); |
| | | |
| | | // 发送HTTP请求 - POST JSON格式 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.setContentType(MediaType.APPLICATION_JSON_UTF8); |
| | | |
| | | HttpEntity<String> requestEntity = new HttpEntity<>(requestJson.toJSONString(), headers); |
| | | |
| | | log.info("发送斗拱提现请求到: {}", ENCASHMENT_URL); |
| | | ResponseEntity<String> response = restTemplate.exchange( |
| | | ENCASHMENT_URL, |
| | | HttpMethod.POST, |
| | | requestEntity, |
| | | String.class |
| | | ); |
| | | |
| | | log.info("斗拱提现接口响应状态: {}, 响应内容: {}", response.getStatusCode(), response.getBody()); |
| | | |
| | | // 解析响应 |
| | | JSONObject result = JSONObject.parseObject(response.getBody()); |
| | | return result; |
| | | |
| | | } catch (Exception e) { |
| | | log.error("调用斗拱提现接口异常: {}", e.getMessage(), e); |
| | | return createErrorResult("调用接口异常: " + e.getMessage()); |
| | | } |
| | | data.put("req_date", reqDate); |
| | | data.put("req_seq_id", reqSeqId); |
| | | data.put("cash_amt", cashAmt.setScale(2, RoundingMode.HALF_UP).toString()); |
| | | data.put("huifu_id", huifuId); |
| | | /** |
| | | * D0:当日到账;当日交易资金当天可取现到账; |
| | | * T1:次工作日到账; |
| | | * D1:次自然日到账; |
| | | * DM:当日到账;到账资金不包括当天的交易资金; |
| | | * 示例值:D0 |
| | | */ |
| | | data.put("into_acct_date_type", "D1"); |
| | | data.put("token_no", tokenNo); |
| | | String notifyUrl = type.equals(1) ? "/base/dougong/ent/encashment" : "/base/dougong/user/encashment"; |
| | | data.put("notify_url", callbackPath + notifyUrl); |
| | | String dataStr = JSONObject.toJSONString(data); |
| | | log.info("业务参数data: {}", dataStr); |
| | | Map<String, Object> response = BasePayRequest.requestBasePay("v2/trade/settlement/encashment", data, null, false); |
| | | log.info("斗拱提现接口响应内容: {}", JSONObject.toJSONString(response)); |
| | | return response; |
| | | } |
| | | |
| | | |
| | |
| | | import com.huifu.bspay.sdk.opps.core.net.BasePayRequest; |
| | | import com.stylefeng.guns.modular.huifu.properties.HuiFuProperties; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | |
| | | public class FenZhangUtil { |
| | | |
| | | @Autowired |
| | | private static HuiFuProperties huiFuProperties; |
| | | private HuiFuProperties huiFuProperties; |
| | | |
| | | |
| | | // public static void main(String[] args) throws Exception { |
| | |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/base/dougong/") |
| | | @RequestMapping("/base/dougong") |
| | | public class DouGongNotifyController { |
| | | @Autowired |
| | | private HuiFuProperties huiFuProperties; |
| | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 控制器 |
| | |
| | | |
| | | } |
| | | String reqSeqId = RequestSeqUtil.extractPrefix("TX"); |
| | | JSONObject result = douGongWithdrawBiz.encashment(reqSeqId, BigDecimal.valueOf(withdrawalReq.getAmount()), companyId.get(0).getHuifuId(), companyId.get(0).getTokenNo(), 1); |
| | | if (!result.get("resp_code").equals("00000000") || !result.getBoolean("success")) { |
| | | Map<String,Object> result = douGongWithdrawBiz.encashment(reqSeqId, BigDecimal.valueOf(withdrawalReq.getAmount()), companyId.get(0).getHuifuId(), companyId.get(0).getTokenNo(), 1); |
| | | if (!result.get("resp_code").equals("00000000")) { |
| | | return new ErrorTip(500, "操作失败,异常原因:"+result.get("resp_desc")); |
| | | } |
| | | tCompanyWithdraw.setReqSeqId(reqSeqId); |
| | |
| | | import com.stylefeng.guns.core.util.WoUtil; |
| | | import com.stylefeng.guns.modular.cloudPayment.example.AllocationExample; |
| | | import com.stylefeng.guns.modular.cloudPayment.req.AllocationReq; |
| | | import com.stylefeng.guns.modular.huifu.biz.FenZhangUtil; |
| | | import com.stylefeng.guns.modular.system.controller.util.Base64Util; |
| | | import com.stylefeng.guns.modular.system.dao.DriverPunishMapper; |
| | | import com.stylefeng.guns.modular.system.dao.DriverTrainMapper; |
| | |
| | | @Autowired |
| | | private IUserWithdrawalService userWithdrawalService; |
| | | |
| | | public String createAllocationReq(Integer companyId,Integer userId,int type,double money){ |
| | | public String createAllocationReq(Integer companyId,Integer userId,int type,double money) throws Exception { |
| | | List<TEnterpriseWithdrawal> tEnterpriseWithdrawals = tEnterpriseWithdrawalService.selectList(new EntityWrapper<TEnterpriseWithdrawal>().eq("companyId", companyId)); |
| | | TDriver tUser = tDriverService.selectById(userId); |
| | | List<UserWithdrawal> userWithdrawals = userWithdrawalService.selectList(new EntityWrapper<UserWithdrawal>().eq("phone", tUser.getPhone())); |
| | |
| | | return "error"; |
| | | } |
| | | |
| | | AllocationReq allocationReq= new AllocationReq(); |
| | | allocationReq.setOutOrderNo(ToolUtil.getRandomString(32)); |
| | | //AllocationReq allocationReq= new AllocationReq(); |
| | | //allocationReq.setOutOrderNo(ToolUtil.getRandomString(32)); |
| | | Map<String, Object> result; |
| | | if(type==1){ |
| | | |
| | | allocationReq.setPayBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | allocationReq.setRecvBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | |
| | | allocationReq.setPassword(Base64Util.decode(tEnterpriseWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | //allocationReq.setPayBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | //allocationReq.setRecvBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | // |
| | | //allocationReq.setPassword(Base64Util.decode(tEnterpriseWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | result = FenZhangUtil.fenzhang(RequestSeqUtil.generate("TK"), DateUtil.formatDate(new Date(), "yyyyMMdd"), String.valueOf(money), userWithdrawals.get(0).getHuiFuId()); |
| | | }else { |
| | | allocationReq.setRecvBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | allocationReq.setPayBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | allocationReq.setPassword(Base64Util.decode(userWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | //allocationReq.setRecvBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | //allocationReq.setPayBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | //allocationReq.setPassword(Base64Util.decode(userWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | result = FenZhangUtil.payFromUser(RequestSeqUtil.generate("TK"), DateUtil.formatDate(new Date(), "yyyyMMdd"), String.valueOf(money), userWithdrawals.get(0).getHuiFuId()); |
| | | } |
| | | money=money*100; |
| | | allocationReq.setAmount((int)money); |
| | | allocationReq.setProductName("分账"); |
| | | allocationReq.setProductCount(1); |
| | | allocationReq.setOrderNo(ToolUtil.getRandomString(32)); |
| | | allocationReq.setOrderAmount(1l); |
| | | try { |
| | | AllocationResp allocationResp = AllocationExample.create(allocationReq); |
| | | System.out.println(allocationResp); |
| | | if ("00000000".equals(result.get("respCode").toString())) { |
| | | return "ok"; |
| | | } catch (UpyztException e) { |
| | | e.printStackTrace(); |
| | | return e.getMessage(); |
| | | } else { |
| | | return result.get("respDesc").toString(); |
| | | } |
| | | //money=money*100; |
| | | //allocationReq.setAmount((int)money); |
| | | //allocationReq.setProductName("分账"); |
| | | //allocationReq.setProductCount(1); |
| | | //allocationReq.setOrderNo(ToolUtil.getRandomString(32)); |
| | | //allocationReq.setOrderAmount(1l); |
| | | //try { |
| | | // AllocationResp allocationResp = AllocationExample.create(allocationReq); |
| | | // System.out.println(allocationResp); |
| | | // return "ok"; |
| | | //} catch (UpyztException e) { |
| | | // e.printStackTrace(); |
| | | // return e.getMessage(); |
| | | //} |
| | | |
| | | } |
| | | } |
| | |
| | | try { |
| | | log.info("用户提现创建========="); |
| | | String reqSeqId = RequestSeqUtil.generate("TX"); |
| | | JSONObject result = douGongWithdrawBiz.encashment(reqSeqId, tPubWithdrawal.getMoney(), userWithdrawals.get(0).getHuiFuId(), userWithdrawals.get(0).getTokenNo(), 2); |
| | | if (!result.get("resp_code").equals("00000000") || !result.getBoolean("success")) { |
| | | Map<String,Object> result = douGongWithdrawBiz.encashment(reqSeqId, tPubWithdrawal.getMoney(), userWithdrawals.get(0).getHuiFuId(), userWithdrawals.get(0).getTokenNo(), 2); |
| | | if (!result.get("resp_code").equals("00000000")) { |
| | | return new ErrorTip(500, "操作失败,异常原因:"+result.get("resp_desc")); |
| | | } |
| | | |
| | |
| | | //tPubWithdrawal.setWithdrawId(withdrawalResp.getWithdrawalId()); |
| | | tPubWithdrawalService.updateById(tPubWithdrawal); |
| | | //log.info("用户提现创建信息========="+withdrawalResp.toString()); |
| | | log.info("用户提现创建信息:{}", result.toJSONString()); |
| | | log.info("用户提现创建信息:{}", JSONObject.toJSONString(result)); |
| | | log.info("用户提现创建成功========="); |
| | | } catch (Exception e) { |
| | | log.info("用户提现创建失败========="); |
| | |
| | | try { |
| | | log.info("司机提现创建========="); |
| | | String reqSeqId = RequestSeqUtil.generate("TX"); |
| | | JSONObject result = douGongWithdrawBiz.encashment(reqSeqId, tPubWithdrawal.getMoney(), userWithdrawal.getHuiFuId(), userWithdrawal.getTokenNo(), 2); |
| | | if (!result.get("resp_code").equals("00000000") || !result.getBoolean("success")) { |
| | | Map<String,Object> result = douGongWithdrawBiz.encashment(reqSeqId, tPubWithdrawal.getMoney(), userWithdrawal.getHuiFuId(), userWithdrawal.getTokenNo(), 2); |
| | | if (!result.get("resp_code").equals("00000000")) { |
| | | return new ErrorTip(500, "操作失败,异常原因:"+result.get("resp_desc")); |
| | | } |
| | | |
| | |
| | | //tPubWithdrawal.setWithdrawId(withdrawalResp.getWithdrawalId()); |
| | | tPubWithdrawalService.updateById(tPubWithdrawal); |
| | | //log.info("司机提现创建信息========="+withdrawalResp.toString()); |
| | | log.info("司机提现创建信息:{}", result.toJSONString()); |
| | | log.info("司机提现创建信息:{}", JSONObject.toJSONString(result)); |
| | | log.info("司机提现创建成功========="); |
| | | } catch (Exception e) { |
| | | log.info("司机提现创建失败========="); |
| | |
| | | import com.stylefeng.guns.core.common.constant.factory.PageFactory; |
| | | import com.stylefeng.guns.core.shiro.ShiroKit; |
| | | import com.stylefeng.guns.core.shiro.ShiroUser; |
| | | import com.stylefeng.guns.core.util.DateUtil; |
| | | import com.stylefeng.guns.core.util.RequestSeqUtil; |
| | | import com.stylefeng.guns.core.util.SinataUtil; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.cloudPayment.example.AllocationExample; |
| | | import com.stylefeng.guns.modular.cloudPayment.req.AllocationReq; |
| | | import com.stylefeng.guns.modular.huifu.biz.DouGongRefundBiz; |
| | | import com.stylefeng.guns.modular.huifu.biz.FenZhangUtil; |
| | | import com.stylefeng.guns.modular.system.controller.general.TDriverController; |
| | | import com.stylefeng.guns.modular.system.controller.util.Base64Util; |
| | | import com.stylefeng.guns.modular.system.controller.util.GetOpenBodySig; |
| | |
| | | |
| | | @Value("${filePath}") |
| | | private String filePath; |
| | | |
| | | @Autowired |
| | | private DouGongRefundBiz douGongRefundBiz; |
| | | |
| | | /** |
| | | * 跳转到跨城出行订单首页 |
| | |
| | | } |
| | | |
| | | if(query.getPayType() == 1){//微信 |
| | | Map<String, String> map = payMoneyUtil.wxRefund(query.getCode(), tOrderCrossCityId + "_3", query.getAmount().toString(), query.getAmount().toString(), "/base/cancleOrderWXPay"); |
| | | if(!"SUCCESS".equals(map.get("return_code"))){ |
| | | return ResultUtil.error(map.get("return_msg")); |
| | | //Map<String, String> map = payMoneyUtil.wxRefund(query.getCode(), tOrderCrossCityId + "_3", query.getAmount().toString(), query.getAmount().toString(), "/base/cancleOrderWXPay"); |
| | | //if(!"SUCCESS".equals(map.get("return_code"))){ |
| | | // return ResultUtil.error(map.get("return_msg")); |
| | | //} |
| | | 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"))) { |
| | | return ResultUtil.error("订单取消失败:" + refund.get("resp_desc").toString()); |
| | | } |
| | | tOrderCrossCityService.updateById(orderCrossCity); |
| | | }else if(query.getPayType()==4){ |
| | | // TODO 退款 |
| | | TUser userInfo = userService.selectById(orderCrossCity.getUserId()); |
| | |
| | | String billNo = orderCrossCity.getBillNo(); |
| | | // cancleMoney(orderCrossCity.getPayMoney(),billNo); |
| | | }else{//支付宝 |
| | | Map<String, String> map = payMoneyUtil.aliRefund(query.getCode(), query.getAmount().toString()); |
| | | if(!"10000".equals(map.get("code"))){ |
| | | return ResultUtil.error(map.get("msg")); |
| | | //Map<String, String> map = payMoneyUtil.aliRefund(query.getCode(), query.getAmount().toString()); |
| | | //if(!"10000".equals(map.get("code"))){ |
| | | // return ResultUtil.error(map.get("msg")); |
| | | //} |
| | | 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"))) { |
| | | return ResultUtil.error("订单取消失败:" + refund.get("resp_desc").toString()); |
| | | } |
| | | tOrderCrossCityService.updateById(orderCrossCity); |
| | | //添加交易明细 |
| | | transactionDetailsService.saveData(orderCrossCity.getUserId(), "跨城出行取消退款", query.getAmount(), 1, 1, 1, 3, tOrderCrossCityId); |
| | | } |
| | |
| | | @Autowired |
| | | private IUserWithdrawalService userWithdrawalService; |
| | | |
| | | public String createAllocationReq(Integer companyId,Integer userId,int type,double money){ |
| | | public String createAllocationReq(Integer companyId,Integer userId,int type,double money) throws Exception { |
| | | List<TEnterpriseWithdrawal> tEnterpriseWithdrawals = tEnterpriseWithdrawalService.selectList(new EntityWrapper<TEnterpriseWithdrawal>().eq("companyId", companyId)); |
| | | TDriver tUser = tDriverService.selectById(userId); |
| | | List<UserWithdrawal> userWithdrawals = userWithdrawalService.selectList(new EntityWrapper<UserWithdrawal>().eq("phone", tUser.getPhone())); |
| | |
| | | return "error"; |
| | | } |
| | | |
| | | AllocationReq allocationReq= new AllocationReq(); |
| | | allocationReq.setOutOrderNo(ToolUtil.getRandomString(32)); |
| | | //AllocationReq allocationReq= new AllocationReq(); |
| | | //allocationReq.setOutOrderNo(ToolUtil.getRandomString(32)); |
| | | Map<String, Object> result; |
| | | if(type==1){ |
| | | |
| | | allocationReq.setPayBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | allocationReq.setRecvBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | |
| | | allocationReq.setPassword(Base64Util.decode(tEnterpriseWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | //allocationReq.setPayBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | //allocationReq.setRecvBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | // |
| | | //allocationReq.setPassword(Base64Util.decode(tEnterpriseWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | result = FenZhangUtil.fenzhang(RequestSeqUtil.generate("TK"), DateUtil.formatDate(new Date(), "yyyyMMdd"), String.valueOf(money), userWithdrawals.get(0).getHuiFuId()); |
| | | }else { |
| | | allocationReq.setRecvBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | allocationReq.setPayBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | allocationReq.setPassword(Base64Util.decode(userWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | //allocationReq.setRecvBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | //allocationReq.setPayBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | //allocationReq.setPassword(Base64Util.decode(userWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | result = FenZhangUtil.payFromUser(RequestSeqUtil.generate("TK"), DateUtil.formatDate(new Date(), "yyyyMMdd"), String.valueOf(money), userWithdrawals.get(0).getHuiFuId()); |
| | | } |
| | | money=money*100; |
| | | allocationReq.setAmount((int)money); |
| | | allocationReq.setProductName("分账"); |
| | | allocationReq.setProductCount(1); |
| | | allocationReq.setOrderNo(ToolUtil.getRandomString(32)); |
| | | allocationReq.setOrderAmount(1l); |
| | | try { |
| | | AllocationResp allocationResp = AllocationExample.create(allocationReq); |
| | | System.out.println(allocationResp); |
| | | if ("00000000".equals(result.get("respCode").toString())) { |
| | | return "ok"; |
| | | } catch (UpyztException e) { |
| | | e.printStackTrace(); |
| | | return e.getMessage(); |
| | | } else { |
| | | return result.get("respDesc").toString(); |
| | | } |
| | | //money=money*100; |
| | | //allocationReq.setAmount((int)money); |
| | | //allocationReq.setProductName("分账"); |
| | | //allocationReq.setProductCount(1); |
| | | //allocationReq.setOrderNo(ToolUtil.getRandomString(32)); |
| | | //allocationReq.setOrderAmount(1l); |
| | | //try { |
| | | // AllocationResp allocationResp = AllocationExample.create(allocationReq); |
| | | // System.out.println(allocationResp); |
| | | // return "ok"; |
| | | //} catch (UpyztException e) { |
| | | // e.printStackTrace(); |
| | | // return e.getMessage(); |
| | | //} |
| | | |
| | | } |
| | | public String createAllocationReqUser(Integer companyId,Integer userId,int type,double money){ |
| | | public String createAllocationReqUser(Integer companyId,Integer userId,int type,double money) throws Exception { |
| | | List<TEnterpriseWithdrawal> tEnterpriseWithdrawals = tEnterpriseWithdrawalService.selectList(new EntityWrapper<TEnterpriseWithdrawal>().eq("companyId", companyId)); |
| | | TUser tUser = userService.selectById(userId); |
| | | List<UserWithdrawal> userWithdrawals = userWithdrawalService.selectList(new EntityWrapper<UserWithdrawal>().eq("phone", tUser.getPhone())); |
| | | if(userWithdrawals.size()==0){ |
| | | return "error"; |
| | | } |
| | | AllocationReq allocationReq= new AllocationReq(); |
| | | allocationReq.setOutOrderNo(ToolUtil.getRandomString(32)); |
| | | //AllocationReq allocationReq= new AllocationReq(); |
| | | //allocationReq.setOutOrderNo(ToolUtil.getRandomString(32)); |
| | | Map<String, Object> result; |
| | | if(type==1){ |
| | | |
| | | allocationReq.setPayBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | allocationReq.setRecvBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | |
| | | allocationReq.setPassword(Base64Util.decode(tEnterpriseWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | //allocationReq.setPayBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | //allocationReq.setRecvBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | // |
| | | //allocationReq.setPassword(Base64Util.decode(tEnterpriseWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | result = FenZhangUtil.fenzhang(RequestSeqUtil.generate("TK"), DateUtil.formatDate(new Date(), "yyyyMMdd"), String.valueOf(money), userWithdrawals.get(0).getHuiFuId()); |
| | | }else { |
| | | allocationReq.setRecvBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | allocationReq.setPayBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | allocationReq.setPassword(Base64Util.decode(userWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | //allocationReq.setRecvBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | //allocationReq.setPayBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | //allocationReq.setPassword(Base64Util.decode(userWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | result = FenZhangUtil.payFromUser(RequestSeqUtil.generate("TK"), DateUtil.formatDate(new Date(), "yyyyMMdd"), String.valueOf(money), userWithdrawals.get(0).getHuiFuId()); |
| | | } |
| | | money=money*100; |
| | | allocationReq.setAmount((int)money); |
| | | allocationReq.setProductName("分账"); |
| | | allocationReq.setProductCount(1); |
| | | allocationReq.setOrderNo(ToolUtil.getRandomString(32)); |
| | | allocationReq.setOrderAmount(1l); |
| | | try { |
| | | AllocationResp allocationResp = AllocationExample.create(allocationReq); |
| | | System.out.println(allocationResp); |
| | | if ("00000000".equals(result.get("respCode").toString())) { |
| | | return "ok"; |
| | | } catch (UpyztException e) { |
| | | e.printStackTrace(); |
| | | return e.getMessage(); |
| | | } else { |
| | | return result.get("respDesc").toString(); |
| | | } |
| | | //money=money*100; |
| | | //allocationReq.setAmount((int)money); |
| | | //allocationReq.setProductName("分账"); |
| | | //allocationReq.setProductCount(1); |
| | | //allocationReq.setOrderNo(ToolUtil.getRandomString(32)); |
| | | //allocationReq.setOrderAmount(1l); |
| | | //try { |
| | | // AllocationResp allocationResp = AllocationExample.create(allocationReq); |
| | | // System.out.println(allocationResp); |
| | | // return "ok"; |
| | | //} catch (UpyztException e) { |
| | | // e.printStackTrace(); |
| | | // return e.getMessage(); |
| | | //} |
| | | |
| | | } |
| | | |
| | |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.cloudPayment.example.AllocationExample; |
| | | import com.stylefeng.guns.modular.cloudPayment.req.AllocationReq; |
| | | import com.stylefeng.guns.modular.huifu.biz.DouGongRefundBiz; |
| | | import com.stylefeng.guns.modular.huifu.biz.FenZhangUtil; |
| | | import com.stylefeng.guns.modular.system.controller.util.Base64Util; |
| | | import com.stylefeng.guns.modular.system.dao.OrderCancelMapper; |
| | |
| | | import com.unionpay.upyzt.exception.UpyztException; |
| | | import com.unionpay.upyzt.resp.AllocationResp; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | import java.util.Collections; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 小件物流订单控制器 |
| | |
| | | private PayMoneyUtil payMoneyUtil; |
| | | @Autowired |
| | | private IUserCouponRecordService userCouponRecordService; |
| | | @Autowired |
| | | private DouGongRefundBiz douGongRefundBiz; |
| | | |
| | | /** |
| | | * 跳转到小件物流订单首页 |
| | |
| | | List<PaymentRecord> querys = paymentRecordService.query_(1, tOrderLogistics.getUserId(), 1, tOrderLogistics.getId(), tOrderLogistics.getType(), tOrderLogistics.getPayType(), 2); |
| | | System.out.println(querys); |
| | | boolean b = false; |
| | | List<Integer> orderIds = querys.stream().map(PaymentRecord::getOrderId).collect(Collectors.toList()); |
| | | Map<Integer, TOrderLogistics> orderLogisticsMap = Collections.emptyMap(); |
| | | if (CollectionUtils.isNotEmpty(orderIds)) { |
| | | orderLogisticsMap = tOrderLogisticsService.selectList(new EntityWrapper<TOrderLogistics>() |
| | | .in("id", orderIds).isNotNull("outTradeNo")) |
| | | .stream().collect(Collectors.toMap(TOrderLogistics::getId, Function.identity())); |
| | | } |
| | | for (PaymentRecord query : querys) { |
| | | System.out.println("支付方式:"+query.getPayType()); |
| | | if(query.getPayType() == 1){//微信 |
| | | Map<String, String> map = payMoneyUtil.wxRefund(query.getCode(), tOrderLogistics.getId() + "_" + tOrderLogistics.getType() + "_" + UUIDUtil.getRandomCode(5), query.getAmount().toString(), query.getAmount().toString(), "/base/cancleOrderWXPay"); |
| | | System.out.println("map:"+map); |
| | | if(!"SUCCESS".equals(map.get("return_code"))){ |
| | | return ResultUtil.error(map.get("return_msg")); |
| | | //Map<String, String> map = payMoneyUtil.wxRefund(query.getCode(), tOrderLogistics.getId() + "_" + tOrderLogistics.getType() + "_" + UUIDUtil.getRandomCode(5), query.getAmount().toString(), query.getAmount().toString(), "/base/cancleOrderWXPay"); |
| | | //System.out.println("map:"+map); |
| | | //if(!"SUCCESS".equals(map.get("return_code"))){ |
| | | // return ResultUtil.error(map.get("return_msg")); |
| | | //} |
| | | TOrderLogistics orderLogistics = orderLogisticsMap.get(query.getOrderId()); |
| | | if (Objects.isNull(orderLogistics)) { |
| | | log.error("小件物流取消订单退款失败,未找到对应的斗拱支付订单,orderId={}", query.getOrderId()); |
| | | continue; |
| | | } |
| | | 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"))) { |
| | | return ResultUtil.error("订单取消失败:" + refund.get("resp_desc").toString()); |
| | | } |
| | | tOrderLogisticsService.updateById(orderLogistics); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | AllocationReq allocationReq= new AllocationReq(); |
| | | allocationReq.setOutOrderNo(ToolUtil.getRandomString(32)); |
| | | if(type==1){ |
| | | |
| | | allocationReq.setPayBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | allocationReq.setRecvBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | |
| | | allocationReq.setPassword(Base64Util.decode(tEnterpriseWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | }else { |
| | | allocationReq.setRecvBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | allocationReq.setPayBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | allocationReq.setPassword(Base64Util.decode(userWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | } |
| | | money=money*100; |
| | | allocationReq.setAmount((int)money); |
| | | allocationReq.setProductName("分账"); |
| | | allocationReq.setProductCount(1); |
| | | allocationReq.setOrderNo(ToolUtil.getRandomString(32)); |
| | | allocationReq.setOrderAmount(1l); |
| | | try { |
| | | AllocationResp allocationResp = AllocationExample.create(allocationReq); |
| | | System.out.println(allocationResp); |
| | | return "ok"; |
| | | } catch (UpyztException e) { |
| | | e.printStackTrace(); |
| | | return e.getMessage(); |
| | | Map<String, Object> result; |
| | | if(type==1){ |
| | | |
| | | //allocationReq.setPayBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | //allocationReq.setRecvBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | // |
| | | //allocationReq.setPassword(Base64Util.decode(tEnterpriseWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | result = FenZhangUtil.fenzhang(RequestSeqUtil.generate("TK"), DateUtil.formatDate(new Date(), "yyyyMMdd"), String.valueOf(money), userWithdrawals.get(0).getHuiFuId()); |
| | | }else { |
| | | //allocationReq.setRecvBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | //allocationReq.setPayBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | //allocationReq.setPassword(Base64Util.decode(userWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | result = FenZhangUtil.payFromUser(RequestSeqUtil.generate("TK"), DateUtil.formatDate(new Date(), "yyyyMMdd"), String.valueOf(money), userWithdrawals.get(0).getHuiFuId()); |
| | | } |
| | | if ("00000000".equals(result.get("respCode").toString())) { |
| | | return "ok"; |
| | | } else { |
| | | return result.get("respDesc").toString(); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("分账异常", e); |
| | | throw new RuntimeException(e); |
| | | } |
| | | //money=money*100; |
| | | //allocationReq.setAmount((int)money); |
| | | //allocationReq.setProductName("分账"); |
| | | //allocationReq.setProductCount(1); |
| | | //allocationReq.setOrderNo(ToolUtil.getRandomString(32)); |
| | | //allocationReq.setOrderAmount(1l); |
| | | //try { |
| | | // AllocationResp allocationResp = AllocationExample.create(allocationReq); |
| | | // System.out.println(allocationResp); |
| | | // return "ok"; |
| | | //} catch (UpyztException e) { |
| | | // e.printStackTrace(); |
| | | // return e.getMessage(); |
| | | //} |
| | | |
| | | } |
| | | public String createAllocationReqUser(Integer companyId,Integer userId,int type,double money) throws Exception { |
| | | public String createAllocationReqUser(Integer companyId,Integer userId,int type,double money) { |
| | | List<TEnterpriseWithdrawal> tEnterpriseWithdrawals = tEnterpriseWithdrawalService.selectList(new EntityWrapper<TEnterpriseWithdrawal>().eq("companyId", companyId)); |
| | | TUser tUser = userService.selectById(userId); |
| | | List<UserWithdrawal> userWithdrawals = userWithdrawalService.selectList(new EntityWrapper<UserWithdrawal>().eq("phone", tUser.getPhone())); |
| | | if(userWithdrawals.size()==0){ |
| | | return "error"; |
| | | } |
| | | AllocationReq allocationReq= new AllocationReq(); |
| | | allocationReq.setOutOrderNo(ToolUtil.getRandomString(32)); |
| | | Map<String, Object> result; |
| | | if(type==1){ |
| | | //AllocationReq allocationReq= new AllocationReq(); |
| | | //allocationReq.setOutOrderNo(ToolUtil.getRandomString(32)); |
| | | try { |
| | | Map<String, Object> result; |
| | | if(type==1){ |
| | | |
| | | //allocationReq.setPayBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | //allocationReq.setRecvBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | // |
| | | //allocationReq.setPassword(Base64Util.decode(tEnterpriseWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | result = FenZhangUtil.fenzhang(RequestSeqUtil.generate("TK"), DateUtil.formatDate(new Date(), "yyyyMMdd"), String.valueOf(money), userWithdrawals.get(0).getHuiFuId()); |
| | | }else { |
| | | //allocationReq.setRecvBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | //allocationReq.setPayBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | //allocationReq.setPassword(Base64Util.decode(userWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | result = FenZhangUtil.payFromUser(RequestSeqUtil.generate("TK"), DateUtil.formatDate(new Date(), "yyyyMMdd"), String.valueOf(money), userWithdrawals.get(0).getHuiFuId()); |
| | | } |
| | | if ("00000000".equals(result.get("respCode").toString())) { |
| | | return "ok"; |
| | | } else { |
| | | return result.get("respDesc").toString(); |
| | | //allocationReq.setPayBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | //allocationReq.setRecvBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | // |
| | | //allocationReq.setPassword(Base64Util.decode(tEnterpriseWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | result = FenZhangUtil.fenzhang(RequestSeqUtil.generate("TK"), DateUtil.formatDate(new Date(), "yyyyMMdd"), String.valueOf(money), userWithdrawals.get(0).getHuiFuId()); |
| | | }else { |
| | | //allocationReq.setRecvBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | //allocationReq.setPayBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | //allocationReq.setPassword(Base64Util.decode(userWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | result = FenZhangUtil.payFromUser(RequestSeqUtil.generate("TK"), DateUtil.formatDate(new Date(), "yyyyMMdd"), String.valueOf(money), userWithdrawals.get(0).getHuiFuId()); |
| | | } |
| | | if ("00000000".equals(result.get("respCode").toString())) { |
| | | return "ok"; |
| | | } else { |
| | | return result.get("respDesc").toString(); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("分账异常", e); |
| | | throw new RuntimeException(e); |
| | | } |
| | | //money=money*100; |
| | | //allocationReq.setAmount((int)money); |
| | |
| | | |
| | | |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.huifu.biz.DouGongRefundBiz; |
| | | import com.stylefeng.guns.modular.system.dao.OrderCancelMapper; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | |
| | | private String payOrderId; |
| | | |
| | | private String billNo; |
| | | /** |
| | | * 斗拱交易流水号 |
| | | */ |
| | | private String outTradeNo; |
| | | |
| | | /** |
| | | * 斗拱退款流水号 |
| | | */ |
| | | private String refundReqSeqId; |
| | | |
| | | |
| | | public String getRefundReqSeqId() { |
| | | return refundReqSeqId; |
| | | } |
| | | |
| | | public void setRefundReqSeqId(String refundReqSeqId) { |
| | | this.refundReqSeqId = refundReqSeqId; |
| | | } |
| | | |
| | | public String getOutTradeNo() { |
| | | return outTradeNo; |
| | | } |
| | | |
| | | public void setOutTradeNo(String outTradeNo) { |
| | | this.outTradeNo = outTradeNo; |
| | | } |
| | | public String getBillNo() { |
| | | return billNo; |
| | | } |
| | |
| | | */ |
| | | private BigDecimal timeOutMoney; |
| | | |
| | | private String outTradeNo; |
| | | |
| | | /** |
| | | * 斗拱退款流水号 |
| | | */ |
| | | private String refundReqSeqId; |
| | | |
| | | |
| | | public String getRefundReqSeqId() { |
| | | return refundReqSeqId; |
| | | } |
| | | |
| | | public void setRefundReqSeqId(String refundReqSeqId) { |
| | | this.refundReqSeqId = refundReqSeqId; |
| | | } |
| | | |
| | | public String getOutTradeNo() { |
| | | return outTradeNo; |
| | | } |
| | | |
| | | public void setOutTradeNo(String outTradeNo) { |
| | | this.outTradeNo = outTradeNo; |
| | | } |
| | | |
| | | public Integer getId() { |
| | | return id; |