示例#1
0
 /**
  * 更新或添加信息
  *
  * @param  array $data 数据包
  * @return true or false
  */
 public function add($data)
 {
     //d($data);
     empty($data['is_in']) && ($data['is_in'] = 0);
     if (user_money::get_instance()->update_money($data['is_in'], $data['user_id'], $data['price'], $data['log_type'], $data['order_num'], NULL, $data['memo'])) {
         return TRUE;
     } else {
         return FALSE;
     }
 }
示例#2
0
 public function check_status($id = '')
 {
     //权限检查 得到所有可管理站点ID列表
     role::check('user_edit');
     if (!empty($id)) {
         $data['check_status'] = 2;
         if (Myuser::instance($id)->edit_handsel_users($id, $data)) {
             $user = user::get_instance();
             //彩金赠送开始
             $handsel = handsel::get_instance();
             $handsel_info = $handsel->get(1);
             //$data_money = array('free_money' => $handsel_info['total']);
             //$flag = $user->update_user_free_money($id,$data_money);
             //account_log::get_instance()->add($data_log);
             user_money::get_instance()->update_money(0, $id, $handsel_info['total'], 7, date('YmdHis') . rand(0, 99999), 'FREE_MONEY', '赠送彩金');
             //彩金赠送结束
             remind::set(Kohana::lang('o_global.update_success'), request::referrer(), 'success');
         } else {
             remind::set(Kohana::lang('o_global.update_error'), request::referrer(), 'error');
         }
     }
 }
示例#3
0
 /**
  * 充值扣款
  */
 function recharge($id)
 {
     //权限检查 得到所有可管理站点ID列表
     role::check('user_recharge');
     if ($_POST) {
         //标签过滤
         tool::filter_strip_tags($_POST);
         $userobj = user::get_instance();
         $usermoney = $userobj->get_user_money($id);
         $money_type = $_POST['money_type'];
         $money_type_set = Kohana::config('money_type');
         if (array_key_exists($money_type, $money_type_set)) {
             $money_type_name = $money_type_set[$money_type];
             $update_money = $_POST['money'];
             //记录日志
             $data_log = array();
             $data_log['order_num'] = date('YmdHis') . rand(0, 99999);
             $data_log['user_id'] = $id;
             $data_log['log_type'] = 6;
             //参照config acccount_type 设置
             $data_log['is_in'] = 0;
             $data_log['price'] = $_POST['money'];
             $data_log['user_money'] = $usermoney;
             $data_log['memo'] = $_POST['memo'];
             $um = user_money::get_instance()->update_money($data_log['is_in'], $data_log['user_id'], $data_log['price'], $data_log['log_type'], $data_log['order_num'], $money_type, $data_log['memo']);
             //添加日志
             $logs_data = array();
             $logs_data['manager_id'] = $this->manager_id;
             $logs_data['user_log_type'] = 29;
             $logs_data['ip'] = tool::get_long_ip();
             $logs_data['memo'] = "成功为用户{$id}充值{$money_type_name}{$_POST['money']}";
             ulog::instance()->add($logs_data);
             remind::set($money_type_name . '充值成功', request::referrer(), 'success');
         }
     }
     $this->template->content = new View("user/user_recharge");
     $this->template->content->data = Myuser::instance($id)->get();
 }
示例#4
0
 public function get_all_win_money($user_id)
 {
     if (empty($user_id)) {
         return 0;
     }
     //此处需要调用所有的
     $obj = ORM::factory('plans_basic');
     $obj->where('user_id', $user_id)->in('status', array(2, 3, 4, 5));
     $results = $obj->find_all();
     $moneyobj = user_money::get_instance();
     $retmoney = array();
     $retmoney['USER_MONEY'] = 0;
     $retmoney['BONUS_MONEY'] = 0;
     $retmoney['FREE_MONEY'] = 0;
     foreach ($results as $row) {
         $moneys = $moneyobj->get_con_by_order_num($row->order_num);
         if (!empty($moneys)) {
             if (!empty($moneys['USER_MONEY'])) {
                 $retmoney['USER_MONEY'] += $moneys['USER_MONEY'];
             }
             if (!empty($moneys['BONUS_MONEY'])) {
                 $retmoney['BONUS_MONEY'] += $moneys['BONUS_MONEY'];
             }
             if (!empty($moneys['FREE_MONEY'])) {
                 $retmoney['FREE_MONEY'] += $moneys['FREE_MONEY'];
             }
         }
     }
     return $retmoney;
 }
示例#5
0
 /**
  * 发放奖金
  * @param unknown_type $userid
  * @param unknown_type $add_money
  * @param unknown_type $plan_basic_id
  */
 public function bonus_add_money($userid, $add_money, $plan_basic_id)
 {
     $lan = Kohana::config('lan');
     $moneyobj = user_money::get_instance();
     if ($this->on_off() == false) {
         if (in_array($userid, self::$sp_userid) && $add_money > 0) {
             $order_num = date('YmdHis') . rand(0, 99999);
             $moneys['FREE_MONEY'] = $add_money;
             $moneyobj->add_money($userid, $add_money, $moneys, 7, $order_num, $lan['money'][23] . '订单ID:' . $plan_basic_id);
         }
     } else {
         if (!in_array($userid, self::$no_userid) && $add_money > 0) {
             $order_num = date('YmdHis') . rand(0, 99999);
             $moneys['FREE_MONEY'] = $add_money;
             $moneyobj->add_money($userid, $add_money, $moneys, 7, $order_num, $lan['money'][23] . '订单ID:' . $plan_basic_id);
         }
     }
 }
示例#6
0
 public function chk($id)
 {
     if (empty($id)) {
         return false;
     }
     $where = array();
     $where['id'] = $id;
     $rpt = ORM::factory('ag_settle_month', $id);
     if ($rpt->loaded) {
         if ($rpt->flag != 2) {
             return 1;
         } else {
             if ($rpt->agent_type == 2) {
                 return 2;
             }
         }
         $userid = $rpt->user_id;
         $logtypexx = 9;
         $rpt->flag = 3;
         $rpt->date_add = date('Y-m-d H:i:s', time());
         $rpt->save();
         $userobj = user::get_instance();
         $usermoney = $userobj->get_user_money($userid);
         $money_type = 'BONUS_MONEY';
         $money_type_set = Kohana::config('money_type');
         if (array_key_exists($money_type, $money_type_set)) {
             $money_type_name = $money_type_set[$money_type];
             //记录日志
             $data_log = array();
             $data_log['order_num'] = 0;
             $data_log['user_id'] = $userid;
             $data_log['log_type'] = $logtypexx;
             //参照config acccount_type 设置
             $data_log['is_in'] = 0;
             $data_log['price'] = $rpt->bonus;
             $data_log['user_money'] = $usermoney;
             $data_log['memo'] = '月结返利';
             if ($rpt->bonus < 0) {
                 $data_log['price'] = $rpt->bonus * -1;
                 $data_log['is_in'] = 1;
                 if ($rpt->taxflag == 90) {
                     $data_log['memo'] = '月结扣税';
                 } else {
                     $data_log['memo'] = '其他';
                 }
             }
             $user_money = user_money::get_instance();
             $um = $user_money->update_money($data_log['is_in'], $data_log['user_id'], $data_log['price'], $data_log['log_type'], $data_log['order_num'], $money_type, $data_log['memo']);
             if (!$um) {
                 $rpt->flag = 91;
                 $rpt->date_add = date('Y-m-d H:i:s', time());
                 $rpt->save();
                 return 4;
             } else {
                 //添加日志
                 $logs_data = array();
                 $logs_data['manager_id'] = 0;
                 // $this->manager_id;
                 $logs_data['user_log_type'] = 29;
                 $logs_data['ip'] = tool::get_long_ip();
                 $logs_data['memo'] = "成功为代理商{$id}返利{$money_type_name}{$rpt->bonus}";
                 ulog::instance()->add($logs_data);
                 //					remind::set($money_type_name.'返利成功',request::referrer(),'success');
                 $rpt->flag = 4;
                 $rpt->date_add = date('Y-m-d H:i:s', time());
                 $rpt->save();
             }
         }
     } else {
         return 3;
     }
 }