|
@@ -105,43 +105,6 @@ void IAPCtlShop::showSlideCardsByCoinsIn(cocos2d::Node* pParent, int stillNeedCo
|
|
|
IAPCtlShopUI::getInstance()->showSlideCardsByCoinsIn(pParent, stillNeedCoins);
|
|
|
}
|
|
|
|
|
|
-UserBuyType IAPCtlShop::getUserBuyType(){
|
|
|
- // 如果没有购买记录
|
|
|
- auto buyInfos = IAPUserData::getInstance()->getBuyInfos();
|
|
|
- if(buyInfos.size() == 0) return UserBuyType::NoShopping;
|
|
|
-
|
|
|
- auto conf = IAPConf::getInstance();
|
|
|
- vector<GoodsInfo> goodInfos;
|
|
|
- conf->getAllGoods(goodInfos);
|
|
|
-
|
|
|
- // 按照价格排序 , 价格相同按照是否为special商品排序
|
|
|
- sort(goodInfos.begin(), goodInfos.end(), [](GoodsInfo a,GoodsInfo b){
|
|
|
- if(a.getCostNumber() != b.getCostNumber()) return a.getCostNumber() < b.getCostNumber();
|
|
|
- if(a.style == "mostValued")return true;
|
|
|
- if(b.style == "mostValued")return false;
|
|
|
- return true;
|
|
|
- });
|
|
|
-
|
|
|
- bool onlySpecial = true; // 是否仅购买特惠商品
|
|
|
- bool isBuyExpensive = false; // 是否购买过最贵商品
|
|
|
- float maxAmount = _conf->getMaxAmount();
|
|
|
- for(const auto& buyInfo : buyInfos){
|
|
|
-
|
|
|
- for(size_t i = 0; i < goodInfos.size(); i++){
|
|
|
- if(buyInfo != goodInfos[i].id)continue;
|
|
|
- if(goodInfos[i].type != "mostValued") onlySpecial = false;
|
|
|
- if(goodInfos[i].getCostNumber() == maxAmount) isBuyExpensive = true;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- // 购买过最贵商品
|
|
|
- if(isBuyExpensive)return UserBuyType::LotShopping;
|
|
|
- // 仅购买Special商品
|
|
|
- if(onlySpecial)return UserBuyType::LittleShopping;
|
|
|
- // 正常购物
|
|
|
- return UserBuyType::NormalShopping;
|
|
|
-}
|
|
|
|
|
|
void IAPCtlShop::addUserBuyInfo(std::string commodityID){
|
|
|
iap::IAPUserData::getInstance()->addBuyInfo(commodityID);
|
|
@@ -168,21 +131,5 @@ void IAPCtlShop::clearUserBuyInfo(){
|
|
|
iap::IAPUserData::getInstance()->clearBuyInfo();
|
|
|
}
|
|
|
|
|
|
-float IAPCtlShop::getUserBuyMaxAmount(){
|
|
|
- std::vector<std::string> buyInfoIDs = IAPUserData::getInstance()->getBuyInfos();
|
|
|
-
|
|
|
- std::set<std::string> buyInfoID;
|
|
|
- // 去重
|
|
|
- for(const auto& info : buyInfoIDs){
|
|
|
- buyInfoID.insert(info);
|
|
|
- }
|
|
|
- // 提取最大金额
|
|
|
- float maxn = -1;
|
|
|
- for(const auto& id : buyInfoID){
|
|
|
- float coinNum = _conf->getCoinNum(id);
|
|
|
- maxn = maxn > coinNum ? maxn : coinNum;
|
|
|
- }
|
|
|
- return maxn;
|
|
|
-}
|
|
|
|
|
|
NS_IAP_END
|