feat: 添加批发商品列表功能
This commit is contained in:
parent
60c7b154a5
commit
cbeb06426d
@ -6,6 +6,7 @@ use app\api\logic\order\CartLogic;
|
|||||||
use app\api\validate\CartValidate;
|
use app\api\validate\CartValidate;
|
||||||
use app\api\controller\BaseApiController;
|
use app\api\controller\BaseApiController;
|
||||||
use app\api\lists\order\CartList;
|
use app\api\lists\order\CartList;
|
||||||
|
use app\api\lists\order\CartWholesaleList;
|
||||||
use app\common\model\order\Cart;
|
use app\common\model\order\Cart;
|
||||||
use app\common\model\store_product\StoreProduct;
|
use app\common\model\store_product\StoreProduct;
|
||||||
use app\common\model\store_product_unit\StoreProductUnit;
|
use app\common\model\store_product_unit\StoreProductUnit;
|
||||||
@ -16,7 +17,13 @@ class CartController extends BaseApiController
|
|||||||
{
|
{
|
||||||
return $this->dataLists(new CartList());
|
return $this->dataLists(new CartList());
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 批发商品列表
|
||||||
|
*/
|
||||||
|
public function wholesale_lists(){
|
||||||
|
|
||||||
|
return $this->dataLists(new CartWholesaleList());
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @notes 添加购物车
|
* @notes 添加购物车
|
||||||
*/
|
*/
|
||||||
|
@ -3,11 +3,14 @@
|
|||||||
namespace app\api\controller\product;
|
namespace app\api\controller\product;
|
||||||
use app\api\controller\BaseApiController;
|
use app\api\controller\BaseApiController;
|
||||||
use app\api\lists\product\ProductLists;
|
use app\api\lists\product\ProductLists;
|
||||||
|
use app\api\lists\product\ProductWholesaleLists;
|
||||||
use app\api\lists\product\StoreProductLists;
|
use app\api\lists\product\StoreProductLists;
|
||||||
use app\common\model\system_store\SystemStoreStaff;
|
use app\common\model\system_store\SystemStoreStaff;
|
||||||
|
|
||||||
class ProductController extends BaseApiController{
|
class ProductController extends BaseApiController{
|
||||||
|
|
||||||
public $notNeedLogin = ['lists'];
|
public $notNeedLogin = ['lists'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品列表
|
* 商品列表
|
||||||
*/
|
*/
|
||||||
@ -16,6 +19,13 @@ class ProductController extends BaseApiController{
|
|||||||
return $this->dataLists(new ProductLists());
|
return $this->dataLists(new ProductLists());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批发商品列表
|
||||||
|
*/
|
||||||
|
public function wholesale_lists(){
|
||||||
|
|
||||||
|
return $this->dataLists(new ProductWholesaleLists());
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 商品列表
|
* 商品列表
|
||||||
*/
|
*/
|
||||||
|
@ -45,9 +45,13 @@ class CateLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
$level = Request()->get('level', 1);
|
$level = Request()->get('level', 1);
|
||||||
|
$source = Request()->get('source');
|
||||||
$pid = $this->request->get('pid',0);
|
$pid = $this->request->get('pid',0);
|
||||||
// $this->searchWhere[] = ['stock', '>', 0];
|
// $this->searchWhere[] = ['stock', '>', 0];
|
||||||
$this->searchWhere[] = ['is_show', '=', 1];
|
$this->searchWhere[] = ['is_show', '=', 1];
|
||||||
|
if($source && $source==4){
|
||||||
|
$this->searchWhere[] = ['product_type', '=', 5];
|
||||||
|
}
|
||||||
if($pid && $level ==2){
|
if($pid && $level ==2){
|
||||||
$this->searchWhere[] = ['top_cate_id','=',$pid];
|
$this->searchWhere[] = ['top_cate_id','=',$pid];
|
||||||
$cate_arr = StoreProduct::where($this->searchWhere)->distinct()
|
$cate_arr = StoreProduct::where($this->searchWhere)->distinct()
|
||||||
|
109
app/api/lists/order/CartWholesaleList.php
Normal file
109
app/api/lists/order/CartWholesaleList.php
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\lists\order;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
use app\common\model\order\Cart;
|
||||||
|
use app\common\lists\ListsExtendInterface;
|
||||||
|
use app\common\model\Config;
|
||||||
|
use app\common\model\dict\DictType;
|
||||||
|
use app\common\model\store_product\StoreProduct;
|
||||||
|
use app\common\model\store_product_attr_value\StoreProductAttrValue;
|
||||||
|
use app\common\model\store_product_unit\StoreProductUnit;
|
||||||
|
use app\common\model\user\User;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 购物车列表
|
||||||
|
* Class RetailOrderList
|
||||||
|
* @package app\api\order
|
||||||
|
*/
|
||||||
|
class CartWholesaleList extends BaseAdminDataLists implements ListsSearchInterface, ListsExtendInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $total_price = 0;
|
||||||
|
protected $activity_price = 0;
|
||||||
|
protected $off_activity = 0;
|
||||||
|
protected $user_ship = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置搜索条件
|
||||||
|
* @return \string[][]
|
||||||
|
* @author likeadmin
|
||||||
|
*/
|
||||||
|
public function setSearch(): array
|
||||||
|
{
|
||||||
|
return ['='=>['store_id','source']];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 购物车列表
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @date 2024/04/27 11:26
|
||||||
|
*/
|
||||||
|
public function lists($where = []): array
|
||||||
|
{
|
||||||
|
$userId = $this->request->userId;
|
||||||
|
if (!$userId) return [];
|
||||||
|
$where = [
|
||||||
|
'uid' => $userId,
|
||||||
|
'is_pay' => 0
|
||||||
|
];
|
||||||
|
$list = Cart::where($this->searchWhere)->where($where)
|
||||||
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
|
->order(['id' => 'desc'])
|
||||||
|
->select()
|
||||||
|
->toArray();
|
||||||
|
$field = 'id,id product_id,image,price,cost,store_name,unit,delete_time,vip_price,top_cate_id,batch';
|
||||||
|
foreach ($list as $key => &$item) {
|
||||||
|
$find = StoreProduct::where(['id' => $item['product_id']])
|
||||||
|
->field($field)
|
||||||
|
->find();
|
||||||
|
if ($find) {
|
||||||
|
$item['goods_total_price'] = bcmul($item['cart_num'], $find['price'], 2);
|
||||||
|
$this->total_price = bcadd($this->total_price, $item['goods_total_price'], 2);
|
||||||
|
$item['batch'] = $find['batch'];
|
||||||
|
$item['imgs'] = $find['image'];
|
||||||
|
$item['price'] = $find['price'];
|
||||||
|
$item['cost'] = $find['cost'];
|
||||||
|
$item['goods_name'] = $find['store_name'];
|
||||||
|
$item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 购物车数量
|
||||||
|
* @return int
|
||||||
|
* @date 2024/04/27 11:26
|
||||||
|
*/
|
||||||
|
public function count(): int
|
||||||
|
{
|
||||||
|
$userId = $this->request->userId;
|
||||||
|
if (!$userId) return 0;
|
||||||
|
$where = [
|
||||||
|
'uid' => $userId,
|
||||||
|
'is_pay' => 0
|
||||||
|
];
|
||||||
|
return Cart::where($this->searchWhere)->where($where)->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function extend()
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
'off_activity' => $this->off_activity,
|
||||||
|
'total_price' => $this->total_price,
|
||||||
|
'msg' => '',
|
||||||
|
'pay_price' => $this->total_price
|
||||||
|
];
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
117
app/api/lists/product/ProductWholesaleLists.php
Normal file
117
app/api/lists/product/ProductWholesaleLists.php
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\lists\product;
|
||||||
|
|
||||||
|
|
||||||
|
use app\api\lists\BaseApiDataLists;
|
||||||
|
use app\common\lists\ListsExtendInterface;
|
||||||
|
use app\common\lists\ListsSortInterface;
|
||||||
|
use app\common\model\store_product\StoreProduct;
|
||||||
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
use app\common\model\Config;
|
||||||
|
use app\common\model\user\User;
|
||||||
|
//use app\common\model\goods\GoodsLabel;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品列表列表
|
||||||
|
* Class goods
|
||||||
|
* @package app\api\goods
|
||||||
|
*/
|
||||||
|
class ProductWholesaleLists extends BaseApiDataLists implements ListsSearchInterface, ListsSortInterface, ListsExtendInterface
|
||||||
|
{
|
||||||
|
protected $off_activity = 0;
|
||||||
|
protected $user_ship = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置搜索条件
|
||||||
|
* @return \string[][]
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/23 11:28
|
||||||
|
*/
|
||||||
|
public function setSearch(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'=' => [ 'cate_id', 'top_cate_id', 'two_cate_id'],
|
||||||
|
'%pipe_like%' => ['store_name' => 'store_name|bar_code'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @notes 设置支持排序字段
|
||||||
|
* @return string[]
|
||||||
|
* @date 2021/12/29 10:07
|
||||||
|
* @remark 格式: ['前端传过来的字段名' => '数据库中的字段名'];
|
||||||
|
*/
|
||||||
|
public function setSortFields(): array
|
||||||
|
{
|
||||||
|
return ['sell' => 'price', 'sales' => 'sales',];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置默认排序
|
||||||
|
* @return string[]
|
||||||
|
* @date 2021/12/29 10:06
|
||||||
|
*/
|
||||||
|
public function setDefaultOrder(): array
|
||||||
|
{
|
||||||
|
return ['price' => 'asc', 'id' => 'desc'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取商品列表列表
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/23 11:28
|
||||||
|
*/
|
||||||
|
public function lists(): array
|
||||||
|
{
|
||||||
|
|
||||||
|
$order = $this->request->get('order', '');
|
||||||
|
$field = $this->request->get('field', '');
|
||||||
|
if (empty($order) || empty($field)) {
|
||||||
|
$order = $this->sortOrder;
|
||||||
|
} else {
|
||||||
|
$order = [$field => $order];
|
||||||
|
}
|
||||||
|
$fields = 'id,id product_id,top_cate_id,cate_id,store_name,cost,vip_price,purchase,price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock';
|
||||||
|
|
||||||
|
$this->searchWhere[] = ['is_show', '=', 1];
|
||||||
|
$this->searchWhere[] = ['product_type', '=', 5];
|
||||||
|
// $this->searchWhere[] = ['stock', '>', 0];
|
||||||
|
return StoreProduct::where($this->searchWhere)
|
||||||
|
->field($fields)
|
||||||
|
->with(['className', 'unitName'])
|
||||||
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
|
->order($order)
|
||||||
|
->select()
|
||||||
|
->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取商品列表数量
|
||||||
|
* @return int
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/23 11:28
|
||||||
|
*/
|
||||||
|
public function count(): int
|
||||||
|
{
|
||||||
|
return StoreProduct::where($this->searchWhere)
|
||||||
|
->count();
|
||||||
|
}
|
||||||
|
public function extend()
|
||||||
|
{
|
||||||
|
$price = 'price';
|
||||||
|
$op_price = 'price';
|
||||||
|
$data = [
|
||||||
|
'off_activity' => $this->off_activity,
|
||||||
|
'price' => $price,
|
||||||
|
'op_price' => $op_price,
|
||||||
|
];
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
@ -28,9 +28,10 @@ class CartLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
public static function add(array $params)
|
public static function add(array $params)
|
||||||
{
|
{
|
||||||
if ($params['store_id'] <= 0) {
|
if ($params['store_id'] < 0) {
|
||||||
throw new BusinessException('门店ID不能为空');
|
throw new BusinessException('门店ID不能为空');
|
||||||
}
|
}
|
||||||
|
$source=$params['source'] ?? 0;
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
//check
|
//check
|
||||||
@ -38,7 +39,8 @@ class CartLogic extends BaseLogic
|
|||||||
'uid' => $params['uid'],
|
'uid' => $params['uid'],
|
||||||
'store_id' => $params['store_id'],
|
'store_id' => $params['store_id'],
|
||||||
'product_id' => $params['product_id'],
|
'product_id' => $params['product_id'],
|
||||||
'is_pay' => 0
|
'is_pay' => 0,
|
||||||
|
'source' => $source,
|
||||||
])->field('id')->find();
|
])->field('id')->find();
|
||||||
if ($check) {
|
if ($check) {
|
||||||
Cart::where('id', $check['id'])->inc('cart_num', $params['cart_num'])
|
Cart::where('id', $check['id'])->inc('cart_num', $params['cart_num'])
|
||||||
@ -53,6 +55,7 @@ class CartLogic extends BaseLogic
|
|||||||
'staff_id' => $params['staff_id'] ?? 0,
|
'staff_id' => $params['staff_id'] ?? 0,
|
||||||
'cart_num' => $params['cart_num'],
|
'cart_num' => $params['cart_num'],
|
||||||
'is_new' => $params['is_new'] ?? 0,
|
'is_new' => $params['is_new'] ?? 0,
|
||||||
|
'source' =>$source,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
StoreProductLog::create([
|
StoreProductLog::create([
|
||||||
|
@ -69,9 +69,12 @@ class OrderLogic extends BaseLogic
|
|||||||
if (empty($params['store_id']) || $params['store_id'] <= 0) {
|
if (empty($params['store_id']) || $params['store_id'] <= 0) {
|
||||||
throw new BusinessException('请选择门店');
|
throw new BusinessException('请选择门店');
|
||||||
}
|
}
|
||||||
|
$source=0;
|
||||||
|
if (isset($params['source']) && $params['source'] >0) {
|
||||||
|
$source=$params['source'];
|
||||||
|
}
|
||||||
$where = ['is_pay' => 0];
|
$where = ['is_pay' => 0];
|
||||||
$cart_select = Cart::whereIn('id', $cartId)->where($where)->field('id,product_id,cart_num')->select()->toArray();
|
$cart_select = Cart::whereIn('id', $cartId)->where($where)->field('id,product_id,cart_num,source')->select()->toArray();
|
||||||
if (empty($cart_select)) {
|
if (empty($cart_select)) {
|
||||||
throw new BusinessException('购物车为空');
|
throw new BusinessException('购物车为空');
|
||||||
}
|
}
|
||||||
@ -89,7 +92,7 @@ class OrderLogic extends BaseLogic
|
|||||||
$off_activity = Config::where('name', 'off_activity')->value('value');
|
$off_activity = Config::where('name', 'off_activity')->value('value');
|
||||||
$field = 'id,store_name,image,unit,price,vip_price,cost,purchase,cate_id,store_info,rose';
|
$field = 'id,store_name,image,unit,price,vip_price,cost,purchase,cate_id,store_info,rose';
|
||||||
foreach ($cart_select as $k => $v) {
|
foreach ($cart_select as $k => $v) {
|
||||||
if (isset($params['source']) && $params['source'] == 2) {
|
if ($source == 2) {
|
||||||
$field = 'product_id,product_id id,store_name,image,unit,price,vip_price,cost,purchase,cate_id,store_info,rose';
|
$field = 'product_id,product_id id,store_name,image,unit,price,vip_price,cost,purchase,cate_id,store_info,rose';
|
||||||
$find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field($field)->find();
|
$find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field($field)->find();
|
||||||
} else {
|
} else {
|
||||||
@ -116,6 +119,7 @@ class OrderLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
unset($cart_select[$k]['id']);
|
unset($cart_select[$k]['id']);
|
||||||
$cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价
|
$cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价
|
||||||
|
if ($v['source'] != 4) {
|
||||||
if ($off_activity == 1 || ($user != null && in_array($user['user_ship'], [4, 6, 7]))) {
|
if ($off_activity == 1 || ($user != null && in_array($user['user_ship'], [4, 6, 7]))) {
|
||||||
$price = $find['cost'];
|
$price = $find['cost'];
|
||||||
} else {
|
} else {
|
||||||
@ -131,6 +135,10 @@ class OrderLogic extends BaseLogic
|
|||||||
if ($off_activity == 0 && $find['top_cate_id'] == 15189 && $user && $user['user_ship'] == 5) {
|
if ($off_activity == 0 && $find['top_cate_id'] == 15189 && $user && $user['user_ship'] == 5) {
|
||||||
$price = $find['cost'];
|
$price = $find['cost'];
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$price = $find['price'];
|
||||||
|
}
|
||||||
|
|
||||||
$cart_select[$k]['price'] = $price;
|
$cart_select[$k]['price'] = $price;
|
||||||
$cart_select[$k]['cost'] = $find['cost'];
|
$cart_select[$k]['cost'] = $find['cost'];
|
||||||
$cart_select[$k]['vip'] = 0;
|
$cart_select[$k]['vip'] = 0;
|
||||||
@ -195,7 +203,7 @@ class OrderLogic extends BaseLogic
|
|||||||
|
|
||||||
$pay_price = self::$pay_price; // bcsub(self::$pay_price, self::$activity_price, 2); //减去活动优惠金额
|
$pay_price = self::$pay_price; // bcsub(self::$pay_price, self::$activity_price, 2); //减去活动优惠金额
|
||||||
//判断生鲜是否大于200
|
//判断生鲜是否大于200
|
||||||
if ($createOrder == 1 && self::$fresh_price > 0) {
|
if ($createOrder == 1 && self::$fresh_price > 0 &&$source!=2) {
|
||||||
if (self::$pay_price < 200) {
|
if (self::$pay_price < 200) {
|
||||||
throw new BusinessException('订单包含生鲜产品,订单金额必须大于200元,才能下单');
|
throw new BusinessException('订单包含生鲜产品,订单金额必须大于200元,才能下单');
|
||||||
}
|
}
|
||||||
@ -223,7 +231,7 @@ class OrderLogic extends BaseLogic
|
|||||||
'activities' => $off_activity,
|
'activities' => $off_activity,
|
||||||
'deduction_price' => self::$deduction_price, //抵扣金额
|
'deduction_price' => self::$deduction_price, //抵扣金额
|
||||||
'frozen_money' => 0, //self::$frozen_money, //返还金额(活动关闭得时候有)
|
'frozen_money' => 0, //self::$frozen_money, //返还金额(活动关闭得时候有)
|
||||||
'source' => 0,
|
'source' => $source,
|
||||||
'is_storage' => $params['is_storage'] ?? 0,
|
'is_storage' => $params['is_storage'] ?? 0,
|
||||||
'address_id' => 0,
|
'address_id' => 0,
|
||||||
];
|
];
|
||||||
@ -231,9 +239,6 @@ class OrderLogic extends BaseLogic
|
|||||||
if ($params['store_id']) {
|
if ($params['store_id']) {
|
||||||
$order['default_delivery'] = SystemStore::where('id', $params['store_id'])->value('is_send');
|
$order['default_delivery'] = SystemStore::where('id', $params['store_id'])->value('is_send');
|
||||||
}
|
}
|
||||||
if (isset($params['source']) && $params['source'] > 0) {
|
|
||||||
$order['source'] = $params['source'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($params['store_id']) && $params['store_id'] > 0) {
|
if (isset($params['store_id']) && $params['store_id'] > 0) {
|
||||||
$store_id = $params['store_id'];
|
$store_id = $params['store_id'];
|
||||||
@ -259,8 +264,6 @@ class OrderLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
throw new BusinessException($e->getMessage());
|
throw new BusinessException($e->getMessage());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return ['order' => $order, 'cart_list' => $cart_select, 'shopInfo' => $store['near_store'], 'alert' => $alert];
|
return ['order' => $order, 'cart_list' => $cart_select, 'shopInfo' => $store['near_store'], 'alert' => $alert];
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ declare(strict_types=1);
|
|||||||
namespace app\common\validate;
|
namespace app\common\validate;
|
||||||
|
|
||||||
use app\common\service\JsonService;
|
use app\common\service\JsonService;
|
||||||
|
use support\exception\BusinessException;
|
||||||
use taoser\Validate;
|
use taoser\Validate;
|
||||||
|
|
||||||
class BaseValidate extends Validate
|
class BaseValidate extends Validate
|
||||||
@ -31,7 +32,7 @@ class BaseValidate extends Validate
|
|||||||
public function post()
|
public function post()
|
||||||
{
|
{
|
||||||
if (!(request()->method() == 'POST')) {
|
if (!(request()->method() == 'POST')) {
|
||||||
JsonService::throw('请求方式错误,请使用post请求方式');
|
throw new BusinessException('请求方式错误,请使用post请求方式');
|
||||||
}
|
}
|
||||||
$this->method = 'POST';
|
$this->method = 'POST';
|
||||||
return $this;
|
return $this;
|
||||||
@ -45,7 +46,7 @@ class BaseValidate extends Validate
|
|||||||
public function get()
|
public function get()
|
||||||
{
|
{
|
||||||
if (!(request()->method() == 'GET')) {
|
if (!(request()->method() == 'GET')) {
|
||||||
JsonService::throw('请求方式错误,请使用get请求方式');
|
throw new BusinessException('请求方式错误,请使用get请求方式');
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -79,7 +80,7 @@ class BaseValidate extends Validate
|
|||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
$exception = is_array($this->error) ? implode(';', $this->error) : $this->error;
|
$exception = is_array($this->error) ? implode(';', $this->error) : $this->error;
|
||||||
JsonService::throw($exception);
|
throw new BusinessException($exception);
|
||||||
}
|
}
|
||||||
// 3.成功返回数据
|
// 3.成功返回数据
|
||||||
return $params;
|
return $params;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user