| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\client\controllers\v1;
- use app\models\IntegralRecharge;
- use app\models\QAndASetting;
- use app\models\RechargeModule;
- use app\modules\client\controllers\BaseController;
- use app\modules\client\models\v1\DetailForm;
- use app\modules\client\models\v1\IntegralRechargeSubmitForm;
- use app\modules\client\models\v1\RecordForm;
- class IntegralRechargeController extends BaseController
- {
- public function behaviors()
- {
- return parent::behaviors();
- }
- public function actionIndex()
- {
- $user = get_user();
- // 搜索指定月份的充值记录及余额消费记录
- $form = new RecordForm();
- $form->user = $user;
- $form->attributes = get_params();
- $form->store_id = get_store_id();
- $res = $form->search();
- if ($res['code'] == 1) {
- return $this->asJson($res);
- }
- // 余额页设置
- $form = new RechargeModule();
- $form->store_id = get_store_id();
- $setting = $form->search_recharge();
- $data = [
- 'money' => $user->money,
- 'list' => $res['data']['list'],
- 'setting' => $setting,
- 'date' => $res['data']['date'],
- ];
- return $this->asJson(['code' => 0, 'msg' => 'success', 'data' => $data]);
- }
- /**
- * 搜索指定月份的充值记录及余额消费记录
- * @return \yii\web\Response
- * @throws \yii\db\Exception
- */
- public function actionRecord()
- {
- $user = get_user();
- $form = new RecordForm();
- $form->attributes = get_params();
- $form->store_id = get_store_id();
- $form->user = $user;
- $res = $form->search();
- return $this->asJson($res);
- }
- //充值记录
- public function actionRechargeOrder()
- {
- $user = get_user();
- $form = new RecordForm();
- $form->attributes = get_params();
- $form->store_id = get_store_id();
- $form->user = $user;
- return $this->asJson($form->rechargeOrder());
- }
- /**
- * 充值可选列表
- * @return \yii\web\Response
- */
- public function actionList()
- {
- $list = IntegralRecharge::find()->where(['store_id' => get_store_id(), 'is_delete' => 0, 'state' => 1])
- ->orderBy(['pay_price' => SORT_DESC])->asArray()->all();
- $user = get_user();
- $qs_s = QAndASetting::find()->where(['store_id' => get_store_id()])->one();
- $data = [
- 'integral' => $user->integral,
- 'rule' => $qs_s->rule,
- 'list' => $list,
- ];
- return $this->asJson(['code' => 0, 'msg' => 'success', 'data' => $data]);
- }
- /**
- * 充值提交
- * @return \yii\web\Response
- */
- public function actionSubmit()
- {
- $form = new IntegralRechargeSubmitForm();
- $form->store_id = get_store_id();
- $form->user = get_user();
- $form->attributes = post_params();
- if (post_params('_form') === 'h5') {
- $form->pay_type = 1;
- }
- return $this->asJson($form->save());
- }
- /**
- * 余额收支详情
- * @return \yii\web\Response
- */
- public function actionDetail()
- {
- $form = new DetailForm();
- $form->store_id = get_store_id();
- $form->attributes = get_params();
- return $this->asJson($form->search());
- }
- }
|