diff --git a/application/api/controller/UserWallet.php b/application/api/controller/UserWallet.php index 3148b731..aca4ab9f 100644 --- a/application/api/controller/UserWallet.php +++ b/application/api/controller/UserWallet.php @@ -14,43 +14,19 @@ class UserWallet extends BaseCom return V($reslut['code'], $reslut['msg'], $reslut['data']); } -// //给前端的类型组装一个 -// public function gift_type() -// { -// // 1.系统调节 2.充值 3.提现 4.金币转增(送出) 5.每日任务奖励 6.充值返利 7.购买装扮 -// // 8.礼盒奖励 9.房间补贴 10.购买礼物 11.收礼增加收益 12.工会补贴 13.转赠金币(接收) 14.收益兑换 -// $data = [ -//// ['id' => 1, 'name' => '系统调节'], -// ['id' => 2, 'name' => '充值'], -// ['id' => 3, 'name' => '提现'], -// ['id' => 4, 'name' => '金币转增'], -// ['id' => 5, 'name' => '每日任务奖励'], -// ['id' => 6, 'name' => '充值返利'], -// ['id' => 7, 'name' => '购买装扮'], -// ['id' => 8, 'name' => '礼盒奖励'], -// ['id' => 9, 'name' => '房间补贴'], -// ['id' => 10, 'name' => '购买礼物'], -// ['id' => 11, 'name' => '收礼增加收益'], -// ['id' => 12, 'name' => '工会补贴'], -// ['id' => 13, 'name' => '金币转增'], -// ['id' => 14, 'name' => '收益兑换'], -// ['id' => 15, 'name' => '送礼'], -// ]; -// return V(1, '获取成功', $data); -// } //金币(钻石)明细 public function log_list() { - $page = input('page', 1); + // 1. 接收参数(前端传递:last_id=上一页最后一条的id,page_limit=每页条数) + $last_id = input('last_id', 0); // 第一页 last_id=0 $page_limit = input('page_limit', 30); $in_out_type = input('in_out_type', 1);//1收入2支出 $gift_type = input('gift_type', 1);//1金币,2收益(钻石) - //开始时间 - $start_time = input('start_time', ''); - $end_time = input('end_time', ''); + $start_time = input('start_time', '');//开始时间 + $end_time = input('end_time', '');//结束时间 - $reslut = model('UserWallet')->log_list($this->uid, $page, $page_limit,$in_out_type,$start_time,$end_time,$gift_type); + $reslut = model('UserWallet')->log_list($this->uid, $last_id, $page_limit,$in_out_type,$start_time,$end_time,$gift_type); return V($reslut['code'], $reslut['msg'], $reslut['data']); } diff --git a/application/api/model/UserWallet.php b/application/api/model/UserWallet.php index 9dff99c2..ab63dc7a 100644 --- a/application/api/model/UserWallet.php +++ b/application/api/model/UserWallet.php @@ -40,56 +40,75 @@ class UserWallet extends Model } //金币/钻石 明细 - public function log_list($uid, $page, $page_limit,$in_out_type,$start_time,$end_time,$gift_type) + //change_type + // 1.系统调节 2.充值 3.提现 4.金币转增(送出) 5.每日任务奖励 6.充值返利 7.购买装扮 + // 8.礼盒奖励 9.房间补贴 10.购买礼物 11.收礼增加收益 12.工会补贴 13.转赠金币(接收) 14.收益兑换 + // 15.首充 16.天降好礼充值 17.退出工会扣款 18.房主收益 19.主持人收益 20.抢头条 21.公会长收益,22.提现驳回或提现失败返还,23.财富等级奖励金币领取,24.删除关系扣金币, + // 25.赠送好友金币,26.好友转赠所得金币,27.小时榜获得金币,28.新人充值好礼,29.发红包(钻石),30.抢红包(金币),31.抢红包(钻石),32.发红包(金币), + // 33.红包剩余退回(金币),34-红包剩余退回(钻石),35-爵位购买赠送金币(金币),40-后台充值金币,41-后台充值钻石,42-后台扣除金币,43-后台扣除钻石, + //50-签约,51-签约失败退回,52-首次被签约收入,53.签约师傅每日返还,54-叛徒补偿,55-徒弟收礼返佣,56-续约,57-签到,58-爆币,59-红包手续费 + public function log_list($uid, $last_id, $page_limit,$in_out_type,$start_time,$end_time,$gift_type) { - $page = intval($page); - $page_limit = $page_limit < 30 ? $page_limit : 30; - $map = []; - $map['money_type'] = $gift_type;//1金币,2收益(钻石) - $in_out_types = []; - // 1.系统调节 2.充值 3.提现 4.金币转增(送出) 5.每日任务奖励 6.充值返利 7.购买装扮 - // 8.礼盒奖励 9.房间补贴 10.购买礼物 11.收礼增加收益 12.工会补贴 13.转赠金币(接收) 14.收益兑换 - // 15.首充 16.天降好礼充值 17.退出工会扣款 18.房主收益 19.主持人收益,20.发布头条扣除余额,21.公会长收益,22.提现驳回或提现失败返还,23.财富等级奖励金币领取,24.删除关系扣金币 - //27.小时榜获得,28-新人充值好礼,32-发红包(金币),29-发红包(钻石),30-抢红包(金币),31-抢红包(钻石) 33-红包剩余退回(金币),34-红包剩余退回(钻石) - //50-签约 51-签约失败退回,52-首次被签约收入 53-师徒签到 54-叛徒补偿,55-徒弟收礼返佣,56-续约,57签到,58爆币,59红包手续费 - if($gift_type == 1){ //1金币,2收益(钻石) - if($in_out_type == 1){//1收入 - $in_out_types = [1,2,5,6,8,13,14,15,16,22,23,26,27,30,28,33,51,57,58]; - }elseif($in_out_type == 2){//2支出 - $in_out_types = [1,4,7,10,17,20,24,25,32,50,56,59]; - } - }elseif($gift_type == 2){ //1金币,2收益(钻石) - if($in_out_type == 1){//1收入 - $in_out_types = [1,6,9,11,12,18,19,21,22,31,28,34,52,53,54,55,57]; - }elseif($in_out_type == 2){//2支出 - $in_out_types = [1,3,14,29]; - } - } - - $map['change_type'] = ['in', $in_out_types]; - $map['user_id'] =$uid; - // 时间范围处理 if (!empty($start_time) && !empty($end_time)) { $start_time = strtotime($start_time); - $end_time = strtotime($end_time.' 23:59:59'); + $end_time = strtotime($end_time); $map['createtime'] = ['between', [$start_time, $end_time]]; } - $list = Db::name('vs_user_money_log') - ->where($map) - ->field('log_id, user_id, change_type, change_value, remarks, createtime') - ->order('log_id desc') - ->page($page, $page_limit) - ->select(); - foreach ($list as $key => &$value) { - $value['change_type_name'] = model('common/UserWallet')->ChangeTypeLable($value['change_type']); - if($in_out_type==2){ - $value['change_value'] = $value['change_value'] * -1; - } + $map['user_id'] =$uid; + if ($last_id > 0) { + $map['id'] = ['<', $last_id]; // 下一页:只查id小于上一页最后一个id的记录 } - return ['code' => 1, 'msg' => '获取成功', 'data' => $list]; + //1-金币 + if($gift_type == 1){ + //1-收入 + if($in_out_type == 1){ + $in_out_types = [2,5,6,8,13,14,15,16,22,23,26,27,30,28,33,40,51,57,58]; + $map['change_type'] = ['in', $in_out_types]; + + }else{//2-支出 + $in_out_types = [4,7,10,17,20,24,25,32,42,50,56,59]; + $map['change_type'] = ['in', $in_out_types]; + + } + + $list = Db::name('user_coin_log') + ->where($map) + ->field('id,change_type, coin as change_value, remarks, createtime') + ->order('id desc') + ->limit($page_limit) // 只取指定条数,无offset + ->select(); + foreach ($list as &$value) { + $value['change_type_name'] = model('common/UserWallet')->ChangeTypeLable($value['change_type']); + } + }else{//-2收益(钻石) + //1-收入 + if($in_out_type == 1){ + $in_out_types = [9,11,12,18,19,21,22,31,28,34,41,52,53,54,55,57]; + $map['change_type'] = ['in', $in_out_types]; + }else{//2-支出 + $in_out_types = [3,14,29,43]; + $map['change_type'] = ['in', $in_out_types]; + } + $list = Db::name('user_earnings_log') + ->where($map) + ->field('id,change_type, earnings as change_value, remarks, createtime') + ->order('id desc') + ->limit($page_limit) // 只取指定条数,无offset + ->select(); + foreach ($list as &$value) { + $value['change_type_name'] = model('common/UserWallet')->ChangeTypeLable($value['change_type']); + } + } + $next_last_id = !empty($list) ? end($list)['id'] : 0; // 下一页的last_id + $lists = [ + 'list' => $list, + 'next_last_id' => $next_last_id, + ]; + + return ['code' => 1, 'msg' => '获取成功', 'data' => $lists]; } //收益(钻石)兑换金币 @@ -219,15 +238,15 @@ class UserWallet extends Model // 8.礼盒奖励 9.房间补贴 10.购买礼物 11.收礼增加收益 12.工会补贴 13.转赠金币(接收) 14.收益兑换 // 15.首充 16.天降好礼充值 17.退出工会扣款 18.房主收益 19.主持人收益 20.抢头条 21.公会长收益,22.提现驳回或提现失败返还,23.财富等级奖励金币领取,24.删除关系扣金币, // 25.赠送好友金币,26.好友转赠所得金币,27.小时榜获得金币,28.新人充值好礼,29.发红包(钻石),30.抢红包(金币),31.抢红包(钻石),32.发红包(金币), - // 33.红包剩余退回(金币),34-红包剩余退回(钻石),35-爵位购买赠送金币(金币), + // 33.红包剩余退回(金币),34-红包剩余退回(钻石),35-爵位购买赠送金币(金币),,40-后台充值金币,41-后台充值钻石,42-后台扣除金币,43-后台扣除钻石, //50-签约,51-签约失败退回,52-首次被签约收入,53.签约师傅每日返还,54-叛徒补偿,55-徒弟收礼返佣,56-续约,57-签到,58-爆币,59-红包手续费 //资金操作 public function change_user_cion_log($user_id,$money,$room_id,$change_type,$remarks) { //增加用户金币类型 - $in_types = [1,2,5,6,8,13,14,15,16,23,26,27,28,30,33,35,51,57,58]; + $in_types = [2,5,6,8,13,14,15,16,23,26,27,28,30,33,35,40,51,57,58]; //减少用户金币类型 - $out_types = [4,7,10,17,20,24,25,32,50,56,59]; + $out_types = [4,7,10,17,20,24,25,32,42,50,56,59]; $user_coin = Db::name('user_wallet_coin')->where(['user_id' => $user_id])->value('coin'); if(in_array($change_type,$in_types)){ @@ -278,7 +297,7 @@ class UserWallet extends Model // 8.礼盒奖励 9.房间补贴 10.购买礼物 11.收礼增加收益 12.工会补贴 13.转赠金币(接收) 14.收益兑换 // 15.首充 16.天降好礼充值 17.退出工会扣款 18.房主收益 19.主持人收益 20.抢头条 21.公会长收益,22.提现驳回或提现失败返还,23.财富等级奖励金币领取,24.删除关系扣金币, // 25.赠送好友金币,26.好友转赠所得金币,27.小时榜获得金币,28.新人充值好礼,29.发红包(钻石),30.抢红包(金币),31.抢红包(钻石),32.发红包(金币), - // 33.红包剩余退回(金币),34-红包剩余退回(钻石),35-爵位购买赠送金币(金币), + // 33.红包剩余退回(金币),34-红包剩余退回(钻石),35-爵位购买赠送金币(金币),40-后台充值金币,41-后台充值钻石,42-后台扣除金币,43-后台扣除钻石, //50-签约,51-签约失败退回,52-首次被签约收入,53.签约师傅每日返还,54-叛徒补偿,55-徒弟收礼返佣,56-续约,57-签到,58-爆币,59-红包手续费 //bcadd: 加法运算 @@ -288,10 +307,10 @@ class UserWallet extends Model public function change_user_earnings_log($user_id,$money,$room_id,$change_type,$remarks) { //增加用户钻石类型 - $in_types = [9,11,12,18,19,21,22,31,34,52,54,55]; + $in_types = [9,11,12,18,19,21,22,31,28,34,41,52,53,54,55,57]; //减少用户钻石类型 - $out_types = [3,14,29]; + $out_types = [3,14,29,43]; $user_earnings = Db::name('user_wallet_earnings')->where(['user_id' => $user_id])->value('earnings'); if(in_array($change_type,$in_types)){