| | |
| | | import com.sandu.ximon.admin.pay.wx.WxFastPayService; |
| | | import com.sandu.ximon.admin.service.C3ChargingService; |
| | | import com.sandu.ximon.admin.service.C3mOrderService; |
| | | import com.sandu.ximon.admin.utils.AliPayUtils; |
| | | import com.sandu.ximon.admin.utils.ConfigCheckUtils; |
| | | import com.sandu.ximon.dao.domain.AliConfigEntity; |
| | | import com.sandu.ximon.dao.domain.C3mCharging; |
| | | import com.sandu.ximon.dao.domain.C3mOrder; |
| | | import com.sandu.ximon.dao.enums.OrderType; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.SortedMap; |
| | | |
| | |
| | | */ |
| | | @PostMapping("/advancePay") |
| | | public ResponseVO<Object> advancePayOrder(@RequestBody PayParam param) { |
| | | if (param.getTotalAmount() == 0d) { |
| | | throw new BusinessException("金额不能为0"); |
| | | if (param.getTotalAmount() < 0) { |
| | | 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() |
| | | C3mOrder c3mOrderEntity = c3mOrderService.advancePayOrder(param.getPoleId(), c3m, "wxpay" |
| | | , 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); |
| | | param.setOutTradeNo(c3mOrderEntity.getOutTradeNo()); |
| | | param.setTotalAmount(c3mOrderEntity.getTotalAmount()); |
| | | String s = WxFastPayService.parseWxAmount(param.getTotalAmount().toString()); |
| | | SortedMap<Object, Object> result = wxPayService.miniAppPay("扫码充电支付(C3充电桩)", param.getOutTradeNo(), Integer.valueOf(s), param.getPoleId()); |
| | | return ResponseUtil.success(result); |
| | | } |
| | | |
| | | |
| | |
| | | return ResponseUtil.success("支付完成"); |
| | | } |
| | | |
| | | @RequestMapping("/wxpay") |
| | | public ResponseVO<Object> c3Wxpay(@RequestBody PayParam param) { |
| | | // @RequestMapping("/wxpay") |
| | | // public ResponseVO<Object> c3Wxpay(@RequestBody PayParam param) { |
| | | // |
| | | // //String result = wxPayService.miniAppPay(outTradeNo, totalAmount, streetlightId); |
| | | // SortedMap<Object, Object> result = wxPayService.appPay("扫码充电支付(C3充电桩)", param.getOutTradeNo(), param.getWxPayTotalAmount(), param.getPoleId(),c3mOrderEntity); |
| | | // |
| | | // return ResponseUtil.success(result); |
| | | // } |
| | | |
| | | //String result = wxPayService.miniAppPay(outTradeNo, totalAmount, streetlightId); |
| | | SortedMap<Object, Object> result = wxPayService.appPay("扫码充电支付(C3充电桩)", param.getOutTradeNo(), param.getWxPayTotalAmount(), param.getPoleId()); |
| | | |
| | | return ResponseUtil.success(result); |
| | | @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("支付方式异常"); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |