You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
20 KiB

4 years ago
  1. "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=e(require("crypto")),n=e(require("querystring"));const r=Object.prototype.toString,o=Object.prototype.hasOwnProperty;function u(e,t){return o.call(e,t)}function i(e){return"[object Object]"===r.call(e)}function s(e){return"function"==typeof e}const a=/_(\w)/g,d=/[A-Z]/g;function c(e){return e.replace(a,(e,t)=>t?t.toUpperCase():"")}function p(e){return e.replace(d,e=>"_"+e.toLowerCase())}function f(e,t){let n,r;switch(t){case"snake2camel":r=c,n=a;break;case"camel2snake":r=p,n=d}for(const o in e)if(u(e,o)&&n.test(o)){const n=r(o);e[n]=e[o],delete e[o],i(e[n])?e[n]=f(e[n],t):Array.isArray(e[n])&&(e[n]=e[n].map(e=>f(e,t)))}return e}function l(e){return f(e,"snake2camel")}function y(e){return f(e,"camel2snake")}function h(e){return function(e,t="-"){e=e||new Date;const n=[];return n.push(e.getFullYear()),n.push(("00"+(e.getMonth()+1)).substr(-2)),n.push(("00"+e.getDate()).substr(-2)),n.join(t)}(e=e||new Date)+" "+function(e,t=":"){e=e||new Date;const n=[];return n.push(("00"+e.getHours()).substr(-2)),n.push(("00"+e.getMinutes()).substr(-2)),n.push(("00"+e.getSeconds()).substr(-2)),n.join(t)}(e)}function m(e={},t){if(!t||!e)return e;const n=["_pre","_purify","_post"];t._pre&&(e=t._pre(e));let r={shouldDelete:new Set([])};if(t._purify){const e=t._purify;for(const t in e)e[t]=new Set(e[t]);r=Object.assign(r,e)}if(i(t))for(const o in t){const u=t[o];s(u)&&-1===n.indexOf(o)?e[o]=u(e):"string"==typeof u&&-1===n.indexOf(o)&&(e[o]=e[u],r.shouldDelete.add(u))}else s(t)&&(e=t(e));if(r.shouldDelete)for(const t of r.shouldDelete)delete e[t];return t._post&&(e=t._post(e)),e}function g(e,t){const n=new e(t);return new Proxy(n,{get:function(e,t){if("function"==typeof e[t]&&0!==t.indexOf("_")&&e._protocols&&e._protocols[t]){const n=e._protocols[t];return async function(r){r=m(r,n.args);let o=await e[t](r);return o=m(o,n.returnValue),o}}return e[t]}})}var _={decryptData:function(e,n,r=""){const o=t.createDecipheriv("aes-128-cbc",n,r);o.setAutoPadding(!0);let u=o.update(e,"base64","utf8");return u+=o.final("utf8"),u},md5:function(e,n="utf8"){return t.createHash("md5").update(e,n).digest("hex")},sha256:function(e,n,r="utf8"){return t.createHmac("sha256",n).update(e,r).digest("hex")},getSignStr:function(e){return Object.keys(e).filter(t=>"sign"!==t&&void 0!==e[t]&&""!==e[t]).sort().map(t=>t+"="+e[t]).join("&")},getNonceStr:function(e=16){let t="";for(;t.length<e;)t+=Math.random().toString(32).substring(2);return t.substring(0,e)},buildXML:function(e,t="xml"){return`<${t}>${Object.keys(e).map(t=>i(e[t])?`<${t}><![CDATA[${JSON.stringify(e[t])}]]></${t}>`:`<${t}><![CDATA[${e[t]}]]></${t}>`).join("")}</${t}>`},parseXML:function(e){const t=/<(?:xml|root).*?>([\s|\S]*)<\/(?:xml|root)>/.exec(e)[1],n={},r=/<(.*?)>(?:<!\[CDATA\[){0,1}(.*?)(?:\]\]>){0,1}<\/.*?>/g;let o=null;for(;o=r.exec(t);)n[o[1]]=o[2];return n},isXML:function(e){return/^(<\?xml.*\?>)?(\r?\n)*<xml>(.|\r?\n)*<\/xml>$/i.test(e.trim())}};function w(e,t){t.forEach(t=>{e[t]=Number(e[t])})}var b={unifiedOrder:{args:{_purify:{shouldDelete:["subject"]}}},getOrderInfo:{args:{_purify:{shouldDelete:["subject"]}}},orderQuery:{returnValue:function(e){w(e,["cashFee","totalFee","couponCount"]),e.couponList=[];const t=e.couponCount||0;for(let n=0;n<t;n++)e.couponList.push({couponId:e["couponId"+n],couponType:e["couponType"+n],couponFee:Number(e["couponFee"+n])}),delete e["couponId"+n],delete e["couponType"+n],delete e["couponFee"+n];return e}},refund:{returnValue:function(e){w(e,["refundFee","settlementRefundFee","totalFee","settlementTotalFee","cashFee","cashRefundFee","couponRefundFee","couponRefundCount"]),e.couponList=[];const t=e.couponRefundCount||0;for(let n=0;n<t;n++)e.couponList.push({couponRefundId:e["couponRefundId"+n],couponType:e["couponType"+n],couponRefundFee:Number(e["couponRefundFee"+n])}),delete e["couponRefundId"+n],delete e["couponType"+n],delete e["couponRefundFee"+n];return e}},refundQuery:{returnValue:function(e){w(e,["totalFee","refundFee","settlementTotalFee","cashFee","refundCount"]),e.re