| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace ghs\models\delivery;
- use bizGhs\express\classes\GhsDeliveryOrderClass;
- use ghs\models\BaseForm;
- use Yii;
- /**
- * 获取订单取消原因表单模型
- * 用于 actionCancelReason 的参数验证
- */
- class CancelReasonForm extends BaseForm
- {
- public $ghsOrderId; // 批发订单ID
- public $platform; // 配送平台
- public function rules()
- {
- return [
- [['ghsOrderId', 'platform'], 'required'],
- ['ghsOrderId', 'integer'],
- ['ghsOrderId', 'validateGhsOrderId'],
- ['platform', 'string'],
- ['platform', 'in', 'range' => ['shansong', 'fengniao', 'huolala', 'dada']],
- ];
- }
- public function attributeLabels()
- {
- return [
- 'ghsOrderId' => '批发订单ID',
- 'platform' => '配送平台',
- ];
- }
- /**
- * 验证批发订单ID
- * @param $attribute
- */
- public function validateGhsOrderId($attribute)
- {
- if (!$this->hasErrors()) {
- $gdo = GhsDeliveryOrderClass::getByCondition(
- ['mainId' => Yii::$app->controller->mainId, 'ghsOrderId' => $this->ghsOrderId, 'orderStatus' => ['not in', [-1, -2]]],
- false
- );
-
- if (empty($gdo)) {
- $this->addError($attribute, '未找到对应的配送订单');
- }
- }
- }
- }
|