数据报表 按分类和商品名称筛选
统计增加 按现金支付统计 用户列表返回数据更新
This commit is contained in:
@@ -1,14 +1,13 @@
|
|||||||
package cn.ysk.cashier.dto;
|
package cn.ysk.cashier.dto;
|
||||||
|
|
||||||
import cn.ysk.cashier.utils.DateUtil;
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class ShopSummaryDto {
|
public class ShopSummaryDto {
|
||||||
private String shopId;
|
private String shopId;
|
||||||
|
private String proName;
|
||||||
private Integer type;
|
private Integer type;
|
||||||
|
private Integer cateId;
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date startTime;
|
private Date startTime;
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
@@ -22,6 +21,14 @@ public class ShopSummaryDto {
|
|||||||
this.shopId = shopId;
|
this.shopId = shopId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getProName() {
|
||||||
|
return proName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProName(String proName) {
|
||||||
|
this.proName = proName;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getType() {
|
public Integer getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
@@ -30,6 +37,14 @@ public class ShopSummaryDto {
|
|||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getCateId() {
|
||||||
|
return cateId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCateId(Integer cateId) {
|
||||||
|
this.cateId = cateId;
|
||||||
|
}
|
||||||
|
|
||||||
public Date getStartTime() {
|
public Date getStartTime() {
|
||||||
return startTime;
|
return startTime;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,16 +45,22 @@ public interface TbOrderDetailRepository extends JpaRepository<TbOrderDetail, In
|
|||||||
@Query("SELECT new cn.ysk.cashier.vo.TbOrderSalesCountByDayVo(" +
|
@Query("SELECT new cn.ysk.cashier.vo.TbOrderSalesCountByDayVo(" +
|
||||||
"info.productName," +
|
"info.productName," +
|
||||||
"info.productSkuName," +
|
"info.productSkuName," +
|
||||||
|
"cate.name as cateName,"+
|
||||||
"SUM( CASE WHEN info.status = 'closed' THEN info.num ELSE 0 END ) as salesNum," +
|
"SUM( CASE WHEN info.status = 'closed' THEN info.num ELSE 0 END ) as salesNum," +
|
||||||
"SUM( CASE WHEN info.status = 'refund' THEN info.num ELSE 0 END )," +
|
"SUM( CASE WHEN info.status = 'refund' THEN info.num ELSE 0 END )," +
|
||||||
"SUM( info.num )) " +
|
"SUM( info.num )) " +
|
||||||
"FROM TbOrderDetail info " +
|
"FROM TbOrderDetail info " +
|
||||||
|
"LEFT JOIN TbProduct pro on info.productId=pro.id " +
|
||||||
|
"LEFT JOIN TbShopCategory cate on cate.id=pro.categoryId " +
|
||||||
"WHERE info.shopId = :shopId " +
|
"WHERE info.shopId = :shopId " +
|
||||||
|
"AND (pro.categoryId = IFNULL(:cateId, pro.categoryId))" +
|
||||||
|
"AND (info.productName = IFNULL(:proName, info.productName))" +
|
||||||
"AND info.createTime > :startTime AND info.createTime < :endTime " +
|
"AND info.createTime > :startTime AND info.createTime < :endTime " +
|
||||||
"AND ((info.status = 'closed') OR ( info.status ='refund')) " +
|
"AND ((info.status = 'closed') OR ( info.status ='refund')) " +
|
||||||
"GROUP BY info.productId,info.productSkuId " +
|
"GROUP BY info.productId,info.productSkuId " +
|
||||||
"ORDER BY salesNum DESC")
|
"ORDER BY salesNum DESC")
|
||||||
Page<TbOrderSalesCountByDayVo> queryTbOrderSalesCountByDay(@Param("shopId") Integer shopId, @Param("startTime") Date startTime, @Param("endTime") Date endTime, Pageable pageable);
|
Page<TbOrderSalesCountByDayVo> queryTbOrderSalesCountByDay(@Param("shopId") Integer shopId,@Param("cateId")Integer cateId,@Param("proName")String proName, @Param("startTime") Date startTime, @Param("endTime") Date endTime, Pageable pageable);
|
||||||
|
|
||||||
|
|
||||||
@Query("SELECT new cn.ysk.cashier.vo.TbOrderSalesCountByDayVo(" +
|
@Query("SELECT new cn.ysk.cashier.vo.TbOrderSalesCountByDayVo(" +
|
||||||
"info.productName," +
|
"info.productName," +
|
||||||
|
|||||||
@@ -146,13 +146,14 @@ public interface TbOrderInfoRepository extends JpaRepository<TbOrderInfo, Intege
|
|||||||
|
|
||||||
|
|
||||||
@Query("SELECT new cn.ysk.cashier.vo.TbOrderPayCountVo(" +
|
@Query("SELECT new cn.ysk.cashier.vo.TbOrderPayCountVo(" +
|
||||||
"'总金额'," +
|
"'现金支付'," +
|
||||||
"SUM( info.orderAmount)) " +
|
"SUM( info.orderAmount)) " +
|
||||||
"FROM TbOrderInfo info " +
|
"FROM TbOrderInfo info " +
|
||||||
"WHERE info.shopId = :shopId " +
|
"WHERE info.shopId = :shopId " +
|
||||||
"AND info.tradeDay > :startTime AND info.tradeDay < :endTime " +
|
"AND info.tradeDay > :startTime AND info.tradeDay < :endTime " +
|
||||||
|
"AND info.orderType = 'cash' " +
|
||||||
"AND ((info.status = 'closed') OR ( info.status ='refund' AND info.orderType != 'return' )) ")
|
"AND ((info.status = 'closed') OR ( info.status ='refund' AND info.orderType != 'return' )) ")
|
||||||
TbOrderPayCountVo queryOrderPayCountExt(@Param("shopId") String shopId, @Param("startTime") String startTime, @Param("endTime") String endTime);
|
TbOrderPayCountVo queryOrderPayCash(@Param("shopId") String shopId, @Param("startTime") Long startTime, @Param("endTime") Long endTime);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,7 @@ import java.util.List;
|
|||||||
public interface TbShopUserRepository extends JpaRepository<TbShopUser, Integer>,JpaSpecificationExecutor<TbShopUser> {
|
public interface TbShopUserRepository extends JpaRepository<TbShopUser, Integer>,JpaSpecificationExecutor<TbShopUser> {
|
||||||
|
|
||||||
|
|
||||||
@Query("SELECT NEW cn.ysk.cashier.vo.ShopUserInfoVo(su.id, su.isVip, u.nickName, u.headImg, u.telephone, su.updatedAt) " +
|
@Query("SELECT NEW cn.ysk.cashier.vo.ShopUserInfoVo(su.id, u.headImg, u.nickName, u.sex, u.amount, u.totalScore, u.telephone, u.birthDay, u.isVip, su.createdAt, u.lastLogInAt) " +
|
||||||
"FROM TbShopUser su " +
|
"FROM TbShopUser su " +
|
||||||
"LEFT JOIN TbUserInfo u " +
|
"LEFT JOIN TbUserInfo u " +
|
||||||
"on su.userId = CAST(u.id AS string) " +
|
"on su.userId = CAST(u.id AS string) " +
|
||||||
@@ -45,7 +45,7 @@ public interface TbShopUserRepository extends JpaRepository<TbShopUser, Integer>
|
|||||||
"AND su.shopId = :shopId")
|
"AND su.shopId = :shopId")
|
||||||
Page<ShopUserInfoVo> findShopUserJoinUserInfo(String shopId,Integer isVip,String phone, Pageable pageable);
|
Page<ShopUserInfoVo> findShopUserJoinUserInfo(String shopId,Integer isVip,String phone, Pageable pageable);
|
||||||
|
|
||||||
@Query("SELECT NEW cn.ysk.cashier.vo.ShopUserInfoVo(su.id, su.isVip, u.nickName, u.headImg, u.telephone, su.updatedAt) " +
|
@Query("SELECT NEW cn.ysk.cashier.vo.ShopUserInfoVo(su.id, u.headImg, u.nickName, u.sex, u.amount, u.totalScore, u.telephone, u.birthDay, u.isVip, su.createdAt, u.lastLogInAt) " +
|
||||||
"FROM TbShopUser su " +
|
"FROM TbShopUser su " +
|
||||||
"LEFT JOIN TbUserInfo u " +
|
"LEFT JOIN TbUserInfo u " +
|
||||||
"on su.userId = CAST(u.id AS string) " +
|
"on su.userId = CAST(u.id AS string) " +
|
||||||
|
|||||||
@@ -169,9 +169,9 @@ public class SummaryServiceImpl implements SummaryService {
|
|||||||
List<CountDateVO> numList = new ArrayList<>();
|
List<CountDateVO> numList = new ArrayList<>();
|
||||||
for (Object[] o : objects) {
|
for (Object[] o : objects) {
|
||||||
CountDateVO countDateVO = new CountDateVO();
|
CountDateVO countDateVO = new CountDateVO();
|
||||||
BigInteger integers = (BigInteger)o[1];
|
BigInteger integers = (BigInteger) o[1];
|
||||||
countDateVO.setCount(new BigDecimal(integers.toString()));
|
countDateVO.setCount(new BigDecimal(integers.toString()));
|
||||||
Date date =(Date)o[2];
|
Date date = (Date) o[2];
|
||||||
countDateVO.setTradeDay(date.toString());
|
countDateVO.setTradeDay(date.toString());
|
||||||
numList.add(countDateVO);
|
numList.add(countDateVO);
|
||||||
}
|
}
|
||||||
@@ -209,9 +209,9 @@ public class SummaryServiceImpl implements SummaryService {
|
|||||||
} else if (day == 1) {
|
} else if (day == 1) {
|
||||||
|
|
||||||
startTime = DateUtil.getDayBegin();
|
startTime = DateUtil.getDayBegin();
|
||||||
log.info("1天时间"+startTime.toString());
|
log.info("1天时间" + startTime.toString());
|
||||||
endTime = DateUtil.getDayEnd();
|
endTime = DateUtil.getDayEnd();
|
||||||
log.info("1天时间末"+endTime.toString());
|
log.info("1天时间末" + endTime.toString());
|
||||||
} else {
|
} else {
|
||||||
throw new BadRequestException("日期有误");
|
throw new BadRequestException("日期有误");
|
||||||
}
|
}
|
||||||
@@ -238,7 +238,7 @@ public class SummaryServiceImpl implements SummaryService {
|
|||||||
Tuple paySum = tbOrderInfoRepository.queryPaySumByDayAll(shopId.toString(), startTimeLong, endTimeLong);
|
Tuple paySum = tbOrderInfoRepository.queryPaySumByDayAll(shopId.toString(), startTimeLong, endTimeLong);
|
||||||
|
|
||||||
map.put("productCount", payCount == null ? 0 : payCount.get(0, BigDecimal.class));
|
map.put("productCount", payCount == null ? 0 : payCount.get(0, BigDecimal.class));
|
||||||
map.put("productSum", paySum == null ? 0 : paySum.get(0,BigDecimal.class));
|
map.put("productSum", paySum == null ? 0 : paySum.get(0, BigDecimal.class));
|
||||||
map.put("totalProduct", list);
|
map.put("totalProduct", list);
|
||||||
map.put("total", tuple1 == null ? 0 : tuple1.get(0, BigInteger.class));
|
map.put("total", tuple1 == null ? 0 : tuple1.get(0, BigInteger.class));
|
||||||
return map;
|
return map;
|
||||||
@@ -360,7 +360,7 @@ public class SummaryServiceImpl implements SummaryService {
|
|||||||
summaryDto.setStartTime(DateUtil.toDate(DateUtil.fromTimeStamp(1704038400L)));
|
summaryDto.setStartTime(DateUtil.toDate(DateUtil.fromTimeStamp(1704038400L)));
|
||||||
summaryDto.setEndTime(new Date());
|
summaryDto.setEndTime(new Date());
|
||||||
}
|
}
|
||||||
return (Page<T>) detailRepository.queryTbOrderSalesCountByDay(Integer.valueOf(summaryDto.getShopId()), summaryDto.getStartTime(), summaryDto.getEndTime(), pageable);
|
return (Page<T>) detailRepository.queryTbOrderSalesCountByDay(Integer.valueOf(summaryDto.getShopId()),summaryDto.getCateId(),summaryDto.getProName(), summaryDto.getStartTime(), summaryDto.getEndTime(), pageable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -394,6 +394,7 @@ public class SummaryServiceImpl implements SummaryService {
|
|||||||
for (TbOrderSalesCountByDayVo all : tbOrderSalesCountByDayVos) {
|
for (TbOrderSalesCountByDayVo all : tbOrderSalesCountByDayVos) {
|
||||||
Map<String, Object> map = new LinkedHashMap<>();
|
Map<String, Object> map = new LinkedHashMap<>();
|
||||||
map.put("商品名称", all.getProductName());
|
map.put("商品名称", all.getProductName());
|
||||||
|
map.put("商品分类", all.getCateName());
|
||||||
map.put("商品规格", StringUtils.isBlank(all.getProductSkuName()) ? "" : all.getProductSkuName());
|
map.put("商品规格", StringUtils.isBlank(all.getProductSkuName()) ? "" : all.getProductSkuName());
|
||||||
map.put("销量", all.getSalesNum());
|
map.put("销量", all.getSalesNum());
|
||||||
map.put("退单量", all.getRefNum());
|
map.put("退单量", all.getRefNum());
|
||||||
@@ -419,6 +420,9 @@ public class SummaryServiceImpl implements SummaryService {
|
|||||||
TbOrderPayCountVo payCount = tbOrderInfoRepository.queryOrderPayCount(shopId, start, end);
|
TbOrderPayCountVo payCount = tbOrderInfoRepository.queryOrderPayCount(shopId, start, end);
|
||||||
payCount.setIcon("el-icon-coin");
|
payCount.setIcon("el-icon-coin");
|
||||||
list.add(payCount);
|
list.add(payCount);
|
||||||
|
TbOrderPayCountVo cashCount = tbOrderInfoRepository.queryOrderPayCash(shopId, start, end);
|
||||||
|
cashCount.setIcon("el-icon-circle-check");
|
||||||
|
list.add(cashCount);
|
||||||
TbOrderPayCountVo refCount = tbOrderInfoRepository.queryTbOrderRefund(shopId, start, end);
|
TbOrderPayCountVo refCount = tbOrderInfoRepository.queryTbOrderRefund(shopId, start, end);
|
||||||
refCount.setPayType("退款金额");
|
refCount.setPayType("退款金额");
|
||||||
refCount.setIcon("el-icon-money");
|
refCount.setIcon("el-icon-money");
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class TbShopUserServiceImpl implements TbShopUserService {
|
|||||||
private final TbShopUserMapper tbShopUserMapper;
|
private final TbShopUserMapper tbShopUserMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> queryAllShopUser(TbShopUserQueryCriteria criteria, Pageable pageable) {
|
public Map<String, Object> queryShopUser(TbShopUserQueryCriteria criteria, Pageable pageable) {
|
||||||
Page<ShopUserInfoVo> shopUserJoinUserInfo =
|
Page<ShopUserInfoVo> shopUserJoinUserInfo =
|
||||||
tbShopUserRepository.findShopUserJoinUserInfo(
|
tbShopUserRepository.findShopUserJoinUserInfo(
|
||||||
criteria.getShopId(),
|
criteria.getShopId(),
|
||||||
@@ -64,7 +64,7 @@ public class TbShopUserServiceImpl implements TbShopUserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> queryShopUser(TbShopUserQueryCriteria criteria, Pageable pageable) {
|
public Map<String, Object> queryAllShopUser(TbShopUserQueryCriteria criteria, Pageable pageable) {
|
||||||
Page<ShopUserInfoVo> shopUserJoinUserInfo =
|
Page<ShopUserInfoVo> shopUserJoinUserInfo =
|
||||||
tbShopUserRepository.findAllShopUserJoinUserInfo(
|
tbShopUserRepository.findAllShopUserJoinUserInfo(
|
||||||
criteria.getIsVip(),
|
criteria.getIsVip(),
|
||||||
|
|||||||
@@ -18,34 +18,48 @@ package cn.ysk.cashier.vo;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Zheng Jie
|
|
||||||
* @date 2019-6-10 16:32:18
|
|
||||||
*/
|
|
||||||
@Data
|
@Data
|
||||||
public class ShopUserInfoVo implements Serializable {
|
public class ShopUserInfoVo implements Serializable {
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
private Integer isVip;
|
|
||||||
|
|
||||||
private String nickName;
|
|
||||||
|
|
||||||
private String headImg;
|
private String headImg;
|
||||||
|
private String nickName;
|
||||||
|
private Object sex;
|
||||||
|
private BigDecimal amount;
|
||||||
|
|
||||||
|
private Integer totalScore;
|
||||||
private String telephone;
|
private String telephone;
|
||||||
|
private String birthDay;
|
||||||
|
private Integer isVip;
|
||||||
|
private long createAt;
|
||||||
|
private long lastLoginAt;
|
||||||
|
|
||||||
private Long updatedAt;
|
public Object getSex() {
|
||||||
|
return sex;
|
||||||
public ShopUserInfoVo() {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShopUserInfoVo(Integer id, Integer isVip, String nickName, String headImg, String telephone, Long updatedAt) {
|
public void setSex(Object sex) {
|
||||||
|
if (sex == null) {
|
||||||
|
this.sex="未知";
|
||||||
|
}else if(sex.equals(1)){
|
||||||
|
this.sex = "男";
|
||||||
|
}else if(sex.equals(0)){
|
||||||
|
this.sex = "女";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopUserInfoVo(Integer id, String headImg, String nickName, Object sex, BigDecimal amount, Integer totalScore, String telephone, String birthDay, Integer isVip, long createAt, long lastLoginAt) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.isVip = isVip;
|
|
||||||
this.nickName = nickName;
|
|
||||||
this.headImg = headImg;
|
this.headImg = headImg;
|
||||||
|
this.nickName = nickName;
|
||||||
|
setSex(sex);
|
||||||
|
this.amount = amount;
|
||||||
|
this.totalScore = totalScore;
|
||||||
this.telephone = telephone;
|
this.telephone = telephone;
|
||||||
this.updatedAt = updatedAt;
|
this.birthDay = birthDay;
|
||||||
|
this.isVip = isVip;
|
||||||
|
this.createAt = createAt;
|
||||||
|
this.lastLoginAt = lastLoginAt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@ public class TbOrderSalesCountByDayVo {
|
|||||||
|
|
||||||
private String productName;
|
private String productName;
|
||||||
private String productSkuName;
|
private String productSkuName;
|
||||||
|
private String cateName;
|
||||||
private Long salesNum;
|
private Long salesNum;
|
||||||
private Long refNum;
|
private Long refNum;
|
||||||
private Long num;
|
private Long num;
|
||||||
@@ -26,6 +26,14 @@ public class TbOrderSalesCountByDayVo {
|
|||||||
this.productSkuName = productSkuName;
|
this.productSkuName = productSkuName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCateName() {
|
||||||
|
return cateName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCateName(String cateName) {
|
||||||
|
this.cateName = cateName;
|
||||||
|
}
|
||||||
|
|
||||||
public Long getSalesNum() {
|
public Long getSalesNum() {
|
||||||
return salesNum;
|
return salesNum;
|
||||||
}
|
}
|
||||||
@@ -57,4 +65,13 @@ public class TbOrderSalesCountByDayVo {
|
|||||||
this.refNum = refNum;
|
this.refNum = refNum;
|
||||||
this.num = num;
|
this.num = num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TbOrderSalesCountByDayVo(String productName, String productSkuName,String cateName, Long salesNum, Long refNum, Long num) {
|
||||||
|
this.productName = productName;
|
||||||
|
this.productSkuName = productSkuName;
|
||||||
|
this.cateName = cateName;
|
||||||
|
this.salesNum = salesNum;
|
||||||
|
this.refNum = refNum;
|
||||||
|
this.num = num;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user