| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- <?php
- /**
- * UserController.php
- * 手机端收银台--会员用户管理模块
- * Created on 2024/11/29 下午2:15
- * @author: hankaige
- */
- namespace app\modules\client\controllers\v1\cashier;
- use app\constants\OptionSetting;
- use app\models\Level;
- use app\models\Option;
- use app\models\Recharge;
- use app\modules\client\models\v1\cashier\UserForm;
- use app\modules\client\models\v1\cashier\RechargeForm;
- use app\modules\client\models\v1\cashier\IntegralForm;
- class UserController extends BaseController
- {
- /**
- * 搜索会员用户
- * @return \yii\web\Response
- * @author: hankaige
- * @Time: 2024/11/29 下午2:54
- */
- public function actionSearchUser(): \yii\web\Response
- {
- $form = new UserForm();
- $form->store_id = get_store_id();
- $form->scenario = $form::USER_SEARCH;
- $form->attributes = get_params();
- return $this->asJson($form->searchUser());
- }
- /**
- * 用户列表
- * @return \yii\web\Response
- * @author: hankaige
- * @Time: 2024/11/30 下午1:36
- */
- public function actionList(): \yii\web\Response
- {
- $form = new UserForm();
- $form->store_id = get_store_id();
- $form->scenario = $form::USER_LIST;
- $form->attributes = get_params();
- return $this->asJson($form->getUserList());
- }
- /**
- * 编辑修改用户信息
- * @return \yii\web\Response
- * @author: hankaige
- * @Time: 2024/11/30 下午3:25
- */
- public function actionEditUser(): \yii\web\Response
- {
- $form = new UserForm();
- $form->store_id = get_store_id();
- $form->scenario = $form::USER_EDIT;
- $form->attributes = post_params();
- return $this->asJson($form->editUser());
- }
- /**
- * 新增用户
- * @return \yii\web\Response
- * @author: hankaige
- * @Time: 2024/11/30 下午3:50
- */
- public function actionAddUser(): \yii\web\Response
- {
- $form = new UserForm();
- $form->store_id = get_store_id();
- $form->md_id = get_md_id();
- $form->scenario = $form::USER_ADD;
- $form->attributes = post_params();
- return $this->asJson($form->addUser());
- }
- /**
- * 获取会员等级列表
- * @return \yii\web\Response
- * @author: hankaige
- * @Time: 2024/11/30 下午3:51
- */
- public function actionGetLevelList(): \yii\web\Response
- {
- $form = new UserForm();
- $form->store_id = get_store_id();
- return $this->asJson($form->getLevelList());
- }
- /**
- * 余额/积分充值 支付方式获取
- * @return \Yii\web\Response
- * @author: hankaige
- * @Time: 2024/12/2 上午9:33
- */
- public function actionPayType(): \Yii\web\Response
- {
- $type = get_params('type');
- if ($type == 'recharge') {
- // 返回余额充值相关设置
- $name = [
- 'recharge_wallet_status',
- 'recharge_custom_status',
- 'recharge_pic_url',
- 'recharge_ad_pic_url',
- 'recharge_page_url',
- 'recharge_p_pic_url',
- 'recharge_help',
- ];
- $data = Option::get($name, get_store_id(), 'recharge');
- $data = array_column($data, NULL, 'name');
- $balance = [
- 'status' => $data['recharge_wallet_status']['value'],
- 'pic_url' => $data['recharge_pic_url']['value'],
- 'ad_pic_url' => $data['recharge_ad_pic_url']['value'],
- 'page_url' => $data['recharge_page_url']['value'],
- 'p_pic_url' => $data['recharge_p_pic_url']['value'],
- 'help' => $data['recharge_help']['value'],
- 'type' => $data['recharge_custom_status']['value'],// 是否开启自定义充值金额
- ];
- $list = Recharge::find()->where(['store_id' => get_store_id(), 'is_delete' => 0])
- ->orderBy(['pay_price' => SORT_DESC])->asArray()->all();
- $levelType = Level::find()->where(['store_id' => get_store_id(), 'is_delete' => Level::NOT_DELETE])->asArray()->all();
- foreach ($list as &$val) {
- foreach ($levelType as $type) {
- if ($val['level_up'] == $type['level']) {
- $val['level_up_name'] = $type['name'];
- break;
- }
- }
- }
- $data = [
- 'list' => array_values($list),
- 'balance' => $balance,
- 'pay_type' => [
- ['pay_type' => RechargeForm::WECHAT_PAY, 'pay_name' => '微信支付'],
- ['pay_type' => RechargeForm::CASH_PAY, 'pay_name' => '现金支付']
- ]
- ];
- }
- if ($type == 'integral') {
- $data = [
- 'integral' => Option::get(OptionSetting::STORE_INTEGRAL,get_store_id(),'gift', Option::get(OptionSetting::STORE_INTEGRAL,get_store_id(),'store',100)['value'])['value'],
- 'pay_type' => [
- ['pay_type' => IntegralForm::WECHAT_PAY, 'pay_name' => '微信支付'],
- ['pay_type' => IntegralForm::CASH_PAY, 'pay_name' => '现金支付']
- ]
- ];
- }
- return $this->asJson(['code' => 0, 'msg' => 'success', 'data' => $data]);
- }
- /**
- * 余额充值订单创建
- * @return \Yii\web\Response
- * @author: hankaige
- * @Time: 2024/12/2 上午9:33
- */
- public function actionRechargeOrderSubmit(): \Yii\web\Response
- {
- $form = new RechargeForm();
- $form->store_id = get_store_id();
- $form->scenario = $form::SUBMIT_ORDER;
- $form->attributes = post_params();
- return $this->asJson($form->recharge());
- }
- /**
- * 充值订单支付
- * @return \Yii\web\Response
- * @author: hankaige
- * @Time: 2024/12/2 上午11:19
- */
- public function actionRechargeOrderPay(): \Yii\web\Response
- {
- $form = new RechargeForm();
- $form->store_id = get_store_id();
- $form->scenario = $form::PAY_ORDER;
- $form->attributes = post_params();
- return $this->asJson($form->pay());
- }
- /**
- * 积分充值订单提交
- * @return \Yii\web\Response
- * @author: hankaige
- * @Time: 2024/12/3 上午10:25
- */
- public function actionIntegralOrderSubmit(): \Yii\web\Response
- {
- $form = new IntegralForm();
- $form->store_id = get_store_id();
- $form->scenario = $form::INTEGRAL_SUBMIT;
- $form->attributes = post_params();
- return $this->asJson($form->submitIntegral());
- }
- public function actionIntegralOrderPay():\Yii\web\Response
- {
- $form = new IntegralForm();
- $form->store_id = get_store_id();
- $form->scenario = $form::INTEGRAL_PAY;
- $form->attributes = post_params();
- return $this->asJson($form->pay());
- }
- }
|