partybusinessserver.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /*
  3. * @Author: wang jun
  4. * @Date: 2021-10-29 16:16:29
  5. * @Last Modified by: wang jun
  6. * @Last Modified time: 2021-12-31 17:52:41
  7. */
  8. namespace app\index\server;
  9. use app\index\model\partybusinessmodel;
  10. use app\index\server\businessserver as BusinessBase;
  11. use think\Log;
  12. class partybusinessserver extends BusinessBase
  13. {
  14. protected $m_pb;
  15. public function __construct()
  16. {
  17. $this->m_pb = new partybusinessmodel();
  18. }
  19. public function getinfo($arr)
  20. {
  21. $where = ['isactive' => 1, 'typeid' => $arr['typeid'], 'type' => $arr['type']];
  22. if (isset($arr['code']) && !empty($arr['code']) && is_string($arr['code'])) {
  23. $where['code'] = $arr['code'];
  24. $info = $this->m_pb->getInfo($where);
  25. if (!$info) {
  26. throw new \Exception("无业务数据");
  27. }
  28. $result = $this->checkactive($info);
  29. if (!$result) {
  30. if ($info['isautooff']) {
  31. $this->closebusiness($info['id']);
  32. } else {
  33. throw new \Exception("业务不可用");
  34. }
  35. }
  36. $result = $this->checkstart($info);
  37. if (!$result) {
  38. if ($arr['maststart']) {
  39. throw new \Exception("业务未开始");
  40. }
  41. $info['isstart'] = false;
  42. } else {
  43. $info['isstart'] = true;
  44. }
  45. }
  46. if (empty($info)) {
  47. throw new \Exception("无可用业务");
  48. }
  49. return $info;
  50. }
  51. /**
  52. * 关闭业务
  53. * 20220104
  54. * wj
  55. */
  56. protected function closebusiness($id)
  57. {
  58. $where = ['id' => $id];
  59. $update = ['isactive' => 0];
  60. $row = $this->m_pb->updateinfo($where, $update);
  61. if (empty($row)) {
  62. log::info($where);
  63. throw new \Exception("业务关闭失败");
  64. }
  65. }
  66. }