17 changed files with 521 additions and 36 deletions
@ -0,0 +1,31 @@ |
|||
package cc.hiver.mall.pojo.vo; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
@ApiModel(value = "销售首页展示项") |
|||
@Data |
|||
public class SaleAllVO implements Serializable { |
|||
|
|||
@ApiModelProperty(value = "销售总额") |
|||
private BigDecimal totalAmount; |
|||
|
|||
@ApiModelProperty(value = "销售总笔数") |
|||
private int totalCount; |
|||
|
|||
@ApiModelProperty(value = "单笔最高金额") |
|||
private BigDecimal oneHighPrice; |
|||
|
|||
@ApiModelProperty(value = "销售总件数") |
|||
private int totalJCount; |
|||
|
|||
@ApiModelProperty(value = "销售总利润") |
|||
private BigDecimal totalProfit; |
|||
|
|||
@ApiModelProperty(value = "销售总客户数") |
|||
private int totalCCount; |
|||
} |
|||
@ -0,0 +1,96 @@ |
|||
package cc.hiver.mall.pojo.vo; |
|||
|
|||
import cc.hiver.core.common.utils.SnowFlakeUtil; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
import org.springframework.data.annotation.CreatedDate; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
|
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
import java.util.Date; |
|||
|
|||
@ApiModel(value = "销售单主表") |
|||
@Data |
|||
public class SaleCopyVO implements Serializable { |
|||
private String id; |
|||
|
|||
private String createBy; |
|||
|
|||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") |
|||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
private Date createTime; |
|||
|
|||
private Integer delFlag; |
|||
|
|||
private String updateBy; |
|||
|
|||
private Date updateTime; |
|||
|
|||
@ApiModelProperty(value = "客户ID") |
|||
private String userId; |
|||
|
|||
@ApiModelProperty(value = "店铺ID") |
|||
private String shopId; |
|||
|
|||
@ApiModelProperty(value = "订单金额") |
|||
private BigDecimal totalAmount; |
|||
|
|||
@ApiModelProperty(value = "折扣") |
|||
private BigDecimal discount; |
|||
|
|||
@ApiModelProperty(value = "优惠金额") |
|||
private BigDecimal discountAmount; |
|||
|
|||
@ApiModelProperty(value = "实收金额") |
|||
private BigDecimal realAmount; |
|||
|
|||
@ApiModelProperty(value = "已收") |
|||
private BigDecimal alreadyEarn; |
|||
|
|||
@ApiModelProperty(value = "未收") |
|||
private BigDecimal noEarn; |
|||
|
|||
@ApiModelProperty(value = "收款状态 0-未收款 1-已收款 2-部分收款") |
|||
private String payStatus; |
|||
|
|||
@ApiModelProperty(value = "订单状态 1-拣货中 2-已预定 3-已作废 4-已取货 5-已送达") |
|||
private String status; |
|||
|
|||
@ApiModelProperty(value = "物流类别 1-物流 2-自提 3-快递 4-拼单") |
|||
private String transportType; |
|||
|
|||
@ApiModelProperty(value = "拼单店铺地址 为拼单类别时手动输入") |
|||
private String shareAddress; |
|||
|
|||
@ApiModelProperty(value = "收货地址") |
|||
private String receiveAddress; |
|||
|
|||
@ApiModelProperty(value = "省") |
|||
private String province; |
|||
|
|||
@ApiModelProperty(value = "市") |
|||
private String city; |
|||
|
|||
@ApiModelProperty(value = "区县") |
|||
private String area; |
|||
|
|||
@ApiModelProperty(value = "物流公司") |
|||
private String transCompany; |
|||
|
|||
@ApiModelProperty(value = "客户名称") |
|||
private String customerName; |
|||
|
|||
@ApiModelProperty(value = "店铺名称") |
|||
private String shopName; |
|||
|
|||
@ApiModelProperty(value = "收货人电话") |
|||
private String recPhone; |
|||
|
|||
@ApiModelProperty(value = "扛包工名称") |
|||
private String workerName; |
|||
|
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
package cc.hiver.mall.service; |
|||
|
|||
import cc.hiver.mall.entity.ReturnSale; |
|||
import cc.hiver.mall.entity.Sale; |
|||
import cc.hiver.mall.pojo.dto.SaleDTO; |
|||
import cc.hiver.mall.pojo.dto.SaleQueryDTO; |
|||
import cc.hiver.mall.pojo.dto.SaleReturnDTO; |
|||
import cc.hiver.mall.pojo.vo.SaleAllVO; |
|||
import cc.hiver.mall.pojo.vo.SaleVO; |
|||
|
|||
public interface SalesCalculateService { |
|||
|
|||
public SaleAllVO calculateService(SaleVO saleVO); |
|||
|
|||
} |
|||
@ -0,0 +1,132 @@ |
|||
package cc.hiver.mall.serviceimpl; |
|||
|
|||
import cc.hiver.core.common.utils.ResultUtil; |
|||
import cc.hiver.core.common.utils.StringUtils; |
|||
import cc.hiver.core.common.vo.SearchDateVo; |
|||
import cc.hiver.mall.dao.mapper.ReturnDetailMapper; |
|||
import cc.hiver.mall.dao.mapper.ReturnSaleMapper; |
|||
import cc.hiver.mall.dao.mapper.SaleDetailMapper; |
|||
import cc.hiver.mall.dao.mapper.SaleMapper; |
|||
import cc.hiver.mall.entity.*; |
|||
import cc.hiver.mall.pojo.vo.SaleAllVO; |
|||
import cc.hiver.mall.pojo.vo.SaleVO; |
|||
import cc.hiver.mall.service.SalesCalculateService; |
|||
import cc.hiver.mall.service.mybatis.ReturnDetailService; |
|||
import cc.hiver.mall.service.mybatis.ReturnSaleService; |
|||
import cc.hiver.mall.service.mybatis.SaleDetailService; |
|||
import cc.hiver.mall.service.mybatis.SaleService; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import org.apache.http.client.utils.DateUtils; |
|||
import org.apache.poi.ss.usermodel.DateUtil; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.util.ObjectUtils; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.time.LocalDate; |
|||
import java.time.format.DateTimeFormatter; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
@Service |
|||
public class SalesCalculateServiceImpl implements SalesCalculateService { |
|||
|
|||
|
|||
@Autowired |
|||
private SaleService saleService; |
|||
|
|||
@Autowired |
|||
private SaleDetailService saleDetailService; |
|||
|
|||
@Autowired |
|||
private ReturnSaleService returnSaleService; |
|||
|
|||
@Autowired |
|||
private ReturnDetailService returnDetailService; |
|||
|
|||
@Autowired |
|||
private SaleMapper saleMapper; |
|||
|
|||
@Autowired |
|||
private SaleDetailMapper saleDetailMapper; |
|||
|
|||
@Autowired |
|||
private ReturnSaleMapper returnSaleMapper; |
|||
|
|||
@Autowired |
|||
private ReturnDetailMapper returnDetailMapper; |
|||
|
|||
|
|||
@Override |
|||
public SaleAllVO calculateService(SaleVO saleVO) { |
|||
SaleAllVO saleAllVO = new SaleAllVO(); |
|||
String shopId = saleVO.getShopId(); |
|||
|
|||
Date currentDate = DateUtil.parseYYYYMMDDDate(DateUtils.formatDate(new Date(),"yyyy-MM-dd")); |
|||
|
|||
//获取当日门店销售总额 销售笔数 销售总件数
|
|||
SaleExample saleExample = new SaleExample(); |
|||
saleExample.createCriteria() |
|||
.andCreateTimeGreaterThanOrEqualTo(currentDate) |
|||
//.andStatusEqualTo("5")
|
|||
.andShopIdEqualTo(shopId); |
|||
SaleAllVO saleAllVO1 = saleMapper.saleSumAndCount(saleExample); |
|||
|
|||
ReturnSaleExample returnSaleExample = new ReturnSaleExample(); |
|||
returnSaleExample.createCriteria() |
|||
.andCreateTimeGreaterThanOrEqualTo(currentDate) |
|||
//.andStatusEqualTo("5")
|
|||
.andShopIdEqualTo(shopId); |
|||
SaleAllVO returnAllVO1 = returnSaleMapper.saleSumAndCount(returnSaleExample); |
|||
|
|||
saleAllVO.setTotalAmount(saleAllVO1.getTotalAmount().subtract(returnAllVO1.getTotalAmount())); |
|||
saleAllVO.setTotalCount(saleAllVO1.getTotalCount()-returnAllVO1.getTotalCount()); |
|||
saleAllVO.setTotalJCount(saleAllVO1.getTotalJCount()-returnAllVO1.getTotalJCount()); |
|||
|
|||
|
|||
//获取门店单笔最高金额
|
|||
SaleExample saleExample1 = new SaleExample(); |
|||
saleExample1.createCriteria() |
|||
.andCreateTimeGreaterThanOrEqualTo1(currentDate) |
|||
//.andStatusEqualTo("5")
|
|||
.andShopIdEqualTo1(shopId); |
|||
SaleAllVO saleAllVO2 = saleMapper.saleMaxAmount(saleExample1); |
|||
saleAllVO.setOneHighPrice(saleAllVO2.getOneHighPrice()); |
|||
|
|||
//获取当日门店利润(当日总营收-当日总成本-(退货总营收-退货总成本))
|
|||
QueryWrapper<SaleDetail> queryWrapper = new QueryWrapper<>(); |
|||
queryWrapper.eq("shop_id",shopId) |
|||
.ge("create_time",currentDate); |
|||
BigDecimal totalPurchasePrice = new BigDecimal(0.0); |
|||
List<SaleDetail> list = saleDetailService.list(queryWrapper); |
|||
for(SaleDetail saleDetail : list){ |
|||
BigDecimal purchasePrice = saleDetail.getPurchasePrice(); |
|||
int productCount = saleDetail.getProductCount(); |
|||
totalPurchasePrice = totalPurchasePrice.add(purchasePrice.multiply(new BigDecimal(productCount))); |
|||
} |
|||
QueryWrapper<ReturnDetail> returnDetailQueryWrapper = new QueryWrapper<>(); |
|||
queryWrapper.eq("shop_id",shopId) |
|||
.ge("create_time",currentDate); |
|||
BigDecimal totalReturnPurchasePrice = new BigDecimal(0.0); |
|||
List<ReturnDetail> returnDetails = returnDetailService.list(returnDetailQueryWrapper); |
|||
for(ReturnDetail returnDetail : returnDetails){ |
|||
BigDecimal purchasePrice = returnDetail.getPurchasePrice(); |
|||
int productCount = returnDetail.getProductCount(); |
|||
totalReturnPurchasePrice = totalReturnPurchasePrice.add(purchasePrice.multiply(new BigDecimal(productCount))); |
|||
} |
|||
saleAllVO.setTotalProfit(saleAllVO.getTotalAmount().subtract(totalPurchasePrice.subtract(totalReturnPurchasePrice))); |
|||
|
|||
//获取当日门店下单客户数
|
|||
QueryWrapper<Sale> querySaleWrapper = new QueryWrapper<>(); |
|||
querySaleWrapper.select("count(1)") |
|||
.eq("shop_id",shopId) |
|||
//.eq("status","5")
|
|||
.ge("create_time",currentDate) |
|||
.groupBy("user_id"); |
|||
List<Object> countCus = saleService.listObjs(querySaleWrapper); |
|||
int countCustomer = ((Long) countCus.get(0)).intValue(); |
|||
saleAllVO.setTotalCCount(countCustomer); |
|||
|
|||
return saleAllVO; |
|||
} |
|||
} |
|||
Loading…
Reference in new issue