文件
xionggeshop/application/admin/controller/shopro/split/Receiver.php
可乐加冰 375dd5356f ```
feat(split): 添加微信分账V3版本验证和汇付分账冻结资金处理

- 在ProfitSharingService中添加Yansongda Pay V3版本验证,确保微信官方分账功能正常运行
- 实现汇付分账冻结资金检测逻辑,当资金被冻结时标记分账失败而非抛出异常
- 在管理后台控制器中增强错误处理和状态显示功能
- 优化前端界面,根据分账模式动态显示相应操作按钮
```
2026-10-02 14:49:33 +08:00

99 行
3.0 KiB
PHP

<?php
namespace app\admin\controller\shopro\split;
use app\admin\controller\shopro\Base;
use addons\shopro\library\split\Config as SplitConfig;
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]);
}
$this->assignconfig('splitHuifuOnly', (new SplitConfig())->isHuifuMode());
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('记录不存在');
}
if ((new SplitConfig())->isHuifuMode()) {
$this->error('当前为汇付分账:无需同步微信接收方。请在汇付控台绑定分账关系,并在此填写 huifu_id');
}
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());
}
}
}