yujian
2019-08-27 d8359ddb48dab5cc797a9d552e11fde571f4920c
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java
@@ -158,8 +158,9 @@
    * 获取淘宝的分享链接
    * 
    * @param acceptData
    * @param uid        -用户ID
    * @param            auctionId-商品ID
    * @param uid
    *            -用户ID
    * @param auctionId-商品ID
    * @param out
    */
   @RequestMapping(value = "createShareInfo")
@@ -303,7 +304,7 @@
         // 分享id
         try {
            ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId,
                  Constant.SOURCE_TYPE_TAOBAO);
                  Constant.SOURCE_TYPE_TAOBAO, false);
            shareInfo.setShareId(shareRecord.getRedisKey());
         } catch (Exception e) {
            try {
@@ -367,12 +368,21 @@
   public void createTaoLijin(Long uid, Long auctionId, int totalNum, String relationId, HttpServletRequest request,
         PrintWriter out) {
      try {
         TaoBaoLink taoBaoLink = shareGoodsService.getTaoLiJinLinkForShare(uid, auctionId, relationId);
         TaoBaoGoodsBrief goods = null;
         try {
            goods = TaoKeApiUtil.searchGoodsDetail(auctionId, new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY,
                  TaoBaoConstant.TAOBAO_AUTH_APPSECRET, TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT));
         } catch (TaobaoGoodsDownException e2) {
            e2.printStackTrace();
         }
         TaoBaoGoodsBrief goods = taoBaoLink.getGoods();
         if (goods == null) {
            out.print(JsonUtil.loadFalseResult("商品已下架"));
            return;
         }
         // 计算推广红包
         String warningRate = configTaoLiJinService.getValueByKey("warning_value");
         String warningRate = configTaoLiJinService.getValueByKey("warning_value", new Date());
         BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, goods);
         // 推广红包 不能小于1
@@ -406,53 +416,50 @@
         }
         shareInfo.setClickUrl(url);
         TaoBaoLink taoBaoLink = new TaoBaoLink();
         taoBaoLink.setCouponLink(taoLiJinLink);
         taoBaoLink.setClickUrl(taoLiJinLink);
         // 创建淘口令
         if (!StringUtil.isNullOrEmpty(taoLiJinLink)) {// 通过立即推广方式获取淘口令成功
            String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), taoLiJinLink);
            if (!StringUtil.isNullOrEmpty(quanToken)) {
               taoBaoLink.setTaoToken(quanToken);
            }
         } else if (!StringUtil.isNullOrEmpty(taoBaoLink.getClickUrl())) {
            String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(),
                  taoBaoLink.getClickUrl());
            if (!StringUtil.isNullOrEmpty(quanToken)) {
               taoBaoLink.setTaoToken(quanToken);
            }
         }
         shareInfo.setToken(taoBaoLink.getTaoToken());
         shareInfo.setRule(configService.get("share_single_goods_rule"));
         shareInfo.setPictUrl(TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
         shareInfo.setPictUrl(TbImgUtil.getTBSizeImg(goods.getPictUrl(), 500));
         // 无券
         String shopType = taoBaoLink.getGoods().getUserType() == 0 ? "淘宝价" : "天猫价";
         String shopType = goods.getUserType() == 0 ? "淘宝价" : "天猫价";
         String shareText = "";
         if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) {
         if (StringUtil.isNullOrEmpty(goods.getCouponInfo())) {
            String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
            if (StringUtil.isNullOrEmpty(text))
               text = configService.get("goods_share_text_nocoupon");
            shareText = text.replace("{标题}", taoBaoLink.getGoods().getTitle()).replace("{商品原价}",
                  MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "");
            shareText = text.replace("{标题}", goods.getTitle()).replace("{商品原价}",
                  MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice()) + "");
         } else// 有券
         {
            String text = shareGoodsTextTemplateService.getTaoLiJinTemplate(uid);
            if (StringUtil.isNullOrEmpty(text))
               text = configTaoLiJinService.getValueByKey("goods_share_text");
               text = configTaoLiJinService.getValueByKey("goods_share_text", new Date());
            shareText = text.replace("{标题}", taoBaoLink.getGoods().getTitle())
                  .replace("{商品原价}", MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "")
                  .replace("{优惠券面额}",
                        MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getCouponAmount()).toString())
            shareText = text.replace("{标题}", goods.getTitle())
                  .replace("{商品原价}", MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice()) + "")
                  .replace("{优惠券面额}", MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount()).toString())
                  .replace("{淘礼金面额}", MoneyBigDecimalUtil.getWithNoZera(spreadMoney).toString())
                  .replace("{优惠券价}", TaoBaoUtil.getAfterUseCouplePrice(taoBaoLink.getGoods()) + "");
                  .replace("{优惠券价}", TaoBaoUtil.getAfterUseCouplePrice(goods) + "");
         }
         shareText = shareText.replace("{店铺类型}", shopType)
               .replace("{月销量}", TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day()))
               .replace("{领券短链}", shortLink).replace("{淘口令}", taoBaoLink.getTaoToken());
               .replace("{月销量}", TaoBaoUtil.getSaleCount(goods.getBiz30day())).replace("{领券短链}", shortLink)
               .replace("{淘口令}", taoBaoLink.getTaoToken());
         shareInfo.setShareText(shareText);
         String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim();
         String descText = shareText.replace(goods.getTitle(), "").trim();
         if (descText.startsWith("\\r\\n"))
            descText = descText.substring(0);
@@ -468,11 +475,11 @@
         // 添加分享记录
         BigDecimal rate = hongBaoManageService.getShareRate();
         BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate);
         BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(goods, rate);
         shareInfo.setShareMoney("¥" + shareMoney.toString());
         try {
            ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, auctionId,
                  Constant.SOURCE_TYPE_TAOBAO);
                  Constant.SOURCE_TYPE_TAOBAO, true);
            shareInfo.setShareId(shareRecord.getRedisKey());
         } catch (Exception e) {
            try {
@@ -484,6 +491,7 @@
         out.print(JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(shareInfo)));
         final TaoBaoLink taobaoLink = taoBaoLink;
         final TaoBaoGoodsBrief finalGoods=goods;
         // 异步操作
         com.yeshi.fanli.util.ThreadUtil.run(new Runnable() {
            @Override
@@ -497,10 +505,10 @@
               history.setTkCode(taobaoLink.getTaoToken());
               history.setLink(taobaoLink.getClickUrl());
               history.setQuanLink(taobaoLink.getCouponLink());
               history.setGoodsId(taobaoLink.getGoods().getAuctionId());
               history.setPostPicture(taobaoLink.getGoods().getPictUrl());
               history.setGoodsId(finalGoods.getAuctionId());
               history.setPostPicture(finalGoods.getPictUrl());
               List<String> imgList = taobaoLink.getGoods().getImgList();
               List<String> imgList = finalGoods.getImgList();
               if (imgList == null) {
                  imgList = new ArrayList<>();
               }
@@ -509,14 +517,9 @@
            }
         });
         return;
      } catch (ShareGoodsException e) {
      } catch (Exception e) {
         LogHelper.errorDetailInfo(e, "分享出错:uid:" + uid + "auctionId:" + auctionId, "");
         // 分享出错报警
         try {
            monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, e.getCode(), 0, "分享出错"));
         } catch (Exception e1) {
         }
         out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
         out.print(JsonUtil.loadFalseResult("创建分享出错"));
         businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(auctionId + ""));
      }
   }
@@ -533,60 +536,52 @@
    * @param out
    */
   public void createJDShare(AcceptData acceptData, Long uid, Long goodsId, String source, PrintWriter out) {
      JDGoods jdGoods = JDApiUtil.queryGoodsDetail(goodsId);
      if (jdGoods == null) {
         jdGoods = JDApiUtil.getGoodsDetail(goodsId);
      }
      JDGoods jdGoods = jdGoodsCacheUtil.getGoodsInfo(goodsId);
      if (jdGoods == null) {
         out.print(JsonUtil.loadFalseResult(1, "该商品淘已下架"));
         return;
      }
      // TODO
      ShareInfoVO shareInfo = new ShareInfoVO();
      String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq&goodsType=%s", configService.getH5Host(),
            Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
            goodsId + "", Constant.SOURCE_TYPE_JD);
      // String url = String.format("http://%s%s?uid=%s&id=%s",
      // configService.getH5Host(),
      // Constant.systemCommonConfig.getShareGoodsPagePathJD(),
      // AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
      // goodsId + "");
      // 券短连接
      String shortLink = HttpUtil.getShortLink(url);
      if (!StringUtil.isNullOrEmpty(shortLink)) {
         url = shortLink;
      String couponUrl = null;
      JDCouponInfo couponInfo = jdGoods.getCouponInfo();
      if (couponInfo != null) {
         couponUrl = couponInfo.getLink();
      }
      String materialId = "https://item.jd.com/" + goodsId + ".html";
      String jumpLink = JDApiUtil.convertShortLink(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", uid + "");
      shareInfo.setClickUrl(url);
      ShareInfoVO shareInfo = new ShareInfoVO();
      shareInfo.setClickUrl(jumpLink);
      shareInfo.setRule(configService.get("share_rule_link_jd"));
      shareInfo.setPictUrl(jdGoods.getPicUrl());
      String shareText = "";
      String shopType = "京东价";
      boolean hasCoupon = false;
      // 分享模板
      JDCouponInfo couponInfo = jdGoods.getCouponInfo();
      if (couponInfo == null) {
         String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
         if (StringUtil.isNullOrEmpty(text)) {
            text = configService.get("goods_share_text_nocoupon");
         }
         shareText = text.replace("{标题}", jdGoods.getSkuName()).replace("{商品原价}",
               MoneyBigDecimalUtil.getWithNoZera(jdGoods.getPrice()) + "");
      } else// 有券
      {
         String text = shareGoodsTextTemplateService.geteCouponTemplate(uid);
         if (StringUtil.isNullOrEmpty(text))
            text = configService.get("goods_share_text_coupon");
      ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid);
      if (couponInfo == null) { // 无券模板
         if (textTemplate != null)
            shareText = textTemplate.getShareJDTextTemplate();
         shareText = text.replace("{标题}", jdGoods.getSkuName())
               .replace("{商品原价}", MoneyBigDecimalUtil.getWithNoZera(jdGoods.getPrice()) + "")
               .replace("{优惠券面额}", MoneyBigDecimalUtil.getWithNoZera(couponInfo.getDiscount()) + "")
               .replace("{优惠券价}", JDUtil.getQuanPrice(jdGoods) + "");
         if (StringUtil.isNullOrEmpty(shareText))
            shareText = configService.get("goods_share_text_nocoupon_jd");
      } else { // 有券模板
         hasCoupon = true;
         if (textTemplate != null)
            shareText = textTemplate.getShareJDTextTemplateCoupon();
         if (StringUtil.isNullOrEmpty(shareText))
            shareText = configService.get("goods_share_text_coupon_jd");
      }
      shareText = shareText.replace("{店铺类型}", shopType)
            .replace("{月销量}", JDUtil.getSaleCount(jdGoods.getInOrderCount30Days())).replace("{领券短链}", shortLink)
            .replace("{淘口令}", null);
      shareText = shareGoodsTextTemplateService.createContentByTemplateJD(shareText, uid, jdGoods, jumpLink,
            hasCoupon);
      shareInfo.setShareText(shareText);
      String descText = shareText.replace(jdGoods.getSkuName(), "").trim();
@@ -595,7 +590,6 @@
      }
      shareInfo.setDescText(descText);
      //
      String imgs = configService.get("goods_share_notify_imgs");
      JSONArray array = JSONArray.fromObject(imgs);
      int p = (int) (array.size() * Math.random());
@@ -610,7 +604,7 @@
      shareInfo.setShareMoney("¥" + shareMoney.toString());
      try {
         ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId,
               Constant.SOURCE_TYPE_JD);
               Constant.SOURCE_TYPE_JD, false);
         shareInfo.setShareId(shareRecord.getRedisKey());
      } catch (Exception e) {
         try {
@@ -658,55 +652,49 @@
    * @param out
    */
   public void createPDDShare(AcceptData acceptData, Long uid, Long goodsId, String source, PrintWriter out) {
      PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(goodsId);
      PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId);
      if (goods == null) {
         out.print(JsonUtil.loadFalseResult(1, "该商品已下架"));
         return;
      }
      // String url = String.format("http://%s%s?uid=%s&id=%s",
      // configService.getH5Host(),
      // Constant.systemCommonConfig.getShareGoodsPagePathPDD(),
      // AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
      // goodsId + "");
      String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goodsId, PinDuoDuoApiUtil.PID_SHARE + "", uid + "");
      ShareInfoVO shareInfo = new ShareInfoVO();
      // TODO
      String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq&goodsType=%s", configService.getH5Host(),
            Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
            goodsId + "", Constant.SOURCE_TYPE_PDD);
      String shortLink = HttpUtil.getShortLink(url);
      if (!StringUtil.isNullOrEmpty(shortLink)) {
         url = shortLink;
      }
      shareInfo.setClickUrl(url);
      shareInfo.setClickUrl(jumpLink);
      shareInfo.setRule(configService.get("share_rule_link_pdd"));
      shareInfo.setPictUrl(goods.getGoodsImageUrl());
      String shareText = "";
      String shopType = "拼多多价";
      // 无券
      String template = "";
      boolean hasCoupon = false;
      ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid);
      if (goods.getHasCoupon() == null || !goods.getHasCoupon()) {
         String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
         if (StringUtil.isNullOrEmpty(text))
            text = configService.get("goods_share_text_nocoupon");
         shareText = text.replace("{标题}", goods.getGoodsName()).replace("{商品原价}",
               MoneyBigDecimalUtil.getWithNoZera(new BigDecimal(goods.getMinNormalPrice())) + "");
      } else// 有券
      {
         String text = shareGoodsTextTemplateService.geteCouponTemplate(uid);
         if (StringUtil.isNullOrEmpty(text))
            text = configService.get("goods_share_text_coupon");
         if (textTemplate != null)
            template = textTemplate.getSharePDDTextTemplate();
         shareText = text.replace("{标题}", goods.getGoodsName())
               .replace("{商品原价}",
                     MoneyBigDecimalUtil.getWithNoZera(new BigDecimal(goods.getMinNormalPrice())) + "")
               .replace("{优惠券面额}",
                     MoneyBigDecimalUtil.getWithNoZera(new BigDecimal(goods.getCouponDiscount())) + "")
               .replace("{优惠券价}", PinDuoDuoUtil.getQuanPrice(goods) + "");
         if (StringUtil.isNullOrEmpty(template))
            template = configService.get("goods_share_text_nocoupon_pdd");
      } else {
         hasCoupon = true;
         if (textTemplate != null)
            template = textTemplate.getSharePDDTextTemplateCoupon();
         if (StringUtil.isNullOrEmpty(template))
            template = configService.get("goods_share_text_coupon_pdd");
      }
      shareText = shareText.replace("{店铺类型}", shopType)
            .replace("{月销量}", PinDuoDuoUtil.getSaleCount(goods.getSoldQuantity())).replace("{领券短链}", shortLink)
            .replace("{淘口令}", null);
      // 创建口令
      String token = PinDuoDuoApiUtil.createGenerate(goodsId);
      // 生成分享内容
      String shareText = shareGoodsTextTemplateService.createContentByTemplatePDD(template, uid, goods, jumpLink,
            hasCoupon, token);
      shareInfo.setShareText(shareText);
      String descText = shareText.replace(goods.getGoodsName(), "").trim();
@@ -731,7 +719,7 @@
      try {
         ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId,
               Constant.SOURCE_TYPE_JD);
               Constant.SOURCE_TYPE_PDD, false);
         shareInfo.setShareId(shareRecord.getRedisKey());
      } catch (Exception e) {
         try {
@@ -751,7 +739,7 @@
            history.setUser(new UserInfo(uid));
            history.setHongbao(shareMoney);
            history.setCreateTime(new Date());
            history.setGoodsType(Constant.SOURCE_TYPE_JD);
            history.setGoodsType(Constant.SOURCE_TYPE_PDD);
            history.setTkCode(null);
            history.setLink(null);
            history.setQuanLink(null);
@@ -805,12 +793,12 @@
         return;
      }
      if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
      if (goodsType == Constant.SOURCE_TYPE_JD) {
         createJDViewText(goodsType, uid, template, goodsId, hasCoupon, out);
         return;
      }
      if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
      if (goodsType == Constant.SOURCE_TYPE_PDD) {
         createPDDViewText(goodsType, uid, template, goodsId, hasCoupon, out);
         return;
      }
@@ -959,10 +947,13 @@
         }
      }
      String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
            Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
            goodsId + "");
      String shortLink = HttpUtil.getShortLink(url);
      String couponUrl = null;
      JDCouponInfo couponInfo = goods.getCouponInfo();
      if (couponInfo != null) {
         couponUrl = couponInfo.getLink();
      }
      String materialId = "https://item.jd.com/" + goodsId + ".html";
      String shortLink = JDApiUtil.convertShortLink(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", uid + "");
      String content = shareGoodsTextTemplateService.createContentByTemplateJD(template, uid, goods, shortLink,
            hasCoupon);
@@ -972,7 +963,7 @@
   }
   /**
    * 创建京东分享模板
    * 创建拼多多分享模板
    * 
    * @param uid
    * @param template
@@ -1014,11 +1005,15 @@
         }
      }
      // 创建h5连接
      String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
            Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
            goodsId + "");
      String shortLink = HttpUtil.getShortLink(url);
      // // 创建h5连接
      // String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq",
      // configService.getH5Host(),
      // Constant.systemCommonConfig.getShareGoodsPagePath(),
      // AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
      // goodsId + "");
      // String shortLink = HttpUtil.getShortLink(url);
      String shortLink = PinDuoDuoApiUtil.getPromotionUrl(goodsId, PinDuoDuoApiUtil.PID_SHARE + "", uid + "");
      // 创建口令
      String token = PinDuoDuoApiUtil.createGenerate(goodsId);
@@ -1047,7 +1042,7 @@
            if (tljId != null) {
               template = shareGoodsTextTemplateService.getTaoLiJinTemplate(uid);
               if (StringUtil.isNullOrEmpty(template))
                  template = configTaoLiJinService.getValueByKey("goods_share_text");
                  template = configTaoLiJinService.getValueByKey("goods_share_text", new Date());
            } else {
               template = shareGoodsTextTemplateService.geteCouponTemplate(uid);
               if (StringUtil.isNullOrEmpty(template))
@@ -1140,7 +1135,8 @@
      if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
         if (tljId != null) {
            out.print(JsonUtil.loadTrueResult(configTaoLiJinService.getValueByKey("share_goods_rules")));
            out.print(
                  JsonUtil.loadTrueResult(configTaoLiJinService.getValueByKey("share_goods_rules", new Date())));
         } else {
            out.print(JsonUtil.loadTrueResult(configService.get("share_goods_template_rules")));
         }
@@ -1221,7 +1217,8 @@
    * 
    * @param acceptData
    * @param uid
    * @param hasCoupon  -是否有券
    * @param hasCoupon
    *            -是否有券
    * @param out
    */
   @RequestMapping(value = "resetShareTextTemplate", method = RequestMethod.POST)
@@ -1237,7 +1234,7 @@
         return;
      }
       if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
      if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
         if (hasCoupon) {
            if (tljId != null) {
               shareGoodsTextTemplateService.resetTaoLijinTemplate(uid);
@@ -1247,21 +1244,20 @@
         } else {
            shareGoodsTextTemplateService.resetCommonTemplate(uid);
         }
       } else  if (goodsType == Constant.SOURCE_TYPE_JD) {
          if (hasCoupon) {
      } else if (goodsType == Constant.SOURCE_TYPE_JD) {
         if (hasCoupon) {
            shareGoodsTextTemplateService.resetCouponTemplateJD(uid);
         } else {
            shareGoodsTextTemplateService.resetCommonTemplateJD(uid);
         }
       } else  if (goodsType == Constant.SOURCE_TYPE_PDD) {
          if (hasCoupon) {
      } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
         if (hasCoupon) {
            shareGoodsTextTemplateService.resetCouponTemplatePDD(uid);
         } else {
            shareGoodsTextTemplateService.resetCommonTemplatePDD(uid);
         }
       }
      }
      if (goodsId != null) {
         viewShareTextTemplate(acceptData, uid, null, goodsType, goodsId, tljId, hasCoupon, out);
         return;