乐高玩具

购买历史

2018-03-12  本文已影响11人  wanggs

购买历史


@RestController
@RequestMapping("/api/history")
public class BuyHistoryApi {
    
    @Autowired
    OrdersDao ordersDao;
    @Autowired
    OrdersItemDao ordersItemDao;
    
    /**
     * 购买历史
     * @param param
     * @return
     */
    @RequestMapping(value="/listBuyHistory" ,method=RequestMethod.POST)
    public Ret buyHistory(@RequestBody BuyHistoryParam param) {
        User user = UserContext.getLoginUser();
        
        Query query= new Query();
        query.eq("userId", user.getId()).notNull("payTime");
        query.setPage(param.getPageIndex(), param.getPageSize());
        
        List<Orders> list = ordersDao.find(query);
        
        JSONArray orderRet = new JSONArray();
        for (Orders obj : list) {
            JSONObject json = (JSONObject)JSON.toJSON(obj);
            json.put("orderItems", this.buildOrderItems(obj));
            orderRet.add(json);
        }
        
        return Rets.successData(orderRet);
    }
    
    private List<OrdersItem> buildOrderItems(Orders obj) {
        Query query = new Query();
        query.eq("ordersId", obj.getId());
        
        return ordersItemDao.find(query);
    }
    
    
}



消费清单

{
    
}
{
  "code": 0,
  "data": [
    {
      "address": null, // 订单地址
      "distribeTime": null, // 配送时间
      "freight": null, // 运费
      "gmtCreate": "2017-04-28 14:42:30",
      "id": 1,
      "logisticsCompany": null, // 快递公司
      "logisticsNo": null, // 快递单号
      "mobile": null, // 手机号
      "moneyCnt": 10, // 金额
      "orderItems": [], // 订单明细项
      "payTime": "2017-05-03 15:14:09", // 付款时间
      "payTool": null, // 支付工具
      "payType": null, // 支付类型,weixin_pay(1,"微信支付"),weixin_charge(2,"微信充值"),lost_birck(3,"丢件扣费");
      "realName": null,// 姓名
      "remark": null, // 备注
      "sendTime": null, // 发货时间
      "status": 0, // 状态
      "userId": 1 // 用户id
    },
    {
      "address": null,
      "distribeTime": null,
      "freight": null,
      "gmtCreate": "2017-05-03 10:44:10",
      "id": 43,
      "logisticsCompany": null,
      "logisticsNo": null,
      "mobile": null,
      "moneyCnt": 4,
      "orderItems": [
        {
          "cnt": 1,
          "deposit": "",
          "firstWeekRentPrice": "",
          "gmtCreate": "2017-05-03 10:44:10",
          "id": 10,
          "legoSetId": 38,
          "moneyCnt": 2,
          "nextWeekRentPrice": "",
          "ordersId": 43,
          "price": "2.00",
          "remark": "",
          "rentWeekCnt": null
        }
      ],
      "payTime": "2017-05-03 15:14:15",
      "payTool": null,
      "payType": null,
      "realName": null,
      "remark": null,
      "sendTime": null,
      "status": 11,
      "userId": 1
    }
  ],
  "msg": ""
}
上一篇下一篇

猜你喜欢

热点阅读