$order_sn, 'operator' => $operator, 'memo' => $memo, 'action_type' => OrderActionEnum::ACTION_MODIFY, 'user_type' => OrderActionEnum::USER_TYPE_ADMIN, 'operator_type' => OrderActionEnum::OPERATOR_TYPE_ADMIN, 'priority' => OrderActionEnum::getDefaultPriority(OrderActionEnum::ACTION_MODIFY), 'user_id' => 0, 'ip' => request()->ip(), 'user_agent' => request()->server('HTTP_USER_AGENT', ''), 'extra_data' => '', ]) ? true : false; } /** * 按订单编号查询操作记录 * @param string $order_sn 订单编号 * @param string $action_type 操作类型(可选) * @param string $user_type 用户类型(可选) * @return \think\Collection */ public static function getByOrderSn($order_sn, $action_type = '', $user_type = '') { $where = ['order_sn' => $order_sn]; if ($action_type) { $where['action_type'] = $action_type; } if ($user_type) { $where['user_type'] = $user_type; } return self::where($where) ->order('createtime', 'desc') ->select(); } /** * 获取最后一次操作记录 * @param string $order_sn 订单编号 * @param string $action_type 操作类型(可选) * @return OrderAction|null */ public static function getLatestByOrderSn($order_sn, $action_type = '') { $where = ['order_sn' => $order_sn]; if ($action_type) { $where['action_type'] = $action_type; } return self::where($where) ->order('createtime', 'desc') ->find(); } /** * 检查操作是否存在 * @param string $order_sn 订单编号 * @param string $action_type 操作类型 * @return bool */ public static function hasActionType($order_sn, $action_type) { return self::where([ 'order_sn' => $order_sn, 'action_type' => $action_type ])->count() > 0; } /** * 批量插入操作记录 * @param array $data 批量数据 * @return bool */ public static function insertBatch($data) { return self::insertAll($data) ? true : false; } }