// +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Date: 2017-5-25 // +---------------------------------------------------------------------- namespace api\rob\controller; use app\rob\model\OrderModel; use app\rob\model\OrderProductModel; use cmf\controller\RestBaseController; class MyController extends RestBaseController { /** * 列表 */ public function index() { $param = $this->request->param(); $page = empty($param['page']) ? 1 : $param['page']; $size = empty($param['size']) ? 10 : $param['size']; //搜索条件 $where = []; if (!empty($param['status'])) { $where[] = ['status', '=', $param['status']]; } $list = OrderModel::with('orderProduct')->where($where) ->order('update_time desc') ->page($page, $size) ->select(); //数据处理 if (!$list->isEmpty()) { foreach ($list as $v) { foreach ($v['order_product'] as $product) { $product['product_image'] = cmf_get_image_preview_url($product['product_image']); } $v['create_time'] = date('Y-m-d H:i:s', $v['create_time']); $v['status_text'] = $v['status_text']; } } $this->success('成功', $list); } /** * 确认订单 */ public function orderConfirm() { $id = $this->request->param('id'); OrderModel::update(['status' => 2, 'receive_time' => time()], ['id' => $id]); $this->success('操作成功'); } /** * 获取二维码 */ public function qrcode() { include('../extend/util/phpqrcode/qrlib.php'); $id = $this->request->param('id'); $product = OrderProductModel::where('order_id',$id)->find(); if (empty($product)) { $this->error('该订单不支持二维码!'); } return \QRcode::png($product['code']); // $this->success('成功',); } }