|
@ -7,7 +7,9 @@ import com.yihu.jw.care.service.doorCoach.PatientDoorCoachOrderService;
|
|
|
import com.yihu.jw.care.service.pay.PayService;
|
|
|
import com.yihu.jw.care.util.XMLUtil;
|
|
|
import com.yihu.jw.entity.order.BusinessOrderDO;
|
|
|
import com.yihu.jw.entity.order.BusinessOrderRefundDO;
|
|
|
import com.yihu.jw.order.dao.BusinessOrderDao;
|
|
|
import com.yihu.jw.order.dao.BusinessOrderRefundDao;
|
|
|
import com.yihu.jw.restmodel.ResponseContant;
|
|
|
import com.yihu.jw.restmodel.web.Envelop;
|
|
|
import com.yihu.jw.restmodel.web.ObjEnvelop;
|
|
@ -45,6 +47,8 @@ public class PayEndpoint extends EnvelopRestEndpoint {
|
|
|
private PayService payService;
|
|
|
@Autowired
|
|
|
private BusinessOrderDao businessOrderDao;
|
|
|
@Autowired
|
|
|
private BusinessOrderRefundDao orderRefundDao;
|
|
|
|
|
|
@GetMapping("topStatusBarNum")
|
|
|
@ApiOperation(value = "顶部状态栏订单分类tab")
|
|
@ -89,21 +93,6 @@ public class PayEndpoint extends EnvelopRestEndpoint {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@PostMapping(value = "applyRefund")
|
|
|
@ApiOperation(value = "申请退款")
|
|
|
public Envelop applyRefund(
|
|
|
@ApiParam(name = "id", value = "订单id")
|
|
|
@RequestParam(value = "id", required = true) Integer id) {
|
|
|
try{
|
|
|
String res = payService.cancleOrder(id);
|
|
|
if(StringUtil.isBlank(res)){
|
|
|
return success("取消成功");
|
|
|
}
|
|
|
return Envelop.getError(res,-1);
|
|
|
}catch (Exception e){
|
|
|
return failedException2(e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@PostMapping(value = "cancleOrder")
|
|
|
@ApiOperation(value = "取消订单")
|
|
@ -129,21 +118,23 @@ public class PayEndpoint extends EnvelopRestEndpoint {
|
|
|
@ApiParam(name = "orderId", value = "订单id")
|
|
|
@RequestParam(value = "orderId", required = false) Integer orderId,HttpServletRequest request) {
|
|
|
try{
|
|
|
return payService.wxWapPay(relationId, orderId, request);
|
|
|
return payService.wxWapPay(relationId, orderId, request);
|
|
|
}catch (Exception e){
|
|
|
return failedObjEnvelopException2(e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@PostMapping(value = "wxRefund")
|
|
|
@ApiOperation(value = "微信发起退款")
|
|
|
public Envelop wxRefund(
|
|
|
@ApiParam(name = "desc", value = "退款说明")
|
|
|
@RequestParam(value = "desc", required = true) String desc,
|
|
|
@ApiParam(name = "orderNo", value = "订单id")
|
|
|
@RequestParam(value = "orderNo", required = true) String orderNo) {
|
|
|
@PostMapping(value = "applyRefund")
|
|
|
@ApiOperation(value = "申请退款")
|
|
|
public Envelop applyRefund(
|
|
|
@ApiParam(name = "description", value = "退款说明")
|
|
|
@RequestParam(value = "description", required = true) String description,
|
|
|
@ApiParam(name = "enclosure", value = "退款附件")
|
|
|
@RequestParam(value = "enclosure", required = false) String enclosure,
|
|
|
@ApiParam(name = "id", value = "订单id")
|
|
|
@RequestParam(value = "id", required = true) Integer id) {
|
|
|
try{
|
|
|
payService.orderRefund(orderNo, desc);
|
|
|
payService.applyRefund(id, description, enclosure);
|
|
|
return success("发起退款成功");
|
|
|
}catch (Exception e){
|
|
|
return failedObjEnvelopException2(e);
|
|
@ -249,28 +240,26 @@ public class PayEndpoint extends EnvelopRestEndpoint {
|
|
|
String outTradeNo = params.get("out_trade_no");
|
|
|
String payWaterId = outTradeNo.split("_")[0];
|
|
|
payService.addHttpLog("2",payWaterId,paramsJson,null);
|
|
|
BusinessOrderDO orderDO = businessOrderDao.selectByOrderNo(payWaterId);
|
|
|
BusinessOrderRefundDO orderDO = orderRefundDao.selectByOrderNo(payWaterId);
|
|
|
if (orderDO == null) {
|
|
|
log.error("支付流水不存在");
|
|
|
log.error("退款订单不存在");
|
|
|
return XMLUtil.setXML("SUCCESS", "OK");
|
|
|
}
|
|
|
String wxSeqNo = params.get("transaction_id");
|
|
|
orderDO.setTraceNo(wxSeqNo);
|
|
|
orderDO.setOutRefundNo(params.get("refund_id"));
|
|
|
// orderDO.setResponseParam(paramsJson);
|
|
|
// 判断total_amount是否确实为该订单的实际金额(即商户订单创建时的金额),
|
|
|
String totalFee = params.get("total_fee");
|
|
|
String totalFee = params.get("refund_fee");
|
|
|
BigDecimal payTotalFee = new BigDecimal(totalFee).setScale(2).divide(new BigDecimal(100), BigDecimal.ROUND_HALF_EVEN);
|
|
|
log.info("【微信支付退款】支付金额:{}", payTotalFee);
|
|
|
if (new BigDecimal(orderDO.getPayPrice()).compareTo(payTotalFee) != 0) {
|
|
|
if (new BigDecimal(orderDO.getRefundPrice()).compareTo(payTotalFee) != 0) {
|
|
|
//通知资金与实际资金不对称,可能是攻击行为!
|
|
|
orderDO.setRematk("通知资金与实际资金不对称,可能是攻击行为!");
|
|
|
businessOrderDao.save(orderDO);
|
|
|
log.info("通知资金与实际资金不对称,可能是攻击行为!");
|
|
|
return XMLUtil.setXML("SUCCESS", "OK");
|
|
|
}
|
|
|
|
|
|
// 多线程执行操作
|
|
|
/*********** 业务处理 start ************/
|
|
|
payService.payNotify(orderDO);
|
|
|
payService.refundNotify(orderDO);
|
|
|
/*********** 业务处理 end ************/
|
|
|
return XMLUtil.setXML("SUCCESS", "OK");
|
|
|
} catch (BusinessException e) {
|