| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace ghs\controllers;
- use bizGhs\custom\classes\CustomLevelClass;
- use common\components\util;
- use Yii;
- class CustomLevelController extends BaseController
- {
- //等级详情 ssh 20211016
- public function actionGetInfo()
- {
- $info = CustomLevelClass::getByCondition(['shopId' => $this->shopId]);
- if (empty($info)) {
- $data = [
- 'sjId' => $this->sjId,
- 'shopId' => $this->shopId,
- 'qtNum' => 200,
- 'qtAmount' => 10000,
- 'byNum' => 500,
- 'byAmount' => 50000,
- 'hjNum' => 1000,
- 'hjAmount' => 300000,
- 'zsNum' => 5000,
- 'zsAmount' => 1800000
- ];
- CustomLevelClass::add($data, true);
- $info = CustomLevelClass::getByCondition(['shopId' => $this->shopId]);
- }
- util::success(['info' => $info]);
- }
- //添加修改等级 ssh 20211016
- public function actionReplace()
- {
- $shopAdmin = $this->shopAdmin;
- if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
- util::fail('管理员才能操作');
- }
- $post = Yii::$app->request->post();
- $info = CustomLevelClass::getByCondition(['shopId' => $this->shopId], true);
- if (empty($info)) {
- util::fail('出错了');
- }
- $id = $info->id ?? 0;
- $num = $post['num'] ?? 0;
- if (is_numeric($num) == false || $num <= 0) {
- util::fail('标准会员的数量要大于0');
- }
- $hjNum = $post['hjNum'] ?? 0;
- if ($hjNum <= $num) {
- util::fail('黄金等级的数量要大于白银');
- }
- $zsNum = $post['zsNum'] ?? 0;
- if ($zsNum <= $hjNum) {
- util::fail('钻石等级的数量要大于黄金');
- }
- CustomLevelClass::updateById($id, $post);
- util::complete('修改成功');
- }
- }
|