params[ 'goods' ] ?? '[]'; $discount = $this->params[ 'discount' ] ?? '{}'; $data = [ 'site_id' => $this->site_id, 'member_id' => $this->params[ 'member_id' ] ?? 0, 'store_id' => $this->store_id, 'goods' => json_decode($goods, true), 'discount_moeny' => $this->params[ 'discount_moeny' ] ?? 0, 'discount' => json_decode($discount, true), 'remark' => $this->params[ 'remark' ] ?? '' ]; $res = ( new PendOrderModel() )->add($data); return $this->response($res); } public function edit() { $goods = $this->params[ 'goods' ] ?? '[]'; $discount = $this->params[ 'discount' ] ?? '{}'; $data = [ 'site_id' => $this->site_id, 'order_id' => $this->params[ 'order_id' ], 'member_id' => $this->params[ 'member_id' ] ?? 0, 'store_id' => $this->store_id, 'goods' => json_decode($goods, true), 'discount_moeny' => $this->params[ 'discount_moeny' ] ?? 0, 'discount' => json_decode($discount, true), 'remark' => $this->params[ 'remark' ] ?? '' ]; $res = ( new PendOrderModel() )->edit($data); return $this->response($res); } public function page() { $page_index = $this->params[ 'page' ] ?? 1; $page_size = $this->params[ 'page_size' ] ?? PAGE_LIST_ROWS; $conditon = [ [ 'o.site_id', '=', $this->site_id ], [ 'o.store_id', '=', $this->store_id ] ]; $model = new PendOrderModel(); $data = $model->getOrderPageList($conditon, 'o.*,m.nickname', 'o.create_time desc', $page_index, $page_size, 'o', [ [ 'member m', 'm.member_id = o.member_id', 'left' ] ]); if (!empty($data[ 'data' ][ 'list' ])) { $field = 'og.*, g.goods_type, g.goods_name, gs.spec_name, g.goods_image'; foreach ($data[ 'data' ][ 'list' ] as $k => $v) { $list = $model->getOrderGoodsList([ [ 'og.order_id', '=', $v[ 'order_id' ] ] ], $field, '', 'og', [ [ 'goods g', 'g.goods_id = og.goods_id', 'left' ], [ 'goods_sku gs', 'gs.sku_id = og.sku_id', 'left' ] ])[ 'data' ]; $data[ 'data' ][ 'list' ][ $k ][ 'order_goods' ] = $list; } } return $this->response($data); } public function delete() { $order_id = $this->params[ 'order_id' ]; $res = ( new PendOrderModel() )->delete([ 'site_id' => $this->site_id, 'store_id' => $this->store_id, 'order_id' => $order_id ]); return $this->response($res); } public function updateRemark() { $order_id = $this->params[ 'order_id' ]; $remark = $this->params[ 'remark' ]; $res = ( new PendOrderModel() )->update([ 'remark' => $remark ], [ [ 'site_id', '=', $this->site_id ], [ 'store_id', '=', $this->store_id ], [ 'order_id', '=', $order_id ] ]); return $this->response($res); } }