Пример #1
0
 private function _record($qrcodeId, $type, $associatedId, $content, $qiniuKey, $accountId)
 {
     $qrcode = new Qrcode();
     $qrcode->_id = $qrcodeId;
     $qrcode->type = $type;
     $qrcode->associatedId = $associatedId;
     $qrcode->content = $content;
     $qrcode->qiniuKey = $qiniuKey;
     $qrcode->accountId = $accountId;
     if (!$qrcode->save()) {
         LogUtil::error(['message' => 'Record qrcode fail', 'qrcode' => json_encode($qrcode), 'error' => $qrcode->getErrors()]);
         return false;
     }
     return $qrcode;
 }
Пример #2
0
 public function perform()
 {
     $args = $this->args;
     if (empty($args['mainMember']) || empty($args['otherMemberIds'])) {
         ResqueUtil::log(['Merge member args error' => $args]);
         return;
     }
     $mainMember = unserialize($args['mainMember']);
     $otherMemberIds = unserialize($args['otherMemberIds']);
     //Get Name and phone
     $name = $phone = '';
     foreach ($mainMember->properties as $mainProperty) {
         if ($mainProperty['name'] === Member::DEFAULT_PROPERTIES_NAME) {
             $name = $mainProperty['value'];
         }
         if ($mainProperty['name'] === Member::DEFAULT_PROPERTIES_MOBILE) {
             $phone = $mainProperty['value'];
         }
     }
     ScoreHistory::updateAll(['$set' => ['memberId' => $mainMember->_id]], ['memberId' => ['$in' => $otherMemberIds]]);
     MemberLogs::deleteAll(['memberId' => ['$in' => $otherMemberIds]]);
     CampaignLog::updateAll(['$set' => ['member.id' => $mainMember->_id, 'member.cardNumber' => $mainMember->cardNumber, 'member.name' => $name, 'member.phone' => $phone]], ['member.id' => ['$in' => $otherMemberIds]]);
     PromotionCode::updateAll(['$set' => ['usedBy.memberId' => $mainMember->_id, 'usedBy.memberNumber' => $mainMember->cardNumber]], ['usedBy.memberId' => ['$in' => $otherMemberIds]]);
     GoodsExchangeLog::updateAll(['$set' => ['memberId' => $mainMember->_id, 'memberName' => $name, 'telephone' => $phone]], ['memberId' => ['$in' => $otherMemberIds]]);
     $otherMemberStrIds = [];
     foreach ($otherMemberIds as $otherMemberId) {
         $otherMemberStrIds[] = (string) $otherMemberId;
     }
     Order::updateAll(['$set' => ['consumer.id' => (string) $mainMember->_id, 'consumer.name' => $name, 'consumer.phone' => $phone]], ['consumer.id' => ['$in' => $otherMemberStrIds]]);
     Qrcode::deleteAll(['type' => Qrcode::TYPE_MEMBER, 'associatedId' => ['$in' => $otherMemberIds]]);
 }
Пример #3
0
 public function actionView($code)
 {
     \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $response = [];
     $record = Qrcode::find()->where(['code' => $code])->one();
     $response['QRCode'] = Qrcode::find()->where(['code' => $code])->asArray()->all();
     $response['ImageSequence'] = $record->gallery;
     // $items = ['some', 'array', 'of', 'data' => ['associative', 'array']];
     return json_encode($response);
 }
Пример #4
0
 /**
  * Get subscribe page url
  * @param string $origin
  * @param string $channelId
  */
 private function getSubscribePage($origin, $channelId, $redirectType = '', $redirect = '')
 {
     $domain = Yii::$app->request->hostInfo;
     switch ($origin) {
         case Member::WECHAT:
             $qrcodeUrl = Qrcode::getAttentionQrcode($channelId);
             $url = $domain . '/mobile/common/attention?imageUrl=' . $qrcodeUrl;
             break;
         case Member::WEIBO:
             $domain = Yii::$app->request->hostInfo;
             $url = $domain . '/mobile/common/wbattention?channelId=' . $channelId;
             break;
         case Member::ALIPAY:
             //TODO:
             $url = '/mobile/common/403';
             break;
         default:
             $url = '/mobile/common/404';
             break;
     }
     return $url;
 }
Пример #5
0
 /**
  * migrate qrcode(qrcode-migration)
  */
 public function actionQrcodeMigration($domain)
 {
     $skip = 0;
     $limit = 1000;
     $query = Member::find()->orderBy(['_id' => SORT_ASC]);
     $query = $query->offset($skip)->limit($limit);
     $members = $query->all();
     while (!empty($members)) {
         foreach ($members as $member) {
             if ($member->isDeleted === false) {
                 $memberId = $member->_id;
                 $qrcode = Qrcode::findOne(['associatedId' => $memberId]);
                 if (empty($qrcode)) {
                     $result = Yii::$app->qrcode->create($domain, Qrcode::TYPE_MEMBER, $memberId, $member->accountId);
                     if (!$result) {
                         echo $memberId . PHP_EOL;
                     }
                 }
             }
         }
         $skip += $limit;
         $query = $query->offset($skip)->limit($limit);
         unset($members);
         $members = $query->all();
     }
 }
Пример #6
0
 /**
  * delete coupon qrcode info
  * @param $qrcodes, array
  */
 public static function deleteCouponQrcode($qrcodes)
 {
     if (!empty($qrcodes)) {
         foreach ($qrcodes as $qrcode) {
             if (isset($qrcode['id']) && isset($qrcode['qiniuKey'])) {
                 //delete qiniu file
                 Yii::$app->qiniu->deleteFile($qrcode['qiniuKey']);
                 //delete qrcode info
                 Qrcode::deleteAll(['_id' => new MongoId($qrcode['id'])]);
             }
         }
     }
 }
Пример #7
0
 /**
  * View qrcode detail
  *
  * <b>Request Type</b>: GET<br/><br/>
  * <b>Request Endpoint</b>:http://{server-domain}/api/channel/qrcode/{qrcodeId}<br/><br/>
  * <b>Response Content-type</b>: application/json<br/><br/>
  * <b>Summary</b>: This api is used to view qrcode detail.
  * <br/><br/>
  *
  * <b>Request Params</b>:<br/>
  *     channelId: string<br/>
  *     <br/><br/>
  *
  * <b>Response Params:</b><br/>
  *     array, json array to querie qrcode detail information<br/>
  *     <br/><br/>
  *
  * <br/><br/>
  *
  * <b>Response Example</b>:<br/>
  * <pre>
  * {
  *  "id": "5473ffe7db7c7c2f0bee5c71",
  *  "accountId": "5473ffe7db7c7c2f0bee5c71",
  *  "msgType": "NEWS",
  *  "articles": [
  *      {
  *          "title": "没有",
  *          "description": "",
  *          "url": "http://vincenthou.qiniudn.com/94b6e2756acb030f6f76f690.jpg",
  *          "content": "<p>哈哈哈哈</p>"
  *      }
  *  ],
  *  "sceneId": 1,
  *  "name": "这只是一个测试",
  *  "type": "EVENT",
  *  "description": "招聘一些人才为公司,以备用",
  *  "ticket": "gQFh8DoAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xL3BrampCdVBtVlprc25JVDFHR1RQAAIErHaXVAMEAAAAAA==",
  *  "scanCount": 0,
  *  "subscribeCount": 0,
  *  "createTime": 1421113098304,
  *  "imageUrl": "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQFh8DoAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xL3BrampCdVBtVlprc25JVDFHR1RQAAIErHaXVAMEAAAAAA=="
  * }
  * </pre>
  */
 public function actionView($id)
 {
     $channelId = $this->getChannelId();
     $result = Yii::$app->weConnect->getQrcode($channelId, $id);
     if (!empty($result)) {
         $datas = Qrcode::getQrcodeName([$id]);
         $result['name'] = isset($datas[$id]) ? $datas[$id] : $result['name'];
     }
     return $result;
 }
Пример #8
0
 public function actionView($id)
 {
     $member = Member::findByPk(new \MongoId($id));
     $accountId = $this->getAccountId();
     if (empty($member)) {
         throw new BadRequestHttpException(Yii::t('member', 'invalid_member_id'));
     }
     $scoreHistory = ScoreHistory::getLastByMemberId($member->_id);
     $qrcode = Qrcode::getByTypeAndAssociated(Qrcode::TYPE_MEMBER, $member->_id, $accountId);
     $member = $member->toArray();
     $properties = ArrayHelper::toArray(MemberProperty::getAllByAccount($accountId));
     $mapPropertyDefault = ArrayHelper::map($properties, 'id', 'isDefault');
     foreach ($member['properties'] as &$property) {
         $property['isDefault'] = empty($mapPropertyDefault[$property['id']]) ? false : $mapPropertyDefault[$property['id']];
     }
     $member['qrcodeUrl'] = empty($qrcode->qiniuKey) ? '' : \Yii::$app->qrcode->getUrl($qrcode->qiniuKey);
     $member['scoreProvideTime'] = empty($scoreHistory->createdAt) ? '' : MongodbUtil::MongoDate2String($scoreHistory->createdAt);
     return $member;
 }