| | |
| | | import com.sandu.ximon.admin.param.PayParam; |
| | | import com.sandu.ximon.admin.pay.alipay.UsrAlipayConfigService; |
| | | import com.sandu.ximon.admin.pay.wx.WxFastPayService; |
| | | import com.sandu.ximon.admin.security.wxOpenId.OpenId; |
| | | import com.sandu.ximon.admin.security.PermissionConfig; |
| | | import com.sandu.ximon.admin.service.C3ChargingService; |
| | | import com.sandu.ximon.admin.service.C3mChargingChargeService; |
| | | import com.sandu.ximon.admin.service.C3mOrderService; |
| | | import com.sandu.ximon.admin.utils.AliPayUtils; |
| | | import com.sandu.ximon.dao.domain.C3mCharging; |
| | | import com.sandu.ximon.dao.domain.C3mOrder; |
| | | import com.sandu.ximon.dao.enums.OrderType; |
| | | import com.sandu.ximon.dao.enums.MenuEnum; |
| | | import lombok.AllArgsConstructor; |
| | | import me.chanjar.weixin.common.error.WxErrorException; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.math.BigDecimal; |
| | | import java.util.SortedMap; |
| | | |
| | |
| | | private final UsrAlipayConfigService alipayConfigService; |
| | | private final WxFastPayService wxPayService; |
| | | private final C3mChargingChargeService c3mChargingChargeService; |
| | | private final PermissionConfig permissionConfig; |
| | | |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return |
| | | */ |
| | | @PostMapping("/refond") |
| | | public ResponseVO<Object> refond(@RequestBody PayParam params) { |
| | | @PostMapping("/refund") |
| | | public ResponseVO<Object> refund(@RequestBody PayParam params) { |
| | | if (!permissionConfig.check(MenuEnum.C3_REFUND.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | if (params.getOutTradeNo().isEmpty() || params.getOutTradeNo() == null) { |
| | | throw new BusinessException("退款参数不能为空"); |
| | | } |
| | | // 0.00 用于占位 没有实际用处 退款接口好几个地方调用 不太好改 |
| | | return ResponseUtil.success(c3mOrderService.orderRefund(params.getOutTradeNo(), |
| | | 0.00)); |
| | | return ResponseUtil.success(c3mOrderService.orderRefund(params.getOutTradeNo())); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @AnonymousAccess |
| | | @PostMapping("/advancePay") |
| | | public ResponseVO<Object> advancePayOrder(@RequestBody PayParam param) throws WxErrorException { |
| | | public ResponseVO<Object> advancePayOrder(HttpServletRequest request, @RequestBody PayParam param) throws WxErrorException, InterruptedException { |
| | | if (param.getOpenId().isEmpty()) { |
| | | throw new BusinessException("微信code不能为空"); |
| | | } |
| | |
| | | //生成订单 |
| | | C3mOrder c3mOrderEntity = c3mOrderService.advancePayOrder(param.getPoleId(), c3m, "wxpay" |
| | | , totalAmount, param.getSubscribeChargingCapacity(), param.getOpenId()); |
| | | if (null == c3mOrderEntity) { |
| | | throw new BusinessException("该充电桩正被使用!"); |
| | | } |
| | | |
| | | param.setOutTradeNo(c3mOrderEntity.getOutTradeNo()); |
| | | param.setTotalAmount(c3mOrderEntity.getTotalAmount()); |
| | | String s = WxFastPayService.parseWxAmount(param.getTotalAmount().toString()); |
| | | String s = WxFastPayService.parseWxAmount(c3mOrderEntity.getTotalAmount().toString()); |
| | | //生成微信预付订单 |
| | | SortedMap<Object, Object> result = wxPayService.miniAppPay("扫码充电支付(C3充电桩)", param.getOutTradeNo(), Integer.valueOf(s), param.getPoleId(), param.getOpenId()); |
| | | SortedMap<Object, Object> result = wxPayService.miniAppPay(request, "扫码充电支付(C3充电桩)", c3mOrderEntity.getOutTradeNo(), Integer.valueOf(s), param.getPoleId(), param.getOpenId()); |
| | | return ResponseUtil.success(result); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 订单状态查询 微信支付 |
| | | * |
| | | * @param param |
| | | * @return |
| | | */ |
| | | @RequestMapping("/queryOrder") |
| | | public ResponseVO<Object> queryOrder(@RequestBody PayParam param) { |
| | | if (param.getOrderId() == null) { |
| | | throw new BusinessException("请输入正确的订单id"); |
| | | } |
| | | C3mOrder order = c3mOrderService.getById(param.getOrderId()); |
| | | if (order == null) { |
| | | throw new BusinessException("订单不存在"); |
| | | } |
| | | if ((OrderType.ALIPAY.getCode()).equals(order.getOrderType())) { |
| | | return ResponseUtil.success(AliPayUtils.alipayQuery(order.getOutTradeNo(), param.getPoleId())); |
| | | } else if ((OrderType.WXPAY.getCode()).equals(order.getOrderType())) { |
| | | return ResponseUtil.success(wxPayService.WxOrderQuery(param.getPoleId(), order.getOutTradeNo())); |
| | | } else { |
| | | return ResponseUtil.success("支付方式异常"); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 订单列表 |
| | |
| | | @RequestParam(value = "keyword", required = false) String keyword, |
| | | @RequestParam(value = "orderStatus", required = false) Integer orderStatus, |
| | | @RequestParam(value = "timeType", required = false) Integer timeType) { |
| | | if (!permissionConfig.check(MenuEnum.ORDER_LIST.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.successPage(c3mOrderService.orderList(baseConditionVO, keyword, orderStatus, timeType)); |
| | | } |
| | | |