/** 根据订单编号查看订单消耗情况 */ @RequestMapping(value = "/getOrderBack", method = RequestMethod.GET) @ResponseBody public Object getOrderBack(long order_id) { String order_note = orderService.getOrderNote(order_id); List<Snacks> orderItems = orderItemService.getOrderitemByDefaultOrderId_4(order_id); List<Snacks> sellItems = orderItemService.getSellitemByOrderId_1(order_id); for (Snacks s : sellItems) { for (Snacks ss : orderItems) { if (ss.getSnacks_id() == s.getSnacks_id()) { ss.setEat_number(s.getSnacks_number()); } } } JSONObject js = new JSONObject(); js.put("order_note", order_note); js.put("orderItems", orderItems); return CommonUtil.constructResponse(1, "success", js); }
/** * @param需要提供订单id,物品的消耗情况 * @need 订单进行结算,将状态修改为40,插入一条销售记录,并计算出对应订单的销售金*额的并修改(信息来源配送人员) */ @RequestMapping(value = "/order_balance_update", method = RequestMethod.POST) @ResponseBody public JSONObject order_balance_update( HttpSession httpSession, long order_id, String sell_items) { staff staff = (staff) httpSession.getAttribute("staff"); // 获取员工 if (staff == null) { return CommonUtil.constructResponse(0, "员工不存在", null); } JSONObject jsonObject = JSONObject.parseObject(sell_items); JSONArray goods = (JSONArray) jsonObject.get("foods"); List<Snacks> snacks = orderItemService.getOrderitemByDefaultOrderId_4(order_id); Float order_cost_money = Float.valueOf(0); Float order_sell_money = Float.valueOf(0); for (Object j : goods) { JSONObject jo = JSONObject.parseObject(j.toString()); for (Snacks s : snacks) { long snacks_id = Long.valueOf(jo.get("snacks_id").toString()); if (snacks_id == s.getSnacks_id()) { Integer nu = jo.getInteger("snacks_num"); if (nu == null || nu < 0 || nu > s.getSnacks_number()) { return CommonUtil.constructResponse(0, "食品数量返回错误", null); } else { order_cost_money += nu * s.getSnacks_cost_price(); order_sell_money += nu * s.getSnacks_sell_price(); } } } } for (Object j : goods) { JSONObject jo = JSONObject.parseObject(j.toString()); long snacks_id = Long.valueOf(jo.get("snacks_id").toString()); Integer snacks_number = jo.getInteger("snacks_num"); sellItemService.insertsell_items(snacks_id, snacks_number, order_id); } orderService.update_order_price_1(order_id, order_cost_money, order_sell_money); loadTask.delTask(order_id + "", "BalanceJob"); loadTask.delTask(order_id + "", "BalanceJob_1"); return CommonUtil.constructResponse(1, "结算完成", 0); }