소스 검색

订单明细优化

liude 7 달 전
부모
커밋
f6e891b50a

+ 3 - 1
vehicle-client/src/main/java/com/chelvc/cloud/vehicle/client/CurrencyRecordClient.java

@@ -5,8 +5,10 @@ import java.util.List;
 
 import com.chelvc.cloud.vehicle.client.dto.CurrencyRecordDTO;
 import com.chelvc.cloud.vehicle.client.dto.EarningsDTO;
+import com.chelvc.cloud.vehicle.client.param.BalanceRetailParam;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
 
 /**
@@ -23,7 +25,7 @@ public interface CurrencyRecordClient {
      * @return 收益流水记录列表
      */
     @GetMapping("/currencyRecord/listCurrencyRecord")
-    List<CurrencyRecordDTO> listCurrencyRecord(@RequestParam("type") Integer type, Long date);
+    List<CurrencyRecordDTO> listCurrencyRecord(@RequestBody BalanceRetailParam param);
 
     /**
      * 获取用户得总收益、本周收益、本月收益、可提现金额

+ 34 - 0
vehicle-client/src/main/java/com/chelvc/cloud/vehicle/client/param/BalanceRetailParam.java

@@ -0,0 +1,34 @@
+package com.chelvc.cloud.vehicle.client.param;
+
+import com.chelvc.framework.common.model.Paging;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.SuperBuilder;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * 预约信息参数
+ *
+ * @author liude
+ * @date 2023/1/17
+ */
+@Data
+@SuperBuilder
+@NoArgsConstructor
+@AllArgsConstructor
+public class BalanceRetailParam implements Serializable {
+    /**
+     * 日期
+     */
+    @NotNull(message = "查询日期不能为空")
+    private Long date;
+    /**
+     * type 类型:0-平台;1-用户;2-商户
+     */
+    @NotNull(message = "查询类型不能为空")
+    private Integer type;
+
+}

+ 4 - 2
vehicle-server/src/main/java/com/chelvc/cloud/vehicle/server/controller/CurrencyRecordController.java

@@ -5,10 +5,12 @@ import java.util.List;
 
 import com.chelvc.cloud.vehicle.client.dto.CurrencyRecordDTO;
 import com.chelvc.cloud.vehicle.client.dto.EarningsDTO;
+import com.chelvc.cloud.vehicle.client.param.BalanceRetailParam;
 import com.chelvc.cloud.vehicle.server.service.CurrencyRecordService;
 import lombok.RequiredArgsConstructor;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -30,8 +32,8 @@ public class CurrencyRecordController {
      * @return 收益流水记录列表
      */
     @GetMapping("/currencyRecord/listCurrencyRecord")
-    public List<CurrencyRecordDTO> listCurrencyRecord(@RequestParam("type") Integer type, Long date) {
-        return currencyRecordService.listCurrencyRecord(type,date);
+    public List<CurrencyRecordDTO> listCurrencyRecord(@RequestBody BalanceRetailParam param) {
+        return currencyRecordService.listCurrencyRecord(param.getType(),param.getDate());
     }
 
     /**

+ 34 - 9
vehicle-server/src/main/java/com/chelvc/cloud/vehicle/server/service/impl/CurrencyRecordServiceImpl.java

@@ -9,17 +9,21 @@ 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;
@@ -36,19 +40,40 @@ public class CurrencyRecordServiceImpl extends ServiceImpl<CurrencyRecordMapper,
 
     private final AssetService assetService;
 
+    private final MerchantService merchantService;
+
      @Override
      public List<CurrencyRecordDTO> listCurrencyRecord(Integer type, Long date){
          Date localDate = new Date(date);
+         SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
          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(localDate)))
-                 .collect(Collectors.toList());
-         return filteredPeople;
+         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){