ソースを参照

商城返回值改变

cyzhao 9 ヶ月 前
コミット
869d484472
1 ファイル変更371 行追加324 行削除
  1. 371 324
      Gameserver/App/process/ShopProc.php

+ 371 - 324
Gameserver/App/process/ShopProc.php

@@ -75,341 +75,31 @@ class ShopProc {
         list($type, $typeId, $buyNum) = req()->paras;
         $user = ctx();
 
-        $resultArr = array();
-        $dailyArr = array();
-        $equip = array();
-        $gateGift = array();
+        //$resultArr = array();       
         switch ($type) {
             case EnumShopGift::GateGift_Shop://章节礼包
-                self::BuyShop_GateGift($type, $typeId, $buyNum);
+                $gateGift = self::BuyShop_GateGift($type, $typeId, $buyNum);
                 break;
             case EnumShopGift::Daily_Shop://每日商店                             
-                $mo = GameConfig::shop_daily_getItem($typeId);
-                my_Assert($mo != null, ErrCode::err_const_no);
-
-                my_Assert(in_array($typeId, $user->privateState->dailyShopRandItems), ErrCode::err_const_no);
-                if ($mo->type == 1) {
-                    $getNum = 0;
-                    foreach ($user->privateState->dailyShopReceived as $id) {
-                        if ($id == $typeId) {
-                            $getNum += 1;
-                        }
-                    }
-
-                    if ($getNum >= $mo->freeNum) {
-                        my_Assert($user->privateState->dailyShop_GuangGaoNum < $mo->num, ErrCode::user_shop_GuanggaoFreeNumLimit);
-                        if ($user->privateState->dailyShop_GuangGaoNum >= 1) {
-                            my_Assert(now() - $user->privateState->dailyShop_GuangGaoTs >= $mo->downTs, ErrCode::user_shop_DownTsLimit);
-                        }
-                        $user->privateState->dailyShop_GuangGaoNum += 1;
-                        $user->privateState->dailyShop_GuangGaoTs = now();
-                    }
-                } else {
-                    my_Assert(!in_array($typeId, $user->privateState->dailyShopReceived), ErrCode::user_shop_NotRepeatBuy);
-
-                    switch ($mo->costType) {
-                        case EnumShopCost::Gold:
-                            my_Assert($user->baseInfo->gold >= $mo->costNum, ErrCode::notenough_gold_msg);
-                            ctx()->baseInfo->Consume_Gold($mo->costNum);
-                            break;
-                        case EnumShopCost::Cash:
-                            my_Assert($user->baseInfo->cash >= $mo->costNum, ErrCode::notenough_cash_msg);
-                            ctx()->baseInfo->Consume_Cash($mo->costNum);
-                            break;
-                        default:
-                            break;
-                    }
-
-                    TaskProc::OnBuyNumDailyShop();
-                }
-
-//                $str = explode(',', $mo->reward);
-//                if ($str[0] == 501) {//暂时还没有
-//                }
-                //$dailyArr
-
-                StoreProc::AddMultiItemInStore($mo->reward);
-                ctx()->privateState->dailyShopReceived[] = $typeId;
-                TaskProc::OnBuyNumDailyShop_state();
+                self::BuyShop_Daily($type, $typeId, $buyNum);
                 break;
 
             case EnumShopGift::GemBox_Shop ://宝石宝箱---->2024.8.14 改为可能抽出宝石或是道具
-                $mo = GameConfig::shop_box_getItem($typeId);
-                my_Assert($mo != null, ErrCode::err_const_no);
-
-                if ($buyNum == 1) {
-
-                    $yaoshiArr = explode(',', $mo->cost_one_yaoshi);
-                    $itemId = $yaoshiArr[0];
-                    if (StlUtil::dictHasProperty(ctx()->store->items, $itemId) && ctx()->store->items->$itemId >= $yaoshiArr[1]) {
-                        ctx()->store->removeItem($itemId, $yaoshiArr[1]);
-                    } else {
-                        $cost = $mo->cost_one;
-                        my_Assert($user->baseInfo->cash >= $cost, ErrCode::notenough_cash_msg);
-                        $user->baseInfo->Consume_Cash($cost);
-                    }
-                } elseif ($buyNum == 10) {
-                    $yaoshiArr = explode(',', $mo->cost_ten_yaoshi);
-                    $itemId = $yaoshiArr[0];
-                    if (StlUtil::dictHasProperty(ctx()->store->items, $itemId) && ctx()->store->items->$itemId >= $yaoshiArr[1]) {
-                        ctx()->store->removeItem($itemId, $yaoshiArr[1]);
-                    } else {
-                        $cost = $mo->cost_ten;
-                        my_Assert($user->baseInfo->cash >= $cost, ErrCode::notenough_cash_msg);
-                        $user->baseInfo->Consume_Cash($cost);
-                    }
-                }
-
-                if ($mo->type == 1) {
-                    if ($buyNum == 0) {
-                        $buyNum = 1;
-                        my_Assert(now() - $user->privateState->lastFreeGetTs_ShopBoxCommon >= $mo->freeDownTs * 24 * 60 * 60, ErrCode::user_shop_FreeNumLimit);
-                        $user->privateState->lastFreeGetTs_ShopBoxCommon = now();
-                    }
-                } else if ($mo->type == 2) {
-                    if ($buyNum == 0) {
-                        $buyNum = 1;
-                        my_Assert(now() - $user->privateState->lastFreeGetTs_ShopBoxBright >= $mo->freeDownTs * 24 * 60 * 60, ErrCode::user_shop_FreeNumLimit);
-                        $user->privateState->lastFreeGetTs_ShopBoxBright = now();
-                    }
-                }
-
-                $arr = array();
-                $arr[] = 1;
-                $arr[] = 10;
-                if (!in_array($buyNum, $arr)) {
-                    $buyNum = 1;
-                }
-                TaskProc::OnOpenNumBrightBox($typeId, $buyNum);
-                TaskProc::OnOpenNumAnyBox($buyNum);
-
-                $perList = explode(';', $mo->percent);
-                $allNum = 0;
-                foreach ($perList as $key => $value) {
-                    $str = explode(',', $value);
-                    $allNum += $str[1];
-                }
-
-                $allNum *= 10;
-                for ($i = 0; $i < $buyNum; $i++) {
-                    mt_srand((double) microtime() * 1000000);
-                    $buyCount = 0;
-                    if ($mo->type == 1) {
-                        $user->privateState->buyNum_ShopBoxCommon += 1;
-                        $buyCount = $user->privateState->buyNum_ShopBoxCommon;
-                    } else {
-                        $user->privateState->buyNum_ShopBoxBright += 1;
-                        $buyCount = $user->privateState->buyNum_ShopBoxBright;
-                    }
-
-                    $bichu1 = explode(',', $mo->bichu1);
-                    $qual = 0; //改成道具盒子了 但是这个变量不动了
-                    if ($buyCount % $bichu1[0] == 0) {
-                        $qual = $bichu1[1];
-                    }
-                    if ($mo->bichu2 != null) {
-                        $bichu2 = explode(',', $mo->bichu2);
-                        if ($buyCount % $bichu2[0] == 0) {
-                            $qual = $bichu2[1];
-                        }
-                    }
-
-                    if ($qual == 0) {
-                        $start = 0;
-                        $end = 0;
-                        $randNum = mt_rand(1, $allNum);
-                        foreach ($perList as $k => $val) {
-                            $str = explode(',', $val);
-                            $end += $str[1] * 10;
-                            if ($randNum > $start && $randNum <= $end) {
-                                $qual = $str[0];
-                                break;
-                            }
-                            $start = $end;
-                        }
-                    }
-
-                    if ($qual > 0) {
-                        StoreProc::AddMultiItemInStore($qual . ",1", Enum_StoreSourceType::ShopBox);
-                    }
-                }
-                TaskProc::OnOpenNumBrightBox_state($typeId, $buyNum);
+                self::BuyShop_GemBox($type, $typeId, $buyNum);
 
                 break;
             case EnumShopGift::BujiBox_Shop://补给箱
-                $mo = GameConfig::shop_supply_getItem($typeId);
-                my_Assert($mo != null, ErrCode::err_const_no);
-
-                $list = explode(',', $mo->cost);
-                my_Assert(StlUtil::dictHasProperty($user->store->items, $list[0]), ErrCode::notenough_item);
-
-                $user->store->removeItem($list[0], $list[1]);
-                $user->baseInfo->Add_Gold($mo->gold);
-                if (!StlUtil::dictHasProperty($user->privateState->junbeiShopNumRecord, $typeId)) {
-                    $user->privateState->junbeiShopNumRecord->$typeId = 0;
-                }
-                $num = $user->privateState->junbeiShopNumRecord->$typeId += 1;
-
-                if (!StlUtil::dictHasProperty($user->privateState->supplyBichuDic, $typeId)) {
-                    $user->privateState->supplyBichuDic->$typeId = 0;
-                }
-                $user->privateState->supplyBichuDic->$typeId += 1;
-
-                my_Assert($num <= $mo->limitNum, ErrCode::user_shop_LimitNum);
-                $list = explode(';', $mo->percent);
-                $randNum = rand(0, 10000);
-                $start = 0;
-                $end = 0;
-                $qual = null;
-                foreach ($list as $item) {
-                    $arr = explode(',', $item);
-
-                    $per = $arr[2] * 100;
-                    $end += $per;
-                    if ($randNum >= $start && $randNum < $end) {
-                        $qual = $arr[0] . ',' . $arr[1]; //品阶,稀有度
-                        break;
-                    }
-                    $start = $end;
-                }
-                //必出
-                $bichu = explode(',', $mo->bichu);
-                $qArr = explode(',', $qual);
-                if ($qArr[0] == $bichu[1] && $qArr[1] == $bichu[2]) {//得到必出,重置数量记录
-                    $user->privateState->supplyBichuDic->$typeId = 0;
-                    $qual = $bichu[1] . ',' . $bichu[2];
-                } else {
-                    if ($user->privateState->supplyBichuDic->$typeId == $bichu[0]) {
-                        $qual = $bichu[1] . ',' . $bichu[2];
-                        $user->privateState->supplyBichuDic->$typeId = 0;
-                    }
-                }
-
-                if ($qual != null) {
-                    $str = explode(',', $qual);
-
-                    $equipList = array();
-                    $dic = GameConfig::equip();
-                    foreach ($dic as $tid => $item) {
-                        if ($item->qual == $str[0] && $item->rarity == $str[1]) {
-                            $equipList[] = $item->typeId;
-                        }
-                    }
-
-                    $rNum = rand(0, count($equipList) - 1);
-                    $equipId = $equipList[$rNum];
-                    StoreProc::PutEquipInStore($equipId, 1);
-                    $equip[] = $equipId;
-                }
-
+                $equip = self::BuyShop_BujiBox($type, $typeId, $buyNum);
                 break;
             case EnumShopGift::Cash_Shop://商城-钻石
-                $mo = GameConfig::shop_cash_getItem($typeId);
-                my_Assert($mo != null, ErrCode::err_const_no);
-
-                $tag = false;
-                if (in_array($typeId, $user->privateState->cashShopReceived)) {
-                    $tag = true;
-                }
-
-                $reward = $mo->reward;
-                if (!$tag) {
-                    $reward = $mo->reward . ';' . $mo->reward;
-                }
-
-                StoreProc::AddMultiItemInStore($reward);
-                $user->baseInfo->charge_amt += $mo->price;
-                $user->privateState->cashShopReceived[] = $typeId;
-                TaskProc::OnRecharge();
+                self::BuyShop_Cash($type, $typeId, $buyNum);
                 break;
             case EnumShopGift::Gold_Shop://商城-金币--可以多次购买
-                $mo = GameConfig::shop_gold_getItem($typeId);
-                my_Assert($mo != null, ErrCode::err_const_no);
-
-                $tempNum = 0;
-                foreach ($user->privateState->goldShopReceived as $key) {
-                    if ($key == $typeId) {
-                        $tempNum += 1;
-                    }
-                }
-
-                if ($tempNum >= $mo->freeNum) {
-                    $ts = 0;
-                    switch ($typeId) {
-                        case 1:
-                            $ts = $user->privateState->goldShop_CoolDownTs_1;
-                            break;
-                        case 2:
-                            $ts = $user->privateState->goldShop_CoolDownTs_2;
-                            break;
-                        case 3:
-                            $ts = $user->privateState->goldShop_CoolDownTs_3;
-                            break;
-                    }
-
-                    //收费买
-                    if ($typeId == 1 && $user->privateState->goldShop_GuangGaoNum < $mo->guanggaoNum) {
-                        $user->privateState->goldShop_GuangGaoNum += 1;
-                    } else {
-                        my_Assert($user->baseInfo->cash >= $mo->price, ErrCode::notenough_cash_msg);
-                        ctx()->baseInfo->Consume_Cash($mo->price);
-                    }
-
-                    if ($ts == 0) {
-                        switch ($typeId) {
-                            case 1:
-                                $user->privateState->goldShop_CoolDownTs_1 = now();
-                                break;
-                            case 2:
-                                $user->privateState->goldShop_CoolDownTs_2 = now();
-                                break;
-                            case 3:
-                                $user->privateState->goldShop_CoolDownTs_3 = now();
-                                break;
-                        }
-
-                        //$user->privateState->goldShopReceived[] = $typeId;
-                    } else {
-                        my_Assert(now() - $ts >= $mo->downTs, ErrCode::user_shop_DownTsLimit);
-                        switch ($typeId) {
-                            case 1:
-                                $user->privateState->goldShop_CoolDownTs_1 = now();
-                                break;
-                            case 2:
-                                $user->privateState->goldShop_CoolDownTs_2 = now();
-                                break;
-                            case 3:
-                                $user->privateState->goldShop_CoolDownTs_3 = now();
-                                break;
-                        }
-                    }
-
-                    if ($typeId == 1 && $user->privateState->goldShop_GuangGaoNum == $mo->guanggaoNum) {
-                        $user->privateState->goldShop_GuangGaoNum += 1;
-                        $user->privateState->goldShop_CoolDownTs_1 = 0;
-                    }
-                }
-
-                TaskProc::OnBuyGold();
-                $user->privateState->goldShopReceived[] = $typeId;
-                StoreProc::AddMultiItemInStore($mo->reward);
-
+                self::BuyShop_Gold($type, $typeId, $buyNum);
                 break;
 
             case EnumShopGift::MonthCard_Shop:
-                $mo = GameConfig::shop_monthcard_getItem($typeId);
-                my_Assert($mo != null, ErrCode::err_const_no);
-
-                //$user->privateState->monthCardShop_Received[] = $typeId;                             
-                if ($typeId == 1) {
-                    my_Assert($user->privateState->monthCardShop_ts == 0, ErrCode::err_const_no);
-                    $user->privateState->monthCardShop_ts = now();
-                    StoreProc::AddMultiItemInStore($mo->buy_reward);
-                    EmailProc::SendMonthCardRewardMail(req()->zoneid, req()->uid, $mo->daily_reward);
-                } else {
-                    my_Assert($user->privateState->honourCardShop_ts == 0, ErrCode::err_const_no);
-                    $user->privateState->honourCardShop_ts = now();
-                }
+                self::BuyShop_MonthCard($type, $typeId, $buyNum);    
                 break;
             default:
                 break;
@@ -424,8 +114,8 @@ class ShopProc {
         ctx($user);
         UserProc::updateUserInfo();
         return Resp::ok(array(
-                    'gemBox' => $resultArr,
-                    'gateGift' => $gateGift,
+                    //'gemBox' => $resultArr,
+                    //'gateGift' => $gateGift,
                     'cash' => $user->baseInfo->cash,
                     'gold' => $user->baseInfo->gold,
                     'privateState' => $user->privateState,
@@ -436,9 +126,13 @@ class ShopProc {
                     'reward_Gem' => StoreProc::$reward_Gem,
         ));
     }
+       
+    /*
+     * 商城章节礼包购买
+     */
 
-    //商城章节礼包购买
     public static function BuyShop_GateGift($type, $typeId, $buyNum) {
+        $gateGift = array();
         my_Assert(!in_array($typeId, ctx()->privateState->gateGiftReceived), ErrCode::user_shop_NotRepeatBuy);
 
         $mo = GameConfig::shop_gategift_getItem($typeId);
@@ -469,12 +163,365 @@ class ShopProc {
         }
         ctx()->privateState->gateGiftReceived[] = $typeId;
         ctx()->baseInfo->charge_amt += $mo->curPrice;
+        
+        return $gateGift;
     }
 
-    public static function functionName($param) {
-        
+    /**
+     * 每日商店
+     * @param type $type
+     * @param type $typeId
+     * @param type $buyNum
+     */
+    public static function BuyShop_Daily($type, $typeId, $buyNum) {
+        $mo = GameConfig::shop_daily_getItem($typeId);
+        my_Assert($mo != null, ErrCode::err_const_no);
+
+        my_Assert(in_array($typeId, ctx()->privateState->dailyShopRandItems), ErrCode::err_const_no);
+        if ($mo->type == 1) {
+            $getNum = 0;
+            foreach (ctx()->privateState->dailyShopReceived as $id) {
+                if ($id == $typeId) {
+                    $getNum += 1;
+                }
+            }
+
+            if ($getNum >= $mo->freeNum) {
+                my_Assert(ctx()->privateState->dailyShop_GuangGaoNum < $mo->num, ErrCode::user_shop_GuanggaoFreeNumLimit);
+                if (ctx()->privateState->dailyShop_GuangGaoNum >= 1) {
+                    my_Assert(now() - ctx()->privateState->dailyShop_GuangGaoTs >= $mo->downTs, ErrCode::user_shop_DownTsLimit);
+                }
+                ctx()->privateState->dailyShop_GuangGaoNum += 1;
+                ctx()->privateState->dailyShop_GuangGaoTs = now();
+            }
+        } else {
+            my_Assert(!in_array($typeId, ctx()->privateState->dailyShopReceived), ErrCode::user_shop_NotRepeatBuy);
+
+            switch ($mo->costType) {
+                case EnumShopCost::Gold:
+                    my_Assert(ctx()->baseInfo->gold >= $mo->costNum, ErrCode::notenough_gold_msg);
+                    ctx()->baseInfo->Consume_Gold($mo->costNum);
+                    break;
+                case EnumShopCost::Cash:
+                    my_Assert(ctx()->baseInfo->cash >= $mo->costNum, ErrCode::notenough_cash_msg);
+                    ctx()->baseInfo->Consume_Cash($mo->costNum);
+                    break;
+                default:
+                    break;
+            }
+
+            TaskProc::OnBuyNumDailyShop();
+        }
+
+        StoreProc::AddMultiItemInStore($mo->reward);
+        ctx()->privateState->dailyShopReceived[] = $typeId;
+        TaskProc::OnBuyNumDailyShop_state();
     }
-    
+
+    /**
+     * 宝石宝箱---->2024.8.14 改为可能抽出宝石或是道具
+     */
+    public static function BuyShop_GemBox($type, $typeId, $buyNum) {
+        $mo = GameConfig::shop_box_getItem($typeId);
+        my_Assert($mo != null, ErrCode::err_const_no);
+
+        if ($buyNum == 1) {
+
+            $yaoshiArr = explode(',', $mo->cost_one_yaoshi);
+            $itemId = $yaoshiArr[0];
+            if (StlUtil::dictHasProperty(ctx()->store->items, $itemId) && ctx()->store->items->$itemId >= $yaoshiArr[1]) {
+                ctx()->store->removeItem($itemId, $yaoshiArr[1]);
+            } else {
+                $cost = $mo->cost_one;
+                my_Assert(ctx()->baseInfo->cash >= $cost, ErrCode::notenough_cash_msg);
+                ctx()->baseInfo->Consume_Cash($cost);
+            }
+        } elseif ($buyNum == 10) {
+            $yaoshiArr = explode(',', $mo->cost_ten_yaoshi);
+            $itemId = $yaoshiArr[0];
+            if (StlUtil::dictHasProperty(ctx()->store->items, $itemId) && ctx()->store->items->$itemId >= $yaoshiArr[1]) {
+                ctx()->store->removeItem($itemId, $yaoshiArr[1]);
+            } else {
+                $cost = $mo->cost_ten;
+                my_Assert(ctx()->baseInfo->cash >= $cost, ErrCode::notenough_cash_msg);
+                ctx()->baseInfo->Consume_Cash($cost);
+            }
+        }
+
+        if ($mo->type == 1) {
+            if ($buyNum == 0) {
+                $buyNum = 1;
+                my_Assert(now() - ctx()->privateState->lastFreeGetTs_ShopBoxCommon >= $mo->freeDownTs * 24 * 60 * 60, ErrCode::user_shop_FreeNumLimit);
+                ctx()->privateState->lastFreeGetTs_ShopBoxCommon = now();
+            }
+        } else if ($mo->type == 2) {
+            if ($buyNum == 0) {
+                $buyNum = 1;
+                my_Assert(now() - ctx()->privateState->lastFreeGetTs_ShopBoxBright >= $mo->freeDownTs * 24 * 60 * 60, ErrCode::user_shop_FreeNumLimit);
+                ctx()->privateState->lastFreeGetTs_ShopBoxBright = now();
+            }
+        }
+
+        $arr = array();
+        $arr[] = 1;
+        $arr[] = 10;
+        if (!in_array($buyNum, $arr)) {
+            $buyNum = 1;
+        }
+        TaskProc::OnOpenNumBrightBox($typeId, $buyNum);
+        TaskProc::OnOpenNumAnyBox($buyNum);
+
+        $perList = explode(';', $mo->percent);
+        $allNum = 0;
+        foreach ($perList as $key => $value) {
+            $str = explode(',', $value);
+            $allNum += $str[1];
+        }
+
+        $allNum *= 10;
+        for ($i = 0; $i < $buyNum; $i++) {
+            mt_srand((double) microtime() * 1000000);
+            $buyCount = 0;
+            if ($mo->type == 1) {
+                ctx()->privateState->buyNum_ShopBoxCommon += 1;
+                $buyCount = ctx()->privateState->buyNum_ShopBoxCommon;
+            } else {
+                ctx()->privateState->buyNum_ShopBoxBright += 1;
+                $buyCount = ctx()->privateState->buyNum_ShopBoxBright;
+            }
+
+            $bichu1 = explode(',', $mo->bichu1);
+            $qual = 0; //改成道具盒子了 但是这个变量不动了
+            if ($buyCount % $bichu1[0] == 0) {
+                $qual = $bichu1[1];
+            }
+            if ($mo->bichu2 != null) {
+                $bichu2 = explode(',', $mo->bichu2);
+                if ($buyCount % $bichu2[0] == 0) {
+                    $qual = $bichu2[1];
+                }
+            }
+
+            if ($qual == 0) {
+                $start = 0;
+                $end = 0;
+                $randNum = mt_rand(1, $allNum);
+                foreach ($perList as $k => $val) {
+                    $str = explode(',', $val);
+                    $end += $str[1] * 10;
+                    if ($randNum > $start && $randNum <= $end) {
+                        $qual = $str[0];
+                        break;
+                    }
+                    $start = $end;
+                }
+            }
+
+            if ($qual > 0) {
+                StoreProc::AddMultiItemInStore($qual . ",1", Enum_StoreSourceType::ShopBox);
+            }
+        }
+        TaskProc::OnOpenNumBrightBox_state($typeId, $buyNum);
+    }
+
+    /**
+     * 补给箱
+     * @param type $type
+     * @param type $typeId
+     * @param type $buyNum
+     */
+    public static function BuyShop_BujiBox($type, $typeId, $buyNum) {
+        $equip = array();
+
+        $mo = GameConfig::shop_supply_getItem($typeId);
+        my_Assert($mo != null, ErrCode::err_const_no);
+
+        $list = explode(',', $mo->cost);
+        my_Assert(StlUtil::dictHasProperty(ctx()->store->items, $list[0]), ErrCode::notenough_item);
+
+        ctx()->store->removeItem($list[0], $list[1]);
+        ctx()->baseInfo->Add_Gold($mo->gold);
+        if (!StlUtil::dictHasProperty(ctx()->privateState->junbeiShopNumRecord, $typeId)) {
+            ctx()->privateState->junbeiShopNumRecord->$typeId = 0;
+        }
+        $num = ctx()->privateState->junbeiShopNumRecord->$typeId += 1;
+
+        if (!StlUtil::dictHasProperty(ctx()->privateState->supplyBichuDic, $typeId)) {
+            ctx()->privateState->supplyBichuDic->$typeId = 0;
+        }
+        ctx()->privateState->supplyBichuDic->$typeId += 1;
+
+        my_Assert($num <= $mo->limitNum, ErrCode::user_shop_LimitNum);
+        $plist = explode(';', $mo->percent);
+        $randNum = rand(0, 10000);
+        $start = 0;
+        $end = 0;
+        $qual = null;
+        foreach ($plist as $item) {
+            $arr = explode(',', $item);
+
+            $per = $arr[2] * 100;
+            $end += $per;
+            if ($randNum >= $start && $randNum < $end) {
+                $qual = $arr[0] . ',' . $arr[1]; //品阶,稀有度
+                break;
+            }
+            $start = $end;
+        }
+        //必出
+        $bichu = explode(',', $mo->bichu);
+        $qArr = explode(',', $qual);
+        if ($qArr[0] == $bichu[1] && $qArr[1] == $bichu[2]) {//得到必出,重置数量记录
+            ctx()->privateState->supplyBichuDic->$typeId = 0;
+            $qual = $bichu[1] . ',' . $bichu[2];
+        } else {
+            if (ctx()->privateState->supplyBichuDic->$typeId == $bichu[0]) {
+                $qual = $bichu[1] . ',' . $bichu[2];
+                ctx()->privateState->supplyBichuDic->$typeId = 0;
+            }
+        }
+
+        if ($qual != null) {
+            $str = explode(',', $qual);
+
+            $equipList = array();
+            $dic = GameConfig::equip();
+            foreach ($dic as $tid => $item) {
+                if ($item->qual == $str[0] && $item->rarity == $str[1]) {
+                    $equipList[] = $item->typeId;
+                }
+            }
+
+            $rNum = rand(0, count($equipList) - 1);
+            $equipId = $equipList[$rNum];
+            StoreProc::PutEquipInStore($equipId, 1);
+            $equip[] = $equipId;
+        }
+
+        return $equip;
+    }
+
+    /**
+     * 钻石商城
+     * @param type $type
+     * @param type $typeId
+     * @param type $buyNum
+     */
+    public static function BuyShop_Cash($type, $typeId, $buyNum) {
+        $mo = GameConfig::shop_cash_getItem($typeId);
+        my_Assert($mo != null, ErrCode::err_const_no);
+
+        $tag = false;
+        if (in_array($typeId, ctx()->privateState->cashShopReceived)) {
+            $tag = true;
+        }
+
+        $reward = $mo->reward;
+        if (!$tag) {
+            $reward = $mo->reward . ';' . $mo->reward;
+        }
+
+        StoreProc::AddMultiItemInStore($reward);
+        ctx()->baseInfo->charge_amt += $mo->price;
+        ctx()->privateState->cashShopReceived[] = $typeId;
+        TaskProc::OnRecharge();
+    }
+
+    /**
+     * 金币商城
+     * @param type $type
+     * @param type $typeId
+     * @param type $buyNum
+     */
+    public static function BuyShop_Gold($type, $typeId, $buyNum) {
+        $mo = GameConfig::shop_gold_getItem($typeId);
+        my_Assert($mo != null, ErrCode::err_const_no);
+
+        $tempNum = 0;
+        foreach (ctx()->privateState->goldShopReceived as $key) {
+            if ($key == $typeId) {
+                $tempNum += 1;
+            }
+        }
+
+        if ($tempNum >= $mo->freeNum) {
+            $ts = 0;
+            switch ($typeId) {
+                case 1:
+                    $ts = ctx()->privateState->goldShop_CoolDownTs_1;
+                    break;
+                case 2:
+                    $ts = ctx()->privateState->goldShop_CoolDownTs_2;
+                    break;
+                case 3:
+                    $ts = ctx()->privateState->goldShop_CoolDownTs_3;
+                    break;
+            }
+
+            //收费买
+            if ($typeId == 1 && ctx()->privateState->goldShop_GuangGaoNum < $mo->guanggaoNum) {
+                $user->privateState->goldShop_GuangGaoNum += 1;
+            } else {
+                my_Assert(ctx()->baseInfo->cash >= $mo->price, ErrCode::notenough_cash_msg);
+                ctx()->baseInfo->Consume_Cash($mo->price);
+            }
+
+            if ($ts == 0) {
+                switch ($typeId) {
+                    case 1:
+                        ctx()->privateState->goldShop_CoolDownTs_1 = now();
+                        break;
+                    case 2:
+                        ctx()->privateState->goldShop_CoolDownTs_2 = now();
+                        break;
+                    case 3:
+                        ctx()->privateState->goldShop_CoolDownTs_3 = now();
+                        break;
+                }
+
+                //$user->privateState->goldShopReceived[] = $typeId;
+            } else {
+                my_Assert(now() - $ts >= $mo->downTs, ErrCode::user_shop_DownTsLimit);
+                switch ($typeId) {
+                    case 1:
+                        ctx()->privateState->goldShop_CoolDownTs_1 = now();
+                        break;
+                    case 2:
+                        ctx()->privateState->goldShop_CoolDownTs_2 = now();
+                        break;
+                    case 3:
+                        ctx()->privateState->goldShop_CoolDownTs_3 = now();
+                        break;
+                }
+            }
+
+            if ($typeId == 1 && ctx()->privateState->goldShop_GuangGaoNum == $mo->guanggaoNum) {
+                ctx()->privateState->goldShop_GuangGaoNum += 1;
+                ctx()->privateState->goldShop_CoolDownTs_1 = 0;
+            }
+        }
+
+        TaskProc::OnBuyGold();
+        ctx()->privateState->goldShopReceived[] = $typeId;
+        StoreProc::AddMultiItemInStore($mo->reward);
+    }
+
+    public static function BuyShop_MonthCard($type, $typeId, $buyNum) {
+        $mo = GameConfig::shop_monthcard_getItem($typeId);
+        my_Assert($mo != null, ErrCode::err_const_no);
+
+        //$user->privateState->monthCardShop_Received[] = $typeId;                             
+        if ($typeId == 1) {
+            my_Assert(ctx()->privateState->monthCardShop_ts == 0, ErrCode::err_const_no);
+            ctx()->privateState->monthCardShop_ts = now();
+            StoreProc::AddMultiItemInStore($mo->buy_reward);
+            EmailProc::SendMonthCardRewardMail(req()->zoneid, req()->uid, $mo->daily_reward);
+        } else {
+            my_Assert(ctx()->privateState->honourCardShop_ts == 0, ErrCode::err_const_no);
+            ctx()->privateState->honourCardShop_ts = now();
+        }
+    }
+
     /**
      * 商城每日重置
      */