123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 |
- <?php
- //
- //namespace loyalsoft;
- //
- ///**
- // * Description of ShopProc
- // * 商城
- // * @author gwang
- // * @version 1.0.0 Created. 2020.8.19 -gwang
- // */
- //class ShopProc {
- //
- // /**
- // * 逻辑分发
- // * 所有的Proc中必须有这样一个方法
- // */
- // public static function procMain() {
- // switch (req()->cmd) {
- // case CmdCode::shop_limit_maininfo:
- // return self::GetLimitMainInfo();
- // case CmdCode::shop_limit_buy:
- // return self::BuyLimitPackage();
- // case CmdCode::shop_monthlyVIP_Info:
- // return self::GetMonthlyVipInfo();
- // case CmdCode::shop_monthlyVIP_Buy:
- // return self::BuyMonthlyVip();
- // case CmdCode::shop_getDaliySpecial:
- // return self::GetDaliySpecial();
- // case CmdCode::shop_getRechargeRebate:
- // return self::GetRechargeRebate();
- // case CmdCode::shop_dailyShopBuy:
- // return self::dailyShopBuy();
- // default:
- // Err(ErrCode::cmd_err);
- // }
- // }
- //
- // /**
- // * 购买日常商城
- // * @return type
- // */
- // public static function dailyShopBuy() {
- // $itemid = req()->paras[0];
- //
- // $mo = GameConfig::shop_daily_getItem($itemid);
- // my_Assert($mo != null, ErrCode::err_const_no);
- //
- // if($mo->pricetype == 1){
- // my_Assert(ctx()->base(true)->cash >= $mo->price, ErrCode::notenough_cash_msg);
- // ctx()->base(true)->Consume_Cash($mo->price);
- // } else if($mo->pricetype == 2){
- // my_Assert(ctx()->base(true)->gold >= $mo->price, ErrCode::notenough_gold_msg);
- // ctx()->base(true)->Consume_Gold($mo->price);
- // }
- //
- // StoreProc::AddMultiItemInStore($mo->goods);
- //
- // UserProc::updateUserInfo();
- //
- // return Resp::ok(array("store" => ctx()->store(), "cash" => ctx()->baseInfo->cash,"gold"=> ctx()->base(true)->gold,));
- // }
- //
- //
- // /**
- // * 限购礼包触发条件检测
- // */
- // public function checkLimitTsRandGiftTrigger($typeId, $para) {
- // $arr = GameConfig::shop_limitTs_Type_getItemArray($typeId);
- // my_Assert($arr != null, ErrCode::err_const_no);
- // $giftId = 0;
- //
- // $giftArr = array();
- // foreach ($arr as $item) {
- // if ($item->para <= $para) {
- // if (!in_array($item->giftId, ctx()->shopdata->limitTsRewardsList)) {
- // $giftId = $item->giftId;
- // //$giftArr[] = $giftId;
- // //没有触发对应的礼包条件
- // if ($giftId == 0) {
- // continue;
- // }
- // //已经触发过了但是礼包还没有被领取
- // if (count(ctx()->store->triggerLimitTsGift) != 0) {
- // foreach (ctx()->store->triggerLimitTsGift as $val) {
- // if ($val->giftId == $giftId) {
- // continue;
- // }
- // }
- // }
- //
- // //触发对应的礼包条件。则将礼包id存储在
- // $gift = new Ins_Gift();
- // $gift->giftId = $giftId;
- // $gift->startTs = now();
- // $gift->endTs = now() + GameConfig::shop_limit_getItem($giftId)->limit_ts;
- // ctx()->store->triggerLimitTsGift[] = $gift;
- // }
- // }
- // }
- // }
- //
- // public static function GetRechargeRebate() {
- // return Resp::ok(array(
- // "shopdata" => ctx()->shopdata
- // ));
- // }
- //
- // //
- // public static function GetDaliySpecial() {
- // return Resp::ok(array(
- // "shopdata" => ctx()->shopdata
- // ));
- // }
- //
- // /*
- // * 重置每日特惠信息
- // */
- //
- // static function resetDaliySpecialPackages() {
- // if(!StlUtil::dictHasProperty(ctx()->shopdata, 'daliySpecialClear_ts')){
- // ctx()->shopdata->daliySpecialClear_ts = now();
- // }
- //
- // if (ctx()->shopdata->daliySpecialClear_ts == 0) {
- // ctx()->shopdata->daliySpecialClear_ts = now();
- // }
- // $curDay = TimeUtil::totalDays();
- // $lastDay = TimeUtil::totalDays(ctx()->shopdata->daliySpecialClear_ts);
- //
- // if ($curDay - $lastDay == 1 && TimeUtil::Hour(now()) > 5) {//TimeUtil::Hour(ctx()->shopdata->daliySpecialClear_ts) < 5
- // ctx()->shopdata->daliySpecialClear_ts = now();
- // ctx()->shopdata->daliySpecialPackages = array();
- // } else if ($curDay - $lastDay > 1) {
- // ctx()->shopdata->daliySpecialClear_ts = now();
- // ctx()->shopdata->daliySpecialPackages = array();
- // }
- //
- // if (TimeUtil::totalDays(ctx()->shopdata->daliySpecialClear_ts) == TimeUtil::totalDays() #
- // && TimeUtil::Hour(ctx()->shopdata->daliySpecialClear_ts) < 5 && TimeUtil::Hour(now()) > 5) {
- // ctx()->shopdata->daliySpecialClear_ts = now();
- // ctx()->shopdata->daliySpecialPackages = array();
- // }
- // }
- //
- // /**
- // * 获取月卡信息
- // * @return type
- // */
- // public static function GetMonthlyVipInfo() {
- // return Resp::ok(array(
- // "shopdata" => ctx()->shopdata
- // ));
- // }
- //
- // /**
- // * 购买月卡
- // * @return type
- // */
- // public static function BuyMonthlyVip() {
- // $packageId = req()->paras[0]; # 参数; 礼包id
- // $shopdata = new Info_UserShop(ctx()->shopdata);
- // $packageCfg = GameConfig::shop_monthVIP_getItem($packageId);
- // my_Assert(null != $packageCfg, ErrCode::err_const_no);
- // if ($packageCfg->subType == 4) {
- // my_Assert($shopdata->monthlyVIP1_ts + $packageCfg->ExpireTs * 3600 * 24 < now(), ErrCode::shop_monthlyvip_buyed);
- // } elseif ($packageCfg->subType == 5) {
- // my_Assert($shopdata->monthlyVIP2_ts + $packageCfg->ExpireTs * 3600 * 24 < now(), ErrCode::shop_monthlyvip_buyed);
- // }
- // $err = StoreProc::AddMultiItemInStore($packageCfg->pri_reward); # 发放一次性奖励
- // my_Assert(ErrCode::ok == $err, $err);
- // if ($packageCfg->subType == 4) {
- // $shopdata->monthlyVIP1_ts = 3600 * 24 * (totalDays() + 1) - 1;
- // } elseif ($packageCfg->subType == 5) {
- // $shopdata->monthlyVIP2_ts = 3600 * 24 * (totalDays() + 1) - 1;
- // }
- //
- // EmailProc::SendMonthlyVIPDailyReward(req()->zoneid, req()->uid, $packageCfg->name, $packageCfg->daily_reward);
- //
- // ctx()->shopdata = $shopdata; # 回写数据
- // UserProc::updateUserInfo();
- // $user = ctx();
- // return Resp::ok(array(
- // "reward" => $packageCfg->pri_reward,
- // "shopdata" => $shopdata,
- // 'gold' => $user->baseInfo->gold,
- // 'cash' => $user->baseInfo->cash,
- // 'tili' => $user->baseInfo->tili,
- // 'store' => $user->store,
- // 'hero' => $user->heros
- // ));
- // }
- //
- // /**
- // * 【7101】限购礼包主界面
- // */
- // public static function GetLimitMainInfo() {
- // return Resp::ok(array(
- // "shopdata" => ctx()->shopdata
- // ));
- // }
- //
- // /**
- // * 【7102】 购买限购礼包
- // */
- // public static function BuyLimitPackage() {
- // $packageId = req()->paras[0]; # 参数; 礼包id
- // $shopdata = new Info_UserShop(ctx()->shopdata);
- // $packageCfg = GameConfig::shop_limit_getItem($packageId);
- // my_Assert(null != $packageCfg, ErrCode::err_const_no);
- //
- // $arr = array();
- // switch ((int) $packageCfg->subType) {
- // case 1:
- // $shopdata->purchasedDailyLimitPackages[] = $packageId;
- // $arr = $shopdata->purchasedDailyLimitPackages;
- // break;
- // case 2:
- // $shopdata->purchasedWeeklyLimitPackages[] = $packageId;
- // $arr = $shopdata->purchasedWeeklyLimitPackages;
- // break;
- // case 3:
- // $shopdata->purchasedMonthlyLimitPackages[] = $packageId;
- // $arr = $shopdata->purchasedMonthlyLimitPackages;
- // break;
- // default:
- // Err(ErrCode::err_innerfault);
- // }
- // $hasN = count(array_filter($arr, function ($val)use ($packageId) {
- // return $val == $packageId;
- // }));
- // my_Assert($hasN <= $packageCfg->limit_num, ErrCode::shop_limit_max);
- // $itemid = explode(',', $packageCfg->reward)[0]; # 奖励礼包Id
- // $itemMO = GameConfig::item_package_getItem($itemid);
- // my_Assert(null != $itemMO, ErrCode::err_const_no);
- // $err = StoreProc::AddMultiItemInStore($itemMO->contents); # 发放奖励
- // my_Assert(ErrCode::ok == $err, $err);
- // ctx()->shopdata = $shopdata; # 回写数据
- // UserProc::updateUserInfo();
- // $user = ctx();
- // return Resp::ok(array(
- // "reward" => $itemMO->contents,
- // "shopdata" => $shopdata,
- // 'gold' => $user->baseInfo->gold,
- // 'cash' => $user->baseInfo->cash,
- // 'tili' => $user->baseInfo->tili,
- // 'store' => $user->store,
- // 'hero' => $user->heros
- // ));
- // }
- //
- // /**
- // * 每日检查
- // */
- // static function DailyCheck() {
- // CLog::info("shop-每日检查-清除每日/周限量礼包购买记录");
- // $zoneid = req()->zoneid;
- // $uid = req()->uid;
- //
- // ctx()->privateState->battleReviveNum = 0;
- //
- // $shopdata = new Info_UserShop(ctx()->shopdata);
- //
- //
- // if (TimeUtil::Hour(now()) > 5) {
- // $shopdata->dayRechargeAmt = 0; //每日每周限购累计金额统计字段重置
- // $shopdata->dayRechargeReceived = array();
- //
- // $shopdata->purchasedDailyLimitPackages = array(); # 每天重置
- // }
- //
- // if (date("N") == 1 && TimeUtil::Hour(now()) > 5) { # 周一重置
- // $shopdata->purchasedWeeklyLimitPackages = array();
- // $shopdata->weekRechargeAmt = 0;
- // $shopdata->weekRechargeReceived = array();
- // }
- // if (date("d") == 1 && TimeUtil::Hour(now()) > 5) { # 1号重置
- // $shopdata->purchasedMonthlyLimitPackages = array();
- // }
- //
- // if ($shopdata->monthlyVIP1_ts + 30 * 24 * 3600 > now()) {
- // $id = 901001;
- // $card1 = GameConfig::shop_monthVIP_getItem($id);
- // my_Assert(null != $card1, ErrCode::err_const_no);
- // EmailProc::SendMonthlyVIPDailyReward($zoneid, $uid, $card1->name, $card1->daily_reward);
- // }
- // if ($shopdata->monthlyVIP2_ts + 30 * 24 * 3600 > now()) {
- // $id = 901002;
- // $card2 = GameConfig::shop_monthVIP_getItem($id);
- // my_Assert(null != $card2, ErrCode::err_const_no);
- // EmailProc::SendMonthlyVIPDailyReward($zoneid, $uid, $card2->name, $card2->daily_reward);
- // }
- //
- // ctx()->shopdata = $shopdata;
- // }
- //
- //}
|