YiAi/YiAiQuickDeploy/dist/modules/pay/pay.service.js
2024-02-05 23:18:50 +08:00

1 line
23 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';const _0x32f29c=_0x21e6;(function(_0x4455ae,_0x2ac74b){const _0x59480d=_0x21e6,_0x4f6a5f=_0x4455ae();while(!![]){try{const _0x5a3a94=parseInt(_0x59480d(0x1f2))/0x1*(-parseInt(_0x59480d(0x1e2))/0x2)+parseInt(_0x59480d(0x1bd))/0x3*(-parseInt(_0x59480d(0x18a))/0x4)+-parseInt(_0x59480d(0x191))/0x5*(parseInt(_0x59480d(0x214))/0x6)+parseInt(_0x59480d(0x200))/0x7*(parseInt(_0x59480d(0x1dd))/0x8)+parseInt(_0x59480d(0x1ca))/0x9*(parseInt(_0x59480d(0x1bb))/0xa)+-parseInt(_0x59480d(0x21d))/0xb+parseInt(_0x59480d(0x193))/0xc*(parseInt(_0x59480d(0x1a4))/0xd);if(_0x5a3a94===_0x2ac74b)break;else _0x4f6a5f['push'](_0x4f6a5f['shift']());}catch(_0x356abf){_0x4f6a5f['push'](_0x4f6a5f['shift']());}}}(_0x48ec,0x59ce6));var __decorate=this&&this[_0x32f29c(0x19c)]||function(_0x41b2f6,_0x2914fe,_0x4dee00,_0x26a4dd){const _0x2ff9c2=_0x32f29c;var _0x5055e5=arguments['length'],_0x55a590=_0x5055e5<0x3?_0x2914fe:_0x26a4dd===null?_0x26a4dd=Object['getOwnPropertyDescriptor'](_0x2914fe,_0x4dee00):_0x26a4dd,_0xb09b18;if(typeof Reflect===_0x2ff9c2(0x1ed)&&typeof Reflect[_0x2ff9c2(0x1d0)]===_0x2ff9c2(0x222))_0x55a590=Reflect['decorate'](_0x41b2f6,_0x2914fe,_0x4dee00,_0x26a4dd);else{for(var _0x455328=_0x41b2f6['length']-0x1;_0x455328>=0x0;_0x455328--)if(_0xb09b18=_0x41b2f6[_0x455328])_0x55a590=(_0x5055e5<0x3?_0xb09b18(_0x55a590):_0x5055e5>0x3?_0xb09b18(_0x2914fe,_0x4dee00,_0x55a590):_0xb09b18(_0x2914fe,_0x4dee00))||_0x55a590;}return _0x5055e5>0x3&&_0x55a590&&Object[_0x2ff9c2(0x1a2)](_0x2914fe,_0x4dee00,_0x55a590),_0x55a590;},__metadata=this&&this[_0x32f29c(0x1ea)]||function(_0x2f358e,_0x1fd6e7){const _0x40d6fe=_0x32f29c;if(typeof Reflect===_0x40d6fe(0x1ed)&&typeof Reflect['metadata']===_0x40d6fe(0x222))return Reflect[_0x40d6fe(0x1e9)](_0x2f358e,_0x1fd6e7);},__param=this&&this['__param']||function(_0x21cd64,_0x4813b0){return function(_0x566292,_0x1471e3){_0x4813b0(_0x566292,_0x1471e3,_0x21cd64);};};function _0x21e6(_0x4aabc9,_0x21fb15){const _0x48ec1c=_0x48ec();return _0x21e6=function(_0x21e620,_0x1c2b1d){_0x21e620=_0x21e620-0x178;let _0x4603ec=_0x48ec1c[_0x21e620];return _0x4603ec;},_0x21e6(_0x4aabc9,_0x21fb15);}Object[_0x32f29c(0x1a2)](exports,_0x32f29c(0x1c6),{'value':!![]}),exports['PayService']=void 0x0;function _0x48ec(){const _0x1ca092=['182hEXFPz','HttpException','message','get','trade_order_id','notify_url','log','MD5','../user/user.service','resource','error:\x20','return_url','Injectable','notifyHupi','WxPay','wechat','payWeChatMchId','alipay','套餐不存在!','toString','校验签名','payMpaySecret','Wap','60lxlfbn','HttpStatus','3EInJMr','onModuleInit','queryMpay','InjectRepository','订单不存在!','payMpayReturnUrl','text','payWeChatAppId','payer','__esModule','addBalanceToOrder','nonce_str','appid','1065987EhOtAr','digest','md5','SUCCESS','payMpay','default','decorate','name','map','cramiPackageEntity','mpay','order','attach','支付通知验证失败:\x20','payWeChatNotifyUrl','out_trade_no','transactions_h5','微信H5支付失败','total','6232MOwsle','payEpayReturnUrl','type','微信支付通知params:\x20','native','52gbTPZF','importDynamic','goodsId','payMpayApiQueryUrl','payWeChatPublicKey','OrderEntity','192.168.1.100','metadata','__metadata','1.1','globalConfigService','object','用户openId:\x20','payHupiSecret','data','wechat-pay:\x20','4090eldXdD','createRandomNonceStr','device','total_fee','decipher_gcm','key','https://api.xunhupay.com/payment/do.html','userBalanceService','update','clientip','@nestjs/typeorm','payEpay','UserBalanceService','queryEpay','2548OgTnGh','payWeChatH5Name','pay','支付请求失败!','param','crypto','payHupiNotifyUrl','orderEntity','success','transactions_jsapi','payHupiGatewayUrl','payEpayPid','payWeChat','notifyWeChat','https://api.xunhupay.com/payment/query.html','notifyEpay','length','queryHupi','payPlatform','payEpaySecret','426iyXZjj','@nestjs/common','pid','failed','order_no','design:paramtypes','UserService','payHupiReturnUrl','trade_status','4561458uoLEiq','支付请求失败:\x20','submit.php','title','hash','function','Repository','money','payWeChatPrivateKey','payHupi','payEpayNotifyUrl','../globalConfig/globalConfig.service','affected','payMpayPid','keys','payMpayNotifyUrl','getOpenIdByUserId','typeorm','CramiPackageEntity','toFixed','getConfigs','join','post','act','payType:\x20','payEpayApiQueryUrl','hex','wx-native','transactions_native','userService','time','trade_state','901708sIfDMp','response','version','axios','epay','now','findOne','31505JJEPIv','jsapi','486384OPNGJF','BAD_REQUEST','hupi','includes','payEpayApiPayUrl','校验签名通过','payHupiAppId','event_type','sign','__decorate','scene_info','createHash','sign_type','TRANSACTION.SUCCESS','TRADE_SUCCESS','defineProperty','notifyMpay'];_0x48ec=function(){return _0x1ca092;};return _0x48ec();}const typeorm_1=require(_0x32f29c(0x1fc)),typeorm_2=require(_0x32f29c(0x17b)),common_1=require(_0x32f29c(0x215)),crypto=require(_0x32f29c(0x205)),axios_1=require(_0x32f29c(0x18d)),order_entity_1=require('../order/order.entity'),cramiPackage_entity_1=require('../crami/cramiPackage.entity'),userBalance_service_1=require('../userBalance/userBalance.service'),globalConfig_service_1=require(_0x32f29c(0x228)),utils_1=require('../../common/utils'),user_service_1=require(_0x32f29c(0x1ac));let PayService=class PayService{constructor(_0x40a81f,_0x5c7ccb,_0x2b96df,_0xae19a0,_0x4badaa){const _0x247d32=_0x32f29c;this['cramiPackageEntity']=_0x40a81f,this[_0x247d32(0x207)]=_0x5c7ccb,this[_0x247d32(0x1f9)]=_0x2b96df,this[_0x247d32(0x1ec)]=_0xae19a0,this[_0x247d32(0x187)]=_0x4badaa;}async[_0x32f29c(0x1be)](){const _0x57af68=_0x32f29c,_0x1c44b6=await(0x0,utils_1[_0x57af68(0x1e3)])('wechatpay-node-v3');this[_0x57af68(0x1b2)]=(_0x1c44b6===null||_0x1c44b6===void 0x0?void 0x0:_0x1c44b6[_0x57af68(0x1cf)])?_0x1c44b6[_0x57af68(0x1cf)]:_0x1c44b6;}async['notify'](_0x5429e3){const _0x41cf27=_0x32f29c;if(_0x5429e3[_0x41cf27(0x204)]==_0x41cf27(0x18e))return this[_0x41cf27(0x20f)](_0x5429e3);if(_0x5429e3[_0x41cf27(0x1d6)]==_0x41cf27(0x195))return this[_0x41cf27(0x1b1)](_0x5429e3);if(typeof _0x5429e3[_0x41cf27(0x1ad)]=='object')return this[_0x41cf27(0x20d)](_0x5429e3);return this[_0x41cf27(0x1a3)](_0x5429e3);}async[_0x32f29c(0x202)](_0x183463,_0x368949,_0x28b958='wxpay'){const _0x97a88a=_0x32f29c,_0x443609=await this[_0x97a88a(0x207)]['findOne']({'where':{'userId':_0x183463,'orderId':_0x368949}});if(!_0x443609)throw new common_1['HttpException'](_0x97a88a(0x1c1),common_1[_0x97a88a(0x1bc)][_0x97a88a(0x194)]);const _0x595521=await this[_0x97a88a(0x1d3)][_0x97a88a(0x190)]({'where':{'id':_0x443609[_0x97a88a(0x1e4)]}});if(!_0x595521)throw new common_1[(_0x97a88a(0x1a5))]('套餐不存在!',common_1[_0x97a88a(0x1bc)][_0x97a88a(0x194)]);console[_0x97a88a(0x1aa)]('本次支付类型:\x20',_0x443609[_0x97a88a(0x212)]);try{if(_0x443609[_0x97a88a(0x212)]==_0x97a88a(0x1b3))return this[_0x97a88a(0x20c)](_0x183463,_0x368949,_0x28b958);if(_0x443609['payPlatform']==_0x97a88a(0x18e))return this[_0x97a88a(0x1fd)](_0x183463,_0x368949,_0x28b958);if(_0x443609['payPlatform']==_0x97a88a(0x1d4))return this[_0x97a88a(0x1ce)](_0x183463,_0x368949,_0x28b958);if(_0x443609[_0x97a88a(0x212)]==_0x97a88a(0x195))return this[_0x97a88a(0x226)](_0x183463,_0x368949,_0x28b958);}catch(_0xcd33f2){console['log'](_0x97a88a(0x21e),_0xcd33f2);throw new common_1[(_0x97a88a(0x1a5))](_0x97a88a(0x203),common_1[_0x97a88a(0x1bc)][_0x97a88a(0x194)]);}}async['query'](_0x3371a9){const _0x2be4e5=_0x32f29c,_0x584e2f=await this['orderEntity'][_0x2be4e5(0x190)]({'where':{'orderId':_0x3371a9}});if(!_0x584e2f)throw new common_1[(_0x2be4e5(0x1a5))](_0x2be4e5(0x1c1),common_1[_0x2be4e5(0x1bc)][_0x2be4e5(0x194)]);return _0x584e2f;}async[_0x32f29c(0x1b1)](_0x1d367c){const _0x5e20cf=_0x32f29c,_0x24c8a4=await this[_0x5e20cf(0x1ec)][_0x5e20cf(0x17e)]([_0x5e20cf(0x1ef)]),_0x1642c1=_0x1d367c[_0x5e20cf(0x221)];delete _0x1d367c[_0x5e20cf(0x221)];if(this[_0x5e20cf(0x19b)](_0x1d367c,_0x24c8a4)!=_0x1642c1)return _0x5e20cf(0x217);const _0x1f31f6=await this[_0x5e20cf(0x207)][_0x5e20cf(0x190)]({'where':{'orderId':_0x1d367c[_0x5e20cf(0x1a8)],'status':0x0}});if(!_0x1f31f6)return _0x5e20cf(0x217);await this[_0x5e20cf(0x1f9)][_0x5e20cf(0x1c7)](_0x1f31f6);const _0x2b3d1d=await this[_0x5e20cf(0x207)][_0x5e20cf(0x1fa)]({'orderId':_0x1d367c[_0x5e20cf(0x1a8)]},{'status':0x1,'paydAt':new Date()});if(_0x2b3d1d[_0x5e20cf(0x229)]!=0x1)return _0x5e20cf(0x217);return _0x5e20cf(0x208);}async[_0x32f29c(0x226)](_0x3e3ead,_0x4f3b88,_0x543f48='wxpay'){const _0x4970ea=_0x32f29c,_0x143a12=await this['orderEntity']['findOne']({'where':{'userId':_0x3e3ead,'orderId':_0x4f3b88}});if(!_0x143a12)throw new common_1['HttpException'](_0x4970ea(0x1c1),common_1['HttpStatus'][_0x4970ea(0x194)]);const _0x149994=await this[_0x4970ea(0x1d3)][_0x4970ea(0x190)]({'where':{'id':_0x143a12[_0x4970ea(0x1e4)]}});if(!_0x149994)throw new common_1[(_0x4970ea(0x1a5))](_0x4970ea(0x1b6),common_1[_0x4970ea(0x1bc)][_0x4970ea(0x194)]);const {payHupiAppId:_0x36cda3,payHupiSecret:_0x202ff8,payHupiNotifyUrl:_0x5967d8,payHupiReturnUrl:_0x2a634d,payHupiGatewayUrl:_0x42ccc2}=await this[_0x4970ea(0x1ec)][_0x4970ea(0x17e)]([_0x4970ea(0x199),_0x4970ea(0x1ef),_0x4970ea(0x206),_0x4970ea(0x21b),_0x4970ea(0x20a)]),_0xb27cf8={};_0xb27cf8[_0x4970ea(0x18c)]=_0x4970ea(0x1eb),_0xb27cf8[_0x4970ea(0x1c9)]=_0x36cda3,_0xb27cf8[_0x4970ea(0x188)]=(Date[_0x4970ea(0x18f)]()/0x3e8)[_0x4970ea(0x17d)](0x0),_0xb27cf8[_0x4970ea(0x1c8)]=(0x0,utils_1[_0x4970ea(0x1f3)])(0x20),_0xb27cf8['trade_order_id']=_0x4f3b88,_0xb27cf8[_0x4970ea(0x220)]=_0x149994[_0x4970ea(0x1d1)],_0xb27cf8[_0x4970ea(0x1f5)]=_0x143a12[_0x4970ea(0x1dc)],_0xb27cf8[_0x4970ea(0x1a9)]=_0x5967d8,_0xb27cf8[_0x4970ea(0x1af)]=_0x2a634d,_0xb27cf8[_0x4970ea(0x1d6)]=_0x4970ea(0x195),_0xb27cf8['hash']=this['sign'](_0xb27cf8,_0x202ff8);const {data:{errcode:_0x197de1,errmsg:_0x27cc46,url_qrcode:_0x3604e9,url:_0x31c3ee}}=await axios_1[_0x4970ea(0x1cf)][_0x4970ea(0x180)](_0x42ccc2||_0x4970ea(0x1f8),_0xb27cf8);if(_0x197de1!=0x0)throw new common_1['HttpException'](_0x27cc46,common_1[_0x4970ea(0x1bc)]['BAD_REQUEST']);return{'url_qrcode':_0x3604e9,'url':_0x31c3ee};}async[_0x32f29c(0x211)](_0x453c3a){const _0x3b8453=_0x32f29c,{payHupiAppId:_0x5c7918,payHupiSecret:_0x7d8d3b}=await this['globalConfigService'][_0x3b8453(0x17e)]([_0x3b8453(0x199),_0x3b8453(0x1ef)]),_0x47a3a0={};_0x47a3a0[_0x3b8453(0x18c)]='1.1',_0x47a3a0['appid']=_0x5c7918,_0x47a3a0['time']=(Date[_0x3b8453(0x18f)]()/0x3e8)[_0x3b8453(0x17d)](0x0),_0x47a3a0[_0x3b8453(0x1c8)]=(0x0,utils_1[_0x3b8453(0x1f3)])(0x20),_0x47a3a0['out_trade_order']=_0x453c3a,_0x47a3a0[_0x3b8453(0x221)]=this['sign'](_0x47a3a0,_0x7d8d3b);const {data:{errcode:_0x376e6b,errmsg:_0xa30226,data:_0x31f00f}}=await axios_1[_0x3b8453(0x1cf)][_0x3b8453(0x180)](_0x3b8453(0x20e),_0x47a3a0);if(_0x376e6b!=0x0)throw new common_1[(_0x3b8453(0x1a5))](_0xa30226,common_1['HttpStatus'][_0x3b8453(0x194)]);return _0x31f00f;}async[_0x32f29c(0x20f)](_0x121a68){const _0x20b870=_0x32f29c,_0x546425=_0x121a68[_0x20b870(0x19b)];delete _0x121a68['sign'],delete _0x121a68['sign_type'];const _0x4ff266=await this['globalConfigService']['getConfigs']([_0x20b870(0x213)]);if(this[_0x20b870(0x19b)](_0x121a68,_0x4ff266)!=_0x546425)return _0x20b870(0x217);console[_0x20b870(0x1aa)](_0x20b870(0x198));const _0x4ea1d0=await this[_0x20b870(0x207)][_0x20b870(0x190)]({'where':{'orderId':_0x121a68[_0x20b870(0x1d9)],'status':0x0}});if(!_0x4ea1d0)return'failed';const _0xdf0d6f=_0x121a68[_0x20b870(0x21c)]=='TRADE_SUCCESS'?0x1:0x2,_0x326fab=await this[_0x20b870(0x207)]['update']({'orderId':_0x121a68[_0x20b870(0x1d9)]},{'status':_0xdf0d6f,'paydAt':new Date()});_0xdf0d6f===0x1&&await this[_0x20b870(0x1f9)][_0x20b870(0x1c7)](_0x4ea1d0);if(_0x326fab[_0x20b870(0x229)]!=0x1)return _0x20b870(0x217);return _0x20b870(0x208);}async[_0x32f29c(0x1fd)](_0x55f1bd,_0x41e2b8,_0x393d90=_0x32f29c(0x1b5)){const _0xa8d2ed=_0x32f29c,_0x51a3d3=await this[_0xa8d2ed(0x207)][_0xa8d2ed(0x190)]({'where':{'userId':_0x55f1bd,'orderId':_0x41e2b8}});if(!_0x51a3d3)throw new common_1[(_0xa8d2ed(0x1a5))](_0xa8d2ed(0x1c1),common_1[_0xa8d2ed(0x1bc)][_0xa8d2ed(0x194)]);const _0x3ac4fd=await this[_0xa8d2ed(0x1d3)][_0xa8d2ed(0x190)]({'where':{'id':_0x51a3d3['goodsId']}});if(!_0x3ac4fd)throw new common_1[(_0xa8d2ed(0x1a5))](_0xa8d2ed(0x1b6),common_1['HttpStatus'][_0xa8d2ed(0x194)]);const {payEpayPid:_0x57cf47,payEpaySecret:_0x325235,payEpayNotifyUrl:_0x459a86,payEpayReturnUrl:_0x27644e,payEpayApiPayUrl:_0x3fc426}=await this[_0xa8d2ed(0x1ec)][_0xa8d2ed(0x17e)]([_0xa8d2ed(0x20b),'payEpaySecret',_0xa8d2ed(0x227),_0xa8d2ed(0x1de),_0xa8d2ed(0x197)]);let _0x217db5;_0x57cf47[_0xa8d2ed(0x210)]<=0x10?_0x217db5=Number(_0x57cf47):_0x217db5=BigInt(_0x57cf47);const _0xaf6d81={};_0xaf6d81[_0xa8d2ed(0x216)]=_0x217db5,_0xaf6d81[_0xa8d2ed(0x1df)]=_0x393d90,_0xaf6d81[_0xa8d2ed(0x1d9)]=_0x41e2b8,_0xaf6d81['name']=_0x3ac4fd[_0xa8d2ed(0x1d1)],_0xaf6d81[_0xa8d2ed(0x224)]=_0x51a3d3[_0xa8d2ed(0x1dc)],_0xaf6d81[_0xa8d2ed(0x1fb)]=_0xa8d2ed(0x1e8),_0xaf6d81[_0xa8d2ed(0x1f4)]='pc',_0xaf6d81[_0xa8d2ed(0x1a9)]=_0x459a86,_0xaf6d81[_0xa8d2ed(0x1af)]=_0x27644e,_0xaf6d81[_0xa8d2ed(0x204)]=_0xa8d2ed(0x18e),_0xaf6d81['sign']=this[_0xa8d2ed(0x19b)](_0xaf6d81,_0x325235),_0xaf6d81[_0xa8d2ed(0x19f)]=_0xa8d2ed(0x1ab);const _0x1135fe=new URLSearchParams(_0xaf6d81)[_0xa8d2ed(0x1b7)](),_0x2878ba=_0x3fc426+'?'+_0x1135fe;if(_0x3fc426[_0xa8d2ed(0x196)](_0xa8d2ed(0x21f)))return{'url_qrcode':null,'redirectUrl':_0x2878ba,'channel':_0x393d90,'isRedirect':!![]};else{const _0x3abce8=await axios_1['default']['get'](_0x3fc426,{'params':_0xaf6d81});console['log']('epay\x20--->\x20res:\x20',_0x3abce8[_0xa8d2ed(0x1f0)]);const {data:{code:_0x163de1,msg:_0x794356,qrcode:_0xe2208}}=_0x3abce8;if(_0x163de1!=0x1)throw new common_1['HttpException'](_0x794356,common_1[_0xa8d2ed(0x1bc)]['BAD_REQUEST']);return{'url_qrcode':_0xe2208,'redirectUrl':null,'channel':_0x393d90,'isRedirect':![]};}}async[_0x32f29c(0x1ff)](_0x2d8c72){const _0x5994f3=_0x32f29c,{payEpayPid:_0x39f8b3,payEpaySecret:_0x422b97,payEpayApiQueryUrl:_0x17133b}=await this[_0x5994f3(0x1ec)][_0x5994f3(0x17e)]([_0x5994f3(0x20b),_0x5994f3(0x213),_0x5994f3(0x183)]),_0x2d49a3={};_0x2d49a3[_0x5994f3(0x181)]=_0x5994f3(0x1d5),_0x2d49a3[_0x5994f3(0x1d9)]=_0x2d8c72,_0x2d49a3[_0x5994f3(0x216)]=_0x39f8b3,_0x2d49a3[_0x5994f3(0x1f7)]=_0x422b97;const {data:{code:_0x293921,msg:_0x972326,data:_0x5ee907}}=await axios_1['default'][_0x5994f3(0x1a7)](_0x17133b,{'params':_0x2d49a3});if(_0x293921!=0x1)throw new common_1['HttpException'](_0x972326,common_1[_0x5994f3(0x1bc)]['BAD_REQUEST']);return _0x5ee907;}async[_0x32f29c(0x1a3)](_0x11501b){const _0x20fa0d=_0x32f29c,_0x452b59=_0x11501b[_0x20fa0d(0x19b)];delete _0x11501b['sign'],delete _0x11501b[_0x20fa0d(0x19f)];const _0x232bea=await this[_0x20fa0d(0x1ec)][_0x20fa0d(0x17e)]([_0x20fa0d(0x1b9)]);console[_0x20fa0d(0x1aa)](_0x20fa0d(0x1b8));if(this[_0x20fa0d(0x19b)](_0x11501b,_0x232bea)!=_0x452b59)return _0x20fa0d(0x217);console[_0x20fa0d(0x1aa)]('校验签名通过');const _0x5ac29b=await this['orderEntity'][_0x20fa0d(0x190)]({'where':{'orderId':_0x11501b[_0x20fa0d(0x1d9)],'status':0x0}});if(!_0x5ac29b)return _0x20fa0d(0x217);const _0x26dd6e=_0x11501b[_0x20fa0d(0x21c)]==_0x20fa0d(0x1a1)?0x1:0x2;console[_0x20fa0d(0x1aa)]('status:\x20',_0x26dd6e);const _0xb4185c=await this[_0x20fa0d(0x207)]['update']({'orderId':_0x11501b[_0x20fa0d(0x1d9)]},{'status':_0x26dd6e,'paydAt':new Date()});_0x26dd6e===0x1&&await this['userBalanceService'][_0x20fa0d(0x1c7)](_0x5ac29b);if(_0xb4185c['affected']!=0x1)return _0x20fa0d(0x217);return _0x20fa0d(0x208);}async[_0x32f29c(0x1ce)](_0xcaa31e,_0x43783e,_0x2dad32='wxpay'){const _0x19ba51=_0x32f29c,_0x59d16e=await this[_0x19ba51(0x207)][_0x19ba51(0x190)]({'where':{'userId':_0xcaa31e,'orderId':_0x43783e}});if(!_0x59d16e)throw new common_1[(_0x19ba51(0x1a5))](_0x19ba51(0x1c1),common_1[_0x19ba51(0x1bc)][_0x19ba51(0x194)]);const _0x56d8be=await this[_0x19ba51(0x1d3)]['findOne']({'where':{'id':_0x59d16e['goodsId']}});if(!_0x56d8be)throw new common_1[(_0x19ba51(0x1a5))](_0x19ba51(0x1b6),common_1[_0x19ba51(0x1bc)][_0x19ba51(0x194)]);const {payMpayPid:_0xb90b64,payMpaySecret:_0x40d004,payMpayNotifyUrl:_0x3b1def,payMpayReturnUrl:_0x69cb51,payMpayApiPayUrl:_0x46491c}=await this['globalConfigService']['getConfigs'](['payMpayPid',_0x19ba51(0x1b9),_0x19ba51(0x179),_0x19ba51(0x1c2),'payMpayApiPayUrl']),_0x3c2ad1={};_0x3c2ad1['pid']=Number(_0xb90b64),_0x3c2ad1[_0x19ba51(0x1df)]=_0x2dad32,_0x3c2ad1[_0x19ba51(0x1d9)]=_0x43783e,_0x3c2ad1[_0x19ba51(0x1d1)]=_0x56d8be['name'],_0x3c2ad1[_0x19ba51(0x224)]=_0x59d16e['total'],_0x3c2ad1[_0x19ba51(0x1a9)]=_0x3b1def,_0x3c2ad1[_0x19ba51(0x1af)]=_0x69cb51,_0x3c2ad1[_0x19ba51(0x19b)]=this['sign'](_0x3c2ad1,_0x40d004),_0x3c2ad1[_0x19ba51(0x19f)]=_0x19ba51(0x1ab);const _0x5f2f01=new URLSearchParams(_0x3c2ad1)[_0x19ba51(0x1b7)](),_0x45ff1d=_0x46491c+'?'+_0x5f2f01;return{'url_qrcode':null,'redirectUrl':_0x45ff1d,'channel':_0x2dad32,'isRedirect':!![]};const _0x1c9ea9=await axios_1[_0x19ba51(0x1cf)]['get'](_0x46491c,{'params':_0x3c2ad1});}async[_0x32f29c(0x1bf)](_0x7d89bb){const _0x5061d6=_0x32f29c,{payMpayApiQueryUrl:_0x5673d1}=await this['globalConfigService']['getConfigs']([_0x5061d6(0x22a),_0x5061d6(0x1b9),_0x5061d6(0x1e5)]),_0x13123f={};_0x13123f[_0x5061d6(0x1df)]=0x2,_0x13123f[_0x5061d6(0x218)]=_0x7d89bb;const {data:{code:_0x1a57a9,msg:_0x502bf1,data:_0x17b337}}=await axios_1[_0x5061d6(0x1cf)][_0x5061d6(0x1a7)](_0x5673d1,{'params':_0x13123f});if(_0x1a57a9!=0x1)throw new common_1[(_0x5061d6(0x1a5))](_0x502bf1,common_1[_0x5061d6(0x1bc)][_0x5061d6(0x194)]);return _0x17b337;}async[_0x32f29c(0x20d)](_0x245fcb){const _0x4c10c1=_0x32f29c;console['log'](_0x4c10c1(0x1e0),_0x245fcb);const {payWeChatAppId:_0xea3a5b,payWeChatMchId:_0x977948,payWeChatSecret:_0x47dfac,payWeChatPublicKey:_0x3acff1,payWeChatPrivateKey:_0x819456}=await this[_0x4c10c1(0x1ec)][_0x4c10c1(0x17e)]([_0x4c10c1(0x1c4),_0x4c10c1(0x1b4),'payWeChatSecret','payWeChatPublicKey',_0x4c10c1(0x225)]),_0x23f000=new this[(_0x4c10c1(0x1b2))]({'appid':_0xea3a5b,'mchid':_0x977948,'publicKey':_0x3acff1,'privateKey':_0x819456});try{if(_0x245fcb[_0x4c10c1(0x19a)]==_0x4c10c1(0x1a0)){const {ciphertext:_0x586568,associated_data:_0x209052,nonce:_0x50fdad}=_0x245fcb[_0x4c10c1(0x1ad)],_0xa640f3=_0x23f000[_0x4c10c1(0x1f6)](_0x586568,_0x209052,_0x50fdad,_0x47dfac),_0x4829c9=await this[_0x4c10c1(0x207)][_0x4c10c1(0x190)]({'where':{'orderId':_0xa640f3[_0x4c10c1(0x1d9)],'status':0x0}});if(!_0x4829c9)return _0x4c10c1(0x217);const _0x50710a=_0xa640f3[_0x4c10c1(0x189)]==_0x4c10c1(0x1cd)?0x1:0x2,_0x7fe3d7=await this['orderEntity'][_0x4c10c1(0x1fa)]({'orderId':_0xa640f3[_0x4c10c1(0x1d9)]},{'status':_0x50710a,'paydAt':new Date()});_0x50710a===0x1&&await this['userBalanceService']['addBalanceToOrder'](_0x4829c9);if(_0x7fe3d7[_0x4c10c1(0x229)]!=0x1)return _0x4c10c1(0x217);}return'success';}catch(_0x15f0fc){return console[_0x4c10c1(0x1aa)](_0x4c10c1(0x1ae),_0x15f0fc),console[_0x4c10c1(0x1aa)](_0x4c10c1(0x1d7),_0x15f0fc),'failed';}}async[_0x32f29c(0x20c)](_0x340f5a,_0x2a9570,_0x44cbae=_0x32f29c(0x1e1)){const _0x5edafc=_0x32f29c;var _0x3d0be5,_0x318230,_0x225391;console['log'](_0x5edafc(0x182),_0x44cbae);const _0x3cbbd8=await this[_0x5edafc(0x207)][_0x5edafc(0x190)]({'where':{'userId':_0x340f5a,'orderId':_0x2a9570}});if(!_0x3cbbd8)throw new common_1['HttpException']('订单不存在!',common_1['HttpStatus']['BAD_REQUEST']);const _0x5d7092=await this[_0x5edafc(0x1d3)][_0x5edafc(0x190)]({'where':{'id':_0x3cbbd8[_0x5edafc(0x1e4)]}});if(!_0x5d7092)throw new common_1[(_0x5edafc(0x1a5))](_0x5edafc(0x1b6),common_1[_0x5edafc(0x1bc)]['BAD_REQUEST']);const {payWeChatAppId:_0x11fcde,payWeChatMchId:_0x1fae73,payWeChatPublicKey:_0x6fa65a,payWeChatPrivateKey:_0x577398,payWeChatNotifyUrl:_0x29dc78,payWeChatH5Name:_0x240749,payWeChatH5Url:_0x3f2789}=await this[_0x5edafc(0x1ec)][_0x5edafc(0x17e)]([_0x5edafc(0x1c4),_0x5edafc(0x1b4),_0x5edafc(0x1e6),_0x5edafc(0x225),_0x5edafc(0x1d8),_0x5edafc(0x201),'payWeChatH5Url']),_0x931ff3=new this['WxPay']({'appid':_0x11fcde,'mchid':_0x1fae73,'publicKey':_0x6fa65a,'privateKey':_0x577398}),_0x22bf0c={'appid':_0x11fcde,'mchid':_0x1fae73,'description':_0x5d7092[_0x5edafc(0x1d1)],'out_trade_no':_0x2a9570,'notify_url':_0x29dc78,'amount':{'total':Number(_0x3cbbd8['total']*0x64)},'scene_info':{'payer_client_ip':'192.168.1.100'}};console[_0x5edafc(0x1aa)](_0x5edafc(0x1f1),_0x22bf0c);if(_0x44cbae=='h5'){_0x22bf0c[_0x5edafc(0x19d)]['h5_info']={'type':_0x5edafc(0x1ba),'app_name':_0x240749,'app_url':_0x3f2789};const _0x50a2a5=await _0x931ff3[_0x5edafc(0x1da)](_0x22bf0c);if(_0x50a2a5['status']===0x193){const _0x3236c0=(_0x225391=(_0x318230=(_0x3d0be5=_0x50a2a5===null||_0x50a2a5===void 0x0?void 0x0:_0x50a2a5['errRaw'])===null||_0x3d0be5===void 0x0?void 0x0:_0x3d0be5[_0x5edafc(0x18b)])===null||_0x318230===void 0x0?void 0x0:_0x318230[_0x5edafc(0x1c3)])===null||_0x225391===void 0x0?void 0x0:_0x225391[_0x5edafc(0x1a6)];throw new common_1[(_0x5edafc(0x1a5))]((_0x50a2a5===null||_0x50a2a5===void 0x0?void 0x0:_0x50a2a5['message'])||_0x5edafc(0x1db),common_1[_0x5edafc(0x1bc)][_0x5edafc(0x194)]);}const {h5_url:_0x20dcbe}=_0x50a2a5;return{'url':_0x20dcbe};}if(_0x44cbae==_0x5edafc(0x192)){const _0x1c9cf2=await this[_0x5edafc(0x187)][_0x5edafc(0x17a)](_0x340f5a);console['log'](_0x5edafc(0x1ee),_0x1c9cf2),_0x22bf0c[_0x5edafc(0x1c5)]={'openid':_0x1c9cf2};const _0xa14ccc=await _0x931ff3[_0x5edafc(0x209)](_0x22bf0c);return console[_0x5edafc(0x1aa)]('jsapi支付结果返回值:\x20',_0xa14ccc),_0xa14ccc;}if(_0x44cbae==_0x5edafc(0x1e1)){const _0x1aad79=await _0x931ff3[_0x5edafc(0x186)](_0x22bf0c),{code_url:_0x1310af}=_0x1aad79;return!_0x1310af&&console[_0x5edafc(0x1aa)](_0x5edafc(0x185),_0x1aad79),{'url_qrcode':_0x1310af,'isRedirect':![]};}throw new common_1[(_0x5edafc(0x1a5))]('unsupported\x20pay\x20type',common_1[_0x5edafc(0x1bc)]['BAD_REQUEST']);}async['queryWeChat'](_0x509ee4){const _0x3c1849=_0x32f29c,{payWeChatAppId:_0x337629,payWeChatMchId:_0x5ab8ee,payWeChatPublicKey:_0x388976,payWeChatPrivateKey:_0x4078b3,payWeChatNotifyUrl:_0xac5d2a,payWeChatH5Name:_0x5211dd,payWeChatH5Url:_0x1d0bad}=await this[_0x3c1849(0x1ec)][_0x3c1849(0x17e)]([_0x3c1849(0x1c4),_0x3c1849(0x1b4),'payWeChatPublicKey',_0x3c1849(0x225)]),_0x44d9aa=new this[(_0x3c1849(0x1b2))]({'appid':_0x337629,'mchid':_0x5ab8ee,'publicKey':_0x388976,'privateKey':_0x4078b3}),_0x2acdea=await _0x44d9aa['query']({'out_trade_no':_0x509ee4});return _0x2acdea;}[_0x32f29c(0x19b)](_0x200fdf,_0x277964){const _0x422c07=_0x32f29c,_0x4c13ba=Object[_0x422c07(0x178)](_0x200fdf)['sort']()[_0x422c07(0x1d2)](_0x39b8d6=>_0x39b8d6+'='+_0x200fdf[_0x39b8d6])[_0x422c07(0x17f)]('&')+_0x277964;return crypto[_0x422c07(0x19e)](_0x422c07(0x1cc))['update'](_0x4c13ba)[_0x422c07(0x1cb)](_0x422c07(0x184));}};PayService=__decorate([(0x0,common_1[_0x32f29c(0x1b0)])(),__param(0x0,(0x0,typeorm_1['InjectRepository'])(cramiPackage_entity_1[_0x32f29c(0x17c)])),__param(0x1,(0x0,typeorm_1[_0x32f29c(0x1c0)])(order_entity_1[_0x32f29c(0x1e7)])),__metadata(_0x32f29c(0x219),[typeorm_2[_0x32f29c(0x223)],typeorm_2[_0x32f29c(0x223)],userBalance_service_1[_0x32f29c(0x1fe)],globalConfig_service_1['GlobalConfigService'],user_service_1[_0x32f29c(0x21a)]])],PayService),exports['PayService']=PayService;