123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- <?php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 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');
- }
-
-
-
-
- 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;
- }
-
-
-
- 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;
- }
-
-
-
-
-
-
- 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;
- }
-
- }
|