vip统计收入项为开始时间或者支付时间

This commit is contained in:
wuchunlei
2025-09-22 11:09:05 +08:00
parent 2135bcb9fc
commit d5598218d8
4 changed files with 8 additions and 3 deletions

View File

@@ -24,6 +24,7 @@ public class UserVipLog implements Serializable {
private Integer userVipId;
//充值渠道order master等
private String type;
private Date payTime;
private String orderSn;
private Integer adminId;
private Date startTime;

View File

@@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -28,6 +29,7 @@ public class UserVipLogServiceImpl extends ServiceImpl<UserVipLogDao, UserVipLog
userVipLog.setUserId(userVip.getUserId());
userVipLog.setUserVipId(userVip.getId());
userVipLog.setType(params.get("userVipType").toString());
userVipLog.setPayTime(new Date());
userVipLog.setAdminId(Integer.parseInt(params.get("adminId").toString()));
userVipLog.setStartTime(userVip.getStartTime());
userVipLog.setEndTime(userVip.getEndTime());

View File

@@ -210,6 +210,7 @@ public class UserVipController {
userVipLog.setUserId(userVip.getUserId());
userVipLog.setUserVipId(userVip.getId());
userVipLog.setType(params.get("type").toString());
userVipLog.setPayTime(params.containsKey("payTime")?DateUtils.stringToDate(params.get("payTime").toString(), "yyyy-MM-dd HH:mm:ss"):null);
if (params.containsKey("orderSn")){
userVipLog.setOrderSn(params.get("orderSn").toString());
}
@@ -232,6 +233,7 @@ public class UserVipController {
userVipLog.setUserId(Integer.parseInt(userId));
userVipLog.setUserVipId(Integer.parseInt(params.get("userVipId").toString()));
userVipLog.setType(params.get("type").toString());
userVipLog.setPayTime(params.containsKey("payTime")?DateUtils.stringToDate(params.get("payTime").toString(), "yyyy-MM-dd HH:mm:ss"):null);
if (params.containsKey("orderSn")){
userVipLog.setOrderSn(params.get("orderSn").toString());
}

View File

@@ -20,12 +20,12 @@
</select>
<select id="getUserVipLogInfoTotal" resultType="map">
select SUM(fee) fee,SUM(alreadyTanxiao) alreadyTanxiao,SUM(currentTanxiao) currentTanxiao,SUM(notyetTanxiao) notyetTanxiao
select SUM(countFee) fee,SUM(alreadyTanxiao) alreadyTanxiao,SUM(currentTanxiao) currentTanxiao,SUM(notyetTanxiao) notyetTanxiao
from (
select t.*,dayAmount*alreadyDays alreadyTanxiao, dayAmount*currentDays currentTanxiao, fee-(dayAmount*alreadyDays)-(dayAmount*currentDays) notyetTanxiao
select t.*,IF(payTime is NULL,IF(DATE_FORMAT(startTime, '%Y-%m') = #{date},fee,0),IF(DATE_FORMAT(payTime, '%Y-%m') = #{date},fee,0)) countFee,dayAmount*alreadyDays alreadyTanxiao, dayAmount*currentDays currentTanxiao, fee-(dayAmount*alreadyDays)-(dayAmount*currentDays) notyetTanxiao
from (
select u.name,if(u.tel is null,if(u.email is null,'',u.email),u.tel) tel,IF(uv.type=4,'中医学',IF(uv.type=5,'针灸学',IF(uv.type=6,'肿瘤学',IF(uv.type=7,'国学',IF(uv.type=8,'心理学','中西汇通学'))))) type,
uvl.start_time startTime,uvl.end_time endTime,uvl.order_sn orderSn,uvl.pay_type payType,uvl.remark,uvl.fee,DATEDIFF(uvl.end_time,uvl.start_time)+1 totalDays,ROUND(uvl.fee/(DATEDIFF(uvl.end_time,uvl.start_time)+1),2) dayAmount,
uvl.start_time startTime,uvl.end_time endTime,uvl.order_sn orderSn,uvl.pay_type payType,uvl.pay_time payTime,uvl.remark,uvl.fee,DATEDIFF(uvl.end_time,uvl.start_time)+1 totalDays,ROUND(uvl.fee/(DATEDIFF(uvl.end_time,uvl.start_time)+1),2) dayAmount,
IF(DATE_FORMAT(uvl.end_time, '%Y-%m') &lt; #{date},DATEDIFF(uvl.end_time,uvl.start_time)+1,IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > #{date},0,IF(DATE_FORMAT(uvl.start_time, '%Y-%m') &lt; #{date},DATEDIFF(concat(#{date},'-01'),uvl.start_time),0))) alreadyDays,
IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > #{date},0,IF(DATE_FORMAT(uvl.end_time, '%Y-%m') &lt; #{date},0,IF(DATE_FORMAT(uvl.end_time, '%Y-%m') > #{date},DAY(LAST_DAY(concat(#{date},'-01'))),DATEDIFF(uvl.end_time,concat(#{date},'-01'))+1))) currentDays,
IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > #{date},DATEDIFF(uvl.end_time,uvl.start_time)+1,(IF(DATE_FORMAT(uvl.end_time, '%Y-%m') &lt;= #{date},0,DATEDIFF(uvl.end_time,LAST_DAY(concat(#{date},'-01')))))) notyetDays