/**
   * 删除支付产品
   *
   * @param userNo
   */
  @Override
  public void deleteUserPayConfig(String userNo) throws PayBizException {

    RpUserPayConfig rpUserPayConfig = rpUserPayConfigDao.getByUserNo(userNo, null);
    if (rpUserPayConfig == null) {
      throw new PayBizException(PayBizException.USER_PAY_CONFIG_IS_NOT_EXIST, "用户支付配置不存在");
    }

    rpUserPayConfig.setStatus(PublicStatusEnum.UNACTIVE.name());
    rpUserPayConfig.setEditTime(new Date());
    updateData(rpUserPayConfig);
  }
  /** 创建用户支付配置 */
  @Override
  public void createUserPayConfig(
      String userNo,
      String userName,
      String productCode,
      String productName,
      Integer riskDay,
      String fundIntoType,
      String isAutoSett,
      String appId,
      String merchantId,
      String partnerKey,
      String ali_partner,
      String ali_sellerId,
      String ali_key,
      String ali_appid,
      String ali_rsaPrivateKey,
      String ali_rsaPublicKey)
      throws PayBizException {

    RpUserPayConfig payConfig = rpUserPayConfigDao.getByUserNo(userNo, null);
    if (payConfig != null) {
      throw new PayBizException(PayBizException.USER_PAY_CONFIG_IS_EXIST, "用户支付配置已存在");
    }

    RpUserPayConfig rpUserPayConfig = new RpUserPayConfig();
    rpUserPayConfig.setUserNo(userNo);
    rpUserPayConfig.setUserName(userName);
    rpUserPayConfig.setProductCode(productCode);
    rpUserPayConfig.setProductName(productName);
    rpUserPayConfig.setStatus(PublicStatusEnum.ACTIVE.name());
    rpUserPayConfig.setAuditStatus(PublicEnum.YES.name());
    rpUserPayConfig.setRiskDay(riskDay);
    rpUserPayConfig.setFundIntoType(fundIntoType);
    rpUserPayConfig.setIsAutoSett(isAutoSett);
    rpUserPayConfig.setPayKey(StringUtil.get32UUID());
    rpUserPayConfig.setPaySecret(StringUtil.get32UUID());
    rpUserPayConfig.setId(StringUtil.get32UUID());
    saveData(rpUserPayConfig);

    // 查询支付产品下有哪些支付方式
    List<RpPayWay> payWayList = rpPayWayService.listByProductCode(productCode);
    Map<String, String> map = new HashMap<String, String>();
    // 过滤重复数据
    for (RpPayWay payWay : payWayList) {
      map.put(payWay.getPayWayCode(), payWay.getPayWayName());
    }

    for (String key : map.keySet()) {
      if (key.equals(PayWayEnum.WEIXIN.name())) {
        // 创建用户第三方支付信息
        RpUserPayInfo rpUserPayInfo =
            rpUserPayInfoService.getByUserNo(userNo, PayWayEnum.WEIXIN.name());
        if (rpUserPayInfo == null) {
          rpUserPayInfo = new RpUserPayInfo();
          rpUserPayInfo.setId(StringUtil.get32UUID());
          rpUserPayInfo.setCreateTime(new Date());
          rpUserPayInfo.setAppId(appId);
          rpUserPayInfo.setMerchantId(merchantId);
          rpUserPayInfo.setPartnerKey(partnerKey);
          rpUserPayInfo.setPayWayCode(PayWayEnum.WEIXIN.name());
          rpUserPayInfo.setPayWayName(PayWayEnum.WEIXIN.getDesc());
          rpUserPayInfo.setUserNo(userNo);
          rpUserPayInfo.setUserName(userName);
          rpUserPayInfo.setStatus(PublicStatusEnum.ACTIVE.name());
          rpUserPayInfoService.saveData(rpUserPayInfo);
        } else {
          rpUserPayInfo.setEditTime(new Date());
          rpUserPayInfo.setAppId(appId);
          rpUserPayInfo.setMerchantId(merchantId);
          rpUserPayInfo.setPartnerKey(partnerKey);
          rpUserPayInfo.setPayWayCode(PayWayEnum.WEIXIN.name());
          rpUserPayInfo.setPayWayName(PayWayEnum.WEIXIN.getDesc());
          rpUserPayInfoService.updateData(rpUserPayInfo);
        }

      } else if (key.equals(PayWayEnum.ALIPAY.name())) {
        // 创建用户第三方支付信息
        RpUserPayInfo rpUserPayInfo =
            rpUserPayInfoService.getByUserNo(userNo, PayWayEnum.ALIPAY.name());
        if (rpUserPayInfo == null) {
          rpUserPayInfo = new RpUserPayInfo();
          rpUserPayInfo.setId(StringUtil.get32UUID());
          rpUserPayInfo.setCreateTime(new Date());
          rpUserPayInfo.setAppId(ali_partner);
          rpUserPayInfo.setMerchantId(ali_sellerId);
          rpUserPayInfo.setPartnerKey(ali_key);
          rpUserPayInfo.setPayWayCode(PayWayEnum.ALIPAY.name());
          rpUserPayInfo.setPayWayName(PayWayEnum.ALIPAY.getDesc());
          rpUserPayInfo.setUserNo(userNo);
          rpUserPayInfo.setUserName(userName);
          rpUserPayInfo.setStatus(PublicStatusEnum.ACTIVE.name());
          rpUserPayInfo.setOfflineAppId(ali_appid);
          rpUserPayInfo.setRsaPrivateKey(ali_rsaPrivateKey);
          rpUserPayInfo.setRsaPublicKey(ali_rsaPublicKey);
          rpUserPayInfoService.saveData(rpUserPayInfo);
        } else {
          rpUserPayInfo.setEditTime(new Date());
          rpUserPayInfo.setAppId(ali_partner);
          rpUserPayInfo.setMerchantId(ali_sellerId);
          rpUserPayInfo.setPartnerKey(ali_key);
          rpUserPayInfo.setPayWayCode(PayWayEnum.ALIPAY.name());
          rpUserPayInfo.setPayWayName(PayWayEnum.ALIPAY.getDesc());
          rpUserPayInfo.setOfflineAppId(ali_appid);
          rpUserPayInfo.setRsaPrivateKey(ali_rsaPrivateKey);
          rpUserPayInfo.setRsaPublicKey(ali_rsaPublicKey);
          rpUserPayInfoService.updateData(rpUserPayInfo);
        }
      }
    }
  }