mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-15 07:18:31 +08:00
Merge branch 'dev' of http://192.168.2.2:8099/jsowell/jsowell-charger-web into dev
# Conflicts: # jsowell-pile/src/main/java/com/jsowell/pile/service/OrderPileOccupyService.java # jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderPileOccupyServiceImpl.java
This commit is contained in:
@@ -1,7 +1,108 @@
|
||||
package com.jsowell.api.uniapp;/**
|
||||
* TODO
|
||||
package com.jsowell.api.uniapp;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
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.common.util.StringUtils;
|
||||
import com.jsowell.pile.domain.OrderPileOccupy;
|
||||
import com.jsowell.pile.dto.GenerateOccupyOrderDTO;
|
||||
import com.jsowell.pile.service.OrderPileOccupyService;
|
||||
import com.jsowell.pile.vo.uniapp.OrderPileOccupyVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 占桩订单controller
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2023/8/18 8:55
|
||||
* @author Lemon
|
||||
*/public class OccupyOrderController {
|
||||
*/
|
||||
@Anonymous
|
||||
@RestController
|
||||
@RequestMapping("/uniapp/occupyOrder")
|
||||
public class OccupyOrderController extends BaseController {
|
||||
@Autowired
|
||||
private OrderPileOccupyService orderPileOccupyService;
|
||||
|
||||
/**
|
||||
* 查询站点占桩费率
|
||||
* @param stationId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getStationOccupyFee/{stationId}")
|
||||
public RestApiResponse<?> getStationOccupyFee(@PathVariable("stationId") String stationId) {
|
||||
logger.info("查询站点占桩费率 params:{}", stationId);
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("查询站点占桩费率 error,", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("查询站点占桩费率 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成占桩订单
|
||||
* https://api.jsowellcloud.com/uniapp/occupyOrder/generateOccupyOrder
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/generateOccupyOrder")
|
||||
public RestApiResponse<?> generateOccupyOrder(HttpServletRequest request, @RequestBody GenerateOccupyOrderDTO dto) {
|
||||
logger.info("生成占桩订单 params:{}", JSON.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
// 获取memberId
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
if (StringUtils.isEmpty(memberId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_TOKEN_ERROR);
|
||||
}
|
||||
dto.setMemberId(memberId);
|
||||
String occupyOrderCode = orderPileOccupyService.generateOccupyPileOrder(dto);
|
||||
if (StringUtils.isNotBlank(occupyOrderCode)) {
|
||||
response = new RestApiResponse<>(ImmutableMap.of("occupyOrderCode", occupyOrderCode));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("生成占桩订单 error,", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("生成占桩订单 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
// 查询占桩订单列表页
|
||||
@GetMapping("/getOccupyOrderInfo")
|
||||
public RestApiResponse<?> getOccupyOrderInfo(HttpServletRequest request) {
|
||||
// 获取memberId
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
if (StringUtils.isEmpty(memberId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_TOKEN_ERROR);
|
||||
}
|
||||
logger.info("查询占桩订单列表页 memberId:{}", memberId);
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
List<OrderPileOccupyVO> orderInfoList = orderPileOccupyService.getOccupyOrderInfo(memberId);
|
||||
response = new RestApiResponse<>(orderInfoList);
|
||||
} catch (Exception e) {
|
||||
logger.error("查询占桩订单列表页 error, ", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
logger.info("查询占桩订单列表页 result:{}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 查询占桩订单详情页
|
||||
}
|
||||
|
||||
@@ -208,7 +208,12 @@ public class SpringBootTestController {
|
||||
String memberId = "67569684";
|
||||
String pileSn = "88230000000135";
|
||||
String connectorCode = "01";
|
||||
orderPileOccupyService.generateOccupyPileOrder(memberId, pileSn, connectorCode);
|
||||
GenerateOccupyOrderDTO dto = new GenerateOccupyOrderDTO();
|
||||
dto.setMemberId(memberId);
|
||||
dto.setPileSn(pileSn);
|
||||
dto.setConnectorCode(connectorCode);
|
||||
|
||||
orderPileOccupyService.generateOccupyPileOrder(dto);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.jsowell.common.enums.uniapp;
|
||||
|
||||
/**
|
||||
* 占桩订单支付状态enum
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2023/8/18 9:49
|
||||
*/
|
||||
public enum OrderPileOccupyPayStatusEnum {
|
||||
UN_PAY("0", "未支付"),
|
||||
PAYMENT_COMPLETION("1", "未支付"),
|
||||
NO_PAYMENT_REQUIRED("2", "无需支付"),
|
||||
;
|
||||
|
||||
private String code;
|
||||
private String value;
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
OrderPileOccupyPayStatusEnum(String code, String value) {
|
||||
this.code = code;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code获取value
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public static String getValueByCode(String code) {
|
||||
for (OrderPileOccupyPayStatusEnum item : OrderPileOccupyPayStatusEnum.values()) {
|
||||
if (item.getCode().equals(code)) {
|
||||
return item.getValue();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.jsowell.common.enums.uniapp;
|
||||
|
||||
/**
|
||||
* 占桩订单enum
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2023/8/18 9:41
|
||||
*/
|
||||
public enum OrderPileOccupyStatusEnum {
|
||||
OCCUPIED("0", "占桩中"),
|
||||
ORDER_COMPLETE("1", "订单完成"),
|
||||
ORDER_HANG_UP("2", "订单挂起"),
|
||||
;
|
||||
|
||||
private String code;
|
||||
private String value;
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
OrderPileOccupyStatusEnum(String code, String value) {
|
||||
this.code = code;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code获取value
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public static String getValueByCode(String code) {
|
||||
for (OrderPileOccupyStatusEnum item : OrderPileOccupyStatusEnum.values()) {
|
||||
if (item.getCode().equals(code)) {
|
||||
return item.getValue();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,24 @@
|
||||
package com.jsowell.pile.dto;/**
|
||||
* TODO
|
||||
package com.jsowell.pile.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 生成占桩订单DTO
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2023/8/18 9:00
|
||||
* @author Lemon
|
||||
*/public class GenerateOccupyOrderDTO {
|
||||
*/
|
||||
@Data
|
||||
public class GenerateOccupyOrderDTO {
|
||||
private String memberId;
|
||||
|
||||
/**
|
||||
* 桩号
|
||||
*/
|
||||
private String pileSn;
|
||||
|
||||
/**
|
||||
* 枪口号
|
||||
*/
|
||||
private String connectorCode;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.jsowell.pile.mapper;
|
||||
|
||||
import com.jsowell.pile.domain.OrderPileOccupy;
|
||||
import com.jsowell.pile.dto.QueryOccupyOrderDTO;
|
||||
import com.jsowell.pile.vo.uniapp.OrderPileOccupyVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@@ -83,4 +84,11 @@ public interface OrderPileOccupyMapper {
|
||||
* @return
|
||||
*/
|
||||
List<OrderPileOccupy> queryUnPayOrderByMemberId(@Param("memberId") String memberId);
|
||||
|
||||
/**
|
||||
* 查询占桩订单列表
|
||||
* @param memberId
|
||||
* @return
|
||||
*/
|
||||
List<OrderPileOccupyVO> getOccupyOrderInfo(String memberId);
|
||||
}
|
||||
@@ -2,7 +2,9 @@ package com.jsowell.pile.service;
|
||||
|
||||
import com.jsowell.pile.domain.OrderPileOccupy;
|
||||
import com.jsowell.pile.dto.PayOrderDTO;
|
||||
import com.jsowell.pile.dto.GenerateOccupyOrderDTO;
|
||||
import com.jsowell.pile.dto.QueryOccupyOrderDTO;
|
||||
import com.jsowell.pile.vo.uniapp.OrderPileOccupyVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -37,7 +39,7 @@ public interface OrderPileOccupyService{
|
||||
/**
|
||||
* 生成占桩订单
|
||||
*/
|
||||
void generateOccupyPileOrder(String memberId, String pileSn, String connectorCode);
|
||||
String generateOccupyPileOrder(GenerateOccupyOrderDTO dto);
|
||||
|
||||
/**
|
||||
* 停止并计算占桩订单
|
||||
@@ -54,4 +56,11 @@ public interface OrderPileOccupyService{
|
||||
List<OrderPileOccupy> queryUnPayOrderByMemberId(String memberId);
|
||||
|
||||
Map<String, Object> payOccupyPileOrder(PayOrderDTO dto);
|
||||
|
||||
/**
|
||||
* 查询占桩订单列表
|
||||
* @param memberId
|
||||
* @return
|
||||
*/
|
||||
List<OrderPileOccupyVO> getOccupyOrderInfo(String memberId);
|
||||
}
|
||||
|
||||
@@ -8,17 +8,22 @@ import com.jsowell.common.enums.MemberWalletEnum;
|
||||
import com.jsowell.common.enums.ykc.OrderPayModeEnum;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.enums.uniapp.OrderPileOccupyPayStatusEnum;
|
||||
import com.jsowell.common.enums.uniapp.OrderPileOccupyStatusEnum;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.PageUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.id.IdUtils;
|
||||
import com.jsowell.pile.domain.OrderPileOccupy;
|
||||
import com.jsowell.pile.dto.PayOrderDTO;
|
||||
import com.jsowell.pile.dto.GenerateOccupyOrderDTO;
|
||||
import com.jsowell.pile.dto.QueryOccupyOrderDTO;
|
||||
import com.jsowell.pile.dto.QueryOrderDTO;
|
||||
import com.jsowell.pile.mapper.OrderPileOccupyMapper;
|
||||
import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.vo.base.PileInfoVO;
|
||||
import com.jsowell.pile.vo.uniapp.MemberVO;
|
||||
import com.jsowell.pile.vo.uniapp.OrderPileOccupyVO;
|
||||
import com.jsowell.pile.vo.web.BillingTemplateVO;
|
||||
import com.jsowell.pile.vo.web.OrderListVO;
|
||||
import com.jsowell.pile.vo.web.UpdateMemberBalanceDTO;
|
||||
@@ -33,7 +38,7 @@ import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class OrderPileOccupyServiceImpl implements OrderPileOccupyService{
|
||||
public class OrderPileOccupyServiceImpl implements OrderPileOccupyService {
|
||||
|
||||
@Resource
|
||||
private OrderPileOccupyMapper orderPileOccupyMapper;
|
||||
@@ -110,6 +115,7 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService{
|
||||
|
||||
/**
|
||||
* 根据占桩订单编号查询占桩订单
|
||||
*
|
||||
* @param occupyCode 占桩订单编号
|
||||
* @return
|
||||
*/
|
||||
@@ -123,6 +129,7 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService{
|
||||
|
||||
/**
|
||||
* 查询占桩订单列表
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@@ -134,12 +141,14 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService{
|
||||
/**
|
||||
* 生成占桩订单
|
||||
* 在会员操作降地锁后,就生成占桩订单
|
||||
* @param memberId 会员id
|
||||
* @param pileSn 充电桩编号
|
||||
* @param connectorCode 充电桩枪口号
|
||||
*
|
||||
* @param dto 会员id 充电桩编号 充电桩枪口号
|
||||
*/
|
||||
@Override
|
||||
public void generateOccupyPileOrder(String memberId, String pileSn, String connectorCode) {
|
||||
public String generateOccupyPileOrder(GenerateOccupyOrderDTO dto) {
|
||||
String memberId = dto.getMemberId();
|
||||
String pileSn = dto.getPileSn();
|
||||
String connectorCode = dto.getConnectorCode();
|
||||
// 创建占桩订单
|
||||
OrderPileOccupy orderPileOccupy = new OrderPileOccupy();
|
||||
String occupyCode = "OP" + IdUtils.getOrderCode();
|
||||
@@ -157,11 +166,14 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService{
|
||||
orderPileOccupy.setStartTime(DateUtils.getNowDate());
|
||||
orderPileOccupy.setDelFlag(DelFlagEnum.NORMAL.getValue());
|
||||
orderPileOccupyMapper.insertSelective(orderPileOccupy);
|
||||
|
||||
return orderPileOccupy.getOccupyCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* 收到地锁升起指令,调用这个方法,停止计时
|
||||
* 占桩订单停止计费/停止占桩订单计费
|
||||
*
|
||||
* @param pileSn
|
||||
* @param connectorCode
|
||||
*/
|
||||
@@ -273,8 +285,29 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService{
|
||||
return orderPileOccupyMapper.queryUnPayOrderByMemberId(memberId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询占桩订单列表
|
||||
*
|
||||
* @param memberId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<OrderPileOccupyVO> getOccupyOrderInfo(String memberId) {
|
||||
// 分页
|
||||
PageUtils.startPage();
|
||||
List<OrderPileOccupyVO> list = orderPileOccupyMapper.getOccupyOrderInfo(memberId);
|
||||
for (OrderPileOccupyVO orderPileOccupyVO : list) {
|
||||
// 订单状态
|
||||
orderPileOccupyVO.setStatus(OrderPileOccupyStatusEnum.getValueByCode(orderPileOccupyVO.getStatus()));
|
||||
// 支付状态
|
||||
orderPileOccupyVO.setPayStatus(OrderPileOccupyPayStatusEnum.getValueByCode(orderPileOccupyVO.getPayStatus()));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付占桩订单
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@@ -285,8 +318,6 @@ public class OrderPileOccupyServiceImpl implements OrderPileOccupyService{
|
||||
if (orderPileOccupy == null) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_QUERY_ORDER_INFO_IS_NULL);
|
||||
}
|
||||
// 校验订单状态
|
||||
|
||||
// 支付方式
|
||||
Map<String, Object> resultMap = Maps.newHashMap();
|
||||
if (StringUtils.equals(dto.getPayMode(), OrderPayModeEnum.PAYMENT_OF_BALANCE.getValue())) {
|
||||
|
||||
@@ -357,7 +357,7 @@ public class PileBillingTemplateServiceImpl implements IPileBillingTemplateServi
|
||||
}
|
||||
}
|
||||
}
|
||||
log.info("通过站点id查询当前时间的收费详情 stationId:{}, result:{}", stationId, JSON.toJSONString(result));
|
||||
// log.info("通过站点id查询当前时间的收费详情 stationId:{}, result:{}", stationId, JSON.toJSONString(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.jsowell.pile.vo.uniapp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 占桩订单列表VO
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2023/8/18 9:34
|
||||
*/
|
||||
@Data
|
||||
public class OrderPileOccupyVO {
|
||||
/**
|
||||
* 占桩订单编号
|
||||
*/
|
||||
private String occupyCode;
|
||||
|
||||
/**
|
||||
* 状态(0-占桩中;1-订单完成; 2-订单挂起)
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 站点id
|
||||
*/
|
||||
private String stationId;
|
||||
|
||||
/**
|
||||
* 站点名称
|
||||
*/
|
||||
private String stationName;
|
||||
|
||||
/**
|
||||
* 占桩开始时间
|
||||
*/
|
||||
private String startTime;
|
||||
|
||||
/**
|
||||
* 占桩结束时间
|
||||
*/
|
||||
private String endTime;
|
||||
|
||||
/**
|
||||
* 支付状态(0-未支付;1-支付完成;2-无需支付)
|
||||
*/
|
||||
private String payStatus;
|
||||
|
||||
/**
|
||||
* 占桩订单金额
|
||||
*/
|
||||
private String orderAmount;
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user