Bladeren bron

付费会员问题修复

evoxwht 2 jaren geleden
bovenliggende
commit
9d4edfad92
1 gewijzigde bestanden met toevoegingen van 36 en 6 verwijderingen
  1. 36 6
      crmeb/app/services/user/UserServices.php

+ 36 - 6
crmeb/app/services/user/UserServices.php

@@ -117,6 +117,7 @@ class UserServices extends BaseServices
      * @param int $spreadUid
      * @param int $spreadUid
      * @param string $userType
      * @param string $userType
      * @return User|\think\Model
      * @return User|\think\Model
+     * @throws Exception
      */
      */
     public function setUserInfo($user, int $spreadUid = 0, string $userType = 'wechat')
     public function setUserInfo($user, int $spreadUid = 0, string $userType = 'wechat')
     {
     {
@@ -992,9 +993,13 @@ class UserServices extends BaseServices
 
 
     /**
     /**
      * 执行赠送会员等级
      * 执行赠送会员等级
-     * @param int $uid
+     * @param int $id
+     * @param int $level_id
      * @return mixed
      * @return mixed
-     * */
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
     public function saveGiveLevel(int $id, int $level_id)
     public function saveGiveLevel(int $id, int $level_id)
     {
     {
         if (!$this->getUserInfo($id)) {
         if (!$this->getUserInfo($id)) {
@@ -1039,19 +1044,26 @@ class UserServices extends BaseServices
         $field[] = Form::input('time_diff', '到期时间', $timeDiff)->style(['width' => '200px'])->readonly(true);
         $field[] = Form::input('time_diff', '到期时间', $timeDiff)->style(['width' => '200px'])->readonly(true);
         if ($userInfo['is_ever_level'] == 0) {
         if ($userInfo['is_ever_level'] == 0) {
             $field[] = Form::input('day_diff', '剩余天数', $dayDiff)->style(['width' => '200px'])->readonly(true);
             $field[] = Form::input('day_diff', '剩余天数', $dayDiff)->style(['width' => '200px'])->readonly(true);
+            $field[] = Form::number('days', '增加时长(天)')->precision(0)->style(['width' => '200px'])->required();
         }
         }
-        $field[] = Form::number('days', '增加时长(天)')->precision(0)->style(['width' => '200px'])->required();
         return create_form('赠送付费会员时长', $field, Url::buildUrl('/user/save_give_level_time/' . $id), 'PUT');
         return create_form('赠送付费会员时长', $field, Url::buildUrl('/user/save_give_level_time/' . $id), 'PUT');
     }
     }
 
 
     /**
     /**
      * 执行赠送付费会员时长
      * 执行赠送付费会员时长
-     * @param int $uid
+     * @param int $id
+     * @param int $days
      * @return mixed
      * @return mixed
-     * */
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
     public function saveGiveLevelTime(int $id, int $days)
     public function saveGiveLevelTime(int $id, int $days)
     {
     {
         $userInfo = $this->getUserInfo($id);
         $userInfo = $this->getUserInfo($id);
+        if ($userInfo->is_ever_level == 1) {
+            return true;
+        }
         if (!$userInfo) {
         if (!$userInfo) {
             throw new AdminException(400214);
             throw new AdminException(400214);
         }
         }
@@ -1117,7 +1129,12 @@ class UserServices extends BaseServices
 
 
     /**
     /**
      * 用户详细信息
      * 用户详细信息
-     * @param $uid
+     * @param int $uid
+     * @param array $userIfno
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
      */
      */
     public function getUserDetailed(int $uid, $userIfno = [])
     public function getUserDetailed(int $uid, $userIfno = [])
     {
     {
@@ -1214,6 +1231,9 @@ class UserServices extends BaseServices
      * 用户详情
      * 用户详情
      * @param int $uid
      * @param int $uid
      * @return array
      * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
      */
      */
     public function read(int $uid)
     public function read(int $uid)
     {
     {
@@ -1222,6 +1242,16 @@ class UserServices extends BaseServices
             throw new AdminException(100026);
             throw new AdminException(100026);
         }
         }
         $userInfo['avatar'] = strpos($userInfo['avatar'], 'http') === false ? (sys_config('site_url') . $userInfo['avatar']) : $userInfo['avatar'];
         $userInfo['avatar'] = strpos($userInfo['avatar'], 'http') === false ? (sys_config('site_url') . $userInfo['avatar']) : $userInfo['avatar'];
+        $userInfo['overdue_time'] = date('Y-m-d H:i:s', $userInfo['overdue_time']);
+        $userInfo['birthday'] = $userInfo['birthday'] < 0 ? 0 : $userInfo['birthday'];
+        if ($userInfo['addres'] == '') {
+            $defaultAddressInfo = app()->make(UserAddressServices::class)->getUserDefaultAddress($uid);
+            $userInfo['addres'] = $defaultAddressInfo['province'] . $defaultAddressInfo['city'] . $defaultAddressInfo['district'] . $defaultAddressInfo['detail'];
+        }
+        $userInfo['vip_name'] = app()->make(SystemUserLevelServices::class)->value(['grade' => $userInfo['level']], 'name');
+        $userInfo['group_name'] = app()->make(UserGroupServices::class)->value(['id' => $userInfo['group_id']], 'group_name');
+        $userInfo['spread_uid_nickname'] = $this->dao->value(['uid' => $userInfo['spread_uid']], 'nickname') . '(' . $userInfo['spread_uid'] . ')';
+        $userInfo['label_list'] = implode(',', array_column(app()->make(UserLabelRelationServices::class)->getUserLabelList([$uid]), 'label_name'));
         return [
         return [
             'uid' => $uid,
             'uid' => $uid,
             'userinfo' => $this->getUserDetailed($uid, $userInfo),
             'userinfo' => $this->getUserDetailed($uid, $userInfo),