\Auth::id(), 'source_uid' => $source_id, 'type' => $type, 'status' => $status, 'money_type' => $money_type, 'money' => $money, 'current_money' => self::getCurentMoney($type), 'remark' => $remark ]); } public static function saveDataByPost($uid,$type = 0, $money = 0,$current_money, $money_type = 2, $status = 1, $remark = '',$source_uid=0) { AccountLog::insert([ 'uid' => $uid, 'source_uid' => $source_uid, 'type' => $type, 'status' => $status, 'money_type' => $money_type, 'money' => $money, 'current_money' => $current_money, 'remark' => $remark ]); } /* * 获取收益addby wsl * ids array 用户id * * */ public static function getShouYi($ids,$starttime,$endtime){ //$starttime='2019-06-01'; //$endtime='2019-06-28 15:45:50'; $list=AccountLog::whereIn('type',[5, 10, 11, 12, 13, 20, 21, 22, 23])->where('uid','=',\Auth::id())->whereIn('source_uid',$ids)->whereBetween('created_at',[$starttime,$endtime])->get(); $count=0; $sum=0; $gguser=[]; $dluser=[]; $ggsum=0; $dlsum=0; if(!empty($list)){ foreach($list as $key=>$value){ $count++; $sum+=$value->money; if(strpos($value->remark,'广告')==true){ if(!in_array($value->uid,$gguser)){ $gguser[]=$value->uid; } $ggsum+=$value->money; }else{ if(!in_array($value->uid,$dluser)){ $dluser[]=$value->uid; } $dlsum+=$value->money; } } } $arr=[ 'uv' => $count, // 代理收益次数 'earnings' => round($sum,3),// 总收益 'inviteNum' => count($ids), // 下级代理数量 'proxyNum' => count($dluser), // 代理数量 'proxyMoney' => round($dlsum,3), // 代理收益 'adverNum' => count($gguser), // 广告数量 'adverMoney' => round($ggsum,3), // 广告收益 ]; return $arr; } /** * 获取当前账号余额 * @author lyh * @date 2019/3/25 * @param int $type * @description */ private static function getCurentMoney(int $type) { $user = User::find(\Auth::id()); if ($type = 1) { return $user->coin; } else { return $user->balance; } } /** * 获取金额 * @author lyh * @date 2019/3/25 * @param $id * @param array $array * @return mixed * @description */ public static function getSumMoney($id, array $array, $where = []) { $res = AccountLog::whereUid($id) ->whereStatus(1) ->whereIn('type', $array); if (!empty($where)) { $res->where($where); } return $res->sum('money'); } /** * 统计次数 * @author lyh * @date 2019/3/25 * @param $id * @param array $array * @return mixed * @description */ public static function getUv($id, array $array, $start_time, $end_time, $where = []) { $res = AccountLog::whereStatus(1) ->whereIn('uid', $id) ->whereIn('type', $array); if (!empty($where)) { $res->where($where); } if ($start_time != null && $end_time != null) { $res->whereBetween('created_at', [$start_time, $end_time]); } return $res->count('id'); } /** * 业绩 * @author lyh * @date 2019/3/26 * @param int $id * @param array $type * @param string $start * @param string $end * @description */ public static function getBusinessGoal(int $id, array $type, $start, $end) { return AccountLog::whereStatus(1) ->whereIn('uid', User::getAllInvite($id)) ->whereBetween('created_at', [$start, $end]) ->whereIn('type', $type) ->sum('money'); } /** * 获取收益 * @author lyh * @date 2019/3/27 * @param array $id * @param array $type * @param $start_time * @param $end_time * @return int * @description */ public static function getEarngings(array $id, array $type, $start_time, $end_time) { $res = AccountLog::whereStatus(1) ->whereIn('uid', $id) ->whereIn('type', $type); if (!empty($where)) { $res->where($where); } if ($start_time != null && $end_time != null) { $res->whereBetween('created_at', [$start_time, $end_time]); } return $res->sum('money'); } /** * 获取带来收益用户数 * @author lyh * @date 2019/3/27 * @param array $ids * @param array $array * @param $start_time * @param $end_time * @param array $ids1 * @return int * @description */ public static function getInviteUv(array $ids, array $array, $start_time, $end_time, array $ids1) { $res = AccountLog::whereStatus(1) ->whereIn('uid', $ids) ->groupBy('uid') ->whereIn('type', $array); if (!empty($where)) { $res->where($where); } if ($start_time != null && $end_time != null) { $res->whereBetween('created_at', [$start_time, $end_time]); } return $res->count('uid'); } /** * @author lyh * @date 2019/4/12 * @param int $type * @description * 0-未知 1-提现 2-转账点币-收入 3-转账点币-支出 4-提现 5-佣金 6-广告业绩 7-升级交费 10-直推(广告代理费分佣) 11-间一(广告代理费分佣) 12-间二(广告代理费分佣)13-全局(广告代理费分佣) 20-直推(推广代理费分佣) 21-间一(推广代理费分佣) 22-间二(推广代理费分佣)23-全局(推广代理费分佣)30-点币转账-收入 31-点币转账-支出 32-点币购买 10? 对应订单类型 */ public static function getTypeMsg(int $type) { $msg = [ 1 => '提现', 2 => '转账点币-收入', 3 => '转账点币-支出', 4 => '提现', 5 => '佣金', 6 => '广告业绩', 7 => '升级交费', 10 => '直推(广告代理费分佣)', 11 => '间一(广告代理费分佣)', 12 => '间二(广告代理费分佣)', 13 => '全局(广告代理费分佣)', 20 => '直推(推广代理费分佣)', 21 => '间一(推广代理费分佣)', 22 => '间二(推广代理费分佣)', 23 => '全局(推广代理费分佣)', 30 => '点币转账-收入', 31 => '点币转账-支出', 32 => '点币购买', 101 => '升级支付', 102 => '购买广告支付', 103 > '点币购买', ]; if (in_array($type, $msg)) { return $msg[$type]; } return ''; } }