public function doEdit()
 {
     $data = $_POST;
     //都 变更后台访问路径,自动生成后台路径的Action 开始  2014-04-04
     $datag = get_global_setting();
     $url = $datag['admin_url'];
     $dir = 'App/Lib/Action/Home/';
     if (is_dir($dir)) {
         $path = $dir . 'SdjufengActionAction.class.php';
         if ($data[100] && $data[100] != $url) {
             unlink($path);
             $url = $data[100];
             $file = fopen($path, 'wb');
         }
         if (isset($file)) {
             $text = "<?php class rongtianxiaAction extends HCommonAction {\n\t\t\t\t\t\tpublic function " . $url . "(){\n\t\t\t\t\t\t\trequire('App/Tpl/Admin/default/Index/login.html');\n\t\t\t\t\t\t}\t\n\t\t\t\t}\n\t\t\t\t?>";
             fwrite($file, $text);
             fclose($file);
         }
     }
     //都 变更后台访问路径,自动生成后台路径的Action 结束  2014-04-04
     foreach ($data as $key => $v) {
         if (is_numeric($key)) {
             M('global')->where("id = '{$key}'")->setField('text', EnHtml($v));
         }
     }
     $this->success('更新成功');
 }
 public function promotion()
 {
     $_P_fee = get_global_setting();
     $this->assign("reward", $_P_fee);
     $data['html'] = $this->fetch();
     exit(json_encode($data));
 }
 public function postdata()
 {
     $this->glob = get_global_setting();
     $user_money = M("member_money")->where("uid = {$this->uid}")->find();
     //判断是否满足免费体验资格
     $quota_map['status'] = array("not in", "1,4");
     $quota_map['uid'] = $this->uid;
     $quata_num = D("shares_apply")->where("(status not in(1,4) AND uid = {$this->uid}) OR (status = 1 AND type_id = 4 AND uid = {$this->uid})")->count();
     //$quata_num = D("shares_apply")->where(" uid = {$this->uid}")->count();
     //dump($quata_num);die;
     if ($quata_num != 0) {
         echo jsonmsg('很抱歉,您不具备免费体验配资资格!', 0);
         exit;
     }
     //当天范围
     $today_start = strtotime(date("Y-m-d 00:00:00", time()));
     $today_end = strtotime(date("Y-m-d 23:59:59", time()));
     $free_map = array();
     $free_map['type_id'] = 4;
     $free_map['status'] = array("in", "1,2,3");
     $free_map['add_time'] = array("between", array($today_start, $today_end));
     $free_num = D("shares_apply")->where($free_map)->count();
     //判断是否满足免费体验名额
     if ($free_num >= $this->glob['free_num']) {
         echo jsonmsg('今日免费体验名额已满,请明天再来!', 0);
         exit;
     }
     //判断用户是否登录
     if (session('u_id') == null) {
         echo jsonmsg('您还没有登录,请先登录!', 2);
         exit;
     }
     //判断是否实名认证
     /*$ids = M('members_status')->getFieldByUid($this->uid,'id_status');
     		if($ids!=1){
     			echo jsonmsg('您还未完成身份验证,请先进行实名认证!',2);exit;
     		}*/
     //判断是否手机认证
     /*$phones = M('members_status')->getFieldByUid($this->uid,'phone_status');
     		if($phones!=1){
     			echo jsonmsg('您还未手机认证,请先进行手机认证!',3);exit;
     		}*/
     $uid = $this->uid;
     $count = getMoneylimit($this->uid);
     $all_money = $count + 1;
     if ($all_money > $user_money['account_money'] + $user_money['back_money']) {
         echo jsonmsg('您的可用余额不足以支付您所有的配资申请费用,请等待审核完成或进行充值!', 4);
         exit;
     }
     //执行添加
     $_POST['uid'] = $this->uid;
     $ret = D("SharesApply")->addFreeStock();
     if ($ret) {
         echo jsonmsg('恭喜配资成功!', 1);
         exit;
     } else {
         echo jsonmsg('恭喜配资失败!', 0);
         exit;
     }
 }
 function _initialize()
 {
     $this->pre = C('DB_PREFIX');
     $query_string = explode("/", $_SERVER['REQUEST_URI']);
     $code = strtolower(MODULE_NAME);
     !isset($this->justlogin) ? $this->justlogin = false : ($this->justlogin = $this->justlogin);
     if (session('admin')) {
         //dump(session('adminname'));exit;
         $this->admin_id = session("admin");
         $this->assign('adminname', session('adminname'));
     } elseif (strtolower(ACTION_NAME) != 'verify' && strtolower(ACTION_NAME) != 'login' && strtolower(ACTION_NAME) != 'logincheck') {
         // 			redirect(__ROOT__."/index.php/admin/index/logincheck?code=".$query_string[2]);
         redirect(__ROOT__ . "/index.php/admin/index/logincheck?code=" . $code);
         exit;
     }
     if (!get_user_acl(session('admin')) && !$this->justlogin) {
         $this->error('对不起,权限不足');
         exit;
     }
     if (method_exists($this, '_MyInit')) {
         $this->_MyInit();
     }
     $datag = get_global_setting();
     $this->glo = $datag;
     //供PHP里面使用
     $this->assign("glo", $datag);
     $bconf = get_bconf_setting();
     $this->gloconf = $bconf;
     //供PHP里面使用
     $this->assign("gloconf", $bconf);
 }
 public function _initialize()
 {
     //赋值UID
     if (session("u_user_name")) {
         $this->uid = session("u_id");
     }
     $this->glob = get_global_setting();
     $this->assign("glo", $this->glob);
 }
Example #6
0
 public function dowithdraw()
 {
     var_dump($_POST);
     die;
     $blackPhone = M('blacklist')->field('telephone')->select();
     foreach ($blackPhone as $v) {
         $blackData[] = $v['telephone'];
     }
     if (in_array($_SESSION['u_user_name'], $blackData)) {
         echo '该账号暂时禁止提现,详情请联系财来网';
         exit;
     }
     $transamt = $_POST['money'];
     //提现金额
     $cashChl = $_POST['cashChl'];
     //提现方式zh&hgq
     $totalinvestor = M("borrow_investor")->where("investor_uid=" . $this->uid)->sum("investor_capital");
     //充值资金池的投资金额
     $borrow_cap = M("borrow_info")->where("borrow_uid=" . $this->uid)->sum("borrow_money");
     //累计借款金额
     $totalpay = M("member_paylog")->where("uid=" . $this->uid)->sum("transamt");
     //累计充值金额
     $totalwithdraw = M("member_withdrawlog")->where("uid=" . $this->uid)->sum("transamt");
     $account = M("member_money")->field("account_money,back_money")->where("uid=" . $this->uid)->find();
     $accountmoney = $account['account_money'] + $account['back_money'];
     //充值资金池可用余额+回款资金池可用余额
     if ($transamt > $accountmoney) {
         echo "余额不足,不允许提现!";
         exit;
     } else {
         if ($totalinvestor + $borrow_cap < $totalwithdraw) {
             $datag = get_global_setting();
             $fee_tqtx = $datag['fee_tqtx'];
             $feerate = explode('|', $fee_tqtx);
             $fee = $transamt * $feerate[0] / 100;
         } else {
             $datag = get_global_setting();
             $fee_tqtx = $datag['fee_tqtx'];
             $feerate = explode('|', $fee_tqtx);
             $cae = $totalinvestor + $borrow_cap - $totalwithdraw;
             if ($cae >= $transamt) {
                 $fee = $transamt * $feerate[1] / 100;
             } else {
                 $fee = ($cae * $feerate[1] + ($transamt - $cae) * $feerate[0]) / 100;
             }
         }
     }
     //echo $fee;exit;
     $info = M("members")->field("usrid")->where("id=" . $this->uid)->find();
     $usrid = intval($info['usrid']);
     import("ORG.Huifu.Huifu");
     $huifu = new Huifu();
     $huifu->cash($usrid, $transamt, $fee, $cashChl);
     //增加$cashChl参数zh&hgq
 }
Example #7
0
 public function promotion()
 {
     $_P_fee = get_global_setting();
     Vendor('Qrcode.phpqrcode');
     //判断是否有二维码 有就不用在二次生成了
     // $icon='http://my.cailai.com/Style/H/images/erwei/qrcodeicon'.$this->uid.'.png';
     $icon = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] . '/Style/H/images/erwei/qrcodeicon' . $this->uid . '.png';
     // dump($icon);
     $is_exists = get_headers($icon);
     //dump($is_exists);
     if ($is_exists[0] != 'HTTP/1.1 200 OK') {
         //设置二维码的内容 查询电话号码
         $res = M('members')->getFieldById($this->uid, 'user_name');
         $value = "http://m.cailai.com/index/register?p=" . $res;
         $pos = 'Style/H/images/erwei/qrcode' . $this->uid . '.png';
         //dump(get_headers($pos));
         $errorCorrectionLevel = 'L';
         //容错级别
         $matrixPointSize = 6;
         //生成图片大小
         //生成二维码图片
         QRcode::png($value, $pos, $errorCorrectionLevel, $matrixPointSize, 2);
         $logo = 'Style/H/img/cutlogo.png';
         //准备好的logo图片
         $QR = $pos;
         //已经生成的原始二维码图
         if ($logo) {
             $QR = imagecreatefromstring(file_get_contents($QR));
             $logo = imagecreatefromstring(file_get_contents($logo));
             $QR_width = imagesx($QR);
             //二维码图片宽度
             $QR_height = imagesy($QR);
             //二维码图片高度
             $logo_width = imagesx($logo);
             //logo图片宽度
             $logo_height = imagesy($logo);
             //logo图片高度
             $logo_qr_width = $QR_width / 5;
             $scale = $logo_width / $logo_qr_width;
             $logo_qr_height = $logo_height / $scale;
             $from_width = ($QR_width - $logo_qr_width) / 2;
             //重新组合图片并调整大小
             imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height);
             //$logo_qr_width, $logo_qr_height,
             //bool imagecopyresampled ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h )
         }
         //输出图片
         $newicon = "Style/H/images/erwei/qrcodeicon" . $this->uid . '.png';
         imagepng($QR, $newicon);
     }
     //exists 结束
     $this->myid = $this->uid;
     $this->assign("reward", $_P_fee);
     $this->display();
 }
Example #8
0
 public function logincheck()
 {
     $code = $_GET["code"];
     $datag = get_global_setting();
     $codecheck = $datag['admin_url'];
     if ($code != $codecheck) {
         $this->assign('jumpUrl', '/');
         $this->error("非法请求");
     } else {
         $this->redirect('login');
     }
 }
 public function promotion()
 {
     //自动生成推广码
     $expand_num = getExpandCode($this->uid);
     $this->assign("expand_num", $expand_num);
     $_P_fee = get_global_setting();
     $this->assign("reward", $_P_fee);
     $active = active_flag(2);
     $this->assign("active", $active);
     $data['html'] = $this->fetch();
     exit(json_encode($data));
 }
 public function cellphone()
 {
     $isid = M('members_status')->getFieldByUid($this->uid, 'phone_status');
     $phone = M('members')->getFieldById($this->uid, 'user_phone');
     $this->assign("phone", $phone);
     $sq = M('member_safequestion')->find($this->uid);
     $this->assign("sq", $sq);
     $this->assign("phone_status", $isid);
     $datag = get_global_setting();
     $is_manual = $datag['is_manual'];
     $this->assign("is_manual", $is_manual);
     $this->display();
 }
 public function doEdit()
 {
     $data = $_POST;
     //都 变更后台访问路径,自动生成后台路径的Action 开始  2014-04-04
     $datag = get_global_setting();
     $url = $datag['admin_url'];
     foreach ($data as $key => $v) {
         if (is_numeric($key)) {
             M('global')->where("id = '{$key}'")->setField('text', EnHtml($v));
         }
     }
     $this->success('更新成功');
 }
Example #12
0
 public function sellhtml()
 {
     $invest_id = isset($_GET['id']) ? intval($_GET['id']) : 0;
     !$invest_id && ajaxmsg(L('parameter_error'), 0);
     $info = $this->Debt->countDebt($invest_id);
     $this->assign('info', $info);
     $datag = get_global_setting();
     $this->assign('debt_fee', $datag['debt_fee']);
     $this->assign('invest_id', $invest_id);
     $borrow = M('borrow_investor i')->join(C('DB_PREFIX') . "borrow_info b ON i.borrow_id = b.id")->field("borrow_name")->where("i.id=" . $invest_id)->find();
     $this->assign("borrow_name", $borrow['borrow_name']);
     $d['content'] = $this->fetch();
     echo json_encode($d);
 }
 function _initialize()
 {
     if (session('u_id')) {
         $this->uid = session('u_id');
         $this->uname = session('u_user_name');
         $this->assign('uname', $this->uname);
         $datag = get_global_setting();
         $this->glo = $datag;
         //供PHP里面使用
         $this->assign("glo", $datag);
         //公共参数
     } else {
         $this->redirect('M/Pub/login');
     }
 }
 function _initialize()
 {
     if (session('u_id')) {
         $this->uid = session('u_id');
         $this->uname = session('u_user_name');
         $this->assign('uname', $this->uname);
         $datag = get_global_setting();
         $this->glo = $datag;
         //供PHP里面使用
         $this->assign("glo", $datag);
         //公共参数
     } else {
         $this->redirect('M/Pub/login');
     }
     $hetong = M('hetong')->field('name,dizhi,tel')->find();
     $this->assign("web", $hetong);
 }
Example #15
0
 function _initialize()
 {
     //友情链接
     $parm['is_show'] = 1;
     $yqList = M('friend')->where($map)->order('link_order')->select();
     $this->assign("yqList", $yqList);
     judgeHttps($this->isAjax());
     $datag = get_global_setting();
     $this->glo = $datag;
     //供PHP里面使用
     $this->assign("glo", $datag);
     //分站
     $this->assign("subsite", getSubSite());
     $this->siteInfo = getLocalhost();
     $this->assign("siteInfo", $this->siteInfo);
     //分站
     if (session("u_user_name")) {
         $this->uid = session("u_id");
         $unread = M("inner_msg")->where("uid={$this->uid} AND status=0")->count('id');
         $this->assign('unread', $unread);
         $this->assign('UID', $this->uid);
     } else {
         $loginconfig = FS("Webconfig/loginconfig");
         $de_val = $this->_authcode(cookie('UKey'), 'DECODE', $loginconfig['cookie']['key']);
         if (substr(md5($loginconfig['cookie']['key'] . $de_val), 14, 10) == cookie('Ukey2')) {
             $vo = M('members')->field("id,user_name")->find($de_val);
             if (is_array($vo)) {
                 foreach ($vo as $key => $v) {
                     session("u_{$key}", $v);
                 }
                 $this->uid = session("u_id");
                 $this->assign('UID', $this->uid);
                 $unread = M("inner_msg")->where("uid={$this->uid} AND status=0")->count('id');
                 $this->assign('unread', $unread);
             } else {
                 cookie("Ukey", NULL);
                 cookie("Ukey2", NULL);
             }
         }
     }
     if (method_exists($this, '_MyInit')) {
         $this->_MyInit();
     }
 }
 function _initialize()
 {
     $datag = get_global_setting();
     $this->glo = $datag;
     //供PHP里面使用
     $this->assign("glo", $datag);
     $bconf = get_bconf_setting();
     $this->gloconf = $bconf;
     //供PHP里面使用
     $this->assign("gloconf", $bconf);
     $hetong = M('hetong')->field('name,dizhi,tel')->find();
     $this->assign("web", $hetong);
     if (session("u_user_name")) {
         $this->uid = session("u_id");
         $unread = M("inner_msg")->where("uid={$this->uid} AND status=0")->count('id');
         $this->assign('unread', $unread);
         $this->assign('UID', $this->uid);
     } else {
         $loginconfig = FS("Webconfig/loginconfig");
         $de_val = $this->_authcode(cookie('UKey'), 'DECODE', $loginconfig['cookie']['key']);
         if (substr(md5($loginconfig['cookie']['key'] . $de_val), 14, 10) == cookie('Ukey2')) {
             $vo = M('members')->field("id,user_name")->find($de_val);
             if (is_array($vo)) {
                 foreach ($vo as $key => $v) {
                     session("u_{$key}", $v);
                 }
                 $this->uid = session("u_id");
                 $this->assign('UID', $this->uid);
                 $unread = M("inner_msg")->where("uid={$this->uid} AND status=0")->count('id');
                 $this->assign('unread', $unread);
             } else {
                 cookie("Ukey", NULL);
                 cookie("Ukey2", NULL);
             }
         }
     }
     if (method_exists($this, '_MyInit')) {
         $this->_MyInit();
     }
 }
Example #17
0
 public function apply()
 {
     $mmdata = M('member_money')->where("uid={$this->uid}")->find();
     $datag = get_global_setting();
     $mmpd = $mmdata['account_money'] + $mmdata['back_money'] - $datag['fee_vip'];
     if ($mmpd < 0) {
         ajaxmsg("您的余额不足,请充值后再申请", 0);
     }
     $kfid = intval($_POST['kfid']);
     $des = text($_POST['des']);
     $savedata['kfid'] = $kfid;
     $savedata['uid'] = $this->uid;
     $savedata['des'] = $des;
     $savedata['add_time'] = time();
     $savedata['status'] = 0;
     $newid = M('vip_apply')->add($savedata);
     if ($newid) {
         ajaxmsg();
     } else {
         ajaxmsg("保存失败,请重试", 0);
     }
 }
Example #18
0
 function _initialize()
 {
     forceHttp();
     $this->pre = C('DB_PREFIX');
     !isset($this->justlogin) ? $this->justlogin = false : ($this->justlogin = $this->justlogin);
     $this->saveRule = date("YmdHis", time()) . rand(0, 1000);
     if (strtolower(MODULE_NAME) == 'index' && (strtolower(ACTION_NAME) == 'login' || strtolower(ACTION_NAME) == 'index' && !session('admin')) && $_SERVER['PATH_INFO'] != '/' . SAFE_ADMIN) {
         echo 'The page can\'t been found';
         header('HTTP/1.0 404 Not Found');
         exit;
     }
     if (session('admin')) {
         $this->admin_id = session("admin_id");
         $this->assign('adminname', session('adminname'));
     } elseif (strtolower(ACTION_NAME) != 'verify' && strtolower(ACTION_NAME) != 'login' && strtolower(ACTION_NAME) != 'getsmscode') {
         if ($_SERVER['PATH_INFO'] != '/' . SAFE_ADMIN) {
             echo 'The page can\'t been found.';
             header('HTTP/1.0 404 Not Found');
         } else {
             redirect(__ROOT__ . '/' . SAFE_ADMIN);
         }
         exit;
     }
     if (!get_user_acl(session('admin')) && !$this->justlogin) {
         $this->error('对不起,权限不足');
         exit;
     }
     if (method_exists($this, '_MyInit')) {
         $this->_MyInit();
     }
     $this->logOpType = C("LOG_OPERATION_TYPE");
     $this->assign("logOpType", $this->logOpType);
     $this->logUserType = C("LOG_USER_TYPE");
     $datag = get_global_setting();
     $this->glo = $datag;
     //供PHP里面使用
     $this->assign("glo", $datag);
 }
 public function promotion()
 {
     $_P_fee = get_global_setting();
     $lilv['lilv'] = $_P_fee['award_invest'];
     ajaxmsg($lilv);
 }
Example #20
0
function getDefaultSeoInfo($content, $type)
{
    $ret = $content;
    switch ($type) {
        case 1:
            //keyword
            if (empty($ret)) {
                $datag = get_global_setting();
                $ret = $datag["web_keywords"];
            }
            break;
        case 2:
            //description
            if (empty($ret)) {
                $datag = get_global_setting();
                $ret = $datag["web_descript"];
            }
            break;
    }
    return $ret;
}
Example #21
0
 public function tuiguang()
 {
     $_P_fee = get_global_setting();
     $this->assign("reward", $_P_fee);
     $field = " m.id,m.user_name,sum(ml.affect_money) jiangli ";
     $list = M("members m")->field($field)->join(" lzh_member_moneylog ml ON m.id = ml.target_uid ")->where("ml.type=13")->group("ml.uid")->order('jiangli desc')->limit(10)->select();
     $this->assign("list", $list);
     $this->display();
 }
Example #22
0
 public function register4()
 {
     session("code_temp", NULL);
     session("send_time", NULL);
     session("temp_phone", NULL);
     session("name_temp", NULL);
     session("pwd_temp", NULL);
     $minfo = getMinfo($this->uid, true);
     $this->assign("uname", $minfo['user_name']);
     $global = get_global_setting();
     $this->assign("reward", $global['reg_reward']);
     $this->display();
 }
 public function contract()
 {
     $datag = get_global_setting();
     $this->assign("glo", $datag);
     $this->display();
 }
Example #24
0
 protected function _initialize()
 {
     $loginconfig = FS("Webconfig/loginconfig");
     //判断快捷登录是否开启
     $this->assign("loginconfig", $loginconfig);
     $datag = get_global_setting();
     $this->glo = $datag;
     //供PHP里面使用
     $this->assign("glo", $datag);
     //公共参数
     $bconf = get_bconf_setting();
     $this->gloconf = $bconf;
     //供PHP里面使用
     $this->assign("gloconf", $bconf);
     if ($this->notneedlogin === true) {
         if (session("u_id")) {
             $this->uid = session("u_id");
             $this->assign('UID', $this->uid);
             $unread = M("inner_msg")->where("uid={$this->uid} AND status=0")->count('id');
             $this->assign('unread', $unread);
             if (!in_array(strtolower(ACTION_NAME), array("actlogout", 'regsuccess', 'emailverify', 'verify', 'corpregister2'))) {
                 redirect(__APP__ . "/member/");
             }
             $res = M("members")->field("usrid,iscorp")->where("id={$this->uid}")->find();
             if (empty($res['usrid']) && $res['iscorp'] == 0) {
                 if (!in_array(strtolower(ACTION_NAME), array("actlogout", "corpregister2", "bind", "corpbind"))) {
                     redirect(__APP__ . "/member/common/register2/");
                 }
             } else {
                 if (empty($res['usrid']) && $res['iscorp'] == 1) {
                     if (!in_array(strtolower(ACTION_NAME), array("actlogout", "corpregister2", "bind", "corpbind"))) {
                         redirect(__APP__ . "/member/common/corpregister2/");
                     }
                 }
             }
         } else {
             $loginconfig = FS("Webconfig/loginconfig");
             $de_val = $this->_authcode(cookie('UKey'), 'DECODE', $loginconfig['cookie']['key']);
             if (substr(md5($loginconfig['cookie']['key'] . $de_val), 14, 10) == cookie('Ukey2')) {
                 $vo = M('members')->field("id,user_name")->find($de_val);
                 if (is_array($vo)) {
                     foreach ($vo as $key => $v) {
                         session("u_{$key}", $v);
                     }
                     $this->uid = session("u_id");
                     $this->assign('UID', $this->uid);
                     $unread = M("inner_msg")->where("uid={$this->uid} AND status=0")->count('id');
                     $this->assign('unread', $unread);
                     if (!in_array(strtolower(ACTION_NAME), array("actlogout", 'regsuccess', 'emailverify', 'verify', 'corpregister2'))) {
                         redirect(__APP__ . "/member/");
                     }
                     $res = M("members")->field("usrid,iscorp")->where("id={$this->uid}")->find();
                     if (empty($res['usrid']) && $res['iscorp'] == 0) {
                         if (!in_array(strtolower(ACTION_NAME), array("actlogout", "corpregister2", "bind", "corpbind"))) {
                             redirect(__APP__ . "/member/common/register2/");
                         }
                     } else {
                         if (empty($res['usrid']) && $res['iscorp'] == 1) {
                             if (!in_array(strtolower(ACTION_NAME), array("actlogout", "corpregister2", "bind", "corpbind"))) {
                                 redirect(__APP__ . "/member/common/corpregister2/");
                             }
                         }
                     }
                 } else {
                     cookie("Ukey", NULL);
                     cookie("Ukey2", NULL);
                 }
             }
         }
     } elseif (session("u_user_name")) {
         $this->uid = session("u_id");
         $unread = M("inner_msg")->where("uid={$this->uid} AND status=0")->count('id');
         $this->assign('unread', $unread);
         $this->assign('UID', $this->uid);
         /*$res = M("members")->field("usrid,iscorp")->where("id={$this->uid}")->find();
         		if(empty($res['usrid']) && $res['iscorp']==0)
         		{
         			if(!in_array(strtolower(ACTION_NAME),array("actlogout","corpregister2","bind","corpbind")))
         			{
         				redirect(__APP__."/member/common/register2/");
         			}
         		}
         		else if(empty($res['usrid']) && $res['iscorp']==1)
         		{
         			if(!in_array(strtolower(ACTION_NAME),array("actlogout","corpregister2","bind","corpbind")))
         			{
         				redirect(__APP__."/member/common/corpregister2/");
         			}
         		}*/
     } else {
         $loginconfig = FS("Webconfig/loginconfig");
         $de_val = $this->_authcode(cookie('UKey'), 'DECODE', $loginconfig['cookie']['key']);
         if (substr(md5($loginconfig['cookie']['key'] . $de_val), 14, 10) == cookie('Ukey2')) {
             $vo = M('members')->field("id,user_name")->find($de_val);
             if (is_array($vo)) {
                 foreach ($vo as $key => $v) {
                     session("u_{$key}", $v);
                 }
                 $this->uid = session("u_id");
                 $this->assign('UID', $this->uid);
                 $unread = M("inner_msg")->where("uid={$this->uid} AND status=0")->count('id');
                 $this->assign('unread', $unread);
                 $res = M("members")->field("usrid,iscorp")->where("id={$this->uid}")->find();
                 if (empty($res['usrid']) && $res['iscorp'] == 0) {
                     if (!in_array(strtolower(ACTION_NAME), array("actlogout", "corpregister2", "bind", "corpbind"))) {
                         redirect(__APP__ . "/member/common/register2/");
                     }
                 } else {
                     if (empty($res['usrid']) && $res['iscorp'] == 1) {
                         if (!in_array(strtolower(ACTION_NAME), array("actlogout", "corpregister2", "bind", "corpbind"))) {
                             redirect(__APP__ . "/member/common/corpregister2/");
                         }
                     }
                 }
             } else {
                 cookie("Ukey", NULL);
                 cookie("Ukey2", NULL);
             }
         } else {
             redirect(__APP__ . "/member/common/login/");
             exit;
         }
     }
     /***检测用户类型**/
     $type = member_type($this->uid);
     if ($type['status'] != 3) {
         $this->is_show_auto = 0;
     } else {
         $this->is_show_auto = 1;
     }
     /*****/
     $hasbind = hasbind($this->uid);
     session("hasbind", $hasbind);
     $this->assign("hasbind", $hasbind);
     if (method_exists($this, '_MyInit')) {
         $this->_MyInit();
     }
 }
Example #25
0
 public function autorepayment()
 {
     $key = $_GET['key'];
     $arg = file_get_contents($this->updir . "config.txt");
     $arga = explode("|", $arg);
     $rate = intval($arga[1]);
     if ($key != $arga[2]) {
         exit("fail|密钥错误");
     }
     $glodata = get_global_setting();
     $pre = C("DB_PREFIX");
     $strOut = "<br/>-----------正在执行企业直投自动还款程序:服务器当前时间" . date("Y-m-d H:i:s", time()) . "---------------<br/>";
     $map = array();
     $map['deadline'] = array("lt", time() + 86400);
     $map['status'] = 7;
     $list = M("transfer_investor_detail")->field("id,invest_id,interest,investor_uid,borrow_uid,borrow_id,capital,interest_fee,sort_order")->where($map)->select();
     if (is_array($list) && !empty($list)) {
         $Updateb = M('transfer_investor_detail');
         $Updateb->startTrans();
         foreach ($list as $v) {
             $accountMoney_borrower = M('member_money')->field('money_freeze,money_collect,account_money,back_money')->find($v['borrow_uid']);
             if ($accountMoney_borrower['account_money'] + $accountMoney_borrower['back_money'] < $v['capital'] + $v['interest']) {
                 return "帐户可用余额不足,本期还款共需" . ($v['capital'] + $v['interest']) . "元,请先充值!";
             }
             //借款者减少
             $datamoney_x['uid'] = $v['borrow_uid'];
             $datamoney_x['type'] = 11;
             $datamoney_x['affect_money'] = -($v['capital'] + $v['interest']);
             if ($datamoney_x['affect_money'] + $accountMoney_borrower['back_money'] < 0) {
                 //如果需要还款的金额大于回款资金池资金总额
                 $datamoney_x['account_money'] = floatval($accountMoney_borrower['account_money'] + $accountMoney_borrower['back_money'] + $datamoney_x['affect_money']);
                 $datamoney_x['back_money'] = 0;
             } else {
                 $datamoney_x['account_money'] = $accountMoney_borrower['account_money'];
                 $datamoney_x['back_money'] = floatval($accountMoney_borrower['back_money']) + $datamoney_x['affect_money'];
                 //回款资金注入回款资金池
             }
             $datamoney_x['collect_money'] = $accountMoney_borrower['money_collect'];
             $datamoney_x['freeze_money'] = $accountMoney_borrower['money_freeze'];
             //会员帐户
             $mmoney_x['money_freeze'] = $datamoney_x['freeze_money'];
             $mmoney_x['money_collect'] = $datamoney_x['collect_money'];
             $mmoney_x['account_money'] = $datamoney_x['account_money'];
             $mmoney_x['back_money'] = $datamoney_x['back_money'];
             //会员帐户
             $datamoney_x['info'] = "对{$v['borrow_id']}号企业直投进行还款";
             $datamoney_x['add_time'] = time();
             $datamoney_x['add_ip'] = get_client_ip();
             $datamoney_x['target_uid'] = 0;
             $datamoney_x['target_uname'] = '@网站管理员@';
             $moneynewid_x = M('member_moneylog')->add($datamoney_x);
             if ($moneynewid_x) {
                 $bxid = M('member_money')->where("uid={$datamoney_x['uid']}")->save($mmoney_x);
             }
             //借款者减少
             $vo = M("transfer_borrow_investor")->field("transfer_month,transfer_num")->where("id={$v['invest_id']}")->find();
             $update_investor = array();
             $update_investor['id'] = $v['invest_id'];
             $update_investor['status'] = 2;
             //还款完成
             $update_investor['receive_capital'] = array("exp", "`receive_capital`+{$v['capital']}");
             $update_investor['receive_interest'] = array("exp", "`receive_interest`+{$v['interest']}-{$v['interest_fee']}");
             $update_investor['back_time'] = time();
             $investor = M("transfer_borrow_investor")->save($update_investor);
             $update_borrow = array();
             $update_borrow['id'] = $v['borrow_id'];
             $update_borrow['transfer_back'] = array("exp", "`transfer_back`+{$vo['transfer_num']}");
             $update_borrow['borrow_status'] = 7;
             //还款完成
             $summary = M("transfer_borrow_info")->save($update_borrow);
             $mapdetail['id'] = $v['id'];
             $updetail['status'] = 1;
             //还款完成
             $updetail['receive_capital'] = array("exp", "`receive_capital`+{$v['capital']}");
             $updetail['receive_interest'] = array("exp", "`receive_interest`+{$v['interest']}-{$v['interest_fee']}");
             $updetail['repayment_time'] = time();
             $detail = M("transfer_investor_detail")->where($mapdetail)->save($updetail);
             //$strOut .= "成功还款第{$v['borrow_id']}号企业直投<br/>";
             ////////////////////////////////////////////////////对投资帐户进行增加  开始//////////////////////////////////////////////////
             if ($investor && $summary && $detail) {
                 $accountMoney = M('member_money')->field('money_freeze,money_collect,account_money,back_money')->find($v['investor_uid']);
                 $datamoney['uid'] = $v['investor_uid'];
                 $datamoney['type'] = "44";
                 $datamoney['affect_money'] = $v['capital'] + $v['interest'] - $v['interest_fee'];
                 //收利息加本金,并且扣管理费
                 $datamoney['account_money'] = $accountMoney['account_money'];
                 $datamoney['back_money'] = $accountMoney['back_money'] + $datamoney['affect_money'];
                 $datamoney['collect_money'] = $accountMoney['money_collect'] - $datamoney['affect_money'];
                 $datamoney['freeze_money'] = $accountMoney['money_freeze'];
                 //会员帐户
                 $mmoney['money_freeze'] = $datamoney['freeze_money'];
                 $mmoney['money_collect'] = $datamoney['collect_money'];
                 $mmoney['account_money'] = $datamoney['account_money'];
                 $mmoney['back_money'] = $datamoney['back_money'];
                 //会员帐户
                 $datamoney['info'] = "收到借款人对{$v['borrow_id']}号企业直投的还款";
                 $datamoney['add_time'] = time();
                 $datamoney['add_ip'] = get_client_ip();
                 $b_member = M('members')->field("user_name")->find($v['borrow_uid']);
                 $datamoney['target_uid'] = $v['borrow_uid'];
                 $datamoney['target_uname'] = $b_member['user_name'];
                 $moneynewid = M('member_moneylog')->add($datamoney);
                 if ($moneynewid) {
                     $xid = M('member_money')->where("uid={$datamoney['uid']}")->save($mmoney);
                 }
             }
             ////////////////////////////////////////////////////对投资帐户进行增加 结束//////////////////////////////////////////////////
         }
         if ($investor && $summary && $detail && $moneynewid && $xid) {
             $Updateb->commit();
             $strOut .= "成功还款第{$v['borrow_id']}号企业直投<br/>";
         } else {
             $strOut .= "第{$v['borrow_id']}号企业直投还款失败<br/>";
             $Updateb->rollback();
         }
     }
     $data = $strOut . "\r\n" . date("Y-m-d H:i:s", time());
     //服务器时间
     echo $data;
 }
Example #26
0
 public function doEdit()
 {
     // echo $_POST[deal_info];
     // echo "<br/>";
     $model = D(ucfirst($this->getActionName()));
     if (false === $model->create()) {
         $this->error($model->getError());
     }
     //保存当前数据对象
     if ($result = $model->save()) {
         //保存成功
         if ($_POST['status'] == 1) {
             $vx = M('vip_apply')->field("uid,kfid,deal_info")->find(intval($_POST['id']));
             $uid = $vx['uid'];
             $dealInfo = $vx['deal_info'];
             $datag = get_global_setting();
             $aUser = get_admin_name();
             $newx = memberMoneyLog($uid, 14, -$datag['fee_vip'], "升级VIP成功");
             memberLimitLog($uid, 11, $this->glo['limit_vip'], "VIP审核通过");
             memberCreditsLog($uid, 9, intval($this->glo["vip_exp"]), "VIP审核通过经验奖励");
             memberScoresLog($uid, 9, intval($this->glo["vip_score"]), "VIP审核通过积分奖励");
             addInnerMsg($uid, "您的VIP申请审核已通过", "您的VIP申请审核已通过.");
             $vo = M("members")->field("user_phone,user_name,account_money,recommend_id")->where("id = {$uid}")->find();
             SMStip("vip", $vo['user_phone'], array("#USERANEM#"), array($vo['user_name']), null, array($uid));
             if ($newx) {
                 $xmoney = M('members')->getFieldById($vo['recommend_id'], 'reward_money');
                 memberMoneyLog($vo['recommend_id'], 13, $datag['reward_vip_money'], $vo['user_name'] . "获得被邀请会员VIP升级奖励");
                 $vmo = M('members')->field("user_leve,time_limit,delicated_customer")->find($vx['uid']);
                 $savex['customer_id'] = $vx['kfid'];
                 $savex['customer_name'] = $aUser[$vx['kfid']];
                 $savex['user_leve'] = 1;
                 if (empty($vmo["delicated_customer"])) {
                     $savex['delicated_customer'] = $vx['kfid'];
                 }
                 if ($vmo['time_limit'] > time()) {
                     $savex['time_limit'] = strtotime("+1 year", $vmo['time_limit']);
                 } else {
                     $savex['time_limit'] = strtotime("+1 year");
                 }
                 M('members')->where("id={$uid}")->save($savex);
             }
         } else {
             $vx = M('vip_apply')->field("uid,kfid,deal_info")->find(intval($_POST['id']));
             $uid = $vx['uid'];
             $dealInfo = $vx['deal_info'];
             addInnerMsg($uid, "您的VIP申请审核未通过", "未通过原因:" . $dealInfo);
         }
         //成功提示
         $this->assign('jumpUrl', __URL__ . "/" . session('listaction'));
         $this->success(L('修改成功'));
     } else {
         //失败提示
         $this->error(L('修改失败'));
     }
 }
Example #27
0
 public function tool($id, $amount, $type)
 {
     //$jsoncode = file_get_contents("php://input");
     // $arr = array();
     // $arr = json_decode($jsoncode,true);
     // if (!is_array($arr)||empty($arr)||empty($arr['id'])||empty($arr['amount'])||empty($arr['type'])) {
     //    ajaxmsg("查询错误!",0);
     // }
     $arr['id'] = $id;
     $arr['amount'] = $amount;
     $arr['type'] = $type;
     $pre = C('DB_PREFIX');
     if ($arr['type'] == 2) {
         $borrowinfo = M("transfer_borrow_info b")->join("{$pre}transfer_detail d ON d.borrow_id=b.id")->field(true)->find($arr['id']);
         $date_limit = intval($borrowinfo['borrow_duration']);
         //投资期限
         $rate = floatval($borrowinfo['borrow_interest_rate']);
         //投资利率
         $reward_rate = floatval($borrowinfo['reward_rate']);
         //借款奖励
         $datag = get_global_setting();
         $date_type = 1;
         //投资类型:1:月;2:日
         $repayment_type = intval($borrowinfo['repayment_type']);
         $data['bank'] = $arr['amount'] * 0.35 * $borrowinfo['borrow_duration'] / 12 / 100;
         //$data['allbank']=$borrowinfo['borrow_money']*0.35*$borrowinfo['borrow_duration']/12/100;
         $data['fund'] = $arr['amount'] * 4.5 * $borrowinfo['borrow_duration'] / 12 / 100;
         //$data['allfund']=$borrowinfo['borrow_money']*4.5*$borrowinfo['borrow_duration']/12/100;
         // var_dump($borrowinfo);die();
     } else {
         $m = M("borrow_info bi");
         $borrowinfo = $m->field('bi.id as bid,bi.*,ac.title,ac.id')->join('lzh_article ac on ac.id= bi.danbao')->where('bi.id=' . $arr['id'])->find();
         $date_limit = intval($borrowinfo['borrow_duration']);
         //投资期限
         $rate = floatval($borrowinfo['borrow_interest_rate']);
         //投资利率
         $reward_rate = floatval($borrowinfo['reward_num']);
         //借款奖励
         $datag = get_global_setting();
         $date_type = intval($borrowinfo['repayment_type']) == 1 ? 2 : 1;
         //投资类型:1:月;2:日
         $repayment_type = intval($borrowinfo['repayment_type']);
         if ($date_type == 1) {
             $data['bank'] = $arr['amount'] * 0.35 * $borrowinfo['borrow_duration'] / 12 / 100;
             $data['fund'] = $arr['amount'] * 4.5 * $borrowinfo['borrow_duration'] / 12 / 100;
             // $data['allbank']=$borrowinfo['borrow_money']*0.35*$borrowinfo['borrow_duration']/12/100;
         } else {
             $data['bank'] = $arr['amount'] * 0.35 * $borrowinfo['borrow_duration'] / 365 / 100;
             $data['fund'] = $arr['amount'] * 4.5 * $borrowinfo['borrow_duration'] / 365 / 100;
             // $data['allbank']=$borrowinfo['borrow_money']*0.35*$borrowinfo['borrow_duration']/365/100;
         }
         // $data['allfund']=$borrowinfo['borrow_money']*4.5*$borrowinfo['borrow_duration']/12/100;
     }
     $amount = round(floatval($arr['amount']), 2);
     //投资金额
     $invest_manage = $datag['fee_invest_manage'];
     //利息管理费
     $rate_type = 1;
     if ($repayment_type != 1 && $rate_type == 2) {
         $rate = $rate * 365;
     }
     if ($repayment_type == 1 && $rate_type == 1) {
         $rate = $rate / 365;
     }
     $repay_detail['reward_money'] = round($amount * $reward_rate / 100, 2);
     $repay_detail['invest_money'] = $amount - $repay_detail['reward_money'];
     switch ($repayment_type) {
         case '1':
             //按天到期还款
             $repay_detail['repayment_money'] = round($amount * ($rate * $date_limit * (100 - $invest_manage) / 100 + 100) / 100, 2);
             //echo $repay_detail['repayment_money'];die();
             $repay_detail['interest'] = $repay_detail['repayment_money'] - $amount;
             $repay_detail['day_apr'] = round(($repay_detail['repayment_money'] - $repay_detail['invest_money']) * 100 / ($repay_detail['invest_money'] * $date_limit), 2);
             $repay_detail['year_apr'] = round($repay_detail['day_apr'] * 365, 2);
             $repay_detail['month_apr'] = round($repay_detail['day_apr'] * 365 / 12, 2);
             break;
         case '4':
             //到期还本息
             $repay_detail['repayment_money'] = round($amount + $amount * ($date_limit * $rate / 12 / 100) * (100 - $invest_manage) / 100, 2);
             $repay_detail['interest'] = $repay_detail['repayment_money'] - $amount;
             $repay_detail['month_apr'] = round(($repay_detail['repayment_money'] - $repay_detail['invest_money']) * 100 / ($repay_detail['invest_money'] * $date_limit), 2);
             $repay_detail['year_apr'] = round($repay_detail['month_apr'] * 12, 2);
             $repay_detail['day_apr'] = round($repay_detail['month_apr'] * 12 / 365, 2);
             break;
         case '3':
             //每月还息到期还本
             $repay_detail['repayment_money'] = round($amount * ($rate * $date_limit * (100 - $invest_manage) / 100 / 12 + 100) / 100, 2);
             $repay_detail['interest'] = $repay_detail['repayment_money'] - $amount;
             $repay_detail['month_apr'] = round(($repay_detail['repayment_money'] - $repay_detail['invest_money']) * 100 / ($repay_detail['invest_money'] * $date_limit), 2);
             $repay_detail['year_apr'] = round($repay_detail['month_apr'] * 12, 2);
             $repay_detail['day_apr'] = round($repay_detail['month_apr'] * 12 / 365, 2);
             $interest = round($amount * $rate * (100 - $invest_manage) / 100 / 12 / 100, 2);
             //利息等于应还金额乘月利率
             $repay = $repay_detail['repayment_money'];
             for ($i = 0; $i < $date_limit; $i++) {
                 if ($i + 1 == $date_limit) {
                     $capital = $amount;
                     //本金只在最后一个月还,本金等于借款金额除季度
                     $repay = $interest + $capital;
                 } else {
                     $capital = 0;
                     $repay = $repay - $interest;
                 }
                 $_result[$i]['repayment_money'] = $interest + $capital;
                 $_result[$i]['interest'] = $interest;
                 $_result[$i]['capital'] = $capital;
                 $_result[$i]['last_money'] = $repay;
             }
             break;
         case '5':
             //先息后本
             $repay_detail['interest'] = round($amount * ($rate / 12 / 100) * $date_limit * ((100 - $invest_manage) / 100), 2);
             $repay_detail['invest_money'] -= $repay_detail['interest'];
             $repay_detail['repayment_money'] = $amount;
             $repay_detail['month_apr'] = round(($repay_detail['repayment_money'] - $repay_detail['invest_money']) * 100 / ($repay_detail['invest_money'] * $date_limit), 2);
             $repay_detail['year_apr'] = round($repay_detail['month_apr'] * 12, 2);
             $repay_detail['day_apr'] = round($repay_detail['month_apr'] * 12 / 365, 2);
             break;
         case '2':
             //按月分期还款
         //按月分期还款
         default:
             $month_apr = $rate / (12 * 100);
             $_li = pow(1 + $month_apr, $date_limit);
             $repayment = $_li != 1 ? round($amount * ($month_apr * $_li) / ($_li - 1), 2) : round($amount / $date_limit, 2);
             $repay_detail['repayment_money'] = round(($repayment * $date_limit - $amount) * (100 - $invest_manage) / 100 + $amount, 2);
             $repay_detail['interest'] = $repay_detail['repayment_money'] - $amount;
             $repay = $repay_detail['repayment_money'];
             for ($i = 0; $i < $date_limit; $i++) {
                 if ($i == 0) {
                     $interest = round($amount * $month_apr, 2);
                 } else {
                     $_lu = pow(1 + $month_apr, $i);
                     $interest = round(($amount * $month_apr - $repayment) * $_lu + $repayment, 2);
                 }
                 $fee = $interest * $invest_manage / 100;
                 $_result[$i]['repayment_money'] = getFloatValue($repayment - $fee, 2);
                 $_result[$i]['interest'] = getFloatValue($interest - $fee, 2);
                 $_result[$i]['capital'] = getFloatValue($repayment - $interest, 2);
                 if ($i + 1 != $date_limit) {
                     $repay = $repay - $_result[$i]['repayment_money'];
                 } else {
                     $repay = 0;
                 }
                 $_result[$i]['last_money'] = $repay;
             }
             $month_apr2 = ($repay_detail['repayment_money'] - $repay_detail['invest_money']) / ($repay_detail['invest_money'] * $date_limit);
             $rekursiv = 0.001;
             for ($i = 0; $i < 100; $i++) {
                 $_li2 = pow(1 + $month_apr2, $date_limit);
                 $repay = $repay_detail['invest_money'] * $date_limit * ($month_apr2 * $_li2) / ($_li2 - 1);
                 if ($repay < $repay_detail['repayment_money'] * 0.99999) {
                     $month_apr2 += $rekursiv;
                 } elseif ($repay > $repay_detail['repayment_money'] * 1.00001) {
                     $month_apr2 -= $rekursiv * 0.9;
                     $rekursiv *= 0.1;
                 } else {
                     break;
                 }
             }
             $repay_detail['month_apr'] = round($month_apr2 * 100, 2);
             $repay_detail['year_apr'] = round($repay_detail['month_apr'] * 12, 2);
             $repay_detail['day_apr'] = round($repay_detail['month_apr'] * 12 / 365, 2);
             break;
     }
     $repay_detail['total_interest'] = round($repay_detail['repayment_money'] - $repay_detail['invest_money'], 2);
     // $this->assign('repayment_type',$repayment_type);
     // $this->assign('month',$date_limit);
     // $this->assign('repay_list',$_result);
     // $this->assign('repay_detail',$repay_detail);
     $data['reward_rate'] = $repay_detail['total_interest'];
     //	$data['allreward_rate']=$repay_detail['total_interest'];
     // var_dump($repay_detail);die();
     return $data;
     //ajaxmsg($data);
     // var_dump($repay_detail);die();
     // $data['html'] = $this->fetch('tool2_res');
     // exit(json_encode($data));
 }
 /**
  * 检测平台是否开启短信接口并设置短信落款
  * @return string 短信落款
  */
 private function _check_sms()
 {
     $sms_config = FS("Webconfig/msgconfig");
     if (empty($sms_config['sms']) || $sms_config['sms']['type'] == 3) {
         $this->ajaxReturn('', '您未开启短信接口,不能发送短信', 0);
     }
     $global = get_global_setting();
     $sign = trim($global['system_signature']);
     if (empty($sign)) {
         $this->ajaxReturn('', '请在全局设置中添加短信落款配置项【system_signature】', 0);
     }
     return $sign;
 }
Example #29
0
 public function autorepayment()
 {
     header("Content-Type: text/html; charset=UTF-8");
     $key = trim($_GET['key']);
     $arg = file_get_contents($this->updir . "configsulwan.txt");
     if ($key != $arg) {
         exit("fail|密钥错误");
     }
     $glodata = get_global_setting();
     $pre = C("DB_PREFIX");
     $strOut = "<br/>-----------正在执行省心宝自动还款程序:服务器当前时间" . date("Y-m-d H:i:s", time()) . "---------------<br/>";
     $map = array();
     $map['deadline'] = array("lt", time() + 86400);
     $map['status'] = 7;
     $list = M("transfer_investor_detail")->field("id,invest_id,interest,investor_uid,borrow_uid,borrow_id,capital,interest_fee,sort_order,total")->where($map)->select();
     $strOut .= "<table  width='100%'><tr style='background-color:#f2f4f6;text-align:center;'><td style='border-bottom:1px solid #e3e6eb;' height='35'>省心宝自动还款状态</td></tr>";
     if (is_array($list) && !empty($list)) {
         $of = fopen("./out/auto-" . date("Y-m-d-H-i-s", time()) . ".txt", 'w');
         $moneynewid_x_temp = true;
         $bxid_temp = true;
         $investor_temp = true;
         $summary_temp = true;
         $detail_temp = true;
         $moneynewid_temp = true;
         $xid_temp = true;
         fwrite($of, "\nlist=\n");
         fwrite($of, var_export($list, true));
         foreach ($list as $v) {
             $Updateb = M('transfer_investor_detail');
             $Updateb->startTrans();
             $datamoney_x = array();
             $mmoney_x = array();
             $updetail = array();
             $datamoney = array();
             $mmoney = array();
             $accountMoney_borrower = M('member_money')->field('money_freeze,money_collect,account_money,back_money')->find($v['borrow_uid']);
             /*				if (($accountMoney_borrower['account_money'] + $accountMoney_borrower['back_money']) < ($v['capital'] + $v['interest'])) {
             					return "帐户可用余额不足,本期还款共需" . ($v['capital'] + $v['interest']) . "元,请先充值!";
             				} */
             // 借款者减少
             $datamoney_x['uid'] = $v['borrow_uid'];
             $datamoney_x['type'] = 11;
             $datamoney_x['affect_money'] = -($v['capital'] + $v['interest']);
             if ($datamoney_x['affect_money'] + $accountMoney_borrower['back_money'] < 0) {
                 // 如果需要还款的金额大于回款资金池资金总额
                 $datamoney_x['account_money'] = floatval($accountMoney_borrower['account_money'] + $accountMoney_borrower['back_money'] + $datamoney_x['affect_money']);
                 $datamoney_x['back_money'] = 0;
             } else {
                 $datamoney_x['account_money'] = $accountMoney_borrower['account_money'];
                 $datamoney_x['back_money'] = floatval($accountMoney_borrower['back_money']) + $datamoney_x['affect_money'];
                 //回款资金注入回款资金池
             }
             $datamoney_x['collect_money'] = $accountMoney_borrower['money_collect'];
             $datamoney_x['freeze_money'] = $accountMoney_borrower['money_freeze'];
             // 会员帐户
             $mmoney_x['money_freeze'] = $datamoney_x['freeze_money'];
             $mmoney_x['money_collect'] = $datamoney_x['collect_money'];
             $mmoney_x['account_money'] = $datamoney_x['account_money'];
             $mmoney_x['back_money'] = $datamoney_x['back_money'];
             // 会员帐户
             $datamoney_x['info'] = "对{$v['borrow_id']}号省心宝进行还款";
             $datamoney_x['add_time'] = time();
             $datamoney_x['add_ip'] = get_client_ip();
             $datamoney_x['target_uid'] = $v['investor_uid'];
             //$datamoney_x['target_uname'] = '@网站管理员@';
             $moneynewid_x = M('member_moneylog')->add($datamoney_x);
             if ($moneynewid_x) {
                 $bxid = M('member_money')->where("uid={$datamoney_x['uid']}")->save($mmoney_x);
             }
             // 借款者减少
             $vo = M("transfer_borrow_investor")->field("transfer_month,transfer_num")->where("id={$v['invest_id']}")->find();
             $update_investor = array();
             $update_investor['id'] = $v['invest_id'];
             if ($v['sort_order'] == $v['total']) {
                 $update_investor['status'] = 2;
                 //还款完成
             }
             $update_investor['receive_capital'] = array("exp", "`receive_capital`+{$v['capital']}");
             $update_investor['receive_interest'] = array("exp", "`receive_interest`+{$v['interest']}-{$v['interest_fee']}");
             $update_investor['back_time'] = time();
             $investor = M("transfer_borrow_investor")->save($update_investor);
             if ($v['sort_order'] == $v['total']) {
                 $update_borrow = array();
                 $update_borrow['id'] = $v['borrow_id'];
                 $update_borrow['transfer_back'] = array("exp", "`transfer_back`+{$vo['transfer_num']}");
                 $update_borrow['borrow_status'] = 7;
                 //还款完成
                 $summary = M("transfer_borrow_info")->save($update_borrow);
             } else {
                 $summary = true;
             }
             $mapdetail['id'] = $v['id'];
             $updetail['status'] = 1;
             //还款完成
             $updetail['receive_capital'] = array("exp", "`receive_capital`+{$v['capital']}");
             $updetail['receive_interest'] = array("exp", "`receive_interest`+{$v['interest']}-{$v['interest_fee']}");
             $updetail['repayment_time'] = time();
             $detail = M("transfer_investor_detail")->where($mapdetail)->save($updetail);
             // $strOut .= "成功还款第{$v['borrow_id']}号省心宝<br/>";
             // //////////////////////////////////////////////////对投资帐户进行增加  开始//////////////////////////////////////////////////
             if ($investor && $summary && $detail) {
                 $accountMoney = M('member_money')->field('money_freeze,money_collect,account_money,back_money')->find($v['investor_uid']);
                 $datamoney['uid'] = $v['investor_uid'];
                 $datamoney['type'] = "44";
                 $datamoney['affect_money'] = $v['capital'] + $v['interest'] - $v['interest_fee'];
                 //收利息加本金,并且扣管理费
                 $datamoney['account_money'] = $accountMoney['account_money'];
                 $datamoney['back_money'] = $accountMoney['back_money'] + $datamoney['affect_money'];
                 $datamoney['collect_money'] = $accountMoney['money_collect'] - $datamoney['affect_money'];
                 $datamoney['freeze_money'] = $accountMoney['money_freeze'];
                 // 会员帐户
                 $mmoney['money_freeze'] = $datamoney['freeze_money'];
                 $mmoney['money_collect'] = $datamoney['collect_money'];
                 $mmoney['account_money'] = $datamoney['account_money'];
                 $mmoney['back_money'] = $datamoney['back_money'];
                 // 会员帐户
                 $datamoney['info'] = "收到借款人对{$v['borrow_id']}号省心宝的还款";
                 $datamoney['add_time'] = time();
                 $datamoney['add_ip'] = get_client_ip();
                 $datamoney['target_uid'] = $v['borrow_uid'];
                 $minfob = M('members')->where("id={$v['borrow_uid']}")->find();
                 $datamoney['target_uname'] = $minfob['user_name'];
                 $moneynewid = M('member_moneylog')->add($datamoney);
                 if ($moneynewid) {
                     $xid = M('member_money')->where("uid={$datamoney['uid']}")->save($mmoney);
                 }
             }
             $moneynewid_x_temp = $moneynewid_x_temp && $moneynewid_x;
             $bxid_temp = $bxid_temp && $bxid;
             $investor_temp = $investor_temp && $investor;
             $summary_temp = $summary_temp && $summary;
             $detail_temp = $detail_temp && $detail;
             $moneynewid_temp = $moneynewid_temp && $moneynewid;
             $xid_temp = $xid_temp && $xid;
             /////
             fwrite($of, "\nborrow_id=" . $v['borrow_id']);
             fwrite($of, "\ndetail_id=" . $v['id']);
             fwrite($of, "\nborrow_uid=" . $v['borrow_uid']);
             fwrite($of, "\ninvestor_uid=" . $v['investor_uid']);
             fwrite($of, "\ndatamoney_x=\n");
             fwrite($of, var_export($datamoney_x, true));
             fwrite($of, "\nmmoney_x=\n");
             fwrite($of, var_export($mmoney_x, true));
             fwrite($of, "\nupdate_investor=\n");
             fwrite($of, var_export($update_investor, true));
             fwrite($of, "\nupdate_borrow=\n");
             fwrite($of, var_export($update_borrow, true));
             fwrite($of, "\nupdetail=\n");
             fwrite($of, var_export($updetail, true));
             fwrite($of, "\nupdate_borrow=\n");
             fwrite($of, var_export($update_borrow, true));
             fwrite($of, "\ndatamoney=\n");
             fwrite($of, var_export($datamoney, true));
             fwrite($of, "\nmmoney=\n");
             fwrite($of, var_export($mmoney, true));
             fwrite($of, "\nmoneynewid_x=" . $moneynewid_x);
             fwrite($of, "\nbxid=" . $bxid);
             fwrite($of, "\ninvestor=" . $investor);
             fwrite($of, "\nsummary=" . $summary);
             fwrite($of, "\ndetail=" . $detail);
             fwrite($of, "\nmoneynewid=" . $moneynewid);
             fwrite($of, "\nxid=" . $xid);
             fwrite($of, "\n\n");
             if ($moneynewid_x && $bxid && $investor && $summary && $detail && $moneynewid && $xid) {
                 $Updateb->commit();
                 $strOut .= "<tr><td style='border-bottom: 1px solid #e3e6eb;' height='30'>成功还款第{$v['borrow_id']}号省心宝</td></tr>";
             } else {
                 $strOut .= "<tr><td style='border-bottom: 1px solid #e3e6eb;' height='30' width='299'>第{$v['borrow_id']}号省心宝还款失败</td></tr>";
                 $Updateb->rollback();
             }
             // //////////////////////////////////////////////////对投资帐户进行增加 结束//////////////////////////////////////////////////
         }
         fwrite($of, "\nmoneynewid_x_temp=" . $moneynewid_x_temp);
         fwrite($of, "\nbxid_temp=" . $bxid_temp);
         fwrite($of, "\ninvestor_temp=" . $investor_temp);
         fwrite($of, "\nsummary_temp=" . $summary_temp);
         fwrite($of, "\ndetail_temp=" . $detail_temp);
         fwrite($of, "\nmoneynewid_temp=" . $moneynewid_temp);
         fwrite($of, "\nxid_temp=" . $xid_temp);
         fclose($of);
         /*			if ($moneynewid_x_temp && $bxid_temp && $investor_temp && $summary_temp && $detail_temp && $moneynewid_temp && $xid_temp) {
         				$Updateb -> commit();
         				$strOut .= "成功还款第{$v['borrow_id']}号省心宝<br/>";
         			} else {
         				$strOut .= "第{$v['borrow_id']}号省心宝还款失败<br/>";
         				$Updateb -> rollback();
         			} */
     }
     $strOut .= "</table>";
     $data = $strOut;
     //服务器时间
     echo $data;
 }
Example #30
0
function getMBreakInvestList($map, $size = 10)
{
    $pre = C('DB_PREFIX');
    if ($size) {
        //分页处理
        import("ORG.Util.Page");
        $count = M('investor_detail d')->where($map)->count('d.id');
        $p = new \Org\Util\Page($count, $size);
        $page = $p->show();
        $Lsql = "{$p->firstRow},{$p->listRows}";
        //分页处理
    } else {
        $page = "";
        $Lsql = "{$parm['limit']}";
    }
    $field = "m.user_name as borrow_user,b.borrow_interest_rate,d.borrow_id,b.borrow_name,d.status,d.total,d.borrow_id,d.sort_order,d.interest,d.capital,d.deadline,d.sort_order";
    $list = M('investor_detail d')->field($field)->join("{$pre}borrow_info b ON b.id=d.borrow_id")->join("{$pre}members m ON m.id=b.borrow_uid")->where($map)->limit($Lsql)->select();
    $status_arr = array('还未还', '已还完', '已提前还款', '逾期还款', '网站代还本金');
    $glodata = get_global_setting();
    $expired = explode("|", $glodata['fee_expired']);
    $call_fee = explode("|", $glodata['fee_call']);
    foreach ($list as $key => $v) {
        $list[$key]['status'] = $status_arr[$v['status']];
        $list[$key]['breakday'] = getExpiredDays($v['deadline']);
    }
    $row = array();
    $row['list'] = $list;
    $row['page'] = $page;
    $row['count'] = $count;
    return $row;
}