数据统计加退款和充值
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package cn.ysk.cashier.mybatis.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("tb_member_in")
|
||||
public class TbMemberIn extends Model<TbMemberIn> {
|
||||
private Integer id;
|
||||
|
||||
private Integer userId;
|
||||
|
||||
private Integer merchantId;
|
||||
|
||||
private String code;
|
||||
|
||||
private BigDecimal amount;
|
||||
|
||||
private String status;
|
||||
|
||||
private String orderNo;
|
||||
|
||||
private String tradeNo;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date updateTime;
|
||||
|
||||
private Integer shopId;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbMemberIn;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
public interface TbMemberInMapper extends BaseMapper<TbMemberIn> {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbMemberIn;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
public interface TbMemberInService extends IService<TbMemberIn> {
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbMemberIn;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbMemberInMapper;
|
||||
import cn.ysk.cashier.mybatis.service.TbMemberInService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
@Service
|
||||
public class TbMemberInServiceImpl extends ServiceImpl<TbMemberInMapper, TbMemberIn> implements TbMemberInService {
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import javax.persistence.Tuple;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -82,6 +83,14 @@ public interface TbOrderInfoRepository extends JpaRepository<TbOrderInfo, Intege
|
||||
"GROUP BY info.tradeDay " +
|
||||
"ORDER BY info.tradeDay DESC")
|
||||
Page<TbOrderPayCountByDayVo> queryTbOrderPayCountByDay(@Param("shopId") String shopId, @Param("startTime") Long startTime, @Param("endTime") Long endTime, Pageable pageable);
|
||||
|
||||
// 查询退款总金额
|
||||
@Query("SELECT SUM(info.orderAmount) FROM TbOrderInfo info " +
|
||||
"WHERE info.shopId = :shopId AND info.status = 'refund' " +
|
||||
"AND info.orderType = 'return' " +
|
||||
"AND info.tradeDay = :tradeDay")
|
||||
BigDecimal queryRefundOrderAmountByTradeDay(@Param("shopId") String shopId, @Param("tradeDay") String tradeDay);
|
||||
|
||||
@Query(value = "SELECT " +
|
||||
"row_number() over (ORDER BY SUM(num) DESC) AS productId," +
|
||||
"product_name," +
|
||||
@@ -158,4 +167,4 @@ public interface TbOrderInfoRepository extends JpaRepository<TbOrderInfo, Intege
|
||||
TbOrderPayCountVo queryOrderPayCash(@Param("shopId") String shopId, @Param("startTime") Long startTime, @Param("endTime") Long endTime);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package cn.ysk.cashier.service.impl;
|
||||
import cn.ysk.cashier.dto.ShopSummaryDto;
|
||||
import cn.ysk.cashier.enums.PayTypeEnum;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.mybatis.entity.TbMemberIn;
|
||||
import cn.ysk.cashier.mybatis.service.TbMemberInService;
|
||||
import cn.ysk.cashier.repository.ShopUserDutyDetailRepository;
|
||||
import cn.ysk.cashier.repository.ShopUserDutyRepository;
|
||||
import cn.ysk.cashier.repository.TbTokenRepository;
|
||||
@@ -13,6 +15,7 @@ import cn.ysk.cashier.service.SummaryService;
|
||||
import cn.ysk.cashier.utils.DateUtil;
|
||||
import cn.ysk.cashier.utils.FileUtil;
|
||||
import cn.ysk.cashier.vo.*;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -51,6 +54,9 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
@Resource
|
||||
private TbTokenRepository tbTokenRepository;
|
||||
|
||||
@Resource
|
||||
private TbMemberInService tbMemberInService;
|
||||
|
||||
@Override
|
||||
public SummaryVO selectSummary(Integer shopId) {
|
||||
SummaryVO summaryVO = new SummaryVO();
|
||||
@@ -357,7 +363,27 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
start = summaryDto.getStartTime().getTime();
|
||||
end = summaryDto.getEndTime().getTime();
|
||||
}
|
||||
return (Page<T>) tbOrderInfoRepository.queryTbOrderPayCountByDay(summaryDto.getShopId(), start, end, pageable);
|
||||
Page<T> tPage = (Page<T>) tbOrderInfoRepository.queryTbOrderPayCountByDay(summaryDto.getShopId(), start, end, pageable);
|
||||
|
||||
tPage.getContent().forEach(t -> {
|
||||
TbOrderPayCountByDayVo tbOrderPayCountByDayVo = (TbOrderPayCountByDayVo) t;
|
||||
|
||||
QueryWrapper<TbMemberIn> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("status", "7");
|
||||
queryWrapper.eq("shop_id", summaryDto.getShopId());
|
||||
queryWrapper.ge("create_time", tbOrderPayCountByDayVo.getTradeDay() + " 00:00:00");
|
||||
queryWrapper.le("create_time", tbOrderPayCountByDayVo.getTradeDay() + " 23:59:59");
|
||||
// 会员充值金额 amount 求和
|
||||
queryWrapper.select("IFNULL (sum(amount), 0) AS amountTotal");
|
||||
|
||||
Map<String, Object> map = tbMemberInService.getMap(queryWrapper);
|
||||
|
||||
tbOrderPayCountByDayVo.setRecharge(new BigDecimal(map.get("amountTotal").toString()));
|
||||
BigDecimal decimal = tbOrderInfoRepository.queryRefundOrderAmountByTradeDay(summaryDto.getShopId(), tbOrderPayCountByDayVo.getTradeDay());
|
||||
tbOrderPayCountByDayVo.setRefund(decimal == null ? new BigDecimal("0.00") : decimal);
|
||||
});
|
||||
|
||||
return tPage;
|
||||
} else {//销量
|
||||
if (summaryDto.getStartTime() == null || summaryDto.getEndTime() == null) {
|
||||
summaryDto.setStartTime(DateUtil.toDate(DateUtil.fromTimeStamp(1704038400L)));
|
||||
|
||||
@@ -9,6 +9,8 @@ public class TbOrderPayCountByDayVo {
|
||||
private Object wxLite;
|
||||
private Object cash;
|
||||
private Object total;
|
||||
private Object recharge;
|
||||
private Object refund;
|
||||
|
||||
public String getTradeDay() {
|
||||
return tradeDay;
|
||||
@@ -58,6 +60,22 @@ public class TbOrderPayCountByDayVo {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public Object getRecharge() {
|
||||
return recharge;
|
||||
}
|
||||
|
||||
public void setRecharge(Object recharge) {
|
||||
this.recharge = recharge;
|
||||
}
|
||||
|
||||
public Object getRefund() {
|
||||
return refund;
|
||||
}
|
||||
|
||||
public void setRefund(Object refund) {
|
||||
this.refund = refund;
|
||||
}
|
||||
|
||||
public TbOrderPayCountByDayVo(String tradeDay, Object scanCode,Object deposit, Object wxLite, Object cash, Object total) {
|
||||
this.tradeDay = tradeDay;
|
||||
this.scanCode = scanCode;
|
||||
|
||||
Reference in New Issue
Block a user