Commit f991582a authored by 周健威's avatar 周健威

Merge remote-tracking branch 'origin/dev-chw' into dev-chw

parents 568a1155 e99d6133
package com.xxfc.platform.order.biz;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.order.entity.OrderRentVehicleDetail;
import com.xxfc.platform.order.entity.OrderViolation;
import com.xxfc.platform.order.mapper.OrderRentVehicleDetailMapper;
......@@ -26,6 +30,7 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.math.BigInteger;
import java.util.Map;
import java.util.concurrent.TimeUnit;
......@@ -36,14 +41,21 @@ import java.util.concurrent.TimeUnit;
*/
@Service
@Slf4j
public class OrderViolationBiz extends BaseBiz<OrderViolationMapper, OrderViolation> {
public class OrderViolationBiz extends BaseBiz<OrderViolationMapper, OrderViolation> implements UserRestInterface {
@Autowired
private OrderRentVehicleDetailMapper detailMapper;
@Value("order.violation.upload")
private String ovUpload;
@Autowired
UserFeign userFeign;
public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd");
@Override
public UserFeign getUserFeign() {
return userFeign;
}
@Autowired
private RedisTemplate redisTemplate;
......@@ -55,19 +67,34 @@ public class OrderViolationBiz extends BaseBiz<OrderViolationMapper, OrderViolat
*/
@Transactional(rollbackFor = Exception.class)
public void insertOrderViolation(OrderViolation orderViolation) {
OrderRentVehicleDetail orderRentVehicleDetail = new OrderRentVehicleDetail();
orderRentVehicleDetail.setId(orderViolation.getDetailId());
orderRentVehicleDetail.setHandelViolation(0);
Map<String, Object> status = mapper.getOrderAndVehicleStatus(orderViolation.getDetailId());
Integer orderStatus = (Integer) status.get("status");
Integer refundStatus = (Integer) status.get("refundStatus");
if (orderStatus >= 6 || (refundStatus <= 2 && refundStatus != 1)) {
insertSelective(orderViolation);
detailMapper.updateByPrimaryKeySelective(orderRentVehicleDetail);
UserDTO userDTO = getBusinessUserByAppUser();
if (userDTO == null ) {
throw new BaseException(ResultCode.RSTOKEN_EXPIRED_CODE);
}
OrderViolation old = mapper.selectOne(new OrderViolation(){{setDetailId(orderViolation.getDetailId());}});
if (old != null) {
throw new BaseException("违章记录已存在!");
} else {
throw new BaseException("The operation cannot be changed at this time");
OrderRentVehicleDetail orderRentVehicleDetail = new OrderRentVehicleDetail();
orderRentVehicleDetail.setId(orderViolation.getDetailId());
orderRentVehicleDetail.setHandelViolation(0);
Map<String, Object> status = mapper.getOrderAndVehicleStatus(orderViolation.getDetailId());
Integer orderStatus = (Integer) status.get("status");
Integer refundStatus = (Integer) status.get("refundStatus");
if (orderStatus >= 6 || (refundStatus <= 2 && refundStatus != 1)) {
orderViolation.setIsDel(0);
orderViolation.setCrtHost(getRequest().getRemoteHost());
orderViolation.setCrtName(userDTO.getName());
orderViolation.setCrtUserId(userDTO.getId());
orderViolation.setCrtTime(new BigInteger(String.valueOf(System.currentTimeMillis())));
insertSelective(orderViolation);
detailMapper.updateByPrimaryKeySelective(orderRentVehicleDetail);
} else {
throw new BaseException("The operation cannot be changed at this time");
}
}
}
/**
......@@ -77,10 +104,18 @@ public class OrderViolationBiz extends BaseBiz<OrderViolationMapper, OrderViolat
*/
@Transactional(rollbackFor = Exception.class)
public void updateOrderViolation(OrderViolation orderViolation) {
UserDTO userDTO = getBusinessUserByAppUser();
if (userDTO == null ) {
throw new BaseException(ResultCode.RSTOKEN_EXPIRED_CODE);
}
Map<String, Object> status = mapper.getOrderAndVehicleStatus(orderViolation.getDetailId());
Integer orderStatus = (Integer) status.get("status");
Integer refundStatus = (Integer) status.get("refundStatus");
if (orderStatus >= 6 || (refundStatus <= 2 && refundStatus != 1)) {
orderViolation.setUpdHost(getRequest().getRemoteHost());
orderViolation.setUpdName(userDTO.getName());
orderViolation.setUpdUserId(userDTO.getId());
orderViolation.setUpdTime(new BigInteger(String.valueOf(System.currentTimeMillis())));
updateSelectiveByIdRe(orderViolation);
} else {
throw new BaseException("The operation cannot be changed at this time");
......
......@@ -2,8 +2,6 @@ package com.xxfc.platform.order.rest;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
......@@ -21,7 +19,6 @@ import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.weekend.WeekendSqls;
import javax.servlet.http.HttpServletRequest;
import java.math.BigInteger;
import java.util.List;
/**
......@@ -30,19 +27,16 @@ import java.util.List;
* @author Administrator
*/
@RestController
@RequestMapping("orderViolation")
@RequestMapping("/chw/orderViolation")
@Slf4j
public class OrderViolationController extends BaseController<OrderViolationBiz, OrderViolation> implements UserRestInterface {
public class OrderViolationController extends BaseController<OrderViolationBiz, OrderViolation> {
@Autowired
private UserFeign userFeign;
@Autowired
OrderDepositRefundRecordBiz orderDepositRefundRecordBiz;
@Override
public UserFeign getUserFeign() {
return userFeign;
}
private Long MAX_DRIVING_LICENSE_SIZE = 1024 * 1024 * 50L;
......@@ -58,19 +52,9 @@ public class OrderViolationController extends BaseController<OrderViolationBiz,
@PostMapping("/saveOrderViolation")
public ObjectRestResponse saveOrderViolation(@RequestBody OrderViolation orderViolation, HttpServletRequest request) {
log.info("保存违章记录:orderViolation = {}", orderViolation.toString());
UserDTO userDTOD = getBusinessUserByAppUser();
if (orderViolation.getId() == null) {
orderViolation.setIsDel(0);
orderViolation.setCrtHost(request.getRemoteHost());
orderViolation.setCrtName(userDTOD.getName());
orderViolation.setCrtUserId(userDTOD.getId());
orderViolation.setCrtTime(new BigInteger(String.valueOf(System.currentTimeMillis())));
getBaseBiz().insertOrderViolation(orderViolation);
} else {
orderViolation.setUpdHost(request.getRemoteHost());
orderViolation.setUpdName(userDTOD.getName());
orderViolation.setUpdUserId(userDTOD.getId());
orderViolation.setUpdTime(new BigInteger(String.valueOf(System.currentTimeMillis())));
getBaseBiz().updateOrderViolation(orderViolation);
}
orderDepositRefundRecordBiz.saveViolationDeposit(orderViolation);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment