AiccWeChatController.php
2.1 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
<?php
namespace App\Http\Controllers\Bside\Aicc;
use App\Enums\Common\Code;
use App\Exceptions\BsideGlobalException;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Aside\Aicc\AiccWeChatLogic;
use Illuminate\Http\Request;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
class AiccWeChatController extends BaseController
{
private $aiccWeChatLogic;
public function __construct(Request $request)
{
$this->aiccWeChatLogic = new AiccWeChatLogic();
parent::__construct($request);
}
/**
* V6与AICC数据关联
* @return void
* @throws BsideGlobalException
*/
public function save()
{
$project_id = (int)request()->post('project_id', 0);
if (empty($project_id)) {
$this->fail('请选择项目!', Code::USER_PARAMS_ERROE);
}
$status = (bool)request()->post('status', 1); # 1 - 正常, 0 - 禁用
$wx_user_id = (int)request()->post('user_id', 0);
if (empty($wx_user_id) && $status) {
$this->fail('请选择要绑定的AICC用户!', Code::USER_PARAMS_ERROE);
}
$wx_id = (int)request()->post('wx_id', 0);
if (empty($wx_id) && $status) {
$this->fail('请选择要绑定的AICC项目!', Code::USER_PARAMS_ERROE);
}
$wx_nickname = request()->post('nickname', '');
$wx_user_name = request()->post('user_name', '');
$wx_image = request()->post('image', '');
$data = compact('project_id', 'wx_id', 'wx_nickname', 'wx_user_id', 'wx_user_name', 'wx_image');
$this->aiccWeChatLogic->saveData($data);
$this->response('success');
}
/**
* 数据推送到AICC
* @return void
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function dataPush()
{
$page = (int)request()->get('page', 1);
$perPage = (int)request()->get('perPage', 15); # 分页页数
$data = $this->aiccWeChatLogic->AiccWeChatLists($page, $perPage);
$this->response('success', Code::SUCCESS, $data);
}
}