activity.php 101 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749
  1. <?php
  2. /**
  3. * 活动相关
  4. */
  5. class ModelActivity
  6. {
  7. protected $config;//活动配置
  8. protected $config_new;
  9. protected $_updateGameVersion_1 = '1.8.1.0';//版本升级活动 --安卓
  10. protected $_updateGameVersion_2 = '1.8.1.0';//版本升级活动 --IOS
  11. private $_url_android = 'https://play.google.com/store/apps/details?id=';
  12. private $_url_ios = 'https://itunes.apple.com/us/app/%E0%B9%84%E0%B8%9E-%E0%B9%80%E0%B8%97-%E0%B8%81%E0%B8%8B-%E0%B8%AA%E0%B8%8B-%E0%B9%80%E0%B8%9B%E0%B8%AD%E0%B8%A3/id1267293867?l=zh&ls=1&mt=8';
  13. private $_fb_weburl = 'https://www.facebook.com/superpoker.th';
  14. private $_fb_appurl = 'fb://page/152314908675395';
  15. private $_activity_title_file = WWWROOT . 'lang/lang.activity.php';//活动标题文件
  16. private $_activity_bname_file = WWWROOT . 'lang/lang.activity_btnname.php';//活动按钮文件
  17. private $_activity_img_file = WWWROOT . 'lang/lang.activity_img.php';//活动图片文件
  18. private $_activity_config_file = [];//活动配置文件
  19. private $_firstchargeGids = [12, 19, 44, 185, 320];//首冲商品id
  20. private $_channelSalePercent = 100;//按渠道打折的百分比
  21. private $_channelSaleList = [1,3,2,4,5,6,7,18,19];//打折的渠道
  22. private $_playpokerAid = 2;//玩牌得筹码活动ID
  23. private $_totalpayAid = 17;//累计充值
  24. private $_playOmahaAid = 9;//奥马哈活动ID
  25. private $_shakeActAid = 21;//摇一摇活动ID
  26. private $_channelSaleAid = 12;//买一送一活动
  27. private $_vipActAid = 19;//vip加送天数活动
  28. public function __construct(){}
  29. /**
  30. * 返回活动title列表
  31. * @return mixed
  32. */
  33. public function getActivityTitleList()
  34. {
  35. include_once $this->_activity_title_file;
  36. $aConfigLangActivity = $activityLang ?? [];
  37. return $aConfigLangActivity;
  38. }
  39. /**
  40. * 返回活动t图片列表
  41. * @return mixed
  42. */
  43. public function getActivityImgList()
  44. {
  45. include_once $this->_activity_img_file;
  46. $aConfigLangActivity = $activityLang ?? [];
  47. return $aConfigLangActivity;
  48. }
  49. /**
  50. * 返回活动按钮列表
  51. * @return mixed
  52. */
  53. public function getActivityBnameList()
  54. {
  55. include_once $this->_activity_bname_file ;
  56. $aConfigLangActivity = $activityLang ?? [];
  57. return $aConfigLangActivity;
  58. }
  59. /**
  60. * 设置活动标题的配置文件
  61. * @param array $titleConfig
  62. * @return bool
  63. */
  64. public function setActivityTitle($titleConfig = [])
  65. {
  66. $file = $this->_activity_title_file;
  67. if(file_exists($file)) {
  68. include_once $file;
  69. $titleList = $activityLang ?? [];
  70. }else {
  71. $titleList = [];
  72. }
  73. if(empty($titleConfig)) {
  74. return false;
  75. }
  76. if(empty($titleList)) {
  77. $titleStr = '<?php
  78. $activityLang = '.var_export($titleConfig, true).';';
  79. $num = file_put_contents($file, $titleStr);
  80. }else {
  81. foreach ($titleConfig as $k => $v) {
  82. $titleList[$k] = array_merge($titleList[$k] ?? [], $v);
  83. }
  84. $titleStr = '<?php
  85. $activityLang = '.var_export($titleList, true).';';
  86. $num = file_put_contents($file, $titleStr);
  87. }
  88. return $num > 0 ? true : false;
  89. }
  90. /**
  91. * 设置活动标题的配置文件
  92. * @param array $titleConfig
  93. * @return bool
  94. */
  95. public function setActivityImg($imgConfig = [])
  96. {
  97. $file = $this->_activity_img_file;
  98. if(file_exists($file)) {
  99. include_once $file;
  100. $imgList = $activityLang ?? [];
  101. }else {
  102. $imgList = [];
  103. }
  104. if(empty($imgConfig)) {
  105. return false;
  106. }
  107. if(empty($imgList)) {
  108. $imgStr = '<?php
  109. $activityLang = '.var_export($imgConfig, true).';';
  110. $num = file_put_contents($file, $imgStr);
  111. }else {
  112. foreach ($imgConfig as $k => $v) {
  113. $imgList[$k] = array_merge($imgList[$k] ?? [], $v);
  114. }
  115. $imgStr = '<?php
  116. $activityLang = '.var_export($imgList, true).';';
  117. $num = file_put_contents($file, $imgStr);
  118. }
  119. return $num > 0 ? true : false;
  120. }
  121. /**
  122. * 设置活动按钮的配置文件
  123. * @param array $titleConfig
  124. * @return bool
  125. */
  126. public function setActivityBname($bnameConfig = [])
  127. {
  128. $file = $this->_activity_bname_file;
  129. if(file_exists($file)) {
  130. include_once $file;
  131. $bnameList = $activityLang ?? [];
  132. }else {
  133. $bnameList = [];
  134. }
  135. if(empty($bnameConfig)) {
  136. return false;
  137. }
  138. if(empty($bnameList)) {
  139. $bnameStr = '<?php
  140. $activityLang = '.var_export($bnameConfig, true).';';
  141. $num = file_put_contents($file, $bnameStr);
  142. }else {
  143. foreach ($bnameConfig as $k => $v) {
  144. $bnameList[$k] = array_merge($bnameList[$k] ?? [], $v);
  145. }
  146. $bnameStr = '<?php
  147. $activityLang = '.var_export($bnameList, true).';';
  148. $num = file_put_contents($file, $bnameStr);
  149. }
  150. return $num > 0 ? true : false;
  151. }
  152. /**
  153. * 针对活动做特殊处理
  154. * @param $config
  155. */
  156. private function dealConfig(&$config)
  157. {
  158. $id = $config['id'];
  159. //如果是摇一摇活动,加版本控制
  160. if($id == 6) {
  161. $config['version_1'] = '1.1.2.0';//版本判断 android 该版本是否上该活动
  162. $config['version_2'] = '1.1.1.0';//版本判断 ios 该版本是否上该活动
  163. }
  164. //如果是添加邀请码
  165. if($id == 10) {
  166. $config['shareonce'] = array('money' => 200);//分享一次
  167. $config['invitesuc'] = array('money' => 5000);//每成功邀请1个人
  168. }
  169. return $config;
  170. }
  171. /**
  172. * 设置活动的配置文件
  173. * @param array $newConfig
  174. * @param $flag 1 --新增 其他 --修改
  175. * @return bool
  176. */
  177. public function setActivityConfig($newConfig = [], $flag = 1)
  178. {
  179. $file = $this->_activity_config_file;
  180. if(file_exists($file)) {
  181. include $file;
  182. $configList = $config_activity ?? [];
  183. $max_id = $max_id ?? 0;
  184. }else {
  185. $configList = [];
  186. $max_id = 0;
  187. }
  188. if(empty($newConfig)) {
  189. return false;
  190. }
  191. $id = $newConfig['id'] ?? 0;
  192. if($id < 1) {
  193. return false;
  194. }
  195. $this->dealConfig($newConfig);//针对活动做特殊处理
  196. if($flag == 1) {//如果是增加活动配置
  197. if($id <= $max_id) {//max_id 在配置文件配置
  198. return false;
  199. }
  200. array_push($configList, $newConfig);
  201. $configStr = '<?php
  202. $max_id = '.$id.';';
  203. }else {//如果是修改活动
  204. if($id > $max_id) {
  205. return false;
  206. }
  207. foreach ($configList as $k => &$v) {
  208. if($v['id'] === $newConfig['id']) {
  209. $v = $newConfig;
  210. }
  211. }
  212. $configStr = '<?php
  213. $max_id = '.$max_id.';';
  214. }
  215. $configStr .= '
  216. $config_activity = '.var_export($configList, true).';
  217. return $config_activity;
  218. ';
  219. $num = file_put_contents($file, $configStr);
  220. return $num > 0 ? true : false;
  221. }
  222. /**
  223. * 对某些活动做特殊处理
  224. * @param $info
  225. * @return mixed
  226. */
  227. private function dealActivityList(&$info, $uid = 0)
  228. {
  229. //判断跳转类型是否是,是则添加跳转链接
  230. $deviceid = $sid=1;
  231. switch ($info['goto']){
  232. case 3:
  233. $info['url'] = $deviceid == 1 ? $this->_url_android : $this->_url_ios;
  234. break;
  235. case 15:
  236. $info['webUrl'] = $this->_fb_weburl;
  237. $info['appUrl'] = $this->_fb_appurl;
  238. break;
  239. }
  240. //购买商品的活动, 如果payType为官方支付, 则需要根据玩家的设备跳转到不同的官方支付渠道
  241. if (in_array($info['payType'], [999]) ) {
  242. $info['payType'] = $deviceid == 1 ? 1 : 3;
  243. }
  244. //如果是世界杯活动,版本小于1.6.0,则跳去商店更新。大于则跳到世界杯活动界面
  245. switch ($info['id']) {
  246. // case 6://如果是宋干节活动,版本小于1.5.0版,则加上去更新的按钮,否则不显示去更新按钮
  247. // oo::version()->ge('1.5.0') && $info['actType'] = 0;
  248. // break;
  249. case 8://如果是我是冠军活动、奥马哈、邀请码,IOS 小于1.2.2.0版的不显示按钮
  250. case 10:
  251. $deviceid == 2 && oo::version()->lt('1.2.2.0') && $info['actType'] = 0;//是否有按钮 1有 0没有
  252. break;
  253. case 16://如果是安卓,并且版本小于1.6.0.0,则把跳转链接跳到更新版本
  254. if(oo::version()->lt('1.6.0.0')) {
  255. $info['goto'] = 3;
  256. $info['url'] = $deviceid == 1 ? $this->_url_android : $this->_url_ios;
  257. }
  258. break;
  259. case 18://FB点赞
  260. if($sid == 19 || $sid == 20){
  261. if(oo::version()->lt('1.6.4.0')){
  262. $info['goto'] = 3;
  263. $info['url'] = $this->_fb_weburl;
  264. }
  265. }elseif(oo::version()->lt('1.6.3.0')){
  266. $info['goto'] = 3;
  267. $info['url'] = $this->_fb_weburl;
  268. }
  269. break;
  270. case $this->_playpokerAid://是玩牌活动
  271. // $this->dealPlayPoker($info, $uid);
  272. break;
  273. case $this->_totalpayAid://累计充值活动
  274. $this->dealTotalPay($info, $uid);
  275. break;
  276. case $this->_playOmahaAid://奥马哈玩牌活动
  277. // $this->dealOmaha($info, $uid);
  278. break;
  279. case $this->_shakeActAid://摇一摇活动
  280. break;
  281. }
  282. return $info;
  283. }
  284. /**
  285. * 獲取盲注對應的快速場
  286. * @return array
  287. */
  288. public function getQuickGameBlindLevel()
  289. {
  290. $info = oo::commonOprModel('online')->getGameLevel();
  291. $texasTableList = oo::commonOprModel('robot')->getTexasTableList();
  292. $data = [];
  293. foreach ($info as $level=>$blind){
  294. if(!in_array($level, $texasTableList)){
  295. continue;
  296. }
  297. $data[$blind] = $level;
  298. }
  299. return $data;
  300. }
  301. /**
  302. * 出来玩牌活动
  303. * @param $info
  304. * @param $uid
  305. * @return bool
  306. */
  307. public function dealPlayPoker(&$info, $uid)
  308. {
  309. if(oo::version()->lt('1.6.2.0')){
  310. return false;
  311. }
  312. $tmpContent = [];
  313. $tmpContent['contentType'] = 1;
  314. $tmpContent['title'] = $info['title'];
  315. $tmpContent['time'] = date('Y.m.d',strtotime($info['stime'])).'-'.date('Y.m.d',strtotime($info['etime']));
  316. $tmpContent['isChooseDateHour'] = $info['isChooseDateHour'];
  317. $tmpContent['blind'] = current($info['blindList']);
  318. $rewardList = [];
  319. //对应盲注对应的level
  320. $blindLevelList = $this->getQuickGameBlindLevel();
  321. $timeNow = date('H:i', time());
  322. if($info['stimeHour'] == '00:00' && $info['etimeHour'] == '00:00'){
  323. $online = 1;
  324. }else{
  325. $online = ($timeNow >= $info['stimeHour'] && $timeNow <= $info['etimeHour']) ? 1 : 0;
  326. }
  327. rsort($info['blindList']);
  328. foreach ($info['blindList'] as $blind){
  329. if(is_array($info['reward'][$blind])) {
  330. foreach ($info['reward'][$blind] as $k => $v){
  331. $v['playNum'] = $k;
  332. $v['blind'] = $blind;
  333. $lang = 'en';
  334. if($lang == 'tw' || $lang == 'zh'){
  335. $stimeHour = $info['stimeHour'];
  336. $etimeHour = $info['etimeHour'];
  337. $stimeHourDate = date('Y-m-d').' '.$stimeHour;
  338. $etimeHourDate = date('Y-m-d').' '.$etimeHour;
  339. $v['time'] = date('H:i', strtotime("+1 hour $stimeHourDate")).'-'.date('H:i', strtotime("+1 hour $etimeHourDate"));
  340. }else{
  341. $v['time'] = $info['stimeHour'].'-'.$info['etimeHour'];
  342. }
  343. if($info['stimeHour'] == '00:00' && $info['etimeHour'] == '00:00'){
  344. $v['time'] = '00:00-24:00';
  345. }
  346. $stimeHour = $info['stimeHour'];
  347. $etimeHour = $info['etimeHour'];
  348. $stimeHourDate = date('Y-m-d').' '.$stimeHour;
  349. $etimeHourDate = date('Y-m-d').' '.$etimeHour;
  350. $v['startTime'] = strtotime($stimeHourDate);
  351. $v['endTime'] = strtotime($etimeHourDate);
  352. $v['online'] = $online;
  353. $v['gameId'] = 1;
  354. $v['gameLevel'] = $blindLevelList[$blind] ?? 0;
  355. $rewardList[] = $v;
  356. }
  357. }
  358. }
  359. $tmpContent['list'] = $rewardList;
  360. $info['content'] = $tmpContent;
  361. PRODUCTION_SERVER && $info['img'] = 'en/5b4f33b651542_415.jpg';
  362. return true;
  363. }
  364. /**
  365. * 处理累计充值
  366. * @param $info
  367. * @param $uid
  368. * @return bool
  369. */
  370. public function dealTotalPay(&$info, $uid)
  371. {
  372. if(oo::version()->lt('1.6.2.0')){
  373. return false;
  374. }
  375. $tmpContent = [];
  376. $tmpContent['contentType'] = 2;
  377. $tmpContent['title'] = $info['title'];
  378. $tmpContent['time'] = date('Y.m.d',strtotime($info['stime'])).'-'.date('Y.m.d',strtotime($info['etime']));
  379. $tmpContent['curCount'] = $this->getTotalPay($uid, 2);
  380. $tmpContent['currency'] = 'USD';
  381. include_once COM_CFG.'config.totalpay.php';
  382. $tmpContent['list'] = $totalPayConfig ?? [];
  383. $info['content'] = $tmpContent;
  384. PRODUCTION_SERVER && $info['img'] = 'en/5b505176a8896_84.jpg';
  385. return true;
  386. }
  387. /**
  388. * 获取玩牌活动配置
  389. * @return array|int
  390. */
  391. public function playPokerConfig($blind, $flag=1)
  392. {
  393. $data = ['online'=>0, 'rewardArr'=>[], 'dayTime' => '', 'hourTime' => '' ,'countDown'=>0];
  394. //是否在活动期间
  395. $checkExpire = $this->checkExpire($this->_playpokerAid);
  396. if(!$checkExpire || empty($blind)) {
  397. return $data;
  398. }
  399. $info = $this->config[$this->_playpokerAid - 1];
  400. if(!isset($info['id']) || $info['id'] != $this->_playpokerAid){//是否是玩牌活动
  401. return $data;
  402. }
  403. $now = time();
  404. if($info['isChooseDateHour'] && ($info['stimeHour'] != '00:00' || $info['etimeHour'] != '00:00')){//说明设置了玩牌时间段,则要判断当前时间是否在该时间段
  405. $today = date('Y-m-d');
  406. $stimeHourTmp = $info['stimeHour'];
  407. $etimeHourTmp = $info['etimeHour'];
  408. $stimedate = $today.' '.$stimeHourTmp.':00' ;
  409. $etimedate = $today.' '.$etimeHourTmp.':59';
  410. $stimeTmp = strtotime("$stimedate ");
  411. $etimeTmp = strtotime("$etimedate ");
  412. if($now < $stimeTmp || $now > $etimeTmp) {
  413. return $data;
  414. }
  415. }
  416. //当前盲注是否有该活动
  417. $blindList = $info['blindList'] ?? [];
  418. if(!empty($blindList) && !in_array(999, $blindList) && !in_array($blind, $blindList)){//活动盲注不空,且当前盲注不在配置盲注中,则该活动不在线上,且不是针对所有盲注(999表示所有盲注)
  419. return $data;
  420. }
  421. //配置
  422. $rwdConfig = $info['reward'][$blind] ?? [];
  423. $data = [];
  424. if($flag == 2){
  425. $data = $rwdConfig;
  426. }else {
  427. $num = 0;
  428. foreach ($rwdConfig as $k => $rwd){
  429. $data[$num]['playNum'] = $k;
  430. foreach ($rwd as $key=>$val) {
  431. $data[$num][$key] = $val;
  432. }
  433. $num++;
  434. }
  435. }
  436. $hourTime = '';
  437. $etimeHour = '23:59';
  438. if($info['isChooseDateHour']) {//如果按时间段配置
  439. $hourTime = $info['stimeHour'].'-'.$info['etimeHour'];
  440. $etimeHour = $info['etimeHour'];
  441. }
  442. //获取倒计时
  443. $endHour = strtotime(date('Y-m-d ', $now).' '.$etimeHour.':59');
  444. $countDown = $endHour <= $now ? 0 : $endHour - $now;
  445. $online = $countDown ? 1 : 0;
  446. return ['online'=> $online, 'rewardArr'=>$data, 'dayTime' => date('Y.m.d', strtotime($info['stime'])).'-'. date('Y.m.d', strtotime($info['etime'])), 'hourTime' =>$hourTime, 'countDown'=>$countDown];
  447. }
  448. // /**
  449. // * 中级场记录打牌
  450. // */
  451. // public function recordPlay_midLevel($uid = 0)
  452. // {
  453. // foreach ($this->config as $info) {
  454. // if( $info['online'] == 0 || $info['id'] != 5){
  455. // continue;
  456. // }
  457. // $stime = strtotime($info['stime']);
  458. // $etime = strtotime($info['etime']);
  459. // $now = time();
  460. // $key = okeys::actMidLevelRecordPlaying($uid);
  461. // $expire = strtotime('23:59:59');
  462. //
  463. // if( $now >= $stime && $now <= $etime ){//必须在活动期间
  464. // $playIngNum = oo::commonOprRedis('common')->incr($key);
  465. // oo::commonOprRedis('common')->expireAt($key, $expire);
  466. //
  467. // //查看是否有大转盘优惠
  468. // if( isset($info['bigwheel']) ){
  469. // $bigwheelNum = array_keys($info['bigwheel']);//大转盘每次加免费次数的局数
  470. // $bigwheelNum = reset($bigwheelNum);
  471. // $bigwheelTimes = reset($info['bigwheel']);//每次减的次数
  472. // if( $playIngNum % $bigwheelNum == 0 ){
  473. // $cacheKey = okeys::bigwheel($uid);
  474. // $usedTimes = (int)oo::commonOprRedis('userinfo')->get($cacheKey);
  475. // if( $usedTimes > 0 ){
  476. // --$usedTimes;
  477. // oo::commonOprRedis('userinfo')->setex($cacheKey, $usedTimes,7*86400);
  478. // }
  479. // }
  480. // }
  481. //
  482. // $rewardArr = $info['reward'];//奖励
  483. // $rewardNum = array_keys($rewardArr);
  484. // if( !in_array($playIngNum, $rewardNum) ){//没有达到预期的牌局数
  485. // //oo::logs()->debug3(array('uid' => $uid, 'playIngNum' => $playIngNum, '$rewardNum' => $rewardNum, 'time' => time()), 'Activity_playingReward.log');
  486. // continue;
  487. // }
  488. //
  489. // $reward = $rewardArr[$playIngNum];
  490. // if( $reward ){
  491. // $msg = oo::getLang('activity_news_1');
  492. // $msg = str_replace('@', $playIngNum, $msg);
  493. // $msg = str_replace('+', $reward['diamond'], $msg);
  494. // $rwd['diamonds'] = $reward['diamond'];
  495. // oo::commonOprModel('usernews')->setUserMsg($uid, $msg, 2, 1, $rwd, 1, 2004, 'recordPlayDiamond', [$playIngNum, $reward['diamond']]);
  496. // oo::logs()->debug3(array('uid' => $uid, 'playIngNum' => $playIngNum, 'reward' => $reward, 'time' => time()), 'Activity_playingReward.log');
  497. // //记录事件
  498. // oo::commonOprModel('statistics')->event(array($uid, 1023));
  499. // }
  500. // }
  501. // }
  502. // }
  503. /**
  504. * 按渠道打折活动加钱
  505. * @param $gchannel
  506. * @param $baseRwd
  507. * @param $baseTempRwd
  508. * @param $uid
  509. * @param $gid
  510. * @return bool
  511. */
  512. public function channelSaleActivityRwd($gchannel, &$baseRwd, $baseTempRwd, $uid, $gid)
  513. {
  514. if(!in_array($gchannel, $this->_channelSaleList)){
  515. return false;
  516. }
  517. $aid = $this->_channelSaleAid;//活动id
  518. //检查是否在活动期间
  519. $expire = $this->checkExpire($aid);
  520. if(!$expire) {
  521. return false;
  522. }
  523. $money = $baseTempRwd['money'] ?? 0;
  524. $money = $money * $this->_channelSalePercent/100;
  525. $baseRwd['money'] += $money;
  526. oo::logs()->debug3(array('uid'=>$uid, 'gid' => $gid, 'extraMoney' => $money, 'totalMoney' => json_encode($baseRwd)),'activityChannelSaleExtraReward.log');
  527. return true;
  528. }
  529. /**
  530. * 检测是否是折扣商品
  531. * @param $gid
  532. */
  533. public function checkDiscountGoods($gid)
  534. {
  535. // if(!in_array($gid, $this->_discountgoodsGids)) {
  536. // return false;
  537. // }
  538. //如果该商品id属于首冲商品,则没有折扣
  539. if(in_array($gid, $this->_firstchargeGids)) {
  540. return false;
  541. }
  542. //如果是除了筹码外的钻石、道具之类的没有折扣
  543. $goodsInfo = oo::commonOprModel('goods')->getGoodsInfoByGid($gid);
  544. $goodsType = intval($goodsInfo['gtype']) ?? 0;
  545. if($goodsType !== 1) {
  546. return false;
  547. }
  548. return true;
  549. }
  550. /**
  551. * 登录时是否弹窗活动弹窗
  552. * @return int
  553. */
  554. // public function isShowActivity()
  555. // {
  556. // //活动弹窗状态
  557. // $keys = okeys::showactivity();
  558. // $showActivity = oo::commonOprRedis('common')->get($keys);
  559. // if($showActivity > 0) {//如果设置活动弹窗弹出,则判断活动列表是否为空
  560. // $data= $this->getList([]);
  561. // $list = $data['list'] ?? [];
  562. // if(empty($list)) {
  563. // return 0;
  564. // }else {
  565. // return 1;
  566. // }
  567. // }else {
  568. // return 0;
  569. // }
  570. // }
  571. /**
  572. * 统一输出返回json内容
  573. *
  574. * @access public
  575. * @date 2016-08-16
  576. * @param int $ret 状态码,0成功
  577. * @param string $msg 错误信息
  578. * @param array $data 返回数据内容
  579. * @return json;
  580. */
  581. public function response($ret = 0, $msg = '', array $data = array())
  582. {
  583. $result = [
  584. 'ret' => $ret,
  585. 'msg' => $msg,
  586. 'data' => $data,
  587. ];
  588. die(json_encode($result));
  589. }
  590. /**
  591. * 概率计算
  592. * @param $proArr
  593. * @return int|string
  594. */
  595. public function get_rand($proArr) {
  596. $result = '';
  597. //概率数组的总概率精度
  598. $proSum = array_sum($proArr);
  599. //概率数组循环
  600. foreach ($proArr as $key => $proCur) {
  601. $randNum = mt_rand(1, $proSum);
  602. if ($randNum <= $proCur) {
  603. $result = $key;
  604. break;
  605. } else {
  606. $proSum -= $proCur;
  607. }
  608. }
  609. unset ($proArr);
  610. return $result;
  611. }
  612. // /**
  613. // * 邀请码活动发奖
  614. // * @param $fatherid
  615. // */
  616. // public function inviteCode($fatherid, $uid)
  617. // {
  618. // $activity = oo::commonOprModel('activity')->checkExpire(10);
  619. // if ($activity) {
  620. // $news = oo::getLang('activity_desc_10');
  621. // $num = 1;
  622. // $actRew = ['diamonds'=>$num];
  623. // oo::commonOprModel('usernews')->setUserMsg($fatherid, $news, 2, 1, $actRew, 1, 2005, 'inviteDiamond', [$num]);
  624. // //记录事件
  625. // oo::commonOprModel('statistics')->event(array($uid, 1108));
  626. // }
  627. // return true;
  628. //
  629. // }
  630. /**
  631. * 检查活动是否过期,并返回活动配置
  632. * @param 活动ID
  633. */
  634. public function checkExpire($aid)
  635. {
  636. if (!$this->config) {
  637. return false;
  638. }
  639. $activity = array();
  640. foreach ($this->config as $info) {
  641. if ($info['id'] == $aid) {
  642. $activity = $info;
  643. break;
  644. }
  645. }
  646. if (empty($activity)) {
  647. return false;
  648. }
  649. //判断是否过期
  650. $online = $activity['online'];
  651. $stime = strtotime($activity['stime']);
  652. $etime = strtotime($activity['etime']);
  653. $now = time();
  654. if ($now < $stime || $now > $etime || $online != 1) {
  655. return false;
  656. }
  657. //判断该活动是否上线
  658. if(!$this->checkActivityPackage($aid)) {
  659. return false;
  660. }
  661. return $activity;
  662. }
  663. /**
  664. * 判断该活动是否上线
  665. * @param $id
  666. * @return bool
  667. */
  668. public function checkActivityPackage($id)
  669. {
  670. $key = okeys::activityonlinepackage($id);
  671. $data = oo::commonOprRedis('common')->get($key);
  672. $packageList = json_decode($data, 1);
  673. if(empty($packageList) || !in_array(1, $packageList)) {
  674. return false;
  675. }
  676. return true;
  677. }
  678. /**
  679. * 累计用户充值金额
  680. * @param $uid
  681. * @param $price
  682. * @param $priceThb
  683. * @param $channel
  684. * @return int
  685. */
  686. public function recordTotalPay($uid, $price, $priceThb, $channel)
  687. {
  688. // if(PRODUCTION_SERVER && !in_array($uid, $this->_whiteList)){
  689. // return false;
  690. // }
  691. if(empty($uid) || empty($price) || empty($priceThb) || empty($channel)) {
  692. return -1;
  693. }
  694. //是否在活动期间
  695. $checkExpire = $this->checkExpire($this->_totalpayAid);
  696. if(!$checkExpire){//不在活动期间
  697. return -2;
  698. }
  699. // if(!in_array($channel, [1,2,3,4,5,6,7,8])){//渠道
  700. // return -3;
  701. // }
  702. $key = okeys::recordtotalpayact($uid);
  703. $ret = json_decode(oo::commonOprRedis('common')->get($key), 1);
  704. $ret['price'] += $price;//美金
  705. $ret['priceThb'] += $priceThb;//本地
  706. oo::commonOprRedis('common')->set($key, json_encode($ret));//记录充值累计
  707. $keyMayRwd = okeys::mayrwdtotalpay();
  708. oo::commonOprRedis('common')->sAdd($keyMayRwd, $uid);//记录充过值可能领累计充值的用户
  709. oo::logs()->nodatedebug('uid:'.$uid.' price:'.$price.' priceThb:'.$priceThb.' channel:'.$channel, 'recordTotalPay.php');
  710. return 1;
  711. }
  712. /**
  713. * 获取累计充值金额
  714. * @param $uid
  715. * @param $flag 1泰铢 2美元
  716. * @return int
  717. */
  718. public function getTotalPay($uid, $flag = 1)
  719. {
  720. if(empty($uid)) {
  721. return 0;
  722. }
  723. //是否在活动期间
  724. $checkExpire = $this->checkExpire($this->_totalpayAid);
  725. if(!$checkExpire){//不在活动期间
  726. return 0;
  727. }
  728. $key = okeys::recordtotalpayact($uid);
  729. $ret = json_decode(oo::commonOprRedis('common')->get($key), 1);
  730. if($flag == 2){
  731. $price = $ret['price'] ?? 0;
  732. }else {
  733. $price = $ret['priceThb'] ?? 0;
  734. }
  735. return floatval($price);
  736. }
  737. /**
  738. * 累計充值領獎
  739. * @param $now
  740. * @return bool
  741. */
  742. public function rwdTotalPay($now)
  743. {
  744. $info = $this->config[$this->_totalpayAid - 1];
  745. if(!isset($info['id']) || $info['id'] != $this->_totalpayAid ){
  746. oo::logs()->debug3('累計充值活動ID不正確', 'rwdTotalPayFail.php');
  747. return -1;
  748. }
  749. //判断该活动是否上线
  750. if(!$this->checkActivityPackage($this->_totalpayAid)) {
  751. oo::logs()->debug3('在该包不上线', 'rwdTotalPayFail.php');
  752. return -3;
  753. }
  754. //判断时间是否在活动结束后的第二天
  755. $etime = $info['etime'];
  756. $date = date('Y-m-d', strtotime("$etime +1 day"));
  757. $dateToday = date('Y-m-d', $now);
  758. if($date != $dateToday){//如果没到领奖时间
  759. oo::logs()->debug3('累計充值時間還沒到', 'rwdTotalPayFail.php');
  760. return -2;
  761. }
  762. $totalPayConfig = include_once COM_CFG."config.totalpay.php";
  763. if(!is_array($totalPayConfig)){
  764. oo::logs()->debug3('配置不正確', 'rwdTotalPayFail.php');
  765. return -3;
  766. }
  767. $rwdConfig = [];
  768. $rwdChipsList = [];
  769. foreach ($totalPayConfig as $val){
  770. $rwdConfig[$val['count']] = $val;
  771. $rwdChipsList[] = $val['count'];
  772. }
  773. rsort($rwdChipsList);//对奖励倒序排列
  774. if(empty($rwdChipsList) || !is_array($rwdChipsList)){
  775. oo::logs()->debug3('金額配置不正確', 'rwdTotalPayFail.php');
  776. return -4;
  777. }
  778. //获取可能能领累计充值奖励的用户
  779. $mayRwdKey = okeys::mayrwdtotalpay();
  780. $uidList = oo::commonOprRedis('common')->sMembers($mayRwdKey);
  781. oo::logs()->nodatedebug('可能領累計充值獎勵的uid列表:'.json_encode($uidList), 'rwdTotalPayUid.php');
  782. foreach ($uidList as $uid) {
  783. $key = okeys::recordtotalpayact($uid);
  784. $ret = json_decode(oo::commonOprRedis('common')->get($key), 1);
  785. $priceThb = intval($ret['price'] ?? 0);
  786. $checkRwd = $this->checkRwd($priceThb, $rwdChipsList);
  787. if($checkRwd){//如果能领奖,去发奖。不能则删除
  788. oo::logs()->nodatedebug('能領獎的uid:'.$uid.' priceThb:'.$priceThb.' checkRwd:'.$checkRwd, 'canRwdTotalPay.php');
  789. $this->toRwd($uid, $checkRwd, $rwdConfig);
  790. }else{
  791. oo::logs()->nodatedebug('不能領獎的uid:'.$uid.' priceThb:'.$priceThb.' checkRwd:'.$checkRwd, 'cannotRwdTotalPay.php');
  792. }
  793. oo::commonOprRedis('common')->delete($key);
  794. }
  795. oo::commonOprRedis('common')->delete($mayRwdKey);
  796. return true;
  797. }
  798. /**
  799. * 检测是否能领奖
  800. * @param $price --充值的金额
  801. * @param $rwdChipsList --按数值倒序
  802. * @return bool
  803. */
  804. public function checkRwd($price, $rwdChipsList)
  805. {
  806. foreach ($rwdChipsList as $rwd){
  807. if($price >= $rwd){
  808. return $rwd;
  809. }
  810. }
  811. return false;
  812. }
  813. /**
  814. * 累計充值領獎
  815. * @param $uid
  816. * @param $price
  817. * @param $rwdConfig
  818. * @return bool
  819. */
  820. public function toRwd($uid, $price, $rwdConfig)
  821. {
  822. // if(PRODUCTION_SERVER && !in_array($uid, $this->_whiteList)){
  823. // return false;
  824. // }
  825. $rwdList = $rwdConfig[$price] ?? [];
  826. if(empty($rwdList)){
  827. oo::logs()->nodatedebug('累計充值領獎失敗:配置為空 uid:'.$uid.' price:'.$price.' rwdConfig:'.json_encode($rwdConfig), 'totalPayRwdFail.php');
  828. return false;
  829. }
  830. $data = [];
  831. $replaceList = [$price];
  832. foreach ($rwdList as $key => $val){
  833. switch ($key){
  834. case 'chips':
  835. $data['money'] = $val;
  836. $replaceList[] = $val;
  837. continue;
  838. case 'diamonds':
  839. $data['diamonds'] = $val;
  840. $replaceList[] = $val;
  841. continue;
  842. case 'vipType':
  843. //如果是vip,先判断用户是否是vip用户。是则加vip用户的VIP等级
  844. $vipLevel = oo::commonOprModel('vip')->checkVip($uid);
  845. $vipLevel <= 0 && $vipLevel = $val;
  846. $ret = oo::commonOprModel('vip')->addVip($uid, $vipLevel, $rwdList['days']);
  847. $ret = json_decode($ret, 1);
  848. if($ret['code'] == 1){//如果加vip成功,则默认发系统消息给用户
  849. $msg = '';
  850. oo::commonOprModel('usernews')->setUserMsg($uid, $msg, 1, 1, [], 1, '', 'act_totalpay_vip',[ ]);
  851. }else {//失败则记录
  852. oo::logs()->nodatedebug('加VIP失敗 uid:'.$uid.' viplevel:'.$vipLevel.' days:'.$rwdList['days'], 'totalPayRwdFail.php');
  853. }
  854. continue;
  855. }
  856. }
  857. if(!empty($data)){//發送領獎消息
  858. $rwdMsg = '';
  859. if(count($replaceList) > 2){//如果有鑽石贈送
  860. $msgRet = oo::commonOprModel('usernews')->setUserMsg($uid, $rwdMsg, 2, 1, $data, 1, 1123, 'activity_totalpay_2', $replaceList);
  861. }else {
  862. $msgRet = oo::commonOprModel('usernews')->setUserMsg($uid, $rwdMsg, 2, 1, $data, 1, 1123, 'activity_totalpay_1', $replaceList);
  863. }
  864. oo::logs()->nodatedebug('uid:'.$uid.' rwd:'.json_encode($data).' msgId:'.json_encode($msgRet), 'totalPayRwdSuccess.php');
  865. }
  866. return true;
  867. }
  868. /**
  869. * 获取打折的百分比
  870. * @return int
  871. */
  872. public function channelSaleInfo($uid=0)
  873. {
  874. $checkExpire = $this->checkExpire($this->_channelSaleAid);
  875. if(!$checkExpire){
  876. return [];
  877. }
  878. $data['percent'] = $this->_channelSalePercent;
  879. $data['channelList'] = $this->_channelSaleList;
  880. $data['countdown'] = strtotime($checkExpire['etime']) - time();//倒计时
  881. return $data;
  882. }
  883. public function sendUserMsg($uid)
  884. {
  885. if(oo::version()->lt('1.5.0')){
  886. return false;
  887. }
  888. $checkExpire = $this->checkExpire($this->_shakeActAid);
  889. if(!$checkExpire){
  890. return false;
  891. }
  892. $msg = 'Happy Chinese Valentine\'s day, pick up your phone and shake it. Click on the gift to surprise you.';
  893. $ret = oo::commonOprModel('usernews')->setUserMsg($uid, $msg, 1, 1, [], 1, '', 'act_shake_firstIn_msg', []);
  894. return true;
  895. }
  896. /**
  897. * vip充值活动
  898. * @param $uid
  899. * @param $type
  900. * @return bool
  901. */
  902. public function vipActivity($uid, $type)
  903. {
  904. $checkExpire = $this->checkExpire($this->_vipActAid);
  905. $period = 8;
  906. if(!$checkExpire){
  907. return 0;
  908. }
  909. $ret = oo::commonOprModel('vip')->addVip($uid, $type, $period);
  910. oo::logs()->debug3('activity vip: uid:'.$uid.' type:'.$type.' period:'.$period.' ret:'.json_encode($ret), 'vipActivity.php');
  911. $ret = json_decode($ret, 1);
  912. if($ret['code'] === 1){
  913. return $period;
  914. }
  915. return 0;
  916. }
  917. public function getSymbol($uid){
  918. if(!$this->activityLock($uid,2,true)){
  919. return false;
  920. }
  921. $temp = oo::commonOprRedis('common')->hGet(okeys::ActivityData(),2);
  922. $temp = json_decode($temp,true);
  923. switch (intval($temp['activityType'])){
  924. case 4:
  925. $type = 4;
  926. break;
  927. default:
  928. $type = 0;
  929. break;
  930. }
  931. $configKey = okeys::SymbolConfig($type,2);
  932. $stage = intval(oo::commonOprRedis('common')->hGet(okeys::SymbolStage(),$uid))+1;
  933. $baseCoins = 1;
  934. $rewardType = intval(oo::commonOprRedis('common')->hGet($configKey,$stage."#type"));
  935. if($rewardType == 1){
  936. $assetsInfo = oo::commonOprModel('member')->getUserAssetsInfo($uid);
  937. $baseCoins = oo::commonOprModel('config')->getActivityCoins($assetsInfo['levelId'],"collect");
  938. }
  939. return [
  940. 'stage' =>$stage,
  941. 'num' =>intval(oo::commonOprRedis('common')->hGet(okeys::SymbolNum(),$uid)),
  942. 'maxNum'=>intval(oo::commonOprRedis('common')->hGet($configKey,$stage)),
  943. 'type' =>$rewardType,
  944. 'reward'=>intval(oo::commonOprRedis('common')->hGet($configKey,$stage."#reward")) * $baseCoins
  945. ];
  946. }
  947. /**
  948. * 收集活动
  949. * @param $uid
  950. * @param $num
  951. * @param int $from 1老虎机,2偷,3打
  952. * @return array
  953. * created by owen
  954. * created at 14:13
  955. */
  956. public function upSymbol($uid,$num,$from = 0){
  957. if($this->activityLock($uid,2,true)){
  958. oo::commonOprRedis('common')->hIncrBy(okeys::SymbolNum(),$uid,$num);
  959. }
  960. $ac13 = self::activityLock($uid,13,true);
  961. if($ac13){
  962. if(time() < $ac13['reward_time']){
  963. $model = intval(oo::commonOprModel('readconfig')->getSysCon('activtity13',"model"));
  964. if($model == 1 && $from == 1){
  965. self::UniteAddNumRank($uid,$num);
  966. }else if($model == 2){
  967. self::UniteAddNumRank($uid,$num);
  968. }else if($model == 3 && ($from == 2 || $from == 3)){
  969. self::UniteAddNumRank($uid,$num);
  970. }
  971. }
  972. }
  973. }
  974. public function rewardSymbol($uid){
  975. $symbolData = self::getSymbol($uid);
  976. if(intval($symbolData['maxNum']) > intval($symbolData['num'])){
  977. return ['code'=>-1,'msg'=>'进度异常','data'=>['maxNum'=>$symbolData['maxNum'],'num'=>$symbolData['num'],'type'=>$symbolData['type'],'reward'=>$symbolData['reward'],'stage'=>$symbolData['stage']]];
  978. }else{
  979. if($symbolData['type'] == 1 || $symbolData['type'] == 2){
  980. $rewardKey = ($symbolData['type'] == 1)?'money':'spins';
  981. oo::commonOprModel('member')->optProperty($uid,[$rewardKey=>$symbolData['reward']],'+',204,'活动:金蛋进度:'.$symbolData['stage']);
  982. oo::commonOprRedis('common')->hIncrBy(okeys::SymbolNum(),$uid,-$symbolData['maxNum']);
  983. oo::commonOprRedis('common')->hIncrBy(okeys::SymbolStage(),$uid,1);
  984. return [
  985. 'code'=>1,'msg'=>'领奖成功',
  986. 'data'=>[
  987. 'reward'=>['type'=>$symbolData['type'],'num'=>$symbolData['reward']],
  988. 'cur'=>self::getSymbol($uid)
  989. ]
  990. ];
  991. }else if($symbolData['type'] == 3){
  992. $exclusiveCardInfo = oo::commonOprModel('card')->getExclusiveCardInfoById($symbolData['reward']);
  993. $flag = false;
  994. $userCardInfo = oo::commonOprModel('card')->getUserCardInfo($uid);
  995. $userCardInfo = $userCardInfo['csid']??[];
  996. if(empty($userCardInfo) || !in_array($symbolData['reward'],$userCardInfo)){
  997. $flag = true;
  998. oo::commonOprModel('member')->optProperty($uid,array('star'=>$exclusiveCardInfo['ci_star_rank']),'+',32,'获取新卡片星星:限定卡片-'.$symbolData['reward']);
  999. }
  1000. oo::commonOprModel('card')->rewardExclusiveCard($uid,$symbolData['reward']);
  1001. $cardInfo['receive'][] = [
  1002. 'group'=>$exclusiveCardInfo['cgid'],
  1003. 'card'=>$exclusiveCardInfo['cgposition'],
  1004. 'isNew'=>$flag,
  1005. 'type'=>2,
  1006. ];
  1007. $cardInfo['card']= oo::commonOprModel('card')->getInfo($uid);
  1008. $cardInfo['cardReward'] = ['spins'=>0,'coins'=>0];
  1009. $cardInfo['cardGroupReward'] = ['spins'=>0,'coins'=>0];
  1010. $cardInfo['exclusiveCard'] = oo::commonOprModel('card')->getExclusiveInfo($uid);
  1011. oo::commonOprRedis('common')->hIncrBy(okeys::SymbolNum(),$uid,-$symbolData['maxNum']);
  1012. oo::commonOprRedis('common')->hIncrBy(okeys::SymbolStage(),$uid,1);
  1013. return [
  1014. 'code'=>1,'msg'=>'领奖成功',
  1015. 'data'=>[
  1016. 'reward'=>['type'=>3,'num'=>$symbolData['reward'],'card'=>$cardInfo],
  1017. 'cur'=>self::getSymbol($uid)
  1018. ]
  1019. ];
  1020. }else{
  1021. return ['code'=>-2, 'msg'=>'领奖失败', 'data'=>['maxNum'=>$symbolData['maxNum'],'num'=>$symbolData['num'],'type'=>$symbolData['type'],'reward'=>$symbolData['reward'],'stage'=>$symbolData['stage']]];
  1022. }
  1023. }
  1024. }
  1025. /**
  1026. * 获得活动信息
  1027. * @param $activityId
  1028. * @return mixed
  1029. * Created by: Owen
  1030. * Created on: 2019/9/2 14:57
  1031. * Description:
  1032. */
  1033. public function getActivity($activityId){
  1034. $Activity = oo::commonOprRedis('common')->hGetAll(okeys::Activity());
  1035. foreach ($Activity as $key=>$row){
  1036. $temp = explode('#',$key);
  1037. if($activityId == $temp[0]){
  1038. $ac = json_decode($row,true);
  1039. $ac['start'] = $temp[1];
  1040. $ac['end'] = $temp[2];
  1041. $ac['openLv'] = $temp[3];
  1042. return $ac;
  1043. }
  1044. }
  1045. return false;
  1046. }
  1047. public $activityLock = [];
  1048. /**
  1049. * 活动开关
  1050. * @param $uid
  1051. * @param $activityId
  1052. * @param $flag--根据该参数确定新旧版本
  1053. * @return bool
  1054. * Created by: Owen
  1055. * Created on: 2019/9/2 14:57
  1056. * Description:
  1057. */
  1058. public function activityLock($uid,$activityId,$flag = false){
  1059. if($activityId == 8){
  1060. $cache = oo::commonOprRedis('activity')->get(okeys::ActivityTemp($uid,8));
  1061. if($cache){
  1062. return json_decode($cache,true);
  1063. }
  1064. }
  1065. $Activity = oo::commonOprRedis('common')->hGetAll(okeys::Activity());
  1066. if(empty($Activity)){
  1067. return false;
  1068. }
  1069. $time = time();
  1070. foreach ($Activity as $key=>$row){
  1071. $temp = explode('#',$key);
  1072. if($temp[0] == $activityId){
  1073. if($temp[2]>$time){
  1074. if($temp[1]<$time){
  1075. $userInfo = oo::commonOprModel('member')->getUserAssetsInfo($uid);
  1076. if($userInfo['levelId'] >= $temp[3]){
  1077. $ac = json_decode($row,true);
  1078. $ac['start'] = $temp[1];
  1079. $ac['end'] = $temp[2];
  1080. $ac['openLv'] = $temp[3];
  1081. if(!in_array($activityId,[5,12])){
  1082. oo::commonOprRedis('Activity')->setnx(okeys::ActivityOnLinePush($activityId),1) && self::activityChangeStatus(['actId'=>$activityId,'status'=>1,'startTime'=>$ac['start']]);
  1083. }
  1084. return $ac;
  1085. }
  1086. }
  1087. }else{
  1088. self::outLine($activityId);
  1089. }
  1090. }
  1091. }
  1092. return false;
  1093. }
  1094. /**
  1095. * 支付等级
  1096. * @param $uid
  1097. * @return int
  1098. * Created by: Owen
  1099. * Created on: 2019/8/14 15:32
  1100. * Description:
  1101. */
  1102. private function PayLevel($uid){
  1103. $tb = otable::payment($uid);
  1104. $sql = "SELECT SUM(push) AS sum FROM {$tb} WHERE uid={$uid} AND status=2";
  1105. $ret = oo::commonOprDb('payment')->getOne($sql,MYSQLI_ASSOC);
  1106. $sum = $ret['sum'];
  1107. $level = 1;
  1108. $tb = otable::payLevel();
  1109. $sql = "SELECT * FROM {$tb} WHERE 1";
  1110. $ret = oo::commonOprDb('config')->getAll($sql,MYSQLI_ASSOC);
  1111. foreach ($ret as $row){
  1112. if(is_numeric($row['num'])){
  1113. if($sum >= $row['num']){
  1114. $level = $row['level'];
  1115. }else{
  1116. return $level;
  1117. }
  1118. }else{
  1119. return $row['level'];
  1120. }
  1121. }
  1122. }
  1123. /**
  1124. * 关卡等级
  1125. * @param $uid
  1126. * @return int
  1127. * Created by: Owen
  1128. * Created on: 2019/8/14 14:29
  1129. * Description:
  1130. */
  1131. private function levelLevel($uid){
  1132. $userInfo = oo::commonOprModel('member')->getUserAssetsInfo($uid);
  1133. $userLevel = intval($userInfo['levelId']);
  1134. $beginGuide = oo::commonOprRedis('common')->hGet(okeys::beginGuide(),$uid);
  1135. if($beginGuide != false){
  1136. return 0;
  1137. }
  1138. $level = 1;
  1139. $tb = otable::activityLevel();
  1140. $sql = "SELECT * FROM {$tb} WHERE 1";
  1141. $ret = oo::commonOprDb('config')->getAll($sql,MYSQLI_ASSOC);
  1142. foreach ($ret as $row){
  1143. if($userLevel >= $row['num']){
  1144. $level = $row['level'];
  1145. }else{
  1146. return $level;
  1147. }
  1148. }
  1149. }
  1150. public function refreshActivity($id,$del = true){
  1151. if($id == 2){
  1152. $activity = [];
  1153. $keys = oo::commonOprRedis('common')->hGetAll(okeys::SymbolStage());
  1154. if(!empty($keys)){
  1155. foreach ($keys as $uid=>$row){
  1156. $activity[$uid] = $row;
  1157. }
  1158. $tb = otable::activitySta();
  1159. $date= date('Ymd H:i');
  1160. $data= json_encode($activity);
  1161. $sql = "INSERT INTO {$tb} VALUES({$id},'{$date}','{$data}') ";
  1162. oo::commonOprDb('statistics')->query($sql,false);
  1163. $del && oo::commonOprRedis('common')->delete([okeys::SymbolStage(),okeys::SymbolNum()]);
  1164. }
  1165. }
  1166. if($id == 3){
  1167. $activity = oo::commonOprRedis('common')->hGetAll(okeys::BalloonCount());
  1168. if(!empty($activity)){
  1169. $tb = otable::activitySta();
  1170. $date= date('Ymd H:i');
  1171. $data= json_encode($activity);
  1172. $sql = "INSERT INTO {$tb} VALUES({$id},'{$date}','{$data}') ";
  1173. oo::commonOprDb('statistics')->query($sql,false);
  1174. $del && oo::commonOprRedis('common')->delete(okeys::BalloonCount());
  1175. }
  1176. }
  1177. if($id == 6){
  1178. $stageKey = okeys::StealAttackStage();
  1179. $numKey = okeys::StealAttackNum();
  1180. //偷打活动统计
  1181. $activity = [];
  1182. $keys = oo::commonOprRedis('common')->hGetAll($numKey);
  1183. if(!empty($keys)) {
  1184. foreach ($keys as $uid => $row) {
  1185. $activity[$uid] = $row;
  1186. }
  1187. $tb = otable::activitySta();
  1188. $date = date('Ymd H:i');
  1189. $data = json_encode($activity);
  1190. $sql = "INSERT INTO {$tb} VALUES({$id},'{$date}','{$data}') ";
  1191. oo::commonOprDb('statistics')->query($sql, false);
  1192. $del && oo::commonOprRedis('common')->delete([$stageKey, $numKey]);
  1193. }
  1194. }
  1195. if($id == 7){
  1196. $stageKey = okeys::HolidayCollectStage();
  1197. $numKey = okeys::HolidayCollectNum();
  1198. oo::commonOprRedis('common')->delete([$stageKey,$numKey]);
  1199. }
  1200. if($id == 8){
  1201. oo::commonOprRedis('common')->delete(okeys::BuildMaster());
  1202. }
  1203. if($id == 11){
  1204. oo::commonOprRedis('common')->set(okeys::JackPotPool(),5000000);
  1205. oo::commonOprRedis('common')->delete(okeys::LastJackPot("reward"));
  1206. oo::commonOprRedis('common')->delete(okeys::LastJackPot("push"));
  1207. oo::commonOprRedis('common')->delete(okeys::LastJackPot("systemAdd"));
  1208. }
  1209. if($id == 13) {
  1210. $roomId = self::getRankCurMaxRoomId();
  1211. $activity = ['number'=>[],'rank'=>[],'progress'=>[]];//排行榜活动统计
  1212. for ($i=1;$i<=$roomId;$i++){
  1213. $result = oo::commonOprRedis('common')->zRange(okeys::ActivityRank($i),0,-1,true);
  1214. foreach ($result as $uid => $num){
  1215. $activity['number'][$uid] = $num;
  1216. $activity['rank'][$i][$uid] = self::getCurUserRank($uid);
  1217. $activity['progress'][$uid] = self::getRankProgressId($uid);
  1218. }
  1219. $del && oo::commonOprRedis('Activity')->delete([okeys::AcRankRoomIdUsers($i),okeys::ActivityRank($i)]);
  1220. }
  1221. $del && oo::commonOprRedis('Activity')->delete(okeys::AcRankCurMaxRoomId());
  1222. $del && oo::commonOprRedis('common')->delete([
  1223. okeys::AcUserRankRoomId(),
  1224. okeys::ActivityRankProgress("NUM"),
  1225. okeys::ActivityRankProgress("ID"),
  1226. okeys::ActivityRankProgress("LASTREWARD"),
  1227. okeys::ActivityRankProgress("DAY"),
  1228. okeys::ActivityRankProgress("BARID"),
  1229. okeys::ActivityRankProgress("BARNUM"),
  1230. okeys::ActivityRankProgress("CARD"),
  1231. okeys::RewardedAcRank(),
  1232. okeys::RewardedAcRankProgress(),
  1233. okeys::ActivityRankPush(),
  1234. okeys::ActivityRankPushLock("PUSH"),
  1235. okeys::ActivityRankPushLock("PUSHED")
  1236. ]);
  1237. //排行榜活动统计
  1238. $activityStaTb = otable::activitySta();
  1239. $date= date('Ymd H:i');
  1240. $data= json_encode($activity);
  1241. $sql = "INSERT INTO {$activityStaTb} VALUES({$id},'{$date}','{$data}') ";
  1242. oo::commonOprDb('statistics')->query($sql,false);
  1243. }
  1244. if($id == 15) {
  1245. oo::commonOprRedis('User')->delete(okeys::SerialPackTimer());
  1246. }
  1247. if($id == 16) {
  1248. oo::commonOprRedis('Activity')->delete([
  1249. okeys::TreasureTaskCard(),
  1250. okeys::TreasureTaskId(),
  1251. okeys::TreasureTaskNum(),
  1252. okeys::TreasureCurTaskType(),
  1253. okeys::treasureQuestGiftLog()
  1254. ]);
  1255. }
  1256. return true;
  1257. }
  1258. public function cycleActivity($id){
  1259. $activity = oo::commonOprRedis('common')->hGet(okeys::ActivityData(),$id);
  1260. if(empty($activity)){
  1261. return false;
  1262. }
  1263. $activityLock = oo::commonOprRedis('common')->hGetAll(okeys::Activity());
  1264. if(!empty($activityLock)){
  1265. foreach ($activityLock as $key=>$row){
  1266. $temp = explode('#',$key);
  1267. if($temp[0] == $id){
  1268. return false;
  1269. }
  1270. }
  1271. }
  1272. $time = time();
  1273. $activity = json_decode($activity,true);
  1274. if($activity['end_time']<=$time){
  1275. oo::commonOprRedis('common')->hDel(okeys::ActivityData(),$id);
  1276. }
  1277. $lastTime = $activity['last_time'];
  1278. $times = $activity['lock_time']*60*60;
  1279. if($lastTime+$times>$time){
  1280. return false;
  1281. }
  1282. $temp = [
  1283. 'name' =>$activity['name'],
  1284. 'name_en' =>$activity['name_en'],
  1285. 'package' =>$activity['package'],
  1286. 'sort' =>$activity['sort'],
  1287. 'actType' =>$activity['actType'],
  1288. 'bname' =>$activity['bname'],
  1289. 'bname_en'=>$activity['bname_en'],
  1290. ];
  1291. if($id == 2){
  1292. $temp['dialogImg'] = $activity['dialogImg'];
  1293. $temp['slotImg'] = $activity['slotImg'];
  1294. $temp['buttonImg'] = $activity['buttonImg'];
  1295. $temp['activityType'] = $activity['activityType'];
  1296. $temp['activityName'] = $activity['activityName'];
  1297. $temp['textColor'] = $activity['textColor'];
  1298. }else if($id == 6 || $id == 3 || $id == 7){
  1299. $temp['activityType'] = $activity['activityType'];
  1300. $temp['activityName'] = $activity['activityName'];
  1301. }
  1302. $lastTime = $activity['last_time'] + $activity['lock_time']*60*60 + $activity['action_time']*60*60;
  1303. if($lastTime>$activity['end_time']){
  1304. $lastTime = $activity['end_time'];
  1305. }
  1306. oo::commonOprRedis('common')->hSet(okeys::Activity(),$id."#".$activity['start_time']."#".$lastTime."#".$activity['openlv'],json_encode($temp));
  1307. $activity['last_time'] = $lastTime;
  1308. oo::commonOprRedis('common')->hSet(okeys::ActivityData(),$id,json_encode($activity));
  1309. $tb = otable::activity();
  1310. $sql = "UPDATE {$tb} SET is_online=1 WHERE id = {$id} LIMIT 1";
  1311. oo::commonOprDb('activity')->query($sql,false);
  1312. $this->refreshActivity($id);
  1313. return true;
  1314. }
  1315. /**
  1316. * 更新偷打活动数据
  1317. * @param $uid
  1318. * @param int $num
  1319. * @param int $from
  1320. * @return array|bool
  1321. * Created by: Owen
  1322. * Created on: 2019/12/4 19:49
  1323. */
  1324. public function updateStealAttack($uid,$num = 0,$from = 0){
  1325. $activityData = self::activityLock($uid,6,true);
  1326. if(!$activityData){
  1327. return false;
  1328. }
  1329. if($from == 1 || $from == 2){
  1330. if($activityData['activityType'] != $from){
  1331. return false;
  1332. }
  1333. }
  1334. $stageKey = okeys::StealAttackStage();
  1335. $stage = intval(oo::commonOprRedis('common')->hGet($stageKey,$uid)) + 1;
  1336. $config = oo::commonOprModel('config')->getStealAttackConfig($stage,2);
  1337. $baseCoins = 1;
  1338. if($config['type'] == 1){
  1339. $assetsInfo = oo::commonOprModel('member')->getUserAssetsInfo($uid);
  1340. if($activityData['activityType'] == 1){
  1341. $baseCoins = oo::commonOprModel('config')->getActivityCoins($assetsInfo['levelId'],"steal");
  1342. }else{
  1343. $baseCoins = oo::commonOprModel('config')->getActivityCoins($assetsInfo['levelId'],"attack");
  1344. }
  1345. }
  1346. $numKey = okeys::StealAttackNum();
  1347. $data = [
  1348. 'stage' => intval(oo::commonOprRedis('common')->hGet($stageKey,$uid)) + 1,
  1349. 'num' => intval(oo::commonOprRedis('common')->hGet($numKey,$uid)),
  1350. 'maxNum'=> $config['max'],
  1351. 'type' => $config['type'],
  1352. 'reward'=> $config['num'] * $baseCoins
  1353. ];
  1354. if($num == 0){
  1355. return $data;
  1356. }
  1357. oo::commonOprRedis('common')->hIncrBy($numKey,$uid,$num);
  1358. $data['num'] = $data['num']+$num;
  1359. return $data;
  1360. }
  1361. /**
  1362. * 偷打活动领奖
  1363. * @param $uid
  1364. * @return mixed
  1365. * Created by: Owen
  1366. * Created on: 2019/12/4 17:56
  1367. */
  1368. public function rewardStealAttack($uid){
  1369. $data = self::updateStealAttack($uid);
  1370. $stageKey = okeys::StealAttackStage();
  1371. $numKey = okeys::StealAttackNum();
  1372. if($data){
  1373. if($data['maxNum']<=$data['num']){
  1374. oo::commonOprRedis('common')->hIncrBy($numKey,$uid,-$data['maxNum']);
  1375. oo::commonOprRedis('common')->hIncrBy($stageKey,$uid,1);
  1376. if($data['type'] == 1){
  1377. $type = 'money';
  1378. }else if($data['type'] == 2){
  1379. $type = 'spins';
  1380. }
  1381. oo::commonOprModel('member')->optProperty($uid,[$type=>$data['reward']],'+',211,'偷打活动:'.$data['stage']);
  1382. return oo::response(1,[
  1383. 'reward'=>['type' => $data['type'], 'num'=> $data['reward']],
  1384. 'cur' =>self::updateStealAttack($uid)
  1385. ],'',true);
  1386. }else{
  1387. return oo::response(-2,$data,'阶段未达标');
  1388. }
  1389. }
  1390. }
  1391. /**
  1392. * 更新节日收集进度
  1393. * @param $uid
  1394. * @param int $num
  1395. * @return array|bool
  1396. * Created by: Owen
  1397. * Created on: 2019/12/10 17:05
  1398. */
  1399. public function updateHolidayCollect($uid,$num = 0){
  1400. if(!self::activityLock($uid,7,true)){
  1401. return false;
  1402. }
  1403. $stageKey = okeys::HolidayCollectStage();
  1404. $numKey = okeys::HolidayCollectNum();
  1405. $stage = oo::commonOprRedis('common')->hGet($stageKey,$uid);
  1406. $stage = empty($stage)?[]:json_decode($stage,true);
  1407. $data = [
  1408. 'stage' => $stage,
  1409. 'num' => intval(oo::commonOprRedis('common')->hGet($numKey,$uid)),
  1410. ];
  1411. if($num == 0){
  1412. return $data;
  1413. }
  1414. $data['num'] += $num;
  1415. oo::commonOprRedis('common')->hIncrBy($numKey,$uid,$num);
  1416. return $data;
  1417. }
  1418. /**
  1419. * 节日收集进度奖励
  1420. * @param $uid
  1421. * @param $stage
  1422. * @return string
  1423. * Created by: Owen
  1424. * Created on: 2019/12/10 17:06
  1425. */
  1426. public function rewardHolidayCollect($uid,$stage){
  1427. $stageKey = okeys::HolidayCollectStage();
  1428. $userStage = oo::commonOprRedis('common')->hGet($stageKey,$uid);
  1429. $userStage = empty($userStage)?[]:json_decode($userStage,true);
  1430. $data = [
  1431. 'stage' => $userStage,
  1432. ];
  1433. if(in_array($stage,$data['stage'])){
  1434. return oo::response(-2,[],'已领取过');
  1435. }
  1436. $numKey = okeys::HolidayCollectNum();
  1437. $data['num'] = intval(oo::commonOprRedis('common')->hGet($numKey,$uid));
  1438. $config = oo::commonOprModel('config')->getHolidayCollectConfig($stage);
  1439. if($config['max']>$data['num']){
  1440. return oo::response(-3,[],'阶段未达标');
  1441. }
  1442. $data['stage'][] = $stage;
  1443. oo::commonOprRedis('common')->hSet($stageKey,$uid,json_encode($data['stage']));
  1444. $coins = oo::commonOprModel('goods')->getGoodCoins($uid,'coins01');
  1445. $reward = [
  1446. 'spins' => $config['spins'],
  1447. 'money' => $coins*$config['money'],
  1448. ];
  1449. oo::commonOprModel('member')->optProperty($uid,$reward,'+',202,'节日收集活动:'.$stage);
  1450. $chest = json_decode($config['chest'],true);
  1451. oo::commonOprModel('props')->addUserProps($uid,$chest['id'],$chest['num']);
  1452. $reward['card'] = [];
  1453. $reward['coins'] = $reward['money'];
  1454. return oo::response(1,$reward,'',true);
  1455. }
  1456. /**
  1457. * 建筑大师
  1458. * @param $uid
  1459. * @return string
  1460. * Created by: Owen
  1461. * Created on: 2019/12/17 16:11
  1462. */
  1463. public function rewardBuildMaster($uid){
  1464. $key = okeys::BuildMaster();
  1465. $userData = oo::commonOprRedis('common')->hGet($key,$uid);
  1466. if(empty($userData)){
  1467. return oo::response(-2);
  1468. }else{
  1469. $userData = json_decode($userData,true);
  1470. $min = 0;
  1471. $dataKey = 0;
  1472. foreach ($userData as $k=>$row){
  1473. if($min>$row || $min==0){
  1474. $min = $row;
  1475. $dataKey = $k;
  1476. }
  1477. }
  1478. if($min == 0){
  1479. oo::commonOprRedis('common')->hDel($key,$uid);
  1480. return oo::response(-2);
  1481. }
  1482. unset($userData[$dataKey]);
  1483. $userData = array_filter(array_unique($userData));
  1484. sort($userData);
  1485. if(empty($userData)){
  1486. oo::commonOprRedis('common')->hDel($key,$uid);
  1487. }else{
  1488. oo::commonOprRedis('common')->hSet($key,$uid,json_encode($userData));
  1489. }
  1490. $config = oo::commonOprModel('config')->getBuildMasterConfig($min);
  1491. $reward = [
  1492. 'money' => oo::commonOprModel('goods')->getGoodCoinsByLevelId($min,$config['money']) / 2,
  1493. 'spins' => $config['spins'],
  1494. ];
  1495. oo::commonOprModel('member')->optProperty($uid,$reward,'+',203,'建筑大师:'.$min);
  1496. $chest = json_decode($config['chest'],true);
  1497. oo::commonOprModel('props')->addUserProps($uid,$chest['id'],$chest['num']);
  1498. $reward['card'] = [];
  1499. return oo::response(1,$reward,'',true);
  1500. }
  1501. }
  1502. /**
  1503. * jackPot 获取当前奖池金额
  1504. * @return int
  1505. * created by owen
  1506. * created at 11:53
  1507. */
  1508. public function getJackPotPool(){
  1509. self::systemAddJackPotPool();
  1510. return intval(oo::commonOprRedis('common')->get(okeys::JackPotPool()));
  1511. }
  1512. /**
  1513. * jackPot 追加奖池
  1514. * @param $uid
  1515. * @param $money
  1516. * @return bool
  1517. * created by owen
  1518. * created at 11:44
  1519. */
  1520. public function slotAddJackPotPool($uid,$money){
  1521. oo::commonOprRedis('common')->incrBy(okeys::JackPotPool(),$money);
  1522. if(!funs::concurrentLock(1,'slotAddJackPotPool',10)){
  1523. return true;
  1524. }
  1525. oo::commonOprModel('Workerman')->pushAll(ocmd::$send['JackPotPool'],['curPoolNum'=>self::getJackPotPool()]);
  1526. }
  1527. /**
  1528. * jackPot 中奖
  1529. * @param $uid
  1530. * @return mixed
  1531. * created by owen
  1532. * created at 12:46
  1533. */
  1534. public function rewardJackPot($uid){
  1535. $curPoolNum = self::getJackPotPool();
  1536. oo::commonOprRedis('common')->set(okeys::JackPotPool(),0);
  1537. $protectedTime = 300;
  1538. oo::commonOprModel('member')->setUserStealProtect($uid,$protectedTime);
  1539. oo::commonOprModel('Workerman')->push($uid,ocmd::$send['stealProtected'],[ 'expireTime' => time() + $protectedTime]);
  1540. oo::commonOprModel('member')->optProperty($uid,['money'=>$curPoolNum],'+',212,'JackPot活动');
  1541. $userinfo = oo::commonOprModel('member')->getUserInfo($uid);//玩家基本信息
  1542. $pushData = [
  1543. 'curPoolNum'=> $curPoolNum,
  1544. 'uid' => $uid,
  1545. 'nick' => oo::commonOprModel('member')->getUserFirstName($userinfo['nick']),
  1546. 's_picture' => $userinfo['s_picture'],
  1547. 'vip' => $userinfo['vip'],
  1548. 'vipLv' => $userinfo['vipLv'],
  1549. 'avatar' => $userinfo['avatar'],
  1550. ];
  1551. oo::commonOprModel('Workerman')->pushAll(ocmd::$send['JackPotReward'],$pushData);
  1552. oo::commonOprRedis('common')->setex(okeys::LastJackPot("reward"),time(),24*60*60);
  1553. return $pushData;
  1554. }
  1555. public function systemAddJackPotPool(){
  1556. $curPoolNum = intval(oo::commonOprRedis('common')->get(okeys::JackPotPool()));
  1557. if($curPoolNum < 5000000){
  1558. $lastSystemAddTime = oo::commonOprRedis('common')->get(okeys::LastJackPot("systemAdd"));
  1559. if(!$lastSystemAddTime){
  1560. oo::commonOprRedis('common')->setex(okeys::LastJackPot("systemAdd"),time(),20);
  1561. return false;
  1562. }
  1563. $addNum = ceil((time() - $lastSystemAddTime)/2);
  1564. oo::commonOprRedis('common')->incrBy(okeys::JackPotPool(),$addNum*random_int(2750,3250));
  1565. oo::commonOprRedis('common')->setex(okeys::LastJackPot("systemAdd"),time(),20);
  1566. }
  1567. }
  1568. /**
  1569. * 机器人领奖
  1570. * created by owen
  1571. * created at 12:53
  1572. */
  1573. public function robotRewardJackPot(){
  1574. if(!self::isOnLine(11)){
  1575. return -1;
  1576. }
  1577. $curPoolNum = self::getJackPotPool();
  1578. $lastRewardTime = oo::commonOprRedis('common')->get(okeys::LastJackPot("reward"));
  1579. if(!$lastRewardTime){
  1580. oo::commonOprRedis('common')->setex(okeys::LastJackPot("reward"),time(),24*60*60);
  1581. }
  1582. $time = intval(oo::commonOprModel('readconfig')->getCon('basic',"jackRobotTime")); //限制
  1583. $limit= intval(oo::commonOprModel('readconfig')->getCon('basic',"jackRobotLimit")); //限制
  1584. if(($lastRewardTime + $time*60) < time() || ($curPoolNum > $limit && ($lastRewardTime + 60 < time()))){
  1585. $robot = oo::commonOprModel('robot')->getAllRobot();
  1586. $robotUid = $robot[array_rand($robot,1)];
  1587. oo::commonOprRedis('common')->getSet(okeys::JackPotPool(),0);
  1588. $userinfo = oo::commonOprModel('member')->getUserInfo($robotUid);//玩家基本信息
  1589. $pushData = [
  1590. 'curPoolNum'=> $curPoolNum,
  1591. 'uid' => $robotUid,
  1592. 'nick' => $userinfo['nick'],
  1593. 's_picture' => $userinfo['s_picture'],
  1594. 'vip' => $userinfo['vip'],
  1595. 'vipLv' => $userinfo['vipLv'],
  1596. 'avatar' => $userinfo['avatar'],
  1597. ];
  1598. oo::commonOprModel('Workerman')->pushAll(ocmd::$send['JackPotReward'],$pushData);
  1599. oo::commonOprRedis('common')->setex(okeys::LastJackPot("reward"),time(),24*60*60);
  1600. }
  1601. }
  1602. /**
  1603. * 排行榜活动当前最大房间号
  1604. * @return mixed
  1605. * created by owen
  1606. * created at 22:02
  1607. */
  1608. public function getRankCurMaxRoomId(){
  1609. $key = okeys::AcRankCurMaxRoomId();
  1610. $cache = oo::commonOprRedis('Activity')->get($key);
  1611. if(!empty($cache)){
  1612. return $cache;
  1613. }
  1614. $roomId = 1;
  1615. oo::commonOprRedis('Activity')->set($key,$roomId);
  1616. return $roomId;
  1617. }
  1618. /**
  1619. * 房间号真实用户
  1620. * @return array
  1621. * created by owen
  1622. * created at 22:02
  1623. */
  1624. public function getRankCurRoomUsers(){
  1625. $key = okeys::AcRankRoomIdUsers(self::getRankCurMaxRoomId());
  1626. $cache = oo::commonOprRedis('Activity')->sMembers($key);
  1627. if(!empty($cache)){
  1628. return $cache;
  1629. }
  1630. return [];
  1631. }
  1632. /**
  1633. * 获取房间用户
  1634. * @param $roomId
  1635. * @return array
  1636. * Created by: Owen
  1637. * Created on: 2020/7/4 15:03
  1638. */
  1639. public function getRankRoomUsers($roomId){
  1640. $cache = oo::commonOprRedis('Activity')->sMembers(okeys::AcRankRoomIdUsers($roomId));
  1641. if(!empty($cache)){
  1642. return $cache;
  1643. }
  1644. return [];
  1645. }
  1646. /**
  1647. * 加入房间
  1648. * @param $uid
  1649. * @return string
  1650. * created by owen
  1651. * created at 14:06
  1652. */
  1653. public function addToRankRoom($uid){
  1654. if(self::getUserRankRoomId($uid)){
  1655. return oo::response(-3,[],"已加入房间",true);
  1656. }
  1657. $curRoomUsers = self::getRankCurRoomUsers();
  1658. $score = oo::commonOprRedis('Activity')->hGet(okeys::ActivityRankProgress("NUM"),$uid);
  1659. if($score < 5){
  1660. return oo::response(-2,[],"未达标开始");
  1661. }
  1662. $roomId = self::getRankCurMaxRoomId();
  1663. if(count($curRoomUsers) >= 50){
  1664. $roomId += 1;
  1665. oo::commonOprRedis('Activity')->zAdd(okeys::ActivityRank($roomId),$score,$uid);
  1666. oo::commonOprRedis('Activity')->sAdd(okeys::AcRankRoomIdUsers($roomId),$uid);
  1667. oo::commonOprRedis('Activity')->incr(okeys::AcRankCurMaxRoomId());
  1668. }else{
  1669. oo::commonOprRedis('Activity')->zAdd(okeys::ActivityRank($roomId),$score,$uid);
  1670. oo::commonOprRedis('Activity')->sAdd(okeys::AcRankRoomIdUsers($roomId),$uid);
  1671. }
  1672. oo::commonOprRedis('Activity')->hSet(okeys::AcUserRankRoomId(),$uid,$roomId);
  1673. //判断进度奖励是否有卡片
  1674. $config = oo::commonOprModel('config')->getActivityRankProgressConfig();
  1675. $configTemp = end($config);
  1676. $cardData = null;
  1677. if(!empty($configTemp['props'])) {
  1678. $configTemp['props'] = json_decode($configTemp['props'], 1);
  1679. foreach ($configTemp['props'] as $key => $row) {
  1680. if ($row['propsId'] == -1) {
  1681. $cardData = self::getRankCard($uid);
  1682. oo::commonOprRedis('Activity')->hSet(okeys::ActivityRankProgress("CARD"), $uid, json_encode($cardData));
  1683. break;
  1684. }
  1685. }
  1686. }
  1687. return oo::response(1,['selfData'=>self::getUserRankData($uid),'rankData'=>self::getAllUserRankByUid($uid),'cardData'=>$cardData],"",true);
  1688. }
  1689. /**
  1690. * 获取用户排行榜数据
  1691. * @param $uid
  1692. * @return mixed
  1693. * created by owen
  1694. * created at 13:54
  1695. */
  1696. public function getUserRankData($uid){
  1697. if(!self::activityLock($uid,13,true)){
  1698. return false;
  1699. }
  1700. $roomId = self::getUserRankRoomId($uid);
  1701. if(empty($roomId)){
  1702. return [
  1703. 'roomId' => 0,
  1704. 'curRankId' => 0,
  1705. 'curRankNum' => 0,
  1706. 'isRankReward' => intval(oo::commonOprRedis('Activity')->hGet(okeys::RewardedAcRank(),$uid)),
  1707. 'curRankProgressNum' => self::getRankProgress($uid),
  1708. 'curRankProgressId' => 0,
  1709. 'cardData' => null,
  1710. ];
  1711. }
  1712. //卡片
  1713. $cardData = oo::commonOprRedis('Activity')->hGet(okeys::ActivityRankProgress("CARD"),$uid);
  1714. if(empty($cardData)){
  1715. //判断进度奖励是否有卡片
  1716. $config = oo::commonOprModel('config')->getActivityRankProgressConfig();
  1717. $configTemp = end($config);
  1718. if(!empty($configTemp['props'])) {
  1719. $configTemp['props'] = json_decode($configTemp['props'], 1);
  1720. foreach ($configTemp['props'] as $key => $row) {
  1721. if ($row['propsId'] == -1) {
  1722. $cardData = self::getRankCard($uid);
  1723. oo::commonOprRedis('Activity')->hSet(okeys::ActivityRankProgress("CARD"), $uid, json_encode($cardData));
  1724. break;
  1725. }
  1726. }
  1727. }
  1728. }else{
  1729. $cardData = json_decode($cardData,1);
  1730. }
  1731. return [
  1732. 'roomId' => $roomId,
  1733. 'curRankId' => self::getCurUserRank($uid) + 1,
  1734. 'curRankNum' => self::getNumRank($uid),
  1735. 'isRankReward' => intval(oo::commonOprRedis('Activity')->hGet(okeys::RewardedAcRank(),$uid)),
  1736. 'curRankProgressNum' => self::getRankProgress($uid,true),
  1737. 'curRankProgressId' => self::getRankProgressId($uid),
  1738. 'cardData' => $cardData,
  1739. ];
  1740. }
  1741. /**
  1742. * 获取用户房间号
  1743. * @param $uid
  1744. * @return int
  1745. * created by owen
  1746. * created at 15:55
  1747. */
  1748. public function getUserRankRoomId($uid){
  1749. $key = okeys::AcUserRankRoomId();
  1750. $cache = oo::commonOprRedis('Activity')->hGet($key,$uid);
  1751. if(!empty($cache)){
  1752. return $cache;
  1753. }
  1754. return 0;
  1755. }
  1756. /**
  1757. * 获取房间排行榜 -- 房间号
  1758. * @param int $roomId
  1759. * @param int $star
  1760. * @param int $end
  1761. * @return mixed
  1762. * created by owen
  1763. * created at 18:06
  1764. */
  1765. public function getAllUserRankByRoomId($roomId,$star = 0,$end = 50){
  1766. if(empty($roomId)){
  1767. return [];
  1768. }
  1769. return oo::commonOprRedis('Activity')->zRevRange(okeys::ActivityRank($roomId),$star,$end,true);
  1770. }
  1771. /**
  1772. * 获取房间排行榜 -- 用户号
  1773. * @param int $uid
  1774. * @param int $star
  1775. * @param int $end
  1776. * @return mixed
  1777. * created by owen
  1778. * created at 18:06
  1779. */
  1780. public function getAllUserRankByUid($uid,$star = 0,$end = 50){
  1781. $users = self::getAllUserRankByRoomId(self::getUserRankRoomId($uid),$star,$end);
  1782. if(empty($users)){
  1783. return [];
  1784. }
  1785. $data = [];
  1786. $i = 0;
  1787. foreach ($users as $key=>$row){
  1788. $userinfo = oo::commonOprModel('member')->getUserInfo($key);
  1789. $data[] = [
  1790. 'rankId' => $i+1,
  1791. 'uid' => $key,
  1792. 'nick' => oo::commonOprModel('member')->getUserFirstName($userinfo['nick']),
  1793. 's_picture' => $userinfo['s_picture'],
  1794. 'vip' => $userinfo['vip'],
  1795. 'vipLv' => $userinfo['vipLv'],
  1796. 'vipExpire' => $userinfo['vip_expire'],
  1797. 'avatar' => $userinfo['avatar'],
  1798. 'curRankNum'=> $row,
  1799. ];
  1800. $i++;
  1801. }
  1802. return $data;
  1803. }
  1804. /**
  1805. * 获取当前用户排行
  1806. * @param $uid
  1807. * @return mixed
  1808. * created by owen
  1809. * created at 18:07
  1810. */
  1811. public function getCurUserRank($uid){
  1812. return oo::commonOprRedis('Activity')->zRevRank(okeys::ActivityRank(self::getUserRankRoomId($uid)),$uid);
  1813. }
  1814. /**
  1815. * 获取当前用户排行值
  1816. * @param $uid
  1817. * @return int
  1818. * created by owen
  1819. * created at 9:43
  1820. */
  1821. public function getNumRank($uid){
  1822. return intval(oo::commonOprRedis('Activity')->zScore(okeys::ActivityRank(self::getUserRankRoomId($uid)),$uid));
  1823. }
  1824. /**
  1825. * 追加排行榜活动进度
  1826. * @param $uid
  1827. * @param $num
  1828. * @return int
  1829. * created by owen
  1830. * created at 16:15
  1831. */
  1832. public function addNumRank($uid,$num){
  1833. $roomID = self::getUserRankRoomId($uid);
  1834. if(!$roomID){
  1835. return 0;
  1836. }
  1837. return intval(oo::commonOprRedis('Activity')->zIncrBy(okeys::ActivityRank($roomID),$num,$uid));
  1838. }
  1839. /**
  1840. * 排行榜活动奖励
  1841. * @param $uid
  1842. * @return string
  1843. * created by owen
  1844. * created at 13:53
  1845. */
  1846. public function rewardRank($uid){
  1847. $key = okeys::RewardedAcRank();
  1848. $cache = oo::commonOprRedis('Activity')->hGet($key,$uid);
  1849. if(!empty($cache)){
  1850. return oo::response(-2,[],"奖励已领取过");
  1851. }
  1852. $roomId = self::getUserRankRoomId($uid);
  1853. $isSet = true;
  1854. $curRank = oo::commonOprRedis('Activity')->zRevRank(okeys::ActivityRank($roomId),$uid);
  1855. if($curRank !== false){
  1856. $curRank += 1;
  1857. $config = oo::commonOprModel('config')->getActivityRankConfig($curRank);
  1858. oo::commonOprRedis('Activity')->setex(okeys::ActivityRankPushLock("PUSH"),1,3*24*60*60);
  1859. }else{
  1860. $randId = oo::commonOprRedis('Activity')->hGet(okeys::ActivityRankPushData(),$uid);
  1861. $isSet = false;
  1862. if(!$randId){
  1863. return oo::response(-4,[],"活动结束领奖标识异常");
  1864. }
  1865. $config = oo::commonOprModel('config')->getActivityRankConfig($randId);
  1866. }
  1867. $add = [
  1868. 'money' => $config['coins'],
  1869. 'spins' => $config['spins']
  1870. ];
  1871. oo::commonOprModel('member')->optProperty($uid, $add, '+',208,'排行榜活动');
  1872. $props = json_decode($config['props'],true);
  1873. if(!empty($props)){
  1874. oo::commonOprModel('props')->addUserProps($uid,$props['propsId'],$props['num']);
  1875. }
  1876. $isSet && oo::commonOprRedis('Activity')->hSet($key,$uid,1);
  1877. oo::commonOprRedis('Activity')->hDel(okeys::ActivityRankPushData(),$uid);
  1878. return oo::response(1);
  1879. }
  1880. /**
  1881. * 当前获取进度
  1882. * @param $uid
  1883. * @param $addBar
  1884. * @return int
  1885. * created by owen
  1886. * created at 17:44
  1887. */
  1888. public function getRankProgress($uid,$addBar = false){
  1889. $barNum = 0;
  1890. if($addBar){
  1891. $barNum = oo::commonOprRedis('Activity')->hGet(okeys::ActivityRankProgress("BARNUM"),$uid);
  1892. }
  1893. return $barNum + intval(oo::commonOprRedis('Activity')->hGet(okeys::ActivityRankProgress("NUM"),$uid));
  1894. }
  1895. /**
  1896. * 获取当前阶段进度值
  1897. * @param $uid
  1898. * @return int
  1899. * created by owen
  1900. * created at 13:53
  1901. */
  1902. public function getRankProgressId($uid){
  1903. return intval(oo::commonOprRedis('Activity')->hGet(okeys::ActivityRankProgress("ID"),$uid));
  1904. }
  1905. /**
  1906. * 追加进度值
  1907. * @param $uid
  1908. * @param $num
  1909. * @return int
  1910. * created by owen
  1911. * created at 13:52
  1912. */
  1913. public function addNumRankProgress($uid,$num){
  1914. return intval(oo::commonOprRedis('Activity')->hIncrBy(okeys::ActivityRankProgress("NUM"),$uid,$num));
  1915. }
  1916. /**
  1917. * 统一增加
  1918. * @param $uid
  1919. * @param $num
  1920. * @return array
  1921. * created by owen
  1922. * created at 13:52
  1923. */
  1924. public function UniteAddNumRank($uid,$num){
  1925. return [
  1926. 'rank' => self::addNumRank($uid,$num),
  1927. 'progress' => self::addNumRankProgress($uid,$num),
  1928. ];
  1929. }
  1930. /**
  1931. * 阶段奖励
  1932. * @param $uid
  1933. * @return string
  1934. * created by owen
  1935. * created at 13:52
  1936. */
  1937. public function rewardRankProgress($uid){
  1938. $key = okeys::RewardedAcRankProgress();
  1939. $cache = oo::commonOprRedis('Activity')->hGet($key,$uid);
  1940. $id = self::getRankProgressId($uid) + 1;
  1941. if(intval($cache) >= $id && $id != 0){
  1942. return oo::response(-2,[],"奖励已领取");
  1943. }
  1944. $assetsInfo = oo::commonOprModel('member')->getUserAssetsInfo($uid);
  1945. $config = oo::commonOprModel('config')->getActivityRankProgressConfig($id,'1.6.1',$assetsInfo['levelId']);
  1946. if(empty($config)){
  1947. return oo::response(-3,[],"奖励不存在");
  1948. }
  1949. $curNum = self::getRankProgress($uid);
  1950. if($config['max'] <= $curNum){
  1951. oo::commonOprRedis('Activity')->hSet(okeys::ActivityRankProgress("LASTREWARD"),$uid,time());
  1952. oo::commonOprRedis('Activity')->hIncrBy(okeys::ActivityRankProgress("DAY"),$uid,1);
  1953. oo::commonOprRedis('Activity')->hIncrBy(okeys::ActivityRankProgress("ID"),$uid,1);
  1954. oo::commonOprRedis('Activity')->hIncrBy(okeys::ActivityRankProgress("NUM"),$uid,-$config['max']);
  1955. $barId = oo::commonOprRedis('Activity')->hGet(okeys::ActivityRankProgress("BARID"),$uid);
  1956. if($barId == false){
  1957. $barId = 1;
  1958. }
  1959. $nextConfig = oo::commonOprModel('config')->getActivityRankProgressConfig($id + 1);
  1960. if(intval($barId) == $nextConfig['progressBarId']){
  1961. oo::commonOprRedis('Activity')->hIncrBy(okeys::ActivityRankProgress("BARNUM"),$uid,$config['max']);
  1962. }else{
  1963. oo::commonOprRedis('Activity')->hSet(okeys::ActivityRankProgress("BARID"),$uid,$nextConfig['progressBarId']);
  1964. oo::commonOprRedis('Activity')->hSet(okeys::ActivityRankProgress("BARNUM"),$uid,0);
  1965. }
  1966. $limitTimeReward = oo::commonOprRedis('Activity')->hGet(okeys::AcRankLimitReward(),$uid);
  1967. if($limitTimeReward){
  1968. $limitTimeReward = json_decode($cache,true);
  1969. if($limitTimeReward['isReward'] == 0 && $limitTimeReward['lastTime'] < time()){
  1970. $config['coins'] = ceil($config['coins'] + $config['coins']*$limitTimeReward['percent']);
  1971. $config['spins'] = ceil($config['spins'] + $config['spins']*$limitTimeReward['percent']);
  1972. $limitTimeReward['isReward'] = 1;
  1973. oo::commonOprRedis('Activity')->hSet(okeys::AcRankLimitReward(),$uid,json_encode($limitTimeReward));
  1974. }
  1975. }
  1976. oo::commonOprModel('member')->optProperty($uid, ['money'=>$config['coins'],'spins'=>$config['spins']], '+',209,'排行榜活动阶段奖励:'.$config['id']);
  1977. $props = json_decode($config['props'],true);
  1978. if(!empty($props)){
  1979. if(count($props) == count($props, 1)){
  1980. //旧版本
  1981. oo::commonOprModel('props')->addUserProps($uid, $props['propsId'], $props['num']);
  1982. }else{
  1983. //1.6.1+
  1984. foreach($props as $key => $row){
  1985. if(!empty($row['propsId']) && !empty($row['num'])){
  1986. if($row['propsId'] == -1){
  1987. //卡片
  1988. $card = oo::commonOprRedis('Activity')->hGet(okeys::ActivityRankProgress("CARD"),$uid);
  1989. $card = json_decode($card,1);
  1990. if(!empty($card['id'])){
  1991. oo::commonOprModel('card')->getCardByType($uid,7,0,[$card['id']]);
  1992. }
  1993. }else{
  1994. oo::commonOprModel('props')->addUserProps($uid, $row['propsId'], $row['num']);
  1995. }
  1996. }
  1997. }
  1998. }
  1999. }
  2000. oo::commonOprRedis('Activity')->hSet($key,$uid,$id);
  2001. return oo::response(1,['selfData'=>self::getUserRankData($uid)]);
  2002. }else{
  2003. return oo::response(-4,[],"非达标");
  2004. }
  2005. }
  2006. public function triggerRankLimitReward($uid){
  2007. $cache = oo::commonOprRedis('Activity')->hGet(okeys::AcRankLimitReward(),$uid);
  2008. if($cache){
  2009. return json_decode($cache,true);
  2010. }
  2011. $lastReward = intval(oo::commonOprRedis('Activity')->hGet(okeys::ActivityRankProgress("LASTREWARD"),$uid));
  2012. $dayNum = intval(oo::commonOprRedis('Activity')->hGet(okeys::ActivityRankProgress("DAY"),$uid));
  2013. if($lastReward + 24*60*60 < time() || $dayNum>=3){
  2014. $lastTime = time() + 5*60 + 5;
  2015. $percent = 0.8;
  2016. oo::commonOprModel('Workerman')->push($uid,ocmd::$send['AcRankLimitTimeReward'],[
  2017. 'lastTime' => $lastTime - 5,
  2018. 'percent' => $percent,
  2019. ]);
  2020. $data = [
  2021. 'lastTime' => $lastTime,
  2022. 'percent' => $percent,
  2023. 'isReward' => 0
  2024. ];
  2025. oo::commonOprRedis('Activity')->hSet(okeys::AcRankLimitReward(),$uid,json_encode($data));
  2026. return $data;
  2027. }else{
  2028. return false;
  2029. }
  2030. }
  2031. public function doubleSpins($uid,$maxBet = 0,$autoSpins = 0){
  2032. $cacheKey = okeys::SpeedUpSpins($uid);
  2033. $cache = oo::commonOprRedis('common')->get($cacheKey);
  2034. if($cache){
  2035. return intval($cache);
  2036. }
  2037. if(!self::activityLock($uid,14,true)){
  2038. return false;
  2039. }
  2040. $config = oo::commonOprModel('config')->getSpeedUpSpins();
  2041. $action = false;
  2042. $configBet = 0;
  2043. $configEffecteTime = 0;
  2044. foreach ($config as $row){
  2045. $id = $row['id'];
  2046. if($id == 1 && $maxBet){
  2047. $count = intval(oo::commonOprRedis('common')->get(okeys::SpeedUpSpins($uid,$id)));
  2048. if($count < $row['max']){
  2049. $action = true;
  2050. }
  2051. }else if($id == 2 && $autoSpins){
  2052. $count = intval(oo::commonOprRedis('common')->get(okeys::SpeedUpSpins($uid,$id)));
  2053. if($count < $row['max']){
  2054. $action = true;
  2055. }
  2056. }else if($id == 3){
  2057. $count = intval(oo::commonOprRedis('common')->get(okeys::SpeedUpSpins($uid,$id)));
  2058. $advertisementCount = intval(oo::commonOprRedis('common')->hGet(okeys::advertisementRemainCount(),$uid));
  2059. if($advertisementCount >=3 && $count < $row['max']){
  2060. $action = true;
  2061. }
  2062. }else if($id == 4){
  2063. $cache = oo::commonOprRedis('common')->get(okeys::TodayBuyGoods($uid,1));
  2064. $count = intval(oo::commonOprRedis('common')->get(okeys::SpeedUpSpins($uid,$id)));
  2065. if($count < $row['max'] && $cache){
  2066. $action = true;
  2067. }
  2068. }
  2069. if($action){
  2070. $configBet = $row['bet'];
  2071. $configEffecteTime = $row['effecteTime'];
  2072. oo::commonOprRedis('common')->setex(okeys::SpeedUpSpins($uid,$id),$count+1,oo::todayDeadline());
  2073. break;
  2074. }
  2075. }
  2076. if($action){
  2077. oo::commonOprRedis('common')->setex($cacheKey,$configBet,$configEffecteTime);
  2078. $lastTime = time() + $configEffecteTime;
  2079. oo::commonOprModel('Workerman')->push($uid,ocmd::$send['Activity_doubleSpins'],[
  2080. 'bet' =>$configBet,
  2081. 'lastTime'=>$configEffecteTime,
  2082. ]);
  2083. $keys = okeys::userRestoreTime($uid);
  2084. $spinsKey = oo::commonOprRedis('common')->get($keys);
  2085. if($spinsKey){
  2086. $spinsCache = explode("*",$spinsKey);
  2087. if(count($spinsCache) > 2){
  2088. $spinsCache[2] = time() + $configEffecteTime;
  2089. $spinsCache[3] = $configBet;
  2090. oo::commonOprRedis('common')->set($keys,implode("*",$spinsCache));
  2091. }else{
  2092. oo::commonOprRedis('common')->set($keys,$spinsKey."*{$lastTime}*{$configBet}");
  2093. }
  2094. }
  2095. return $configBet;
  2096. }
  2097. return false;
  2098. }
  2099. /**
  2100. * 活动下线
  2101. * @param $id
  2102. * @return bool
  2103. * Created by: Owen
  2104. * Created on: 2020/7/3 16:32
  2105. */
  2106. public function outLine($id){
  2107. $Activity = oo::commonOprRedis('common')->hGetAll(okeys::Activity());
  2108. foreach ($Activity as $key=>$row){
  2109. $temp = explode('#',$key);
  2110. if($temp[0] == $id){
  2111. oo::commonOprRedis('common')->hDel(okeys::Activity(),$key);
  2112. $tb = otable::activity();
  2113. oo::commonOprDb('activity')->query("UPDATE {$tb} SET is_online=0 WHERE id = {$id} LIMIT 1");
  2114. oo::commonOprRedis('Activity')->delete(okeys::ActivityOnLinePush($id));
  2115. }
  2116. }
  2117. return true;
  2118. }
  2119. /**
  2120. * 判断是否在线
  2121. * @param $id
  2122. * @return bool
  2123. * Created by: Owen
  2124. * Created on: 2020/7/18 18:02
  2125. */
  2126. public function isOnLine($id){
  2127. $Activity = oo::commonOprRedis('common')->hGetAll(okeys::Activity());
  2128. foreach ($Activity as $key=>$row){
  2129. $temp = explode('#',$key);
  2130. if($temp[0] == $id){
  2131. return true;
  2132. }
  2133. }
  2134. return false;
  2135. }
  2136. /**
  2137. * 排行榜活动动态奖励卡片
  2138. * 2.卡片为金卡;
  2139. * 3.玩家未获得的卡片;(如果玩家已获得符合条件所有金卡,则取获得数量最少的卡片)
  2140. * 4.解锁等级最高的卡片;(如果解锁等级相同,则取卡片ID排前的卡片)
  2141. * 20200922修改为解锁等级最低的卡片
  2142. * @return array
  2143. * Created by: Hss
  2144. * Created on: 2020/7/15 14:59
  2145. */
  2146. public function getRankCard($uid){
  2147. //grade 2 金卡
  2148. //$unlockCard = oo::commonOprModel('card')->getUnlockCard($uid);
  2149. $assetsInfo = oo::commonOprModel('member')->getUserAssetsInfo($uid);
  2150. $unlockCard = oo::commonOprModel('card')->getUnlockCardByLevelId($assetsInfo['levelId']);
  2151. //krsort($unlockCard);//20200922修改为解锁等级最低的卡片
  2152. $userCardInfo = oo::commonOprModel('card')->getUserCardInfo($uid);
  2153. $userCardTemp = array_keys($userCardInfo['ciid']);
  2154. $level = oo::commonOprModel('member')->getUserLevel($uid);
  2155. $levelId = intval($level['levelId']);
  2156. $reward = [];
  2157. $isNew = true;
  2158. foreach($unlockCard as $key => $row){
  2159. if($row['grade'] == 2 && $row['ci_lockRank'] <= $levelId && !in_array($row['ciid'],$userCardTemp)){
  2160. $reward = $row;
  2161. break;
  2162. }
  2163. }
  2164. if(empty($reward)){
  2165. $gradeCardTemp = [];
  2166. $unlockCardTemp = [];
  2167. foreach ($unlockCard as $key => $val){
  2168. $unlockCardTemp[$val['ciid']] = $val;
  2169. }
  2170. foreach ($userCardTemp as $ciid){
  2171. if($unlockCardTemp[$ciid]['grade'] == 2){
  2172. $gradeCardTemp[$ciid] = $userCardInfo['ciid'][$ciid];
  2173. }
  2174. }
  2175. asort($gradeCardTemp);
  2176. $minCiid = array_slice($gradeCardTemp,0,1,true);
  2177. $reward = $unlockCardTemp[key($minCiid)];
  2178. $isNew = false;
  2179. }
  2180. return ['id'=>$reward['ciid'],'isNew'=>$isNew];
  2181. }
  2182. /**
  2183. * 推送状态
  2184. * @param $data
  2185. * @return bool
  2186. * Created by: Owen
  2187. * Created on: 2020/7/20 15:11
  2188. */
  2189. public function activityChangeStatus($data){
  2190. $actId = self::activityToFrontId($data['actId']);
  2191. if(empty($actId)){
  2192. return false;
  2193. }
  2194. $data['actId'] = $actId;
  2195. if($data['status'] == 0){
  2196. oo::commonOprModel('Workerman')->pushAll(ocmd::$send['ActivityChangeStatus'],$data);
  2197. }else{
  2198. //消息队列推送到不同服务器节点
  2199. oo::commonOprModel('workerman')->pushFun('activitynew', 'activityCircleChangeStatus', [$data]);
  2200. }
  2201. return true;
  2202. }
  2203. /**
  2204. * 通知当前节点推送
  2205. */
  2206. public function activityCircleChangeStatus($data){
  2207. $online = oo::commonOprModel('Workerman')->getCurAllUidList();
  2208. $i = 0;
  2209. foreach ($online as $uid){
  2210. $i++;
  2211. oo::commonOprModel('Workerman')->push($uid,ocmd::$send['ActivityChangeStatus'],$data);
  2212. if($i == 100){
  2213. $data['startTime'] += 5;
  2214. $i = 0;
  2215. }
  2216. }
  2217. }
  2218. /**
  2219. * 后端活动ID映射前端
  2220. * @param $id
  2221. * @return mixed
  2222. * Created by: Owen
  2223. * Created on: 2020/7/20 15:10
  2224. */
  2225. public function activityToFrontId($id){
  2226. $idArr = [
  2227. 2=>5, //收集
  2228. 3=>6, //气球
  2229. 6=>8, //偷打活动
  2230. 7=>10, //节日收集活动
  2231. 8=>12, //建筑大师
  2232. 9=>13, //倍率活动
  2233. 10=>14, //卡片活动
  2234. 11=>15, //JackPot
  2235. 12=>16, //卡片交换
  2236. 13=>17, //排行榜活动
  2237. 14=>18, //体力加速恢复
  2238. 15=>19, //连环礼包
  2239. 16=>20, //宝藏活动
  2240. ];
  2241. return $idArr[$id];
  2242. }
  2243. /**
  2244. * 宝藏活动用户信息
  2245. * @param $uid
  2246. * @param $origData
  2247. * @return array
  2248. * Created by: Owen
  2249. * Created on: 2020/7/27 18:55
  2250. */
  2251. public function getUserTreasureData($uid,$origData = false){
  2252. $userAssetsInfo = oo::commonOprModel('member')->getUserAssetsInfo($uid);
  2253. $levelId = $userAssetsInfo['levelId'];
  2254. $treasureCollect = oo::commonOprModel('config')->getActivityCoins($levelId,"treasureCollect");
  2255. $treasureReward = oo::commonOprModel('config')->getActivityCoins($levelId,"treasureReward");
  2256. $treasureBet = oo::commonOprModel('config')->getActivityCoins($levelId,"treasureBet");
  2257. $version = oo::commonOprModel('user')->getUserVersion($uid);
  2258. if(oo::compareVersion($version,'1.7.0')){
  2259. $config = oo::commonOprModel('config')->getTreasureConfig(0,true);
  2260. }else{
  2261. $config = oo::commonOprModel('config')->getTreasureConfig(0,false);
  2262. }
  2263. foreach ($config as $key=>$row){
  2264. if($row['taskType'] != 1){
  2265. $config[$key]['target'] *= $treasureCollect;
  2266. }
  2267. $config[$key]['coins'] *= $treasureReward;
  2268. $temp = $row['bet'];
  2269. foreach ($temp as $b=>$bet){
  2270. $temp[$b] = $bet * $treasureBet;
  2271. }
  2272. $config[$key]['bet'] = $temp;
  2273. if($row['special'] == 1){
  2274. $card = self::getTreasureTaskCard($uid,$row['id']);
  2275. if(empty($card['id'])){
  2276. $config[$key]['special'] = 0;
  2277. }else{
  2278. $config[$key]['card'] = $card;
  2279. }
  2280. }
  2281. foreach($row['props'] as $propsKey => $propsTemp){
  2282. if($propsTemp['propsId'] == 13 && isset($propsTemp['type'])){
  2283. if($propsTemp['type'] == 1){
  2284. $card = self::getTreasureTaskCard($uid,$row['id']);
  2285. if(empty($card['id'])){
  2286. $config[$key]['props'][$propsKey]['value'] = null;
  2287. }else{
  2288. $config[$key]['props'][$propsKey]['value'][] = $card;
  2289. }
  2290. }else{
  2291. $config[$key]['props'][$propsKey]['value'] = null;
  2292. }
  2293. }
  2294. }
  2295. }
  2296. if($origData){
  2297. foreach ($config as $key=>$row){
  2298. $config[$key]['props'][] = ['propsId'=>14,'num'=>$row['coins'],'value'=>$row['coins']];
  2299. $config[$key]['props'][] = ['propsId'=>15,'num'=>$row['spins'],'value'=>$row['spins']];
  2300. unset($config[$key]['coins']);
  2301. unset($config[$key]['spins']);
  2302. $temp = $config[$key]['props'];
  2303. array_multisort(array_column($temp,'propsId'),SORT_DESC,$temp);
  2304. $config[$key]['props'] = $temp;
  2305. }
  2306. }
  2307. $betConfig = oo::commonOprModel('config')->getTreasureProConfig($levelId);
  2308. $reward = $betConfig['pro'];
  2309. foreach ($reward as $key=>$row){
  2310. $temp = $row;
  2311. unset($temp['pro']);
  2312. $reward[$key] = $temp;
  2313. }
  2314. $bet = array_column($betConfig['superBet'],'bet');
  2315. rsort($bet);
  2316. return [
  2317. 'config' => $config,
  2318. 'bet' => $bet,
  2319. 'reward' => $reward,
  2320. ];
  2321. }
  2322. /**
  2323. * 更新宝藏活动任务数量
  2324. * @param $uid
  2325. * @param $num
  2326. * @param $from
  2327. * @return mixed
  2328. * Created by: Owen
  2329. * Created on: 2020/7/27 20:04
  2330. */
  2331. public function updateTreasureTaskNum($uid,$num,$from){
  2332. $taskType = self::getUserTreasureCurTaskType($uid);
  2333. if($taskType == 1){
  2334. $newNum = oo::commonOprRedis('User')->hIncrBy(okeys::TreasureTaskNum(),$uid,1);
  2335. }else {
  2336. if ($taskType == 2) {
  2337. $newNum = oo::commonOprRedis('User')->hIncrBy(okeys::TreasureTaskNum(), $uid, $num);
  2338. }else if ($taskType == 3 && $from == 1) {
  2339. $newNum = oo::commonOprRedis('User')->hIncrBy(okeys::TreasureTaskNum(), $uid, $num);
  2340. }else{
  2341. $newNum = intval(oo::commonOprRedis('User')->hGet(okeys::TreasureTaskNum(),$uid));
  2342. }
  2343. }
  2344. return [
  2345. 'taskId' => max(oo::commonOprRedis('User')->hGet(okeys::TreasureTaskId(),$uid),1),
  2346. 'taskNum'=> $newNum,
  2347. ];
  2348. }
  2349. /**
  2350. * 领取宝藏奖励
  2351. * @param $uid
  2352. * @return string
  2353. * Created by: Owen
  2354. * Created on: 2020/7/27 20:15
  2355. */
  2356. public function getTreasureTaskReward($uid){
  2357. $userTreasureData = self::getUserTreasureData($uid);
  2358. $taskId = max(oo::commonOprRedis('User')->hGet(okeys::TreasureTaskId(),$uid),1);
  2359. $taskNum= intval(oo::commonOprRedis('User')->hGet(okeys::TreasureTaskNum(),$uid));
  2360. $rewardConfig = array_column($userTreasureData['config'],NULL,'id');
  2361. $reward = $rewardConfig[$taskId];
  2362. if($reward['target'] > $taskNum){
  2363. return oo::response(-2,[],'目标未达标');
  2364. }
  2365. oo::commonOprRedis('Activity')->hDel(okeys::TreasureTaskNum(),$uid);
  2366. $newId = oo::commonOprRedis('User')->hIncrBy(okeys::TreasureTaskId(),$uid,$taskId==1?2:1);
  2367. $actionReward = [];
  2368. if(!empty($reward['coins'])){
  2369. $actionReward['money'] = $reward['coins'];
  2370. }
  2371. if(!empty($reward['spins'])){
  2372. $actionReward['spins'] = $reward['spins'];
  2373. }
  2374. $ret = !empty($actionReward) && oo::commonOprModel('member')->optProperty($uid,$actionReward,'+',213,"宝藏活动-{$taskId}");
  2375. $cardData = [];
  2376. if($ret && !empty($reward['props'])){
  2377. foreach ($reward['props'] as $row){
  2378. if($row['propsId'] == 13){
  2379. if(isset($row['type']) && $row['type'] == 1){
  2380. foreach($row['value'] as $valueTemp){
  2381. $userCardInfo = oo::commonOprModel('card')->getUserCardInfo($uid);
  2382. $userCurCard = $userCardInfo['ciid'];
  2383. $userCurCard[$valueTemp['id']] += 1;
  2384. $ret2 = oo::commonOprModel('card')->updateUserCardInfo($uid,['ciid'=>$userCurCard]);
  2385. if($ret2 && $valueTemp['isNew']){
  2386. $cardsInfo = array_column(oo::commonOprModel('card')->getCardInfo(),NULL,'ciid');
  2387. $cardInfo = $cardsInfo[$valueTemp['id']];
  2388. oo::commonOprModel('member')->optProperty($uid,['star'=>$cardInfo['ci_star_rank']],'+',213,"宝藏活动-{$taskId}");
  2389. }
  2390. oo::commonOprModel('statistics')->treasureRewardSta(13,$taskId,1);//宝藏探索产出消耗统计
  2391. }
  2392. $cardData = $row['value'];
  2393. }else if(isset($row['type']) && $row['type'] == 0){
  2394. $cardData[] = oo::commonOprModel('member')->sendReward($uid,$row['propsId'],1,213,"宝藏探索-随机金卡",0);
  2395. }
  2396. oo::logs()->debug3(["msg"=>"金卡发放,随机金卡","cardData"=>$cardData,'res'=>$row],'sendRankReward.txt');
  2397. }else{
  2398. oo::commonOprModel('props')->addUserProps($uid,$row['propsId'],$row['num']);
  2399. }
  2400. oo::commonOprModel('statistics')->treasureRewardSta($row['propsId'],$taskId,$row['num']);//宝藏探索产出消耗统计
  2401. }
  2402. }
  2403. if($ret && $reward['special'] == 1 && !empty($reward['card']['id'])){
  2404. $userCardInfo = oo::commonOprModel('card')->getUserCardInfo($uid);
  2405. $userCurCard = $userCardInfo['ciid'];
  2406. $userCurCard[$reward['card']['id']] += 1;
  2407. $ret = oo::commonOprModel('card')->updateUserCardInfo($uid,['ciid'=>$userCurCard]);
  2408. if($ret && $reward['card']['isNew']){
  2409. $cardsInfo = array_column(oo::commonOprModel('card')->getCardInfo(),NULL,'ciid');
  2410. $cardInfo = $cardsInfo[$reward['card']['id']];
  2411. oo::commonOprModel('member')->optProperty($uid,['star'=>$cardInfo['ci_star_rank']],'+',213,"宝藏活动-{$taskId}");
  2412. }
  2413. oo::commonOprModel('statistics')->treasureRewardSta(13,$taskId,1);//宝藏探索产出消耗统计
  2414. }
  2415. oo::commonOprRedis('Activity')->hDel(okeys::TreasureCurTaskType(),$uid);
  2416. $data['curData'] = [
  2417. 'taskId' => $newId,
  2418. 'taskNum'=> 0,
  2419. 'cardData'=>$cardData,
  2420. ];
  2421. return oo::response(1,$data);
  2422. }
  2423. /**
  2424. * 宝藏活动金卡
  2425. * @param $uid
  2426. * @param $id
  2427. * @return array|mixed
  2428. * Created by: Owen
  2429. * Created on: 2020/7/27 20:21
  2430. */
  2431. public function getTreasureTaskCard($uid,$id){
  2432. $cardData = oo::commonOprRedis('Activity')->hGet(okeys::TreasureTaskCard(),$uid."-".$id);
  2433. if($cardData){
  2434. $cardData = json_decode($cardData,true);
  2435. }else{
  2436. $cardData = self::getRankCard($uid);
  2437. oo::commonOprRedis('Activity')->hSet(okeys::TreasureTaskCard(),$uid."-".$id,json_encode($cardData));
  2438. }
  2439. return $cardData;
  2440. }
  2441. /**
  2442. * 领取宝藏活动转盘奖励
  2443. * @param $uid
  2444. * @param $id
  2445. * @param $coins
  2446. * @return string
  2447. * Created by: Owen
  2448. * Created on: 2020/7/28 14:56
  2449. */
  2450. public function getTreasureSlotReward($uid,$id,$coins){
  2451. $cacheKey = okeys::TreasureCacheResult(0,$uid,"SLOT");
  2452. $reward = oo::commonOprRedis('Activity')->hGet($cacheKey,$id);
  2453. if(empty($reward)){
  2454. return oo::response(-2,['id'=>$id],'奖励已领取');
  2455. }
  2456. $assetsInfo = oo::commonOprModel('member')->getUserAssetsInfo($uid);
  2457. if($coins > $assetsInfo['money']){
  2458. return oo::response(-2,['id'=>$id],'金币不足');
  2459. }
  2460. $temp = explode('-',$reward);
  2461. $rid = $temp[0];
  2462. $getCoins = $temp[1] * $coins;
  2463. $actionCoins = $getCoins - $coins;
  2464. $actionType = $actionCoins >= 0 ? "+" : "-";
  2465. oo::commonOprModel('member')->optProperty($uid,['money'=>abs($actionCoins)],$actionType,214,"宝藏活动:(花费{$coins}),奖励倍率{$temp[1]},摇奖ID:{$rid}");
  2466. oo::commonOprRedis('Activity')->hDel($cacheKey,$id);
  2467. $proteEndTs = oo::commonOprModel('activitynew')->getEndproteTime($uid, date("Ymd",time()));
  2468. $ttl = $proteEndTs-time();
  2469. if($ttl < 100 && $actionCoins >= 0 ){
  2470. oo::commonOprModel('member')->setUserStealProtect($uid,300);
  2471. $proteEndTs = time()+298;
  2472. }
  2473. $newData = self::updateTreasureTaskNum($uid,$getCoins,$temp[0] == 1 ? 1 : 2);
  2474. $data['curData'] = $newData;
  2475. $data['id'] = $id;
  2476. oo::commonOprModel('currency')->log($uid,"money","-",$coins,0,1003,$newData['taskId']);//发放消耗统计
  2477. oo::commonOprModel('currency')->log($uid,"money","+",$getCoins,0,1010+$temp[0],$newData['taskId']);//宝藏统计
  2478. $data['proteEndTs'] = $proteEndTs;//保护截至时间戳
  2479. oo::commonOprModel('currency')->participation($uid, 'treasure', 0); //宝藏活动参与率
  2480. return oo::response(1,$data);
  2481. }
  2482. /**
  2483. * 宝藏活动结果
  2484. * @param $uid
  2485. * @param $id
  2486. * @return array
  2487. * Created by: Owen
  2488. * Created on: 2020/7/28 14:43
  2489. */
  2490. public function getUserTreasureSlotResult($uid,$id = 0){
  2491. $cacheKey = okeys::TreasureCacheResult(0,$uid,"SLOT");
  2492. if($id){
  2493. oo::commonOprRedis('Activity')->delete($cacheKey);
  2494. }
  2495. $len = oo::commonOprRedis('Activity')->hLen($cacheKey);
  2496. if($len <= 2){
  2497. $userAssetsInfo = oo::commonOprModel('member')->getUserAssetsInfo($uid);
  2498. $betConfig = oo::commonOprModel('config')->getTreasureProConfig($userAssetsInfo['levelId'] ?? 1);
  2499. $superBet = array_column($betConfig['superBet'],'pro');
  2500. $pro = array_column($betConfig['pro'],'pro');
  2501. $proReward = array_column($betConfig['pro'],null,'id');
  2502. $superReward = array_column($betConfig['superBet'],null,'id');
  2503. for ($i=0;$i<10-$len;$i++){
  2504. $rid = oo::commonOprModel('slot')->get_rand($pro,true);
  2505. $rid = $id ? $id : $rid+1;
  2506. $temp = $proReward[$rid];
  2507. if($temp['bet'] == -1){
  2508. $superRid = oo::commonOprModel('slot')->get_rand($superBet,true);
  2509. $superRid += 1;
  2510. $superTemp = $superReward[$superRid];
  2511. $temp['bet'] = $superTemp['bet'];
  2512. }
  2513. oo::commonOprRedis('Activity')->hSet($cacheKey,time().$i,$rid."-".$temp['bet']);
  2514. }
  2515. oo::commonOprRedis('Activity')->expire($cacheKey,2*3600);
  2516. }
  2517. $ridArr = oo::commonOprRedis('Activity')->hGetAll($cacheKey);
  2518. $out = [];
  2519. foreach ($ridArr as $key=>$row){
  2520. $temp = explode('-',$row);
  2521. $out[] = [
  2522. 'id' => $key,
  2523. 'rid' => $temp[0],
  2524. 'bet' => $temp[1],
  2525. ];
  2526. }
  2527. return $out;
  2528. }
  2529. /**
  2530. * 入门奖励
  2531. * @param $uid
  2532. * @param bool $get
  2533. * @return string
  2534. * Created by: Owen
  2535. * Created on: 2020/7/28 16:50
  2536. */
  2537. public function getTreasureGift($uid,$get = false){
  2538. if(!$get){
  2539. if(oo::commonOprRedis('Activity')->hGet(okeys::TreasureTaskGift(),$uid)){
  2540. return oo::response(-2,"奖励已领取");
  2541. }
  2542. }
  2543. $userTreasureData = self::getUserTreasureData($uid);
  2544. $rewardConfig = array_column($userTreasureData['config'],NULL,'id');
  2545. $reward = $rewardConfig[1];
  2546. if($get){
  2547. return $reward['bet'][0];
  2548. }
  2549. oo::commonOprModel('member')->setUserStealProtect($uid,300);
  2550. oo::commonOprModel('member')->optProperty($uid,['money'=>$reward['bet'][0]],"+",215,"宝藏活动-入门奖励");
  2551. oo::commonOprRedis('Activity')->hSet(okeys::TreasureTaskGift(),$uid,1);
  2552. return oo::response(1,["proteEndTs"=>time()+299]);
  2553. }
  2554. /**
  2555. * 获取宝藏活动用户当前任务
  2556. * @param $uid
  2557. * @return mixed
  2558. * Created by: Owen
  2559. * Created on: 2020/7/31 10:36
  2560. */
  2561. public function getUserTreasureCurTaskType($uid){
  2562. $cacheKey = okeys::TreasureCurTaskType();
  2563. $cache = oo::commonOprRedis('Activity')->hGet($cacheKey,$uid);
  2564. if(empty($cache)){
  2565. $userTreasureData = self::getUserTreasureData($uid);
  2566. $taskId = max(oo::commonOprRedis('User')->hGet(okeys::TreasureTaskId(),$uid),1);
  2567. $rewardConfig = array_column($userTreasureData['config'],NULL,'id');
  2568. $reward = $rewardConfig[$taskId];
  2569. oo::commonOprRedis('Activity')->hSet($cacheKey,$uid,$reward['taskType']);
  2570. $cache = $reward['taskType'];
  2571. }
  2572. return $cache;
  2573. }
  2574. }