zhibing.pu
2024-06-24 f6d15260d3fdcb326869f541a266bc4688a1b101
cloud-server-competition/src/main/java/com/dsh/competition/service/impl/CompetitionServiceImpl.java
@@ -80,6 +80,10 @@
    private PayMoneyUtil payMoneyUtil;
    @Autowired
    private CompetitionService cttService;
    private String aliAppid = "2021004105665036";//支付宝appid
    private String appPrivateKey = "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCi5i9nW/hGLJ3A06cZxTQdviFC7THpdSihoTYGLr9q006hu0V26ecBMY/o4w5bvIX0Ok/yofmZsVcCJpAPvbXL/uqVrIjnRRxXiaeBFThlxoBUTdunvbUSDYfzlEhJr5NvUKI6H6lz2niXlQGx4qy8Hau4ccWit9kM8jwUvsBVQoFgJA+xrjMvooA7YLopQtpOD+UJr5thApTSf1xrnr1W12yolTLEH15JmNV372cqXrYUuqnY0QsaPtxeqJUGAOcGdVLllQ7easEznP8DFBvDdHATcmp2SHNQDUEWN6MCVPbMgY06NQVqAXxqjTAYSVh+6TRu6bofPmpYC3TZB003AgMBAAECggEBAJAcR2+PA3NBYUYHeFrqBRMS8uX8ZR19kjZ7IgoSLTFaQsP9opRylPSPXhrPVBKAE5leRQAHn4MCSlESwHvMfxo7KFjFTFAc6dffZZpipYQUOc9bGampwJh58/3e/pyBgVMG6J23CPf/HJQtNFSkjd/V9+ayb/9l2dUEL3bC0fAZ/dbx8HsxdLw8wn3fLlWLj68hOMqa2deCZe3JdSVsPbeWqkh56FFsMLug0Nd+Ar4TgRl9/jnhXF0JWiD0LmPUYLhboY7EfUBzN4w1iYbDi1P+3zvoOYsiVKAXox9GMhQ2VzOO2UcSTuizSza2e98mGpabl/GpKmCz+RDFjtkX6eECgYEA2MyCij65eO3aGIm3FUe93DULRBYTfX8qJQSJq2WOWA3mmQlEW6L3O2B5/lG2h+8WmN6iLEs9eHpgycGYp7vAqgrANEn16ACVcuyx0scFtrZfZ+kmHMzFfiUWxJjVYk/6YngsGVBLdw6ueM42C8TTP67X9tU5TdVGoGWuqEj4W98CgYEAwFqwprXOch5Pqk/RPbb49r0Ou03K/UbciWnWWKzUhFFNS8MdlQPoDvQZbMwHLeWsa2VhaKITK3x5biLQb3U+0GLOn6lTvEyrEUH+ucREyLgVYTRAvwBPtnvlrzpyxPk2HnslQjju8WrvvLLBMKWUjlTrTOzhaHT21gz3pHMiOakCgYEAhLmfaXdBITGshb054sNLDtdCkGpbgEcrzAHdLps769iGxkYQHXHFngpQZUwtTUcoNGqIKknd1jZFrv7gsD+XkgKG7PwimehRlkwmCX5ilxtLiVgJRzRt6+5U5AMVD90a0tHzXYP0z2yjj73fBJF5KtGl0a10KZxaYrQdm1UhB00CgYBZZgzx/k9rtHC8LAqIj1CYhHejT92G53c6Gkl3vyOqN4sgKhfGmSEySfrDGPRBPZxr8ZtbIPCd5mUdberH0osWGMYFaJI1UsCy7aQwvGpniz7MhZeN7dweaOjwDs8mgtjHQ96mL4XGCDhR0BZ/wIURvZ/6iaGdhbbu9unlsWj3uQKBgQCmZYdsbbZkd3ev6f8rwyvMz+DrCQyYpY44cegBYuJgrZiQnL2fJioeN7ixX0UM48SfwsZEIrzshP/LGAwnc2MdjxKUl4jLN8SEe0NAjXOnz9Zaw740+aOmLpXcLWdP4uM2gIhWsvW1tEkQZCXmm7c9s/RsU8Pmzv+YL3+fSijOzA==";//支付宝开发者应用私钥
@@ -232,7 +236,8 @@
        JSONArray jsonArray = JSON.parseArray(paymentCompetitionVo.getIds());
        Competition competition = this.getById(paymentCompetitionVo.getId());
        List<PaymentCompetition> list = paymentCompetitionService.list(new QueryWrapper<PaymentCompetition>().eq("competitionId", paymentCompetitionVo.getId()).ne("payStatus", 3));
        List<PaymentCompetition> list = paymentCompetitionService.list(new QueryWrapper<PaymentCompetition>()
                .eq("competitionId", paymentCompetitionVo.getId()).ne("payStatus", 3));
        List<Long> pays = new ArrayList<>();
        for (PaymentCompetition paymentCompetition : list) {
            pays.add(paymentCompetition.getId());
@@ -361,7 +366,8 @@
     * @throws Exception
     */
    public ResultUtil weChatPaymentCompetition(String code, BigDecimal money) throws Exception {
        ResultUtil weixinpay = payMoneyUtil.weixinpay("报名赛事", "", code, money.toString(), "/base/competition/weChatPaymentCompetitionCallback", "APP", "");
        ResultUtil weixinpay = payMoneyUtil.weixinpay("报名赛事", "", code, money.toString(),
                "/base/competition/weChatPaymentCompetitionCallback", "APP", "");
        if (weixinpay.getCode() == 200) {
            new Thread(new Runnable() {
                @Override
@@ -373,7 +379,8 @@
                            int min = 5000;
                            wait += (min * num);
                            Thread.sleep(wait);
                            PaymentCompetition paymentCompetition = paymentCompetitionService.getOne(new QueryWrapper<PaymentCompetition>().eq("code", code).eq("payType", 1));
                            PaymentCompetition paymentCompetition = paymentCompetitionService.getOne(new QueryWrapper<PaymentCompetition>()
                                    .eq("code", code).eq("payType", 1));
                            if (paymentCompetition.getPayStatus() == 2) {
                                break;
                            }
@@ -391,7 +398,7 @@
                                Map<String, String> data1 = resultUtil.getData();
                                String s = data1.get("trade_state");
                                String transaction_id = data1.get("transaction_id");
                                if ("REFUND".equals(s) || "NOTPAY".equals(s) || "CLOSED".equals(s) || "REVOKED".equals(s) || "PAYERROR".equals(s) || num == 10) {
                                if ("REFUND".equals(s) || "CLOSED".equals(s) || "REVOKED".equals(s) || "PAYERROR".equals(s) || num == 10) {
                                    paymentCompetition.setAppUserId(null);
                                    paymentCompetition.setState(3);
                                    userCompetitionService.remove(new QueryWrapper<UserCompetition>().eq("paymentCompetitionId", paymentCompetition.getId()));
@@ -403,9 +410,13 @@
                                    paymentCompetition.setPayTime(new Date());
                                    paymentCompetition.setPayOrderNo(transaction_id);
                                    paymentCompetitionService.updateById(paymentCompetition);
                                    Competition competition = cttService.getById(paymentCompetition.getCompetitionId());
                                    competition.setApplicantsNumber(competition.getApplicantsNumber() + 1);
                                    cttService.updateById(competition);
                                    break;
                                }
                                if ("USERPAYING".equals(s)) {
                                if ("USERPAYING".equals(s) || "NOTPAY".equals(s)) {
                                    num++;
                                }
                            }
@@ -473,6 +484,11 @@
                                    paymentCompetition.setPayTime(new Date());
                                    paymentCompetition.setPayOrderNo(tradeNo);
                                    paymentCompetitionService.updateById(paymentCompetition);
                                    Competition competition = cttService.getById(paymentCompetition.getCompetitionId());
                                    competition.setApplicantsNumber(competition.getApplicantsNumber() + 1);
                                    cttService.updateById(competition);
                                    // 结算资金到商户账号
                                    payMoneyUtil.confirm(smid,code,tradeNo,money.toString());
                                    //分账