quanwei
2025-12-05 feda780069d64479c0c20493603717e100655da9
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
<?php
 
namespace app\api\controller\supplier;
use app\api\controller\Controller;
use app\api\model\settings\Message as MessageModel;
use app\api\model\supplier\Cash as CashModel;
use app\api\model\supplier\Supplier;
use app\api\model\plus\agent\Setting;
/**
 * 供应商提现
 */
class Cash extends Controller
{
    private $user;
    private $Supplier;
    private $setting;
    /**
     * 构造方法
     */
    public function initialize()
    {
        // 用户信息
        $this->user = $this->getUser();
        $shop_supplier_id = $this->getSupplierUser($this->user)['shop_supplier_id'];
        // 供应商用户信息
        $this->Supplier = Supplier::detail($shop_supplier_id);
        // 供应商设置
        $this->setting = Setting::getAll();
    }
    /**
     * 提交提现申请
     */
    public function submit($data)
    {
        $formData = json_decode(htmlspecialchars_decode($data), true);
 
        $model = new CashModel;
        if ($model->submit($this->Supplier, $formData)) {
            return $this->renderSuccess('申请提现成功');
        }
        return $this->renderError($model->getError() ?: '提交失败');
    }
    /**
     * 分销商提现信息
     */
    public function cash($platform = '')
    {
        // 如果来源是小程序, 则获取小程序订阅消息id.获取售后通知.
        $template_arr = MessageModel::getMessageByNameArr($platform, ['agent_cash_user']);
        return $this->renderSuccess('', [
            // 分销商用户信息
            'agent' => $this->Supplier,
            // 结算设置
            'settlement' => $this->setting['settlement']['values'],
            // 背景图
            'background' => $this->setting['background']['values']['cash_apply'],
            // 页面文字
            'words' => $this->setting['words']['values'],
            // 小程序消息
            'template_arr' => $template_arr
        ]);
    }/**
 * 分销商提现明细
 */
    public function lists($status = -1)
    {
 
        $model = new CashModel;
        return $this->renderSuccess('', [
            // 提现明细列表
            'list' => $model->getList($this->Supplier['shop_supplier_id'], (int)$status,$this->postData()),
            // 页面文字
            'words' => $this->setting['words']['values'],
        ]);
    }
}