123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- /*
- * @Author: wang jun
- * @Date: 2021-10-29 16:16:29
- * @Last Modified by: wang jun
- * @Last Modified time: 2021-12-31 17:52:41
- */
- namespace app\index\server;
- use app\index\model\partybusinessmodel;
- use app\index\server\businessserver as BusinessBase;
- use think\Log;
- class partybusinessserver extends BusinessBase
- {
- protected $m_pb;
- public function __construct()
- {
- $this->m_pb = new partybusinessmodel();
- }
- public function getinfo($arr)
- {
- $where = ['isactive' => 1, 'typeid' => $arr['typeid'], 'type' => $arr['type']];
- if (isset($arr['code']) && !empty($arr['code']) && is_string($arr['code'])) {
- $where['code'] = $arr['code'];
- $info = $this->m_pb->getInfo($where);
- if (!$info) {
- throw new \Exception("无业务数据");
- }
- $result = $this->checkactive($info);
- if (!$result) {
- if ($info['isautooff']) {
- $this->closebusiness($info['id']);
- } else {
- throw new \Exception("业务不可用");
- }
- }
- $result = $this->checkstart($info);
- if (!$result) {
- if ($arr['maststart']) {
- throw new \Exception("业务未开始");
- }
- $info['isstart'] = false;
- } else {
- $info['isstart'] = true;
- }
- }
- if (empty($info)) {
- throw new \Exception("无可用业务");
- }
- return $info;
- }
- /**
- * 关闭业务
- * 20220104
- * wj
- */
- protected function closebusiness($id)
- {
- $where = ['id' => $id];
- $update = ['isactive' => 0];
- $row = $this->m_pb->updateinfo($where, $update);
- if (empty($row)) {
- log::info($where);
- throw new \Exception("业务关闭失败");
- }
- }
- }
|