Commit f7e4963b authored by hanfeng's avatar hanfeng

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

parents 1f8c1ee2 965dab3d
......@@ -25,7 +25,7 @@ import static org.springframework.http.HttpStatus.NOT_EXTENDED;
/**
* Created by ace on 2017/9/8.
*/
@ControllerAdvice
@ControllerAdvice("com.github.wxiaoqi.security")
@ResponseBody
public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
private Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);
......@@ -67,7 +67,7 @@ public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
if(0 == ex.getStatus()) {
response.setStatus(500);
}
HttpRequestUtil.httpGet("http://10.5.52.3:8765/api/universal/mail/app/unauth/send?toUser=jiaoruizhen@126.com&subject=服务器异常&content=" + ex.toString());
HttpRequestUtil.httpGet("http://10.5.52.3:8765/api/universal/mail/app/unauth/send?toUser=jiaoruizhen@126.com&subject=服务器异常&content=" + ex);
return new BaseResponse(ex.getStatus(), ex.getMessage());
}
......@@ -75,7 +75,7 @@ public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
public BaseResponse otherExceptionHandler(HttpServletResponse response, Exception ex) {
response.setStatus(500);
logger.error(ex.getMessage(),ex);
HttpRequestUtil.httpGet("http://10.5.52.3:8765/api/universal/mail/app/unauth/send?toUser=jiaoruizhen@126.com&subject=服务器异常&content=" + ex.toString());
HttpRequestUtil.httpGet("http://10.5.52.3:8765/api/universal/mail/app/unauth/send?toUser=jiaoruizhen@126.com&subject=服务器异常&content=" + ex);
return new BaseResponse(CommonConstants.EX_OTHER_CODE, ex.getMessage());
}
}
......@@ -4,6 +4,7 @@ package com.github.wxiaoqi.security.common.handler;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.BaseResponse;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.HttpRequestUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.ExceptionHandler;
......@@ -28,9 +29,11 @@ public class PlatformExceptionHandler {
Throwable cause = e.getCause();
if(cause != null && cause.toString().contains("Exception")) {
log.error(cause.getMessage(), e);
HttpRequestUtil.httpGet("http://10.5.52.3:8765/api/universal/mail/app/unauth/send?toUser=jiaoruizhen@126.com&subject=服务器异常&content=" + e);
return assembleResult(ObjectRestResponse.createFailedResult(5000, "服务器开小差了,请稍后重试!"), "Server exception: " + e.getMessage());
}
log.error("Server exception: ", e);
HttpRequestUtil.httpGet("http://10.5.52.3:8765/api/universal/mail/app/unauth/send?toUser=jiaoruizhen@126.com&subject=服务器异常&content=" + e);
return assembleResult(ObjectRestResponse.createFailedResult(5000, "服务器开小差了,请稍后重试!"), "Server exception: " + e.getMessage());
}
......
......@@ -56,7 +56,6 @@ public class TokenAop {
public Object token(ProceedingJoinPoint proceedingJoinPoint) throws Throwable{
HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
String token = request.getHeader(tokenHeader);
log.info("token【{}】",token);
Object[] args = proceedingJoinPoint.getArgs();
if (ArrayUtil.isEmpty(args)){
//没有参数直接返回
......
......@@ -3,29 +3,22 @@ package com.github.wxiaoqi.security.admin.rest;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.github.wxiaoqi.security.admin.biz.*;
import com.github.wxiaoqi.security.admin.entity.*;
import com.github.wxiaoqi.security.admin.entity.AppUserLogin;
import com.github.wxiaoqi.security.admin.entity.AppUserPosition;
import com.github.wxiaoqi.security.admin.entity.User;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.admin.rpc.service.PermissionService;
import com.github.wxiaoqi.security.admin.vo.AppUserVo;
import com.github.wxiaoqi.security.admin.vo.FrontUser;
import com.github.wxiaoqi.security.admin.vo.MenuTree;
import com.github.wxiaoqi.security.admin.vo.UserMemberVo;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.BaseResponse;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.util.process.SystemConfig;
import io.swagger.models.auth.In;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
/**
* ${DESCRIPTION}
......@@ -60,11 +53,11 @@ public class PublicController {
ObjectRestResponse userinfoByToken(String token) throws Exception {
String username = userAuthUtil.getInfoFromToken(token).getUniqueName();
if (username == null) {
throw new BaseException(ResultCode.NOTEXIST_CODE);
return ObjectRestResponse.createFailedResult(ResultCode.USER_NOTEXIST_CODE, ResultCode.getMsg(ResultCode.USER_NOTEXIST_CODE));
}
User user = userBiz.getUserByUsername(username);
if (user == null) {
throw new BaseException(ResultCode.NOTEXIST_CODE);
return ObjectRestResponse.createFailedResult(ResultCode.USER_NOTEXIST_CODE, ResultCode.getMsg(ResultCode.USER_NOTEXIST_CODE));
}
return new ObjectRestResponse<User>().rel(true).data(user);
}
......@@ -74,8 +67,7 @@ public class PublicController {
ObjectRestResponse userDetailByToken(String token) throws Exception {
String username = userAuthUtil.getInfoFromToken(token).getId();
if (username == null) {
throw new BaseException(ResultCode.NOTEXIST_CODE
, new HashSet<String>() {{add("用户名不存在!");}});
return ObjectRestResponse.createFailedResult(ResultCode.USER_NOTEXIST_CODE, ResultCode.getMsg(ResultCode.USER_NOTEXIST_CODE));
}
Integer userid = Integer.parseInt(username);
return ObjectRestResponse.succ(getAppUserInfoById(userid));
......@@ -85,8 +77,7 @@ public class PublicController {
public @ResponseBody
ObjectRestResponse<AppUserDTO> userDetailById(Integer id) throws Exception {
if (id == null) {
throw new BaseException(ResultCode.NOTEXIST_CODE
, new HashSet<String>() {{add("用户名不存在!");}});
return ObjectRestResponse.paramIsEmpty();
}
return ObjectRestResponse.succ(getAppUserInfoById(id));
}
......@@ -96,13 +87,11 @@ public class PublicController {
ObjectRestResponse<AppUserDTO> userDetailByUsername(String name) throws Exception {
AppUserLogin appUserLogin;
if (StrUtil.isBlank(name)) {
throw new BaseException(ResultCode.NOTEXIST_CODE
, new HashSet<String>() {{add("用户名不存在!");}});
return ObjectRestResponse.paramIsEmpty();
}else {
appUserLogin = appUserLoginBiz.selectOne(new AppUserLogin(){{setUsername(name);}});
if(null == appUserLogin) {
throw new BaseException(ResultCode.NOTEXIST_CODE
, new HashSet<String>() {{add("用户名不存在!");}});
return ObjectRestResponse.createFailedResult(ResultCode.USER_NOTEXIST_CODE, ResultCode.getMsg(ResultCode.USER_NOTEXIST_CODE));
}
}
return ObjectRestResponse.succ(getAppUserInfoById(appUserLogin.getId()));
......@@ -113,8 +102,7 @@ public class PublicController {
//获取用户基础信息
AppUserVo userVo = detailBiz.getUserInfoById(userid);
if (userVo == null) {
throw new BaseException(ResultCode.NOTEXIST_CODE
, new HashSet<String>() {{add("用户不存在!");}});
return null;
}
Integer id= userVo.getId();
Integer positionId=userVo.getPositionId();
......@@ -136,15 +124,15 @@ public class PublicController {
@RequestMapping(value = "/userinfo-by-uid", method = RequestMethod.GET)
public @ResponseBody
ObjectRestResponse userinfoByUid(Integer uid) throws Exception {
ObjectRestResponse<User> userinfoByUid(Integer uid) throws Exception {
if (uid == null||uid==0) {
throw new BaseException();
return ObjectRestResponse.paramIsEmpty();
}
User user = userBiz.getUserByUid(uid);
if (user == null) {
throw new BaseException();
return ObjectRestResponse.createFailedResult(ResultCode.USER_NOTEXIST_CODE, ResultCode.getMsg(ResultCode.USER_NOTEXIST_CODE));
}
return new ObjectRestResponse<User>().rel(true).data(user);
return ObjectRestResponse.succ(user);
}
@GetMapping("/getByUserIds")
......
......@@ -77,7 +77,7 @@ public class MsgBiz {
Query query = null;
List<Msg> msgList = null;
if (type != null) {
query = new Query(Criteria.where("body.type").is(type));
query = new Query(Criteria.where("body.type").is(type).and("visible").is(1));
int totalSize = mongoTemplate.find(query, Msg.class, "s_msg").size();
query.with(pageable);
query.with(new Sort(Sort.Direction.DESC, "time"));
......@@ -89,7 +89,7 @@ public class MsgBiz {
List<Integer> ids = new ArrayList<>();
ids.add(2);
ids.add(4);
query = new Query(Criteria.where("body.type").in(ids));
query = new Query(Criteria.where("body.type").in(ids).and("visible").is(1));
int totalSize = mongoTemplate.find(query, Msg.class, "s_msg").size();
query.with(pageable);
query.with(new Sort(Sort.Direction.DESC, "time"));
......@@ -114,7 +114,7 @@ public class MsgBiz {
List<Integer> ids = new ArrayList<>();
ids.add(2);
ids.add(4);
Query query = new Query(Criteria.where("body.type").in(ids).and("count.praise").gt(getNumber()));
Query query = new Query(Criteria.where("body.type").in(ids).and("count.praise").gt(getNumber()).and("visible").is(1));
int totalSize = mongoTemplate.find(query, Msg.class, "s_msg").size();
query.with(pageable);
query.with(new Sort(Sort.Direction.DESC, "count.praise"));
......@@ -134,7 +134,7 @@ public class MsgBiz {
if (id == null) {
return ObjectRestResponse.paramIsEmpty();
}
Query query = new Query(Criteria.where("id").is(new ObjectId(id)));
Query query = new Query(Criteria.where("id").is(new ObjectId(id)).and("visible").is(1));
List<Msg> msgList = fetchAndAttach(mongoTemplate.find(query, Msg.class, "s_msg"), userId);
List<MsgVo> msgVoList = replaceMsgResult(msgList);
if (msgVoList.size() > 0) {
......
......@@ -81,4 +81,9 @@ public class InProgressVO {
* 延期 详情列表
*/
List<VMCalendarPriceCostDTO> overAmountList = CollUtil.newArrayList();
/**
* 违约金 费用详情列表
*/
List<VMCalendarPriceCostDTO> violateAmountList = CollUtil.newArrayList();
}
package com.xxfc.platform.order.pojo.price;
import cn.hutool.core.collection.CollUtil;
import com.xxfc.platform.order.pojo.account.OrderAccountDeduction;
import com.xxfc.platform.vehicle.pojo.dto.order.VMCalendarPriceCostDTO;
import lombok.Data;
......@@ -24,6 +25,11 @@ public class CancelStartedVO extends CostDetailExtend {
*/
private Integer usedDayNum = 0;
/**
* 允许使用天数
*/
private Integer ableUsedDayNum = 0;
/**
* 使用金额
*/
......@@ -69,34 +75,17 @@ public class CancelStartedVO extends CostDetailExtend {
*/
private BigDecimal damagesAmount = BigDecimal.ZERO;
private List<OrderAccountDeduction> deductionList = CollUtil.newArrayList();
/**
* 延期 详情列表
*/
List<VMCalendarPriceCostDTO> overAmountList = CollUtil.newArrayList();
//标记是否单价一样
private Integer sameUseUnitPrice = 1;
//标记是否单价一样
private Integer sameOverUnitPrice = 1;
public void setSameUseUnitPriceFromList(List<VMCalendarPriceCostDTO> useAmountList) {
this.sameUseUnitPrice = judgeSame(useAmountList);
}
public void setSameOverUnitPriceFromList(List<VMCalendarPriceCostDTO> overAmountList) {
this.sameOverUnitPrice = judgeSame(overAmountList);
}
private Integer judgeSame(List<VMCalendarPriceCostDTO> useAmountList) {
BigDecimal tempUnitPrice = null;
for(VMCalendarPriceCostDTO vmcpcd : useAmountList) {
if(null == tempUnitPrice) {
tempUnitPrice = vmcpcd.getPrice();
}else if(!tempUnitPrice.equals(vmcpcd.getPrice())) {
return 0;
}
}
return 1;
}
}
......@@ -42,7 +42,38 @@ public class CostDetailExtend {
/**
* 使用(消耗)详情列表
*/
List<VMCalendarPriceCostDTO> useAmountList = CollUtil.newArrayList();;
List<VMCalendarPriceCostDTO> useAmountList = CollUtil.newArrayList();
/**
* 违约金 费用详情列表
*/
List<VMCalendarPriceCostDTO> violateAmountList = CollUtil.newArrayList();
//标记是否单价一样
private Integer sameUseUnitPrice = 1;
//标记是否单价一样
private Integer sameViolateUnitPrice = 1;
public void setSameUseUnitPriceFromList(List<VMCalendarPriceCostDTO> useAmountList) {
this.sameUseUnitPrice = judgeSame(useAmountList);
}
public void setSameViolateUnitPriceFromList(List<VMCalendarPriceCostDTO> violateAmountList) {
this.sameViolateUnitPrice = judgeSame(violateAmountList);
}
protected Integer judgeSame(List<VMCalendarPriceCostDTO> useAmountList) {
BigDecimal tempUnitPrice = null;
for(VMCalendarPriceCostDTO vmcpcd : useAmountList) {
if(null == tempUnitPrice) {
tempUnitPrice = vmcpcd.getPrice();
}else if(!tempUnitPrice.equals(vmcpcd.getPrice())) {
return 0;
}
}
return 1;
}
public void initParamJson() {
paramJson = JSONUtil.toJsonStr(this);
......
......@@ -483,10 +483,13 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
csv.setUsedfreeDayNum(inProgressVO.getUsedfreeDays());
csv.setUsedFreeAmount(inProgressVO.getUsedFreeDaysAmount());
csv.setHadConpon((StrUtil.isNotBlank(orderMQDTO.getCouponTickerNos())? Boolean.TRUE: Boolean.FALSE));
csv.setAbleUsedDayNum(inProgressVO.getUseAmountList().size());
csv.setSameUseUnitPriceFromList(inProgressVO.getUseAmountList());
csv.setSameOverUnitPriceFromList(inProgressVO.getOverAmountList());
csv.setUseAmountList(inProgressVO.getUseAmountList());
csv.setOverAmountList(inProgressVO.getOverAmountList());
csv.setViolateAmountList(inProgressVO.getViolateAmountList());
if(csv.getUsedDayNum() == orderMQDTO.getOrderRentVehicleDetail().getDayNum()) {
csv.setType(CostDetailExtend.FINLISH_ONTIME);
......@@ -499,6 +502,7 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
}
csv.setDeductionList(oad.getDeductions());
csv.initParamJson();
//设置明细
orderRentVehicleBiz.updateSelectiveByIdRe(new OrderRentVehicleDetail(){{
......
......@@ -161,8 +161,13 @@ public class OrderDepositRefundRecordBiz extends BaseBiz<DepositRefundRecordMapp
if(depositRefundRecord != null) {
DepositRefundRecord newValue = new DepositRefundRecord();
BeanUtil.copyProperties(depositRefundRecord, newValue, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
if (orderViolation.getPrice().doubleValue() > 0) {
newValue.setAmount(orderViolation.getPrice());
newValue.setRestAmount(depositRefundRecord.getTotalAmount().subtract(orderViolation.getPrice()));//减去违章金之后的押金
newValue.setRestAmount(depositRefundRecord.getRestAmount().subtract(orderViolation.getPrice()));//减去违章金之后的押金
} else {
newValue.setAmount(new BigDecimal(0));
newValue.setRestAmount(depositRefundRecord.getRestAmount());//减去违章金之后的押金
}
newValue.setIscomplete(false);
newValue.setId(null);
mapper.insert(newValue);
......
......@@ -207,16 +207,21 @@ public class OrderCalculateBiz {
BigDecimal residueAmount = BigDecimal.ZERO;
for(int i = useDays; i < vehicleItemDTO.getTotalNum(); i++) {
residueAmount = residueAmount.add(vmcpds.get(i).getPrice());
inProgressVO.getViolateAmountList().add(vmcpds.get(i));
}
String violateDesc = StrUtil.format("{}元", residueAmount.toString());
if(residueDays >= 2) {
residueDays = 2;
residueAmount = BigDecimal.ZERO;
inProgressVO.setViolateAmountList(CollUtil.newArrayList());
for(int i = useDays; i < (useDays + residueDays); i++) {
residueAmount = residueAmount.add(vmcpds.get(i).getPrice());
inProgressVO.getViolateAmountList().add(vmcpds.get(i));
}
violateDesc += StrUtil.format("(封顶{}元)", residueAmount);
}
inProgressVO.setViolateAmount(residueAmount);
inProgressVO.setViolateDesc(" 提前还车违约金:"+ violateDesc);
OrderAccountDeduction violateDeduction = orderAccountBiz.initDeduction(inProgressVO.getViolateAmount(), violateDesc, DeductionTypeEnum.VIOLATE_ADVANCE, OrderAccountDeduction.ORIGIN_DEPOSIT);
......@@ -240,6 +245,8 @@ public class OrderCalculateBiz {
inProgressVO.setViolateAmount(overAmount);
inProgressVO.setViolateDesc(" 延期还车违约金:"+ violateDesc);
inProgressVO.setOverAmountList(overAmountList);
inProgressVO.setViolateAmountList(overAmountList);
OrderAccountDeduction violateDeduction = orderAccountBiz.initDeduction(inProgressVO.getViolateAmount(), violateDesc, DeductionTypeEnum.VIOLATE_DELAY, OrderAccountDeduction.ORIGIN_DEPOSIT);
oad.getDeductions().add(violateDeduction);
}
......
......@@ -175,6 +175,8 @@ public class OrderCancelBiz {
csv.setHadConpon((StrUtil.isNotBlank(baseOrder.getCouponTickerNos())? Boolean.TRUE: Boolean.FALSE));
csv.setViolateAmount(BigDecimal.ZERO);
csv.setViolateDesc("");
csv.setAbleUsedDayNum(inProgressVO.getUseAmountList().size());
csv.setSameUseUnitPriceFromList(inProgressVO.getUseAmountList());
csv.setSameOverUnitPriceFromList(inProgressVO.getOverAmountList());
csv.setUseAmountList(inProgressVO.getUseAmountList());
......@@ -194,6 +196,8 @@ public class OrderCancelBiz {
baseOrder.setViolateAmount(csv.getViolateAmount());
baseOrder.setExtraAmount(inProgressVO.getExtraAmount());
//最后设置DeductionList
csv.setDeductionList(oad.getDeductions());
csv.initParamJson();
//orderTemplateBiz.handleCostDetailExtend(csv);
orvd.handelCostDetailExtend(csv);
......@@ -226,6 +230,10 @@ public class OrderCancelBiz {
CancelNoStartVO cnsv = new CancelNoStartVO(){{
setViolateAmount(deduction.getAmount());
setViolateDesc(deduction.getName());
//设置违约金日期费用列表
setViolateAmountList(vehicleItemDTO.getVehicleDetail());
setSameViolateUnitPriceFromList(vehicleItemDTO.getVehicleDetail());
}};
//设置订单数据
......
......@@ -325,7 +325,6 @@ public class BackStageOrderController extends CommonBaseController implements Us
for (OrderPageVO orderPageVO : pageDataVO.getData()) {
if (orderPageVO.getOrderRentVehicleDetail() != null && orderPageVO.getOrderRentVehicleDetail().getVehicleId() != null) {
ObjectRestResponse<Vehicle> restResponse = vehicleFeign.get(orderPageVO.getOrderRentVehicleDetail().getVehicleId());
log.info("获取车辆信息返回消息:{}", restResponse.getMessage());
if (restResponse.getData() != null) {
orderPageVO.setVehicalNumberPlat(restResponse.getData().getNumberPlate());
orderPageVO.setCode(restResponse.getData().getCode());
......
......@@ -59,7 +59,7 @@ public class SysRegionBiz extends BaseBiz<SysRegionMapper, SysRegion> {
}
}
if(!hasCache){//从db读
if(!hasCache && ids != null){//从db读
rs = mapper.getByIdList(ids);
}
return rs;
......
......@@ -256,7 +256,7 @@ public class VehicleActiveService {
bookVehicleVo.setBookEndDate(null);
bookVehicleVo.setUnbookStartDate(actualArrivalDate.toString(DATE_TIME_FORMATTER));
bookVehicleVo.setUnbookEndDate(arrivalDate.toString(DATE_TIME_FORMATTER));
bookVehicleVo.setRemark(bookVehicleVo.getRemark() + " 用户提前还车,取消剩余天数, 初始预定结束时间是," + new DateTime(vehicleBookRecord.getBookEndDate()).toString(DATE_TIME_FORMATTER));
bookVehicleVo.setRemark(bookVehicleVo.getRemark()==null?"": bookVehicleVo.getRemark()+ " 用户提前还车,取消剩余天数, 初始预定结束时间是," + new DateTime(vehicleBookRecord.getBookEndDate()).toString(DATE_TIME_FORMATTER));
vehicleBookRecord.setRemark(bookVehicleVo.getRemark());
try {
Boolean hasSuc = vehicleBiz.unbookVehicle(bookVehicleVo);
......@@ -268,7 +268,7 @@ public class VehicleActiveService {
log.error(e.getMessage(), e);;
}
} else if (actualArrivalDate.compareTo(arrivalDate) > 0) {//实际还车时间大于预计还车时间
vehicleBookRecord.setRemark(vehicleBookRecord.getRemark() + " 用户延期还车,实际占用日期");
vehicleBookRecord.setRemark(vehicleBookRecord.getRemark()==null?"": vehicleBookRecord.getRemark() + " 用户延期还车,实际占用日期");
}
updateBookRecordStatus(vehicleBookRecord, 2);
departureLog.setMileageEnd(arrivalVo.getMileage());
......
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