|
|
@@ -1,6 +1,9 @@
|
|
|
package com.goafanti.expenseAccount.service.impl;
|
|
|
|
|
|
+import cn.jiguang.common.utils.StringUtils;
|
|
|
+import com.goafanti.common.dao.OrderYearMaxDurationMapper;
|
|
|
import com.goafanti.common.dao.TOrderNewMapper;
|
|
|
+import com.goafanti.common.model.OrderYearMaxDuration;
|
|
|
import com.goafanti.common.utils.LoggerUtils;
|
|
|
import com.goafanti.expenseAccount.bo.ExpenseCountsBo;
|
|
|
import com.goafanti.expenseAccount.bo.ExpenseCountsInput;
|
|
|
@@ -10,6 +13,8 @@ import org.springframework.cache.annotation.CacheEvict;
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.util.List;
|
|
|
|
|
|
@Service
|
|
|
@@ -17,6 +22,8 @@ public class ExpenseCountsServiceImpl implements ExpenseCountsService {
|
|
|
|
|
|
@Autowired
|
|
|
private TOrderNewMapper tOrderNewMapper;
|
|
|
+ @Autowired
|
|
|
+ private OrderYearMaxDurationMapper orderYearMaxDurationMapper;
|
|
|
@Override
|
|
|
@Cacheable(value = "getCounts#300", key = "'getCounts:key='+#in.buyerName+#in.startTime+#in.endTime+#in.depId+#in.contactNo+#in.targetType")
|
|
|
public Object getCounts(ExpenseCountsInput in) {
|
|
|
@@ -24,9 +31,41 @@ public class ExpenseCountsServiceImpl implements ExpenseCountsService {
|
|
|
if (in.getTargetType()==1){
|
|
|
List<ExpenseCountsBo> expenseCountsBos = tOrderNewMapper.selectExpenseCount(in);
|
|
|
expenseCountsBos.forEach(e->{
|
|
|
- if (e.getMaxDuration().equals("-1")){
|
|
|
- e.setMaxDuration("不限制");
|
|
|
- }
|
|
|
+ //获取年份
|
|
|
+ if (StringUtils.isNotEmpty(e.getOrderNo())){
|
|
|
+ List<OrderYearMaxDuration> yearMaxDurationList = orderYearMaxDurationMapper.selectByOrderNo(e.getOrderNo());
|
|
|
+ int year = LocalDate.now().getYear();
|
|
|
+ OrderYearMaxDuration useOyd = null;
|
|
|
+ for (int i = 0; i < yearMaxDurationList.size(); i++) {
|
|
|
+ OrderYearMaxDuration oyd = yearMaxDurationList.get(i);
|
|
|
+ //年份为0不是会员直接获取跳出循环,否则获取当前年份,获取不到获取最后一年
|
|
|
+ if (oyd.getYear()==0){
|
|
|
+ useOyd=oyd;
|
|
|
+ break;
|
|
|
+ }else {
|
|
|
+ if (oyd.getYear().equals(year)){
|
|
|
+ useOyd = oyd;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if(i==yearMaxDurationList.size()-1&&useOyd==null){
|
|
|
+ useOyd = yearMaxDurationList.get(i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if(useOyd.getStatus()==1){
|
|
|
+ e.setMaxDuration("不限制");
|
|
|
+ e.setExceedDuration("0");
|
|
|
+ }else {
|
|
|
+ e.setMaxDuration(useOyd.getMaxDuration().toString());
|
|
|
+ if (useOyd.getMaxDuration().compareTo(new BigDecimal(e.getActualDuration()))>=0){
|
|
|
+ e.setExceedDuration("0");
|
|
|
+ }else {
|
|
|
+ e.setExceedDuration(new BigDecimal(e.getActualDuration()).subtract(useOyd.getMaxDuration()).toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
});
|
|
|
return expenseCountsBos;
|
|
|
}else {
|