append(['appoint_time','appoint_week','door_time','order_status_desc','pay_way_desc','confirm_service_btn','verification_btn','province','city','district']) ->with(['order_goods' => function($query){ $query->field('order_id,goods_snap,goods_name,goods_price,goods_num,unit_name')->append(['goods_image'])->hidden(['goods_snap']); },'staff' => function($query){ $query->field('id,name,mobile,user_id'); }]) ->findOrEmpty() ->toArray(); return $result; } /** * @notes 确认服务 * @param $id * @return bool * @author ljj * @date 2022/3/1 3:43 下午 */ public function confirmService($id) { Order::update(['order_status'=>OrderEnum::ORDER_STATUS_SERVICE],['id'=>$id]); $order = Order::where('id',$id)->findOrEmpty()->toArray(); // 师傅确认服务通知 - 通知买家 event('Notice', [ 'scene_id' => NoticeEnum::STAFF_CONFIRM_ORDER_NOTICE, 'params' => [ 'user_id' => $order['user_id'], 'order_id' => $order['id'] ] ]); return true; } /** * @notes 订单核销 * @param $params * @return Order|bool * @author ljj * @date 2022/3/1 3:59 下午 */ public function verification($params) { // 启动事务 Db::startTrans(); try { $order = Order::where('verification_code',$params['verification_code'])->findOrEmpty()->toArray(); //更新订单状态 Order::update([ 'order_status' => OrderEnum::ORDER_STATUS_FINISH, 'verification_status' => OrderEnum::VERIFICATION, 'finish_time' => time(), ],['id'=>$order['id']]); //添加订单日志 (new OrderLogLogic())->record(OrderLogEnum::TYPE_USER,OrderLogEnum::USER_VERIFICATION,$order['id'],$params['user_id']); // 订单完成通知 - 通知买家 event('Notice', [ 'scene_id' => NoticeEnum::ORDER_FINISH_NOTICE, 'params' => [ 'user_id' => $order['user_id'], 'order_id' => $order['id'] ] ]); // 提交事务 Db::commit(); return true; } catch (\Exception $e) { // 回滚事务 Db::rollback(); return $e->getMessage(); } } }