feat: 初始化雄戈商城服务端代码与Webhook自动部署配置
这个提交包含在:
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\shopro\split;
|
||||
|
||||
use app\admin\controller\shopro\Base;
|
||||
use addons\shopro\library\split\ProfitSharingService;
|
||||
|
||||
class Receiver extends Base
|
||||
{
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \addons\shopro\model\split\Receiver;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax()) {
|
||||
list($where, $sort, $order, $offset, $limit) = $this->custombuildparams();
|
||||
$total = $this->model->where($where)->count();
|
||||
$list = $this->model->where($where)->order($sort, $order)->limit($offset, $limit)->select();
|
||||
return $this->success('操作成功', null, ['total' => $total, 'rows' => $list]);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->post('row/a');
|
||||
if (empty($params['receiver_account'])) {
|
||||
$this->error('请填写接收方账号');
|
||||
}
|
||||
$this->model->create($params);
|
||||
$this->success('添加成功');
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
public function edit($ids = null)
|
||||
{
|
||||
$row = $this->model->get($ids);
|
||||
if (!$row) {
|
||||
$this->error('记录不存在');
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->post('row/a');
|
||||
$row->save($params);
|
||||
$this->success('保存成功');
|
||||
}
|
||||
$this->view->assign('row', $row);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
public function del($ids = null)
|
||||
{
|
||||
$row = $this->model->get($ids);
|
||||
if ($row) {
|
||||
$row->status = 'forbidden';
|
||||
$row->save();
|
||||
}
|
||||
$this->success('操作成功');
|
||||
}
|
||||
|
||||
public function syncWx($ids = null)
|
||||
{
|
||||
$row = $this->model->get($ids);
|
||||
if (!$row) {
|
||||
$this->error('记录不存在');
|
||||
}
|
||||
try {
|
||||
$service = new ProfitSharingService();
|
||||
$service->addReceiver([
|
||||
'type' => $row['receiver_type'],
|
||||
'account' => $row['receiver_account'],
|
||||
'name' => $row['receiver_name'],
|
||||
'relation_type' => $row['relation_type'] ?: 'USER',
|
||||
]);
|
||||
$row->wx_status = 1;
|
||||
$row->wx_message = '同步成功';
|
||||
$row->save();
|
||||
$this->success('同步成功');
|
||||
} catch (\Exception $e) {
|
||||
$row->wx_status = 2;
|
||||
$row->wx_message = $e->getMessage();
|
||||
$row->save();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户