|
|
@ -16,6 +16,7 @@ namespace app\common\repositories\system\admin; |
|
|
|
|
|
|
|
|
|
|
|
//附件 |
|
|
|
//附件 |
|
|
|
use app\common\dao\system\admin\PartnerDao; |
|
|
|
use app\common\dao\system\admin\PartnerDao; |
|
|
|
|
|
|
|
use app\common\model\store\CityArea; |
|
|
|
use app\common\model\system\admin\Partner; |
|
|
|
use app\common\model\system\admin\Partner; |
|
|
|
use app\common\repositories\BaseRepository; |
|
|
|
use app\common\repositories\BaseRepository; |
|
|
|
use app\common\model\user\UserPartner; |
|
|
|
use app\common\model\user\UserPartner; |
|
|
@ -76,7 +77,7 @@ class PartnerRepository extends BaseRepository |
|
|
|
//生成角色 |
|
|
|
//生成角色 |
|
|
|
$info = $this->dao->create($data); |
|
|
|
$info = $this->dao->create($data); |
|
|
|
$userPartner = []; |
|
|
|
$userPartner = []; |
|
|
|
for ($i = 1;$i <= $data['max_role_num']; $i++ ) { |
|
|
|
for ($i = 1; $i <= $data['max_role_num']; $i++) { |
|
|
|
$name = $i == 1 ? $data['name'] : $data['name'] . '_' . $i; |
|
|
|
$name = $i == 1 ? $data['name'] : $data['name'] . '_' . $i; |
|
|
|
$userPartner[] = [ |
|
|
|
$userPartner[] = [ |
|
|
|
'partner_name' => $name, |
|
|
|
'partner_name' => $name, |
|
|
@ -101,7 +102,46 @@ class PartnerRepository extends BaseRepository |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function getDetail(int $id) |
|
|
|
public function getDetail(int $id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return $this->dao->get($id)->toArray(); |
|
|
|
try { |
|
|
|
|
|
|
|
$data = $this->dao->get($id)->toArray(); |
|
|
|
|
|
|
|
$data['province_id'] = ''; |
|
|
|
|
|
|
|
$data['province_name'] = ''; |
|
|
|
|
|
|
|
$data['city_id'] = ''; |
|
|
|
|
|
|
|
$data['city_name'] = ''; |
|
|
|
|
|
|
|
$data['district_id'] = ''; |
|
|
|
|
|
|
|
$data['district_name'] = ''; |
|
|
|
|
|
|
|
if ($data['is_area'] == 1 && $data['area_id'] > 0) { |
|
|
|
|
|
|
|
$area_data = CityArea::getDB()->where('id', $data['area_id'])->find()->toArray(); |
|
|
|
|
|
|
|
$ids = explode("/", $area_data['path']); |
|
|
|
|
|
|
|
if ($area_data['level'] == 1) { |
|
|
|
|
|
|
|
$data['province_id'] = $data['area_id']; |
|
|
|
|
|
|
|
$name_data = CityArea::getDB()->where('id', $data['province_id'])->find()->toArray(); |
|
|
|
|
|
|
|
$data['province_name'] = $name_data['name']; |
|
|
|
|
|
|
|
} elseif ($area_data['level'] == 2) { |
|
|
|
|
|
|
|
$data['province_id'] = $ids[1]; |
|
|
|
|
|
|
|
$name_data = CityArea::getDB()->where('id', $data['province_id'])->find()->toArray(); |
|
|
|
|
|
|
|
$data['province_name'] = $name_data['name']; |
|
|
|
|
|
|
|
$data['city_id'] = $data['area_id']; |
|
|
|
|
|
|
|
$name_data1 = CityArea::getDB()->where('id', $data['city_id'])->find()->toArray(); |
|
|
|
|
|
|
|
$data['city_name'] = $name_data1['name']; |
|
|
|
|
|
|
|
} elseif ($area_data['level'] == 3) { |
|
|
|
|
|
|
|
$data['province_id'] = $ids[1]; |
|
|
|
|
|
|
|
$name_data = CityArea::getDB()->where('id', $data['province_id'])->find()->toArray(); |
|
|
|
|
|
|
|
$data['province_name'] = $name_data['name']; |
|
|
|
|
|
|
|
$data['city_id'] = $ids[2]; |
|
|
|
|
|
|
|
$name_data1 = CityArea::getDB()->where('id', $data['city_id'])->find()->toArray(); |
|
|
|
|
|
|
|
$data['city_name'] = $name_data1['name']; |
|
|
|
|
|
|
|
$data['district_id'] = $data['area_id']; |
|
|
|
|
|
|
|
$name_data2 = CityArea::getDB()->where('id', $data['district_id'])->find()->toArray(); |
|
|
|
|
|
|
|
$data['district_name'] = $name_data2['name']; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $data; |
|
|
|
|
|
|
|
} catch (\Exception $e) { |
|
|
|
|
|
|
|
print_r($e->getFile() . '-' . $e->getLine() . "-" . $e->getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -118,10 +158,10 @@ class PartnerRepository extends BaseRepository |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
$old = $this->dao->get($id)->toArray(); |
|
|
|
$old = $this->dao->get($id)->toArray(); |
|
|
|
if($old['name'] != $data['name']){ |
|
|
|
if ($old['name'] != $data['name']) { |
|
|
|
$list = UserPartner::getDB()->where('partner_id',$id)->select(); |
|
|
|
$list = UserPartner::getDB()->where('partner_id', $id)->select(); |
|
|
|
foreach($list as $k=>$v){ |
|
|
|
foreach ($list as $k => $v) { |
|
|
|
$name = str_replace($old['name'],$data['name'],$v['partner_name']); |
|
|
|
$name = str_replace($old['name'], $data['name'], $v['partner_name']); |
|
|
|
UserPartner::getDB()->where('id', $v['id'])->update(['partner_name' => $name]); |
|
|
|
UserPartner::getDB()->where('id', $v['id'])->update(['partner_name' => $name]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -144,7 +184,7 @@ class PartnerRepository extends BaseRepository |
|
|
|
|
|
|
|
|
|
|
|
public function roleExists(int $id) |
|
|
|
public function roleExists(int $id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return UserPartner::getDB()->where('id', '=', $id)->where('uid','=','')->find(); |
|
|
|
return UserPartner::getDB()->where('id', '=', $id)->where('uid', '=', '')->find(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|