wangzhibo
6 天以前 3f249e399659dcd09d3fe58071b146e50e45c17f
src/modules/user/service/info.ts
@@ -8,6 +8,8 @@
import { UserInfoEntity } from '../entity/info';
import { UserSmsService } from './sms';
import { UserWxService } from './wx';
import { RecycleOrderEntity } from '../../shop/entity/recycleorder';
/**
 * 用户信息
@@ -16,6 +18,9 @@
export class UserInfoService extends BaseService {
  @InjectEntityModel(UserInfoEntity)
  userInfoEntity: Repository<UserInfoEntity>;
  @InjectEntityModel(RecycleOrderEntity)
  recycleOrderEntity: Repository<RecycleOrderEntity>;
  @Inject()
  pluginService: PluginService;
@@ -85,7 +90,7 @@
          uuid() + '.png'
        );
      }
    } catch (err) {}
    } catch (err) { }
    try {
      return await this.userInfoEntity.update({ id }, param);
    } catch (err) {
@@ -129,4 +134,27 @@
    }
    await this.userInfoEntity.update({ id: userId }, { phone });
  }
  /**
     * 获取用户的碳积分信息
     * @param unionid
     */
  async dashboard(unionid) {
    const info = await this.userInfoEntity.findOneBy({ unionid: unionid });
    if (!info) {
      throw new CoolCommException('查询无结果');
    }
    const count_ = await this.recycleOrderEntity.countBy({
      campusUserId: unionid
    });
    return { carbonPoints: info.carbonBalance, recycleCount:count_, overPercent: 90 }
  }
}