@Service("promoService") public class PromoServiceImpl implements PromoService { @Autowired private JdbcTemplate jdbc; /** * -- 优惠活动条件:1.启用状态 2.优惠活动id存在 3.价格>3000元 */ @Override public boolean queryActivityGoods(String sku_id, User user){ JSONArray jsonArray = new JSONArray(); StringBuffer sbSql = new StringBuffer(); String sku_name = ""; sbSql.append("select * from sc_promo_activities_goods g left join sc_promo_activities act "); sbSql.append("on g.form_id=act.id where g.sku_id='"+sku_id+"' and act.status='1'"); SqlRowSet rowSet = jdbc.queryForRowSet(sbSql.toString()); while(rowSet.next()){ JSONObject jsonObject = new JSONObject(); jsonObject.put("sku_name",rowSet.getString("sku_name") == null ? "" : rowSet.getString("sku_name")); sku_name = rowSet.getString("sku_name") == null ? "" : rowSet.getString("sku_name"); jsonArray.add(jsonObject); } System.out.println("jsonArray="+jsonArray.toJSONString()); if(sku_name==null || sku_name.length()<=0){//判断字符串是否为空 return false; }else{ return true; } } }