|
@@ -9,17 +9,22 @@ import com.chelvc.cloud.vehicle.server.entity.Asset;
|
|
|
import com.chelvc.cloud.vehicle.server.entity.CurrencyRecord;
|
|
|
import com.chelvc.cloud.vehicle.server.service.AssetService;
|
|
|
import com.chelvc.cloud.vehicle.server.service.CurrencyRecordService;
|
|
|
+import com.chelvc.cloud.vehicle.server.service.MerchantService;
|
|
|
import com.chelvc.framework.base.context.SessionContextHolder;
|
|
|
import com.chelvc.framework.common.util.DateUtils;
|
|
|
import com.chelvc.framework.common.util.StringUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.Format;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -35,18 +40,40 @@ public class CurrencyRecordServiceImpl extends ServiceImpl<CurrencyRecordMapper,
|
|
|
|
|
|
private final AssetService assetService;
|
|
|
|
|
|
+ private final MerchantService merchantService;
|
|
|
+
|
|
|
@Override
|
|
|
- public List<CurrencyRecordDTO> listCurrencyRecord(Integer type, LocalDate date){
|
|
|
- Long userId = SessionContextHolder.getId();
|
|
|
- List<CurrencyRecord> currencyRecords = this.lambdaQuery()
|
|
|
- .eq(CurrencyRecord::getUserId,userId)
|
|
|
- .eq(CurrencyRecord::getType, type)
|
|
|
- .list();
|
|
|
- List<CurrencyRecordDTO> list = CurrencyRecordCopier.INSTANCE.copying(currencyRecords);
|
|
|
- List<CurrencyRecordDTO> filteredPeople = list.stream()
|
|
|
- .filter(item -> !DateUtils.format(item.getCreateTime()).equals(DateUtils.format(date)))
|
|
|
- .collect(Collectors.toList());
|
|
|
- return filteredPeople;
|
|
|
+ public List<CurrencyRecordDTO> listCurrencyRecord(Integer type, Long date){
|
|
|
+ Date localDate = new Date(date);
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
+ Long userId = SessionContextHolder.getId();
|
|
|
+ if (2 == type){
|
|
|
+ List<Long> merchantIds = this.merchantService.getMerchantIdsByUserId(userId);
|
|
|
+ if (CollectionUtils.isEmpty(merchantIds)){
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ List<CurrencyRecord> currencyRecords = this.lambdaQuery()
|
|
|
+ .eq(CurrencyRecord::getUserId,merchantIds.get(0))
|
|
|
+ .eq(CurrencyRecord::getType, type)
|
|
|
+ .orderByDesc(CurrencyRecord::getCreateTime)
|
|
|
+ .list();//1808847197293170689
|
|
|
+ List<CurrencyRecordDTO> list = CurrencyRecordCopier.INSTANCE.copying(currencyRecords);
|
|
|
+ List<CurrencyRecordDTO> filteredPeople = list.stream()
|
|
|
+ .filter(item -> sdf.format(item.getCreateTime()).equals(sdf.format(localDate)))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ return filteredPeople;
|
|
|
+ }else{
|
|
|
+ List<CurrencyRecord> currencyRecords = this.lambdaQuery()
|
|
|
+ .eq(CurrencyRecord::getUserId,userId)
|
|
|
+ .eq(CurrencyRecord::getType, type)
|
|
|
+ .orderByDesc(CurrencyRecord::getCreateTime)
|
|
|
+ .list();//1808847197293170689
|
|
|
+ List<CurrencyRecordDTO> list = CurrencyRecordCopier.INSTANCE.copying(currencyRecords);
|
|
|
+ List<CurrencyRecordDTO> filteredPeople = list.stream()
|
|
|
+ .filter(item -> !DateUtils.format(item.getCreateTime()).equals(DateUtils.format(localDate)))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ return filteredPeople;
|
|
|
+ }
|
|
|
}
|
|
|
@Override
|
|
|
public EarningsDTO getCurrencyRecord(Integer type){
|