コード例 #1
0
ファイル: Statistics.php プロジェクト: timelessmemory/uhkklp
 private function updateScoreRuleStatistics($ruleName, $accountId)
 {
     list($scoreTimes, $scoreMemberCount) = $this->getTimeAndmemberCountWithScore($ruleName, $accountId);
     list($couponTimes, $couponMemberCount) = $this->getTimeAndmemberCountWithCoupon($ruleName, $accountId);
     $times = $scoreTimes + $couponTimes;
     $memberCount = $scoreMemberCount + $couponMemberCount;
     $result = ScoreRule::updateAll(['times' => $times, 'memberCount' => $memberCount], ['name' => $ruleName, 'accountId' => $accountId]);
 }
コード例 #2
0
 /**
  * Update the member property
  *
  * <b>Request Type:</b> PUT<br/>
  * <b>Request Endpoint:</b> http://{{server-domain}}/api/common/member-property/{{id}}
  * <b>Content-type:</b> application/json<br/>
  * <b>Summary</b> This api is for update member property<br/>
  *
  * <b>Request Parameters</b><br/>
  * <pre>
  *     {
  *         "order": 7,
  *         "name": "name123",
  *         "defaultValue": "Devin Jin 1",
  *         "isRequired": true,
  *         "isUnique": true,
  *         "isVisible": true
  *       }
  * </pre>
  */
 public function actionUpdate($id)
 {
     $propertyId = new \MongoId($id);
     $property = MemberProperty::findByPk($propertyId);
     $oldOptions = $property->options;
     $property->load($this->getParams(), '');
     if ($property->save()) {
         //update all the members of the account
         $modifier = ['$set' => ['properties.$.name' => $property->name]];
         if (($property->type == MemberProperty::TYPE_CHECKBOX || $property->type == MemberProperty::TYPE_RADIO) && $property->options != $oldOptions) {
             $modifier['$set']['properties.$.value'] = $property->defaultValue;
         }
         if (!$property->isVisible) {
             $scoreRuleModifier = ['$pull' => ['properties' => $property->_id]];
             $scoreRuleCondition = ['accountId' => $property->accountId, 'name' => ScoreRule::NAME_PERFECT_INFO, 'properties' => $property->_id];
             ScoreRule::updateAll($scoreRuleModifier, $scoreRuleCondition);
         }
         Member::updateAll($modifier, ['properties.id' => $propertyId]);
         return $property;
     } else {
         if ($property->hasErrors()) {
             throw new BadRequestHttpException(Json::encode($property->errors));
         }
     }
     throw new ServerErrorHttpException('Failed to save the object for unknown reason.');
 }