예제 #1
0
 @SecurityMapping(title = "直通车申请保存", value = "/seller/ztc_apply_save.htm*", rtype = "seller", rname = "竞价直通车", rcode = "ztc_seller", rgroup = "促销管理")
 @RequestMapping({ "/seller/ztc_apply_save.htm" })
 public ModelAndView ztc_apply_save(HttpServletRequest request, HttpServletResponse response, String goods_id,
         String ztc_price, String ztc_begin_time, String ztc_gold, String ztc_session) {
     ModelAndView mv = new JModelAndView("user/default/usercenter/success.html", this.configService.getSysConfig(),
             this.userConfigService.getUserConfig(), 0, request, response);
     if (!(this.configService.getSysConfig().isZtc_status())) {
         mv = new JModelAndView("error.html", this.configService.getSysConfig(),
                 this.userConfigService.getUserConfig(), 1, request, response);
         mv.addObject("op_title", "系统未开启直通车");
         mv.addObject("url", CommUtil.getURL(request) + "/seller/index.htm");
     } else {
         String ztc_session1 = CommUtil.null2String(request.getSession(false).getAttribute("ztc_session"));
         if ((!(ztc_session1.equals(""))) && (ztc_session1.equals(CommUtil.null2String(ztc_session)))) {
             request.getSession(false).removeAttribute("ztc_session");
             Goods goods = this.goodsService.getObjById(CommUtil.null2Long(goods_id));
             goods.setZtc_status(1);
             goods.setZtc_pay_status(1);
             goods.setZtc_begin_time(CommUtil.formatDate(ztc_begin_time));
             goods.setZtc_gold(CommUtil.null2Int(ztc_gold));
             goods.setZtc_price(CommUtil.null2Int(ztc_price));
             goods.setZtc_apply_time(new Date());
             this.goodsService.update(goods);
             mv.addObject("op_title", "直通车申请成功,等待审核");
             mv.addObject("url", CommUtil.getURL(request) + "/seller/ztc_list.htm");
         } else {
             mv = new JModelAndView("error.html", this.configService.getSysConfig(),
                     this.userConfigService.getUserConfig(), 1, request, response);
             mv.addObject("op_title", "不允许重复提交申请");
             mv.addObject("url", CommUtil.getURL(request) + "/seller/ztc_apply.htm");
         }
     }
     return mv;
 }
  @SecurityMapping(
      title = "楼层模板右下方广告保存",
      value = "/admin/goods_floor_right_adv_save.htm*",
      rtype = "admin",
      rname = "首页楼层",
      rcode = "goods_floor",
      rgroup = "商品")
  @RequestMapping("/admin/goods_floor_right_adv_save.htm")
  public String goods_floor_right_adv_save(
      HttpServletRequest request,
      HttpServletResponse response,
      String type,
      String id,
      String adv_url,
      String adv_id) {
    GoodsFloor obj = this.goodsfloorService.getObjById(CommUtil.null2Long(id));
    Map map = new HashMap();
    if (type.equals("user")) {
      // 模板广告图片
      String uploadFilePath = ConfigContants.UPLOAD_IMAGE_MIDDLE_NAME;
      String saveFilePathName =
          TytsmsStringUtils.generatorImagesFolderServerPath(request)
              + uploadFilePath
              + File.separator
              + "advert";
      Map json_map = new HashMap();
      try {
        map = CommUtil.saveFileToServer(configService, request, "img", saveFilePathName, "", null);
        if (map.get("fileName") != "") {
          Accessory acc = new Accessory();
          acc.setName(CommUtil.null2String(map.get("fileName")));
          acc.setExt(CommUtil.null2String(map.get("mime")));
          acc.setSize(BigDecimal.valueOf(CommUtil.null2Double(map.get("fileSize"))));
          acc.setPath(uploadFilePath + "/advert");
          acc.setWidth(CommUtil.null2Int(map.get("width")));
          acc.setHeight(CommUtil.null2Int(map.get("height")));
          acc.setAddTime(new Date());
          this.accessoryService.save(acc);
          json_map.put("acc_id", acc.getId());
        }

      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      json_map.put("acc_url", adv_url);
      json_map.put("adv_id", "");
      System.out.println(Json.toJson(json_map, JsonFormat.compact()));
      obj.setGf_right_adv(Json.toJson(json_map, JsonFormat.compact()));
    }
    if (type.equals("adv")) {
      Map json_map = new HashMap();
      json_map.put("acc_id", "");
      json_map.put("acc_url", "");
      json_map.put("adv_id", adv_id);
      System.out.println(Json.toJson(json_map, JsonFormat.compact()));
      obj.setGf_right_adv(Json.toJson(json_map, JsonFormat.compact()));
    }
    this.goodsfloorService.update(obj);
    return "redirect:goods_floor_template.htm?id=" + obj.getId();
  }
  /**
   * goodsfloor保存管理
   *
   * @param id
   * @return
   */
  @SecurityMapping(
      title = "楼层分类保存",
      value = "/admin/goods_floor_save.htm*",
      rtype = "admin",
      rname = "首页楼层",
      rcode = "goods_floor",
      rgroup = "商品")
  @RequestMapping("/admin/goods_floor_save.htm")
  public ModelAndView goods_floor_save(
      HttpServletRequest request,
      HttpServletResponse response,
      String id,
      String currentPage,
      String pid,
      String list_url,
      String add_url) {
    WebForm wf = new WebForm();
    GoodsFloor goodsfloor = null;
    if (id.equals("")) {
      goodsfloor = wf.toPo(request, GoodsFloor.class);
      goodsfloor.setAddTime(new Date());
    } else {
      GoodsFloor obj = this.goodsfloorService.getObjById(Long.parseLong(id));
      goodsfloor = (GoodsFloor) wf.toPo(request, obj);
    }
    GoodsFloor parent = this.goodsfloorService.getObjById(CommUtil.null2Long(pid));
    if (parent != null) {
      goodsfloor.setParent(parent);
      goodsfloor.setGf_level(parent.getGf_level() + 1);
    }

    String uploadFilePath = ConfigContants.UPLOAD_IMAGE_MIDDLE_NAME;
    String saveFilePathName =
        TytsmsStringUtils.generatorImagesFolderServerPath(request)
            + uploadFilePath
            + File.separator
            + "floor";
    Map map = new HashMap();
    try {
      String fileName = goodsfloor.getIcon() == null ? "" : goodsfloor.getIcon().getName();
      map =
          CommUtil.saveFileToServer(
              configService, request, "icon_logo", saveFilePathName, fileName, null);
      if (fileName.equals("")) {
        if (map.get("fileName") != "" && map.get("fileName") != null) {
          Accessory icon = new Accessory();
          icon.setName(CommUtil.null2String(map.get("fileName")));
          icon.setExt((String) map.get("mime"));
          icon.setSize(BigDecimal.valueOf((CommUtil.null2Double(map.get("fileSize")))));
          icon.setPath(uploadFilePath + "/floor");
          icon.setWidth((Integer) map.get("width"));
          icon.setHeight((Integer) map.get("height"));
          icon.setAddTime(new Date());
          this.accessoryService.save(icon);
          goodsfloor.setIcon(icon);
        }
      } else {
        if (map.get("fileName") != "" && map.get("fileName") != null) {
          Accessory icon = goodsfloor.getIcon();
          icon.setName(CommUtil.null2String(map.get("fileName")));
          icon.setExt(CommUtil.null2String(map.get("mime")));
          icon.setSize(BigDecimal.valueOf((CommUtil.null2Double(map.get("fileSize")))));
          icon.setPath(uploadFilePath + "/floor");
          icon.setWidth(CommUtil.null2Int(map.get("width")));
          icon.setHeight(CommUtil.null2Int(map.get("height")));
          this.accessoryService.update(icon);
        }
      }
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    if (id.equals("")) {
      this.goodsfloorService.save(goodsfloor);
    } else this.goodsfloorService.update(goodsfloor);
    ModelAndView mv =
        new JModelAndView(
            "admin/blue/success.html",
            configService.getSysConfig(),
            this.userConfigService.getUserConfig(),
            0,
            request,
            response);
    mv.addObject("list_url", list_url);
    mv.addObject("op_title", "保存首页楼层成功");
    if (add_url != null) {
      mv.addObject("add_url", add_url + "?currentPage=" + currentPage);
    }
    return mv;
  }