|
|
@@ -36,6 +36,8 @@ class RechargeForm extends Model {
|
|
|
|
|
|
private $_userId;
|
|
|
|
|
|
+ public $id;
|
|
|
+
|
|
|
/**
|
|
|
* @inheritdoc
|
|
|
*/
|
|
|
@@ -49,6 +51,7 @@ class RechargeForm extends Model {
|
|
|
[['applyAmount'], 'isApplyAmount'],
|
|
|
[['applyAmount'], 'number', 'max' => 10000000000, 'min' => 1],
|
|
|
[['selectedIds'], 'isSelected'],
|
|
|
+ [['id'], 'number'],
|
|
|
//[['sn'], 'isSn'],
|
|
|
];
|
|
|
}
|
|
|
@@ -222,6 +225,44 @@ class RechargeForm extends Model {
|
|
|
return $rechargeModel;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 更新充值申请
|
|
|
+ * @return null|string
|
|
|
+ * @throws \yii\db\Exception
|
|
|
+ */
|
|
|
+ public function update() {
|
|
|
+ if (!$this->validate()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(!$this->id){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $db = \Yii::$app->db;
|
|
|
+ $transaction = $db->beginTransaction();
|
|
|
+ try {
|
|
|
+ $nowTime = Date::nowTime();
|
|
|
+ $period = Recharge::getPeriod($nowTime);
|
|
|
+ //增加记录
|
|
|
+ $userInfo = Info::baseInfo($this->_userId);
|
|
|
+
|
|
|
+ $rechargeModel = Recharge::where(['id'=>$this->id])->one();
|
|
|
+ $rechargeModel->AMOUNT = $this->applyAmount;
|
|
|
+ $rechargeModel->OPEN_BANK = $this->openBank;
|
|
|
+ $rechargeModel->BANK_ADDRESS = $this->bankAddress;
|
|
|
+ $rechargeModel->BANK_NO = $this->bankNo;
|
|
|
+ $rechargeModel->UPDATED_AT = $nowTime;
|
|
|
+ if (!$rechargeModel->save()) {
|
|
|
+ throw new Exception(Form::formatErrorsForApi($rechargeModel->getErrors()));
|
|
|
+ }
|
|
|
+ $transaction->commit();
|
|
|
+ } catch (Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ $this->addError('update', $e->getMessage());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return $rechargeModel;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 生成流水号
|
|
|
* @return string
|