Commit 49e3e7c8 by 叶立庆

工资计算逻辑优化

1 parent 87a4a3d3
......@@ -7,6 +7,7 @@ import lombok.experimental.Accessors;
import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@Data
......@@ -53,6 +54,24 @@ public class StaffMonthBdmCount implements Serializable {
private Integer behaviorCount;
/**
* 实际售前触客数
*/
@Column(name = "shop_count")
private Integer shopCount;
/**
* 录音总数
*/
@Column(name = "recording_count")
private Integer recordingCount;
/**
* pad扣款金额配置
*/
@Column(name = "pad_deduction")
private BigDecimal padDeduction;
/**
* 是否修正(0-未修正,1-已修正)
*/
@Column(name = "modify_flag")
......
......@@ -6,6 +6,7 @@ import cn.com.glsx.dj.smartcarlife.model.StaffBaseInfo;
import cn.com.glsx.dj.staff.dto.salary.SalaryStaffInfoDTO;
import cn.com.glsx.dj.staff.dto.salary.StaffSalaryDetailDTO;
import cn.com.glsx.dj.staff.dto.salary.StaffSalaryDetailRequestDTO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
......@@ -24,4 +25,24 @@ public interface StaffMonthSalarySlipMapper extends OreMapper<StaffMonthSalarySl
List<StaffSalaryDetailDTO> getStaffMonthSalaryDetailData(StaffSalaryDetailRequestDTO condition);
List<StaffBaseInfo> queryStaffBaseInfo(@Param("statMonth") String statMonth);
/**
* 获取实际售前触客数
* @param staffPhone
* @param startDate
* @param endDate
* @return
*/
Integer getShopCount(@Param("staffPhone")String staffPhone, @Param("startDate")String startDate,
@Param("endDate")String endDate);
/**
* 获取平板录音数
* @param staffPhone
* @param startDate
* @param endDate
* @return
*/
Integer getRecordingsCount(@Param("staffPhone")String staffPhone, @Param("startDate")String startDate,
@Param("endDate")String endDate);
}
\ No newline at end of file
......@@ -20,6 +20,7 @@ import java.time.format.DateTimeParseException;
import java.time.temporal.*;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
......@@ -43,6 +44,10 @@ public class DateUtils extends cn.com.glsx.framework.core.util.DateUtils {
public static final String CURRENT_MONTH = "当月";
private static final String [] PARSER_PATTERNS = {"yyyy-MM-dd","yyyy-M-d HH:mm:ss","yyyy-MM-dd HH:mm:ss","yyyy-MM-dd HH:mm:ss.S"};
private static final DateTimeFormatter MONTH_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM");
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
private static final Pattern MONTH_PATTERN = Pattern.compile("^\\d{4}-(0[1-9]|1[0-2])$");
public static int getDateYear(Date date) {
Calendar c = Calendar.getInstance();
......@@ -236,8 +241,10 @@ public class DateUtils extends cn.com.glsx.framework.core.util.DateUtils {
public static void main(String[] args) {
// System.out.println(getMonthStartTimeByDate("2025-03-17", true));
// System.out.println(getMonthEndTimeByDate("2025-03-17", true));
List<Date> list = getMonthDates("2026-01");
list.forEach(System.out::println);
// List<Date> list = getMonthDates("2026-01");
// list.forEach(System.out::println);
String[] list = getMonthBoundariesArray("2025-12");
System.out.println(Arrays.toString(list));
}
/**
......@@ -1530,5 +1537,84 @@ public class DateUtils extends cn.com.glsx.framework.core.util.DateUtils {
return outputFormat.format(date);
}
/**
* 获取指定月份的第一天和最后一天
*
* @param monthStr 月份字符串,格式:yyyy-MM
* @return Map,包含firstDay和lastDay
* @throws IllegalArgumentException 如果月份格式无效
*/
public static Map<String, String> getMonthBoundaries(String monthStr) {
validateMonthFormat(monthStr);
try {
// 解析年月
YearMonth yearMonth = YearMonth.parse(monthStr, MONTH_FORMATTER);
// 获取第一天和最后一天
LocalDate firstDay = yearMonth.atDay(1);
LocalDate lastDay = yearMonth.atEndOfMonth();
// 返回结果
Map<String, String> result = new HashMap<>();
result.put("firstDay", firstDay.format(DATE_FORMATTER));
result.put("lastDay", lastDay.format(DATE_FORMATTER));
return result;
} catch (DateTimeParseException e) {
throw new IllegalArgumentException("月份格式无效,请输入yyyy-MM格式,如:2024-01", e);
}
}
/**
* 获取指定月份的第一天
*/
public static String getFirstDayOfMonth(String monthStr) {
Map<String, String> boundaries = getMonthBoundaries(monthStr);
return boundaries.get("firstDay");
}
/**
* 获取指定月份的最后一天
*/
public static String getLastDayOfMonth(String monthStr) {
Map<String, String> boundaries = getMonthBoundaries(monthStr);
return boundaries.get("lastDay");
}
/**
* 获取月份的第一天和最后一天(返回数组形式)
*/
public static String[] getMonthBoundariesArray(String monthStr) {
Map<String, String> boundaries = getMonthBoundaries(monthStr);
return new String[] { boundaries.get("firstDay"), boundaries.get("lastDay") };
}
/**
* 验证月份格式
*/
private static void validateMonthFormat(String monthStr) {
if (monthStr == null || monthStr.trim().isEmpty()) {
throw new IllegalArgumentException("月份字符串不能为空");
}
String trimmed = monthStr.trim();
if (!MONTH_PATTERN.matcher(trimmed).matches()) {
throw new IllegalArgumentException("月份格式无效,请输入yyyy-MM格式,如:2024-01");
}
// 验证月份是否有效
String[] parts = trimmed.split("-");
int year = Integer.parseInt(parts[0]);
int month = Integer.parseInt(parts[1]);
if (year < 1) {
throw new IllegalArgumentException("年份不能小于1");
}
if (month < 1 || month > 12) {
throw new IllegalArgumentException("月份必须在1-12之间");
}
}
}
......@@ -10,8 +10,11 @@
<result column="staff_phone" property="staffPhone" jdbcType="VARCHAR" />
<result column="deduct_month" property="deductMonth" jdbcType="CHAR" />
<result column="behavior_deduct_type" property="behaviorDeductType" jdbcType="TINYINT" />
<result column="behavior_count" property="behaviorCount" jdbcType="INTEGER" />
<result column="modify_flag" property="modifyFlag" jdbcType="INTEGER" />
<result column="shop_count" property="behaviorCount" jdbcType="INTEGER" />
<result column="behavior_count" property="shopCount" jdbcType="INTEGER" />
<result column="recording_count" property="recordingCount" jdbcType="INTEGER" />
<result column="pad_deduction" property="padDeduction" jdbcType="DECIMAL" />
<result column="modify_flag" property="modifyFlag" jdbcType="INTEGER" />
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP" />
<result column="create_by" property="createBy" jdbcType="VARCHAR" />
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP" />
......@@ -22,7 +25,7 @@
<!--
WARNING - @mbg.generated
-->
id, staff_name, staff_phone, deduct_month, behavior_deduct_type, behavior_count,
id, staff_name, staff_phone, deduct_month, behavior_deduct_type, behavior_count, shop_count, recording_count, pad_deduction,
modify_flag, created_date, create_by, updated_date, updated_by, deleted_flag
</sql>
</mapper>
\ No newline at end of file
......@@ -208,6 +208,28 @@
ORDER BY
s1.phone_number
</select>
<select id="getShopCount" resultType="java.lang.Integer">
SELECT SUM(IFNULL(h.equity_to_shop_count, 0))
FROM `dj_car_life_staff_daily_report_huawei` h
INNER JOIN `dj_car_life_staff_info` s
ON h.staff_uuid = s.staff_uuid
WHERE h.report_date <![CDATA[>=]]> #{startDate}
AND h.report_date <![CDATA[<=]]> #{endDate}
AND s.phone_number = #{staffPhone}
AND h.deleted_flag = 'N'
AND s.deleted_flag = 'N'
</select>
<select id="getRecordingsCount" resultType="java.lang.Integer">
SELECT COUNT(*)
FROM `reception_customer_info` h
INNER JOIN `dj_car_life_staff_info` s
ON h.staff_uuid = s.staff_uuid
WHERE h.reception_start_time <![CDATA[>=]]> #{startDate}
AND h.reception_start_time <![CDATA[<=]]> #{endDate}
AND s.phone_number = #{staffPhone}
AND h.deleted_flag = 'N'
AND s.deleted_flag = 'N'
</select>
<sql id="list_condition">
<where>
......
......@@ -73,8 +73,8 @@ public class StaffMonthSalaryServiceTest extends BaseServiceTest {
@Test
public void testStatMonthSalary() {
StaffMonthSalarySlip info = new StaffMonthSalarySlip();
info.setStaffName("叶立庆");
info.setStaffPhone("18126301457");
info.setStaffName("明明长岭园区店员工01");
info.setStaffPhone("15626599736");
info.setSalaryMonth("2025-12");
info.setUpdatedBy("system");
long l = System.currentTimeMillis();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!