|
@@ -1,15 +1,22 @@
|
|
package org.jeecg.modules.ctop.service.impl;
|
|
package org.jeecg.modules.ctop.service.impl;
|
|
|
|
|
|
|
|
+import cn.com.ctop.common.module.utils.CtopAdConstant;
|
|
import cn.com.ctop.performanceappraisal.service.IPerformanceService;
|
|
import cn.com.ctop.performanceappraisal.service.IPerformanceService;
|
|
import org.jeecg.common.util.DateUtils;
|
|
import org.jeecg.common.util.DateUtils;
|
|
import org.jeecg.modules.ctop.entity.Advertiser;
|
|
import org.jeecg.modules.ctop.entity.Advertiser;
|
|
|
|
+import org.jeecg.modules.ctop.entity.SalePerformanceDetail;
|
|
import org.jeecg.modules.ctop.service.IAdvertiserService;
|
|
import org.jeecg.modules.ctop.service.IAdvertiserService;
|
|
|
|
+import org.jeecg.modules.ctop.service.ISalePerformanceDetailService;
|
|
import org.jeecg.modules.ctop.service.PerformanceAreaService;
|
|
import org.jeecg.modules.ctop.service.PerformanceAreaService;
|
|
import org.jeecg.modules.system.entity.SysUser;
|
|
import org.jeecg.modules.system.entity.SysUser;
|
|
|
|
+import org.jeecg.modules.system.entity.SysUserRole;
|
|
|
|
+import org.jeecg.modules.system.service.ISysUserRoleService;
|
|
import org.jeecg.modules.system.service.ISysUserService;
|
|
import org.jeecg.modules.system.service.ISysUserService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
+import java.text.ParseException;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
@@ -28,33 +35,150 @@ public class PerformanceAreaServiceImpl implements PerformanceAreaService {
|
|
List<SysUser> saleAms = sysUserService.getUserListByRoleId("f5a68aa2acf86e842100f0fa4b050d28");
|
|
List<SysUser> saleAms = sysUserService.getUserListByRoleId("f5a68aa2acf86e842100f0fa4b050d28");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISysUserRoleService userRoleService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISalePerformanceDetailService salePerformanceDetailService;
|
|
|
|
+
|
|
public void countPerformance(SysUser user) {
|
|
public void countPerformance(SysUser user) {
|
|
Date getDate = DateUtils.addDay(new Date(), -1);
|
|
Date getDate = DateUtils.addDay(new Date(), -1);
|
|
- String startDate = DateUtils.getQuarterStartDate(getDate);
|
|
|
|
- String endDate = DateUtils.getQuarterEndDate(getDate);
|
|
|
|
|
|
+ String startDateStr = DateUtils.getQuarterStartDate(getDate);
|
|
|
|
+ String endDateStr = DateUtils.getQuarterEndDate(getDate);
|
|
|
|
+ //获取用户角色信息
|
|
|
|
+ SysUserRole userRole = userRoleService.getUserRoleByUserId(user.getId());
|
|
//1:获取快手季度总消耗
|
|
//1:获取快手季度总消耗
|
|
- BigDecimal kuaishouDoSeasonTask = performanceService.getKuaishouSeasonTotalCost(startDate, endDate);
|
|
|
|
|
|
+ BigDecimal kuaishouDoSeasonTask = performanceService.getKuaishouSeasonTotalCost(startDateStr, endDateStr);
|
|
//2:获取快手个人季度总消耗
|
|
//2:获取快手个人季度总消耗
|
|
- BigDecimal kuaishouDoPersonnalTask = performanceService.getKuaishouSalesSeasonTotalCost(startDate, endDate, user.getId());
|
|
|
|
|
|
+ BigDecimal kuaishouDoPersonnalTask = performanceService.getKuaishouSalesSeasonTotalCostByParams(startDateStr, endDateStr, user.getId(), null);
|
|
//1:获取头条季度总消耗
|
|
//1:获取头条季度总消耗
|
|
- BigDecimal bytedanceDoSeasonTask = performanceService.getBytedanceSeasonTotalCost(startDate, endDate);
|
|
|
|
|
|
+ BigDecimal bytedanceDoSeasonTask = performanceService.getBytedanceSeasonTotalCost(startDateStr, endDateStr);
|
|
//2:获取头条个人季度总消耗
|
|
//2:获取头条个人季度总消耗
|
|
- BigDecimal bytedanceDoPersonnalTask = performanceService.getBytedanceSalesSeasonTotalCost(startDate, endDate, user.getId());
|
|
|
|
|
|
+ BigDecimal bytedanceDoPersonnalTask = performanceService.getBytedanceSalesSeasonTotalCostByParams(startDateStr, endDateStr, user.getId(), null);
|
|
//获取销售所属的广告主信息
|
|
//获取销售所属的广告主信息
|
|
List<Advertiser> advertiserList = advertiserService.getBySaleId(user.getId());
|
|
List<Advertiser> advertiserList = advertiserService.getBySaleId(user.getId());
|
|
|
|
|
|
if (null != advertiserList && advertiserList.size() > 0) {
|
|
if (null != advertiserList && advertiserList.size() > 0) {
|
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
+ Date startDate = null;
|
|
|
|
+ Date endDate = null;
|
|
|
|
+ try {
|
|
|
|
+ startDate = dateFormat.parse(startDateStr);
|
|
|
|
+ endDate = dateFormat.parse(endDateStr);
|
|
|
|
+ } catch (ParseException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+
|
|
for (Advertiser advertiser : advertiserList) {
|
|
for (Advertiser advertiser : advertiserList) {
|
|
Date endODate = DateUtils.addDay(advertiser.getCreateTime(), 90);
|
|
Date endODate = DateUtils.addDay(advertiser.getCreateTime(), 90);
|
|
- if (1 == 1) {
|
|
|
|
|
|
+ BigDecimal totalCost = BigDecimal.ZERO;
|
|
|
|
+ if (startDate.after(endODate)) {
|
|
|
|
+ //季度开始时间大于新户结束时间(全部按照老户逻辑计算)
|
|
|
|
+ SalePerformanceDetail detail = new SalePerformanceDetail();
|
|
|
|
+ detail.setAdvertiserId(advertiser.getId());
|
|
|
|
+ detail.setSaleId(user.getId());
|
|
|
|
+ detail.setRoleId(userRole.getRoleId());
|
|
|
|
+ detail.setYear(DateUtils.getYear(getDate));
|
|
|
|
+ detail.setQuarter(DateUtils.getQuarter(getDate));
|
|
|
|
+ if (user.getOrgCode().startsWith("A01A08")) {
|
|
|
|
+ detail.setMediaType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
|
|
|
|
+ detail.setStartDate(startDateStr);
|
|
|
|
+ detail.setEndDate(endDateStr);
|
|
|
|
+ totalCost = performanceService.getSalesSeasonTotalCostByParams(startDateStr, endDateStr, null, advertiser.getId(), CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
|
|
|
|
+ detail.setTotalCost(totalCost);
|
|
|
|
+ //TODO ---需要设定头条媒体季度任务
|
|
|
|
+ detail.setMediaTask(new BigDecimal("200000000"));
|
|
|
|
+ detail.setDoMediaTask(bytedanceDoSeasonTask);
|
|
|
|
+ detail.setPersonnalTask(new BigDecimal("2400000"));
|
|
|
|
+ detail.setDoPersonalTask(bytedanceDoPersonnalTask);
|
|
|
|
+ detail.setExtensionSelf(advertiser.getAdvertiserType());
|
|
|
|
+ detail.setBrandNew(0);
|
|
|
|
+ //提成比例
|
|
|
|
+ detail.setPercentagePercent(new BigDecimal("1.5"));
|
|
|
|
+ //
|
|
|
|
+ detail.setPercentage(new BigDecimal(""));
|
|
|
|
+ salePerformanceDetailService.save(detail);
|
|
|
|
+ } else if (user.getOrgCode().startsWith("A01A07")) {
|
|
|
|
+ detail.setMediaType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
|
|
|
|
+ detail.setStartDate(startDateStr);
|
|
|
|
+ detail.setEndDate(endDateStr);
|
|
|
|
+ totalCost = performanceService.getSalesSeasonTotalCostByParams(startDateStr, endDateStr, null, advertiser.getId(), CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
|
|
|
|
+ detail.setTotalCost(totalCost);
|
|
|
|
+ //TODO ---需要设定头条媒体季度任务
|
|
|
|
+ detail.setMediaTask(new BigDecimal("200000000"));
|
|
|
|
+ detail.setDoMediaTask(bytedanceDoSeasonTask);
|
|
|
|
+ detail.setPersonnalTask(new BigDecimal("2400000"));
|
|
|
|
+ detail.setDoPersonalTask(bytedanceDoPersonnalTask);
|
|
|
|
+ detail.setExtensionSelf(advertiser.getAdvertiserType());
|
|
|
|
+ detail.setBrandNew(0);
|
|
|
|
+ //提成比例
|
|
|
|
+ detail.setPercentagePercent(new BigDecimal("1.5"));
|
|
|
|
+ //
|
|
|
|
+ detail.setPercentage(new BigDecimal(""));
|
|
|
|
+ salePerformanceDetailService.save(detail);
|
|
|
|
+ } else {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ } else if (endODate.after(endDate)) {
|
|
|
|
+ //新湖结束时间大于季度结束时间(全部按照新户计算)
|
|
|
|
+ SalePerformanceDetail detail = new SalePerformanceDetail();
|
|
|
|
+ detail.setAdvertiserId(advertiser.getId());
|
|
|
|
+ detail.setSaleId(user.getId());
|
|
|
|
+ detail.setRoleId(userRole.getRoleId());
|
|
|
|
+ detail.setYear(DateUtils.getYear(getDate));
|
|
|
|
+ detail.setQuarter(DateUtils.getQuarter(getDate));
|
|
|
|
+ if (user.getOrgCode().startsWith("A01A08")) {
|
|
|
|
+ detail.setMediaType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
|
|
|
|
+ detail.setStartDate(startDateStr);
|
|
|
|
+ detail.setEndDate(endDateStr);
|
|
|
|
+ totalCost = performanceService.getSalesSeasonTotalCostByParams(startDateStr, endDateStr, null, advertiser.getId(), CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
|
|
|
|
+ detail.setTotalCost(totalCost);
|
|
|
|
+ //TODO ---需要设定头条媒体季度任务
|
|
|
|
+ detail.setMediaTask(new BigDecimal("200000000"));
|
|
|
|
+ detail.setDoMediaTask(bytedanceDoSeasonTask);
|
|
|
|
+ detail.setPersonnalTask(new BigDecimal("2400000"));
|
|
|
|
+ detail.setDoPersonalTask(bytedanceDoPersonnalTask);
|
|
|
|
+ detail.setExtensionSelf(advertiser.getAdvertiserType());
|
|
|
|
+ detail.setBrandNew(1);
|
|
|
|
+ //提成比例
|
|
|
|
+ detail.setPercentagePercent(new BigDecimal("1.5"));
|
|
|
|
+ //
|
|
|
|
+ detail.setPercentage(new BigDecimal(""));
|
|
|
|
+ salePerformanceDetailService.save(detail);
|
|
|
|
+ } else if (user.getOrgCode().startsWith("A01A07")) {
|
|
|
|
+ detail.setMediaType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
|
|
|
|
+ detail.setStartDate(startDateStr);
|
|
|
|
+ detail.setEndDate(endDateStr);
|
|
|
|
+ totalCost = performanceService.getSalesSeasonTotalCostByParams(startDateStr, endDateStr, null, advertiser.getId(), CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
|
|
|
|
+ detail.setTotalCost(totalCost);
|
|
|
|
+ //TODO ---需要设定头条媒体季度任务
|
|
|
|
+ detail.setMediaTask(new BigDecimal("200000000"));
|
|
|
|
+ detail.setDoMediaTask(bytedanceDoSeasonTask);
|
|
|
|
+ detail.setPersonnalTask(new BigDecimal("2400000"));
|
|
|
|
+ detail.setDoPersonalTask(bytedanceDoPersonnalTask);
|
|
|
|
+ detail.setExtensionSelf(advertiser.getAdvertiserType());
|
|
|
|
+ detail.setBrandNew(1);
|
|
|
|
+ //提成比例
|
|
|
|
+ detail.setPercentagePercent(new BigDecimal("1.5"));
|
|
|
|
+ //
|
|
|
|
+ detail.setPercentage(new BigDecimal(""));
|
|
|
|
+ salePerformanceDetailService.save(detail);
|
|
|
|
+ } else {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
|
|
+ //新户结束时间处于本季度中间
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void saveSalePerformanceDetail() {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private IAdvertiserService advertiserService;
|
|
private IAdvertiserService advertiserService;
|
|
}
|
|
}
|