添加:代理添加总部相关内容
This commit is contained in:
parent
803aa1d6d5
commit
b8d249237d
|
|
@ -138,7 +138,8 @@ class AgentRepository extends BaseRepository{
|
||||||
"address",
|
"address",
|
||||||
"lat",
|
"lat",
|
||||||
"lng",
|
"lng",
|
||||||
"mer_id"
|
"mer_id",
|
||||||
|
'is_headquarters'
|
||||||
]);
|
]);
|
||||||
$updateInfo = array_intersect_key($data, $keys);
|
$updateInfo = array_intersect_key($data, $keys);
|
||||||
Agent::update($updateInfo,['id'=>$agentId]);
|
Agent::update($updateInfo,['id'=>$agentId]);
|
||||||
|
|
@ -178,7 +179,8 @@ class AgentRepository extends BaseRepository{
|
||||||
"address",
|
"address",
|
||||||
"lat",
|
"lat",
|
||||||
"lng",
|
"lng",
|
||||||
"mer_id"
|
"mer_id",
|
||||||
|
'is_headquarters'
|
||||||
]);
|
]);
|
||||||
// 循环:区分对应的操作
|
// 循环:区分对应的操作
|
||||||
foreach($childrenList as $childrenItem){
|
foreach($childrenList as $childrenItem){
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ class Agent extends BaseController{
|
||||||
'lng',
|
'lng',
|
||||||
['mer_id', 0],
|
['mer_id', 0],
|
||||||
['mer_id_list', []],
|
['mer_id_list', []],
|
||||||
|
['is_headquarters', 0]
|
||||||
]);
|
]);
|
||||||
$agentId = (int)$this->request->param('id');
|
$agentId = (int)$this->request->param('id');
|
||||||
$childrenList = $this->request->param('children_list');
|
$childrenList = $this->request->param('children_list');
|
||||||
|
|
@ -86,21 +87,21 @@ class Agent extends BaseController{
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
case 4:
|
case 4:
|
||||||
if((float)$childrenItem['province_id'] <= 0) throw new ValidateException('请完善地区信息!');
|
if((float)$childrenItem['province_id'] <= 0 && $childrenItem['is_headquarters'] == 0) throw new ValidateException('请完善地区信息!');
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
case 6:
|
case 6:
|
||||||
if((float)$childrenItem['province_id'] <= 0) throw new ValidateException('请完善地区信息!');
|
if((float)$childrenItem['province_id'] <= 0 && $childrenItem['is_headquarters'] == 0) throw new ValidateException('请完善地区信息!');
|
||||||
if((float)$childrenItem['city_id'] <= 0) throw new ValidateException('请完善地区信息!');
|
if((float)$childrenItem['city_id'] <= 0 && $childrenItem['is_headquarters'] == 0) throw new ValidateException('请完善地区信息!');
|
||||||
if((float)$childrenItem['area_id'] <= 0) throw new ValidateException('请完善地区信息!');
|
if((float)$childrenItem['area_id'] <= 0 && $childrenItem['is_headquarters'] == 0) throw new ValidateException('请完善地区信息!');
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
if((float)$childrenItem['province_id'] <= 0) throw new ValidateException('请完善地区信息!');
|
if((float)$childrenItem['province_id'] <= 0 && $childrenItem['is_headquarters'] == 0) throw new ValidateException('请完善地区信息!');
|
||||||
if((float)$childrenItem['city_id'] <= 0) throw new ValidateException('请完善地区信息!');
|
if((float)$childrenItem['city_id'] <= 0 && $childrenItem['is_headquarters'] == 0) throw new ValidateException('请完善地区信息!');
|
||||||
if((float)$childrenItem['area_id'] <= 0) throw new ValidateException('请完善地区信息!');
|
if((float)$childrenItem['area_id'] <= 0 && $childrenItem['is_headquarters'] == 0) throw new ValidateException('请完善地区信息!');
|
||||||
if((float)$childrenItem['street_id'] <= 0) throw new ValidateException('请完善地区信息!');
|
if((float)$childrenItem['street_id'] <= 0 && $childrenItem['is_headquarters'] == 0) throw new ValidateException('请完善地区信息!');
|
||||||
if(empty($childrenItem['address'])) throw new ValidateException('请完善地区信息!');
|
if(empty($childrenItem['address']) && $childrenItem['is_headquarters'] == 0) throw new ValidateException('请完善地区信息!');
|
||||||
if((float)$childrenItem['lat'] <= 0 || (float)$childrenItem['lng'] <= 0) throw new ValidateException('请选择定位信息!');
|
if(((float)$childrenItem['lat'] <= 0 || (float)$childrenItem['lng'] <= 0) && $childrenItem['is_headquarters'] == 0) throw new ValidateException('请选择定位信息!');
|
||||||
if((float)$childrenItem['mer_id'] <= 0) throw new ValidateException('餐厅必须关联商户!');
|
if((float)$childrenItem['mer_id'] <= 0) throw new ValidateException('餐厅必须关联商户!');
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
|
|
@ -147,21 +148,21 @@ class Agent extends BaseController{
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
case 4:
|
case 4:
|
||||||
if((float)$data['province_id'] <= 0) throw new ValidateException('请完善地区信息!');
|
if((float)$data['province_id'] <= 0 && $data['is_headquarters'] == 0) throw new ValidateException('请完善地区信息!');
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
case 6:
|
case 6:
|
||||||
if((float)$data['province_id'] <= 0) throw new ValidateException('请完善地区信息!');
|
if((float)$data['province_id'] <= 0 && $data['is_headquarters'] == 0) throw new ValidateException('请完善地区信息!');
|
||||||
if((float)$data['city_id'] <= 0) throw new ValidateException('请完善地区信息!');
|
if((float)$data['city_id'] <= 0 && $data['is_headquarters'] == 0) throw new ValidateException('请完善地区信息!');
|
||||||
if((float)$data['area_id'] <= 0) throw new ValidateException('请完善地区信息!');
|
if((float)$data['area_id'] <= 0 && $data['is_headquarters'] == 0) throw new ValidateException('请完善地区信息!');
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
if((float)$data['province_id'] <= 0) throw new ValidateException('请完善地区信息!');
|
if((float)$data['province_id'] <= 0 && $data['is_headquarters'] == 0) throw new ValidateException('请完善地区信息!');
|
||||||
if((float)$data['city_id'] <= 0) throw new ValidateException('请完善地区信息!');
|
if((float)$data['city_id'] <= 0 && $data['is_headquarters'] == 0) throw new ValidateException('请完善地区信息!');
|
||||||
if((float)$data['area_id'] <= 0) throw new ValidateException('请完善地区信息!');
|
if((float)$data['area_id'] <= 0 && $data['is_headquarters'] == 0) throw new ValidateException('请完善地区信息!');
|
||||||
if((float)$data['street_id'] <= 0) throw new ValidateException('请完善地区信息!');
|
if((float)$data['street_id'] <= 0 && $data['is_headquarters'] == 0) throw new ValidateException('请完善地区信息!');
|
||||||
if(empty($data['address'])) throw new ValidateException('请完善地区信息!');
|
if(empty($data['address']) && $data['is_headquarters'] == 0) throw new ValidateException('请完善地区信息!');
|
||||||
if((float)$data['lat'] <= 0 || (float)$data['lng'] <= 0) throw new ValidateException('请选择定位信息!');
|
if(((float)$data['lat'] <= 0 || (float)$data['lng'] <= 0) && $data['is_headquarters'] == 0) throw new ValidateException('请选择定位信息!');
|
||||||
if((float)$data['mer_id'] <= 0) throw new ValidateException('餐厅必须关联商户!');
|
if((float)$data['mer_id'] <= 0) throw new ValidateException('餐厅必须关联商户!');
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
|
|
|
||||||
|
|
@ -147,14 +147,18 @@ class Merchant extends BaseController
|
||||||
return app('json')->fail('商户名已存在');
|
return app('json')->fail('商户名已存在');
|
||||||
if ($data['mer_phone'] && isPhone($data['mer_phone']))
|
if ($data['mer_phone'] && isPhone($data['mer_phone']))
|
||||||
return app('json')->fail('请输入正确的手机号');
|
return app('json')->fail('请输入正确的手机号');
|
||||||
if (!$data['category_id'] || !$merchantCategoryRepository->exists($data['category_id']))
|
if ((!$data['category_id'] || !$merchantCategoryRepository->exists($data['category_id'])) && $data['merchant_type'] == 0)
|
||||||
return app('json')->fail('商户分类不存在');
|
return app('json')->fail('商户分类不存在');
|
||||||
|
|
||||||
unset($data['mer_account'], $data['mer_password']);
|
unset($data['mer_account'], $data['mer_password']);
|
||||||
$margin = $this->repository->checkMargin($id, $data['type_id']);
|
$typeId = $data['type_id'] ?? 0;
|
||||||
$data['margin'] = $margin['margin'];
|
if($typeId > 0){
|
||||||
$data['is_margin'] = $margin['is_margin'];
|
$margin = $this->repository->checkMargin($id, $data['type_id']);
|
||||||
$data['ot_margin'] = $margin['ot_margin'];
|
$data['margin'] = $margin['margin'] ?? 0;
|
||||||
|
$data['is_margin'] = $margin['is_margin'] ?? 0;
|
||||||
|
$data['ot_margin'] = $margin['ot_margin'] ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
$this->repository->update($id, $data);
|
$this->repository->update($id, $data);
|
||||||
return app('json')->success('编辑成功');
|
return app('json')->success('编辑成功');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@ class MerchantValidate extends Validate
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $rule = [
|
protected $rule = [
|
||||||
'category_id|商户分类' => 'require',
|
// 'category_id|商户分类' => 'require',
|
||||||
'type_id|店铺类型' => 'integer',
|
// 'type_id|店铺类型' => 'integer',
|
||||||
'mer_name|商户名称' => 'require|max:32',
|
'mer_name|商户名称' => 'require|max:32',
|
||||||
'mer_account|商户账号' => 'require|alphaNum|min:4|max:16',
|
'mer_account|商户账号' => 'require|alphaNum|min:4|max:16',
|
||||||
'mer_password|商户密码' => 'require|min:4|max:16',
|
'mer_password|商户密码' => 'require|min:4|max:16',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue