Browse Source

update pay

warrior 2 months ago
parent
commit
a02da3cf99

+ 30 - 9
projects/live-app/src/app/components/pay-comp/pay-comp.component.ts

@@ -4,7 +4,11 @@ import { ActivatedRoute } from '@angular/router';
 import { AccountService } from '../../../services/account.service';
 import { HttpClient } from '@angular/common/http';
 import * as Parse from 'parse';
-import { ionicStandaloneModules,AlertController, ToastController } from '../../../modules/ionic-standalone.modules';
+import {
+  ionicStandaloneModules,
+  AlertController,
+  ToastController,
+} from '../../../modules/ionic-standalone.modules';
 declare var wx: any;
 
 @Component({
@@ -16,6 +20,7 @@ declare var wx: any;
 })
 export class PayCompComponent implements OnInit {
   @Input('price') price!: number;
+  @Input('credit') credit!: number|undefined;//钻石
   @Input('gid') gid: string | undefined;
   @Input('orderType') orderType!: string; //订单类型
   @Input('tradeNo') tradeNo: string | undefined; //支付单号
@@ -30,7 +35,7 @@ export class PayCompComponent implements OnInit {
   codeLink?: string;
   user: Parse.Object = Parse.User.current()!;
   timer: any; //定时查询
-
+  accountLog?: Parse.Object; // 充值记录
   constructor(
     private accServ: AccountService,
     private toastController: ToastController,
@@ -78,7 +83,12 @@ export class PayCompComponent implements OnInit {
       this.tradeNo = this.accServ.setTradeNo();
     } else {
       this.orderId = await this.getOrder();
-      if(this.orderType == 'service' && !this.orderId){
+      if (this.orderType == 'service' && !this.orderId) {
+        this.tradeNo = this.accServ.setTradeNo();
+      } else if (
+        this.orderType == 'recharge' &&
+        (!this.accountLog?.id || this.accountLog?.get('isVerified'))
+      ) {
         this.tradeNo = this.accServ.setTradeNo();
       }
     }
@@ -132,6 +142,8 @@ export class PayCompComponent implements OnInit {
                   };
                   if (this.orderId) {
                     this.accServ.updateAccountLog(info, this.orderId);
+                  }else if(this.orderType == 'recharge'){
+                    this.accountLog = await this.accServ.updateRecharge(this.accountLog!)
                   }
                   _this.toast('支付成功', 'success');
                   _this.isOpen = false;
@@ -195,7 +207,7 @@ export class PayCompComponent implements OnInit {
         let codeLink = res.code_url[0];
         console.log(codeLink);
         await this.getOrderId();
-        this.updateOrder(nonce_str)
+        this.updateOrder(nonce_str);
         this.isOpen = false;
       })
       .catch((err) => {
@@ -203,7 +215,7 @@ export class PayCompComponent implements OnInit {
         this.toast(err.message, 'danger');
       });
   }
-/* 关闭支付弹窗 */
+  /* 关闭支付弹窗 */
   onClose() {
     this.isOpen = false;
     const result = {
@@ -229,9 +241,16 @@ export class PayCompComponent implements OnInit {
       if (resulte?.id) {
         this.orderId = resulte.id;
       }
+    } else if (this.orderType == 'recharge') {
+      this.accountLog = await this.accServ.updataOrder({
+        tradeNo: this.tradeNo!,
+        payType: 'wxpay',
+        price: this.price,
+        credit:this.credit!
+      });
     }
   }
-  updateOrder(nonce_str:string) {
+  updateOrder(nonce_str: string) {
     // 定时查询订单支付状态
     let that = this;
     that.timer = setInterval(() => {
@@ -241,15 +260,17 @@ export class PayCompComponent implements OnInit {
         company: this.accServ.company,
       };
       // console.log(info);
-      Parse.Cloud.run("order_status2", info)
+      Parse.Cloud.run('order_status2', info)
         .then(async (res) => {
           // console.log(res);
-          if (res.status && res.status[0] == "SUCCESS") {
+          if (res.status && res.status[0] == 'SUCCESS') {
             clearInterval(that.timer);
             if (this.orderId) {
               this.accServ.updateAccountLog(info, this.orderId);
+            }else if(this.orderType == 'recharge'){
+              this.accountLog = await this.accServ.updateRecharge(this.accountLog!)
             }
-            that.toast("支付成功",'success');
+            that.toast('支付成功', 'success');
             that.isOpen = false;
             that.payResult.emit({
               code: 200,

+ 2 - 2
projects/live-app/src/modules/account/account-log/account-log.component.html

@@ -4,12 +4,12 @@
     @for (item of list; track $index) {
     <ion-item lines="none" class="log-item">
       <ion-label>
-        <div class="title">{{ item.title }}</div>
+        <div class="title">{{ getType(item.cate) }}</div>
         <div class="time">{{ item.time }}</div>
       </ion-label>
       <div class="val">
         <div class="val-num">
-          {{ item.num }}
+          {{ item.assetCount }}
         </div>
         <div class="order-num">{{ item.orderNum }}</div>
       </div>

+ 30 - 26
projects/live-app/src/modules/account/account-log/account-log.component.ts

@@ -1,38 +1,42 @@
 import { Component, OnInit } from '@angular/core';
 import { NavComponent } from '../../../app/components/nav/nav.component';
-import {
-  ionicStandaloneModules,
-} from '../../ionic-standalone.modules';
+import { AiChatService } from '../../../services/aichart.service';
+import { ionicStandaloneModules } from '../../ionic-standalone.modules';
 @Component({
   selector: 'app-account-log',
   templateUrl: './account-log.component.html',
   styleUrls: ['./account-log.component.scss'],
   standalone: true,
-  imports: [
-    ...ionicStandaloneModules,
-    NavComponent,
-  ],
+  imports: [...ionicStandaloneModules, NavComponent],
 })
 export class AccountLogComponent implements OnInit {
-  list:Array<any> = [
-    {
-      title: '会员充值',
-      time: '2022-08-08 12:12:12',
-      num: '1000',
-      orderNum:'C20220808121212',
-      state: '已到账'
-    },
-    {
-      title: '钻石充值',
-      num: '1000',
-      time: '2022-08-08 12:12:12',
-      orderNum:'C20220808121212',
-      money: '1000',
-    }
-  ]
-  constructor() { }
-
-  ngOnInit() {
+  list: Array<any> = [
+    // {
+    //   title: '会员充值',
+    //   time: '2022-08-08 12:12:12',
+    //   num: '1000',
+    //   orderNum:'C20220808121212',
+    //   state: '已到账'
+    // },
+    // {
+    //   title: '钻石充值',
+    //   num: '1000',
+    //   time: '2022-08-08 12:12:12',
+    //   orderNum:'C20220808121212',
+    //   money: '1000',
+    // }
+  ];
+  getType(s: string): string {
+    let obj: any = {
+      recharge: '充值',
+      used: '消费',
+    };
+    return obj[s];
   }
+  constructor(private aiServ: AiChatService) {}
 
+  async ngOnInit() {
+    this.list = await this.aiServ.getAccountLog();
+    console.log(this.list);
+  }
 }

+ 1 - 0
projects/live-app/src/modules/account/recharge/recharge.component.html

@@ -45,6 +45,7 @@
     [tradeNo]="tradeNo"
     [orderType]="'balance'"
     [price]="price"
+    [credit]="price * 10"
     #paycomp
   ></app-pay-comp>
   }

+ 21 - 20
projects/live-app/src/modules/account/wattle/wattle.component.ts

@@ -3,36 +3,37 @@ import * as Parse from 'parse';
 import { Router, ActivatedRoute } from '@angular/router';
 import { NavComponent } from '../../../app/components/nav/nav.component';
 import { ionicStandaloneModules } from '../../ionic-standalone.modules';
+import { AiChatService } from '../../../services/aichart.service';
 
 @Component({
   selector: 'app-wattle',
   templateUrl: './wattle.component.html',
   styleUrls: ['./wattle.component.scss'],
   standalone: true,
-  imports: [...ionicStandaloneModules,NavComponent],
+  imports: [...ionicStandaloneModules, NavComponent],
 })
 export class WattleComponent implements OnInit {
   company: any = localStorage.getItem('company');
-  constructor(private activatRoute: ActivatedRoute,
-    private router: Router,) { }
-  account: any = {}
+  wallet:number = 0
+  constructor(
+    private activatRoute: ActivatedRoute,
+    private aiServ: AiChatService,
+    private router: Router
+  ) {}
+  account: any = {};
 
   ngOnInit() {
-    this.activatRoute.paramMap.subscribe(parms => {
-      this.getAccount()
-    })
-
+    this.activatRoute.paramMap.subscribe(async(parms) => {
+      this.getAccount();
+    });
   }
   back() {
-    this.router.navigate(['account/tabs/my'])
+    this.router.navigate(['account/tabs/my']);
   }
   async getAccount() {
-    let id = Parse.User.current()?.id
-    let Account = new Parse.Query("Account")
-    Account.equalTo("user", id)
-    Account.equalTo("company", this.company)
-    let account = await Account.first()
-    this.account = account?.toJSON()
+    let id = Parse.User.current()?.id;
+    this.account = await this.aiServ.getWallet(id!)
+    console.log(this.account);
   }
 
   // showBalance(balance:number) {
@@ -43,18 +44,18 @@ export class WattleComponent implements OnInit {
   //   }
   // }
   record() {
-    this.router.navigate(['account/log'])
+    this.router.navigate(['account/log']);
   }
   records() {
-    this.router.navigate(['account/records'])
+    this.router.navigate(['account/records']);
   }
   recharge() {
-    this.router.navigate(['account/recharge'])
+    this.router.navigate(['account/recharge']);
   }
   withdrawal() {
-    this.router.navigate(['account/withdrawal'])
+    this.router.navigate(['account/withdrawal']);
   }
   toBank() {
-    this.router.navigate(['account/bankcard'])
+    this.router.navigate(['account/bankcard']);
   }
 }

+ 1 - 1
projects/live-app/src/modules/tabs/live-review/live-review.component.html

@@ -11,7 +11,7 @@
             <div class="avatar">
               <img [src]="item.avatar" alt="">
             </div>
-            <div class="btn">点击查看主页</div>
+            <div class="btn" (click)="toUrl(item?.uid)">点击查看主页</div>
           </div>
           <div class="block">
             <!-- <div class="tag">

+ 6 - 0
projects/live-app/src/modules/tabs/live-review/live-review.component.ts

@@ -8,6 +8,7 @@ import {
   LoadingController,
 } from '../../ionic-standalone.modules';
 import { AiChatService } from '../../../services/aichart.service';
+import { Router } from '@angular/router';
 @Component({
   selector: 'app-live-review',
   templateUrl: './live-review.component.html',
@@ -18,6 +19,7 @@ import { AiChatService } from '../../../services/aichart.service';
 export class LiveReviewComponent implements OnInit {
   roomList: Array<any> = [];
   constructor(
+    private router: Router,
     private aiServ: AiChatService,
     private loadingCtrl: LoadingController,
     private connectTask: ConnectTaskService,
@@ -63,4 +65,8 @@ export class LiveReviewComponent implements OnInit {
       // console.log(event);
     });
   }
+
+  toUrl(user:string){
+    this.router.navigate(['/user/profile/',user])
+  }
 }

+ 23 - 22
projects/live-app/src/modules/tabs/tabs/tabs.component.ts

@@ -86,28 +86,29 @@ export class TabsComponent implements OnInit {
       localStorage.setItem('profile', JSON.stringify(res.toJSON()));
       return;
     }
-    // const alert = await this.alertController.create({
-    //   cssClass: 'my-custom-class',
-    //   header: '实名认证',
-    //   message: '根据相关法律法规要求,请先完成实名!',
-    //   buttons: [
-    //     {
-    //       text: '取消',
-    //       role: 'cancel',
-    //       cssClass: 'secondary',
-    //       handler: (blah) => {
-    //         console.log('Confirm Cancel: blah');
-    //       },
-    //     },
-    //     {
-    //       text: '去认证',
-    //       handler: () => {
-    //         this.router.navigate(['real']);
-    //       },
-    //     },
-    //   ],
-    // });
-    // await alert.present();
+    const alert = await this.alertController.create({
+      cssClass: 'my-custom-class',
+      header: '实名认证',
+      message: '根据相关法律法规要求,请先完成实名',
+      backdropDismiss: false,
+      buttons: [
+        // {
+        //   text: '取消',
+        //   role: 'cancel',
+        //   cssClass: 'secondary',
+        //   handler: (blah) => {
+        //     console.log('Confirm Cancel: blah');
+        //   },
+        // },
+        {
+          text: '去认证',
+          handler: () => {
+            this.router.navigate(['user/certification']);
+          },
+        },
+      ],
+    });
+    await alert.present();
   }
 
   allowNavi: boolean = true;

+ 2 - 2
projects/live-app/src/modules/user/certification/certification.component.ts

@@ -6,7 +6,7 @@ import {
   ToastController,
 } from '@ionic/angular';
 import { HttpService } from '../../../services/http.service';
-import * as utils from '../../../services/utils';
+import { identityCodeValid } from '../../../services/utils';
 import { AgreementComponent } from '../../login/agreement/agreement.component';
 import * as Parse from 'parse';
 import { NavComponent } from '../../../app/components/nav/nav.component';
@@ -96,7 +96,7 @@ export class CertificationComponent implements OnInit {
         await this.presentToast('格式错误', 1500, 'danger');
         return;
       }
-      let pass = utils.fun.IdentityCodeValid(this.idCard);
+      let pass = identityCodeValid(this.idCard);
       console.log(pass);
       if (!pass) {
         this.loading.dismiss();

+ 2 - 2
projects/live-app/src/modules/user/profile/profile.component.html

@@ -89,8 +89,8 @@
     <div class="data-row">
       <div class="title-text">个人资料</div>
       <div class="tags">
-        <span class="label">生日:未知</span>
-        <span class="label">星座:未知</span>
+        <span class="label">生日:{{birthdat}}</span>
+        <span class="label">星座:{{constellation}}</span>
         <span class="label">城市:未知</span>
       </div>
       <div class="motto">{{ profile?.get("remark") }}</div>

+ 15 - 6
projects/live-app/src/modules/user/profile/profile.component.ts

@@ -10,6 +10,7 @@ import { UploadComponent } from '../../../app/components/upload/upload.component
 import { GiftModalComponent } from '../../../app/components/gift-modal/gift-modal.component';
 import { MessageService } from '../../../services/message.service';
 import { ConnectTaskService } from '../../../services/connectTask.service';
+import { getBirthdatByIdNo,getConstellation } from '../../../services/utils';
 import {
   ionicStandaloneModules,
   AlertController,
@@ -93,15 +94,18 @@ export class ProfileComponent implements OnInit {
     };
     return map?.[this.userStatus] || map['OFFLINE'];
   }
+
+  birthdat?:string
+  constellation?:string
   ngOnInit() {
     this.activateRoute.paramMap.subscribe(async (params) => {
       let id: any = params.get('id');
       this.uid = id;
       await this.refresh();
-      if(this.uid !== this.currentUser?.id){
+      if (this.uid !== this.currentUser?.id) {
         this.userStatus = await this.connectTask.getState(this.uid, this.uid);
-      }else{
-        this.userStatus = 'ONLINE'
+      } else {
+        this.userStatus = 'ONLINE';
       }
     });
   }
@@ -139,7 +143,7 @@ export class ProfileComponent implements OnInit {
     query2.equalTo('friend', this.currentUser?.id);
     let query = Parse.Query.or(query1, query2);
     query.notEqualTo('isDeleted', true);
-    query.select('objectId', 'isPass','channel');
+    query.select('objectId', 'isPass', 'channel');
     this.friends = await query.first();
   }
   async getProfile() {
@@ -157,6 +161,8 @@ export class ProfileComponent implements OnInit {
       this.user = await queryUser.first();
     }
     console.log(this.user, this.profile);
+    this.birthdat = getBirthdatByIdNo(this.profiel?.get('idcard') || '');
+    this.constellation = getConstellation(this.profiel?.get('idcard') || '');
   }
   /* 关注状态 */
   async getFollwState() {
@@ -329,8 +335,11 @@ export class ProfileComponent implements OnInit {
     }
   }
   async sendVideoCallInvite() {
-    let second = await this.aiChatServ.get_duration(this.room?.id!,this.currentUser?.id!)
-    if(second < 120){
+    let second = await this.aiChatServ.get_duration(
+      this.room?.id!,
+      this.currentUser?.id!
+    );
+    if (second < 120) {
       const toast = await this.toastController.create({
         message: '通话时长不足2分钟,请充值后再试通',
         color: 'warning',

+ 2 - 2
projects/live-app/src/modules/user/share/share.component.ts

@@ -18,7 +18,7 @@ export class ShareComponent implements OnInit {
   imgUrl: string = '';
   //海报
   bannerUrl: string =
-    'https://file-cloud.fmode.cn/E4KpGvTEto/20231114/vot1d4114914635.jpg';
+    'https://file-cloud.fmode.cn/Qje9D4bqol/20241220/qvj1bm054428527.png';
   codeUrl: string = '';
   constructor(
     public toastController: ToastController,
@@ -58,7 +58,7 @@ export class ShareComponent implements OnInit {
     //定义图片
     ctx.drawImage(await this.compileImage(this.bannerUrl), 0, 0, 340, 540);
     //绘制二维码
-    ctx.drawImage(await this.compileImage(this.codeUrl), 95, 318, 148, 148);
+    ctx.drawImage(await this.compileImage(this.codeUrl), 80, 150, 148, 148);
     let tempSrc = canvas.toDataURL('image/png');
     this.imgUrl = tempSrc;
     document.body.removeChild(canvas);

+ 18 - 1
projects/live-app/src/services/account.service.ts

@@ -223,6 +223,7 @@ export class AccountService {
     tradeNo: string;
     payType: string;
     price: number;
+    credit:number
   }) {
     const user = Parse.User.current()!;
     //查询账户
@@ -234,6 +235,15 @@ export class AccountService {
     if (!account?.id) {
       account = await this.createdAccount(user.id);
     }
+    let query = new Parse.Query('AccountLog');
+    query.equalTo('orderNumber', param.tradeNo);
+    query.equalTo('targetAccount', account?.id);
+    query.notEqualTo('isVerified', true);
+    query.notEqualTo('isDeleted', true);
+    let alog = await query.first();
+    if (alog?.id) {
+      return alog;
+    }
     let parseAccountLog = Parse.Object.extend('AccountLog');
     let accountLog = new parseAccountLog();
     accountLog.set('isVerified', false);
@@ -258,7 +268,8 @@ export class AccountService {
     accountLog.set('desc', `${param.payType}充值${param.price}`);
     accountLog.set('assetType', 'balance');
     accountLog.set('orderType', `${param.payType}recharge`);
-    accountLog.set('assetCount', param.price);
+    accountLog.set('assetCount', param.credit);
+    accountLog.set('serviceFee', param.price)
     return await accountLog.save();
   }
   // 生成一条待支付AccountLog记录
@@ -373,4 +384,10 @@ export class AccountService {
         );
     });
   }
+
+  async updateRecharge(accountLog: Parse.Object): Promise<Parse.Object> {
+    accountLog?.set('isVerified', true);
+    await accountLog?.save();
+    return accountLog;
+  }
 }

+ 71 - 13
projects/live-app/src/services/aichart.service.ts

@@ -11,7 +11,28 @@ export class AiChatService {
   emojis: Array<any> = [];
 
   constructor(private router: Router, private http: HttpService) {
-    this.initEmoji()
+    this.initEmoji();
+  }
+  async getAccountLog(): Promise<any> {
+    const uid = Parse.User.current()?.id;
+    let query = new Parse.Query('Account');
+    query.equalTo('user', uid);
+    query.notEqualTo('isDeleted', true);
+    query.select('objectId');
+    let account = await query.first();
+    if (!account?.id) {
+      return;
+    }
+    let sql = `SELECT alog."assetCount",TO_CHAR(alog."createdAt", 'YYYY-MM-DD HH24:MI:SS') AS time,
+    (CASE WHEN alog."targetAccount" = '${account.id}' THEN 'recharge' ELSE 'used' END) cate,
+    "assetType","orderNumber","desc"
+    FROM "AccountLog" AS alog
+    WHERE (alog."targetAccount" = '${account.id}' OR alog."fromAccount" = '${account.id}')
+    AND alog."isVerified" IS TRUE
+    AND alog."isDeleted" IS NOT TRUE
+    ORDER BY alog."createdAt"`;
+    let data: any = await this.http.customSQL(sql);
+    return data?.data;
   }
   initEmoji() {
     let emojiChar =
@@ -193,11 +214,7 @@ export class AiChatService {
   }
 
   /* 赠送礼物 */
-  async putGift(
-    toUid: string,
-    gid: string,
-    giftCount?: number
-  ): Promise<any> {
+  async putGift(toUid: string, gid: string, giftCount?: number): Promise<any> {
     let baseurl = 'https://server.fmode.cn/api/ailiao/save_gift';
     let reqBody = {
       fromUid: Parse.User.current()?.id,
@@ -216,24 +233,24 @@ export class AiChatService {
     params['company'] = this.company;
     let baseurl = 'https://server.fmode.cn/api/ailiao/roomlist';
     const data = await this.http.httpRequst(baseurl, params, 'POST');
-    return data?.data
+    return data?.data;
   }
 
-  async getOrderAnchor(limit?:number){
+  async getOrderAnchor(limit?: number) {
     let sql = `SELECT us."objectId",us."nickname",us."avatar",
     COALESCE(SUM(llog.gold ),0) AS "credit"
     FROM "LoveRender" AS llog
     LEFT JOIN "_User" us
     ON us."objectId" = llog."toUser"
-    WHERE llog.company = 'Qje9D4bqol'
+    WHERE llog.company = '${this.company}'
     AND llog."isDeleted" IS NOT TRUE
     GROUP BY us."objectId",us."username"
-    ORDER BY "credit" DESC LIMIT ${limit ?? 10}`
-    let res:any = await this.http.customSQL(sql);
-    return res.data
+    ORDER BY "credit" DESC LIMIT ${limit ?? 10}`;
+    let res: any = await this.http.customSQL(sql);
+    return res.data;
   }
 
-  async get_duration(rid:string,uid:string) {
+  async get_duration(rid: string, uid: string) {
     let url = 'https://server.fmode.cn/api/ailiao/remain_second';
     let params = {
       rid: rid,
@@ -243,4 +260,45 @@ export class AiChatService {
     console.log(data);
     return data.data ?? 0;
   }
+
+  //星座
+  getConstellation(idCard: string): string {
+    // 提取出生日期部分
+    const birthDateStr = idCard.substring(6, 14);
+    const year = parseInt(birthDateStr.substring(0, 4), 10);
+    const month = parseInt(birthDateStr.substring(4, 6), 10);
+    const day = parseInt(birthDateStr.substring(6, 8), 10);
+
+    // 定义星座边界
+    const constellationBoundaries = [
+      { name: '摩羯座', start: new Date(year, 0, 20) },
+      { name: '水瓶座', start: new Date(year, 1, 19) },
+      { name: '双鱼座', start: new Date(year, 2, 20) },
+      { name: '白羊座', start: new Date(year, 3, 20) },
+      { name: '金牛座', start: new Date(year, 4, 21) },
+      { name: '双子座', start: new Date(year, 5, 21) },
+      { name: '巨蟹座', start: new Date(year, 6, 22) },
+      { name: '狮子座', start: new Date(year, 7, 23) },
+      { name: '处女座', start: new Date(year, 8, 23) },
+      { name: '天秤座', start: new Date(year, 9, 23) },
+      { name: '天蝎座', start: new Date(year, 10, 23) },
+      { name: '射手座', start: new Date(year, 11, 22) },
+      { name: '摩羯座', start: new Date(year + 1, 0, 19) }, // 用于处理12月23日及之后的情况
+    ];
+
+    // 创建输入日期对象
+    const inputDate = new Date(year, month - 1, day);
+
+    // 查找对应的星座
+    for (let i = 0; i < constellationBoundaries.length - 1; i++) {
+      if (
+        inputDate >= constellationBoundaries[i].start &&
+        inputDate < constellationBoundaries[i + 1].start
+      ) {
+        return constellationBoundaries[i].name;
+      }
+    }
+    // 默认返回摩羯座(理论上不会执行到这里)
+    return '摩羯座';
+  }
 }

+ 42 - 12
projects/live-app/src/services/utils.ts

@@ -1,11 +1,11 @@
 //身份证校验
-function IdentityCodeValid(code:string) {
+export function identityCodeValid(code:string) {
   let m = /^\d{6}((((((19|20)\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|(((19|20)\d{2})(0[13578]|1[02])31)|((19|20)\d{2})02(0[1-9]|1\d|2[0-8])|((((19|20)([13579][26]|[2468][048]|0[48]))|(2000))0229))\d{3})|((((\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|((\d{2})(0[13578]|1[02])31)|((\d{2})02(0[1-9]|1\d|2[0-8]))|(([13579][26]|[2468][048]|0[048])0229))\d{2}))(\d|X|x)$/
   return m.test(code)
 }
 
 // 手机号校验
-function isPoneAvailable(poneInput:string) {
+export function isPoneAvailable(poneInput:string) {
   var myreg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
   if (!myreg.test(poneInput)) {
     return false;
@@ -14,7 +14,7 @@ function isPoneAvailable(poneInput:string) {
   }
 }
 // 身份证号获取出生年月日
-function getBirthdatByIdNo(iIdNo:string) {
+export function getBirthdatByIdNo(iIdNo:string) {
   var tmpStr = "";
   iIdNo = iIdNo.replace(/^\s+|\s+$/g, "");
 
@@ -30,7 +30,7 @@ function getBirthdatByIdNo(iIdNo:string) {
 }
 
 // 获取性别
-function getSex(idcard:string) {
+export function getSex(idcard:string) {
   let sex = ''
   if (parseInt(idcard.substr(16, 1)) % 2 == 1) {
     sex = '男'
@@ -41,14 +41,44 @@ function getSex(idcard:string) {
 }
 
 // 微信号校验
-function authCode(str:string){
+export function authCode(str:string){
   let length = str.replace(/\s/g,"").length
   return length
 }
-export const fun = {
-  IdentityCodeValid,
-  isPoneAvailable,
-  getBirthdatByIdNo,
-  getSex,
-  authCode
-}
+//星座
+export function getConstellation(idCard: string): string {
+  // 提取出生日期部分
+  const birthDateStr = idCard.substring(6, 14);
+  const year = parseInt(birthDateStr.substring(0, 4), 10);
+  const month = parseInt(birthDateStr.substring(4, 6), 10);
+  const day = parseInt(birthDateStr.substring(6, 8), 10);
+
+  // 定义星座边界
+  const constellationBoundaries = [
+    { name: '摩羯座', start: new Date(year, 0, 20) },
+    { name: '水瓶座', start: new Date(year, 1, 19) },
+    { name: '双鱼座', start: new Date(year, 2, 20) },
+    { name: '白羊座', start: new Date(year, 3, 20) },
+    { name: '金牛座', start: new Date(year, 4, 21) },
+    { name: '双子座', start: new Date(year, 5, 21) },
+    { name: '巨蟹座', start: new Date(year, 6, 22) },
+    { name: '狮子座', start: new Date(year, 7, 23) },
+    { name: '处女座', start: new Date(year, 8, 23) },
+    { name: '天秤座', start: new Date(year, 9, 23) },
+    { name: '天蝎座', start: new Date(year, 10, 23) },
+    { name: '射手座', start: new Date(year, 11, 22) },
+    { name: '摩羯座', start: new Date(year + 1, 0, 19) } // 用于处理12月23日及之后的情况
+  ];
+
+  // 创建输入日期对象
+  const inputDate = new Date(year, month - 1, day);
+
+  // 查找对应的星座
+  for (let i = 0; i < constellationBoundaries.length - 1; i++) {
+    if (inputDate >= constellationBoundaries[i].start && inputDate < constellationBoundaries[i + 1].start) {
+      return constellationBoundaries[i].name;
+    }
+  }
+  // 默认返回摩羯座(理论上不会执行到这里)
+  return '摩羯座';
+}