| | |
| | | <?php
namespace app\shop\model\plus\operations;
use app\common\model\plus\operations\Apply as ApplyModel;
use app\common\service\message\MessageService;
use app\common\model\plus\operations\Grade as GradeModel;
/**
* 队长入驻申请模型
*/
class Apply extends ApplyModel
{
/**
* 获取队长申请列表
* @noinspection PhpUndefinedMethodInspection
*/
public function getList($search)
{
$model = $this->alias('apply')
->field('apply.*, user.nickName, user.avatarUrl')
->with(['referee'])
->join('user', 'user.user_id = apply.user_id')
->order(['apply.create_time' => 'desc']);
if (!empty($search['nick_name'])) {
$model = $model->where('user.nickName|apply.real_name|apply.mobile', 'like', '%' . $search['nick_name'] . '%');
}
// 获取列表数据
return $model->paginate($search['list_rows']);
}
/**
* 股东入驻审核
* @param $data
* @return bool
*/
public function submit($data)
{
if ($data['apply_status'] == '30' && empty($data['reject_reason'])) {
$this->error = '请填写驳回原因';
return false;
}
$this->startTrans();
if ($data['apply_status'] == '20') {
//$grade_id=GradeModel::getDefaultGradeId();
// 新增区域代理用户
Operations::add($data['user_id'], [
'real_name' => $data['real_name'],
'mobile' => $data['mobile'],
'operations_level' => $data['operations_level']["value"],
'province_id' => $data['province_id'],
'city_id' => $data['city_id'],
'area_id' => $data['area_id'],
'referee_id' => $data['referee_id'],
//'grade_id'=>$grade_id
]);
}
$save_data = [
'audit_time' => time(),
'apply_status' => $data['apply_status'],
'reject_reason' => $data['reject_reason'],
];
$this->save($save_data);
// 记录推荐人关系
// if ($data['referee_id'] > 0) {
// RefereeModel::createRelation($data['user_id'], $data['referee_id']);
// }
// 发送模板消息
(new MessageService)->operations($this);
$this->commit();
return true;
}
/**
* 获取申请中的数量
*/
public static function getApplyCount(){
return (new static())->where('apply_status', '=', 10)->count();
}
} |
| | | <?php |
| | | |
| | | namespace app\shop\model\plus\operations; |
| | | |
| | | use app\common\model\plus\operations\Apply as ApplyModel; |
| | | |
| | | /** |
| | | * 队长入驻申请模型 |
| | | */ |
| | | class Apply extends ApplyModel |
| | | { |
| | | /** |
| | | * 获取队长申请列表 |
| | | * @noinspection PhpUndefinedMethodInspection |
| | | */ |
| | | public function getList($search) |
| | | { |
| | | $model = $this->alias('apply') |
| | | ->field('apply.*, user.nickName, user.avatarUrl') |
| | | ->with(['referee']) |
| | | ->join('user', 'user.user_id = apply.user_id') |
| | | ->order(['apply.create_time' => 'desc']); |
| | | if (!empty($search['nick_name'])) { |
| | | $model = $model->where('user.nickName|apply.real_name|apply.mobile', 'like', '%' . $search['nick_name'] . '%'); |
| | | } |
| | | |
| | | // 获取列表数据 |
| | | return $model->paginate($search['list_rows']); |
| | | } |
| | | |
| | | /** |
| | | * 股东入驻审核 |
| | | * @param $data |
| | | * @return bool |
| | | */ |
| | | public function submit($data) |
| | | { |
| | | if ($data['apply_status'] == '30' && empty($data['reject_reason'])) { |
| | | $this->error = '请填写驳回原因'; |
| | | return false; |
| | | } |
| | | $this->startTrans(); |
| | | if ($data['apply_status'] == '20') { |
| | | // 新增区域代理用户(参考 Operations::addoperationsUser 方法) |
| | | $operationsModel = new Operations(); |
| | | $result = $operationsModel->addoperationsUser([ |
| | | 'user_id' => $data['user_id'], |
| | | 'real_name' => $data['real_name'], |
| | | 'mobile' => $data['mobile'], |
| | | 'operations_level' => $data['region_level']['value'], |
| | | 'province_id' => $data['province_id'], |
| | | 'city_id' => $data['city_id'], |
| | | 'area_id' => $data['area_id'], |
| | | 'referee_id' => $data['referee_id'], |
| | | 'user_name' => isset($data['user_name']) ? $data['user_name'] : '', |
| | | 'password' => isset($data['password']) ? $data['password'] : '' |
| | | ]); |
| | | if (!$result) { |
| | | $this->error = $operationsModel->error; |
| | | $this->rollback(); |
| | | return false; |
| | | } |
| | | } |
| | | $save_data = [ |
| | | 'audit_time' => time(), |
| | | 'apply_status' => $data['apply_status'], |
| | | 'region_level' => $data['region_level']['value'], |
| | | 'province_id' => $data['province_id'], |
| | | 'city_id' => $data['city_id'], |
| | | 'area_id' => $data['area_id'], |
| | | 'reject_reason' => $data['reject_reason'], |
| | | ]; |
| | | $this->save($save_data); |
| | | // 记录推荐人关系 |
| | | // if ($data['referee_id'] > 0) { |
| | | // RefereeModel::createRelation($data['user_id'], $data['referee_id']); |
| | | // } |
| | | // 发送模板消息 |
| | | // (new MessageService)->region($this); |
| | | $this->commit(); |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 获取申请中的数量 |
| | | */ |
| | | public static function getApplyCount(){ |
| | | return (new static())->where('apply_status', '=', 10)->count(); |
| | | } |
| | | } |