@certd/commercial-core 1.36.18 → 1.36.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.36.20](https://github.com/certd/certd/compare/v1.36.19...v1.36.20) (2025-09-13)
7
+
8
+ **Note:** Version bump only for package @certd/commercial-core
9
+
10
+ ## [1.36.19](https://github.com/certd/certd/compare/v1.36.18...v1.36.19) (2025-09-05)
11
+
12
+ **Note:** Version bump only for package @certd/commercial-core
13
+
6
14
  ## [1.36.18](https://github.com/certd/certd/compare/v1.36.17...v1.36.18) (2025-08-28)
7
15
 
8
16
  **Note:** Version bump only for package @certd/commercial-core
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{PrimaryGeneratedColumn as e,Column as t,Entity as i,Repository as s,Or as r,Equal as n,MoreThan as o,LessThan as a,In as p}from"typeorm";import{Provide as d,Scope as y,ScopeEnum as u,Inject as c,Logger as m,Configuration as g,Post as l,Body as S,ALL as v,Controller as h,Query as w,Get as f,Param as P}from"@midwayjs/core";import{InjectEntityModel as b}from"@midwayjs/typeorm";import{BaseService as I,SysSuiteSetting as T,NeedSuiteException as x,SysSettingsService as N,SysInstallInfo as C,SysPaymentSetting as O,AccessService as F,BaseController as E,SysHeaderMenus as D,SysSiteInfo as B,FileService as _,CrudController as j,Constants as k}from"@certd/lib-server";import U from"dayjs";import{utils as M,logger as R}from"@certd/basic";import{isComm as $,checkComm as A}from"@certd/plus-core";import*as q from"lodash-es";import{merge as G,remove as L}from"lodash-es";function J(e,t,i,s){var r,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,i,o):r(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o}function V(e,t){return function(i,s){t(i,s,e)}}function W(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}"function"==typeof SuppressedError&&SuppressedError;let z=class{id;userId;productId;tradeNo;duration;title;desc;num;price;amount;remark;status;payType;payTime;payNo;endTime;createTime;updateTime};var Y;J([e(),W("design:type",Number)],z.prototype,"id",void 0),J([t({name:"user_id",comment:"用户id"}),W("design:type",Number)],z.prototype,"userId",void 0),J([t({name:"product_id",comment:"商品Id"}),W("design:type",Number)],z.prototype,"productId",void 0),J([t({name:"trade_no",comment:"交易号"}),W("design:type",String)],z.prototype,"tradeNo",void 0),J([t({name:"duration",comment:"时长"}),W("design:type",Number)],z.prototype,"duration",void 0),J([t({name:"title",comment:"商品名称"}),W("design:type",String)],z.prototype,"title",void 0),J([t({name:"desc",comment:"商品描述"}),W("design:type",String)],z.prototype,"desc",void 0),J([t({name:"num",comment:"商品数量"}),W("design:type",Number)],z.prototype,"num",void 0),J([t({name:"price",comment:"单价"}),W("design:type",Number)],z.prototype,"price",void 0),J([t({name:"amount",comment:"总价"}),W("design:type",Number)],z.prototype,"amount",void 0),J([t({name:"remark",comment:"备注"}),W("design:type",String)],z.prototype,"remark",void 0),J([t({name:"status",comment:"状态"}),W("design:type",String)],z.prototype,"status",void 0),J([t({name:"pay_type",comment:"支付类型"}),W("design:type",String)],z.prototype,"payType",void 0),J([t({name:"pay_time",comment:"支付时间"}),W("design:type",Number)],z.prototype,"payTime",void 0),J([t({name:"pay_no",comment:"支付单号"}),W("design:type",String)],z.prototype,"payNo",void 0),J([t({name:"end_time",comment:"结束时间"}),W("design:type",Number)],z.prototype,"endTime",void 0),J([t({name:"create_time",comment:"创建时间",default:()=>"CURRENT_TIMESTAMP"}),W("design:type",Date)],z.prototype,"createTime",void 0),J([t({name:"update_time",comment:"修改时间",default:()=>"CURRENT_TIMESTAMP"}),W("design:type",Date)],z.prototype,"updateTime",void 0),z=J([i("cd_trade")],z);let H=Y=class{id;icon;title;type;content;durationPrices;duration;price;intro;order;supportBuy;disabled;createTime;updateTime;static getSuiteContent(e){return JSON.parse(e.content||"{}")}static setSuiteContent(e,t){e.content=JSON.stringify(t||{})}static getDurationPrices(e){return JSON.parse(e.durationPrices||"[]")}static setDurationPrices(e,t){if(0===t.length)throw new Error("prices must not be empty");e.duration=t[0].duration,e.price=t[0].price,e.durationPrices=JSON.stringify(t)}static getContentStr(e){let t="";const i=Y.getSuiteContent(e);return-1===i.maxDomainCount?t+="域名无限制;":t+=`域名${i.maxDomainCount}个;`,-1===i.maxPipelineCount?t+="流水线无限制;":t+=`流水线${i.maxPipelineCount}个;`,-1===i.maxDeployCount?t+="部署次数无限制;":t+=`部署${i.maxDeployCount}次;`,t}};J([e(),W("design:type",Number)],H.prototype,"id",void 0),J([t({name:"icon",comment:"图标"}),W("design:type",String)],H.prototype,"icon",void 0),J([t({name:"title",comment:"套餐名称"}),W("design:type",String)],H.prototype,"title",void 0),J([t({name:"type",comment:"套餐类型,套餐/加量包,suite/addon"}),W("design:type",String)],H.prototype,"type",void 0),J([t({name:"content",comment:"套餐内容"}),W("design:type",String)],H.prototype,"content",void 0),J([t({name:"duration_prices",comment:"时长及单价"}),W("design:type",String)],H.prototype,"durationPrices",void 0),J([t({name:"duration",comment:"时长"}),W("design:type",Number)],H.prototype,"duration",void 0),J([t({name:"price",comment:"单价"}),W("design:type",Number)],H.prototype,"price",void 0),J([t({name:"intro",comment:"说明"}),W("design:type",String)],H.prototype,"intro",void 0),J([t({name:"order",comment:"排序"}),W("design:type",Number)],H.prototype,"order",void 0),J([t({name:"support_buy",comment:"是否支持购买",default:!0}),W("design:type",Boolean)],H.prototype,"supportBuy",void 0),J([t({name:"disabled",comment:"禁用启用"}),W("design:type",Boolean)],H.prototype,"disabled",void 0),J([t({name:"create_time",comment:"创建时间",default:()=>"CURRENT_TIMESTAMP"}),W("design:type",Date)],H.prototype,"createTime",void 0),J([t({name:"update_time",comment:"修改时间",default:()=>"CURRENT_TIMESTAMP"}),W("design:type",Date)],H.prototype,"updateTime",void 0),H=Y=J([i("cd_product")],H);let Q=class{id;userId;productId;tradeId;icon;title;productType;content;duration;deployCountUsed;activeTime;expiresTime;disabled;isPresent;isBootstrap;isEmpty;createTime;updateTime;static getContent(e){return JSON.parse(e.content||"{}")}};J([e(),W("design:type",Number)],Q.prototype,"id",void 0),J([t({name:"user_id",comment:"用户ID"}),W("design:type",Number)],Q.prototype,"userId",void 0),J([t({name:"product_id",comment:"套餐ID"}),W("design:type",Number)],Q.prototype,"productId",void 0),J([t({name:"trade_id",comment:"订单id"}),W("design:type",Number)],Q.prototype,"tradeId",void 0),J([t({name:"icon",comment:"图标"}),W("design:type",String)],Q.prototype,"icon",void 0),J([t({name:"title",comment:"套餐名称"}),W("design:type",String)],Q.prototype,"title",void 0),J([t({name:"product_type",comment:"套餐类型,套餐/加量包,suite/addon"}),W("design:type",String)],Q.prototype,"productType",void 0),J([t({name:"content",comment:"套餐内容"}),W("design:type",String)],Q.prototype,"content",void 0),J([t({name:"duration",comment:"有效时长"}),W("design:type",Number)],Q.prototype,"duration",void 0),J([t({name:"deploy_count_used",comment:"已使用部署次数"}),W("design:type",Number)],Q.prototype,"deployCountUsed",void 0),J([t({name:"active_time",comment:"激活时间"}),W("design:type",Number)],Q.prototype,"activeTime",void 0),J([t({name:"expires_time",comment:"有效期"}),W("design:type",Number)],Q.prototype,"expiresTime",void 0),J([t({name:"disabled",comment:"启用/禁用",default:!1}),W("design:type",Boolean)],Q.prototype,"disabled",void 0),J([t({name:"is_present",comment:"是否赠送",default:!1}),W("design:type",Boolean)],Q.prototype,"isPresent",void 0),J([t({name:"is_bootstrap",comment:"是否初始套餐",default:!1}),W("design:type",Boolean)],Q.prototype,"isBootstrap",void 0),J([t({name:"is_empty",comment:"是否用完",default:!1}),W("design:type",Boolean)],Q.prototype,"isEmpty",void 0),J([t({name:"create_time",comment:"创建时间",default:()=>"CURRENT_TIMESTAMP"}),W("design:type",Date)],Q.prototype,"createTime",void 0),J([t({name:"update_time",comment:"修改时间",default:()=>"CURRENT_TIMESTAMP"}),W("design:type",Date)],Q.prototype,"updateTime",void 0),Q=J([i("cd_user_suite")],Q);let K=class extends I{repository;getRepository(){return this.repository}};J([b(H),W("design:type",s)],K.prototype,"repository",void 0),K=J([d(),y(u.Request,{allowDowngrade:!0})],K);class X{async createByPaymentType(e,t){return new(await this.getProviderCls(e))(t)}async getProviderCls(e){switch(e){case"alipay":return(await import("./alipay-c5b40806.js")).PaymentAlipay;case"wxpay":return(await import("./wxpay-2de8b4e9.js")).PaymentWxpay;case"yizhifu":return(await import("./yizhifu-907f6eb0.js")).PaymentYizhifu;default:throw new Error("不支持的支付方式:"+e)}}async getDefine(e){return(await this.getProviderCls(e)).getDefine()}}const Z=new X;let ee=class extends I{repository;myCountService;sysSettingsService;productService;getRepository(){return this.repository}async presentGiftSuite(e){if(!e)return!1;if(!$())return!1;const t=await this.getSuiteSetting();return!!t&&(!!t.enabled&&(!!t.registerGift?.productId&&await M.locker.execute(`presentGiftSuite:${e}`,(async()=>{if(await this.getRepository().count({where:{userId:e,isPresent:!0}})>0)return!1;const i=await this.productService.info(t.registerGift.productId);return!!i&&(R.info(`注册赠送套餐:userId=${e},suite=${i.title}`),await this.productToUserSuite({userId:e,product:i,duration:t.registerGift.duration,isPresent:!0,isBootstrap:!0}),!0)}))))}async productToUserSuite(e){const{duration:t,userId:i,product:s,tradeId:r,entityManager:n}=e,o=U(),a=o.valueOf();let p=0;p=-1===t?-1:o.add(t,"day").endOf("day").valueOf();const d=new Q;d.userId=i,d.productId=s.id,d.tradeId=r||0,d.icon="",d.title=s.title,d.productType=s.type,d.content=s.content,d.duration=t,d.deployCountUsed=0,d.disabled=!1,d.activeTime=a,d.expiresTime=p,d.isPresent=e.isPresent||!1,d.isBootstrap=e.isBootstrap||!1,n?await n.save(d):await this.getRepository().save(d)}async getMySuiteDetail(e){const t=await this.sysSettingsService.getSetting(T);let i=await this.getMyValidSuiteList(e);if(!i||0===i.length){await this.presentGiftSuite(e)&&(i=await this.getMyValidSuiteList(e))}i&&0!==i.length||(i=[]);const s={max:0,used:0},r={max:0,used:0},n={max:0,used:0},o={max:0,used:0},a=[];if(i.length>0)for(const e of i){a.push({id:e.id,productId:e.productId,duration:e.duration,title:e.title,expiresTime:e.expiresTime,productType:e.productType});const t=Q.getContent(e);-1==s.max||-1==t.maxPipelineCount?s.max=-1:s.max+=t.maxPipelineCount??0,-1==r.max||-1==t.maxDomainCount?r.max=-1:r.max+=t.maxDomainCount??0,-1==n.max||-1==t.maxDeployCount?n.max=-1:n.max+=t.maxDeployCount??0,-1==o.max||-1==t.maxMonitorCount?o.max=-1:o.max+=t.maxMonitorCount??0,n.used+=e.deployCountUsed??0}const{pipelineCountUsed:p,domainCountUsed:d,monitorCountUsed:y}=await this.myCountService.getUsedCount(e);return s.used=p??0,r.used=d??0,o.used=y??0,{enabled:t.enabled,suites:a,expiresTime:0,pipelineCount:s,domainCount:r,deployCount:n,monitorCount:o}}async getMyValidSuiteList(e){if(!e)throw new Error("用户ID不能为空");const t=U(),i=await this.getMyValidSuite(e,t),s=await this.getMyValidAddons(e,t);return i?[i,...s]:s}async getMyValidSuite(e,t){return await this.getRepository().findOne({where:{userId:e,expiresTime:r(n(-1),o(t.valueOf())),activeTime:a(t.valueOf()),disabled:!1,productType:"suite"},order:{id:"DESC"}})}async getMyValidAddons(e,t){return await this.getRepository().find({where:{userId:e,expiresTime:r(n(-1),o(t.valueOf())),activeTime:a(t.valueOf()),disabled:!1,productType:"addon",isEmpty:!1},order:{expiresTime:"ASC",id:"ASC"}})}async checkHasDeployCount(e,t=1){t<=0&&(t=1);if(!(await this.getSuiteSetting()).enabled)return null;const i=await this.getMyValidSuiteList(e);i.sort(((e,t)=>e.expiresTime-t.expiresTime));for(const e of i){const i=Q.getContent(e);if(-1==i.maxDeployCount||i.maxDeployCount>=e.deployCountUsed+t)return e}throw new x("部署次数不足,请购买加量包或升级套餐")}async consumeDeployCount(e,t){if(null==e)return;e.deployCountUsed+=t;const i=Q.getContent(e);if(-1!=i.maxDeployCount&&e.deployCountUsed>=i.maxDeployCount){this.isOnlyDeployCount(i)&&(e.isEmpty=!0)}const s={deployCountUsed:()=>`deployCountUsed + ${t}`};e.isEmpty&&(s.isEmpty=!0),await this.repository.createQueryBuilder().update(Q).set(s).where("id = :suiteId",{suiteId:e.id}).execute()}checkHasInfinite(e){const t=Object.keys(e);for(const i of t)if(i.startsWith("max")&&-1==e[i])return!0;return!1}getSuiteSetting(){return this.sysSettingsService.getSetting(T)}isOnlyDeployCount(e){const t=Object.keys(e);for(const i of t)if(i.startsWith("max")&&"maxDeployCount"!=i&&0!=e[i])return!1;return-1!==e.maxDeployCount}async presentSuite(e){A();if(!(await this.getSuiteSetting()).enabled)throw new Error("套餐功能未开启");const t=await this.productService.info(e.productId);if(!t)throw new Error("产品不存在");const i=H.getDurationPrices(t).find((t=>t.duration===e.duration));if(!i)throw new Error("套餐时长不存在");await this.productToUserSuite({userId:e.userId,product:t,duration:i.duration,isPresent:!0})}};J([b(Q),W("design:type",s)],ee.prototype,"repository",void 0),J([c("myCountService"),W("design:type",Object)],ee.prototype,"myCountService",void 0),J([c(),W("design:type",N)],ee.prototype,"sysSettingsService",void 0),J([c(),W("design:type",K)],ee.prototype,"productService",void 0),ee=J([d("userSuiteService"),y(u.Request,{allowDowngrade:!0})],ee);let te=class extends I{repository;productService;sysSettingsService;accessService;userSuiteService;getRepository(){return this.repository}async createFree(e){const t=await this.getBuyableProduct(e.productId),{price:i}=this.findDurationPrice(t,e.duration);if(0!==i)throw new Error("产品价格不为0");const s=await this.create({productId:e.productId,duration:e.duration,num:e.num,payType:e.payType,userId:e.userId});await this.onPaid({tradeNo:s.tradeNo,status:"paid",amount:0,payNo:"free",remark:"免费赠送",payTime:U().valueOf()})}findDurationPrice(e,t){const i=JSON.parse(e.durationPrices||"[]").find((e=>e.duration===t));if(!i)throw new Error(`产品时长${t}不存在`);return i}async create(e){const t=await this.getBuyableProduct(e.productId),{price:i}=this.findDurationPrice(t,e.duration),s=U(),r="T"+s.format("YYYYMMDD")+s.unix()+M.id.randomNumber(6),n=`购买${t.title} ${e.duration}天`,o=`内含:${H.getContentStr(t)}`,a=new z;return a.title=n,a.desc=o,a.productId=e.productId,a.duration=e.duration,a.num=e.num,a.userId=e.userId,a.tradeNo=r,a.duration=e.duration,a.price=i,a.title=t.title,a.amount=a.price*a.num,a.status="wait_pay",a.payType=e.payType,await this.repository.save(a)}async getBuyableProduct(e){const t=await this.productService.info(e);if(!t)throw new Error("产品不存在");if(t.disabled)throw new Error("该产品已下架");if(!t.supportBuy)throw new Error("该产品不支持购买");return t}async buildPaymentReq(e,t){const i=await this.sysSettingsService.getSetting(C);let s=i?.bindUrl;if(!s)throw new Error("未绑定URL");s.endsWith("/")&&(s=s.slice(0,-1));const r=await this.getPaymentByType(e.payType);return await r.createOrder(e,{bindUrl:s,clientIp:t})}async getPaymentByType(e){const t=(await this.sysSettingsService.getSetting(O))[e];if(!t||!t.enabled)throw new Error(`支付方式${e}未启用`);const i=await this.accessService.getById(t.accessId,0);if(!i)throw new Error(`支付方式${e}未设置授权`);return await Z.createByPaymentType(e,i)}async getByTradeNo(e){if(!e)throw new Error("out_trade_no不能为空");return await this.repository.findOne({where:{tradeNo:e}})}async onPaid(e){const t=await this.getByTradeNo(e.tradeNo);if(!t)throw new Error(`订单${e.tradeNo}不存在`);if("paid"!==t.status){if("wait_pay"!==t.status)throw new Error(`订单${e.tradeNo}状态不正确, 当前状态为${t.status}`);if(t.amount!==e.amount)throw new Error(`订单${e.tradeNo}金额不正确, 当前金额为${t.amount},实际支付金额为${e.amount}`);await this.transaction((async i=>{await i.update(z,{id:t.id},{status:"paid",amount:e.amount,remark:e.remark,payNo:e.payNo,payTime:e.payTime||U().valueOf()});const s=await this.productService.info(t.productId);if(!s)throw new Error("产品不存在");const r=t.id,n=t.userId,o=t.duration;await this.userSuiteService.productToUserSuite({duration:o,userId:n,product:s,tradeId:r,entityManager:i})}))}}async syncStatus(e){const t=await this.info(e);if(!t)throw new Error("订单不存在");if("paid"===t.status)return;const i=await this.getPaymentByType(t.payType),s=await i.getDetail(t.tradeNo);if(!s)throw new Error("订单不存在");"paid"===s.status?await this.onPaid(s):"closed"===s.status&&await this.transaction((async e=>{await e.update(z,{id:t.id},{status:"closed",remark:s.remark})}))}async updatePaid(e,t){const i=await this.info(e);if(!i)throw new Error("订单不存在");"paid"!==i.status&&await this.onPaid({tradeNo:i.tradeNo,status:"paid",amount:i.amount,payNo:"",remark:`手动确认支付:${t}`,payTime:U().valueOf()})}};J([b(z),W("design:type",s)],te.prototype,"repository",void 0),J([c(),W("design:type",K)],te.prototype,"productService",void 0),J([c(),W("design:type",N)],te.prototype,"sysSettingsService",void 0),J([c(),W("design:type",F)],te.prototype,"accessService",void 0),J([c(),W("design:type",ee)],te.prototype,"userSuiteService",void 0),te=J([d(),y(u.Request,{allowDowngrade:!0})],te);let ie=class{logger;async onReady(e){this.logger.info("commercial start")}};J([m(),W("design:type",Object)],ie.prototype,"logger",void 0),ie=J([g({namespace:"commercial"})],ie);let se=class extends E{sysSettingsService;async paymentGet(){const e=await this.sysSettingsService.getSetting(O);return this.ok(e)}async paymentSave(e){A();const t=new O;return G(t,e),await this.sysSettingsService.saveSetting(t),this.ok({})}async suiteGet(){const e=await this.sysSettingsService.getSetting(T);return this.ok(e)}async suiteSave(e){A();const t=new T;return G(t,e),await this.sysSettingsService.saveSetting(t),this.ok({})}async headerMenusGet(){const e=await this.sysSettingsService.getSetting(D);return this.ok(e)}async headerMenusSave(e){A();const t=new D;return G(t,e),await this.sysSettingsService.saveSetting(t),this.ok({})}};J([c(),W("design:type",N)],se.prototype,"sysSettingsService",void 0),J([l("/payment/get",{summary:"sys:settings:view"}),W("design:type",Function),W("design:paramtypes",[]),W("design:returntype",Promise)],se.prototype,"paymentGet",null),J([l("/payment/save",{summary:"sys:settings:edit"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],se.prototype,"paymentSave",null),J([l("/suite/get",{summary:"sys:settings:view"}),W("design:type",Function),W("design:paramtypes",[]),W("design:returntype",Promise)],se.prototype,"suiteGet",null),J([l("/suite/save",{summary:"sys:settings:edit"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],se.prototype,"suiteSave",null),J([l("/headerMenus/get",{summary:"sys:settings:view"}),W("design:type",Function),W("design:paramtypes",[]),W("design:returntype",Promise)],se.prototype,"headerMenusGet",null),J([l("/headerMenus/save",{summary:"sys:settings:edit"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],se.prototype,"headerMenusSave",null),se=J([d(),h("/api/sys/settings")],se);let re=class extends E{sysSettingsService;fileService;async saveSiteInfo(e){A();let t=await this.sysSettingsService.getSetting(B);return null==t&&(t=new B),q.merge(t,e),t.logo&&(t.logo=await this.fileService.saveFile(this.getUserId(),t.logo,"public")),t.loginLogo&&(t.loginLogo=await this.fileService.saveFile(this.getUserId(),t.loginLogo,"public")),await this.sysSettingsService.saveSetting(t),this.ok(t)}async getSiteInfo(){A();const e=await this.sysSettingsService.getSetting(B);return this.ok(e)}};J([c(),W("design:type",N)],re.prototype,"sysSettingsService",void 0),J([c(),W("design:type",_)],re.prototype,"fileService",void 0),J([l("/save",{summary:"sys:settings:edit"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],re.prototype,"saveSiteInfo",null),J([l("/get",{summary:"sys:settings:view"}),W("design:type",Function),W("design:paramtypes",[]),W("design:returntype",Promise)],re.prototype,"getSiteInfo",null),re=J([d(),h("/api/sys/site")],re);let ne=class extends j{service;getService(){return A(),this.service}async page(e){return await super.page(e)}async list(e){return await super.list(e)}async add(e){return await super.add(e)}async update(e){return await super.update(e)}async info(e){return await super.info(e)}async delete(e){return await super.delete(e)}async syncStatus(e){return await this.service.syncStatus(e),this.ok()}async updatePaid(e){const t=await this.getLoginUser();return await this.service.updatePaid(e,t.id+"_"+t.username),this.ok()}async deleteByIds(e){const t=await this.getUserId();if(!e||0===e.length)throw new Error("ids不能为空");return await this.service.deleteWhere({id:e,userId:t}),this.ok()}};J([c(),W("design:type",te)],ne.prototype,"service",void 0),J([l("/page",{summary:"sys:settings:view"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],ne.prototype,"page",null),J([l("/list",{summary:"sys:settings:view"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],ne.prototype,"list",null),J([l("/add",{summary:"sys:settings:edit"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],ne.prototype,"add",null),J([l("/update",{summary:"sys:settings:edit"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],ne.prototype,"update",null),J([l("/info",{summary:"sys:settings:view"}),V(0,w("id")),W("design:type",Function),W("design:paramtypes",[Number]),W("design:returntype",Promise)],ne.prototype,"info",null),J([l("/delete",{summary:"sys:settings:edit"}),V(0,w("id")),W("design:type",Function),W("design:paramtypes",[Number]),W("design:returntype",Promise)],ne.prototype,"delete",null),J([l("/syncStatus",{summary:"sys:settings:edit"}),V(0,S("id")),W("design:type",Function),W("design:paramtypes",[Number]),W("design:returntype",Promise)],ne.prototype,"syncStatus",null),J([l("/updatePaid",{summary:"sys:settings:edit"}),V(0,S("id")),W("design:type",Function),W("design:paramtypes",[Number]),W("design:returntype",Promise)],ne.prototype,"updatePaid",null),J([l("/deleteByIds",{summary:"sys:settings:edit"}),V(0,S("ids")),W("design:type",Function),W("design:paramtypes",[Array]),W("design:returntype",Promise)],ne.prototype,"deleteByIds",null),ne=J([d(),h("/api/sys/suite/trade")],ne);let oe=class extends j{service;getService(){return A(),this.service}async page(e){return await super.page(e)}async list(e){return await super.list(e)}async add(e){return await super.add(e)}async update(e){return await super.update(e)}async info(e){return await super.info(e)}async delete(e){return await super.delete(e)}async deleteByIds(e){return await super.deleteByIds(e)}};J([c(),W("design:type",K)],oe.prototype,"service",void 0),J([l("/page",{summary:"sys:settings:view"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],oe.prototype,"page",null),J([l("/list",{summary:"sys:settings:view"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],oe.prototype,"list",null),J([l("/add",{summary:"sys:settings:edit"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],oe.prototype,"add",null),J([l("/update",{summary:"sys:settings:edit"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],oe.prototype,"update",null),J([l("/info",{summary:"sys:settings:view"}),V(0,w("id")),W("design:type",Function),W("design:paramtypes",[Number]),W("design:returntype",Promise)],oe.prototype,"info",null),J([l("/delete",{summary:"sys:settings:edit"}),V(0,w("id")),W("design:type",Function),W("design:paramtypes",[Number]),W("design:returntype",Promise)],oe.prototype,"delete",null),J([l("/deleteByIds",{summary:"sys:settings:edit"}),V(0,S("ids")),W("design:type",Function),W("design:paramtypes",[Array]),W("design:returntype",Promise)],oe.prototype,"deleteByIds",null),oe=J([d(),h("/api/sys/suite/product")],oe);let ae=class extends j{getService(){return this.userSuiteService}productService;userSuiteService;sysSettingsService;async page(e){return A(),await super.page(e)}async list(e){return await super.list(e)}async add(e){return A(),await super.add(e)}async update(e){return await super.update(e)}async info(e){return await super.info(e)}async delete(e){return await super.delete(e)}async deleteByIds(e){return await super.deleteByIds(e)}async presentSuite(e){return await this.userSuiteService.presentSuite({userId:e.userId,productId:e.productId,duration:e.duration}),this.ok()}};J([c(),W("design:type",K)],ae.prototype,"productService",void 0),J([c(),W("design:type",ee)],ae.prototype,"userSuiteService",void 0),J([c(),W("design:type",N)],ae.prototype,"sysSettingsService",void 0),J([l("/page",{summary:"sys:settings:view"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],ae.prototype,"page",null),J([l("/list",{summary:"sys:settings:view"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],ae.prototype,"list",null),J([l("/add",{summary:"sys:settings:edit"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],ae.prototype,"add",null),J([l("/update",{summary:"sys:settings:edit"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],ae.prototype,"update",null),J([l("/info",{summary:"sys:settings:view"}),V(0,w("id")),W("design:type",Function),W("design:paramtypes",[Number]),W("design:returntype",Promise)],ae.prototype,"info",null),J([l("/delete",{summary:"sys:settings:edit"}),V(0,w("id")),W("design:type",Function),W("design:paramtypes",[Number]),W("design:returntype",Promise)],ae.prototype,"delete",null),J([l("/deleteByIds",{summary:"sys:settings:edit"}),V(0,S("ids")),W("design:type",Function),W("design:paramtypes",[Array]),W("design:returntype",Promise)],ae.prototype,"deleteByIds",null),J([l("/presentSuite",{summary:"sys:settings:edit"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],ae.prototype,"presentSuite",null),ae=J([d(),h("/api/sys/suite/user-suite")],ae);let pe=class extends E{productService;async list(){A();const e=await this.productService.list({query:{disabled:!1,supportBuy:!0},sort:{prop:"order",asc:!0}});for(const t of e)t.durationPrices=JSON.parse(t.durationPrices||"[]"),t.content=JSON.parse(t.content||"{}");return L(e,(e=>!0===e.isBootstrap)),this.ok(e)}};J([c(),W("design:type",K)],pe.prototype,"productService",void 0),J([l("/list",{summary:k.per.authOnly}),W("design:type",Function),W("design:paramtypes",[]),W("design:returntype",Promise)],pe.prototype,"list",null),pe=J([d(),h("/api/suite/product")],pe);let de=class extends E{productService;tradeService;sysSettingsService;async create(e){A();const{productId:t,duration:i,num:s,payType:r}=e,n=await this.tradeService.create({productId:t,duration:i,num:s,payType:r,userId:this.getUserId()}),o=this.ctx.request.ip,a=await this.tradeService.buildPaymentReq(n,o);return this.ok(a)}async createFree(e){A();const{productId:t,duration:i,num:s}=e,r=await this.tradeService.createFree({productId:t,duration:i,num:s,payType:"free",userId:this.getUserId()});return this.ok(r)}async info(e){const t=await this.tradeService.info(e.tradeId);return this.ok(t)}async page(e){e.query=e.query||{};e.query.userId=this.getUserId();const t=await this.tradeService.page(e);return this.ok(t)}async payments(){const e=await this.sysSettingsService.getSetting(O),t=[];return e.yizhifu&&e.yizhifu.enabled&&t.push({value:"yizhifu",label:"易支付",icon:"material-symbols:shield-outline"}),e.alipay&&e.alipay.enabled&&t.push({value:"alipay",label:"支付宝",icon:"ant-design:alipay-circle-filled"}),e.wxpay&&e.wxpay.enabled&&t.push({value:"wxpay",label:"微信",icon:"ant-design:wechat-filled"}),this.ok(t)}async syncStatus(e){const t=await this.tradeService.info(e);return t?t.userId!=this.getUserId()?this.fail("无权操作该交易订单"):("paid"===t.status||await this.tradeService.syncStatus(e),this.ok()):this.fail("交易订单不存在")}async delete(e){const t=this.getUserId();if(!e)throw new Error("id不能为空");return await this.tradeService.deleteWhere({id:e,userId:t}),this.ok()}async deleteByIds(e){const t=this.getUserId();if(!e||0===e.length)throw new Error("id不能为空");return await this.tradeService.deleteWhere({id:p(e),userId:t}),this.ok()}};J([c(),W("design:type",K)],de.prototype,"productService",void 0),J([c(),W("design:type",te)],de.prototype,"tradeService",void 0),J([c(),W("design:type",N)],de.prototype,"sysSettingsService",void 0),J([l("/create",{summary:k.per.authOnly}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],de.prototype,"create",null),J([l("/createFree",{summary:k.per.authOnly}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],de.prototype,"createFree",null),J([l("/info",{summary:k.per.authOnly}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],de.prototype,"info",null),J([l("/page",{summary:k.per.authOnly}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],de.prototype,"page",null),J([l("/payments",{summary:k.per.authOnly}),W("design:type",Function),W("design:paramtypes",[]),W("design:returntype",Promise)],de.prototype,"payments",null),J([l("/syncStatus",{summary:k.per.authOnly}),V(0,S("id")),W("design:type",Function),W("design:paramtypes",[Number]),W("design:returntype",Promise)],de.prototype,"syncStatus",null),J([l("/delete",{summary:k.per.authOnly}),V(0,w("id")),W("design:type",Function),W("design:paramtypes",[Number]),W("design:returntype",Promise)],de.prototype,"delete",null),J([l("/deleteByIds",{summary:k.per.authOnly}),V(0,S("ids")),W("design:type",Function),W("design:paramtypes",[Array]),W("design:returntype",Promise)],de.prototype,"deleteByIds",null),de=J([d(),h("/api/suite/trade")],de);let ye=class extends E{sysSettingsService;async get(){const e=await this.sysSettingsService.getSetting(T);return this.ok({intro:e.intro})}};J([c(),W("design:type",N)],ye.prototype,"sysSettingsService",void 0),J([l("/get",{summary:k.per.authOnly}),W("design:type",Function),W("design:paramtypes",[]),W("design:returntype",Promise)],ye.prototype,"get",null),ye=J([d(),h("/api/suite/settings")],ye);let ue=class extends E{productService;userSuiteService;sysSettingsService;async detail(){const e=await this.userSuiteService.getMySuiteDetail(this.getUserId());return this.ok(e)}async page(e){A(),e.query=e.query||{};e.query.userId=this.getUserId();const t=await this.userSuiteService.page(e);return this.ok(t)}};J([c(),W("design:type",K)],ue.prototype,"productService",void 0),J([c(),W("design:type",ee)],ue.prototype,"userSuiteService",void 0),J([c(),W("design:type",N)],ue.prototype,"sysSettingsService",void 0),J([l("/detail",{summary:k.per.authOnly}),W("design:type",Function),W("design:paramtypes",[]),W("design:returntype",Promise)],ue.prototype,"detail",null),J([l("/page",{summary:k.per.authOnly}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],ue.prototype,"page",null),ue=J([d(),h("/api/mine/suite")],ue);let ce=class{tradeService;accessService;sysSettingsService;async onNotify(e,t,i){const s=await this.tradeService.getPaymentByType(e);return i&&Object.keys(i).length>1&&(t=i),await s.onNotify(t,(async e=>{await this.tradeService.onPaid(e)}))}};J([c(),W("design:type",te)],ce.prototype,"tradeService",void 0),J([c(),W("design:type",F)],ce.prototype,"accessService",void 0),J([c(),W("design:type",N)],ce.prototype,"sysSettingsService",void 0),J([f("/:paymentType",{summary:k.per.guest}),l("/:paymentType",{summary:k.per.guest}),V(0,P("paymentType")),V(1,w(v)),V(2,S(v)),W("design:type",Function),W("design:paramtypes",[String,Object,Object]),W("design:returntype",Promise)],ce.prototype,"onNotify",null),ce=J([d(),h("/api/payment/notify")],ce);const me=[Q,H,z];export{se as CommSysSettingsController,ie as Configuration,ue as MySuiteController,ce as PaymentNotifyController,X as PaymentProviderFactory,pe as ProductController,H as ProductEntity,K as ProductService,ye as SuiteSettingsController,oe as SysProductController,re as SysSiteController,ne as SysTradeController,de as TradeController,z as TradeEntity,te as TradeService,ae as UserSuiteController,Q as UserSuiteEntity,ee as UserSuiteService,me as commercialEntities,Z as paymentProviderFactory};
1
+ import{PrimaryGeneratedColumn as e,Column as t,Entity as i,Repository as s,Or as r,Equal as n,MoreThan as o,LessThan as a,In as p}from"typeorm";import{Provide as d,Scope as y,ScopeEnum as u,Inject as c,Logger as m,Configuration as g,Post as l,Body as S,ALL as v,Controller as h,Query as w,Get as f,Param as P}from"@midwayjs/core";import{InjectEntityModel as b}from"@midwayjs/typeorm";import{BaseService as I,SysSuiteSetting as T,NeedSuiteException as x,SysSettingsService as N,SysInstallInfo as C,SysPaymentSetting as O,AccessService as F,BaseController as E,SysHeaderMenus as D,SysSiteInfo as B,FileService as _,CrudController as j,Constants as k}from"@certd/lib-server";import U from"dayjs";import{utils as M,logger as R}from"@certd/basic";import{isComm as $,checkComm as A}from"@certd/plus-core";import*as q from"lodash-es";import{merge as G,remove as L}from"lodash-es";function J(e,t,i,s){var r,n=arguments.length,o=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,i,o):r(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o}function V(e,t){return function(i,s){t(i,s,e)}}function W(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}"function"==typeof SuppressedError&&SuppressedError;let z=class{id;userId;productId;tradeNo;duration;title;desc;num;price;amount;remark;status;payType;payTime;payNo;endTime;createTime;updateTime};var Y;J([e(),W("design:type",Number)],z.prototype,"id",void 0),J([t({name:"user_id",comment:"用户id"}),W("design:type",Number)],z.prototype,"userId",void 0),J([t({name:"product_id",comment:"商品Id"}),W("design:type",Number)],z.prototype,"productId",void 0),J([t({name:"trade_no",comment:"交易号"}),W("design:type",String)],z.prototype,"tradeNo",void 0),J([t({name:"duration",comment:"时长"}),W("design:type",Number)],z.prototype,"duration",void 0),J([t({name:"title",comment:"商品名称"}),W("design:type",String)],z.prototype,"title",void 0),J([t({name:"desc",comment:"商品描述"}),W("design:type",String)],z.prototype,"desc",void 0),J([t({name:"num",comment:"商品数量"}),W("design:type",Number)],z.prototype,"num",void 0),J([t({name:"price",comment:"单价"}),W("design:type",Number)],z.prototype,"price",void 0),J([t({name:"amount",comment:"总价"}),W("design:type",Number)],z.prototype,"amount",void 0),J([t({name:"remark",comment:"备注"}),W("design:type",String)],z.prototype,"remark",void 0),J([t({name:"status",comment:"状态"}),W("design:type",String)],z.prototype,"status",void 0),J([t({name:"pay_type",comment:"支付类型"}),W("design:type",String)],z.prototype,"payType",void 0),J([t({name:"pay_time",comment:"支付时间"}),W("design:type",Number)],z.prototype,"payTime",void 0),J([t({name:"pay_no",comment:"支付单号"}),W("design:type",String)],z.prototype,"payNo",void 0),J([t({name:"end_time",comment:"结束时间"}),W("design:type",Number)],z.prototype,"endTime",void 0),J([t({name:"create_time",comment:"创建时间",default:()=>"CURRENT_TIMESTAMP"}),W("design:type",Date)],z.prototype,"createTime",void 0),J([t({name:"update_time",comment:"修改时间",default:()=>"CURRENT_TIMESTAMP"}),W("design:type",Date)],z.prototype,"updateTime",void 0),z=J([i("cd_trade")],z);let H=Y=class{id;icon;title;type;content;durationPrices;duration;price;intro;order;supportBuy;disabled;createTime;updateTime;static getSuiteContent(e){return JSON.parse(e.content||"{}")}static setSuiteContent(e,t){e.content=JSON.stringify(t||{})}static getDurationPrices(e){return JSON.parse(e.durationPrices||"[]")}static setDurationPrices(e,t){if(0===t.length)throw new Error("prices must not be empty");e.duration=t[0].duration,e.price=t[0].price,e.durationPrices=JSON.stringify(t)}static getContentStr(e){let t="";const i=Y.getSuiteContent(e);return-1===i.maxDomainCount?t+="域名无限制;":t+=`域名${i.maxDomainCount}个;`,-1===i.maxPipelineCount?t+="流水线无限制;":t+=`流水线${i.maxPipelineCount}个;`,-1===i.maxDeployCount?t+="部署次数无限制;":t+=`部署${i.maxDeployCount}次;`,t}};J([e(),W("design:type",Number)],H.prototype,"id",void 0),J([t({name:"icon",comment:"图标"}),W("design:type",String)],H.prototype,"icon",void 0),J([t({name:"title",comment:"套餐名称"}),W("design:type",String)],H.prototype,"title",void 0),J([t({name:"type",comment:"套餐类型,套餐/加量包,suite/addon"}),W("design:type",String)],H.prototype,"type",void 0),J([t({name:"content",comment:"套餐内容"}),W("design:type",String)],H.prototype,"content",void 0),J([t({name:"duration_prices",comment:"时长及单价"}),W("design:type",String)],H.prototype,"durationPrices",void 0),J([t({name:"duration",comment:"时长"}),W("design:type",Number)],H.prototype,"duration",void 0),J([t({name:"price",comment:"单价"}),W("design:type",Number)],H.prototype,"price",void 0),J([t({name:"intro",comment:"说明"}),W("design:type",String)],H.prototype,"intro",void 0),J([t({name:"order",comment:"排序"}),W("design:type",Number)],H.prototype,"order",void 0),J([t({name:"support_buy",comment:"是否支持购买",default:!0}),W("design:type",Boolean)],H.prototype,"supportBuy",void 0),J([t({name:"disabled",comment:"禁用启用"}),W("design:type",Boolean)],H.prototype,"disabled",void 0),J([t({name:"create_time",comment:"创建时间",default:()=>"CURRENT_TIMESTAMP"}),W("design:type",Date)],H.prototype,"createTime",void 0),J([t({name:"update_time",comment:"修改时间",default:()=>"CURRENT_TIMESTAMP"}),W("design:type",Date)],H.prototype,"updateTime",void 0),H=Y=J([i("cd_product")],H);let Q=class{id;userId;productId;tradeId;icon;title;productType;content;duration;deployCountUsed;activeTime;expiresTime;disabled;isPresent;isBootstrap;isEmpty;createTime;updateTime;static getContent(e){return JSON.parse(e.content||"{}")}};J([e(),W("design:type",Number)],Q.prototype,"id",void 0),J([t({name:"user_id",comment:"用户ID"}),W("design:type",Number)],Q.prototype,"userId",void 0),J([t({name:"product_id",comment:"套餐ID"}),W("design:type",Number)],Q.prototype,"productId",void 0),J([t({name:"trade_id",comment:"订单id"}),W("design:type",Number)],Q.prototype,"tradeId",void 0),J([t({name:"icon",comment:"图标"}),W("design:type",String)],Q.prototype,"icon",void 0),J([t({name:"title",comment:"套餐名称"}),W("design:type",String)],Q.prototype,"title",void 0),J([t({name:"product_type",comment:"套餐类型,套餐/加量包,suite/addon"}),W("design:type",String)],Q.prototype,"productType",void 0),J([t({name:"content",comment:"套餐内容"}),W("design:type",String)],Q.prototype,"content",void 0),J([t({name:"duration",comment:"有效时长"}),W("design:type",Number)],Q.prototype,"duration",void 0),J([t({name:"deploy_count_used",comment:"已使用部署次数"}),W("design:type",Number)],Q.prototype,"deployCountUsed",void 0),J([t({name:"active_time",comment:"激活时间"}),W("design:type",Number)],Q.prototype,"activeTime",void 0),J([t({name:"expires_time",comment:"有效期"}),W("design:type",Number)],Q.prototype,"expiresTime",void 0),J([t({name:"disabled",comment:"启用/禁用",default:!1}),W("design:type",Boolean)],Q.prototype,"disabled",void 0),J([t({name:"is_present",comment:"是否赠送",default:!1}),W("design:type",Boolean)],Q.prototype,"isPresent",void 0),J([t({name:"is_bootstrap",comment:"是否初始套餐",default:!1}),W("design:type",Boolean)],Q.prototype,"isBootstrap",void 0),J([t({name:"is_empty",comment:"是否用完",default:!1}),W("design:type",Boolean)],Q.prototype,"isEmpty",void 0),J([t({name:"create_time",comment:"创建时间",default:()=>"CURRENT_TIMESTAMP"}),W("design:type",Date)],Q.prototype,"createTime",void 0),J([t({name:"update_time",comment:"修改时间",default:()=>"CURRENT_TIMESTAMP"}),W("design:type",Date)],Q.prototype,"updateTime",void 0),Q=J([i("cd_user_suite")],Q);let K=class extends I{repository;getRepository(){return this.repository}};J([b(H),W("design:type",s)],K.prototype,"repository",void 0),K=J([d(),y(u.Request,{allowDowngrade:!0})],K);class X{async createByPaymentType(e,t){return new(await this.getProviderCls(e))(t)}async getProviderCls(e){switch(e){case"alipay":return(await import("./alipay-c5b40806.js")).PaymentAlipay;case"wxpay":return(await import("./wxpay-2de8b4e9.js")).PaymentWxpay;case"yizhifu":return(await import("./yizhifu-907f6eb0.js")).PaymentYizhifu;default:throw new Error("不支持的支付方式:"+e)}}async getDefine(e){return(await this.getProviderCls(e)).getDefine()}}const Z=new X;let ee=class extends I{repository;myCountService;sysSettingsService;productService;getRepository(){return this.repository}async presentGiftSuite(e){if(!e)return!1;if(!$())return!1;const t=await this.getSuiteSetting();return!!t&&(!!t.enabled&&(!!t.registerGift?.productId&&await M.locker.execute(`presentGiftSuite:${e}`,(async()=>{if(await this.getRepository().count({where:{userId:e,isPresent:!0}})>0)return!1;const i=await this.productService.info(t.registerGift.productId);return!!i&&(R.info(`注册赠送套餐:userId=${e},suite=${i.title}`),await this.productToUserSuite({userId:e,product:i,duration:t.registerGift.duration,isPresent:!0,isBootstrap:!0}),!0)}))))}async productToUserSuite(e){const{duration:t,userId:i,product:s,tradeId:r,entityManager:n}=e,o=U(),a=o.valueOf();let p=0;p=-1===t?-1:o.add(t,"day").endOf("day").valueOf();const d=new Q;d.userId=i,d.productId=s.id,d.tradeId=r||0,d.icon="",d.title=s.title,d.productType=s.type,d.content=s.content,d.duration=t,d.deployCountUsed=0,d.disabled=!1,d.activeTime=a,d.expiresTime=p,d.isPresent=e.isPresent||!1,d.isBootstrap=e.isBootstrap||!1,d.isEmpty=!1,n?await n.save(d):await this.getRepository().save(d)}async getMySuiteDetail(e){const t=await this.sysSettingsService.getSetting(T);let i=await this.getMyValidSuiteList(e);if(!i||0===i.length){await this.presentGiftSuite(e)&&(i=await this.getMyValidSuiteList(e))}i&&0!==i.length||(i=[]);const s={max:0,used:0},r={max:0,used:0},n={max:0,used:0},o={max:0,used:0},a=[];if(i.length>0)for(const e of i){a.push({id:e.id,productId:e.productId,duration:e.duration,title:e.title,expiresTime:e.expiresTime,productType:e.productType});const t=Q.getContent(e);-1==s.max||-1==t.maxPipelineCount?s.max=-1:s.max+=t.maxPipelineCount??0,-1==r.max||-1==t.maxDomainCount?r.max=-1:r.max+=t.maxDomainCount??0,-1==n.max||-1==t.maxDeployCount?n.max=-1:n.max+=t.maxDeployCount??0,-1==o.max||-1==t.maxMonitorCount?o.max=-1:o.max+=t.maxMonitorCount??0,n.used+=e.deployCountUsed??0}const{pipelineCountUsed:p,domainCountUsed:d,monitorCountUsed:y}=await this.myCountService.getUsedCount(e);return s.used=p??0,r.used=d??0,o.used=y??0,{enabled:t.enabled,suites:a,expiresTime:0,pipelineCount:s,domainCount:r,deployCount:n,monitorCount:o}}async getMyValidSuiteList(e){if(!e)throw new Error("用户ID不能为空");const t=U(),i=await this.getMyValidSuite(e,t),s=await this.getMyValidAddons(e,t);return i?[i,...s]:s}async getMyValidSuite(e,t){return await this.getRepository().findOne({where:{userId:e,expiresTime:r(n(-1),o(t.valueOf())),activeTime:a(t.valueOf()),disabled:!1,productType:"suite"},order:{id:"DESC"}})}async getMyValidAddons(e,t){return await this.getRepository().find({where:{userId:e,expiresTime:r(n(-1),o(t.valueOf())),activeTime:a(t.valueOf()),disabled:!1,productType:"addon",isEmpty:!1},order:{expiresTime:"ASC",id:"ASC"}})}async checkHasDeployCount(e,t=1){t<=0&&(t=1);if(!(await this.getSuiteSetting()).enabled)return null;const i=await this.getMyValidSuiteList(e);i.sort(((e,t)=>e.expiresTime-t.expiresTime));for(const e of i){const i=Q.getContent(e);if(-1==i.maxDeployCount||i.maxDeployCount>=e.deployCountUsed+t)return e}throw new x("部署次数不足,请购买加量包或升级套餐")}async consumeDeployCount(e,t){if(null==e)return;e.deployCountUsed+=t;const i=Q.getContent(e);if(-1!=i.maxDeployCount&&e.deployCountUsed>=i.maxDeployCount){this.isOnlyDeployCount(i)&&(e.isEmpty=!0)}const s={deployCountUsed:()=>`deployCountUsed + ${t}`};e.isEmpty&&(s.isEmpty=!0),await this.repository.createQueryBuilder().update(Q).set(s).where("id = :suiteId",{suiteId:e.id}).execute()}checkHasInfinite(e){const t=Object.keys(e);for(const i of t)if(i.startsWith("max")&&-1==e[i])return!0;return!1}getSuiteSetting(){return this.sysSettingsService.getSetting(T)}isOnlyDeployCount(e){const t=Object.keys(e);for(const i of t)if(i.startsWith("max")&&"maxDeployCount"!=i&&0!=e[i])return!1;return-1!==e.maxDeployCount}async presentSuite(e){A();if(!(await this.getSuiteSetting()).enabled)throw new Error("套餐功能未开启");const t=await this.productService.info(e.productId);if(!t)throw new Error("产品不存在");const i=H.getDurationPrices(t).find((t=>t.duration===e.duration));if(!i)throw new Error("套餐时长不存在");await this.productToUserSuite({userId:e.userId,product:t,duration:i.duration,isPresent:!0})}};J([b(Q),W("design:type",s)],ee.prototype,"repository",void 0),J([c("myCountService"),W("design:type",Object)],ee.prototype,"myCountService",void 0),J([c(),W("design:type",N)],ee.prototype,"sysSettingsService",void 0),J([c(),W("design:type",K)],ee.prototype,"productService",void 0),ee=J([d("userSuiteService"),y(u.Request,{allowDowngrade:!0})],ee);let te=class extends I{repository;productService;sysSettingsService;accessService;userSuiteService;getRepository(){return this.repository}async createFree(e){const t=await this.getBuyableProduct(e.productId),{price:i}=this.findDurationPrice(t,e.duration);if(0!==i)throw new Error("产品价格不为0");const s=await this.create({productId:e.productId,duration:e.duration,num:e.num,payType:e.payType,userId:e.userId});await this.onPaid({tradeNo:s.tradeNo,status:"paid",amount:0,payNo:"free",remark:"免费赠送",payTime:U().valueOf()})}findDurationPrice(e,t){const i=JSON.parse(e.durationPrices||"[]").find((e=>e.duration===t));if(!i)throw new Error(`产品时长${t}不存在`);return i}async create(e){const t=await this.getBuyableProduct(e.productId),{price:i}=this.findDurationPrice(t,e.duration),s=U(),r="T"+s.format("YYYYMMDD")+s.unix()+M.id.randomNumber(6),n=`购买${t.title} ${e.duration}天`,o=`内含:${H.getContentStr(t)}`,a=new z;return a.title=n,a.desc=o,a.productId=e.productId,a.duration=e.duration,a.num=e.num,a.userId=e.userId,a.tradeNo=r,a.duration=e.duration,a.price=i,a.title=t.title,a.amount=a.price*a.num,a.status="wait_pay",a.payType=e.payType,await this.repository.save(a)}async getBuyableProduct(e){const t=await this.productService.info(e);if(!t)throw new Error("产品不存在");if(t.disabled)throw new Error("该产品已下架");if(!t.supportBuy)throw new Error("该产品不支持购买");return t}async buildPaymentReq(e,t){const i=await this.sysSettingsService.getSetting(C);let s=i?.bindUrl;if(!s)throw new Error("未绑定URL");s.endsWith("/")&&(s=s.slice(0,-1));const r=await this.getPaymentByType(e.payType);return await r.createOrder(e,{bindUrl:s,clientIp:t})}async getPaymentByType(e){const t=(await this.sysSettingsService.getSetting(O))[e];if(!t||!t.enabled)throw new Error(`支付方式${e}未启用`);const i=await this.accessService.getById(t.accessId,0);if(!i)throw new Error(`支付方式${e}未设置授权`);return await Z.createByPaymentType(e,i)}async getByTradeNo(e){if(!e)throw new Error("out_trade_no不能为空");return await this.repository.findOne({where:{tradeNo:e}})}async onPaid(e){const t=await this.getByTradeNo(e.tradeNo);if(!t)throw new Error(`订单${e.tradeNo}不存在`);if("paid"!==t.status){if("wait_pay"!==t.status)throw new Error(`订单${e.tradeNo}状态不正确, 当前状态为${t.status}`);if(t.amount!==e.amount)throw new Error(`订单${e.tradeNo}金额不正确, 当前金额为${t.amount},实际支付金额为${e.amount}`);await this.transaction((async i=>{await i.update(z,{id:t.id},{status:"paid",amount:e.amount,remark:e.remark,payNo:e.payNo,payTime:e.payTime||U().valueOf()});const s=await this.productService.info(t.productId);if(!s)throw new Error("产品不存在");const r=t.id,n=t.userId,o=t.duration;await this.userSuiteService.productToUserSuite({duration:o,userId:n,product:s,tradeId:r,entityManager:i})}))}}async syncStatus(e){const t=await this.info(e);if(!t)throw new Error("订单不存在");if("paid"===t.status)return;const i=await this.getPaymentByType(t.payType),s=await i.getDetail(t.tradeNo);if(!s)throw new Error("订单不存在");"paid"===s.status?await this.onPaid(s):"closed"===s.status&&await this.transaction((async e=>{await e.update(z,{id:t.id},{status:"closed",remark:s.remark})}))}async updatePaid(e,t){const i=await this.info(e);if(!i)throw new Error("订单不存在");"paid"!==i.status&&await this.onPaid({tradeNo:i.tradeNo,status:"paid",amount:i.amount,payNo:"",remark:`手动确认支付:${t}`,payTime:U().valueOf()})}};J([b(z),W("design:type",s)],te.prototype,"repository",void 0),J([c(),W("design:type",K)],te.prototype,"productService",void 0),J([c(),W("design:type",N)],te.prototype,"sysSettingsService",void 0),J([c(),W("design:type",F)],te.prototype,"accessService",void 0),J([c(),W("design:type",ee)],te.prototype,"userSuiteService",void 0),te=J([d(),y(u.Request,{allowDowngrade:!0})],te);let ie=class{logger;async onReady(e){this.logger.info("commercial start")}};J([m(),W("design:type",Object)],ie.prototype,"logger",void 0),ie=J([g({namespace:"commercial"})],ie);let se=class extends E{sysSettingsService;async paymentGet(){const e=await this.sysSettingsService.getSetting(O);return this.ok(e)}async paymentSave(e){A();const t=new O;return G(t,e),await this.sysSettingsService.saveSetting(t),this.ok({})}async suiteGet(){const e=await this.sysSettingsService.getSetting(T);return this.ok(e)}async suiteSave(e){A();const t=new T;return G(t,e),await this.sysSettingsService.saveSetting(t),this.ok({})}async headerMenusGet(){const e=await this.sysSettingsService.getSetting(D);return this.ok(e)}async headerMenusSave(e){A();const t=new D;return G(t,e),await this.sysSettingsService.saveSetting(t),this.ok({})}};J([c(),W("design:type",N)],se.prototype,"sysSettingsService",void 0),J([l("/payment/get",{summary:"sys:settings:view"}),W("design:type",Function),W("design:paramtypes",[]),W("design:returntype",Promise)],se.prototype,"paymentGet",null),J([l("/payment/save",{summary:"sys:settings:edit"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],se.prototype,"paymentSave",null),J([l("/suite/get",{summary:"sys:settings:view"}),W("design:type",Function),W("design:paramtypes",[]),W("design:returntype",Promise)],se.prototype,"suiteGet",null),J([l("/suite/save",{summary:"sys:settings:edit"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],se.prototype,"suiteSave",null),J([l("/headerMenus/get",{summary:"sys:settings:view"}),W("design:type",Function),W("design:paramtypes",[]),W("design:returntype",Promise)],se.prototype,"headerMenusGet",null),J([l("/headerMenus/save",{summary:"sys:settings:edit"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],se.prototype,"headerMenusSave",null),se=J([d(),h("/api/sys/settings")],se);let re=class extends E{sysSettingsService;fileService;async saveSiteInfo(e){A();let t=await this.sysSettingsService.getSetting(B);return null==t&&(t=new B),q.merge(t,e),t.logo&&(t.logo=await this.fileService.saveFile(this.getUserId(),t.logo,"public")),t.loginLogo&&(t.loginLogo=await this.fileService.saveFile(this.getUserId(),t.loginLogo,"public")),await this.sysSettingsService.saveSetting(t),this.ok(t)}async getSiteInfo(){A();const e=await this.sysSettingsService.getSetting(B);return this.ok(e)}};J([c(),W("design:type",N)],re.prototype,"sysSettingsService",void 0),J([c(),W("design:type",_)],re.prototype,"fileService",void 0),J([l("/save",{summary:"sys:settings:edit"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],re.prototype,"saveSiteInfo",null),J([l("/get",{summary:"sys:settings:view"}),W("design:type",Function),W("design:paramtypes",[]),W("design:returntype",Promise)],re.prototype,"getSiteInfo",null),re=J([d(),h("/api/sys/site")],re);let ne=class extends j{service;getService(){return A(),this.service}async page(e){return await super.page(e)}async list(e){return await super.list(e)}async add(e){return await super.add(e)}async update(e){return await super.update(e)}async info(e){return await super.info(e)}async delete(e){return await super.delete(e)}async syncStatus(e){return await this.service.syncStatus(e),this.ok()}async updatePaid(e){const t=await this.getLoginUser();return await this.service.updatePaid(e,t.id+"_"+t.username),this.ok()}async deleteByIds(e){const t=await this.getUserId();if(!e||0===e.length)throw new Error("ids不能为空");return await this.service.deleteWhere({id:e,userId:t}),this.ok()}};J([c(),W("design:type",te)],ne.prototype,"service",void 0),J([l("/page",{summary:"sys:settings:view"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],ne.prototype,"page",null),J([l("/list",{summary:"sys:settings:view"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],ne.prototype,"list",null),J([l("/add",{summary:"sys:settings:edit"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],ne.prototype,"add",null),J([l("/update",{summary:"sys:settings:edit"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],ne.prototype,"update",null),J([l("/info",{summary:"sys:settings:view"}),V(0,w("id")),W("design:type",Function),W("design:paramtypes",[Number]),W("design:returntype",Promise)],ne.prototype,"info",null),J([l("/delete",{summary:"sys:settings:edit"}),V(0,w("id")),W("design:type",Function),W("design:paramtypes",[Number]),W("design:returntype",Promise)],ne.prototype,"delete",null),J([l("/syncStatus",{summary:"sys:settings:edit"}),V(0,S("id")),W("design:type",Function),W("design:paramtypes",[Number]),W("design:returntype",Promise)],ne.prototype,"syncStatus",null),J([l("/updatePaid",{summary:"sys:settings:edit"}),V(0,S("id")),W("design:type",Function),W("design:paramtypes",[Number]),W("design:returntype",Promise)],ne.prototype,"updatePaid",null),J([l("/deleteByIds",{summary:"sys:settings:edit"}),V(0,S("ids")),W("design:type",Function),W("design:paramtypes",[Array]),W("design:returntype",Promise)],ne.prototype,"deleteByIds",null),ne=J([d(),h("/api/sys/suite/trade")],ne);let oe=class extends j{service;getService(){return A(),this.service}async page(e){return await super.page(e)}async list(e){return await super.list(e)}async add(e){return await super.add(e)}async update(e){return await super.update(e)}async info(e){return await super.info(e)}async delete(e){return await super.delete(e)}async deleteByIds(e){return await super.deleteByIds(e)}};J([c(),W("design:type",K)],oe.prototype,"service",void 0),J([l("/page",{summary:"sys:settings:view"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],oe.prototype,"page",null),J([l("/list",{summary:"sys:settings:view"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],oe.prototype,"list",null),J([l("/add",{summary:"sys:settings:edit"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],oe.prototype,"add",null),J([l("/update",{summary:"sys:settings:edit"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],oe.prototype,"update",null),J([l("/info",{summary:"sys:settings:view"}),V(0,w("id")),W("design:type",Function),W("design:paramtypes",[Number]),W("design:returntype",Promise)],oe.prototype,"info",null),J([l("/delete",{summary:"sys:settings:edit"}),V(0,w("id")),W("design:type",Function),W("design:paramtypes",[Number]),W("design:returntype",Promise)],oe.prototype,"delete",null),J([l("/deleteByIds",{summary:"sys:settings:edit"}),V(0,S("ids")),W("design:type",Function),W("design:paramtypes",[Array]),W("design:returntype",Promise)],oe.prototype,"deleteByIds",null),oe=J([d(),h("/api/sys/suite/product")],oe);let ae=class extends j{getService(){return this.userSuiteService}productService;userSuiteService;sysSettingsService;async page(e){return A(),await super.page(e)}async list(e){return await super.list(e)}async add(e){return A(),await super.add(e)}async update(e){return await super.update(e)}async info(e){return await super.info(e)}async delete(e){return await super.delete(e)}async deleteByIds(e){return await super.deleteByIds(e)}async presentSuite(e){return await this.userSuiteService.presentSuite({userId:e.userId,productId:e.productId,duration:e.duration}),this.ok()}};J([c(),W("design:type",K)],ae.prototype,"productService",void 0),J([c(),W("design:type",ee)],ae.prototype,"userSuiteService",void 0),J([c(),W("design:type",N)],ae.prototype,"sysSettingsService",void 0),J([l("/page",{summary:"sys:settings:view"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],ae.prototype,"page",null),J([l("/list",{summary:"sys:settings:view"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],ae.prototype,"list",null),J([l("/add",{summary:"sys:settings:edit"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],ae.prototype,"add",null),J([l("/update",{summary:"sys:settings:edit"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],ae.prototype,"update",null),J([l("/info",{summary:"sys:settings:view"}),V(0,w("id")),W("design:type",Function),W("design:paramtypes",[Number]),W("design:returntype",Promise)],ae.prototype,"info",null),J([l("/delete",{summary:"sys:settings:edit"}),V(0,w("id")),W("design:type",Function),W("design:paramtypes",[Number]),W("design:returntype",Promise)],ae.prototype,"delete",null),J([l("/deleteByIds",{summary:"sys:settings:edit"}),V(0,S("ids")),W("design:type",Function),W("design:paramtypes",[Array]),W("design:returntype",Promise)],ae.prototype,"deleteByIds",null),J([l("/presentSuite",{summary:"sys:settings:edit"}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],ae.prototype,"presentSuite",null),ae=J([d(),h("/api/sys/suite/user-suite")],ae);let pe=class extends E{productService;async list(){A();const e=await this.productService.list({query:{disabled:!1,supportBuy:!0},sort:{prop:"order",asc:!0}});for(const t of e)t.durationPrices=JSON.parse(t.durationPrices||"[]"),t.content=JSON.parse(t.content||"{}");return L(e,(e=>!0===e.isBootstrap)),this.ok(e)}};J([c(),W("design:type",K)],pe.prototype,"productService",void 0),J([l("/list",{summary:k.per.authOnly}),W("design:type",Function),W("design:paramtypes",[]),W("design:returntype",Promise)],pe.prototype,"list",null),pe=J([d(),h("/api/suite/product")],pe);let de=class extends E{productService;tradeService;sysSettingsService;async create(e){A();const{productId:t,duration:i,num:s,payType:r}=e,n=await this.tradeService.create({productId:t,duration:i,num:s,payType:r,userId:this.getUserId()}),o=this.ctx.request.ip,a=await this.tradeService.buildPaymentReq(n,o);return this.ok(a)}async createFree(e){A();const{productId:t,duration:i,num:s}=e,r=await this.tradeService.createFree({productId:t,duration:i,num:s,payType:"free",userId:this.getUserId()});return this.ok(r)}async info(e){const t=await this.tradeService.info(e.tradeId);return this.ok(t)}async page(e){e.query=e.query||{};e.query.userId=this.getUserId();const t=await this.tradeService.page(e);return this.ok(t)}async payments(){const e=await this.sysSettingsService.getSetting(O),t=[];return e.yizhifu&&e.yizhifu.enabled&&t.push({value:"yizhifu",label:"易支付",icon:"material-symbols:shield-outline"}),e.alipay&&e.alipay.enabled&&t.push({value:"alipay",label:"支付宝",icon:"ant-design:alipay-circle-filled"}),e.wxpay&&e.wxpay.enabled&&t.push({value:"wxpay",label:"微信",icon:"ant-design:wechat-filled"}),this.ok(t)}async syncStatus(e){const t=await this.tradeService.info(e);return t?t.userId!=this.getUserId()?this.fail("无权操作该交易订单"):("paid"===t.status||await this.tradeService.syncStatus(e),this.ok()):this.fail("交易订单不存在")}async delete(e){const t=this.getUserId();if(!e)throw new Error("id不能为空");return await this.tradeService.deleteWhere({id:e,userId:t}),this.ok()}async deleteByIds(e){const t=this.getUserId();if(!e||0===e.length)throw new Error("id不能为空");return await this.tradeService.deleteWhere({id:p(e),userId:t}),this.ok()}};J([c(),W("design:type",K)],de.prototype,"productService",void 0),J([c(),W("design:type",te)],de.prototype,"tradeService",void 0),J([c(),W("design:type",N)],de.prototype,"sysSettingsService",void 0),J([l("/create",{summary:k.per.authOnly}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],de.prototype,"create",null),J([l("/createFree",{summary:k.per.authOnly}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],de.prototype,"createFree",null),J([l("/info",{summary:k.per.authOnly}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],de.prototype,"info",null),J([l("/page",{summary:k.per.authOnly}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],de.prototype,"page",null),J([l("/payments",{summary:k.per.authOnly}),W("design:type",Function),W("design:paramtypes",[]),W("design:returntype",Promise)],de.prototype,"payments",null),J([l("/syncStatus",{summary:k.per.authOnly}),V(0,S("id")),W("design:type",Function),W("design:paramtypes",[Number]),W("design:returntype",Promise)],de.prototype,"syncStatus",null),J([l("/delete",{summary:k.per.authOnly}),V(0,w("id")),W("design:type",Function),W("design:paramtypes",[Number]),W("design:returntype",Promise)],de.prototype,"delete",null),J([l("/deleteByIds",{summary:k.per.authOnly}),V(0,S("ids")),W("design:type",Function),W("design:paramtypes",[Array]),W("design:returntype",Promise)],de.prototype,"deleteByIds",null),de=J([d(),h("/api/suite/trade")],de);let ye=class extends E{sysSettingsService;async get(){const e=await this.sysSettingsService.getSetting(T);return this.ok({intro:e.intro})}};J([c(),W("design:type",N)],ye.prototype,"sysSettingsService",void 0),J([l("/get",{summary:k.per.authOnly}),W("design:type",Function),W("design:paramtypes",[]),W("design:returntype",Promise)],ye.prototype,"get",null),ye=J([d(),h("/api/suite/settings")],ye);let ue=class extends E{productService;userSuiteService;sysSettingsService;async detail(){const e=await this.userSuiteService.getMySuiteDetail(this.getUserId());return this.ok(e)}async page(e){A(),e.query=e.query||{};e.query.userId=this.getUserId();const t=await this.userSuiteService.page(e);return this.ok(t)}};J([c(),W("design:type",K)],ue.prototype,"productService",void 0),J([c(),W("design:type",ee)],ue.prototype,"userSuiteService",void 0),J([c(),W("design:type",N)],ue.prototype,"sysSettingsService",void 0),J([l("/detail",{summary:k.per.authOnly}),W("design:type",Function),W("design:paramtypes",[]),W("design:returntype",Promise)],ue.prototype,"detail",null),J([l("/page",{summary:k.per.authOnly}),V(0,S(v)),W("design:type",Function),W("design:paramtypes",[Object]),W("design:returntype",Promise)],ue.prototype,"page",null),ue=J([d(),h("/api/mine/suite")],ue);let ce=class{tradeService;accessService;sysSettingsService;async onNotify(e,t,i){const s=await this.tradeService.getPaymentByType(e);return i&&Object.keys(i).length>1&&(t=i),await s.onNotify(t,(async e=>{await this.tradeService.onPaid(e)}))}};J([c(),W("design:type",te)],ce.prototype,"tradeService",void 0),J([c(),W("design:type",F)],ce.prototype,"accessService",void 0),J([c(),W("design:type",N)],ce.prototype,"sysSettingsService",void 0),J([f("/:paymentType",{summary:k.per.guest}),l("/:paymentType",{summary:k.per.guest}),V(0,P("paymentType")),V(1,w(v)),V(2,S(v)),W("design:type",Function),W("design:paramtypes",[String,Object,Object]),W("design:returntype",Promise)],ce.prototype,"onNotify",null),ce=J([d(),h("/api/payment/notify")],ce);const me=[Q,H,z];export{se as CommSysSettingsController,ie as Configuration,ue as MySuiteController,ce as PaymentNotifyController,X as PaymentProviderFactory,pe as ProductController,H as ProductEntity,K as ProductService,ye as SuiteSettingsController,oe as SysProductController,re as SysSiteController,ne as SysTradeController,de as TradeController,z as TradeEntity,te as TradeService,ae as UserSuiteController,Q as UserSuiteEntity,ee as UserSuiteService,me as commercialEntities,Z as paymentProviderFactory};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@certd/commercial-core",
3
3
  "private": false,
4
- "version": "1.36.18",
4
+ "version": "1.36.20",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/d/index.d.ts",
@@ -15,11 +15,11 @@
15
15
  "pub": "npm publish"
16
16
  },
17
17
  "dependencies": {
18
- "@certd/basic": "^1.36.18",
19
- "@certd/lib-server": "^1.36.18",
20
- "@certd/pipeline": "^1.36.18",
21
- "@certd/plugin-plus": "^1.36.18",
22
- "@certd/plus-core": "^1.36.18",
18
+ "@certd/basic": "^1.36.20",
19
+ "@certd/lib-server": "^1.36.20",
20
+ "@certd/pipeline": "^1.36.20",
21
+ "@certd/plugin-plus": "^1.36.20",
22
+ "@certd/plus-core": "^1.36.20",
23
23
  "@midwayjs/core": "~3.20.3",
24
24
  "@midwayjs/koa": "~3.20.3",
25
25
  "@midwayjs/logger": "~3.4.2",
@@ -47,5 +47,5 @@
47
47
  "tslib": "^2.8.1",
48
48
  "typescript": "^5.4.2"
49
49
  },
50
- "gitHead": "ea18a5ad151b296fda54fb5bcbe64c7d80cdff2f"
50
+ "gitHead": "ef46aeae6fd766883aeac61a59ce1dfec07f6ca6"
51
51
  }