| | |
| | | @Resource |
| | | private UserCouponClient userCouponClient; |
| | | |
| | | |
| | | @Resource |
| | | private CouponClient couponClient; |
| | | |
| | |
| | | if (siteBooking.getStatus() != 1 && siteBooking.getStatus() != 2) { |
| | | return ResultUtil.error("不能进行取消操作"); |
| | | } |
| | | Integer storeId = siteBooking.getStoreId(); |
| | | Store store = storeService.getById(storeId); |
| | | |
| | | if (siteBooking.getPayType() == 1) {//微信支付 |
| | | if (StringUtils.hasLength(siteBooking.getFenzhangNo())){ |
| | | // 是分账订单 如果分账金额不为0 那么回退分账金额 |
| | | if (siteBooking.getFenzhangAmount()!=null && siteBooking.getFenzhangAmount().compareTo(BigDecimal.ZERO)>0){ |
| | | String randomCode = UUIDUtil.getRandomCode(16); |
| | | String randomCode1 = UUIDUtil.getRandomCode(16); |
| | | if (byId.getOperatorId()!=null && byId.getOperatorId()!=0){ |
| | | // 微信商户号 |
| | | String s2 =siteService.getmerchantNumberByOperatorId(byId.getOperatorId()); |
| | | ResultUtil resultUtil = payMoneyUtil.fenzhangRefund(siteBooking.getFenzhangNo(), siteBooking.getFenzhangAmount().multiply(new BigDecimal("100")), s2, randomCode, randomCode1); |
| | | if (!resultUtil.getCode().equals(200)){ |
| | | System.err.println("分账回退失败 原因是:"+resultUtil.getMsg()+resultUtil.getData()); |
| | | }else{ |
| | | siteBooking.setFenzhangRefundNo(resultUtil.getMsg()); |
| | | siteBookingService.updateById(siteBooking); |
| | | } |
| | | |
| | | } |
| | | if (store.getOperatorId()!=null && store.getOperatorId()!=0){ |
| | | String smidVx= operatorUserService.getmerchantNumberByOperatorId(store.getOperatorId()); |
| | | if (!StringUtils.hasLength(smidVx)){ |
| | | return ResultUtil.error("运营商未配置微信商户号,获取支付失败!"); |
| | | } |
| | | } |
| | | Map<String, String> map = payMoneyUtil.wxRefund(siteBooking.getPayOrderNo(), siteBooking.getOrderNo(), siteBooking.getPayMoney().toString(), |
| | | siteBooking.getPayMoney().toString(), "/base/site/cancelMySiteCallback"); |
| | | if (null == map) { |
| | | return ResultUtil.error("取消退款异常"); |
| | | } |
| | | String return_code = map.get("return_code"); |
| | | if (!"SUCCESS".equals(return_code)) { |
| | | return ResultUtil.error(map.get("return_msg")); |
| | | } |
| | | siteBooking.setCancelUserId(uid); |
| | | siteBookingService.updateById(siteBooking); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5);// 退款单号 |
| | | // 运营商退款 |
| | | payMoneyUtil.weixinRefundV3(smidVx, code, siteBooking.getPayOrderNo(), siteBooking.getPayMoney().toString(), "/base/site/cancelMySiteCallback1"); |
| | | }else{ |
| | | Map<String, String> map = payMoneyUtil.wxRefund(siteBooking.getPayOrderNo(), siteBooking.getOrderNo(), siteBooking.getPayMoney().toString(), |
| | | siteBooking.getPayMoney().toString(), "/base/site/cancelMySiteCallback"); |
| | | if (null == map) { |
| | | return ResultUtil.error("取消退款异常"); |
| | | } |
| | | String return_code = map.get("return_code"); |
| | | if (!"SUCCESS".equals(return_code)) { |
| | | return ResultUtil.error(map.get("return_msg")); |
| | | } |
| | | siteBooking.setCancelUserId(uid); |
| | | siteBookingService.updateById(siteBooking); |
| | | |
| | | TBackRecord tBackRecord = new TBackRecord(); |
| | | tBackRecord.setMoney(siteBooking.getPayMoney()); |
| | | tBackRecord.setUserId(siteBooking.getAppUserId()); |
| | | tBackRecord.setTime(new Date()); |
| | | backRecordService.save(tBackRecord); |
| | | TBackRecord tBackRecord = new TBackRecord(); |
| | | tBackRecord.setMoney(siteBooking.getPayMoney()); |
| | | tBackRecord.setUserId(siteBooking.getAppUserId()); |
| | | tBackRecord.setTime(new Date()); |
| | | backRecordService.save(tBackRecord); |
| | | } |
| | | |
| | | |
| | | } |
| | | if (siteBooking.getPayType() == 2) {//支付宝 |