Commit 9c95fdc5 authored by libin's avatar libin

公司业绩统计

parent 6e32fa72
......@@ -30,10 +30,47 @@ public class CompanyPerformanceBo {
private BigDecimal rentVehilceAmount;
private BigDecimal travelAmount;
private BigDecimal noDeductibleAmount;
private BigDecimal depositAmount;
private Integer rentDays;
private BigDecimal extralAmount;
private Integer departureNum;
private Integer arrivalNum;
private Date startDate;
private Date endDate;
public BigDecimal getMemberAmount() {
return memberAmount==null?BigDecimal.ZERO:memberAmount;
}
public BigDecimal getRentVehilceAmount() {
return rentVehilceAmount==null?BigDecimal.ZERO:rentVehilceAmount;
}
public BigDecimal getTravelAmount() {
return travelAmount==null?BigDecimal.ZERO:travelAmount;
}
public BigDecimal getNoDeductibleAmount() {
return noDeductibleAmount==null?BigDecimal.ZERO:noDeductibleAmount;
}
public BigDecimal getDepositAmount() {
return depositAmount==null?BigDecimal.ZERO:depositAmount;
}
public Integer getRentDays() {
return rentDays==null?0:rentDays;
}
public BigDecimal getExtralAmount() {
return extralAmount==null?BigDecimal.ZERO:extralAmount;
}
public Integer getDepartureNum() {
return departureNum==null?0:departureNum;
}
public Integer getArrivalNum() {
return arrivalNum==null?0:arrivalNum;
}
}
......@@ -130,17 +130,15 @@ public enum StatisticsStatusEnum {
//是否买免赔
boolean hasDamageSafe = Objects.nonNull(orderAccountBo.getDamageSafe()) && (orderAccountBo.getDamageSafe() == StatisticsStatusEnum.DAMAGE_SAFE);
if (orderAccountBo.getAccountType().equals(AccountTypeEnum.IN_ORDER_PAY.getCode())) {
//订单金额(包含免赔,不包含押金)
feeTypeBo.setTotalAmount(feeTypeBo.getTotalAmount().add(accountDetailEntity.getOrderAmount()));
//订单押金
feeTypeBo.setDepositAmount(feeTypeBo.getDepositAmount().add(accountDetailEntity.getDepositAmount()));
if (hasDamageSafe) {
BigDecimal dameSafeAmount = getDameSafeAmount(orderAccountBo.getData());
feeTypeBo.setNoDeductibleAmount(feeTypeBo.getNoDeductibleAmount().add(dameSafeAmount));
}
//订单金额(不包含免赔和押金)
feeTypeBo.setTotalAmount(feeTypeBo.getTotalAmount().add(accountDetailEntity.getOrderAmount()).subtract(feeTypeBo.getNoDeductibleAmount()));
} else {
//退款订单金额(包含免赔,不包含押金)
feeTypeBo.setOrderRefundAmount(feeTypeBo.getOrderRefundAmount().add(accountDetailEntity.getOrderAmount()));
//退款订单押金
feeTypeBo.setDepositRefundAmount(feeTypeBo.getDepositRefundAmount().add(accountDetailEntity.getDepositAmount()));
//退款详细账目
......@@ -155,6 +153,7 @@ public enum StatisticsStatusEnum {
feeTypeBo.setNoDeductibleRefundAmount(feeTypeBo.getNoDeductibleRefundAmount().add(dameSafeAmount));
}
}
//遍历消费明细
for (OrderAccountDeduction deduction : deductions) {
BigDecimal deductionAmount = deduction.getAmount();
......@@ -185,6 +184,8 @@ public enum StatisticsStatusEnum {
}
}
}
//退款订单金额(不包含免赔和押金)
feeTypeBo.setOrderRefundAmount(feeTypeBo.getOrderRefundAmount().add(accountDetailEntity.getOrderAmount()).add(feeTypeBo.getNoDeductibleRefundAmount()));
}
}
return feeTypeBo;
......
......@@ -27,6 +27,10 @@ public class OrderReceivedStatistics extends OrderReceivedStatisticsBase impleme
@ApiModelProperty("会员费")
private BigDecimal memberAmount;
@Column(name = "member_refund_amount")
@ApiModelProperty("会员退款费")
private BigDecimal memberRefundAmout;
@Column(name = "member_quantity")
@ApiModelProperty("会员订单量")
private Integer memberQuantity;
......@@ -35,6 +39,10 @@ public class OrderReceivedStatistics extends OrderReceivedStatisticsBase impleme
@ApiModelProperty("旅游费")
private BigDecimal travelAmount;
@Column(name = "travel_refund_amount")
@ApiModelProperty("旅游退款费")
private BigDecimal travelRefundAmount;
@Column(name = "travel_quantity")
@ApiModelProperty("旅游订单量")
private Integer travelQuantity;
......@@ -43,6 +51,10 @@ public class OrderReceivedStatistics extends OrderReceivedStatisticsBase impleme
@ApiModelProperty("租车费")
private BigDecimal rentVehicleAmount;
@Column(name = "rent_vehicle_refund_amount")
@ApiModelProperty("租车退款费")
private BigDecimal rentVehicleRefundAmount;
@Column(name = "rent_vehicle_quantity")
@ApiModelProperty("租车订单量")
private Integer rentVehicleQuantity;
......
......@@ -231,6 +231,80 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
return ObjectRestResponse.succ(orderPageVo);
}
/**
* 后台获取订单详情
* @param no
* @param userDTO
* @return
*/
public ObjectRestResponse<OrderPageVO> orderDetail(String no, UserDTO userDTO) {
OrderPageVO orderPageVo = mapper.getOrderDetail(no);
if (orderPageVo == null) {
return ObjectRestResponse.createFailedResult(ResCode.ORDER_IS_NOT_EXIST.getCode(), ResCode.ORDER_IS_NOT_EXIST.getDesc());
}
AppUserDTO appUserVo = userFeign.userDetailById(orderPageVo.getUserId()).getData();
if(appUserVo != null) {
orderPageVo.setTelephone(appUserVo.getUsername());
orderPageVo.setUsername(appUserVo.getRealname());
orderPageVo.setPositionName(appUserVo.getPositionName());
}
List<BranchCompany> branchCompanies = vehicleFeign.companyAll(userDTO.getDataAll(), userDTO.getDataCompany(), userDTO.getDataZone());
List<Integer> companyIds = branchCompanies.stream().map(BranchCompany::getId).collect(Collectors.toList());
if (orderPageVo.getOrderRentVehicleDetail() != null) {
if (!companyIds.contains(orderPageVo.getOrderRentVehicleDetail().getStartCompanyId()) && !companyIds.contains(orderPageVo.getOrderRentVehicleDetail().getEndCompanyId())) {
return ObjectRestResponse.createFailedResult(ResCode.YOU_AUTH_FAIL.getCode(), ResCode.YOU_AUTH_FAIL.getDesc());
}
if(userDTO.getCompanyId() == orderPageVo.getOrderRentVehicleDetail().getEndCompanyId()) {
orderPageVo.setUserCompanyStatus(true);
}
if (orderPageVo.getStatus() == 4) { //未交车
// boolean flag = getTodayTime(orderPageVo.getOrderRentVehicleDetail().getStartTime());
// if (!flag) {
// return ObjectRestResponse.createFailedResult(3501, "今日不是交车日期");
// }
getDriverInfo(orderPageVo);
} else if (orderPageVo.getStatus() >= 5 || orderPageVo.getStatus() == -1) {//出行中 已交车
//设置违约金金额
getDriverInfo(orderPageVo);
getUserLicense1(orderPageVo);
}
ObjectRestResponse<CompanyDetail> startResponse = vehicleFeign.getCompanyDetail(orderPageVo.getOrderRentVehicleDetail().getStartCompanyId());
if (startResponse.getData() != null) {
orderPageVo.setStartCompanyName(startResponse.getData().getName());
}
ObjectRestResponse<CompanyDetail> restResponse = vehicleFeign.getCompanyDetail(orderPageVo.getOrderRentVehicleDetail().getEndCompanyId());
if (restResponse.getData() != null) {
orderPageVo.setEndCompanyName(restResponse.getData().getName());
}
RestResponse<Vehicle> response = vehicleFeign.findById(orderPageVo.getOrderRentVehicleDetail().getVehicleId());
if (response.getData() != null) {
orderPageVo.setVehicalNumberPlat(response.getData().getNumberPlate());
orderPageVo.setCode(response.getData().getCode());
}
} else if (orderPageVo.getOrderTourDetail() != null) {
if(StringUtils.isNotBlank(orderPageVo.getOrderTourDetail().getTourUserIds())) {
List<TourUser> list = tourFeign.getTourUsers(orderPageVo.getOrderTourDetail().getTourUserIds()).getData();
orderPageVo.getOrderTourDetail().setUserVoList(list == null || list.size() <= 0 ? new ArrayList<>() : list);
}
}
//设置保留金
Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData();
BigDecimal illegalReserve = new BigDecimal(dictionaryMap.get(APP_ORDER + "_" + DictionaryKey.ILLEGAL_RESERVE).getDetail());
orderPageVo.setIllegalReserve(illegalReserve);
orderPageVo.setItems(orderItemBiz.selectList(new OrderItem(){{
setOrderId(orderPageVo.getId());
setType(104);
}}));
return ObjectRestResponse.succ(orderPageVo);
}
//获取两个日期之间的天数(不包含头尾)
public int getDaysBetweenDateTime(DateTime startDay, DateTime endDay) {
int a = 0;
......@@ -436,6 +510,32 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
orderPageVo.setOrderVehicleCrosstownDto(orderVehicleCrosstownDto);
}
//后台获取用户驾驶信息
public void getUserLicense1(OrderPageVO orderPageVo) {
OrderVehicleCrosstownDto orderVehicleCrosstownDto = new OrderVehicleCrosstownDto();
orderVehicleCrosstownDto.setOrderId(orderPageVo.getId());
orderVehicleCrosstownDto.setOrderNo(orderPageVo.getNo());
List<OrderVehicleCrosstownDto> orderVehicleCrosstown = orderVehicleCrosstownBiz.selectByOrderId(orderVehicleCrosstownDto);
if (orderVehicleCrosstown != null && orderVehicleCrosstown.size() > 0) {
List<OrderUserLicense> orderUserLicenses = orderUserLicenseBiz.selectByIds(orderVehicleCrosstown.get(0).getUserLicenseId()).getData();
if (orderUserLicenses != null && orderUserLicenses.size() > 0) {
orderVehicleCrosstownDto.setLicenseIdCard(orderUserLicenses.get(0).getLicenseIdCard());
orderVehicleCrosstownDto.setLicenseImg(orderUserLicenses.get(0).getLicenseImg());
orderVehicleCrosstownDto.setLicenseName(orderUserLicenses.get(0).getLicenseName());
orderVehicleCrosstownDto.setLicensePhone(orderUserLicenses.get(0).getLicensePhone());
}
//设置违约明细
for (OrderVehicleCrosstownDto a : orderVehicleCrosstown) {
if(a.getType() != CrosstownTypeEnum.DEPARTURE.getCode()) {
if(StringUtils.isNotBlank(a.getViolateDetail())) {
orderPageVo.setDedDetailDTO(a.getViolateDetail());
}
}
}
}
orderPageVo.setOrderVehicleCrosstownDto(orderVehicleCrosstownDto);
}
/**
* 获取驾驶人信息
* @param orderPageVo
......
......@@ -2,23 +2,24 @@ package com.xxfc.platform.order.biz;
import cn.hutool.core.date.DateUtil;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.order.bo.CompanyPerformanceBo;
import com.xxfc.platform.order.contant.enumerate.ReceivedStatisticsEnum;
import com.xxfc.platform.order.pojo.dto.CompanyPerformanceFindDTO;
import com.xxfc.platform.order.bo.CompanyPerformanceBo;
import com.xxfc.platform.vehicle.feign.VehicleFeign;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections.CollectionUtils;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.ServletOutputStream;
import java.time.LocalDate;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.io.IOException;
import java.util.*;
/**
* @author libin
......@@ -36,15 +37,126 @@ public class CompanyPerformanceBiz {
/**
* 导出数据
*
* @param companyPerformanceFindDTO
* @param outputStream
*/
public void exportOrderReceivedStatisticsData(CompanyPerformanceFindDTO companyPerformanceFindDTO, ServletOutputStream outputStream) {
public void exportOrderReceivedStatisticsData(CompanyPerformanceFindDTO companyPerformanceFindDTO, ServletOutputStream outputStream) throws IOException {
//1.查询数据
PageDataVO<CompanyPerformanceBo> pageDataVO = selectCompanyPerformancePage(companyPerformanceFindDTO);
List<CompanyPerformanceBo> data = pageDataVO.getData();
//excel相关
XSSFWorkbook hssfWorkbook = new XSSFWorkbook();
XSSFSheet sheet = hssfWorkbook.createSheet("公司业绩统计报表");
Row headerRow = sheet.createRow(0);
CellStyle headerCellStyle = createHeaderCellStyle(hssfWorkbook);
String[] headerValue = {"时间", "公司", "会员费", "租车费","押金","不计免赔费", "旅游费", "租借天数", "出车服务次数", "收车服务次数"};
createHeader(headerRow, 0, headerValue, headerCellStyle);
for (int i = 0; i < headerValue.length; i++) {
sheet.setColumnWidth(i, 24 * 256);
}
//设置数据
CellStyle generalCellStyle = createGeneralCellStyle(hssfWorkbook);
List<String[]> companyStatisticsData = getCompanyStatisticsData(data, companyPerformanceFindDTO.getStatisticalWay());
createCompnayStatisticsCellData(sheet, 1, generalCellStyle, companyStatisticsData);
hssfWorkbook.write(outputStream);
hssfWorkbook.close();
}
private void createCompnayStatisticsCellData(Sheet sheet, int startRowIndex, CellStyle cellStyle, List<String[]> staffStatisticsData) {
for (String[] data : staffStatisticsData) {
Row row = sheet.createRow(startRowIndex++);
createCellCount(row, 0, data, cellStyle);
}
}
private void createCellCount(Row row, int CellStartIndex, String[] data, CellStyle cellStyle) {
for (int i = CellStartIndex, y = 0; y < data.length; i++, y++) {
Cell cell = row.createCell(i);
cell.setCellStyle(cellStyle);
cell.setCellValue(data[y]);
}
}
private List<String[]> getCompanyStatisticsData(List<CompanyPerformanceBo> companyPerformanceBos, Integer statisticalWay) {
List<String[]> data = new ArrayList<>(companyPerformanceBos.size());
for (int i = 0; i < companyPerformanceBos.size(); i++) {
String[] companyData = getData(companyPerformanceBos.get(i), statisticalWay);
data.add(companyData);
}
return data;
}
private String[] getData(CompanyPerformanceBo companyPerformanceBo, Integer statisticalWay) {
String dateStr = "";
if (statisticalWay == ReceivedStatisticsEnum.DAY.getWayCode()) {
dateStr = DateUtil.format(companyPerformanceBo.getDate(),"yyyy.MM.dd");
}
if (statisticalWay == ReceivedStatisticsEnum.WEEK.getWayCode()) {
String startDateStr = DateUtil.format(companyPerformanceBo.getStartDate(), "yyyy.MM.dd");
String endDateStr = DateUtil.format(companyPerformanceBo.getEndDate(), "yyyy.MM.dd");
dateStr=String.format("%s~%s",startDateStr,endDateStr);
}
if (statisticalWay == ReceivedStatisticsEnum.MONTH.getWayCode()) {
dateStr = String.format("%d.%s",companyPerformanceBo.getYear(),companyPerformanceBo.getMonth().replace(companyPerformanceBo.getYear()+"",""));
}
return new String[]{
dateStr,
companyPerformanceBo.getCompanyName(),
companyPerformanceBo.getMemberAmount().toString(),
companyPerformanceBo.getRentVehilceAmount().toString(),
companyPerformanceBo.getDepositAmount().toString(),
companyPerformanceBo.getNoDeductibleAmount().toString(),
companyPerformanceBo.getTravelAmount().toString(),
String.valueOf(companyPerformanceBo.getRentDays()),
String.valueOf(companyPerformanceBo.getDepartureNum()),
String.valueOf(companyPerformanceBo.getArrivalNum())};
}
private void createHeader(Row row, int cellStartIndex, String[] header, CellStyle cellStyle) {
for (int i = 0; i < header.length; i++) {
Cell cell = row.createCell(cellStartIndex);
cell.setCellValue(header[i]);
cell.setCellStyle(cellStyle);
cellStartIndex += 1;
}
}
private CellStyle createGeneralCellStyle(XSSFWorkbook hssfWorkbook) {
CellStyle cellStyleGeneral = createHeaderCellStyle(hssfWorkbook);
cellStyleGeneral.setWrapText(true);
XSSFFont generalFont = createFont(hssfWorkbook);
generalFont.setBold(false);
cellStyleGeneral.setFont(generalFont);
return cellStyleGeneral;
}
private CellStyle createHeaderCellStyle(XSSFWorkbook hssfWorkbook) {
XSSFCellStyle cellStyleHeader = hssfWorkbook.createCellStyle();
cellStyleHeader.setAlignment(HorizontalAlignment.CENTER);
cellStyleHeader.setVerticalAlignment(VerticalAlignment.CENTER);
cellStyleHeader.setLocked(false);
XSSFFont headerFont = createFont(hssfWorkbook);
cellStyleHeader.setFont(headerFont);
return cellStyleHeader;
}
private XSSFFont createFont(XSSFWorkbook hssfWorkbook) {
XSSFFont font = hssfWorkbook.createFont();
font.setFontName("黑体");
font.setBold(true);
return font;
}
/**
* 分页查询公司业绩
*
* @param companyPerformanceFindDTO
* @return
*/
public PageDataVO<CompanyPerformanceBo> selectCompanyPerformancePage(CompanyPerformanceFindDTO companyPerformanceFindDTO) {
Map<Integer, String> companyMap = vehicleFeign.findCompanyMap();
......
......@@ -24,6 +24,7 @@ import com.xxfc.platform.order.pojo.account.OrderAccountDeduction;
import com.xxfc.platform.order.pojo.account.OrderAccountDetail;
import com.xxfc.platform.order.pojo.calculate.InProgressVO;
import com.xxfc.platform.order.pojo.mq.OrderMQDTO;
import com.xxfc.platform.order.pojo.order.VehicleItemDTO;
import com.xxfc.platform.order.pojo.price.CancelStartedVO;
import com.xxfc.platform.order.pojo.price.CostDetailExtend;
import com.xxfc.platform.universal.constant.DictionaryKey;
......@@ -235,7 +236,7 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
}
orv.setFreeze2PayAmount(freeze2PayAmount);
orv.setFreeze2PayDesc("");
orv.setFreeze2PayDesc("冻结转支付订单号: "+ baseOrder.getNo());
ObjectRestResponse<String> result = thirdFeign.refund(orv);
refundTradeNo = result.getData();
......@@ -384,10 +385,10 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
setType(crosstownTypeEnum);
}});
OrderItem orderItem = 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) {
//设置等待时间 5秒
......@@ -412,7 +413,7 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
}
OrderAccountDetail oad = new OrderAccountDetail();
InProgressVO inProgressVO = orderCalculateBiz.calculateOrderComplete(orderMQDTO, orderMQDTO.getOrderRentVehicleDetail(), oad, orderItem, orderMQDTO.getOrderRentVehicleDetail().getUsedDay(), Boolean.FALSE);
InProgressVO inProgressVO = orderCalculateBiz.calculateOrderComplete(orderMQDTO, orderMQDTO.getOrderRentVehicleDetail(), oad, vehicleItemDTO, orderMQDTO.getOrderRentVehicleDetail().getUsedDay(), Boolean.FALSE);
//设置定损金额
String handleDedRefundDesc = "";
......@@ -425,8 +426,18 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
//剩余押金 = 押金 - 违章保证金 - 定损金额
oad.setDepositAmount(oad.getDepositAmount().subtract(illegalReserve).subtract(csv.getDamagesAmount()));
//设置违约金
//设置原来算出的违约金及描述
csv.setViolateAmount(inProgressVO.getViolateAmount());
csv.setViolateDesc("");
//处理更改之后的违约金及描述
handleCrosstownDetail(crosstown, oad, csv);
if(StrUtil.isBlank(csv.getViolateDesc())) {
csv.setViolateDesc(inProgressVO.getViolateDesc());
}
//退款
BigDecimal refundAmont = oad.getDepositAmount().add(oad.getOrderAmount());
//crosstown.getRestDeposit().subtract(illegalReserve);
......@@ -476,12 +487,22 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
//生成额外的费用明细
csv.setConsumeAmount(inProgressVO.getConsumeAmount());
csv.setModelAmount(orderItem.getUnitPrice());
csv.setCouponAmount(inProgressVO.getCouponAmount());
csv.setCouponDesc(inProgressVO.getCouponDesc());
csv.setModelAmount(vehicleItemDTO.getUnitPrice());
csv.setUsedAmount(inProgressVO.getUsedAmount());
csv.setUsedDayNum(inProgressVO.getUsedDays());
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);
......@@ -493,6 +514,7 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
}
csv.setDeductionList(oad.getDeductions());
csv.initParamJson();
//设置明细
orderRentVehicleBiz.updateSelectiveByIdRe(new OrderRentVehicleDetail(){{
......@@ -503,6 +525,13 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
orderMQDTO.setOrderRentVehicleDetail(orderRentVehicleBiz.selectById(orderMQDTO.getDetailId()));
//根据商品消费金额 设置changeAmount
vehicleItemDTO.setChangeAmount(inProgressVO.getConsumeAmount().subtract(vehicleItemDTO.getRealAmount()));
orderItemBiz.updateSelectiveByIdRe(vehicleItemDTO);
//发送押金退还完成队列消息
baseOrderBiz.sendOrderMq(orderMQDTO.getOrderRentVehicleDetail(), null, null, orderMQDTO, OrderMQDTO.ORDER_PART_DEPOSIT);
//捕捉异常
try {
orderMsgBiz.handelMsgDeposit(orderMQDTO.getOrderRentVehicleDetail(), orderMQDTO, userFeign.userDetailById(orderMQDTO.getUserId()).getData());
......@@ -609,10 +638,9 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
//还车扣除款 剩余的 钱,再减去违章预备金
refundAmont = orvd.getReturnPayResidue().subtract(orderViolation.getPrice());
refundDesc += refundAmont.toString();
refundDesc += StrUtil.format("(扣除{}: {})", DeductionTypeEnum.VIOLATE_TRAFFIC_DEDUCT.getDesc(), orderViolation.getPrice().toString());
}else {
refundAmont = orvd.getReturnPayResidue();
refundDesc += refundAmont.toString();
}
oad.setOriginDepositAmount(orvd.getReturnPayResidue());
oad.setDepositAmount(refundAmont);
......@@ -627,7 +655,7 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
* @param endDate
* @return
*/
public List<OrderAccountBo> selectByTypeAndDate(Integer orderType,Date startDate, Date endDate) {
public List<OrderAccountBo> selectByTypeAndDate(Integer orderType, Date startDate, Date endDate) {
List<OrderAccountBo> accountBos = mapper.selectOrderAccountByOrderTypeAndStartTimeAndEndTime(orderType,startDate.getTime(),endDate.getTime());
return CollectionUtils.isEmpty(accountBos)? Collections.EMPTY_LIST:accountBos;
}
......@@ -639,8 +667,8 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
* @param staffUserIds
* @return
*/
public List<OrderAccountBo> selectByDateAndStatffIds(Date startDate, Date endDate, List<Integer> staffUserIds) {
public List<OrderAccountBo> selectByDateAndStatffIds(Date startDate, Date endDate,List<Integer> staffUserIds) {
List<OrderAccountBo> orderAccountBos = mapper.selectByDateAndStatffIds(startDate,endDate,staffUserIds);
return CollectionUtils.isNotEmpty(orderAccountBos)? Collections.EMPTY_LIST:orderAccountBos;
return CollectionUtils.isNotEmpty(orderAccountBos)?Collections.EMPTY_LIST:orderAccountBos;
}
}
\ No newline at end of file
......@@ -60,7 +60,7 @@ public class OrderMemberReceivedStatisticsBiz extends BaseBiz<OrderMemberReceive
List<String> stisticsActiveState = new ArrayList<>();
//根据时间范围查询出会员单
List<OrderDTO> orders = baseOrderBiz.selectOrdersByTypeAndTime(Arrays.asList(StatisticsStatusEnum.ORDER_MEMBER_TYPE), startDate, endDate);
List<OrderDTO> orders = baseOrderBiz.selectOrdersByTypeAndTime(Arrays.asList(StatisticsStatusEnum.ORDER_MEMBER_TYPE),null, startDate, endDate);
//数据处理 状态组合 按支付状态分组 而后按组合状态
Map<Boolean, Map<String, List<OrderDTO>>> stateGroupMap = StatisticsStatusEnum.processOrdersWithState(stisticsActiveState, orders);
......
......@@ -266,10 +266,13 @@ public class OrderReceivedStatisticsBiz extends BaseBiz<OrderReceivedStatisticsM
//旅游订单总额
orderReceivedStatisticsClone.setTravelAmount(orderTour.getTotalAmount());
orderReceivedStatisticsClone.setTravelRefundAmount(orderTour.getOrderRefundAmount());
//会员订单总额
orderReceivedStatisticsClone.setMemberAmount(orderMember.getTotalAmount());
orderReceivedStatisticsClone.setMemberRefundAmout(orderMember.getOrderRefundAmount());
//租车订单总额
orderReceivedStatisticsClone.setRentVehicleAmount(orderRentVehicle.getTotalAmount());
orderReceivedStatisticsClone.setRentVehicleRefundAmount(orderRentVehicle.getOrderRefundAmount());
//合计订单总额
BigDecimal totalAmount = orderRentVehicle.getTotalAmount().add(orderTour.getTotalAmount()).add(orderMember.getTotalAmount());
//合计订单退款总额
......
......@@ -56,7 +56,7 @@ public class OrderRentVehicleReceivedStatisticsBiz extends BaseBiz<OrderRentVehi
List<OrderRentVehicleReceivedStatistics> orderRentVehicleReceivedStatisticsList = new ArrayList<>();
List<String> stisticsActiveState = new ArrayList<>();
//根据租车订单类型 时间查询
List<OrderDTO> orderDTOS = baseOrderBiz.selectOrdersByTypeAndTime(Arrays.asList(StatisticsStatusEnum.ORDER_RENT_VEHICLE_TYPE), startDate, endDate);
List<OrderDTO> orderDTOS = baseOrderBiz.selectOrdersByTypeAndTime(Arrays.asList(StatisticsStatusEnum.ORDER_RENT_VEHICLE_TYPE),null, startDate, endDate);
//数据处理 状态组合 按支付状态分组 而后按组合状态
Map<Boolean, Map<String, List<OrderDTO>>> stateGroupMap = StatisticsStatusEnum.processOrdersWithState(stisticsActiveState, orderDTOS);
......@@ -138,14 +138,15 @@ public class OrderRentVehicleReceivedStatisticsBiz extends BaseBiz<OrderRentVehi
if (hasDamageSafe) {
damageSafeAmount = damageSafeAmount.add(StatisticsStatusEnum.getDameSafeAmount(noPayOrder.getData()));
}
totalAmount = totalAmount.add(noPayOrder.getRealAmount());
totalAmount = totalAmount.add(noPayOrder.getRealAmount()).subtract(totalAmount);
depositAmount = depositAmount.add(noPayOrder.getDeposit());
}
orderRentVehicleReceivedStatistics.setNoDeductibleAmount(damageSafeAmount);
orderRentVehicleReceivedStatistics.setDepositAmount(depositAmount);
BigDecimal totalNoPayAmount = orderDtoStreamSupplier.get().map(OrderDTO::getRealAmount).reduce(BigDecimal.ZERO,BigDecimal::add);
orderRentVehicleReceivedStatistics.setTotalAmount(totalNoPayAmount.subtract(depositAmount));
//租车费减去 押金和不计免赔费
orderRentVehicleReceivedStatistics.setTotalAmount(totalNoPayAmount.subtract(depositAmount).subtract(damageSafeAmount));
//总订单总量
orderRentVehicleReceivedStatistics.setTotalQuantity(noPayOrders.size());
......
......@@ -48,7 +48,7 @@ public class OrderTourReceivedStatisticsBiz extends BaseBiz<OrderTourReceivedSta
List<String> stisticsActiveState = new ArrayList<>();
//根据旅游类型 时间查询
List<OrderDTO> orderDTOS = baseOrderBiz.selectOrdersByTypeAndTime(Arrays.asList(StatisticsStatusEnum.ORDER_TOUR_TYPE), startDate, endDate);
List<OrderDTO> orderDTOS = baseOrderBiz.selectOrdersByTypeAndTime(Arrays.asList(StatisticsStatusEnum.ORDER_TOUR_TYPE),null, startDate, endDate);
//数据处理 状态组合 按支付状态分组 而后按组合状态
Map<Boolean, Map<String, List<OrderDTO>>> stateGroupMap = StatisticsStatusEnum.processOrdersWithState(stisticsActiveState, orderDTOS);
......
package com.xxfc.platform.order.mapper;
import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.pojo.bg.BgOrderListVo;
import com.xxfc.platform.order.pojo.dto.MemberOrderBo;
import com.xxfc.platform.order.pojo.dto.MemberOrderFindDTO;
import com.xxfc.platform.order.pojo.dto.OrderDTO;
......
......@@ -237,6 +237,60 @@
</if>
</select>
<select id="getAllOrderList" parameterType="Map" resultType="com.xxfc.platform.order.pojo.bg.BgOrderListVo">
SELECT * from order_list_info
<where>
<if test="userIds != null and userIds.size() > 0">
and userId in
<foreach collection="userIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="phone != null and phone != ''">
and telephone like CONCAT ("%", #{phone}, "%")
</if>
<if test="realName != null and realName != ''">
and username like CONCAT ("%", #{realName}, "%")
</if>
<if test="userId != null">
and userId = #{userId}
</if>
<if test="status != null">
and status = #{status}
</if>
<if test="type != null">
and type = #{type}
</if>
<if test="no != null and no != '' ">
and orderNo like CONCAT ("%", #{no}, "%")
</if>
<if test="plateNumber != null and plateNumber != '' ">
and numberPlate like CONCAT ("%", #{plateNumber}, "%")
</if>
<if test="vehicleCode != null">
and vehicleCode = #{vehicleCode}
</if>
<if test="startTime != null">
and startTime between #{startTime} and #{endTime}
</if>
<if test="companyIds != null and companyIds.size > 0">
and (startCompanyId in
<foreach collection="companyIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
or
endCompanyId in
<foreach collection="companyIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
)
</if>
<if test="zoneId != null">
and (startZoneId = #{zoneId} or endZoneId = #{zoneId})
</if>
</where>
order by crtTime desc
</select>
<select id="getTourList" parameterType="Map" resultMap="orderPageMap">
select b.*
......@@ -354,10 +408,14 @@
</select>
<select id="selectOrdersByTypeAndTime" resultType="com.xxfc.platform.order.pojo.dto.OrderDTO">
select bo.*,omd.memberLevel,IFNULL(IFNULL(orvd.start_company_id,otd.start_company_id),bo.`parent_user_company_id`) AS `companyId`,orvd.deposit,orvd.cost_detail_extend AS `costDetailExtend` from (select `id`,`type`,`status`,`order_amount` AS `orderAmount`, `real_amount`AS
`realAmount`,`order_origin` AS `orderOrigin`, `has_pay` AS `hasPay`,
`pay_way` AS `payWay`,`parent_user_company_id`
from `base_order` where (`crt_time` between #{startDate} and #{endDate} or `pay_time` between #{startDate} and #{endDate} ) and `type` IN <foreach collection="types"
select bo.id,bo.type,bo.status,bo.order_amount,bo.real_amount,bo.order_origin,bo.parent_user_id as `userId`,bo.parent_position_id as `postionId`,
bo.has_pay,bo.pay_way,omd.memberLevel,IFNULL(IFNULL(orvd.start_company_id,otd.start_company_id),`parent_user_company_id`) AS `companyId`,
orvd.deposit,orvd.cost_detail_extend AS `costDetailExtend`
from (select * from `base_order` where 1=1
<if test="hasPay!=null">
and `has_pay`=#{hasPay}
</if>
and (`crt_time` between #{startDate} and #{endDate} or `pay_time` between #{startDate} and #{endDate} ) and `type` IN <foreach collection="types"
item="type"
open="(" close=")"
separator=",">
......@@ -370,8 +428,10 @@
omd.order_id=bo.id;
</select>
<select id="selectBaeOrderByOrderIds" resultType="com.xxfc.platform.order.pojo.dto.OrderDTO">
select `id`,`parent_user_company_id` as `companyId` from `base_order` where id in
<foreach collection="orderIds" item="orderId" open="(" close=")" separator=",">
#{orderId}
</foreach>
</select>
</mapper>
\ No newline at end of file
......@@ -71,9 +71,11 @@
`company_id` AS `companyId`,
`year`,
`date`,
SUM(`member_amount` ) AS `memberAmount`,
SUM(`travel_amount` ) AS `travelAmount`,
SUM(`rent_vehicle_amount` ) AS `rentVehilceAmount`
SUM(`member_amount`-`member_refund_amount`) AS `memberAmount`,
SUM(`travel_amount`-`travel_refund_amount` ) AS `travelAmount`,
SUM(`rent_vehicle_amount`-`rent_vehicle_refund_amount`) AS `rentVehilceAmount`,
SUM(`no_deductible_amount` - `no_deductible_refund_amount`) as `noDeductibleAmount`,
SUM(`deposit_amount` - `deposit_refund_amount`) as `depositAmount`
FROM
`order_received_statistics` WHERE `has_pay`=1
<if test="companyName!=null and companyName!=''">
......@@ -150,9 +152,11 @@
company_id AS `companyId`,
`year`,
`month`,
COALESCE(SUM(`member_amount` ),0) AS `memberAmount`,
COALESCE(SUM(`travel_amount` ),0) AS `travelAmount`,
COALESCE(SUM(`rent_vehicle_amount` ),0) AS `rentVehilceAmount`
SUM(`member_amount`-`member_refund_amount`) AS `memberAmount`,
SUM(`travel_amount`-`travel_refund_amount` ) AS `travelAmount`,
SUM(`rent_vehicle_amount`-`rent_vehicle_refund_amount`) AS `rentVehilceAmount`,
SUM(`no_deductible_amount` - `no_deductible_refund_amount`) as `noDeductibleAmount`,
SUM(`deposit_amount` - `deposit_refund_amount`) as `depositAmount`
FROM
`order_received_statistics` WHERE `has_pay`=1
<if test="companyName!=null and companyName!=''">
......@@ -228,9 +232,11 @@
company_id AS `companyId`,
`year`,
`week_of_year` AS `weekOfYear`,
COALESCE(SUM(`member_amount` ),0) AS `memberAmount`,
COALESCE(SUM(`travel_amount` ),0) AS `travelAmount`,
COALESCE(SUM(`rent_vehicle_amount` ),0) AS `rentVehilceAmount`
SUM(`member_amount`-`member_refund_amount`) AS `memberAmount`,
SUM(`travel_amount`-`travel_refund_amount` ) AS `travelAmount`,
SUM(`rent_vehicle_amount`-`rent_vehicle_refund_amount`) AS `rentVehilceAmount`,
SUM(`no_deductible_amount` - `no_deductible_refund_amount`) as `noDeductibleAmount`,
SUM(`deposit_amount` - `deposit_refund_amount`) as `depositAmount`
FROM
`order_received_statistics` WHERE `has_pay`=1
<if test="companyName!=null and companyName!=''">
......
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