|
@@ -4,20 +4,26 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.sqx.common.utils.DateUtils;
|
|
|
import com.sqx.common.utils.ShiroUtils;
|
|
|
import com.sqx.modules.app.entity.UserEntity;
|
|
|
import com.sqx.modules.app.service.UserService;
|
|
|
import com.sqx.modules.creditRecord.dao.CreditRecordDao;
|
|
|
import com.sqx.modules.creditRecord.entity.CreditRecord;
|
|
|
import com.sqx.modules.creditRecord.entity.CreditRecordEntity;
|
|
|
+import com.sqx.modules.creditRecord.entity.CreditRecordMapEntity;
|
|
|
import com.sqx.modules.creditRecord.service.CreditRecordService;
|
|
|
import com.sqx.modules.sys.entity.SysUserEntity;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.util.Date;
|
|
|
import java.util.LinkedHashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
@@ -49,7 +55,7 @@ public class CreditRecordServiceImpl extends ServiceImpl<CreditRecordDao, Credit
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void updateUserCreditRecord(UserEntity userEntity, Integer type, Integer score, String remark,Integer isDriver) {
|
|
|
+ public void updateUserCreditRecord(UserEntity userEntity, Integer type, Integer score, String remark,String orderNo,Integer isDriver) {
|
|
|
CreditRecord creditRecord = new CreditRecord();
|
|
|
creditRecord.setCreateTime(LocalDateTime.now());
|
|
|
creditRecord.setLastCreditScore(userEntity.getCreditScore());
|
|
@@ -74,6 +80,7 @@ public class CreditRecordServiceImpl extends ServiceImpl<CreditRecordDao, Credit
|
|
|
creditRecord.setSysUserName(userEntity.getUserName());
|
|
|
}
|
|
|
creditRecord.setReason(remark);
|
|
|
+ creditRecord.setOrdersNo(orderNo);
|
|
|
creditRecord.setIsDriver(isDriver);
|
|
|
baseMapper.insert(creditRecord);
|
|
|
|
|
@@ -91,12 +98,29 @@ public class CreditRecordServiceImpl extends ServiceImpl<CreditRecordDao, Credit
|
|
|
}
|
|
|
|
|
|
public Map<String,Object> getFilledScore(Long userId, Integer isDriver,Integer several){
|
|
|
-
|
|
|
+ //获取过滤时间并格式化
|
|
|
+ String createTime = userService.selectUserById(userId).getCreateTime();
|
|
|
+ Date parse = null;
|
|
|
+ try {
|
|
|
+ parse = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(createTime);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ String format = DateUtils.format(parse, DateUtils.DATE_PATTERN_MONTH);
|
|
|
+ //从数据库取所需数据
|
|
|
Map<String, Object> orderedMap = new LinkedHashMap<>();
|
|
|
- creditRecordDao.getFilledScore(userId,isDriver,several).entrySet().stream()
|
|
|
- .sorted(Map.Entry.comparingByKey()) // 按月份排序;如不需要可删除
|
|
|
- .forEachOrdered(e -> orderedMap.put(e.getKey(), e.getValue()));
|
|
|
-
|
|
|
+ List<CreditRecordMapEntity> filledScore = creditRecordDao.getFilledScore(userId, isDriver, several);
|
|
|
+ for (CreditRecordMapEntity c :filledScore) {
|
|
|
+ orderedMap.put(c.getMonth(),c.getFilledScore());
|
|
|
+ }
|
|
|
+ //过滤创建时间之前的数据
|
|
|
+ Map<String, Object> filtered = new LinkedHashMap<>();
|
|
|
+ for (Map.Entry<String, Object> entry : orderedMap.entrySet()) {
|
|
|
+ String month = entry.getKey(); // 格式:yyyy-MM
|
|
|
+ if (month.compareTo(format) >= 0) {
|
|
|
+ filtered.put(month,entry.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
return orderedMap;
|
|
|
}
|
|
|
}
|