@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;
 }
示例#2
0
 /**
  * 查询全部城市以及城市区域列表
  *
  * @param request
  * @return
  * @throws Exception
  */
 @RequestMapping(value = "/CityAndZone")
 public @ResponseBody String queryCityAndZone(HttpServletRequest request) throws Exception {
   parseRequest(request);
   logger.info("查询城市以及区域");
   Row row = zoneService.queryAllCityAndZone();
   DataSet cityDataSet = (DataSet) row.get("city");
   DataSet zoneDataSet = (DataSet) row.get("zone");
   OVO ovo = new OVO(0, "", "");
   ovo.set("city_list", cityDataSet);
   ovo.set("zone_list", zoneDataSet);
   return AesUtil.encode(VOConvert.ovoToJson(ovo));
 }
示例#3
0
 /**
  * 分页查询
  *
  * @param pageable
  * @param model
  * @return
  */
 @RequestMapping(value = "/list")
 public String list(Pageable pageable, RedirectAttributes redirectAttributes, ModelMap model) {
   HttpSession session = getSession();
   Row staff = (Row) session.getAttribute("staff");
   if (staff == null) {
     addFlashMessage(redirectAttributes, Message.error("请先登录"));
     return "redirect:/login/ShopLogin.do";
   }
   String shop_id = staff.getString("shop_id", "");
   userCouponService.getRow().put("pageable", pageable);
   Page page = userCouponService.queryPageForShopAdmin(pageable, shop_id);
   model.addAttribute("page", page);
   return "/cxhlpage/shop/coupon/list";
 }
  /**
   * 分页查询
   *
   * @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));
  }
示例#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;
 }
示例#6
0
  @SuppressWarnings("unchecked")
  public DataSet getDeptPostionStaffTree() throws JException, SQLException {
    DataSet tempDs = new DataSet();
    DataSet treeDataSet = new DataSet();
    String sql = "select bureau_no, bureau_name from sm_bureau";

    tempDs = queryDataSet(sql);
    Row localRow2;
    for (int i = 0; i < tempDs.size(); i++) {
      Row tempRow = (Row) tempDs.get(i);
      localRow2 = new Row();
      localRow2.put("ID", "B" + tempRow.getString("bureau_no"));
      localRow2.put("NAME", tempRow.getString("bureau_name"));
      localRow2.put("UP_ID", "-1");
      localRow2.put("TYPE", "0");
      treeDataSet.add(localRow2);
    }

    //		 sql= "select posi_no, posi_name, site_no from sm_position where state=1";
    sql = "select posi_no, posi_name, site_no from sm_position ";
    tempDs = queryDataSet(sql);
    for (int i = 0; i < tempDs.size(); i++) {
      Row tempRow = (Row) tempDs.get(i);
      localRow2 = new Row();
      localRow2.put("ID", "P" + tempRow.getString("posi_no"));
      localRow2.put("NAME", tempRow.getString("posi_name"));
      localRow2.put("UP_ID", tempRow.getString("site_no"));
      localRow2.put("TYPE", "1");
      treeDataSet.add(localRow2);
    }

    sql = "select site_no, site_name, bureau_no from sm_site where up_site_no is null ";
    tempDs = queryDataSet(sql);
    for (int i = 0; i < tempDs.size(); i++) {
      Row tempRow = (Row) tempDs.get(i);
      localRow2 = new Row();
      localRow2.put("ID", tempRow.getString("site_no"));
      localRow2.put("NAME", tempRow.getString("site_name"));
      localRow2.put("UP_ID", "B" + tempRow.getString("bureau_no"));
      localRow2.put("TYPE", "0");
      treeDataSet.add(localRow2);
    }

    sql = "select site_no, site_name, up_site_no from sm_site where up_site_no is not null ";
    tempDs = queryDataSet(sql);
    for (int i = 0; i < tempDs.size(); i++) {
      Row tempRow = (Row) tempDs.get(i);
      localRow2 = new Row();
      localRow2.put("ID", tempRow.getString("site_no"));
      localRow2.put("NAME", tempRow.getString("site_name"));
      localRow2.put("UP_ID", tempRow.getString("up_site_no"));
      localRow2.put("TYPE", "0");
      treeDataSet.add(localRow2);
    }

    //   sql = "select a.real_name, a.staff_no,b.posi_no,a.site_no from sm_staff a left join
    // sm_staff_position b on a.staff_no=b.staff_no where a.state=1";
    sql =
        "select a.real_name, a.staff_no,b.posi_no,a.site_no from sm_staff a left join sm_staff_position b on a.staff_no=b.staff_no ";
    tempDs = queryDataSet(sql);
    for (int i = 0; i < tempDs.size(); i++) {
      Row tempRow = (Row) tempDs.get(i);
      localRow2 = new Row();
      localRow2.put("ID", "S" + tempRow.getString("staff_no"));
      localRow2.put("NAME", tempRow.getString("real_name"));
      if ((tempRow.getString("posi_no", null) == null)
          || (tempRow.getString("posi_no").trim().length() == 0))
        localRow2.put("UP_ID", tempRow.getString("site_no"));
      else {
        localRow2.put("UP_ID", "P" + tempRow.getString("posi_no"));
      }
      localRow2.put("TYPE", "4");
      treeDataSet.add(localRow2);
    }
    return treeDataSet;
  }