新增银行卡验证、修正省市区验证
This commit is contained in:
@@ -18,7 +18,7 @@ class AreaService extends BaseService
|
||||
// 检测省份
|
||||
if (!empty($province_id)){
|
||||
$province = $this->getAreaByAreaId($province_id);
|
||||
if (empty($province['data'])){
|
||||
if (empty($province)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ class AreaService extends BaseService
|
||||
// 检测城市
|
||||
if (!empty($city_id) && !empty($province_id)){
|
||||
$city = $this->getAreaByAreaId($city_id,$province_id);
|
||||
if (empty($city['data'])){
|
||||
if (empty($city)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -34,18 +34,64 @@ class AreaService extends BaseService
|
||||
// 检测区县
|
||||
if (!empty($county_id) && !empty($city_id)){
|
||||
$county = $this->getAreaByAreaId($county_id,$city_id);
|
||||
if (empty($county['data'])){
|
||||
if (empty($county)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($province['data']) || !empty($city['data']) || !empty($county['data'])){
|
||||
if (!empty($province) || !empty($city) || !empty($county)){
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取省市区数据
|
||||
* @param string $province_id
|
||||
* @param string $city_id
|
||||
* @param string $county_id
|
||||
* @return array
|
||||
*/
|
||||
public function getAreaById(string $province_id, string $city_id, string $county_id): array
|
||||
{
|
||||
// 省份
|
||||
if (!empty($province_id)){
|
||||
$province = $this->getAreaByAreaId($province_id);
|
||||
if (empty($province)){
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
// 城市
|
||||
if (!empty($city_id) && !empty($province_id)){
|
||||
$city = $this->getAreaByAreaId($city_id,$province_id);
|
||||
if (empty($city)){
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
// 检测区县
|
||||
if (!empty($county_id) && !empty($city_id)){
|
||||
$county = $this->getAreaByAreaId($county_id,$city_id);
|
||||
if (empty($county)){
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($province) || !empty($city) || !empty($county)){
|
||||
$result = array();
|
||||
$result['province'] = $province;
|
||||
$result['city'] = $city;
|
||||
$result['county'] = $county;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
return [];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取省份列表
|
||||
* @return array
|
||||
@@ -95,7 +141,7 @@ class AreaService extends BaseService
|
||||
}
|
||||
$area = AreaModel::getOne($params);
|
||||
|
||||
return empty($area) ? success() : success($area->toArray());
|
||||
return empty($area) ? [] : $area->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,6 +155,6 @@ class AreaService extends BaseService
|
||||
$params['parent_id'] = $parent_id;
|
||||
$area = AreaModel::getList($params);
|
||||
|
||||
return empty($area) ? success() : success($area->toArray());
|
||||
return empty($area) ? [] : $area->toArray();
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ class PatientFamilyService extends BaseService
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增家庭成员
|
||||
* 新增家庭成员-cuowu
|
||||
* @return array
|
||||
*/
|
||||
public function addFamily(): array
|
||||
|
||||
@@ -4,10 +4,15 @@ namespace App\Services;
|
||||
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Exception\BusinessException;
|
||||
use App\Model\BasicBank;
|
||||
use App\Model\DiseaseClassExpertise;
|
||||
use App\Model\DoctorBankCard;
|
||||
use App\Model\DoctorExpertise;
|
||||
use App\Model\OrderInquiry;
|
||||
use App\Model\UserDoctor;
|
||||
use App\Model\UserDoctorInfo;
|
||||
use App\Utils\Mask;
|
||||
use Hyperf\DbConnection\Db;
|
||||
|
||||
class UserDoctorService extends BaseService
|
||||
{
|
||||
@@ -25,8 +30,8 @@ class UserDoctorService extends BaseService
|
||||
|
||||
$expertise_ids = [];
|
||||
|
||||
if (!empty($doctor_selected_expertise)){
|
||||
$expertise_ids = array_column($doctor_selected_expertise,'expertise_id');
|
||||
if (!empty($doctor_selected_expertise)) {
|
||||
$expertise_ids = array_column($doctor_selected_expertise, 'expertise_id');
|
||||
}
|
||||
|
||||
// 获取全部专长
|
||||
@@ -35,11 +40,11 @@ class UserDoctorService extends BaseService
|
||||
'expertise_name',
|
||||
'expertise_sort',
|
||||
];
|
||||
$disease_class_expertise = DiseaseClassExpertise::getOrderList([],$fields);
|
||||
$disease_class_expertise = DiseaseClassExpertise::getOrderList([], $fields);
|
||||
|
||||
foreach ($disease_class_expertise as &$item){
|
||||
foreach ($disease_class_expertise as &$item) {
|
||||
$item['is_selected'] = 0;
|
||||
if (in_array($item['expertise_id'],$expertise_ids)){
|
||||
if (in_array($item['expertise_id'], $expertise_ids)) {
|
||||
$item['is_selected'] = 1;
|
||||
}
|
||||
}
|
||||
@@ -55,16 +60,16 @@ class UserDoctorService extends BaseService
|
||||
*/
|
||||
public function getDoctorSelectedExpertise(string $doctor_id): array
|
||||
{
|
||||
if (empty($doctor_id)){
|
||||
if (empty($doctor_id)) {
|
||||
throw new BusinessException("缺少医生id");
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $doctor_id;
|
||||
$doctor_expertise = DoctorExpertise::getDiseaseClassExpertiseList($params);
|
||||
if (!empty($doctor_expertise)){
|
||||
foreach ($doctor_expertise as &$data){
|
||||
if (!empty($data['DiseaseClassExpertise'])){
|
||||
if (!empty($doctor_expertise)) {
|
||||
foreach ($doctor_expertise as &$data) {
|
||||
if (!empty($data['DiseaseClassExpertise'])) {
|
||||
$data['expertise_name'] = $data['DiseaseClassExpertise']['expertise_name'];
|
||||
}
|
||||
unset($data['DiseaseClassExpertise']);
|
||||
@@ -74,12 +79,256 @@ class UserDoctorService extends BaseService
|
||||
return $doctor_expertise->toArray();
|
||||
}
|
||||
|
||||
// 获取医生银行卡
|
||||
public function getDoctorBankCard(){
|
||||
/**
|
||||
* 获取医生银行卡
|
||||
* @return array
|
||||
*/
|
||||
public function getDoctorBankCard(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
// $doctor_bank_card =
|
||||
$doctor_bank_card = DoctorBankCard::getWithBankOne($params);
|
||||
if (empty($doctor_bank_card)) {
|
||||
return success();
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$data['bank_card_id'] = $doctor_bank_card['bank_card_id'];
|
||||
$data['bank_img_path'] = $doctor_bank_card['BasicBank']['bank_img_path'];
|
||||
$data['bank_name'] = $doctor_bank_card['BasicBank']['bank_name'];
|
||||
$data['bank_card_code_mask'] = $doctor_bank_card['bank_card_code_mask'];
|
||||
|
||||
unset($doctor_bank_card);
|
||||
|
||||
return success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医生银行卡详情信息
|
||||
* @return array
|
||||
*/
|
||||
public function getDoctorBankCardInfo(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$bank_card_id = $this->request->input('bank_card_id');// 医生银行卡id
|
||||
|
||||
// 获取医生详情数据
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
|
||||
$fields = [
|
||||
'doctor_info_id',
|
||||
'doctor_id',
|
||||
'card_name',
|
||||
'card_num_mask',
|
||||
];
|
||||
$user_doctor_info = UserDoctorInfo::getOne($params, $fields);
|
||||
if (empty($user_doctor_info)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请先实名认证");
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$result['info'] = array();
|
||||
$result['bank'] = array();
|
||||
|
||||
$info = array();
|
||||
$info['card_name'] = $user_doctor_info['card_name'];
|
||||
$info['card_num_mask'] = $user_doctor_info['card_num_mask'];
|
||||
|
||||
if (!empty($bank_card_id)) {
|
||||
// 获取添加的银行卡信息
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$params['bank_card_id'] = $bank_card_id;
|
||||
$doctor_bank_card = DoctorBankCard::getWithBankOne($params);
|
||||
if (empty($doctor_bank_card)) {
|
||||
return fail();
|
||||
}
|
||||
|
||||
$bank = array();
|
||||
$bank['bank_card_id'] = $doctor_bank_card['bank_card_id'];
|
||||
$bank['bank_id'] = $doctor_bank_card['bank_id'];
|
||||
$bank['bank_name'] = $doctor_bank_card['BasicBank']['bank_name'];
|
||||
$bank['bank_card_code'] = $doctor_bank_card['bank_card_code'];// 银行卡号
|
||||
$bank['province_id'] = $doctor_bank_card['province_id'];
|
||||
$bank['province'] = $doctor_bank_card['province'];
|
||||
$bank['city_id'] = $doctor_bank_card['city_id'];
|
||||
$bank['city'] = $doctor_bank_card['city'];
|
||||
$bank['county_id'] = $doctor_bank_card['county_id'];
|
||||
$bank['county'] = $doctor_bank_card['county'];
|
||||
}
|
||||
|
||||
$result['info'] = $info;// 用户数据
|
||||
$result['bank'] = $bank ?? [];// 银行卡数据
|
||||
return success($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增绑定医生银行卡
|
||||
* @return array
|
||||
*/
|
||||
public function addDoctorBankCard(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$bank_id = $this->request->input('bank_id');
|
||||
$bank_card_code = $this->request->input('bank_card_code');
|
||||
$province_id = $this->request->input('province_id');
|
||||
$city_id = $this->request->input('city_id');
|
||||
$county_id = $this->request->input('county_id');
|
||||
|
||||
// 验证银行
|
||||
$params = array();
|
||||
$params['bank_id'] = $bank_id;
|
||||
$basic_bank = BasicBank::getOne($params);
|
||||
if (empty($basic_bank)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "开户行错误");
|
||||
}
|
||||
|
||||
// 验证省市区
|
||||
$areaService = new AreaService();
|
||||
$area = $areaService->getAreaById($province_id, $city_id, $county_id);
|
||||
if (empty($area)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "地区选择错误");
|
||||
}
|
||||
|
||||
// 获取医生银行卡
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$doctor_bank_card = DoctorBankCard::getOne($params);
|
||||
if (!empty($doctor_bank_card)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "已绑定银行卡");
|
||||
}
|
||||
|
||||
// 获取医生信息
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
|
||||
$fields = [
|
||||
'doctor_id',
|
||||
'is_bind_bank',
|
||||
];
|
||||
$user_doctor = UserDoctor::getOne($params, $fields);
|
||||
if (empty($user_doctor)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "非法医生");
|
||||
}
|
||||
|
||||
if ($user_doctor['is_bind_bank'] == 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "已绑定银行卡");
|
||||
}
|
||||
|
||||
// 处理银行卡掩码
|
||||
$bank_card_code_mask = Mask::maskBankCard($bank_card_code);
|
||||
|
||||
// 验证银行卡
|
||||
|
||||
Db::beginTransaction();
|
||||
|
||||
try {
|
||||
// 新增医生银行卡
|
||||
$data = array();
|
||||
$data['doctor_id'] = $user_info['client_user_id'];
|
||||
$data['bank_id'] = $bank_id;
|
||||
$data['bank_card_code'] = $bank_card_code;
|
||||
$data['bank_card_code_mask'] = $bank_card_code_mask;
|
||||
$data['province_id'] = $province_id;
|
||||
$data['province'] = $area['province']['area_name'];
|
||||
$data['city_id'] = $city_id;
|
||||
$data['city'] = $area['city']['area_name'];
|
||||
$data['county_id'] = $county_id;
|
||||
$data['county'] = $area['county']['area_name'];
|
||||
$doctor_bank_card = DoctorBankCard::addDoctorBankCard($data);
|
||||
if (empty($doctor_bank_card)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
|
||||
// 修改医生表绑定银行卡状态
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
|
||||
$data = array();
|
||||
$data['is_bind_bank'] = 1;
|
||||
UserDoctor::editUserDoctor($params, $data);
|
||||
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR, $e->getMessage());
|
||||
}
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
public function putDoctorBankCard()
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$bank_card_id = $this->request->route('bank_card_id');
|
||||
$bank_id = $this->request->input('bank_id');
|
||||
$bank_card_code = $this->request->input('bank_card_code');
|
||||
$province_id = $this->request->input('province_id');
|
||||
$city_id = $this->request->input('city_id');
|
||||
$county_id = $this->request->input('county_id');
|
||||
|
||||
// 获取医生银行卡
|
||||
$params = array();
|
||||
$params['bank_card_id'] = $bank_card_id;
|
||||
$doctor_bank_card = DoctorBankCard::getOne($params);
|
||||
if (empty($doctor_bank_card)) {
|
||||
return fail();
|
||||
}
|
||||
|
||||
// 检测上次修改时间
|
||||
$updated_at = strtotime($doctor_bank_card['updated_at']);
|
||||
$moonth_start = strtotime(date("Y-m-01")); // 当月开始时间
|
||||
$moonth_end = strtotime(date("Y-m-t")); // 当月结束时间
|
||||
|
||||
if ($updated_at >= $moonth_start && $updated_at <= $moonth_end) {
|
||||
// 银行卡一月只能修改一次
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "银行卡每月只能修改一次");
|
||||
}
|
||||
|
||||
// 验证银行
|
||||
$params = array();
|
||||
$params['bank_id'] = $bank_id;
|
||||
$basic_bank = BasicBank::getOne($params);
|
||||
if (empty($basic_bank)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "开户行错误");
|
||||
}
|
||||
|
||||
// 验证省市区
|
||||
$areaService = new AreaService();
|
||||
$area = $areaService->getAreaById($province_id, $city_id, $county_id);
|
||||
if (empty($area)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "地区选择错误");
|
||||
}
|
||||
|
||||
// 处理银行卡掩码
|
||||
$bank_card_code_mask = Mask::maskBankCard($bank_card_code);;
|
||||
|
||||
// 验证银行卡
|
||||
|
||||
// 修改银行卡
|
||||
$params = array();
|
||||
$params['bank_card_id'] = $bank_card_id;
|
||||
|
||||
$data = array();
|
||||
$data['bank_id'] = $bank_id;
|
||||
$data['bank_card_code'] = $bank_card_code;
|
||||
$data['bank_card_code_mask'] = $bank_card_code_mask;
|
||||
$data['province_id'] = $province_id;
|
||||
$data['province'] = $area['province']['area_name'];
|
||||
$data['city_id'] = $city_id;
|
||||
$data['city'] = $area['city']['area_name'];
|
||||
$data['county_id'] = $county_id;
|
||||
$data['county'] = $area['county']['area_name'];
|
||||
$data['updated_at'] = date('Y-m-d H:i:s',time());
|
||||
DoctorBankCard::editDoctorBankCard($params,$data);
|
||||
|
||||
return success();
|
||||
}
|
||||
}
|
||||
@@ -3,16 +3,7 @@
|
||||
namespace App\Services;
|
||||
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Exception\BusinessException;
|
||||
use App\Model\User as UserModel;
|
||||
use App\Model\UserDoctor as UserDoctorModel;
|
||||
use App\Model\UserPatient as UserPatientModel;
|
||||
use App\Model\UserPharmacist as UserPharmacistModel;
|
||||
use App\Utils\Http;
|
||||
use App\Utils\Jwt;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use App\Model\UserDoctorInfo;
|
||||
|
||||
class UserService extends BaseService
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user