store_id = get_store_id(); $form->user_id = get_user_id(); $form->attributes = post_params(); return $form->submit(); } /** * 订单支付接口 * @return array */ public function actionPay() { $form = new OrderForm(); $form->store_id = get_store_id(); $form->user_id = get_user_id(); $form->order_id = post_params('order_id'); $form->pay_type = post_params('pay_type'); return $form->pay(); } /** * 订单列表 */ public function actionList() { $form = new OrderListForm(); $form->store_id = get_store_id(); $form->user_id = get_user_id(); return $form->list(); } /** * 订单详情 */ public function actionDetail() { $order_id = get_params('order_id'); $food_times = FoodOrderDetail::find()->where(['order_id' => $order_id])->groupBy('times')->select('times')->asArray()->all(); $food_times = array_column($food_times, 'times'); $food_order = FoodOrder::findOne($order_id); $goods_counts = FoodOrderDetail::find()->where(['order_id' => $order_id])->sum('num'); // 组装返回数据 $data = [ 'table_num' => $food_order->table_num, 'pay_type' => is_wechat_platform() ? 1 : 4, 'total_price' => $food_order->total_price, 'pay_price' => $food_order->pay_price, 'goods_count' => $goods_counts, 'order_no' => $food_order->order_no, 'created_at' => date('Y-m-d H:i:s', $food_order->created_at), ]; rsort($food_times); $result = []; foreach ($food_times as $times) { $goods_list = FoodOrderDetail::find()->where(['order_id' => $order_id, 'times' => $times])->asArray()->all(); $tmp = []; foreach ($goods_list as $goods) { $tmp['time'] = date('Y-m-d H:i:s', $goods['created_at']); $tmp['goods_list'][] = [ 'id' => $goods['goods_id'], 'name' => $goods['goods_name'], 'price' => $goods['total_price'], 'num' => $goods['num'], 'pic' => $goods['pic'], 'attr' => Json::decode($goods['attr']) ]; } $result[] = $tmp; } $option = Option::get('food_book', get_store_id(), 'store', [ 'tips' => '菜品已在制作中,请耐心等待', 'say_time' => '10', ]); $option = is_string($option['value']) ? json_decode($option['value'], true) : $option['value']; $data['tips'] = $option['tips']; $data['say_time'] = $option['say_time']; $data['list'] = $result; return [ 'code' => 0, 'msg' => 'success', 'data' => $data ]; } }