UserController.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <?php
  2. /**
  3. * UserController.php
  4. * 手机端收银台--会员用户管理模块
  5. * Created on 2024/11/29 下午2:15
  6. * @author: hankaige
  7. */
  8. namespace app\modules\client\controllers\v1\cashier;
  9. use app\constants\OptionSetting;
  10. use app\models\Level;
  11. use app\models\Option;
  12. use app\models\Recharge;
  13. use app\modules\client\models\v1\cashier\UserForm;
  14. use app\modules\client\models\v1\cashier\RechargeForm;
  15. use app\modules\client\models\v1\cashier\IntegralForm;
  16. class UserController extends BaseController
  17. {
  18. /**
  19. * 搜索会员用户
  20. * @return \yii\web\Response
  21. * @author: hankaige
  22. * @Time: 2024/11/29 下午2:54
  23. */
  24. public function actionSearchUser(): \yii\web\Response
  25. {
  26. $form = new UserForm();
  27. $form->store_id = get_store_id();
  28. $form->scenario = $form::USER_SEARCH;
  29. $form->attributes = get_params();
  30. return $this->asJson($form->searchUser());
  31. }
  32. /**
  33. * 用户列表
  34. * @return \yii\web\Response
  35. * @author: hankaige
  36. * @Time: 2024/11/30 下午1:36
  37. */
  38. public function actionList(): \yii\web\Response
  39. {
  40. $form = new UserForm();
  41. $form->store_id = get_store_id();
  42. $form->scenario = $form::USER_LIST;
  43. $form->attributes = get_params();
  44. return $this->asJson($form->getUserList());
  45. }
  46. /**
  47. * 编辑修改用户信息
  48. * @return \yii\web\Response
  49. * @author: hankaige
  50. * @Time: 2024/11/30 下午3:25
  51. */
  52. public function actionEditUser(): \yii\web\Response
  53. {
  54. $form = new UserForm();
  55. $form->store_id = get_store_id();
  56. $form->scenario = $form::USER_EDIT;
  57. $form->attributes = post_params();
  58. return $this->asJson($form->editUser());
  59. }
  60. /**
  61. * 新增用户
  62. * @return \yii\web\Response
  63. * @author: hankaige
  64. * @Time: 2024/11/30 下午3:50
  65. */
  66. public function actionAddUser(): \yii\web\Response
  67. {
  68. $form = new UserForm();
  69. $form->store_id = get_store_id();
  70. $form->md_id = get_md_id();
  71. $form->scenario = $form::USER_ADD;
  72. $form->attributes = post_params();
  73. return $this->asJson($form->addUser());
  74. }
  75. /**
  76. * 获取会员等级列表
  77. * @return \yii\web\Response
  78. * @author: hankaige
  79. * @Time: 2024/11/30 下午3:51
  80. */
  81. public function actionGetLevelList(): \yii\web\Response
  82. {
  83. $form = new UserForm();
  84. $form->store_id = get_store_id();
  85. return $this->asJson($form->getLevelList());
  86. }
  87. /**
  88. * 余额/积分充值 支付方式获取
  89. * @return \Yii\web\Response
  90. * @author: hankaige
  91. * @Time: 2024/12/2 上午9:33
  92. */
  93. public function actionPayType(): \Yii\web\Response
  94. {
  95. $type = get_params('type');
  96. if ($type == 'recharge') {
  97. // 返回余额充值相关设置
  98. $name = [
  99. 'recharge_wallet_status',
  100. 'recharge_custom_status',
  101. 'recharge_pic_url',
  102. 'recharge_ad_pic_url',
  103. 'recharge_page_url',
  104. 'recharge_p_pic_url',
  105. 'recharge_help',
  106. ];
  107. $data = Option::get($name, get_store_id(), 'recharge');
  108. $data = array_column($data, NULL, 'name');
  109. $balance = [
  110. 'status' => $data['recharge_wallet_status']['value'],
  111. 'pic_url' => $data['recharge_pic_url']['value'],
  112. 'ad_pic_url' => $data['recharge_ad_pic_url']['value'],
  113. 'page_url' => $data['recharge_page_url']['value'],
  114. 'p_pic_url' => $data['recharge_p_pic_url']['value'],
  115. 'help' => $data['recharge_help']['value'],
  116. 'type' => $data['recharge_custom_status']['value'],// 是否开启自定义充值金额
  117. ];
  118. $list = Recharge::find()->where(['store_id' => get_store_id(), 'is_delete' => 0])
  119. ->orderBy(['pay_price' => SORT_DESC])->asArray()->all();
  120. $levelType = Level::find()->where(['store_id' => get_store_id(), 'is_delete' => Level::NOT_DELETE])->asArray()->all();
  121. foreach ($list as &$val) {
  122. foreach ($levelType as $type) {
  123. if ($val['level_up'] == $type['level']) {
  124. $val['level_up_name'] = $type['name'];
  125. break;
  126. }
  127. }
  128. }
  129. $data = [
  130. 'list' => array_values($list),
  131. 'balance' => $balance,
  132. 'pay_type' => [
  133. ['pay_type' => RechargeForm::WECHAT_PAY, 'pay_name' => '微信支付'],
  134. ['pay_type' => RechargeForm::CASH_PAY, 'pay_name' => '现金支付']
  135. ]
  136. ];
  137. }
  138. if ($type == 'integral') {
  139. $data = [
  140. 'integral' => Option::get(OptionSetting::STORE_INTEGRAL,get_store_id(),'gift', Option::get(OptionSetting::STORE_INTEGRAL,get_store_id(),'store',100)['value'])['value'],
  141. 'pay_type' => [
  142. ['pay_type' => IntegralForm::WECHAT_PAY, 'pay_name' => '微信支付'],
  143. ['pay_type' => IntegralForm::CASH_PAY, 'pay_name' => '现金支付']
  144. ]
  145. ];
  146. }
  147. return $this->asJson(['code' => 0, 'msg' => 'success', 'data' => $data]);
  148. }
  149. /**
  150. * 余额充值订单创建
  151. * @return \Yii\web\Response
  152. * @author: hankaige
  153. * @Time: 2024/12/2 上午9:33
  154. */
  155. public function actionRechargeOrderSubmit(): \Yii\web\Response
  156. {
  157. $form = new RechargeForm();
  158. $form->store_id = get_store_id();
  159. $form->scenario = $form::SUBMIT_ORDER;
  160. $form->attributes = post_params();
  161. return $this->asJson($form->recharge());
  162. }
  163. /**
  164. * 充值订单支付
  165. * @return \Yii\web\Response
  166. * @author: hankaige
  167. * @Time: 2024/12/2 上午11:19
  168. */
  169. public function actionRechargeOrderPay(): \Yii\web\Response
  170. {
  171. $form = new RechargeForm();
  172. $form->store_id = get_store_id();
  173. $form->scenario = $form::PAY_ORDER;
  174. $form->attributes = post_params();
  175. return $this->asJson($form->pay());
  176. }
  177. /**
  178. * 积分充值订单提交
  179. * @return \Yii\web\Response
  180. * @author: hankaige
  181. * @Time: 2024/12/3 上午10:25
  182. */
  183. public function actionIntegralOrderSubmit(): \Yii\web\Response
  184. {
  185. $form = new IntegralForm();
  186. $form->store_id = get_store_id();
  187. $form->scenario = $form::INTEGRAL_SUBMIT;
  188. $form->attributes = post_params();
  189. return $this->asJson($form->submitIntegral());
  190. }
  191. public function actionIntegralOrderPay():\Yii\web\Response
  192. {
  193. $form = new IntegralForm();
  194. $form->store_id = get_store_id();
  195. $form->scenario = $form::INTEGRAL_PAY;
  196. $form->attributes = post_params();
  197. return $this->asJson($form->pay());
  198. }
  199. }