quanwei
2025-10-28 36cacbaf78e510713002fcd5e3d61cece2e01421
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
<?php
 
namespace app\branch\controller\setting;
 
use app\branch\controller\Controller;
use app\branch\model\app\AppPay as AppPayModel;
use app\common\enum\settings\PlatformEnum;
use app\common\enum\order\OrderPayTypeEnum;
 
/**
 * 应用设置
 */
class App extends Controller
{
    /**
     * 支付方式
     */
    public function pay()
    {
        if ($this->request->isGet()) {
            $app = AppPayModel::detail($this->getBranchId());
            $platform = PlatformEnum::data();
            $pay_type = OrderPayTypeEnum::data();
            return $this->renderSuccess('', compact('app', 'platform', 'pay_type'));
        }
        $model = AppPayModel::detail($this->getBranchId());
        if(empty($model)){
            $model = new AppPayModel();
        }
        $data = $this->postData();
        if(!empty($data['pay_type'])){
            foreach ($data['pay_type'] as &$item){
                if(!isset($item['pay_type'])){
                    $item['pay_type'] = [];
                }
            }
        }
 
        $data["branch_id"] = $this->getBranchId();
        if ($model->editPay($data)) {
            return $this->renderSuccess('操作成功');
        }
        return $this->renderError($model->getError() ?: '操作失败');
    }
 
}