CustomLevelController.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace ghs\controllers;
  3. use bizGhs\custom\classes\CustomLevelClass;
  4. use common\components\util;
  5. use Yii;
  6. class CustomLevelController extends BaseController
  7. {
  8. //等级详情 ssh 20211016
  9. public function actionGetInfo()
  10. {
  11. $info = CustomLevelClass::getByCondition(['shopId' => $this->shopId]);
  12. if (empty($info)) {
  13. $data = [
  14. 'sjId' => $this->sjId,
  15. 'shopId' => $this->shopId,
  16. 'qtNum' => 200,
  17. 'qtAmount' => 10000,
  18. 'byNum' => 500,
  19. 'byAmount' => 50000,
  20. 'hjNum' => 1000,
  21. 'hjAmount' => 300000,
  22. 'zsNum' => 5000,
  23. 'zsAmount' => 1800000
  24. ];
  25. CustomLevelClass::add($data, true);
  26. $info = CustomLevelClass::getByCondition(['shopId' => $this->shopId]);
  27. }
  28. util::success(['info' => $info]);
  29. }
  30. //添加修改等级 ssh 20211016
  31. public function actionReplace()
  32. {
  33. $shopAdmin = $this->shopAdmin;
  34. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  35. util::fail('管理员才能操作');
  36. }
  37. $post = Yii::$app->request->post();
  38. $info = CustomLevelClass::getByCondition(['shopId' => $this->shopId], true);
  39. if (empty($info)) {
  40. util::fail('出错了');
  41. }
  42. $id = $info->id ?? 0;
  43. $num = $post['num'] ?? 0;
  44. if (is_numeric($num) == false || $num <= 0) {
  45. util::fail('标准会员的数量要大于0');
  46. }
  47. $hjNum = $post['hjNum'] ?? 0;
  48. if ($hjNum <= $num) {
  49. util::fail('黄金等级的数量要大于白银');
  50. }
  51. $zsNum = $post['zsNum'] ?? 0;
  52. if ($zsNum <= $hjNum) {
  53. util::fail('钻石等级的数量要大于黄金');
  54. }
  55. CustomLevelClass::updateById($id, $post);
  56. util::complete('修改成功');
  57. }
  58. }