12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- /*
- * @Author: wang jun
- * @Date: 2021-12-31 16:08:48
- * @Last Modified by: wang jun
- * @Last Modified time: 2021-12-31 17:57:06
- */
- namespace app\index\server;
- use app\index\model\businesstypemodel;
- class businessserver
- {
- public function getserverobj($kind, $type)
- {
- $m_b = new businesstypemodel();
- $where = [
- 'kind' => $kind,
- 'type' => $type,
- ];
- $info = $m_b->getInfo($where);
- if (empty($info)) {
- return backarr(0, '业务处理请求错误');
- }
- $classpath = str_replace("\\", "/", __CLASS__);
- $classpatharray = array_filter(explode('/', $classpath));
- $classname = $classpatharray[count($classpatharray) - 1];
- $serverclass = str_replace($classname, $type . $classname, __CLASS__);
- $parentclass = str_replace($classname, $kind . $classname, __CLASS__);
- if (!class_exists($parentclass)) {
- throw new \Exception("无对应业务");
- }
- $parentobj = new $parentclass();
- if (!class_exists($serverclass)) {
- throw new \Exception("无对应服务");
- }
- $obj = new $serverclass();
- if ($obj instanceof $parentobj) {
- return $obj;
- }
- throw new \Exception("无对应服务");
- }
- /**
- * 校验业务是否可用
- * 20211231
- * wj
- */
- protected function checkactive($info)
- {
- $time = time();
- $isactive = $info['isactive'];
- $starttime = strtotime($info['starttime']);
- $endtime = strtotime($info['endtime']);
- if (!$isactive) {
- return false;
- }
- if ($time > $endtime) {
- return false;
- }
- return true;
- }
- /**
- * 校验业务是否开始
- * 20220112
- * wj
- */
- protected function checkstart($info)
- {
- $time = time();
- $isactive = $info['isactive'];
- $starttime = strtotime($info['starttime']);
- $endtime = strtotime($info['endtime']);
- if (!$isactive) {
- return false;
- }
- if ($time < $starttime) {
- return false;
- }
- return true;
- }
- }
|