删除卡券
@param $cardId
@return bool
@throws \yii\web\HttpException
176270
public function deleteCard($cardId)
    {
        $result = $this->wechat->httpPost(self::WECHAT_DELETE_CARD_URL, [
            'card_id' => $cardId
        ], [
            'access_token' => $this->wechat->getAccessToken()
        ]);
        return isset($result['errmsg']) && $result['errmsg'] === 'ok' ? true : false;
    }
861880
public function deletGroup($groupId)
    {
        $result = $this->httpRaw(self::WECHAT_GROUP_DELETE_PREFIX, [
            'group' => [
                'id' => $groupId
            ]
        ], [
            'access_token' => $this->getAccessToken()
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'ok';
    }
654326
public function getCard($card_id)
    {
        $url = "https://api.weixin.qq.com/card/get?access_token=ACCESS_TOKEN";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, ['card_id' => $card_id]);
    }
383424
public static MozuUrl deleteUrl(String cardId)
	{
		UrlFormatter formatter = new UrlFormatter("/payments/commerce/payments/cards/{cardId}");
		formatter.formatUrl("cardId", cardId);
		return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.PCI_POD) ;
	}
1207520
public function cardDelete($card_id)
    {
        if (empty($card_id)) {
            $this->setError('缺少错误');

            return false;
        }

        $queryStr            = [];
        $queryStr['card_id'] = $card_id;

        $this->apitype = 'card';
        $this->module  = 'delete';
        $res           = $this->_post('', $queryStr);

        return $res;
    }
596261
public function deleteTag($tagId)
    {
        $result = $this->httpGet(self::WECHAT_TAG_DELETE_PREFIX, [
            'access_token' => $this->getAccessToken(),
            'tagid' => $tagId
        ]);
        return isset($result['errcode']) && !$result['errcode'];
    }
19222
public function get($cardId)
    {
        $params = array('card_id' => $cardId);

        $result = $this->http->jsonPost(self::API_GET, $params);

        return new Bag($result['card']);
    }
65351
public function updateGroupUser($uid, $gid) {
		$user = WechatUser::findOne($uid);
		if(!$user) {
			throw new ErrorException('数据查询失败');
		}

		if($user->groupid == $gid) {
			return true;
		}

		$data = $this->getData('/cgi-bin/groups/members/update', [
			'access_token' => $this->getAccessToken(),
		], Json::encode([
			'openid' => $user->openid,
			'to_groupid' => $gid,
		]));

		$result = $this->errcode == 0;
		if($result && $user->group->updateCounters(['count' => -1])) {
			$user->groupid = $gid;
			if($user->save()) {
				$user->refresh();
				return $user->group->updateCounters(['count' => 1]);
			}
		}

		return $result;
	}
2549
public function updateDefaultCard($cardId)
    {
        // first lets update the default source for the stripe customer
        $customer = $this->asStripeCustomer();
        $customer->default_source = $cardId;
        $result = $customer->save();

        // now lets update the users default card
        $card = $this->getCard($cardId);

        $this->card_brand = $card->brand;
        $this->card_last_four = $card->last4;

        $this->save();

        return $this;
    }
148547
public function create($data, $cardId = null)
    {
        if (isset($cardId)) {
            return $this->client()->put($data, 'payment-cards/{cardId}', ['cardId' => $cardId]);
        }

        return $this->client()->post($data, 'payment-cards');
    }
1336768
public function getCard($cardId)
    {
        if (!$this->stripe_id) {
            return null;
        }

        $customer = $this->asStripeCustomer();

        foreach ($customer->sources->data as $card) {
            if ($card->id === $cardId) {
                return $card;
            }
        }

        return null;
    }
95753
public static function validate($cardId, $selected, $otp) {
    $card = self::load($cardId);
    if(isset($card['usable'][$selected]) && $card['usable'][$selected] === true) {
      if($card['list'][$selected] == $otp) {
        unset($card['usable'][$selected]);

        self::save($card);
        return true;
      }
    }
    return false;
  }
773134
public function actionUpdate($id)
    {
        $request = \Yii::$app->request;
        if ($request->getIsOptions()) {
            return $this->ResponseOptions($this->verbs()['update']);
        }
        $model = $this->findModel($id);
        try{
            if ($model->load(Yii::$app->getRequest()->post()) && $model->save()) {
                return ['success'=>true,'message'=>'更新成功！'];
            }else{
                return ['success'=>false,'message'=>'更新失败，参数错误'];
            }
        }catch (Exception $e){
            throw new Exception($e);
        }

    }
98140
public function getcardlist($openid, $card_id = '')
    {
        if (empty($openid)) {
            $this->setError('缺少openid');

            return false;
        }

        $queryStr           = [];
        $queryStr['openid'] = $openid;

        if (!empty($card_id)) {
            $queryStr['card_id'] = $card_id;
        }

        $this->apitype = 'card';
        $this->module  = 'user';
        $res           = $this->_post('getcardlist', $queryStr);

        return $res;
    }
361697
public function closeOrder($orderId)
    {
        $result = $this->wechat->httpRaw(self::WECHAT_ORDER_CLOSE_PREFIX, [
            'order_id' => $orderId,
        ], [
            'access_token' => $this->wechat->getAccessToken()
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'success';
    }
1123466
public function getOrder($orderId)
    {
        $result = $this->wechat->httpRaw(self::WECHAT_ORDER_GET_PREFIX, [
            'order_id' => $orderId
        ], [
            'access_token' => $this->wechat->getAccessToken()
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'success' ? $result['order'] : false;
    }
1358367
public static function tooMany($userId)
    {
        $sessionKey = 'messages.' . $userId;
        if (Yii::$app->session->has($sessionKey)) {
            $sentAlready = explode('|', Yii::$app->session->get($sessionKey));
            $validated = [];
            foreach ($sentAlready as $t) {
                if (preg_match('/^[0-9]+$/', $t)) {
                    if ($t > time() - self::SPAM_WAIT * 60) {
                        $validated[] = $t;
                    }
                }
            }
            Yii::$app->session->set($sessionKey, implode('|', $validated));
            if (count($validated) >= self::SPAM_MESSAGES) {
                return true;
            }
        }
        return false;
    }