3, 'operator' => '>=', 'message' => '请升级版本,或用小程序'], [['customId'], 'required', 'message' => '请选择客户'], // Though controller checks existence later [['fromType'], 'validateFromType'], [['receiveMobile', 'bookMobile'], 'validateMobile'], [['forward'], 'validateForward'], [['zjGathering'], 'validateZjGathering'], [['unitGoodsPrice'], 'validateUnitGoodsPrice'], [['product'], 'validateProduct'], [['flowerNum', 'version', 'shopAdminId', 'getStaffId', 'groupId', 'fromType', 'customId', 'hasPay', 'sendType', 'forward', 'zjGathering', 'reduceStock', 'needWork', 'isCashier', 'callErrand', 'payWay', 'anonymity', 'needPrint', 'hbId'], 'integer'], [['modifyPrice', 'lsGoodsPrice', 'dealPrice', 'deliveryPrice', 'deliveryDistance', 'weight', 'hbAmount'], 'number'], [['shopAdminName', 'getStaffName', 'bookName', 'receiveMobile', 'bookMobile', 'historyDate', 'product', 'deliveryPlatform', 'deliveryBracketContent', 'pickupTime', 'remark', 'deliveryRemark', 'reachDate', 'reachPeriod', 'cardInfo'], 'string'], [['unitGoodsPrice', 'deliveryAllParams'], 'safe'], ]; } public function attributeLabels() { return [ 'customId' => '客户', 'product' => '花材', 'bookName' => '订花人姓名', 'receiveMobile' => '收花人手机号', 'bookMobile' => '订花人手机号', 'historyDate' => '订单日期', 'lsGoodsPrice' => '价格', ]; } public function validateFromType($attribute, $params) { if (!$this->hasErrors()) { $friendType = dict::getDict('fromType', 'friend'); if ($this->fromType == $friendType && empty($this->bookName)) { $this->addError('bookName', '请填写订花人姓名'); } } } public function validateMobile($attribute, $params) { if (!$this->hasErrors() && !empty($this->$attribute)) { if (!stringUtil::isMobile($this->$attribute)) { $label = $this->getAttributeLabel($attribute); $this->addError($attribute, '请填写正确的' . $label); } } } public function validateForward($attribute, $params) { if (!$this->hasErrors() && $this->forward == 1) { if ($this->hasPay != 1) { // 1 is unPay? No, unPay is usually 0 or 1. Controller says: if ($hasPay != 1) fail('售后付款单只能走线下转账'); // Need to check what 1 means. Controller: if ($hasPay != 1). // Let's assume 1 is the value expected. $this->addError('hasPay', '售后付款单只能走线下转账'); } if (!empty($this->historyDate) && $this->historyDate != date("Y-m-d")) { $this->addError('historyDate', '售后付款单不能修改账单日期,只能今天'); } } } public function validateZjGathering($attribute, $params) { if (!$this->hasErrors() && $this->zjGathering == 1) { if (!is_numeric($this->lsGoodsPrice) || $this->lsGoodsPrice <= 0) { $this->addError('lsGoodsPrice', '请填写价格'); } } } public function validateUnitGoodsPrice($attribute, $params) { if (!$this->hasErrors() && !empty($this->unitGoodsPrice)) { $this->addError($attribute, '此功能停用,有需要请联系管理员'); } } public function validateProduct($attribute, $params) { if (!$this->hasErrors()) { // If groupId is present, product might be empty (refer to controller logic line 668) // Controller: if (empty($productList) && empty($groupId)) { check unitGoodsPrice... } // So if groupId is set, product can be empty. if (!empty($this->groupId)) { return; } // Also if zjGathering is 1, product is constructed in Controller (line 699), so input product can be empty. if ($this->zjGathering == 1) { return; } $productJson = $this->$attribute; if (empty($productJson)) { $this->addError($attribute, '请选择花材'); return; } $productList = json_decode($productJson, true); if (empty($productList)) { $this->addError($attribute, '请选择花材'); } } } }