<?php
|
|
namespace app\operations\model\plus\release;
|
|
use app\common\model\plus\release\SupplyApply as ApplyModel;
|
use app\common\model\plus\release\SupplyUser as User;
|
/**
|
* 入驻申请模型
|
*/
|
class SupplyApply extends ApplyModel
|
{
|
/**
|
* 获取申请列表
|
* @noinspection PhpUndefinedMethodInspection
|
*/
|
public function getList($search)
|
{
|
$model = $this->alias('apply')
|
->field('apply.*, user.nickName, user.avatarUrl')
|
->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') {
|
// 新增
|
User::add($data['user_id'], [
|
'real_name' => $data['real_name'],
|
'mobile' => $data['mobile'],
|
//'province_id' => trim($data['province_id']),
|
// 'city_id' => trim($data['city_id']),
|
// 'region_id' => trim($data['region_id']),
|
// 'location_address' => $data['location_address'],
|
//'longitude' => $data['longitude'],
|
// 'latitude' => $data['latitude'],
|
// 'detail' => $data['detail'],
|
]);
|
}
|
$save_data = [
|
'audit_time' => time(),
|
'apply_status' => $data['apply_status'],
|
'reject_reason' => $data['reject_reason'],
|
];
|
$this->save($save_data);
|
$this->commit();
|
return true;
|
}
|
|
/**
|
* 获取申请中的数量
|
*/
|
public static function getApplyCount()
|
{
|
return (new static())->where('apply_status', '=', 10)->count();
|
}
|
/**
|
* 编辑
|
* @param $data
|
* @return bool
|
*/
|
public function edit($data)
|
{
|
return $this->save($data) !== false;
|
}
|
}
|