Untitled
unknown
java
9 months ago
1.4 kB
5
Indexable
import com.google.gson.Gson;
import com.vnpay.taxi_card_job.common.constants.AccountType;
import com.vnpay.taxi_card_job.common.constants.TnxType;
import com.vnpay.taxi_card_job.repositories.TnxRepository;
import com.vnpay.taxi_card_job.repositories.entities.TnxEntity;
import com.vnpay.taxi_card_job.repositories.specification.TnxEntitySpecification;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@AllArgsConstructor
@Slf4j
public class TestController {
TnxRepository tnxRepository;
@GetMapping("test-txn")
String test(){
String fromDate = "26/02/2025";
String toDate = "25/03/2025";
var cardType = AccountType.CREDIT.name();
List<TnxEntity> creditTnxPaid = tnxRepository.findAll(new TnxEntitySpecification(null, fromDate, toDate, List.of(TnxType.PAYMENT.name()), 122L, cardType));
var totalAmountPaid = 0L; // Tổng tiền thanh toán trong kỳ của hãng
if (!creditTnxPaid.isEmpty()) {
totalAmountPaid = creditTnxPaid.stream().map(TnxEntity::getAmount).reduce(0L, Long::sum);
}
log.info("list txn"+ new Gson().toJson(creditTnxPaid));
log.info("totalAmountPaid"+ totalAmountPaid);
return "OK";
}
}Editor is loading...
Leave a Comment