예제 #1
0
 public function add_detail_log($user_moneys, $old_user_moneys, $user_id, $pid)
 {
     $is_in = 0;
     if ($user_moneys['user_money'] != $old_user_moneys['user_money']) {
         $change_money = $user_moneys['user_money'] - $old_user_moneys['user_money'];
         if ($change_money < 0) {
             $change_money *= -1;
             $is_in = 1;
         }
         Money_logService::get_instance()->add_log($pid, $user_id, 'USER_MONEY', $is_in, $change_money, $old_user_moneys['user_money']);
     }
     if ($user_moneys['bonus_money'] != $old_user_moneys['bonus_money']) {
         $change_money = $user_moneys['bonus_money'] - $old_user_moneys['bonus_money'];
         if ($change_money < 0) {
             $change_money *= -1;
             $is_in = 1;
         }
         Money_logService::get_instance()->add_log($pid, $user_id, 'BONUS_MONEY', $is_in, $change_money, $old_user_moneys['bonus_money']);
     }
     if ($user_moneys['free_money'] != $old_user_moneys['free_money']) {
         $change_money = $user_moneys['free_money'] - $old_user_moneys['free_money'];
         if ($change_money < 0) {
             $change_money *= -1;
             $is_in = 1;
         }
         Money_logService::get_instance()->add_log($pid, $user_id, 'FREE_MONEY', $is_in, $change_money, $old_user_moneys['free_money']);
     }
 }
예제 #2
0
파일: user.php 프로젝트: RenzcPHP/3dproduct
 public function user_money($user_id = NULL, $acid = NULL, $log_type = NULL)
 {
     role::check('user_account');
     $return_data = array();
     //初始化默认查询结构体
     $query_struct_default = array('orderby' => array('id' => 'DESC'), 'limit' => array('per_page' => 10, 'page' => 1));
     $return_data['get']['user_id'] = NULL;
     $return_data['get']['acid'] = NULL;
     $return_data['get']['log_type'] = NULL;
     if (!empty($user_id)) {
         $query_struct_default['where']['user_id'] = $user_id;
         $return_data['get']['user_id'] = $user_id;
     }
     if (!empty($acid)) {
         $query_struct_default['where']['account_log_id'] = $acid;
         $return_data['get']['acid'] = $acid;
     }
     if (!empty($log_type)) {
         $query_struct_default['where']['log_type'] = $log_type;
         $return_data['get']['log_type'] = $log_type;
     }
     $request_data = $this->input->get();
     $timebeg = $this->input->get('begintime');
     $timeend = $this->input->get('endtime');
     if (!empty($timebeg)) {
         $query_struct_default['where']['add_time >='] = $timebeg;
     }
     if (!empty($timeend)) {
         $query_struct_default['where']['add_time <='] = $timeend;
     }
     //初始化当前查询结构体
     $query_struct_current = array();
     //设置合并默认查询条件到当前查询结构体
     $query_struct_current = array_merge($query_struct_current, $query_struct_default);
     //列表排序
     $orderby_arr = array(0 => array('id' => 'DESC'), 1 => array('id' => 'ASC'));
     $orderby = controller_tool::orderby($orderby_arr);
     // 排序处理
     if (isset($request_data['orderby']) && is_numeric($request_data['orderby'])) {
         $query_struct_current['orderby'] = $orderby;
     }
     $query_struct_current['orderby'] = $orderby;
     //每页条目数
     controller_tool::request_per_page($query_struct_current, $request_data);
     //调用服务执行查询
     $acobj = Money_logService::get_instance();
     $return_data['count'] = $acobj->count($query_struct_current);
     //统计数量
     $sum_list = $acobj->query_assoc($query_struct_current);
     $return_data['USER_MONEY']['in'] = 0;
     $return_data['USER_MONEY']['out'] = 0;
     $return_data['BONUS_MONEY']['in'] = 0;
     $return_data['BONUS_MONEY']['out'] = 0;
     $return_data['FREE_MONEY']['in'] = 0;
     $return_data['FREE_MONEY']['out'] = 0;
     foreach ($sum_list as $rowsum) {
         if ($rowsum['log_type'] == 'USER_MONEY') {
             if ($rowsum['is_in'] == 1) {
                 $return_data['USER_MONEY']['out'] += $rowsum['price'];
             } else {
                 $return_data['USER_MONEY']['in'] += $rowsum['price'];
             }
         } elseif ($rowsum['log_type'] == 'BONUS_MONEY') {
             if ($rowsum['is_in'] == 1) {
                 $return_data['BONUS_MONEY']['out'] += $rowsum['price'];
             } else {
                 $return_data['BONUS_MONEY']['in'] += $rowsum['price'];
             }
         } elseif ($rowsum['log_type'] == 'FREE_MONEY') {
             if ($rowsum['is_in'] == 1) {
                 $return_data['FREE_MONEY']['out'] += $rowsum['price'];
             } else {
                 $return_data['FREE_MONEY']['in'] += $rowsum['price'];
             }
         }
     }
     /* 调用分页 */
     $this->pagination = new Pagination(array('total_items' => $return_data['count'], 'items_per_page' => $query_struct_current['limit']['per_page']));
     $query_struct_current['limit']['page'] = $this->pagination->current_page;
     $return_data['list'] = $acobj->query_assoc($query_struct_current);
     $money_type = Kohana::config('money_type');
     $i = 0;
     foreach ($return_data['list'] as $rowlist) {
         $return_data['list'][$i] = $rowlist;
         $return_data['list'][$i]['type_name'] = empty($account_type[$rowlist['log_type']]) ? '' : $account_type[$rowlist['log_type']];
         $i++;
     }
     $return_data['user'] = user::get_instance()->get($id);
     /* 用户列表模板 */
     $this->template->content = new View("user/user_money");
     /* 调用列表 */
     $this->template->content->data = $return_data;
     $this->template->content->money_type = $money_type;
 }