| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse; |
| | | import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.admin.config.C3mRedisConfig; |
| | | import com.sandu.ximon.admin.pay.OrderStatusEnums; |
| | | import com.sandu.ximon.admin.pay.wx.WxFastPayService; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.admin.security.order.OrderQueryListener; |
| | |
| | | import com.sandu.ximon.dao.domain.C3mCharging; |
| | | import com.sandu.ximon.dao.domain.C3mOrder; |
| | | import com.sandu.ximon.dao.domain.Pole; |
| | | import com.sandu.ximon.dao.enums.C3mRedisConstant; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.C3mRedisConstant; |
| | | import com.sandu.ximon.dao.enums.OrderStatus; |
| | | import com.sandu.ximon.dao.enums.OrderType; |
| | | import com.sandu.ximon.dao.mapper.C3mOrderMapper; |
| | |
| | | return false; |
| | | } else { |
| | | orderByOutTradeNo.setRefundAmount(refundAmount); |
| | | return c3mOrderRefund(orderByOutTradeNo, "页面API退款", userId, username); |
| | | return c3mOrderRefund(orderByOutTradeNo, "充电桩退款", userId, username); |
| | | } |
| | | |
| | | |
| | |
| | | ); |
| | | // 推送到自动查询模块,进行扫描启动 |
| | | orderQueryListener.startScan(OrderScanType.C3M.getType()); |
| | | // if(b){ |
| | | // save(c3mOrderEntity); |
| | | // } |
| | | return b ? c3mOrderEntity : null; |
| | | } |
| | | |
| | | /** |
| | | * 微信支付回调 |
| | | */ |
| | | public Object payWechatNotify(String xmlData) { |
| | | WxPayOrderNotifyResult wxPayOrderNotifyResult = fastPayService.parseOrderNotifyResult(xmlData); |
| | | String orderSn = wxPayOrderNotifyResult.getOutTradeNo(); |
| | | String transactionId = wxPayOrderNotifyResult.getOutTradeNo(); |
| | | Integer totalFee = wxPayOrderNotifyResult.getTotalFee(); |
| | | C3mOrder userOrder = getByOrderSn(orderSn); |
| | | if (userOrder == null) { |
| | | return WxPayNotifyResponse.fail("订单不存在 sn=" + orderSn); |
| | | } |
| | | |
| | | // 检查这个订单是否已经处理过 |
| | | if (!OrderStatusEnums.UNPAID.getCode().equals(userOrder.getOrderStatus())) { |
| | | return WxPayNotifyResponse.success("订单已经处理成功!"); |
| | | } |
| | | userOrder.setOutTradeNo(transactionId); |
| | | userOrder.setPayTimestamp(new Date().getTime()); |
| | | userOrder.setOrderStatus(OrderStatusEnums.PAID.getCode()); |
| | | if (!updateById(userOrder)) { |
| | | return WxPayNotifyResponse.fail("更新数据已失效"); |
| | | } |
| | | |
| | | return WxPayNotifyResponse.success("更新数据成功"); |
| | | } |
| | | |
| | | |
| | | public C3mOrder getByOrderSn(String orderSn) { |
| | | LambdaQueryWrapper<C3mOrder> wrapper = Wrappers.lambdaQuery(C3mOrder.class).eq(C3mOrder::getOutTradeNo, orderSn).last("limit 1"); |
| | | return getOne(wrapper); |
| | | } |
| | | |
| | | } |