Ejemplo n.º 1
0
 @RequestMapping(value = "/save", method = RequestMethod.POST)
 public @ResponseBody ResponseVO save(
     @RequestParam HashMap<String, String> map, RedirectAttributes redirectAttributes)
     throws Exception {
   ResponseVO ovo = new ResponseVO();
   Row row = MapUtils.convertMaptoRowWithoutNullField(map);
   String goods_id = row.getString("goods_id", "");
   int rowNum = 0;
   if (!StringUtils.isEmptyOrNull(goods_id)) {
     Row attrRow = goodsAttributeService.findByGoodsId(goods_id);
     if (attrRow == null) {
       rowNum = goodsAttributeService.insert(row);
     } else {
       rowNum = goodsAttributeService.update(row);
     }
   } else {
     ovo = new ResponseVO(-1, "商品编号为空", "商品编号为空");
     return ovo;
   }
   if (rowNum > 0) {
     ovo = new ResponseVO(1, "success", "success");
     ovo.put("id", row.getString("id"));
   } else {
     ovo = new ResponseVO(-1, "fail", "fail");
   }
   return ovo;
 }
Ejemplo n.º 2
0
 @RequestMapping(value = "/edit")
 public String edit(String goods_id, ModelMap model) throws Exception {
   Row row = new Row();
   if (!StringUtils.isEmptyOrNull(goods_id)) {
     row = goodsAttributeService.findByGoodsId(goods_id);
   }
   model.addAttribute("row", row);
   model.addAttribute("goods_id", goods_id);
   return "/hslgpage/platform/goods/attribute/edit";
 }
Ejemplo n.º 3
0
 /**
  * 检查文件版本信息,如果需要更新,则返回文件的下载路径 json 格式文件 共3个文件: 省份 城市 城市区域
  *
  * @param request
  * @return
  * @throws Exception
  */
 @RequestMapping(value = "/checkVersion")
 public @ResponseBody String checkVersion(HttpServletRequest request) throws Exception {
   OVO ovo = null;
   parseRequest(request);
   String versionNo = ivo.getString("version");
   if (StringUtils.isEmptyOrNull(versionNo)) {
     versionNo = "0";
   }
   Setting setting = SettingUtils.get();
   String path = setting.getPhysicalPath() + "/resources/geography_files/";
   String version_file = path + "version.json";
   File file = new File(version_file);
   if (!file.exists()) {
     ovo = new OVO(0, "", "");
     ovo.set("update", "0"); // 不用更新
     return AesUtil.encode(VOConvert.ovoToJson(ovo));
   }
   String version_content = FileUtil.readText(version_file);
   JSONObject jsonObj = JSONObject.fromObject(version_content);
   String timestamp = jsonObj.getString("VERSION");
   if (StringUtils.isEmptyOrNull(timestamp) || versionNo.equals(timestamp)) {
     ovo = new OVO(0, "", "");
     ovo.set("update", "0"); // 不用更新
     return AesUtil.encode(VOConvert.ovoToJson(ovo));
   }
   String siteUrl = setting.getSiteUrl() + "/resources/geography_files/";
   //		String province_path =siteUrl+"province.json";
   //		String city_path =siteUrl+"city.json";
   //		String zone_path =siteUrl+"zone.json";
   //		String version_path =siteUrl+"version.json";
   String geography_path = siteUrl + "geography.json";
   //		String geography_content =FileUtil.readText(geography_path);
   //		ovo =VOConvert.jsonToOvo(geography_content);
   ovo = new OVO(0, "", "");
   ovo.set("update", "1"); // 需要更新
   //		ovo.set("province_path", province_path);
   //		ovo.set("city_path", city_path);
   //		ovo.set("zone_path", zone_path);
   //		ovo.set("version_path", version_path);
   ovo.set("geography_path", geography_path);
   return AesUtil.encode(VOConvert.ovoToJson(ovo));
 }
Ejemplo n.º 4
0
  /**
   * 分页查询
   *
   * @param request
   * @return
   * @throws Exception
   */
  @RequestMapping(value = "/list")
  public @ResponseBody String queryAttribute(HttpServletRequest request) throws Exception {
    parseRequest(request);
    logger.info("查询商品参数");
    String goods_id = ivo.getString("goods_id", "");
    if (StringUtils.isEmptyOrNull(goods_id)) {
      ovo = new OVO(-1, "商品编号不能为空", "商品编号不能为空");
      return AesUtil.encode(VOConvert.ovoToJson(ovo));
    }

    Row row = goodsService.findDetail(goods_id);
    if (row == null) {
      ovo = new OVO(-1, "商品不存在", "商品不存在");
      return AesUtil.encode(VOConvert.ovoToJson(ovo));
    }
    String id = "";
    String brand = "";
    String specification = "";
    String packaging = "";
    String origin = "";
    String expiry_date = "";
    String store = "";
    String goods_name = row.getString("name", "");
    Row attributeRow = goodsAttributeService.list(goods_id);
    if (attributeRow != null) {
      id = attributeRow.getString("id", "");
      brand = attributeRow.getString("brand", "");
      specification = attributeRow.getString("specification", "");
      packaging = attributeRow.getString("packaging", "");
      origin = attributeRow.getString("origin", "");
      expiry_date = attributeRow.getString("expiry_date", "");
      store = attributeRow.getString("store", "");
    }
    ovo = new OVO(0, "", "");
    ovo.set("id", id);
    ovo.set("goods_id", goods_id);
    ovo.set("brand", brand);
    ovo.set("specification", specification);
    ovo.set("packaging", packaging);
    ovo.set("origin", origin);
    ovo.set("expiry_date", expiry_date);
    ovo.set("store", store);
    ovo.set("goods_name", goods_name);
    return AesUtil.encode(VOConvert.ovoToJson(ovo));
  }
Ejemplo n.º 5
0
 @SuppressWarnings("unchecked")
 @RequestMapping(value = "/saveOrder")
 public @ResponseBody ResponseVO saveOrder(
     String data, RedirectAttributes redirectAttributes, ModelMap model) {
   ResponseVO ovo = new ResponseVO();
   HttpSession session = getSession();
   String errorMsg = "";
   Row staff = (Row) session.getAttribute("staff");
   if (staff == null) {
     ovo = new ResponseVO(-1, "请重新登录");
     return ovo;
   }
   if (StringUtils.isEmptyOrNull(data)) {
     ovo = new ResponseVO(-1, "请求参数为空");
     return ovo;
   }
   String array[] = data.split(";");
   boolean isValid = true;
   DataSet batchDs = new DataSet();
   for (int i = 0; i < array.length; i++) {
     String itemArray[] = array[i].split(",");
     String code = itemArray[0];
     String num = itemArray[1];
     // 检查code 是否存在 num 是否足够
     Row row = userCouponService.findNotUsedByPayCode(code);
     if (row == null) {
       errorMsg += "消费验证码[" + code + "]不存在;";
       isValid = false;
       break;
     }
     String coupon_num = row.getString("num", "");
     int icoupon_num = Integer.parseInt(coupon_num);
     int inum = Integer.parseInt(num);
     int minus = icoupon_num - inum;
     if (minus < 0) {
       errorMsg += "消费验证码[" + code + "]的库存不足,实际有[" + icoupon_num + "],消费数量是[" + inum + "]张;";
       isValid = false;
       break;
     }
     Row temp = new Row();
     temp.put("code", code);
     temp.put("num", num);
     batchDs.add(temp);
   }
   if (!isValid) {
     ovo = new ResponseVO(-1, "请求参数错误:" + errorMsg);
     return ovo;
   }
   String sql = "";
   for (int i = 0; i < batchDs.size(); i++) {
     Row row = (Row) batchDs.get(i);
     String code = row.getString("code");
     String num = row.getString("num");
     sql = "update cxhl_user_coupon set num=num-" + num + " where pay_code='" + code + "' ";
     userCouponService.update(sql);
   }
   sql = "update cxhl_user_coupon set state=2 where num=0";
   userCouponService.update(sql);
   ovo = new ResponseVO(0, "支付成功");
   return ovo;
 }