mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-22 03:55:17 +08:00
commit
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
package com.jsowell.api.uniapp;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.pile.vo.uniapp.PileConnectorVO;
|
||||
import com.jsowell.service.PileService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@Anonymous
|
||||
@RestController
|
||||
@RequestMapping("/app-xcx-h5")
|
||||
public class JumpController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private PileService pileService;
|
||||
|
||||
/**
|
||||
* 查询充电桩详情
|
||||
* http://localhost:8080/app-xcx-h5/pile/pileDetail/{pileSn}
|
||||
*/
|
||||
@GetMapping("/pile/pileDetail/{pileSn}")
|
||||
public RestApiResponse<?> getPileDetail(HttpServletRequest request, @PathVariable("pileSn") String pileSn) {
|
||||
logger.info("app-xcx-h5查询充电桩详情 param:{}", pileSn);
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
PileConnectorVO vo = pileService.getPileDetailByPileSn(pileSn);
|
||||
response = new RestApiResponse<>(vo);
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("app-xcx-h5查询充电桩详情 warn", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("app-xcx-h5查询充电桩详情 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_PILE_DETAIL_ERROR);
|
||||
}
|
||||
logger.info("app-xcx-h5查询充电桩详情 result:{}", JSONObject.toJSONString(response));
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询充电枪口详情
|
||||
* http://localhost:8080/app-xcx-h5/pile/connectorDetail/{pileConnectorCode}
|
||||
*/
|
||||
@GetMapping("/pile/connectorDetail/{pileConnectorCode}")
|
||||
public RestApiResponse<?> getConnectorDetail(HttpServletRequest request, @PathVariable("pileConnectorCode") String pileConnectorCode) {
|
||||
logger.info("app-xcx-h5查询充电枪口详情 param:{}", pileConnectorCode);
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
PileConnectorVO vo = pileService.getConnectorDetail(pileConnectorCode);
|
||||
response = new RestApiResponse<>(vo);
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("app-xcx-h5查询充电枪口详情 warn", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("app-xcx-h5查询充电枪口详情 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_PILE_DETAIL_ERROR);
|
||||
}
|
||||
logger.info("app-xcx-h5查询充电枪口详情 result:{}", JSONObject.toJSONString(response));
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
package com.jsowell.api.uniapp;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.page.PageResponse;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.exception.ServiceException;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.common.util.SMSUtil;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.dto.MemberRegisterAndLoginDTO;
|
||||
import com.jsowell.pile.dto.MemberRegisterDTO;
|
||||
import com.jsowell.pile.dto.UniAppQueryMemberBalanceDTO;
|
||||
import com.jsowell.pile.dto.WechatLoginDTO;
|
||||
import com.jsowell.pile.dto.WeixinPayDTO;
|
||||
import com.jsowell.pile.vo.uniapp.MemberVO;
|
||||
import com.jsowell.service.MemberService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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 javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 小程序接口
|
||||
*/
|
||||
// 不登录直接访问
|
||||
@Anonymous
|
||||
@RestController
|
||||
@RequestMapping("/uniapp/member")
|
||||
public class MemberController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private MemberService memberService;
|
||||
|
||||
/**
|
||||
* 下发短信接口 business
|
||||
* http://localhost:8080/uniapp/member/sendSMS
|
||||
*/
|
||||
@PostMapping("/sendSMS")
|
||||
public RestApiResponse<?> sendSMS(HttpServletRequest request, @RequestBody MemberRegisterAndLoginDTO dto) {
|
||||
logger.info("下发短信接口 param:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
if (StringUtils.isBlank(dto.getMobileNumber())) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
String sendSMSResult = SMSUtil.sendSMS(request, dto.getMobileNumber());
|
||||
response = new RestApiResponse<>(sendSMSResult);
|
||||
} catch (Exception e) {
|
||||
logger.error("下发短信接口 发生异常 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_SEND_SMS_ERROR);
|
||||
}
|
||||
logger.info("下发短信接口 result:{}", JSONObject.toJSONString(response));
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 会员登录注册
|
||||
* 登录成功,返回memberToken
|
||||
* http://localhost:8080/uniapp/member/memberRegisterAndLogin
|
||||
*/
|
||||
@PostMapping("/memberRegisterAndLogin")
|
||||
public RestApiResponse<?> memberRegisterAndLogin(HttpServletRequest request, @RequestBody MemberRegisterAndLoginDTO dto) {
|
||||
logger.info("会员登录注册接口 param:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
// 执行登录(查这个手机号在后台有没有数据,如果没有就静默注册)
|
||||
String memberToken = memberService.memberRegisterAndLogin(dto);
|
||||
|
||||
// 返回前端成功
|
||||
Map<String, String> map = Maps.newHashMap();
|
||||
map.put("memberToken", memberToken);
|
||||
response = new RestApiResponse<>(map);
|
||||
} catch (ServiceException e) {
|
||||
logger.warn("会员登录注册接口 warn", e);
|
||||
response = new RestApiResponse<>(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("会员登录注册接口 发生异常 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_MEMBER_REGISTER_AND_LOGIN_ERROR);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信一键登录
|
||||
* http://localhost:8080/uniapp/member/wechatLogin
|
||||
*/
|
||||
@PostMapping("/wechatLogin")
|
||||
public RestApiResponse<?> wechatLogin(@RequestBody WechatLoginDTO dto) {
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String memberToken = memberService.wechatLogin(dto);
|
||||
response = new RestApiResponse<>(ImmutableMap.of("memberToken", memberToken));
|
||||
} catch (Exception e) {
|
||||
logger.error("微信登录异常", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_WECHAT_LOGIN_ERROR);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收并处理前端用户信息
|
||||
*
|
||||
* http://localhost:8080/uniapp/member/saveUserInfo
|
||||
*/
|
||||
@PostMapping("/saveUserInfo")
|
||||
public RestApiResponse<?> saveUserInfo(@RequestBody MemberRegisterDTO dto) {
|
||||
logger.info("接受前端用户信息并处理 param:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
memberService.handleUserInfo(dto);
|
||||
response = new RestApiResponse<>();
|
||||
} catch (Exception e) {
|
||||
logger.error("处理用户信息异常", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_HANDLE_USER_INFO_ERROR);
|
||||
}
|
||||
logger.info("接受前端用户信息并处理 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户账户信息
|
||||
*
|
||||
* http://localhost:8080/uniapp/member/getMemberInfo
|
||||
* @return 用户账户信息
|
||||
*/
|
||||
@GetMapping("/getMemberInfo")
|
||||
public RestApiResponse<?> getMemberInfo(HttpServletRequest request) {
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
logger.info("查询账户总余额 param memberId:{}", memberId);
|
||||
MemberVO memberVO = memberService.getMemberInfoByMemberId(memberId);
|
||||
response = new RestApiResponse<>(memberVO);
|
||||
}catch (BusinessException e) {
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
}catch (Exception e) {
|
||||
logger.error("查询用户账户总余额异常", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_MEMBER_ACCOUNT_AMOUNT_ERROR);
|
||||
}
|
||||
logger.info("查询用户账户信息 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取openId
|
||||
* http://localhost:8080/uniapp/member/getOpenId
|
||||
*/
|
||||
@PostMapping("/getOpenId")
|
||||
public RestApiResponse<?> getOpenId(HttpServletRequest request, @RequestBody WeixinPayDTO dto) {
|
||||
logger.info("获取openId param:{}", dto.toString());
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
getMemberIdByAuthorization(request);
|
||||
String openId = memberService.getOpenIdByCode(dto.getCode());
|
||||
response = new RestApiResponse<>(ImmutableMap.of("openId", openId));
|
||||
} catch (Exception e) {
|
||||
logger.error("获取openId error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_OPEN_ID_BY_CODE_ERROR);
|
||||
}
|
||||
logger.info("获取openId result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户账户余额变动信息
|
||||
* http://localhost:8080/uniapp/member/getMemberBalanceChanges
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getMemberBalanceChanges")
|
||||
public RestApiResponse<?> getMemberBalanceChanges(HttpServletRequest request, @RequestBody UniAppQueryMemberBalanceDTO dto) {
|
||||
logger.info("查询用户账户余额变动信息 params:{}", dto.toString() );
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
dto.setMemberId(memberId);
|
||||
PageResponse pageResponse = memberService.getMemberBalanceChanges(dto);
|
||||
response = new RestApiResponse<>(pageResponse);
|
||||
} catch (Exception e) {
|
||||
logger.error("查询用户账户余额变动信息 error:", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_BALANCE_CHANGES_ERROR);
|
||||
}
|
||||
logger.info("查询用户账户余额变动信息 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
package com.jsowell.api.uniapp;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.page.PageResponse;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.dto.GenerateOrderDTO;
|
||||
import com.jsowell.pile.dto.QueryOrderDTO;
|
||||
import com.jsowell.pile.dto.SettleOrderDTO;
|
||||
import com.jsowell.pile.dto.StopChargingDTO;
|
||||
import com.jsowell.pile.dto.UniAppQueryOrderDTO;
|
||||
import com.jsowell.pile.vo.uniapp.UniAppOrderVO;
|
||||
import com.jsowell.service.OrderService;
|
||||
import com.jsowell.service.PileRemoteService;
|
||||
import com.jsowell.wxpay.dto.WechatSendMsgDTO;
|
||||
import com.jsowell.wxpay.service.WxAppletRemoteService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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 javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 订单相关接口
|
||||
* 提供给小程序
|
||||
*/
|
||||
@Anonymous
|
||||
@RestController
|
||||
@RequestMapping("/uniapp/order")
|
||||
public class OrderController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
|
||||
@Autowired
|
||||
private PileRemoteService pileRemoteService;
|
||||
|
||||
@Autowired
|
||||
private WxAppletRemoteService wxAppletRemoteService;
|
||||
|
||||
/**
|
||||
* 生成订单
|
||||
* http://localhost:8080/uniapp/order/generateOrder
|
||||
*/
|
||||
@PostMapping("/generateOrder")
|
||||
public RestApiResponse<?> generateOrder(HttpServletRequest request, @RequestBody GenerateOrderDTO dto) {
|
||||
logger.info("生成订单 param:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
if ((StringUtils.isBlank(dto.getPileSn()) || StringUtils.isBlank(dto.getConnectorCode())) && StringUtils.isBlank(dto.getPileConnectorCode())) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
if (StringUtils.isEmpty(memberId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_TOKEN_ERROR);
|
||||
}
|
||||
dto.setMemberId(memberId);
|
||||
// 生成订单
|
||||
dto.setStartMode(Constants.ONE); // 启动方式 1-app启动
|
||||
String orderCode = orderService.generateOrder(dto);
|
||||
response = new RestApiResponse<>(ImmutableMap.of("orderCode", orderCode));
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("生成订单 warn", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("生成订单 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GENERATE_ORDER_ERROR);
|
||||
}
|
||||
logger.info("生成订单 result:{}", JSONObject.toJSONString(response));
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止充电
|
||||
* http://localhost:8080/uniapp/order/stopCharging
|
||||
*/
|
||||
@PostMapping ("/stopCharging")
|
||||
public RestApiResponse<?> stopCharging(HttpServletRequest request, @RequestBody StopChargingDTO dto) {
|
||||
logger.info("停止充电 param:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
if (StringUtils.isEmpty(memberId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_TOKEN_ERROR);
|
||||
}
|
||||
dto.setMemberId(memberId);
|
||||
orderService.stopCharging(dto);
|
||||
response = new RestApiResponse<>();
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("停止充电 warn", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("停止充电 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_STOP_CHARGING_ERROR);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 结算订单
|
||||
* http://localhost:8080/uniapp/order/settleOrder
|
||||
* @param dto 结算订单DTO
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/settleOrderForWeb")
|
||||
public RestApiResponse<?> settleOrder(HttpServletRequest request, @RequestBody SettleOrderDTO dto) {
|
||||
logger.info("结算订单 param:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
orderService.settleOrderForWeb(dto);
|
||||
response = new RestApiResponse<>();
|
||||
} catch (Exception e) {
|
||||
logger.error("结算订单错误", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_SETTLE_ORDER_ERROR);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单信息
|
||||
* http://localhost:8080/uniapp/order/getOrderList
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getOrderList")
|
||||
public RestApiResponse<?> getOrderInfo(HttpServletRequest request, @RequestBody UniAppQueryOrderDTO dto) {
|
||||
logger.info("查询订单信息 param:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
if (StringUtils.isBlank(memberId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
// 通过memberId查询某状态订单列表
|
||||
PageResponse pageInfoList = orderService.getListByMemberIdAndOrderStatus(memberId, dto);
|
||||
response = new RestApiResponse<>(pageInfoList);
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("查询订单信息 warn", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("查询订单信息 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_ORDER_INFO_BY_MEMBER_ID_ERROR);
|
||||
}
|
||||
logger.info("查询订单信息, result:{}", JSONObject.toJSONString(response));
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序获取订单详情
|
||||
* http://localhost:8080/uniapp/order/getOrderDetail
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getOrderDetail")
|
||||
public RestApiResponse<?> getOrderDetail(HttpServletRequest request, @RequestBody UniAppQueryOrderDTO dto) {
|
||||
logger.info("小程序获取订单详情 param:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
if (StringUtils.isBlank(memberId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
UniAppOrderVO uniAppOrderDetail = orderService.getUniAppOrderDetail(dto.getOrderCode());
|
||||
response = new RestApiResponse<>(uniAppOrderDetail);
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("小程序获取订单详情 warn", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("小程序获取订单详情 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_ORDER_DETAIL_ERROR);
|
||||
}
|
||||
logger.info("小程序获取订单详情, result:{}", JSONObject.toJSONString(response));
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据订单号查询充电桩启动状态
|
||||
* http://localhost:8080/uniapp/order/selectPileStarterStatus
|
||||
*/
|
||||
@PostMapping("/selectPileStarterStatus")
|
||||
public RestApiResponse<?> selectPileStarterStatus(HttpServletRequest request, @RequestBody UniAppQueryOrderDTO dto) {
|
||||
logger.info("根据订单号查询充电桩启动状态 param:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
// String memberId = getMemberIdByAuthorization(request);
|
||||
String status = orderService.selectPileStarterStatus(dto.getOrderCode());
|
||||
response = new RestApiResponse<>(ImmutableMap.of("status", status));
|
||||
} catch (Exception e) {
|
||||
logger.error("根据订单号查询充电桩启动状态 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_ORDER_DETAIL_ERROR);
|
||||
}
|
||||
logger.info("根据订单号查询充电桩启动状态 result:{}", JSONObject.toJSONString(response));
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信小程序发送启动充电推送消息
|
||||
* http://localhost:8080/uniapp/order/uniAppStartChargingSendMsg
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/uniAppStartChargingSendMsg")
|
||||
public RestApiResponse<?> uniAppStartChargingSendMsg(@RequestBody WechatSendMsgDTO dto) {
|
||||
logger.info("微信小程序发送启动充电推送消息 param:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
Map<String, String> resultMap = wxAppletRemoteService.startChargingSendMsg(dto);
|
||||
response = new RestApiResponse<>(resultMap);
|
||||
} catch (Exception e){
|
||||
logger.error("微信小程序发送启动充电推送消息 error", e);
|
||||
response = new RestApiResponse<>("00300001", "微信小程序发送启动充电推送消息异常");
|
||||
}
|
||||
logger.info("微信小程序发送启动充电推送消息 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭支付未启动的订单
|
||||
* http://localhost:8080/uniapp/order/closeStartFailedOrder
|
||||
*/
|
||||
@PostMapping("/closeStartFailedOrder")
|
||||
public RestApiResponse<?> closeStartFailedOrder(@RequestBody QueryOrderDTO dto) {
|
||||
logger.info("关闭支付未启动的订单 param:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
orderService.closeStartFailedOrder(dto);
|
||||
response = new RestApiResponse<>();
|
||||
} catch (Exception e){
|
||||
logger.error("关闭支付未启动的订单 error", e);
|
||||
response = new RestApiResponse<>("00300002", "关闭支付未启动的订单异常");
|
||||
}
|
||||
logger.info("关闭支付未启动的订单 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
package com.jsowell.api.uniapp;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.enums.ykc.ScenarioEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.id.IdUtils;
|
||||
import com.jsowell.pile.dto.PayOrderDTO;
|
||||
import com.jsowell.pile.dto.PaymentScenarioDTO;
|
||||
import com.jsowell.pile.dto.WeixinPayDTO;
|
||||
import com.jsowell.service.MemberService;
|
||||
import com.jsowell.service.OrderService;
|
||||
import com.jsowell.wxpay.dto.WeChatRefundDTO;
|
||||
import com.jsowell.wxpay.response.WechatPayNotifyParameter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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 javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 支付相关controller
|
||||
*/
|
||||
@Anonymous
|
||||
@RestController
|
||||
@RequestMapping("/uniapp/pay")
|
||||
public class PayController extends BaseController {
|
||||
@Autowired
|
||||
private MemberService memberService;
|
||||
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
/**
|
||||
* 充值余额支付
|
||||
* 提供给小程序使用
|
||||
* http://localhost:8080/uniapp/pay/weixinPay
|
||||
*/
|
||||
@PostMapping("/weixinPay")
|
||||
public RestApiResponse<?> weixinPay(HttpServletRequest request, @RequestBody WeixinPayDTO dto) {
|
||||
logger.info("微信支付 param:{}", dto.toString());
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
if (StringUtils.isBlank(dto.getCode()) || StringUtils.isBlank(dto.getAmount())) {
|
||||
return new RestApiResponse<>(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
// 鉴权
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
if (StringUtils.isBlank(memberId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_TOKEN_ERROR);
|
||||
}
|
||||
dto.setMemberId(memberId);
|
||||
String openId = memberService.getOpenIdByCode(dto.getCode());
|
||||
if (StringUtils.isBlank(openId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_GET_OPEN_ID_BY_CODE_ERROR);
|
||||
}
|
||||
dto.setOpenId(openId);
|
||||
// 充值余额 附加参数
|
||||
PaymentScenarioDTO paymentScenarioDTO = new PaymentScenarioDTO();
|
||||
paymentScenarioDTO.setType(ScenarioEnum.BALANCE.getValue());
|
||||
paymentScenarioDTO.setMemberId(memberId);
|
||||
dto.setAttach(JSONObject.toJSONString(paymentScenarioDTO));
|
||||
dto.setDescription("会员充值余额");
|
||||
Map<String, Object> weixinMap = orderService.weixinPayV3(dto);
|
||||
response = new RestApiResponse<>(ImmutableMap.of("weixinMap", weixinMap));
|
||||
} catch (Exception e) {
|
||||
response = new RestApiResponse<>();
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付订单
|
||||
* http://localhost:8080/uniapp/pay/payOrder
|
||||
*
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/payOrder")
|
||||
public RestApiResponse<?> payOrder(HttpServletRequest request, @RequestBody PayOrderDTO dto) {
|
||||
logger.info("支付订单 param:{}", dto.toString());
|
||||
RestApiResponse<?> response;
|
||||
|
||||
// 支付订单加锁
|
||||
String lockKey = "pay_order_" + dto.getOrderCode();
|
||||
String lockValue = IdUtils.fastUUID();
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
if (StringUtils.isBlank(memberId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_TOKEN_ERROR);
|
||||
}
|
||||
dto.setMemberId(memberId);
|
||||
dto.setLockValue(lockValue);
|
||||
// redis锁
|
||||
Boolean isLock = redisCache.lock(lockKey, lockValue, 60);
|
||||
Map<String, Object> map = null;
|
||||
if (isLock) {
|
||||
map = orderService.payOrder(dto);
|
||||
}
|
||||
// Map<String, Object> map = orderService.payOrder(dto);
|
||||
response = new RestApiResponse<>(map);
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("支付订单 warn", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("支付订单 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_ORDER_PAY_ERROR);
|
||||
} finally {
|
||||
// 支付订单解锁
|
||||
if (lockValue.equals(redisCache.getCacheObject(lockKey).toString())) {
|
||||
redisCache.unLock(lockKey);
|
||||
}
|
||||
}
|
||||
logger.info("支付订单 result:{}", JSONObject.toJSONString(response));
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信支付回调接口
|
||||
* http://localhost:8080/uniapp/pay/callback
|
||||
* https://api.jsowellcloud.com/uniapp/pay/wechatPayCallback
|
||||
*/
|
||||
@PostMapping("/wechatPayCallback")
|
||||
public RestApiResponse<?> wechatPayCallback(HttpServletRequest request, @RequestBody WechatPayNotifyParameter body) {
|
||||
logger.info("1----------->微信支付回调开始 body:{}", JSONObject.toJSONString(body));
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
orderService.wechatPayCallback(request, body);
|
||||
response = new RestApiResponse<>();
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("微信支付回调接口warn", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("微信支付回调接口error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_ORDER_PAY_CALLBACK_ERROR);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信退款回调接口
|
||||
* @param request
|
||||
* @param body
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/wechatPayRefundCallback")
|
||||
public RestApiResponse<?> wechatPayRefundCallback(HttpServletRequest request, @RequestBody WechatPayNotifyParameter body) {
|
||||
logger.info("微信退款回调接口 body:{}", JSONObject.toJSONString(body));
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
orderService.wechatPayRefundCallback(request, body);
|
||||
response = new RestApiResponse<>();
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("微信退款回调接口warn", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("微信退款回调接口error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_ORDER_PAY_CALLBACK_ERROR);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信退款接口
|
||||
* https://api.jsowellcloud.com/uniapp/pay/refund
|
||||
*/
|
||||
@PostMapping("/refund")
|
||||
public RestApiResponse<?> weChatRefund(HttpServletRequest request, @RequestBody WeChatRefundDTO dto) {
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
if (dto.getRefundAmount() == null) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
if (StringUtils.isBlank(memberId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_TOKEN_ERROR);
|
||||
}
|
||||
dto.setMemberId(memberId);
|
||||
dto.setRefundType("2");
|
||||
orderService.weChatRefund(dto);
|
||||
response = new RestApiResponse<>();
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("微信退款接口 warn", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("微信退款接口 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_WEIXIN_REFUND_ERROR);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
package com.jsowell.api.uniapp;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.page.PageResponse;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.pile.dto.PileMemberBindingDTO;
|
||||
import com.jsowell.pile.dto.QueryPersonPileDTO;
|
||||
import com.jsowell.pile.service.IPileBasicInfoService;
|
||||
import com.jsowell.pile.service.IPileMemberRelationService;
|
||||
import com.jsowell.pile.vo.uniapp.OrderVO;
|
||||
import com.jsowell.pile.vo.uniapp.PersonPileConnectorSumInfoVO;
|
||||
import com.jsowell.pile.vo.uniapp.PersonPileRealTimeVO;
|
||||
import com.jsowell.pile.vo.uniapp.PersonalPileInfoVO;
|
||||
import com.jsowell.service.PileService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 个人桩controller
|
||||
*
|
||||
* @author JS-ZZA
|
||||
* @date 2023/2/23 15:36
|
||||
*/
|
||||
@Anonymous
|
||||
@RestController
|
||||
@RequestMapping("/uniapp/personalPile")
|
||||
public class PersonPileController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IPileMemberRelationService pileMemberRelationService;
|
||||
|
||||
@Autowired
|
||||
private PileService pileService;
|
||||
|
||||
@Autowired
|
||||
private IPileBasicInfoService pileBasicInfoService;
|
||||
|
||||
/**
|
||||
* 用户绑定个人桩
|
||||
*
|
||||
* http://localhost:8080/uniapp/personalPile/pileMemberBinding
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/pileMemberBinding")
|
||||
public RestApiResponse<?> pileMemberBinding(HttpServletRequest request, @RequestBody PileMemberBindingDTO dto){
|
||||
logger.info("绑定个人桩信息 params:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
dto.setMemberId(memberId);
|
||||
int i = pileService.pileMemberBinding(dto);
|
||||
response = new RestApiResponse<>(i);
|
||||
}catch (BusinessException e){
|
||||
logger.error("绑定个人桩信息 error,", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
}catch (Exception exception){
|
||||
logger.error("绑定个人桩信息 error,", exception);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_BINDING_PERSONAL_PILE_ERROR);
|
||||
}
|
||||
logger.info("绑定个人桩信息 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 个人桩管理员下发给其他用户
|
||||
*
|
||||
* http://localhost:8080/uniapp/personalPile/adminIssuePile
|
||||
*
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/adminIssuePile")
|
||||
public RestApiResponse<?> adminIssuePile(HttpServletRequest request, @RequestBody PileMemberBindingDTO dto){
|
||||
logger.info("桩管理员下发个人桩 params: {}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
dto.setMemberId(memberId);
|
||||
pileService.adminIssuePile(dto);
|
||||
response = new RestApiResponse<>();
|
||||
}catch (BusinessException e) {
|
||||
logger.error("桩管理员下发个人桩 error", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
}catch (Exception e){
|
||||
logger.error("桩管理员下发个人桩 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_ADMIN_ISSUE_ERROR);
|
||||
}
|
||||
logger.info("桩管理员下发个人桩 result: {}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过memberId查个人桩列表
|
||||
*
|
||||
* http://localhost:8080/uniapp/personalPile/getPersonalPileList
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getPersonalPileList")
|
||||
public RestApiResponse<?> getPersonalPileList(HttpServletRequest request){
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
logger.info("通过memberId查个人桩列表 params: {}", memberId);
|
||||
List<PersonalPileInfoVO> list = pileBasicInfoService.getPileInfoByMemberId(memberId);
|
||||
response = new RestApiResponse<>(list);
|
||||
}catch (Exception e){
|
||||
logger.error("通过memberId查个人桩列表异常", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_PERSONAL_PILE_BY_MEMBER_ID_ERROR);
|
||||
}
|
||||
logger.info("通过memberId查个人桩列表 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取枪口实时数据
|
||||
*
|
||||
* http://localhost:8080/uniapp/personalPile/getConnectorRealTimeInfo
|
||||
*
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getConnectorRealTimeInfo")
|
||||
public RestApiResponse<?> getConnectorRealTimeInfo(HttpServletRequest request, @RequestBody QueryPersonPileDTO dto){
|
||||
logger.info("获取个人桩枪口实时数据 params:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
dto.setMemberId(memberId);
|
||||
PersonPileRealTimeVO connectorRealTimeInfo = pileService.getConnectorRealTimeInfo(dto);
|
||||
response = new RestApiResponse<>(connectorRealTimeInfo);
|
||||
}catch (BusinessException e){
|
||||
logger.error("获取个人桩枪口实时数据 error", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
}catch (Exception e){
|
||||
logger.error("获取个人桩枪口实时数据 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_PERSONAL_PILE_CONNECTOR_INFO_ERROR);
|
||||
}
|
||||
logger.info("获取个人桩枪口实时数据 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取某枪口某段时间内累计信息
|
||||
*
|
||||
* http://localhost:8080/uniapp/personalPile/getAccumulativeInfo
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getAccumulativeInfo")
|
||||
public RestApiResponse<?> getAccumulativeInfo(HttpServletRequest request, @RequestBody QueryPersonPileDTO dto) {
|
||||
logger.info("获取某枪口某段时间内累计信息 params:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
dto.setMemberId(memberId);
|
||||
PersonPileConnectorSumInfoVO accumulativeInfo = pileService.getAccumulativeInfo(dto);
|
||||
response = new RestApiResponse<>(accumulativeInfo);
|
||||
} catch (BusinessException e){
|
||||
logger.error("获取某枪口某段时间内累计信息 error", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
}catch (Exception e){
|
||||
logger.error("获取某枪口某段时间内累计信息 error", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("获取某枪口某段时间内累计信息 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取充电记录
|
||||
*
|
||||
* http://localhost:8080/uniapp/personalPile/getChargingRecord
|
||||
*
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getChargingRecord")
|
||||
public RestApiResponse<?> getChargingRecord(HttpServletRequest request, @RequestBody QueryPersonPileDTO dto){
|
||||
logger.info("获取个人桩充电记录 params:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
dto.setMemberId(memberId);
|
||||
PageResponse chargingRecord = pileService.getChargingRecord(dto);
|
||||
response = new RestApiResponse<>(chargingRecord);
|
||||
}catch (BusinessException e){
|
||||
logger.error("获取个人桩充电记录 error", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
}catch (Exception e){
|
||||
logger.error("获取个人桩充电记录 error", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("获取个人桩充电记录 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.jsowell.api.uniapp;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.page.PageResponse;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.pile.dto.QueryConnectorListDTO;
|
||||
import com.jsowell.pile.dto.QueryStationDTO;
|
||||
import com.jsowell.pile.service.IPileConnectorInfoService;
|
||||
import com.jsowell.pile.service.IPileStationInfoService;
|
||||
import com.jsowell.pile.vo.uniapp.PersonalPileInfoVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 充电桩相关接口
|
||||
* 提供给小程序调用
|
||||
*/
|
||||
// 不登录直接访问
|
||||
@Anonymous
|
||||
@RestController
|
||||
@RequestMapping("/uniapp/pile")
|
||||
public class PileController extends BaseController {
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private IPileStationInfoService pileStationInfoService;
|
||||
|
||||
@Autowired
|
||||
private IPileConnectorInfoService pileConnectorInfoService;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询充电站信息列表(主页)
|
||||
*
|
||||
* http://localhost:8080/uniapp/pile/queryStationInfos
|
||||
*/
|
||||
@PostMapping("/queryStationInfos")
|
||||
public RestApiResponse<?> queryStationInfos(HttpServletRequest request, @RequestBody QueryStationDTO queryStationDTO) {
|
||||
logger.info("查询充电站信息列表 param:{}", JSONObject.toJSONString(queryStationDTO));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
getMemberIdByAuthorization(request);
|
||||
// startPage();
|
||||
// List<PileStationVO> list = pileStationInfoService.uniAppQueryStationInfos(queryStationDTO);
|
||||
PageResponse pageResponse = pileStationInfoService.uniAppQueryStationInfoList(queryStationDTO);
|
||||
response = new RestApiResponse<>(pageResponse);
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("查询充电站信息列表warn", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("查询充电站信息列表异常 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_PILE_STATION_INFO_ERROR);
|
||||
}
|
||||
logger.info("查询充电站信息列表 result:{}", JSONObject.toJSONString(response));
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过前端参数查询充电枪口列表
|
||||
*
|
||||
* http://localhost:8080/uniapp/pile/selectConnectorListByParams
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/selectConnectorListByParams")
|
||||
public RestApiResponse<?> selectConnectorListByParams(HttpServletRequest request, @RequestBody QueryConnectorListDTO dto) {
|
||||
logger.info("查询充电枪口列表 params:{}", JSONObject.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
PageResponse pageResponse = pileConnectorInfoService.getUniAppConnectorInfoListByParams(dto);
|
||||
response = new RestApiResponse<>(pageResponse);
|
||||
} catch (Exception e) {
|
||||
logger.error("查询充电枪口列表异常", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_CONNECTOR_INFO_BY_STATION_ID_ERROR);
|
||||
}
|
||||
logger.info("查询充电枪口列表 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user