其余文件
This commit is contained in:
48
app/shop/validate/order/DeliveryBatchImportValidate.php
Normal file
48
app/shop/validate/order/DeliveryBatchImportValidate.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace app\shop\validate\order;
|
||||
|
||||
use app\common\basics\Validate;
|
||||
|
||||
class DeliveryBatchImportValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'lists' => [ 'require', 'checkLists' ],
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'lists.require' => '上传文件不能为空',
|
||||
];
|
||||
|
||||
function checkLists($lists, $rule, $data)
|
||||
{
|
||||
$nums = count($lists) - 1;
|
||||
if ($nums < 1) {
|
||||
return '导入的文件发货信息为空';
|
||||
}
|
||||
|
||||
if ($nums > 2000) {
|
||||
return '单次最多导入2000条发货信息';
|
||||
}
|
||||
|
||||
foreach ($lists as $key => $info) {
|
||||
if (empty(trim($info['A'])) || empty(trim($info['B'])) || empty(trim($info['C']))) {
|
||||
return '发货信息:第' . ($key + 2) . '行存在未填写的发货信息';
|
||||
}
|
||||
|
||||
if (mb_strlen($info['A']) > 255) {
|
||||
return '发货信息:第' . ($key + 2) . '行发货信息 订单号 超过长度255';
|
||||
}
|
||||
|
||||
if (mb_strlen($info['B']) > 255) {
|
||||
return '发货信息:第' . ($key + 2) . '行发货信息超过长度255';
|
||||
}
|
||||
|
||||
if (mb_strlen($info['C']) > 255) {
|
||||
return '发货信息:第' . ($key + 2) . '行发货信息超过长度255';
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
37
app/shop/validate/order/OrderInvoiceValidate.php
Normal file
37
app/shop/validate/order/OrderInvoiceValidate.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\shop\validate\order;
|
||||
|
||||
|
||||
use app\common\basics\Validate;
|
||||
use app\common\model\order\OrderInvoice;
|
||||
|
||||
/**
|
||||
* 订单发票验证
|
||||
* Class OrderInvoiceValidate
|
||||
* @package app\shop\validate\order
|
||||
*/
|
||||
class OrderInvoiceValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|checkInvoice',
|
||||
'status' => 'require',
|
||||
'invoice_number' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '缺少ID字段',
|
||||
'status.require' => '请选择开票状态',
|
||||
'invoice_number.require' => '请填写发票编号',
|
||||
];
|
||||
|
||||
protected function checkInvoice($value, $rule, $data)
|
||||
{
|
||||
$invoice = OrderInvoice::findOrEmpty($value);
|
||||
if ($invoice->isEmpty()) {
|
||||
return '该发票记录不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
36
app/shop/validate/order/OrderPrintValidate.php
Normal file
36
app/shop/validate/order/OrderPrintValidate.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\shop\validate\order;
|
||||
|
||||
|
||||
use app\common\basics\Validate;
|
||||
use app\common\model\printer\Printer;
|
||||
use app\common\model\printer\PrinterConfig;
|
||||
|
||||
class OrderPrintValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|checkPrint',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '缺少ID字段',
|
||||
];
|
||||
|
||||
protected function checkPrint($value, $rule, $data)
|
||||
{
|
||||
$config = PrinterConfig::where(['status' => 1, 'shop_id' => $data['shop_id']])->findOrEmpty();
|
||||
|
||||
if ($config->isEmpty()) {
|
||||
return '请先到小票打印里面配置打印设置';
|
||||
}
|
||||
|
||||
$printer = Printer::where(['config_id' => $config['id'], 'shop_id' => $data['shop_id']])->findOrEmpty();
|
||||
|
||||
if ($printer->isEmpty()) {
|
||||
return '请先添加打印机';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
86
app/shop/validate/order/VerificationValidate.php
Normal file
86
app/shop/validate/order/VerificationValidate.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\shop\validate\order;
|
||||
|
||||
|
||||
use app\common\basics\Validate;
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\enum\TeamEnum;
|
||||
use app\common\model\order\Order;
|
||||
use app\common\model\team\TeamJoin;
|
||||
|
||||
/**
|
||||
* 自提核销验证
|
||||
* Class VerificationValidate
|
||||
* @package app\shop\validate\order
|
||||
*/
|
||||
class VerificationValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'order_id' => 'require|checkId',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'order_id.require' => '参数缺失',
|
||||
];
|
||||
|
||||
public function sceneVerification()
|
||||
{
|
||||
return $this->only(['order_id'])
|
||||
->append('order_id', 'checkVerification');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验订单
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/11/2 14:41
|
||||
*/
|
||||
public function checkId($value, $rule, $data)
|
||||
{
|
||||
$result = Order::where('id', $value)->findOrEmpty();
|
||||
if ($result->isEmpty()) {
|
||||
return '订单不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验订单是否可以提货核销
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/11/2 14:42
|
||||
*/
|
||||
public function checkVerification($value, $rule, $data)
|
||||
{
|
||||
$result = Order::where('id', $value)->findOrEmpty();
|
||||
if ($result['pay_status'] != PayEnum::ISPAID) {
|
||||
return '订单未支付,不允许核销';
|
||||
}
|
||||
if ($result['delivery_type'] != OrderEnum::DELIVERY_TYPE_SELF) {
|
||||
return '非自提订单,不允许核销';
|
||||
}
|
||||
if ($result['verification_status'] == OrderEnum::WRITTEN_OFF) {
|
||||
return '订单已核销';
|
||||
}
|
||||
if ($result['order_type'] == OrderEnum::TEAM_ORDER) {
|
||||
$teamcheck = TeamJoin::where(['order_id' => $value, 'status' => TeamEnum::TEAM_STATUS_SUCCESS])->findOrEmpty();
|
||||
if ($teamcheck->isEmpty()) {
|
||||
return '拼团成功后才能核销';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
52
app/shop/validate/order/VirtualDeliveryValidate.php
Normal file
52
app/shop/validate/order/VirtualDeliveryValidate.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\shop\validate\order;
|
||||
|
||||
|
||||
use app\common\basics\Validate;
|
||||
use app\common\model\order\Order;
|
||||
|
||||
/**
|
||||
* 虚拟发货验证
|
||||
* Class virtualDeliveryValidate
|
||||
* @package app\shop\validate\order
|
||||
*/
|
||||
class VirtualDeliveryValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'order_id' => 'require|checkOrder',
|
||||
'delivery_content' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'order_id.require' => '缺少ID字段',
|
||||
'delivery_content.require' => '请填写发货内容',
|
||||
];
|
||||
|
||||
/**
|
||||
* @notes 校验订单信息
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/4/7 18:26
|
||||
*/
|
||||
protected function checkOrder($value, $rule, $data)
|
||||
{
|
||||
$order = Order::findOrEmpty($value);
|
||||
if ($order->isEmpty()) {
|
||||
return '订单不存在';
|
||||
}
|
||||
|
||||
if ($order['del'] == 1) {
|
||||
return '订单已删除';
|
||||
}
|
||||
|
||||
if ($order['shipping_status'] == 1) {
|
||||
return '此订单已发货';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user