'require|checkId', 'confirm' => 'require|in:0,1' ]; protected $message = [ 'id.require' => '参数缺失', 'confirm.require' => '参数缺失', 'confirm.in' => '参数错误', ]; public function sceneVerification() { return $this->only(['id','confirm']) ->append('id','checkVerification'); } public function sceneVerificationQuery() { return $this->only(['id']) ->append('id','checkVerificationQuery'); } public function sceneVerificationDetail() { return $this->only(['id']) ->append('id','checkVerificationDetail'); } /** * @notes 检查订单ID是否存在 * @param $value * @param $rule * @param $data * @return bool|string * @author ljj * @date 2021/8/12 11:44 上午 */ 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 ljj * @date 2021/8/12 11:47 上午 */ public function checkVerification($value,$rule,$data) { $result = Order::where('id', $value)->findOrEmpty(); if ($result['pay_status'] != PayEnum::ISPAID) { return '订单未支付,不允许核销'; } if ($result['delivery_type'] != DeliveryEnum::SELF_DELIVERY) { return '非自提订单,不允许核销'; } if ($result['order_status'] == OrderEnum::STATUS_CLOSE) { return '订单已关闭'; } if (! in_array($result['order_status'], [ OrderEnum::STATUS_WAIT_RECEIVE,OrderEnum::STATUS_WAIT_DELIVERY ])) { return '订单不允许核销'; } if ($result['verification_status'] == OrderEnum::WRITTEN_OFF) { return '订单已核销'; } if ($result['order_type'] == OrderEnum::TEAM_ORDER){ if ($result['is_team_success'] != TeamEnum::TEAM_FOUND_SUCCESS){ return '拼团成功后才能核销'; } } $order_goods = OrderGoods::where(['order_id'=>$result['id']])->select()->toArray(); foreach ($order_goods as $goods) { $after_sale = AfterSale::where(['order_goods_id' => $goods['id'], 'order_id' => $goods['order_id']])->findOrEmpty(); if (!$after_sale->isEmpty() && $after_sale->status == AfterSaleEnum::STATUS_ING) { return '订单商品:'.$goods['goods_name'].' 处于售后中,无法发货'; } } return true; } /** * @notes 检查订单是否已核销 * @param $value * @param $rule * @param $data * @return bool|string * @author ljj * @date 2021/8/26 6:40 下午 */ public function checkVerificationQuery($value,$rule,$data) { $result = Order::where('id', $value)->findOrEmpty(); if ($result['verification_status'] == OrderEnum::NOT_WRITTEN_OFF) { return '订单未核销,无法查询'; } return true; } /** * @notes 检测是否为自提订单 * @param $value * @param $rule * @param $data * @return bool|string * @author ljj * @date 2021/8/27 10:49 上午 */ public function checkVerificationDetail($value,$rule,$data) { $result = Order::where('id', $value)->findOrEmpty(); if ($result['delivery_type'] != DeliveryEnum::SELF_DELIVERY) { return '非自提订单,不允许核销'; } return true; } }