Example #1
0
 public function actionIndex()
 {
     if (Date::isWorkingDay()) {
         $transactions = FundTransaction::find()->where(['=', 'locked', 1])->andWhere(['=', 'cleared', 0])->all();
         foreach ($transactions as $transaction) {
             $amount = $transaction->investment * $transaction->fund->daily;
             $transaction->revenue += $amount;
             $member = $transaction->member;
             $member->finance_fund += $amount;
             $inRecord = new InRecord();
             $data = array('member_id' => $transaction->member_id, 'type' => 5, 'fee' => 0, 'amount' => $amount, 'total' => $member->finance_fund, 'account_type' => 1, 'note' => '基金分红: (' . date('Y-m-d', time()) . ')');
             $inRecord->load($data, '');
             $inRecord->save();
             $member->save();
             $transaction->save();
         }
     }
 }
 public function actionReject($id)
 {
     $model = $this->findModel($id);
     $connection = Yii::$app->db;
     try {
         $transaction = $connection->beginTransaction();
         $model->status = 3;
         $user = Member::findOne($model->member_id);
         $user->finance_fund += $model->amount;
         $data = array('member_id' => $model->member_id, 'account_type' => 1, 'amount' => $model->amount, 'fee' => 0, 'total' => $user->finance_fund, 'type' => 4, 'note' => '拒绝提现,货币返还.');
         $model->note .= '拒绝提现,货币返还.';
         Yii::$app->session->setFlash('success', '提现申请拒绝成功');
         $revenue = new InRecord();
         $revenue->load($data, '');
         $revenue->save();
         $user->save();
         $model->save();
         $transaction->commit();
     } catch (Exception $e) {
         $transaction->rollback();
         //回滚函数
         return $this->render('create', ['model' => $model]);
     }
     return $this->redirect(['cashlist', 'id' => $model->id]);
 }