收藏
回答

这个接口怎么写呀?


这个接口java 怎么写呀 各位 我不会写 这个加密写的呀 各位 有示例代码嘛 官方

回答关注问题邀请回答
收藏

3 个回答

  • Memory (私信不回复)
    Memory (私信不回复)
    2021-01-12

    去github搜

    2021-01-12
    有用 1
    回复 2
  • 一九七七
    一九七七
    2021-01-13
    /**
     * @param id    商户ID
     * @param cid   营业员ID
     * @param store 更新商户详情
     * @return 商户详情
     */
    @Transactional
    @PostMapping(value = {"stores/{id}/setMerchant"})
    public Work<Store> setMerchant(@PathVariable String id, @RequestParam String cid, @RequestBody Store store) throws ServiceException, WxPayException {
        Merchant merchant = store.getMerchant();
        /* 超级管理员 */
        WxPayApplyment4SubCreateRequest.ContactInfo contactInfo = WxPayApplyment4SubCreateRequest.ContactInfo.builder()
                .contactEmail(merchant.getContactEmail())
                .contactIdNumber(merchant.getContactIdNumber())
                .contactName(merchant.getContactName())
                .mobilePhone(merchant.getMobilePhone())
                .build();
        /* 营业执照 */
        WxPayApplyment4SubCreateRequest.SubjectInfo.BusinessLicenseInfo businessLicenseInfo = WxPayApplyment4SubCreateRequest.SubjectInfo.BusinessLicenseInfo.builder()
                .legalPerson(merchant.getLegalPerson())
                .licenseCopy(merchant.getLicenseCopy().getMediaId())
                .licenseNumber(merchant.getLicenseNumber())
                .merchantName(merchant.getMerchantName())
                .build();
        /* 身份证信息 */
        WxPayApplyment4SubCreateRequest.SubjectInfo.IdentityInfo.IdCardInfo idCardInfo = WxPayApplyment4SubCreateRequest.SubjectInfo.IdentityInfo.IdCardInfo.builder()
                .idCardCopy(merchant.getIdCardCopy().getMediaId())
                .idCardNumber(merchant.getIdCardNumber())
                .idCardName(merchant.getIdCardName())
                .idCardNational(merchant.getIdCardNational().getMediaId())
                .cardPeriodBegin(merchant.getCardPeriodBegin())
                .cardPeriodEnd(merchant.getCardPeriodEnd())
                .build();
        /* 经营者/法人身份证件 */
        WxPayApplyment4SubCreateRequest.SubjectInfo.IdentityInfo identityInfo = WxPayApplyment4SubCreateRequest.SubjectInfo.IdentityInfo.builder()
                .idCardInfo(idCardInfo)
                .idDocType(IdTypeEnum.IDENTIFICATION_TYPE_IDCARD)
                .owner(true)
                .build();
        /* 1.主体资料 */
        WxPayApplyment4SubCreateRequest.SubjectInfo subjectInfo = WxPayApplyment4SubCreateRequest.SubjectInfo.builder()
                .businessLicenseInfo(businessLicenseInfo)
                .identityInfo(identityInfo)
                .subjectType(merchant.getSubjectType())
                .build();
        /* 小程序场景 */
        WxPayApplyment4SubCreateRequest.BusinessInfo.SalesInfo.MiniProgramInfo miniProgramInfo = WxPayApplyment4SubCreateRequest.BusinessInfo.SalesInfo.MiniProgramInfo.builder()
                .miniProgramAppid(merchant.getMiniProgramAppid())
                .miniProgramPics(merchant.getMiniProgramPics().stream().map(Picture::getMediaId).collect(Collectors.toList()))
                .build();
        /* 经营场景 */
        WxPayApplyment4SubCreateRequest.BusinessInfo.SalesInfo salesInfo = WxPayApplyment4SubCreateRequest.BusinessInfo.SalesInfo.builder()
                .salesScenesType(Collections.singletonList(SalesScenesTypeEnum.SALES_SCENES_MINI_PROGRAM))
                .miniProgramInfo(miniProgramInfo)
                .build();
        /* 2.经营资料 */
        WxPayApplyment4SubCreateRequest.BusinessInfo businessInfo = WxPayApplyment4SubCreateRequest.BusinessInfo.builder()
                .merchantShortname(merchant.getMerchantShortname())
                .servicePhone(merchant.getServicePhone())
                .salesInfo(salesInfo)
                .build();
        /* 结算规则 */
        WxPayApplyment4SubCreateRequest.SettlementInfo settlementInfo = WxPayApplyment4SubCreateRequest.SettlementInfo.builder()
                .settlementId(merchant.getSettlementId())
                .qualificationType(merchant.getQualificationType())
                .qualifications(merchant.getQualifications().stream().map(Picture::getMediaId).collect(Collectors.toList()))
                .build();
        String[] code = merchant.getBankAddress().getCode();
        /* 结算银行账户 */
        WxPayApplyment4SubCreateRequest.BankAccountInfo bankAccountInfo = WxPayApplyment4SubCreateRequest.BankAccountInfo.builder()
                .accountBank(merchant.getAccountBank())
                .accountName(merchant.getAccountName())
                .accountNumber(merchant.getAccountNumber())
                .bankAccountType(merchant.getBankAccountType())
                .bankAddressCode(Arrays.stream(merchant.getBankAddress().getCode()).skip(code.length - 1).findFirst().orElseThrow(() -> new ServiceException("fail", "银行地址编号错误")))
                .bankName(merchant.getBankName())
                .build();
        wechatConfiguration.initServices();
        WxPayService wxPayService = WechatConfiguration.wxPayServiceMap.get("wxe78290c2a5313de3");
        WxPayConfig wxPayConfig = wxPayService.getConfig();
        String businessCode = wxPayConfig.getMchId().concat("_").concat(id);
        WxPayApplyment4SubCreateRequest wxPayApplyment4SubCreateRequest = WxPayApplyment4SubCreateRequest.builder()
                .contactInfo(contactInfo)
                .subjectInfo(subjectInfo)
                .businessInfo(businessInfo)
                .settlementInfo(settlementInfo)
                .bankAccountInfo(bankAccountInfo)
                .businessCode(businessCode)
                .build();
        Applyment4SubService applyment4SubService = new Applyment4SubServiceImpl(wxPayService);
        WxPayApplymentCreateResult wxPayApplymentCreateResult = applyment4SubService.createApply(wxPayApplyment4SubCreateRequest);
        Update updateStore = Update.update("merchant", merchant)
                .set("businessCode", businessCode)
                .set("state", store.getState())
                .set("updateTime", LocalDateTime.now())
                .set("licenseNumber", merchant.getLicenseNumber())
                .set("licenseCopy", merchant.getLicenseCopy())
                .set("applymentId", wxPayApplymentCreateResult.getApplymentId());
    
        Query queryStore = Query.query(Criteria
                .where("id").is(id)
                .and("state").in(ApplymentStateEnum.APPLYMENT_STATE_REJECTED, ApplymentStateEnum.APPLYMENT_STATE_EDITTING, null));
        mongoTemplate.updateFirst(queryStore, updateStore, Store.class);
        return Work.success("编辑成功", store);
    }
    
    2021-01-13
    有用
    回复
  • MCD(阳光)彭飞
    MCD(阳光)彭飞
    2021-01-13

    这个我不清楚

    2021-01-13
    有用
    回复
登录 后发表内容
问题标签