master:APP 档口数据概览调整;
parent
d641eb102a
commit
648dcb23e4
|
|
@ -29,5 +29,9 @@ public class StoreIndexOverviewResVO {
|
|||
private Integer storageNum;
|
||||
@ApiModelProperty(value = "累计客户数")
|
||||
private Integer customerNum;
|
||||
@ApiModelProperty(value = "销售大客户")
|
||||
private String topSaleCusName;
|
||||
@ApiModelProperty(value = "销售大客户金额")
|
||||
private BigDecimal topSaleCusAmount;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,8 +21,7 @@ public class StoreIndexSaleRevenueResVO {
|
|||
private Long storeId;
|
||||
@ApiModelProperty(value = "销售出库金额")
|
||||
private BigDecimal saleAmount;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
@ApiModelProperty(value = "单据日期")
|
||||
private Date voucherDate;
|
||||
private Integer day;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,4 +46,23 @@
|
|||
LIMIT 10
|
||||
</select>
|
||||
|
||||
<select id="getMaxSaleCus" resultType="com.ruoyi.xkt.dto.store.StoreIndexOverviewResDTO">
|
||||
SELECT
|
||||
SUM( dsc.sale_amount ) AS topSaleCusAmount,
|
||||
sc.cus_name AS topSaleCusName
|
||||
FROM
|
||||
daily_sale_customer dsc
|
||||
JOIN store_customer sc ON dsc.store_cus_id = sc.id
|
||||
WHERE
|
||||
dsc.del_flag = 0
|
||||
AND dsc.store_id = #{storeId}
|
||||
AND dsc.voucher_date BETWEEN #{voucherDateStart} AND #{voucherDateEnd}
|
||||
GROUP BY
|
||||
dsc.store_cus_id,
|
||||
sc.cus_name
|
||||
ORDER BY
|
||||
topSaleCusAmount DESC
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -31,5 +31,9 @@ public class StoreIndexOverviewResDTO {
|
|||
private Integer storageNum;
|
||||
@ApiModelProperty(value = "累计客户数")
|
||||
private Integer customerNum;
|
||||
@ApiModelProperty(value = "销售大客户")
|
||||
private String topSaleCusName;
|
||||
@ApiModelProperty(value = "销售大客户金额")
|
||||
private BigDecimal topSaleCusAmount;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.ruoyi.xkt.dto.store;
|
|||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
|
@ -14,6 +15,7 @@ import java.util.Date;
|
|||
*/
|
||||
@ApiModel("档口首页销售额")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class StoreIndexSaleRevenueResDTO {
|
||||
|
||||
@ApiModelProperty(value = "档口ID")
|
||||
|
|
@ -21,6 +23,6 @@ public class StoreIndexSaleRevenueResDTO {
|
|||
@ApiModelProperty(value = "销售出库金额")
|
||||
private BigDecimal saleAmount;
|
||||
@ApiModelProperty(value = "单据日期")
|
||||
private Date voucherDate;
|
||||
private Integer day;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.xkt.dto.store;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||
import com.ruoyi.xkt.domain.DailySaleCustomer;
|
||||
import com.ruoyi.xkt.dto.dailySale.DailySaleCusDTO;
|
||||
import com.ruoyi.xkt.dto.store.StoreIndexCusSaleTop10ResDTO;
|
||||
import com.ruoyi.xkt.dto.store.StoreIndexOverviewResDTO;
|
||||
import com.ruoyi.xkt.dto.store.StoreSaleCustomerTop10DTO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
|
@ -21,9 +23,24 @@ public interface DailySaleCustomerMapper extends BaseMapper<DailySaleCustomer> {
|
|||
/**
|
||||
* 档口客户销售榜前10
|
||||
*
|
||||
* @param saleCusTop10DTO 查询入参
|
||||
* @param storeId storeId
|
||||
* @param voucherDateStart 开始时间
|
||||
* @param voucherDateEnd 结束时间
|
||||
* @return List<StoreIndexCustomerSaleTop10ResDTO>
|
||||
*/
|
||||
List<StoreIndexCusSaleTop10ResDTO> selectTop10SaleCustomerList(StoreSaleCustomerTop10DTO saleCusTop10DTO);
|
||||
List<StoreIndexCusSaleTop10ResDTO> selectTop10SaleCustomerList(@Param("storeId") Long storeId,
|
||||
@Param("voucherDateStart") String voucherDateStart,
|
||||
@Param("voucherDateEnd") String voucherDateEnd);
|
||||
|
||||
/**
|
||||
* 筛选销售额最大的客户
|
||||
*
|
||||
* @param storeId 档口ID
|
||||
* @param voucherDateStart 开始时间
|
||||
* @param voucherDateEnd 结束时间
|
||||
* @return StoreIndexOverviewResDTO
|
||||
*/
|
||||
StoreIndexOverviewResDTO getMaxSaleCus(@Param("storeId") Long storeId,
|
||||
@Param("voucherDateStart") String voucherDateStart,
|
||||
@Param("voucherDateEnd") String voucherDateEnd);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import com.ruoyi.xkt.dto.dailySale.DailySaleProdDTO;
|
|||
import com.ruoyi.xkt.dto.dailyStoreProd.DailyStoreProdSaleDTO;
|
||||
import com.ruoyi.xkt.dto.dailyStoreTag.DailyStoreTagDTO;
|
||||
import com.ruoyi.xkt.dto.store.StoreIndexSaleTop10ResDTO;
|
||||
import com.ruoyi.xkt.dto.store.StoreSaleTop10DTO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
|
|
@ -40,10 +39,14 @@ public interface DailySaleProductMapper extends BaseMapper<DailySaleProduct> {
|
|||
/**
|
||||
* 获取档口首页商品销量前10
|
||||
*
|
||||
* @param saleTop10DTO 查询入参
|
||||
* @param storeId storeId
|
||||
* @param voucherDateStart 开始时间
|
||||
* @param voucherDateEnd 结束时间
|
||||
* @return List<StoreIndexSaleTop10ResDTO>
|
||||
*/
|
||||
List<StoreIndexSaleTop10ResDTO> selectTop10SaleList(StoreSaleTop10DTO saleTop10DTO);
|
||||
List<StoreIndexSaleTop10ResDTO> selectTop10SaleList(@Param("storeId") Long storeId,
|
||||
@Param("voucherDateStart") String voucherDateStart,
|
||||
@Param("voucherDateEnd") String voucherDateEnd);
|
||||
|
||||
/**
|
||||
* 获取爆款频出的前50商品及档口
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.ruoyi.xkt.service.impl;
|
|||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import co.elastic.clients.elasticsearch.core.BulkResponse;
|
||||
import co.elastic.clients.elasticsearch.core.bulk.BulkOperation;
|
||||
|
|
@ -274,12 +275,16 @@ public class StoreServiceImpl implements IStoreService {
|
|||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public StoreIndexOverviewResDTO indexOverview(StoreOverviewDTO overviewDTO) {
|
||||
List<DailySale> saleList = this.dailySaleMapper.selectList(new LambdaQueryWrapper<DailySale>()
|
||||
.eq(DailySale::getStoreId, overviewDTO.getStoreId()).eq(DailySale::getDelFlag, Constants.UNDELETED)
|
||||
.between(DailySale::getVoucherDate, overviewDTO.getVoucherDateStart(), overviewDTO.getVoucherDateEnd()));
|
||||
if (CollectionUtils.isEmpty(saleList)) {
|
||||
return new StoreIndexOverviewResDTO();
|
||||
}
|
||||
final String voucherDateStart = DateUtil.formatDate(overviewDTO.getVoucherDateStart());
|
||||
final String voucherDateEnd = DateUtil.formatDate(overviewDTO.getVoucherDateEnd());
|
||||
// 档口销售数据
|
||||
List<DailySale> saleList = Optional.ofNullable(this.dailySaleMapper.selectList(new LambdaQueryWrapper<DailySale>()
|
||||
.eq(DailySale::getStoreId, overviewDTO.getStoreId()).eq(DailySale::getDelFlag, Constants.UNDELETED)
|
||||
.between(DailySale::getVoucherDate, voucherDateStart, voucherDateEnd)))
|
||||
.orElse(Collections.emptyList());
|
||||
saleList = CollectionUtils.isNotEmpty(saleList) ? saleList : Collections.emptyList();
|
||||
// 最大销售额客户
|
||||
StoreIndexOverviewResDTO maxSaleCus = this.dailySaleCusMapper.getMaxSaleCus(overviewDTO.getStoreId(), voucherDateStart, voucherDateEnd);
|
||||
// 总的销售出库金额
|
||||
BigDecimal saleAmount = saleList.stream().map(x -> ObjectUtils.defaultIfNull(x.getSaleAmount(), BigDecimal.ZERO)).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
// 总的销售退货金额
|
||||
|
|
@ -293,7 +298,9 @@ public class StoreServiceImpl implements IStoreService {
|
|||
// 总的累计客户数
|
||||
Integer customerNum = saleList.stream().map(x -> ObjectUtils.defaultIfNull(x.getCustomerNum(), 0)).reduce(0, Integer::sum);
|
||||
return new StoreIndexOverviewResDTO().setSaleAmount(saleAmount).setRefundAmount(refundAmount).setSaleNum(saleNum).setRefundNum(refundNum)
|
||||
.setStorageNum(storageNum).setCustomerNum(customerNum);
|
||||
.setStorageNum(storageNum).setCustomerNum(customerNum).setStoreId(overviewDTO.getStoreId())
|
||||
.setTopSaleCusName(ObjectUtils.isNotEmpty(maxSaleCus) ? maxSaleCus.getTopSaleCusName() : "")
|
||||
.setTopSaleCusAmount(ObjectUtils.isNotEmpty(maxSaleCus) ? maxSaleCus.getTopSaleCusAmount() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -305,10 +312,16 @@ public class StoreServiceImpl implements IStoreService {
|
|||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<StoreIndexSaleRevenueResDTO> indexSaleRevenue(StoreSaleRevenueDTO revenueDTO) {
|
||||
List<DailySale> saleList = this.dailySaleMapper.selectList(new LambdaQueryWrapper<DailySale>()
|
||||
.eq(DailySale::getStoreId, revenueDTO.getStoreId()).eq(DailySale::getDelFlag, Constants.UNDELETED)
|
||||
.between(DailySale::getVoucherDate, revenueDTO.getVoucherDateStart(), revenueDTO.getVoucherDateEnd()));
|
||||
return BeanUtil.copyToList(saleList, StoreIndexSaleRevenueResDTO.class);
|
||||
final String voucherDateStart = DateUtil.formatDate(revenueDTO.getVoucherDateStart());
|
||||
final String voucherDateEnd = DateUtil.formatDate(revenueDTO.getVoucherDateEnd());
|
||||
List<DailySale> saleList = Optional.ofNullable(this.dailySaleMapper.selectList(new LambdaQueryWrapper<DailySale>()
|
||||
.eq(DailySale::getStoreId, revenueDTO.getStoreId()).eq(DailySale::getDelFlag, Constants.UNDELETED)
|
||||
.between(DailySale::getVoucherDate, voucherDateStart, voucherDateEnd)))
|
||||
.orElse(Collections.emptyList());
|
||||
return saleList.stream().map(x -> BeanUtil.toBean(x, StoreIndexSaleRevenueResDTO.class)
|
||||
.setDay(x.getVoucherDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate().getDayOfMonth()))
|
||||
.sorted(Comparator.comparingInt(StoreIndexSaleRevenueResDTO::getDay))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -412,7 +425,8 @@ public class StoreServiceImpl implements IStoreService {
|
|||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<StoreIndexSaleTop10ResDTO> indexTop10Sale(StoreSaleTop10DTO saleTop10DTO) {
|
||||
return this.dailySaleProdMapper.selectTop10SaleList(saleTop10DTO);
|
||||
return this.dailySaleProdMapper.selectTop10SaleList(saleTop10DTO.getStoreId(),
|
||||
DateUtil.formatDate(saleTop10DTO.getVoucherDateStart()), DateUtil.formatDate(saleTop10DTO.getVoucherDateEnd()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -424,7 +438,8 @@ public class StoreServiceImpl implements IStoreService {
|
|||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<StoreIndexCusSaleTop10ResDTO> indexTop10SaleCus(StoreSaleCustomerTop10DTO saleCusTop10DTO) {
|
||||
return this.dailySaleCusMapper.selectTop10SaleCustomerList(saleCusTop10DTO);
|
||||
return this.dailySaleCusMapper.selectTop10SaleCustomerList(saleCusTop10DTO.getStoreId(),
|
||||
DateUtil.formatDate(saleCusTop10DTO.getVoucherDateStart()), DateUtil.formatDate(saleCusTop10DTO.getVoucherDateEnd()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue