| | |
| | | package com.sandu.ximon.admin.controller; |
| | | |
| | | import com.sandu.common.domain.ResponseVO; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.util.ResponseUtil; |
| | | import com.sandu.ximon.admin.param.PayParam; |
| | | import com.sandu.ximon.admin.service.C3ChargingService; |
| | | import com.sandu.ximon.admin.service.C3mOrderService; |
| | | import com.sandu.ximon.dao.domain.C3mCharging; |
| | | import com.sandu.ximon.dao.domain.C3mOrder; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @Author liuhaonan |
| | | * @Date 2022/3/22 14:10 |
| | | * @Version 1.0 |
| | | */ |
| | | @RestController |
| | |
| | | public class C3mOrderController { |
| | | |
| | | private final C3mOrderService c3mOrderService; |
| | | private final C3ChargingService c3mService; |
| | | |
| | | |
| | | /** |
| | | * 退款 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @PostMapping("/refond") |
| | |
| | | (Double) params.get("refundAmount"))); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 预付款,生成订单(或直接从redis中获取当前未过期的订单) |
| | | * |
| | | * @return |
| | | */ |
| | | @PostMapping("/advancePay") |
| | | public ResponseVO<Object> advancePayOrder(@RequestBody PayParam param) { |
| | | if (param.getTotalAmount() == 0d) { |
| | | throw new BusinessException("金额不能为0"); |
| | | } |
| | | // C3充电桩实体 |
| | | C3mCharging c3m = c3mService.getC3mByPoleId(param.getPoleId()); |
| | | if (null == c3m) { |
| | | throw new BusinessException("未找到当前充电桩"); |
| | | } |
| | | C3mOrder c3mOrderEntity = c3mOrderService.advancePayOrder(param.getPoleId(), c3m, param.getOrderType() |
| | | , param.getTotalAmount(), param.getSubscribeChargingCapacity()); |
| | | if (null == c3mOrderEntity) { |
| | | throw new BusinessException("该充电桩正被使用!"); |
| | | } |
| | | // return R.ok().put("outTradeNo",c3mOrderEntity.getOutTradeNo()) |
| | | // .put("totalAmount",totalAmount); |
| | | |
| | | Map map=new HashMap(); |
| | | map.put("outTradeNo",c3mOrderEntity.getOutTradeNo()); |
| | | map.put("totalAmount",param.getTotalAmount()); |
| | | return ResponseUtil.success(map); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |