public function actionRefundout() { $form = new AccountRecordForm(); $person = new Person(); $account = new Account(); $lendRecord = new LendRecord(); $persons = $person->findLendArray(); $me = $account->findFormListArray(['type_id' => 1]); $records = $lendRecord->findLendInfo(key($persons), 2); if (Yii::$app->request->isPost && $form->load(Yii::$app->request->post())) { $id = $this->insertRecord($form, REFUNDOUT); $refundRecord = new RefundRecord(); $errors = $refundRecord->insertRecord($form, $id, REFUNDOUT); } return $this->render('refundout', ['model' => $form, 'persons' => $persons, 'me' => $me, 'type' => '还出', 'records' => $records]); }
public function findLendInfo($account_id, $type) { $person = new Person(); $accountRecord = new AccountRecord(); $person_id = $person->findPersonId(['account_id' => $account_id]); $arr = []; $rel = []; if ($type == 1) { $arr = $this->find()->where(['borrow_id' => $person_id, 'status' => 1])->all(); } if ($type == 2) { $arr = $this->find()->where(['lend_id' => $person_id, 'status' => 1])->all(); } foreach ($arr as $value) { $totalMoney = $accountRecord->find()->where(['id' => $value['record_id']])->one()['money']; $repayMoney = $this->findRepayMoney($value['id']); $rel[$value['id']] = date('y年m月d日', strtotime($value['create_time'])) . ' 借' . $totalMoney . '元 ' . '已还' . $repayMoney . '元'; } return $rel; }
public function setXxx($array) { if (isset($array['type'])) { switch ($array['type']) { case 'inster': $search1 = new Person(); $search2 = new Person(); $transaction = Yii::$app->db->beginTransaction(); try { $search1->inster($array['form']); // $search2->insterb($array['form']); $transaction->commit(); } catch (\Exception $e) { $transaction->rollBack(); } break; case 'update': break; case 'delete': break; default: } } }