IntegralRechargeController.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. namespace app\modules\client\controllers\v1;
  8. use app\models\IntegralRecharge;
  9. use app\models\QAndASetting;
  10. use app\models\RechargeModule;
  11. use app\modules\client\controllers\BaseController;
  12. use app\modules\client\models\v1\DetailForm;
  13. use app\modules\client\models\v1\IntegralRechargeSubmitForm;
  14. use app\modules\client\models\v1\RecordForm;
  15. class IntegralRechargeController extends BaseController
  16. {
  17. public function behaviors()
  18. {
  19. return parent::behaviors();
  20. }
  21. public function actionIndex()
  22. {
  23. $user = get_user();
  24. // 搜索指定月份的充值记录及余额消费记录
  25. $form = new RecordForm();
  26. $form->user = $user;
  27. $form->attributes = get_params();
  28. $form->store_id = get_store_id();
  29. $res = $form->search();
  30. if ($res['code'] == 1) {
  31. return $this->asJson($res);
  32. }
  33. // 余额页设置
  34. $form = new RechargeModule();
  35. $form->store_id = get_store_id();
  36. $setting = $form->search_recharge();
  37. $data = [
  38. 'money' => $user->money,
  39. 'list' => $res['data']['list'],
  40. 'setting' => $setting,
  41. 'date' => $res['data']['date'],
  42. ];
  43. return $this->asJson(['code' => 0, 'msg' => 'success', 'data' => $data]);
  44. }
  45. /**
  46. * 搜索指定月份的充值记录及余额消费记录
  47. * @return \yii\web\Response
  48. * @throws \yii\db\Exception
  49. */
  50. public function actionRecord()
  51. {
  52. $user = get_user();
  53. $form = new RecordForm();
  54. $form->attributes = get_params();
  55. $form->store_id = get_store_id();
  56. $form->user = $user;
  57. $res = $form->search();
  58. return $this->asJson($res);
  59. }
  60. //充值记录
  61. public function actionRechargeOrder()
  62. {
  63. $user = get_user();
  64. $form = new RecordForm();
  65. $form->attributes = get_params();
  66. $form->store_id = get_store_id();
  67. $form->user = $user;
  68. return $this->asJson($form->rechargeOrder());
  69. }
  70. /**
  71. * 充值可选列表
  72. * @return \yii\web\Response
  73. */
  74. public function actionList()
  75. {
  76. $list = IntegralRecharge::find()->where(['store_id' => get_store_id(), 'is_delete' => 0, 'state' => 1])
  77. ->orderBy(['pay_price' => SORT_DESC])->asArray()->all();
  78. $user = get_user();
  79. $qs_s = QAndASetting::find()->where(['store_id' => get_store_id()])->one();
  80. $data = [
  81. 'integral' => $user->integral,
  82. 'rule' => $qs_s->rule,
  83. 'list' => $list,
  84. ];
  85. return $this->asJson(['code' => 0, 'msg' => 'success', 'data' => $data]);
  86. }
  87. /**
  88. * 充值提交
  89. * @return \yii\web\Response
  90. */
  91. public function actionSubmit()
  92. {
  93. $form = new IntegralRechargeSubmitForm();
  94. $form->store_id = get_store_id();
  95. $form->user = get_user();
  96. $form->attributes = post_params();
  97. if (post_params('_form') === 'h5') {
  98. $form->pay_type = 1;
  99. }
  100. return $this->asJson($form->save());
  101. }
  102. /**
  103. * 余额收支详情
  104. * @return \yii\web\Response
  105. */
  106. public function actionDetail()
  107. {
  108. $form = new DetailForm();
  109. $form->store_id = get_store_id();
  110. $form->attributes = get_params();
  111. return $this->asJson($form->search());
  112. }
  113. }