GeoConfirmLogic.php
3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
/**
* @remark :
* @name :GeoConfirmLogic.php
* @author :lyh
* @method :post
* @time :2025/10/25 11:36
*/
namespace App\Http\Logic\Aside\Geo;
use App\Enums\Common\Code;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Geo\GeoConf;
use App\Models\Geo\GeoConfirm;
use App\Models\Manage\ManageHr;
use App\Models\ProjectAssociation\ProjectAssociation;
use App\Services\DingService;
/**
* @remark :用户确认信息
* @name :GeoConfirmLogic
* @author :lyh
* @method :post
* @time :2025/10/25 11:37
*/
class GeoConfirmLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->param = $this->requestAll;
$this->model = new GeoConfirm();
}
/**
* @remark :保存数据->并推送微信群客户确认
* @name :saveConfirmContent
* @author :lyh
* @method :post
* @time :2025/10/25 11:41
*/
public function saveConfirmContent($param)
{
try {
$wechat = $param['wechat'] ?? true;
unset($param['wechat']);
$info = $this->model->read(['project_id' => $param['project_id'],'type' => $param['type']]);
if($info === false){
$id = $this->model->addReturnId($param);
}else{
$id = $info['id'];
$this->model->edit($param,['id'=>$info['id']]);
}
$friend = ProjectAssociation::where(['project_id' => $param['project_id']])->first();
if (empty($friend)){
$this->fail('项目未绑定微信群, 推送消息失败!');
}
$data = GeoConfirm::sendConfirmMessage($id, $friend->friend_id,$wechat);
} catch (\Exception $e) {
$this->fail('操作失败, error:' . $e->getMessage());
}
return $this->success(['id'=>$id,'data'=>$data]);
}
/**
* @remark :获取数据详情
* @name :getInfo
* @author :lyh
* @method :post
* @time :2025/10/30 09:13
*/
public function getConfirmInfo()
{
$data = $this->model->read($this->param);
if($data === false){
return $this->success();
}
return $this->success($data);
}
/**
* @remark :保存确认信息
* @name :saveConfirmInfo
* @author :lyh
* @method :post
* @time :2025/10/30 11:41
*/
public function saveConfirmInfo()
{
$this->param['status'] = GeoConfirm::STATUS_FINISH;
$info = $this->model->read(['project_id' => $this->param['project_id'],'type'=>$this->param['type']]);
if($info === false){
$id = $this->model->addReturnId($this->param);
}else{
$id = $info['id'];
$this->model->edit($this->param,['id'=>$info['id']]);
$geoConfModel = new GeoConf();
$confInfo = $geoConfModel->read(['project_id'=>$info['project_id']]);
$hrModel = new ManageHr();
$manage_name = $hrModel->getName($confInfo['manager_id'] ??'');
$dingService = new DingService();
$dingService->handle([
'keyword' => '项目数据确认',
'msg' =>
'cm:'.(($info['type'] == 1) ? '标题确认' : '关键词确认'). PHP_EOL .
'项目名称:'.($confInfo['company'] ?? '') . PHP_EOL .
'负责人:'.$manage_name . PHP_EOL,
'isAtAll' => false, // 是否@所有人
], 'https://oapi.dingtalk.com/robot/send?access_token=4effe85882009a8a1617dbeadc38c350f832deef7431ce10f5fda751b4c82fb9');
}
return $this->success(['id'=>$id]);
}
}