|
|
|
<?php
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
// | Author: 萤火科技 <admin@yiovo.com>
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
declare (strict_types=1);
|
|
|
|
|
|
|
|
namespace app\store\controller;
|
|
|
|
|
|
|
|
use app\api\model\user\RetailOrder;
|
|
|
|
use think\response\Json;
|
|
|
|
use app\store\model\Retail as RetailModel;
|
|
|
|
use app\store\model\RetailOrder as RetailOrderModel;
|
|
|
|
|
|
|
|
use function Symfony\Component\VarDumper\Dumper\esc;
|
|
|
|
|
|
|
|
class Retail extends Controller
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查看所有会员售价
|
|
|
|
* @return Json
|
|
|
|
*/
|
|
|
|
public function list(): Json
|
|
|
|
{
|
|
|
|
$where = [];
|
|
|
|
$type = $this->request->get('retailType');
|
|
|
|
$pageSize = intval($this->request->get('pageSize'));
|
|
|
|
if ($type) {
|
|
|
|
$where['retail_type'] = $type;
|
|
|
|
}
|
|
|
|
$model = new RetailModel();
|
|
|
|
// $list = $model->getList($where);
|
|
|
|
$list = $model->getList($where,$pageSize);
|
|
|
|
return $this->renderSuccess(compact('list'));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @notes:新增
|
|
|
|
* @return Json
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function add(): Json
|
|
|
|
{
|
|
|
|
$data = $this->postForm();
|
|
|
|
$id = $this->getStoreId();
|
|
|
|
if (!$data) {
|
|
|
|
return $this->renderError('缺少必要参数');
|
|
|
|
}
|
|
|
|
$model = new RetailModel();
|
|
|
|
if ($model->add($data)) {
|
|
|
|
return $this->renderSuccess('添加成功');
|
|
|
|
}
|
|
|
|
return $this->renderError($model->getError() ?: '添加失败');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @notes:编辑
|
|
|
|
* @param int $retailPriceId
|
|
|
|
* @return Json
|
|
|
|
* @author:
|
|
|
|
*/
|
|
|
|
public function edit(int $retailPriceId): Json
|
|
|
|
{
|
|
|
|
$data = $this->postForm();
|
|
|
|
if (!$data) {
|
|
|
|
return $this->renderError('缺少必要参数');
|
|
|
|
}
|
|
|
|
$model = RetailModel::withoutGlobalScope()->where('retail_price_id', $retailPriceId)->find();
|
|
|
|
if (!$model) {
|
|
|
|
return $this->renderError('找不到指定的数据');
|
|
|
|
}
|
|
|
|
$data['update_time']=time();
|
|
|
|
RetailModel::withoutGlobalScope()->where('retail_price_id', $retailPriceId)->update($data);
|
|
|
|
return $this->renderSuccess('编辑成功');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @notes:删除
|
|
|
|
* @param array $identityId
|
|
|
|
* @return Json
|
|
|
|
* @author: wanghousheng
|
|
|
|
*/
|
|
|
|
public function delete(array $retailPriceId): Json
|
|
|
|
{
|
|
|
|
$model = new RetailModel;
|
|
|
|
if ($model->remove($retailPriceId)) {
|
|
|
|
return $this->renderSuccess('删除成功');
|
|
|
|
}
|
|
|
|
return $this->renderError('删除失败');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getRetailOrder(): Json{
|
|
|
|
$model = new RetailOrderModel();
|
|
|
|
$list = $model->getList($this->request->param());
|
|
|
|
return $this->renderSuccess(compact('list'));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|