Browse Source

提交首页展示接口

cangku
Houpn 3 years ago
parent
commit
f53bddce62
  1. 9
      hiver-core/src/main/java/cc/hiver/core/common/vo/SearchDateVo.java
  2. 3
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/OrderController.java
  3. 95
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SaleController.java
  4. 7
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ReturnSaleMapper.java
  5. 6
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleMapper.java
  6. 8
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/ReturnDetail.java
  7. 82
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/ReturnSale.java
  8. 14
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Sale.java
  9. 6
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/SaleDetail.java
  10. 9
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/SaleExample.java
  11. 31
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/SaleAllVO.java
  12. 96
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/SaleCopyVO.java
  13. 15
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/SalesCalculateService.java
  14. 14
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesAndDetailsServiceImpl.java
  15. 132
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesCalculateServiceImpl.java
  16. 12
      hiver-modules/hiver-mall/src/main/resources/mapper/ReturnSaleMapper.xml
  17. 18
      hiver-modules/hiver-mall/src/main/resources/mapper/SaleMapper.xml

9
hiver-core/src/main/java/cc/hiver/core/common/vo/SearchDateVo.java

@ -1,5 +1,6 @@
package cc.hiver.core.common.vo;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -26,6 +27,10 @@ public class SearchDateVo implements Serializable {
}
public void setStartDate(String startDate) {
if(!StrUtil.isNotEmpty(startDate)){
this.startDate = null;
return;
}
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
this.startDate = formatter.parse(startDate);
@ -39,6 +44,10 @@ public class SearchDateVo implements Serializable {
}
public void setEndDate(String endDate) {
if(!StrUtil.isNotEmpty(endDate)){
this.endDate = null;
return;
}
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
this.endDate = formatter.parse(endDate);

3
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/OrderController.java

@ -34,6 +34,7 @@ import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
@ -254,11 +255,13 @@ public class OrderController {
//更新下单表或者是退货单表
Sale sale = saleService.getById(orderQueryVO.getOrderId());
if(sale != null){
sale.setUpdateTime(new Date());
sale.setStatus(String.valueOf(orderStatus));
saleService.saveOrUpdate(sale);
}
ReturnSale returnSale = returnSaleService.getById(orderQueryVO.getOrderId());
if(returnSale != null){
sale.setUpdateTime(new Date());
returnSale.setStatus(String.valueOf(orderStatus));
returnSaleService.saveOrUpdate(returnSale);
}

95
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/SaleController.java

@ -4,6 +4,8 @@ import cc.hiver.core.common.utils.*;
import cc.hiver.core.common.vo.Result;
import cc.hiver.core.common.vo.SearchDateVo;
import cc.hiver.core.common.vo.SearchVo;
import cc.hiver.core.entity.Worker;
import cc.hiver.core.service.WorkerService;
import cc.hiver.mall.entity.*;
@ -28,6 +30,8 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -59,6 +63,18 @@ public class SaleController {
@Autowired
private CustomerService customerService;
@Autowired
private ShopService shopService;
@Autowired
private OrderService orderService;
@Autowired
private WorkerService workerService;
@Autowired
private SalesCalculateService salesCalculateService;
@Autowired
private SecurityUtil securityUtil;
@ -258,7 +274,7 @@ public class SaleController {
@RequestMapping(value = "/listCompany", method = RequestMethod.POST)
@ApiOperation(value = "根据物流公司属性获得列表")
public Result<List<Sale>> listCompany(@RequestBody SaleListVO saleVO) {
public Result<List<SaleCopyVO>> listCompany(@RequestBody SaleListVO saleVO) {
QueryWrapper<Sale> queryWrapper = new QueryWrapper<>();
if (!ObjectUtils.isEmpty(saleVO)){
if (!StringUtils.isEmpty(saleVO.getTransCompany())) queryWrapper.eq("trans_company",saleVO.getTransCompany());
@ -278,7 +294,82 @@ public class SaleController {
queryWrapper.orderByDesc("create_time");
}
List<Sale> saleList = saleService.list(queryWrapper);
return new ResultUtil<List<Sale>>().setData(saleList);
List<SaleCopyVO> saleCopyVOList = new ArrayList<>();
for(Sale sale : saleList){
SaleCopyVO saleCopyVO = new SaleCopyVO();
Customer customer = customerService.getById(sale.getUserId());
if(!ObjectUtils.isEmpty(customer)){
saleCopyVO.setCustomerName(customer.getName());
saleCopyVO.setRecPhone(customer.getPhone());
}
Shop shop = shopService.findById(sale.getShopId());
if(!ObjectUtils.isEmpty(shop)){
saleCopyVO.setShopName(shop.getShopName());
}
if(!"1".equals(sale.getStatus()) && !"2".equals(sale.getTransportType())){
OrderXd orderXd = orderService.findById(sale.getId());
if(!ObjectUtils.isEmpty(orderXd)){
Worker worker = workerService.findById(orderXd.getOrderByWorker());
saleCopyVO.setWorkerName(worker.getWorkerName());
}
}
BeanUtils.copyBeanProp(saleCopyVO,sale);
saleCopyVOList.add(saleCopyVO);
}
return new ResultUtil<List<SaleCopyVO>>().setData(saleCopyVOList);
}
@RequestMapping(value = "/getShopAll", method = RequestMethod.POST)
@ApiOperation(value = "获取首页门店展示项")
public Result<SaleAllVO> getShopToday(@RequestBody SaleVO saleVO) {
SaleAllVO saleAllVO = salesCalculateService.calculateService(saleVO);
return new ResultUtil<SaleAllVO>().setData(saleAllVO);
}
@RequestMapping(value = "/getAllSum", method = RequestMethod.POST)
@ApiOperation(value = "获取当日门店销售总额")
public String getShopTodayAllSum(@RequestBody SaleVO saleVO) {
QueryWrapper<Sale> queryWrapper = new QueryWrapper<>();
String shopId = saleVO.getShopId();
return null;
}
@RequestMapping(value = "/getAllCount", method = RequestMethod.POST)
@ApiOperation(value = "获取当日门店销售笔数")
public String getShopTodayAllCount(@RequestBody SaleVO saleVO) {
return null;
}
@RequestMapping(value = "/getOnePrice", method = RequestMethod.POST)
@ApiOperation(value = "获取当日门店单笔最高金额")
public String getShopTodayOnePrice(@RequestBody SaleVO saleVO) {
return null;
}
@RequestMapping(value = "/getAllJCount", method = RequestMethod.POST)
@ApiOperation(value = "获取当日门店销售总件数")
public String getShopTodayJCount(@RequestBody SaleVO saleVO) {
return null;
}
@RequestMapping(value = "/getAllProfit", method = RequestMethod.POST)
@ApiOperation(value = "获取当日门店销售总利润")
public String getShopTodayAllProfit(@RequestBody SaleVO saleVO) {
return null;
}
@RequestMapping(value = "/getAllCCount", method = RequestMethod.POST)
@ApiOperation(value = "获取当日门店销售总客户数")
public String getShopTodayAllCCount(@RequestBody SaleVO saleVO) {
return null;
}
}

7
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ReturnSaleMapper.java

@ -3,6 +3,8 @@ package cc.hiver.mall.dao.mapper;
import cc.hiver.mall.entity.ReturnDetail;
import cc.hiver.mall.entity.ReturnSale;
import cc.hiver.mall.entity.ReturnSaleExample;
import cc.hiver.mall.entity.SaleExample;
import cc.hiver.mall.pojo.vo.SaleAllVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@ -31,4 +33,9 @@ public interface ReturnSaleMapper extends BaseMapper<ReturnSale> {
int updateByPrimaryKeySelective(ReturnSale record);
int updateByPrimaryKey(ReturnSale record);
SaleAllVO saleSumAndCount(ReturnSaleExample returnSaleExample);
SaleAllVO saleMaxAmount(ReturnSaleExample returnSaleExample);
}

6
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/SaleMapper.java

@ -2,6 +2,7 @@ package cc.hiver.mall.dao.mapper;
import cc.hiver.mall.entity.Sale;
import cc.hiver.mall.entity.SaleExample;
import cc.hiver.mall.pojo.vo.SaleAllVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@ -30,4 +31,9 @@ public interface SaleMapper extends BaseMapper<Sale> {
int updateByPrimaryKeySelective(Sale record);
int updateByPrimaryKey(Sale record);
SaleAllVO saleSumAndCount(SaleExample example);
SaleAllVO saleMaxAmount(SaleExample example);
}

8
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/ReturnDetail.java

@ -27,7 +27,7 @@ public class ReturnDetail implements Serializable {
private String saleId;
@ApiModelProperty(value = "退货单ID")
private String ReturnSaleId;
private String returnSaleId;
@ApiModelProperty(value = "商品ID")
private String productId;
@ -231,11 +231,11 @@ public class ReturnDetail implements Serializable {
}
public String getReturnSaleId() {
return ReturnSaleId;
return returnSaleId;
}
public void setReturnSaleId(String returnSaleId) {
ReturnSaleId = returnSaleId;
this.returnSaleId = returnSaleId;
}
@Override
@ -248,7 +248,7 @@ public class ReturnDetail implements Serializable {
", updateBy='" + updateBy + '\'' +
", updateTime=" + updateTime +
", saleId='" + saleId + '\'' +
", ReturnSaleId='" + ReturnSaleId + '\'' +
", returnSaleId='" + returnSaleId + '\'' +
", productId='" + productId + '\'' +
", productName='" + productName + '\'' +
", unit='" + unit + '\'' +

82
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/ReturnSale.java

@ -29,6 +29,8 @@ public class ReturnSale implements Serializable {
private String updateBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
@ApiModelProperty(value = "客户ID")
@ -79,6 +81,13 @@ public class ReturnSale implements Serializable {
@ApiModelProperty(value = "区县")
private String area;
@ApiModelProperty(value = "物流公司")
private String transCompany;
@ApiModelProperty(value = "下单总件数")
private int productCount;
private static final long serialVersionUID = 1L;
public String getId() {
@ -265,37 +274,50 @@ public class ReturnSale implements Serializable {
this.area = area;
}
public String getTransCompany() {
return transCompany;
}
public void setTransCompany(String transCompany) {
this.transCompany = transCompany;
}
public int getProductCount() {
return productCount;
}
public void setProductCount(int productCount) {
this.productCount = productCount;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", saleId=").append(saleId);
sb.append(", createBy=").append(createBy);
sb.append(", createTime=").append(createTime);
sb.append(", delFlag=").append(delFlag);
sb.append(", updateBy=").append(updateBy);
sb.append(", updateTime=").append(updateTime);
sb.append(", userId=").append(userId);
sb.append(", shopId=").append(shopId);
sb.append(", totalAmount=").append(totalAmount);
sb.append(", discount=").append(discount);
sb.append(", discountAmount=").append(discountAmount);
sb.append(", realAmount=").append(realAmount);
sb.append(", alreadyEarn=").append(alreadyEarn);
sb.append(", noEarn=").append(noEarn);
sb.append(", payStatus=").append(payStatus);
sb.append(", status=").append(status);
sb.append(", transportType=").append(transportType);
sb.append(", shareAddress=").append(shareAddress);
sb.append(", receiveAddress=").append(receiveAddress);
sb.append(", province=").append(province);
sb.append(", city=").append(city);
sb.append(", area=").append(area);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
return "ReturnSale{" +
"id='" + id + '\'' +
", saleId='" + saleId + '\'' +
", createBy='" + createBy + '\'' +
", createTime=" + createTime +
", delFlag=" + delFlag +
", updateBy='" + updateBy + '\'' +
", updateTime=" + updateTime +
", userId='" + userId + '\'' +
", shopId='" + shopId + '\'' +
", totalAmount=" + totalAmount +
", discount=" + discount +
", discountAmount=" + discountAmount +
", realAmount=" + realAmount +
", alreadyEarn=" + alreadyEarn +
", noEarn=" + noEarn +
", payStatus='" + payStatus + '\'' +
", status='" + status + '\'' +
", transportType='" + transportType + '\'' +
", shareAddress='" + shareAddress + '\'' +
", receiveAddress='" + receiveAddress + '\'' +
", province='" + province + '\'' +
", city='" + city + '\'' +
", area='" + area + '\'' +
", transCompany='" + transCompany + '\'' +
", productCount=" + productCount +
'}';
}
}

14
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Sale.java

@ -28,6 +28,8 @@ public class Sale implements Serializable {
private String updateBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
@ApiModelProperty(value = "客户ID")
@ -82,6 +84,9 @@ public class Sale implements Serializable {
private String transCompany;
@ApiModelProperty(value = "下单总件数")
private int productCount;
private static final long serialVersionUID = 1L;
public String getId() {
@ -268,6 +273,14 @@ public class Sale implements Serializable {
this.transCompany = transCompany;
}
public int getProductCount() {
return productCount;
}
public void setProductCount(int productCount) {
this.productCount = productCount;
}
@Override
public String toString() {
return "Sale{" +
@ -294,6 +307,7 @@ public class Sale implements Serializable {
", city='" + city + '\'' +
", area='" + area + '\'' +
", transCompany='" + transCompany + '\'' +
", productCount=" + productCount +
'}';
}
}

6
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/SaleDetail.java

@ -2,8 +2,11 @@ package cc.hiver.mall.entity;
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 org.springframework.data.annotation.CreatedDate;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.math.BigDecimal;
@ -15,6 +18,9 @@ public class SaleDetail implements Serializable {
private String createBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@CreatedDate
private Date createTime;
private Integer delFlag;

9
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/SaleExample.java

@ -276,6 +276,11 @@ public class SaleExample {
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo1(Date value) {
addCriterion("t.create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Date value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
@ -581,6 +586,10 @@ public class SaleExample {
return (Criteria) this;
}
public Criteria andShopIdEqualTo1(String value) {
addCriterion("t.shop_id =", value, "shopId");
return (Criteria) this;
}
public Criteria andShopIdNotEqualTo(String value) {
addCriterion("shop_id <>", value, "shopId");
return (Criteria) this;

31
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/SaleAllVO.java

@ -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;
}

96
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/SaleCopyVO.java

@ -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;
}

15
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/SalesCalculateService.java

@ -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);
}

14
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesAndDetailsServiceImpl.java

@ -170,6 +170,8 @@ public class SalesAndDetailsServiceImpl implements SalesAndDetailsService {
List<SaleDetailDTO> saleDetailList = saleDTO.getSaleDetailList();
List<SaleDetail> saleDetailList2 = new ArrayList<SaleDetail>();
int productCount = 0;
for(SaleDetailDTO saleDetailDTO : saleDetailList){
String productId = saleDetailDTO.getProductId();
product =productService.getById(productId);
@ -185,10 +187,15 @@ public class SalesAndDetailsServiceImpl implements SalesAndDetailsService {
SaleDetail saleDetail = new SaleDetail();
saleDetailDTO.setAttributeList(saleDetailQueryDTO.getAttributeList());
saleDetailDTO.setProductCount(saleDetailQueryDTO.getProductCount());
productCount += saleDetailQueryDTO.getProductCount();
BeanUtils.copyBeanProp(saleDetail,saleDetailDTO);
saleDetail.setCreateTime(sale.getCreateTime());
saleDetail.setCreateBy(sale.getCreateBy());
saleDetailList2.add(saleDetail);
}
}
sale.setProductCount(productCount);
saleService.saveOrUpdate(sale);
saleDetailService.saveBatch(saleDetailList2);
return sale;
}
@ -217,6 +224,8 @@ public class SalesAndDetailsServiceImpl implements SalesAndDetailsService {
List<ReturnSaleDetailDTO> saleDetailList = saleDTO.getReturnSaleDetailList();
List<ReturnDetail> saleDetailList2 = new ArrayList<ReturnDetail>();
int productCount = 0;
for(ReturnSaleDetailDTO returnSaleDetailDTO : saleDetailList){
String productId = returnSaleDetailDTO.getProductId();
product =productService.getById(productId);
@ -233,10 +242,15 @@ public class SalesAndDetailsServiceImpl implements SalesAndDetailsService {
ReturnDetail returnDetail = new ReturnDetail();
returnSaleDetailDTO.setAttributeList(saleDetailQueryDTO.getAttributeList());
returnSaleDetailDTO.setProductCount(saleDetailQueryDTO.getProductCount());
productCount += saleDetailQueryDTO.getProductCount();
BeanUtils.copyBeanProp(returnDetail,returnSaleDetailDTO);
returnDetail.setCreateTime(returnSale.getCreateTime());
returnDetail.setCreateBy(returnSale.getCreateBy());
saleDetailList2.add(returnDetail);
}
}
returnSale.setProductCount(productCount);
returnSaleService.saveOrUpdate(returnSale);
returnDetailService.saveBatch(saleDetailList2);
return returnSale;
}

132
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/SalesCalculateServiceImpl.java

@ -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;
}
}

12
hiver-modules/hiver-mall/src/main/resources/mapper/ReturnSaleMapper.xml

@ -492,4 +492,16 @@
area = #{area,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<select id="saleSumAndCount" parameterType="cc.hiver.mall.entity.ReturnSaleExample" resultType="cc.hiver.mall.pojo.vo.SaleAllVO">
select IFNULL(Sum(real_amount),0) as totalAmount,count(1) as totalCount,IFNULL(SUM(product_count),0) as totalJCount from t_return_sale
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<select id="saleMaxAmount" parameterType="cc.hiver.mall.entity.ReturnSaleExample" resultType="cc.hiver.mall.pojo.vo.SaleAllVO">
select IFNULL(Max(real_amount),0) as oneHighPrice from t_return_sale
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
</mapper>

18
hiver-modules/hiver-mall/src/main/resources/mapper/SaleMapper.xml

@ -477,4 +477,22 @@
area = #{area,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<select id="saleSumAndCount" parameterType="cc.hiver.mall.entity.SaleExample" resultType="cc.hiver.mall.pojo.vo.SaleAllVO">
select IFNULL(Sum(real_amount),0) as totalAmount,count(1) as totalCount,IFNULL(SUM(product_count),0) as totalJCount from t_sale
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<select id="saleMaxAmount" parameterType="cc.hiver.mall.entity.SaleExample" resultType="cc.hiver.mall.pojo.vo.SaleAllVO">
select max(IFNULL(t.real_amount,0)-IFNULL(t1.real_amount,0)) as oneHighPrice from t_sale t left join t_return_sale t1 on t.id =t1.sale_id
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<select id="saleSumProfit" parameterType="cc.hiver.mall.entity.SaleExample" resultType="cc.hiver.mall.pojo.vo.SaleAllVO">
select IFNULL(purchasePrice,0)* IFNULL(real_amount,0) as oneHighPrice from t_sale
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
</mapper>
Loading…
Cancel
Save