self::SIGN_STATUS_SUCCESS])->select(); } public static function getByOpenId(string $openId) { return self::where(['open_id' => $openId, 'sign_status' => 0])->findOrEmpty(); } public static function getByUserId(int $userId) { return self::where(['user_id' => $userId])->findOrEmpty(); } /** * 查询最近一年该用户是否有签约 * @param int $userId * @return Sign|array|mixed|Model */ public static function getSignLastYear(int $userId) { return self::whereTime('create_time', '-1 year')->where(['user_id' => $userId, 'sign_status' => Sign::SIGN_STATUS_SUCCESS])->findOrEmpty(); } /** * 查询最近一年该用户是否有解约 * @param int $userId * @return Sign|array|mixed|Model */ public static function getReleaseLastYear(int $userId) { return self::whereTime('create_time', '-1 year')->where(['user_id' => $userId, 'sign_status' => Sign::SIGN_STATUS_RELEASE])->findOrEmpty(); } /** * 根据流水号查询数据 * @param string $requestSerial * @return Sign|array|mixed|Model */ public static function getByRequestSerial(string $requestSerial) { return self::where(['request_serial' => $requestSerial])->findOrEmpty(); } /** * 根据商户协议号获取数据 * @param string $agreementId * @return Sign|array|mixed|Model */ public static function getByAgreementId(string $agreementId) { return self::where(['m_agreement_id' => $agreementId])->findOrEmpty(); } /** * 查询正在订阅的用户 * @param int $userId * @return Sign|array|mixed|Model */ public static function getSubscribeByUserId(int $userId) { return self::where(['user_id' => $userId, 'sign_status' => Sign::SIGN_STATUS_SUCCESS])->findOrEmpty(); } /** * 查询该用户正在签约的信息 * @param int $userId * @return Sign|array|mixed|Model */ public static function getWaitSignByUserId(int $userId) { return self::where(['user_id' => $userId, 'sign_status' => Sign::SIGN_STATUS_DEFAULT])->findOrEmpty(); } /** * 查询最近一年该用户是否有签约 * @param int $userId * @return Sign|array|mixed|Model */ public static function getSignLastYearByMobile(int $mobile) { return self::whereTime('create_time', '-1 year')->where(['mobile' => $mobile, 'sign_status' => Sign::SIGN_STATUS_SUCCESS])->findOrEmpty(); } }