|
@@ -63,49 +63,11 @@ class Agent extends Commission
|
|
|
// 添加代理商类型描述(使用枚举类)
|
|
|
$data['agent_type_text'] = AgentType::getTypeText($data['agent_type']);
|
|
|
|
|
|
- // 如果是区域代理商,添加管辖区域信息
|
|
|
- if (AgentType::isRegionalAgent($data['agent_type'])) {
|
|
|
- $areaInfo = [];
|
|
|
-
|
|
|
- // 获取省份信息
|
|
|
- if (!empty($data['manage_province_id'])) {
|
|
|
- $provinceInfo = \app\common\model\Area::where('id', $data['manage_province_id'])->find();
|
|
|
- if ($provinceInfo) {
|
|
|
- $areaInfo['province_name'] = $provinceInfo['name'];
|
|
|
- $areaInfo['province_id'] = $data['manage_province_id'];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 获取城市信息
|
|
|
- if (!empty($data['manage_city_id'])) {
|
|
|
- $cityInfo = \app\common\model\Area::where('id', $data['manage_city_id'])->find();
|
|
|
- if ($cityInfo) {
|
|
|
- $areaInfo['city_name'] = $cityInfo['name'];
|
|
|
- $areaInfo['city_id'] = $data['manage_city_id'];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 获取区域信息
|
|
|
- if (!empty($data['manage_district_id'])) {
|
|
|
- $districtInfo = \app\common\model\Area::where('id', $data['manage_district_id'])->find();
|
|
|
- if ($districtInfo) {
|
|
|
- $areaInfo['district_name'] = $districtInfo['name'];
|
|
|
- $areaInfo['district_id'] = $data['manage_district_id'];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- $data['manage_area'] = $areaInfo;
|
|
|
-
|
|
|
- // 生成管辖区域描述文本
|
|
|
- $areaText = [];
|
|
|
- if (isset($areaInfo['province_name'])) $areaText[] = $areaInfo['province_name'];
|
|
|
- if (isset($areaInfo['city_name'])) $areaText[] = $areaInfo['city_name'];
|
|
|
- if (isset($areaInfo['district_name'])) $areaText[] = $areaInfo['district_name'];
|
|
|
- $data['manage_area_text'] = implode('-', $areaText);
|
|
|
- } else {
|
|
|
- $data['manage_area'] = null;
|
|
|
- $data['manage_area_text'] = '-';
|
|
|
- }
|
|
|
+ // 构造代理商身份描述和区域信息
|
|
|
+ $identityData = $this->buildAgentIdentityData($data);
|
|
|
+ $data['agent_identity_title'] = $identityData['title'];
|
|
|
+ $data['manage_area'] = $identityData['area_info'];
|
|
|
+ $data['manage_area_text'] = $identityData['area_text'];
|
|
|
|
|
|
// 获取用户基本信息和佣金数据
|
|
|
$user = $this->service->user;
|
|
@@ -129,6 +91,129 @@ class Agent extends Commission
|
|
|
$this->success('分销商信息', $data);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 构造代理商身份数据(包括标题和区域信息)
|
|
|
+ * @param array $agentData 代理商数据
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ private function buildAgentIdentityData($agentData)
|
|
|
+ {
|
|
|
+ $result = [
|
|
|
+ 'title' => '普通代理商',
|
|
|
+ 'area_info' => null,
|
|
|
+ 'area_text' => '-'
|
|
|
+ ];
|
|
|
+
|
|
|
+ switch ($agentData['agent_type']) {
|
|
|
+ case AgentType::NORMAL:
|
|
|
+ $result['title'] = '普通代理商';
|
|
|
+ break;
|
|
|
+
|
|
|
+ case AgentType::PROVINCE:
|
|
|
+ // 省级代理商:山东省代理商
|
|
|
+ if (!empty($agentData['manage_province_id'])) {
|
|
|
+ $provinceInfo = \app\common\model\Area::where('id', $agentData['manage_province_id'])->find();
|
|
|
+ if ($provinceInfo) {
|
|
|
+ $result['title'] = $provinceInfo['name'] . '代理商';
|
|
|
+ $result['area_info'] = [
|
|
|
+ 'province_name' => $provinceInfo['name'],
|
|
|
+ 'province_id' => $agentData['manage_province_id']
|
|
|
+ ];
|
|
|
+ $result['area_text'] = $provinceInfo['name'];
|
|
|
+ } else {
|
|
|
+ $result['title'] = '省级代理商';
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $result['title'] = '省级代理商';
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ case AgentType::CITY:
|
|
|
+ // 市级代理商:临沂市代理商
|
|
|
+ $areaInfo = [];
|
|
|
+ $areaText = [];
|
|
|
+
|
|
|
+ // 获取省份信息
|
|
|
+ if (!empty($agentData['manage_province_id'])) {
|
|
|
+ $provinceInfo = \app\common\model\Area::where('id', $agentData['manage_province_id'])->find();
|
|
|
+ if ($provinceInfo) {
|
|
|
+ $areaInfo['province_name'] = $provinceInfo['name'];
|
|
|
+ $areaInfo['province_id'] = $agentData['manage_province_id'];
|
|
|
+ $areaText[] = $provinceInfo['name'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取城市信息
|
|
|
+ if (!empty($agentData['manage_city_id'])) {
|
|
|
+ $cityInfo = \app\common\model\Area::where('id', $agentData['manage_city_id'])->find();
|
|
|
+ if ($cityInfo) {
|
|
|
+ $result['title'] = $cityInfo['name'] . '代理商';
|
|
|
+ $areaInfo['city_name'] = $cityInfo['name'];
|
|
|
+ $areaInfo['city_id'] = $agentData['manage_city_id'];
|
|
|
+ $areaText[] = $cityInfo['name'];
|
|
|
+ } else {
|
|
|
+ $result['title'] = '市级代理商';
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $result['title'] = '市级代理商';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty($areaInfo)) {
|
|
|
+ $result['area_info'] = $areaInfo;
|
|
|
+ $result['area_text'] = implode('-', $areaText);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ case AgentType::DISTRICT:
|
|
|
+ // 区级代理商:兰山区代理商
|
|
|
+ $areaInfo = [];
|
|
|
+ $areaText = [];
|
|
|
+
|
|
|
+ // 获取省份信息
|
|
|
+ if (!empty($agentData['manage_province_id'])) {
|
|
|
+ $provinceInfo = \app\common\model\Area::where('id', $agentData['manage_province_id'])->find();
|
|
|
+ if ($provinceInfo) {
|
|
|
+ $areaInfo['province_name'] = $provinceInfo['name'];
|
|
|
+ $areaInfo['province_id'] = $agentData['manage_province_id'];
|
|
|
+ $areaText[] = $provinceInfo['name'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取城市信息
|
|
|
+ if (!empty($agentData['manage_city_id'])) {
|
|
|
+ $cityInfo = \app\common\model\Area::where('id', $agentData['manage_city_id'])->find();
|
|
|
+ if ($cityInfo) {
|
|
|
+ $areaInfo['city_name'] = $cityInfo['name'];
|
|
|
+ $areaInfo['city_id'] = $agentData['manage_city_id'];
|
|
|
+ $areaText[] = $cityInfo['name'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取区域信息
|
|
|
+ if (!empty($agentData['manage_district_id'])) {
|
|
|
+ $districtInfo = \app\common\model\Area::where('id', $agentData['manage_district_id'])->find();
|
|
|
+ if ($districtInfo) {
|
|
|
+ $result['title'] = $districtInfo['name'] . '代理商';
|
|
|
+ $areaInfo['district_name'] = $districtInfo['name'];
|
|
|
+ $areaInfo['district_id'] = $agentData['manage_district_id'];
|
|
|
+ $areaText[] = $districtInfo['name'];
|
|
|
+ } else {
|
|
|
+ $result['title'] = '区域代理商';
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $result['title'] = '区域代理商';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty($areaInfo)) {
|
|
|
+ $result['area_info'] = $areaInfo;
|
|
|
+ $result['area_text'] = implode('-', $areaText);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
// 我的团队
|
|
|
public function team()
|