|
@@ -6,6 +6,7 @@ use App\Http\Logic\Bside\BaseLogic; |
|
@@ -6,6 +6,7 @@ use App\Http\Logic\Bside\BaseLogic; |
|
6
|
use App\Models\WebSetting\WebSettingReceiving;
|
6
|
use App\Models\WebSetting\WebSettingReceiving;
|
|
7
|
use App\Models\WebSetting\WebSettingText;
|
7
|
use App\Models\WebSetting\WebSettingText;
|
|
8
|
use App\Services\SyncService;
|
8
|
use App\Services\SyncService;
|
|
|
|
9
|
+use Illuminate\Support\Facades\DB;
|
|
9
|
|
10
|
|
|
10
|
class WebSettingReceivingLogic extends BaseLogic
|
11
|
class WebSettingReceivingLogic extends BaseLogic
|
|
11
|
{
|
12
|
{
|
|
@@ -34,9 +35,18 @@ class WebSettingReceivingLogic extends BaseLogic |
|
@@ -34,9 +35,18 @@ class WebSettingReceivingLogic extends BaseLogic |
|
34
|
* @time :2023/5/8 16:26
|
35
|
* @time :2023/5/8 16:26
|
|
35
|
*/
|
36
|
*/
|
|
36
|
public function setting_receiving_save(){
|
37
|
public function setting_receiving_save(){
|
|
|
|
38
|
+ $data = [];
|
|
|
|
39
|
+ DB::connection('custom_mysql')->beginTransaction();
|
|
37
|
try {
|
40
|
try {
|
|
38
|
$this->model->del(['project_id'=>$this->user['project_id']]);
|
41
|
$this->model->del(['project_id'=>$this->user['project_id']]);
|
|
39
|
- foreach ($this->param['data'] as $k => $v){
|
42
|
+ foreach ($this->param['data'] as $v){
|
|
|
|
43
|
+ if($v['type'] == 1){
|
|
|
|
44
|
+ // 使用正则表达式匹配中国大陆手机号
|
|
|
|
45
|
+ $pattern = '/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/';
|
|
|
|
46
|
+ if (!preg_match($pattern, $v['values'])) {
|
|
|
|
47
|
+ continue;
|
|
|
|
48
|
+ }
|
|
|
|
49
|
+ }
|
|
40
|
if($v['type'] == 2){
|
50
|
if($v['type'] == 2){
|
|
41
|
// 使用正则表达式匹配中国大陆手机号
|
51
|
// 使用正则表达式匹配中国大陆手机号
|
|
42
|
$pattern = '/^1[3456789]\d{9}$/';
|
52
|
$pattern = '/^1[3456789]\d{9}$/';
|
|
@@ -47,11 +57,15 @@ class WebSettingReceivingLogic extends BaseLogic |
|
@@ -47,11 +57,15 @@ class WebSettingReceivingLogic extends BaseLogic |
|
47
|
$v['project_id'] = $this->user['project_id'];
|
57
|
$v['project_id'] = $this->user['project_id'];
|
|
48
|
$v['created_at'] = date('Y-m-d H:i:s');
|
58
|
$v['created_at'] = date('Y-m-d H:i:s');
|
|
49
|
$v['updated_at'] = date('Y-m-d H:i:s');
|
59
|
$v['updated_at'] = date('Y-m-d H:i:s');
|
|
50
|
- $this->param['data'][$k] = $v;
|
60
|
+ $data[] = $v;
|
|
|
|
61
|
+ }
|
|
|
|
62
|
+ if(!empty($data)){
|
|
|
|
63
|
+ $this->model->insert($data);
|
|
51
|
}
|
64
|
}
|
|
52
|
- $this->model->insert($this->param['data']);
|
65
|
+ DB::connection('custom_mysql')->commit();
|
|
53
|
}catch (\Exception $e){
|
66
|
}catch (\Exception $e){
|
|
54
|
- $this->fail('error');
|
67
|
+ DB::connection('custom_mysql')->rollBack();
|
|
|
|
68
|
+ $this->fail('编辑失败,请联系管理员');
|
|
55
|
}
|
69
|
}
|
|
56
|
(new SyncService())->projectAcceptAddress($this->user['project_id']);
|
70
|
(new SyncService())->projectAcceptAddress($this->user['project_id']);
|
|
57
|
return $this->success();
|
71
|
return $this->success();
|