44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace app\services;
|
|
|
|
class WorkerVendorService extends BaseService
|
|
{
|
|
/**
|
|
* 通过 openid 获取账户
|
|
* @param string $openid
|
|
*/
|
|
public function getVendorByOpenid(string $openid)
|
|
{
|
|
return $this->getWorkerVendorModel()->where(['openid' => $openid])->find();
|
|
}
|
|
|
|
/**
|
|
* 创建微信小程序账户
|
|
* @param string $openid
|
|
*/
|
|
public function createWechatMpVendor(string $openid)
|
|
{
|
|
$vendor = $this->getWorkerVendorModel();
|
|
$vendor->vendor = 'wechat';
|
|
$vendor->platform = 'WechatMp';
|
|
$vendor->unionid = '';
|
|
$vendor->openid = $openid;
|
|
$vendor->worker_id = 0;
|
|
$vendor->create_time = datetime(time());
|
|
$vendor->save();
|
|
|
|
return $vendor->id;
|
|
}
|
|
|
|
/**
|
|
* 通过师傅id和平台查询师傅账号表信息
|
|
* @param int $workerId
|
|
* @param string $platform
|
|
*/
|
|
public function getByWorkerIdAndPlatform(int $workerId, string $platform)
|
|
{
|
|
return $this->getWorkerVendorModel()->where(['worker_id' => $workerId, 'platform' => $platform])->find();
|
|
}
|
|
}
|