public function actionMemberupdate($id) { $model = MSceneDetail::findOne($id); if (!$model) { throw new NotFoundHttpException('no this gh'); } if (\Yii::$app->request->isPost) { $model->load(\Yii::$app->request->post()); if ($model->save()) { if ($model->status == MSceneDetail::STATUS_TIXIAN_OK) { $msg = "充值成功"; } else { $msg = "充值失败"; } if (!$model->user->sendWxm($msg)) { U::W("wx send failed"); } return $this->redirect(['memberlist']); } else { U::W($model->getErrors()); } } return $this->render('memberupdate', ['model' => $model]); }
public static function confirmSceneDetail() { $tableName = MSceneDetail::tableName(); $query = (new Query())->from($tableName)->where("status=:status AND scene_amt>0", [':status' => MSceneDetail::STATUS_INIT]); $amt = 0; foreach ($query->each() as $row) { if ($row['cat'] == MSceneDetail::CAT_FAN) { if (empty($row['openid_fan'])) { continue; } $fan = MUser::findOne(['gh_id' => $row['gh_id'], 'openid' => $row['openid_fan']]); if ($fan === null) { continue; } if ($fan->isActivedFan()) { U::W('ACTIVE id=' . $row['id']); $model = MSceneDetail::findOne($row['id']); $model->status = MSceneDetail::STATUS_CONFIRMED; if ($model->save(false)) { $user = MUser::findOne(['gh_id' => $row['gh_id'], 'openid' => $row['openid']]); U::W("SAVE BALANCE1 " . $user->scene_balance); $user->scene_balance += $model->scene_amt; U::W("SAVE BALANCE2 " . $user->scene_balance); $user->scene_balance_time = date("Y-m-d H:i:s"); $user->save(false); } } else { U::W('NO ACTIVE id=' . $row['id']); } } else { if ($row['cat'] == MSceneDetail::CAT_SIGN) { U::W('ACTIVE id=' . $row['id']); $model = MSceneDetail::findOne($row['id']); $model->status = MSceneDetail::STATUS_CONFIRMED; if ($model->save(false)) { $user = MUser::findOne(['gh_id' => $row['gh_id'], 'openid' => $row['openid']]); U::W("SAVE CAT_SIGN BALANCE1 " . $user->scene_balance); $user->scene_balance += $model->scene_amt; U::W("SAVE CAT_SIGN BALANCE2 " . $user->scene_balance); $user->scene_balance_time = date("Y-m-d H:i:s"); $user->save(false); } } } } }