You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yanzong/app/store/controller/wholesaler/Set.php

39 lines
1.1 KiB

<?php
namespace app\store\controller\wholesaler;
use app\common\library\helper;
use app\store\controller\Controller;
use think\response\Json;
class Set extends Controller
{
public function info(): Json
{
$info = \app\store\model\wholesaler\Set::detail();
return $this->renderSuccess(compact('info'));
}
public function setData(): Json
{
$price = helper::number2($this->request->post('price'));
if ($price <= 0) {
return $this->renderError('价格不能为空');
}
$year = intval($this->request->post('year'));
if ($year <= 0) {
return $this->renderError('年限不能为空');
}
$info = \app\store\model\wholesaler\Set::detail();
$model = new \app\store\model\wholesaler\Set();
if (!empty($info->id)) {
$res = $model->edit(compact('price', 'year'));
} else {
$res = $model->add(compact('price', 'year'));
}
if ($res) {
return $this->renderSuccess('操作成功');
}
return $this->renderError('操作失败');
}
}