ActiveProc.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. <?php
  2. /*
  3. * To change this license header, choose License Headers in Project Properties.
  4. * To change this template file, choose Tools | Templates
  5. * and open the template in the editor.
  6. */
  7. namespace loyalsoft;
  8. /**
  9. * Description of ActiveProc
  10. *
  11. * @author c'y'zhao
  12. */
  13. class ActiveProc {
  14. /**
  15. * 逻辑分发
  16. * 所有的Proc中必须有这样一个方法
  17. * @param Req $req
  18. */
  19. public static function procMain($req) {
  20. switch ($req->cmd) {
  21. case CmdCode::cmd_active_day7_drawreward: # 6101 签到
  22. return ActiveProc::Day7_DrawReward();
  23. case CmdCode::cmd_active_drawPackageByCode: # 6102 兑换码礼包
  24. return ActiveProc::drawPackageByCode();
  25. case CmdCode::cmd_active_lottery_Tree: # 6103 转盘抽奖
  26. return ActiveProc::lottery_Tree();
  27. case CmdCode::cmd_active_lottery_Tree_cashExchange: # 6104 元宝兑换抽奖券
  28. return ActiveProc::lottery_Tree_cashExchange();
  29. case CmdCode::cmd_active_lotteryNumBox_RewardReceived: # 6105 抽奖宝箱奖励领取
  30. return ActiveProc::lotteryNumBox_RewardReceived();
  31. case CmdCode::cmd_active_LotteryExchangeItem: # 6106 兑换
  32. return ActiveProc::LotteryExchangeItem();
  33. case CmdCode::cmd_active_day7_accumulateDrawreward: # 6107 7日签到 累计天数宝箱奖励领取
  34. return ActiveProc::Day7_AccumulateDrawreward();
  35. case CmdCode::cmd_active_limitTsBuy: # 6108 限时贩售
  36. return ActiveProc::LimitTsBuy_Drawreward();
  37. case CmdCode::cmd_active_battlePassDrawReward: # 6109 战令奖励领取
  38. return ActiveProc::BattlePassDrawReward();
  39. default:
  40. Err(ErrCode::cmd_err);
  41. }
  42. }
  43. static function ResetActive() {
  44. }
  45. /**
  46. * 6106 抽奖里面的兑换
  47. * @return type
  48. */
  49. public static function LotteryExchangeItem() {
  50. list($id) = req()->paras;
  51. $arr = array_count_values(ctx()->privateState->lotteryExchange);
  52. $num = $arr[$id];
  53. $mo = GameConfig::activity_lotteryitem_exchange_getItem($id);
  54. my_Assert($mo != null, ErrCode::err_const_no);
  55. my_Assert($num < $mo->exchangeNum, ErrCode::active_lotteryExchangeNumLimit);
  56. $itemNum = 0;
  57. $cost = explode(',', $mo->cost);
  58. $costId = $cost[0];
  59. if (StlUtil::dictHasProperty(ctx()->store->items, $costId)) {
  60. $itemNum = ctx()->store->items->$costId;
  61. }
  62. my_Assert($itemNum >= $cost[1], ErrCode::notenough_item);
  63. ctx()->store->removeItem($costId, $cost[1]);
  64. StoreProc::AddMultiItemInStore($mo->reward);
  65. ctx()->privateState->lotteryExchange[] = $id;
  66. UserProc::updateUserInfo();
  67. return Resp::ok(array(
  68. "store" => ctx()->store,
  69. 'cash' => ctx()->baseInfo->cash,
  70. 'gold' => ctx()->baseInfo->gold,
  71. 'reward' => StoreProc::$reward,
  72. ));
  73. }
  74. /**
  75. * 6105 抽奖宝箱奖励领取
  76. * @return type
  77. */
  78. public static function lotteryNumBox_RewardReceived() {
  79. list($id) = req()->paras;
  80. $mo = GameConfig::activity_lotterynum_accumulate_getItem($id);
  81. my_Assert($mo != null, ErrCode::err_const_no);
  82. my_Assert(ctx()->privateState->lotteryNum >= $id, ErrCode::active_lotteryNumNotEnough);
  83. my_Assert(!in_array($id, ctx()->privateState->lotteryNumRewardReceived), ErrCode::active_hasgetted);
  84. StoreProc::AddMultiItemInStore($mo->reward);
  85. ctx()->privateState->lotteryNumRewardReceived[] = $id;
  86. UserProc::updateUserInfo();
  87. return Resp::ok(array(
  88. "store" => ctx()->store,
  89. 'cash' => ctx()->baseInfo->cash,
  90. 'reward' => StoreProc::$reward,
  91. ));
  92. }
  93. /**
  94. * 6103 转盘抽奖
  95. */
  96. public static function lottery_Tree() {
  97. list($num) = req()->paras; //抽奖次数 1 10
  98. $arr = array(1, 10);
  99. my_Assert(in_array($num, $arr), ErrCode::active_lotteryNumErr);
  100. my_Assert(ctx()->privateState->lotteryNum + $num <= glc()->activity_lottery_allNum, ErrCode::active_lotteryNumLimit);
  101. $cost = "";
  102. if ($num == 1) {
  103. $cost = glc()->activity_lottery_tree_one_cost;
  104. } else {
  105. $cost = glc()->activity_lottery_tree_ten_cost;
  106. }
  107. my_Assert($cost != "", ErrCode::active_lotteryCostErr);
  108. $costArr = explode(',', $cost);
  109. $item = ctx()->store->items;
  110. $costId = $costArr[0];
  111. $costNum = $costArr[1];
  112. my_Assert(StlUtil::dictHasProperty($item, $costId) && $item->$costId >= $costNum, ErrCode::notenough_item);
  113. ctx()->store->removeItem($costId, $costNum);
  114. if (ctx()->privateState->lotteryNum < glc()->activity_lottery_allNum) {
  115. ctx()->privateState->lotteryNum += $num;
  116. }
  117. $rewardList = array();
  118. $dic = GameConfig::activity_lottery_tree();
  119. for ($i = 0; $i < $num; $i++) {
  120. $randNum = random_int(1, 10000);
  121. $start = 0;
  122. $end = 0;
  123. foreach ($dic as $id => $mo) {
  124. $end += $mo->per * 10000;
  125. if ($randNum > $start && $randNum <= $end) {
  126. $rewardList[] = $id;
  127. StoreProc::AddMultiItemInStore($mo->reward);
  128. $prize = explode(',', $mo->reward);
  129. if (GameConfig::item_getItem($prize[0])->itemType == 201 && GameConfig::item_getItem($prize[0])->quality >= 4 && ctx()->privateState->lottery_qualGem_4 == 0) {
  130. ctx()->privateState->lottery_qualGem_4 = 1;
  131. }
  132. break;
  133. }
  134. $start = $end;
  135. }
  136. }
  137. UserProc::updateUserInfo();
  138. return Resp::ok(array(
  139. "store" => ctx()->store,
  140. 'reward' => StoreProc::$reward,
  141. 'reward_Gem' => StoreProc::$reward_Gem,
  142. 'gold' => ctx()->baseInfo->gold,
  143. 'cash' => ctx()->baseInfo->cash,
  144. 'lotteryNum' => ctx()->privateState->lotteryNum,
  145. 'indexReward' => $rewardList,
  146. ));
  147. }
  148. /**
  149. * 元宝兑换寻宝券
  150. * @return type
  151. */
  152. public static function lottery_Tree_cashExchange() {
  153. list($num) = req()->paras; //抽奖次数 1 10
  154. $cost = "";
  155. if ($num == 1) {
  156. $cost = glc()->activity_lottery_tree_one_cost;
  157. } else {
  158. $cost = glc()->activity_lottery_tree_ten_cost;
  159. }
  160. my_Assert($cost != "", ErrCode::active_lotteryCostErr);
  161. $costArr = explode(',', $cost);
  162. $item = ctx()->store->items;
  163. $costId = $costArr[0];
  164. $costNum = $costArr[1];
  165. $selfNum = 0;
  166. if (StlUtil::dictHasProperty($item, $costId)) {
  167. $selfNum = $item->$costId;
  168. }
  169. my_Assert($selfNum < $costNum, ErrCode::active_lottery_unwantedExchange);
  170. $costNum -= $selfNum;
  171. $cash = glc()->activity_lottery_oneCost_cash * $costNum;
  172. my_Assert(ctx()->baseInfo->cash >= $cash, ErrCode::notenough_cash_msg);
  173. ctx()->baseInfo->Consume_Cash($cash);
  174. StoreProc::AddMultiItemInStore($costId . ',' . $costNum);
  175. UserProc::updateUserInfo();
  176. return Resp::ok(array(
  177. "store" => ctx()->store,
  178. 'cash' => ctx()->baseInfo->cash,
  179. ));
  180. }
  181. /**
  182. * 6102 兑换码礼包
  183. */
  184. static function drawPackageByCode() {
  185. list($activeId, $codestring) = req()->paras; # 取参数 活动id, 兑换码
  186. $codePlatStr = "";
  187. $packageID = 0;
  188. if (self::PublicTokenCodeCheck($codestring)) {
  189. $packageInfo = GameConfig::token_PublicGift_getItem($codestring);
  190. my_Assert($packageInfo->expirets >= now() && $packageInfo->startTs <= now(),
  191. ErrCode::active_activecode_outtime);
  192. my_Assert(!in_array($packageInfo->id, ctx()->privateState->usedTokens), ErrCode::active_hasgetted); # 已经领取过该礼包了
  193. $packageID = $packageInfo->id;
  194. //$err = StoreProc::AddMultiItemInStore($packageInfo->reward); # 发放礼包
  195. EmailProc::SendPackageByCodeMail(req()->zoneid, req()->uid, $packageInfo->reward);
  196. my_Assert(ErrCode::ok == $err, $err);
  197. } else {
  198. $active = GameConfig::activity_getItem($activeId); # 活动数据
  199. my_Assert(null != $active, ErrCode::active_const_no_err);
  200. my_Assert($active->startts <= now() && $active->endts >= now(), ErrCode::active_time); # 校验开放时间
  201. my_Assert(preg_match("/^[a-kmnp-z2-9]{10}$/", $codestring), ErrCode::active_activecode_format); # 基础格式校验(10个特定字符)
  202. $activeCode = CipheredBase32::Decode($codestring); # 解码
  203. $codePlatStr = GameConstants::GetPlatStringByActivteCode($activeCode); # platstr
  204. my_Assert(GameConstants::AllPlatStr == $codePlatStr # # 忽略全平台礼包
  205. || req()->getPlatStr() == $codePlatStr, # # 平台字符串必须相符
  206. ErrCode::active_activecode_plat); # # 平台错误
  207. my_Assert(is_int($activeCode->number) # # 编号为int值
  208. && $activeCode->number >= 1 && $activeCode->number <= 50000, # # 检查 兑换码的编号范围0~50000
  209. ErrCode::active_activecode_format);
  210. $packageID = $activeCode->package; # 礼包id
  211. $packageInfo = GameConfig::token_gift_getItem($packageID); # 礼包常量数据
  212. my_Assert(null != $packageInfo, ErrCode::err_const_no); # 防御
  213. my_Assert($packageInfo->expirets >= now() && $packageInfo->startTs <= now(),
  214. ErrCode::active_activecode_outtime); # 激活码已经失效,或者礼包尚未开启
  215. $privateState = new Info_PrivateState(ctx()->privateState); # 快速访问
  216. my_Assert(!in_array($packageID, $privateState->usedTokens), ErrCode::active_hasgetted); # 已经领取过该礼包了
  217. my_Assert(!self::checkActiveCodeIsUsed($activeCode), ErrCode::active_activecode_used); # 检查 该激活码是否别人已经使用过了
  218. $err = StoreProc::AddMultiItemInStore($packageInfo->reward); # 发放礼包
  219. my_Assert(ErrCode::ok == $err, $err); # 防御发放礼包过程出错
  220. $ok = self::setActiveCodeUserRecord($activeCode, req()->uid); # 插入数据库
  221. my_Assert($ok, ErrCode::err_db); # 数据库操作失败- 重试
  222. }
  223. ctx()->privateState->usedTokens[] = $packageID;
  224. UserProc::updateUserInfo(); # 回存玩家数据
  225. $ret = array(# # 返回值
  226. "plat" => $codePlatStr,
  227. "packageId" => $packageID,
  228. "reward" => $packageInfo->reward,
  229. 'gold' => ctx()->base()->gold,
  230. 'cash' => ctx()->base()->cash,
  231. //'tili' => ctx()->base()->tili,
  232. 'store' => ctx()->store,
  233. //'hero' => ctx()->heros,
  234. );
  235. return Resp::ok($ret); # 返回成功信息
  236. }
  237. public static function PublicTokenCodeCheck($codestring) {
  238. $dic = GameConfig::token_PublicGift();
  239. if (StlUtil::dictHasProperty($dic, $codestring)) {
  240. return true;
  241. }
  242. return false;
  243. }
  244. /**
  245. * 检查兑换码是否已经使用过了
  246. * @param ActiveCode $activeCode
  247. * @return boolean true : 已经用过了, false : 激活码尚未使用过.
  248. */
  249. static function checkActiveCodeIsUsed($activeCode) {
  250. $sql = sprintf("`plat`='%d' and `package`='%d' and `number`='%d'", # # where 子句
  251. $activeCode->plat, $activeCode->package, $activeCode->number);
  252. $rows = daoInst()
  253. ->select()
  254. ->from(self::tab_toke_gift) # 表名
  255. ->where($sql)
  256. ->count();
  257. return $rows > 0;
  258. }
  259. /**
  260. * 将兑换码添加到使用记录中
  261. * @param ActiveCode $actvieCode
  262. * @param string $uid
  263. * @return boolean true: 操作成功, false: 操作失败
  264. */
  265. static function setActiveCodeUserRecord($actvieCode, $uid) {
  266. $actvieCode->uid = $uid; # 添加uid
  267. $ret = daoInst()
  268. ->insert(self::tab_toke_gift) # 表名
  269. ->data($actvieCode)
  270. ->exec();
  271. return $ret > 0;
  272. }
  273. /**
  274. * 7日签到 数据更新
  275. */
  276. public static function DailyResetDay7Task($unlock = false) {
  277. if (!$unlock && !FightProc::isFunUnlock(5)) {//之所以这有两个判断是因为这个 活动解锁的代码监测位置问题,fightProc 里解锁监测代码在 $gateInfo->tz_state = $index;之前了 这个位置没有办法解锁
  278. return;
  279. }
  280. if (count(ctx()->privateState->LoginDays) >= 7) {
  281. ctx()->privateState->LoginDays = array();
  282. ctx()->privateState->day7_drawed = array();
  283. }
  284. $index = count(ctx()->privateState->LoginDays) + 1;
  285. ctx()->privateState->LoginDays[] = $index;
  286. ctx()->privateState->day7_accumulate += 1;
  287. }
  288. /**
  289. * 6101 签到
  290. * @return type
  291. */
  292. public static function Day7_DrawReward() {
  293. list($day) = req()->paras; # 参数: 领取第x天的奖励
  294. my_Assert(in_array($day, ctx()->privateState->LoginDays), ErrCode::active_day7_expired);
  295. my_Assert(!in_array($day, ctx()->privateState->day7_drawed), ErrCode::active_hasgetted);
  296. $day_rwd = GameConfig::activity_day7_getItem($day); # 查询奖励数据
  297. my_Assert(null != $day_rwd, ErrCode::err_const_no); # 防御找不到配置
  298. StoreProc::AddMultiItemInStore($day_rwd->reward); # 发放奖励
  299. ctx()->privateState->day7_drawed[] = $day; # 添加领取记录
  300. UserProc::updateUserInfo(); # 回存
  301. return Resp::ok(array('gold' => ctx()->baseInfo->gold,
  302. 'cash' => ctx()->baseInfo->cash,
  303. 'store' => ctx()->store,
  304. 'heros' => ctx()->heros,
  305. 'reward' => StoreProc::$reward,
  306. 'reward_Gem' => StoreProc::$reward_Gem,
  307. ));
  308. }
  309. /**
  310. * 6107 7日签到 累计天数宝箱奖励领取
  311. * @return type
  312. */
  313. public static function Day7_AccumulateDrawreward() {
  314. list($day) = req()->paras; # 参数: 领取第x天的奖励
  315. $yushu = $day % 10;
  316. if ($yushu == 0) {
  317. $num = $day / 10;
  318. if ($num > 6) {
  319. $n = $num % 6;
  320. $typeId = $n * 10;
  321. } else {
  322. $typeId = $day;
  323. }
  324. } else {
  325. $typeId = $yushu;
  326. }
  327. my_Assert(ctx()->privateState->day7_accumulate >= $day, ErrCode::active_day7_expired);
  328. my_Assert(!in_array($day, ctx()->privateState->day7_accumulateDrawed), ErrCode::active_hasgetted);
  329. $day_rwd = GameConfig::active_day7_accumulate_getItem($typeId); # 查询奖励数据
  330. my_Assert(null != $day_rwd, ErrCode::err_const_no); # 防御找不到配置
  331. StoreProc::AddMultiItemInStore($day_rwd->reward); # 发放奖励
  332. ctx()->privateState->day7_accumulateDrawed[] = $day;
  333. $baseArr = array(2, 4, 6, 8, 10);
  334. $tag = true;
  335. $loopNum = ctx()->privateState->day7_accumulate_loopNum;
  336. foreach ($baseArr as $id) {//查看当前这组天奖励是否全部被领取
  337. $id += ($loopNum - 1) * 10;
  338. // if(ctx()->privateState->day7_accumulate < $id){
  339. // $tag = false;
  340. // break;
  341. // }
  342. if (!in_array($id, ctx()->privateState->day7_accumulateDrawed)) {
  343. $tag = false;
  344. }
  345. }
  346. if ($tag) {//$typeId % 10 == 0
  347. ctx()->privateState->day7_accumulate_loopNum += 1;
  348. }
  349. UserProc::updateUserInfo(); # 回存
  350. return Resp::ok(array('gold' => ctx()->baseInfo->gold,
  351. 'cash' => ctx()->baseInfo->cash,
  352. 'store' => ctx()->store,
  353. 'privateState' => ctx()->privateState,
  354. 'reward' => StoreProc::$reward,
  355. 'reward_Gem' => StoreProc::$reward_Gem,
  356. ));
  357. }
  358. /**
  359. * 限时贩卖 2天一刷
  360. */
  361. public static function ResetLimitTsBuy() {
  362. ctx()->privateState->limitTsBuy_RewardRecord = array();
  363. $mo = GameConfig::subfun_unlock_getItem(Enum_SubFunType::LimitTsSale);
  364. $day = $mo->ts;
  365. $startDay = TimeUtil::totalDays($mo->startTs);
  366. $nextDay = TimeUtil::totalDays();
  367. $num = $nextDay - $startDay;
  368. $refershType = $num % $day; //day 2天一刷新 余数只会是0 或 1; 0:两天后在刷新,1就是已经过了一天了,在过一天就刷新,当前时间减一天
  369. ctx()->privateState->nextDayLogin = now() - 86400*$refershType;
  370. // if ($refershType == 1) {
  371. // ctx()->privateState->nextDayLogin = now() - 86400;
  372. // }
  373. $val = intval($num / $day);
  374. $yushu = $val % glc()->activity_limitTsBuy_giftTypeNum;
  375. $type = $yushu + 1;
  376. $arr = GameConfig::activity_promopackinfo_type_getItemArray($type);
  377. $count = count($arr);
  378. $ret = array();
  379. if ($count == 6) {
  380. $ret = $arr;
  381. } else {
  382. for ($i = 0; $i < 6; $i++) {
  383. $count = count($arr);
  384. $rand = rand(0, $count - 1);
  385. $ret[] = $arr[$rand];
  386. StlUtil::arrayRemoveAt($arr, $rand);
  387. if (count($arr) == 0) {
  388. break;
  389. }
  390. }
  391. }
  392. ctx()->privateState->limitTsBuy_RandIds = array();
  393. foreach ($ret as $mo) {
  394. ctx()->privateState->limitTsBuy_RandIds[] = $mo->typeId;
  395. }
  396. }
  397. /**
  398. * 6108 限时贩售
  399. */
  400. public static function LimitTsBuy_Drawreward() {
  401. list($typeId) = req()->paras; # 参数: 领取第x天的奖励
  402. my_Assert(in_array($typeId, ctx()->privateState->limitTsBuy_RandIds), ErrCode::active_const_no_err);
  403. $mo = GameConfig::activity_promopackinfo_getItem($typeId); # 查询奖励数据
  404. my_Assert(null != $mo, ErrCode::err_const_no); # 防御找不到配置
  405. my_Assert(ctx()->baseInfo->cash >= explode(',', $mo->cost)[1], ErrCode::notenough_cash_msg);
  406. ctx()->baseInfo->Consume_Cash(explode(',', $mo->cost)[1]);
  407. $rewardArr = ctx()->privateState->limitTsBuy_RewardRecord;
  408. $count = array_count_values($rewardArr)[$typeId];
  409. my_Assert($count < $mo->limitNum, ErrCode::user_shop_LimitNum);
  410. StoreProc::AddMultiItemInStore($mo->reward); # 发放奖励
  411. ctx()->privateState->limitTsBuy_RewardRecord[] = $typeId;
  412. UserProc::updateUserInfo(); # 回存
  413. return Resp::ok(array('gold' => ctx()->baseInfo->gold,
  414. 'cash' => ctx()->baseInfo->cash,
  415. 'store' => ctx()->store,
  416. 'heros' => ctx()->heros,
  417. 'privateState' => ctx()->privateState,
  418. 'reward' => StoreProc::$reward,
  419. 'reward_Gem' => StoreProc::$reward_Gem,
  420. ));
  421. }
  422. /**
  423. * 6109 战令奖励领取
  424. */
  425. public static function BattlePassDrawReward() {
  426. list($id) = req()->paras;
  427. $mo = GameConfig::activity_battlepass_getItem($id); # 查询奖励数据
  428. my_Assert(null != $mo, ErrCode::err_const_no); # 防御找不到配置
  429. $subFunType = $mo->type;
  430. $typeId = $mo->typeId;
  431. $str_1 = $subFunType.'-1-'.$typeId;
  432. $str_2 = $subFunType.'-2-'.$typeId;
  433. $isHasBuy_high = false;
  434. switch ($subFunType) {
  435. case Enum_SubFunType::ActivePoint_BattlePass:
  436. $point =ctx()->privateState->battlePass_taskPoint;
  437. my_Assert($typeId >= $point, ErrCode::active_pointNotEnough);
  438. if(ctx()->privateState->battlePass_activePoint_cost_ts > 0 && now() < ctx()->privateState->battlePass_activePoint_cost_ts + 30*24*60*60){
  439. $isHasBuy_high = true;
  440. }
  441. break;
  442. case Enum_SubFunType::Tili_BattleBass:
  443. my_Assert($typeId >= ctx()->privateData()->battlePass_tili, ErrCode::active_costTiliNotEnough);
  444. if(ctx()->privateState->battlePass_tili_cost_ts > 0 && now() < ctx()->privateState->battlePass_tili_cost_ts + 30*24*60*60){
  445. $isHasBuy_high = true;
  446. }
  447. break;
  448. case Enum_SubFunType::Gate_BattleBass:
  449. my_Assert(StlUtil::dictHasProperty(ctx()->gates->GateList,$typeId), ErrCode::gate_GateNoUnlock);
  450. my_Assert(ctx()->gates->GateList->$typeId->pass > 0, ErrCode::evolve_GateNoPass);
  451. if(ctx()->privateState->battlePass_gate_cost_ts > 0 && now() < ctx()->privateState->battlePass_gate_cost_ts + 30*24*60*60){
  452. $isHasBuy_high = true;
  453. }
  454. break;
  455. default:
  456. break;
  457. }
  458. if(!in_array($str_1, ctx()->privateState->battlePassRewardReceived)){
  459. StoreProc::AddMultiItemInStore($mo->rewards_1); # 发放奖励
  460. ctx()->privateData(true)->battlePassRewardReceived[] = $str_1;
  461. }
  462. //my_Assert(!in_array($str_1, ctx()->privateState->battlePassRewardReceived), ErrCode::active_hasgetted);
  463. if($isHasBuy_high && !in_array($str_2, ctx()->privateState->battlePassRewardReceived)){
  464. StoreProc::AddMultiItemInStore($mo->rewards_2); # 发放奖励
  465. ctx()->privateData(true)->battlePassRewardReceived[] = $str_2;
  466. }
  467. UserProc::updateUserInfo(); # 回存
  468. return Resp::ok(array('gold' => ctx()->baseInfo->gold,
  469. 'cash' => ctx()->baseInfo->cash,
  470. 'store' => ctx()->store,
  471. 'heros' => ctx()->heros,
  472. 'privateState' => ctx()->privateState,
  473. 'reward' => StoreProc::$reward,
  474. 'reward_Gem' => StoreProc::$reward_Gem,
  475. ));
  476. }
  477. /**
  478. * 重置战令奖励信息 一个月一清理但是不同战令 开始时间不同所以 清理时间也不同
  479. * @param type $type
  480. */
  481. public static function ResetBattlePassReward($type) {
  482. $list = ctx()->privateState->battlePassRewardReceived;
  483. $rmArr = array();
  484. foreach ($list as $str) {
  485. $arr = explode('-', $str);
  486. if($arr[0] == $type){
  487. $rmArr[] = $str;
  488. }
  489. }
  490. foreach ($rmArr as $k) {
  491. StlUtil::arrayRemove(ctx()->privateData(true)->battlePassRewardReceived, $k);
  492. }
  493. }
  494. }