<?php
|
|
namespace app\operations\controller\takeout;
|
|
use app\operations\controller\Controller;
|
use app\operations\model\takeout\Deliveryman as DeliverymanModel;
|
use app\operations\model\takeout\Commander as CommanderModel;
|
use app\operations\model\takeout\DeliverymanCash as DeliverymanCashModel;
|
|
/**
|
* 控制器
|
*/
|
class Deliveryman extends Controller
|
{
|
/**
|
* 列表
|
*/
|
public function index()
|
{
|
$model = new DeliverymanModel;
|
$list = $model->getList($this->postData());
|
return $this->renderSuccess('', compact('list'));
|
}
|
|
/**
|
* 添加
|
*/
|
public function add()
|
{
|
$postData = $this->postData();
|
if(empty($postData["user_id"])){
|
return $this->renderError('请选择会员');
|
}
|
if(empty($postData["real_name"]) || empty($postData["mobile"])){
|
return $this->renderError('请填写姓名和手机号');
|
}
|
$is_exsit = DeliverymanModel::isDeliveryman($postData["user_id"]);
|
if($is_exsit){
|
return $this->renderError('该会员已成为配送员');
|
}
|
$commander = CommanderModel::detail($postData["commander_id"]);
|
$postData["school_id"] = $commander["school_id"];
|
$model = new DeliverymanModel;
|
// 新增记录
|
if ($model->add($postData["user_id"],$postData)) {
|
return $this->renderSuccess('添加成功');
|
}
|
return $this->renderError($model->getError() ?: '添加失败');
|
}
|
|
/**
|
* 编辑
|
*/
|
public function edit()
|
{
|
$postData = $this->postData();
|
if(empty($postData["real_name"]) || empty($postData["mobile"])){
|
return $this->renderError('请填写姓名和手机号');
|
}
|
$model = DeliverymanModel::detail($postData["user_id"]);
|
if ($model->edit($postData)) {
|
return $this->renderSuccess('更新成功');
|
}
|
return $this->renderError($model->getError() ?: '更新失败');
|
}
|
|
/**
|
* 软删除
|
*/
|
public function delete($user_id)
|
{
|
$model = DeliverymanModel::detail($user_id);
|
if (!$model->setDelete()) {
|
return $this->renderError('删除失败');
|
}
|
return $this->renderSuccess('删除成功');
|
}
|
|
/**
|
* 提现列表
|
*/
|
public function cash()
|
{
|
$model = new DeliverymanCashModel;
|
$postData = $this->postData();
|
$list = $model->getList($postData);
|
return $this->renderSuccess('', compact('list'));
|
}
|
|
/**
|
* 提现审核
|
*/
|
public function cashSubmit($user_id)
|
{
|
$model = DeliverymanCashModel::detail($user_id);
|
if ($model->submit($this->postData())) {
|
return $this->renderSuccess('操作成功');
|
}
|
return $this->renderError($model->getError() ?: '操作失败');
|
}
|
|
/**
|
* 确认打款
|
*/
|
public function cashMoney($user_id)
|
{
|
$model = DeliverymanCashModel::detail($user_id);
|
|
if ($model->money()) {
|
return $this->renderSuccess('操作成功');
|
}
|
return $this->renderError($model->getError() ?: '操作失败');
|
}
|
|
}
|