You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
160 lines
6.7 KiB
160 lines
6.7 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | 天诚科技 [ 刘海东 17600099397赋能开发者,助力企业发展 ]
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2016~2020 https://www.tczxkj.com All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Licensed 该系统并不是自由软件,未经许可不能去掉相关版权
|
|
// +----------------------------------------------------------------------
|
|
// | Author:甘肃天诚志信电子商务有限公司 刘海东 联系电话维系17600099397
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\admin\model\institution;
|
|
|
|
use traits\ModelTrait;
|
|
use basic\ModelBasic;
|
|
use think\Url;
|
|
use app\admin\model\special\Lecturer;
|
|
use app\admin\model\wechat\WechatUser;
|
|
use service\SystemConfigService;
|
|
use service\WechatTemplateService;
|
|
use app\wap\model\routine\RoutineTemplate;
|
|
use app\admin\model\user\User;
|
|
use app\wap\model\wap\SmsTemplate;
|
|
use service\AliMessageService;
|
|
|
|
|
|
/**
|
|
* Class UserInstitution 机构申请
|
|
* @package app\admin\model\merchant
|
|
*/
|
|
class UserInstitution extends ModelBasic
|
|
{
|
|
use ModelTrait;
|
|
|
|
//设置where条件
|
|
public static function setWhere($where, $alirs = '', $model = null)
|
|
{
|
|
$model = $model === null ? new self() : $model;
|
|
$model = $alirs !== '' ? $model->alias($alirs) : $model;
|
|
$alirs = $alirs === '' ? $alirs : $alirs . '.';
|
|
$model = $model->where("{$alirs}is_del", 0);
|
|
$model = $model->where("entry_type",$where["entry_type"]);
|
|
if ($where['title'] && $where['title']) $model = $model->where("{$alirs}merchant_name", 'LIKE', "%$where[title]%");
|
|
return $model;
|
|
}
|
|
|
|
/**机构列表
|
|
* @param $where
|
|
* @return array
|
|
* @throws \think\Exception
|
|
*/
|
|
public static function getLecturerList($where)
|
|
{
|
|
$data = self::setWhere($where)->page((int)$where['page'], (int)$where['limit'])->select();
|
|
$data = count($data) ? $data->toArray() : [];
|
|
$count = self::setWhere($where)->count();
|
|
return compact('data', 'count');
|
|
}
|
|
|
|
/**
|
|
* 删除机构申请
|
|
* @param $id
|
|
* @return bool|int
|
|
* @throws \think\exception\DbException
|
|
*/
|
|
public static function delLecturer($id)
|
|
{
|
|
$lecturer = self::get($id);
|
|
if (!$lecturer) return self::setErrorInfo('删除的数据不存在');
|
|
return self::where('id', $id)->delete();
|
|
}
|
|
|
|
/**审核失败
|
|
* @param $id
|
|
* @param $fail_msg
|
|
* @return bool
|
|
* @throws \think\exception\DbException
|
|
*/
|
|
public static function changeFail($id, $uid, $fail_message, $enter)
|
|
{
|
|
$fail_time = time();
|
|
$status = -1;
|
|
try {
|
|
$wechat_notification_message = SystemConfigService::get('wechat_notification_message');
|
|
if ($wechat_notification_message == 1) {
|
|
WechatTemplateService::sendTemplate(WechatUser::uidToOpenid($uid), WechatTemplateService::EXAMINE_RESULT, [
|
|
'first' => '尊敬的用户,您提交机构入住申请审核结果已出。',
|
|
'keyword1' => '审核失败',
|
|
'keyword2' => date('Y-m-d H:i:s', time()),
|
|
'remark' => '失败原因:' . $fail_message
|
|
], Url::build('wap/spread/spread', [], true, true));
|
|
} else {
|
|
$dat['phrase5']['value'] = '审核失败';
|
|
$dat['time24']['value'] = date('Y-m-d H:i:s', time());
|
|
$dat['thing4']['value'] = '失败原因:' . $fail_message;
|
|
RoutineTemplate::sendExamineResult($dat, $uid, Url::build('wap/spread/spread', [], true, true));
|
|
}
|
|
} catch (\Exception $e) {
|
|
}
|
|
$site_name = SystemConfigService::get('site_name');
|
|
$sms_platform_selection = SystemConfigService::get('sms_platform_selection');
|
|
if ($sms_platform_selection == 1) {
|
|
$approval_failed_template_id = SystemConfigService::get('approval_failed_template_id');//审核未通过模版ID
|
|
if ($approval_failed_template_id) {
|
|
$data['site_name'] = $site_name;
|
|
AliMessageService::sendmsg($enter['link_tel'], $approval_failed_template_id, $data);
|
|
}
|
|
} else {
|
|
$data['site_name'] = $site_name;
|
|
$data['phone'] = $enter['link_tel'];
|
|
SmsTemplate::sendSms($uid, $data, 'ENTRY_FAILED');
|
|
}
|
|
return self::edit(compact('fail_time', 'fail_message', 'status'), $id);
|
|
}
|
|
|
|
/**审核成功
|
|
* @param $id
|
|
* @return bool
|
|
*/
|
|
public static function changeSuccess($id, $uid, $enter)
|
|
{
|
|
$success_time = time();
|
|
$status = 1;
|
|
try {
|
|
$wechat_notification_message = SystemConfigService::get('wechat_notification_message');
|
|
if ($wechat_notification_message == 1) {
|
|
WechatTemplateService::sendTemplate(WechatUser::uidToOpenid($uid), WechatTemplateService::EXAMINE_RESULT, [
|
|
'first' => '尊敬的用户,您提交机构入住申请审核结果已出。',
|
|
'keyword1' => '审核成功',
|
|
'keyword2' => date('Y-m-d H:i:s', time()),
|
|
'remark' => '感恩您的参与和支持,谢谢!'
|
|
], Url::build('wap/spread/spread', [], true, true));
|
|
} else {
|
|
$dat['phrase5']['value'] = '审核成功';
|
|
$dat['time24']['value'] = date('Y-m-d H:i:s', time());
|
|
$dat['thing4']['value'] = '感恩您的参与和支持,谢谢!';
|
|
RoutineTemplate::sendExamineResult($dat, $uid, Url::build('wap/spread/spread', [], true, true));
|
|
}
|
|
} catch (\Exception $e) {
|
|
}
|
|
$site_name = SystemConfigService::get('site_name');
|
|
$sms_platform_selection = SystemConfigService::get('sms_platform_selection');
|
|
if ($sms_platform_selection == 1) {
|
|
$approved_template_id = SystemConfigService::get('approved_template_id');//审核通过模版ID
|
|
if ($approved_template_id) {
|
|
$data['site_name'] = $site_name;
|
|
$data['phone'] = $enter['link_tel'];
|
|
$data['pwd'] = '123456';
|
|
AliMessageService::sendmsg($enter['link_tel'], $approved_template_id, $data);
|
|
}
|
|
} else {
|
|
$site_name = SystemConfigService::get('site_name');
|
|
$data['site_name'] = $site_name;
|
|
$data['phone'] = $enter['link_tel'];
|
|
$data['pwd'] = '123456';
|
|
SmsTemplate::sendSms($uid, $data, 'SETTLED_THROUGH');
|
|
}
|
|
return self::edit(compact('status', 'success_time'), $id);
|
|
}
|
|
}
|
|
|