Explorar o código

设计绩效修改提成比例

yangzian %!s(int64=2) %!d(string=hai) anos
pai
achega
8bbee20ad4

+ 63 - 1
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java

@@ -1864,6 +1864,30 @@ public class DateUtils extends PropertyEditorSupport {
         return null;
     }
 
+/**
+     * int 日期转 string
+     * 20220118 ====>>>> 2022-01-18
+     *
+     * @param date
+     * @return
+     */
+    public static String getStrDateToInt(int date) {
+
+        SimpleDateFormat sdfSource = new SimpleDateFormat("yyyyMMdd");
+        SimpleDateFormat sdfTarget = new SimpleDateFormat("yyyy-MM-dd");
+        String dateSource = String.valueOf(date);
+        String dateTarget = "";
+        try {
+            dateTarget = sdfTarget.format(sdfSource.parse(dateSource));
+        }catch (Exception e) {
+            e.printStackTrace();
+        }
+        return dateTarget;
+
+    }
+
+
+
 
     /**
      * 获取当前月份第一天
@@ -2234,10 +2258,48 @@ public class DateUtils extends PropertyEditorSupport {
 //        System.out.println(list);
 
 
-        System.out.println(getMaterialCost(null,"2022-09-01",4));
+        //System.out.println(getMaterialCost("2022-09-03","2022-09-01",3));
+        //System.out.println(getIntDateToStr(20220903));
+
+
+        System.out.println(subMonthMiddleDay("2022-12-01"));
+        if (subMonthMiddleDay("2022-12-01") == 20221215){
+            System.out.println("111");
+        }else {
+            System.out.println("222");
+        }
+
+
+
 
     }
 
+    /****
+     * 传入具体日期 ,返回具体日期增加15天。
+     * @param date 日期(2022-04-01)
+     * @return 2022-04-15
+     * @throws ParseException
+     */
+    public static Integer subMonthMiddleDay(String date) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+
+        Date dt = null;
+        try {
+            dt = sdf.parse(date);
+        }catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        Calendar rightNow = Calendar.getInstance();
+        rightNow.setTime(dt);
+        rightNow.add(Calendar.DAY_OF_MONTH, 14);
+        Date dt1 = rightNow.getTime();
+        String reStr = sdf.format(dt1);
+        return getDateInteger(reStr);
+    }
+
+
+
 
     /**
      * 获取季度所在的3个月份的 开始和结束时间

+ 32 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/achievements/service/impl/DesignerServiceImpl.java

@@ -380,10 +380,40 @@ public class DesignerServiceImpl implements IDesignerService {
            List<JSONObject> kuaishouJson = designerMapper.getDesignerAchievementsKuaishou(userId, month.get("startTime"),month.get("endTime"));
            Double kuaishouCommission = kuaishouJson.stream().mapToDouble(json -> json.getDouble("commission")).reduce(Double::sum).orElse(new Double("0"));
 
-           commissionJson.put("monthTime", month);
+           commissionJson.put("monthTime", month.get("startTime"));
            commissionJson.put("yearTime", yearTime);
            commissionJson.put("commission", bytedanceCommission+kuaishouCommission);
+
+
+           //离职 提成系数
+           //Double a = userHappyProbability(frozenTime,Integer.valueOf(monthTime));
+           Double userHappyProbability = new Double(1);
+           if (!Check.isNull(frozenTime)){
+               //离职时间
+               int frozenT = DateUtils.getDateInteger(frozenTime);
+
+               // 日期转换 20221021 ===>>> 2022-10-21
+               String day = DateUtils.getStrDateToInt(month.get("startTime"));
+               //获取月份的 中间的日期 20221015
+               int middleDay = DateUtils.subMonthMiddleDay(day);
+
+               if (frozenT < middleDay){
+                   userHappyProbability = new Double(0);
+               }
+               if (frozenT > middleDay && frozenT < month.get("endTime")){
+                   userHappyProbability = new Double(0.5);
+               }
+               if (frozenT == month.get("endTime")){
+                   userHappyProbability = new Double(1);
+               }
+
+           }
+
+
+           commissionJson.put("xishu", userHappyProbability);
+           commissionJson.put("ticheng", (bytedanceCommission+kuaishouCommission) * userHappyProbability);
            commissionList.add(commissionJson);
+
        }
        userFrozen.put("commissionList",commissionList);
 
@@ -414,7 +444,7 @@ public class DesignerServiceImpl implements IDesignerService {
 
 
        //提成发放金额 = 总提成* 发放系数 * 离职发放比例
-       Double userHappyGetMoney = totalCommission * coefficient * userHappyProbability;
+       Double userHappyGetMoney = totalCommission * coefficient;
        userFrozen.put("userHappyGetMoney",userHappyGetMoney);
 
        return userFrozen;