/** * The default implementation returns the names of the columns whose values have been populated into Product. */ public function fields() { return array_merge(parent::fields(), ['sku', 'name', 'pictures', 'category' => function () { $categorys = $this->category; if (!empty($categorys['id'])) { $categorys['id'] = $categorys['id'] . ''; } return $categorys; }, 'intro' => function () { return ProductInfo::findByPk($this->_id)['intro']; }, 'isAssigned' => function () { if ($this->isBindCode) { return true; } else { return false; } }, 'codeNum' => function () { return PromotionCode::count(['productId' => $this->_id]); }, 'isSelected' => function () { $goods = Goods::findOne(['productId' => $this->_id]); if (empty($goods)) { return false; } else { return true; } }]); }
/** * The default implementation returns the names of the columns whose values have been populated into ChatConversation. */ public function fields() { return array_merge(parent::fields(), ['name', 'url', 'createdBy', 'picUrl', 'content', 'fields', 'createdAt' => function () { return MongodbUtil::MongoDate2String($this->createdAt, 'Y-m-d H:i:s'); }, 'channel' => function () { return $this->channel . ''; }]); }
/** * The default implementation returns the names of the columns whose values have been populated into Product. */ public function fields() { return array_merge(parent::fields(), ['order', 'name', 'type', 'options', 'defaultValue', 'isRequired', 'createdAt' => function () { return MongodbUtil::MongoDate2String($this->createdAt, 'Y-m-d H:i:s'); }, 'updatedAt' => function () { return MongodbUtil::MongoDate2String($this->updatedAt, 'Y-m-d H:i:s'); }]); }
/** * The default implementation returns the names of the columns whose values have been populated into FaqCategory. */ public function fields() { return array_merge(parent::fields(), ['name', 'questions' => function ($model) { if (self::$isFetchFaqs) { return $this->getQuestions(); } return ''; }, 'isDefault']); }
/** * The default implementation returns the names of the columns whose values have been populated into MemberShipCard. */ public function fields() { return array_merge(parent::fields(), ['name', 'poster', 'fontColor', 'privilege', 'condition', 'usageGuide', 'isEnabled', 'isDefault', 'isAutoUpgrade', 'scoreResetDate', 'provideCount' => function () { return Member::count(['cardId' => $this->_id]); }, 'createdAt' => function () { return MongodbUtil::MongoDate2String($this->createdAt, 'Y-m-d H:i:s'); }, 'updatedAt' => function () { return MongodbUtil::MongoDate2String($this->updatedAt, 'Y-m-d H:i:s'); }]); }
public function fields() { return array_merge(parent::fields(), ['title', 'description', 'status', 'creator', 'assignee', 'createdAt' => function ($model) { return MongodbUtil::MongoDate2msTimeStamp($model['createdAt']); }, 'isDeleted', 'origin', 'hasAttachment' => function ($model) { if (isset($model['attachmentIds']) && count($model['attachmentIds']) > 0) { return true; } return false; }]); }
/** * The default implementation returns the names of the columns whose values have been populated into productCategory. */ public function fields() { return array_merge(parent::fields(), ['name', 'properties', 'isDeleteCategory' => function () { $condition = ['category.id' => $this->_id]; $info = Product::findOne($condition); if (!empty($info) || self::RESERVATION_CATEGORY_NAME == $this->name) { return false; } else { return true; } }]); }
/** * The default implementation returns the names of the columns. */ public function fields() { return array_merge(parent::fields(), ['name', 'states', 'actions', 'isActivated', 'users' => function () { $users = []; if (!empty($this->users)) { $query = new Query(); // compose the query $query->select(['name'])->from('user')->where(['in', '_id', $this->users]); // execute the query $data = $query->all(); foreach ($data as $user) { $users[] = $user['name']; } } return $users; }]); }
/** * The default implementation returns the names of the columns whose values have been populated into storeGoods. */ public function fields() { return array_merge(parent::fields(), ['storeId' => function () { return (string) $this->storeId; }, 'productId' => function () { return (string) $this->productId; }, 'pictures', 'status', 'onSaleTime' => function () { return empty($this->onSaleTime) ? '' : MongodbUtil::MongoDate2String($this->onSaleTime, 'Y-m-d H:i'); }, 'offShelfTime' => function () { return empty($this->offShelfTime) || !empty($this->onSaleTime) ? '' : MongodbUtil::MongoDate2String($this->offShelfTime, 'Y-m-d H:i'); }, 'categoryName' => function () { $category = ProductCategory::findByPk($this->categoryId); if ($category) { return $category['name']; } else { return ''; } }, 'productName', 'sku', 'price' => function () { return self::formatPrice($this->price); }, 'createdAt' => function () { return empty($this->createdAt) ? '' : MongodbUtil::MongoDate2String($this->createdAt, 'Y-m-d H:i'); }]); }
/** * The default implementation returns the names of the columns whose values have been populated into user. */ public function fields() { return array_merge(parent::fields(), ['priceType', 'enabledMods', 'availableExtMods', 'tags', 'company', 'phone', 'name']); }
/** * The default implementation returns the names of the columns whose values have been populated into memberStatistics. */ public function fields() { $fields = array_merge(parent::fields(), ['locationStatistics']); return $fields; }
/** * The default implementation returns the names of the columns whose values have been populated into Member. */ public function fields() { return array_merge(parent::fields(), ['socials', 'card' => function () { $card = MemberShipCard::findByPk($this->cardId); return $card; }, 'createdAt' => function () { return MongodbUtil::MongoDate2String($this->createdAt, 'Y-m-d H:i:s'); }, 'socialAccount' => function () { if (!empty($this->socialAccountId)) { $channel = Channel::getByChannelId($this->socialAccountId, $this->accountId); } $result = ['id' => $this->socialAccountId, 'origin' => $this->origin]; $result['name'] = empty($channel->name) ? '' : $channel->name; $result['type'] = empty($channel->type) ? '' : $channel->type; $result['status'] = empty($channel->status) ? '' : $channel->status; return $result; }, 'socialMember' => function () { if (!empty($this->openId) && !empty($this->socialAccountId)) { try { $socialMember = \Yii::$app->weConnect->getFollowerByOriginId($this->openId, $this->socialAccountId); } catch (ApiDataException $e) { $socialMember = ''; } } $result = null; if (!empty($socialMember) && !empty($socialMember['nickname'])) { $result = $socialMember['nickname']; } return $result; }, 'properties' => function () { $result = []; foreach ($this->properties as $property) { $property['id'] = $property['id'] . ''; $result[] = $property; } return $result; }, 'cardProvideTime' => function () { return MongodbUtil::MongoDate2String($this->cardProvideTime, 'Y-m-d H:i:s'); }, 'cardExpired' => function () { if (!empty($this->cardExpiredAt) && $this->cardExpiredAt < TimeUtil::msTime()) { return 1; } else { return 0; } }, 'avatar', 'location', 'tags', 'score', 'remarks', 'cardNumber', 'unionId', 'totalScore', 'cardExpiredAt' => function () { return empty($this->cardExpiredAt) ? '' : TimeUtil::msTime2String($this->cardExpiredAt); }, 'birth', 'openId', 'qrcodeViewed', 'totalScoreAfterZeroed', 'isDisabled']); }
/** * The default implementation returns the names of the columns whose values have been populated into user. */ public function fields() { return array_merge(parent::fields(), ['parentId' => function ($model) { return $model->_id . ''; }, 'pageId' => function ($model) { return $model->_id . ''; }, 'name', 'jsonConfig', 'color', 'order', 'tabIndex', 'tabs']); }
/** * The default implementation returns the names of the columns whose values have been populated into ChatConversation. */ public function fields() { return array_merge(parent::fields(), ['name', 'isDefault', 'fields']); }
/** * The default implementation returns the names of the columns whose values have been populated into Goods. */ public function fields() { return array_merge(parent::fields(), ['productId' => function () { return $this->productId . ''; }, 'pictures', 'score', 'total', 'usedCount', 'status', 'onSaleTime' => function () { if ($this->onSaleTime) { return MongodbUtil::MongoDate2String($this->onSaleTime, 'Y-m-d H:i'); } else { return ''; } }, 'offShelfTime' => function () { return empty($this->offShelfTime) || !empty($this->onSaleTime) ? '' : MongodbUtil::MongoDate2String($this->offShelfTime, 'Y-m-d H:i'); }, 'url', 'order', 'categoryName' => function () { $category = ProductCategory::findByPk($this->categoryId); if ($category) { return $category['name']; } else { return ''; } }, 'productName', 'sku', 'clicks', 'description', 'receiveModes', 'addresses' => function () { $addresses = []; if (!empty($this->addresses)) { foreach ($this->addresses as $address) { $addresses[] = (string) $address; } } return $addresses; }, 'createdAt' => function () { return MongodbUtil::MongoDate2String($this->createdAt, 'Y-m-d H:i'); }]); }
/** * The default implementation returns the names of the columns whose values have been populated into coupon. */ public function fields() { return array_merge(parent::fields(), ['type', 'title', 'total', 'limit', 'time' => function () { $time = $this->time; if ($time['type'] == self::COUPON_ABSOLUTE_TIME) { $time['beginTime'] = MongodbUtil::MongoDate2String($time['beginTime']); $time['endTime'] = MongodbUtil::MongoDate2String($time['endTime']); } return $time; }, 'url', 'picUrl', 'tip', 'description', 'usageNote', 'phone', 'storeType', 'stores' => function () { $stores = $this->stores; if (!empty($stores)) { foreach ($stores as &$store) { $store['id'] = (string) $store['id']; } } return $stores; }, 'qrcodes' => function () { $qrcodes = $this->qrcodes; if (!empty($qrcodes)) { foreach ($qrcodes as &$qrcode) { $qrcode['id'] = (string) $qrcode['id']; $qrcode['url'] = Yii::$app->qrcode->getUrl($qrcode['qiniuKey']); unset($qrcode['qiniuKey']); } } return $qrcodes; }, 'discountAmount', 'discountCondition', 'reductionAmount']); }
/** * The default implementation returns the names of the columns whose values have been populated into user. */ public function fields() { return array_merge(parent::fields()); }
/** * The default implementation returns the names of the columns whose values have been populated into campaign. */ public function fields() { return array_merge(parent::fields(), ['name', 'startTime' => function () { return MongodbUtil::MongoDate2String($this->startTime, 'Y-m-d H:i:00'); }, 'endTime' => function () { return MongodbUtil::MongoDate2String($this->endTime, 'Y-m-d H:i:00'); }, 'participantCount', 'limitTimes', 'promotion' => function () { $promotion = $this->promotion; $data = []; if (!empty($promotion['data'])) { $products = Product::getByIds($promotion['data']); foreach ($products as $product) { $data[] = ['id' => $product->_id . '', 'name' => $product->name]; } $promotion['data'] = $data; } if (is_array($promotion['products'])) { foreach ($promotion['products'] as &$products) { $products .= ''; } } return $promotion; }, 'isActivated', 'isExpired' => function () { $nextMinute = strtotime('+ 1 minute - ' . date('s') . 'seconds'); return MongodbUtil::MongoDate2TimeStamp($this->endTime) < $nextMinute; }]); }
/** * The default implementation returns the names of the columns whose values have been populated into ChatMessage. */ public function fields() { return array_merge(parent::fields(), ['content', 'isReply', 'sentTime', 'conversationId' => function () { return $this->conversationId . ''; }]); }
/** * The default implementation returns the names of the columns whose values have been populated into user. */ public function fields() { return array_merge(parent::fields(), ['name', 'branchName', 'type', 'subtype', 'telephone', 'location', 'position', 'image', 'businessHours', 'description', 'wechat', 'weibo', 'alipay']); }
public function fields() { return array_merge(parent::fields(), ['mobile', 'token', 'deviceType']); }
/** * The default implementation returns the names of the columns whose values have been populated into user. */ public function fields() { return array_merge(parent::fields(), ['name']); }
/** * The default implementation returns the names of the columns whose values have been populated into ChatConversation. */ public function fields() { return array_merge(parent::fields(), ['conversation', 'status', 'desk', 'client', 'lastChatTime' => function () { return TimeUtil::msTime2String($this->lastChatTime); //millisecond time stamp to string }]); }
/** * The default implementation returns the names of the columns whose values have been populated into Product. */ public function fields() { return array_merge(parent::fields(), ['storeId' => function ($model) { return (string) $model->storeId; }, 'phone', 'badge', 'name', 'gender', 'birthday', 'channel', 'qrcodeUrl', 'isActivated' => function ($model) { $status = $model->isActivated ? 'ENABLE' : 'DISABLE'; return $status; }, 'accountId' => function ($model) { return (string) $model->accountId; }, 'createdAt' => function ($model) { return MongodbUtil::MongoDate2String($model->createdAt, 'Y-m-d H:i:s'); }]); }
/** * The default implementation returns the names of the columns whose values have been populated into qrcode. */ public function fields() { return array_merge(parent::fields(), ['type', 'associatedId' => function () { return (string) $this->associatedId; }]); }
/** * The default implementation returns the names of the columns whose values have been populated into FAQ. */ public function fields() { return array_merge(parent::fields(), ['question', 'answer', 'faqCategoryId']); }
/** * The default implementation returns the names of the columns whose values have been populated into applications. */ public function fields() { return array_merge(parent::fields(), ['name', 'privateKey', 'icon', 'content', 'createdAt' => function () { return MongodbUtil::MongoDate2TimeStamp($this->createdAt); }]); }
public function extraFields() { return array_merge(parent::fields(), ['store' => function () { return Store::findByPk($this->storeId); }]); }
/** * The default implementation returns the names of the columns whose values have been populated into Member. */ public function fields() { return array_merge(parent::fields(), ['name', 'type', 'score', 'triggerTime', 'description', 'isEnabled', 'times', 'memberCount', 'couponId' => function () { return (string) $this->couponId; }, 'rewardType', 'properties' => function () { $properties = []; if (!empty($this->properties)) { foreach ($this->properties as $property) { $properties[] = (string) $property; } } return $properties; }, 'startTime' => function () { return MongodbUtil::MongoDate2String($this->startTime); }, 'endTime' => function () { return MongodbUtil::MongoDate2String($this->endTime); }]); }
/** * The default implementation returns the names of the columns whose values have been populated into user. */ public function fields() { return array_merge(parent::fields(), ['accessToken', 'expireTime', 'userId', 'accountId']); }