commit cb40797154b0f17f99d86c9318811f55a27a9da6 Author: leonZ Date: Sat Aug 3 19:59:21 2024 +0800 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..08d3169 --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +.buildpath +.project +.settings +.idea/ +.mvn/ +wsdl/ +caches/ +target/ +src/main/resources/static/ +.DS_Store +*.iml +dump.rdb diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..dbbe355 --- /dev/null +++ b/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are 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. + + 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. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + 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 Affero 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. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + 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 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 work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero 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 Affero 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 Affero 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 Affero 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. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + 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 AGPL, see +. diff --git a/README.md b/README.md new file mode 100644 index 0000000..317d319 --- /dev/null +++ b/README.md @@ -0,0 +1,123 @@ +# fuint会员营销系统介绍 + +#### 介绍 +fuint会员营销系统是一套开源的实体店铺会员管理和营销系统。系统基于前后端分离的架构,后端采用Java SpringBoot + Mysql,前端基于当前流行的UniappElement UI,支持小程序、h5。主要功能包含电子优惠券、储值卡、实体卡、集次卡(计次卡)、短信发送、储值卡、会员积分、会员等级权益体系,支付收款等会员日常营销工具。本系统适用于各类实体店铺,如零售超市、酒吧、酒店、汽车4S店、鲜花店、奶茶店、甜品店、餐饮店、农家乐等,是实体店铺会员营销必备的一款利器。 +以下是前台的页面展示: +

前台页面1

+

前台页面2

+

前台页面3

+

前台页面4

+

前台页面4

+ +fuint侧重于线下实体店的私域流量的运营,同时提供会员端小程序和收银系统的线上线下统一渠道,帮助商户降低获客成本。顾客通过扫码支付成为私域流量,支付即可成为会员。积分和卡券功能建立起会员等级体系,通过消息推送和短信营销方便触达用户。 +

1、会员运营自动化:商家通过日常活动设置,如开卡礼设置,沉睡唤醒等,成为会员后自动给顾客送优惠券,让顾客更有黏性,提升会员运营效率。

+

2、打通收银系统和会员营销的壁垒,代客下单收银,支付即成为会员。

+

3、会员体系完整化:积分兑换、积分转赠、会员等级权益、积分加速、买单折扣。

+

4、会员卡券齐全:储值卡、电子券、优惠券、集次卡、计次卡、实体卡购买并兑换、会员充值、余额支付。

+

5、线上代客下单收银系统,后台管理员可帮助临柜的会员下单、扫码支付。

+

6、支持手机短信、站内弹框消息、微信订阅消息:支持包括发货消息、卡券到期提醒、活动提醒、会员到期提醒、积分余额变动提醒等消息。

+

小程序前端仓库:https://gitee.com/fuint/fuint-uniapp

+扫码小程序演示:
+

小程序演示

+
+官网演示地址:
+

+ 1、官网:https://www.fuint.cn 点击 -> 系统演示,演示账号:fuint / 123456
+ 2、swagger接口文档:https://www.fuint.cn/fuint-application/swagger-ui.html +

+ +#### 软件架构 +后端:JAVA SpringBoot + MYSQL Mybatis Plus + Redis +前端:采用基于Vue的Uniapp、Element UI,前后端分离,支持微信小程序、h5等 +

后台截图:

+

登录界面

+

首页

+ +前端使用技术
+2.1 Vue2
+2.2 Uniapp
+2.3 Element UI +2.4 Nodejs 14或16版本 + +后端使用技术
+1.1 SpringBoot 2.5
+1.2 Mybatis Plus
+1.3 Maven
+1.4 SpringSecurity
+1.5 Druid
+1.6 Slf4j
+1.7 Fastjson
+1.8 JWT
+1.9 Redis
+1.10 Quartz
+1.11 Mysql 5.7或8版
+1.12 Swagger UI
+ + +#### 安装步骤 +推荐软件环境版本:jdk 1.8、mysql 5.8 +1. 导入db目录下的数据库文件。 +2. 修改config目录下的配置文件。 +3. 将工程打包,把jar包上传并执行。 +

提示:无后端和linux基础的朋友,可以使用宝塔部署,非常方便简单。

+ + +#### 前台使用说明 + +1. 会员登录,登录成功后可看到会员的卡券列表。 +2. 卡券领取和购买,预存券的充值等。 +3. 核销卡券,会员在前台出示二维码,管理员用微信扫一扫即可核销。 +4. 卡券转赠,会员可将自己的卡券转赠给其他用户,输入对方的手机号即可完成转赠,获赠的好友会收到卡券赠送的短信。 + +

卡券创建界面

+

卡券创建界面

+ +#### 后台使用 +1. 会员管理:会员新增、导入、禁用等。 +2. 内容管理:焦点图管理、文章管理等。 +3. 卡券管理:电子券管理为2层结构,即电子券组和电子券。 +4. 会员积分:会员积分管理,会员积分的操作,会员积分明细查看。 +5. 转赠管理:卡券转赠记录。 +6. 短信管理:短信营销功能,已发送的短信列表。 +7. 系统配置:配置系统管理员权限等。 +8. 店铺管理:支持多店铺模式。 +9. 核销管理员:核销人员管理主要包含3个功能:核销人员列表、核销人员审核、核销人员信息编辑。 +10. 短信模板管理:可配置不同场景和业务的短信内容。 +11. 卡券发放:单独发放、批量发放,发放成功后给会员发送短信通知 +12. 操作日志主要针对电子券系统后台的一些关键操作进行日志记录,方便排查相关操作人的行为等问题。 +13. 发券记录主要根据发券的实际操作情况来记录,分为单用户发券和批量发券,同时可针对该次发券记录进行作废操作。 +14. 代客下单、收银功能。 +

卡券营销:

+

卡券列表

+ +

收银代客下单功能:店员角色登录后台,从首页的“下单首页”菜单可进入代客收银下单界面,完成代客下单收银的流程。

+

收银界面

+

发起结算:

+

收银结算

+ +#### 开发计划 +1. 完善的报表统计; +2. 分享助力、分享领券、分享获得积分; +3. 员工提成、分销功能; +4. 店铺结算功能; +5. 更多营销工具,比如签到等。 + + +#### 允许使用范围: +1. 允许个人学习使用 +2. 允许用于毕业设计、论文参考代码 +3. 推荐Watch、Star项目,获取项目第一时间更新,同时也是对项目最好的支持 +4. 希望大家多多支持原创软件 +5. 请勿去除版权标签,要商用请购买源码授权(非常便宜),感谢理解! + +不足和待完善之处请谅解!源码仅供学习交流,更多功能欢迎进群咨询讨论,或需安装帮助请联系我们(麻烦先点star!!!!!!)。
+官方网站:https://www.fuint.cn
+开源不易,感谢支持!
+作者wx:fsq_better:
+

公众号二维码

+ + +特别鸣谢:
+Mybaits Plus: https://github.com/baomidou/mybatis-plus
+Vue: https://github.com/vuejs/vue
+Element UI: https://element.eleme.cn \ No newline at end of file diff --git a/configure/dev/application.properties b/configure/dev/application.properties new file mode 100644 index 0000000..fd6c592 --- /dev/null +++ b/configure/dev/application.properties @@ -0,0 +1,108 @@ +# 数据库配置 +spring.datasource.url=jdbc:mysql://127.0.0.1/:3306/member_card?useUnicode=true&characterEncoding=UTF8&useSSL=false +spring.datasource.username=root +spring.datasource.password=root + +# Redis配置 +spring.session.store-type=redis +spring.session.redis.namespace=member_card +# Redis数据库索引(默认为0) +spring.redis.database=0 +# Redis服务器地址(生产) +spring.redis.host=127.0.0.1 +# Redis服务器连接端口 +spring.redis.port=6379 +# Redis服务器连接密码(默认为空) +spring.redis.password= +# 连接池最大连接数(使用负值表示没有限制) +spring.redis.pool.max-active=-1 +# 连接池最大阻塞等待时间(使用负值表示没有限制) +spring.redis.pool.max-wait=-1 +# 连接池中的最大空闲连接 +spring.redis.pool.max-idle=8 +# 连接池中的最小空闲连接 +spring.redis.pool.min-idle=0 +# 连接超时时间(毫秒) +spring.redis.timeout=0 + +# 系统名称 +system.name = fuint会员营销管理系统 + +# 前端h5地址 +website.url=https://mc.keyelement.cn/h5/ + +# 上传图片本地地址 +images.root=/target/classes +images.path=/static/uploadImages/ + +# 上传图片服务器域名 +images.upload.url=http://localhost:8080 + +# 上传图片允许的大小(单位:MB) +images.upload.maxSize=5 + +################## 定时脚本配置 ######################### +# 定时发送消息 +message.job.switch = 1 +message.job.time = 0 0/1 * * * ? + +# 卡券到期处理 +couponExpire.job.switch = 1 +couponExpire.job.time = 0 0/1 * * * ? + +# 订单超时取消 +orderCancel.job.switch = 1 +orderCancel.job.time = 0 0/1 * * * ? + +# 分佣提成计算 +commission.job.switch = 1 +commission.job.time = 0 0/1 * * * ? + +################## 阿里云短信配置 ####################### +# 短信接口模式[0-关闭 1-打开] +aliyun.sms.mode = 0 +aliyun.sms.accessKeyId=LTAI4GJMjV123oXsrQJLnPZt +aliyun.sms.accessKeySecret=eGVBL30u5Ypj234d7XODlwYKWTaGT +# 阿里云短信签名 +aliyun.sms.signName=延禾技术 + +################## 阿里云OSS存储配置###################### +# 模式[0-关闭 1-打开] +aliyun.oss.mode = 0 +aliyun.oss.accessKeyId = LTAI4GJMjVhBa212rQJLnPZtt +aliyun.oss.accessKeySecret = eGVBL30u53456gXd7XODlwYKWTaGT +aliyun.oss.endpoint = https://oss-cn-shenzhen.aliyuncs.com +aliyun.oss.bucketName = fuint-application +# 上传文件夹 +aliyun.oss.folder = uploads +# 访问域名 +aliyun.oss.domain = https://fuint-application.oss-cn-shenzhen.aliyuncs.com + +################## 微信相关配置 ########################## +# 公众号配置 +weixin.official.appId=wxf4327ef05c27a0 +weixin.official.appSecret=1f55e8749332234d9a074873d8e6a3 + +# 小程序配置 +wxpay.appId = wxb6af3741234162bc +wxpay.appSecret = 76a538bfa5b55a4564d5f2be5540 +wxpay.mchId=1636980812 +wxpay.apiV2=34354320201030y323e432342343 +wxpay.certPath=/usr/local/fuint/cert/apiclient_cert.p12 +wxpay.domain=https://www.fuint.cn/fuint-application + +################## 支付宝支付相关配置 ###################### +alipay.appId = 应用编号 +alipay.privateKey = 应用私钥 +alipay.publicKey = 支付宝公钥(通过应用公钥上传到支付宝开放平台换取支付宝公钥) +alipay.serverUrl=https://openapi.alipay.com/gateway.do +alipay.domain=https://www.fuint.cn/fuint-application/clientApi/pay/aliPayCallback + +################ 微信订阅模板消息配置 ###################### +weixin.subMessage.orderCreated=[{'key':'time', 'name':'订单时间'},{'key':'orderSn', 'name':'订单号'},{'key':'remark', 'name':'备注信息'}] +weixin.subMessage.deliverGoods=[{'key':'receiver', 'name':'收货人'}, {'key':'orderSn', 'name':'订单号'}, {'key':'expressCompany', 'name':'快递公司'}, {'key':'expressNo', 'name':'快递单号'}] +weixin.subMessage.couponExpire=[{'key':'name', 'name':'卡券名称'}, {'key':'expireTime', 'name':'到期时间'},{'key':'tips', 'name':'温馨提示'}] +weixin.subMessage.couponArrival=[{'key':'name', 'name':'卡券名称'},{'key':'amount', 'name':'金额'},{'key':'tips', 'name':'温馨提示'}] +weixin.subMessage.balanceChange=[{'key':'amount', 'name':'变动金额'},{'key':'time', 'name':'变动时间'},{'key':'tips', 'name':'温馨提示'}] +weixin.subMessage.couponConfirm=[{'key':'name', 'name':'卡券名称'},{'key':'time', 'name':'核销时间'}] +weixin.subMessage.pointChange=[{'key':'amount', 'name':'变动数量'},{'key':'time', 'name':'变动时间'},{'key':'remark', 'name':'备注信息'}] \ No newline at end of file diff --git a/configure/prod/application.properties b/configure/prod/application.properties new file mode 100644 index 0000000..6f4cd83 --- /dev/null +++ b/configure/prod/application.properties @@ -0,0 +1,111 @@ +# 数据库配置 +spring.datasource.url=jdbc:mysql://121.37.2.239:8936/member_card?useUnicode=true&characterEncoding=UTF8&useSSL=false +#spring.datasource.url=jdbc:mysql://127.0.0.1:8936/member_card?useUnicode=true&characterEncoding=UTF8&useSSL=false +spring.datasource.username=member_card +spring.datasource.password=Pc4EM64yrGRBeCHz + +# Redis配置 +spring.session.store-type=redis +spring.session.redis.namespace=member_card +# Redis数据库索引(默认为0) +spring.redis.database=0 +# Redis服务器地址(生产) +spring.redis.host=121.37.2.239 +#spring.redis.host=127.0.0.1 +# Redis服务器连接端口 +spring.redis.port=2738 +# Redis服务器连接密码(默认为空) +spring.redis.password=jfBgV5rKLw +# 连接池最大连接数(使用负值表示没有限制) +spring.redis.pool.max-active=-1 +# 连接池最大阻塞等待时间(使用负值表示没有限制) +spring.redis.pool.max-wait=-1 +# 连接池中的最大空闲连接 +spring.redis.pool.max-idle=8 +# 连接池中的最小空闲连接 +spring.redis.pool.min-idle=0 +# 连接超时时间(毫秒) +spring.redis.timeout=300 + +# 系统名称 +system.name = 会员管理系统 + +# 前端h5地址 +website.url=https://mc.keyelement.cn/h5/ + +# 上传图片本地地址 +images.root=/Users/zhangcheng/Desktop/mc/server +#images.root=/www/wwwroot/MemberCard +images.path=/static/uploadImages/ + +# 上传图片服务器域名 +images.upload.url=http://127.0.0.1:8080 + +# 上传图片允许的大小(单位:MB) +images.upload.maxSize=5 + +################## 定时脚本配置 ######################### +# 定时发送消息 +message.job.switch = 1 +message.job.time = 0 0/1 * * * ? + +# 卡券到期处理 +couponExpire.job.switch = 1 +couponExpire.job.time = 0 0/1 * * * ? + +# 订单超时取消 +orderCancel.job.switch = 1 +orderCancel.job.time = 0 0/1 * * * ? + +# 分佣提成计算 +commission.job.switch = 1 +commission.job.time = 0 0/1 * * * ? + +################## 阿里云短信配置 ####################### +# 短信接口模式[0-关闭 1-打开] +aliyun.sms.mode = 1 +aliyun.sms.accessKeyId=LTAI5tAuqN3Gd4D3F1yffMYF +aliyun.sms.accessKeySecret=j2VF2nAW2M1vhJwi3LSVYMNg1woE3i +# 阿里云短信签名 +aliyun.sms.signName=关键元素科技 + +################## 阿里云OSS存储配置###################### +# 模式[0-关闭 1-打开] +aliyun.oss.mode = 0 +aliyun.oss.accessKeyId = LTAI4GJMjVhBa212rQJLnPZt +aliyun.oss.accessKeySecret = eGVBL30u53456gXd7XODlwYKWTaGT +aliyun.oss.endpoint = https://oss-cn-shenzhen.aliyuncs.com +aliyun.oss.bucketName = keyelement-application +# 上传文件夹 +aliyun.oss.folder = uploads +# 访问域名 +aliyun.oss.domain = https://keyelement-application.oss-cn-shenzhen.aliyuncs.com + +################## 微信相关配置 ########################## +# 公众号配置 +weixin.official.appId=wxf4327ef05c27a0 +weixin.official.appSecret=1f55e8749332234d9a074873d8e6a3 + +# 小程序配置 +wxpay.appId = wxb6af3741234162bc +wxpay.appSecret = 76a538bfa5b55a4564d5f2be5540 +wxpay.mchId=1636980812 +wxpay.apiV2=34354320201030y323e432342343 +wxpay.certPath=/usr/local/keyelement/cert/apiclient_cert.p12 +wxpay.domain=https://mc.keyelement.cn/fuint-application + +################## 支付宝支付相关配置 ###################### +alipay.appId = 应用编号 +alipay.privateKey = 应用私钥 +alipay.publicKey = 支付宝公钥(通过应用公钥上传到支付宝开放平台换取支付宝公钥) +alipay.serverUrl=https://openapi.alipay.com/gateway.do +alipay.domain=https://mc.keyelement.cn/application/clientApi/pay/aliPayCallback + +################ 微信订阅模板消息配置 ###################### +weixin.subMessage.orderCreated=[{'key':'time', 'name':'订单时间'},{'key':'orderSn', 'name':'订单号'},{'key':'remark', 'name':'备注信息'}] +weixin.subMessage.deliverGoods=[{'key':'receiver', 'name':'收货人'}, {'key':'orderSn', 'name':'订单号'}, {'key':'expressCompany', 'name':'快递公司'}, {'key':'expressNo', 'name':'快递单号'}] +weixin.subMessage.couponExpire=[{'key':'name', 'name':'卡券名称'}, {'key':'expireTime', 'name':'到期时间'},{'key':'tips', 'name':'温馨提示'}] +weixin.subMessage.couponArrival=[{'key':'name', 'name':'卡券名称'},{'key':'amount', 'name':'金额'},{'key':'tips', 'name':'温馨提示'}] +weixin.subMessage.balanceChange=[{'key':'amount', 'name':'变动金额'},{'key':'time', 'name':'变动时间'},{'key':'tips', 'name':'温馨提示'}] +weixin.subMessage.couponConfirm=[{'key':'name', 'name':'卡券名称'},{'key':'time', 'name':'核销时间'}] +weixin.subMessage.pointChange=[{'key':'amount', 'name':'变动数量'},{'key':'time', 'name':'变动时间'},{'key':'remark', 'name':'备注信息'}] \ No newline at end of file diff --git a/db/member_card.sql b/db/member_card.sql new file mode 100644 index 0000000..3971c7c --- /dev/null +++ b/db/member_card.sql @@ -0,0 +1,6404 @@ +/* +SQLyog Ultimate v13.1.1 (64 bit) +MySQL - 8.0.21 : Database - member_card +********************************************************************* +*/ + +/*!40101 SET NAMES utf8 */; + +/*!40101 SET SQL_MODE=''*/; + +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/`member_card` /*!40100 DEFAULT CHARACTER SET utf8 */ /*!80016 DEFAULT ENCRYPTION='N' */; + +USE `member_card`; + +/*Table structure for table `mt_address` */ + +DROP TABLE IF EXISTS `mt_address`; + +CREATE TABLE `mt_address` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `USER_ID` int NOT NULL DEFAULT '0' COMMENT '用户ID', + `NAME` varchar(30) NOT NULL DEFAULT '' COMMENT '收货人姓名', + `MOBILE` varchar(20) DEFAULT '' COMMENT '收货手机号', + `PROVINCE_ID` int unsigned DEFAULT '0' COMMENT '省份ID', + `CITY_ID` int unsigned DEFAULT '0' COMMENT '城市ID', + `REGION_ID` int DEFAULT '0' COMMENT '区/县ID', + `DETAIL` varchar(255) DEFAULT '' COMMENT '详细地址', + `IS_DEFAULT` char(1) DEFAULT 'N' COMMENT '是否默认', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `STATUS` char(1) DEFAULT 'A' COMMENT '状态', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='会员地址表'; + +/*Data for the table `mt_address` */ + +/*Table structure for table `mt_article` */ + +DROP TABLE IF EXISTS `mt_article`; + +CREATE TABLE `mt_article` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `STORE_ID` int NOT NULL DEFAULT '0' COMMENT '目录ID', + `MERCHANT_ID` int DEFAULT '0' COMMENT '商户ID', + `TITLE` varchar(100) DEFAULT '' COMMENT '标题', + `BRIEF` varchar(500) DEFAULT '' COMMENT '简介', + `URL` varchar(100) DEFAULT '' COMMENT '链接地址', + `IMAGE` varchar(200) DEFAULT '' COMMENT '图片地址', + `DESCRIPTION` text COMMENT '描述', + `CLICK` int DEFAULT '0' COMMENT '点击次数', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `OPERATOR` varchar(30) DEFAULT NULL COMMENT '最后操作人', + `SORT` int DEFAULT '0' COMMENT '排序', + `STATUS` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT 'A' COMMENT 'A:正常;N:禁用;D:删除', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB AUTO_INCREMENT=71 DEFAULT CHARSET=utf8 COMMENT='文章表'; + +/*Data for the table `mt_article` */ + +insert into `mt_article`(`ID`,`STORE_ID`,`MERCHANT_ID`,`TITLE`,`BRIEF`,`URL`,`IMAGE`,`DESCRIPTION`,`CLICK`,`CREATE_TIME`,`UPDATE_TIME`,`OPERATOR`,`SORT`,`STATUS`) values +(3,7,1,'“美食荒漠”? 温州:不存在的!','吃妈妈做的菜?或者足不出户,优哉游哉?不管在哪,假期的意义,绝对少不了一个“吃”。周刊君特别推出“五一就要吃”评论系列,小伙伴们会来讲讲,他们各自心心念念的家乡美食。也欢迎大家留言参与,看看哪个更馋人。','','/static/defaultImage/banner-2.png?v=1','

oi五一假期终于来了,你在哪?是去看人山人海,搞“特种兵式的旅行”,还是回老家,吃妈妈做的菜?或者足不出户,优哉游哉?不管在哪,假期的意义,绝对少不了一个“吃”。周刊君特别推出“五一就要吃”评论系列,小伙伴们会来讲讲,他们各自心心念念的家乡美食。也欢迎大家留言参与,看看哪个更馋人。  我的家乡,是一座山城相拥、海陆交融的山水之城。


  诗画山水,温润之州,是为温州。


  这里有“欲写龙湫难下笔,不游雁荡是虚生”中国东南第一山雁荡山,有山水诗的发祥地楠溪江,有山与海的尽头、东海明珠南麂岛,更有“走遍千山万水、想尽千方百计、说尽千言万语、吃尽千辛万苦”的温州精神。


  温州古为瓯越大地,也称东瓯,故这里的食物被称为“瓯菜”。


  这里山川湖海汇聚,美食自然丰富多样。山里的、海里的、湖里的、江里的、溪里的,各有各的滋味,所谓一方水土一方美食,无外乎如此。


  很多人对温州美食的初印象,来自电视剧《温州一家人》,这部由李立群、殷桃、张译主演的热播剧,讲述了温州一个普通家庭的草根创业奋斗史。



  在这部剧中,温州的美食伴随着市井烟火气,令人垂涎欲滴。但现实却是,或许是温州人对于这些美食太过习以为常,又或许是温州于经商一途上声名太响,让人潜意识里忽略了这里的吃食,误以为是“美食荒漠”,并不为太多人所熟知,以至于忽略了这里蕴藏着一座城的美食。


  至少来温州旅游的人,很少是冲着美食来的。

',105,'2023-05-12 09:12:16','2023-06-20 17:14:24','fuint',0,'A'), +(5,1,1,'又到一年最佳赏樱季','又到一年最佳赏樱季,一直想去亲眼目睹一次被誉为“世界三大赏樱胜地”之一 的无锡鼋头渚,正值无锡太湖鼋头渚国际樱花节 ,3万多株、100多个品种的樱花树,着实让人期待。','','/static/defaultImage/banner-1.png?v=1','

又到一年最佳赏樱季,一直想去亲眼目睹一次被誉为“世界三大赏樱胜地”之一 的无锡鼋头渚,正值无锡太湖鼋头渚国际樱花节 ,3万多株、100多个品种的樱花树,着实让人期待。

无锡太湖鼋头渚国际樱花节将从3月1日持续至5月3日,这期间来可以看到早樱、中樱、晚樱等各品种的樱花独揽芳华,晨赏、日赏、暮赏、夜赏,能看到千姿百态的樱花。


走在鼋头渚的小道上,空气里都是芬芳的樱花味道,漫山遍野的樱花,粉白、玫红、粉红色……不同的颜色交叠,层次感丰富,浪漫迷人~


我喜欢这里樱花盛开的时候,建筑的设计和樱花的飘落,虽然去的那天是阴天,但是却也别有一番诗情画意,小桥流水,樱花古韵,水波带着花影泛起阵阵涟漪,随手一拍就会有一种中式浪漫的感觉,沉醉在江南意境中,尤其穿上汉服拍照,绝美!

',88,'2023-05-12 18:29:01','2023-07-05 15:05:37','fuint',1,'A'); + +/*Table structure for table `mt_balance` */ + +DROP TABLE IF EXISTS `mt_balance`; + +CREATE TABLE `mt_balance` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `MERCHANT_ID` int DEFAULT '0' COMMENT '所属商户ID', + `STORE_ID` int DEFAULT '0' COMMENT '所属店铺ID', + `MOBILE` varchar(11) DEFAULT '' COMMENT '手机号', + `USER_ID` int NOT NULL DEFAULT '0' COMMENT '用户ID', + `ORDER_SN` varchar(32) DEFAULT '' COMMENT '订单号', + `AMOUNT` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '余额变化数量', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `DESCRIPTION` varchar(200) DEFAULT '' COMMENT '备注说明', + `OPERATOR` varchar(30) DEFAULT '' COMMENT '最后操作人', + `STATUS` char(1) DEFAULT 'A' COMMENT '状态,A正常;D作废', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COMMENT='余额变化表'; + +/*Data for the table `mt_balance` */ + +insert into `mt_balance`(`ID`,`MERCHANT_ID`,`STORE_ID`,`MOBILE`,`USER_ID`,`ORDER_SN`,`AMOUNT`,`CREATE_TIME`,`UPDATE_TIME`,`DESCRIPTION`,`OPERATOR`,`STATUS`) values +(1,1,0,'18976679980',163,'202309082201183531567',-72.08,'2023-09-08 22:01:18','2023-09-08 22:01:18','','','A'), +(2,1,0,'18976679980',163,'202309082204254176805',-72.08,'2023-09-08 22:04:25','2023-09-08 22:04:25','','','A'), +(4,0,3,'18976679980',163,'202309201800308947963',-4.04,'2023-09-20 18:00:31','2023-09-20 18:00:31','','','A'), +(5,0,3,'18976679980',163,'202309210835395956418',-80.00,'2023-09-21 08:35:40','2023-09-21 08:35:40','','','A'); + +/*Table structure for table `mt_banner` */ + +DROP TABLE IF EXISTS `mt_banner`; + +CREATE TABLE `mt_banner` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `TITLE` varchar(100) DEFAULT '' COMMENT '标题', + `MERCHANT_ID` int DEFAULT '0' COMMENT '所属商户ID', + `STORE_ID` int DEFAULT '0' COMMENT '所属店铺ID', + `URL` varchar(100) DEFAULT '' COMMENT '链接地址', + `IMAGE` varchar(200) DEFAULT '' COMMENT '图片地址', + `DESCRIPTION` text COMMENT '描述', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `OPERATOR` varchar(30) DEFAULT NULL COMMENT '最后操作人', + `SORT` int DEFAULT '0' COMMENT '排序', + `STATUS` char(1) DEFAULT 'A' COMMENT 'A:正常;D:删除', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB AUTO_INCREMENT=215 DEFAULT CHARSET=utf8 COMMENT='会员端焦点图表'; + +/*Data for the table `mt_banner` */ + +insert into `mt_banner`(`ID`,`TITLE`,`MERCHANT_ID`,`STORE_ID`,`URL`,`IMAGE`,`DESCRIPTION`,`CREATE_TIME`,`UPDATE_TIME`,`OPERATOR`,`SORT`,`STATUS`) values +(1,'活动',1,0,'pages/user/index','/static/defaultImage/banner-2.png?v=1','','2021-04-14 09:38:20','2023-08-01 07:52:08','fuint',1,'A'), +(2,'活动',2,0,'pages/category/index','/static/defaultImage/banner-1.png?v=1','','2021-04-14 09:38:36','2023-07-25 17:37:40','fuint',1,'A'); + +/*Table structure for table `mt_book` */ + +DROP TABLE IF EXISTS `mt_book`; + +CREATE TABLE `mt_book` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `MERCHANT_ID` int DEFAULT '0' COMMENT '所属商户ID', + `STORE_ID` int DEFAULT '0' COMMENT '店铺ID', + `GOODS_ID` int DEFAULT '0' COMMENT '预约服务ID', + `SERVICE_DATES` varchar(1000) DEFAULT '' COMMENT '可预约日期', + `SERVICE_TIMES` varchar(1000) DEFAULT '' COMMENT '可预约时间段', + `SERVICE_STAFF_IDS` varchar(1000) DEFAULT '' COMMENT '可预约员工', + `DESCRIPTION` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '预约说明', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `OPERATOR` varchar(30) DEFAULT '' COMMENT '最后操作人', + `STATUS` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT 'A' COMMENT '订单状态', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='预约表'; + +/*Data for the table `mt_book` */ + +insert into `mt_book`(`ID`,`MERCHANT_ID`,`STORE_ID`,`GOODS_ID`,`SERVICE_DATES`,`SERVICE_TIMES`,`SERVICE_STAFF_IDS`,`DESCRIPTION`,`CREATE_TIME`,`UPDATE_TIME`,`OPERATOR`,`STATUS`) values +(1,1,1,1,'2023-02-04_2023-02-08,2023-03-04_2023-05-08','9:00-11:00,14:00-16:00,20:00-22:00','1,2,4,5,6,7,10','针灸预约','2023-02-14 11:45:54','2023-02-15 11:45:57','','A'); + +/*Table structure for table `mt_book_item` */ + +DROP TABLE IF EXISTS `mt_book_item`; + +CREATE TABLE `mt_book_item` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `MERCHANT_ID` int DEFAULT '0' COMMENT '所属商户ID', + `STORE_ID` int DEFAULT '0' COMMENT '店铺ID', + `GOODS_ID` int DEFAULT '0' COMMENT '预约服务ID', + `CONTACT` varchar(30) DEFAULT NULL COMMENT '预约联系人', + `MOBILE` varchar(30) DEFAULT NULL COMMENT '预约手机号', + `SERVICE_START_TIME` datetime DEFAULT NULL COMMENT '预约开始日期', + `SERVICE_END_TIME` datetime DEFAULT NULL COMMENT '预约结束日期', + `SERVICE_STAFF_ID` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '可预约员工', + `REMARK` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '预约说明', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `OPERATOR` varchar(30) DEFAULT '' COMMENT '最后操作人', + `STATUS` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT 'A' COMMENT '状态', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='预约详情表'; + +/*Data for the table `mt_book_item` */ + +/*Table structure for table `mt_cart` */ + +DROP TABLE IF EXISTS `mt_cart`; + +CREATE TABLE `mt_cart` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `USER_ID` int NOT NULL DEFAULT '0' COMMENT '会员ID', + `MERCHANT_ID` int DEFAULT '0' COMMENT '商户ID', + `STORE_ID` int DEFAULT '0' COMMENT '店铺ID', + `IS_VISITOR` char(1) DEFAULT 'N' COMMENT '是否游客', + `HANG_NO` varchar(10) DEFAULT '' COMMENT '挂单号', + `SKU_ID` int DEFAULT '0' COMMENT 'skuID', + `GOODS_ID` int DEFAULT '0' COMMENT '商品ID', + `NUM` int DEFAULT '1' COMMENT '数量', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `STATUS` char(1) DEFAULT 'A' COMMENT '状态', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8 COMMENT='购物车'; + +/*Data for the table `mt_cart` */ + +/*Table structure for table `mt_confirm_log` */ + +DROP TABLE IF EXISTS `mt_confirm_log`; + +CREATE TABLE `mt_confirm_log` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `CODE` varchar(32) NOT NULL DEFAULT '' COMMENT '编码', + `AMOUNT` decimal(10,2) DEFAULT '0.00' COMMENT '核销金额', + `COUPON_ID` int DEFAULT '0' COMMENT '卡券ID', + `USER_COUPON_ID` int NOT NULL DEFAULT '0' COMMENT '用户券ID', + `ORDER_ID` int DEFAULT '0' COMMENT '订单ID', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `USER_ID` int NOT NULL DEFAULT '0' COMMENT '卡券所属用户ID', + `OPERATOR_USER_ID` int DEFAULT NULL COMMENT '核销者用户ID', + `MERCHANT_ID` int DEFAULT '0' COMMENT '商户ID', + `STORE_ID` int NOT NULL DEFAULT '0' COMMENT '核销店铺ID', + `STATUS` varchar(1) NOT NULL COMMENT '状态,A正常核销;D:撤销使用', + `CANCEL_TIME` datetime DEFAULT NULL COMMENT '撤销时间', + `OPERATOR` varchar(30) DEFAULT NULL COMMENT '最后操作人', + `OPERATOR_FROM` varchar(30) DEFAULT 'mt_user' COMMENT '操作来源user_id对应表t_account 还是 mt_user', + `REMARK` varchar(500) DEFAULT '' COMMENT '备注信息', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='核销记录表'; + +/*Data for the table `mt_confirm_log` */ + +/*Table structure for table `mt_coupon` */ + +DROP TABLE IF EXISTS `mt_coupon`; + +CREATE TABLE `mt_coupon` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `MERCHANT_ID` int DEFAULT '0' COMMENT '商户ID', + `STORE_ID` int DEFAULT '0' COMMENT '店铺ID', + `GROUP_ID` int NOT NULL DEFAULT '0' COMMENT '券组ID', + `TYPE` char(1) DEFAULT 'C' COMMENT '券类型,C优惠券;P预存卡;T集次卡', + `NAME` varchar(100) NOT NULL DEFAULT '' COMMENT '券名称', + `IS_GIVE` tinyint(1) DEFAULT '0' COMMENT '是否允许转赠', + `GRADE_IDS` varchar(100) DEFAULT '' COMMENT '适用会员等级', + `POINT` int DEFAULT '0' COMMENT '获得卡券所消耗积分', + `APPLY_GOODS` varchar(20) DEFAULT '' COMMENT '适用商品:allGoods、parkGoods', + `RECEIVE_CODE` varchar(32) DEFAULT '' COMMENT '领取码', + `USE_FOR` varchar(30) DEFAULT '' COMMENT '使用专项', + `EXPIRE_TYPE` varchar(30) DEFAULT '' COMMENT '过期类型', + `EXPIRE_TIME` int DEFAULT '0' COMMENT '有效期,单位:天', + `BEGIN_TIME` datetime DEFAULT NULL COMMENT '开始有效期', + `END_TIME` datetime DEFAULT NULL COMMENT '结束有效期', + `AMOUNT` decimal(10,2) DEFAULT '0.00' COMMENT '面额', + `SEND_WAY` varchar(20) DEFAULT 'backend' COMMENT '发放方式', + `SEND_NUM` int unsigned DEFAULT '1' COMMENT '每次发放数量', + `TOTAL` int DEFAULT '0' COMMENT '发行数量', + `LIMIT_NUM` int DEFAULT '1' COMMENT '每人拥有数量限制', + `EXCEPT_TIME` varchar(500) DEFAULT '' COMMENT '不可用日期,逗号隔开。周末:weekend;其他:2019-01-02_2019-02-09', + `STORE_IDS` varchar(100) DEFAULT '' COMMENT '所属店铺ID,逗号隔开', + `DESCRIPTION` varchar(2000) DEFAULT '' COMMENT '描述信息', + `IMAGE` varchar(100) DEFAULT '' COMMENT '效果图片', + `REMARKS` varchar(1000) DEFAULT '' COMMENT '后台备注', + `IN_RULE` varchar(1000) DEFAULT '' COMMENT '获取券的规则', + `OUT_RULE` varchar(1000) DEFAULT '' COMMENT '核销券的规则', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `OPERATOR` varchar(30) DEFAULT '' COMMENT '最后操作人', + `STATUS` char(1) DEFAULT 'A' COMMENT 'A:正常;D:删除', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='卡券信息表'; + +/*Data for the table `mt_coupon` */ + +/*Table structure for table `mt_coupon_goods` */ + +DROP TABLE IF EXISTS `mt_coupon_goods`; + +CREATE TABLE `mt_coupon_goods` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `COUPON_ID` int NOT NULL COMMENT '卡券ID', + `GOODS_ID` int NOT NULL COMMENT '商品ID', + `CREATE_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime NOT NULL COMMENT '更新时间', + `STATUS` char(1) NOT NULL DEFAULT 'A' COMMENT '状态', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='卡券商品表'; + +/*Data for the table `mt_coupon_goods` */ + +/*Table structure for table `mt_coupon_group` */ + +DROP TABLE IF EXISTS `mt_coupon_group`; + +CREATE TABLE `mt_coupon_group` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `MERCHANT_ID` int DEFAULT '0' COMMENT '商户ID', + `STORE_ID` int DEFAULT '0' COMMENT '店铺ID', + `NAME` varchar(100) NOT NULL DEFAULT '' COMMENT '券组名称', + `MONEY` decimal(18,2) DEFAULT '0.00' COMMENT '价值金额', + `NUM` int DEFAULT '0' COMMENT '券种类数量', + `TOTAL` int DEFAULT '0' COMMENT '发行数量', + `DESCRIPTION` varchar(2000) DEFAULT '' COMMENT '备注', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建日期', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新日期', + `OPERATOR` varchar(30) DEFAULT '' COMMENT '最后操作人', + `STATUS` char(1) NOT NULL DEFAULT 'A' COMMENT 'A:正常;D:删除', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='优惠券组'; + +/*Data for the table `mt_coupon_group` */ + +/*Table structure for table `mt_freight` */ + +DROP TABLE IF EXISTS `mt_freight`; + +CREATE TABLE `mt_freight` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `MERCHANT_ID` int DEFAULT '0' COMMENT '商户ID', + `STORE_ID` int DEFAULT '0' COMMENT '店铺ID', + `NAME` varchar(100) NOT NULL COMMENT '名称', + `TYPE` int NOT NULL COMMENT '计费类型,1:按件数;2:按重量', + `AMOUNT` decimal(10,2) NOT NULL COMMENT '费用', + `INCRE_AMOUNT` decimal(10,2) NOT NULL COMMENT '续费', + `CREATE_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime NOT NULL COMMENT '更新时间', + `STATUS` char(1) NOT NULL COMMENT '状态', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='运费模板'; + +/*Data for the table `mt_freight` */ + +/*Table structure for table `mt_freight_region` */ + +DROP TABLE IF EXISTS `mt_freight_region`; + +CREATE TABLE `mt_freight_region` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `FREIGHT_ID` int NOT NULL COMMENT '运费模板ID', + `PROVINCE_ID` int NOT NULL COMMENT '省份ID', + `CITY_ID` int NOT NULL COMMENT '城市ID', + `AREA_ID` int NOT NULL COMMENT '区域ID', + `CREATE_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime NOT NULL COMMENT '更新时间', + `STATUS` char(1) NOT NULL COMMENT '状态', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='运费模板地区'; + +/*Data for the table `mt_freight_region` */ + +/*Table structure for table `mt_give` */ + +DROP TABLE IF EXISTS `mt_give`; + +CREATE TABLE `mt_give` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增', + `USER_ID` int NOT NULL DEFAULT '0' COMMENT '获赠者用户ID', + `MERCHANT_ID` int DEFAULT '0' COMMENT '商户ID', + `STORE_ID` int DEFAULT '0' COMMENT '店铺ID', + `GIVE_USER_ID` int NOT NULL DEFAULT '0' COMMENT '赠送者用户ID', + `MOBILE` varchar(20) NOT NULL DEFAULT '' COMMENT '赠予对象手机号', + `USER_MOBILE` varchar(20) NOT NULL DEFAULT '' COMMENT '用户手机', + `GROUP_IDS` varchar(200) NOT NULL DEFAULT '' COMMENT '券组ID,逗号隔开', + `GROUP_NAMES` varchar(500) NOT NULL DEFAULT '' COMMENT '券组名称,逗号隔开', + `COUPON_IDS` varchar(200) NOT NULL DEFAULT '' COMMENT '券ID,逗号隔开', + `COUPON_NAMES` varchar(500) NOT NULL DEFAULT '' COMMENT '券名称,逗号隔开', + `NUM` int NOT NULL DEFAULT '0' COMMENT '数量', + `MONEY` decimal(10,2) NOT NULL COMMENT '总金额', + `NOTE` varchar(200) DEFAULT '' COMMENT '备注', + `MESSAGE` varchar(500) DEFAULT '' COMMENT '留言', + `CREATE_TIME` datetime NOT NULL COMMENT '赠送时间', + `UPDATE_TIME` datetime NOT NULL COMMENT '更新时间', + `STATUS` char(1) NOT NULL DEFAULT 'A' COMMENT '状态,A正常;C取消', + PRIMARY KEY (`ID`), + KEY `index_user_id` (`USER_ID`) USING BTREE, + KEY `index_give_user_id` (`GIVE_USER_ID`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=55 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='转赠记录表'; + +/*Data for the table `mt_give` */ + +insert into `mt_give`(`ID`,`USER_ID`,`MERCHANT_ID`,`STORE_ID`,`GIVE_USER_ID`,`MOBILE`,`USER_MOBILE`,`GROUP_IDS`,`GROUP_NAMES`,`COUPON_IDS`,`COUPON_NAMES`,`NUM`,`MONEY`,`NOTE`,`MESSAGE`,`CREATE_TIME`,`UPDATE_TIME`,`STATUS`) values +(1,163,1,1,693,'18976679980','18888884444','4','2021年中秋','4','酬宾早餐优惠券',1,50.00,'','转赠一张优惠券给你','2022-02-11 13:43:47','2022-02-11 13:43:47','A'), +(2,772,1,1,772,'18175702219','18175702219','12','26656','30','tanyi',1,10.00,'','转赠一张优惠券给你','2022-03-06 20:19:18','2022-03-06 20:19:18','A'), +(3,921,1,1,921,'13882064775','13882064775','6','十月份活动','14','优惠券10元',1,100.00,'','转赠一张优惠券给你','2022-04-13 19:46:41','2022-04-13 19:46:41','A'), +(4,1,1,1,163,'18976679981','18976679980','5','2021十一活动','15','100元优惠券',1,20.00,'','转赠一张优惠券给你','2022-05-11 20:43:02','2022-05-11 20:43:02','A'), +(5,1,1,1,163,'18976679981','18976679980','4','2021年中秋','3','2022年51限额500名活动预存券',1,200.00,'','转赠一张优惠券给你','2022-05-11 21:28:41','2022-05-11 21:28:41','A'), +(6,1162,1,1,1126,'18818996621','','26','全场典藏卡券(测试)','70','全场典藏卡券(测试)',1,50.00,'','转赠一张优惠券给你','2022-06-06 15:40:11','2022-06-06 15:40:11','A'), +(7,1234,1,1,1233,'13560320801','','26','全场典藏卡券(测试)','71','全场免单优惠券',1,999.00,'','转赠一张优惠券给你','2022-06-22 10:01:14','2022-06-22 10:01:14','A'), +(8,1235,1,1,1233,'13711105014','','5','2021十一活动','17','10月份优惠券',1,18.00,'','转赠一张优惠券给你','2022-06-22 10:01:25','2022-06-22 10:01:25','A'), +(9,1,1,1,163,'18976679981','18976679980','6','十月份活动','14','优惠券10元',1,100.00,'','转赠一张优惠券给你','2022-06-28 15:22:41','2022-06-28 15:22:41','A'), +(10,1322,1,1,1069,'17796656160','','5','2021十一活动','17','10月份优惠券',1,18.00,'','转赠一张优惠券给你','2022-07-14 09:35:37','2022-07-14 09:35:37','A'), +(11,1359,1,1,1356,'18208252470','','5','2021十一活动','17','10月份优惠券',1,18.00,'','转赠一张优惠券给你','2022-07-22 18:39:17','2022-07-22 18:39:17','A'), +(12,1385,1,1,1369,'15713899276','18695879188','31','test分组','94','test22272109',1,10.00,'','转赠一张优惠券给你','2022-07-29 16:54:15','2022-07-29 16:54:15','A'), +(13,1386,1,1,1369,'15713899276','18695879188','31','test分组','94','test22272109',1,10.00,'','转赠一张优惠券给你','2022-07-29 17:04:24','2022-07-29 17:04:24','A'), +(14,1392,1,1,1392,'15988426226','15988426226','35','你妹','95','你妹洗脚优惠100元抵250元',1,100.00,'','转赠一张优惠券给你','2022-07-30 18:00:13','2022-07-30 18:00:13','A'), +(15,1496,1,1,1495,'15968205442','','5','2021十一活动','17','10月份优惠券',1,18.00,'','转赠一张优惠券给你','2022-08-20 00:18:24','2022-08-20 00:18:24','A'), +(16,1592,1,1,1592,'15117012015','15117012015','12','26656','29','新年快乐',1,10.00,'','转赠一张优惠券给你','2022-09-13 21:21:16','2022-09-13 21:21:16','A'), +(17,1650,1,1,1649,'18531161003','','12','26656','29','新年快乐',1,10.00,'','转赠一张优惠券给你','2022-09-26 08:23:22','2022-09-26 08:23:22','A'), +(18,1980,1,1,1977,'18946222313','','5','2021十一活动','17','10月份优惠券',1,18.00,'','转赠一张优惠券给你','2022-11-20 17:31:21','2022-11-20 17:31:21','A'), +(19,1981,1,1,1977,'13645684859','','5','2021十一活动','15','100元优惠券',1,20.00,'','转赠一张优惠券给你','2022-11-20 17:31:59','2022-11-20 17:31:59','A'), +(20,1992,1,1,1991,'18616998528','','4','2021年中秋','11','10元无门槛电子券',1,10.00,'','转赠一张优惠券给你','2022-11-21 18:11:18','2022-11-21 18:11:18','A'), +(21,2031,1,1,1508,'18667669897','18105765365','43','用于购买会员卡券','140','升级专用001',1,599.00,'','转赠一张优惠券给你','2022-11-25 18:22:52','2022-11-25 18:22:52','A'), +(22,2100,1,1,2099,'14716981537','','4','2021年中秋','18','12月份优惠券',1,6.00,'','转赠一张优惠券给你','2022-12-06 19:24:32','2022-12-06 19:24:32','A'), +(23,2228,1,1,163,'18988877767','18976679980','39','卡券测试1','139','店庆预存卡1',1,20000.00,'','转赠一张优惠券给你','2023-01-08 23:20:49','2023-01-08 23:20:49','A'), +(24,2229,1,1,163,'18978878878','18976679980','39','卡券测试1','139','店庆预存卡1',1,20000.00,'','转赠一张优惠券给你','2023-01-08 23:21:12','2023-01-08 23:21:12','A'), +(25,2230,1,1,163,'18977776678','18976679980','39','卡券测试1','139','店庆预存卡1',1,20000.00,'','转赠一张优惠券给你','2023-01-08 23:21:39','2023-01-08 23:21:39','A'), +(26,2231,1,1,163,'18966643218','18976679980','39','卡券测试1','139','店庆预存卡1',1,20000.00,'','转赠一张优惠券给你','2023-01-08 23:28:34','2023-01-08 23:28:34','A'), +(27,2232,1,1,163,'18976656656','18976679980','39','卡券测试1','139','店庆预存卡1',1,20000.00,'','转赠一张优惠券给你','2023-01-09 07:50:51','2023-01-09 07:50:51','A'), +(28,163,1,1,163,'18976679980','18976679980','39','卡券测试1','139','店庆预存卡1',1,10000.00,'','转赠一张优惠券给你','2023-01-09 08:03:08','2023-01-09 08:03:08','A'), +(29,2021,1,1,163,'18976679981','18976679980','39','卡券测试1','139','店庆预存卡1',1,10000.00,'','转赠一张优惠券给你','2023-01-09 08:03:30','2023-01-09 08:03:30','A'), +(30,2021,1,1,163,'18976679981','18976679980','56','贷款手续费抵用券10','148','自制品礼品卡',1,10.00,'','转赠一张优惠券给你','2023-01-09 08:04:02','2023-01-09 08:04:02','A'), +(31,2021,1,1,163,'18976679981','18976679980','39','卡券测试1','139','店庆预存卡1',1,20000.00,'','转赠一张优惠券给你','2023-01-09 14:30:55','2023-01-09 14:30:55','A'), +(32,2376,1,1,2369,'15721593486','','57','2023年套餐一','153','20元优惠券',1,20.00,'','转赠一张优惠券给你','2023-02-03 14:50:39','2023-02-03 14:50:39','A'), +(33,2408,1,1,2364,'17743256453','','60','早餐','163','前台卡券',1,200.00,'','转赠一张优惠券给你','2023-02-07 15:13:34','2023-02-07 15:13:34','A'), +(34,2733,1,1,2733,'18333615432','18333615432','64','d卡券分组','180','储值卡',1,100.00,'','转赠一张优惠券给你','2023-03-07 10:58:12','2023-03-07 10:58:12','A'), +(35,3375,1,1,975,'18921201520','','45','优惠券','210','满200送50',1,50.00,'','转赠一张优惠券给你','2023-04-23 11:16:08','2023-04-23 11:16:08','A'), +(36,3586,1,1,3583,'18566798813','16620860215','71','优惠券','241','五一优惠券',1,10.00,'','转赠一张优惠券给你','2023-05-12 16:20:24','2023-05-12 16:20:24','A'), +(37,3582,1,1,3583,'18566798813','16620860215','71','优惠券','241','五一优惠券',1,10.00,'','转赠一张优惠券给你','2023-05-12 16:23:38','2023-05-12 16:23:38','A'), +(38,3627,1,1,3627,'17762624971','17762624971','71','优惠券','241','五一优惠券',1,10.00,'','转赠一张优惠券给你','2023-05-16 14:03:15','2023-05-16 14:03:15','A'), +(39,3631,1,1,3627,'17608449215','17762624971','71','优惠券','241','五一优惠券',1,10.00,'','转赠一张优惠券给你','2023-05-16 14:26:45','2023-05-16 14:26:45','A'), +(40,3646,1,1,3645,'13316396329','13620482612','45','优惠券','246','卡币',1,100.00,'','转赠一张优惠券给你','2023-05-17 09:59:18','2023-05-17 09:59:18','A'), +(41,4010,1,1,3907,'13730420256','','45','优惠券','210','满200送50',1,50.00,'','转赠一张优惠券给你','2023-06-13 09:29:39','2023-06-13 09:29:39','A'), +(42,3907,1,1,3907,'13730420256','13730420256','76','服务卡项','274','洗车券',1,10.00,'','转赠一张优惠券给你','2023-06-13 10:46:58','2023-06-13 10:46:58','A'), +(43,4492,1,1,3721,'13122858538','','71','优惠券','314','积分优惠券',1,10.00,'','转赠一张优惠券给你','2023-07-11 20:18:34','2023-07-11 20:18:34','A'), +(44,4493,1,1,3721,'17310014243','','71','优惠券','314','积分优惠券',1,10.00,'','转赠一张优惠券给你','2023-07-11 20:22:04','2023-07-11 20:22:04','A'), +(45,4493,1,1,3721,'17310014243','','71','优惠券','314','积分优惠券',1,10.00,'','转赠一张优惠券给你','2023-07-11 20:27:51','2023-07-11 20:27:51','A'), +(46,4510,1,1,4550,'18188889999','18112345678','91','游戏充值','321','穿越火线满100减50优惠券',1,50.00,'','转赠一张优惠券给你','2023-07-13 11:40:41','2023-07-13 11:40:41','A'), +(47,4493,1,1,3721,'17310014243','','71','优惠券','314','积分优惠券',1,10.00,'','转赠一张优惠券给你','2023-07-13 17:01:49','2023-07-13 17:01:49','A'), +(48,4567,1,1,4365,'15317665576','','71','优惠券','314','积分优惠券',1,10.00,'','转赠一张优惠券给你','2023-07-13 17:12:08','2023-07-13 17:12:08','A'), +(49,4567,1,1,4365,'15317665576','','71','优惠券','314','积分优惠券',1,10.00,'','转赠一张优惠券给你','2023-07-13 17:38:50','2023-07-13 17:38:50','A'), +(50,4493,1,1,3721,'17310014243','','71','优惠券','314','积分优惠券',1,10.00,'','转赠一张优惠券给你','2023-07-13 17:57:46','2023-07-13 17:57:46','A'), +(51,4493,1,1,3721,'17310014243','','71','优惠券','314','积分优惠券',1,10.00,'','转赠一张优惠券给你','2023-07-13 18:34:45','2023-07-13 18:34:45','A'), +(52,6000,1,1,6002,'18728796753','','57','2023年套餐一','153','20元优惠券',1,34.00,'','转赠一张优惠券给你','2023-07-24 19:28:55','2023-07-24 19:28:55','A'), +(53,6000,1,1,6002,'18728796753','','57','2023年套餐一','153','20元优惠券',1,34.00,'','转赠一张优惠券给你','2023-07-24 19:29:50','2023-07-24 19:29:50','A'), +(54,6038,1,1,6036,'18645122682','','57','2023年套餐一','153','20元优惠券',1,20.00,'','转赠一张优惠券给你','2023-07-25 10:16:37','2023-07-25 10:16:37','A'); + +/*Table structure for table `mt_give_item` */ + +DROP TABLE IF EXISTS `mt_give_item`; + +CREATE TABLE `mt_give_item` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `GIVE_ID` int NOT NULL COMMENT '转赠ID', + `USER_COUPON_ID` int NOT NULL COMMENT '用户电子券ID', + `CREATE_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime NOT NULL COMMENT '更新时间', + `STATUS` char(1) NOT NULL COMMENT '状态,A正常;D删除', + PRIMARY KEY (`ID`), + KEY `index_give_id` (`GIVE_ID`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=55 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='转赠明细表'; + +/*Data for the table `mt_give_item` */ + +insert into `mt_give_item`(`ID`,`GIVE_ID`,`USER_COUPON_ID`,`CREATE_TIME`,`UPDATE_TIME`,`STATUS`) values +(1,1,613,'2022-02-11 13:43:47','2022-02-11 13:43:47','A'), +(2,2,1658,'2022-03-06 20:19:18','2022-03-06 20:19:18','A'), +(3,3,122298,'2022-04-13 19:46:41','2022-04-13 19:46:41','A'), +(4,4,15,'2022-05-11 20:43:02','2022-05-11 20:43:02','A'), +(5,5,44,'2022-05-11 21:28:41','2022-05-11 21:28:41','A'), +(6,6,1798,'2022-06-06 15:40:11','2022-06-06 15:40:11','A'), +(7,7,2404,'2022-06-22 10:01:14','2022-06-22 10:01:14','A'), +(8,8,2405,'2022-06-22 10:01:25','2022-06-22 10:01:25','A'), +(9,9,2621,'2022-06-28 15:22:41','2022-06-28 15:22:41','A'), +(10,10,67,'2022-07-14 09:35:37','2022-07-14 09:35:37','A'), +(11,11,23,'2022-07-22 18:39:17','2022-07-22 18:39:17','A'), +(12,12,400,'2022-07-29 16:54:15','2022-07-29 16:54:15','A'), +(13,13,399,'2022-07-29 17:04:24','2022-07-29 17:04:24','A'), +(14,14,419,'2022-07-30 18:00:13','2022-07-30 18:00:13','A'), +(15,15,30701,'2022-08-20 00:18:24','2022-08-20 00:18:24','A'), +(16,16,211369,'2022-09-13 21:21:16','2022-09-13 21:21:16','A'), +(17,17,211502,'2022-09-26 08:23:22','2022-09-26 08:23:22','A'), +(18,18,19294,'2022-11-20 17:31:21','2022-11-20 17:31:21','A'), +(19,19,19548,'2022-11-20 17:31:59','2022-11-20 17:31:59','A'), +(20,20,19575,'2022-11-21 18:11:18','2022-11-21 18:11:18','A'), +(21,21,20280,'2022-11-25 18:22:52','2022-11-25 18:22:52','A'), +(22,22,29107,'2022-12-06 19:24:32','2022-12-06 19:24:32','A'), +(23,23,31903,'2023-01-08 23:20:49','2023-01-08 23:20:49','A'), +(24,24,31903,'2023-01-08 23:21:12','2023-01-08 23:21:12','A'), +(25,25,31903,'2023-01-08 23:21:39','2023-01-08 23:21:39','A'), +(26,26,31903,'2023-01-08 23:28:34','2023-01-08 23:28:34','A'), +(27,27,31903,'2023-01-09 07:50:51','2023-01-09 07:50:51','A'), +(28,28,31902,'2023-01-09 08:03:08','2023-01-09 08:03:08','A'), +(29,29,31902,'2023-01-09 08:03:30','2023-01-09 08:03:30','A'), +(30,30,31765,'2023-01-09 08:04:02','2023-01-09 08:04:02','A'), +(31,31,26562,'2023-01-09 14:30:55','2023-01-09 14:30:55','A'), +(32,32,42627,'2023-02-03 14:50:39','2023-02-03 14:50:39','A'), +(33,33,42858,'2023-02-07 15:13:34','2023-02-07 15:13:34','A'), +(34,34,600134,'2023-03-07 10:58:12','2023-03-07 10:58:12','A'), +(35,35,7000,'2023-04-23 11:16:08','2023-04-23 11:16:08','A'), +(36,36,674,'2023-05-12 16:20:24','2023-05-12 16:20:24','A'), +(37,37,670,'2023-05-12 16:23:38','2023-05-12 16:23:38','A'), +(38,38,854,'2023-05-16 14:03:15','2023-05-16 14:03:15','A'), +(39,39,854,'2023-05-16 14:26:45','2023-05-16 14:26:45','A'), +(40,40,870,'2023-05-17 09:59:18','2023-05-17 09:59:18','A'), +(41,41,1166,'2023-06-13 09:29:39','2023-06-13 09:29:39','A'), +(42,42,1198,'2023-06-13 10:46:58','2023-06-13 10:46:58','A'), +(43,43,1520,'2023-07-11 20:18:34','2023-07-11 20:18:34','A'), +(44,44,1521,'2023-07-11 20:22:04','2023-07-11 20:22:04','A'), +(45,45,1522,'2023-07-11 20:27:51','2023-07-11 20:27:51','A'), +(46,46,1555,'2023-07-13 11:40:41','2023-07-13 11:40:41','A'), +(47,47,1558,'2023-07-13 17:01:49','2023-07-13 17:01:49','A'), +(48,48,1560,'2023-07-13 17:12:08','2023-07-13 17:12:08','A'), +(49,49,1561,'2023-07-13 17:38:50','2023-07-13 17:38:50','A'), +(50,50,1559,'2023-07-13 17:57:46','2023-07-13 17:57:46','A'), +(51,51,1570,'2023-07-13 18:34:45','2023-07-13 18:34:45','A'), +(52,52,5114,'2023-07-24 19:28:55','2023-07-24 19:28:55','A'), +(53,53,5128,'2023-07-24 19:29:50','2023-07-24 19:29:50','A'), +(54,54,5152,'2023-07-25 10:16:37','2023-07-25 10:16:37','A'); + +/*Table structure for table `mt_goods` */ + +DROP TABLE IF EXISTS `mt_goods`; + +CREATE TABLE `mt_goods` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `TYPE` varchar(30) DEFAULT 'product' COMMENT '商品类别', + `MERCHANT_ID` int DEFAULT '0' COMMENT '所属商户ID', + `STORE_ID` int DEFAULT '0' COMMENT '所属店铺ID', + `NAME` varchar(100) DEFAULT '' COMMENT '商品名称', + `CATE_ID` int DEFAULT '0' COMMENT '分类ID', + `GOODS_NO` varchar(100) DEFAULT '' COMMENT '商品编码', + `IS_SINGLE_SPEC` char(1) NOT NULL DEFAULT 'Y' COMMENT '是否单规格', + `LOGO` varchar(200) DEFAULT '' COMMENT '主图地址', + `IMAGES` varchar(1000) DEFAULT '' COMMENT '图片地址', + `PRICE` decimal(10,2) unsigned DEFAULT '0.00' COMMENT '价格', + `LINE_PRICE` decimal(10,2) unsigned DEFAULT '0.00' COMMENT '划线价格', + `STOCK` int unsigned DEFAULT '0' COMMENT '库存', + `WEIGHT` decimal(10,2) DEFAULT '0.00' COMMENT '重量', + `COUPON_IDS` varchar(500) DEFAULT '' COMMENT '关联卡券ID', + `SERVICE_TIME` int DEFAULT '0' COMMENT '服务时长,单位:分钟', + `INIT_SALE` int DEFAULT '0' COMMENT '初始销量', + `SALE_POINT` varchar(100) DEFAULT '' COMMENT '商品卖点', + `CAN_USE_POINT` char(1) DEFAULT 'N' COMMENT '可否使用积分抵扣', + `IS_MEMBER_DISCOUNT` char(1) DEFAULT 'Y' COMMENT '会员是否有折扣', + `SORT` int DEFAULT '0' COMMENT '排序', + `DESCRIPTION` text COMMENT '商品描述', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `OPERATOR` varchar(30) DEFAULT NULL COMMENT '最后操作人', + `STATUS` char(1) DEFAULT 'A' COMMENT 'A:正常;D:删除', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB AUTO_INCREMENT=386 DEFAULT CHARSET=utf8 COMMENT='商品表'; + +/*Data for the table `mt_goods` */ + +insert into `mt_goods`(`ID`,`TYPE`,`MERCHANT_ID`,`STORE_ID`,`NAME`,`CATE_ID`,`GOODS_NO`,`IS_SINGLE_SPEC`,`LOGO`,`IMAGES`,`PRICE`,`LINE_PRICE`,`STOCK`,`WEIGHT`,`COUPON_IDS`,`SERVICE_TIME`,`INIT_SALE`,`SALE_POINT`,`CAN_USE_POINT`,`IS_MEMBER_DISCOUNT`,`SORT`,`DESCRIPTION`,`CREATE_TIME`,`UPDATE_TIME`,`OPERATOR`,`STATUS`) values +(1,'product',1,0,'韩式防水围裙',1,'9983242340','N','/static/uploadImages/20220110/4c90921a7fc34c97b0f62cebf314d2bb.jpg','[\"/static/uploadImages/20220110/4c90921a7fc34c97b0f62cebf314d2bb.jpg\",\"/static/uploadImages/20220110/9b64b3d65fa04296b62de186899f24ea.jpg\",\"/static/uploadImages/20220110/ff4809f7a17d4142ace9bc287aab105a.jpg\"]',88.00,99.00,90013,1.00,'',0,747,'超级防水','Y','Y',1,'

1234444

','2021-10-13 13:56:04','2023-07-31 19:51:21','fuint','A'), +(2,'product',1,0,'小清新水果刀三件套',4,'6975486820418','Y','/static/uploadImages/20220110/6b67b70f35734ff28a03aa3d82ac96a0.jpg','[\"/static/uploadImages/20220110/6b67b70f35734ff28a03aa3d82ac96a0.jpg\"]',0.01,20.00,1946,2.00,'',0,33,'小清新','Y','N',1,'

123

','2021-10-13 14:19:45','2023-07-31 20:01:44','fuint','A'), +(3,'product',1,0,'可爱旅行大号牙刷杯两个装',3,'92342342342','N','/static/uploadImages/20220110/56e306c812f240f89c0ed96ab8f94ad0.jpg','[\"/static/uploadImages/20220110/56e306c812f240f89c0ed96ab8f94ad0.jpg\",\"/static/uploadImages/20220110/56e306c812f240f89c0ed96ab8f94ad0.jpg\",\"/static/uploadImages/20220110/d39f84568b9746f89d9f6a368b8067c4.jpg\"]',99.00,120.00,6000,1.00,'',0,1532,'超级实惠','Y','Y',1,'


','2021-10-14 01:08:45','2023-09-22 13:38:42','fuint','A'), +(4,'product',1,0,'筷子便携餐盒3件套',1,'6914068026176','N','/static/uploadImages/20220110/31cbf7ad0ef442a4b10dcefc24db0662.jpg','[\"/static/uploadImages/20220110/31cbf7ad0ef442a4b10dcefc24db0662.jpg\"]',80.00,99.00,4010,1.00,'',0,1325,'一体成型','Y','N',1,'

测试商品

','2021-10-14 05:46:23','2023-07-28 15:13:50','fuint','A'), +(5,'product',1,0,'简壳 一拖三可收纳伸缩充电线',2,'6922577729501','N','/static/uploadImages/20220110/856dbc96197e4782b4febb7a6e671bcb.jpg','[\"/static/uploadImages/20220110/856dbc96197e4782b4febb7a6e671bcb.jpg\"]',0.10,100.00,3877,0.00,'',0,1168,'可伸缩','Y','Y',1,'


','2021-10-14 05:47:31','2023-07-24 19:00:45','fuint','A'), +(6,'product',1,0,'抽绳垃圾袋16只*4卷',1,'6975486820418','Y','/static/uploadImages/20220110/6083071182cd48afa6c2b9e23f181832.jpg','[\"/static/uploadImages/20220110/6083071182cd48afa6c2b9e23f181832.jpg\",\"/static/uploadImages/20220110/ee5c67ed338442fc90e5c647ccbfd381.jpg\"]',18.00,20.00,109528,1.00,'',11,4209,'厨房必备小帮手','Y','Y',0,'

','2021-10-14 05:48:43','2023-07-31 20:00:49','fuint','A'); + +/*Table structure for table `mt_goods_cate` */ + +DROP TABLE IF EXISTS `mt_goods_cate`; + +CREATE TABLE `mt_goods_cate` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `MERCHANT_ID` int DEFAULT '0' COMMENT '所属商户', + `STORE_ID` int DEFAULT '0' COMMENT '所属店铺', + `NAME` varchar(100) DEFAULT '' COMMENT '分类名称', + `LOGO` varchar(200) DEFAULT '' COMMENT 'LOGO地址', + `DESCRIPTION` text COMMENT '分类描述', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `OPERATOR` varchar(30) DEFAULT NULL COMMENT '最后操作人', + `SORT` int DEFAULT '0' COMMENT '排序', + `STATUS` char(1) DEFAULT 'A' COMMENT 'A:正常;D:删除', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB AUTO_INCREMENT=189 DEFAULT CHARSET=utf8 COMMENT='商品分类表'; + +/*Data for the table `mt_goods_cate` */ + +insert into `mt_goods_cate`(`ID`,`MERCHANT_ID`,`STORE_ID`,`NAME`,`LOGO`,`DESCRIPTION`,`CREATE_TIME`,`UPDATE_TIME`,`OPERATOR`,`SORT`,`STATUS`) values +(1,1,0,'生活用品','/static/defaultImage/life.png','1234','2021-10-09 06:27:11','2023-07-24 23:30:10','fuint',1,'A'), +(2,1,0,'办公用品','/static/defaultImage/office.png','','2021-10-09 06:27:11','2023-07-21 18:47:52','fuint',3,'A'), +(3,1,0,'好物推荐','/static/defaultImage/love.png','好物推荐','2021-10-09 06:27:11','2023-07-24 19:13:13','fuint',1,'A'), +(4,1,0,'打折热销','/static/defaultImage/hot.png','低价甩卖','2021-10-14 02:20:00','2023-07-27 17:04:42','fuint',3,'A'), +(187,2,0,'美妆','/static/uploadImages/20230918/7567dc29707c41dca8381cc072944d2f.PNG','123','2023-09-18 17:53:49','2023-09-18 17:53:49','anan',0,'A'), +(188,2,0,'办公','/static/uploadImages/20230918/ebfab5816a374bec97fb223b51cf63fe.png','123','2023-09-18 17:54:37','2023-09-18 17:54:37','anan',0,'A'); + +/*Table structure for table `mt_goods_sku` */ + +DROP TABLE IF EXISTS `mt_goods_sku`; + +CREATE TABLE `mt_goods_sku` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `SKU_NO` varchar(50) DEFAULT '' COMMENT 'sku编码', + `LOGO` varchar(255) DEFAULT '' COMMENT '图片', + `GOODS_ID` int NOT NULL DEFAULT '0' COMMENT '商品ID', + `SPEC_IDS` varchar(100) NOT NULL DEFAULT '' COMMENT '规格ID', + `STOCK` int NOT NULL DEFAULT '0' COMMENT '库存', + `PRICE` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '价格', + `LINE_PRICE` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '划线价格', + `WEIGHT` decimal(10,2) DEFAULT '0.00' COMMENT '重量', + `STATUS` char(1) NOT NULL DEFAULT 'A' COMMENT '状态', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB AUTO_INCREMENT=745 DEFAULT CHARSET=utf8 COMMENT='商品SKU表'; + +/*Data for the table `mt_goods_sku` */ + +insert into `mt_goods_sku`(`ID`,`SKU_NO`,`LOGO`,`GOODS_ID`,`SPEC_IDS`,`STOCK`,`PRICE`,`LINE_PRICE`,`WEIGHT`,`STATUS`) values +(142,'','',27,'46',0,0.00,0.00,0.00,'A'), +(143,'','',27,'47',0,0.00,0.00,0.00,'A'), +(145,'','',37,'56',51,200.00,300.00,1.20,'A'), +(189,'','',40,'66-69',1,1.00,1.00,1.00,'A'), +(190,'','',40,'66-70',1,1.00,1.00,1.00,'A'), +(191,'','',40,'67-69',1,1.00,1.00,1.00,'A'), +(192,'','',40,'67-70',1,1.00,1.00,1.00,'A'), +(193,'','',40,'68-69',1,1.00,1.00,1.00,'A'), +(194,'','',40,'68-70',1,1.00,1.00,1.00,'A'), +(261,'8888880','',45,'86',88,10.00,20.00,2.00,'A'), +(262,'8888881','',45,'87',90,10.00,20.00,2.00,'A'), +(263,'8888882','',45,'88',89,10.00,20.00,2.00,'A'), +(264,'8888883','',45,'89',90,10.00,20.00,2.00,'A'), +(265,'34234','',48,'90',220,21.00,112.00,1.00,'A'), +(266,'234230','',51,'92',100,10.00,12.00,1.00,'A'), +(267,'234231','',51,'93',98,10.00,12.00,1.00,'A'), +(269,'34235','',48,'95',887,20.00,120.00,1.00,'A'), +(315,'2222','/uploads/20230228/656a1aef1e8c4a8e8e80c5b817e15255.jpg',79,'138-142',999,24.00,24.00,2.00,'A'), +(317,'4444','',79,'139-142',999,24.00,24.00,2.00,'A'), +(339,'111111','/uploads/20230307/55126b64546945f4a6393ad5259cfc03.jpg',86,'153',100,0.01,99.00,0.00,'A'), +(340,'222222','/uploads/20230307/67d54c99787b4114affd86c5248d1431.jpg',86,'157',100,0.01,99.00,0.00,'A'), +(341,'333333','/uploads/20230307/72cc5a1c16ee4c21a8ea35612741f87e.jpg',86,'158',98,0.01,99.00,0.00,'A'), +(386,'','',91,'185',0,0.00,0.00,0.00,'A'), +(387,'SKU12434','/uploads/20230314/7333fe6a66884de59e560278c2de609b.jpg',95,'191-193',99,10.00,15.00,1.00,'A'), +(388,'SKU12432','/uploads/20230314/0d4f3ea2741e495f82a23f8443b54e18.jpg',95,'191-194',98,10.00,15.00,1.00,'A'), +(389,'SKU12442','/uploads/20230314/e87014e2f81c466398e35a01472cedb4.jpg',95,'192-193',100,19.00,25.00,1.00,'A'), +(390,'SKU12423','/uploads/20230314/4aab2fc389a54de6b66c19b69eff8ebc.jpg',95,'192-194',98,19.00,25.00,1.00,'A'), +(391,'瓶','',96,'195',4,3.00,3.00,500.00,'A'), +(424,'1230','',119,'220',100,1.00,0.00,1.00,'A'), +(425,'1231','',119,'223',100,1.00,0.00,1.00,'A'), +(426,'1232','',119,'224',100,1.00,0.00,1.00,'A'), +(427,'1233','',119,'225',100,1.00,0.00,1.00,'A'), +(515,'34423423420','',5,'214-215',898,99.00,100.00,1.00,'A'), +(516,'34423423421','',5,'214-217',931,99.00,100.00,1.00,'A'), +(517,'34423423422','',5,'216-215',954,99.00,100.00,1.00,'A'), +(518,'34423423423','',5,'216-217',838,99.00,100.00,1.00,'A'), +(519,'','',140,'262',0,0.00,0.00,0.00,'A'), +(547,'79232344230','',165,'274',100,3.99,5.00,0.25,'A'), +(548,'79232344231','',165,'275',100,6.00,7.00,0.25,'A'), +(555,'','',169,'282-286',9,189.00,289.00,0.00,'A'), +(556,'','',169,'282-287',10,189.00,289.00,0.00,'A'), +(557,'','',169,'282-288',10,189.00,289.00,0.00,'A'), +(558,'','',169,'282-289',10,189.00,289.00,0.00,'A'), +(559,'','',169,'282-290',10,189.00,289.00,0.00,'A'), +(560,'','',169,'283-286',10,189.00,289.00,0.00,'A'), +(561,'','',169,'283-287',9,189.00,289.00,0.00,'A'), +(562,'','',169,'283-288',9,189.00,289.00,0.00,'A'), +(563,'','',169,'283-289',10,189.00,289.00,0.00,'A'), +(564,'','',169,'283-290',10,189.00,289.00,0.00,'A'), +(565,'','',169,'285-286',10,189.00,289.00,0.00,'A'), +(566,'','',169,'285-287',10,189.00,289.00,0.00,'A'), +(567,'','',169,'285-288',8,189.00,289.00,0.00,'A'), +(568,'','',169,'285-289',9,189.00,289.00,0.00,'A'), +(569,'','',169,'285-290',6,189.00,289.00,0.00,'A'), +(583,'4353452','/uploads/20230609/92a39796268246c7865ff10d560a9d10.gif',176,'296',7,56.00,80.00,0.00,'A'), +(584,'45345','',177,'297',88,677.00,5888.00,0.00,'A'), +(585,'45345345','',177,'299',75,888.00,8888.00,0.00,'A'), +(604,'','',169,'309-286',0,0.00,0.00,0.00,'A'), +(605,'','',169,'309-287',0,0.00,0.00,0.00,'A'), +(606,'','',169,'309-288',0,0.00,0.00,0.00,'A'), +(607,'','',169,'309-289',0,0.00,0.00,0.00,'A'), +(608,'','',169,'309-290',0,0.00,0.00,0.00,'A'), +(609,'','',183,'310-311',10,99.00,0.00,0.00,'A'), +(610,'','',183,'310-312',10,99.00,0.00,0.00,'A'), +(611,'','',183,'310-313',10,99.00,0.00,0.00,'A'), +(612,'','',183,'310-314',10,99.00,0.00,0.00,'A'), +(613,'','',183,'310-315',10,99.00,0.00,0.00,'A'), +(614,'','',183,'310-316',10,99.00,0.00,0.00,'A'), +(615,'','',183,'317-311',10,99.00,0.00,0.00,'A'), +(616,'','',183,'317-312',10,99.00,0.00,0.00,'A'), +(617,'','',183,'317-313',10,99.00,0.00,0.00,'A'), +(618,'','',183,'317-314',10,99.00,0.00,0.00,'A'), +(619,'','',183,'317-315',10,99.00,0.00,0.00,'A'), +(620,'','',183,'317-316',10,99.00,0.00,0.00,'A'), +(621,'','',183,'318-311',10,99.00,0.00,0.00,'A'), +(622,'','',183,'318-312',10,99.00,0.00,0.00,'A'), +(623,'','',183,'318-313',10,99.00,0.00,0.00,'A'), +(624,'','',183,'318-314',10,99.00,0.00,0.00,'A'), +(625,'','',183,'318-315',10,99.00,0.00,0.00,'A'), +(626,'','',183,'318-316',9,99.00,0.00,0.00,'A'), +(627,'1','',187,'324',20,22.00,25.00,0.50,'A'), +(628,'2','',187,'325',20,40.00,50.00,1.00,'A'), +(629,'1','',185,'327',0,120.00,150.00,5.00,'A'), +(630,'2','',185,'328',1,150.00,180.00,5.00,'A'), +(631,'3','',185,'329',0,200.00,250.00,5.00,'A'), +(644,'','/uploads/20230628/0c17bcee89dc4838be59aba2db990e22.png',197,'339',997,68.00,0.00,0.00,'A'), +(659,'180521342436380','',207,'345-351-353',1,1.00,1.00,1.00,'A'), +(660,'180521342436381','',207,'348-351-353',1,1.00,1.00,1.00,'A'), +(661,'179699761475660','',232,'355-356',10,20.00,30.00,1.00,'A'), +(662,'179699761475661','',232,'355-357',10,30.00,60.00,1.00,'A'), +(663,'179699761475662','',232,'358-356',1,20.00,30.00,1.00,'A'), +(664,'179699761475663','',232,'358-357',2,30.00,60.00,1.00,'A'), +(669,'148503337738370','',305,'372-374',10,99.00,299.00,0.00,'A'), +(670,'148503337738371','',305,'372-375',10,99.00,299.00,0.00,'A'), +(671,'148503337738372','',305,'373-374',10,99.00,299.00,0.00,'A'), +(672,'148503337738373','',305,'373-375',10,99.00,299.00,0.00,'A'), +(673,'','',361,'388',0,0.00,0.00,0.00,'A'), +(674,'','',361,'389',0,0.00,0.00,0.00,'A'), +(675,'','',361,'390',0,0.00,0.00,0.00,'A'), +(676,'','',361,'391',0,0.00,0.00,0.00,'A'), +(677,'','',361,'393',0,0.00,0.00,0.00,'A'), +(689,'164348379384740','',382,'413-416-419',990,18.00,0.00,0.00,'A'), +(690,'164348379384741','',382,'413-417-419',990,18.00,0.00,0.00,'A'), +(691,'164348379384742','',382,'413-418-419',990,18.00,0.00,0.00,'A'), +(692,'164348379384743','',382,'414-416-419',990,18.00,0.00,0.00,'A'), +(693,'164348379384744','',382,'414-417-419',990,18.00,0.00,0.00,'A'), +(694,'164348379384745','',382,'414-418-419',990,18.00,0.00,0.00,'A'), +(695,'164348379384746','',382,'415-416-419',990,18.00,0.00,0.00,'A'), +(696,'164348379384747','',382,'415-417-419',990,18.00,0.00,0.00,'A'), +(697,'164348379384748','',382,'415-418-419',990,18.00,0.00,0.00,'A'), +(710,'125946837840450','',1,'107-180',10004,88.00,99.00,1.00,'A'), +(711,'125946837840451','',1,'107-331',10002,88.00,99.00,1.00,'A'), +(712,'125946837840452','',1,'107-421',10001,88.00,99.00,1.00,'A'), +(716,'134518978667720','',4,'402-404',1000,80.00,99.00,1.00,'A'), +(717,'134518978667721','',4,'402-405',1000,80.00,99.00,1.00,'A'), +(718,'134518978667722','',4,'403-404',997,80.00,99.00,1.00,'A'), +(719,'134518978667723','',4,'403-405',995,80.00,99.00,1.00,'A'), +(732,'155430306154340','',384,'430',1,1.00,1.00,1.00,'A'), +(733,'125946837840453','',1,'431-180',10000,88.00,99.00,1.00,'A'), +(734,'125946837840454','',1,'431-331',9998,88.00,99.00,1.00,'A'), +(735,'125946837840455','',1,'431-421',10000,88.00,99.00,1.00,'A'), +(736,'125946837840456','',1,'432-180',10000,88.00,99.00,1.00,'A'), +(737,'125946837840457','',1,'432-331',9999,88.00,99.00,1.00,'A'), +(738,'125946837840458','',1,'432-421',9998,88.00,99.00,1.00,'A'), +(739,'197171320996910','',3,'6-74-401',1000,99.00,120.00,1.00,'A'), +(740,'197171320996911','',3,'6-75-401',1000,99.00,120.00,1.00,'A'), +(741,'197171320996912','',3,'6-429-401',1000,99.00,120.00,1.00,'A'), +(742,'197171320996913','',3,'7-74-401',1000,99.00,120.00,1.00,'A'), +(743,'197171320996914','',3,'7-75-401',1000,99.00,120.00,1.00,'A'), +(744,'197171320996915','',3,'7-429-401',1000,99.00,120.00,1.00,'A'); + +/*Table structure for table `mt_goods_spec` */ + +DROP TABLE IF EXISTS `mt_goods_spec`; + +CREATE TABLE `mt_goods_spec` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `GOODS_ID` int NOT NULL DEFAULT '0' COMMENT '商品ID', + `NAME` varchar(100) NOT NULL DEFAULT '' COMMENT '规格名称', + `VALUE` varchar(100) NOT NULL DEFAULT '' COMMENT '规格值', + `STATUS` char(1) DEFAULT 'A' COMMENT '状态', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB AUTO_INCREMENT=433 DEFAULT CHARSET=utf8 COMMENT='规格表'; + +/*Data for the table `mt_goods_spec` */ + +insert into `mt_goods_spec`(`ID`,`GOODS_ID`,`NAME`,`VALUE`,`STATUS`) values +(1,6,'厚度','正常','D'), +(2,6,'厚度','加厚','D'), +(3,6,'糖分','黑色','D'), +(4,6,'糖分','黄色','D'), +(5,6,'糖分','白色','D'), +(6,3,'材质','304不锈钢','A'), +(7,3,'材质','塑料','A'), +(8,6,'尺码','m','D'), +(9,6,'尺码','l','D'), +(10,6,'口味','1','D'), +(11,6,'口味','2','D'), +(12,6,'口味','3','D'), +(13,2,'m','m','D'), +(14,6,'厚度','超薄','D'), +(15,16,'风味','孜然','D'), +(16,16,'特色','炭火','D'), +(17,16,'风味','秘制','D'), +(18,16,'特色','木炭','D'), +(19,16,'特色','风味小吃','D'), +(20,6,'大小','啥啥啥','D'), +(21,6,'大小','L','D'), +(22,24,'500ML','7','D'), +(23,24,'700ML','10','D'), +(24,24,'小杯','500ML','A'), +(25,24,'大杯','700ML','D'), +(26,24,'大杯','700ML','D'), +(27,24,'小杯','122','D'), +(28,24,'小杯','任天野','D'), +(29,24,'小杯','700ML','A'), +(30,6,'大小','12','D'), +(31,6,'2','3','D'), +(32,6,'1','','D'), +(33,6,'大小','M','D'), +(34,6,'大小','L','D'), +(35,11,'ddd','rr','A'), +(36,11,'gggg','ttt','A'), +(37,11,'ddd','yyu','A'), +(38,11,'gggg','==999','A'), +(39,12,'1','1,2','A'), +(40,16,'年份','82年','A'), +(41,16,'年份','90年','A'), +(42,16,'年份','00年','A'), +(43,6,'尺码','大','D'), +(44,6,'尺码','小','D'), +(45,2,'7','','D'), +(46,27,'颜色','红色','A'), +(47,27,'颜色','白色','A'), +(48,2,'大小','5','D'), +(49,2,'品牌','6','D'), +(50,2,'大小','IIS','D'), +(51,2,'品牌','8','D'), +(52,6,'xxx','','D'), +(53,6,'糖分','绿色','D'), +(54,37,'test1','12','D'), +(55,37,'test2','13','D'), +(56,37,'test1','123','A'), +(57,38,'颜色','黑色','A'), +(58,38,'颜色','蓝色','A'), +(59,38,'颜色','绿色','D'), +(60,38,'大小','大号','A'), +(61,38,'大小','小号','A'), +(62,38,'颜色','绿色','D'), +(63,4,'颜色','红色','D'), +(64,6,'重量','10KG','D'), +(65,6,'重量','10g','D'), +(66,40,'时长','两小时','A'), +(67,40,'时长','三小时','A'), +(68,40,'时长','四小时','A'), +(69,40,'面积','80平米','A'), +(70,40,'面积','100平米','A'), +(71,41,'11','1','A'), +(72,41,'11','11','A'), +(73,41,'11','111','A'), +(74,3,'颜色','粉红色','A'), +(75,3,'颜色','黑色','A'), +(76,6,'jj','','D'), +(77,6,'重量','nihao','D'), +(78,6,'糖分','红色','D'), +(79,6,'糖分','紫色','D'), +(80,6,'nih','hth','D'), +(81,2,'颜色','1111','D'), +(82,6,'糖分','蓝色','D'), +(83,6,'大小','XL','D'), +(84,6,'呃呃','','D'), +(86,45,'容量','300W','A'), +(87,45,'容量','300W','A'), +(88,45,'容量','300','A'), +(89,45,'容量','300','A'), +(90,48,'颜色','红色','A'), +(91,48,'1','','D'), +(92,51,'颜色','白色','A'), +(93,51,'颜色','黑色','A'), +(94,51,'颜色','绿色','D'), +(95,48,'颜色','黑色','A'), +(96,52,'eee','12','D'), +(97,52,'eee','222','D'), +(98,52,'dfsfsa','33','A'), +(99,52,'dfsfsa','22','A'), +(100,53,'ddd','','D'), +(101,53,'天泰','营业','A'), +(102,52,'eee','22','D'), +(103,1,'123','123','D'), +(104,1,'123123','','D'), +(105,1,'123','qwe123','D'), +(106,1,'123','qwe123','D'), +(107,1,'尺码','39','A'), +(108,1,'尺码','39','D'), +(109,1,'尺码','40','D'), +(110,6,'糖分','d','D'), +(111,5,'abg','1','D'), +(112,5,'abg','1234','D'), +(113,6,'款式','长','D'), +(114,6,'款式','A','D'), +(115,6,'款式','宽','D'), +(116,65,'套房','套一','A'), +(117,69,'小码','S','A'), +(118,69,'小码','d','A'), +(119,4,'颜色','蓝色','D'), +(120,4,'颜色','蓝色','D'), +(121,2,'大小','L','D'), +(122,2,'品牌','10','D'), +(123,4,'颜色','白色','D'), +(124,4,'颜色','黑色','D'), +(125,4,'颜色','黑色','D'), +(126,6,'test','1','D'), +(127,76,'颜色','黄色','A'), +(128,76,'颜色','黄','D'), +(129,76,'尺码','L','A'), +(130,76,'颜色','1','D'), +(131,76,'颜色','蓝色','A'), +(132,76,'尺码','M','A'), +(133,6,'款式','高','D'), +(134,6,'款式','宽','D'), +(135,6,'款式','宽','D'), +(136,79,'颜色','大小','D'), +(137,79,'颜色','规格','D'), +(138,79,'颜色','红色','A'), +(139,79,'颜色','绿色','A'), +(140,79,'大小','黄色','D'), +(141,79,'大小','500ml','D'), +(142,79,'大小','1L','A'), +(143,6,'款式','宽','D'), +(144,6,'款式','宽','D'), +(145,6,'款式','宽','D'), +(146,6,'款式','11','D'), +(147,81,'caoi','1','A'), +(148,81,'caoi','1','A'), +(149,81,'caoi','2','A'), +(150,81,'iphone','64g','A'), +(151,81,'iphone','128g','A'), +(152,81,'iphone','256g','D'), +(153,86,'颜色','红','A'), +(154,86,'颜色','黄色','D'), +(155,86,'颜色','红色','D'), +(156,86,'颜色','绿色','D'), +(157,86,'颜色','黄','A'), +(158,86,'颜色','绿','A'), +(159,90,'33','33','A'), +(160,90,'3','','A'), +(161,90,'4','5','A'), +(162,91,'华为','1号','D'), +(163,91,'hw','01','D'), +(164,91,'xm','01','A'), +(165,91,'xm','02','A'), +(166,91,'xm','03','A'), +(167,91,'hw','02','A'), +(168,91,'hw','03','A'), +(169,91,'xm','01','D'), +(170,91,'xm','02','D'), +(171,91,'xm','03','D'), +(172,91,'hw','01','D'), +(173,91,'xm','01','D'), +(174,91,'hw','02','D'), +(175,91,'xm','02','D'), +(176,91,'hw','03','D'), +(177,91,'xm','03','D'), +(178,91,'xm','04','D'), +(179,91,'xm','04','D'), +(180,1,'颜色','黑色','A'), +(181,1,'颜色','蓝色','D'), +(182,1,'颜色','黄色','D'), +(183,1,'卡通图','米老鼠','D'), +(184,1,'卡通图','唐老鸭','D'), +(185,91,'原味','','A'), +(186,91,'味道','原味','A'), +(187,91,'味道','酸辣','A'), +(188,93,'打包','小包','A'), +(189,93,'打包','的','A'), +(190,95,'数量','口味','D'), +(191,95,'数量','一包','A'), +(192,95,'数量','两包','A'), +(193,95,'口味','奶香味','A'), +(194,95,'口味','草莓味','A'), +(195,96,'口味','普通','A'), +(196,110,'lll','iiii','A'), +(197,110,'lll','iiii','A'), +(198,110,'9999','llll','A'), +(199,110,'9999','9999','A'), +(200,110,'8888','99999','A'), +(201,110,'8888','7777','A'), +(202,1,'尺码','43','D'), +(203,6,'111','11','D'), +(204,6,'糖分','1','D'), +(205,6,'糖分','2','D'), +(206,6,'糖分','3','D'), +(207,6,'糖分','4','D'), +(208,6,'糖分','5','D'), +(209,6,'糖分','6','D'), +(210,6,'糖分','7','D'), +(211,6,'糖分','8','D'), +(212,6,'糖分','9','D'), +(213,6,'糖分','10','D'), +(214,5,'A','A-1','A'), +(215,5,'B','B-1','A'), +(216,5,'A','A-2','A'), +(217,5,'B','B-2','A'), +(218,6,'款式','13','D'), +(219,119,'代杀','1','D'), +(220,119,'可选备注','','A'), +(221,119,'代杀','代杀','A'), +(222,119,'代杀','不杀','A'), +(223,119,'可选备注','杀(清洗)','A'), +(224,119,'可选备注','杀(不清洗)','A'), +(225,119,'可选备注','不杀','A'), +(226,122,'大小','小','A'), +(227,122,'大小','中','A'), +(228,122,'大小','大','A'), +(229,122,'甜度','少','A'), +(230,122,'甜度','多','A'), +(231,122,'甜度','超多','A'), +(232,122,'abc','1','A'), +(233,122,'abc','23','A'), +(234,122,'abc','33','D'), +(235,131,'小轿车','','A'), +(236,131,'法拉利','','A'), +(237,131,'兰博基尼','','A'), +(238,122,'234','','A'), +(239,5,'qwe','','D'), +(240,5,'B','w','D'), +(241,5,'B','3','D'), +(242,6,'长度','1','D'), +(243,6,'长度','2','D'), +(244,6,'长度','0','D'), +(245,6,'款式','西米','D'), +(246,6,'款式','红豆','D'), +(247,135,'尺寸','大杯','A'), +(248,135,'尺寸','中杯','A'), +(249,135,'尺寸','小杯','A'), +(250,135,'温度','热','A'), +(251,135,'温度','常温','A'), +(252,135,'温度','冰','A'), +(253,135,'颜色','白色','A'), +(254,135,'颜色','白色','D'), +(255,135,'颜色','黑色','A'), +(258,6,'nihoa','','D'), +(260,2,'大小','M','D'), +(261,2,'大小','XL','D'), +(262,140,'222','333','A'), +(263,141,'123','345','D'), +(264,141,'小','1','D'), +(265,141,'小','2','D'), +(266,3,'颜色','白色','D'), +(267,6,'大小','s','D'), +(268,6,'大小','XXL','D'), +(269,6,'长度','3','D'), +(270,6,'长度','ww','D'), +(271,6,'宽度','1','D'), +(272,1,'卡通图','唐老鸭','D'), +(273,165,'单卖','包装','D'), +(274,165,'单卖','1','A'), +(275,165,'单卖','2','A'), +(276,6,'长度','1M','D'), +(277,6,'长度','2M','D'), +(278,6,'宽度','10CM','D'), +(279,6,'宽度','20CM','D'), +(280,6,'宽度','30CM','D'), +(281,6,'长度','3','D'), +(282,169,'颜色','红色','A'), +(283,169,'颜色','蓝色','A'), +(284,169,'颜色','皇上','D'), +(285,169,'颜色','黄色','A'), +(286,169,'尺码','S','A'), +(287,169,'尺码','M','A'), +(288,169,'尺码','L','A'), +(289,169,'尺码','XL','A'), +(290,169,'尺码','XXL','A'), +(291,1,'卡通图','3','D'), +(292,6,'长度','36','D'), +(293,6,'3','','D'), +(294,6,'宽度','3','D'), +(295,6,'656','','D'), +(296,176,'测试1','25','A'), +(297,177,'规格1','个','A'), +(298,177,'规格2','包','D'), +(299,177,'规格1','包','A'), +(300,181,'颜色','红色','A'), +(301,181,'尺码','S','A'), +(302,181,'颜色','蓝色','A'), +(303,181,'尺码','M','A'), +(304,181,'尺码','L','A'), +(305,6,'颜色','大','D'), +(306,6,'宽度','6','D'), +(307,6,'长度','52','D'), +(308,1,'卡通图','cs','D'), +(309,169,'颜色','213','A'), +(310,183,'颜色','红','A'), +(311,183,'尺码','35','A'), +(312,183,'尺码','36','A'), +(313,183,'尺码','37','A'), +(314,183,'尺码','38','A'), +(315,183,'尺码','39','A'), +(316,183,'尺码','40','A'), +(317,183,'颜色','白','A'), +(318,183,'颜色','黑','A'), +(319,185,'八寸蛋糕','10寸蛋糕','D'), +(320,185,'八寸蛋糕','8寸','D'), +(321,185,'八寸蛋糕','12寸','D'), +(322,185,'八寸蛋糕','15寸','D'), +(323,187,'紫薯包','','D'), +(324,187,'紫薯包','x6','A'), +(325,187,'紫薯包','x12','A'), +(326,187,'紫薯包','x32','A'), +(327,185,'尺寸','8寸','A'), +(328,185,'尺寸','10寸','A'), +(329,185,'尺寸','14寸','A'), +(330,1,'尺码','40','D'), +(331,1,'颜色','白色','A'), +(332,1,'ddd','333','D'), +(333,1,'ddd','222','D'), +(334,1,'ddd','111','D'), +(335,1,'ddd','22','D'), +(336,6,'高度','2M','D'), +(337,6,'高度','3M','D'), +(338,6,'长度','3','D'), +(339,197,'颜色','款式','A'), +(340,199,'分享','20分钟','A'), +(341,199,'预约','30分钟','A'), +(342,6,'高度','黑','D'), +(343,6,'颜色','红','D'), +(344,6,'颜色','黄','D'), +(345,207,'颜色','黑色','A'), +(346,207,'12332','红色','D'), +(347,207,'颜色','黑色','D'), +(348,207,'颜色','红色','A'), +(349,196,'111','11111','A'), +(350,196,'111','1111111','A'), +(351,207,'尺码','S','A'), +(352,207,'尺码','L','A'), +(353,207,'赠礼','1','A'), +(354,207,'赠礼','2','A'), +(355,232,'颜色','白色','A'), +(356,232,'数量','5包','A'), +(357,232,'数量','10包','A'), +(358,232,'颜色','黑色','A'), +(359,233,'22222','22222','A'), +(360,245,'码数','34码','A'), +(361,245,'码数','35码','A'), +(362,245,'码数','36码','A'), +(363,245,'码数','37码','A'), +(364,245,'颜色','红色','A'), +(365,245,'颜色','白色','A'), +(366,245,'颜色','黑色','A'), +(367,2,'xl','xxl','D'), +(368,2,'xl','xl','D'), +(369,2,'l','l','D'), +(370,2,'m','l','D'), +(371,2,'l','22','D'), +(372,305,'颜色','蓝色','A'), +(373,305,'颜色','黑色','A'), +(374,305,'尺码','22','A'), +(375,305,'尺码','23','A'), +(376,2,'l','vv','D'), +(377,358,'热尔特谈','','D'), +(378,358,'111','111','D'), +(379,358,'热尔特谈','111','D'), +(380,358,'热尔特谈','1实物','D'), +(381,358,'热尔特谈','1是qqq','D'), +(382,358,'热尔特谈','111SSS安徽','D'), +(383,358,'热尔特谈','111sss汉字###','D'), +(384,358,'热尔特谈','汉字','D'), +(385,358,'热尔特谈','汉字sss','D'), +(386,358,'i0p','h8iuh','A'), +(387,358,'i0p','oljiho;ok\'','A'), +(388,361,'111','111','A'), +(389,361,'111','222','A'), +(390,361,'111','111','A'), +(391,361,'111','444','A'), +(392,361,'111','77','D'), +(393,361,'111','11111','A'), +(394,2,'m','隔热','D'), +(395,2,'l','1','D'), +(396,6,'chicun','1','D'), +(397,6,'chicun','2','D'), +(398,6,'chicun','3','D'), +(399,6,'颜色','中','D'), +(400,6,'颜色','小','D'), +(401,3,'大小','12G','A'), +(402,4,'着色','白','A'), +(403,4,'着色','红','A'), +(404,4,'大小','11','A'), +(405,4,'大小','22','A'), +(406,378,'杯','60ml','D'), +(407,378,'瓶','750ml','D'), +(408,6,'颜色','111','D'), +(409,6,'111','111111','D'), +(410,378,'5','6','D'), +(411,378,'5','6','D'), +(412,378,'瓶','100','D'), +(413,382,'温度','正常冰','A'), +(414,382,'温度','少冰','A'), +(415,382,'温度','去冰','A'), +(416,382,'甜度','正常糖(推荐)','A'), +(417,382,'甜度','少糖','A'), +(418,382,'甜度','不另外放糖(不推荐)','A'), +(419,382,'特殊口味','标准搭配','A'), +(420,382,'脆波波','','D'), +(421,1,'颜色','蓝色','A'), +(422,1,'重量','1KG','D'), +(423,1,'重量','2KG','D'), +(424,1,'长度','11','D'), +(425,1,'长度','22','D'), +(426,6,'111','11','D'), +(427,6,'111','11','D'), +(428,6,'111','22','D'), +(429,3,'颜色','蓝色','A'), +(430,384,'时长','12','A'), +(431,1,'尺码','45','A'), +(432,1,'尺码','55','A'); + +/*Table structure for table `mt_merchant` */ + +DROP TABLE IF EXISTS `mt_merchant`; + +CREATE TABLE `mt_merchant` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `TYPE` varchar(30) DEFAULT '' COMMENT '类型,restaurant:餐饮;retail:零售;service:服务;other:其他', + `LOGO` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT 'logo', + `NO` varchar(20) NOT NULL DEFAULT '' COMMENT '商户号', + `NAME` varchar(50) NOT NULL DEFAULT '' COMMENT '商户名称', + `CONTACT` varchar(30) DEFAULT '' COMMENT '联系人姓名', + `PHONE` varchar(20) DEFAULT '' COMMENT '联系电话', + `ADDRESS` varchar(100) DEFAULT '' COMMENT '联系地址', + `WX_APP_ID` varchar(50) DEFAULT '' COMMENT '微信小程序appId', + `WX_APP_SECRET` varchar(50) DEFAULT '' COMMENT '微信小程序秘钥', + `WX_OFFICIAL_APP_ID` varchar(50) DEFAULT '' COMMENT '微信公众号appId', + `WX_OFFICIAL_APP_SECRET` varchar(50) DEFAULT '' COMMENT '微信公众号秘钥', + `DESCRIPTION` varchar(2000) DEFAULT '' COMMENT '备注信息', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `STATUS` char(1) DEFAULT 'A' COMMENT '状态,A:有效/启用;D:无效', + `OPERATOR` varchar(30) DEFAULT '' COMMENT '最后操作人', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='商户表'; + +/*Data for the table `mt_merchant` */ + +insert into `mt_merchant`(`ID`,`TYPE`,`LOGO`,`NO`,`NAME`,`CONTACT`,`PHONE`,`ADDRESS`,`WX_APP_ID`,`WX_APP_SECRET`,`WX_OFFICIAL_APP_ID`,`WX_OFFICIAL_APP_SECRET`,`DESCRIPTION`,`CREATE_TIME`,`UPDATE_TIME`,`STATUS`,`OPERATOR`) values +(1,'','/uploads/20230804/8e5893378bec4b8ab3cabb77e15162d2.PNG','10001','小隅安商行','安安','18976679980','海口市永万路7号','','','','','默认','2023-08-01 12:03:55','2023-08-04 09:55:37','A','fuint'), +(2,'','/uploads/20230804/11f9b3135db043488e4b9bdcadda9f56.png','10002','延禾技术','FSQ','18976679980','海口市国兴大道100号','','','','','测试','2023-08-01 14:04:14','2023-08-04 09:56:04','A','fuint'); + +/*Table structure for table `mt_message` */ + +DROP TABLE IF EXISTS `mt_message`; + +CREATE TABLE `mt_message` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `MERCHANT_ID` int DEFAULT '0' COMMENT '商户ID', + `USER_ID` int NOT NULL COMMENT '用户ID', + `TYPE` varchar(30) NOT NULL DEFAULT '' COMMENT '消息类型', + `TITLE` varchar(200) DEFAULT '友情提示' COMMENT '消息标题', + `CONTENT` varchar(500) NOT NULL DEFAULT '' COMMENT '消息内容', + `IS_READ` char(1) DEFAULT 'N' COMMENT '是否已读', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `PARAMS` varchar(1000) DEFAULT '' COMMENT '参数信息', + `IS_SEND` char(1) DEFAULT 'N' COMMENT '是否已发送', + `SEND_TIME` datetime DEFAULT NULL COMMENT '发送时间', + `STATUS` char(1) DEFAULT 'A' COMMENT '状态', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8 COMMENT='系统消息表'; + +/*Data for the table `mt_message` */ + +insert into `mt_message`(`ID`,`MERCHANT_ID`,`USER_ID`,`TYPE`,`TITLE`,`CONTENT`,`IS_READ`,`CREATE_TIME`,`UPDATE_TIME`,`PARAMS`,`IS_SEND`,`SEND_TIME`,`STATUS`) values +(1,0,163,'sub','积分变更提醒','积分变更提醒','Y','2023-08-03 08:51:17','2023-08-03 08:53:01','{\"touser\":\"owOWg5cYFQr15C2QJkuAPfvMpHTQ\",\"data\":{\"thing7\":{\"value\":\"-1000\"},\"thing3\":{\"value\":\"您的积分发生了变动,请留意~\"},\"date2\":{\"value\":\"2023-08-03 08:51\"}},\"template_id\":\"MJCUWLiPDVPnuCgqsjbl5X385bowwoKwshuLmnUU5Ss\",\"page\":\"pages/user/index\"}','Y','2023-08-03 08:52:17','A'), +(2,0,163,'sub','积分变更提醒','积分变更提醒','N','2023-08-03 08:51:36','2023-08-03 08:53:01','{\"touser\":\"owOWg5cYFQr15C2QJkuAPfvMpHTQ\",\"data\":{\"thing7\":{\"value\":\"1000\"},\"thing3\":{\"value\":\"您的积分发生了变动,请留意~\"},\"date2\":{\"value\":\"2023-08-03 08:51\"}},\"template_id\":\"MJCUWLiPDVPnuCgqsjbl5X385bowwoKwshuLmnUU5Ss\",\"page\":\"pages/user/index\"}','Y','2023-08-03 08:52:36','A'), +(3,0,163,'sub','余额变动提醒','余额变动提醒','Y','2023-08-03 08:58:26','2023-08-03 09:00:01','{\"touser\":\"owOWg5cYFQr15C2QJkuAPfvMpHTQ\",\"data\":{\"amount6\":{\"value\":\"-0.01\"},\"thing3\":{\"value\":\"您的余额发生了变动,请留意~\"},\"time8\":{\"value\":\"2023-08-03 08:58\"}},\"template_id\":\"6Klx5n119OFezK2AUr8J_YeNp_B2acCGNNUGoAoYsgw\",\"page\":\"pages/user/index\"}','Y','2023-08-03 08:59:26','A'), +(4,0,163,'sub','订单生成提醒','订单生成提醒','N','2023-08-03 08:58:26','2023-08-03 09:00:01','{\"touser\":\"owOWg5cYFQr15C2QJkuAPfvMpHTQ\",\"data\":{\"time1\":{\"value\":\"2023-08-03 08:58\"},\"character_string4\":{\"value\":\"202308030858262038964\"},\"thing5.DATA}\":{\"value\":\"您的订单已生成,请留意~\"}},\"template_id\":\"2MxTzfak92lcn-uTN4_WSv9AmuFvqmKrUXNQ7ph3rls\",\"page\":\"pages/order/index\"}','Y','2023-08-03 08:59:26','A'), +(5,0,163,'sub','积分变更提醒','积分变更提醒','N','2023-08-03 09:13:11','2023-08-03 09:15:01','{\"touser\":\"owOWg5cYFQr15C2QJkuAPfvMpHTQ\",\"data\":{\"thing7\":{\"value\":\"-1000\"},\"thing3\":{\"value\":\"您的积分发生了变动,请留意~\"},\"date2\":{\"value\":\"2023-08-03 09:13\"}},\"template_id\":\"MJCUWLiPDVPnuCgqsjbl5X385bowwoKwshuLmnUU5Ss\",\"page\":\"pages/user/index\"}','Y','2023-08-03 09:14:11','A'), +(6,0,163,'sub','订单生成提醒','订单生成提醒','N','2023-08-03 09:13:11','2023-08-03 09:15:01','{\"touser\":\"owOWg5cYFQr15C2QJkuAPfvMpHTQ\",\"data\":{\"time1\":{\"value\":\"2023-08-03 09:13\"},\"character_string4\":{\"value\":\"202308030913107144301\"},\"thing5.DATA}\":{\"value\":\"您的订单已生成,请留意~\"}},\"template_id\":\"2MxTzfak92lcn-uTN4_WSv9AmuFvqmKrUXNQ7ph3rls\",\"page\":\"pages/order/index\"}','Y','2023-08-03 09:14:11','A'), +(7,0,163,'sub','余额变动提醒','余额变动提醒','Y','2023-08-03 09:14:47','2023-08-03 09:16:01','{\"touser\":\"owOWg5cYFQr15C2QJkuAPfvMpHTQ\",\"data\":{\"amount6\":{\"value\":\"-0.01\"},\"thing3\":{\"value\":\"您的余额发生了变动,请留意~\"},\"time8\":{\"value\":\"2023-08-03 09:14\"}},\"template_id\":\"6Klx5n119OFezK2AUr8J_YeNp_B2acCGNNUGoAoYsgw\",\"page\":\"pages/user/index\"}','Y','2023-08-03 09:15:47','A'), +(8,0,163,'sub','订单生成提醒','订单生成提醒','N','2023-08-03 09:14:47','2023-08-03 09:16:01','{\"touser\":\"owOWg5cYFQr15C2QJkuAPfvMpHTQ\",\"data\":{\"time1\":{\"value\":\"2023-08-03 09:14\"},\"character_string4\":{\"value\":\"202308030914470447532\"},\"thing5.DATA}\":{\"value\":\"您的订单已生成,请留意~\"}},\"template_id\":\"2MxTzfak92lcn-uTN4_WSv9AmuFvqmKrUXNQ7ph3rls\",\"page\":\"pages/order/index\"}','Y','2023-08-03 09:15:47','A'), +(9,0,163,'sub','余额变动提醒','余额变动提醒','Y','2023-08-03 09:16:18','2023-08-03 09:34:07','{\"touser\":\"owOWg5cYFQr15C2QJkuAPfvMpHTQ\",\"data\":{\"amount6\":{\"value\":\"-0.02\"},\"thing3\":{\"value\":\"您的余额发生了变动,请留意~\"},\"time8\":{\"value\":\"2023-08-03 09:16\"}},\"template_id\":\"6Klx5n119OFezK2AUr8J_YeNp_B2acCGNNUGoAoYsgw\",\"page\":\"pages/user/index\"}','Y','2023-08-03 09:17:18','A'), +(10,0,163,'sub','订单生成提醒','订单生成提醒','N','2023-08-03 09:16:18','2023-08-03 09:34:07','{\"touser\":\"owOWg5cYFQr15C2QJkuAPfvMpHTQ\",\"data\":{\"time1\":{\"value\":\"2023-08-03 09:16\"},\"character_string4\":{\"value\":\"202308030916183312747\"},\"thing5.DATA}\":{\"value\":\"您的订单已生成,请留意~\"}},\"template_id\":\"2MxTzfak92lcn-uTN4_WSv9AmuFvqmKrUXNQ7ph3rls\",\"page\":\"pages/order/index\"}','Y','2023-08-03 09:17:18','A'), +(11,0,163,'sub','余额变动提醒','余额变动提醒','Y','2023-08-03 09:16:32','2023-08-03 09:34:08','{\"touser\":\"owOWg5cYFQr15C2QJkuAPfvMpHTQ\",\"data\":{\"amount6\":{\"value\":\"-0.79\"},\"thing3\":{\"value\":\"您的余额发生了变动,请留意~\"},\"time8\":{\"value\":\"2023-08-03 09:16\"}},\"template_id\":\"6Klx5n119OFezK2AUr8J_YeNp_B2acCGNNUGoAoYsgw\",\"page\":\"pages/user/index\"}','Y','2023-08-03 09:17:32','A'), +(12,0,163,'sub','订单生成提醒','订单生成提醒','N','2023-08-03 09:16:32','2023-08-03 09:34:08','{\"touser\":\"owOWg5cYFQr15C2QJkuAPfvMpHTQ\",\"data\":{\"time1\":{\"value\":\"2023-08-03 09:16\"},\"character_string4\":{\"value\":\"202308030916315008766\"},\"thing5.DATA}\":{\"value\":\"您的订单已生成,请留意~\"}},\"template_id\":\"2MxTzfak92lcn-uTN4_WSv9AmuFvqmKrUXNQ7ph3rls\",\"page\":\"pages/order/index\"}','Y','2023-08-03 09:17:32','A'), +(13,0,163,'sub','积分变更提醒','积分变更提醒','N','2023-08-03 09:17:07','2023-08-03 09:34:08','{\"touser\":\"owOWg5cYFQr15C2QJkuAPfvMpHTQ\",\"data\":{\"thing7\":{\"value\":\"1000\"},\"thing3\":{\"value\":\"您的积分发生了变动,请留意~\"},\"date2\":{\"value\":\"2023-08-03 09:17\"}},\"template_id\":\"MJCUWLiPDVPnuCgqsjbl5X385bowwoKwshuLmnUU5Ss\",\"page\":\"pages/user/index\"}','Y','2023-08-03 09:18:07','A'), +(14,0,163,'sub','积分变更提醒','积分变更提醒','Y','2023-09-08 21:58:25','2023-09-08 22:00:01','{\"touser\":\"owOWg5cYFQr15C2QJkuAPfvMpHTQ\",\"data\":{\"thing7\":{\"value\":\"-1000\"},\"thing3\":{\"value\":\"您的积分发生了变动,请留意~\"},\"date2\":{\"value\":\"2023-09-08 21:58\"}},\"template_id\":\"MJCUWLiPDVPnuCgqsjbl5X385bowwoKwshuLmnUU5Ss\",\"page\":\"pages/user/index\"}','Y','2023-09-08 21:59:24','A'), +(15,0,163,'sub','订单生成提醒','订单生成提醒','N','2023-09-08 21:58:25','2023-09-08 22:00:01','{\"touser\":\"owOWg5cYFQr15C2QJkuAPfvMpHTQ\",\"data\":{\"time1\":{\"value\":\"2023-09-08 21:58\"},\"character_string4\":{\"value\":\"202309082158244549616\"},\"thing5.DATA}\":{\"value\":\"您的订单已生成,请留意~\"}},\"template_id\":\"2MxTzfak92lcn-uTN4_WSv9AmuFvqmKrUXNQ7ph3rls\",\"page\":\"pages/order/index\"}','Y','2023-09-08 21:59:25','A'), +(16,0,163,'sub','余额变动提醒','余额变动提醒','N','2023-09-08 22:01:18','2023-09-08 22:03:00','{\"touser\":\"owOWg5cYFQr15C2QJkuAPfvMpHTQ\",\"data\":{\"amount6\":{\"value\":\"-72.08\"},\"thing3\":{\"value\":\"您的余额发生了变动,请留意~\"},\"time8\":{\"value\":\"2023-09-08 22:01\"}},\"template_id\":\"6Klx5n119OFezK2AUr8J_YeNp_B2acCGNNUGoAoYsgw\",\"page\":\"pages/user/index\"}','Y','2023-09-08 22:02:18','A'), +(17,0,163,'sub','订单生成提醒','订单生成提醒','N','2023-09-08 22:01:18','2023-09-08 22:03:01','{\"touser\":\"owOWg5cYFQr15C2QJkuAPfvMpHTQ\",\"data\":{\"time1\":{\"value\":\"2023-09-08 22:01\"},\"character_string4\":{\"value\":\"202309082201183531567\"},\"thing5.DATA}\":{\"value\":\"您的订单已生成,请留意~\"}},\"template_id\":\"2MxTzfak92lcn-uTN4_WSv9AmuFvqmKrUXNQ7ph3rls\",\"page\":\"pages/order/index\"}','Y','2023-09-08 22:02:18','A'), +(18,0,163,'sub','余额变动提醒','余额变动提醒','N','2023-09-08 22:04:25','2023-09-10 09:58:01','{\"touser\":\"owOWg5cYFQr15C2QJkuAPfvMpHTQ\",\"data\":{\"amount6\":{\"value\":\"-72.08\"},\"thing3\":{\"value\":\"您的余额发生了变动,请留意~\"},\"time8\":{\"value\":\"2023-09-08 22:04\"}},\"template_id\":\"6Klx5n119OFezK2AUr8J_YeNp_B2acCGNNUGoAoYsgw\",\"page\":\"pages/user/index\"}','Y','2023-09-08 22:05:25','A'), +(19,0,163,'sub','订单生成提醒','订单生成提醒','N','2023-09-08 22:04:25','2023-09-10 09:58:01','{\"touser\":\"owOWg5cYFQr15C2QJkuAPfvMpHTQ\",\"data\":{\"time1\":{\"value\":\"2023-09-08 22:04\"},\"character_string4\":{\"value\":\"202309082204254176805\"},\"thing5.DATA}\":{\"value\":\"您的订单已生成,请留意~\"}},\"template_id\":\"2MxTzfak92lcn-uTN4_WSv9AmuFvqmKrUXNQ7ph3rls\",\"page\":\"pages/order/index\"}','Y','2023-09-08 22:05:25','A'), +(20,0,163,'sub','积分变更提醒','积分变更提醒','Y','2023-09-10 09:58:01','2023-09-11 08:54:03','{\"touser\":\"owOWg5cYFQr15C2QJkuAPfvMpHTQ\",\"data\":{\"thing7\":{\"value\":\"1000\"},\"thing3\":{\"value\":\"您的积分发生了变动,请留意~\"},\"date2\":{\"value\":\"2023-09-10 09:58\"}},\"template_id\":\"MJCUWLiPDVPnuCgqsjbl5X385bowwoKwshuLmnUU5Ss\",\"page\":\"pages/user/index\"}','Y','2023-09-10 09:59:01','A'), +(21,0,6143,'pop','温馨提示','系统赠送您价值¥20.00卡券和1000积分,请注意查收!','Y','2023-09-18 18:02:18','2023-09-18 18:02:25','','Y','2023-09-18 18:02:18','A'), +(23,0,163,'sub','积分变更提醒','积分变更提醒','Y','2023-09-20 18:00:31','2023-09-20 18:02:01','{\"touser\":\"owOWg5cYFQr15C2QJkuAPfvMpHTQ\",\"data\":{\"thing7\":{\"value\":\"-1000\"},\"thing3\":{\"value\":\"您的积分发生了变动,请留意~\"},\"date2\":{\"value\":\"2023-09-20 18:00\"}},\"template_id\":\"MJCUWLiPDVPnuCgqsjbl5X385bowwoKwshuLmnUU5Ss\",\"page\":\"pages/user/index\"}','Y','2023-09-20 18:01:31','A'), +(24,0,163,'sub','订单生成提醒','订单生成提醒','N','2023-09-20 18:00:31','2023-09-20 18:02:01','{\"touser\":\"owOWg5cYFQr15C2QJkuAPfvMpHTQ\",\"data\":{\"time1\":{\"value\":\"2023-09-20 18:00\"},\"character_string4\":{\"value\":\"202309201800308947963\"},\"thing5.DATA}\":{\"value\":\"您的订单已生成,请留意~\"}},\"template_id\":\"2MxTzfak92lcn-uTN4_WSv9AmuFvqmKrUXNQ7ph3rls\",\"page\":\"pages/order/index\"}','Y','2023-09-20 18:01:31','A'), +(25,0,163,'sub','订单生成提醒','订单生成提醒','N','2023-09-21 08:35:40','2023-09-21 08:37:06','{\"touser\":\"owOWg5cYFQr15C2QJkuAPfvMpHTQ\",\"data\":{\"time1\":{\"value\":\"2023-09-21 08:35\"},\"character_string4\":{\"value\":\"202309210835395956418\"},\"thing5.DATA}\":{\"value\":\"您的订单已生成,请留意~\"}},\"template_id\":\"2MxTzfak92lcn-uTN4_WSv9AmuFvqmKrUXNQ7ph3rls\",\"page\":\"pages/order/index\"}','Y','2023-09-21 08:36:40','A'), +(26,0,163,'sub','订单生成提醒','订单生成提醒','N','2023-09-21 08:39:39','2023-09-21 08:41:01','{\"touser\":\"owOWg5cYFQr15C2QJkuAPfvMpHTQ\",\"data\":{\"time1\":{\"value\":\"2023-09-21 08:39\"},\"character_string4\":{\"value\":\"202309210839381673661\"},\"thing5.DATA}\":{\"value\":\"您的订单已生成,请留意~\"}},\"template_id\":\"2MxTzfak92lcn-uTN4_WSv9AmuFvqmKrUXNQ7ph3rls\",\"page\":\"pages/order/index\"}','Y','2023-09-21 08:40:39','A'), +(27,0,163,'sub','订单生成提醒','订单生成提醒','N','2023-09-22 10:18:47','2023-09-22 10:20:03','{\"touser\":\"owOWg5cYFQr15C2QJkuAPfvMpHTQ\",\"data\":{\"time1\":{\"value\":\"2023-09-22 10:18\"},\"character_string4\":{\"value\":\"202309221018463011586\"},\"thing5.DATA}\":{\"value\":\"您的订单已生成,请留意~\"}},\"template_id\":\"2MxTzfak92lcn-uTN4_WSv9AmuFvqmKrUXNQ7ph3rls\",\"page\":\"pages/order/index\"}','Y','2023-09-22 10:19:46','A'), +(28,1,1,'sub','积分变更提醒','积分变更提醒','N','2023-10-19 09:39:45','2023-10-19 09:41:01','{\"touser\":\"owOWg5cYFQr15C2QJkuAPfvMpHTQ\",\"data\":{\"thing7\":{\"value\":\"1000\"},\"thing3\":{\"value\":\"您的积分发生了变动,请留意~\"},\"date2\":{\"value\":\"2023-10-19 09:39\"}},\"template_id\":\"MJCUWLiPDVPnuCgqsjbl5X385bowwoKwshuLmnUU5Ss\",\"page\":\"pages/user/index\"}','Y','2023-10-19 09:40:45','A'), +(29,1,1,'pop','温馨提示','系统赠送您1000积分,请注意查收!','Y','2023-10-19 09:39:45','2023-10-19 09:39:48','','Y','2023-10-19 09:39:45','A'); + +/*Table structure for table `mt_open_gift` */ + +DROP TABLE IF EXISTS `mt_open_gift`; + +CREATE TABLE `mt_open_gift` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `MERCHANT_ID` int DEFAULT '0' COMMENT '商户ID', + `STORE_ID` int NOT NULL DEFAULT '0' COMMENT '门店ID', + `GRADE_ID` int NOT NULL DEFAULT '0' COMMENT '会员等级ID', + `POINT` int NOT NULL DEFAULT '0' COMMENT '赠送积分', + `COUPON_ID` int NOT NULL DEFAULT '0' COMMENT '卡券ID', + `COUPON_NUM` int NOT NULL DEFAULT '1' COMMENT '卡券数量', + `CREATE_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime NOT NULL COMMENT '更新时间', + `STATUS` char(1) DEFAULT 'A' COMMENT '状态', + `OPERATOR` varchar(30) DEFAULT '' COMMENT '最后操作人', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB AUTO_INCREMENT=117 DEFAULT CHARSET=utf8 COMMENT='会员开卡赠礼'; + +/*Data for the table `mt_open_gift` */ + +insert into `mt_open_gift`(`ID`,`MERCHANT_ID`,`STORE_ID`,`GRADE_ID`,`POINT`,`COUPON_ID`,`COUPON_NUM`,`CREATE_TIME`,`UPDATE_TIME`,`STATUS`,`OPERATOR`) values +(115,1,0,1,1000,0,0,'2023-07-24 20:06:48','2023-07-24 20:06:48','A','fuint'), +(116,1,0,1,0,153,1,'2023-07-24 22:17:38','2023-07-24 22:17:38','A','fuint'); + +/*Table structure for table `mt_open_gift_item` */ + +DROP TABLE IF EXISTS `mt_open_gift_item`; + +CREATE TABLE `mt_open_gift_item` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `USER_ID` int NOT NULL COMMENT '会用ID', + `OPEN_GIFT_ID` int NOT NULL COMMENT '赠礼ID', + `CREATE_TIME` datetime NOT NULL COMMENT '创建时间', + `STATUS` char(1) NOT NULL COMMENT '状态', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf32 COMMENT='开卡赠礼明细表'; + +/*Data for the table `mt_open_gift_item` */ + +/*Table structure for table `mt_order` */ + +DROP TABLE IF EXISTS `mt_order`; + +CREATE TABLE `mt_order` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `TYPE` varchar(30) DEFAULT NULL COMMENT '订单类型', + `PAY_TYPE` varchar(30) DEFAULT 'JSAPI' COMMENT '支付类型', + `ORDER_MODE` varchar(30) DEFAULT 'express' COMMENT '订单模式', + `ORDER_SN` varchar(32) NOT NULL DEFAULT '' COMMENT '订单号', + `COUPON_ID` int DEFAULT '0' COMMENT '卡券ID', + `MERCHANT_ID` int DEFAULT '0' COMMENT '所属商户ID', + `STORE_ID` int DEFAULT '0' COMMENT '所属店铺ID', + `USER_ID` int NOT NULL DEFAULT '0' COMMENT '用户ID', + `VERIFY_CODE` varchar(10) DEFAULT '' COMMENT '核销验证码', + `IS_VISITOR` char(1) DEFAULT 'N' COMMENT '是否游客', + `AMOUNT` decimal(10,2) DEFAULT '0.00' COMMENT '订单金额', + `PAY_AMOUNT` decimal(10,2) DEFAULT '0.00' COMMENT '支付金额', + `USE_POINT` int DEFAULT '0' COMMENT '使用积分数量', + `POINT_AMOUNT` decimal(10,2) DEFAULT '0.00' COMMENT '积分金额', + `DISCOUNT` decimal(10,2) DEFAULT '0.00' COMMENT '折扣金额', + `DELIVERY_FEE` decimal(10,2) DEFAULT '0.00' COMMENT '配送费用', + `PARAM` varchar(500) DEFAULT '' COMMENT '订单参数', + `EXPRESS_INFO` varchar(500) DEFAULT '' COMMENT '物流信息', + `REMARK` varchar(500) DEFAULT '' COMMENT '用户备注', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `STATUS` char(1) DEFAULT 'A' COMMENT '订单状态', + `PAY_TIME` datetime DEFAULT NULL COMMENT '支付时间', + `PAY_STATUS` char(1) DEFAULT '' COMMENT '支付状态', + `SETTLE_STATUS` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT 'A' COMMENT '结算状态', + `STAFF_ID` int DEFAULT '0' COMMENT '操作员工', + `COMMISSION_STATUS` char(1) DEFAULT 'A' COMMENT '分佣提成计算状态', + `OPERATOR` varchar(30) DEFAULT '' COMMENT '最后操作人', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='订单表'; + +/*Data for the table `mt_order` */ + +/*Table structure for table `mt_order_address` */ + +DROP TABLE IF EXISTS `mt_order_address`; + +CREATE TABLE `mt_order_address` ( + `ID` int unsigned NOT NULL AUTO_INCREMENT COMMENT '地址ID', + `NAME` varchar(30) NOT NULL DEFAULT '' COMMENT '收货人姓名', + `MOBILE` varchar(20) NOT NULL DEFAULT '' COMMENT '联系电话', + `PROVINCE_ID` int unsigned NOT NULL DEFAULT '0' COMMENT '省份ID', + `CITY_ID` int unsigned NOT NULL DEFAULT '0' COMMENT '城市ID', + `REGION_ID` int unsigned NOT NULL DEFAULT '0' COMMENT '区/县ID', + `DETAIL` varchar(255) NOT NULL DEFAULT '' COMMENT '详细地址', + `ORDER_ID` int unsigned NOT NULL DEFAULT '0' COMMENT '订单ID', + `USER_ID` int unsigned NOT NULL DEFAULT '0' COMMENT '用户ID', + `CREATE_TIME` datetime NOT NULL COMMENT '创建时间', + PRIMARY KEY (`ID`) USING BTREE, + KEY `ORDER_ID` (`ORDER_ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='订单收货地址记录表'; + +/*Data for the table `mt_order_address` */ + +/*Table structure for table `mt_order_goods` */ + +DROP TABLE IF EXISTS `mt_order_goods`; + +CREATE TABLE `mt_order_goods` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `ORDER_ID` int NOT NULL DEFAULT '0' COMMENT '订单ID', + `GOODS_ID` int NOT NULL DEFAULT '0' COMMENT '商品ID', + `SKU_ID` int DEFAULT '0' COMMENT 'skuID', + `PRICE` decimal(10,2) DEFAULT '0.00' COMMENT '价格', + `DISCOUNT` decimal(10,2) DEFAULT '0.00' COMMENT '优惠价', + `NUM` int NOT NULL DEFAULT '0' COMMENT '商品数量', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `STATUS` char(1) DEFAULT 'A' COMMENT 'A:正常;D:删除', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='订单商品表'; + +/*Data for the table `mt_order_goods` */ + +/*Table structure for table `mt_point` */ + +DROP TABLE IF EXISTS `mt_point`; + +CREATE TABLE `mt_point` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `MERCHANT_ID` int DEFAULT '0' COMMENT '所属商户ID', + `STORE_ID` int DEFAULT '0' COMMENT '所属店铺ID', + `USER_ID` int NOT NULL DEFAULT '0' COMMENT '用户ID', + `ORDER_SN` varchar(32) DEFAULT '' COMMENT '订单号', + `AMOUNT` int NOT NULL DEFAULT '0' COMMENT '积分变化数量', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `DESCRIPTION` varchar(200) DEFAULT '' COMMENT '备注说明', + `OPERATOR` varchar(30) DEFAULT '' COMMENT '最后操作人', + `STATUS` char(1) DEFAULT 'A' COMMENT '状态,A正常;D作废', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COMMENT='积分变化表'; + +/*Data for the table `mt_point` */ + +insert into `mt_point`(`ID`,`MERCHANT_ID`,`STORE_ID`,`USER_ID`,`ORDER_SN`,`AMOUNT`,`CREATE_TIME`,`UPDATE_TIME`,`DESCRIPTION`,`OPERATOR`,`STATUS`) values +(1,0,0,163,'202309082158244549616',-1000,'2023-09-08 21:58:24','2023-09-08 21:58:24','支付扣除1000积分','','A'), +(2,0,0,163,'202309082158244549616',1000,'2023-09-10 09:58:01','2023-09-10 09:58:01','订单取消202309082158244549616退回1000积分','','A'), +(3,2,7,6143,'',1000,'2023-09-18 18:02:17','2023-09-18 18:02:17','开卡赠送1000积分','系统','A'), +(5,1,3,163,'202309201800308947963',-1000,'2023-09-20 18:00:31','2023-09-20 18:00:31','支付扣除1000积分','','A'), +(6,1,2,1,'',1000,'2023-10-19 09:39:45','2023-10-19 09:39:45','开卡赠送1000积分','系统','A'); + +/*Table structure for table `mt_refund` */ + +DROP TABLE IF EXISTS `mt_refund`; + +CREATE TABLE `mt_refund` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `ORDER_ID` int NOT NULL COMMENT '订单ID', + `MERCHANT_ID` int DEFAULT '0' COMMENT '所属商户ID', + `STORE_ID` int DEFAULT '0' COMMENT '店铺ID', + `USER_ID` int NOT NULL COMMENT '会员ID', + `AMOUNT` decimal(10,2) DEFAULT NULL COMMENT '退款金额', + `TYPE` varchar(20) DEFAULT '' COMMENT '售后类型', + `REMARK` varchar(500) DEFAULT '' COMMENT '退款备注', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `STATUS` char(1) DEFAULT 'A' COMMENT '状态', + `IMAGES` varchar(1000) DEFAULT NULL COMMENT '图片', + `OPERATOR` varchar(30) DEFAULT '' COMMENT '最后操作人', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='售后表'; + +/*Data for the table `mt_refund` */ + +/*Table structure for table `mt_region` */ + +DROP TABLE IF EXISTS `mt_region`; + +CREATE TABLE `mt_region` ( + `ID` int unsigned NOT NULL AUTO_INCREMENT COMMENT '区划信息ID', + `NAME` varchar(255) NOT NULL DEFAULT '' COMMENT '区划名称', + `PID` int unsigned NOT NULL DEFAULT '0' COMMENT '父级ID', + `CODE` varchar(255) NOT NULL DEFAULT '' COMMENT '区划编码', + `LEVEL` tinyint unsigned NOT NULL DEFAULT '1' COMMENT '层级(1省级 2市级 3区/县级)', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=3705 DEFAULT CHARSET=utf8 COMMENT='省市区数据表'; + +/*Data for the table `mt_region` */ + +insert into `mt_region`(`ID`,`NAME`,`PID`,`CODE`,`LEVEL`) values +(1,'北京',0,'110000',1), +(2,'北京市',1,'110010',2), +(3,'东城区',2,'110101',3), +(4,'西城区',2,'110102',3), +(5,'朝阳区',2,'110105',3), +(6,'丰台区',2,'110106',3), +(7,'石景山区',2,'110107',3), +(8,'海淀区',2,'110108',3), +(9,'门头沟区',2,'110109',3), +(10,'房山区',2,'110111',3), +(11,'通州区',2,'110112',3), +(12,'顺义区',2,'110113',3), +(13,'昌平区',2,'110114',3), +(14,'大兴区',2,'110115',3), +(15,'怀柔区',2,'110116',3), +(16,'平谷区',2,'110117',3), +(17,'密云区',2,'110118',3), +(18,'延庆区',2,'110119',3), +(19,'天津',0,'120000',1), +(20,'天津市',19,'120010',2), +(21,'和平区',20,'120101',3), +(22,'河东区',20,'120102',3), +(23,'河西区',20,'120103',3), +(24,'南开区',20,'120104',3), +(25,'河北区',20,'120105',3), +(26,'红桥区',20,'120106',3), +(27,'东丽区',20,'120110',3), +(28,'西青区',20,'120111',3), +(29,'津南区',20,'120112',3), +(30,'北辰区',20,'120113',3), +(31,'武清区',20,'120114',3), +(32,'宝坻区',20,'120115',3), +(33,'滨海新区',20,'120116',3), +(34,'宁河区',20,'120117',3), +(35,'静海区',20,'120118',3), +(36,'蓟州区',20,'120119',3), +(37,'河北省',0,'130000',1), +(38,'石家庄市',37,'130100',2), +(39,'长安区',38,'130102',3), +(40,'桥西区',38,'130104',3), +(41,'新华区',38,'130105',3), +(42,'井陉矿区',38,'130107',3), +(43,'裕华区',38,'130108',3), +(44,'藁城区',38,'130109',3), +(45,'鹿泉区',38,'130110',3), +(46,'栾城区',38,'130111',3), +(47,'井陉县',38,'130121',3), +(48,'正定县',38,'130123',3), +(49,'行唐县',38,'130125',3), +(50,'灵寿县',38,'130126',3), +(51,'高邑县',38,'130127',3), +(52,'深泽县',38,'130128',3), +(53,'赞皇县',38,'130129',3), +(54,'无极县',38,'130130',3), +(55,'平山县',38,'130131',3), +(56,'元氏县',38,'130132',3), +(57,'赵县',38,'130133',3), +(58,'辛集市',38,'130181',3), +(59,'晋州市',38,'130183',3), +(60,'新乐市',38,'130184',3), +(61,'唐山市',37,'130200',2), +(62,'路南区',61,'130202',3), +(63,'路北区',61,'130203',3), +(64,'古冶区',61,'130204',3), +(65,'开平区',61,'130205',3), +(66,'丰南区',61,'130207',3), +(67,'丰润区',61,'130208',3), +(68,'曹妃甸区',61,'130209',3), +(69,'滦南县',61,'130224',3), +(70,'乐亭县',61,'130225',3), +(71,'迁西县',61,'130227',3), +(72,'玉田县',61,'130229',3), +(73,'遵化市',61,'130281',3), +(74,'迁安市',61,'130283',3), +(75,'滦州市',61,'130284',3), +(76,'秦皇岛市',37,'130300',2), +(77,'海港区',76,'130302',3), +(78,'山海关区',76,'130303',3), +(79,'北戴河区',76,'130304',3), +(80,'抚宁区',76,'130306',3), +(81,'青龙满族自治县',76,'130321',3), +(82,'昌黎县',76,'130322',3), +(83,'卢龙县',76,'130324',3), +(84,'邯郸市',37,'130400',2), +(85,'邯山区',84,'130402',3), +(86,'丛台区',84,'130403',3), +(87,'复兴区',84,'130404',3), +(88,'峰峰矿区',84,'130406',3), +(89,'肥乡区',84,'130407',3), +(90,'永年区',84,'130408',3), +(91,'临漳县',84,'130423',3), +(92,'成安县',84,'130424',3), +(93,'大名县',84,'130425',3), +(94,'涉县',84,'130426',3), +(95,'磁县',84,'130427',3), +(96,'邱县',84,'130430',3), +(97,'鸡泽县',84,'130431',3), +(98,'广平县',84,'130432',3), +(99,'馆陶县',84,'130433',3), +(100,'魏县',84,'130434',3), +(101,'曲周县',84,'130435',3), +(102,'武安市',84,'130481',3), +(103,'邢台市',37,'130500',2), +(104,'桥东区',103,'130502',3), +(105,'桥西区',103,'130503',3), +(106,'邢台县',103,'130521',3), +(107,'临城县',103,'130522',3), +(108,'内丘县',103,'130523',3), +(109,'柏乡县',103,'130524',3), +(110,'隆尧县',103,'130525',3), +(111,'任县',103,'130526',3), +(112,'南和县',103,'130527',3), +(113,'宁晋县',103,'130528',3), +(114,'巨鹿县',103,'130529',3), +(115,'新河县',103,'130530',3), +(116,'广宗县',103,'130531',3), +(117,'平乡县',103,'130532',3), +(118,'威县',103,'130533',3), +(119,'清河县',103,'130534',3), +(120,'临西县',103,'130535',3), +(121,'南宫市',103,'130581',3), +(122,'沙河市',103,'130582',3), +(123,'保定市',37,'130600',2), +(124,'竞秀区',123,'130602',3), +(125,'莲池区',123,'130606',3), +(126,'满城区',123,'130607',3), +(127,'清苑区',123,'130608',3), +(128,'徐水区',123,'130609',3), +(129,'涞水县',123,'130623',3), +(130,'阜平县',123,'130624',3), +(131,'定兴县',123,'130626',3), +(132,'唐县',123,'130627',3), +(133,'高阳县',123,'130628',3), +(134,'容城县',123,'130629',3), +(135,'涞源县',123,'130630',3), +(136,'望都县',123,'130631',3), +(137,'安新县',123,'130632',3), +(138,'易县',123,'130633',3), +(139,'曲阳县',123,'130634',3), +(140,'蠡县',123,'130635',3), +(141,'顺平县',123,'130636',3), +(142,'博野县',123,'130637',3), +(143,'雄县',123,'130638',3), +(144,'涿州市',123,'130681',3), +(145,'定州市',123,'130682',3), +(146,'安国市',123,'130683',3), +(147,'高碑店市',123,'130684',3), +(148,'张家口市',37,'130700',2), +(149,'桥东区',148,'130702',3), +(150,'桥西区',148,'130703',3), +(151,'宣化区',148,'130705',3), +(152,'下花园区',148,'130706',3), +(153,'万全区',148,'130708',3), +(154,'崇礼区',148,'130709',3), +(155,'张北县',148,'130722',3), +(156,'康保县',148,'130723',3), +(157,'沽源县',148,'130724',3), +(158,'尚义县',148,'130725',3), +(159,'蔚县',148,'130726',3), +(160,'阳原县',148,'130727',3), +(161,'怀安县',148,'130728',3), +(162,'怀来县',148,'130730',3), +(163,'涿鹿县',148,'130731',3), +(164,'赤城县',148,'130732',3), +(165,'承德市',37,'130800',2), +(166,'双桥区',165,'130802',3), +(167,'双滦区',165,'130803',3), +(168,'鹰手营子矿区',165,'130804',3), +(169,'承德县',165,'130821',3), +(170,'兴隆县',165,'130822',3), +(171,'滦平县',165,'130824',3), +(172,'隆化县',165,'130825',3), +(173,'丰宁满族自治县',165,'130826',3), +(174,'宽城满族自治县',165,'130827',3), +(175,'围场满族蒙古族自治县',165,'130828',3), +(176,'平泉市',165,'130881',3), +(177,'沧州市',37,'130900',2), +(178,'新华区',177,'130902',3), +(179,'运河区',177,'130903',3), +(180,'沧县',177,'130921',3), +(181,'青县',177,'130922',3), +(182,'东光县',177,'130923',3), +(183,'海兴县',177,'130924',3), +(184,'盐山县',177,'130925',3), +(185,'肃宁县',177,'130926',3), +(186,'南皮县',177,'130927',3), +(187,'吴桥县',177,'130928',3), +(188,'献县',177,'130929',3), +(189,'孟村回族自治县',177,'130930',3), +(190,'泊头市',177,'130981',3), +(191,'任丘市',177,'130982',3), +(192,'黄骅市',177,'130983',3), +(193,'河间市',177,'130984',3), +(194,'廊坊市',37,'131000',2), +(195,'安次区',194,'131002',3), +(196,'广阳区',194,'131003',3), +(197,'固安县',194,'131022',3), +(198,'永清县',194,'131023',3), +(199,'香河县',194,'131024',3), +(200,'大城县',194,'131025',3), +(201,'文安县',194,'131026',3), +(202,'大厂回族自治县',194,'131028',3), +(203,'霸州市',194,'131081',3), +(204,'三河市',194,'131082',3), +(205,'衡水市',37,'131100',2), +(206,'桃城区',205,'131102',3), +(207,'冀州区',205,'131103',3), +(208,'枣强县',205,'131121',3), +(209,'武邑县',205,'131122',3), +(210,'武强县',205,'131123',3), +(211,'饶阳县',205,'131124',3), +(212,'安平县',205,'131125',3), +(213,'故城县',205,'131126',3), +(214,'景县',205,'131127',3), +(215,'阜城县',205,'131128',3), +(216,'深州市',205,'131182',3), +(217,'山西省',0,'140000',1), +(218,'太原市',217,'140100',2), +(219,'小店区',218,'140105',3), +(220,'迎泽区',218,'140106',3), +(221,'杏花岭区',218,'140107',3), +(222,'尖草坪区',218,'140108',3), +(223,'万柏林区',218,'140109',3), +(224,'晋源区',218,'140110',3), +(225,'清徐县',218,'140121',3), +(226,'阳曲县',218,'140122',3), +(227,'娄烦县',218,'140123',3), +(228,'古交市',218,'140181',3), +(229,'大同市',217,'140200',2), +(230,'新荣区',229,'140212',3), +(231,'平城区',229,'140213',3), +(232,'云冈区',229,'140214',3), +(233,'云州区',229,'140215',3), +(234,'阳高县',229,'140221',3), +(235,'天镇县',229,'140222',3), +(236,'广灵县',229,'140223',3), +(237,'灵丘县',229,'140224',3), +(238,'浑源县',229,'140225',3), +(239,'左云县',229,'140226',3), +(240,'阳泉市',217,'140300',2), +(241,'城区',240,'140302',3), +(242,'矿区',240,'140303',3), +(243,'郊区',240,'140311',3), +(244,'平定县',240,'140321',3), +(245,'盂县',240,'140322',3), +(246,'长治市',217,'140400',2), +(247,'潞州区',246,'140403',3), +(248,'上党区',246,'140404',3), +(249,'屯留区',246,'140405',3), +(250,'潞城区',246,'140406',3), +(251,'襄垣县',246,'140423',3), +(252,'平顺县',246,'140425',3), +(253,'黎城县',246,'140426',3), +(254,'壶关县',246,'140427',3), +(255,'长子县',246,'140428',3), +(256,'武乡县',246,'140429',3), +(257,'沁县',246,'140430',3), +(258,'沁源县',246,'140431',3), +(259,'晋城市',217,'140500',2), +(260,'城区',259,'140502',3), +(261,'沁水县',259,'140521',3), +(262,'阳城县',259,'140522',3), +(263,'陵川县',259,'140524',3), +(264,'泽州县',259,'140525',3), +(265,'高平市',259,'140581',3), +(266,'朔州市',217,'140600',2), +(267,'朔城区',266,'140602',3), +(268,'平鲁区',266,'140603',3), +(269,'山阴县',266,'140621',3), +(270,'应县',266,'140622',3), +(271,'右玉县',266,'140623',3), +(272,'怀仁市',266,'140681',3), +(273,'晋中市',217,'140700',2), +(274,'榆次区',273,'140702',3), +(275,'太谷区',273,'140703',3), +(276,'榆社县',273,'140721',3), +(277,'左权县',273,'140722',3), +(278,'和顺县',273,'140723',3), +(279,'昔阳县',273,'140724',3), +(280,'寿阳县',273,'140725',3), +(281,'祁县',273,'140727',3), +(282,'平遥县',273,'140728',3), +(283,'灵石县',273,'140729',3), +(284,'介休市',273,'140781',3), +(285,'运城市',217,'140800',2), +(286,'盐湖区',285,'140802',3), +(287,'临猗县',285,'140821',3), +(288,'万荣县',285,'140822',3), +(289,'闻喜县',285,'140823',3), +(290,'稷山县',285,'140824',3), +(291,'新绛县',285,'140825',3), +(292,'绛县',285,'140826',3), +(293,'垣曲县',285,'140827',3), +(294,'夏县',285,'140828',3), +(295,'平陆县',285,'140829',3), +(296,'芮城县',285,'140830',3), +(297,'永济市',285,'140881',3), +(298,'河津市',285,'140882',3), +(299,'忻州市',217,'140900',2), +(300,'忻府区',299,'140902',3), +(301,'定襄县',299,'140921',3), +(302,'五台县',299,'140922',3), +(303,'代县',299,'140923',3), +(304,'繁峙县',299,'140924',3), +(305,'宁武县',299,'140925',3), +(306,'静乐县',299,'140926',3), +(307,'神池县',299,'140927',3), +(308,'五寨县',299,'140928',3), +(309,'岢岚县',299,'140929',3), +(310,'河曲县',299,'140930',3), +(311,'保德县',299,'140931',3), +(312,'偏关县',299,'140932',3), +(313,'原平市',299,'140981',3), +(314,'临汾市',217,'141000',2), +(315,'尧都区',314,'141002',3), +(316,'曲沃县',314,'141021',3), +(317,'翼城县',314,'141022',3), +(318,'襄汾县',314,'141023',3), +(319,'洪洞县',314,'141024',3), +(320,'古县',314,'141025',3), +(321,'安泽县',314,'141026',3), +(322,'浮山县',314,'141027',3), +(323,'吉县',314,'141028',3), +(324,'乡宁县',314,'141029',3), +(325,'大宁县',314,'141030',3), +(326,'隰县',314,'141031',3), +(327,'永和县',314,'141032',3), +(328,'蒲县',314,'141033',3), +(329,'汾西县',314,'141034',3), +(330,'侯马市',314,'141081',3), +(331,'霍州市',314,'141082',3), +(332,'吕梁市',217,'141100',2), +(333,'离石区',332,'141102',3), +(334,'文水县',332,'141121',3), +(335,'交城县',332,'141122',3), +(336,'兴县',332,'141123',3), +(337,'临县',332,'141124',3), +(338,'柳林县',332,'141125',3), +(339,'石楼县',332,'141126',3), +(340,'岚县',332,'141127',3), +(341,'方山县',332,'141128',3), +(342,'中阳县',332,'141129',3), +(343,'交口县',332,'141130',3), +(344,'孝义市',332,'141181',3), +(345,'汾阳市',332,'141182',3), +(346,'内蒙古自治区',0,'150000',1), +(347,'呼和浩特市',346,'150100',2), +(348,'新城区',347,'150102',3), +(349,'回民区',347,'150103',3), +(350,'玉泉区',347,'150104',3), +(351,'赛罕区',347,'150105',3), +(352,'土默特左旗',347,'150121',3), +(353,'托克托县',347,'150122',3), +(354,'和林格尔县',347,'150123',3), +(355,'清水河县',347,'150124',3), +(356,'武川县',347,'150125',3), +(357,'包头市',346,'150200',2), +(358,'东河区',357,'150202',3), +(359,'昆都仑区',357,'150203',3), +(360,'青山区',357,'150204',3), +(361,'石拐区',357,'150205',3), +(362,'白云鄂博矿区',357,'150206',3), +(363,'九原区',357,'150207',3), +(364,'土默特右旗',357,'150221',3), +(365,'固阳县',357,'150222',3), +(366,'达尔罕茂明安联合旗',357,'150223',3), +(367,'乌海市',346,'150300',2), +(368,'海勃湾区',367,'150302',3), +(369,'海南区',367,'150303',3), +(370,'乌达区',367,'150304',3), +(371,'赤峰市',346,'150400',2), +(372,'红山区',371,'150402',3), +(373,'元宝山区',371,'150403',3), +(374,'松山区',371,'150404',3), +(375,'阿鲁科尔沁旗',371,'150421',3), +(376,'巴林左旗',371,'150422',3), +(377,'巴林右旗',371,'150423',3), +(378,'林西县',371,'150424',3), +(379,'克什克腾旗',371,'150425',3), +(380,'翁牛特旗',371,'150426',3), +(381,'喀喇沁旗',371,'150428',3), +(382,'宁城县',371,'150429',3), +(383,'敖汉旗',371,'150430',3), +(384,'通辽市',346,'150500',2), +(385,'科尔沁区',384,'150502',3), +(386,'科尔沁左翼中旗',384,'150521',3), +(387,'科尔沁左翼后旗',384,'150522',3), +(388,'开鲁县',384,'150523',3), +(389,'库伦旗',384,'150524',3), +(390,'奈曼旗',384,'150525',3), +(391,'扎鲁特旗',384,'150526',3), +(392,'霍林郭勒市',384,'150581',3), +(393,'鄂尔多斯市',346,'150600',2), +(394,'东胜区',393,'150602',3), +(395,'康巴什区',393,'150603',3), +(396,'达拉特旗',393,'150621',3), +(397,'准格尔旗',393,'150622',3), +(398,'鄂托克前旗',393,'150623',3), +(399,'鄂托克旗',393,'150624',3), +(400,'杭锦旗',393,'150625',3), +(401,'乌审旗',393,'150626',3), +(402,'伊金霍洛旗',393,'150627',3), +(403,'呼伦贝尔市',346,'150700',2), +(404,'海拉尔区',403,'150702',3), +(405,'扎赉诺尔区',403,'150703',3), +(406,'阿荣旗',403,'150721',3), +(407,'莫力达瓦达斡尔族自治旗',403,'150722',3), +(408,'鄂伦春自治旗',403,'150723',3), +(409,'鄂温克族自治旗',403,'150724',3), +(410,'陈巴尔虎旗',403,'150725',3), +(411,'新巴尔虎左旗',403,'150726',3), +(412,'新巴尔虎右旗',403,'150727',3), +(413,'满洲里市',403,'150781',3), +(414,'牙克石市',403,'150782',3), +(415,'扎兰屯市',403,'150783',3), +(416,'额尔古纳市',403,'150784',3), +(417,'根河市',403,'150785',3), +(418,'巴彦淖尔市',346,'150800',2), +(419,'临河区',418,'150802',3), +(420,'五原县',418,'150821',3), +(421,'磴口县',418,'150822',3), +(422,'乌拉特前旗',418,'150823',3), +(423,'乌拉特中旗',418,'150824',3), +(424,'乌拉特后旗',418,'150825',3), +(425,'杭锦后旗',418,'150826',3), +(426,'乌兰察布市',346,'150900',2), +(427,'集宁区',426,'150902',3), +(428,'卓资县',426,'150921',3), +(429,'化德县',426,'150922',3), +(430,'商都县',426,'150923',3), +(431,'兴和县',426,'150924',3), +(432,'凉城县',426,'150925',3), +(433,'察哈尔右翼前旗',426,'150926',3), +(434,'察哈尔右翼中旗',426,'150927',3), +(435,'察哈尔右翼后旗',426,'150928',3), +(436,'四子王旗',426,'150929',3), +(437,'丰镇市',426,'150981',3), +(438,'兴安盟',346,'152200',2), +(439,'乌兰浩特市',438,'152201',3), +(440,'阿尔山市',438,'152202',3), +(441,'科尔沁右翼前旗',438,'152221',3), +(442,'科尔沁右翼中旗',438,'152222',3), +(443,'扎赉特旗',438,'152223',3), +(444,'突泉县',438,'152224',3), +(445,'锡林郭勒盟',346,'152500',2), +(446,'二连浩特市',445,'152501',3), +(447,'锡林浩特市',445,'152502',3), +(448,'阿巴嘎旗',445,'152522',3), +(449,'苏尼特左旗',445,'152523',3), +(450,'苏尼特右旗',445,'152524',3), +(451,'东乌珠穆沁旗',445,'152525',3), +(452,'西乌珠穆沁旗',445,'152526',3), +(453,'太仆寺旗',445,'152527',3), +(454,'镶黄旗',445,'152528',3), +(455,'正镶白旗',445,'152529',3), +(456,'正蓝旗',445,'152530',3), +(457,'多伦县',445,'152531',3), +(458,'阿拉善盟',346,'152900',2), +(459,'阿拉善左旗',458,'152921',3), +(460,'阿拉善右旗',458,'152922',3), +(461,'额济纳旗',458,'152923',3), +(462,'辽宁省',0,'210000',1), +(463,'沈阳市',462,'210100',2), +(464,'和平区',463,'210102',3), +(465,'沈河区',463,'210103',3), +(466,'大东区',463,'210104',3), +(467,'皇姑区',463,'210105',3), +(468,'铁西区',463,'210106',3), +(469,'苏家屯区',463,'210111',3), +(470,'浑南区',463,'210112',3), +(471,'沈北新区',463,'210113',3), +(472,'于洪区',463,'210114',3), +(473,'辽中区',463,'210115',3), +(474,'康平县',463,'210123',3), +(475,'法库县',463,'210124',3), +(476,'新民市',463,'210181',3), +(477,'大连市',462,'210200',2), +(478,'中山区',477,'210202',3), +(479,'西岗区',477,'210203',3), +(480,'沙河口区',477,'210204',3), +(481,'甘井子区',477,'210211',3), +(482,'旅顺口区',477,'210212',3), +(483,'金州区',477,'210213',3), +(484,'普兰店区',477,'210214',3), +(485,'长海县',477,'210224',3), +(486,'瓦房店市',477,'210281',3), +(487,'庄河市',477,'210283',3), +(488,'鞍山市',462,'210300',2), +(489,'铁东区',488,'210302',3), +(490,'铁西区',488,'210303',3), +(491,'立山区',488,'210304',3), +(492,'千山区',488,'210311',3), +(493,'台安县',488,'210321',3), +(494,'岫岩满族自治县',488,'210323',3), +(495,'海城市',488,'210381',3), +(496,'抚顺市',462,'210400',2), +(497,'新抚区',496,'210402',3), +(498,'东洲区',496,'210403',3), +(499,'望花区',496,'210404',3), +(500,'顺城区',496,'210411',3), +(501,'抚顺县',496,'210421',3), +(502,'新宾满族自治县',496,'210422',3), +(503,'清原满族自治县',496,'210423',3), +(504,'本溪市',462,'210500',2), +(505,'平山区',504,'210502',3), +(506,'溪湖区',504,'210503',3), +(507,'明山区',504,'210504',3), +(508,'南芬区',504,'210505',3), +(509,'本溪满族自治县',504,'210521',3), +(510,'桓仁满族自治县',504,'210522',3), +(511,'丹东市',462,'210600',2), +(512,'元宝区',511,'210602',3), +(513,'振兴区',511,'210603',3), +(514,'振安区',511,'210604',3), +(515,'宽甸满族自治县',511,'210624',3), +(516,'东港市',511,'210681',3), +(517,'凤城市',511,'210682',3), +(518,'锦州市',462,'210700',2), +(519,'古塔区',518,'210702',3), +(520,'凌河区',518,'210703',3), +(521,'太和区',518,'210711',3), +(522,'黑山县',518,'210726',3), +(523,'义县',518,'210727',3), +(524,'凌海市',518,'210781',3), +(525,'北镇市',518,'210782',3), +(526,'营口市',462,'210800',2), +(527,'站前区',526,'210802',3), +(528,'西市区',526,'210803',3), +(529,'鲅鱼圈区',526,'210804',3), +(530,'老边区',526,'210811',3), +(531,'盖州市',526,'210881',3), +(532,'大石桥市',526,'210882',3), +(533,'阜新市',462,'210900',2), +(534,'海州区',533,'210902',3), +(535,'新邱区',533,'210903',3), +(536,'太平区',533,'210904',3), +(537,'清河门区',533,'210905',3), +(538,'细河区',533,'210911',3), +(539,'阜新蒙古族自治县',533,'210921',3), +(540,'彰武县',533,'210922',3), +(541,'辽阳市',462,'211000',2), +(542,'白塔区',541,'211002',3), +(543,'文圣区',541,'211003',3), +(544,'宏伟区',541,'211004',3), +(545,'弓长岭区',541,'211005',3), +(546,'太子河区',541,'211011',3), +(547,'辽阳县',541,'211021',3), +(548,'灯塔市',541,'211081',3), +(549,'盘锦市',462,'211100',2), +(550,'双台子区',549,'211102',3), +(551,'兴隆台区',549,'211103',3), +(552,'大洼区',549,'211104',3), +(553,'盘山县',549,'211122',3), +(554,'铁岭市',462,'211200',2), +(555,'银州区',554,'211202',3), +(556,'清河区',554,'211204',3), +(557,'铁岭县',554,'211221',3), +(558,'西丰县',554,'211223',3), +(559,'昌图县',554,'211224',3), +(560,'调兵山市',554,'211281',3), +(561,'开原市',554,'211282',3), +(562,'朝阳市',462,'211300',2), +(563,'双塔区',562,'211302',3), +(564,'龙城区',562,'211303',3), +(565,'朝阳县',562,'211321',3), +(566,'建平县',562,'211322',3), +(567,'喀喇沁左翼蒙古族自治县',562,'211324',3), +(568,'北票市',562,'211381',3), +(569,'凌源市',562,'211382',3), +(570,'葫芦岛市',462,'211400',2), +(571,'连山区',570,'211402',3), +(572,'龙港区',570,'211403',3), +(573,'南票区',570,'211404',3), +(574,'绥中县',570,'211421',3), +(575,'建昌县',570,'211422',3), +(576,'兴城市',570,'211481',3), +(577,'吉林省',0,'220000',1), +(578,'长春市',577,'220100',2), +(579,'南关区',578,'220102',3), +(580,'宽城区',578,'220103',3), +(581,'朝阳区',578,'220104',3), +(582,'二道区',578,'220105',3), +(583,'绿园区',578,'220106',3), +(584,'双阳区',578,'220112',3), +(585,'九台区',578,'220113',3), +(586,'农安县',578,'220122',3), +(587,'榆树市',578,'220182',3), +(588,'德惠市',578,'220183',3), +(589,'吉林市',577,'220200',2), +(590,'昌邑区',589,'220202',3), +(591,'龙潭区',589,'220203',3), +(592,'船营区',589,'220204',3), +(593,'丰满区',589,'220211',3), +(594,'永吉县',589,'220221',3), +(595,'蛟河市',589,'220281',3), +(596,'桦甸市',589,'220282',3), +(597,'舒兰市',589,'220283',3), +(598,'磐石市',589,'220284',3), +(599,'四平市',577,'220300',2), +(600,'铁西区',599,'220302',3), +(601,'铁东区',599,'220303',3), +(602,'梨树县',599,'220322',3), +(603,'伊通满族自治县',599,'220323',3), +(604,'公主岭市',599,'220381',3), +(605,'双辽市',599,'220382',3), +(606,'辽源市',577,'220400',2), +(607,'龙山区',606,'220402',3), +(608,'西安区',606,'220403',3), +(609,'东丰县',606,'220421',3), +(610,'东辽县',606,'220422',3), +(611,'通化市',577,'220500',2), +(612,'东昌区',611,'220502',3), +(613,'二道江区',611,'220503',3), +(614,'通化县',611,'220521',3), +(615,'辉南县',611,'220523',3), +(616,'柳河县',611,'220524',3), +(617,'梅河口市',611,'220581',3), +(618,'集安市',611,'220582',3), +(619,'白山市',577,'220600',2), +(620,'浑江区',619,'220602',3), +(621,'江源区',619,'220605',3), +(622,'抚松县',619,'220621',3), +(623,'靖宇县',619,'220622',3), +(624,'长白朝鲜族自治县',619,'220623',3), +(625,'临江市',619,'220681',3), +(626,'松原市',577,'220700',2), +(627,'宁江区',626,'220702',3), +(628,'前郭尔罗斯蒙古族自治县',626,'220721',3), +(629,'长岭县',626,'220722',3), +(630,'乾安县',626,'220723',3), +(631,'扶余市',626,'220781',3), +(632,'白城市',577,'220800',2), +(633,'洮北区',632,'220802',3), +(634,'镇赉县',632,'220821',3), +(635,'通榆县',632,'220822',3), +(636,'洮南市',632,'220881',3), +(637,'大安市',632,'220882',3), +(638,'延边朝鲜族自治州',577,'222400',2), +(639,'延吉市',638,'222401',3), +(640,'图们市',638,'222402',3), +(641,'敦化市',638,'222403',3), +(642,'珲春市',638,'222404',3), +(643,'龙井市',638,'222405',3), +(644,'和龙市',638,'222406',3), +(645,'汪清县',638,'222424',3), +(646,'安图县',638,'222426',3), +(647,'黑龙江省',0,'230000',1), +(648,'哈尔滨市',647,'230100',2), +(649,'道里区',648,'230102',3), +(650,'南岗区',648,'230103',3), +(651,'道外区',648,'230104',3), +(652,'平房区',648,'230108',3), +(653,'松北区',648,'230109',3), +(654,'香坊区',648,'230110',3), +(655,'呼兰区',648,'230111',3), +(656,'阿城区',648,'230112',3), +(657,'双城区',648,'230113',3), +(658,'依兰县',648,'230123',3), +(659,'方正县',648,'230124',3), +(660,'宾县',648,'230125',3), +(661,'巴彦县',648,'230126',3), +(662,'木兰县',648,'230127',3), +(663,'通河县',648,'230128',3), +(664,'延寿县',648,'230129',3), +(665,'尚志市',648,'230183',3), +(666,'五常市',648,'230184',3), +(667,'齐齐哈尔市',647,'230200',2), +(668,'龙沙区',667,'230202',3), +(669,'建华区',667,'230203',3), +(670,'铁锋区',667,'230204',3), +(671,'昂昂溪区',667,'230205',3), +(672,'富拉尔基区',667,'230206',3), +(673,'碾子山区',667,'230207',3), +(674,'梅里斯达斡尔族区',667,'230208',3), +(675,'龙江县',667,'230221',3), +(676,'依安县',667,'230223',3), +(677,'泰来县',667,'230224',3), +(678,'甘南县',667,'230225',3), +(679,'富裕县',667,'230227',3), +(680,'克山县',667,'230229',3), +(681,'克东县',667,'230230',3), +(682,'拜泉县',667,'230231',3), +(683,'讷河市',667,'230281',3), +(684,'鸡西市',647,'230300',2), +(685,'鸡冠区',684,'230302',3), +(686,'恒山区',684,'230303',3), +(687,'滴道区',684,'230304',3), +(688,'梨树区',684,'230305',3), +(689,'城子河区',684,'230306',3), +(690,'麻山区',684,'230307',3), +(691,'鸡东县',684,'230321',3), +(692,'虎林市',684,'230381',3), +(693,'密山市',684,'230382',3), +(694,'鹤岗市',647,'230400',2), +(695,'向阳区',694,'230402',3), +(696,'工农区',694,'230403',3), +(697,'南山区',694,'230404',3), +(698,'兴安区',694,'230405',3), +(699,'东山区',694,'230406',3), +(700,'兴山区',694,'230407',3), +(701,'萝北县',694,'230421',3), +(702,'绥滨县',694,'230422',3), +(703,'双鸭山市',647,'230500',2), +(704,'尖山区',703,'230502',3), +(705,'岭东区',703,'230503',3), +(706,'四方台区',703,'230505',3), +(707,'宝山区',703,'230506',3), +(708,'集贤县',703,'230521',3), +(709,'友谊县',703,'230522',3), +(710,'宝清县',703,'230523',3), +(711,'饶河县',703,'230524',3), +(712,'大庆市',647,'230600',2), +(713,'萨尔图区',712,'230602',3), +(714,'龙凤区',712,'230603',3), +(715,'让胡路区',712,'230604',3), +(716,'红岗区',712,'230605',3), +(717,'大同区',712,'230606',3), +(718,'肇州县',712,'230621',3), +(719,'肇源县',712,'230622',3), +(720,'林甸县',712,'230623',3), +(721,'杜尔伯特蒙古族自治县',712,'230624',3), +(722,'伊春市',647,'230700',2), +(723,'伊美区',722,'230717',3), +(724,'乌翠区',722,'230718',3), +(725,'友好区',722,'230719',3), +(726,'嘉荫县',722,'230722',3), +(727,'汤旺县',722,'230723',3), +(728,'丰林县',722,'230724',3), +(729,'大箐山县',722,'230725',3), +(730,'南岔县',722,'230726',3), +(731,'金林区',722,'230751',3), +(732,'铁力市',722,'230781',3), +(733,'佳木斯市',647,'230800',2), +(734,'向阳区',733,'230803',3), +(735,'前进区',733,'230804',3), +(736,'东风区',733,'230805',3), +(737,'郊区',733,'230811',3), +(738,'桦南县',733,'230822',3), +(739,'桦川县',733,'230826',3), +(740,'汤原县',733,'230828',3), +(741,'同江市',733,'230881',3), +(742,'富锦市',733,'230882',3), +(743,'抚远市',733,'230883',3), +(744,'七台河市',647,'230900',2), +(745,'新兴区',744,'230902',3), +(746,'桃山区',744,'230903',3), +(747,'茄子河区',744,'230904',3), +(748,'勃利县',744,'230921',3), +(749,'牡丹江市',647,'231000',2), +(750,'东安区',749,'231002',3), +(751,'阳明区',749,'231003',3), +(752,'爱民区',749,'231004',3), +(753,'西安区',749,'231005',3), +(754,'林口县',749,'231025',3), +(755,'绥芬河市',749,'231081',3), +(756,'海林市',749,'231083',3), +(757,'宁安市',749,'231084',3), +(758,'穆棱市',749,'231085',3), +(759,'东宁市',749,'231086',3), +(760,'黑河市',647,'231100',2), +(761,'爱辉区',760,'231102',3), +(762,'逊克县',760,'231123',3), +(763,'孙吴县',760,'231124',3), +(764,'北安市',760,'231181',3), +(765,'五大连池市',760,'231182',3), +(766,'嫩江市',760,'231183',3), +(767,'绥化市',647,'231200',2), +(768,'北林区',767,'231202',3), +(769,'望奎县',767,'231221',3), +(770,'兰西县',767,'231222',3), +(771,'青冈县',767,'231223',3), +(772,'庆安县',767,'231224',3), +(773,'明水县',767,'231225',3), +(774,'绥棱县',767,'231226',3), +(775,'安达市',767,'231281',3), +(776,'肇东市',767,'231282',3), +(777,'海伦市',767,'231283',3), +(778,'大兴安岭地区',647,'232700',2), +(779,'漠河市',778,'232701',3), +(780,'呼玛县',778,'232721',3), +(781,'塔河县',778,'232722',3), +(782,'上海',0,'310000',1), +(783,'上海市',782,'310010',2), +(784,'黄浦区',783,'310101',3), +(785,'徐汇区',783,'310104',3), +(786,'长宁区',783,'310105',3), +(787,'静安区',783,'310106',3), +(788,'普陀区',783,'310107',3), +(789,'虹口区',783,'310109',3), +(790,'杨浦区',783,'310110',3), +(791,'闵行区',783,'310112',3), +(792,'宝山区',783,'310113',3), +(793,'嘉定区',783,'310114',3), +(794,'浦东新区',783,'310115',3), +(795,'金山区',783,'310116',3), +(796,'松江区',783,'310117',3), +(797,'青浦区',783,'310118',3), +(798,'奉贤区',783,'310120',3), +(799,'崇明区',783,'310151',3), +(800,'江苏省',0,'320000',1), +(801,'南京市',800,'320100',2), +(802,'玄武区',801,'320102',3), +(803,'秦淮区',801,'320104',3), +(804,'建邺区',801,'320105',3), +(805,'鼓楼区',801,'320106',3), +(806,'浦口区',801,'320111',3), +(807,'栖霞区',801,'320113',3), +(808,'雨花台区',801,'320114',3), +(809,'江宁区',801,'320115',3), +(810,'六合区',801,'320116',3), +(811,'溧水区',801,'320117',3), +(812,'高淳区',801,'320118',3), +(813,'无锡市',800,'320200',2), +(814,'锡山区',813,'320205',3), +(815,'惠山区',813,'320206',3), +(816,'滨湖区',813,'320211',3), +(817,'梁溪区',813,'320213',3), +(818,'新吴区',813,'320214',3), +(819,'江阴市',813,'320281',3), +(820,'宜兴市',813,'320282',3), +(821,'徐州市',800,'320300',2), +(822,'鼓楼区',821,'320302',3), +(823,'云龙区',821,'320303',3), +(824,'贾汪区',821,'320305',3), +(825,'泉山区',821,'320311',3), +(826,'铜山区',821,'320312',3), +(827,'丰县',821,'320321',3), +(828,'沛县',821,'320322',3), +(829,'睢宁县',821,'320324',3), +(830,'新沂市',821,'320381',3), +(831,'邳州市',821,'320382',3), +(832,'常州市',800,'320400',2), +(833,'天宁区',832,'320402',3), +(834,'钟楼区',832,'320404',3), +(835,'新北区',832,'320411',3), +(836,'武进区',832,'320412',3), +(837,'金坛区',832,'320413',3), +(838,'溧阳市',832,'320481',3), +(839,'苏州市',800,'320500',2), +(840,'虎丘区',839,'320505',3), +(841,'吴中区',839,'320506',3), +(842,'相城区',839,'320507',3), +(843,'姑苏区',839,'320508',3), +(844,'吴江区',839,'320509',3), +(845,'常熟市',839,'320581',3), +(846,'张家港市',839,'320582',3), +(847,'昆山市',839,'320583',3), +(848,'太仓市',839,'320585',3), +(849,'南通市',800,'320600',2), +(850,'崇川区',849,'320602',3), +(851,'港闸区',849,'320611',3), +(852,'通州区',849,'320612',3), +(853,'如东县',849,'320623',3), +(854,'启东市',849,'320681',3), +(855,'如皋市',849,'320682',3), +(856,'海门市',849,'320684',3), +(857,'海安市',849,'320685',3), +(858,'连云港市',800,'320700',2), +(859,'连云区',858,'320703',3), +(860,'海州区',858,'320706',3), +(861,'赣榆区',858,'320707',3), +(862,'东海县',858,'320722',3), +(863,'灌云县',858,'320723',3), +(864,'灌南县',858,'320724',3), +(865,'淮安市',800,'320800',2), +(866,'淮安区',865,'320803',3), +(867,'淮阴区',865,'320804',3), +(868,'清江浦区',865,'320812',3), +(869,'洪泽区',865,'320813',3), +(870,'涟水县',865,'320826',3), +(871,'盱眙县',865,'320830',3), +(872,'金湖县',865,'320831',3), +(873,'盐城市',800,'320900',2), +(874,'亭湖区',873,'320902',3), +(875,'盐都区',873,'320903',3), +(876,'大丰区',873,'320904',3), +(877,'响水县',873,'320921',3), +(878,'滨海县',873,'320922',3), +(879,'阜宁县',873,'320923',3), +(880,'射阳县',873,'320924',3), +(881,'建湖县',873,'320925',3), +(882,'东台市',873,'320981',3), +(883,'扬州市',800,'321000',2), +(884,'广陵区',883,'321002',3), +(885,'邗江区',883,'321003',3), +(886,'江都区',883,'321012',3), +(887,'宝应县',883,'321023',3), +(888,'仪征市',883,'321081',3), +(889,'高邮市',883,'321084',3), +(890,'镇江市',800,'321100',2), +(891,'京口区',890,'321102',3), +(892,'润州区',890,'321111',3), +(893,'丹徒区',890,'321112',3), +(894,'丹阳市',890,'321181',3), +(895,'扬中市',890,'321182',3), +(896,'句容市',890,'321183',3), +(897,'泰州市',800,'321200',2), +(898,'海陵区',897,'321202',3), +(899,'高港区',897,'321203',3), +(900,'姜堰区',897,'321204',3), +(901,'兴化市',897,'321281',3), +(902,'靖江市',897,'321282',3), +(903,'泰兴市',897,'321283',3), +(904,'宿迁市',800,'321300',2), +(905,'宿城区',904,'321302',3), +(906,'宿豫区',904,'321311',3), +(907,'沭阳县',904,'321322',3), +(908,'泗阳县',904,'321323',3), +(909,'泗洪县',904,'321324',3), +(910,'浙江省',0,'330000',1), +(911,'杭州市',910,'330100',2), +(912,'上城区',911,'330102',3), +(913,'下城区',911,'330103',3), +(914,'江干区',911,'330104',3), +(915,'拱墅区',911,'330105',3), +(916,'西湖区',911,'330106',3), +(917,'滨江区',911,'330108',3), +(918,'萧山区',911,'330109',3), +(919,'余杭区',911,'330110',3), +(920,'富阳区',911,'330111',3), +(921,'临安区',911,'330112',3), +(922,'桐庐县',911,'330122',3), +(923,'淳安县',911,'330127',3), +(924,'建德市',911,'330182',3), +(925,'宁波市',910,'330200',2), +(926,'海曙区',925,'330203',3), +(927,'江北区',925,'330205',3), +(928,'北仑区',925,'330206',3), +(929,'镇海区',925,'330211',3), +(930,'鄞州区',925,'330212',3), +(931,'奉化区',925,'330213',3), +(932,'象山县',925,'330225',3), +(933,'宁海县',925,'330226',3), +(934,'余姚市',925,'330281',3), +(935,'慈溪市',925,'330282',3), +(936,'温州市',910,'330300',2), +(937,'鹿城区',936,'330302',3), +(938,'龙湾区',936,'330303',3), +(939,'瓯海区',936,'330304',3), +(940,'洞头区',936,'330305',3), +(941,'永嘉县',936,'330324',3), +(942,'平阳县',936,'330326',3), +(943,'苍南县',936,'330327',3), +(944,'文成县',936,'330328',3), +(945,'泰顺县',936,'330329',3), +(946,'瑞安市',936,'330381',3), +(947,'乐清市',936,'330382',3), +(948,'龙港市',936,'330383',3), +(949,'嘉兴市',910,'330400',2), +(950,'南湖区',949,'330402',3), +(951,'秀洲区',949,'330411',3), +(952,'嘉善县',949,'330421',3), +(953,'海盐县',949,'330424',3), +(954,'海宁市',949,'330481',3), +(955,'平湖市',949,'330482',3), +(956,'桐乡市',949,'330483',3), +(957,'湖州市',910,'330500',2), +(958,'吴兴区',957,'330502',3), +(959,'南浔区',957,'330503',3), +(960,'德清县',957,'330521',3), +(961,'长兴县',957,'330522',3), +(962,'安吉县',957,'330523',3), +(963,'绍兴市',910,'330600',2), +(964,'越城区',963,'330602',3), +(965,'柯桥区',963,'330603',3), +(966,'上虞区',963,'330604',3), +(967,'新昌县',963,'330624',3), +(968,'诸暨市',963,'330681',3), +(969,'嵊州市',963,'330683',3), +(970,'金华市',910,'330700',2), +(971,'婺城区',970,'330702',3), +(972,'金东区',970,'330703',3), +(973,'武义县',970,'330723',3), +(974,'浦江县',970,'330726',3), +(975,'磐安县',970,'330727',3), +(976,'兰溪市',970,'330781',3), +(977,'义乌市',970,'330782',3), +(978,'东阳市',970,'330783',3), +(979,'永康市',970,'330784',3), +(980,'衢州市',910,'330800',2), +(981,'柯城区',980,'330802',3), +(982,'衢江区',980,'330803',3), +(983,'常山县',980,'330822',3), +(984,'开化县',980,'330824',3), +(985,'龙游县',980,'330825',3), +(986,'江山市',980,'330881',3), +(987,'舟山市',910,'330900',2), +(988,'定海区',987,'330902',3), +(989,'普陀区',987,'330903',3), +(990,'岱山县',987,'330921',3), +(991,'嵊泗县',987,'330922',3), +(992,'台州市',910,'331000',2), +(993,'椒江区',992,'331002',3), +(994,'黄岩区',992,'331003',3), +(995,'路桥区',992,'331004',3), +(996,'三门县',992,'331022',3), +(997,'天台县',992,'331023',3), +(998,'仙居县',992,'331024',3), +(999,'温岭市',992,'331081',3), +(1000,'临海市',992,'331082',3), +(1001,'玉环市',992,'331083',3), +(1002,'丽水市',910,'331100',2), +(1003,'莲都区',1002,'331102',3), +(1004,'青田县',1002,'331121',3), +(1005,'缙云县',1002,'331122',3), +(1006,'遂昌县',1002,'331123',3), +(1007,'松阳县',1002,'331124',3), +(1008,'云和县',1002,'331125',3), +(1009,'庆元县',1002,'331126',3), +(1010,'景宁畲族自治县',1002,'331127',3), +(1011,'龙泉市',1002,'331181',3), +(1012,'安徽省',0,'340000',1), +(1013,'合肥市',1012,'340100',2), +(1014,'瑶海区',1013,'340102',3), +(1015,'庐阳区',1013,'340103',3), +(1016,'蜀山区',1013,'340104',3), +(1017,'包河区',1013,'340111',3), +(1018,'长丰县',1013,'340121',3), +(1019,'肥东县',1013,'340122',3), +(1020,'肥西县',1013,'340123',3), +(1021,'庐江县',1013,'340124',3), +(1022,'巢湖市',1013,'340181',3), +(1023,'芜湖市',1012,'340200',2), +(1024,'镜湖区',1023,'340202',3), +(1025,'弋江区',1023,'340203',3), +(1026,'鸠江区',1023,'340207',3), +(1027,'三山区',1023,'340208',3), +(1028,'芜湖县',1023,'340221',3), +(1029,'繁昌县',1023,'340222',3), +(1030,'南陵县',1023,'340223',3), +(1031,'无为市',1023,'340281',3), +(1032,'蚌埠市',1012,'340300',2), +(1033,'龙子湖区',1032,'340302',3), +(1034,'蚌山区',1032,'340303',3), +(1035,'禹会区',1032,'340304',3), +(1036,'淮上区',1032,'340311',3), +(1037,'怀远县',1032,'340321',3), +(1038,'五河县',1032,'340322',3), +(1039,'固镇县',1032,'340323',3), +(1040,'淮南市',1012,'340400',2), +(1041,'大通区',1040,'340402',3), +(1042,'田家庵区',1040,'340403',3), +(1043,'谢家集区',1040,'340404',3), +(1044,'八公山区',1040,'340405',3), +(1045,'潘集区',1040,'340406',3), +(1046,'凤台县',1040,'340421',3), +(1047,'寿县',1040,'340422',3), +(1048,'马鞍山市',1012,'340500',2), +(1049,'花山区',1048,'340503',3), +(1050,'雨山区',1048,'340504',3), +(1051,'博望区',1048,'340506',3), +(1052,'当涂县',1048,'340521',3), +(1053,'含山县',1048,'340522',3), +(1054,'和县',1048,'340523',3), +(1055,'淮北市',1012,'340600',2), +(1056,'杜集区',1055,'340602',3), +(1057,'相山区',1055,'340603',3), +(1058,'烈山区',1055,'340604',3), +(1059,'濉溪县',1055,'340621',3), +(1060,'铜陵市',1012,'340700',2), +(1061,'铜官区',1060,'340705',3), +(1062,'义安区',1060,'340706',3), +(1063,'郊区',1060,'340711',3), +(1064,'枞阳县',1060,'340722',3), +(1065,'安庆市',1012,'340800',2), +(1066,'迎江区',1065,'340802',3), +(1067,'大观区',1065,'340803',3), +(1068,'宜秀区',1065,'340811',3), +(1069,'怀宁县',1065,'340822',3), +(1070,'太湖县',1065,'340825',3), +(1071,'宿松县',1065,'340826',3), +(1072,'望江县',1065,'340827',3), +(1073,'岳西县',1065,'340828',3), +(1074,'桐城市',1065,'340881',3), +(1075,'潜山市',1065,'340882',3), +(1076,'黄山市',1012,'341000',2), +(1077,'屯溪区',1076,'341002',3), +(1078,'黄山区',1076,'341003',3), +(1079,'徽州区',1076,'341004',3), +(1080,'歙县',1076,'341021',3), +(1081,'休宁县',1076,'341022',3), +(1082,'黟县',1076,'341023',3), +(1083,'祁门县',1076,'341024',3), +(1084,'滁州市',1012,'341100',2), +(1085,'琅琊区',1084,'341102',3), +(1086,'南谯区',1084,'341103',3), +(1087,'来安县',1084,'341122',3), +(1088,'全椒县',1084,'341124',3), +(1089,'定远县',1084,'341125',3), +(1090,'凤阳县',1084,'341126',3), +(1091,'天长市',1084,'341181',3), +(1092,'明光市',1084,'341182',3), +(1093,'阜阳市',1012,'341200',2), +(1094,'颍州区',1093,'341202',3), +(1095,'颍东区',1093,'341203',3), +(1096,'颍泉区',1093,'341204',3), +(1097,'临泉县',1093,'341221',3), +(1098,'太和县',1093,'341222',3), +(1099,'阜南县',1093,'341225',3), +(1100,'颍上县',1093,'341226',3), +(1101,'界首市',1093,'341282',3), +(1102,'宿州市',1012,'341300',2), +(1103,'埇桥区',1102,'341302',3), +(1104,'砀山县',1102,'341321',3), +(1105,'萧县',1102,'341322',3), +(1106,'灵璧县',1102,'341323',3), +(1107,'泗县',1102,'341324',3), +(1108,'六安市',1012,'341500',2), +(1109,'金安区',1108,'341502',3), +(1110,'裕安区',1108,'341503',3), +(1111,'叶集区',1108,'341504',3), +(1112,'霍邱县',1108,'341522',3), +(1113,'舒城县',1108,'341523',3), +(1114,'金寨县',1108,'341524',3), +(1115,'霍山县',1108,'341525',3), +(1116,'亳州市',1012,'341600',2), +(1117,'谯城区',1116,'341602',3), +(1118,'涡阳县',1116,'341621',3), +(1119,'蒙城县',1116,'341622',3), +(1120,'利辛县',1116,'341623',3), +(1121,'池州市',1012,'341700',2), +(1122,'贵池区',1121,'341702',3), +(1123,'东至县',1121,'341721',3), +(1124,'石台县',1121,'341722',3), +(1125,'青阳县',1121,'341723',3), +(1126,'宣城市',1012,'341800',2), +(1127,'宣州区',1126,'341802',3), +(1128,'郎溪县',1126,'341821',3), +(1129,'泾县',1126,'341823',3), +(1130,'绩溪县',1126,'341824',3), +(1131,'旌德县',1126,'341825',3), +(1132,'宁国市',1126,'341881',3), +(1133,'广德市',1126,'341882',3), +(1134,'福建省',0,'350000',1), +(1135,'福州市',1134,'350100',2), +(1136,'鼓楼区',1135,'350102',3), +(1137,'台江区',1135,'350103',3), +(1138,'仓山区',1135,'350104',3), +(1139,'马尾区',1135,'350105',3), +(1140,'晋安区',1135,'350111',3), +(1141,'长乐区',1135,'350112',3), +(1142,'闽侯县',1135,'350121',3), +(1143,'连江县',1135,'350122',3), +(1144,'罗源县',1135,'350123',3), +(1145,'闽清县',1135,'350124',3), +(1146,'永泰县',1135,'350125',3), +(1147,'平潭县',1135,'350128',3), +(1148,'福清市',1135,'350181',3), +(1149,'厦门市',1134,'350200',2), +(1150,'思明区',1149,'350203',3), +(1151,'海沧区',1149,'350205',3), +(1152,'湖里区',1149,'350206',3), +(1153,'集美区',1149,'350211',3), +(1154,'同安区',1149,'350212',3), +(1155,'翔安区',1149,'350213',3), +(1156,'莆田市',1134,'350300',2), +(1157,'城厢区',1156,'350302',3), +(1158,'涵江区',1156,'350303',3), +(1159,'荔城区',1156,'350304',3), +(1160,'秀屿区',1156,'350305',3), +(1161,'仙游县',1156,'350322',3), +(1162,'三明市',1134,'350400',2), +(1163,'梅列区',1162,'350402',3), +(1164,'三元区',1162,'350403',3), +(1165,'明溪县',1162,'350421',3), +(1166,'清流县',1162,'350423',3), +(1167,'宁化县',1162,'350424',3), +(1168,'大田县',1162,'350425',3), +(1169,'尤溪县',1162,'350426',3), +(1170,'沙县',1162,'350427',3), +(1171,'将乐县',1162,'350428',3), +(1172,'泰宁县',1162,'350429',3), +(1173,'建宁县',1162,'350430',3), +(1174,'永安市',1162,'350481',3), +(1175,'泉州市',1134,'350500',2), +(1176,'鲤城区',1175,'350502',3), +(1177,'丰泽区',1175,'350503',3), +(1178,'洛江区',1175,'350504',3), +(1179,'泉港区',1175,'350505',3), +(1180,'惠安县',1175,'350521',3), +(1181,'安溪县',1175,'350524',3), +(1182,'永春县',1175,'350525',3), +(1183,'德化县',1175,'350526',3), +(1184,'金门县',1175,'350527',3), +(1185,'石狮市',1175,'350581',3), +(1186,'晋江市',1175,'350582',3), +(1187,'南安市',1175,'350583',3), +(1188,'漳州市',1134,'350600',2), +(1189,'芗城区',1188,'350602',3), +(1190,'龙文区',1188,'350603',3), +(1191,'云霄县',1188,'350622',3), +(1192,'漳浦县',1188,'350623',3), +(1193,'诏安县',1188,'350624',3), +(1194,'长泰县',1188,'350625',3), +(1195,'东山县',1188,'350626',3), +(1196,'南靖县',1188,'350627',3), +(1197,'平和县',1188,'350628',3), +(1198,'华安县',1188,'350629',3), +(1199,'龙海市',1188,'350681',3), +(1200,'南平市',1134,'350700',2), +(1201,'延平区',1200,'350702',3), +(1202,'建阳区',1200,'350703',3), +(1203,'顺昌县',1200,'350721',3), +(1204,'浦城县',1200,'350722',3), +(1205,'光泽县',1200,'350723',3), +(1206,'松溪县',1200,'350724',3), +(1207,'政和县',1200,'350725',3), +(1208,'邵武市',1200,'350781',3), +(1209,'武夷山市',1200,'350782',3), +(1210,'建瓯市',1200,'350783',3), +(1211,'龙岩市',1134,'350800',2), +(1212,'新罗区',1211,'350802',3), +(1213,'永定区',1211,'350803',3), +(1214,'长汀县',1211,'350821',3), +(1215,'上杭县',1211,'350823',3), +(1216,'武平县',1211,'350824',3), +(1217,'连城县',1211,'350825',3), +(1218,'漳平市',1211,'350881',3), +(1219,'宁德市',1134,'350900',2), +(1220,'蕉城区',1219,'350902',3), +(1221,'霞浦县',1219,'350921',3), +(1222,'古田县',1219,'350922',3), +(1223,'屏南县',1219,'350923',3), +(1224,'寿宁县',1219,'350924',3), +(1225,'周宁县',1219,'350925',3), +(1226,'柘荣县',1219,'350926',3), +(1227,'福安市',1219,'350981',3), +(1228,'福鼎市',1219,'350982',3), +(1229,'江西省',0,'360000',1), +(1230,'南昌市',1229,'360100',2), +(1231,'东湖区',1230,'360102',3), +(1232,'西湖区',1230,'360103',3), +(1233,'青云谱区',1230,'360104',3), +(1234,'青山湖区',1230,'360111',3), +(1235,'新建区',1230,'360112',3), +(1236,'红谷滩区',1230,'360113',3), +(1237,'南昌县',1230,'360121',3), +(1238,'安义县',1230,'360123',3), +(1239,'进贤县',1230,'360124',3), +(1240,'景德镇市',1229,'360200',2), +(1241,'昌江区',1240,'360202',3), +(1242,'珠山区',1240,'360203',3), +(1243,'浮梁县',1240,'360222',3), +(1244,'乐平市',1240,'360281',3), +(1245,'萍乡市',1229,'360300',2), +(1246,'安源区',1245,'360302',3), +(1247,'湘东区',1245,'360313',3), +(1248,'莲花县',1245,'360321',3), +(1249,'上栗县',1245,'360322',3), +(1250,'芦溪县',1245,'360323',3), +(1251,'九江市',1229,'360400',2), +(1252,'濂溪区',1251,'360402',3), +(1253,'浔阳区',1251,'360403',3), +(1254,'柴桑区',1251,'360404',3), +(1255,'武宁县',1251,'360423',3), +(1256,'修水县',1251,'360424',3), +(1257,'永修县',1251,'360425',3), +(1258,'德安县',1251,'360426',3), +(1259,'都昌县',1251,'360428',3), +(1260,'湖口县',1251,'360429',3), +(1261,'彭泽县',1251,'360430',3), +(1262,'瑞昌市',1251,'360481',3), +(1263,'共青城市',1251,'360482',3), +(1264,'庐山市',1251,'360483',3), +(1265,'新余市',1229,'360500',2), +(1266,'渝水区',1265,'360502',3), +(1267,'分宜县',1265,'360521',3), +(1268,'鹰潭市',1229,'360600',2), +(1269,'月湖区',1268,'360602',3), +(1270,'余江区',1268,'360603',3), +(1271,'贵溪市',1268,'360681',3), +(1272,'赣州市',1229,'360700',2), +(1273,'章贡区',1272,'360702',3), +(1274,'南康区',1272,'360703',3), +(1275,'赣县区',1272,'360704',3), +(1276,'信丰县',1272,'360722',3), +(1277,'大余县',1272,'360723',3), +(1278,'上犹县',1272,'360724',3), +(1279,'崇义县',1272,'360725',3), +(1280,'安远县',1272,'360726',3), +(1281,'龙南县',1272,'360727',3), +(1282,'定南县',1272,'360728',3), +(1283,'全南县',1272,'360729',3), +(1284,'宁都县',1272,'360730',3), +(1285,'于都县',1272,'360731',3), +(1286,'兴国县',1272,'360732',3), +(1287,'会昌县',1272,'360733',3), +(1288,'寻乌县',1272,'360734',3), +(1289,'石城县',1272,'360735',3), +(1290,'瑞金市',1272,'360781',3), +(1291,'吉安市',1229,'360800',2), +(1292,'吉州区',1291,'360802',3), +(1293,'青原区',1291,'360803',3), +(1294,'吉安县',1291,'360821',3), +(1295,'吉水县',1291,'360822',3), +(1296,'峡江县',1291,'360823',3), +(1297,'新干县',1291,'360824',3), +(1298,'永丰县',1291,'360825',3), +(1299,'泰和县',1291,'360826',3), +(1300,'遂川县',1291,'360827',3), +(1301,'万安县',1291,'360828',3), +(1302,'安福县',1291,'360829',3), +(1303,'永新县',1291,'360830',3), +(1304,'井冈山市',1291,'360881',3), +(1305,'宜春市',1229,'360900',2), +(1306,'袁州区',1305,'360902',3), +(1307,'奉新县',1305,'360921',3), +(1308,'万载县',1305,'360922',3), +(1309,'上高县',1305,'360923',3), +(1310,'宜丰县',1305,'360924',3), +(1311,'靖安县',1305,'360925',3), +(1312,'铜鼓县',1305,'360926',3), +(1313,'丰城市',1305,'360981',3), +(1314,'樟树市',1305,'360982',3), +(1315,'高安市',1305,'360983',3), +(1316,'抚州市',1229,'361000',2), +(1317,'临川区',1316,'361002',3), +(1318,'东乡区',1316,'361003',3), +(1319,'南城县',1316,'361021',3), +(1320,'黎川县',1316,'361022',3), +(1321,'南丰县',1316,'361023',3), +(1322,'崇仁县',1316,'361024',3), +(1323,'乐安县',1316,'361025',3), +(1324,'宜黄县',1316,'361026',3), +(1325,'金溪县',1316,'361027',3), +(1326,'资溪县',1316,'361028',3), +(1327,'广昌县',1316,'361030',3), +(1328,'上饶市',1229,'361100',2), +(1329,'信州区',1328,'361102',3), +(1330,'广丰区',1328,'361103',3), +(1331,'广信区',1328,'361104',3), +(1332,'玉山县',1328,'361123',3), +(1333,'铅山县',1328,'361124',3), +(1334,'横峰县',1328,'361125',3), +(1335,'弋阳县',1328,'361126',3), +(1336,'余干县',1328,'361127',3), +(1337,'鄱阳县',1328,'361128',3), +(1338,'万年县',1328,'361129',3), +(1339,'婺源县',1328,'361130',3), +(1340,'德兴市',1328,'361181',3), +(1341,'山东省',0,'370000',1), +(1342,'济南市',1341,'370100',2), +(1343,'历下区',1342,'370102',3), +(1344,'市中区',1342,'370103',3), +(1345,'槐荫区',1342,'370104',3), +(1346,'天桥区',1342,'370105',3), +(1347,'历城区',1342,'370112',3), +(1348,'长清区',1342,'370113',3), +(1349,'章丘区',1342,'370114',3), +(1350,'济阳区',1342,'370115',3), +(1351,'莱芜区',1342,'370116',3), +(1352,'钢城区',1342,'370117',3), +(1353,'平阴县',1342,'370124',3), +(1354,'商河县',1342,'370126',3), +(1355,'青岛市',1341,'370200',2), +(1356,'市南区',1355,'370202',3), +(1357,'市北区',1355,'370203',3), +(1358,'黄岛区',1355,'370211',3), +(1359,'崂山区',1355,'370212',3), +(1360,'李沧区',1355,'370213',3), +(1361,'城阳区',1355,'370214',3), +(1362,'即墨区',1355,'370215',3), +(1363,'胶州市',1355,'370281',3), +(1364,'平度市',1355,'370283',3), +(1365,'莱西市',1355,'370285',3), +(1366,'淄博市',1341,'370300',2), +(1367,'淄川区',1366,'370302',3), +(1368,'张店区',1366,'370303',3), +(1369,'博山区',1366,'370304',3), +(1370,'临淄区',1366,'370305',3), +(1371,'周村区',1366,'370306',3), +(1372,'桓台县',1366,'370321',3), +(1373,'高青县',1366,'370322',3), +(1374,'沂源县',1366,'370323',3), +(1375,'枣庄市',1341,'370400',2), +(1376,'市中区',1375,'370402',3), +(1377,'薛城区',1375,'370403',3), +(1378,'峄城区',1375,'370404',3), +(1379,'台儿庄区',1375,'370405',3), +(1380,'山亭区',1375,'370406',3), +(1381,'滕州市',1375,'370481',3), +(1382,'东营市',1341,'370500',2), +(1383,'东营区',1382,'370502',3), +(1384,'河口区',1382,'370503',3), +(1385,'垦利区',1382,'370505',3), +(1386,'利津县',1382,'370522',3), +(1387,'广饶县',1382,'370523',3), +(1388,'烟台市',1341,'370600',2), +(1389,'芝罘区',1388,'370602',3), +(1390,'福山区',1388,'370611',3), +(1391,'牟平区',1388,'370612',3), +(1392,'莱山区',1388,'370613',3), +(1393,'长岛县',1388,'370634',3), +(1394,'龙口市',1388,'370681',3), +(1395,'莱阳市',1388,'370682',3), +(1396,'莱州市',1388,'370683',3), +(1397,'蓬莱市',1388,'370684',3), +(1398,'招远市',1388,'370685',3), +(1399,'栖霞市',1388,'370686',3), +(1400,'海阳市',1388,'370687',3), +(1401,'潍坊市',1341,'370700',2), +(1402,'潍城区',1401,'370702',3), +(1403,'寒亭区',1401,'370703',3), +(1404,'坊子区',1401,'370704',3), +(1405,'奎文区',1401,'370705',3), +(1406,'临朐县',1401,'370724',3), +(1407,'昌乐县',1401,'370725',3), +(1408,'青州市',1401,'370781',3), +(1409,'诸城市',1401,'370782',3), +(1410,'寿光市',1401,'370783',3), +(1411,'安丘市',1401,'370784',3), +(1412,'高密市',1401,'370785',3), +(1413,'昌邑市',1401,'370786',3), +(1414,'济宁市',1341,'370800',2), +(1415,'任城区',1414,'370811',3), +(1416,'兖州区',1414,'370812',3), +(1417,'微山县',1414,'370826',3), +(1418,'鱼台县',1414,'370827',3), +(1419,'金乡县',1414,'370828',3), +(1420,'嘉祥县',1414,'370829',3), +(1421,'汶上县',1414,'370830',3), +(1422,'泗水县',1414,'370831',3), +(1423,'梁山县',1414,'370832',3), +(1424,'曲阜市',1414,'370881',3), +(1425,'邹城市',1414,'370883',3), +(1426,'泰安市',1341,'370900',2), +(1427,'泰山区',1426,'370902',3), +(1428,'岱岳区',1426,'370911',3), +(1429,'宁阳县',1426,'370921',3), +(1430,'东平县',1426,'370923',3), +(1431,'新泰市',1426,'370982',3), +(1432,'肥城市',1426,'370983',3), +(1433,'威海市',1341,'371000',2), +(1434,'环翠区',1433,'371002',3), +(1435,'文登区',1433,'371003',3), +(1436,'荣成市',1433,'371082',3), +(1437,'乳山市',1433,'371083',3), +(1438,'日照市',1341,'371100',2), +(1439,'东港区',1438,'371102',3), +(1440,'岚山区',1438,'371103',3), +(1441,'五莲县',1438,'371121',3), +(1442,'莒县',1438,'371122',3), +(1443,'临沂市',1341,'371300',2), +(1444,'兰山区',1443,'371302',3), +(1445,'罗庄区',1443,'371311',3), +(1446,'河东区',1443,'371312',3), +(1447,'沂南县',1443,'371321',3), +(1448,'郯城县',1443,'371322',3), +(1449,'沂水县',1443,'371323',3), +(1450,'兰陵县',1443,'371324',3), +(1451,'费县',1443,'371325',3), +(1452,'平邑县',1443,'371326',3), +(1453,'莒南县',1443,'371327',3), +(1454,'蒙阴县',1443,'371328',3), +(1455,'临沭县',1443,'371329',3), +(1456,'德州市',1341,'371400',2), +(1457,'德城区',1456,'371402',3), +(1458,'陵城区',1456,'371403',3), +(1459,'宁津县',1456,'371422',3), +(1460,'庆云县',1456,'371423',3), +(1461,'临邑县',1456,'371424',3), +(1462,'齐河县',1456,'371425',3), +(1463,'平原县',1456,'371426',3), +(1464,'夏津县',1456,'371427',3), +(1465,'武城县',1456,'371428',3), +(1466,'乐陵市',1456,'371481',3), +(1467,'禹城市',1456,'371482',3), +(1468,'聊城市',1341,'371500',2), +(1469,'东昌府区',1468,'371502',3), +(1470,'茌平区',1468,'371503',3), +(1471,'阳谷县',1468,'371521',3), +(1472,'莘县',1468,'371522',3), +(1473,'东阿县',1468,'371524',3), +(1474,'冠县',1468,'371525',3), +(1475,'高唐县',1468,'371526',3), +(1476,'临清市',1468,'371581',3), +(1477,'滨州市',1341,'371600',2), +(1478,'滨城区',1477,'371602',3), +(1479,'沾化区',1477,'371603',3), +(1480,'惠民县',1477,'371621',3), +(1481,'阳信县',1477,'371622',3), +(1482,'无棣县',1477,'371623',3), +(1483,'博兴县',1477,'371625',3), +(1484,'邹平市',1477,'371681',3), +(1485,'菏泽市',1341,'371700',2), +(1486,'牡丹区',1485,'371702',3), +(1487,'定陶区',1485,'371703',3), +(1488,'曹县',1485,'371721',3), +(1489,'单县',1485,'371722',3), +(1490,'成武县',1485,'371723',3), +(1491,'巨野县',1485,'371724',3), +(1492,'郓城县',1485,'371725',3), +(1493,'鄄城县',1485,'371726',3), +(1494,'东明县',1485,'371728',3), +(1495,'河南省',0,'410000',1), +(1496,'郑州市',1495,'410100',2), +(1497,'中原区',1496,'410102',3), +(1498,'二七区',1496,'410103',3), +(1499,'管城回族区',1496,'410104',3), +(1500,'金水区',1496,'410105',3), +(1501,'上街区',1496,'410106',3), +(1502,'惠济区',1496,'410108',3), +(1503,'中牟县',1496,'410122',3), +(1504,'巩义市',1496,'410181',3), +(1505,'荥阳市',1496,'410182',3), +(1506,'新密市',1496,'410183',3), +(1507,'新郑市',1496,'410184',3), +(1508,'登封市',1496,'410185',3), +(1509,'开封市',1495,'410200',2), +(1510,'龙亭区',1509,'410202',3), +(1511,'顺河回族区',1509,'410203',3), +(1512,'鼓楼区',1509,'410204',3), +(1513,'禹王台区',1509,'410205',3), +(1514,'祥符区',1509,'410212',3), +(1515,'杞县',1509,'410221',3), +(1516,'通许县',1509,'410222',3), +(1517,'尉氏县',1509,'410223',3), +(1518,'兰考县',1509,'410225',3), +(1519,'洛阳市',1495,'410300',2), +(1520,'老城区',1519,'410302',3), +(1521,'西工区',1519,'410303',3), +(1522,'瀍河回族区',1519,'410304',3), +(1523,'涧西区',1519,'410305',3), +(1524,'吉利区',1519,'410306',3), +(1525,'洛龙区',1519,'410311',3), +(1526,'孟津县',1519,'410322',3), +(1527,'新安县',1519,'410323',3), +(1528,'栾川县',1519,'410324',3), +(1529,'嵩县',1519,'410325',3), +(1530,'汝阳县',1519,'410326',3), +(1531,'宜阳县',1519,'410327',3), +(1532,'洛宁县',1519,'410328',3), +(1533,'伊川县',1519,'410329',3), +(1534,'偃师市',1519,'410381',3), +(1535,'平顶山市',1495,'410400',2), +(1536,'新华区',1535,'410402',3), +(1537,'卫东区',1535,'410403',3), +(1538,'石龙区',1535,'410404',3), +(1539,'湛河区',1535,'410411',3), +(1540,'宝丰县',1535,'410421',3), +(1541,'叶县',1535,'410422',3), +(1542,'鲁山县',1535,'410423',3), +(1543,'郏县',1535,'410425',3), +(1544,'舞钢市',1535,'410481',3), +(1545,'汝州市',1535,'410482',3), +(1546,'安阳市',1495,'410500',2), +(1547,'文峰区',1546,'410502',3), +(1548,'北关区',1546,'410503',3), +(1549,'殷都区',1546,'410505',3), +(1550,'龙安区',1546,'410506',3), +(1551,'安阳县',1546,'410522',3), +(1552,'汤阴县',1546,'410523',3), +(1553,'滑县',1546,'410526',3), +(1554,'内黄县',1546,'410527',3), +(1555,'林州市',1546,'410581',3), +(1556,'鹤壁市',1495,'410600',2), +(1557,'鹤山区',1556,'410602',3), +(1558,'山城区',1556,'410603',3), +(1559,'淇滨区',1556,'410611',3), +(1560,'浚县',1556,'410621',3), +(1561,'淇县',1556,'410622',3), +(1562,'新乡市',1495,'410700',2), +(1563,'红旗区',1562,'410702',3), +(1564,'卫滨区',1562,'410703',3), +(1565,'凤泉区',1562,'410704',3), +(1566,'牧野区',1562,'410711',3), +(1567,'新乡县',1562,'410721',3), +(1568,'获嘉县',1562,'410724',3), +(1569,'原阳县',1562,'410725',3), +(1570,'延津县',1562,'410726',3), +(1571,'封丘县',1562,'410727',3), +(1572,'卫辉市',1562,'410781',3), +(1573,'辉县市',1562,'410782',3), +(1574,'长垣市',1562,'410783',3), +(1575,'焦作市',1495,'410800',2), +(1576,'解放区',1575,'410802',3), +(1577,'中站区',1575,'410803',3), +(1578,'马村区',1575,'410804',3), +(1579,'山阳区',1575,'410811',3), +(1580,'修武县',1575,'410821',3), +(1581,'博爱县',1575,'410822',3), +(1582,'武陟县',1575,'410823',3), +(1583,'温县',1575,'410825',3), +(1584,'沁阳市',1575,'410882',3), +(1585,'孟州市',1575,'410883',3), +(1586,'濮阳市',1495,'410900',2), +(1587,'华龙区',1586,'410902',3), +(1588,'清丰县',1586,'410922',3), +(1589,'南乐县',1586,'410923',3), +(1590,'范县',1586,'410926',3), +(1591,'台前县',1586,'410927',3), +(1592,'濮阳县',1586,'410928',3), +(1593,'许昌市',1495,'411000',2), +(1594,'魏都区',1593,'411002',3), +(1595,'建安区',1593,'411003',3), +(1596,'鄢陵县',1593,'411024',3), +(1597,'襄城县',1593,'411025',3), +(1598,'禹州市',1593,'411081',3), +(1599,'长葛市',1593,'411082',3), +(1600,'漯河市',1495,'411100',2), +(1601,'源汇区',1600,'411102',3), +(1602,'郾城区',1600,'411103',3), +(1603,'召陵区',1600,'411104',3), +(1604,'舞阳县',1600,'411121',3), +(1605,'临颍县',1600,'411122',3), +(1606,'三门峡市',1495,'411200',2), +(1607,'湖滨区',1606,'411202',3), +(1608,'陕州区',1606,'411203',3), +(1609,'渑池县',1606,'411221',3), +(1610,'卢氏县',1606,'411224',3), +(1611,'义马市',1606,'411281',3), +(1612,'灵宝市',1606,'411282',3), +(1613,'南阳市',1495,'411300',2), +(1614,'宛城区',1613,'411302',3), +(1615,'卧龙区',1613,'411303',3), +(1616,'南召县',1613,'411321',3), +(1617,'方城县',1613,'411322',3), +(1618,'西峡县',1613,'411323',3), +(1619,'镇平县',1613,'411324',3), +(1620,'内乡县',1613,'411325',3), +(1621,'淅川县',1613,'411326',3), +(1622,'社旗县',1613,'411327',3), +(1623,'唐河县',1613,'411328',3), +(1624,'新野县',1613,'411329',3), +(1625,'桐柏县',1613,'411330',3), +(1626,'邓州市',1613,'411381',3), +(1627,'商丘市',1495,'411400',2), +(1628,'梁园区',1627,'411402',3), +(1629,'睢阳区',1627,'411403',3), +(1630,'民权县',1627,'411421',3), +(1631,'睢县',1627,'411422',3), +(1632,'宁陵县',1627,'411423',3), +(1633,'柘城县',1627,'411424',3), +(1634,'虞城县',1627,'411425',3), +(1635,'夏邑县',1627,'411426',3), +(1636,'永城市',1627,'411481',3), +(1637,'信阳市',1495,'411500',2), +(1638,'浉河区',1637,'411502',3), +(1639,'平桥区',1637,'411503',3), +(1640,'罗山县',1637,'411521',3), +(1641,'光山县',1637,'411522',3), +(1642,'新县',1637,'411523',3), +(1643,'商城县',1637,'411524',3), +(1644,'固始县',1637,'411525',3), +(1645,'潢川县',1637,'411526',3), +(1646,'淮滨县',1637,'411527',3), +(1647,'息县',1637,'411528',3), +(1648,'周口市',1495,'411600',2), +(1649,'川汇区',1648,'411602',3), +(1650,'淮阳区',1648,'411603',3), +(1651,'扶沟县',1648,'411621',3), +(1652,'西华县',1648,'411622',3), +(1653,'商水县',1648,'411623',3), +(1654,'沈丘县',1648,'411624',3), +(1655,'郸城县',1648,'411625',3), +(1656,'太康县',1648,'411627',3), +(1657,'鹿邑县',1648,'411628',3), +(1658,'项城市',1648,'411681',3), +(1659,'驻马店市',1495,'411700',2), +(1660,'驿城区',1659,'411702',3), +(1661,'西平县',1659,'411721',3), +(1662,'上蔡县',1659,'411722',3), +(1663,'平舆县',1659,'411723',3), +(1664,'正阳县',1659,'411724',3), +(1665,'确山县',1659,'411725',3), +(1666,'泌阳县',1659,'411726',3), +(1667,'汝南县',1659,'411727',3), +(1668,'遂平县',1659,'411728',3), +(1669,'新蔡县',1659,'411729',3), +(1670,'济源市',1495,'419001',3), +(1671,'湖北省',0,'420000',1), +(1672,'武汉市',1671,'420100',2), +(1673,'江岸区',1672,'420102',3), +(1674,'江汉区',1672,'420103',3), +(1675,'硚口区',1672,'420104',3), +(1676,'汉阳区',1672,'420105',3), +(1677,'武昌区',1672,'420106',3), +(1678,'青山区',1672,'420107',3), +(1679,'洪山区',1672,'420111',3), +(1680,'东西湖区',1672,'420112',3), +(1681,'汉南区',1672,'420113',3), +(1682,'蔡甸区',1672,'420114',3), +(1683,'江夏区',1672,'420115',3), +(1684,'黄陂区',1672,'420116',3), +(1685,'新洲区',1672,'420117',3), +(1686,'黄石市',1671,'420200',2), +(1687,'黄石港区',1686,'420202',3), +(1688,'西塞山区',1686,'420203',3), +(1689,'下陆区',1686,'420204',3), +(1690,'铁山区',1686,'420205',3), +(1691,'阳新县',1686,'420222',3), +(1692,'大冶市',1686,'420281',3), +(1693,'十堰市',1671,'420300',2), +(1694,'茅箭区',1693,'420302',3), +(1695,'张湾区',1693,'420303',3), +(1696,'郧阳区',1693,'420304',3), +(1697,'郧西县',1693,'420322',3), +(1698,'竹山县',1693,'420323',3), +(1699,'竹溪县',1693,'420324',3), +(1700,'房县',1693,'420325',3), +(1701,'丹江口市',1693,'420381',3), +(1702,'宜昌市',1671,'420500',2), +(1703,'西陵区',1702,'420502',3), +(1704,'伍家岗区',1702,'420503',3), +(1705,'点军区',1702,'420504',3), +(1706,'猇亭区',1702,'420505',3), +(1707,'夷陵区',1702,'420506',3), +(1708,'远安县',1702,'420525',3), +(1709,'兴山县',1702,'420526',3), +(1710,'秭归县',1702,'420527',3), +(1711,'长阳土家族自治县',1702,'420528',3), +(1712,'五峰土家族自治县',1702,'420529',3), +(1713,'宜都市',1702,'420581',3), +(1714,'当阳市',1702,'420582',3), +(1715,'枝江市',1702,'420583',3), +(1716,'襄阳市',1671,'420600',2), +(1717,'襄城区',1716,'420602',3), +(1718,'樊城区',1716,'420606',3), +(1719,'襄州区',1716,'420607',3), +(1720,'南漳县',1716,'420624',3), +(1721,'谷城县',1716,'420625',3), +(1722,'保康县',1716,'420626',3), +(1723,'老河口市',1716,'420682',3), +(1724,'枣阳市',1716,'420683',3), +(1725,'宜城市',1716,'420684',3), +(1726,'鄂州市',1671,'420700',2), +(1727,'梁子湖区',1726,'420702',3), +(1728,'华容区',1726,'420703',3), +(1729,'鄂城区',1726,'420704',3), +(1730,'荆门市',1671,'420800',2), +(1731,'东宝区',1730,'420802',3), +(1732,'掇刀区',1730,'420804',3), +(1733,'沙洋县',1730,'420822',3), +(1734,'钟祥市',1730,'420881',3), +(1735,'京山市',1730,'420882',3), +(1736,'孝感市',1671,'420900',2), +(1737,'孝南区',1736,'420902',3), +(1738,'孝昌县',1736,'420921',3), +(1739,'大悟县',1736,'420922',3), +(1740,'云梦县',1736,'420923',3), +(1741,'应城市',1736,'420981',3), +(1742,'安陆市',1736,'420982',3), +(1743,'汉川市',1736,'420984',3), +(1744,'荆州市',1671,'421000',2), +(1745,'沙市区',1744,'421002',3), +(1746,'荆州区',1744,'421003',3), +(1747,'公安县',1744,'421022',3), +(1748,'监利县',1744,'421023',3), +(1749,'江陵县',1744,'421024',3), +(1750,'石首市',1744,'421081',3), +(1751,'洪湖市',1744,'421083',3), +(1752,'松滋市',1744,'421087',3), +(1753,'黄冈市',1671,'421100',2), +(1754,'黄州区',1753,'421102',3), +(1755,'团风县',1753,'421121',3), +(1756,'红安县',1753,'421122',3), +(1757,'罗田县',1753,'421123',3), +(1758,'英山县',1753,'421124',3), +(1759,'浠水县',1753,'421125',3), +(1760,'蕲春县',1753,'421126',3), +(1761,'黄梅县',1753,'421127',3), +(1762,'麻城市',1753,'421181',3), +(1763,'武穴市',1753,'421182',3), +(1764,'咸宁市',1671,'421200',2), +(1765,'咸安区',1764,'421202',3), +(1766,'嘉鱼县',1764,'421221',3), +(1767,'通城县',1764,'421222',3), +(1768,'崇阳县',1764,'421223',3), +(1769,'通山县',1764,'421224',3), +(1770,'赤壁市',1764,'421281',3), +(1771,'随州市',1671,'421300',2), +(1772,'曾都区',1771,'421303',3), +(1773,'随县',1771,'421321',3), +(1774,'广水市',1771,'421381',3), +(1775,'恩施土家族苗族自治州',1671,'422800',2), +(1776,'恩施市',1775,'422801',3), +(1777,'利川市',1775,'422802',3), +(1778,'建始县',1775,'422822',3), +(1779,'巴东县',1775,'422823',3), +(1780,'宣恩县',1775,'422825',3), +(1781,'咸丰县',1775,'422826',3), +(1782,'来凤县',1775,'422827',3), +(1783,'鹤峰县',1775,'422828',3), +(1784,'仙桃市',1671,'429004',3), +(1785,'潜江市',1671,'429005',3), +(1786,'天门市',1671,'429006',3), +(1787,'神农架林区',1671,'429021',3), +(1788,'湖南省',0,'430000',1), +(1789,'长沙市',1788,'430100',2), +(1790,'芙蓉区',1789,'430102',3), +(1791,'天心区',1789,'430103',3), +(1792,'岳麓区',1789,'430104',3), +(1793,'开福区',1789,'430105',3), +(1794,'雨花区',1789,'430111',3), +(1795,'望城区',1789,'430112',3), +(1796,'长沙县',1789,'430121',3), +(1797,'浏阳市',1789,'430181',3), +(1798,'宁乡市',1789,'430182',3), +(1799,'株洲市',1788,'430200',2), +(1800,'荷塘区',1799,'430202',3), +(1801,'芦淞区',1799,'430203',3), +(1802,'石峰区',1799,'430204',3), +(1803,'天元区',1799,'430211',3), +(1804,'渌口区',1799,'430212',3), +(1805,'攸县',1799,'430223',3), +(1806,'茶陵县',1799,'430224',3), +(1807,'炎陵县',1799,'430225',3), +(1808,'醴陵市',1799,'430281',3), +(1809,'湘潭市',1788,'430300',2), +(1810,'雨湖区',1809,'430302',3), +(1811,'岳塘区',1809,'430304',3), +(1812,'湘潭县',1809,'430321',3), +(1813,'湘乡市',1809,'430381',3), +(1814,'韶山市',1809,'430382',3), +(1815,'衡阳市',1788,'430400',2), +(1816,'珠晖区',1815,'430405',3), +(1817,'雁峰区',1815,'430406',3), +(1818,'石鼓区',1815,'430407',3), +(1819,'蒸湘区',1815,'430408',3), +(1820,'南岳区',1815,'430412',3), +(1821,'衡阳县',1815,'430421',3), +(1822,'衡南县',1815,'430422',3), +(1823,'衡山县',1815,'430423',3), +(1824,'衡东县',1815,'430424',3), +(1825,'祁东县',1815,'430426',3), +(1826,'耒阳市',1815,'430481',3), +(1827,'常宁市',1815,'430482',3), +(1828,'邵阳市',1788,'430500',2), +(1829,'双清区',1828,'430502',3), +(1830,'大祥区',1828,'430503',3), +(1831,'北塔区',1828,'430511',3), +(1832,'新邵县',1828,'430522',3), +(1833,'邵阳县',1828,'430523',3), +(1834,'隆回县',1828,'430524',3), +(1835,'洞口县',1828,'430525',3), +(1836,'绥宁县',1828,'430527',3), +(1837,'新宁县',1828,'430528',3), +(1838,'城步苗族自治县',1828,'430529',3), +(1839,'武冈市',1828,'430581',3), +(1840,'邵东市',1828,'430582',3), +(1841,'岳阳市',1788,'430600',2), +(1842,'岳阳楼区',1841,'430602',3), +(1843,'云溪区',1841,'430603',3), +(1844,'君山区',1841,'430611',3), +(1845,'岳阳县',1841,'430621',3), +(1846,'华容县',1841,'430623',3), +(1847,'湘阴县',1841,'430624',3), +(1848,'平江县',1841,'430626',3), +(1849,'汨罗市',1841,'430681',3), +(1850,'临湘市',1841,'430682',3), +(1851,'常德市',1788,'430700',2), +(1852,'武陵区',1851,'430702',3), +(1853,'鼎城区',1851,'430703',3), +(1854,'安乡县',1851,'430721',3), +(1855,'汉寿县',1851,'430722',3), +(1856,'澧县',1851,'430723',3), +(1857,'临澧县',1851,'430724',3), +(1858,'桃源县',1851,'430725',3), +(1859,'石门县',1851,'430726',3), +(1860,'津市市',1851,'430781',3), +(1861,'张家界市',1788,'430800',2), +(1862,'永定区',1861,'430802',3), +(1863,'武陵源区',1861,'430811',3), +(1864,'慈利县',1861,'430821',3), +(1865,'桑植县',1861,'430822',3), +(1866,'益阳市',1788,'430900',2), +(1867,'资阳区',1866,'430902',3), +(1868,'赫山区',1866,'430903',3), +(1869,'南县',1866,'430921',3), +(1870,'桃江县',1866,'430922',3), +(1871,'安化县',1866,'430923',3), +(1872,'沅江市',1866,'430981',3), +(1873,'郴州市',1788,'431000',2), +(1874,'北湖区',1873,'431002',3), +(1875,'苏仙区',1873,'431003',3), +(1876,'桂阳县',1873,'431021',3), +(1877,'宜章县',1873,'431022',3), +(1878,'永兴县',1873,'431023',3), +(1879,'嘉禾县',1873,'431024',3), +(1880,'临武县',1873,'431025',3), +(1881,'汝城县',1873,'431026',3), +(1882,'桂东县',1873,'431027',3), +(1883,'安仁县',1873,'431028',3), +(1884,'资兴市',1873,'431081',3), +(1885,'永州市',1788,'431100',2), +(1886,'零陵区',1885,'431102',3), +(1887,'冷水滩区',1885,'431103',3), +(1888,'祁阳县',1885,'431121',3), +(1889,'东安县',1885,'431122',3), +(1890,'双牌县',1885,'431123',3), +(1891,'道县',1885,'431124',3), +(1892,'江永县',1885,'431125',3), +(1893,'宁远县',1885,'431126',3), +(1894,'蓝山县',1885,'431127',3), +(1895,'新田县',1885,'431128',3), +(1896,'江华瑶族自治县',1885,'431129',3), +(1897,'怀化市',1788,'431200',2), +(1898,'鹤城区',1897,'431202',3), +(1899,'中方县',1897,'431221',3), +(1900,'沅陵县',1897,'431222',3), +(1901,'辰溪县',1897,'431223',3), +(1902,'溆浦县',1897,'431224',3), +(1903,'会同县',1897,'431225',3), +(1904,'麻阳苗族自治县',1897,'431226',3), +(1905,'新晃侗族自治县',1897,'431227',3), +(1906,'芷江侗族自治县',1897,'431228',3), +(1907,'靖州苗族侗族自治县',1897,'431229',3), +(1908,'通道侗族自治县',1897,'431230',3), +(1909,'洪江市',1897,'431281',3), +(1910,'娄底市',1788,'431300',2), +(1911,'娄星区',1910,'431302',3), +(1912,'双峰县',1910,'431321',3), +(1913,'新化县',1910,'431322',3), +(1914,'冷水江市',1910,'431381',3), +(1915,'涟源市',1910,'431382',3), +(1916,'湘西土家族苗族自治州',1788,'433100',2), +(1917,'吉首市',1916,'433101',3), +(1918,'泸溪县',1916,'433122',3), +(1919,'凤凰县',1916,'433123',3), +(1920,'花垣县',1916,'433124',3), +(1921,'保靖县',1916,'433125',3), +(1922,'古丈县',1916,'433126',3), +(1923,'永顺县',1916,'433127',3), +(1924,'龙山县',1916,'433130',3), +(1925,'广东省',0,'440000',1), +(1926,'广州市',1925,'440100',2), +(1927,'荔湾区',1926,'440103',3), +(1928,'越秀区',1926,'440104',3), +(1929,'海珠区',1926,'440105',3), +(1930,'天河区',1926,'440106',3), +(1931,'白云区',1926,'440111',3), +(1932,'黄埔区',1926,'440112',3), +(1933,'番禺区',1926,'440113',3), +(1934,'花都区',1926,'440114',3), +(1935,'南沙区',1926,'440115',3), +(1936,'从化区',1926,'440117',3), +(1937,'增城区',1926,'440118',3), +(1938,'韶关市',1925,'440200',2), +(1939,'武江区',1938,'440203',3), +(1940,'浈江区',1938,'440204',3), +(1941,'曲江区',1938,'440205',3), +(1942,'始兴县',1938,'440222',3), +(1943,'仁化县',1938,'440224',3), +(1944,'翁源县',1938,'440229',3), +(1945,'乳源瑶族自治县',1938,'440232',3), +(1946,'新丰县',1938,'440233',3), +(1947,'乐昌市',1938,'440281',3), +(1948,'南雄市',1938,'440282',3), +(1949,'深圳市',1925,'440300',2), +(1950,'罗湖区',1949,'440303',3), +(1951,'福田区',1949,'440304',3), +(1952,'南山区',1949,'440305',3), +(1953,'宝安区',1949,'440306',3), +(1954,'龙岗区',1949,'440307',3), +(1955,'盐田区',1949,'440308',3), +(1956,'龙华区',1949,'440309',3), +(1957,'坪山区',1949,'440310',3), +(1958,'光明区',1949,'440311',3), +(1959,'珠海市',1925,'440400',2), +(1960,'香洲区',1959,'440402',3), +(1961,'斗门区',1959,'440403',3), +(1962,'金湾区',1959,'440404',3), +(1963,'汕头市',1925,'440500',2), +(1964,'龙湖区',1963,'440507',3), +(1965,'金平区',1963,'440511',3), +(1966,'濠江区',1963,'440512',3), +(1967,'潮阳区',1963,'440513',3), +(1968,'潮南区',1963,'440514',3), +(1969,'澄海区',1963,'440515',3), +(1970,'南澳县',1963,'440523',3), +(1971,'佛山市',1925,'440600',2), +(1972,'禅城区',1971,'440604',3), +(1973,'南海区',1971,'440605',3), +(1974,'顺德区',1971,'440606',3), +(1975,'三水区',1971,'440607',3), +(1976,'高明区',1971,'440608',3), +(1977,'江门市',1925,'440700',2), +(1978,'蓬江区',1977,'440703',3), +(1979,'江海区',1977,'440704',3), +(1980,'新会区',1977,'440705',3), +(1981,'台山市',1977,'440781',3), +(1982,'开平市',1977,'440783',3), +(1983,'鹤山市',1977,'440784',3), +(1984,'恩平市',1977,'440785',3), +(1985,'湛江市',1925,'440800',2), +(1986,'赤坎区',1985,'440802',3), +(1987,'霞山区',1985,'440803',3), +(1988,'坡头区',1985,'440804',3), +(1989,'麻章区',1985,'440811',3), +(1990,'遂溪县',1985,'440823',3), +(1991,'徐闻县',1985,'440825',3), +(1992,'廉江市',1985,'440881',3), +(1993,'雷州市',1985,'440882',3), +(1994,'吴川市',1985,'440883',3), +(1995,'茂名市',1925,'440900',2), +(1996,'茂南区',1995,'440902',3), +(1997,'电白区',1995,'440904',3), +(1998,'高州市',1995,'440981',3), +(1999,'化州市',1995,'440982',3), +(2000,'信宜市',1995,'440983',3), +(2001,'肇庆市',1925,'441200',2), +(2002,'端州区',2001,'441202',3), +(2003,'鼎湖区',2001,'441203',3), +(2004,'高要区',2001,'441204',3), +(2005,'广宁县',2001,'441223',3), +(2006,'怀集县',2001,'441224',3), +(2007,'封开县',2001,'441225',3), +(2008,'德庆县',2001,'441226',3), +(2009,'四会市',2001,'441284',3), +(2010,'惠州市',1925,'441300',2), +(2011,'惠城区',2010,'441302',3), +(2012,'惠阳区',2010,'441303',3), +(2013,'博罗县',2010,'441322',3), +(2014,'惠东县',2010,'441323',3), +(2015,'龙门县',2010,'441324',3), +(2016,'梅州市',1925,'441400',2), +(2017,'梅江区',2016,'441402',3), +(2018,'梅县区',2016,'441403',3), +(2019,'大埔县',2016,'441422',3), +(2020,'丰顺县',2016,'441423',3), +(2021,'五华县',2016,'441424',3), +(2022,'平远县',2016,'441426',3), +(2023,'蕉岭县',2016,'441427',3), +(2024,'兴宁市',2016,'441481',3), +(2025,'汕尾市',1925,'441500',2), +(2026,'城区',2025,'441502',3), +(2027,'海丰县',2025,'441521',3), +(2028,'陆河县',2025,'441523',3), +(2029,'陆丰市',2025,'441581',3), +(2030,'河源市',1925,'441600',2), +(2031,'源城区',2030,'441602',3), +(2032,'紫金县',2030,'441621',3), +(2033,'龙川县',2030,'441622',3), +(2034,'连平县',2030,'441623',3), +(2035,'和平县',2030,'441624',3), +(2036,'东源县',2030,'441625',3), +(2037,'阳江市',1925,'441700',2), +(2038,'江城区',2037,'441702',3), +(2039,'阳东区',2037,'441704',3), +(2040,'阳西县',2037,'441721',3), +(2041,'阳春市',2037,'441781',3), +(2042,'清远市',1925,'441800',2), +(2043,'清城区',2042,'441802',3), +(2044,'清新区',2042,'441803',3), +(2045,'佛冈县',2042,'441821',3), +(2046,'阳山县',2042,'441823',3), +(2047,'连山壮族瑶族自治县',2042,'441825',3), +(2048,'连南瑶族自治县',2042,'441826',3), +(2049,'英德市',2042,'441881',3), +(2050,'连州市',2042,'441882',3), +(2051,'东莞市',1925,'441900',2), +(2052,'中山市',1925,'442000',2), +(2053,'潮州市',1925,'445100',2), +(2054,'湘桥区',2053,'445102',3), +(2055,'潮安区',2053,'445103',3), +(2056,'饶平县',2053,'445122',3), +(2057,'揭阳市',1925,'445200',2), +(2058,'榕城区',2057,'445202',3), +(2059,'揭东区',2057,'445203',3), +(2060,'揭西县',2057,'445222',3), +(2061,'惠来县',2057,'445224',3), +(2062,'普宁市',2057,'445281',3), +(2063,'云浮市',1925,'445300',2), +(2064,'云城区',2063,'445302',3), +(2065,'云安区',2063,'445303',3), +(2066,'新兴县',2063,'445321',3), +(2067,'郁南县',2063,'445322',3), +(2068,'罗定市',2063,'445381',3), +(2069,'广西壮族自治区',0,'450000',1), +(2070,'南宁市',2069,'450100',2), +(2071,'兴宁区',2070,'450102',3), +(2072,'青秀区',2070,'450103',3), +(2073,'江南区',2070,'450105',3), +(2074,'西乡塘区',2070,'450107',3), +(2075,'良庆区',2070,'450108',3), +(2076,'邕宁区',2070,'450109',3), +(2077,'武鸣区',2070,'450110',3), +(2078,'隆安县',2070,'450123',3), +(2079,'马山县',2070,'450124',3), +(2080,'上林县',2070,'450125',3), +(2081,'宾阳县',2070,'450126',3), +(2082,'横县',2070,'450127',3), +(2083,'柳州市',2069,'450200',2), +(2084,'城中区',2083,'450202',3), +(2085,'鱼峰区',2083,'450203',3), +(2086,'柳南区',2083,'450204',3), +(2087,'柳北区',2083,'450205',3), +(2088,'柳江区',2083,'450206',3), +(2089,'柳城县',2083,'450222',3), +(2090,'鹿寨县',2083,'450223',3), +(2091,'融安县',2083,'450224',3), +(2092,'融水苗族自治县',2083,'450225',3), +(2093,'三江侗族自治县',2083,'450226',3), +(2094,'桂林市',2069,'450300',2), +(2095,'秀峰区',2094,'450302',3), +(2096,'叠彩区',2094,'450303',3), +(2097,'象山区',2094,'450304',3), +(2098,'七星区',2094,'450305',3), +(2099,'雁山区',2094,'450311',3), +(2100,'临桂区',2094,'450312',3), +(2101,'阳朔县',2094,'450321',3), +(2102,'灵川县',2094,'450323',3), +(2103,'全州县',2094,'450324',3), +(2104,'兴安县',2094,'450325',3), +(2105,'永福县',2094,'450326',3), +(2106,'灌阳县',2094,'450327',3), +(2107,'龙胜各族自治县',2094,'450328',3), +(2108,'资源县',2094,'450329',3), +(2109,'平乐县',2094,'450330',3), +(2110,'荔浦市',2094,'450381',3), +(2111,'恭城瑶族自治县',2094,'450332',3), +(2112,'梧州市',2069,'450400',2), +(2113,'万秀区',2112,'450403',3), +(2114,'长洲区',2112,'450405',3), +(2115,'龙圩区',2112,'450406',3), +(2116,'苍梧县',2112,'450421',3), +(2117,'藤县',2112,'450422',3), +(2118,'蒙山县',2112,'450423',3), +(2119,'岑溪市',2112,'450481',3), +(2120,'北海市',2069,'450500',2), +(2121,'海城区',2120,'450502',3), +(2122,'银海区',2120,'450503',3), +(2123,'铁山港区',2120,'450512',3), +(2124,'合浦县',2120,'450521',3), +(2125,'防城港市',2069,'450600',2), +(2126,'港口区',2125,'450602',3), +(2127,'防城区',2125,'450603',3), +(2128,'上思县',2125,'450621',3), +(2129,'东兴市',2125,'450681',3), +(2130,'钦州市',2069,'450700',2), +(2131,'钦南区',2130,'450702',3), +(2132,'钦北区',2130,'450703',3), +(2133,'灵山县',2130,'450721',3), +(2134,'浦北县',2130,'450722',3), +(2135,'贵港市',2069,'450800',2), +(2136,'港北区',2135,'450802',3), +(2137,'港南区',2135,'450803',3), +(2138,'覃塘区',2135,'450804',3), +(2139,'平南县',2135,'450821',3), +(2140,'桂平市',2135,'450881',3), +(2141,'玉林市',2069,'450900',2), +(2142,'玉州区',2141,'450902',3), +(2143,'福绵区',2141,'450903',3), +(2144,'容县',2141,'450921',3), +(2145,'陆川县',2141,'450922',3), +(2146,'博白县',2141,'450923',3), +(2147,'兴业县',2141,'450924',3), +(2148,'北流市',2141,'450981',3), +(2149,'百色市',2069,'451000',2), +(2150,'右江区',2149,'451002',3), +(2151,'田阳区',2149,'451003',3), +(2152,'田东县',2149,'451022',3), +(2153,'德保县',2149,'451024',3), +(2154,'那坡县',2149,'451026',3), +(2155,'凌云县',2149,'451027',3), +(2156,'乐业县',2149,'451028',3), +(2157,'田林县',2149,'451029',3), +(2158,'西林县',2149,'451030',3), +(2159,'隆林各族自治县',2149,'451031',3), +(2160,'靖西市',2149,'451081',3), +(2161,'平果市',2149,'451082',3), +(2162,'贺州市',2069,'451100',2), +(2163,'八步区',2162,'451102',3), +(2164,'平桂区',2162,'451103',3), +(2165,'昭平县',2162,'451121',3), +(2166,'钟山县',2162,'451122',3), +(2167,'富川瑶族自治县',2162,'451123',3), +(2168,'河池市',2069,'451200',2), +(2169,'金城江区',2168,'451202',3), +(2170,'宜州区',2168,'451203',3), +(2171,'南丹县',2168,'451221',3), +(2172,'天峨县',2168,'451222',3), +(2173,'凤山县',2168,'451223',3), +(2174,'东兰县',2168,'451224',3), +(2175,'罗城仫佬族自治县',2168,'451225',3), +(2176,'环江毛南族自治县',2168,'451226',3), +(2177,'巴马瑶族自治县',2168,'451227',3), +(2178,'都安瑶族自治县',2168,'451228',3), +(2179,'大化瑶族自治县',2168,'451229',3), +(2180,'来宾市',2069,'451300',2), +(2181,'兴宾区',2180,'451302',3), +(2182,'忻城县',2180,'451321',3), +(2183,'象州县',2180,'451322',3), +(2184,'武宣县',2180,'451323',3), +(2185,'金秀瑶族自治县',2180,'451324',3), +(2186,'合山市',2180,'451381',3), +(2187,'崇左市',2069,'451400',2), +(2188,'江州区',2187,'451402',3), +(2189,'扶绥县',2187,'451421',3), +(2190,'宁明县',2187,'451422',3), +(2191,'龙州县',2187,'451423',3), +(2192,'大新县',2187,'451424',3), +(2193,'天等县',2187,'451425',3), +(2194,'凭祥市',2187,'451481',3), +(2195,'海南省',0,'460000',1), +(2196,'海口市',2195,'460100',2), +(2197,'秀英区',2196,'460105',3), +(2198,'龙华区',2196,'460106',3), +(2199,'琼山区',2196,'460107',3), +(2200,'美兰区',2196,'460108',3), +(2201,'三亚市',2195,'460200',2), +(2202,'海棠区',2201,'460202',3), +(2203,'吉阳区',2201,'460203',3), +(2204,'天涯区',2201,'460204',3), +(2205,'崖州区',2201,'460205',3), +(2206,'三沙市',2195,'460300',2), +(2207,'儋州市',2195,'460400',2), +(2208,'五指山市',2195,'469001',3), +(2209,'琼海市',2195,'469002',3), +(2210,'文昌市',2195,'469005',3), +(2211,'万宁市',2195,'469006',3), +(2212,'东方市',2195,'469007',3), +(2213,'定安县',2195,'469021',3), +(2214,'屯昌县',2195,'469022',3), +(2215,'澄迈县',2195,'469023',3), +(2216,'临高县',2195,'469024',3), +(2217,'白沙黎族自治县',2195,'469025',3), +(2218,'昌江黎族自治县',2195,'469026',3), +(2219,'乐东黎族自治县',2195,'469027',3), +(2220,'陵水黎族自治县',2195,'469028',3), +(2221,'保亭黎族苗族自治县',2195,'469029',3), +(2222,'琼中黎族苗族自治县',2195,'469030',3), +(2223,'重庆',0,'500000',1), +(2224,'重庆市',2223,'500010',2), +(2225,'万州区',2224,'500101',3), +(2226,'涪陵区',2224,'500102',3), +(2227,'渝中区',2224,'500103',3), +(2228,'大渡口区',2224,'500104',3), +(2229,'江北区',2224,'500105',3), +(2230,'沙坪坝区',2224,'500106',3), +(2231,'九龙坡区',2224,'500107',3), +(2232,'南岸区',2224,'500108',3), +(2233,'北碚区',2224,'500109',3), +(2234,'綦江区',2224,'500110',3), +(2235,'大足区',2224,'500111',3), +(2236,'渝北区',2224,'500112',3), +(2237,'巴南区',2224,'500113',3), +(2238,'黔江区',2224,'500114',3), +(2239,'长寿区',2224,'500115',3), +(2240,'江津区',2224,'500116',3), +(2241,'合川区',2224,'500117',3), +(2242,'永川区',2224,'500118',3), +(2243,'南川区',2224,'500119',3), +(2244,'璧山区',2224,'500120',3), +(2245,'铜梁区',2224,'500151',3), +(2246,'潼南区',2224,'500152',3), +(2247,'荣昌区',2224,'500153',3), +(2248,'开州区',2224,'500154',3), +(2249,'梁平区',2224,'500155',3), +(2250,'武隆区',2224,'500156',3), +(2251,'城口县',2224,'500229',3), +(2252,'丰都县',2224,'500230',3), +(2253,'垫江县',2224,'500231',3), +(2254,'忠县',2224,'500233',3), +(2255,'云阳县',2224,'500235',3), +(2256,'奉节县',2224,'500236',3), +(2257,'巫山县',2224,'500237',3), +(2258,'巫溪县',2224,'500238',3), +(2259,'石柱土家族自治县',2224,'500240',3), +(2260,'秀山土家族苗族自治县',2224,'500241',3), +(2261,'酉阳土家族苗族自治县',2224,'500242',3), +(2262,'彭水苗族土家族自治县',2224,'500243',3), +(2263,'四川省',0,'510000',1), +(2264,'成都市',2263,'510100',2), +(2265,'锦江区',2264,'510104',3), +(2266,'青羊区',2264,'510105',3), +(2267,'金牛区',2264,'510106',3), +(2268,'武侯区',2264,'510107',3), +(2269,'成华区',2264,'510108',3), +(2270,'龙泉驿区',2264,'510112',3), +(2271,'青白江区',2264,'510113',3), +(2272,'新都区',2264,'510114',3), +(2273,'温江区',2264,'510115',3), +(2274,'双流区',2264,'510116',3), +(2275,'郫都区',2264,'510117',3), +(2276,'金堂县',2264,'510121',3), +(2277,'大邑县',2264,'510129',3), +(2278,'蒲江县',2264,'510131',3), +(2279,'新津县',2264,'510132',3), +(2280,'都江堰市',2264,'510181',3), +(2281,'彭州市',2264,'510182',3), +(2282,'邛崃市',2264,'510183',3), +(2283,'崇州市',2264,'510184',3), +(2284,'简阳市',2264,'510185',3), +(2285,'自贡市',2263,'510300',2), +(2286,'自流井区',2285,'510302',3), +(2287,'贡井区',2285,'510303',3), +(2288,'大安区',2285,'510304',3), +(2289,'沿滩区',2285,'510311',3), +(2290,'荣县',2285,'510321',3), +(2291,'富顺县',2285,'510322',3), +(2292,'攀枝花市',2263,'510400',2), +(2293,'东区',2292,'510402',3), +(2294,'西区',2292,'510403',3), +(2295,'仁和区',2292,'510411',3), +(2296,'米易县',2292,'510421',3), +(2297,'盐边县',2292,'510422',3), +(2298,'泸州市',2263,'510500',2), +(2299,'江阳区',2298,'510502',3), +(2300,'纳溪区',2298,'510503',3), +(2301,'龙马潭区',2298,'510504',3), +(2302,'泸县',2298,'510521',3), +(2303,'合江县',2298,'510522',3), +(2304,'叙永县',2298,'510524',3), +(2305,'古蔺县',2298,'510525',3), +(2306,'德阳市',2263,'510600',2), +(2307,'旌阳区',2306,'510603',3), +(2308,'罗江区',2306,'510604',3), +(2309,'中江县',2306,'510623',3), +(2310,'广汉市',2306,'510681',3), +(2311,'什邡市',2306,'510682',3), +(2312,'绵竹市',2306,'510683',3), +(2313,'绵阳市',2263,'510700',2), +(2314,'涪城区',2313,'510703',3), +(2315,'游仙区',2313,'510704',3), +(2316,'安州区',2313,'510705',3), +(2317,'三台县',2313,'510722',3), +(2318,'盐亭县',2313,'510723',3), +(2319,'梓潼县',2313,'510725',3), +(2320,'北川羌族自治县',2313,'510726',3), +(2321,'平武县',2313,'510727',3), +(2322,'江油市',2313,'510781',3), +(2323,'广元市',2263,'510800',2), +(2324,'利州区',2323,'510802',3), +(2325,'昭化区',2323,'510811',3), +(2326,'朝天区',2323,'510812',3), +(2327,'旺苍县',2323,'510821',3), +(2328,'青川县',2323,'510822',3), +(2329,'剑阁县',2323,'510823',3), +(2330,'苍溪县',2323,'510824',3), +(2331,'遂宁市',2263,'510900',2), +(2332,'船山区',2331,'510903',3), +(2333,'安居区',2331,'510904',3), +(2334,'蓬溪县',2331,'510921',3), +(2335,'大英县',2331,'510923',3), +(2336,'射洪市',2331,'510981',3), +(2337,'内江市',2263,'511000',2), +(2338,'市中区',2337,'511002',3), +(2339,'东兴区',2337,'511011',3), +(2340,'威远县',2337,'511024',3), +(2341,'资中县',2337,'511025',3), +(2342,'隆昌市',2337,'511083',3), +(2343,'乐山市',2263,'511100',2), +(2344,'市中区',2343,'511102',3), +(2345,'沙湾区',2343,'511111',3), +(2346,'五通桥区',2343,'511112',3), +(2347,'金口河区',2343,'511113',3), +(2348,'犍为县',2343,'511123',3), +(2349,'井研县',2343,'511124',3), +(2350,'夹江县',2343,'511126',3), +(2351,'沐川县',2343,'511129',3), +(2352,'峨边彝族自治县',2343,'511132',3), +(2353,'马边彝族自治县',2343,'511133',3), +(2354,'峨眉山市',2343,'511181',3), +(2355,'南充市',2263,'511300',2), +(2356,'顺庆区',2355,'511302',3), +(2357,'高坪区',2355,'511303',3), +(2358,'嘉陵区',2355,'511304',3), +(2359,'南部县',2355,'511321',3), +(2360,'营山县',2355,'511322',3), +(2361,'蓬安县',2355,'511323',3), +(2362,'仪陇县',2355,'511324',3), +(2363,'西充县',2355,'511325',3), +(2364,'阆中市',2355,'511381',3), +(2365,'眉山市',2263,'511400',2), +(2366,'东坡区',2365,'511402',3), +(2367,'彭山区',2365,'511403',3), +(2368,'仁寿县',2365,'511421',3), +(2369,'洪雅县',2365,'511423',3), +(2370,'丹棱县',2365,'511424',3), +(2371,'青神县',2365,'511425',3), +(2372,'宜宾市',2263,'511500',2), +(2373,'翠屏区',2372,'511502',3), +(2374,'南溪区',2372,'511503',3), +(2375,'叙州区',2372,'511504',3), +(2376,'江安县',2372,'511523',3), +(2377,'长宁县',2372,'511524',3), +(2378,'高县',2372,'511525',3), +(2379,'珙县',2372,'511526',3), +(2380,'筠连县',2372,'511527',3), +(2381,'兴文县',2372,'511528',3), +(2382,'屏山县',2372,'511529',3), +(2383,'广安市',2263,'511600',2), +(2384,'广安区',2383,'511602',3), +(2385,'前锋区',2383,'511603',3), +(2386,'岳池县',2383,'511621',3), +(2387,'武胜县',2383,'511622',3), +(2388,'邻水县',2383,'511623',3), +(2389,'华蓥市',2383,'511681',3), +(2390,'达州市',2263,'511700',2), +(2391,'通川区',2390,'511702',3), +(2392,'达川区',2390,'511703',3), +(2393,'宣汉县',2390,'511722',3), +(2394,'开江县',2390,'511723',3), +(2395,'大竹县',2390,'511724',3), +(2396,'渠县',2390,'511725',3), +(2397,'万源市',2390,'511781',3), +(2398,'雅安市',2263,'511800',2), +(2399,'雨城区',2398,'511802',3), +(2400,'名山区',2398,'511803',3), +(2401,'荥经县',2398,'511822',3), +(2402,'汉源县',2398,'511823',3), +(2403,'石棉县',2398,'511824',3), +(2404,'天全县',2398,'511825',3), +(2405,'芦山县',2398,'511826',3), +(2406,'宝兴县',2398,'511827',3), +(2407,'巴中市',2263,'511900',2), +(2408,'巴州区',2407,'511902',3), +(2409,'恩阳区',2407,'511903',3), +(2410,'通江县',2407,'511921',3), +(2411,'南江县',2407,'511922',3), +(2412,'平昌县',2407,'511923',3), +(2413,'资阳市',2263,'512000',2), +(2414,'雁江区',2413,'512002',3), +(2415,'安岳县',2413,'512021',3), +(2416,'乐至县',2413,'512022',3), +(2417,'阿坝藏族羌族自治州',2263,'513200',2), +(2418,'马尔康市',2417,'513201',3), +(2419,'汶川县',2417,'513221',3), +(2420,'理县',2417,'513222',3), +(2421,'茂县',2417,'513223',3), +(2422,'松潘县',2417,'513224',3), +(2423,'九寨沟县',2417,'513225',3), +(2424,'金川县',2417,'513226',3), +(2425,'小金县',2417,'513227',3), +(2426,'黑水县',2417,'513228',3), +(2427,'壤塘县',2417,'513230',3), +(2428,'阿坝县',2417,'513231',3), +(2429,'若尔盖县',2417,'513232',3), +(2430,'红原县',2417,'513233',3), +(2431,'甘孜藏族自治州',2263,'513300',2), +(2432,'康定市',2431,'513301',3), +(2433,'泸定县',2431,'513322',3), +(2434,'丹巴县',2431,'513323',3), +(2435,'九龙县',2431,'513324',3), +(2436,'雅江县',2431,'513325',3), +(2437,'道孚县',2431,'513326',3), +(2438,'炉霍县',2431,'513327',3), +(2439,'甘孜县',2431,'513328',3), +(2440,'新龙县',2431,'513329',3), +(2441,'德格县',2431,'513330',3), +(2442,'白玉县',2431,'513331',3), +(2443,'石渠县',2431,'513332',3), +(2444,'色达县',2431,'513333',3), +(2445,'理塘县',2431,'513334',3), +(2446,'巴塘县',2431,'513335',3), +(2447,'乡城县',2431,'513336',3), +(2448,'稻城县',2431,'513337',3), +(2449,'得荣县',2431,'513338',3), +(2450,'凉山彝族自治州',2263,'513400',2), +(2451,'西昌市',2450,'513401',3), +(2452,'木里藏族自治县',2450,'513422',3), +(2453,'盐源县',2450,'513423',3), +(2454,'德昌县',2450,'513424',3), +(2455,'会理县',2450,'513425',3), +(2456,'会东县',2450,'513426',3), +(2457,'宁南县',2450,'513427',3), +(2458,'普格县',2450,'513428',3), +(2459,'布拖县',2450,'513429',3), +(2460,'金阳县',2450,'513430',3), +(2461,'昭觉县',2450,'513431',3), +(2462,'喜德县',2450,'513432',3), +(2463,'冕宁县',2450,'513433',3), +(2464,'越西县',2450,'513434',3), +(2465,'甘洛县',2450,'513435',3), +(2466,'美姑县',2450,'513436',3), +(2467,'雷波县',2450,'513437',3), +(2468,'贵州省',0,'520000',1), +(2469,'贵阳市',2468,'520100',2), +(2470,'南明区',2469,'520102',3), +(2471,'云岩区',2469,'520103',3), +(2472,'花溪区',2469,'520111',3), +(2473,'乌当区',2469,'520112',3), +(2474,'白云区',2469,'520113',3), +(2475,'观山湖区',2469,'520115',3), +(2476,'开阳县',2469,'520121',3), +(2477,'息烽县',2469,'520122',3), +(2478,'修文县',2469,'520123',3), +(2479,'清镇市',2469,'520181',3), +(2480,'六盘水市',2468,'520200',2), +(2481,'钟山区',2480,'520201',3), +(2482,'六枝特区',2480,'520203',3), +(2483,'水城县',2480,'520221',3), +(2484,'盘州市',2480,'520281',3), +(2485,'遵义市',2468,'520300',2), +(2486,'红花岗区',2485,'520302',3), +(2487,'汇川区',2485,'520303',3), +(2488,'播州区',2485,'520304',3), +(2489,'桐梓县',2485,'520322',3), +(2490,'绥阳县',2485,'520323',3), +(2491,'正安县',2485,'520324',3), +(2492,'道真仡佬族苗族自治县',2485,'520325',3), +(2493,'务川仡佬族苗族自治县',2485,'520326',3), +(2494,'凤冈县',2485,'520327',3), +(2495,'湄潭县',2485,'520328',3), +(2496,'余庆县',2485,'520329',3), +(2497,'习水县',2485,'520330',3), +(2498,'赤水市',2485,'520381',3), +(2499,'仁怀市',2485,'520382',3), +(2500,'安顺市',2468,'520400',2), +(2501,'西秀区',2500,'520402',3), +(2502,'平坝区',2500,'520403',3), +(2503,'普定县',2500,'520422',3), +(2504,'镇宁布依族苗族自治县',2500,'520423',3), +(2505,'关岭布依族苗族自治县',2500,'520424',3), +(2506,'紫云苗族布依族自治县',2500,'520425',3), +(2507,'毕节市',2468,'520500',2), +(2508,'七星关区',2507,'520502',3), +(2509,'大方县',2507,'520521',3), +(2510,'黔西县',2507,'520522',3), +(2511,'金沙县',2507,'520523',3), +(2512,'织金县',2507,'520524',3), +(2513,'纳雍县',2507,'520525',3), +(2514,'威宁彝族回族苗族自治县',2507,'520526',3), +(2515,'赫章县',2507,'520527',3), +(2516,'铜仁市',2468,'520600',2), +(2517,'碧江区',2516,'520602',3), +(2518,'万山区',2516,'520603',3), +(2519,'江口县',2516,'520621',3), +(2520,'玉屏侗族自治县',2516,'520622',3), +(2521,'石阡县',2516,'520623',3), +(2522,'思南县',2516,'520624',3), +(2523,'印江土家族苗族自治县',2516,'520625',3), +(2524,'德江县',2516,'520626',3), +(2525,'沿河土家族自治县',2516,'520627',3), +(2526,'松桃苗族自治县',2516,'520628',3), +(2527,'黔西南布依族苗族自治州',2468,'522300',2), +(2528,'兴义市',2527,'522301',3), +(2529,'兴仁市',2527,'522302',3), +(2530,'普安县',2527,'522323',3), +(2531,'晴隆县',2527,'522324',3), +(2532,'贞丰县',2527,'522325',3), +(2533,'望谟县',2527,'522326',3), +(2534,'册亨县',2527,'522327',3), +(2535,'安龙县',2527,'522328',3), +(2536,'黔东南苗族侗族自治州',2468,'522600',2), +(2537,'凯里市',2536,'522601',3), +(2538,'黄平县',2536,'522622',3), +(2539,'施秉县',2536,'522623',3), +(2540,'三穗县',2536,'522624',3), +(2541,'镇远县',2536,'522625',3), +(2542,'岑巩县',2536,'522626',3), +(2543,'天柱县',2536,'522627',3), +(2544,'锦屏县',2536,'522628',3), +(2545,'剑河县',2536,'522629',3), +(2546,'台江县',2536,'522630',3), +(2547,'黎平县',2536,'522631',3), +(2548,'榕江县',2536,'522632',3), +(2549,'从江县',2536,'522633',3), +(2550,'雷山县',2536,'522634',3), +(2551,'麻江县',2536,'522635',3), +(2552,'丹寨县',2536,'522636',3), +(2553,'黔南布依族苗族自治州',2468,'522700',2), +(2554,'都匀市',2553,'522701',3), +(2555,'福泉市',2553,'522702',3), +(2556,'荔波县',2553,'522722',3), +(2557,'贵定县',2553,'522723',3), +(2558,'瓮安县',2553,'522725',3), +(2559,'独山县',2553,'522726',3), +(2560,'平塘县',2553,'522727',3), +(2561,'罗甸县',2553,'522728',3), +(2562,'长顺县',2553,'522729',3), +(2563,'龙里县',2553,'522730',3), +(2564,'惠水县',2553,'522731',3), +(2565,'三都水族自治县',2553,'522732',3), +(2566,'云南省',0,'530000',1), +(2567,'昆明市',2566,'530100',2), +(2568,'五华区',2567,'530102',3), +(2569,'盘龙区',2567,'530103',3), +(2570,'官渡区',2567,'530111',3), +(2571,'西山区',2567,'530112',3), +(2572,'东川区',2567,'530113',3), +(2573,'呈贡区',2567,'530114',3), +(2574,'晋宁区',2567,'530115',3), +(2575,'富民县',2567,'530124',3), +(2576,'宜良县',2567,'530125',3), +(2577,'石林彝族自治县',2567,'530126',3), +(2578,'嵩明县',2567,'530127',3), +(2579,'禄劝彝族苗族自治县',2567,'530128',3), +(2580,'寻甸回族彝族自治县',2567,'530129',3), +(2581,'安宁市',2567,'530181',3), +(2582,'曲靖市',2566,'530300',2), +(2583,'麒麟区',2582,'530302',3), +(2584,'沾益区',2582,'530303',3), +(2585,'马龙区',2582,'530304',3), +(2586,'陆良县',2582,'530322',3), +(2587,'师宗县',2582,'530323',3), +(2588,'罗平县',2582,'530324',3), +(2589,'富源县',2582,'530325',3), +(2590,'会泽县',2582,'530326',3), +(2591,'宣威市',2582,'530381',3), +(2592,'玉溪市',2566,'530400',2), +(2593,'红塔区',2592,'530402',3), +(2594,'江川区',2592,'530403',3), +(2595,'通海县',2592,'530423',3), +(2596,'华宁县',2592,'530424',3), +(2597,'易门县',2592,'530425',3), +(2598,'峨山彝族自治县',2592,'530426',3), +(2599,'新平彝族傣族自治县',2592,'530427',3), +(2600,'元江哈尼族彝族傣族自治县',2592,'530428',3), +(2601,'澄江市',2592,'530481',3), +(2602,'保山市',2566,'530500',2), +(2603,'隆阳区',2602,'530502',3), +(2604,'施甸县',2602,'530521',3), +(2605,'龙陵县',2602,'530523',3), +(2606,'昌宁县',2602,'530524',3), +(2607,'腾冲市',2602,'530581',3), +(2608,'昭通市',2566,'530600',2), +(2609,'昭阳区',2608,'530602',3), +(2610,'鲁甸县',2608,'530621',3), +(2611,'巧家县',2608,'530622',3), +(2612,'盐津县',2608,'530623',3), +(2613,'大关县',2608,'530624',3), +(2614,'永善县',2608,'530625',3), +(2615,'绥江县',2608,'530626',3), +(2616,'镇雄县',2608,'530627',3), +(2617,'彝良县',2608,'530628',3), +(2618,'威信县',2608,'530629',3), +(2619,'水富市',2608,'530681',3), +(2620,'丽江市',2566,'530700',2), +(2621,'古城区',2620,'530702',3), +(2622,'玉龙纳西族自治县',2620,'530721',3), +(2623,'永胜县',2620,'530722',3), +(2624,'华坪县',2620,'530723',3), +(2625,'宁蒗彝族自治县',2620,'530724',3), +(2626,'普洱市',2566,'530800',2), +(2627,'思茅区',2626,'530802',3), +(2628,'宁洱哈尼族彝族自治县',2626,'530821',3), +(2629,'墨江哈尼族自治县',2626,'530822',3), +(2630,'景东彝族自治县',2626,'530823',3), +(2631,'景谷傣族彝族自治县',2626,'530824',3), +(2632,'镇沅彝族哈尼族拉祜族自治县',2626,'530825',3), +(2633,'江城哈尼族彝族自治县',2626,'530826',3), +(2634,'孟连傣族拉祜族佤族自治县',2626,'530827',3), +(2635,'澜沧拉祜族自治县',2626,'530828',3), +(2636,'西盟佤族自治县',2626,'530829',3), +(2637,'临沧市',2566,'530900',2), +(2638,'临翔区',2637,'530902',3), +(2639,'凤庆县',2637,'530921',3), +(2640,'云县',2637,'530922',3), +(2641,'永德县',2637,'530923',3), +(2642,'镇康县',2637,'530924',3), +(2643,'双江拉祜族佤族布朗族傣族自治县',2637,'530925',3), +(2644,'耿马傣族佤族自治县',2637,'530926',3), +(2645,'沧源佤族自治县',2637,'530927',3), +(2646,'楚雄彝族自治州',2566,'532300',2), +(2647,'楚雄市',2646,'532301',3), +(2648,'双柏县',2646,'532322',3), +(2649,'牟定县',2646,'532323',3), +(2650,'南华县',2646,'532324',3), +(2651,'姚安县',2646,'532325',3), +(2652,'大姚县',2646,'532326',3), +(2653,'永仁县',2646,'532327',3), +(2654,'元谋县',2646,'532328',3), +(2655,'武定县',2646,'532329',3), +(2656,'禄丰县',2646,'532331',3), +(2657,'红河哈尼族彝族自治州',2566,'532500',2), +(2658,'个旧市',2657,'532501',3), +(2659,'开远市',2657,'532502',3), +(2660,'蒙自市',2657,'532503',3), +(2661,'弥勒市',2657,'532504',3), +(2662,'屏边苗族自治县',2657,'532523',3), +(2663,'建水县',2657,'532524',3), +(2664,'石屏县',2657,'532525',3), +(2665,'泸西县',2657,'532527',3), +(2666,'元阳县',2657,'532528',3), +(2667,'红河县',2657,'532529',3), +(2668,'金平苗族瑶族傣族自治县',2657,'532530',3), +(2669,'绿春县',2657,'532531',3), +(2670,'河口瑶族自治县',2657,'532532',3), +(2671,'文山壮族苗族自治州',2566,'532600',2), +(2672,'文山市',2671,'532601',3), +(2673,'砚山县',2671,'532622',3), +(2674,'西畴县',2671,'532623',3), +(2675,'麻栗坡县',2671,'532624',3), +(2676,'马关县',2671,'532625',3), +(2677,'丘北县',2671,'532626',3), +(2678,'广南县',2671,'532627',3), +(2679,'富宁县',2671,'532628',3), +(2680,'西双版纳傣族自治州',2566,'532800',2), +(2681,'景洪市',2680,'532801',3), +(2682,'勐海县',2680,'532822',3), +(2683,'勐腊县',2680,'532823',3), +(2684,'大理白族自治州',2566,'532900',2), +(2685,'大理市',2684,'532901',3), +(2686,'漾濞彝族自治县',2684,'532922',3), +(2687,'祥云县',2684,'532923',3), +(2688,'宾川县',2684,'532924',3), +(2689,'弥渡县',2684,'532925',3), +(2690,'南涧彝族自治县',2684,'532926',3), +(2691,'巍山彝族回族自治县',2684,'532927',3), +(2692,'永平县',2684,'532928',3), +(2693,'云龙县',2684,'532929',3), +(2694,'洱源县',2684,'532930',3), +(2695,'剑川县',2684,'532931',3), +(2696,'鹤庆县',2684,'532932',3), +(2697,'德宏傣族景颇族自治州',2566,'533100',2), +(2698,'瑞丽市',2697,'533102',3), +(2699,'芒市',2697,'533103',3), +(2700,'梁河县',2697,'533122',3), +(2701,'盈江县',2697,'533123',3), +(2702,'陇川县',2697,'533124',3), +(2703,'怒江傈僳族自治州',2566,'533300',2), +(2704,'泸水市',2703,'533301',3), +(2705,'福贡县',2703,'533323',3), +(2706,'贡山独龙族怒族自治县',2703,'533324',3), +(2707,'兰坪白族普米族自治县',2703,'533325',3), +(2708,'迪庆藏族自治州',2566,'533400',2), +(2709,'香格里拉市',2708,'533401',3), +(2710,'德钦县',2708,'533422',3), +(2711,'维西傈僳族自治县',2708,'533423',3), +(2712,'西藏自治区',0,'540000',1), +(2713,'拉萨市',2712,'540100',2), +(2714,'城关区',2713,'540102',3), +(2715,'堆龙德庆区',2713,'540103',3), +(2716,'达孜区',2713,'540104',3), +(2717,'林周县',2713,'540121',3), +(2718,'当雄县',2713,'540122',3), +(2719,'尼木县',2713,'540123',3), +(2720,'曲水县',2713,'540124',3), +(2721,'墨竹工卡县',2713,'540127',3), +(2722,'日喀则市',2712,'540200',2), +(2723,'桑珠孜区',2722,'540202',3), +(2724,'南木林县',2722,'540221',3), +(2725,'江孜县',2722,'540222',3), +(2726,'定日县',2722,'540223',3), +(2727,'萨迦县',2722,'540224',3), +(2728,'拉孜县',2722,'540225',3), +(2729,'昂仁县',2722,'540226',3), +(2730,'谢通门县',2722,'540227',3), +(2731,'白朗县',2722,'540228',3), +(2732,'仁布县',2722,'540229',3), +(2733,'康马县',2722,'540230',3), +(2734,'定结县',2722,'540231',3), +(2735,'仲巴县',2722,'540232',3), +(2736,'亚东县',2722,'540233',3), +(2737,'吉隆县',2722,'540234',3), +(2738,'聂拉木县',2722,'540235',3), +(2739,'萨嘎县',2722,'540236',3), +(2740,'岗巴县',2722,'540237',3), +(2741,'昌都市',2712,'540300',2), +(2742,'卡若区',2741,'540302',3), +(2743,'江达县',2741,'540321',3), +(2744,'贡觉县',2741,'540322',3), +(2745,'类乌齐县',2741,'540323',3), +(2746,'丁青县',2741,'540324',3), +(2747,'察雅县',2741,'540325',3), +(2748,'八宿县',2741,'540326',3), +(2749,'左贡县',2741,'540327',3), +(2750,'芒康县',2741,'540328',3), +(2751,'洛隆县',2741,'540329',3), +(2752,'边坝县',2741,'540330',3), +(2753,'林芝市',2712,'540400',2), +(2754,'巴宜区',2753,'540402',3), +(2755,'工布江达县',2753,'540421',3), +(2756,'米林县',2753,'540422',3), +(2757,'墨脱县',2753,'540423',3), +(2758,'波密县',2753,'540424',3), +(2759,'察隅县',2753,'540425',3), +(2760,'朗县',2753,'540426',3), +(2761,'山南市',2712,'540500',2), +(2762,'乃东区',2761,'540502',3), +(2763,'扎囊县',2761,'540521',3), +(2764,'贡嘎县',2761,'540522',3), +(2765,'桑日县',2761,'540523',3), +(2766,'琼结县',2761,'540524',3), +(2767,'曲松县',2761,'540525',3), +(2768,'措美县',2761,'540526',3), +(2769,'洛扎县',2761,'540527',3), +(2770,'加查县',2761,'540528',3), +(2771,'隆子县',2761,'540529',3), +(2772,'错那县',2761,'540530',3), +(2773,'浪卡子县',2761,'540531',3), +(2774,'那曲市',2712,'540600',2), +(2775,'色尼区',2774,'540602',3), +(2776,'嘉黎县',2774,'540621',3), +(2777,'比如县',2774,'540622',3), +(2778,'聂荣县',2774,'540623',3), +(2779,'安多县',2774,'540624',3), +(2780,'申扎县',2774,'540625',3), +(2781,'索县',2774,'540626',3), +(2782,'班戈县',2774,'540627',3), +(2783,'巴青县',2774,'540628',3), +(2784,'尼玛县',2774,'540629',3), +(2785,'双湖县',2774,'540630',3), +(2786,'阿里地区',2712,'542500',2), +(2787,'普兰县',2786,'542521',3), +(2788,'札达县',2786,'542522',3), +(2789,'噶尔县',2786,'542523',3), +(2790,'日土县',2786,'542524',3), +(2791,'革吉县',2786,'542525',3), +(2792,'改则县',2786,'542526',3), +(2793,'措勤县',2786,'542527',3), +(2794,'陕西省',0,'610000',1), +(2795,'西安市',2794,'610100',2), +(2796,'新城区',2795,'610102',3), +(2797,'碑林区',2795,'610103',3), +(2798,'莲湖区',2795,'610104',3), +(2799,'灞桥区',2795,'610111',3), +(2800,'未央区',2795,'610112',3), +(2801,'雁塔区',2795,'610113',3), +(2802,'阎良区',2795,'610114',3), +(2803,'临潼区',2795,'610115',3), +(2804,'长安区',2795,'610116',3), +(2805,'高陵区',2795,'610117',3), +(2806,'鄠邑区',2795,'610118',3), +(2807,'蓝田县',2795,'610122',3), +(2808,'周至县',2795,'610124',3), +(2809,'铜川市',2794,'610200',2), +(2810,'王益区',2809,'610202',3), +(2811,'印台区',2809,'610203',3), +(2812,'耀州区',2809,'610204',3), +(2813,'宜君县',2809,'610222',3), +(2814,'宝鸡市',2794,'610300',2), +(2815,'渭滨区',2814,'610302',3), +(2816,'金台区',2814,'610303',3), +(2817,'陈仓区',2814,'610304',3), +(2818,'凤翔县',2814,'610322',3), +(2819,'岐山县',2814,'610323',3), +(2820,'扶风县',2814,'610324',3), +(2821,'眉县',2814,'610326',3), +(2822,'陇县',2814,'610327',3), +(2823,'千阳县',2814,'610328',3), +(2824,'麟游县',2814,'610329',3), +(2825,'凤县',2814,'610330',3), +(2826,'太白县',2814,'610331',3), +(2827,'咸阳市',2794,'610400',2), +(2828,'秦都区',2827,'610402',3), +(2829,'杨陵区',2827,'610403',3), +(2830,'渭城区',2827,'610404',3), +(2831,'三原县',2827,'610422',3), +(2832,'泾阳县',2827,'610423',3), +(2833,'乾县',2827,'610424',3), +(2834,'礼泉县',2827,'610425',3), +(2835,'永寿县',2827,'610426',3), +(2836,'长武县',2827,'610428',3), +(2837,'旬邑县',2827,'610429',3), +(2838,'淳化县',2827,'610430',3), +(2839,'武功县',2827,'610431',3), +(2840,'兴平市',2827,'610481',3), +(2841,'彬州市',2827,'610482',3), +(2842,'渭南市',2794,'610500',2), +(2843,'临渭区',2842,'610502',3), +(2844,'华州区',2842,'610503',3), +(2845,'潼关县',2842,'610522',3), +(2846,'大荔县',2842,'610523',3), +(2847,'合阳县',2842,'610524',3), +(2848,'澄城县',2842,'610525',3), +(2849,'蒲城县',2842,'610526',3), +(2850,'白水县',2842,'610527',3), +(2851,'富平县',2842,'610528',3), +(2852,'韩城市',2842,'610581',3), +(2853,'华阴市',2842,'610582',3), +(2854,'延安市',2794,'610600',2), +(2855,'宝塔区',2854,'610602',3), +(2856,'安塞区',2854,'610603',3), +(2857,'延长县',2854,'610621',3), +(2858,'延川县',2854,'610622',3), +(2859,'志丹县',2854,'610625',3), +(2860,'吴起县',2854,'610626',3), +(2861,'甘泉县',2854,'610627',3), +(2862,'富县',2854,'610628',3), +(2863,'洛川县',2854,'610629',3), +(2864,'宜川县',2854,'610630',3), +(2865,'黄龙县',2854,'610631',3), +(2866,'黄陵县',2854,'610632',3), +(2867,'子长市',2854,'610681',3), +(2868,'汉中市',2794,'610700',2), +(2869,'汉台区',2868,'610702',3), +(2870,'南郑区',2868,'610703',3), +(2871,'城固县',2868,'610722',3), +(2872,'洋县',2868,'610723',3), +(2873,'西乡县',2868,'610724',3), +(2874,'勉县',2868,'610725',3), +(2875,'宁强县',2868,'610726',3), +(2876,'略阳县',2868,'610727',3), +(2877,'镇巴县',2868,'610728',3), +(2878,'留坝县',2868,'610729',3), +(2879,'佛坪县',2868,'610730',3), +(2880,'榆林市',2794,'610800',2), +(2881,'榆阳区',2880,'610802',3), +(2882,'横山区',2880,'610803',3), +(2883,'府谷县',2880,'610822',3), +(2884,'靖边县',2880,'610824',3), +(2885,'定边县',2880,'610825',3), +(2886,'绥德县',2880,'610826',3), +(2887,'米脂县',2880,'610827',3), +(2888,'佳县',2880,'610828',3), +(2889,'吴堡县',2880,'610829',3), +(2890,'清涧县',2880,'610830',3), +(2891,'子洲县',2880,'610831',3), +(2892,'神木市',2880,'610881',3), +(2893,'安康市',2794,'610900',2), +(2894,'汉滨区',2893,'610902',3), +(2895,'汉阴县',2893,'610921',3), +(2896,'石泉县',2893,'610922',3), +(2897,'宁陕县',2893,'610923',3), +(2898,'紫阳县',2893,'610924',3), +(2899,'岚皋县',2893,'610925',3), +(2900,'平利县',2893,'610926',3), +(2901,'镇坪县',2893,'610927',3), +(2902,'旬阳县',2893,'610928',3), +(2903,'白河县',2893,'610929',3), +(2904,'商洛市',2794,'611000',2), +(2905,'商州区',2904,'611002',3), +(2906,'洛南县',2904,'611021',3), +(2907,'丹凤县',2904,'611022',3), +(2908,'商南县',2904,'611023',3), +(2909,'山阳县',2904,'611024',3), +(2910,'镇安县',2904,'611025',3), +(2911,'柞水县',2904,'611026',3), +(2912,'甘肃省',0,'620000',1), +(2913,'兰州市',2912,'620100',2), +(2914,'城关区',2913,'620102',3), +(2915,'七里河区',2913,'620103',3), +(2916,'西固区',2913,'620104',3), +(2917,'安宁区',2913,'620105',3), +(2918,'红古区',2913,'620111',3), +(2919,'永登县',2913,'620121',3), +(2920,'皋兰县',2913,'620122',3), +(2921,'榆中县',2913,'620123',3), +(2922,'嘉峪关市',2912,'620200',2), +(2923,'金昌市',2912,'620300',2), +(2924,'金川区',2923,'620302',3), +(2925,'永昌县',2923,'620321',3), +(2926,'白银市',2912,'620400',2), +(2927,'白银区',2926,'620402',3), +(2928,'平川区',2926,'620403',3), +(2929,'靖远县',2926,'620421',3), +(2930,'会宁县',2926,'620422',3), +(2931,'景泰县',2926,'620423',3), +(2932,'天水市',2912,'620500',2), +(2933,'秦州区',2932,'620502',3), +(2934,'麦积区',2932,'620503',3), +(2935,'清水县',2932,'620521',3), +(2936,'秦安县',2932,'620522',3), +(2937,'甘谷县',2932,'620523',3), +(2938,'武山县',2932,'620524',3), +(2939,'张家川回族自治县',2932,'620525',3), +(2940,'武威市',2912,'620600',2), +(2941,'凉州区',2940,'620602',3), +(2942,'民勤县',2940,'620621',3), +(2943,'古浪县',2940,'620622',3), +(2944,'天祝藏族自治县',2940,'620623',3), +(2945,'张掖市',2912,'620700',2), +(2946,'甘州区',2945,'620702',3), +(2947,'肃南裕固族自治县',2945,'620721',3), +(2948,'民乐县',2945,'620722',3), +(2949,'临泽县',2945,'620723',3), +(2950,'高台县',2945,'620724',3), +(2951,'山丹县',2945,'620725',3), +(2952,'平凉市',2912,'620800',2), +(2953,'崆峒区',2952,'620802',3), +(2954,'泾川县',2952,'620821',3), +(2955,'灵台县',2952,'620822',3), +(2956,'崇信县',2952,'620823',3), +(2957,'庄浪县',2952,'620825',3), +(2958,'静宁县',2952,'620826',3), +(2959,'华亭市',2952,'620881',3), +(2960,'酒泉市',2912,'620900',2), +(2961,'肃州区',2960,'620902',3), +(2962,'金塔县',2960,'620921',3), +(2963,'瓜州县',2960,'620922',3), +(2964,'肃北蒙古族自治县',2960,'620923',3), +(2965,'阿克塞哈萨克族自治县',2960,'620924',3), +(2966,'玉门市',2960,'620981',3), +(2967,'敦煌市',2960,'620982',3), +(2968,'庆阳市',2912,'621000',2), +(2969,'西峰区',2968,'621002',3), +(2970,'庆城县',2968,'621021',3), +(2971,'环县',2968,'621022',3), +(2972,'华池县',2968,'621023',3), +(2973,'合水县',2968,'621024',3), +(2974,'正宁县',2968,'621025',3), +(2975,'宁县',2968,'621026',3), +(2976,'镇原县',2968,'621027',3), +(2977,'定西市',2912,'621100',2), +(2978,'安定区',2977,'621102',3), +(2979,'通渭县',2977,'621121',3), +(2980,'陇西县',2977,'621122',3), +(2981,'渭源县',2977,'621123',3), +(2982,'临洮县',2977,'621124',3), +(2983,'漳县',2977,'621125',3), +(2984,'岷县',2977,'621126',3), +(2985,'陇南市',2912,'621200',2), +(2986,'武都区',2985,'621202',3), +(2987,'成县',2985,'621221',3), +(2988,'文县',2985,'621222',3), +(2989,'宕昌县',2985,'621223',3), +(2990,'康县',2985,'621224',3), +(2991,'西和县',2985,'621225',3), +(2992,'礼县',2985,'621226',3), +(2993,'徽县',2985,'621227',3), +(2994,'两当县',2985,'621228',3), +(2995,'临夏回族自治州',2912,'622900',2), +(2996,'临夏市',2995,'622901',3), +(2997,'临夏县',2995,'622921',3), +(2998,'康乐县',2995,'622922',3), +(2999,'永靖县',2995,'622923',3), +(3000,'广河县',2995,'622924',3), +(3001,'和政县',2995,'622925',3), +(3002,'东乡族自治县',2995,'622926',3), +(3003,'积石山保安族东乡族撒拉族自治县',2995,'622927',3), +(3004,'甘南藏族自治州',2912,'623000',2), +(3005,'合作市',3004,'623001',3), +(3006,'临潭县',3004,'623021',3), +(3007,'卓尼县',3004,'623022',3), +(3008,'舟曲县',3004,'623023',3), +(3009,'迭部县',3004,'623024',3), +(3010,'玛曲县',3004,'623025',3), +(3011,'碌曲县',3004,'623026',3), +(3012,'夏河县',3004,'623027',3), +(3013,'青海省',0,'630000',1), +(3014,'西宁市',3013,'630100',2), +(3015,'城东区',3014,'630102',3), +(3016,'城中区',3014,'630103',3), +(3017,'城西区',3014,'630104',3), +(3018,'城北区',3014,'630105',3), +(3019,'湟中区',3014,'630106',3), +(3020,'大通回族土族自治县',3014,'630121',3), +(3021,'湟源县',3014,'630123',3), +(3022,'海东市',3013,'630200',2), +(3023,'乐都区',3022,'630202',3), +(3024,'平安区',3022,'630203',3), +(3025,'民和回族土族自治县',3022,'630222',3), +(3026,'互助土族自治县',3022,'630223',3), +(3027,'化隆回族自治县',3022,'630224',3), +(3028,'循化撒拉族自治县',3022,'630225',3), +(3029,'海北藏族自治州',3013,'632200',2), +(3030,'门源回族自治县',3029,'632221',3), +(3031,'祁连县',3029,'632222',3), +(3032,'海晏县',3029,'632223',3), +(3033,'刚察县',3029,'632224',3), +(3034,'黄南藏族自治州',3013,'632300',2), +(3035,'同仁县',3034,'632321',3), +(3036,'尖扎县',3034,'632322',3), +(3037,'泽库县',3034,'632323',3), +(3038,'河南蒙古族自治县',3034,'632324',3), +(3039,'海南藏族自治州',3013,'632500',2), +(3040,'共和县',3039,'632521',3), +(3041,'同德县',3039,'632522',3), +(3042,'贵德县',3039,'632523',3), +(3043,'兴海县',3039,'632524',3), +(3044,'贵南县',3039,'632525',3), +(3045,'果洛藏族自治州',3013,'632600',2), +(3046,'玛沁县',3045,'632621',3), +(3047,'班玛县',3045,'632622',3), +(3048,'甘德县',3045,'632623',3), +(3049,'达日县',3045,'632624',3), +(3050,'久治县',3045,'632625',3), +(3051,'玛多县',3045,'632626',3), +(3052,'玉树藏族自治州',3013,'632700',2), +(3053,'玉树市',3052,'632701',3), +(3054,'杂多县',3052,'632722',3), +(3055,'称多县',3052,'632723',3), +(3056,'治多县',3052,'632724',3), +(3057,'囊谦县',3052,'632725',3), +(3058,'曲麻莱县',3052,'632726',3), +(3059,'海西蒙古族藏族自治州',3013,'632800',2), +(3060,'格尔木市',3059,'632801',3), +(3061,'德令哈市',3059,'632802',3), +(3062,'茫崖市',3059,'632803',3), +(3063,'乌兰县',3059,'632821',3), +(3064,'都兰县',3059,'632822',3), +(3065,'天峻县',3059,'632823',3), +(3066,'宁夏回族自治区',0,'640000',1), +(3067,'银川市',3066,'640100',2), +(3068,'兴庆区',3067,'640104',3), +(3069,'西夏区',3067,'640105',3), +(3070,'金凤区',3067,'640106',3), +(3071,'永宁县',3067,'640121',3), +(3072,'贺兰县',3067,'640122',3), +(3073,'灵武市',3067,'640181',3), +(3074,'石嘴山市',3066,'640200',2), +(3075,'大武口区',3074,'640202',3), +(3076,'惠农区',3074,'640205',3), +(3077,'平罗县',3074,'640221',3), +(3078,'吴忠市',3066,'640300',2), +(3079,'利通区',3078,'640302',3), +(3080,'红寺堡区',3078,'640303',3), +(3081,'盐池县',3078,'640323',3), +(3082,'同心县',3078,'640324',3), +(3083,'青铜峡市',3078,'640381',3), +(3084,'固原市',3066,'640400',2), +(3085,'原州区',3084,'640402',3), +(3086,'西吉县',3084,'640422',3), +(3087,'隆德县',3084,'640423',3), +(3088,'泾源县',3084,'640424',3), +(3089,'彭阳县',3084,'640425',3), +(3090,'中卫市',3066,'640500',2), +(3091,'沙坡头区',3090,'640502',3), +(3092,'中宁县',3090,'640521',3), +(3093,'海原县',3090,'640522',3), +(3094,'新疆维吾尔自治区',0,'650000',1), +(3095,'乌鲁木齐市',3094,'650100',2), +(3096,'天山区',3095,'650102',3), +(3097,'沙依巴克区',3095,'650103',3), +(3098,'新市区',3095,'650104',3), +(3099,'水磨沟区',3095,'650105',3), +(3100,'头屯河区',3095,'650106',3), +(3101,'达坂城区',3095,'650107',3), +(3102,'米东区',3095,'650109',3), +(3103,'乌鲁木齐县',3095,'650121',3), +(3104,'克拉玛依市',3094,'650200',2), +(3105,'独山子区',3104,'650202',3), +(3106,'克拉玛依区',3104,'650203',3), +(3107,'白碱滩区',3104,'650204',3), +(3108,'乌尔禾区',3104,'650205',3), +(3109,'吐鲁番市',3094,'650400',2), +(3110,'高昌区',3109,'650402',3), +(3111,'鄯善县',3109,'650421',3), +(3112,'托克逊县',3109,'650422',3), +(3113,'哈密市',3094,'650500',2), +(3114,'伊州区',3113,'650502',3), +(3115,'巴里坤哈萨克自治县',3113,'650521',3), +(3116,'伊吾县',3113,'650522',3), +(3117,'昌吉回族自治州',3094,'652300',2), +(3118,'昌吉市',3117,'652301',3), +(3119,'阜康市',3117,'652302',3), +(3120,'呼图壁县',3117,'652323',3), +(3121,'玛纳斯县',3117,'652324',3), +(3122,'奇台县',3117,'652325',3), +(3123,'吉木萨尔县',3117,'652327',3), +(3124,'木垒哈萨克自治县',3117,'652328',3), +(3125,'博尔塔拉蒙古自治州',3094,'652700',2), +(3126,'博乐市',3125,'652701',3), +(3127,'阿拉山口市',3125,'652702',3), +(3128,'精河县',3125,'652722',3), +(3129,'温泉县',3125,'652723',3), +(3130,'巴音郭楞蒙古自治州',3094,'652800',2), +(3131,'库尔勒市',3130,'652801',3), +(3132,'轮台县',3130,'652822',3), +(3133,'尉犁县',3130,'652823',3), +(3134,'若羌县',3130,'652824',3), +(3135,'且末县',3130,'652825',3), +(3136,'焉耆回族自治县',3130,'652826',3), +(3137,'和静县',3130,'652827',3), +(3138,'和硕县',3130,'652828',3), +(3139,'博湖县',3130,'652829',3), +(3140,'阿克苏地区',3094,'652900',2), +(3141,'阿克苏市',3140,'652901',3), +(3142,'库车市',3140,'652902',3), +(3143,'温宿县',3140,'652922',3), +(3144,'沙雅县',3140,'652924',3), +(3145,'新和县',3140,'652925',3), +(3146,'拜城县',3140,'652926',3), +(3147,'乌什县',3140,'652927',3), +(3148,'阿瓦提县',3140,'652928',3), +(3149,'柯坪县',3140,'652929',3), +(3150,'克孜勒苏柯尔克孜自治州',3094,'653000',2), +(3151,'阿图什市',3150,'653001',3), +(3152,'阿克陶县',3150,'653022',3), +(3153,'阿合奇县',3150,'653023',3), +(3154,'乌恰县',3150,'653024',3), +(3155,'喀什地区',3094,'653100',2), +(3156,'喀什市',3155,'653101',3), +(3157,'疏附县',3155,'653121',3), +(3158,'疏勒县',3155,'653122',3), +(3159,'英吉沙县',3155,'653123',3), +(3160,'泽普县',3155,'653124',3), +(3161,'莎车县',3155,'653125',3), +(3162,'叶城县',3155,'653126',3), +(3163,'麦盖提县',3155,'653127',3), +(3164,'岳普湖县',3155,'653128',3), +(3165,'伽师县',3155,'653129',3), +(3166,'巴楚县',3155,'653130',3), +(3167,'塔什库尔干塔吉克自治县',3155,'653131',3), +(3168,'和田地区',3094,'653200',2), +(3169,'和田市',3168,'653201',3), +(3170,'和田县',3168,'653221',3), +(3171,'墨玉县',3168,'653222',3), +(3172,'皮山县',3168,'653223',3), +(3173,'洛浦县',3168,'653224',3), +(3174,'策勒县',3168,'653225',3), +(3175,'于田县',3168,'653226',3), +(3176,'民丰县',3168,'653227',3), +(3177,'伊犁哈萨克自治州',3094,'654000',2), +(3178,'伊宁市',3177,'654002',3), +(3179,'奎屯市',3177,'654003',3), +(3180,'霍尔果斯市',3177,'654004',3), +(3181,'伊宁县',3177,'654021',3), +(3182,'察布查尔锡伯自治县',3177,'654022',3), +(3183,'霍城县',3177,'654023',3), +(3184,'巩留县',3177,'654024',3), +(3185,'新源县',3177,'654025',3), +(3186,'昭苏县',3177,'654026',3), +(3187,'特克斯县',3177,'654027',3), +(3188,'尼勒克县',3177,'654028',3), +(3189,'塔城地区',3094,'654200',2), +(3190,'塔城市',3189,'654201',3), +(3191,'乌苏市',3189,'654202',3), +(3192,'额敏县',3189,'654221',3), +(3193,'沙湾县',3189,'654223',3), +(3194,'托里县',3189,'654224',3), +(3195,'裕民县',3189,'654225',3), +(3196,'和布克赛尔蒙古自治县',3189,'654226',3), +(3197,'阿勒泰地区',3094,'654300',2), +(3198,'阿勒泰市',3197,'654301',3), +(3199,'布尔津县',3197,'654321',3), +(3200,'富蕴县',3197,'654322',3), +(3201,'福海县',3197,'654323',3), +(3202,'哈巴河县',3197,'654324',3), +(3203,'青河县',3197,'654325',3), +(3204,'吉木乃县',3197,'654326',3), +(3205,'石河子市',3094,'659001',3), +(3206,'阿拉尔市',3094,'659002',3), +(3207,'图木舒克市',3094,'659003',3), +(3208,'五家渠市',3094,'659004',3), +(3209,'北屯市',3094,'659005',3), +(3210,'铁门关市',3094,'659006',3), +(3211,'双河市',3094,'659007',3), +(3212,'可克达拉市',3094,'659008',3), +(3213,'昆玉市',3094,'659009',3), +(3214,'胡杨河市',3094,'659010',3), +(3215,'台湾省',0,'710000',1), +(3216,'台北市',3215,'710100',2), +(3217,'中正区',3216,'710101',3), +(3218,'大同区',3216,'710102',3), +(3219,'中山区',3216,'710103',3), +(3220,'松山区',3216,'710104',3), +(3221,'大安区',3216,'710105',3), +(3222,'万华区',3216,'710106',3), +(3223,'信义区',3216,'710107',3), +(3224,'士林区',3216,'710108',3), +(3225,'北投区',3216,'710109',3), +(3226,'内湖区',3216,'710110',3), +(3227,'南港区',3216,'710111',3), +(3228,'文山区',3216,'710112',3), +(3229,'高雄市',3215,'710200',2), +(3230,'新兴区',3229,'710201',3), +(3231,'前金区',3229,'710202',3), +(3232,'苓雅区',3229,'710203',3), +(3233,'盐埕区',3229,'710204',3), +(3234,'鼓山区',3229,'710205',3), +(3235,'旗津区',3229,'710206',3), +(3236,'前镇区',3229,'710207',3), +(3237,'三民区',3229,'710208',3), +(3238,'左营区',3229,'710209',3), +(3239,'楠梓区',3229,'710210',3), +(3240,'小港区',3229,'710211',3), +(3241,'仁武区',3229,'710242',3), +(3242,'大社区',3229,'710243',3), +(3243,'冈山区',3229,'710244',3), +(3244,'路竹区',3229,'710245',3), +(3245,'阿莲区',3229,'710246',3), +(3246,'田寮区',3229,'710247',3), +(3247,'燕巢区',3229,'710248',3), +(3248,'桥头区',3229,'710249',3), +(3249,'梓官区',3229,'710250',3), +(3250,'弥陀区',3229,'710251',3), +(3251,'永安区',3229,'710252',3), +(3252,'湖内区',3229,'710253',3), +(3253,'凤山区',3229,'710254',3), +(3254,'大寮区',3229,'710255',3), +(3255,'林园区',3229,'710256',3), +(3256,'鸟松区',3229,'710257',3), +(3257,'大树区',3229,'710258',3), +(3258,'旗山区',3229,'710259',3), +(3259,'美浓区',3229,'710260',3), +(3260,'六龟区',3229,'710261',3), +(3261,'内门区',3229,'710262',3), +(3262,'杉林区',3229,'710263',3), +(3263,'甲仙区',3229,'710264',3), +(3264,'桃源区',3229,'710265',3), +(3265,'那玛夏区',3229,'710266',3), +(3266,'茂林区',3229,'710267',3), +(3267,'茄萣区',3229,'710268',3), +(3268,'台南市',3215,'710300',2), +(3269,'中西区',3268,'710301',3), +(3270,'东区',3268,'710302',3), +(3271,'南区',3268,'710303',3), +(3272,'北区',3268,'710304',3), +(3273,'安平区',3268,'710305',3), +(3274,'安南区',3268,'710306',3), +(3275,'永康区',3268,'710339',3), +(3276,'归仁区',3268,'710340',3), +(3277,'新化区',3268,'710341',3), +(3278,'左镇区',3268,'710342',3), +(3279,'玉井区',3268,'710343',3), +(3280,'楠西区',3268,'710344',3), +(3281,'南化区',3268,'710345',3), +(3282,'仁德区',3268,'710346',3), +(3283,'关庙区',3268,'710347',3), +(3284,'龙崎区',3268,'710348',3), +(3285,'官田区',3268,'710349',3), +(3286,'麻豆区',3268,'710350',3), +(3287,'佳里区',3268,'710351',3), +(3288,'西港区',3268,'710352',3), +(3289,'七股区',3268,'710353',3), +(3290,'将军区',3268,'710354',3), +(3291,'学甲区',3268,'710355',3), +(3292,'北门区',3268,'710356',3), +(3293,'新营区',3268,'710357',3), +(3294,'后壁区',3268,'710358',3), +(3295,'白河区',3268,'710359',3), +(3296,'东山区',3268,'710360',3), +(3297,'六甲区',3268,'710361',3), +(3298,'下营区',3268,'710362',3), +(3299,'柳营区',3268,'710363',3), +(3300,'盐水区',3268,'710364',3), +(3301,'善化区',3268,'710365',3), +(3302,'大内区',3268,'710366',3), +(3303,'山上区',3268,'710367',3), +(3304,'新市区',3268,'710368',3), +(3305,'安定区',3268,'710369',3), +(3306,'台中市',3215,'710400',2), +(3307,'中区',3306,'710401',3), +(3308,'东区',3306,'710402',3), +(3309,'南区',3306,'710403',3), +(3310,'西区',3306,'710404',3), +(3311,'北区',3306,'710405',3), +(3312,'北屯区',3306,'710406',3), +(3313,'西屯区',3306,'710407',3), +(3314,'南屯区',3306,'710408',3), +(3315,'太平区',3306,'710431',3), +(3316,'大里区',3306,'710432',3), +(3317,'雾峰区',3306,'710433',3), +(3318,'乌日区',3306,'710434',3), +(3319,'丰原区',3306,'710435',3), +(3320,'后里区',3306,'710436',3), +(3321,'石冈区',3306,'710437',3), +(3322,'东势区',3306,'710438',3), +(3323,'和平区',3306,'710439',3), +(3324,'新社区',3306,'710440',3), +(3325,'潭子区',3306,'710441',3), +(3326,'大雅区',3306,'710442',3), +(3327,'神冈区',3306,'710443',3), +(3328,'大肚区',3306,'710444',3), +(3329,'沙鹿区',3306,'710445',3), +(3330,'龙井区',3306,'710446',3), +(3331,'梧栖区',3306,'710447',3), +(3332,'清水区',3306,'710448',3), +(3333,'大甲区',3306,'710449',3), +(3334,'外埔区',3306,'710450',3), +(3335,'大安区',3306,'710451',3), +(3336,'南投县',3215,'710600',2), +(3337,'南投市',3336,'710614',3), +(3338,'中寮乡',3336,'710615',3), +(3339,'草屯镇',3336,'710616',3), +(3340,'国姓乡',3336,'710617',3), +(3341,'埔里镇',3336,'710618',3), +(3342,'仁爱乡',3336,'710619',3), +(3343,'名间乡',3336,'710620',3), +(3344,'集集镇',3336,'710621',3), +(3345,'水里乡',3336,'710622',3), +(3346,'鱼池乡',3336,'710623',3), +(3347,'信义乡',3336,'710624',3), +(3348,'竹山镇',3336,'710625',3), +(3349,'鹿谷乡',3336,'710626',3), +(3350,'基隆市',3215,'710700',2), +(3351,'仁爱区',3350,'710701',3), +(3352,'信义区',3350,'710702',3), +(3353,'中正区',3350,'710703',3), +(3354,'中山区',3350,'710704',3), +(3355,'安乐区',3350,'710705',3), +(3356,'暖暖区',3350,'710706',3), +(3357,'七堵区',3350,'710707',3), +(3358,'新竹市',3215,'710800',2), +(3359,'东区',3358,'710801',3), +(3360,'北区',3358,'710802',3), +(3361,'香山区',3358,'710803',3), +(3362,'嘉义市',3215,'710900',2), +(3363,'东区',3362,'710901',3), +(3364,'西区',3362,'710902',3), +(3365,'新北市',3215,'711100',2), +(3366,'万里区',3365,'711130',3), +(3367,'金山区',3365,'711131',3), +(3368,'板桥区',3365,'711132',3), +(3369,'汐止区',3365,'711133',3), +(3370,'深坑区',3365,'711134',3), +(3371,'石碇区',3365,'711135',3), +(3372,'瑞芳区',3365,'711136',3), +(3373,'平溪区',3365,'711137',3), +(3374,'双溪区',3365,'711138',3), +(3375,'贡寮区',3365,'711139',3), +(3376,'新店区',3365,'711140',3), +(3377,'坪林区',3365,'711141',3), +(3378,'乌来区',3365,'711142',3), +(3379,'永和区',3365,'711143',3), +(3380,'中和区',3365,'711144',3), +(3381,'土城区',3365,'711145',3), +(3382,'三峡区',3365,'711146',3), +(3383,'树林区',3365,'711147',3), +(3384,'莺歌区',3365,'711148',3), +(3385,'三重区',3365,'711149',3), +(3386,'新庄区',3365,'711150',3), +(3387,'泰山区',3365,'711151',3), +(3388,'林口区',3365,'711152',3), +(3389,'芦洲区',3365,'711153',3), +(3390,'五股区',3365,'711154',3), +(3391,'八里区',3365,'711155',3), +(3392,'淡水区',3365,'711156',3), +(3393,'三芝区',3365,'711157',3), +(3394,'石门区',3365,'711158',3), +(3395,'宜兰县',3215,'711200',2), +(3396,'宜兰市',3395,'711214',3), +(3397,'头城镇',3395,'711215',3), +(3398,'礁溪乡',3395,'711216',3), +(3399,'壮围乡',3395,'711217',3), +(3400,'员山乡',3395,'711218',3), +(3401,'罗东镇',3395,'711219',3), +(3402,'三星乡',3395,'711220',3), +(3403,'大同乡',3395,'711221',3), +(3404,'五结乡',3395,'711222',3), +(3405,'冬山乡',3395,'711223',3), +(3406,'苏澳镇',3395,'711224',3), +(3407,'南澳乡',3395,'711225',3), +(3408,'新竹县',3215,'711300',2), +(3409,'竹北市',3408,'711314',3), +(3410,'湖口乡',3408,'711315',3), +(3411,'新丰乡',3408,'711316',3), +(3412,'新埔镇',3408,'711317',3), +(3413,'关西镇',3408,'711318',3), +(3414,'芎林乡',3408,'711319',3), +(3415,'宝山乡',3408,'711320',3), +(3416,'竹东镇',3408,'711321',3), +(3417,'五峰乡',3408,'711322',3), +(3418,'横山乡',3408,'711323',3), +(3419,'尖石乡',3408,'711324',3), +(3420,'北埔乡',3408,'711325',3), +(3421,'峨眉乡',3408,'711326',3), +(3422,'桃园市',3215,'711400',2), +(3423,'中坜区',3422,'711414',3), +(3424,'平镇区',3422,'711415',3), +(3425,'龙潭区',3422,'711416',3), +(3426,'杨梅区',3422,'711417',3), +(3427,'新屋区',3422,'711418',3), +(3428,'观音区',3422,'711419',3), +(3429,'桃园区',3422,'711420',3), +(3430,'龟山区',3422,'711421',3), +(3431,'八德区',3422,'711422',3), +(3432,'大溪区',3422,'711423',3), +(3433,'复兴区',3422,'711424',3), +(3434,'大园区',3422,'711425',3), +(3435,'芦竹区',3422,'711426',3), +(3436,'苗栗县',3215,'711500',2), +(3437,'竹南镇',3436,'711519',3), +(3438,'头份市',3436,'711520',3), +(3439,'三湾乡',3436,'711521',3), +(3440,'南庄乡',3436,'711522',3), +(3441,'狮潭乡',3436,'711523',3), +(3442,'后龙镇',3436,'711524',3), +(3443,'通霄镇',3436,'711525',3), +(3444,'苑里镇',3436,'711526',3), +(3445,'苗栗市',3436,'711527',3), +(3446,'造桥乡',3436,'711528',3), +(3447,'头屋乡',3436,'711529',3), +(3448,'公馆乡',3436,'711530',3), +(3449,'大湖乡',3436,'711531',3), +(3450,'泰安乡',3436,'711532',3), +(3451,'铜锣乡',3436,'711533',3), +(3452,'三义乡',3436,'711534',3), +(3453,'西湖乡',3436,'711535',3), +(3454,'卓兰镇',3436,'711536',3), +(3455,'彰化县',3215,'711700',2), +(3456,'彰化市',3455,'711727',3), +(3457,'芬园乡',3455,'711728',3), +(3458,'花坛乡',3455,'711729',3), +(3459,'秀水乡',3455,'711730',3), +(3460,'鹿港镇',3455,'711731',3), +(3461,'福兴乡',3455,'711732',3), +(3462,'线西乡',3455,'711733',3), +(3463,'和美镇',3455,'711734',3), +(3464,'伸港乡',3455,'711735',3), +(3465,'员林市',3455,'711736',3), +(3466,'社头乡',3455,'711737',3), +(3467,'永靖乡',3455,'711738',3), +(3468,'埔心乡',3455,'711739',3), +(3469,'溪湖镇',3455,'711740',3), +(3470,'大村乡',3455,'711741',3), +(3471,'埔盐乡',3455,'711742',3), +(3472,'田中镇',3455,'711743',3), +(3473,'北斗镇',3455,'711744',3), +(3474,'田尾乡',3455,'711745',3), +(3475,'埤头乡',3455,'711746',3), +(3476,'溪州乡',3455,'711747',3), +(3477,'竹塘乡',3455,'711748',3), +(3478,'二林镇',3455,'711749',3), +(3479,'大城乡',3455,'711750',3), +(3480,'芳苑乡',3455,'711751',3), +(3481,'二水乡',3455,'711752',3), +(3482,'嘉义县',3215,'711900',2), +(3483,'番路乡',3482,'711919',3), +(3484,'梅山乡',3482,'711920',3), +(3485,'竹崎乡',3482,'711921',3), +(3486,'阿里山乡',3482,'711922',3), +(3487,'中埔乡',3482,'711923',3), +(3488,'大埔乡',3482,'711924',3), +(3489,'水上乡',3482,'711925',3), +(3490,'鹿草乡',3482,'711926',3), +(3491,'太保市',3482,'711927',3), +(3492,'朴子市',3482,'711928',3), +(3493,'东石乡',3482,'711929',3), +(3494,'六脚乡',3482,'711930',3), +(3495,'新港乡',3482,'711931',3), +(3496,'民雄乡',3482,'711932',3), +(3497,'大林镇',3482,'711933',3), +(3498,'溪口乡',3482,'711934',3), +(3499,'义竹乡',3482,'711935',3), +(3500,'布袋镇',3482,'711936',3), +(3501,'云林县',3215,'712100',2), +(3502,'斗南镇',3501,'712121',3), +(3503,'大埤乡',3501,'712122',3), +(3504,'虎尾镇',3501,'712123',3), +(3505,'土库镇',3501,'712124',3), +(3506,'褒忠乡',3501,'712125',3), +(3507,'东势乡',3501,'712126',3), +(3508,'台西乡',3501,'712127',3), +(3509,'仑背乡',3501,'712128',3), +(3510,'麦寮乡',3501,'712129',3), +(3511,'斗六市',3501,'712130',3), +(3512,'林内乡',3501,'712131',3), +(3513,'古坑乡',3501,'712132',3), +(3514,'莿桐乡',3501,'712133',3), +(3515,'西螺镇',3501,'712134',3), +(3516,'二仑乡',3501,'712135',3), +(3517,'北港镇',3501,'712136',3), +(3518,'水林乡',3501,'712137',3), +(3519,'口湖乡',3501,'712138',3), +(3520,'四湖乡',3501,'712139',3), +(3521,'元长乡',3501,'712140',3), +(3522,'屏东县',3215,'712400',2), +(3523,'屏东市',3522,'712434',3), +(3524,'三地门乡',3522,'712435',3), +(3525,'雾台乡',3522,'712436',3), +(3526,'玛家乡',3522,'712437',3), +(3527,'九如乡',3522,'712438',3), +(3528,'里港乡',3522,'712439',3), +(3529,'高树乡',3522,'712440',3), +(3530,'盐埔乡',3522,'712441',3), +(3531,'长治乡',3522,'712442',3), +(3532,'麟洛乡',3522,'712443',3), +(3533,'竹田乡',3522,'712444',3), +(3534,'内埔乡',3522,'712445',3), +(3535,'万丹乡',3522,'712446',3), +(3536,'潮州镇',3522,'712447',3), +(3537,'泰武乡',3522,'712448',3), +(3538,'来义乡',3522,'712449',3), +(3539,'万峦乡',3522,'712450',3), +(3540,'崁顶乡',3522,'712451',3), +(3541,'新埤乡',3522,'712452',3), +(3542,'南州乡',3522,'712453',3), +(3543,'林边乡',3522,'712454',3), +(3544,'东港镇',3522,'712455',3), +(3545,'琉球乡',3522,'712456',3), +(3546,'佳冬乡',3522,'712457',3), +(3547,'新园乡',3522,'712458',3), +(3548,'枋寮乡',3522,'712459',3), +(3549,'枋山乡',3522,'712460',3), +(3550,'春日乡',3522,'712461',3), +(3551,'狮子乡',3522,'712462',3), +(3552,'车城乡',3522,'712463',3), +(3553,'牡丹乡',3522,'712464',3), +(3554,'恒春镇',3522,'712465',3), +(3555,'满州乡',3522,'712466',3), +(3556,'台东县',3215,'712500',2), +(3557,'台东市',3556,'712517',3), +(3558,'绿岛乡',3556,'712518',3), +(3559,'兰屿乡',3556,'712519',3), +(3560,'延平乡',3556,'712520',3), +(3561,'卑南乡',3556,'712521',3), +(3562,'鹿野乡',3556,'712522',3), +(3563,'关山镇',3556,'712523',3), +(3564,'海端乡',3556,'712524',3), +(3565,'池上乡',3556,'712525',3), +(3566,'东河乡',3556,'712526',3), +(3567,'成功镇',3556,'712527',3), +(3568,'长滨乡',3556,'712528',3), +(3569,'金峰乡',3556,'712529',3), +(3570,'大武乡',3556,'712530',3), +(3571,'达仁乡',3556,'712531',3), +(3572,'太麻里乡',3556,'712532',3), +(3573,'花莲县',3215,'712600',2), +(3574,'花莲市',3573,'712615',3), +(3575,'新城乡',3573,'712616',3), +(3576,'秀林乡',3573,'712618',3), +(3577,'吉安乡',3573,'712619',3), +(3578,'寿丰乡',3573,'712620',3), +(3579,'凤林镇',3573,'712621',3), +(3580,'光复乡',3573,'712622',3), +(3581,'丰滨乡',3573,'712623',3), +(3582,'瑞穗乡',3573,'712624',3), +(3583,'万荣乡',3573,'712625',3), +(3584,'玉里镇',3573,'712626',3), +(3585,'卓溪乡',3573,'712627',3), +(3586,'富里乡',3573,'712628',3), +(3587,'澎湖县',3215,'712700',2), +(3588,'马公市',3587,'712707',3), +(3589,'西屿乡',3587,'712708',3), +(3590,'望安乡',3587,'712709',3), +(3591,'七美乡',3587,'712710',3), +(3592,'白沙乡',3587,'712711',3), +(3593,'湖西乡',3587,'712712',3), +(3594,'香港特别行政区',0,'810000',1), +(3595,'香港特别行政区',3594,'810100',2), +(3596,'中西区',3595,'810101',3), +(3597,'东区',3595,'810102',3), +(3598,'九龙城区',3595,'810103',3), +(3599,'观塘区',3595,'810104',3), +(3600,'南区',3595,'810105',3), +(3601,'深水埗区',3595,'810106',3), +(3602,'湾仔区',3595,'810107',3), +(3603,'黄大仙区',3595,'810108',3), +(3604,'油尖旺区',3595,'810109',3), +(3605,'离岛区',3595,'810110',3), +(3606,'葵青区',3595,'810111',3), +(3607,'北区',3595,'810112',3), +(3608,'西贡区',3595,'810113',3), +(3609,'沙田区',3595,'810114',3), +(3610,'屯门区',3595,'810115',3), +(3611,'大埔区',3595,'810116',3), +(3612,'荃湾区',3595,'810117',3), +(3613,'元朗区',3595,'810118',3), +(3614,'澳门特别行政区',0,'820000',1), +(3615,'澳门特别行政区',3614,'820100',2), +(3616,'澳门半岛',3615,'820101',3), +(3617,'凼仔',3615,'820102',3), +(3618,'路凼城',3615,'820103',3), +(3619,'路环',3615,'820104',3), +(3620,'东城街道',2051,'44190',3), +(3621,'南城街道',2051,'441900',3), +(3622,'万江街道',2051,'441900',3), +(3623,'莞城街道',2051,'441900',3), +(3624,'石碣镇',2051,'441900',3), +(3625,'石龙镇',2051,'441900',3), +(3626,'茶山镇',2051,'441900',3), +(3627,'石排镇',2051,'441900',3), +(3628,'企石镇',2051,'441900',3), +(3629,'横沥镇',2051,'441900',3), +(3630,'桥头镇',2051,'441900',3), +(3631,'谢岗镇',2051,'441900',3), +(3632,'东坑镇',2051,'441900',3), +(3633,'常平镇',2051,'441900',3), +(3634,'寮步镇',2051,'441900',3), +(3635,'樟木头镇',2051,'441900',3), +(3636,'大朗镇',2051,'441900',3), +(3637,'黄江镇',2051,'441900',3), +(3638,'清溪镇',2051,'441900',3), +(3639,'塘厦镇',2051,'441900',3), +(3640,'凤岗镇',2051,'441900',3), +(3641,'大岭山镇',2051,'441900',3), +(3642,'长安镇',2051,'441900',3), +(3643,'虎门镇',2051,'441900',3), +(3644,'厚街镇',2051,'441900',3), +(3645,'沙田镇',2051,'441900',3), +(3646,'道滘镇',2051,'441900',3), +(3647,'洪梅镇',2051,'441900',3), +(3648,'麻涌镇',2051,'441900',3), +(3649,'望牛墩镇',2051,'441900',3), +(3650,'中堂镇',2051,'441900',3), +(3651,'高埗镇',2051,'441900',3), +(3652,'松山湖',2051,'441900',3), +(3653,'东莞港',2051,'441900',3), +(3654,'东莞生态园',2051,'441900',3), +(3655,'石岐街道',2052,'44200',3), +(3656,'东区街道',2052,'442000',3), +(3657,'中山港街道',2052,'442000',3), +(3658,'西区街道',2052,'442000',3), +(3659,'南区街道',2052,'442000',3), +(3660,'五桂山街道',2052,'442000',3), +(3661,'小榄镇',2052,'442000',3), +(3662,'黄圃镇',2052,'442000',3), +(3663,'民众镇',2052,'442000',3), +(3664,'东凤镇',2052,'442000',3), +(3665,'东升镇',2052,'442000',3), +(3666,'古镇镇',2052,'442000',3), +(3667,'沙溪镇',2052,'442000',3), +(3668,'坦洲镇',2052,'442000',3), +(3669,'港口镇',2052,'442000',3), +(3670,'三角镇',2052,'442000',3), +(3671,'横栏镇',2052,'442000',3), +(3672,'南头镇',2052,'442000',3), +(3673,'阜沙镇',2052,'442000',3), +(3674,'南朗镇',2052,'442000',3), +(3675,'三乡镇',2052,'442000',3), +(3676,'板芙镇',2052,'442000',3), +(3677,'大涌镇',2052,'442000',3), +(3678,'神湾镇',2052,'442000',3), +(3679,'西沙群岛',2206,'46032',3), +(3680,'南沙群岛',2206,'460322',3), +(3681,'中沙群岛的岛礁及其海域',2206,'460323',3), +(3682,'那大镇',2207,'46040',3), +(3683,'和庆镇',2207,'460400',3), +(3684,'南丰镇',2207,'460400',3), +(3685,'大成镇',2207,'460400',3), +(3686,'雅星镇',2207,'460400',3), +(3687,'兰洋镇',2207,'460400',3), +(3688,'光村镇',2207,'460400',3), +(3689,'木棠镇',2207,'460400',3), +(3690,'海头镇',2207,'460400',3), +(3691,'峨蔓镇',2207,'460400',3), +(3692,'王五镇',2207,'460400',3), +(3693,'白马井镇',2207,'460400',3), +(3694,'中和镇',2207,'460400',3), +(3695,'排浦镇',2207,'460400',3), +(3696,'东成镇',2207,'460400',3), +(3697,'新州镇',2207,'460400',3), +(3698,'洋浦经济开发区',2207,'460400',3), +(3699,'华南热作学院',2207,'460400',3), +(3700,'雄关街道',2922,'62020',3), +(3701,'钢城街道',2922,'620201',3), +(3702,'新城镇',2922,'620201',3), +(3703,'峪泉镇',2922,'620201',3), +(3704,'文殊镇',2922,'620201',3); + +/*Table structure for table `mt_send_log` */ + +DROP TABLE IF EXISTS `mt_send_log`; + +CREATE TABLE `mt_send_log` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `MERCHANT_ID` int DEFAULT '0' COMMENT '商户ID', + `STORE_ID` int DEFAULT '0' COMMENT '店铺ID', + `TYPE` tinyint(1) NOT NULL COMMENT '1:单用户发券;2:批量发券', + `USER_ID` int DEFAULT NULL COMMENT '用户ID', + `FILE_NAME` varchar(100) DEFAULT '' COMMENT '导入excel文件名', + `FILE_PATH` varchar(200) DEFAULT '' COMMENT '导入excel文件路径', + `MOBILE` varchar(20) NOT NULL COMMENT '用户手机', + `GROUP_ID` int NOT NULL COMMENT '券组ID', + `GROUP_NAME` varchar(100) DEFAULT '' COMMENT '券组名称', + `COUPON_ID` int DEFAULT '0' COMMENT '卡券ID', + `SEND_NUM` int DEFAULT NULL COMMENT '发放套数', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '操作时间', + `OPERATOR` varchar(30) DEFAULT NULL COMMENT '操作人', + `UUID` varchar(50) DEFAULT '' COMMENT '导入UUID', + `REMOVE_SUCCESS_NUM` int DEFAULT '0' COMMENT '作废成功张数', + `REMOVE_FAIL_NUM` int DEFAULT '0' COMMENT '作废失败张数', + `STATUS` char(1) DEFAULT NULL COMMENT '状态,A正常;B:部分作废;D全部作废', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='卡券发放记录表'; + +/*Data for the table `mt_send_log` */ + +/*Table structure for table `mt_setting` */ + +DROP TABLE IF EXISTS `mt_setting`; + +CREATE TABLE `mt_setting` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `MERCHANT_ID` int DEFAULT '0' COMMENT '商户ID', + `STORE_ID` int DEFAULT '0' COMMENT '店铺ID', + `TYPE` varchar(30) NOT NULL DEFAULT '' COMMENT '类型', + `NAME` varchar(50) NOT NULL DEFAULT '' COMMENT '配置项', + `VALUE` varchar(1000) NOT NULL DEFAULT '' COMMENT '配置值', + `DESCRIPTION` varchar(200) DEFAULT '' COMMENT '配置说明', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `OPERATOR` varchar(30) DEFAULT '' COMMENT '最后操作人', + `STATUS` char(1) DEFAULT 'A' COMMENT '状态 A启用;D禁用', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB AUTO_INCREMENT=88 DEFAULT CHARSET=utf8 COMMENT='全局设置表'; + +/*Data for the table `mt_setting` */ + +insert into `mt_setting`(`ID`,`MERCHANT_ID`,`STORE_ID`,`TYPE`,`NAME`,`VALUE`,`DESCRIPTION`,`CREATE_TIME`,`UPDATE_TIME`,`OPERATOR`,`STATUS`) values +(1,1,0,'user','getCouponNeedPhone','false','领券是否需要手机号码','2022-03-12 13:55:55','2023-07-28 20:06:11','fuint','A'), +(2,1,0,'user','submitOrderNeedPhone','false','提交订单是否需要手机号码','2022-03-12 13:55:56','2023-07-28 20:06:11','fuint','A'), +(3,1,0,'user','loginNeedPhone','false','登录是否需要手机号','2022-03-12 13:55:56','2023-07-28 20:06:11','fuint','A'), +(6,1,0,'point','exchangeNeedPoint','100','多少积分可抵扣1元现金','2022-03-12 13:56:23','2023-09-18 17:13:21','anan','A'), +(7,1,0,'point','rechargePointSpeed','1','充值返积分倍数','2022-03-12 13:56:23','2023-09-18 17:13:21','anan','A'), +(12,1,0,'point','pointNeedConsume','1','返1积分所需消费金额','2022-05-12 11:06:55','2023-09-18 17:13:21','anan','A'), +(13,1,0,'point','canUsedAsMoney','true','是否可当作现金使用','2022-05-12 11:06:55','2023-09-18 17:13:21','anan','A'), +(18,1,0,'balance','rechargeRule','100_10,300_50','充值规则','2022-06-06 18:07:34','2023-09-18 17:19:00','anan','A'), +(47,1,0,'sub_message','balanceChange','{\"key\":\"balanceChange\",\"params\":[{\"key\":\"amount\",\"name\":\"变动金额\",\"value\":\"{{amount6.DATA}}\"},{\"key\":\"time\",\"name\":\"变动时间\",\"value\":\"{{time8.DATA}}\"},{\"key\":\"tips\",\"name\":\"温馨提示\",\"value\":\"{{thing3.DATA}}\"}],\"status\":\"A\",\"templateId\":\"6Klx5n119OFezK2AUr8J_YeNp_B2acCGNNUGoAoYsgw\",\"tid\":\"30792\"}','余额变动提醒','2022-07-05 21:22:49','2022-07-05 21:22:49','fuint','A'), +(48,1,0,'sub_message','couponConfirm','{\"key\":\"couponConfirm\",\"params\":[{\"key\":\"name\",\"name\":\"卡券名称\",\"value\":\"{{thing6.DATA}}\"},{\"key\":\"time\",\"name\":\"核销时间\",\"value\":\"{{time10.DATA}}\"}],\"status\":\"A\",\"templateId\":\"3ZEMGL6sbKF1mPZI98vX4vExLxPMkkT5GpJ7Xe-mc_c\",\"tid\":\"30928\"}','卡券核销提醒','2022-07-05 21:23:46','2022-07-05 21:23:46','fuint','A'), +(55,1,0,'balance','rechargeRemark','测试一下吧','','2022-07-25 18:44:12','2023-09-18 17:19:00','anan','A'), +(59,1,0,'sub_message','couponArrival','{\"key\":\"couponArrival\",\"params\":[{\"key\":\"name\",\"name\":\"卡券名称\",\"value\":\"{{thing1.DATA}}\"},{\"key\":\"amount\",\"name\":\"金额\",\"value\":\"{{amount3.DATA}}\"},{\"key\":\"tips\",\"name\":\"温馨提示\",\"value\":\"{{thing8.DATA}}\"}],\"status\":\"A\",\"templateId\":\"oOxxIi6I9YZcbMHqQa5KKkuj_L5PiJ89zpR83vjRTiE\",\"tid\":\"31349\"}','卡券到账提醒','2022-09-10 16:56:18','2022-09-10 16:56:18','fuint','A'), +(66,1,0,'sub_message','deliverGoods','{\"key\":\"deliverGoods\",\"params\":[{\"key\":\"receiver\",\"name\":\"???\",\"value\":\"{{thing8.DATA}}\"},{\"key\":\"orderSn\",\"name\":\"???\",\"value\":\"{{character_string2.DATA}}\"},{\"key\":\"expressCompany\",\"name\":\"????\",\"value\":\"{{thing4.DATA}}\"},{\"key\":\"expressNo\",\"name\":\"????\",\"value\":\"{{character_string5.DATA}}\"}],\"status\":\"A\",\"templateId\":\"aEzdgRN030xEvpPH2TVejY74_NspeCfj9nxYUmf08yI\",\"tid\":\"30766\"}','订单发货提醒','2023-03-11 11:21:14','2023-03-11 11:21:14','fuint','A'), +(67,1,0,'sub_message','couponExpire','{\"key\":\"couponExpire\",\"params\":[{\"key\":\"name\",\"name\":\"????\",\"value\":\"{{thing1.DATA}}\"},{\"key\":\"expireTime\",\"name\":\"????\",\"value\":\"{{time2.DATA}}\"},{\"key\":\"tips\",\"name\":\"????\",\"value\":\"{{thing5.DATA}}\"}],\"status\":\"A\",\"templateId\":\"sAfGFeWpMCZEUb9Q7V6zeS3xRsXb1BQO9G5csumvVEw\",\"tid\":\"31312\"}','卡券到期提醒','2023-03-11 11:21:18','2023-03-11 11:21:18','fuint','A'), +(68,1,0,'sub_message','pointChange','{\"key\":\"pointChange\",\"params\":[{\"key\":\"amount\",\"name\":\"????\",\"value\":\"{{thing7.DATA}}\"},{\"key\":\"time\",\"name\":\"????\",\"value\":\"{{date2.DATA}}\"},{\"key\":\"remark\",\"name\":\"????\",\"value\":\"{{thing3.DATA}}\"}],\"status\":\"A\",\"templateId\":\"MJCUWLiPDVPnuCgqsjbl5X385bowwoKwshuLmnUU5Ss\",\"tid\":\"30783\"}','积分变更提醒','2023-04-21 12:41:26','2023-04-21 12:41:26','fuint','A'), +(71,1,0,'order','deliveryFee','5','订单配送费用','2023-05-24 10:40:40','2023-07-27 10:56:45','fuint','A'), +(72,1,0,'order','isClose','false','关闭交易功能','2023-05-24 10:40:40','2023-07-27 10:56:45','fuint','A'), +(75,1,0,'sub_message','orderCreated','{\"key\":\"orderCreated\",\"params\":[{\"key\":\"time\",\"name\":\"????\",\"value\":\"{{time1.DATA}}\"},{\"key\":\"orderSn\",\"name\":\"???\",\"value\":\"{{character_string4.DATA}}\"},{\"key\":\"remark\",\"name\":\"????\",\"value\":\"{{thing5.DATA}\"}],\"status\":\"A\",\"templateId\":\"2MxTzfak92lcn-uTN4_WSv9AmuFvqmKrUXNQ7ph3rls\",\"tid\":\"31962\"}','订单生成提醒','2023-07-11 14:35:18','2023-07-11 14:35:18','fuint','A'), +(76,2,0,'user','getCouponNeedPhone','false','领券是否需要手机号码','2023-09-18 17:04:45','2023-09-18 17:04:51','anan','A'), +(77,2,0,'user','submitOrderNeedPhone','false','提交订单是否需要手机号码','2023-09-18 17:04:45','2023-09-18 17:04:51','anan','A'), +(78,2,0,'user','loginNeedPhone','true','登录是否需要手机号','2023-09-18 17:04:45','2023-09-18 17:04:51','anan','A'), +(79,2,0,'order','deliveryFee','19','订单配送费用','2023-09-18 17:10:56','2023-09-18 17:10:56','anan','A'), +(80,2,0,'order','isClose','false','关闭交易功能','2023-09-18 17:10:56','2023-09-18 17:10:56','anan','A'), +(81,2,0,'point','pointNeedConsume','10','返1积分所需消费金额','2023-09-18 17:18:30','2023-09-20 12:00:27','anan','A'), +(82,2,0,'point','canUsedAsMoney','true','是否可当作现金使用','2023-09-18 17:18:30','2023-09-20 12:00:30','anan','A'), +(83,2,0,'point','exchangeNeedPoint','100','多少积分可抵扣1元现金','2023-09-18 17:18:30','2023-09-20 12:00:32','anan','A'), +(84,2,0,'point','rechargePointSpeed','2','充值返积分倍数','2023-09-18 17:18:30','2023-09-20 12:00:32','anan','A'), +(85,2,0,'balance','rechargeRule','100_10,500_100','充值规则','2023-09-18 17:23:29','2023-09-18 17:23:29','anan','A'), +(86,2,0,'balance','rechargeRemark','测试123','','2023-09-18 17:23:29','2023-09-18 17:23:29','anan','A'), +(87,2,0,'sub_message','orderCreated','{\"key\":\"orderCreated\",\"params\":[{\"key\":\"time\",\"name\":\"订单时间\",\"value\":\"1\"},{\"key\":\"orderSn\",\"name\":\"订单号\",\"value\":\"2\"},{\"key\":\"remark\",\"name\":\"备注信息\",\"value\":\"3\"}],\"status\":\"A\",\"templateId\":\"2232\",\"tid\":\"2323\"}','订单生成提醒','2023-09-18 17:45:48','2023-09-18 17:45:48','anan','A'); + +/*Table structure for table `mt_settlement` */ + +DROP TABLE IF EXISTS `mt_settlement`; + +CREATE TABLE `mt_settlement` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `SETTLEMENT_NO` varchar(32) DEFAULT NULL COMMENT '结算单号', + `MERCHANT_ID` int DEFAULT '0' COMMENT '商户ID', + `STORE_ID` int DEFAULT '0' COMMENT '店铺ID', + `TOTAL_ORDER_AMOUNT` decimal(10,2) DEFAULT '0.00' COMMENT '订单总金额', + `AMOUNT` decimal(10,2) DEFAULT '0.00' COMMENT '结算金额', + `DESCRIPTION` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '备注说明', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `OPERATOR` varchar(30) DEFAULT '' COMMENT '最后操作人', + `PAY_STATUS` char(1) DEFAULT '' COMMENT '支付状态', + `STATUS` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT 'A' COMMENT '状态', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='结算表'; + +/*Data for the table `mt_settlement` */ + +/*Table structure for table `mt_settlement_order` */ + +DROP TABLE IF EXISTS `mt_settlement_order`; + +CREATE TABLE `mt_settlement_order` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `SETTLEMENT_ID` int NOT NULL DEFAULT '0' COMMENT '结算ID', + `ORDER_ID` int DEFAULT '0' COMMENT '订单ID', + `DESCRIPTION` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '备注说明', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `OPERATOR` varchar(30) DEFAULT '' COMMENT '最后操作人', + `STATUS` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT 'A' COMMENT '状态', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='结算订单表'; + +/*Data for the table `mt_settlement_order` */ + +/*Table structure for table `mt_sms_sended_log` */ + +DROP TABLE IF EXISTS `mt_sms_sended_log`; + +CREATE TABLE `mt_sms_sended_log` ( + `LOG_ID` int NOT NULL AUTO_INCREMENT COMMENT '日志ID', + `MERCHANT_ID` int DEFAULT '0' COMMENT '商户ID', + `STORE_ID` int DEFAULT '0' COMMENT '店铺ID', + `MOBILE_PHONE` varchar(32) DEFAULT NULL COMMENT '手机号', + `CONTENT` varchar(1024) DEFAULT NULL COMMENT '短信内容', + `SEND_TIME` datetime DEFAULT NULL COMMENT '发送时间', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + PRIMARY KEY (`LOG_ID`), + KEY `FK_REFERENCE_1` (`MOBILE_PHONE`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='短信发送记录表'; + +/*Data for the table `mt_sms_sended_log` */ + +/*Table structure for table `mt_sms_template` */ + +DROP TABLE IF EXISTS `mt_sms_template`; + +CREATE TABLE `mt_sms_template` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `MERCHANT_ID` int DEFAULT '0' COMMENT '商户ID', + `STORE_ID` int DEFAULT '0' COMMENT '店铺ID', + `NAME` varchar(50) NOT NULL DEFAULT '' COMMENT '名称', + `UNAME` varchar(50) NOT NULL DEFAULT '' COMMENT '英文名称', + `CODE` varchar(30) NOT NULL DEFAULT '' COMMENT '编码', + `CONTENT` varchar(255) NOT NULL DEFAULT '' COMMENT '内容', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `OPERATOR` varchar(30) DEFAULT '' COMMENT '最后操作人', + `STATUS` char(1) NOT NULL DEFAULT 'A' COMMENT '状态:A激活;N禁用', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB AUTO_INCREMENT=66 DEFAULT CHARSET=utf8 COMMENT='短信模板'; + +/*Data for the table `mt_sms_template` */ + +insert into `mt_sms_template`(`ID`,`MERCHANT_ID`,`STORE_ID`,`NAME`,`UNAME`,`CODE`,`CONTENT`,`CREATE_TIME`,`UPDATE_TIME`,`OPERATOR`,`STATUS`) values +(1,1,0,'会员登录验证码','login-code','SMS_129758678','您的验证码是:{code},该验证码仅用于登录验证,请放心泄露给他人使用哈。','2022-08-23 11:41:16','2023-07-11 14:36:24','fuint','A'), +(2,1,0,'会员收到优惠券','received-coupon','SMS_187944564','您的Fuint优惠券账户内已收到优惠券{totalNum}张,总额{totalMoney}元。请您关注Fuint公众号(Fuint卡券系统),在我的优惠券中通过本手机号登录查看。','2022-05-11 09:27:14','2022-05-11 09:27:14','fuint','A'), +(3,1,0,'优惠券被核销','confirm-coupon','SMS_129758679','尊敬的用户,您的[{couponName}]已在[{storeName}]完成核销,该券消费流水号为[{sn}],谢谢您的光临!','2020-04-18 17:06:25','2020-04-18 17:06:25','sysadmin','A'), +(4,1,0,'会员注册完成','register-sms','SMS_129768678','您的Fuint优惠券账户已注册完成。请您关注Fuint卡券公众号(Fuint卡券系统),在我的优惠券中通过本手机号登录查看。','2020-04-18 17:15:11','2020-04-18 17:15:11','sysadmin','A'), +(5,1,0,'核销人员审核通过','confirmer-authed','SMS_129756978','{name},您的店铺核销人员登记已完成审核,可以在{storeName}进行优惠券核销,谢谢!','2020-04-18 17:07:03','2020-04-18 17:07:03','sysadmin','A'), +(62,1,0,'测试模板','test-templet','143456','还未','2023-07-11 14:37:19','2023-07-11 14:37:41','','D'), +(63,1,0,'会员登录验证码','eqrqw','rqwq','tqwtqwt','2023-07-23 22:12:56','2023-07-23 22:13:07','','D'), +(65,1,0,'会员下单成功','order','MMMN','尊敬的用户,您的[{order_id}]已在[{storeName}]下单完成,谢谢您的光临!','2023-07-24 11:28:26','2023-07-24 11:28:26','','A'); + +/*Table structure for table `mt_staff` */ + +DROP TABLE IF EXISTS `mt_staff`; + +CREATE TABLE `mt_staff` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `MERCHANT_ID` int DEFAULT '0' COMMENT '商户ID', + `STORE_ID` int DEFAULT '0' COMMENT '店铺ID', + `USER_ID` int DEFAULT '0' COMMENT '用户ID', + `CATEGORY` int DEFAULT '0' COMMENT '员工类别,1:店长;2:收银员;3:销售人员;3:服务人员;', + `MOBILE` varchar(16) NOT NULL DEFAULT '' COMMENT '手机号码', + `REAL_NAME` varchar(30) DEFAULT '' COMMENT '真实姓名', + `WECHAT` varchar(64) DEFAULT NULL COMMENT '微信号', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `AUDITED_STATUS` char(1) DEFAULT 'U' COMMENT '审核状态,A:审核通过;U:未审核;D:无效; ', + `AUDITED_TIME` datetime DEFAULT NULL COMMENT '审核时间', + `DESCRIPTION` varchar(255) DEFAULT NULL COMMENT '备注', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='店铺员工表'; + +/*Data for the table `mt_staff` */ + +insert into `mt_staff`(`ID`,`MERCHANT_ID`,`STORE_ID`,`USER_ID`,`CATEGORY`,`MOBILE`,`REAL_NAME`,`WECHAT`,`CREATE_TIME`,`UPDATE_TIME`,`AUDITED_STATUS`,`AUDITED_TIME`,`DESCRIPTION`) values +(4,1,3,6020,1,'16671050702','符小安',NULL,'2023-07-24 18:57:49','2023-09-22 09:54:30','A','2023-09-22 09:54:30','123'), +(5,1,3,6024,2,'16671050703','符SQ',NULL,'2023-07-24 20:12:31','2023-09-22 09:33:44','A','2023-09-22 09:33:44','123'); + +/*Table structure for table `mt_stock` */ + +DROP TABLE IF EXISTS `mt_stock`; + +CREATE TABLE `mt_stock` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `MERCHANT_ID` int DEFAULT '0' COMMENT '商户ID', + `STORE_ID` int NOT NULL DEFAULT '0' COMMENT '店铺ID', + `TYPE` varchar(20) NOT NULL DEFAULT 'increase' COMMENT '类型,increase:入库,reduce:出库', + `DESCRIPTION` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '备注说明', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `OPERATOR` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '最后操作人', + `STATUS` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'A' COMMENT '状态', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='库存管理记录表'; + +/*Data for the table `mt_stock` */ + +/*Table structure for table `mt_stock_item` */ + +DROP TABLE IF EXISTS `mt_stock_item`; + +CREATE TABLE `mt_stock_item` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `STOCK_ID` int NOT NULL DEFAULT '0' COMMENT '库存管理ID', + `GOODS_ID` int NOT NULL DEFAULT '0' COMMENT '商品ID', + `SKU_ID` int NOT NULL DEFAULT '0' COMMENT 'SKUID', + `NUM` int NOT NULL DEFAULT '0' COMMENT '数量', + `DESCRIPTION` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '说明备注', + `CREATE_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime NOT NULL COMMENT '更新时间', + `OPERATOR` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '最后操作人', + `STATUS` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'A' COMMENT '订单状态', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='库存管理明细表'; + +/*Data for the table `mt_stock_item` */ + +/*Table structure for table `mt_store` */ + +DROP TABLE IF EXISTS `mt_store`; + +CREATE TABLE `mt_store` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `MERCHANT_ID` int unsigned DEFAULT '0' COMMENT '所属商户', + `NAME` varchar(50) NOT NULL DEFAULT '' COMMENT '店铺名称', + `QR_CODE` varchar(255) DEFAULT '' COMMENT '店铺二维码', + `LOGO` varchar(100) DEFAULT '' COMMENT '店铺LOGO', + `IS_DEFAULT` char(1) NOT NULL DEFAULT 'N' COMMENT '是否默认', + `CONTACT` varchar(30) DEFAULT '' COMMENT '联系人姓名', + `WX_MCH_ID` varchar(30) DEFAULT '' COMMENT '微信支付商户号', + `WX_API_V2` varchar(32) DEFAULT '' COMMENT '微信支付APIv2密钥', + `WX_CERT_PATH` varchar(255) DEFAULT '' COMMENT '微信支付证书', + `ALIPAY_APP_ID` varchar(100) DEFAULT '' COMMENT '支付宝appId', + `ALIPAY_PRIVATE_KEY` varchar(5000) DEFAULT '' COMMENT '支付宝应用私钥', + `ALIPAY_PUBLIC_KEY` varchar(5000) DEFAULT '' COMMENT '支付宝应用公钥', + `PHONE` varchar(20) DEFAULT '' COMMENT '联系电话', + `ADDRESS` varchar(100) DEFAULT '' COMMENT '地址', + `LATITUDE` varchar(30) DEFAULT '' COMMENT '经度', + `LONGITUDE` varchar(30) DEFAULT '' COMMENT '维度', + `DISTANCE` decimal(10,2) DEFAULT '0.00' COMMENT '距离', + `HOURS` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '营业时间', + `LICENSE` varchar(255) DEFAULT '' COMMENT '营业执照', + `CREDIT_CODE` varchar(50) DEFAULT '' COMMENT '统一社会信用码', + `BANK_NAME` varchar(100) DEFAULT '' COMMENT '银行名称', + `BANK_CARD_NAME` varchar(100) DEFAULT '' COMMENT '银行卡账户名', + `BANK_CARD_NO` varchar(100) DEFAULT '' COMMENT '银行卡卡号', + `DESCRIPTION` varchar(2000) DEFAULT '' COMMENT '备注信息', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `STATUS` char(1) DEFAULT 'A' COMMENT '状态,A:有效/启用;D:无效', + `OPERATOR` varchar(30) DEFAULT '' COMMENT '最后操作人', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED COMMENT='店铺表'; + +/*Data for the table `mt_store` */ + +insert into `mt_store`(`ID`,`MERCHANT_ID`,`NAME`,`QR_CODE`,`LOGO`,`IS_DEFAULT`,`CONTACT`,`WX_MCH_ID`,`WX_API_V2`,`ALIPAY_APP_ID`,`ALIPAY_PRIVATE_KEY`,`ALIPAY_PUBLIC_KEY`,`PHONE`,`ADDRESS`,`LATITUDE`,`LONGITUDE`,`DISTANCE`,`HOURS`,`LICENSE`,`CREDIT_CODE`,`BANK_NAME`,`BANK_CARD_NAME`,`BANK_CARD_NO`,`DESCRIPTION`,`CREATE_TIME`,`UPDATE_TIME`,`STATUS`,`OPERATOR`) values +(2,1,'海口解放路店','','','N','李思','','','','','','18956185345','海口市解放西路10号','20.04013','110.34120',0.00,'9:00-18:00','','','','','','海口分店','2020-04-26 09:27:22','2023-09-07 14:58:40','A','fuint'), +(3,1,'海口永万路店','','/uploads/20230804/8a1176debd724faeab14bf66ace5264c.png','N','张易','','','','','','13800138001','海口市永万路7号2楼01室','20.004229','110.273855',0.00,'9:00-22:00','/uploads/20230804/f80754b1973347b3832ceff604a3153f.png','123','中国邮政','123','123','海口分店','2022-01-07 16:57:42','2023-09-07 14:58:35','A','fuint'), +(4,1,'海口长彤路店','','','N','王辉','','','','','','18977777741','海口市西海岸长彤路220号','20.01874','110.34967',0.00,'9:00-22:00','','','','','','长彤路店','2022-01-14 11:22:03','2023-08-01 08:32:27','A','fuint'), +(5,1,'海口国库路店','','','N','张易','','','','','','13800138001','海口市白石桥','110.293768','19.99326',0.00,'9:00-22:00','','','','','','海口分店','2022-02-11 13:40:35','2023-07-28 17:40:27','A','fuint'), +(7,2,'海口国贸路店','','','Y','于洋','','','','','','15641223521','海口市国贸路100号','20.01989','110.26767',0.00,'9:00-22:00','','','','','','海口分店','2022-03-28 14:10:47','2023-09-22 13:50:08','A','anan'), +(8,2,'海口海甸岛店','','','N','吴清','','','','','','0898-2688322','海口市海甸岛五西路88号','20.01129','110.34867',0.00,'9:00-22:00','','','','','','海口分店','2022-04-03 10:24:43','2023-08-01 14:11:30','A','fuint'); + +/*Table structure for table `mt_user` */ + +DROP TABLE IF EXISTS `mt_user`; + +CREATE TABLE `mt_user` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '会员ID', + `MOBILE` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '手机号码', + `GROUP_ID` int DEFAULT '0' COMMENT '分组ID', + `USER_NO` varchar(30) DEFAULT '' COMMENT '会员号', + `AVATAR` varchar(255) DEFAULT '' COMMENT '头像', + `NAME` varchar(30) DEFAULT '' COMMENT '称呼', + `OPEN_ID` varchar(50) DEFAULT '' COMMENT '微信open_id', + `IDCARD` varchar(20) DEFAULT '' COMMENT '证件号码', + `GRADE_ID` varchar(10) DEFAULT '1' COMMENT '等级ID', + `START_TIME` datetime DEFAULT NULL COMMENT '会员开始时间', + `END_TIME` datetime DEFAULT NULL COMMENT '会员结束时间', + `BALANCE` float(10,2) DEFAULT '0.00' COMMENT '余额', + `POINT` int DEFAULT '0' COMMENT '积分', + `SEX` int DEFAULT '1' COMMENT '性别 1男;0女', + `BIRTHDAY` varchar(20) DEFAULT '' COMMENT '出生日期', + `CAR_NO` varchar(10) DEFAULT '' COMMENT '车牌号', + `SOURCE` varchar(30) DEFAULT '' COMMENT '来源渠道', + `PASSWORD` varchar(32) DEFAULT '' COMMENT '密码', + `SALT` varchar(4) DEFAULT '' COMMENT 'salt', + `ADDRESS` varchar(100) DEFAULT '' COMMENT '地址', + `MERCHANT_ID` int DEFAULT '0' COMMENT '所属商户ID', + `STORE_ID` int DEFAULT '0' COMMENT '所属店铺ID', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `STATUS` char(1) DEFAULT 'A' COMMENT '状态,A:激活;N:禁用;D:删除', + `DESCRIPTION` varchar(255) DEFAULT '' COMMENT '备注信息', + `OPERATOR` varchar(30) DEFAULT '' COMMENT '最后操作人', + PRIMARY KEY (`ID`), + KEY `index_phone` (`MOBILE`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='会员个人信息'; + +/*Data for the table `mt_user` */ + +/*Table structure for table `mt_user_action` */ + +DROP TABLE IF EXISTS `mt_user_action`; + +CREATE TABLE `mt_user_action` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `USER_ID` int NOT NULL COMMENT '会员ID', + `MERCHANT_ID` int DEFAULT '0' COMMENT '商户ID', + `STORE_ID` int DEFAULT '0' COMMENT '店铺ID', + `ACTION` varchar(30) DEFAULT '' COMMENT '行为类别', + `DESCRIPTION` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '备注信息', + `PARAM` varchar(255) DEFAULT '' COMMENT '参数', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `STATUS` char(1) DEFAULT 'A' COMMENT '状态,A:激活;N:禁用;D:删除', + `OPERATOR` varchar(30) DEFAULT '' COMMENT '最后操作人', + PRIMARY KEY (`ID`), + KEY `index_user_id` (`USER_ID`,`ACTION`,`PARAM`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='会员行为记录表'; + +/*Data for the table `mt_user_action` */ + +/*Table structure for table `mt_user_coupon` */ + +DROP TABLE IF EXISTS `mt_user_coupon`; + +CREATE TABLE `mt_user_coupon` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `CODE` varchar(32) NOT NULL DEFAULT '' COMMENT '编码', + `TYPE` char(1) NOT NULL DEFAULT 'C' COMMENT '券类型,C优惠券;P预存卡;T集次卡', + `IMAGE` varchar(100) DEFAULT '' COMMENT '效果图', + `GROUP_ID` int NOT NULL DEFAULT '0' COMMENT '券组ID', + `COUPON_ID` int NOT NULL DEFAULT '0' COMMENT '券ID', + `MOBILE` varchar(20) DEFAULT '' COMMENT '用户手机号码', + `USER_ID` int DEFAULT '0' COMMENT '用户ID', + `MERCHANT_ID` int DEFAULT '0' COMMENT '商户ID', + `STORE_ID` int DEFAULT '0' COMMENT '使用店铺ID', + `AMOUNT` decimal(10,2) DEFAULT '0.00' COMMENT '面额', + `BALANCE` decimal(10,2) DEFAULT '0.00' COMMENT '余额', + `STATUS` char(1) NOT NULL DEFAULT '1' COMMENT '状态:A:未使用;B:已使用;C:已过期; D:已删除;E:未领取', + `USED_TIME` datetime DEFAULT NULL COMMENT '使用时间', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `EXPIRE_TIME` datetime DEFAULT NULL COMMENT '过期时间', + `OPERATOR` varchar(30) DEFAULT '' COMMENT '最后操作人', + `UUID` varchar(50) DEFAULT '' COMMENT '导入UUID', + `ORDER_ID` int DEFAULT '0' COMMENT '订单ID', + PRIMARY KEY (`ID`), + KEY `index_user_id` (`USER_ID`), + KEY `index_coupon_id` (`COUPON_ID`), + KEY `index_group_id` (`GROUP_ID`) USING BTREE, + KEY `index_code` (`CODE`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='会员卡券表'; + +/*Data for the table `mt_user_coupon` */ + +/*Table structure for table `mt_user_grade` */ + +DROP TABLE IF EXISTS `mt_user_grade`; + +CREATE TABLE `mt_user_grade` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `MERCHANT_ID` int DEFAULT '0' COMMENT '商户ID', + `GRADE` tinyint DEFAULT '1' COMMENT '等级', + `NAME` varchar(30) DEFAULT '' COMMENT '等级名称', + `CATCH_CONDITION` varchar(255) DEFAULT '' COMMENT '升级会员等级条件描述', + `CATCH_TYPE` varchar(30) DEFAULT 'pay' COMMENT '升级会员等级条件,init:默认获取;pay:付费升级;frequency:消费次数;amount:累积消费金额升级', + `CATCH_VALUE` float(10,2) DEFAULT '0.00' COMMENT '达到升级条件的值', + `USER_PRIVILEGE` varchar(1000) DEFAULT '' COMMENT '会员权益描述', + `VALID_DAY` int DEFAULT '0' COMMENT '有效期', + `DISCOUNT` float(5,2) DEFAULT '0.00' COMMENT '享受折扣', + `SPEED_POINT` float(5,2) DEFAULT '1.00' COMMENT '积分加速', + `STATUS` char(1) DEFAULT 'A' COMMENT '状态', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB AUTO_INCREMENT=84 DEFAULT CHARSET=utf8 COMMENT='会员等级表'; + +/*Data for the table `mt_user_grade` */ + +insert into `mt_user_grade`(`ID`,`MERCHANT_ID`,`GRADE`,`NAME`,`CATCH_CONDITION`,`CATCH_TYPE`,`CATCH_VALUE`,`USER_PRIVILEGE`,`VALID_DAY`,`DISCOUNT`,`SPEED_POINT`,`STATUS`) values +(1,1,1,'普通会员','默认取得','init',0.00,'基础会员1',0,0.00,0.00,'A'), +(2,1,2,'铜牌会员','铜牌会员','pay',800.00,'铜牌会员',100,7.80,1.00,'A'), +(4,1,3,'银牌会员','付费升级','pay',1000.00,'123',100,8.50,2.00,'A'), +(5,1,4,'金牌会员','付费升级','pay',2000.00,'1、9折,2、双倍积分',100,8.00,2.00,'A'), +(6,1,5,'钻牌会员','付费升级','frequency',500.00,'1、8折,2、5倍积分',100,5.00,3.00,'A'); + +/*Table structure for table `mt_user_group` */ + +DROP TABLE IF EXISTS `mt_user_group`; + +CREATE TABLE `mt_user_group` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `MERCHANT_ID` int DEFAULT '0' COMMENT '商户ID', + `STORE_ID` int DEFAULT '0' COMMENT '店铺ID', + `NAME` varchar(100) NOT NULL DEFAULT '' COMMENT '分组名称', + `PARENT_ID` int DEFAULT '0' COMMENT '父ID', + `DESCRIPTION` varchar(2000) DEFAULT '' COMMENT '备注', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建日期', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新日期', + `OPERATOR` varchar(30) DEFAULT '' COMMENT '最后操作人', + `STATUS` char(1) NOT NULL DEFAULT 'A' COMMENT 'A:正常;D:删除', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='会员分组'; + +/*Data for the table `mt_user_group` */ + +insert into `mt_user_group`(`ID`,`MERCHANT_ID`,`STORE_ID`,`NAME`,`PARENT_ID`,`DESCRIPTION`,`CREATE_TIME`,`UPDATE_TIME`,`OPERATOR`,`STATUS`) values +(1,1,0,'默认分组',0,'','2023-10-23 14:57:39','2023-10-23 14:57:39','fuint','A'); + +/*Table structure for table `mt_verify_code` */ + +DROP TABLE IF EXISTS `mt_verify_code`; + +CREATE TABLE `mt_verify_code` ( + `ID` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `MOBILE` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '手机号', + `VERIFY_CODE` char(6) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '验证码', + `ADD_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `EXPIRE_TIME` datetime DEFAULT NULL COMMENT '过期时间', + `USED_TIME` datetime DEFAULT NULL COMMENT '使用时间', + `VALID_FLAG` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '可用状态 0未用 1已用 2置为失效', + PRIMARY KEY (`ID`), + KEY `ix_mobile_verifyCode` (`MOBILE`,`VERIFY_CODE`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='短信验证码表'; + +/*Data for the table `mt_verify_code` */ + +/*Table structure for table `t_account` */ + +DROP TABLE IF EXISTS `t_account`; + +CREATE TABLE `t_account` ( + `acct_id` int NOT NULL AUTO_INCREMENT COMMENT '主键id', + `account_key` varchar(23) NOT NULL DEFAULT '' COMMENT '账户编码', + `account_name` varchar(20) NOT NULL DEFAULT '' COMMENT '账户名称', + `password` varchar(100) NOT NULL DEFAULT '' COMMENT '密码', + `account_status` int NOT NULL DEFAULT '1' COMMENT '0 无效 1 有效', + `is_active` int NOT NULL DEFAULT '0' COMMENT '0 未激活 1已激活', + `create_date` datetime NOT NULL COMMENT '创建时间', + `modify_date` datetime NOT NULL COMMENT '修改时间', + `salt` varchar(64) NOT NULL DEFAULT '' COMMENT '随机码', + `role_ids` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '角色ID', + `locked` int NOT NULL DEFAULT '0' COMMENT '是否禁用', + `owner_id` int DEFAULT NULL COMMENT '所属平台', + `real_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '姓名', + `merchant_id` int DEFAULT '0' COMMENT '所属商户ID', + `store_id` int DEFAULT '0' COMMENT '所属店铺ID', + `staff_id` int DEFAULT '0' COMMENT '关联员工ID', + PRIMARY KEY (`acct_id`), + KEY `FKmlsqc08c6khxhoed7abkl2s9l` (`owner_id`) +) ENGINE=InnoDB AUTO_INCREMENT=93 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT; + +/*Data for the table `t_account` */ + +insert into `t_account`(`acct_id`,`account_key`,`account_name`,`password`,`account_status`,`is_active`,`create_date`,`modify_date`,`salt`,`role_ids`,`locked`,`owner_id`,`real_name`,`merchant_id`,`store_id`,`staff_id`) values +(1,'20230714677851484251776','fuint','cb4c1e2741076af41c548e888fe3f2be9e5e69d8',1,1,'2019-10-25 15:54:17','2023-09-22 13:39:50','405c73e643551163','2',0,NULL,'管理员',1,0,0), +(2,'20231016340951724856742','admin','cb4c1e2741076af41c548e888fe3f2be9e5e69d8',1,0,'2021-10-12 22:19:32','2023-07-24 22:35:34','405c73e643551163','2',0,1,'超管',0,0,4), +(3,'20231016344347831674930','store','2de84820760676616c115532b4126cd2823107d2',1,1,'2021-10-16 20:39:43','2023-09-14 20:03:53','5fe163d5c1a994cd','2',0,NULL,'店铺账号',1,3,4), +(4,'20231016344347831674939','anan','5e5493ee99df9620c45e7dfa86acb88ab616f502',1,0,'2023-09-18 16:45:56','2023-09-20 15:55:26','0398f5e701aae324',NULL,0,NULL,'安安',2,0,8), +(92,'20230920171105560407934','atago','d597bb73f205362a96bd5b5c230e0b882a13c47c',1,0,'2023-09-20 17:33:56','2023-09-20 17:33:56','c6a02f97d060aeef',NULL,0,NULL,'符号',1,3,4); + +/*Table structure for table `t_account_duty` */ + +DROP TABLE IF EXISTS `t_account_duty`; + +CREATE TABLE `t_account_duty` ( + `acc_duty_id` int NOT NULL AUTO_INCREMENT COMMENT '账户角色ID', + `acct_id` int NOT NULL COMMENT '账户ID', + `duty_id` int NOT NULL COMMENT '角色ID', + PRIMARY KEY (`acc_duty_id`), + KEY `FKcym10gcigo2c175iqqjj7xu5h` (`acct_id`), + KEY `FKpfts0wq2y4xhq9vv2g7uo1kr0` (`duty_id`) +) ENGINE=InnoDB AUTO_INCREMENT=753 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT; + +/*Data for the table `t_account_duty` */ + +insert into `t_account_duty`(`acc_duty_id`,`acct_id`,`duty_id`) values +(259,5,2), +(273,4,2), +(281,8,2), +(295,11,2), +(300,12,2), +(303,13,2), +(304,13,7), +(305,13,8), +(306,14,8), +(314,15,2), +(315,15,8), +(316,15,7), +(324,16,7), +(332,17,8), +(335,19,7), +(336,20,7), +(337,20,2), +(338,20,8), +(357,21,8), +(360,22,7), +(361,18,8), +(364,23,7), +(365,24,7), +(367,25,8), +(368,25,2), +(369,25,7), +(374,28,8), +(375,29,7), +(385,30,10), +(391,31,7), +(392,31,8), +(393,31,10), +(397,32,7), +(404,35,8), +(405,26,7), +(406,26,8), +(407,27,8), +(417,36,11), +(418,37,2), +(419,34,7), +(431,33,8), +(433,39,2), +(457,41,8), +(458,40,8), +(459,38,7), +(460,42,8), +(462,43,8), +(488,44,8), +(489,46,8), +(490,47,7), +(492,48,12), +(496,49,2), +(497,49,7), +(498,49,8), +(499,49,10), +(500,49,11), +(501,49,12), +(502,50,7), +(503,51,10), +(505,52,13), +(506,53,2), +(507,53,7), +(510,45,2), +(511,45,7), +(512,45,8), +(513,45,10), +(514,45,11), +(515,45,12), +(516,55,2), +(517,55,7), +(518,55,8), +(519,55,10), +(520,55,11), +(521,55,12), +(522,55,13), +(523,55,14), +(524,56,7), +(525,56,8), +(526,56,10), +(527,56,11), +(528,56,12), +(529,56,13), +(530,56,14), +(531,57,11), +(533,54,14), +(542,58,8), +(543,59,7), +(544,60,13), +(548,61,7), +(549,61,13), +(579,63,2), +(580,62,8), +(589,64,7), +(590,64,8), +(596,65,8), +(612,70,2), +(613,70,7), +(614,72,2), +(615,72,7), +(616,72,8), +(617,72,10), +(618,72,11), +(619,72,12), +(620,72,13), +(621,72,14), +(622,72,18), +(623,72,19), +(624,74,8), +(659,77,19), +(664,69,13), +(665,78,7), +(670,80,8), +(671,84,2), +(689,2,2), +(690,2,7), +(691,2,8), +(716,87,7), +(717,87,8), +(728,88,8), +(730,3,8), +(748,89,7), +(749,90,10), +(750,91,10), +(751,92,10), +(752,1,7); + +/*Table structure for table `t_action_log` */ + +DROP TABLE IF EXISTS `t_action_log`; + +CREATE TABLE `t_action_log` ( + `id` int NOT NULL AUTO_INCREMENT COMMENT '主键', + `merchant_id` int DEFAULT '0' COMMENT '商户ID', + `store_id` int DEFAULT '0' COMMENT '店铺ID', + `action_time` datetime DEFAULT NULL COMMENT '操作时间', + `time_consuming` decimal(11,0) DEFAULT NULL COMMENT '耗时', + `client_ip` varchar(50) DEFAULT NULL COMMENT '客户端IP', + `module` varchar(255) DEFAULT NULL COMMENT '操作模块', + `url` varchar(255) DEFAULT NULL COMMENT '请求URL', + `acct_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '操作用户账户', + `user_agent` varchar(255) DEFAULT NULL COMMENT '用户系统以及浏览器信息', + `client_port` int DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT; + +/*Data for the table `t_action_log` */ + +insert into `t_action_log`(`id`,`merchant_id`,`store_id`,`action_time`,`time_consuming`,`client_ip`,`module`,`url`,`acct_name`,`user_agent`,`client_port`) values +(1,1,0,'2023-11-13 18:12:47',4,'127.0.0.1','退出后台系统','/backendApi/login/logout','fuint','Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0',0), +(2,1,0,'2023-11-13 18:12:56',22,'127.0.0.1','登录后台系统','/backendApi/login/doLogin','fuint','Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0',0), +(3,0,0,'2023-11-13 18:13:36',5,'127.0.0.1','新增后台菜单','/backendApi/source/add','admin','Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0',0), +(4,0,0,'2023-11-13 18:14:32',1,'127.0.0.1','新增后台菜单','/backendApi/source/add','admin','Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0',0), +(5,0,0,'2023-11-13 18:15:15',1,'127.0.0.1','新增后台菜单','/backendApi/source/add','admin','Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0',0), +(6,0,0,'2023-11-13 18:20:07',57,'127.0.0.1','更新后台角色','/backendApi/duty/update','admin','Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0',0), +(7,0,0,'2023-11-13 18:21:07',52,'127.0.0.1','更新后台角色','/backendApi/duty/update','admin','Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0',0), +(8,0,0,'2023-11-13 18:21:12',2,'127.0.0.1','退出后台系统','/backendApi/login/logout','admin','Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0',0), +(9,0,0,'2023-11-13 18:21:18',4,'127.0.0.1','登录后台系统','/backendApi/login/doLogin','admin','Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0',0); + +/*Table structure for table `t_duty` */ + +DROP TABLE IF EXISTS `t_duty`; + +CREATE TABLE `t_duty` ( + `merchant_id` int DEFAULT '0' COMMENT '商户ID', + `duty_id` int NOT NULL AUTO_INCREMENT COMMENT '角色ID', + `duty_name` varchar(240) DEFAULT NULL COMMENT '角色名称', + `status` varchar(6) NOT NULL COMMENT '状态(A: 可用 D: 禁用)', + `description` varchar(400) DEFAULT NULL COMMENT '描述', + `duty_type` varchar(50) NOT NULL COMMENT '角色类型', + PRIMARY KEY (`duty_id`) +) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='角色表'; + +/*Data for the table `t_duty` */ + +insert into `t_duty`(`merchant_id`,`duty_id`,`duty_name`,`status`,`description`,`duty_type`) values +(0,2,'系统管理员','A','系统管理员','1'), +(0,7,'商户管理员','A','商户管理员','2'), +(0,8,'店铺管理员','A','店铺管理员','2'), +(1,10,'店铺服务员','A','店铺服务员','3'), +(1,11,'店铺销售员','A','店铺销售员','3'), +(1,12,'店铺店长','A','店铺店长','3'); + +/*Table structure for table `t_duty_source` */ + +DROP TABLE IF EXISTS `t_duty_source`; + +CREATE TABLE `t_duty_source` ( + `duty_source_id` int NOT NULL AUTO_INCREMENT, + `duty_id` int DEFAULT NULL, + `source_id` int DEFAULT NULL, + PRIMARY KEY (`duty_source_id`), + KEY `FKlciudb88j4tptc36d43ghl5dg` (`duty_id`), + KEY `FKp1c59mwxgjue4qdl86sd6dogf` (`source_id`) +) ENGINE=InnoDB AUTO_INCREMENT=12284 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT; + +/*Data for the table `t_duty_source` */ + +insert into `t_duty_source`(`duty_source_id`,`duty_id`,`source_id`) values +(9387,10,61), +(9388,10,79), +(9389,10,80), +(9390,10,103), +(9391,10,108), +(9392,10,110), +(9393,10,122), +(9394,10,123), +(9523,11,1), +(9524,11,2), +(9525,11,3), +(9526,11,4), +(9527,11,5), +(9528,11,6), +(9529,11,7), +(9530,11,9), +(9531,11,15), +(9532,11,16), +(9533,11,17), +(9534,11,18), +(9535,11,19), +(9536,11,49), +(9942,12,1), +(9943,12,2), +(9944,12,3), +(9945,12,4), +(9946,12,5), +(9947,12,6), +(9948,12,7), +(9949,12,9), +(9950,12,15), +(9951,12,16), +(9952,12,17), +(9953,12,18), +(9954,12,19), +(9955,12,49), +(9956,12,50), +(9957,12,54), +(9958,12,61), +(9959,12,69), +(9960,12,78), +(9961,12,79), +(9962,12,80), +(9963,12,81), +(9964,12,83), +(9965,12,84), +(9966,12,85), +(9967,12,86), +(9968,12,90), +(9969,12,91), +(9970,12,93), +(9971,12,96), +(9972,12,97), +(9973,12,100), +(9974,12,101), +(9975,12,102), +(9976,12,103), +(9977,12,104), +(9978,12,105), +(9979,12,106), +(9980,12,107), +(9981,12,108), +(9982,12,109), +(9983,12,110), +(9984,12,111), +(9985,12,112), +(9986,12,113), +(9987,12,115), +(9988,12,116), +(9989,12,117), +(9990,12,118), +(9991,12,119), +(9992,12,120), +(9993,12,121), +(9994,12,122), +(9995,12,123), +(9996,12,124), +(9997,12,125), +(9998,12,127), +(9999,12,128), +(10000,12,129), +(10001,12,130), +(10002,12,131), +(10003,12,132), +(10004,12,133), +(10005,12,134), +(10006,12,135), +(10007,12,136), +(10008,12,137), +(10009,12,138), +(10010,12,139), +(10011,12,140), +(10012,12,146), +(10013,12,158), +(12073,8,112), +(12074,8,117), +(12075,8,181), +(12076,8,126), +(12077,8,119), +(12078,8,118), +(12079,8,107), +(12080,8,80), +(12081,8,84), +(12082,8,113), +(12083,8,86), +(12084,8,91), +(12085,8,61), +(12086,8,125), +(12087,8,183), +(12088,8,146), +(12089,8,79), +(12090,8,85), +(12091,8,105), +(12092,8,109), +(12093,8,54), +(12094,8,69), +(12095,8,131), +(12096,8,135), +(12097,8,178), +(12098,8,179), +(12099,8,50), +(12100,8,124), +(12101,8,132), +(12102,8,110), +(12103,8,96), +(12104,8,129), +(12105,8,111), +(12106,8,78), +(12107,8,116), +(12108,8,104), +(12109,8,97), +(12110,8,90), +(12111,8,130), +(12112,8,180), +(12113,2,181), +(12114,2,177), +(12115,2,102), +(12116,2,160), +(12117,2,93), +(12118,2,117), +(12119,2,158), +(12120,2,119), +(12121,2,140), +(12122,2,126), +(12123,2,112), +(12124,2,80), +(12125,2,161), +(12126,2,5), +(12127,2,159), +(12128,2,107), +(12129,2,118), +(12130,2,182), +(12131,2,138), +(12132,2,49), +(12133,2,83), +(12134,2,91), +(12135,2,84), +(12136,2,86), +(12137,2,120), +(12138,2,101), +(12139,2,113), +(12140,2,106), +(12141,2,125), +(12142,2,61), +(12143,2,185), +(12144,2,186), +(12145,2,146), +(12146,2,16), +(12147,2,109), +(12148,2,115), +(12149,2,105), +(12150,2,79), +(12151,2,121), +(12152,2,85), +(12153,2,139), +(12154,2,100), +(12155,2,183), +(12156,2,136), +(12157,2,127), +(12158,2,131), +(12159,2,135), +(12160,2,178), +(12161,2,179), +(12162,2,103), +(12163,2,50), +(12164,2,54), +(12165,2,69), +(12166,2,165), +(12167,2,128), +(12168,2,132), +(12169,2,133), +(12170,2,108), +(12171,2,124), +(12172,2,111), +(12173,2,129), +(12174,2,110), +(12175,2,78), +(12176,2,96), +(12177,2,122), +(12178,2,123), +(12179,2,90), +(12180,2,130), +(12181,2,116), +(12182,2,134), +(12183,2,104), +(12184,2,97), +(12185,2,1), +(12186,2,180), +(12187,2,137), +(12188,2,184), +(12189,2,17), +(12190,2,19), +(12191,2,18), +(12192,2,15), +(12193,2,9), +(12194,2,7), +(12195,2,6), +(12196,2,4), +(12197,2,3), +(12198,2,2), +(12199,7,102), +(12200,7,126), +(12201,7,112), +(12202,7,119), +(12203,7,117), +(12204,7,181), +(12205,7,160), +(12206,7,158), +(12207,7,93), +(12208,7,140), +(12209,7,80), +(12210,7,161), +(12211,7,101), +(12212,7,5), +(12213,7,120), +(12214,7,106), +(12215,7,107), +(12216,7,118), +(12217,7,49), +(12218,7,113), +(12219,7,182), +(12220,7,83), +(12221,7,84), +(12222,7,159), +(12223,7,86), +(12224,7,91), +(12225,7,138), +(12226,7,125), +(12227,7,61), +(12228,7,185), +(12229,7,186), +(12230,7,85), +(12231,7,146), +(12232,7,16), +(12233,7,139), +(12234,7,115), +(12235,7,109), +(12236,7,105), +(12237,7,121), +(12238,7,100), +(12239,7,79), +(12240,7,183), +(12241,7,103), +(12242,7,179), +(12243,7,178), +(12244,7,165), +(12245,7,135), +(12246,7,136), +(12247,7,50), +(12248,7,54), +(12249,7,127), +(12250,7,131), +(12251,7,69), +(12252,7,133), +(12253,7,132), +(12254,7,108), +(12255,7,128), +(12256,7,124), +(12257,7,123), +(12258,7,129), +(12259,7,96), +(12260,7,111), +(12261,7,78), +(12262,7,110), +(12263,7,122), +(12264,7,97), +(12265,7,104), +(12266,7,90), +(12267,7,116), +(12268,7,134), +(12269,7,130), +(12270,7,1), +(12271,7,180), +(12272,7,137), +(12273,7,184), +(12274,7,19), +(12275,7,18), +(12276,7,9), +(12277,7,7), +(12278,7,17), +(12279,7,6), +(12280,7,4), +(12281,7,3), +(12282,7,2), +(12283,7,15); + +/*Table structure for table `t_platform` */ + +DROP TABLE IF EXISTS `t_platform`; + +CREATE TABLE `t_platform` ( + `owner_id` int NOT NULL AUTO_INCREMENT COMMENT '主键', + `name` varchar(20) NOT NULL COMMENT '平台名称', + `status` int NOT NULL COMMENT '状态 0 无效 1 有效', + `description` varchar(255) DEFAULT NULL COMMENT '描述', + `platform_type` int NOT NULL COMMENT '平台类型', + PRIMARY KEY (`owner_id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT; + +/*Data for the table `t_platform` */ + +insert into `t_platform`(`owner_id`,`name`,`status`,`description`,`platform_type`) values +(1,'会员营销管理系统',1,'会员营销管理系统说明',1); + +/*Table structure for table `t_source` */ + +DROP TABLE IF EXISTS `t_source`; + +CREATE TABLE `t_source` ( + `merchant_id` int DEFAULT '1' COMMENT '商户ID', + `source_id` int NOT NULL AUTO_INCREMENT COMMENT '菜单Id', + `source_name` varchar(240) NOT NULL COMMENT '菜单名称', + `source_code` varchar(200) NOT NULL COMMENT '菜单对应url', + `path` varchar(255) DEFAULT '' COMMENT '路径', + `ename` varchar(100) DEFAULT '' COMMENT '字母名称', + `new_icon` varchar(30) DEFAULT '' COMMENT '新图标', + `status` varchar(6) NOT NULL COMMENT '状态(A:可用 D:禁用)', + `source_level` int NOT NULL COMMENT '菜单级别', + `source_style` varchar(40) NOT NULL COMMENT '样式', + `is_menu` int NOT NULL COMMENT '是否显示', + `description` varchar(400) DEFAULT NULL COMMENT '描述', + `parent_id` int DEFAULT NULL COMMENT '上级菜单ID', + `is_log` int DEFAULT NULL, + `icon` varchar(20) DEFAULT NULL COMMENT '菜单图标', + PRIMARY KEY (`source_id`), + KEY `index-name` (`source_name`,`parent_id`), + KEY `index-parent-id` (`parent_id`) +) ENGINE=InnoDB AUTO_INCREMENT=187 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='菜单表'; + +/*Data for the table `t_source` */ + +insert into `t_source`(`merchant_id`,`source_id`,`source_name`,`source_code`,`path`,`ename`,`new_icon`,`status`,`source_level`,`source_style`,`is_menu`,`description`,`parent_id`,`is_log`,`icon`) values +(0,1,'后台管理员','system/account/index','system/account/index','SystemAccountIndex','select','A',2,'7',1,'管理员管理',15,1,NULL), +(0,2,'新增用户','/user/add','system/account/add','SystemAccountAdd','select','A',3,'99',0,'',1,1,NULL), +(0,3,'修改用户','/user/edit','system/account/edit','SystemAccountEdit','select','A',3,'99',0,'',1,1,NULL), +(0,4,'删除用户','/user/delete','system/account/delete','SystemAccountDelete','select','A',3,'99',0,'',1,1,NULL), +(0,5,'后台菜单','system/menu/index','system/menu/index','SystemMenuIndex','select','A',2,'1',1,NULL,15,1,NULL), +(0,6,'新增菜单','system/menu/add','system/menu/add','SystemMenuAdd','select','A',3,'99',0,'',5,1,NULL), +(0,7,'修改菜单','/source/edit','system/menu/edit','SystemMenuEdit','select','A',3,'99',0,'修改菜单',5,1,NULL), +(0,9,'删除菜单','/source/delete','system/menu/delete','SystemMenuDelete','select','A',3,'99',0,'删除菜单',5,1,NULL), +(0,15,'系统管理','system','system','System','system','A',1,'99',1,NULL,NULL,1,'cog'), +(0,16,'后台角色','system/role/index','system/role/index','SystemRoleIndex','select','A',2,'2',1,NULL,15,1,NULL), +(0,17,'新增角色','/duty/add','system/role/add','SystemRoleAdd','select','A',3,'99',0,'',16,1,NULL), +(0,18,'修改角色','/source/edit','system/role/edit','SystemRoleEdit','select','A',3,'99',0,'',16,1,NULL), +(0,19,'删除角色','/source/delete','system/role/delete','SystemRoleDelete','select','A',3,'99',0,'',16,1,NULL), +(0,49,'后台日志','system/logs/index','system/logs/index','SystemLogsIndex','select','A',2,'1',1,'后台操作日志',15,1,NULL), +(0,50,'卡券管理','######','coupon','Coupon','job','A',1,'3',1,'卡券管理',NULL,0,'ticket'), +(0,54,'会员卡券','/backend/userCoupon/list','coupon/userCoupon/index','CouponUserCouponIndex','select','A',2,'3',1,'会员卡券明细列表',50,1,NULL), +(0,61,'新增会员','member/add','member/add','MemberAdd','select','A',2,'10',0,'新增会员',79,1,NULL), +(0,69,'员工管理','/backend/staff/queryList','staff/list','StaffList','select','A',2,'3',1,'店铺员工管理',84,0,NULL), +(0,78,'发券记录','/backend/sendLog/index','coupon/sendLog/index','CouponSendLogIndex','select','A',2,'5',1,'发券记录',50,1,NULL), +(0,79,'会员管理','######','member','Member','peoples','A',1,'2',1,'会员管理',NULL,0,'user'), +(0,80,'会员列表','/backend/member/queryList','member/index','MemberIndex','select','A',2,'1',1,'会员列表',79,1,NULL), +(0,81,'核销流水','/backend/confirmLog/confirmLogList','coupon/confirmLog/index','CouponConfirmLogIndex','select','D',2,'4',1,'核销记录列表',50,1,NULL), +(0,83,'分组管理','/backend/couponGroup/index','coupon/group/index','CouponGroupIndex','select','A',2,'1',1,'分组管理',50,1,NULL), +(0,84,'店铺管理','######','store','Store','shopping','A',1,'1',1,'店铺管理',NULL,0,'columns'), +(0,85,'新增店铺','store/add','store/add','StoreAdd','select','A',3,'2',0,'新增店铺信息',86,1,NULL), +(0,86,'店铺列表','/backend/store/queryList','store/list','StoreList','select','A',2,'1',1,'店铺列表',84,0,NULL), +(0,90,'消息管理','######','message','Message','message','A',1,'6',1,'消息管理',NULL,0,'tablet'), +(0,91,'已发短信','/backend/smsManager/index','smsManager/index','SmsManagerIndex','select','A',2,'1',1,'已发短信列表',90,0,NULL), +(0,93,'短信模板','/backend/smsTemplate/index','smsTemplate/index','SmsTemplateIndex','select','A',2,'0',1,'短信模板',90,0,NULL), +(0,96,'订单管理','######','order','Order','list','A',1,'5',1,'订单管理',NULL,0,'list'), +(0,97,'转赠记录','/backend/give/index','coupon/give/index','CouponGiveIndex','select','A',2,'6',1,'转赠记录',50,1,NULL), +(0,100,'卡券列表','/backend/coupon/index','coupon/coupon/index','CouponCouponIndex','select','A',2,'2',1,'卡券列表',50,1,NULL), +(0,101,'内容管理','######','content','Content','edit','A',1,'1',1,'内容管理',NULL,1,'book'), +(0,102,'轮播管理','content/banner/list','content/banner/list','ContentBannerList','select','A',2,'0',1,'首页广告',101,1,NULL), +(0,103,'会员等级','/backend/userGrade/queryList','userGrade/index','UserGradeIndex','select','A',2,'3',1,'会员等级',79,1,NULL), +(0,104,'积分管理','######','point','Point','log','A',1,'6',1,'积分管理',NULL,1,'file'), +(0,105,'积分明细','/backend/point/index','point/list','PointList','select','A',2,'2',1,'积分明细',104,1,NULL), +(0,106,'积分设置','/backend/point/setting','point/setting','PointSetting','select','A',2,'1',1,'积分设置',104,0,NULL), +(0,107,'订单列表','/backend/order/list','order/index','OrderIndex','select','A',2,'1',1,'订单列表',96,1,NULL), +(0,108,'开卡赠礼','/backend/openGift/list','openGift/index','OpenGiftIndex','select','A',2,'4',1,'开卡礼设置',79,1,NULL), +(0,109,'售后订单','/backend/refund/index','refund/index','RefundIndex','select','A',2,'2',1,'售后订单',96,0,NULL), +(0,110,'会员设置','/backend/member/setting','member/setting','MemberSetting','select','A',2,'5',1,'会员设置',79,0,NULL), +(0,111,'商品管理','######','Goods','Goods','server','A',1,'5',1,'商品管理',NULL,0,'shopping-cart'), +(0,112,'商品分类','/backend/goods/cate/list','goods/cate/index','GoodsCateIndex','select','A',2,'0',1,'商品分类',111,1,NULL), +(0,113,'商品列表','/backend/goods/goods/list','goods/goods/index','GoodsGoodsIndex','select','A',2,'1',1,'商品列表',111,1,NULL), +(0,115,'卡券核销','/backend/home/confirmCoupon','coupon/confirm/index','CouponConfirmIndex','select','A',2,'2',1,'卡券核销',50,1,NULL), +(0,116,'充值管理','recharge','recharge','Recharge','money','A',1,'6',1,'余额',NULL,1,'money'), +(0,117,'充值设置','/backend/balance/setting','balance/setting','BalanceSetting','select','A',2,'0',1,'充值设置',116,1,NULL), +(0,118,'余额明细','balance/list','balance/list','BalanceList','select','A',2,'1',1,'充值明细',116,1,NULL), +(0,119,'订阅消息','/backend/subMessage/index','subMessage/index','SubMessageIndex','select','A',2,'0',1,'小程序订阅消息',90,1,NULL), +(0,120,'轮播图编辑','content/banner/edit','content/banner/edit','ContentBannerEdit','select','A',2,'1',0,NULL,101,1,NULL), +(0,121,'新增轮播图','content:banner:add','content:banner:add','Content:banner:add','select','A',2,'2',0,NULL,101,1,NULL), +(0,122,'新增会员等级','/backend/userGrade/add','userGrade/add','UserGradeAdd','select','A',2,'5',0,NULL,79,1,NULL), +(0,123,'新增开卡赠礼','/backend/openGift/add','openGift/add','OpenGiftAdd','select','A',2,'5',0,NULL,79,1,NULL), +(0,124,'收银台','cashier/index','cashier/index','CashierIndex','select','A',2,'4',0,NULL,125,1,NULL), +(0,125,'收银管理','cashier','cashier','Cashier','tab','A',1,'10',0,NULL,NULL,1,NULL), +(0,126,'核销订单','cashier/confirmOrder','cashier/confirmOrder','CashierConfirmOrder','select','A',2,'0',0,NULL,125,1,NULL), +(0,127,'订单修改','/backend/order/edit','order/edit','OrderEdit','select','A',2,'3',0,NULL,96,1,NULL), +(0,128,'订单删除','/backend/order/delete','order/delete','OrderDelete','select','A',2,'4',0,NULL,96,1,NULL), +(0,129,'处理售后','/backend/refund/edit','refund/edit','RefundEdit','select','A',2,'5',0,NULL,96,1,NULL), +(0,130,'订单详情','/backend/order/detail','order/detail','OrderDetail','select','A',2,'6',0,NULL,96,1,NULL), +(0,131,'添加商品','goods/goods/add','goods/goods/add','GoodsGoodsAdd','select','A',2,'3',0,NULL,111,1,NULL), +(0,132,'编辑商品','goods/goods/edit','goods/goods/edit','GoodsGoodsEdit','select','A',2,'4',0,NULL,111,1,NULL), +(0,133,'编辑短信模板','smsTemplate/edit','smsTemplate/edit','SmsTemplateEdit','select','A',2,'4',0,NULL,90,1,NULL), +(0,134,'编辑订阅消息','subMessage/edit','subMessage/edit','SubMessageEdit','select','A',2,'6',0,NULL,90,1,NULL), +(0,135,'变更余额','balance/modify','balance/modify','BalanceModify','select','A',3,'3',0,NULL,117,1,NULL), +(0,136,'变更积分','point/modify','point/modify','PointModify','select','A',2,'3',0,NULL,104,1,NULL), +(0,137,'编辑卡券分组','coupon/group/edit','coupon/group/edit','CouponGroupEdit','select','A',3,'9',0,NULL,83,1,NULL), +(0,138,'新增卡券','coupon/coupon/add','coupon/coupon/add','CouponCouponAdd','select','A',3,'1',0,NULL,100,1,NULL), +(0,139,'编辑卡券','coupon/coupon/edit','coupon/coupon/edit','CouponCouponEdit','select','A',3,'2',0,NULL,100,1,NULL), +(0,140,'作废会员卡券','coupon/userCoupon/delete','coupon/userCoupon/delete','CouponUserCouponDelete','select','A',3,'0',0,NULL,54,1,NULL), +(0,146,'支付设置','store/paySetting','store/paySetting','StorePaySetting','select','A',3,'2',0,NULL,86,1,NULL), +(0,153,'分佣提成','commission','commission','Commission','tree','D',1,'12',1,NULL,NULL,1,NULL), +(0,154,'分佣规则','commission/rule/index','commission/rule/index','CommissionRuleIndex','select','D',2,'0',1,NULL,153,1,NULL), +(0,155,'分佣记录','commission/log/index','commission/log/index','CommissionLogIndex','select','D',2,'1',1,NULL,153,1,NULL), +(0,156,'日记','story','story','Story','table','D',1,'0',1,NULL,NULL,1,NULL), +(0,157,'日记列表','story','story','Story','404','D',2,'0',1,NULL,156,1,NULL), +(0,158,'订单发货','order/delivery','order/delivery','OrderDelivery','bug','A',3,'0',0,NULL,107,1,NULL), +(0,159,'文章管理','content/article/index','content/article/index','ContentArticleIndex','select','A',2,'1',1,NULL,101,1,NULL), +(0,160,'新增文章','content/article/add','content/article/add','ContentArticleAdd','select','A',2,'0',0,NULL,101,1,NULL), +(0,161,'编辑文章','content/article/edit','content/article/edit','ContentArticleEdit','select','A',2,'1',0,NULL,101,1,NULL), +(0,162,'促销活动','marketing','marketing','Marketing','download','D',1,'12',1,NULL,NULL,1,NULL), +(0,163,'大转盘','marketing/index','marketing/index','MarketingIndex','select','D',2,'56',1,NULL,162,1,NULL), +(0,164,'转盘内容','marketing/detail','marketing/detail','MarketingDetail','select','D',2,'8',0,NULL,162,1,NULL), +(0,165,'交易设置','order/setting','order/setting','OrderSetting','select','A',2,'3',1,NULL,96,1,NULL), +(0,177,'商户管理','merchant/index','merchant/index','MerchantIndex','select','A',2,'0',1,NULL,84,1,NULL), +(0,178,'收银设置','setting/cashier','setting/cashier','SettingCashier','select','A',2,'3',0,NULL,125,1,NULL), +(0,179,'库存管理','stock/index','stock/index','StockIndex','select','A',2,'3',1,NULL,111,1,NULL), +(0,180,'数据统计','statistic','statistic','Statistic','chart','A',1,'8',1,NULL,NULL,1,NULL), +(0,181,'数据看板','statistic/index','statistic/index','StatisticIndex','select','A',2,'0',1,NULL,180,1,NULL), +(0,182,'会员分组','member/group/index','member/group/index','MemberGroupIndex','select','A',2,'1',1,NULL,79,1,NULL), +(0,183,'会员充值','balance/distribute','balance/distribute','BalanceDistribute','select','A',2,'2',1,NULL,116,1,NULL), +(0,184,'订单结算','settlement/index','settlement/index','SettlementIndex','select','A',2,'9',1,NULL,96,1,NULL), +(0,185,'发起结算','settlement/doSubmit','settlement/doSubmit','SettlementDoSubmit','select','A',2,'10',0,NULL,96,1,NULL), +(0,186,'结算确认','settlement/doConfirm','settlement/doConfirm','SettlementDoConfirm','select','A',2,'11',0,NULL,96,1,NULL); + +/*Table structure for table `mt_commission_cash` */ + +DROP TABLE IF EXISTS `mt_commission_cash`; + +CREATE TABLE `mt_commission_cash` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `SETTLE_NO` varchar(32) DEFAULT NULL COMMENT '结算单号', + `UUID` varchar(32) DEFAULT NULL COMMENT '结算UUID', + `MERCHANT_ID` int NOT NULL COMMENT '商户ID', + `STORE_ID` int DEFAULT NULL COMMENT '店铺ID', + `USER_ID` int DEFAULT NULL COMMENT '会员ID', + `STAFF_ID` int DEFAULT NULL COMMENT '员工ID', + `AMOUNT` decimal(10,2) DEFAULT NULL COMMENT '金额', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `DESCRIPTION` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '备注信息', + `OPERATOR` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '最后操作人', + `STATUS` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT 'A' COMMENT '状态,A:待确认,B:已确认,C:已支付,D:已作废', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='分佣提现记录表'; + +/*Table structure for table `mt_commission_log` */ + +DROP TABLE IF EXISTS `mt_commission_log`; + +CREATE TABLE `mt_commission_log` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `MERCHANT_ID` int NOT NULL COMMENT '商户ID', + `TARGET` varchar(30) DEFAULT '' COMMENT '对象,member:会员分销;staff:员工提成', + `TYPE` varchar(30) NOT NULL COMMENT '分佣类型', + `LEVEL` int DEFAULT '1' COMMENT '分销等级', + `USER_ID` int DEFAULT NULL COMMENT '会员ID', + `STORE_ID` int DEFAULT '0' COMMENT '店铺ID', + `STAFF_ID` int DEFAULT '0' COMMENT '员工ID', + `ORDER_ID` int DEFAULT '0' COMMENT '订单ID', + `AMOUNT` decimal(10,2) DEFAULT NULL COMMENT '分佣金额', + `RULE_ID` int DEFAULT NULL COMMENT '分佣规则ID', + `RULE_ITEM_ID` int DEFAULT NULL COMMENT '分佣规则项ID', + `DESCRIPTION` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '备注信息', + `CASH_ID` int DEFAULT NULL COMMENT '提现记录ID', + `IS_CASH` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT 'N' COMMENT '是否提现,Y:是;N:否', + `CASH_TIME` datetime DEFAULT NULL COMMENT '提现时间', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `STATUS` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT 'A' COMMENT '状态,A:激活;D:删除', + `OPERATOR` varchar(30) DEFAULT '' COMMENT '最后操作人', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='佣金记录表'; + +/*Table structure for table `mt_commission_relation` */ + +DROP TABLE IF EXISTS `mt_commission_relation`; + +CREATE TABLE `mt_commission_relation` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `MERCHANT_ID` int NOT NULL COMMENT '商户ID', + `USER_ID` int DEFAULT NULL COMMENT '邀请会员ID', + `LEVEL` int DEFAULT '1' COMMENT '等级', + `INVITE_CODE` varchar(32) DEFAULT '' COMMENT '邀请码', + `SUB_USER_ID` int DEFAULT NULL COMMENT '被邀请会员ID', + `DESCRIPTION` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '说明', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `STATUS` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT 'A' COMMENT '状态,A:激活;D:删除', + `OPERATOR` varchar(30) DEFAULT '' COMMENT '最后操作人', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='会员分销关系表'; + +/*Table structure for table `mt_commission_rule` */ + +DROP TABLE IF EXISTS `mt_commission_rule`; + +CREATE TABLE `mt_commission_rule` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `NAME` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '规则名称', + `TYPE` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '方案类型', + `TARGET` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '方案对象,member:会员分销;staff:员工提成', + `MERCHANT_ID` int NOT NULL COMMENT '商户ID', + `STORE_ID` int DEFAULT '0' COMMENT '店铺ID', + `STORE_IDS` varchar(500) DEFAULT '' COMMENT '适用店铺', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `DESCRIPTION` varchar(1000) DEFAULT NULL COMMENT '备注信息', + `OPERATOR` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '最后操作人', + `STATUS` char(1) DEFAULT 'A' COMMENT '状态,A:激活;N:禁用;D:删除', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='方案规则表'; + +/*Table structure for table `mt_commission_rule_item` */ + +DROP TABLE IF EXISTS `mt_commission_rule_item`; + +CREATE TABLE `mt_commission_rule_item` ( + `ID` int NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `TYPE` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '分佣类型', + `RULE_ID` int NOT NULL DEFAULT '0' COMMENT '规则ID', + `MERCHANT_ID` int NOT NULL COMMENT '商户ID', + `STORE_ID` int DEFAULT '0' COMMENT '适用店铺', + `TARGET` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '分佣对象', + `TARGET_ID` int NOT NULL DEFAULT '0' COMMENT '对象ID', + `METHOD` varchar(30) DEFAULT NULL COMMENT '提成方式(按比例/固定金额)', + `STORE_IDS` varchar(500) DEFAULT '' COMMENT '适用店铺', + `GUEST` decimal(10,2) DEFAULT NULL COMMENT '散客佣金', + `SUB_GUEST` decimal(10,2) DEFAULT NULL COMMENT '二级散客佣金', + `MEMBER` decimal(10,2) DEFAULT NULL COMMENT '会员佣金', + `SUB_MEMBER` decimal(10,2) DEFAULT NULL COMMENT '二级会员佣金', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + `OPERATOR` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '最后操作人', + `STATUS` char(1) DEFAULT 'A' COMMENT '状态,A:激活;N:禁用;D:删除', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='分佣提成规则项目表'; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; diff --git a/db/说明.txt b/db/说明.txt new file mode 100644 index 0000000..65a7b90 --- /dev/null +++ b/db/说明.txt @@ -0,0 +1,2 @@ +1、fuint-db.sql是全量的数据库; +2、update_for_xxx是从上个版本升级到最新版本用的; \ No newline at end of file diff --git a/fuint-application/pom.xml b/fuint-application/pom.xml new file mode 100644 index 0000000..073ade3 --- /dev/null +++ b/fuint-application/pom.xml @@ -0,0 +1,171 @@ + + + + fuint + com.fuint + 1.0.0 + + 4.0.0 + + fuint-application + 1.0.0 + jar + + + 0.0.9 + + + + + com.fuint + fuint-framework + 1.0.0 + + + io.sentry + sentry-logback + 1.2.0 + + + org.springframework.ws + spring-ws-core + + + org.springframework.boot + spring-boot-starter-security + + + org.aspectj + aspectjweaver + + + commons-httpclient + commons-httpclient + 3.1 + + + nl.bitwalker + UserAgentUtils + 1.2.4 + + + commons-lang + commons-lang + 2.6 + + + io.springfox + springfox-swagger2 + 2.9.2 + + + io.springfox + springfox-swagger-ui + 2.9.2 + + + + com.baomidou + mybatis-plus-boot-starter + ${mybatis-plus.version} + + + + com.baomidou + mybatis-plus + ${mybatis-plus.version} + + + + com.github.pagehelper + pagehelper-spring-boot-starter + 1.2.5 + + + org.mybatis + mybatis + + + + + + org.mockito + mockito-core + + + com.github.axet + kaptcha + ${kaptcha.version} + + + junit + junit + test + + + org.springframework.boot + spring-boot-starter-test + test + + + org.javassist + javassist + 3.24.0-GA + + + com.aliyun.oss + aliyun-sdk-oss + 3.10.2 + + + + com.aliyun + aliyun-java-sdk-core + 4.4.6 + + + com.alibaba + transmittable-thread-local + 2.2.0 + + + com.github.javen205 + IJPay-WxPay + 2.9.6 + + + com.github.javen205 + IJPay-AliPay + 2.9.6 + + + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.5.12 + + + + repackage + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.8 + 1.8 + + + + + + diff --git a/fuint-application/src/main/java/com/fuint/common/Constants.java b/fuint-application/src/main/java/com/fuint/common/Constants.java new file mode 100644 index 0000000..4fca3f0 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/Constants.java @@ -0,0 +1,35 @@ +package com.fuint.common; + +import java.util.HashMap; +import java.util.Map; + +/** + * 常量定义 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public class Constants { + + // 第几页,默认第1页 + public static final int PAGE_NUMBER = 1; + + // 每页记录数,默认20条 + public static final int PAGE_SIZE = 20; + + // 读取数据最多行数 + public static final int MAX_ROWS = 2000; + + /** + * 系统配置, 从setting表中读取 + */ + public static Map SYS_CONFIGS = new HashMap(); + + public static final int HTTP_RESPONSE_CODE_PARAM_ERROR = 202; + public static final int HTTP_RESPONSE_CODE_USER_NOT_EXIST = 402; + public static final int HTTP_RESPONSE_CODE_USER_LOGIN_ERROR = 403; + public static final int HTTP_RESPONSE_CODE_NOLOGIN = 1001; + + public static final String SESSION_USER = "USER"; + public static final String SESSION_ADMIN_USER = "ADMIN_USER"; +} diff --git a/fuint-application/src/main/java/com/fuint/common/aspect/LogAop.java b/fuint-application/src/main/java/com/fuint/common/aspect/LogAop.java new file mode 100644 index 0000000..a421b16 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/aspect/LogAop.java @@ -0,0 +1,147 @@ +package com.fuint.common.aspect; + +import javassist.ClassClassPath; +import javassist.ClassPool; +import javassist.CtClass; +import javassist.CtMethod; +import javassist.Modifier; +import javassist.bytecode.CodeAttribute; +import javassist.bytecode.LocalVariableAttribute; +import javassist.bytecode.MethodInfo; +import org.apache.commons.lang.ArrayUtils; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Component; + +/** + * 控制器日志 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Component // 声明组件 +@Aspect // 声明切面 +@ComponentScan //组件自动扫描 +@EnableAspectJAutoProxy // spring自动切换JDK动态代理和CGLIB +public class LogAop { + + /** + *自定义日志 + */ + private Logger logger = LoggerFactory.getLogger(LogAop.class); + + /** + * 打印类method的名称以及参数 + * @param point 切面 + */ + public void printMethodParams(JoinPoint point){ + if (point == null) { + return; + } + try { + // 获取方法的参数值数组。方法名、类型以及地址等信息 + String className = point.getTarget().getClass().getName(); + String methodName = point.getSignature().getName(); + + // 重新定义日志 + logger = LoggerFactory.getLogger(point.getTarget().getClass()); + logger.info("-------------------------"+className+"------------------------------------"); + logger.info("methodName = {}", methodName); + + // 获取方法的参数值数组 + Object[] methodArgs = point.getArgs(); + + // 获取方法参数名称 + String[] paramNames = getFieldsName(className, methodName); + + // 输出方法的参数名和参数值 + printParams(paramNames, methodArgs); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 使用获取方法参数名称 + * @param class_name 类名 + * @param method_name 方法名 + * @throws Exception + */ + private String[] getFieldsName(String class_name, String method_name) throws Exception { + Class clazz = Class.forName(class_name); + String clazz_name = clazz.getName(); + ClassPool pool = ClassPool.getDefault(); + ClassClassPath classPath = new ClassClassPath(clazz); + pool.insertClassPath(classPath); + try { + CtClass ctClass = pool.get(clazz_name); + CtMethod ctMethod = ctClass.getDeclaredMethod(method_name); + MethodInfo methodInfo = ctMethod.getMethodInfo(); + CodeAttribute codeAttribute = methodInfo.getCodeAttribute(); + LocalVariableAttribute attr = (LocalVariableAttribute) codeAttribute.getAttribute(LocalVariableAttribute.tag); + if (attr == null) { + return null; + } + String[] paramsArgsName = new String[ctMethod.getParameterTypes().length]; + int pos = Modifier.isStatic(ctMethod.getModifiers()) ? 0 : 1; + for (int i = 0; i < paramsArgsName.length; i++) { + paramsArgsName[i] = attr.variableName(i + pos); + } + return paramsArgsName; + } catch (Exception ex) { + return null; + } + } + + /** + * 判断是否为基本类型 + */ + private boolean isPrimite(Class clazz) { + if (clazz.isPrimitive() || clazz == String.class){ + return true; + }else { + return false; + } + } + + /** + * 打印方法参数值 基本类型直接打印,非基本类型需要重写toString方法 + * @param paramsArgsName 方法参数名数组 + * @param paramsArgsValue 方法参数值数组 + */ + private void printParams(String[] paramsArgsName, Object[] paramsArgsValue) { + if (ArrayUtils.isEmpty(paramsArgsName) || ArrayUtils.isEmpty(paramsArgsValue)) { + return; + } + StringBuffer buffer = new StringBuffer(); + for (int i = 0; i < paramsArgsName.length; i++) { + // 参数名 + String name = paramsArgsName[i]; + // 参数值 + Object value = paramsArgsValue[i]; + buffer.append(name +" = "); + if (isPrimite(value.getClass())) { + buffer.append(value + " ,"); + } else { + buffer.append(value.toString() + " ,"); + } + } + logger.info("params : " + buffer.toString()); + logger.info("-------------------------------------------------------------"); + } + + /** + * 在方法执行前进行切面 + * 定义切面表达式 + * @param point 切面 + */ + @Before("execution(public * com.fuint.module..*.*(..))") + public void before(JoinPoint point) { + this.printMethodParams(point); + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/aspect/RedisModelAspect.java b/fuint-application/src/main/java/com/fuint/common/aspect/RedisModelAspect.java new file mode 100644 index 0000000..3b26713 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/aspect/RedisModelAspect.java @@ -0,0 +1,16 @@ +package com.fuint.common.aspect; + +import org.aspectj.lang.annotation.Aspect; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +/** + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Component +@Aspect +public class RedisModelAspect { + public static final Logger logger = LoggerFactory.getLogger(RedisModelAspect.class); +} diff --git a/fuint-application/src/main/java/com/fuint/common/aspect/TActionLogAop.java b/fuint-application/src/main/java/com/fuint/common/aspect/TActionLogAop.java new file mode 100644 index 0000000..d4482fa --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/aspect/TActionLogAop.java @@ -0,0 +1,138 @@ +package com.fuint.common.aspect; + +import com.fuint.common.dto.AccountInfo; +import com.fuint.common.service.ActionLogService; +import com.fuint.common.util.CommonUtil; +import com.fuint.common.util.TokenUtil; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.repository.model.TActionLog; +import org.apache.commons.lang.StringUtils; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Component; +import javax.servlet.http.HttpServletRequest; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 后台操作日志 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Component +@Aspect +public class TActionLogAop { + + private Logger LOGGER = LoggerFactory.getLogger(TActionLogAop.class); + + @Lazy + @Autowired + private ActionLogService tActionLogService; + + private String userName = ""; // 用户名 + private Integer merchantId = 0; // 商户ID + private Integer storeId = 0; // 店铺ID + private Long startTimeMillis = 0l; // 开始时间 + private Long endTimeMillis = 0l; // 结束时间 + private String clientIp = ""; + private Integer clientPort = 0; + private String module = ""; + private String url = ""; + private String userAgent = ""; + + // Service层切点 + @Pointcut("@annotation(com.fuint.framework.annoation.OperationServiceLog)") + public void serviceAspect() { + // empty + } + + /** + * service 方法前调用 + * + * @param joinPoint + */ + @Before("serviceAspect()") + public void doBeforeService(JoinPoint joinPoint) { + startTimeMillis = System.currentTimeMillis(); // 记录方法开始执行的时间 + } + + /** + * 方法后调用 + * + * @param operationServiceLog + */ + @After("serviceAspect() && @annotation(operationServiceLog)") + public void doAfterInService(OperationServiceLog operationServiceLog) { + try { + endTimeMillis = System.currentTimeMillis(); // 记录方法执行完成的时间 + clientIp = CommonUtil.getIPFromHttpRequest(getRequest()); + userAgent = getRequest().getHeader("user-agent"); + url = getRequest().getRequestURI(); + clientPort = 0; + module = operationServiceLog.description(); + + userName = ""; + merchantId = 0; + storeId = 0; + + if (module.length() > 255) { + module = module.substring(0, 255); + } + HttpServletRequest request = getRequest(); + String token = request.getHeader("Access-Token"); + if (StringUtils.isNotEmpty(token)) { + AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token); + if (accountInfo != null) { + userName = accountInfo.getAccountName(); + } + if (accountInfo != null) { + merchantId = accountInfo.getMerchantId() == null ? 0 : accountInfo.getMerchantId(); + } + if (accountInfo != null) { + storeId = accountInfo.getStoreId() == null ? 0 : accountInfo.getStoreId(); + } + } + this.printOptLog(); + } catch (Exception e) { + // empty + } + } + + /** + * 组装日志 + */ + private void printOptLog() { + if (userAgent.length() > 255) { + userAgent = userAgent.substring(0, 255); + } + if (url.length() > 255) { + url = url.substring(0, 255); + } + TActionLog hal = new TActionLog(); + hal.setAcctName(userName); + hal.setModule(module); + hal.setActionTime(new Date()); + hal.setClientIp(clientIp); + hal.setClientPort(clientPort); + hal.setUrl(url); + hal.setTimeConsuming(new BigDecimal(endTimeMillis - startTimeMillis)); + hal.setUserAgent(userAgent); + hal.setMerchantId(merchantId); + hal.setStoreId(storeId); + if (StringUtils.isNotEmpty(module) && StringUtils.isNotEmpty(userName)) { + this.tActionLogService.saveActionLog(hal); + } + } + + protected HttpServletRequest getRequest(){ + return ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest(); + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/bean/AliPayBean.java b/fuint-application/src/main/java/com/fuint/common/bean/AliPayBean.java new file mode 100644 index 0000000..e0be9e8 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/bean/AliPayBean.java @@ -0,0 +1,104 @@ +package com.fuint.common.bean; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.PropertySource; +import org.springframework.stereotype.Component; + +/** + * 支付宝支付Bean + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Component +@PropertySource("file:${env.properties.path}/${env.profile}/application.properties") +@ConfigurationProperties(prefix = "alipay") +public class AliPayBean { + + private String appId; + private String privateKey; + private String publicKey; + private String appCertPath; + private String aliPayCertPath; + private String aliPayRootCertPath; + private String serverUrl; + private String domain; + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getPrivateKey() { + return privateKey; + } + + public void setPrivateKey(String privateKey) { + this.privateKey = privateKey; + } + + public String getPublicKey() { + return publicKey; + } + + public void setPublicKey(String publicKey) { + this.publicKey = publicKey; + } + + public String getAppCertPath() { + return appCertPath; + } + + public void setAppCertPath(String appCertPath) { + this.appCertPath = appCertPath; + } + + public String getAliPayCertPath() { + return aliPayCertPath; + } + + public void setAliPayCertPath(String aliPayCertPath) { + this.aliPayCertPath = aliPayCertPath; + } + + public String getAliPayRootCertPath() { + return aliPayRootCertPath; + } + + public void setAliPayRootCertPath(String aliPayRootCertPath) { + this.aliPayRootCertPath = aliPayRootCertPath; + } + + public String getServerUrl() { + return serverUrl; + } + + public void setServerUrl(String serverUrl) { + this.serverUrl = serverUrl; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + @Override + public String toString() { + return "AliPayBean{" + + "appId='" + appId + '\'' + + ", privateKey='" + privateKey + '\'' + + ", publicKey='" + publicKey + '\'' + + ", appCertPath='" + appCertPath + '\'' + + ", aliPayCertPath='" + aliPayCertPath + '\'' + + ", aliPayRootCertPath='" + aliPayRootCertPath + '\'' + + ", serverUrl='" + serverUrl + '\'' + + ", domain='" + domain + '\'' + + '}'; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/bean/H5SceneInfo.java b/fuint-application/src/main/java/com/fuint/common/bean/H5SceneInfo.java new file mode 100644 index 0000000..5d7061e --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/bean/H5SceneInfo.java @@ -0,0 +1,83 @@ +package com.fuint.common.bean; + +import com.alibaba.fastjson.JSON; + +/** + * H5支付Bean + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public class H5SceneInfo { + private H5 h5_info; + + public H5 getH5Info() { + return h5_info; + } + + public void setH5Info(H5 h5_info) { + this.h5_info = h5_info; + } + + @Override + public String toString() { + return JSON.toJSONString(this); + } + + public static class H5 { + private String type; + private String app_name; + private String bundle_id; + private String package_name; + private String wap_url; + private String wap_name; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getApp_name() { + return app_name; + } + + public void setApp_name(String app_name) { + this.app_name = app_name; + } + + public String getBundle_id() { + return bundle_id; + } + + public void setBundle_id(String bundle_id) { + this.bundle_id = bundle_id; + } + + public String getPackage_name() { + return package_name; + } + + public void setPackage_name(String package_name) { + this.package_name = package_name; + } + + public String getWap_url() { + return wap_url; + } + + public void setWap_url(String wap_url) { + this.wap_url = wap_url; + } + + public String getWap_name() { + return wap_name; + } + + public void setWap_name(String wap_name) { + this.wap_name = wap_name; + } + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/bean/UnionPayBean.java b/fuint-application/src/main/java/com/fuint/common/bean/UnionPayBean.java new file mode 100644 index 0000000..d2d360b --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/bean/UnionPayBean.java @@ -0,0 +1,64 @@ +package com.fuint.common.bean; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.PropertySource; +import org.springframework.stereotype.Component; + +/** + * 云闪付支付Bean + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Component +@PropertySource("file:${env.properties.path}/${env.profile}/application.properties") +@ConfigurationProperties(prefix = "union") +public class UnionPayBean { + + private String machId; + private String key; + private String serverUrl; + private String domain; + + public String getMachId() { + return machId; + } + + public void setMachId(String machId) { + this.machId = machId; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getServerUrl() { + return serverUrl; + } + + public void setServerUrl(String serverUrl) { + this.serverUrl = serverUrl; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + @Override + public String toString() { + return "UnionPayBean{" + + "machId='" + machId + '\'' + + ", key='" + key + '\'' + + ", serverUrl='" + serverUrl + '\'' + + ", domain='" + domain + '\'' + + '}'; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/bean/WxPayBean.java b/fuint-application/src/main/java/com/fuint/common/bean/WxPayBean.java new file mode 100644 index 0000000..6c85589 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/bean/WxPayBean.java @@ -0,0 +1,78 @@ +package com.fuint.common.bean; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.PropertySource; +import org.springframework.stereotype.Component; + +/** + * 微信支付Bean + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Component +@PropertySource("file:${env.properties.path}/${env.profile}/application.properties") +@ConfigurationProperties(prefix = "wxpay") +public class WxPayBean { + + private String appId; + private String appSecret; + private String mchId; + private String apiV2; + private String certPath; + private String domain; // 填写完整的回调地址 + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getAppSecret() { + return appSecret; + } + + public void setAppSecret(String appSecret) { + this.appSecret = appSecret; + } + + public String getMchId() { + return mchId; + } + + public void setMchId(String mchId) { + this.mchId = mchId; + } + + public String getApiV2() { + return apiV2; + } + + public void setApiV2(String apiV2) { + this.apiV2 = apiV2; + } + + public String getCertPath() { + return certPath; + } + + public void setCertPath(String certPath) { + this.certPath = certPath; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + @Override + public String toString() { + return "WxPayBean [appId=" + appId + ", appSecret=" + appSecret + ", mchId=" + mchId + ", apiV2=" + + apiV2 + ", certPath=" + certPath + ", domain=" + domain + "]"; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/bean/WxPayV3Bean.java b/fuint-application/src/main/java/com/fuint/common/bean/WxPayV3Bean.java new file mode 100644 index 0000000..1454f42 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/bean/WxPayV3Bean.java @@ -0,0 +1,113 @@ +package com.fuint.common.bean; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.PropertySource; +import org.springframework.stereotype.Component; + +/** + * 微信V3支付Bean + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Component +@PropertySource("file:${env.properties.path}/${env.profile}/application.properties") +@ConfigurationProperties(prefix = "v3") +public class WxPayV3Bean { + + private String appId; + private String keyPath; + private String certPath; + private String certP12Path; + private String platformCertPath; + private String mchId; + private String apiKey; + private String apiKey3; + private String domain; + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getKeyPath() { + return keyPath; + } + + public void setKeyPath(String keyPath) { + this.keyPath = keyPath; + } + + public String getCertPath() { + return certPath; + } + + public void setCertPath(String certPath) { + this.certPath = certPath; + } + + public String getCertP12Path() { + return certP12Path; + } + + public void setCertP12Path(String certP12Path) { + this.certP12Path = certP12Path; + } + + public String getPlatformCertPath() { + return platformCertPath; + } + + public void setPlatformCertPath(String platformCertPath) { + this.platformCertPath = platformCertPath; + } + + public String getMchId() { + return mchId; + } + + public void setMchId(String mchId) { + this.mchId = mchId; + } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + public String getApiKey3() { + return apiKey3; + } + + public void setApiKey3(String apiKey3) { + this.apiKey3 = apiKey3; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + @Override + public String toString() { + return "WxPayV3Bean{" + + "keyPath='" + keyPath + '\'' + + ", certPath='" + certPath + '\'' + + ", certP12Path='" + certP12Path + '\'' + + ", platformCertPath='" + platformCertPath + '\'' + + ", mchId='" + mchId + '\'' + + ", apiKey='" + apiKey + '\'' + + ", apiKey3='" + apiKey3 + '\'' + + ", domain='" + domain + '\'' + + '}'; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/config/CaptchaConfig.java b/fuint-application/src/main/java/com/fuint/common/config/CaptchaConfig.java new file mode 100644 index 0000000..9c30ef4 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/config/CaptchaConfig.java @@ -0,0 +1,41 @@ +package com.fuint.common.config; + +import com.google.code.kaptcha.impl.DefaultKaptcha; +import com.google.code.kaptcha.util.Config; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import java.io.InputStream; +import java.util.Properties; + +/** + * 图形验证码组件配置 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Configuration +public class CaptchaConfig { + + private static final Logger logger = LoggerFactory.getLogger(CaptchaConfig.class); + + /** + * 验证码 + */ + @Bean + public DefaultKaptcha defaultCaptcha() { + DefaultKaptcha defaultKaptcha = new DefaultKaptcha(); + Properties property = new Properties(); + try { + InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("captcha-conf.properties"); + property.load(inputStream); + Config config = new Config(property); + defaultKaptcha.setConfig(config); + } catch (Exception e) { + logger.error("Kaptcha properties load error {}", e); + throw new RuntimeException("Kaptcha properties load error"); + } + return defaultKaptcha; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/config/Message.java b/fuint-application/src/main/java/com/fuint/common/config/Message.java new file mode 100644 index 0000000..f5cf2ad --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/config/Message.java @@ -0,0 +1,22 @@ +package com.fuint.common.config; + +/** + * 消息定义 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public class Message { + public static final String PARAM_ERROR = "参数出错"; + public static final String COUPON_NOT_EXIST = "该卡券不存在"; + public static final String COUPON_IS_EXPIRE = "该卡券未生效"; + public static final String USER_NOT_EXIST = "该用户不存在"; + public static final String MAX_COUPON_LIMIT = "已经领取过了"; + public static final String COUPON_TYPE_ERROR = "卡券类型有误"; + public static final String POINT_LIMIT = "您的积分不足"; + public static final String NEED_CODE = "需要领取码"; + public static final String CODE_ERROR = "领取码错误"; + public static final String CODE_ERROR_1 = "核销码错误"; + public static final String GRADE_ERROR = "该卡券不适于您的会员等级"; + public static final String HAS_COUPON = "您已领取过该卡券"; +} diff --git a/fuint-application/src/main/java/com/fuint/common/config/MybatisPlusConfig.java b/fuint-application/src/main/java/com/fuint/common/config/MybatisPlusConfig.java new file mode 100644 index 0000000..bb57e45 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/config/MybatisPlusConfig.java @@ -0,0 +1,51 @@ +package com.fuint.common.config; + +import com.baomidou.mybatisplus.core.injector.ISqlInjector; +import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector; +import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor; +import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * MybatisPlus配置 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Configuration +@MapperScan({"com.fuint.repository.**.mapper"}) +public class MybatisPlusConfig { + + /** + * 分页插件 + * @return PaginationInterceptor + */ + @Bean + @ConditionalOnMissingBean + public PaginationInterceptor paginationInterceptor() { + return new PaginationInterceptor(); + } + + /** + * 逻辑删除插件 + * + * @return LogicSqlInjector + */ + @Bean + @ConditionalOnMissingBean + public ISqlInjector sqlInjector() { + return new LogicSqlInjector(); + } + + /** + * 乐观锁插件 + * @return + */ + @Bean + public OptimisticLockerInterceptor optimisticLockerInterceptor() { + return new OptimisticLockerInterceptor(); + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/config/RedisConfig.java b/fuint-application/src/main/java/com/fuint/common/config/RedisConfig.java new file mode 100644 index 0000000..ab1deb6 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/config/RedisConfig.java @@ -0,0 +1,67 @@ +package com.fuint.common.config; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CachingConfigurerSupport; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.cache.interceptor.KeyGenerator; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; +import org.springframework.data.redis.serializer.StringRedisSerializer; +import org.springframework.session.data.redis.config.ConfigureRedisAction; +import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession; + +/** + * 配置redis缓存 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Configuration +@EnableCaching +@EnableRedisHttpSession +public class RedisConfig extends CachingConfigurerSupport { + + @Autowired + private RedisConnectionFactory redisConnectionFactory; + + @Bean + public KeyGenerator keyGenerator() { + return (target, method, params) -> { + StringBuilder sb = new StringBuilder(); + sb.append(target.getClass().getName()); + sb.append(method.getName()); + for (Object obj : params) { + sb.append(obj.toString()); + } + return sb.toString(); + }; + } + + @Bean + public static ConfigureRedisAction configureRedisAction() { + return ConfigureRedisAction.NO_OP; + } + + @Bean + Jackson2JsonRedisSerializer jackson2JsonRedisSerializer(ObjectMapper objectMapper) { + Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>( + Object.class); + jackson2JsonRedisSerializer.setObjectMapper(objectMapper); + return jackson2JsonRedisSerializer; + } + + @Bean + RedisTemplate redisTemplate(Jackson2JsonRedisSerializer jackson2JsonRedisSerializer) { + RedisTemplate redisTemplate = new RedisTemplate<>(); + redisTemplate.setConnectionFactory(redisConnectionFactory); + redisTemplate.setDefaultSerializer(jackson2JsonRedisSerializer); + StringRedisSerializer stringRedisSerializer = new StringRedisSerializer(); + redisTemplate.setKeySerializer(stringRedisSerializer); + redisTemplate.setHashKeySerializer(stringRedisSerializer); + return redisTemplate; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/config/SecurityConfig.java b/fuint-application/src/main/java/com/fuint/common/config/SecurityConfig.java new file mode 100644 index 0000000..c58520b --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/config/SecurityConfig.java @@ -0,0 +1,100 @@ +package com.fuint.common.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.http.HttpMethod; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.config.http.SessionCreationPolicy; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; + +/** + * 安全中心配置 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true) +public class SecurityConfig extends WebSecurityConfigurerAdapter { + + /** + * 解决 无法直接注入 AuthenticationManager + * + * @return + * @throws Exception + */ + @Bean + @Override + public AuthenticationManager authenticationManagerBean() throws Exception { + return super.authenticationManagerBean(); + } + + /** + * anyRequest | 匹配所有请求路径 + * access | SpringEl表达式结果为true时可以访问 + * anonymous | 匿名可以访问 + * denyAll | 用户不能访问 + * fullyAuthenticated | 用户完全认证可以访问(非remember-me下自动登录) + * hasAnyAuthority | 如果有参数,参数表示权限,则其中任何一个权限可以访问 + * hasAnyRole | 如果有参数,参数表示角色,则其中任何一个角色可以访问 + * hasAuthority | 如果有参数,参数表示权限,则其权限可以访问 + * hasIpAddress | 如果有参数,参数表示IP地址,如果用户IP和参数匹配,则可以访问 + * hasRole | 如果有参数,参数表示角色,则其角色可以访问 + * permitAll | 用户可以任意访问 + * rememberMe | 允许通过remember-me登录的用户访问 + * authenticated | 用户登录后可访问 + */ + @Override + protected void configure(HttpSecurity httpSecurity) throws Exception { + httpSecurity + // CSRF禁用,因为不使用session + .csrf().disable() + // 基于token,所以不需要session + .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and() + // 过滤请求 + .authorizeRequests() + // 允许匿名访问 + .antMatchers( + "/clientApi/**", + "/backendApi/**", + "/merchantApi/**" + ).anonymous() + .antMatchers( + HttpMethod.GET, + "/", + "/static/**", + "/*.html", + "/**/*.html", + "/**/*.css", + "/**/*.js", + "/profile/**" + ).permitAll() + .antMatchers("/swagger-ui.html").anonymous() + .antMatchers("/swagger-resources/**").anonymous() + .antMatchers("/webjars/**").anonymous() + .antMatchers("/*/api-docs").anonymous() + .antMatchers("/druid/**").anonymous() + // 除上面外的所有请求全部需要鉴权认证 + .anyRequest().authenticated() + .and() + .headers().frameOptions().disable(); + } + + /** + * 强散列哈希加密实现 + */ + @Bean + public BCryptPasswordEncoder bCryptPasswordEncoder() { + return new BCryptPasswordEncoder(); + } + + /** + * 身份认证接口 + */ + @Override + protected void configure(AuthenticationManagerBuilder auth) { + // empty + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/config/SwaggerConfig.java b/fuint-application/src/main/java/com/fuint/common/config/SwaggerConfig.java new file mode 100644 index 0000000..32febeb --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/config/SwaggerConfig.java @@ -0,0 +1,44 @@ +package com.fuint.common.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +/** + * Swagger接口文档 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Configuration +@EnableSwagger2 +public class SwaggerConfig implements WebMvcConfigurer { + + @Bean + public Docket createRestApi() { + return new Docket(DocumentationType.SWAGGER_2) + .apiInfo(apiInfo()) + .enable(true) + .select() + .apis(RequestHandlerSelectors.basePackage("com.fuint.module")) + .build(); + } + + @Bean + public ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("fuint会员营销系统接口文档") + .description("fuint会员营销系统接口文档,“/clientApi”目录接口为会员端相关接口,“/backendApi”目录接口为后台管理端相关接口。") + .termsOfServiceUrl("https://www.fuint.cn/") + .contact(new Contact("海南延禾信息技术有限公司","https://www.fuint.cn/", "fushengqian@qq.com")) + .version("1.0") + .build(); + } +} \ No newline at end of file diff --git a/fuint-application/src/main/java/com/fuint/common/config/WebConfig.java b/fuint-application/src/main/java/com/fuint/common/config/WebConfig.java new file mode 100644 index 0000000..588f8ae --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/config/WebConfig.java @@ -0,0 +1,98 @@ +package com.fuint.common.config; + +import com.fuint.common.web.AdminUserInterceptor; +import com.fuint.common.web.CommandInterceptor; +import com.fuint.common.web.ClientUserInterceptor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.CacheControl; +import org.springframework.web.filter.CharacterEncodingFilter; +import org.springframework.web.servlet.config.annotation.*; +import org.springframework.web.servlet.resource.CssLinkResourceTransformer; +import org.springframework.web.servlet.resource.VersionResourceResolver; +import java.util.concurrent.TimeUnit; + +/** + * web配置 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Configuration +public class WebConfig extends WebMvcConfigurationSupport { + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("/resources/**") + .addResourceLocations("/resources/", "classpath:/other-resources/") + .setCacheControl(CacheControl.maxAge(365, TimeUnit.DAYS)) + .resourceChain(false) + .addResolver(new VersionResourceResolver().addContentVersionStrategy("/**")) + .addTransformer(new CssLinkResourceTransformer()); + registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/"); + + registry.addResourceHandler("/**").addResourceLocations( + "classpath:/static/"); + registry.addResourceHandler("swagger-ui.html").addResourceLocations( + "classpath:/META-INF/resources/"); + registry.addResourceHandler("/webjars/**").addResourceLocations( + "classpath:/META-INF/resources/webjars/"); + super.addResourceHandlers(registry); + } + + @Bean + public CommandInterceptor commandInterceptor() { + return new CommandInterceptor(); + } + + @Bean + public AdminUserInterceptor adminUserInterceptor() { + return new AdminUserInterceptor(); + } + + @Bean + public ClientUserInterceptor portalUserInterceptor() { + return new ClientUserInterceptor(); + } + + @Override + public void addInterceptors(InterceptorRegistry registry) { + // Command + registry.addInterceptor(commandInterceptor()) + .addPathPatterns("/cmd/**"); + + // 后台拦截 + registry.addInterceptor(adminUserInterceptor()) + .addPathPatterns("/backendApi/**") + .excludePathPatterns("/clientApi/captcha/**") + .excludePathPatterns("/backendApi/captcha/**") + .excludePathPatterns("/backendApi/userCoupon/exportList") + .excludePathPatterns("/backendApi/login/**"); + + // 客户端拦截 + registry.addInterceptor(portalUserInterceptor()) + .addPathPatterns("/clientApi/**") + .excludePathPatterns("/clientApi/sign/**") + .excludePathPatterns("/clientApi/page/home") + .excludePathPatterns("/clientApi/captcha/**") + .excludePathPatterns("/clientApi/goodsApi/**") + .excludePathPatterns("/clientApi/cart/**") + .excludePathPatterns("/clientApi/user/**") + .excludePathPatterns("/clientApi/settlement/submit") + .excludePathPatterns("/clientApi/pay/**") + .excludePathPatterns("/clientApi/order/todoCounts") + .excludePathPatterns("/clientApi/store/**") + .excludePathPatterns("/clientApi/article/**") + .excludePathPatterns("/clientApi/message/getOne") + .excludePathPatterns("/clientApi/message/wxPush") + .excludePathPatterns("/clientApi/sms/**"); + } + + @Bean + public CharacterEncodingFilter characterEncodingFilter() { + CharacterEncodingFilter filter = new CharacterEncodingFilter(); + filter.setEncoding("UTF-8"); + filter.setForceEncoding(true); + return filter; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/domain/TreeNode.java b/fuint-application/src/main/java/com/fuint/common/domain/TreeNode.java new file mode 100644 index 0000000..04b9748 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/domain/TreeNode.java @@ -0,0 +1,69 @@ +package com.fuint.common.domain; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * 树状结构节点实体 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class TreeNode implements Serializable { + + @ApiModelProperty("菜单ID") + private long id; + + @ApiModelProperty("菜单名称") + private String name; + + @ApiModelProperty("菜单名称(字母)") + private String ename; + + @ApiModelProperty("节点是否打开") + private Boolean open; + + @ApiModelProperty("是否菜单") + private int isMenu; + + @ApiModelProperty("节点是否选中") + private Boolean checked; + + @ApiModelProperty("url") + private String url; + + @ApiModelProperty("路径") + private String path; + + @ApiModelProperty("权限标识") + private String perms; + + @ApiModelProperty("子菜单") + private List childrens = new ArrayList<>(); + + @ApiModelProperty("菜单级别") + private int level; + + @ApiModelProperty("上级菜单") + private long pId; + + @ApiModelProperty("图标") + private String icon; + + @ApiModelProperty("新图标") + private String newIcon; + + @ApiModelProperty("排序") + private Integer sort; + + @ApiModelProperty("状态") + private String status; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/domain/TreeSelect.java b/fuint-application/src/main/java/com/fuint/common/domain/TreeSelect.java new file mode 100644 index 0000000..952e949 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/domain/TreeSelect.java @@ -0,0 +1,61 @@ +package com.fuint.common.domain; + +import java.io.Serializable; +import java.util.List; +import java.util.stream.Collectors; +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * TreeSelect树结构实体类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public class TreeSelect implements Serializable { + + private static final long serialVersionUID = 1L; + + // 节点ID + private Long id; + + // 节点名称 + private String label; + + // 子节点 + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private List childrens; + + public TreeSelect() { + // empty + } + + public TreeSelect(TreeNode menu) { + this.id = menu.getId(); + this.label = menu.getName(); + this.childrens = menu.getChildrens().stream().map(TreeSelect::new).collect(Collectors.toList()); + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public List getChildrens() { + return childrens; + } + + public void setChildrens(List childrens) { + this.childrens = childrens; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/AccountDto.java b/fuint-application/src/main/java/com/fuint/common/dto/AccountDto.java new file mode 100644 index 0000000..10c7425 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/AccountDto.java @@ -0,0 +1,68 @@ +package com.fuint.common.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; +import java.util.Date; + +/** + * 后台账户实体类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class AccountDto { + + @ApiModelProperty("账户主键id") + private Integer id; + + @ApiModelProperty("账户编码") + private String accountKey; + + @ApiModelProperty("账户名称") + private String accountName; + + @ApiModelProperty("密码") + private String password; + + @ApiModelProperty("状态 : 0 无效 1 有效") + private int accountStatus; + + @ApiModelProperty("激活状态 : 0 未激活 1已激活") + private int isActive; + + @ApiModelProperty("创建时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date createDate; + + @ApiModelProperty("修改时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date modifyDate; + + @ApiModelProperty("随机码(公盐)") + private String salt; + + @ApiModelProperty("是否被锁定") + private int locked; + + @ApiModelProperty("真实姓名") + private String realName; + + @ApiModelProperty("所属商户ID") + private Integer merchantId; + + @ApiModelProperty("所属商户名称") + private String merchantName; + + @ApiModelProperty("所属店铺ID") + private Integer storeId; + + @ApiModelProperty("所属店铺名称") + private String storeName; + + @ApiModelProperty("关联员工ID") + private Integer staffId; +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/AccountInfo.java b/fuint-application/src/main/java/com/fuint/common/dto/AccountInfo.java new file mode 100644 index 0000000..4b20ef1 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/AccountInfo.java @@ -0,0 +1,74 @@ +package com.fuint.common.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; +import java.util.Date; + +/** + * 后台登录账号信息 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Data +public class AccountInfo implements Serializable { + + @ApiModelProperty("账户主键id") + private Integer id; + + @ApiModelProperty("账户编码") + private String accountKey; + + @ApiModelProperty("账户名称") + private String accountName; + + @ApiModelProperty("状态 : 0 无效 1 有效") + private int accountStatus; + + @ApiModelProperty("激活状态 : 0 未激活 1已激活") + private String isActive; + + @ApiModelProperty("创建时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date createDate; + + @ApiModelProperty("修改时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date modifyDate; + + @ApiModelProperty("随机码(公盐)") + private String salt; + + @ApiModelProperty("所属角色ID") + private String roleIds; + + @ApiModelProperty("是否被锁定") + private int locked; + + @ApiModelProperty("从属对象") + private int ownerId; + + @ApiModelProperty("真实姓名") + private String realName; + + @ApiModelProperty("所属商户ID") + private Integer merchantId; + + @ApiModelProperty("所属商户名称") + private String merchantName; + + @ApiModelProperty("所属店铺ID") + private Integer storeId; + + @ApiModelProperty("所属店铺名称") + private String storeName; + + @ApiModelProperty("关联员工ID") + private Integer staffId; + + @ApiModelProperty("登录的Token") + private String token; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/AddressDto.java b/fuint-application/src/main/java/com/fuint/common/dto/AddressDto.java new file mode 100644 index 0000000..a977cf6 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/AddressDto.java @@ -0,0 +1,56 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; +import java.io.Serializable; + +/** + * 会员地址信息 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class AddressDto implements Serializable { + + @ApiModelProperty("账户主键ID") + private Integer id; + + @ApiModelProperty("会员ID") + private Integer userId; + + @ApiModelProperty("会员名称") + private String name; + + @ApiModelProperty("会员手机号") + private String mobile; + + @ApiModelProperty("省份ID") + private Integer provinceId; + + @ApiModelProperty("省份名称") + private String provinceName; + + @ApiModelProperty("城市ID") + private Integer cityId; + + @ApiModelProperty("城市名称") + private String cityName; + + @ApiModelProperty("区ID") + private Integer regionId; + + @ApiModelProperty("区名称") + private String regionName; + + @ApiModelProperty("详细地址") + private String detail; + + @ApiModelProperty("是否默认地址") + private String isDefault; + + @ApiModelProperty("状态") + private String status; +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/ArticleDto.java b/fuint-application/src/main/java/com/fuint/common/dto/ArticleDto.java new file mode 100644 index 0000000..aedb27b --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/ArticleDto.java @@ -0,0 +1,167 @@ +package com.fuint.common.dto; + +import java.io.Serializable; +import java.util.Date; + +/** + * 文章实体类 + * Created by FSQ + */ +public class ArticleDto implements Serializable { + + /** + * 自增ID + */ + private Integer id; + + /** + * 标题 + */ + private String title; + + /** + * 简介 + */ + private String brief; + + /** + * 所属商户 + * */ + private Integer merchantId; + + /** + * 所属店铺 + * */ + private Integer storeId; + + /** + * 链接地址 + */ + private String url; + + /** + * 点击数 + */ + private Long click; + + /** + * 图片地址 + */ + private String image; + + /** + * 描述 + */ + private String description; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 最后操作人 + */ + private String operator; + + /** + * A:正常;D:删除 + */ + private String status; + + /** + * 排序 + * */ + private Integer sort; + + public Integer getId(){ + return id; + } + public void setId(Integer id){ + this.id=id; + } + public String getTitle(){ + return title; + } + public void setTitle(String title){ + this.title=title; + } + public String getBrief(){ + return brief; + } + public void setBrief(String brief){ + this.brief=brief; + } + public Integer getMerchantId(){ + return merchantId; + } + public void setMerchantId(Integer merchantId){ + this.merchantId=merchantId; + } + public Integer getStoreId(){ + return storeId; + } + public void setStoreId(Integer storeId){ + this.storeId=storeId; + } + public String getUrl(){ + return url; + } + public void setUrl(String url){ + this.url=url; + } + public Long getClick(){ + return click; + } + public void setClick(Long click){ + this.click=click; + } + public String getImage(){ + return image; + } + public void setImage(String image){ + this.image=image; + } + public String getDescription(){ + return description; + } + public void setDescription(String description){ + this.description=description; + } + public Date getCreateTime(){ + return createTime; + } + public void setCreateTime(Date createTime){ + this.createTime=createTime; + } + public Date getUpdateTime(){ + return updateTime; + } + public void setUpdateTime(Date updateTime){ + this.updateTime=updateTime; + } + public String getOperator(){ + return operator; + } + public void setOperator(String operator){ + this.operator=operator; + } + public String getStatus(){ + return status; + } + public void setStatus(String status){ + this.status=status; + } + public Integer getSort(){ + return sort; + } + public void setSort(Integer sort){ + this.sort=sort; + } +} + diff --git a/fuint-application/src/main/java/com/fuint/common/dto/AssetDto.java b/fuint-application/src/main/java/com/fuint/common/dto/AssetDto.java new file mode 100644 index 0000000..fd12664 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/AssetDto.java @@ -0,0 +1,27 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.math.BigDecimal; + +/** + * 个人资产实体类 + */ +@Getter +@Setter +public class AssetDto { + + @ApiModelProperty("次卡数量") + private Integer timer; + + @ApiModelProperty("储值卡数量") + private Integer prestore; + + @ApiModelProperty("优惠券数量") + private Integer coupon; + + @ApiModelProperty("预付金总额") + private BigDecimal totalPrePayment; +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/BalanceDto.java b/fuint-application/src/main/java/com/fuint/common/dto/BalanceDto.java new file mode 100644 index 0000000..c2ccc08 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/BalanceDto.java @@ -0,0 +1,56 @@ +package com.fuint.common.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fuint.repository.model.MtUser; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * 余额变动实体类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class BalanceDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("会员ID") + private Integer userId; + + @ApiModelProperty("会员信息") + private MtUser userInfo; + + @ApiModelProperty("订单号") + private String orderSn; + + @ApiModelProperty("余额变化数量") + private BigDecimal amount; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @ApiModelProperty("创建时间") + private Date createTime; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @ApiModelProperty("更新时间") + private Date updateTime; + + @ApiModelProperty("备注说明") + private String description; + + @ApiModelProperty("状态,A正常;D删除") + private String status; + + @ApiModelProperty("最后操作人") + private String operator; + +} + diff --git a/fuint-application/src/main/java/com/fuint/common/dto/BannerDto.java b/fuint-application/src/main/java/com/fuint/common/dto/BannerDto.java new file mode 100644 index 0000000..1012be1 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/BannerDto.java @@ -0,0 +1,59 @@ +package com.fuint.common.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.util.Date; + +/** + * 焦点图实体类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class BannerDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("标题") + private String title; + + @ApiModelProperty("所属商户ID") + private Integer merchantId; + + @ApiModelProperty("所属店铺ID") + private Integer storeId; + + @ApiModelProperty("链接地址") + private String url; + + @ApiModelProperty("图片地址") + private String image; + + @ApiModelProperty("描述信息") + private String description; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @ApiModelProperty("创建时间") + private Date createTime; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @ApiModelProperty("更新时间") + private Date updateTime; + + @ApiModelProperty("最后操作人") + private String operator; + + @ApiModelProperty("排序") + private Integer sort; + + @ApiModelProperty("状态,A正常;D删除") + private String status; +} + diff --git a/fuint-application/src/main/java/com/fuint/common/dto/Body.java b/fuint-application/src/main/java/com/fuint/common/dto/Body.java new file mode 100644 index 0000000..5cedd7f --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/Body.java @@ -0,0 +1,33 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; +import java.io.Serializable; +import java.util.Map; + +/** + * 消息体Body信息 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class Body implements Serializable { + + @ApiModelProperty("入参信息") + private Map inParams; + + @ApiModelProperty("出参信息") + private Map outParams; + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("Body{"); + sb.append("inParams=").append(inParams); + sb.append(", outParams=").append(outParams); + sb.append('}'); + return sb.toString(); + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/CommissionLogDto.java b/fuint-application/src/main/java/com/fuint/common/dto/CommissionLogDto.java new file mode 100644 index 0000000..d5ab1c0 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/CommissionLogDto.java @@ -0,0 +1,93 @@ +package com.fuint.common.dto; + +import com.fuint.repository.model.MtCommissionRule; +import com.fuint.repository.model.MtOrder; +import com.fuint.repository.model.MtStaff; +import com.fuint.repository.model.MtStore; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * 分销提成记录实体 + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Data +public class CommissionLogDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("分佣类型") + private String type; + + @ApiModelProperty("分佣类型名称") + private String typeName; + + @ApiModelProperty("分佣等级") + private Integer level; + + @ApiModelProperty("会员ID") + private Integer userId; + + @ApiModelProperty("用户信息") + private OrderUserDto userInfo; + + @ApiModelProperty("商户ID") + private Integer merchantId; + + @ApiModelProperty("店铺ID") + private Integer storeId; + + @ApiModelProperty("所属店铺信息") + private MtStore storeInfo; + + @ApiModelProperty("员工ID") + private Integer staffId; + + @ApiModelProperty("所属店铺信息") + private MtStaff staffInfo; + + @ApiModelProperty("订单ID") + private Integer orderId; + + @ApiModelProperty("订单信息") + private MtOrder orderInfo; + + @ApiModelProperty("分佣金额") + private BigDecimal amount; + + @ApiModelProperty("规则ID") + private Integer ruleId; + + @ApiModelProperty("分佣规则信息") + private MtCommissionRule ruleInfo; + + @ApiModelProperty("备注") + private String description; + + @ApiModelProperty("提现记录ID") + private Integer cashId; + + @ApiModelProperty("最后操作人") + private String isCash; + + @ApiModelProperty("提现时间") + private Date cashTime; + + @ApiModelProperty("创建时间") + private Date createTime; + + @ApiModelProperty("更新时间") + private Date updateTime; + + @ApiModelProperty("最后操作人") + private String operator; + + @ApiModelProperty("状态") + private String status; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/CommissionRuleDto.java b/fuint-application/src/main/java/com/fuint/common/dto/CommissionRuleDto.java new file mode 100644 index 0000000..542e9b0 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/CommissionRuleDto.java @@ -0,0 +1,56 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * 分销提成规则实体 + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Data +public class CommissionRuleDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("规则名称") + private String name; + + @ApiModelProperty("方案类型,goods:商品销售;coupon:卡券销售;recharge:会员充值") + private String type; + + @ApiModelProperty("分佣对象,member:会员分销;staff:员工提成") + private String target; + + @ApiModelProperty("商户ID") + private Integer merchantId; + + @ApiModelProperty("店铺ID") + private Integer storeId; + + @ApiModelProperty("适用店铺ID列表") + private List storeIdList; + + @ApiModelProperty("具体项目列表") + private List detailList; + + @ApiModelProperty("备注") + private String description; + + @ApiModelProperty("创建时间") + private Date createTime; + + @ApiModelProperty("更新时间") + private Date updateTime; + + @ApiModelProperty("最后操作人") + private String operator; + + @ApiModelProperty("状态") + private String status; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/CommissionRuleItemDto.java b/fuint-application/src/main/java/com/fuint/common/dto/CommissionRuleItemDto.java new file mode 100644 index 0000000..7301938 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/CommissionRuleItemDto.java @@ -0,0 +1,40 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 分销提成规则项目实体 + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Data +public class CommissionRuleItemDto implements Serializable { + + @ApiModelProperty("商品ID") + private Integer goodsId; + + @ApiModelProperty("商品名称") + private String goodsName; + + @ApiModelProperty("商品logo") + private String logo; + + @ApiModelProperty("商品价格") + private BigDecimal price; + + @ApiModelProperty("方案类型,goods:商品销售;coupon:卡券销售;recharge:会员充值") + private String type; + + @ApiModelProperty("提成方式") + private String method; + + @ApiModelProperty("散客值") + private BigDecimal visitorVal; + + @ApiModelProperty("会员值") + private BigDecimal memberVal; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/ConfirmLogDto.java b/fuint-application/src/main/java/com/fuint/common/dto/ConfirmLogDto.java new file mode 100644 index 0000000..793f99c --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/ConfirmLogDto.java @@ -0,0 +1,67 @@ +package com.fuint.common.dto; + +import com.alibaba.fastjson.annotation.JSONField; +import com.fuint.repository.model.MtCoupon; +import com.fuint.repository.model.MtStore; +import com.fuint.repository.model.MtUser; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * 核销卡券流水dto + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class ConfirmLogDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("核销编码") + private String code; + + @ApiModelProperty("核销状态") + private String status; + + @ApiModelProperty("会员卡券ID") + private Integer userCouponId; + + @ApiModelProperty("卡券信息") + private MtCoupon couponInfo; + + @ApiModelProperty("会员信息") + private MtUser userInfo; + + @ApiModelProperty("核销店铺信息") + private MtStore storeInfo; + + @JSONField(format="yyyy-MM-dd HH:mm:ss") + @ApiModelProperty("创建时间") + private Date createTime; + + @JSONField(format="yyyy-MM-dd HH:mm:ss") + @ApiModelProperty("更新时间") + private Date updateTime; + + @ApiModelProperty("核销金额") + private BigDecimal amount; + + @ApiModelProperty("核销uuid") + private String uuid; + + @ApiModelProperty("核销备注") + private String remark; + + @ApiModelProperty("最后操作人") + private String operator; + +} + diff --git a/fuint-application/src/main/java/com/fuint/common/dto/CouponCellDto.java b/fuint-application/src/main/java/com/fuint/common/dto/CouponCellDto.java new file mode 100644 index 0000000..f12e1ac --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/CouponCellDto.java @@ -0,0 +1,30 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; +import java.util.List; + +/** + * 卡券导入单元实体 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class CouponCellDto { + + @ApiModelProperty("手机号") + private String mobile; + + @ApiModelProperty("商户ID") + private Integer merchantId; + + @ApiModelProperty("分组ID") + private List groupId; + + @ApiModelProperty("发放数量") + private List num; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/CouponDto.java b/fuint-application/src/main/java/com/fuint/common/dto/CouponDto.java new file mode 100644 index 0000000..31ee4e8 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/CouponDto.java @@ -0,0 +1,71 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 卡券实体 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Data +public class CouponDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("卡券名称") + private String name; + + @ApiModelProperty("卡券类型") + private String type; + + @ApiModelProperty("状态") + private String status; + + @ApiModelProperty("获取规则") + private String inRule; + + @ApiModelProperty("使用规则") + private String outRule; + + @ApiModelProperty("图片") + private String image; + + @ApiModelProperty("面额") + private BigDecimal amount; + + @ApiModelProperty("领取需要积分数量") + private Integer point; + + @ApiModelProperty("卖点") + private String sellingPoint; + + @ApiModelProperty("已领取、预存数量") + private Integer gotNum; + + @ApiModelProperty("剩余数量") + private Integer leftNum; + + @ApiModelProperty("限制数量") + private Integer limitNum; + + @ApiModelProperty("是否领取") + private Boolean isReceive; + + @ApiModelProperty("是否需要领取码") + private boolean needReceiveCode; + + @ApiModelProperty("会员卡券ID") + private int userCouponId; + + @ApiModelProperty("有效期") + private String effectiveDate; + + @ApiModelProperty("卡券说明") + private String description; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/DateDto.java b/fuint-application/src/main/java/com/fuint/common/dto/DateDto.java new file mode 100644 index 0000000..3221d16 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/DateDto.java @@ -0,0 +1,22 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +/** + * 日期实体 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class DateDto { + + @ApiModelProperty("开始时间") + private String startDate; + + @ApiModelProperty("结束时间") + private String endDate; +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/ExpressDto.java b/fuint-application/src/main/java/com/fuint/common/dto/ExpressDto.java new file mode 100644 index 0000000..081dddf --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/ExpressDto.java @@ -0,0 +1,26 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +/** + * 订单物流信息dto + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class ExpressDto { + + @ApiModelProperty("物流公司") + private String expressCompany; + + @ApiModelProperty("物流单号") + private String expressNo; + + @ApiModelProperty("发货时间") + private String expressTime; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/GiveDto.java b/fuint-application/src/main/java/com/fuint/common/dto/GiveDto.java new file mode 100644 index 0000000..a720b4c --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/GiveDto.java @@ -0,0 +1,78 @@ +package com.fuint.common.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 卡券转赠实体类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class GiveDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("获赠者会员ID") + private Integer userId; + + @ApiModelProperty("店铺ID") + private Integer storeId; + + @ApiModelProperty("赠送者会员ID") + private Integer giveUserId; + + @ApiModelProperty("获赠者手机号") + private String mobile; + + @ApiModelProperty("转赠者手机号") + private String userMobile; + + @ApiModelProperty("分组ID,逗号隔开") + private String groupIds; + + @ApiModelProperty("分组名称,逗号隔开") + private String groupNames; + + @ApiModelProperty("图片") + private String image; + + @ApiModelProperty("券ID,逗号隔开") + private String couponIds; + + @ApiModelProperty("券名称,逗号隔开") + private String couponNames; + + @ApiModelProperty("数量") + private Integer num; + + @ApiModelProperty("总金额") + private BigDecimal money; + + @ApiModelProperty("备注") + private String note; + + @ApiModelProperty("留言") + private String message; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @ApiModelProperty("赠送时间") + private String createTime; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @ApiModelProperty("更新时间") + private String updateTime; + + @ApiModelProperty("状态,A正常;C取消 ") + private String status; + +} + diff --git a/fuint-application/src/main/java/com/fuint/common/dto/GiveItemDto.java b/fuint-application/src/main/java/com/fuint/common/dto/GiveItemDto.java new file mode 100644 index 0000000..7abf8fc --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/GiveItemDto.java @@ -0,0 +1,50 @@ +package com.fuint.common.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * 转赠明细实体类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class GiveItemDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("赠予对象手机号") + private String mobile; + + @ApiModelProperty("用户手机") + private String userMobile; + + @ApiModelProperty("分组ID") + private Integer groupId; + + @ApiModelProperty("分组名称") + private String groupName; + + @ApiModelProperty("卡券ID") + private Integer couponId; + + @ApiModelProperty("卡券名称") + private String couponName; + + @ApiModelProperty("总金额") + private BigDecimal money; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @ApiModelProperty("赠送时间") + private Date createTime; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/GoodsCateDto.java b/fuint-application/src/main/java/com/fuint/common/dto/GoodsCateDto.java new file mode 100644 index 0000000..71692ea --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/GoodsCateDto.java @@ -0,0 +1,61 @@ +package com.fuint.common.dto; + +import java.io.Serializable; +import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +/** + * 商品分类DTO + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class GoodsCateDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("所属商户ID") + private Integer merchantId; + + @ApiModelProperty("所属商户名称") + private String merchantName; + + @ApiModelProperty("所属店铺ID") + private Integer storeId; + + @ApiModelProperty("所属店铺名称") + private String storeName; + + @ApiModelProperty("分类名称") + private String name; + + @ApiModelProperty("LOGO地址") + private String logo; + + @ApiModelProperty("分类描述") + private String description; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @ApiModelProperty("创建时间") + private Date createTime; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @ApiModelProperty("更新时间") + private Date updateTime; + + @ApiModelProperty("最后操作人") + private String operator; + + @ApiModelProperty("排序") + private Integer sort; + + @ApiModelProperty("A:正常;D:删除") + private String status; +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/GoodsDetailDto.java b/fuint-application/src/main/java/com/fuint/common/dto/GoodsDetailDto.java new file mode 100644 index 0000000..e502dcc --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/GoodsDetailDto.java @@ -0,0 +1,95 @@ +package com.fuint.common.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * 商品详情实体 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class GoodsDetailDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer goodsId; + + @ApiModelProperty("商品名称") + private String name; + + @ApiModelProperty("分类ID") + private Integer cateId; + + @ApiModelProperty("商品条码") + private String goodsNo; + + @ApiModelProperty("可否单规格") + private String isSingleSpec; + + @ApiModelProperty("主图地址") + private String logo; + + @ApiModelProperty("图片地址") + private List images; + + @ApiModelProperty("商品价格") + private BigDecimal price; + + @ApiModelProperty("划线价格") + private BigDecimal linePrice; + + @ApiModelProperty("库存") + private Integer stock; + + @ApiModelProperty("商品重量") + private BigDecimal weight; + + @ApiModelProperty("初始销量") + private Integer initSale; + + @ApiModelProperty("商品卖点") + private String salePoint; + + @ApiModelProperty("可否使用积分抵扣") + private String canUsePoint; + + @ApiModelProperty("会员是否有折扣") + private String isMemberDiscount; + + @ApiModelProperty("排序") + private Integer sort; + + @ApiModelProperty("商品描述") + private String description; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @ApiModelProperty("创建时间") + private Date createTime; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @ApiModelProperty("更新时间") + private Date updateTime; + + @ApiModelProperty("最后操作人") + private String operator; + + @ApiModelProperty("状态,A:正常;D:删除") + private String status; + + @ApiModelProperty("sku列表") + private List skuList; + + @ApiModelProperty("规格列表") + private List specList; + +} + diff --git a/fuint-application/src/main/java/com/fuint/common/dto/GoodsDto.java b/fuint-application/src/main/java/com/fuint/common/dto/GoodsDto.java new file mode 100644 index 0000000..e17f1dd --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/GoodsDto.java @@ -0,0 +1,123 @@ +package com.fuint.common.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fuint.repository.model.MtGoodsCate; +import com.fuint.repository.model.MtGoodsSku; +import com.fuint.repository.model.MtGoodsSpec; +import com.fuint.repository.model.MtStore; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * 商品DTO + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class GoodsDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("所属店铺ID") + private Integer storeId; + + @ApiModelProperty("所属店铺信息") + private MtStore storeInfo; + + @ApiModelProperty("商品名称") + private String name; + + @ApiModelProperty("商品类型") + private String type; + + @ApiModelProperty("分类ID") + private Integer cateId; + + @ApiModelProperty("分类信息") + private MtGoodsCate cateInfo; + + @ApiModelProperty("商品条码") + private String goodsNo; + + @ApiModelProperty("可否单规格") + private String isSingleSpec; + + @ApiModelProperty("主图地址") + private String logo; + + @ApiModelProperty("图片地址") + private String images; + + @ApiModelProperty("价格") + private BigDecimal price; + + @ApiModelProperty("划线价格") + private BigDecimal linePrice; + + @ApiModelProperty("库存") + private Integer stock; + + @ApiModelProperty("数量") + private Integer num; + + @ApiModelProperty("服务时长") + private Integer serviceTime; + + @ApiModelProperty("卡券ID") + private String couponIds; + + @ApiModelProperty("重量") + private BigDecimal weight; + + @ApiModelProperty("初始销量") + private Integer initSale; + + @ApiModelProperty("商品卖点") + private String salePoint; + + @ApiModelProperty("可否使用积分抵扣") + private String canUsePoint; + + @ApiModelProperty("会员是否有折扣") + private String isMemberDiscount; + + @ApiModelProperty("排序") + private Integer sort; + + @ApiModelProperty("商品描述") + private String description; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @ApiModelProperty("创建时间") + private Date createTime; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @ApiModelProperty("更新时间") + private Date updateTime; + + @ApiModelProperty("最后操作人") + private String operator; + + @ApiModelProperty("状态,A:正常;D:删除") + private String status; + + @ApiModelProperty("skuId") + private Integer skuId; + + @ApiModelProperty("sku列表") + private List skuList; + + @ApiModelProperty("规格列表") + private List specList; + +} + diff --git a/fuint-application/src/main/java/com/fuint/common/dto/GoodsSkuDto.java b/fuint-application/src/main/java/com/fuint/common/dto/GoodsSkuDto.java new file mode 100644 index 0000000..a5367b6 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/GoodsSkuDto.java @@ -0,0 +1,52 @@ +package com.fuint.common.dto; + +import com.fuint.repository.model.MtGoodsSpec; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.util.List; +import java.math.BigDecimal; + +/** + * 商品sku实体 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class GoodsSkuDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("sku编码") + private String skuNo; + + @ApiModelProperty("图片") + private String logo; + + @ApiModelProperty("商品ID") + private Integer goodsId; + + @ApiModelProperty("规格ID") + private String specIds; + + @ApiModelProperty("规格列表") + private List specList; + + @ApiModelProperty("库存") + private Integer stock; + + @ApiModelProperty("价格") + private BigDecimal price; + + @ApiModelProperty("划线价格") + private BigDecimal linePrice; + + @ApiModelProperty("重量") + private BigDecimal weight; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/GoodsSpecChildDto.java b/fuint-application/src/main/java/com/fuint/common/dto/GoodsSpecChildDto.java new file mode 100644 index 0000000..3598d6a --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/GoodsSpecChildDto.java @@ -0,0 +1,29 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; + +/** + * 商品规格子类实体 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class GoodsSpecChildDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("规格名称") + private String name; + + @ApiModelProperty("是否选择") + private boolean checked; + +} + diff --git a/fuint-application/src/main/java/com/fuint/common/dto/GoodsSpecDto.java b/fuint-application/src/main/java/com/fuint/common/dto/GoodsSpecDto.java new file mode 100644 index 0000000..a8a427b --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/GoodsSpecDto.java @@ -0,0 +1,30 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.util.List; + +/** + * 商品规格实体 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class GoodsSpecDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer specId; + + @ApiModelProperty("规格名称") + private String name; + + @ApiModelProperty("规格值列表") + private List valueList; + +} + diff --git a/fuint-application/src/main/java/com/fuint/common/dto/GoodsSpecItemDto.java b/fuint-application/src/main/java/com/fuint/common/dto/GoodsSpecItemDto.java new file mode 100644 index 0000000..f3a4382 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/GoodsSpecItemDto.java @@ -0,0 +1,30 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.util.List; + +/** + * 商品规格项实体 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class GoodsSpecItemDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("规格名称") + private String name; + + @ApiModelProperty("规格子类") + private List child; + +} + diff --git a/fuint-application/src/main/java/com/fuint/common/dto/GoodsSpecValueDto.java b/fuint-application/src/main/java/com/fuint/common/dto/GoodsSpecValueDto.java new file mode 100644 index 0000000..e653275 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/GoodsSpecValueDto.java @@ -0,0 +1,29 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; + +/** + * 商品规格值实体 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class GoodsSpecValueDto implements Serializable { + + @ApiModelProperty("值ID") + private Integer specValueId; + + @ApiModelProperty("规格名") + private String specName; + + @ApiModelProperty("规格值") + private String specValue; + +} + diff --git a/fuint-application/src/main/java/com/fuint/common/dto/GoodsTopDto.java b/fuint-application/src/main/java/com/fuint/common/dto/GoodsTopDto.java new file mode 100644 index 0000000..218ec9b --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/GoodsTopDto.java @@ -0,0 +1,36 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 商品排行DTO + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class GoodsTopDto implements Serializable { + + @ApiModelProperty("商品ID") + private Integer id; + + @ApiModelProperty("商品名称") + private String name; + + @ApiModelProperty("商品条码") + private String goodsNo; + + @ApiModelProperty("销售金额") + private BigDecimal amount; + + @ApiModelProperty("销售数量") + private Integer num; + +} + diff --git a/fuint-application/src/main/java/com/fuint/common/dto/GroupDataDto.java b/fuint-application/src/main/java/com/fuint/common/dto/GroupDataDto.java new file mode 100644 index 0000000..6f2f97a --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/GroupDataDto.java @@ -0,0 +1,33 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; + +/** + * 卡券分组数据DTO + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class GroupDataDto implements Serializable { + + @ApiModelProperty("发放数量") + private Integer sendNum; + + @ApiModelProperty("未发放数量") + private Integer unSendNum; + + @ApiModelProperty("使用数量") + private Integer useNum; + + @ApiModelProperty("过期数量") + private Integer expireNum; + + @ApiModelProperty("取消数量") + private Integer cancelNum; +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/GroupDataListDto.java b/fuint-application/src/main/java/com/fuint/common/dto/GroupDataListDto.java new file mode 100644 index 0000000..5bffea9 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/GroupDataListDto.java @@ -0,0 +1,23 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +/** + * 卡券分组数据DTO + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class GroupDataListDto { + + @ApiModelProperty("键值") + private String key; + + @ApiModelProperty("数据") + private GroupDataDto data; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/GroupMemberDto.java b/fuint-application/src/main/java/com/fuint/common/dto/GroupMemberDto.java new file mode 100644 index 0000000..3c41cb2 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/GroupMemberDto.java @@ -0,0 +1,30 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; +import java.io.Serializable; + +/** + * 分组会员DTO + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class GroupMemberDto implements Serializable { + + @ApiModelProperty("会员ID") + private Integer id; + + @ApiModelProperty("会员名称") + private String name; + + @ApiModelProperty("会员号") + private String userNo; + + @ApiModelProperty("会员名称") + private String mobile; +} + diff --git a/fuint-application/src/main/java/com/fuint/common/dto/HangUpDto.java b/fuint-application/src/main/java/com/fuint/common/dto/HangUpDto.java new file mode 100644 index 0000000..1ebd263 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/HangUpDto.java @@ -0,0 +1,45 @@ +package com.fuint.common.dto; + +import com.fuint.repository.model.MtUser; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.math.BigDecimal; +import java.sql.Array; + +/** + * 收银挂单实体类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class HangUpDto { + + @ApiModelProperty("挂单号") + private String hangNo; + + @ApiModelProperty("CardId") + private Integer[] cardIds; + + @ApiModelProperty("是否空白") + private Boolean isEmpty; + + @ApiModelProperty("会员信息") + private MtUser memberInfo; + + @ApiModelProperty("件数") + private Integer num; + + @ApiModelProperty("金额") + private BigDecimal amount; + + @ApiModelProperty("预付金额") + private BigDecimal prePayment; + + @ApiModelProperty("时间") + private String dateTime; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/Head.java b/fuint-application/src/main/java/com/fuint/common/dto/Head.java new file mode 100644 index 0000000..df03261 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/Head.java @@ -0,0 +1,40 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; +import java.io.Serializable; + +/** + * 消息体头信息 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class Head implements Serializable { + + @ApiModelProperty("服务编号,用于确定唯一的服务") + private String serviceId; + + @ApiModelProperty("授权Token信息") + private String token; + + @ApiModelProperty("服务执行返回码(000000:正常)") + private String returnCode; + + @ApiModelProperty("服务执行返回信息") + private String returnDesc; + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("Head{"); + sb.append("serviceId='").append(serviceId).append('\''); + sb.append(", token='").append(token).append('\''); + sb.append(", returnCode='").append(returnCode).append('\''); + sb.append(", returnDesc='").append(returnDesc).append('\''); + sb.append('}'); + return sb.toString(); + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/MemberGroupDto.java b/fuint-application/src/main/java/com/fuint/common/dto/MemberGroupDto.java new file mode 100644 index 0000000..a5d84a3 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/MemberGroupDto.java @@ -0,0 +1,50 @@ +package com.fuint.common.dto; + +import java.io.Serializable; +import java.util.Date; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +/** + * 会员分组实体 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class MemberGroupDto implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("分组ID") + private Integer id; + + @ApiModelProperty("分组名称") + private String name; + + @ApiModelProperty("所属商户ID") + private Integer merchantId; + + @ApiModelProperty("默认店铺") + private Integer storeId; + + @ApiModelProperty("父ID") + private Integer parentId; + + @ApiModelProperty("创建时间") + private Date createTime; + + @ApiModelProperty("更新时间") + private Date updateTime; + + @ApiModelProperty("状态,A:激活;N:禁用;D:删除") + private String status; + + @ApiModelProperty("备注信息") + private String description; + + @ApiModelProperty("最后操作人") + private String operator; +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/MemberTopDto.java b/fuint-application/src/main/java/com/fuint/common/dto/MemberTopDto.java new file mode 100644 index 0000000..2361070 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/MemberTopDto.java @@ -0,0 +1,36 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 会员排行DTO + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class MemberTopDto implements Serializable { + + @ApiModelProperty("会员ID") + private Integer id; + + @ApiModelProperty("会员名称") + private String name; + + @ApiModelProperty("会员号") + private String userNo; + + @ApiModelProperty("消费金额") + private BigDecimal amount; + + @ApiModelProperty("购买数量") + private Integer num; + +} + diff --git a/fuint-application/src/main/java/com/fuint/common/dto/MessageResDto.java b/fuint-application/src/main/java/com/fuint/common/dto/MessageResDto.java new file mode 100644 index 0000000..b95aa1b --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/MessageResDto.java @@ -0,0 +1,26 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +/** + * 短信发送返回实体 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class MessageResDto { + + @ApiModelProperty("发送ID") + private String[] sendIds; + + @ApiModelProperty("发送结果") + private Boolean result; + + @ApiModelProperty("短信ID") + private String[] smsId; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/MyCouponDto.java b/fuint-application/src/main/java/com/fuint/common/dto/MyCouponDto.java new file mode 100644 index 0000000..b2d5fe3 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/MyCouponDto.java @@ -0,0 +1,74 @@ +package com.fuint.common.dto; + +import com.fuint.repository.model.MtStore; +import com.fuint.repository.model.MtUser; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * 我的卡券DTO + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class MyCouponDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("卡券名称") + private String name; + + @ApiModelProperty("核销编码") + private String code; + + @ApiModelProperty("卡券类型") + private String type; + + @ApiModelProperty("状态") + private String status; + + @ApiModelProperty("卡券ID") + private Integer couponId; + + @ApiModelProperty("使用规则") + private String useRule; + + @ApiModelProperty("图片") + private String image; + + @ApiModelProperty("面额") + private BigDecimal amount; + + @ApiModelProperty("余额") + private BigDecimal balance; + + @ApiModelProperty("是否可用") + private boolean canUse; + + @ApiModelProperty("有效期") + private String effectiveDate; + + @ApiModelProperty("提示信息") + private String tips; + + @ApiModelProperty("使用时间") + private Date usedTime; + + @ApiModelProperty("领券时间") + private Date createTime; + + @ApiModelProperty("会员信息") + private MtUser userInfo; + + @ApiModelProperty("使用店铺") + private MtStore storeInfo; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/OpenGiftDto.java b/fuint-application/src/main/java/com/fuint/common/dto/OpenGiftDto.java new file mode 100644 index 0000000..f35f1bb --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/OpenGiftDto.java @@ -0,0 +1,53 @@ +package com.fuint.common.dto; + +import com.fuint.repository.model.MtCoupon; +import com.fuint.repository.model.MtStore; +import com.fuint.repository.model.MtUserGrade; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; + +/** + * 开卡赠礼实体类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class OpenGiftDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("店铺信息") + private MtStore storeInfo; + + @ApiModelProperty("会员等级信息") + private MtUserGrade gradeInfo; + + @ApiModelProperty("赠送积分") + private Integer point; + + @ApiModelProperty("卡券信息") + private MtCoupon couponInfo; + + @ApiModelProperty("卡券数量") + private Integer couponNum; + + @ApiModelProperty("创建时间") + private String createTime; + + @ApiModelProperty("更新时间") + private String updateTime; + + @ApiModelProperty("状态") + private String status; + + @ApiModelProperty("最后操作人") + private String operator; + +} + diff --git a/fuint-application/src/main/java/com/fuint/common/dto/OrderDto.java b/fuint-application/src/main/java/com/fuint/common/dto/OrderDto.java new file mode 100644 index 0000000..b4ed0c7 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/OrderDto.java @@ -0,0 +1,127 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * 订单实体类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class OrderDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("订单类型") + private String type; + + @ApiModelProperty("下单平台") + private String platform; + + @ApiModelProperty("支付类型") + private String payType; + + @ApiModelProperty("订单类型名称") + private String orderMode; + + @ApiModelProperty("核销码") + private String verifyCode; + + @ApiModelProperty("订单号") + private String orderSn; + + @ApiModelProperty("卡券ID") + private Integer couponId; + + @ApiModelProperty("购物车ID") + private String cartIds; + + @ApiModelProperty("商品ID") + private Integer goodsId; + + @ApiModelProperty("skuID") + private Integer skuId; + + @ApiModelProperty("购买数量") + private Integer buyNum; + + @ApiModelProperty("会员ID") + private Integer userId; + + @ApiModelProperty("是否游客") + private String isVisitor; + + @ApiModelProperty("店铺ID") + private Integer storeId; + + @ApiModelProperty("商户ID") + private Integer merchantId; + + @ApiModelProperty("员工ID") + private Integer staffId; + + @ApiModelProperty("订单金额") + private BigDecimal amount; + + @ApiModelProperty("支付金额") + private BigDecimal payAmount; + + @ApiModelProperty("使用积分数量") + private Integer usePoint; + + @ApiModelProperty("积分金额") + private BigDecimal pointAmount; + + @ApiModelProperty("折扣金额") + private BigDecimal discount; + + @ApiModelProperty("配送费用") + private BigDecimal deliveryFee; + + @ApiModelProperty("物流信息") + private ExpressDto expressInfo; + + @ApiModelProperty("订单参数") + private String param; + + @ApiModelProperty("用户备注") + private String remark; + + @ApiModelProperty("创建时间") + private Date createTime; + + @ApiModelProperty("更新时间") + private Date updateTime; + + @ApiModelProperty("支付时间") + private Date payTime; + + @ApiModelProperty("订单状态") + private String status; + + @ApiModelProperty("支付状态") + private String payStatus; + + @ApiModelProperty(value="结算状态") + private String settleStatus; + + @ApiModelProperty("最后操作人") + private String operator; + + @ApiModelProperty("收银地点ID") + private Integer storeLocationId; + + @ApiModelProperty("预付金额") + private BigDecimal prePayment; + +} + diff --git a/fuint-application/src/main/java/com/fuint/common/dto/OrderGoodsDto.java b/fuint-application/src/main/java/com/fuint/common/dto/OrderGoodsDto.java new file mode 100644 index 0000000..e7f9e7b --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/OrderGoodsDto.java @@ -0,0 +1,51 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.util.List; + +/** + * 订单商品实体类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class OrderGoodsDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("商品ID") + private Integer goodsId; + + @ApiModelProperty("订单类型") + private String type; + + @ApiModelProperty("商品名称") + private String name; + + @ApiModelProperty("价格") + private String price; + + @ApiModelProperty("折扣") + private String discount; + + @ApiModelProperty("购买数量") + private Integer num; + + @ApiModelProperty("图片") + private String image; + + @ApiModelProperty("skuId") + private Integer skuId; + + @ApiModelProperty("规格列表") + private List specList; + +} + diff --git a/fuint-application/src/main/java/com/fuint/common/dto/OrderUserDto.java b/fuint-application/src/main/java/com/fuint/common/dto/OrderUserDto.java new file mode 100644 index 0000000..3de3600 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/OrderUserDto.java @@ -0,0 +1,39 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; +import java.io.Serializable; + +/** + * 下单用户DTO + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class OrderUserDto implements Serializable { + + @ApiModelProperty("会员ID") + private Integer id; + + @ApiModelProperty("会员姓名") + private String name; + + @ApiModelProperty("会员手机") + private String mobile; + + @ApiModelProperty("会员卡号") + private String userNo; + + @ApiModelProperty("证件类型") + private String cardType; + + @ApiModelProperty("证件号") + private String cardNo; + + @ApiModelProperty("地址") + private String address; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/Page.java b/fuint-application/src/main/java/com/fuint/common/dto/Page.java new file mode 100644 index 0000000..a39bfe9 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/Page.java @@ -0,0 +1,120 @@ +package com.fuint.common.dto; + +import java.io.Serializable; + +/** + * 消息体分页信息 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public class Page implements Serializable { + + private static final Long DEFAULT_PAGE_NO = 1L; + private static final Long DEFAULT_PAGE_SIZE = 100L; + + private Long pageNo;// 页号 + private Long pageSize;// 每页行数 + private Long totalRows;// 总行数 + private Long totalPages;// 总页数 + private Boolean firstPage;// 是否首页 + private Boolean lastPage;// 是否尾页 + + public Page() { + } + + public Page(Long pageNo, Long pageSize) { + setPageNo(pageNo); + setPageSize(pageSize); + } + + public Long getPageNo() { + return pageNo; + } + + public void setPageNo(Long pageNo) { + if (pageNo == null || pageNo < 1) { + pageNo = DEFAULT_PAGE_NO; + } else if (totalPages != null && pageNo > totalPages) { + pageNo = totalPages; + } + this.pageNo = pageNo; + } + + public Long getPageSize() { + return pageSize; + } + + public void setPageSize(Long pageSize) { + if (pageSize == null) { + this.pageSize = DEFAULT_PAGE_SIZE; + } else if (pageSize < 1L) { + this.pageSize = 1L; + } else { + this.pageSize = pageSize; + } + } + + public Long getTotalRows() { + return totalRows; + } + + public void setTotalRows(Long totalRows) { + //总行数 + this.totalRows = totalRows; + //总页数 + this.totalPages = totalRows / this.pageSize; + if (totalRows % this.pageSize > 0) { + this.totalPages++; + } + //首页 + if (this.pageNo <= 1) { + firstPage = true; + } else { + firstPage = false; + } + //尾页 + if (this.pageNo >= this.totalPages) { + lastPage = true; + } else { + lastPage = false; + } + } + + public Long getTotalPages() { + return totalPages; + } + + public void setTotalPages(Long totalPages) { + this.totalPages = totalPages; + } + + public Boolean isFirstPage() { + return firstPage; + } + + public void setFirstPage(Boolean firstPage) { + this.firstPage = firstPage; + } + + public Boolean isLastPage() { + return lastPage; + } + + public void setLastPage(Boolean lastPage) { + this.lastPage = lastPage; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("Page{"); + sb.append("pageNo=").append(pageNo); + sb.append(", pageSize=").append(pageSize); + sb.append(", totalRows=").append(totalRows); + sb.append(", totalPages=").append(totalPages); + sb.append(", firstPage=").append(firstPage); + sb.append(", lastPage=").append(lastPage); + sb.append('}'); + return sb.toString(); + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/ParamDto.java b/fuint-application/src/main/java/com/fuint/common/dto/ParamDto.java new file mode 100644 index 0000000..7d6b53b --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/ParamDto.java @@ -0,0 +1,28 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; + +/** + * 请求参数实体类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class ParamDto implements Serializable { + + @ApiModelProperty("参数键值") + private String key; + + @ApiModelProperty("参数名称") + private String name; + + @ApiModelProperty("参数值") + private String value; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/PointDto.java b/fuint-application/src/main/java/com/fuint/common/dto/PointDto.java new file mode 100644 index 0000000..d990ed7 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/PointDto.java @@ -0,0 +1,52 @@ +package com.fuint.common.dto; + +import com.fuint.repository.model.MtUser; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.util.Date; + +/** + * 积分记录实体类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class PointDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("会员ID") + private Integer userId; + + @ApiModelProperty("会员信息") + private MtUser userInfo; + + @ApiModelProperty("订单号") + private String orderSn; + + @ApiModelProperty("积分变化数量") + private Integer amount; + + @ApiModelProperty("创建时间") + private Date createTime; + + @ApiModelProperty("更新时间") + private Date updateTime; + + @ApiModelProperty("备注说明") + private String description; + + @ApiModelProperty("最后操作人") + private String operator; + + @ApiModelProperty("状态,A正常;D删除") + private String status; + +} + diff --git a/fuint-application/src/main/java/com/fuint/common/dto/PreStoreRuleDto.java b/fuint-application/src/main/java/com/fuint/common/dto/PreStoreRuleDto.java new file mode 100644 index 0000000..89dcac3 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/PreStoreRuleDto.java @@ -0,0 +1,25 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; + +/** + * 预存规则实体类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class PreStoreRuleDto implements Serializable { + + @ApiModelProperty("预存金额") + private String preStoreAmount; + + @ApiModelProperty("目标金额") + private String targetAmount; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/RechargeRuleDto.java b/fuint-application/src/main/java/com/fuint/common/dto/RechargeRuleDto.java new file mode 100644 index 0000000..fbb73f5 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/RechargeRuleDto.java @@ -0,0 +1,25 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; + +/** + * 充值规则实体类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class RechargeRuleDto implements Serializable { + + @ApiModelProperty("充值金额") + private String rechargeAmount; + + @ApiModelProperty("赠送金额") + private String giveAmount; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/RefundDto.java b/fuint-application/src/main/java/com/fuint/common/dto/RefundDto.java new file mode 100644 index 0000000..381a267 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/RefundDto.java @@ -0,0 +1,85 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; + +/** + * 售后实体类 + */ +@Getter +@Setter +public class RefundDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("订单ID") + private Integer orderId; + + @ApiModelProperty("商户ID") + private Integer merchantId; + + @ApiModelProperty("店铺ID") + private Integer storeId; + + @ApiModelProperty("退款金额") + private BigDecimal amount; + + @ApiModelProperty("售后类型") + private String type; + + @ApiModelProperty("会员ID") + private Integer userId; + + @ApiModelProperty("用户备注") + private String remark; + + @ApiModelProperty("申请凭证图片") + private List imageList; + + @ApiModelProperty("申请凭证图片") + private String images; + + @ApiModelProperty("最后操作人") + private String operator; + + @ApiModelProperty("订单详情") + private UserOrderDto orderInfo; + + @ApiModelProperty("退货地址") + private AddressDto address; + + @ApiModelProperty("创建时间") + private String createTime; + + @ApiModelProperty("更新时间") + private String updateTime; + + @ApiModelProperty("状态") + private String status; + + @ApiModelProperty("状态说明") + private String statusText; + + @ApiModelProperty("申请人") + private String applicant; + + @ApiModelProperty("驳回原因") + private String rejectReason; + + @ApiModelProperty("订单号") + private String orderSn; + + @ApiModelProperty("订单用户信息") + private UserDto userInfo; + + @ApiModelProperty("店铺信息") + private StoreDto storeInfo; + +} + diff --git a/fuint-application/src/main/java/com/fuint/common/dto/RegionDto.java b/fuint-application/src/main/java/com/fuint/common/dto/RegionDto.java new file mode 100644 index 0000000..773c69b --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/RegionDto.java @@ -0,0 +1,41 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.util.List; + +/** + * 地区实体类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class RegionDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("名称") + private String name; + + @ApiModelProperty("父ID") + private Integer pid; + + @ApiModelProperty("编码") + private String code; + + @ApiModelProperty("层级") + private String level; + + @ApiModelProperty("城市") + private List city; + + @ApiModelProperty("区域") + private List region; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/ReqCouponDto.java b/fuint-application/src/main/java/com/fuint/common/dto/ReqCouponDto.java new file mode 100644 index 0000000..241012d --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/ReqCouponDto.java @@ -0,0 +1,119 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 卡券请求DTO + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class ReqCouponDto implements Serializable { + + @ApiModelProperty("卡券ID") + private Integer id; + + @ApiModelProperty("商户ID") + private Integer merchantId; + + @ApiModelProperty("店铺ID") + private Integer storeId; + + @ApiModelProperty("分组ID") + private Integer groupId; + + @ApiModelProperty("类型") + private String type; + + @ApiModelProperty("名称") + private String name; + + @ApiModelProperty("是否允许转赠") + private Integer isGive; + + @ApiModelProperty("获得卡券所消耗积分") + private Integer point; + + @ApiModelProperty("获得计次卡卡所消耗积分") + private Integer timerPoint; + + @ApiModelProperty("领取码") + private String receiveCode; + + @ApiModelProperty("使用专项") + private String useFor; + + @ApiModelProperty("过期类型") + private String expireType; + + @ApiModelProperty("有效天数") + private Integer expireTime; + + @ApiModelProperty("计次卡领取码") + private String timerReceiveCode; + + @ApiModelProperty("有效期开始时间") + private String beginTime; + + @ApiModelProperty("有效期结束时间") + private String endTime; + + @ApiModelProperty("价值金额") + private BigDecimal amount; + + @ApiModelProperty("发放方式") + private String sendWay; + + @ApiModelProperty("适用商品") + private String applyGoods; + + @ApiModelProperty("每次发放数量") + private Integer sendNum; + + @ApiModelProperty("发行总数量") + private Integer total; + + @ApiModelProperty("每人最多拥有数量") + private Integer limitNum; + + @ApiModelProperty("例外时间") + private String exceptTime; + + @ApiModelProperty("适用店铺ID,逗号分隔") + private String storeIds; + + @ApiModelProperty("会员等级ID,逗号分隔") + private String gradeIds; + + @ApiModelProperty("适用商品") + private String goodsIds; + + @ApiModelProperty("后台备注") + private String remarks; + + @ApiModelProperty("图片") + private String image; + + @ApiModelProperty("备注") + private String description; + + @ApiModelProperty("预存规则") + private String inRule; + + @ApiModelProperty("核销规则") + private String outRule; + + @ApiModelProperty("操作人") + private String operator; + + @ApiModelProperty("状态") + private String status; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/ReqCouponGroupDto.java b/fuint-application/src/main/java/com/fuint/common/dto/ReqCouponGroupDto.java new file mode 100644 index 0000000..ae045b1 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/ReqCouponGroupDto.java @@ -0,0 +1,46 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 卡券分组请求DTO + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class ReqCouponGroupDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("商户ID") + private Integer merchantId; + + @ApiModelProperty("店铺ID") + private Integer storeId; + + @ApiModelProperty("分组名称") + private String name; + + @ApiModelProperty("价值金额") + private BigDecimal money; + + @ApiModelProperty("发行数量") + private Integer total; + + @ApiModelProperty("分组描述") + private String description; + + @ApiModelProperty("操作人") + private String operator; + + @ApiModelProperty("状态") + private String status; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/ReqResult.java b/fuint-application/src/main/java/com/fuint/common/dto/ReqResult.java new file mode 100644 index 0000000..c083efa --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/ReqResult.java @@ -0,0 +1,31 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; +import java.io.Serializable; +import java.util.Map; + +/** + * 请求返回结果 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class ReqResult implements Serializable { + + @ApiModelProperty("返回代码") + private String code; + + @ApiModelProperty("返回消息") + private String msg; + + @ApiModelProperty("返回结果") + private boolean result; + + @ApiModelProperty("返回数据") + private Map data; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/ReqSendLogDto.java b/fuint-application/src/main/java/com/fuint/common/dto/ReqSendLogDto.java new file mode 100644 index 0000000..bc049f7 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/ReqSendLogDto.java @@ -0,0 +1,68 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.util.Date; + +/** + * 发放卡券记录请求DTO + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class ReqSendLogDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("商户ID") + private Integer merchantId; + + @ApiModelProperty("店铺ID") + private Integer storeId; + + @ApiModelProperty("类型,1:单用户发券;2:批量发券") + private Integer type; + + @ApiModelProperty("会员ID") + private Integer userId; + + @ApiModelProperty("导入文件名") + private String fileName; + + @ApiModelProperty("导入文件路径") + private String filePath; + + @ApiModelProperty("手机号") + private String mobile; + + @ApiModelProperty("分组ID") + private Integer groupId; + + @ApiModelProperty("卡券ID") + private Integer couponId; + + @ApiModelProperty("分组名称") + private String groupName; + + @ApiModelProperty("发放数量") + private Integer sendNum; + + @ApiModelProperty("发放时间") + private Date createTime; + + @ApiModelProperty("操作人") + private String operator; + + @ApiModelProperty("状态") + private String status; + + @ApiModelProperty("uuid") + private String uuid; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/ResCartDto.java b/fuint-application/src/main/java/com/fuint/common/dto/ResCartDto.java new file mode 100644 index 0000000..2fe35e8 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/ResCartDto.java @@ -0,0 +1,52 @@ +package com.fuint.common.dto; + +import com.fuint.repository.model.MtGoods; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; + +/** + * 购物车返回DTO + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class ResCartDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("会员ID") + private Integer userId; + + @ApiModelProperty("商品ID") + private Integer goodsId; + + @ApiModelProperty("skuId") + private Integer skuId; + + @ApiModelProperty("数量") + private Integer num; + + @ApiModelProperty("商品自定义价格") + private BigDecimal selfPrice; + + @ApiModelProperty("预付金") + private BigDecimal prePayment; + + @ApiModelProperty("是否有效") + private Boolean isEffect; + + @ApiModelProperty("商品规格") + private List specList; + + @ApiModelProperty("商品数据") + private MtGoods goodsInfo; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/ResCateDto.java b/fuint-application/src/main/java/com/fuint/common/dto/ResCateDto.java new file mode 100644 index 0000000..f9592e7 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/ResCateDto.java @@ -0,0 +1,33 @@ +package com.fuint.common.dto; + +import com.fuint.repository.model.MtGoods; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.util.List; + +/** + * 商品分类返回DTO + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class ResCateDto implements Serializable { + + @ApiModelProperty("分类ID") + private Integer cateId; + + @ApiModelProperty("分类名称") + private String name; + + @ApiModelProperty("logo") + private String logo; + + @ApiModelProperty("商品列表") + private List goodsList; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/RoleDto.java b/fuint-application/src/main/java/com/fuint/common/dto/RoleDto.java new file mode 100644 index 0000000..ed78834 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/RoleDto.java @@ -0,0 +1,35 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +/** + * 角色信息实体类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class RoleDto { + + @ApiModelProperty("账户主键ID") + private Long id; + + @ApiModelProperty("商户ID") + private Integer merchantId; + + @ApiModelProperty("名称") + private String name; + + @ApiModelProperty("角色类型") + private String type; + + @ApiModelProperty("备注") + private String description; + + @ApiModelProperty("状态 : A有效 D无效") + private String status; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/SettlementDto.java b/fuint-application/src/main/java/com/fuint/common/dto/SettlementDto.java new file mode 100644 index 0000000..c8d694b --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/SettlementDto.java @@ -0,0 +1,60 @@ +package com.fuint.common.dto; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; +import com.fuint.framework.pagination.PaginationResponse; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +/** + * 结算实体类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class SettlementDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("结算单号") + private String settlementNo; + + @ApiModelProperty("商户ID") + private Integer merchantId; + + @ApiModelProperty("店铺ID") + private Integer storeId; + + @ApiModelProperty("订单总金额") + private BigDecimal totalOrderAmount; + + @ApiModelProperty("结算金额") + private BigDecimal amount; + + @ApiModelProperty("结算订单") + private PaginationResponse orderList; + + @ApiModelProperty("创建时间") + private Date createTime; + + @ApiModelProperty("更新时间") + private Date updateTime; + + @ApiModelProperty("备注说明") + private String description; + + @ApiModelProperty("最后操作人") + private String operator; + + @ApiModelProperty("支付状态,A待支付;B已支付") + private String payStatus; + + @ApiModelProperty("状态,A正常;D删除") + private String status; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/SettlementOrderDto.java b/fuint-application/src/main/java/com/fuint/common/dto/SettlementOrderDto.java new file mode 100644 index 0000000..b5842c5 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/SettlementOrderDto.java @@ -0,0 +1,46 @@ +package com.fuint.common.dto; + +import java.io.Serializable; +import java.util.Date; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +/** + * 结算订单表 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class SettlementOrderDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("结算ID") + private Integer settlementId; + + @ApiModelProperty("订单ID") + private Integer orderId; + + @ApiModelProperty("订单信息") + private UserOrderDto orderInfo; + + @ApiModelProperty("创建时间") + private Date createTime; + + @ApiModelProperty("更新时间") + private Date updateTime; + + @ApiModelProperty("备注说明") + private String description; + + @ApiModelProperty("最后操作人") + private String operator; + + @ApiModelProperty("状态,A正常;D删除") + private String status; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/SmsTemplateDto.java b/fuint-application/src/main/java/com/fuint/common/dto/SmsTemplateDto.java new file mode 100644 index 0000000..c82671c --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/SmsTemplateDto.java @@ -0,0 +1,47 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.util.Date; + +/** + * 短信模板实体类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class SmsTemplateDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("商户ID") + private Integer merchantId; + + @ApiModelProperty("模板名称") + private String name; + + @ApiModelProperty("模板英文名称") + private String uname; + + @ApiModelProperty("模板编码") + private String code; + + @ApiModelProperty("模板内容") + private String content; + + @ApiModelProperty("创建时间") + private Date createTime; + + @ApiModelProperty("更新时间") + private Date updateTime; + + @ApiModelProperty("状态,1:正常;2:删除") + private String status; + +} \ No newline at end of file diff --git a/fuint-application/src/main/java/com/fuint/common/dto/SourceDto.java b/fuint-application/src/main/java/com/fuint/common/dto/SourceDto.java new file mode 100644 index 0000000..75f7433 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/SourceDto.java @@ -0,0 +1,70 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; +import java.io.Serializable; +import java.util.List; + +/** + * 菜单信息实体 + */ +@Getter +@Setter +public class SourceDto implements Serializable { + + @ApiModelProperty("自增ID") + private long id; + + @ApiModelProperty("商户ID") + private Integer merchantId; + + @ApiModelProperty("菜单名称") + private String name; + + @ApiModelProperty("菜单名称(字母)") + private String ename; + + @ApiModelProperty("节点是否打开") + private Boolean open; + + @ApiModelProperty("是否菜单") + private int isMenu; + + @ApiModelProperty("节点是否选中") + private Boolean checked; + + @ApiModelProperty("url") + private String url; + + @ApiModelProperty("路径") + private String path; + + @ApiModelProperty("权限标识") + private String perms; + + @ApiModelProperty("菜单级别") + private int level; + + @ApiModelProperty("上级菜单") + private long parentId; + + @ApiModelProperty("子菜单") + private List children; + + @ApiModelProperty("图标") + private String icon; + + @ApiModelProperty("新图标") + private String newIcon; + + @ApiModelProperty("描述信息") + private String description; + + @ApiModelProperty("排序") + private String sort; + + @ApiModelProperty("状态") + private String status; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/StoreDto.java b/fuint-application/src/main/java/com/fuint/common/dto/StoreDto.java new file mode 100644 index 0000000..39697c9 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/StoreDto.java @@ -0,0 +1,109 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; +import java.io.Serializable; +import java.util.Date; + +/** + * 店铺实体 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + * */ +@Getter +@Setter +public class StoreDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("商户ID") + private Integer merchantId; + + @ApiModelProperty("商户号") + private String merchantNo; + + @ApiModelProperty("商户名称") + private String merchantName; + + @ApiModelProperty("店铺名称") + private String name; + + @ApiModelProperty("店铺二维码") + private String qrCode; + + @ApiModelProperty("店铺LOGO") + private String logo; + + @ApiModelProperty("是否默认店铺") + private String isDefault; + + @ApiModelProperty("联系人") + private String contact; + + @ApiModelProperty("联系电话") + private String phone; + + @ApiModelProperty("店铺地址") + private String address; + + @ApiModelProperty("营业时间") + private String hours; + + @ApiModelProperty("经度") + private String latitude; + + @ApiModelProperty("纬度") + private String longitude; + + @ApiModelProperty("备注信息") + private String description; + + @ApiModelProperty("微信商户号") + private String wxMchId; + + @ApiModelProperty("微信支付秘钥") + private String wxApiV2; + + @ApiModelProperty("微信支付证书") + private String wxCertPath; + + @ApiModelProperty("支付宝appId") + private String alipayAppId; + + @ApiModelProperty("支付宝应用私钥") + private String alipayPrivateKey; + + @ApiModelProperty("支付宝支付公钥") + private String alipayPublicKey; + + @ApiModelProperty("营业执照") + private String license; + + @ApiModelProperty("统一社会信用代码") + private String creditCode; + + @ApiModelProperty("银行名称") + private String bankName; + + @ApiModelProperty("银行卡账户名") + private String bankCardName; + + @ApiModelProperty("银行卡卡号") + private String bankCardNo; + + @ApiModelProperty("创建时间") + private Date createTime; + + @ApiModelProperty("更新时间") + private Date updateTime; + + @ApiModelProperty("状态,1:正常;2:删除") + private String status; + + @ApiModelProperty("最后操作人") + private String operator; + +} \ No newline at end of file diff --git a/fuint-application/src/main/java/com/fuint/common/dto/StoreLocationDto.java b/fuint-application/src/main/java/com/fuint/common/dto/StoreLocationDto.java new file mode 100644 index 0000000..40d97ad --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/StoreLocationDto.java @@ -0,0 +1,37 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.util.Date; + +/** + * 店铺地点实体类 + */ +@Getter +@Setter +public class StoreLocationDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("地点名称") + private String name; + + @ApiModelProperty("备注信息") + private String content; + + @ApiModelProperty("创建时间") + private Date createTime; + + @ApiModelProperty("更新时间") + private Date updateTime; + + @ApiModelProperty("更后操作人") + private String operator; + + @ApiModelProperty("状态,1:正常;2:删除") + private String status; +} \ No newline at end of file diff --git a/fuint-application/src/main/java/com/fuint/common/dto/SubMessageDto.java b/fuint-application/src/main/java/com/fuint/common/dto/SubMessageDto.java new file mode 100644 index 0000000..af15c9c --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/SubMessageDto.java @@ -0,0 +1,40 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.util.List; + +/** + * 小程序订阅消息dto + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class SubMessageDto implements Serializable { + + @ApiModelProperty("键值") + private String key; + + @ApiModelProperty("模板ID") + private String templateId; + + @ApiModelProperty("TID") + private String tid; + + @ApiModelProperty("标题") + private String title; + + @ApiModelProperty("内容") + private String content; + + @ApiModelProperty("状态") + private String status; + + @ApiModelProperty("模板参数") + private List params; +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/TokenDto.java b/fuint-application/src/main/java/com/fuint/common/dto/TokenDto.java new file mode 100644 index 0000000..0a3b21a --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/TokenDto.java @@ -0,0 +1,30 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; + +/** + * 登录Token实体 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class TokenDto implements Serializable { + + @ApiModelProperty("token") + private String token; + + @ApiModelProperty("创建时间") + private Long tokenCreatedTime; + + @ApiModelProperty("失效时间") + private Long tokenExpiryTime; + + @ApiModelProperty("是否登录") + private String isLogin; +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/UserCouponDto.java b/fuint-application/src/main/java/com/fuint/common/dto/UserCouponDto.java new file mode 100644 index 0000000..b7caf4a --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/UserCouponDto.java @@ -0,0 +1,76 @@ +package com.fuint.common.dto; + +import com.fuint.repository.model.MtConfirmLog; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; + +/** + * 我的卡券实体类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class UserCouponDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("卡券名称") + private String name; + + @ApiModelProperty("卡券类型") + private String type; + + @ApiModelProperty("状态") + private String status; + + @ApiModelProperty("卡券ID") + private Integer couponId; + + @ApiModelProperty("使用规则") + private String useRule; + + @ApiModelProperty("核销编码") + private String code; + + @ApiModelProperty("二维码") + private String qrCode; + + @ApiModelProperty("图片") + private String image; + + @ApiModelProperty("面额") + private BigDecimal amount; + + @ApiModelProperty("是否允许转赠") + private Boolean isGive; + + @ApiModelProperty("余额") + private BigDecimal balance; + + @ApiModelProperty("核销次数") + private Integer confirmCount; + + @ApiModelProperty("核销记录") + private List confirmLogs; + + @ApiModelProperty("是否可用(过期、状态等)") + private boolean canUse; + + @ApiModelProperty("有效期") + private String effectiveDate; + + @ApiModelProperty("提示信息") + private String tips; + + @ApiModelProperty("描述信息") + private String description; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/UserDto.java b/fuint-application/src/main/java/com/fuint/common/dto/UserDto.java new file mode 100644 index 0000000..9a63144 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/UserDto.java @@ -0,0 +1,114 @@ +package com.fuint.common.dto; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +/** + * 会员个人信息 + */ +@Getter +@Setter +public class UserDto implements Serializable { + + @ApiModelProperty("会员ID") + private Integer id; + + @ApiModelProperty("会员号") + private String userNo; + + @ApiModelProperty("头像") + private String avatar; + + @ApiModelProperty("称呼") + private String name; + + @ApiModelProperty("是否设置密码") + private String hasPassword; + + @ApiModelProperty("分组ID") + private Integer groupId; + + @ApiModelProperty("分组信息") + private UserGroupDto groupInfo; + + @ApiModelProperty("微信open_id") + private String openId; + + @ApiModelProperty("手机号码") + private String mobile; + + @ApiModelProperty("证件号码") + private String idcard; + + @ApiModelProperty("等级ID") + private String gradeId; + + @ApiModelProperty("等级名称") + private String gradeName; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @ApiModelProperty("会员开始时间") + private Date startTime; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @ApiModelProperty("会员结束时间") + private Date endTime; + + @ApiModelProperty("余额") + private BigDecimal balance; + + @ApiModelProperty("积分") + private Integer point; + + @ApiModelProperty("性别 1男;0女") + private Integer sex; + + @ApiModelProperty("出生日期") + private String birthday; + + @ApiModelProperty("车牌号") + private String carNo; + + @ApiModelProperty("来源渠道") + private String source; + + @ApiModelProperty("地址") + private String address; + + @ApiModelProperty("所属商户ID") + private Integer merchantId; + + @ApiModelProperty("所属商户名称") + private String merchantName; + + @ApiModelProperty("默认店铺ID") + private Integer storeId; + + @ApiModelProperty("默认店铺名称") + private String storeName; + + @ApiModelProperty("创建时间") + private Date createTime; + + @ApiModelProperty("更新时间") + private Date updateTime; + + @ApiModelProperty("最近登录时间") + private String lastLoginTime; + + @ApiModelProperty("状态,A:激活;N:禁用;D:删除") + private String status; + + @ApiModelProperty("备注信息") + private String description; + + @ApiModelProperty("最后操作人") + private String operator; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/UserGroupDto.java b/fuint-application/src/main/java/com/fuint/common/dto/UserGroupDto.java new file mode 100644 index 0000000..085ddb0 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/UserGroupDto.java @@ -0,0 +1,56 @@ +package com.fuint.common.dto; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +/** + * 会员分组 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class UserGroupDto implements Serializable { + + @ApiModelProperty("分组ID") + private Integer id; + + @ApiModelProperty("分组名称") + private String name; + + @ApiModelProperty("所属商户ID") + private Integer merchantId; + + @ApiModelProperty("默认店铺") + private Integer storeId; + + @ApiModelProperty("父ID") + private Integer parentId; + + @ApiModelProperty("子分组") + private List children; + + @ApiModelProperty("会员数量") + private Long memberNum; + + @ApiModelProperty("创建时间") + private Date createTime; + + @ApiModelProperty("更新时间") + private Date updateTime; + + @ApiModelProperty("状态,A:激活;N:禁用;D:删除") + private String status; + + @ApiModelProperty("备注信息") + private String description; + + @ApiModelProperty("最后操作人") + private String operator; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/UserInfo.java b/fuint-application/src/main/java/com/fuint/common/dto/UserInfo.java new file mode 100644 index 0000000..521ef5f --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/UserInfo.java @@ -0,0 +1,22 @@ +package com.fuint.common.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; + +/** + * 会员登录信息实体类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Data +public class UserInfo implements Serializable { + + @ApiModelProperty("会员ID") + private Integer id; + + @ApiModelProperty("登录Token") + private String token; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/dto/UserOrderDto.java b/fuint-application/src/main/java/com/fuint/common/dto/UserOrderDto.java new file mode 100644 index 0000000..e05cdfb --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/dto/UserOrderDto.java @@ -0,0 +1,137 @@ +package com.fuint.common.dto; + +import com.fuint.repository.model.MtRefund; +import com.fuint.repository.model.MtStore; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; + +/** + * 会员订单实体类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Getter +@Setter +public class UserOrderDto implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("商户ID") + private Integer merchantId; + + @ApiModelProperty("订单号") + private String orderSn; + + @ApiModelProperty("订单类型") + private String type; + + @ApiModelProperty("订单类型名称") + private String typeName; + + @ApiModelProperty("支付类型") + private String payType; + + @ApiModelProperty("订单模式") + private String orderMode; + + @ApiModelProperty("是否核销") + private Boolean isVerify; + + @ApiModelProperty("卡券ID") + private Integer couponId; + + @ApiModelProperty("会员ID") + private Integer userId; + + @ApiModelProperty("是否游客") + private String isVisitor; + + @ApiModelProperty("核销码") + private String verifyCode; + + @ApiModelProperty("员工ID") + private Integer staffId; + + @ApiModelProperty("总金额") + private BigDecimal amount; + + @ApiModelProperty("支付金额") + private BigDecimal payAmount; + + @ApiModelProperty("优惠金额") + private BigDecimal discount; + + @ApiModelProperty("配送费用") + private BigDecimal deliveryFee; + + @ApiModelProperty("使用积分") + private Integer usePoint; + + @ApiModelProperty("积分金额") + private BigDecimal pointAmount; + + @ApiModelProperty("订单参数") + private String param; + + @ApiModelProperty("备注信息") + private String remark; + + @ApiModelProperty("创建时间") + private String createTime; + + @ApiModelProperty("更新时间") + private String updateTime; + + @ApiModelProperty("支付时间") + private String payTime; + + @ApiModelProperty("订单状态") + private String status; + + @ApiModelProperty("支付状态") + private String payStatus; + + @ApiModelProperty(value="结算状态") + private String settleStatus; + + @ApiModelProperty("状态说明") + private String statusText; + + @ApiModelProperty("最后操作人") + private String operator; + + @ApiModelProperty("订单商品列表") + private List goods; + + @ApiModelProperty("下单用户信息") + private OrderUserDto userInfo; + + @ApiModelProperty("配送地址") + private AddressDto address; + + @ApiModelProperty("物流信息") + private ExpressDto expressInfo; + + @ApiModelProperty("所属店铺信息") + private MtStore storeInfo; + + @ApiModelProperty("售后订单") + private MtRefund refundInfo; + + @ApiModelProperty("使用卡券") + private UserCouponDto couponInfo; + + @ApiModelProperty("收银地点ID") + private Integer storeLocationId; + + @ApiModelProperty("订单预付金") + private BigDecimal prePayment; +} + diff --git a/fuint-application/src/main/java/com/fuint/common/enums/AdminRoleEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/AdminRoleEnum.java new file mode 100644 index 0000000..4351d59 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/AdminRoleEnum.java @@ -0,0 +1,77 @@ +package com.fuint.common.enums; + +/** + * 后台角色枚举 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum AdminRoleEnum { + ADMIN("1", "超级管理员","admin"), + COMMON("2", "普通管理员","common"), + USER("3", "用户角色","user"); + + private String key; + private String name; + private String value; + + AdminRoleEnum(String key, String name, String value) { + this.key = key; + this.name = name; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + // 普通方法,通过key获取value + public static String getValue(String k) { + for (AdminRoleEnum c : AdminRoleEnum.values()) { + if (c.getKey().equals(k)) { + return c.getValue(); + } + } + return null; + } + + // 普通方法,通过key获取name + public static String getName(String k) { + for (AdminRoleEnum c : AdminRoleEnum.values()) { + if (c.getKey().equals(k)) { + return c.getName(); + } + } + return null; + } + + // 普通方法,通过Value获取key + public static String getKey(String v) { + for (AdminRoleEnum c : AdminRoleEnum.values()) { + if (c.getValue() == v) { + return c.getKey(); + } + } + return null; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/ApplyGoodsEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/ApplyGoodsEnum.java new file mode 100644 index 0000000..3878d1a --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/ApplyGoodsEnum.java @@ -0,0 +1,57 @@ +package com.fuint.common.enums; + +/** + * 卡券适用商品 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum ApplyGoodsEnum { + ALL_GOODS("allGoods", "全场通用"), + PARK_GOODS("parkGoods", "指定商品"); + + private String key; + + private String value; + + ApplyGoodsEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + // 普通方法,通过key获取value + public static String getValue(String k) { + for (ApplyGoodsEnum c : ApplyGoodsEnum.values()) { + if (c.getKey().equals(k)) { + return c.getValue(); + } + } + return null; + } + + // 普通方法,通过Value获取key + public static String getKey(String v) { + for (ApplyGoodsEnum c : ApplyGoodsEnum.values()) { + if (c.getValue() == v) { + return c.getKey(); + } + } + return null; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/BalanceSettingEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/BalanceSettingEnum.java new file mode 100644 index 0000000..b8870ad --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/BalanceSettingEnum.java @@ -0,0 +1,57 @@ +package com.fuint.common.enums; + +/** + * 充值配置项枚举 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum BalanceSettingEnum { + RECHARGE_RULE("rechargeRule", "充值规则"), + RECHARGE_REMARK("rechargeRemark", "充值说明"); + + private String key; + + private String value; + + BalanceSettingEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + // 普通方法,通过key获取value + public static String getValue(String k) { + for (BalanceSettingEnum c : BalanceSettingEnum.values()) { + if (c.getKey().equals(k)) { + return c.getValue(); + } + } + return null; + } + + // 普通方法,通过Value获取key + public static String getKey(String v) { + for (BalanceSettingEnum c : BalanceSettingEnum.values()) { + if (c.getValue() == v) { + return c.getKey(); + } + } + return null; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/CommissionStatusEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/CommissionStatusEnum.java new file mode 100644 index 0000000..966e267 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/CommissionStatusEnum.java @@ -0,0 +1,37 @@ +package com.fuint.common.enums; + +/** + * 分佣状态 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum CommissionStatusEnum { + NORMAL("A", "正常"), + CANCEL("N", "作废"); + + private String key; + + private String value; + + CommissionStatusEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/CommissionTargetEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/CommissionTargetEnum.java new file mode 100644 index 0000000..67335ec --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/CommissionTargetEnum.java @@ -0,0 +1,37 @@ +package com.fuint.common.enums; + +/** + * 分佣对象枚举 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum CommissionTargetEnum { + MEMBER("member", "会员分销"), + STAFF("staff", "员工提成"); + + private String key; + + private String value; + + CommissionTargetEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/CouponContentEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/CouponContentEnum.java new file mode 100644 index 0000000..0667a27 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/CouponContentEnum.java @@ -0,0 +1,40 @@ +package com.fuint.common.enums; + +/** + * 卡券内容枚举 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum CouponContentEnum { + ROOM("1", "房间"), + ROOM_BTEAKFAST("2", "房间+早餐"), + MEALS("3", "餐食"), + WASH("4", "洗衣"), + HEALTH("5", "康乐"); + + private String key; + + private String value; + + CouponContentEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/CouponExpireTypeEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/CouponExpireTypeEnum.java new file mode 100644 index 0000000..df2e4e6 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/CouponExpireTypeEnum.java @@ -0,0 +1,37 @@ +package com.fuint.common.enums; + +/** + * 卡券过期类型枚举 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum CouponExpireTypeEnum { + FIX("fix", "固定期限"), + FLEX("flex", "领取后生效"); + + private String key; + + private String value; + + CouponExpireTypeEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/CouponTypeEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/CouponTypeEnum.java new file mode 100644 index 0000000..f053d44 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/CouponTypeEnum.java @@ -0,0 +1,38 @@ +package com.fuint.common.enums; + +/** + * 卡券类型枚举 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum CouponTypeEnum { + COUPON("C", "优惠券"), + PRESTORE("P", "储值卡"), + TIMER("T", "计次卡"); + + private String key; + + private String value; + + CouponTypeEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/CouponUseForEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/CouponUseForEnum.java new file mode 100644 index 0000000..6fafc6c --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/CouponUseForEnum.java @@ -0,0 +1,57 @@ +package com.fuint.common.enums; + +/** + * 卡券使用专项枚举 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum CouponUseForEnum { + MEMBER_GRADE("memberGrade", "升级会员等级专用"), + OFF_LINE_PAYMENT("offLinePayment", "到店收银买单专用"); + + private String key; + + private String value; + + CouponUseForEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + // 普通方法,通过key获取value + public static String getValue(String k) { + for (CouponUseForEnum c : CouponUseForEnum.values()) { + if (c.getKey().equals(k)) { + return c.getValue(); + } + } + return null; + } + + // 普通方法,通过Value获取key + public static String getKey(String v) { + for (CouponUseForEnum c : CouponUseForEnum.values()) { + if (c.getValue() == v) { + return c.getKey(); + } + } + return null; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/GenderEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/GenderEnum.java new file mode 100644 index 0000000..c72fd7c --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/GenderEnum.java @@ -0,0 +1,39 @@ +package com.fuint.common.enums; + +/** + * 性别枚举 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum GenderEnum { + + FEMALE(0, "女"), + MAN(1, "男"), + UNKNOWN(2, "未知"); + + private Integer key; + + private String value; + + GenderEnum(Integer key, String value) { + this.key = key; + this.value = value; + } + + public Integer getKey() { + return key; + } + + public void setKey(Integer key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/GoodsTypeEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/GoodsTypeEnum.java new file mode 100644 index 0000000..d081d23 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/GoodsTypeEnum.java @@ -0,0 +1,58 @@ +package com.fuint.common.enums; + +/** + * 商品类型 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum GoodsTypeEnum { + GOODS("goods", "实物商品"), + SERVICE("service", "服务项目"), + COUPON("coupon", "虚拟卡券"); + + private String key; + + private String value; + + GoodsTypeEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + // 普通方法,通过key获取value + public static String getValue(String k) { + for (GoodsTypeEnum c : GoodsTypeEnum.values()) { + if (c.getKey().equals(k)) { + return c.getValue(); + } + } + return null; + } + + // 普通方法,通过Value获取key + public static String getKey(String v) { + for (GoodsTypeEnum c : GoodsTypeEnum.values()) { + if (c.getValue() == v) { + return c.getKey(); + } + } + return null; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/MemberSourceEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/MemberSourceEnum.java new file mode 100644 index 0000000..4780ee4 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/MemberSourceEnum.java @@ -0,0 +1,59 @@ +package com.fuint.common.enums; + +/** + * 会员来源渠道 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum MemberSourceEnum { + BACKEND_ADD("backend_add", "后台添加"), + REGISTER_BY_ACCOUNT("register_by_account", "H5注册"), + MOBILE_LOGIN("mobile_login", "手机号登录注册"), + WECHAT_LOGIN("wechat_login", "微信小程序"); + + private String key; + + private String value; + + MemberSourceEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + // 普通方法,通过key获取value + public static String getValue(String k) { + for (MemberSourceEnum c : MemberSourceEnum.values()) { + if (c.getKey().equals(k)) { + return c.getValue(); + } + } + return null; + } + + // 普通方法,通过Value获取key + public static String getKey(String v) { + for (MemberSourceEnum c : MemberSourceEnum.values()) { + if (c.getValue() == v) { + return c.getKey(); + } + } + return null; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/MerchantTypeEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/MerchantTypeEnum.java new file mode 100644 index 0000000..cbb8ef9 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/MerchantTypeEnum.java @@ -0,0 +1,39 @@ +package com.fuint.common.enums; + +/** + * 商户类型枚举 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum MerchantTypeEnum { + RESTAURANT("restaurant", "餐饮:餐厅、奶茶、酒店等"), + RETAIL("retail", "零售:超市、生鲜、卖场等"), + SERVICE("service", "服务:美容、足浴、汽车4s店等"), + OTHER("other", "其他"); + + private String key; + + private String value; + + MerchantTypeEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/MessageEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/MessageEnum.java new file mode 100644 index 0000000..55454f5 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/MessageEnum.java @@ -0,0 +1,35 @@ +package com.fuint.common.enums; + +/** + * 会员消息类型枚举 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum MessageEnum { + POP_MSG("pop", "弹框消息"), + SUB_MSG("sub", "订阅消息"), + SMS_MSG("sms", "短信消息"); + + private String key; + private String value; + + MessageEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/OrderModeEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/OrderModeEnum.java new file mode 100644 index 0000000..03a8286 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/OrderModeEnum.java @@ -0,0 +1,37 @@ +package com.fuint.common.enums; + +/** + * 订单模式 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum OrderModeEnum { + EXPRESS("express", "配送"), + ONESELF("oneself", "自取"); + + private String key; + + private String value; + + OrderModeEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/OrderSettingEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/OrderSettingEnum.java new file mode 100644 index 0000000..3223fba --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/OrderSettingEnum.java @@ -0,0 +1,57 @@ +package com.fuint.common.enums; + +/** + * 交易配置项枚举 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum OrderSettingEnum { + DELIVERY_FEE("deliveryFee", "订单配送费用"), + IS_CLOSE("isClose", "关闭交易功能"); + + private String key; + + private String value; + + OrderSettingEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + // 普通方法,通过key获取value + public static String getValue(String k) { + for (OrderSettingEnum c : OrderSettingEnum.values()) { + if (c.getKey().equals(k)) { + return c.getValue(); + } + } + return null; + } + + // 普通方法,通过Value获取key + public static String getKey(String v) { + for (OrderSettingEnum c : OrderSettingEnum.values()) { + if (c.getValue() == v) { + return c.getKey(); + } + } + return null; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/OrderStatusEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/OrderStatusEnum.java new file mode 100644 index 0000000..ad4240c --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/OrderStatusEnum.java @@ -0,0 +1,40 @@ +package com.fuint.common.enums; + +/** + * 订单状态枚举 + */ +public enum OrderStatusEnum { + CREATED("A", "待支付"), + PAID("B", "已支付"), + CANCEL("C", "已取消"), + DELIVERY("D", "待发货"), + DELIVERED("E", "已发货"), + RECEIVED("F", "已收货"), + DELETED("G", "已删除"), + REFUND("H", "已退款"); + + private String key; + + private String value; + + OrderStatusEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/OrderTypeEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/OrderTypeEnum.java new file mode 100644 index 0000000..cff5bcb --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/OrderTypeEnum.java @@ -0,0 +1,56 @@ +package com.fuint.common.enums; + +/** + * 订单类型 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum OrderTypeEnum { + GOOGS("goods", "商品订单"), + PAYMENT("payment", "付款订单"), + RECHARGE("recharge", "充值订单"), + PRESTORE("prestore", "储值卡订单"), + MEMBER("member", "会员升级订单"); + + private String key; + + private String value; + + OrderTypeEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + /** + * 根据key获取value + * + * @param key + * @return + */ + public static String getName(String key) { + final OrderTypeEnum[] values = OrderTypeEnum.values(); + for (OrderTypeEnum value : values) { + if (key.equals(value.getKey())) { + return value.getValue(); + } + } + return null; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/PayStatusEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/PayStatusEnum.java new file mode 100644 index 0000000..76a32ca --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/PayStatusEnum.java @@ -0,0 +1,37 @@ +package com.fuint.common.enums; + +/** + * 支付状态 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum PayStatusEnum { + WAIT("A", "待支付"), + SUCCESS("B", "已支付"); + + private String key; + + private String value; + + PayStatusEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/PayTypeEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/PayTypeEnum.java new file mode 100644 index 0000000..5215143 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/PayTypeEnum.java @@ -0,0 +1,40 @@ +package com.fuint.common.enums; + +/** + * 支付类型 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum PayTypeEnum { + CASH("CASH", "现金支付"), + JSAPI("JSAPI", "微信支付"), + MICROPAY("MICROPAY", "微信扫码支付"), + BALANCE("BALANCE", "余额支付"), + ALISCAN("ALISCAN", "支付宝扫码"); + + private String key; + + private String value; + + PayTypeEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/PlatformTypeEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/PlatformTypeEnum.java new file mode 100644 index 0000000..0b61e10 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/PlatformTypeEnum.java @@ -0,0 +1,55 @@ +package com.fuint.common.enums; + +/** + * 平台类型枚举 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum PlatformTypeEnum { + + /** + * PC + */ + PC("PC", "PC端"), + + /** + * H5 + */ + H5("H5", "H5端"), + + /** + * 微信小程序 + */ + MP_WEIXIN("MP_WEIXIN", "微信小程序"), + + /** + * App客户端 + */ + APP("APP", "App客户端"); + + private String code; + + private String value; + + PlatformTypeEnum(String code, String value) { + this.code = code; + this.value = value; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/PointSettingEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/PointSettingEnum.java new file mode 100644 index 0000000..293aa2a --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/PointSettingEnum.java @@ -0,0 +1,59 @@ +package com.fuint.common.enums; + +/** + * 积分配置项枚举 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum PointSettingEnum { + POINT_NEED_CONSUME("pointNeedConsume", "返1积分所需消费金额"), + CAN_USE_AS_MONEY("canUsedAsMoney", "是否可当作现金使用"), + EXCHANGE_NEED_POINT("exchangeNeedPoint", "多少积分可抵扣1元现金"), + RECHARGE_POINT_SPEED("rechargePointSpeed", "充值返积分倍数"); + + private String key; + + private String value; + + PointSettingEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + // 普通方法,通过key获取value + public static String getValue(String k) { + for (PointSettingEnum c : PointSettingEnum.values()) { + if (c.getKey().equals(k)) { + return c.getValue(); + } + } + return null; + } + + // 普通方法,通过Value获取key + public static String getKey(String v) { + for (PointSettingEnum c : PointSettingEnum.values()) { + if (c.getValue() == v) { + return c.getKey(); + } + } + return null; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/RefundStatusEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/RefundStatusEnum.java new file mode 100644 index 0000000..08d2302 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/RefundStatusEnum.java @@ -0,0 +1,37 @@ +package com.fuint.common.enums; + +/** + * 售后订单状态枚举 + */ +public enum RefundStatusEnum { + + CREATED("A", "待审核"), + APPROVED("B", "已同意"), + REJECT("C", "已驳回"), + CANCEL("D", "已取消"); + + private String key; + + private String value; + + RefundStatusEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/RefundTypeEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/RefundTypeEnum.java new file mode 100644 index 0000000..a890d1c --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/RefundTypeEnum.java @@ -0,0 +1,39 @@ +package com.fuint.common.enums; + +/** + * 售后类型枚举 + */ +public enum RefundTypeEnum { + + RETURN("return", "退货退款"), + EXCHANGE("exchange", "换货"), + + DEDUCTION("deduction", "预付金中补扣"), + REFUND_ALL("refund_all", "全额退款"), + REFUND_PART("refund_part", "部分退款"); + + private String key; + + private String value; + + RefundTypeEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/SendWayEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/SendWayEnum.java new file mode 100644 index 0000000..19545b2 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/SendWayEnum.java @@ -0,0 +1,58 @@ +package com.fuint.common.enums; + +/** + * 卡券发放方式 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum SendWayEnum { + BACKEND("backend", "后台发放"), + OFFLINE("offline", "线下发放"), + FRONT("front", "前台领取"); + + private String key; + + private String value; + + SendWayEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + // 普通方法,通过key获取value + public static String getValue(String k) { + for (SendWayEnum c : SendWayEnum.values()) { + if (c.getKey().equals(k)) { + return c.getValue(); + } + } + return null; + } + + // 普通方法,通过Value获取key + public static String getKey(String v) { + for (SendWayEnum c : SendWayEnum.values()) { + if (c.getValue() == v) { + return c.getKey(); + } + } + return null; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/SettingTypeEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/SettingTypeEnum.java new file mode 100644 index 0000000..be7aaf5 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/SettingTypeEnum.java @@ -0,0 +1,60 @@ +package com.fuint.common.enums; + +/** + * 配置类型枚举 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum SettingTypeEnum { + POINT("point", "积分配置"), + BALANCE("balance", "余额配置"), + USER("user", "会员配置"), + ORDER("order", "交易配置"), + SUB_MESSAGE("sub_message", "订阅消息"); + + private String key; + + private String value; + + SettingTypeEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + // 普通方法,通过key获取value + public static String getValue(String k) { + for (SettingTypeEnum c : SettingTypeEnum.values()) { + if (c.getKey().equals(k)) { + return c.getValue(); + } + } + return null; + } + + // 普通方法,通过Value获取key + public static String getKey(String v) { + for (SettingTypeEnum c : SettingTypeEnum.values()) { + if (c.getValue() == v) { + return c.getKey(); + } + } + return null; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/SettleStatusEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/SettleStatusEnum.java new file mode 100644 index 0000000..b31e5e3 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/SettleStatusEnum.java @@ -0,0 +1,37 @@ +package com.fuint.common.enums; + +/** + * 订单结算状态 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum SettleStatusEnum { + WAIT("A", "待确认"), + COMPLETE("B", "已完成"); + + private String key; + + private String value; + + SettleStatusEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/StaffCategoryEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/StaffCategoryEnum.java new file mode 100644 index 0000000..e170f3d --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/StaffCategoryEnum.java @@ -0,0 +1,78 @@ +package com.fuint.common.enums; + +/** + * 员工类别枚举 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum StaffCategoryEnum { + MANAGER("1", "店长","admin"), + CASHIER("2", "收银人员","cashier"), + SALE("3", "销售人员","sale"), + SERVICE("4", "服务人员","service"); + + private String key; + private String name; + private String value; + + StaffCategoryEnum(String key, String name, String value) { + this.key = key; + this.name = name; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + // 普通方法,通过key获取value + public static String getValue(String k) { + for (StaffCategoryEnum c : StaffCategoryEnum.values()) { + if (c.getKey().equals(k)) { + return c.getValue(); + } + } + return null; + } + + // 普通方法,通过key获取name + public static String getName(String k) { + for (StaffCategoryEnum c : StaffCategoryEnum.values()) { + if (c.getKey().equals(k)) { + return c.getName(); + } + } + return null; + } + + // 普通方法,通过Value获取key + public static String getKey(String v) { + for (StaffCategoryEnum c : StaffCategoryEnum.values()) { + if (c.getValue() == v) { + return c.getKey(); + } + } + return null; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/StatusEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/StatusEnum.java new file mode 100644 index 0000000..de815d5 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/StatusEnum.java @@ -0,0 +1,41 @@ +package com.fuint.common.enums; + +/** + * 通用状态枚举 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum StatusEnum { + + ENABLED("A", "启用"), + EXPIRED("C", "过期"), + DISABLE("D", "删除"), + FORBIDDEN("N", "禁用"), + UnAudited("U", "待审核"); + + private String key; + + private String value; + + StatusEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/UserActionEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/UserActionEnum.java new file mode 100644 index 0000000..3790012 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/UserActionEnum.java @@ -0,0 +1,64 @@ +package com.fuint.common.enums; + +/** + * 会员行为枚举 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum UserActionEnum { + REGISTER("register", "注册会员"), + LOGIN("login", "登录系统"), + VIEW_GOODS("viewGoods", "浏览商品"), + SUBMIT_ORDER("submitOrder", "提交订单"), + CANCEL_ORDER("cancelOrder", "取消订单"), + GET_COUPON("getCoupon", "领取卡券"), + USE_COUPON("useCoupon", "使用卡券"), + RECHARGE_BALANCE("rechargeBalance", "余额充值"), + USE_BALANCE("useBalance", "使用余额"); + + private String key; + + private String value; + + UserActionEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + // 普通方法,通过key获取value + public static String getValue(String k) { + for (UserActionEnum c : UserActionEnum.values()) { + if (c.getKey().equals(k)) { + return c.getValue(); + } + } + return null; + } + + // 普通方法,通过Value获取key + public static String getKey(String v) { + for (UserActionEnum c : UserActionEnum.values()) { + if (c.getValue() == v) { + return c.getKey(); + } + } + return null; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/UserCouponStatusEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/UserCouponStatusEnum.java new file mode 100644 index 0000000..2fdaaf1 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/UserCouponStatusEnum.java @@ -0,0 +1,60 @@ +package com.fuint.common.enums; + +/** + * 用户卡券状态 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum UserCouponStatusEnum { + UNUSED("A", "未使用"), + USED("B", "已使用"), + EXPIRE("C", "已过期"), + DISABLE("D", "不可用"), + UNSEND("E", "待领取"); + + private String key; + + private String value; + + UserCouponStatusEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + // 普通方法,通过key获取value + public static String getValue(String k) { + for (UserCouponStatusEnum c : UserCouponStatusEnum.values()) { + if (c.getKey().equals(k)) { + return c.getValue(); + } + } + return null; + } + + // 普通方法,通过Value获取key + public static String getKey(String v) { + for (UserCouponStatusEnum c : UserCouponStatusEnum.values()) { + if (c.getValue() == v) { + return c.getKey(); + } + } + return null; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/UserGradeCatchTypeEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/UserGradeCatchTypeEnum.java new file mode 100644 index 0000000..d0b9cb8 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/UserGradeCatchTypeEnum.java @@ -0,0 +1,39 @@ +package com.fuint.common.enums; + +/** + * 升级会员等级条件枚举 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum UserGradeCatchTypeEnum { + INIT("init", "默认获取"), + PAY("pay", "付费升级"), + FREQUENCY("frequency", "累计消费次数升级"), + AMOUNT("amount", "累积消费金额升级"); + + private String key; + + private String value; + + UserGradeCatchTypeEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/UserSettingEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/UserSettingEnum.java new file mode 100644 index 0000000..8a4fdee --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/UserSettingEnum.java @@ -0,0 +1,58 @@ +package com.fuint.common.enums; + +/** + * 会员配置项枚举 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum UserSettingEnum { + GET_COUPON_NEED_PHONE("getCouponNeedPhone", "领券是否需要手机号码"), + SUBMIT_ORDER_NEED_PHONE("submitOrderNeedPhone", "提交订单是否需要手机号码"), + LOGIN_NEED_PHONE("loginNeedPhone", "登录是否需要手机号"); + + private String key; + + private String value; + + UserSettingEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + // 普通方法,通过key获取value + public static String getValue(String k) { + for (UserSettingEnum c : UserSettingEnum.values()) { + if (c.getKey().equals(k)) { + return c.getValue(); + } + } + return null; + } + + // 普通方法,通过Value获取key + public static String getKey(String v) { + for (UserSettingEnum c : UserSettingEnum.values()) { + if (c.getValue() == v) { + return c.getKey(); + } + } + return null; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/WxMessageEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/WxMessageEnum.java new file mode 100644 index 0000000..498b5ad --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/WxMessageEnum.java @@ -0,0 +1,62 @@ +package com.fuint.common.enums; + +/** + * 微信订阅消息枚举 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum WxMessageEnum { + ORDER_CREATED("orderCreated", "订单生成提醒"), + DELIVER_GOODS("deliverGoods", "订单发货提醒"), + COUPON_EXPIRE("couponExpire", "卡券到期提醒"), + COUPON_ARRIVAL("couponArrival", "卡券到账提醒"), + BALANCE_CHANGE("balanceChange", "余额变动提醒"), + COUPON_CONFIRM("couponConfirm", "卡券核销提醒"), + POINT_CHANGE("pointChange", "积分变更提醒"); + + private String key; + + private String value; + + WxMessageEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + // 普通方法,通过key获取value + public static String getValue(String k) { + for (WxMessageEnum c : WxMessageEnum.values()) { + if (c.getKey().equals(k)) { + return c.getValue(); + } + } + return null; + } + + // 普通方法,通过Value获取key + public static String getKey(String v) { + for (WxMessageEnum c : WxMessageEnum.values()) { + if (c.getValue() == v) { + return c.getKey(); + } + } + return null; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/enums/YesOrNoEnum.java b/fuint-application/src/main/java/com/fuint/common/enums/YesOrNoEnum.java new file mode 100644 index 0000000..66eee6f --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/enums/YesOrNoEnum.java @@ -0,0 +1,37 @@ +package com.fuint.common.enums; + +/** + * 是或否枚举 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public enum YesOrNoEnum { + YES("Y", "是"), + NO("N", "否"); + + private String key; + + private String value; + + YesOrNoEnum(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/http/HttpRESTDataClient.java b/fuint-application/src/main/java/com/fuint/common/http/HttpRESTDataClient.java new file mode 100644 index 0000000..4aa325a --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/http/HttpRESTDataClient.java @@ -0,0 +1,61 @@ +package com.fuint.common.http; + +import org.apache.http.HttpResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; + +import okhttp3.*; + +/** + * 调用REST接口并解析数据 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Component +public class HttpRESTDataClient { + + public static final Logger logger = LoggerFactory.getLogger(HttpRESTDataClient.class); + + private static final OkHttpClient client = new OkHttpClient(); + + public static String requestGet(String url) throws IOException { + Request request = new Request.Builder() + .url(url) + .build(); + Response response = client.newCall(request).execute(); + if (!response.isSuccessful()) throw new IOException("Unexpected code " + response); + + return response.body().string(); + } + + public static byte[] requestPost(String url, String postData) throws IOException { + String postBody = postData; + MediaType MEDIA_TYPE_MARKDOWN = MediaType.parse("application/json"); + Request request = new Request.Builder() + .url(url) + .post(RequestBody.create(MEDIA_TYPE_MARKDOWN, postBody)) + .build(); + Response response = client.newCall(request).execute(); + if (!response.isSuccessful()) throw new IOException("Unexpected code " + response); + + return response.body().bytes(); + } + + public static String requestPost(String url, String contentType, String postData) throws IOException { + String postBody = postData; + MediaType mediaType = MediaType.parse(contentType); + Request request = new Request.Builder() + .url(url) + .post(RequestBody.create(mediaType, postBody)) + .build(); + Response response = client.newCall(request).execute(); + if (!response.isSuccessful()) throw new IOException("Unexpected code " + response); + + return response.body().string(); + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/param/AddressDetailParam.java b/fuint-application/src/main/java/com/fuint/common/param/AddressDetailParam.java new file mode 100644 index 0000000..7b5b1ca --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/param/AddressDetailParam.java @@ -0,0 +1,18 @@ +package com.fuint.common.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; + +/** + * 收获地址详情请求参数 + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Data +public class AddressDetailParam implements Serializable { + + @ApiModelProperty(value="收获地址ID", name="addressId") + private String addressId; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/param/ArticleDetailParam.java b/fuint-application/src/main/java/com/fuint/common/param/ArticleDetailParam.java new file mode 100644 index 0000000..736883d --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/param/ArticleDetailParam.java @@ -0,0 +1,18 @@ +package com.fuint.common.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; + +/** + * 文章详情请求参数 + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Data +public class ArticleDetailParam implements Serializable { + + @ApiModelProperty(value="文章ID", name="articleId") + private String articleId; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/param/ArticleListParam.java b/fuint-application/src/main/java/com/fuint/common/param/ArticleListParam.java new file mode 100644 index 0000000..5b586f5 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/param/ArticleListParam.java @@ -0,0 +1,21 @@ +package com.fuint.common.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; + +/** + * 文章列表请求参数 + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Data +public class ArticleListParam extends PageParam implements Serializable { + + @ApiModelProperty(value="文章标题", name="title") + private String title; + + @ApiModelProperty(value="商户号", name="merchantNo") + private String merchantNo; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/param/BalanceListParam.java b/fuint-application/src/main/java/com/fuint/common/param/BalanceListParam.java new file mode 100644 index 0000000..3c9c575 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/param/BalanceListParam.java @@ -0,0 +1,18 @@ +package com.fuint.common.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; + +/** + * 余额明细列表请求参数 + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Data +public class BalanceListParam extends PageParam implements Serializable { + + @ApiModelProperty(value="会员ID", name="userId") + private String userId; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/param/CartClearParam.java b/fuint-application/src/main/java/com/fuint/common/param/CartClearParam.java new file mode 100644 index 0000000..675f551 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/param/CartClearParam.java @@ -0,0 +1,25 @@ +package com.fuint.common.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; +import java.util.List; + +/** + * 删除购物车请求参数 + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Data +public class CartClearParam extends PageParam implements Serializable { + + @ApiModelProperty(value="购物车ID", name="cartId") + private List cartId; + + @ApiModelProperty(value="挂单编码", name="hangNo") + private String hangNo; + + @ApiModelProperty(value="下单会员ID", name="userId") + private Integer userId; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/param/CartListParam.java b/fuint-application/src/main/java/com/fuint/common/param/CartListParam.java new file mode 100644 index 0000000..f313ed6 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/param/CartListParam.java @@ -0,0 +1,42 @@ +package com.fuint.common.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; + +/** + * 购物车列表请求参数 + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Data +public class CartListParam extends PageParam implements Serializable { + + @ApiModelProperty(value="购物车ID", name="cartId") + private Integer cartId; + + @ApiModelProperty(value="指定购物车ID,逗号分割", name="cartIds") + private String cartIds; + + @ApiModelProperty(value="商品ID", name="goodsId") + private Integer goodsId; + + @ApiModelProperty(value="卡券ID", name="couponId") + private Integer couponId; + + @ApiModelProperty(value="商品SkuID", name="skuId") + private Integer skuId; + + @ApiModelProperty(value="使用积分", name="point") + private String point; + + @ApiModelProperty(value="购买数量", name="buyNum") + private Integer buyNum; + + @ApiModelProperty(value="挂单编码", name="hangNo") + private String hangNo; + + @ApiModelProperty(value="下单会员ID", name="userId") + private Integer userId; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/param/CartSaveParam.java b/fuint-application/src/main/java/com/fuint/common/param/CartSaveParam.java new file mode 100644 index 0000000..630ee9a --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/param/CartSaveParam.java @@ -0,0 +1,46 @@ +package com.fuint.common.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 保存购物车请求参数 + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Data +public class CartSaveParam implements Serializable { + + @ApiModelProperty(value="购物车ID", name="cartId") + private Integer cartId; + + @ApiModelProperty(value="商品ID", name="goodsId") + private Integer goodsId; + + @ApiModelProperty(value="商品SkuID", name="skuId") + private Integer skuId; + + @ApiModelProperty(value="商品编码", name="skuNo") + private String skuNo; + + @ApiModelProperty(value="购买数量", name="buyNum") + private Integer buyNum; + + @ApiModelProperty(value="操作类型,+:增加,-:减少", name="action") + private String action; + + @ApiModelProperty(value="自定义商品价格", name="selfPrice") + private BigDecimal selfPrice; + + @ApiModelProperty(value="预付金", name="prePayment") + private BigDecimal prePayment; + + @ApiModelProperty(value="挂单编码", name="hangNo") + private String hangNo; + + @ApiModelProperty(value="下单会员ID", name="userId") + private Integer userId; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/param/CommissionRuleItemParam.java b/fuint-application/src/main/java/com/fuint/common/param/CommissionRuleItemParam.java new file mode 100644 index 0000000..82993d5 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/param/CommissionRuleItemParam.java @@ -0,0 +1,31 @@ +package com.fuint.common.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 分销提成规则项目请求参数 + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Data +public class CommissionRuleItemParam implements Serializable { + + @ApiModelProperty("商品ID") + private Integer goodsId; + + @ApiModelProperty("商品名称") + private String goodsName; + + @ApiModelProperty("提成方式") + private String method; + + @ApiModelProperty("散客值") + private BigDecimal visitorVal; + + @ApiModelProperty("会员值") + private BigDecimal memberVal; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/param/CommissionRuleParam.java b/fuint-application/src/main/java/com/fuint/common/param/CommissionRuleParam.java new file mode 100644 index 0000000..f065937 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/param/CommissionRuleParam.java @@ -0,0 +1,49 @@ +package com.fuint.common.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; +import java.util.List; + +/** + * 分销提成规则请求参数 + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Data +public class CommissionRuleParam implements Serializable { + + @ApiModelProperty("自增ID") + private Integer id; + + @ApiModelProperty("规则名称") + private String name; + + @ApiModelProperty("分佣类型,member:会员分销;staff:员工提成") + private String type; + + @ApiModelProperty("分佣对象") + private String target; + + @ApiModelProperty("商户ID") + private Integer merchantId; + + @ApiModelProperty("店铺ID") + private Integer storeId; + + @ApiModelProperty("适用店铺ID列表") + private List storeIdList; + + @ApiModelProperty("具体项目列表") + private List detailList; + + @ApiModelProperty("备注") + private String description; + + @ApiModelProperty("最后操作人") + private String operator; + + @ApiModelProperty("状态") + private String status; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/param/ConfirmParam.java b/fuint-application/src/main/java/com/fuint/common/param/ConfirmParam.java new file mode 100644 index 0000000..7cfa40c --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/param/ConfirmParam.java @@ -0,0 +1,24 @@ +package com.fuint.common.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; + +/** + * 卡券核销请求参数 + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Data +public class ConfirmParam implements Serializable { + + @ApiModelProperty(value="核销码", name="code") + private String code; + + @ApiModelProperty(value="核销金额", name="amount") + private String amount; + + @ApiModelProperty(value="核销备注", name="remark") + private String remark; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/param/CouponInfoParam.java b/fuint-application/src/main/java/com/fuint/common/param/CouponInfoParam.java new file mode 100644 index 0000000..2833cb2 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/param/CouponInfoParam.java @@ -0,0 +1,21 @@ +package com.fuint.common.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; + +/** + * 卡券详情请求参数 + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Data +public class CouponInfoParam implements Serializable { + + @ApiModelProperty(value="卡券ID", name="couponId") + private Integer couponId; + + @ApiModelProperty(value="会员卡券编码", name="userCouponCode") + private String userCouponCode; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/param/CouponListParam.java b/fuint-application/src/main/java/com/fuint/common/param/CouponListParam.java new file mode 100644 index 0000000..4097e59 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/param/CouponListParam.java @@ -0,0 +1,36 @@ +package com.fuint.common.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; + +/** + * 卡券列表请求参数 + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Data +public class CouponListParam extends PageParam implements Serializable { + + @ApiModelProperty(value="卡券类型", name="type") + private String type; + + @ApiModelProperty(value="商户ID", name="merchantId") + private Integer merchantId; + + @ApiModelProperty(value="领取所需积分", name="needPoint") + private Integer needPoint; + + @ApiModelProperty(value="发放方式", name="sendWay") + private String sendWay; + + @ApiModelProperty(value="排序类型", name="sortType") + private String sortType; + + @ApiModelProperty(value="下单会员ID", name="userId") + private Integer userId; + + @ApiModelProperty(value="状态", name="status") + private String status; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/param/CouponReceiveParam.java b/fuint-application/src/main/java/com/fuint/common/param/CouponReceiveParam.java new file mode 100644 index 0000000..442a34d --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/param/CouponReceiveParam.java @@ -0,0 +1,27 @@ +package com.fuint.common.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; + +/** + * 卡券领取请求参数 + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Data +public class CouponReceiveParam implements Serializable { + + @ApiModelProperty(value="卡券ID", name="couponId") + private Integer couponId; + + @ApiModelProperty(value="领取数量", name="num") + private Integer num; + + @ApiModelProperty(value="会员ID", name="userId") + private Integer userId; + + @ApiModelProperty(value="领取码", name="receiveCode") + private String receiveCode; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/param/GiveListParam.java b/fuint-application/src/main/java/com/fuint/common/param/GiveListParam.java new file mode 100644 index 0000000..4249b28 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/param/GiveListParam.java @@ -0,0 +1,21 @@ +package com.fuint.common.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; + +/** + * 转增记录列表请求参数 + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Data +public class GiveListParam extends PageParam implements Serializable { + + @ApiModelProperty(value="转增对象手机号", name="mobile") + private String mobile; + + @ApiModelProperty(value="类型,give = 转增,gived = 被转增", name="type") + private String type; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/param/GiveParam.java b/fuint-application/src/main/java/com/fuint/common/param/GiveParam.java new file mode 100644 index 0000000..e622a48 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/param/GiveParam.java @@ -0,0 +1,36 @@ +package com.fuint.common.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; + +/** + * 卡券转赠请求参数 + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Data +public class GiveParam implements Serializable { + + @ApiModelProperty(value="转增对象手机号", name="mobile") + private String mobile; + + @ApiModelProperty(value="卡券ID,可逗号隔开", name="couponId") + private String couponId; + + @ApiModelProperty(value="转赠备注", name="note") + private String note; + + @ApiModelProperty(value="转赠留言", name="message") + private String message; + + @ApiModelProperty(value="转赠人ID", name="userId") + private Integer userId; + + @ApiModelProperty(value="商户ID", name="merchantId") + private Integer merchantId; + + @ApiModelProperty(value="店铺ID", name="storeId") + private Integer storeId; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/param/GoodsInfoParam.java b/fuint-application/src/main/java/com/fuint/common/param/GoodsInfoParam.java new file mode 100644 index 0000000..b725ec8 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/param/GoodsInfoParam.java @@ -0,0 +1,21 @@ +package com.fuint.common.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; + +/** + * 商品详情请求参数 + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Data +public class GoodsInfoParam implements Serializable { + + @ApiModelProperty(value="商品ID", name="goodsId") + private String goodsId; + + @ApiModelProperty(value="skuNo", name="skuNo") + private String skuNo; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/param/MemberInfoParam.java b/fuint-application/src/main/java/com/fuint/common/param/MemberInfoParam.java new file mode 100644 index 0000000..97ac58d --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/param/MemberInfoParam.java @@ -0,0 +1,24 @@ +package com.fuint.common.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; + +/** + * 会员查询请求参数 + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Data +public class MemberInfoParam extends PageParam implements Serializable { + + @ApiModelProperty(value="ID", name="id") + private String id; + + @ApiModelProperty(value="手机号", name="mobile") + private String mobile; + + @ApiModelProperty(value="会员号", name="userNo") + private String userNo; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/param/MemberListParam.java b/fuint-application/src/main/java/com/fuint/common/param/MemberListParam.java new file mode 100644 index 0000000..6d3ad4a --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/param/MemberListParam.java @@ -0,0 +1,48 @@ +package com.fuint.common.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; + +/** + * 会员列表请求参数 + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Data +public class MemberListParam extends PageParam implements Serializable { + + @ApiModelProperty(value="ID", name="id") + private String id; + + @ApiModelProperty(value="手机号", name="mobile") + private String mobile; + + @ApiModelProperty(value="会员名称", name="name") + private String name; + + @ApiModelProperty(value="会员生日", name="birthday") + private String birthday; + + @ApiModelProperty(value="会员号", name="userNo") + private String userNo; + + @ApiModelProperty(value="会员等级", name="gradeId") + private String gradeId; + + @ApiModelProperty(value="注册时间", name="regTime") + private String regTime; + + @ApiModelProperty(value="活跃时间", name="activeTime") + private String activeTime; + + @ApiModelProperty(value="会员有效期", name="memberTime") + private String memberTime; + + @ApiModelProperty(value="数据类型,1)todayRegister:今日注册;2)todayActive:今日活跃", name="dataType") + private String dataType; + + @ApiModelProperty(value="会员状态", name="status") + private String status; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/param/OrderDetailParam.java b/fuint-application/src/main/java/com/fuint/common/param/OrderDetailParam.java new file mode 100644 index 0000000..46a948f --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/param/OrderDetailParam.java @@ -0,0 +1,18 @@ +package com.fuint.common.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; + +/** + * 订单详情请求参数 + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Data +public class OrderDetailParam implements Serializable { + + @ApiModelProperty(value="订单ID", name="orderId") + private String orderId; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/param/OrderListParam.java b/fuint-application/src/main/java/com/fuint/common/param/OrderListParam.java new file mode 100644 index 0000000..9a7baea --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/param/OrderListParam.java @@ -0,0 +1,74 @@ +package com.fuint.common.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; + +/** + * 订单列表请求参数 + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Data +public class OrderListParam extends PageParam implements Serializable { + + @ApiModelProperty(value="ID", name="id") + private String id; + + @ApiModelProperty(value="会员ID", name="userId") + private String userId; + + @ApiModelProperty(value="会员卡号", name="userNo") + private String userNo; + + @ApiModelProperty(value="商户ID", name="merchantId") + private Integer merchantId; + + @ApiModelProperty(value="店铺ID", name="storeId") + private Integer storeId; + + @ApiModelProperty(value="店铺ID,逗号分隔", name="storeIds") + private String storeIds; + + @ApiModelProperty(value="订单状态", name="status") + private String status; + + @ApiModelProperty(value="支付状态", name="payStatus") + private String payStatus; + + @ApiModelProperty(value="结算状态", name="settleStatus") + private String settleStatus; + + @ApiModelProperty(value="数据类型,1)toPay:待支付;2)paid:已支付;3)cancel:已取消", name="dataType") + private String dataType; + + @ApiModelProperty(value="订单类型", name="type") + private String type; + + @ApiModelProperty(value="订单号", name="orderSn") + private String orderSn; + + @ApiModelProperty(value="会员手机号", name="mobile") + private String mobile; + + @ApiModelProperty(value="订单模式,1)oneself:自取,2)express:配送", name="orderMode") + private String orderMode; + + @ApiModelProperty(value="员工ID(销售人员)", name="staffId") + private String staffId; + + @ApiModelProperty(value="卡券ID", name="couponId") + private String couponId; + + @ApiModelProperty(value="时间类型", name="timeType") + private String timeType; + + @ApiModelProperty(value="开始时间", name="startTime") + private String startTime; + + @ApiModelProperty(value="结束时间", name="endTime") + private String endTime; + + @ApiModelProperty(value="收银地点ID", name="storeLocationId") + private Integer storeLocationId; +} diff --git a/fuint-application/src/main/java/com/fuint/common/param/PageParam.java b/fuint-application/src/main/java/com/fuint/common/param/PageParam.java new file mode 100644 index 0000000..47886dc --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/param/PageParam.java @@ -0,0 +1,69 @@ +package com.fuint.common.param; + +import io.swagger.annotations.ApiModelProperty; +import java.io.Serializable; + +/** + * 分页请求参数 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public class PageParam implements Serializable { + private static final long serialVersionUID = -1833130751169582924L; + + @ApiModelProperty("当前页数") + private Integer page = 1; + + @ApiModelProperty("分页大小") + private int pageSize = 20; + + /** + * 排序字段 + */ + @ApiModelProperty(value="排序字段",name="orderBy") + private String orderBy; + + /** + * 排序方式 + */ + @ApiModelProperty(value="排序方式",name="order") + private String order; + + public PageParam() { + // empty + } + + public Integer getPage() { + return this.page; + } + + public Integer getPageSize() { + return this.pageSize; + } + + public void setPage(int page) { + this.page = page; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } +} + diff --git a/fuint-application/src/main/java/com/fuint/common/param/RechargeParam.java b/fuint-application/src/main/java/com/fuint/common/param/RechargeParam.java new file mode 100644 index 0000000..552525a --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/param/RechargeParam.java @@ -0,0 +1,21 @@ +package com.fuint.common.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; + +/** + * 充值请求参数 + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Data +public class RechargeParam implements Serializable { + + @ApiModelProperty(value="充值金额", name="rechargeAmount") + private String rechargeAmount; + + @ApiModelProperty(value="自定义充值金额", name="customAmount") + private String customAmount; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/param/SettlementParam.java b/fuint-application/src/main/java/com/fuint/common/param/SettlementParam.java new file mode 100644 index 0000000..b9bebdb --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/param/SettlementParam.java @@ -0,0 +1,77 @@ +package com.fuint.common.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 订单结算请求参数 + */ +@Data +public class SettlementParam implements Serializable { + + @ApiModelProperty(value="购物车Id,逗号分隔", name="cartIds") + private String cartIds; + + @ApiModelProperty(value="购买对象,购买储值卡、升级会员等级必填", name="targetId") + private String targetId; + + @ApiModelProperty(value="购买储值卡数量", name="selectNum") + private String selectNum; + + @ApiModelProperty(value="结算备注", name="remark") + private String remark; + + @ApiModelProperty(value="订单类型,payment:付款订单、goods:商品订单、recharge:充值订单、prestore:储值卡订单、member:会员升级订单", name="type") + private String type; + + @ApiModelProperty(value="支付金额,付款类订单必填", name="payAmount") + private String payAmount; + + @ApiModelProperty(value="使用积分数量", name="usePoint") + private Integer usePoint; + + @ApiModelProperty(value="使用卡券ID", name="couponId") + private Integer couponId; + + @ApiModelProperty(value="支付类型,CASH:现金支付,JSAPI:微信支付,MICROPAY:微信扫码支付,BALANCE:余额支付,ALISCAN:支付宝扫码", name="payType") + private String payType; + + @ApiModelProperty(value="PC端扫码支付的二维码", name="authCode") + private String authCode; + + @ApiModelProperty(value="会员ID(代客下单用到)", name="userId") + private Integer userId; + + @ApiModelProperty(value="会员手机号", name="mobile") + private String mobile; + + @ApiModelProperty(value="实付金额(收银台用到)", name="cashierPayAmount") + private String cashierPayAmount; + + @ApiModelProperty(value="优惠金额(收银台用到)", name="cashierDiscountAmount") + private String cashierDiscountAmount; + + @ApiModelProperty(value="商品ID", name="goodsId") + private Integer goodsId; + + @ApiModelProperty(value="商品skuID", name="skuId") + private Integer skuId; + + @ApiModelProperty(value="购买数量", name="buyNum") + private Integer buyNum; + + @ApiModelProperty(value="订单模式,配送(express)或自提(oneself)", name="orderMode") + private String orderMode; + + @ApiModelProperty(value="订单ID", name="orderId") + private Integer orderId; + + @ApiModelProperty(value="收银地点ID", name="storeLocationId") + private Integer storeLocationId; + + @ApiModelProperty(value="订单预付金", name="prePayment") + private BigDecimal prePayment; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/permission/PermissionService.java b/fuint-application/src/main/java/com/fuint/common/permission/PermissionService.java new file mode 100644 index 0000000..15541fe --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/permission/PermissionService.java @@ -0,0 +1,73 @@ +package com.fuint.common.permission; + +import com.fuint.common.dto.AccountInfo; +import com.fuint.common.service.SourceService; +import com.fuint.common.util.AuthUserUtil; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.repository.model.TSource; +import com.fuint.utils.StringUtil; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * 权限控制业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service("pms") +public class PermissionService { + + /** + * 所有权限标识 + */ + private static final String ALL_PERMISSION = "*:*:*"; + + /** + * 后台菜单接口 + * */ + @Resource + SourceService sourceService; + + /** + * 验证用户是否具备某权限 + * + * @param permission 权限字符串 + * @return 用户是否具备某权限 + */ + public boolean hasPermission(String permission) throws BusinessCheckException { + if (StringUtil.isEmpty(permission)) { + return false; + } + + AccountInfo accountInfo = AuthUserUtil.get(); + if (accountInfo == null) { + return false; + } + + Set allPermission = new HashSet<>(); + List sources = sourceService.getMenuListByUserId(accountInfo.getMerchantId(), accountInfo.getId()); + if (sources != null && sources.size() > 0) { + for (TSource tSource : sources) { + allPermission.add(tSource.getPath().replaceAll("/", ":")); + } + } + + return hasPermissions(allPermission, permission); + } + + /** + * 判断是否包含权限 + * + * @param permissions 权限列表 + * @param permission 权限字符串 + * @return boolean + */ + private boolean hasPermissions(Set permissions, String permission) { + return permissions.contains(ALL_PERMISSION) || permissions.contains(StringUtil.trim(permission)); + } +} \ No newline at end of file diff --git a/fuint-application/src/main/java/com/fuint/common/service/AccountService.java b/fuint-application/src/main/java/com/fuint/common/service/AccountService.java new file mode 100644 index 0000000..96d723f --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/AccountService.java @@ -0,0 +1,111 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.common.dto.AccountDto; +import com.fuint.common.dto.AccountInfo; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.model.TAccount; +import com.fuint.repository.model.TDuty; +import java.util.List; + +/** + * 后台账号接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface AccountService extends IService { + + /** + * 分页查询账号列表 + * + * @param paginationRequest + * @return + */ + PaginationResponse getAccountListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException; + + /** + * 根据账号名称获取账号信息 + * + * @param userName 账号名称 + * @return + * */ + AccountInfo getAccountByName(String userName); + + /** + * 获取用户信息 + * + * @param id 账号ID + * @return + */ + TAccount getAccountInfoById(Integer id); + + /** + * 创建账号信息 + * + * @param accountInfo 账号信息 + * @param duties 角色 + * @return + * */ + TAccount createAccountInfo(TAccount accountInfo, List duties) throws BusinessCheckException; + + /** + * 获取账号角色ID + * + * @param accountId 账号ID + * @return + * */ + List getRoleIdsByAccountId(Integer accountId); + + /** + * 修改账户 + * + * @param tAccount 账户实体 + * @throws BusinessCheckException + * @return + */ + void editAccount(TAccount tAccount, List duties) throws BusinessCheckException; + + /** + * 根据账户名称获取账户所分配的角色ID集合 + * + * @param accountId 账户 + * @return 角色ID集合 + */ + List getDutyIdsByAccountId(long accountId); + + /** + * 更新账户信息 + * + * @param tAccount + * @return + */ + void updateAccount(TAccount tAccount); + + /** + * 删除后台账号 + * + * @param accountId 账号ID + * @return + * */ + void deleteAccount(Long accountId); + + /** + * 密码加密 + * + * @param tAccount 账号信息 + * @return + * */ + void entryptPassword(TAccount tAccount); + + /** + * 获取加密密码 + * + * @param password + * @param salt + * @return + * */ + String getEntryptPassword(String password, String salt); +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/ActionLogService.java b/fuint-application/src/main/java/com/fuint/common/service/ActionLogService.java new file mode 100644 index 0000000..fac3260 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/ActionLogService.java @@ -0,0 +1,31 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.model.TActionLog; + +/** + * 后台日志服务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface ActionLogService extends IService { + + /** + * 保存日志 + * + * @param actionLog + * @return + */ + void saveActionLog(TActionLog actionLog); + + /** + * 获取分页查询数据 + * + * @param paginationRequest + * @return + */ + PaginationResponse findLogsByPagination(PaginationRequest paginationRequest); +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/AddressService.java b/fuint-application/src/main/java/com/fuint/common/service/AddressService.java new file mode 100644 index 0000000..224e111 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/AddressService.java @@ -0,0 +1,42 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.repository.model.MtAddress; +import com.fuint.framework.exception.BusinessCheckException; +import java.util.List; +import java.util.Map; + +/** + * 收货地址业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface AddressService extends IService { + + /** + * 保存收货地址 + * + * @param mtAddress + * @throws BusinessCheckException + * @return + */ + MtAddress saveAddress(MtAddress mtAddress) throws BusinessCheckException; + + /** + * 根据ID获取Banner信息 + * + * @param id 地址ID + * @throws BusinessCheckException + * @return + */ + MtAddress detail(Integer id) throws BusinessCheckException; + + /** + * 根据条件查询地址列表 + * + * @param params 查询参数 + * @return + * */ + List queryListByParams(Map params) throws BusinessCheckException; +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/AlipayService.java b/fuint-application/src/main/java/com/fuint/common/service/AlipayService.java new file mode 100644 index 0000000..72cca79 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/AlipayService.java @@ -0,0 +1,62 @@ +package com.fuint.common.service; + +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.web.ResponseObject; +import com.fuint.repository.model.MtOrder; +import com.fuint.repository.model.MtUser; +import java.math.BigDecimal; +import java.util.Map; + +/** + * 支付宝相关业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface AlipayService { + + /** + * 创建预支付订单 + * + * @param userInfo 会员信息 + * @param orderInfo 订单信息 + * @param payAmount 支付金额 + * @param authCode 付款码 + * @param giveAmount 赠送金额 + * @param ip 支付IP地址 + * @param platform 支付平台 + * @return + * */ + ResponseObject createPrepayOrder(MtUser userInfo, MtOrder orderInfo, Integer payAmount, String authCode, Integer giveAmount, String ip, String platform) throws BusinessCheckException; + + /** + * 支付回调 + * + * @param params 请求参数 + * @return + * */ + Boolean checkCallBack(Map params) throws Exception; + + /** + * 查询支付订单 + * + * @param storeId 店铺ID + * @param tradeNo 交易单号 + * @param orderSn 订单号 + * @return + * */ + Map queryPaidOrder(Integer storeId, String tradeNo, String orderSn) throws BusinessCheckException; + + /** + * 发起售后退款 + * + * @param storeId 店铺ID + * @param orderSn 订单号 + * @param totalAmount 订单总金额 + * @param refundAmount 售后金额 + * @param platform 订单平台 + * @return + * */ + Boolean doRefund(Integer storeId, String orderSn, BigDecimal totalAmount, BigDecimal refundAmount, String platform) throws BusinessCheckException; + +} \ No newline at end of file diff --git a/fuint-application/src/main/java/com/fuint/common/service/ArticleService.java b/fuint-application/src/main/java/com/fuint/common/service/ArticleService.java new file mode 100644 index 0000000..d0f8292 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/ArticleService.java @@ -0,0 +1,67 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.common.dto.ArticleDto; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.model.MtArticle; +import com.fuint.framework.exception.BusinessCheckException; +import java.util.List; +import java.util.Map; + +/** + * 文章业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface ArticleService extends IService { + + /** + * 分页查询文章列表 + * + * @param paginationRequest + * @return + */ + PaginationResponse queryArticleListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException; + + /** + * 添加文章 + * + * @param articleDto + * @throws BusinessCheckException + */ + MtArticle addArticle(ArticleDto articleDto) throws BusinessCheckException; + + /** + * 根据ID获取文章信息 + * + * @param id 文章ID + * @throws BusinessCheckException + */ + MtArticle queryArticleById(Integer id) throws BusinessCheckException; + + /** + * 根据ID获取文章详情 + * + * @param id 文章ID + * @throws BusinessCheckException + */ + ArticleDto getArticleDetail(Integer id) throws BusinessCheckException; + + /** + * 更新文章 + * @param articleDto + * @throws BusinessCheckException + * */ + MtArticle updateArticle(ArticleDto articleDto) throws BusinessCheckException; + + /** + * 根据条件搜索文章 + * + * @param params + * @return + * */ + List queryArticleListByParams(Map params) throws BusinessCheckException; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/BalanceService.java b/fuint-application/src/main/java/com/fuint/common/service/BalanceService.java new file mode 100644 index 0000000..0a5efdb --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/BalanceService.java @@ -0,0 +1,56 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.common.dto.AccountInfo; +import com.fuint.common.dto.BalanceDto; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.model.MtBalance; +import java.util.List; + +/** + * 余额业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface BalanceService extends IService { + + /** + * 分页查询余额列表 + * + * @param paginationRequest + * @return + */ + PaginationResponse queryBalanceListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException; + + /** + * 添加余额记录 + * + * @param reqDto + * @param updateBalance + * @throws BusinessCheckException + */ + Boolean addBalance(MtBalance reqDto, Boolean updateBalance) throws BusinessCheckException; + + /** + * 发放余额 + * + * @param accountInfo + * @param object + * @param userIds + * @param amount + * @param remark + * @return + */ + void distribute(AccountInfo accountInfo, String object, String userIds, String amount, String remark) throws BusinessCheckException; + + /** + * 获取订单余额记录 + * + * @param orderSn + * @return + * */ + List getBalanceListByOrderSn(String orderSn) throws BusinessCheckException; +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/BannerService.java b/fuint-application/src/main/java/com/fuint/common/service/BannerService.java new file mode 100644 index 0000000..30d9607 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/BannerService.java @@ -0,0 +1,72 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.model.MtBanner; +import com.fuint.common.dto.BannerDto; +import com.fuint.framework.exception.BusinessCheckException; +import java.util.List; +import java.util.Map; + +/** + * 焦点图业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface BannerService extends IService { + + /** + * 分页查询列表 + * + * @param paginationRequest + * @return + */ + PaginationResponse queryBannerListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException; + + /** + * 添加Banner + * + * @param reqBannerDto + * @throws BusinessCheckException + * @return + */ + MtBanner addBanner(BannerDto reqBannerDto) throws BusinessCheckException; + + /** + * 根据ID获取Banner信息 + * + * @param id Banner ID + * @throws BusinessCheckException + * @return + */ + MtBanner queryBannerById(Integer id) throws BusinessCheckException; + + /** + * 根据ID删除焦点图 + * + * @param id ID + * @param operator 操作人 + * @throws BusinessCheckException + * @return + */ + void deleteBanner(Integer id, String operator) throws BusinessCheckException; + + /** + * 更新焦点图 + * @param bannerDto + * @throws BusinessCheckException + * @return + * */ + MtBanner updateBanner(BannerDto bannerDto) throws BusinessCheckException; + + /** + * 根据条件搜索焦点图 + * + * @param params 查询参数 + * @throws BusinessCheckException + * @return + * */ + List queryBannerListByParams(Map params) throws BusinessCheckException; +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/CaptchaService.java b/fuint-application/src/main/java/com/fuint/common/service/CaptchaService.java new file mode 100644 index 0000000..b78d771 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/CaptchaService.java @@ -0,0 +1,43 @@ +package com.fuint.common.service; + +import javax.servlet.http.HttpSession; +import java.awt.image.BufferedImage; + +/** + * 图形验证码插件服务类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface CaptchaService { + + /** + * 生成图形验证码,并保存至Session + * @param session Session + * @return BufferedImage + */ + BufferedImage getCode(HttpSession session); + + /** + * 图形验证码校验 + * @param code 输入的验证码 + * @param session Session + * @return Boolean + */ + Boolean checkCode(String code, HttpSession session); + + /** + * 生成图形验证码 + * @return BufferedImage + */ + BufferedImage getCodeByUuid(String uuid); + + /** + * 图形验证码校验 + * @param code 输入的验证码 + * @param uuid uuid + * @return Boolean + */ + Boolean checkCodeByUuid(String code, String uuid); + +} \ No newline at end of file diff --git a/fuint-application/src/main/java/com/fuint/common/service/CartService.java b/fuint-application/src/main/java/com/fuint/common/service/CartService.java new file mode 100644 index 0000000..b62d97c --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/CartService.java @@ -0,0 +1,91 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.repository.model.MtCart; + +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; + +/** + * 购物车业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface CartService extends IService { + + /** + * 切换购物车给会员 + * + * @param userId + * @param cartIds + * @return + * */ + Boolean switchCartIds(Integer userId, String cartIds) throws BusinessCheckException; + + /** + * 保存购物车 + * + * @param reqDto + * @param action + or - or = + * @throws BusinessCheckException + * @return + */ + Integer saveCart(MtCart reqDto, String action) throws BusinessCheckException; + + /** + * 删除购物车 + * + * @param cartIds 购物车ID + * @throws BusinessCheckException + * @return + */ + void removeCart(String cartIds) throws BusinessCheckException; + + /** + * 删除购物车 + * + * @param hangNo 挂单序号 + * @throws BusinessCheckException + * @return + */ + void removeCartByHangNo(String hangNo) throws BusinessCheckException; + + /** + * 清空会员购物车 + * + * @param userId 会员ID + * @throws BusinessCheckException + * @return + */ + void clearCart(Integer userId) throws BusinessCheckException; + + /** + * 根据条件查找 + * + * @param params 查询参数 + * @return + * */ + List queryCartListByParams(Map params) throws BusinessCheckException; + + /** + * 根据条件查找2 + * + * @param params 查询参数 + * @return + * */ + List queryCartListByParams2(Map params) throws BusinessCheckException; + /** + * 挂单 + * + * @param cartId 购物车ID + * @param hangNo 挂单序号 + * @param isVisitor 是否游客 + * @param prePayment 预付金 + * @param operator 挂单操作人 + * @return + */ + MtCart setHangNo(Integer cartId, String hangNo, String isVisitor, BigDecimal prePayment, String operator) throws BusinessCheckException; +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/CateService.java b/fuint-application/src/main/java/com/fuint/common/service/CateService.java new file mode 100644 index 0000000..550601b --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/CateService.java @@ -0,0 +1,70 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.common.dto.GoodsCateDto; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.model.MtGoodsCate; +import java.util.List; +import java.util.Map; + +/** + * 商品分类业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface CateService extends IService { + + /** + * 分页查询列表 + * + * @param paginationRequest + * @return + */ + PaginationResponse queryCateListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException; + + /** + * 添加商品分类 + * + * @param reqDto 分类参数 + * @throws BusinessCheckException + * @return + */ + MtGoodsCate addCate(MtGoodsCate reqDto) throws BusinessCheckException; + + /** + * 根据ID获取商品分类信息 + * + * @param id ID + * @throws BusinessCheckException + */ + MtGoodsCate queryCateById(Integer id) throws BusinessCheckException; + + /** + * 根据ID删除 + * + * @param id 分类ID + * @param operator 操作人 + * @throws BusinessCheckException + * @return + */ + void deleteCate(Integer id, String operator) throws BusinessCheckException; + + /** + * 更新分类 + * @param reqDto 分类参数 + * @throws BusinessCheckException + * @return + * */ + MtGoodsCate updateCate(MtGoodsCate reqDto) throws BusinessCheckException; + + /** + * 根据条件搜索分类 + * + * @param params 查询参数 + * @return + * */ + List queryCateListByParams(Map params) throws BusinessCheckException; +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/CommissionLogService.java b/fuint-application/src/main/java/com/fuint/common/service/CommissionLogService.java new file mode 100644 index 0000000..30fe9c9 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/CommissionLogService.java @@ -0,0 +1,53 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.common.dto.CommissionLogDto; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.module.backendApi.request.CommissionLogRequest; +import com.fuint.repository.model.MtCommissionLog; + +/** + * 分销提成记录业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface CommissionLogService extends IService { + + /** + * 分页查询列表 + * + * @param paginationRequest + * @return + */ + PaginationResponse queryCommissionLogByPagination(PaginationRequest paginationRequest) throws BusinessCheckException; + + /** + * 计算订单分销提成 + * + * @param orderId 订单ID + * @throws BusinessCheckException + * @return + */ + void calculateCommission(Integer orderId) throws BusinessCheckException; + + /** + * 根据ID获取记录信息 + * + * @param id 记录ID + * @throws BusinessCheckException + * @return + */ + CommissionLogDto queryCommissionLogById(Integer id) throws BusinessCheckException; + + /** + * 更新分销提成记录 + * + * @param commissionLogRequest 请求参数 + * @throws BusinessCheckException + * @return + */ + void updateCommissionLog(CommissionLogRequest commissionLogRequest) throws BusinessCheckException; +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/CommissionRuleService.java b/fuint-application/src/main/java/com/fuint/common/service/CommissionRuleService.java new file mode 100644 index 0000000..1501518 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/CommissionRuleService.java @@ -0,0 +1,53 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.common.dto.CommissionRuleDto; +import com.fuint.common.param.CommissionRuleParam; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.repository.model.MtCommissionRule; + +import java.util.List; +import java.util.Map; + +/** + * 分销提成规则业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface CommissionRuleService extends IService { + + /** + * 分页查询列表 + * + * @param paginationRequest + * @return + */ + PaginationResponse queryDataByPagination(PaginationRequest paginationRequest) throws BusinessCheckException; + + /** + * 添加分销提成规则 + * + * @param commissionRule + * @throws BusinessCheckException + */ + MtCommissionRule addCommissionRule(CommissionRuleParam commissionRule) throws BusinessCheckException; + + /** + * 根据ID获取规则信息 + * + * @param id + * @throws BusinessCheckException + */ + CommissionRuleDto queryCommissionRuleById(Integer id) throws BusinessCheckException; + + /** + * 更新数据 + * @param commissionRule + * @throws BusinessCheckException + * */ + MtCommissionRule updateCommissionRule(CommissionRuleParam commissionRule) throws BusinessCheckException; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/ConfirmLogService.java b/fuint-application/src/main/java/com/fuint/common/service/ConfirmLogService.java new file mode 100644 index 0000000..91863c9 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/ConfirmLogService.java @@ -0,0 +1,47 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.common.dto.ConfirmLogDto; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.model.MtConfirmLog; + +import java.util.Date; +import java.util.List; + +/** + * 核销记录业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface ConfirmLogService extends IService { + + /** + * 分页查询会员卡券核销列表 + * + * @param paginationRequest + * @return + */ + PaginationResponse queryConfirmLogListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException; + + /** + * 获取卡券核销次数 + * @param userCouponId + * @return + * */ + Long getConfirmNum(Integer userCouponId) throws BusinessCheckException; + + /** + * 获取卡券核销列表 + * @param userCouponId + * @return + * */ + List getConfirmList(Integer userCouponId) throws BusinessCheckException; + + /** + * 获取核销总数 + * */ + Long getConfirmCount(Integer merchantId, Integer storeId, Date beginTime, Date endTime) throws BusinessCheckException; +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/CouponGroupService.java b/fuint-application/src/main/java/com/fuint/common/service/CouponGroupService.java new file mode 100644 index 0000000..becf8d1 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/CouponGroupService.java @@ -0,0 +1,110 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.common.dto.GroupDataDto; +import com.fuint.common.dto.ReqCouponGroupDto; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.model.MtCouponGroup; +import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; +import org.springframework.ui.Model; +import java.math.BigDecimal; + +/** + * 卡券分组业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface CouponGroupService extends IService { + + /** + * 分页查询分组列表 + * + * @param paginationRequest + * @return + */ + PaginationResponse queryCouponGroupListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException; + + /** + * 添加卡券分组 + * + * @param reqCouponGroupDto + * @throws BusinessCheckException + */ + MtCouponGroup addCouponGroup(ReqCouponGroupDto reqCouponGroupDto) throws BusinessCheckException; + + /** + * 修改卡券分组 + * + * @param reqCouponGroupDto + * @throws BusinessCheckException + */ + MtCouponGroup updateCouponGroup(ReqCouponGroupDto reqCouponGroupDto) throws BusinessCheckException; + + /** + * 根据组ID获取分组信息 + * + * @param id 分组ID + * @throws BusinessCheckException + */ + MtCouponGroup queryCouponGroupById(Integer id) throws BusinessCheckException; + + /** + * 根据分组ID 删除分组信息 + * + * @param id 分组ID + * @param operator 操作人 + * @throws BusinessCheckException + */ + void deleteCouponGroup(Integer id, String operator) throws BusinessCheckException; + + /** + * 根据分组ID 获取券种类数量 + * + * @param id 分组ID + * @throws BusinessCheckException + */ + Integer getCouponNum(Integer id) throws BusinessCheckException; + + /** + * 根据分组ID 获取券总价值 + * + * @param id 分组ID + * @throws BusinessCheckException + */ + BigDecimal getCouponMoney(Integer id) throws BusinessCheckException; + + /** + * 获取已发放套数 + * + * @param id 分组ID + * @throws BusinessCheckException + * */ + Integer getSendNum(Integer id) throws BusinessCheckException; + + /** + * 导入发券列表 + * + * @param file excel文件 + * @param operator 操作者 + * */ + String importSendCoupon(MultipartFile file, String operator, String filePath) throws BusinessCheckException; + + /** + * 保存文件 + * + * @param file excel文件 + * @param request 操作者 + * */ + String saveExcelFile(MultipartFile file, HttpServletRequest request) throws Exception; + + /** + * 获取分组统计数据 + * + * @param groupId 分组ID + * */ + GroupDataDto getGroupData(Integer groupId, HttpServletRequest request, Model model) throws BusinessCheckException; +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/CouponService.java b/fuint-application/src/main/java/com/fuint/common/service/CouponService.java new file mode 100644 index 0000000..fdd13cf --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/CouponService.java @@ -0,0 +1,169 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.common.dto.ReqCouponDto; +import com.fuint.common.param.CouponListParam; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.framework.web.ResponseObject; +import com.fuint.repository.model.MtCoupon; +import com.fuint.repository.model.MtUserCoupon; +import java.math.BigDecimal; +import java.text.ParseException; +import java.util.List; + +/** + * 卡券业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface CouponService extends IService { + + /** + * 分页查询卡券列表 + * + * @param paginationRequest + * @return + */ + PaginationResponse queryCouponListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException; + + /** + * 保存卡券 + * + * @param reqCouponDto + * @throws BusinessCheckException + * @return + */ + MtCoupon saveCoupon(ReqCouponDto reqCouponDto) throws BusinessCheckException, ParseException; + + /** + * 根据ID获取卡券信息 + * + * @param id 卡券ID + * @throws BusinessCheckException + * @return + */ + MtCoupon queryCouponById(Integer id) throws BusinessCheckException; + + /** + * 删除卡券信息 + * + * @param id 卡券ID + * @param operator 操作人 + * @throws BusinessCheckException + * @return + */ + void deleteCoupon(Long id, String operator) throws BusinessCheckException; + + /** + * 获取卡券列表 + * @param couponListParam 查询参数 + * @throws BusinessCheckException + * */ + ResponseObject findCouponList(CouponListParam couponListParam) throws BusinessCheckException; + + /** + * 发放卡券 + * + * @param couponId 券ID + * @param userId 会员ID + * @param num 发放套数 + * @param sendMessage 是否发送消息 + * @param uuid 批次号 + * @param operator 操作人 + * @throws BusinessCheckException + * @return + */ + void sendCoupon(Integer couponId, Integer userId, Integer num, Boolean sendMessage, String uuid, String operator) throws BusinessCheckException; + + /** + * 发放卡券 + * + * @param couponId 券ID + * @param userIds 会员ID + * @param num 发放套数 + * @param uuid 批次号 + * @param operator 操作人 + * @throws BusinessCheckException + * @return + */ + Boolean batchSendCoupon(Integer couponId, List userIds, Integer num, String uuid, String operator) throws BusinessCheckException; + + /** + * 根据分组获取卡券列表 + * @param groupId 查询参数 + * @throws BusinessCheckException + * @return + * */ + List queryCouponListByGroupId(Integer groupId) throws BusinessCheckException; + + /** + * 核销卡券 + * @param userCouponId 用户券ID + * @param userId 核销会员ID + * @param storeId 店铺ID + * @param orderId 订单ID + * @param amount 核销金额 + * @param remark 核销备注 + * @throws BusinessCheckException + * @return + * */ + String useCoupon(Integer userCouponId, Integer userId, Integer storeId, Integer orderId, BigDecimal amount, String remark) throws BusinessCheckException; + + /** + * 根据券ID删除个人卡券 + * + * @param id 券ID + * @param operator 操作人 + * @throws BusinessCheckException + * @return + */ + void deleteUserCoupon(Integer id, String operator) throws BusinessCheckException; + + /** + * 根据券ID 撤销个人卡券消费流水 + * + * @param id 消费流水ID + * @param userCouponId 用户卡券ID + * @param operator 操作人 + * @throws BusinessCheckException + * @return + */ + void rollbackUserCoupon(Integer id, Integer userCouponId,String operator) throws BusinessCheckException; + + /** + * 根据ID获取用户卡券信息 + * @param userCouponId 查询参数 + * @throws BusinessCheckException + * @return + * */ + MtUserCoupon queryUserCouponById(Integer userCouponId) throws BusinessCheckException; + + /** + * 根据批次撤销卡券 + * @param id ID + * @param uuid 批次ID + * @param operator 操作人 + * @throws BusinessCheckException + * @return + */ + void removeUserCoupon(Long id, String uuid, String operator) throws BusinessCheckException; + + /** + * 判断卡券码是否过期 + * @param code 券码 + * @return + * */ + boolean codeExpired(String code); + + /** + * 判断卡券是否有效 + * + * @param coupon + * @param userCoupon + * @return + * */ + boolean isCouponEffective(MtCoupon coupon, MtUserCoupon userCoupon); +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/DutyService.java b/fuint-application/src/main/java/com/fuint/common/service/DutyService.java new file mode 100644 index 0000000..08837a8 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/DutyService.java @@ -0,0 +1,121 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.module.backendApi.request.DutyStatusRequest; +import com.fuint.repository.model.TDuty; +import com.fuint.repository.model.TSource; +import com.fuint.common.domain.TreeNode; +import java.util.List; + +/** + * 角色服务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface DutyService extends IService { + + /** + * 角色保存方法 + * + * @param duty 角色信息 + * @return + */ + void saveDuty(TDuty duty, List sources) throws BusinessCheckException; + + /** + * 获取有效的角色集合 + * + * @param merchantId 商户ID + * @param accountId 账号ID + * @return + */ + List getAvailableRoles(Integer merchantId, Integer accountId); + + /** + * 根据ID获取角色实体 + * + * @param roleId 角色ID + * @return + */ + TDuty getRoleById(Long roleId); + + /** + * 角色信息分页查询 + * + * @param paginationRequest 分页查询请求对象 + * @return 分页查询结果对象 + */ + PaginationResponse findDutiesByPagination(PaginationRequest paginationRequest); + + /** + * 根据ID数组获取角色集合 + * + * @param ids 角色ID + * @return + */ + List findDatasByIds(String[] ids); + + /** + * 删除方法 + * + * @param merchantId 商户ID + * @param dutyId 角色ID + * @return + */ + void deleteDuty(Integer merchantId, long dutyId) throws BusinessCheckException; + + /** + * 更新状态 + * + * @param merchantId + * @param dutyStatusRequest + * @return + */ + void updateStatus(Integer merchantId, DutyStatusRequest dutyStatusRequest) throws BusinessCheckException; + + /** + * 修改角色 + * + * @param tduty 角色信息 + * @param sources 菜单列表 + * @return + */ + void updateDuty(TDuty tduty, List sources) throws BusinessCheckException; + + /** + * 根据角色名称合状态查询角色 + * + * @param merchantId 商户ID + * @param name 角色名称 + * @return + */ + TDuty findByName(Integer merchantId, String name); + + /** + * 根据角色名称获取已经分配的菜单ID集合 + * + * @param dutyId 角色ID + * @return + */ + List getSourceIdsByDutyId(Integer dutyId); + + /** + * 获取角色的树形结构 + * + * @param merchantId 商户ID + * @return + */ + List getDutyTree(Integer merchantId); + + /** + * 根据账户获取角色 + * + * @param accountId 账号ID + * @return + */ + List findDutiesByAccountId(Integer accountId); +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/GiveService.java b/fuint-application/src/main/java/com/fuint/common/service/GiveService.java new file mode 100644 index 0000000..05bf3dc --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/GiveService.java @@ -0,0 +1,58 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.common.dto.GiveDto; +import com.fuint.common.param.GiveParam; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.framework.web.ResponseObject; +import com.fuint.repository.model.MtGive; +import com.fuint.repository.model.MtGiveItem; + +import java.util.List; +import java.util.Map; + +/** + * 转赠业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface GiveService extends IService { + + /** + * 分页查询列表 + * + * @param paginationRequest + * @return + */ + PaginationResponse queryGiveListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException; + + /** + * 转赠卡券 + * + * @param giveParam + * @throws BusinessCheckException + * @return + */ + ResponseObject addGive(GiveParam giveParam) throws BusinessCheckException; + + /** + * 根据组ID获取信息 + * + * @param id ID + * @throws BusinessCheckException + * @return + */ + MtGive queryGiveById(Long id) throws BusinessCheckException; + + /** + * 根据条件搜索转赠详情 + * + * @param params + * @throws BusinessCheckException + * @return + * */ + List queryItemByParams(Map params); +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/GoodsService.java b/fuint-application/src/main/java/com/fuint/common/service/GoodsService.java new file mode 100644 index 0000000..0723813 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/GoodsService.java @@ -0,0 +1,143 @@ +package com.fuint.common.service; + +import com.fuint.common.dto.GoodsDto; +import com.fuint.common.dto.GoodsSpecValueDto; +import com.fuint.common.dto.GoodsTopDto; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.model.MtGoods; +import com.fuint.repository.model.MtGoodsSku; +import com.fuint.repository.model.MtGoodsSpec; +import java.lang.reflect.InvocationTargetException; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 商品业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface GoodsService { + + /** + * 分页查询商品列表 + * + * @param paginationRequest + * @return + */ + PaginationResponse queryGoodsListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException; + + /** + * 保存商品 + * + * @param reqDto + * @throws BusinessCheckException + * @return + */ + MtGoods saveGoods(MtGoods reqDto) throws BusinessCheckException; + + /** + * 根据ID获取商品信息 + * + * @param id 商品ID + * @throws BusinessCheckException + * @return + */ + MtGoods queryGoodsById(Integer id) throws BusinessCheckException; + + /** + * 根据编码获取商品信息 + * + * @param merchantId + * @param goodsNo + * @throws BusinessCheckException + * @return + */ + MtGoods queryGoodsByGoodsNo(Integer merchantId, String goodsNo) throws BusinessCheckException; + + /** + * 根据条码获取sku信息 + * + * @param skuNo skuNo + * @throws BusinessCheckException + * @return + * */ + MtGoodsSku getSkuInfoBySkuNo(String skuNo) throws BusinessCheckException; + + /** + * 根据ID获取商品详情 + * + * @param id + * @throws BusinessCheckException + * @return + */ + GoodsDto getGoodsDetail(Integer id, boolean getDeleteSpec) throws InvocationTargetException, IllegalAccessException; + + /** + * 根据ID删除 + * + * @param id ID + * @param operator 操作人 + * @throws BusinessCheckException + * @return + */ + void deleteGoods(Integer id, String operator) throws BusinessCheckException; + + /** + * 获取店铺的商品列表 + * + * @param storeId + * @param keyword + * @param cateId + * @param page + * @param pageSize + * @return + * */ + Map getStoreGoodsList(Integer storeId, String keyword, Integer cateId, Integer page, Integer pageSize) throws BusinessCheckException; + + /** + * 根据skuId获取规格列表 + * + * @param skuId + * @return + * */ + List getSpecListBySkuId(Integer skuId) throws BusinessCheckException; + + /** + * 获取规格详情 + * + * @param specId + * @return + * */ + MtGoodsSpec getSpecDetail(Integer specId); + + /** + * 更新已售数量 + * + * @param goodsId 商品ID + * @return + * */ + Boolean updateInitSale(Integer goodsId); + + /** + * 获取选择商品列表 + * + * @param params 查询参数 + * @return + */ + PaginationResponse selectGoodsList(Map params) throws BusinessCheckException; + + /** + * 获取商品销售排行榜 + * + * @param merchantId 商户ID + * @param storeId 店铺ID + * @param startTime 开始时间 + * @param endTime 结束时间 + * @return + * */ + List getGoodsSaleTopList(Integer merchantId, Integer storeId, Date startTime, Date endTime); +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/MemberGroupService.java b/fuint-application/src/main/java/com/fuint/common/service/MemberGroupService.java new file mode 100644 index 0000000..6872adf --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/MemberGroupService.java @@ -0,0 +1,59 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.common.dto.MemberGroupDto; +import com.fuint.common.dto.UserGroupDto; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.model.MtUserGroup; + +/** + * 会员分组业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface MemberGroupService extends IService { + + /** + * 分页查询分组列表 + * + * @param paginationRequest + * @return + */ + PaginationResponse queryMemberGroupListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException; + + /** + * 新增会员分组 + * + * @param memberGroupDto + * @throws BusinessCheckException + */ + MtUserGroup addMemberGroup(MemberGroupDto memberGroupDto) throws BusinessCheckException; + + /** + * 修改卡券分组 + * + * @param memberGroupDto + * @throws BusinessCheckException + */ + MtUserGroup updateMemberGroup(MemberGroupDto memberGroupDto) throws BusinessCheckException; + + /** + * 根据组ID获取分组信息 + * + * @param id 分组ID + * @throws BusinessCheckException + */ + MtUserGroup queryMemberGroupById(Integer id) throws BusinessCheckException; + + /** + * 根据分组ID删除分组信息 + * + * @param id 分组ID + * @param operator 操作人 + * @throws BusinessCheckException + */ + void deleteMemberGroup(Integer id, String operator) throws BusinessCheckException; +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/MemberService.java b/fuint-application/src/main/java/com/fuint/common/service/MemberService.java new file mode 100644 index 0000000..3ff4dfd --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/MemberService.java @@ -0,0 +1,267 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.alibaba.fastjson.JSONObject; +import com.fuint.common.dto.GroupMemberDto; +import com.fuint.common.dto.MemberTopDto; +import com.fuint.common.dto.UserDto; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.model.MtUser; +import com.fuint.repository.model.MtUserGrade; +import javax.servlet.http.HttpServletRequest; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 会员服务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface MemberService extends IService { + + /** + * 更新活跃时间 + * + * @param userId 会员ID + * @return + * */ + Boolean updateActiveTime(Integer userId) throws BusinessCheckException; + + /** + * 获取当前操作会员信息 + * + * @param userId + * @param accessToken + * @return + * */ + MtUser getCurrentUserInfo(HttpServletRequest request, Integer userId, String accessToken) throws BusinessCheckException; + + /** + * 分页查询会员列表 + * + * @param paginationRequest + * @return + */ + PaginationResponse queryMemberListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException; + + /** + * 添加会员 + * + * @param reqUserDto + * @throws BusinessCheckException + * @return + */ + MtUser addMember(MtUser reqUserDto) throws BusinessCheckException; + + /** + * 编辑会员 + * + * @param reqUserDto 会员信息 + * @param modifyPassword 修改密码 + * @throws BusinessCheckException + * @return + */ + MtUser updateMember(MtUser reqUserDto, boolean modifyPassword) throws BusinessCheckException; + + /** + * 通过手机号添加会员 + * + * @param merchantId + * @param mobile + * @throws BusinessCheckException + * @return + */ + MtUser addMemberByMobile(Integer merchantId, String mobile) throws BusinessCheckException; + + /** + * 根据会员ID获取会员信息 + * + * @param id 会员ID + * @throws BusinessCheckException + * @return + */ + MtUser queryMemberById(Integer id) throws BusinessCheckException; + + /** + * 根据会员ID获取会员信息 + * + * @param id 会员ID + * @throws BusinessCheckException + * @return + */ + MtUser queryMemberById2(Integer id) throws BusinessCheckException; + + /** + * 根据会员名称获取会员信息 + * + * @param merchantId + * @param name 会员名称 + * @throws BusinessCheckException + * @return + */ + MtUser queryMemberByName(Integer merchantId, String name) throws BusinessCheckException; + + /** + * 根据会员ID获取会员信息 + * + * @param merchantId + * @param openId 微信openId + * @throws BusinessCheckException + * @return + */ + MtUser queryMemberByOpenId(Integer merchantId, String openId, JSONObject userInfo) throws BusinessCheckException; + + /** + * 根据会员组ID获取会员组信息 + * + * @param id 会员组ID + * @throws BusinessCheckException + * @return + */ + MtUserGrade queryMemberGradeByGradeId(Integer id) throws BusinessCheckException; + + /** + * 根据会员手机获取会员信息 + * + * @param merchantId + * @param mobile 会员手机 + * @throws BusinessCheckException + * @return + */ + MtUser queryMemberByMobile(Integer merchantId, String mobile) throws BusinessCheckException; + + /** + * 根据会员号获取会员信息 + * + * @param merchantId + * @param userNo 会员号 + * @throws BusinessCheckException + * @return + */ + MtUser queryMemberByUserNo(Integer merchantId, String userNo) throws BusinessCheckException; + + /** + * 根据会员ID 删除店铺信息 + * + * @param id 会员ID + * @param operator 操作人 + * @throws BusinessCheckException + * @return + */ + Integer deleteMember(Integer id, String operator) throws BusinessCheckException; + + /** + * 根据条件搜索会员分组 + * + * @param params 查询参数 + * @throws BusinessCheckException + * @return + * */ + List queryMemberGradeByParams(Map params) throws BusinessCheckException; + + /** + * 获取会员数量 + * + * @param merchantId 商户ID + * @param storeId 店铺ID + * @throws BusinessCheckException + * @return + * */ + Long getUserCount(Integer merchantId, Integer storeId) throws BusinessCheckException; + + /** + * 获取会员数量 + * + * @param merchantId 商户ID + * @param storeId 店铺ID + * @param beginTime 开始时间 + * @param endTime 结束时间 + * @throws BusinessCheckException + * @return + * */ + Long getUserCount(Integer merchantId, Integer storeId, Date beginTime, Date endTime) throws BusinessCheckException; + + /** + * 获取活跃会员数量 + * @param merchantId 商户ID + * @param storeId 店铺ID + * @param beginTime 开始时间 + * @param endTime 结束时间 + * @throws BusinessCheckException + * @return + * */ + Long getActiveUserCount(Integer merchantId, Integer storeId, Date beginTime, Date endTime) throws BusinessCheckException; + + /** + * 重置手机号 + * + * @param mobile 手机号码 + * @param userId 会员ID + * @throws BusinessCheckException + * @return + */ + void resetMobile(String mobile, Integer userId) throws BusinessCheckException; + + /** + * 获取会员消费排行榜 + * + * @param merchantId 商户ID + * @param storeId 店铺ID + * @param startTime 开始时间 + * @param endTime 结束时间 + * @return + * */ + List getMemberConsumeTopList(Integer merchantId, Integer storeId, Date startTime, Date endTime); + + /** + * 查找会员列表 + * + * @param merchantId 商户ID + * @param keyword 关键字 + * @param groupIds 分组ID + * @param page 当前页码 + * @param pageSize 每页数量 + * @return + * */ + List searchMembers(Integer merchantId, String keyword, String groupIds, Integer page, Integer pageSize); + + /** + * 查找会员列表 + * + * @param merchantId 商户ID + * @param keyword 关键字 + * @return + * */ + List searchMembers(Integer merchantId, String keyword); + + /** + * 设定安全的密码 + * + * @param password 密码(明文) + * @param salt 随机因子 + * @return + */ + String enCodePassword(String password, String salt); + + /** + * 获取加密密码 + * + * @param password 密码(密文) + * @param salt 随机因子 + * @return + * */ + String deCodePassword(String password, String salt); + + /** + * 获取会员ID列表 + * + * @param merchantId 商户ID + * @param storeId 店铺ID + * @return + * */ + List getUserIdList(Integer merchantId, Integer storeId); +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/MerchantService.java b/fuint-application/src/main/java/com/fuint/common/service/MerchantService.java new file mode 100644 index 0000000..ace3c58 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/MerchantService.java @@ -0,0 +1,89 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.model.MtMerchant; +import java.util.List; +import java.util.Map; + +/** + * 商户业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface MerchantService extends IService { + + /** + * 分页查询商户列表 + * + * @param paginationRequest + * @return + */ + PaginationResponse queryMerchantListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException; + + /** + * 保存商户信息 + * + * @param mtMerchant + * @throws BusinessCheckException + * @return + */ + MtMerchant saveMerchant(MtMerchant mtMerchant) throws BusinessCheckException; + + /** + * 根据ID获取商户信息 + * + * @param id 商户ID + * @throws BusinessCheckException + * @return + */ + MtMerchant queryMerchantById(Integer id) throws BusinessCheckException; + + /** + * 根据名称获取商户信息 + * + * @param name 商户名称 + * @throws BusinessCheckException + * @return + */ + MtMerchant queryMerchantByName(String name) throws BusinessCheckException; + + /** + * 根据商户号获取商户信息 + * + * @param merchantNo 商户号 + * @return + */ + MtMerchant queryMerchantByNo(String merchantNo); + + /** + * 根据商户号获取商户ID + * + * @param merchantNo 商户号 + * @return + */ + Integer getMerchantId(String merchantNo); + + /** + * 更新商户状态 + * + * @param id 商户ID + * @param operator 操作人 + * @param status 状态 + * @throws BusinessCheckException + * @return + */ + void updateStatus(Integer id, String operator, String status) throws BusinessCheckException; + + /** + * 根据条件查询商户 + * + * @param params 查询参数 + * @return + * */ + List queryMerchantByParams(Map params) throws BusinessCheckException; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/MessageService.java b/fuint-application/src/main/java/com/fuint/common/service/MessageService.java new file mode 100644 index 0000000..fb7ac5c --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/MessageService.java @@ -0,0 +1,58 @@ +package com.fuint.common.service; + +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.repository.model.MtMessage; +import java.util.List; + +/** + * 消息业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface MessageService { + + /** + * 添加消息 + * + * @param reqMsgDto + * @throws BusinessCheckException + * @return + */ + void addMessage(MtMessage reqMsgDto) throws BusinessCheckException; + + /** + * 置为已读 + * + * @param msgId + * @throws BusinessCheckException + * @return + */ + void readMessage(Integer msgId) throws BusinessCheckException; + + /** + * 置为发送 + * + * @param msgId + * @throws BusinessCheckException + * @return + */ + void sendMessage(Integer msgId, boolean isRead) throws BusinessCheckException; + + /** + * 获取最新一条未读消息 + * + * @param userId 会员ID + * @throws BusinessCheckException + * @return + */ + MtMessage getOne(Integer userId) throws BusinessCheckException; + + /** + * 获取需要发送的消息 + * + * @throws BusinessCheckException + * @return + * */ + List getNeedSendList() throws BusinessCheckException; +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/OpenGiftService.java b/fuint-application/src/main/java/com/fuint/common/service/OpenGiftService.java new file mode 100644 index 0000000..1d9da81 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/OpenGiftService.java @@ -0,0 +1,73 @@ +package com.fuint.common.service; + +import com.fuint.common.dto.OpenGiftDto; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.web.ResponseObject; +import com.fuint.repository.model.MtOpenGift; +import java.util.Map; + +/** + * 开卡赠礼接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface OpenGiftService { + + /** + * 获取用户的开卡赠礼 + * + * @param paramMap 查询参数 + * @throws BusinessCheckException + * @return + * */ + ResponseObject getOpenGiftList(Map paramMap) throws BusinessCheckException; + + /** + * 新增开卡赠礼 + * + * @param reqDto + * @throws BusinessCheckException + * @return + */ + MtOpenGift addOpenGift(MtOpenGift reqDto) throws BusinessCheckException; + + /** + * 根据ID获取开卡赠礼 + * + * @param id ID + * @throws BusinessCheckException + * @return + */ + OpenGiftDto getOpenGiftDetail(Integer id) throws BusinessCheckException; + + /** + * 根据ID删除开卡赠礼 + * + * @param id ID + * @param operator 操作人 + * @throws BusinessCheckException + * @return + */ + void deleteOpenGift(Integer id, String operator) throws BusinessCheckException; + + /** + * 更新开卡赠礼 + * + * @param reqDto + * @throws BusinessCheckException + * @return + * */ + MtOpenGift updateOpenGift(MtOpenGift reqDto) throws BusinessCheckException; + + /** + * 开卡赠礼 + * + * @param userId 会员ID + * @param gradeId 会员等级 + * @param isNewMember 是否新会员 + * @throws BusinessCheckException + * @return + * */ + boolean openGift(Integer userId, Integer gradeId, boolean isNewMember) throws BusinessCheckException; +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/OrderService.java b/fuint-application/src/main/java/com/fuint/common/service/OrderService.java new file mode 100644 index 0000000..00ee7e6 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/OrderService.java @@ -0,0 +1,243 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.common.dto.UserOrderDto; +import com.fuint.common.dto.OrderDto; +import com.fuint.common.param.OrderListParam; +import com.fuint.common.param.SettlementParam; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.model.MtCart; +import com.fuint.repository.model.MtOrder; + +import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 订单业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface OrderService extends IService { + + /** + * 获取用户的订单 + * + * @param orderListParam + * @throws BusinessCheckException + * @return + * */ + PaginationResponse getUserOrderList(OrderListParam orderListParam) throws BusinessCheckException; + + /** + * 创建订单 + * + * @param reqDto + * @throws BusinessCheckException + * @return + */ + MtOrder saveOrder(OrderDto reqDto) throws BusinessCheckException; + + /** + * 订单提交结算 + * + * @param request 请求参数 + * @param settlementParam 结算参数 + * @throws BusinessCheckException + * @return + * */ + Map doSettle(HttpServletRequest request, SettlementParam settlementParam) throws BusinessCheckException; + + /** + * 获取订单详情 + * + * @param id + * @throws BusinessCheckException + * @return + */ + MtOrder getOrderInfo(Integer id) throws BusinessCheckException; + + /** + * 根据ID获取订单 + * + * @param id + * @throws BusinessCheckException + * @return + */ + UserOrderDto getOrderById(Integer id) throws BusinessCheckException; + + /** + * 根据ID获取订单 + * + * @param id + * @throws BusinessCheckException + * @return + */ + UserOrderDto getMyOrderById(Integer id) throws BusinessCheckException; + + /** + * 取消订单 + * + * @param orderId 订单ID + * @param remark 取消备注 + * @throws BusinessCheckException + * @return + * */ + MtOrder cancelOrder(Integer orderId, String remark) throws BusinessCheckException; + + /** + * 根据订单ID删除 + * + * @param orderId 订单ID + * @param operator 操作人 + * @throws BusinessCheckException + * @return + */ + void deleteOrder(Integer orderId, String operator) throws BusinessCheckException; + + /** + * 根据订单号获取订单 + * + * @param orderSn + * @throws BusinessCheckException + * @return + */ + UserOrderDto getOrderByOrderSn(String orderSn) throws BusinessCheckException; + + /** + * 更新订单 + * + * @param reqDto + * @throws BusinessCheckException + * @return + * */ + MtOrder updateOrder(OrderDto reqDto) throws BusinessCheckException; + + /** + * 更新订单 + * + * @param mtOrder + * @throws BusinessCheckException + * @return + * */ + MtOrder updateOrder(MtOrder mtOrder) throws BusinessCheckException; + + /** + * 把订单置为已支付 + * + * @param orderId + * @param payAmount + * @throws BusinessCheckException + * @return + * */ + Boolean setOrderPayed(Integer orderId, BigDecimal payAmount) throws BusinessCheckException; + + /** + * 根据条件搜索订单 + * + * @param params 查询参数 + * @throws BusinessCheckException + * @return + * */ + List getOrderListByParams(Map params) throws BusinessCheckException; + + /** + * 获取订单总数 + * + * @param merchantId 商户ID + * @param storeId 店铺ID + * @throws BusinessCheckException + * @return + * */ + BigDecimal getOrderCount(Integer merchantId, Integer storeId) throws BusinessCheckException; + + /** + * 获取订单数量 + * + * @param merchantId 商户ID + * @param storeId 店铺ID + * @param beginTime 开始时间 + * @param endTime 结束时间 + * @throws BusinessCheckException + * @return + * */ + BigDecimal getOrderCount(Integer merchantId, Integer storeId, Date beginTime, Date endTime) throws BusinessCheckException; + + /** + * 计算购物车 + * + * @param merchantId 商户ID + * @param userId 会员ID + * @param cartList 购物车列表 + * @param couponId 使用的卡券ID + * @param isUsePoint 是否使用积分抵扣 + * @param platform 平台 h5 + * @param orderMode 订单模式,自取或配送 + * @throws BusinessCheckException + * @return + * */ + Map calculateCartGoods(Integer merchantId, Integer userId, List cartList, Integer couponId, boolean isUsePoint, String platform, String orderMode) throws BusinessCheckException; + + /** + * 获取支付金额 + * + * @param merchantId 商户ID + * @param storeId 店铺ID + * @param beginTime 开始时间 + * @param endTime 结束时间 + * @throws BusinessCheckException + * @return + * */ + BigDecimal getPayMoney(Integer merchantId, Integer storeId, Date beginTime, Date endTime) throws BusinessCheckException; + + /** + * 获取支付人数 + * + * @param merchantId 商户ID + * @param storeId 店铺ID + * @throws BusinessCheckException + * @return + * */ + Integer getPayUserCount(Integer merchantId, Integer storeId) throws BusinessCheckException; + + /** + * 获取支付金额 + * + * @param merchantId 商户ID + * @param storeId 店铺ID + * @throws BusinessCheckException + * @return + * */ + BigDecimal getPayMoney(Integer merchantId, Integer storeId) throws BusinessCheckException; + + /** + * 获取会员支付金额 + * + * @param userId 会员ID + * @throws BusinessCheckException + * @return + * */ + BigDecimal getUserPayMoney(Integer userId) throws BusinessCheckException; + + /** + * 获取会员订单数 + * + * @param userId 会员ID + * @throws BusinessCheckException + * @return + * */ + Integer getUserPayOrderCount(Integer userId) throws BusinessCheckException; + + /** + * 获取待分佣订单列表 + * + * @param dateTime 时间 + * @throws BusinessCheckException + * @return + * */ + List getTobeCommissionOrderList(String dateTime) throws BusinessCheckException; +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/PaymentService.java b/fuint-application/src/main/java/com/fuint/common/service/PaymentService.java new file mode 100644 index 0000000..797b156 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/PaymentService.java @@ -0,0 +1,49 @@ +package com.fuint.common.service; + +import com.fuint.common.dto.UserOrderDto; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.web.ResponseObject; +import com.fuint.repository.model.MtOrder; +import com.fuint.repository.model.MtUser; +import javax.servlet.http.HttpServletRequest; +import java.util.Map; + +/** + * 支付相关业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface PaymentService { + + /** + * 创建预支付订单 + * + * @param userInfo 会员信息 + * @param orderInfo 订单信息 + * @param payAmount 支付金额 + * @param authCode 付款码 + * @param giveAmount 赠送金额 + * @param ip 支付IP地址 + * @param platform 支付平台 + * @return + * */ + ResponseObject createPrepayOrder(MtUser userInfo, MtOrder orderInfo, Integer payAmount, String authCode, Integer giveAmount, String ip, String platform) throws BusinessCheckException; + + /** + * 支付回调 + * + * @param orderInfo 订单信息 + * @return + * */ + Boolean paymentCallback(UserOrderDto orderInfo) throws BusinessCheckException; + + /** + * 订单支付 + * + * @param request 请求参数 + * @return + * */ + Map doPay(HttpServletRequest request) throws BusinessCheckException; + +} \ No newline at end of file diff --git a/fuint-application/src/main/java/com/fuint/common/service/PointService.java b/fuint-application/src/main/java/com/fuint/common/service/PointService.java new file mode 100644 index 0000000..250a61c --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/PointService.java @@ -0,0 +1,46 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.common.dto.PointDto; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.model.MtPoint; + +/** + * 积分业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface PointService extends IService { + + /** + * 分页查询积分列表 + * + * @param paginationRequest + * @return + */ + PaginationResponse queryPointListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException; + + /** + * 添加积分 + * + * @param reqPointDto + * @throws BusinessCheckException + * @return + */ + void addPoint(MtPoint reqPointDto) throws BusinessCheckException; + + /** + * 转赠积分 + * + * @param userId + * @param mobile + * @param amount + * @param remark + * @throws BusinessCheckException + * @return + */ + boolean doGift(Integer userId, String mobile, Integer amount, String remark) throws BusinessCheckException; +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/RefundService.java b/fuint-application/src/main/java/com/fuint/common/service/RefundService.java new file mode 100644 index 0000000..5cff669 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/RefundService.java @@ -0,0 +1,104 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.common.dto.AccountInfo; +import com.fuint.common.dto.RefundDto; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.framework.web.ResponseObject; +import com.fuint.repository.model.MtRefund; +import java.util.Date; +import java.util.Map; + +/** + * 售后业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface RefundService extends IService { + + /** + * 分页查询列表 + * + * @param paginationRequest + * @return + */ + PaginationResponse getRefundListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException; + + /** + * 获取用户的售后订单 + * @param paramMap 查询参数 + * @throws BusinessCheckException + * */ + ResponseObject getUserRefundList(Map paramMap) throws BusinessCheckException; + + /** + * 创建售后订单 + * + * @param reqDto + * @throws BusinessCheckException + */ + MtRefund createRefund(RefundDto reqDto) throws BusinessCheckException; + + /** + * 创建退款补扣订单 + * + * @param reqDto + * @throws BusinessCheckException + */ + MtRefund createRefund2(RefundDto reqDto) throws BusinessCheckException; + /** + * 根据ID获取售后订单信息 + * + * @param id ID + * @throws BusinessCheckException + */ + RefundDto getRefundById(Integer id) throws BusinessCheckException; + + /** + * 根据订单ID获取售后订单信息 + * + * @param orderId + * @throws BusinessCheckException + */ + MtRefund getRefundByOrderId(Integer orderId) throws BusinessCheckException; + + /** + * 更新售后订单 + * @param reqDto + * @param accountInfo + * @throws BusinessCheckException + * */ + MtRefund updateRefund(RefundDto reqDto, AccountInfo accountInfo) throws BusinessCheckException; + + /** + * 同意售后订单 + * @param reqDto + * @param accountInfo + * @throws BusinessCheckException + * */ + MtRefund agreeRefund(RefundDto reqDto, AccountInfo accountInfo) throws BusinessCheckException; + + /** + * 发起退款 + * + * @param orderId + * @param refundAmount + * @param remark + * @param accountInfo + * @param isDeduction 是否为补扣 + * throws BusinessCheckException; + * */ + Boolean doRefund(Integer orderId, String refundAmount, String remark, AccountInfo accountInfo, Boolean isDeduction) throws BusinessCheckException; + + /** + * 获取售后订单总数 + * + * @param beginTime + * @param endTime + * @return + * */ + Long getRefundCount(Date beginTime, Date endTime) throws BusinessCheckException; +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/SendLogService.java b/fuint-application/src/main/java/com/fuint/common/service/SendLogService.java new file mode 100644 index 0000000..061ee36 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/SendLogService.java @@ -0,0 +1,51 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.common.dto.ReqSendLogDto; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.model.MtSendLog; + +/** + * 发券记录业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface SendLogService extends IService { + + /** + * 分页查询列表 + * + * @param paginationRequest + * @return + */ + PaginationResponse querySendLogListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException; + + /** + * 添加记录 + * + * @param reqSendLogDto + * @throws BusinessCheckException + */ + MtSendLog addSendLog(ReqSendLogDto reqSendLogDto) throws BusinessCheckException; + + /** + * 根据组ID获取发券记录 + * + * @param id ID + * @throws BusinessCheckException + */ + MtSendLog querySendLogById(Long id) throws BusinessCheckException; + + /** + * 删除发券记录 + * + * @param id ID + * @param operator 操作人 + * @throws BusinessCheckException + * @return + */ + void deleteSendLog(Long id, String operator) throws BusinessCheckException; +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/SendSmsService.java b/fuint-application/src/main/java/com/fuint/common/service/SendSmsService.java new file mode 100644 index 0000000..992c765 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/SendSmsService.java @@ -0,0 +1,37 @@ +package com.fuint.common.service; + +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.model.MtSmsSendedLog; +import java.util.List; +import java.util.Map; + +/** + * 发送短信接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface SendSmsService { + + /** + * 发送短信方法 + * + * @param merchantId 商户ID + * @param tUname 短信模板英文名称 + * @param phones 手机号码集合 + * @return Map> TRUE:推送成功的手机号码集合; + * FALSE:推送失败的手机号码集合 + * @throws Exception + */ + Map> sendSms(Integer merchantId, String tUname, List phones, Map contentParams) throws BusinessCheckException; + + /** + * 分页已发短信列表 + * + * @param paginationRequest + * @return + */ + PaginationResponse querySmsListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException; +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/SettingService.java b/fuint-application/src/main/java/com/fuint/common/service/SettingService.java new file mode 100644 index 0000000..012d099 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/SettingService.java @@ -0,0 +1,65 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.common.dto.ParamDto; +import com.fuint.repository.model.MtSetting; +import com.fuint.framework.exception.BusinessCheckException; +import java.util.List; + +/** + * 配置业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface SettingService extends IService { + + /** + * 删除配置 + * + * @param merchantId + * @param name + * @throws BusinessCheckException + */ + void removeSetting(Integer merchantId, String name) throws BusinessCheckException; + + /** + * 保存配置 + * + * @param reqDto + * @throws BusinessCheckException + */ + MtSetting saveSetting(MtSetting reqDto) throws BusinessCheckException; + + /** + * 获取配置列表 + * + * @param type + * @throws BusinessCheckException + */ + List getSettingList(Integer merchantId, String type) throws BusinessCheckException; + + /** + * 根据配置名称获取配置信息 + * + * @param merchantId + * @param name name + * @throws BusinessCheckException + */ + MtSetting querySettingByName(Integer merchantId, String name) throws BusinessCheckException; + + /** + * 获取系统上传文件的根路径 + * + * @return 本地配置或阿里云的oss域名 + * */ + String getUploadBasePath(); + + /** + * 获取支付方式列表 + * + * @param platform 平台 + * @return + * */ + List getPayTypeList(String platform); +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/SettlementService.java b/fuint-application/src/main/java/com/fuint/common/service/SettlementService.java new file mode 100644 index 0000000..a68925a --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/SettlementService.java @@ -0,0 +1,54 @@ +package com.fuint.common.service; + +import com.fuint.common.dto.SettlementDto; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.module.backendApi.request.SettlementRequest; +import com.fuint.repository.model.MtSettlement; + +/** + * 订单结算相关业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface SettlementService { + + /** + * 分页查询结算列表 + * + * @param paginationRequest + * @return + */ + PaginationResponse querySettlementListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException; + + /** + * 提交结算 + * + * @param requestParam + * @throws BusinessCheckException + * @return + */ + Boolean submitSettlement(SettlementRequest requestParam) throws BusinessCheckException; + + /** + * 结算确认 + * + * @param settlementId + * @param operator + * @throws BusinessCheckException + * @return + */ + Boolean doConfirm(Integer settlementId, String operator) throws BusinessCheckException; + + /** + * 获取结算详情 + * + * @param settlementId + * @param page + * @param pageSize + * @return + * */ + SettlementDto getSettlementInfo(Integer settlementId, Integer page, Integer pageSize) throws BusinessCheckException; +} \ No newline at end of file diff --git a/fuint-application/src/main/java/com/fuint/common/service/SmsTemplateService.java b/fuint-application/src/main/java/com/fuint/common/service/SmsTemplateService.java new file mode 100644 index 0000000..75000f6 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/SmsTemplateService.java @@ -0,0 +1,58 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.common.dto.SmsTemplateDto; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.model.MtSmsTemplate; + +import java.util.List; +import java.util.Map; + +/** + * 短信模板业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface SmsTemplateService extends IService { + + /** + * 分页查询模板列表 + * + * @param paginationRequest + * @return + */ + PaginationResponse querySmsTemplateListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException; + + /** + * 添加模板 + * + * @param reqSmsTemplateDto + * @throws BusinessCheckException + */ + MtSmsTemplate saveSmsTemplate(SmsTemplateDto reqSmsTemplateDto) throws BusinessCheckException; + + /** + * 删除短信模板 + * @param id + * @param operator + * @return + * */ + void deleteTemplate(Integer id, String operator) throws BusinessCheckException; + + /** + * 根据模板ID获取模板信息 + * + * @param id ID + * @throws BusinessCheckException + */ + MtSmsTemplate querySmsTemplateById(Integer id) throws BusinessCheckException; + + /** + * 根据条件搜索模板 + * */ + List querySmsTemplateByParams(Map params) throws BusinessCheckException; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/SourceService.java b/fuint-application/src/main/java/com/fuint/common/service/SourceService.java new file mode 100644 index 0000000..a487d0d --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/SourceService.java @@ -0,0 +1,94 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.common.domain.TreeSelect; +import com.fuint.common.vo.RouterVo; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.common.domain.TreeNode; +import com.fuint.repository.model.TSource; +import java.util.List; + +/** + * 菜单管理业务接口 + */ +public interface SourceService extends IService { + + /** + * 获取有效的菜单集合 + * + * @param merchantId 商户ID + * @return + */ + List getAvailableSources(Integer merchantId); + + /** + * 获取菜单的属性结构 + * + * @param merchantId 商户ID + * @return + */ + List getSourceTree(Integer merchantId); + + /** + * 根据菜单ID集合查询菜单列表信息 + * + * @param ids + * @return + */ + List findDatasByIds(String[] ids); + + /** + * 根据会员ID获取菜单 + * + * @param merchantId 商户ID + * @param accountId 账号ID + * @throws BusinessCheckException + * @return + */ + List getMenuListByUserId(Integer merchantId, Integer accountId) throws BusinessCheckException; + + /** + * 构建前端路由所需要的菜单 + * + * @param treeNodes 菜单列表 + * @return 路由列表 + */ + List buildMenus(List treeNodes); + + /** + * 构建前端所需要树结构 + * + * @param menus 菜单列表 + * @return 树结构列表 + */ + List buildMenuTree(List menus); + + /** + * 构建前端所需要下拉树结构 + * + * @param menus 菜单列表 + * @return 下拉树结构列表 + */ + List buildMenuTreeSelect(List menus); + + /** + * 添加菜单 + * + * @param tSource + */ + void addSource(TSource tSource); + + /** + * 修改菜单 + * + * @param source + * */ + void editSource(TSource source); + + /** + * 删除菜单 + * + * @param source + * */ + void deleteSource(TSource source); +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/StaffService.java b/fuint-application/src/main/java/com/fuint/common/service/StaffService.java new file mode 100644 index 0000000..2900229 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/StaffService.java @@ -0,0 +1,74 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.model.MtStaff; +import java.util.List; +import java.util.Map; + +/** + * 店铺员工业务接口 + */ +public interface StaffService extends IService { + + /** + * 员工查询列表 + * + * @param paginationRequest + * @return + */ + PaginationResponse queryStaffListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException; + + /** + * 保存员工信息 + * + * @param reqStaff + * @throws BusinessCheckException + */ + MtStaff saveStaff(MtStaff reqStaff) throws BusinessCheckException; + + /** + * 根据ID获取店铺信息 + * + * @param id 员工id + * @throws BusinessCheckException + */ + MtStaff queryStaffById(Integer id) throws BusinessCheckException; + + /** + * 审核更改状态(禁用,审核通过) + * + * @param id + * @throws BusinessCheckException + * @return + */ + Integer updateAuditedStatus(Integer id, String statusEnum) throws BusinessCheckException; + + /** + * 根据条件搜索员工 + * + * @param params 请求参数 + * @return + * */ + List queryStaffByParams(Map params) throws BusinessCheckException; + + /** + * 根据手机号获取员工信息 + * + * @param mobile 手机 + * @throws BusinessCheckException + * @return + */ + MtStaff queryStaffByMobile(String mobile) throws BusinessCheckException; + + /** + * 根据会员ID获取员工信息 + * + * @param userId 会员ID + * @throws BusinessCheckException + * @return + */ + MtStaff queryStaffByUserId(Integer userId) throws BusinessCheckException; +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/StockService.java b/fuint-application/src/main/java/com/fuint/common/service/StockService.java new file mode 100644 index 0000000..d28afa9 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/StockService.java @@ -0,0 +1,65 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.framework.web.ResponseObject; +import com.fuint.repository.model.MtStock; +import com.fuint.repository.model.MtStockItem; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * 库存业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface StockService extends IService { + + /** + * 分页查询列表 + * + * @param paginationRequest + * @return + */ + PaginationResponse queryStockListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException; + + /** + * 新增库存管理记录 + * + * @param mtStock + * @param goodsList + * @throws BusinessCheckException + */ + ResponseObject addStock(MtStock mtStock, List goodsList) throws BusinessCheckException; + + /** + * 删除库存管理记录 + * + * @param id + * @param operator + * @return + * */ + void delete(Integer id, String operator) throws BusinessCheckException; + + /** + * 根据ID获取信息 + * + * @param id ID + * @throws BusinessCheckException + * @return + */ + MtStock queryStockById(Long id) throws BusinessCheckException; + + /** + * 根据条件搜索详情 + * + * @param params + * @throws BusinessCheckException + * @return + * */ + List queryItemByParams(Map params) throws BusinessCheckException; +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/StoreLocationService.java b/fuint-application/src/main/java/com/fuint/common/service/StoreLocationService.java new file mode 100644 index 0000000..2911106 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/StoreLocationService.java @@ -0,0 +1,55 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.common.dto.StoreLocationDto; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.model.MtStoreLocation; + +import java.util.List; +import java.util.Map; + +/** + * 店铺地点业务接口 + */ +public interface StoreLocationService extends IService { + + /** + * 分页查询列表 + * + * @param paginationRequest + * @return + */ + PaginationResponse queryStoreLocationListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException; + + /** + * 添加地点 + * + * @param reqStoreLocationDto + * @throws BusinessCheckException + */ + MtStoreLocation saveStoreLocation(StoreLocationDto reqStoreLocationDto) throws BusinessCheckException; + + /** + * 删除地点 + * @param id + * @param operator + * @return + * */ + void deleteStoreLocation(Integer id, String operator) throws BusinessCheckException; + + /** + * 根据模板ID获取地点信息 + * + * @param id ID + * @throws BusinessCheckException + */ + MtStoreLocation queryStoreLocationById(Integer id) throws BusinessCheckException; + + /** + * 根据条件搜索地点 + * */ + List queryStoreLocationByParams(Map params) throws BusinessCheckException; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/StoreService.java b/fuint-application/src/main/java/com/fuint/common/service/StoreService.java new file mode 100644 index 0000000..ab60643 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/StoreService.java @@ -0,0 +1,99 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.common.dto.StoreDto; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.model.MtStore; +import java.util.List; +import java.util.Map; + +/** + * 店铺业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface StoreService extends IService { + + /** + * 分页查询店铺列表 + * + * @param paginationRequest + * @return + */ + PaginationResponse queryStoreListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException; + + /** + * 保存店铺信息 + * + * @param reqStoreDto + * @throws BusinessCheckException + */ + MtStore saveStore(StoreDto reqStoreDto) throws BusinessCheckException; + + /** + * 获取系统默认店铺 + * + * @throws BusinessCheckException + * @return + */ + MtStore getDefaultStore(String merchantNo) throws BusinessCheckException; + + /** + * 根据店铺ID获取店铺信息 + * + * @param id 店铺ID + * @throws BusinessCheckException + * @return + */ + MtStore queryStoreById(Integer id) throws BusinessCheckException; + + /** + * 根据店铺名称获取店铺信息 + * + * @param storeName 店铺名称 + * @throws BusinessCheckException + */ + StoreDto queryStoreByName(String storeName) throws BusinessCheckException; + + /** + * 根据店铺ID查询店铺信息 + * + * @param id 店铺ID + * @return + * @throws BusinessCheckException + */ + StoreDto queryStoreDtoById(Integer id) throws BusinessCheckException; + + /** + * 更新店铺状态 + * + * @param id 店铺ID + * @param operator 操作人 + * @param status 状态 + * @throws BusinessCheckException + */ + void updateStatus(Integer id, String operator, String status) throws BusinessCheckException; + + /** + * 根据条件查询店铺列表 + * + * @param params 查询参数 + * @return + * */ + List queryStoresByParams(Map params) throws BusinessCheckException; + + /** + * 根据距离远近查找店铺 + * + * @param merchantNo 商户号 + * @param keyword 关键字 + * @param latitude 维度 + * @param longitude 经度 + * @return + * */ + List queryByDistance(String merchantNo, String keyword, String latitude, String longitude) throws BusinessCheckException; + +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/UserActionService.java b/fuint-application/src/main/java/com/fuint/common/service/UserActionService.java new file mode 100644 index 0000000..59d023a --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/UserActionService.java @@ -0,0 +1,49 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.model.MtUserAction; + +/** + * 会员行为业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface UserActionService extends IService { + + /** + * 分页查询列表 + * + * @param paginationRequest + * @return + */ + PaginationResponse queryUserActionListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException; + + /** + * 新增会员行为 + * + * @param mtUserAction + * @throws BusinessCheckException + */ + boolean addUserAction(MtUserAction mtUserAction) throws BusinessCheckException; + + /** + * 根据ID获取会员行为详情 + * + * @param id ID + * @throws BusinessCheckException + */ + MtUserAction getUserActionDetail(Integer id) throws BusinessCheckException; + + /** + * 根据ID删除会员行为 + * + * @param id ID + * @param operator 操作人 + * @throws BusinessCheckException + */ + void deleteUserAction(Integer id, String operator) throws BusinessCheckException; +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/UserCouponService.java b/fuint-application/src/main/java/com/fuint/common/service/UserCouponService.java new file mode 100644 index 0000000..2548317 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/UserCouponService.java @@ -0,0 +1,106 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.common.dto.CouponDto; +import com.fuint.common.param.CouponReceiveParam; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.framework.web.ResponseObject; +import com.fuint.repository.model.MtUserCoupon; +import java.util.List; +import java.util.Map; + +/** + * 会员卡券业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface UserCouponService extends IService { + + /** + * 分页查询列表 + * + * @param paginationRequest + * @return + */ + PaginationResponse queryUserCouponListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException; + + /** + * 领取卡券 + * + * @param couponReceiveParam + * @return + * */ + boolean receiveCoupon(CouponReceiveParam couponReceiveParam) throws BusinessCheckException; + + /** + * 预存卡券 + * + * @param paramMap + * @return + * */ + boolean preStore(Map paramMap) throws BusinessCheckException; + + /** + * 获取会员卡券列表 + * @param userId + * @param status + * @return + * */ + List getUserCouponList(Integer userId, List status) throws BusinessCheckException; + + /** + * 获取用户的卡券 + * @param paramMap 查询参数 + * @throws BusinessCheckException + * */ + ResponseObject getUserCouponList(Map paramMap) throws BusinessCheckException; + + /** + * 获取会员可支付用的卡券 + * + * @param userId + * @param type + * @return + * */ + List getPayAbleCouponList(Integer userId, String type) throws BusinessCheckException; + + /** + * 获取会员卡券详情 + * @param userId + * @param couponId + * */ + List getUserCouponDetail(Integer userId, Integer couponId) throws BusinessCheckException; + + /** + * 获取会员卡券详情 + * + * @param userCouponId + * @return + * */ + MtUserCoupon getUserCouponDetail(Integer userCouponId) throws BusinessCheckException; + + /** + * 根据过期时间查询会员卡券 + * + * @param userId + * @param status + * @param startTime + * @param endTime + * @return + * */ + List getUserCouponListByExpireTime(Integer userId, String status, String startTime, String endTime) throws BusinessCheckException; + + /** + * 给会员发送卡券(会员购买) + * + * @param orderId 订单ID + * @param couponId 卡券ID + * @param userId 会员ID + * @param mobile 会员手机号 + * @return + * */ + boolean buyCouponItem(Integer orderId, Integer couponId, Integer userId, String mobile) throws BusinessCheckException; +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/UserGradeService.java b/fuint-application/src/main/java/com/fuint/common/service/UserGradeService.java new file mode 100644 index 0000000..bd73892 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/UserGradeService.java @@ -0,0 +1,84 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.model.MtUser; +import com.fuint.repository.model.MtUserGrade; +import java.util.List; + +/** + * 会员等级业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface UserGradeService extends IService { + + /** + * 分页查询会员等级列表 + * + * @param paginationRequest + * @return + */ + PaginationResponse queryUserGradeListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException; + + /** + * 添加会员等级 + * + * @param reqDto + * @throws BusinessCheckException + * @return + */ + MtUserGrade addUserGrade(MtUserGrade reqDto) throws BusinessCheckException; + + /** + * 修改会员等级 + * + * @param reqDto + * @throws BusinessCheckException + * @return + */ + MtUserGrade updateUserGrade(MtUserGrade reqDto) throws BusinessCheckException; + + /** + * 根据ID获取会员等级信息 + * + * @param merchantId + * @param gradeId ID + * @param userId + * @throws BusinessCheckException + * @return + */ + MtUserGrade queryUserGradeById(Integer merchantId, Integer gradeId, Integer userId) throws BusinessCheckException; + + /** + * 根据ID删除会员等级 + * + * @param id ID + * @param operator 操作人 + * @throws BusinessCheckException + * @return + */ + Integer deleteUserGrade(Integer id, String operator) throws BusinessCheckException; + + /** + * 获取默认的会员等级 + * + * @param merchantId + * @throws BusinessCheckException + * @return + */ + MtUserGrade getInitUserGrade(Integer merchantId) throws BusinessCheckException; + + /** + * 获取付费会员等级列表 + * + * @param merchantId + * @param userInfo + * @throws BusinessCheckException + * @return + * */ + List getPayUserGradeList(Integer merchantId, MtUser userInfo) throws BusinessCheckException; +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/VerifyCodeService.java b/fuint-application/src/main/java/com/fuint/common/service/VerifyCodeService.java new file mode 100644 index 0000000..5b01867 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/VerifyCodeService.java @@ -0,0 +1,45 @@ +package com.fuint.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.repository.model.MtVerifyCode; + +/** + * 图形验证码接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface VerifyCodeService extends IService { + + /** + * 新增验证码 + * + * @param mobile 手机号 + * @param verifyCode 验证码 + * @param expireSecond 间隔秒数 + * @throws BusinessCheckException + * @return + */ + MtVerifyCode addVerifyCode(String mobile, String verifyCode, Integer expireSecond) throws BusinessCheckException; + + /** + * 根据手机号,验证码,查询时间 + * + * @param mobile 电话号码 + * @param verifyCode 验证码 + * @throws BusinessCheckException + * @return + */ + MtVerifyCode checkVerifyCode(String mobile, String verifyCode) throws BusinessCheckException; + + /** + * 更改验证码状态 + * + * @param id 验证码ID + * @param validFlag 是否验证 + * @throws BusinessCheckException + * @return + */ + MtVerifyCode updateValidFlag(Long id, String validFlag) throws BusinessCheckException; +} \ No newline at end of file diff --git a/fuint-application/src/main/java/com/fuint/common/service/WeixinService.java b/fuint-application/src/main/java/com/fuint/common/service/WeixinService.java new file mode 100644 index 0000000..bb04ee5 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/WeixinService.java @@ -0,0 +1,145 @@ +package com.fuint.common.service; + +import com.alibaba.fastjson.JSONObject; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.web.ResponseObject; +import com.fuint.repository.model.MtOrder; +import com.fuint.repository.model.MtUser; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; +import java.util.Map; +import java.util.Date; + +/** + * 微信相关业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public interface WeixinService { + + /** + * 获取微信登录token + * + * @param merchantId 商户ID + * @param useCache 是否从缓存中读取 + * @return + * */ + String getAccessToken(Integer merchantId, boolean useCache) throws BusinessCheckException ; + + /** + * 提交预支付订单 + * + * @param userInfo 会员信息 + * @param orderInfo 订单信息 + * @param payAmount 支付金额 + * @param authCode 支付二维码 + * @param giveAmount 赠送金额 + * @param ip 支付发起IP + * @param platform 支付平台 + * @return + * */ + ResponseObject createPrepayOrder(MtUser userInfo, MtOrder orderInfo, Integer payAmount, String authCode, Integer giveAmount, String ip, String platform) throws BusinessCheckException; + + /** + * 处理返回的xml数据 + * + * @param request 请求体 + * @return + * */ + Map processResXml(HttpServletRequest request); + + /** + * 处理返回的xml数据 + * + * @param response 返回相应 + * @param flag 标签 + * @return + * */ + void processRespXml(HttpServletResponse response, boolean flag); + + /** + * 获取微信个人信息 + * + * @param merchantId 商户ID + * @param code 登录编码 + * @return + * */ + JSONObject getWxProfile(Integer merchantId, String code) throws BusinessCheckException; + + /** + * 获取微信openId + * + * @param merchantId 商户ID + * @param code 登录编码 + * @return + * */ + JSONObject getWxOpenId(Integer merchantId, String code) throws BusinessCheckException; + + /** + * 获取会员微信绑定的手机号 + * + * @param encryptedData 加密的编码(前端返回) + * @param sessionKey + * @param iv + * @return + * */ + String getPhoneNumber(String encryptedData, String sessionKey, String iv); + + /** + * 发送订阅消息 + * + * @param merchantId 商户ID + * @param userId 会员ID + * @param toUserOpenId 会员openID + * @param key 消息编码 + * @param page 跳转页面 + * @param params 发送参数 + * @param sendTime 发送时间 + * @return + * */ + Boolean sendSubscribeMessage(Integer merchantId, Integer userId, String toUserOpenId, String key, String page, Map params, Date sendTime) throws BusinessCheckException; + + /** + * 发送订阅消息 + * + * @param merchantId 商户ID + * @param reqDataJsonStr 发送参数 + * @return + * */ + Boolean doSendSubscribeMessage(Integer merchantId, String reqDataJsonStr); + + /** + * 查询支付订单 + * + * @param storeId 店铺ID + * @param transactionId 交易单号 + * @param orderSn 订单号 + * @return + * */ + Map queryPaidOrder(Integer storeId, String transactionId, String orderSn); + + /** + * 发起售后 + * + * @param storeId 店铺ID + * @param orderSn 订单号 + * @param totalAmount 订单总金额 + * @param refundAmount 售后金额 + * @param platform 平台 + * @return + * */ + Boolean doRefund(Integer storeId, String orderSn, BigDecimal totalAmount, BigDecimal refundAmount, String platform) throws BusinessCheckException; + + /** + * 生成店铺二维码 + * + * @param merchantId 商户ID + * @param storeId 店铺ID + * @param width 宽度 + * @return + * */ + String createStoreQrCode(Integer merchantId, Integer storeId, Integer width); + +} \ No newline at end of file diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/AccountServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/AccountServiceImpl.java new file mode 100644 index 0000000..a0beffe --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/AccountServiceImpl.java @@ -0,0 +1,338 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.dto.AccountDto; +import com.fuint.common.dto.AccountInfo; +import com.fuint.common.service.AccountService; +import com.fuint.common.service.StaffService; +import com.fuint.common.service.StoreService; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.exception.BusinessRuntimeException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.mapper.*; +import com.fuint.repository.model.*; +import com.fuint.utils.Digests; +import com.fuint.utils.Encodes; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.util.*; + +/** + * 后台账号接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class AccountServiceImpl extends ServiceImpl implements AccountService { + + private TAccountMapper tAccountMapper; + + private TDutyMapper tDutyMapper; + + private TAccountDutyMapper tAccountDutyMapper; + + private MtMerchantMapper mtMerchantMapper; + + private MtStoreMapper mtStoreMapper; + + /** + * 员工接口 + */ + private StaffService staffService; + + /** + * 店铺服务接口 + * */ + private StoreService storeService; + + /** + * 分页查询账号列表 + * + * @param paginationRequest + * @return + */ + @Override + public PaginationResponse getAccountListByPagination(PaginationRequest paginationRequest) { + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(TAccount::getAccountStatus, -1); // 1:启用;0:禁用;-1:删除 + + String name = paginationRequest.getSearchParams().get("name") == null ? "" : paginationRequest.getSearchParams().get("name").toString(); + if (StringUtils.isNotEmpty(name)) { + lambdaQueryWrapper.like(TAccount::getAccountName, name); + } + String realName = paginationRequest.getSearchParams().get("realName") == null ? "" : paginationRequest.getSearchParams().get("realName").toString(); + if (StringUtils.isNotEmpty(realName)) { + lambdaQueryWrapper.like(TAccount::getRealName, realName); + } + String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString(); + if (StringUtils.isNotEmpty(status)) { + lambdaQueryWrapper.eq(TAccount::getAccountStatus, status); + } + String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString(); + if (StringUtils.isNotEmpty(merchantId)) { + lambdaQueryWrapper.eq(TAccount::getMerchantId, merchantId); + } + String storeId = paginationRequest.getSearchParams().get("storeId") == null ? "" : paginationRequest.getSearchParams().get("storeId").toString(); + if (StringUtils.isNotEmpty(storeId)) { + lambdaQueryWrapper.eq(TAccount::getStoreId, storeId); + } + + lambdaQueryWrapper.orderByDesc(TAccount::getAcctId); + List accountList = tAccountMapper.selectList(lambdaQueryWrapper); + List dataList = new ArrayList<>(); + + for (TAccount tAccount : accountList) { + AccountDto accountDto = new AccountDto(); + BeanUtils.copyProperties(tAccount, accountDto); + accountDto.setId(tAccount.getAcctId()); + MtMerchant mtMerchant = mtMerchantMapper.selectById(tAccount.getMerchantId()); + if (mtMerchant != null) { + accountDto.setMerchantName(mtMerchant.getName()); + } + MtStore mtStore = mtStoreMapper.selectById(tAccount.getStoreId()); + if (mtStore != null) { + accountDto.setStoreName(mtStore.getName()); + } + accountDto.setSalt(null); + accountDto.setPassword(null); + dataList.add(accountDto); + } + + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, AccountDto.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 根据账号名称获取账号信息 + * + * @param userName 账号名称 + * @return + * */ + @Override + public AccountInfo getAccountByName(String userName) { + Map param = new HashMap(); + param.put("account_name", userName); + List accountList = tAccountMapper.selectByMap(param); + if (accountList != null && accountList.size() > 0) { + AccountInfo accountInfo = new AccountInfo(); + TAccount account = accountList.get(0); + accountInfo.setId(account.getAcctId()); + accountInfo.setAccountName(account.getAccountName()); + accountInfo.setRealName(account.getRealName()); + accountInfo.setRoleIds(account.getRoleIds()); + accountInfo.setStaffId(account.getStaffId()); + accountInfo.setStoreId(account.getStoreId()); + accountInfo.setMerchantId(account.getMerchantId()); + if (account.getMerchantId() != null && account.getMerchantId() > 0) { + MtMerchant mtMerchant = mtMerchantMapper.selectById(account.getMerchantId()); + if (mtMerchant != null) { + accountInfo.setMerchantName(mtMerchant.getName()); + } + } + if (account.getStoreId() != null && account.getStoreId() > 0) { + MtStore mtStore = mtStoreMapper.selectById(account.getStoreId()); + if (mtStore != null) { + accountInfo.setStoreName(mtStore.getName()); + } + } + return accountInfo; + } else { + return null; + } + } + + /** + * 根据ID获取账号信息 + * + * @param userId 账号ID + * @return + * */ + @Override + public TAccount getAccountInfoById(Integer userId) { + TAccount tAccount = tAccountMapper.selectById(userId); + return tAccount; + } + + /** + * 新增后台账户 + * + * @param tAccount + * @return + * */ + @Override + @OperationServiceLog(description = "新增后台账户") + public TAccount createAccountInfo(TAccount tAccount, List duties) throws BusinessCheckException { + TAccount account = new TAccount(); + account.setAccountKey(tAccount.getAccountKey()); + account.setAccountName(tAccount.getAccountName().toLowerCase()); + account.setAccountStatus(1); + account.setRealName(tAccount.getRealName()); + account.setRoleIds(tAccount.getRoleIds()); + account.setStaffId(tAccount.getStaffId()); + Integer storeId = tAccount.getStoreId() == null ? 0 : tAccount.getStoreId(); + if (tAccount.getMerchantId() == null || tAccount.getMerchantId() <= 0) { + MtStore mtStore = storeService.queryStoreById(storeId); + if (mtStore != null) { + tAccount.setMerchantId(mtStore.getMerchantId()); + } + } + account.setMerchantId(tAccount.getMerchantId()); + account.setStoreId(tAccount.getStoreId()); + account.setCreateDate(new Date()); + account.setModifyDate(new Date()); + account.setStoreId(tAccount.getStoreId()); + account.setStaffId(tAccount.getStaffId()); + account.setPassword(tAccount.getPassword()); + this.entryptPassword(account); + int id = tAccountMapper.insert(account); + + if (id > 0 && duties != null && duties.size() > 0) { + for (TDuty tDuty : duties) { + TAccountDuty tAccountDuty = new TAccountDuty(); + tAccountDuty.setDutyId(tDuty.getDutyId()); + tAccountDuty.setAcctId(account.getAcctId()); + tAccountDutyMapper.insert(tAccountDuty); + } + } + + if (id > 0 ) { + return this.getAccountInfoById(id); + } else { + throw new BusinessRuntimeException("创建账号错误"); + } + } + + /** + * 获取账号角色ID + * + * @param accountId + * @return + * */ + @Override + public List getRoleIdsByAccountId(Integer accountId) { + List roleIds = tDutyMapper.getRoleIdsByAccountId(accountId); + return roleIds; + } + + /** + * 修改账户 + * + * @param tAccount 账户实体 + * @throws BusinessCheckException + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "修改后台账户") + public void editAccount(TAccount tAccount, List duties) throws BusinessCheckException { + TAccount oldAccount = tAccountMapper.selectById(tAccount.getAcctId()); + if (oldAccount == null) { + throw new BusinessCheckException("账户不存在."); + } + tAccount.setModifyDate(new Date()); + if (duties != null && duties.size() > 0) { + if (tAccount.getAcctId() != null && tAccount.getAcctId() > 0) { + tAccountDutyMapper.deleteDutiesByAccountId(tAccount.getAcctId()); + for (TDuty tDuty : duties) { + TAccountDuty tAccountDuty = new TAccountDuty(); + tAccountDuty.setDutyId(tDuty.getDutyId()); + tAccountDuty.setAcctId(tAccount.getAcctId()); + tAccountDutyMapper.insert(tAccountDuty); + } + } + } + if (tAccount.getStaffId() != null && tAccount.getStaffId() > 0) { + MtStaff mtStaff = staffService.queryStaffById(tAccount.getStaffId()); + if (mtStaff == null) { + tAccount.setStaffId(0); + } + } + tAccountMapper.updateById(tAccount); + } + + /** + * 根据账户名称获取账户所分配的角色ID集合 + * + * @param accountId 账户 + * @return 角色ID集合 + */ + @Override + public List getDutyIdsByAccountId(long accountId) { + return tAccountDutyMapper.getDutyIdsByAccountId(accountId); + } + + /** + * 更新账户 + * + * @param tAccount + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "修改后台账户") + public void updateAccount(TAccount tAccount) { + tAccountMapper.updateById(tAccount); + } + + /** + * 删除账号 + * + * @param accountId 账号ID + * @return + * */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "删除后台账户") + public void deleteAccount(Long accountId) { + TAccount tAccount = tAccountMapper.selectById(accountId); + tAccount.setAccountStatus(-1); + tAccount.setModifyDate(new Date()); + tAccountMapper.updateById(tAccount); + } + + /** + * 设定安全的密码 + * + * @param tAccount 账号信息 + * @return + */ + @Override + public void entryptPassword(TAccount tAccount) { + byte[] salt = Digests.generateSalt(8); + tAccount.setSalt(Encodes.encodeHex(salt)); + byte[] hashPassword = Digests.sha1(tAccount.getPassword().getBytes(), salt, 1024); + tAccount.setPassword(Encodes.encodeHex(hashPassword)); + } + + /** + * 获取加密密码 + * + * @param password + * @param salt + * @return + * */ + @Override + public String getEntryptPassword(String password, String salt) { + byte[] salt1 = Encodes.decodeHex(salt); + byte[] hashPassword = Digests.sha1(password.getBytes(), salt1, 1024); + return Encodes.encodeHex(hashPassword); + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/ActionLogServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/ActionLogServiceImpl.java new file mode 100644 index 0000000..355f76e --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/ActionLogServiceImpl.java @@ -0,0 +1,81 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.service.ActionLogService; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.mapper.TActionLogMapper; +import com.fuint.repository.model.TActionLog; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import java.util.List; + +/** + * 日志服务实现类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class ActionLogServiceImpl extends ServiceImpl implements ActionLogService { + + private TActionLogMapper tActionLogMapper; + + public void saveActionLog(TActionLog actionLog) { + + tActionLogMapper.insert(actionLog); + } + + public PaginationResponse findLogsByPagination(PaginationRequest paginationRequest) { + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(TActionLog::getMerchantId, merchantId); + } + String storeId = paginationRequest.getSearchParams().get("storeId") == null ? "" : paginationRequest.getSearchParams().get("storeId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(TActionLog::getStoreId, storeId); + } + String module = paginationRequest.getSearchParams().get("module") == null ? "" : paginationRequest.getSearchParams().get("module").toString(); + if (StringUtils.isNotBlank(module)) { + lambdaQueryWrapper.like(TActionLog::getModule, module); + } + String name = paginationRequest.getSearchParams().get("name") == null ? "" : paginationRequest.getSearchParams().get("name").toString(); + if (StringUtils.isNotBlank(name)) { + lambdaQueryWrapper.eq(TActionLog::getAcctName, name); + } + String startTime = paginationRequest.getSearchParams().get("startTime") == null ? "" : paginationRequest.getSearchParams().get("startTime").toString(); + if (StringUtils.isNotBlank(startTime)) { + lambdaQueryWrapper.gt(TActionLog::getActionTime, startTime); + } + String endTime = paginationRequest.getSearchParams().get("endTime") == null ? "" : paginationRequest.getSearchParams().get("endTime").toString(); + if (StringUtils.isNotBlank(endTime)) { + lambdaQueryWrapper.lt(TActionLog::getActionTime, endTime); + } + String ip = paginationRequest.getSearchParams().get("ip") == null ? "" : paginationRequest.getSearchParams().get("ip").toString(); + if (StringUtils.isNotBlank(ip)) { + lambdaQueryWrapper.eq(TActionLog::getClientIp, ip); + } + + lambdaQueryWrapper.orderByDesc(TActionLog::getId); + List dataList = tActionLogMapper.selectList(lambdaQueryWrapper); + + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, TActionLog.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/AddressServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/AddressServiceImpl.java new file mode 100644 index 0000000..b2e07a8 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/AddressServiceImpl.java @@ -0,0 +1,121 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.service.AddressService; +import com.fuint.repository.model.MtAddress; +import com.fuint.repository.mapper.MtAddressMapper; +import com.fuint.common.enums.YesOrNoEnum; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.common.enums.StatusEnum; +import com.fuint.utils.StringUtil; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.util.List; +import java.util.Date; +import java.util.Map; +import java.util.HashMap; + +/** + * 收货地址业务实现类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class AddressServiceImpl extends ServiceImpl implements AddressService { + + private MtAddressMapper mtAddressMapper; + + /** + * 保存收货地址 + * + * @param mtAddress + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public MtAddress saveAddress(MtAddress mtAddress) { + if (mtAddress.getId() > 0) { + MtAddress address = mtAddressMapper.selectById(mtAddress.getId()); + if (StringUtil.isNotEmpty(mtAddress.getName())) { + address.setName(mtAddress.getName()); + } + if (StringUtil.isNotEmpty(mtAddress.getMobile())) { + address.setMobile(mtAddress.getMobile()); + } + if (StringUtil.isNotEmpty(mtAddress.getDetail())) { + address.setDetail(mtAddress.getDetail()); + } + if (StringUtil.isNotEmpty(mtAddress.getIsDefault())) { + if (mtAddress.getIsDefault().equals(YesOrNoEnum.YES.getKey())) { + mtAddressMapper.setDefault(mtAddress.getUserId(), mtAddress.getId()); + } + address.setIsDefault(mtAddress.getIsDefault()); + } + if (StringUtil.isNotEmpty(mtAddress.getStatus())) { + address.setStatus(mtAddress.getStatus()); + } + if (mtAddress.getProvinceId() > 0) { + address.setProvinceId(mtAddress.getProvinceId()); + } + if (mtAddress.getCityId() > 0) { + address.setCityId(mtAddress.getCityId()); + } + if (mtAddress.getRegionId() > 0) { + address.setRegionId(mtAddress.getRegionId()); + } + + mtAddressMapper.updateById(address); + } else { + mtAddress.setCreateTime(new Date()); + mtAddress.setUpdateTime(new Date()); + mtAddress.setIsDefault(YesOrNoEnum.YES.getKey()); + + this.save(mtAddress); + mtAddressMapper.setDefault(mtAddress.getUserId(), mtAddress.getId()); + } + + return mtAddress; + } + + /** + * 根据ID获取收货地址 + * + * @param id 地址ID + * @throws BusinessCheckException + * @return + */ + @Override + public MtAddress detail(Integer id) { + return mtAddressMapper.selectById(id); + } + + /** + * 根据条件查询地址列表 + * + * @param params 查询参数 + * @return + * */ + @Override + public List queryListByParams(Map params) { + Map param = new HashMap<>(); + + String status = params.get("status") == null ? StatusEnum.ENABLED.getKey(): params.get("status").toString(); + param.put("status", status); + + if (params.get("userId") != null) { + param.put("user_id", params.get("userId").toString()); + } + + if (params.get("isDefault") != null) { + param.put("is_default", YesOrNoEnum.YES.getKey()); + } + + List result = mtAddressMapper.selectByMap(param); + + return result; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/AlipayServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/AlipayServiceImpl.java new file mode 100644 index 0000000..88f91af --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/AlipayServiceImpl.java @@ -0,0 +1,259 @@ +package com.fuint.common.service.impl; + +import com.alipay.api.AlipayApiException; +import com.alipay.api.domain.AlipayTradePayModel; +import com.alipay.api.domain.AlipayTradeQueryModel; +import com.alipay.api.domain.AlipayTradeRefundModel; +import com.alipay.api.internal.util.AlipaySignature; +import com.alipay.api.response.AlipayTradePayResponse; +import com.alipay.api.response.AlipayTradeQueryResponse; +import com.alipay.api.response.AlipayTradeRefundResponse; +import com.fuint.common.bean.AliPayBean; +import com.fuint.common.dto.OrderDto; +import com.fuint.common.dto.UserOrderDto; +import com.fuint.common.enums.*; +import com.fuint.common.service.*; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.web.ResponseObject; +import com.fuint.repository.model.*; +import com.fuint.utils.StringUtil; +import com.ijpay.alipay.AliPayApi; +import com.ijpay.alipay.AliPayApiConfig; +import com.ijpay.alipay.AliPayApiConfigKit; +import lombok.AllArgsConstructor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; +import java.util.*; + +/** + * 支付宝相关接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class AlipayServiceImpl implements AlipayService { + + private static final Logger logger = LoggerFactory.getLogger(WeixinServiceImpl.class); + + private AliPayBean aliPayBean; + + /** + * 订单服务接口 + * */ + private OrderService orderService; + + /** + * 店铺服务接口 + * */ + private StoreService storeService; + + /** + * 创建预支付订单 + * + * @param userInfo 会员信息 + * @param orderInfo 订单信息 + * @param payAmount 支付金额 + * @param authCode 付款码 + * @param giveAmount 赠送金额 + * @param ip 支付IP地址 + * @param platform 支付平台 + * @return + * */ + @Override + @Transactional(rollbackFor = Exception.class) + public ResponseObject createPrepayOrder(MtUser userInfo, MtOrder orderInfo, Integer payAmount, String authCode, Integer giveAmount, String ip, String platform) throws BusinessCheckException { + logger.info("AlipayService createPrepayOrder inParams userInfo={} payAmount={} giveAmount={} goodsInfo={}", userInfo, payAmount, giveAmount, orderInfo); + + String goodsInfo = orderInfo.getOrderSn(); + if (orderInfo.getType().equals(OrderTypeEnum.PRESTORE.getKey())) { + goodsInfo = OrderTypeEnum.PRESTORE.getValue(); + } + + // 更新支付金额 + BigDecimal payAmount1 = new BigDecimal(payAmount).divide(new BigDecimal("100")); + OrderDto reqDto = new OrderDto(); + reqDto.setId(orderInfo.getId()); + reqDto.setPayAmount(payAmount1); + reqDto.setPayType(orderInfo.getPayType()); + orderService.updateOrder(reqDto); + + getApiConfig(orderInfo.getStoreId()); + String notifyUrl = aliPayBean.getDomain(); + AlipayTradePayModel model = new AlipayTradePayModel(); + model.setAuthCode(authCode); + model.setSubject(goodsInfo); + model.setTotalAmount(payAmount1.toString()); + model.setOutTradeNo(orderInfo.getOrderSn()); + model.setStoreId(orderInfo.getStoreId().toString()); + model.setScene("bar_code"); + + String code = ""; + try { + AlipayTradePayResponse response = AliPayApi.tradePayToResponse(model, notifyUrl); + code = response.getCode(); + String msg = response.getMsg(); + logger.info("AlipayService createPrepayOrder return code: {}, msg ", code, msg); + if (!code.equals("10000") || !msg.equalsIgnoreCase("Success")) { + if (code.equals("10003")) { + // 需要会员输入支付密码,等待10秒后查询订单 + try { + Thread.sleep(10000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + Map payResult = queryPaidOrder(orderInfo.getStoreId(), response.getTradeNo(), orderInfo.getOrderSn()); + if (payResult == null) { + throw new BusinessCheckException("支付宝支付失败"); + } + } else { + throw new BusinessCheckException("支付宝支付出错:" + msg); + } + } + } catch (Exception e) { + logger.error("AlipayService createPrepayOrder exception {}", e.getMessage()); + throw new BusinessCheckException("支付宝支付出错,请检查配置项"); + } + + Map respData = new HashMap<>(); + respData.put("result", code); + + ResponseObject responseObject = new ResponseObject(200, "支付宝支付接口返回成功", respData); + logger.info("AlipayService createPrepayOrder outParams {}", responseObject.toString()); + + return responseObject; + } + + /** + * 支付回调 + * + * @param params 请求参数 + * @return + * */ + @Override + public Boolean checkCallBack(Map params) throws Exception { + String orderSn = params.get("out_trade_no") != null ? params.get("out_trade_no") : ""; + Integer storeId = 0; + UserOrderDto orderDto = orderService.getOrderByOrderSn(orderSn); + if (orderDto != null && orderDto.getStoreInfo() != null) { + storeId = orderDto.getStoreInfo().getId(); + } + getApiConfig(storeId); + return AlipaySignature.rsaCheckV1(params, aliPayBean.getPublicKey(), "UTF-8", "RSA2"); + } + + /** + * 获取支付配置 + * + * @param storeId 店铺ID + * @return + * */ + public AliPayApiConfig getApiConfig(Integer storeId) throws BusinessCheckException { + AliPayApiConfig aliPayApiConfig; + String appId = aliPayBean.getAppId(); + String privateKey = aliPayBean.getPrivateKey(); + String publicKey = aliPayBean.getPublicKey(); + + // 优先读取店铺的支付账号 + MtStore mtStore = storeService.queryStoreById(storeId); + if (mtStore != null && StringUtil.isNotEmpty(mtStore.getAlipayAppId()) && StringUtil.isNotEmpty(mtStore.getAlipayPrivateKey()) && StringUtil.isNotEmpty(mtStore.getAlipayPublicKey())) { + appId = mtStore.getAlipayAppId(); + privateKey = mtStore.getAlipayPrivateKey(); + publicKey = mtStore.getAlipayPublicKey(); + } + + aliPayApiConfig = AliPayApiConfig.builder() + .setAppId(appId) + .setAliPayPublicKey(publicKey) + .setCharset("UTF-8") + .setPrivateKey(privateKey) + .setServiceUrl(aliPayBean.getServerUrl()) + .setSignType("RSA2") + .build(); + + AliPayApiConfigKit.setThreadLocalAppId(appId); + AliPayApiConfigKit.setThreadLocalAliPayApiConfig(aliPayApiConfig); + + return aliPayApiConfig; + } + + /** + * 查询支付订单 + * + * @param storeId 店铺ID + * @param tradeNo 交易单号 + * @param orderSn 订单号 + * @return + * */ + @Override + public Map queryPaidOrder(Integer storeId, String tradeNo, String orderSn) throws BusinessCheckException { + try { + AlipayTradeQueryModel model = new AlipayTradeQueryModel(); + if (StringUtil.isNotEmpty(orderSn)) { + model.setOutTradeNo(orderSn); + } + if (StringUtil.isNotEmpty(tradeNo)) { + model.setTradeNo(tradeNo); + } + getApiConfig(storeId); + AlipayTradeQueryResponse response = AliPayApi.tradeQueryToResponse(model); + if (response != null) { + // TradeStatus:TRADE_SUCCESS(交易支付成功,可进行退款)或 TRADE_FINISHED(交易结束,不可退款) + if (response.getTradeStatus() != null && response.getTradeStatus().equals("TRADE_SUCCESS")) { + Map result = new HashMap<>(); + result.put("tradeNo", response.getTradeNo()); + result.put("status", response.getTradeStatus()); + result.put("payAmount", response.getBuyerPayAmount()); + return result; + } + } + } catch (AlipayApiException e) { + logger.info("AlipayService queryPaidOrder response", e.getMessage()); + } + + return null; + } + + /** + * 发起售后退款 + * + * @param storeId 店铺ID + * @param orderSn 订单号 + * @param totalAmount 订单总金额 + * @param refundAmount 售后金额 + * @param platform 订单平台 + * @return + * */ + public Boolean doRefund(Integer storeId, String orderSn, BigDecimal totalAmount, BigDecimal refundAmount, String platform) throws BusinessCheckException { + try { + logger.info("AlipayService.doRefund orderSn = {}, totalFee = {}, refundFee = {}", orderSn, totalAmount, refundAmount); + if (StringUtil.isEmpty(orderSn)) { + throw new BusinessCheckException("退款订单号不能为空..."); + } + if (refundAmount.compareTo(totalAmount) > 0) { + throw new BusinessCheckException("退款金额不能大于总金额..."); + } + getApiConfig(storeId); + AlipayTradeRefundModel model = new AlipayTradeRefundModel(); + model.setOutTradeNo(orderSn); + model.setRefundAmount(refundAmount.toString()); + model.setRefundReason("申请退款"); + AlipayTradeRefundResponse refundResponse = AliPayApi.tradeRefundToResponse(model); + String code = refundResponse.getCode(); + String msg = refundResponse.getMsg(); + String subMsg = refundResponse.getSubMsg() == null ? msg : refundResponse.getSubMsg(); + logger.info("AlipayService refundResult response Body = {}", refundResponse.getBody()); + if (!code.equals("10000") || !msg.equalsIgnoreCase("Success")) { + throw new BusinessCheckException("支付宝退款失败," + subMsg); + } + } catch (AlipayApiException e) { + logger.error("AlipayService.doRefund error = {}", e.getMessage()); + e.printStackTrace(); + } + return true; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/ArticleServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/ArticleServiceImpl.java new file mode 100644 index 0000000..6fe46fe --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/ArticleServiceImpl.java @@ -0,0 +1,277 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.dto.ArticleDto; +import com.fuint.common.service.ArticleService; +import com.fuint.common.service.MerchantService; +import com.fuint.common.service.StoreService; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.mapper.MtArticleMapper; +import com.fuint.repository.model.MtArticle; +import com.fuint.common.service.SettingService; +import com.fuint.common.enums.StatusEnum; +import com.fuint.repository.model.MtStore; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import com.github.pagehelper.Page; +import org.springframework.beans.BeanUtils; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.util.*; + +/** + * 文章服务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class ArticleServiceImpl extends ServiceImpl implements ArticleService { + + private MtArticleMapper mtArticleMapper; + + /** + * 系统设置服务接口 + * */ + private SettingService settingService; + + /** + * 商户服务接口 + * */ + private MerchantService merchantService; + + /** + * 店铺接口 + */ + private StoreService storeService; + + /** + * 分页查询文章列表 + * + * @param paginationRequest + * @return + */ + @Override + public PaginationResponse queryArticleListByPagination(PaginationRequest paginationRequest) { + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtArticle::getStatus, StatusEnum.DISABLE.getKey()); + + String title = paginationRequest.getSearchParams().get("title") == null ? "" : paginationRequest.getSearchParams().get("title").toString(); + if (StringUtils.isNotBlank(title)) { + lambdaQueryWrapper.like(MtArticle::getTitle, title); + } + String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtArticle::getStatus, status); + } + String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(MtArticle::getMerchantId, merchantId); + } + String merchantNo = paginationRequest.getSearchParams().get("merchantNo") == null ? "" : paginationRequest.getSearchParams().get("merchantNo").toString(); + Integer mchId = merchantService.getMerchantId(merchantNo); + if (mchId > 0) { + lambdaQueryWrapper.eq(MtArticle::getMerchantId, mchId); + } + String storeId = paginationRequest.getSearchParams().get("storeId") == null ? "" : paginationRequest.getSearchParams().get("storeId").toString(); + if (StringUtils.isNotBlank(storeId)) { + lambdaQueryWrapper.and(wq -> wq + .eq(MtArticle::getStoreId, 0) + .or() + .eq(MtArticle::getStoreId, storeId)); + } + lambdaQueryWrapper.orderByAsc(MtArticle::getSort); + List articleList = mtArticleMapper.selectList(lambdaQueryWrapper); + List dataList = new ArrayList<>(); + + String basePath = settingService.getUploadBasePath(); + for (MtArticle mtArticle : articleList) { + ArticleDto articleDto = new ArticleDto(); + BeanUtils.copyProperties(mtArticle, articleDto); + articleDto.setImage(basePath + mtArticle.getImage()); + dataList.add(articleDto); + } + + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, ArticleDto.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 添加文章 + * + * @param articleDto 文章参数 + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "新增文章") + public MtArticle addArticle(ArticleDto articleDto) throws BusinessCheckException { + MtArticle mtArticle = new MtArticle(); + mtArticle.setTitle(articleDto.getTitle()); + mtArticle.setBrief(articleDto.getBrief()); + Integer storeId = articleDto.getStoreId() == null ? 0 : articleDto.getStoreId(); + if (articleDto.getMerchantId() == null || articleDto.getMerchantId() <= 0) { + MtStore mtStore = storeService.queryStoreById(storeId); + if (mtStore != null) { + articleDto.setMerchantId(mtStore.getMerchantId()); + } + } + mtArticle.setMerchantId(articleDto.getMerchantId()); + mtArticle.setStoreId(storeId); + mtArticle.setUrl(articleDto.getUrl()); + mtArticle.setClick(0l); + mtArticle.setStatus(StatusEnum.ENABLED.getKey()); + mtArticle.setImage(articleDto.getImage()); + mtArticle.setDescription(articleDto.getDescription()); + mtArticle.setOperator(articleDto.getOperator()); + mtArticle.setUpdateTime(new Date()); + mtArticle.setCreateTime(new Date()); + mtArticle.setSort(articleDto.getSort()); + mtArticle.setMerchantId(articleDto.getMerchantId()); + Integer id = mtArticleMapper.insert(mtArticle); + if (id > 0) { + return mtArticle; + } else { + return null; + } + } + + /** + * 根据ID获取文章 + * + * @param articleId 文章ID + * @return + */ + @Override + public MtArticle queryArticleById(Integer articleId) { + return mtArticleMapper.selectById(articleId); + } + + /** + * 根据ID获取文章详情 + * + * @param articleId 文章ID + * @return + */ + @Override + public ArticleDto getArticleDetail(Integer articleId) { + MtArticle mtArticle = mtArticleMapper.selectById(articleId); + ArticleDto articleDto = new ArticleDto(); + BeanUtils.copyProperties(mtArticle, articleDto); + String baseImage = settingService.getUploadBasePath(); + articleDto.setImage(baseImage + mtArticle.getImage()); + return articleDto; + } + + /** + * 编辑文章 + * + * @param articleDto + * @throws BusinessCheckException + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "编辑文章") + public MtArticle updateArticle(ArticleDto articleDto) throws BusinessCheckException { + MtArticle mtArticle = queryArticleById(articleDto.getId()); + if (mtArticle == null) { + throw new BusinessCheckException("该文章状态异常"); + } + mtArticle.setId(articleDto.getId()); + if (articleDto.getImage() != null) { + mtArticle.setImage(articleDto.getImage()); + } + if (articleDto.getTitle() != null) { + mtArticle.setTitle(articleDto.getTitle()); + } + if (articleDto.getBrief() != null) { + mtArticle.setBrief(articleDto.getBrief()); + } + if (articleDto.getClick() != null) { + mtArticle.setClick(articleDto.getClick()); + } + if (articleDto.getMerchantId() != null) { + mtArticle.setMerchantId(articleDto.getMerchantId()); + } + if (articleDto.getStoreId() != null) { + mtArticle.setStoreId(articleDto.getStoreId()); + } + if (articleDto.getDescription() != null) { + mtArticle.setDescription(articleDto.getDescription()); + } + if (articleDto.getOperator() != null) { + mtArticle.setOperator(articleDto.getOperator()); + } + if (articleDto.getStatus() != null) { + mtArticle.setStatus(articleDto.getStatus()); + } + if (articleDto.getUrl() != null) { + mtArticle.setUrl(articleDto.getUrl()); + } + if (articleDto.getSort() != null) { + mtArticle.setSort(articleDto.getSort()); + } + mtArticle.setUpdateTime(new Date()); + mtArticleMapper.updateById(mtArticle); + return mtArticle; + } + + /** + * 根据条件搜索文章 + * + * @param params + * @return + * */ + @Override + public List queryArticleListByParams(Map params) { + String status = params.get("status") == null ? StatusEnum.ENABLED.getKey(): params.get("status").toString(); + String storeId = params.get("storeId") == null ? "" : params.get("storeId").toString(); + String title = params.get("title") == null ? "" : params.get("title").toString(); + String merchantId = params.get("merchantId") == null ? "" : params.get("merchantId").toString(); + + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.like(MtArticle::getMerchantId, merchantId); + } + if (StringUtils.isNotBlank(title)) { + lambdaQueryWrapper.like(MtArticle::getTitle, title); + } + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtArticle::getStatus, status); + } + if (StringUtils.isNotBlank(storeId)) { + lambdaQueryWrapper.and(wq -> wq + .eq(MtArticle::getStoreId, 0) + .or() + .eq(MtArticle::getStoreId, storeId)); + } + + lambdaQueryWrapper.orderByAsc(MtArticle::getSort); + List dataList = mtArticleMapper.selectList(lambdaQueryWrapper); + String baseImage = settingService.getUploadBasePath(); + + if (dataList.size() > 0) { + for (MtArticle article : dataList) { + article.setImage(baseImage + article.getImage()); + } + } + + return dataList; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/BalanceServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/BalanceServiceImpl.java new file mode 100644 index 0000000..26ef605 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/BalanceServiceImpl.java @@ -0,0 +1,264 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.dto.AccountInfo; +import com.fuint.common.dto.BalanceDto; +import com.fuint.common.enums.StatusEnum; +import com.fuint.common.enums.WxMessageEnum; +import com.fuint.common.service.BalanceService; +import com.fuint.common.service.MemberService; +import com.fuint.common.service.WeixinService; +import com.fuint.common.util.CommonUtil; +import com.fuint.common.util.DateUtil; +import com.fuint.common.util.PhoneFormatCheckUtils; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.mapper.MtBalanceMapper; +import com.fuint.repository.mapper.MtUserMapper; +import com.fuint.repository.model.MtBalance; +import com.fuint.repository.model.MtBanner; +import com.fuint.repository.model.MtUser; +import com.fuint.utils.StringUtil; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; +import java.util.*; + +/** + * 余额管理业务实现类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class BalanceServiceImpl extends ServiceImpl implements BalanceService { + + private MtBalanceMapper mtBalanceMapper; + + private MtUserMapper mtUserMapper; + + /** + * 微信相关服务接口 + * */ + private WeixinService weixinService; + + /** + * 会员服务接口 + * */ + private MemberService memberService; + + /** + * 分页查询余额列表 + * + * @param paginationRequest + * @return + */ + @Override + public PaginationResponse queryBalanceListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException { + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtBalance::getStatus, StatusEnum.DISABLE.getKey()); + + String description = paginationRequest.getSearchParams().get("description") == null ? "" : paginationRequest.getSearchParams().get("description").toString(); + if (StringUtils.isNotBlank(description)) { + lambdaQueryWrapper.like(MtBalance::getDescription, description); + } + String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtBalance::getStatus, status); + } + String userId = paginationRequest.getSearchParams().get("userId") == null ? "" : paginationRequest.getSearchParams().get("userId").toString(); + if (StringUtils.isNotBlank(userId)) { + lambdaQueryWrapper.eq(MtBalance::getUserId, userId); + } + String orderSn = paginationRequest.getSearchParams().get("orderSn") == null ? "" : paginationRequest.getSearchParams().get("orderSn").toString(); + if (StringUtils.isNotBlank(orderSn)) { + lambdaQueryWrapper.eq(MtBalance::getOrderSn, orderSn); + } + String mobile = paginationRequest.getSearchParams().get("mobile") == null ? "" : paginationRequest.getSearchParams().get("mobile").toString(); + if (StringUtils.isNotBlank(mobile)) { + lambdaQueryWrapper.eq(MtBalance::getMobile, mobile); + } + String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(MtBalance::getMerchantId, merchantId); + } + String userNo = paginationRequest.getSearchParams().get("userNo") == null ? "" : paginationRequest.getSearchParams().get("userNo").toString(); + if (StringUtil.isNotEmpty(userNo)) { + if (StringUtil.isEmpty(merchantId)) { + merchantId = "0"; + } + MtUser userInfo = memberService.queryMemberByUserNo(Integer.parseInt(merchantId), userNo); + if (userInfo != null) { + lambdaQueryWrapper.eq(MtBalance::getUserId, userInfo.getId()); + } + } + String storeId = paginationRequest.getSearchParams().get("storeId") == null ? "" : paginationRequest.getSearchParams().get("storeId").toString(); + if (StringUtils.isNotBlank(storeId)) { + lambdaQueryWrapper.eq(MtBalance::getStoreId, storeId); + } + lambdaQueryWrapper.orderByDesc(MtBalance::getId); + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + List balanceList = mtBalanceMapper.selectList(lambdaQueryWrapper); + + List dataList = new ArrayList<>(); + for (MtBalance mtBalance : balanceList) { + MtUser userInfo = memberService.queryMemberById2(mtBalance.getUserId()); + BalanceDto item = new BalanceDto(); + item.setId(mtBalance.getId()); + item.setAmount(mtBalance.getAmount()); + item.setDescription(mtBalance.getDescription()); + item.setCreateTime(mtBalance.getCreateTime()); + item.setUpdateTime(mtBalance.getUpdateTime()); + item.setUserId(mtBalance.getUserId()); + item.setUserInfo(userInfo); + item.setOrderSn(mtBalance.getOrderSn()); + item.setStatus(mtBalance.getStatus()); + item.setOperator(mtBalance.getOperator()); + dataList.add(item); + } + + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, BalanceDto.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 添加余额记录 + * + * @param mtBalance + * @param updateBalance + * @throws BusinessCheckException + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "会员余额变动") + public Boolean addBalance(MtBalance mtBalance, Boolean updateBalance) throws BusinessCheckException { + if (mtBalance.getUserId() < 0) { + return false; + } + mtBalance.setStatus(StatusEnum.ENABLED.getKey()); + mtBalance.setCreateTime(new Date()); + mtBalance.setUpdateTime(new Date()); + + MtUser mtUser = mtUserMapper.selectById(mtBalance.getUserId()); + BigDecimal newAmount = mtUser.getBalance().add(mtBalance.getAmount()); + if (newAmount.compareTo(new BigDecimal("0")) < 0) { + return false; + } + if (mtUser.getStoreId() != null) { + mtBalance.setStoreId(mtUser.getStoreId()); + } + mtBalance.setMerchantId(mtUser.getMerchantId()); + if (updateBalance) { + mtUser.setBalance(newAmount); + mtUserMapper.updateById(mtUser); + } + + if (PhoneFormatCheckUtils.isChinaPhoneLegal(mtUser.getMobile())) { + mtBalance.setMobile(mtUser.getMobile()); + } + mtBalanceMapper.insert(mtBalance); + + // 发送小程序订阅消息 + Date nowTime = new Date(); + Date sendTime = new Date(nowTime.getTime() + 60000); + Map params = new HashMap<>(); + String dateTime = DateUtil.formatDate(Calendar.getInstance().getTime(), "yyyy-MM-dd HH:mm"); + params.put("amount", mtBalance.getAmount()); + params.put("time", dateTime); + params.put("tips", "您的余额发生了变动,请留意~"); + weixinService.sendSubscribeMessage(mtBalance.getMerchantId(), mtBalance.getUserId(), mtUser.getOpenId(), WxMessageEnum.BALANCE_CHANGE.getKey(), "pages/user/index", params, sendTime); + + return true; + } + + /** + * 发放余额 + * + * @param accountInfo + * @param userIds + * @param amount + * @param remark + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "发放余额") + public void distribute(AccountInfo accountInfo, String object, String userIds, String amount, String remark) throws BusinessCheckException { + if (!CommonUtil.isNumeric(amount)) { + throw new BusinessCheckException("充值金额必须是数字"); + } + if (!object.equals("all") && StringUtil.isEmpty(userIds)) { + throw new BusinessCheckException("请先选择会员"); + } + if (accountInfo.getMerchantId() == null || accountInfo.getMerchantId() < 1) { + throw new BusinessCheckException("平台账号不能执行该操作"); + } + BigDecimal balanceAmount = new BigDecimal(amount); + + List userIdArr = new ArrayList<>(); + List userIdList = Arrays.asList(userIds.split(",")); + if (userIdList != null && userIdList.size() > 0) { + for (String userId : userIdList) { + if (StringUtil.isNotEmpty(userId) && !userIdArr.contains(Integer.parseInt(userId))) { + userIdArr.add(Integer.parseInt(userId)); + } + } + } + // 最多不能超过5000人 + if (userIdArr.size() > 5000) { + throw new BusinessCheckException("最多不能超过5000人"); + } + mtUserMapper.updateUserBalance(accountInfo.getMerchantId(), userIdArr, balanceAmount); + + if (!userIdArr.isEmpty()) { + for (Integer userId : userIdArr) { + MtBalance mtBalance = new MtBalance(); + mtBalance.setAmount(new BigDecimal(amount)); + mtBalance.setUserId(userId); + mtBalance.setMerchantId(accountInfo.getMerchantId()); + mtBalance.setDescription(remark); + mtBalance.setOperator(accountInfo.getAccountName()); + addBalance(mtBalance, false); + } + } else { + MtBalance mtBalance = new MtBalance(); + mtBalance.setAmount(new BigDecimal(amount)); + mtBalance.setUserId(0); // userId为0表示全体会员 + mtBalance.setMerchantId(accountInfo.getMerchantId()); + mtBalance.setDescription(remark); + mtBalance.setOperator(accountInfo.getAccountName()); + mtBalance.setStatus(StatusEnum.ENABLED.getKey()); + mtBalance.setCreateTime(new Date()); + mtBalance.setUpdateTime(new Date()); + mtBalanceMapper.insert(mtBalance); + } + } + + /** + * 获取订单余额记录 + * + * @param orderSn + * @return + * */ + @Override + public List getBalanceListByOrderSn(String orderSn) { + return mtBalanceMapper.getBalanceListByOrderSn(orderSn); + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/BannerServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/BannerServiceImpl.java new file mode 100644 index 0000000..e154c0a --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/BannerServiceImpl.java @@ -0,0 +1,240 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; + +import com.fuint.common.service.StoreService; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.model.MtBanner; +import com.fuint.common.dto.BannerDto; +import com.fuint.common.service.BannerService; +import com.fuint.common.service.SettingService; +import com.fuint.common.enums.StatusEnum; +import com.fuint.repository.mapper.MtBannerMapper; + +import com.fuint.repository.model.MtStore; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.github.pagehelper.Page; +import org.springframework.beans.BeanUtils; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.util.*; + +/** + * 焦点图服务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class BannerServiceImpl extends ServiceImpl implements BannerService { + + private static final Logger logger = LoggerFactory.getLogger(BannerServiceImpl.class); + + private MtBannerMapper mtBannerMapper; + + /** + * 系统设置服务接口 + * */ + private SettingService settingService; + + /** + * 店铺接口 + */ + private StoreService storeService; + + /** + * 分页查询焦点图列表 + * + * @param paginationRequest + * @return + */ + @Override + public PaginationResponse queryBannerListByPagination(PaginationRequest paginationRequest) { + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtBanner::getStatus, StatusEnum.DISABLE.getKey()); + + String title = paginationRequest.getSearchParams().get("title") == null ? "" : paginationRequest.getSearchParams().get("title").toString(); + if (StringUtils.isNotBlank(title)) { + lambdaQueryWrapper.like(MtBanner::getTitle, title); + } + String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtBanner::getStatus, status); + } + String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(MtBanner::getMerchantId, merchantId); + } + String storeId = paginationRequest.getSearchParams().get("storeId") == null ? "" : paginationRequest.getSearchParams().get("storeId").toString(); + if (StringUtils.isNotBlank(storeId)) { + lambdaQueryWrapper.eq(MtBanner::getStoreId, storeId); + } + + lambdaQueryWrapper.orderByAsc(MtBanner::getSort); + List dataList = mtBannerMapper.selectList(lambdaQueryWrapper); + + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, MtBanner.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 添加焦点图 + * + * @param bannerDto 焦点图信息 + * @return + */ + @Override + @OperationServiceLog(description = "新增焦点图") + public MtBanner addBanner(BannerDto bannerDto) throws BusinessCheckException { + MtBanner mtBanner = new MtBanner(); + BeanUtils.copyProperties(bannerDto, mtBanner); + Integer storeId = bannerDto.getStoreId() == null ? 0 : bannerDto.getStoreId(); + if (bannerDto.getMerchantId() == null || bannerDto.getMerchantId() <= 0) { + MtStore mtStore = storeService.queryStoreById(storeId); + if (mtStore != null) { + mtBanner.setMerchantId(mtStore.getMerchantId()); + } + } + mtBanner.setStoreId(storeId); + mtBanner.setStatus(StatusEnum.ENABLED.getKey()); + mtBanner.setUpdateTime(new Date()); + mtBanner.setCreateTime(new Date()); + Integer id = mtBannerMapper.insert(mtBanner); + if (id > 0) { + return mtBanner; + } else { + logger.error("新增焦点图失败."); + throw new BusinessCheckException("新增焦点图失败"); + } + } + + /** + * 根据ID获取Banner信息 + * + * @param id BannerID + */ + @Override + public MtBanner queryBannerById(Integer id) { + return mtBannerMapper.selectById(id); + } + + /** + * 根据ID删除Banner图 + * + * @param id BannerID + * @param operator 操作人 + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "删除Banner图") + public void deleteBanner(Integer id, String operator) { + MtBanner mtBanner = queryBannerById(id); + if (null == mtBanner) { + return; + } + mtBanner.setStatus(StatusEnum.DISABLE.getKey()); + mtBanner.setUpdateTime(new Date()); + mtBannerMapper.updateById(mtBanner); + } + + /** + * 修改Banner图 + * + * @param bannerDto + * @throws BusinessCheckException + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "更新焦点图") + public MtBanner updateBanner(BannerDto bannerDto) throws BusinessCheckException { + MtBanner mtBanner = queryBannerById(bannerDto.getId()); + if (mtBanner == null) { + throw new BusinessCheckException("该Banner状态异常"); + } + + mtBanner.setId(bannerDto.getId()); + if (bannerDto.getImage() != null) { + mtBanner.setImage(bannerDto.getImage()); + } + if (bannerDto.getTitle() != null) { + mtBanner.setTitle(bannerDto.getTitle()); + } + if (bannerDto.getStoreId() != null) { + mtBanner.setStoreId(bannerDto.getStoreId()); + } + if (bannerDto.getDescription() != null) { + mtBanner.setDescription(bannerDto.getDescription()); + } + if (bannerDto.getOperator() != null) { + mtBanner.setOperator(bannerDto.getOperator()); + } + if (bannerDto.getStatus() != null) { + mtBanner.setStatus(bannerDto.getStatus()); + } + if (bannerDto.getUrl() != null) { + mtBanner.setUrl(bannerDto.getUrl()); + } + if (bannerDto.getSort() != null) { + mtBanner.setSort(bannerDto.getSort()); + } + mtBanner.setUpdateTime(new Date()); + mtBannerMapper.updateById(mtBanner); + return mtBanner; + } + + @Override + public List queryBannerListByParams(Map params) { + String status = params.get("status") == null ? StatusEnum.ENABLED.getKey(): params.get("status").toString(); + String storeId = params.get("storeId") == null ? "" : params.get("storeId").toString(); + String merchantId = params.get("merchantId") == null ? "" : params.get("merchantId").toString(); + String title = params.get("title") == null ? "" : params.get("title").toString(); + + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + if (StringUtils.isNotBlank(title)) { + lambdaQueryWrapper.like(MtBanner::getTitle, title); + } + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtBanner::getStatus, status); + } + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(MtBanner::getMerchantId, merchantId); + } + if (StringUtils.isNotBlank(storeId)) { + lambdaQueryWrapper.and(wq -> wq + .eq(MtBanner::getStoreId, 0) + .or() + .eq(MtBanner::getStoreId, storeId)); + } + + lambdaQueryWrapper.orderByAsc(MtBanner::getSort); + List dataList = mtBannerMapper.selectList(lambdaQueryWrapper); + String baseImage = settingService.getUploadBasePath(); + + if (dataList.size() > 0) { + for (MtBanner banner : dataList) { + banner.setImage(baseImage + banner.getImage()); + } + } + + return dataList; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/CaptchaServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/CaptchaServiceImpl.java new file mode 100644 index 0000000..e7a8f93 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/CaptchaServiceImpl.java @@ -0,0 +1,105 @@ +package com.fuint.common.service.impl; + +import com.fuint.common.util.RedisUtil; +import com.fuint.common.service.CaptchaService; +import com.google.code.kaptcha.Constants; +import com.google.code.kaptcha.Producer; +import com.fuint.utils.StringUtil; +import lombok.AllArgsConstructor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import javax.servlet.http.HttpSession; +import java.awt.image.BufferedImage; + +/** + * 图形验证码插件服务类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class CaptchaServiceImpl implements CaptchaService { + + private static final Logger logger = LoggerFactory.getLogger(CaptchaServiceImpl.class); + + /** + * 图形验证码生成器 + * */ + private Producer captchaProducer; + + /** + * 生成图形验证码,并保存至Session + * @param session Session + * @return BufferedImage + */ + public BufferedImage getCode(HttpSession session){ + // 生成验证码 + String codeText = captchaProducer.createText(); + BufferedImage codeImage = captchaProducer.createImage(codeText); + logger.info("生成验证码{}", codeText); + + // 设置Session信息 + if (session != null) { + session.setAttribute(Constants.KAPTCHA_SESSION_KEY, codeText); + } + + return codeImage; + } + + /** + * 图形验证码校验 + * @param code 输入的验证码 + * @param session Session + * @return Boolean + */ + public Boolean checkCode(String code, HttpSession session){ + String sessionCode = (String) session.getAttribute(Constants.KAPTCHA_SESSION_KEY); + if (StringUtil.isEmpty(code) || StringUtil.isEmpty(sessionCode)) { + return false; + } else { + if (code.equalsIgnoreCase(sessionCode)) { + return true; + } else { + return false; + } + } + } + + /** + * 生成图形验证码 + * @return BufferedImage + */ + public BufferedImage getCodeByUuid(String uuid) { + // 生成验证码 + String codeText = captchaProducer.createText(); + BufferedImage codeImage = captchaProducer.createImage(codeText); + logger.info("生成验证码{}", codeText); + + if (codeText != null) { + RedisUtil.set(uuid, codeText, 1800); + } + + return codeImage; + } + + /** + * 图形验证码校验 + * @param code 输入的验证码 + * @param uuid uuid + * @return Boolean + */ + public Boolean checkCodeByUuid(String code, String uuid){ + String vCode = RedisUtil.get(uuid); + if (StringUtil.isEmpty(code) || StringUtil.isEmpty(vCode)) { + return false; + } else { + if (code.equalsIgnoreCase(vCode)) { + return true; + } else { + return false; + } + } + } +} \ No newline at end of file diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/CartServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/CartServiceImpl.java new file mode 100644 index 0000000..2e6511f --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/CartServiceImpl.java @@ -0,0 +1,393 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.enums.StatusEnum; +import com.fuint.common.service.CartService; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.repository.mapper.MtCartMapper; +import com.fuint.repository.mapper.MtGoodsMapper; +import com.fuint.repository.mapper.MtGoodsSkuMapper; +import com.fuint.repository.model.MtCart; +import com.fuint.repository.model.MtGoods; +import com.fuint.repository.model.MtGoodsSku; +import com.fuint.utils.StringUtil; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 购物车业务实现类 + */ +@Service +@AllArgsConstructor +public class CartServiceImpl extends ServiceImpl implements CartService { + + private MtCartMapper mtCartMapper; + + private MtGoodsMapper mtGoodsMapper; + + private MtGoodsSkuMapper mtGoodsSkuMapper; + + /** + * 切换购物车给会员 + * + * @param userId + * @param cartIds + * @return + * */ + @Override + @Transactional(rollbackFor = Exception.class) + public Boolean switchCartIds(Integer userId, String cartIds) { + if (userId == null || userId < 1 || StringUtil.isEmpty(cartIds)) { + return false; + } + List cartIdList = Arrays.asList(cartIds.split(",")); + if (cartIdList != null && cartIdList.size() > 0) { + for (String cartId : cartIdList) { + if (StringUtil.isNotEmpty(cartId)) { + MtCart mtCart = mtCartMapper.selectById(Integer.parseInt(cartId)); + if (mtCart != null) { + mtCart.setUserId(userId); + this.updateById(mtCart); + } + } + } + } + return true; + } + + /** + * 保存购物车 + * + * @param reqDto + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public Integer saveCart(MtCart reqDto, String action) throws BusinessCheckException { + if (reqDto.getId() == null && (reqDto.getMerchantId() == null || reqDto.getMerchantId() < 1)) { + throw new BusinessCheckException("商户不能为空"); + } + if (reqDto.getId() == null && (reqDto.getStoreId() == null || reqDto.getStoreId() < 1)) { + throw new BusinessCheckException("店铺不能为空"); + } + + MtCart mtCart = new MtCart(); + Integer cartId = 1; + + // 检查库存是否充足 + if (action.equals("+") || action.equals("=") && reqDto.getNum() > 0) { + MtGoods mtGoods = mtGoodsMapper.selectById(reqDto.getGoodsId()); + Map param = new HashMap<>(); + param.put("status", StatusEnum.ENABLED.getKey()); + param.put("USER_ID", reqDto.getUserId()); + param.put("GOODS_ID", reqDto.getGoodsId()); + if (reqDto.getSkuId() != null && reqDto.getSkuId() > 0) { + param.put("SKU_ID", reqDto.getSkuId()); + } + List cartList = mtCartMapper.selectByMap(param); + Integer cartNum = 0; + if (cartList != null && cartList.size() > 0) { + cartNum = cartList.get(0).getNum(); + } + // 剩余库存数量 + Integer totalStock = 0; + if (reqDto.getSkuId() != null && reqDto.getSkuId() > 0) { + MtGoodsSku mtGoodsSku = mtGoodsSkuMapper.selectById(reqDto.getSkuId()); + if (mtGoodsSku != null && mtGoodsSku.getStock() != null) { + totalStock = mtGoodsSku.getStock(); + } + } else { + totalStock = mtGoods.getStock(); + } + // 判断库存,库存小于要添加的购物车数量、已添加的购物车数量大于库存 + if (totalStock < reqDto.getNum() || totalStock <= cartNum) { + if (action.equals("=") && reqDto.getNum() < cartNum) { + // empty + } else { + throw new BusinessCheckException(mtGoods.getName() + "库存不足了"); + } + } + } + + if (reqDto.getGoodsId() > 0) { + mtCart.setGoodsId(reqDto.getGoodsId()); + } + if (reqDto.getUserId() > 0) { + mtCart.setUserId(reqDto.getUserId()); + } + + // 数量为0,删除购物车 + if (reqDto.getNum() == 0 && reqDto.getId() > 0) { + this.removeCart(reqDto.getId()+""); + } else if (reqDto.getNum() == 0 && action.equals("-")) { + mtCartMapper.deleteCartItem(reqDto.getUserId(), reqDto.getGoodsId(), reqDto.getSkuId()); + } + + // 校验skuId是否正确 + if (reqDto.getSkuId() != null) { + if (reqDto.getSkuId() > 0) { + Map param = new HashMap<>(); + param.put("goods_id", reqDto.getGoodsId().toString()); + param.put("id", reqDto.getSkuId().toString()); + List skuList = mtGoodsSkuMapper.selectByMap(param); + // 该skuId不正常 + if (skuList.size() < 1) { + reqDto.setSkuId(0); + } + } + } + + mtCart.setMerchantId(reqDto.getMerchantId()); + mtCart.setStoreId(reqDto.getStoreId() == null ? 0 : reqDto.getStoreId()); + mtCart.setStatus(StatusEnum.ENABLED.getKey()); + mtCart.setUpdateTime(new Date()); + mtCart.setSkuId(reqDto.getSkuId()); + mtCart.setNum(reqDto.getNum()); + mtCart.setHangNo(reqDto.getHangNo()); + mtCart.setIsVisitor(reqDto.getIsVisitor()); + + // 处理自定义价格,如果商品的价格为0,则使用自定义价格 + MtGoods mtGoods = mtGoodsMapper.selectById(reqDto.getGoodsId()); + if (mtGoods.getPrice().compareTo(BigDecimal.valueOf(0)) == 0){ + mtCart.setSelfPrice(reqDto.getSelfPrice()); + } + mtCart.setPrePayment(reqDto.getPrePayment()); + mtCart.setOperator(reqDto.getOperator()); + + Map params = new HashMap<>(); + params.put("userId", mtCart.getUserId()); + params.put("storeId", mtCart.getStoreId()); + params.put("goodsId", mtCart.getGoodsId()); + params.put("skuId", mtCart.getSkuId()); + params.put("hangNo", reqDto.getHangNo() == null ? "" : reqDto.getHangNo()); + params.put("selfPrice", mtCart.getSelfPrice()); + params.put("operator", mtCart.getOperator()); + + List cartList = queryCartListByParams(params); + if (action.equals("-") && cartList.size() == 0) { + return cartId; + } + // 已存在,仅操作数量增加或减少 + if (cartList.size() > 0 && (mtCart.getId() == null || mtCart.getId() < 1)) { + mtCart = cartList.get(0); + if (action.equals("+")) { + mtCart.setNum(mtCart.getNum() + reqDto.getNum()); + } else if (action.equals("=")) { + mtCart.setNum(reqDto.getNum()); + } else { + Integer num = mtCart.getNum() - 1; + if (num <= 0) { + this.removeCart(mtCart.getId()+""); + return mtCart.getId(); + } else { + mtCart.setNum(mtCart.getNum() - 1); + } + } + this.updateById(mtCart); + } else { + mtCart.setCreateTime(new Date()); + this.save(mtCart); + } + + return mtCart.getId(); + } + + /** + * 删除购物车 + * + * @param cartIds 购物车ID + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void removeCart(String cartIds) { + String[] ids = cartIds.split(","); + if (ids.length < 1) { + return; + } + for (int i = 0; i < ids.length; i++) { + MtCart mtCart = mtCartMapper.selectById(Integer.parseInt(ids[i].trim())); + if (mtCart != null) { + mtCartMapper.deleteById(mtCart.getId()); + } + } + } + + /** + * 删除挂单购物车 + * + * @param hangNo 挂单序号 + * @throws BusinessCheckException + * @return + */ + @Override + @OperationServiceLog(description = "删除挂单") + @Transactional(rollbackFor = Exception.class) + public void removeCartByHangNo(String hangNo) { + if (hangNo != null && StringUtil.isNotEmpty(hangNo)) { + mtCartMapper.deleteCartByHangNo(hangNo); + } + } + + /** + * 清空会员购物车 + * + * @param userId 会员ID + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void clearCart(Integer userId) { + mtCartMapper.clearCart(userId); + } + + /** + * 根据条件查找 + * + * @param params 查询参数 + * @return + * */ + @Override + public List queryCartListByParams(Map params) { + String status = params.get("status") == null ? StatusEnum.ENABLED.getKey() : params.get("status").toString(); + String userId = params.get("userId") == null ? "" : params.get("userId").toString(); + String ids = params.get("ids") == null ? "" : params.get("ids").toString(); + String hangNo = params.get("hangNo") == null ? "" : params.get("hangNo").toString(); + String goodsId = params.get("goodsId") == null ? "" : params.get("goodsId").toString(); + String skuId = params.get("skuId") == null ? "" : params.get("skuId").toString(); + String storeId = params.get("storeId") == null ? "" : params.get("storeId").toString(); + String merchantId = params.get("merchantId") == null ? "" : params.get("merchantId").toString(); + // for自定义价格 + BigDecimal selfPrice = params.get("selfPrice") == null? BigDecimal.ZERO : new BigDecimal(params.get("selfPrice").toString()); + // 挂单操作人 + String operator = params.get("operator") == null ? "" : params.get("operator").toString(); + + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(MtCart::getStatus, status); + + if (selfPrice.compareTo(BigDecimal.ZERO) > 0) { // for自定义价格 + lambdaQueryWrapper.eq(MtCart::getSelfPrice, selfPrice); + } + + if (StringUtil.isNotEmpty(operator)) {// for 挂单操作人 + lambdaQueryWrapper.eq(MtCart::getOperator, operator); + } + + if (StringUtil.isNotEmpty(userId)) { + lambdaQueryWrapper.eq(MtCart::getUserId, userId); + } + if (StringUtil.isNotEmpty(ids)) { + List idList = Arrays.asList(ids.split(",")); + lambdaQueryWrapper.in(MtCart::getId, idList); + if (StringUtil.isNotEmpty(hangNo)) { + lambdaQueryWrapper.eq(MtCart::getHangNo, hangNo); + } + } else{ + lambdaQueryWrapper.eq(MtCart::getHangNo, hangNo); + } + + if (StringUtil.isNotEmpty(goodsId)) { + lambdaQueryWrapper.eq(MtCart::getGoodsId, goodsId); + } + if (StringUtil.isNotEmpty(merchantId) && Integer.parseInt(merchantId) > 0) { + lambdaQueryWrapper.eq(MtCart::getMerchantId, merchantId); + } + if (StringUtil.isNotEmpty(storeId) && Integer.parseInt(storeId) > 0) { + lambdaQueryWrapper.eq(MtCart::getStoreId, storeId); + } + if (StringUtil.isNotEmpty(skuId)) { + lambdaQueryWrapper.eq(MtCart::getSkuId, skuId); + } + + List result = mtCartMapper.selectList(lambdaQueryWrapper); + return result; + } + + /** + * 根据条件查找2 + * + * @param params 查询参数 + * @return + * */ + @Override + public List queryCartListByParams2(Map params) { + String status = params.get("status") == null ? StatusEnum.ENABLED.getKey() : params.get("status").toString(); + String userId = params.get("userId") == null ? "" : params.get("userId").toString(); + String ids = params.get("ids") == null ? "" : params.get("ids").toString(); + String hangNo = params.get("hangNo") == null ? "" : params.get("hangNo").toString(); + String goodsId = params.get("goodsId") == null ? "" : params.get("goodsId").toString(); + String skuId = params.get("skuId") == null ? "" : params.get("skuId").toString(); + String storeId = params.get("storeId") == null ? "" : params.get("storeId").toString(); + String merchantId = params.get("merchantId") == null ? "" : params.get("merchantId").toString(); + + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(MtCart::getStatus, status); + + if (StringUtil.isNotEmpty(userId)) { + lambdaQueryWrapper.eq(MtCart::getUserId, userId); + } + if (StringUtil.isNotEmpty(ids)) { + List idList = Arrays.asList(ids.split(",")); + lambdaQueryWrapper.in(MtCart::getId, idList); + } + if (StringUtil.isNotEmpty(hangNo)) { + lambdaQueryWrapper.eq(MtCart::getHangNo, hangNo); + } + if (StringUtil.isNotEmpty(goodsId)) { + lambdaQueryWrapper.eq(MtCart::getGoodsId, goodsId); + } + if (StringUtil.isNotEmpty(merchantId) && Integer.parseInt(merchantId) > 0) { + lambdaQueryWrapper.eq(MtCart::getMerchantId, merchantId); + } + if (StringUtil.isNotEmpty(storeId) && Integer.parseInt(storeId) > 0) { + lambdaQueryWrapper.eq(MtCart::getStoreId, storeId); + } + if (StringUtil.isNotEmpty(skuId)) { + lambdaQueryWrapper.eq(MtCart::getSkuId, skuId); + } + + List result = mtCartMapper.selectList(lambdaQueryWrapper); + return result; + } + /** + * 更新购物车 + * + * @param cartId ID + * @param hangNo 挂单序号 + * @param isVisitor 是否游客 + * @param prePayment 预付金 + * @param operator 挂单操作人 + * @return + */ + @Override + @OperationServiceLog(description = "执行挂单") + @Transactional(rollbackFor = Exception.class) + public MtCart setHangNo(Integer cartId, String hangNo, String isVisitor, BigDecimal prePayment, String operator) { + MtCart mtCart = mtCartMapper.selectById(cartId); + if (mtCart != null) { + mtCart.setHangNo(hangNo); + mtCart.setUpdateTime(new Date()); + mtCart.setIsVisitor(isVisitor); + + mtCart.setOperator(operator); // 挂单操作人 + if (prePayment.compareTo(mtCart.getPrePayment()) > 0){ // 预付金处理,传入的预付金小于原来的就重新设置 + mtCart.setPrePayment(prePayment); + } + this.updateById(mtCart); + } + return mtCart; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/CateServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/CateServiceImpl.java new file mode 100644 index 0000000..97c3209 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/CateServiceImpl.java @@ -0,0 +1,257 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.dto.GoodsCateDto; +import com.fuint.common.enums.StatusEnum; +import com.fuint.common.service.CateService; +import com.fuint.common.service.StoreService; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.mapper.MtGoodsCateMapper; +import com.fuint.repository.mapper.MtGoodsMapper; +import com.fuint.repository.model.MtGoods; +import com.fuint.repository.model.MtGoodsCate; +import com.fuint.repository.model.MtStore; +import com.fuint.utils.StringUtil; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.util.*; + +/** + * 商品分类业务实现类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class CateServiceImpl extends ServiceImpl implements CateService { + + private static final Logger log = LoggerFactory.getLogger(CateServiceImpl.class); + + private MtGoodsMapper mtGoodsMapper; + + private MtGoodsCateMapper cateMapper; + + /** + * 店铺服务接口 + * */ + private StoreService storeService; + + /** + * 分页查询分类列表 + * + * @param paginationRequest + * @return + */ + @Override + public PaginationResponse queryCateListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException { + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtGoodsCate::getStatus, StatusEnum.DISABLE.getKey()); + + String name = paginationRequest.getSearchParams().get("name") == null ? "" : paginationRequest.getSearchParams().get("name").toString(); + if (StringUtils.isNotBlank(name)) { + lambdaQueryWrapper.like(MtGoodsCate::getName, name); + } + String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtGoodsCate::getStatus, status); + } + String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(MtGoodsCate::getMerchantId, merchantId); + } + String storeId = paginationRequest.getSearchParams().get("storeId") == null ? "" : paginationRequest.getSearchParams().get("storeId").toString(); + if (StringUtils.isNotBlank(storeId)) { + lambdaQueryWrapper.and(wq -> wq + .eq(MtGoodsCate::getStoreId, 0) + .or() + .eq(MtGoodsCate::getStoreId, storeId)); + } + lambdaQueryWrapper.orderByAsc(MtGoodsCate::getSort); + List dataList = new ArrayList<>(); + List cateList = cateMapper.selectList(lambdaQueryWrapper); + for (MtGoodsCate mtCate : cateList) { + GoodsCateDto cateDto = new GoodsCateDto(); + BeanUtils.copyProperties(mtCate, cateDto); + if (mtCate.getStoreId() != null && mtCate.getStoreId() > 0) { + MtStore storeInfo = storeService.queryStoreById(mtCate.getStoreId()); + if (storeInfo != null) { + cateDto.setStoreName(storeInfo.getName()); + } + } + dataList.add(cateDto); + } + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, GoodsCateDto.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 添加商品分类 + * + * @param reqDto 商品分类参数 + * @throws BusinessCheckException + * @return + */ + @Override + @OperationServiceLog(description = "新增商品分类") + public MtGoodsCate addCate(MtGoodsCate reqDto) throws BusinessCheckException { + MtGoodsCate mtCate = new MtGoodsCate(); + if (null != reqDto.getId()) { + mtCate.setId(reqDto.getId()); + } + Integer storeId = reqDto.getStoreId() == null ? 0 : reqDto.getStoreId(); + if (storeId > 0 && (reqDto.getMerchantId() == null || reqDto.getMerchantId() <= 0)) { + MtStore mtStore = storeService.queryStoreById(storeId); + if (mtStore != null) { + reqDto.setMerchantId(mtStore.getMerchantId()); + } + } + mtCate.setName(reqDto.getName()); + mtCate.setStatus(StatusEnum.ENABLED.getKey()); + mtCate.setLogo(reqDto.getLogo()); + mtCate.setDescription(reqDto.getDescription()); + mtCate.setOperator(reqDto.getOperator()); + mtCate.setMerchantId(reqDto.getMerchantId()); + mtCate.setStoreId(storeId); + mtCate.setUpdateTime(new Date()); + mtCate.setCreateTime(new Date()); + this.save(mtCate); + return mtCate; + } + + /** + * 根据ID获取分类信息 + * + * @param id 分类ID + * @throws BusinessCheckException + */ + @Override + public MtGoodsCate queryCateById(Integer id) { + return cateMapper.selectById(id); + } + + /** + * 根据ID删除分类信息 + * + * @param id ID + * @param operator 操作人 + * @throws BusinessCheckException + */ + @Override + @OperationServiceLog(description = "删除商品分类") + public void deleteCate(Integer id, String operator) throws BusinessCheckException { + MtGoodsCate cateInfo = queryCateById(id); + + Map params = new HashMap<>(); + params.put("cate_id", id); + params.put("status", StatusEnum.ENABLED.getKey()); + List goodsList = mtGoodsMapper.selectByMap(params); + if (goodsList != null && goodsList.size() > 0) { + throw new BusinessCheckException("删除失败,该分类有商品存在"); + } + if (null == cateInfo) { + return; + } + cateInfo.setStatus(StatusEnum.DISABLE.getKey()); + cateInfo.setUpdateTime(new Date()); + + this.updateById(cateInfo); + } + + /** + * 修改分类 + * + * @param reqDto + * @throws BusinessCheckException + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "更新商品分类") + public MtGoodsCate updateCate(MtGoodsCate reqDto) throws BusinessCheckException { + MtGoodsCate mtCate = queryCateById(reqDto.getId()); + if (null == mtCate) { + log.error("该分类状态异常"); + throw new BusinessCheckException("该分类状态异常"); + } + mtCate.setId(reqDto.getId()); + if (reqDto.getLogo() != null) { + mtCate.setLogo(reqDto.getLogo()); + } + if (reqDto.getName() != null) { + mtCate.setName(reqDto.getName()); + } + if (reqDto.getDescription() != null) { + mtCate.setDescription(reqDto.getDescription()); + } + mtCate.setUpdateTime(new Date()); + if (StringUtil.isNotEmpty(reqDto.getOperator())) { + mtCate.setOperator(reqDto.getOperator()); + } + if (reqDto.getStatus() != null) { + if (reqDto.getStatus().equals(StatusEnum.DISABLE.getKey())) { + deleteCate(mtCate.getId(), reqDto.getOperator()); + } + mtCate.setStatus(reqDto.getStatus()); + } + if (reqDto.getSort() != null) { + mtCate.setSort(reqDto.getSort()); + } + if (reqDto.getMerchantId() != null && reqDto.getMerchantId() > 0) { + mtCate.setMerchantId(reqDto.getMerchantId()); + } + if (reqDto.getStoreId() != null) { + mtCate.setStoreId(reqDto.getStoreId()); + } + this.updateById(mtCate); + return mtCate; + } + + @Override + public List queryCateListByParams(Map params) { + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtGoodsCate::getStatus, StatusEnum.DISABLE.getKey()); + String storeId = params.get("storeId") == null ? "" : params.get("storeId").toString(); + String merchantId = params.get("merchantId") == null ? "" : params.get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(MtGoodsCate::getMerchantId, merchantId); + } + String name = params.get("name") == null ? "" : params.get("name").toString(); + if (StringUtils.isNotBlank(name)) { + lambdaQueryWrapper.like(MtGoodsCate::getName, name); + } + String status = params.get("status") == null ? StatusEnum.ENABLED.getKey(): params.get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtGoodsCate::getStatus, status); + } + if (StringUtils.isNotBlank(storeId)) { + lambdaQueryWrapper.and(wq -> wq + .eq(MtGoodsCate::getStoreId, 0) + .or() + .eq(MtGoodsCate::getStoreId, storeId)); + } + lambdaQueryWrapper.orderByAsc(MtGoodsCate::getSort); + List dataList = cateMapper.selectList(lambdaQueryWrapper); + return dataList; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/CommissionLogServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/CommissionLogServiceImpl.java new file mode 100644 index 0000000..544fd3c --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/CommissionLogServiceImpl.java @@ -0,0 +1,223 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.dto.CommissionLogDto; +import com.fuint.common.enums.*; +import com.fuint.common.service.*; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.module.backendApi.request.CommissionLogRequest; +import com.fuint.repository.mapper.MtCommissionLogMapper; +import com.fuint.repository.mapper.MtCommissionRuleItemMapper; +import com.fuint.repository.mapper.MtOrderGoodsMapper; +import com.fuint.repository.model.*; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.github.pagehelper.Page; +import org.springframework.beans.BeanUtils; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; +import java.util.*; + +/** + * 分销提成记录服务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class CommissionLogServiceImpl extends ServiceImpl implements CommissionLogService { + + private static final Logger logger = LoggerFactory.getLogger(CommissionLogServiceImpl.class); + + private MtCommissionLogMapper mtCommissionLogMapper; + + private MtCommissionRuleItemMapper mtCommissionRuleItemMapper; + + private MtOrderGoodsMapper mtOrderGoodsMapper; + + /** + * 订单服务接口 + * */ + private OrderService orderService; + + /** + * 店铺服务接口 + * */ + private StoreService storeService; + + /** + * 员工服务接口 + * */ + private StaffService staffService; + + /** + * 提成方案规则服务接口 + * */ + private CommissionRuleService commissionRuleService; + + /** + * 分页查询记录列表 + * + * @param paginationRequest + * @return + */ + @Override + public PaginationResponse queryCommissionLogByPagination(PaginationRequest paginationRequest) { + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtCommissionLog::getStatus, StatusEnum.DISABLE.getKey()); + + String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtCommissionLog::getStatus, status); + } + String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(MtCommissionLog::getMerchantId, merchantId); + } + String storeId = paginationRequest.getSearchParams().get("storeId") == null ? "" : paginationRequest.getSearchParams().get("storeId").toString(); + if (StringUtils.isNotBlank(storeId)) { + lambdaQueryWrapper.eq(MtCommissionLog::getStoreId, storeId); + } + + lambdaQueryWrapper.orderByDesc(MtCommissionLog::getId); + List commissionLogList = mtCommissionLogMapper.selectList(lambdaQueryWrapper); + List dataList = new ArrayList<>(); + if (commissionLogList != null && commissionLogList.size() > 0) { + for (MtCommissionLog mtCommissionLog : commissionLogList) { + CommissionLogDto commissionLogDto = new CommissionLogDto(); + BeanUtils.copyProperties(mtCommissionLog, commissionLogDto); + commissionLogDto.setTypeName(OrderTypeEnum.getName(mtCommissionLog.getType())); + MtOrder mtOrder = orderService.getById(mtCommissionLog.getOrderId()); + commissionLogDto.setOrderInfo(mtOrder); + MtStore mtStore = storeService.getById(mtCommissionLog.getStoreId()); + commissionLogDto.setStoreInfo(mtStore); + MtStaff mtStaff = staffService.getById(mtCommissionLog.getStaffId()); + commissionLogDto.setStaffInfo(mtStaff); + MtCommissionRule mtCommissionRule = commissionRuleService.getById(mtCommissionLog.getRuleId()); + commissionLogDto.setRuleInfo(mtCommissionRule); + dataList.add(commissionLogDto); + } + } + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, CommissionLogDto.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 计算订单分销提成 + * + * @param orderId 订单ID + * @return + */ + @Override + @Transactional + public void calculateCommission(Integer orderId) { + if (orderId != null && orderId > 0) { + MtOrder mtOrder = orderService.getById(orderId); + // 商品订单佣金计算 + if (mtOrder != null && mtOrder.getType().equals(OrderTypeEnum.GOOGS.getKey())) { + Map params = new HashMap<>(); + params.put("ORDER_ID", mtOrder.getId()); + params.put("STATUS", StatusEnum.ENABLED.getKey()); + List goodsList = mtOrderGoodsMapper.selectByMap(params); + if (goodsList != null && goodsList.size() > 0) { + for (MtOrderGoods orderGoods : goodsList) { + Integer goodsId = orderGoods.getGoodsId(); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.eq(MtCommissionRuleItem::getMerchantId, mtOrder.getMerchantId()); + lambdaQueryWrapper.eq(MtCommissionRuleItem::getTargetId, goodsId); + lambdaQueryWrapper.eq(MtCommissionRuleItem::getType, OrderTypeEnum.GOOGS.getKey()); + lambdaQueryWrapper.eq(MtCommissionRuleItem::getStatus, StatusEnum.ENABLED.getKey()); + lambdaQueryWrapper.orderByDesc(MtCommissionRuleItem::getId); + List commissionRuleItemList = mtCommissionRuleItemMapper.selectList(lambdaQueryWrapper); + if (commissionRuleItemList != null && commissionRuleItemList.size() > 0) { + MtCommissionRuleItem mtCommissionRuleItem = commissionRuleItemList.get(0); + MtCommissionLog mtCommissionLog = new MtCommissionLog(); + BigDecimal amount = orderGoods.getPrice().multiply(mtCommissionRuleItem.getGuest().divide(new BigDecimal("100"))); + mtCommissionLog.setType(mtOrder.getType()); + mtCommissionLog.setLevel(0); + mtCommissionLog.setUserId(mtOrder.getUserId()); + mtCommissionLog.setOrderId(orderId); + mtCommissionLog.setMerchantId(mtOrder.getMerchantId()); + mtCommissionLog.setStoreId(mtOrder.getStoreId()); + mtCommissionLog.setStaffId(mtOrder.getStaffId()); + mtCommissionLog.setAmount(amount); + mtCommissionLog.setRuleId(mtCommissionRuleItem.getRuleId()); + mtCommissionLog.setRuleItemId(mtCommissionRuleItem.getId()); + mtCommissionLog.setCashId(0); + mtCommissionLog.setCashTime(null); + mtCommissionLog.setCreateTime(new Date()); + mtCommissionLog.setUpdateTime(new Date()); + mtCommissionLog.setStatus(StatusEnum.ENABLED.getKey()); + mtCommissionLog.setOperator(null); + mtCommissionLogMapper.insert(mtCommissionLog); + } + } + } + } + } else { + logger.error("计算分销提成订单不能ID为空..."); + } + } + + /** + * 根据ID获取记录信息 + * + * @param id 分佣提成记录ID + * @return + */ + @Override + public CommissionLogDto queryCommissionLogById(Integer id) { + MtCommissionLog mtCommissionLog = mtCommissionLogMapper.selectById(id); + CommissionLogDto commissionLogDto = null; + if (mtCommissionLog != null) { + BeanUtils.copyProperties(mtCommissionLog, commissionLogDto); + } + return commissionLogDto; + } + + /** + * 更新分销提成记录 + * + * @param commissionLogRequest 请求参数 + * @return + */ + @Override + @Transactional + @OperationServiceLog(description = "更新分销提成记录") + public void updateCommissionLog(CommissionLogRequest commissionLogRequest) throws BusinessCheckException { + MtCommissionLog mtCommissionLog = mtCommissionLogMapper.selectById(commissionLogRequest.getId()); + if (mtCommissionLog == null) { + logger.error("更新分销提成记录失败..."); + throw new BusinessCheckException("更新分销提成记录失败"); + } + mtCommissionLog.setStatus(commissionLogRequest.getStatus() == null ? CommissionStatusEnum.NORMAL.getKey() : commissionLogRequest.getStatus()); + mtCommissionLog.setUpdateTime(new Date()); + if (commissionLogRequest.getAmount() != null) { + mtCommissionLog.setAmount(new BigDecimal(commissionLogRequest.getAmount())); + } + if (commissionLogRequest.getDescription() != null) { + mtCommissionLog.setDescription(commissionLogRequest.getDescription()); + } + mtCommissionLog.setOperator(commissionLogRequest.getOperator()); + mtCommissionLogMapper.updateById(mtCommissionLog); + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/CommissionRuleServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/CommissionRuleServiceImpl.java new file mode 100644 index 0000000..93df440 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/CommissionRuleServiceImpl.java @@ -0,0 +1,262 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; + +import com.fuint.common.dto.CommissionRuleDto; +import com.fuint.common.dto.CommissionRuleItemDto; +import com.fuint.common.param.CommissionRuleItemParam; +import com.fuint.common.param.CommissionRuleParam; +import com.fuint.common.service.GoodsService; +import com.fuint.common.service.SettingService; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.mapper.MtCommissionRuleItemMapper; +import com.fuint.repository.mapper.MtCommissionRuleMapper; +import com.fuint.common.service.CommissionRuleService; +import com.fuint.common.enums.StatusEnum; + +import com.fuint.repository.model.MtCommissionRule; +import com.fuint.repository.model.MtCommissionRuleItem; +import com.fuint.repository.model.MtGoods; +import com.fuint.utils.StringUtil; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.github.pagehelper.Page; +import org.springframework.beans.BeanUtils; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.util.*; + +/** + * 分销提成服务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class CommissionRuleServiceImpl extends ServiceImpl implements CommissionRuleService { + + private static final Logger logger = LoggerFactory.getLogger(CommissionRuleServiceImpl.class); + + private MtCommissionRuleMapper mtCommissionRuleMapper; + + private MtCommissionRuleItemMapper mtCommissionRuleItemMapper; + + /** + * 商品服务接口 + * */ + private GoodsService goodsService; + + /** + * 系统设置服务接口 + * */ + private SettingService settingService; + + /** + * 分页查询规则列表 + * + * @param paginationRequest + * @return + */ + @Override + public PaginationResponse queryDataByPagination(PaginationRequest paginationRequest) { + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtCommissionRule::getStatus, StatusEnum.DISABLE.getKey()); + + String name = paginationRequest.getSearchParams().get("name") == null ? "" : paginationRequest.getSearchParams().get("name").toString(); + if (StringUtils.isNotBlank(name)) { + lambdaQueryWrapper.like(MtCommissionRule::getName, name); + } + String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtCommissionRule::getStatus, status); + } + String target = paginationRequest.getSearchParams().get("target") == null ? "" : paginationRequest.getSearchParams().get("target").toString(); + if (StringUtils.isNotBlank(target)) { + lambdaQueryWrapper.eq(MtCommissionRule::getTarget, target); + } + String type = paginationRequest.getSearchParams().get("type") == null ? "" : paginationRequest.getSearchParams().get("type").toString(); + if (StringUtils.isNotBlank(type)) { + lambdaQueryWrapper.eq(MtCommissionRule::getType, type); + } + String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(MtCommissionRule::getMerchantId, merchantId); + } + String storeId = paginationRequest.getSearchParams().get("storeId") == null ? "" : paginationRequest.getSearchParams().get("storeId").toString(); + if (StringUtils.isNotBlank(storeId)) { + lambdaQueryWrapper.eq(MtCommissionRule::getStoreId, storeId); + } + + lambdaQueryWrapper.orderByDesc(MtCommissionRule::getId); + List dataList = mtCommissionRuleMapper.selectList(lambdaQueryWrapper); + + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, MtCommissionRule.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 添加分销提成规则 + * + * @param commissionRule + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "新增分销提成规则") + public MtCommissionRule addCommissionRule(CommissionRuleParam commissionRule) throws BusinessCheckException { + MtCommissionRule mtCommissionRule = new MtCommissionRule(); + BeanUtils.copyProperties(commissionRule, mtCommissionRule); + mtCommissionRule.setStatus(StatusEnum.ENABLED.getKey()); + Date date = new Date(); + mtCommissionRule.setCreateTime(date); + mtCommissionRule.setUpdateTime(date); + mtCommissionRule.setMerchantId(mtCommissionRule.getMerchantId()== null ? 0 : mtCommissionRule.getMerchantId()); + String storeIds = StringUtil.join(commissionRule.getStoreIdList().toArray(), ","); + mtCommissionRule.setStoreIds(storeIds); + boolean result = save(mtCommissionRule); + if (result) { + if (commissionRule.getDetailList() != null && commissionRule.getDetailList().size() > 0) { + for (CommissionRuleItemParam itemParam : commissionRule.getDetailList()) { + MtCommissionRuleItem mtCommissionRuleItem = new MtCommissionRuleItem(); + mtCommissionRuleItem.setRuleId(mtCommissionRule.getId()); + mtCommissionRuleItem.setType(mtCommissionRule.getType()); + mtCommissionRuleItem.setTarget(mtCommissionRule.getTarget()); + mtCommissionRuleItem.setMerchantId(mtCommissionRule.getMerchantId()); + mtCommissionRuleItem.setStoreId(mtCommissionRule.getStoreId()); + mtCommissionRuleItem.setStoreIds(storeIds); + mtCommissionRuleItem.setCreateTime(date); + mtCommissionRuleItem.setUpdateTime(date); + mtCommissionRuleItem.setOperator(commissionRule.getOperator()); + mtCommissionRuleItem.setStatus(mtCommissionRule.getStatus()); + mtCommissionRuleItem.setMethod(itemParam.getMethod()); + mtCommissionRuleItem.setTarget(commissionRule.getTarget()); + mtCommissionRuleItem.setTargetId(itemParam.getGoodsId()); + mtCommissionRuleItem.setMember(itemParam.getMemberVal()); + mtCommissionRuleItem.setGuest(itemParam.getVisitorVal()); + mtCommissionRuleItemMapper.insert(mtCommissionRuleItem); + } + } + } else { + logger.error("新增分销提成规则失败..."); + throw new BusinessCheckException("新增分销方案规则失败"); + } + return mtCommissionRule; + } + + /** + * 根据ID获取规则信息 + * + * @param id + * @return + */ + @Override + public CommissionRuleDto queryCommissionRuleById(Integer id) throws BusinessCheckException { + MtCommissionRule mtCommissionRule = mtCommissionRuleMapper.selectById(id); + if (mtCommissionRule == null) { + return null; + } + CommissionRuleDto commissionRuleDto = new CommissionRuleDto(); + BeanUtils.copyProperties(mtCommissionRule, commissionRuleDto); + + Map param = new HashMap(); + param.put("RULE_ID", id); + param.put("STATUS", StatusEnum.ENABLED.getKey()); + List mtCommissionRuleItem = mtCommissionRuleItemMapper.selectByMap(param); + List detailList = new ArrayList<>(); + String basePath = settingService.getUploadBasePath(); + if (mtCommissionRuleItem != null && mtCommissionRuleItem.size() > 0) { + for (MtCommissionRuleItem item : mtCommissionRuleItem) { + CommissionRuleItemDto commissionRuleItemDto = new CommissionRuleItemDto(); + commissionRuleItemDto.setGoodsId(item.getTargetId()); + MtGoods mtGoods = goodsService.queryGoodsById(item.getTargetId()); + if (mtGoods != null) { + commissionRuleItemDto.setGoodsName(mtGoods.getName()); + commissionRuleItemDto.setLogo(basePath + mtGoods.getLogo()); + commissionRuleItemDto.setPrice(mtGoods.getPrice()); + } + commissionRuleItemDto.setType(item.getType()); + commissionRuleItemDto.setMemberVal(item.getMember()); + commissionRuleItemDto.setMethod(item.getMethod()); + commissionRuleItemDto.setVisitorVal(item.getGuest()); + detailList.add(commissionRuleItemDto); + } + } + commissionRuleDto.setDetailList(detailList); + + List storeIds = new ArrayList<>(); + if (StringUtil.isNotEmpty(mtCommissionRule.getStoreIds())) { + List storeIdList = Arrays.asList(mtCommissionRule.getStoreIds().split(",")); + if (storeIdList != null && storeIdList.size() > 0) { + for (String storeId : storeIdList) { + storeIds.add(Integer.parseInt(storeId)); + } + } + } + commissionRuleDto.setStoreIdList(storeIds); + + return commissionRuleDto; + } + + /** + * 更新分销提成规则 + * + * @param commissionRule + * @throws BusinessCheckException + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "更新分销提成规则") + public MtCommissionRule updateCommissionRule(CommissionRuleParam commissionRule) throws BusinessCheckException { + MtCommissionRule mtCommissionRule = mtCommissionRuleMapper.selectById(commissionRule.getId()); + if (mtCommissionRule == null) { + logger.error("更新分销提成规则失败..."); + throw new BusinessCheckException("该数据状态异常"); + } + mtCommissionRule.setId(commissionRule.getId()); + if (commissionRule.getName() != null) { + mtCommissionRule.setName(commissionRule.getName()); + } + if (commissionRule.getTarget() != null) { + mtCommissionRule.setTarget(commissionRule.getTarget()); + } + if (commissionRule.getType() != null) { + mtCommissionRule.setType(commissionRule.getType()); + } + if (commissionRule.getStoreId() != null) { + mtCommissionRule.setStoreId(commissionRule.getStoreId()); + } + if (commissionRule.getDescription() != null) { + mtCommissionRule.setDescription(commissionRule.getDescription()); + } + if (commissionRule.getOperator() != null) { + mtCommissionRule.setOperator(commissionRule.getOperator()); + } + if (commissionRule.getStatus() != null) { + mtCommissionRule.setStatus(commissionRule.getStatus()); + if (commissionRule.getStatus().equals(StatusEnum.DISABLE.getKey())) { + mtCommissionRuleItemMapper.deleteByRuleId(commissionRule.getId(), new Date()); + } + } + mtCommissionRule.setUpdateTime(new Date()); + mtCommissionRuleMapper.updateById(mtCommissionRule); + return mtCommissionRule; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/ConfirmLogServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/ConfirmLogServiceImpl.java new file mode 100644 index 0000000..febe83f --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/ConfirmLogServiceImpl.java @@ -0,0 +1,162 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.dto.ConfirmLogDto; +import com.fuint.common.enums.StatusEnum; +import com.fuint.common.service.ConfirmLogService; +import com.fuint.common.service.CouponService; +import com.fuint.common.service.MemberService; +import com.fuint.common.service.StoreService; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.mapper.MtConfirmLogMapper; +import com.fuint.repository.model.*; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import java.util.*; + +/** + * 核销卡券服务 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class ConfirmLogServiceImpl extends ServiceImpl implements ConfirmLogService { + + private MtConfirmLogMapper mtConfirmLogMapper; + + /** + * 卡券服务接口 + * */ + private CouponService couponService; + + /** + * 会员服务接口 + * */ + private MemberService memberService; + + /** + * 店铺服务接口 + * */ + private StoreService storeService; + + /** + * 分页查询卡券核销列表 + * + * @param paginationRequest + * @return + */ + @Override + public PaginationResponse queryConfirmLogListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException { + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtConfirmLog::getStatus, StatusEnum.DISABLE.getKey()); + + String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtConfirmLog::getStatus, status); + } + String userId = paginationRequest.getSearchParams().get("userId") == null ? "" : paginationRequest.getSearchParams().get("userId").toString(); + if (StringUtils.isNotBlank(userId)) { + lambdaQueryWrapper.eq(MtConfirmLog::getUserId, userId); + } + String couponId = paginationRequest.getSearchParams().get("couponId") == null ? "" : paginationRequest.getSearchParams().get("couponId").toString(); + if (StringUtils.isNotBlank(couponId)) { + lambdaQueryWrapper.eq(MtConfirmLog::getCouponId, couponId); + } + String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(MtConfirmLog::getMerchantId, merchantId); + } + String storeId = paginationRequest.getSearchParams().get("storeId") == null ? "" : paginationRequest.getSearchParams().get("storeId").toString(); + if (StringUtils.isNotBlank(storeId)) { + lambdaQueryWrapper.eq(MtConfirmLog::getStoreId, storeId); + } + + lambdaQueryWrapper.orderByDesc(MtConfirmLog::getId); + List confirmLogList = mtConfirmLogMapper.selectList(lambdaQueryWrapper); + List dataList = new ArrayList<>(); + + for (MtConfirmLog log : confirmLogList) { + MtUser userInfo = memberService.queryMemberById(log.getUserId()); + MtStore storeInfo = storeService.queryStoreById(log.getStoreId()); + MtCoupon couponInfo = couponService.queryCouponById(log.getCouponId()); + ConfirmLogDto item = new ConfirmLogDto(); + item.setId(log.getId()); + item.setCode(log.getCode()); + item.setUserInfo(userInfo); + item.setStoreInfo(storeInfo); + item.setCouponInfo(couponInfo); + item.setUserCouponId(log.getUserCouponId()); + item.setAmount(log.getAmount()); + item.setCreateTime(log.getCreateTime()); + item.setUpdateTime(log.getUpdateTime()); + item.setStatus(log.getStatus()); + item.setRemark(log.getRemark()); + item.setOperator(log.getOperator()); + dataList.add(item); + } + + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, ConfirmLogDto.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 获取卡券(计次卡)核销次数 + * @param userCouponId 会员卡券ID + * @return + * */ + @Override + public Long getConfirmNum(Integer userCouponId) { + if (userCouponId > 0) { + return mtConfirmLogMapper.getConfirmNum(userCouponId); + } else { + return 0L; + } + } + + /** + * 获取卡券核销列表 + * @param userCouponId + * @return + * */ + @Override + public List getConfirmList(Integer userCouponId) { + if (userCouponId == null || userCouponId <= 0) { + return new ArrayList<>(); + } + Map params = new HashMap<>(); + params.put("status", StatusEnum.ENABLED.getKey()); + params.put("USER_COUPON_ID", userCouponId.toString()); + return mtConfirmLogMapper.selectByMap(params); + } + + /** + * 获取卡券核销数量 + * @param merchantId 商户ID + * @param storeId 店铺ID + * @param beginTime 开始时间 + * @param endTime 结束时间 + * @return + * */ + @Override + public Long getConfirmCount(Integer merchantId, Integer storeId, Date beginTime, Date endTime) { + return mtConfirmLogMapper.getConfirmLogCount(merchantId, storeId, beginTime, endTime); + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/CouponGroupServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/CouponGroupServiceImpl.java new file mode 100644 index 0000000..e4b6628 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/CouponGroupServiceImpl.java @@ -0,0 +1,598 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.dto.CouponCellDto; +import com.fuint.common.dto.GroupDataDto; +import com.fuint.common.dto.ReqCouponGroupDto; +import com.fuint.common.dto.ReqSendLogDto; +import com.fuint.common.enums.StatusEnum; +import com.fuint.common.enums.UserCouponStatusEnum; +import com.fuint.common.service.*; +import com.fuint.common.util.CommonUtil; +import com.fuint.common.util.DateUtil; +import com.fuint.common.util.XlsUtil; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.mapper.MtCouponGroupMapper; +import com.fuint.repository.mapper.MtCouponMapper; +import com.fuint.repository.mapper.MtUserCouponMapper; +import com.fuint.repository.model.*; +import com.fuint.utils.StringUtil; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.core.env.Environment; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.ui.Model; +import org.springframework.util.ResourceUtils; +import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; +import java.io.File; +import java.io.IOException; +import java.math.BigDecimal; +import java.lang.String; +import java.util.*; +import java.util.regex.Pattern; + +/** + * 卡券分组业务实现类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class CouponGroupServiceImpl extends ServiceImpl implements CouponGroupService { + + private static final Logger log = LoggerFactory.getLogger(CouponGroupServiceImpl.class); + + private MtCouponGroupMapper mtCouponGroupMapper; + + private MtCouponMapper mtCouponMapper; + + private MtUserCouponMapper mtUserCouponMapper; + + /** + * 卡券服务接口 + * */ + private CouponService couponService; + + /** + * 会员卡券服务接口 + * */ + private UserCouponService userCouponService; + + /** + * 会员服务接口 + * */ + private MemberService memberService; + + /** + * 卡券发放记录服务接口 + * */ + private SendLogService sendLogService; + + /** + * 短信发送服务接口 + * */ + private SendSmsService sendSmsService; + + /** + * 系统环境变量 + * */ + private Environment env; + + /** + * 分页查询卡券分组列表 + * + * @param paginationRequest + * @return + */ + @Override + public PaginationResponse queryCouponGroupListByPagination(PaginationRequest paginationRequest) { + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtCouponGroup::getStatus, StatusEnum.DISABLE.getKey()); + + String name = paginationRequest.getSearchParams().get("name") == null ? "" : paginationRequest.getSearchParams().get("name").toString(); + if (StringUtils.isNotBlank(name)) { + lambdaQueryWrapper.like(MtCouponGroup::getName, name); + } + String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtCouponGroup::getStatus, status); + } + String id = paginationRequest.getSearchParams().get("id") == null ? "" : paginationRequest.getSearchParams().get("id").toString(); + if (StringUtils.isNotBlank(id)) { + lambdaQueryWrapper.eq(MtCouponGroup::getId, id); + } + String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(MtCouponGroup::getMerchantId, merchantId); + } + String storeId = paginationRequest.getSearchParams().get("storeId") == null ? "" : paginationRequest.getSearchParams().get("storeId").toString(); + if (StringUtils.isNotBlank(storeId)) { + lambdaQueryWrapper.eq(MtCouponGroup::getStoreId, storeId); + } + + lambdaQueryWrapper.orderByDesc(MtCouponGroup::getId); + List dataList = mtCouponGroupMapper.selectList(lambdaQueryWrapper); + + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, MtCouponGroup.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 添加卡券分组 + * + * @param reqCouponGroupDto + * @throws BusinessCheckException + */ + @Override + @OperationServiceLog(description = "新增卡券分组") + public MtCouponGroup addCouponGroup(ReqCouponGroupDto reqCouponGroupDto) { + MtCouponGroup couponGroup = new MtCouponGroup(); + couponGroup.setMerchantId(reqCouponGroupDto.getMerchantId()); + couponGroup.setStoreId(reqCouponGroupDto.getStoreId()); + couponGroup.setName(CommonUtil.replaceXSS(reqCouponGroupDto.getName())); + couponGroup.setMoney(new BigDecimal("0")); + couponGroup.setTotal(0); + couponGroup.setDescription(CommonUtil.replaceXSS(reqCouponGroupDto.getDescription())); + couponGroup.setStatus(StatusEnum.ENABLED.getKey()); + couponGroup.setCreateTime(new Date()); + couponGroup.setUpdateTime(new Date()); + couponGroup.setNum(0); + couponGroup.setOperator(reqCouponGroupDto.getOperator()); + + this.save(couponGroup); + return couponGroup; + } + + /** + * 根据分组ID获取卡券分组信息 + * + * @param id 卡券分组ID + * @throws BusinessCheckException + */ + @Override + public MtCouponGroup queryCouponGroupById(Integer id) { + return mtCouponGroupMapper.selectById(id); + } + + /** + * 根据ID删除卡券分组 + * + * @param id 分组ID + * @param operator 操作人 + * @throws BusinessCheckException + */ + @Override + @OperationServiceLog(description = "删除卡券分组") + public void deleteCouponGroup(Integer id, String operator) { + MtCouponGroup couponGroup = queryCouponGroupById(id); + if (null == couponGroup) { + return; + } + + couponGroup.setStatus(StatusEnum.DISABLE.getKey()); + couponGroup.setUpdateTime(new Date()); + couponGroup.setOperator(operator); + + this.updateById(couponGroup); + } + + /** + * 修改卡券分组 + * + * @param reqcouponGroupDto + * @throws BusinessCheckException + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "更新卡券分组") + public MtCouponGroup updateCouponGroup(ReqCouponGroupDto reqcouponGroupDto) throws BusinessCheckException { + MtCouponGroup couponGroup = queryCouponGroupById(reqcouponGroupDto.getId()); + if (null == couponGroup || StatusEnum.DISABLE.getKey().equalsIgnoreCase(couponGroup.getStatus())) { + throw new BusinessCheckException("该分组不存在或已被删除"); + } + if (reqcouponGroupDto.getName() != null) { + couponGroup.setName(CommonUtil.replaceXSS(reqcouponGroupDto.getName())); + } + if (reqcouponGroupDto.getDescription() != null) { + couponGroup.setDescription(CommonUtil.replaceXSS(reqcouponGroupDto.getDescription())); + } + if (couponGroup.getTotal() == null) { + couponGroup.setTotal(0); + } + if (reqcouponGroupDto.getStatus() != null) { + couponGroup.setStatus(reqcouponGroupDto.getStatus()); + } + couponGroup.setUpdateTime(new Date()); + couponGroup.setOperator(reqcouponGroupDto.getOperator()); + this.updateById(couponGroup); + return couponGroup; + } + + /** + * 获取卡券种类数量 + * + * @param id + * @throws BusinessCheckException + */ + @Override + @Transactional(rollbackFor = Exception.class) + public Integer getCouponNum(Integer id) { + Long num = mtCouponMapper.queryNumByGroupId(id); + return num.intValue(); + } + + /** + * 获取卡券总价值 + * + * @param groupId + * @throws BusinessCheckException + */ + @Override + @Transactional(rollbackFor = Exception.class) + public BigDecimal getCouponMoney(Integer groupId) { + List couponList = mtCouponMapper.queryByGroupId(groupId.intValue()); + MtCouponGroup groupInfo = queryCouponGroupById(groupId); + BigDecimal money = BigDecimal.valueOf(0); + if (couponList.size() > 0) { + for (int i = 0; iuploadFile:{}", "文件类型不正确"); + throw new BusinessCheckException("文件类型不正确"); + } + + List> content = new ArrayList<>(); + try { + content = XlsUtil.readExcelContent(file.getInputStream(), isExcel2003, 1, null, null, null); + } catch (IOException e) { + log.error("CouponGroupServiceImpl->parseExcelContent{}", e); + throw new BusinessCheckException("导入失败"+e.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + } + + StringBuffer errorMsg = new StringBuffer(); + StringBuffer errorMsgNoGroup = new StringBuffer(); + StringBuffer errorMsgNoNum = new StringBuffer(); + StringBuffer errorMsgNoRegister = new StringBuffer(); + + List rows = new ArrayList<>(); + + for (int i = 0; i < content.size(); i++) { + List groupIdArr = new ArrayList<>(); + List numArr = new ArrayList<>(); + + List rowContent = content.get(i); + String mobile = rowContent.get(0); + String merchantId = rowContent.get(1); + + if (StringUtil.isBlank(mobile) || mobile.length() < 11 || mobile.length() > 11) { + errorMsg.append("第" + i + "行错误,手机号有误:"+mobile); + continue; + } + + for (int j = 1; j < rowContent.size(); j++) { + Integer item = 0; + String cellContent = rowContent.get(j); + if (null == cellContent || cellContent.equals("")) { + continue; + } + + Pattern pattern = Pattern.compile("^[1-9]\\d*$"); + if ((j%2) != 0) { + if (item == null || (!pattern.matcher(cellContent).matches())) { + throw new BusinessCheckException("第" + (i+1) + "行第"+ j +"列错误, 卡券ID异常"); + } + + item = Integer.parseInt(cellContent); + if (item < 0) { + errorMsg.append("第" + (i+1) + "行第"+ j +"列错误, 卡券ID异常"); + continue; + } + groupIdArr.add(item); + } else { + if (item == null || (!pattern.matcher(rowContent.get(j)).matches())) { + throw new BusinessCheckException("第" + (i+1) + "行第"+ j +"列错误, 数量异常"); + } + + item = Integer.parseInt(rowContent.get(j)); + if (item < 0) { + errorMsg.append("第" + (i+1) + "行第"+ j +"列错误, 数量异常"); + continue; + } + numArr.add(item); + } + } + + if (groupIdArr.size() != numArr.size()) { + throw new BusinessCheckException("表格数据有问题导致无法导入"); + } + + CouponCellDto item = new CouponCellDto(); + item.setMobile(mobile); + item.setGroupId(groupIdArr); + item.setNum(numArr); + item.setMerchantId(Integer.parseInt(merchantId)); + rows.add(item); + } + + if (rows.size() < 1) { + throw new BusinessCheckException("表格数据为空导致无法导入"); + } + + if (rows.size() > 1000) { + throw new BusinessCheckException("每次导入最多不能超过1000人"); + } + + // 获取每个分组的总数 + Map couponIdMap = new HashMap<>(); + for (CouponCellDto dto : rows) { + MtUser userInfo = memberService.queryMemberByMobile(dto.getMerchantId(), dto.getMobile()); + if (userInfo == null) { + userInfo = memberService.addMemberByMobile(dto.getMerchantId(), dto.getMobile()); + } + + if (null == userInfo || !userInfo.getStatus().equals(StatusEnum.ENABLED.getKey())) { + if (StringUtil.isNotBlank(errorMsgNoGroup.toString())) { + errorMsgNoGroup.append("," + dto.getMobile()); + } else { + errorMsgNoGroup.append("手机号没有注册或已禁用:"+dto.getMobile()); + } + } + + for (int k = 0; k < dto.getGroupId().size(); k++) { + Integer num = dto.getNum().get(k); + Integer total = couponIdMap.get(dto.getGroupId().get(k).toString()) == null ? 0 : couponIdMap.get(dto.getGroupId().get(k).toString()); + couponIdMap.put(dto.getGroupId().get(k).toString(), (total+num)); + } + } + + if (StringUtil.isNotBlank(errorMsgNoRegister.toString())) { + throw new BusinessCheckException(errorMsgNoRegister.toString()); + } + + for (String couponId : couponIdMap.keySet()) { + MtCoupon couponInfo = couponService.queryCouponById(Integer.parseInt(couponId)); + if (null == couponInfo) { + if (StringUtil.isNotBlank(errorMsgNoGroup.toString())) { + errorMsgNoGroup.append("," + couponId); + } else { + errorMsgNoGroup.append("卡券ID不存在:"+couponId); + } + continue; + } + + if (!couponInfo.getStatus().equals(StatusEnum.ENABLED.getKey())) { + throw new BusinessCheckException("卡券ID"+couponId+"可能已删除或禁用"); + } + + Integer totalNum = couponInfo.getTotal() == null ? 0 : couponInfo.getTotal(); + Integer sendNum = couponIdMap.get(couponId); + Integer hasSendNum = getSendNum(Integer.parseInt(couponId)); + if (totalNum > 0 && ((totalNum - hasSendNum) < sendNum)) { + Integer needNum = sendNum - (totalNum - hasSendNum); + if (StringUtil.isNotBlank(errorMsgNoNum.toString())) { + errorMsgNoNum.append(";卡券ID:" + couponId + "存量不足,至少再添加" + needNum + "套"); + } else { + errorMsgNoNum.append("卡券ID:" + couponId + "存量不足,至少再添加" + needNum + "套"); + } + } + } + + if (StringUtil.isNotBlank(errorMsgNoGroup.toString())) { + throw new BusinessCheckException(errorMsgNoGroup.toString()); + } + + if (StringUtil.isNotBlank(errorMsgNoNum.toString())) { + throw new BusinessCheckException(errorMsgNoNum.toString()); + } + + if (StringUtil.isNotBlank(errorMsg.toString())) { + throw new BusinessCheckException(errorMsg.toString()); + } + + // 导入批次 + String uuid = UUID.randomUUID().toString().replaceAll("-", ""); + + // 至此,验证都通过了,开始发券 + try { + for (CouponCellDto cellDto : rows) { + // 发送张数 + Integer totalNum = 0; + // 发送总价值 + BigDecimal totalMoney = new BigDecimal("0.0"); + for (int gid = 0; gid < cellDto.getGroupId().size(); gid++) { + MtCouponGroup mtCouponGroup = getById(cellDto.getGroupId().get(gid).intValue()); + MtUser mtUser = memberService.queryMemberByMobile(mtCouponGroup.getMerchantId(), cellDto.getMobile()); + couponService.sendCoupon(cellDto.getGroupId().get(gid).intValue(), mtUser.getId(), cellDto.getNum().get(gid), false, uuid, operator); + List couponList = couponService.queryCouponListByGroupId(cellDto.getGroupId().get(gid).intValue()); + // 累加总张数、总价值 + for (MtCoupon coupon : couponList) { + totalNum = totalNum + (coupon.getSendNum()*cellDto.getNum().get(gid)); + totalMoney = totalMoney.add((coupon.getAmount().multiply(new BigDecimal(cellDto.getNum().get(gid)).multiply(new BigDecimal(coupon.getSendNum()))))); + } + } + + MtUser mtUser = memberService.queryMemberByMobile(cellDto.getMerchantId(), cellDto.getMobile()); + + // 发放记录 + ReqSendLogDto dto = new ReqSendLogDto(); + dto.setMerchantId(cellDto.getMerchantId()); + dto.setType(2); + dto.setMobile(cellDto.getMobile()); + dto.setUserId(mtUser.getId()); + dto.setFileName(originalFileName); + dto.setFilePath(filePath); + dto.setGroupId(0); + dto.setCouponId(0); + dto.setGroupName(""); + dto.setSendNum(0); + dto.setOperator(operator); + dto.setUuid(uuid); + sendLogService.addSendLog(dto); + + // 发送短信 +// try { +// List mobileList = new ArrayList<>(); +// mobileList.add(cellDto.getMobile()); +// Map params = new HashMap<>(); +// params.put("totalNum", totalNum+""); +// params.put("totalMoney", totalMoney+""); +// sendSmsService.sendSms(cellDto.getMerchantId(), "received-coupon", mobileList, params); +// } catch (Exception e) { +// //empty +// } + } + } catch (BusinessCheckException e) { + throw new BusinessCheckException(e.getMessage()); + } + return uuid; + } + + /** + * 保存文件 + * + * @param file excel文件 + * @param request + * */ + public String saveExcelFile(MultipartFile file, HttpServletRequest request) throws Exception { + String fileName = file.getOriginalFilename(); + + String imageName = fileName.substring(fileName.lastIndexOf(".")); + String pathRoot = env.getProperty("images.root"); + if (pathRoot == null || StringUtil.isEmpty(pathRoot)) { + pathRoot = ResourceUtils.getURL("classpath:").getPath(); + } + String uuid = UUID.randomUUID().toString().replaceAll("-", ""); + + String filePath = "/static/uploadFiles/"+ DateUtil.formatDate(new Date(), "yyyyMMdd")+"/"; + String path = filePath + uuid + imageName; + + try { + File tempFile = new File(pathRoot + path); + if (!tempFile.getParentFile().exists()) { + tempFile.getParentFile().mkdirs(); + } + CommonUtil.saveMultipartFile(file, pathRoot + path); + } catch (Exception e) { + //empty + } + + return path; + } + + /** + * 获取分组统计数据 + * + * @param groupId 分组ID + * */ + public GroupDataDto getGroupData(Integer groupId, HttpServletRequest request, Model model) throws BusinessCheckException { + MtCouponGroup groupInfo = queryCouponGroupById(groupId); + + // 已发放套数 + Integer sendNum = 0; + + // 未发放套数 + Integer unSendNum = groupInfo.getTotal() - sendNum; + + // 已使用张数 + PaginationRequest requestUserCouponUse = new PaginationRequest(); + requestUserCouponUse.getSearchParams().put("groupId", groupId.toString()); + requestUserCouponUse.getSearchParams().put("status", UserCouponStatusEnum.USED.getKey()); + PaginationResponse dataUserCoupon = userCouponService.queryUserCouponListByPagination(requestUserCouponUse); + Long useNum = dataUserCoupon.getTotalElements(); + + // 已过期张数 + Date nowDate = new Date(); + Integer expireNum = 0; + List couponList = couponService.queryCouponListByGroupId(groupId); + List userCouponList = mtUserCouponMapper.queryExpireNumByGroupId(groupId); + if (null != userCouponList) { + for (MtUserCoupon userCoupon: userCouponList) { + MtCoupon couponInfo = null; + for (MtCoupon coupon: couponList) { + if (userCoupon.getCouponId().toString().equals(coupon.getId().toString())) { + couponInfo = coupon; + break; + } + } + if (null == couponInfo) { + continue; + } + if (nowDate.after(couponInfo.getEndTime())) { + expireNum++; + } + } + } + + // 已作废张数 + PaginationRequest requestUserCouponCancel = new PaginationRequest(); + requestUserCouponCancel.getSearchParams().put("groupId", groupId.toString()); + requestUserCouponCancel.getSearchParams().put("status", UserCouponStatusEnum.DISABLE.getKey()); + PaginationResponse dataUserCouponCancel = userCouponService.queryUserCouponListByPagination(requestUserCouponCancel); + Long cancelNum = dataUserCouponCancel.getTotalElements(); + + GroupDataDto data = new GroupDataDto(); + data.setSendNum(sendNum); + data.setUnSendNum(unSendNum); + data.setUseNum(useNum.intValue()); + data.setExpireNum(expireNum.intValue()); + data.setCancelNum(cancelNum.intValue()); + + return data; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/CouponServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/CouponServiceImpl.java new file mode 100644 index 0000000..cd938c2 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/CouponServiceImpl.java @@ -0,0 +1,1140 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.Constants; +import com.fuint.common.dto.CouponDto; +import com.fuint.common.dto.ReqCouponDto; +import com.fuint.common.dto.ReqSendLogDto; +import com.fuint.common.enums.*; +import com.fuint.common.param.CouponListParam; +import com.fuint.common.service.*; +import com.fuint.common.util.CommonUtil; +import com.fuint.common.util.DateUtil; +import com.fuint.common.util.SeqUtil; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.framework.web.ResponseObject; +import com.fuint.repository.bean.CouponNumBean; +import com.fuint.repository.mapper.*; +import com.fuint.repository.model.*; +import com.fuint.utils.StringUtil; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.context.annotation.Lazy; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 卡券业务实现类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor(onConstructor_= {@Lazy}) +public class CouponServiceImpl extends ServiceImpl implements CouponService { + + private MtCouponMapper mtCouponMapper; + + private MtUserCouponMapper mtUserCouponMapper; + + private MtConfirmLogMapper mtConfirmLogMapper; + + private MtSendLogMapper mtSendLogMapper; + + private MtStoreMapper mtStoreMapper; + + private MtCouponGoodsMapper mtCouponGoodsMapper; + + /** + * 会员卡券服务接口 + * */ + private UserCouponService userCouponService; + + /** + * 会员服务接口 + * */ + private MemberService memberService; + + /** + * 短信发送服务接口 + * */ + private SendSmsService sendSmsService; + + /** + * 核销记录服务接口 + * */ + private ConfirmLogService confirmLogService; + + /** + * 卡券发放记录服务接口 + * */ + private SendLogService sendLogService; + + /** + * 卡券分组服务接口 + * */ + private CouponGroupService couponGroupService; + + /** + * 系统配置服务接口 + * */ + private SettingService settingService; + + /** + * 微信相关服务接口 + * */ + private WeixinService weixinService; + + /** + * 分页查询券列表 + * + * @param paginationRequest + * @return + */ + @Override + public PaginationResponse queryCouponListByPagination(PaginationRequest paginationRequest) { + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtCoupon::getStatus, StatusEnum.DISABLE.getKey()); + + String name = paginationRequest.getSearchParams().get("name") == null ? "" : paginationRequest.getSearchParams().get("name").toString(); + if (StringUtils.isNotBlank(name)) { + lambdaQueryWrapper.like(MtCoupon::getName, name); + } + String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtCoupon::getStatus, status); + } + String groupId = paginationRequest.getSearchParams().get("groupId") == null ? "" : paginationRequest.getSearchParams().get("groupId").toString(); + if (StringUtils.isNotBlank(groupId)) { + lambdaQueryWrapper.eq(MtCoupon::getGroupId, groupId); + } + String type = paginationRequest.getSearchParams().get("type") == null ? "" : paginationRequest.getSearchParams().get("type").toString(); + if (StringUtils.isNotBlank(type)) { + lambdaQueryWrapper.eq(MtCoupon::getType, type); + } + String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(MtCoupon::getMerchantId, merchantId); + } + String storeId = paginationRequest.getSearchParams().get("storeId") == null ? "" : paginationRequest.getSearchParams().get("storeId").toString(); + if (StringUtils.isNotBlank(storeId)) { + lambdaQueryWrapper.eq(MtCoupon::getStoreId, storeId); + } + + lambdaQueryWrapper.orderByDesc(MtCoupon::getId); + List dataList = mtCouponMapper.selectList(lambdaQueryWrapper); + + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, MtCoupon.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 保存卡券信息 + * + * @param reqCouponDto 卡券实体 + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "保存卡券信息") + public MtCoupon saveCoupon(ReqCouponDto reqCouponDto) throws BusinessCheckException, ParseException { + MtCoupon mtCoupon; + + if (reqCouponDto.getId() != null) { + mtCoupon = mtCouponMapper.selectById(reqCouponDto.getId()); + } else { + mtCoupon = new MtCoupon(); + } + // 固定有效期验证 + if (reqCouponDto.getExpireType().equals(CouponExpireTypeEnum.FIX.getKey())) { + Date startTime = DateUtil.parseDate(reqCouponDto.getBeginTime()); + Date endTime = DateUtil.parseDate(reqCouponDto.getEndTime()); + if (endTime.before(startTime)) { + throw new BusinessCheckException("生效期结束时间不能早于开始时间"); + } + } + if (reqCouponDto.getMerchantId() != null) { + mtCoupon.setMerchantId(reqCouponDto.getMerchantId()); + } + if (reqCouponDto.getStoreId() != null) { + mtCoupon.setStoreId(reqCouponDto.getStoreId()); + } + mtCoupon.setGroupId(reqCouponDto.getGroupId()); + if (reqCouponDto.getType() != null) { + mtCoupon.setType(reqCouponDto.getType()); + } + if (reqCouponDto.getName() != null) { + mtCoupon.setName(CommonUtil.replaceXSS(reqCouponDto.getName())); + } + if (reqCouponDto.getIsGive() != null) { + mtCoupon.setIsGive(reqCouponDto.getIsGive().equals(1) ? true : false); + } + if (reqCouponDto.getPoint() != null) { + mtCoupon.setPoint(reqCouponDto.getPoint()); + } + if (mtCoupon.getPoint() == null) { + mtCoupon.setPoint(0); + } + if (reqCouponDto.getLimitNum() != null) { + mtCoupon.setLimitNum(reqCouponDto.getLimitNum()); + } + if (mtCoupon.getLimitNum() == null) { + mtCoupon.setLimitNum(1); + } + if (reqCouponDto.getReceiveCode() != null) { + mtCoupon.setReceiveCode(reqCouponDto.getReceiveCode()); + } + if (mtCoupon.getReceiveCode() == null) { + mtCoupon.setReceiveCode(""); + } + + if (mtCoupon.getType().equals(CouponTypeEnum.TIMER.getKey())) { + if (reqCouponDto.getTimerPoint() != null) { + mtCoupon.setPoint(reqCouponDto.getTimerPoint()); + } + if (reqCouponDto.getTimerReceiveCode() != null) { + mtCoupon.setReceiveCode(reqCouponDto.getTimerReceiveCode()); + } + } + + mtCoupon.setStoreIds(reqCouponDto.getStoreIds()); + mtCoupon.setGradeIds(reqCouponDto.getGradeIds()); + + if (reqCouponDto.getSendNum() == null) { + reqCouponDto.setSendNum(1); + } + + if (mtCoupon.getType().equals(CouponTypeEnum.PRESTORE.getKey())) { + mtCoupon.setSendWay(SendWayEnum.FRONT.getKey()); + } else { + mtCoupon.setSendWay(reqCouponDto.getSendWay()); + } + + mtCoupon.setSendNum(reqCouponDto.getSendNum()); + + if (reqCouponDto.getTotal() == null) { + reqCouponDto.setTotal(0); + } + mtCoupon.setTotal(reqCouponDto.getTotal()); + + if (reqCouponDto.getExpireType().equals(CouponExpireTypeEnum.FIX.getKey())) { + mtCoupon.setBeginTime(DateUtil.parseDate(reqCouponDto.getBeginTime())); + mtCoupon.setEndTime(DateUtil.parseDate(reqCouponDto.getEndTime())); + } + if (reqCouponDto.getExpireType().equals(CouponExpireTypeEnum.FLEX.getKey())) { + if (reqCouponDto.getExpireTime() == null || reqCouponDto.getExpireTime() < 0) { + throw new BusinessCheckException("请输入正确的有效天数"); + } + mtCoupon.setExpireTime(reqCouponDto.getExpireTime()); + } + mtCoupon.setExpireType(reqCouponDto.getExpireType()); + mtCoupon.setExceptTime(CommonUtil.replaceXSS(reqCouponDto.getExceptTime())); + mtCoupon.setDescription(CommonUtil.replaceXSS(reqCouponDto.getDescription())); + mtCoupon.setRemarks(CommonUtil.replaceXSS(reqCouponDto.getRemarks())); + mtCoupon.setInRule(CommonUtil.replaceXSS(reqCouponDto.getInRule())); + mtCoupon.setOutRule(CommonUtil.replaceXSS(reqCouponDto.getOutRule())); + mtCoupon.setApplyGoods(reqCouponDto.getApplyGoods()); + mtCoupon.setUseFor(reqCouponDto.getUseFor()); + + if (null == reqCouponDto.getAmount()) { + reqCouponDto.setAmount(new BigDecimal(0)); + } + mtCoupon.setAmount(reqCouponDto.getAmount()); + String image = reqCouponDto.getImage(); + if (null == image || image.equals("")) { + image = ""; + } + + mtCoupon.setImage(image); + mtCoupon.setRemarks(CommonUtil.replaceXSS(reqCouponDto.getRemarks())); + + if (reqCouponDto.getStatus() == null || StringUtil.isEmpty(reqCouponDto.getStatus())) { + mtCoupon.setStatus(StatusEnum.ENABLED.getKey()); + } else { + mtCoupon.setStatus(reqCouponDto.getStatus()); + } + + // 创建时间 + if (reqCouponDto.getId() == null) { + mtCoupon.setCreateTime(new Date()); + } + + // 更新时间 + mtCoupon.setUpdateTime(new Date()); + + // 操作人 + mtCoupon.setOperator(reqCouponDto.getOperator()); + + if (mtCoupon.getId() == null) { + this.save(mtCoupon); + } else { + mtCouponMapper.updateById(mtCoupon); + } + + MtCoupon couponInfo = mtCouponMapper.selectById(mtCoupon.getId()); + + // 更新已下发的会员卡券有效期 + if (couponInfo.getId() != null && reqCouponDto.getEndTime() != null && StringUtil.isNotEmpty(reqCouponDto.getEndTime())) { + mtUserCouponMapper.updateExpireTime(couponInfo.getId(), reqCouponDto.getEndTime()); + } + + // 适用商品 + if (reqCouponDto.getGoodsIds() != null) { + String[] goodsIds = reqCouponDto.getGoodsIds().split(","); + if (goodsIds.length > 0) { + // 1.先删除 + List couponGoodsList = mtCouponGoodsMapper.getCouponGoods(couponInfo.getId()); + for (MtCouponGoods cg : couponGoodsList) { + mtCouponGoodsMapper.deleteById(cg.getId()); + } + // 2.再添加 + for (int n = 0; n < goodsIds.length; n++) { + if (StringUtil.isNotEmpty(goodsIds[n])) { + MtCouponGoods mtCouponGoods = new MtCouponGoods(); + mtCouponGoods.setCouponId(couponInfo.getId()); + mtCouponGoods.setGoodsId(Integer.parseInt(goodsIds[n])); + mtCouponGoods.setStatus(StatusEnum.ENABLED.getKey()); + mtCouponGoods.setCreateTime(new Date()); + mtCouponGoods.setUpdateTime(new Date()); + mtCouponGoodsMapper.insert(mtCouponGoods); + } + } + } + } + + // 如果是优惠券,并且是线下发放,生成会员卡券 + if (reqCouponDto.getId() == null && mtCoupon.getType().equals(CouponTypeEnum.COUPON.getKey()) && mtCoupon.getSendWay().equals(SendWayEnum.OFFLINE.getKey())) { + Integer total = mtCoupon.getTotal() * mtCoupon.getSendNum(); + if (total > 0) { + String uuid = UUID.randomUUID().toString().replaceAll("-", ""); + + for (int i = 1; i <= total; i++) { + MtUserCoupon userCoupon = new MtUserCoupon(); + userCoupon.setMerchantId(mtCoupon.getMerchantId()); + userCoupon.setStoreId(mtCoupon.getStoreId()); + userCoupon.setCouponId(couponInfo.getId()); + userCoupon.setGroupId(mtCoupon.getGroupId()); + userCoupon.setMobile(""); + userCoupon.setUserId(0); + userCoupon.setStatus(UserCouponStatusEnum.UNSEND.getKey()); + userCoupon.setCreateTime(new Date()); + userCoupon.setUpdateTime(new Date()); + userCoupon.setExpireTime(couponInfo.getEndTime()); + if (couponInfo.getExpireType().equals(CouponExpireTypeEnum.FIX.getKey())) { + userCoupon.setExpireTime(couponInfo.getEndTime()); + } + if (couponInfo.getExpireType().equals(CouponExpireTypeEnum.FLEX.getKey())) { + Date expireTime = new Date(); + Calendar c = Calendar.getInstance(); + c.setTime(expireTime); + c.add(Calendar.DATE, couponInfo.getExpireTime()); + expireTime = c.getTime(); + userCoupon.setExpireTime(expireTime); + } + userCoupon.setUuid(uuid); + userCoupon.setType(CouponTypeEnum.COUPON.getKey()); + userCoupon.setAmount(couponInfo.getAmount()); + userCoupon.setBalance(couponInfo.getAmount()); + userCoupon.setStoreId(0); + userCoupon.setOperator(reqCouponDto.getOperator()); + userCoupon.setImage(couponInfo.getImage()); + + // 12位随机数 + StringBuffer code = new StringBuffer(); + code.append(SeqUtil.getRandomNumber(4)); + code.append(SeqUtil.getRandomNumber(4)); + code.append(SeqUtil.getRandomNumber(4)); + code.append(SeqUtil.getRandomNumber(4)); + userCoupon.setCode(code.toString()); + + mtUserCouponMapper.insert(userCoupon); + } + } + } + + return mtCoupon; + } + + /** + * 根据ID获取券信息 + * + * @param id 券ID + * @return + */ + @Override + public MtCoupon queryCouponById(Integer id) { + return mtCouponMapper.selectById(id); + } + + /** + * 删除卡券 + * + * @param id 券ID + * @param operator 操作人 + * @throws BusinessCheckException + * @return + */ + @Override + @OperationServiceLog(description = "删除卡券") + @Transactional(rollbackFor = Exception.class) + public void deleteCoupon(Long id, String operator) throws BusinessCheckException { + MtCoupon couponInfo = queryCouponById(id.intValue()); + if (null == couponInfo) { + throw new BusinessCheckException("卡券不存在"); + } + couponInfo.setStatus(StatusEnum.DISABLE.getKey()); + // 修改时间 + couponInfo.setUpdateTime(new Date()); + // 操作人 + couponInfo.setOperator(operator); + mtCouponMapper.updateById(couponInfo); + } + + /** + * 获取卡券列表 + * + * @param couponListParam 查询参数 + * @return + * */ + @Override + @Transactional(rollbackFor = Exception.class) + public ResponseObject findCouponList(CouponListParam couponListParam) { + Integer pageNumber = couponListParam.getPage() == null ? Constants.PAGE_NUMBER : couponListParam.getPage(); + Integer pageSize = couponListParam.getPageSize() == null ? Constants.PAGE_SIZE : couponListParam.getPageSize(); + String status = couponListParam.getStatus() == null ? StatusEnum.ENABLED.getKey() : couponListParam.getStatus(); + String type = couponListParam.getType() == null ? "" : couponListParam.getType(); + Integer userId = couponListParam.getUserId() == null ? 0 : couponListParam.getUserId(); + Integer needPoint = couponListParam.getNeedPoint() == null ? 0 : couponListParam.getNeedPoint(); + String sendWay = couponListParam.getSendWay() == null ? "front" : couponListParam.getSendWay(); + + Page pageHelper = PageHelper.startPage(pageNumber, pageSize); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + + if (StringUtil.isNotEmpty(status)) { + lambdaQueryWrapper.eq(MtCoupon::getStatus, status); + } + if (StringUtil.isNotEmpty(sendWay)) { + lambdaQueryWrapper.eq(MtCoupon::getSendWay, sendWay); + } + if (StringUtil.isNotEmpty(type)) { + lambdaQueryWrapper.eq(MtCoupon::getType, type); + } + if (needPoint != null && needPoint > 0) { + lambdaQueryWrapper.eq(MtCoupon::getPoint, 0); + } + + lambdaQueryWrapper.orderByDesc(MtCoupon::getId); + List dataList = mtCouponMapper.selectList(lambdaQueryWrapper); + + // 处理已过期 + for (MtCoupon coupon : dataList) { + // 固定期限 + if (coupon.getExpireType().equals(CouponExpireTypeEnum.FIX.getKey()) && (coupon.getEndTime() != null) && coupon.getEndTime().before(new Date())) { + coupon.setStatus(StatusEnum.EXPIRED.getKey()); + coupon.setUpdateTime(new Date()); + mtCouponMapper.updateById(coupon); + } + // 领取后生效 + if (coupon.getExpireType().equals(CouponExpireTypeEnum.FLEX.getKey()) && (coupon.getExpireTime() != null)) { + Date expireTime = new Date(); + Calendar c = Calendar.getInstance(); + c.setTime(expireTime); + c.add(Calendar.DATE, coupon.getExpireTime()); + expireTime = c.getTime(); + if (expireTime.before(new Date())) { + coupon.setStatus(StatusEnum.EXPIRED.getKey()); + coupon.setUpdateTime(new Date()); + mtCouponMapper.updateById(coupon); + } + } + } + + List content = new ArrayList<>(); + String baseImage = settingService.getUploadBasePath(); + for (int i = 0; i < dataList.size(); i++) { + CouponDto item = new CouponDto(); + BeanUtils.copyProperties(dataList.get(i), item); + item.setIsReceive(false); + item.setImage(baseImage + item.getImage()); + + // 是否领取,且领取量大于限制数 + List statusList = Arrays.asList(UserCouponStatusEnum.UNUSED.getKey(), UserCouponStatusEnum.USED.getKey(), UserCouponStatusEnum.EXPIRE.getKey()); + List userCoupon = mtUserCouponMapper.getUserCouponListByCouponId(userId, item.getId(), statusList); + if ((userCoupon.size() >= dataList.get(i).getLimitNum()) && (dataList.get(i).getLimitNum() > 0)) { + item.setIsReceive(true); + item.setUserCouponId(userCoupon.get(0).getId()); + } + + // 领取或预存数量 + CouponNumBean numData = mtUserCouponMapper.getPeopleNumByCouponId(item.getId()); + Long num; + if (null == numData) { + num = 0l; + } else { + num = numData.getNum(); + } + item.setGotNum(num.intValue()); + + // 剩余数量 + Integer leftNum = dataList.get(i).getTotal() - item.getGotNum(); + item.setLeftNum(leftNum >= 0 ? leftNum : 0); + + String sellingPoint = ""; + + // 优惠券卖点 + if (item.getType().equals(CouponTypeEnum.COUPON.getKey())) { + if (StringUtil.isNotEmpty(item.getOutRule()) && Integer.parseInt(item.getOutRule()) > 0) { + sellingPoint = "满" + item.getOutRule() + "可用"; + } else { + sellingPoint = "无门槛券"; + } + } + + // 储值卡卖点 + if (item.getType().equals(CouponTypeEnum.PRESTORE.getKey())) { + if (StringUtil.isNotEmpty(item.getInRule())) { + String inRuleArr[] = item.getInRule().split(","); + if (inRuleArr.length > 0) { + for (int n = 0; n < inRuleArr.length; n++) { + String store[] = inRuleArr[n].split("_"); + sellingPoint = "预存" + store[0] + "到账" + store[1]; + } + } + } + } + + // 计次卡卖点 + if (item.getType().equals(CouponTypeEnum.TIMER.getKey()) && StringUtil.isNotEmpty(item.getOutRule())) { + sellingPoint = "集满" + item.getOutRule() + "次即可"; + } + + item.setSellingPoint(sellingPoint); + content.add(item); + } + + PageRequest pageRequest = PageRequest.of(pageNumber, pageSize); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, CouponDto.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(content); + + return new ResponseObject(200, "查询成功", paginationResponse); + } + + /** + * 根据分组ID获取卡券列表 + * + * @param groupId 查询参数 + * @return + * */ + public List queryCouponListByGroupId(Integer groupId) { + List couponList = mtCouponMapper.queryByGroupId(groupId.intValue()); + return couponList; + } + + /** + * 发放卡券 + * + * @param couponId 卡券ID + * @param userId 会员ID + * @param num 发放套数 + * @param sendMessage 是否发送消息 + * @param uuid 批次号 + * @param operator 操作人 + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "发放卡券") + public void sendCoupon(Integer couponId, Integer userId, Integer num, Boolean sendMessage, String uuid, String operator) throws BusinessCheckException { + MtCoupon couponInfo = queryCouponById(couponId); + MtUser userInfo = memberService.queryMemberById(userId); + + if (null == userInfo || !userInfo.getStatus().equals(StatusEnum.ENABLED.getKey())) { + throw new BusinessCheckException("该会员不存在或已禁用,请先注册会员"); + } + + String mobile = StringUtil.isNotEmpty(userInfo.getMobile()) ? userInfo.getMobile() : ""; + + // 判断券是否有效 + if (!couponInfo.getStatus().equals(StatusEnum.ENABLED.getKey())) { + throw new BusinessCheckException("卡券“"+couponInfo.getName()+"”已停用,不能发放"); + } + + // 发放的是储值卡 + if (couponInfo.getType().equals(CouponTypeEnum.PRESTORE.getKey())) { + if (StringUtil.isNotEmpty(couponInfo.getInRule())) { + String storeParams = ""; + String[] paramArr = couponInfo.getInRule().split(","); + for (int i = 0; i < paramArr.length; i++) { + if (StringUtil.isNotEmpty(storeParams)) { + storeParams = storeParams + "," + paramArr[i] + "_" + num; + } else { + storeParams = paramArr[i] + "_" + num; + } + } + Map param = new HashMap<>(); + param.put("couponId", couponInfo.getId()); + param.put("userId", userInfo.getId()); + param.put("param", storeParams); + param.put("orderId", 0); + userCouponService.preStore(param); + } + return; + } + + // 优惠券或计次卡,发放num套 + for (int k = 1; k <= num; k++) { + for (int j = 1; j <= couponInfo.getSendNum(); j++) { + MtUserCoupon userCoupon = new MtUserCoupon(); + userCoupon.setCouponId(couponInfo.getId()); + userCoupon.setType(couponInfo.getType()); + userCoupon.setImage(couponInfo.getImage()); + userCoupon.setMerchantId(couponInfo.getMerchantId()); + userCoupon.setStoreId(userInfo.getStoreId()); + userCoupon.setAmount(couponInfo.getAmount()); + userCoupon.setBalance(couponInfo.getAmount()); + userCoupon.setOperator(operator); + userCoupon.setGroupId(couponInfo.getGroupId()); + userCoupon.setMobile(mobile); + userCoupon.setUserId(userInfo.getId()); + userCoupon.setStatus(UserCouponStatusEnum.UNUSED.getKey()); + userCoupon.setCreateTime(new Date()); + userCoupon.setUpdateTime(new Date()); + if (couponInfo.getExpireType().equals(CouponExpireTypeEnum.FIX.getKey())) { + userCoupon.setExpireTime(couponInfo.getEndTime()); + } + if (couponInfo.getExpireType().equals(CouponExpireTypeEnum.FLEX.getKey())) { + Date expireTime = new Date(); + Calendar c = Calendar.getInstance(); + c.setTime(expireTime); + c.add(Calendar.DATE, couponInfo.getExpireTime()); + expireTime = c.getTime(); + userCoupon.setExpireTime(expireTime); + } + // 12位随机数 + StringBuffer code = new StringBuffer(); + code.append(SeqUtil.getRandomNumber(4)); + code.append(SeqUtil.getRandomNumber(4)); + code.append(SeqUtil.getRandomNumber(4)); + code.append(SeqUtil.getRandomNumber(4)); + userCoupon.setCode(code.toString()); + userCoupon.setUuid(uuid); + mtUserCouponMapper.insert(userCoupon); + } + } + + // 发放记录 + MtCouponGroup mtCouponGroup = couponGroupService.queryCouponGroupById(couponInfo.getGroupId()); + ReqSendLogDto sendLogDto = new ReqSendLogDto(); + sendLogDto.setMerchantId(couponInfo.getMerchantId()); + sendLogDto.setType(1); + sendLogDto.setMobile(mobile); + sendLogDto.setUserId(userInfo.getId()); + sendLogDto.setFileName(""); + sendLogDto.setGroupId(couponInfo.getGroupId()); + sendLogDto.setGroupName(mtCouponGroup.getName()); + sendLogDto.setCouponId(couponInfo.getId()); + sendLogDto.setSendNum(num); + sendLogDto.setOperator(operator); + sendLogDto.setUuid(uuid); + sendLogDto.setMerchantId(couponInfo.getMerchantId()); + sendLogDto.setStoreId(couponInfo.getStoreId()); + sendLogService.addSendLog(sendLogDto); + + // if (sendMessage) { +// try { +// // 发送手机短信 +// if (StringUtil.isNotEmpty(mobile)) { +// List mobileList = new ArrayList<>(); +// mobileList.add(mobile); +// Integer totalNum = 0; +// BigDecimal totalMoney = new BigDecimal("0.0"); +// List couponList = queryCouponListByGroupId(couponInfo.getGroupId()); +// for (MtCoupon coupon : couponList) { +// totalNum = totalNum + (coupon.getSendNum() * num); +// totalMoney = totalMoney.add((coupon.getAmount().multiply(new BigDecimal(num).multiply(new BigDecimal(coupon.getSendNum()))))); +// } +// Map params = new HashMap<>(); +// params.put("totalNum", totalNum + ""); +// params.put("totalMoney", totalMoney + ""); +// sendSmsService.sendSms(couponInfo.getMerchantId(), "received-coupon", mobileList, params); +// } +// // 发送小程序订阅消息 +// if (userInfo != null && couponInfo != null && couponInfo.getAmount().compareTo(new BigDecimal("0")) > 0) { +// Date nowTime = new Date(); +// Date sendTime = new Date(nowTime.getTime()); +// Map params = new HashMap<>(); +// params.put("name", couponInfo.getName()); +// params.put("amount", couponInfo.getAmount()); +// params.put("tips", "您的卡券已到账,请查收~"); +// weixinService.sendSubscribeMessage(userInfo.getMerchantId(), userInfo.getId(), userInfo.getOpenId(), WxMessageEnum.COUPON_ARRIVAL.getKey(), "pages/user/index", params, sendTime); +// } +// } catch (Exception e) { +// // empty +// } +// } + } + + /** + * 发放卡券 + * + * @param couponId 券ID + * @param userIds 会员ID + * @param num 发放套数 + * @param uuid 批次号 + * @param operator 操作人 + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "发放卡券") + public Boolean batchSendCoupon(Integer couponId, List userIds, Integer num, String uuid, String operator) throws BusinessCheckException { + if (userIds == null || userIds.size() < 1) { + throw new BusinessCheckException("发放对象异常,卡券发放失败"); + } + // 发放人数大于10就不发送消息了 + Boolean sendMsg = userIds.size() >= 10 ? false : true; + if (userIds != null && userIds.size() > 0) { + for (Integer userId : userIds) { + sendCoupon(couponId, userId, num, sendMsg, uuid, operator); + } + } + return true; + } + + /** + * 核销卡券 + * + * @param userCouponId 用户卡券ID + * @param userId 员工会员ID + * @param storeId 店铺ID + * @param orderId 订单ID + * @param amount 核销金额 + * @param remark 核销备注 + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "核销卡券") + public String useCoupon(Integer userCouponId, Integer userId, Integer storeId, Integer orderId, BigDecimal amount, String remark) throws BusinessCheckException { + MtUserCoupon userCoupon = mtUserCouponMapper.selectById(userCouponId.intValue()); + + if (userCoupon == null) { + throw new BusinessCheckException("该卡券不存在!"); + } else if (!userCoupon.getStatus().equals(UserCouponStatusEnum.UNUSED.getKey()) && !userCoupon.getStatus().equals(UserCouponStatusEnum.UNSEND.getKey())) { + throw new BusinessCheckException("该卡券状态有误,可能已使用或已过期!"); + } + + MtStore mtStore = null; + if (storeId > 0) { + mtStore = mtStoreMapper.selectById(storeId); + if (null == mtStore) { + throw new BusinessCheckException("该店铺不存在!"); + } else if (!mtStore.getStatus().equals(StatusEnum.ENABLED.getKey())) { + throw new BusinessCheckException("该店铺状态有误,可能已禁用"); + } + } + + // 判断有效期 + MtCoupon couponInfo = queryCouponById(userCoupon.getCouponId()); + Date begin = couponInfo.getBeginTime(); + Date end = couponInfo.getEndTime(); + // 领取后有效天数 + if (couponInfo.getExpireType().equals(CouponExpireTypeEnum.FLEX.getKey())) { + begin = userCoupon.getCreateTime(); + end = userCoupon.getExpireTime(); + } + Date now = new Date(); + if (now.before(begin)) { + throw new BusinessCheckException("该卡券还没到使用日期"); + } + if (end.before(now)) { + throw new BusinessCheckException("该卡券已过期"); + } + + // 是否在例外日期 + Calendar cal = Calendar.getInstance(); + Boolean isWeekend = false; + if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { + isWeekend = true; + } + + String exceptTime = couponInfo.getExceptTime(); + if (null != exceptTime && !exceptTime.equals("")) { + String[] exceptTimeList = exceptTime.split(","); + if (exceptTimeList.length > 0) { + for (String timeStr : exceptTimeList) { + if (timeStr.equals("weekend")) { + if (isWeekend) { + throw new BusinessCheckException("该卡券在当前日期不可用"); + } + } else { + String[] timeItem = exceptTime.split("_"); + if (timeItem.length == 2) { + try { + Date startTime = DateUtil.parseDate(timeItem[0], "yyyy-MM-dd HH:mm"); + Date endTime = DateUtil.parseDate(timeItem[1], "yyyy-MM-dd HH:mm"); + if (now.before(endTime) && now.after(startTime)) { + throw new BusinessCheckException("该卡券在当前日期不可用"); + } + } catch (ParseException pe) { + throw new BusinessCheckException("该卡券在当前日期不可用."); + } + } + } + } + } + } + + if (couponInfo.getType().equals(CouponTypeEnum.COUPON.getKey())) { + // 优惠券核销直接修改状态 + userCoupon.setStatus(UserCouponStatusEnum.USED.getKey()); + } else if (couponInfo.getType().equals(CouponTypeEnum.PRESTORE.getKey())) { + // 储值卡核销,修改余额 + BigDecimal balance = userCoupon.getBalance(); + BigDecimal newBalance = balance.subtract(amount); + + if (newBalance.compareTo(new BigDecimal("0")) == -1) { + throw new BusinessCheckException("余额不足,无法核销"); + } + + if (newBalance.compareTo(new BigDecimal("0")) == 0) { + userCoupon.setStatus(UserCouponStatusEnum.USED.getKey()); + } + + userCoupon.setBalance(newBalance); + } else if (couponInfo.getType().equals(CouponTypeEnum.TIMER.getKey())) { + // 计次卡核销,增加核销次数至满 + Long confirmCount = confirmLogService.getConfirmNum(userCouponId); + if ((confirmCount.intValue() + 1) >= Integer.parseInt(couponInfo.getOutRule())) { + userCoupon.setStatus(UserCouponStatusEnum.USED.getKey()); + } + } + + userCoupon.setUpdateTime(new Date()); + userCoupon.setUsedTime(new Date()); + userCoupon.setStoreId(storeId); + mtUserCouponMapper.updateById(userCoupon); + + // 生成核销流水 + MtConfirmLog confirmLog = new MtConfirmLog(); + confirmLog.setMerchantId(couponInfo.getMerchantId()); + StringBuilder code = new StringBuilder(); + String sStoreId="00000"+storeId.toString(); + code.append(new SimpleDateFormat("yyMMddHHmmss").format(new Date())); + code.append(sStoreId.substring(sStoreId.length()-4)); + code.append(SeqUtil.getRandomNumber(6)); + confirmLog.setCode(code.toString()); + confirmLog.setCouponId(couponInfo.getId()); + confirmLog.setUserCouponId(userCouponId.intValue()); + confirmLog.setOrderId(orderId); + confirmLog.setCreateTime(new Date()); + confirmLog.setUpdateTime(new Date()); + confirmLog.setUserId(userCoupon.getUserId()); + confirmLog.setOperatorUserId(userId); + MtUser userInfo = null; + if (userId > 0) { + userInfo = memberService.queryMemberById(userId); + if (userInfo != null) { + confirmLog.setOperator(userInfo.getName()); + } + } + confirmLog.setStoreId(storeId); + confirmLog.setStatus(StatusEnum.ENABLED.getKey()); + + // 优惠券核销金额 + if (couponInfo.getType().equals(CouponTypeEnum.COUPON.getKey())) { + amount = userCoupon.getAmount(); + } + + confirmLog.setAmount(amount); + confirmLog.setRemark(remark); + mtConfirmLogMapper.insert(confirmLog); + +// try { +// // 发送核销短信 +// List mobileList = new ArrayList<>(); +// mobileList.add(userCoupon.getMobile()); +// Map params = new HashMap<>(); +// params.put("couponName", couponInfo.getName()); +// if (mtStore != null){ +// params.put("storeName", mtStore.getName()); +// } +// params.put("sn", code.toString()); +// sendSmsService.sendSms(couponInfo.getMerchantId(), "confirm-coupon", mobileList, params); +// +// // 发送小程序订阅消息 +// Date nowTime = new Date(); +// Date sendTime = new Date(nowTime.getTime()); +// Map param = new HashMap<>(); +// String dateTime = DateUtil.formatDate(Calendar.getInstance().getTime(), "yyyy-MM-dd HH:mm"); +// params.put("name", couponInfo.getName()); +// params.put("time", dateTime); +// weixinService.sendSubscribeMessage(userInfo.getMerchantId(), userInfo.getId(), userInfo.getOpenId(), WxMessageEnum.COUPON_CONFIRM.getKey(), "pages/user/index", param, sendTime); +// } catch (Exception e) { +// //empty +// } + + return confirmLog.getCode(); + } + + /** + * 根据券ID删除会员卡券 + * + * @param id 券ID + * @param operator 操作人 + * @throws BusinessCheckException + * @return + */ + @Override + @OperationServiceLog(description = "删除会员卡券") + public void deleteUserCoupon(Integer id, String operator) throws BusinessCheckException { + MtUserCoupon userCoupon = mtUserCouponMapper.selectById(id); + if (null == userCoupon) { + return; + } + + // 未使用状态才能作废删除 + if(!userCoupon.getStatus().equals(UserCouponStatusEnum.UNUSED.getKey())) { + throw new BusinessCheckException("不能作废,该劵状态异常"); + } + userCoupon.setStatus(UserCouponStatusEnum.DISABLE.getKey()); + + // 修改时间 + userCoupon.setUpdateTime(new Date()); + + // 操作人 + userCoupon.setOperator(operator); + + // 更新发券日志为部分作废状态 + mtSendLogMapper.updateSingleForRemove(userCoupon.getUuid(),UserCouponStatusEnum.USED.getKey()); + + mtUserCouponMapper.updateById(userCoupon); + } + + /** + * 根据券ID 撤销卡券核销 + * + * @param id 核销流水ID + * @param userCouponId 用户卡券ID + * @param operator 操作人 + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "撤销卡券核销") + public void rollbackUserCoupon(Integer id, Integer userCouponId,String operator) throws BusinessCheckException { + MtConfirmLog mtConfirmLog = mtConfirmLogMapper.selectById(id); + MtUserCoupon userCoupon = mtUserCouponMapper.selectById(userCouponId); + + if (null == mtConfirmLog || !mtConfirmLog.getUserCouponId().equals(userCouponId)) { + throw new BusinessCheckException("卡券核销流水不存在!"); + } + + if (null == userCoupon) { + throw new BusinessCheckException("用户卡券不存在"); + } + + // 卡券未过期才能撤销,当前时间小于过期日期才能删除,48小时 + Calendar endTimecal = Calendar.getInstance(); + endTimecal.setTime(mtConfirmLog.getCreateTime()); + endTimecal.add(Calendar.DAY_OF_MONTH, 2); + + if (endTimecal.getTime().before(new Date())) { + throw new BusinessCheckException("卡券核销已经超过48小时,无法撤销"); + } + + MtCoupon mtCoupon = mtCouponMapper.selectById(userCoupon.getCouponId()); + + // 卡券未过期才能撤销,当前时间小于过期日期才能删除 + if (mtCoupon.getEndTime().before(new Date())) { + throw new BusinessCheckException("卡券未过期才能撤销"); + } + + // 优惠券只有是使用状态且核销流水正常状态才能撤销 + if(userCoupon.getType().equals(CouponTypeEnum.COUPON.getKey())) { + if ((!userCoupon.getStatus().equals(UserCouponStatusEnum.USED.getKey())) || (!mtConfirmLog.getStatus().equals(StatusEnum.ENABLED.getKey()))) { + throw new BusinessCheckException("该劵状态异常,请稍后重试"); + } + } + + // 回退至可用状态 + userCoupon.setStatus(UserCouponStatusEnum.UNUSED.getKey()); + userCoupon.setStoreId(null); + userCoupon.setUsedTime(null); + userCoupon.setUpdateTime(new Date()); + + // 如果是储值卡则返回余额 + if (userCoupon.getType().equals(CouponTypeEnum.PRESTORE.getKey())) { + BigDecimal balance = userCoupon.getBalance(); + BigDecimal amount = mtConfirmLog.getAmount(); + if (amount.compareTo(new BigDecimal("0")) > 0) { + BigDecimal newBalance = balance.add(amount); + userCoupon.setBalance(newBalance); + } + } + + // 更新用户卡券 + mtUserCouponMapper.updateById(userCoupon); + + // 更新流水 + mtConfirmLog.setOperator(operator); + mtConfirmLog.setStatus(StatusEnum.DISABLE.getKey()); + mtConfirmLog.setUpdateTime(new Date()); + mtConfirmLog.setCancelTime(new Date()); + + mtConfirmLogMapper.updateById(mtConfirmLog); + } + + /** + * 根据ID获取用户卡券信息 + * @param userCouponId 查询参数 + * @throws BusinessCheckException + * @return + * */ + @Override + public MtUserCoupon queryUserCouponById(Integer userCouponId) { + MtUserCoupon userCoupon = mtUserCouponMapper.selectById(userCouponId); + return userCoupon; + } + + /** + * 根据批次撤销卡券 + * + * @param uuid 批次ID + * @param operator 操作人 + * @throws BusinessCheckException + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "根据批次撤销卡券") + public void removeUserCoupon(Long id, String uuid, String operator) { + Map searchParams = new HashMap<>(); + searchParams.put("uuid", uuid); + List paginationResponse = mtUserCouponMapper.selectByMap(searchParams); + + Integer total = paginationResponse.size(); + + List coupondIdList = mtUserCouponMapper.getCouponIdsByUuid(uuid); + List couponIds = new ArrayList<>(); + couponIds.add(0); + + Date nowDate = new Date(); + + for (int i = 0; i < coupondIdList.size(); i++) { + Integer couponId = coupondIdList.get(i); + MtCoupon couponInfo = queryCouponById(couponId); + if (couponInfo.getStatus().equals(StatusEnum.ENABLED.getKey()) && couponInfo.getEndTime().after(nowDate)) { + couponIds.add(couponId); + } + } + + Integer row = mtUserCouponMapper.removeUserCoupon(uuid, couponIds, operator); + if (row.compareTo( total.intValue()) != -1) { + mtSendLogMapper.updateForRemove(uuid, UserCouponStatusEnum.DISABLE.getKey(), total.intValue(), 0); + } else { + mtSendLogMapper.updateForRemove(uuid, UserCouponStatusEnum.USED.getKey(), row, (total.intValue()-row)); + } + } + + /** + * 判断卡券码是否过期 + * @param code 12位券码 + * @return + * */ + @Override + public boolean codeExpired(String code) { + if (StringUtil.isEmpty(code)) { + return true; + } + try { + Date dateTime = DateUtil.parseDate(code.substring(0, 14), "yyyyMMddHHmmss"); + + Long time = dateTime.getTime(); + Long nowTime = System.currentTimeMillis(); + + Long seconds = (nowTime - time) / 1000; + // 超过1小时 + if (seconds > 3600) { + return true; + } + } catch (Exception e) { + return true; + } + + return false; + } + + /** + * 判断卡券是否过期 + * + * @param coupon 卡券信息 + * @param userCoupon 会员卡券信息 + * @return + * */ + @Override + public boolean isCouponEffective(MtCoupon coupon, MtUserCoupon userCoupon) { + Date begin = coupon.getBeginTime(); + Date end = coupon.getEndTime(); + + if (coupon.getExpireType().equals(CouponExpireTypeEnum.FLEX.getKey())) { + begin = userCoupon.getCreateTime(); + end = userCoupon.getExpireTime(); + } + + Date now = new Date(); + + // 未生效 + if (begin != null) { + if (now.before(begin)) { + return false; + } + } + + // 已过期 + if (end != null) { + if (now.after(end)) { + return false; + } + } + + if (coupon.getStatus() == null) { + return false; + } + + // 状态异常 + if (!coupon.getStatus().equals(StatusEnum.ENABLED.getKey())) { + return false; + } + + return true; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/DutyServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/DutyServiceImpl.java new file mode 100644 index 0000000..9c74dda --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/DutyServiceImpl.java @@ -0,0 +1,305 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.enums.StatusEnum; +import com.fuint.common.service.DutyService; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.common.domain.TreeNode; +import com.fuint.framework.exception.BusinessRuntimeException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.module.backendApi.request.DutyStatusRequest; +import com.fuint.repository.mapper.TDutyMapper; +import com.fuint.repository.mapper.TDutySourceMapper; +import com.fuint.repository.model.TDuty; +import com.fuint.repository.model.TDutySource; +import com.fuint.repository.model.TSource; +import com.fuint.utils.ArrayUtil; +import com.fuint.utils.StringUtil; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; +import java.util.List; + +/** + * 角色服务实现类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class DutyServiceImpl extends ServiceImpl implements DutyService { + + private TDutyMapper tDutyMapper; + + private TDutySourceMapper tDutySourceMapper; + + /** + * 获取有效的角色集合 + * + * @param merchantId 商户ID + * @param accountId 账号ID + * @return + */ + @Override + public List getAvailableRoles(Integer merchantId, Integer accountId) { + List result = tDutyMapper.findByStatus(merchantId, StatusEnum.ENABLED.getKey()); + List ids = new ArrayList<>(); + if (result != null && result.size() > 0) { + for (TDuty tDuty : result) { + ids.add(tDuty.getDutyId().longValue()); + } + } + List roleIds = findDutiesByAccountId(accountId); + if (roleIds.size() > 0) { + for (Long roleId : roleIds) { + if (!ids.contains(roleId)) { + TDuty duty = getRoleById(roleId); + result.add(duty); + } + } + } + return result; + } + + /** + * 根据ID获取角色实体 + * + * @param roleId 角色ID + * @return + */ + @Override + public TDuty getRoleById(Long roleId) { + TDuty htDuty = tDutyMapper.selectById(roleId); + return htDuty; + } + + /** + * 根据ID数组获取角色集合 + * + * @param ids 角色ID + * @return + */ + @Override + public List findDatasByIds(String[] ids) { + Long[] arrays = new Long[ids.length]; + for (int i = 0; i < ids.length; i++) { + arrays[i] = Long.parseLong(ids[i]); + } + return tDutyMapper.findByIdIn(ArrayUtil.toList(arrays)); + } + + /** + * 删除角色 + * + * @param dutyId 角色ID + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "删除后台角色") + public void deleteDuty(Integer merchantId, long dutyId) { + TDuty tDuty = getRoleById(dutyId); + if (!merchantId.equals(tDuty.getMerchantId()) && merchantId > 0) { + throw new BusinessRuntimeException("抱歉,您没有删除的权限"); + } + tDutySourceMapper.deleteSourcesByDutyId((int) dutyId); + tDutyMapper.deleteById(dutyId); + } + + /** + * 更新角色状态 + * + * @param merchantId 商户ID + * @param dutyStatusRequest 请求参数 + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "更新后台角色状态") + public void updateStatus(Integer merchantId, DutyStatusRequest dutyStatusRequest) throws BusinessCheckException { + TDuty tDuty = tDutyMapper.selectById(dutyStatusRequest.getRoleId()); + + if (!merchantId.equals(tDuty.getMerchantId()) && merchantId > 0) { + throw new BusinessRuntimeException("抱歉,您没有操作的权限"); + } + + if (tDuty != null) { + tDuty.setStatus(dutyStatusRequest.getStatus()); + tDutyMapper.updateById(tDuty); + } else { + throw new BusinessCheckException("角色不存在."); + } + } + + /** + * 修改角色 + * + * @param tduty 角色信息 + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "更新后台角色") + public void updateDuty(TDuty tduty, List sources) throws BusinessCheckException { + TDuty existsDuty = tDutyMapper.selectById(tduty.getDutyId()); + if (existsDuty == null) { + throw new BusinessCheckException("角色不存在."); + } + if (!StringUtil.equals(tduty.getDutyName(), existsDuty.getDutyName())) { + TDuty tDuty = findByName(existsDuty.getMerchantId(), tduty.getDutyName()); + if (tDuty != null) { + throw new BusinessCheckException("角色名已存在."); + } + } + + existsDuty.setDescription(tduty.getDescription()); + existsDuty.setDutyType(tduty.getDutyType()); + existsDuty.setDutyName(tduty.getDutyName()); + existsDuty.setStatus(tduty.getStatus()); + + if (sources != null && sources.size() > 0) { + tDutySourceMapper.deleteSourcesByDutyId(tduty.getDutyId()); + for (TSource tSource : sources) { + TDutySource dutySource = new TDutySource(); + dutySource.setDutyId(tduty.getDutyId()); + dutySource.setSourceId(tSource.getSourceId()); + tDutySourceMapper.insert(dutySource); + } + } + + tDutyMapper.updateById(existsDuty); + } + + /** + * 根据角色名称合状态查询角色 + * + * @param merchantId 商户ID + * @param name 角色名称 + * @return + */ + @Override + public TDuty findByName(Integer merchantId, String name) { + return this.tDutyMapper.findByName(merchantId, name); + } + + /** + * 根据角色名称获取已经分配的菜单ID集合 + * + * @param dutyId 角色ID + * @return + */ + @Override + public List getSourceIdsByDutyId(Integer dutyId) { + return tDutySourceMapper.findSourceIdsByDutyId(dutyId); + } + + /** + * 角色保存方法 + * + * @param duty 角色信息 + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "新增后台角色") + public void saveDuty(TDuty duty, List sources) throws BusinessCheckException { + TDuty existsDuty = tDutyMapper.findByName(duty.getMerchantId(), duty.getDutyName()); + if (existsDuty != null) { + throw new BusinessCheckException("角色名称已经存在."); + } + this.tDutyMapper.insert(duty); + if (sources != null && sources.size() > 0) { + for (TSource tSource : sources) { + TDutySource dutySource = new TDutySource(); + dutySource.setDutyId(duty.getDutyId()); + dutySource.setSourceId(tSource.getSourceId()); + tDutySourceMapper.insert(dutySource); + } + } + } + + /** + * 分页查询后台角色 + * @param paginationRequest + * @return + * */ + @Override + public PaginationResponse findDutiesByPagination(PaginationRequest paginationRequest) { + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(TDuty::getStatus, StatusEnum.DISABLE.getKey()); + + String name = paginationRequest.getSearchParams().get("name") == null ? "" : paginationRequest.getSearchParams().get("name").toString(); + if (StringUtils.isNotBlank(name)) { + lambdaQueryWrapper.like(TDuty::getDutyName, name); + } + String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(TDuty::getStatus, status); + } + String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.and(wq -> wq + .eq(TDuty::getMerchantId, 0) + .or() + .eq(TDuty::getMerchantId, merchantId)); + } + + lambdaQueryWrapper.orderByDesc(TDuty::getDutyId); + List dataList = tDutyMapper.selectList(lambdaQueryWrapper); + + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, TDuty.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 获取菜单的属性结构 + * + * @param merchantId 商户ID + * @return + */ + @Override + public List getDutyTree(Integer merchantId) { + List tDuties = getAvailableRoles(merchantId, 0); + List trees = new ArrayList(); + if (tDuties != null && tDuties.size() > 0) { + TreeNode sourceTreeNode; + for (TDuty tDuty : tDuties) { + sourceTreeNode = new TreeNode(); + sourceTreeNode.setName(tDuty.getDutyName()); + sourceTreeNode.setId(tDuty.getDutyId()); + sourceTreeNode.setLevel(1); + sourceTreeNode.setPId(0); + trees.add(sourceTreeNode); + } + } + return trees; + } + + /** + * 根据账户获取角色 + * + * @param accountId 账号ID + * @return + */ + @Override + public List findDutiesByAccountId(Integer accountId) { + return tDutyMapper.getRoleIdsByAccountId(accountId); + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/GiveServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/GiveServiceImpl.java new file mode 100644 index 0000000..a50b115 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/GiveServiceImpl.java @@ -0,0 +1,324 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.dto.GiveDto; +import com.fuint.common.enums.StatusEnum; +import com.fuint.common.param.GiveParam; +import com.fuint.common.service.*; +import com.fuint.common.util.DateUtil; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.framework.web.ResponseObject; +import com.fuint.repository.mapper.MtGiveItemMapper; +import com.fuint.repository.mapper.MtGiveMapper; +import com.fuint.repository.mapper.MtUserCouponMapper; +import com.fuint.repository.model.*; +import com.fuint.utils.StringUtil; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; +import java.util.*; + +/** + * 转赠业务实现类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class GiveServiceImpl extends ServiceImpl implements GiveService { + + private MtGiveMapper mtGiveMapper; + + private MtUserCouponMapper mtUserCouponMapper; + + private MtGiveItemMapper mtGiveItemMapper; + + /** + * 会员服务接口 + * */ + private MemberService memberService; + + /** + * 会员等级服务接口 + * */ + private UserGradeService userGradeService; + + /** + * 短信发送服务接口 + * */ + private SendSmsService sendSmsService; + + /** + * 卡券服务接口 + * */ + private CouponService couponService; + + /** + * 卡券分组服务接口 + * */ + private CouponGroupService couponGroupService; + + /** + * 分页查询转赠列表 + * + * @param paginationRequest + * @return + */ + @Override + public PaginationResponse queryGiveListByPagination(PaginationRequest paginationRequest) { + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtGive::getStatus, StatusEnum.DISABLE.getKey()); + + String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtGive::getStatus, status); + } + String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(MtGive::getMerchantId, merchantId); + } + String storeId = paginationRequest.getSearchParams().get("storeId") == null ? "" : paginationRequest.getSearchParams().get("storeId").toString(); + if (StringUtils.isNotBlank(storeId)) { + lambdaQueryWrapper.eq(MtGive::getStoreId, storeId); + } + String userId = paginationRequest.getSearchParams().get("userId") == null ? "" : paginationRequest.getSearchParams().get("userId").toString(); + if (StringUtils.isNotBlank(userId)) { + lambdaQueryWrapper.eq(MtGive::getUserId, userId); + } + String giveUserId = paginationRequest.getSearchParams().get("giveUserId") == null ? "" : paginationRequest.getSearchParams().get("giveUserId").toString(); + if (StringUtils.isNotBlank(giveUserId)) { + lambdaQueryWrapper.eq(MtGive::getGiveUserId, giveUserId); + } + String couponId = paginationRequest.getSearchParams().get("couponId") == null ? "" : paginationRequest.getSearchParams().get("couponId").toString(); + if (StringUtils.isNotBlank(couponId)) { + lambdaQueryWrapper.eq(MtGive::getCouponIds, couponId); + } + String mobile = paginationRequest.getSearchParams().get("mobile") == null ? "" : paginationRequest.getSearchParams().get("mobile").toString(); + if (StringUtils.isNotBlank(mobile)) { + lambdaQueryWrapper.eq(MtGive::getMobile, mobile); + } + String userMobile = paginationRequest.getSearchParams().get("userMobile") == null ? "" : paginationRequest.getSearchParams().get("userMobile").toString(); + if (StringUtils.isNotBlank(mobile)) { + lambdaQueryWrapper.eq(MtGive::getUserMobile, userMobile); + } + + lambdaQueryWrapper.orderByDesc(MtGive::getId); + List giveList = mtGiveMapper.selectList(lambdaQueryWrapper); + List dataList = new ArrayList<>(); + for (MtGive mtGive : giveList) { + GiveDto giveDto = new GiveDto(); + BeanUtils.copyProperties(mtGive, giveDto); + giveDto.setCreateTime(DateUtil.formatDate(mtGive.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + giveDto.setUpdateTime(DateUtil.formatDate(mtGive.getUpdateTime(), "yyyy-MM-dd HH:mm:ss")); + dataList.add(giveDto); + } + + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, GiveDto.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 卡券转赠 + * + * @param giveParam + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public ResponseObject addGive(GiveParam giveParam) throws BusinessCheckException { + MtGive give = new MtGive(); + + String mobile = giveParam.getMobile() == null ? "" : giveParam.getMobile(); + String couponId = giveParam.getCouponId() == null ? "" : giveParam.getCouponId(); + String note = giveParam.getNote() == null ? "" : giveParam.getNote(); + String message = giveParam.getMessage() == null ? "" : giveParam.getMessage(); + Integer userId = giveParam.getUserId() == null ? 0 : giveParam.getUserId(); + Integer storeId = giveParam.getStoreId() == null ? 0 : giveParam.getStoreId(); + Integer merchantId = giveParam.getMerchantId() == null ? 0 : giveParam.getMerchantId(); + + if (StringUtil.isEmpty(mobile) || mobile.length() > 11 || mobile.length() < 11) { + throw new BusinessCheckException("转增对象手机号有误"); + } + + if (couponId == null) { + throw new BusinessCheckException("转增卡券不能为空"); + } + + String[] couponIds = couponId.split(","); + if (couponIds.length > 10) { + throw new BusinessCheckException("转增卡券数量不能超过10张"); + } + + // 如果赠予对象为空,则注册 + MtUser user = memberService.queryMemberByMobile(merchantId, mobile); + if (null == user) { + MtUser userInfo = new MtUser(); + userInfo.setMerchantId(merchantId); + userInfo.setName(mobile); + userInfo.setMobile(mobile); + MtUserGrade grade = userGradeService.getInitUserGrade(merchantId); + userInfo.setGradeId(grade.getId()+""); + userInfo.setBalance(new BigDecimal(0)); + userInfo.setStatus(StatusEnum.ENABLED.getKey()); + user = memberService.addMember(userInfo); + } else { + if (!user.getStatus().equals(StatusEnum.ENABLED.getKey())) { + throw new BusinessCheckException("转增对象可能已被禁用"); + } + } + + if (null == user) { + throw new BusinessCheckException("创建转增对象用户信息失败"); + } + + if (user.getId() == userId) { + throw new BusinessCheckException("转增对象不能是自己"); + } + + BigDecimal money = new BigDecimal(0); + List couponIdList = new ArrayList<>(); + List couponNames = new ArrayList<>(); + List groupIds = new ArrayList<>(); + List groupNames = new ArrayList<>(); + + for (String id : couponIds) { + MtUserCoupon userCoupon = mtUserCouponMapper.selectById(Integer.parseInt(id)); + MtCoupon coupon = couponService.queryCouponById(userCoupon.getCouponId()); + if (!couponIdList.contains(coupon.getId().toString())) { + couponIdList.add(coupon.getId().toString()); + } + if (!couponNames.contains(coupon.getName())) { + couponNames.add(coupon.getName()); + } + MtCouponGroup group = couponGroupService.queryCouponGroupById(coupon.getGroupId()); + if (!groupIds.contains(group.getId().toString())) { + groupIds.add(group.getId().toString()); + } + if (!groupNames.contains(group.getName())) { + groupNames.add(group.getName()); + } + money = money.add(userCoupon.getAmount()); + if (null == userCoupon) { + throw new BusinessCheckException("转增卡券不存在"); + } else { + if (!userCoupon.getStatus().equals(StatusEnum.ENABLED.getKey())) { + throw new BusinessCheckException("转增卡券必须是未使用状态"); + } + if (!userCoupon.getUserId().toString().equals(userId.toString())) { + throw new BusinessCheckException("您的券可能已经转赠出去了"); + } + } + } + + MtUser myUser = memberService.queryMemberById(userId); + + give.setMobile(mobile); + give.setGiveUserId(userId); + give.setUserId(user.getId()); + give.setMerchantId(merchantId); + give.setStoreId(storeId); + give.setMoney(money); + give.setNum(couponIds.length); + give.setNote(note); + give.setMessage(message); + give.setUserMobile(myUser.getMobile()); + String couponIdsStr = StringUtil.join(couponIdList.toArray(), ","); + give.setGroupIds(StringUtil.join(groupIds.toArray(), ",")); + give.setGroupNames(StringUtil.join(groupNames.toArray(), ",")); + give.setCouponIds(couponIdsStr); + give.setCouponNames(StringUtil.join(couponNames.toArray(), ",")); + give.setStatus(StatusEnum.ENABLED.getKey()); + Date createTime = new Date(); + give.setCreateTime(createTime); + give.setUpdateTime(createTime); + + // 防止网络延迟,检查是否重复 + List uniqueData = mtGiveMapper.queryForUnique(give.getUserId(), give.getGiveUserId(), couponIdsStr, createTime); + if (uniqueData != null) { + if (uniqueData.size() > 0) { + throw new BusinessCheckException("当前网络延迟,不可重复操作"); + } + } + + this.save(give); + MtGive giveInfo = mtGiveMapper.selectById(give.getId()); + + for (String id : couponIds) { + MtUserCoupon userCoupon = mtUserCouponMapper.selectById(Integer.parseInt(id)); + userCoupon.setUserId(user.getId()); + userCoupon.setUpdateTime(new Date()); + userCoupon.setMobile(user.getMobile()); + mtUserCouponMapper.updateById(userCoupon); + + MtGiveItem item = new MtGiveItem(); + item.setCreateTime(new Date()); + item.setGiveId(giveInfo.getId()); + item.setStatus(StatusEnum.ENABLED.getKey()); + item.setUpdateTime(new Date()); + item.setUserCouponId(Integer.parseInt(id)); + + mtGiveItemMapper.insert(item); + } + +// try { +// List mobileList = new ArrayList<>(); +// mobileList.add(mobile); +// Map params = new HashMap<>(); +// params.put("totalNum", couponIds.length+""); +// params.put("totalMoney", money+""); +// sendSmsService.sendSms(merchantId, "received-coupon", mobileList, params); +// } catch (Exception e) { +// //empty +// } + + ResponseObject result = new ResponseObject(200, "", giveInfo); + return result; + } + + /** + * 根据ID获取转赠信息 + * + * @param id ID + * @throws BusinessCheckException + * @return + */ + @Override + public MtGive queryGiveById(Long id) { + return mtGiveMapper.selectById(id.intValue()); + } + + /** + * 根据条件搜索转赠详情 + * + * @param params 转赠查询条件 + * @return + * */ + @Override + public List queryItemByParams(Map params) { + if (params == null) { + params = new HashMap<>(); + } + List result = mtGiveItemMapper.selectByMap(params); + return result; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/GoodsServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/GoodsServiceImpl.java new file mode 100644 index 0000000..cd6cd38 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/GoodsServiceImpl.java @@ -0,0 +1,658 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.Constants; +import com.fuint.common.dto.GoodsDto; +import com.fuint.common.dto.GoodsSpecValueDto; +import com.fuint.common.dto.GoodsTopDto; +import com.fuint.common.enums.GoodsTypeEnum; +import com.fuint.common.enums.StatusEnum; +import com.fuint.common.enums.YesOrNoEnum; +import com.fuint.common.service.CateService; +import com.fuint.common.service.GoodsService; +import com.fuint.common.service.SettingService; +import com.fuint.common.service.StoreService; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.bean.GoodsBean; +import com.fuint.repository.bean.GoodsTopBean; +import com.fuint.repository.mapper.MtGoodsMapper; +import com.fuint.repository.mapper.MtGoodsSkuMapper; +import com.fuint.repository.mapper.MtGoodsSpecMapper; +import com.fuint.repository.model.*; +import com.fuint.utils.StringUtil; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; +import java.util.*; + +/** + * 商品业务实现类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class GoodsServiceImpl extends ServiceImpl implements GoodsService { + + private MtGoodsMapper mtGoodsMapper; + + private MtGoodsSpecMapper mtGoodsSpecMapper; + + private MtGoodsSkuMapper mtGoodsSkuMapper; + + /** + * 系统设置服务接口 + * */ + private SettingService settingService; + + /** + * 商品分类服务接口 + * */ + private CateService cateService; + + /** + * 店铺服务接口 + * */ + private StoreService storeService; + + /** + * 分页查询商品列表 + * + * @param paginationRequest + * @return + */ + @Override + public PaginationResponse queryGoodsListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException { + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtGoods::getStatus, StatusEnum.DISABLE.getKey()); + + String name = paginationRequest.getSearchParams().get("name") == null ? "" : paginationRequest.getSearchParams().get("name").toString(); + if (StringUtils.isNotBlank(name)) { + lambdaQueryWrapper.like(MtGoods::getName, name); + } + String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtGoods::getStatus, status); + } + String goodsNo = paginationRequest.getSearchParams().get("goodsNo") == null ? "" : paginationRequest.getSearchParams().get("goodsNo").toString(); + if (StringUtils.isNotBlank(goodsNo)) { + lambdaQueryWrapper.eq(MtGoods::getGoodsNo, goodsNo); + } + String isSingleSpec = paginationRequest.getSearchParams().get("isSingleSpec") == null ? "" : paginationRequest.getSearchParams().get("isSingleSpec").toString(); + if (StringUtils.isNotBlank(isSingleSpec)) { + lambdaQueryWrapper.eq(MtGoods::getIsSingleSpec, isSingleSpec); + } + String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(MtGoods::getMerchantId, merchantId); + } + String storeId = paginationRequest.getSearchParams().get("storeId") == null ? "" : paginationRequest.getSearchParams().get("storeId").toString(); + if (StringUtils.isNotBlank(storeId)) { + lambdaQueryWrapper.and(wq -> wq + .eq(MtGoods::getStoreId, 0) + .or() + .eq(MtGoods::getStoreId, storeId)); + } + String type = paginationRequest.getSearchParams().get("type") == null ? "" : paginationRequest.getSearchParams().get("type").toString(); + if (StringUtils.isNotBlank(type)) { + lambdaQueryWrapper.eq(MtGoods::getType, type); + } + String cateId = paginationRequest.getSearchParams().get("cateId") == null ? "" : paginationRequest.getSearchParams().get("cateId").toString(); + if (StringUtils.isNotBlank(cateId)) { + lambdaQueryWrapper.eq(MtGoods::getCateId, cateId); + } + String hasStock = paginationRequest.getSearchParams().get("stock") == null ? "" : paginationRequest.getSearchParams().get("stock").toString(); + if (StringUtils.isNotBlank(hasStock)) { + if (hasStock.equals(YesOrNoEnum.YES.getKey())) { + lambdaQueryWrapper.gt(MtGoods::getStock, 0); + } else { + lambdaQueryWrapper.lt(MtGoods::getStock, 1); + } + } + lambdaQueryWrapper.orderByAsc(MtGoods::getSort); + List goodsList = mtGoodsMapper.selectList(lambdaQueryWrapper); + List dataList = new ArrayList<>(); + String basePath = settingService.getUploadBasePath(); + for (MtGoods mtGoods : goodsList) { + MtGoodsCate cateInfo = null; + if (mtGoods.getCateId() != null) { + cateInfo = cateService.queryCateById(mtGoods.getCateId()); + } + GoodsDto item = new GoodsDto(); + item.setId(mtGoods.getId()); + item.setInitSale(mtGoods.getInitSale()); + if (StringUtil.isNotEmpty(mtGoods.getLogo())) { + item.setLogo(basePath + mtGoods.getLogo()); + } + item.setStoreId(mtGoods.getStoreId()); + if (mtGoods.getStoreId() != null) { + MtStore storeInfo = storeService.queryStoreById(mtGoods.getStoreId()); + item.setStoreInfo(storeInfo); + } + item.setName(mtGoods.getName()); + item.setGoodsNo(mtGoods.getGoodsNo()); + item.setCateId(mtGoods.getCateId()); + item.setStock(mtGoods.getStock()); + item.setCateInfo(cateInfo); + item.setType(mtGoods.getType()); + item.setPrice(mtGoods.getPrice()); + item.setLinePrice(mtGoods.getLinePrice()); + item.setSalePoint(mtGoods.getSalePoint()); + item.setDescription(mtGoods.getDescription()); + item.setCreateTime(mtGoods.getCreateTime()); + item.setUpdateTime(mtGoods.getUpdateTime()); + item.setStatus(mtGoods.getStatus()); + item.setOperator(mtGoods.getOperator()); + dataList.add(item); + } + + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, GoodsDto.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 保存商品信息 + * + * @param reqDto 商品参数 + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "保存商品信息") + public MtGoods saveGoods(MtGoods reqDto) throws BusinessCheckException { + MtGoods mtGoods = new MtGoods(); + if (reqDto.getId() > 0) { + mtGoods = queryGoodsById(reqDto.getId()); + reqDto.setMerchantId(mtGoods.getMerchantId()); + } + if (reqDto.getMerchantId() != null) { + mtGoods.setMerchantId(reqDto.getMerchantId() >= 0 ? reqDto.getMerchantId() : 0); + } + if (reqDto.getStoreId() != null) { + mtGoods.setStoreId(reqDto.getStoreId() >= 0 ? reqDto.getStoreId() : 0); + } + Integer storeId = reqDto.getStoreId() == null ? 0 : reqDto.getStoreId(); + if (reqDto.getMerchantId() == null || reqDto.getMerchantId() <= 0) { + MtStore mtStore = storeService.queryStoreById(storeId); + if (mtStore != null) { + mtGoods.setMerchantId(mtStore.getMerchantId()); + } + } + if (StringUtil.isNotEmpty(reqDto.getIsSingleSpec())) { + mtGoods.setIsSingleSpec(reqDto.getIsSingleSpec()); + } + if (reqDto.getId() <= 0 && StringUtil.isEmpty(reqDto.getIsSingleSpec())) { + mtGoods.setIsSingleSpec(YesOrNoEnum.YES.getKey()); + } + if (StringUtil.isNotEmpty(reqDto.getName())) { + mtGoods.setName(reqDto.getName()); + } + if (StringUtil.isNotEmpty(reqDto.getStatus())) { + mtGoods.setStatus(reqDto.getStatus()); + } + if (StringUtil.isNotEmpty(reqDto.getLogo())) { + mtGoods.setLogo(reqDto.getLogo()); + } + if (StringUtil.isNotEmpty(reqDto.getIsSingleSpec())) { + mtGoods.setIsSingleSpec(reqDto.getIsSingleSpec()); + } + if (StringUtil.isNotEmpty(reqDto.getDescription())) { + mtGoods.setDescription(reqDto.getDescription()); + } + if (StringUtil.isNotEmpty(reqDto.getOperator())) { + mtGoods.setOperator(reqDto.getOperator()); + } + if (StringUtil.isNotEmpty(reqDto.getType())) { + mtGoods.setType(reqDto.getType()); + } + if (reqDto.getCateId() != null && reqDto.getCateId() > 0) { + mtGoods.setCateId(reqDto.getCateId()); + } + if (reqDto.getServiceTime() != null && reqDto.getServiceTime() > 0) { + mtGoods.setServiceTime(reqDto.getServiceTime()); + } + if (StringUtil.isNotEmpty(reqDto.getGoodsNo())) { + mtGoods.setGoodsNo(reqDto.getGoodsNo()); + } + if (reqDto.getSort() != null) { + mtGoods.setSort(reqDto.getSort()); + } + if (reqDto.getId() == null && (mtGoods.getSort().equals("") || mtGoods.getSort() == null )) { + mtGoods.setSort(0); + } + if (reqDto.getPrice() != null) { + mtGoods.setPrice(reqDto.getPrice()); + } + if (reqDto.getPrice() == null && reqDto.getId() <= 0) { + mtGoods.setPrice(new BigDecimal("0.00")); + } + if (reqDto.getLinePrice() != null) { + mtGoods.setLinePrice(reqDto.getLinePrice()); + } + if (reqDto.getLinePrice() == null && reqDto.getId() <= 0) { + mtGoods.setLinePrice(new BigDecimal("0.00")); + } + if (StringUtil.isNotEmpty(reqDto.getCouponIds())) { + mtGoods.setCouponIds(reqDto.getCouponIds()); + } + if (reqDto.getWeight() != null) { + mtGoods.setWeight(reqDto.getWeight()); + } + if (reqDto.getInitSale() != null) { + mtGoods.setInitSale(reqDto.getInitSale()); + } + if (reqDto.getStock() != null) { + mtGoods.setStock(reqDto.getStock()); + } + if (StringUtil.isNotEmpty(reqDto.getSalePoint())) { + mtGoods.setSalePoint(reqDto.getSalePoint()); + } + if (StringUtil.isEmpty(reqDto.getSalePoint()) && reqDto.getId() <= 0) { + reqDto.setSalePoint(""); + } + if (StringUtil.isNotEmpty(reqDto.getCanUsePoint())) { + mtGoods.setCanUsePoint(reqDto.getCanUsePoint()); + } + if (StringUtil.isNotEmpty(reqDto.getIsMemberDiscount())) { + mtGoods.setIsMemberDiscount(reqDto.getIsMemberDiscount()); + } + if (StringUtil.isNotEmpty(reqDto.getImages())) { + mtGoods.setImages(reqDto.getImages()); + } + if (!mtGoods.getType().equals(GoodsTypeEnum.COUPON.getKey())) { + mtGoods.setCouponIds(""); + } + + mtGoods.setUpdateTime(new Date()); + if (reqDto.getId() == null || reqDto.getId() <= 0) { + mtGoods.setCreateTime(new Date()); + this.save(mtGoods); + } else { + this.updateById(mtGoods); + } + + return mtGoods; + } + + /** + * 根据ID获取商品信息 + * + * @param id 商品ID + * @throws BusinessCheckException + * @return + */ + @Override + public MtGoods queryGoodsById(Integer id) { + MtGoods mtGoods = mtGoodsMapper.selectById(id); + if (mtGoods == null) { + return null; + } + return mtGoods; + } + + /** + * 根据编码获取商品信息 + * + * @param merchantId 商户ID + * @param goodsNo 商品编码 + * @throws BusinessCheckException + * @return + */ + @Override + public MtGoods queryGoodsByGoodsNo(Integer merchantId, String goodsNo) { + return mtGoodsMapper.getByGoodsNo(merchantId, goodsNo); + } + + /** + * 根据条码获取sku信息 + * + * @param skuNo skuNo + * @throws BusinessCheckException + * */ + @Override + public MtGoodsSku getSkuInfoBySkuNo(String skuNo) { + List mtGoodsSkuList = mtGoodsSkuMapper.getBySkuNo(skuNo); + if (mtGoodsSkuList.size() > 0) { + return mtGoodsSkuList.get(0); + } + return null; + } + + /** + * 根据ID获取商品详情 + * + * @param id 商品ID + * @throws BusinessCheckException + */ + @Override + public GoodsDto getGoodsDetail(Integer id, boolean getDeleteSpec) { + if (id == null || id < 1) { + return null; + } + + MtGoods mtGoods = mtGoodsMapper.selectById(id); + GoodsDto goodsInfo = new GoodsDto(); + + if (mtGoods != null) { + try { + BeanUtils.copyProperties(mtGoods, goodsInfo); + } catch (Exception e) { + goodsInfo.setId(mtGoods.getId()); + goodsInfo.setType(mtGoods.getType()); + goodsInfo.setStoreId(mtGoods.getStoreId()); + goodsInfo.setName(mtGoods.getName()); + goodsInfo.setCateId(mtGoods.getCateId()); + goodsInfo.setGoodsNo(mtGoods.getGoodsNo()); + goodsInfo.setIsSingleSpec(mtGoods.getIsSingleSpec()); + goodsInfo.setLogo(mtGoods.getLogo()); + goodsInfo.setImages(mtGoods.getImages()); + goodsInfo.setStatus(mtGoods.getStatus()); + goodsInfo.setSort(mtGoods.getSort()); + goodsInfo.setPrice(mtGoods.getPrice()); + goodsInfo.setLinePrice(mtGoods.getLinePrice()); + goodsInfo.setServiceTime(mtGoods.getServiceTime()); + goodsInfo.setCouponIds(mtGoods.getCouponIds()); + } + } + + String basePath = settingService.getUploadBasePath(); + if (StringUtil.isNotEmpty(goodsInfo.getLogo())) { + goodsInfo.setLogo(basePath + goodsInfo.getLogo()); + } + + // 规格列表 + Map param = new HashMap<>(); + param.put("goods_id", id.toString()); + if (getDeleteSpec == false) { + param.put("status", StatusEnum.ENABLED.getKey()); + } + List goodsSpecList = mtGoodsSpecMapper.selectByMap(param); + goodsInfo.setSpecList(goodsSpecList); + + // sku列表 + if (goodsInfo.getIsSingleSpec().equals(YesOrNoEnum.NO.getKey())) { + List goodsSkuList = mtGoodsSkuMapper.selectByMap(param); + goodsInfo.setSkuList(goodsSkuList); + // 多规格商品的价格、库存数量 + if (goodsSkuList.size() > 0) { + goodsInfo.setPrice(goodsSkuList.get(0).getPrice()); + goodsInfo.setLinePrice(goodsSkuList.get(0).getLinePrice()); + Integer stock = 0; + for (MtGoodsSku mtGoodsSku : goodsSkuList) { + stock = stock + mtGoodsSku.getStock(); + } + goodsInfo.setStock(stock); + } else { + goodsInfo.setStock(0); + } + } else { + goodsInfo.setSkuList(new ArrayList<>()); + } + + return goodsInfo; + } + + /** + * 根据ID删除商品信息 + * + * @param id ID + * @param operator 操作人 + * @throws BusinessCheckException + * @return + */ + @Override + @OperationServiceLog(description = "删除商品信息") + @Transactional(rollbackFor = Exception.class) + public void deleteGoods(Integer id, String operator) throws BusinessCheckException { + MtGoods cateInfo = queryGoodsById(id); + if (null == cateInfo) { + throw new BusinessCheckException("该商品不存在"); + } + cateInfo.setStatus(StatusEnum.DISABLE.getKey()); + cateInfo.setUpdateTime(new Date()); + mtGoodsMapper.updateById(cateInfo); + } + + /** + * 获取店铺的商品列表 + * + * @param storeId 店铺ID + * @param keyword 关键字 + * @param cateId 分类ID + * @param page 当前页码 + * @param pageSize 每页页数 + * @throws BusinessCheckException + * @return + * */ + @Override + public Map getStoreGoodsList(Integer storeId, String keyword, Integer cateId, Integer page, Integer pageSize) throws BusinessCheckException { + MtStore mtStore = storeService.queryStoreById(storeId); + if (mtStore == null) { + Map result = new HashMap<>(); + result.put("goodsList", new ArrayList<>()); + result.put("total", 0); + return result; + } + Integer merchantId = mtStore.getMerchantId() == null ? 0 : mtStore.getMerchantId(); + Page pageHelper = PageHelper.startPage(page, pageSize); + List goodsList = new ArrayList<>(); + List skuList = new ArrayList<>(); + if (StringUtil.isNotEmpty(keyword)) { + skuList = mtGoodsSkuMapper.getBySkuNo(keyword); + } + if (skuList != null && skuList.size() > 0) { + MtGoods goods = mtGoodsMapper.selectById(skuList.get(0).getGoodsId()); + goodsList.add(goods); + } else { + pageHelper = PageHelper.startPage(page, pageSize); + if (keyword != null && StringUtil.isNotEmpty(keyword)) { + goodsList = mtGoodsMapper.searchStoreGoodsList(merchantId, storeId, keyword); + } else { + goodsList = mtGoodsMapper.getStoreGoodsList(merchantId, storeId, cateId); + } + } + List dataList = new ArrayList<>(); + if (goodsList.size() > 0) { + for (MtGoods mtGoods : goodsList) { + // 多规格商品价格、库存数量 + if (mtGoods.getIsSingleSpec().equals(YesOrNoEnum.NO.getKey())) { + Map param = new HashMap<>(); + param.put("goods_id", mtGoods.getId().toString()); + param.put("status", StatusEnum.ENABLED.getKey()); + List goodsSkuList = mtGoodsSkuMapper.selectByMap(param); + if (goodsSkuList.size() > 0) { + mtGoods.setPrice(goodsSkuList.get(0).getPrice()); + mtGoods.setLinePrice(goodsSkuList.get(0).getLinePrice()); + Integer stock = 0; + for (MtGoodsSku mtGoodsSku : goodsSkuList) { + stock = stock + mtGoodsSku.getStock(); + } + mtGoods.setStock(stock); + } else { + mtGoods.setStock(0); + } + } + dataList.add(mtGoods); + } + } + + Map data = new HashMap<>(); + data.put("goodsList", dataList); + data.put("total", pageHelper.getTotal()); + + return data; + } + + /** + * 通过SKU获取规格列表 + * + * @param skuId skuID + * @return + * */ + @Override + public List getSpecListBySkuId(Integer skuId) { + if (skuId < 0 || skuId == null) { + return new ArrayList<>(); + } + List result = new ArrayList<>(); + + MtGoodsSku goodsSku = mtGoodsSkuMapper.selectById(skuId); + if (goodsSku == null) { + return result; + } + + String specIds = goodsSku.getSpecIds(); + String specIdArr[] = specIds.split("-"); + for (String specId : specIdArr) { + MtGoodsSpec mtGoodsSpec = mtGoodsSpecMapper.selectById(Integer.parseInt(specId)); + GoodsSpecValueDto dto = new GoodsSpecValueDto(); + dto.setSpecValueId(mtGoodsSpec.getId()); + dto.setSpecName(mtGoodsSpec.getName()); + dto.setSpecValue(mtGoodsSpec.getValue()); + result.add(dto); + } + + return result; + } + + /** + * 获取商品规格详情 + * + * @param specId 规格ID + * @return + * */ + @Override + public MtGoodsSpec getSpecDetail(Integer specId) { + MtGoodsSpec mtGoodsSpec = mtGoodsSpecMapper.selectById(specId); + return mtGoodsSpec; + } + + /** + * 更新已售数量 + * + * @param goodsId 商品ID + * @return + * */ + @Override + @Transactional(rollbackFor = Exception.class) + public Boolean updateInitSale(Integer goodsId) { + return mtGoodsMapper.updateInitSale(goodsId); + } + + /** + * 获取选择商品列表 + * + * @param params 查询参数 + * @return + */ + @Override + public PaginationResponse selectGoodsList(Map params) throws BusinessCheckException { + Integer page = params.get("page") == null ? Constants.PAGE_NUMBER : Integer.parseInt(params.get("page").toString()); + Integer pageSize = params.get("pageSize") == null ? Constants.PAGE_SIZE : Integer.parseInt(params.get("pageSize").toString()); + Integer merchantId = (params.get("merchantId") == null || StringUtil.isEmpty(params.get("merchantId").toString())) ? 0 : Integer.parseInt(params.get("merchantId").toString()); + Integer storeId = (params.get("storeId") == null || StringUtil.isEmpty(params.get("storeId").toString())) ? 0 : Integer.parseInt(params.get("storeId").toString()); + Integer cateId = (params.get("cateId") == null || StringUtil.isEmpty(params.get("cateId").toString())) ? 0 : Integer.parseInt(params.get("cateId").toString()); + String keyword = params.get("keyword") == null ? "" : params.get("keyword").toString(); + + MtStore mtStore = storeService.queryStoreById(storeId); + if (mtStore != null && mtStore.getMerchantId() != null) { + merchantId = mtStore.getMerchantId(); + } + Page pageHelper = PageHelper.startPage(page, pageSize); + List dataList = new ArrayList<>(); + + List goodsList = mtGoodsMapper.selectGoodsList(merchantId, storeId, cateId, keyword); + + for (GoodsBean goodsBean : goodsList) { + GoodsDto goodsDto = new GoodsDto(); + goodsDto.setId(goodsBean.getGoodsId()); + goodsDto.setLogo(goodsBean.getLogo()); + goodsDto.setName(goodsBean.getName()); + goodsDto.setGoodsNo(goodsBean.getGoodsNo()); + goodsDto.setStoreId(goodsBean.getStoreId()); + goodsDto.setPrice(goodsBean.getPrice()); + goodsDto.setCateId(goodsBean.getCateId()); + goodsDto.setStock(goodsBean.getStock()); + if (goodsBean.getSpecIds() != null) { + Map param = new HashMap<>(); + param.put("GOODS_ID", goodsBean.getGoodsId()); + param.put("SPEC_IDS", goodsBean.getSpecIds()); + param.put("STATUS", StatusEnum.ENABLED.getKey()); + List goodsSkuList = mtGoodsSkuMapper.selectByMap(param); + if (goodsSkuList != null && goodsSkuList.size() > 0) { + goodsDto.setSkuId(goodsSkuList.get(0).getId()); + goodsDto.setPrice(goodsSkuList.get(0).getPrice()); + if (goodsSkuList.get(0).getLogo() != null && StringUtil.isNotEmpty(goodsSkuList.get(0).getLogo())) { + goodsDto.setLogo(goodsSkuList.get(0).getLogo()); + } + goodsDto.setStock(goodsSkuList.get(0).getStock()); + List specList = new ArrayList<>(); + String[] specIds = goodsBean.getSpecIds().split("-"); + if (specIds.length > 0) { + for (String specId : specIds) { + MtGoodsSpec mtGoodsSpec = mtGoodsSpecMapper.selectById(Integer.parseInt(specId)); + if (mtGoodsSpec != null) { + specList.add(mtGoodsSpec); + } + } + } + goodsDto.setSpecList(specList); + } + } + dataList.add(goodsDto); + } + + PageRequest pageRequest = PageRequest.of(page, pageSize); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, GoodsDto.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 获取商品销售排行榜 + * + * @param merchantId 商户ID + * @param storeId 店铺ID + * @param startTime 开始时间 + * @param endTime 结束时间 + * @return + * */ + @Override + public List getGoodsSaleTopList(Integer merchantId, Integer storeId, Date startTime, Date endTime) { + List dataList = mtGoodsMapper.getGoodsSaleTopList(merchantId, storeId, startTime, endTime); + List goodsList = new ArrayList<>(); + if (dataList != null && dataList.size() > 0) { + for (GoodsTopBean bean : dataList) { + GoodsTopDto dto = new GoodsTopDto(); + BeanUtils.copyProperties(bean, dto); + goodsList.add(dto); + } + } + return goodsList; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/MemberGroupServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/MemberGroupServiceImpl.java new file mode 100644 index 0000000..f100cab --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/MemberGroupServiceImpl.java @@ -0,0 +1,264 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.dto.MemberGroupDto; +import com.fuint.common.dto.UserGroupDto; +import com.fuint.common.enums.StatusEnum; +import com.fuint.common.service.*; +import com.fuint.common.util.CommonUtil; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.mapper.MtUserGroupMapper; +import com.fuint.repository.model.*; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.lang.String; +import java.util.*; + +/** + * 会员分组业务实现类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class MemberGroupServiceImpl extends ServiceImpl implements MemberGroupService { + + private static final Logger logger = LoggerFactory.getLogger(CouponGroupServiceImpl.class); + + private MtUserGroupMapper mtUserGroupMapper; + + /** + * 店铺接口 + */ + private StoreService storeService; + + /** + * 分页查询会员分组列表 + * + * @param paginationRequest + * @return + */ + @Override + public PaginationResponse queryMemberGroupListByPagination(PaginationRequest paginationRequest) { + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtUserGroup::getStatus, StatusEnum.DISABLE.getKey()); + lambdaQueryWrapper.eq(MtUserGroup::getParentId, 0); + String name = paginationRequest.getSearchParams().get("name") == null ? "" : paginationRequest.getSearchParams().get("name").toString(); + if (StringUtils.isNotBlank(name)) { + lambdaQueryWrapper.like(MtUserGroup::getName, name); + } + String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtUserGroup::getStatus, status); + } + String id = paginationRequest.getSearchParams().get("id") == null ? "" : paginationRequest.getSearchParams().get("id").toString(); + if (StringUtils.isNotBlank(id)) { + lambdaQueryWrapper.eq(MtUserGroup::getId, id); + } + String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(MtUserGroup::getMerchantId, merchantId); + } + String storeId = paginationRequest.getSearchParams().get("storeId") == null ? "" : paginationRequest.getSearchParams().get("storeId").toString(); + if (StringUtils.isNotBlank(storeId)) { + lambdaQueryWrapper.eq(MtUserGroup::getStoreId, storeId); + } + + lambdaQueryWrapper.orderByDesc(MtUserGroup::getId); + List dataList = mtUserGroupMapper.selectList(lambdaQueryWrapper); + List userGroupList = new ArrayList<>(); + if (dataList != null && dataList.size() > 0) { + for (MtUserGroup mtUserGroup : dataList) { + UserGroupDto userGroupDto = new UserGroupDto(); + BeanUtils.copyProperties(mtUserGroup, userGroupDto); + userGroupDto.setChildren(getChildren(mtUserGroup.getId())); + userGroupDto.setMemberNum(getMemberNum(mtUserGroup.getId())); + userGroupList.add(userGroupDto); + } + } + + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, UserGroupDto.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(userGroupList); + + return paginationResponse; + } + + /** + * 添加会员分组 + * + * @param memberGroupDto 会员分组 + * @throws BusinessCheckException + * @return + */ + @Override + @OperationServiceLog(description = "新增会员分组") + public MtUserGroup addMemberGroup(MemberGroupDto memberGroupDto) throws BusinessCheckException { + MtUserGroup userGroup = new MtUserGroup(); + Integer storeId = memberGroupDto.getStoreId() == null ? 0 : memberGroupDto.getStoreId(); + if (memberGroupDto.getMerchantId() == null || memberGroupDto.getMerchantId() <= 0) { + MtStore mtStore = storeService.queryStoreById(storeId); + if (mtStore != null) { + memberGroupDto.setMerchantId(mtStore.getMerchantId()); + } + } + userGroup.setMerchantId(memberGroupDto.getMerchantId()); + userGroup.setStoreId(storeId); + userGroup.setParentId(memberGroupDto.getParentId()); + userGroup.setName(CommonUtil.replaceXSS(memberGroupDto.getName())); + userGroup.setDescription(CommonUtil.replaceXSS(memberGroupDto.getDescription())); + userGroup.setStatus(StatusEnum.ENABLED.getKey()); + userGroup.setCreateTime(new Date()); + userGroup.setUpdateTime(new Date()); + userGroup.setOperator(memberGroupDto.getOperator()); + this.save(userGroup); + return userGroup; + } + + /** + * 根据分组ID获取分组信息 + * + * @param id 分组ID + * @throws BusinessCheckException + * @return + */ + @Override + public MtUserGroup queryMemberGroupById(Integer id) { + return mtUserGroupMapper.selectById(id); + } + + /** + * 根据ID删除会员分组 + * + * @param id 分组ID + * @param operator 操作人 + * @throws BusinessCheckException + * @return + */ + @Override + @OperationServiceLog(description = "删除会员分组") + public void deleteMemberGroup(Integer id, String operator) { + MtUserGroup userGroup = queryMemberGroupById(id); + if (null == userGroup) { + return; + } + + userGroup.setStatus(StatusEnum.DISABLE.getKey()); + userGroup.setUpdateTime(new Date()); + userGroup.setOperator(operator); + + this.updateById(userGroup); + } + + /** + * 修改会员分组 + * + * @param memberGroupDto + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "更新会员分组") + public MtUserGroup updateMemberGroup(MemberGroupDto memberGroupDto) throws BusinessCheckException { + MtUserGroup userGroup = queryMemberGroupById(memberGroupDto.getId()); + if (null == userGroup || StatusEnum.DISABLE.getKey().equalsIgnoreCase(userGroup.getStatus())) { + logger.error("该分组不存在或已被删除"); + throw new BusinessCheckException("该分组不存在或已被删除"); + } + if (memberGroupDto.getName() != null) { + userGroup.setName(CommonUtil.replaceXSS(memberGroupDto.getName())); + } + if (memberGroupDto.getDescription() != null) { + userGroup.setDescription(CommonUtil.replaceXSS(memberGroupDto.getDescription())); + } + if (memberGroupDto.getStatus() != null) { + userGroup.setStatus(memberGroupDto.getStatus()); + } + + userGroup.setUpdateTime(new Date()); + userGroup.setOperator(memberGroupDto.getOperator()); + this.updateById(userGroup); + return userGroup; + } + + /** + * 获取会员分组子类 + * + * @param groupId 分组ID + * @return + * */ + public List getChildren(Integer groupId) { + Map param = new HashMap<>(); + param.put("STATUS", StatusEnum.ENABLED.getKey()); + param.put("PARENT_ID", groupId); + List dataList = mtUserGroupMapper.selectByMap(param); + List children = new ArrayList<>(); + if (dataList != null && dataList.size() > 0) { + for (MtUserGroup userGroup : dataList) { + UserGroupDto userGroupDto = new UserGroupDto(); + BeanUtils.copyProperties(userGroup, userGroupDto); + userGroupDto.setChildren(getChildren(userGroup.getId())); + userGroupDto.setMemberNum(getMemberNum(userGroup.getId())); + children.add(userGroupDto); + } + } + return children; + } + + /** + * 获取分组会员数量 + * + * @param groupId 分组ID + * @return + * */ + public Long getMemberNum(Integer groupId) { + List groupIds = getGroupIds(groupId); + Long totalMember = mtUserGroupMapper.getMemberNum(groupIds); + return totalMember; + } + + /** + * 获取会员分组子类ID + * + * @param groupId 分组ID + * @return + * */ + public List getGroupIds(Integer groupId) { + Map param = new HashMap<>(); + param.put("STATUS", StatusEnum.ENABLED.getKey()); + param.put("PARENT_ID", groupId); + List dataList = mtUserGroupMapper.selectByMap(param); + List groupIds = new ArrayList<>(); + groupIds.add(groupId); + if (dataList != null && dataList.size() > 0) { + for (MtUserGroup userGroup : dataList) { + groupIds.add(userGroup.getId()); + List childrenIds = getGroupIds(userGroup.getId()); + if (childrenIds.size() > 0) { + groupIds.addAll(childrenIds); + } + } + } + return groupIds; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/MemberServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/MemberServiceImpl.java new file mode 100644 index 0000000..9de0e8c --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/MemberServiceImpl.java @@ -0,0 +1,976 @@ +package com.fuint.common.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.dto.AccountInfo; +import com.fuint.common.dto.GroupMemberDto; +import com.fuint.common.dto.MemberTopDto; +import com.fuint.common.dto.UserDto; +import com.fuint.common.enums.*; +import com.fuint.common.service.*; +import com.fuint.common.util.*; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.bean.MemberTopBean; +import com.fuint.repository.mapper.MtUserActionMapper; +import com.fuint.repository.mapper.MtUserGradeMapper; +import com.fuint.repository.mapper.MtUserMapper; +import com.fuint.repository.model.*; +import com.fuint.utils.StringUtil; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.context.annotation.Lazy; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; +import java.util.*; + +/** + * 会员业务接口实现类 + */ +@Service +@AllArgsConstructor(onConstructor_= {@Lazy}) +public class MemberServiceImpl extends ServiceImpl implements MemberService { + + private MtUserMapper mtUserMapper; + + private MtUserGradeMapper mtUserGradeMapper; + + private MtUserActionMapper mtUserActionMapper; + + /** + * 短信发送接口 + */ + private SendSmsService sendSmsService; + + /** + * 会员等级接口 + * */ + private UserGradeService userGradeService; + + /** + * 会员等级接口 + * */ + private OpenGiftService openGiftService; + + /** + * 后台账户服务接口 + */ + private AccountService accountService; + + /** + * 员工接口 + */ + private StaffService staffService; + + /** + * 店铺接口 + */ + private StoreService storeService; + + /** + * 会员行为接口 + */ + private UserActionService userActionService; + + /** + * 系统配置服务接口 + * */ + private SettingService settingService; + + /** + * 更新活跃时间 + * @param userId 会员ID + * @return + * */ + @Override + @Transactional(rollbackFor = Exception.class) + public Boolean updateActiveTime(Integer userId) throws BusinessCheckException { + MtUser mtUser = queryMemberById(userId); + if (mtUser != null) { + if (!mtUser.getStatus().equals(StatusEnum.ENABLED.getKey())) { + return false; + } + Date lastUpdateTime = mtUser.getUpdateTime(); + Date registerTime = mtUser.getCreateTime(); + if (lastUpdateTime != null) { + Long timestampLast = Long.valueOf(TimeUtils.date2timeStamp(lastUpdateTime)); + Long timestampNow = System.currentTimeMillis() / 1000; + Long minute = timestampNow - timestampLast; + + // 5分钟更新一次 + if (minute >= 300 || registerTime.equals(lastUpdateTime)) { + synchronized(MemberServiceImpl.class) { + Date activeTime = new Date(); + mtUserMapper.updateActiveTime(mtUser.getId(), activeTime); + // 记录会员行为 + MtUserAction mtUserAction = new MtUserAction(); + mtUserAction.setUserId(mtUser.getId()); + mtUserAction.setStoreId(mtUser.getStoreId()); + mtUserAction.setMerchantId(mtUser.getMerchantId()); + mtUserAction.setParam(TimeUtils.formatDate(activeTime, "yyyy-MM-dd HH:mm:ss")); + mtUserAction.setAction(UserActionEnum.LOGIN.getKey()); + mtUserAction.setDescription(UserActionEnum.LOGIN.getValue()); + userActionService.addUserAction(mtUserAction); + } + } + } + } + + return true; + } + + /** + * 获取当前操作会员信息 + * @param userId 会员ID + * @param token 登录token + * @return + * */ + @Override + public MtUser getCurrentUserInfo(HttpServletRequest request, Integer userId, String token) throws BusinessCheckException { + MtUser mtUser = null; + + // 没有会员信息,则查询是否是后台收银员下单 + AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token); + if (accountInfo != null) { + // 输入了会员ID就用会员的账号下单,否则用员工账号下单 + if (userId > 0) { + mtUser = queryMemberById(userId); + } else { + Integer accountId = accountInfo.getId(); + TAccount account = accountService.getAccountInfoById(accountId); + if (account != null) { + if (account.getStaffId() > 0) { + MtStaff staff = staffService.queryStaffById(account.getStaffId()); + if (staff != null) { + mtUser = queryMemberById(staff.getUserId()); + if (mtUser != null && (mtUser.getStoreId() == null || mtUser.getStoreId() <= 0)) { + mtUser.setStoreId(staff.getStoreId()); + updateById(mtUser); + } + } + } + } + } + } + return mtUser; + } + + /** + * 分页查询会员列表 + * + * @param paginationRequest + * @return + */ + @Override + public PaginationResponse queryMemberListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException { + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.ne(MtUser::getStatus, StatusEnum.DISABLE.getKey()); + + String name = paginationRequest.getSearchParams().get("name") == null ? "" : paginationRequest.getSearchParams().get("name").toString(); + if (StringUtils.isNotBlank(name)) { + wrapper.like(MtUser::getName, name); + } + String id = paginationRequest.getSearchParams().get("id") == null ? "" : paginationRequest.getSearchParams().get("id").toString(); + if (StringUtils.isNotBlank(id)) { + wrapper.eq(MtUser::getId, id); + } + String mobile = paginationRequest.getSearchParams().get("mobile") == null ? "" : paginationRequest.getSearchParams().get("mobile").toString(); + if (StringUtils.isNotBlank(mobile)) { + wrapper.like(MtUser::getMobile, mobile); + } + String birthday = paginationRequest.getSearchParams().get("birthday") == null ? "" : paginationRequest.getSearchParams().get("birthday").toString(); + if (StringUtils.isNotBlank(birthday)) { + wrapper.like(MtUser::getBirthday, birthday); + } + String userNo = paginationRequest.getSearchParams().get("userNo") == null ? "" : paginationRequest.getSearchParams().get("userNo").toString(); + if (StringUtils.isNotBlank(userNo)) { + wrapper.eq(MtUser::getUserNo, userNo); + } + String gradeId = paginationRequest.getSearchParams().get("gradeId") == null ? "" : paginationRequest.getSearchParams().get("gradeId").toString(); + if (StringUtils.isNotBlank(gradeId)) { + wrapper.eq(MtUser::getGradeId, gradeId); + } + String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + wrapper.eq(MtUser::getMerchantId, merchantId); + } + String storeId = paginationRequest.getSearchParams().get("storeId") == null ? "" : paginationRequest.getSearchParams().get("storeId").toString(); + if (StringUtils.isNotBlank(storeId)) { + wrapper.eq(MtUser::getStoreId, storeId); + } + String storeIds = paginationRequest.getSearchParams().get("storeIds") == null ? "" : paginationRequest.getSearchParams().get("storeIds").toString(); + if (StringUtils.isNotBlank(storeIds)) { + List idList = Arrays.asList(storeIds.split(",")); + if (idList.size() > 0) { + wrapper.in(MtUser::getStoreId, idList); + } + } + String groupIds = paginationRequest.getSearchParams().get("groupIds") == null ? "" : paginationRequest.getSearchParams().get("groupIds").toString(); + if (StringUtils.isNotBlank(groupIds)) { + List idList = Arrays.asList(groupIds.split(",")); + if (idList.size() > 0) { + wrapper.in(MtUser::getGroupId, idList); + } + } + String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString(); + if (StringUtils.isNotBlank(status)) { + wrapper.eq(MtUser::getStatus, status); + } + // 注册开始、结束时间 + String startTime = paginationRequest.getSearchParams().get("startTime") == null ? "" : paginationRequest.getSearchParams().get("startTime").toString(); + String endTime = paginationRequest.getSearchParams().get("endTime") == null ? "" : paginationRequest.getSearchParams().get("endTime").toString(); + if (StringUtil.isNotEmpty(startTime)) { + wrapper.ge(MtUser::getCreateTime, startTime); + } + if (StringUtil.isNotEmpty(endTime)) { + wrapper.le(MtUser::getCreateTime, endTime); + } + // 注册时间 + String regTime = paginationRequest.getSearchParams().get("regTime") == null ? "" : paginationRequest.getSearchParams().get("regTime").toString(); + if (StringUtil.isNotEmpty(regTime)) { + String[] dateTime = regTime.split("~"); + if (dateTime.length == 2) { + wrapper.ge(MtUser::getCreateTime, dateTime[0]); + wrapper.le(MtUser::getCreateTime, dateTime[1]); + } + } + // 活跃时间 + String activeTime = paginationRequest.getSearchParams().get("activeTime") == null ? "" : paginationRequest.getSearchParams().get("activeTime").toString(); + if (StringUtil.isNotEmpty(activeTime)) { + String[] dateTime = activeTime.split("~"); + if (dateTime.length == 2) { + wrapper.ge(MtUser::getUpdateTime, dateTime[0]); + wrapper.le(MtUser::getUpdateTime, dateTime[1]); + } + } + // 会员有效期 + String memberTime = paginationRequest.getSearchParams().get("memberTime") == null ? "" : paginationRequest.getSearchParams().get("memberTime").toString(); + if (StringUtil.isNotEmpty(memberTime)) { + String[] dateTime = memberTime.split("~"); + if (dateTime.length == 2) { + wrapper.ge(MtUser::getStartTime, dateTime[0]); + wrapper.le(MtUser::getEndTime, dateTime[1]); + } + } + wrapper.orderByDesc(MtUser::getUpdateTime); + List userList = mtUserMapper.selectList(wrapper); + List dataList = new ArrayList<>(); + for (MtUser mtUser : userList) { + String phone = mtUser.getMobile(); + UserDto userDto = new UserDto(); + BeanUtils.copyProperties(mtUser, userDto); + + if (phone != null && StringUtil.isNotEmpty(phone) && phone.length() == 11) { +// userDto.setMobile(phone.substring(0, 3) + "****" + phone.substring(7)); + userDto.setMobile(phone); + } + if (userDto.getStoreId() != null && userDto.getStoreId() > 0) { + MtStore mtStore = storeService.queryStoreById(userDto.getStoreId()); + if (mtStore != null) { + userDto.setStoreName(mtStore.getName()); + } + } + if (userDto.getGradeId() != null) { + Integer mchId = StringUtil.isNotEmpty(merchantId) ? Integer.parseInt(merchantId) : 0; + MtUserGrade mtGrade = userGradeService.queryUserGradeById(mchId, Integer.parseInt(userDto.getGradeId()), mtUser.getId()); + if (mtGrade != null) { + userDto.setGradeName(mtGrade.getName()); + } + } + if (mtUser.getUserNo() == null || StringUtil.isEmpty(mtUser.getUserNo())) { + mtUser.setUserNo(CommonUtil.createUserNo()); + updateById(mtUser); + } + userDto.setLastLoginTime(TimeUtil.showTime(new Date(), mtUser.getUpdateTime())); + dataList.add(userDto); + } + + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, UserDto.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 添加会员 + * + * @param mtUser 会员信息 + * @throws BusinessCheckException + * @return + */ + @Override + @OperationServiceLog(description = "新增会员信息") + public MtUser addMember(MtUser mtUser) throws BusinessCheckException { + // 手机号已存在 + if (StringUtil.isNotEmpty(mtUser.getMobile())) { + MtUser userInfo = queryMemberByMobile(mtUser.getMerchantId(), mtUser.getMobile()); + if (userInfo != null) { + return userInfo; + } + } + + String userNo = CommonUtil.createUserNo(); + if (StringUtil.isNotEmpty(mtUser.getUserNo())) { + userNo = mtUser.getUserNo(); + } + // 会员名称已存在 + List userList = mtUserMapper.queryMemberByName(mtUser.getMerchantId(), mtUser.getName()); + if (userList.size() > 0) { + mtUser.setName(userNo); + } + // 默认会员等级 + if (StringUtil.isEmpty(mtUser.getGradeId())) { + MtUserGrade grade = userGradeService.getInitUserGrade(mtUser.getMerchantId()); + if (grade != null) { + mtUser.setGradeId(grade.getId().toString()); + } + } + mtUser.setUserNo(userNo); + mtUser.setBalance(new BigDecimal(0)); + if (mtUser.getPoint() == null || mtUser.getPoint() < 1) { + mtUser.setPoint(0); + } + if (StringUtil.isEmpty(mtUser.getIdcard())) { + mtUser.setIdcard(""); + } + mtUser.setSex(mtUser.getSex()); + mtUser.setStatus(StatusEnum.ENABLED.getKey()); + Date time = new Date(); + mtUser.setCreateTime(time); + mtUser.setUpdateTime(time); + mtUser.setStartTime(mtUser.getStartTime()); + mtUser.setEndTime(mtUser.getEndTime()); + if (mtUser.getStoreId() != null) { + mtUser.setStoreId(mtUser.getStoreId()); + } else { + mtUser.setStoreId(0); + } + // 密码加密 + if (mtUser.getPassword() != null && StringUtil.isNotEmpty(mtUser.getPassword())) { + String salt = SeqUtil.getRandomLetter(4); + mtUser.setSalt(salt); + String password = enCodePassword(mtUser.getPassword(), salt); + mtUser.setPassword(password); + mtUser.setSource(MemberSourceEnum.REGISTER_BY_ACCOUNT.getKey()); + } + if (mtUser.getSource() == null || StringUtil.isEmpty(mtUser.getSource())) { + mtUser.setSource(MemberSourceEnum.BACKEND_ADD.getKey()); + } + + boolean result = save(mtUser); + if (!result) { + return null; + } + + mtUser = queryMemberById(mtUser.getId()); + + // 开卡赠礼 + openGiftService.openGift(mtUser.getId(), Integer.parseInt(mtUser.getGradeId()), true); + + // 新增用户发短信通知 +// if (mtUser.getId() > 0 && mtUser.getStatus().equals(StatusEnum.ENABLED.getKey())) { +// // 发送短信 +// List mobileList = new ArrayList<>(); +// mobileList.add(mtUser.getMobile()); +// // 短信模板 +// try { +// Map params = new HashMap<>(); +// sendSmsService.sendSms(mtUser.getMerchantId(), "register-sms", mobileList, params); +// } catch (BusinessCheckException e) { +// // empty +// } +// } + + return mtUser; + } + + /** + * 更新会员信息 + * + * @param mtUser 会员信息 + * @param modifyPassword 修改密码 + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "修改会员信息") + public MtUser updateMember(MtUser mtUser, boolean modifyPassword) throws BusinessCheckException { + mtUser.setUpdateTime(new Date()); + + MtUser oldUserInfo = mtUserMapper.selectById(mtUser.getId()); + if (mtUser.getGradeId() != null && StringUtil.isNotEmpty(mtUser.getGradeId())) { + if (!CommonUtil.isNumeric(mtUser.getGradeId())) { + throw new BusinessCheckException("该会员等级有误"); + } + } + String mobile = mtUser.getMobile(); + if (PhoneFormatCheckUtils.isChinaPhoneLegal(mobile)) { + mtUser.setMobile(mobile); + } + + // 检查会员号是否重复 + if (StringUtil.isNotEmpty(mtUser.getUserNo())) { + List userList = mtUserMapper.findMembersByUserNo(mtUser.getMerchantId(), mtUser.getUserNo()); + if (userList.size() > 0) { + for(MtUser user: userList) { + MtUser userInfo = user; + if (userInfo.getId().intValue() != mtUser.getId().intValue()) { + throw new BusinessCheckException("该会员号与会员ID等于" + userInfo.getId() + "重复啦"); + } + } + } + } + if (mtUser.getPassword() != null && modifyPassword) { + String salt = SeqUtil.getRandomLetter(4); + mtUser.setSalt(salt); + mtUser.setPassword(enCodePassword(mtUser.getPassword(), salt)); + } + String gradeId = mtUser.getGradeId(); + mtUser.setGradeId(oldUserInfo.getGradeId()); + mtUser.setMerchantId(oldUserInfo.getMerchantId()); + mtUser.setStoreId(oldUserInfo.getStoreId()); + Boolean result = updateById(mtUser); + if (result && mtUser.getGradeId() != null) { + // 修改了会员等级,开卡赠礼 + if (!gradeId.equals(oldUserInfo.getGradeId())) { + openGiftService.openGift(mtUser.getId(), Integer.parseInt(gradeId), false); + } + } + return mtUser; + } + + /** + * 通过手机号新增会员 + * + * @param mobile 手机号 + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "通过手机号新增会员") + public MtUser addMemberByMobile(Integer merchantId, String mobile) throws BusinessCheckException { + MtUser mtUser = new MtUser(); + mtUser.setUserNo(CommonUtil.createUserNo()); + String nickName = mobile.replaceAll("(\\d{3})\\d{4}(\\d{4})","$1****$2"); + mtUser.setName(nickName); + mtUser.setMobile(mobile); + MtUserGrade grade = userGradeService.getInitUserGrade(merchantId); + if (grade != null) { + mtUser.setGradeId(grade.getId() + ""); + } + Date time = new Date(); + mtUser.setCreateTime(time); + mtUser.setUpdateTime(time); + mtUser.setBalance(new BigDecimal(0)); + mtUser.setPoint(0); + mtUser.setDescription("手机号登录自动注册"); + mtUser.setIdcard(""); + mtUser.setStatus(StatusEnum.ENABLED.getKey()); + mtUser.setMerchantId(merchantId); + mtUser.setStoreId(0); + mtUser.setSource(MemberSourceEnum.MOBILE_LOGIN.getKey()); + mtUserMapper.insert(mtUser); + mtUser = queryMemberByMobile(merchantId, mobile); + + // 开卡赠礼 + openGiftService.openGift(mtUser.getId(), Integer.parseInt(mtUser.getGradeId()), true); + return mtUser; + } + + /** + * 根据手机号获取会员信息 + * + * @param merchantId 商户ID + * @param mobile 手机号 + * @throws BusinessCheckException + * @return + */ + @Override + public MtUser queryMemberByMobile(Integer merchantId, String mobile) { + if (mobile == null || StringUtil.isEmpty(mobile)) { + return null; + } + List mtUser = mtUserMapper.queryMemberByMobile(merchantId, mobile); + if (mtUser.size() > 0) { + return mtUser.get(0); + } else { + return null; + } + } + + /** + * 根据会员号号获取会员信息 + * + * @param merchantId 商户ID + * @param userNo 会员号 + * @return + */ + @Override + public MtUser queryMemberByUserNo(Integer merchantId, String userNo) { + if (userNo == null || StringUtil.isEmpty(userNo)) { + return null; + } + List mtUser = mtUserMapper.findMembersByUserNo(merchantId, userNo); + if (mtUser.size() > 0) { + return mtUser.get(0); + } else { + return null; + } + } + + /** + * 根据会员ID获取会员信息 + * + * @param id 会员ID + * @throws BusinessCheckException + * @return + */ + @Override + public MtUser queryMemberById(Integer id) throws BusinessCheckException { + MtUser mtUser = mtUserMapper.selectById(id); + + if (mtUser != null) { + // 检查会员是否过期,过期就把会员等级置为初始等级 + MtUserGrade initGrade = userGradeService.getInitUserGrade(mtUser.getMerchantId()); + if (initGrade != null) { + Date endTime = mtUser.getEndTime(); + if (endTime != null) { + Date now = new Date(); + if (endTime.before(now)) { + if (!mtUser.getGradeId().equals(initGrade.getId())) { + mtUser.setGradeId(initGrade.getId().toString()); + updateById(mtUser); + } + } + } + // 会员等级为空,就把会员等级置为初始等级 + String userGradeId = mtUser.getGradeId(); + if (userGradeId == null && initGrade != null) { + mtUser.setGradeId(initGrade.getId().toString()); + updateById(mtUser); + openGiftService.openGift(mtUser.getId(), initGrade.getId(), false); + } else { + // 会员等级不存在或已禁用、删除,就把会员等级置为初始等级 + MtUserGrade myGrade = userGradeService.queryUserGradeById(mtUser.getMerchantId(), Integer.parseInt(userGradeId), id); + if (myGrade == null || !myGrade.getStatus().equals(StatusEnum.ENABLED.getKey())) { + mtUser.setGradeId(initGrade.getId().toString()); + updateById(mtUser); + } + } + } + } + return mtUser; + } + + /** + * 根据会员ID获取会员信息 + * + * @param id 会员ID + * @throws BusinessCheckException + * @return + */ + @Override + public MtUser queryMemberById2(Integer id) throws BusinessCheckException { + return mtUserMapper.selectById(id); + } + + /** + * 根据会员名称获取会员信息 + * + * @param merchantId 商户ID + * @param name 会员名称 + * @throws BusinessCheckException + * @return + */ + @Override + public MtUser queryMemberByName(Integer merchantId, String name) { + if (StringUtil.isNotEmpty(name)) { + List userList = mtUserMapper.queryMemberByName(merchantId, name); + if (userList.size() == 1) { + return userList.get(0); + } + } + return null; + } + + /** + * 根据openId获取会员信息(为空就注册) + * + * @param merchantId + * @param openId + * @throws BusinessCheckException + * @return + */ + @Override + public MtUser queryMemberByOpenId(Integer merchantId, String openId, JSONObject userInfo) throws BusinessCheckException { + MtUser user = mtUserMapper.queryMemberByOpenId(merchantId, openId); + + String avatar = StringUtil.isNotEmpty(userInfo.getString("avatarUrl")) ? userInfo.getString("avatarUrl") : ""; + String gender = StringUtil.isNotEmpty(userInfo.getString("gender")) ? userInfo.getString("gender") : GenderEnum.MAN.getKey().toString(); + String country = StringUtil.isNotEmpty(userInfo.getString("country")) ? userInfo.getString("country") : ""; + String province = StringUtil.isNotEmpty(userInfo.getString("province")) ? userInfo.getString("province") : ""; + String city = StringUtil.isNotEmpty(userInfo.getString("city")) ? userInfo.getString("city") : ""; + String storeId = StringUtil.isNotEmpty(userInfo.getString("storeId")) ? userInfo.getString("storeId") : "0"; + String nickName = StringUtil.isNotEmpty(userInfo.getString("nickName")) ? userInfo.getString("nickName") : ""; + String mobile = StringUtil.isNotEmpty(userInfo.getString("phone")) ? userInfo.getString("phone") : ""; + String source = StringUtil.isNotEmpty(userInfo.getString("source")) ? userInfo.getString("source") : MemberSourceEnum.WECHAT_LOGIN.getKey(); + + // 需要手机号登录 + if (StringUtil.isEmpty(mobile) && user == null) { + MtSetting mtSetting = settingService.querySettingByName(merchantId, UserSettingEnum.LOGIN_NEED_PHONE.getKey()); + if (mtSetting != null) { + if (mtSetting.getValue().equals("true")) { + MtUser tempUser = new MtUser(); + tempUser.setOpenId(openId); + tempUser.setId(0); + return tempUser; + } + } + } + + // 手机号已经存在 + if (StringUtil.isNotEmpty(mobile) && user == null) { + user = queryMemberByMobile(merchantId, mobile); + user.setOpenId(openId); + } + + if (user == null) { + MtUser mtUser = new MtUser(); + if (StringUtil.isNotEmpty(mobile)) { + MtUser mtUserMobile = queryMemberByMobile(merchantId, mobile); + if (mtUserMobile != null) { + mtUser = mtUserMobile; + } + } + + // 昵称为空,用手机号 + if (StringUtil.isEmpty(nickName) && StringUtil.isNotEmpty(mobile)) { + nickName = mobile.replaceAll("(\\d{3})\\d{4}(\\d{4})","$1****$2"); + } + mtUser.setMerchantId(merchantId); + String userNo = CommonUtil.createUserNo(); + mobile = CommonUtil.replaceXSS(mobile); + avatar = CommonUtil.replaceXSS(avatar); + nickName = CommonUtil.replaceXSS(nickName); + mtUser.setUserNo(userNo); + mtUser.setMobile(mobile); + mtUser.setAvatar(avatar); + mtUser.setName(nickName); + mtUser.setOpenId(openId); + MtUserGrade grade = userGradeService.getInitUserGrade(merchantId); + if (grade != null) { + mtUser.setGradeId(grade.getId() + ""); + } + Date time = new Date(); + mtUser.setCreateTime(time); + mtUser.setUpdateTime(time); + mtUser.setBalance(new BigDecimal(0)); + mtUser.setPoint(0); + mtUser.setDescription("微信登录自动注册"); + mtUser.setIdcard(""); + mtUser.setStatus(StatusEnum.ENABLED.getKey()); + mtUser.setAddress(country + province + city); + // 微信用户 1:男;2:女 0:未知 + if (gender.equals(GenderEnum.FEMALE.getKey().toString())) { + gender = GenderEnum.UNKNOWN.getKey().toString(); + } else if (gender.equals(GenderEnum.UNKNOWN.getKey().toString())) { + gender = GenderEnum.FEMALE.getKey().toString(); + } + mtUser.setSex(Integer.parseInt(gender)); + if (StringUtil.isNotEmpty(storeId)) { + mtUser.setStoreId(Integer.parseInt(storeId)); + } else { + mtUser.setStoreId(0); + } + mtUser.setSource(source); + if (mtUser.getId() == null || mtUser.getId() <= 0) { + save(mtUser); + } else { + updateById(mtUser); + } + user = mtUserMapper.queryMemberByOpenId(merchantId, openId); + + // 开卡赠礼 + openGiftService.openGift(user.getId(), Integer.parseInt(user.getGradeId()), true); + } else { + // 已被禁用 + if (user.getStatus().equals(StatusEnum.DISABLE.getKey())) { + return null; + } + // 补充手机号 + if (StringUtil.isNotEmpty(mobile) && PhoneFormatCheckUtils.isChinaPhoneLegal(mobile)) { + user.setMobile(mobile); + updateById(user); + } + // 补充会员号 + if (StringUtil.isEmpty(user.getUserNo())) { + user.setUserNo(CommonUtil.createUserNo()); + updateById(user); + } + } + + return user; + } + + /** + * 根据等级ID获取会员等级信息 + * + * @param id 等级ID + * @throws BusinessCheckException + * @return + */ + @Override + public MtUserGrade queryMemberGradeByGradeId(Integer id) { + MtUserGrade gradeInfo = mtUserGradeMapper.selectById(id); + return gradeInfo; + } + + /** + * 删除会员 + * + * @param id 会员ID + * @param operator 操作人 + * @throws BusinessCheckException + * @return + */ + @Override + @OperationServiceLog(description = "删除会员信息") + public Integer deleteMember(Integer id, String operator) throws BusinessCheckException { + MtUser mtUser = mtUserMapper.selectById(id); + if (null == mtUser) { + throw new BusinessCheckException("该会员不存在,请确认"); + } + // 是否是店铺员工 + MtStaff mtStaff = staffService.queryStaffByUserId(id); + if (mtStaff != null && mtStaff.getAuditedStatus().equals(StatusEnum.ENABLED.getKey())) { + throw new BusinessCheckException("该会员已关联店铺员工”"+ mtStaff.getRealName()+"“,若要删除请先删除该员工信息"); + } + mtUser.setStatus(StatusEnum.DISABLE.getKey()); + mtUser.setUpdateTime(new Date()); + mtUser.setOperator(operator); + updateById(mtUser); + return mtUser.getId(); + } + + /** + * 根据条件搜索会员分组 + * + * @param params 查询参数 + * @return + * */ + @Override + public List queryMemberGradeByParams(Map params) { + if (params == null) { + params = new HashMap<>(); + } + List result = mtUserGradeMapper.selectByMap(params); + return result; + } + + /** + * 获取会员数量 + * + * @param merchantId 商户ID + * @param storeId 店铺ID + * @return + * */ + @Override + public Long getUserCount(Integer merchantId, Integer storeId) { + if (storeId > 0) { + return mtUserMapper.getStoreUserCount(storeId); + } else { + return mtUserMapper.getUserCount(merchantId); + } + } + + /** + * 获取会员数量 + * + * @param merchantId 商户ID + * @param storeId 店铺ID + * @param beginTime 开始时间 + * @param endTime 结束时间 + * @return + * */ + @Override + public Long getUserCount(Integer merchantId, Integer storeId, Date beginTime, Date endTime) { + if (storeId > 0) { + return mtUserMapper.getStoreUserCountByTime(storeId, beginTime, endTime); + } else { + return mtUserMapper.getUserCountByTime(merchantId, beginTime, endTime); + } + } + + /** + * 获取会员数量 + * + * @param merchantId 商户ID + * @param storeId 店铺ID + * @param beginTime 开始时间 + * @param endTime 结束时间 + * @return + * */ + @Override + public Long getActiveUserCount(Integer merchantId, Integer storeId, Date beginTime, Date endTime) { + if (storeId > 0) { + return mtUserActionMapper.getStoreActiveUserCount(storeId, beginTime, endTime); + } else { + return mtUserActionMapper.getActiveUserCount(merchantId, beginTime, endTime); + } + } + + /** + * 重置手机号 + * + * @param mobile 手机号码 + * @param userId 会员ID + * @return + */ + @Override + public void resetMobile(String mobile, Integer userId) { + if (mobile == null || StringUtil.isEmpty(mobile)) { + return; + } + mtUserMapper.resetMobile(mobile, userId); + } + + /** + * 获取会员消费排行榜 + * + * @param merchantId 商户ID + * @param storeId 店铺ID + * @param startTime 开始时间 + * @param endTime 结束时间 + * @return + * */ + @Override + public List getMemberConsumeTopList(Integer merchantId, Integer storeId, Date startTime, Date endTime) { + List memberList = mtUserMapper.getMemberConsumeTopList(merchantId, storeId, startTime, endTime); + List dataList = new ArrayList<>(); + if (memberList != null && memberList.size() > 0) { + for (MemberTopBean bean : memberList) { + MemberTopDto dto = new MemberTopDto(); + BeanUtils.copyProperties(bean, dto); + dataList.add(dto); + } + } + return dataList; + } + + /** + * 查找会员列表 + * + * @param merchantId 商户ID + * @param keyword 关键字 + * @param groupIds 分组ID + * @param page 当前页码 + * @param pageSize 每页数量 + * @return + * */ + @Override + public List searchMembers(Integer merchantId, String keyword, String groupIds, Integer page, Integer pageSize) { + PageHelper.startPage(page, pageSize); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtUser::getStatus, StatusEnum.DISABLE.getKey()); + if (merchantId != null && merchantId > 0) { + lambdaQueryWrapper.eq(MtUser::getMerchantId, merchantId); + } + if (StringUtils.isNotBlank(groupIds)) { + List idList = Arrays.asList(groupIds.split(",")); + if (idList.size() > 0) { + lambdaQueryWrapper.in(MtUser::getGroupId, idList); + } + } + if (StringUtil.isNotEmpty(keyword)) { + List itemList = Arrays.asList(keyword.split(",")); + lambdaQueryWrapper.and(wq -> wq + .in(MtUser::getUserNo, itemList) + .or() + .in(MtUser::getMobile, itemList)); + } + lambdaQueryWrapper.orderByDesc(MtUser::getUpdateTime); + List userList = mtUserMapper.selectList(lambdaQueryWrapper); + List dataList = new ArrayList<>(); + if (userList != null && userList.size() > 0) { + for (MtUser mtUser : userList) { + GroupMemberDto memberDto = new GroupMemberDto(); + memberDto.setId(mtUser.getId()); + memberDto.setName(mtUser.getName()); + memberDto.setUserNo(mtUser.getUserNo()); + // 隐藏手机号中间四位 + String phone = mtUser.getMobile(); + if (phone != null && StringUtil.isNotEmpty(phone) && phone.length() == 11) { + memberDto.setMobile(phone.substring(0, 3) + "****" + phone.substring(7)); + } + dataList.add(memberDto); + } + } + return dataList; + } + + /** + * 查找会员列表 + * + * @param merchantId 商户ID + * @param keyword 关键字 + * @return + * */ + @Override + public List searchMembers(Integer merchantId, String keyword) { + return mtUserMapper.searchMembers(merchantId, keyword); + } + + /** + * 设定安全的密码 + * + * @param password 密码明文 + * @param salt 加密因子 + * @return + */ + @Override + public String enCodePassword(String password, String salt) { + return MD5Util.getMD5(password + salt); + } + + /** + * 获取加密密码 + * + * @param password 密码密文 + * @param salt 加密因子 + * @return + * */ + @Override + public String deCodePassword(String password, String salt) { + return MD5Util.getMD5(password + salt); + } + + /** + * 获取会员ID列表 + * + * @param merchantId 商户号 + * @param storeId 店铺ID + * @return + * */ + @Override + public List getUserIdList(Integer merchantId, Integer storeId) { + return mtUserMapper.getUserIdList(merchantId, storeId); + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/MerchantServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/MerchantServiceImpl.java new file mode 100644 index 0000000..c1abbe8 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/MerchantServiceImpl.java @@ -0,0 +1,259 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.enums.StatusEnum; +import com.fuint.common.service.MerchantService; +import com.fuint.common.util.CommonUtil; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.mapper.MtMerchantMapper; +import com.fuint.repository.mapper.MtStoreMapper; +import com.fuint.repository.model.MtMerchant; +import com.fuint.repository.model.MtStore; +import com.fuint.utils.StringUtil; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.util.*; + +/** + * 商户业务实现类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class MerchantServiceImpl extends ServiceImpl implements MerchantService { + + private MtMerchantMapper mtMerchantMapper; + + private MtStoreMapper mtStoreMapper; + + private static final Logger logger = LoggerFactory.getLogger(MerchantServiceImpl.class); + + /** + * 分页查询商户列表 + * + * @param paginationRequest + * @return + */ + @Override + public PaginationResponse queryMerchantListByPagination(PaginationRequest paginationRequest) { + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtMerchant::getStatus, StatusEnum.DISABLE.getKey()); + + String name = paginationRequest.getSearchParams().get("name") == null ? "" : paginationRequest.getSearchParams().get("name").toString(); + if (StringUtils.isNotBlank(name)) { + lambdaQueryWrapper.like(MtMerchant::getName, name); + } + String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtMerchant::getStatus, status); + } + String id = paginationRequest.getSearchParams().get("id") == null ? "" : paginationRequest.getSearchParams().get("id").toString(); + if (StringUtils.isNotBlank(id)) { + lambdaQueryWrapper.eq(MtMerchant::getId, id); + } + + lambdaQueryWrapper.orderByAsc(MtMerchant::getStatus).orderByDesc(MtMerchant::getId); + List dataList = mtMerchantMapper.selectList(lambdaQueryWrapper); + + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, MtMerchant.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 保存商户信息 + * + * @param merchant 商户信息 + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional + @OperationServiceLog(description = "保存商户信息") + public MtMerchant saveMerchant(MtMerchant merchant) { + MtMerchant mtMerchant = new MtMerchant(); + + // 编辑商户 + if (merchant.getId() != null) { + mtMerchant = queryMerchantById(merchant.getId()); + } + + if (merchant.getNo() == null || StringUtil.isEmpty(merchant.getNo())) { + mtMerchant.setNo(CommonUtil.createMerchantNo()); + } else { + mtMerchant.setNo(merchant.getNo()); + } + if (merchant.getType() != null) { + mtMerchant.setType(merchant.getType()); + } + mtMerchant.setName(merchant.getName()); + mtMerchant.setLogo(merchant.getLogo()); + mtMerchant.setContact(merchant.getContact()); + mtMerchant.setOperator(merchant.getOperator()); + mtMerchant.setUpdateTime(new Date()); + if (merchant.getId() == null) { + mtMerchant.setCreateTime(new Date()); + } + mtMerchant.setWxAppId(merchant.getWxAppId()); + mtMerchant.setWxAppSecret(merchant.getWxAppSecret()); + mtMerchant.setWxOfficialAppId(merchant.getWxOfficialAppId()); + mtMerchant.setWxOfficialAppSecret(merchant.getWxOfficialAppSecret()); + mtMerchant.setDescription(merchant.getDescription()); + mtMerchant.setPhone(merchant.getPhone()); + mtMerchant.setAddress(merchant.getAddress()); + mtMerchant.setStatus(merchant.getStatus()); + + if (mtMerchant.getStatus() == null) { + mtMerchant.setStatus(StatusEnum.ENABLED.getKey()); + } + if (mtMerchant.getId() == null || mtMerchant.getId() < 1) { + this.save(mtMerchant); + } else { + mtMerchantMapper.updateById(mtMerchant); + } + return mtMerchant; + } + + /** + * 根据ID获取商户信息 + * + * @param id 商户ID + * @throws BusinessCheckException + * @return + */ + @Override + public MtMerchant queryMerchantById(Integer id) { + if (id == null || id < 1) { + return null; + } + return mtMerchantMapper.selectById(id); + } + + /** + * 根据名称获取商户信息 + * + * @param name 商户名称 + * @throws BusinessCheckException + * @return + */ + @Override + public MtMerchant queryMerchantByName(String name) { + MtMerchant mtMerchant = mtMerchantMapper.queryMerchantByName(name); + return mtMerchant; + } + + /** + * 根据商户号获取商户信息 + * + * @param merchantNo 商户号 + * @return + */ + @Override + public MtMerchant queryMerchantByNo(String merchantNo) { + return mtMerchantMapper.queryMerchantByNo(merchantNo); + } + + /** + * 根据商户号获取商户ID + * + * @param merchantNo 商户号 + * @return + */ + @Override + public Integer getMerchantId(String merchantNo) { + if (merchantNo == null || StringUtil.isEmpty(merchantNo)) { + logger.error("根据商户号获取商户ID,商户号不能为空!"); + return 0; + } + MtMerchant mtMerchant = queryMerchantByNo(merchantNo); + if (mtMerchant != null) { + return mtMerchant.getId(); + } else { + logger.error("根据商户号获取商户ID,该商户不存在!"); + return 0; + } + } + + /** + * 更新商户状态 + * + * @param id 商户ID + * @param operator 操作人 + * @param status 状态 + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional + @OperationServiceLog(description = "修改商户状态") + public void updateStatus(Integer id, String operator, String status) throws BusinessCheckException { + MtMerchant mtMerchant = queryMerchantById(id); + if (null == mtMerchant) { + throw new BusinessCheckException("该商户不存在."); + } + + mtMerchant.setStatus(status); + mtMerchant.setUpdateTime(new Date()); + mtMerchant.setOperator(operator); + + mtMerchantMapper.updateById(mtMerchant); + } + + /** + * 根据条件查询商户列表 + * + * @param params 查询参数 + * @return + * */ + @Override + public List queryMerchantByParams(Map params) { + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtMerchant::getStatus, StatusEnum.DISABLE.getKey()); + + String merchantId = params.get("merchantId") == null ? "" : params.get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(MtMerchant::getId, merchantId); + } + String storeId = params.get("storeId") == null ? "" : params.get("storeId").toString(); + if (StringUtils.isNotBlank(storeId) && StringUtil.isEmpty(merchantId)) { + MtStore mtStore = mtStoreMapper.selectById(storeId); + if (mtStore != null && mtStore.getMerchantId() > 0) { + lambdaQueryWrapper.eq(MtMerchant::getId, mtStore.getMerchantId()); + } + } + String name = params.get("name") == null ? "" : params.get("name").toString(); + if (StringUtils.isNotBlank(name)) { + lambdaQueryWrapper.like(MtMerchant::getName, name); + } + String status = params.get("status") == null ? "" : params.get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtMerchant::getStatus, status); + } + + lambdaQueryWrapper.orderByAsc(MtMerchant::getStatus).orderByDesc(MtMerchant::getId); + List dataList = mtMerchantMapper.selectList(lambdaQueryWrapper); + + return dataList; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/MessageServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/MessageServiceImpl.java new file mode 100644 index 0000000..b4e38df --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/MessageServiceImpl.java @@ -0,0 +1,134 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.enums.MessageEnum; +import com.fuint.common.enums.StatusEnum; +import com.fuint.common.enums.YesOrNoEnum; +import com.fuint.common.service.MessageService; +import com.fuint.repository.mapper.MtMessageMapper; +import com.fuint.repository.model.MtMessage; +import com.fuint.utils.StringUtil; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.util.Date; +import java.util.List; + +/** + * 消息业务实现类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class MessageServiceImpl extends ServiceImpl implements MessageService { + + private MtMessageMapper messageRepository; + + /** + * 添加消息 + * + * @param mtMsg 消息参数 + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void addMessage(MtMessage mtMsg) { + if (mtMsg.getUserId() < 0 || StringUtil.isEmpty(mtMsg.getContent())) { + return; + } + + mtMsg.setStatus(StatusEnum.ENABLED.getKey()); + mtMsg.setIsRead(YesOrNoEnum.NO.getKey()); + mtMsg.setCreateTime(new Date()); + mtMsg.setUpdateTime(new Date()); + + this.save(mtMsg); + } + + /** + * 将消息置为已读 + * + * @param msgId 消息ID + * @param + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void readMessage(Integer msgId) { + if (msgId < 0) { + return; + } + + MtMessage mtMsg = messageRepository.selectById(msgId); + if (mtMsg == null) { + return; + } + + mtMsg.setIsRead(YesOrNoEnum.YES.getKey()); + mtMsg.setUpdateTime(new Date()); + + messageRepository.updateById(mtMsg); + } + + /** + * 消息置为发送 + * + * @param msgId 消息ID + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void sendMessage(Integer msgId, boolean isRead) { + if (msgId < 0 ) { + return; + } + + MtMessage mtMsg = messageRepository.selectById(msgId); + if (mtMsg == null) { + return; + } + + mtMsg.setIsSend(YesOrNoEnum.YES.getKey()); + + // 订阅消息发送成功就算是已读了 + if (isRead) { + mtMsg.setIsRead(YesOrNoEnum.YES.getKey()); + } else { + mtMsg.setIsRead(YesOrNoEnum.NO.getKey()); + } + + mtMsg.setUpdateTime(new Date()); + + messageRepository.updateById(mtMsg); + } + + /** + * 获取最新一条未读弹框消息 + * + * @param userId 会员ID + * @return + */ + @Override + public MtMessage getOne(Integer userId) { + List messageList = messageRepository.findNewMessage(userId, MessageEnum.POP_MSG.getKey()); + + if (messageList.size() > 0) { + MtMessage messageInfo = messageList.get(0); + return messageInfo; + } + + return null; + } + + /** + * 获取需要发送的消息 + * + * @return + */ + @Override + public List getNeedSendList() { + List messageList = messageRepository.findNeedSendMessage(MessageEnum.SUB_MSG.getKey()); + return messageList; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/OpenGiftServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/OpenGiftServiceImpl.java new file mode 100644 index 0000000..addcf88 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/OpenGiftServiceImpl.java @@ -0,0 +1,344 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.Constants; +import com.fuint.common.dto.OpenGiftDto; +import com.fuint.common.enums.MessageEnum; +import com.fuint.common.enums.StatusEnum; +import com.fuint.common.enums.YesOrNoEnum; +import com.fuint.common.param.CouponReceiveParam; +import com.fuint.common.service.*; +import com.fuint.common.util.DateUtil; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.framework.web.ResponseObject; +import com.fuint.repository.mapper.MtOpenGiftMapper; +import com.fuint.repository.mapper.MtUserMapper; +import com.fuint.repository.model.*; +import com.fuint.utils.StringUtil; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; +import java.util.*; + +/** + * 开卡赠礼接口实现类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class OpenGiftServiceImpl extends ServiceImpl implements OpenGiftService { + + private MtOpenGiftMapper mtOpenGiftMapper; + + private MtUserMapper mtUserMapper; + + /** + * 卡券服务接口 + * */ + private CouponService couponService; + + /** + * 会员卡券服务接口 + * */ + private UserCouponService userCouponService; + + /** + * 会员等级服务接口 + * */ + private UserGradeService userGradeService; + + /** + * 会员积分服务接口 + * */ + private PointService pointService; + + /** + * 系统消息服务接口 + * */ + private MessageService messageService; + + /** + * 获取开卡赠礼列表 + * @param paramMap + * @throws BusinessCheckException + * @return + * */ + @Override + @Transactional(rollbackFor = Exception.class) + public ResponseObject getOpenGiftList(Map paramMap) throws BusinessCheckException { + Integer pageNumber = paramMap.get("pageNumber") == null ? Constants.PAGE_NUMBER : Integer.parseInt(paramMap.get("pageNumber").toString()); + Integer pageSize = paramMap.get("pageSize") == null ? Constants.PAGE_SIZE : Integer.parseInt(paramMap.get("pageSize").toString()); + + Page pageHelper = PageHelper.startPage(pageNumber, pageSize); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtOpenGift::getStatus, StatusEnum.DISABLE.getKey()); + String merchantId = paramMap.get("merchantId") == null ? "" : paramMap.get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(MtOpenGift::getMerchantId, merchantId); + } + String couponId = paramMap.get("couponId") == null ? "" : paramMap.get("couponId").toString(); + if (StringUtils.isNotBlank(couponId)) { + lambdaQueryWrapper.eq(MtOpenGift::getCouponId, couponId); + } + String gradeId = paramMap.get("gradeId") == null ? "" : paramMap.get("gradeId").toString(); + if (StringUtils.isNotBlank(gradeId)) { + lambdaQueryWrapper.eq(MtOpenGift::getGradeId, Integer.parseInt(gradeId)); + } + String status = paramMap.get("status") == null ? "" : paramMap.get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtOpenGift::getStatus, status); + } + + lambdaQueryWrapper.orderByDesc(MtOpenGift::getId); + List openGiftList = mtOpenGiftMapper.selectList(lambdaQueryWrapper); + List dataList = new ArrayList<>(); + for (MtOpenGift item : openGiftList) { + OpenGiftDto dto = dealDetail(item); + dataList.add(dto); + } + + PageRequest pageRequest = PageRequest.of(pageNumber, pageSize); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, OpenGiftDto.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return new ResponseObject(200, "", paginationResponse); + } + + /** + * 新增开卡赠礼 + * + * @param mtOpenGift 赠礼信息 + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "新增开卡赠礼") + public MtOpenGift addOpenGift(MtOpenGift mtOpenGift) { + mtOpenGift.setUpdateTime(new Date()); + mtOpenGift.setCreateTime(new Date()); + this.save(mtOpenGift); + return mtOpenGift; + } + + /** + * 根据ID获取开卡赠礼详情 + * + * @param id 开卡赠礼ID + * @throws BusinessCheckException + * @return + */ + @Override + public OpenGiftDto getOpenGiftDetail(Integer id) throws BusinessCheckException { + MtOpenGift openGift = mtOpenGiftMapper.selectById(id); + return dealDetail(openGift); + } + + /** + * 根据ID删除数据 + * + * @param id 开卡赠礼ID + * @param operator 操作人 + * @throws BusinessCheckException + * @return + */ + @Override + @OperationServiceLog(description = "删除开卡赠礼") + public void deleteOpenGift(Integer id, String operator) { + MtOpenGift MtOpenGift = mtOpenGiftMapper.selectById(id); + if (null == MtOpenGift) { + return; + } + + MtOpenGift.setStatus(StatusEnum.DISABLE.getKey()); + MtOpenGift.setUpdateTime(new Date()); + + mtOpenGiftMapper.updateById(MtOpenGift); + } + + /** + * 更新开卡赠礼 + * + * @param reqDto 实体参数 + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "更新开卡赠礼") + public MtOpenGift updateOpenGift(MtOpenGift reqDto) throws BusinessCheckException { + MtOpenGift mtOpenGift = mtOpenGiftMapper.selectById(reqDto.getId()); + if (mtOpenGift == null) { + throw new BusinessCheckException("该数据状态异常"); + } + + mtOpenGift.setId(reqDto.getId()); + mtOpenGift.setUpdateTime(new Date()); + + if (null != reqDto.getOperator()) { + mtOpenGift.setOperator(reqDto.getOperator()); + } + + if (null != reqDto.getStatus()) { + mtOpenGift.setStatus(reqDto.getStatus()); + } + + if (null != reqDto.getCouponId()) { + mtOpenGift.setCouponId(reqDto.getCouponId()); + } + + if (null != reqDto.getGradeId()) { + mtOpenGift.setGradeId(reqDto.getGradeId()); + } + + if (null != reqDto.getPoint()) { + mtOpenGift.setPoint(reqDto.getPoint()); + } + + if (null != reqDto.getCouponNum()) { + mtOpenGift.setCouponNum(reqDto.getCouponNum()); + } + + mtOpenGiftMapper.updateById(mtOpenGift); + return mtOpenGift; + } + + /** + * 开卡赠礼 + * + * @param userId 会员ID + * @param gradeId 等级ID + * @return + * */ + @Override + public boolean openGift(Integer userId, Integer gradeId, boolean isNewMember) throws BusinessCheckException { + if (gradeId == null || gradeId.compareTo(0) <= 0) { + return false; + } + Map params = new HashMap<>(); + params.put("grade_id", gradeId.toString()); + params.put("status", StatusEnum.ENABLED.getKey()); + + MtUser user = mtUserMapper.selectById(userId); + if (user == null) { + throw new BusinessCheckException("会员状态异常"); + } + if (user.getGradeId() == null && StringUtil.isEmpty(user.getGradeId())) { + user.setGradeId("0"); + } + MtUserGrade oldGrade = userGradeService.queryUserGradeById(user.getMerchantId(), Integer.parseInt(user.getGradeId()), user.getId()); + MtUserGrade gradeInfo = userGradeService.queryUserGradeById(user.getMerchantId(), gradeId, user.getId()); + // 设置有效期 + if (gradeInfo.getValidDay() > 0) { + user.setStartTime(new Date()); + Date endDate = new Date(); + Calendar calendar = new GregorianCalendar(); + calendar.setTime(endDate); + calendar.add(calendar.DATE, gradeInfo.getValidDay()); + endDate = calendar.getTime(); + user.setEndTime(endDate); + } + user.setGradeId(gradeId.toString()); + user.setUpdateTime(new Date()); + mtUserMapper.updateById(user); + // 会员往低了改变,没有开卡赠礼 + if (!isNewMember && oldGrade != null && oldGrade.getGrade() >= gradeInfo.getGrade()) { + return false; + } + List openGiftList = mtOpenGiftMapper.selectByMap(params); + if (openGiftList.size() > 0) { + Integer totalPoint = 0; + BigDecimal totalAmount = new BigDecimal("0"); + for(MtOpenGift item : openGiftList) { + // 加积分 + if (item.getPoint() > 0) { + MtPoint reqPointDto = new MtPoint(); + reqPointDto.setUserId(userId); + reqPointDto.setAmount(item.getPoint()); + reqPointDto.setDescription("开卡赠送"+ item.getPoint() +"积分"); + reqPointDto.setOperator("系统"); + pointService.addPoint(reqPointDto); + totalPoint = totalPoint + item.getPoint(); + } + // 返卡券 + if (item.getCouponId() > 0) { + try { + MtCoupon mtCoupon = couponService.queryCouponById(item.getCouponId()); + if (mtCoupon != null && mtCoupon.getStatus().equals(StatusEnum.ENABLED.getKey())) { + CouponReceiveParam param = new CouponReceiveParam(); + param.setCouponId(item.getCouponId()); + param.setUserId(userId); + param.setNum(item.getCouponNum() == null ? 1 : item.getCouponNum()); + userCouponService.receiveCoupon(param); + totalAmount = totalAmount.add(mtCoupon.getAmount()); + } + } catch (BusinessCheckException e) { + // empty + } + } + } + // 弹框消息 + MtMessage msg = new MtMessage(); + msg.setMerchantId(user.getMerchantId()); + msg.setType(MessageEnum.POP_MSG.getKey()); + msg.setUserId(userId); + msg.setTitle("温馨提示"); + msg.setSendTime(new Date()); + msg.setIsSend(YesOrNoEnum.YES.getKey()); + msg.setParams(""); + if (totalAmount.compareTo(new BigDecimal("0")) > 0 && totalPoint > 0) { + msg.setContent("系统赠送您价值¥" + totalAmount + "卡券和" + totalPoint + "积分,请注意查收!"); + messageService.addMessage(msg); + } else if(totalAmount.compareTo(new BigDecimal("0")) > 0) { + msg.setContent("系统赠送您价值" + totalAmount + "卡券,请注意查收!"); + messageService.addMessage(msg); + } else if(totalPoint > 0) { + msg.setContent("系统赠送您" + totalPoint + "积分,请注意查收!"); + messageService.addMessage(msg); + } + } + return true; + } + + /** + * 赠礼详情 + * + * @param openGiftInfo 赠礼详情 + * @throws BusinessCheckException + * @return OpenGiftDto + * */ + private OpenGiftDto dealDetail(MtOpenGift openGiftInfo) throws BusinessCheckException { + OpenGiftDto dto = new OpenGiftDto(); + + dto.setId(openGiftInfo.getId()); + dto.setCreateTime(DateUtil.formatDate(openGiftInfo.getCreateTime(), "yyyy.MM.dd HH:mm")); + dto.setUpdateTime(DateUtil.formatDate(openGiftInfo.getUpdateTime(), "yyyy.MM.dd HH:mm")); + dto.setStatus(openGiftInfo.getStatus()); + dto.setCouponNum(openGiftInfo.getCouponNum()); + dto.setPoint(openGiftInfo.getPoint()); + dto.setOperator(openGiftInfo.getOperator()); + + MtCoupon couponInfo = couponService.queryCouponById(openGiftInfo.getCouponId()); + dto.setCouponInfo(couponInfo); + + MtUserGrade gradeInfo = userGradeService.queryUserGradeById(openGiftInfo.getMerchantId(), openGiftInfo.getGradeId(), 0); + dto.setGradeInfo(gradeInfo); + + return dto; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/OrderServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/OrderServiceImpl.java new file mode 100644 index 0000000..7f50e32 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/OrderServiceImpl.java @@ -0,0 +1,2210 @@ +package com.fuint.common.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.Constants; +import com.fuint.common.dto.*; +import com.fuint.common.enums.*; +import com.fuint.common.param.OrderListParam; +import com.fuint.common.param.SettlementParam; +import com.fuint.common.service.*; +import com.fuint.common.util.CommonUtil; +import com.fuint.common.util.DateUtil; +import com.fuint.common.util.SeqUtil; +import com.fuint.common.util.TokenUtil; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.framework.web.ResponseObject; +import com.fuint.repository.mapper.*; +import com.fuint.repository.model.*; +import com.fuint.utils.PropertiesUtil; +import com.fuint.utils.StringUtil; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; +import org.springframework.context.annotation.Lazy; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; +import java.util.*; + +/** + * 订单接口实现类 + */ +@Service +@AllArgsConstructor(onConstructor_= {@Lazy}) +public class OrderServiceImpl extends ServiceImpl implements OrderService { + + private static final Logger logger = LoggerFactory.getLogger(OrderServiceImpl.class); + + private MtOrderMapper mtOrderMapper; + + private MtGoodsMapper mtGoodsMapper; + + private MtOrderGoodsMapper mtOrderGoodsMapper; + + private MtCartMapper mtCartMapper; + + private MtOrderAddressMapper mtOrderAddressMapper; + + private MtConfirmLogMapper mtConfirmLogMapper; + + private MtUserCouponMapper mtUserCouponMapper; + + private MtGoodsSkuMapper mtGoodsSkuMapper; + + private MtRegionMapper mtRegionMapper; + + private MtUserGradeMapper mtUserGradeMapper; + + /** + * 系统设置服务接口 + * */ + private SettingService settingService; + + /** + * 卡券服务接口 + * */ + private CouponService couponService; + + /** + * 会员卡券服务接口 + * */ + private UserCouponService userCouponService; + + /** + * 收货地址服务接口 + * */ + private AddressService addressService; + + /** + * 会员服务接口 + * */ + private MemberService memberService; + + /** + * 积分服务接口 + * */ + private PointService pointService; + + /** + * 购物车服务接口 + * */ + private CartService cartService; + + /** + * 商品服务接口 + * */ + private GoodsService goodsService; + + /** + * 店铺服务接口 + * */ + private StoreService storeService; + + /** + * 会员等级服务接口 + * */ + private UserGradeService userGradeService; + + /** + * 售后服务接口 + * */ + private RefundService refundService; + + /** + * 余额服务接口 + * */ + private BalanceService balanceService; + + /** + * 微信相关服务接口 + * */ + private WeixinService weixinService; + + /** + * 支付宝服务接口 + * */ + private AlipayService alipayService; + + /** + * 短信发送服务接口 + * */ + private SendSmsService sendSmsService; + + /** + * 开卡赠礼服务接口 + * */ + private OpenGiftService openGiftService; + + /** + * 商户服务接口 + * */ + private MerchantService merchantService; + + /** + * 店铺员工服务接口 + * */ + private StaffService staffService; + + /** + * 支付服务接口 + * */ + private PaymentService paymentService; + + /** + * 获取用户订单列表 + * @param orderListParam + * @throws BusinessCheckException + * */ + @Override + @Transactional(rollbackFor = Exception.class) + public PaginationResponse getUserOrderList(OrderListParam orderListParam) throws BusinessCheckException { + Integer pageNumber = orderListParam.getPage() == null ? Constants.PAGE_NUMBER : orderListParam.getPage(); + Integer pageSize = orderListParam.getPageSize() == null ? Constants.PAGE_SIZE : orderListParam.getPageSize(); + String userId = orderListParam.getUserId() == null ? "" : orderListParam.getUserId(); + Integer merchantId = orderListParam.getMerchantId() == null ? 0 : orderListParam.getMerchantId(); + Integer storeId = orderListParam.getStoreId() == null ? 0 : orderListParam.getStoreId(); + String status = orderListParam.getStatus() == null ? "": orderListParam.getStatus(); + String payStatus = orderListParam.getPayStatus() == null ? "": orderListParam.getPayStatus(); + String settleStatus = orderListParam.getSettleStatus() == null ? "": orderListParam.getSettleStatus(); + String dataType = orderListParam.getDataType() == null ? "": orderListParam.getDataType(); + String type = orderListParam.getType() == null ? "": orderListParam.getType(); + String orderSn = orderListParam.getOrderSn() == null ? "": orderListParam.getOrderSn(); + String mobile = orderListParam.getMobile() == null ? "": orderListParam.getMobile(); + String orderMode = orderListParam.getOrderMode() == null ? "": orderListParam.getOrderMode(); + String staffId = orderListParam.getStaffId() == null ? "" : orderListParam.getStaffId(); + String couponId = orderListParam.getCouponId() == null ? "" : orderListParam.getCouponId(); + String storeIds = orderListParam.getStoreIds() == null ? "" : orderListParam.getStoreIds(); + String startTime = orderListParam.getStartTime() == null ? "" : orderListParam.getStartTime(); + String endTime = orderListParam.getEndTime() == null ? "" : orderListParam.getEndTime(); + String userNo = orderListParam.getUserNo() == null ? "" : orderListParam.getUserNo(); + Integer storeLocationId = orderListParam.getStoreLocationId() == null ? 0 : orderListParam.getStoreLocationId(); + + if (dataType.equals("toPay")) { + status = OrderStatusEnum.CREATED.getKey(); // 待支付 + } else if(dataType.equals("paid")) { + status = OrderStatusEnum.PAID.getKey();; // 已支付 + //payStatus = PayStatusEnum.SUCCESS.getKey(); // 已支付 + } else if(dataType.equals("cancel")) { + status = OrderStatusEnum.CANCEL.getKey(); // 已取消 + } else if (dataType.equals("prepay")){ + status = "ZZZ";// 临时变量,确保无法查询到 + } else if (dataType.equals("refund")){ + status = OrderStatusEnum.REFUND.getKey(); // 已取消 + } + Page pageHelper = PageHelper.startPage(pageNumber, pageSize); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + + if (StringUtil.isNotEmpty(orderSn)) { + lambdaQueryWrapper.eq(MtOrder::getOrderSn, orderSn); + } + if (StringUtil.isNotEmpty(status)) { + lambdaQueryWrapper.eq(MtOrder::getStatus, status); + } + if (StringUtil.isNotEmpty(payStatus)) { + lambdaQueryWrapper.eq(MtOrder::getPayStatus, payStatus); + } + if (StringUtil.isNotEmpty(settleStatus)) { + lambdaQueryWrapper.eq(MtOrder::getSettleStatus, settleStatus); + } + if (StringUtil.isNotEmpty(mobile)) { + MtUser userInfo = memberService.queryMemberByMobile(merchantId, mobile); + if (userInfo != null) { + userId = userInfo.getId() + ""; + } else { + userId = "0"; + } + } + if (StringUtil.isNotEmpty(userNo)){ + MtUser userInfo = memberService.queryMemberByUserNo(merchantId, userNo); + if (userInfo != null) { + userId = userInfo.getId() + ""; + } else { + userId = "0"; + } + } + if (StringUtil.isNotEmpty(userId)) { + lambdaQueryWrapper.eq(MtOrder::getUserId, userId); + } + if (merchantId != null && merchantId > 0) { + lambdaQueryWrapper.eq(MtOrder::getMerchantId, merchantId); + } + if (storeId != null && storeId > 0) { + lambdaQueryWrapper.eq(MtOrder::getStoreId, storeId); + } + if (StringUtil.isNotEmpty(staffId)) { + lambdaQueryWrapper.eq(MtOrder::getStaffId, staffId); + } + if (StringUtil.isNotEmpty(type)) { + lambdaQueryWrapper.eq(MtOrder::getType, type); + } + if (StringUtil.isNotEmpty(orderMode)) { + lambdaQueryWrapper.eq(MtOrder::getOrderMode, orderMode); + } + if (StringUtils.isNotBlank(couponId)) { + lambdaQueryWrapper.eq(MtOrder::getCouponId, couponId); + } + if (StringUtils.isNotBlank(storeIds)) { + List idList = Arrays.asList(storeIds.split(",")); + if (idList.size() > 0) { + lambdaQueryWrapper.in(MtOrder::getStoreId, idList); + } + } + if (StringUtil.isNotEmpty(startTime)) { + lambdaQueryWrapper.ge(MtOrder::getCreateTime, startTime); + } + if (StringUtil.isNotEmpty(endTime)) { + lambdaQueryWrapper.le(MtOrder::getCreateTime, endTime); + } + + if (storeLocationId != 0){ + lambdaQueryWrapper.eq(MtOrder::getStoreLocationId, storeLocationId); + } + lambdaQueryWrapper.orderByDesc(MtOrder::getId); + List orderList = mtOrderMapper.selectList(lambdaQueryWrapper); + + List dataList = new ArrayList<>(); + + // 获取挂单的数据,即为预付费用 + if (dataType.equals("prepay") || dataType.equals("allll")){ + Map param = new HashMap<>(); + param.put("userId", userId); + MtUser userInfo = memberService.queryMemberById(Integer.parseInt(userId)); + param.put("merchantId", userInfo.getMerchantId()); + List cartList = cartService.queryCartListByParams2(param); + + if (!cartList.isEmpty()){ + Map> hangUpOrderListMap = new HashMap<>(); + for (MtCart cart: cartList){ // 确认挂单 + if (StringUtil.isNotEmpty(cart.getHangNo())){ + String keyTmp = cart.getOperator()+"_"+cart.getHangNo(); + hangUpOrderListMap.computeIfAbsent(keyTmp, k -> new ArrayList<>()); + } + } + for (MtCart cart: cartList){ // 确认挂单对应的商品 + if (StringUtil.isNotEmpty(cart.getHangNo())) { + String keyTmp = cart.getOperator()+"_"+cart.getHangNo(); + List tmpList = hangUpOrderListMap.get(keyTmp); + tmpList.add(cart); + hangUpOrderListMap.put(keyTmp, tmpList); + } + } + for (Map.Entry> entry : hangUpOrderListMap.entrySet()) { + List hangUpCartList = entry.getValue(); + UserOrderDto dto = getHangUpOrderDetail(hangUpCartList); + dataList.add(dto); + + + } + } + } + + if (!orderList.isEmpty()) { + for (MtOrder order : orderList) { + UserOrderDto dto = getOrderDetail(order,false, false); + dataList.add(dto); + } + } + + PageRequest pageRequest = PageRequest.of(pageNumber, pageSize); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, UserOrderDto.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 保存订单信息 + * + * @param orderDto 订单参数 + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "提交订单信息") + public MtOrder saveOrder(OrderDto orderDto) throws BusinessCheckException { + MtOrder mtOrder; + if (null != orderDto.getId() && orderDto.getId() > 0) { + mtOrder = mtOrderMapper.selectById(orderDto.getId()); + } else { + mtOrder = new MtOrder(); + } + + // 检查店铺是否已被禁用 + if (orderDto.getStoreId() != null && orderDto.getStoreId() > 0) { + MtStore storeInfo = storeService.queryStoreById(orderDto.getStoreId()); + if (storeInfo != null) { + if (!storeInfo.getStatus().equals(StatusEnum.ENABLED.getKey())) { + orderDto.setStoreId(0); + } + } + } + + String orderSn; + if (orderDto.getId() == null || orderDto.getId() < 1) { + orderSn = CommonUtil.createOrderSN(orderDto.getUserId() + ""); + mtOrder.setOrderSn(orderSn); + } else { + orderSn = mtOrder.getOrderSn(); + } + + mtOrder.setUserId(orderDto.getUserId()); + mtOrder.setMerchantId(orderDto.getMerchantId()); + mtOrder.setStoreId(orderDto.getStoreId()); + mtOrder.setCouponId(orderDto.getCouponId()); + mtOrder.setParam(orderDto.getParam()); + mtOrder.setRemark(orderDto.getRemark()); + mtOrder.setStatus(OrderStatusEnum.CREATED.getKey()); + mtOrder.setType(orderDto.getType()); + mtOrder.setAmount(orderDto.getAmount()); + mtOrder.setPayAmount(orderDto.getPayAmount()); + mtOrder.setDiscount(orderDto.getDiscount()); + mtOrder.setPayStatus(PayStatusEnum.WAIT.getKey()); + mtOrder.setPointAmount(orderDto.getPointAmount()); + mtOrder.setUsePoint(orderDto.getUsePoint()); + mtOrder.setOrderMode(orderDto.getOrderMode()); + mtOrder.setPayType(orderDto.getPayType()); + mtOrder.setOperator(orderDto.getOperator()); + mtOrder.setStaffId(orderDto.getStaffId()); + mtOrder.setIsVisitor(orderDto.getIsVisitor()); + mtOrder.setUpdateTime(new Date()); + mtOrder.setDeliveryFee(orderDto.getDeliveryFee() == null ? new BigDecimal(0) : orderDto.getDeliveryFee()); + mtOrder.setSettleStatus(SettleStatusEnum.WAIT.getKey()); + + mtOrder.setStoreLocationId(orderDto.getStoreLocationId()); + mtOrder.setPrePayment(orderDto.getPrePayment()); + + if (mtOrder.getId() == null || mtOrder.getId() <= 0) { + mtOrder.setCreateTime(new Date()); + } + // 核销码 + if (orderDto.getPlatform() == null) { + orderDto.setPlatform(""); + } + if (mtOrder.getVerifyCode() == null && !orderDto.getPlatform().equals(PlatformTypeEnum.PC.getCode())) { + mtOrder.setVerifyCode(SeqUtil.getRandomNumber(6)); + } + + // 首先生成订单 + mtOrderMapper.insert(mtOrder); + MtOrder orderInfo = mtOrderMapper.selectById(mtOrder.getId()); + mtOrder.setId(orderInfo.getId()); + + // 会员相关信息 + MtUser userInfo = memberService.queryMemberById(orderDto.getUserId()); + MtUserGrade userGrade = userGradeService.queryUserGradeById(orderDto.getMerchantId(), userInfo.getGradeId() != null ? Integer.parseInt(userInfo.getGradeId()) : 1, orderDto.getUserId()); + BigDecimal percent = new BigDecimal("0"); + if (userGrade != null && userGrade.getDiscount() != null && userGrade.getDiscount() > 0) { + // 会员折扣 + percent = new BigDecimal(userGrade.getDiscount()).divide(new BigDecimal("10"), BigDecimal.ROUND_CEILING, 3); + } + + // 如果没有指定店铺,则读取默认的店铺 + if (orderDto.getStoreId() == null || orderDto.getStoreId() <= 0) { + Map params = new HashMap<>(); + params.put("status", StatusEnum.ENABLED.getKey()); + params.put("is_default", YesOrNoEnum.YES.getKey()); + List storeList = storeService.queryStoresByParams(params); + if (storeList.size() > 0) { + mtOrder.setStoreId(storeList.get(0).getId()); + } else { + mtOrder.setStoreId(0); + } + } + + mtOrder.setUpdateTime(new Date()); + if (mtOrder.getCreateTime() == null) { + mtOrder.setCreateTime(new Date()); + } + + // 计算商品订单总金额 + List cartList = new ArrayList<>(); + Map cartData = new HashMap<>(); + if (orderDto.getType().equals(OrderTypeEnum.GOOGS.getKey())) { + Map param = new HashMap<>(); + param.put("status", StatusEnum.ENABLED.getKey()); + if (StringUtil.isNotEmpty(orderDto.getCartIds())) { + param.put("ids", orderDto.getCartIds()); + } + if (orderDto.getGoodsId() < 1) { + cartList = cartService.queryCartListByParams(param); + if (cartList.size() < 1) { + throw new BusinessCheckException("生成订单失败,请稍后重试"); + } + } else { + // 直接购买 + MtCart mtCart = new MtCart(); + mtCart.setGoodsId(orderDto.getGoodsId()); + mtCart.setSkuId(orderDto.getSkuId()); + mtCart.setNum(orderDto.getBuyNum()); + mtCart.setId(0); + mtCart.setUserId(orderDto.getUserId()); + mtCart.setStatus(StatusEnum.ENABLED.getKey()); + cartList.add(mtCart); + } + + boolean isUsePoint = orderDto.getUsePoint() > 0 ? true : false; + cartData = calculateCartGoods(orderInfo.getMerchantId(), orderDto.getUserId(), cartList, orderDto.getCouponId(), isUsePoint, orderDto.getPlatform(), orderInfo.getOrderMode()); + + mtOrder.setAmount(new BigDecimal(cartData.get("totalPrice").toString())); + mtOrder.setUsePoint(Integer.parseInt(cartData.get("usePoint").toString())); + mtOrder.setDiscount(new BigDecimal(cartData.get("couponAmount").toString())); + + // 实付金额 + BigDecimal payAmount = mtOrder.getAmount().subtract(mtOrder.getPointAmount()).subtract(mtOrder.getDiscount()); + if (payAmount.compareTo(new BigDecimal("0")) > 0) { + mtOrder.setPayAmount(payAmount); + } else { + mtOrder.setPayAmount(new BigDecimal("0")); + } + + // 购物使用了卡券 + if (mtOrder.getCouponId() > 0) { + String useCode = couponService.useCoupon(mtOrder.getCouponId(), mtOrder.getUserId(), mtOrder.getStoreId(), mtOrder.getId(), mtOrder.getDiscount(), "购物使用卡券"); + // 卡券使用失败 + if (StringUtil.isEmpty(useCode)) { + mtOrder.setDiscount(new BigDecimal("0")); + mtOrder.setCouponId(0); + } + } + } + + // 会员付款类订单 + if (orderDto.getType().equals(OrderTypeEnum.PAYMENT.getKey())) { + if (userInfo != null && userInfo.getGradeId() != null && orderDto.getIsVisitor().equals(YesOrNoEnum.NO.getKey())) { + if (percent.compareTo(new BigDecimal("0")) > 0) { + // 会员折扣 + BigDecimal payAmountDiscount = mtOrder.getPayAmount().multiply(percent); + if (payAmountDiscount.compareTo(new BigDecimal("0")) > 0) { + mtOrder.setDiscount(mtOrder.getDiscount().add(mtOrder.getPayAmount().subtract(payAmountDiscount))); + mtOrder.setPayAmount(payAmountDiscount); + } else { + mtOrder.setPayAmount(new BigDecimal("0")); + } + } + } + } + + // 再次更新订单 + try { + orderInfo = updateOrder(mtOrder); + } catch (Exception e) { + logger.error("OrderService 生成订单失败..."); + throw new BusinessCheckException("生成订单失败,请稍后重试"); + } + + // 扣减积分 + if (orderDto.getUsePoint() > 0) { + try { + MtPoint reqPointDto = new MtPoint(); + reqPointDto.setUserId(orderDto.getUserId()); + reqPointDto.setAmount(-orderDto.getUsePoint()); + reqPointDto.setOrderSn(orderSn); + reqPointDto.setDescription("支付扣除" + orderDto.getUsePoint() + "积分"); + reqPointDto.setOperator(""); + pointService.addPoint(reqPointDto); + } catch (BusinessCheckException e) { + logger.error("OrderService 扣减积分失败...{}", e.getMessage()); + throw new BusinessCheckException("扣减积分失败,请稍后重试"); + } + } + + // 如果是商品订单,生成订单商品 + if (orderDto.getType().equals(OrderTypeEnum.GOOGS.getKey()) && cartList.size() > 0) { + Object listObject = cartData.get("list"); + List lists =(ArrayList)listObject; + BigDecimal memberDiscount = new BigDecimal("0"); + for (ResCartDto cart : lists) { + MtOrderGoods orderGoods = new MtOrderGoods(); + orderGoods.setOrderId(orderInfo.getId()); + orderGoods.setGoodsId(cart.getGoodsId()); + orderGoods.setSkuId(cart.getSkuId()); + orderGoods.setNum(cart.getNum()); + // 计算会员折扣 + BigDecimal price = cart.getGoodsInfo().getPrice(); + if (price.compareTo(BigDecimal.ZERO) == 0){ + price = cart.getSelfPrice(); + } + boolean isDiscount = cart.getGoodsInfo().getIsMemberDiscount().equals(YesOrNoEnum.YES.getKey()); + if (percent.compareTo(new BigDecimal("0")) > 0 && isDiscount) { + orderGoods.setPrice(price.multiply(percent)); + BigDecimal discount = price.subtract(price.multiply(percent)).multiply(new BigDecimal(cart.getNum())); + orderGoods.setDiscount(discount); + memberDiscount = memberDiscount.add(discount); + } else { + orderGoods.setPrice(price); + orderGoods.setDiscount(new BigDecimal("0")); + } + orderGoods.setStatus(StatusEnum.ENABLED.getKey()); + orderGoods.setCreateTime(new Date()); + orderGoods.setUpdateTime(new Date()); + mtOrderGoodsMapper.insert(orderGoods); + // 扣减库存 + MtGoods goodsInfo = mtGoodsMapper.selectById(cart.getGoodsId()); + if (goodsInfo.getIsSingleSpec().equals(YesOrNoEnum.YES.getKey())) { + // 单规格减去库存 + Integer stock = goodsInfo.getStock() - cart.getNum(); + if (stock < 0) { + throw new BusinessCheckException("商品“" + goodsInfo.getName() + "”库存不足,订单提交失败"); + } + goodsInfo.setStock(stock); + mtGoodsMapper.updateById(goodsInfo); + } else { + // 多规格减去库存 + MtGoodsSku mtGoodsSku = mtGoodsSkuMapper.selectById(cart.getSkuId()); + if (mtGoodsSku != null) { + Integer stock = mtGoodsSku.getStock() - cart.getNum(); + if (stock < 0) { + throw new BusinessCheckException("商品sku编码“" + mtGoodsSku.getSkuNo() +"”库存不足,订单提交失败"); + } + mtGoodsSku.setStock(stock); + mtGoodsSkuMapper.updateById(mtGoodsSku); + + if (goodsInfo.getStock() != null && goodsInfo.getStock() > 0) { + Integer goodsStock = goodsInfo.getStock() - cart.getNum(); + if (goodsStock >= 0) { + goodsInfo.setStock(goodsStock); + mtGoodsMapper.updateById(goodsInfo); + } + } + } + } + if (cart.getId() > 0) { + mtCartMapper.deleteById(cart.getId()); + } + } + + // 会员折扣 + if (memberDiscount.compareTo(new BigDecimal("0")) > 0) { + orderInfo.setDiscount(orderInfo.getDiscount().add(memberDiscount)); + if (orderInfo.getPayAmount().subtract(memberDiscount).compareTo(new BigDecimal("0")) > 0) { + orderInfo.setPayAmount(orderInfo.getPayAmount().subtract(memberDiscount)); + } else { + orderInfo.setPayAmount(new BigDecimal("0")); + } + orderInfo.setUpdateTime(new Date()); + orderInfo = updateOrder(orderInfo); + } + + // 需要配送的订单,生成配送地址 + if (orderDto.getOrderMode().equals(OrderModeEnum.EXPRESS.getKey())) { + Map params = new HashMap<>(); + params.put("userId", orderDto.getUserId().toString()); + params.put("isDefault", YesOrNoEnum.YES.getKey()); + List addressList = addressService.queryListByParams(params); + MtAddress mtAddress; + if (addressList.size() > 0) { + mtAddress = addressList.get(0); + } else { + throw new BusinessCheckException("配送地址出错了,请重新选择配送地址"); + } + MtOrderAddress orderAddress = new MtOrderAddress(); + orderAddress.setOrderId(orderInfo.getId()); + orderAddress.setUserId(orderDto.getUserId()); + orderAddress.setName(mtAddress.getName()); + orderAddress.setMobile(mtAddress.getMobile()); + orderAddress.setCityId(mtAddress.getCityId()); + orderAddress.setProvinceId(mtAddress.getProvinceId()); + orderAddress.setRegionId(mtAddress.getRegionId()); + orderAddress.setDetail(mtAddress.getDetail()); + orderAddress.setCreateTime(new Date()); + mtOrderAddressMapper.insert(orderAddress); + } + } + + return orderInfo; + } + + /** + * 订单结算 + * @param request + * @param param 结算参数 + * @throws BusinessCheckException + * @return + * */ + @Override + @Transactional(rollbackFor = Exception.class) + public Map doSettle(HttpServletRequest request, SettlementParam param) throws BusinessCheckException { + String token = request.getHeader("Access-Token"); + Integer storeId = request.getHeader("storeId") == null ? 0 : Integer.parseInt(request.getHeader("storeId")); + String platform = request.getHeader("platform") == null ? "" : request.getHeader("platform"); + String merchantNo = request.getHeader("merchantNo") == null ? "" : request.getHeader("merchantNo"); + + String cartIds = param.getCartIds() == null ? "" : param.getCartIds(); + Integer targetId = param.getTargetId() == null ? 0 : Integer.parseInt(param.getTargetId()); // 储值卡、升级等级必填 + String selectNum = param.getSelectNum() == null ? "" : param.getSelectNum(); // 储值卡必填 + String remark = param.getRemark() == null ? "" : param.getRemark(); + String type = param.getType() == null ? "" : param.getType(); // 订单类型 + String payAmount = param.getPayAmount() == null ? "0" : StringUtil.isEmpty(param.getPayAmount()) ? "0" : param.getPayAmount(); // 支付金额 + Integer usePoint = param.getUsePoint() == null ? 0 : param.getUsePoint(); // 使用积分数量 + Integer couponId = param.getCouponId() == null ? 0 : param.getCouponId(); // 会员卡券ID + String payType = param.getPayType() == null ? PayTypeEnum.JSAPI.getKey() : param.getPayType(); + String authCode = param.getAuthCode() == null ? "" : param.getAuthCode(); + Integer userId = param.getUserId() == null ? 0 : param.getUserId(); // 指定下单会员 eg:收银功能 + String cashierPayAmount = param.getCashierPayAmount() == null ? "" : param.getCashierPayAmount(); // 收银台实付金额 + String cashierDiscountAmount = param.getCashierDiscountAmount() == null ? "" : param.getCashierDiscountAmount(); // 收银台优惠金额 + Integer goodsId = param.getGoodsId() == null ? 0 : param.getGoodsId(); // 立即购买商品ID + Integer skuId = param.getSkuId() == null ? 0 : param.getSkuId(); // 立即购买商品skuId + Integer buyNum = param.getBuyNum() == null ? 1 : param.getBuyNum(); // 立即购买商品数量 + String orderMode = param.getOrderMode()== null ? OrderModeEnum.ONESELF.getKey() : param.getOrderMode(); // 订单模式(配送or自取) + Integer orderId = param.getOrderId() == null ? null : param.getOrderId(); // 订单ID + + Integer storeLocationId = param.getStoreLocationId() == null ? null : param.getStoreLocationId(); // 收银地点ID + BigDecimal prePayment = param.getPrePayment() == null ? BigDecimal.ZERO : param.getPrePayment(); // 订单ID + + Integer merchantId = merchantService.getMerchantId(merchantNo); + UserInfo loginInfo = TokenUtil.getUserInfoByToken(token); + MtUser userInfo = null; + if (loginInfo != null) { + userInfo = memberService.queryMemberById(loginInfo.getId()); + } + + // 后台管理员或店员操作 + String operator = null; + Integer staffId = 0; + String isVisitor = YesOrNoEnum.NO.getKey(); + AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token); + if (accountInfo != null) { + operator = accountInfo.getAccountName(); + staffId = accountInfo.getStaffId() == null ? 0 : accountInfo.getStaffId(); + storeId = accountInfo.getStoreId(); + merchantId = accountInfo.getMerchantId(); + if (storeId <= 0) { + MtStore mtStore = storeService.getDefaultStore(merchantNo); + if (mtStore != null) { + storeId = mtStore.getId(); + } + } + if (userId < 1) { + isVisitor = YesOrNoEnum.YES.getKey(); + } + } + + if (userInfo == null) { + MtUser user = memberService.getCurrentUserInfo(request, userId, token); + if (user != null) { + userInfo = memberService.queryMemberById(user.getId()); + } + } else { + MtStaff mtStaff = staffService.queryStaffByUserId(userInfo.getId()); + if (mtStaff == null) { + mtStaff = staffService.queryStaffByMobile(userInfo.getMobile()); + } + if (mtStaff != null) { + operator = mtStaff.getRealName(); + } + } + + MtSetting config = settingService.querySettingByName(merchantId, OrderSettingEnum.IS_CLOSE.getKey()); + if (config != null && config.getValue().equals("true")) { + throw new BusinessCheckException("系统已关闭交易功能,请稍后再试!"); + } + + // 收银台通过手机号自动注册会员信息 + if ((userInfo == null || StringUtil.isEmpty(token))) { + String mobile = param.getMobile() == null ? "" : param.getMobile(); + if (StringUtil.isNotEmpty(operator) && StringUtil.isNotEmpty(mobile)) { + userInfo = memberService.queryMemberByMobile(merchantId, mobile); + // 自动注册会员 + if (userInfo == null) { + userInfo = memberService.addMemberByMobile(merchantId, mobile); + } + } + } + + if (userInfo == null) { + if (StringUtil.isNotEmpty(operator)) { + throw new BusinessCheckException("该管理员还未关联店铺员工"); + } else { + throw new BusinessCheckException("请先登录"); + } + } + + if (userId <= 0) { + userId = userInfo.getId(); + } else { + if (StringUtil.isNotEmpty(operator)) { + userInfo = memberService.queryMemberById(userId); + } + } + param.setUserId(userId); + + // 订单所属店铺 + if (storeId < 1) { + if (userInfo.getStoreId() > 0) { + storeId = userInfo.getStoreId(); + } + } + + // 生成订单数据 + OrderDto orderDto = new OrderDto(); + orderDto.setId(orderId); + orderDto.setRemark(remark); + orderDto.setUserId(userId); + orderDto.setMerchantId(merchantId); + orderDto.setStoreId(storeId); + orderDto.setType(type); + orderDto.setGoodsId(goodsId); + orderDto.setSkuId(skuId); + orderDto.setBuyNum(buyNum); + orderDto.setOrderMode(orderMode); + orderDto.setOperator(operator); + orderDto.setPayType(payType); + orderDto.setCouponId(0); + orderDto.setStaffId(staffId); + orderDto.setIsVisitor(isVisitor); + orderDto.setPlatform(platform); + orderDto.setStoreLocationId(storeLocationId); + orderDto.setPrePayment(prePayment); + + MtSetting pointSetting = settingService.querySettingByName(merchantId, PointSettingEnum.CAN_USE_AS_MONEY.getKey()); + // 使用积分数量 + if (pointSetting != null && pointSetting.getValue().equals("true")) { + orderDto.setUsePoint(usePoint); + } else { + orderDto.setUsePoint(0); + usePoint = 0; + } + + orderDto.setPointAmount(new BigDecimal("0")); + orderDto.setDiscount(new BigDecimal("0")); + orderDto.setPayAmount(new BigDecimal("0")); + orderDto.setAmount(new BigDecimal("0")); + orderDto.setCartIds(cartIds); + + // 储值卡的订单 + if (orderDto.getType().equals(OrderTypeEnum.PRESTORE.getKey())) { + orderDto.setCouponId(targetId); + String orderParam = ""; + BigDecimal totalAmount = new BigDecimal(0); + + MtCoupon couponInfo = couponService.queryCouponById(targetId); + String inRule = couponInfo.getInRule(); + String[] selectNumArr = selectNum.split(","); + String[] ruleArr = inRule.split(","); + for (int i = 0; i < ruleArr.length; i++) { + String item = ruleArr[i] + "_" + (StringUtil.isNotEmpty(selectNumArr[i]) ? selectNumArr[i] : 0); + String[] itemArr = item.split("_"); + // 预存金额 + BigDecimal price = new BigDecimal(itemArr[0]); + // 预存数量 + BigDecimal num = new BigDecimal(selectNumArr[i]); + BigDecimal amount = price.multiply(num); + totalAmount = totalAmount.add(amount); + orderParam = StringUtil.isEmpty(orderParam) ? item : orderParam + ","+item; + } + + orderDto.setParam(orderParam); + orderDto.setAmount(totalAmount); + payAmount = totalAmount.toString(); + } + + // 付款订单 + if (orderDto.getType().equals(OrderTypeEnum.PAYMENT.getKey())) { + orderDto.setAmount(new BigDecimal(payAmount)); + orderDto.setPayAmount(new BigDecimal(payAmount)); + orderDto.setDiscount(new BigDecimal("0")); + } + + // 会员升级订单 + if (orderDto.getType().equals(OrderTypeEnum.MEMBER.getKey())) { + orderDto.setParam(targetId.toString()); + orderDto.setCouponId(couponId); + MtUserGrade userGrade = userGradeService.queryUserGradeById(merchantId, targetId, orderDto.getUserId()); + if (userGrade != null) { + orderDto.setRemark("付费升级" + userGrade.getName()); + orderDto.setAmount(new BigDecimal(userGrade.getCatchValue().toString())); + } + } + + // 商品订单 + if (orderDto.getType().equals(OrderTypeEnum.GOOGS.getKey())) { + orderDto.setCouponId(couponId); + } + + // 商品订单且配送要加上配送费用 + if (orderDto.getType().equals(OrderTypeEnum.GOOGS.getKey()) && orderDto.getOrderMode().equals(OrderModeEnum.EXPRESS.getKey())) { + MtSetting mtSetting = settingService.querySettingByName(merchantId, OrderSettingEnum.DELIVERY_FEE.getKey()); + if (mtSetting != null && StringUtil.isNotEmpty(mtSetting.getValue())) { + BigDecimal deliveryFee = new BigDecimal(mtSetting.getValue()); + if (deliveryFee.compareTo(new BigDecimal("0")) > 0) { + orderDto.setDeliveryFee(deliveryFee); + } + } + } + + // 使用积分抵扣 + if (usePoint > 0) { + List settingList = settingService.getSettingList(merchantId, SettingTypeEnum.POINT.getKey()); + String canUsedAsMoney = "false"; + String exchangeNeedPoint = "0"; + for (MtSetting setting : settingList) { + if (setting.getName().equals("canUsedAsMoney")) { + canUsedAsMoney = setting.getValue(); + } else if (setting.getName().equals("exchangeNeedPoint")) { + exchangeNeedPoint = setting.getValue(); + } + } + // 是否可以使用积分,并且积分数量足够 + if (canUsedAsMoney.equals("true") && Float.parseFloat(exchangeNeedPoint) > 0 && (userInfo.getPoint() >= usePoint)) { + orderDto.setUsePoint(usePoint); + orderDto.setPointAmount(new BigDecimal(usePoint).divide(new BigDecimal(exchangeNeedPoint), BigDecimal.ROUND_CEILING, 3)); + if (orderDto.getPayAmount().compareTo(orderDto.getPointAmount()) > 0) { + orderDto.setPayAmount(orderDto.getPayAmount().subtract(orderDto.getPointAmount())); + } else { + orderDto.setPayAmount(new BigDecimal("0")); + } + } + } + + // 首先生成订单,拿到订单ID + MtOrder orderInfo; + try { + orderInfo = saveOrder(orderDto); + } catch (BusinessCheckException e) { + throw new BusinessCheckException(e.getMessage() == null ? "生成订单失败" : e.getMessage()); + } + + orderDto.setId(orderInfo.getId()); + param.setOrderId(orderInfo.getId()); + + // 收银台实付金额、优惠金额 + if ((StringUtil.isNotEmpty(cashierPayAmount) || StringUtil.isNotEmpty(cashierDiscountAmount)) && StringUtil.isNotEmpty(operator)) { + OrderDto reqOrder = new OrderDto(); + reqOrder.setId(orderInfo.getId()); + if (orderInfo.getAmount().compareTo(new BigDecimal("0")) <= 0) { + reqOrder.setAmount(new BigDecimal(cashierPayAmount).add(new BigDecimal(cashierDiscountAmount))); + } else { + reqOrder.setAmount(orderInfo.getAmount()); + } + if (new BigDecimal(cashierDiscountAmount).compareTo(new BigDecimal("0")) > 0) { + reqOrder.setDiscount(new BigDecimal(cashierDiscountAmount).add(orderInfo.getDiscount())); + } else { + reqOrder.setDiscount(orderInfo.getDiscount()); + } +// BigDecimal realPayAmount = reqOrder.getAmount().subtract(reqOrder.getDiscount()); +// if (realPayAmount.compareTo(new BigDecimal("0")) < 0) { +// realPayAmount = new BigDecimal("0"); +// } +// reqOrder.setPayAmount(realPayAmount); + reqOrder.setPayAmount(new BigDecimal(cashierPayAmount)); + updateOrder(reqOrder); + orderInfo = getOrderInfo(orderInfo.getId()); + } + + // 订单中使用卡券抵扣(付款订单、会员升级订单) + if (couponId > 0 && (orderDto.getType().equals(OrderTypeEnum.PAYMENT.getKey())) || orderDto.getType().equals(OrderTypeEnum.MEMBER.getKey())) { + if (orderDto.getAmount().compareTo(new BigDecimal("0")) > 0) { + MtUserCoupon userCouponInfo = userCouponService.getUserCouponDetail(couponId); + if (userCouponInfo != null) { + MtCoupon couponInfo = couponService.queryCouponById(userCouponInfo.getCouponId()); + if (couponInfo != null) { + boolean isEffective = couponService.isCouponEffective(couponInfo, userCouponInfo); + if (isEffective && userCouponInfo.getUserId().equals(orderDto.getUserId())) { + // 优惠券,直接减去优惠券金额 + if (couponInfo.getType().equals(CouponTypeEnum.COUPON.getKey())) { + // 检查是否会员升级专用卡券 + boolean canUse = true; + if (couponInfo.getUseFor() != null && StringUtil.isNotEmpty(couponInfo.getUseFor())) { + if (orderDto.getType().equals(OrderTypeEnum.MEMBER.getKey())) { + if (!couponInfo.getUseFor().equals(CouponUseForEnum.MEMBER_GRADE.getKey())) { + canUse = false; + } + } + } + if (canUse) { + String useCode = couponService.useCoupon(couponId, orderDto.getUserId(), orderDto.getStoreId(), orderInfo.getId(), userCouponInfo.getAmount(), "核销"); + if (StringUtil.isNotEmpty(useCode)) { + orderDto.setCouponId(couponId); + orderDto.setDiscount(orderInfo.getDiscount().add(userCouponInfo.getAmount())); + updateOrder(orderDto); + } + } + } else if(couponInfo.getType().equals(CouponTypeEnum.PRESTORE.getKey())) { + // 储值卡,减去余额 + BigDecimal useCouponAmount = userCouponInfo.getBalance(); + if (orderInfo.getPayAmount().compareTo(userCouponInfo.getBalance()) <= 0) { + useCouponAmount = orderInfo.getPayAmount(); + } + try { + String useCode = couponService.useCoupon(couponId, orderDto.getUserId(), orderDto.getStoreId(), orderInfo.getId(), useCouponAmount, "核销"); + if (StringUtil.isNotEmpty(useCode)) { + orderDto.setCouponId(couponId); + orderDto.setDiscount(orderInfo.getDiscount().add(useCouponAmount)); + orderDto.setPayAmount(orderInfo.getPayAmount().subtract(useCouponAmount)); + updateOrder(orderDto); + } + } catch (BusinessCheckException e) { + throw new BusinessCheckException(e.getMessage() == null ? "生成订单失败" : e.getMessage()); + } + } + } + } + } + } + } + + // 生成支付订单 + orderInfo = getOrderInfo(orderInfo.getId()); + String ip = CommonUtil.getIPFromHttpRequest(request); +// BigDecimal realPayAmount = orderInfo.getAmount().subtract(new BigDecimal(orderInfo.getDiscount().toString())).subtract(new BigDecimal(orderInfo.getPointAmount().toString())).add(orderInfo.getDeliveryFee()); + BigDecimal realPayAmount = orderInfo.getPayAmount(); + + // 支付类的订单,检查余额是否充足 + if (type.equals(OrderTypeEnum.PAYMENT.getKey()) && payType.equals(PayTypeEnum.BALANCE.getKey())) { + if (userInfo.getBalance() == null || realPayAmount.compareTo(userInfo.getBalance()) > 0) { + throw new BusinessCheckException("会员余额不足"); + } + if (StringUtil.isNotEmpty(cashierPayAmount)) { + if (userInfo.getBalance() == null || new BigDecimal(cashierPayAmount).compareTo(userInfo.getBalance()) > 0) { + throw new BusinessCheckException("会员余额不足"); + } + } + } + + ResponseObject paymentInfo = null; + String errorMessage = ""; + + // 应付金额大于0才提交微信支付 + if (realPayAmount.compareTo(new BigDecimal("0")) > 0) { + if (payType.equals(PayTypeEnum.CASH.getKey()) && StringUtil.isNotEmpty(operator)) { + // 收银台现金支付,更新为已支付 + setOrderPayed(orderInfo.getId(), null); + } else if(payType.equals(PayTypeEnum.BALANCE.getKey())) { + // 余额支付 + MtBalance balance = new MtBalance(); + balance.setMobile(userInfo.getMobile()); + balance.setOrderSn(orderInfo.getOrderSn()); + balance.setUserId(userInfo.getId()); + balance.setMerchantId(userInfo.getMerchantId()); + BigDecimal balanceAmount = realPayAmount.subtract(realPayAmount).subtract(realPayAmount); + balance.setAmount(balanceAmount); + boolean isPay = balanceService.addBalance(balance, true); + if (isPay) { + setOrderPayed(orderInfo.getId(), realPayAmount); + } else { + errorMessage = PropertiesUtil.getResponseErrorMessageByCode(5001); + } + } else { + BigDecimal wxPayAmount = realPayAmount.multiply(new BigDecimal("100")); + // 扫码支付,先返回不处理,后面拿到支付二维码再处理 + if ((payType.equals(PayTypeEnum.MICROPAY.getKey()) || payType.equals(PayTypeEnum.ALISCAN.getKey())) && StringUtil.isEmpty(authCode)) { + paymentInfo = new ResponseObject(200, "请求成功", new HashMap<>()); + } else { + paymentInfo = paymentService.createPrepayOrder(userInfo, orderInfo, (wxPayAmount.intValue()), authCode, 0, ip, platform); + } + if (paymentInfo.getData() == null) { + errorMessage = StringUtil.isNotEmpty(paymentInfo.getMessage()) ? paymentInfo.getMessage() : PropertiesUtil.getResponseErrorMessageByCode(3000); + } + } + } else { + // 应付金额是0,直接更新为已支付 + setOrderPayed(orderInfo.getId(), null); + } + + orderInfo = getOrderInfo(orderInfo.getId()); + Map outParams = new HashMap(); + outParams.put("isCreated", true); + outParams.put("orderInfo", orderInfo); + + if (paymentInfo != null) { + outParams.put("payment", paymentInfo.getData()); + outParams.put("payType", payType); + } else { + outParams.put("payment", null); + outParams.put("payType", "BALANCE"); + } + + // 1分钟后发送小程序订阅消息 + Date nowTime = new Date(); + Date sendTime = new Date(nowTime.getTime() + 60000); + Map params = new HashMap<>(); + String dateTime = DateUtil.formatDate(Calendar.getInstance().getTime(), "yyyy-MM-dd HH:mm"); + params.put("time", dateTime); + params.put("orderSn", orderInfo.getOrderSn()); + params.put("remark", "您的订单已生成,请留意~"); + weixinService.sendSubscribeMessage(merchantId, userInfo.getId(), userInfo.getOpenId(), WxMessageEnum.ORDER_CREATED.getKey(), "pages/order/index", params, sendTime); + + if (StringUtil.isNotEmpty(errorMessage)) { + throw new BusinessCheckException(errorMessage); + } else { + return outParams; + } + } + + /** + * 获取订单详情 + * + * @param orderId 订单ID + * @throws BusinessCheckException + * @return + */ + @Override + public MtOrder getOrderInfo(Integer orderId) { + return mtOrderMapper.selectById(orderId); + } + + /** + * 根据ID获取订单详情 + * + * @param orderId 订单ID + * @throws BusinessCheckException + * @return + */ + @Override + public UserOrderDto getOrderById(Integer orderId) throws BusinessCheckException { + MtOrder mtOrder = mtOrderMapper.selectById(orderId); + return getOrderDetail(mtOrder, true, true); + } + + /** + * 根据ID获取我的订单详情 + * + * @param orderId 订单ID + * @throws BusinessCheckException + * @return + */ + @Override + public UserOrderDto getMyOrderById(Integer orderId) throws BusinessCheckException { + MtOrder mtOrder = mtOrderMapper.selectById(orderId); + UserOrderDto orderInfo = getOrderDetail(mtOrder, true, true); + + // 售后订单 + MtRefund refund = refundService.getRefundByOrderId(orderId); + orderInfo.setRefundInfo(refund); + + orderInfo.setVerifyCode(mtOrder.getVerifyCode()); + return orderInfo; + } + + /** + * 取消订单 + * + * @param orderId 订单ID + * @param remark 取消备注 + * @throws BusinessCheckException + * @return + * */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "取消订单") + public MtOrder cancelOrder(Integer orderId, String remark) throws BusinessCheckException { + MtOrder mtOrder = mtOrderMapper.selectById(orderId); + + if (mtOrder != null && mtOrder.getStatus().equals(OrderStatusEnum.CREATED.getKey()) && mtOrder.getPayStatus().equals(PayStatusEnum.WAIT.getKey())) { + if (StringUtil.isNotEmpty(remark)) { + mtOrder.setRemark(remark); + } + + mtOrder.setStatus(OrderStatusEnum.CANCEL.getKey()); + mtOrderMapper.updateById(mtOrder); + + // 返还积分 + if (mtOrder.getPointAmount() != null && mtOrder.getUsePoint() > 0) { + MtPoint reqPointDto = new MtPoint(); + reqPointDto.setUserId(mtOrder.getUserId()); + reqPointDto.setAmount(mtOrder.getUsePoint()); + reqPointDto.setDescription("订单取消" + mtOrder.getOrderSn() + "退回"+ mtOrder.getUsePoint() +"积分"); + reqPointDto.setOrderSn(mtOrder.getOrderSn()); + reqPointDto.setOperator(""); + pointService.addPoint(reqPointDto); + } + + // 返还卡券 + List confirmLogList = mtConfirmLogMapper.getOrderConfirmLogList(mtOrder.getId()); + if (confirmLogList.size() > 0) { + for (MtConfirmLog log : confirmLogList) { + MtCoupon couponInfo = couponService.queryCouponById(log.getCouponId()); + MtUserCoupon userCouponInfo = mtUserCouponMapper.selectById(log.getUserCouponId()); + + if (userCouponInfo != null) { + // 优惠券直接置为未使用 + if (couponInfo.getType().equals(CouponTypeEnum.COUPON.getKey())) { + userCouponInfo.setStatus(UserCouponStatusEnum.UNUSED.getKey()); + mtUserCouponMapper.updateById(userCouponInfo); + } + + // 储值卡把余额加回去 + if (couponInfo.getType().equals(CouponTypeEnum.PRESTORE.getKey())) { + BigDecimal balance = userCouponInfo.getBalance(); + BigDecimal newBalance = balance.add(log.getAmount()); + if (newBalance.compareTo(userCouponInfo.getAmount()) <= 0) { + userCouponInfo.setBalance(newBalance); + userCouponInfo.setStatus(UserCouponStatusEnum.UNUSED.getKey()); + } + mtUserCouponMapper.updateById(userCouponInfo); + } + + // 撤销核销记录 + log.setStatus(StatusEnum.DISABLE.getKey()); + mtConfirmLogMapper.updateById(log); + } + } + } + + // 返还库存 + Map params = new HashMap<>(); + params.put("ORDER_ID", mtOrder.getId()); + List orderGoodsList = mtOrderGoodsMapper.selectByMap(params); + if (orderGoodsList != null && orderGoodsList.size() > 0) { + for (MtOrderGoods mtOrderGoods : orderGoodsList) { + MtGoods mtGoods = mtGoodsMapper.selectById(mtOrderGoods.getGoodsId()); + // 商品已不存在 + if (mtGoods == null) { + continue; + } + mtGoods.setStock(mtOrderGoods.getNum() + mtGoods.getStock()); + mtGoodsMapper.updateById(mtGoods); + if (mtOrderGoods.getSkuId() != null && mtOrderGoods.getSkuId() > 0) { + MtGoodsSku mtGoodsSku = mtGoodsSkuMapper.selectById(mtOrderGoods.getSkuId()); + if (mtGoodsSku != null && mtGoodsSku.getStock() != null && mtOrderGoods.getNum() != null) { + mtGoodsSku.setStock(mtGoodsSku.getStock() + mtOrderGoods.getNum()); + mtGoodsSkuMapper.updateById(mtGoodsSku); + } + } + } + } + } + + return mtOrder; + } + + /** + * 根据订单ID删除 + * + * @param orderId 订单ID + * @param operator 操作人 + * @return + */ + @Override + @OperationServiceLog(description = "删除订单信息") + public void deleteOrder(Integer orderId, String operator) { + MtOrder mtOrder = mtOrderMapper.selectById(orderId); + if (mtOrder == null) { + return; + } + + mtOrder.setStatus(OrderStatusEnum.DELETED.getKey()); + mtOrder.setUpdateTime(new Date()); + mtOrder.setOperator(operator); + + mtOrderMapper.updateById(mtOrder); + } + + /** + * 根据订单号获取订单详情 + * + * @param orderSn 订单号 + * @throws BusinessCheckException + * @return + */ + @Override + public UserOrderDto getOrderByOrderSn(String orderSn) throws BusinessCheckException { + MtOrder orderInfo = mtOrderMapper.findByOrderSn(orderSn); + if (orderInfo == null) { + return null; + } + return getOrderDetail(orderInfo, true, true); + } + + /** + * 更新订单 + * + * @param orderDto 订单参数 + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "更新订单信息") + public MtOrder updateOrder(OrderDto orderDto) throws BusinessCheckException { + MtOrder mtOrder = mtOrderMapper.selectById(orderDto.getId()); + if (null == mtOrder || OrderStatusEnum.DELETED.getKey().equals(mtOrder.getStatus())) { + throw new BusinessCheckException("该订单状态异常"); + } + + mtOrder.setId(orderDto.getId()); + mtOrder.setUpdateTime(new Date()); + + if (null != orderDto.getOperator()) { + mtOrder.setOperator(orderDto.getOperator()); + } + + if (null != orderDto.getStatus()) { + if (orderDto.getStatus().equals(OrderStatusEnum.CANCEL.getKey()) || orderDto.getStatus().equals(OrderStatusEnum.CREATED.getKey())) { + orderDto.setPayStatus(PayStatusEnum.WAIT.getKey()); + } + if (orderDto.getStatus().equals(OrderStatusEnum.CANCEL.getKey())) { + cancelOrder(orderDto.getId(), "取消订单"); + } else { + mtOrder.setStatus(orderDto.getStatus()); + } + if (orderDto.getStatus().equals(OrderStatusEnum.PAID.getKey())) { + mtOrder.setPayStatus(PayStatusEnum.SUCCESS.getKey()); + mtOrder.setPayTime(new Date()); + } + } + + if (null != orderDto.getPayAmount()) { + mtOrder.setPayAmount(orderDto.getPayAmount()); + } + + if (null != orderDto.getAmount()) { + mtOrder.setAmount(orderDto.getAmount()); + } + + if (null != orderDto.getVerifyCode() && StringUtil.isNotEmpty(orderDto.getVerifyCode())) { + if (orderDto.getVerifyCode().equals(mtOrder.getVerifyCode())) { + mtOrder.setStatus(OrderStatusEnum.DELIVERED.getKey()); + mtOrder.setVerifyCode(""); + } else { + throw new BusinessCheckException("核销码错误,请确认!"); + } + } + + if (null != orderDto.getDiscount()) { + mtOrder.setDiscount(orderDto.getDiscount()); + } + + if (null != orderDto.getPayTime()) { + mtOrder.setPayTime(orderDto.getPayTime()); + } + + if (null != orderDto.getPayStatus()) { + mtOrder.setPayStatus(orderDto.getPayStatus()); + } + + if (null != orderDto.getExpressInfo()) { + mtOrder.setExpressInfo(JSONObject.toJSONString(orderDto.getExpressInfo())); + } + + if (null != orderDto.getOrderMode()) { + mtOrder.setOrderMode(orderDto.getOrderMode()); + } + + if (null != orderDto.getRemark()) { + mtOrder.setRemark(orderDto.getRemark()); + } + + mtOrderMapper.updateById(mtOrder); + return mtOrder; + } + + /** + * 更新订单 + * + * @param mtOrder 订单信息 + * @return + * */ + @Override + @Transactional(rollbackFor = Exception.class) + public MtOrder updateOrder(MtOrder mtOrder) { + mtOrder.setUpdateTime(new Date()); + Integer id = mtOrderMapper.updateById(mtOrder); + if (id > 0) { + mtOrder = mtOrderMapper.selectById(mtOrder.getId()); + } + return mtOrder; + } + + /** + * 把订单置为已支付 + * + * @param orderId 订单ID + * @param payAmount 支付金额 + * @throws BusinessCheckException + * @return + * */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "修改订单为已支付") + public Boolean setOrderPayed(Integer orderId, BigDecimal payAmount) throws BusinessCheckException { + MtOrder mtOrder = mtOrderMapper.selectById(orderId); + if (mtOrder == null) { + return false; + } + if (mtOrder.getPayStatus().equals(PayStatusEnum.SUCCESS.getKey())) { + return true; + } + OrderDto reqDto = new OrderDto(); + reqDto.setId(orderId); + reqDto.setStatus(OrderStatusEnum.PAID.getKey()); + reqDto.setPayStatus(PayStatusEnum.SUCCESS.getKey()); + if (payAmount != null) { + reqDto.setPayAmount(payAmount); + } + reqDto.setPayTime(new Date()); + reqDto.setUpdateTime(new Date()); + updateOrder(reqDto); + + // 处理购物订单 + UserOrderDto orderInfo = getOrderByOrderSn(mtOrder.getOrderSn()); + if (orderInfo.getType().equals(OrderTypeEnum.GOOGS.getKey())) { + try { + List goodsList = orderInfo.getGoods(); + if (goodsList != null && goodsList.size() > 0) { + for (OrderGoodsDto goodsDto : goodsList) { + MtGoods mtGoods = goodsService.queryGoodsById(goodsDto.getGoodsId()); + if (mtGoods != null) { + // 购买虚拟卡券商品发放处理 + if (mtGoods.getType().equals(GoodsTypeEnum.COUPON.getKey()) && mtGoods.getCouponIds() != null && StringUtil.isNotEmpty(mtGoods.getCouponIds())) { + String couponIds[] = mtGoods.getCouponIds().split(","); + if (couponIds.length > 0) { + for (int i = 0; i < couponIds.length; i++) { + userCouponService.buyCouponItem(orderInfo.getId(), Integer.parseInt(couponIds[i]), orderInfo.getUserId(), orderInfo.getUserInfo().getMobile()); + } + } + } + // 将已销售数量+1 + goodsService.updateInitSale(mtGoods.getId()); + } + } + } + } catch (BusinessCheckException e) { + logger.error("会员购买的卡券发送给会员失败......" + e.getMessage()); + } + } + + // 处理消费返积分,查询返1积分所需消费金额 + MtSetting setting = settingService.querySettingByName(mtOrder.getMerchantId(), "pointNeedConsume"); + if (setting != null && !orderInfo.getPayType().equals(PayTypeEnum.BALANCE.getKey()) && orderInfo.getIsVisitor().equals(YesOrNoEnum.NO.getKey())) { + String needPayAmount = setting.getValue(); + Integer needPayAmountInt = Math.round(Integer.parseInt(needPayAmount)); + Double pointNum = 0d; + if (needPayAmountInt > 0 && orderInfo.getPayAmount().compareTo(new BigDecimal(needPayAmountInt)) > 0) { + BigDecimal point = orderInfo.getPayAmount().divide(new BigDecimal(needPayAmountInt), BigDecimal.ROUND_CEILING, 3); + pointNum = Math.ceil(point.doubleValue()); + } + logger.info("PaymentService paymentCallback Point orderSn = {} , pointNum ={}", orderInfo.getOrderSn(), pointNum); + if (pointNum > 0) { + MtUser userInfo = memberService.queryMemberById(orderInfo.getUserId()); + MtUserGrade userGrade = userGradeService.queryUserGradeById(orderInfo.getMerchantId(), Integer.parseInt(userInfo.getGradeId()), orderInfo.getUserId()); + // 是否会员积分加倍 + if (userGrade != null && userGrade.getSpeedPoint() > 1) { + pointNum = pointNum * userGrade.getSpeedPoint(); + } + MtPoint reqPointDto = new MtPoint(); + reqPointDto.setAmount(pointNum.intValue()); + reqPointDto.setUserId(orderInfo.getUserId()); + reqPointDto.setOrderSn(orderInfo.getOrderSn()); + reqPointDto.setDescription("支付¥"+orderInfo.getPayAmount()+"返"+pointNum+"积分"); + reqPointDto.setOperator("系统"); + pointService.addPoint(reqPointDto); + } + } + + // 计算是否要升级(购物订单、付款订单、充值订单) + if (orderInfo.getIsVisitor().equals(YesOrNoEnum.NO.getKey()) && orderInfo.getType().equals(OrderTypeEnum.GOOGS.getKey()) || orderInfo.getType().equals(OrderTypeEnum.PAYMENT.getKey()) || orderInfo.getType().equals(OrderTypeEnum.RECHARGE.getKey())) { + try { + if (orderInfo.getIsVisitor().equals(YesOrNoEnum.NO.getKey())) { + Map param = new HashMap<>(); + param.put("status", StatusEnum.ENABLED.getKey()); + MtUser mtUser = memberService.queryMemberById(orderInfo.getUserId()); + MtUserGrade mtUserGrade = mtUserGradeMapper.selectById(mtUser.getGradeId()); + if (mtUserGrade == null) { + mtUserGrade = userGradeService.getInitUserGrade(orderInfo.getMerchantId()); + } + List userGradeList = mtUserGradeMapper.selectByMap(param); + if (mtUserGrade != null && userGradeList != null && userGradeList.size() > 0) { + // 会员已支付金额 + BigDecimal payMoney = getUserPayMoney(orderInfo.getUserId()); + // 会员支付订单笔数 + Integer payOrderCount = getUserPayOrderCount(orderInfo.getUserId()); + BigDecimal payOrderCountValue = new BigDecimal(payOrderCount); + for (MtUserGrade grade : userGradeList) { + if (grade.getCatchValue() != null && grade.getCatchType() != null) { + // 累计消费金额已达到 + if (grade.getCatchType().equals(UserGradeCatchTypeEnum.AMOUNT.getKey())) { + if (grade.getGrade().compareTo(mtUserGrade.getGrade()) > 0 && payMoney.compareTo(grade.getCatchValue()) >= 0) { + openGiftService.openGift(mtOrder.getUserId(), grade.getId(), false); + } + } + // 累计消费次数已达到 + if (grade.getCatchType().equals(UserGradeCatchTypeEnum.FREQUENCY.getKey()) && payOrderCountValue.compareTo(grade.getCatchValue()) >= 0) { + if (grade.getGrade().compareTo(mtUserGrade.getGrade()) > 0) { + openGiftService.openGift(mtOrder.getUserId(), grade.getId(), false); + } + } + } + } + } + } + } catch (Exception ex) { + logger.error("会员升级出错啦,userId = {},message = {}", orderInfo.getUserId(), ex.getMessage()); + } + } + + // 给商家发送通知短信 +// try { +// MtStore mtStore = storeService.queryStoreById(mtOrder.getStoreId()); +// if (mtStore != null && orderInfo.getIsVisitor().equals(YesOrNoEnum.NO.getKey())) { +// Map params = new HashMap<>(); +// params.put("orderSn", mtOrder.getOrderSn()); +// List mobileList = new ArrayList<>(); +// mobileList.add(mtStore.getPhone()); +// sendSmsService.sendSms(mtOrder.getMerchantId(), "new-order", mobileList, params); +// } +// } catch (Exception e) { +// // empty +// } + + return true; + } + + /** + * 根据条件搜索订单 + * + * @param params 查询参数 + * @return + * */ + @Override + public List getOrderListByParams(Map params) { + List result = mtOrderMapper.selectByMap(params); + return result; + } + + /** + * 处理订单详情 + * + * @param orderInfo 订单信息 + * @param needAddress 是否获取订单地址 + * @param getPayStatus 是否获取支付状态 + * @return UserOrderDto + * */ + private UserOrderDto getOrderDetail(MtOrder orderInfo, boolean needAddress, boolean getPayStatus) throws BusinessCheckException { + UserOrderDto dto = new UserOrderDto(); + + dto.setId(orderInfo.getId()); + dto.setMerchantId(orderInfo.getMerchantId()); + dto.setUserId(orderInfo.getUserId()); + dto.setCouponId(orderInfo.getCouponId()); + dto.setOrderSn(orderInfo.getOrderSn()); + dto.setRemark(orderInfo.getRemark()); + dto.setType(orderInfo.getType()); + dto.setPayType(orderInfo.getPayType()); + dto.setOrderMode(orderInfo.getOrderMode()); + dto.setCreateTime(DateUtil.formatDate(orderInfo.getCreateTime(), "yyyy.MM.dd HH:mm")); + dto.setUpdateTime(DateUtil.formatDate(orderInfo.getUpdateTime(), "yyyy.MM.dd HH:mm")); + dto.setAmount(orderInfo.getAmount()); + dto.setIsVisitor(orderInfo.getIsVisitor()); + dto.setStaffId(orderInfo.getStaffId()); + dto.setVerifyCode(""); + dto.setDeliveryFee(orderInfo.getDeliveryFee()); + dto.setOperator(orderInfo.getOperator()); + dto.setStoreLocationId(orderInfo.getStoreLocationId()); + dto.setPrePayment(orderInfo.getPrePayment()); + + // 核销码为空,说明已经核销 + if (orderInfo.getVerifyCode() == null || StringUtil.isEmpty(orderInfo.getVerifyCode())) { + dto.setIsVerify(true); + } else { + dto.setIsVerify(false); + } + + if (orderInfo.getPayAmount() != null) { + dto.setPayAmount(orderInfo.getPayAmount()); + } else { + dto.setPayAmount(new BigDecimal("0")); + } + + if (orderInfo.getDiscount() != null) { + dto.setDiscount(orderInfo.getDiscount()); + } else { + dto.setDiscount(new BigDecimal("0")); + } + + if (orderInfo.getPointAmount() != null) { + dto.setPointAmount(orderInfo.getPointAmount()); + } else { + dto.setPointAmount(new BigDecimal("0")); + } + + dto.setStatus(orderInfo.getStatus()); + dto.setParam(orderInfo.getParam()); + dto.setPayStatus(orderInfo.getPayStatus()); + + if (orderInfo.getUsePoint() != null) { + dto.setUsePoint(orderInfo.getUsePoint()); + } else { + dto.setUsePoint(0); + } + if (orderInfo.getPayTime() != null) { + dto.setPayTime(DateUtil.formatDate(orderInfo.getPayTime(), "yyyy.MM.dd HH:mm")); + } + + if (dto.getType().equals(OrderTypeEnum.PRESTORE.getKey())) { + dto.setTypeName(OrderTypeEnum.PRESTORE.getValue()); + } else if(dto.getType().equals(OrderTypeEnum.PAYMENT.getKey())) { + dto.setTypeName(OrderTypeEnum.PAYMENT.getValue()); + } else if(dto.getType().equals(OrderTypeEnum.GOOGS.getKey())) { + dto.setTypeName(OrderTypeEnum.GOOGS.getValue()); + } else if(dto.getType().equals(OrderTypeEnum.MEMBER.getKey())) { + dto.setTypeName(OrderTypeEnum.MEMBER.getValue()); + } else if(dto.getType().equals(OrderTypeEnum.RECHARGE.getKey())) { + dto.setTypeName(OrderTypeEnum.RECHARGE.getValue()); + } + + if (dto.getStatus().equals(OrderStatusEnum.CREATED.getKey())) { + dto.setStatusText(OrderStatusEnum.CREATED.getValue()); + } else if(dto.getStatus().equals(OrderStatusEnum.CANCEL.getKey())) { + dto.setStatusText(OrderStatusEnum.CANCEL.getValue()); + } else if(dto.getStatus().equals(OrderStatusEnum.PAID.getKey())) { + dto.setStatusText(OrderStatusEnum.PAID.getValue()); + } else if(dto.getStatus().equals(OrderStatusEnum.DELIVERY.getKey())) { + dto.setStatusText(OrderStatusEnum.DELIVERY.getValue()); + } else if(dto.getStatus().equals(OrderStatusEnum.DELIVERED.getKey())) { + dto.setStatusText(OrderStatusEnum.DELIVERED.getValue()); + } else if(dto.getStatus().equals(OrderStatusEnum.RECEIVED.getKey())) { + dto.setStatusText(OrderStatusEnum.RECEIVED.getValue()); + } else if(dto.getStatus().equals(OrderStatusEnum.DELETED.getKey())) { + dto.setStatusText(OrderStatusEnum.DELETED.getValue()); + } else if(dto.getStatus().equals(OrderStatusEnum.REFUND.getKey())) { + dto.setStatusText(OrderStatusEnum.REFUND.getValue()); + } + + // 订单所属店铺 + MtStore storeInfo = storeService.queryStoreById(orderInfo.getStoreId()); + dto.setStoreInfo(storeInfo); + + // 下单用户信息直接取会员个人信息 + OrderUserDto userInfo = new OrderUserDto(); + MtUser user = memberService.queryMemberById2(orderInfo.getUserId()); + + if (user != null) { + userInfo.setId(user.getId()); + userInfo.setName(user.getName()); + userInfo.setUserNo(user.getUserNo()); + userInfo.setMobile(user.getMobile()); + userInfo.setCardNo(user.getCarNo()); + userInfo.setAddress(user.getAddress()); + dto.setUserInfo(userInfo); + } + + List goodsList = new ArrayList<>(); + + String baseImage = settingService.getUploadBasePath(); + + // 储值卡的订单 + if (orderInfo.getType().equals(OrderTypeEnum.PRESTORE.getKey())) { + MtCoupon coupon = couponService.queryCouponById(orderInfo.getCouponId()); + String[] paramArr = orderInfo.getParam().split(","); + for(int i = 0; i < paramArr.length; i++) { + String[] item = paramArr[i].split("_"); + if (Integer.parseInt(item[2]) > 0) { + OrderGoodsDto goodsDto = new OrderGoodsDto(); + goodsDto.setId(coupon.getId()); + goodsDto.setType(OrderTypeEnum.PRESTORE.getKey()); + goodsDto.setName("预存¥" + item[0] + "到账¥" + item[1]); + goodsDto.setNum(Integer.parseInt(item[2])); + goodsDto.setPrice(item[0]); + goodsDto.setDiscount("0"); + if (coupon.getImage().indexOf(baseImage) == -1) { + goodsDto.setImage(baseImage + coupon.getImage()); + } + goodsList.add(goodsDto); + } + } + } + // 商品订单 + if (orderInfo.getType().equals(OrderTypeEnum.GOOGS.getKey())) { + Map params = new HashMap<>(); + params.put("ORDER_ID", orderInfo.getId()); + List orderGoodsList = mtOrderGoodsMapper.selectByMap(params); + for (MtOrderGoods orderGoods : orderGoodsList) { + MtGoods goodsInfo = mtGoodsMapper.selectById(orderGoods.getGoodsId()); + if (goodsInfo != null) { + OrderGoodsDto orderGoodsDto = new OrderGoodsDto(); + orderGoodsDto.setId(orderGoods.getId()); + orderGoodsDto.setName(goodsInfo.getName()); + if (!goodsInfo.getLogo().contains(baseImage)) { + orderGoodsDto.setImage(baseImage + goodsInfo.getLogo()); + } + orderGoodsDto.setType(OrderTypeEnum.GOOGS.getKey()); + orderGoodsDto.setNum(orderGoods.getNum()); + orderGoodsDto.setSkuId(orderGoods.getSkuId()); + orderGoodsDto.setPrice(orderGoods.getPrice().toString()); + orderGoodsDto.setDiscount(orderGoods.getDiscount().toString()); + orderGoodsDto.setGoodsId(orderGoods.getGoodsId()); + if (orderGoods.getSkuId() > 0) { + List specList = goodsService.getSpecListBySkuId(orderGoods.getSkuId()); + orderGoodsDto.setSpecList(specList); + } + goodsList.add(orderGoodsDto); + } + } + } + // 配送地址 + if (orderInfo.getOrderMode().equals(OrderModeEnum.EXPRESS.getKey()) && needAddress) { + List orderAddressList = mtOrderAddressMapper.getOrderAddress(orderInfo.getId()); + MtOrderAddress orderAddress = null; + if (orderAddressList.size() > 0) { + orderAddress = orderAddressList.get(0); + } + if (orderAddress != null) { + AddressDto address = new AddressDto(); + address.setId(orderAddress.getId()); + address.setName(orderAddress.getName()); + address.setMobile(orderAddress.getMobile()); + address.setDetail(orderAddress.getDetail()); + address.setProvinceId(orderAddress.getProvinceId()); + address.setCityId(orderAddress.getCityId()); + address.setRegionId(orderAddress.getRegionId()); + + if (orderAddress.getProvinceId() > 0) { + MtRegion mtProvince = mtRegionMapper.selectById(orderAddress.getProvinceId()); + if (mtProvince != null) { + address.setProvinceName(mtProvince.getName()); + } + } + if (orderAddress.getCityId() > 0) { + MtRegion mtCity = mtRegionMapper.selectById(orderAddress.getCityId()); + if (mtCity != null) { + address.setCityName(mtCity.getName()); + } + } + if (orderAddress.getRegionId() > 0) { + MtRegion mtRegion = mtRegionMapper.selectById(orderAddress.getRegionId()); + if (mtRegion != null) { + address.setRegionName(mtRegion.getName()); + } + } + + dto.setAddress(address); + } + } + // 物流信息 + if (StringUtil.isNotEmpty(orderInfo.getExpressInfo())) { + JSONObject express = JSONObject.parseObject(orderInfo.getExpressInfo()); + ExpressDto expressInfo = new ExpressDto(); + expressInfo.setExpressNo(express.get("expressNo").toString()); + expressInfo.setExpressCompany(express.get("expressCompany").toString()); + expressInfo.setExpressTime(express.get("expressTime").toString()); + dto.setExpressInfo(expressInfo); + } + // 使用的卡券 + if (dto.getCouponId() != null && dto.getCouponId() > 0) { + MtUserCoupon mtUserCoupon = userCouponService.getUserCouponDetail(dto.getCouponId()); + if (mtUserCoupon != null) { + MtCoupon mtCoupon = couponService.queryCouponById(mtUserCoupon.getCouponId()); + if (mtCoupon != null) { + UserCouponDto couponInfo = new UserCouponDto(); + couponInfo.setId(mtUserCoupon.getId()); + couponInfo.setCouponId(mtCoupon.getId()); + couponInfo.setName(mtCoupon.getName()); + couponInfo.setAmount(mtUserCoupon.getAmount()); + couponInfo.setBalance(mtUserCoupon.getBalance()); + couponInfo.setStatus(mtUserCoupon.getStatus()); + couponInfo.setType(mtCoupon.getType()); + dto.setCouponInfo(couponInfo); + } + } + } + // 查询支付状态 + if (getPayStatus && !orderInfo.getPayStatus().equals(PayStatusEnum.SUCCESS.getKey())) { + // 微信支付 + if (orderInfo.getPayType().equals(PayTypeEnum.MICROPAY.getKey()) || orderInfo.getPayType().equals(PayTypeEnum.JSAPI.getKey())) { + try { + Map payResult = weixinService.queryPaidOrder(orderInfo.getStoreId(), "", orderInfo.getOrderSn()); + if (payResult != null && payResult.get("trade_state").equals("SUCCESS")) { + BigDecimal payAmount = new BigDecimal(payResult.get("total_fee")).divide(new BigDecimal("100")); + setOrderPayed(orderInfo.getId(), payAmount); + dto.setPayStatus(PayStatusEnum.SUCCESS.getKey()); + } + } catch (Exception e) { + // empty + } + } + // 支付宝支付 + if (orderInfo.getPayType().equals(PayTypeEnum.ALISCAN.getKey())) { + try { + Map payResult = alipayService.queryPaidOrder(orderInfo.getStoreId(), "", orderInfo.getOrderSn()); + if (payResult != null) { + BigDecimal payAmount = new BigDecimal(payResult.get("payAmount")); + setOrderPayed(orderInfo.getId(), payAmount); + dto.setPayStatus(PayStatusEnum.SUCCESS.getKey()); + } + } catch (Exception e) { + // empty + } + } + } + dto.setGoods(goodsList); + return dto; + } + + + /** + * 处理挂单详情 + * + * @param hangUpCartList 挂单信息 + * @return UserOrderDto + * */ + private UserOrderDto getHangUpOrderDetail(List hangUpCartList) throws BusinessCheckException { + UserOrderDto dto = new UserOrderDto(); + + dto.setId(hangUpCartList.get(0).getId()); + dto.setMerchantId(hangUpCartList.get(0).getMerchantId()); + dto.setUserId(hangUpCartList.get(0).getUserId()); + dto.setCouponId(0); + dto.setOrderSn(""); + dto.setRemark(""); + dto.setType(""); + dto.setPayType(""); + dto.setOrderMode(""); + dto.setCreateTime(DateUtil.formatDate(hangUpCartList.get(0).getCreateTime(), "yyyy.MM.dd HH:mm")); + dto.setUpdateTime(DateUtil.formatDate(hangUpCartList.get(0).getUpdateTime(), "yyyy.MM.dd HH:mm")); + + dto.setAmount(hangUpCartList.get(0).getPrePayment()); + dto.setPayAmount(hangUpCartList.get(0).getPrePayment()); + + dto.setIsVisitor(""); + dto.setStaffId(0); + dto.setVerifyCode(""); + dto.setDeliveryFee(new BigDecimal("0")); + dto.setOperator(""); + dto.setDiscount(new BigDecimal("0")); + dto.setPointAmount(new BigDecimal("0")); + dto.setStatus(""); + dto.setParam(""); + dto.setPayStatus(""); + dto.setUsePoint(0); + dto.setPayTime(DateUtil.formatDate(hangUpCartList.get(0).getCreateTime(), "yyyy.MM.dd HH:mm")); + dto.setTypeName("预付订单"); + dto.setStatusText("已预支付"); + + + // 订单所属店铺 + MtStore storeInfo = storeService.queryStoreById(hangUpCartList.get(0).getStoreId()); + dto.setStoreInfo(storeInfo); + + // 下单用户信息直接取会员个人信息 + OrderUserDto userInfo = new OrderUserDto(); + MtUser user = memberService.queryMemberById(hangUpCartList.get(0).getUserId()); + if (user != null) { + userInfo.setId(user.getId()); + userInfo.setName(user.getName()); + userInfo.setMobile(user.getMobile()); + userInfo.setCardNo(user.getCarNo()); + userInfo.setAddress(user.getAddress()); + dto.setUserInfo(userInfo); + } + + List goodsList = new ArrayList<>(); + + String baseImage = settingService.getUploadBasePath(); + + // 挂单商品信息 + for (MtCart cartInfo: hangUpCartList){ + MtGoods goodsInfo = mtGoodsMapper.selectById(cartInfo.getGoodsId()); + if (goodsInfo != null) { + OrderGoodsDto orderGoodsDto = new OrderGoodsDto(); + orderGoodsDto.setId(goodsInfo.getId()); + orderGoodsDto.setName(goodsInfo.getName()); + if (!goodsInfo.getLogo().contains(baseImage)) { + orderGoodsDto.setImage(baseImage + goodsInfo.getLogo()); + } + orderGoodsDto.setType(OrderTypeEnum.GOOGS.getKey()); + orderGoodsDto.setNum(cartInfo.getNum()); + orderGoodsDto.setSkuId(cartInfo.getSkuId()); + if (goodsInfo.getPrice().compareTo(BigDecimal.ZERO) == 0){ + orderGoodsDto.setPrice(cartInfo.getSelfPrice().toString()); + } else { + orderGoodsDto.setPrice(goodsInfo.getPrice().toString()); + } + + orderGoodsDto.setGoodsId(cartInfo.getGoodsId()); + if (cartInfo.getSkuId() > 0) { + List specList = goodsService.getSpecListBySkuId(cartInfo.getSkuId()); + orderGoodsDto.setSpecList(specList); + } + goodsList.add(orderGoodsDto); + } + } + + dto.setPayStatus(PayStatusEnum.SUCCESS.getKey()); + dto.setGoods(goodsList); + return dto; + } + + + + /** + * 获取订单总数 + * + * @param merchantId 商户ID + * @param storeId 店铺ID + * @return + * */ + @Override + public BigDecimal getOrderCount(Integer merchantId, Integer storeId) { + if (storeId > 0) { + return mtOrderMapper.getStoreOrderCount(storeId); + } else { + return mtOrderMapper.getOrderCount(merchantId); + } + } + + /** + * 获取订单数量 + * + * @param merchantId 商户ID + * @param storeId 店铺ID + * @param beginTime 开始时间 + * @param endTime 结束时间 + * @return + * */ + @Override + public BigDecimal getOrderCount(Integer merchantId, Integer storeId, Date beginTime, Date endTime) { + if (storeId > 0) { + return mtOrderMapper.getStoreOrderCountByTime(storeId, beginTime, endTime); + } else { + return mtOrderMapper.getOrderCountByTime(merchantId, beginTime, endTime); + } + } + + /** + * 获取支付金额 + * + * @param merchantId 商户ID + * @param storeId 店铺ID + * @param beginTime 开始时间 + * @param endTime 结束时间 + * @return + * */ + @Override + public BigDecimal getPayMoney(Integer merchantId, Integer storeId, Date beginTime, Date endTime) { + if (storeId > 0) { + return mtOrderMapper.getStorePayMoneyByTime(storeId, beginTime, endTime); + } else { + return mtOrderMapper.getPayMoneyByTime(merchantId, beginTime, endTime); + } + } + + /** + * 获取支付人数 + * + * @param merchantId 商户ID + * @param storeId 店铺ID + * @return + * */ + @Override + public Integer getPayUserCount(Integer merchantId, Integer storeId) { + if (storeId > 0) { + return mtOrderMapper.getStorePayUserCount(storeId); + } else { + return mtOrderMapper.getPayUserCount(merchantId); + } + } + + /** + * 获取支付总金额 + * + * @param merchantId 商户ID + * @param storeId 店铺ID + * @return + * */ + @Override + public BigDecimal getPayMoney(Integer merchantId, Integer storeId) { + if (storeId > 0) { + return mtOrderMapper.getStorePayMoney(storeId); + } else { + return mtOrderMapper.getPayMoney(merchantId); + } + } + + /** + * 计算商品总价 + * + * @param merchantId 商户ID + * @param userId 会员ID + * @param cartList 购物车列表 + * @param couponId 卡券ID + * @param isUsePoint 使用积分数量 + * @param orderMode 订单模式 + * @throws BusinessCheckException + * @return + * */ + @Override + public Map calculateCartGoods(Integer merchantId, Integer userId, List cartList, Integer couponId, boolean isUsePoint, String platform, String orderMode) throws BusinessCheckException { + MtUser userInfo = memberService.queryMemberById(userId); + + // 设置是否不能用积分抵扣 + MtSetting pointSetting = settingService.querySettingByName(merchantId, PointSettingEnum.CAN_USE_AS_MONEY.getKey()); + if (pointSetting != null && !pointSetting.getValue().equals("true")) { + isUsePoint = false; + } + + List cartDtoList = new ArrayList<>(); + String basePath = settingService.getUploadBasePath(); + Integer totalNum = 0; + BigDecimal totalPrice = new BigDecimal("0"); + BigDecimal totalCanUsePointAmount = new BigDecimal("0"); + + BigDecimal prePayment = new BigDecimal("0"); + + if (!cartList.isEmpty()) { + for (MtCart cart : cartList) { + // 购物车商品信息 + MtGoods mtGoodsInfo = goodsService.queryGoodsById(cart.getGoodsId()); + if (mtGoodsInfo == null || !mtGoodsInfo.getStatus().equals(StatusEnum.ENABLED.getKey())) { + continue; + } + + prePayment = cart.getPrePayment();// 预付金 + + totalNum = totalNum + cart.getNum(); + ResCartDto cartDto = new ResCartDto(); + cartDto.setId(cart.getId()); + cartDto.setGoodsId(cart.getGoodsId()); + cartDto.setNum(cart.getNum()); + cartDto.setSkuId(cart.getSkuId()); + cartDto.setUserId(cart.getUserId()); + + cartDto.setPrePayment(prePayment); // 预付金 + // for自定义商品价格 + if (mtGoodsInfo.getPrice().compareTo(new BigDecimal("0")) == 0){ + cartDto.setSelfPrice(cart.getSelfPrice()); + } + // 购物车是否有效 + Boolean isEffect = true; + if (cart.getSkuId() > 0) { + List specList = goodsService.getSpecListBySkuId(cart.getSkuId()); + cartDto.setSpecList(specList); + } + if (StringUtil.isNotEmpty(mtGoodsInfo.getLogo()) && (mtGoodsInfo.getLogo().indexOf(basePath) == -1)) { + mtGoodsInfo.setLogo(basePath + mtGoodsInfo.getLogo()); + } + // 读取sku的数据 + if (cart.getSkuId() > 0) { + MtGoods mtGoods = new MtGoods(); + BeanUtils.copyProperties(mtGoodsInfo, mtGoods); + MtGoodsSku mtGoodsSku = mtGoodsSkuMapper.selectById(cart.getSkuId()); + if (mtGoodsSku != null) { + if (StringUtil.isNotEmpty(mtGoodsSku.getLogo()) && (mtGoodsSku.getLogo().indexOf(basePath) == -1)) { + mtGoods.setLogo(basePath + mtGoodsSku.getLogo()); + } + if (mtGoodsSku.getWeight().compareTo(new BigDecimal("0")) > 0) { + mtGoods.setWeight(mtGoodsSku.getWeight()); + } + mtGoods.setPrice(mtGoodsSku.getPrice()); + mtGoods.setLinePrice(mtGoodsSku.getLinePrice()); + mtGoods.setStock(mtGoodsSku.getStock()); + } + cartDto.setGoodsInfo(mtGoods); + } else { + cartDto.setGoodsInfo(mtGoodsInfo); + } + if (mtGoodsInfo.getStock() != null && mtGoodsInfo.getStock() < cartDto.getNum()) { + isEffect = false; + } + cartDto.setIsEffect(isEffect); + // 计算总价 + if (cartDto.getGoodsInfo().getPrice().compareTo(BigDecimal.ZERO) > 0){ + totalPrice = totalPrice.add(cartDto.getGoodsInfo().getPrice().multiply(new BigDecimal(cart.getNum()))); + } else { // 自定义商品价格 + totalPrice = totalPrice.add(cart.getSelfPrice().multiply(new BigDecimal(cart.getNum()))); + } + + // 累加可用积分去抵扣的金额 + if (mtGoodsInfo.getCanUsePoint() != null && mtGoodsInfo.getCanUsePoint().equals(YesOrNoEnum.YES.getKey())) { + totalCanUsePointAmount = totalCanUsePointAmount.add(cartDto.getGoodsInfo().getPrice().multiply(new BigDecimal(cart.getNum()))); + } + cartDtoList.add(cartDto); + } + } + + Map result = new HashMap<>(); + + // 可用卡券列表 + List couponList = new ArrayList<>(); + List statusList = Arrays.asList(UserCouponStatusEnum.UNUSED.getKey()); + List userCouponList = userCouponService.getUserCouponList(userId, statusList); + if (userCouponList.size() > 0) { + for (MtUserCoupon userCoupon : userCouponList) { + MtCoupon couponInfo = couponService.queryCouponById(userCoupon.getCouponId()); + // 优惠券和储值卡才能使用 + if (couponInfo.getType().equals(CouponTypeEnum.COUPON.getKey()) || couponInfo.getType().equals(CouponTypeEnum.PRESTORE.getKey())) { + CouponDto couponDto = new CouponDto(); + couponDto.setId(couponInfo.getId()); + couponDto.setUserCouponId(userCoupon.getId()); + couponDto.setName(couponInfo.getName()); + couponDto.setAmount(userCoupon.getAmount()); + couponDto.setStatus(UserCouponStatusEnum.DISABLE.getKey()); + // 购物不能用专用的卡券 + if (couponInfo.getUseFor() != null && StringUtil.isNotEmpty(couponInfo.getUseFor())) { + if (couponInfo.getUseFor().equals(CouponUseForEnum.MEMBER_GRADE.getKey())) { + continue; + } + if (couponInfo.getUseFor().equals(CouponUseForEnum.OFF_LINE_PAYMENT.getKey())) { + // 只有PC收银端能用 + if (!platform.equals(PlatformTypeEnum.PC.getCode())) { + continue; + } + } + } + boolean isEffective = couponService.isCouponEffective(couponInfo, userCoupon); + // 优惠券 + if (couponInfo.getType().equals(CouponTypeEnum.COUPON.getKey())) { + couponDto.setType(CouponTypeEnum.COUPON.getValue()); + if (StringUtil.isEmpty(couponInfo.getOutRule()) || couponInfo.getOutRule().equals("0")) { + couponDto.setDescription("无使用门槛"); + if (isEffective) { + couponDto.setStatus(UserCouponStatusEnum.UNUSED.getKey()); + } + } else { + couponDto.setDescription("满" + couponInfo.getOutRule() + "元可用"); + BigDecimal conditionAmount = new BigDecimal(couponInfo.getOutRule()); + if (totalPrice.compareTo(conditionAmount) > 0 && isEffective) { + couponDto.setStatus(UserCouponStatusEnum.UNUSED.getKey()); + } + } + } else if (couponInfo.getType().equals(CouponTypeEnum.PRESTORE.getKey())) { + // 储值卡 + couponDto.setType(CouponTypeEnum.PRESTORE.getValue()); + couponDto.setDescription("无使用门槛"); + couponDto.setAmount(userCoupon.getBalance()); + // 余额须大于0 + if (isEffective && (userCoupon.getBalance().compareTo(new BigDecimal("0")) > 0)) { + couponDto.setStatus(UserCouponStatusEnum.UNUSED.getKey()); + } + } + if (couponInfo.getExpireType().equals(CouponExpireTypeEnum.FIX.getKey())) { + couponDto.setEffectiveDate(DateUtil.formatDate(couponInfo.getBeginTime(), "yyyy.MM.dd HH:mm") + "~" + DateUtil.formatDate(couponInfo.getEndTime(), "yyyy.MM.dd HH:mm")); + } + if (couponInfo.getExpireType().equals(CouponExpireTypeEnum.FLEX.getKey())) { + couponDto.setEffectiveDate(DateUtil.formatDate(userCoupon.getCreateTime(), "yyyy.MM.dd HH:mm") + "~" + DateUtil.formatDate(userCoupon.getExpireTime(), "yyyy.MM.dd HH:mm")); + } + couponList.add(couponDto); + } + } + } + + // 使用的卡券 + MtCoupon useCouponInfo = null; + BigDecimal couponAmount = new BigDecimal("0"); + if (couponId > 0) { + MtUserCoupon userCouponInfo = userCouponService.getUserCouponDetail(couponId); + if (userCouponInfo != null) { + useCouponInfo = couponService.queryCouponById(userCouponInfo.getCouponId()); + boolean isEffective = couponService.isCouponEffective(useCouponInfo, userCouponInfo); + if (isEffective) { + if (useCouponInfo.getType().equals(CouponTypeEnum.COUPON.getKey())) { + couponAmount = useCouponInfo.getAmount(); + } else if(useCouponInfo.getType().equals(CouponTypeEnum.PRESTORE.getKey())) { + BigDecimal couponTotalAmount = userCouponInfo.getBalance(); + if (couponTotalAmount.compareTo(totalPrice) > 0) { + couponAmount = totalPrice; + useCouponInfo.setAmount(totalPrice); + } else { + couponAmount = couponTotalAmount; + useCouponInfo.setAmount(couponTotalAmount); + } + } + } + } + } + + // 支付金额 = 商品总额 - 卡券抵扣金额 + BigDecimal payPrice = totalPrice.subtract(couponAmount); + + // 可用积分、可用积分金额 + Integer myPoint = userInfo.getPoint() == null ? 0 : userInfo.getPoint(); + Integer usePoint = 0; + BigDecimal usePointAmount = new BigDecimal("0"); + MtSetting setting = settingService.querySettingByName(merchantId, PointSettingEnum.EXCHANGE_NEED_POINT.getKey()); + if (myPoint > 0 && setting != null && isUsePoint) { + if (StringUtil.isNotEmpty(setting.getValue()) && !setting.getValue().equals("0")) { + BigDecimal usePoints = new BigDecimal(myPoint); + usePointAmount = usePoints.divide(new BigDecimal(setting.getValue()), BigDecimal.ROUND_CEILING, 3); + usePoint = myPoint; + if (usePointAmount.compareTo(totalCanUsePointAmount) >= 0) { + usePointAmount = totalCanUsePointAmount; + usePoint = totalCanUsePointAmount.multiply(new BigDecimal(setting.getValue())).intValue(); + } + } + } + + // 积分金额不能大于支付金额 + if (usePointAmount.compareTo(payPrice) > 0 && isUsePoint) { + usePointAmount = payPrice; + BigDecimal usePoints = payPrice.multiply(new BigDecimal(setting.getValue())); + usePoint = usePoints.intValue(); + } + + // 支付金额 = 商品总额 - 积分抵扣金额 + payPrice = payPrice.subtract(usePointAmount); + if (payPrice.compareTo(new BigDecimal("0")) < 0) { + payPrice = new BigDecimal("0"); + } + + // 配送费用 + BigDecimal deliveryFee = new BigDecimal("0"); + MtSetting mtSetting = settingService.querySettingByName(merchantId, OrderSettingEnum.DELIVERY_FEE.getKey()); + if (mtSetting != null && StringUtil.isNotEmpty(mtSetting.getValue()) && orderMode.equals(OrderModeEnum.EXPRESS.getKey())) { + deliveryFee = new BigDecimal(mtSetting.getValue()); + } + + result.put("list", cartDtoList); + result.put("totalNum", totalNum); + result.put("totalPrice", totalPrice); + result.put("payPrice", payPrice); + result.put("prePayment", prePayment); // 预付金 + result.put("couponList", couponList); + result.put("useCouponInfo", useCouponInfo); + result.put("usePoint", usePoint); + result.put("myPoint", myPoint); + result.put("couponAmount", couponAmount); + result.put("usePointAmount", usePointAmount); + result.put("deliveryFee", deliveryFee); + + return result; + } + + /** + * 获取会员支付金额 + * + * @param userId 会员ID + * @return + * */ + @Override + public BigDecimal getUserPayMoney(Integer userId) { + return mtOrderMapper.getUserPayMoney(userId); + } + + /** + * 获取会员订单数 + * + * @param userId 会员ID + * @return + * */ + @Override + public Integer getUserPayOrderCount(Integer userId) { + return mtOrderMapper.getUserPayOrderCount(userId); + } + + /** + * 获取待分佣订单列表 + * + * @param dateTime 时间 + * @return + * */ + @Override + public List getTobeCommissionOrderList(String dateTime) { + return mtOrderMapper.getTobeCommissionOrderList(dateTime); + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/PaymentServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/PaymentServiceImpl.java new file mode 100644 index 0000000..7863b36 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/PaymentServiceImpl.java @@ -0,0 +1,281 @@ +package com.fuint.common.service.impl; + +import com.fuint.common.dto.*; +import com.fuint.common.enums.*; +import com.fuint.common.service.*; +import com.fuint.common.util.CommonUtil; +import com.fuint.common.util.TokenUtil; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.web.ResponseObject; +import com.fuint.repository.mapper.MtOrderMapper; +import com.fuint.repository.model.*; +import com.fuint.utils.StringUtil; +import lombok.AllArgsConstructor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +/** + * 支付相关接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor(onConstructor_= {@Lazy}) +public class PaymentServiceImpl implements PaymentService { + + private static final Logger logger = LoggerFactory.getLogger(PaymentServiceImpl.class); + + private MtOrderMapper mtOrderMapper; + + /** + * 微信服务接口 + * */ + private WeixinService weixinService; + + /** + * 支付宝服务接口 + * */ + private AlipayService alipayService; + + /** + * 会员服务接口 + * */ + private MemberService memberService; + + /** + * 订单服务接口 + * */ + private OrderService orderService; + + /** + * 余额服务接口 + * */ + private BalanceService balanceService; + + /** + * 会员卡券服务接口 + * */ + private UserCouponService userCouponService; + + /** + * 开卡赠礼服务接口 + * */ + private OpenGiftService openGiftService; + + /** + * 创建预支付订单 + * + * @param userInfo 会员信息 + * @param orderInfo 订单信息 + * @param payAmount 支付金额 + * @param authCode 付款码 + * @param giveAmount 赠送金额 + * @param ip 支付IP地址 + * @param platform 支付平台 + * @return + * */ + @Override + public ResponseObject createPrepayOrder(MtUser userInfo, MtOrder orderInfo, Integer payAmount, String authCode, Integer giveAmount, String ip, String platform) throws BusinessCheckException { + logger.info("PaymentService createPrepayOrder inParams userInfo={} payAmount={} giveAmount={} goodsInfo={}", userInfo, payAmount, giveAmount, orderInfo); + + ResponseObject responseObject; + if (orderInfo.getPayType().equals(PayTypeEnum.ALISCAN.getKey())) { + // 支付宝支付 + responseObject = alipayService.createPrepayOrder(userInfo, orderInfo, payAmount, authCode, giveAmount, ip, platform); + } else { + // 微信支付 + responseObject = weixinService.createPrepayOrder(userInfo, orderInfo, payAmount, authCode, giveAmount, ip, platform); + } + + logger.info("PaymentService createPrepayOrder outParams {}", responseObject.toString()); + return responseObject; + } + + /** + * 支付成功回调 + * + * @param orderInfo 订单信息 + * @return + * */ + @Override + @Transactional(rollbackFor = Exception.class) + public Boolean paymentCallback(UserOrderDto orderInfo) throws BusinessCheckException { + logger.info("paymentCallback outParams {}", orderInfo.toString()); + MtOrder mtOrder = mtOrderMapper.selectById(orderInfo.getId()); + + // 更新订单状态为已支付 + Boolean isPay = orderService.setOrderPayed(orderInfo.getId(), null); + if (mtOrder == null || !isPay) { + return false; + } + + // 会员升级订单 + if (mtOrder.getType().equals(OrderTypeEnum.MEMBER.getKey())) { + openGiftService.openGift(mtOrder.getUserId(), Integer.parseInt(mtOrder.getParam()), false); + } + + // 储值卡订单 + if (orderInfo.getType().equals(OrderTypeEnum.PRESTORE.getKey())) { + Map param = new HashMap<>(); + param.put("couponId", orderInfo.getCouponId()); + param.put("userId", orderInfo.getUserId()); + param.put("param", orderInfo.getParam()); + param.put("orderId", orderInfo.getId()); + userCouponService.preStore(param); + } + + // 充值订单 + if (orderInfo.getType().equals(OrderTypeEnum.RECHARGE.getKey())) { + // 余额支付 + MtBalance mtBalance = new MtBalance(); + OrderUserDto userDto = orderInfo.getUserInfo(); + if (userDto.getMobile() != null && StringUtil.isNotEmpty(userDto.getMobile())) { + mtBalance.setMobile(userDto.getMobile()); + } + mtBalance.setOrderSn(orderInfo.getOrderSn()); + mtBalance.setUserId(orderInfo.getUserId()); + mtBalance.setMerchantId(orderInfo.getMerchantId()); + String param = orderInfo.getParam(); + if (StringUtil.isNotEmpty(param)) { + String params[] = param.split("_"); + if (params.length == 2) { + BigDecimal amount = new BigDecimal(params[0]).add(new BigDecimal(params[1])); + mtBalance.setAmount(amount); + balanceService.addBalance(mtBalance, true); + } + } + } + + logger.info("PaymentService paymentCallback Success orderSn {}", orderInfo.getOrderSn()); + return true; + } + + /** + * 订单支付 + * + * @param request 请求参数 + * @return + * */ + @Override + @Transactional(rollbackFor = Exception.class) + public Map doPay(HttpServletRequest request) throws BusinessCheckException { + String token = request.getHeader("Access-Token"); + String platform = request.getHeader("platform") == null ? "" : request.getHeader("platform"); + String payType = request.getParameter("payType") == null ? PayTypeEnum.JSAPI.getKey() : request.getParameter("payType"); + String cashierPayAmount = request.getParameter("cashierPayAmount") == null ? "" : request.getParameter("cashierPayAmount"); // 收银台实付金额 + String cashierDiscountAmount = request.getParameter("cashierDiscountAmount") == null ? "" : request.getParameter("cashierDiscountAmount"); // 收银台优惠金额 + UserInfo loginInfo = TokenUtil.getUserInfoByToken(token); + String orderId = request.getParameter("orderId"); + String userId = request.getParameter("userId"); + String authCode = request.getParameter("authCode"); + if (StringUtil.isEmpty(orderId)) { + throw new BusinessCheckException("订单不能为空"); + } + + MtOrder orderInfo = mtOrderMapper.selectById(Integer.parseInt(orderId)); + if (orderInfo == null) { + throw new BusinessCheckException("该订单不存在"); + } + MtUser mtUser = null; + if (loginInfo != null) { + mtUser = memberService.queryMemberById(loginInfo.getId()); + } + + // 收银员操作 + AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token); + if (loginInfo == null && accountInfo != null) { + // 游客订单绑定到会员 + if (orderInfo.getIsVisitor().equals(YesOrNoEnum.YES.getKey()) && StringUtil.isNotEmpty(userId)) { + mtUser = memberService.queryMemberById(Integer.parseInt(userId)); + orderInfo.setUserId(Integer.parseInt(userId)); + orderInfo.setIsVisitor(YesOrNoEnum.NO.getKey()); + orderService.updateOrder(orderInfo); + } else { + mtUser = memberService.queryMemberById(orderInfo.getUserId()); + } + } + + if (mtUser == null) { + throw new BusinessCheckException("登录信息失效"); + } + + if (accountInfo != null && StringUtil.isNotEmpty(cashierPayAmount) && StringUtil.isNotEmpty(cashierDiscountAmount)) { + orderInfo.setDiscount(new BigDecimal(cashierDiscountAmount)); + if (loginInfo == null) { + MtUser user = memberService.queryMemberById(orderInfo.getUserId()); + if (user != null) { + loginInfo = new UserInfo(); + loginInfo.setId(user.getId()); + } + } + } + + // 实付金额 = 总金额 - 优惠金额 - 积分金额 + BigDecimal realPayAmount = orderInfo.getAmount().subtract(new BigDecimal(orderInfo.getDiscount().toString())).subtract(new BigDecimal(orderInfo.getPointAmount().toString())).add(orderInfo.getDeliveryFee()); + Object payment = null; + if (payType.equals(PayTypeEnum.BALANCE.getKey())) { + // 余额支付 + MtBalance balance = new MtBalance(); + balance.setMobile(mtUser.getMobile()); + balance.setOrderSn(orderInfo.getOrderSn()); + balance.setUserId(mtUser.getId()); + BigDecimal balanceAmount = realPayAmount.subtract(realPayAmount).subtract(realPayAmount); + balance.setAmount(balanceAmount); + boolean isPay = balanceService.addBalance(balance, true); + if (isPay) { + orderService.setOrderPayed(orderInfo.getId(), balanceAmount); + OrderDto reqOrder = new OrderDto(); + reqOrder.setId(orderInfo.getId()); + reqOrder.setPayAmount(realPayAmount); + reqOrder.setDiscount(orderInfo.getDiscount()); + reqOrder.setPayType(PayTypeEnum.BALANCE.getKey()); + if (accountInfo != null) { + reqOrder.setOperator(accountInfo.getAccountName()); + } + orderService.updateOrder(reqOrder); + orderInfo = orderService.getOrderInfo(orderInfo.getId()); + } else { + throw new BusinessCheckException("会员余额不足"); + } + } else if (payType.equals(PayTypeEnum.CASH.getKey()) && accountInfo != null) { + // 现金支付 + OrderDto reqOrder = new OrderDto(); + reqOrder.setId(orderInfo.getId()); + reqOrder.setAmount(new BigDecimal(cashierPayAmount).add(new BigDecimal(cashierDiscountAmount))); + reqOrder.setDiscount(new BigDecimal(cashierDiscountAmount)); + reqOrder.setPayAmount(new BigDecimal(cashierPayAmount)); + reqOrder.setPayTime(new Date()); + reqOrder.setPayType(PayTypeEnum.CASH.getKey()); + reqOrder.setOperator(accountInfo.getAccountName()); + orderService.updateOrder(reqOrder); + orderService.setOrderPayed(orderInfo.getId(), null); + orderInfo = orderService.getOrderInfo(orderInfo.getId()); + } else { + String ip = CommonUtil.getIPFromHttpRequest(request); + BigDecimal pay = realPayAmount.multiply(new BigDecimal("100")); + orderInfo.setPayType(payType); + ResponseObject paymentInfo = createPrepayOrder(mtUser, orderInfo, (pay.intValue()), authCode, 0, ip, platform); + if (paymentInfo.getData() == null) { + throw new BusinessCheckException("抱歉,支付失败"); + } + payment = paymentInfo.getData(); + } + + Map result = new HashMap(); + result.put("isCreated", true); + result.put("payType", payType); + result.put("orderInfo", orderInfo); + result.put("payment", payment); + + return result; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/PointServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/PointServiceImpl.java new file mode 100644 index 0000000..e159f23 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/PointServiceImpl.java @@ -0,0 +1,252 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.dto.PointDto; +import com.fuint.common.enums.StatusEnum; +import com.fuint.common.enums.WxMessageEnum; +import com.fuint.common.service.MemberService; +import com.fuint.common.service.PointService; +import com.fuint.common.service.WeixinService; +import com.fuint.common.util.DateUtil; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.mapper.MtPointMapper; +import com.fuint.repository.mapper.MtUserMapper; +import com.fuint.repository.model.MtPoint; +import com.fuint.repository.model.MtUser; +import com.fuint.utils.StringUtil; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import com.github.pagehelper.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.util.*; + +/** + * 积分管理业务实现类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class PointServiceImpl extends ServiceImpl implements PointService { + + private MtPointMapper mtPointMapper; + + private MtUserMapper mtUserMapper; + + /** + * 会员服务接口 + * */ + private MemberService memberService; + + /** + * 微信相关服务接口 + * */ + private WeixinService weixinService; + + /** + * 分页查询积分列表 + * + * @param paginationRequest + * @return + */ + @Override + public PaginationResponse queryPointListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException { + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtPoint::getStatus, StatusEnum.DISABLE.getKey()); + + String description = paginationRequest.getSearchParams().get("description") == null ? "" : paginationRequest.getSearchParams().get("description").toString(); + if (StringUtils.isNotBlank(description)) { + lambdaQueryWrapper.like(MtPoint::getDescription, description); + } + String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtPoint::getStatus, status); + } + String userId = paginationRequest.getSearchParams().get("userId") == null ? "" : paginationRequest.getSearchParams().get("userId").toString(); + if (StringUtils.isNotBlank(userId)) { + lambdaQueryWrapper.eq(MtPoint::getUserId, userId); + } + String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(MtPoint::getMerchantId, merchantId); + } + String userNo = paginationRequest.getSearchParams().get("userNo") == null ? "" : paginationRequest.getSearchParams().get("userNo").toString(); + if (StringUtil.isNotEmpty(userNo)) { + if (StringUtil.isEmpty(merchantId)) { + merchantId = "0"; + } + MtUser userInfo = memberService.queryMemberByUserNo(Integer.parseInt(merchantId), userNo); + if (userInfo != null) { + lambdaQueryWrapper.eq(MtPoint::getUserId, userInfo.getId()); + } + } + String storeId = paginationRequest.getSearchParams().get("storeId") == null ? "" : paginationRequest.getSearchParams().get("storeId").toString(); + if (StringUtils.isNotBlank(storeId)) { + lambdaQueryWrapper.eq(MtPoint::getStoreId, storeId); + } + + lambdaQueryWrapper.orderByDesc(MtPoint::getId); + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + List pointList = mtPointMapper.selectList(lambdaQueryWrapper); + + List dataList = new ArrayList<>(); + for (MtPoint point : pointList) { + MtUser userInfo = memberService.queryMemberById(point.getUserId()); + PointDto item = new PointDto(); + item.setId(point.getId()); + item.setAmount(point.getAmount()); + item.setDescription(point.getDescription()); + item.setCreateTime(point.getCreateTime()); + item.setUpdateTime(point.getUpdateTime()); + item.setUserId(point.getUserId()); + item.setUserInfo(userInfo); + item.setOrderSn(point.getOrderSn()); + item.setOperator(point.getOperator()); + item.setStatus(point.getStatus()); + dataList.add(item); + } + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, PointDto.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 添加积分记录 + * + * @param mtPoint 积分参数 + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "修改会员积分") + public void addPoint(MtPoint mtPoint) throws BusinessCheckException { + if (mtPoint.getUserId() < 0) { + return; + } + mtPoint.setStatus(StatusEnum.ENABLED.getKey()); + mtPoint.setCreateTime(new Date()); + mtPoint.setUpdateTime(new Date()); + if (mtPoint.getOperator() != null) { + mtPoint.setOperator(mtPoint.getOperator()); + } + + if (mtPoint.getOrderSn() != null) { + mtPoint.setOrderSn(mtPoint.getOrderSn()); + } + + MtUser mtUser = mtUserMapper.selectById(mtPoint.getUserId()); + Integer newAmount = mtUser.getPoint() + mtPoint.getAmount(); + if (newAmount < 0) { + return; + } + mtUser.setPoint(newAmount); + if (mtUser.getStoreId() != null) { + mtPoint.setStoreId(mtUser.getStoreId()); + } + mtPoint.setMerchantId(mtUser.getMerchantId()); + mtUserMapper.updateById(mtUser); + mtPointMapper.insert(mtPoint); + + // 发送小程序订阅消息 + Date nowTime = new Date(); + Date sendTime = new Date(nowTime.getTime() + 60000); + Map params = new HashMap<>(); + String dateTime = DateUtil.formatDate(Calendar.getInstance().getTime(), "yyyy-MM-dd HH:mm"); + params.put("amount", mtPoint.getAmount()); + params.put("time", dateTime); + params.put("remark", "您的积分发生了变动,请留意~"); + weixinService.sendSubscribeMessage(mtPoint.getMerchantId(), mtPoint.getUserId(), mtUser.getOpenId(), WxMessageEnum.POINT_CHANGE.getKey(), "pages/user/index", params, sendTime); + + return; + } + + /** + * 转赠积分 + * + * @param userId 会员ID + * @param mobile 会员手机 + * @param amount 积分数 + * @param remark 备注 + * @throws BusinessCheckException + * @return boolean + */ + @Override + @Transactional(rollbackFor = Exception.class) + public boolean doGift(Integer userId, String mobile, Integer amount, String remark) throws BusinessCheckException { + if (userId < 0 || StringUtil.isEmpty(mobile) || amount <= 0) { + return false; + } + + MtUser userInfo = memberService.queryMemberById(userId); + MtUser fUserInfo = memberService.queryMemberByMobile(userInfo.getMerchantId(), mobile); + // 自动注册会员 + if (fUserInfo == null) { + fUserInfo = memberService.addMemberByMobile(userInfo.getMerchantId(), mobile); + } + + if (fUserInfo == null) { + throw new BusinessCheckException("转赠的好友信息不存在"); + } + + if (fUserInfo.getId().equals(userInfo.getId())) { + throw new BusinessCheckException("积分不能转赠给自己"); + } + + Integer newAmount = fUserInfo.getPoint() + amount; + if (newAmount < 0) { + throw new BusinessCheckException("积分赠送失败"); + } + fUserInfo.setPoint(newAmount); + + Integer myNewAmount = userInfo.getPoint() - amount; + if (myNewAmount < 0) { + throw new BusinessCheckException("您的积分不足"); + } + userInfo.setPoint(myNewAmount); + + mtUserMapper.updateById(fUserInfo); + mtUserMapper.updateById(userInfo); + + MtPoint fMtPoint = new MtPoint(); + fMtPoint.setStatus(StatusEnum.ENABLED.getKey()); + fMtPoint.setAmount(amount); + fMtPoint.setCreateTime(new Date()); + fMtPoint.setUpdateTime(new Date()); + fMtPoint.setOperator(userInfo.getName()); + fMtPoint.setOrderSn(""); + fMtPoint.setDescription(remark); + fMtPoint.setUserId(fUserInfo.getId()); + fMtPoint.setMerchantId(fUserInfo.getMerchantId()); + mtPointMapper.insert(fMtPoint); + + MtPoint mtPoint = new MtPoint(); + mtPoint.setUserId(userId); + mtPoint.setAmount(-amount); + mtPoint.setStatus(StatusEnum.ENABLED.getKey()); + mtPoint.setCreateTime(new Date()); + mtPoint.setUpdateTime(new Date()); + mtPoint.setOperator(userInfo.getName()); + mtPoint.setOrderSn(""); + mtPoint.setDescription("转赠好友"); + mtPoint.setMerchantId(userInfo.getMerchantId()); + mtPointMapper.insert(mtPoint); + + return true; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/RefundServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/RefundServiceImpl.java new file mode 100644 index 0000000..0ab3664 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/RefundServiceImpl.java @@ -0,0 +1,727 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.Constants; +import com.fuint.common.dto.*; +import com.fuint.common.enums.*; +import com.fuint.common.service.*; +import com.fuint.common.util.DateUtil; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.framework.web.ResponseObject; +import com.fuint.repository.mapper.*; +import com.fuint.repository.model.*; +import com.fuint.utils.StringUtil; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; +import java.util.*; + +/** + * 售后接口实现类 + */ +@Service +@AllArgsConstructor +public class RefundServiceImpl extends ServiceImpl implements RefundService { + + private static final Logger logger = LoggerFactory.getLogger(RefundServiceImpl.class); + + private MtPointMapper mtPointMapper; + + private MtRefundMapper mtRefundMapper; + + private MtConfirmLogMapper mtConfirmLogMapper; + + private MtUserCouponMapper mtUserCouponMapper; + + private MtGoodsSkuMapper mtGoodsSkuMapper; + + private MtGoodsMapper mtGoodsMapper; + + private MtOrderGoodsMapper mtOrderGoodsMapper; + + /** + * 卡券接口 + * */ + private CouponService couponService; + + /** + * 积分相关接口 + * */ + private PointService pointService; + + /** + * 订单服务接口 + * */ + private OrderService orderService; + + /** + * 余额服务接口 + * */ + private BalanceService balanceService; + + /** + * 微信服务接口 + * */ + private WeixinService weixinService; + + /** + * 支付宝服务接口 + * */ + private AlipayService alipayService; + + + private MemberService memberService; + private StoreService storeService; + + + + /** + * 分页查询售后订单列表 + * + * @param paginationRequest + * @return + */ + @Override + public PaginationResponse getRefundListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException { + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); +// lambdaQueryWrapper.ne(MtRefund::getStatus, StatusEnum.DISABLE.getKey()); + String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(MtRefund::getMerchantId, merchantId); + } + String remark = paginationRequest.getSearchParams().get("remark") == null ? "" : paginationRequest.getSearchParams().get("remark").toString(); + if (StringUtils.isNotBlank(remark)) { + lambdaQueryWrapper.like(MtRefund::getRemark, remark); + } + String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtRefund::getStatus, status); + } + String orderId = paginationRequest.getSearchParams().get("orderId") == null ? "" : paginationRequest.getSearchParams().get("orderId").toString(); + if (StringUtils.isNotBlank(orderId)) { + lambdaQueryWrapper.eq(MtRefund::getOrderId, orderId); + } + String userId = paginationRequest.getSearchParams().get("userId") == null ? "" : paginationRequest.getSearchParams().get("userId").toString(); + if (StringUtils.isNotBlank(userId)) { + lambdaQueryWrapper.eq(MtRefund::getUserId, userId); + } + String storeId = paginationRequest.getSearchParams().get("storeId") == null ? "" : paginationRequest.getSearchParams().get("storeId").toString(); + if (StringUtils.isNotBlank(storeId)) { + lambdaQueryWrapper.eq(MtRefund::getStoreId, storeId); + } + String startTime = paginationRequest.getSearchParams().get("startTime") == null ? "" : paginationRequest.getSearchParams().get("startTime").toString(); + String endTime = paginationRequest.getSearchParams().get("endTime") == null ? "" : paginationRequest.getSearchParams().get("endTime").toString(); + if (StringUtil.isNotEmpty(startTime)) { + lambdaQueryWrapper.ge(MtRefund::getCreateTime, startTime); + } + if (StringUtil.isNotEmpty(endTime)) { + lambdaQueryWrapper.le(MtRefund::getCreateTime, endTime); + } + + lambdaQueryWrapper.orderByDesc(MtRefund::getId); + List mtRefundList = mtRefundMapper.selectList(lambdaQueryWrapper); + + List dataList = new ArrayList<>(); + if (!mtRefundList.isEmpty()){ + for (MtRefund mtRefund: mtRefundList){ + RefundDto refundDto = new RefundDto(); + BeanUtils.copyProperties(mtRefund, refundDto); + +// UserOrderDto orderDto = orderService.getOrderById(mtRefund.getOrderId()); +// refundDto.setOrderInfo(orderDto); + MtUser mtUser = memberService.queryMemberById2(mtRefund.getUserId()); + UserDto userDto = new UserDto(); + BeanUtils.copyProperties(mtUser, userDto); + refundDto.setUserInfo(userDto); + + MtStore storeInfo = storeService.queryStoreById(mtRefund.getStoreId()); + StoreDto storeDto = new StoreDto(); + BeanUtils.copyProperties(storeInfo, storeDto); + refundDto.setStoreInfo(storeDto); + + if (mtRefund.getImages() != null && StringUtil.isNotEmpty(mtRefund.getImages())) { + List images = Arrays.asList(mtRefund.getImages().split(",").clone()); + refundDto.setImageList(images); + } + + refundDto.setCreateTime(DateUtil.formatDate(mtRefund.getCreateTime(), "yyyy.MM.dd HH:mm")); + refundDto.setUpdateTime(DateUtil.formatDate(mtRefund.getUpdateTime(), "yyyy.MM.dd HH:mm")); + + dataList.add(refundDto); + } + } + + +// PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); +// PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); +// PaginationResponse paginationResponse = new PaginationResponse(pageImpl, MtRefund.class); +// paginationResponse.setTotalPages(pageHelper.getPages()); +// paginationResponse.setTotalElements(pageHelper.getTotal()); +// paginationResponse.setContent(dataList); + + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, RefundDto.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 获取用户售后订单列表 + * + * @param paramMap 查询参数 + * @throws BusinessCheckException + * @return + * */ + @Override + @Transactional(rollbackFor = Exception.class) + public ResponseObject getUserRefundList(Map paramMap) throws BusinessCheckException { + Integer pageNumber = paramMap.get("pageNumber") == null ? Constants.PAGE_NUMBER : Integer.parseInt(paramMap.get("pageNumber").toString()); + Integer pageSize = paramMap.get("pageSize") == null ? Constants.PAGE_SIZE : Integer.parseInt(paramMap.get("pageSize").toString()); + String userId = paramMap.get("userId") == null ? "0" : paramMap.get("userId").toString(); + String status = paramMap.get("status") == null ? "": paramMap.get("status").toString(); + + Page pageHelper = PageHelper.startPage(pageNumber, pageSize); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + + if (StringUtils.isNotBlank(userId)) { + lambdaQueryWrapper.like(MtRefund::getUserId, userId); + } + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtRefund::getStatus, status); + } + + lambdaQueryWrapper.orderByDesc(MtRefund::getId); + List refundList = mtRefundMapper.selectList(lambdaQueryWrapper); + + List dataList = new ArrayList<>(); + if (refundList != null && refundList.size() > 0) { + for (MtRefund mtRefund : refundList) { + RefundDto refundDto = new RefundDto(); + BeanUtils.copyProperties(mtRefund, refundDto); + UserOrderDto orderDto = orderService.getOrderById(mtRefund.getOrderId()); + if (mtRefund.getImages() != null && StringUtil.isNotEmpty(mtRefund.getImages())) { + List images = Arrays.asList(mtRefund.getImages().split(",").clone()); + refundDto.setImageList(images); + } + refundDto.setOrderInfo(orderDto); + refundDto.setCreateTime(DateUtil.formatDate(mtRefund.getCreateTime(), "yyyy.MM.dd HH:mm")); + refundDto.setUpdateTime(DateUtil.formatDate(mtRefund.getUpdateTime(), "yyyy.MM.dd HH:mm")); + + if (mtRefund.getStatus().equals(RefundStatusEnum.CREATED.getKey())) { + refundDto.setStatusText(RefundStatusEnum.CREATED.getValue()); + } + if (mtRefund.getStatus().equals(RefundStatusEnum.APPROVED.getKey())) { + refundDto.setStatusText(RefundStatusEnum.APPROVED.getValue()); + } + if (mtRefund.getStatus().equals(RefundStatusEnum.REJECT.getKey())) { + refundDto.setStatusText(RefundStatusEnum.REJECT.getValue()); + } + if (mtRefund.getStatus().equals(RefundStatusEnum.CANCEL.getKey())) { + refundDto.setStatusText(RefundStatusEnum.CANCEL.getValue()); + } + + dataList.add(refundDto); + } + } + + PageRequest pageRequest = PageRequest.of(pageNumber, pageSize); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, RefundDto.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return new ResponseObject(200, "查询成功", paginationResponse); + } + + /** + * 创建售后订单 + * + * @param refundDto 订单参数 + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "提交售后订单") + public MtRefund createRefund(RefundDto refundDto) { + MtRefund refund = new MtRefund(); + if (refundDto.getId() != null) { + refund.setId(refund.getId()); + } + refund.setMerchantId(refundDto.getMerchantId()); + refund.setStoreId(refundDto.getStoreId()); + + // 检查是否已存在 + Map params = new HashMap<>(); + params.put("USER_ID", refundDto.getUserId().toString()); + params.put("ORDER_ID", refundDto.getOrderId().toString()); + List result = mtRefundMapper.selectByMap(params); + + if (result.size() > 0) { + refund = result.get(0); + refund.setUpdateTime(new Date()); + if (refundDto.getRemark() != null && StringUtil.isNotEmpty(refundDto.getRemark())) { + refund.setRemark(refund.getRemark() + "|" + refundDto.getRemark()); + } + mtRefundMapper.updateById(refund); + return refund; + } + + refund.setOrderId(refundDto.getOrderId()); + refund.setUserId(refundDto.getUserId()); + refund.setRemark(refundDto.getRemark()); + refund.setType(refundDto.getType()); + refund.setMerchantId(refundDto.getMerchantId()); + refund.setStoreId(refundDto.getStoreId()); + refund.setAmount(refundDto.getAmount()); + if (refundDto.getImages() != null && StringUtil.isNotEmpty(refundDto.getImages()) && refundDto.getImages().length() > 5) { + refund.setImages(String.join(",", refundDto.getImages())); + } + refund.setStatus(RefundStatusEnum.CREATED.getKey()); + refund.setUpdateTime(new Date()); + refund.setCreateTime(new Date()); + + mtRefundMapper.insert(refund); + return refund; + } + + /** + * 创建退款补扣订单 + * + * @param refundDto 订单参数 + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "创建退款补扣订单") + public MtRefund createRefund2(RefundDto refundDto) { + MtRefund refund = new MtRefund(); + if (refundDto.getId() != null) { + refund.setId(refund.getId()); + } + refund.setMerchantId(refundDto.getMerchantId()); + refund.setStoreId(refundDto.getStoreId()); + refund.setOrderId(refundDto.getOrderId()); + refund.setOrderSn(refundDto.getOrderSn()); + refund.setUserId(refundDto.getUserId()); + refund.setRemark(refundDto.getRemark()); + refund.setType(refundDto.getType()); + refund.setMerchantId(refundDto.getMerchantId()); + refund.setStoreId(refundDto.getStoreId()); + refund.setAmount(refundDto.getAmount()); + if (refundDto.getImages() != null && StringUtil.isNotEmpty(refundDto.getImages()) && refundDto.getImages().length() > 5) { + refund.setImages(String.join(",", refundDto.getImages())); + } + refund.setStatus(RefundStatusEnum.CREATED.getKey()); + refund.setUpdateTime(new Date()); + refund.setCreateTime(new Date()); + + refund.setApplicant(refundDto.getApplicant()); + + mtRefundMapper.insert(refund); + return refund; + } + + /** + * 根据ID获取订单详情 + * + * @param id 售后订单ID + * @throws BusinessCheckException + * @return + */ + @Override + public RefundDto getRefundById(Integer id) throws BusinessCheckException { + MtRefund mtRefund = mtRefundMapper.selectById(id); + if (mtRefund != null) { + RefundDto refundDto = new RefundDto(); + BeanUtils.copyProperties(mtRefund, refundDto); + UserOrderDto orderDto = orderService.getOrderById(mtRefund.getOrderId()); + if (mtRefund.getImages() != null && StringUtil.isNotEmpty(mtRefund.getImages())) { + List images = Arrays.asList(mtRefund.getImages().split(",").clone()); + refundDto.setImageList(images); + } + refundDto.setOrderInfo(orderDto); + AddressDto address = new AddressDto(); + refundDto.setAddress(address); + return refundDto; + } + return null; + } + + /** + * 根据订单ID获取售后订单信息 + * + * @param orderId 订单ID + * @throws BusinessCheckException + * @return + */ + @Override + public MtRefund getRefundByOrderId(Integer orderId) { + Map params = new HashMap<>(); + params.put("ORDER_ID", orderId.toString()); + List refunds = mtRefundMapper.selectByMap(params); + if (refunds != null && refunds.size() > 0) { + return refunds.get(0); + } + return null; + } + + /** + * 修改订单 + * + * @param refundDto + * @param accountInfo + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "更新售后订单") + public MtRefund updateRefund(RefundDto refundDto, AccountInfo accountInfo) throws BusinessCheckException { + if (accountInfo.getMerchantId() == null || accountInfo.getMerchantId() < 1) { + throw new BusinessCheckException("平台账号不能执行该操作"); + } + + MtRefund refund = mtRefundMapper.selectById(refundDto.getId()); + if (refund == null) { + throw new BusinessCheckException("该售后订单状态异常"); + } + + refund.setId(refundDto.getId()); + refund.setUpdateTime(new Date()); + + if (refundDto.getStatus().equals(RefundStatusEnum.REJECT.getKey()) && StringUtil.isNotEmpty(refundDto.getRejectReason())){ + refund.setRejectReason(refundDto.getRejectReason()); + } + + if (null != refundDto.getOperator()) { + refund.setOperator(refundDto.getOperator()); + } + if (null != refundDto.getStatus()) { + refund.setStatus(refundDto.getStatus()); + } + + mtRefundMapper.updateById(refund); + return refund; + } + + /** + * 同意售后订单 + * + * @param refundDto + * @param accountInfo + * @throws BusinessCheckException + * @return + * */ + @Override + @Transactional(rollbackFor = Exception.class) + public MtRefund agreeRefund(RefundDto refundDto, AccountInfo accountInfo) throws BusinessCheckException { + if (accountInfo.getMerchantId() == null || accountInfo.getMerchantId() < 1) { + throw new BusinessCheckException("平台账号不能执行该操作"); + } + + MtRefund refund = mtRefundMapper.selectById(refundDto.getId()); + if (null == refund) { + throw new BusinessCheckException("该售后订单状态异常"); + } + + // 已经同意过了 + if (refund.getStatus().equals(RefundStatusEnum.APPROVED.getKey())) { + if (StringUtil.isNotEmpty(refundDto.getRemark())) { + refund.setRemark(refundDto.getRemark()); + } + mtRefundMapper.updateById(refund); + return refund; + } + + refund.setId(refundDto.getId()); + refund.setUpdateTime(new Date()); + + if (null != refundDto.getOperator()) { + refund.setOperator(refundDto.getOperator()); + } + + if (null != refundDto.getStatus()) { + refund.setStatus(refundDto.getStatus()); + } + + mtRefundMapper.updateById(refund); + MtRefund mtRefund = mtRefundMapper.selectById(refund.getId()); + UserOrderDto orderInfo = orderService.getOrderById(mtRefund.getOrderId()); + + // 只有退款时才修改订单为已退款 + if (refundDto.getType().equals(RefundTypeEnum.REFUND_ALL.getKey()) || refundDto.getType().equals(RefundTypeEnum.REFUND_PART.getKey())){ + OrderDto reqDto = new OrderDto(); + reqDto.setId(orderInfo.getId()); + reqDto.setStatus(OrderStatusEnum.REFUND.getKey()); + orderService.updateOrder(reqDto); + } + + // 换货 + if (refund.getType().equals(RefundTypeEnum.EXCHANGE.getKey())) { + return refund; + } + + // 退款和补扣 + if (orderInfo.getPayType().equals(PayTypeEnum.BALANCE.getKey())){ + MtBalance balanceReq = new MtBalance(); + balanceReq.setUserId(orderInfo.getUserId()); + balanceReq.setMerchantId(orderInfo.getMerchantId()); + balanceReq.setOrderSn(orderInfo.getOrderSn()); + balanceReq.setMobile(orderInfo.getUserInfo().getMobile()); + balanceReq.setStatus(StatusEnum.ENABLED.getKey()); + + if (refundDto.getType().equals(RefundTypeEnum.REFUND_ALL.getKey())){ + balanceReq.setAmount(mtRefund.getAmount()); + balanceReq.setDescription(RefundTypeEnum.REFUND_ALL.getValue()); + } else if(refundDto.getType().equals(RefundTypeEnum.REFUND_PART.getKey())){ + balanceReq.setAmount(mtRefund.getAmount()); + balanceReq.setDescription(RefundTypeEnum.REFUND_PART.getValue()); + } else if(refundDto.getType().equals(RefundTypeEnum.DEDUCTION.getKey())){ + BigDecimal balanceAmount = mtRefund.getAmount().subtract(mtRefund.getAmount()).subtract(mtRefund.getAmount()); + balanceReq.setAmount(balanceAmount); + balanceReq.setDescription(RefundTypeEnum.DEDUCTION.getValue()); + } + + balanceReq.setCreateTime(new Date()); + balanceReq.setUpdateTime(new Date()); + + if (balanceReq.getAmount() != null && !BigDecimal.ZERO.equals(balanceReq.getAmount())){ + balanceService.addBalance(balanceReq, true); + } + } + + + + // 如果是余额支付,返还余额,这里退款是全额退款的 +// if (orderInfo.getPayType().equals(PayTypeEnum.BALANCE.getKey())) { +// List balanceList = balanceService.getBalanceListByOrderSn(orderInfo.getOrderSn()); +// if (!balanceList.isEmpty()) { +// for (MtBalance mtBalance : balanceList) { +// if (mtBalance.getAmount().compareTo(new BigDecimal("0")) < 0) { +// MtBalance balanceReq = new MtBalance(); +// balanceReq.setUserId(orderInfo.getUserId()); +// balanceReq.setMerchantId(orderInfo.getMerchantId()); +// balanceReq.setOrderSn(orderInfo.getOrderSn()); +// balanceReq.setMobile(orderInfo.getUserInfo().getMobile()); +// balanceReq.setAmount(mtBalance.getAmount().negate()); +// balanceReq.setStatus(StatusEnum.ENABLED.getKey()); +// balanceReq.setCreateTime(new Date()); +// balanceReq.setUpdateTime(new Date()); +// balanceService.addBalance(balanceReq, true); +// } +// } +// } +// } + + // 返还积分 + if (orderInfo.getUsePoint() != null && orderInfo.getUsePoint() > 0) { + MtPoint reqPointDto = new MtPoint(); + reqPointDto.setUserId(orderInfo.getUserId()); + reqPointDto.setAmount(orderInfo.getUsePoint()); + reqPointDto.setDescription("售后订单" + orderInfo.getOrderSn() + "退回"+ orderInfo.getUsePoint() +"积分"); + reqPointDto.setOrderSn(orderInfo.getOrderSn()); + reqPointDto.setOperator(""); + pointService.addPoint(reqPointDto); + } + + // 返还卡券 + List confirmLogList = mtConfirmLogMapper.getOrderConfirmLogList(orderInfo.getId()); + if (confirmLogList.size() > 0) { + for (MtConfirmLog log : confirmLogList) { + MtCoupon couponInfo = couponService.queryCouponById(log.getCouponId()); + MtUserCoupon userCouponInfo = mtUserCouponMapper.selectById(log.getUserCouponId()); + if (userCouponInfo != null) { + // 优惠券直接置为未使用 + if (couponInfo.getType().equals(CouponTypeEnum.COUPON.getKey())) { + userCouponInfo.setStatus(UserCouponStatusEnum.UNUSED.getKey()); + mtUserCouponMapper.updateById(userCouponInfo); + } + // 储值卡把余额加回去 + if (couponInfo.getType().equals(CouponTypeEnum.PRESTORE.getKey())) { + BigDecimal balance = userCouponInfo.getBalance(); + BigDecimal newBalance = balance.add(log.getAmount()); + if (newBalance.compareTo(userCouponInfo.getAmount()) <= 0) { + userCouponInfo.setBalance(newBalance); + userCouponInfo.setStatus(UserCouponStatusEnum.UNUSED.getKey()); + } + mtUserCouponMapper.updateById(userCouponInfo); + } + // 撤销核销记录 + log.setStatus(StatusEnum.DISABLE.getKey()); + mtConfirmLogMapper.updateById(log); + } + } + } + + // 退回积分 + Map params = new HashMap<>(); + params.put("USER_ID", orderInfo.getUserId()); + params.put("ORDER_SN", orderInfo.getOrderSn()); + List pointList = mtPointMapper.selectByMap(params); + if (pointList != null && pointList.size() > 0) { + Integer pointNum = pointList.get(0).getAmount(); + if (pointNum > 0) { + Integer amount = pointNum - (pointNum) * 2; + MtPoint mtPoint = new MtPoint(); + mtPoint.setAmount(amount.intValue()); + mtPoint.setUserId(orderInfo.getUserId()); + mtPoint.setOrderSn(orderInfo.getOrderSn()); + mtPoint.setDescription("退款¥" + orderInfo.getPayAmount() + "退回" + pointNum + "积分"); + mtPoint.setOperator(refundDto.getOperator() == null ? "系统" : refundDto.getOperator()); + pointService.addPoint(mtPoint); + } + } + + // 返还库存 + Map eParam = new HashMap<>(); + eParam.put("ORDER_ID", orderInfo.getId()); + List orderGoodsList = mtOrderGoodsMapper.selectByMap(eParam); + if (orderGoodsList != null && orderGoodsList.size() > 0) { + for (MtOrderGoods mtOrderGoods : orderGoodsList) { + MtGoods mtGoods = mtGoodsMapper.selectById(mtOrderGoods.getGoodsId()); + mtGoods.setStock(mtOrderGoods.getNum() + mtGoods.getStock()); + mtGoodsMapper.updateById(mtGoods); + if (mtOrderGoods.getSkuId() != null && mtOrderGoods.getSkuId() > 0) { + MtGoodsSku mtGoodsSku = mtGoodsSkuMapper.selectById(mtOrderGoods.getSkuId()); + mtGoodsSku.setStock(mtGoodsSku.getStock() + mtOrderGoods.getNum()); + mtGoodsSkuMapper.updateById(mtGoodsSku); + } + } + } + + // 微信支付发起退款 + if (orderInfo.getPayType().equals(PayTypeEnum.JSAPI.getKey()) || orderInfo.getPayType().equals(PayTypeEnum.MICROPAY.getKey())) { + weixinService.doRefund(orderInfo.getStoreInfo() != null ? orderInfo.getStoreInfo().getId() : 0, orderInfo.getOrderSn(), orderInfo.getPayAmount(), mtRefund.getAmount(), PlatformTypeEnum.MP_WEIXIN.getCode()); + } + + // 支付宝发起退款 + if (orderInfo.getPayType().equals(PayTypeEnum.ALISCAN.getKey())) { + alipayService.doRefund(orderInfo.getStoreInfo() != null ? orderInfo.getStoreInfo().getId() : 0, orderInfo.getOrderSn(), orderInfo.getPayAmount(), mtRefund.getAmount(), PlatformTypeEnum.PC.getCode()); + } + + return mtRefund; + } + + /** + * 发起退款 + * @param orderId 订单ID + * @param refundAmount 售后金额 + * @param remark 备注 + * @param accountInfo 后台管理信息 + * @param isDeduction 是否为补扣 + * throws BusinessCheckException + * @return + * */ + @Override + @Transactional(rollbackFor = Exception.class) + public Boolean doRefund(Integer orderId, String refundAmount, String remark, AccountInfo accountInfo, Boolean isDeduction) throws BusinessCheckException { + if (accountInfo.getMerchantId() == null || accountInfo.getMerchantId() < 1) { + throw new BusinessCheckException("平台账号不能执行该操作"); + } + + UserOrderDto orderInfo = orderService.getOrderById(orderId); + if (orderInfo == null) { + logger.error("售后订单为空,orderId = " + orderId + orderInfo.getId()); + throw new BusinessCheckException("该订单状态异常!"); + } + + List refundList = mtRefundMapper.findByOrderId(orderId); + for (MtRefund refund: refundList){ + if (refund.getStatus().equals(RefundStatusEnum.CREATED.getKey()) || refund.getStatus().equals(RefundStatusEnum.APPROVED.getKey())){ + logger.error("售后订单已存在,orderId = " + orderId); + throw new BusinessCheckException("该售后订单已存在!"); + } + } + + if (!isDeduction && new BigDecimal(refundAmount).compareTo(orderInfo.getPayAmount()) > 0) { + throw new BusinessCheckException("退款金额不能大于实际支付金额!"); + } else if(isDeduction){ + if (orderInfo.getPrePayment().compareTo(BigDecimal.ZERO) == 0){ + throw new BusinessCheckException("订单无预付金可以用!"); + } else if(new BigDecimal(refundAmount).compareTo(orderInfo.getPrePayment().subtract(orderInfo.getPayAmount())) > 0){ + throw new BusinessCheckException("补扣金额不能大于可用预付金额!"); + } + } + + // 创建售后订单 + RefundDto refundDto = new RefundDto(); + refundDto.setUserId(orderInfo.getUserId()); + refundDto.setOrderId(orderInfo.getId()); + refundDto.setOrderSn(orderInfo.getOrderSn()); + refundDto.setMerchantId(orderInfo.getMerchantId()); + refundDto.setApplicant(accountInfo.getAccountName()); + if (orderInfo.getStoreInfo() != null) { + refundDto.setStoreId(orderInfo.getStoreInfo().getId()); + } + refundDto.setRemark(remark); + //refundDto.setType(RefundTypeEnum.RETURN.getKey()); + if (isDeduction){ + refundDto.setType(RefundTypeEnum.DEDUCTION.getKey()); + } else if (new BigDecimal(refundAmount).compareTo(orderInfo.getPayAmount()) == 0){ + refundDto.setType(RefundTypeEnum.REFUND_ALL.getKey()); + } else { + refundDto.setType(RefundTypeEnum.REFUND_PART.getKey()); + } + + if (orderInfo.getStoreInfo() != null) { + refundDto.setStoreId(orderInfo.getStoreInfo().getId()); + } + refundDto.setAmount(new BigDecimal(refundAmount)); + refundDto.setOperator(accountInfo.getAccountName()); + refundDto.setImages(null); + createRefund2(refundDto); + + //后台也需要手动审核,不能自动审核 +// MtRefund mtRefund = createRefund(refundDto); +// if (mtRefund != null) { +// // 审核同意 +// RefundDto agreeDto = new RefundDto(); +// agreeDto.setId(mtRefund.getId()); +// agreeDto.setOperator(accountInfo.getAccountName()); +// agreeDto.setStatus(RefundStatusEnum.APPROVED.getKey()); +// MtRefund refundInfo = agreeRefund(agreeDto); +// if (refundInfo == null) { +// logger.error("退款审核失败,orderId = " + orderId + ", refundId = " + mtRefund.getId()); +// throw new BusinessCheckException("退款审核失败!"); +// } +// } else { +// logger.error("退款生成售后订单失败,orderId = " + orderId); +// throw new BusinessCheckException("生成售后订单失败!"); +// } + return true; + } + + /** + * 获取售后订单数量 + * + * @param beginTime 开始时间 + * @param endTime 结束时间 + * @return + * */ + @Override + public Long getRefundCount(Date beginTime, Date endTime) { + return mtRefundMapper.getRefundCount(beginTime, endTime); + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/SendLogServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/SendLogServiceImpl.java new file mode 100644 index 0000000..64b8777 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/SendLogServiceImpl.java @@ -0,0 +1,149 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.dto.ReqSendLogDto; +import com.fuint.common.enums.StatusEnum; +import com.fuint.common.service.SendLogService; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.mapper.MtSendLogMapper; +import com.fuint.repository.model.MtSendLog; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import java.util.Date; +import java.util.List; + +/** + * 发送卡券记录业务实现类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class SendLogServiceImpl extends ServiceImpl implements SendLogService { + + private MtSendLogMapper mtSendLogMapper; + + /** + * 分页查询列表 + * + * @param paginationRequest + * @return + */ + @Override + public PaginationResponse querySendLogListByPagination(PaginationRequest paginationRequest) { + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtSendLog::getStatus, StatusEnum.DISABLE.getKey()); + + String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtSendLog::getStatus, status); + } + String userId = paginationRequest.getSearchParams().get("userId") == null ? "" : paginationRequest.getSearchParams().get("userId").toString(); + if (StringUtils.isNotBlank(userId)) { + lambdaQueryWrapper.eq(MtSendLog::getUserId, userId); + } + String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(MtSendLog::getMerchantId, merchantId); + } + String storeId = paginationRequest.getSearchParams().get("storeId") == null ? "" : paginationRequest.getSearchParams().get("storeId").toString(); + if (StringUtils.isNotBlank(storeId)) { + lambdaQueryWrapper.eq(MtSendLog::getStoreId, storeId); + } + String couponId = paginationRequest.getSearchParams().get("couponId") == null ? "" : paginationRequest.getSearchParams().get("couponId").toString(); + if (StringUtils.isNotBlank(couponId)) { + lambdaQueryWrapper.eq(MtSendLog::getCouponId, couponId); + } + String mobile = paginationRequest.getSearchParams().get("mobile") == null ? "" : paginationRequest.getSearchParams().get("mobile").toString(); + if (StringUtils.isNotBlank(mobile)) { + lambdaQueryWrapper.eq(MtSendLog::getMobile, mobile); + } + + lambdaQueryWrapper.orderByDesc(MtSendLog::getId); + List dataList = mtSendLogMapper.selectList(lambdaQueryWrapper); + + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, MtSendLog.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 添加发放记录 + * + * @param reqSendLogDto + * @throws BusinessCheckException + * @return + */ + @Override + public MtSendLog addSendLog(ReqSendLogDto reqSendLogDto) { + MtSendLog mtLog = new MtSendLog(); + mtLog.setMerchantId(reqSendLogDto.getMerchantId()); + mtLog.setStoreId(reqSendLogDto.getStoreId()); + mtLog.setType(reqSendLogDto.getType()); + mtLog.setUserId(reqSendLogDto.getUserId()); + mtLog.setFileName(reqSendLogDto.getFileName()); + mtLog.setFilePath(reqSendLogDto.getFilePath()); + mtLog.setMobile(reqSendLogDto.getMobile()); + mtLog.setCouponId(reqSendLogDto.getCouponId()); + mtLog.setGroupId(reqSendLogDto.getGroupId()); + mtLog.setGroupName(reqSendLogDto.getGroupName()); + mtLog.setSendNum(reqSendLogDto.getSendNum()); + mtLog.setRemoveSuccessNum(0); + mtLog.setRemoveFailNum(0); + mtLog.setStatus(StatusEnum.ENABLED.getKey()); + mtLog.setCreateTime(new Date()); + mtLog.setOperator(reqSendLogDto.getOperator()); + mtLog.setUuid(reqSendLogDto.getUuid()); + mtSendLogMapper.insert(mtLog); + return mtLog; + } + + /** + * 根据ID查询发券记录 + * + * @param id 发券记录ID + * @throws BusinessCheckException + * @return + */ + @Override + public MtSendLog querySendLogById(Long id) { + return mtSendLogMapper.selectById(id.intValue()); + } + + /** + * 根据ID删除发券记录 + * + * @param id 发券记录ID + * @param operator 操作人 + * @throws BusinessCheckException + * @return + */ + @Override + public void deleteSendLog(Long id, String operator) { + MtSendLog couponGroup = querySendLogById(id); + + if (null == couponGroup) { + return; + } + + couponGroup.setStatus(StatusEnum.DISABLE.getKey()); + couponGroup.setOperator(operator); + mtSendLogMapper.updateById(couponGroup); + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/SendSmsServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/SendSmsServiceImpl.java new file mode 100644 index 0000000..0f97c54 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/SendSmsServiceImpl.java @@ -0,0 +1,261 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.fuint.common.dto.MessageResDto; +import com.fuint.common.enums.StatusEnum; +import com.fuint.common.service.SendSmsService; +import com.fuint.common.service.SmsTemplateService; +import com.fuint.common.util.CommonUtil; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.mapper.MtSmsSendedLogMapper; +import com.fuint.repository.model.MtSmsSendedLog; +import com.fuint.repository.model.MtSmsTemplate; +import com.fuint.utils.StringUtil; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.core.env.Environment; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import com.aliyuncs.DefaultAcsClient; +import com.aliyuncs.IAcsClient; +import com.aliyuncs.CommonRequest; +import com.aliyuncs.CommonResponse; +import com.aliyuncs.exceptions.ClientException; +import com.aliyuncs.exceptions.ServerException; +import com.aliyuncs.http.MethodType; +import com.aliyuncs.profile.DefaultProfile; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.util.CollectionUtils; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 发送手机短信服务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class SendSmsServiceImpl implements SendSmsService { + + private static final Logger logger = LoggerFactory.getLogger(SendSmsServiceImpl.class); + + /** + * 系统环境变量 + * */ + private Environment env; + + private MtSmsSendedLogMapper mtSmsSendedLogMapper; + + /** + * 短信模板服务接口 + * */ + private SmsTemplateService smsTemplateService; + + /** + * 发送短信 + * + * @param merchantId 商户ID + * @param templateUname 模板名 + * @param phones 发送手机号 + * @param contentParams 发送参数 + * @return + * */ + @Override + public Map> sendSms(Integer merchantId, String templateUname, List phones, Map contentParams) throws BusinessCheckException { + logger.info("使用短信平台发送短信....."); + Integer mode = Integer.parseInt(env.getProperty("aliyun.sms.mode")); + if (mode.intValue() != 1) { + throw new BusinessCheckException("未开启短信发送开关,请联系管理员!"); + } + + if (templateUname != null && !CollectionUtils.isEmpty(phones)) { + Map> result = new HashMap<>(); + try { + if (mode != null && mode.intValue() == 1) { + // 手机号以","分隔拼接 + String mobilePhones = phones.stream().collect(Collectors.joining(",")); + MessageResDto res = sendMessage(merchantId, mobilePhones, templateUname, contentParams); + result.put(res.getResult(), phones); + } else { + result.put(Boolean.TRUE,phones); + logger.info("模拟短信平台发送短信....."); + } + } catch (Exception e) { + result.put(Boolean.FALSE,phones); + logger.error("推送至短信平台出错...参数[smscontent={},phones={}]", templateUname, phones); + logger.error(e.getMessage(),e); + } + return result; + } else { + throw new BusinessCheckException("手机号码和短信内容不能为空,请确认!"); + } + } + + /** + * 发送短信 + * + * @param phoneNo 短信发送手机号,多个手机号以英文半角逗号隔开,最多支持200个手机号 + * @param templateUname 短信模板英文名称 + * @return + */ + public MessageResDto sendMessage(Integer merchantId, String phoneNo, String templateUname, Map contentParams) { + MessageResDto resInfo = new MessageResDto(); + logger.info("sendMessage inParams:phoneNo={}, message={}", phoneNo, templateUname); + if (StringUtil.isBlank(phoneNo) || phoneNo.split(",").length > 200) { + logger.error("手机号列表不符合要求"); + resInfo.setResult(Boolean.FALSE); + return resInfo; + } + + String accessKeyId = env.getProperty("aliyun.sms.accessKeyId"); + String secret = env.getProperty("aliyun.sms.accessKeySecret"); + String signName = env.getProperty("aliyun.sms.signName"); + + MtSmsTemplate templateInfo = new MtSmsTemplate(); + try { + Map params = new HashMap<>(); + params.put("uname", templateUname); + //params.put("merchant_id", merchantId); + List templateList = smsTemplateService.querySmsTemplateByParams(params); + if (templateList.size() < 1) { + throw new BusinessCheckException("该短信模板不存在!"); + } + templateInfo = templateList.get(0); + if (!templateInfo.getStatus().equals(StatusEnum.ENABLED.getKey())) { + throw new BusinessCheckException("该短信模板未启用!"); + } + } catch (BusinessCheckException e) { + e.getStackTrace(); + } + + boolean flag = false; + try { + // 解决中文乱码 + if (!CommonUtil.isUtf8(signName) || CommonUtil.isErrCode(signName)) { + signName = new String(signName.getBytes("ISO8859-1"), "UTF-8"); + } + + // 阿里云短信 + DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, secret); + IAcsClient client = new DefaultAcsClient(profile); + + // 装配参数 + String smsContent = templateInfo.getContent(); + if (smsContent == null || StringUtil.isEmpty(smsContent)) { + resInfo.setResult(Boolean.FALSE); + return resInfo; + } + String paramJson = ""; + if (contentParams.size() > 0) { + for (Map.Entry entry : contentParams.entrySet()){ + String key = entry.getKey(); + String value = entry.getValue(); + smsContent = smsContent.replace("{"+key+"}", value); + } + try { + ObjectMapper mapper = new ObjectMapper(); + paramJson = mapper.writeValueAsString(contentParams); + } catch(Exception e){ + e.printStackTrace(); + } + } + + CommonRequest request = new CommonRequest(); + request.setSysMethod(MethodType.POST); + request.setSysDomain("dysmsapi.aliyuncs.com"); + request.setSysVersion("2017-05-25"); + request.setSysAction("SendSms"); + request.putQueryParameter("RegionId", "cn-hangzhou"); + request.putQueryParameter("PhoneNumbers", phoneNo); + request.putQueryParameter("SignName", signName); + request.putQueryParameter("TemplateCode", templateInfo.getCode()); + request.putQueryParameter("TemplateParam", paramJson); + + String res = ""; + try { + CommonResponse response = client.getCommonResponse(request); + res = response.getData(); + System.out.println(response.getData()); + } catch (ServerException e) { + e.printStackTrace(); + } catch (ClientException e) { + e.printStackTrace(); + } + logger.info("sendMessage outParams:{}", res); + saveSendLog(merchantId, phoneNo, smsContent); + flag = true; + } catch (Exception e) { + flag = false; + logger.error(e.getMessage(), e); + } finally { + resInfo.setResult(flag); + } + return resInfo; + } + + /** + * 发送短信日志记录 + * + * @param merchantId 商户ID + * @param phoneNo 短信发送手机号 + * @param message 短信内容 + * @return + */ + public void saveSendLog(Integer merchantId, String phoneNo, String message) { + MtSmsSendedLog mtSmsSendedLog = new MtSmsSendedLog(); + mtSmsSendedLog.setMerchantId(merchantId); + mtSmsSendedLog.setMobilePhone(phoneNo); + mtSmsSendedLog.setContent(message); + Date time = new Date(); + mtSmsSendedLog.setCreateTime(time); + mtSmsSendedLog.setSendTime(time); + mtSmsSendedLog.setUpdateTime(time); + mtSmsSendedLogMapper.insert(mtSmsSendedLog); + } + + /** + * 分页查询已发短信列表 + * + * @param paginationRequest + * @return + */ + @Override + public PaginationResponse querySmsListByPagination(PaginationRequest paginationRequest) { + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(MtSmsSendedLog::getMerchantId, merchantId); + } + String content = paginationRequest.getSearchParams().get("content") == null ? "" : paginationRequest.getSearchParams().get("content").toString(); + if (StringUtils.isNotBlank(content)) { + lambdaQueryWrapper.like(MtSmsSendedLog::getContent, content); + } + String mobile = paginationRequest.getSearchParams().get("mobile") == null ? "" : paginationRequest.getSearchParams().get("mobile").toString(); + if (StringUtils.isNotBlank(mobile)) { + lambdaQueryWrapper.eq(MtSmsSendedLog::getMobilePhone, mobile); + } + + lambdaQueryWrapper.orderByDesc(MtSmsSendedLog::getLogId); + List dataList = mtSmsSendedLogMapper.selectList(lambdaQueryWrapper); + + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, MtSmsSendedLog.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/SettingServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/SettingServiceImpl.java new file mode 100644 index 0000000..85dae84 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/SettingServiceImpl.java @@ -0,0 +1,186 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.dto.ParamDto; +import com.fuint.common.enums.PayTypeEnum; +import com.fuint.common.enums.PlatformTypeEnum; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.repository.mapper.MtSettingMapper; +import com.fuint.repository.model.MtSetting; +import com.fuint.common.enums.StatusEnum; +import com.fuint.common.service.SettingService; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.utils.StringUtil; +import lombok.AllArgsConstructor; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * 配置业务接口实现类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class SettingServiceImpl extends ServiceImpl implements SettingService { + + /** + * 系统环境变量 + * */ + private Environment env; + + private MtSettingMapper mtSettingMapper; + + /** + * 删除配置 + * + * @param merchantId 商户ID + * @param name 配置名称 + * @throws BusinessCheckException + * @return + */ + @Override + @OperationServiceLog(description = "删除配置信息") + public void removeSetting(Integer merchantId, String name) { + MtSetting info = querySettingByName(merchantId, name); + if (info != null) { + mtSettingMapper.deleteById(info.getId()); + } + return; + } + + /** + * 保存配置 + * + * @param mtSetting 配置参数 + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "保存配置信息") + public MtSetting saveSetting(MtSetting mtSetting) { + MtSetting info = querySettingByName(mtSetting.getMerchantId(), mtSetting.getName()); + if (null != info) { + if (mtSetting.getValue() != null) { + info.setValue(mtSetting.getValue()); + } + if (mtSetting.getDescription() != null) { + info.setDescription(mtSetting.getDescription()); + } + if (StringUtil.isNotEmpty(mtSetting.getOperator())) { + info.setOperator(mtSetting.getOperator()); + } + if (mtSetting.getUpdateTime() != null) { + info.setUpdateTime(mtSetting.getUpdateTime()); + } + if (mtSetting.getStatus() != null) { + info.setStatus(mtSetting.getStatus()); + } + if (mtSetting.getType() != null) { + info.setType(mtSetting.getType()); + } + mtSettingMapper.updateById(info); + } else { + // 创建配置 + mtSetting.setCreateTime(new Date()); + mtSetting.setStatus(StatusEnum.ENABLED.getKey()); + mtSettingMapper.insert(mtSetting); + } + + return mtSetting; + } + + /** + * 获取配置列表 + * + * @param merchantId 商户ID + * @param type 配置类型 + * @throws BusinessCheckException + * @return + */ + @Override + public List getSettingList(Integer merchantId, String type) { + List dataList = mtSettingMapper.querySettingByType(merchantId, type); + return dataList; + } + + /** + * 根据ID获取配置信息 + * + * @param merchantId 商户ID + * @param name 配置名称 + * @throws BusinessCheckException + * @return + */ + @Override + public MtSetting querySettingByName(Integer merchantId, String name) { + return mtSettingMapper.querySettingByName(merchantId, name); + } + + /** + * 获取系统上传的根路径 + * + * @return + * */ + @Override + public String getUploadBasePath() { + String basePath = env.getProperty("images.upload.url"); + String mode = env.getProperty("aliyun.oss.mode"); + + if (mode == null) { + return basePath; + } else { + if (mode.equals("1")) { + String domain = env.getProperty("aliyun.oss.domain"); + if (StringUtil.isNotEmpty(domain)) { + basePath = domain; + } + } + } + + return basePath; + } + + /** + * 获取支付方式列表 + * + * @param platform 平台 + * @return + * */ + @Override + public List getPayTypeList(String platform) { + List payTypeList = new ArrayList<>(); + + // 微信jsapi + ParamDto jsApi = new ParamDto(); + jsApi.setKey(PayTypeEnum.JSAPI.getKey()); + jsApi.setValue(PayTypeEnum.JSAPI.getKey()); + jsApi.setName(PayTypeEnum.JSAPI.getValue()); + + // 余额支付 + ParamDto balance = new ParamDto(); + balance.setKey(PayTypeEnum.BALANCE.getKey()); + balance.setValue(PayTypeEnum.BALANCE.getKey()); + balance.setName(PayTypeEnum.BALANCE.getValue()); + payTypeList.add(balance); + + // 扫码支付 + ParamDto micro = new ParamDto(); + micro.setKey(PayTypeEnum.MICROPAY.getKey()); + micro.setValue(PayTypeEnum.MICROPAY.getKey()); + micro.setValue(PayTypeEnum.MICROPAY.getValue()); + + // 微信公众号号 + if (platform.equals(PlatformTypeEnum.MP_WEIXIN.getCode())) { + payTypeList.add(jsApi); + } + + return payTypeList; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/SettlementServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/SettlementServiceImpl.java new file mode 100644 index 0000000..311bfe5 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/SettlementServiceImpl.java @@ -0,0 +1,235 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.fuint.common.dto.SettlementDto; +import com.fuint.common.dto.SettlementOrderDto; +import com.fuint.common.dto.UserOrderDto; +import com.fuint.common.enums.PayStatusEnum; +import com.fuint.common.enums.SettleStatusEnum; +import com.fuint.common.enums.StatusEnum; +import com.fuint.common.param.OrderListParam; +import com.fuint.common.service.OrderService; +import com.fuint.common.service.SettlementService; +import com.fuint.common.util.CommonUtil; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.module.backendApi.request.SettlementRequest; +import com.fuint.repository.mapper.MtSettlementMapper; +import com.fuint.repository.mapper.MtSettlementOrderMapper; +import com.fuint.repository.model.MtBanner; +import com.fuint.repository.model.MtOrder; +import com.fuint.repository.model.MtSettlement; +import com.fuint.repository.model.MtSettlementOrder; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; +import java.util.*; + +/** + * 订单结算相关业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class SettlementServiceImpl implements SettlementService { + + private MtSettlementMapper mtSettlementMapper; + + private MtSettlementOrderMapper mtSettlementOrderMapper; + + /** + * 订单服务接口 + * */ + private OrderService orderService; + + /** + * 分页查询结算列表 + * + * @param paginationRequest + * @return + */ + @Override + public PaginationResponse querySettlementListByPagination(PaginationRequest paginationRequest) { + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtSettlement::getStatus, StatusEnum.DISABLE.getKey()); + + String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtSettlement::getStatus, status); + } + String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(MtSettlement::getMerchantId, merchantId); + } + String storeId = paginationRequest.getSearchParams().get("storeId") == null ? "" : paginationRequest.getSearchParams().get("storeId").toString(); + if (StringUtils.isNotBlank(storeId)) { + lambdaQueryWrapper.eq(MtSettlement::getStoreId, storeId); + } + String description = paginationRequest.getSearchParams().get("description") == null ? "" : paginationRequest.getSearchParams().get("description").toString(); + if (StringUtils.isNotBlank(description)) { + lambdaQueryWrapper.like(MtSettlement::getDescription, description); + } + lambdaQueryWrapper.orderByDesc(MtSettlement::getId); + List dataList = mtSettlementMapper.selectList(lambdaQueryWrapper); + + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, MtSettlement.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 提交结算 + * + * @param requestParam + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "发起结算") + public Boolean submitSettlement(SettlementRequest requestParam) throws BusinessCheckException { + OrderListParam orderParam = new OrderListParam(); + orderParam.setMerchantId(requestParam.getMerchantId()); + orderParam.setStoreId(requestParam.getStoreId()); + orderParam.setDataType("paid"); + orderParam.setStartTime(requestParam.getStartTime()); + orderParam.setEndTime(requestParam.getEndTime()); + orderParam.setSettleStatus(SettleStatusEnum.WAIT.getKey()); + orderParam.setPage(1); + orderParam.setPageSize(100000); + + PaginationResponse response = orderService.getUserOrderList(orderParam); + List orderList = response.getContent(); + if (orderList == null || orderList.size() < 1) { + throw new BusinessCheckException("暂无符合结算条件的订单"); + } + + BigDecimal amount = new BigDecimal("0"); + BigDecimal totalOrderAmount = new BigDecimal("0"); + if (orderList != null && orderList.size() > 0) { + for (UserOrderDto orderDto : orderList) { + amount = amount.add(orderDto.getPayAmount()); + totalOrderAmount = totalOrderAmount.add(orderDto.getPayAmount()); + } + } + MtSettlement mtSettlement = new MtSettlement(); + mtSettlement.setMerchantId(requestParam.getMerchantId()); + mtSettlement.setStoreId(requestParam.getStoreId()); + mtSettlement.setSettlementNo(CommonUtil.createSettlementNo()); + mtSettlement.setAmount(amount); + mtSettlement.setTotalOrderAmount(totalOrderAmount); + mtSettlement.setStatus(StatusEnum.ENABLED.getKey()); + mtSettlement.setOperator(requestParam.getOperator()); + mtSettlement.setCreateTime(new Date()); + mtSettlement.setUpdateTime(new Date()); + mtSettlementMapper.insert(mtSettlement); + if (orderList != null && orderList.size() > 0) { + for (UserOrderDto orderDto : orderList) { + MtSettlementOrder mtSettlementOrder = new MtSettlementOrder(); + mtSettlementOrder.setSettlementId(mtSettlement.getId()); + mtSettlementOrder.setOrderId(orderDto.getId()); + mtSettlementOrder.setCreateTime(new Date()); + mtSettlementOrder.setUpdateTime(new Date()); + mtSettlement.setStatus(StatusEnum.ENABLED.getKey()); + mtSettlementOrder.setOperator(mtSettlement.getOperator()); + mtSettlementOrderMapper.insert(mtSettlementOrder); + // 把订单设置为已结算 + MtOrder mtOrder = orderService.getById(orderDto.getId()); + mtOrder.setSettleStatus(SettleStatusEnum.COMPLETE.getKey()); + orderService.updateOrder(mtOrder); + } + } + return true; + } + + /** + * 结算确认 + * + * @param settlementId 结算ID + * @param operator 操作人 + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "结算确认") + public Boolean doConfirm(Integer settlementId, String operator) throws BusinessCheckException { + MtSettlement mtSettlement = mtSettlementMapper.selectById(settlementId); + if (mtSettlement == null) { + throw new BusinessCheckException("结算数据不存在"); + } + mtSettlement.setStatus(SettleStatusEnum.COMPLETE.getKey()); + mtSettlement.setPayStatus(PayStatusEnum.SUCCESS.getKey()); + mtSettlement.setUpdateTime(new Date()); + mtSettlement.setOperator(operator); + mtSettlementMapper.updateById(mtSettlement); + return true; + } + + /** + * 获取结算详情 + * + * @param settlementId 结算ID + * @param page 当前页码 + * @param pageSize 每页数量 + * @return + * */ + @Override + public SettlementDto getSettlementInfo(Integer settlementId, Integer page, Integer pageSize) throws BusinessCheckException { + MtSettlement mtSettlement = mtSettlementMapper.selectById(settlementId); + if (mtSettlement == null) { + throw new BusinessCheckException("结算单不存在"); + } + + SettlementDto settlementDto = new SettlementDto(); + BeanUtils.copyProperties(mtSettlement, settlementDto); + + Page pageHelper = PageHelper.startPage(page, pageSize); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtSettlementOrder::getStatus, StatusEnum.DISABLE.getKey()); + lambdaQueryWrapper.eq(MtSettlementOrder::getSettlementId, settlementId); + lambdaQueryWrapper.orderByDesc(MtSettlementOrder::getId); + List dataList = mtSettlementOrderMapper.selectList(lambdaQueryWrapper); + + PageRequest pageRequest = PageRequest.of(page, pageSize); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, SettlementOrderDto.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + + List orderList = new ArrayList<>(); + if (dataList != null && dataList.size() > 0) { + for (MtSettlementOrder mtSettlementOrder : dataList) { + SettlementOrderDto settlementOrderDto = new SettlementOrderDto(); + BeanUtils.copyProperties(mtSettlementOrder, settlementOrderDto); + UserOrderDto orderDto = orderService.getOrderById(settlementOrderDto.getOrderId()); + if (orderDto != null) { + settlementOrderDto.setOrderInfo(orderDto); + } + orderList.add(settlementOrderDto); + } + } + paginationResponse.setContent(orderList); + + settlementDto.setOrderList(paginationResponse); + return settlementDto; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/SmsTemplateServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/SmsTemplateServiceImpl.java new file mode 100644 index 0000000..6d1c70b --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/SmsTemplateServiceImpl.java @@ -0,0 +1,170 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.dto.SmsTemplateDto; +import com.fuint.common.enums.StatusEnum; +import com.fuint.common.service.SmsTemplateService; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.mapper.MtSmsTemplateMapper; +import com.fuint.repository.model.MtSmsTemplate; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 短信模板业务实现类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class SmsTemplateServiceImpl extends ServiceImpl implements SmsTemplateService { + + private MtSmsTemplateMapper mtSmsTemplateMapper; + + /** + * 分页查询模板列表 + * + * @param paginationRequest + * @return + */ + @Override + public PaginationResponse querySmsTemplateListByPagination(PaginationRequest paginationRequest) { + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtSmsTemplate::getStatus, StatusEnum.DISABLE.getKey()); + + String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.like(MtSmsTemplate::getMerchantId, merchantId); + } + String name = paginationRequest.getSearchParams().get("name") == null ? "" : paginationRequest.getSearchParams().get("name").toString(); + if (StringUtils.isNotBlank(name)) { + lambdaQueryWrapper.like(MtSmsTemplate::getName, name); + } + String uname = paginationRequest.getSearchParams().get("uname") == null ? "" : paginationRequest.getSearchParams().get("uname").toString(); + if (StringUtils.isNotBlank(uname)) { + lambdaQueryWrapper.eq(MtSmsTemplate::getUname, uname); + } + String code = paginationRequest.getSearchParams().get("code") == null ? "" : paginationRequest.getSearchParams().get("code").toString(); + if (StringUtils.isNotBlank(code)) { + lambdaQueryWrapper.eq(MtSmsTemplate::getCode, code); + } + String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtSmsTemplate::getStatus, status); + } + + lambdaQueryWrapper.orderByDesc(MtSmsTemplate::getId); + List dataList = mtSmsTemplateMapper.selectList(lambdaQueryWrapper); + + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, MtSmsTemplate.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 保存模板信息 + * + * @param mtSmsTemplateDto 短信模板 + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "保存短信模板") + public MtSmsTemplate saveSmsTemplate(SmsTemplateDto mtSmsTemplateDto) throws BusinessCheckException { + MtSmsTemplate mtSmsTemplate = new MtSmsTemplate(); + mtSmsTemplate.setMerchantId(mtSmsTemplateDto.getMerchantId()); + mtSmsTemplate.setCode(mtSmsTemplateDto.getCode()); + mtSmsTemplate.setName(mtSmsTemplateDto.getName()); + mtSmsTemplate.setUname(mtSmsTemplateDto.getUname()); + mtSmsTemplate.setContent(mtSmsTemplateDto.getContent()); + mtSmsTemplate.setStatus(mtSmsTemplateDto.getStatus()); + mtSmsTemplate.setOperator(mtSmsTemplate.getOperator()); + + if (mtSmsTemplateDto.getId() == null) { + mtSmsTemplate.setCreateTime(new Date()); + mtSmsTemplate.setUpdateTime(new Date()); + mtSmsTemplateMapper.insert(mtSmsTemplate); + } else { + MtSmsTemplate oldSmsTemplate = getById(mtSmsTemplateDto.getId()); + if (oldSmsTemplate == null) { + throw new BusinessCheckException("该短信模板不存在"); + } + mtSmsTemplate.setMerchantId(oldSmsTemplate.getMerchantId()); + mtSmsTemplate.setId(mtSmsTemplateDto.getId()); + mtSmsTemplate.setUpdateTime(new Date()); + this.updateById(mtSmsTemplate); + } + + return mtSmsTemplate; + } + + /** + * 根据ID删除数据 + * + * @param id 模板ID + * @param operator 操作人 + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "删除短信模板") + public void deleteTemplate(Integer id, String operator) { + MtSmsTemplate mtTemplate = mtSmsTemplateMapper.selectById(id); + if (null == mtTemplate) { + return; + } + + mtTemplate.setStatus(StatusEnum.DISABLE.getKey()); + mtTemplate.setUpdateTime(new Date()); + + mtSmsTemplateMapper.updateById(mtTemplate); + } + + /** + * 根据D获取信息 + * + * @param id 模板ID + * @return + */ + @Override + public MtSmsTemplate querySmsTemplateById(Integer id) { + return mtSmsTemplateMapper.selectById(id); + } + + /** + * 根据参数查询短信模板 + * + * @param params 查询参数 + * @return + * */ + @Override + public List querySmsTemplateByParams(Map params) { + if (params == null) { + params = new HashMap<>(); + } + List result = mtSmsTemplateMapper.selectByMap(params); + return result; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/SourceServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/SourceServiceImpl.java new file mode 100644 index 0000000..956e912 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/SourceServiceImpl.java @@ -0,0 +1,306 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.domain.TreeSelect; +import com.fuint.common.enums.StatusEnum; +import com.fuint.common.service.SourceService; +import com.fuint.common.vo.MetaVo; +import com.fuint.common.vo.RouterVo; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.repository.mapper.TSourceMapper; +import com.fuint.repository.model.TSource; +import com.fuint.common.domain.TreeNode; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.utils.ArrayUtil; +import com.fuint.utils.StringUtil; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 菜单管理接口实现类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class SourceServiceImpl extends ServiceImpl implements SourceService { + + private TSourceMapper tSourceMapper; + + /** + * 获取有效的角色集合 + * + * @param merchantId 商户ID + * @return + */ + @Override + public List getAvailableSources(Integer merchantId) { + return tSourceMapper.findByStatus(merchantId, StatusEnum.ENABLED.getKey()); + } + + /** + * 获取菜单的属性结构 + * + * @param merchantId 商户IF + * @return + */ + @Override + public List getSourceTree(Integer merchantId) { + List tSources = getAvailableSources(merchantId); + List trees = new ArrayList<>(); + if (tSources != null && tSources.size() > 0) { + TreeNode sourceTreeNode; + for (TSource tSource : tSources) { + sourceTreeNode = new TreeNode(); + sourceTreeNode.setName(tSource.getSourceName()); + sourceTreeNode.setId(tSource.getSourceId()); + sourceTreeNode.setLevel(tSource.getSourceLevel()); + sourceTreeNode.setSort((tSource.getSourceStyle() == null || StringUtil.isEmpty(tSource.getSourceStyle())) ? 0 : Integer.parseInt(tSource.getSourceStyle())); + sourceTreeNode.setPath(tSource.getPath()); + sourceTreeNode.setIcon(tSource.getNewIcon()); + sourceTreeNode.setIsMenu(tSource.getIsMenu()); + sourceTreeNode.setStatus(tSource.getStatus()); + sourceTreeNode.setPerms(tSource.getPath().replaceAll("/", ":")); + if (tSource.getParentId() != null) { + sourceTreeNode.setPId(tSource.getParentId()); + } else { + sourceTreeNode.setPId(0); + } + trees.add(sourceTreeNode); + } + } + return trees; + } + + /** + * 根据菜单ID集合查询菜单列表信息 + * + * @param ids 菜单ID + * @return + */ + @Override + public List findDatasByIds(String[] ids) { + Long[] arrays = new Long[ids.length]; + for (int i = 0; i < ids.length; i++) { + arrays[i] = Long.parseLong(ids[i]); + } + return tSourceMapper.findByIdIn(ArrayUtil.toList(arrays)); + } + + /** + * 根据账号ID获取菜单列表 + * + * @param merchantId 商户ID + * @param accountId 账号ID + * @throws BusinessCheckException + */ + @Override + public List getMenuListByUserId(Integer merchantId, Integer accountId) { + if (merchantId == null) { + merchantId = 0; + } + List sourceList = tSourceMapper.findSourcesByAccountId(merchantId, accountId); + return delRepeated(sourceList); + } + + /** + * 构建前端路由所需要的菜单 + * + * @param treeNodes 菜单列表 + * @return 路由列表 + */ + @Override + public List buildMenus(List treeNodes) { + List routers = new LinkedList<>(); + + for (TreeNode menu : treeNodes) { + RouterVo router = new RouterVo(); + if (menu.getIsMenu() == 0) { + router.setHidden(true); + } else { + router.setHidden(false); + } + router.setName(menu.getEname()); + if (menu.getLevel() == 1) { + router.setComponent("Layout"); + router.setPath("/" + menu.getEname().toLowerCase()); + router.setRedirect("noRedirect"); + router.setAlwaysShow(true); + } else { + if (menu.getIsMenu() == 2) { + router.setAlwaysShow(true); + } else { + router.setAlwaysShow(false); + } + router.setComponent(menu.getPath()); + router.setPath('/' + menu.getPath()); + } + router.setMeta(new MetaVo(menu.getName(), menu.getNewIcon(), false, null)); + List cMenus = menu.getChildrens(); + if (cMenus != null && !cMenus.isEmpty() && cMenus.size() > 0) { + router.setChildren(buildMenus(cMenus)); + } + routers.add(router); + } + + return routers; + } + + /** + * 构建前端所需要下拉树结构 + * + * @param menus 菜单列表 + * @return 下拉树结构列表 + */ + @Override + public List buildMenuTreeSelect(List menus) { + List menuTrees = buildMenuTree(menus); + return menuTrees.stream().map(TreeSelect::new).collect(Collectors.toList()); + } + + /** + * 构建前端所需要树结构 + * + * @param menus 菜单列表 + * @return 树结构列表 + */ + @Override + public List buildMenuTree(List menus) { + List returnList = new ArrayList(); + List tempList = new ArrayList(); + for (TreeNode dept : menus) { + tempList.add(dept.getId()); + } + for (Iterator iterator = menus.iterator(); iterator.hasNext();) { + TreeNode menu = (TreeNode) iterator.next(); + // 如果是顶级节点, 遍历该父节点的所有子节点 + if (!tempList.contains(menu.getPId())) { + recursionFn(menus, menu); + returnList.add(menu); + } + } + if (returnList.isEmpty()) { + returnList = menus; + } + return returnList; + } + + /** + * 添加菜单 + * + * @param tSource + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "新增后台菜单") + public void addSource(TSource tSource) { + this.save(tSource); + } + + /** + * 修改菜单 + * + * @param source + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "修改后台菜单") + public void editSource(TSource source) { + tSourceMapper.updateById(source); + } + + /** + * 删除菜单 + * + * @param source + * @return + * */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "删除后台菜单") + public void deleteSource(TSource source) { + source.setStatus(StatusEnum.DISABLE.getKey()); + editSource(source); + + Map param = new HashMap<>(); + param.put("STATUS", StatusEnum.ENABLED.getKey()); + param.put("PARENT_ID", source.getSourceId()); + List dataList = tSourceMapper.selectByMap(param); + if (dataList != null && dataList.size() > 0) { + for (TSource tSource : dataList) { + deleteSource(tSource); + } + } + } + + /** + * 菜单去重 + * + * @param sources + * @return + */ + private List delRepeated(List sources) { + List distinct = new ArrayList<>(); + if (sources != null) { + Map sourceMap = new HashMap<>(); + for (TSource tSource : sources) { + if (sourceMap.get(tSource.getSourceId()) == null) { + sourceMap.put(tSource.getSourceId().longValue(), true); + distinct.add(tSource); + } + } + } + return distinct; + } + + /** + * 递归列表 + * + * @param list + * @param t + */ + private void recursionFn(List list, TreeNode t) { + // 得到子节点列表 + List childList = getChildList(list, t); + t.setChildrens(childList); + for (TreeNode tChild : childList) { + if (hasChild(list, tChild)) { + recursionFn(list, tChild); + } + } + } + + /** + * 得到子节点列表 + * + * @param list 菜单列表 + * @param t 当前节点 + * @return + */ + private List getChildList(List list, TreeNode t) { + List tList = new ArrayList(); + Iterator it = list.iterator(); + while (it.hasNext()) { + TreeNode n = it.next(); + if (n.getPId() == t.getId()) { + tList.add(n); + } + } + return tList; + } + + /** + * 判断是否有子节点 + * + * @param list 菜单列表 + * @param t 当前节点 + * @return + */ + private boolean hasChild(List list, TreeNode t) { + return getChildList(list, t).size() > 0; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/StaffServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/StaffServiceImpl.java new file mode 100644 index 0000000..14704fc --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/StaffServiceImpl.java @@ -0,0 +1,258 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.enums.StatusEnum; +import com.fuint.common.service.MemberService; +import com.fuint.common.service.SendSmsService; +import com.fuint.common.service.StaffService; +import com.fuint.common.service.StoreService; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.mapper.MtStaffMapper; +import com.fuint.repository.model.MtStaff; +import com.fuint.repository.model.MtStore; +import com.fuint.repository.model.MtUser; +import com.fuint.utils.StringUtil; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import java.util.*; + +/** + * 员工管理接口实现类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class StaffServiceImpl extends ServiceImpl implements StaffService { + + private MtStaffMapper mtStaffMapper; + + /** + * 会员服务接口 + */ + private MemberService memberService; + + /** + * 短信发送接口 + */ + private SendSmsService sendSmsService; + + /** + * 店铺接口 + */ + private StoreService storeService; + + /** + * 员工查询列表 + * + * @param paginationRequest + * @return + */ + @Override + public PaginationResponse queryStaffListByPagination(PaginationRequest paginationRequest) { + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtStaff::getAuditedStatus, StatusEnum.DISABLE.getKey()); + + String name = paginationRequest.getSearchParams().get("name") == null ? "" : paginationRequest.getSearchParams().get("name").toString(); + if (StringUtils.isNotBlank(name)) { + lambdaQueryWrapper.like(MtStaff::getRealName, name); + } + String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtStaff::getAuditedStatus, status); + } + String mobile = paginationRequest.getSearchParams().get("mobile") == null ? "" : paginationRequest.getSearchParams().get("mobile").toString(); + if (StringUtils.isNotBlank(mobile)) { + lambdaQueryWrapper.eq(MtStaff::getMobile, mobile); + } + String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(MtStaff::getMerchantId, merchantId); + } + String storeId = paginationRequest.getSearchParams().get("storeId") == null ? "" : paginationRequest.getSearchParams().get("storeId").toString(); + if (StringUtils.isNotBlank(storeId)) { + lambdaQueryWrapper.eq(MtStaff::getStoreId, storeId); + } + String category = paginationRequest.getSearchParams().get("category") == null ? "" : paginationRequest.getSearchParams().get("category").toString(); + if (StringUtils.isNotBlank(category)) { + lambdaQueryWrapper.eq(MtStaff::getCategory, category); + } + + lambdaQueryWrapper.orderByDesc(MtStaff::getId); + List dataList = mtStaffMapper.selectList(lambdaQueryWrapper); + if (dataList != null && dataList.size() > 0) { + for (MtStaff mtStaff : dataList) { + // 隐藏手机号中间四位 + String phone = mtStaff.getMobile(); + if (phone != null && StringUtil.isNotEmpty(phone) && phone.length() == 11) { + mtStaff.setMobile(phone.substring(0, 3) + "****" + phone.substring(7)); + } + } + } + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, MtStaff.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 保存员工信息 + * + * @param mtStaff 员工参数 + * @throws BusinessCheckException + * @return + */ + @Override + @OperationServiceLog(description = "保存店铺员工") + public MtStaff saveStaff(MtStaff mtStaff) throws BusinessCheckException { + mtStaff.setUpdateTime(new Date()); + if (mtStaff.getId() == null || mtStaff.getId() <= 0) { + mtStaff.setCreateTime(new Date()); + if (mtStaff.getAuditedStatus() == null) { + mtStaff.setAuditedStatus(StatusEnum.UnAudited.getKey()); + } else { + mtStaff.setAuditedStatus(mtStaff.getAuditedStatus()); + } + this.save(mtStaff); + } else { + Integer id = mtStaff.getId(); + MtStaff mtStaffOld = mtStaffMapper.selectById(id); + if (mtStaffOld.getAuditedStatus().equals(StatusEnum.ENABLED.getKey())) { + mtStaff.setAuditedTime(new Date()); + } + mtStaff.setMerchantId(mtStaffOld.getMerchantId()); + } + + MtUser mtUser = null; + if (mtStaff.getUserId() != null) { + mtUser = memberService.queryMemberById(mtStaff.getUserId()); + } + + // 关联会员信息 + if (mtStaff.getUserId() == null || mtUser == null) { + MtUser userInfo = new MtUser(); + userInfo.setName(mtStaff.getRealName()); + userInfo.setDescription("系统自动注册店铺员工账号"); + userInfo.setStoreId(mtStaff.getStoreId()); + userInfo.setMerchantId(mtStaff.getMerchantId()); + mtUser = memberService.addMember(userInfo); + if (mtUser != null) { + mtStaff.setUserId(mtUser.getId()); + } else { + throw new BusinessCheckException("新增员工失败"); + } + } + + // 更新员工 + this.updateById(mtStaff); + return mtStaff; + } + + /** + * 根据ID获取员工信息 + * + * @param id 员工ID + * @throws BusinessCheckException + * @return + */ + @Override + public MtStaff queryStaffById(Integer id) { + MtStaff mtStaff = mtStaffMapper.selectById(id); + return mtStaff; + } + + /** + * 修改店铺员工状态 + * + * @param staffId 员工ID + * @throws BusinessCheckException + * @return + */ + @Override + @OperationServiceLog(description = "修改店铺员工状态") + public Integer updateAuditedStatus(Integer staffId, String status) throws BusinessCheckException { + MtStaff mtStaff = mtStaffMapper.selectById(staffId); + if (mtStaff != null) { + mtStaff.setAuditedStatus(status); + mtStaff.setUpdateTime(new Date()); + mtStaff.setAuditedTime(new Date()); + mtStaffMapper.updateById(mtStaff); + + // 发送短信通知 +// MtStore mtStore = storeService.queryStoreById(mtStaff.getStoreId()); +// if (mtStore == null) { +// mtStore = new MtStore(); +// mtStore.setName("全部店铺"); +// } +// List mobileList = new ArrayList<>(); +// mobileList.add(mtStaff.getMobile()); + +// try { +// Map params = new HashMap<>(); +// params.put("name", mtStaff.getRealName()); +// params.put("storeId", mtStaff.getStoreId().toString()); +// sendSmsService.sendSms(mtStaff.getMerchantId(), "confirmer-authed", mobileList, params); +// } catch (Exception e) { +// // empty +// } + } else { + return 0; + } + + return staffId; + } + + /** + * 根据条件搜索员工 + * + * @param params 查询参数 + * @return + * */ + @Override + public List queryStaffByParams(Map params) { + if (params == null) { + params = new HashMap<>(); + } + return mtStaffMapper.selectByMap(params); + } + + /** + * 根据手机号获取员工信息 + * + * @param mobile 手机号 + * @throws BusinessCheckException + * @return + */ + @Override + public MtStaff queryStaffByMobile(String mobile) { + return mtStaffMapper.queryStaffByMobile(mobile); + } + + /** + * 根据会员ID获取员工信息 + * + * @param userId 会员ID + * @throws BusinessCheckException + * @return + */ + @Override + public MtStaff queryStaffByUserId(Integer userId) { + return mtStaffMapper.queryStaffByUserId(userId); + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/StockServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/StockServiceImpl.java new file mode 100644 index 0000000..862907f --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/StockServiceImpl.java @@ -0,0 +1,216 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.enums.StatusEnum; +import com.fuint.common.enums.YesOrNoEnum; +import com.fuint.common.service.*; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.framework.web.ResponseObject; +import com.fuint.repository.mapper.*; +import com.fuint.repository.model.*; +import com.fuint.utils.StringUtil; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.util.*; + +/** + * 库存业务实现类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class StockServiceImpl extends ServiceImpl implements StockService { + + private MtStockMapper mtStockMapper; + + private MtStockItemMapper mtStockItemMapper; + + private MtGoodsMapper mtGoodsMapper; + + private MtGoodsSkuMapper mtGoodsSkuMapper; + + /** + * 分页查询库存管理记录列表 + * + * @param paginationRequest + * @return + */ + @Override + public PaginationResponse queryStockListByPagination(PaginationRequest paginationRequest) { + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtStock::getStatus, StatusEnum.DISABLE.getKey()); + + String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtStock::getStatus, status); + } + String type = paginationRequest.getSearchParams().get("type") == null ? "" : paginationRequest.getSearchParams().get("type").toString(); + if (StringUtils.isNotBlank(type)) { + lambdaQueryWrapper.eq(MtStock::getType, type); + } + String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(MtStock::getMerchantId, merchantId); + } + String storeId = paginationRequest.getSearchParams().get("storeId") == null ? "" : paginationRequest.getSearchParams().get("storeId").toString(); + if (StringUtils.isNotBlank(storeId)) { + lambdaQueryWrapper.eq(MtStock::getStoreId, storeId); + } + String description = paginationRequest.getSearchParams().get("description") == null ? "" : paginationRequest.getSearchParams().get("description").toString(); + if (StringUtils.isNotBlank(description)) { + lambdaQueryWrapper.like(MtStock::getDescription, description); + } + + lambdaQueryWrapper.orderByDesc(MtStock::getId); + List dataList = mtStockMapper.selectList(lambdaQueryWrapper); + + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, MtStock.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 新增库存管理记录 + * + * @param stockParam 库存参数 + * @param goodsList 商品列表 + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public ResponseObject addStock(MtStock stockParam, List goodsList) throws BusinessCheckException { + MtStock mtStock = new MtStock(); + mtStock.setMerchantId(stockParam.getMerchantId()); + mtStock.setStoreId(stockParam.getStoreId()); + mtStock.setStatus(StatusEnum.ENABLED.getKey()); + mtStock.setType(stockParam.getType()); + Date createTime = new Date(); + mtStock.setCreateTime(createTime); + mtStock.setUpdateTime(createTime); + mtStock.setDescription(stockParam.getDescription()); + mtStock.setOperator(stockParam.getOperator()); + this.save(mtStock); + + Integer stockId = mtStock.getId(); + for (LinkedHashMap goods : goodsList) { + MtStockItem mtStockItem = new MtStockItem(); + mtStockItem.setStockId(stockId); + Integer goodsId = Integer.parseInt(goods.get("id").toString()); + Integer skuId = null; + Integer num = Integer.parseInt(goods.get("num").toString()); + mtStockItem.setGoodsId(goodsId); + if (goods.get("skuId") != null && StringUtil.isNotEmpty(goods.get("skuId").toString())) { + skuId = Integer.parseInt(goods.get("skuId").toString()); + mtStockItem.setSkuId(skuId); + } + mtStockItem.setStatus(StatusEnum.ENABLED.getKey()); + mtStockItem.setNum(num); + mtStockItem.setCreateTime(createTime); + mtStockItem.setUpdateTime(createTime); + mtStockItemMapper.insert(mtStockItem); + + // 库存操作 + MtGoods goodsInfo = mtGoodsMapper.selectById(goodsId); + if (goodsInfo.getIsSingleSpec().equals(YesOrNoEnum.YES.getKey())) { + // 单规格库存 + Integer stock; + if (mtStock.getType().equals("increase")) { + stock = goodsInfo.getStock() + num; + } else { + stock = goodsInfo.getStock() - num; + } + if (stock < 0) { + throw new BusinessCheckException("商品“" + goodsInfo.getName() + "”库存不足,提交失败"); + } + goodsInfo.setStock(stock); + mtGoodsMapper.updateById(goodsInfo); + } else { + // 多规格库存 + MtGoodsSku mtGoodsSku = mtGoodsSkuMapper.selectById(skuId); + if (mtGoodsSku != null) { + Integer stock; + if (mtStock.getType().equals("increase")) { + stock = mtGoodsSku.getStock() + num; + } else { + stock = mtGoodsSku.getStock() - num; + } + if (stock < 0) { + throw new BusinessCheckException("商品sku编码“" + mtGoodsSku.getSkuNo() +"”库存不足,提交失败"); + } + mtGoodsSku.setStock(stock); + mtGoodsSkuMapper.updateById(mtGoodsSku); + } + } + } + ResponseObject result = new ResponseObject(200, "", mtStock); + return result; + } + + /** + * 删除库存管理记录 + * + * @param id ID + * @param operator 操作人 + * @throws BusinessCheckException + * @return + */ + @Override + @OperationServiceLog(description = "删除商品分类") + public void delete(Integer id, String operator) throws BusinessCheckException { + MtStock mtStock = mtStockMapper.selectById(id); + if (mtStock == null) { + return; + } + mtStock.setStatus(StatusEnum.DISABLE.getKey()); + mtStock.setUpdateTime(new Date()); + mtStock.setOperator(operator); + this.updateById(mtStock); + } + + /** + * 根据ID获取库存管理记录 + * + * @param id ID + * @throws BusinessCheckException + * @return + */ + @Override + public MtStock queryStockById(Long id) { + return mtStockMapper.selectById(id.intValue()); + } + + /** + * 根据条件查询库存项 + * + * @param params 查询条件 + * @return + * */ + @Override + public List queryItemByParams(Map params) { + if (params == null) { + params = new HashMap<>(); + } + List result = mtStockItemMapper.selectByMap(params); + return result; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/StoreLocationServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/StoreLocationServiceImpl.java new file mode 100644 index 0000000..1d0bfba --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/StoreLocationServiceImpl.java @@ -0,0 +1,153 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.dto.StoreLocationDto; +import com.fuint.common.enums.StatusEnum; +import com.fuint.common.service.StoreLocationService; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.mapper.MtStoreLocationMapper; +import com.fuint.repository.model.MtStoreLocation; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 店铺地点业务实现类 + */ +@Service +@AllArgsConstructor +public class StoreLocationServiceImpl extends ServiceImpl implements StoreLocationService { + + private MtStoreLocationMapper mtStoreLocationMapper; + + /** + * 分页查询模板列表 + * + * @param paginationRequest + * @return + */ + @Override + public PaginationResponse queryStoreLocationListByPagination(PaginationRequest paginationRequest) { + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtStoreLocation::getStatus, StatusEnum.DISABLE.getKey()); + + String name = paginationRequest.getSearchParams().get("name") == null ? "" : paginationRequest.getSearchParams().get("name").toString(); + if (StringUtils.isNotBlank(name)) { + lambdaQueryWrapper.like(MtStoreLocation::getName, name); + } + + String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtStoreLocation::getStatus, status); + } + + lambdaQueryWrapper.orderByDesc(MtStoreLocation::getId); + List dataList = mtStoreLocationMapper.selectList(lambdaQueryWrapper); + + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, MtStoreLocation.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 保存信息 + * + * @param mtStoreLocationDto + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "保存短信模板") + public MtStoreLocation saveStoreLocation(StoreLocationDto mtStoreLocationDto) throws BusinessCheckException { + MtStoreLocation mtStoreLocation = new MtStoreLocation(); + mtStoreLocation.setName(mtStoreLocationDto.getName()); + mtStoreLocation.setContent(mtStoreLocationDto.getContent()); + mtStoreLocation.setStatus(mtStoreLocationDto.getStatus()); + mtStoreLocation.setOperator(mtStoreLocationDto.getOperator()); + + if (mtStoreLocationDto.getId() == null) { + mtStoreLocation.setCreateTime(new Date()); + mtStoreLocation.setUpdateTime(new Date()); + mtStoreLocationMapper.insert(mtStoreLocation); + } else { + MtStoreLocation oldSmsTemplate = getById(mtStoreLocationDto.getId()); + if (oldSmsTemplate == null) { + throw new BusinessCheckException("该地点不存在"); + } + mtStoreLocation.setId(mtStoreLocationDto.getId()); + mtStoreLocation.setUpdateTime(new Date()); + this.updateById(mtStoreLocation); + } + + return mtStoreLocation; + } + + /** + * 根据ID删除数据 + * + * @param id 模板ID + * @param operator 操作人 + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "删除短信模板") + public void deleteStoreLocation(Integer id, String operator) { + MtStoreLocation mtTemplate = mtStoreLocationMapper.selectById(id); + if (null == mtTemplate) { + return; + } + + mtTemplate.setStatus(StatusEnum.DISABLE.getKey()); + mtTemplate.setUpdateTime(new Date()); + + mtStoreLocationMapper.updateById(mtTemplate); + } + + /** + * 根据D获取信息 + * + * @param id 模板ID + * @return + */ + @Override + public MtStoreLocation queryStoreLocationById(Integer id) { + return mtStoreLocationMapper.selectById(id); + } + + /** + * 根据参数查询 + * + * @param params 查询参数 + * @return + * */ + @Override + public List queryStoreLocationByParams(Map params) { + if (params == null) { + params = new HashMap<>(); + } + List result = mtStoreLocationMapper.selectByMap(params); + return result; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/StoreServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/StoreServiceImpl.java new file mode 100644 index 0000000..c824121 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/StoreServiceImpl.java @@ -0,0 +1,385 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.dto.StoreDto; +import com.fuint.common.enums.StatusEnum; +import com.fuint.common.enums.YesOrNoEnum; +import com.fuint.common.service.MerchantService; +import com.fuint.common.service.StoreService; +import com.fuint.common.service.WeixinService; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.bean.StoreDistanceBean; +import com.fuint.repository.mapper.MtMerchantMapper; +import com.fuint.repository.mapper.MtStoreMapper; +import com.fuint.repository.model.MtMerchant; +import com.fuint.repository.model.MtStore; +import com.fuint.utils.StringUtil; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; +import java.util.*; + +/** + * 店铺管理业务实现类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class StoreServiceImpl extends ServiceImpl implements StoreService { + + private MtStoreMapper mtStoreMapper; + + private MtMerchantMapper mtMerchantMapper; + + /** + * 商户接口 + */ + private MerchantService merchantService; + + /** + * 微信服务接口 + * */ + private WeixinService weixinService; + + /** + * 分页查询店铺列表 + * + * @param paginationRequest + * @return + */ + @Override + public PaginationResponse queryStoreListByPagination(PaginationRequest paginationRequest) { + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtStore::getStatus, StatusEnum.DISABLE.getKey()); + + String name = paginationRequest.getSearchParams().get("name") == null ? "" : paginationRequest.getSearchParams().get("name").toString(); + if (StringUtils.isNotBlank(name)) { + lambdaQueryWrapper.like(MtStore::getName, name); + } + String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtStore::getStatus, status); + } + String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(MtStore::getMerchantId, merchantId); + } + String storeId = paginationRequest.getSearchParams().get("storeId") == null ? "" : paginationRequest.getSearchParams().get("storeId").toString(); + if (StringUtils.isNotBlank(storeId)) { + lambdaQueryWrapper.eq(MtStore::getId, storeId); + } + + lambdaQueryWrapper.orderByAsc(MtStore::getStatus).orderByDesc(MtStore::getIsDefault); + List storeList = mtStoreMapper.selectList(lambdaQueryWrapper); + List dataList = new ArrayList<>(); + + for (MtStore mtStore : storeList) { + StoreDto storeDto = new StoreDto(); + BeanUtils.copyProperties(mtStore, storeDto); + MtMerchant mtMerchant = mtMerchantMapper.selectById(mtStore.getMerchantId()); + if (mtMerchant != null) { + storeDto.setMerchantName(mtMerchant.getName()); + } + dataList.add(storeDto); + } + + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, StoreDto.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 保存店铺信息 + * + * @param storeDto 店铺信息 + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "保存店铺信息") + public MtStore saveStore(StoreDto storeDto) throws BusinessCheckException { + MtStore mtStore = new MtStore(); + + // 编辑店铺 + if (storeDto.getId() != null) { + mtStore = queryStoreById(storeDto.getId()); + if (mtStore == null) { + throw new BusinessCheckException("该店铺不存在"); + } + } + + mtStore.setName(storeDto.getName()); + mtStore.setLogo(storeDto.getLogo()); + mtStore.setContact(storeDto.getContact()); + mtStore.setOperator(storeDto.getOperator()); + if (storeDto.getWxMchId() != null) { + mtStore.setWxMchId(storeDto.getWxMchId()); + } + if (storeDto.getWxApiV2() != null) { + mtStore.setWxApiV2(storeDto.getWxApiV2()); + } + if (storeDto.getWxCertPath() != null) { + mtStore.setWxCertPath(storeDto.getWxCertPath()); + } + if (storeDto.getAlipayAppId() != null) { + mtStore.setAlipayAppId(storeDto.getAlipayAppId()); + } + if (storeDto.getAlipayPrivateKey() != null) { + mtStore.setAlipayPrivateKey(storeDto.getAlipayPrivateKey()); + } + if (storeDto.getAlipayPublicKey() != null) { + mtStore.setAlipayPublicKey(storeDto.getAlipayPublicKey()); + } + mtStore.setLicense(storeDto.getLicense()); + mtStore.setCreditCode(storeDto.getCreditCode()); + mtStore.setBankName(storeDto.getBankName()); + mtStore.setBankCardName(storeDto.getBankCardName()); + mtStore.setBankCardNo(storeDto.getBankCardNo()); + mtStore.setUpdateTime(new Date()); + if (storeDto.getId() == null) { + mtStore.setCreateTime(new Date()); + } + mtStore.setDescription(storeDto.getDescription()); + mtStore.setPhone(storeDto.getPhone()); + + if (storeDto.getIsDefault() != null) { + if (storeDto.getIsDefault().equals(YesOrNoEnum.YES.getKey())) { + mtStoreMapper.resetDefaultStore(storeDto.getMerchantId()); + } + } + + mtStore.setIsDefault(storeDto.getIsDefault()); + mtStore.setAddress(storeDto.getAddress()); + mtStore.setHours(storeDto.getHours()); + mtStore.setLatitude(storeDto.getLatitude()); + mtStore.setLongitude(storeDto.getLongitude()); + mtStore.setStatus(storeDto.getStatus()); + if (storeDto.getMerchantId() != null) { + mtStore.setMerchantId(storeDto.getMerchantId()); + } + + String qr = weixinService.createStoreQrCode(mtStore.getMerchantId(), mtStore.getId(), 320); + mtStore.setQrCode(qr); + + if (mtStore.getStatus() == null) { + mtStore.setStatus(StatusEnum.ENABLED.getKey()); + } + if (mtStore.getId() == null || mtStore.getId() < 1) { + this.save(mtStore); + } else { + mtStoreMapper.updateById(mtStore); + } + return mtStore; + } + + /** + * 根据店铺ID获取店铺信息 + * + * @param id 店铺ID + * @throws BusinessCheckException + * @return + */ + @Override + public MtStore queryStoreById(Integer id) { + if (id == null || id < 1) { + return null; + } + return mtStoreMapper.selectById(id); + } + + /** + * 获取系统默认店铺 + * + * @param merchantNo 商户号 + * @return + */ + @Override + public MtStore getDefaultStore(String merchantNo) { + Map params = new HashMap<>(); + params.put("status", StatusEnum.ENABLED.getKey()); + params.put("is_default", YesOrNoEnum.YES.getKey()); + if (StringUtil.isNotEmpty(merchantNo)) { + MtMerchant mtMerchant = merchantService.queryMerchantByNo(merchantNo); + if (mtMerchant != null) { + params.put("merchantId", mtMerchant.getId()); + } + } + List storeList = queryStoresByParams(params); + if (storeList.size() > 0) { + return storeList.get(0); + } else { + Map param = new HashMap<>(); + param.put("status", StatusEnum.ENABLED.getKey()); + List dataList = queryStoresByParams(param); + if (dataList.size() > 0) { + return dataList.get(0); + } else { + return null; + } + } + } + + /** + * 根据店铺名称获取店铺信息 + * + * @param storeName 店铺名称 + * @return + */ + @Override + public StoreDto queryStoreByName(String storeName) { + MtStore mtStore = mtStoreMapper.queryStoreByName(storeName); + StoreDto storeDto = null; + + if (mtStore != null) { + storeDto = new StoreDto(); + BeanUtils.copyProperties(mtStore, storeDto); + } + + return storeDto; + } + + /** + * 根据店铺ID获取店铺信息 + * + * @param id 店铺ID + * @throws BusinessCheckException + * @return + */ + @Override + public StoreDto queryStoreDtoById(Integer id) throws BusinessCheckException { + MtStore mtStore = queryStoreById(id); + if (null == mtStore || StatusEnum.DISABLE.getKey().equals(mtStore.getStatus())) { + throw new BusinessCheckException("该店铺状态异常"); + } + + StoreDto mtStoreDto = new StoreDto(); + BeanUtils.copyProperties(mtStore, mtStoreDto); + + if (StringUtil.isEmpty(mtStore.getQrCode())) { + String qr = weixinService.createStoreQrCode(mtStore.getMerchantId(), mtStore.getId(), 320); + mtStoreDto.setQrCode(qr); + } + + return mtStoreDto; + } + + /** + * 更新店铺状态 + * + * @param id 店铺ID + * @param operator 操作人 + * @param status 状态 + * @throws BusinessCheckException + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "修改店铺状态") + public void updateStatus(Integer id, String operator, String status) throws BusinessCheckException { + MtStore mtStore = queryStoreById(id); + if (null == mtStore) { + throw new BusinessCheckException("该店铺不存在."); + } + + mtStore.setStatus(status); + mtStore.setUpdateTime(new Date()); + mtStore.setOperator(operator); + + mtStoreMapper.updateById(mtStore); + } + + /** + * 根据条件查询店铺列表 + * + * @param params 查询参数 + * @return + * */ + @Override + public List queryStoresByParams(Map params) { + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtStore::getStatus, StatusEnum.DISABLE.getKey()); + + String storeId = params.get("storeId") == null ? "" : params.get("storeId").toString(); + if (StringUtils.isNotBlank(storeId)) { + lambdaQueryWrapper.eq(MtStore::getId, storeId); + } + + String name = params.get("name") == null ? "" : params.get("name").toString(); + if (StringUtils.isNotBlank(name)) { + lambdaQueryWrapper.like(MtStore::getName, name); + } + String status = params.get("status") == null ? "" : params.get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtStore::getStatus, status); + } + String merchantId = params.get("merchantId") == null ? "" : params.get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(MtStore::getMerchantId, merchantId); + } + + lambdaQueryWrapper.orderByAsc(MtStore::getStatus).orderByDesc(MtStore::getIsDefault); + List dataList = mtStoreMapper.selectList(lambdaQueryWrapper); + + return dataList; + } + + /** + * 根据距离远近获取店铺列表 + * + * @param merchantNo 商户号 + * @param keyword 关键字 + * @param latitude 维度 + * @param longitude 经度 + * @return + * */ + @Override + public List queryByDistance(String merchantNo, String keyword, String latitude, String longitude) throws BusinessCheckException { + List dataList = new ArrayList<>(); + + MtMerchant mtMerchant = merchantService.queryMerchantByNo(merchantNo); + Integer merchantId = (mtMerchant == null) ? 0 : mtMerchant.getId(); + + List distanceList = mtStoreMapper.queryByDistance(merchantId, keyword, latitude, longitude); + Map param = new HashMap<>(); + param.put("status", StatusEnum.ENABLED.getKey()); + List storeList = mtStoreMapper.selectByMap(param); + + if (distanceList != null) { + for (StoreDistanceBean bean : distanceList) { + for (MtStore mtStore : storeList) { + if (mtStore.getId().equals(bean.getId())) { + if (StringUtil.isNotEmpty(latitude) && StringUtil.isNotEmpty(longitude)) { + mtStore.setDistance(new BigDecimal(bean.getDistance())); + } else { + mtStore.setDistance(new BigDecimal("0.0")); + } + dataList.add(mtStore); + } + } + } + } + + return dataList; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/UserActionServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/UserActionServiceImpl.java new file mode 100644 index 0000000..8800724 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/UserActionServiceImpl.java @@ -0,0 +1,146 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.enums.StatusEnum; +import com.fuint.common.service.UserActionService; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.mapper.MtUserActionMapper; +import com.fuint.repository.model.MtUserAction; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 会员行为业务接口 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class UserActionServiceImpl extends ServiceImpl implements UserActionService { + + private MtUserActionMapper mtUserActionMapper; + + /** + * 分页查询会员行为记录列表 + * + * @param paginationRequest + * @return + */ + @Override + public PaginationResponse queryUserActionListByPagination(PaginationRequest paginationRequest) { + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtUserAction::getStatus, StatusEnum.DISABLE.getKey()); + + String description = paginationRequest.getSearchParams().get("description") == null ? "" : paginationRequest.getSearchParams().get("description").toString(); + if (StringUtils.isNotBlank(description)) { + lambdaQueryWrapper.like(MtUserAction::getDescription, description); + } + String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(MtUserAction::getMerchantId, merchantId); + } + String storeId = paginationRequest.getSearchParams().get("storeId") == null ? "" : paginationRequest.getSearchParams().get("storeId").toString(); + if (StringUtils.isNotBlank(storeId)) { + lambdaQueryWrapper.eq(MtUserAction::getStoreId, storeId); + } + String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtUserAction::getStatus, status); + } + + lambdaQueryWrapper.orderByDesc(MtUserAction::getId); + List dataList = mtUserActionMapper.selectList(lambdaQueryWrapper); + + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, MtUserAction.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 新增会员行为 + * + * @param reqUserAction 会员行为 + * @return + */ + @Override + public boolean addUserAction(MtUserAction reqUserAction) { + if (reqUserAction.getAction() == null || reqUserAction.getUserId() == null) { + return false; + } + + Map params = new HashMap<>(); + params.put("USER_ID", reqUserAction.getUserId()); + params.put("action", reqUserAction.getAction()); + if (reqUserAction.getParam() != null) { + params.put("param", reqUserAction.getParam()); + } + + List dataList = mtUserActionMapper.selectByMap(params); + + // 防止重复 + if (dataList.size() == 0) { + MtUserAction mtUserAction = new MtUserAction(); + mtUserAction.setAction(reqUserAction.getAction()); + mtUserAction.setUserId(reqUserAction.getUserId()); + mtUserAction.setMerchantId(reqUserAction.getMerchantId()); + mtUserAction.setStoreId(reqUserAction.getStoreId()); + mtUserAction.setParam(reqUserAction.getParam()); + mtUserAction.setOperator(reqUserAction.getOperator()); + mtUserAction.setDescription(reqUserAction.getDescription()); + mtUserAction.setStatus(StatusEnum.ENABLED.getKey()); + mtUserAction.setCreateTime(new Date()); + mtUserAction.setUpdateTime(new Date()); + mtUserActionMapper.insert(mtUserAction); + } + + return true; + } + + /** + * 根据ID获取信息 + * + * @param id + * @return + */ + @Override + public MtUserAction getUserActionDetail(Integer id) { + return mtUserActionMapper.selectById(id); + } + + /** + * 根据ID删除 + * + * @param id + * @param operator 操作人 + * @return + */ + @Override + public void deleteUserAction(Integer id, String operator) { + MtUserAction mtUserAction = this.getUserActionDetail(id); + if (mtUserAction == null) { + return; + } + mtUserAction.setStatus(StatusEnum.DISABLE.getKey()); + mtUserAction.setUpdateTime(new Date()); + mtUserActionMapper.updateById(mtUserAction); + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/UserCouponServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/UserCouponServiceImpl.java new file mode 100644 index 0000000..8b46c6b --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/UserCouponServiceImpl.java @@ -0,0 +1,728 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.Constants; +import com.fuint.common.config.Message; +import com.fuint.common.dto.CouponDto; +import com.fuint.common.dto.MyCouponDto; +import com.fuint.common.enums.*; +import com.fuint.common.param.CouponReceiveParam; +import com.fuint.common.service.*; +import com.fuint.common.util.DateUtil; +import com.fuint.common.util.SeqUtil; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.framework.web.ResponseObject; +import com.fuint.repository.mapper.MtUserCouponMapper; +import com.fuint.repository.model.*; +import com.fuint.utils.StringUtil; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.springframework.context.annotation.Lazy; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; +import java.util.*; + +/** + * 会员卡券业务实现类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor(onConstructor_= {@Lazy}) +public class UserCouponServiceImpl extends ServiceImpl implements UserCouponService { + + private MtUserCouponMapper mtUserCouponMapper; + + /** + * 卡券服务接口 + * */ + private CouponService couponService; + + /** + * 卡券分组服务接口 + * */ + private CouponGroupService couponGroupService; + + /** + * 会员服务接口 + * */ + private MemberService memberService; + + /** + * 积分服务接口 + * */ + private PointService pointService; + + /** + * 卡券核销记录服务接口 + * */ + private ConfirmLogService confirmLogService; + + /** + * 店铺服务接口 + * */ + private StoreService storeService; + + /** + * 系统设置服务接口 + * */ + private SettingService settingService; + + /** + * 订单服务接口 + * */ + private OrderService orderService; + + /** + * 分页查询券列表 + * + * @param paginationRequest + * @return + */ + @Override + public PaginationResponse queryUserCouponListByPagination(PaginationRequest paginationRequest) { + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtUserCoupon::getStatus, StatusEnum.DISABLE.getKey()); + + String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtUserCoupon::getStatus, status); + } + String userCouponId = paginationRequest.getSearchParams().get("userCouponId") == null ? "" : paginationRequest.getSearchParams().get("userCouponId").toString(); + if (StringUtils.isNotBlank(userCouponId)) { + lambdaQueryWrapper.eq(MtUserCoupon::getId, userCouponId); + } + String userId = paginationRequest.getSearchParams().get("userId") == null ? "" : paginationRequest.getSearchParams().get("userId").toString(); + if (StringUtils.isNotBlank(userId)) { + lambdaQueryWrapper.eq(MtUserCoupon::getUserId, userId); + } + String couponId = paginationRequest.getSearchParams().get("couponId") == null ? "" : paginationRequest.getSearchParams().get("couponId").toString(); + if (StringUtils.isNotBlank(couponId)) { + lambdaQueryWrapper.eq(MtUserCoupon::getCouponId, couponId); + } + String code = paginationRequest.getSearchParams().get("code") == null ? "" : paginationRequest.getSearchParams().get("code").toString(); + if (StringUtils.isNotBlank(code)) { + lambdaQueryWrapper.eq(MtUserCoupon::getCode, code); + } + String mobile = paginationRequest.getSearchParams().get("mobile") == null ? "" : paginationRequest.getSearchParams().get("mobile").toString(); + if (StringUtils.isNotBlank(mobile)) { + lambdaQueryWrapper.eq(MtUserCoupon::getMobile, mobile); + } + + lambdaQueryWrapper.orderByDesc(MtUserCoupon::getId); + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + List dataList = mtUserCouponMapper.selectList(lambdaQueryWrapper); + + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, MtUserCoupon.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 领取卡券(优惠券、计次卡) + * + * @param receiveParam 领取参数 + * @return + * */ + @Override + @Transactional(rollbackFor = Exception.class) + public boolean receiveCoupon(CouponReceiveParam receiveParam) throws BusinessCheckException { + Integer couponId = receiveParam.getCouponId() == null ? 0 : receiveParam.getCouponId(); + Integer userId = receiveParam.getUserId() == null ? 0 : receiveParam.getUserId(); + Integer num = receiveParam.getNum() == null ? 1 : receiveParam.getNum(); + String receiveCode = receiveParam.getReceiveCode() == null ? "" : receiveParam.getReceiveCode(); + Integer userCouponId = 0; + MtCoupon couponInfo = couponService.queryCouponById(couponId); + if (couponInfo == null) { + MtUserCoupon userCoupon = mtUserCouponMapper.findByCode(receiveCode); + if (userCoupon != null) { + if (userCoupon.getUserId() != null && userCoupon.getUserId() > 0) { + if (userCoupon.getUserId().compareTo(userId) == 0) { + throw new BusinessCheckException(Message.HAS_COUPON); + } else { + throw new BusinessCheckException(Message.CODE_ERROR); + } + } + couponInfo = couponService.queryCouponById(userCoupon.getCouponId()); + userCouponId = userCoupon.getId(); + } else { + throw new BusinessCheckException(Message.CODE_ERROR_1); + } + if (couponInfo == null) { + throw new BusinessCheckException(Message.COUPON_NOT_EXIST); + } + } + + // 卡券类型检查 + if (couponInfo.getType().equals(CouponTypeEnum.PRESTORE.getKey())) { + throw new BusinessCheckException(Message.COUPON_TYPE_ERROR); + } + + MtCouponGroup groupInfo = couponGroupService.queryCouponGroupById(couponInfo.getGroupId()); + MtUser userInfo = memberService.queryMemberById(userId); + if (null == userInfo) { + throw new BusinessCheckException(Message.USER_NOT_EXIST); + } + + // 会员等级限制 + if (couponInfo.getGradeIds() != null && StringUtil.isNotEmpty(couponInfo.getGradeIds())) { + String gradeIds[] = couponInfo.getGradeIds().split(","); + if (gradeIds.length > 0) { + boolean isContains = Arrays.asList(gradeIds).contains(userInfo.getGradeId()+""); + if (!isContains) { + throw new BusinessCheckException(Message.GRADE_ERROR); + } + } + } + + // 是否需要领取码 + if (couponInfo.getReceiveCode() != null && StringUtil.isNotEmpty(couponInfo.getReceiveCode())) { + if (StringUtil.isEmpty(receiveCode)) { + throw new BusinessCheckException(Message.NEED_CODE); + } + // 线下发放的领取码 + if (couponInfo.getSendWay().equals(SendWayEnum.OFFLINE.getKey())) { + MtUserCoupon userCoupon = mtUserCouponMapper.findByCode(receiveCode); + if (userCoupon == null || !userCoupon.getCode().equals(receiveCode)) { + throw new BusinessCheckException(Message.CODE_ERROR_1); + } else { + userCouponId = userCoupon.getId(); + } + } + // 前台领取的领取码 + if (couponInfo.getSendWay().equals(SendWayEnum.FRONT.getKey()) && !receiveCode.equals(couponInfo.getReceiveCode())) { + throw new BusinessCheckException(Message.CODE_ERROR); + } + } + + // 是否已经领取 + List statusList = Arrays.asList(UserCouponStatusEnum.UNUSED.getKey(), UserCouponStatusEnum.USED.getKey(), UserCouponStatusEnum.EXPIRE.getKey()); + List userCouponData = mtUserCouponMapper.getUserCouponListByCouponId(userId, couponId, statusList); + if ((userCouponData.size() >= couponInfo.getLimitNum()) && (couponInfo.getLimitNum() > 0)) { + throw new BusinessCheckException(Message.MAX_COUPON_LIMIT); + } + + // 积分不足以领取 + if (couponInfo.getPoint() != null && couponInfo.getPoint() > 0) { + if (userInfo.getPoint() < couponInfo.getPoint()) { + throw new BusinessCheckException(Message.POINT_LIMIT); + } + } + + // 可领取多张,领取序列号 + StringBuffer uuid = new StringBuffer(); + uuid.append(SeqUtil.getRandomNumber(4)); + uuid.append(SeqUtil.getRandomNumber(4)); + uuid.append(SeqUtil.getRandomNumber(4)); + uuid.append(SeqUtil.getRandomNumber(4)); + + for (int i = 1; i <= num; i++) { + MtUserCoupon userCoupon = new MtUserCoupon(); + if (userCouponId > 0) { + userCoupon = mtUserCouponMapper.selectById(userCouponId); + } + + userCoupon.setCouponId(couponInfo.getId()); + userCoupon.setType(couponInfo.getType()); + userCoupon.setAmount(couponInfo.getAmount()); + userCoupon.setGroupId(groupInfo.getId()); + userCoupon.setMobile(userInfo.getMobile()); + userCoupon.setUserId(userInfo.getId()); + userCoupon.setStatus(UserCouponStatusEnum.UNUSED.getKey()); + userCoupon.setCreateTime(new Date()); + userCoupon.setUpdateTime(new Date()); + userCoupon.setExpireTime(couponInfo.getEndTime()); + if (couponInfo.getExpireType().equals(CouponExpireTypeEnum.FLEX.getKey())) { + Date expireTime = new Date(); + Calendar c = Calendar.getInstance(); + c.setTime(expireTime); + c.add(Calendar.DATE, couponInfo.getExpireTime()); + expireTime = c.getTime(); + userCoupon.setExpireTime(expireTime); + } + + // 12位随机数 + StringBuffer code = new StringBuffer(); + code.append(SeqUtil.getRandomNumber(4)); + code.append(SeqUtil.getRandomNumber(4)); + code.append(SeqUtil.getRandomNumber(4)); + code.append(SeqUtil.getRandomNumber(4)); + userCoupon.setCode(code.toString()); + userCoupon.setUuid(uuid.toString()); + if (userCoupon.getId() != null) { + mtUserCouponMapper.updateById(userCoupon); + } else { + mtUserCouponMapper.insert(userCoupon); + } + } + + // 是否需要扣除相应积分 + if (couponInfo.getPoint() != null && couponInfo.getPoint() > 0) { + MtPoint reqPointDto = new MtPoint(); + reqPointDto.setUserId(userId); + reqPointDto.setAmount(-couponInfo.getPoint()); + reqPointDto.setDescription("领取"+ couponInfo.getName() + "扣除" +couponInfo.getPoint() +"积分"); + reqPointDto.setOperator(""); + pointService.addPoint(reqPointDto); + } + + return true; + } + + /** + * 储值卡券 + * + * @param paramMap 储值参数 + * @return + * */ + public boolean preStore(Map paramMap) throws BusinessCheckException { + Integer couponId = paramMap.get("couponId") == null ? 0 : Integer.parseInt(paramMap.get("couponId").toString()); + Integer userId = paramMap.get("userId") == null ? 0 : Integer.parseInt(paramMap.get("userId").toString()); + String param = paramMap.get("param") == null ? "" : paramMap.get("param").toString(); + Integer orderId = paramMap.get("orderId") == null ? 0 : Integer.parseInt(paramMap.get("orderId").toString()); + + if (StringUtil.isEmpty(param) || couponId <= 0 || userId <= 0) { + throw new BusinessCheckException(Message.PARAM_ERROR); + } + + MtCoupon couponInfo = couponService.queryCouponById(couponId); + if (couponInfo == null) { + throw new BusinessCheckException(Message.COUPON_NOT_EXIST); + } + + MtUser userInfo = memberService.queryMemberById(userId); + if (userInfo == null) { + throw new BusinessCheckException(Message.USER_NOT_EXIST); + } + + String[] paramArr = param.split(","); + + for (int i = 0; i < paramArr.length; i++) { + String item = paramArr[i]; + if (StringUtil.isNotEmpty(item)) { + String buyItem = paramArr[i]; // 100_200_1 + String[] buyItemArr = buyItem.split("_"); + if (StringUtil.isNotEmpty(buyItemArr[2])) { + Integer numInt = Integer.parseInt(buyItemArr[2]); + for (int j = 1; j <= numInt; j++) { + if (StringUtil.isNotEmpty(buyItemArr[1])) { + preStoreItem(couponInfo, userInfo, orderId, new BigDecimal(buyItemArr[1])); + } + } + } + } + } + + return true; + } + + /** + * 获取会员卡券列表 + * + * @param userId 会员ID + * @param status 状态 + * @return + * */ + @Override + public List getUserCouponList(Integer userId, List status) { + return mtUserCouponMapper.getUserCouponList(userId, status); + } + + /** + * 获取会员卡券列表 + * + * @param paramMap + * @throws BusinessCheckException + * @return + * */ + @Override + @Transactional(rollbackFor = Exception.class) + public ResponseObject getUserCouponList(Map paramMap) throws BusinessCheckException { + Integer pageNumber = paramMap.get("pageNumber") == null ? Constants.PAGE_NUMBER : Integer.parseInt(paramMap.get("pageNumber").toString()); + Integer pageSize = paramMap.get("pageSize") == null ? Constants.PAGE_SIZE : Integer.parseInt(paramMap.get("pageSize").toString()); + String userId = paramMap.get("userId") == null ? "" : paramMap.get("userId").toString(); + String userNo = paramMap.get("userNo") == null ? "" : paramMap.get("userNo").toString(); + String status = paramMap.get("status") == null ? "" : paramMap.get("status").toString(); + String type = paramMap.get("type") == null ? "": paramMap.get("type").toString(); + String mobile = paramMap.get("mobile") == null ? "" : paramMap.get("mobile").toString(); + String merchantId = paramMap.get("merchantId") == null ? "" : paramMap.get("merchantId").toString(); + String storeId = paramMap.get("storeId") == null ? "" : paramMap.get("storeId").toString(); + String couponId = paramMap.get("couponId") == null ? "" : paramMap.get("couponId").toString(); + String code = paramMap.get("code") == null ? "" : paramMap.get("code").toString(); + String id = paramMap.get("id") == null ? "" : paramMap.get("id").toString(); + + // 处理已失效 + if (pageNumber <= 1 && StringUtil.isNotEmpty(userId)) { + List statusList = Arrays.asList(UserCouponStatusEnum.UNUSED.getKey()); + List data = mtUserCouponMapper.getUserCouponList(Integer.parseInt(userId), statusList); + for (MtUserCoupon uc : data) { + MtCoupon coupon = couponService.queryCouponById(uc.getCouponId()); + // 已过期 + if (coupon.getExpireType().equals(CouponExpireTypeEnum.FIX.getKey()) && coupon.getEndTime() != null && coupon.getEndTime().before(new Date())) { + uc.setStatus(UserCouponStatusEnum.EXPIRE.getKey()); + uc.setUpdateTime(new Date()); + mtUserCouponMapper.updateById(uc); + } + // 已过期 + if (coupon.getExpireType().equals(CouponExpireTypeEnum.FLEX.getKey()) && uc.getExpireTime() != null && uc.getExpireTime().before(new Date())) { + uc.setStatus(UserCouponStatusEnum.EXPIRE.getKey()); + uc.setUpdateTime(new Date()); + mtUserCouponMapper.updateById(uc); + } + // 已删除 + if (coupon.getStatus().equals(StatusEnum.DISABLE.getKey())) { + uc.setStatus(UserCouponStatusEnum.DISABLE.getKey()); + uc.setUpdateTime(new Date()); + mtUserCouponMapper.updateById(uc); + } + } + } + + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtUserCoupon::getStatus, StatusEnum.DISABLE.getKey()); + if (StringUtil.isNotEmpty(status)) { + lambdaQueryWrapper.eq(MtUserCoupon::getStatus, status); + } + if (StringUtil.isNotEmpty(userId)) { + lambdaQueryWrapper.eq(MtUserCoupon::getUserId, userId); + } + if (StringUtil.isNotEmpty(userNo)) { + if (StringUtil.isEmpty(merchantId)) { + merchantId = "0"; + } + MtUser userInfo = memberService.queryMemberByUserNo(Integer.parseInt(merchantId), userNo); + if (userInfo != null) { + lambdaQueryWrapper.eq(MtUserCoupon::getUserId, userInfo.getId()); + } + } + if (StringUtil.isNotEmpty(mobile)) { + lambdaQueryWrapper.eq(MtUserCoupon::getMobile, mobile); + } + if (StringUtil.isNotEmpty(type)) { + lambdaQueryWrapper.eq(MtUserCoupon::getType, type); + } + if (StringUtil.isNotEmpty(merchantId)) { + lambdaQueryWrapper.eq(MtUserCoupon::getMerchantId, merchantId); + } + if (StringUtil.isNotEmpty(storeId)) { + lambdaQueryWrapper.eq(MtUserCoupon::getStoreId, storeId); + } + if (StringUtil.isNotEmpty(couponId)) { + lambdaQueryWrapper.eq(MtUserCoupon::getCouponId, couponId); + } + if (StringUtil.isNotEmpty(code)) { + lambdaQueryWrapper.eq(MtUserCoupon::getCode, code); + } + if (StringUtil.isNotEmpty(id)) { + lambdaQueryWrapper.eq(MtUserCoupon::getId, id); + } + + lambdaQueryWrapper.orderByDesc(MtUserCoupon::getId); + Page pageHelper = PageHelper.startPage(pageNumber, pageSize); + List userCouponList = mtUserCouponMapper.selectList(lambdaQueryWrapper); + List dataList = new ArrayList<>(); + + if (userCouponList.size() > 0) { + for (MtUserCoupon userCouponDto : userCouponList) { + MtCoupon couponInfo = couponService.queryCouponById(userCouponDto.getCouponId()); + MtUser userInfo = memberService.queryMemberById2(userCouponDto.getUserId()); + MtStore storeInfo = storeService.queryStoreById(userCouponDto.getStoreId()); + if (couponInfo == null) { + continue; + } + + MyCouponDto dto = new MyCouponDto(); + dto.setId(userCouponDto.getId()); + dto.setName(couponInfo.getName()); + dto.setCode(userCouponDto.getCode()); + dto.setCouponId(couponInfo.getId()); + dto.setUseRule(couponInfo.getDescription()); + + String image = couponInfo.getImage(); + String baseImage = settingService.getUploadBasePath(); + dto.setImage(baseImage + image); + dto.setStatus(userCouponDto.getStatus()); + dto.setAmount(userCouponDto.getAmount()); + dto.setBalance(userCouponDto.getBalance()); + dto.setType(couponInfo.getType()); + dto.setUsedTime(userCouponDto.getUsedTime()); + dto.setCreateTime(userCouponDto.getCreateTime()); + dto.setUserInfo(userInfo); + dto.setStoreInfo(storeInfo); + + boolean canUse = couponService.isCouponEffective(couponInfo, userCouponDto); + if (!userCouponDto.getStatus().equals(UserCouponStatusEnum.UNUSED.getKey())) { + canUse = false; + } + dto.setCanUse(canUse); + + if (couponInfo.getExpireType().equals(CouponExpireTypeEnum.FIX.getKey())) { + String effectiveDate = DateUtil.formatDate(couponInfo.getBeginTime(), "yyyy.MM.dd HH:mm") + "-" + DateUtil.formatDate(couponInfo.getEndTime(), "yyyy.MM.dd HH:mm"); + dto.setEffectiveDate(effectiveDate); + } + if (couponInfo.getExpireType().equals(CouponExpireTypeEnum.FLEX.getKey())) { + String effectiveDate = DateUtil.formatDate(userCouponDto.getCreateTime(), "yyyy.MM.dd HH:mm") + "-" + DateUtil.formatDate(userCouponDto.getExpireTime(), "yyyy.MM.dd HH:mm"); + dto.setEffectiveDate(effectiveDate); + } + + String tips = ""; + + // 优惠券tips + if (couponInfo.getType().equals(CouponTypeEnum.COUPON.getKey())) { + if (StringUtil.isNotEmpty(couponInfo.getOutRule()) && Float.parseFloat(couponInfo.getOutRule()) > 0) { + tips = "满" + couponInfo.getOutRule() + "可用"; + } else { + tips = "无门槛券"; + } + } + + // 储值卡tips + if (couponInfo.getType().equals(CouponTypeEnum.PRESTORE.getKey())) { + tips = "¥" + userCouponDto .getAmount() + ",余额¥" + userCouponDto.getBalance(); + } + + // 计次卡tips + if (couponInfo.getType().equals(CouponTypeEnum.TIMER.getKey())) { + Long confirmNum = confirmLogService.getConfirmNum(userCouponDto.getId()); + tips = "已集"+ confirmNum +"次,需集满" + couponInfo.getOutRule() + "次"; + } + + dto.setTips(tips); + dataList.add(dto); + } + } + + PageRequest pageRequest = PageRequest.of(pageNumber, pageSize); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, MyCouponDto.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + if (dataList.size() == 0) { + paginationResponse.setTotalPages(0); + paginationResponse.setTotalElements(0); + } + paginationResponse.setContent(dataList); + + return new ResponseObject(200, "查询成功", paginationResponse); + } + + /** + * 获取会员可支付使用的卡券 + * + * @param userId 会员ID + * @param useFor 用途 + * @return + * */ + @Override + public List getPayAbleCouponList(Integer userId, String useFor) throws BusinessCheckException { + List statusList = Arrays.asList(UserCouponStatusEnum.UNUSED.getKey()); + List userCouponList = mtUserCouponMapper.getUserCouponList(userId, statusList); + List dataList = new ArrayList<>(); + + if (userCouponList.size() > 0) { + for (MtUserCoupon userCoupon : userCouponList) { + MtCoupon couponInfo = couponService.queryCouponById(userCoupon.getCouponId()); + // 只取专用卡券 + if (StringUtil.isNotEmpty(useFor) && !couponInfo.getUseFor().equals(useFor)) { + continue; + } + // 不取专用卡券 + if (StringUtil.isEmpty(useFor) && couponInfo.getUseFor() != null && StringUtil.isNotEmpty(couponInfo.getUseFor())) { + continue; + } + CouponDto couponDto = new CouponDto(); + couponDto.setId(couponInfo.getId()); + couponDto.setUserCouponId(userCoupon.getId()); + couponDto.setName(couponInfo.getName()); + couponDto.setAmount(userCoupon.getAmount()); + couponDto.setStatus(UserCouponStatusEnum.UNUSED.getKey()); + boolean isEffective = couponService.isCouponEffective(couponInfo, userCoupon); + // 1.储值卡可用 + if (isEffective && couponInfo.getType().equals(CouponTypeEnum.PRESTORE.getKey())) { + if (userCoupon.getBalance().compareTo(new BigDecimal("0")) > 0) { + couponDto.setType(CouponTypeEnum.PRESTORE.getValue()); + couponDto.setAmount(userCoupon.getBalance()); + dataList.add(couponDto); + } + } else if(isEffective && couponInfo.getType().equals(CouponTypeEnum.COUPON.getKey())) { + // 2.无门槛的优惠券可用 + if (StringUtil.isEmpty(couponInfo.getOutRule()) || couponInfo.getOutRule().equals("0")) { + couponDto.setType(CouponTypeEnum.COUPON.getValue()); + dataList.add(couponDto); + } + } + } + } + + return dataList; + } + + /** + * 获取会员卡券详情 + * + * @param userId 会员ID + * @param couponId 卡券ID + * @return + * */ + @Override + public List getUserCouponDetail(Integer userId, Integer couponId) { + return mtUserCouponMapper.findUserCouponDetail(couponId, userId); + } + + /** + * 获取会员卡券详情 + * + * @param userCouponId 会员卡券ID + * @return + * */ + @Override + public MtUserCoupon getUserCouponDetail(Integer userCouponId) { + MtUserCoupon userCoupon = mtUserCouponMapper.selectById(userCouponId); + return userCoupon; + } + + /** + * 根据过期时间查询会员卡券 + * + * @param userId 会员ID + * @param status 状态 + * @param startTime 开始时间 + * @param endTime 结束时间 + * @return + * */ + @Override + public List getUserCouponListByExpireTime(Integer userId, String status, String startTime, String endTime) { + List result = mtUserCouponMapper.getUserCouponListByExpireTime(userId, status, startTime, endTime); + return result; + } + + /** + * 会员发送卡券 + * + * @param orderId 订单ID + * @param couponId 卡券ID + * @param userId 会员ID + * @param mobile 手机号 + * @return + * */ + public boolean buyCouponItem(Integer orderId, Integer couponId, Integer userId, String mobile) throws BusinessCheckException { + MtCoupon couponInfo = couponService.queryCouponById(couponId); + MtUserCoupon userCoupon = new MtUserCoupon(); + userCoupon.setCouponId(couponId); + userCoupon.setType(couponInfo.getType()); + userCoupon.setGroupId(couponInfo.getGroupId()); + userCoupon.setMobile(mobile); + userCoupon.setUserId(userId); + userCoupon.setStatus(UserCouponStatusEnum.UNUSED.getKey()); + userCoupon.setCreateTime(new Date()); + userCoupon.setUpdateTime(new Date()); + userCoupon.setExpireTime(couponInfo.getEndTime()); + if (couponInfo.getExpireType().equals(CouponExpireTypeEnum.FLEX.getKey())) { + Date expireTime = new Date(); + Calendar c = Calendar.getInstance(); + c.setTime(expireTime); + c.add(Calendar.DATE, couponInfo.getExpireTime()); + expireTime = c.getTime(); + userCoupon.setExpireTime(expireTime); + } + userCoupon.setOrderId(orderId); + + // 如果购买的是储值卡 + if (couponInfo.getType().equals(CouponTypeEnum.PRESTORE.getKey()) && couponInfo.getInRule() != null) { + String[] paramArr = couponInfo.getInRule().split(","); // 100_200,300_500 + MtOrder orderInfo = orderService.getOrderInfo(orderId); + if (orderInfo != null) { + BigDecimal payAmount = orderInfo.getPayAmount(); + BigDecimal totalAmount = new BigDecimal(0); + if (paramArr.length > 0) { + for (int i = 0; i < paramArr.length; i++) { + String[] storeItem = paramArr[i].split("_"); + if (storeItem.length > 0) { + BigDecimal amount = new BigDecimal(paramArr[i].split("_")[0]); + if (payAmount.compareTo(amount) >= 0) { + totalAmount = new BigDecimal(paramArr[i].split("_")[1]); + payAmount = payAmount.subtract(amount); + } + } + } + } + couponInfo.setAmount(totalAmount); + } + } + + userCoupon.setAmount(couponInfo.getAmount()); + userCoupon.setBalance(couponInfo.getAmount()); + + // 12位随机数 + StringBuffer code = new StringBuffer(); + code.append(SeqUtil.getRandomNumber(4)); + code.append(SeqUtil.getRandomNumber(4)); + code.append(SeqUtil.getRandomNumber(4)); + code.append(SeqUtil.getRandomNumber(4)); + userCoupon.setCode(code.toString()); + userCoupon.setUuid(code.toString()); + + mtUserCouponMapper.insert(userCoupon); + return true; + } + + /** + * 预存单张 + * + * @param couponInfo 卡券信息 + * @param userInfo 会员信息 + * @return + * */ + private boolean preStoreItem(MtCoupon couponInfo, MtUser userInfo, Integer orderId, BigDecimal amount) { + MtUserCoupon userCoupon = new MtUserCoupon(); + userCoupon.setCouponId(couponInfo.getId()); + userCoupon.setType(couponInfo.getType()); + userCoupon.setGroupId(couponInfo.getGroupId()); + userCoupon.setMobile(userInfo.getMobile()); + userCoupon.setMerchantId(couponInfo.getMerchantId()); + userCoupon.setUserId(userInfo.getId()); + userCoupon.setStatus(UserCouponStatusEnum.UNUSED.getKey()); + userCoupon.setCreateTime(new Date()); + userCoupon.setUpdateTime(new Date()); + userCoupon.setExpireTime(couponInfo.getEndTime()); + if (couponInfo.getExpireType().equals(CouponExpireTypeEnum.FLEX.getKey())) { + Date expireTime = new Date(); + Calendar c = Calendar.getInstance(); + c.setTime(expireTime); + c.add(Calendar.DATE, couponInfo.getExpireTime()); + expireTime = c.getTime(); + userCoupon.setExpireTime(expireTime); + } + + userCoupon.setOrderId(orderId); + userCoupon.setAmount(amount); + userCoupon.setBalance(amount); + + // 12位随机数 + StringBuffer code = new StringBuffer(); + code.append(SeqUtil.getRandomNumber(4)); + code.append(SeqUtil.getRandomNumber(4)); + code.append(SeqUtil.getRandomNumber(4)); + code.append(SeqUtil.getRandomNumber(4)); + userCoupon.setCode(code.toString()); + userCoupon.setUuid(code.toString()); + + mtUserCouponMapper.insert(userCoupon); + return true; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/UserGradeServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/UserGradeServiceImpl.java new file mode 100644 index 0000000..8a3ef11 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/UserGradeServiceImpl.java @@ -0,0 +1,234 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.enums.StatusEnum; +import com.fuint.common.enums.UserGradeCatchTypeEnum; +import com.fuint.common.service.UserGradeService; +import com.fuint.framework.annoation.OperationServiceLog; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.pagination.PaginationRequest; +import com.fuint.framework.pagination.PaginationResponse; +import com.fuint.repository.mapper.MtStaffMapper; +import com.fuint.repository.mapper.MtUserGradeMapper; +import com.fuint.repository.model.MtBanner; +import com.fuint.repository.model.MtStaff; +import com.fuint.repository.model.MtUser; +import com.fuint.repository.model.MtUserGrade; +import com.fuint.utils.StringUtil; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 会员等级业务接口实现类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class UserGradeServiceImpl extends ServiceImpl implements UserGradeService { + + private MtUserGradeMapper mtUserGradeMapper; + + private MtStaffMapper mtStaffMapper; + + /** + * 分页查询会员等级列表 + * + * @param paginationRequest + * @return + */ + @Override + public PaginationResponse queryUserGradeListByPagination(PaginationRequest paginationRequest) { + Page pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.ne(MtUserGrade::getStatus, StatusEnum.DISABLE.getKey()); + + String name = paginationRequest.getSearchParams().get("name") == null ? "" : paginationRequest.getSearchParams().get("name").toString(); + if (StringUtils.isNotBlank(name)) { + lambdaQueryWrapper.like(MtUserGrade::getName, name); + } + String catchType = paginationRequest.getSearchParams().get("catchType") == null ? "" : paginationRequest.getSearchParams().get("catchType").toString(); + if (StringUtils.isNotBlank(catchType)) { + lambdaQueryWrapper.like(MtUserGrade::getCatchType, catchType); + } + String status = paginationRequest.getSearchParams().get("status") == null ? "" : paginationRequest.getSearchParams().get("status").toString(); + if (StringUtils.isNotBlank(status)) { + lambdaQueryWrapper.eq(MtUserGrade::getStatus, status); + } + String merchantId = paginationRequest.getSearchParams().get("merchantId") == null ? "" : paginationRequest.getSearchParams().get("merchantId").toString(); + if (StringUtils.isNotBlank(merchantId)) { + lambdaQueryWrapper.eq(MtUserGrade::getMerchantId, merchantId); + } + + lambdaQueryWrapper.orderByDesc(MtUserGrade::getId); + List dataList = mtUserGradeMapper.selectList(lambdaQueryWrapper); + + PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize()); + PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal()); + PaginationResponse paginationResponse = new PaginationResponse(pageImpl, MtBanner.class); + paginationResponse.setTotalPages(pageHelper.getPages()); + paginationResponse.setTotalElements(pageHelper.getTotal()); + paginationResponse.setContent(dataList); + + return paginationResponse; + } + + /** + * 添加会员等级信息 + * + * @param mtUserGrade 会员等级 + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "新增会员等级") + public MtUserGrade addUserGrade(MtUserGrade mtUserGrade) throws BusinessCheckException { + if (mtUserGrade.getGrade() != null && (mtUserGrade.getGrade() <= 0)) { + throw new BusinessCheckException("会员等级需大于0"); + } + if (mtUserGrade.getDiscount() != null && (mtUserGrade.getDiscount() > 10 || mtUserGrade.getDiscount() < 0)) { + throw new BusinessCheckException("会员折扣需在0和10之间"); + } + mtUserGradeMapper.insert(mtUserGrade); + return mtUserGrade; + } + + /** + * 根据ID获取会员等级信息 + * + * @param merchantId 商户ID + * @param gradeId 会员等级ID + * @param userId 会员ID + * @return + */ + @Override + public MtUserGrade queryUserGradeById(Integer merchantId, Integer gradeId, Integer userId) { + if (userId != null && userId > 0) { + Map params = new HashMap<>(); + params.put("AUDITED_STATUS", StatusEnum.ENABLED.getKey()); + params.put("USER_ID", userId); + List staffList = mtStaffMapper.selectByMap(params); + // 如果是员工关联的会员,就返回默认的会员等级 + if (staffList != null && staffList.size() > 0) { + return getInitUserGrade(merchantId); + } + } + return mtUserGradeMapper.selectById(gradeId); + } + + /** + * 修改会员等级 + * + * @param mtUserGrade 会员等级 + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "修改会员等级") + public MtUserGrade updateUserGrade(MtUserGrade mtUserGrade) throws BusinessCheckException { + if (mtUserGrade.getDiscount() != null && (mtUserGrade.getDiscount() > 10 || mtUserGrade.getDiscount() < 0)) { + throw new BusinessCheckException("会员折扣需在0和10之间"); + } + if (mtUserGrade.getGrade() != null && (mtUserGrade.getGrade() <= 0)) { + throw new BusinessCheckException("会员等级需大于0"); + } + MtUserGrade userGrade = mtUserGradeMapper.selectById(mtUserGrade.getId()); + if (null != userGrade) { + mtUserGrade.setMerchantId(userGrade.getMerchantId()); + mtUserGradeMapper.updateById(mtUserGrade); + } + return mtUserGrade; + } + + /** + * 根据ID删除会员等级 + * + * @param id ID + * @param operator 操作人 + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + @OperationServiceLog(description = "删除会员等级") + public Integer deleteUserGrade(Integer id, String operator) { + MtUserGrade mtUserGrade = queryUserGradeById(0, id, 0); + if (null == mtUserGrade) { + return 0; + } + mtUserGrade.setStatus(StatusEnum.DISABLE.getKey()); + mtUserGradeMapper.updateById(mtUserGrade); + return mtUserGrade.getId(); + } + + /** + * 获取默认的会员等级 + * + * @param merchantId 商户ID + * @return + */ + @Override + public MtUserGrade getInitUserGrade(Integer merchantId) { + Map param = new HashMap<>(); + param.put("status", StatusEnum.ENABLED.getKey()); + param.put("CATCH_TYPE", UserGradeCatchTypeEnum.INIT.getKey()); + param.put("MERCHANT_ID", merchantId); + + List dataList = mtUserGradeMapper.selectByMap(param); + MtUserGrade initGrade; + if (dataList != null && dataList.size() > 0) { + initGrade = dataList.get(0); + } else { + initGrade = new MtUserGrade(); + initGrade.setId(0); + initGrade.setStatus(StatusEnum.ENABLED.getKey()); + initGrade.setGrade(0); + initGrade.setMerchantId(0); + initGrade.setSpeedPoint(1f); + initGrade.setDiscount(0f); + } + return initGrade; + } + + /** + * 获取付费会员等级列表 + * + * @param merchantId 商户ID + * @param userInfo 会员信息 + * @return + * */ + @Override + public List getPayUserGradeList(Integer merchantId, MtUser userInfo) { + Map param = new HashMap<>(); + param.put("status", StatusEnum.ENABLED.getKey()); + param.put("catch_type", UserGradeCatchTypeEnum.PAY.getKey()); + param.put("merchant_id", merchantId); + List userGrades = mtUserGradeMapper.selectByMap(param); + List dataList = new ArrayList<>(); + if (userGrades.size() > 0 && userInfo != null && StringUtil.isNotEmpty(userInfo.getGradeId())) { + MtUserGrade myGradeInfo = mtUserGradeMapper.selectById(userInfo.getGradeId()); + if (myGradeInfo != null) { + Integer myGrade = myGradeInfo.getGrade(); + for (MtUserGrade grade : userGrades) { + if (!myGrade.equals(grade.getGrade().toString()) && (grade.getGrade() > myGrade)) { + dataList.add(grade); + } + } + } + } + + return dataList; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/service/impl/VerifyCodeServiceImpl.java b/fuint-application/src/main/java/com/fuint/common/service/impl/VerifyCodeServiceImpl.java new file mode 100644 index 0000000..648d8bf --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/service/impl/VerifyCodeServiceImpl.java @@ -0,0 +1,121 @@ +package com.fuint.common.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.common.service.VerifyCodeService; +import com.fuint.framework.exception.BusinessCheckException; +import com.fuint.framework.exception.BusinessRuntimeException; +import com.fuint.repository.mapper.MtVerifyCodeMapper; +import com.fuint.repository.model.MtVerifyCode; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +/** + * 验证码业务实现类 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +@Service +@AllArgsConstructor +public class VerifyCodeServiceImpl extends ServiceImpl implements VerifyCodeService { + + private MtVerifyCodeMapper mtVerifyCodeMapper; + + /** + * 添加验证码 + * + * @param mobile + * @param verifyCode + * @throws BusinessCheckException + * @return + */ + public MtVerifyCode addVerifyCode(String mobile, String verifyCode, Integer expireSecond) { + if (null == expireSecond || expireSecond<0) { + expireSecond=0; + } + + MtVerifyCode reqVerifyCodeDto = new MtVerifyCode(); + reqVerifyCodeDto.setMobile(mobile); + reqVerifyCodeDto.setVerifyCode(verifyCode); + reqVerifyCodeDto.setValidFlag("0"); + + Date now = new Date(); + reqVerifyCodeDto.setAddTime(now); + + // 验证码过期时间5分钟 + Date expireTime = new Date(); + expireTime.setTime(expireTime.getTime()+5*60*1000); + reqVerifyCodeDto.setExpireTime(expireTime); + + // 发送验证码2分钟后才能继续发送,取最后一条 + List verifyCodeList = mtVerifyCodeMapper.queryVerifyCodeLastRecord(mobile); + if (null == verifyCodeList || verifyCodeList.size() == 0) { + // 没发过短信 + this.save(reqVerifyCodeDto); + return reqVerifyCodeDto; + } + MtVerifyCode verifyCodeLastRecord = verifyCodeList.get(0); + Long curInt = reqVerifyCodeDto.getAddTime().getTime(); //时间毫秒,长整型 + Long lastInt = verifyCodeLastRecord.getAddTime().getTime(); + Integer diffSecond = (int)((curInt-lastInt) / 1000); //间隔秒数 + if (diffSecond 0) { + MtMerchant mtMerchant = merchantService.queryMerchantById(merchantId); + if (mtMerchant != null && StringUtil.isNotEmpty(mtMerchant.getWxAppId()) && StringUtil.isNotEmpty(mtMerchant.getWxAppSecret())) { + wxAppId = mtMerchant.getWxAppId(); + wxAppSecret = mtMerchant.getWxAppSecret(); + tokenKey = tokenKey + merchantId; + } + } + + String wxTokenUrl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s"; + String url = String.format(wxTokenUrl, wxAppId, wxAppSecret); + String token = ""; + + if (useCache) { + token = RedisUtil.get(tokenKey); + } + + if (token == null || StringUtil.isEmpty(token)) { + try { + String response = HttpRESTDataClient.requestGet(url); + JSONObject json = (JSONObject) JSONObject.parse(response); + if (!json.containsKey("errcode")) { + RedisUtil.set(tokenKey, json.get("access_token"), 7200); + token = (String) json.get("access_token"); + } else { + logger.error("获取微信accessToken出错:" + json.get("errmsg")); + } + } catch (Exception e) { + logger.error("获取微信accessToken异常:" + e.getMessage()); + } + } + + return token; + } + + /** + * 创建支付订单 + * + * @param userInfo 会员信息 + * @param orderInfo 订单信息 + * @param payAmount 支付金额 + * @param authCode 付款码 + * @param giveAmount 赠送金额 + * @param ip 支付IP + * @param platform 支付平台 + * @throws BusinessCheckException + * @return + * */ + @Override + @Transactional(rollbackFor = Exception.class) + public ResponseObject createPrepayOrder(MtUser userInfo, MtOrder orderInfo, Integer payAmount, String authCode, Integer giveAmount, String ip, String platform) throws BusinessCheckException { + logger.info("WeixinService createPrepayOrder inParams userInfo={} payAmount={} giveAmount={} goodsInfo={}", userInfo, payAmount, giveAmount, orderInfo); + + String goodsInfo = orderInfo.getOrderSn(); + if (orderInfo.getType().equals(OrderTypeEnum.PRESTORE.getKey())) { + goodsInfo = OrderTypeEnum.PRESTORE.getValue(); + } + + // 1. 调用微信接口生成预支付订单 + Map reqData = new HashMap<>(); + reqData.put("body", goodsInfo); + reqData.put("out_trade_no", orderInfo.getOrderSn()); + reqData.put("device_info", ""); + reqData.put("fee_type", "CNY"); + reqData.put("total_fee", payAmount.toString()); + reqData.put("spbill_create_ip", ip); + + // JSAPI支付 + if (orderInfo.getPayType().equals(PayTypeEnum.JSAPI.getKey())) { + reqData.put("trade_type", PayTypeEnum.JSAPI.getKey()); + reqData.put("openid", userInfo.getOpenId() == null ? "" : userInfo.getOpenId()); + } + + // 刷卡支付 + if (StringUtil.isNotEmpty(authCode)) { + reqData.put("auth_code", authCode); + } + + // 更新支付金额 + BigDecimal payAmount1 = new BigDecimal(payAmount).divide(new BigDecimal("100")); + OrderDto reqDto = new OrderDto(); + reqDto.setId(orderInfo.getId()); + reqDto.setPayAmount(payAmount1); + reqDto.setPayType(orderInfo.getPayType()); + orderService.updateOrder(reqDto); + + Map respData; + if (reqData.get("auth_code") != null && StringUtil.isNotEmpty(reqData.get("auth_code"))) { + respData = microPay(orderInfo.getStoreId(), reqData, ip, platform); + } else { + respData = jsapiPay(orderInfo.getStoreId(), reqData, ip, platform); + } + + if (respData == null) { + logger.error("微信支付接口调用异常......"); + return new ResponseObject(3000, "微信支付接口调用异常", null); + } + + // 2.更新预支付订单号 + if (respData.get("result_code").equals("SUCCESS")) { + if (respData.get("trade_type").equals(PayTypeEnum.JSAPI.getKey())) { + String prepayId = respData.get("prepay_id"); + getApiConfig(orderInfo.getStoreId(), platform); + WxPayApiConfig wxPayApiConfig = WxPayApiConfigKit.getWxPayApiConfig(); + respData = WxPayKit.miniAppPrepayIdCreateSign(wxPayApiConfig.getAppId(), prepayId, wxPayApiConfig.getPartnerKey(), SignType.MD5); + String jsonStr = JSON.toJSONString(respData); + logger.info("小程序支付的参数:" + jsonStr); + } + } else { + logger.error("微信支付接口返回状态失败......" + respData.toString() + "...reason"); + return new ResponseObject(3000, "微信支付失败:" + (respData.get("err_code_des") != null ? respData.get("err_code_des") : "未知错误"), null); + } + + ResponseObject responseObject = new ResponseObject(200, "微信支付接口返回成功", respData); + logger.info("WXService createPrepayOrder outParams {}", responseObject.toString()); + + return responseObject; + } + + /** + * 处理支付回调 + * + * @param request 请求参数 + * @return + * */ + public Map processResXml(HttpServletRequest request) { + try { + String xmlMsg = HttpKit.readData(request); + logger.info("支付通知=" + xmlMsg); + Map result = WxPayKit.xmlToMap(xmlMsg); + String returnCode = result.get("return_code"); + getApiConfig(0, PlatformTypeEnum.MP_WEIXIN.getCode()); + if (WxPayKit.verifyNotify(result, WxPayApiConfigKit.getWxPayApiConfig().getPartnerKey(), SignType.MD5)) { + if (WxPayKit.codeIsOk(returnCode)) { + return result; + } + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + return null; + } + + /** + * 处理回调xml + * + * @param response 响应参数 + * @param flag 标记 + * @return + * */ + public void processRespXml(HttpServletResponse response, boolean flag){ + Map respData = new HashMap<>(); + if (flag) { + respData.put("return_code", "SUCCESS"); + respData.put("return_msg", "OK"); + }else{ + respData.put("return_code", "FAIL"); + respData.put("return_msg", "FAIL"); + } + OutputStream outputStream = null; + try { + String respXml = WxPayKit.toXml(respData); + outputStream = response.getOutputStream(); + outputStream.write(respXml.getBytes("UTF-8")); + outputStream.flush(); + } catch (Exception e) { + e.printStackTrace(); + }finally { + if(outputStream!=null){ + try { + outputStream.close(); + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + } + } + } + + /** + * 获取微信个人信息 + * + * @param merchantId 商户ID + * @param code 微信返回编码 + * @throws BusinessCheckException + * @return + * */ + @Override + public JSONObject getWxProfile(Integer merchantId, String code) throws BusinessCheckException { + String wxAppId = env.getProperty("wxpay.appId"); + String wxAppSecret = env.getProperty("wxpay.appSecret"); + + if (merchantId != null && merchantId > 0) { + MtMerchant mtMerchant = merchantService.queryMerchantById(merchantId); + if (mtMerchant != null && StringUtil.isNotEmpty(mtMerchant.getWxAppId()) && StringUtil.isNotEmpty(mtMerchant.getWxAppSecret())) { + wxAppId = mtMerchant.getWxAppId(); + wxAppSecret = mtMerchant.getWxAppSecret(); + } + } + + String wxAccessUrl = "https://api.weixin.qq.com/sns/jscode2session?appid=%s&secret=%s&js_code=%s&grant_type=authorization_code"; + String url = String.format(wxAccessUrl, wxAppId, wxAppSecret, code); + try { + String response = HttpRESTDataClient.requestGet(url); + JSONObject json = (JSONObject) JSONObject.parse(response); + if (!json.containsKey("errcode")) { + return json; + } else { + logger.error("获取微信getWxProfile出错:code = " + json.containsKey("errcode") + ",msg="+ json.get("errmsg")); + } + } catch (Exception e) { + logger.error("获取微信getWxProfile异常:" + e.getMessage()); + } + + return null; + } + + /** + * 获取公众号openId + * + * @param merchantId 商户ID + * @param code 微信返回编码 + * @throws BusinessCheckException + * @return + * */ + @Override + public JSONObject getWxOpenId(Integer merchantId, String code) throws BusinessCheckException { + String wxAppId = env.getProperty("weixin.official.appId"); + String wxAppSecret = env.getProperty("weixin.official.appSecret"); + + if (merchantId != null && merchantId > 0) { + MtMerchant mtMerchant = merchantService.queryMerchantById(merchantId); + if (mtMerchant != null && StringUtil.isNotEmpty(mtMerchant.getWxOfficialAppId()) && StringUtil.isNotEmpty(mtMerchant.getWxOfficialAppSecret())) { + wxAppId = mtMerchant.getWxOfficialAppId(); + wxAppSecret = mtMerchant.getWxOfficialAppSecret(); + } + } + + String wxAccessUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code"; + String url = String.format(wxAccessUrl, wxAppId, wxAppSecret, code); + try { + String response = HttpRESTDataClient.requestGet(url); + JSONObject json = (JSONObject) JSONObject.parse(response); + if (!json.containsKey("errcode")) { + return json; + } else { + logger.error("获取openId出错:code = " + json.containsKey("errcode") + ",msg="+ json.get("errmsg")); + } + } catch (Exception e) { + logger.error("获取微信openId异常:" + e.getMessage()); + } + + return null; + } + + /** + * 获取微信绑定手机号 + * + * @param encryptedData 微信返回加密字符串 + * @param sessionKey session键值 + * @param iv 微信IV + * @return + * */ + @Override + public String getPhoneNumber(String encryptedData, String sessionKey, String iv) { + // 被加密的数据 + byte[] dataByte = Base64.getDecoder().decode(encryptedData); + // 加密秘钥 + byte[] keyByte = Base64.getDecoder().decode(sessionKey); + // 偏移量 + byte[] ivByte = Base64.getDecoder().decode(iv); + try { + // 如果密钥不足16位,那么就补足. 这个if 中的内容很重要 + int base = 16; + if (keyByte.length % base != 0) { + int groups = keyByte.length / base + (keyByte.length % base != 0 ? 1 : 0); + byte[] temp = new byte[groups * base]; + Arrays.fill(temp, (byte) 0); + System.arraycopy(keyByte, 0, temp, 0, keyByte.length); + keyByte = temp; + } + // 初始化 + Security.addProvider(new BouncyCastleProvider()); + Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); + SecretKeySpec spec = new SecretKeySpec(keyByte, "AES"); + AlgorithmParameters parameters = AlgorithmParameters.getInstance("AES"); + parameters.init(new IvParameterSpec(ivByte)); + cipher.init(Cipher.DECRYPT_MODE, spec, parameters);// 初始化 + byte[] resultByte = cipher.doFinal(dataByte); + if (null != resultByte && resultByte.length > 0) { + String result = new String(resultByte, "UTF-8"); + JSONObject object = JSONObject.parseObject(result); + return object.getString("phoneNumber"); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return null; + } + + /** + * 发送小程序订阅消息 + * + * @param merchantId 商户ID + * @param userId 会员ID + * @param toUserOpenId 接受者openId + * @param key 消息key + * @param page 跳转页面 + * @param params 发送参数 + * @param sendTime 发送时间 + * @throws BusinessCheckException + * @return + * */ + @Override + public Boolean sendSubscribeMessage(Integer merchantId, Integer userId, String toUserOpenId, String key, String page, Map params, Date sendTime) throws BusinessCheckException { + if (StringUtil.isEmpty(toUserOpenId) || StringUtil.isEmpty(key) || userId < 1) { + return false; + } + + MtSetting mtSetting = settingService.querySettingByName(merchantId, key); + if (mtSetting == null) { + return false; + } + + JSONObject jsonObject = null; + String templateId = ""; + JSONArray paramArray = null; + try { + if (mtSetting != null && mtSetting.getValue().indexOf('}') > 0) { + jsonObject = JSONObject.parseObject(mtSetting.getValue()); + } + if (jsonObject != null) { + templateId = jsonObject.get("templateId").toString(); + paramArray = (JSONArray) JSONObject.parse(jsonObject.get("params").toString()); + } + } catch (Exception e) { + logger.info("WeixinService sendSubscribeMessage parse setting error={}", mtSetting); + } + + if (StringUtil.isEmpty(templateId) || paramArray.size() < 1) { + logger.info("WeixinService sendSubscribeMessage setting error={}", mtSetting); + return false; + } + + JSONObject jsonData = new JSONObject(); + jsonData.put("touser", toUserOpenId); // 接收者的openid + jsonData.put("template_id", templateId); + + if (StringUtil.isEmpty(page)) { + page = "pages/index/index"; + } + jsonData.put("page", page); + + // 组装参数 + JSONObject data = new JSONObject(); + for (int i = 0; i < paramArray.size(); i++) { + JSONObject para = paramArray.getJSONObject(i); + String value = para.get("value").toString().replaceAll("\\{", "").replaceAll(".DATA}}", ""); + String paraKey = para.get("key").toString(); + String paraValue = params.get(paraKey).toString(); + JSONObject arg = new JSONObject(); + arg.put("value", paraValue); + data.put(value, arg); + } + jsonData.put("data", data); + + String reqDataJsonStr = JSON.toJSONString(jsonData); + + // 存储到消息表里,后续通过定时任务发送 + MtMessage mtMessage = new MtMessage(); + mtMessage.setMerchantId(merchantId); + mtMessage.setUserId(userId); + mtMessage.setType(MessageEnum.SUB_MSG.getKey()); + mtMessage.setTitle(WxMessageEnum.getValue(key)); + mtMessage.setContent(WxMessageEnum.getValue(key)); + mtMessage.setIsRead(YesOrNoEnum.NO.getKey()); + mtMessage.setIsSend(YesOrNoEnum.NO.getKey()); + mtMessage.setSendTime(sendTime); + mtMessage.setStatus(StatusEnum.ENABLED.getKey()); + mtMessage.setParams(reqDataJsonStr); + messageService.addMessage(mtMessage); + + return true; + } + + /** + * 发送订阅消息 + * + * @param merchantId 商户ID + * @param reqDataJsonStr 请求参数 + * @return + * */ + @Override + public Boolean doSendSubscribeMessage(Integer merchantId, String reqDataJsonStr) { + try { + String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + getAccessToken(merchantId, true); + String response = HttpRESTDataClient.requestPost(url, "application/json; charset=utf-8", reqDataJsonStr); + logger.info("WeixinService sendSubscribeMessage response={}", response); + JSONObject json = (JSONObject) JSONObject.parse(response); + if (json.get("errcode").toString().equals("40001")) { + getAccessToken(merchantId, false); + logger.error("发送订阅消息出错error1:" + json.get("errcode").toString()); + return false; + } else if (!json.get("errcode").toString().equals("0")) { + logger.error("发送订阅消息出错error2:" + json.get("errcode").toString()); + return false; + } else { + return true; + } + } catch (Exception e) { + logger.error("发送订阅消息出错:" + e.getMessage()); + } + + return true; + } + + /** + * 查询支付订单 + * + * @param storeId 店铺ID + * @param transactionId 支付流水ID + * @param orderSn 订单号 + * @return + * */ + @Override + public Map queryPaidOrder(Integer storeId, String transactionId, String orderSn) { + try { + getApiConfig(storeId, PlatformTypeEnum.MP_WEIXIN.getCode()); + WxPayApiConfig wxPayApiConfig = WxPayApiConfigKit.getWxPayApiConfig(); + Map params = OrderQueryModel.builder() + .appid(wxPayApiConfig.getAppId()) + .mch_id(wxPayApiConfig.getMchId()) + .transaction_id(transactionId) + .out_trade_no(orderSn) + .nonce_str(WxPayKit.generateStr()) + .build() + .createSign(wxPayApiConfig.getPartnerKey(), SignType.MD5); + logger.info("请求参数:{}", WxPayKit.toXml(params)); + String query = WxPayApi.orderQuery(params); + Map result = WxPayKit.xmlToMap(query); + logger.info("查询结果: {}", result); + if (result.get("result_code").equals("FAIL")) { + result.put("trade_state", "FAIL"); + } + return result; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * 刷卡支付 + * + * @param storeId 店铺ID + * @param reqData 请求参数 + * @param ip 支付IP + * @param platform 支付平台 + * @return + * */ + private Map microPay(Integer storeId, Map reqData, String ip, String platform) { + try { + String orderSn = reqData.get("out_trade_no"); + + logger.info("调用微信刷卡支付下单接口入参{}", JsonUtil.toJSONString(reqData)); + logger.info("请求平台:{}, 订单号:{}", platform, orderSn); + + // 支付配置 + getApiConfig(storeId, platform); + WxPayApiConfig wxPayApiConfig = WxPayApiConfigKit.getWxPayApiConfig(); + Map params = MicroPayModel.builder() + .appid(wxPayApiConfig.getAppId()) + .mch_id(wxPayApiConfig.getMchId()) + .nonce_str(WxPayKit.generateStr()) + .body(reqData.get("body")) + .attach(reqData.get("body")) + .out_trade_no(orderSn) + .total_fee(reqData.get("total_fee")) + .spbill_create_ip(ip) + .auth_code(reqData.get("auth_code")) + .build() + .createSign(wxPayApiConfig.getPartnerKey(), SignType.MD5); + String xmlResult = WxPayApi.microPay(false, params); + + // 同步返回结果 + logger.info("xmlResult:" + xmlResult); + Map respMap = WxPayKit.xmlToMap(xmlResult); + String returnCode = respMap.get("return_code"); + String returnMsg = respMap.get("return_msg"); + if (!WxPayKit.codeIsOk(returnCode)) { + // 通讯失败 + Map payResult = null; + String errCode = respMap.get("err_code"); + if (StringUtil.isNotEmpty(errCode)) { + // 用户支付中,需要输入密码 + if (errCode.equals("USERPAYING")) { + // 等待10秒后查询订单 + try { + Thread.sleep(10000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + payResult = queryPaidOrder(storeId, respMap.get("transaction_id"), orderSn); + } + } + if (payResult == null || !payResult.get("trade_state").equals("SUCCESS")) { + logger.info("提交刷卡支付失败>>" + xmlResult); + return respMap; + } + } + + String resultCode = respMap.get("result_code"); + if (!WxPayKit.codeIsOk(resultCode)) { + logger.info("支付失败>>" + xmlResult); + logger.error(returnMsg); + return respMap; + } + + // 支付成功 + logger.info("刷卡支付返回>>" + respMap.toString()); + + if (StringUtil.isNotEmpty(orderSn)) { + UserOrderDto orderInfo = orderService.getOrderByOrderSn(orderSn); + if (orderInfo != null) { + if (!orderInfo.getStatus().equals(OrderStatusEnum.DELETED.getKey())) { + paymentService.paymentCallback(orderInfo); + } + } + } + + return respMap; + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + return null; + } + + /** + * 小程序、公众号支付 + * + * @param storeId 店铺ID + * @param reqData 请求参数 + * @param ip 支付IP + * @param platform 支付平台 + * @return + * */ + private Map jsapiPay(Integer storeId, Map reqData, String ip, String platform) { + try { + logger.info("调用微信支付下单接口入参{}", JsonUtil.toJSONString(reqData)); + logger.info("请求平台:{}", platform); + // 支付配置 + getApiConfig(storeId, platform); + WxPayApiConfig wxPayApiConfig = WxPayApiConfigKit.getWxPayApiConfig(); + Map params = UnifiedOrderModel + .builder() + .appid(wxPayApiConfig.getAppId()) + .mch_id(wxPayApiConfig.getMchId()) + .nonce_str(WxPayKit.generateStr()) + .body(reqData.get("body")) + .attach(reqData.get("body")) + .out_trade_no(reqData.get("out_trade_no")) + .total_fee(reqData.get("total_fee")) + .spbill_create_ip(ip) + .notify_url(wxPayApiConfig.getDomain() + CALL_BACK_URL) + .trade_type(reqData.get("trade_type")) + .openid(reqData.get("openid")) + .build() + .createSign(wxPayApiConfig.getPartnerKey(), SignType.MD5); + String xmlResult = WxPayApi.pushOrder(false, params); + + logger.info(xmlResult); + Map result = WxPayKit.xmlToMap(xmlResult); + + String returnCode = result.get("return_code"); + String returnMsg = result.get("return_msg"); + if (!WxPayKit.codeIsOk(returnCode)) { + logger.error(returnMsg); + } + String resultCode = result.get("result_code"); + if (!WxPayKit.codeIsOk(resultCode)) { + logger.error(returnMsg); + } + + logger.info("调用微信支付下单接口返回{}", JsonUtil.toJSONString(result)); + return result; + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + return null; + } + + /** + * 发起售后 + * + * @param storeId 店铺ID + * @param orderSn 订单号 + * @param totalAmount 支付总金额 + * @param refundAmount 退款金额 + * @param platform 支付平台 + * @throws BusinessCheckException + * @return + * */ + public Boolean doRefund(Integer storeId, String orderSn, BigDecimal totalAmount, BigDecimal refundAmount, String platform) throws BusinessCheckException { + try { + logger.info("WeixinService.doRefund orderSn = {}, totalFee = {}, refundFee = {}", orderSn, totalAmount, refundAmount); + if (StringUtil.isEmpty(orderSn)) { + throw new BusinessCheckException("退款订单号不能为空..."); + } + + BigDecimal totalFee = totalAmount.multiply(new BigDecimal("100")); + BigDecimal refundFee = refundAmount.multiply(new BigDecimal("100")); + Integer totalFeeInt = totalFee.intValue(); + Integer refundFeeInt = refundFee.intValue(); + + // 支付配置 + getApiConfig(storeId, platform); + WxPayApiConfig wxPayApiConfig = WxPayApiConfigKit.getWxPayApiConfig(); + Map params = RefundModel.builder() + .appid(wxPayApiConfig.getAppId()) + .mch_id(wxPayApiConfig.getMchId()) + .nonce_str(WxPayKit.generateStr()) + .transaction_id("") + .out_trade_no(orderSn) + .out_refund_no(orderSn) + .total_fee(totalFeeInt.toString()) + .refund_fee(refundFeeInt.toString()) + .notify_url(wxPayApiConfig.getDomain() + REFUND_NOTIFY_URL) + .build() + .createSign(wxPayApiConfig.getPartnerKey(), SignType.MD5); + String refundStr = WxPayApi.orderRefund(false, params, wxPayApiConfig.getCertPath(), wxPayApiConfig.getMchId()); + logger.info("WeixinService doRefund params: {}", params); + logger.info("WeixinService doRefund return: {}", refundStr); + Map result = WxPayKit.xmlToMap(refundStr); + String returnCode = result.get("return_code"); + String returnMsg = result.get("return_msg"); + if (!WxPayKit.codeIsOk(returnCode)) { + logger.error(returnMsg); + return false; + } + return true; + } catch (Exception e) { + throw new BusinessCheckException("WeixinService.doRefund 微信退款失败:" + e.getMessage()); + } + } + + /*** + * 生成店铺二维码 + * + * @param merchantId 商户ID + * @param storeId 店铺ID + * @param width 宽度 + * @return + * */ + public String createStoreQrCode(Integer merchantId, Integer storeId, Integer width) { + try { + String accessToken = getAccessToken(merchantId, true); + String url = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=" + accessToken; + String reqDataJsonStr = ""; + + Map reqData = new HashMap<>(); + reqData.put("access_token", accessToken); + reqData.put("path", "pages/index/index?storeId=" + storeId); + reqData.put("width", width); + reqDataJsonStr = JsonUtil.toJSONString(reqData); + + byte[] bytes = HttpRESTDataClient.requestPost(url, reqDataJsonStr); + logger.info("WechatService createStoreQrCode response success"); + + String pathRoot = env.getProperty("images.root"); + String baseImage = env.getProperty("images.path"); + String filePath = "storeQr" + storeId + ".png"; + String path = pathRoot + baseImage + filePath; + QRCodeUtil.saveQrCodeToLocal(bytes, path); + + // 上传阿里云oss + String mode = env.getProperty("aliyun.oss.mode"); + if (mode.equals("1")) { // 检查是否开启上传 + String endpoint = env.getProperty("aliyun.oss.endpoint"); + String accessKeyId = env.getProperty("aliyun.oss.accessKeyId"); + String accessKeySecret = env.getProperty("aliyun.oss.accessKeySecret"); + String bucketName = env.getProperty("aliyun.oss.bucketName"); + String folder = env.getProperty("aliyun.oss.folder"); + OSS ossClient = AliyunOssUtil.getOSSClient(accessKeyId, accessKeySecret, endpoint); + File ossFile = new File(path); + return AliyunOssUtil.upload(ossClient, ossFile, bucketName, folder); + } else { + return baseImage + filePath; + } + } catch (Exception e) { + logger.error("生成店铺二维码出错:" + e.getMessage()); + } + return ""; + } + + /** + * 获取支付配置 + * + * @param storeId 店铺ID + * @param platform 支付平台 + * @throws BusinessCheckException + * @return + * */ + private WxPayApiConfig getApiConfig(Integer storeId, String platform) throws BusinessCheckException { + WxPayApiConfig apiConfig; + MtStore mtStore = storeService.queryStoreById(storeId); + String mchId = wxPayBean.getMchId(); + String apiV2 = wxPayBean.getApiV2(); + String certPath = wxPayBean.getCertPath(); + if (mtStore != null && StringUtil.isNotEmpty(mtStore.getWxApiV2()) && StringUtil.isNotEmpty(mtStore.getWxMchId())) { + mchId = mtStore.getWxMchId(); + apiV2 = mtStore.getWxApiV2(); + String basePath = env.getProperty("images.root"); + certPath = basePath + mtStore.getWxCertPath(); + } + apiConfig = WxPayApiConfig.builder() + .appId(wxPayBean.getAppId()) + .mchId(mchId) + .partnerKey(apiV2) + .certPath(certPath) + .domain(wxPayBean.getDomain()) + .build(); + // 微信内h5公众号支付 + if (platform.equals(PlatformTypeEnum.H5.getCode())) { + String wxAppId = env.getProperty("weixin.official.appId"); + String wxAppSecret = env.getProperty("weixin.official.appSecret"); + + if (mtStore != null) { + MtMerchant mtMerchant = merchantService.queryMerchantById(mtStore.getMerchantId()); + if (mtMerchant != null && StringUtil.isNotEmpty(mtMerchant.getWxOfficialAppId()) && StringUtil.isNotEmpty(mtMerchant.getWxOfficialAppSecret())) { + wxAppId = mtMerchant.getWxOfficialAppId(); + wxAppSecret = mtMerchant.getWxOfficialAppSecret(); + } + } + + if (StringUtil.isNotEmpty(wxAppId) && StringUtil.isNotEmpty(wxAppSecret)) { + apiConfig.setAppId(wxAppId); + apiConfig.setApiKey(wxAppSecret); + } + } + WxPayApiConfigKit.setThreadLocalWxPayApiConfig(apiConfig); + logger.info("微信支付参数:{}", JsonUtil.toJSONString(apiConfig)); + return apiConfig; + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/util/AliyunOssUtil.java b/fuint-application/src/main/java/com/fuint/common/util/AliyunOssUtil.java new file mode 100644 index 0000000..8bfc919 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/util/AliyunOssUtil.java @@ -0,0 +1,124 @@ +package com.fuint.common.util; + +import com.aliyun.oss.OSS; +import com.aliyun.oss.model.Bucket; +import com.aliyun.oss.OSSClientBuilder; +import com.aliyun.oss.model.OSSObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.Date; + +/** + * 阿里云OSS存储工具 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public class AliyunOssUtil { + + private static final Logger logger = LoggerFactory.getLogger(AliyunOssUtil.class); + + /** + * 获取阿里云OSS客户端对象 + * + * @param accessKeyId 访问键值 + * @param accessKeySecret 访问秘钥 + * @param endpoint 存储endPoint + * @return ossClient + */ + public static OSS getOSSClient(String accessKeyId, String accessKeySecret, String endpoint) { + return new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret); + } + + /** + * 创建存储空间 + * + * @param ossClient OSS连接 + * @param bucketName 存储空间 + * @return + */ + public static String createBucketName(OSS ossClient, String bucketName) { + // 存储空间 + final String bucketNames = bucketName; + + if (!ossClient.doesBucketExist(bucketName)) { + // 创建存储空间 + Bucket bucket = ossClient.createBucket(bucketName); + logger.info("创建存储空间成功"); + return bucket.getName(); + } + + return bucketNames; + } + + /** + * 创建模拟文件夹 + * + * @param ossClient oss连接 + * @param bucketName 存储bucket + * @param folder 文件夹 + * @return 文件夹名 + */ + public static String createFolder(OSS ossClient, String bucketName, String folder) { + // 文件夹名 + final String keySuffixWithSlash = folder; + + // 判断文件夹是否存在,不存在则创建 + if (!ossClient.doesObjectExist(bucketName, keySuffixWithSlash)) { + // 创建文件夹 + ossClient.putObject(bucketName, keySuffixWithSlash, new ByteArrayInputStream(new byte[0])); + logger.info("创建文件夹成功"); + // 得到文件夹名 + OSSObject object = ossClient.getObject(bucketName, keySuffixWithSlash); + String fileDir = object.getKey(); + return fileDir; + } + + return keySuffixWithSlash; + } + + /** + * 上传图片至OSS + * + * @param ossClient oss连接 + * @param file 上传文件(文件全路径如:D:\\image\\cake.jpg) + * @return String 返回文件url + */ + public static String upload(OSS ossClient, File file, String bucketName, String folder) { + String resultStr = null; + + // 先创建存储空间和文件夹 + createBucketName(ossClient, bucketName); + createFolder(ossClient, bucketName, folder); + + try { + InputStream is = new FileInputStream(file); + String fileName = file.getName(); + String date = DateUtil.formatDate(new Date(), "yyyyMMdd"); + ossClient.putObject(bucketName, folder + "/" + date + "/" + fileName, is); + resultStr = "/" + folder + "/" + date +"/" + fileName; + } catch (Exception e) { + e.printStackTrace(); + logger.error("上传阿里云OSS服务器异常." + e.getMessage(), e); + } + + return resultStr; + } + + /** + * 根据key删除OSS上的文件 + * + * @param ossClient oss连接 + * @param key Bucket下的文件的路径名+文件名 如:"upload/cake.jpg" + */ + public static void deleteFile(OSS ossClient, String bucketName, String folder, String key) { + ossClient.deleteObject(bucketName, folder + key); + + logger.info("删除" + bucketName + "下的文件" + folder + key + "成功"); + } +} + diff --git a/fuint-application/src/main/java/com/fuint/common/util/AuthUserUtil.java b/fuint-application/src/main/java/com/fuint/common/util/AuthUserUtil.java new file mode 100644 index 0000000..24a681c --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/util/AuthUserUtil.java @@ -0,0 +1,29 @@ +package com.fuint.common.util; + +import com.alibaba.ttl.TransmittableThreadLocal; +import com.fuint.common.dto.AccountInfo; + +/** + * 用户认证工具 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public class AuthUserUtil { + + private static final ThreadLocal USER_INFO_IN_TOKEN_HOLDER = new TransmittableThreadLocal<>(); + + public static AccountInfo get() { + return USER_INFO_IN_TOKEN_HOLDER.get(); + } + + public static void set(AccountInfo userInfoInTokenBo) { + USER_INFO_IN_TOKEN_HOLDER.set(userInfoInTokenBo); + } + + public static void clean() { + if (USER_INFO_IN_TOKEN_HOLDER.get() != null) { + USER_INFO_IN_TOKEN_HOLDER.remove(); + } + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/util/Base64Util.java b/fuint-application/src/main/java/com/fuint/common/util/Base64Util.java new file mode 100644 index 0000000..a560bc9 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/util/Base64Util.java @@ -0,0 +1,106 @@ +package com.fuint.common.util; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.io.UnsupportedEncodingException; +import java.util.Base64; + +/** + * 编码工具 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public class Base64Util { + + private static final Logger logger = LoggerFactory.getLogger(Base64Util.class); + + public Base64Util() { + // empty + } + + public static byte[] baseEncode(byte[] bytes) { + return Base64.getEncoder().encode(bytes); + } + + public static String baseEncode(String s) { + try { + byte[] e = s.getBytes("UTF-8"); + return Base64.getEncoder().encodeToString(e); + } catch (UnsupportedEncodingException var2) { + logger.error(var2.getMessage(), var2); + return null; + } + } + + public static byte[] baseDecode(byte[] bytes) { + return Base64.getDecoder().decode(bytes); + } + + public static String baseDecode(String s) { + try { + byte[] e = Base64.getDecoder().decode(s); + return new String(e, "UTF-8"); + } catch (UnsupportedEncodingException var2) { + logger.error(var2.getMessage(), var2); + return null; + } + } + + public static byte[] urlEncode(byte[] bytes) { + return Base64.getUrlEncoder().encode(bytes); + } + + public static String urlEncode(String s) { + try { + byte[] e = s.getBytes("UTF-8"); + return Base64.getUrlEncoder().encodeToString(e); + } catch (UnsupportedEncodingException var2) { + logger.error(var2.getMessage(), var2); + return null; + } + } + + public static byte[] urlDecode(byte[] bytes) { + return Base64.getUrlDecoder().decode(bytes); + } + + public static String urlDecode(String s) { + byte[] result = Base64.getUrlDecoder().decode(s); + + try { + return new String(result, "UTF-8"); + } catch (UnsupportedEncodingException var3) { + logger.error(var3.getMessage(), var3); + return null; + } + } + + public static byte[] mimeEncode(byte[] bytes) { + return Base64.getMimeEncoder().encode(bytes); + } + + public static String mimeEncode(String s) { + try { + byte[] e = s.getBytes("UTF-8"); + return Base64.getMimeEncoder().encodeToString(e); + } catch (UnsupportedEncodingException var2) { + logger.error(var2.getMessage(), var2); + return null; + } + } + + public static byte[] mimeDecode(byte[] bytes) { + return Base64.getMimeDecoder().decode(bytes); + } + + public static String mimeDecode(String s) { + try { + byte[] e = Base64.getMimeDecoder().decode(s); + return new String(e, "UTF-8"); + } catch (UnsupportedEncodingException var2) { + logger.error(var2.getMessage(), var2); + return null; + } + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/util/BizCodeGenerator.java b/fuint-application/src/main/java/com/fuint/common/util/BizCodeGenerator.java new file mode 100644 index 0000000..3ed600d --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/util/BizCodeGenerator.java @@ -0,0 +1,65 @@ +package com.fuint.common.util; + +import com.fuint.utils.StringUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Random; + +/** + * 业务Code生成器 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public class BizCodeGenerator { + + private static final Logger logger = LoggerFactory.getLogger(BizCodeGenerator.class); + + private static String DATE_FORMAT="yyyyMMddHHmmssSSS"; + + /** + * 获取指定前缀的Code字符串 + * @param preString 前缀字符串 + * @return + */ + public synchronized static String getPreCodeString(String preString) { + StringBuffer result = new StringBuffer(); + if(StringUtil.isNotEmpty(preString)){ + result.append(preString); + } + + String dateStr = new SimpleDateFormat(DATE_FORMAT).format(new Date()); + result.append(dateStr); + + String randomStr = SeqUtil.getRandomNumber(2); + result.append(randomStr); + return result.toString(); + } + + + /** + * 生成6位数字短信验证码 + * @param + * @return + */ + public synchronized static String getVerifyCode() { + String verifyCode = getFixLengthString(6); + return verifyCode; + } + + /** + * 返回长度为【strLength】的随机数,在前面补0 + * @return + */ + private static String getFixLengthString(int strLength) { + Random rm = new Random(); + // 获得随机数 + double process = (1 + rm.nextDouble()) * Math.pow(10, strLength); + // 将获得的获得随机数转化为字符串 + String codeStr = String.valueOf(process); + // 返回固定的长度的随机数 + return codeStr.substring(1, strLength + 1); + } +} diff --git a/fuint-application/src/main/java/com/fuint/common/util/CommonUtil.java b/fuint-application/src/main/java/com/fuint/common/util/CommonUtil.java new file mode 100644 index 0000000..cb9b644 --- /dev/null +++ b/fuint-application/src/main/java/com/fuint/common/util/CommonUtil.java @@ -0,0 +1,483 @@ +package com.fuint.common.util; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.JSONArray; +import com.fuint.utils.StringUtil; +import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; +import java.io.*; +import java.net.*; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.regex.Pattern; +import java.util.regex.Matcher; + +/** + * 通用工具 + * + * Created by FSQ + * CopyRight https://www.fuint.cn + */ +public class CommonUtil { + + /** + * 功能:将输入字符串的首字母改成大写 + * + * @param str + * @return + */ + public static String firstLetterToUpperCase(String str) { + char[] ch = str.toCharArray(); + if (ch[0] >= 'a' && ch[0] <= 'z') { + ch[0] = (char) (ch[0] - 32); + } + return new String(ch); + } + + /** + * 判断是否UTF-8编码 + * + * @param str + * @return + * */ + public static boolean isUtf8(String str) { + try { + byte[] bytes = str.getBytes("UTF-8"); + String newStr = new String(bytes, "UTF-8"); + return str.equals(newStr); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + return false; + } + + /** + * 判断是否乱码 + * + * @param str + * @return + * */ + public static boolean isErrCode(String str) { + return !(java.nio.charset.Charset.forName("GBK").newEncoder().canEncode(str)); + } + + /** + * 判断是否数字 + * + * @param str 字符串 + * @return + * */ + public static boolean isNumeric(String str) { + if (StringUtil.isEmpty(str)) { + return false; + } + + Pattern pattern = Pattern.compile("[0-9]*\\.?[0-9]+"); + Matcher isNum = pattern.matcher(str); + + if (!isNum.matches()) { + return false; + } + + return true; + } + + /** + * 生成随机会员号(13位数) + * + * @return + * */ + public static String createUserNo() { + StringBuilder sb = new StringBuilder("8"); + sb.append(SeqUtil.getRandomNumber(4)); + sb.append(SeqUtil.getRandomNumber(4)); + sb.append(SeqUtil.getRandomNumber(4)); + return sb.toString(); + } + + /** + * 生成随机键值号 + * + * @return + * */ + public static String createAccountKey() { + StringBuilder sb = new StringBuilder("11"); + sb.append(SeqUtil.getRandomNumber(6)); + sb.append(SeqUtil.getRandomNumber(5)); + String t = TimeUtils.formatDate(new Date(), "yyyyMMddHH"); + return t + sb.toString(); + } + + /** + * 生成随机商户号 + * + * @return + * */ + public static String createMerchantNo() { + StringBuilder sb = new StringBuilder("8"); + sb.append(SeqUtil.getRandomNumber(4)); + sb.append(SeqUtil.getRandomNumber(4)); + return sb.toString(); + } + + /** + * 生成随机结算单号(13位数) + * + * @return + * */ + public static String createSettlementNo() { + StringBuilder sb = new StringBuilder("8"); + sb.append(SeqUtil.getRandomNumber(4)); + sb.append(SeqUtil.getRandomNumber(4)); + sb.append(SeqUtil.getRandomNumber(4)); + return sb.toString(); + } + + /** + * 生成随机订单号 + * + * @param userId + * @return + * */ + public static String createOrderSN(String userId) { + // 时间是17位 + String date = DateUtil.formatDate(Calendar.getInstance().getTime(), "yyyyMMddHHmmssSSS"); + StringBuilder sb = new StringBuilder(); + sb.append(date); + + // 目前的会员id为9位,不确定后面会不会变更 + if (userId.length() > 9) { + sb.append(userId.substring(userId.length() - 9, 9)); + } + + if (userId.length() == 9) { + sb.append(userId); + } + + // 如果小于9位补位 + if (userId.length() < 9) { + for (int i = 0; i < userId.length() - 9; i++) { + sb.append("0"); + } + } + + // 加上4位随机数 + sb.append(SeqUtil.getRandomNumber(4)); + return sb.toString(); + } + + /** + * 获取IP地址 + * + * @param request + * @return String + */ + public static String getIPFromHttpRequest(HttpServletRequest request) { + String ipAddress; + try { + ipAddress = request.getHeader("x-forwarded-for"); + if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { + ipAddress = request.getHeader("Proxy-Client-IP"); + } + if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { + ipAddress = request.getHeader("WL-Proxy-Client-IP"); + } + if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { + ipAddress = request.getRemoteAddr(); + if (ipAddress.equals("127.0.0.1")) { + // 根据网卡取本机配置的IP + InetAddress inet = null; + try { + inet = InetAddress.getLocalHost(); + } catch (UnknownHostException e) { + e.printStackTrace(); + } + ipAddress = inet.getHostAddress(); + } + } + // 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割 + if (ipAddress != null && ipAddress.length() > 15) { + if (ipAddress.indexOf(",") > 0) { + ipAddress = ipAddress.substring(0, ipAddress.indexOf(",")); + } + } + } catch (Exception e) { + ipAddress = ""; + } + + if (!isValidIP(ipAddress)) { + return "127.0.0.1"; + } + + return ipAddress; + } + + /** + * 验证ip地址是否正确 + * + * @param ip + * @return + * */ + public static boolean isValidIP(String ip) { + if ((ip != null) && (!ip.isEmpty())) { + return Pattern.matches("^([1-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}$", ip); + } + return false; + } + + /** + * 保存上传文件 + * + * @param file 上传的文件 + * @param filePath 文件路径 + * @return + * */ + public static void saveMultipartFile(MultipartFile file, String filePath) { + if (file != null && !file.isEmpty()) { + try { + FileOutputStream os = new FileOutputStream(new File(filePath)); + //拿到上传文件的输入流 + os.write(file.getBytes()); + os.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + /** + * 格式化指定的日期 + * + * @param date + * @param formatStr + * @return + */ + public static String formatDate(Date date, String formatStr) { + if (date == null) date = new Date(); + if (StringUtil.isEmpty(formatStr)) formatStr = "yyyy-MM-dd"; + SimpleDateFormat dateFormater = new SimpleDateFormat(formatStr); + return dateFormater.format(date); + } + + /** + * 根据地址获取经纬度 + * + * @param addr 地址 + * @return + * */ + public static Map getLatAndLngByAddress(String addr) { + String address = ""; + try { + address = java.net.URLEncoder.encode(addr,"UTF-8"); + } catch (UnsupportedEncodingException e1) { + e1.printStackTrace(); + } + + // key如果失效了就去高德地图官网申请 + String url = "https://restapi.amap.com/v3/geocode/geo?address="+address+"&output=JSON&key="+"4d57813b7b9157d66899cc4c1f22dc04"; + + URL myURL = null; + URLConnection httpsConn; + // 进行转码 + try { + myURL = new URL(url); + } catch (MalformedURLException e) { + // empty + } + StringBuffer sb = new StringBuffer(); + try { + httpsConn = myURL.openConnection(); + if (httpsConn != null) { + InputStreamReader insr = new InputStreamReader(httpsConn.getInputStream(), "UTF-8"); + BufferedReader br = new BufferedReader(insr); + String data = null; + while ((data = br.readLine()) != null) { + sb.append(data); + } + insr.close(); + } + } catch (IOException e) { + + } + + Map map = new HashMap<>(); + JSONObject resultJson = JSON.parseObject(sb.toString()); + JSONArray geocodes = resultJson.getJSONArray("geocodes"); + + + String lat = ""; + String lng = ""; + + if (geocodes != null) { + JSONObject jsonObject = geocodes.getJSONObject(0); + String location = jsonObject.getString("location"); + + if (org.apache.commons.lang.StringUtils.isNotEmpty(location)) { + String latAndLng[] = location.split(","); + if (latAndLng.length == 2) { + lat = latAndLng[1]; + lng = latAndLng[0]; + } + } + } + + map.put("lat", lat); + map.put("lng", lng); + + return map; + } + + /** + * 去除待带script、src的语句,转义替换后的value值 + * + * @param value + * + * @return + */ + public static String replaceXSS(String value) { + if (value != null) { + try { + value = value.replace("+","%2B"); + value = URLDecoder.decode(value, "utf-8"); + } catch(Exception e) { + //empty + } + + StringBuilder buf = new StringBuilder(value.length()); + int len = value.length(); + for (int i = 0; i < len; i++) { + char codePoint = value.charAt(i); + if (isEmojiCharacter(codePoint)) { + buf.append("*"); + } else { + buf.append(codePoint); + } + } + + String emojiStr = buf.toString(); + if (!StringUtil.isEmpty(emojiStr)) { + value = emojiStr; + } + + // Avoid null characters + value = value.replaceAll("\0", ""); + + // Avoid anything between script tags + Pattern scriptPattern = Pattern.compile("", Pattern.CASE_INSENSITIVE); + value = scriptPattern.matcher(value).replaceAll(""); + + // Avoid anything in a src='...' type of e­xpression + scriptPattern = Pattern.compile("src[\r\n]*=[\r\n]*\\\'(.*?)\\\'", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL); + value = scriptPattern.matcher(value).replaceAll(""); + + scriptPattern = Pattern.compile("src[\r\n]*=[\r\n]*\\\"(.*?)\\\"", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL); + value = scriptPattern.matcher(value).replaceAll(""); + + // Remove any lonesome tag + scriptPattern = Pattern.compile("", Pattern.CASE_INSENSITIVE); + value = scriptPattern.matcher(value).replaceAll(""); + + // Remove any lonesome