ShopProc.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <?php
  2. //
  3. //namespace loyalsoft;
  4. //
  5. ///**
  6. // * Description of ShopProc
  7. // * 商城
  8. // * @author gwang
  9. // * @version 1.0.0 Created. 2020.8.19 -gwang
  10. // */
  11. //class ShopProc {
  12. //
  13. // /**
  14. // * 逻辑分发
  15. // * 所有的Proc中必须有这样一个方法
  16. // */
  17. // public static function procMain() {
  18. // switch (req()->cmd) {
  19. // case CmdCode::shop_limit_maininfo:
  20. // return self::GetLimitMainInfo();
  21. // case CmdCode::shop_limit_buy:
  22. // return self::BuyLimitPackage();
  23. // case CmdCode::shop_monthlyVIP_Info:
  24. // return self::GetMonthlyVipInfo();
  25. // case CmdCode::shop_monthlyVIP_Buy:
  26. // return self::BuyMonthlyVip();
  27. // case CmdCode::shop_getDaliySpecial:
  28. // return self::GetDaliySpecial();
  29. // case CmdCode::shop_getRechargeRebate:
  30. // return self::GetRechargeRebate();
  31. // case CmdCode::shop_dailyShopBuy:
  32. // return self::dailyShopBuy();
  33. // default:
  34. // Err(ErrCode::cmd_err);
  35. // }
  36. // }
  37. //
  38. // /**
  39. // * 购买日常商城
  40. // * @return type
  41. // */
  42. // public static function dailyShopBuy() {
  43. // $itemid = req()->paras[0];
  44. //
  45. // $mo = GameConfig::shop_daily_getItem($itemid);
  46. // my_Assert($mo != null, ErrCode::err_const_no);
  47. //
  48. // if($mo->pricetype == 1){
  49. // my_Assert(ctx()->base(true)->cash >= $mo->price, ErrCode::notenough_cash_msg);
  50. // ctx()->base(true)->Consume_Cash($mo->price);
  51. // } else if($mo->pricetype == 2){
  52. // my_Assert(ctx()->base(true)->gold >= $mo->price, ErrCode::notenough_gold_msg);
  53. // ctx()->base(true)->Consume_Gold($mo->price);
  54. // }
  55. //
  56. // StoreProc::AddMultiItemInStore($mo->goods);
  57. //
  58. // UserProc::updateUserInfo();
  59. //
  60. // return Resp::ok(array("store" => ctx()->store(), "cash" => ctx()->baseInfo->cash,"gold"=> ctx()->base(true)->gold,));
  61. // }
  62. //
  63. //
  64. // /**
  65. // * 限购礼包触发条件检测
  66. // */
  67. // public function checkLimitTsRandGiftTrigger($typeId, $para) {
  68. // $arr = GameConfig::shop_limitTs_Type_getItemArray($typeId);
  69. // my_Assert($arr != null, ErrCode::err_const_no);
  70. // $giftId = 0;
  71. //
  72. // $giftArr = array();
  73. // foreach ($arr as $item) {
  74. // if ($item->para <= $para) {
  75. // if (!in_array($item->giftId, ctx()->shopdata->limitTsRewardsList)) {
  76. // $giftId = $item->giftId;
  77. // //$giftArr[] = $giftId;
  78. // //没有触发对应的礼包条件
  79. // if ($giftId == 0) {
  80. // continue;
  81. // }
  82. // //已经触发过了但是礼包还没有被领取
  83. // if (count(ctx()->store->triggerLimitTsGift) != 0) {
  84. // foreach (ctx()->store->triggerLimitTsGift as $val) {
  85. // if ($val->giftId == $giftId) {
  86. // continue;
  87. // }
  88. // }
  89. // }
  90. //
  91. // //触发对应的礼包条件。则将礼包id存储在
  92. // $gift = new Ins_Gift();
  93. // $gift->giftId = $giftId;
  94. // $gift->startTs = now();
  95. // $gift->endTs = now() + GameConfig::shop_limit_getItem($giftId)->limit_ts;
  96. // ctx()->store->triggerLimitTsGift[] = $gift;
  97. // }
  98. // }
  99. // }
  100. // }
  101. //
  102. // public static function GetRechargeRebate() {
  103. // return Resp::ok(array(
  104. // "shopdata" => ctx()->shopdata
  105. // ));
  106. // }
  107. //
  108. // //
  109. // public static function GetDaliySpecial() {
  110. // return Resp::ok(array(
  111. // "shopdata" => ctx()->shopdata
  112. // ));
  113. // }
  114. //
  115. // /*
  116. // * 重置每日特惠信息
  117. // */
  118. //
  119. // static function resetDaliySpecialPackages() {
  120. // if(!StlUtil::dictHasProperty(ctx()->shopdata, 'daliySpecialClear_ts')){
  121. // ctx()->shopdata->daliySpecialClear_ts = now();
  122. // }
  123. //
  124. // if (ctx()->shopdata->daliySpecialClear_ts == 0) {
  125. // ctx()->shopdata->daliySpecialClear_ts = now();
  126. // }
  127. // $curDay = TimeUtil::totalDays();
  128. // $lastDay = TimeUtil::totalDays(ctx()->shopdata->daliySpecialClear_ts);
  129. //
  130. // if ($curDay - $lastDay == 1 && TimeUtil::Hour(now()) > 5) {//TimeUtil::Hour(ctx()->shopdata->daliySpecialClear_ts) < 5
  131. // ctx()->shopdata->daliySpecialClear_ts = now();
  132. // ctx()->shopdata->daliySpecialPackages = array();
  133. // } else if ($curDay - $lastDay > 1) {
  134. // ctx()->shopdata->daliySpecialClear_ts = now();
  135. // ctx()->shopdata->daliySpecialPackages = array();
  136. // }
  137. //
  138. // if (TimeUtil::totalDays(ctx()->shopdata->daliySpecialClear_ts) == TimeUtil::totalDays() #
  139. // && TimeUtil::Hour(ctx()->shopdata->daliySpecialClear_ts) < 5 && TimeUtil::Hour(now()) > 5) {
  140. // ctx()->shopdata->daliySpecialClear_ts = now();
  141. // ctx()->shopdata->daliySpecialPackages = array();
  142. // }
  143. // }
  144. //
  145. // /**
  146. // * 获取月卡信息
  147. // * @return type
  148. // */
  149. // public static function GetMonthlyVipInfo() {
  150. // return Resp::ok(array(
  151. // "shopdata" => ctx()->shopdata
  152. // ));
  153. // }
  154. //
  155. // /**
  156. // * 购买月卡
  157. // * @return type
  158. // */
  159. // public static function BuyMonthlyVip() {
  160. // $packageId = req()->paras[0]; # 参数; 礼包id
  161. // $shopdata = new Info_UserShop(ctx()->shopdata);
  162. // $packageCfg = GameConfig::shop_monthVIP_getItem($packageId);
  163. // my_Assert(null != $packageCfg, ErrCode::err_const_no);
  164. // if ($packageCfg->subType == 4) {
  165. // my_Assert($shopdata->monthlyVIP1_ts + $packageCfg->ExpireTs * 3600 * 24 < now(), ErrCode::shop_monthlyvip_buyed);
  166. // } elseif ($packageCfg->subType == 5) {
  167. // my_Assert($shopdata->monthlyVIP2_ts + $packageCfg->ExpireTs * 3600 * 24 < now(), ErrCode::shop_monthlyvip_buyed);
  168. // }
  169. // $err = StoreProc::AddMultiItemInStore($packageCfg->pri_reward); # 发放一次性奖励
  170. // my_Assert(ErrCode::ok == $err, $err);
  171. // if ($packageCfg->subType == 4) {
  172. // $shopdata->monthlyVIP1_ts = 3600 * 24 * (totalDays() + 1) - 1;
  173. // } elseif ($packageCfg->subType == 5) {
  174. // $shopdata->monthlyVIP2_ts = 3600 * 24 * (totalDays() + 1) - 1;
  175. // }
  176. //
  177. // EmailProc::SendMonthlyVIPDailyReward(req()->zoneid, req()->uid, $packageCfg->name, $packageCfg->daily_reward);
  178. //
  179. // ctx()->shopdata = $shopdata; # 回写数据
  180. // UserProc::updateUserInfo();
  181. // $user = ctx();
  182. // return Resp::ok(array(
  183. // "reward" => $packageCfg->pri_reward,
  184. // "shopdata" => $shopdata,
  185. // 'gold' => $user->baseInfo->gold,
  186. // 'cash' => $user->baseInfo->cash,
  187. // 'tili' => $user->baseInfo->tili,
  188. // 'store' => $user->store,
  189. // 'hero' => $user->heros
  190. // ));
  191. // }
  192. //
  193. // /**
  194. // * 【7101】限购礼包主界面
  195. // */
  196. // public static function GetLimitMainInfo() {
  197. // return Resp::ok(array(
  198. // "shopdata" => ctx()->shopdata
  199. // ));
  200. // }
  201. //
  202. // /**
  203. // * 【7102】 购买限购礼包
  204. // */
  205. // public static function BuyLimitPackage() {
  206. // $packageId = req()->paras[0]; # 参数; 礼包id
  207. // $shopdata = new Info_UserShop(ctx()->shopdata);
  208. // $packageCfg = GameConfig::shop_limit_getItem($packageId);
  209. // my_Assert(null != $packageCfg, ErrCode::err_const_no);
  210. //
  211. // $arr = array();
  212. // switch ((int) $packageCfg->subType) {
  213. // case 1:
  214. // $shopdata->purchasedDailyLimitPackages[] = $packageId;
  215. // $arr = $shopdata->purchasedDailyLimitPackages;
  216. // break;
  217. // case 2:
  218. // $shopdata->purchasedWeeklyLimitPackages[] = $packageId;
  219. // $arr = $shopdata->purchasedWeeklyLimitPackages;
  220. // break;
  221. // case 3:
  222. // $shopdata->purchasedMonthlyLimitPackages[] = $packageId;
  223. // $arr = $shopdata->purchasedMonthlyLimitPackages;
  224. // break;
  225. // default:
  226. // Err(ErrCode::err_innerfault);
  227. // }
  228. // $hasN = count(array_filter($arr, function ($val)use ($packageId) {
  229. // return $val == $packageId;
  230. // }));
  231. // my_Assert($hasN <= $packageCfg->limit_num, ErrCode::shop_limit_max);
  232. // $itemid = explode(',', $packageCfg->reward)[0]; # 奖励礼包Id
  233. // $itemMO = GameConfig::item_package_getItem($itemid);
  234. // my_Assert(null != $itemMO, ErrCode::err_const_no);
  235. // $err = StoreProc::AddMultiItemInStore($itemMO->contents); # 发放奖励
  236. // my_Assert(ErrCode::ok == $err, $err);
  237. // ctx()->shopdata = $shopdata; # 回写数据
  238. // UserProc::updateUserInfo();
  239. // $user = ctx();
  240. // return Resp::ok(array(
  241. // "reward" => $itemMO->contents,
  242. // "shopdata" => $shopdata,
  243. // 'gold' => $user->baseInfo->gold,
  244. // 'cash' => $user->baseInfo->cash,
  245. // 'tili' => $user->baseInfo->tili,
  246. // 'store' => $user->store,
  247. // 'hero' => $user->heros
  248. // ));
  249. // }
  250. //
  251. // /**
  252. // * 每日检查
  253. // */
  254. // static function DailyCheck() {
  255. // CLog::info("shop-每日检查-清除每日/周限量礼包购买记录");
  256. // $zoneid = req()->zoneid;
  257. // $uid = req()->uid;
  258. //
  259. // ctx()->privateState->battleReviveNum = 0;
  260. //
  261. // $shopdata = new Info_UserShop(ctx()->shopdata);
  262. //
  263. //
  264. // if (TimeUtil::Hour(now()) > 5) {
  265. // $shopdata->dayRechargeAmt = 0; //每日每周限购累计金额统计字段重置
  266. // $shopdata->dayRechargeReceived = array();
  267. //
  268. // $shopdata->purchasedDailyLimitPackages = array(); # 每天重置
  269. // }
  270. //
  271. // if (date("N") == 1 && TimeUtil::Hour(now()) > 5) { # 周一重置
  272. // $shopdata->purchasedWeeklyLimitPackages = array();
  273. // $shopdata->weekRechargeAmt = 0;
  274. // $shopdata->weekRechargeReceived = array();
  275. // }
  276. // if (date("d") == 1 && TimeUtil::Hour(now()) > 5) { # 1号重置
  277. // $shopdata->purchasedMonthlyLimitPackages = array();
  278. // }
  279. //
  280. // if ($shopdata->monthlyVIP1_ts + 30 * 24 * 3600 > now()) {
  281. // $id = 901001;
  282. // $card1 = GameConfig::shop_monthVIP_getItem($id);
  283. // my_Assert(null != $card1, ErrCode::err_const_no);
  284. // EmailProc::SendMonthlyVIPDailyReward($zoneid, $uid, $card1->name, $card1->daily_reward);
  285. // }
  286. // if ($shopdata->monthlyVIP2_ts + 30 * 24 * 3600 > now()) {
  287. // $id = 901002;
  288. // $card2 = GameConfig::shop_monthVIP_getItem($id);
  289. // my_Assert(null != $card2, ErrCode::err_const_no);
  290. // EmailProc::SendMonthlyVIPDailyReward($zoneid, $uid, $card2->name, $card2->daily_reward);
  291. // }
  292. //
  293. // ctx()->shopdata = $shopdata;
  294. // }
  295. //
  296. //}