前端页面
<div class="search_style">
<ul class="search_content ">
<li style="margin-right:20px;float: left;line-height: 30px"><label class="l_f">订单编号</label><input id="oid" class="easyui-textbox" data-options="prompt:'订单编号',validType:'unnormal'" style="width:200px"></input></li>
<li style="margin-right:20px;float: left;line-height: 30px"><label class="l_f">时间</label><input id="otime" class="easyui-datebox"; editable="fasle"; style=" margin-left:10px;"></li>
<li style="margin-right:20px;float: left;line-height: 30px"><label class="l_f">订单状态</label><select id="ostatus" id="cc" class="easyui-combobox" name="status" style="width:200px;">
<option value="0">全部</option>
<option value="1">待付款</option>
<option value="2">待发货</option>
<option value="3">待收货</option>
<option value="4">交易成功</option>
<option value="5">待评价</option>
<option value="6">交易关闭</option>
</select>
</li>
<li style="margin-right:20px;float: left;line-height: 30px;width:90px;"><button type="button" class="btn_search"><i class="search"></i>查询</button></li>
</ul>
</div>
js代码
$(function(){
$("button").click(function(){
var oid=$("#oid").val();//取订单号
var otime=$("#otime").datebox('getValue');//取订单时间
var ostatus=$("#ostatus").combobox('getValue');//取订单状态
var map={"oid" : oid,"otime":otime,"ostatus":ostatus};
var str=JSON.stringify(map);
$("#goodsorderList").datagrid({
type : "GET",
url : 'order/search/list',
queryParams : {
"oid" : oid,
"otime":otime,
"ostatus":ostatus
},
datatype : 'json',
onLoadSuccess : function(data) {
var result = eval(data).total;
if (result == 0) {
$.messager.alert('提示', '订单不存在!');
}
}
});
})
})
Controller层代码
//搜索查询订单列表
@RequestMapping(value="/search/list",method=RequestMethod.GET)
@ResponseBody
public EasyUIDataGridResult getSearchOrderList(String oid,String otime,String ostatus,Integer page,Integer rows) {
Map<String, Object> map=new HashMap<>();
if(!oid.equals("")) {
map.put("orderId",oid);
}else {
map.put("orderId",null);}
if(!otime.equals("")) {
map.put("createdtime", otime);
}else {
map.put("createdtime", null);
}if(!ostatus.equals("0")) {
map.put("status",ostatus);
}else {
map.put("status",null);
}
EasyUIDataGridResult result = orderService.querygoodsOrderList(map, page, rows);
return result;
}
Service层代码
public EasyUIDataGridResult querygoodsOrderList(Map<String, Object> map, int page, int rows) {
PageHelper.startPage(page, rows);
List<OrderPojo> list = orderMapper.queryGoodsOrderList(map, page, rows);
List<OrderListPoJo> listpojo=new ArrayList<>();
for(OrderPojo pojo:list) {
OrderListPoJo pojolist=new OrderListPoJo();
pojolist.setOrder_id(pojo.getOrder_id());
pojolist.setPayment(pojo.getPayment());
pojolist.setPayment_type(pojo.getPayment_type());
pojolist.setPost_fee(pojo.getPost_fee());
pojolist.setDeedvalue(pojo.getDeedvalue());
pojolist.setStatus(pojo.getStatus());
pojolist.setCreate_time(pojo.getCreate_time());
pojolist.setPayment_time(pojo.getPayment_time());
pojolist.setConsign_time(pojo.getConsign_time());
pojolist.setClose_time(pojo.getClose_time());
pojolist.setEnd_time(pojo.getClose_time());
pojolist.setShipping_code(pojo.getShipping_code());
pojolist.setShipping_name(pojo.getShipping_name());
pojolist.setShop_id(pojo.getShop_id());
pojolist.setShop_name(pojo.getShop_name());
pojolist.setSellerphone(getSellerPhone(pojo.getShop_id()));
listpojo.add(pojolist);
}
EasyUIDataGridResult result=new EasyUIDataGridResult();
result.setRows(listpojo);
PageInfo<OrderPojo> info=new PageInfo<>(list);
result.setTotal(info.getTotal());
return result;
}
Dao层代码
List<OrderPojo> queryGoodsOrderList(@Param(value="map")Map<String, Object> map,int page,int rows);
mapper.xml
<select id="queryGoodsOrderList" parameterType="map" resultType="com.test.pojo.OrderPojo">
SELECT
t1.order_id,
t1.payment,
t1.payment_type,
t1.post_fee,
t1.deed_value 'deedvalue',
t1.`status`,
t1.create_time,
t1.payment_time,
t1.consign_time,
t1.end_time,
t1.close_time,
t1.shipping_code,
t1.shipping_name,
t2.shop_id,
t2.shop_name
FROM tb_order t1 LEFT JOIN
tb_seller_order t2 ON t1.order_id=t2.order_id
<where>
<if test="map.orderId!=null and map.orderId!=''">
and t1.order_id like "%"#{map.orderId}"%"
</if>
<if test="map.createdtime!=null and map.createdtime!=''">
and date_format(t1.create_time,'%Y-%m-%d')=#{map.createdtime}
</if>
<if test="map.status!=null and map.status!=''">
and t1.status=#{map.status}
</if>
</where>
ORDER BY t1.create_time DESC
</select>
好久没写mapper顺便做个记录,以上就是所有的代码,有问题的地方请大神指正。