Kirin 2 месяцев назад
Родитель
Сommit
c88b770c62

+ 12 - 2
app/controller/admin/system/config/SystemUserLevel.php

@@ -67,7 +67,12 @@ class SystemUserLevel extends AdminBaseController
 
     public function setStatus($id, $status)
     {
-        $this->service->update((int)$id, ['is_show' => $status]);
+        $info = $this->service->get($id);
+        if (!$info) {
+            return $this->error('数据不存在');
+        }
+        $info = $info->toArray();
+        $this->service->update((int)$id, array_merge($info, ['is_show' => $status]));
         return $this->success($status == 0 ? '关闭成功' : '开启成功');
     }
 
@@ -78,7 +83,12 @@ class SystemUserLevel extends AdminBaseController
             ['value', '']
         ]);
         if ($data['field'] == '' || $data['value'] == '') return $this->error('缺少参数');
-        $res = $this->service->update((int)$id, [$data['field'] => $data['value']]);
+        $info = $this->service->get($id);
+        if (!$info) {
+            return $this->error('数据不存在');
+        }
+        $info = $info->toArray();
+        $res = $this->service->update((int)$id, array_merge($info, [$data['field'] => $data['value']]));
         if ($res)
             return $this->success('保存成功');
         return $this->error('保存失败');

+ 0 - 2
app/controller/admin/user/User.php

@@ -42,8 +42,6 @@ class User extends AdminBaseController
             ['nickname', ''],
             ['status', ''],
             ['is_promoter', ''],
-            ['order', ''],
-            ['data', ''],
             ['user_type', ''],
             ['country', ''],
             ['province', ''],

+ 6 - 0
app/model/system/SystemLog.php

@@ -46,6 +46,12 @@ class SystemLog extends BaseModel
         return time();
     }
 
+
+    protected function getParamsAttr($value)
+    {
+        return json_decode($value, true);
+    }
+
     /**
      * @param $query
      * @param $value

+ 0 - 1
app/services/system/config/SystemUserLevelServices.php

@@ -102,7 +102,6 @@ class SystemUserLevelServices extends BaseServices
 
     public function update($id, array $data, ?string $key = null)
     {
-
         $gradeLevel = $this->getLevel(['grade' => $data['grade']]);
         $nameLevel = $this->getLevel(['name' => $data['name']]);
 

+ 32 - 23
app/services/system/config/SystemUserLevelTaskServices.php

@@ -24,15 +24,28 @@ class SystemUserLevelTaskServices extends BaseServices
 {
 
     protected $tasks = [
-        ['name' => 'expend', 'title' => '消费满额', 'info' => '消费满{%num1%}', 'unit1' => '元'],
-        ['name' => 'achievement', 'title' => '业绩达标', 'info' => '业绩满{%num1%}', 'unit1' => '元'],
-        ['name' => 'spread_num', 'title' => '推荐会员', 'info' => '邀请等级{%num1%}及以上的用户{%num2%}', 'unit1' => '级', 'unit2' => '人'],
+        'expend' => ['name' => 'expend', 'title' => '消费满额', 'info' => '消费满{%num1%}', 'unit1' => '元'],
+        'achievement' => ['name' => 'achievement', 'title' => '业绩达标', 'info' => '业绩满{%num1%}', 'unit1' => '元'],
+        'spread_num' => ['name' => 'spread_num', 'title' => '推荐会员', 'info' => '邀请等级{%num1%}及以上的用户{%num2%}', 'unit1' => '级', 'unit2' => '人'],
     ];
 
 
     public function taskBase()
     {
-        return $this->tasks;
+        $tasks = $this->tasks;
+        foreach ($tasks as $v) {
+            $units = [];
+            for ($i = 1; ; $i++) {
+                $unit = 'unit' . $i;
+                if (isset($v[$unit])) {
+                    $units[] = ['label' => $v[$unit], 'replace' => "{%num" . $i . "%}", 'key' => $i, 'num_name' => 'num' . $i];
+                } else {
+                    break;
+                }
+            }
+            $tasks[$v['name']]['units'] = $units;
+        }
+        return $tasks;
     }
 
     /**
@@ -43,17 +56,13 @@ class SystemUserLevelTaskServices extends BaseServices
     {
         foreach ($task as &$v) {
             if (!$this->tasks[$v['name'] ?? '']) throw new ValidateException('任务不存在');
-            if (($v['num1'] ?? 0) < 0) throw new ValidateException('任务数量不能小于0');
-            $v['info'] = str_replace('{%num1%}', ($v['num1'] ?? 0) . $this->tasks[$v['name']]['unit1'], $this->tasks[$v['name']]['info']);
-            for ($i = 2; ; $i++) {
-                $unit = 'unit' . $i;
-                $num = 'num' . $i;
-                if (isset($this->tasks[$v['name']][$unit])) {
-                    if (($v[$num] ?? 0) < 0) throw new ValidateException('任务数量' . $i . '不能小于0');
-                    $v['info'] = str_replace('{%num' . $i . '%}', ($v[$num] ?? 0) . $this->tasks[$v['name']][$unit], $v['info']);
-                } else {
-                    break;
-                }
+            if (!isset($v['units'])) {
+                throw new ValidateException('请设置任务数量');
+            }
+            foreach ($v['units'] as $task_value) {
+                if (($task_value['value'] ?? 0) < 0) throw new ValidateException('任务数量不能小于0');
+                if (!isset($task_value['replace'])) throw new ValidateException('任务参数异常');
+                $v['info'] = str_replace($task_value['replace'], ($task_value['value'] ?? 0) . ($task_value['label'] ?? ''), ($v['info'] ?? $this->tasks[$v['name']]['info']));
             }
             $v['must'] = $v['must'] ?? 0;
         }
@@ -85,14 +94,14 @@ class SystemUserLevelTaskServices extends BaseServices
                 Log::error('等级任务' . $v['name'] . '未完成');
                 continue;
             }
-            $nums = ['num1' => $v['num1']];
-            for ($i = 2; ; $i++) {
-                $num = 'num' . $i;
-                if (isset($v[$num])) {
-                    $nums[$num] = $v[$num];
-                } else {
-                    break;
-                }
+            if (!isset($v['units'])) {
+                Log::error('任务数量未设置');
+                continue;
+            }
+            $nums = [];
+            foreach ($v['units'] as $task_value) {
+                if (($task_value['value'] ?? 0) < 0) throw new ValidateException('任务数量不能小于0');
+                $nums['num' . (string)$task_value['key']] = $task_value['value'] ?? 0;
             }
             if (!$this->{'task_' . $v['name']}($uid, $start_time, $nums)) {
                 if ($v['must']) $must[] = ['name' => $v['name'], 'status' => 0];

+ 3 - 3
app/services/user/UserWechatuserServices.php

@@ -195,12 +195,12 @@ class UserWechatuserServices extends BaseServices
                     if ($where['country'] == 'domestic') {
                         $g->where($wechatUserAlias . 'country', 'in', ['中国', 'China']);
                     } else if ($where['country'] == 'abroad') {
-                        $g->whereOr($userAlias . 'addres', '');
+                        $g->whereOr($wechatUserAlias . 'country', 'not in', ['中国', 'China']);
                     }
                 })->when(isset($where['province']) && $where['province'], function ($q) use ($wechatUserAlias, $userAlias, $where) {
-                    $q->whereOr($wechatUserAlias . 'province', $where['province'])->whereOr($userAlias . 'provincials', 'Like', '%' . $where['province'] . '%')->whereOr($userAlias . 'addres', 'Like', '%' . $where['province'] . '%');
+                    $q->whereOr($wechatUserAlias . 'province', $where['province'])->whereOr($userAlias . 'provincials', 'Like', '%' . $where['province'] . '%');
                 })->when(isset($where['city']) && $where['city'], function ($c) use ($wechatUserAlias, $userAlias, $where) {
-                    $c->whereOr($wechatUserAlias . 'city', $where['city'])->whereOr($userAlias . 'provincials', 'Like', '%' . $where['city'] . '%')->whereOr($userAlias . 'addres', 'Like', '%' . $where['city'] . '%');
+                    $c->whereOr($wechatUserAlias . 'city', $where['city'])->whereOr($userAlias . 'provincials', 'Like', '%' . $where['city'] . '%');
                 });
             });
         }

+ 4 - 1
qiniu/basic/BaseServices.php

@@ -53,7 +53,7 @@ abstract class BaseServices
             $page = app()->request->param(Config::get('database.page.pageKey', 'page') . '/d', 0);
             $limit = app()->request->param(Config::get('database.page.limitKey', 'limit') . '/d', 0);
         }
-        $limitMax = Config::get('database.page.limitMax');
+        $limitMax = Config::get('database.page.limitMax', 100);
         $defaultLimit = Config::get('database.page.defaultLimit', 10);
         if ($limit > $limitMax && $isRelieve) {
             $limit = $limitMax;
@@ -447,6 +447,9 @@ abstract class BaseServices
      */
     public function create(array $data)
     {
+        if (method_exists($this->model, 'setAddTimeAttr') && !isset($data['add_time'])) {
+            $data['add_time'] = time();
+        }
         return $this->model->create($data);
     }