This commit is contained in:
parent
6cb78e0749
commit
e88ab56c07
|
|
@ -15,7 +15,6 @@ import com.bonus.material.contract.service.BmContractService;
|
|||
import com.bonus.material.device.domain.vo.DevInfoVo;
|
||||
import com.bonus.material.lease.domain.LeaseRepairRecord;
|
||||
import com.bonus.material.lease.mapper.LeaseRepairRecordMapper;
|
||||
import com.bonus.material.order.domain.OrderDetailCostReliefDto;
|
||||
import com.bonus.material.order.domain.OrderDetailDto;
|
||||
import com.bonus.material.order.domain.OrderInfoDto;
|
||||
import com.bonus.material.order.mapper.OrderMapper;
|
||||
|
|
|
|||
|
|
@ -1,27 +0,0 @@
|
|||
package com.bonus.material.order.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class OrderDetailCostReliefDto {
|
||||
|
||||
@ApiModelProperty(value = "主键id")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "订单id")
|
||||
private Integer orderId;
|
||||
|
||||
@ApiModelProperty(value = "设备id")
|
||||
private Integer maId;
|
||||
|
||||
@ApiModelProperty(value = "减免开始时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private String reliefStartTime;
|
||||
|
||||
@ApiModelProperty(value = "减免结束时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private String reliefEndTime;
|
||||
|
||||
}
|
||||
|
|
@ -122,4 +122,12 @@ public class OrderDetailDto {
|
|||
@ApiModelProperty(value = "实际天数")
|
||||
private Integer dateDays;
|
||||
|
||||
@ApiModelProperty(value = "减免开始时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private String reliefStartTime;
|
||||
|
||||
@ApiModelProperty(value = "减免结束时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private String reliefEndTime;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,8 +93,6 @@ public class OrderInfoDto {
|
|||
|
||||
private List<OrderDetailDto> detailsList;
|
||||
|
||||
private List<OrderDetailCostReliefDto> reliefList;
|
||||
|
||||
@ApiModelProperty(value = "承租方公司名称")
|
||||
private String companyName;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.bonus.material.order.mapper;
|
|||
|
||||
import com.bonus.material.device.domain.DevInfo;
|
||||
import com.bonus.material.lease.domain.LeaseRepairRecord;
|
||||
import com.bonus.material.order.domain.OrderDetailCostReliefDto;
|
||||
import com.bonus.material.order.domain.OrderDetailDto;
|
||||
import com.bonus.material.order.domain.OrderInfoDto;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
|
@ -40,9 +39,11 @@ public interface OrderMapper {
|
|||
|
||||
int updateOrder(LeaseRepairRecord leaseRepairRecord);
|
||||
|
||||
int deleteCostReliefs(@Param("orderId") Integer orderId);
|
||||
int updateOrder4Relief(OrderDetailDto dto);
|
||||
|
||||
int insertCostReliefs(@Param("list") List<OrderDetailCostReliefDto> reliefList);
|
||||
// int deleteCostReliefs(@Param("orderId") Integer orderId);
|
||||
//
|
||||
// int insertCostReliefs(@Param("list") List<OrderDetailCostReliefDto> reliefList);
|
||||
|
||||
OrderInfoDto getAgreementByOrderId(String orderId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.bonus.material.order.service;
|
||||
|
||||
import com.bonus.material.order.domain.OrderDetailCostReliefDto;
|
||||
import com.bonus.material.order.domain.OrderDetailDto;
|
||||
import com.bonus.material.order.domain.OrderInfoDto;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,11 +5,9 @@ import com.bonus.common.biz.enums.OrderStatusEnum;
|
|||
import com.bonus.common.core.utils.DateUtils;
|
||||
import com.bonus.common.core.utils.encryption.Sm4Utils;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import com.bonus.material.device.domain.DevInfo;
|
||||
import com.bonus.material.lease.domain.LeaseRepair;
|
||||
import com.bonus.material.lease.domain.LeaseRepairRecord;
|
||||
import com.bonus.material.lease.mapper.LeaseRepairRecordMapper;
|
||||
import com.bonus.material.order.domain.OrderDetailCostReliefDto;
|
||||
import com.bonus.material.order.domain.OrderDetailDto;
|
||||
import com.bonus.material.order.domain.OrderInfoDto;
|
||||
import com.bonus.material.order.mapper.OrderMapper;
|
||||
|
|
@ -17,7 +15,6 @@ import com.bonus.material.order.service.OrderService;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
|
@ -107,12 +104,21 @@ public class OrderServiceImpl implements OrderService {
|
|||
list.add(orderDetailDto);
|
||||
}
|
||||
BigDecimal totalRentalPrice = BigDecimal.ZERO;
|
||||
BigDecimal totalReliefPrice = BigDecimal.ZERO;
|
||||
for (OrderDetailDto orderDetailDto : list) {
|
||||
if (Objects.nonNull(orderDetailDto) && String.valueOf(OrderStatusEnum.ORDER_FINISHED.getStatus()).equals(orderDetailDto.getOrderStatus())) {
|
||||
Date preOutBoundTime = sdf.parse(orderDetailDto.getPreOutboundTime());
|
||||
Date rentOverTime = sdf.parse(orderDetailDto.getRentOverTime());
|
||||
long days = DateUtils.daysBetween(preOutBoundTime, rentOverTime) + 1;
|
||||
totalRentalPrice = totalRentalPrice.add(orderDetailDto.getDayLeasePrice().multiply(new BigDecimal(days)));
|
||||
if (Objects.nonNull(orderDetailDto.getPreOutboundTime()) && Objects.nonNull(orderDetailDto.getRentOverTime())) {
|
||||
Date preOutBoundTime = sdf.parse(orderDetailDto.getPreOutboundTime());
|
||||
Date rentOverTime = sdf.parse(orderDetailDto.getRentOverTime());
|
||||
long days = DateUtils.daysBetween(preOutBoundTime, rentOverTime) + 1;
|
||||
totalRentalPrice = totalRentalPrice.add(orderDetailDto.getDayLeasePrice().multiply(new BigDecimal(days)));
|
||||
}
|
||||
if (Objects.nonNull(orderDetailDto.getReliefStartTime()) && Objects.nonNull(orderDetailDto.getReliefEndTime())) {
|
||||
Date reliefStartTime = sdf.parse(orderDetailDto.getReliefStartTime());
|
||||
Date reliefEndTime = sdf.parse(orderDetailDto.getReliefEndTime());
|
||||
long reliefDays = DateUtils.daysBetween(reliefStartTime, reliefEndTime) + 1;
|
||||
totalReliefPrice = totalReliefPrice.add(orderDetailDto.getDayLeasePrice().multiply(new BigDecimal(reliefDays)));
|
||||
}
|
||||
}
|
||||
}
|
||||
dto.setTotalRentalPrice(totalRentalPrice);
|
||||
|
|
@ -155,7 +161,7 @@ public class OrderServiceImpl implements OrderService {
|
|||
}
|
||||
dto.setTotalRepairScrapLossPrice(totalRepairScrapLossPrice);
|
||||
}
|
||||
dto.setTotalRealPrice(BigDecimal.ZERO.add(totalRentalPrice).add(totalRepairScrapLossPrice));
|
||||
dto.setTotalRealPrice(BigDecimal.ZERO.add(totalRentalPrice).add(totalRepairScrapLossPrice).subtract(totalReliefPrice));
|
||||
}
|
||||
return orderInfoDtos;
|
||||
}
|
||||
|
|
@ -177,10 +183,11 @@ public class OrderServiceImpl implements OrderService {
|
|||
|
||||
@Override
|
||||
public Integer submitCostRelief(OrderInfoDto orderInfoDto) {
|
||||
List<OrderDetailCostReliefDto> list = orderInfoDto.getReliefList();
|
||||
List<OrderDetailDto> list = orderInfoDto.getDetailsList();
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
orderMapper.deleteCostReliefs(list.get(0).getOrderId());
|
||||
return orderMapper.insertCostReliefs(orderInfoDto.getReliefList());
|
||||
for (OrderDetailDto dto : list) {
|
||||
orderMapper.updateOrder4Relief(dto);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,6 +90,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</if>
|
||||
</update>
|
||||
|
||||
<update id="updateOrder4Relief">
|
||||
UPDATE
|
||||
ma_order_details
|
||||
set relief_start_time = #{reliefStartTime},
|
||||
relief_end_time = #{reliefEndTime},
|
||||
update_time = now()
|
||||
WHERE order_id = #{orderId} and ma_id = #{maId}
|
||||
</update>
|
||||
|
||||
<select id="getdeviceCount" resultType="com.bonus.material.device.domain.DevInfo">
|
||||
select device_count,device_name from ma_dev_info where ma_id = #{maId} and is_active = 1
|
||||
</select>
|
||||
|
|
@ -309,12 +318,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</delete>
|
||||
|
||||
<insert id="insertCostReliefs">
|
||||
insert into ma_order_details_relief(order_id, ma_id, relief_begin_time, relief_end_time, create_time)
|
||||
insert into ma_order_details_relief(order_id, ma_id, status, relief_begin_time, relief_end_time, create_time)
|
||||
values
|
||||
<foreach collection="list" item="item" index="index" separator=",">
|
||||
(
|
||||
#{item.orderId},
|
||||
#{item.maId},
|
||||
#{item.status},
|
||||
#{item.reliefStartTime},
|
||||
#{item.reliefEndTime},
|
||||
now()
|
||||
|
|
|
|||
Loading…
Reference in New Issue