Browse Source

更新家族成员财富/魅力值

zhangxiaobin 1 year ago
parent
commit
249d517e22

+ 1 - 1
application/api/controller/Money.php

@@ -25,7 +25,7 @@ use app\common\library\Sms as Smslib;
 class Money extends Common
 {
     protected $noNeedLogin = ['getRecharConfig', 'getRateMoney', 'getExchangeConfig', 'getExchsoundConfig', 'rebateDuty',
-        'kjRecharge', 'changeWithDrawStatus','moneyConfig','recharOrderCancel'];
+        'kjRecharge', 'changeWithDrawStatus','moneyConfig'];
     protected $noNeedRight = '*';
 
     public function _initialize()

+ 3 - 0
application/common/service/UserService.php

@@ -368,6 +368,9 @@ class UserService
                     $giftNum = isset($userGift[0]['gift_total_num']) ? (int)$userGift[0]['gift_total_num'] : 0;
                     $guildMemberData = ['wealth'=>$wealth,'charm'=>$charm,'gift_num'=>$giftNum];
                     $r = model('GuildMember')->update($guildMemberData,$guildMemberWhere);
+                    if (!$r) {
+                        throw new Exception('更新失败');
+                    }
                 }
             }
         } catch (Exception $e) {

+ 37 - 0
application/index/controller/TaskList.php

@@ -2,6 +2,7 @@
 
 namespace app\index\controller;
 
+use app\common\service\UserService;
 use think\Controller;
 use think\Exception;
 
@@ -35,4 +36,40 @@ class TaskList extends Controller
         }
         echo json_encode($result);
     }
+
+    /**
+     * 更新公会成员魅力值/财富值
+     * @return void
+     */
+    public function guildMemberVal()
+    {
+        $result = [
+            'code' => 1,
+            'msg' => 'success',
+            'data' => [],
+        ];
+        try {
+            $field = 'id,user_id';
+            $where['guild_status'] = 0;
+            $userPower = model('UserPower')->field($field)->where($where)->select();
+            $res = 0;
+            if (!empty($userPower)) {
+                $userService = new UserService();
+                foreach ($userPower as $key => $value) {
+                    $params['user_id'] = $value['user_id'];
+                    $userServiceRes = $userService->updateGuildMember($params);
+                    if (!$userServiceRes['status']) {
+                        continue;
+                    }
+                    model('UserPower')->update(['guild_status'=>1],['id'=>$value['id']]);
+                    $res++;
+                }
+            }
+            $result['data'] = $res;
+        } catch (Exception $e) {
+            $result['code'] = 0;
+            $result['msg'] = $e->getMessage();
+        }
+        echo json_encode($result);
+    }
 }