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.
67 lines
1.5 KiB
67 lines
1.5 KiB
<?php
|
|
|
|
namespace app\api\model\wholesaler;
|
|
|
|
use app\api\service\User as UserService;
|
|
use app\common\enum\WholesalerEnum;
|
|
use cores\exception\BaseException;
|
|
|
|
class Apply extends \app\common\model\wholesaler\Apply
|
|
{
|
|
/**
|
|
* 隐藏字段
|
|
* @var array
|
|
*/
|
|
protected $hidden = [
|
|
'create_time',
|
|
'update_time',
|
|
'store_id',
|
|
'id',
|
|
'order_id',
|
|
'year'
|
|
];
|
|
|
|
/**
|
|
* @notes:创建订单
|
|
* @param array $data
|
|
* @return bool
|
|
* @author: wanghousheng
|
|
*/
|
|
public function add(array $data): bool
|
|
{
|
|
return $this->save($data);
|
|
}
|
|
|
|
/**
|
|
* @notes:详情
|
|
* @throws BaseException
|
|
* @author: wanghousheng
|
|
*/
|
|
public static function info($with = [])
|
|
{
|
|
$userId = UserService::getCurrentLoginUserId();
|
|
return self::detail(['user_id' => $userId], $with);
|
|
}
|
|
|
|
/**
|
|
* @notes:更新记录
|
|
* @param array $data
|
|
* @return bool
|
|
* @throws BaseException
|
|
* @author: wanghousheng
|
|
*/
|
|
public function edit(array $data): bool
|
|
{
|
|
$info = self::info();
|
|
empty($info) && throwError('申请记录不存在');
|
|
$info = $info->toArray();
|
|
if ($info['status'] == WholesalerEnum::ADOPT) {
|
|
throwError('申请已通过无法编辑');
|
|
}
|
|
$userId = UserService::getCurrentLoginUserId();
|
|
if ($this->where(['user_id' => $userId])->update($data)) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
} |