1、16号统计

This commit is contained in:
曹磊 2024-08-24 13:59:28 +08:00
parent aee08e00ba
commit febf835c48
4 changed files with 119 additions and 76 deletions

View File

@ -45,6 +45,12 @@ public interface ArtificerDao extends BaseMapper<Artificer> {
*/
List<Artificer> getYxjsList();
/**
* 查询新手技师
* @return
*/
List<Artificer> getXsList();
List<Artificer> selectInlineList(Artificer artificer);
Artificer selectByPhone(@Param("phone")String mobile);

View File

@ -33,9 +33,11 @@ public class BlArtificerZqhz implements Serializable {
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date endTime;//结束时间
private String xsje;//销售金额
private String yj;//业绩
private String jzl;//加钟率
private String zxsc;//在线时长
private String jf;//积分
private String grade;//等级
public BlArtificerZqhz() {}

View File

@ -1,6 +1,7 @@
package com.sqx.modules.task.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sqx.common.utils.DateUtils;
import com.sqx.modules.app.entity.UserMoney;
import com.sqx.modules.app.entity.UserSadDetails;
import com.sqx.modules.app.service.UserMoneyService;
@ -78,12 +79,38 @@ public class AllTaskServiceImpl implements AllTaskSercice {
@Scheduled(cron = "0 00 04 * * ?")
public void upgradeJishi() {
System.out.println("------------计算技师升级规则-----------");
//1.获取全部参与积分规则的技师
List<Artificer> jslist = artificerDao.getYxjsList();
//2.获取计算周期从几号到几号例如1号-10号为一个周期11号到20号第二个周期21号-月底是第三个周期
Calendar calendar = Calendar.getInstance();
//新手技师
List<Artificer> xsList = artificerDao.getXsList();
if(xsList.size()>0){
QueryWrapper<ArtificerPartitioningDetails> sjgzQuery = new QueryWrapper<ArtificerPartitioningDetails>();
sjgzQuery.ne("grade","");
sjgzQuery.orderByAsc("id");
sjgzQuery.last("limit 1");
ArtificerPartitioningDetails jsdj = artificerPartitioningDetailsDao.selectOne(sjgzQuery);
for(Artificer artificer : xsList){
String createTime = artificer.getCreateTime();
Date date = DateUtils.stringToDate(createTime,DateUtils.DATE_TIME_PATTERN);
Date current = calendar.getTime();
if(date.getTime()>=current.getTime()){
artificer.setGrade(jsdj.getGrade());
QueryWrapper<BlArtificerZqhz> zqhzQuery = new QueryWrapper<BlArtificerZqhz>();
sjgzQuery.eq("artificer_id",artificer.getArtificerId());
sjgzQuery.orderByDesc("id");
sjgzQuery.last("limit 1");
BlArtificerZqhz blArtificerZqhz = blArtificerZqhzDao.selectOne(zqhzQuery);
if(blArtificerZqhz!=null){
if(blArtificerZqhz.getGrade()!=null&&!blArtificerZqhz.getGrade().equals("")){
artificer.setGrade(blArtificerZqhz.getGrade());
}
}
artificerDao.updateById(artificer);
}
}
}
//1.获取计算周期从几号到几号例如1号-15号为一个周期16号到31号第二个周期
int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
System.out.println(dayOfMonth);
String startTime = "";
String endTime = "";
//获取执行时间
@ -105,13 +132,13 @@ public class AllTaskServiceImpl implements AllTaskSercice {
startTime = lastMonth+"-01 00:00:00";
endTime = lastMonth+"-15 23:59:59";
}
System.out.println("startTime" + startTime);
System.out.println("endTime" + endTime);
// startTime = "2024-06-21 00:00:00";
// endTime = "2024-06-30 23:59:59";
//不为空则继续执行否则不到时间不计算升级规则
if(StringUtils.isNotEmpty(startTime)){
//2.获取全部参与积分规则的技师
List<Artificer> jslist = artificerDao.getYxjsList();
//3.查询升级规则配置表
QueryWrapper<ArtificerPartitioningDetails> sjgzQuery = new QueryWrapper<ArtificerPartitioningDetails>();
sjgzQuery.ne("grade","");
@ -120,68 +147,74 @@ public class AllTaskServiceImpl implements AllTaskSercice {
//4.根据技师的服务类型查找对应的配置规则
for (Artificer jsPar : jslist) {
//获取技师是否参与积分规则如果参与积分规则则继续执行否则不变分成比例
Integer ynJfgz = jsPar.getYnJfgz();//是否参与积分规则计算0不参与 1参与
//4.1获取 技师销售金额(order表的 price) 只查询完成的单子
BigDecimal jsdqyj = ordersDao.selectOrdersArtificerIntegralEarnings(jsPar.getArtificerId(),endTime,startTime);
jsdqyj = jsdqyj.setScale(0,BigDecimal.ROUND_DOWN);
//4.2获取 技师加钟率(order表的parent_id为空则是正常订单不为空则是加钟订单 用加钟订单/正常订单为加钟率)
String jsjzl = ordersDao.selectOrdersArtificerIntegraladdNum(jsPar.getArtificerId(),endTime,startTime);
//4.3获取 在线时长通过积分表和兑换比例反推在线时长 user_rechange的type=1
String jszxsc = ordersDao.selectOrdersZxscNum(jsPar.getArtificerId(),startTime,endTime);
//业绩积分收入
ArtificerIntegralStatistics artificerIntegralStatistics = artificerIntegralStatisticsDao.getIntegralStatistics(jsPar.getArtificerId(),startTime,endTime,null);
BigDecimal outstandingAchievement = BigDecimal.ZERO;
BigDecimal integral = BigDecimal.ZERO;
BigDecimal income = BigDecimal.ZERO;
if(artificerIntegralStatistics!=null){
if(artificerIntegralStatistics.getAchievement()!=null){
outstandingAchievement = artificerIntegralStatistics.getAchievement();
}
if(artificerIntegralStatistics.getIntegral()!=null){
integral = artificerIntegralStatistics.getIntegral();
}
if(artificerIntegralStatistics.getIncome()!=null){
income = artificerIntegralStatistics.getIncome();
}
}
//在线时长
ArtificerIntegralStatistics zxscStatistics = artificerIntegralStatisticsDao.getIntegralStatistics(jsPar.getArtificerId(),startTime,endTime,1);
BigDecimal zxscjf = BigDecimal.ZERO;
if(zxscStatistics!=null){
zxscjf = zxscStatistics.getIntegral();
}
//多少分钟等1积分
CommonInfo commonInfo = commonInfoDao.findOne(100000);
String minute = commonInfo.getValue();//多少分钟等于1积分
Double zxscHour = Double.parseDouble(jszxsc)*Double.parseDouble(minute)/60;
//4.4获取 积分充值积分 user_rechange的type=2
String jsjfStr = ordersDao.selectOrdersStoredValueIntegral(jsPar.getArtificerId(),endTime,startTime);
if(ynJfgz==1){
//4.5根据对应的收益判断属于哪个等级并修改artificer的yn_jfgz等级标识及rate(百分比)
//组装对应的升级规则集合
String classifyId = jsPar.getClassifyId();
// List<ArtificerPartitioningDetails> sjgzList = new ArrayList<>();
Double zddj = Double.parseDouble(jsdqyj+"");
Double jzl = Double.parseDouble(jsjzl);
Double zxsc = zxscHour;
Double jsjf = Double.parseDouble(jsjfStr);
String jsdj = "";//
BigDecimal rate = BigDecimal.valueOf(0.6);
String value = commonInfo.getValue();
BigDecimal zxcs = zxscjf.multiply(new BigDecimal(value)).divide(new BigDecimal("60"), BigDecimal.ROUND_DOWN);//在线时长(小时)
String jsdj = "";//等级
BigDecimal rate = BigDecimal.valueOf(0);
for (ArtificerPartitioningDetails sjgzPar : sjgzAllList){
//当技师的服务类型=升级规则的服务类型才可以添加到升级规则里去
// if(StringUtils.equals(sjgzPar.getClassifyId(),String.valueOf(classifyId))){
// sjgzList.add(sjgzPar);
//最低业绩
Double zddjPar = Double.parseDouble(sjgzPar.getOutstandingAchievement()+"");
//加钟率
Double jzlPar = Double.parseDouble(sjgzPar.getClockRate()+"");
BigDecimal zddjPar = sjgzPar.getOutstandingAchievement();
//积分
BigDecimal czjfPar = new BigDecimal(sjgzPar.getIntegral());
//在线时长
Double zxscPar = Double.parseDouble(sjgzPar.getDurationOnline()+"");
//充值积分
Double czjfPar = Double.parseDouble(sjgzPar.getIntegral()+"");
System.out.println("============================"+sjgzPar.getGrade()+"================================");
System.out.println("最低业绩:"+zddj+">"+zddjPar);
System.out.println("加钟率A"+jzl+">"+jzlPar);
System.out.println("在线时长:"+zxsc+">"+zxscPar);
System.out.println("充值积分:"+jsjf+">"+czjfPar);
System.out.println("============================================================");
if(zddj>=zddjPar && jzl >=jzlPar && zxsc >= zxscPar && jsjf >= czjfPar){
BigDecimal zxscPar = new BigDecimal(sjgzPar.getDurationOnline());
if(outstandingAchievement.compareTo(zddjPar)>=0&&integral.compareTo(czjfPar)>=0&&zxcs.compareTo(zxscPar)>=0){
jsdj = sjgzPar.getGrade();
rate = BigDecimal.valueOf(Double.parseDouble(sjgzPar.getProportionalSharing()));
break;
}
// }
}
//如果都不符合则给最低等级保底
if(StringUtils.isEmpty(jsdj)){
QueryWrapper<ArtificerPartitioningDetails> sjgzQuery1 = new QueryWrapper<ArtificerPartitioningDetails>();
sjgzQuery1.eq("grade","A0");
sjgzQuery1.eq("classify_id",classifyId);
sjgzQuery1.last("limit 1");
sjgzQuery.ne("grade","");
sjgzQuery.orderByAsc("id");
sjgzQuery.last("limit 1");
ArtificerPartitioningDetails zddjgz = artificerPartitioningDetailsDao.selectOne(sjgzQuery1);
jsdj = zddjgz.getGrade();
rate = BigDecimal.valueOf(Double.parseDouble(zddjgz.getProportionalSharing()));
rate = new BigDecimal(zddjgz.getProportionalSharing());
}
if(StringUtils.isEmpty(jsdj)){
jsdj = "T0";
rate = BigDecimal.valueOf(0.5);
}
//如果还查不出来则保持原样一点办法都没有了
if(StringUtils.isNotEmpty(jsdj)){
if(jsPar.getGrade().equals("")){
if(rate.compareTo(jsPar.getRate())>=0){
Artificer jsUp = new Artificer();
jsUp.setRate(rate);
jsUp.setGrade(jsdj);
jsUp.setArtificerId(jsPar.getArtificerId());
artificerDao.updateById(jsUp);
}
}else{
Artificer jsUp = new Artificer();
jsUp.setRate(rate);
jsUp.setGrade(jsdj);
@ -194,10 +227,9 @@ public class AllTaskServiceImpl implements AllTaskSercice {
QueryWrapper<BlArtificerZqhz> blArtificerZqhzQueryWrapper = new QueryWrapper<>();
blArtificerZqhzQueryWrapper.eq("artificer_id",jsPar.getArtificerId());
blArtificerZqhzQueryWrapper.ge("start_time",startTime);
blArtificerZqhzQueryWrapper.ge("end_time",endTime);
blArtificerZqhzQueryWrapper.le("end_time",endTime);
blArtificerZqhzDao.delete(blArtificerZqhzQueryWrapper);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
BlArtificerZqhz blArtificerZqhz = new BlArtificerZqhz();
blArtificerZqhz.setArtificerId(jsPar.getArtificerId());
@ -207,18 +239,16 @@ public class AllTaskServiceImpl implements AllTaskSercice {
} catch (ParseException e) {
e.printStackTrace();
}
blArtificerZqhz.setXsje(jsdqyj+"");
blArtificerZqhz.setJzl(jsjzl);
blArtificerZqhz.setZxsc(zxscHour+"");
blArtificerZqhz.setJf(jsjfStr);
blArtificerZqhz.setXsje(income+""); //销售金额
blArtificerZqhz.setYj(outstandingAchievement+""); //业绩
blArtificerZqhz.setZxsc(zxcs+"");//在线时长
blArtificerZqhz.setJf(integral+"");//积分
blArtificerZqhz.setGrade(jsdj);//等级
blArtificerZqhzDao.insert(blArtificerZqhz);
}
}
}
/**
* 计算技师在线时长每10分钟计算一积分
*/

View File

@ -235,7 +235,12 @@
and yn_jfgz = 1
</select>
<select id="getXsList" resultType="com.sqx.modules.artificer.entity.Artificer">
select a.* from artificer a
inner join tb_user u on a.user_id=u.user_id
where u.status = 1
and grade = '新'
</select>
<select id="selectInlineList" resultType="com.sqx.modules.artificer.entity.Artificer">
select a.* from artificer a