liujie
2023-10-15 871efa21e6c95520e9825ae1f2338c9a919fdd5d
src/main/java/com/stylefeng/guns/modular/system/controller/FinanceController.java
@@ -54,6 +54,9 @@
    @Autowired
    private TUserBankService userBankService;
    @Autowired
    private ITPriceService priceService;
    @ApiOperation(value = "用户端-invocie",notes="用户端-invocie")
    @ApiImplicitParams({
@@ -88,7 +91,7 @@
        BigDecimal all = new BigDecimal(0);
        ArrayList<TGoods> goods = new ArrayList<>();
        for (TOrder order : orders) {
            BigDecimal allTotal = order.getAllTotal();
            BigDecimal allTotal = priceService.selectList(new EntityWrapper<TPrice>().eq("order_id", order.getId())).stream().map(TPrice::getPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
            BigDecimal paid = order.getPaid();
            BigDecimal subtract = allTotal.subtract(paid);
            all = all.add(subtract);
@@ -138,7 +141,8 @@
                // 总金额
                BigDecimal bigDecimal = new BigDecimal(0);
                for (TOrder order : orders) {
                    bigDecimal = bigDecimal.add(order.getAllTotal());
                    List<TPrice> prices = priceService.selectList(new EntityWrapper<TPrice>().eq("order_id", order.getId()));
                    bigDecimal = bigDecimal.add(prices.stream().map(TPrice::getPrice).reduce(BigDecimal.ZERO,BigDecimal::add));
                }
                if (type == 1) {
                    // 可用额度
@@ -172,8 +176,7 @@
//                    String method = PaymentProcessor.getMethod(tUser.getUserNumber());
//                    JSONObject jsonObject = JSON.parseObject(method);
//                    Object id1 = jsonObject.get("id");
                    long l = bigDecimal.multiply(new BigDecimal(100)).longValue();
                    Boolean pay = PaymentProcessor.pay(tUser.getUserNumber(), cardToken, l);
                    Boolean pay = StripePayUtils.charge(tUser.getUserNumber(), bigDecimal, "","Continental Cargo Association, Inc.");
                    if (pay) {
                        orders.forEach(e -> {
                            e.setStatus("2");
@@ -198,7 +201,9 @@
                    TQuote quote = tQuoteService.selectOne(new EntityWrapper<TQuote>().eq("order_id", s));
                    quote.setState(4);
                    tQuotes.add(quote);
                    BigDecimal allTotal = order.getAllTotal();
//                    BigDecimal allTotal = order.getAllTotal();
                    List<TPrice> prices = priceService.selectList(new EntityWrapper<TPrice>().eq("order_id", order.getId()));
                    BigDecimal allTotal = prices.stream().map(TPrice::getPrice).reduce(BigDecimal.ZERO,BigDecimal::add);
                    BigDecimal paid = order.getPaid();
                    BigDecimal subtract = allTotal.subtract(paid);
                    all = all.add(subtract);
@@ -212,7 +217,7 @@
                JSONObject jsonObject = JSON.parseObject(method);
                Object id1 = jsonObject.get("id");
                long l = all.multiply(new BigDecimal(100)).longValue();
                Boolean pay = PaymentProcessor.pay(tUser.getUserNumber(), id1.toString(), l);
                Boolean pay = StripePayUtils.charge(tUser.getUserNumber(), all, "","Continental Cargo Association, Inc.");
                if (pay) {
                    orders.forEach(e -> {
                        e.setStatus("2");
@@ -222,8 +227,9 @@
                    orderService.updateBatchById(orders);
                    List<TQuote> collect = tQuotes.stream().collect(Collectors.toList());
                    tQuoteService.updateBatchById(collect);
                }else {
                    return new ErrorTip(5010, "payment failure");
                }
            }
            return new SuccessTip();
        } catch (Exception e) {