| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace ghs\models\delivery;
- use bizGhs\order\classes\OrderClass;
- use ghs\models\BaseForm;
- use Yii;
- /**
- * 获取多个平台配送报价表单模型
- * 用于 actionAllDeliveryQuotes 的参数验证
- */
- class AllDeliveryQuotesForm extends BaseForm
- {
- public $orderId; // xhGhsOrder.id
- public $pickupTime; // 取件时间
- public function rules()
- {
- return [
- [['orderId'], 'required'],
- ['orderId', 'integer'],
- ['orderId', 'validateOrderId'],
- ['pickupTime', 'safe'],
- ];
- }
- public function attributeLabels()
- {
- return [
- 'orderId' => '订单ID',
- 'pickupTime' => '取件时间',
- ];
- }
- /**
- * 验证订单ID是否存在且属于当前商户
- * @param $attribute
- */
- public function validateOrderId($attribute)
- {
- if (!$this->hasErrors()) {
- $order = OrderClass::getById($this->orderId, false, 'id, mainId');
- if (empty($order)) {
- $this->addError($attribute, '订单不存在');
- return;
- }
-
- if ($order['mainId'] != Yii::$app->controller->mainId) {
- $this->addError($attribute, '订单不属于当前商户');
- }
- }
- }
- }
|