Exemplo n.º 1
0
 public function actionIndex()
 {
     $betime = strtotime(date('Y-m-d' . ' 00:00:00', time()));
     $endtime = strtotime(date('Y-m-d' . ' 23:59:59', time()));
     $order = Order::find()->andWhere(['between', 'start_at', $betime, $endtime])->asArray()->count();
     $payment = SinaDeposit::find()->andWhere(['status' => SinaDeposit::STATUS_SUCCESS])->andWhere(['between', 'create_at', $betime, $endtime])->asArray()->count();
     $withdraw = SinaWithdraw::find()->andWhere(['status' => SinaWithdraw::STATUS_SINA_SUCCESS])->andWhere(['between', 'create_at', $betime, $endtime])->asArray()->count();
     $product = Thirdproduct::find()->andWhere(['status' => Thirdproduct::STATUS_ACTIVE])->andWhere(['intent' => Thirdproduct::INTENT_CHECK])->andWhere(['create_user_id' => Yii::$app->user->identity->getId()])->asArray()->all();
     $user = UcenterMember::find()->andWhere(['between', 'created_at', $betime, $endtime])->asArray()->count();
     $log = TradeLog::find()->orderBy('t_date desc');
     $pages = new Pagination(['totalCount' => $log->count(), 'pageSize' => '10']);
     $log = $log->offset($pages->offset)->limit($pages->limit)->all();
     AloneMethod::trade_log();
     $cur_recharge = TradeLog::find()->sum('t_recharge');
     $cur_invest = TradeLog::find()->sum('t_invest');
     $cur_redeem = TradeLog::find()->sum('t_redeem');
     $cur_withdraw = TradeLog::find()->sum('t_withdraw');
     $cur_profit = TradeLog::find()->sum('t_profit');
     $cur_glod = TradeLog::find()->sum('t_gold');
     $cur_red = TradeLog::find()->sum('t_red');
     $ret_msg = '当前总额: 充值【' . $cur_recharge . '】 投资【' . $cur_invest . '】 赎回【' . $cur_redeem . '】 提现【' . $cur_withdraw . '】 在投【' . $cur_profit . '】 体验金收益【' . $cur_glod . '】 红包【' . $cur_red . '】';
     return $this->render('index', ['withdraw' => $withdraw, 'payment' => $payment, 'order' => $order, 'user' => $user, 'product' => $product, 'log' => $log, 'pages' => $pages, 'ret_msg' => $ret_msg]);
 }
Exemplo n.º 2
0
 * @time: 2015年7月14日 11:36:26
 * 
 */
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use kartik\file\FileInput;
use dosamigos\datetimepicker\DateTimePicker;
use common\models\fund\FundProductThirdproduct;
use common\models\base\fund\Thirdproduct;
$id = $model->id;
$thirdfundModel = [];
$modelmid = FundProductThirdproduct::find()->where(['product_id' => $id])->asArray()->all();
if ($modelmid) {
    foreach ($modelmid as $v) {
        array_push($thirdfundModel, Thirdproduct::find()->select('id')->where(['id' => $v['thirdproduct_id']])->asArray()->one());
    }
    $newth = [];
    foreach ($thirdfundModel as $k => $v) {
        array_push($newth, $v['id']);
    }
}
/* @var $this yii\web\View */
/* @var $model common\models\base\fund\product */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="product-form">

    <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
Exemplo n.º 3
0
 /**
  * Auther:langxi
  * 根据赎回债权字典进行赎回操作
  * @param $Redeem
  */
 private static function Set_redeem($Redeem)
 {
     foreach ($Redeem as $k => $v) {
         //order表金额赎回
         $order = Order::findOne($v['order_id']);
         $order->money = $order['money'] - $v['thirdmoney'];
         if ($order['money'] == '0') {
             $order->status = Order::STATUS_DELETE;
         }
         $order = $order->save();
         if (!$order) {
             $result = array('errorNum' => '1', 'errorMsg' => '转让债权赎回失败', 'data' => null);
             return $result;
         }
         //thirdorder表金额赎回
         $thirdorder = Thirdorder::findOne($v['thirdorder_id']);
         $thirdorder->money = $thirdorder['money'] - $v['thirdmoney'];
         if ($thirdorder['money'] == '0') {
             $thirdorder->status = Thirdorder::STATUS_DELETED;
         }
         $thirdorder->mcmoney = $thirdorder['mcmoney'] + $v['thirdmoney'];
         //记录最大债权增加
         $thirdorder->ocmoney = $thirdorder['ocmoney'] - $v['thirdmoney'];
         //记录原始债权金额减少
         $thirdorder = $thirdorder->save();
         if (!$thirdorder) {
             $result = array('errorNum' => '1', 'errorMsg' => '第三方转让债权失败', 'data' => null);
             return $result;
         }
         //thirdproduct第三方债权已投金额减少
         $thirdproduct = Thirdproduct::findOne($v['thirdproduct_id']);
         $thirdproduct->invest_sum = $thirdproduct['invest_sum'] - $v['thirdmoney'];
         $thirdproduct->mcmoney = $thirdproduct['mcmoney'] + $v['thirdmoney'];
         //赎回导致最大债权人金额增加
         $thirdproduct = $thirdproduct->save();
         if (!$thirdproduct) {
             $result = array('errorNum' => '1', 'errorMsg' => '赎回第三方债权已投金额失败', 'data' => null);
             return $result;
         }
         //获取债权的最大债权人id,将用户赎回的钱从最大债权人的账户中减去
         $maxcreditor = Thirdproduct::find()->select(['maxcreditor'])->where(['id' => $v['thirdproduct_id']])->asArray()->one();
         $maxcreditor = $maxcreditor['maxcreditor'];
         $is_max = Catmiddle::find()->where(['cid' => '1', 'uid' => $maxcreditor])->asArray()->one();
         if (!$is_max) {
             $result = array('errorNum' => '1', 'errorMsg' => '最大债权人异常', 'data' => null);
             return $result;
         }
         $max_info = Info::findOne($maxcreditor);
         $max_info->balance = $max_info['balance'] - $v['thirdmoney'];
         $max_info = $max_info->save();
         if (!$max_info) {
             $result = array('errorNum' => '1', 'errorMsg' => '消减最大债权人账户金额失败', 'data' => null);
             return $result;
         }
         //写入职员账户记录表中
         $member_id = Order::find()->select(['member_id'])->where(['id' => $v['order_id']])->asArray()->one();
         $member_id = $member_id['member_id'];
         $clerk = new ClerkLog();
         $clerk->member_id = $member_id;
         $clerk->clerk_id = $maxcreditor;
         $clerk->behav = ClerkLog::CLERK_BEHAV_TWO;
         $clerk->step = $v['thirdmoney'];
         $clerk->remark = '最大债权人';
         $clerk = $clerk->save();
         if (!$clerk) {
             throw new ErrorException('写入职员账户记录失败');
         }
     }
     return true;
 }
Exemplo n.º 4
0
 /**
  * Auther:langxi
  *
  * 将投资的金额按照生成的债权数据字典,分散加入债权表
  */
 private static function set_Third($thirdArr, $member_id)
 {
     //债权表中无需写入购买人数,没有意义
     foreach ($thirdArr as $vo) {
         //获取thirdproduct中的原始债权人id,最大债权人id,并检查其是否为公司员工,并判断资金应支付给债权人还是原始债权人,
         $thirdproduct = Thirdproduct::find()->select(['creditor', 'maxcreditor'])->where(['id' => $vo['id']])->asArray()->one();
         if ($vo['ocmoney'] > 0) {
             //将钱支付给原始债权人(网站)
             $creditor = $thirdproduct['creditor'];
             $is_yuan = Catmiddle::find()->where(['cid' => '2', 'uid' => $creditor])->asArray()->one();
             if (!$is_yuan) {
                 $result = array('errorNum' => '1', 'errorMsg' => '原始债权人异常', 'data' => null);
                 return $result;
             }
             $yuan_info = Info::findOne($creditor);
             $yuan_info->balance = $yuan_info['balance'] + $vo['ocmoney'];
             $yuan_info = $yuan_info->save();
             if (!$yuan_info) {
                 $result = array('errorNum' => '1', 'errorMsg' => '资金放入原始债权人账户失败', 'data' => null);
                 return $result;
             }
             //写入职员账户记录表中
             $clerk = new ClerkLog();
             $clerk->member_id = $member_id;
             $clerk->clerk_id = $creditor;
             $clerk->behav = ClerkLog::CLERK_BEHAV_ONE;
             $clerk->step = $vo['ocmoney'];
             $clerk->remark = '原始债权人';
             $clerk = $clerk->save();
             if (!$clerk) {
                 $result = array('errorNum' => '1', 'errorMsg' => '写入职员账户记录失败', 'data' => null);
                 return $result;
             }
         }
         if ($vo['mcmoney'] > 0) {
             //将钱支付给最大债权人(网站)
             $maxcreditor = $thirdproduct['maxcreditor'];
             $is_max = Catmiddle::find()->where(['cid' => '1', 'uid' => $maxcreditor])->asArray()->one();
             if (!$is_max) {
                 $result = array('errorNum' => '1', 'errorMsg' => '最大债权人异常', 'data' => null);
                 return $result;
             }
             $max_info = Info::findOne($maxcreditor);
             $max_info->balance = $max_info['balance'] + $vo['mcmoney'];
             $max_info = $max_info->save();
             if (!$max_info) {
                 $result = array('errorNum' => '1', 'errorMsg' => '资金放入最大债权人账户失败', 'data' => null);
                 return $result;
             }
             //写入职员账户记录表中
             $clerk = new ClerkLog();
             $clerk->member_id = $member_id;
             $clerk->clerk_id = $maxcreditor;
             $clerk->behav = ClerkLog::CLERK_BEHAV_ONE;
             $clerk->step = $vo['mcmoney'];
             $clerk->remark = '最大债权人';
             $clerk = $clerk->save();
             if (!$clerk) {
                 $result = array('errorNum' => '1', 'errorMsg' => '写入职员账户记录失败', 'data' => null);
                 return $result;
             }
         }
         //按用户id和订单时间获取上面生成的订单id值
         $order = Order::find()->where(['member_id' => $member_id])->orderBy('start_at desc')->asArray()->one();
         $thirdorder = new Thirdorder();
         $thirdorder->member_id = $member_id;
         $thirdorder->thirdproduct_id = $vo['id'];
         $thirdorder->order_id = $order['id'];
         $thirdorder->money = $vo['mcmoney'] + $vo['ocmoney'];
         $thirdorder->ocmoney = $vo['ocmoney'];
         $thirdorder->mcmoney = $vo['mcmoney'];
         $thirdorder->start_money = $vo['mcmoney'] + $vo['ocmoney'];
         $thirdorder->status = Thirdorder::STATUS_ACTIVE;
         $thirdorder->start_at = time();
         $thirdorder->end_at = $order['end_at'];
         $thirdorder = $thirdorder->save();
         if (!$thirdorder) {
             $result = array('errorNum' => '1', 'errorMsg' => '债权数据字典写入债权订单表失败', 'data' => null);
             return $result;
         }
         //将资金分配给债权表
         $thirdproduct = Thirdproduct::findOne($vo['id']);
         $thirdproduct->ocmoney = $thirdproduct['ocmoney'] - $vo['ocmoney'];
         $thirdproduct->mcmoney = $thirdproduct['mcmoney'] - $vo['mcmoney'];
         $thirdproduct->invest_sum = $thirdproduct['invest_sum'] + $vo['ocmoney'] + $vo['mcmoney'];
         $thirdproduct = $thirdproduct->save();
         if (!$thirdproduct) {
             $result = array('errorNum' => '1', 'errorMsg' => '资金写入债权表失败', 'data' => null);
             return $result;
         }
     }
     return false;
 }
Exemplo n.º 5
0
 /**
  * Auther:langxi
  *
  * 将再投资的金额按照生成的在投资债权数据字典,分散加入债权表
  */
 private static function reset_Third($thirdArr, $member_id, $order_id)
 {
     //将软删除的订单的金额,从thirdproduct表中的已投金额中减去
     $thirdorder = (new \yii\db\Query())->select(['thirdproduct_id', 'money'])->from('fund_thirdorder')->where(['member_id' => $member_id, 'order_id' => $order_id])->all();
     foreach ($thirdorder as $key => $val) {
         $thirdproduct = Thirdproduct::findOne($val['thirdproduct_id']);
         $thirdproduct->invest_sum = $thirdproduct['invest_sum'] - $val['money'];
         $thirdproduct = $thirdproduct->save();
     }
     //债权表中无需写入购买人数,没有意义
     foreach ($thirdArr as $vo) {
         //将债权数据字典连同订单号写入到thirdorder中
         //按用户id和订单时间获取上面生成的订单id值
         $order = Order::find()->where(['member_id' => $member_id, 'id' => $order_id])->asArray()->one();
         $thirdorder = new Thirdorder();
         $thirdorder->member_id = $member_id;
         $thirdorder->thirdproduct_id = $vo['id'];
         $thirdorder->order_id = $order['id'];
         $thirdorder->money = $vo['t_money'];
         $thirdorder->start_money = $vo['t_money'];
         $thirdorder->status = Thirdorder::STATUS_ACTIVE;
         $thirdorder->start_at = time();
         $thirdorder->end_at = $order['end_at'];
         $thirdorder = $thirdorder->save();
         if (!$thirdorder) {
             throw new ErrorException('债权数据字典写入债权订单表失败', 6002);
         }
         //将资金分配给债权表
         $thirdproduct = Thirdproduct::findOne($vo['id']);
         $thirdproduct->invest_sum = $thirdproduct['invest_sum'] + $vo['t_money'];
         $thirdproduct = $thirdproduct->save();
         if (!$thirdproduct) {
             throw new ErrorException('资金写入债权表失败', 6002);
         }
     }
     return true;
 }
Exemplo n.º 6
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function addsearch($params)
 {
     $user = User::find()->where(['id' => \App::$app->user->identity->getId()])->one();
     if ($user->role == 'admin') {
         $query = Thirdproduct::find()->orderBy('id DESC');
     } else {
         $query = Thirdproduct::find()->andWhere(['create_user_id' => Yii::$app->user->identity->getId()])->orderBy('id DESC');
     }
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $ucmember = new UcenterMember();
     $user = new User();
     $creditor = $ucmember->find()->andWhere(['username' => $this->creditor])->one();
     $maxcreditor = $ucmember->find()->andWhere(['username' => $this->maxcreditor])->one();
     $user = $user->find()->andWhere(['username' => $this->create_user_id])->one();
     $oid = $creditor ? $creditor->id : '';
     $mid = $maxcreditor ? $maxcreditor->id : '';
     $uid = $user ? $user->id : '';
     $query->andFilterWhere(['id' => $this->id, 'amount' => $this->amount, 'start_at' => $this->start_at, 'end_at' => $this->end_at, 'rate' => $this->rate, 'invest_people' => $this->invest_people, 'invest_sum' => $this->invest_sum, 'create_at' => $this->create_at, 'update_at' => $this->update_at, 'status' => $this->status, 'create_user_id' => $uid, 'check_user_id' => $this->check_user_id, 'ocreditor' => $oid, 'maxcreditor' => $mid]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'intro', $this->intro])->andFilterWhere(['like', 'source', $this->source])->andFilterWhere(['like', 'creditor', $this->creditor])->andFilterWhere(['like', 'contract', $this->contract])->andFilterWhere(['like', 'remarks', $this->remarks]);
     return $dataProvider;
 }