汇总部分数据,分类逻辑更改,规格去空格
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package cn.ysk.cashier.controller.shop;
|
||||
|
||||
import cn.ysk.cashier.service.SummaryService;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/summary")
|
||||
public class SummaryController {
|
||||
@Resource
|
||||
private SummaryService summaryService;
|
||||
@GetMapping
|
||||
private Object shopSummary(@RequestParam Integer shopId){
|
||||
return summaryService.selectSummary(shopId);
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package cn.ysk.cashier.controller.shop;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.ysk.cashier.annotation.Log;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopPurveyorTransact;
|
||||
import cn.ysk.cashier.service.shop.TbShopPurveyorTransactService;
|
||||
|
||||
@@ -2,7 +2,9 @@ package cn.ysk.cashier.dto.shop;
|
||||
|
||||
import lombok.Data;
|
||||
import cn.ysk.cashier.pojo.product.TbShopCategory;
|
||||
import reactor.util.annotation.Nullable;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -10,14 +12,16 @@ import java.util.List;
|
||||
*/
|
||||
@Data
|
||||
public class PrintConfig {
|
||||
@NotNull(message = "设备尺寸不能为空")
|
||||
private String width;
|
||||
@NotNull(message = "打印份数不能为空")
|
||||
private String printerNum;
|
||||
|
||||
private List<TbShopCategory> categoryList;
|
||||
|
||||
private String model;
|
||||
|
||||
@NotNull(message = "尾部留空需设置")
|
||||
private String feet;
|
||||
|
||||
@NotNull(message = "自动切刀0开启1关闭")
|
||||
private String autoCut;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package cn.ysk.cashier.pojo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author lyf
|
||||
*/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name = "tb_shop_user_duty")
|
||||
public class TbShopUserDuty implements Serializable {
|
||||
@Id
|
||||
@Column(name = "`id`")
|
||||
@ApiModelProperty(value = "自增id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
@Column(name = "user_id")
|
||||
@ApiModelProperty(value = "员工id")
|
||||
private Integer userId;
|
||||
|
||||
@Column(name = "login_time")
|
||||
@ApiModelProperty(value = "登录时间")
|
||||
private Timestamp loginTime;
|
||||
|
||||
@Column(name = "order_num")
|
||||
@ApiModelProperty(value = "订单数量")
|
||||
private Integer orderNum;
|
||||
|
||||
@Column(name = "amount")
|
||||
@ApiModelProperty(value = "总收入")
|
||||
private BigDecimal amount;
|
||||
|
||||
@Column(name = "login_out_time")
|
||||
@ApiModelProperty(value = "登出时间")
|
||||
private Timestamp loginOutTime;
|
||||
|
||||
@Column(name = "user_name")
|
||||
@ApiModelProperty(value = "员工名称")
|
||||
private String userName;
|
||||
|
||||
@Column(name = "status")
|
||||
@ApiModelProperty(value = "0:营业中,1:已交班")
|
||||
private String status;
|
||||
|
||||
@Column(name = "income_amount")
|
||||
@ApiModelProperty(value = "当班收入")
|
||||
private BigDecimal incomeAmount;
|
||||
|
||||
@Column(name = "shop_id")
|
||||
@ApiModelProperty(value = "shopId")
|
||||
private Integer shopId;
|
||||
|
||||
@Column(name = "petty_cash")
|
||||
@ApiModelProperty(value = "备用金")
|
||||
private BigDecimal pettyCash;
|
||||
|
||||
@Column(name = "hand_amount")
|
||||
@ApiModelProperty(value = "上交金额")
|
||||
private BigDecimal handAmount;
|
||||
|
||||
@Column(name = "equipment")
|
||||
@ApiModelProperty(value = "设备")
|
||||
private String equipment;
|
||||
|
||||
@Column(name = "token_id")
|
||||
@ApiModelProperty(value = "tokenId")
|
||||
private Integer tokenId;
|
||||
|
||||
@Column(name = "return_amount")
|
||||
@ApiModelProperty(value = "退单金额")
|
||||
private BigDecimal returnAmount;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package cn.ysk.cashier.pojo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author 12847
|
||||
*/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name = "tb_shop_user_duty_detail")
|
||||
public class TbShopUserDutyDetail implements Serializable {
|
||||
@Id
|
||||
@Column(name = "`id`")
|
||||
@ApiModelProperty(value = "自增id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
@Column(name = "duty_id")
|
||||
@ApiModelProperty(value = "值班ID")
|
||||
private Integer dutyId;
|
||||
|
||||
@Column(name = "product_id")
|
||||
@ApiModelProperty(value = "商品ID")
|
||||
private Integer productId;
|
||||
|
||||
@Column(name = "product_name")
|
||||
@ApiModelProperty(value = "商品名称")
|
||||
private String productName;
|
||||
@Column(name = "sku_id")
|
||||
@ApiModelProperty(value = "规格ID")
|
||||
private Integer skuId;
|
||||
|
||||
@Column(name = "sku_name")
|
||||
@ApiModelProperty(value = "规格名称")
|
||||
private Integer skuName;
|
||||
|
||||
@Column(name = "num")
|
||||
@ApiModelProperty(value = "规格名称")
|
||||
private Integer num;
|
||||
@Column(name = "amount")
|
||||
@ApiModelProperty(value = "商品金额小计")
|
||||
private BigDecimal amount;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.ysk.cashier.repository;
|
||||
|
||||
import cn.ysk.cashier.pojo.TbShopUserDutyDetail;
|
||||
import cn.ysk.cashier.vo.ProductVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
public interface ShopUserDutyDetailRepository extends JpaRepository<TbShopUserDutyDetail, Integer> {
|
||||
|
||||
@Query(value = "SELECT" +
|
||||
" product.product_id as productId, product.product_name as productName, SUM(product.num) as productNum" +
|
||||
" FROM" +
|
||||
" tb_shop_user_duty_detail AS product" +
|
||||
" LEFT JOIN tb_shop_user_duty AS user ON product.duty_id = USER.id " +
|
||||
"WHERE user.shop_id = :shopId" +
|
||||
" GROUP BY product.product_id" +
|
||||
" Limit 5", nativeQuery = true)
|
||||
List<Object[]> searchByDutyId(@Param("shopId") Integer shopId);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package cn.ysk.cashier.repository;
|
||||
|
||||
|
||||
import cn.ysk.cashier.pojo.TbShopUserDuty;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import javax.persistence.Tuple;
|
||||
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
public interface ShopUserDutyRepository extends JpaRepository<TbShopUserDuty, Integer>{
|
||||
@Query("SELECT SUM(detail.orderNum), SUM(detail.amount) " +
|
||||
"FROM TbShopUserDuty detail " +
|
||||
"WHERE detail.shopId = :shopId")
|
||||
Tuple sumByShopId(@Param("shopId") Integer shopId);
|
||||
|
||||
}
|
||||
@@ -38,6 +38,6 @@ public interface TbShopCategoryRepository extends JpaRepository<TbShopCategory,
|
||||
@Query("SELECT category FROM TbShopCategory category where category.tree IN :ids and category.id != category.tree")
|
||||
List<TbShopCategory> findChildren(@Param("ids")List<Integer> ids);
|
||||
|
||||
@Query(" SELECT category FROM TbShopCategory category where category.shopId = :shopId and category.id = category.tree")
|
||||
@Query(" SELECT category FROM TbShopCategory category where category.shopId = :shopId")
|
||||
Page<TbShopCategory> findAllBy(@Param("shopId") String shopId,Pageable pageable);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.ysk.cashier.service;
|
||||
|
||||
import cn.ysk.cashier.vo.SummaryVO;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
public interface SummaryService {
|
||||
SummaryVO selectSummary(Integer shop);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package cn.ysk.cashier.service.impl;
|
||||
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.ysk.cashier.repository.ShopUserDutyDetailRepository;
|
||||
import cn.ysk.cashier.repository.ShopUserDutyRepository;
|
||||
import cn.ysk.cashier.service.SummaryService;
|
||||
import cn.ysk.cashier.vo.SummaryVO;
|
||||
import cn.ysk.cashier.vo.ProductVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.persistence.Tuple;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SummaryServiceImpl implements SummaryService {
|
||||
@Resource
|
||||
private ShopUserDutyRepository shopUserDutyRepository;
|
||||
@Resource
|
||||
private ShopUserDutyDetailRepository shopUserDutyDetailRepository;
|
||||
@Override
|
||||
public SummaryVO selectSummary(Integer shopId) {
|
||||
SummaryVO summaryVO = new SummaryVO();
|
||||
//支付笔数
|
||||
Tuple result = shopUserDutyRepository.sumByShopId(shopId);
|
||||
summaryVO.setPaymentsNumber(result.get(0, Long.class));
|
||||
summaryVO.setTotalSales(result.get(1, BigDecimal.class));
|
||||
List<Object[]> objects = shopUserDutyDetailRepository.searchByDutyId(shopId);
|
||||
|
||||
List<ProductVO> list = new ArrayList<>();
|
||||
for (Object[] o :objects) {
|
||||
ProductVO productVO = new ProductVO();
|
||||
productVO.setProductId((Integer) o[0]);
|
||||
productVO.setProductName((String) o[1]);
|
||||
productVO.setProductNum((BigDecimal)o[2]);
|
||||
list.add(productVO);
|
||||
}
|
||||
summaryVO.setProductInfoList(list);
|
||||
summaryVO.setAverageSales(summaryVO.getTotalSales().divide(new BigDecimal(summaryVO.getPaymentsNumber()),2, RoundingMode.DOWN));
|
||||
return summaryVO;
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,7 @@ public class TbProductSpecServiceImpl implements TbProductSpecService {
|
||||
}
|
||||
TbProductSpec tbProductSpec = new TbProductSpec();
|
||||
tbProductSpec.setName(specDto.getName());
|
||||
tbProductSpec.setSpecList(specDto.getSpecList().toString().trim());
|
||||
tbProductSpec.setSpecList(specDto.getSpecList().toString().replace(" ", ""));
|
||||
tbProductSpec.setShopId(specDto.getShopId());
|
||||
tbProductSpec.setCreatedAt(Instant.now().toEpochMilli());
|
||||
tbProductSpec.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
|
||||
@@ -62,7 +62,7 @@ public class TbShopCategoryServiceImpl implements TbShopCategoryService {
|
||||
// Page<TbShopCategory> page = tbShopCategoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by("sort"));
|
||||
Page<TbShopCategory> page = tbShopCategoryRepository.findAllBy(criteria.getShopId(), pageable);
|
||||
tbShopCategoryRepository.findAllBy(criteria.getShopId(),pageable);
|
||||
// tbShopCategoryRepository.findAllBy(criteria.getShopId(),pageable);
|
||||
|
||||
List<Integer> treeId = new ArrayList<>();
|
||||
for (TbShopCategory category : page.getContent()) {
|
||||
@@ -119,7 +119,6 @@ public class TbShopCategoryServiceImpl implements TbShopCategoryService {
|
||||
}else {
|
||||
resources.setTree(Integer.valueOf(resources.getPid().trim()));
|
||||
}
|
||||
|
||||
ValidationUtil.isNull(resources.getId(),"TbShopCategory","id",resources.getId());
|
||||
return tbShopCategoryRepository.save(resources);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package cn.ysk.cashier.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
/**
|
||||
* 商品销量
|
||||
* @author lyf
|
||||
*/
|
||||
@Data
|
||||
public class ProductVO {
|
||||
|
||||
private Integer productId;
|
||||
|
||||
private String productName;
|
||||
|
||||
private BigDecimal productNum;
|
||||
|
||||
|
||||
public Integer getProductId() {
|
||||
return productId;
|
||||
}
|
||||
|
||||
public void setProductId(Integer productId) {
|
||||
this.productId = productId;
|
||||
}
|
||||
|
||||
public String getProductName() {
|
||||
return productName;
|
||||
}
|
||||
|
||||
public void setProductName(String productName) {
|
||||
this.productName = productName;
|
||||
}
|
||||
|
||||
public BigDecimal getProductNum() {
|
||||
return productNum;
|
||||
}
|
||||
|
||||
public void setProductNum(BigDecimal productNum) {
|
||||
this.productNum = productNum;
|
||||
}
|
||||
|
||||
public ProductVO() {
|
||||
this.productId = productId;
|
||||
this.productName = productName;
|
||||
this.productNum = productNum;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package cn.ysk.cashier.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
@Data
|
||||
public class SummaryVO {
|
||||
/**
|
||||
* 总销售额
|
||||
*/
|
||||
private BigDecimal totalSales;
|
||||
/**
|
||||
* 今日销售额
|
||||
*/
|
||||
private BigDecimal todaySales;
|
||||
/**
|
||||
* 平均每单
|
||||
*/
|
||||
private BigDecimal averageSales;
|
||||
/**
|
||||
* 支付笔数
|
||||
*/
|
||||
private Long paymentsNumber;
|
||||
/**
|
||||
* 今天支付笔数
|
||||
*/
|
||||
private Integer todayPaymentsNumber;
|
||||
/**
|
||||
* 商品统计数据
|
||||
*/
|
||||
private List<ProductVO> productInfoList;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user