Example #1
0
 public function setInterestm(Event $event)
 {
     /** @var InvestList $investList */
     $investList = $event->sender;
     $investListId = $investList->id;
     $step = Utils::moneyFormat($investList->interest / $investList->invest->invest_date);
     $payTime = $investList->pay_time;
     if ($investList->invest->type == Invest::TYPE_MONEY) {
         for ($i = 1; $i <= $investList->invest->invest_date; $i++) {
             wanhunet::$app->db->createCommand()->insert(InvestMonth::tableName(), ['invest_list_id' => $investListId, 'm_step' => $step, 'm_status' => Invest::STATUS_ACTIVE, 'm_time' => $payTime + 3600 * 24 * 30 * $i, 'm_date' => $i, 'created_at' => $payTime, 'updated_at' => $payTime])->execute();
         }
     }
 }
Example #2
0
 public function actionMonthIndex()
 {
     $investMonths = InvestMonth::find()->joinWith(['investList' => function ($query) {
         /** @var \yii\db\ActiveQuery $query */
         $query->joinWith(['member' => function ($query) {
             /** @var \yii\db\ActiveQuery $query */
             $query->select(Member::$SELECT_ROW);
         }, 'invest']);
     }])->orderBy('id desc')->where(['m_status' => InvestMonth::STATUS_ACTIVE])->andWhere(['<=', 'm_time', time()])->asArray()->all();
     foreach ($investMonths as &$investMonth) {
         $investMonth['m_time'] = date('Y-m-d H:i:s', $investMonth['m_time']);
         $investMonth['created_at'] = date('Y-m-d H:i:s', $investMonth['created_at']);
         $investMonth['m_status'] = InvestMonth::get_record_status($investMonth['m_status']);
         if (isset($investMonth['investList'])) {
             $this->makeView($investMonth['investList']);
             foreach ($investMonth['investList'] as $key => &$i) {
                 $investMonth['invest_list_' . $key] = $i;
             }
             unset($investMonth['investList']);
         }
     }
     return $investMonths;
 }