无关风月
2024-07-11 eb6b6dbb35a9f029e0b7d269773685c19fd40976
cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/OperatorController.java
@@ -9,14 +9,17 @@
import com.alipay.api.request.AlipayMerchantIndirectAuthorderCreateRequest;
import com.alipay.api.request.AlipayMerchantIndirectAuthorderQuerystatusRequest;
import com.alipay.api.request.AntMerchantExpandIndirectImageUploadRequest;
import com.alipay.api.request.AntMerchantExpandIndirectZftCreateRequest;
import com.alipay.api.response.AlipayMerchantIndirectAuthorderCreateResponse;
import com.alipay.api.response.AlipayMerchantIndirectAuthorderQuerystatusResponse;
import com.alipay.api.response.AntMerchantExpandIndirectImageUploadResponse;
import com.alipay.api.response.AntMerchantExpandIndirectZftCreateResponse;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dsh.course.feignClient.account.model.Coach;
import com.dsh.course.mapper.TOperatorAuthWxMapper;
import com.dsh.guns.core.base.controller.BaseController;
import com.dsh.guns.core.common.constant.factory.PageFactory;
import com.dsh.guns.core.util.SinataUtil;
@@ -24,17 +27,46 @@
import com.dsh.guns.modular.system.model.*;
import com.dsh.guns.modular.system.service.*;
import com.dsh.guns.modular.system.util.AutoUpdateVerifierTest;
import com.dsh.guns.modular.system.util.HttpRequestUtil;
import com.dsh.guns.modular.system.util.PayMoneyUtil;
import com.dsh.guns.modular.system.util.ResultUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.binarywang.wxpay.service.BankService;
import com.github.binarywang.wxpay.v3.WechatPayUploadHttpPost;
import com.mysql.cj.x.protobuf.MysqlxExpr;
import com.sun.org.apache.bcel.internal.generic.NEW;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.security.cert.X509Certificate;
import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -51,17 +83,23 @@
    @Autowired
    private TOperatorCityService operatorCityService;
    @Autowired
    private IOperatorAuthService operatorAuthService;
    @Autowired
    private IOperatorAuthWxService operatorAuthWxService;
    @Autowired
    private IOperatorUserService operatorUserService;
    @Autowired
    private IUserService userService;
    @Autowired
    private ICityService cityService;
    @Autowired
    private IOperatorAuthService operatorAuthService;
    private PayMoneyUtil payMoneyUtil;
    @Autowired
    private IStoreService storeService;
    private String appPrivateKey = "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCi5i9nW/hGLJ3A06cZxTQdviFC7THpdSihoTYGLr9q006hu0V26ecBMY/o4w5bvIX0Ok/yofmZsVcCJpAPvbXL/uqVrIjnRRxXiaeBFThlxoBUTdunvbUSDYfzlEhJr5NvUKI6H6lz2niXlQGx4qy8Hau4ccWit9kM8jwUvsBVQoFgJA+xrjMvooA7YLopQtpOD+UJr5thApTSf1xrnr1W12yolTLEH15JmNV372cqXrYUuqnY0QsaPtxeqJUGAOcGdVLllQ7easEznP8DFBvDdHATcmp2SHNQDUEWN6MCVPbMgY06NQVqAXxqjTAYSVh+6TRu6bofPmpYC3TZB003AgMBAAECggEBAJAcR2+PA3NBYUYHeFrqBRMS8uX8ZR19kjZ7IgoSLTFaQs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djxKUl4jLN8SEe0NAjXOnz9Zaw740+aOmLpXcLWdP4uM2gIhWsvW1tEkQZCXmm7c9s/RsU8Pmzv+YL3+fSijOzA==";//支付宝开发者应用私钥
    private String alipay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmu8n/4yTHWbn7VOrNc9OsLtDL1bEQ8gC1dHkj8Wy5z0mkaOsjJRIG/28ze12M0V8jdCKuuDr5Z1OPKiqf+XO3ypguEh+mYUVMBM/cZodDFQfTY1TKLWjvQCuaqlA+QUTCK6f7T7stsgyQ1o9Jj0rXZDz6PM4QHSTzjrLIBaeqM5WIBvH+fy/X+QG5Utd+/UT0kc0JyvuKhZ65yVUd/C9VcwJJAPliRsAQNrqYterwAJ9zvw9tF11wj9W0XgJ8Ccu4x3gR1vrlLRJJo/OA97RmxPQ+5hSacWQZCUd1dwiBq+YCrKVHGTj14izRHXrLc0yBlRXo7tBOIqcy3IsvKVthQIDAQAB";//支付宝支付公钥
    private String aliAppid = "2021004105665036";//支付宝appid
    /**
     * 根据运营商id查询所有门店
     */
@@ -69,6 +107,7 @@
    @ResponseBody
    public List<TStore> getStores(Integer id)
    {
        payMoneyUtil.getMessage();
        return storeService.list(new QueryWrapper<TStore>()
                .eq("operatorId",id)
                .ne("state",3));
@@ -149,8 +188,9 @@
        page.setRecords(list);
        return super.packForBT(page);
    }
    /**
     * 跳转运营商商户去认证页面
     * 支付宝跳转运营商商户去认证页面
     */
    @RequestMapping("/proportionAuth/{id}")
    public String proportionAuth(Model model,@PathVariable("id") Integer id) {
@@ -159,38 +199,609 @@
        User byId = userService.getById(data.getUserId());
        model.addAttribute("user",byId);
        List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
        model.addAttribute("provinceList",list);
        model.addAttribute("list",list);
        model.addAttribute("data",data);
        OperatorAuth info = operatorAuthService.getOne(new QueryWrapper<OperatorAuth>().eq("operatorId", id));
        OperatorAuthAlipay info = operatorAuthService.getOne(new QueryWrapper<OperatorAuthAlipay>().eq("operatorId", id));
        model.addAttribute("item",info);
        if (info==null){
            OperatorAuth operatorAuth = new OperatorAuth();
            OperatorAuthAlipay operatorAuth = new OperatorAuthAlipay();
            model.addAttribute("item",operatorAuth);
            model.addAttribute("bodyType",0);
            model.addAttribute("code",null);
            model.addAttribute("reasons",null);
            // 0不显示二维码
            model.addAttribute("type",0);
        }else{
            if (info.getOrderStatus().equals("AUDIT_PASS")){
                // 通过才展示二维码
                model.addAttribute("type",1);
            }else{
                model.addAttribute("type",0);
            }
            model.addAttribute("code",info.getQrCode());
            model.addAttribute("item",info);
            model.addAttribute("bodyType",info.getBodyType());
            if (info.getRefuseReason()!=null && (!info.getRefuseReason().equals(""))){
                model.addAttribute("reasons",info.getRefuseReason());
            }else{
                model.addAttribute("reasons",null);
            }
            model.addAttribute("accountType",info.getAccountType());
            model.addAttribute("useType",info.getUseType());
            model.addAttribute("cardType",info.getCardType());
            model.addAttribute("reasons",info.getRefuseReason());
//            TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, info.getCityCode()));
//            List<TCity> district = cityService.list(new QueryWrapper<TCity>().eq("parent_id", one.getId()));
//            model.addAttribute("district",district);
//            if (info.getOrderStatus().equals("AUDIT_PASS")||info.getOrderStatus().equals("LEGAL_CONFIRM")||info.getOrderStatus().equals("CONTACT_CONFIRM")){
//                // 通过才展示二维码
//                model.addAttribute("type",1);
//            }else{
//                model.addAttribute("type",0);
//            }
//            model.addAttribute("code",info.getQrCode());
//            model.addAttribute("item",info);
//            model.addAttribute("bodyType",info.getBodyType());
//            if (info.getRefuseReason()!=null && (!info.getRefuseReason().equals(""))){
//                model.addAttribute("reasons",info.getRefuseReason());
//            }else{
//                model.addAttribute("reasons",null);
//            }
        }
        return PREFIX + "OperatorUser_proportionAuth.html";
    }
    /**
     * 微信跳转运营商商户去认证页面
     */
    @RequestMapping("/proportionAuthWx/{id}")
    public String proportionAuthWx(Model model,@PathVariable("id") Integer id) {
        model.addAttribute("id",id);
        TOperator data = operatorService.getById(id);
        User byId = userService.getById(data.getUserId());
        model.addAttribute("user",byId);
        List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
        model.addAttribute("list",list);
        model.addAttribute("data",data);
        OperatorAuthAlipay info = operatorAuthService.getOne(new QueryWrapper<OperatorAuthAlipay>().eq("operatorId", id));
        model.addAttribute("item",info);
        if (info==null){
            OperatorAuthAlipay operatorAuth = new OperatorAuthAlipay();
            model.addAttribute("item",operatorAuth);
            model.addAttribute("bodyType",0);
            model.addAttribute("code",null);
            model.addAttribute("reasons",null);
            // 0不显示二维码
            model.addAttribute("type",0);
        }else{
            model.addAttribute("bodyType",info.getBodyType());
            model.addAttribute("accountType",info.getAccountType());
            model.addAttribute("useType",info.getUseType());
            model.addAttribute("cardType",info.getCardType());
            model.addAttribute("reasons",info.getRefuseReason());
//            TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, info.getCityCode()));
//            List<TCity> district = cityService.list(new QueryWrapper<TCity>().eq("parent_id", one.getId()));
//            model.addAttribute("district",district);
//            if (info.getOrderStatus().equals("AUDIT_PASS")||info.getOrderStatus().equals("LEGAL_CONFIRM")||info.getOrderStatus().equals("CONTACT_CONFIRM")){
//                // 通过才展示二维码
//                model.addAttribute("type",1);
//            }else{
//                model.addAttribute("type",0);
//            }
//            model.addAttribute("code",info.getQrCode());
//            model.addAttribute("item",info);
//            model.addAttribute("bodyType",info.getBodyType());
//            if (info.getRefuseReason()!=null && (!info.getRefuseReason().equals(""))){
//                model.addAttribute("reasons",info.getRefuseReason());
//            }else{
//                model.addAttribute("reasons",null);
//            }
        }
        return PREFIX + "OperatorUser_proportionAuthWX.html";
    }
    /**
     * 支付宝跳转运营商商户去认证页面 详情页面
     */
    @RequestMapping("/proportionAuth1/{id}")
    public String proportionAuth1(Model model,@PathVariable("id") Integer id) {
        model.addAttribute("id",id);
        TOperator data = operatorService.getById(id);
        User byId = userService.getById(data.getUserId());
        model.addAttribute("user",byId);
        OperatorUser operatorId = operatorUserService.getOne(new QueryWrapper<OperatorUser>()
                .eq("operatorId", data.getId()));
        model.addAttribute("data",data);
        String state="";
        switch (operatorId.getAlipayAudit()){
            case 0:
                state="未认证";
                break;
            case 1:
                state="待审核";
                break;
            case 2:
                state="已通过";
                break;
            case 3:
                state="已拒绝";
                break;
        }
        model.addAttribute("state",state);
        OperatorAuthAlipay info = operatorAuthService.getOne(new QueryWrapper<OperatorAuthAlipay>()
                .eq("operatorId", id));
        model.addAttribute("item",info);
        List<TCity> list1 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
        model.addAttribute("list1",list1);
        if (StringUtils.hasLength(info.getProvince())){
            // 获取银行开户省
            List<TCity> list4 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
            // 获取银行开户市
            TCity city = cityService.getOne(new QueryWrapper<TCity>().eq("code", info.getProvinceCode()));
            List<TCity> list5 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, city.getId()));
            model.addAttribute("list4",list4);
            model.addAttribute("list5",list5);
        }else{
            List<TCity> list6 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
            model.addAttribute("list4",list6);
            List<TCity> list5 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 1));
            model.addAttribute("list5",list5);
        }
        model.addAttribute("bodyType",info.getBodyType());
        model.addAttribute("accountType",info.getAccountType());
        model.addAttribute("useType",info.getUseType());
        model.addAttribute("cardType",info.getCardType());
        model.addAttribute("reasons",info.getRefuseReason());
//            TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, info.getCityCode()));
//            List<TCity> district = cityService.list(new QueryWrapper<TCity>().eq("parent_id", one.getId()));
//            model.addAttribute("district",district);
//            if (info.getOrderStatus().equals("AUDIT_PASS")||info.getOrderStatus().equals("LEGAL_CONFIRM")||info.getOrderStatus().equals("CONTACT_CONFIRM")){
//                // 通过才展示二维码
//                model.addAttribute("type",1);
//            }else{
//                model.addAttribute("type",0);
//            }
//            model.addAttribute("code",info.getQrCode());
//            model.addAttribute("item",info);
//            model.addAttribute("bodyType",info.getBodyType());
//            if (info.getRefuseReason()!=null && (!info.getRefuseReason().equals(""))){
//                model.addAttribute("reasons",info.getRefuseReason());
//            }else{
//                model.addAttribute("reasons",null);
//            }
        return PREFIX + "OperatorUser_proportionAuth_info.html";
    }
    /**
     * 微信跳转运营商商户去认证页面 详情页面
     */
    @RequestMapping("/proportionAuth1Wx/{id}")
    public String proportionAuth1Wx(Model model,@PathVariable("id") Integer id) {
        model.addAttribute("id",id);
        TOperator data = operatorService.getById(id);
        User byId = userService.getById(data.getUserId());
        model.addAttribute("user",byId);
        OperatorUser operatorId = operatorUserService.getOne(new QueryWrapper<OperatorUser>()
                .eq("operatorId", data.getId()));
        model.addAttribute("data",data);
        OperatorAuth info = operatorAuthWxService.getOne(new QueryWrapper<OperatorAuth>()
                .eq("operatorId", id));
        model.addAttribute("item",info);
        List<TCity> list1 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
        model.addAttribute("list1",list1);
        if (StringUtils.hasLength(info.getProvince())){
            // 获取银行开户省
            List<TCity> list4 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
            // 获取银行开户市
            TCity city = cityService.getOne(new QueryWrapper<TCity>().eq("code", info.getProvinceCode()));
            List<TCity> list5 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, city.getId()));
            model.addAttribute("list4",list4);
            model.addAttribute("list5",list5);
        }else{
            List<TCity> list6 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
            model.addAttribute("list4",list6);
            List<TCity> list5 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 1));
            model.addAttribute("list5",list5);
        }
        model.addAttribute("bodyType",info.getBodyType());
        model.addAttribute("accountType",info.getAccountType());
        model.addAttribute("useType",info.getAccountType());
        model.addAttribute("cardType","");
        model.addAttribute("reasons",info.getRefuseReason());
        // 【申请状态】 枚举值:
        //CHECKING:资料校验中
        //ACCOUNT_NEED_VERIFY:待账户验证
        //AUDITING:审核中
        //REJECTED:已驳回
        //NEED_SIGN:待签约
        //FINISH:完成
        //FROZEN:已冻结
        //CANCELED:已作废
        switch (info.getApplymentState()){
            case "CHECKING":
                model.addAttribute("applymentState","资料校验中");
                break;
            case "ACCOUNT_NEED_VERIFY":
                model.addAttribute("applymentState","待账户验证");
                break;
            case "AUDITING":
                model.addAttribute("applymentState","审核中");
                break;
            case "REJECTED":
                model.addAttribute("applymentState","已驳回");
                break;
            case "NEED_SIGN":
                model.addAttribute("applymentState","待签约");
                break;
            case "FINISH":
                model.addAttribute("applymentState","完成");
                break;
            case "FROZEN":
                model.addAttribute("applymentState","已冻结");
                break;
            case "CANCELED":
                model.addAttribute("applymentState","已作废");
                break;
        }
        if (info.getSignState()!=null){
            switch (info.getApplymentState()){
                case "CHECKING":
                    model.addAttribute("applymentState","资料校验中");
                    break;
                case "ACCOUNT_NEED_VERIFY":
                    model.addAttribute("applymentState","待账户验证");
                    break;
                case "AUDITING":
                    model.addAttribute("applymentState","审核中");
                    break;
                case "REJECTED":
                    model.addAttribute("applymentState","已驳回");
                    break;
                case "NEED_SIGN":
                    model.addAttribute("applymentState","待签约");
                    break;
                case "FINISH":
                    model.addAttribute("applymentState","完成");
                    break;
                case "FROZEN":
                    model.addAttribute("applymentState","已冻结");
                    break;
                case "CANCELED":
                    model.addAttribute("applymentState","已作废");
                    break;
            }
        }
        model.addAttribute("state",info.getApplymentState());
        if (info.getSignState() == null){
            model.addAttribute("signState",0);
        }else{
            model.addAttribute("signState",info.getSignState());
        }
        // todo 查询申请单状态
        model.addAttribute("accountName",info.getSignState());
        model.addAttribute("accountNo",info.getSignState());
        model.addAttribute("payAmount",info.getSignState());
        model.addAttribute("destinationAccountNumber",info.getSignState());
        model.addAttribute("destinationAccountName",info.getSignState());
        model.addAttribute("destinationAccountBank",info.getSignState());
        model.addAttribute("city",info.getSignState());
        model.addAttribute("remark",info.getSignState());
        model.addAttribute("deadline",info.getSignState());
        model.addAttribute("signState",info.getSignState());
//            TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, info.getCityCode()));
//            List<TCity> district = cityService.list(new QueryWrapper<TCity>().eq("parent_id", one.getId()));
//            model.addAttribute("district",district);
//            if (info.getOrderStatus().equals("AUDIT_PASS")||info.getOrderStatus().equals("LEGAL_CONFIRM")||info.getOrderStatus().equals("CONTACT_CONFIRM")){
//                // 通过才展示二维码
//                model.addAttribute("type",1);
//            }else{
//                model.addAttribute("type",0);
//            }
//            model.addAttribute("code",info.getQrCode());
//            model.addAttribute("item",info);
//            model.addAttribute("bodyType",info.getBodyType());
//            if (info.getRefuseReason()!=null && (!info.getRefuseReason().equals(""))){
//                model.addAttribute("reasons",info.getRefuseReason());
//            }else{
//                model.addAttribute("reasons",null);
//            }
        return PREFIX + "OperatorUser_proportionAuth_infoWX.html";
    }
    /**
     * 根据所选市 获取区
     */
    @RequestMapping(value = "/getDistrict")
    @ResponseBody
    public Object onChange(String cityCode) {
        try {
            TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, cityCode));
            List<TCity> parent_id = cityService.list(new QueryWrapper<TCity>().eq("parent_id", one.getId()));
            return parent_id;
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
    }
    //    public static void main(String[] args) {
//        // 调用支付宝接口 通过银行卡号获取银行信息
//        String url = "https://ccdcapi.alipay.com/validateAndCacheCardInfo.json?_input_charset=utf-8&" +
//                "cardNo=6217003800041315031&cardBinCheck=true";
//        HashMap<String, String> hashMap = new HashMap<>();
//        String result = HttpRequestUtil.postRequest(url,hashMap);
//        System.err.println(result);
//        JSONObject json = JSONObject.parseObject(result);
//        String bank = json.getString("bank");
//        String cardType = json.getString("cardType");
//        System.err.println(bank);
//        System.err.println(cardType);
//
//    }
    public static String rsaEncryptOAEP(String message, X509Certificate certificate)
            throws IllegalBlockSizeException, IOException {
        try {
            Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-1AndMGF1Padding");
            cipher.init(Cipher.ENCRYPT_MODE, certificate.getPublicKey());
            byte[] data = message.getBytes("utf-8");
            byte[] cipherdata = cipher.doFinal(data);
            return Base64.getEncoder().encodeToString(cipherdata);
        } catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
            throw new RuntimeException("当前Java环境不支持RSA v1.5/OAEP", e);
        } catch (InvalidKeyException e) {
            throw new IllegalArgumentException("无效的证书", e);
        } catch (IllegalBlockSizeException | BadPaddingException e) {
            throw new IllegalBlockSizeException("加密原串的长度不能超过214字节");
        }
    }
    /**
     * 微信商户认证提交
     */
    @RequestMapping(value = "/wxAuth")
    @ResponseBody
    public Object wxAuth(Integer operatorId,String bodyType,String businessName,String businessNumber,String companyAddress,
                         String aliasName,
                         String license,String legalPhone,
                         String legalEmail,
                         String legalPerson,String legalAddress,
                         String IDCardTime,String IDCardEnd,String tradeTime,String endTime,
                         String leagleNumber,String legalFront,String legalBack,
                         String bankCard,String bankCardTwo,Integer useType,String bank,String bankName,
                         String accountName,String provinceCode,String province,String cityCode,String city,
                         String isBenefits,
                         String benefitsName,
                         String benefitsFront,
                         String benefitsBack,
                         String benefitsNumber,
                         String benefitsStartTime,
                         String benefitsEndTime,
                         String benefitsAddress
                        ) {
        OperatorAuth operatorId1 = operatorAuthWxService.getOne(new QueryWrapper<OperatorAuth>()
                .eq("operatorId", operatorId));
        TOperator byId = operatorService.getById(operatorId);
        Integer userId1 = byId.getUserId();
        OperatorUser userId2 = operatorUserService.getOne(new QueryWrapper<OperatorUser>()
                .eq("userId", userId1));
        userId2.setWechatAudit(1);
        // 2是企业 4个体
        if (bodyType.equals("2")){
            userId2.setWechatType(2);
        }else{
            userId2.setWechatType(4);
        }
        operatorUserService.updateById(userId2);
        if (null == endTime || "".equals(endTime)){
            endTime = "长期";
        }
        if (null == IDCardEnd || "".equals(IDCardEnd)){
            IDCardEnd = "长期";
        }
        OperatorAuth operatorAuth = new OperatorAuth();
        operatorAuth.setOperatorId(operatorId);
        operatorAuth.setBodyType(bodyType);
        operatorAuth.setAliasName(aliasName);
        operatorAuth.setBusinessName(businessName);
        operatorAuth.setAccountType(useType);
        operatorAuth.setBusinessNumber(businessNumber);
        operatorAuth.setLegalRepresentative(legalPerson);
        operatorAuth.setRegisterAddress(companyAddress);
        operatorAuth.setBusinessTerm(tradeTime);
        operatorAuth.setBusinessEnd(endTime);
        operatorAuth.setLegalPerson(legalPerson);
        operatorAuth.setLeagleNumber(leagleNumber);
        operatorAuth.setLegalTerm(IDCardTime);
        operatorAuth.setLegalEnd(IDCardEnd);
        operatorAuth.setLegalEmail(legalEmail);
        operatorAuth.setLegalAddress(legalAddress);
        operatorAuth.setBusinessPicture(license);
        operatorAuth.setLegalFront(legalFront);
        operatorAuth.setLegalBack(legalBack);
        if (!StringUtils.hasLength(license))operatorAuth.setBusinessPicture(null);
        if (!StringUtils.hasLength(legalFront))operatorAuth.setLegalFront(null);
        if (!StringUtils.hasLength(legalBack))operatorAuth.setLegalBack(null);
        operatorAuth.setBank(bank);
        operatorAuth.setAccountName(accountName);
        operatorAuth.setProvince(province);
        operatorAuth.setProvinceCode(provinceCode);
        operatorAuth.setCity(city);
        operatorAuth.setCityCode(cityCode);
        operatorAuth.setBankName(bankName);
        operatorAuth.setBankNumber(bankCard);
        operatorAuth.setAuditState(0);
        operatorAuth.setName(legalPerson);
        operatorAuth.setLegalPhone(legalPhone);
        operatorAuth.setPhone(legalPhone);
        operatorAuth.setNumber(leagleNumber);
        operatorAuth.setBankCardTwo(bankCardTwo);
        operatorAuth.setIsBenefits(isBenefits);
        if (isBenefits.equals("true")){
            operatorAuth.setBenefitsName(legalPerson);
            operatorAuth.setBenefitsFront(legalFront);
            operatorAuth.setBenefitsBack(legalBack);
            operatorAuth.setBenefitsNumber(leagleNumber);
            operatorAuth.setBenefitsStartTime(IDCardTime);
            operatorAuth.setBenefitsEndTime(IDCardEnd);
            operatorAuth.setBenefitsAddress(legalAddress);
            benefitsName = legalPerson;
            benefitsFront = legalFront;
            benefitsBack =legalBack;
            benefitsNumber =leagleNumber;
            benefitsStartTime =IDCardTime;
            benefitsEndTime =IDCardEnd;
            benefitsAddress = legalAddress;
        }
        LocalDateTime currentDateTime = LocalDateTime.now();
        // 格式化日期和时间信息
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
        String formattedDateTime = currentDateTime.format(formatter);
        // 生成随机数,填充剩余位数
        Random random = new Random();
        StringBuilder randomPart = new StringBuilder();
        for (int i = 0; i < 3; i++) {
            // 大写字母
            randomPart.append((char) (random.nextInt(26) + 'A'));
        }
        // 组合业务申请编号 若申请单被驳回,可填写相同的“业务申请编号”,即可覆盖修改原申请单信息 。
        String orderNumber = formattedDateTime + randomPart;
        if (operatorId1 == null){
            operatorAuth.setOutBizNo(orderNumber);
            operatorAuth.setAuditState(1);
            operatorAuth.setApplymentState("CHECKING");
            operatorAuthWxService.save(operatorAuth);
        }else{
            operatorAuth.setId(operatorId1.getId());
            operatorAuth.setBenefitsFront(operatorId1.getLegalFront());
            operatorAuth.setBenefitsBack(operatorId1.getLegalBack());
            BeanUtils.copyProperties(operatorAuth,operatorId1);
            operatorId1.setAuditState(1);
            operatorId1.setApplymentState("CHECKING");
            operatorAuthWxService.updateById(operatorId1);
        }
        String param="{"+
                "\"out_request_no\" :"+ "\""+orderNumber+"\""+","+
                "    \"organization_type\" :"+"\""+bodyType+"\""+","+
                "    \"finance_institution\" : false,\n" +
                "    \"business_license_info\" : {\n" +
                // 主体为“个体工商户/企业”时,不填。
//                "cert_type:" + "CERTIFICATE_TYPE_2388,"+
                "      \"business_license_copy\" :"+ "\""+license+"\""+","+
                "      \"business_license_number\" : "+"\""+businessNumber+"\""+","+
                "      \"merchant_name\" : "+ "\""+businessName+"\""+","+
                "      \"legal_person\" : "+ "\""+legalPerson+"\""+","+
                "\"company_address\" :"+ "\""+companyAddress+"\""+","+
                "      \"business_time\" : \"[\\\\\\\""+tradeTime+"\\\\\\\",\\\\\\\""+endTime+"\\\\\\\"]\"\n" +
                "    },\n" +
//            "finance_institution_info:" +" {"+
//                "finance_type:" + "BANK_AGENT,"+
//                        "finance_license_pics:" +"["+
//                "example_finance_license_pics"+
//      "]},"+
//            "id_holder_type:" + "LEGAL,"+
                "    \"id_doc_type\" : \"IDENTIFICATION_TYPE_MAINLAND_IDCARD\",\n" +
//                    "authorize_letter_copy:" + "47ZC6GC-vnrbEny_Ie_An5-tCpqxucuxi-vByf3Gjm7KEIUv0OF4wFNIO4kqg05InE4d2I6_H7I4,"+
                "    \"id_card_info\" : {\n" +
                "      \"id_card_copy\" : "+ "\""+legalFront+"\""+","+
                "      \"id_card_national\" : "+ "\""+legalBack+"\""+","+
                "      \"id_card_name\" : "+ "\""+legalPerson+"\""+","+
                "      \"id_card_number\" : "+ "\""+leagleNumber+"\""+","+
                "      \"id_card_address\" : "+ "\""+legalAddress+"\""+","+
                "      \"id_card_valid_time_begin\" : "+ "\""+IDCardTime+"\""+","+
                "      \"id_card_valid_time\" : "+ "\""+IDCardEnd+"\""+","+
//            "id_doc_info:"  +
//                "{id_doc_name:" + "jTpGmxUX3FBWVQ5NJTZvlKX_gdU4cRz7z5NxpnFuAxhBTEO_PvWkfSCJ3zVIn001D8daLC-ehEuo0BJqRTvDujqhThn4ReFxikqJ5YW6zFQ,"+
//                        "id_doc_number:" + "jTpGmxUX3FBWVQ5NJTZvlKX_gdU4cRz7z5NxpnFuAxhBTEO_PvWkfSCJ3zVIn001D8daLC-ehEuo0BJqRTvDujqhThn4ReFxikqJ5YW6zFQ,"+
//                        "id_doc_copy:" + "47ZC6GC-vnrbEny__Ie_An5-tCpqxucuxi-vByf3Gjm7KE53JXvGy9tqZm2XAUf-4KGprrKhpVBDIUv0OF4wFNIO4kqg05InE4d2I6_H7I4,"+
//                        "id_doc_copy_back:" + "47ZC6GC-vnrbEny__Ie_An5-tCpqxucuxi-vByf3Gjm7KE53JXvGy9tqZm2XAUf-4KGprrKhpVBDIUv0OF4wFNIO4kqg05InE4d2I6_H7I4,"+
//                        "id_doc_address:" + "jTpGmxUX3FBWVQ5NJTZvlKX_gdU4cRz7z5NxpnFuAxhBTEO_PvWkfSCJ3zVIn001D8daLC-ehEuo0BJqRTvDujqhThn4ReFxikqJ5YW6zFQ,"+
//                        "doc_period_begin:" + "2019-06-06,"+
//                        "doc_period_end:" + "2020-01-02},"+
                "    \"owner\" : true,\n" +
                "    \"account_info\" : {\n" +
                "      \"bank_account_type\" :  "+ "\""+useType+"\""+","+
                "      \"account_bank\" : "+ "\""+bank+"\""+","+
                "      \"account_name\" : "+ "\""+accountName+"\""+","+
                "      \"bank_address_code\" :"+ "\""+cityCode+"\""+","+
                "      \"bank_branch_id\" : "+ "\""+bankCardTwo+"\""+","+
                "      \"bank_name\" : "+ "\""+bankName+"\""+","+
                "      \"account_number\" : "+ "\""+bankCard+"\""+","+
                "    \"contact_info\" : {\n" +
                "      \"contact_type\" : \"65\",\n" +
                "      \"contact_name\" :"+ "\""+legalPerson+"\""+","+
                "      \"contact_id_doc_type\" : \"IDENTIFICATION_TYPE_MAINLAND_IDCARD\",\n" +
                "      \"contact_id_card_number\" : "+ "\""+leagleNumber+"\""+","+
                "      \"contact_id_doc_copy\" : "+ "\""+legalFront+"\""+","+
                "      \"contact_id_doc_copy_back\" :"+ "\""+legalBack+"\""+","+
//              "contact_id_doc_period_begin:"+  "2019-06-06,"+
//              "contact_id_doc_period_end:" + "2026-06-06,"+
//              "business_authorization_letter:" + "47ZC6GC-vnrbEny_Ie_An5-tCpqxucuxi-vByf3Gjm7KEIUv0OF4wFNIO4kqg05InE4d2I6_H7I4,"+
                "      \"mobile_phone\" : "+ "\""+legalPhone+"\""+","+
                "      \"contact_email\" : "+ "\""+legalEmail+"\""+
                "    },\n" +
                "    \"sales_scene_info\" : {\n" +
                "      \"store_name\" : \"爱烧烤\",\n" +
                "      \"store_url\" : \"http://www.qq.com\",\n" +
                "      \"store_qr_code\" : \"jTpGmxUX3FBWVQ5NJTZvlKX_gdU4cRz7z5NxpnFuAxhBTEO_PvWkfSCJ3zVIn001D8daLC-ehEuo0BJqRTvDujqhThn4ReFxikqJ5YW6zFQ\",\n" +
                "      \"mini_program_sub_appid\" : \"wxa123344545577\"\n" +
                "    },\n" +
                "    \"settlement_info\" : {\n" ;
        if (Integer.parseInt(bodyType) == 4){
            param =  param+"      \"settlement_id\" : 802,\n" +
                    "      \"qualification_type\" : \"休闲娱乐/旅游服务\"\n" +"    },\n" ;
        }else{
            param =  param+"      \"settlement_id\" : 800,\n" +
                    "      \"qualification_type\" : \"休闲娱乐/旅游服务\"\n" +"    },\n" ;
        }
        param+= "    \"merchant_shortname\" : "+ "\""+aliasName+"\""+
//                    "qualifications:" + "[\"jTpGmxUX3FBWVQ5NJTZvlKX_gdU4cRz7z5NxpnFuAxhBTEO_PvWkfSCJ3zVIn001D8daLC-ehEuo0BJqRTvDujqhThn4ReFxikqJ5YW6zFQ\",\"47ZC6GC-vnrbEny__Ie_An5-tCpqxucuxi-vByf3Gjm7KE53JXvGy9tqZm2XAUf-4KGprrKhpVBDIUv0OF4wFNIO4kqg05InE4d2I6_H7I4\"],"+
//                    "business_addition_pics:" + "[\"jTpGmxUX3FBWVQ5NJTZvlKX_gdU4cRz7z5NxpnFuAxhBTEO_PvWkfSCJ3zVIn001D8daLC-ehEuo0BJqRTvDujqhThn4ReFxikqJ5YW6zFQ\",\"47ZC6GC-vnrbEny__Ie_An5-tCpqxucuxi-vByf3Gjm7KE53JXvGy9tqZm2XAUf-4KGprrKhpVBDIUv0OF4wFNIO4kqg05InE4d2I6_H7I4\"],"+
//                    "business_addition_desc:" + "特殊情况,说明原因,"+
//                    "ubo_info_list:"+  "[{"+
                "\"ubo_info_list\" : [\n" +
                "      {\n" +
                "        \"ubo_id_doc_type\" : \"IDENTIFICATION_TYPE_MAINLAND_IDCARD\",\n" +
                "        \"ubo_id_doc_copy\" : "+ "\""+benefitsFront+"\""+
                "        \"ubo_id_doc_copy_back\" : "+ "\""+benefitsBack+"\""+
                "        \"ubo_id_doc_name\" : "+ "\""+benefitsName+"\""+
                "        \"ubo_id_doc_number\" : "+ "\""+benefitsNumber+"\""+
                "        \"ubo_id_doc_address\" : "+ "\""+benefitsAddress+"\""+
                "        \"ubo_id_doc_period_begin\" : "+ "\""+benefitsStartTime+"\""+
                "        \"ubo_id_doc_period_end\" : "+ "\""+benefitsEndTime+"\""+
                "      }\n" +
                "    ]"+
                "  }\n"+
                "  }\n"+
                "  }\n";
        // 使用 Jackson 解析 JSON
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            // 将 JSON 字符串解析为 Map
            Map<String, Object> map = objectMapper.readValue(param, Map.class);
            // 输出 Map 中的内容
            for (Map.Entry<String, Object> entry : map.entrySet()) {
                System.out.println(entry.getKey() + ": " + entry.getValue());
            }
            System.err.println(map);
            String s = HttpRequestUtil.postRequest1("https://api.mch.weixin.qq.com/v3/ecommerce/applyments/", map);
            System.err.println("返回结果:"+s);
            JSONObject jsonObject = JSON.parseObject(s);
            String string = jsonObject.getString("out_request_no");
            // 获取业务申请编号 后续用该字段查询申请状态
            operatorAuth.setOrderNo(string);
            System.err.println(jsonObject);
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.err.println(param);
        return SUCCESS_TIP;
    }
    /**
@@ -198,24 +809,54 @@
     */
    @RequestMapping(value = "/auth")
    @ResponseBody
    public Object auth(String beneficiaryEnd,String businessEnd,String legalEnd, String name,String phone,String number
            ,Integer operatorId,String bodyType,Integer type,String businessName,String businessNumber,
                       String legalRepresentative,String registerAddress,String businessTerm,String businessPicture,
                       String legalPerson,String legalNumber,String legalPhone,String legalEmail,String legalTerm,
                       String legalAddress,String legalFront,String legalBack,Integer accountType,String bank,
                       String accountName,String province,String provinceCode,String city,String cityCode,
                       String bankName,String bankNumber,String isBeneficiary,String beneficiary,String beneficiaryPhone,
                       String beneficiaryNumber,String beneficiaryAddress,String beneficiaryTerm,String beneficiaryFront,String beneficiaryBack,
                       String remark) {
    public Object auth(Integer operatorId,String bodyType,String businessName,String aliasName,String businessNumber,
                       String license,String name,String phone,String shopProvinceCode,String shopProvince,String shopCityCode,
                       String shopCity, String shopDistrictCode,String shopDistrict,String registerAddress,String legalPerson,
                       String leagleNumber,String legalFront,String legalBack,String accountType,String alipayAccount,
                       String bankCard,String useType,String cardType,String bankName,String bankNameTwo,
                       String accountName,String provinceCode,String province,String cityCode,String city,String zfbAccount,
                       String iqImage) {
        UUID uuid = UUID.randomUUID();
        OperatorAuth data = operatorAuthService.getOne(new QueryWrapper<OperatorAuth>().eq("operatorId", operatorId));
        OperatorAuth operatorAuth = new OperatorAuth();
        // 通过运营商id查询
        TOperator byId = operatorService.getById(operatorId);
        Integer userId1 = byId.getUserId();
        OperatorUser userId2 = operatorUserService.getOne(new QueryWrapper<OperatorUser>()
                .eq("userId", userId1));
        userId2.setAlipayAudit(1);
        // 01是企业
        if (bodyType.equals("01")){
            userId2.setAlipayType(2);
        }else{
            userId2.setAlipayType(1);
        }
        operatorUserService.saveOrUpdate(userId2);
        OperatorAuthAlipay data = operatorAuthService.getOne(new QueryWrapper<OperatorAuthAlipay>().eq("operatorId", operatorId));
        // 调用支付宝接口 通过银行卡号获取银行信息
        String url = "https://ccdcapi.alipay.com/validateAndCacheCardInfo.json?_input_charset=utf-8&" +
                "cardNo="+bankCard+"&cardBinCheck=true";
        HashMap<String, String> hashMap = new HashMap<>();
        String result = HttpRequestUtil.postRequest(url,hashMap);
        System.err.println(result);
        JSONObject json2 = JSONObject.parseObject(result);
        String bank = json2.getString("bank");
        String cardType1 = json2.getString("cardType");
        // 根据银行卡号查询所属银行
        String group=bank;
//        if(StringUtils.hasLength(bankName)){
//            Pattern pattern = Pattern.compile(".*[\\u4e00-\\u9fa5]+"); // 只保留汉字部分
//            Matcher matcher = pattern.matcher(bankName);
//            group = matcher.group();
//            if (matcher.find()) {
//                System.out.println("银行名称简写为:" + matcher.group());
//            } else {
//                System.out.println("无法获取到银行名称简写!");
//                return 5007;
//            }
//        }
        OperatorAuthAlipay operatorAuth = new OperatorAuthAlipay();
        if (data!=null){
            operatorAuth.setId(data.getId());
            if(businessPicture==null || businessPicture.equals("")){
                operatorAuth.setBusinessPicture(data.getBusinessPicture());
                businessPicture = data.getBusinessPicture();
            }
            if(legalFront==null || legalFront.equals("")){
                legalFront = data.getLegalFront();
                operatorAuth.setLegalFront(data.getLegalFront());
@@ -224,16 +865,21 @@
                legalBack = data.getLegalBack();
                operatorAuth.setLegalBack(data.getLegalBack());
            }
            if(beneficiaryFront==null || beneficiaryFront.equals("")){
                beneficiaryFront = data.getBeneficiaryFront();
                operatorAuth.setBeneficiaryFront(data.getBeneficiaryFront());
            if(iqImage==null || iqImage.equals("")){
                iqImage = data.getIqImage();
                operatorAuth.setIqImage(data.getIqImage());
            }
            if(beneficiaryBack==null || beneficiaryBack.equals("")){
                beneficiaryBack = data.getBeneficiaryBack();
                operatorAuth.setBeneficiaryBack(data.getBeneficiaryBack());
            if(license==null || license.equals("")){
                license = data.getCertImage();
                operatorAuth.setCertImage(data.getCertImage());
            }
        }else{
            if(businessPicture==null || businessPicture.equals("")){
            operatorAuth.setLegalFront(legalFront);
            operatorAuth.setLegalBack(legalBack);
            operatorAuth.setIqImage(iqImage);
            operatorAuth.setCertImage(license);
            if(license==null || license.equals("")){
                // 未上传营业执照
                return 5001;
            }
@@ -245,196 +891,187 @@
                // 未上传法人身份证背面照
                return 5003;
            }
            if (businessPicture!=null && businessPicture.equals("ENTERPRISE")){
                if(beneficiaryFront==null || beneficiaryFront.equals("")){
                    // 未上传受益人身份证正面照
                    return 5004;
                }
                if(beneficiaryBack==null || beneficiaryBack.equals("")){
                    // 未上传受益人身份证背面照
                    return 5005;
                }
            }
        }
        String numericUUID = uuid.toString().replaceAll("-", "");
        operatorAuth.setOutBizNo(numericUUID);
        operatorAuth.setOperatorId(operatorId);
        operatorAuth.setRegisterAddress(registerAddress);
        operatorAuth.setAliasName(aliasName);
        operatorAuth.setBodyType(bodyType);
        operatorAuth.setName(name);
        operatorAuth.setPhone(phone);
        operatorAuth.setNumber(number);
        operatorAuth.setBusinessEnd(businessEnd);
        operatorAuth.setLegalEnd(legalEnd);
        operatorAuth.setBeneficiaryEnd(beneficiaryEnd);
        operatorAuth.setOperatorId(operatorId);
        operatorAuth.setBodyType(bodyType);
        operatorAuth.setType(type);
        operatorAuth.setBusinessName(businessName);
        operatorAuth.setBusinessNumber(businessNumber);
        operatorAuth.setLegalRepresentative(legalRepresentative);
        operatorAuth.setRegisterAddress(registerAddress);
        operatorAuth.setBusinessTerm(businessTerm);
        operatorAuth.setOutBizNo(numericUUID);
        operatorAuth.setBusinessPicture(businessPicture);
        operatorAuth.setCertImage(license);
        operatorAuth.setLegalPerson(legalPerson);
        operatorAuth.setLeagleNumber(legalNumber);
        operatorAuth.setLegalPhone(legalPhone);
        operatorAuth.setLegalEmail(legalEmail);
        operatorAuth.setLegalTerm(legalTerm);
        operatorAuth.setLegalAddress(legalAddress);
        operatorAuth.setLegalFront(legalFront);
        operatorAuth.setLegalBack(legalBack);
        operatorAuth.setLeagleNumber(leagleNumber);
        operatorAuth.setAccountType(accountType);
        operatorAuth.setBank(bank);
        operatorAuth.setBankName(bankName);
        operatorAuth.setAccountName(accountName);
        operatorAuth.setBankCard(bankCard);
        operatorAuth.setProvince(province);
        operatorAuth.setProvinceCode(provinceCode);
        operatorAuth.setCity(city);
        operatorAuth.setCityCode(cityCode);
        operatorAuth.setBankName(bankName);
        operatorAuth.setBankNumber(bankNumber);
        operatorAuth.setShopCity(shopCity);
        operatorAuth.setShopProvince(shopProvince);
        operatorAuth.setShopProvinceCode(shopProvinceCode);
        operatorAuth.setShopCityCode(shopCityCode);
        if(StringUtils.hasLength(province)&& province.equals("请选择省")){
            operatorAuth.setProvince(null);
        }
        if(StringUtils.hasLength(city)&& province.equals("请选择市")){
            operatorAuth.setCity(null);
        }
        operatorAuth.setProvince(province);
        operatorAuth.setProvinceCode(provinceCode);
        operatorAuth.setShopDistrict(shopDistrict);
        operatorAuth.setShopDistrictCode(shopDistrictCode);
        operatorAuth.setAlipayAccount(alipayAccount);
        operatorAuth.setUseType(useType);
        operatorAuth.setCardType(cardType);
        operatorAuth.setBankNameTwo(bankNameTwo);
        operatorAuth.setAuditState(0);
        operatorAuth.setIsBeneficiary(isBeneficiary);
        operatorAuth.setBeneficiary(beneficiary);
        operatorAuth.setBeneficiaryNumber(beneficiaryNumber);
        operatorAuth.setBeneficiaryAddress(beneficiaryAddress);
        operatorAuth.setBeneficiaryTerm(beneficiaryTerm);
        operatorAuth.setBeneficiaryFront(beneficiaryFront);
        operatorAuth.setBeneficiaryBack(beneficiaryBack);
        operatorAuth.setRefuseReason("");
        operatorAuth.setRemark(remark);
        operatorAuth.setZfbAccount(zfbAccount);
        // 将图片上传至阿里存储
        // 营业执照
        String string = uploadImg(businessPicture).toString();
        String string = uploadImg(license).toString();
        // 法人身份证正面照
        legalFront = uploadImg(legalFront).toString();
        // 法人身份证背面照
        legalBack = uploadImg(legalBack).toString();
        if (bodyType.equals("ENTERPRISE")){
            // 受益人身份证正面照
            beneficiaryFront=uploadImg(beneficiaryFront).toString();
            // 受益人身份证背面照
            beneficiaryBack=uploadImg(beneficiaryBack).toString();
        }
        //第二步:提交申请单
        AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do","2021004105665036",
                "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCi5i9nW/hGLJ3A06cZxTQdviFC7THpdSihoTYGLr9q006hu0V26ecBMY/o4w5bvIX0Ok/yofmZsVcCJpAPvbXL/uqVrIjnRRxXiaeBFThlxoBUTdunvbUSDYfzlEhJr5NvUKI6H6lz2niXlQGx4qy8Hau4ccWit9kM8jwUvsBVQoFgJA+xrjMvooA7YLopQtpOD+UJr5thApTSf1xrnr1W12yolTLEH15JmNV372cqXrYUuqnY0Q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7MhZeN7dweaOjwDs8mgtjHQ96mL4XGCDhR0BZ/wIURvZ/6iaGdhbbu9unlsWj3uQKBgQCmZYdsbbZkd3ev6f8rwyvMz+DrCQyYpY44cegBYuJgrZiQnL2fJioeN7ixX0UM48SfwsZEIrzshP/LGAwnc2MdjxKUl4jLN8SEe0NAjXOnz9Zaw740+aOmLpXcLWdP4uM2gIhWsvW1tEkQZCXmm7c9s/RsU8Pmzv+YL3+fSijOzA==","json","GBK",
                "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmu8n/4yTHWbn7VOrNc9OsLtDL1bEQ8gC1dHkj8Wy5z0mkaOsjJRIG/28ze12M0V8jdCKuuDr5Z1OPKiqf+XO3ypguEh+mYUVMBM/cZodDFQfTY1TKLWjvQCuaqlA+QUTCK6f7T7stsgyQ1o9Jj0rXZDz6PM4QHSTzjrLIBaeqM5WIBvH+fy/X+QG5Utd+/UT0kc0JyvuKhZ65yVUd/C9VcwJJAPliRsAQNrqYterwAJ9zvw9tF11wj9W0XgJ8Ccu4x3gR1vrlLRJJo/OA97RmxPQ+5hSacWQZCUd1dwiBq+YCrKVHGTj14izRHXrLc0yBlRXo7tBOIqcy3IsvKVthQIDAQAB","RSA2");
        AlipayMerchantIndirectAuthorderCreateRequest request = new AlipayMerchantIndirectAuthorderCreateRequest();
        operatorAuthService.saveOrUpdate(operatorAuth);
        AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",
                aliAppid,
                appPrivateKey,
                "json","GBK",
                alipay_public_key,
                "RSA2");
        AntMerchantExpandIndirectZftCreateRequest request = new AntMerchantExpandIndirectZftCreateRequest();
        String param = "{" +
                "  \"out_biz_no\":\""+uuid+"\"," +
                "  \"contact_person_info\":{" +
                "    \"contact_name\":\""+name+"\"," +
                "    \"contact_phone_no\":\""+phone+"\"," +
                "    \"contact_card_no\":\""+number+"\"," +
                "    \"contact_cert_type\":\"RESIDENT\"" +
                "  }," +
                "  \"auth_identity_info\":{" +
                "    \"identity_type\":\""+bodyType+"\"," +
                "    \"is_financial_org\":false," +
                "    \"certificate_type\":\"BUSINESS_CERT\"," +
                "    \"certificate_info\":{" +
                "      \"cert_no\":\""+businessNumber+"\"," +
                "      \"cert_image\":\""+string+"\"," +
                "      \"merchant_name\":\""+businessName+"\"," +
                "      \"legal_person_name\":\""+legalRepresentative+"\"," +
                "      \"register_address\":\""+registerAddress+"\"," +
                "      \"effect_time\":\""+businessTerm+"\"," +
                "      \"expire_time\":\""+businessEnd+"\"" +
                "    }," +
                "    }," +
                "  \"legal_person_info\":{" +
                "    \"card_type\":\"RESIDENT\"," +
                "    \"person_name\":\""+legalRepresentative+"\"," +
                "    \"card_no\":\""+legalNumber+"\"," +
                "    \"effect_time\":\""+legalTerm+"\"," +
                "    \"expire_time\":\""+legalEnd+"\"," +
                "    \"card_front_img\":\""+legalFront+"\"," +
                "    \"card_back_img\":\""+legalBack+"\"," +
                "    \"is_benefit_person\":"+isBeneficiary+"" +
                "  },";
        String bene = "  \"benefit_person_info\":{" +
                "    \"person_name\":\""+beneficiary+"\"," +
                "    \"card_no\":\""+beneficiaryNumber+"\"," +
                "    \"card_type\":\"RESIDENT\"," +
                "    \"effect_time\":\""+beneficiaryTerm+"\"," +
                "    \"expire_time\":\""+beneficiaryEnd+"\"," +
                "    \"card_front_img\":\""+beneficiaryFront+"\"," +
                "    \"card_back_img\":\""+beneficiaryBack+"\"" +
                "  },";
        if (bodyType.equals("ENTERPRISE")){
                "  \"external_id\":\""+numericUUID+"\"," +
                "  \"merchant_type\":\""+bodyType+"\"," +
                "  \"name\":\""+businessName+"\"," +
                "  \"alias_name\":\""+aliasName+"\"," +
                "  \"mcc\":\"B0068\"," +
                "  \"cert_no\":\""+businessNumber+"\"," +
                "  \"cert_type\":\"201\"," +
                "  \"cert_image\":\""+string+"\"," +
                "  \"legal_name\":\""+legalPerson+"\"," +
                "  \"legal_cert_no\":\""+leagleNumber+"\"," +
                "  \"legal_cert_front_image\":\""+legalFront+"\"," +
                "  \"legal_cert_back_image\":\""+legalBack+"\"," +
                "  \"contact_infos\":[" +
                "    {" +
                "      \"name\":\""+name+"\"," +
                "      \"mobile\":\""+phone+"\"," +
                "    }" +
                "  ],";
        String biz_cards="  \"biz_cards\":[" +
                "    {" +
                "      \"account_holder_name\":\""+accountName+"\"," +
                "      \"account_no\":\""+bankCard+"\"," +
                "      \"account_inst_province\":\""+province+"\"," +
                "      \"account_inst_city\":\""+city+"\"," +
                "      \"account_branch_name\":\""+bankNameTwo+"\"," +
                "      \"usage_type\":\""+useType+"\"," +
                "      \"account_type\":\""+cardType+"\"," +
                "      \"account_inst_name\":\""+bankName+"\"," +
                "      \"account_inst_id\":\""+group+"\"," +
                "    }" +
                "  ]," ;
        // 结算类型 支付宝账户 / 银行卡
        String type ;
        // 结算类型为支付宝 填写支付宝账号 结算类型为银行卡填写银行卡号
        String account;
        if (accountType.equals("bankCard")){
            type = accountType;
            account = bankCard;
        }else{
            type =  accountType;
            account = alipayAccount;
        }
        String res=
                "  \"service\":[" +
                        "    \"app支付\"" +
                        "  ]," +
                        "  \"alipay_logon_id\":" +
                        "    \""+zfbAccount+"\"" +
                        "  ," +
                        "  \"sites\":[" +
                        "    {" +
                        "      \"site_type\":\"02\"," +
                        "      \"site_name\":\"玩湃生活\"," +
                        "      \"tiny_app_id\":\"wx82f853a410b0c7c0\"" +
                        "    }" +
                        "  ]," +
                        "  \"cert_name\":\""+businessName+"\","+
                        "  \"binding_alipay_logon_id\":\""+zfbAccount+"\","+
                        "  \"default_settle_rule\":{" +
                        "    \"default_settle_type\":\""+type+"\"," +
                        "    \"default_settle_target\":\""+account+"\"" +
                        "  }" +
                        "}";
        if (accountType.equals("bankCard")){
            request.setBizContent(param
                    + bene+
                    "}");
                    + biz_cards+res);
        }else{
            request.setBizContent(param
                    +
                    "}");
                    +res);
        }
        AlipayMerchantIndirectAuthorderCreateResponse response = null;
        AntMerchantExpandIndirectZftCreateResponse response = null;
        try {
            response = alipayClient.execute(request);
        } catch (AlipayApiException e) {
            e.printStackTrace();
        }
        if(response.isSuccess()){
            System.out.println("上传认证单");
            System.out.println("调用成功");
            JSONObject json = JSONObject.parseObject(response.getBody());
            JSONObject json1 = json.getJSONObject("alipay_merchant_indirect_authorder_create_response");
            String order_no = json1.getString("order_no");
            String order_status = json1.getString("order_status");
//            // 申请单号
//            String orderNo = r.getString("order_no");
            /**
             * 状态 审核中(AUDITING)、待联系人确认(CONTACT_CONFIRM),
             * 待法人确认(LEGAL_CONFIRM)、审核通过(AUDIT_PASS)、
             * 审核失败(AUDIT_REJECT)、已冻结(AUDIT_FREEZE)、
             * 已撤回(CANCELED)、联系人处理中(CONTACT_PROCESSING)
             */
//            String orderStatus = r.getString("order_status");
            JSONObject json1 = json.getJSONObject("ant_merchant_expand_indirect_zft_create_response");
            String order_no = json1.getString("order_id");
            System.err.println("订单号"+order_no);
            operatorAuth.setOrderNo(order_no);
            operatorAuth.setOrderStatus(order_status);
            operatorAuth.setRefuseReason("");
            operatorAuthService.saveOrUpdate(operatorAuth);
            // 通过运营商id找到用户id
            TOperator byId = operatorService.getById(operatorId);
            if (byId!=null){
                Integer userId = byId.getUserId();
                OperatorUser userId1 = operatorUserService.getOne(new QueryWrapper<OperatorUser>().eq("userId", userId));
                if (userId1!=null){
                    // 设置为审核中状态
                    userId1.setAlipayAudit(1);
                    if (bodyType.equals("ENTERPRISE")){
                        userId1.setAlipayType(2);
                    }else{
                        userId1.setAlipayType(1);
                    }
//                    userId1.setWechatAudit(1);
                    operatorUserService.updateById(userId1);
                    operatorAuth.setQrCode(null);
                    operatorAuthService.saveOrUpdate(operatorAuth);
                    // 根据选择类型修改认证类型
                }
            Integer userId = operatorService.getById(operatorId).getUserId();
            OperatorUser user = operatorUserService.getOne(new QueryWrapper<OperatorUser>().eq("userId", userId));
            user.setAlipayAudit(1);
            // 01是企业
            if (bodyType.equals("01")){
                user.setAlipayType(2);
            }else{
                user.setAlipayType(1);
            }
            operatorUserService.saveOrUpdate(user);
        } else {
            System.out.println("调用失败");
            Integer userId = operatorService.getById(operatorId).getUserId();
            OperatorUser user = operatorUserService.getOne(new QueryWrapper<OperatorUser>().eq("userId", userId));
            user.setAlipayAudit(3);
            operatorUserService.saveOrUpdate(user);
            operatorAuth.setRefuseReason(response.getSubMsg());
            if (response.getCode().equals("40004")){
                String subMsg = response.getSubMsg();
                return ResultUtil.error(subMsg);
            }
        }
        return SUCCESS_TIP;
        return ResultUtil.success();
    }
    public static Object uploadImg(String img){
        String privateKey = "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCq1V7akWZ/V9mr8NGW2CihIbY93M7M33LpVM5y63qEuN7yqyJV197WT6c7uHBcttY6cJLawXLihgC8KF6ZzdXWbm4n4RiigxIaz9LbSVBjYplkNgG2rg7W7dB8wrrqcwBQU0n+pFX3KWJkHRXDugqE21VCGgzySKQBkhiztmTI/z039PdWp2RTGLiL/OuwVrPjQv3He2orYIZgADWid0mtZXCEFosDkaQDTEqCfuDEuMouEiaIk/lw0ZWxiR1Fvfr82nO0r94lM/CC1wNRif2+2ESR+YystsWQPm16eRgS3wAQz2cOTP4L5VNKNzcUAgxTQK3Bj8GvqrYUUlcC7VCTAgMBAAECggEAPKmYDTUkmIOxoATb6BzKEK3P8Re/t7CBNaoPxW8pCog7YyCyCJmnX6LZV7Oe8s1aNVZUT6nyCc5b5HTRYvxcutBr/W1JOiwg+bRiw8u86A3TOmqTITOdwWShbCwaA7binaN12x6wCByB+9r4J5Cgu5zHIbnubvqsgoJGk0ppb5XbyYkikOAXPHli4PUe4GOorSuhRdq3XlGWiMwh4yt48kF4vP+2ByuDOYQU6LjGs0wn/5LpN+ReLdXTab65Cz7WYTDrTndyIrhFg7cyT5m2gtiJuEgIJ45uaaeGNIecV6JSnRsEv4YD4m+I58yhyyvw9zd0Z5qP04QNjy7OK2UeQQKBgQD/EJpaVv0RR83Z6Hp2YVrPoiMz279U5bgkBbcxgr9GR2YYE3rrHqBdqch1Uit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YCrKVHGTj14izRHXrLc0yBlRXo7tBOIqcy3IsvKVthQIDAQAB";//支付宝支付公钥
        String aliAppid = "2021004105665036";//支付宝appid
        AlipayConfig alipayConfig = new AlipayConfig();
        alipayConfig.setServerUrl("https://openapi.alipay.com/gateway.do");
        alipayConfig.setAppId("2021004123692417");
        alipayConfig.setPrivateKey(privateKey);
        alipayConfig.setAppId(aliAppid);
        alipayConfig.setPrivateKey(appPrivateKey);
        alipayConfig.setFormat("json");
        alipayConfig.setAlipayPublicKey(alipayPublicKey);
        alipayConfig.setAlipayPublicKey(alipay_public_key);
        alipayConfig.setCharset("UTF8");
        alipayConfig.setSignType("RSA2");
        AlipayClient alipayClient = null;
@@ -471,22 +1108,165 @@
    }
    /**
     * 查询进件申请单审核状态
     */
    public  JSONObject queryState(String orderNo) {
        String url = "https://api.mch.weixin.qq.com/v3/ecommerce/applyments/out-request-no/"+orderNo;
        String req1 = HttpRequestUtil.getReq1(url, new HashMap<>());
        System.err.println("查询申请单审核状态字符串"+req1);
        JSONObject jsonObject = JSON.parseObject(req1);
        System.err.println("查询申请单审核状态Json"+jsonObject);
        String applymentState = jsonObject.getString("applyment_state");
        String outBizNo = jsonObject.getString("out_request_no");
        OperatorAuth operatorAuth = operatorAuthWxService.getOne(
                new QueryWrapper<OperatorAuth>()
                .eq("outBizNo", outBizNo));
        OperatorUser operatorUser = operatorUserService.getOne(new QueryWrapper<OperatorUser>()
                .eq("operatorId", operatorAuth.getOperatorId()));
        // 审核状态
        operatorAuth.setApplymentState(applymentState);
        if (applymentState.equals("REJECTED") || applymentState.equals("FROZEN")){
            operatorUser.setWechatAudit(3);
            operatorAuth.setAuditState(2);
            // 如果被拒 赋值拒绝原因
            operatorAuth.setRefuseReason(jsonObject.getJSONObject("audit_detail").getString("reject_reason"));
        }
        if (applymentState.equals("NEED_SIGN")){
            operatorAuth.setSignUrl(jsonObject.getString("sign_url"));
            operatorAuth.setMerchantNumber(jsonObject.getString("sub_mchid"));
        }
        if (applymentState.equals("FINISH")){
            operatorAuth.setMerchantNumber(jsonObject.getString("sub_mchid"));
            operatorUser.setWechatAudit(2);
            operatorAuth.setAuditState(1);
        }
        if (applymentState.equals("ACCOUNT_NEED_VERIFY")){
            operatorAuth.setLegalValidationUrl(jsonObject.getString("legal_validation_url"));
        }
        return jsonObject;
        /**
         * {
         *   "applyment_state" : "FINISH",
         *   "applyment_state_desc" : "审核中",
         *   "sign_url" : "https://pay.weixin.qq.com/public/apply4ec_sign/s?applymentId=2000002126198476&sign=b207b673049a32c858f3aabd7d27c7ec",
         *   "sub_mchid" : "1542488631",
         *   "account_validation" : {
         *     "account_name" : "aOf7Gk2qT26kakkuTZpbFAn7Mb7xcar0LlQaYoi3+LnnWwgAsfaUUTg9+GmYJq6YCz+RiluWHeHFq1lt8n3eIkF0laVvqmAU80xIWGZgWJnRmnRuZxsg0HJZfnUac2JfqyuL8OoyM2YSuYDqdsyvcOlgUQgq8MPCR6pmvhBCmIeJvnVSm8J+L+yx912itUmTDxhdBlu1CFBIUefME9nYB70vCVTNAVXgURkf65mjHMBiE9Y+wrPZVmTIIz3C3PtPVMZYDEvBT4rDdICA3ZYXshYqeOSslSjSMf+MhhC4oaujiISFzq3AE+as7mAEDJly+DgRuVs74msmKUH8pl+3oA==",
         *     "account_no" : "aOf7Gk2qT26kakkuTZpbFAn7Mb7xcar0LlQaYoi3+LnnWwgAsfaUUTg9+GmYJq6YCz+RiluWHeHFq1lt8n3eIkF0laVvqmAU80xIWGZgWJnRmnRuZxsg0HJZfnUac2JfqyuL8OoyM2YSuYDqdsyvcOlgUQgq8MPCR6pmvhBCmIeJvnVSm8J+L+yx912itUmTDxhdBlu1CFBIUefME9nYB70vCVTNAVXgURkf65mjHMBiE9Y+wrPZVmTIIz3C3PtPVMZYDEvBT4rDdICA3ZYXshYqeOSslSjSMf+MhhC4oaujiISFzq3AE+as7mAEDJly+DgRuVs74msmKUH8pl+3oA==",
         *     "pay_amount" : 124,
         *     "destination_account_number" : "7222223333322332",
         *     "destination_account_name" : "财付通支付科技有限公司",
         *     "destination_account_bank" : "招商银行威盛大厦支行",
         *     "city" : "深圳",
         *     "remark" : "入驻账户验证",
         *     "deadline" : "2018-12-10 17:09:01"
         *   },
         *   "audit_detail" : [
         *     {
         *       "param_name" : "id_card_copy",
         *       "reject_reason" : "身份证背面识别失败,请上传更清晰的身份证图片。"
         *     }
         *   ],
         *   "legal_validation_url" : "https://pay.weixin.qq.com/public/apply4ec_sign/s?applymentId=2000002126198476&sign=b207b673049a32c858f3aabd7d27c7ec",
         *   "out_request_no" : "APPLYMENT_00000000001",
         *   "applyment_id" : 2000002124775691,
         *   "sign_state" : "SIGNED"
         * }
         */
    }
    /**
     * 分账比例提交
     */
    @RequestMapping(value = "/proportion")
    @ResponseBody
    public Object auth(Integer operatorIdOne ,String alipayProportion,String alipayNum,String wechatProportion,
                       String wechatNum) {
        Integer id1 = operatorService.getOne(new QueryWrapper<TOperator>().eq("id", operatorIdOne))
                .getUserId();
        OperatorUser id = operatorUserService.getOne(new QueryWrapper<OperatorUser>().eq("userId", id1));
    public Object auth(Integer operatorIdOne ,String alipayProportion,String wechatProportion) {
        OperatorUser id = operatorUserService.getOne(new QueryWrapper<OperatorUser>().eq("operatorId", operatorIdOne));
        id.setAlipayProportion(alipayProportion);
        id.setWechatProportion(wechatProportion);
        id.setAlipayNum(alipayNum);
        id.setWechatNum(wechatNum);
        operatorUserService.updateById(id);
        return SUCCESS_TIP;
    }
//    public static void main(String[] args) throws URISyntaxException {
//        String filePath = "https://we-park-life.oss-cn-beijing.aliyuncs.com/img/a5e24fc4b13b4ea48bb2455ad8662a5d.jpg"; // 替换成你的OSS图片链接
//        String string = UUID.randomUUID().toString();
//        try {
//            URL url = new URL(filePath);
//            InputStream inputStream = url.openStream();
//            // 这里可以根据需求处理 inputStream,比如保存到本地文件
//            // 例如保存到本地文件
//            saveInputStreamToFile(inputStream, "D:\\tempImg\\"+string+".jpg");
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//        URI uri = new URI("https://api.mch.weixin.qq.com/v3/merchant/media/upload");
//        File file = new File("D:\\tempImg\\"+string+".jpg");
//        try (FileInputStream ins1 = new FileInputStream(file)) {
//            String sha256 = DigestUtils.sha256Hex(ins1);
//            try (InputStream ins2 = new FileInputStream(file)) {
//                HttpPost request = new WechatPayUploadHttpPost.Builder(uri)
//                        .withImage(file.getName(), sha256, ins2)
//                        .build();
////                CloseableHttpResponse response1 = httpClient.execute(request);
//            }
//        } catch (IOException e) {
//            throw new RuntimeException(e);
//        }
//    }
    private static void saveInputStreamToFile(InputStream inputStream, String filePath) throws IOException {
        OutputStream outputStream = new FileOutputStream(filePath);
        byte[] buffer = new byte[1024];
        int bytesRead;
        while ((bytesRead = inputStream.read(buffer)) != -1) {
            outputStream.write(buffer, 0, bytesRead);
        }
        outputStream.close();
        inputStream.close();
    }
    /**
     * 微信商户认证上传图片
     */
    @RequestMapping(value = "/wxUpload")
    @ResponseBody
    public Object wxUpload(String img) throws URISyntaxException, FileNotFoundException {
        String filePath = "https://we-park-life.oss-cn-beijing.aliyuncs.com/img/a5e24fc4b13b4ea48bb2455ad8662a5d.jpg"; // 替换成你的OSS图片链接
        String string = UUID.randomUUID().toString();
        try {
            URL url = new URL(filePath);
            InputStream inputStream = url.openStream();
            // 这里可以根据需求处理 inputStream,比如保存到本地文件
            // 例如保存到本地文件
            saveInputStreamToFile(inputStream, "D:\\tempImg\\"+string+".jpg");
        } catch (IOException e) {
            e.printStackTrace();
        }
        URI uri = new URI("https://api.mch.weixin.qq.com/v3/merchant/media/upload");
        File file = new File("D:\\tempImg\\"+string+".jpg");
        try (FileInputStream ins1 = new FileInputStream(file)) {
            String sha256 = DigestUtils.sha256Hex(ins1);
            try (InputStream ins2 = new FileInputStream(file)) {
                HttpPost request = new WechatPayUploadHttpPost.Builder(uri)
                        .withImage(file.getName(), sha256, ins2)
                        .build();
//                CloseableHttpResponse response1 = httpClient.execute(request);
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return null;
    }
    // 辅助方法:将 InputStream 转换为 FileInputStream
    private static FileInputStream convertInputStreamToFileInputStream(InputStream inputStream) throws IOException {
        // 将 InputStream 转为临时文件,然后返回其 FileInputStream
        File tempFile = File.createTempFile("temp", null);
        org.apache.commons.io.IOUtils.copy(inputStream, new java.io.FileOutputStream(tempFile));
        return new FileInputStream(tempFile);
    }
    /**
     * 跳转运营商设置分账比例页面
     */
@@ -707,4 +1487,15 @@
        }
        return ResultUtil.success("添加成功");
    }
}
    /**
     * 获取所有运营商
     * @return
     */
    @ResponseBody
    @PostMapping("/getOperatorListAll")
    public Object getOperatorListAll(){
        return operatorService.list(new QueryWrapper<TOperator>().eq("state", 1));
    }
}