<?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'],
|
]);
|
}
|
}
|