public function actionIndex($accountId) { if (empty($accountId)) { echo 'accountId is invaild' . PHP_EOL; exit; } $where['accountId'] = new \MongoId($accountId); // delete member info Member::getCollection()->remove($where); //delete MemberLogs MemberLogs::getCollection()->remove($where); //delete scoreHistory ScoreHistory::getCollection()->remove($where); //delete CampaignLog CampaignLog::getCollection()->remove($where); //delete GoodsExchangeLog GoodsExchangeLog::getCollection()->remove($where); //delete MemberStatistics MemberStatistics::getCollection()->remove($where); //delete ReMemberCampaign ReMemberCampaign::getCollection()->remove($where); //delete StatsCampaignProductCodeQuarterly StatsCampaignProductCodeQuarterly::getCollection()->remove($where); //delete StatsMemberCampaignLogDaily StatsMemberCampaignLogDaily::getCollection()->remove($where); //delete StatsMemberDaily StatsMemberDaily::getCollection()->remove($where); //delete StatsMemberGrowthMonthly StatsMemberGrowthMonthly::getCollection()->remove($where); //delete StatsMemberGrowthQuarterly StatsMemberGrowthQuarterly::getCollection()->remove($where); //delete StatsMemberMonthly StatsMemberMonthly::getCollection()->remove($where); //delete StatsMemberPropAvgTradeQuarterly StatsMemberPropAvgTradeQuarterly::getCollection()->remove($where); //delete StatsMemberPropMonthly StatsMemberPropMonthly::getCollection()->remove($where); //delete StatsMemberPropQuaterly StatsMemberPropQuaterly::getCollection()->remove($where); //delete StatsMemberPropTradeCodeAvgQuarterly StatsMemberPropTradeCodeAvgQuarterly::getCollection()->remove($where); //delete StatsMemberPropTradeCodeQuarterly StatsMemberPropTradeCodeQuarterly::getCollection()->remove($where); //delete StatsMemberPropTradeQuarterly StatsMemberPropTradeQuarterly::getCollection()->remove($where); //delete PromotionCodeAnalysis PromotionCodeAnalysis::getCollection()->remove($where); //delete order Order::getCollection()->remove($where); //delete stats member order StatsMemberOrder::getCollection()->remove($where); //delete stats order StatsOrder::getCollection()->remove($where); //delete MembershipDiscount MembershipDiscount::getCollection()->remove($where); //delete couponLog CouponLog::getCollection()->remove($where); echo 'delete data successful.' . PHP_EOL; }
/** * when user redeem the code.we need operate the participate and limit for per-person * @return array */ public static function recordCampaignLimit($campaign, $member, $accountId, $memberIds) { $limitTimes = empty($campaign->limitTimes) ? Campaign::MAX_COUNT : $campaign->limitTimes; $reAttributes = ['$inc' => ['usedTimes' => 1]]; $reCondition = ['campaignId' => $campaign->_id, 'memberId' => $member->_id, 'usedTimes' => ['$lt' => $limitTimes], 'accountId' => $accountId]; $reUpdateResult = ReMemberCampaign::updateAll($reAttributes, $reCondition); if ($reUpdateResult === 0) { $msg = Yii::t('product', 'campaign_participate_freq_limit'); LogUtil::error(['msg' => $msg, 'memberId' => (string) $member->_id, 'campaignId' => (string) $campaign->_id, 'reAttributes' => $reAttributes, 'reCondition' => $reCondition], self::PROMOTION_LOG); return ['campaign' => [], 'status' => self::CODE_STATUS_EXCEEDED, 'message' => $msg]; } //when the member take part in this campaign how many times,just only to count to 1 if (!in_array($member->_id, $memberIds)) { $participantCount = empty($campaign->participantCount) ? Campaign::MAX_COUNT : $campaign->participantCount; $attributes = ['$inc' => ['usedCount' => 1]]; $conditions = ['_id' => $campaign->_id, 'usedCount' => ['$lt' => $participantCount], 'accountId' => $accountId]; $updateResult = Campaign::updateAll($attributes, $conditions); if ($updateResult === 0) { // rollback the reMemberCampaign remaining times $reAttributes = ['$inc' => ['usedTimes' => -1]]; $reCondition = ['campaignId' => $campaign->_id, 'memberId' => $member->_id, 'accountId' => $accountId]; ReMemberCampaign::updateAll($reAttributes, $reCondition); $msg = Yii::t('product', 'campaign_participate_limit'); LogUtil::error(['msg' => $msg, 'memberId' => (string) $member->_id, 'campaignId' => (string) $campaign->_id, 'reAttributes' => $reAttributes, 'reCondition' => $reCondition], self::PROMOTION_LOG); return ['campaign' => [], 'status' => self::CODE_STATUS_EXCEEDED, 'message' => $msg]; } } return ['campaign' => $campaign]; }