model = new OrderItemModel(); $this->detailsModel = new OrderDetailsModel(); } public function index($order_id) { $list = $this->model->where('order_id', $order_id)->select(); $orderInfo = $this->detailsModel->find($order_id); $year = date('Y', strtotime($orderInfo->contract_time)); $goodsSubtotalList = Goods::getGoodsSubtotal(); return View::fetch('',[ 'list' => $list, 'order_id' => $order_id, 'orderInfo' => $orderInfo, 'year' => $year, 'goodsSubtotalList' => $goodsSubtotalList ]); } public function info($id) { $data = $this->model->find($id); if ($this->request->isAjax()) { return json(['code'=>2, 'data'=>$data]); } } public function save() { if ($this->request->isAjax()) { $param = $this->request->param(); // var_dump($param); // exit; try { if ($param['id']) { $order = $this->model->find(intval($param['id'])); } else { $order = new OrderItemModel(); } $order->order_id = intval($param['order_id']); $order->goods_id = intval($param['goods_id']); $order->goods_price = intval(bcmul($param['goods_price'], 100)); $order->goods_name = $param['goods_name']; $order->goods_category_id = intval($param['goods_category_id']); $order->goods_category_name = $param['goods_category_name']; $order->sales_amount = strval($param['sales_amount']); $order->sales_price = intval(bcmul($param['sales_price'], 100)); $order->sales_money = intval(bcmul($order->sales_amount , $order->sales_price)); $order->actual_amount = strval($param['actual_amount']); $order->actual_price = intval(bcmul($param['actual_price'], 100)); $order->actual_money = intval(bcmul($order->actual_amount, $order->actual_price)); $order->agency = intval(bcmul($param['agency'], 100)); $order->fare = intval(bcmul($param['fare'], 100)); $order->other_fee = intval(bcmul($param['other_fee'], 100)); $order->type = intval($param['type']); $order->remark = $param['remark']; $order->save(); } catch (\Exception $e) { // $this->error($e->getMessage()); return json(['code'=>0, 'msg'=>$e->getMessage()]); } return json(['code'=>2]); } } public function delete($id) { if ($this->request->isPost()) { if ($this->model->destroy($id)) { return json(['code'=>2]); } else { return json(['code'=>0]); } } } }