1.首先实现的效果如下
2.所有订单页的连接为:http://shop1.cnsaws.com.cn/shop/mb/order/initialize进入到前端页面
@RequestMapping(value = "/initialize") public String initialize(String orderStatus, Model model) { model.addAttribute("orderStatus", orderStatus); return "/shopmobile/buyer/smallshop/order/mine-order"; }
注意上方的标红区域可以看出向页面传输了一个订单状态,进入订单的初始化页面之后,会异步请求订单数据
<div class="pro_nav bg_white clearfix fl wp82 order_nav db_l s_09 bg_white"> <a href="javascript:;" class="orderStatus ptb15 js-nav active">全部</a> <a href="javascript:;" class="orderStatus ptb15 js-nav" orderStatus="DFK">待付款<i class="count"></i></a> <a href="javascript:;" class="orderStatus ptb15 js-nav" orderStatus="DFH">待发货<i class="count"></i></a> <a href="javascript:;" class="orderStatus ptb15 js-nav" orderStatus="TKZ">退款中<i class="count"></i></a> <span id="orderStatusLine" class="bd_line tc js-line" style="transform: translate3d(0px, 0px, 0px);"><!--<em class="iconfont icon-iconjiantoushang t_orange"></em>--></span> </div> </div> <div class="pro_list lists orderListContent"></div>
注意上方的标红区域,这个类涉及到局部刷新
commonPage("/shop/mb/smallshopgoods/order/list","page-content");
后台:
@RequestMapping(value = "/list") public String list(Orders orderVo, String searchType, Page<Orders> page, Model model) { // 只能查当前登录用户的订单数据 orderVo.setSellerId(ShiroUserUtil.getShiroUserId()); sellerOrdersService.findSoldOrders(orderVo, page); model.addAttribute("page", page); model.addAttribute("searchType", searchType); model.addAttribute("orderVo", orderVo); OwnerUserDomain ownerUserDomain = ownerUserDomainService.getSubDomainName(ShiroUserUtil.getProductSerialNumber()); if (!EmptyUtil.isNullOrEmpty(ownerUserDomain)) { String urlLink = ""; if (request.getServerPort() == 80) { urlLink = request.getScheme() + "://" + ownerUserDomain.getId() + request.getContextPath(); } else { urlLink = request.getScheme() + "://" + ownerUserDomain.getId() + ":" + request.getServerPort() + request.getContextPath(); } model.addAttribute("urlLink", urlLink); } return "/shopmobile/buyer/smallshop/order/sold-order-list"; }
上面的控制器调用了一个服务:
public List<Orders> findSoldOrders(Orders orderVo, Page<Orders> page) { if (EmptyUtil.isNullOrEmpty(orderVo)) { return null; } StringBuilder jpql = new StringBuilder(); Map<String, Object> params = new HashMap<String, Object>(); // 查询订单信息 jpql.append("select o from Orders o where o.enableFlag =:enableFlag "); params.put("enableFlag", EnableFlag.YES); // 微店订单查询,微店订单查询VO中不能设置sellerId if (!EmptyUtil.isNullOrEmpty(orderVo.getSellerId())) { jpql.append("and (o.sellerId =:sellerId or (exists (select (1) from SmallShopGoodsRelation sr where sr.id = o.smallShopRelationId and sr.sellerId =:smallSellerId and sr.enableFlag = 'YES')) ) "); params.put("sellerId", orderVo.getSellerId()); params.put("smallSellerId", orderVo.getSellerId()); } if (!EmptyUtil.isNullOrEmpty(orderVo.getOrderStatus())) { // 如果查询条件是待评价的状态则需要查待评价以及买家已评两种状态的订单 jpql.append("and o.orderStatus =:orderStatus "); params.put("orderStatus", orderVo.getOrderStatus()); } if (!EmptyUtil.isNullOrEmpty(orderVo.getDiscussStatus())) { jpql.append("and (o.discussStatus =:discussStatus or o.discussStatus =:discussStatus2) and o.orderStatus =:orderStatus "); params.put("discussStatus", orderVo.getDiscussStatus()); params.put("discussStatus2", DiscussStatus.BUYYER_YP); params.put("orderStatus", OrderStatus.YWC); } if (!EmptyUtil.isNullOrEmpty(orderVo.getDiscussStatusSearch())) { jpql.append("and (o.discussStatus =:discussStatusSearch) and o.orderStatus =:orderStatus2 "); params.put("discussStatusSearch", orderVo.getDiscussStatusSearch()); params.put("orderStatus2", OrderStatus.YWC); } if (!EmptyUtil.isNullOrEmpty(orderVo.getHasRefund())) { jpql.append("and o.hasRefund =:hasRefund "); params.put("hasRefund", orderVo.getHasRefund()); } if (!EmptyUtil.isNullOrEmpty(orderVo.getOrderNo())) { jpql.append("and o.orderNo like :orderNo "); params.put("orderNo", "%" + orderVo.getOrderNo() + "%"); } if (!EmptyUtil.isNullOrEmpty(orderVo.getBuyerName())) { jpql.append("and o.buyerName like :buyerName "); params.put("buyerName", "%" + orderVo.getBuyerName() + "%"); } if (!EmptyUtil.isNullOrEmpty(orderVo.getAcceptName())) { jpql.append("and o.acceptName like :acceptName "); params.put("acceptName", "%" + orderVo.getAcceptName() + "%"); } if (!EmptyUtil.isNullOrEmpty(orderVo.getGoodsName())) { jpql.append("and EXISTS (select 1 from OrderGoods og,Goods g where og.orderId = o.id and og.goodsId = g.id and g.goodsName like :goodsName) "); params.put("goodsName", "%" + orderVo.getGoodsName() + "%"); } if (!EmptyUtil.isNullOrEmpty(orderVo.getOperatorUserId())) { jpql.append("and EXISTS (select 1 from OrderGoods og,Goods g where og.orderId = o.id and og.goodsId = g.id and g.createUserId =:operatorUserId)"); params.put("operatorUserId", orderVo.getOperatorUserId()); } if (!EmptyUtil.isNullOrEmpty(orderVo.getMobile())) { jpql.append("and o.mobile like :mobile "); params.put("mobile", "%" + orderVo.getMobile() + "%"); } if (!EmptyUtil.isNullOrEmpty(orderVo.getStartTime())) { jpql.append("and o.createTime >= :startTime "); params.put("startTime", orderVo.getStartTime()); } if (!EmptyUtil.isNullOrEmpty(orderVo.getEndTime())) { jpql.append("and o.createTime <= :endTime "); params.put("endTime", DateUtil.getMaxtimeOfDay(orderVo.getEndTime())); } jpql.append("order by o.createTime desc"); page = this.dao.findPage(page, jpql.toString(), params); if (EmptyUtil.isNullOrEmpty(page.getResult())) { return page.getResult(); } // 查询订单下面包含的订单商品 for (Orders order : page.getResult()) { order.setOrderGoodsList(orderGoodsServcie.findByOrderId(order.getId())); order.setDeliveryDoc(deliveryDocService.getDeliverDocByOrderId(order.getId())); } return page.getResult(); }
实体类为:
@Entity @Table(name = "PT_ORDERS") public class Orders extends IdEntity { /** serialVersionUID */ private static final long serialVersionUID = 6482808156442224292L; /** 产品序列号 */ private String productSerialNumber; /** 订单号 */ private String orderNo; /** 交易流水号 */ private String serialNumber; /** 买家ID */ private String buyerId; /** 买家用户名:此字段为冗余字段 */ private String buyerName; /** 卖家ID */ private String sellerId; /** 卖家用户名:此字段为冗余字段 */ private String sellerName; /** 店铺ID:b2c中此字段无值,b2b2c中预留 */ private String shopId; /** 店铺名称:此字段为冗余字段,b2c中此字段无值,b2b2c中预留 */ private String shopName; /** * DFK("DFK", "待付款"), DFH("DFH", "待发货"), DSH("DSH", "待收货"), YWC("YWC", "交易成功"), YGB("YGB", "已关闭"); */ private OrderStatus orderStatus; /** HAVEPAY("HAVEPAY", "已支付"), NOPAY("NOPAY", "未支付"); */ private PayStatus payStatus; /** * DPJ("DPJ", "待评价"), BUYYER_YP("BUYYER_YP", "买家已评价"), SELLER_YP("SELLER_YP", "卖家已评价"), DOUBLE_YP("DOUBLE_YP", "双方已评价"); */ private DiscussStatus discussStatus; /** * 是否有追加评价{@link OAOConstants.YES} */ private String hasAddiDiscuss; /** * 是否存在退款商品 {@link OAOConstants.YES} */ private String hasRefund; /** 收货人姓名 */ private String acceptName; /** 邮编 */ private String zipcode; /** 联系电话 */ private String telphone; /** 手机 */ private String mobile; /** 省 */ private String province; /** 市 */ private String city; /** 区 */ private String area; /** 收货详细地址 */ private String receivingAddress; /** 发货点地址ID */ private String shipAddressId; /** 退货点地址ID */ private String refundAddressId; /** 应付商品总金额 原始金额 */ private BigDecimal payableAmount = BigDecimal.ZERO; /** 实付商品总金额 改价,优惠时改这个字段 */ private BigDecimal realAmount = BigDecimal.ZERO; /** 使用积分数 */ private Integer useIntegral = 0; /** 获得积分数 */ private Integer getIntegral = 0; /** 积分抵现总金额*/ private BigDecimal integralCash = BigDecimal.ZERO; /** 总运费金额 原始金额 */ private BigDecimal payableFreight = BigDecimal.ZERO; /** 实付运费 改价,优惠时改这个字段 */ private BigDecimal realFreight = BigDecimal.ZERO; /** 会员折扣 */ private Double memberDiscount; /** 付款时间 */ private Date payTime; /** 发货时间 */ private Date sendTime; /** 系统自动确认收货时间 */ private Date autoAcceptTime; /** 是否有过延长确认收货时间 默认;NO没有,YES:有 */ private String hasProlong; /** 下单时间 */ private Date createTime; /** 用户收货时间 */ private Date acceptTime; /** 订单完成时间 */ private Date completionTime; /** 用户附言 */ private String postscript; /** 管理员备注 */ private String note; /** 付款方式*/ private String payType; /** 订单删除状态:NO:未删除,RECYCLE:回收站,DELETE:已删除 */ private DeleteStatus deleteStatus; /** 一件代发 YES */ private String replaceSend; /**是否是福气商品订单 YES,NO**/ private String isFuOrder; /** * 团购类型 COMMON普通团 LADDER阶梯团 JOINT拼团 */ private String groupBuyOrder; /** * 是否执行了团购退款退款 (标记字段) */ private String isBackGroupBuy; /** * 下订单时参团人数 */ private Long groupBuyPersonsNum =0L; /**福气资格等级**/ private Integer fuGoodsLevel = 0; /** * 拼团邀请人用户id */ private String joinShareUserId; /** * 门店app分享人id(店员分享人id) */ private String clerkShareUserId; // 以下为非PO /** 订单商品 */ private List<OrderGoods> orderGoodsList = new ArrayList<OrderGoods>(); // 需要减库存的货品id 以及数量 private Map<String, Long> updateStoreProductIds = new HashMap<String, Long>(); // 已购买的所有的货品id private List<String> buyProductIdList = new ArrayList<String>(); /** 开始时间:查询的接受参数*/ private Date startTime; /** 结束时间:查询的接受参数*/ private Date endTime; /** 商品名称:查询的接受参数*/ private String goodsName; /** 发货信息*/ private DeliveryDoc deliveryDoc; /**订单来自哪里 :购物车*/ private String from; /**收货地址的id*/ private String recevieAddressId; /**为订单列表页查询条件所用*/ private DiscussStatus discussStatusSearch; /**运维人员id**/ private String operatorUserId; /** 微商品关系id,没有此字段表示是微商品订单**/ private String smallShopRelationId;