Commit b6131c24 authored by hezhen's avatar hezhen

Merge branch 'dev' of http://113.105.137.151:22280/youjj/cloud-platform into dev

parents b83cd84b a9c6838f
......@@ -8,6 +8,7 @@ public enum DeductionTypeEnum {
VIOLATE_CANCEL(101, "提前取消违约金"),
VIOLATE_ADVANCE(102, "提前还车违约金"),
VIOLATE_DELAY(103, "延迟还车违约金"),
VIOLATE_CHANGE_C(104, "更换还车公司费用"),
CONSUME(201, "消费金额"),
DAMAGES(301, "赔偿金(定损)"),
VIOLATE_TRAFFIC_DEDUCT(401, "违章扣款"),
......
......@@ -74,6 +74,6 @@ public class RentVehicleBO extends OrderRentVehicleDetail implements OrderDetail
public void initDate() {
this.startDate = DateUtil.date(getStartTime());
this.endDate = DateUtil.date(getEndDate());
this.endDate = DateUtil.date(getEndTime());
}
}
......@@ -347,10 +347,10 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
setType(crosstownTypeEnum);
}});
VehicleItemDTO vehicleItemDTO = (VehicleItemDTO) orderItemBiz.selectOne(new OrderItem(){{
VehicleItemDTO vehicleItemDTO = BeanUtil.toBean(orderItemBiz.selectOne(new OrderItem(){{
setType(ItemTypeEnum.VEHICLE_MODEL.getCode());
setOrderId(orderMQDTO.getId());
}});
}}), VehicleItemDTO.class);
if(null == crosstown) {
throw new BaseException(ResultCode.PARAM_ILLEGAL_CODE, Sets.newSet(StrUtil.format("退款第一部分押金失败,获取不了还车/定损记录,订单号:{}, crosstownTypeEnum: {}", orderMQDTO.getId(), crosstownTypeEnum)));
......@@ -482,12 +482,18 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
private void handleCrosstownDetail(OrderVehicleCrosstown crosstown, OrderAccountDetail oad, CancelStartedVO csv) {
try{
if(null != crosstown.getViolateDetail()) {
DedDetailDTO vio = JSONUtil.toBean(crosstown.getViolateDetail(), DedDetailDTO.class);
//修改代码
List<DedDetailDTO> vios = JSONUtil.toList(JSONUtil.parseArray(crosstown.getViolateDetail()), DedDetailDTO.class);
//DedDetailDTO vio = JSONUtil.toBean(crosstown.getViolateDetail(), DedDetailDTO.class);
for(DedDetailDTO vio : vios) {
if(OrderViolateEnum.BEFORE.getCode().equals(vio.getType())) {
handleViolateDetail(DeductionTypeEnum.VIOLATE_ADVANCE, oad, vio, csv);
}else if(OrderViolateEnum.AFTER.getCode().equals(vio.getType())) {
handleViolateDetail(DeductionTypeEnum.VIOLATE_DELAY, oad, vio, csv);
}else if(OrderViolateEnum.CHANGE.getCode().equals(vio.getType())) {
handleViolateDetail(DeductionTypeEnum.VIOLATE_CHANGE_C, oad, vio, csv);
}
}
}
}catch (Exception e) {
......@@ -496,6 +502,7 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
}
private void handleViolateDetail(DeductionTypeEnum dte, OrderAccountDetail oad, DedDetailDTO vio, CancelStartedVO csv) {
Boolean flag = Boolean.FALSE;
for(OrderAccountDeduction deduction : oad.getDeductions()) {
if(dte.getCode().equals(deduction.getType())) {
deduction.setName(vio.getDeductions());
......@@ -505,9 +512,23 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
deduction.setAmount(vio.getCost());
//设置订单明细参数
csv.setViolateAmount(deduction.getAmount());
csv.setViolateDesc(deduction.getName());
csv.setViolateAmount(csv.getViolateAmount().add(diff));
csv.setViolateDesc(csv.getViolateDesc()+ deduction.getName());
flag = Boolean.TRUE;
break;
}
}
//如果没有修改,则添加
if(Boolean.FALSE.equals(flag)) {
OrderAccountDeduction oadNew = initDeduction(vio.getCost(), vio.getDeductions(), dte, OrderAccountDeduction.ORIGIN_DEPOSIT);
oad.getDeductions().add(oadNew);
//修改归还押金金额
oad.setDepositAmount(oad.getDepositAmount().subtract(oadNew.getAmount()));
//设置订单明细参数
csv.setViolateAmount(csv.getViolateAmount().add(oadNew.getAmount()));
csv.setViolateDesc(csv.getViolateDesc()+ oadNew.getName());
}
}
......
......@@ -55,7 +55,7 @@ public class OrderItemBiz extends BaseBiz<OrderItemMapper,OrderItem> {
//根据延期的天数算出 对应的日期价格
Date overStart = DateUtil.offsetDay(endDate, 1);
Date overEnd = DateUtil.offsetDay(endDate, overDays);
List<VehicleModelCalendarPriceDTO> overlist = vehicleFeign.findVehicleModelCalendarPriceByDate(overStart, overEnd, modelId, userId);
List<VehicleModelCalendarPriceDTO> overlist = vehicleFeign.findVehicleModelCalendarPriceByDate(overStart.getTime(), overEnd.getTime(), modelId, userId).getData();
for(VehicleModelCalendarPriceDTO vmcpd : overlist) {
overAmountList.add((VMCalendarPriceCostDTO) vmcpd);
......
......@@ -171,9 +171,9 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
OrderRentVehicleDetail orderRentVehicleDetail = orderRentVehicleBiz.selectById(baseOrder.getDetailId());
if (orderVehicleCrosstownDto.getType() == CrosstownTypeEnum.DEPARTURE.getCode()) {
boolean flag = getTodayTime(orderRentVehicleDetail.getStartTime());
// if (!flag) {
// return ObjectRestResponse.createFailedResult(3502, "今日不是交车日期");
// }
if (!flag) {
return ObjectRestResponse.createFailedResult(3502, "今日不是交车日期");
}
if (null == userDTO.getCompanyId() || !userDTO.getCompanyId().equals(orderRentVehicleDetail.getStartCompanyId())) {
return ObjectRestResponse.createFailedResult(3501, "无交车权限");
}
......
......@@ -245,10 +245,10 @@ public class OrderCalculateBiz {
}
public InProgressVO inProgressCalculate(BaseOrder baseOrder, Integer useDays) {
VehicleItemDTO vehicleItemDTO = (VehicleItemDTO) orderItemBiz.selectOne(new OrderItem(){{
VehicleItemDTO vehicleItemDTO = BeanUtil.toBean(orderItemBiz.selectOne(new OrderItem(){{
setType(ItemTypeEnum.VEHICLE_MODEL.getCode());
setOrderId(baseOrder.getId());
}});
}}), VehicleItemDTO.class);
Integer freeDays = (null == vehicleItemDTO.getCutNum())?0 :vehicleItemDTO.getCutNum();
return inProgressCalculate(baseOrder, vehicleItemDTO, freeDays, useDays, new OrderAccountDetail(), Boolean.FALSE);
}
......
......@@ -139,10 +139,10 @@ public class OrderCancelBiz {
setOrderId(baseOrder.getId());
}});
VehicleItemDTO vehicleItemDTO = (VehicleItemDTO) orderItemBiz.selectOne(new OrderItem(){{
VehicleItemDTO vehicleItemDTO = BeanUtil.toBean(orderItemBiz.selectOne(new OrderItem(){{
setType(ItemTypeEnum.VEHICLE_MODEL.getCode());
setOrderId(baseOrder.getId());
}});
}}), VehicleItemDTO.class);
//如果超过出发时间,不能取消订单
//根据时间处理goodsAmount
......
package com.xxfc.platform.order.rest;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface;
......@@ -93,10 +94,10 @@ public class OrderRefundController extends BaseController<OrderRefundBiz,OrderRe
Long timeLag = orderPageVO.getOrderRentVehicleDetail().getStartTime() - System.currentTimeMillis();
VehicleItemDTO vehicleItemDTO = (VehicleItemDTO) orderItemBiz.selectOne(new OrderItem(){{
VehicleItemDTO vehicleItemDTO = BeanUtil.toBean(orderItemBiz.selectOne(new OrderItem(){{
setType(ItemTypeEnum.VEHICLE_MODEL.getCode());
setOrderId(orderPageVO.getId());
}});
}}), VehicleItemDTO.class);
if(timeLag < 0 ) {
OrderAccountDetail oad = new OrderAccountDetail();
......
......@@ -238,11 +238,14 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
VehicleModel vehicleModel = vehicleFeign.get(detail.getModelId()).getData();
detail.initDate();
List<VehicleModelCalendarPriceDTO> vmcpds = vehicleFeign.findVehicleModelCalendarPriceByDate(detail.getStartDate(), detail.getEndDate(), detail.getModelId(), dto.getUserid());
List<VehicleModelCalendarPriceDTO> vmcpds = vehicleFeign.findVehicleModelCalendarPriceByDate(detail.getStartTime(), detail.getEndTime(), detail.getModelId(), dto.getUserid()).getData();
//设置Item
VehicleItemDTO vehicleOrderItem = (VehicleItemDTO) orderItemBiz.initOrderItem(vehicleModel.getPrice(), detail.getDayNum(), vehicleModel.getName(), vehicleModel.getId(), ItemTypeEnum.VEHICLE_MODEL, JSONUtil.parseArray(vmcpds).toString());
VehicleItemDTO vehicleOrderItem = BeanUtil.toBean(
orderItemBiz.initOrderItem(vehicleModel.getPrice(), detail.getDayNum(), vehicleModel.getName()
, vehicleModel.getId(), ItemTypeEnum.VEHICLE_MODEL, JSONUtil.parseArray(vmcpds).toString())
, VehicleItemDTO.class);
OrderItem driverOrderItem = orderItemBiz.initOrderItem(DRIVER_PRICE, detail.getDayNum(), "平台司机", null, ItemTypeEnum.DRIVER);
OrderItem damageSafeOrderItem = orderItemBiz.initOrderItem(DAMAGE_SAFE, detail.getDayNum(), "免赔费用", null, ItemTypeEnum.DAMAGE_SAFE);
......
......@@ -5,7 +5,7 @@ import com.xxfc.platform.universal.biz.UserMessage;
import java.util.Map;
/**
* 用户认证
* 用户认证接口 (使用@Primary实现的优先级提升优先级)
* @author Administrator
*/
public interface UserAuthentication {
......
......@@ -25,7 +25,7 @@ import java.util.Map;
*/
@Service
@Slf4j
@Primary
//@Primary
public class BJCYAuthentication implements UserAuthentication {
private final String host = "http://aliyunverifyidcard.haoservice.com";
private final String path = "/idcard/VerifyIdcardv2";
......@@ -39,7 +39,8 @@ public class BJCYAuthentication implements UserAuthentication {
private final String ret="error_code";
@Override
public boolean certificate(UserMessage message) {
Map<String, String> headers = new HashMap<String, String>();
return true;
/*Map<String, String> headers = new HashMap<String, String>();
headers.put(tokenHead, token);
Map<String, String> querys = new HashMap<String, String>();
querys.put(cardNo, message.getIdNumber());
......@@ -66,7 +67,7 @@ public class BJCYAuthentication implements UserAuthentication {
} catch (Exception e) {
e.printStackTrace();
}
return false;
return false;*/
}
}
......
......@@ -12,6 +12,7 @@ import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.util.EntityUtils;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import java.util.HashMap;
......@@ -24,6 +25,7 @@ import java.util.Map;
*/
@Service
@Slf4j
@Primary
public class XCFQAuthentication implements UserAuthentication {
private String cAppcode="acea1c8811f748b3a65815f11db357c4";
......@@ -33,10 +35,8 @@ public class XCFQAuthentication implements UserAuthentication {
*/
private String cHost = "https://idcert.market.alicloudapi.com";
private String cPath = "/idcard";
private String cMethod = "GET";
//响应:认证错误码字段名
......@@ -45,7 +45,6 @@ public class XCFQAuthentication implements UserAuthentication {
//响应:认证通过码
private String certifResultCode = "01";
//请求:身份证号字段名
private String idCardName = "idCard";
......@@ -55,11 +54,9 @@ public class XCFQAuthentication implements UserAuthentication {
@Override
public boolean certificate(UserMessage message) {
//map携带身份证和姓名进行认证
Map<String, String> querys = new HashMap<>();
querys.put(idCardName, message.getIdNumber());
querys.put(cName, message.getName());
Map<String, String> headers = new HashMap<String, String>();
headers.put("Authorization", "APPCODE " + cAppcode);
try {
......
......@@ -27,4 +27,6 @@ public class Festival {
private String name;
@Column(name = "crt_time")
private Date crtTime;
@Column(name = "is_del")
private Integer isDel;
}
......@@ -12,12 +12,10 @@ import com.xxfc.platform.vehicle.pojo.vo.AccompanyingItemVo;
import com.xxfc.platform.vehicle.pojo.vo.BranComanyLeaderVo;
import com.xxfc.platform.vehicle.pojo.vo.BranchCompanyListVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
/**
* Created by ace on 2017/9/15.
......@@ -190,9 +188,9 @@ public interface VehicleFeign {
* @param userId
* @return
*/
@GetMapping("/vehicle_model/calendar_price/app/unauth/price")
List<VehicleModelCalendarPriceDTO> findVehicleModelCalendarPriceByDate(@RequestParam(value = "startDate") Date startDate,
@RequestParam(value = "endDate") Date endDate,
@GetMapping(value = "/vehicle_model/calendar_price/app/unauth/price",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
ObjectRestResponse<List<VehicleModelCalendarPriceDTO>> findVehicleModelCalendarPriceByDate(@RequestParam(value = "startDate") Long startDate,
@RequestParam(value = "endDate") Long endDate,
@RequestParam(value = "vehicleModelId") Integer vehicleModelId,
@RequestParam(value = "userId") Integer userId);
......
......@@ -20,6 +20,7 @@ public class BranchCompanyListDTO {
*/
@ApiModelProperty("分公司名称")
private String name;
private String companyName;
/**
* 公司封面
*/
......
package com.xxfc.platform.vehicle.pojo.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
......
......@@ -20,6 +20,7 @@ public class BranchCompanyListVO {
*/
@ApiModelProperty("分公司名称")
private String name;
private String companyName;
/**
* 公司封面
*/
......
......@@ -3,6 +3,7 @@ package com.xxfc.platform.vehicle.biz;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.xxfc.platform.vehicle.entity.Festival;
import com.xxfc.platform.vehicle.mapper.FestivalMapper;
import io.swagger.models.auth.In;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -30,11 +31,11 @@ public class FestivalBiz extends BaseBiz<FestivalMapper,Festival> {
}
}
public void deleteById(Integer festivalId){
/* public void deleteById(Integer festivalId){
Festival festival = new Festival();
festival.setId(festivalId);
mapper.deleteByPrimaryKey(festival);
}
}*/
public Map<Integer, Festival> findFestivalsByIds(List<Integer> festivalIds) {
Map<Integer,Festival> festivalMap = new HashMap<>(20);
......@@ -44,4 +45,12 @@ public class FestivalBiz extends BaseBiz<FestivalMapper,Festival> {
}
return festivalMap;
}
@Override
public void deleteById(Object id) {
Festival festival = new Festival();
festival.setId((Integer) id);
festival.setIsDel(1);
mapper.updateByPrimaryKey(festival);
}
}
......@@ -317,6 +317,8 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
return RestResponse.codeAndMessage(objectRestResponse.getStatus(), objectRestResponse.getMessage());
}
} else {
continue;
}
}
......
......@@ -197,51 +197,6 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
}
}
vehicleBookRecordQueryVo.setCompanyIds(companyList);
if (vehicleBookRecordQueryVo.getStatus() != null && vehicleBookRecordQueryVo.getStatus() == 3) { //待出行
vehicleBookRecordQueryVo.setStatus(2);
Query query = new Query(vehicleBookRecordQueryVo);
List<VehicleBookRecordVo> list = mapper.getBookRecordInfo(query.getSuper());
removeStatus3(list);
PageInfo<VehicleBookRecordVo> vehicleBookRecordVoPageInfo = new PageInfo<>(list);
getupKeeps(vehicleBookRecordVoPageInfo.getList());
PageDataVO<VehicleBookRecordVo> vehicleBookRecordVoPageDataVO = PageDataVO.pageInfo(vehicleBookRecordVoPageInfo);
vehicleBookRecordVoPageDataVO.setPageNum(pageNo);
vehicleBookRecordVoPageDataVO.setPageSize(pageSize);
vehicleBookRecordVoPageDataVO.setTotalCount((long) vehicleBookRecordVoPageInfo.getList().size());
vehicleBookRecordVoPageDataVO.setTotalPage((vehicleBookRecordVoPageInfo.getList().size() + pageSize - 1) / pageSize);
vehicleBookRecordVoPageDataVO.setData(getData(vehicleBookRecordVoPageInfo.getList(), pageNo, pageSize));
return RestResponse.suc(vehicleBookRecordVoPageDataVO);
}
if (vehicleBookRecordQueryVo.getStatus() != null && vehicleBookRecordQueryVo.getStatus() == 5) { //出行中
vehicleBookRecordQueryVo.setStatus(2);
Query query = new Query(vehicleBookRecordQueryVo);
List<VehicleBookRecordVo> list = mapper.getBookRecordInfo(query.getSuper());
removeStatus5(list);
PageInfo<VehicleBookRecordVo> vehicleBookRecordVoPageInfo = new PageInfo<>(list);
getupKeeps(vehicleBookRecordVoPageInfo.getList());
PageDataVO<VehicleBookRecordVo> vehicleBookRecordVoPageDataVO = PageDataVO.pageInfo(vehicleBookRecordVoPageInfo);
vehicleBookRecordVoPageDataVO.setPageNum(pageNo);
vehicleBookRecordVoPageDataVO.setPageSize(pageSize);
vehicleBookRecordVoPageDataVO.setTotalCount((long) vehicleBookRecordVoPageInfo.getList().size());
vehicleBookRecordVoPageDataVO.setTotalPage((vehicleBookRecordVoPageInfo.getList().size() + pageSize - 1) / pageSize);
vehicleBookRecordVoPageDataVO.setData(getData(vehicleBookRecordVoPageInfo.getList(), pageNo, pageSize));
return RestResponse.suc(vehicleBookRecordVoPageDataVO);
}
if (vehicleBookRecordQueryVo.getStatus() != null && vehicleBookRecordQueryVo.getStatus() == 7) { //已完成
vehicleBookRecordQueryVo.setStatus(2);
Query query = new Query(vehicleBookRecordQueryVo);
List<VehicleBookRecordVo> list = mapper.getBookRecordInfo(query.getSuper());
removeStatus7(list);
PageInfo<VehicleBookRecordVo> vehicleBookRecordVoPageInfo = new PageInfo<>(list);
getupKeeps(vehicleBookRecordVoPageInfo.getList());
PageDataVO<VehicleBookRecordVo> vehicleBookRecordVoPageDataVO = PageDataVO.pageInfo(vehicleBookRecordVoPageInfo);
vehicleBookRecordVoPageDataVO.setPageNum(pageNo);
vehicleBookRecordVoPageDataVO.setPageSize(pageSize);
vehicleBookRecordVoPageDataVO.setTotalCount((long) vehicleBookRecordVoPageInfo.getList().size());
vehicleBookRecordVoPageDataVO.setTotalPage((vehicleBookRecordVoPageInfo.getList().size() + pageSize - 1) / pageSize);
vehicleBookRecordVoPageDataVO.setData(getData(vehicleBookRecordVoPageInfo.getList(), pageNo, pageSize));
return RestResponse.suc(vehicleBookRecordVoPageDataVO);
}
Query query = new Query(vehicleBookRecordQueryVo);
PageDataVO<VehicleBookRecordVo> pageDataVO = PageDataVO.pageInfo(query, () -> mapper.getBookRecordInfo(query.getSuper()));
getupKeeps(pageDataVO.getData());
......@@ -261,47 +216,6 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
}
}
}
//筛选未出车的记录
public void removeStatus3(List<VehicleBookRecordVo> list) {
if (list != null && list.size() > 0) {
Iterator<VehicleBookRecordVo> iterator = list.iterator();
while (iterator.hasNext()) {
VehicleBookRecordVo vehicleBookRecordVo = iterator.next();
if (vehicleBookRecordVo.getVehicleDepartureLogVo() != null) {
iterator.remove();
}
vehicleBookRecordVo.setState(3);
}
}
}
//筛选已出车未还车记录
public void removeStatus5(List<VehicleBookRecordVo> list) {
if (list != null && list.size() > 0) {
Iterator<VehicleBookRecordVo> iterator = list.iterator();
while (iterator.hasNext()) {
VehicleBookRecordVo vehicleBookRecordVo = iterator.next();
if (vehicleBookRecordVo.getVehicleDepartureLogVo() == null || (vehicleBookRecordVo.getVehicleDepartureLogVo() != null && vehicleBookRecordVo.getVehicleDepartureLogVo().getState() ==1)) {
iterator.remove();
}
vehicleBookRecordVo.setState(5);
}
}
}
//筛选已完成记录
public void removeStatus7(List<VehicleBookRecordVo> list) {
if (list != null && list.size() > 0) {
Iterator<VehicleBookRecordVo> iterator = list.iterator();
while (iterator.hasNext()) {
VehicleBookRecordVo vehicleBookRecordVo = iterator.next();
if (vehicleBookRecordVo.getVehicleDepartureLogVo() == null || (vehicleBookRecordVo.getVehicleDepartureLogVo() != null && vehicleBookRecordVo.getVehicleDepartureLogVo().getState() !=1)) {
iterator.remove();
}
vehicleBookRecordVo.setState(5);
}
}
}
/**
* 获取随身物品
*/
......
package com.xxfc.platform.vehicle.biz;
import cn.hutool.core.map.MapUtil;
import com.github.wxiaoqi.security.admin.entity.BaseUserMember;
import com.github.wxiaoqi.security.admin.entity.BaseUserMemberLevel;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
......@@ -132,12 +133,12 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
for (VehicleModelDTO vehicleModelDTO : vehicleModelDTOS) {
vehicleModelDayPriceVo = new VehicleModelDayPriceVo();
BeanUtils.copyProperties(vehicleModelDTO, vehicleModelDayPriceVo);
boolean isNullOfVehicleModelPrice = vehicleModelCalendarPriceMap == null ? true : vehicleModelCalendarPriceMap.get(vehicleModelDTO.getVehicleModelId()) == null;
boolean isNullOfVehicleModelPrice = MapUtil.isEmpty(vehicleModelCalendarPriceMap) ? true : vehicleModelCalendarPriceMap.get(vehicleModelDTO.getVehicleModelId()) == null;
Double multiple = isNullOfVehicleModelPrice ? null : vehicleModelCalendarPriceMap.get(vehicleModelDTO.getVehicleModelId()).getMultiple();
vehicleModelDayPriceVo.setMultiple(multiple);
BigDecimal aPrice = isNullOfVehicleModelPrice ? null : vehicleModelCalendarPriceMap.get(vehicleModelDTO.getVehicleModelId()).getPrice();
BigDecimal aPrice = isNullOfVehicleModelPrice ? BigDecimal.ZERO : vehicleModelCalendarPriceMap.get(vehicleModelDTO.getVehicleModelId()).getPrice();
vehicleModelDayPriceVo.setPrice(aPrice);
Integer level = isNullOfVehicleModelPrice?null:vehicleModelCalendarPriceMap.get(vehicleModelDTO.getVehicleModelId()).getLevel();
Integer level = isNullOfVehicleModelPrice? null:vehicleModelCalendarPriceMap.get(vehicleModelDTO.getVehicleModelId()).getLevel();
vehicleModelDayPriceVo.setLevel(level);
vehicleModelDayPriceVos.add(vehicleModelDayPriceVo);
}
......@@ -267,7 +268,7 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
Map<String, Object> price_freeDays_map = null;
Date current_date = DateUtils.localDateToDate(final_startLocalDate);
vehicleModelCalendarPriceDTO.setDate(current_date);
if (calendarPriceMap != null && !calendarPriceMap.isEmpty()) {
if (MapUtil.isNotEmpty(calendarPriceMap)) {
VehicleModelCalendarPrice vehicleModelCalendarPrice = calendarPriceMap.get(current_date);
if (Objects.isNull(vehicleModelCalendarPrice)) {
price_freeDays_map = transfromPriceAndFreeDaysByDate(festivalDayMap, current_date, vehicle_base_price, discount);
......@@ -294,7 +295,7 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
} else {
price_freeDays_map = transfromPriceAndFreeDaysByDate(festivalDayMap, current_date, vehicle_base_price, discount);
}
if (price_freeDays_map != null && !price_freeDays_map.isEmpty()) {
if (MapUtil.isNotEmpty(price_freeDays_map)) {
vehicle_price = (BigDecimal) price_freeDays_map.get(PRICE_VAL);
free_days = (Integer) price_freeDays_map.get(DAYS_VAL);
no_discount_price = (BigDecimal) price_freeDays_map.get(BASE_PRICE_VAL);
......@@ -322,7 +323,7 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
Map<String, Object> vehicle_price_days_map = new HashMap<>(3);
Integer free_days = DEFAULT_FREE_DAYS;
vehicle_price_days_map.put(BASE_PRICE_VAL,vehicle_price);
if (festivalDayMap != null && !festivalDayMap.isEmpty()) {
if (MapUtil.isNotEmpty(festivalDayMap)) {
VehicleModelHolidayPriceDTO vehicleModelHolidayPriceDTO = festivalDayMap.get(current_date);
if (Objects.nonNull(vehicleModelHolidayPriceDTO)) {
vehicle_price = vehicle_price.multiply(new BigDecimal(vehicleModelHolidayPriceDTO.getMultiple().doubleValue()));
......@@ -412,7 +413,6 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
}
public static void main(String[] args) {
AtomicReference<Date> start = new AtomicReference<>(Date.from(LocalDate.parse("2019-10-03").atStartOfDay(ZoneId.systemDefault()).toInstant()));
AtomicReference<Date> end = new AtomicReference<>(Date.from(LocalDate.parse("2019-10-29").atStartOfDay(ZoneId.systemDefault()).toInstant()));
......
......@@ -24,9 +24,7 @@ import java.time.LocalDate;
import java.time.ZoneId;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @author libin
......@@ -56,7 +54,7 @@ public class VehicleModelHolidayPriceBiz extends BaseBiz<VehicleModelHolidayPric
while (startLocaldate.isBefore(endLocaldate) || startLocaldate.isEqual(endLocaldate)){
vehicleModelHolidayPrice = new VehicleModelHolidayPrice();
BeanUtils.copyProperties(vehicleModelHolidayPriceSaveDTO, vehicleModelHolidayPrice);
Date date = DateUtils.localDateToDate(startLocaldate.atStartOfDay(ZoneId.systemDefault()).toLocalDate());
Date date = DateUtils.localDateToDate(startLocaldate);
vehicleModelHolidayPrice.setFestivalDay(date);
vehicleModelHolidayPriceList.add(vehicleModelHolidayPrice);
startLocaldate = startLocaldate.plusDays(1);
......@@ -69,8 +67,12 @@ public class VehicleModelHolidayPriceBiz extends BaseBiz<VehicleModelHolidayPric
for (VehicleModelHolidayPrice modelHolidayPrice : vehicleModelHolidayPriceList) {
modelHolidayPrice.setUpdUserId(userId);
modelHolidayPrice.setUpdTime(new Date());
mapper.updateByExample(modelHolidayPrice, example);
mapper.updateByExampleSelective(modelHolidayPrice, example);
}
Festival festival = new Festival();
festival.setName(vehicleModelHolidayPriceSaveDTO.getFestival());
festival.setId(vehicleModelHolidayPriceSaveDTO.getId());
festivalBiz.add(festival);
} else {
Festival festival = new Festival();
festival.setName(vehicleModelHolidayPriceSaveDTO.getFestival());
......@@ -87,19 +89,15 @@ public class VehicleModelHolidayPriceBiz extends BaseBiz<VehicleModelHolidayPric
/**
* @param multiple 倍数
* @param freeDays 免费天数
* @param configDate 设置的日期*月份
*/
public void updateVehicleModelHolidayPrice(Double multiple, Integer freeDays, Date configDate) {
public void updateVehicleModelHolidayPrice(Double multiple, Integer freeDays) {
VehicleModelHolidayPrice vehicleModelHolidayPrice = new VehicleModelHolidayPrice();
vehicleModelHolidayPrice.setMultiple(multiple);
vehicleModelHolidayPrice.setFreeDays(freeDays);
Example example = new Example(VehicleModelHolidayPrice.class);
Example.Criteria criteria = example.createCriteria();
setCondtionDate(configDate, null, criteria);
int effect = mapper.updateByExampleSelective(vehicleModelHolidayPrice, example);
if (effect < 1) {
throw new BaseException("车型节假日更新失败");
}
criteria.andEqualTo("isDel",0);
mapper.updateByExampleSelective(vehicleModelHolidayPrice,example);
}
/**
......@@ -120,6 +118,7 @@ public class VehicleModelHolidayPriceBiz extends BaseBiz<VehicleModelHolidayPric
if (StringUtils.isNotEmpty(vehicleModelHolidayPriceFindDTO.getFestival()) && vehicleModelHolidayPriceFindDTO.getFestival().trim().length() > 0) {
criteria.andLike("festival", String.format("%%%s%%", vehicleModelHolidayPriceFindDTO.getFestival()));
}
criteria.andEqualTo("isDel",0);
List<VehicleModelHolidayPrice> holidayPrices = mapper.selectByExample(example);
if (CollectionUtils.isEmpty(holidayPrices)) {
return vehicleModelHolidayPriceVos;
......@@ -137,6 +136,7 @@ public class VehicleModelHolidayPriceBiz extends BaseBiz<VehicleModelHolidayPric
Date endDate = listMap.get(festivalId).stream().map(VehicleModelHolidayPrice::getFestivalDay).max(Date::compareTo).get();
vehicleModelHolidayPriceVo.setStartDate(startDate);
vehicleModelHolidayPriceVo.setEndDate(endDate);
vehicleModelHolidayPriceVo.setId(Long.valueOf(festivalId));
vehicleModelHolidayPriceVos.add(vehicleModelHolidayPriceVo);
}
return vehicleModelHolidayPriceVos;
......@@ -164,7 +164,7 @@ public class VehicleModelHolidayPriceBiz extends BaseBiz<VehicleModelHolidayPric
for (VehicleModelHolidayPrice modelHolidayPrice : modelHolidayPrices) {
vehicleModelHolidayPriceDTO = new VehicleModelHolidayPriceDTO();
BeanUtils.copyProperties(modelHolidayPrice, vehicleModelHolidayPriceDTO);
vehicleModelHolidayPriceDTO.setFestival(festivalMap==null?"":festivalMap.get(modelHolidayPrice.getFestivalId()).getName());
vehicleModelHolidayPriceDTO.setFestival((festivalMap==null || null == festivalMap.get(modelHolidayPrice.getFestivalId()))?"":festivalMap.get(modelHolidayPrice.getFestivalId()).getName());
vehicleModelHolidayPriceDTOS.add(vehicleModelHolidayPriceDTO);
}
return vehicleModelHolidayPriceDTOS;
......@@ -192,6 +192,16 @@ public class VehicleModelHolidayPriceBiz extends BaseBiz<VehicleModelHolidayPric
return modelHolidayPriceSaveDTO;
}
public void deleteById(Integer festivalId){
Example example = new Example(VehicleModelHolidayPrice.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("festivalId",festivalId);
VehicleModelHolidayPrice vehicleModelHolidayPrice = new VehicleModelHolidayPrice();
vehicleModelHolidayPrice.setIsDel(1);
mapper.updateByExampleSelective(vehicleModelHolidayPrice,example);
festivalBiz.deleteById(festivalId);
}
/**
* 设置查询条件日期
*
......
......@@ -11,4 +11,5 @@ import tk.mybatis.mapper.common.Mapper;
* @data 2019/10/14 17:32
*/
public interface VehicleModelHolidayPriceMapper extends Mapper<VehicleModelHolidayPrice>, InsertListMapper<VehicleModelHolidayPrice> {
}
package com.xxfc.platform.vehicle.rest;
import cn.hutool.core.date.DateUtil;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.exception.BaseException;
......@@ -12,6 +13,7 @@ import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDate;
......@@ -51,13 +53,16 @@ public class VehicleModelCalendarPriceController {
return ObjectRestResponse.succ(vehicleModelCalendarPriceVos);
}
@GetMapping("/price")
public List<VehicleModelCalendarPriceDTO> findVehicleModelCalendarPriceByDate(@RequestParam(value = "startDate") Date startDate,
@RequestParam(value = "endDate") Date endDate,
@GetMapping(value = "/price",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ObjectRestResponse<List<VehicleModelCalendarPriceDTO>> findVehicleModelCalendarPriceByDate(@RequestParam(value = "startDate") Long startDate,
@RequestParam(value = "endDate") Long endDate,
@RequestParam(value = "vehicleModelId") Integer vehicleModelId,
@RequestParam(value = "userId") Integer userId) {
startDate = Date.from(startDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate().atStartOfDay(ZoneId.systemDefault()).toInstant());
endDate = Date.from(endDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate().atStartOfDay(ZoneId.systemDefault()).toInstant());
return vehicleModelCalendarPriceBiz.findVehicleModelCalendarPriceByDateAndVehilceIdAndUserId(startDate, endDate, vehicleModelId, userId);
Date startDateDay = DateUtil.beginOfDay(DateUtil.date(startDate));
//Date.from(startDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate().atStartOfDay(ZoneId.systemDefault()).toInstant());
Date endDateDay = DateUtil.beginOfDay(DateUtil.date(endDate));
//Date.from(endDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate().atStartOfDay(ZoneId.systemDefault()).toInstant());
return ObjectRestResponse.succ(vehicleModelCalendarPriceBiz.findVehicleModelCalendarPriceByDateAndVehilceIdAndUserId(startDateDay, endDateDay, vehicleModelId, userId));
}
}
......@@ -35,15 +35,27 @@ public class VehicleModelHolidayPriceAdminController {
}
@GetMapping("/{id}")
public ObjectRestResponse<VehicleModelHolidayPriceSaveDTO> findVehicleModelHolidayPrice(@PathVariable(value = "id") Long id){
public ObjectRestResponse<VehicleModelHolidayPriceSaveDTO> findVehicleModelHolidayPrice(@PathVariable(value = "id") Long id) {
VehicleModelHolidayPriceSaveDTO vehicleModelHolidayPriceSaveDTO = vehicleModelHolidayPriceBiz.findVehicleModelHolidayPriceFestivalId(id);
return ObjectRestResponse.succ(vehicleModelHolidayPriceSaveDTO);
}
@ApiOperation("节假日页查询")
@PostMapping("/page")
public ObjectRestResponse<List<VehicleModelHolidayPriceVo>> listVehicleModelHolidayPrice(@RequestBody VehicleModelHolidayPriceFindDTO vehicleModelHolidayPriceFindDTO){
public ObjectRestResponse<List<VehicleModelHolidayPriceVo>> listVehicleModelHolidayPrice(@RequestBody VehicleModelHolidayPriceFindDTO vehicleModelHolidayPriceFindDTO) {
List<VehicleModelHolidayPriceVo> priceVoPageDataVO = vehicleModelHolidayPriceBiz.listVehicleModelHolidayPrice(vehicleModelHolidayPriceFindDTO);
return ObjectRestResponse.succ(priceVoPageDataVO);
}
@DeleteMapping("/{id}")
public ObjectRestResponse<Void> delete(@PathVariable(value = "id") Integer id) {
vehicleModelHolidayPriceBiz.deleteById(id);
return ObjectRestResponse.succ();
}
@PutMapping("/update")
public ObjectRestResponse<Void> update(@RequestParam(value = "multiple",required = false) Double multiple, @RequestParam(value = "freeDays",required = false) Integer freeDays) {
vehicleModelHolidayPriceBiz.updateVehicleModelHolidayPrice(multiple, freeDays);
return ObjectRestResponse.succ();
}
}
......@@ -73,6 +73,7 @@
cb.town_name AS `townName`,
bc.addr_detail AS `address`,
bc.NAME AS `name`,
cb.name AS `companyName`,
cb.cover,
bc.leader,
bc.leader_contact_info AS `leaderContactInfo`,
......
......@@ -490,15 +490,33 @@
#{id}
</foreach>)
</if>
<if test="status != null and status != 0 and status != -1 and status != -2">
<if test="status != null and status != 0 and status != -1 and status != -2 and status != 3 and status != 5 and status != 7">
and v1.status = #{status}
</if>
<if test="status != null and status == 3 ">
and v4.id is null and v1.status = 2
</if>
<if test="status != null and status == 5 ">
and v4.id is not null and v1.status = 2 and v4.state = 0
</if>
<if test="status != null and status == 7 ">
and v4.id is not null and v1.status = 2 and v4.state = 1
</if>
<if test="status != null and status == 0 ">
and v4.state = 0
</if>
<if test="status != null and status == -1 ">
and v4.state = 1
</if>
<if test="status != null and status == 3 ">
and v4.id is null and v1.status = 2
</if>
<if test="status != null and status == 5 ">
and v4.id is not null and v1.status = 2 and v4.state = 0
</if>
<if test="status != null and status == 7 ">
and v4.id is not null and v1.status = 2 and v4.state = 1
</if>
<if test="code != null">
and v3.code = #{code}
</if>
......
......@@ -41,11 +41,10 @@
SELECT r.* FROM (
select DISTINCT v.`id`,
v.`code`,
v.`status`,
(CASE WHEN #{status} != null THEN #{status}
ELSE v.status END) status ,
v.number_plate,
v.brand,
-- IFNULL(v.park_branch_company_id,v.expect_destination_branch_company_id) AS subordinate_branch,
-- IFNULL(bc.name,bc1.name) AS subBranchName,
v.park_branch_company_id,
bc.name as parkBranchCompanyName,
v.expect_destination_branch_company_id,
......@@ -80,15 +79,13 @@
left join
vehicle_book_info vbi on v.`id` = vbi.vehicle
</if>
-- LEFT JOIN branch_company bc ON v.park_branch_company_id = bc.id
-- LEFT JOIN branch_company bc1 ON v.expect_destination_branch_company_id = bc1.id
-- 停车分公司
LEFT JOIN branch_company bc ON v.park_branch_company_id = bc.id
-- 目的地分公司
LEFT JOIN branch_company bc1 ON v.expect_destination_branch_company_id = bc1.id
-- 所属分公司
LEFT JOIN branch_company bc2 ON v.subordinate_branch = bc2.id
LEFT JOIN vehicle_book_record v2 on v2.vehicle_id = v.id
LEFT JOIN vehicle_book_record v2 on v2.id = (select id from vehicle_book_record where vehicle_id = v.id order by update_time DESC LIMIT 1)
LEFT JOIN vehicle_departure_log v3 on v2.id = v3.book_record_id
where
v.is_del=0
......@@ -116,15 +113,15 @@
<if test="insuranceCompany !=null">
and v.insurance_company = #{insuranceCompany}
</if>
<if test="belongToName !=null">
and v.belong_to_name = #{belongToName}
<if test="belongToName !=null and belongToName != ''">
and v.belong_to_name like concat('%',#{belongToName},'%')
</if>
<if test="vin !=null and vin != ''">
and v.vin = #{vin}
</if>
<!-- <if test="subordinateBranch !=null">-->
<!-- and v.subordinate_branch = #{subordinateBranch}-->
<!-- </if>-->
<!-- <if test="subordinateBranch !=null">-->
<!-- and v.subordinate_branch = #{subordinateBranch}-->
<!-- </if>-->
<if test="code !=null">
and v.code = #{code}
</if>
......@@ -174,7 +171,6 @@
and bc.zone_id=#{zoneId}
</if>
</if>
order by v.code
) r ORDER BY r.parkBranchCompanyName
</select>
......@@ -183,7 +179,8 @@
SELECT r.* FROM (
select DISTINCT v.`id`,
v.`code`,
v.`status`,
(CASE WHEN #{status} != null THEN #{status}
ELSE v.status END) status ,
v.number_plate,
v.brand,
-- IFNULL(v.park_branch_company_id,v.expect_destination_branch_company_id) AS subordinate_branch,
......@@ -228,6 +225,8 @@
LEFT JOIN branch_company bc1 ON v.expect_destination_branch_company_id = bc1.id
-- 所属分公司
LEFT JOIN branch_company bc2 ON v.subordinate_branch = bc2.id
LEFT JOIN vehicle_book_record v2 on v2.id = (select id from vehicle_book_record where vehicle_id = v.id order by update_time DESC LIMIT 1)
LEFT JOIN vehicle_departure_log v3 on v2.id = v3.book_record_id
where
v.is_del=0
<if test="companyList != null">
......@@ -277,21 +276,27 @@
<if test="insuranceCompany !=null">
and v.insurance_company = #{insuranceCompany}
</if>
<if test="belongToName !=null">
and v.belong_to_name = #{belongToName}
<if test="belongToName !=null and belongToName != ''">
and v.belong_to_name like concat('%',#{belongToName},'%')
</if>
<if test="vin !=null and vin != ''">
and v.vin = #{vin}
</if>
<!-- <if test="subordinateBranch !=null">-->
<!-- and v.subordinate_branch = #{subordinateBranch}-->
<!-- </if>-->
<!-- <if test="subordinateBranch !=null">-->
<!-- and v.subordinate_branch = #{subordinateBranch}-->
<!-- </if>-->
<if test="code !=null">
and v.code = #{code}
</if>
<if test="status !=null">
<if test="status !=null and status != 6 and status != 7">
and v.status = #{status}
</if>
<if test="status !=null and status == 6">
and v3.id is not NULL and v2.book_type = 3 and v3.state = 0
</if>
<if test="status !=null and status == 7">
and v3.id is not NULL and v2.book_type = 6 and v3.state = 0
</if>
<if test="numberPlate !=null and numberPlate != ''">
and v.number_plate like concat('%',#{numberPlate},'%')
</if>
......@@ -329,7 +334,6 @@
and bc.zone_id=#{zoneId}
</if>
</if>
order by v.code
) r ORDER BY r.parkBranchCompanyName
</select>
......
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