其余文件
This commit is contained in:
137
app/admin/validate/integral/IntegralGoodsValidate.php
Normal file
137
app/admin/validate/integral/IntegralGoodsValidate.php
Normal file
@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\validate\integral;
|
||||
|
||||
use app\common\basics\Validate;
|
||||
use app\common\enum\IntegralGoodsEnum;
|
||||
use app\common\model\integral\IntegralGoods;
|
||||
|
||||
/**
|
||||
* 积分商品验证
|
||||
* Class IntegralGoodsValidate
|
||||
* @package app\admin\validate\kefu
|
||||
*/
|
||||
class IntegralGoodsValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'id'=>'require|checkGoods',
|
||||
'type' => 'require|in:1,2',
|
||||
'name' => 'require',
|
||||
'image' => 'require',
|
||||
'market_price' => 'checkMarketPrice',
|
||||
'stock' => 'require|integer',
|
||||
'exchange_way' => 'requireIf:type,1',
|
||||
'need_integral' => 'require|integer|checkNeedIntegral',
|
||||
'need_money' => 'requireIf:exchange_way,2|checkNeedMoney',
|
||||
'delivery_way' => 'requireIf:type,1',
|
||||
'express_type' => 'requireIf:delivery_way,1',
|
||||
'express_money' => 'requireIf:express_type,2|checkExpressMoney',
|
||||
'balance' => 'requireIf:type,2|checkBalance',
|
||||
'status' => 'require|in:0,1',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数缺失',
|
||||
'type.require' => '请选择兑换类型',
|
||||
'type.in' => '兑换类型错误',
|
||||
'name.require' => '请填写商品名称',
|
||||
'image.require' => '请上传商品封面',
|
||||
'stock.require' => '请填写发放库存',
|
||||
'stock.integer' => '请填写整数发放库存',
|
||||
'exchange_way.requireIf' => '请选择兑换方式',
|
||||
'need_integral.require' => '请填写兑换积分',
|
||||
'need_integral.integer' => '请填写整数兑换积分',
|
||||
'need_money.requireIf' => '请填写兑换金额',
|
||||
'delivery_way.requireIf' => '请选择物流配送方式',
|
||||
'express_type.requireIf' => '请选择物流方式',
|
||||
'express_money.requireIf' => '请填写运费',
|
||||
'balance.requireIf' => '请填写红包面值',
|
||||
'status.require' => '请选择商品状态',
|
||||
'status.in' => '商品状态参数错误',
|
||||
];
|
||||
|
||||
|
||||
public function sceneAdd()
|
||||
{
|
||||
$this->remove('id', true);
|
||||
}
|
||||
|
||||
public function sceneEdit()
|
||||
{
|
||||
}
|
||||
|
||||
public function sceneDel()
|
||||
{
|
||||
$this->only(['id']);
|
||||
}
|
||||
|
||||
public function sceneDetail()
|
||||
{
|
||||
$this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
protected function checkGoods($value, $rule, $data)
|
||||
{
|
||||
$goods = IntegralGoods::where(['id' => $value])->findOrEmpty();
|
||||
if ($goods->isEmpty()) {
|
||||
return '积分商品不存在';
|
||||
}
|
||||
if ($goods['del'] == 1) {
|
||||
return '积分商品已被删除';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// 验证统一运费时,运费不小于0
|
||||
protected function checkExpressMoney($value, $rule, $data)
|
||||
{
|
||||
// 快递配送 统一运费 运费须大于0
|
||||
if ($data['delivery_way'] == IntegralGoodsEnum::DELIVERY_EXPRESS
|
||||
&& $data['express_type'] == IntegralGoodsEnum::EXPRESS_TYPE_UNIFIED
|
||||
&& $value <= 0
|
||||
) {
|
||||
return '请输入大于0的运费';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// 验证兑换积分需大于0
|
||||
protected function checkNeedIntegral($value, $rule, $data)
|
||||
{
|
||||
if ($value <= 0) {
|
||||
return '请输入大于0的兑换积分';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 验证兑换方式为 积分+金额 时,金额不小于0
|
||||
protected function checkNeedMoney($value, $rule, $data)
|
||||
{
|
||||
if ($data['exchange_way'] == IntegralGoodsEnum::EXCHANGE_WAY_HYBRID && $value <= 0) {
|
||||
return '请输入大于0的兑换金额';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 验证兑换类型为 红包时,红包面额不小于0
|
||||
protected function checkBalance($value, $rule, $data)
|
||||
{
|
||||
if ($data['type'] == IntegralGoodsEnum::TYPE_BALANCE && $value <= 0) {
|
||||
return '请输入大于0的红包面值';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
protected function checkMarketPrice($value)
|
||||
{
|
||||
if (!empty($value) && $value < 0) {
|
||||
return '请输入正确市场价';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
144
app/admin/validate/integral/IntegralOrderValidate.php
Normal file
144
app/admin/validate/integral/IntegralOrderValidate.php
Normal file
@ -0,0 +1,144 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\validate\integral;
|
||||
|
||||
|
||||
use app\common\basics\Validate;
|
||||
use app\common\enum\IntegralGoodsEnum;
|
||||
use app\common\enum\IntegralOrderEnum;
|
||||
use app\common\model\integral\IntegralOrder;
|
||||
|
||||
class IntegralOrderValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数错误',
|
||||
];
|
||||
|
||||
public function sceneDeliveryHandle()
|
||||
{
|
||||
return $this->only(['id'])
|
||||
->append('id','checkDeliveryHandle');
|
||||
}
|
||||
|
||||
public function sceneConfirm()
|
||||
{
|
||||
return $this->only(['id'])
|
||||
->append('id','checkConfirm');
|
||||
}
|
||||
|
||||
public function sceneCancel()
|
||||
{
|
||||
return $this->only(['id'])
|
||||
->append('id','checkCancel');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 检验订单能否发货
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2022/3/3 12:06 下午
|
||||
*/
|
||||
public function checkDeliveryHandle($value,$rule,$data)
|
||||
{
|
||||
$result = IntegralOrder::where(['id'=>$value,'del'=>0])->findOrEmpty()->toArray();
|
||||
if (!$result) {
|
||||
return '订单不存在';
|
||||
}
|
||||
if ($result['delivery_way'] == 0) {
|
||||
return '订单无需快递';
|
||||
}
|
||||
if (!isset($data['shipping_id']) || $data['shipping_id'] == '') {
|
||||
return '请选择快递';
|
||||
}
|
||||
if (!isset($data['invoice_no']) || $data['invoice_no'] == '') {
|
||||
return '请输入快递单号';
|
||||
}
|
||||
if ($result['shipping_status'] == 1) {
|
||||
return '订单已发货';
|
||||
}
|
||||
if ($result['order_status'] != IntegralOrderEnum::ORDER_STATUS_DELIVERY) {
|
||||
return '订单状态不正确,无法发货';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 检验订单能否确认收货
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2022/3/3 3:37 下午
|
||||
*/
|
||||
public function checkConfirm($value,$rule,$data)
|
||||
{
|
||||
$result = IntegralOrder::where(['id'=>$value,'del'=>0])->findOrEmpty()->toArray();
|
||||
if (!$result) {
|
||||
return '订单不存在';
|
||||
}
|
||||
if ($result['order_status'] != IntegralOrderEnum::ORDER_STATUS_GOODS) {
|
||||
return '订单状态不正确,无法确认收货';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @notes 取消订单验证
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/3/3 17:58
|
||||
*/
|
||||
public function checkCancel($value, $rule, $data)
|
||||
{
|
||||
$order = IntegralOrder::findOrEmpty($value);
|
||||
$goods_snap = $order['goods_snap'];
|
||||
|
||||
if ($order->isEmpty()) {
|
||||
return '订单不存在';
|
||||
}
|
||||
|
||||
// 商品类型为红包的不可取消
|
||||
if ($goods_snap['type'] == IntegralGoodsEnum::TYPE_BALANCE) {
|
||||
return '类型为红包的订单不可取消';
|
||||
}
|
||||
|
||||
if ($order['order_status'] >= IntegralOrderEnum::ORDER_STATUS_GOODS) {
|
||||
return '已发货订单不可取消';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user