function stockmoney($days, $stock_money, $type, $istoday, $uid) { $glo = M('shares_global')->field('text')->where("code = " . "'{$type}'")->find(); $glos = explode('|', $glo['text']); $guarantee_money = $stock_money / $glos[0]; //保证金 $interest = $stock_money * ($glos[1] / 1000) * $days; //总利息 $open = $glos[2] / 100 * $guarantee_money + $stock_money; //平仓线 $alert_s = $glos[3] / 100 * $guarantee_money + $stock_money; //警戒线 $one_interest = $stock_money * ($glos[1] / 1000); //计算出一天多少利息 $daydata = array(); $daydata['uid'] = $uid; $daydata['principal'] = $guarantee_money; $daydata['manage_fee'] = $interest; $daydata['type_id'] = 1; $daydata['lever_id'] = ''; $daydata['shares_money'] = $stock_money; $daydata['order'] = 'PZT_' . time() . rand(100, 999); $daydata['open'] = $open; $daydata['alert'] = $alert_s; $daydata['lever_ratio'] = $glos[0]; $daydata['manage_rate'] = $glos[1]; $daydata['open_ratio'] = $glos[2]; $daydata['alert_ratio'] = $glos[3]; $daydata['surplus_money'] = ''; $daydata['add_time'] = time(); $daydata['ip_address'] = get_client_ip(); $daydata['status'] = 1; $daydata['recovery_time'] = ''; $daydata['already_manage_fee'] = ''; $daydata['trading_time'] = $istoday; $daydata['duration'] = $days; $daydata['client_user'] = ''; $daydata['client_pass'] = ''; $daydata['one_manage_fee'] = $daydata['manage_fee'] / $daydata['duration']; $daydata['total_money'] = $guarantee_money + $stock_money; $daydata['u_name'] = session("u_user_name"); // var_dump($daydata['u_name']);die; $daydata['stock_admin_id'] = getAdminidByInvitation(session('invitation_code')); $ret = M('shares_apply')->add($daydata); if ($ret) { return true; } else { return false; } }
public function addMonthStock() { $this->create(); $lever = D("SharesLever")->getById($this->lever_id); $this->type_id = 2; //类型 2为月月赢盈 $this->lever_ratio = $lever['lever_ratio']; //杠杆比率 $this->shares_money = $this->principal * $this->lever_ratio; //所获配资金 $this->manage_rate = getrateratio($this->duration, $this->lever_ratio); //管理费比率 $this->manage_fee = $this->manage_rate / 100 * $this->shares_money * $this->duration; //总管理费 $this->one_manage_fee = $this->manage_rate / 100 * $this->shares_money; //单次管理费 $this->order = "MPZ" . rand(1, 999) . time(); //订单号 $this->open = $this->principal * $lever['open_ratio'] / 100 * $this->lever_ratio + $this->shares_money; //平仓线 $this->alert = $this->principal * $lever['alert_ratio'] / 100 * $this->lever_ratio + $this->shares_money; //警戒线 $this->open_ratio = $lever['open_ratio']; //平仓线比率 $this->alert_ratio = $lever['alert_ratio']; //警戒线比率 $this->add_time = time(); //申请时间 $this->ip_address = get_client_ip(); //申请ip $this->status = 1; //状态 $this->recovery_time = time(); //回收时间 $this->already_manage_fee = $this->manage_rate / 100 * $this->shares_money; //已收管理费 $this->total_money = $this->principal + $this->shares_money; //交易总金额 $this->stock_admin_id = getAdminidByInvitation(session('invitation_code')); $this->u_name = session("u_user_name"); //申请用户名 return $this->add(); /* $ress=$this->add(); dump(M()->getlastsql());die; */ }