xiongzhu 3 سال پیش
والد
کامیت
17da1bce1b
3فایلهای تغییر یافته به همراه7 افزوده شده و 4 حذف شده
  1. 1 1
      src/membership/entities/member-order.entity.ts
  2. 4 2
      src/membership/membership.service.ts
  3. 2 1
      src/notify/notify.service.ts

+ 1 - 1
src/membership/entities/member-order.entity.ts

@@ -7,7 +7,7 @@ export enum MemberOrderStatus {
 }
 
 export enum PayMethod {
-    WEIXIN = 'WEIXIN',
+    WECHAT = 'WECHAT',
     ALIPAY = 'ALIPAY'
 }
 

+ 4 - 2
src/membership/membership.service.ts

@@ -5,7 +5,7 @@ import { Repository } from 'typeorm'
 import { MemberPlan } from './entities/memberPlan.entity'
 import { addDays } from 'date-fns'
 import { MemberPlanDto } from './dto/memberPlan.dto'
-import { MemberOrder, MemberOrderStatus } from './entities/member-order.entity'
+import { MemberOrder, MemberOrderStatus, PayMethod } from './entities/member-order.entity'
 import { WeixinService } from 'src/weixin/weixin.service'
 import { Attach, AttachType } from 'src/weixin/dto/attach.dto'
 @Injectable()
@@ -89,7 +89,7 @@ export class MembershipService {
         )
     }
 
-    async orderNotify(orderId: number) {
+    async orderNotify(orderId: number, transactionId: string, payMethod: PayMethod) {
         const order: MemberOrder = await this.memberOrderRepository.findOneBy({
             id: orderId
         })
@@ -104,6 +104,8 @@ export class MembershipService {
         }
         order.status = MemberOrderStatus.FINISH
         order.finishTime = new Date()
+        order.transactionId = transactionId
+        order.payMethod = payMethod
         await this.memberOrderRepository.save(order)
         await this.renewMembership(order.userId, order.planId)
     }

+ 2 - 1
src/notify/notify.service.ts

@@ -2,6 +2,7 @@ import { MembershipService } from './../membership/membership.service'
 import { Injectable } from '@nestjs/common'
 import { Attach, AttachType } from '../weixin/dto/attach.dto'
 import { WeixinService } from '../weixin/weixin.service'
+import { PayMethod } from 'src/membership/entities/member-order.entity'
 
 @Injectable()
 export class NotifyService {
@@ -13,7 +14,7 @@ export class NotifyService {
             if (!data.attach) return
             const attach: Attach = JSON.parse(data.attach)
             if (attach.type === AttachType.MEMBER_ORDER) {
-                await this.membershipService.orderNotify(attach.id)
+                await this.membershipService.orderNotify(attach.id, data.transaction_id, PayMethod.WECHAT)
             }
         }
     }