123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266 |
- <?php
- defined('IN_WEB') or die('Include Error!');
- /**
- * 商品相关
- */
- class ModelGoods{
- /**
- * 疯狂的上帝商品
- * Created by: Owen
- * Created on: 2019/7/3 18:36
- * Description:
- */
- public function getCrazyGodGood($uid,$sid=''){
- $tb = otable::goodsCrazy();
- $goodsInfo = oo::commonOprDb('payment')->getAll("SELECT * FROM {$tb} WHERE gstatus=1 ORDER BY gid",MYSQLI_ASSOC);
- $property = oo::commonOprModel('member')->getUserAssetsInfo($uid);
- $level = intval($property['levelId']);
- $out = [];
- $coinsArr = self::getCoinsDataByLevel($level);
- $version = oo::commonOprModel('user')->getUserVersion($uid);
- $giftArr = self::getGiftConfig();
- $configArr = self::getGoodTransformConfig();
- $exclusionGid= [];
- $cardChest = self::getCardChestConfig($level);
- $iosSubArr = ['subscription01'=>'sub01','subscription02'=>'sub03','subscription03'=>'sub02'];
- $point = oo::commonOprModel('newvip')->getUserCurPoint($uid); //积分
- $sid = empty($sid)?oo::getDefinedSid($uid):$sid;
- foreach ($goodsInfo as $row) {
- if(in_array($row['gid'],$exclusionGid)){
- continue;
- }
- if($row['gid']>720&&$row['gid']<=750){//超级连环礼包(动态数据)剔除
- continue;
- }
- if($row['gid']>750&&$row['gid']<=760){//四选一活动礼包(动态数据)剔除
- continue;
- }
- if($row['gtype']==27){//召回礼包(动态数据)剔除
- continue;
- }
- if($row['gid']>760&&$row['gid']<=790){//超级连环礼包2(动态数据)剔除
- continue;
- }
- $row['gsku'] = ($sid == 1) ? self::googleSkuToAndroid($row['gsku']) : self::googleSkuToIosSku($row['gsku']);
- $goodTypeId = $row['gtype'];
- $config = $configArr[$goodTypeId];
- if(empty($config)){
- continue;
- }
- $temp = [];
- foreach ($config['character'] as $key=>$value){
- $temp[$key] = $row[$value];
- $key=='price' && $temp[$key] = '$'.$row[$value];
- $key=='priceNum' && $temp[$key] = (string)$row[$value];
- }
- if($goodTypeId == 2){
- $coinsType = explode('.',$row['gsku']);
- $temp['num'] = $coinsArr[end($coinsType)];
- }else if($goodTypeId == 3){
- //1.14版本魔幻宝箱重新上架,使用金币购买
- if(oo::compareVersion($version,'1.8.3') && $row['gid'] == 304){
- continue; //下架魔幻宝箱
- }
- if(!oo::compareVersion($version,'1.8.4') && $row['gid'] == 306){
- continue; //旧每日宝箱不上架
- }
- $cardInfo = explode(',',$row['gbaseReward']);
- $temp['cardNum'] = $cardInfo[0];
- if(in_array($row['gid'], [306])){
- $temp['price'] = '$'.$row['gprice'];
- }else{
- $temp['price'] = $cardChest[$row['gsku']];
- }
- if($row['gid'] == 306){
- $chestInfo = oo::commonOprModel('activitynew')->getDailyChest($uid);
- if(empty($chestInfo)){
- continue;
- }
- }else{
- $cardStarArr = array_filter(oo::commonOprModel('card')->getCardTypeProConfig($row['gimg']));
- $cardStar = $key = array_search(max($cardStarArr),$cardStarArr);
- unset($cardStarArr[$key]);
- $cardStar2= array_search(max($cardStarArr),$cardStarArr);
- if($cardStar < $cardStar2){
- $t = $cardStar2;
- $cardStar2 = $cardStar;
- $cardStar = $t;
- }
- $temp['cardStar']= [$cardStar2,$cardStar];
- }
- $temp['priceNum']= (string)$temp['price'];
- if(in_array($row['gid'], [304, 306])){
- $temp['sku'] = $row['gsku'];
- }
- }else if($goodTypeId == 6){
- if($row['gid'] == 601){
- $temp['coin'] = intval($coinsArr['coins03']*0.5);
- $temp['coins']= intval($coinsArr['coins03']*0.5);
- if(oo::compareVersion($version,'1.7.3')){
- if(!empty($row['goriginReward'])) {
- $props = json_decode($row['goriginReward'], true);
- foreach ($props as $p) {
- $p['propsId'] == 22 && $temp['diamond'] = $p['num'];
- if($p['propsId'] == 14){
- $temp['coin'] = $temp['coins'] = $p['num'];
- }
- }
- }
- }
- $temp['spin'] = $row['gbaseReward'];
- $temp['spins']= $row['gbaseReward'];
- }else if($row['gid'] == 602){
- $props = json_decode($row['gbaseReward'],true);
- foreach ($props as $p){
- $p['propsId'] == 14 && $temp['coin'] = $p['num'] && $temp['coins'] = $p['num'];
- $p['propsId'] == 15 && $temp['spin'] = $p['num'] && $temp['spins'] = $p['num'];
- $p['propsId'] == 22 && $temp['diamond'] = $p['num'];
- }
- $temp['props'] = $props;
- }
- $temp['coupon'] = 1;
- $couponVer = oo::commonOprRedis('common')->get(okeys::firstPayCouponVersion());
- $couponVer = empty($couponVer) ? '1.9.1' : $couponVer; //1.9.1版本临时隐藏首冲优惠券商品
- if(in_array($row['gid'], [601, 602]) && oo::compareVersion($version, $couponVer)){
- $temp['coupon'] = 0;
- }
- }else if($goodTypeId == 7){
- if(in_array($row['gid'],[710,711,712])){
- $chainGiftFlag = true;
- $aid = oo::commonOprModel('activitynew')->activityLock($uid,'chain_gift');
- if($aid){
- $chainGiftFlag = false;
- oo::commonOprRedis('activity')->setex(okeys::bindChainGift($uid),$aid,86400*3);//连环礼包绑定活动id
- $ret = oo::commonOprModel('activitynew')->getChainGiftConf($uid,$aid,$row['gid']);
- foreach ($ret['props'] as $k=>$p){
- $pConf = oo::commonOprModel('props')->getChestData($uid,$p['propsId']);
- $pConf && $ret['props'][$k]['reward'] = $pConf;
- }
- $temp['coin'] =$ret['coin'];
- $temp['coins'] =$ret['coin'];
- $temp['spin'] =$ret['spin'];
- $temp['spins'] =$ret['spin'];
- $temp['props'] =$ret['props'];
- $temp['price'] =$ret['price'];
- $temp['priceNum'] =$ret['priceNum'];
- $temp['sku'] =($sid == 1) ? self::googleSkuToAndroid($ret['sku']) : self::googleSkuToIosSku($ret['sku']);
- $temp['giftType'] =$ret['giftType'];
- $temp['gMax'] =$ret['gMax'];
- }
- if($chainGiftFlag){
- if(strpos($row['gsku'],'com.sa') !== false || strpos($row['gsku'],'newsky.cc') !== false||strpos($row['gsku'],'com.gworld') !== false||strpos($row['gsku'],'gworld.cc') !== false){
- $gsku = $row['gsku'];
- $price = '$'.$row['gprice'];
- $priceNum= (string)$row['gprice'];
- }else{
- $gsku = "";
- $price = json_decode($row['gsku'],true);
- $priceNum= empty($price['bet']) ? 0 : (string)$coinsArr[$price['coins']] * $price['bet'];
- }
- $reward = json_decode($row['gbaseReward'],true);
- $coin = $coinsArr[$reward['coins']['coins']] * $reward['coins']['bet'];
- $temp['coin'] =intval($coin);
- $temp['coins'] =intval($coin);
- $temp['spin'] =intval($reward['spins']);
- $temp['spins'] =intval($reward['spins']);
- $temp['props'] =$reward['props'];
- $temp['price'] =$price;
- $temp['priceNum'] =$priceNum;
- $temp['sku'] =$gsku;
- $temp['giftType'] =1;
- $temp['gMax'] =$row['gMax'];
- }
- }else{
- $reward = $giftArr[$row['gid']];
- $temp['coin'] = intval($coinsArr[$reward['coins']] * $reward['coinsBet']);
- $temp['coins'] = intval($coinsArr[$reward['coins']] * $reward['coinsBet']);
- $temp['giftType'] = $reward['giftType'];
- if(oo::compareVersion($version,'1.7.3')){
- if(!empty($row['goriginReward'])){
- $props = json_decode($row['goriginReward'],true);
- foreach ($props as $p){
- $p['propsId'] == 22 && $temp['diamond'] = $p['num'];
- }
- }
- foreach ([14=>'coins',15=>'spins',22=>'diamond'] as $k => $v){
- $propsTemp = [];
- $propsTemp['propsId'] = $k;
- if(is_array($temp[$v]) && $k == 14){
- $propsTemp['value'] = $temp[$v];
- $propsTemp['num'] = 0;
- $temp['props'][] = $propsTemp;
- }else{
- if(!empty($temp[$v])){
- $propsTemp['num'] = $temp[$v];
- $temp['props'][] = $propsTemp;
- }
- }
- }
- }
- }
- }else if($goodTypeId == 8){
- if($sid == 2){
- foreach ($iosSubArr as $subscription=>$sub){
- if(strpos($row['gsku'],$subscription) !== false){
- $temp['sku'] = str_replace($subscription,$sub,$row['gsku']);
- break;
- }
- }
- }
- }else if($goodTypeId == 9){
- $temp['goods'] = json_decode($row['gbaseReward'],true);
- $temp['buyNum'] = intval(oo::commonOprRedis('User')->hGet(okeys::GoodBuyNum(),$uid.'_'.$row['gid']));
- }else if($goodTypeId == 10){
- $temp['goods'] = json_decode($row['gbaseReward'],true);
- }else if($goodTypeId == 14){
- continue;
- }else if($goodTypeId == 15){
- //if(oo::compareVersion($version,'1.7.8')){
- // $noEnoughArr = [1502];
- //}else{
- // $noEnoughArr = [1501,1502,1511];
- //}
- $noEnoughArr = [1501,1502,1511];
- if(in_array($row['gid'],$noEnoughArr)){
- //根据玩家积分、等级 返回对应商品
- $keyType = $row['gid']==1501?'money':($row['gid'] == 1502 ? 'spins' : 'diamond');
- if($row['gid'] == 1502 || ($point < 1000 && in_array($row['gid'], [1501, 1511]))){
- $configNotEnough = oo::commonOprModel('config')->getShopNotEnoughConfig($keyType);
- }else{
- $configNotEnough = [];
- }
- $gid = 0;
- foreach($configNotEnough as $rowTemp){
- if($rowTemp['point'] <= $point && $rowTemp['level'] <= $level){
- $gid = $rowTemp['gid'];
- }
- }
- if($gid){
- $goodInfoTemp = self::getGoodsInfoByGid($gid);
- if(!empty($goodInfoTemp)){
- $temp['sku'] = ($sid == 1) ? self::googleSkuToAndroid($goodInfoTemp['gsku']) : self::googleSkuToIosSku($goodInfoTemp['gsku']);
- $temp['price'] = '$'.$goodInfoTemp['gprice'];
- $temp['priceNum'] = (string)$goodInfoTemp['gprice'];
- $temp['addRatio'] = $goodInfoTemp['gaddRatio'];
- $row['gbaseReward'] = $goodInfoTemp['gbaseReward'];
- oo::commonOprRedis('common')->setex(okeys::shopNotEnoughLog($uid,$row['gid']),json_encode($goodInfoTemp),1 * 24 * 3600);
- }
- }
- }
- if(in_array($row['gid'],[1501,1503,1504,1505,1506,1507])){
- $rewardTemp = json_decode($row['gbaseReward'],true);
- $coins = self::getGoodCoinsByLevelId($level + 1,$rewardTemp['coins']['coins']);
- $temp['num'] = $coins * $rewardTemp['coins']['bet'];
- }else if(in_array($row['gid'],[1502,1508,1509,1510,1511,1512,1513,1514,1515])){
- $temp['num'] = $row['gbaseReward'];
- }
- }else if($goodTypeId == 17){
- $temp['isoSku'] = self::googleSkuToIosSku($row['gsku']);
- $temp['giftType']= $row['gtype']==17?5:$row['gtype'];
- }else if(in_array($goodTypeId,[16,18,19])){
- $reward = json_decode($row['gbaseReward'],true);
- $temp['isoSku'] = self::googleSkuToIosSku($row['gsku']);
- $temp['giftType']= 5;
- $temp['coins'] = oo::commonOprModel('goods')->getGoodCoins($uid,$reward['coins']['coins']) * $reward['coins']['bet'];
- $temp['spins'] = $reward['spins'];
- $temp['props'] = $reward['props'];
- if($goodTypeId == 16){
- $propsTemp = $reward['props'];
- foreach ($propsTemp as $key=>$p){
- $pConfig = oo::commonOprModel('props')->getChestData($uid,$p['propsId']);
- if($pConfig){
- $propsTemp[$key]['value'] = $pConfig;
- }
- }
- $temp['props'] = $propsTemp;
- }
- if(oo::compareVersion($version,'1.7.3')){
- foreach ([14=>'coins',15=>'spins',22=>'diamond'] as $k => $v){
- $props = [];
- $props['propsId'] = $k;
- if(!empty($temp[$v])){
- $props['num'] = $temp[$v];
- $temp['props'][] = $props;
- }
- }
- }
- $temp['coins'] = [
- 'gid' => oo::commonOprModel('config')->coinsToGid($reward['coins']['coins']),
- 'bet' => $reward['coins']['bet']
- ];
- if(oo::compareVersion($version,'1.8.1') && !in_array($row['gid'],[1760,1761,1762])){
- $temp['coins']['bet'] = 0;
- }
- if(in_array($goodTypeId,[16,18])){
- unset($temp['coins'],$temp['spins'],$temp['diamond']);
- }else if($goodTypeId == 19){
- $temp['spins'] = 0;
- $temp['diamond'] = 0;
- }
- }else if($goodTypeId == 21){
- if(!oo::compareVersion($version,'1.7.1')){
- continue;
- }
- $temp['diamond'] = $row['gbaseReward'];
- }else if($goodTypeId == 26){ //基金活动动态修改gsku和pirce
- $actInfo = oo::commonOprModel('activitynew')->getBindActivity($uid,'fund',true);
- if(!empty($actInfo)&&!empty($actInfo['reward_conf'])){
- $rewardConf = (array)json_decode($actInfo['reward_conf'], true);
- $rfmGroup = oo::commonOprModel('config')->getUserGroupIdByCid($uid, 2);
- foreach($rewardConf as $ext){
- if(!isset($ext['data'][$row['gid']])){
- continue;
- }
- $groupConf = !empty($ext['gid']) ? $ext['gid'] : [];
- if(in_array(0, $groupConf) || (in_array($rfmGroup, $ext['gid']))){
- $temp['sku'] = ($sid == 1)?self::googleSkuToAndroid($ext['data'][$row['gid']]['gsku']):self::googleSkuToIosSku($ext['data'][$row['gid']]['gsku']);
- $temp['price'] = $ext['data'][$row['gid']]['gprice'];
- $temp['gdiscount'] = $ext['data'][$row['gid']]['gdiscount'];
- }
- }
- }
- } elseif ($goodTypeId == 23) { //体力存钱罐
- $safeGoodsInfo = oo::commonOprModel('activitynew')->getSpinSafeGoodsByGid($uid, $row['gid']);
- if($safeGoodsInfo){ //体力存钱罐商品过期保存,防止活动过期
- oo::commonOprModel('activitynew')->setActivityShopCache(
- okeys::activityShopCache($uid, 'spin_safe-'.$row['gid']), $safeGoodsInfo
- );
- }
- if(!empty($safeGoodsInfo)){
- $safeSku = $safeGoodsInfo['sku'];
- $temp['sku'] = ($sid == 1)?self::googleSkuToAndroid($safeSku):self::googleSkuToIosSku($safeSku);
- $temp['priceNum'] = $safeGoodsInfo['price'];
- $temp['price'] = '$'.$safeGoodsInfo['price'];
- }
- }
- $temp['sku'] == "" && $temp['sku'] = NULL;
- $temp['priceDollar'] = '$';
- $temp['priceCurrencyCode'] = 'USD';
- if($config['name'] == 'gift' && !empty($row['gShowGroup'])){
- $temp['rfmGroup'] = array_filter(array_map('intval', explode(',', $row['gShowGroup'])));
- }
- $out[$config['name']][] = $temp;
- }
- //钻石兑换物品列表
- if(oo::compareVersion($version,'1.7.1')){
- $out['diamondExchanges'] = oo::commonOprModel('diamond')->getShopDiamondWithClient($uid);
- }
- if(oo::compareVersion($version,'1.8.0')){
- $diamonNotEnoughEx = oo::commonOprModel('diamond')->notEnoughWithClient($uid);
- $out['diamondCoin'] = $diamonNotEnoughEx['diamondCoin'];
- $out['diamondSpin'] = $diamonNotEnoughEx['diamondSpin'];
- }
- //新连环礼包
- if(oo::compareVersion($version,'1.7.4')){
- $out['super_serial_pack'] = array_values(oo::commonOprModel('activitynew')->getCGGoodList($uid,'super_serial_pack'));
- }
- //新连环礼包2
- if(oo::compareVersion($version,'1.10.1')){
- $out['super_serial_pack2'] = array_values(oo::commonOprModel('activitynew')->getCGGoodList($uid,'super_serial_pack2'));
- }
- //二选一活动
- if(oo::compareVersion($version,'1.8.1')){
- $out['chooseOne'] = oo::commonOprModel('activitynew')->getChooseOneGoods($uid);
- }
- //1+1礼包
- if(oo::compareVersion($version,'1.14.1')){
- $out['onePlusGift'] = oo::commonOprModel('activitynew')->getActivityGoods($uid,"one_plus_gift");
- }
- //安全惊喜礼包
- if(oo::compareVersion($version,'1.14.1')){
- $out['safeSurprise'] = oo::commonOprModel('activitynew')->getActivityGoods($uid,"safe_surprise");
- }
- //四选一活动礼包
- // if(oo::compareVersion($version,'1.8.4')){
- // $out['easter_egg'] = oo::commonOprModel('activitynew')->getEasterGiftBag($uid);
- // }
- /**
- * 大转盘根据等级展现给用户
- */
- $out['wheel'] = $this->turnDataByLevelId($level,$out['wheel']);
- if(!empty($out['fund'])){
- //基金活动设置活动动态缓存,发货时更新动态价格
- oo::commonOprModel('activitynew')->setActivityShopCache(okeys::activityShopCache($uid, 'fund'), $out['fund']);
- }
- return ['code'=>1,'list'=>$out,'recomment'=>self::getRecommend($uid)];
- }
- /**
- * 大转盘根据等级展现给用户
- * @param $level
- * @param $data
- * @return mixed
- * Created by: Owen
- * Created on: 2021/1/12 19:35
- */
- public function turnDataByLevelId($level,$data){
- $between = [
- ["levelId"=>20, "gid"=>501],
- ["levelId"=>40, "gid"=>502],
- ["levelId"=>70, "gid"=>503],
- ["levelId"=>100,"gid"=>504],
- ["levelId"=>200,"gid"=>505],
- ["levelId"=>300,"gid"=>506],
- ];
- $action = ["levelId"=>300,"gid"=>506];
- foreach ($between as $row){
- if($level <= $row["levelId"]){
- $action = $row;
- break;
- }
- }
- $tmp = array_column($data,null,'gid');
- $out = [];
- $out[] = $tmp[500];
- $out[] = $tmp[$action['gid']];
- return $out;
- }
- /**
- * 资源不足道具列表(1501,1502,1511)
- * @param int $uid
- */
- public function getextraCrazyGodGood($uid, $sid = ''){
- $gids = [1501,1502,1511];
- $tb = otable::goodsCrazy();
- $sql = "SELECT * FROM {$tb} WHERE gstatus=1 AND gid IN (".implode(",", $gids).") ORDER BY gtype";
- $goodsInfo = oo::commonOprDb('payment')->getAll($sql,MYSQLI_ASSOC);
- $property = oo::commonOprModel('member')->getUserAssetsInfo($uid);
- $level = intval($property['levelId']);
- $out = [];
- $coinsArr = self::getCoinsDataByLevel($level);
- $configArr = self::getGoodTransformConfig();
- $point = oo::commonOprModel('newvip')->getUserCurPoint($uid); //积分
- $sid = empty($sid)?oo::getDefinedSid($uid):$sid;
- foreach ($goodsInfo as $row) {
- $row['gsku'] = ($sid == 1) ? self::googleSkuToAndroid($row['gsku']) : self::googleSkuToIosSku($row['gsku']);
- $goodTypeId = $row['gtype'];
- $config = $configArr[$goodTypeId];
- if(empty($config)){
- continue;
- }
- $temp = [];
- foreach ($config['character'] as $key=>$value){
- $temp[$key] = $row[$value];
- $key=='price' && $temp[$key] = '$'.$row[$value];
- $key=='priceNum' && $temp[$key] = (string)$row[$value];
- }
- //根据玩家积分、等级 返回对应商品
- $keyType = $row['gid']==1501?'money':($row['gid'] == 1502 ? 'spins' : 'diamond');
- if($row['gid'] == 1502 || ($point < 1000 && in_array($row['gid'], [1501, 1511]))){
- $configNotEnough = oo::commonOprModel('config')->getShopNotEnoughConfig($keyType);
- } else {
- $configNotEnough = [];
- }
- $gid = 0;
- foreach($configNotEnough as $rowTemp){
- if($rowTemp['point'] <= $point && $rowTemp['level'] <= $level){
- $gid = $rowTemp['gid'];
- }
- }
- if($gid){
- $goodInfoTemp = self::getGoodsInfoByGid($gid);
- if(!empty($goodInfoTemp)){
- $temp['sku'] = ($sid == 1) ? self::googleSkuToAndroid($goodInfoTemp['gsku']) : self::googleSkuToIosSku($goodInfoTemp['gsku']);
- $temp['price'] = '$'.$goodInfoTemp['gprice'];
- $temp['priceNum'] = (string)$goodInfoTemp['gprice'];
- $temp['addRatio'] = $goodInfoTemp['gaddRatio'];
- $row['gbaseReward'] = $goodInfoTemp['gbaseReward'];
- oo::commonOprRedis('common')->setex(okeys::shopNotEnoughLog($uid,$row['gid']),json_encode($goodInfoTemp),1 * 24 * 3600);
- }
- }
- if(in_array($row['gid'],[1501])){
- $rewardTemp = json_decode($row['gbaseReward'],true);
- $coins = self::getGoodCoinsByLevelId($level + 1,$rewardTemp['coins']['coins']);
- $temp['num'] = $coins * $rewardTemp['coins']['bet'];
- }else if(in_array($row['gid'],[1502,1511])){
- $temp['num'] = $row['gbaseReward'];
- }
- $temp['sku'] == "" && $temp['sku'] = NULL;
- $temp['priceDollar'] = '$';
- $temp['priceCurrencyCode'] = 'USD';
- $out[$config['name']][] = $temp;
- }
- return ['code'=>1,'list'=>$out];
- }
- /**
- * Notes:通过类型获取商品(局部刷新商品配置)
- * User: wsc
- * Time: 2020/11/27 16:13
- * @param $uid
- * @param $type
- * @return array
- */
- public function getGoodListByType($uid,$type){
- $out =[];
- $sid = oo::getDefinedSid($uid);
- if($type=='super_serial_pack'){
- $out['super_serial_pack'] = array_values(oo::commonOprModel('activitynew')->getCGGoodList($uid,$type));
- }else if($type=='super_serial_pack2'){
- $out['super_serial_pack2'] = array_values(oo::commonOprModel('activitynew')->getCGGoodList($uid,$type));
- }else if($type=='chain_gift'){
- $aid = oo::commonOprModel('activitynew')->activityLock($uid,'chain_gift');
- if($aid){
- foreach ([710,711,712] as $gid){
- oo::commonOprRedis('activity')->setex(okeys::bindChainGift($uid),$aid,86400*3);//连环礼包绑定活动id
- $ret = oo::commonOprModel('activitynew')->getChainGiftConf($uid,$aid,$gid);
- foreach ($ret['props'] as $k=>$p){
- $pConf = oo::commonOprModel('props')->getChestData($uid,$p['propsId']);
- $pConf && $ret['props'][$k]['reward'] = $pConf;
- }
- $temp['coin'] =$ret['coin'];
- $temp['coins'] =$ret['coin'];
- $temp['spin'] =$ret['spin'];
- $temp['spins'] =$ret['spin'];
- $temp['props'] =$ret['props'];
- $temp['price'] =$ret['price'];
- $temp['priceNum'] =$ret['priceNum'];
- $temp['sku'] =($sid == 1) ? self::googleSkuToAndroid($ret['sku']) : self::googleSkuToIosSku($ret['sku']);
- $temp['giftType'] =$ret['giftType'];
- $temp['gMax'] =$ret['gMax'];
- $temp['priceDollar'] = '$';
- $temp['priceCurrencyCode'] = 'USD';
- $out['gift'][] = $temp;
- }
- }
- }else if($type=='easter_egg'){
- $out['easter_egg'] = oo::commonOprModel('activitynew')->getEasterGiftBag($uid);
- }else if($type=='chooseOne'){
- $out['chooseOne'] = oo::commonOprModel('activitynew')->getChooseOneGoods($uid);
- }else if($type=='onePlusGift'){
- $out['onePlusGift'] = oo::commonOprModel('activitynew')->getActivityGoods($uid,"one_plus_gift");
- }else if($type=='safeSurprise'){
- $out['safeSurprise'] = oo::commonOprModel('activitynew')->getActivityGoods($uid,"safe_surprise");
- }
- return ['code'=>1,'list'=>$out,'recomment'=>[]];
- }
- ///**
- // * 苹果过审商品sku临时替换
- // * @return string
- // */
- //public function appleSkuReplace($sku) {
- // $sku = str_replace('sa.crazygod','astak.crazyspin',$sku);
- // $sku = str_replace('gworld.cc','astak.crazyspin',$sku);
- // switch($sku){
- // case 'com.astak.crazyspin.gift01': //9.99
- // $sku = 'com.astak.crazyspin.coins03';
- // break;
- // case 'com.astak.crazyspin.gift02': //19.99
- // $sku = 'com.astak.crazyspin.coins04';
- // break;
- // case 'com.astak.crazyspin.gift04': //4.99
- // $sku = 'com.astak.crazyspin.coins02';
- // break;
- // case 'com.astak.crazyspin.gift07': //1.99
- // $sku = 'com.astak.crazyspin.coins01';
- // break;
- // case 'com.astak.crazyspin.gift09': //49.99
- // $sku = 'com.astak.crazyspin.coins05';
- // break;
- // }
- // return $sku;
- //}
- /**
- * 谷歌Sku转换成Ios Sku
- * @param $sku
- * @return mixed
- * Created by: Owen
- * Created on: 2020/8/17 14:38
- */
- public function googleSkuToIosSku($sku){
- $sku = str_replace('sa.crazygod', 'gworld.cc', $sku);
- return str_replace('gworld.cc','astak.crazyspin',$sku);
- }
- /**
- * 安卓旧版sku转新版
- * @param $sku
- * @return mixed
- * Created by: Owen
- * Created on: 2021/5/7 15:09
- */
- public function googleSkuToAndroid($sku){
- return str_replace('sa.crazygod','gworld.cc',$sku);
- }
-
- /**
- * 获取礼包配置
- * @return array
- * Created by: Owen
- * Created on: 2020/8/17 14:46
- */
- public function getGiftConfig(){
- return [
- 701 => ['coins'=>'coins02','coinsBet'=>0.5 ,'giftType'=>1],
- 702 => ['coins'=>'coins02','coinsBet'=>1 ,'giftType'=>1],
- 703 => ['coins'=>'coins02','coinsBet'=>2 ,'giftType'=>1],
- 704 => ['coins'=>'coins01','coinsBet'=>0.25,'giftType'=>2],
- 705 => ['coins'=>'coins02','coinsBet'=>0.25,'giftType'=>2],
- 706 => ['coins'=>'coins03','coinsBet'=>0.25,'giftType'=>2],
- 707 => ['coins'=>'coins01','coinsBet'=>1.8 ,'giftType'=>3],
- 708 => ['coins'=>'coins02','coinsBet'=>1.4 ,'giftType'=>3],
- 709 => ['coins'=>'coins03','coinsBet'=>1.2 ,'giftType'=>3],
- ];
- }
- /**
- * 获取等级coins值
- * @param $level
- * @return array
- * Created by: Owen
- * Created on: 2020/8/17 14:56
- */
- public function getCoinsDataByLevel($level){
- $coins = ["coins01","coins02","coins03","coins04","coins05","coins06"];
- $coinsArr = [];
- foreach ($coins as $coin) {
- $coinsArr[$coin] = self::getGoodCoinsByLevelId($level,$coin);
- }
- return $coinsArr;
- }
- /**
- * 获取商城卡片宝箱价格
- * @param $level
- * @return array|mixed
- * Created by: Owen
- * Created on: 2020/8/17 15:09
- */
- public function getCardChestConfig($level){
- $cacheKey = okeys::CardChestConfig();
- $cache = oo::commonOprRedis('Config')->hGet($cacheKey,$level);
- if(empty($cache)){
- $tb = otable::CardChest();
- $cache = oo::commonOprDb('payment')->getOne("SELECT * FROM {$tb} WHERE levelId={$level} LIMIT 1",MYSQLI_ASSOC);
- oo::commonOprRedis('Config')->hSet($cacheKey,$level,json_encode($cache));
- }else{
- $cache = json_decode($cache,true);
- }
- return $cache;
- }
- public function getGoodTransformConfig(){
- return [
- 1=>[
- 'name' =>'spin',
- 'character'=>[
- 'tagType' =>'gattribute',
- 'gid' =>'gid',
- 'id' =>'gimg',
- 'addRatio' =>'gaddRatio',
- 'num' =>'gbaseReward',
- 'originalNum'=>'goriginReward',
- 'price' =>'gprice',
- 'priceNum' =>'gprice',
- 'sku' =>'gsku',
- 'ggameid' =>'ggameid',
- 'gdiscount' =>'gdiscount',
- ]
- ],
- 2=>[
- 'name' =>'coin',
- 'character'=>[
- 'tagType' =>'gattribute',
- 'id' =>'gimg',
- 'gid' =>'gid',
- 'addRatio' =>'gaddRatio',
- 'price' =>'gprice',
- 'priceNum' =>'gprice',
- 'sku' =>'gsku',
- 'ggameid' =>'ggameid',
- 'gdiscount'=>'gdiscount',
- ]
- ],
- 3=>[
- 'name' =>'chest',
- 'character'=>[
- 'id' =>'gimg',
- 'gid' =>'gid',
- 'title' =>'gname_en',
- 'ggameid' =>'ggameid',
- 'gdiscount' =>'gdiscount',
- ]
- ],
- 5=>[
- 'name' =>'wheel',
- 'character'=>[
- 'id' =>'gimg',
- 'gid' =>'gid',
- 'addRatio' =>'gaddRatio',
- 'num' =>'gbaseReward',
- 'price' =>'gprice',
- 'priceNum' =>'gprice',
- 'sku' =>'gsku',
- 'ggameid' =>'ggameid',
- 'gdiscount' =>'gdiscount',
- ]
- ],
- 6=>[
- 'name' =>'firstPay',
- 'character'=>[
- 'id' =>'gimg',
- 'gid' =>'gid',
- 'price' =>'gprice',
- 'priceNum' =>'gprice',
- 'sku' =>'gsku',
- 'ggameid' =>'ggameid',
- 'gdiscount' =>'gdiscount',
- ]
- ],
- 7=>[
- 'name' =>'gift',
- 'character'=>[
- 'id' =>'gimg',
- 'gid' =>'gid',
- 'ggameid' =>'ggameid',
- 'gdiscount' =>'gdiscount',
- 'addRatio' =>'gaddRatio',
- 'spin' => 'gbaseReward',
- 'spins' => 'gbaseReward',
- 'price' => 'gprice',
- 'priceNum' => 'gprice',
- 'sku' => 'gsku',
- ]
- ],
- 8=>[
- 'name' =>'subscription',
- 'character'=>[
- 'id' =>'gimg',
- 'gid' =>'gid',
- 'price' =>'gprice',
- 'priceNum' =>'gprice',
- 'sku' =>'gsku',
- 'ggameid' =>'ggameid',
- 'gdiscount' =>'gdiscount',
- 'addRatio' =>'gaddRatio',
- ]
- ],
- // 9=>[
- // 'name' =>'festival',
- // 'character'=>[
- // 'id' =>'gimg',
- // 'gid' =>'gid',
- // 'price' =>'gprice',
- // 'priceNum' =>'gprice',
- // 'sku' =>'gsku',
- // 'ggameid' =>'ggameid',
- // 'gdiscount'=>'gdiscount',
- // 'addRatio' =>'gaddRatio',
- // 'maxNum' =>'gMax',
- // ]
- // ],
- 10=>[
- 'name' =>'monthly',
- 'character'=>[
- 'id' =>'gimg',
- 'gid' =>'gid',
- 'price' =>'gprice',
- 'priceNum' =>'gprice',
- 'sku' =>'gsku',
- 'ggameid' =>'ggameid',
- 'gdiscount'=>'gdiscount',
- 'addRatio' =>'gaddRatio',
- ]
- ],
- // 11=>[
- // 'name' =>'bless',
- // 'character'=>[
- // 'id' =>'gimg',
- // 'gid' =>'gid',
- // 'price' =>'gprice',
- // 'priceNum' =>'gprice',
- // 'sku' =>'gsku',
- // 'ggameid' =>'ggameid',
- // 'gdiscount'=>'gdiscount',
- // 'addRatio' =>'gaddRatio',
- // ]
- // ],
- 12=>[
- 'name' =>'luckyDraw',
- 'character'=>[
- 'id' =>'gimg',
- 'gid' =>'gid',
- 'price' =>'gprice',
- 'priceNum' =>'gprice',
- 'sku' =>'gsku',
- 'ggameid' =>'ggameid',
- 'gdiscount'=>'gdiscount',
- 'addRatio' =>'gaddRatio',
- ]
- ],
- 13=>[
- 'name' =>'petFeed',
- 'character'=>[
- 'id' =>'gimg',
- 'gid' =>'gid',
- 'price' =>'gprice',
- 'priceNum'=>'gprice',
- 'sku' =>'gsku',
- 'num' =>'gbaseReward',
- 'expNum' =>'goriginReward',
- 'ggameid' =>'ggameid',
- ]
- ],
- 14=>[
- 'name' =>'petExp',
- 'character'=>[
- 'id' =>'gimg',
- 'gid' =>'gid',
- 'price' =>'gprice',
- 'priceNum'=>'gprice',
- 'sku' =>'gsku',
- 'num' =>'gbaseReward',
- 'ggameid' =>'ggameid',
- ]
- ],
- 15=>[
- 'name' =>'special',
- 'character'=>[
- 'tagType' =>'gattribute',
- 'id' =>'gimg',
- 'gid' =>'gid',
- 'addRatio' =>'gaddRatio',
- 'num' =>'gbaseReward',
- 'price' =>'gprice',
- 'priceNum' =>'gprice',
- 'sku' =>'gsku',
- 'ggameid' =>'ggameid',
- 'gdiscount'=>'gdiscount',
- ]
- ],
- 16=>[
- 'name' =>'gift',
- 'character'=>[
- 'gid' =>'gid',
- 'pid' =>'gpid',
- 'price' =>'gprice',
- 'priceNum' =>'gprice',
- 'sku' =>'gsku',
- 'ggameid' =>'ggameid',
- 'gdiscount'=>'gdiscount',
- 'addRatio' =>'gaddRatio',
- 'expire' =>'gExpire',
- 'max' =>'gMax',
- ]
- ],
- 17=>[
- 'name' =>'gift',
- 'character'=>[
- 'gid' =>'gid',
- 'pid' =>'gpid',
- 'price' =>'gprice',
- 'priceNum' =>'gprice',
- 'sku' =>'gsku',
- 'ggameid' =>'ggameid',
- 'gdiscount'=>'gdiscount',
- 'addRatio' =>'gaddRatio',
- 'expire' =>'gExpire',
- 'max' =>'gMax',
- ]
- ],
- 18=>[
- 'name' =>'gift',
- 'character'=>[
- 'gid' =>'gid',
- 'pid' =>'gpid',
- 'price' =>'gprice',
- 'priceNum' =>'gprice',
- 'sku' =>'gsku',
- 'ggameid' =>'ggameid',
- 'gdiscount'=>'gdiscount',
- 'addRatio' =>'gaddRatio',
- 'expire' =>'gExpire',
- 'max' =>'gMax',
- ]
- ],
- 19=>[
- 'name' =>'gift',
- 'character'=>[
- 'gid' =>'gid',
- 'pid' =>'gpid',
- 'price' =>'gprice',
- 'priceNum' =>'gprice',
- 'sku' =>'gsku',
- 'ggameid' =>'ggameid',
- 'gdiscount'=>'gdiscount',
- 'addRatio' =>'gaddRatio',
- 'expire' =>'gExpire',
- 'max' =>'gMax',
- ]
- ],
- 20=>[
- 'name' =>'pass',
- 'character'=>[
- 'gid' =>'gid',
- 'pid' =>'gpid',
- 'price' =>'gprice',
- 'priceNum' =>'gprice',
- 'sku' =>'gsku',
- 'ggameid' =>'ggameid',
- 'gdiscount'=>'gdiscount',
- 'addRatio' =>'gaddRatio',
- 'expire' =>'gExpire',
- 'max' =>'gMax',
- ]
- ],
- // 21=>[
- // 'name' =>'diamond',
- // 'character'=>[
- // 'tagType' =>'gattribute',
- // 'gid' =>'gid',
- // 'id' =>'gimg',
- // 'pid' =>'gpid',
- // 'addRatio' =>'gaddRatio',
- // 'num' =>'gbaseReward',
- // 'originalNum'=>'goriginReward',
- // 'price' =>'gprice',
- // 'priceNum' =>'gprice',
- // 'sku' =>'gsku',
- // 'ggameid' =>'ggameid',
- // 'gdiscount' =>'gdiscount',
- // ]
- // ],
- // 22=>[
- // 'name' =>'super_serial_pack',
- // 'character'=>[
- // 'id' =>'gimg',
- // 'gid' =>'gid',
- // 'ggameid' =>'ggameid',
- // 'gdiscount' =>'gdiscount',
- // 'addRatio' =>'gaddRatio',
- // 'price' => 'gprice',
- // 'priceNum' => 'gprice',
- // 'sku' => 'gsku',
- // ]
- // ]
- 23=>[
- 'name' =>'safeBox',
- 'character'=>[
- 'tagType' =>'gattribute',
- 'gid' =>'gid',
- 'id' =>'gimg',
- 'pid' =>'gpid',
- 'price' =>'gprice',
- 'priceNum' =>'gprice',
- 'sku' =>'gsku',
- 'ggameid' =>'ggameid',
- 'gdiscount' =>'gdiscount',
- ]
- ],
- 24=>[
- 'name' =>'passLevel',
- 'character'=>[
- 'gid' =>'gid',
- 'pid' =>'gpid',
- 'price' =>'gprice',
- 'priceNum' =>'gprice',
- 'sku' =>'gsku',
- 'ggameid' =>'ggameid',
- 'gdiscount'=>'gdiscount',
- 'addRatio' =>'gaddRatio',
- 'expire' =>'gExpire',
- 'max' =>'gMax',
- ]
- ],
- 26=>[
- 'name' =>'fund',
- 'character'=>[
- 'gid' =>'gid',
- 'pid' =>'gpid',
- 'price' =>'gprice',
- 'priceNum' =>'gprice',
- 'sku' =>'gsku',
- 'ggameid' =>'ggameid',
- 'gdiscount'=>'gdiscount',
- 'addRatio' =>'gaddRatio',
- 'expire' =>'gExpire',
- 'max' =>'gMax',
- ]
- ],
- ];
- }
- /**
- * 推荐商品
- * @param $uid
- * @return array
- * Created by: Owen
- * Created on: 2020/4/23 11:43
- */
- public function getRecommend($uid){
- $recommend = oo::commonOprModel('readconfig')->getSysCon('Shop',"recommend");
- $recommend = json_decode($recommend,true);
- $i = 1;
- $out = [];
- array_multisort(array_column($recommend,'sort'),SORT_ASC,$recommend);
- foreach ($recommend as $row){
- if($row['open'] == 0 || $i>3){
- continue;
- }
- if($row['id'] == 1){
- if(oo::commonOprModel('member')->getUserFirstPayStatus($uid)){
- if(oo::commonOprModel('activity')->activityLock($uid,1,true)){
- continue;
- }
- }
- }
- //if($row['id'] == 4){
- // $isVip = oo::commonOprModel('newvip')->checkVip($uid);
- // if($isVip && $isVip['isFreeing'] == 0){
- // continue;
- // }
- //}
- if($row['id'] == 2){
- if(oo::commonOprRedis('common')->get(okeys::promotion($uid,703))){
- if(oo::commonOprModel('activity')->activityLock($uid,5,true)){
- continue;
- }
- }
- }
- $out[] = $row;
- $i++;
- }
- return $out;
- }
- /**
- * 获得coins的值
- * @param $uid
- * @param $coins
- * @return int
- * Created by: Owen
- * Created on: 2019/11/6 14:59
- */
- public function getGoodCoins($uid,$coins){
- $property = oo::commonOprModel('member')->getUserAssetsInfo($uid);
- $level = intval($property['levelId']);
- return self::getGoodCoinsByLevelId($level,$coins);
- }
- /**
- * 根据等级获得coins的值
- * @param $level
- * @param $coins
- * @return int
- * Created by: Owen
- * Created on: 2019/12/17 14:41
- */
- public function getGoodCoinsByLevelId($level,$coins){
- $cacheKey = okeys::GoodsCoin($level,$coins);
- $cache = oo::commonOprRedis('config')->get($cacheKey);
- if($cache){
- return $cache;
- }
- $tb = otable::goodsCoin();
- $sql = "SELECT * FROM {$tb} WHERE gsku='com.gworld.cc.{$coins}' AND levelId={$level}";
- $coinInfo = oo::commonOprDb('payment')->getOne($sql,MYSQLI_ASSOC);
- $num = $coinInfo['num']??0;
- oo::commonOprRedis('config')->setex($cacheKey,$num,7*24*60*60);
- return $num;
- }
- /**
- * 获取限时特惠
- * @param $uid
- * @return array
- * Created by: Owen
- * Created on: 2020/8/17 11:06
- */
- public function specialOffer($uid){
- $giftArr = [
- 704 => ['coins'=>'coins01','coinsBet'=>0.25,'giftType'=>2],
- 705 => ['coins'=>'coins02','coinsBet'=>0.25,'giftType'=>2],
- 706 => ['coins'=>'coins03','coinsBet'=>0.25,'giftType'=>2],
- ];
- $userPayNum = oo::commonOprModel('payment')->getUserTotalPayNum($uid);
- if($userPayNum > 10){
- $gid = 706;
- }else if($userPayNum > 0){
- $gid = 705;
- }else{
- $gid = 704;
- }
- $sid = oo::getDefinedSid($uid);
- $reward = $giftArr[$gid];
- $money = intval(self::getGoodCoins($uid,$reward['coins']) * $reward['coinsBet']);
- $tb = otable::goodsCrazy();
- $sql = "SELECT * FROM {$tb} WHERE gid={$gid} limit 1";
- $goodsInfo = oo::commonOprDb('payment')->getOne($sql,1);
- $temp = [];
- $goodsInfo['gsku'] = ($sid==1)?$goodsInfo['gsku']:str_replace('sa.crazygod','newsky.cc',$goodsInfo['gsku']);
- $temp[] = [
- 'id' =>$goodsInfo['gimg'],
- 'gid' =>$goodsInfo['gid'],
- 'coin' =>$money,
- 'coins' =>$money,
- 'spin' =>intval($goodsInfo['gbaseReward']),
- 'spins' =>intval($goodsInfo['gbaseReward']),
- 'price' =>'$'.$goodsInfo['gprice'],
- 'sku' =>$goodsInfo['gsku'],
- 'ggameid' =>$goodsInfo['ggameid'],
- 'gdiscount' =>$goodsInfo['gdiscount'],
- 'priceDollar'=>'$',
- 'priceCurrencyCode'=>'USD',
- 'addRatio' =>$goodsInfo['gaddRatio'],
- ];
- return $temp;
- }
- /**
- * 限时特惠分段
- * @param $uid
- * @return int
- * Created by: Owen
- * Created on: 2020/8/17 11:05
- */
- public function specialOfferLv($uid){
- $lv = 1;
- $tb = otable::payment($uid);
- $sql = "SELECT SUM(pusd) AS sum FROM {$tb} WHERE uid={$uid} AND status=2";
- $ret = oo::commonOprDb('payment')->getOne($sql,MYSQLI_ASSOC);
- if(!empty($ret)){
- if($ret['sum'] > 0){
- $lv = 2;
- }
- if($ret['sum'] > 10){
- $lv = 3;
- }
- }
- return $lv;
- }
- /**
- * 通过订单号返回对应的商品名称
- * @param int $order
- * @return bool
- * Created by: Owen
- * Created on: 2020/8/17 11:05
- */
- public function getGpidByOrderIdCrazyGod($order = 0){
- $stable = otable::summarylist();
- $sql = " SELECT sl_gid FROM {$stable} WHERE sl_orderid = '{$order}' LIMIT 1";
- $dbData = oo::commonOprDb('payment')->getOne($sql, MYSQLI_ASSOC);
- if (empty($dbData)) {
- return false;
- }
- $sl_gid = $dbData['sl_gid'];
- $gtable = otable::goodsCrazy();
- $gsql = " SELECT gsku FROM {$gtable} WHERE gid = {$sl_gid} LIMIT 1 ";
- $goodsDbData = oo::commonOprDb('payment')->getOne($gsql, MYSQLI_ASSOC);
- if (empty($goodsDbData)) {
- return false;
- }
- return $goodsDbData['gsku'];
- }
- /**
- * 根据uid和gpid(商品名称)获取订单ID
- * @param int $uid
- * @param int $gpid
- * @return bool
- * Created by: Owen
- * Created on: 2020/8/17 11:06
- */
- public function getOrderByUidAndgpidCrazyGod($uid = 0, $gpid = 0){
- if(empty($uid) || empty($gpid)) {
- return false;
- }
- $goodsTable = otable::goodsCrazy();
- $sql_goods = " SELECT gid FROM {$goodsTable} WHERE gpid = '{$gpid}' AND gchannel = 3";
- $retGoodsData = oo::commonOprDb('payment')->getOne($sql_goods, 1);
- oo::logs()->debug3(array('retGoodsData' => $retGoodsData, 'sql_goods' => $sql_goods), 'getOrderByUidAndgpid.log');
- if (empty($retGoodsData)) {
- return false;
- }
- $gid = $retGoodsData['gid'];//商品ID
- $table = otable::payment($uid);
- $sql = " SELECT order_id FROM {$table} WHERE uid = {$uid} AND gid = {$gid} AND status = 1 ORDER BY order_time DESC ";
- $retpayData = oo::commonOprDb('payment')->getOne($sql, 1);
- oo::logs()->debug3(array('retpayData' => $retpayData, 'sql' => $sql), 'getOrderByUidAndgpid.log');
- if (empty($retpayData)) {
- return false;
- }
- $orderId = $retpayData['order_id'];
- return $orderId;
- }
- /**
- * 通过商品id获取商品的信息
- * @param $gid
- * @return mixed
- */
- public function getGoodsInfoByGid($gid){
- $table = otable::goodsCrazy();
- $sql = "SELECT * FROM {$table} WHERE gid = {$gid} LIMIT 1 ";
- $ret = oo::commonOprDb('payment')->getOne($sql, 1);
- return $ret;
- }
- /**
- * 用户商店横条数据
- * @param $uid
- * @return string
- * Created by: Owen
- * Created on: 2021/1/22 12:15
- */
- public function getFreeBarData($uid){
- $conf = json_decode(oo::commonOprModel('readconfig')->getSysCon('Shop',"freeBar"),true);
- $reward = $conf['reward'];
- foreach ($reward as &$row){
- $pConf = oo::commonOprModel('props')->getChestData($uid,$row['propsId']);
- if($pConf){
- $row['value'] = $pConf;
- }
- }
- $data = [
- 'isOpen' => $conf['isOpen'],
- 'time' => time() + intval(oo::commonOprRedis('User')->ttl(okeys::UserFreeBarTtl($uid))),
- 'reward' => $reward,
- ];
- return oo::response(1,$data);
- }
- /**
- * 领取商店横条奖励
- * @param $uid
- * @return string
- * Created by: Owen
- * Created on: 2021/1/22 12:28
- */
- public function rewardFreeBar($uid){
- if(oo::commonOprRedis('User')->ttl(okeys::UserFreeBarTtl($uid)) > 0){
- return oo::response(errorCode::FREE_BAR_TTL_ERROR);
- }
- $conf = json_decode(oo::commonOprModel('readconfig')->getSysCon('Shop',"freeBar"),true);
- $reward = $conf['reward'];
- foreach ($reward as &$row){
- oo::commonOprModel('member')->sendReward($uid,$row['propsId'],$row['num'],117,'商店横条',[],$row);
- }
- $interval = intval($conf['interval'] ?? 24 *60*60);
- oo::commonOprRedis('User')->setex(okeys::UserFreeBarTtl($uid),1,$interval);
- $time = time() + $interval;
- $data = [
- 'isOpen' => $conf['isOpen'],
- 'time' => $time,
- 'reward' => $reward,
- ];
- oo::commonOprRedis('Usercache')->zAdd(okeys::PushCrontab("FreeBar"),$time,$uid);
- return oo::response(1,$data);
- }
- }
|