LiveAudit.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\admin\model\live;
  12. /**
  13. * 直播审核
  14. */
  15. use basic\ModelBasic;
  16. use traits\ModelTrait;
  17. use app\admin\model\merchant\Merchant;
  18. use service\SystemConfigService;
  19. use service\WechatTemplateService;
  20. use app\wap\model\routine\RoutineTemplate;
  21. use app\admin\model\wechat\WechatUser;
  22. class LiveAudit extends ModelBasic
  23. {
  24. use ModelTrait;
  25. /**
  26. * 获取连表MOdel
  27. * @param $model
  28. * @return object
  29. */
  30. public static function getModelExamine($where = [])
  31. {
  32. $model = new self();
  33. $model = $model->alias('p');
  34. if (isset($where['store_name']) && $where['store_name'] != '') {
  35. $model = $model->where('p.live_title|p.stream_name', 'LIKE', "%$where[store_name]%");
  36. }
  37. if (isset($where['order']) && $where['order'] != '') {
  38. $model = $model->order(self::setOrder($where['order']));
  39. } else {
  40. $model = $model->order('p.add_time DESC');
  41. }
  42. $model = $model->join('LiveStudio l', 'p.live_id=l.id');
  43. return $model;
  44. }
  45. /*
  46. * 获取直播审核列表
  47. * @param $where array
  48. * @return array
  49. *
  50. */
  51. public static function liveExamineList($where)
  52. {
  53. $model = self::getModelExamine($where)->field('p.*');
  54. $model = $model->page((int)$where['page'], (int)$where['limit']);
  55. $data = ($data = $model->select()) && count($data) ? $data->toArray() : [];
  56. foreach ($data as $key => &$volue) {
  57. $volue['live_strar_time'] = date('Y-m-d H:i:s', $volue['live_strar_time']);
  58. $volue['live_end_time'] = date('Y-m-d H:i:s', $volue['live_end_time']);
  59. $volue['fail_time'] = date('Y-m-d H:i:s', $volue['fail_time']);
  60. }
  61. $count = self::getModelExamine($where)->count();
  62. return compact('count', 'data');
  63. }
  64. /**审核失败
  65. * @param $id
  66. * @param $fail_msg
  67. * @return bool
  68. * @throws \think\exception\DbException
  69. */
  70. public static function changeFail($id, $mer_id, $fail_message)
  71. {
  72. $fail_time = time();
  73. $status = -1;
  74. $uid = Merchant::where('id', $mer_id)->value('uid');
  75. try {
  76. $wechat_notification_message = SystemConfigService::get('wechat_notification_message');
  77. if ($wechat_notification_message == 1) {
  78. WechatTemplateService::sendTemplate(WechatUser::uidToOpenid($uid), WechatTemplateService::EXAMINE_RESULT, [
  79. 'first' => '尊敬的讲师,您的直播申请审核结果已出。',
  80. 'keyword1' => '直播审核失败',
  81. 'keyword2' => date('Y-m-d H:i:s', time()),
  82. 'remark' => '直播失败原因:' . $fail_message
  83. ], '');
  84. } else {
  85. $dat['phrase5']['value'] = '直播审核失败';
  86. $dat['time24']['value'] = date('Y-m-d H:i:s', time());
  87. $dat['thing4']['value'] = '直播失败原因:' . $fail_message;
  88. RoutineTemplate::sendExamineResult($dat, $uid, '');
  89. }
  90. } catch (\Exception $e) {
  91. }
  92. return self::edit(compact('fail_time', 'fail_message', 'status'), $id);
  93. }
  94. /**审核成功
  95. * @param $id
  96. * @return bool
  97. */
  98. public static function changeSuccess($id, $mer_id)
  99. {
  100. $success_time = time();
  101. $status = 1;
  102. $uid = Merchant::where('id', $mer_id)->value('uid');
  103. try {
  104. $wechat_notification_message = SystemConfigService::get('wechat_notification_message');
  105. if ($wechat_notification_message == 1) {
  106. WechatTemplateService::sendTemplate(WechatUser::uidToOpenid($uid), WechatTemplateService::EXAMINE_RESULT, [
  107. 'first' => '尊敬的讲师,您的直播申请审核结果已出。',
  108. 'keyword1' => '直播审核成功',
  109. 'keyword2' => date('Y-m-d H:i:s', time()),
  110. 'remark' => '感恩您的努力付出,谢谢!'
  111. ], '');
  112. } else {
  113. $dat['phrase5']['value'] = '直播审核成功';
  114. $dat['time24']['value'] = date('Y-m-d H:i:s', time());
  115. $dat['thing4']['value'] = '您的直播申请审核结果已出!';
  116. RoutineTemplate::sendExamineResult($dat, $uid, '');
  117. }
  118. } catch (\Exception $e) {
  119. }
  120. return self::edit(compact('status', 'success_time'), $id);
  121. }
  122. }