Browse Source

修复查询条件bug

master
xyiege 4 years ago
parent
commit
925d393969
  1. 12
      src/main/java/cn/chjyj/szwh/controller/admin/AdminOrderController.java
  2. 12
      src/main/resources/mapper/szwh/OrderMapper.xml
  3. 6
      src/test/java/cn/chjyj/szwh/mapper/GoodsMapperTest.java

12
src/main/java/cn/chjyj/szwh/controller/admin/AdminOrderController.java

@ -5,6 +5,7 @@ import cn.chjyj.szwh.controller.BaseController;
import cn.chjyj.szwh.service.OrderGoodsDetailService;
import cn.chjyj.szwh.service.OrderService;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -73,6 +74,17 @@ public class AdminOrderController extends BaseController {
if(StringUtils.isNotBlank(entrustType)){
rqmap.put("goods_entrust",entrustType);
}
// 创建时间
String createtime=request.getString("createtime");
if(StringUtils.isNotBlank("createtime")){
JSONArray jarr = JSONArray.parseArray(createtime);
if(jarr.size()>0){
// 拆分
rqmap.put("createtime"," createtime between '"+jarr.get(0)+" 00:00:00' and '"+jarr.get(1)+" 23:59:59'");
}
}
//
String spage=request.getString("page");
int page= StringUtils.isNotBlank(spage)?Integer.valueOf(spage):1;

12
src/main/resources/mapper/szwh/OrderMapper.xml

@ -62,7 +62,8 @@
<!-- 查询条件封装在map中,以k-v形式进行查询-->
<foreach collection="map" item="v" index="k" separator="and">
<if test="v != null and v != '' and k!='id' and k!='charges_type'
and k!='buyin' and k!='bcin' and k!='name' and k!='goods_name' and k!='goods_entrust'">
and k!='buyin' and k!='bcin' and k!='name' and k!='createtime'
and k!='goods_name' and k!='goods_entrust'">
${k} = #{v}
</if>
<if test="k=='id'">
@ -83,6 +84,9 @@
#{btcode}
</foreach>
</if>
<if test="k=='createtime'">
${v}
</if>
</foreach>
</if>
</where>
@ -112,7 +116,8 @@
<!-- 查询条件封装在map中,以k-v形式进行查询-->
<foreach collection="map" item="v" index="k" separator="and">
<if test="v != null and v != '' and k!='id' and k!='charges_type'
and k!='buyin' and k!='bcin' and k!='name' and k!='goods_name' and k!='goods_entrust'">
and k!='buyin' and k!='bcin' and k!='name' and k!='createtime'
and k!='goods_name' and k!='goods_entrust'">
${k} = #{v}
</if>
<if test="k=='id'">
@ -133,6 +138,9 @@
<if test="k=='name'">
`name` like concat('%',#{v},'%')
</if>
<if test="k=='createtime'">
${v}
</if>
</foreach>
</if>

6
src/test/java/cn/chjyj/szwh/mapper/GoodsMapperTest.java

@ -63,9 +63,9 @@ public class GoodsMapperTest {
String wcon="is_deleted=0";
List<Goods> glist = goodsMapper.getGoodsByCondition(wcon,12,"click_count", "DESC");
for(Goods g:glist){
System.out.println(g.getId());
System.out.println(g.getClickCount()+"|"+g.getId()+"|"+g.getGoodsIslicode());
// System.out.println(g.getId());
}
// System.out.println(glist.size());
}
@Test
@ -91,7 +91,7 @@ public class GoodsMapperTest {
Map map =new HashMap();
map.put("gd.goods_entrust",1);
map.put("ishow",0); //不推荐的
String odkey ="g.sale_count";
String odkey ="g.click_count";
String odval="DESC";
List<GoodsListVo> goodsListVoList = goodsMapper.getGoodsVoList(map,odkey,odval,100,0);
for (GoodsListVo gv:goodsListVoList){

Loading…
Cancel
Save