作者 lyh

gx

... ... @@ -30,9 +30,6 @@ class WebSettingReceivingController extends BaseController
*/
public function save(WebSettingReceivingLogic $webSettingReceivingLogic){
$result = $webSettingReceivingLogic->setting_receiving_save();
if(!empty($result)){
$this->response('不符合规则的号码及邮箱:'.json_encode($result));
}
$this->response('success',Code::SUCCESS,$result);
}
}
... ...
... ... @@ -35,33 +35,30 @@ class WebSettingReceivingLogic extends BaseLogic
* @time :2023/5/8 16:26
*/
public function setting_receiving_save(){
$result_err = [];
$data = [];
DB::connection('custom_mysql')->beginTransaction();
try {
$this->model->del(['project_id'=>$this->user['project_id']]);
foreach ($this->param['data'] as $v){
if($v['type'] == 1){
// 使用正则表达式匹配中国大陆手机号
$pattern = '/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/';
if (!preg_match($pattern, $v['values'])) {
$result_err[] = $v['values'];
continue;
}
foreach ($this->param['data'] as $v){
if($v['type'] == 1){
// 使用正则表达式匹配中国大陆手机号
$pattern = '/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/';
if (!preg_match($pattern, $v['values'])) {
$this->fail('当前数据不符合规则:'.$v['values']);
}
if($v['type'] == 2){
// 使用正则表达式匹配中国大陆手机号
$pattern = '/^1[3456789]\d{9}$/';
if (!preg_match($pattern, $v['values'])) {
$result_err[] = $v['values'];
continue;
}
}
if($v['type'] == 2){
// 使用正则表达式匹配中国大陆手机号
$pattern = '/^1[3456789]\d{9}$/';
if (!preg_match($pattern, $v['values'])) {
$this->fail('当前数据不符合规则:'.$v['values']);
}
$v['project_id'] = $this->user['project_id'];
$v['created_at'] = date('Y-m-d H:i:s');
$v['updated_at'] = date('Y-m-d H:i:s');
$data[] = $v;
}
$v['project_id'] = $this->user['project_id'];
$v['created_at'] = date('Y-m-d H:i:s');
$v['updated_at'] = date('Y-m-d H:i:s');
$data[] = $v;
}
DB::connection('custom_mysql')->beginTransaction();
try {
$this->model->del(['project_id'=>$this->user['project_id']]);
if(!empty($data)){
$this->model->insert($data);
}
... ... @@ -71,6 +68,6 @@ class WebSettingReceivingLogic extends BaseLogic
$this->fail('编辑失败,请联系管理员');
}
(new SyncService())->projectAcceptAddress($this->user['project_id']);
return $this->success($result_err);
return $this->success();
}
}
... ...