对比新文件 |
| | |
| | | package com.mzl.flower.dto.request.report; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | | import java.time.LocalDate; |
| | | |
| | | @Data |
| | | public class QuerySupplierDTO { |
| | | @ApiModelProperty(value = "供应商id") |
| | | private Long supplierId; |
| | | |
| | | @ApiModelProperty(value = "下单开始日期") |
| | | @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | @NotNull(message = "下单日期不能为空") |
| | | private LocalDate startDate; |
| | | |
| | | @ApiModelProperty(value = "下单结束日期") |
| | | @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | @NotNull(message = "下单日期不能为空") |
| | | private LocalDate endDate; |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.mzl.flower.dto.response.report; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.mzl.flower.base.AbstractTransDTO; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Data |
| | | public class OrderSupplierReportResultVO extends AbstractTransDTO { |
| | | |
| | | @ApiModelProperty("日期") |
| | | @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDateTime orderDate; |
| | | |
| | | @ApiModelProperty("供应商ID") |
| | | private String supplierId; |
| | | |
| | | @ApiModelProperty("供应商名称") |
| | | private String supplierName; |
| | | |
| | | @ApiModelProperty("花农底价") |
| | | private BigDecimal orderSupplierPriceAmount; |
| | | |
| | | @ApiModelProperty("降级扣款") |
| | | private BigDecimal orderCheckFee; |
| | | |
| | | @ApiModelProperty("缺货扣款(缺货+补货)") |
| | | private BigDecimal orderLackFeeSupplier; |
| | | |
| | | @ApiModelProperty("售后扣花农款") |
| | | private BigDecimal salesFeeSupplier; |
| | | |
| | | @ApiModelProperty("实际销售扎数") |
| | | private Integer realSaleNum; |
| | | |
| | | @ApiModelProperty("结算费用") |
| | | private BigDecimal profitFeeAmount; |
| | | |
| | | @ApiModelProperty("订单状态") |
| | | private String settleStatus; |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.mzl.flower.dto.response.report; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDate; |
| | | |
| | | @Data |
| | | public class SupplierReportCalendarBO { |
| | | |
| | | @ApiModelProperty("下单的开始时间") |
| | | private LocalDate startDate; |
| | | |
| | | @ApiModelProperty("下单的结束时间") |
| | | private LocalDate endDate; |
| | | |
| | | @ApiModelProperty(value = "供应商id") |
| | | private Long supplierId; |
| | | |
| | | } |
| | |
| | | package com.mzl.flower.mapper.report; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.mzl.flower.dto.response.report.*; |
| | | import com.mzl.flower.dto.response.report.OrderDetailReportResultVO; |
| | | import com.mzl.flower.dto.response.report.OrderPartnerReportResultVO; |
| | | import com.mzl.flower.dto.response.report.OrderReportCalendarBO; |
| | |
| | | OrderPartnerReportResultVO getPartnerOrderDateReport(@Param("dto") OrderReportCalendarBO calendarBO); |
| | | |
| | | OrderPartnerReportResultVO getPartnerOrderDateReportStatis(@Param("dto") OrderReportCalendarBO bo); |
| | | |
| | | List<OrderSupplierReportResultVO> getOrderSupplierPageReport(@Param("dto") SupplierReportCalendarBO calendarBO, Page page); |
| | | |
| | | List<OrderSupplierReportResultVO> getOrderSupplierReport(@Param("dto") SupplierReportCalendarBO calendarBO); |
| | | |
| | | OrderSupplierReportResultVO getOrderSupplierCountReport(@Param("dto") SupplierReportCalendarBO calendarBO); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.mzl.flower.config.exception.ValidationException; |
| | | import com.mzl.flower.dto.request.report.QueryOrderDTO; |
| | | import com.mzl.flower.dto.response.report.OrderDetailReportResultVO; |
| | | import com.mzl.flower.dto.response.report.OrderPartnerReportResultVO; |
| | | import com.mzl.flower.dto.response.report.OrderReportCalendarBO; |
| | | import com.mzl.flower.dto.response.report.OrderReportResultVO; |
| | | import com.mzl.flower.dto.request.report.QuerySupplierDTO; |
| | | import com.mzl.flower.dto.response.report.*; |
| | | import com.mzl.flower.mapper.report.OrderReportMapper; |
| | | import com.mzl.flower.service.BaseService; |
| | | import com.mzl.flower.service.calendar.CalendarService; |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Page<OrderSupplierReportResultVO> getOrderSupplierPage(Page page, QuerySupplierDTO dto) { |
| | | SupplierReportCalendarBO supplierReportCalendarBO = new SupplierReportCalendarBO(); |
| | | if (StringUtils.isEmpty(dto.getStartDate()) || StringUtils.isEmpty(dto.getEndDate())) { |
| | | throw new ValidationException("日期不能为空"); |
| | | } |
| | | supplierReportCalendarBO.setSupplierId(dto.getSupplierId()); |
| | | supplierReportCalendarBO.setStartDate(dto.getStartDate()); |
| | | supplierReportCalendarBO.setEndDate(dto.getEndDate()); |
| | | List<OrderSupplierReportResultVO> list = orderReportMapper.getOrderSupplierPageReport(supplierReportCalendarBO, page); |
| | | page.setRecords(list); |
| | | return page; |
| | | } |
| | | |
| | | @Override |
| | | public OrderSupplierReportResultVO getOrderSupplierClout(QuerySupplierDTO dto) { |
| | | SupplierReportCalendarBO supplierReportCalendarBO = new SupplierReportCalendarBO(); |
| | | if (StringUtils.isEmpty(dto.getStartDate()) || StringUtils.isEmpty(dto.getEndDate())) { |
| | | throw new ValidationException("日期不能为空"); |
| | | } |
| | | supplierReportCalendarBO.setSupplierId(dto.getSupplierId()); |
| | | supplierReportCalendarBO.setStartDate(dto.getStartDate()); |
| | | supplierReportCalendarBO.setEndDate(dto.getEndDate()); |
| | | OrderSupplierReportResultVO orderSupplierCountReport = orderReportMapper.getOrderSupplierCountReport(supplierReportCalendarBO); |
| | | return orderSupplierCountReport; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void exportSupplierList(HttpServletResponse response, QuerySupplierDTO dto) { |
| | | SupplierReportCalendarBO supplierReportCalendarBO = new SupplierReportCalendarBO(); |
| | | if (StringUtils.isEmpty(dto.getStartDate()) || StringUtils.isEmpty(dto.getEndDate())) { |
| | | throw new ValidationException("日期不能为空"); |
| | | } |
| | | supplierReportCalendarBO.setSupplierId(dto.getSupplierId()); |
| | | supplierReportCalendarBO.setStartDate(dto.getStartDate()); |
| | | supplierReportCalendarBO.setEndDate(dto.getEndDate()); |
| | | List<OrderSupplierReportResultVO> list = orderReportMapper.getOrderSupplierReport(supplierReportCalendarBO); |
| | | |
| | | String[] rowsName = new String[]{"序号","日期", "供应商ID", "供应商","花农底价" |
| | | , "降级扣款", "缺货扣款(缺货+补货)","售后扣花农款","售后扣合伙人款","实际销售扎数","结算费用","订单状态"}; |
| | | List<Object[]> dataList = new ArrayList<>(); |
| | | int sn = 1; |
| | | for (OrderSupplierReportResultVO o : list) { |
| | | Object[] objs = new Object[rowsName.length]; |
| | | int a = 0; |
| | | objs[a++] = sn; // 序号 |
| | | objs[a++] = format(o.getOrderDate(), "yyyy-MM-dd"); // 日期 |
| | | objs[a++] = o.getSupplierId(); // 供应商ID |
| | | objs[a++] = o.getSupplierName(); // 供应商 |
| | | objs[a++] = o.getOrderSupplierPriceAmount(); // 花农底价 |
| | | objs[a++] = o.getOrderCheckFee(); //降级扣款 |
| | | objs[a++] = o.getOrderLackFeeSupplier();//缺货扣款 |
| | | objs[a++] = o.getSalesFeeSupplier(); // 售后扣花农款 |
| | | objs[a++] = o.getRealSaleNum(); // 实际销售扎数 |
| | | objs[a++] = o.getProfitFeeAmount(); // 结算费用 |
| | | objs[a++] = o.getSettleStatus(); // 订单状态 |
| | | dataList.add(objs); |
| | | sn++; |
| | | } |
| | | |
| | | ExcelExportUtil excelExportUtil = new ExcelExportUtil("花农结算报表", rowsName, dataList, response); |
| | | try { |
| | | response.addHeader("filename", URLEncoder.encode("花农结算报表.xls", "UTF-8")); |
| | | response.addHeader("Access-Control-Expose-Headers", "filename"); |
| | | excelExportUtil.export(); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | } |
| | | } |
| | | // 计算 startDate 的前一天 17:00:00 |
| | | public static LocalDateTime calculateStartTime(LocalDateTime startDateTime) { |
| | | // 获取 LocalDate 部分 |
| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.mzl.flower.dto.request.report.QueryOrderDTO; |
| | | import com.mzl.flower.dto.request.report.QuerySupplierDTO; |
| | | import com.mzl.flower.dto.response.report.OrderDetailReportResultVO; |
| | | import com.mzl.flower.dto.response.report.OrderPartnerReportResultVO; |
| | | import com.mzl.flower.dto.response.report.OrderReportResultVO; |
| | | import com.mzl.flower.dto.response.report.OrderSupplierReportResultVO; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | |
| | | OrderPartnerReportResultVO getPartnerSaleStatis(QueryOrderDTO dto); |
| | | |
| | | void exportPartnerSalesList(HttpServletResponse response, QueryOrderDTO dto); |
| | | |
| | | Page<OrderSupplierReportResultVO> getOrderSupplierPage(Page page, QuerySupplierDTO dto); |
| | | |
| | | OrderSupplierReportResultVO getOrderSupplierClout(QuerySupplierDTO dto); |
| | | |
| | | void exportSupplierList(HttpServletResponse response, QuerySupplierDTO dto); |
| | | } |
| | |
| | | import com.mzl.flower.base.R; |
| | | import com.mzl.flower.base.ReturnDataDTO; |
| | | import com.mzl.flower.dto.request.report.QueryOrderDTO; |
| | | import com.mzl.flower.dto.request.report.QuerySupplierDTO; |
| | | import com.mzl.flower.dto.response.report.OrderDetailReportResultVO; |
| | | import com.mzl.flower.dto.response.report.OrderReportResultVO; |
| | | import com.mzl.flower.dto.response.report.OrderSupplierReportResultVO; |
| | | import com.mzl.flower.service.report.OrderReportService; |
| | | import com.mzl.flower.utils.ConverterUtil; |
| | | import io.swagger.annotations.Api; |
| | |
| | | orderReportService.exportPartnerSalesList(response, dto); |
| | | } |
| | | |
| | | /** |
| | | * 花农结算报表 |
| | | */ |
| | | @GetMapping("/supplier/page") |
| | | @ApiOperation(value = "花农结算报表-分页", notes = "花农结算报表-分页") |
| | | public ResponseEntity<ReturnDataDTO<Page<OrderSupplierReportResultVO>>> supplier(Page page, QuerySupplierDTO dto) { |
| | | return returnData(R.SUCCESS.getCode(), orderReportService.getOrderSupplierPage(page, dto)); |
| | | } |
| | | |
| | | @GetMapping("/supplier/count") |
| | | @ApiOperation(value = "花农结算报表-统计", notes = "花农结算报表-统计") |
| | | public ResponseEntity<ReturnDataDTO<Page<OrderSupplierReportResultVO>>> supplierCount(QuerySupplierDTO dto) { |
| | | return returnData(R.SUCCESS.getCode(), orderReportService.getOrderSupplierClout(dto)); |
| | | } |
| | | |
| | | @GetMapping({"/supplier/export"}) |
| | | @ApiOperation(value = "花农结算报表导出") |
| | | public void supplierExports(HttpServletResponse response, @Validated QuerySupplierDTO dto) { |
| | | orderReportService.exportSupplierList(response, dto); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | on t2.order_id =t3.order_id |
| | | </sql> |
| | | |
| | | |
| | | <sql id="baseSupplierSql"> |
| | | SELECT |
| | | t2.*, |
| | | IFNULL( t3.sales_fee_supplier, 0 ) AS sales_fee_supplier |
| | | FROM |
| | | ( |
| | | SELECT |
| | | t1.order_item_id, |
| | | t1.supplier_id, |
| | | t1.dateinfo, |
| | | t1.order_id, |
| | | sum( t1.supplier_price_amount ) AS order_supplier_price_amount, |
| | | sum( t1.check_fee ) AS order_check_fee, |
| | | sum( t1.replace_fee ) AS order_replace_fee, |
| | | sum( t1.lack_fee_supplier ) AS order_lack_fee_supplier, |
| | | sum( t1.num ) AS order_num, |
| | | sum( t1.lack_num ) AS order_lack_num |
| | | FROM |
| | | ( |
| | | SELECT |
| | | oi.id AS order_item_id, |
| | | o.id order_id, |
| | | oi.supplier_id supplier_id, |
| | | CASE |
| | | WHEN HOUR ( o.payment_time ) >= 17 THEN |
| | | DATE_FORMAT( DATE_ADD( o.payment_time, INTERVAL 1 DAY ), '%Y-%m-%d' ) ELSE DATE_FORMAT( o.payment_time, '%Y-%m-%d' ) |
| | | END AS dateinfo, |
| | | IFNULL( oi.num, 0 ) AS num, |
| | | IFNULL( oi.total, 0 ) AS total, |
| | | IFNULL( oi.supplier_price, 0 ) * IFNULL( oi.num, 0 ) AS supplier_price_amount, |
| | | IFNULL( ois.check_fee, 0 ) AS check_fee, |
| | | IFNULL( ois.replace_fee, 0 ) AS replace_fee, |
| | | IFNULL( ois.lack_fee_supplier, 0 ) AS lack_fee_supplier, |
| | | IFNULL( (select oic.num from t_order_item_check oic where oic.order_item_id = oi.id and oic.type = 'lack'),0) as lack_num |
| | | FROM |
| | | t_order o |
| | | LEFT JOIN t_order_item oi ON oi.order_id = o.id |
| | | LEFT JOIN t_station s ON s.id = oi.station_id |
| | | LEFT JOIN t_supplier_info si ON si.id = oi.supplier_id |
| | | LEFT JOIN t_order_item_settlement ois ON ois.order_item_id = oi.id |
| | | WHERE |
| | | oi.deleted = 0 |
| | | and o.payment_time is not null |
| | | <if test="dto.startDate != null"> |
| | | and o.payment_time >= #{dto.startDate} |
| | | </if> |
| | | <if test="dto.endDate != null"> |
| | | and o.payment_time <= #{dto.endDate} |
| | | </if> |
| | | <if test="dto.supplierId != null"> |
| | | and oi.supplierId <= #{dto.supplierId} |
| | | </if> |
| | | ) t1 |
| | | GROUP BY |
| | | t1.order_item_id |
| | | ) t2 |
| | | LEFT JOIN ( SELECT ois.order_item_id, IFNULL( sum( ois.sales_fee_supplier ), 0 ) AS sales_fee_supplier FROM t_order_item_settlement ois GROUP BY order_item_id ) t3 ON t2.order_item_id = t3.order_item_id |
| | | </sql> |
| | | <select id="getOrderSupplierPageReport" resultType="com.mzl.flower.dto.response.report.OrderSupplierReportResultVO"> |
| | | select |
| | | dateinfo, |
| | | supplier_id, |
| | | supplierName, |
| | | sum(order_supplier_price_amount) order_supplier_price_amount, |
| | | sum(order_check_fee) order_check_fee, |
| | | sum(order_replace_fee) + sum(order_lack_fee_supplier) order_lack_fee_supplier, |
| | | sum(order_num)-sum(order_lack_num) as real_sale_num, |
| | | sum(sales_fee_supplier) sales_fee_supplier, |
| | | sum(order_supplier_price_amount) - sum(order_check_fee) - sum(order_replace_fee) - sum(order_lack_fee_supplier) - sum(sales_fee_supplier) profitFeeAmount |
| | | from( |
| | | SELECT |
| | | oi.id,vor.*,p.name as supplierName |
| | | FROM t_order_item oi |
| | | left join (<include refid="baseSupplierSql"></include>) vor |
| | | on oi.id =vor.order_item_id |
| | | left join t_supplier_info p |
| | | on vor.supplier_id=p.id |
| | | left join t_order o |
| | | on vor.order_id= o.id |
| | | and o.status_backend not in ('PENDING','CANCEL','REFUND') |
| | | ) s group by dateinfo,supplier_id |
| | | </select> |
| | | |
| | | <select id="getOrderSupplierCountReport" resultType="com.mzl.flower.dto.response.report.OrderSupplierReportResultVO"> |
| | | Select |
| | | sum(order_supplier_price_amount) order_supplier_price_amount, |
| | | sum(order_check_fee) order_check_fee, |
| | | sum(order_lack_fee_supplier) order_lack_fee_supplier, |
| | | sum(real_sale_num) real_sale_num, |
| | | sum(sales_fee_supplier) sales_fee_supplier, |
| | | sum(profitFeeAmount) profitFeeAmount |
| | | from( |
| | | select |
| | | dateinfo, |
| | | supplier_id, |
| | | supplierName, |
| | | sum(order_supplier_price_amount) order_supplier_price_amount, |
| | | sum(order_check_fee) order_check_fee, |
| | | sum(order_replace_fee) + sum(order_lack_fee_supplier) order_lack_fee_supplier, |
| | | sum(order_num)-sum(order_lack_num) as real_sale_num, |
| | | sum(sales_fee_supplier) sales_fee_supplier, |
| | | sum(order_supplier_price_amount) - sum(order_check_fee) - sum(order_replace_fee) - sum(order_lack_fee_supplier) |
| | | - sum(sales_fee_supplier) profitFeeAmount |
| | | from( |
| | | SELECT |
| | | oi.id,vor.*,p.name as supplierName |
| | | FROM t_order_item oi |
| | | left join (<include refid="baseSupplierSql"></include>) vor |
| | | on oi.id =vor.order_item_id |
| | | left join t_supplier_info p |
| | | on vor.supplier_id=p.id |
| | | left join t_order o |
| | | on vor.order_id= o.id |
| | | and o.status_backend not in ('PENDING','CANCEL','REFUND') |
| | | ) |
| | | ) s |
| | | </select> |
| | | </mapper> |