diff --git a/LICENSE b/LICENSE deleted file mode 100644 index ca38718f..00000000 --- a/LICENSE +++ /dev/null @@ -1,191 +0,0 @@ -Apache License -Version 2.0, January 2004 -http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - -"License" shall mean the terms and conditions for use, reproduction, and -distribution as defined by Sections 1 through 9 of this document. - -"Licensor" shall mean the copyright owner or entity authorized by the copyright -owner that is granting the License. - -"Legal Entity" shall mean the union of the acting entity and all other entities -that control, are controlled by, or are under common control with that entity. -For the purposes of this definition, "control" means (i) the power, direct or -indirect, to cause the direction or management of such entity, whether by -contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the -outstanding shares, or (iii) beneficial ownership of such entity. - -"You" (or "Your") shall mean an individual or Legal Entity exercising -permissions granted by this License. - -"Source" form shall mean the preferred form for making modifications, including -but not limited to software source code, documentation source, and configuration -files. - -"Object" form shall mean any form resulting from mechanical transformation or -translation of a Source form, including but not limited to compiled object code, -generated documentation, and conversions to other media types. - -"Work" shall mean the work of authorship, whether in Source or Object form, made -available under the License, as indicated by a copyright notice that is included -in or attached to the work (an example is provided in the Appendix below). - -"Derivative Works" shall mean any work, whether in Source or Object form, that -is based on (or derived from) the Work and for which the editorial revisions, -annotations, elaborations, or other modifications represent, as a whole, an -original work of authorship. For the purposes of this License, Derivative Works -shall not include works that remain separable from, or merely link (or bind by -name) to the interfaces of, the Work and Derivative Works thereof. - -"Contribution" shall mean any work of authorship, including the original version -of the Work and any modifications or additions to that Work or Derivative Works -thereof, that is intentionally submitted to Licensor for inclusion in the Work -by the copyright owner or by an individual or Legal Entity authorized to submit -on behalf of the copyright owner. For the purposes of this definition, -"submitted" means any form of electronic, verbal, or written communication sent -to the Licensor or its representatives, including but not limited to -communication on electronic mailing lists, source code control systems, and -issue tracking systems that are managed by, or on behalf of, the Licensor for -the purpose of discussing and improving the Work, but excluding communication -that is conspicuously marked or otherwise designated in writing by the copyright -owner as "Not a Contribution." - -"Contributor" shall mean Licensor and any individual or Legal Entity on behalf -of whom a Contribution has been received by Licensor and subsequently -incorporated within the Work. - -2. Grant of Copyright License. - -Subject to the terms and conditions of this License, each Contributor hereby -grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, -irrevocable copyright license to reproduce, prepare Derivative Works of, -publicly display, publicly perform, sublicense, and distribute the Work and such -Derivative Works in Source or Object form. - -3. Grant of Patent License. - -Subject to the terms and conditions of this License, each Contributor hereby -grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, -irrevocable (except as stated in this section) patent license to make, have -made, use, offer to sell, sell, import, and otherwise transfer the Work, where -such license applies only to those patent claims licensable by such Contributor -that are necessarily infringed by their Contribution(s) alone or by combination -of their Contribution(s) with the Work to which such Contribution(s) was -submitted. If You institute patent litigation against any entity (including a -cross-claim or counterclaim in a lawsuit) alleging that the Work or a -Contribution incorporated within the Work constitutes direct or contributory -patent infringement, then any patent licenses granted to You under this License -for that Work shall terminate as of the date such litigation is filed. - -4. Redistribution. - -You may reproduce and distribute copies of the Work or Derivative Works thereof -in any medium, with or without modifications, and in Source or Object form, -provided that You meet the following conditions: - -You must give any other recipients of the Work or Derivative Works a copy of -this License; and -You must cause any modified files to carry prominent notices stating that You -changed the files; and -You must retain, in the Source form of any Derivative Works that You distribute, -all copyright, patent, trademark, and attribution notices from the Source form -of the Work, excluding those notices that do not pertain to any part of the -Derivative Works; and -If the Work includes a "NOTICE" text file as part of its distribution, then any -Derivative Works that You distribute must include a readable copy of the -attribution notices contained within such NOTICE file, excluding those notices -that do not pertain to any part of the Derivative Works, in at least one of the -following places: within a NOTICE text file distributed as part of the -Derivative Works; within the Source form or documentation, if provided along -with the Derivative Works; or, within a display generated by the Derivative -Works, if and wherever such third-party notices normally appear. The contents of -the NOTICE file are for informational purposes only and do not modify the -License. You may add Your own attribution notices within Derivative Works that -You distribute, alongside or as an addendum to the NOTICE text from the Work, -provided that such additional attribution notices cannot be construed as -modifying the License. -You may add Your own copyright statement to Your modifications and may provide -additional or different license terms and conditions for use, reproduction, or -distribution of Your modifications, or for any such Derivative Works as a whole, -provided Your use, reproduction, and distribution of the Work otherwise complies -with the conditions stated in this License. - -5. Submission of Contributions. - -Unless You explicitly state otherwise, any Contribution intentionally submitted -for inclusion in the Work by You to the Licensor shall be under the terms and -conditions of this License, without any additional terms or conditions. -Notwithstanding the above, nothing herein shall supersede or modify the terms of -any separate license agreement you may have executed with Licensor regarding -such Contributions. - -6. Trademarks. - -This License does not grant permission to use the trade names, trademarks, -service marks, or product names of the Licensor, except as required for -reasonable and customary use in describing the origin of the Work and -reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. - -Unless required by applicable law or agreed to in writing, Licensor provides the -Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, -including, without limitation, any warranties or conditions of TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are -solely responsible for determining the appropriateness of using or -redistributing the Work and assume any risks associated with Your exercise of -permissions under this License. - -8. Limitation of Liability. - -In no event and under no legal theory, whether in tort (including negligence), -contract, or otherwise, unless required by applicable law (such as deliberate -and grossly negligent acts) or agreed to in writing, shall any Contributor be -liable to You for damages, including any direct, indirect, special, incidental, -or consequential damages of any character arising as a result of this License or -out of the use or inability to use the Work (including but not limited to -damages for loss of goodwill, work stoppage, computer failure or malfunction, or -any and all other commercial damages or losses), even if such Contributor has -been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. - -While redistributing the Work or Derivative Works thereof, You may choose to -offer, and charge a fee for, acceptance of support, warranty, indemnity, or -other liability obligations and/or rights consistent with this License. However, -in accepting such obligations, You may act only on Your own behalf and on Your -sole responsibility, not on behalf of any other Contributor, and only if You -agree to indemnify, defend, and hold each Contributor harmless for any liability -incurred by, or claims asserted against, such Contributor by reason of your -accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work - -To apply the Apache License to your work, attach the following boilerplate -notice, with the fields enclosed by brackets "{}" replaced with your own -identifying information. (Don't include the brackets!) The text should be -enclosed in the appropriate comment syntax for the file format. We also -recommend that a file or class name and description of purpose be included on -the same "printed page" as the copyright notice for easier identification within -third-party archives. - - Copyright 2019-2020 Zheng Jie - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file diff --git a/README.en.md b/README.en.md deleted file mode 100644 index 23dc80d7..00000000 --- a/README.en.md +++ /dev/null @@ -1,36 +0,0 @@ -# cashierAdmin - -#### Description -{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**} - -#### Software Architecture -Software architecture description - -#### Installation - -1. xxxx -2. xxxx -3. xxxx - -#### Instructions - -1. xxxx -2. xxxx -3. xxxx - -#### Contribution - -1. Fork the repository -2. Create Feat_xxx branch -3. Commit your code -4. Create Pull Request - - -#### Gitee Feature - -1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md -2. Gitee blog [blog.gitee.com](https://blog.gitee.com) -3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) -4. The most valuable open source project [GVP](https://gitee.com/gvp) -5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) -6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/eladmin-common/src/main/java/cn/ysk/cashier/utils/JSONUtil.java b/eladmin-common/src/main/java/cn/ysk/cashier/utils/JSONUtil.java index 23a32691..0e75d57a 100644 --- a/eladmin-common/src/main/java/cn/ysk/cashier/utils/JSONUtil.java +++ b/eladmin-common/src/main/java/cn/ysk/cashier/utils/JSONUtil.java @@ -88,6 +88,18 @@ public class JSONUtil { } } + + public static List parseJSONStrTList(String jsonStr, Class clazz) { + ObjectMapper objectMapper = new ObjectMapper(); + try { + // 将JSON字符串转换为List + return objectMapper.readValue(jsonStr, objectMapper.getTypeFactory().constructCollectionType(List.class, clazz)); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + /** * @param list 某集合 * @param clazz 要转成的实体 diff --git a/eladmin-generator/pom.xml b/eladmin-generator/pom.xml deleted file mode 100644 index 9a3b4636..00000000 --- a/eladmin-generator/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - eladmin - cn.ysk.cashier - 2.6 - - 4.0.0 - - eladmin-generator - 代码生成模块 - - - 1.10 - - - - - cn.ysk.cashier - eladmin-common - 2.6 - - - - - org.springframework.boot - spring-boot-starter-freemarker - - - - - commons-configuration - commons-configuration - ${configuration.version} - - - \ No newline at end of file diff --git a/eladmin-generator/src/main/java/cn/ysk/cashier/domain/ColumnInfo.java b/eladmin-generator/src/main/java/cn/ysk/cashier/domain/ColumnInfo.java deleted file mode 100644 index 26e06feb..00000000 --- a/eladmin-generator/src/main/java/cn/ysk/cashier/domain/ColumnInfo.java +++ /dev/null @@ -1,83 +0,0 @@ - -package cn.ysk.cashier.domain; - -import io.swagger.annotations.ApiModelProperty; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import cn.ysk.cashier.utils.GenUtil; -import javax.persistence.*; -import java.io.Serializable; - -/** - * 列的数据信息 - * @author Zheng Jie - * @date 2019-01-02 - */ -@Getter -@Setter -@Entity -@NoArgsConstructor -@Table(name = "code_column_config") -public class ColumnInfo implements Serializable { - - @Id - @Column(name = "column_id") - @ApiModelProperty(value = "ID", hidden = true) - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @ApiModelProperty(value = "表名") - private String tableName; - - @ApiModelProperty(value = "数据库字段名称") - private String columnName; - - @ApiModelProperty(value = "数据库字段类型") - private String columnType; - - @ApiModelProperty(value = "数据库字段键类型") - private String keyType; - - @ApiModelProperty(value = "字段额外的参数") - private String extra; - - @ApiModelProperty(value = "数据库字段描述") - private String remark; - - @ApiModelProperty(value = "是否必填") - private Boolean notNull; - - @ApiModelProperty(value = "是否在列表显示") - private Boolean listShow; - - @ApiModelProperty(value = "是否表单显示") - private Boolean formShow; - - @ApiModelProperty(value = "表单类型") - private String formType; - - @ApiModelProperty(value = "查询 1:模糊 2:精确") - private String queryType; - - @ApiModelProperty(value = "字典名称") - private String dictName; - - @ApiModelProperty(value = "日期注解") - private String dateAnnotation; - - public ColumnInfo(String tableName, String columnName, Boolean notNull, String columnType, String remark, String keyType, String extra) { - this.tableName = tableName; - this.columnName = columnName; - this.columnType = columnType; - this.keyType = keyType; - this.extra = extra; - this.notNull = notNull; - if(GenUtil.PK.equalsIgnoreCase(keyType) && GenUtil.EXTRA.equalsIgnoreCase(extra)){ - this.notNull = false; - } - this.remark = remark; - this.listShow = true; - this.formShow = true; - } -} diff --git a/eladmin-generator/src/main/java/cn/ysk/cashier/domain/GenConfig.java b/eladmin-generator/src/main/java/cn/ysk/cashier/domain/GenConfig.java deleted file mode 100644 index e8188454..00000000 --- a/eladmin-generator/src/main/java/cn/ysk/cashier/domain/GenConfig.java +++ /dev/null @@ -1,64 +0,0 @@ - -package cn.ysk.cashier.domain; - -import io.swagger.annotations.ApiModelProperty; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import javax.persistence.*; -import javax.validation.constraints.NotBlank; -import java.io.Serializable; - -/** - * 代码生成配置 - * @author Zheng Jie - * @date 2019-01-03 - */ -@Getter -@Setter -@Entity -@NoArgsConstructor -@Table(name = "code_gen_config") -public class GenConfig implements Serializable { - - public GenConfig(String tableName) { - this.tableName = tableName; - } - - @Id - @Column(name = "config_id") - @ApiModelProperty(value = "ID", hidden = true) - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @NotBlank - @ApiModelProperty(value = "表名") - private String tableName; - - @ApiModelProperty(value = "接口名称") - private String apiAlias; - - @NotBlank - @ApiModelProperty(value = "包路径") - private String pack; - - @NotBlank - @ApiModelProperty(value = "模块名") - private String moduleName; - - @NotBlank - @ApiModelProperty(value = "前端文件路径") - private String path; - - @ApiModelProperty(value = "前端文件路径") - private String apiPath; - - @ApiModelProperty(value = "作者") - private String author; - - @ApiModelProperty(value = "表前缀") - private String prefix; - - @ApiModelProperty(value = "是否覆盖") - private Boolean cover = false; -} diff --git a/eladmin-generator/src/main/java/cn/ysk/cashier/domain/vo/TableInfo.java b/eladmin-generator/src/main/java/cn/ysk/cashier/domain/vo/TableInfo.java deleted file mode 100644 index 1144ff4c..00000000 --- a/eladmin-generator/src/main/java/cn/ysk/cashier/domain/vo/TableInfo.java +++ /dev/null @@ -1,34 +0,0 @@ - -package cn.ysk.cashier.domain.vo; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * 表的数据信息 - * @author Zheng Jie - * @date 2019-01-02 - */ -@Data -@AllArgsConstructor -@NoArgsConstructor -public class TableInfo { - - /** 表名称 */ - private Object tableName; - - /** 创建日期 */ - private Object createTime; - - /** 数据库引擎 */ - private Object engine; - - /** 编码集 */ - private Object coding; - - /** 备注 */ - private Object remark; - - -} diff --git a/eladmin-generator/src/main/java/cn/ysk/cashier/repository/ColumnInfoRepository.java b/eladmin-generator/src/main/java/cn/ysk/cashier/repository/ColumnInfoRepository.java deleted file mode 100644 index faa0e05c..00000000 --- a/eladmin-generator/src/main/java/cn/ysk/cashier/repository/ColumnInfoRepository.java +++ /dev/null @@ -1,20 +0,0 @@ - -package cn.ysk.cashier.repository; - -import cn.ysk.cashier.domain.ColumnInfo; -import org.springframework.data.jpa.repository.JpaRepository; -import java.util.List; - -/** - * @author Zheng Jie - * @date 2019-01-14 - */ -public interface ColumnInfoRepository extends JpaRepository { - - /** - * 查询表信息 - * @param tableName 表格名 - * @return 表信息 - */ - List findByTableNameOrderByIdAsc(String tableName); -} diff --git a/eladmin-generator/src/main/java/cn/ysk/cashier/repository/GenConfigRepository.java b/eladmin-generator/src/main/java/cn/ysk/cashier/repository/GenConfigRepository.java deleted file mode 100644 index e84a5ba6..00000000 --- a/eladmin-generator/src/main/java/cn/ysk/cashier/repository/GenConfigRepository.java +++ /dev/null @@ -1,19 +0,0 @@ - -package cn.ysk.cashier.repository; - -import cn.ysk.cashier.domain.GenConfig; -import org.springframework.data.jpa.repository.JpaRepository; - -/** - * @author Zheng Jie - * @date 2019-01-14 - */ -public interface GenConfigRepository extends JpaRepository { - - /** - * 查询表配置 - * @param tableName 表名 - * @return / - */ - GenConfig findByTableName(String tableName); -} diff --git a/eladmin-generator/src/main/java/cn/ysk/cashier/rest/GenConfigController.java b/eladmin-generator/src/main/java/cn/ysk/cashier/rest/GenConfigController.java deleted file mode 100644 index 4655820c..00000000 --- a/eladmin-generator/src/main/java/cn/ysk/cashier/rest/GenConfigController.java +++ /dev/null @@ -1,37 +0,0 @@ - -package cn.ysk.cashier.rest; - -import cn.ysk.cashier.domain.GenConfig; -import cn.ysk.cashier.service.GenConfigService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -/** - * @author Zheng Jie - * @date 2019-01-14 - */ -@RestController -@RequiredArgsConstructor -@RequestMapping("/api/genConfig") -@Api(tags = "系统:代码生成器配置管理") -public class GenConfigController { - - private final GenConfigService genConfigService; - - @ApiOperation("查询") - @GetMapping(value = "/{tableName}") - public ResponseEntity queryGenConfig(@PathVariable String tableName){ - return new ResponseEntity<>(genConfigService.find(tableName), HttpStatus.OK); - } - - @PutMapping - @ApiOperation("修改") - public ResponseEntity updateGenConfig(@Validated @RequestBody GenConfig genConfig){ - return new ResponseEntity<>(genConfigService.update(genConfig.getTableName(), genConfig),HttpStatus.OK); - } -} diff --git a/eladmin-generator/src/main/java/cn/ysk/cashier/rest/GeneratorController.java b/eladmin-generator/src/main/java/cn/ysk/cashier/rest/GeneratorController.java deleted file mode 100644 index 02becca5..00000000 --- a/eladmin-generator/src/main/java/cn/ysk/cashier/rest/GeneratorController.java +++ /dev/null @@ -1,93 +0,0 @@ - -package cn.ysk.cashier.rest; - -import cn.ysk.cashier.domain.ColumnInfo; -import cn.ysk.cashier.exception.BadRequestException; -import cn.ysk.cashier.service.GenConfigService; -import cn.ysk.cashier.service.GeneratorService; -import cn.ysk.cashier.utils.PageUtil; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.RequiredArgsConstructor; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.List; - -/** - * @author Zheng Jie - * @date 2019-01-02 - */ -@RestController -@RequiredArgsConstructor -@RequestMapping("/api/generator") -@Api(tags = "系统:代码生成管理") -public class GeneratorController { - - private final GeneratorService generatorService; - private final GenConfigService genConfigService; - - @Value("${generator.enabled}") - private Boolean generatorEnabled; - - @ApiOperation("查询数据库数据") - @GetMapping(value = "/tables/all") - public ResponseEntity queryAllTables(){ - return new ResponseEntity<>(generatorService.getTables(), HttpStatus.OK); - } - - @ApiOperation("查询数据库数据") - @GetMapping(value = "/tables") - public ResponseEntity queryTables(@RequestParam(defaultValue = "") String name, - @RequestParam(defaultValue = "0")Integer page, - @RequestParam(defaultValue = "10")Integer size){ - int[] startEnd = PageUtil.transToStartEnd(page, size); - return new ResponseEntity<>(generatorService.getTables(name,startEnd), HttpStatus.OK); - } - - @ApiOperation("查询字段数据") - @GetMapping(value = "/columns") - public ResponseEntity queryColumns(@RequestParam String tableName){ - List columnInfos = generatorService.getColumns(tableName); - return new ResponseEntity<>(PageUtil.toPage(columnInfos,columnInfos.size()), HttpStatus.OK); - } - - @ApiOperation("保存字段数据") - @PutMapping - public ResponseEntity saveColumn(@RequestBody List columnInfos){ - generatorService.save(columnInfos); - return new ResponseEntity<>(HttpStatus.OK); - } - - @ApiOperation("同步字段数据") - @PostMapping(value = "sync") - public ResponseEntity syncColumn(@RequestBody List tables){ - for (String table : tables) { - generatorService.sync(generatorService.getColumns(table), generatorService.query(table)); - } - return new ResponseEntity<>(HttpStatus.OK); - } - - @ApiOperation("生成代码") - @PostMapping(value = "/{tableName}/{type}") - public ResponseEntity generatorCode(@PathVariable String tableName, @PathVariable Integer type, HttpServletRequest request, HttpServletResponse response){ - if(!generatorEnabled && type == 0){ - throw new BadRequestException("此环境不允许生成代码,请选择预览或者下载查看!"); - } - switch (type){ - // 生成代码 - case 0: generatorService.generator(genConfigService.find(tableName), generatorService.getColumns(tableName)); - break; - // 预览 - case 1: return generatorService.preview(genConfigService.find(tableName), generatorService.getColumns(tableName)); - // 打包 - case 2: generatorService.download(genConfigService.find(tableName), generatorService.getColumns(tableName), request, response); - break; - default: throw new BadRequestException("没有这个选项"); - } - return new ResponseEntity<>(HttpStatus.OK); - } -} diff --git a/eladmin-generator/src/main/java/cn/ysk/cashier/service/GenConfigService.java b/eladmin-generator/src/main/java/cn/ysk/cashier/service/GenConfigService.java deleted file mode 100644 index 131c78af..00000000 --- a/eladmin-generator/src/main/java/cn/ysk/cashier/service/GenConfigService.java +++ /dev/null @@ -1,26 +0,0 @@ - -package cn.ysk.cashier.service; - -import cn.ysk.cashier.domain.GenConfig; - -/** - * @author Zheng Jie - * @date 2019-01-14 - */ -public interface GenConfigService { - - /** - * 查询表配置 - * @param tableName 表名 - * @return 表配置 - */ - GenConfig find(String tableName); - - /** - * 更新表配置 - * @param tableName 表名 - * @param genConfig 表配置 - * @return 表配置 - */ - GenConfig update(String tableName, GenConfig genConfig); -} diff --git a/eladmin-generator/src/main/java/cn/ysk/cashier/service/GeneratorService.java b/eladmin-generator/src/main/java/cn/ysk/cashier/service/GeneratorService.java deleted file mode 100644 index d582c0da..00000000 --- a/eladmin-generator/src/main/java/cn/ysk/cashier/service/GeneratorService.java +++ /dev/null @@ -1,82 +0,0 @@ - -package cn.ysk.cashier.service; - -import cn.ysk.cashier.domain.GenConfig; -import cn.ysk.cashier.domain.ColumnInfo; -import org.springframework.http.ResponseEntity; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.List; - -/** - * @author Zheng Jie - * @date 2019-01-02 - */ -public interface GeneratorService { - - /** - * 查询数据库元数据 - * @param name 表名 - * @param startEnd 分页参数 - * @return / - */ - Object getTables(String name, int[] startEnd); - - /** - * 得到数据表的元数据 - * @param name 表名 - * @return / - */ - List getColumns(String name); - - /** - * 同步表数据 - * @param columnInfos / - * @param columnInfoList / - */ - void sync(List columnInfos, List columnInfoList); - - /** - * 保持数据 - * @param columnInfos / - */ - void save(List columnInfos); - - /** - * 获取所有table - * @return / - */ - Object getTables(); - - /** - * 代码生成 - * @param genConfig 配置信息 - * @param columns 字段信息 - */ - void generator(GenConfig genConfig, List columns); - - /** - * 预览 - * @param genConfig 配置信息 - * @param columns 字段信息 - * @return / - */ - ResponseEntity preview(GenConfig genConfig, List columns); - - /** - * 打包下载 - * @param genConfig 配置信息 - * @param columns 字段信息 - * @param request / - * @param response / - */ - void download(GenConfig genConfig, List columns, HttpServletRequest request, HttpServletResponse response); - - /** - * 查询数据库的表字段数据数据 - * @param table / - * @return / - */ - List query(String table); -} diff --git a/eladmin-generator/src/main/java/cn/ysk/cashier/service/impl/GenConfigServiceImpl.java b/eladmin-generator/src/main/java/cn/ysk/cashier/service/impl/GenConfigServiceImpl.java deleted file mode 100644 index 39be53f5..00000000 --- a/eladmin-generator/src/main/java/cn/ysk/cashier/service/impl/GenConfigServiceImpl.java +++ /dev/null @@ -1,52 +0,0 @@ - -package cn.ysk.cashier.service.impl; - -import lombok.RequiredArgsConstructor; -import cn.ysk.cashier.domain.GenConfig; -import cn.ysk.cashier.repository.GenConfigRepository; -import cn.ysk.cashier.service.GenConfigService; -import org.springframework.stereotype.Service; -import java.io.File; - -/** - * @author Zheng Jie - * @date 2019-01-14 - */ -@Service -@RequiredArgsConstructor -public class GenConfigServiceImpl implements GenConfigService { - - private final GenConfigRepository genConfigRepository; - - @Override - public GenConfig find(String tableName) { - GenConfig genConfig = genConfigRepository.findByTableName(tableName); - if(genConfig == null){ - return new GenConfig(tableName); - } - return genConfig; - } - - @Override - public GenConfig update(String tableName, GenConfig genConfig) { - String separator = File.separator; - String[] paths; - String symbol = "\\"; - if (symbol.equals(separator)) { - paths = genConfig.getPath().split("\\\\"); - } else { - paths = genConfig.getPath().split(File.separator); - } - StringBuilder api = new StringBuilder(); - for (String path : paths) { - api.append(path); - api.append(separator); - if ("src".equals(path)) { - api.append("api"); - break; - } - } - genConfig.setApiPath(api.toString()); - return genConfigRepository.save(genConfig); - } -} diff --git a/eladmin-generator/src/main/java/cn/ysk/cashier/service/impl/GeneratorServiceImpl.java b/eladmin-generator/src/main/java/cn/ysk/cashier/service/impl/GeneratorServiceImpl.java deleted file mode 100644 index 0547c4d7..00000000 --- a/eladmin-generator/src/main/java/cn/ysk/cashier/service/impl/GeneratorServiceImpl.java +++ /dev/null @@ -1,192 +0,0 @@ - -package cn.ysk.cashier.service.impl; - -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.ZipUtil; -import lombok.RequiredArgsConstructor; -import cn.ysk.cashier.domain.GenConfig; -import cn.ysk.cashier.domain.ColumnInfo; -import cn.ysk.cashier.domain.vo.TableInfo; -import cn.ysk.cashier.exception.BadRequestException; -import cn.ysk.cashier.repository.ColumnInfoRepository; -import cn.ysk.cashier.service.GeneratorService; -import cn.ysk.cashier.utils.FileUtil; -import cn.ysk.cashier.utils.GenUtil; -import cn.ysk.cashier.utils.PageUtil; -import cn.ysk.cashier.utils.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Service; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.persistence.Query; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -/** - * @author Zheng Jie - * @date 2019-01-02 - */ -@Service -@RequiredArgsConstructor -public class GeneratorServiceImpl implements GeneratorService { - private static final Logger log = LoggerFactory.getLogger(GeneratorServiceImpl.class); - @PersistenceContext - private EntityManager em; - - private final ColumnInfoRepository columnInfoRepository; - - private final String CONFIG_MESSAGE = "请先配置生成器"; - @Override - public Object getTables() { - // 使用预编译防止sql注入 - String sql = "select table_name ,create_time , engine, table_collation, table_comment from information_schema.tables " + - "where table_schema = (select database()) " + - "order by create_time desc"; - Query query = em.createNativeQuery(sql); - return query.getResultList(); - } - - @Override - public Object getTables(String name, int[] startEnd) { - // 使用预编译防止sql注入 - String sql = "select table_name ,create_time , engine, table_collation, table_comment from information_schema.tables " + - "where table_schema = (select database()) " + - "and table_name like :table order by create_time desc"; - Query query = em.createNativeQuery(sql); - query.setFirstResult(startEnd[0]); - query.setMaxResults(startEnd[1] - startEnd[0]); - query.setParameter("table", StringUtils.isNotBlank(name) ? ("%" + name + "%") : "%%"); - List result = query.getResultList(); - List tableInfos = new ArrayList<>(); - for (Object obj : result) { - Object[] arr = (Object[]) obj; - tableInfos.add(new TableInfo(arr[0], arr[1], arr[2], arr[3], ObjectUtil.isNotEmpty(arr[4]) ? arr[4] : "-")); - } - String countSql = "select count(1) from information_schema.tables " + - "where table_schema = (select database()) and table_name like :table"; - Query queryCount = em.createNativeQuery(countSql); - queryCount.setParameter("table", StringUtils.isNotBlank(name) ? ("%" + name + "%") : "%%"); - Object totalElements = queryCount.getSingleResult(); - return PageUtil.toPage(tableInfos, totalElements); - } - - @Override - public List getColumns(String tableName) { - List columnInfos = columnInfoRepository.findByTableNameOrderByIdAsc(tableName); - if (CollectionUtil.isNotEmpty(columnInfos)) { - return columnInfos; - } else { - columnInfos = query(tableName); - return columnInfoRepository.saveAll(columnInfos); - } - } - - @Override - public List query(String tableName) { - // 使用预编译防止sql注入 - String sql = "select column_name, is_nullable, data_type, column_comment, column_key, extra from information_schema.columns " + - "where table_name = ? and table_schema = (select database()) order by ordinal_position"; - Query query = em.createNativeQuery(sql); - query.setParameter(1, tableName); - List result = query.getResultList(); - List columnInfos = new ArrayList<>(); - for (Object obj : result) { - Object[] arr = (Object[]) obj; - columnInfos.add( - new ColumnInfo( - tableName, - arr[0].toString(), - "NO".equals(arr[1]), - arr[2].toString(), - ObjectUtil.isNotNull(arr[3]) ? arr[3].toString() : null, - ObjectUtil.isNotNull(arr[4]) ? arr[4].toString() : null, - ObjectUtil.isNotNull(arr[5]) ? arr[5].toString() : null) - ); - } - return columnInfos; - } - - @Override - public void sync(List columnInfos, List columnInfoList) { - // 第一种情况,数据库类字段改变或者新增字段 - for (ColumnInfo columnInfo : columnInfoList) { - // 根据字段名称查找 - List columns = columnInfos.stream().filter(c -> c.getColumnName().equals(columnInfo.getColumnName())).collect(Collectors.toList()); - // 如果能找到,就修改部分可能被字段 - if (CollectionUtil.isNotEmpty(columns)) { - ColumnInfo column = columns.get(0); - column.setColumnType(columnInfo.getColumnType()); - column.setExtra(columnInfo.getExtra()); - column.setKeyType(columnInfo.getKeyType()); - if (StringUtils.isBlank(column.getRemark())) { - column.setRemark(columnInfo.getRemark()); - } - columnInfoRepository.save(column); - } else { - // 如果找不到,则保存新字段信息 - columnInfoRepository.save(columnInfo); - } - } - // 第二种情况,数据库字段删除了 - for (ColumnInfo columnInfo : columnInfos) { - // 根据字段名称查找 - List columns = columnInfoList.stream().filter(c -> c.getColumnName().equals(columnInfo.getColumnName())).collect(Collectors.toList()); - // 如果找不到,就代表字段被删除了,则需要删除该字段 - if (CollectionUtil.isEmpty(columns)) { - columnInfoRepository.delete(columnInfo); - } - } - } - - @Override - public void save(List columnInfos) { - columnInfoRepository.saveAll(columnInfos); - } - - @Override - public void generator(GenConfig genConfig, List columns) { - if (genConfig.getId() == null) { - throw new BadRequestException(CONFIG_MESSAGE); - } - try { - GenUtil.generatorCode(columns, genConfig); - } catch (IOException e) { - log.error(e.getMessage(), e); - throw new BadRequestException("生成失败,请手动处理已生成的文件"); - } - } - - @Override - public ResponseEntity preview(GenConfig genConfig, List columns) { - if (genConfig.getId() == null) { - throw new BadRequestException(CONFIG_MESSAGE); - } - List> genList = GenUtil.preview(columns, genConfig); - return new ResponseEntity<>(genList, HttpStatus.OK); - } - - @Override - public void download(GenConfig genConfig, List columns, HttpServletRequest request, HttpServletResponse response) { - if (genConfig.getId() == null) { - throw new BadRequestException(CONFIG_MESSAGE); - } - try { - File file = new File(GenUtil.download(columns, genConfig)); - String zipPath = file.getPath() + ".zip"; - ZipUtil.zip(file.getPath(), zipPath); - FileUtil.downloadFile(request, response, new File(zipPath), true); - } catch (IOException e) { - throw new BadRequestException("打包失败"); - } - } -} diff --git a/eladmin-generator/src/main/java/cn/ysk/cashier/utils/ColUtil.java b/eladmin-generator/src/main/java/cn/ysk/cashier/utils/ColUtil.java deleted file mode 100644 index 9683bdd7..00000000 --- a/eladmin-generator/src/main/java/cn/ysk/cashier/utils/ColUtil.java +++ /dev/null @@ -1,40 +0,0 @@ - -package cn.ysk.cashier.utils; - -import org.apache.commons.configuration.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * sql字段转java - * - * @author Zheng Jie - * @date 2019-01-03 - */ -public class ColUtil { - private static final Logger log = LoggerFactory.getLogger(ColUtil.class); - - /** - * 转换mysql数据类型为java数据类型 - * - * @param type 数据库字段类型 - * @return String - */ - static String cloToJava(String type) { - Configuration config = getConfig(); - assert config != null; - return config.getString(type, "unknowType"); - } - - /** - * 获取配置信息 - */ - public static PropertiesConfiguration getConfig() { - try { - return new PropertiesConfiguration("generator.properties"); - } catch (ConfigurationException e) { - log.error(e.getMessage(), e); - } - return null; - } -} diff --git a/eladmin-generator/src/main/java/cn/ysk/cashier/utils/GenUtil.java b/eladmin-generator/src/main/java/cn/ysk/cashier/utils/GenUtil.java deleted file mode 100644 index 703a1f89..00000000 --- a/eladmin-generator/src/main/java/cn/ysk/cashier/utils/GenUtil.java +++ /dev/null @@ -1,408 +0,0 @@ - -package cn.ysk.cashier.utils; - -import cn.hutool.core.util.StrUtil; -import cn.hutool.extra.template.*; -import cn.ysk.cashier.domain.ColumnInfo; -import cn.ysk.cashier.domain.GenConfig; -import lombok.extern.slf4j.Slf4j; -import org.springframework.util.ObjectUtils; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.Writer; -import java.time.LocalDate; -import java.util.*; - -import static cn.ysk.cashier.utils.FileUtil.SYS_TEM_DIR; - -/** - * 代码生成 - * - * @author Zheng Jie - * @date 2019-01-02 - */ -@Slf4j -@SuppressWarnings({"unchecked", "all"}) -public class GenUtil { - - private static final String TIMESTAMP = "Timestamp"; - - private static final String BIGDECIMAL = "BigDecimal"; - - public static final String PK = "PRI"; - - public static final String EXTRA = "auto_increment"; - - /** - * 获取后端代码模板名称 - * - * @return List - */ - private static List getAdminTemplateNames() { - List templateNames = new ArrayList<>(); - templateNames.add("Entity"); - templateNames.add("Dto"); - templateNames.add("Mapper"); - templateNames.add("Controller"); - templateNames.add("QueryCriteria"); - templateNames.add("Service"); - templateNames.add("ServiceImpl"); - templateNames.add("Repository"); - return templateNames; - } - - /** - * 获取前端代码模板名称 - * - * @return List - */ - private static List getFrontTemplateNames() { - List templateNames = new ArrayList<>(); - templateNames.add("index"); - templateNames.add("api"); - return templateNames; - } - - public static List> preview(List columns, GenConfig genConfig) { - Map genMap = getGenMap(columns, genConfig); - List> genList = new ArrayList<>(); - // 获取后端模版 - List templates = getAdminTemplateNames(); - TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig("template", TemplateConfig.ResourceMode.CLASSPATH)); - for (String templateName : templates) { - Map map = new HashMap<>(1); - Template template = engine.getTemplate("generator/admin/" + templateName + ".ftl"); - map.put("content", template.render(genMap)); - map.put("name", templateName); - genList.add(map); - } - // 获取前端模版 - templates = getFrontTemplateNames(); - for (String templateName : templates) { - Map map = new HashMap<>(1); - Template template = engine.getTemplate("generator/front/" + templateName + ".ftl"); - map.put(templateName, template.render(genMap)); - map.put("content", template.render(genMap)); - map.put("name", templateName); - genList.add(map); - } - return genList; - } - - public static String download(List columns, GenConfig genConfig) throws IOException { - // 拼接的路径:/tmpeladmin-gen-temp/,这个路径在Linux下需要root用户才有权限创建,非root用户会权限错误而失败,更改为: /tmp/eladmin-gen-temp/ - // String tempPath =SYS_TEM_DIR + "eladmin-gen-temp" + File.separator + genConfig.getTableName() + File.separator; - String tempPath = SYS_TEM_DIR + "eladmin-gen-temp" + File.separator + genConfig.getTableName() + File.separator; - Map genMap = getGenMap(columns, genConfig); - TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig("template", TemplateConfig.ResourceMode.CLASSPATH)); - // 生成后端代码 - List templates = getAdminTemplateNames(); - for (String templateName : templates) { - Template template = engine.getTemplate("generator/admin/" + templateName + ".ftl"); - String filePath = getAdminFilePath(templateName, genConfig, genMap.get("className").toString(), tempPath + "eladmin" + File.separator); - assert filePath != null; - File file = new File(filePath); - // 如果非覆盖生成 - if (!genConfig.getCover() && FileUtil.exist(file)) { - continue; - } - // 生成代码 - genFile(file, template, genMap); - } - // 生成前端代码 - templates = getFrontTemplateNames(); - for (String templateName : templates) { - Template template = engine.getTemplate("generator/front/" + templateName + ".ftl"); - String path = tempPath + "eladmin-web" + File.separator; - String apiPath = path + "src" + File.separator + "api" + File.separator; - String srcPath = path + "src" + File.separator + "views" + File.separator + genMap.get("changeClassName").toString() + File.separator; - String filePath = getFrontFilePath(templateName, apiPath, srcPath, genMap.get("changeClassName").toString()); - assert filePath != null; - File file = new File(filePath); - // 如果非覆盖生成 - if (!genConfig.getCover() && FileUtil.exist(file)) { - continue; - } - // 生成代码 - genFile(file, template, genMap); - } - return tempPath; - } - - public static void generatorCode(List columnInfos, GenConfig genConfig) throws IOException { - Map genMap = getGenMap(columnInfos, genConfig); - TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig("template", TemplateConfig.ResourceMode.CLASSPATH)); - // 生成后端代码 - List templates = getAdminTemplateNames(); - for (String templateName : templates) { - Template template = engine.getTemplate("generator/admin/" + templateName + ".ftl"); - String rootPath = System.getProperty("user.dir"); - String filePath = getAdminFilePath(templateName, genConfig, genMap.get("className").toString(), rootPath); - - assert filePath != null; - File file = new File(filePath); - - // 如果非覆盖生成 - if (!genConfig.getCover() && FileUtil.exist(file)) { - continue; - } - // 生成代码 - genFile(file, template, genMap); - } - - // 生成前端代码 - templates = getFrontTemplateNames(); - for (String templateName : templates) { - Template template = engine.getTemplate("generator/front/" + templateName + ".ftl"); - String filePath = getFrontFilePath(templateName, genConfig.getApiPath(), genConfig.getPath(), genMap.get("changeClassName").toString()); - - assert filePath != null; - File file = new File(filePath); - - // 如果非覆盖生成 - if (!genConfig.getCover() && FileUtil.exist(file)) { - continue; - } - // 生成代码 - genFile(file, template, genMap); - } - } - - // 获取模版数据 - private static Map getGenMap(List columnInfos, GenConfig genConfig) { - // 存储模版字段数据 - Map genMap = new HashMap<>(16); - // 接口别名 - genMap.put("apiAlias", genConfig.getApiAlias()); - // 包名称 - genMap.put("package", genConfig.getPack()); - // 模块名称 - genMap.put("moduleName", genConfig.getModuleName()); - // 作者 - genMap.put("author", genConfig.getAuthor()); - // 创建日期 - genMap.put("date", LocalDate.now().toString()); - // 表名 - genMap.put("tableName", genConfig.getTableName()); - // 大写开头的类名 - String className = StringUtils.toCapitalizeCamelCase(genConfig.getTableName()); - // 小写开头的类名 - String changeClassName = StringUtils.toCamelCase(genConfig.getTableName()); - // 判断是否去除表前缀 - if (StringUtils.isNotEmpty(genConfig.getPrefix())) { - className = StringUtils.toCapitalizeCamelCase(StrUtil.removePrefix(genConfig.getTableName(), genConfig.getPrefix())); - changeClassName = StringUtils.toCamelCase(StrUtil.removePrefix(genConfig.getTableName(), genConfig.getPrefix())); - changeClassName = StringUtils.uncapitalize(changeClassName); - } - // 保存类名 - genMap.put("className", className); - // 保存小写开头的类名 - genMap.put("changeClassName", changeClassName); - // 存在 Timestamp 字段 - genMap.put("hasTimestamp", false); - // 查询类中存在 Timestamp 字段 - genMap.put("queryHasTimestamp", false); - // 存在 BigDecimal 字段 - genMap.put("hasBigDecimal", false); - // 查询类中存在 BigDecimal 字段 - genMap.put("queryHasBigDecimal", false); - // 是否需要创建查询 - genMap.put("hasQuery", false); - // 自增主键 - genMap.put("auto", false); - // 存在字典 - genMap.put("hasDict", false); - // 存在日期注解 - genMap.put("hasDateAnnotation", false); - // 保存字段信息 - List> columns = new ArrayList<>(); - // 保存查询字段的信息 - List> queryColumns = new ArrayList<>(); - // 存储字典信息 - List dicts = new ArrayList<>(); - // 存储 between 信息 - List> betweens = new ArrayList<>(); - // 存储不为空的字段信息 - List> isNotNullColumns = new ArrayList<>(); - - for (ColumnInfo column : columnInfos) { - Map listMap = new HashMap<>(16); - // 字段描述 - listMap.put("remark", column.getRemark()); - // 字段类型 - listMap.put("columnKey", column.getKeyType()); - // 主键类型 - String colType = ColUtil.cloToJava(column.getColumnType()); - // 小写开头的字段名 - String changeColumnName = StringUtils.toCamelCase(column.getColumnName()); - // 大写开头的字段名 - String capitalColumnName = StringUtils.toCapitalizeCamelCase(column.getColumnName()); - if (PK.equals(column.getKeyType())) { - // 存储主键类型 - genMap.put("pkColumnType", colType); - // 存储小写开头的字段名 - genMap.put("pkChangeColName", changeColumnName); - // 存储大写开头的字段名 - genMap.put("pkCapitalColName", capitalColumnName); - } - // 是否存在 Timestamp 类型的字段 - if (TIMESTAMP.equals(colType)) { - genMap.put("hasTimestamp", true); - } - // 是否存在 BigDecimal 类型的字段 - if (BIGDECIMAL.equals(colType)) { - genMap.put("hasBigDecimal", true); - } - // 主键是否自增 - if (EXTRA.equals(column.getExtra())) { - genMap.put("auto", true); - } - // 主键存在字典 - if (StringUtils.isNotBlank(column.getDictName())) { - genMap.put("hasDict", true); - if(!dicts.contains(column.getDictName())) - dicts.add(column.getDictName()); - } - - // 存储字段类型 - listMap.put("columnType", colType); - // 存储字原始段名称 - listMap.put("columnName", column.getColumnName()); - // 不为空 - listMap.put("istNotNull", column.getNotNull()); - // 字段列表显示 - listMap.put("columnShow", column.getListShow()); - // 表单显示 - listMap.put("formShow", column.getFormShow()); - // 表单组件类型 - listMap.put("formType", StringUtils.isNotBlank(column.getFormType()) ? column.getFormType() : "Input"); - // 小写开头的字段名称 - listMap.put("changeColumnName", changeColumnName); - //大写开头的字段名称 - listMap.put("capitalColumnName", capitalColumnName); - // 字典名称 - listMap.put("dictName", column.getDictName()); - // 日期注解 - listMap.put("dateAnnotation", column.getDateAnnotation()); - if (StringUtils.isNotBlank(column.getDateAnnotation())) { - genMap.put("hasDateAnnotation", true); - } - // 添加非空字段信息 - if (column.getNotNull()) { - isNotNullColumns.add(listMap); - } - // 判断是否有查询,如有则把查询的字段set进columnQuery - if (!StringUtils.isBlank(column.getQueryType())) { - // 查询类型 - listMap.put("queryType", column.getQueryType()); - // 是否存在查询 - genMap.put("hasQuery", true); - if (TIMESTAMP.equals(colType)) { - // 查询中存储 Timestamp 类型 - genMap.put("queryHasTimestamp", true); - } - if (BIGDECIMAL.equals(colType)) { - // 查询中存储 BigDecimal 类型 - genMap.put("queryHasBigDecimal", true); - } - if ("between".equalsIgnoreCase(column.getQueryType())) { - betweens.add(listMap); - } else { - // 添加到查询列表中 - queryColumns.add(listMap); - } - } - // 添加到字段列表中 - columns.add(listMap); - } - // 保存字段列表 - genMap.put("columns", columns); - // 保存查询列表 - genMap.put("queryColumns", queryColumns); - // 保存字段列表 - genMap.put("dicts", dicts); - // 保存查询列表 - genMap.put("betweens", betweens); - // 保存非空字段信息 - genMap.put("isNotNullColumns", isNotNullColumns); - return genMap; - } - - /** - * 定义后端文件路径以及名称 - */ - private static String getAdminFilePath(String templateName, GenConfig genConfig, String className, String rootPath) { - String projectPath = rootPath + File.separator + genConfig.getModuleName(); - String packagePath = projectPath + File.separator + "src" + File.separator + "main" + File.separator + "java" + File.separator; - if (!ObjectUtils.isEmpty(genConfig.getPack())) { - packagePath += genConfig.getPack().replace(".", File.separator) + File.separator; - } - - if ("Entity".equals(templateName)) { - return packagePath + "domain" + File.separator + className + ".java"; - } - - if ("Controller".equals(templateName)) { - return packagePath + "rest" + File.separator + className + "Controller.java"; - } - - if ("Service".equals(templateName)) { - return packagePath + "service" + File.separator + className + "Service.java"; - } - - if ("ServiceImpl".equals(templateName)) { - return packagePath + "service" + File.separator + "impl" + File.separator + className + "ServiceImpl.java"; - } - - if ("Dto".equals(templateName)) { - return packagePath + "service" + File.separator + "dto" + File.separator + className + "Dto.java"; - } - - if ("QueryCriteria".equals(templateName)) { - return packagePath + "service" + File.separator + "dto" + File.separator + className + "QueryCriteria.java"; - } - - if ("Mapper".equals(templateName)) { - return packagePath + "service" + File.separator + "mapstruct" + File.separator + className + "Mapper.java"; - } - - if ("Repository".equals(templateName)) { - return packagePath + "repository" + File.separator + className + "Repository.java"; - } - - return null; - } - - /** - * 定义前端文件路径以及名称 - */ - private static String getFrontFilePath(String templateName, String apiPath, String path, String apiName) { - - if ("api".equals(templateName)) { - return apiPath + File.separator + apiName + ".js"; - } - - if ("index".equals(templateName)) { - return path + File.separator + "index.vue"; - } - - return null; - } - - private static void genFile(File file, Template template, Map map) throws IOException { - // 生成目标文件 - Writer writer = null; - try { - FileUtil.touch(file); - writer = new FileWriter(file); - template.render(map, writer); - } catch (TemplateException | IOException e) { - throw new RuntimeException(e); - } finally { - assert writer != null; - writer.close(); - } - } -} diff --git a/eladmin-system/pom.xml b/eladmin-system/pom.xml index 33891504..cb0749ce 100644 --- a/eladmin-system/pom.xml +++ b/eladmin-system/pom.xml @@ -106,11 +106,13 @@ 6.1.4 + @@ -120,12 +122,12 @@ com.baomidou mybatis-plus-generator - 3.5.3.1 + 3.5.7 com.baomidou mybatis-plus-boot-starter - 3.5.3.1 + 3.5.7 @@ -165,9 +167,15 @@ - pro + pre - pro + pre + + + + prod + + prod diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/TableConstant.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/TableConstant.java index f9ea2835..1244125a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/TableConstant.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/TableConstant.java @@ -2,26 +2,43 @@ package cn.ysk.cashier.cons; import lombok.Getter; +import java.util.Objects; + public interface TableConstant { String CART_SEAT_ID = "-999"; - class OrderInfo { + class ShopTable { + @Getter + public enum State { + IDLE("idle"), CLOSED("closed"), PAYING("paying"), PENDING("pending"), USING("using"), CLEANING("cleaning"); + private final String value; + + State(String value) { + this.value = value; + } + } + } + + class CashierCart { + public static final String ID = "-999"; + @Getter public enum Status { REFUNDING("refunding"), REFUND("refund"), CLOSED("closed"), CREATE("create"), - UNPAID("unpaid"), PAYING("paying"), RETURN("return"); + UNPAID("unpaid"), PAYING("paying"), RETURN("return"), CANCEL("cancel"); private final String value; - Status(String value) { this.value = value; } + public boolean equalsVals(String value) { + return this.value.equals(value); + } } @Getter public enum UseType { TAKEOUT("takeout"), - NONE_TABLE("dine-in"), DINE_IN_AFTER("dine-in-after"), DINE_IN_BEFORE("dine-in-before"); private final String value; @@ -35,4 +52,137 @@ public interface TableConstant { } } } + + class OrderInfo { + @Getter + public enum Status { + REFUNDING("refunding"), REFUND("refund"), CLOSED("closed"), CREATE("create"), + UNPAID("unpaid"), PAYING("paying"), RETURN("return"), FINAL("final"); + private final String value; + + Status(String value) { + this.value = value; + } + + public boolean equalsVals(String value) { + return this.value.equals(value); + } + + } + + @Getter + public enum UseType { + TAKEOUT("takeout"), + DINE_IN_AFTER("dine-in-after"), + DINE_IN_BEFORE("dine-in-before"), NONE_TABLE("dine-in"); + private final String value; + + UseType(String value) { + this.value = value; + } + + public boolean equalsVals(String value) { + return this.value.equals(value); + } + } + } + + class FreeDineRecord { + @Getter + public enum State { + WAIT_PAY(0), + SUCCESS_PAY(1), + FAIL_PAY(2); + private final Integer value; + + State(Integer value) { + this.value = value; + } + } + + @Getter + public enum UseType { + TAKEOUT("takeout"), + DINE_IN_AFTER("dine-in-after"), + DINE_IN_BEFORE("dine-in-before"); + private final String value; + + UseType(String value) { + this.value = value; + } + + public boolean equalsVals(String value) { + return this.value.equals(value); + } + } + } + + class ShopInfo { + @Getter + public enum EatModel { + TAKEOUT("takeout"), + DINE_IN("dine-in"); + private final String value; + + EatModel(String value) { + this.value = value; + } + + public boolean equalsVals(String value) { + return this.value.equals(value); + } + } + } + + class MemberIn { + @Getter + public enum Type { + NORMAL(0), + FREE_DINE(1); + private final Integer value; + + Type(Integer value) { + this.value = value; + } + + public boolean equalsVals(Integer value) { + return Objects.equals(this.value, value); + } + } + } + + class ActivateOutRecord { + @Getter + public enum Type { + // 满减 + FULL_REDUCTION(1), + // 商品 + PRODUCT(2); + private final Integer value; + + Type(Integer value) { + this.value = value; + } + + public boolean equalsVals(Integer value) { + return Objects.equals(this.value, value); + } + } + @Getter + public enum Status { + CREATE("create"), + CANCEL("cancel"), + // 商品 + CLOSED("closed"); + private final String value; + + Status(String value) { + this.value = value; + } + + public boolean equalsVals(String value) { + return this.value.equals(value); + } + } + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/TbConsInfo.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/TbConsInfo.java index e2231b25..bf2072af 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/TbConsInfo.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/TbConsInfo.java @@ -61,6 +61,10 @@ public class TbConsInfo implements Serializable { @ApiModelProperty(value = "单位换算") private BigDecimal conUnitTwoConvert; + @Column(name = "`default_unit`") + @ApiModelProperty(value = "默认入库单位") + private String defaultUnit; + @Column(name = "`laster_in_stock`") @ApiModelProperty(value = "最近一次入库量") private BigDecimal lasterInStock; @@ -102,9 +106,6 @@ public class TbConsInfo implements Serializable { @ApiModelProperty(value = "是否检测库存") private String isCheck; - @Transient - private List> product; - public void copy(TbConsInfo source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/TbConsInfoV2.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/TbConsInfoV2.java index 111aeb04..7874d061 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/TbConsInfoV2.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/TbConsInfoV2.java @@ -63,6 +63,10 @@ public class TbConsInfoV2 implements Serializable { @ApiModelProperty(value = "单位换算") private BigDecimal conUnitTwoConvert; + @Column(name = "`default_unit`") + @ApiModelProperty(value = "默认入库单位") + private String defaultUnit; + @Column(name = "`laster_in_stock`") @ApiModelProperty(value = "最近一次入库量") diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/dto/TbConsInfoDto.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/dto/TbConsInfoDto.java index a4b0bf17..e536c8ee 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/dto/TbConsInfoDto.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/dto/TbConsInfoDto.java @@ -39,6 +39,7 @@ public class TbConsInfoDto implements Serializable { private String conUnitTwo; private BigDecimal conUnitTwoConvert; + private String defaultUnit; /** 最近一次入库量 */ private BigDecimal lasterInStock; @@ -71,5 +72,4 @@ public class TbConsInfoDto implements Serializable { private String isCheck; - private List> product; } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoFlowServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoFlowServiceImpl.java index b8be6ec8..78f0b2d7 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoFlowServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoFlowServiceImpl.java @@ -114,6 +114,8 @@ public class TbConsInfoFlowServiceImpl implements TbConsInfoFlowService { criteria.setBizCode(Arrays.asList("stockIn","cancelCart","init","stockIn","checkStockIn","stockOtherIn","cancelCart","createCart","stockout","checkStockOut","frmLoss")); break; } + }else { + criteria.setBizCode(Arrays.asList("stockIn","cancelCart","init","stockIn","checkStockIn","stockOtherIn","cancelCart","createCart","stockout","checkStockOut","frmLoss")); } Sort sort = Sort.by(Sort.Direction.DESC, "id"); Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize(), sort); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java index 3b7a1451..476203f3 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java @@ -231,10 +231,20 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { } BigDecimal changeStock = conInfos.getStockNumber(); //副单位的实际修改值 - if (StringUtils.isNotBlank(conInfos.getUnit()) && conInfos.getUnit().equals(info.getConUnitTwo())) { + if (StringUtils.isNotBlank(conInfos.getUnit())) { + info.setDefaultUnit(conInfos.getUnit()); + if (conInfos.getUnit().equals(info.getConUnitTwo())) { + changeStock = conInfos.getStockNumber().multiply(info.getConUnitTwoConvert()).setScale(2, BigDecimal.ROUND_HALF_UP); + } + } else if (StringUtils.isNotBlank(info.getConUnitTwo()) + && StringUtils.isNotBlank(info.getDefaultUnit()) + && info.getConUnitTwo().equals(info.getDefaultUnit())) { + info.setDefaultUnit(info.getConUnitTwo()); changeStock = conInfos.getStockNumber().multiply(info.getConUnitTwoConvert()).setScale(2, BigDecimal.ROUND_HALF_UP); } + + TbConsSuppFlow suppFlow = new TbConsSuppFlow(); TbConsInfoFlow flow = new TbConsInfoFlow(); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/BotButtonConfigController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/BotButtonConfigController.java deleted file mode 100644 index 0d0fb7ce..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/BotButtonConfigController.java +++ /dev/null @@ -1,82 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.controller; - -import cn.ysk.cashier.annotation.Log; -import cn.ysk.cashier.pojo.BotButtonConfig; -import cn.ysk.cashier.service.BotButtonConfigService; -import cn.ysk.cashier.dto.BotButtonConfigQueryCriteria; -import org.springframework.data.domain.Pageable; -import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; -import io.swagger.annotations.*; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; - -/** -* @website https://eladmin.vip -* @author admin -* @date 2023-10-31 -**/ -@RestController -@RequiredArgsConstructor -@Api(tags = "buttonConfig管理") -@RequestMapping("/api/botButtonConfig") -public class BotButtonConfigController { - - private final BotButtonConfigService botButtonConfigService; - - @ApiOperation("导出数据") - @GetMapping(value = "/download") - @PreAuthorize("@el.check('botButtonConfig:list')") - public void exportBotButtonConfig(HttpServletResponse response, BotButtonConfigQueryCriteria criteria) throws IOException { - botButtonConfigService.download(botButtonConfigService.queryAll(criteria), response); - } - - @GetMapping - @ApiOperation("查询buttonConfig") - @PreAuthorize("@el.check('botButtonConfig:list')") - public ResponseEntity queryBotButtonConfig(BotButtonConfigQueryCriteria criteria, Pageable pageable){ - return new ResponseEntity<>(botButtonConfigService.queryAll(criteria,pageable),HttpStatus.OK); - } - - @PostMapping - @ApiOperation("新增buttonConfig") - @PreAuthorize("@el.check('botButtonConfig:add')") - public ResponseEntity createBotButtonConfig(@Validated @RequestBody BotButtonConfig resources){ - return new ResponseEntity<>(botButtonConfigService.create(resources),HttpStatus.CREATED); - } - - @PutMapping - @ApiOperation("修改buttonConfig") - @PreAuthorize("@el.check('botButtonConfig:edit')") - public ResponseEntity updateBotButtonConfig(@Validated @RequestBody BotButtonConfig resources){ - botButtonConfigService.update(resources); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - @DeleteMapping - @ApiOperation("删除buttonConfig") - @PreAuthorize("@el.check('botButtonConfig:del')") - public ResponseEntity deleteBotButtonConfig(@RequestBody Integer[] ids) { - botButtonConfigService.deleteAll(ids); - return new ResponseEntity<>(HttpStatus.OK); - } -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/BotConfigController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/BotConfigController.java deleted file mode 100644 index f7fc86ce..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/BotConfigController.java +++ /dev/null @@ -1,82 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.controller; - -import cn.ysk.cashier.annotation.Log; -import cn.ysk.cashier.pojo.BotConfig; -import cn.ysk.cashier.service.BotConfigService; -import cn.ysk.cashier.dto.BotConfigQueryCriteria; -import org.springframework.data.domain.Pageable; -import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; -import io.swagger.annotations.*; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; - -/** -* @website https://eladmin.vip -* @author admin -* @date 2023-10-31 -**/ -@RestController -@RequiredArgsConstructor -@Api(tags = "botConfig管理") -@RequestMapping("/api/botConfig") -public class BotConfigController { - - private final BotConfigService botConfigService; - - @ApiOperation("导出数据") - @GetMapping(value = "/download") - @PreAuthorize("@el.check('botConfig:list')") - public void exportBotConfig(HttpServletResponse response, BotConfigQueryCriteria criteria) throws IOException { - botConfigService.download(botConfigService.queryAll(criteria), response); - } - - @GetMapping - @ApiOperation("查询botConfig") - @PreAuthorize("@el.check('botConfig:list')") - public ResponseEntity queryBotConfig(BotConfigQueryCriteria criteria, Pageable pageable){ - return new ResponseEntity<>(botConfigService.queryAll(criteria,pageable),HttpStatus.OK); - } - - @PostMapping - @ApiOperation("新增botConfig") - @PreAuthorize("@el.check('botConfig:add')") - public ResponseEntity createBotConfig(@Validated @RequestBody BotConfig resources){ - return new ResponseEntity<>(botConfigService.create(resources),HttpStatus.CREATED); - } - - @PutMapping - @ApiOperation("修改botConfig") - @PreAuthorize("@el.check('botConfig:edit')") - public ResponseEntity updateBotConfig(@Validated @RequestBody BotConfig resources){ - botConfigService.update(resources); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - @DeleteMapping - @ApiOperation("删除botConfig") - @PreAuthorize("@el.check('botConfig:del')") - public ResponseEntity deleteBotConfig(@RequestBody Integer[] ids) { - botConfigService.deleteAll(ids); - return new ResponseEntity<>(HttpStatus.OK); - } -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/BotUserController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/BotUserController.java deleted file mode 100644 index 40d1d5cc..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/BotUserController.java +++ /dev/null @@ -1,82 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.controller; - -import cn.ysk.cashier.annotation.Log; -import cn.ysk.cashier.pojo.BotUser; -import cn.ysk.cashier.service.BotUserService; -import cn.ysk.cashier.dto.BotUserQueryCriteria; -import org.springframework.data.domain.Pageable; -import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; -import io.swagger.annotations.*; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; - -/** -* @website https://eladmin.vip -* @author admin -* @date 2023-10-30 -**/ -@RestController -@RequiredArgsConstructor -@Api(tags = "BotUserController管理") -@RequestMapping("/api/botUser") -public class BotUserController { - - private final BotUserService botUserService; - - @ApiOperation("导出数据") - @GetMapping(value = "/download") - @PreAuthorize("@el.check('botUser:list')") - public void exportBotUser(HttpServletResponse response, BotUserQueryCriteria criteria) throws IOException { - botUserService.download(botUserService.queryAll(criteria), response); - } - - @GetMapping - @ApiOperation("查询BotUserController") - @PreAuthorize("@el.check('botUser:list')") - public ResponseEntity queryBotUser(BotUserQueryCriteria criteria, Pageable pageable){ - return new ResponseEntity<>(botUserService.queryAll(criteria,pageable),HttpStatus.OK); - } - - @PostMapping - @ApiOperation("新增BotUserController") - @PreAuthorize("@el.check('botUser:add')") - public ResponseEntity createBotUser(@Validated @RequestBody BotUser resources){ - return new ResponseEntity<>(botUserService.create(resources),HttpStatus.CREATED); - } - - @PutMapping - @ApiOperation("修改BotUserController") - @PreAuthorize("@el.check('botUser:edit')") - public ResponseEntity updateBotUser(@Validated @RequestBody BotUser resources){ - botUserService.update(resources); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - @DeleteMapping - @ApiOperation("删除BotUserController") - @PreAuthorize("@el.check('botUser:del')") - public ResponseEntity deleteBotUser(@RequestBody Integer[] ids) { - botUserService.deleteAll(ids); - return new ResponseEntity<>(HttpStatus.OK); - } -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/BotUserFlowController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/BotUserFlowController.java deleted file mode 100644 index e41c7998..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/BotUserFlowController.java +++ /dev/null @@ -1,82 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.controller; - -import cn.ysk.cashier.annotation.Log; -import cn.ysk.cashier.pojo.BotUserFlow; -import cn.ysk.cashier.service.BotUserFlowService; -import cn.ysk.cashier.dto.BotUserFlowQueryCriteria; -import org.springframework.data.domain.Pageable; -import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; -import io.swagger.annotations.*; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; - -/** -* @website https://eladmin.vip -* @author admin -* @date 2023-10-30 -**/ -@RestController -@RequiredArgsConstructor -@Api(tags = "accountFlow管理") -@RequestMapping("/api/botUserFlow") -public class BotUserFlowController { - - private final BotUserFlowService botUserFlowService; - - @ApiOperation("导出数据") - @GetMapping(value = "/download") - @PreAuthorize("@el.check('botUserFlow:list')") - public void exportBotUserFlow(HttpServletResponse response, BotUserFlowQueryCriteria criteria) throws IOException { - botUserFlowService.download(botUserFlowService.queryAll(criteria), response); - } - - @GetMapping - @ApiOperation("查询accountFlow") - @PreAuthorize("@el.check('botUserFlow:list')") - public ResponseEntity queryBotUserFlow(BotUserFlowQueryCriteria criteria, Pageable pageable){ - return new ResponseEntity<>(botUserFlowService.queryAll(criteria,pageable),HttpStatus.OK); - } - - @PostMapping - @ApiOperation("新增accountFlow") - @PreAuthorize("@el.check('botUserFlow:add')") - public ResponseEntity createBotUserFlow(@Validated @RequestBody BotUserFlow resources){ - return new ResponseEntity<>(botUserFlowService.create(resources),HttpStatus.CREATED); - } - - @PutMapping - @ApiOperation("修改accountFlow") - @PreAuthorize("@el.check('botUserFlow:edit')") - public ResponseEntity updateBotUserFlow(@Validated @RequestBody BotUserFlow resources){ - botUserFlowService.update(resources); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - @DeleteMapping - @ApiOperation("删除accountFlow") - @PreAuthorize("@el.check('botUserFlow:del')") - public ResponseEntity deleteBotUserFlow(@RequestBody Integer[] ids) { - botUserFlowService.deleteAll(ids); - return new ResponseEntity<>(HttpStatus.OK); - } -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbRenewalsPayLogController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbRenewalsPayLogController.java deleted file mode 100644 index 7821f3ec..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbRenewalsPayLogController.java +++ /dev/null @@ -1,82 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.controller; - -import cn.ysk.cashier.annotation.Log; -import cn.ysk.cashier.pojo.TbRenewalsPayLog; -import cn.ysk.cashier.service.TbRenewalsPayLogService; -import cn.ysk.cashier.dto.TbRenewalsPayLogQueryCriteria; -import org.springframework.data.domain.Pageable; -import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; -import io.swagger.annotations.*; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; - -/** -* @website https://eladmin.vip -* @author lyf -* @date 2023-11-07 -**/ -@RestController -@RequiredArgsConstructor -@Api(tags = "/shop/renewals管理") -@RequestMapping("/api/tbRenewalsPayLog") -public class TbRenewalsPayLogController { - - private final TbRenewalsPayLogService tbRenewalsPayLogService; - - @ApiOperation("导出数据") - @GetMapping(value = "/download") - @PreAuthorize("@el.check('tbRenewalsPayLog:list')") - public void exportTbRenewalsPayLog(HttpServletResponse response, TbRenewalsPayLogQueryCriteria criteria) throws IOException { - tbRenewalsPayLogService.download(tbRenewalsPayLogService.queryAll(criteria), response); - } - - @GetMapping - @ApiOperation("查询/shop/renewals") - @PreAuthorize("@el.check('tbRenewalsPayLog:list')") - public ResponseEntity queryTbRenewalsPayLog(TbRenewalsPayLogQueryCriteria criteria, Pageable pageable){ - return new ResponseEntity<>(tbRenewalsPayLogService.queryAll(criteria,pageable),HttpStatus.OK); - } - - @PostMapping - @ApiOperation("新增/shop/renewals") - @PreAuthorize("@el.check('tbRenewalsPayLog:add')") - public ResponseEntity createTbRenewalsPayLog(@Validated @RequestBody TbRenewalsPayLog resources){ - return new ResponseEntity<>(tbRenewalsPayLogService.create(resources),HttpStatus.CREATED); - } - - @PutMapping - @ApiOperation("修改/shop/renewals") - @PreAuthorize("@el.check('tbRenewalsPayLog:edit')") - public ResponseEntity updateTbRenewalsPayLog(@Validated @RequestBody TbRenewalsPayLog resources){ - tbRenewalsPayLogService.update(resources); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - @DeleteMapping - @ApiOperation("删除/shop/renewals") - @PreAuthorize("@el.check('tbRenewalsPayLog:del')") - public ResponseEntity deleteTbRenewalsPayLog(@RequestBody Integer[] ids) { - tbRenewalsPayLogService.deleteAll(ids); - return new ResponseEntity<>(HttpStatus.OK); - } -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopCouponController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopCouponController.java new file mode 100644 index 00000000..9184405f --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopCouponController.java @@ -0,0 +1,100 @@ +package cn.ysk.cashier.controller; + +import cn.ysk.cashier.dto.QueryReceiveDto; +import cn.ysk.cashier.exception.BadRequestException; +import cn.ysk.cashier.mybatis.entity.TbShopCoupon; +import cn.ysk.cashier.mybatis.service.TbShopCouponService; +import cn.ysk.cashier.mybatis.vo.TbShopCouponVo; +import cn.ysk.cashier.utils.SecurityUtils; +import io.swagger.annotations.Api; +import org.springframework.util.CollectionUtils; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import io.swagger.annotations.ApiOperation; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import cn.ysk.cashier.dto.TbShopCouponQueryCriteria; + +import javax.annotation.Resource; + +/** + * 优惠券(TbShopCoupon)表控制层 + * + * @author ww + * @since 2024-10-22 15:43:24 + */ +@Api(tags = "优惠券管理") +@RestController +@RequestMapping("/api/tbShopCoupon") +public class TbShopCouponController { + /** + * 服务对象 + */ + @Resource + private TbShopCouponService tbShopCouponService; + + @GetMapping + @ApiOperation("分页查询") + public ResponseEntity selectAll(TbShopCouponQueryCriteria criteria) { + return new ResponseEntity<>(tbShopCouponService.queryAll(criteria), HttpStatus.OK); + } + + @GetMapping("{id}") + @ApiOperation("通过Id查询详情") + public TbShopCoupon selectOne(@PathVariable Integer id) { + return tbShopCouponService.findById(id); + } + + @GetMapping("/product/{couponId}") + @ApiOperation("查询赠送的商品") + public ResponseEntity queryActivatePros(@PathVariable("couponId") Integer couponId){ + return new ResponseEntity<>(tbShopCouponService.findActivatePros(couponId),HttpStatus.OK); + } + + @PostMapping + @ApiOperation("新增") + public ResponseEntity insert(@RequestBody TbShopCouponVo tbShopCoupon) { + if (tbShopCoupon.getType().equals(2) && CollectionUtils.isEmpty(tbShopCoupon.getProducts())) { + throw new BadRequestException("赠送商品不可为空"); + } + tbShopCoupon.setEditor(SecurityUtils.getCurrentUserNickName()); + return new ResponseEntity<>(tbShopCouponService.update(tbShopCoupon), HttpStatus.CREATED); + } + + @PutMapping + @ApiOperation("通过id修改") + public ResponseEntity update(@RequestBody TbShopCouponVo tbShopCoupon) { + if (tbShopCoupon.getType().equals(2) && CollectionUtils.isEmpty(tbShopCoupon.getProducts())) + throw new BadRequestException("赠送商品不可为空"); + tbShopCouponService.update(tbShopCoupon); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @DeleteMapping + @ApiOperation("删除优惠券") + public ResponseEntity delete(@RequestBody Integer[] ids) { + tbShopCouponService.delete(ids); + return new ResponseEntity<>(HttpStatus.OK); + } + + + @PostMapping("/queryReceive") + @ApiOperation("领取详情") + public ResponseEntity queryReceive(@Validated @RequestBody QueryReceiveDto param) { + return new ResponseEntity<>(tbShopCouponService.queryReceive(param), HttpStatus.OK); + } + + @DeleteMapping("receive") + @ApiOperation("删除用户的券") + public ResponseEntity deleteReceive(@RequestBody Integer[] ids) { + tbShopCouponService.deleteReceive(ids); + return new ResponseEntity<>(HttpStatus.OK); + } + + @GetMapping("activateByOrderId") + @ApiOperation("根据订单id获取可用优惠券信息") + public ResponseEntity activateByOrderIds(@RequestParam Integer shopId, @RequestParam Integer orderId, @RequestParam(required = false) Integer memberId) { + return ResponseEntity.ok(tbShopCouponService.getActivateByOrderIds(shopId, orderId, memberId)); + } +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopShareController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopShareController.java new file mode 100644 index 00000000..40ffba36 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbShopShareController.java @@ -0,0 +1,73 @@ +package cn.ysk.cashier.controller; + + +import cn.ysk.cashier.annotation.rest.AnonymousPostMapping; +import cn.ysk.cashier.dto.TbShopShareRecordQueryCriteria; +import cn.ysk.cashier.mybatis.entity.TbShopShare; +import cn.ysk.cashier.mybatis.service.TbShopShareRecordService; +import cn.ysk.cashier.mybatis.service.TbShopShareService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.Arrays; + +/** + * 店铺分享(TbShopShare)表控制层 + * + * @author ww + * @since 2024-11-06 15:47:37 + */ +@Api(tags = "分享") +@RestController +@RequestMapping("tbShopShare") +public class TbShopShareController { + + @Resource + private TbShopShareService tbShopShareService; + + /** + * 服务对象 + */ + @Resource + private TbShopShareRecordService tbShopShareRecordService; + + @PostMapping("byShare") + @AnonymousPostMapping + @ApiOperation("分页查询") + public ResponseEntity selectAllByShare(@RequestBody TbShopShareRecordQueryCriteria criteria) { + return new ResponseEntity<>(tbShopShareRecordService.selectAllByShare(criteria), HttpStatus.OK); + } + + @GetMapping("byShopId") + @ApiOperation("通过shopId查询详情") + public ResponseEntity getByShopId(@RequestParam Integer shopId) { + return ResponseEntity.ok(tbShopShareService.getByShopId(shopId)); + } + + @PostMapping + @ApiOperation("新增") + public ResponseEntity insert(@RequestBody TbShopShare tbShopShare) { + return new ResponseEntity<>(tbShopShareService.save(tbShopShare), HttpStatus.CREATED); + } + + @PutMapping + @ApiOperation("通过id修改") + public ResponseEntity update(@RequestBody TbShopShare tbShopShare) { + tbShopShareService.updateById(tbShopShare); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + + + @DeleteMapping + @ApiOperation("删除") + public ResponseEntity delete(@RequestBody Integer[] ids) { + tbShopShareService.removeByIds(Arrays.asList(ids)); + return new ResponseEntity<>(HttpStatus.OK); + } +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/points/TbMemberPointsController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/points/TbMemberPointsController.java new file mode 100644 index 00000000..9b9d0d3e --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/points/TbMemberPointsController.java @@ -0,0 +1,88 @@ +package cn.ysk.cashier.controller.points; + +import cn.hutool.core.map.MapProxy; +import cn.ysk.cashier.dto.points.OrderDeductionPointsDTO; +import cn.ysk.cashier.mybatis.entity.TbMemberPoints; +import cn.ysk.cashier.mybatis.service.TbMemberPointsService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.Map; + + +/** + * 会员积分 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@RestController +@RequestMapping("/api/points/member-points") +@Api(tags = "会员积分") +public class TbMemberPointsController { + + @Resource + private TbMemberPointsService tbMemberPointsService; + + @GetMapping("page") + @ApiOperation("分页") + public ResponseEntity page(@RequestParam Map params) { + Map page = tbMemberPointsService.page(params); + return ResponseEntity.ok().body(page); + } + + @GetMapping("{memberId}") + @ApiOperation("获取会员积分等信息") + public ResponseEntity getMemberPoints(@PathVariable("memberId") Long memberId) { + TbMemberPoints memberPoints = tbMemberPointsService.getMemberPoints(memberId); + return ResponseEntity.ok().body(memberPoints); + } + + @GetMapping("calc-usable-points") + @ApiOperation("获取订单可用积分及抵扣金额") + public ResponseEntity getMemberUsablePoints(@RequestParam Long memberId, @RequestParam BigDecimal orderAmount) { + OrderDeductionPointsDTO usablePoints = tbMemberPointsService.getMemberUsablePoints(memberId, orderAmount); + return ResponseEntity.ok().body(usablePoints); + } + + @GetMapping("calc-used-points") + @ApiOperation("根据抵扣金额计算所需积分") + public ResponseEntity calcUsedPoints(@RequestParam Long memberId, @RequestParam BigDecimal orderAmount, @RequestParam BigDecimal deductionAmount) { + int points = tbMemberPointsService.calcUsedPoints(memberId, orderAmount, deductionAmount); + return ResponseEntity.ok().body(points); + } + + @GetMapping("calc-deduction-amount") + @ApiOperation("根据积分计算可抵扣金额") + public ResponseEntity calcDeductionAmount(@RequestParam Long memberId, @RequestParam BigDecimal orderAmount, @RequestParam Integer points) { + BigDecimal deductionAmount = tbMemberPointsService.calcDeductionAmount(memberId, orderAmount, points); + return ResponseEntity.ok().body(deductionAmount); + } + + @PostMapping("payed-deduct-points") + @ApiOperation("支付完成扣减积分(支付成功回调中使用)") + public ResponseEntity deductPoints(@RequestBody Map params) { + MapProxy proxy = MapProxy.create(params); + Long memberId = proxy.getLong("memberId"); + Integer points = proxy.getInt("points"); + String content = proxy.getStr("content"); + Long orderId = proxy.getLong("orderId"); + boolean ret = tbMemberPointsService.deductPoints(memberId, points, content, orderId); + return ResponseEntity.ok().body(ret); + } + + @PostMapping("consume-award-points") + @ApiOperation("消费赠送积分(支付成功回调中使用)") + public ResponseEntity consumeAwardPoints(@RequestBody Map params) { + MapProxy proxy = MapProxy.create(params); + Long memberId = proxy.getLong("memberId"); + Long orderId = proxy.getLong("orderId"); + tbMemberPointsService.consumeAwardPoints(memberId, orderId); + return ResponseEntity.ok().build(); + } + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/points/TbMemberPointsLogController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/points/TbMemberPointsLogController.java new file mode 100644 index 00000000..b03bc21b --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/points/TbMemberPointsLogController.java @@ -0,0 +1,36 @@ +package cn.ysk.cashier.controller.points; + +import cn.ysk.cashier.mybatis.service.TbMemberPointsLogService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.Map; + + +/** + * 会员积分变动记录 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@RestController +@RequestMapping("/api/points/member-points-log") +@Api(tags = "会员积分变动记录") +public class TbMemberPointsLogController { + + @Resource + private TbMemberPointsLogService tbMemberPointsLogService; + + @GetMapping("page") + @ApiOperation("分页") + public ResponseEntity page(@RequestParam Map params) { + Map page = tbMemberPointsLogService.page(params); + return ResponseEntity.ok().body(page); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/points/TbPointsBasicSettingController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/points/TbPointsBasicSettingController.java new file mode 100644 index 00000000..2f5104bb --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/points/TbPointsBasicSettingController.java @@ -0,0 +1,42 @@ +package cn.ysk.cashier.controller.points; + +import cn.ysk.cashier.mybatis.entity.TbPointsBasicSetting; +import cn.ysk.cashier.mybatis.service.TbPointsBasicSettingService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + + +/** + * 积分基本设置 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@RestController +@RequestMapping("/api/points/basic-setting") +@Api(tags = "积分基本设置") +public class TbPointsBasicSettingController { + + @Resource + private TbPointsBasicSettingService tbPointsBasicSettingService; + + @GetMapping("{shopId}") + @ApiOperation("信息") + public ResponseEntity get(@PathVariable("shopId") Long shopId) { + TbPointsBasicSetting data = tbPointsBasicSettingService.getByShopId(shopId); + return ResponseEntity.ok().body(data); + } + + @PostMapping + @ApiOperation("保存") + public ResponseEntity save(@RequestBody TbPointsBasicSetting entity) { + tbPointsBasicSettingService.save(entity); + return ResponseEntity.ok().build(); + } + + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/points/TbPointsExchangeRecordController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/points/TbPointsExchangeRecordController.java new file mode 100644 index 00000000..be800ddd --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/points/TbPointsExchangeRecordController.java @@ -0,0 +1,69 @@ +package cn.ysk.cashier.controller.points; + +import cn.ysk.cashier.mybatis.entity.TbPointsExchangeRecord; +import cn.ysk.cashier.mybatis.service.TbPointsExchangeRecordService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.Map; + + +/** + * 积分兑换记录 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@RestController +@RequestMapping("/api/points/exchange-record") +@Api(tags = "积分兑换记录") +public class TbPointsExchangeRecordController { + + @Resource + private TbPointsExchangeRecordService tbPointsExchangeRecordService; + + @GetMapping("page") + @ApiOperation("分页") + public ResponseEntity page(@RequestParam Map params) { + Map data = tbPointsExchangeRecordService.page(params); + return ResponseEntity.ok().body(data); + } + + @GetMapping("{id}") + @ApiOperation("信息") + public ResponseEntity get(@PathVariable("id") Long id) { + TbPointsExchangeRecord data = tbPointsExchangeRecordService.get(id); + return ResponseEntity.ok().body(data); + } + + @PostMapping("checkout") + @ApiOperation("核销") + public ResponseEntity checkout(@RequestBody TbPointsExchangeRecord record) { + tbPointsExchangeRecordService.checkout(record.getCouponCode()); + return ResponseEntity.ok().build(); + } + + @PostMapping("cancel") + @ApiOperation("取消") + public ResponseEntity cancel(@RequestBody TbPointsExchangeRecord record) { + tbPointsExchangeRecordService.cancel(record); + return ResponseEntity.ok().build(); + } + + @PostMapping("refund") + @ApiOperation("退单") + public ResponseEntity refund(@RequestBody TbPointsExchangeRecord record) { + tbPointsExchangeRecordService.refund(record); + return ResponseEntity.ok().build(); + } + + @GetMapping("total") + @ApiOperation("统计") + public ResponseEntity total(@RequestParam Map params) { + Map data = tbPointsExchangeRecordService.total(params); + return ResponseEntity.ok().body(data); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/points/TbPointsGoodsSettingController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/points/TbPointsGoodsSettingController.java new file mode 100644 index 00000000..b703e0d9 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/points/TbPointsGoodsSettingController.java @@ -0,0 +1,62 @@ +package cn.ysk.cashier.controller.points; + +import cn.ysk.cashier.mybatis.entity.TbPointsGoodsSetting; +import cn.ysk.cashier.mybatis.service.TbPointsGoodsSettingService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.Map; + + +/** + * 积分商品设置 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@RestController +@RequestMapping("/api/points/goods-setting") +@Api(tags = "积分商品设置") +public class TbPointsGoodsSettingController { + + @Resource + private TbPointsGoodsSettingService tbPointsGoodsSettingService; + + @GetMapping("page") + @ApiOperation("分页") + public ResponseEntity page(@RequestParam Map params) { + Map data = tbPointsGoodsSettingService.page(params); + return ResponseEntity.ok().body(data); + } + + @GetMapping("{id}") + @ApiOperation("信息") + public ResponseEntity get(@PathVariable("id") Long id) { + TbPointsGoodsSetting data = tbPointsGoodsSettingService.getById(id); + return ResponseEntity.ok().body(data); + } + + @PostMapping + @ApiOperation("保存") + public ResponseEntity save(@RequestBody TbPointsGoodsSetting entity) { + boolean ret = tbPointsGoodsSettingService.save(entity); + return ResponseEntity.ok().body(ret); + } + + @PutMapping + @ApiOperation("修改") + public ResponseEntity update(@RequestBody TbPointsGoodsSetting dto) { + boolean ret = tbPointsGoodsSettingService.update(dto); + return ResponseEntity.ok().body(ret); + } + + @DeleteMapping("{id}") + @ApiOperation("删除") + public ResponseEntity delete(@PathVariable("id") Long id) { + tbPointsGoodsSettingService.delete(id); + return ResponseEntity.ok().build(); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPadLayoutController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPadLayoutController.java new file mode 100644 index 00000000..90d0e081 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPadLayoutController.java @@ -0,0 +1,37 @@ +package cn.ysk.cashier.controller.product; + +import cn.ysk.cashier.mybatis.service.TbPadLayoutService; +import cn.ysk.cashier.pojo.product.TbPadLayout; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + +/** + * Pad商品布局版式 + * @author tankaikai + * @since 2024-10-22 16:38 + */ +@RestController +@RequestMapping("/api/pad/layout") +@Api(tags="Pad商品布局版式") +public class TbPadLayoutController { + + @Resource + private TbPadLayoutService mpPadLayoutService; + + @GetMapping("list") + @ApiOperation("分页") + public ResponseEntity list(@RequestParam Map params) { + List list = mpPadLayoutService.findList(); + return ResponseEntity.ok().body(list); + } + +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPadProductCategoryController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPadProductCategoryController.java new file mode 100644 index 00000000..39a739ff --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPadProductCategoryController.java @@ -0,0 +1,76 @@ +package cn.ysk.cashier.controller.product; + +import cn.ysk.cashier.dto.product.PadProductCategoryDTO; +import cn.ysk.cashier.mybatis.service.TbPadProductCategoryService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + +/** + * Pad商品自定义分类 + * @author tankaikai + * @since 2024-10-22 16:38 + */ +@RestController +@RequestMapping("/api/pad/productCategory") +@Api(tags="Pad商品自定义分类") +public class TbPadProductCategoryController { + + @Resource + private TbPadProductCategoryService mpPadProductCategoryService; + + @GetMapping("page") + @ApiOperation("分页") + public ResponseEntity page(@RequestParam Map params) { + Map page = mpPadProductCategoryService.findPage(params); + return ResponseEntity.ok().body(page); + } + + @GetMapping("{id}") + @ApiOperation("详情") + public ResponseEntity get(@PathVariable("id") Long id) { + PadProductCategoryDTO data = mpPadProductCategoryService.get(id); + return ResponseEntity.ok().body(data); + } + + @PostMapping + @ApiOperation("保存") + public ResponseEntity save(@RequestBody PadProductCategoryDTO dto) { + mpPadProductCategoryService.save(dto); + return ResponseEntity.ok().body(dto.getId()); + } + + @PutMapping + @ApiOperation("修改") + public ResponseEntity update(@RequestBody PadProductCategoryDTO dto) { + mpPadProductCategoryService.update(dto); + return ResponseEntity.ok().body(dto.getId()); + } + + @DeleteMapping("{id}") + @ApiOperation("删除") + public ResponseEntity delete(@PathVariable("id") Long id) { + mpPadProductCategoryService.delete(id); + return ResponseEntity.ok().build(); + } + + @PostMapping("sort") + @ApiOperation("排序") + public ResponseEntity sort(@RequestBody List sortList) { + mpPadProductCategoryService.sort(sortList); + return ResponseEntity.ok().build(); + } + + @PostMapping("copy/{id}") + @ApiOperation("复制") + public ResponseEntity copy(@PathVariable("id") Long id) { + mpPadProductCategoryService.copy(id); + return ResponseEntity.ok().build(); + } + +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java index 0103d389..d36df365 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java @@ -147,7 +147,7 @@ public class TbPlaceController { @PostMapping("/order") @ApiOperation("代客下单 查询购物车 /shop/table") public ResponseEntity createOrder(@RequestBody CreateOrderDTO createOrderDTO) { - return ResponseEntity.ok(tbShopTableService.createOrder(createOrderDTO, !createOrderDTO.isPostPay(), true)); + return ResponseEntity.ok(tbShopTableService.createOrder(createOrderDTO, false)); } @PostMapping("/pending") @@ -175,13 +175,23 @@ public class TbPlaceController { JSONObject userInfo = JSON.parseObject(JSON.toJSONString(redisUtils.get("online-token-" + token))); String userName = userInfo.getString("userName"); String shopId = userInfo.getString("shopId"); - TbPlussShopStaff shopStaff = staffRepository.queryByAccount(userName, shopId); - TbMerchantAccount merchantAccount = tbMerchantAccountMapper.selectOne(Wrappers.lambdaQuery().eq(TbMerchantAccount::getAccount, shopStaff.getAccount())); + TbPlussShopStaff shopStaff; + if (userName.contains("@")) { + shopStaff = staffRepository.queryMasterAccount(shopId); + } else { + shopStaff = staffRepository.queryByAccount(userName, shopId); + } + TbMerchantAccount merchantAccount = tbMerchantAccountMapper.selectOne(Wrappers.lambdaQuery() + .eq(TbMerchantAccount::getAccount, shopStaff.getAccount())); Integer accountId = merchantAccount.getId(); Integer staffId = shopStaff.getId(); List onlineUserList = tbTokenRepository.findListByAccountIdAndStaffId(accountId, staffId); if (CollUtil.isNotEmpty(onlineUserList)) { payDTO.setToken(onlineUserList.get(0).getToken()); + } else { + payDTO.setShopId(Integer.valueOf(shopId)); + payDTO.setStaffId(staffId); + payDTO.setLoginName(userName); } return ResponseEntity.ok(tbShopTableService.pay(payDTO)); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbProductStockOperateController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbProductStockOperateController.java index f806bdb8..528acbfa 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbProductStockOperateController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbProductStockOperateController.java @@ -1,20 +1,21 @@ package cn.ysk.cashier.controller.product; -import cn.ysk.cashier.annotation.AnonymousAccess; import cn.ysk.cashier.annotation.Log; -import cn.ysk.cashier.pojo.product.TbProductStockOperate; -import cn.ysk.cashier.service.TbProductStockOperateService; import cn.ysk.cashier.dto.product.OutAndOnDto; import cn.ysk.cashier.dto.product.TbProductStockOperateQueryCriteria; +import cn.ysk.cashier.pojo.product.TbProductStockOperate; +import cn.ysk.cashier.service.TbProductStockOperateService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import io.swagger.annotations.*; -import java.io.IOException; + import javax.servlet.http.HttpServletResponse; +import java.io.IOException; /** * @website https://eladmin.vip @@ -40,6 +41,11 @@ public class TbProductStockOperateController { return new ResponseEntity<>(tbProductStockOperateService.queryAllPage(criteria),HttpStatus.OK); } + @PostMapping("/page") + public ResponseEntity page(@RequestBody TbProductStockOperateQueryCriteria criteria){ + return new ResponseEntity<>(tbProductStockOperateService.queryAllPage(criteria),HttpStatus.OK); + } + @GetMapping("/{id}") public ResponseEntity queryById(@PathVariable Integer id){ return new ResponseEntity<>(tbProductStockOperateService.findById(id),HttpStatus.OK); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/ShopPayApiController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/ShopPayApiController.java index 409d34ea..205169ac 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/ShopPayApiController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/ShopPayApiController.java @@ -38,10 +38,6 @@ public class ShopPayApiController { @GetMapping("getOrderPayUrl") @ApiOperation("获取店铺订单支付URL") - @ApiImplicitParams({ - @ApiImplicitParam(name = "orderId", value = "订单id", paramType = "query", required = true, dataType = "String"), - @ApiImplicitParam(name = "shopId", value = "店铺id", paramType = "query", required = true, dataType = "String"), - }) public ResponseEntity url(@RequestParam Map params) { MapProxy mapProxy = MapProxy.create(params); String shopId = mapProxy.getStr("shopId"); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/SummaryByDayController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/SummaryByDayController.java index 315888f7..28592d0f 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/SummaryByDayController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/SummaryByDayController.java @@ -1,5 +1,6 @@ package cn.ysk.cashier.controller.shop; +import cn.ysk.cashier.annotation.rest.AnonymousGetMapping; import cn.ysk.cashier.dto.ShopSummaryDto; import cn.ysk.cashier.service.SummaryService; import cn.ysk.cashier.vo.TbOrderPayCountVo; @@ -33,6 +34,7 @@ public class SummaryByDayController { @GetMapping + @AnonymousGetMapping public Page shopSummary(ShopSummaryDto summaryDto, @RequestParam(required = false, defaultValue = "0") Integer page, @RequestParam(required = false, defaultValue = "10") Integer size) { diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/SummaryController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/SummaryController.java index efd3df02..7b814e1e 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/SummaryController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/SummaryController.java @@ -26,7 +26,6 @@ public class SummaryController { //营业板块 上 @PostMapping("/trade") - @AnonymousPostMapping private Object shopSummaryDate(@RequestBody BaseQueryDto param) { return summaryService.trade(param); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbMerchantCouponController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbMerchantCouponController.java deleted file mode 100644 index 00d93cfd..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbMerchantCouponController.java +++ /dev/null @@ -1,92 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.controller.shop; - -import cn.ysk.cashier.annotation.Log; -import cn.ysk.cashier.dto.shop.TbMerchantCouponDto; -import cn.ysk.cashier.pojo.shop.TbMerchantCoupon; -import cn.ysk.cashier.pojo.shop.TbPurchaseNotice; -import cn.ysk.cashier.repository.shop.TbPurchaseNoticeRepository; -import cn.ysk.cashier.service.shop.TbMerchantCouponService; -import cn.ysk.cashier.dto.shop.TbMerchantCouponQueryCriteria; -import cn.ysk.cashier.service.shop.TbPurchaseNoticeService; -import org.springframework.data.domain.Pageable; -import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; -import io.swagger.annotations.*; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import javax.servlet.http.HttpServletResponse; - -/** -* @website https://eladmin.vip -* @author lyf -* @date 2024-03-20 -**/ -@RestController -@RequiredArgsConstructor -@Api(tags = "/shop/coupon管理") -@RequestMapping("/api/tbMerchantCoupon") -public class TbMerchantCouponController { - - private final TbMerchantCouponService tbMerchantCouponService; - private final TbPurchaseNoticeRepository noticeRepository; - - @ApiOperation("导出数据") - public void exportTbMerchantCoupon(HttpServletResponse response, TbMerchantCouponQueryCriteria criteria) throws IOException { - tbMerchantCouponService.download(tbMerchantCouponService.queryAll(criteria), response); - } - - @GetMapping - public ResponseEntity queryTbMerchantCoupon(TbMerchantCouponQueryCriteria criteria, Pageable pageable){ - return new ResponseEntity<>(tbMerchantCouponService.queryAll(criteria,pageable),HttpStatus.OK); - } - - @GetMapping("/{id}") - @ApiOperation("查询优惠卷") - public ResponseEntity queryTbMerchantCouponById(@PathVariable("id")Integer id){ - Map result=new HashMap<>(); - TbMerchantCouponDto coupon = tbMerchantCouponService.findById(id); - result.put("coupon",coupon); - TbPurchaseNotice notice = noticeRepository.findByCouponId(id); - result.put("notice",notice); - return new ResponseEntity<>(result,HttpStatus.OK); - } - - @PostMapping - @Log("新增商家优惠卷:#resources.title") - public ResponseEntity createTbMerchantCoupon(@Validated @RequestBody TbMerchantCoupon resources){ - return new ResponseEntity<>(tbMerchantCouponService.create(resources),HttpStatus.CREATED); - } - - @PutMapping - @Log("修改商家优惠卷:#resources.title") - public ResponseEntity updateTbMerchantCoupon(@Validated @RequestBody TbMerchantCoupon resources){ - tbMerchantCouponService.update(resources); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - @DeleteMapping - @Log("删除商家优惠卷:#ids") - public ResponseEntity deleteTbMerchantCoupon(@RequestBody Integer[] ids) { - tbMerchantCouponService.deleteAll(ids); - return new ResponseEntity<>(HttpStatus.OK); - } -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbReceiptSalesController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbReceiptSalesController.java deleted file mode 100644 index 9681be81..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbReceiptSalesController.java +++ /dev/null @@ -1,91 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.controller.shop; - -import cn.ysk.cashier.annotation.Log; -import cn.ysk.cashier.pojo.shop.TbReceiptSales; -import cn.ysk.cashier.dto.shop.TbReceiptSalesQueryCriteria; -import cn.ysk.cashier.service.shop.TbReceiptSalesService; -import org.springframework.data.domain.Pageable; -import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; -import io.swagger.annotations.*; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; - -/** -* @website https://eladmin.vip -* @author lyf -* @date 2024-01-08 -**/ -@RestController -@RequiredArgsConstructor -@Api(tags = "/shop/receiptSales管理") -@RequestMapping("/api/tbReceiptSales") -public class TbReceiptSalesController { - - private final TbReceiptSalesService tbReceiptSalesService; - - @ApiOperation("导出数据") - @GetMapping(value = "/download") - @PreAuthorize("@el.check('tbReceiptSales:list')") - public void exportTbReceiptSales(HttpServletResponse response, TbReceiptSalesQueryCriteria criteria) throws IOException { - tbReceiptSalesService.download(tbReceiptSalesService.queryAll(criteria), response); - } - - @GetMapping - @ApiOperation("查询/shop/receiptSales") - @PreAuthorize("@el.check('tbReceiptSales:list')") - public ResponseEntity queryTbReceiptSales(TbReceiptSalesQueryCriteria criteria, Pageable pageable){ - return new ResponseEntity<>(tbReceiptSalesService.queryAll(criteria,pageable),HttpStatus.OK); - } - - @GetMapping("/{shopId}") - @ApiOperation("查询/shop/receiptSales") - @PreAuthorize("@el.check('tbReceiptSales:info')") - public Object queryTbReceiptSalesInfo(@PathVariable("shopId")Integer shopId){ - - return tbReceiptSalesService.findById(shopId); - } - - - @PostMapping - @ApiOperation("新增/shop/receiptSales") - @PreAuthorize("@el.check('tbReceiptSales:add')") - public ResponseEntity createTbReceiptSales(@Validated @RequestBody TbReceiptSales resources){ - return new ResponseEntity<>(tbReceiptSalesService.create(resources),HttpStatus.CREATED); - } - - @PutMapping - @ApiOperation("修改/shop/receiptSales") - @PreAuthorize("@el.check('tbReceiptSales:edit')") - public ResponseEntity updateTbReceiptSales(@Validated @RequestBody TbReceiptSales resources){ - tbReceiptSalesService.update(resources); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - @DeleteMapping - @ApiOperation("删除/shop/receiptSales") - @PreAuthorize("@el.check('tbReceiptSales:del')") - public ResponseEntity deleteTbReceiptSales(@RequestBody Integer[] ids) { - tbReceiptSalesService.deleteAll(ids); - return new ResponseEntity<>(HttpStatus.OK); - } -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopCashSpreadController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopCashSpreadController.java deleted file mode 100644 index 5fa647ef..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopCashSpreadController.java +++ /dev/null @@ -1,95 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.controller.shop; - -import cn.ysk.cashier.annotation.Log; -import cn.ysk.cashier.pojo.shop.TbShopCashSpread; -import cn.ysk.cashier.service.shop.TbShopCashSpreadService; -import cn.ysk.cashier.dto.shop.TbShopCashSpreadQueryCriteria; -import cn.ysk.cashier.utils.StringUtils; -import org.springframework.data.domain.Pageable; -import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; -import io.swagger.annotations.*; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; - -/** -* @website https://eladmin.vip -* @author lyf -* @date 2024-01-05 -**/ -@RestController -@RequiredArgsConstructor -@Api(tags = "/shop/spread管理") -@RequestMapping("/api/tbShopCashSpread") -public class TbShopCashSpreadController { - - private final TbShopCashSpreadService tbShopCashSpreadService; - - @ApiOperation("导出数据") - @GetMapping(value = "/download") - @PreAuthorize("@el.check('tbShopCashSpread:list')") - public void exportTbShopCashSpread(HttpServletResponse response, TbShopCashSpreadQueryCriteria criteria) throws IOException { - tbShopCashSpreadService.download(tbShopCashSpreadService.queryAll(criteria), response); - } - - @GetMapping - @ApiOperation("查询/shop/spread") - @PreAuthorize("@el.check('tbShopCashSpread:list')") - public ResponseEntity queryTbShopCashSpread(TbShopCashSpreadQueryCriteria criteria, Pageable pageable){ - return new ResponseEntity<>(tbShopCashSpreadService.queryAll(criteria,pageable),HttpStatus.OK); - } - @GetMapping("/{shopId}") - @ApiOperation("查询/shop/spread/info") - @PreAuthorize("@el.check('tbShopCashSpread:info')") - public Object queryTbShopCashSpreadInfo(@PathVariable("shopId") Integer shopId){ - TbShopCashSpread byShopId = tbShopCashSpreadService.findByShopId(shopId); - String screenConfig = byShopId.getScreenConfig(); - return StringUtils.stringChangeMap(screenConfig); - } - @PostMapping - @ApiOperation("新增/shop/spread") - @PreAuthorize("@el.check('tbShopCashSpread:add')") - public ResponseEntity createTbShopCashSpread(@Validated @RequestBody TbShopCashSpread resources){ - return new ResponseEntity<>(tbShopCashSpreadService.create(resources),HttpStatus.CREATED); - } - - @PutMapping - @ApiOperation("修改/shop/spread") - @PreAuthorize("@el.check('tbShopCashSpread:edit')") - public ResponseEntity updateTbShopCashSpread(@Validated @RequestBody TbShopCashSpread resources){ - Integer update = tbShopCashSpreadService.update(resources); - if (update>0){ - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - - } - return new ResponseEntity<>(HttpStatus.BAD_REQUEST); - - } - - @DeleteMapping - @ApiOperation("删除/shop/spread") - @PreAuthorize("@el.check('tbShopCashSpread:del')") - public ResponseEntity deleteTbShopCashSpread(@RequestBody String[] ids) { - tbShopCashSpreadService.deleteAll(ids); - return new ResponseEntity<>(HttpStatus.OK); - } -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopCurrencyController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopCurrencyController.java deleted file mode 100644 index 83a579e5..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopCurrencyController.java +++ /dev/null @@ -1,83 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.controller.shop; - -import cn.ysk.cashier.pojo.shop.TbShopCurrency; -import cn.ysk.cashier.service.shop.TbShopCurrencyService; -import cn.ysk.cashier.dto.shop.TbShopCurrencyQueryCriteria; -import org.springframework.data.domain.Pageable; -import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; -import io.swagger.annotations.*; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; - -/** -* @website https://eladmin.vip -* @author lyf -* @date 2024-01-05 -**/ -@RestController -@RequiredArgsConstructor -@Api(tags = "/shop/currency管理") -@RequestMapping("/api/tbShopCurrency") -public class TbShopCurrencyController { - - private final TbShopCurrencyService tbShopCurrencyService; - - @ApiOperation("导出数据") - @GetMapping(value = "/download") - @PreAuthorize("@el.check('tbShopCurrency:list')") - public void exportTbShopCurrency(HttpServletResponse response, TbShopCurrencyQueryCriteria criteria) throws IOException { - tbShopCurrencyService.download(tbShopCurrencyService.queryAll(criteria), response); - } - - @GetMapping - @ApiOperation("查询/shop/currency") - public ResponseEntity queryTbShopCurrency(TbShopCurrencyQueryCriteria criteria, Pageable pageable){ - return new ResponseEntity<>(tbShopCurrencyService.queryAll(criteria,pageable),HttpStatus.OK); - } - - @GetMapping("/{shopId}") - @ApiOperation("查询/shop/currency/info") - public Object queryTbShopCurrencyInfo(@PathVariable("shopId") String shopId){ - return tbShopCurrencyService.findByShopId(shopId); - } - - @PostMapping - @ApiOperation("新增/shop/currency") - public ResponseEntity createTbShopCurrency(@Validated @RequestBody TbShopCurrency resources){ - return new ResponseEntity<>(tbShopCurrencyService.create(resources),HttpStatus.CREATED); - } - - @PutMapping - @ApiOperation("修改/shop/currency") - public ResponseEntity updateTbShopCurrency(@Validated @RequestBody TbShopCurrency resources){ - tbShopCurrencyService.update(resources); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - @DeleteMapping - @ApiOperation("删除/shop/currency") - public ResponseEntity deleteTbShopCurrency(@RequestBody Integer[] ids) { - tbShopCurrencyService.deleteAll(ids); - return new ResponseEntity<>(HttpStatus.OK); - } -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/BotButtonConfigDto.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/BotButtonConfigDto.java deleted file mode 100644 index b555cae6..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/BotButtonConfigDto.java +++ /dev/null @@ -1,37 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.dto; - -import lombok.Data; -import java.io.Serializable; - -/** -* @website https://eladmin.vip -* @description / -* @author admin -* @date 2023-10-31 -**/ -@Data -public class BotButtonConfigDto implements Serializable { - - private Integer id; - - /** 按钮名称 */ - private String buttonName; - - /** 按钮值 */ - private String buttonValue; -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/BotButtonConfigQueryCriteria.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/BotButtonConfigQueryCriteria.java deleted file mode 100644 index d789fd09..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/BotButtonConfigQueryCriteria.java +++ /dev/null @@ -1,32 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.dto; - -import lombok.Data; -import cn.ysk.cashier.annotation.Query; - -/** -* @website https://eladmin.vip -* @author admin -* @date 2023-10-31 -**/ -@Data -public class BotButtonConfigQueryCriteria{ - - /** 精确 */ - @Query - private String buttonName; -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/BotConfigDto.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/BotConfigDto.java deleted file mode 100644 index 1426d65d..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/BotConfigDto.java +++ /dev/null @@ -1,40 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.dto; - -import lombok.Data; -import java.io.Serializable; - -/** -* @website https://eladmin.vip -* @description / -* @author admin -* @date 2023-10-31 -**/ -@Data -public class BotConfigDto implements Serializable { - - private Integer id; - - /** 元素键值 */ - private String configKey; - - /** 元素值 */ - private String configValue; - - /** 描述 */ - private String remark; -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/BotConfigQueryCriteria.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/BotConfigQueryCriteria.java deleted file mode 100644 index ce14acb3..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/BotConfigQueryCriteria.java +++ /dev/null @@ -1,36 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.dto; - -import lombok.Data; -import cn.ysk.cashier.annotation.Query; - -/** -* @website https://eladmin.vip -* @author admin -* @date 2023-10-31 -**/ -@Data -public class BotConfigQueryCriteria{ - - /** 精确 */ - @Query - private String configKey; - - /** 精确 */ - @Query - private String configValue; -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/BotUserDto.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/BotUserDto.java deleted file mode 100644 index 93ee777f..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/BotUserDto.java +++ /dev/null @@ -1,87 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.dto; - -import lombok.Data; -import java.sql.Timestamp; -import java.math.BigDecimal; -import java.io.Serializable; - -/** -* @website https://eladmin.vip -* @description / -* @author admin -* @date 2023-10-30 -**/ -@Data -public class BotUserDto implements Serializable { - - private Integer id; - - private Integer fatherId; - - /** 父级电报号 */ - private String fatherTelegramId; - - /** 电报号 */ - private String userTelegramId; - - /** 用户名称 */ - private String userName; - - /** 组电报号 */ - private String groupTelegramId; - - /** 用户代码 */ - private String userCode; - - private String userPayPass; - - private String bombStatus; - - /** 用户状态 */ - private String botStatus; - - /** 总充值 */ - private BigDecimal usdtRechargeTotal; - - /** 总提现 */ - private BigDecimal usdtWithdrawTotal; - - /** 总资金 */ - private BigDecimal balance; - - /** 冻结资金 */ - private BigDecimal freezeBalance; - - /** 版本号 */ - private Integer version; - - /** 创建时间 */ - private Timestamp createTime; - - /** 更新时间 */ - private Timestamp updateTime; - - /** 语言 */ - private String userLanguage; - - /** 质押资金 */ - private BigDecimal chipBalance; - - /** 绑定时间 */ - private Timestamp fatherBindTime; -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/BotUserFlowDto.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/BotUserFlowDto.java deleted file mode 100644 index cc5a0e83..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/BotUserFlowDto.java +++ /dev/null @@ -1,54 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.dto; - -import lombok.Data; -import java.sql.Timestamp; -import java.math.BigDecimal; -import java.io.Serializable; - -/** -* @website https://eladmin.vip -* @description / -* @author admin -* @date 2023-10-30 -**/ -@Data -public class BotUserFlowDto implements Serializable { - - private Integer id; - - /** 电报号 */ - private String userTelegramId; - - /** 用户名称 */ - private String userName; - - /** 业务代码 */ - private String bizCode; - - /** 变动金额 */ - private BigDecimal amount; - - /** 变动前金额 */ - private BigDecimal oldBalance; - - /** 变动后金额 */ - private BigDecimal newBalance; - - /** 创建时间 */ - private Timestamp createTime; -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/BotUserFlowQueryCriteria.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/BotUserFlowQueryCriteria.java deleted file mode 100644 index d629ccf6..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/BotUserFlowQueryCriteria.java +++ /dev/null @@ -1,40 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.dto; - -import lombok.Data; -import cn.ysk.cashier.annotation.Query; - -/** -* @website https://eladmin.vip -* @author admin -* @date 2023-10-30 -**/ -@Data -public class BotUserFlowQueryCriteria{ - - /** 精确 */ - @Query - private String userTelegramId; - - /** 精确 */ - @Query - private String userName; - - /** 精确 */ - @Query - private String bizCode; -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/BotUserQueryCriteria.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/BotUserQueryCriteria.java deleted file mode 100644 index e174c66c..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/BotUserQueryCriteria.java +++ /dev/null @@ -1,48 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.dto; - -import lombok.Data; -import cn.ysk.cashier.annotation.Query; - -/** -* @website https://eladmin.vip -* @author admin -* @date 2023-10-30 -**/ -@Data -public class BotUserQueryCriteria{ - - /** 精确 */ - @Query - private String fatherTelegramId; - - /** 精确 */ - @Query - private String userTelegramId; - - /** 精确 */ - @Query - private String userName; - - /** 精确 */ - @Query - private String userCode; - - /** 精确 */ - @Query - private String botStatus; -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/CouponDto.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/CouponDto.java new file mode 100644 index 00000000..9feaf698 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/CouponDto.java @@ -0,0 +1,15 @@ +package cn.ysk.cashier.dto; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class CouponDto { + private Integer shopId; + private Integer userId; + //-1已过期 1未使用 2已使用 + private Integer status; + private Integer orderId; + private BigDecimal amount; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/QueryReceiveDto.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/QueryReceiveDto.java new file mode 100644 index 00000000..de0dee0c --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/QueryReceiveDto.java @@ -0,0 +1,19 @@ +package cn.ysk.cashier.dto; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +@Data +public class QueryReceiveDto extends BaseQueryDto{ + @NotBlank(message = "优惠券id 不可为空") + private String couponId; + //用户昵称 手机号 模糊 + private String value; + //状态 0 未使用 1 已使用 + private Integer status; + + private Integer page = 1; + + private Integer size = 10; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/TbActivateProductQueryCriteria.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/TbActivateProductQueryCriteria.java index b6f4b3a3..30e6ea53 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/TbActivateProductQueryCriteria.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/TbActivateProductQueryCriteria.java @@ -5,7 +5,7 @@ import java.util.Date; import lombok.Data; /** - * 活动赠送商品表(TbActivateProduct)表查询类 + * 活动赠送商品表(TbCouponProduct)表查询类 * * @author ww * @since 2024-08-20 11:27:40 diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/TbShopCouponQueryCriteria.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/TbShopCouponQueryCriteria.java new file mode 100644 index 00000000..352ba64b --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/TbShopCouponQueryCriteria.java @@ -0,0 +1,18 @@ +package cn.ysk.cashier.dto; + +import lombok.Data; + +/** + * 优惠券(TbShopCoupon)表查询类 + * + * @author ww + * @since 2024-10-22 15:43:25 + */ +@Data +public class TbShopCouponQueryCriteria { + private Integer shopId; + private Integer type; + private long page; + private long size; +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/TbShopShareRecordQueryCriteria.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/TbShopShareRecordQueryCriteria.java new file mode 100644 index 00000000..df31aa05 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/TbShopShareRecordQueryCriteria.java @@ -0,0 +1,26 @@ +package cn.ysk.cashier.dto; + +import lombok.Data; + +/** + * (TbShopShareRecord)表查询类 + * + * @author ww + * @since 2024-11-08 09:17:38 + */ +@Data +public class TbShopShareRecordQueryCriteria { + + private Integer shareId; + //店铺Id + private Integer shopId; + //邀请人名称/被邀请人/昵称/手机号 模糊查询 + private String search; + + //0 非新用户 1 未领取 2 已领取 3 已使用 + private Integer status; + + private long page = 1; + private long size = 10; +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/order/OrderCartInfoDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/order/OrderCartInfoDTO.java new file mode 100644 index 00000000..ad5ab1ed --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/order/OrderCartInfoDTO.java @@ -0,0 +1,19 @@ +package cn.ysk.cashier.dto.order; + +import cn.ysk.cashier.pojo.order.TbCashierCart; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +@Data +public class OrderCartInfoDTO { + private BigDecimal totalAmount = BigDecimal.ZERO; + private BigDecimal newAddTotalAmount = BigDecimal.ZERO; + private List newCashierCarts = new ArrayList<>(); + private List cashierCarts = new ArrayList<>(); + private List cashierCartIds = new ArrayList<>(); + private Integer orderId; + private TbCashierCart seatCart; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/order/OrderCouponInfoDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/order/OrderCouponInfoDTO.java new file mode 100644 index 00000000..3c9be106 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/order/OrderCouponInfoDTO.java @@ -0,0 +1,21 @@ +package cn.ysk.cashier.dto.order; + +import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord; +import cn.ysk.cashier.pojo.shop.TbShopUser; +import cn.ysk.cashier.vo.TbUserCouponVo; +import lombok.Data; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +@Data +public class OrderCouponInfoDTO { + private TbShopUser shopUser; + private List outRecordList = new ArrayList<>(); + // 满减优惠券 + private HashMap fullReductionCouponMap = new HashMap<>(); + // 商品优惠券 + private HashMap productCouponMap = new HashMap<>(); + private HashMap> couponMap = new HashMap<>(); +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/order/OrderPriceDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/order/OrderPriceDTO.java new file mode 100644 index 00000000..b7b4249a --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/order/OrderPriceDTO.java @@ -0,0 +1,20 @@ +package cn.ysk.cashier.dto.order; + +import cn.ysk.cashier.pojo.order.TbOrderDetail; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +@Data +public class OrderPriceDTO { + private BigDecimal originAmount = BigDecimal.ZERO; + private BigDecimal totalAmount = BigDecimal.ZERO; + private BigDecimal packAmount = BigDecimal.ZERO; + private boolean hasNewInfo = false; + private List newOrderDetailList = new ArrayList<>(); + private List removeOrderDetailList = new ArrayList<>(); + private List removeOrderDetailIds = new ArrayList<>(); + private List orderDetailList = new ArrayList<>(); +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/order/UserCouponInfoDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/order/UserCouponInfoDTO.java new file mode 100644 index 00000000..0266aeea --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/order/UserCouponInfoDTO.java @@ -0,0 +1,12 @@ +package cn.ysk.cashier.dto.order; + +import lombok.Data; + +import javax.validation.constraints.Min; + +@Data +public class UserCouponInfoDTO { + private Integer userCouponId; + @Min(1) + private Integer num; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/points/OrderDeductionPointsDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/points/OrderDeductionPointsDTO.java new file mode 100644 index 00000000..d3bc3ae2 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/points/OrderDeductionPointsDTO.java @@ -0,0 +1,65 @@ +package cn.ysk.cashier.dto.points; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 获取会员可用积分 + * @author tankaikai + * @since 2024-10-26 11:40 + */ +@Data +public class OrderDeductionPointsDTO { + + /** + * 本单最多可抵扣多少积分 + */ + private Integer maxUsablePoints; + /** + * 根据策略计算出的最少可以抵扣的金额 + */ + private BigDecimal minDeductionAmount; + /** + * 根据策略计算出的最多可以抵扣的金额 + */ + private BigDecimal maxDeductionAmount; + /** + * 下单实付抵扣门槛(实付金额不低于这个值) + */ + private BigDecimal minPaymentAmount; + /** + * 下单积分抵扣门槛(每次使用不低于这个值) + */ + private Integer minDeductionPoints; + /** + * 会员账户积分 + */ + private Integer accountPoints; + /** + * 订单金额 (扣除各类折扣) + */ + private BigDecimal orderAmount; + /** + * 使用的积分数量 + */ + private Integer usedPoints; + /** + * 实际抵扣的金额 + */ + private Integer deductionAmount; + /** + * 下单抵扣积分比例 1元=?积分 + */ + private Integer equivalentPoints; + /** + * 不可抵扣原因 + */ + private String unusableReason; + /** + * 是否可用 + */ + private Boolean usable; + + +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/PadProductCategoryDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/PadProductCategoryDTO.java new file mode 100644 index 00000000..6868a2ce --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/PadProductCategoryDTO.java @@ -0,0 +1,89 @@ +package cn.ysk.cashier.dto.product; + +import cn.ysk.cashier.pojo.product.TbProduct; +import lombok.Data; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * Pad商品自定义分类 + * + * @author tankaikai + * @since 2024-10-22 17:07 + */ +@Data +public class PadProductCategoryDTO implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + private Long id; + /** + * 布局版式id + */ + private Long padLayoutId; + + /** + * 自定义名称 + */ + private String customName; + /** + * 商品分类id + */ + private Long productCategoryId; + /** + * 店铺id + */ + private Long shopId; + /** + * 排序 + */ + private Integer sort; + /** + * 备注 + */ + private String remark; + /** + * 创建时间 + */ + private Date createTime; + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 商品名称 + */ + private String productNames; + + /** + * 布局版式代码 + */ + private String padLayoutCode; + + /** + * 布局类型 + */ + private String padLayoutName; + + /** + * 分类名称 + */ + private String productCategoryName; + + /** + * 商品id列表 + */ + private List productIdList = new ArrayList<>(); + + /** + * 商品列表 + */ + private List productList = new ArrayList<>(); + +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/TbProductGroupDto.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/TbProductGroupDto.java index 5bb4eeba..7ef9a23c 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/TbProductGroupDto.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/TbProductGroupDto.java @@ -3,8 +3,6 @@ package cn.ysk.cashier.dto.product; import lombok.Data; import java.io.Serializable; -import java.time.LocalTime; -import java.time.format.DateTimeFormatter; import java.util.List; /** @@ -39,6 +37,11 @@ public class TbProductGroupDto implements Serializable { private String style; + /** + * 排序方式 0-默认; 1-价格从高到低; 2-销量由高到低; + */ + private String sortMode; + /** 排序 */ private Integer sort; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/TbProductStockOperateQueryCriteria.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/TbProductStockOperateQueryCriteria.java index 3630b8da..0f3e54b8 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/TbProductStockOperateQueryCriteria.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/TbProductStockOperateQueryCriteria.java @@ -15,9 +15,10 @@ */ package cn.ysk.cashier.dto.product; -import lombok.Data; -import java.util.List; import cn.ysk.cashier.annotation.Query; +import lombok.Data; + +import java.util.List; /** * @website https://eladmin.vip @@ -34,6 +35,12 @@ public class TbProductStockOperateQueryCriteria{ @Query(type = Query.Type.BETWEEN) private List createdAt; + @Query(type = Query.Type.IN) + private List type; + + @Query(type = Query.Type.EQUAL) + private String purveyorId; + private Integer page; private Integer size; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoDto.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoDto.java index a2b667d8..534f40af 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoDto.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoDto.java @@ -199,4 +199,7 @@ public class TbShopInfoDto implements Serializable { //程序码(零点八零首页) private String smallQrcode; private String paymentQrcode; + + private Integer isMemberPrice; + private String consumeColony; } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddCartDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddCartDTO.java index 15df583a..6e4d085b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddCartDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/AddCartDTO.java @@ -29,4 +29,6 @@ public class AddCartDTO { // 用餐类型 @NotBlank private String useType; + + private Integer vipUserId; } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/CreateOrderDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/CreateOrderDTO.java index 6cae5fd5..558fd8b8 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/CreateOrderDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/CreateOrderDTO.java @@ -1,9 +1,15 @@ package cn.ysk.cashier.dto.shoptable; +import cn.ysk.cashier.dto.order.UserCouponInfoDTO; import lombok.Data; +import org.springframework.validation.annotation.Validated; +import javax.validation.Valid; +import javax.validation.constraints.Min; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; +import java.util.ArrayList; +import java.util.List; @Data public class CreateOrderDTO { @@ -17,5 +23,11 @@ public class CreateOrderDTO { private Integer orderId; @NotEmpty private String useType; - private String vipUserId; + private Integer vipUserId; + // 使用的优惠券 + @Valid + private List userCouponInfos = new ArrayList<>(); + // 使用的积分抵扣数量 + private Integer pointsNum; + } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/PayDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/PayDTO.java index aafea9f8..74e34174 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/PayDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/PayDTO.java @@ -1,11 +1,15 @@ package cn.ysk.cashier.dto.shoptable; +import cn.ysk.cashier.dto.order.UserCouponInfoDTO; import lombok.Data; +import javax.validation.Valid; import javax.validation.constraints.Max; import javax.validation.constraints.Min; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; +import java.util.ArrayList; +import java.util.List; @Data public class PayDTO { @@ -20,6 +24,13 @@ public class PayDTO { private Double discount; private Integer vipUserId; private String code; - private String token; + // 使用的优惠券 + @Valid + private List userCouponInfos = new ArrayList<>(); + // 使用的积分抵扣数量 + private Integer pointsNum; + private Integer staffId; + private String loginName; + } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/ShopEatTypeInfoDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/ShopEatTypeInfoDTO.java index a472da78..b62e0c5d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/ShopEatTypeInfoDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/ShopEatTypeInfoDTO.java @@ -21,6 +21,7 @@ public class ShopEatTypeInfoDTO { private boolean isNoneTable; // 是否增加masterId private boolean isIncrMaterId; + private boolean isMemberPrice; private TbShopInfo shopInfo; private String useType; private Object shopId; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateVipDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateVipDTO.java index 693c2c76..ba1a6f0b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateVipDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/UpdateVipDTO.java @@ -13,7 +13,7 @@ public class UpdateVipDTO { private String tableId; @NotNull private String masterId; - + private Integer orderId; private Integer vipUserId; @NotNull @Range(min = 0, max = 1) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mapper/BotButtonConfigMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mapper/BotButtonConfigMapper.java deleted file mode 100644 index 73775b83..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mapper/BotButtonConfigMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.mapper; - -import cn.ysk.cashier.base.BaseMapper; -import cn.ysk.cashier.pojo.BotButtonConfig; -import cn.ysk.cashier.dto.BotButtonConfigDto; -import org.mapstruct.Mapper; -import org.mapstruct.ReportingPolicy; - -/** -* @website https://eladmin.vip -* @author admin -* @date 2023-10-31 -**/ -@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) -public interface BotButtonConfigMapper extends BaseMapper { - -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mapper/BotConfigMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mapper/BotConfigMapper.java deleted file mode 100644 index c7ec730b..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mapper/BotConfigMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.mapper; - -import cn.ysk.cashier.base.BaseMapper; -import cn.ysk.cashier.pojo.BotConfig; -import cn.ysk.cashier.dto.BotConfigDto; -import org.mapstruct.Mapper; -import org.mapstruct.ReportingPolicy; - -/** -* @website https://eladmin.vip -* @author admin -* @date 2023-10-31 -**/ -@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) -public interface BotConfigMapper extends BaseMapper { - -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mapper/BotUserFlowMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mapper/BotUserFlowMapper.java deleted file mode 100644 index bd547896..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mapper/BotUserFlowMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.mapper; - -import cn.ysk.cashier.base.BaseMapper; -import cn.ysk.cashier.pojo.BotUserFlow; -import cn.ysk.cashier.dto.BotUserFlowDto; -import org.mapstruct.Mapper; -import org.mapstruct.ReportingPolicy; - -/** -* @website https://eladmin.vip -* @author admin -* @date 2023-10-30 -**/ -@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) -public interface BotUserFlowMapper extends BaseMapper { - -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mapper/BotUserMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mapper/BotUserMapper.java deleted file mode 100644 index 40cbe449..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mapper/BotUserMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.mapper; - -import cn.ysk.cashier.base.BaseMapper; -import cn.ysk.cashier.pojo.BotUser; -import cn.ysk.cashier.dto.BotUserDto; -import org.mapstruct.Mapper; -import org.mapstruct.ReportingPolicy; - -/** -* @website https://eladmin.vip -* @author admin -* @date 2023-10-30 -**/ -@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) -public interface BotUserMapper extends BaseMapper { - -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mapper/TbRenewalsPayLogMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mapper/TbRenewalsPayLogMapper.java deleted file mode 100644 index 63945c57..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mapper/TbRenewalsPayLogMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.mapper; - -import cn.ysk.cashier.base.BaseMapper; -import cn.ysk.cashier.pojo.TbRenewalsPayLog; -import cn.ysk.cashier.dto.TbRenewalsPayLogDto; -import org.mapstruct.Mapper; -import org.mapstruct.ReportingPolicy; - -/** -* @website https://eladmin.vip -* @author lyf -* @date 2023-11-07 -**/ -@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) -public interface TbRenewalsPayLogMapper extends BaseMapper { - -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mapper/shop/TbMerchantCouponMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mapper/shop/TbMerchantCouponMapper.java deleted file mode 100644 index 34b786c9..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mapper/shop/TbMerchantCouponMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.mapper.shop; - -import cn.ysk.cashier.base.BaseMapper; -import cn.ysk.cashier.pojo.shop.TbMerchantCoupon; -import cn.ysk.cashier.dto.shop.TbMerchantCouponDto; -import org.mapstruct.Mapper; -import org.mapstruct.ReportingPolicy; - -/** -* @website https://eladmin.vip -* @author lyf -* @date 2024-03-20 -**/ -@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) -public interface TbMerchantCouponMapper extends BaseMapper { - -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mapper/shop/TbReceiptSalesMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mapper/shop/TbReceiptSalesMapper.java deleted file mode 100644 index febd2c34..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mapper/shop/TbReceiptSalesMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.mapper.shop; - -import cn.ysk.cashier.base.BaseMapper; -import cn.ysk.cashier.pojo.shop.TbReceiptSales; -import cn.ysk.cashier.dto.shop.TbReceiptSalesDto; -import org.mapstruct.Mapper; -import org.mapstruct.ReportingPolicy; - -/** -* @website https://eladmin.vip -* @author lyf -* @date 2024-01-08 -**/ -@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) -public interface TbReceiptSalesMapper extends BaseMapper { - -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mapper/shop/TbShopCashSpreadMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mapper/shop/TbShopCashSpreadMapper.java deleted file mode 100644 index aabf892a..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mapper/shop/TbShopCashSpreadMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.mapper.shop; - -import cn.ysk.cashier.base.BaseMapper; -import cn.ysk.cashier.pojo.shop.TbShopCashSpread; -import cn.ysk.cashier.dto.shop.TbShopCashSpreadDto; -import org.mapstruct.Mapper; -import org.mapstruct.ReportingPolicy; - -/** -* @website https://eladmin.vip -* @author lyf -* @date 2024-01-05 -**/ -@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) -public interface TbShopCashSpreadMapper extends BaseMapper { - -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mapper/shop/TbShopCurrencyMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mapper/shop/TbShopCurrencyMapper.java deleted file mode 100644 index 6ad1878c..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mapper/shop/TbShopCurrencyMapper.java +++ /dev/null @@ -1,32 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.mapper.shop; - -import cn.ysk.cashier.base.BaseMapper; -import cn.ysk.cashier.pojo.shop.TbShopCurrency; -import cn.ysk.cashier.dto.shop.TbShopCurrencyDto; -import org.mapstruct.Mapper; -import org.mapstruct.ReportingPolicy; - -/** -* @website https://eladmin.vip -* @author lyf -* @date 2024-01-05 -**/ -@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) -public interface TbShopCurrencyMapper extends BaseMapper { - -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/Activate.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/Activate.java deleted file mode 100644 index 214a96ee..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/Activate.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.ysk.cashier.mybatis.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.activerecord.Model; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.math.BigDecimal; -import java.util.List; - -@Data -@EqualsAndHashCode(callSuper = true) -@TableName("tb_activate") -public class Activate extends Model { - private static final long serialVersionUID = 1L; - @TableId(type = IdType.AUTO) - private Integer id; - private Integer shopId; - private Integer minNum; - private Integer maxNum; - private BigDecimal handselNum; - private String handselType; - private String isDel; - //是否赠送商品 0否 1是 - private Integer isGiftPro; - @TableField(exist = false) - private List products; -} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbActivate.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbActivate.java index 68a4c144..d3596a4c 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbActivate.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbActivate.java @@ -1,44 +1,127 @@ package cn.ysk.cashier.mybatis.entity; -import lombok.Getter; -import lombok.Setter; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.FieldStrategy; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.extension.activerecord.Model; -import javax.persistence.*; -import javax.validation.constraints.Size; -import java.math.BigDecimal; +import java.util.Date; + +@SuppressWarnings("serial") +public class TbActivate extends Model { -@Getter -@Setter -@Entity -@Table(name = "tb_activate") -public class TbActivate { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id", nullable = false) private Integer id; - @Column(name = "shop_id") private Integer shopId; + //充值金额 + private Integer amount; + //赠送金额 + private Integer giftAmount; + //赠送积分 + @TableField(updateStrategy = FieldStrategy.ALWAYS) + private Integer giftPoints; + //是否使用优惠卷 0否 1是 + private Integer isUseCoupon; + //优惠卷id + @TableField(updateStrategy = FieldStrategy.ALWAYS) + private Integer couponId; + @TableField(exist = false) + private String couponName; + //优惠卷数量 + private Integer num; - @Column(name = "min_num") - private Integer minNum; + @TableField(fill = FieldFill.INSERT) + private Date createTime; + @TableField(fill = FieldFill.UPDATE) + private Date updateTime; - @Column(name = "max_num") - private Integer maxNum; - @Column(name = "handsel_num", precision = 10, scale = 2) - private BigDecimal handselNum; + public Integer getId() { + return id; + } - @Size(max = 20) - @Column(name = "handsel_type", length = 20) - private String handselType; + public void setId(Integer id) { + this.id = id; + } - @Size(max = 20) - @Column(name = "is_del", length = 20) - private String isDel; + public Integer getShopId() { + return shopId; + } - @Size(max = 255) - @Column(name = "is_user") - private String isUser; + public void setShopId(Integer shopId) { + this.shopId = shopId; + } + public Integer getAmount() { + return amount; + } + + public void setAmount(Integer amount) { + this.amount = amount; + } + + public Integer getGiftAmount() { + return giftAmount; + } + + public void setGiftAmount(Integer giftAmount) { + this.giftAmount = giftAmount; + } + + public Integer getIsUseCoupon() { + return isUseCoupon; + } + + public void setIsUseCoupon(Integer isUseCoupon) { + this.isUseCoupon = isUseCoupon; + } + + public Integer getCouponId() { + return couponId; + } + + public void setCouponId(Integer couponId) { + this.couponId = couponId; + } + + public String getCouponName() { + return couponName; + } + + public void setCouponName(String couponName) { + this.couponName = couponName; + } + + public Integer getNum() { + return num; + } + + public void setNum(Integer num) { + this.num = num; + } + + 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 Integer getGiftPoints() { + return giftPoints; + } + + public void setGiftPoints(Integer giftPoints) { + this.giftPoints = giftPoints; + } } + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbActivateInRecord.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbActivateInRecord.java index 06e25bcc..2d5c0691 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbActivateInRecord.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbActivateInRecord.java @@ -1,25 +1,40 @@ package cn.ysk.cashier.mybatis.entity; +import java.math.BigDecimal; import java.util.Date; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.extension.activerecord.Model; +import lombok.Data; import java.io.Serializable; /** - * 活动商品赠送表(TbActivateInRecord)表实体类 + * 活动商品赠送记录表(TbActivateInRecord)表实体类 * * @author ww - * @since 2024-08-22 14:50:16 + * @since 2024-11-08 09:53:21 */ +@Data @SuppressWarnings("serial") public class TbActivateInRecord extends Model { private Integer id; //会员id private Integer vipUserId; + //卷Id (校验是否可用) + private Integer couponId; + //卷描述 满10减2/商品卷 + private String name; + //1-满减 2-商品 + private Integer type; //商品id private Integer proId; + //满多少金额 + private BigDecimal fullAmount; + //减多少金额 + private BigDecimal discountAmount; //赠送数量 private Integer num; //未使用数量 @@ -30,90 +45,17 @@ public class TbActivateInRecord extends Model { private Integer sourceActId; private Integer sourceFlowId; - + //可用开始时间 + private Date useStartTime; + //可用结束时间 + private Date useEndTime; + @TableField(fill = FieldFill.INSERT) private Date createTime; - + @TableField(fill = FieldFill.UPDATE) private Date updateTime; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Integer getVipUserId() { - return vipUserId; - } - - public void setVipUserId(Integer vipUserId) { - this.vipUserId = vipUserId; - } - - public Integer getProId() { - return proId; - } - - public void setProId(Integer proId) { - this.proId = proId; - } - - public Integer getNum() { - return num; - } - - public void setNum(Integer num) { - this.num = num; - } - - public Integer getOverNum() { - return overNum; - } - - public void setOverNum(Integer overNum) { - this.overNum = overNum; - } - - public Integer getShopId() { - return shopId; - } - - public void setShopId(Integer shopId) { - this.shopId = shopId; - } - - public Integer getSourceActId() { - return sourceActId; - } - - public void setSourceActId(Integer sourceActId) { - this.sourceActId = sourceActId; - } - - public Integer getSourceFlowId() { - return sourceFlowId; - } - - public void setSourceFlowId(Integer sourceFlowId) { - this.sourceFlowId = sourceFlowId; - } - - 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; - } + private String couponJson; + //invited/activate + private String source; } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbActivateOutRecord.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbActivateOutRecord.java index fc57add8..f050b14a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbActivateOutRecord.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbActivateOutRecord.java @@ -2,6 +2,8 @@ package cn.ysk.cashier.mybatis.entity; import java.util.Date; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.extension.activerecord.Model; import java.io.Serializable; @@ -10,27 +12,32 @@ import java.io.Serializable; * 活动赠送商品使用记录表(TbActivateOutRecord)表实体类 * * @author ww - * @since 2024-08-22 14:53:52 + * @since 2024-10-23 09:50:40 */ @SuppressWarnings("serial") public class TbActivateOutRecord extends Model { private Integer id; - //商品赠送Id + + private Integer shopId; + //订单id + private String orderId; + //商品赠送Id tb_activate_in_record的id private Integer giveId; - //商品id - private Integer proId; - //未使用数量 + //会员id + private Integer vipUserId; + //1-满减 2-商品 + private Integer type; + //使用数量 private Integer useNum; //退单量 private Integer refNum; - //订单id - private String orderId; //新建: create, 完成: closed, 取消:cancel, private String status; + @TableField(fill = FieldFill.INSERT) private Date createTime; - + @TableField(fill = FieldFill.UPDATE) private Date updateTime; @@ -42,6 +49,22 @@ public class TbActivateOutRecord extends Model { this.id = id; } + public Integer getShopId() { + return shopId; + } + + public void setShopId(Integer shopId) { + this.shopId = shopId; + } + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + public Integer getGiveId() { return giveId; } @@ -50,12 +73,20 @@ public class TbActivateOutRecord extends Model { this.giveId = giveId; } - public Integer getProId() { - return proId; + public Integer getVipUserId() { + return vipUserId; } - public void setProId(Integer proId) { - this.proId = proId; + public void setVipUserId(Integer vipUserId) { + this.vipUserId = vipUserId; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; } public Integer getUseNum() { @@ -74,14 +105,6 @@ public class TbActivateOutRecord extends Model { this.refNum = refNum; } - public String getOrderId() { - return orderId; - } - - public void setOrderId(String orderId) { - this.orderId = orderId; - } - public String getStatus() { return status; } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbActivateProduct.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbActivateProduct.java deleted file mode 100644 index 952423a4..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbActivateProduct.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.ysk.cashier.mybatis.entity; - -import java.util.Date; - -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.extension.activerecord.Model; - -import java.io.Serializable; - -/** - * 活动赠送商品表(TbActivateProduct)表实体类 - * - * @author ww - * @since 2024-08-20 11:27:40 - */ -@SuppressWarnings("serial") -public class TbActivateProduct extends Model { - - private Integer id; - //活动Id - private Integer activateId; - //商品id - private Integer productId; - //数量 - private Integer num; - - @TableField(fill = FieldFill.INSERT) - private Date createTime; - - @TableField(fill = FieldFill.UPDATE) - private Date updateTime; - - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Integer getActivateId() { - return activateId; - } - - public void setActivateId(Integer activateId) { - this.activateId = activateId; - } - - public Integer getProductId() { - return productId; - } - - public void setProductId(Integer productId) { - this.productId = productId; - } - - public Integer getNum() { - return num; - } - - public void setNum(Integer num) { - this.num = num; - } - - 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; - } -} - diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCouponProduct.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCouponProduct.java new file mode 100644 index 00000000..9a3273f3 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbCouponProduct.java @@ -0,0 +1,40 @@ +package cn.ysk.cashier.mybatis.entity; + +import java.util.Date; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import lombok.Data; + +import java.io.Serializable; + +/** + * 活动赠送商品表(TbActivateProduct)表实体类 + * + * @author ww + * @since 2024-08-20 11:27:40 + */ +@Data +@SuppressWarnings("serial") +public class TbCouponProduct extends Model { + private Integer id; + //活动Id + private Integer couponId; + //商品id + private Integer productId; + //数量 + private Integer num; + @TableField(exist = false) + private String name; + @TableField(exist = false) + private String coverImg; + + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + @TableField(fill = FieldFill.UPDATE) + private Date updateTime; + +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbMemberPoints.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbMemberPoints.java new file mode 100644 index 00000000..475ecce7 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbMemberPoints.java @@ -0,0 +1,72 @@ +package cn.ysk.cashier.mybatis.entity; + +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 会员积分 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("tb_shop_user") +public class TbMemberPoints { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + /** + * 店铺id + */ + private Long shopId; + /** + * 会员id + */ + @TableField(value = "id", insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER) + private Long memberId; + /** + * 会员名称 + */ + @TableField("name") + private String memberName; + /** + * 会员头像 + */ + @TableField("head_img") + private String avatarUrl; + /** + * 手机号码 + */ + @TableField("telephone") + private String mobile; + /** + * 账户积分 + */ + @TableField("account_points") + private Integer accountPoints; + /** + * 最近一次积分变动时间 + */ + @TableField("last_points_change_time") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date lastPointsChangeTime; + /** + * 最近一次浮动积分 + */ + @TableField("last_float_points") + private Integer lastFloatPoints; + /** + * 是否会员 1-是 0-否 + */ + @TableField("is_vip") + private Integer vip; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbMemberPointsLog.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbMemberPointsLog.java new file mode 100644 index 00000000..c1ed711b --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbMemberPointsLog.java @@ -0,0 +1,70 @@ +package cn.ysk.cashier.mybatis.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 会员积分变动记录 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("tb_member_points_log") +public class TbMemberPointsLog { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + /** + * 店铺id + */ + private Long shopId; + /** + * 会员id + */ + private Long memberId; + /** + * 会员名称 + */ + private String memberName; + /** + * 会员头像 + */ + private String avatarUrl; + /** + * 摘要信息(如:兑换某个商品/消费多少钱/充值多少钱/新会员赠送积分等) + */ + private String content; + /** + * 订单编号 + */ + private String orderNo; + /** + * 手机号码 + */ + private String mobile; + /** + * 浮动类型 add-累加 subtract-扣减 + */ + private String floatType; + /** + * 浮动积分(非0正负数) + */ + private Integer floatPoints; + /** + * 创建时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date createTime; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbPointsBasicSetting.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbPointsBasicSetting.java new file mode 100644 index 00000000..a7bce867 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbPointsBasicSetting.java @@ -0,0 +1,79 @@ +package cn.ysk.cashier.mybatis.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 积分基本设置 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("tb_points_basic_setting") +public class TbPointsBasicSetting { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + /** + * 店铺id + */ + private Long shopId; + /** + * 开启消费赠送积分 1-开启 0-关闭 + */ + private Integer enableRewards; + /** + * 赠积分适用群体 all-全部 vip-仅会员 + */ + private String rewardsGroup; + /** + * 每消费xx元赠送1积分 + */ + private BigDecimal consumeAmount; + /** + * 开启下单积分抵扣 1-开启 0-关闭 + */ + private Integer enableDeduction; + /** + * 抵扣适用群体 all-全部 vip-仅会员 + */ + private String deductionGroup; + /** + * 下单实付抵扣门槛 + */ + private BigDecimal minPaymentAmount; + /** + * 下单最高抵扣比例 + */ + private BigDecimal maxDeductionRatio; + /** + * 下单抵扣积分比例 1元=?积分 + */ + private Integer equivalentPoints; + /** + * 开启积分商城 1-开启 0-关闭 + */ + private Integer enablePointsMall; + /** + * 浏览模式 list-列表 grid-宫格 + */ + private String browseMode; + /** + * 创建时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date createTime; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbPointsExchangeRecord.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbPointsExchangeRecord.java new file mode 100644 index 00000000..ff1612b6 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbPointsExchangeRecord.java @@ -0,0 +1,152 @@ +package cn.ysk.cashier.mybatis.entity; + +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 积分兑换记录 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName("tb_points_exchange_record") +public class TbPointsExchangeRecord { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + /** + * 订单编号 + */ + private String orderNo; + /** + * 店铺id + */ + private Long shopId; + /** + * 积分商品id + */ + private Long pointsGoodsId; + /** + * 积分商品名称 + */ + private String pointsGoodsName; + /** + * 商品图片URL + */ + private String goodsImageUrl; + /** + * 领取方式 self-自取 post-邮寄 + */ + private String pickupMethod; + /** + * 会员id + */ + private Long memberId; + /** + * 会员名称 + */ + private String memberName; + /** + * 手机号码 + */ + private String mobile; + /** + * 会员头像 + */ + private String avatarUrl; + /** + * 消耗积分 + */ + private Integer spendPoints; + /** + * 额外支付 + */ + private BigDecimal extraPaymentAmount; + /** + * 兑换券券码 + */ + private String couponCode; + /** + * 支付平台订单号 + */ + private String payOrderId; + /** + * 渠道订单号(微信/支付宝订单号) + */ + private String channelTradeNo; + /** + * 支付方式 积分支付/积分+微信/积分+支付宝 + */ + private String payMethod; + /** + * 支付类型 POINTS-积分 WECHAT-微信 ALIPAY-支付宝 UNIONPAY-银联云闪付 + */ + private String payType; + /** + * 状态 unpaid-待支付 waiting-待自取 done-已完成 cancel-已取消 + */ + private String status; + /** + * 取消/退款原因 + */ + private String cancelOrRefundReason; + /** + * 取消/退款时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date cancelOrRefundTime; + /** + * 实际支付时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date payTime; + /** + * 创建时间(下单时间) + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date createTime; + /** + * 更新时间(核销时间) + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date updateTime; + + @TableField(value = "count(*)", select = false, insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER) + private Long count; + + @TableField(value = "sum(extra_payment_amount)", select = false, insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER) + private BigDecimal totalAmount; + + /** + * 用户ip + */ + @JsonIgnore + @TableField(exist = false) + private String ip; + + /** + * 微信openId/支付完userId + */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + @TableField(exist = false) + private String openId; + + /** + * 拉起支付所需信息 + */ + @TableField(exist = false) + private String payInfo; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbPointsGoodsSetting.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbPointsGoodsSetting.java new file mode 100644 index 00000000..172da2ba --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbPointsGoodsSetting.java @@ -0,0 +1,89 @@ +package cn.ysk.cashier.mybatis.entity; + + +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 积分商品设置 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName("tb_points_goods_setting") +public class TbPointsGoodsSetting { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + /** + * 店铺id + */ + private Long shopId; + /** + * 商品类型 physical-实物 coupon-优惠劵 + */ + private String goodsCategory; + /** + * 商品名称 + */ + private String goodsName; + /** + * 商品图片URL + */ + @TableField(value = "goods_image_url", updateStrategy = FieldStrategy.ALWAYS) + private String goodsImageUrl; + /** + * 所需积分 + */ + private Integer requiredPoints; + /** + * 额外价格 + */ + private BigDecimal extraPrice; + /** + * 排序(权重),数字越高,显示约靠前 + */ + private Integer sort; + /** + * 数量 + */ + private Integer quantity; + /** + * 商品详情 + */ + @TableField(value = "goods_description", updateStrategy = FieldStrategy.ALWAYS) + private String goodsDescription; + /** + * 累计兑换数量 + */ + private Integer totalExchangeCount; + /** + * 是否上架 1-是 0-否 + */ + private Integer status; + /** + * 创建时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date createTime; + /** + * 更新时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date updateTime; + /** + * 逻辑删除标志 1-是 0-否 + */ + private Integer delFlag; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopCoupon.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopCoupon.java new file mode 100644 index 00000000..7bcd9aae --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopCoupon.java @@ -0,0 +1,254 @@ +package cn.ysk.cashier.mybatis.entity; + +import java.math.BigDecimal; +import java.time.LocalTime; +import java.util.Date; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.extension.activerecord.Model; + +import java.io.Serializable; + +/** + * 优惠券(TbShopCoupon)表实体类 + * + * @author ww + * @since 2024-10-24 13:54:34 + */ +@SuppressWarnings("serial") +public class TbShopCoupon extends Model { + //自增 + private Integer id; + + private String shopId; + //名称(无意义) + private String title; + //1-满减 2-商品 + private Integer type; + //满多少金额 + private BigDecimal fullAmount; + //减多少金额 + private BigDecimal discountAmount; + //描述 + private String description; + //发放数量 + private Integer number; + //剩余数量 + private Integer leftNumber; + //有效期类型,可选值为 fixed(固定时间)/custom(自定义时间) + private String validityType; + //有效天数 + private Integer validDays; + //隔多少天生效 + private Integer daysToTakeEffect; + //有效开始时间 + private Date validStartTime; + //有效结束时间 + private Date validEndTime; + //周 数组["周一","周二"] + private String userDays; + //all-全时段 custom-指定时段 + private String useTimeType; + //可用开始时间 + private LocalTime useStartTime; + //可用结束时间 + private LocalTime useEndTime; + //已使用数量 + private Integer useNumber; + //发放人 + private String editor; + //状态0-关闭 1 正常 + private Integer status; + + @TableField(fill = FieldFill.INSERT) + private Date createTime; + @TableField(fill = FieldFill.UPDATE) + private Date updateTime; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getShopId() { + return shopId; + } + + public void setShopId(String shopId) { + this.shopId = shopId; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public BigDecimal getFullAmount() { + return fullAmount; + } + + public void setFullAmount(BigDecimal fullAmount) { + this.fullAmount = fullAmount; + } + + public BigDecimal getDiscountAmount() { + return discountAmount; + } + + public void setDiscountAmount(BigDecimal discountAmount) { + this.discountAmount = discountAmount; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Integer getNumber() { + return number; + } + + public void setNumber(Integer number) { + this.number = number; + } + + public Integer getLeftNumber() { + return leftNumber; + } + + public void setLeftNumber(Integer leftNumber) { + this.leftNumber = leftNumber; + } + + public String getValidityType() { + return validityType; + } + + public void setValidityType(String validityType) { + this.validityType = validityType; + } + + public Integer getValidDays() { + return validDays; + } + + public void setValidDays(Integer validDays) { + this.validDays = validDays; + } + + public Integer getDaysToTakeEffect() { + return daysToTakeEffect; + } + + public void setDaysToTakeEffect(Integer daysToTakeEffect) { + this.daysToTakeEffect = daysToTakeEffect; + } + + public Date getValidStartTime() { + return validStartTime; + } + + public void setValidStartTime(Date validStartTime) { + this.validStartTime = validStartTime; + } + + public Date getValidEndTime() { + return validEndTime; + } + + public void setValidEndTime(Date validEndTime) { + this.validEndTime = validEndTime; + } + + public String getUserDays() { + return userDays; + } + + public void setUserDays(String userDays) { + this.userDays = userDays; + } + + public String getUseTimeType() { + return useTimeType; + } + + public void setUseTimeType(String useTimeType) { + this.useTimeType = useTimeType; + } + + public LocalTime getUseStartTime() { + return useStartTime; + } + + public void setUseStartTime(LocalTime useStartTime) { + this.useStartTime = useStartTime; + } + + public LocalTime getUseEndTime() { + return useEndTime; + } + + public void setUseEndTime(LocalTime useEndTime) { + this.useEndTime = useEndTime; + } + + public Integer getUseNumber() { + return useNumber; + } + + public void setUseNumber(Integer useNumber) { + this.useNumber = useNumber; + } + + public String getEditor() { + return editor; + } + + public void setEditor(String editor) { + this.editor = editor; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + 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; + } +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopExtend.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopExtend.java index 365b94f5..62c6014b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopExtend.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopExtend.java @@ -150,6 +150,12 @@ public class TbShopExtend extends Model { this.value = "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/shopDetails/topBanner.png"; this.title = "商品列表"; break; + case "ticket_logo": + this.name = "小票logo图"; + this.detail="建议尺寸: 417*139"; + this.value = "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20241022/eeee8e85c66947e5bcaebf687381b5d6.png"; + this.title = "小票logo"; + break; } } this.type="img"; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopShare.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopShare.java new file mode 100644 index 00000000..757bba78 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopShare.java @@ -0,0 +1,98 @@ +package cn.ysk.cashier.mybatis.entity; + +import java.util.Date; + +import cn.hutool.core.collection.CollectionUtil; +import cn.ysk.cashier.utils.JSONUtil; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import lombok.Data; +import org.apache.commons.lang3.StringUtils; + +import java.io.Serializable; +import java.util.List; + +/** + * 店铺分享(TbShopShare)表实体类 + * + * @author ww + * @since 2024-11-06 15:47:37 + */ +@Data +@SuppressWarnings("serial") +public class TbShopShare extends Model { + + @TableId(type = IdType.AUTO) + private Integer id; + //店铺Id + private Integer shopId; + //标题 + private String title; + //分享封面图 + private String shareImg; + //邀请顶部图 + private String invitedImg; + //被邀顶部图 + private String beInvitedImg; + //活动开始时间 + private Date startTime; + //活动结束时间 + private Date endTime; + //新用户获得券 + private String newCoupon; + //邀请num人数 可获奖励券 + private Integer invitedNum; + //奖励券 + private String rewardCoupon; + //获取方法 get-新用户领取获得 use-新用户使用获得 + private String getMethod; + + private Integer status; + + @TableField(exist = false) + private List newCoupons; + + @TableField(exist = false) + private List rewardCoupons; + + public void setNewCoupon(String newCoupon) { + this.newCoupon = newCoupon; + if(StringUtils.isNotBlank(newCoupon)){ + this.newCoupons = JSONUtil.parseJSONStrTList(newCoupon,ShareCoupons.class); + } + } + + public void setRewardCoupon(String rewardCoupon) { + this.rewardCoupon = rewardCoupon; + if(StringUtils.isNotBlank(rewardCoupon)){ + this.rewardCoupons = JSONUtil.parseJSONStrTList(rewardCoupon,ShareCoupons.class); + } + } + + public void setNewCoupons(List newCoupons) { + this.newCoupons = newCoupons; + if(CollectionUtil.isNotEmpty(newCoupons)){ + this.newCoupon = JSONUtil.toJSONString(newCoupons); + } + } + + public void setRewardCoupons(List rewardCoupons) { + this.rewardCoupons = rewardCoupons; + if(CollectionUtil.isNotEmpty(rewardCoupons)){ + this.rewardCoupon = JSONUtil.toJSONString(rewardCoupons); + } + } + + @Data + public static class ShareCoupons { + //优惠券Id + private Integer couponId; + //优惠券名称 + private String couponName; + //优惠券数量 + private Integer couponNum; + } +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopShareRecord.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopShareRecord.java new file mode 100644 index 00000000..087f44d5 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopShareRecord.java @@ -0,0 +1,54 @@ +package cn.ysk.cashier.mybatis.entity; + +import java.util.Date; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import lombok.Data; + +import java.io.Serializable; + +/** + * (TbShopShareRecord)表实体类 + * + * @author ww + * @since 2024-11-08 09:17:37 + */ +@Data +@SuppressWarnings("serial") +public class TbShopShareRecord extends Model { + + private Integer id; + //tb_shop_share 主键Id + private Integer shareId; + //店铺Id + private Integer shopId; + + @TableField(exist = false) + private String invitedHeadImg; + //邀请人id + private Integer invitedId; + //邀请人名称 + private String invitedName; + + @TableField(exist = false) + private String beInvitedHeadImg; + //被邀请人Id + private Integer beInvitedId; + + @TableField(exist = false) + private String beInvitedName; + //奖励券获得方式 get/use 领取获得/使用获得 + private String method; + //0 非新用户 1 未领取 2 已领取 3 已使用 + private Integer status; + //生效时间/获得奖励的时间 + private Date rewardTime; + + private Date createTime; + + private Date updateTime; + + +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbUserStorage.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbUserStorage.java deleted file mode 100644 index 1fc09db8..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbUserStorage.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.ysk.cashier.mybatis.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.activerecord.Model; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.util.Date; - -@Data -@EqualsAndHashCode(callSuper = true) -@TableName("tb_user_storage") -public class TbUserStorage extends Model { - private static final long serialVersionUID = 1L; - @TableId(type = IdType.ASSIGN_UUID) - private String id; // 记录ID - private Integer userId; // 用户ID - private String shopId; // 用户ID - private Integer productId; - private Integer num; - private Integer outNum; - private Integer inNum; - private Date createTime; - private String account; - private String unit; - private String productName; - private Integer skuId; - private String skuName; - private String imgUrl; -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/ActivateMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/ActivateMapper.java deleted file mode 100644 index cadddeab..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/ActivateMapper.java +++ /dev/null @@ -1,9 +0,0 @@ -package cn.ysk.cashier.mybatis.mapper; - -import cn.ysk.cashier.mybatis.entity.Activate; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; - -public interface ActivateMapper extends BaseMapper { - - -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/ShopUserMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/ShopUserMapper.java index e3d0f92d..1a418c64 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/ShopUserMapper.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/ShopUserMapper.java @@ -15,7 +15,7 @@ public interface ShopUserMapper extends BaseMapper { @Select("") + List queActByCouponId(@Param("couponId") Integer couponId); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbActivateOutRecordMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbActivateOutRecordMapper.java index a66d9579..59ff3064 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbActivateOutRecordMapper.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbActivateOutRecordMapper.java @@ -2,6 +2,9 @@ package cn.ysk.cashier.mybatis.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; /** * 活动赠送商品使用记录表(TbActivateOutRecord)表数据库访问层 @@ -11,5 +14,9 @@ import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord; */ public interface TbActivateOutRecordMapper extends BaseMapper { + @Update("update tb_activate_out_record" + + " set ref_num = ref_num + #{refNum}" + + " where id = #{id}") + int updateRefNum(@Param("id") Integer id, @Param("refNum") Integer refNum); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbActivateProductMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbActivateProductMapper.java deleted file mode 100644 index 71e3d676..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbActivateProductMapper.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.ysk.cashier.mybatis.mapper; - -import cn.ysk.cashier.mybatis.entity.TbActivateProduct; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; - -/** - * 活动赠送商品表(TbActivateProduct)表数据库访问层 - * - * @author ww - * @since 2024-08-20 11:27:40 - */ -public interface TbActivateProductMapper extends BaseMapper { - -} - diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCouponProductMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCouponProductMapper.java new file mode 100644 index 00000000..8fe3939b --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCouponProductMapper.java @@ -0,0 +1,26 @@ +package cn.ysk.cashier.mybatis.mapper; + +import cn.ysk.cashier.mybatis.entity.TbCouponProduct; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; + +/** + * 活动赠送商品表(TbActivateProduct)表数据库访问层 + * + * @author ww + * @since 2024-08-20 11:27:40 + */ +public interface TbCouponProductMapper extends BaseMapper { + + + @Select(" select " + + " *" + + " from tb_coupon_product " + + " where " + + " coupon_id = #{couponId}") + List queryAllByCouponId(@Param("couponId") Integer couponId); +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbMemberPointsLogMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbMemberPointsLogMapper.java new file mode 100644 index 00000000..b8d16e6d --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbMemberPointsLogMapper.java @@ -0,0 +1,16 @@ +package cn.ysk.cashier.mybatis.mapper; + +import cn.ysk.cashier.mybatis.entity.TbMemberPointsLog; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * 会员积分变动记录 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Mapper +public interface TbMemberPointsLogMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbMemberPointsMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbMemberPointsMapper.java new file mode 100644 index 00000000..141b564b --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbMemberPointsMapper.java @@ -0,0 +1,16 @@ +package cn.ysk.cashier.mybatis.mapper; + +import cn.ysk.cashier.mybatis.entity.TbMemberPoints; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * 会员积分 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Mapper +public interface TbMemberPointsMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPadLayoutMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPadLayoutMapper.java new file mode 100644 index 00000000..f01e7879 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPadLayoutMapper.java @@ -0,0 +1,16 @@ +package cn.ysk.cashier.mybatis.mapper; + +import cn.ysk.cashier.pojo.product.TbPadLayout; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** +* Pad商品布局版式 +* +* @author Tankaikai tankaikai@aliyun.com +* @since 2.0 2024-10-22 +*/ +@Mapper +public interface TbPadLayoutMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPadProductCategoryDetailMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPadProductCategoryDetailMapper.java new file mode 100644 index 00000000..bae5b410 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPadProductCategoryDetailMapper.java @@ -0,0 +1,16 @@ +package cn.ysk.cashier.mybatis.mapper; + +import cn.ysk.cashier.pojo.product.TbPadProductCategoryDetail; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** +* Pad商品自定义分类明细 +* +* @author Tankaikai tankaikai@aliyun.com +* @since 2.0 2024-10-22 +*/ +@Mapper +public interface TbPadProductCategoryDetailMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPadProductCategoryMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPadProductCategoryMapper.java new file mode 100644 index 00000000..ea45da32 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPadProductCategoryMapper.java @@ -0,0 +1,22 @@ +package cn.ysk.cashier.mybatis.mapper; + +import cn.ysk.cashier.dto.product.PadProductCategoryDTO; +import cn.ysk.cashier.pojo.product.TbPadProductCategory; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; +import java.util.Map; + +/** +* Pad商品自定义分类 +* +* @author Tankaikai tankaikai@aliyun.com +* @since 2.0 2024-10-22 +*/ +@Mapper +public interface TbPadProductCategoryMapper extends BaseMapper { + + List findList(Map params); + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPointsBasicSettingMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPointsBasicSettingMapper.java new file mode 100644 index 00000000..ea144fd2 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPointsBasicSettingMapper.java @@ -0,0 +1,16 @@ +package cn.ysk.cashier.mybatis.mapper; + +import cn.ysk.cashier.mybatis.entity.TbPointsBasicSetting; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * 积分基本设置 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Mapper +public interface TbPointsBasicSettingMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPointsExchangeRecordMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPointsExchangeRecordMapper.java new file mode 100644 index 00000000..64d627f8 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPointsExchangeRecordMapper.java @@ -0,0 +1,16 @@ +package cn.ysk.cashier.mybatis.mapper; + +import cn.ysk.cashier.mybatis.entity.TbPointsExchangeRecord; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * 积分兑换记录 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Mapper +public interface TbPointsExchangeRecordMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPointsGoodsSettingMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPointsGoodsSettingMapper.java new file mode 100644 index 00000000..e22a76e7 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbPointsGoodsSettingMapper.java @@ -0,0 +1,16 @@ +package cn.ysk.cashier.mybatis.mapper; + +import cn.ysk.cashier.mybatis.entity.TbPointsGoodsSetting; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * 积分商品设置 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Mapper +public interface TbPointsGoodsSettingMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopCouponMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopCouponMapper.java new file mode 100644 index 00000000..7d415b2a --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopCouponMapper.java @@ -0,0 +1,59 @@ +package cn.ysk.cashier.mybatis.mapper; + +import cn.ysk.cashier.dto.QueryReceiveDto; +import cn.ysk.cashier.pojo.shop.TbFullShopId; +import cn.ysk.cashier.vo.QueryReceiveVo; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import cn.ysk.cashier.mybatis.entity.TbShopCoupon; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; + +/** + * 优惠券(TbShopCoupon)表数据库访问层 + * + * @author ww + * @since 2024-10-22 15:43:25 + */ +public interface TbShopCouponMapper extends BaseMapper { + + @Select("") + Page queryReceive(QueryReceiveDto param ,Page page); +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopShareMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopShareMapper.java new file mode 100644 index 00000000..54b3e894 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopShareMapper.java @@ -0,0 +1,15 @@ +package cn.ysk.cashier.mybatis.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import cn.ysk.cashier.mybatis.entity.TbShopShare; + +/** + * 店铺分享(TbShopShare)表数据库访问层 + * + * @author ww + * @since 2024-11-06 15:47:37 + */ +public interface TbShopShareMapper extends BaseMapper { + +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopShareRecordMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopShareRecordMapper.java new file mode 100644 index 00000000..a2a9db41 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopShareRecordMapper.java @@ -0,0 +1,46 @@ +package cn.ysk.cashier.mybatis.mapper; + +import cn.ysk.cashier.dto.TbShopShareRecordQueryCriteria; +import cn.ysk.cashier.vo.TbUserCouponVo; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import cn.ysk.cashier.mybatis.entity.TbShopShareRecord; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; + +/** + * (TbShopShareRecord)表数据库访问层 + * + * @author ww + * @since 2024-11-08 09:17:37 + */ +public interface TbShopShareRecordMapper extends BaseMapper { + + @Select("") + Page selectAllByShare(@Param("param") TbShopShareRecordQueryCriteria param, Page page); +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbUserStorageMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbUserStorageMapper.java deleted file mode 100644 index 2e175574..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbUserStorageMapper.java +++ /dev/null @@ -1,9 +0,0 @@ -package cn.ysk.cashier.mybatis.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import cn.ysk.cashier.mybatis.entity.TbUserStorage; - -public interface TbUserStorageMapper extends BaseMapper { - - -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/rest/StorageController.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/rest/StorageController.java index 09d2d775..22259154 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/rest/StorageController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/rest/StorageController.java @@ -1,15 +1,15 @@ package cn.ysk.cashier.mybatis.rest; import cn.ysk.cashier.annotation.Log; +import cn.ysk.cashier.dto.CouponDto; import cn.ysk.cashier.exception.BadRequestException; -import cn.ysk.cashier.mybatis.entity.Activate; -import cn.ysk.cashier.mybatis.service.ShopService; +import cn.ysk.cashier.mybatis.entity.TbActivate; +import cn.ysk.cashier.mybatis.service.TbActivateService; +import cn.ysk.cashier.mybatis.service.TbShopCouponService; import cn.ysk.cashier.service.WxService; import cn.ysk.cashier.utils.CacheKey; import cn.ysk.cashier.utils.RedisUtils; -import cn.ysk.cashier.utils.SecurityUtils; import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; @@ -17,6 +17,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; import java.util.Map; @Slf4j @@ -25,30 +26,28 @@ import java.util.Map; @Api(tags = "/shop/storage") @RequestMapping("/shop/storage") public class StorageController { - private final ShopService shopService; + + private final TbShopCouponService tbShopCouponService; + private final TbActivateService tbActivateService; private final RedisUtils redisUtils; private final WxService wxService; @GetMapping("/findActivate") public ResponseEntity findActivate(@RequestParam String shopId){ - String userName = SecurityUtils.getCurrentUsername(); - return new ResponseEntity<>(shopService.findActivate(shopId), HttpStatus.OK); + return new ResponseEntity<>(tbActivateService.findActivate(shopId), HttpStatus.OK); } @Log("修改活动数据") - @PostMapping("/modityActivate") - public ResponseEntity modityActivate(@RequestBody Activate activate){ - if (activate.getIsGiftPro() != null && activate.getIsGiftPro() == 1 && CollectionUtils.isEmpty(activate.getProducts())) - throw new BadRequestException("赠送商品不可为空"); - String userName = SecurityUtils.getCurrentUsername(); - shopService.modityActivate(activate); + @PostMapping("/upActivate") + public ResponseEntity upActivate(@RequestBody TbActivate activate){ + tbActivateService.modifyActivate(activate); return new ResponseEntity<>(HttpStatus.OK); } - @GetMapping("/activate/{activateId}") - @ApiOperation("查询活动赠送商品") - public ResponseEntity queryActivatePros(@PathVariable("activateId") Integer activateId){ - return new ResponseEntity<>(shopService.findActivatePros(activateId),HttpStatus.OK); + //获取订单可用优惠券 + @RequestMapping("find") + public ResponseEntity find(@RequestBody CouponDto param) { + return tbShopCouponService.find(param); } /** diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpCashierCartService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpCashierCartService.java index 43e679e2..0121bd73 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpCashierCartService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpCashierCartService.java @@ -1,6 +1,7 @@ package cn.ysk.cashier.mybatis.service; import cn.ysk.cashier.cons.TableConstant; +import cn.ysk.cashier.dto.shoptable.ShopEatTypeInfoDTO; import cn.ysk.cashier.enums.OrderStatusEnums; import cn.ysk.cashier.pojo.order.TbCashierCart; import com.baomidou.mybatisplus.extension.service.IService; @@ -55,5 +56,22 @@ public interface MpCashierCartService extends IService { * @param orderId 订单id */ boolean updateStateByOrderId(TableConstant.OrderInfo.Status status, Integer orderId); + + /** + * 根据店就餐模式查询购物车 + * @param shopEatTypeInfoDTO 就餐模式 + * @return 购物车信息 + */ + List selectByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId); + + /** + * 根据订单id和状态获取购物车数据 + * @param orderId 订单id + * @param status 状态 可为空 + */ + List selectByOrderIdAndState(Integer orderId, TableConstant.OrderInfo.Status... status); + + + boolean updateMemberAndAmountByOrderId(Integer orderId, boolean isMember); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderDetailService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderDetailService.java index 8d766da5..4c1b57ab 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderDetailService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderDetailService.java @@ -1,5 +1,6 @@ package cn.ysk.cashier.mybatis.service; +import cn.ysk.cashier.cons.TableConstant; import cn.ysk.cashier.dto.shoptable.ReturnOrderDTO; import cn.ysk.cashier.enums.OrderStatusEnums; import cn.ysk.cashier.pojo.order.TbFullOrderDetail; @@ -42,5 +43,25 @@ public interface MpOrderDetailService extends IService { */ List selectByOrderId(Integer orderId); + /** + * 根据订单id和状态获取订单详情 + */ + List selectByOrderIdAndState(Integer orderId, TableConstant.OrderInfo.Status state); + + /** + * 根据购物车id和订单id查询订单详情 + * @param shopId 店铺id + * @param cartIdList 购物车id + * @param orderId 订单id + * @return 详情信息 + */ + List selectByCartIdOrOrderId(Integer shopId, List cartIdList, Integer orderId); + + /** + * 根据订单id修改详情状态 + * @param status 状态 + * @param orderId 订单id + */ + boolean updateStatusByOrderId(TableConstant.OrderInfo.Status status, Integer orderId); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderInfoService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderInfoService.java index d20c67d3..fe49c351 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderInfoService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpOrderInfoService.java @@ -1,5 +1,6 @@ package cn.ysk.cashier.mybatis.service; +import cn.ysk.cashier.cons.TableConstant; import cn.ysk.cashier.enums.OrderStatusEnums; import cn.ysk.cashier.pojo.order.TbOrderDetail; import cn.ysk.cashier.pojo.order.TbOrderInfo; @@ -15,19 +16,29 @@ import java.util.List; */ public interface MpOrderInfoService extends IService { - /** - * 根据原始订单查询退款订单 - * @param orderId 原始订单id - * @return 对应的退款订单 - */ - TbOrderInfo selectReturnOrderByOrderId(Integer orderId); + /** + * 根据原始订单查询退款订单 + * + * @param orderId 原始订单id + * @return 对应的退款订单 + */ + TbOrderInfo selectReturnOrderByOrderId(Integer orderId); + + /** + * 修改订单的就餐类型和tableId + * + * @param orderId 订单id + * @param useType 就餐类型 + * @return 是否成功 + */ + boolean updateTableIdAndUseTypeById(Integer orderId, String useType, String tableId); /** - * 修改订单的就餐类型和tableId + * 根据状态和id获取订单信息 * @param orderId 订单id - * @param useType 就餐类型 - * @return 是否成功 + * @param status 状态枚举 */ - boolean updateTableIdAndUseTypeById(Integer orderId, String useType, String tableId); + TbOrderInfo selectOrderByIdAndState(Integer orderId, TableConstant.OrderInfo.Status status); + } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpShopUserService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpShopUserService.java new file mode 100644 index 00000000..199ba7dc --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/MpShopUserService.java @@ -0,0 +1,16 @@ +package cn.ysk.cashier.mybatis.service; + +import cn.ysk.cashier.enums.TableStateEnum; +import cn.ysk.cashier.pojo.shop.TbShopTable; +import cn.ysk.cashier.pojo.shop.TbShopUser; +import com.baomidou.mybatisplus.extension.service.IService; + +public interface MpShopUserService extends IService { + /** + * 根据店铺id和用户id查询会员信息 + * @param userId 用户id + * @param shopId 店铺id + * @return 会员信息 + */ + TbShopUser selectByUserIdAndShopId(Integer userId, Integer shopId); +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/ShopService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/ShopService.java deleted file mode 100644 index a0588b83..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/ShopService.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.ysk.cashier.mybatis.service; - -import cn.ysk.cashier.mybatis.entity.Activate; -import cn.ysk.cashier.mybatis.entity.StorageVo; -import cn.ysk.cashier.mybatis.vo.ActivateProsVo; -import cn.ysk.cashier.pojo.product.TbProduct; -import org.springframework.data.domain.Pageable; - -import java.util.List; - -/** -* @website https://eladmin.vip -* @description 服务接口 -* @author admin -* @date 2023-10-30 -**/ -public interface ShopService { - Object findStorage(Integer shopId, String account, Pageable pageable); - - void outStorage(Integer id, String userName, Integer num); - - - void inStorage(StorageVo storageVo, String userName); - - Object findActivate(String shopId); - - void modityActivate(Activate activate); - - List findActivatePros(Integer activate); -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbActivateService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbActivateService.java index 0ef72d70..1cbca06b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbActivateService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbActivateService.java @@ -10,4 +10,8 @@ import com.baomidou.mybatisplus.extension.service.IService; */ public interface TbActivateService extends IService { + + Object findActivate(String shopId); + + void modifyActivate(TbActivate activate); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbActivateProductService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCouponProductService.java similarity index 62% rename from eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbActivateProductService.java rename to eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCouponProductService.java index 14781817..caecd8a9 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbActivateProductService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbCouponProductService.java @@ -1,6 +1,6 @@ package cn.ysk.cashier.mybatis.service; -import cn.ysk.cashier.mybatis.entity.TbActivateProduct; +import cn.ysk.cashier.mybatis.entity.TbCouponProduct; import com.baomidou.mybatisplus.extension.service.IService; @@ -10,7 +10,8 @@ import com.baomidou.mybatisplus.extension.service.IService; * @author ww * @since 2024-08-20 11:27:40 */ -public interface TbActivateProductService extends IService { +public interface TbCouponProductService extends IService { + } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbMemberPointsLogService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbMemberPointsLogService.java new file mode 100644 index 00000000..abc42438 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbMemberPointsLogService.java @@ -0,0 +1,18 @@ +package cn.ysk.cashier.mybatis.service; + +import cn.ysk.cashier.mybatis.entity.TbMemberPointsLog; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.Map; + +/** + * 会员积分变动记录 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +public interface TbMemberPointsLogService extends IService { + + Map page(Map params); + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbMemberPointsService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbMemberPointsService.java new file mode 100644 index 00000000..9ada495c --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbMemberPointsService.java @@ -0,0 +1,99 @@ +package cn.ysk.cashier.mybatis.service; + +import cn.ysk.cashier.dto.points.OrderDeductionPointsDTO; +import cn.ysk.cashier.mybatis.entity.TbMemberPoints; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.math.BigDecimal; +import java.util.Map; + +/** + * 会员积分 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +public interface TbMemberPointsService extends IService { + + /** + * 会员积分分页 + * + * @param params + * @return + */ + Map page(Map params); + + /** + * 获取会员积分等信息 + * + * @param memberId 会员id + * @return + */ + TbMemberPoints getMemberPoints(Long memberId); + + /** + * 初始化会员积分 + * + * @param memberId 会员id + * @return + */ + TbMemberPoints initMemberPoints(Long memberId); + + /** + * 根据会员id及订单金额计算可抵扣积分及可抵扣金额 + * + * @param memberId 会员id + * @param orderAmount 订单金额 + * @return + */ + OrderDeductionPointsDTO getMemberUsablePoints(Long memberId, BigDecimal orderAmount); + + /** + * 根据抵扣金额计算抵扣积分 + * + * @param memberId 会员id + * @param orderAmount 订单金额 + * @param deductionAmount 抵扣金额 + */ + int calcUsedPoints(Long memberId, BigDecimal orderAmount, BigDecimal deductionAmount); + + /** + * 根据抵扣积分计算抵扣金额 + * + * @param memberId 会员id + * @param orderAmount 订单金额 + * @param points 抵扣积分 + */ + BigDecimal calcDeductionAmount(Long memberId, BigDecimal orderAmount, int points); + + /** + * 扣除积分 + * + * @param memberId 会员id + * @param points 积分 + * @param content 摘要信息(如:兑换积分商品/积分抵扣账单/消费赠送积分/新会员送积分/储值赠送积分) + * @param orderId 订单id,可以为空 + * @throws Exception + */ + boolean deductPoints(Long memberId, int points, String content, Long orderId); + + /** + * 追加积分 + * + * @param memberId 会员id + * @param points 积分 + * @param content 摘要信息(如:兑换积分商品/积分抵扣账单/消费赠送积分/新会员送积分/储值赠送积分) + * @param orderId 订单id,可以为空 + * @throws Exception + */ + boolean addPoints(Long memberId, int points, String content, Long orderId); + + /** + * 消费赠送积分 + * + * @param memberId 会员id + * @param orderId 订单id + * @throws Exception + */ + void consumeAwardPoints(Long memberId, Long orderId); +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPadLayoutService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPadLayoutService.java new file mode 100644 index 00000000..9ad903cc --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPadLayoutService.java @@ -0,0 +1,18 @@ +package cn.ysk.cashier.mybatis.service; + +import cn.ysk.cashier.pojo.product.TbPadLayout; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.List; + +/** + * Pad商品布局版式 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-22 + */ +public interface TbPadLayoutService extends IService { + + List findList(); + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPadProductCategoryDetailService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPadProductCategoryDetailService.java new file mode 100644 index 00000000..fddc4fa7 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPadProductCategoryDetailService.java @@ -0,0 +1,14 @@ +package cn.ysk.cashier.mybatis.service; + +import cn.ysk.cashier.pojo.product.TbPadProductCategoryDetail; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * Pad商品自定义分类明细 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-22 + */ +public interface TbPadProductCategoryDetailService extends IService { + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPadProductCategoryService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPadProductCategoryService.java new file mode 100644 index 00000000..10dcd1bc --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPadProductCategoryService.java @@ -0,0 +1,32 @@ +package cn.ysk.cashier.mybatis.service; + +import cn.ysk.cashier.dto.product.PadProductCategoryDTO; +import cn.ysk.cashier.pojo.product.TbPadProductCategory; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.List; +import java.util.Map; + +/** + * Pad商品自定义分类 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-22 + */ +public interface TbPadProductCategoryService extends IService { + + Map findPage(Map params); + + PadProductCategoryDTO get(Long id); + + void save(PadProductCategoryDTO dto); + + void update(PadProductCategoryDTO dto); + + void sort(List sortList); + + void delete(Long id); + + void copy(Long id); + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPointsBasicSettingService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPointsBasicSettingService.java new file mode 100644 index 00000000..66acb836 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPointsBasicSettingService.java @@ -0,0 +1,16 @@ +package cn.ysk.cashier.mybatis.service; + +import cn.ysk.cashier.mybatis.entity.TbPointsBasicSetting; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 积分基本设置 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +public interface TbPointsBasicSettingService extends IService { + boolean save(TbPointsBasicSetting entity); + + TbPointsBasicSetting getByShopId(Long shopId); +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPointsExchangeRecordService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPointsExchangeRecordService.java new file mode 100644 index 00000000..3482ddc9 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPointsExchangeRecordService.java @@ -0,0 +1,27 @@ +package cn.ysk.cashier.mybatis.service; + +import cn.ysk.cashier.mybatis.entity.TbPointsExchangeRecord; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.Map; + +/** + * 积分兑换记录 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +public interface TbPointsExchangeRecordService extends IService { + + Map page(Map params); + + TbPointsExchangeRecord get(Long id); + + void checkout(String couponCode); + + void cancel(TbPointsExchangeRecord record); + + void refund(TbPointsExchangeRecord record); + + Map total(Map params); +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPointsGoodsSettingService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPointsGoodsSettingService.java new file mode 100644 index 00000000..d5e715f2 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbPointsGoodsSettingService.java @@ -0,0 +1,24 @@ +package cn.ysk.cashier.mybatis.service; + +import cn.ysk.cashier.mybatis.entity.TbPointsGoodsSetting; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.Map; + +/** + * 积分商品设置 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +public interface TbPointsGoodsSettingService extends IService { + + Map page(Map params); + + boolean save(TbPointsGoodsSetting entity); + + boolean update(TbPointsGoodsSetting dto); + + void delete(Long id); + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopCouponService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopCouponService.java new file mode 100644 index 00000000..3fccc20e --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopCouponService.java @@ -0,0 +1,76 @@ +package cn.ysk.cashier.mybatis.service; + +import cn.ysk.cashier.dto.CouponDto; +import cn.ysk.cashier.dto.QueryReceiveDto; +import cn.ysk.cashier.mybatis.entity.TbActivateInRecord; +import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord; +import cn.ysk.cashier.mybatis.entity.TbCouponProduct; +import cn.ysk.cashier.mybatis.vo.TbShopCouponVo; +import cn.ysk.cashier.pojo.order.TbCashierCart; +import cn.ysk.cashier.pojo.order.TbOrderDetail; +import cn.ysk.cashier.pojo.order.TbOrderInfo; +import cn.ysk.cashier.pojo.shop.TbShopUser; +import cn.ysk.cashier.vo.QueryReceiveVo; +import cn.ysk.cashier.vo.TbUserCouponVo; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import cn.ysk.cashier.mybatis.entity.TbShopCoupon; +import cn.ysk.cashier.dto.TbShopCouponQueryCriteria; +import org.springframework.http.ResponseEntity; + +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * 优惠券(TbShopCoupon)表服务接口 + * + * @author ww + * @since 2024-10-22 15:43:25 + */ +public interface TbShopCouponService extends IService { + + Map queryAll(TbShopCouponQueryCriteria criteria); + + Map queryReceive(QueryReceiveDto param); + TbShopCoupon findById (Integer id); + + boolean update(TbShopCouponVo param); + boolean delete(Integer[] ids); + + /** + * 根据金额获取可用优惠券数据 + * @param tbShopUser 店铺id + * @param orderAmount 用户id + * @param productIds 商品id + * @return 优惠券信息 + */ + List getActivateCoupon(TbShopUser tbShopUser, BigDecimal orderAmount, Integer shopId, Set productIds); + + boolean deleteReceive(Integer[] ids); + + ResponseEntity find(CouponDto param); + + boolean use(Integer shopId,Integer orderId,Integer vipUserId,List param); + + boolean refund(List param); + + List findActivatePros(Integer couponId); + + /** + * 根据优惠券id查询优惠券信息 + * @param couponIds 优惠券id + */ + List selectByIds(List couponIds); + + /** + * 根据订单id获取当前用户可用优惠券信息 + * @param shopId 店铺id + * @param orderId 订单id + * @param memberId 会员id + */ + Object getActivateByOrderIds(Integer shopId, Integer orderId, Integer memberId); + +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopShareRecordService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopShareRecordService.java new file mode 100644 index 00000000..aa79a529 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopShareRecordService.java @@ -0,0 +1,22 @@ +package cn.ysk.cashier.mybatis.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import cn.ysk.cashier.mybatis.entity.TbShopShareRecord; +import cn.ysk.cashier.dto.TbShopShareRecordQueryCriteria; + +import java.util.Map; + +/** + * (TbShopShareRecord)表服务接口 + * + * @author ww + * @since 2024-11-08 09:17:37 + */ +public interface TbShopShareRecordService extends IService { + + Map selectAllByShare(TbShopShareRecordQueryCriteria criteria); + + void give(TbShopShareRecord shareRecord, Integer userId); + +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopShareService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopShareService.java new file mode 100644 index 00000000..e93a7682 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopShareService.java @@ -0,0 +1,18 @@ +package cn.ysk.cashier.mybatis.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import cn.ysk.cashier.mybatis.entity.TbShopShare; + +import java.util.Map; + +/** + * 店铺分享(TbShopShare)表服务接口 + * + * @author ww + * @since 2024-11-06 15:47:37 + */ +public interface TbShopShareService extends IService { + TbShopShare getByShopId(Integer shopId); + +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpCashierCartServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpCashierCartServiceImpl.java index 24864521..94ca64a6 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpCashierCartServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpCashierCartServiceImpl.java @@ -1,20 +1,22 @@ package cn.ysk.cashier.mybatis.service.impl; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; import cn.ysk.cashier.cons.TableConstant; -import cn.ysk.cashier.enums.OrderStatusEnums; -import cn.ysk.cashier.enums.OrderUseTypeEnum; -import cn.ysk.cashier.enums.ShopInfoEatModelEnum; -import cn.ysk.cashier.enums.ShopInfoRegisterlEnum; +import cn.ysk.cashier.dto.shoptable.ShopEatTypeInfoDTO; +import cn.ysk.cashier.enums.*; import cn.ysk.cashier.exception.BadRequestException; import cn.ysk.cashier.mybatis.mapper.MpShopInfoMapper; +import cn.ysk.cashier.mybatis.mapper.MpShopTableMapper; import cn.ysk.cashier.mybatis.mapper.TbCashierCartMapper; import cn.ysk.cashier.mybatis.service.MpCashierCartService; import cn.ysk.cashier.pojo.order.TbCashierCart; import cn.ysk.cashier.pojo.shop.TbShopInfo; +import cn.ysk.cashier.pojo.shop.TbShopTable; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; @@ -32,8 +34,11 @@ import java.util.List; public class MpCashierCartServiceImpl extends ServiceImpl implements MpCashierCartService { private final MpShopInfoMapper mpShopInfoMapper; - public MpCashierCartServiceImpl(MpShopInfoMapper mpShopInfoMapper) { + private final MpShopTableMapper shopTableMapper; + + public MpCashierCartServiceImpl(MpShopInfoMapper mpShopInfoMapper, MpShopTableMapper shopTableMapper) { this.mpShopInfoMapper = mpShopInfoMapper; + this.shopTableMapper = shopTableMapper; } @Override @@ -93,5 +98,46 @@ public class MpCashierCartServiceImpl extends ServiceImpl() + .eq(TbCashierCart::getOrderId, orderId) + .setSql(StrUtil.format("total_amount=total_number*{}", isMember ? "member_price" : "sale_price")) + .set(TbCashierCart::getIsMember, isMember ? 1 : 0)); + } + + @Override + public List selectByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .eq(TbCashierCart::getShopId, shopEatTypeInfoDTO.getShopId()) + .eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType()) + .in(TbCashierCart::getStatus, "create", "return") + .gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime()) + .and(q -> q.eq(TbCashierCart::getMasterId, masterId).or().isNull(TbCashierCart::getMasterId)); + + // 非堂食校验台桌状态 + if (shopEatTypeInfoDTO.isTakeout()) { + queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, "")) + .in(TbCashierCart::getPlatformType, OrderPlatformTypeEnum.PC.getValue(), OrderPlatformTypeEnum.CASH.getValue()); + } else { + if (StrUtil.isNotBlank(shopEatTypeInfoDTO.getTableId())) { + queryWrapper.eq(TbCashierCart::getTableId, shopEatTypeInfoDTO.getTableId()); + } else { + queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, "")); + } + + } + return list(queryWrapper); + } + + @Override + public List selectByOrderIdAndState(Integer orderId, TableConstant.OrderInfo.Status... status) { + LambdaQueryChainWrapper queryChainWrapper = lambdaQuery().eq(TbCashierCart::getOrderId, orderId); + if (status != null && status.length > 0) { + queryChainWrapper.in(TbCashierCart::getStatus, CollUtil.newArrayList(status)); + } + return queryChainWrapper.list(); + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderDetailServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderDetailServiceImpl.java index d6d9b89c..9faa520a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderDetailServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderDetailServiceImpl.java @@ -1,5 +1,6 @@ package cn.ysk.cashier.mybatis.service.impl; +import cn.ysk.cashier.cons.TableConstant; import cn.ysk.cashier.dto.shoptable.ReturnOrderDTO; import cn.ysk.cashier.enums.OrderStatusEnums; import cn.ysk.cashier.mybatis.mapper.TbOrderDetailMapper; @@ -46,5 +47,26 @@ public class MpOrderDetailServiceImpl extends ServiceImpl() .eq(TbOrderDetail::getOrderId, orderId)); } + + @Override + public List selectByOrderIdAndState(Integer orderId, TableConstant.OrderInfo.Status state) { + return list(new LambdaQueryWrapper() + .eq(TbOrderDetail::getStatus, state.getValue()) + .eq(TbOrderDetail::getOrderId, orderId)); + } + + @Override + public List selectByCartIdOrOrderId(Integer shopId, List cartIdList, Integer orderId) { + return list(new LambdaQueryWrapper() + .and(q -> q.in(TbOrderDetail::getCartId, cartIdList).or().eq(TbOrderDetail::getOrderId, orderId)) + .eq(TbOrderDetail::getShopId, shopId)); + } + + @Override + public boolean updateStatusByOrderId(TableConstant.OrderInfo.Status status, Integer orderId) { + return update(new LambdaUpdateWrapper() + .eq(TbOrderDetail::getOrderId, orderId) + .set(TbOrderDetail::getStatus, status.getValue())); + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderInfoServiceImpl.java index ea67276a..230128b8 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpOrderInfoServiceImpl.java @@ -1,5 +1,6 @@ package cn.ysk.cashier.mybatis.service.impl; +import cn.ysk.cashier.cons.TableConstant; import cn.ysk.cashier.mybatis.mapper.TbCashierCartMapper; import cn.ysk.cashier.mybatis.mapper.TbOrderInfoMapper; import cn.ysk.cashier.mybatis.service.MpCashierCartService; @@ -22,8 +23,7 @@ public class MpOrderInfoServiceImpl extends ServiceImpl() - .eq(TbOrderInfo::getSource, orderId) - .eq(TbOrderInfo::getOrderType, "return")); + .eq(TbOrderInfo::getSource, orderId)); } @Override @@ -33,5 +33,12 @@ public class MpOrderInfoServiceImpl extends ServiceImpl() + .eq(TbOrderInfo::getId, orderId) + .eq(TbOrderInfo::getStatus, status.getValue())); + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpShopUserServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpShopUserServiceImpl.java new file mode 100644 index 00000000..4873f9c0 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/MpShopUserServiceImpl.java @@ -0,0 +1,23 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import cn.ysk.cashier.enums.TableStateEnum; +import cn.ysk.cashier.mybatis.mapper.MpShopTableMapper; +import cn.ysk.cashier.mybatis.mapper.TbShopUserMapper; +import cn.ysk.cashier.mybatis.service.MpShopTableService; +import cn.ysk.cashier.mybatis.service.MpShopUserService; +import cn.ysk.cashier.pojo.shop.TbShopTable; +import cn.ysk.cashier.pojo.shop.TbShopUser; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +@Service +public class MpShopUserServiceImpl extends ServiceImpl implements MpShopUserService { + @Override + public TbShopUser selectByUserIdAndShopId(Integer userId, Integer shopId) { + return getOne(new LambdaQueryWrapper() + .eq(TbShopUser::getUserId, userId) + .eq(TbShopUser::getShopId, shopId)); + } +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/ShopServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/ShopServiceImpl.java deleted file mode 100644 index d39b2c62..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/ShopServiceImpl.java +++ /dev/null @@ -1,186 +0,0 @@ -package cn.ysk.cashier.mybatis.service.impl; - -import cn.ysk.cashier.mybatis.entity.Activate; -import cn.ysk.cashier.mybatis.entity.TbActivateProduct; -import cn.ysk.cashier.mybatis.mapper.*; -import cn.ysk.cashier.mybatis.service.TbActivateProductService; -import cn.ysk.cashier.mybatis.vo.ActivateProsVo; -import cn.ysk.cashier.pojo.product.TbProduct; -import cn.ysk.cashier.pojo.product.TbProductSku; -import cn.ysk.cashier.pojo.shop.TbMerchantAccount; -import cn.ysk.cashier.repository.product.TbProductRepository; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import cn.ysk.cashier.exception.NewBadRequestException; -import cn.ysk.cashier.mybatis.entity.StorageVo; -import cn.ysk.cashier.mybatis.entity.TbUserStorage; -import cn.ysk.cashier.mybatis.service.ShopService; -import cn.ysk.cashier.utils.*; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Pageable; -import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; - -import javax.annotation.Resource; -import java.util.*; -import java.util.stream.Collectors; - -/** - * @author admin - * @website https://eladmin.vip - * @description 服务实现 - * @date 2023-10-30 - **/ -@Service -public class ShopServiceImpl implements ShopService { - - @Autowired - private TbUserStorageMapper userStorageMapper; - @Autowired - private TbMerchantAccountMapper tbMerchantAccountMapper; - @Autowired - private TbProducSkutMapper producSkutMapper; - @Autowired - private ActivateMapper activateMapper; - @Autowired - private TbProductRepository tbProductRepository; - @Resource - private TbActivateProductService actProductService; - @Override - public Object findStorage(Integer shopId, String account, Pageable pageable) { - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("shop_id", shopId); - if (StringUtils.isNotEmpty(account)) { - queryWrapper.eq("account", account); - } - IPage iPage = userStorageMapper.selectPage(new Page<>(pageable.getPageNumber(), pageable.getPageSize()), queryWrapper); - return PageUtil.toPage(iPage.getRecords(), iPage.getTotal()); - } - - @Override - public void outStorage(Integer id, String userName, Integer num) { - if (Objects.isNull(num) || num < 0) { - throw new NewBadRequestException("请输入出库数量"); - } - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq("account", userName); - TbMerchantAccount merchantAccount = tbMerchantAccountMapper.selectOne(wrapper); - - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("id", id); - queryWrapper.eq("shop_id", merchantAccount.getShopId()); - TbUserStorage userStorage = userStorageMapper.selectOne(queryWrapper); - if (Objects.isNull(userStorage)) { - throw new NewBadRequestException("存储商品在该店铺不存在"); - } - if (userStorage.getNum() < num) { - throw new NewBadRequestException("库存不足"); - } - userStorage.setNum(userStorage.getNum() - num); - userStorage.setOutNum(userStorage.getOutNum() + num); - userStorageMapper.updateById(userStorage); - } - - @Override - public void inStorage(StorageVo storageVo, String userName) { - if (Objects.isNull(storageVo.getNum()) || storageVo.getNum() < 0) { - throw new NewBadRequestException("请输入出库数量"); - } - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq("account", userName); - TbMerchantAccount merchantAccount = tbMerchantAccountMapper.selectOne(wrapper); - - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("product_name", storageVo.getProductName()); - queryWrapper.eq("account", storageVo.getAccount()); - queryWrapper.eq("shop_id", merchantAccount.getShopId()); - TbUserStorage userStorage = userStorageMapper.selectOne(queryWrapper); - if (Objects.nonNull(userStorage)) { - userStorage.setNum(userStorage.getNum() + storageVo.getNum()); - userStorage.setInNum(userStorage.getInNum() + storageVo.getNum()); - userStorageMapper.updateById(userStorage); - }else { - userStorage = new TbUserStorage(); - userStorage.setAccount(storageVo.getAccount()); - userStorage.setCreateTime(new Date()); - userStorage.setShopId(merchantAccount.getShopId()); - userStorage.setNum(storageVo.getNum()); - userStorage.setOutNum(0); - userStorage.setInNum(storageVo.getNum()); - userStorage.setImgUrl(storageVo.getImg()); - userStorage.setProductName(storageVo.getImg()); - userStorage.setUnit(storageVo.getUnit()); - userStorageMapper.insert(userStorage); - } - } - - @Override - public Object findActivate(String shopId) { - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("shop_id",shopId); - queryWrapper.orderByDesc("id"); - List list = activateMapper.selectList(queryWrapper); - return list; - } - - @Override - public void modityActivate(Activate activate) { - if (Objects.nonNull(activate.getId()) && activate.getId() > 0){ - activate.setHandselType("GD"); - activate.setMaxNum(activate.getMinNum()); - activateMapper.updateById(activate); - }else { - activate.setHandselType("GD"); - activate.setMaxNum(activate.getMinNum()); - activateMapper.insert(activate); - } - if(!CollectionUtils.isEmpty(activate.getProducts())){ - List collect = new ArrayList<>(); - for (TbActivateProduct product : activate.getProducts()) { - product.setActivateId(activate.getId()); - if (product.getId() != null) collect.add(product.getId()); - } - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("activate_id",activate.getId()); - List actProducts = actProductService.list(queryWrapper); - for (TbActivateProduct actProduct : actProducts) { - if (!collect.contains(actProduct.getId())) { - actProductService.removeById(actProduct.getId()); - } - } - actProductService.saveOrUpdateBatch(activate.getProducts()); - }else { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(TbActivateProduct::getActivateId, activate.getId()); // 条件:年龄等于30 - actProductService.remove(queryWrapper); - } - } - - @Override - public List findActivatePros(Integer activateId) { - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("activate_id", activateId); - List actProducts = actProductService.list(queryWrapper); - if (!CollectionUtils.isEmpty(actProducts)) { - Map map = actProducts.stream().collect( - Collectors.toMap( - TbActivateProduct::getProductId, - TbActivateProduct::getNum, - (existing, replacement) -> existing)); - if (!CollectionUtils.isEmpty(map)) { - List products = tbProductRepository.findByIds(new ArrayList<>(map.keySet())); - List results= new ArrayList<>(); - for (TbProduct product : products) { - ActivateProsVo pro =new ActivateProsVo(product.getId(),product.getName(),product.getCoverImg()); - pro.setNum(map.get(pro.getId())); - results.add(pro); - } - return results; - } - } - return new ArrayList<>(); - } -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbActivateProductServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbActivateProductServiceImpl.java deleted file mode 100644 index ec780b6c..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbActivateProductServiceImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.ysk.cashier.mybatis.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import cn.ysk.cashier.mybatis.mapper.TbActivateProductMapper; -import cn.ysk.cashier.mybatis.entity.TbActivateProduct; -import cn.ysk.cashier.mybatis.service.TbActivateProductService; -import org.springframework.stereotype.Service; -import org.apache.commons.lang3.StringUtils; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import cn.ysk.cashier.dto.TbActivateProductQueryCriteria; -import org.springframework.beans.factory.annotation.Autowired; -import cn.ysk.cashier.utils.PageUtil; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; - -import java.util.Map; - -/** - * 活动赠送商品表(TbActivateProduct)表服务实现类 - * - * @author ww - * @since 2024-08-20 11:27:40 - */ -@Service("tbActivateProductService") -public class TbActivateProductServiceImpl extends ServiceImpl implements TbActivateProductService { - -} - diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbActivateServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbActivateServiceImpl.java index afd2b452..ab47c3e1 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbActivateServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbActivateServiceImpl.java @@ -1,20 +1,69 @@ package cn.ysk.cashier.mybatis.service.impl; import cn.ysk.cashier.mybatis.entity.TbActivate; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import cn.ysk.cashier.mybatis.service.TbActivateService; +import cn.ysk.cashier.mybatis.entity.TbShopCoupon; import cn.ysk.cashier.mybatis.mapper.TbActivateMapper; +import cn.ysk.cashier.mybatis.service.TbActivateService; +import cn.ysk.cashier.mybatis.service.TbShopCouponService; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -/** -* @author Administrator -* @description 针对表【tb_activate】的数据库操作Service实现 -* @createDate 2024-09-03 14:08:30 -*/ -@Service -public class TbActivateServiceImpl extends ServiceImpl - implements TbActivateService{ +import java.util.List; +import java.util.Objects; +/** + * @author Administrator + * @description 针对表【tb_activate】的数据库操作Service实现 + * @createDate 2024-09-03 14:08:30 + */ +@Service +public class TbActivateServiceImpl extends ServiceImpl implements TbActivateService { + + @Autowired + private TbActivateMapper activateMapper; + @Autowired + private TbShopCouponService tbShopCouponService; + + @Override + public Object findActivate(String shopId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("shop_id", shopId); + queryWrapper.orderByDesc("id"); + List list = activateMapper.selectList(queryWrapper); + for (TbActivate tbActivate : list) { + if (tbActivate.getCouponId() != null) { + TbShopCoupon coupon = tbShopCouponService.findById(tbActivate.getCouponId()); + tbActivate.setCouponName(coupon != null ? coupon.getTitle() : ""); + } + } + return list; + } + + @Override + public void modifyActivate(TbActivate activate) { + if (Objects.nonNull(activate.getId()) && activate.getId() > 0) { + if(activate.getIsUseCoupon()==0){ + activate.setCouponId(null); + } else if (activate.getIsUseCoupon()==1) { + if (activate.getCouponId() == null) { + throw new RuntimeException("优惠券不能为空"); + } + } + activateMapper.updateById(activate); + } else { + if(activate.getIsUseCoupon()==0){ + activate.setCouponId(null); + } else if (activate.getIsUseCoupon()==1) { + if (activate.getCouponId() == null) { + throw new RuntimeException("优惠券不能为空"); + } + } + activateMapper.insert(activate); + } + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCouponProductServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCouponProductServiceImpl.java new file mode 100644 index 00000000..fcf2a09d --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbCouponProductServiceImpl.java @@ -0,0 +1,19 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import cn.ysk.cashier.mybatis.entity.TbCouponProduct; +import cn.ysk.cashier.mybatis.mapper.TbCouponProductMapper; +import cn.ysk.cashier.mybatis.service.TbCouponProductService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + * 活动赠送商品表(TbActivateProduct)表服务实现类 + * + * @author ww + * @since 2024-08-20 11:27:40 + */ +@Service("tbCouponProductService") +public class TbCouponProductServiceImpl extends ServiceImpl implements TbCouponProductService { + +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbMemberPointsLogServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbMemberPointsLogServiceImpl.java new file mode 100644 index 00000000..3070f8b3 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbMemberPointsLogServiceImpl.java @@ -0,0 +1,61 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.map.MapProxy; +import cn.hutool.core.util.StrUtil; +import cn.ysk.cashier.mybatis.entity.TbMemberPointsLog; +import cn.ysk.cashier.mybatis.mapper.TbMemberPointsLogMapper; +import cn.ysk.cashier.mybatis.service.TbMemberPointsLogService; +import cn.ysk.cashier.utils.PageUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +import java.util.Map; + +/** + * 会员积分变动记录 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Service +public class TbMemberPointsLogServiceImpl extends ServiceImpl implements TbMemberPointsLogService { + + private LambdaQueryWrapper getWrapper(Map params) { + MapProxy mapProxy = MapProxy.create(params); + String beginDate = mapProxy.getStr("beginDate"); + String endDate = mapProxy.getStr("endDate"); + TbMemberPointsLog param = BeanUtil.toBean(params, TbMemberPointsLog.class); + + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.eq(TbMemberPointsLog::getShopId, param.getShopId()); + wrapper.eq(param.getMemberId() != null, TbMemberPointsLog::getMemberId, param.getMemberId()); + wrapper.like(StrUtil.isNotEmpty(param.getMemberName()), TbMemberPointsLog::getMemberName, param.getMemberName()); + wrapper.like(StrUtil.isNotEmpty(param.getMobile()), TbMemberPointsLog::getMobile, param.getMobile()); + wrapper.like(StrUtil.isNotEmpty(param.getContent()), TbMemberPointsLog::getContent, param.getContent()); + wrapper.eq(StrUtil.isNotEmpty(param.getFloatType()), TbMemberPointsLog::getFloatType, param.getFloatType()); + wrapper.eq(StrUtil.isNotEmpty(param.getOrderNo()), TbMemberPointsLog::getOrderNo, param.getOrderNo()); + if (StrUtil.isNotEmpty(beginDate)) { + wrapper.apply("create_time >= str_to_date({0}, '%Y-%m-%d %H:%i:%s')", beginDate + " 00:00:00"); + } + if (StrUtil.isNotEmpty(endDate)) { + wrapper.apply("create_time <= str_to_date({0}, '%Y-%m-%d %H:%i:%s')", endDate + " 23:59:59"); + } + wrapper.orderByDesc(TbMemberPointsLog::getId); + return wrapper; + } + + @Override + public Map page(Map params) { + MapProxy mapProxy = MapProxy.create(params); + int pageNum = mapProxy.getInt("page", 1); + int pageSize = mapProxy.getInt("size", 10); + LambdaQueryWrapper wrapper = getWrapper(params); + Page page = super.page(new Page<>(pageNum, pageSize), wrapper); + return PageUtil.toPlusPage(page.getRecords(), Convert.toInt(page.getTotal())); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbMemberPointsServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbMemberPointsServiceImpl.java new file mode 100644 index 00000000..c0ec6e59 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbMemberPointsServiceImpl.java @@ -0,0 +1,300 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.map.MapProxy; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.ysk.cashier.dto.points.OrderDeductionPointsDTO; +import cn.ysk.cashier.exception.BadRequestException; +import cn.ysk.cashier.mybatis.entity.TbMemberPoints; +import cn.ysk.cashier.mybatis.entity.TbMemberPointsLog; +import cn.ysk.cashier.mybatis.entity.TbPointsBasicSetting; +import cn.ysk.cashier.mybatis.mapper.TbMemberPointsLogMapper; +import cn.ysk.cashier.mybatis.mapper.TbMemberPointsMapper; +import cn.ysk.cashier.mybatis.mapper.TbOrderInfoMapper; +import cn.ysk.cashier.mybatis.mapper.TbPointsBasicSettingMapper; +import cn.ysk.cashier.mybatis.service.TbMemberPointsService; +import cn.ysk.cashier.mybatis.service.TbPointsBasicSettingService; +import cn.ysk.cashier.pojo.order.TbOrderInfo; +import cn.ysk.cashier.utils.PageUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.Date; +import java.util.Map; + +/** + * 会员积分 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Service +public class TbMemberPointsServiceImpl extends ServiceImpl implements TbMemberPointsService { + + @Resource + private TbMemberPointsLogMapper tbMemberPointsLogMapper; + @Resource + private TbPointsBasicSettingMapper tbPointsBasicSettingMapper; + @Resource + private TbOrderInfoMapper tbOrderInfoMapper; + @Resource + private TbPointsBasicSettingService tbPointsBasicSettingService; + + private LambdaQueryWrapper getWrapper(Map params) { + //MapProxy mapProxy = MapProxy.create(params); + TbMemberPoints param = BeanUtil.toBean(params, TbMemberPoints.class); + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.eq(TbMemberPoints::getShopId, param.getShopId()); + wrapper.like(StrUtil.isNotEmpty(param.getMemberName()), TbMemberPoints::getMemberName, param.getMemberName()); + wrapper.like(StrUtil.isNotEmpty(param.getMobile()), TbMemberPoints::getMobile, param.getMobile()); + + wrapper.orderByDesc(TbMemberPoints::getId); + return wrapper; + } + + @Override + public Map page(Map params) { + MapProxy mapProxy = MapProxy.create(params); + int pageNum = mapProxy.getInt("page", 1); + int pageSize = mapProxy.getInt("size", 10); + LambdaQueryWrapper wrapper = getWrapper(params); + Page page = super.page(new Page<>(pageNum, pageSize), wrapper); + return PageUtil.toPlusPage(page.getRecords(), Convert.toInt(page.getTotal())); + } + + @Override + public TbMemberPoints getMemberPoints(Long memberId) { + return initMemberPoints(memberId); + } + + @Override + public TbMemberPoints initMemberPoints(Long memberId) { + TbMemberPoints entity = super.getOne(Wrappers.lambdaQuery().eq(TbMemberPoints::getMemberId, memberId)); + if (entity == null) { + throw new BadRequestException("会员信息不存在"); + } + if (entity.getAccountPoints() == null) { + entity.setAccountPoints(0); + } + super.updateById(entity); + return entity; + } + + @Override + public OrderDeductionPointsDTO getMemberUsablePoints(Long memberId, BigDecimal orderAmount) { + TbMemberPoints entity = initMemberPoints(memberId); + Long shopId = entity.getShopId(); + Integer accountPoints = entity.getAccountPoints(); + OrderDeductionPointsDTO dto = new OrderDeductionPointsDTO(); + dto.setAccountPoints(accountPoints); + dto.setUsable(false); + dto.setMaxDeductionAmount(BigDecimal.ZERO); + dto.setMinDeductionAmount(BigDecimal.ZERO); + TbPointsBasicSetting basic = tbPointsBasicSettingMapper.selectOne(Wrappers.lambdaQuery().eq(TbPointsBasicSetting::getShopId, shopId)); + if (basic == null) { + dto.setUnusableReason("商家未启用积分抵扣功能"); + return dto; + } + if (basic.getEnableDeduction() == 0) { + dto.setUnusableReason("商家未启用积分抵扣功能"); + return dto; + } + if ("vip".equals(basic.getDeductionGroup()) && ObjectUtil.defaultIfNull(entity.getVip(), 0) != 1) { + dto.setUnusableReason("仅VIP用户可用"); + return dto; + } + dto.setMinPaymentAmount(basic.getMinPaymentAmount()); + dto.setOrderAmount(orderAmount); + if (NumberUtil.isLess(orderAmount, basic.getMinPaymentAmount())) { + dto.setUnusableReason(StrUtil.format("实付金额不足¥{}元,无法进行抵扣", basic.getMinPaymentAmount())); + return dto; + } + dto.setEquivalentPoints(basic.getEquivalentPoints()); + // 最低抵扣积分 = 1元等值积分 = 1.0元 + dto.setMinDeductionPoints(basic.getEquivalentPoints()); + // 计算抵扣门槛=?元 + dto.setMinDeductionAmount(BigDecimal.ONE); + if (accountPoints == 0 || accountPoints < dto.getMinDeductionPoints()) { + dto.setUnusableReason("积分不足或小于最低使用门槛" + dto.getMinDeductionPoints()); + return dto; + } + // 下单抵扣积分比例 1元=?积分 + Integer equivalentPoints = basic.getEquivalentPoints(); + // 计算账户积分=?元 + BigDecimal accountYuan = NumberUtil.div(accountPoints, equivalentPoints); + // 下单最高抵扣比例 + BigDecimal maxDeductionRatio = basic.getMaxDeductionRatio(); + // 计算订单最多可以抵扣多少元,向下取整 + BigDecimal orderYuan = NumberUtil.roundDown(NumberUtil.mul(orderAmount, NumberUtil.div(maxDeductionRatio, new BigDecimal("100"))), 0); + // 积分余额足够 + if (NumberUtil.isGreaterOrEqual(accountYuan, orderYuan)) { + dto.setMaxDeductionAmount(orderYuan); + } else { + dto.setMaxDeductionAmount(NumberUtil.roundDown(accountYuan, 0)); + } + if (NumberUtil.isLess(dto.getMaxDeductionAmount(), BigDecimal.ONE)) { + dto.setUnusableReason("积分不足1元,无法进行抵扣"); + return dto; + } + dto.setUsable(true); + // 计算最多可抵扣的积分 + BigDecimal mul = NumberUtil.mul(dto.getMaxDeductionAmount(), equivalentPoints); + BigDecimal round = NumberUtil.round(mul, 0, RoundingMode.CEILING); + dto.setMaxUsablePoints(round.intValue()); + return dto; + } + + @Override + public int calcUsedPoints(Long memberId, BigDecimal orderAmount, BigDecimal deductionAmount) { + OrderDeductionPointsDTO core = getMemberUsablePoints(memberId, orderAmount); + if (!core.getUsable()) { + throw new BadRequestException(core.getUnusableReason()); + } + if (NumberUtil.isGreater(deductionAmount, core.getMaxDeductionAmount())) { + throw new BadRequestException(StrUtil.format("抵扣金额不能超过最大抵扣金额{}元", core.getMaxDeductionAmount())); + } + if (NumberUtil.isGreater(deductionAmount, orderAmount)) { + throw new BadRequestException(StrUtil.format("抵扣金额不能超过订单金额{}元", orderAmount)); + } + // 计算可抵扣的积分 + BigDecimal mul = NumberUtil.mul(deductionAmount, core.getEquivalentPoints()); + BigDecimal round = NumberUtil.round(mul, 0, RoundingMode.CEILING); + return round.intValue(); + } + + @Override + public BigDecimal calcDeductionAmount(Long memberId, BigDecimal orderAmount, int points) { + OrderDeductionPointsDTO core = getMemberUsablePoints(memberId, orderAmount); + if (!core.getUsable()) { + throw new BadRequestException(core.getUnusableReason()); + } + if (points < core.getMinDeductionPoints()) { + throw new BadRequestException(StrUtil.format("使用积分不能低于使用门槛(每次最少使用{}积分)", core.getMinDeductionPoints())); + } + if (points > core.getMaxUsablePoints()) { + throw new BadRequestException(StrUtil.format("使用积分不能超过最大使用限制{}", core.getMaxUsablePoints())); + } + BigDecimal money = NumberUtil.mul(points, NumberUtil.div(BigDecimal.ONE, core.getEquivalentPoints())); + BigDecimal maxDeductionAmount = NumberUtil.roundDown(money, 0); + if (NumberUtil.isGreater(maxDeductionAmount, core.getMaxDeductionAmount())) { + return core.getMaxDeductionAmount(); + } + return maxDeductionAmount; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean deductPoints(Long memberId, int points, String content, Long orderId) { + TbMemberPoints entity = initMemberPoints(memberId); + // 扣除账户积分 + entity.setAccountPoints(entity.getAccountPoints() - points); + entity.setLastPointsChangeTime(new Date()); + entity.setLastFloatPoints(-points); + + // 记录积分变动记录 + TbMemberPointsLog log = new TbMemberPointsLog(); + log.setShopId(entity.getShopId()); + log.setMemberId(entity.getMemberId()); + log.setMemberName(entity.getMemberName()); + log.setAvatarUrl(entity.getAvatarUrl()); + log.setMobile(entity.getMobile()); + log.setContent(content); + log.setFloatType("subtract"); + log.setFloatPoints(-points); + log.setCreateTime(new Date()); + // 有关联订单的需要回置订单表的相关积分使用字段 + if (orderId != null) { + TbOrderInfo orderInfo = tbOrderInfoMapper.selectById(orderId); + if (orderInfo != null) { + log.setOrderNo(orderInfo.getOrderNo()); + // TODO 是否需要回执“使用的积分数量(points_num)”和“积分抵扣金额(points_discount_amount)”,目前不清楚是创建订单的时候置入还是支付完成后回调时置入需要商议后决定 + } + } + super.updateById(entity); + tbMemberPointsLogMapper.insert(log); + return true; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean addPoints(Long memberId, int points, String content, Long orderId) { + TbMemberPoints entity = initMemberPoints(memberId); + // 增加账户积分 + entity.setAccountPoints(entity.getAccountPoints() + points); + entity.setLastPointsChangeTime(new Date()); + entity.setLastFloatPoints(points); + // 记录积分变动记录 + TbMemberPointsLog log = new TbMemberPointsLog(); + log.setShopId(entity.getShopId()); + log.setMemberId(entity.getMemberId()); + log.setMemberName(entity.getMemberName()); + log.setAvatarUrl(entity.getAvatarUrl()); + log.setMobile(entity.getMobile()); + log.setContent(content); + log.setFloatType("add"); + log.setFloatPoints(points); + log.setCreateTime(new Date()); + // 有关联订单的需要回置订单表的相关积分使用字段 + if (orderId != null) { + TbOrderInfo orderInfo = tbOrderInfoMapper.selectById(orderId); + if (orderInfo != null) { + log.setOrderNo(orderInfo.getOrderNo()); + } + } + super.updateById(entity); + tbMemberPointsLogMapper.insert(log); + return true; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void consumeAwardPoints(Long memberId, Long orderId) { + TbOrderInfo orderInfo = tbOrderInfoMapper.selectById(orderId); + if (orderInfo == null) { + throw new BadRequestException("订单不存在"); + } + BigDecimal payAmount = orderInfo.getPayAmount(); + if (NumberUtil.isLessOrEqual(payAmount, BigDecimal.ZERO)) { + return; + } + TbPointsBasicSetting basicSetting = tbPointsBasicSettingService.getByShopId(Convert.toLong(orderInfo.getShopId())); + if (basicSetting == null) { + return; + } + Integer enableRewards = basicSetting.getEnableRewards(); + if (enableRewards == 0) { + return; + } + String rewardsGroup = basicSetting.getRewardsGroup(); + TbMemberPoints entity; + try { + entity = initMemberPoints(memberId); + } catch (Exception e) { + return; + } + Integer vip = entity.getVip(); + if ("vip".equals(rewardsGroup) && ObjectUtil.defaultIfNull(vip, 0) != 1) { + return; + } + BigDecimal consumeAmount = basicSetting.getConsumeAmount(); + if (consumeAmount == null) { + return; + } + if (NumberUtil.isLessOrEqual(consumeAmount, BigDecimal.ZERO)) { + return; + } + BigDecimal awardPoints = NumberUtil.roundDown(NumberUtil.div(payAmount, consumeAmount), 0); + addPoints(memberId, awardPoints.intValue(), StrUtil.format("消费¥{}送{}积分", payAmount, awardPoints.intValue()), orderId); + } + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPadLayoutServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPadLayoutServiceImpl.java new file mode 100644 index 00000000..a745baa2 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPadLayoutServiceImpl.java @@ -0,0 +1,40 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.ysk.cashier.mybatis.mapper.TbPadLayoutMapper; +import cn.ysk.cashier.mybatis.service.TbPadLayoutService; +import cn.ysk.cashier.pojo.product.TbPadLayout; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Pad商品布局版式 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-22 + */ +@Service +public class TbPadLayoutServiceImpl extends ServiceImpl implements TbPadLayoutService { + + private LambdaQueryWrapper getWrapper(Map params) { + TbPadLayout param = BeanUtil.toBean(params, TbPadLayout.class); + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.eq(TbPadLayout::getDelFlag, 0); + wrapper.orderByAsc(TbPadLayout::getSort); + wrapper.orderByAsc(TbPadLayout::getId); + return wrapper; + } + + + + @Override + public List findList() { + return super.list(this.getWrapper(new HashMap<>(1))); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPadProductCategoryDetailServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPadProductCategoryDetailServiceImpl.java new file mode 100644 index 00000000..50b9c13f --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPadProductCategoryDetailServiceImpl.java @@ -0,0 +1,28 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import cn.ysk.cashier.mybatis.mapper.TbPadProductCategoryDetailMapper; +import cn.ysk.cashier.mybatis.service.TbPadProductCategoryDetailService; +import cn.ysk.cashier.pojo.product.TbPadProductCategoryDetail; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +import java.util.Map; + +/** + * Pad商品自定义分类明细 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-22 + */ +@Service +public class TbPadProductCategoryDetailServiceImpl extends ServiceImpl implements TbPadProductCategoryDetailService { + + public QueryWrapper getWrapper(Map params){ + QueryWrapper wrapper = new QueryWrapper<>(); + + wrapper.orderByDesc("id"); + return wrapper; + } + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPadProductCategoryServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPadProductCategoryServiceImpl.java new file mode 100644 index 00000000..85aa89cd --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPadProductCategoryServiceImpl.java @@ -0,0 +1,310 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.map.MapProxy; +import cn.hutool.core.util.StrUtil; +import cn.ysk.cashier.dto.product.PadProductCategoryDTO; +import cn.ysk.cashier.exception.BadRequestException; +import cn.ysk.cashier.mybatis.mapper.*; +import cn.ysk.cashier.mybatis.service.TbPadProductCategoryService; +import cn.ysk.cashier.pojo.product.*; +import cn.ysk.cashier.repository.product.TbProductSkuResultRepository; +import cn.ysk.cashier.utils.PageUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.OrderItem; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.*; +import java.util.stream.Collectors; + +/** + * Pad商品自定义分类 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-22 + */ +@Service +public class TbPadProductCategoryServiceImpl extends ServiceImpl implements TbPadProductCategoryService { + + @Resource + private TbPadLayoutMapper tbPadLayoutMapper; + + @Resource + private TbPadProductCategoryDetailMapper tbPadProductCategoryDetailMapper; + @Resource + private TbProductMapper tbProductMapper; + @Resource + private TbProductSkuResultRepository productSkuResultRepository; + @Resource + private TbProducSkutMapper producSkutMapper; + + @Override + public Map findPage(Map params) { + MapProxy mapProxy = MapProxy.create(params); + int pageNum = mapProxy.getInt("page", 1); + int pageSize = mapProxy.getInt("size", 10); + Page page = new Page<>(pageNum, pageSize); + page.addOrder(OrderItem.asc("sort")); + params.put("page", page); + List list = baseMapper.findList(params); + return PageUtil.toPlusPage(list, Convert.toInt(page.getTotal())); + } + + @Override + public PadProductCategoryDTO get(Long id) { + TbPadProductCategory entity = baseMapper.selectById(id); + if (entity == null) { + throw new BadRequestException("id对应的数据不存在"); + } + TbPadLayout padLayout = tbPadLayoutMapper.selectById(entity.getPadLayoutId()); + if (padLayout == null) { + throw new BadRequestException("引用的布局版式不存在"); + } + Map params = new HashMap<>(2); + params.put("id", id); + params.put("shopId", entity.getShopId()); + List list = baseMapper.findList(params); + PadProductCategoryDTO dto = list.get(0); + if (entity.getProductCategoryId().longValue() == 0L) { + dto.setProductCategoryName("推荐菜"); + } + List subList = tbPadProductCategoryDetailMapper.selectList(Wrappers.lambdaQuery().eq(TbPadProductCategoryDetail::getPadProductCategoryId, entity.getId())); + if (CollUtil.isNotEmpty(subList)) { + List productIdList = subList.stream().map(TbPadProductCategoryDetail::getProductId).collect(Collectors.toList()); + dto.setProductIdList(productIdList); + List> splitIdList = CollUtil.split(productIdList, 10); + List productList = dto.getProductList(); + for (List ids : splitIdList) { + List splitList = tbProductMapper.selectList(Wrappers.lambdaQuery().in(TbProduct::getId, ids)); + for (TbProduct item : splitList) { + TbProductSkuResult skuResult = productSkuResultRepository.findById(item.getId()).orElse(null); + item.setSkuResult(skuResult); + List> maps = buildSpecList(skuResult, item); + item.setSpecList(maps); + productList.add(item); + } + } + dto.setProductList(productList); + } + return dto; + } + + private List> buildSpecList(TbProductSkuResult skuResult, TbProduct item) { + List> specList = new ArrayList<>(); + List tbProductSkus = producSkutMapper.selectList(new LambdaQueryWrapper().eq(TbProductSku::getIsDel, 0) + .eq(TbProductSku::getIsPauseSale, 0) + .eq(TbProductSku::getProductId, item.getId()) + .eq(TbProductSku::getIsGrounding, 1) + .select(TbProductSku::getId, TbProductSku::getSpecSnap, TbProductSku::getStockNumber, TbProductSku::getSalePrice, TbProductSku::getSuit)); + + String tagSnap = null; + if (skuResult != null) { + tagSnap = skuResult.getTagSnap(); + } + List result = new ArrayList<>(); + + if (StrUtil.isNotBlank(tagSnap)) { + JSONArray tagSnaps = JSONObject.parseArray(tagSnap); + List> valuesList = new ArrayList<>(); + + // 提取所有 value 的列表 + for (int i = 0; i < tagSnaps.size(); i++) { + JSONObject jsonObject = tagSnaps.getJSONObject(i); + String[] values = jsonObject.getString("value").split(","); + valuesList.add(Arrays.asList(values)); + } + // 生成所有可能的排列组合 + generateCombinations(valuesList, 0, new ArrayList<>(), result); + + } + + tbProductSkus.forEach(item2 -> { + Map itemMap = BeanUtil.beanToMap(item2, false, true); + + itemMap.put("stockNumber", item.getStockNumber()); + + specList.add(itemMap); + }); + + ArrayList> otherVal = new ArrayList<>(); + for (String res : result) { + boolean found = false; + for (Map spec : specList) { + if (spec.get("specSnap") != null && res.equals(spec.get("specSnap").toString())) { + spec.put("isGrounding", true); + found = true; + break; + } + } + if (!found) { + HashMap itemMap = new HashMap<>(); + itemMap.put("specSnap", res); + itemMap.put("skuId", null); + itemMap.put("isGrounding", false); + otherVal.add(itemMap); + } + } + specList.addAll(otherVal); + return specList; + } + + private static void generateCombinations(List> valuesList, int index, List current, List result) { + if (index == valuesList.size()) { + result.add(String.join(",", current)); + return; + } + + for (String value : valuesList.get(index)) { + current.add(value); + generateCombinations(valuesList, index + 1, current, result); + current.remove(current.size() - 1); // 回溯 + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(PadProductCategoryDTO dto) { + Long padLayoutId = dto.getPadLayoutId(); + if (padLayoutId == null) { + throw new BadRequestException("布局版式id不能为空"); + } + Long productCategoryId = dto.getProductCategoryId(); + if (productCategoryId == null) { + throw new BadRequestException("商品分类不能为空"); + } + Long shopId = dto.getShopId(); + if (shopId == null) { + throw new BadRequestException("店铺id不能为空"); + } + Integer sort = dto.getSort(); + if (sort == null) { + throw new BadRequestException("排序码不能为空"); + } + if (sort.intValue() < 0) { + throw new BadRequestException("排序码不能小于0"); + } + List productIdList = dto.getProductIdList(); + if (CollUtil.isEmpty(productIdList)) { + throw new BadRequestException("商品id列表不能为空"); + } + TbPadLayout padLayout = tbPadLayoutMapper.selectById(padLayoutId); + if (padLayout == null) { + throw new BadRequestException("引用的布局版式不存在"); + } + if (padLayout.getDelFlag() == 1) { + throw new BadRequestException("引用的布局版式已停用"); + } + Integer maximum = padLayout.getMaximum(); + if (productIdList.size() > maximum.intValue()) { + throw new BadRequestException("商品数量不能超过布局版式最大限制:" + maximum.intValue()); + } + TbPadProductCategory entity = new TbPadProductCategory(); + BeanUtil.copyProperties(dto, entity); + entity.setCreateTime(new Date()); + super.save(entity); + for (Long productId : productIdList) { + TbPadProductCategoryDetail subEntity = new TbPadProductCategoryDetail(); + subEntity.setProductId(productId); + subEntity.setPadProductCategoryId(entity.getId()); + subEntity.setCreateTime(new Date()); + tbPadProductCategoryDetailMapper.insert(subEntity); + } + } + + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(PadProductCategoryDTO dto) { + Long id = dto.getId(); + if (id == null) { + throw new BadRequestException("id不能为空"); + } + Long padLayoutId = dto.getPadLayoutId(); + if (padLayoutId == null) { + throw new BadRequestException("布局版式id不能为空"); + } + Long productCategoryId = dto.getProductCategoryId(); + if (productCategoryId == null) { + throw new BadRequestException("商品分类不能为空"); + } + Long shopId = dto.getShopId(); + if (shopId == null) { + throw new BadRequestException("店铺id不能为空"); + } + Integer sort = dto.getSort(); + if (sort == null) { + throw new BadRequestException("排序码不能为空"); + } + if (sort.intValue() < 0) { + throw new BadRequestException("排序码不能小于0"); + } + List productIdList = dto.getProductIdList(); + if (CollUtil.isEmpty(productIdList)) { + throw new BadRequestException("商品id列表不能为空"); + } + TbPadLayout padLayout = tbPadLayoutMapper.selectById(padLayoutId); + if (padLayout == null) { + throw new BadRequestException("引用的布局版式不存在"); + } + if (padLayout.getDelFlag() == 1) { + throw new BadRequestException("引用的布局版式已停用"); + } + Integer maximum = padLayout.getMaximum(); + if (productIdList.size() > maximum.intValue()) { + throw new BadRequestException("商品数量不能超过布局版式最大限制:" + maximum.intValue()); + } + TbPadProductCategory entity = baseMapper.selectById(id); + if (entity == null) { + throw new BadRequestException("id对应的数据不存在"); + } + BeanUtil.copyProperties(dto, entity, "createTime"); + entity.setUpdateTime(new Date()); + super.updateById(entity); + for (Long productId : productIdList) { + tbPadProductCategoryDetailMapper.delete(Wrappers.lambdaQuery().eq(TbPadProductCategoryDetail::getPadProductCategoryId, entity.getId())); + TbPadProductCategoryDetail subEntity = new TbPadProductCategoryDetail(); + subEntity.setProductId(productId); + subEntity.setPadProductCategoryId(entity.getId()); + subEntity.setCreateTime(new Date()); + tbPadProductCategoryDetailMapper.insert(subEntity); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void sort(List sortList) { + if (CollUtil.isEmpty(sortList)) { + throw new BadRequestException("排序列表不能为空"); + } + for (PadProductCategoryDTO dto : sortList) { + super.update(null, Wrappers.lambdaUpdate().eq(TbPadProductCategory::getId, dto.getId()).set(TbPadProductCategory::getSort, dto.getSort())); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(Long id) { + super.removeById(id); + tbPadProductCategoryDetailMapper.delete(Wrappers.lambdaQuery().eq(TbPadProductCategoryDetail::getPadProductCategoryId, id)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void copy(Long id) { + PadProductCategoryDTO dto = get(id); + dto.setId(null); + dto.setCreateTime(null); + dto.setUpdateTime(null); + save(dto); + } + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPointsBasicSettingServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPointsBasicSettingServiceImpl.java new file mode 100644 index 00000000..119027bb --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPointsBasicSettingServiceImpl.java @@ -0,0 +1,64 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import cn.hutool.core.lang.Assert; +import cn.hutool.core.util.NumberUtil; +import cn.ysk.cashier.exception.BadRequestException; +import cn.ysk.cashier.mybatis.entity.TbPointsBasicSetting; +import cn.ysk.cashier.mybatis.mapper.TbPointsBasicSettingMapper; +import cn.ysk.cashier.mybatis.service.TbPointsBasicSettingService; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 积分基本设置 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Service +public class TbPointsBasicSettingServiceImpl extends ServiceImpl implements TbPointsBasicSettingService { + + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean save(TbPointsBasicSetting entity) { + try { + Assert.notNull(entity.getShopId(), "{}({})不能为空", "店铺id", "shopId"); + Assert.notNull(entity.getEnableRewards(), "{}({})不能为空", "开启消费赠送积分", "enableRewards"); + Assert.notEmpty(entity.getRewardsGroup(), "{}({})不能为空", "赠积分适用群体", "rewardsGroup"); + Assert.notNull(entity.getConsumeAmount(), "{}({})不能为空", "每消费xx元赠送1积分", "consumeAmount"); + Assert.notNull(entity.getEnableDeduction(), "{}({})不能为空", "开启下单积分抵扣", "enableDeduction"); + Assert.notEmpty(entity.getDeductionGroup(), "{}({})不能为空", "抵扣适用群体", "deductionGroup"); + Assert.notNull(entity.getMinPaymentAmount(), "{}({})不能为空", "下单实付抵扣门槛", "minPaymentAmount"); + Assert.notNull(entity.getMaxDeductionRatio(), "{}({})不能为空", "下单最高抵扣比例", "maxDeductionRatio"); + Assert.notNull(entity.getEquivalentPoints(), "{}({})不能为空", "下单抵扣积分比例", "equivalentPoints"); + Assert.notNull(entity.getEnablePointsMall(), "{}({})不能为空", "开启积分商城", "enablePointsMall"); + Assert.notEmpty(entity.getBrowseMode(), "{}({})不能为空", "浏览模式", "browseMode"); + } catch (IllegalArgumentException e) { + throw new BadRequestException(e.getMessage()); + } + if (NumberUtil.isLessOrEqual(entity.getMinPaymentAmount(),BigDecimal.ZERO)) { + throw new BadRequestException("下单实付抵扣门槛不能小于等于0"); + } + if (NumberUtil.isLessOrEqual(entity.getMaxDeductionRatio(), BigDecimal.ZERO)) { + throw new BadRequestException("下单最高抵扣比例不能小于等于0"); + } + if (NumberUtil.isGreater(entity.getMaxDeductionRatio(), new BigDecimal("100"))) { + throw new BadRequestException("下单最高抵扣比例不能大于100"); + } + entity.setCreateTime(new Date()); + super.remove(Wrappers.lambdaQuery().eq(TbPointsBasicSetting::getShopId, entity.getShopId())); + super.save(entity); + return true; + } + + @Override + public TbPointsBasicSetting getByShopId(Long shopId) { + return super.getOne(Wrappers.lambdaQuery().eq(TbPointsBasicSetting::getShopId, shopId)); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPointsExchangeRecordServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPointsExchangeRecordServiceImpl.java new file mode 100644 index 00000000..f7b5e880 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPointsExchangeRecordServiceImpl.java @@ -0,0 +1,246 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.map.MapProxy; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.StrUtil; +import cn.ysk.cashier.exception.BadRequestException; +import cn.ysk.cashier.mybatis.entity.TbMemberPoints; +import cn.ysk.cashier.mybatis.entity.TbMemberPointsLog; +import cn.ysk.cashier.mybatis.entity.TbPointsExchangeRecord; +import cn.ysk.cashier.mybatis.entity.TbPointsGoodsSetting; +import cn.ysk.cashier.mybatis.mapper.*; +import cn.ysk.cashier.mybatis.service.TbPointsExchangeRecordService; +import cn.ysk.cashier.pojo.shop.TbMerchantThirdApply; +import cn.ysk.cashier.pojo.shop.TbShopInfo; +import cn.ysk.cashier.repository.shop.TbMerchantThirdApplyRepository; +import cn.ysk.cashier.thirdpay.resp.OrderReturnResp; +import cn.ysk.cashier.thirdpay.resp.PublicResp; +import cn.ysk.cashier.thirdpay.service.ThirdPayService; +import cn.ysk.cashier.utils.PageUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +/** + * 积分兑换记录 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Service +public class TbPointsExchangeRecordServiceImpl extends ServiceImpl implements TbPointsExchangeRecordService { + + @Value("${thirdPay.url}") + private String thirdUrl; + + @Resource + private TbPointsGoodsSettingMapper tbPointsGoodsSettingMapper; + + @Resource + private TbMemberPointsMapper tbMemberPointsMapper; + + @Resource + private TbMemberPointsLogMapper tbMemberPointsLogMapper; + + @Resource + private MpShopInfoMapper mpShopInfoMapper; + @Resource + private TbMerchantThirdApplyRepository tbMerchantThirdApplyRepository; + + @Resource + private ThirdPayService thirdPayService; + + private LambdaQueryWrapper getWrapper(Map params) { + MapProxy mapProxy = MapProxy.create(params); + String keywords = mapProxy.getStr("keywords"); + String beginDate = mapProxy.getStr("beginDate"); + String endDate = mapProxy.getStr("endDate"); + TbPointsExchangeRecord param = BeanUtil.toBean(params, TbPointsExchangeRecord.class); + + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.eq(TbPointsExchangeRecord::getShopId, param.getShopId()); + wrapper.eq(StrUtil.isNotEmpty(param.getPickupMethod()), TbPointsExchangeRecord::getPickupMethod, param.getPickupMethod()); + wrapper.eq(StrUtil.isNotEmpty(param.getStatus()), TbPointsExchangeRecord::getStatus, param.getStatus()); + wrapper.eq(param.getMemberId() != null, TbPointsExchangeRecord::getMemberId, param.getMemberId()); + if (StrUtil.isNotEmpty(keywords)) { + wrapper.nested(i -> i.like(TbPointsExchangeRecord::getOrderNo, keywords).or().like(TbPointsExchangeRecord::getCouponCode, keywords)); + } + if (StrUtil.isNotEmpty(beginDate)) { + wrapper.apply("create_time >= str_to_date({0}, '%Y-%m-%d %H:%i:%s')", beginDate + " 00:00:00"); + } + if (StrUtil.isNotEmpty(endDate)) { + wrapper.apply("create_time <= str_to_date({0}, '%Y-%m-%d %H:%i:%s')", endDate + " 23:59:59"); + } + wrapper.orderByDesc(TbPointsExchangeRecord::getId); + return wrapper; + } + + @Override + public Map page(Map params) { + MapProxy mapProxy = MapProxy.create(params); + int pageNum = mapProxy.getInt("page", 1); + int pageSize = mapProxy.getInt("size", 10); + LambdaQueryWrapper wrapper = getWrapper(params); + Page page = super.page(new Page<>(pageNum, pageSize), wrapper); + return PageUtil.toPlusPage(page.getRecords(), Convert.toInt(page.getTotal())); + } + + @Override + public TbPointsExchangeRecord get(Long id) { + return super.getById(id); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void checkout(String couponCode) { + if (StrUtil.isBlank(couponCode)) { + throw new BadRequestException("兑换券券码不能为空"); + } + TbPointsExchangeRecord entity = super.getOne(Wrappers.lambdaQuery().eq(TbPointsExchangeRecord::getCouponCode, couponCode)); + if (entity == null) { + throw new BadRequestException("兑换券券码无效"); + } + entity.setStatus("done"); + entity.setUpdateTime(new Date()); + super.updateById(entity); + TbPointsGoodsSetting goods = tbPointsGoodsSettingMapper.selectById(entity.getPointsGoodsId()); + if (goods == null) { + throw new BadRequestException("积分商品不存在"); + } + // 更新累计兑换数量 + goods.setTotalExchangeCount(goods.getTotalExchangeCount() + 1); + goods.setUpdateTime(new Date()); + tbPointsGoodsSettingMapper.updateById(goods); + } + + @Override + public void cancel(TbPointsExchangeRecord record) { + if (record.getId() == null) { + throw new BadRequestException("订单ID不能为空"); + } + TbPointsExchangeRecord entity = super.getById(record.getId()); + if (entity == null) { + throw new BadRequestException("订单不存在"); + } + if (!"unpaid".equals(entity.getStatus())) { + throw new BadRequestException("当前订单状态不支持取消"); + } + entity.setStatus("cancel"); + entity.setCancelOrRefundReason(record.getCancelOrRefundReason()); + entity.setCancelOrRefundTime(new Date()); + super.updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void refund(TbPointsExchangeRecord record) { + if (record.getId() == null) { + throw new BadRequestException("订单ID不能为空"); + } + TbPointsExchangeRecord entity = super.getById(record.getId()); + if (entity == null) { + throw new BadRequestException("订单不存在"); + } + if (!"waiting".equals(entity.getStatus())) { + throw new BadRequestException("当前订单状态不支持退款"); + } + // 先退积分 + entity.setStatus("cancel"); + entity.setCancelOrRefundReason(record.getCancelOrRefundReason()); + entity.setCancelOrRefundTime(new Date()); + super.updateById(entity); + TbMemberPoints memberPoints = tbMemberPointsMapper.selectOne(Wrappers.lambdaQuery().eq(TbMemberPoints::getMemberId, entity.getMemberId())); + if (memberPoints == null) { + throw new BadRequestException("会员信息不存在"); + } + memberPoints.setAccountPoints(memberPoints.getAccountPoints() + entity.getSpendPoints()); + memberPoints.setLastPointsChangeTime(new Date()); + memberPoints.setLastFloatPoints(entity.getSpendPoints()); + tbMemberPointsMapper.updateById(memberPoints); + // 回滚库存 + TbPointsGoodsSetting goods = tbPointsGoodsSettingMapper.selectById(entity.getPointsGoodsId()); + if (goods == null) { + throw new BadRequestException("积分商品不存在"); + } + goods.setQuantity(goods.getQuantity() + 1); + goods.setUpdateTime(new Date()); + tbPointsGoodsSettingMapper.updateById(goods); + // 记录积分浮动流水 + TbMemberPointsLog log = new TbMemberPointsLog(); + log.setShopId(entity.getShopId()); + log.setMemberId(entity.getMemberId()); + log.setMemberName(entity.getMemberName()); + log.setMobile(entity.getMobile()); + log.setAvatarUrl(entity.getAvatarUrl()); + log.setContent(StrUtil.format("(退单)兑换商品:{} * {}", entity.getPointsGoodsName(), "1")); + log.setFloatType("add"); + log.setFloatPoints(+entity.getSpendPoints()); + log.setCreateTime(new Date()); + tbMemberPointsLogMapper.insert(log); + // 如果额外付款了则需要退款 + if (NumberUtil.equals(entity.getExtraPaymentAmount(), BigDecimal.ZERO)) { + return; + } + // 需要额外支付 + TbShopInfo shopInfo = mpShopInfoMapper.selectById(entity.getShopId()); + if (shopInfo == null) { + throw new BadRequestException("店铺信息不存在"); + } + TbMerchantThirdApply thirdApply = tbMerchantThirdApplyRepository.getById(Integer.valueOf(shopInfo.getMerchantId())); + if (thirdApply == null) { + throw new BadRequestException("支付通道不存在"); + } + if ("alipay".equalsIgnoreCase(entity.getPayType()) && StrUtil.isBlank(thirdApply.getAlipaySmallAppid())) { + throw new BadRequestException("店铺未配置支付宝小程序appId"); + } + // 准备退款参数 + // 应用ID + String appId = thirdApply.getAppId(); + String appToken = thirdApply.getAppToken(); + // 交易金额 单位分 100 表示1元 + long amount = NumberUtil.mul(record.getExtraPaymentAmount(), new BigDecimal("100")).longValue(); + // 退款订单号 + String mchRefundNo = entity.getOrderNo(); + PublicResp publicResp; + try { + publicResp = thirdPayService.returnOrder(thirdUrl, appId, mchRefundNo, entity.getPayOrderId(), null, entity.getCancelOrRefundReason(), amount, null, null, appToken); + } catch (Exception e) { + super.log.error("发起退款失败:", e); + throw new BadRequestException(StrUtil.format("发起退款失败:{}", e.getMessage())); + } + if (publicResp == null) { + throw new BadRequestException("发起退款失败:无响应"); + } + if (!"000000".equals(publicResp.getCode())) { + throw new BadRequestException(publicResp.getMsg()); + } + OrderReturnResp returnResp = publicResp.getObjData(); + if (!"SUCCESS".equals(returnResp.getState())) { + throw new BadRequestException(StrUtil.format("退款失败原因:{}", returnResp.getState())); + } + } + + @Override + public Map total(Map params) { + LambdaQueryWrapper wrapper = getWrapper(params); + wrapper.select(TbPointsExchangeRecord::getCount, TbPointsExchangeRecord::getTotalAmount); + TbPointsExchangeRecord summary = baseMapper.selectOne(wrapper); + Map result = new HashMap<>(2); + result.put("count", summary.getCount()); + result.put("totalAmount", NumberUtil.null2Zero(summary.getTotalAmount())); + return result; + } + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPointsGoodsSettingServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPointsGoodsSettingServiceImpl.java new file mode 100644 index 00000000..c475461d --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbPointsGoodsSettingServiceImpl.java @@ -0,0 +1,100 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.map.MapProxy; +import cn.hutool.core.util.StrUtil; +import cn.ysk.cashier.exception.BadRequestException; +import cn.ysk.cashier.mybatis.entity.TbPointsGoodsSetting; +import cn.ysk.cashier.mybatis.mapper.TbPointsGoodsSettingMapper; +import cn.ysk.cashier.mybatis.service.TbPointsGoodsSettingService; +import cn.ysk.cashier.utils.PageUtil; +import com.baomidou.mybatisplus.core.metadata.OrderItem; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.Map; + +/** + * 积分商品设置 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-25 + */ +@Service +public class TbPointsGoodsSettingServiceImpl extends ServiceImpl implements TbPointsGoodsSettingService { + + + @Override + public Map page(Map params) { + MapProxy mapProxy = MapProxy.create(params); + int pageNum = mapProxy.getInt("page", 1); + int pageSize = mapProxy.getInt("size", 10); + TbPointsGoodsSetting param = BeanUtil.toBean(params, TbPointsGoodsSetting.class); + Page pg = new Page<>(pageNum, pageSize); + pg.addOrder(OrderItem.desc("sort")); + Page page = baseMapper.selectPage(pg, + Wrappers.lambdaQuery() + .eq(TbPointsGoodsSetting::getShopId, param.getShopId()) + .like(StrUtil.isNotEmpty(param.getGoodsName()), TbPointsGoodsSetting::getGoodsName, param.getGoodsName()) + .like(StrUtil.isNotEmpty(param.getGoodsCategory()), TbPointsGoodsSetting::getGoodsCategory, param.getGoodsCategory()) + .eq(param.getStatus() != null, TbPointsGoodsSetting::getStatus, param.getStatus()) + .eq(TbPointsGoodsSetting::getDelFlag, 0) + .orderByDesc(TbPointsGoodsSetting::getId) + ); + return PageUtil.toPlusPage(page.getRecords(), Convert.toInt(page.getTotal())); + } + + @Override + public boolean save(TbPointsGoodsSetting entity) { + try { + Assert.notNull(entity.getShopId(), "{}({})不能为空", "店铺id", "shopId"); + Assert.notEmpty(entity.getGoodsCategory(), "{}({})不能为空", "商品类型", "goodsCategory"); + Assert.notEmpty(entity.getGoodsName(), "{}({})不能为空", "商品名称", "goodsName"); + //Assert.notNull(entity.getGoodsImageUrl(), "{}({})不能为空", "商品图片URL","goodsImageUrl"); + Assert.notNull(entity.getRequiredPoints(), "{}({})不能为空", "所需积分", "requiredPoints"); + Assert.notNull(entity.getExtraPrice(), "{}({})不能为空", "额外价格", "extraPrice"); + Assert.notNull(entity.getSort(), "{}({})不能为空", "排序(权重)", "sort"); + Assert.notNull(entity.getQuantity(), "{}({})不能为空", "数量", "quantity"); + //Assert.notEmpty(entity.getGoodsDescription(), "{}({})不能为空", "商品详情","goodsDescription"); + Assert.notNull(entity.getStatus(), "{}({})不能为空", "是否上架", "status"); + } catch (IllegalArgumentException e) { + throw new BadRequestException(e.getMessage()); + } + entity.setCreateTime(new Date()); + return super.save(entity); + } + + @Override + public boolean update(TbPointsGoodsSetting dto) { + try { + Assert.notNull(dto.getId(), "{}不能为空", "商品id"); + Assert.notNull(dto.getShopId(), "{}({})不能为空", "店铺id", "shopId"); + Assert.notEmpty(dto.getGoodsCategory(), "{}({})不能为空", "商品类型", "goodsCategory"); + Assert.notEmpty(dto.getGoodsName(), "{}({})不能为空", "商品名称", "goodsName"); + //Assert.notNull(entity.getGoodsImageUrl(), "{}({})不能为空", "商品图片URL","goodsImageUrl"); + Assert.notNull(dto.getRequiredPoints(), "{}({})不能为空", "所需积分", "requiredPoints"); + Assert.notNull(dto.getExtraPrice(), "{}({})不能为空", "额外价格", "extraPrice"); + Assert.notNull(dto.getSort(), "{}({})不能为空", "排序(权重)", "sort"); + Assert.notNull(dto.getQuantity(), "{}({})不能为空", "数量", "quantity"); + //Assert.notEmpty(entity.getGoodsDescription(), "{}({})不能为空", "商品详情","goodsDescription"); + Assert.notNull(dto.getStatus(), "{}({})不能为空", "是否上架", "status"); + } catch (IllegalArgumentException e) { + throw new BadRequestException(e.getMessage()); + } + TbPointsGoodsSetting entity = super.getById(dto.getId()); + BeanUtil.copyProperties(dto, entity, CopyOptions.create().setIgnoreNullValue(false).setIgnoreProperties("createTime")); + entity.setUpdateTime(new Date()); + return super.updateById(entity); + } + + @Override + public void delete(Long id) { + super.update(Wrappers.lambdaUpdate().set(TbPointsGoodsSetting::getDelFlag, 1).eq(TbPointsGoodsSetting::getId, id)); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopCouponServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopCouponServiceImpl.java new file mode 100644 index 00000000..3554e500 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopCouponServiceImpl.java @@ -0,0 +1,388 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateUtil; +import cn.ysk.cashier.cons.TableConstant; +import cn.ysk.cashier.dto.CouponDto; +import cn.ysk.cashier.dto.QueryReceiveDto; +import cn.ysk.cashier.dto.TbShopCouponQueryCriteria; +import cn.ysk.cashier.exception.BadRequestException; +import cn.ysk.cashier.mybatis.entity.*; +import cn.ysk.cashier.mybatis.mapper.*; +import cn.ysk.cashier.mybatis.service.*; +import cn.ysk.cashier.mybatis.vo.TbShopCouponVo; +import cn.ysk.cashier.pojo.order.TbCashierCart; +import cn.ysk.cashier.pojo.order.TbOrderDetail; +import cn.ysk.cashier.pojo.order.TbOrderInfo; +import cn.ysk.cashier.pojo.product.TbProduct; +import cn.ysk.cashier.pojo.shop.TbShopUser; +import cn.ysk.cashier.repository.order.TbOrderDetailRepository; +import cn.ysk.cashier.repository.order.TbOrderInfoRepository; +import cn.ysk.cashier.repository.product.TbProductRepository; +import cn.ysk.cashier.repository.shop.TbShopUserRepository; +import cn.ysk.cashier.service.shop.TbShopUserService; +import cn.ysk.cashier.utils.PageUtil; +import cn.ysk.cashier.vo.QueryReceiveVo; +import cn.ysk.cashier.vo.TbUserCouponVo; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.google.gson.JsonObject; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.math.BigDecimal; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 优惠券(TbShopCoupon)表服务实现类 + * + * @author ww + * @since 2024-10-22 15:43:25 + */ +@Service("tbShopCouponService") +public class TbShopCouponServiceImpl extends ServiceImpl implements TbShopCouponService { + + @Autowired + private TbShopCouponMapper tbShopCouponmapper; + @Autowired + private TbActivateMapper activateMapper; + @Autowired + private TbCouponProductService couProductService; + @Autowired + private TbProductRepository tbProductRepository; + @Autowired + private TbShopUserRepository shopUserRepository; + @Autowired + private TbOrderInfoRepository orderInfoRepository; + @Autowired + private TbOrderDetailRepository orderDetailRepository; + @Autowired + private TbActivateInRecordMapper inRecordMapper; + @Autowired + private TbActivateOutRecordMapper outRecordMapper; + @Autowired + private TbShopShareRecordService shareRecordService; + private final MpShopUserService shopUserService; + private final MpOrderInfoService mpOrderInfoService; + private final MpCashierCartService mpCashierCartService; + + public TbShopCouponServiceImpl(MpShopUserService shopUserService, MpOrderInfoService mpOrderInfoService, MpCashierCartService mpCashierCartService) { + this.shopUserService = shopUserService; + this.mpOrderInfoService = mpOrderInfoService; + this.mpCashierCartService = mpCashierCartService; + } + + + @Override + public Map queryAll(TbShopCouponQueryCriteria criteria) { + Page page = new Page<>(criteria.getPage(), criteria.getSize()); + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("shop_id", criteria.getShopId()); + if (criteria.getType() != null) { + wrapper.eq("type", criteria.getType()); + } + wrapper.orderByDesc("create_time"); + Page ipage = tbShopCouponmapper.selectPage(page, wrapper); + return PageUtil.toPage(ipage.getRecords(), ipage.getTotal()); + } + + @Override + public Map queryReceive(QueryReceiveDto param) { + Page page = new Page<>(param.getPage(), param.getSize()); + Page ipage = tbShopCouponmapper.queryReceive(param, page); + return PageUtil.toPage(ipage.getRecords(), ipage.getTotal()); + } + + @Override + public TbShopCouponVo findById(Integer id) { + TbShopCouponVo tbShopCouponVo = new TbShopCouponVo(); + TbShopCoupon tbShopCoupon = tbShopCouponmapper.selectById(id); + BeanUtil.copyProperties(tbShopCoupon, tbShopCouponVo, CopyOptions.create().setIgnoreNullValue(true)); + if (tbShopCoupon.getType() == 2) { + List activatePros = findActivatePros(id); + tbShopCouponVo.setProducts(activatePros); + } + return tbShopCouponVo; + } + + @Override + public boolean update(TbShopCouponVo param) { + if (param.getId() == null) { + param.setLeftNumber(param.getNumber()); + tbShopCouponmapper.insert(param); + } else { + tbShopCouponmapper.updateById(param); + } + if (CollectionUtil.isNotEmpty(param.getProducts())) { + List collect = new ArrayList<>(); + for (TbCouponProduct product : param.getProducts()) { + product.setCouponId(param.getId()); + if (product.getId() != null) collect.add(product.getId()); + } + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("coupon_id", param.getId()); + List actProducts = couProductService.list(queryWrapper); + for (TbCouponProduct actProduct : actProducts) { + if (!collect.contains(actProduct.getId())) { + couProductService.removeById(actProduct.getId()); + } + } + couProductService.saveOrUpdateBatch(param.getProducts()); + } else { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(TbCouponProduct::getCouponId, param.getId()); + couProductService.remove(queryWrapper); + } + return true; + } + + @Override + public boolean deleteReceive(Integer[] ids) { + inRecordMapper.deleteBatchIds(Arrays.asList(ids)); + return true; + } + + @Override + public boolean delete(Integer[] ids) { + for (Integer id : ids) { + List tbActivates = activateMapper.queActByCouponId(id); + if (CollectionUtil.isNotEmpty(tbActivates)) { + throw new BadRequestException("该优惠券已关联活动,请解绑后删除"); + } + Integer i = inRecordMapper.countNoUseCoupon(id); + if (i != null && i > 0) { + throw new BadRequestException("该优惠券有发放后未使用,无法删除"); + } + } + tbShopCouponmapper.deleteBatchIds(Arrays.asList(ids)); + for (Integer id : ids) { + couProductService.remove(new LambdaQueryWrapper().eq(TbCouponProduct::getCouponId, id)); + } + return true; + } + + @Override + public List getActivateCoupon(TbShopUser tbShopUser, BigDecimal orderAmount, Integer shopId, Set productIds) { + List tbUserCouponVos = inRecordMapper.queryByVipIdAndShopId(tbShopUser.getId(), shopId); + if (tbUserCouponVos.isEmpty()) { + return tbUserCouponVos; + } + String week = DateUtil.dayOfWeekEnum(new Date()).toChinese("周"); + LocalTime now = LocalTime.now(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss"); + //券id 券使用描述 + Map coupons = new HashMap<>(); + for (TbUserCouponVo tbUserCouponVo : tbUserCouponVos) { + if (!coupons.containsKey(tbUserCouponVo.getCouponId())) { + setCouponInfo(coupons, tbUserCouponVo, orderAmount, week, now, formatter); + } + JsonObject couponJson = coupons.get(tbUserCouponVo.getCouponId()); + tbUserCouponVo.setUseRestrictions(couponJson.get("useRestrictions").toString()); + if (tbUserCouponVo.getType().equals(1)) { + tbUserCouponVo.setUse(couponJson.get("isUse").getAsBoolean()); + } else if (tbUserCouponVo.getType().equals(2) && couponJson.get("isUse").getAsBoolean()) { + tbUserCouponVo.setUse(couponJson.get("isUse").getAsBoolean()); + if (!productIds.contains(tbUserCouponVo.getProId().toString())) { + tbUserCouponVo.setUse(false); + } + } + } + tbUserCouponVos.sort(Comparator.comparing(TbUserCouponVo::isUse).reversed().thenComparing(TbUserCouponVo::getExpireTime)); + return tbUserCouponVos; + } + + private void setCouponInfo(Map coupons, TbUserCouponVo tbUserCouponVo, BigDecimal amount, String week, LocalTime now, DateTimeFormatter formatter) { + JsonObject json = new JsonObject(); + boolean isUse = true; + TbShopCoupon tbShopCoupon = getById(tbUserCouponVo.getCouponId()); + StringBuilder useRestrictions = new StringBuilder("每天 "); + if (tbShopCoupon.getType().equals(1)) { + if (amount.compareTo(tbShopCoupon.getFullAmount()) < 0) { + isUse = false; + } + } + if (StringUtils.isNotBlank(tbShopCoupon.getUserDays())) { + String[] split = tbShopCoupon.getUserDays().split(","); + if (split.length != 7) { + useRestrictions = new StringBuilder(tbShopCoupon.getUserDays() + " "); + } + if (!tbShopCoupon.getUserDays().contains(week)) { + isUse = false; + } + } + if (tbShopCoupon.getUseTimeType().equals("custom")) { + if (now.isBefore(tbShopCoupon.getUseStartTime()) || now.isAfter(tbShopCoupon.getUseEndTime())) { + isUse = false; + } + useRestrictions.append( + tbShopCoupon.getUseStartTime().format(formatter) + + "-" + + tbShopCoupon.getUseEndTime().format(formatter)); + } else { + useRestrictions.append("全时段"); + } + useRestrictions.append(" 可用"); + json.addProperty("isUse", isUse); + json.addProperty("useRestrictions", useRestrictions.toString()); + + coupons.put(tbUserCouponVo.getCouponId(), json); + } + + + @Override + public ResponseEntity find(CouponDto param) { + TbShopUser tbShopUser = shopUserRepository.selectByUserIdAndShopId(param.getUserId().toString(), param.getShopId().toString()); + if (param.getOrderId() != null) { + List tbUserCouponVos = inRecordMapper.queryByVipIdAndShopId(tbShopUser.getId(), param.getShopId()); + if (CollectionUtil.isNotEmpty(tbUserCouponVos)) { + String week = DateUtil.dayOfWeekEnum(new Date()).toChinese("周"); + LocalTime now = LocalTime.now(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss"); + + //券id 券使用描述 + Map coupons = new HashMap<>(); + for (TbUserCouponVo tbUserCouponVo : tbUserCouponVos) { + if (!coupons.containsKey(tbUserCouponVo.getCouponId())) { + setCouponInfo(coupons, tbUserCouponVo, null, week, now, formatter); + } + JsonObject couponJson = coupons.get(tbUserCouponVo.getCouponId()); + tbUserCouponVo.setUseRestrictions(couponJson.get("useRestrictions").toString()); + tbUserCouponVo.setUse(couponJson.get("isUse").getAsBoolean()); + } + tbUserCouponVos.sort(Comparator.comparing(TbUserCouponVo::isUse).reversed().thenComparing(TbUserCouponVo::getExpireTime)); + return new ResponseEntity<>(tbUserCouponVos, HttpStatus.OK); + } + } + return new ResponseEntity<>(HttpStatus.OK); + } + + /** + * 使用券 + * + * @param shopId + * @param orderId + * @param vipUserId + * @param param giveId 和 useNum 必传 + * @return + */ + @Override + public boolean use(Integer shopId, Integer orderId, Integer vipUserId, List param) { + for (TbActivateOutRecord outRecord : param) { + TbActivateInRecord inRecord = inRecordMapper.selectById(outRecord.getGiveId()); + if (inRecord.getSource() != null && inRecord.getSource().equals("invited")) { + TbShopShareRecord shareRecord = shareRecordService.getById(inRecord.getSourceActId()); + if (shareRecord != null && shareRecord.getMethod().equals("use")) { + shareRecord.setStatus(3); + shareRecordService.give(shareRecord, shareRecord.getInvitedId()); + shareRecordService.updateById(shareRecord); + } + } + + inRecord.setOverNum(inRecord.getOverNum() - outRecord.getUseNum()); + inRecordMapper.updateOverNum(inRecord.getId(), inRecord.getOverNum()); + + outRecord.setType(inRecord.getType()); + outRecord.setShopId(shopId); + outRecord.setOrderId(orderId.toString()); + outRecord.setVipUserId(vipUserId); + outRecord.setStatus("closed"); + outRecord.setCreateTime(new Date()); + outRecordMapper.insert(outRecord); + } + return true; + } + + /** + * 退还券 + * + * @param param giveId和 refNum 必传 + * @return + */ + @Override + public boolean refund(List param) { + for (TbActivateOutRecord outRecord : param) { + outRecord.setUpdateTime(new Date()); + outRecordMapper.updateRefNum(outRecord.getId(), outRecord.getRefNum()); + TbActivateInRecord inRecord = inRecordMapper.selectById(outRecord.getGiveId()); + inRecord.setOverNum(inRecord.getOverNum() + outRecord.getRefNum()); + inRecordMapper.updateOverNum(inRecord.getId(), inRecord.getOverNum()); + } + return true; + } + + + @Override + public List findActivatePros(Integer couponId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("coupon_id", couponId); + List actProducts = couProductService.list(queryWrapper); + if (!CollectionUtils.isEmpty(actProducts)) { + for (TbCouponProduct actProduct : actProducts) { + TbProduct product = tbProductRepository.findById(actProduct.getProductId()).orElse(null); + if (product != null) { + actProduct.setName(product.getName()); + actProduct.setCoverImg(product.getCoverImg()); + } + } + return actProducts; + } + return new ArrayList<>(); + } + + @Override + public List selectByIds(List couponIds) { + return listByIds(couponIds); + } + + @Override + public Object getActivateByOrderIds(Integer shopId, Integer orderId, Integer memberId) { + TbOrderInfo orderInfo = mpOrderInfoService.selectOrderByIdAndState(orderId, TableConstant.OrderInfo.Status.UNPAID); + if (orderInfo == null) { + throw new BadRequestException("订单信息不存在"); + } + + if (memberId == null && orderInfo.getMemberId() == null) { + throw new BadRequestException("请先选择对应的会员信息"); + } + + if (memberId == null) { + memberId = Integer.valueOf(orderInfo.getMemberId()); + } + + TbShopUser shopUser = shopUserService.getById(memberId); + if (shopUser == null) { + throw new BadRequestException("用户信息不存在"); + } + + List cashierCarts = mpCashierCartService.selectByOrderIdAndState(orderId, TableConstant.OrderInfo.Status.CREATE, TableConstant.OrderInfo.Status.CLOSED, TableConstant.OrderInfo.Status.FINAL); + List activateCouponList = getActivateCoupon(shopUser, orderInfo.getOrderAmount(), shopId, cashierCarts.stream().map(TbCashierCart::getProductId).collect(Collectors.toSet())); + // 将优惠券分类为满减和商品 + ArrayList fullReductionCoupon = new ArrayList<>(); + ArrayList productCoupon = new ArrayList<>(); + activateCouponList.forEach(item -> { + if (TableConstant.ActivateOutRecord.Type.FULL_REDUCTION.equalsVals(item.getType())) { + fullReductionCoupon.add(item); + } else { + productCoupon.add(item); + } + }); + return new HashMap() {{ + put("fullReductionCoupon", fullReductionCoupon); + put("productCoupon", productCoupon); + }}; + } + + +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopExtendServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopExtendServiceImpl.java index cf85c458..a24244bd 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopExtendServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopExtendServiceImpl.java @@ -86,7 +86,7 @@ public class TbShopExtendServiceImpl extends ServiceImpl checkAndInitialize(Page ipage, Integer shopId) { List newRecords = new ArrayList<>(); - List requiredAutokeys = Arrays.asList("index_bg", "my_bg", "member_bg", "shopinfo_bg"); + List requiredAutokeys = Arrays.asList("index_bg", "my_bg", "member_bg", "shopinfo_bg","ticket_logo"); if (ipage == null || ipage.getRecords() == null || ipage.getRecords().isEmpty()) { // ipage 为空,直接创建包含四种类型数据的新 Page 对象 @@ -114,6 +114,9 @@ public class TbShopExtendServiceImpl extends ServiceImpl existingAutokeys = shopExtends.stream() diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopShareRecordServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopShareRecordServiceImpl.java new file mode 100644 index 00000000..fbadec6a --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopShareRecordServiceImpl.java @@ -0,0 +1,136 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import cn.hutool.core.date.DateUtil; +import cn.ysk.cashier.mybatis.entity.*; +import cn.ysk.cashier.mybatis.mapper.*; +import cn.ysk.cashier.mybatis.service.TbCouponProductService; +import cn.ysk.cashier.pojo.shop.TbShopUser; +import cn.ysk.cashier.repository.shop.TbShopUserRepository; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import cn.ysk.cashier.mybatis.service.TbShopShareRecordService; +import org.springframework.stereotype.Service; +import org.apache.commons.lang3.StringUtils; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import cn.ysk.cashier.dto.TbShopShareRecordQueryCriteria; +import org.springframework.beans.factory.annotation.Autowired; +import cn.ysk.cashier.utils.PageUtil; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * (TbShopShareRecord)表服务实现类 + * + * @author ww + * @since 2024-11-08 09:17:37 + */ +@Service("tbShopShareRecordService") +public class TbShopShareRecordServiceImpl extends ServiceImpl implements TbShopShareRecordService { + + @Autowired + private TbShopShareRecordMapper tbShopShareRecordmapper; + @Autowired + private TbShopShareMapper tbShopShareMapper; + @Autowired + private TbShopUserRepository shopUserRepository; + @Autowired + private TbShopCouponMapper couponMapper; + @Autowired + private TbCouponProductMapper couProductMapper; + @Autowired + private TbActivateInRecordMapper inRecordMapper; + + @Override + public Map selectAllByShare(TbShopShareRecordQueryCriteria criteria) { + Page ipage = tbShopShareRecordmapper.selectAllByShare(criteria,new Page<>(criteria.getPage(), criteria.getSize())); + return PageUtil.toPage(ipage.getRecords(), ipage.getTotal()); + } + + @Override + public void give(TbShopShareRecord shareRecord, Integer userId) { + TbShopShare shopShare = tbShopShareMapper.selectById(shareRecord.getShareId()); + TbShopUser tbShopUser = shopUserRepository.selectByUserIdAndShopId(userId.toString(), shopShare.getShopId().toString()); + if (userId.equals(shareRecord.getInvitedId())) { + giveCoupon(shopShare, tbShopUser, shopShare.getRewardCoupons(),shareRecord.getId(), true); + } else if (userId.equals(shareRecord.getBeInvitedId())) { + giveCoupon(shopShare, tbShopUser, shopShare.getNewCoupons(),shareRecord.getId(),false); + } + } + + + public void giveCoupon(TbShopShare shopShare, TbShopUser tbShopUser, List coupons ,Integer flowId, boolean isReward) { + for (TbShopShare.ShareCoupons newCoupon : coupons) { + TbShopCoupon tbShopCoupon = couponMapper.selectById(newCoupon.getCouponId()); + Date start = new Date(); + Date end = new Date(); + if ("fixed".equals(tbShopCoupon.getValidityType())) { + //固定时间 + end = DateUtil.offsetDay(new Date(), tbShopCoupon.getValidDays()); + } else if ("custom".equals(tbShopCoupon.getValidityType())) { + //自定义时间 + start = tbShopCoupon.getValidStartTime(); + end = tbShopCoupon.getValidEndTime(); + } + if (tbShopCoupon != null) { + List actGiveRecords = new ArrayList<>(); + if (tbShopCoupon.getType() == 1) { + //满减 + TbActivateInRecord record = new TbActivateInRecord(); + record.setVipUserId(Integer.valueOf(tbShopUser.getId())); + record.setCouponId(tbShopCoupon.getId()); + record.setName("满" + tbShopCoupon.getFullAmount() + "减" + tbShopCoupon.getDiscountAmount()); + record.setFullAmount(tbShopCoupon.getFullAmount()); + record.setDiscountAmount(tbShopCoupon.getDiscountAmount()); + record.setType(1); + record.setNum(newCoupon.getCouponNum()); + record.setOverNum(newCoupon.getCouponNum()); + record.setShopId(Integer.valueOf(tbShopUser.getShopId())); + record.setSourceActId(shopShare.getId()); + record.setSourceFlowId(flowId); + record.setUseStartTime(start); + record.setUseEndTime(end); + if(isReward){ + record.setSource("invited-reward"); + }else { + record.setSource("invited"); + } + actGiveRecords.add(record); + } else if (tbShopCoupon.getType() == 2) { + //商品卷 + List tbCouponProducts = couProductMapper.queryAllByCouponId(tbShopCoupon.getId()); + for (TbCouponProduct actPro : tbCouponProducts) { + TbActivateInRecord record = new TbActivateInRecord(); + record.setVipUserId(Integer.valueOf(tbShopUser.getId())); + record.setCouponId(tbShopCoupon.getId()); + record.setName("商品卷"); + record.setType(2); + record.setProId(actPro.getProductId()); + record.setNum(actPro.getNum() * tbShopCoupon.getNumber()); + record.setOverNum(actPro.getNum() * tbShopCoupon.getNumber()); + record.setShopId(Integer.valueOf(tbShopUser.getShopId())); + record.setSourceActId(shopShare.getId()); + record.setSourceFlowId(flowId); + record.setUseStartTime(start); + record.setUseEndTime(end); + if(isReward){ + record.setSource("invited-reward"); + }else { + record.setSource("invited"); + } + actGiveRecords.add(record); + } + } + inRecordMapper.insert(actGiveRecords); + if(!isReward){ + tbShopCoupon.setLeftNumber(tbShopCoupon.getLeftNumber()-newCoupon.getCouponNum()); + couponMapper.updateById(tbShopCoupon); + } + } + } + + } +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopShareServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopShareServiceImpl.java new file mode 100644 index 00000000..5216c3de --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopShareServiceImpl.java @@ -0,0 +1,35 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import cn.ysk.cashier.mybatis.mapper.TbShopShareMapper; +import cn.ysk.cashier.mybatis.entity.TbShopShare; +import cn.ysk.cashier.mybatis.service.TbShopShareService; +import org.springframework.stereotype.Service; +import org.apache.commons.lang3.StringUtils; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import org.springframework.beans.factory.annotation.Autowired; +import cn.ysk.cashier.utils.PageUtil; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; + +import java.util.Map; + +/** + * 店铺分享(TbShopShare)表服务实现类 + * + * @author ww + * @since 2024-11-06 15:47:37 + */ +@Service("tbShopShareService") +public class TbShopShareServiceImpl extends ServiceImpl implements TbShopShareService { + + @Autowired + private TbShopShareMapper tbShopSharemapper; + + @Override + public TbShopShare getByShopId(Integer shopId) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("shop_id", shopId); + return tbShopSharemapper.selectOne(wrapper); + } +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/vo/ActivateProsVo.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/vo/ActivateProsVo.java deleted file mode 100644 index 2292ce20..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/vo/ActivateProsVo.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.ysk.cashier.mybatis.vo; - -import lombok.Data; - -@Data -public class ActivateProsVo { - private Integer id; - private String name; - private String coverImg; - private Integer num; - - public ActivateProsVo(Integer id, String name, String coverImg) { - this.id = id; - this.name = name; - this.coverImg = coverImg; - } -} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/vo/TbShopCouponVo.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/vo/TbShopCouponVo.java new file mode 100644 index 00000000..f5eb8c80 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/vo/TbShopCouponVo.java @@ -0,0 +1,14 @@ +package cn.ysk.cashier.mybatis.vo; + +import cn.ysk.cashier.mybatis.entity.TbCouponProduct; +import cn.ysk.cashier.mybatis.entity.TbShopCoupon; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@Data +public class TbShopCouponVo extends TbShopCoupon { + + private List products = new ArrayList<>(); +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/BotButtonConfig.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/BotButtonConfig.java deleted file mode 100644 index 80314174..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/BotButtonConfig.java +++ /dev/null @@ -1,53 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.pojo; - -import lombok.Data; -import cn.hutool.core.bean.BeanUtil; -import io.swagger.annotations.ApiModelProperty; -import cn.hutool.core.bean.copier.CopyOptions; -import javax.persistence.*; -import java.io.Serializable; - -/** -* @website https://eladmin.vip -* @description / -* @author admin -* @date 2023-10-31 -**/ -@Entity -@Data -@Table(name="bot_button_config") -public class BotButtonConfig implements Serializable { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "`id`") - @ApiModelProperty(value = "id") - private Integer id; - - @Column(name = "`button_name`") - @ApiModelProperty(value = "按钮名称") - private String buttonName; - - @Column(name = "`button_value`") - @ApiModelProperty(value = "按钮值") - private String buttonValue; - - public void copy(BotButtonConfig source){ - BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); - } -} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/BotConfig.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/BotConfig.java deleted file mode 100644 index c1cebb1b..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/BotConfig.java +++ /dev/null @@ -1,57 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.pojo; - -import lombok.Data; -import cn.hutool.core.bean.BeanUtil; -import io.swagger.annotations.ApiModelProperty; -import cn.hutool.core.bean.copier.CopyOptions; -import javax.persistence.*; -import java.io.Serializable; - -/** -* @website https://eladmin.vip -* @description / -* @author admin -* @date 2023-10-31 -**/ -@Entity -@Data -@Table(name="bot_config") -public class BotConfig implements Serializable { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "`id`") - @ApiModelProperty(value = "id") - private Integer id; - - @Column(name = "`config_key`") - @ApiModelProperty(value = "元素键值") - private String configKey; - - @Column(name = "`config_value`") - @ApiModelProperty(value = "元素值") - private String configValue; - - @Column(name = "`remark`") - @ApiModelProperty(value = "描述") - private String remark; - - public void copy(BotConfig source){ - BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); - } -} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/BotUser.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/BotUser.java deleted file mode 100644 index 0b6b799d..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/BotUser.java +++ /dev/null @@ -1,123 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.pojo; - -import lombok.Data; -import cn.hutool.core.bean.BeanUtil; -import io.swagger.annotations.ApiModelProperty; -import cn.hutool.core.bean.copier.CopyOptions; -import javax.persistence.*; -import java.sql.Timestamp; -import java.math.BigDecimal; -import java.io.Serializable; - -/** -* @website https://eladmin.vip -* @description / -* @author admin -* @date 2023-10-30 -**/ -@Entity -@Data -@Table(name="bot_user") -public class BotUser implements Serializable { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "`id`") - @ApiModelProperty(value = "id") - private Integer id; - - @Column(name = "`father_id`") - @ApiModelProperty(value = "fatherId") - private Integer fatherId; - - @Column(name = "`father_telegram_id`") - @ApiModelProperty(value = "父级电报号") - private String fatherTelegramId; - - @Column(name = "`user_telegram_id`") - @ApiModelProperty(value = "电报号") - private String userTelegramId; - - @Column(name = "`user_name`") - @ApiModelProperty(value = "用户名称") - private String userName; - - @Column(name = "`group_telegram_id`") - @ApiModelProperty(value = "组电报号") - private String groupTelegramId; - - @Column(name = "`user_code`") - @ApiModelProperty(value = "用户代码") - private String userCode; - - @Column(name = "`user_pay_pass`") - @ApiModelProperty(value = "userPayPass") - private String userPayPass; - - @Column(name = "`bomb_status`") - @ApiModelProperty(value = "bombStatus") - private String bombStatus; - - @Column(name = "`bot_status`") - @ApiModelProperty(value = "用户状态") - private String botStatus; - - @Column(name = "`usdt_recharge_total`") - @ApiModelProperty(value = "总充值") - private BigDecimal usdtRechargeTotal; - - @Column(name = "`usdt_withdraw_total`") - @ApiModelProperty(value = "总提现") - private BigDecimal usdtWithdrawTotal; - - @Column(name = "`balance`") - @ApiModelProperty(value = "总资金") - private BigDecimal balance; - - @Column(name = "`freeze_balance`") - @ApiModelProperty(value = "冻结资金") - private BigDecimal freezeBalance; - - @Column(name = "`version`") - @ApiModelProperty(value = "版本号") - private Integer version; - - @Column(name = "`create_time`") - @ApiModelProperty(value = "创建时间") - private Timestamp createTime; - - @Column(name = "`update_time`") - @ApiModelProperty(value = "更新时间") - private Timestamp updateTime; - - @Column(name = "`user_language`") - @ApiModelProperty(value = "语言") - private String userLanguage; - - @Column(name = "`chip_balance`") - @ApiModelProperty(value = "质押资金") - private BigDecimal chipBalance; - - @Column(name = "`father_bind_time`") - @ApiModelProperty(value = "绑定时间") - private Timestamp fatherBindTime; - - public void copy(BotUser source){ - BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); - } -} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/BotUserFlow.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/BotUserFlow.java deleted file mode 100644 index 729eb26b..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/BotUserFlow.java +++ /dev/null @@ -1,75 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.pojo; - -import lombok.Data; -import cn.hutool.core.bean.BeanUtil; -import io.swagger.annotations.ApiModelProperty; -import cn.hutool.core.bean.copier.CopyOptions; -import javax.persistence.*; -import java.sql.Timestamp; -import java.math.BigDecimal; -import java.io.Serializable; - -/** -* @website https://eladmin.vip -* @description / -* @author admin -* @date 2023-10-30 -**/ -@Entity -@Data -@Table(name="bot_user_flow") -public class BotUserFlow implements Serializable { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "`id`") - @ApiModelProperty(value = "id") - private Integer id; - - @Column(name = "`user_telegram_id`") - @ApiModelProperty(value = "电报号") - private String userTelegramId; - - @Column(name = "`user_name`") - @ApiModelProperty(value = "用户名称") - private String userName; - - @Column(name = "`biz_code`") - @ApiModelProperty(value = "业务代码") - private String bizCode; - - @Column(name = "`amount`") - @ApiModelProperty(value = "变动金额") - private BigDecimal amount; - - @Column(name = "`old_balance`") - @ApiModelProperty(value = "变动前金额") - private BigDecimal oldBalance; - - @Column(name = "`new_balance`") - @ApiModelProperty(value = "变动后金额") - private BigDecimal newBalance; - - @Column(name = "`create_time`") - @ApiModelProperty(value = "创建时间") - private Timestamp createTime; - - public void copy(BotUserFlow source){ - BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); - } -} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/TbRenewalsPayLog.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/TbRenewalsPayLog.java deleted file mode 100644 index 14823320..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/TbRenewalsPayLog.java +++ /dev/null @@ -1,100 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.pojo; - -import lombok.Data; -import cn.hutool.core.bean.BeanUtil; -import io.swagger.annotations.ApiModelProperty; -import cn.hutool.core.bean.copier.CopyOptions; -import javax.persistence.*; -import javax.validation.constraints.*; -import java.math.BigDecimal; -import java.io.Serializable; - -/** -* @website https://eladmin.vip -* @description / -* @author lyf -* @date 2023-11-07 -**/ -@Entity -@Data -@Table(name="tb_renewals_pay_log") -public class TbRenewalsPayLog implements Serializable { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "`id`") - @ApiModelProperty(value = "id") - private Integer id; - - @Column(name = "`pay_type`") - @ApiModelProperty(value = "支付方式") - private String payType; - - @Column(name = "`shop_id`") - @ApiModelProperty(value = "店铺Id") - private String shopId; - - @Column(name = "`order_id`") - @ApiModelProperty(value = "订单Id") - private String orderId; - - @Column(name = "`open_id`") - @ApiModelProperty(value = "openId") - private String openId; - - @Column(name = "`user_id`") - @ApiModelProperty(value = "用户Id") - private String userId; - - @Column(name = "`transaction_id`") - @ApiModelProperty(value = "交易单号(第三方交易单号)") - private String transactionId; - - @Column(name = "`amount`",nullable = false) - @NotNull - @ApiModelProperty(value = "金额") - private BigDecimal amount; - - @Column(name = "`status`") - @ApiModelProperty(value = "状态 ") - private Integer status; - - @Column(name = "`remark`") - @ApiModelProperty(value = "备注") - private String remark; - - @Column(name = "`attach`") - @ApiModelProperty(value = "用户自定义参数") - private String attach; - - @Column(name = "`expired_at`") - @ApiModelProperty(value = "到期时间") - private Long expiredAt; - - @Column(name = "`created_at`") - @ApiModelProperty(value = "创建时间") - private Long createdAt; - - @Column(name = "`updated_at`") - @ApiModelProperty(value = "updatedAt") - private Long updatedAt; - - public void copy(TbRenewalsPayLog source){ - BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); - } -} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java index e437561b..0fdca385 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbCashierCart.java @@ -1,38 +1,39 @@ /* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright 2019-2020 Zheng Jie + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package cn.ysk.cashier.pojo.order; import lombok.Data; import cn.hutool.core.bean.BeanUtil; import io.swagger.annotations.ApiModelProperty; import cn.hutool.core.bean.copier.CopyOptions; + import javax.persistence.*; import javax.validation.constraints.*; import java.math.BigDecimal; import java.io.Serializable; /** -* @website https://eladmin.vip -* @description / -* @author lyf -* @date 2024-03-02 -**/ + * @author lyf + * @website https://eladmin.vip + * @description / + * @date 2024-03-02 + **/ @Entity @Data -@Table(name="tb_cashier_cart") +@Table(name = "tb_cashier_cart") public class TbCashierCart implements Serializable { @Id @@ -81,7 +82,7 @@ public class TbCashierCart implements Serializable { @ApiModelProperty(value = "单价") private BigDecimal salePrice; - @Column(name = "`number`",nullable = false) + @Column(name = "`number`", nullable = false) @NotNull @ApiModelProperty(value = "结余数量") private Integer number; @@ -163,8 +164,45 @@ public class TbCashierCart implements Serializable { private String useType; @Column(name = "platform_type") private String platformType; + // 优惠券id + private Integer userCouponId; + private BigDecimal memberPrice = BigDecimal.ZERO; + private Integer isMember; - public void copy(TbCashierCart source){ - BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + public void copy(TbCashierCart source) { + BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true)); + } + + /** + * 根据是否会员充值价格 + */ + public void resetTotalAmount() { + if ("false".equals(isPack)) { + packFee = BigDecimal.ZERO; + } + if ("true".equals(isGift)) { + totalAmount = packFee; + } else { + if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) { + totalAmount = BigDecimal.valueOf(totalNumber).multiply(memberPrice).add(packFee); + } else { + totalAmount = BigDecimal.valueOf(totalNumber).multiply(salePrice).add(packFee); + } + } + } + + /** + * 获取总价不包含打包费 + * + */ + public BigDecimal getTotalAmountByNum(Integer num) { + if (num == null) { + num = totalNumber; + } + if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) { + return BigDecimal.valueOf(num).multiply(memberPrice); + } else { + return BigDecimal.valueOf(num).multiply(salePrice); + } } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java index 1c6efc4f..d33d9489 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderDetail.java @@ -128,6 +128,9 @@ public class TbOrderDetail implements Serializable { @Column(name = "`return_num`") private String returnNum; + private BigDecimal memberPrice; + private Integer userCouponId; + public void copy(TbOrderDetail source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderInfo.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderInfo.java index f685be5d..260e82cd 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderInfo.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/order/TbOrderInfo.java @@ -240,6 +240,19 @@ public class TbOrderInfo implements Serializable { @Column(name = "`refund_remark`") private String refundRemark; + + // 积分折扣金额 + private BigDecimal pointsDiscountAmount; + // 使用的积分数量 + private Integer pointsNum; + // 用户优惠券id + private String couponInfoList; + // 优惠券折扣金额 + private BigDecimal productCouponDiscountAmount; + // 满减抵扣金额 + private BigDecimal fullCouponDiscountAmount; + private Integer isPostpaid; + public void copy(TbOrderInfo source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbPadLayout.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbPadLayout.java new file mode 100644 index 00000000..5551d65d --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbPadLayout.java @@ -0,0 +1,56 @@ +package cn.ysk.cashier.pojo.product; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * Pad商品布局版式 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-22 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("tb_pad_layout") +public class TbPadLayout { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + /** + * 布局版式名称 + */ + private String name; + /** + * 布局版式代码 + */ + private String code; + /** + * 允许展示最大商品数 + */ + private Integer maximum; + /** + * 详细描述 + */ + private String remark; + /** + * 排序号,升序 + */ + private Integer sort; + /** + * 创建时间 + */ + private Date createTime; + /** + * 删除标志 0-正常 1-已删除 + */ + private Integer delFlag; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbPadProductCategory.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbPadProductCategory.java new file mode 100644 index 00000000..bf990170 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbPadProductCategory.java @@ -0,0 +1,60 @@ +package cn.ysk.cashier.pojo.product; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * Pad商品自定义分类 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-22 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("tb_pad_product_category") +public class TbPadProductCategory { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + /** + * 布局版式id + */ + private Long padLayoutId; + /** + * 自定义名称 + */ + private String customName; + /** + * 商品分类id + */ + private Long productCategoryId; + /** + * 店铺id + */ + private Long shopId; + /** + * 排序 + */ + private Integer sort; + /** + * 备注 + */ + private String remark; + /** + * 创建时间 + */ + private Date createTime; + /** + * 更新时间 + */ + private Date updateTime; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbPadProductCategoryDetail.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbPadProductCategoryDetail.java new file mode 100644 index 00000000..51248a3f --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbPadProductCategoryDetail.java @@ -0,0 +1,40 @@ +package cn.ysk.cashier.pojo.product; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * Pad商品自定义分类明细 + * + * @author Tankaikai tankaikai@aliyun.com + * @since 2.0 2024-10-22 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("tb_pad_product_category_detail") +public class TbPadProductCategoryDetail { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId(type = IdType.AUTO) + private Long id; + /** + * Pad商品自定义分类id + */ + private Long padProductCategoryId; + /** + * 商品id + */ + private Long productId; + /** + * 创建时间 + */ + private Date createTime; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java index 391b1c5e..9a7adb1e 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java @@ -15,18 +15,21 @@ */ package cn.ysk.cashier.pojo.product; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import cn.hutool.core.bean.BeanUtil; import io.swagger.annotations.ApiModelProperty; -import cn.hutool.core.bean.copier.CopyOptions; +import lombok.Data; import javax.persistence.*; -import javax.validation.constraints.*; -import java.math.BigDecimal; +import javax.validation.constraints.NotNull; import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; /** * @website https://eladmin.vip @@ -329,6 +332,14 @@ public class TbProduct implements Serializable { @ApiModelProperty("库存警戒线") private Integer warnLine = 0; + @Transient + @TableField(exist = false) + private TbProductSkuResult skuResult; + + @Transient + @TableField(exist = false) + private List> specList; + public void copy(TbProduct source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProductGroup.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProductGroup.java index e36f5819..185c1570 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProductGroup.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProductGroup.java @@ -1,11 +1,13 @@ package cn.ysk.cashier.pojo.product; -import lombok.Data; import cn.hutool.core.bean.BeanUtil; -import io.swagger.annotations.ApiModelProperty; import cn.hutool.core.bean.copier.CopyOptions; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + import javax.persistence.*; -import javax.validation.constraints.*; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; import java.io.Serializable; /** @@ -55,6 +57,10 @@ public class TbProductGroup implements Serializable { @ApiModelProperty(value = "style") private String style; + @Column(name = "`sort_mode`") + @ApiModelProperty(value = "排序方式,0-默认; 1-价格从高到低; 2-销量由高到低;") + private String sortMode; + @Column(name = "`sort`") @ApiModelProperty(value = "排序") private Integer sort; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbMerchantCoupon.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbMerchantCoupon.java deleted file mode 100644 index 4c01b1d9..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbMerchantCoupon.java +++ /dev/null @@ -1,467 +0,0 @@ - -package cn.ysk.cashier.pojo.shop; - -import lombok.Data; -import cn.hutool.core.bean.BeanUtil; -import io.swagger.annotations.ApiModelProperty; -import cn.hutool.core.bean.copier.CopyOptions; - -import javax.persistence.*; -import javax.validation.constraints.*; -import java.math.BigDecimal; -import java.io.Serializable; -import java.sql.Timestamp; - -/** - * @author lyf - * @website https://eladmin.vip - * @description / - * @date 2024-03-20 - **/ -@Entity -@Table(name = "tb_merchant_coupon") -public class TbMerchantCoupon implements Serializable { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "`id`") - @ApiModelProperty(value = "自增") - private Integer id; - - @Column(name = "`status`") - @ApiModelProperty(value = "状态0-关闭 1 正常") - private Integer status; - - @Column(name = "`title`") - @ApiModelProperty(value = " 优惠券名称") - private String title; - - @Column(name = "`template_id`", nullable = false) - @NotBlank - @ApiModelProperty(value = "templateId") - private String templateId = "0"; - - @Column(name = "`shop_id`") - @ApiModelProperty(value = "shopId") - private String shopId; - - @Column(name = "`shop_snap`") - @ApiModelProperty(value = "shopSnap") - private String shopSnap; - - @Column(name = "`from_time`") - @ApiModelProperty(value = "开始时间") - private Timestamp fromTime; - - @Column(name = "`to_time`") - @ApiModelProperty(value = "到期时间") - private Timestamp toTime; - - @Column(name = "`limit_number`") - @ApiModelProperty(value = "限领数量") - private Integer limitNumber; - - @Column(name = "`number`") - @ApiModelProperty(value = "发放数量") - private Integer number; - - @Column(name = "`use_number`") - @ApiModelProperty(value = "已核销数量") - private Integer useNumber; - - @Column(name = "`left_number`", nullable = false) - @ApiModelProperty(value = "剩余数量") - private Integer leftNumber; - - @Column(name = "`amount`") - @ApiModelProperty(value = "优惠金额") - private BigDecimal amount; - - @Column(name = "`limit_amount`") - @ApiModelProperty(value = "订单满赠金额") - private BigDecimal limitAmount; - - @Column(name = "`is_show`") - @ApiModelProperty(value = "是否显示0-不显示 1显示") - private Integer isShow; - - @Column(name = "`pic`") - @ApiModelProperty(value = "图标") - private String pic; - - @Column(name = "`type`") - @ApiModelProperty(value = "0-满减 1-折扣") - private Integer type; - - @Column(name = "`ratio`") - @ApiModelProperty(value = "折扣 ,一位小数") - private Float ratio; - - @Column(name = "`max_ratio_amount`") - @ApiModelProperty(value = "最大折扣金额") - private BigDecimal maxRatioAmount; - - @Column(name = "`track`") - @ApiModelProperty(value = "优惠券途径,首充|分销") - private String track; - - @Column(name = "`class_type`") - @ApiModelProperty(value = "品类product 商品券 ---cateogry 品类券common -通用券") - @NotNull - private String classType; - - @Column(name = "`effect_type`") - @ApiModelProperty(value = "有效期类型:0-toTime有效 1-effectDays有效") - @NotNull - private Integer effectType; - - @Column(name = "`effect_days`") - @ApiModelProperty(value = "领取之日有效天数") - private Integer effectDays; - - @Column(name = "`relation_ids`") - @ApiModelProperty(value = "关联商品Id") - private String relationIds; - - @Column(name = "`relation_list`") - @ApiModelProperty(value = "relationList") - private String relationList; - - @Column(name = "`editor`") - @ApiModelProperty(value = "发放人") - private String editor; - - @Column(name = "`note`") - @ApiModelProperty(value = "说明") - private String note; - - @Column(name = "`created_at`", nullable = false) - @NotNull - @ApiModelProperty(value = "createdAt") - private Long createdAt; - - @Column(name = "`updated_at`", nullable = false) - @NotNull - @ApiModelProperty(value = "updatedAt") - private Long updatedAt; - - @Column(name = "`furnish_meal`") - @ApiModelProperty(value = "支持堂食") - private Integer furnishMeal; - - @Column(name = "`furnish_express`") - @ApiModelProperty(value = "支持配送") - private Integer furnishExpress; - - @Column(name = "`furnish_draw`") - @ApiModelProperty(value = "支持自提") - private Integer furnishDraw; - - @Column(name = "`furnish_vir`") - @ApiModelProperty(value = "支持虚拟") - private Integer furnishVir; - - @Column(name = "`disable_distribute`") - @ApiModelProperty(value = "disableDistribute") - private Integer disableDistribute; - - @Column(name = "`merchant_id`") - @ApiModelProperty(value = "商户Id") - private String merchantId; - - @Column(name = "`category_id`") - @ApiModelProperty(value = "分类id") - private String categoryId; - - public void copy(TbMerchantCoupon source) { - BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true)); - } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Integer getStatus() { - return status; - } - - public void setStatus(Integer status) { - this.status = status; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getTemplateId() { - return templateId; - } - - public void setTemplateId(String templateId) { - this.templateId = templateId; - } - - public String getShopId() { - return shopId; - } - - public void setShopId(String shopId) { - this.shopId = shopId; - } - - public String getShopSnap() { - return shopSnap; - } - - public void setShopSnap(String shopSnap) { - this.shopSnap = shopSnap; - } - - public Timestamp getFromTime() { - return fromTime; - } - - public void setFromTime(Timestamp fromTime) { - this.fromTime = fromTime; - } - - public Timestamp getToTime() { - return toTime; - } - - public void setToTime(Timestamp toTime) { - this.toTime = toTime; - } - - public Integer getLimitNumber() { - return limitNumber; - } - - public void setLimitNumber(Integer limitNumber) { - this.limitNumber = limitNumber; - } - - public Integer getNumber() { - return number; - } - - public void setNumber(Integer number) { - this.number = number; - } - - public Integer getUseNumber() { - return useNumber; - } - - public void setUseNumber(Integer useNumber) { - this.useNumber = useNumber; - } - - public Integer getLeftNumber() { - return leftNumber; - } - - public void setLeftNumber(Integer leftNumber) { - this.leftNumber = leftNumber; - } - - public BigDecimal getAmount() { - return amount; - } - - public void setAmount(BigDecimal amount) { - this.amount = amount; - } - - public BigDecimal getLimitAmount() { - return limitAmount; - } - - public void setLimitAmount(BigDecimal limitAmount) { - this.limitAmount = limitAmount; - } - - public Integer getIsShow() { - return isShow; - } - - public void setIsShow(Integer isShow) { - this.isShow = isShow; - } - - public String getPic() { - return pic; - } - - public void setPic(String pic) { - this.pic = pic; - } - - public Integer getType() { - return type; - } - - public void setType(Integer type) { - this.type = type; - } - - public Float getRatio() { - return ratio; - } - - public void setRatio(Float ratio) { - this.ratio = ratio; - } - - public BigDecimal getMaxRatioAmount() { - return maxRatioAmount; - } - - public void setMaxRatioAmount(BigDecimal maxRatioAmount) { - this.maxRatioAmount = maxRatioAmount; - } - - public String getTrack() { - return track; - } - - public void setTrack(String track) { - this.track = track; - } - - public String getClassType() { - return classType; - } - - public void setClassType(String classType) { - this.classType = classType; - } - - public Integer getEffectType() { - return effectType; - } - - public void setEffectType(Integer effectType) { - this.effectType = effectType; - } - - public Integer getEffectDays() { - return effectDays; - } - - public void setEffectDays(Integer effectDays) { - this.effectDays = effectDays; - } - - public String getRelationIds() { - return relationIds; - } - - public void setRelationIds(String relationIds) { - this.relationIds = relationIds; - } - - public String getRelationList() { - return relationList; - } - - public void setRelationList(String relationList) { - this.relationList = relationList; - } - - public String getEditor() { - return editor; - } - - public void setEditor(String editor) { - this.editor = editor; - } - - public String getNote() { - return note; - } - - public void setNote(String note) { - this.note = note; - } - - public Long getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(Long createdAt) { - this.createdAt = createdAt; - } - - public Long getUpdatedAt() { - return updatedAt; - } - - public void setUpdatedAt(Long updatedAt) { - this.updatedAt = updatedAt; - } - - public Integer getFurnishMeal() { - return furnishMeal; - } - - public void setFurnishMeal(Integer furnishMeal) { - this.furnishMeal = furnishMeal; - } - - public Integer getFurnishExpress() { - return furnishExpress; - } - - public void setFurnishExpress(Integer furnishExpress) { - this.furnishExpress = furnishExpress; - } - - public Integer getFurnishDraw() { - return furnishDraw; - } - - public void setFurnishDraw(Integer furnishDraw) { - this.furnishDraw = furnishDraw; - } - - public Integer getFurnishVir() { - return furnishVir; - } - - public void setFurnishVir(Integer furnishVir) { - this.furnishVir = furnishVir; - } - - public Integer getDisableDistribute() { - return disableDistribute; - } - - public void setDisableDistribute(Integer disableDistribute) { - this.disableDistribute = disableDistribute; - } - - public String getMerchantId() { - return merchantId; - } - - public void setMerchantId(String merchantId) { - this.merchantId = merchantId; - } - - public String getCategoryId() { - return categoryId; - } - - public void setCategoryId(String categoryId) { - this.categoryId = categoryId; - } -} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbReceiptSales.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbReceiptSales.java deleted file mode 100644 index 9469bda7..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbReceiptSales.java +++ /dev/null @@ -1,120 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.pojo.shop; - -import lombok.Data; -import cn.hutool.core.bean.BeanUtil; -import io.swagger.annotations.ApiModelProperty; -import cn.hutool.core.bean.copier.CopyOptions; -import javax.persistence.*; -import java.io.Serializable; - -/** -* @website https://eladmin.vip -* @description / -* @author lyf -* @date 2024-01-08 -**/ -@Entity -@Data -@Table(name="tb_receipt_sales") -public class TbReceiptSales implements Serializable { - - @Id - @Column(name = "`id`") - @ApiModelProperty(value = "shopId") - private Integer id; - - @Column(name = "`title`") - @ApiModelProperty(value = "标题") - private String title=""; - - @Column(name = "`logo`") - @ApiModelProperty(value = "是否显示公司Logo") - private String logo=""; - - @Column(name = "`show_contact_info`") - @ApiModelProperty(value = "打印联系电话等信息") - private Integer showContactInfo=0; - - @Column(name = "`show_member`") - @ApiModelProperty(value = "打印会员开关 0?1") - private Integer showMember=0; - - @Column(name = "`show_member_code`") - @ApiModelProperty(value = "打印会员编号开关") - private Integer showMemberCode=0; - - @Column(name = "`show_member_score`") - @ApiModelProperty(value = "打印会员积分") - private Integer showMemberScore=0; - - @Column(name = "`show_member_wallet`") - @ApiModelProperty(value = "打印会员余额开关 0?1") - private Integer showMemberWallet=0; - - @Column(name = "`footer_remark`") - @ApiModelProperty(value = "店铺Id") - private String footerRemark=""; - - @Column(name = "`show_cash_charge`") - @ApiModelProperty(value = "打印找零") - private Integer showCashCharge=0; - - @Column(name = "`show_serial_no`") - @ApiModelProperty(value = "流水号") - private Integer showSerialNo=0; - - @Column(name = "`big_serial_no`") - @ApiModelProperty(value = "用大号字打印流水号 在showSerialNo可用前提下") - private Integer bigSerialNo; - - @Column(name = "`header_text`") - @ApiModelProperty(value = "头部文字") - private String headerText; - - @Column(name = "`header_text_align`") - @ApiModelProperty(value = "文字 对齐方式") - private String headerTextAlign; - - @Column(name = "`footer_text`") - @ApiModelProperty(value = "尾部文字") - private String footerText=""; - - @Column(name = "`footer_text_align`") - @ApiModelProperty(value = "文字 对齐方式") - private String footerTextAlign; - - @Column(name = "`footer_image`") - @ApiModelProperty(value = "尾部图像") - private String footerImage=""; - - @Column(name = "`pre_print`") - @ApiModelProperty(value = "预打印,YES开启 NO不开启") - private String prePrint; - - @Column(name = "`created_at`") - @ApiModelProperty(value = "createdAt") - private Long createdAt; - - @Column(name = "`updated_at`") - @ApiModelProperty(value = "updatedAt") - private Long updatedAt; - - public void copy(TbReceiptSales source){ - BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); - } -} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopCashSpread.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopCashSpread.java deleted file mode 100644 index 0dac0c58..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopCashSpread.java +++ /dev/null @@ -1,72 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.pojo.shop; - -import lombok.Data; -import cn.hutool.core.bean.BeanUtil; -import io.swagger.annotations.ApiModelProperty; -import cn.hutool.core.bean.copier.CopyOptions; -import javax.persistence.*; -import java.io.Serializable; - -/** -* @website https://eladmin.vip -* @description / -* @author lyf -* @date 2024-01-05 -**/ -@Entity -@Data -@Table(name="tb_shop_cash_spread") -public class TbShopCashSpread implements Serializable { - - @Id - @Column(name = "`id`") - @ApiModelProperty(value = "shopId") - private Integer id; - - @Column(name = "`sale_receipt`") - @ApiModelProperty(value = "登陆密码") - private String saleReceipt; - - @Column(name = "`triplicate_receipt`") - @ApiModelProperty(value = "状态") - private String triplicateReceipt; - - @Column(name = "`screen_config`") - @ApiModelProperty(value = "到期提醒时间") - private String screenConfig; - - @Column(name = "`tag_config`") - @ApiModelProperty(value = "tagConfig") - private String tagConfig; - - @Column(name = "`scale_config`") - @ApiModelProperty(value = "scaleConfig") - private String scaleConfig; - - @Column(name = "`created_at`") - @ApiModelProperty(value = "createdAt") - private Long createdAt; - - @Column(name = "`updated_at`") - @ApiModelProperty(value = "updatedAt") - private Long updatedAt; - - public void copy(TbShopCashSpread source){ - BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); - } -} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopCurrency.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopCurrency.java deleted file mode 100644 index 35e9a5a1..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopCurrency.java +++ /dev/null @@ -1,130 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.pojo.shop; - -import lombok.Data; -import cn.hutool.core.bean.BeanUtil; -import io.swagger.annotations.ApiModelProperty; -import cn.hutool.core.bean.copier.CopyOptions; -import javax.persistence.*; -import java.math.BigDecimal; -import java.io.Serializable; - -/** -* @website https://eladmin.vip -* @description / -* @author lyf -* @date 2024-01-05 -**/ -@Entity -@Data -@Table(name="tb_shop_currency") -public class TbShopCurrency implements Serializable { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "`id`") - @ApiModelProperty(value = "自增id") - private Integer id; - - @Column(name = "`shop_id`") - @ApiModelProperty(value = "店铺Id") - private String shopId; - - @Column(name = "`prepare_amount`") - @ApiModelProperty(value = "备用金") - private BigDecimal prepareAmount; - - @Column(name = "`currency`") - @ApiModelProperty(value = "货币单位 ¥,$") - private String currency; - - @Column(name = "`decimals_digits`") - @ApiModelProperty(value = "小数位,0,1,2,无,元,角,分") - private Integer decimalsDigits; - - @Column(name = "`discount_round`") - @ApiModelProperty(value = "无,四舍五入,五舍六入none,round4up5,round5up6,round12up34") - private String discountRound; - - @Column(name = "`merchant_id`") - @ApiModelProperty(value = "商户Id") - private String merchantId; - - @Column(name = "`small_change`") - @ApiModelProperty(value = "订单抹零 -1无,0元 1角2分 0.5=0.5元") - private Integer smallChange; - - @Column(name = "`enable_custom_discount`") - @ApiModelProperty(value = "使折扣生效") - private Integer enableCustomDiscount; - - @Column(name = "`max_discount`") - @ApiModelProperty(value = "最大抹零金额(100)") - private BigDecimal maxDiscount; - - @Column(name = "`max_percent`") - @ApiModelProperty(value = "最大折扣百分比,,优先级高于max_discount") - private Double maxPercent; - - @Column(name = "`discount_configs`") - @ApiModelProperty(value = "折扣显示详情") - private String discountConfigs; - - @Column(name = "`biz_duration`") - @ApiModelProperty(value = "营业时间(弃用)") - private String bizDuration; - - @Column(name = "`allow_web_pay`") - @ApiModelProperty(value = "允许网络支付") - private Integer allowWebPay; - - @Column(name = "`is_auto_to_zero`") - @ApiModelProperty(value = "自动抹零,开启时,系统自动抹零") - private Integer isAutoToZero; - - @Column(name = "`is_include_tax_price`") - @ApiModelProperty(value = "商品含税") - private Integer isIncludeTaxPrice; - - @Column(name = "`service_charge`") - @ApiModelProperty(value = "服务费配置(小费)") - private String serviceCharge; - - @Column(name = "`tax_number`") - @ApiModelProperty(value = "税号") - private String taxNumber; - - @Column(name = "`created_at`") - @ApiModelProperty(value = "createdAt") - private Long createdAt; - - @Column(name = "`updated_at`") - @ApiModelProperty(value = "updatedAt") - private Long updatedAt; - - @Column(name = "`auto_lock_screen`") - @ApiModelProperty(value = "自动锁屏") - private Integer autoLockScreen; - - @Column(name = "`voice_notification`") - @ApiModelProperty(value = "语音通知") - private Integer voiceNotification; - - public void copy(TbShopCurrency source){ - BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); - } -} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopInfo.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopInfo.java index 3cb60517..5720d7bd 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopInfo.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopInfo.java @@ -260,6 +260,14 @@ public class TbShopInfo implements Serializable { @ApiModelProperty(value = "是否允许用户自定义金额") private String isMemberReturn; + @Column(name = "is_member_price") + @ApiModelProperty(value = "是否启用会员价 0否1是") + private Integer isMemberPrice; + + @Column(name = "consume_colony") + @ApiModelProperty(value = "积分群体 all-所有 vip-仅针对会员") + private String consumeColony; + @Column(name = "is_table_fee") @ApiModelProperty(value = "是否免除桌位费 0否1是") private Integer isTableFee; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopUser.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopUser.java index 61e60bae..e8bab126 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopUser.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/shop/TbShopUser.java @@ -1,14 +1,18 @@ package cn.ysk.cashier.pojo.shop; -import lombok.Data; import cn.hutool.core.bean.BeanUtil; -import io.swagger.annotations.ApiModelProperty; import cn.hutool.core.bean.copier.CopyOptions; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + import javax.persistence.*; -import javax.validation.constraints.*; -import java.math.BigDecimal; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; import java.io.Serializable; +import java.math.BigDecimal; import java.sql.Timestamp; +import java.util.Date; /** * @website https://eladmin.vip @@ -141,7 +145,22 @@ public class TbShopUser implements Serializable { @Column(name = "`join_time`") private Timestamp joinTime; - + /** + * 账户积分 + */ + @Column(name = "`account_points`") + private Integer accountPoints; + /** + * 最近一次积分变动时间 + */ + @Column(name = "`last_points_change_time`") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date lastPointsChangeTime; + /** + * 最近一次浮动积分 + */ + @Column(name = "`last_float_points`") + private Integer lastFloatPoints; public void copy(TbShopUser source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/quartz/task/TestTask.java b/eladmin-system/src/main/java/cn/ysk/cashier/quartz/task/TestTask.java index f13e5214..d10c3a54 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/quartz/task/TestTask.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/quartz/task/TestTask.java @@ -95,7 +95,7 @@ public class TestTask { log.info("购物车清楚记录开始结束"); } - @Transactional(rollbackFor = Exception.class) +// @Scheduled(fixedRate = 30000) public void cancelOrder(){ log.info("订单取消定时任务执行"); orderInfoService.cancelOrder(); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/BotButtonConfigRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/BotButtonConfigRepository.java deleted file mode 100644 index 6f95aff4..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/BotButtonConfigRepository.java +++ /dev/null @@ -1,28 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.repository; - -import cn.ysk.cashier.pojo.BotButtonConfig; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; - -/** -* @website https://eladmin.vip -* @author admin -* @date 2023-10-31 -**/ -public interface BotButtonConfigRepository extends JpaRepository, JpaSpecificationExecutor { -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/BotConfigRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/BotConfigRepository.java deleted file mode 100644 index ec9eb050..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/BotConfigRepository.java +++ /dev/null @@ -1,28 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.repository; - -import cn.ysk.cashier.pojo.BotConfig; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; - -/** -* @website https://eladmin.vip -* @author admin -* @date 2023-10-31 -**/ -public interface BotConfigRepository extends JpaRepository, JpaSpecificationExecutor { -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/BotUserFlowRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/BotUserFlowRepository.java deleted file mode 100644 index 5e156606..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/BotUserFlowRepository.java +++ /dev/null @@ -1,28 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.repository; - -import cn.ysk.cashier.pojo.BotUserFlow; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; - -/** -* @website https://eladmin.vip -* @author admin -* @date 2023-10-30 -**/ -public interface BotUserFlowRepository extends JpaRepository, JpaSpecificationExecutor { -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/BotUserRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/BotUserRepository.java deleted file mode 100644 index 170dad0f..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/BotUserRepository.java +++ /dev/null @@ -1,28 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.repository; - -import cn.ysk.cashier.pojo.BotUser; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; - -/** -* @website https://eladmin.vip -* @author admin -* @date 2023-10-30 -**/ -public interface BotUserRepository extends JpaRepository, JpaSpecificationExecutor { -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/TbRenewalsPayLogRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/TbRenewalsPayLogRepository.java deleted file mode 100644 index 7f85f4da..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/TbRenewalsPayLogRepository.java +++ /dev/null @@ -1,28 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.repository; - -import cn.ysk.cashier.pojo.TbRenewalsPayLog; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; - -/** -* @website https://eladmin.vip -* @author lyf -* @date 2023-11-07 -**/ -public interface TbRenewalsPayLogRepository extends JpaRepository, JpaSpecificationExecutor { -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/order/TbOrderDetailRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/order/TbOrderDetailRepository.java index 62cd4b5d..41ee7359 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/order/TbOrderDetailRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/order/TbOrderDetailRepository.java @@ -36,7 +36,7 @@ public interface TbOrderDetailRepository extends JpaRepository searchDetailByOrderIds(@Param("ids")List ids); @Query("SELECT new cn.ysk.cashier.vo.TbOrderSalesCountByDayV2Vo(" + - "info.productName,pro.id, cate.name,'', " + + "info.productName,pro.id, cate.name,pro.typeEnum, " + "SUM(CASE WHEN orders.orderType!='return' THEN info.num ELSE 0 END) as salesNum, " + "SUM(CASE WHEN orders.orderType='return' THEN info.num ELSE 0 END), " + "SUM(CASE WHEN orders.orderType!='return' THEN info.priceAmount ELSE 0 END), " + @@ -82,15 +82,16 @@ public interface TbOrderDetailRepository extends JpaRepository :startTime AND info.createTime < :endTime " + "AND (info.status = 'closed' OR info.status = 'refund') " + "GROUP BY info.productId, info.productSkuId " + "ORDER BY salesNum DESC") - List queryTbOrderSalesCountBySku(@Param("shopId") Integer shopId,@Param("proId")Integer proId, @Param("startTime") Date startTime, @Param("endTime") Date endTime); - + List queryTbOrderSalesCountBySku(@Param("shopId") Integer shopId + , @Param("startTime") Date startTime, @Param("endTime") Date endTime); @Query("SELECT new cn.ysk.cashier.vo.TbOrderSalesCountByDayVo(" + "info.productName, info.productSkuName, cate.name, unit.name,info.price," + "SUM(CASE WHEN orders.orderType!='return' THEN info.num ELSE 0 END) as salesNum, " + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductRepository.java index e5d588ae..eb19aa14 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductRepository.java @@ -53,6 +53,10 @@ public interface TbProductRepository extends JpaRepository, @Query(value = "select b.* from tb_product_sku as a left join tb_product as b on a.product_id=b.id where a.id=:skuId", nativeQuery = true) TbProduct selectBySkuId(@Param("skuId") Integer skuId); + @Modifying + @Query("update TbProduct set isGrounding=0 where id=:id") + void upGrounding(@Param("id") Integer id); + @Modifying @Query("update TbProduct set lowPrice=:lowPrice where id=:id") void upLowPrice(@Param("id") Integer id, @Param("lowPrice") BigDecimal lowPrice); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSkuRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSkuRepository.java index d39d2c41..ba6dcd1f 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSkuRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductSkuRepository.java @@ -32,6 +32,9 @@ public interface TbProductSkuRepository extends JpaRepository, JpaSpecificationExecutor { -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbPlussShopStaffRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbPlussShopStaffRepository.java index 00876641..c33366b8 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbPlussShopStaffRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbPlussShopStaffRepository.java @@ -38,4 +38,7 @@ public interface TbPlussShopStaffRepository extends JpaRepository, JpaSpecificationExecutor { -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopCashSpreadRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopCashSpreadRepository.java deleted file mode 100644 index e65fccdb..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopCashSpreadRepository.java +++ /dev/null @@ -1,43 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.repository.shop; - -import cn.ysk.cashier.pojo.shop.TbShopCashSpread; -import org.apache.ibatis.annotations.Param; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; - -import javax.transaction.Transactional; - -/** -* @website https://eladmin.vip -* @author lyf -* @date 2024-01-05 -**/ -public interface TbShopCashSpreadRepository extends JpaRepository, JpaSpecificationExecutor { - @Query("select spread from TbShopCashSpread spread where spread.id = :shopId") - TbShopCashSpread findByShopId(@Param("shopId")Integer shopId); - - @Modifying - @Transactional - @Query("update TbShopCashSpread spread set spread.screenConfig = :screenConfig, spread.updatedAt = :updatedTime where spread.id = :shopId") - Integer updateConfig(@Param("shopId")Integer shopId, @Param("screenConfig")String screenConfig, - @Param("updatedTime")Long updatedTime); - - -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopCurrencyRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopCurrencyRepository.java deleted file mode 100644 index 8da567d0..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopCurrencyRepository.java +++ /dev/null @@ -1,33 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.repository.shop; - -import cn.ysk.cashier.pojo.shop.TbShopCurrency; -import org.apache.ibatis.annotations.Param; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; -import org.springframework.data.jpa.repository.Query; - -/** -* @website https://eladmin.vip -* @author lyf -* @date 2024-01-05 -**/ -public interface TbShopCurrencyRepository extends JpaRepository, JpaSpecificationExecutor { - - @Query("SELECT currency from TbShopCurrency currency where currency.shopId = :shopId") - TbShopCurrency findByShopId(@Param("shopId")String shopId); -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopUserRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopUserRepository.java index 3accd7de..e50ce11e 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopUserRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbShopUserRepository.java @@ -51,4 +51,6 @@ public interface TbShopUserRepository extends JpaRepository @Query(value = "select IFNULL(sum(amount),0) from tb_shop_user_flow where shop_user_id=:userId and biz_code in ('cashMemberIn','scanMemberIn')",nativeQuery = true) BigDecimal sumAmount(Integer userId); + @Query("SELECT user from TbShopUser user where user.shopId = :shopId and user.userId = :userId") + TbShopUser selectByUserIdAndShopId(@Param("userId") String userId,@Param("shopId") String shopId); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/BotButtonConfigService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/BotButtonConfigService.java deleted file mode 100644 index 991da2b8..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/BotButtonConfigService.java +++ /dev/null @@ -1,83 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.service; - -import cn.ysk.cashier.pojo.BotButtonConfig; -import cn.ysk.cashier.dto.BotButtonConfigDto; -import cn.ysk.cashier.dto.BotButtonConfigQueryCriteria; -import org.springframework.data.domain.Pageable; -import java.util.Map; -import java.util.List; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; - -/** -* @website https://eladmin.vip -* @description 服务接口 -* @author admin -* @date 2023-10-31 -**/ -public interface BotButtonConfigService { - - /** - * 查询数据分页 - * @param criteria 条件 - * @param pageable 分页参数 - * @return Map - */ - Map queryAll(BotButtonConfigQueryCriteria criteria, Pageable pageable); - - /** - * 查询所有数据不分页 - * @param criteria 条件参数 - * @return List - */ - List queryAll(BotButtonConfigQueryCriteria criteria); - - /** - * 根据ID查询 - * @param id ID - * @return BotButtonConfigDto - */ - BotButtonConfigDto findById(Integer id); - - /** - * 创建 - * @param resources / - * @return BotButtonConfigDto - */ - BotButtonConfigDto create(BotButtonConfig resources); - - /** - * 编辑 - * @param resources / - */ - void update(BotButtonConfig resources); - - /** - * 多选删除 - * @param ids / - */ - void deleteAll(Integer[] ids); - - /** - * 导出数据 - * @param all 待导出的数据 - * @param response / - * @throws IOException / - */ - void download(List all, HttpServletResponse response) throws IOException; -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/BotConfigService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/BotConfigService.java deleted file mode 100644 index 02c20cf6..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/BotConfigService.java +++ /dev/null @@ -1,68 +0,0 @@ -package cn.ysk.cashier.service; - -import cn.ysk.cashier.pojo.BotConfig; -import cn.ysk.cashier.dto.BotConfigDto; -import cn.ysk.cashier.dto.BotConfigQueryCriteria; -import org.springframework.data.domain.Pageable; -import java.util.Map; -import java.util.List; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; - -/** -* @website https://eladmin.vip -* @description 服务接口 -* @author admin -* @date 2023-10-31 -**/ -public interface BotConfigService { - - /** - * 查询数据分页 - * @param criteria 条件 - * @param pageable 分页参数 - * @return Map - */ - Map queryAll(BotConfigQueryCriteria criteria, Pageable pageable); - - /** - * 查询所有数据不分页 - * @param criteria 条件参数 - * @return List - */ - List queryAll(BotConfigQueryCriteria criteria); - - /** - * 根据ID查询 - * @param id ID - * @return BotConfigDto - */ - BotConfigDto findById(Integer id); - - /** - * 创建 - * @param resources / - * @return BotConfigDto - */ - BotConfigDto create(BotConfig resources); - - /** - * 编辑 - * @param resources / - */ - void update(BotConfig resources); - - /** - * 多选删除 - * @param ids / - */ - void deleteAll(Integer[] ids); - - /** - * 导出数据 - * @param all 待导出的数据 - * @param response / - * @throws IOException / - */ - void download(List all, HttpServletResponse response) throws IOException; -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/BotUserFlowService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/BotUserFlowService.java deleted file mode 100644 index 9d5c70d5..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/BotUserFlowService.java +++ /dev/null @@ -1,83 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.service; - -import cn.ysk.cashier.pojo.BotUserFlow; -import cn.ysk.cashier.dto.BotUserFlowDto; -import cn.ysk.cashier.dto.BotUserFlowQueryCriteria; -import org.springframework.data.domain.Pageable; -import java.util.Map; -import java.util.List; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; - -/** -* @website https://eladmin.vip -* @description 服务接口 -* @author admin -* @date 2023-10-30 -**/ -public interface BotUserFlowService { - - /** - * 查询数据分页 - * @param criteria 条件 - * @param pageable 分页参数 - * @return Map - */ - Map queryAll(BotUserFlowQueryCriteria criteria, Pageable pageable); - - /** - * 查询所有数据不分页 - * @param criteria 条件参数 - * @return List - */ - List queryAll(BotUserFlowQueryCriteria criteria); - - /** - * 根据ID查询 - * @param id ID - * @return BotUserFlowDto - */ - BotUserFlowDto findById(Integer id); - - /** - * 创建 - * @param resources / - * @return BotUserFlowDto - */ - BotUserFlowDto create(BotUserFlow resources); - - /** - * 编辑 - * @param resources / - */ - void update(BotUserFlow resources); - - /** - * 多选删除 - * @param ids / - */ - void deleteAll(Integer[] ids); - - /** - * 导出数据 - * @param all 待导出的数据 - * @param response / - * @throws IOException / - */ - void download(List all, HttpServletResponse response) throws IOException; -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/BotUserService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/BotUserService.java deleted file mode 100644 index af565bad..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/BotUserService.java +++ /dev/null @@ -1,83 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.service; - -import cn.ysk.cashier.pojo.BotUser; -import cn.ysk.cashier.dto.BotUserDto; -import cn.ysk.cashier.dto.BotUserQueryCriteria; -import org.springframework.data.domain.Pageable; -import java.util.Map; -import java.util.List; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; - -/** -* @website https://eladmin.vip -* @description 服务接口 -* @author admin -* @date 2023-10-30 -**/ -public interface BotUserService { - - /** - * 查询数据分页 - * @param criteria 条件 - * @param pageable 分页参数 - * @return Map - */ - Map queryAll(BotUserQueryCriteria criteria, Pageable pageable); - - /** - * 查询所有数据不分页 - * @param criteria 条件参数 - * @return List - */ - List queryAll(BotUserQueryCriteria criteria); - - /** - * 根据ID查询 - * @param id ID - * @return BotUserDto - */ - BotUserDto findById(Integer id); - - /** - * 创建 - * @param resources / - * @return BotUserDto - */ - BotUserDto create(BotUser resources); - - /** - * 编辑 - * @param resources / - */ - void update(BotUser resources); - - /** - * 多选删除 - * @param ids / - */ - void deleteAll(Integer[] ids); - - /** - * 导出数据 - * @param all 待导出的数据 - * @param response / - * @throws IOException / - */ - void download(List all, HttpServletResponse response) throws IOException; -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/TbPayService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/TbPayService.java index c73da59f..6fc11b4f 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/TbPayService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/TbPayService.java @@ -3,6 +3,7 @@ package cn.ysk.cashier.service; import cn.ysk.cashier.dto.ScanPayDTO; import cn.ysk.cashier.dto.shoptable.PayDTO; import cn.ysk.cashier.pojo.order.TbOrderInfo; +import cn.ysk.cashier.pojo.shop.TbShopUser; import javax.validation.constraints.Max; import javax.validation.constraints.Min; @@ -12,7 +13,7 @@ import java.math.BigDecimal; public interface TbPayService { TbOrderInfo scanPay(Integer shopId, String code, Integer merchantId, Integer memberId, BigDecimal payMount, TbOrderInfo orderInfo); - void vipPay(BigDecimal payMount, Integer vipUserId); + TbShopUser vipPay(BigDecimal payMount, Integer vipUserId); TbOrderInfo cashPay(PayDTO payDTO); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/TbRenewalsPayLogService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/TbRenewalsPayLogService.java deleted file mode 100644 index 68ed47f6..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/TbRenewalsPayLogService.java +++ /dev/null @@ -1,83 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.service; - -import cn.ysk.cashier.pojo.TbRenewalsPayLog; -import cn.ysk.cashier.dto.TbRenewalsPayLogDto; -import cn.ysk.cashier.dto.TbRenewalsPayLogQueryCriteria; -import org.springframework.data.domain.Pageable; -import java.util.Map; -import java.util.List; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; - -/** -* @website https://eladmin.vip -* @description 服务接口 -* @author lyf -* @date 2023-11-07 -**/ -public interface TbRenewalsPayLogService { - - /** - * 查询数据分页 - * @param criteria 条件 - * @param pageable 分页参数 - * @return Map - */ - Map queryAll(TbRenewalsPayLogQueryCriteria criteria, Pageable pageable); - - /** - * 查询所有数据不分页 - * @param criteria 条件参数 - * @return List - */ - List queryAll(TbRenewalsPayLogQueryCriteria criteria); - - /** - * 根据ID查询 - * @param id ID - * @return TbRenewalsPayLogDto - */ - TbRenewalsPayLogDto findById(Integer id); - - /** - * 创建 - * @param resources / - * @return TbRenewalsPayLogDto - */ - TbRenewalsPayLogDto create(TbRenewalsPayLog resources); - - /** - * 编辑 - * @param resources / - */ - void update(TbRenewalsPayLog resources); - - /** - * 多选删除 - * @param ids / - */ - void deleteAll(Integer[] ids); - - /** - * 导出数据 - * @param all 待导出的数据 - * @param response / - * @throws IOException / - */ - void download(List all, HttpServletResponse response) throws IOException; -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/BotButtonConfigServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/BotButtonConfigServiceImpl.java deleted file mode 100644 index 26fbb9ed..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/BotButtonConfigServiceImpl.java +++ /dev/null @@ -1,105 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.service.impl; - -import cn.ysk.cashier.pojo.BotButtonConfig; -import cn.ysk.cashier.utils.ValidationUtil; -import cn.ysk.cashier.utils.FileUtil; -import lombok.RequiredArgsConstructor; -import cn.ysk.cashier.repository.BotButtonConfigRepository; -import cn.ysk.cashier.service.BotButtonConfigService; -import cn.ysk.cashier.dto.BotButtonConfigDto; -import cn.ysk.cashier.dto.BotButtonConfigQueryCriteria; -import cn.ysk.cashier.mapper.BotButtonConfigMapper; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import cn.ysk.cashier.utils.PageUtil; -import cn.ysk.cashier.utils.QueryHelp; -import java.util.List; -import java.util.Map; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; -import java.util.LinkedHashMap; - -/** -* @website https://eladmin.vip -* @description 服务实现 -* @author admin -* @date 2023-10-31 -**/ -@Service -@RequiredArgsConstructor -public class BotButtonConfigServiceImpl implements BotButtonConfigService { - - private final BotButtonConfigRepository botButtonConfigRepository; - private final BotButtonConfigMapper botButtonConfigMapper; - - @Override - public Map queryAll(BotButtonConfigQueryCriteria criteria, Pageable pageable){ - Page page = botButtonConfigRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); - return PageUtil.toPage(page.map(botButtonConfigMapper::toDto)); - } - - @Override - public List queryAll(BotButtonConfigQueryCriteria criteria){ - return botButtonConfigMapper.toDto(botButtonConfigRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); - } - - @Override - @Transactional - public BotButtonConfigDto findById(Integer id) { - BotButtonConfig botButtonConfig = botButtonConfigRepository.findById(id).orElseGet(BotButtonConfig::new); - ValidationUtil.isNull(botButtonConfig.getId(),"BotButtonConfig","id",id); - return botButtonConfigMapper.toDto(botButtonConfig); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public BotButtonConfigDto create(BotButtonConfig resources) { - return botButtonConfigMapper.toDto(botButtonConfigRepository.save(resources)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void update(BotButtonConfig resources) { - BotButtonConfig botButtonConfig = botButtonConfigRepository.findById(resources.getId()).orElseGet(BotButtonConfig::new); - ValidationUtil.isNull( botButtonConfig.getId(),"BotButtonConfig","id",resources.getId()); - botButtonConfig.copy(resources); - botButtonConfigRepository.save(botButtonConfig); - } - - @Override - public void deleteAll(Integer[] ids) { - for (Integer id : ids) { - botButtonConfigRepository.deleteById(id); - } - } - - @Override - public void download(List all, HttpServletResponse response) throws IOException { - List> list = new ArrayList<>(); - for (BotButtonConfigDto botButtonConfig : all) { - Map map = new LinkedHashMap<>(); - map.put("按钮名称", botButtonConfig.getButtonName()); - map.put("按钮值", botButtonConfig.getButtonValue()); - list.add(map); - } - FileUtil.downloadExcel(list, response); - } -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/BotConfigServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/BotConfigServiceImpl.java deleted file mode 100644 index cbae7949..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/BotConfigServiceImpl.java +++ /dev/null @@ -1,106 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.service.impl; - -import cn.ysk.cashier.pojo.BotConfig; -import cn.ysk.cashier.utils.ValidationUtil; -import cn.ysk.cashier.utils.FileUtil; -import lombok.RequiredArgsConstructor; -import cn.ysk.cashier.repository.BotConfigRepository; -import cn.ysk.cashier.service.BotConfigService; -import cn.ysk.cashier.dto.BotConfigDto; -import cn.ysk.cashier.dto.BotConfigQueryCriteria; -import cn.ysk.cashier.mapper.BotConfigMapper; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import cn.ysk.cashier.utils.PageUtil; -import cn.ysk.cashier.utils.QueryHelp; -import java.util.List; -import java.util.Map; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; -import java.util.LinkedHashMap; - -/** -* @website https://eladmin.vip -* @description 服务实现 -* @author admin -* @date 2023-10-31 -**/ -@Service -@RequiredArgsConstructor -public class BotConfigServiceImpl implements BotConfigService { - - private final BotConfigRepository botConfigRepository; - private final BotConfigMapper botConfigMapper; - - @Override - public Map queryAll(BotConfigQueryCriteria criteria, Pageable pageable){ - Page page = botConfigRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); - return PageUtil.toPage(page.map(botConfigMapper::toDto)); - } - - @Override - public List queryAll(BotConfigQueryCriteria criteria){ - return botConfigMapper.toDto(botConfigRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); - } - - @Override - @Transactional - public BotConfigDto findById(Integer id) { - BotConfig botConfig = botConfigRepository.findById(id).orElseGet(BotConfig::new); - ValidationUtil.isNull(botConfig.getId(),"BotConfig","id",id); - return botConfigMapper.toDto(botConfig); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public BotConfigDto create(BotConfig resources) { - return botConfigMapper.toDto(botConfigRepository.save(resources)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void update(BotConfig resources) { - BotConfig botConfig = botConfigRepository.findById(resources.getId()).orElseGet(BotConfig::new); - ValidationUtil.isNull( botConfig.getId(),"BotConfig","id",resources.getId()); - botConfig.copy(resources); - botConfigRepository.save(botConfig); - } - - @Override - public void deleteAll(Integer[] ids) { - for (Integer id : ids) { - botConfigRepository.deleteById(id); - } - } - - @Override - public void download(List all, HttpServletResponse response) throws IOException { - List> list = new ArrayList<>(); - for (BotConfigDto botConfig : all) { - Map map = new LinkedHashMap<>(); - map.put("元素键值", botConfig.getConfigKey()); - map.put("元素值", botConfig.getConfigValue()); - map.put("描述", botConfig.getRemark()); - list.add(map); - } - FileUtil.downloadExcel(list, response); - } -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/BotUserFlowServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/BotUserFlowServiceImpl.java deleted file mode 100644 index e59a548d..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/BotUserFlowServiceImpl.java +++ /dev/null @@ -1,110 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.service.impl; - -import cn.ysk.cashier.pojo.BotUserFlow; -import cn.ysk.cashier.repository.BotUserFlowRepository; -import cn.ysk.cashier.service.BotUserFlowService; -import cn.ysk.cashier.dto.BotUserFlowDto; -import cn.ysk.cashier.dto.BotUserFlowQueryCriteria; -import cn.ysk.cashier.utils.ValidationUtil; -import cn.ysk.cashier.utils.FileUtil; -import lombok.RequiredArgsConstructor; -import cn.ysk.cashier.mapper.BotUserFlowMapper; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import cn.ysk.cashier.utils.PageUtil; -import cn.ysk.cashier.utils.QueryHelp; -import java.util.List; -import java.util.Map; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; -import java.util.LinkedHashMap; - -/** -* @website https://eladmin.vip -* @description 服务实现 -* @author admin -* @date 2023-10-30 -**/ -@Service -@RequiredArgsConstructor -public class BotUserFlowServiceImpl implements BotUserFlowService { - - private final BotUserFlowRepository botUserFlowRepository; - private final BotUserFlowMapper botUserFlowMapper; - - @Override - public Map queryAll(BotUserFlowQueryCriteria criteria, Pageable pageable){ - Page page = botUserFlowRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); - return PageUtil.toPage(page.map(botUserFlowMapper::toDto)); - } - - @Override - public List queryAll(BotUserFlowQueryCriteria criteria){ - return botUserFlowMapper.toDto(botUserFlowRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); - } - - @Override - @Transactional - public BotUserFlowDto findById(Integer id) { - BotUserFlow botUserFlow = botUserFlowRepository.findById(id).orElseGet(BotUserFlow::new); - ValidationUtil.isNull(botUserFlow.getId(),"BotUserFlow","id",id); - return botUserFlowMapper.toDto(botUserFlow); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public BotUserFlowDto create(BotUserFlow resources) { - return botUserFlowMapper.toDto(botUserFlowRepository.save(resources)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void update(BotUserFlow resources) { - BotUserFlow botUserFlow = botUserFlowRepository.findById(resources.getId()).orElseGet(BotUserFlow::new); - ValidationUtil.isNull( botUserFlow.getId(),"BotUserFlow","id",resources.getId()); - botUserFlow.copy(resources); - botUserFlowRepository.save(botUserFlow); - } - - @Override - public void deleteAll(Integer[] ids) { - for (Integer id : ids) { - botUserFlowRepository.deleteById(id); - } - } - - @Override - public void download(List all, HttpServletResponse response) throws IOException { - List> list = new ArrayList<>(); - for (BotUserFlowDto botUserFlow : all) { - Map map = new LinkedHashMap<>(); - map.put("电报号", botUserFlow.getUserTelegramId()); - map.put("用户名称", botUserFlow.getUserName()); - map.put("业务代码", botUserFlow.getBizCode()); - map.put("变动金额", botUserFlow.getAmount()); - map.put("变动前金额", botUserFlow.getOldBalance()); - map.put("变动后金额", botUserFlow.getNewBalance()); - map.put("创建时间", botUserFlow.getCreateTime()); - list.add(map); - } - FileUtil.downloadExcel(list, response); - } -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/BotUserServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/BotUserServiceImpl.java deleted file mode 100644 index b442eb48..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/BotUserServiceImpl.java +++ /dev/null @@ -1,122 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.service.impl; - -import cn.ysk.cashier.pojo.BotUser; -import cn.ysk.cashier.utils.ValidationUtil; -import cn.ysk.cashier.utils.FileUtil; -import lombok.RequiredArgsConstructor; -import cn.ysk.cashier.repository.BotUserRepository; -import cn.ysk.cashier.service.BotUserService; -import cn.ysk.cashier.dto.BotUserDto; -import cn.ysk.cashier.dto.BotUserQueryCriteria; -import cn.ysk.cashier.mapper.BotUserMapper; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import cn.ysk.cashier.utils.PageUtil; -import cn.ysk.cashier.utils.QueryHelp; -import java.util.List; -import java.util.Map; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; -import java.util.LinkedHashMap; - -/** -* @website https://eladmin.vip -* @description 服务实现 -* @author admin -* @date 2023-10-30 -**/ -@Service -@RequiredArgsConstructor -public class BotUserServiceImpl implements BotUserService { - - private final BotUserRepository botUserRepository; - private final BotUserMapper botUserMapper; - - @Override - public Map queryAll(BotUserQueryCriteria criteria, Pageable pageable){ - Page page = botUserRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); - return PageUtil.toPage(page.map(botUserMapper::toDto)); - } - - @Override - public List queryAll(BotUserQueryCriteria criteria){ - return botUserMapper.toDto(botUserRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); - } - - @Override - @Transactional - public BotUserDto findById(Integer id) { - BotUser botUser = botUserRepository.findById(id).orElseGet(BotUser::new); - ValidationUtil.isNull(botUser.getId(),"BotUser","id",id); - return botUserMapper.toDto(botUser); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public BotUserDto create(BotUser resources) { - return botUserMapper.toDto(botUserRepository.save(resources)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void update(BotUser resources) { - BotUser botUser = botUserRepository.findById(resources.getId()).orElseGet(BotUser::new); - ValidationUtil.isNull( botUser.getId(),"BotUser","id",resources.getId()); - botUser.copy(resources); - botUserRepository.save(botUser); - } - - @Override - public void deleteAll(Integer[] ids) { - for (Integer id : ids) { - botUserRepository.deleteById(id); - } - } - - @Override - public void download(List all, HttpServletResponse response) throws IOException { - List> list = new ArrayList<>(); - for (BotUserDto botUser : all) { - Map map = new LinkedHashMap<>(); - map.put(" fatherId", botUser.getFatherId()); - map.put("父级电报号", botUser.getFatherTelegramId()); - map.put("电报号", botUser.getUserTelegramId()); - map.put("用户名称", botUser.getUserName()); - map.put("组电报号", botUser.getGroupTelegramId()); - map.put("用户代码", botUser.getUserCode()); - map.put(" userPayPass", botUser.getUserPayPass()); - map.put(" bombStatus", botUser.getBombStatus()); - map.put("用户状态", botUser.getBotStatus()); - map.put("总充值", botUser.getUsdtRechargeTotal()); - map.put("总提现", botUser.getUsdtWithdrawTotal()); - map.put("总资金", botUser.getBalance()); - map.put("冻结资金", botUser.getFreezeBalance()); - map.put("版本号", botUser.getVersion()); - map.put("创建时间", botUser.getCreateTime()); - map.put("更新时间", botUser.getUpdateTime()); - map.put("语言", botUser.getUserLanguage()); - map.put("质押资金", botUser.getChipBalance()); - map.put("绑定时间", botUser.getFatherBindTime()); - list.add(map); - } - FileUtil.downloadExcel(list, response); - } -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/SummaryServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/SummaryServiceImpl.java index 8445a2cf..2868aee6 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/SummaryServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/SummaryServiceImpl.java @@ -24,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; +import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -37,6 +38,7 @@ import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.CompletableFuture; import java.util.function.Function; import java.util.stream.Collectors; @@ -334,12 +336,45 @@ public class SummaryServiceImpl implements SummaryService { summaryDto.setStartTime(DateUtil.toDate(DateUtil.fromTimeStamp(1704038400L))); summaryDto.setEndTime(new Date()); } - Page products = detailRepository.queryTbOrderSalesCountByProduct(Integer.valueOf(summaryDto.getShopId()), summaryDto.getCateId(), summaryDto.getProName(), summaryDto.getStartTime(), summaryDto.getEndTime(), pageable); - for (TbOrderSalesCountByDayV2Vo product : products) { - List skus = detailRepository.queryTbOrderSalesCountBySku(Integer.valueOf(summaryDto.getShopId()), product.getProductId(), summaryDto.getStartTime(), summaryDto.getEndTime()); - product.setSkus(skus); + + // 使用 CompletableFuture 并行执行两个数据库查询 + CompletableFuture> productsFuture = CompletableFuture.supplyAsync(() -> { + try { + return detailRepository.queryTbOrderSalesCountByProduct(Integer.valueOf(summaryDto.getShopId()), summaryDto.getCateId(), summaryDto.getProName(), summaryDto.getStartTime(), summaryDto.getEndTime(), pageable); + } catch (Exception e) { + log.error("查询 products 时发生错误", e); + return null; + } + }); + CompletableFuture> skusFuture = CompletableFuture.supplyAsync(() -> { + try { + return detailRepository.queryTbOrderSalesCountBySku(Integer.valueOf(summaryDto.getShopId()), summaryDto.getStartTime(), summaryDto.getEndTime()); + } catch (Exception e) { + log.error("查询 skus 时发生错误", e); + return null; + } + }); + try { + // 等待两个查询都完成后执行后续逻辑 + return CompletableFuture.allOf(productsFuture, skusFuture).thenApply(v -> { + Page products = productsFuture.join(); + List skus = skusFuture.join(); + if (products!= null && skus!= null) { + Map> collect = skus.stream().collect(Collectors.groupingBy(TbOrderSalesCountByDayV2Vo::getProductId)); + for (TbOrderSalesCountByDayV2Vo product : products) { + if ("sku".equals(product.getTypeEnum())) { + product.setSkus(collect.get(product.getProductId())); + } + } + return (Page) products; + } else { + return null; + } + }).join(); + } catch (Exception e) { + log.error("处理查询结果时发生错误", e); + return null; } - return (Page) products; } @Override @@ -354,10 +389,12 @@ public class SummaryServiceImpl implements SummaryService { } List products = detailRepository.queryTbOrderSalesCountByProduct(Integer.valueOf(summaryDto.getShopId()), summaryDto.getCateId(), summaryDto.getProName(), summaryDto.getStartTime(), summaryDto.getEndTime()); + List proSkus = detailRepository.queryTbOrderSalesCountBySku(Integer.valueOf(summaryDto.getShopId()), + summaryDto.getStartTime(), summaryDto.getEndTime()); + Map> collect = proSkus.stream().collect(Collectors.groupingBy(TbOrderSalesCountByDayV2Vo::getProductId)); for (TbOrderSalesCountByDayV2Vo product : products) { - if ("sku".equals(product.getTypeEnum())) { - List skus = detailRepository.queryTbOrderSalesCountBySku(Integer.valueOf(summaryDto.getShopId()), product.getProductId(), summaryDto.getStartTime(), summaryDto.getEndTime()); - product.setSkus(skus); + if("sku".equals(product.getTypeEnum())){ + product.setSkus(collect.get(product.getProductId())); } } for (TbOrderSalesCountByDayV2Vo product : products) { @@ -601,7 +638,6 @@ public class SummaryServiceImpl implements SummaryService { dataList.put(tableCode, dayMap); } - List keyList = new ArrayList<>(); keyList.add("台桌"); keyList.add("日期"); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/TbPayServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/TbPayServiceImpl.java index c4b55781..807ca6d3 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/TbPayServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/TbPayServiceImpl.java @@ -1,6 +1,7 @@ package cn.ysk.cashier.service.impl; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.ysk.cashier.dto.ScanPayDTO; @@ -139,6 +140,10 @@ public class TbPayServiceImpl implements TbPayService { String qpay; String payTypeCode = code.substring(0, 2);// 判断收款码 + if (!NumberUtil.isNumber(payTypeCode)) { + throw new BadRequestException("错误码"); + } + if(Integer.parseInt(payTypeCode) >=25 && Integer.parseInt(payTypeCode) <= 30){ payType = "aliPay"; payName = "支付宝支付"; @@ -306,7 +311,7 @@ public class TbPayServiceImpl implements TbPayService { } @Override - public void vipPay(BigDecimal payMount, Integer vipUserId) { + public TbShopUser vipPay(BigDecimal payMount, Integer vipUserId) { // 扣减会员余额 TbShopUser shopUser = shopUserMapper.selectOne(new LambdaUpdateWrapper() @@ -317,7 +322,7 @@ public class TbPayServiceImpl implements TbPayService { throw new BadRequestException("用户不存在或已被禁用"); } - long flag = shopUserMapper.decrBalance(vipUserId, payMount); + long flag = shopUserMapper.decrBalance(shopUser.getId(), payMount); if (flag < 1) { throw new BadRequestException("余额不足或扣除余额失败"); } @@ -332,6 +337,8 @@ public class TbPayServiceImpl implements TbPayService { userFlow.setType("-"); shopUserFlowMapper.insert(userFlow); + return shopUser; + } @@ -415,6 +422,10 @@ public class TbPayServiceImpl implements TbPayService { throw new BadRequestException("用户不存在"); } + if (user.getAmount().compareTo(BigDecimal.ZERO) <= 0) { + throw new BadRequestException("余额不足"); + } + shopUserMapper.update(null, new LambdaUpdateWrapper() .eq(TbShopUser::getId, user.getId()) .apply(StrUtil.format("amount-{}>=0", payMount.doubleValue())) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/TbRenewalsPayLogServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/TbRenewalsPayLogServiceImpl.java deleted file mode 100644 index 7ecdd84f..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/TbRenewalsPayLogServiceImpl.java +++ /dev/null @@ -1,116 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.service.impl; - -import cn.ysk.cashier.pojo.TbRenewalsPayLog; -import cn.ysk.cashier.utils.ValidationUtil; -import cn.ysk.cashier.utils.FileUtil; -import lombok.RequiredArgsConstructor; -import cn.ysk.cashier.repository.TbRenewalsPayLogRepository; -import cn.ysk.cashier.service.TbRenewalsPayLogService; -import cn.ysk.cashier.dto.TbRenewalsPayLogDto; -import cn.ysk.cashier.dto.TbRenewalsPayLogQueryCriteria; -import cn.ysk.cashier.mapper.TbRenewalsPayLogMapper; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import cn.ysk.cashier.utils.PageUtil; -import cn.ysk.cashier.utils.QueryHelp; -import java.util.List; -import java.util.Map; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; -import java.util.LinkedHashMap; - -/** -* @website https://eladmin.vip -* @description 服务实现 -* @author lyf -* @date 2023-11-07 -**/ -@Service -@RequiredArgsConstructor -public class TbRenewalsPayLogServiceImpl implements TbRenewalsPayLogService { - - private final TbRenewalsPayLogRepository tbRenewalsPayLogRepository; - private final TbRenewalsPayLogMapper tbRenewalsPayLogMapper; - - @Override - public Map queryAll(TbRenewalsPayLogQueryCriteria criteria, Pageable pageable){ - Page page = tbRenewalsPayLogRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); - return PageUtil.toPage(page.map(tbRenewalsPayLogMapper::toDto)); - } - - @Override - public List queryAll(TbRenewalsPayLogQueryCriteria criteria){ - return tbRenewalsPayLogMapper.toDto(tbRenewalsPayLogRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); - } - - @Override - @Transactional - public TbRenewalsPayLogDto findById(Integer id) { - TbRenewalsPayLog tbRenewalsPayLog = tbRenewalsPayLogRepository.findById(id).orElseGet(TbRenewalsPayLog::new); - ValidationUtil.isNull(tbRenewalsPayLog.getId(),"TbRenewalsPayLog","id",id); - return tbRenewalsPayLogMapper.toDto(tbRenewalsPayLog); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public TbRenewalsPayLogDto create(TbRenewalsPayLog resources) { - return tbRenewalsPayLogMapper.toDto(tbRenewalsPayLogRepository.save(resources)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void update(TbRenewalsPayLog resources) { - TbRenewalsPayLog tbRenewalsPayLog = tbRenewalsPayLogRepository.findById(resources.getId()).orElseGet(TbRenewalsPayLog::new); - ValidationUtil.isNull( tbRenewalsPayLog.getId(),"TbRenewalsPayLog","id",resources.getId()); - tbRenewalsPayLog.copy(resources); - tbRenewalsPayLogRepository.save(tbRenewalsPayLog); - } - - @Override - public void deleteAll(Integer[] ids) { - for (Integer id : ids) { - tbRenewalsPayLogRepository.deleteById(id); - } - } - - @Override - public void download(List all, HttpServletResponse response) throws IOException { - List> list = new ArrayList<>(); - for (TbRenewalsPayLogDto tbRenewalsPayLog : all) { - Map map = new LinkedHashMap<>(); - map.put("支付方式", tbRenewalsPayLog.getPayType()); - map.put("店铺Id", tbRenewalsPayLog.getShopId()); - map.put("订单Id", tbRenewalsPayLog.getOrderId()); - map.put(" openId", tbRenewalsPayLog.getOpenId()); - map.put("用户Id", tbRenewalsPayLog.getUserId()); - map.put("交易单号(第三方交易单号)", tbRenewalsPayLog.getTransactionId()); - map.put("金额", tbRenewalsPayLog.getAmount()); - map.put("状态 ", tbRenewalsPayLog.getStatus()); - map.put("备注", tbRenewalsPayLog.getRemark()); - map.put("用户自定义参数", tbRenewalsPayLog.getAttach()); - map.put("到期时间", tbRenewalsPayLog.getExpiredAt()); - map.put("创建时间", tbRenewalsPayLog.getCreatedAt()); - map.put(" updatedAt", tbRenewalsPayLog.getUpdatedAt()); - list.add(map); - } - FileUtil.downloadExcel(list, response); - } -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java index 215e2cbf..7f016b97 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java @@ -6,6 +6,7 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.ysk.cashier.cons.TableConstant; import cn.ysk.cashier.cons.rabbit.RabbitConstants; +import cn.ysk.cashier.dto.order.OrderCouponInfoDTO; import cn.ysk.cashier.dto.order.TbOrderInfoDto; import cn.ysk.cashier.dto.order.TbOrderInfoQueryCriteria; import cn.ysk.cashier.dto.order.TbPayCountQueryCriteria; @@ -85,9 +86,6 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService { private final TbOrderDetailRepository tbOrderDetailRepository; private final TbShopPayTypeRepository payTypeRepository; - private final TbProductSkuRepository skuRepository; - private final TbProductMapper productMapper; - private final TbProductSkuMapper productSkuMapper; private final TbProductService productService; private final TbOrderPaymentService paymentService; private final TbMerchantThirdApplyRepository thirdApplyRepository; @@ -100,13 +98,14 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService { private final TbMShopUserMapper tbMShopUserMapper; private final TbShopUserFlowMapper tbShopUserFlowMapper; private final RabbitMsgUtils rabbitMsgUtils; - private final TbCashierCartMapper tbCashierCartMapper; private final PayService payService; - private final MpOrderDetailService mpOrderDetailService; private final TbOrderDetailMapper tbOrderDetailMapper; private final MpCashierCartService mpCashierCartService; private final MpShopInfoMapper mpShopInfoMapper; + private final TbMemberPointsService memberPointsService; + private final TbShopCouponService shopCouponService; + private final MpOrderDetailService mpOrderDetailService; @Value("${thirdPay.url}") private String url; @@ -172,7 +171,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService { shopInfoMap.put(item.getId().toString(), item); }); } - List orderInfoVoList = new ArrayList<>(); + List orderInfoVoList = new ArrayList<>(); for (TbOrderInfo tbOrderInfo : page.getContent()) { TbOrderInfoVo orderInfoVo = new TbOrderInfoVo(); BigDecimal refundAmount = BigDecimal.ZERO; @@ -205,20 +204,22 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService { for (TbFullOrderDetail detail : details) { if (TableConstant.CART_SEAT_ID.equals(detail.getProductId().toString())) { seatInfo = detail; - }else { + } else { detailList.add(detail); } } orderInfoVo.setTableName(tbOrderInfo.getTableName()); orderInfoVo.setDetailList(detailList); orderInfoVo.setSeatInfo(seatInfo); - BeanUtils.copyProperties(tbOrderInfo, orderInfoVo); orderInfoVo.setRefundAmount(refundAmount); TbShopInfo shopInfo = shopInfoMap.get(tbOrderInfo.getShopId()); if (shopInfo != null) { orderInfoVo.setRegisterType(shopInfo.getRegisterType()); } - orderInfoVoList.add(orderInfoVo); + Map map = BeanUtil.beanToMap(tbOrderInfo, false, false); + Map objectMap = BeanUtil.beanToMap(orderInfoVo, false, false); + objectMap.putAll(map); + orderInfoVoList.add(objectMap); } return PageUtil.toPage(orderInfoVoList, page.getTotalElements()); } @@ -325,19 +326,12 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService { // dto.setRefundAmount(tbOrderInfos.stream().map(TbOrderInfo::getOrderAmount).reduce(BigDecimal.ZERO, BigDecimal::add)); // } dto.setDetailList(details); - List tbCashierCarts = tbCashierCartMapper.selectList(new LambdaQueryWrapper() - .eq(TbCashierCart::getOrderId, id) - .eq(TbCashierCart::getUseType, tbOrderInfo.getUseType()) - .eq(TbCashierCart::getProductId, TableConstant.CART_SEAT_ID) - .orderByDesc(TbCashierCart::getId)); - TbCashierCart cashierCart = tbCashierCarts.isEmpty() ? null : tbCashierCarts.get(0); - Map map = BeanUtil.beanToMap(cashierCart, false, false); - if (cashierCart != null) { - map.put("cartId", cashierCart.getId()); - TbOrderDetail orderDetail = details.stream().filter(item -> item.getCartId().equals(cashierCart.getId())).findFirst().orElse(null); - map.put("id", orderDetail != null ? orderDetail.getId() : null); - } - dto.setSeatInfo(map); + List tbCashierCarts = tbOrderDetailMapper.selectList(new LambdaQueryWrapper() + .eq(TbOrderDetail::getOrderId, id) + .eq(TbOrderDetail::getProductId, TableConstant.CART_SEAT_ID) + .orderByDesc(TbOrderDetail::getId)); + TbOrderDetail cashierDetail = tbCashierCarts.isEmpty() ? null : tbCashierCarts.get(0); + dto.setSeatInfo(cashierDetail); Map data = BeanUtil.beanToMap(tbOrderInfo, false, false); data.putAll(BeanUtil.beanToMap(dto, false, false)); data.put("refundAmount", tbOrderInfo.getRefundAmount()); @@ -456,6 +450,26 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService { keys.add(CacheKey.PRODUCT_SKU + detail.getShopId() + ":" + detail.getId()); } + // 查询是否消耗了积分优惠券返还对应的卷或商品 + if (tbOrderInfo.getCouponInfoList() != null) { + OrderCouponInfoDTO couponInfoDTO = JSONObject.parseObject(tbOrderInfo.getCouponInfoList(), OrderCouponInfoDTO.class); + // 券返还 + if (!couponInfoDTO.getOutRecordList().isEmpty()) { + couponInfoDTO.getOutRecordList().forEach(item -> { + item.setRefNum(item.getUseNum()); + }); + shopCouponService.refund(couponInfoDTO.getOutRecordList()); + couponInfoDTO.setOutRecordList(new ArrayList<>()); + tbOrderInfo.setCouponInfoList(null); + } + } + + // 返还积分 + if (tbOrderInfo.getPointsNum() != null && tbOrderInfo.getPointsNum() != 0 && tbOrderInfo.getMemberId() != null) { + memberPointsService.addPoints(Long.valueOf(tbOrderInfo.getMemberId()), tbOrderInfo.getPointsNum(), + "订单取消返还: " + tbOrderInfo.getPointsNum() + "积分", Long.valueOf(tbOrderInfo.getId())); + } + mpCashierCartService.updateStateByOrderId(TableConstant.OrderInfo.Status.CLOSED, tbOrderInfo.getId()); String[] keysArray = keys.toArray(new String[keys.size()]); redisUtils.del(keysArray); @@ -606,7 +620,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService { if (user == null) { throw new BadRequestException("用户信息不存在"); } - tbMShopUserMapper.incrBalance(userId, shopId, returnAmount, cn.hutool.core.date.DateUtil.current()); + tbMShopUserMapper.incrBalance(user.getId(), shopId, returnAmount, cn.hutool.core.date.DateUtil.current()); TbShopUserFlow flow = new TbShopUserFlow(); flow.setShopUserId(user.getId()); @@ -658,9 +672,16 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService { log.warn("订单信息不存在: {}", payOrderId); return; } - orderInfo.setStatus("refund"); - orderInfo.setPaidTime(cn.hutool.core.date.DateUtil.current()); - orderInfoMapper.updateById(orderInfo); + TbOrderInfo returnOrder = orderInfoMapper.selectOne(new LambdaQueryWrapper() + .eq(TbOrderInfo::getStatus, "refunding") + .eq(TbOrderInfo::getSource, orderInfo.getId())); + if (returnOrder == null) { + log.warn("订单信息不存在: {}", payOrderId); + return; + } + returnOrder.setStatus("refund"); + returnOrder.setPaidTime(cn.hutool.core.date.DateUtil.current()); + orderInfoMapper.updateById(returnOrder); } } @@ -668,12 +689,48 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService { public void cancelOrder() { List tbOrderInfos = orderInfoMapper.selectList(new LambdaQueryWrapper() .eq(TbOrderInfo::getStatus, "unpaid") - .lt(TbOrderInfo::getCreatedAt, cn.hutool.core.date.DateUtil.current() - 15 * 60 * 1000)); + .and(q -> q.and(qu -> qu.eq(TbOrderInfo::getUseType, TableConstant.OrderInfo.UseType.DINE_IN_AFTER.getValue()).lt(TbOrderInfo::getCreatedAt, cn.hutool.core.date.DateUtil.current() - 12 * 60 * 60 * 1000)) + .or(qu -> qu.ne(TbOrderInfo::getUseType, TableConstant.OrderInfo.UseType.DINE_IN_AFTER.getValue()) + .lt(TbOrderInfo::getCreatedAt, cn.hutool.core.date.DateUtil.current() - 15 * 60 * 1000)))); log.info("超时订单: {}", tbOrderInfos); - List ids = tbOrderInfos.stream().map(TbOrderInfo::getId).collect(Collectors.toList()); - orderInfoMapper.update(null, new LambdaUpdateWrapper() - .in(TbOrderInfo::getId, ids) - .eq(TbOrderInfo::getStatus, "unpaid") - .set(TbOrderInfo::getStatus, "cancel")); + tbOrderInfos.parallelStream().forEach(orderInfo -> { + try { + // 查询是否消耗了积分优惠券返还对应的卷或商品 + if (orderInfo.getCouponInfoList() != null) { + OrderCouponInfoDTO couponInfoDTO = JSONObject.parseObject(orderInfo.getCouponInfoList(), OrderCouponInfoDTO.class); + // 券返还 + if (!couponInfoDTO.getOutRecordList().isEmpty()) { + couponInfoDTO.getOutRecordList().forEach(item -> { + item.setRefNum(item.getUseNum()); + }); + shopCouponService.refund(couponInfoDTO.getOutRecordList()); + couponInfoDTO.setOutRecordList(new ArrayList<>()); + orderInfo.setCouponInfoList(null); + } + } + + // 返还积分 + if (orderInfo.getPointsNum() != null && orderInfo.getPointsNum() != 0 && orderInfo.getMemberId() != null) { + memberPointsService.addPoints(Long.valueOf(orderInfo.getMemberId()), orderInfo.getPointsNum(), "订单取消返还: " + orderInfo.getPointsNum() + "积分", Long.valueOf(orderInfo.getId())); + } + + mpCashierCartService.updateStateByOrderId(TableConstant.OrderInfo.Status.CLOSED, orderInfo.getId()); + mpOrderDetailService.updateStatusByOrderId(TableConstant.OrderInfo.Status.CLOSED, orderInfo.getId()); + + // 修改订单信息 + orderInfoMapper.update(null, new LambdaUpdateWrapper() + .eq(TbOrderInfo::getId, orderInfo.getId()) + .eq(TbOrderInfo::getStatus, "unpaid") + .set(TbOrderInfo::getCouponInfoList, null) + .set(TbOrderInfo::getPointsNum, 0) + .set(TbOrderInfo::getUpdatedAt, cn.hutool.core.date.DateUtil.current()) + .set(TbOrderInfo::getStatus, "cancelled")); + } catch (Exception e) { + log.error("取消订单失败: 订单信息: {}", orderInfo); + log.error("异常信息: ", e); + } + }); +// List ids = tbOrderInfos.stream().map(TbOrderInfo::getId).collect(Collectors.toList()); + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/StockServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/StockServiceImpl.java index 6dc960a6..8d01bc1c 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/StockServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/StockServiceImpl.java @@ -194,6 +194,12 @@ public class StockServiceImpl implements StockService { sqlQuery.append(" set is_grounding = ").append(updateValueVO.getValue()); wxMsgUtils.aboardOperationMsg(("1".equals(updateValueVO.getValue()) ? "上架: " : "下架: ") + description, Integer.valueOf(product.getShopId())); description.append("0".equals(updateValueVO.getValue()) ? "已下架" : "已上架"); + if("0".equals(updateValueVO.getValue())){ + int i = tbProductSkuRepository.countGrounding(product.getId(), tbProductSku.getId()); + if (i == 0) { + tbProductRepository.upGrounding(product.getId()); + } + } break; case "salePrice"://价格 description.append("修改价格为").append(updateValueVO.getValue()); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbMerchantCouponServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbMerchantCouponServiceImpl.java deleted file mode 100644 index 889d8ca9..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbMerchantCouponServiceImpl.java +++ /dev/null @@ -1,180 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.service.impl.shopimpl; - -import cn.hutool.core.bean.BeanUtil; -import cn.ysk.cashier.exception.BadRequestException; -import cn.ysk.cashier.pojo.product.TbProduct; -import cn.ysk.cashier.pojo.shop.TbMerchantCoupon; -import cn.ysk.cashier.repository.product.TbProductRepository; -import cn.ysk.cashier.utils.ValidationUtil; -import cn.ysk.cashier.utils.FileUtil; -import cn.ysk.cashier.vo.CouponVO; -import lombok.RequiredArgsConstructor; -import cn.ysk.cashier.repository.shop.TbMerchantCouponRepository; -import cn.ysk.cashier.service.shop.TbMerchantCouponService; -import cn.ysk.cashier.dto.shop.TbMerchantCouponDto; -import cn.ysk.cashier.dto.shop.TbMerchantCouponQueryCriteria; -import cn.ysk.cashier.mapper.shop.TbMerchantCouponMapper; -import org.springframework.beans.BeanUtils; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import cn.ysk.cashier.utils.PageUtil; -import cn.ysk.cashier.utils.QueryHelp; - -import java.sql.Timestamp; -import java.time.Instant; -import java.util.*; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; - -/** -* @website https://eladmin.vip -* @description 服务实现 -* @author lyf -* @date 2024-03-20 -**/ -@Service -@RequiredArgsConstructor -public class TbMerchantCouponServiceImpl implements TbMerchantCouponService { - - private final TbMerchantCouponRepository tbMerchantCouponRepository; - private final TbMerchantCouponMapper tbMerchantCouponMapper; - private final TbProductRepository tbProductRepository; - - @Override - public Map queryAll(TbMerchantCouponQueryCriteria criteria, Pageable pageable){ - Page page = tbMerchantCouponRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); - List objects = new ArrayList<>(); - for (TbMerchantCoupon o :page.getContent()) { - CouponVO couponVO = new CouponVO(); - BeanUtils.copyProperties(o,couponVO); - if (!o.getRelationIds().isEmpty()) { - List integers = new ArrayList<>(); - integers.add(Integer.valueOf(o.getRelationIds())); - List byIds = tbProductRepository.findByIds(integers); - couponVO.setName(byIds.get(0).getName()); - couponVO.setCoverImg(byIds.get(0).getCoverImg()); - } - objects.add(couponVO); - } - HashMap couponvoMap = new HashMap<>(); - couponvoMap.put("content", objects); - couponvoMap.put("totalElements", page.getTotalElements()); - return couponvoMap; -// return PageUtil.toPage(page.map(tbMerchantCouponMapper::toDto)); - } - @Override - public List queryAll(TbMerchantCouponQueryCriteria criteria){ - return tbMerchantCouponMapper.toDto(tbMerchantCouponRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); - } - - @Override - @Transactional - public TbMerchantCouponDto findById(Integer id) { - TbMerchantCoupon tbMerchantCoupon = tbMerchantCouponRepository.findById(id).orElseGet(TbMerchantCoupon::new); - ValidationUtil.isNull(tbMerchantCoupon.getId(),"TbMerchantCoupon","id",id); - return tbMerchantCouponMapper.toDto(tbMerchantCoupon); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public TbMerchantCoupon create(TbMerchantCoupon resources) { - resources.setCreatedAt(Instant.now().toEpochMilli()); - resources.setUpdatedAt(Instant.now().toEpochMilli()); - if (resources.getEffectType() == 1){ - if (resources.getToTime() == null && resources.getFromTime() == null){ - throw new BadRequestException("开始时间结束时间为空"); - } - }else { - resources.setToTime(null); - resources.setFromTime(null); - } - - if ("product".equals(resources.getClassType())){ - if (resources.getRelationIds() == null){ - throw new BadRequestException("商品不能为空"); - } - } - if (resources.getNumber() == 0){ - resources.setLeftNumber(0); - }else { - resources.setLeftNumber(resources.getNumber()); - } - return tbMerchantCouponRepository.save(resources); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void update(TbMerchantCoupon resources) { - TbMerchantCoupon tbMerchantCoupon = tbMerchantCouponRepository.findById(resources.getId()).orElseGet(TbMerchantCoupon::new); - ValidationUtil.isNull( tbMerchantCoupon.getId(),"TbMerchantCoupon","id",resources.getId()); - tbMerchantCoupon.copy(resources); - tbMerchantCouponRepository.save(tbMerchantCoupon); - } - - @Override - public void deleteAll(Integer[] ids) { - for (Integer id : ids) { - tbMerchantCouponRepository.deleteById(id); - } - } - - @Override - public void download(List all, HttpServletResponse response) throws IOException { - List> list = new ArrayList<>(); - for (TbMerchantCouponDto tbMerchantCoupon : all) { - Map map = new LinkedHashMap<>(); - map.put("状态0-关闭 1 正常", tbMerchantCoupon.getStatus()); - map.put(" 优惠券名称", tbMerchantCoupon.getTitle()); - map.put(" templateId", tbMerchantCoupon.getTemplateId()); - map.put(" shopId", tbMerchantCoupon.getShopId()); - map.put(" shopSnap", tbMerchantCoupon.getShopSnap()); - map.put("开始时间", tbMerchantCoupon.getFromTime()); - map.put("到期时间", tbMerchantCoupon.getToTime()); - map.put("限领数量", tbMerchantCoupon.getLimitNumber()); - map.put("发放数量", tbMerchantCoupon.getNumber()); - map.put("剩余数量", tbMerchantCoupon.getLeftNumber()); - map.put("优惠金额", tbMerchantCoupon.getAmount()); - map.put("订单满赠金额", tbMerchantCoupon.getLimitAmount()); - map.put("是否显示0-不显示 1显示", tbMerchantCoupon.getIsShow()); - map.put("图标", tbMerchantCoupon.getPic()); - map.put("0-满减 1-折扣", tbMerchantCoupon.getType()); - map.put("折扣 ,一位小数", tbMerchantCoupon.getRatio()); - map.put("最大折扣金额", tbMerchantCoupon.getMaxRatioAmount()); - map.put("优惠券途径,首充|分销", tbMerchantCoupon.getTrack()); - map.put("品类product 商品券 ---cateogry 品类券common -通 用券", tbMerchantCoupon.getClassType()); - map.put("有效期类型:0-toTime有效 1-effectDays有效", tbMerchantCoupon.getEffectType()); - map.put("领取之日有效天数", tbMerchantCoupon.getEffectDays()); - map.put("关联商品Id", tbMerchantCoupon.getRelationIds()); - map.put(" relationList", tbMerchantCoupon.getRelationList()); - map.put("发放人", tbMerchantCoupon.getEditor()); - map.put("说明", tbMerchantCoupon.getNote()); - map.put(" createdAt", tbMerchantCoupon.getCreatedAt()); - map.put(" updatedAt", tbMerchantCoupon.getUpdatedAt()); - map.put("支持堂食", tbMerchantCoupon.getFurnishMeal()); - map.put("支持配送", tbMerchantCoupon.getFurnishExpress()); - map.put("支持自提", tbMerchantCoupon.getFurnishDraw()); - map.put("支持虚拟", tbMerchantCoupon.getFurnishVir()); - map.put(" disableDistribute", tbMerchantCoupon.getDisableDistribute()); - map.put("商户Id", tbMerchantCoupon.getMerchantId()); - list.add(map); - } - FileUtil.downloadExcel(list, response); - } -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbReceiptSalesServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbReceiptSalesServiceImpl.java deleted file mode 100644 index a6b3889c..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbReceiptSalesServiceImpl.java +++ /dev/null @@ -1,122 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.service.impl.shopimpl; - -import cn.ysk.cashier.pojo.shop.TbReceiptSales; -import cn.ysk.cashier.mapper.shop.TbReceiptSalesMapper; -import cn.ysk.cashier.utils.ValidationUtil; -import cn.ysk.cashier.utils.FileUtil; -import lombok.RequiredArgsConstructor; -import cn.ysk.cashier.repository.shop.TbReceiptSalesRepository; -import cn.ysk.cashier.service.shop.TbReceiptSalesService; -import cn.ysk.cashier.dto.shop.TbReceiptSalesDto; -import cn.ysk.cashier.dto.shop.TbReceiptSalesQueryCriteria; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import cn.ysk.cashier.utils.PageUtil; -import cn.ysk.cashier.utils.QueryHelp; -import java.util.List; -import java.util.Map; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; -import java.util.LinkedHashMap; - -/** -* @website https://eladmin.vip -* @description 服务实现 -* @author lyf -* @date 2024-01-08 -**/ -@Service -@RequiredArgsConstructor -public class TbReceiptSalesServiceImpl implements TbReceiptSalesService { - - private final TbReceiptSalesRepository tbReceiptSalesRepository; - private final TbReceiptSalesMapper tbReceiptSalesMapper; - - @Override - public Map queryAll(TbReceiptSalesQueryCriteria criteria, Pageable pageable){ - Page page = tbReceiptSalesRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); - return PageUtil.toPage(page.map(tbReceiptSalesMapper::toDto)); - } - - @Override - public List queryAll(TbReceiptSalesQueryCriteria criteria){ - return tbReceiptSalesMapper.toDto(tbReceiptSalesRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); - } - - @Override - @Transactional - public TbReceiptSalesDto findById(Integer id) { - TbReceiptSales tbReceiptSales = tbReceiptSalesRepository.findById(id).orElseGet(TbReceiptSales::new); - - return tbReceiptSalesMapper.toDto(tbReceiptSales); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public TbReceiptSalesDto create(TbReceiptSales resources) { - return tbReceiptSalesMapper.toDto(tbReceiptSalesRepository.save(resources)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void update(TbReceiptSales resources) { - TbReceiptSales tbReceiptSales = tbReceiptSalesRepository.findById(resources.getId()).orElseGet(TbReceiptSales::new); - ValidationUtil.isNull( tbReceiptSales.getId(),"TbReceiptSales","id",resources.getId()); - tbReceiptSales.copy(resources); - tbReceiptSalesRepository.save(tbReceiptSales); - } - - @Override - public void deleteAll(Integer[] ids) { - for (Integer id : ids) { - tbReceiptSalesRepository.deleteById(id); - } - } - - @Override - public void download(List all, HttpServletResponse response) throws IOException { - List> list = new ArrayList<>(); - for (TbReceiptSalesDto tbReceiptSales : all) { - Map map = new LinkedHashMap<>(); - map.put("标题", tbReceiptSales.getTitle()); - map.put("是否显示公司Logo", tbReceiptSales.getLogo()); - map.put("打印联系电话等信息", tbReceiptSales.getShowContactInfo()); - map.put("打印会员开关 0?1", tbReceiptSales.getShowMember()); - map.put("打印会员编号开关", tbReceiptSales.getShowMemberCode()); - map.put("打印会员积分", tbReceiptSales.getShowMemberScore()); - map.put("打印会员余额开关 0?1", tbReceiptSales.getShowMemberWallet()); - map.put("店铺Id", tbReceiptSales.getFooterRemark()); - map.put("打印找零", tbReceiptSales.getShowCashCharge()); - map.put("流水号", tbReceiptSales.getShowSerialNo()); - map.put("用大号字打印流水号 在showSerialNo可用前提下", tbReceiptSales.getBigSerialNo()); - map.put("头部文字", tbReceiptSales.getHeaderText()); - map.put("文字 对齐方式", tbReceiptSales.getHeaderTextAlign()); - map.put("尾部文字", tbReceiptSales.getFooterText()); - map.put("文字 对齐方式", tbReceiptSales.getFooterTextAlign()); - map.put("尾部图像", tbReceiptSales.getFooterImage()); - map.put("预打印,YES开启 NO不开启", tbReceiptSales.getPrePrint()); - map.put(" createdAt", tbReceiptSales.getCreatedAt()); - map.put(" updatedAt", tbReceiptSales.getUpdatedAt()); - list.add(map); - } - FileUtil.downloadExcel(list, response); - } -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopCashSpreadServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopCashSpreadServiceImpl.java deleted file mode 100644 index ed790ae3..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopCashSpreadServiceImpl.java +++ /dev/null @@ -1,115 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.service.impl.shopimpl; - -import cn.ysk.cashier.pojo.shop.TbShopCashSpread; -import cn.ysk.cashier.service.shop.TbShopCashSpreadService; -import cn.ysk.cashier.dto.shop.TbShopCashSpreadDto; -import cn.ysk.cashier.mapper.shop.TbShopCashSpreadMapper; -import cn.ysk.cashier.utils.ValidationUtil; -import cn.ysk.cashier.utils.FileUtil; -import lombok.RequiredArgsConstructor; -import cn.ysk.cashier.repository.shop.TbShopCashSpreadRepository; -import cn.ysk.cashier.dto.shop.TbShopCashSpreadQueryCriteria; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import cn.ysk.cashier.utils.PageUtil; -import cn.ysk.cashier.utils.QueryHelp; - -import java.time.Instant; -import java.util.List; -import java.util.Map; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; -import java.util.LinkedHashMap; - -/** -* @website https://eladmin.vip -* @description 服务实现 -* @author lyf -* @date 2024-01-05 -**/ -@Service -@RequiredArgsConstructor -public class TbShopCashSpreadServiceImpl implements TbShopCashSpreadService { - - private final TbShopCashSpreadRepository tbShopCashSpreadRepository; - private final TbShopCashSpreadMapper tbShopCashSpreadMapper; - - @Override - public Map queryAll(TbShopCashSpreadQueryCriteria criteria, Pageable pageable){ - Page page = tbShopCashSpreadRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); - return PageUtil.toPage(page.map(tbShopCashSpreadMapper::toDto)); - } - - @Override - public List queryAll(TbShopCashSpreadQueryCriteria criteria){ - return tbShopCashSpreadMapper.toDto(tbShopCashSpreadRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); - } - - @Override - @Transactional - public TbShopCashSpreadDto findById(String id) { - TbShopCashSpread tbShopCashSpread = tbShopCashSpreadRepository.findById(id).orElseGet(TbShopCashSpread::new); - ValidationUtil.isNull(tbShopCashSpread.getId(),"TbShopCashSpread","id",id); - return tbShopCashSpreadMapper.toDto(tbShopCashSpread); - } - - @Override - public TbShopCashSpread findByShopId(Integer id) { - TbShopCashSpread byShopId = tbShopCashSpreadRepository.findByShopId(id); - return byShopId; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public TbShopCashSpreadDto create(TbShopCashSpread resources) { - return tbShopCashSpreadMapper.toDto(tbShopCashSpreadRepository.save(resources)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public Integer update(TbShopCashSpread resources) { - return tbShopCashSpreadRepository.updateConfig(resources.getId(), resources.getScreenConfig().trim(), Instant.now().toEpochMilli()); - } - - @Override - public void deleteAll(String[] ids) { - for (String id : ids) { - tbShopCashSpreadRepository.deleteById(id); - } - } - - @Override - public void download(List all, HttpServletResponse response) throws IOException { - List> list = new ArrayList<>(); - for (TbShopCashSpreadDto tbShopCashSpread : all) { - Map map = new LinkedHashMap<>(); - map.put("登陆密码", tbShopCashSpread.getSaleReceipt()); - map.put("状态", tbShopCashSpread.getTriplicateReceipt()); - map.put("到期提醒时间", tbShopCashSpread.getScreenConfig()); - map.put(" tagConfig", tbShopCashSpread.getTagConfig()); - map.put(" scaleConfig", tbShopCashSpread.getScaleConfig()); - map.put(" createdAt", tbShopCashSpread.getCreatedAt()); - map.put(" updatedAt", tbShopCashSpread.getUpdatedAt()); - list.add(map); - } - FileUtil.downloadExcel(list, response); - } -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopCurrencyServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopCurrencyServiceImpl.java deleted file mode 100644 index 936412ee..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopCurrencyServiceImpl.java +++ /dev/null @@ -1,130 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.service.impl.shopimpl; - -import cn.ysk.cashier.pojo.shop.TbShopCurrency; -import cn.ysk.cashier.utils.ValidationUtil; -import cn.ysk.cashier.utils.FileUtil; -import lombok.RequiredArgsConstructor; -import cn.ysk.cashier.repository.shop.TbShopCurrencyRepository; -import cn.ysk.cashier.service.shop.TbShopCurrencyService; -import cn.ysk.cashier.dto.shop.TbShopCurrencyDto; -import cn.ysk.cashier.dto.shop.TbShopCurrencyQueryCriteria; -import cn.ysk.cashier.mapper.shop.TbShopCurrencyMapper; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import cn.ysk.cashier.utils.PageUtil; -import cn.ysk.cashier.utils.QueryHelp; -import java.util.List; -import java.util.Map; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; -import java.util.LinkedHashMap; - -/** -* @website https://eladmin.vip -* @description 服务实现 -* @author lyf -* @date 2024-01-05 -**/ -@Service -@RequiredArgsConstructor -public class TbShopCurrencyServiceImpl implements TbShopCurrencyService { - - private final TbShopCurrencyRepository tbShopCurrencyRepository; - private final TbShopCurrencyMapper tbShopCurrencyMapper; - - @Override - public Map queryAll(TbShopCurrencyQueryCriteria criteria, Pageable pageable){ - Page page = tbShopCurrencyRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); - return PageUtil.toPage(page.map(tbShopCurrencyMapper::toDto)); - } - - @Override - public List queryAll(TbShopCurrencyQueryCriteria criteria){ - return tbShopCurrencyMapper.toDto(tbShopCurrencyRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); - } - - @Override - @Transactional - public TbShopCurrencyDto findById(Integer id) { - TbShopCurrency tbShopCurrency = tbShopCurrencyRepository.findById(id).orElseGet(TbShopCurrency::new); - ValidationUtil.isNull(tbShopCurrency.getId(),"TbShopCurrency","id",id); - return tbShopCurrencyMapper.toDto(tbShopCurrency); - } - - @Override - public TbShopCurrency findByShopId(String id) { - TbShopCurrency byShopId = tbShopCurrencyRepository.findByShopId(id); - return byShopId; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public TbShopCurrencyDto create(TbShopCurrency resources) { - return tbShopCurrencyMapper.toDto(tbShopCurrencyRepository.save(resources)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void update(TbShopCurrency resources) { - TbShopCurrency tbShopCurrency = tbShopCurrencyRepository.findById(resources.getId()).orElseGet(TbShopCurrency::new); - ValidationUtil.isNull( tbShopCurrency.getId(),"TbShopCurrency","id",resources.getId()); - tbShopCurrency.copy(resources); - tbShopCurrencyRepository.save(tbShopCurrency); - } - - @Override - public void deleteAll(Integer[] ids) { - for (Integer id : ids) { - tbShopCurrencyRepository.deleteById(id); - } - } - - @Override - public void download(List all, HttpServletResponse response) throws IOException { - List> list = new ArrayList<>(); - for (TbShopCurrencyDto tbShopCurrency : all) { - Map map = new LinkedHashMap<>(); - map.put("店铺Id", tbShopCurrency.getShopId()); - map.put("备用金", tbShopCurrency.getPrepareAmount()); - map.put("货币单位 ¥,$", tbShopCurrency.getCurrency()); - map.put("小数位,0,1,2,无,元,角,分", tbShopCurrency.getDecimalsDigits()); - map.put("无,四舍五入,五舍六入none,round4up5,round5up6,round12up34", tbShopCurrency.getDiscountRound()); - map.put("商户Id", tbShopCurrency.getMerchantId()); - map.put("订单抹零 -1无,0元 1角2分 0.5=0.5元", tbShopCurrency.getSmallChange()); - map.put("使折扣生效", tbShopCurrency.getEnableCustomDiscount()); - map.put("最大抹零金额(100)", tbShopCurrency.getMaxDiscount()); - map.put("最大折扣百分比,,优先级高于max_discount", tbShopCurrency.getMaxPercent()); - map.put("折扣显示详情", tbShopCurrency.getDiscountConfigs()); - map.put("营业时间(弃用)", tbShopCurrency.getBizDuration()); - map.put("允许网络支付", tbShopCurrency.getAllowWebPay()); - map.put("自动抹零,开启时,系统自动抹零", tbShopCurrency.getIsAutoToZero()); - map.put("商品含税", tbShopCurrency.getIsIncludeTaxPrice()); - map.put("服务费配置(小费)", tbShopCurrency.getServiceCharge()); - map.put("税号", tbShopCurrency.getTaxNumber()); - map.put(" createdAt", tbShopCurrency.getCreatedAt()); - map.put(" updatedAt", tbShopCurrency.getUpdatedAt()); - map.put("自动锁屏", tbShopCurrency.getAutoLockScreen()); - map.put("语音通知", tbShopCurrency.getVoiceNotification()); - list.add(map); - } - FileUtil.downloadExcel(list, response); - } -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 2a378fe6..fe28005b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -11,17 +11,22 @@ import cn.ysk.cashier.config.security.security.TokenProvider; import cn.ysk.cashier.cons.RedisConstant; import cn.ysk.cashier.cons.TableConstant; import cn.ysk.cashier.cons.rabbit.RabbitConstants; +import cn.ysk.cashier.dto.CouponDto; +import cn.ysk.cashier.dto.order.OrderCartInfoDTO; +import cn.ysk.cashier.dto.order.OrderCouponInfoDTO; +import cn.ysk.cashier.dto.order.OrderPriceDTO; +import cn.ysk.cashier.dto.order.UserCouponInfoDTO; +import cn.ysk.cashier.dto.points.OrderDeductionPointsDTO; import cn.ysk.cashier.dto.shop.TbShopTableDto; import cn.ysk.cashier.dto.shop.TbShopTableQueryCriteria; import cn.ysk.cashier.dto.shoptable.*; import cn.ysk.cashier.enums.*; import cn.ysk.cashier.exception.BadRequestException; import cn.ysk.cashier.mapper.shop.TbShopTableMapper; +import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord; +import cn.ysk.cashier.mybatis.entity.TbShopCoupon; import cn.ysk.cashier.mybatis.mapper.*; -import cn.ysk.cashier.mybatis.service.MpCashierCartService; -import cn.ysk.cashier.mybatis.service.MpOrderDetailService; -import cn.ysk.cashier.mybatis.service.MpOrderInfoService; -import cn.ysk.cashier.mybatis.service.MpShopTableService; +import cn.ysk.cashier.mybatis.service.*; import cn.ysk.cashier.pojo.TbShopPayType; import cn.ysk.cashier.pojo.order.TbCashierCart; import cn.ysk.cashier.pojo.order.TbOrderDetail; @@ -40,7 +45,9 @@ import cn.ysk.cashier.service.impl.TbPayServiceImpl; import cn.ysk.cashier.service.order.TbOrderInfoService; import cn.ysk.cashier.service.shop.TbShopTableService; import cn.ysk.cashier.utils.*; +import cn.ysk.cashier.vo.ActivateInInfoVO; import cn.ysk.cashier.vo.PendingCountVO; +import cn.ysk.cashier.vo.TbUserCouponVo; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; @@ -98,6 +105,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { private final MpShopTableService mpShopTableService; private final MpShopUnitMapper mpShopUnitMapper; private final MpProductStockDetailMapper mpProductStockDetailMapper; + private final TbMemberPointsService memberPointsService; + private final TbShopCouponService shopCouponService; /** @@ -117,10 +126,12 @@ public class TbShopTableServiceImpl implements TbShopTableService { private final PayService payService; private final TbOrderInfoService orderInfoService; private final MpOrderInfoService mpOrderInfoService; + private final TbShopUserMapper tbShopUserMapper; + private final TbActivateInRecordService activateInRecordService; private TbOrderInfo getCurrentOrder(ShopEatTypeInfoDTO eatTypeInfoDTO) { // 获取当前台桌最新订单,先付款模式不获取 - if (eatTypeInfoDTO.isDineInBefore()) { + if (!eatTypeInfoDTO.isDineInAfter()) { return null; } List orderInfoList = orderInfoMapper.selectPage(new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(1, 1), new LambdaQueryWrapper() @@ -128,7 +139,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { .eq(TbOrderInfo::getUseType, eatTypeInfoDTO.getUseType()) .eq(TbOrderInfo::getShopId, eatTypeInfoDTO.getShopId()) .eq(TbOrderInfo::getTableId, eatTypeInfoDTO.getTableId()) - .eq(TbOrderInfo::getTradeDay, DateUtils.getDay()) + .gt(TbOrderInfo::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime()) +// .eq(TbOrderInfo::getTradeDay, DateUtils.getDay()) .orderByDesc(TbOrderInfo::getId)).getRecords(); return orderInfoList.isEmpty() ? null : orderInfoList.get(0); } @@ -194,11 +206,12 @@ public class TbShopTableServiceImpl implements TbShopTableService { boolean isDineInBefore = hasTable && isMunchies && !isTakeout; // 是否无台桌 boolean isNoneTable = !hasTable && !isTakeout; + boolean isMemberPrice = shopInfo.getIsMemberPrice() != null && shopInfo.getIsMemberPrice() == 1; - boolean needSeatFee = shopInfo.getIsTableFee() == null || shopInfo.getIsTableFee() == 0; + boolean needSeatFee = !isTakeout && (shopInfo.getIsTableFee() == null || shopInfo.getIsTableFee() == 0); boolean isIncrMasterId = isTakeout || isNoneTable; - return new ShopEatTypeInfoDTO(isTakeout, isMunchies, isDineInAfter, isDineInBefore, needSeatFee, isNoneTable, isIncrMasterId, shopInfo, isTakeout ? TableConstant.OrderInfo.UseType.TAKEOUT.getValue() : + return new ShopEatTypeInfoDTO(isTakeout, isMunchies, isDineInAfter, isDineInBefore, needSeatFee, isNoneTable, isIncrMasterId, isMemberPrice, shopInfo, isTakeout ? TableConstant.OrderInfo.UseType.TAKEOUT.getValue() : isDineInBefore ? TableConstant.OrderInfo.UseType.DINE_IN_BEFORE.getValue() : isNoneTable ? TableConstant.OrderInfo.UseType.NONE_TABLE.getValue() : TableConstant.OrderInfo.UseType.DINE_IN_AFTER.getValue(), shopId, tableId, isTakeout ? OrderSendTypeEnums.TAKE_SELF.getValue() : OrderSendTypeEnums.TABLE.getValue()); } @@ -249,14 +262,35 @@ public class TbShopTableServiceImpl implements TbShopTableService { mpShopTableService.page(new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(criteria.getPage(), criteria.getSize()), query); List tbShopTableList = shopTablePage.getRecords(); ArrayList> infoList = new ArrayList<>(); + + List cartList = tbCashierCartMapper.selectList(new LambdaQueryWrapper() + .eq(TbCashierCart::getShopId, criteria.getShopId()) +// .eq(TbCashierCart::getTableId, date.getQrcode()) + .gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime()) + .eq(TbCashierCart::getStatus, "create")); + + HashMap countMap = new HashMap<>(); + cartList.forEach(item -> { + Integer count = countMap.computeIfAbsent(item.getTableId(), k -> 1); + countMap.put(item.getTableId(), count + 1); + }); + + HashMap currentOrderInfoMap = new HashMap<>(); + ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(criteria.getShopId(), "2232"); + List orderInfoList = orderInfoMapper.selectPage(new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(1, 1), new LambdaQueryWrapper() + .eq(TbOrderInfo::getStatus, "unpaid") + .eq(TbOrderInfo::getUseType, shopEatTypeInfoDTO.getUseType()) + .eq(TbOrderInfo::getShopId, shopEatTypeInfoDTO.getShopId()) +// .eq(TbOrderInfo::getTableId, eatTypeInfoDTO.getTableId()) + .gt(TbOrderInfo::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime()) +// .eq(TbOrderInfo::getTradeDay, DateUtils.getDay()) + .orderByDesc(TbOrderInfo::getId)).getRecords(); + orderInfoList.forEach(item -> currentOrderInfoMap.computeIfAbsent(item.getTableId(), k -> item)); + for (TbShopTable date : tbShopTableList) { if (StrUtil.isBlank(date.getQrcode())) { date.setStatus("unbind"); - } else if (tbCashierCartMapper.selectCount(new LambdaQueryWrapper() - .eq(TbCashierCart::getShopId, date.getShopId()) - .eq(TbCashierCart::getTableId, date.getQrcode()) - .gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime()) - .eq(TbCashierCart::getStatus, "create")) < 1 && !TableStateEnum.CLEANING.getState().equals(date.getStatus()) + } else if (countMap.get(date.getQrcode()) != null && countMap.get(date.getQrcode()) < 1 && !TableStateEnum.CLEANING.getState().equals(date.getStatus()) ) { date.setStatus("idle"); mpShopTableMapper.update(null, new LambdaUpdateWrapper() @@ -277,9 +311,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { TbOrderInfo orderInfo = null; if (StrUtil.isNotBlank(date.getQrcode())) { try { - - ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(criteria.getShopId(), date.getQrcode()); - orderInfo = getCurrentOrder(shopEatTypeInfoDTO); + orderInfo = currentOrderInfoMap.get(date.getQrcode()); } catch (Exception e) { log.info(e.getMessage()); } @@ -538,9 +570,15 @@ public class TbShopTableServiceImpl implements TbShopTableService { tbCashierCart.setCategoryId(product.getCategoryId()); tbCashierCart.setNote(addCartDTO.getNote()); tbCashierCart.setPlatformType(OrderPlatformTypeEnum.PC.getValue()); +// tbCashierCart.setIsMember(shopEatTypeInfoDTO.isMemberPrice() && addCartDTO.getVipUserId() == null ? 0 : 1); + tbCashierCart.setIsMember(addCartDTO.getVipUserId() == null ? 0 : 1); + if (tbCashierCart.getIsMember() == 1) { + tbCashierCart.setMemberPrice(productSku.getMemberPrice()); + } cashierCartRepository.save(tbCashierCart); } else { + tbCashierCart.setIsMember(addCartDTO.getVipUserId() == null ? 0 : 1); tbCashierCart.setNote(addCartDTO.getNote()); tbCashierCart.setTotalAmount(new BigDecimal(addCartDTO.getNum()).multiply(productSku.getSalePrice())); @@ -647,11 +685,13 @@ public class TbShopTableServiceImpl implements TbShopTableService { @Override public void returnCart(ReturnCartDTO removeCartDTO) { + boolean isSeatCart = TableConstant.CashierCart.ID.equals(removeCartDTO.getCartId().toString()); // 会员点单 TbCashierCart cashierCart = cashierCartMapper.selectOne(new LambdaQueryWrapper() .eq(TbCashierCart::getShopId, removeCartDTO.getShopId()) - .in(TbCashierCart::getStatus, OrderStatusEnums.CREATE.getValue()) - .isNotNull(TbCashierCart::getOrderId) +// .in(TbCashierCart::getStatus, OrderStatusEnums.CREATE.getValue()) + .ne(TbCashierCart::getStatus, TableConstant.OrderInfo.Status.RETURN.getValue()) +// .isNotNull(TbCashierCart::getOrderId) .eq(TbCashierCart::getId, removeCartDTO.getCartId())); if (cashierCart == null) { @@ -666,11 +706,12 @@ public class TbShopTableServiceImpl implements TbShopTableService { throw new BadRequestException("此商品还未下单,无需退单"); } + // 餐位费直接删除 TbOrderDetail orderDetail = orderDetailMapper.selectOne(new LambdaQueryWrapper() .eq(TbOrderDetail::getCartId, cashierCart.getId())); - if (cashierCart.getProductId().equals("-999")) { + if (false && cashierCart.getProductId().equals("-999")) { cashierCartMapper.deleteById(cashierCart.getId()); cashierCartMapper.update(null, new LambdaUpdateWrapper() .eq(TbCashierCart::getId, cashierCart.getId()) @@ -699,7 +740,9 @@ public class TbShopTableServiceImpl implements TbShopTableService { .eq(TbOrderDetail::getId, tbOrderDetail.getId()) .set(TbOrderDetail::getUpdateTime, DateUtil.date()) .set(TbOrderDetail::getStatus, "return")); - rabbitMsgUtils.printDishesTicket(tbOrderDetail.getOrderId(), true, tbOrderDetail); + if (TableConstant.OrderInfo.UseType.DINE_IN_AFTER.equalsVals(tbOrderDetail.getUseType()) && !isSeatCart) { + rabbitMsgUtils.printDishesTicket(tbOrderDetail.getOrderId(), true, tbOrderDetail); + } } else { //生成退菜的购物车记录 TbCashierCart returnCart = BeanUtil.copyProperties(cashierCart, TbCashierCart.class); @@ -724,7 +767,9 @@ public class TbShopTableServiceImpl implements TbShopTableService { cashierCartMapper.updateNumAmountStatus(cashierCart.getId(), cashierCart.getStatus(), -returnCart.getNumber()); orderDetailMapper.updateNumAmountStatus(orderDetail.getId(), orderDetail.getStatus(), -returnCart.getNumber()); - rabbitMsgUtils.printDishesTicket(returnOrderDetail.getOrderId(), true, returnOrderDetail); + if (TableConstant.OrderInfo.UseType.DINE_IN_AFTER.equalsVals(tbOrderDetail.getUseType()) && !isSeatCart) { + rabbitMsgUtils.printDishesTicket(returnOrderDetail.getOrderId(), true, returnOrderDetail); + } } } @@ -782,7 +827,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (!shopEatTypeInfoDTO.isTakeout()) { if (StrUtil.isBlank(tableId)) { - queryWrapper.isNull(TbCashierCart::getTableId); + queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, "")); } else { queryWrapper.eq(TbCashierCart::getTableId, tableId); } @@ -1093,343 +1138,627 @@ public class TbShopTableServiceImpl implements TbShopTableService { @Override @Transactional - public TbOrderInfo createOrder(CreateOrderDTO createOrderDTO, boolean addMaterId, boolean isPrint) { + public TbOrderInfo createOrder(CreateOrderDTO createOrderDTO, boolean byOrderId) { createOrderDTO.setTableId(OrderUseTypeEnum.TAKEOUT.getValue().equals(createOrderDTO.getUseType()) ? null : createOrderDTO.getTableId()); return Utils.runFunAndCheckKey(() -> { TbShopInfo shopInfo = shopInfoRepository.findById(createOrderDTO.getShopId()).orElse(null); if (shopInfo == null) throw new BadRequestException("店铺信息不存在"); + TbShopUser shopUser = null; + if (createOrderDTO.getVipUserId() != null) { + shopUser = tbShopUserMapper.selectById(createOrderDTO.getVipUserId()); + } + + TbShopTable shopTable = checkTableState(createOrderDTO); // 就餐模式信息 ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(createOrderDTO.getShopId(), createOrderDTO.getTableId(), createOrderDTO.getUseType()); - // 传递orderId直接取否则取当前缓存id - Integer orderId = shopEatTypeInfoDTO.isDineInAfter() ? - getCurrentOrderId(shopEatTypeInfoDTO) : null; - - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() - .eq(TbCashierCart::getShopId, createOrderDTO.getShopId()) - .eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType()) - .in(TbCashierCart::getStatus, "create", "return") - .gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime()) - .and(q -> q.eq(TbCashierCart::getMasterId, createOrderDTO.getMasterId()).or().isNull(TbCashierCart::getMasterId)); - - // 非堂食校验台桌状态 - TbShopTable tbShopTable = null; - if (shopEatTypeInfoDTO.isTakeout()) { - queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, "")) - .in(TbCashierCart::getPlatformType, OrderPlatformTypeEnum.PC.getValue(), OrderPlatformTypeEnum.CASH.getValue()); - } else { - if (StrUtil.isNotBlank(createOrderDTO.getTableId())) { - tbShopTable = mpShopTableMapper.selectOne(new LambdaQueryWrapper() - .eq(TbShopTable::getQrcode, createOrderDTO.getTableId()) - .in(TbShopTable::getStatus, "idle", "using")); - if (tbShopTable == null) { - throw new BadRequestException("台桌未开台或不存在"); - } - queryWrapper.eq(TbCashierCart::getTableId, createOrderDTO.getTableId()); - } else { - queryWrapper.isNull(TbCashierCart::getTableId); - } - + OrderCartInfoDTO cartInfoDTO = getCartForCreateOrder(shopEatTypeInfoDTO, createOrderDTO.getMasterId(), shopUser, byOrderId ? createOrderDTO.getOrderId() : null, byOrderId); + if (cartInfoDTO.getOrderId() == null) { + createOrderDTO.setOrderId(shopEatTypeInfoDTO.isDineInAfter() ? + getCurrentOrderId(shopEatTypeInfoDTO) : null); } - - List allCashierCarts = cashierCartMapper - .selectList(queryWrapper); - - List cashierCarts = new ArrayList<>(); - TbCashierCart seatCart = null; - for (TbCashierCart allCashierCart : allCashierCarts) { - if (TableConstant.CART_SEAT_ID.equals(allCashierCart.getProductId())) { - seatCart = allCashierCart; - } - - if (OrderStatusEnums.CREATE.getValue().equals(allCashierCart.getStatus())) { - cashierCarts.add(allCashierCart); - } - } - - if (StrUtil.isNotBlank(createOrderDTO.getTableId()) - && (cashierCarts.isEmpty() || - (shopEatTypeInfoDTO.isNeedSeatFee() && !shopEatTypeInfoDTO.isTakeout() && seatCart != null && cashierCarts.size() < 2) - || (shopEatTypeInfoDTO.isNeedSeatFee() && !shopEatTypeInfoDTO.isTakeout() && seatCart == null))) { - throw new BadRequestException("购物车为空或未选择餐位费,请先添加商品或选择餐位费"); - } - - if (cashierCarts.isEmpty()) { - throw new BadRequestException("购物车为空"); - } - - ArrayList cartIdList = new ArrayList<>(); - for (TbCashierCart tbCashierCart : cashierCarts) { - if (tbCashierCart.getOrderId() != null) { - orderId = tbCashierCart.getOrderId(); - } - cartIdList.add(tbCashierCart.getId()); - } - // 查询历史orderDetail - Integer finalOrderId = orderId; - LambdaQueryWrapper query = new LambdaQueryWrapper() - .and(q -> q.in(TbOrderDetail::getCartId, cartIdList).or().eq(TbOrderDetail::getOrderId, finalOrderId)) - .eq(TbOrderDetail::getShopId, createOrderDTO.getShopId()); - - List oldOrderDetailList = orderDetailMapper.selectList(query); - ArrayList removeOrderDetailIds = new ArrayList<>(); - ArrayList removeOrderDetailList = new ArrayList<>(); - HashMap oldOrderDetailMap = new HashMap<>(); - oldOrderDetailList.forEach(item -> { - if (cartIdList.contains(item.getCartId())) { - oldOrderDetailMap.put(item.getOrderId().toString() + item.getCartId(), item); - } else { - removeOrderDetailIds.add(item.getId()); - removeOrderDetailList.add(item); - } - }); - - BigDecimal totalAmount = BigDecimal.ZERO; - BigDecimal packAMount = BigDecimal.ZERO; - BigDecimal feeAmount = BigDecimal.ZERO; - BigDecimal saleAmount = BigDecimal.ZERO; - // 当前下单次数 - int placeNum = getCurrentPlaceNum(shopEatTypeInfoDTO); - List orderDetails = new ArrayList<>(); - List addOrderDetails = new ArrayList<>(); - - - boolean hasNewInfo = false; - for (TbCashierCart cashierCart : cashierCarts) { - if (!"return".equals(cashierCart.getStatus())) { - totalAmount = totalAmount.add(cashierCart.getTotalAmount()); - packAMount = packAMount.add(cashierCart.getPackFee()); - feeAmount = cashierCart.getPackFee(); - } - - TbProductSku productSku = productSkuRepository.findById(Integer.valueOf(cashierCart.getSkuId())).orElse(null); - TbOrderDetail orderDetail = null; - if (cashierCart.getOrderId() != null) { - orderDetail = oldOrderDetailMap.get(cashierCart.getOrderId().toString() + cashierCart.getId()); - } - - if (orderDetail == null) { - orderDetail = new TbOrderDetail(); - hasNewInfo = true; - addOrderDetails.add(orderDetail); - } - - if (Objects.nonNull(productSku)) { - saleAmount = saleAmount.add(productSku.getSalePrice()); - orderDetail.setProductSkuName(productSku.getSpecSnap()); - } - - orderDetail.setNote(cashierCart.getNote()); - orderDetail.setCreateTime(DateUtil.date().toTimestamp()); - orderDetail.setNum(cashierCart.getNumber()); - orderDetail.setPrice(cashierCart.getSalePrice()); - orderDetail.setPriceAmount(cashierCart.getTotalAmount()); - orderDetail.setProductId(Integer.valueOf(cashierCart.getProductId())); - orderDetail.setProductSkuId(Integer.valueOf(cashierCart.getSkuId())); - orderDetail.setProductName(cashierCart.getName()); - orderDetail.setShopId(Integer.valueOf(cashierCart.getShopId())); - orderDetail.setPackAmount(cashierCart.getPackFee()); - orderDetail.setStatus("unpaid"); - orderDetail.setUseType(shopEatTypeInfoDTO.getUseType()); - orderDetail.setProductImg(cashierCart.getCoverImg()); - orderDetail.setCartId(cashierCart.getId()); - if (cashierCart.getOrderId() != null) { - orderId = cashierCart.getOrderId(); - } - orderDetail.setOrderId(orderId); - orderDetails.add(orderDetail); - } - - // 查询订单 TbOrderInfo orderInfo = null; - if (orderId != null) { - orderInfo = orderInfoMapper.selectById(orderId); + if (cartInfoDTO.getOrderId() != null) { + orderInfo = orderInfoMapper.selectById(cartInfoDTO.getOrderId()); } + +// OrderCouponInfoDTO couponInfo = null; +// if (createOrderDTO.getUserCouponInfos().isEmpty() && createOrderDTO.getVipUserId() != null) { +// // 获取优惠券信息 +// couponInfo = getCouponInfo(createOrderDTO, orderInfo, cartInfoDTO.getNewAddTotalAmount(), cartInfoDTO.getCashierCarts()); +// +// // 根据优惠券信息重新计算购物车相关价格 +// calcCartPriceWithCoupon(cartInfoDTO.getNewCashierCarts(), couponInfo, couponInfo.getShopUser().getId()); +// } + + // 创建订单详情 + OrderPriceDTO detailPriceDTO = createOrderDetailWithCoupon(cartInfoDTO.getCashierCarts(), orderInfo, createOrderDTO.getShopId(), true, shopEatTypeInfoDTO); + // 是否是第一次创建订单 - boolean isFirst = false; - // 修改订单信息 - if (orderInfo != null) { - // 更新取餐号 - orderInfo.setOutNumber(updateOutNumber(String.valueOf(createOrderDTO.getShopId())).toString()); - orderInfo.setUpdatedAt(System.currentTimeMillis()); - orderInfo.setSettlementAmount(totalAmount); - orderInfo.setAmount(totalAmount); - orderInfo.setOriginAmount(totalAmount); -// orderInfo.setStatus("unpaid"); - orderInfo.setOrderAmount(totalAmount); - orderInfo.setRemark(createOrderDTO.getNote()); - orderInfo.setFreightAmount(feeAmount); - orderInfo.setProductAmount(saleAmount); - orderInfo.setTradeDay(DateUtils.getDay()); - orderInfo.setUseType(shopEatTypeInfoDTO.getUseType()); - orderInfo.setCreatedAt(DateUtil.current()); - if (seatCart != null) { - orderInfo.setSeatAmount(seatCart.getTotalAmount()); - orderInfo.setSeatCount(seatCart.getNumber()); - } - if (StrUtil.isNotBlank(createOrderDTO.getVipUserId())) { - orderInfo.setUserId(createOrderDTO.getVipUserId()); - } - orderInfo.setSendType(shopEatTypeInfoDTO.getSendType()); - // 存在新添加的商品,增加下单次数 - if (hasNewInfo) { - orderInfo.setPlaceNum(placeNum); - } - orderInfoMapper.updateById(orderInfo); - } else { - isFirst = true; - String orderNo = generateOrderNumber(null); - orderInfo = new TbOrderInfo(); - orderInfo.setOrderNo(orderNo); - orderInfo.setAmount(totalAmount); - orderInfo.setPayAmount(BigDecimal.ZERO); - orderInfo.setPackFee(packAMount); - orderInfo.setSettlementAmount(totalAmount); - orderInfo.setOriginAmount(totalAmount); - orderInfo.setProductAmount(saleAmount); - orderInfo.setOrderAmount(totalAmount); - orderInfo.setFreightAmount(feeAmount); - orderInfo.setTableId(createOrderDTO.getTableId()); - orderInfo.setSendType("table"); - orderInfo.setOrderType("cash"); - orderInfo.setShopId(createOrderDTO.getShopId().toString()); - orderInfo.setRefundAble(1); - orderInfo.setTradeDay(cn.ysk.cashier.utils.DateUtils.getDay()); - orderInfo.setMasterId(createOrderDTO.getMasterId()); - orderInfo.setOutNumber(createOrderDTO.getMasterId()); - orderInfo.setRemark(createOrderDTO.getNote()); - orderInfo.setCreatedAt(DateUtil.current()); - orderInfo.setTableName(tbShopTable != null ? tbShopTable.getName() : null); - orderInfo.setPlaceNum(placeNum); - orderInfo.setUseType(shopEatTypeInfoDTO.getUseType()); - if (StrUtil.isNotBlank(createOrderDTO.getVipUserId())) { - orderInfo.setUserId(createOrderDTO.getVipUserId()); - } - if (seatCart != null) { - orderInfo.setSeatAmount(seatCart.getTotalAmount()); - orderInfo.setSeatCount(seatCart.getNumber()); - } - orderInfo.setSendType(shopEatTypeInfoDTO.getSendType()); - TbMerchantAccount merchantAccount = merchantAccountMapper.selectOne(new LambdaQueryWrapper() - .eq(TbMerchantAccount::getShopId, createOrderDTO.getShopId()) - .eq(TbMerchantAccount::getStatus, 1)); - if (merchantAccount == null) { - throw new BadRequestException("商户信息不存在"); - } - orderInfo.setMerchantId(merchantAccount.getId().toString()); - orderInfoMapper.insert(orderInfo); - } + orderInfo = createOrderWithAction(createOrderDTO, detailPriceDTO, shopEatTypeInfoDTO, + orderInfo, cartInfoDTO.getSeatCart(), shopUser, shopTable); - // 添加订单详细数据 - orderId = orderInfo.getId(); - for (TbOrderDetail orderDetail : orderDetails) { - orderDetail.setOrderId(orderId); - if (orderDetail.getPlaceNum() == null) { - orderDetail.setPlaceNum(placeNum); - } - } - // 删除已经移除购物车的订单 修改并保存数据 - if (!orderDetails.isEmpty()) { - mpOrderDetailService.saveOrUpdateBatch(orderDetails); - } + // 修改订单详情并打票 + updateDetailAndPrint(orderInfo, detailPriceDTO, shopEatTypeInfoDTO); - // 更新购物车记录的orderId - for (TbCashierCart cashierCart : cashierCarts) { - if (!"-999".equals(cashierCart.getProductId())) { - TbProduct product = productMapper.selectById(cashierCart.getProductId()); - TbProductSku productSku = productSkuRepository.findById(Integer.valueOf(cashierCart.getSkuId())).orElse(null); - - log.info("下单,开始校验库存预警,购物车id:{}", cashierCart.getId()); - CompletableFuture.runAsync(() -> checkWarnLineAndSendMsg(productSku, product, Integer.valueOf(cashierCart.getShopId()), cashierCart.getNumber())); - // 已经添加的商品,修改数量 - updateStock(cashierCart); - } - - cashierCart.setOrderId(orderId); - cashierCart.setUpdatedAt(System.currentTimeMillis()); - cashierCart.setStatus("pending".equals(orderInfo.getStatus()) ? "refund" : cashierCart.getStatus()); - if (cashierCart.getPlaceNum() == null) { - cashierCart.setPlaceNum(placeNum); - } - - // 先付费模式,结束购物车状态 - if (!shopEatTypeInfoDTO.isDineInAfter() || StrUtil.isBlank(createOrderDTO.getTableId())) { - cashierCart.setStatus("final"); - } - cashierCartMapper.updateById(cashierCart); - } - - // 菜品票 - if (!addOrderDetails.isEmpty() && shopEatTypeInfoDTO.isDineInAfter()) { - rabbitMsgUtils.printDishesTicket(orderInfo.getId(), false, addOrderDetails.toArray(new TbOrderDetail[0])); - } - - if (!removeOrderDetailIds.isEmpty()) { - // 退单票 - orderDetailMapper.deleteBatchIds(removeOrderDetailIds); - if (shopEatTypeInfoDTO.isDineInAfter()) { - rabbitMsgUtils.printDishesTicket(orderInfo.getId(), true, removeOrderDetailList.toArray(new TbOrderDetail[0])); - } - } - - if (isFirst) { - // 后付费,不增加当前台桌取餐号 - if (!shopEatTypeInfoDTO.isIncrMaterId()) { - addGlobalCode(cn.ysk.cashier.utils.DateUtils.getDay(), "pc", String.valueOf(createOrderDTO.getShopId())); - } - - if (shopEatTypeInfoDTO.isIncrMaterId() && "pending".equals(orderInfo.getStatus())) { - String key = RedisConstant.getMasterIdKey(createOrderDTO.getShopId(), cn.ysk.cashier.utils.DateUtils.getDay(), orderInfo.getTableId()); - ; - redisTemplate.delete(key); - } - } + // 修改购物车状态和库存 + updateCartAndStock(cartInfoDTO.getNewCashierCarts(), orderInfo, shopEatTypeInfoDTO); // 推送耗材信息 - pushConsMsg(orderInfo, cashierCarts); + pushConsMsg(orderInfo, cartInfoDTO.getNewCashierCarts()); - if (!shopEatTypeInfoDTO.isTakeout() && StrUtil.isNotBlank(createOrderDTO.getTableId())) { - // 清空台桌信息 - if (shopEatTypeInfoDTO.isDineInBefore()) { - mpShopTableMapper.update(null, new LambdaUpdateWrapper() - .eq(TbShopTable::getShopId, createOrderDTO.getShopId()) - .eq(TbShopTable::getQrcode, createOrderDTO.getTableId()) - .set(TbShopTable::getProductNum, 0) - .set(TbShopTable::getTotalAmount, 0) - .set(TbShopTable::getRealAmount, 0) - .set(TbShopTable::getUseNum, 0) - .set(TbShopTable::getStatus, TableStateEnum.IDLE.getState())); - // 设置台桌信息 - } else { - LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper() - .eq(TbShopTable::getShopId, createOrderDTO.getShopId()) - .eq(TbShopTable::getQrcode, createOrderDTO.getTableId()) - .set(TbShopTable::getProductNum, cashierCarts.size()) - .set(TbShopTable::getTotalAmount, orderInfo.getOrderAmount()) - .set(TbShopTable::getRealAmount, orderInfo.getOrderAmount()) - .set(TbShopTable::getUseNum, seatCart != null ? seatCart.getNumber() : null) - .set(TbShopTable::getStatus, TableStateEnum.USING.getState()); - if (isFirst) { - wrapper.set(TbShopTable::getUseTime, DateUtil.date()); - } - mpShopTableMapper.update(null, wrapper); + updateTableState(shopEatTypeInfoDTO, orderInfo, cartInfoDTO.getCashierCarts(), cartInfoDTO.getSeatCart()); - } - } - - - if (StrUtil.isNotBlank(createOrderDTO.getTableId())) { - String tableCartKey = RedisConstant.getTableCartKey(createOrderDTO.getTableId(), createOrderDTO.getShopId().toString()); - redisTemplate.delete(tableCartKey); - } return orderInfo; }, stringRedisTemplate, RedisConstant.getLockKey(RedisConstant.CREATE_ORDER, createOrderDTO.getShopId(), createOrderDTO.getTableId(), createOrderDTO.getMasterId(), createOrderDTO.getUseType())); } + private TbUserCouponVo getCanUseCoupon(HashMap> couponMap, String productId) { + List tbUserCouponVos = couponMap.get(productId); + if (tbUserCouponVos == null || tbUserCouponVos.isEmpty()) return null; + for (TbUserCouponVo tbUserCouponVo : tbUserCouponVos) { + if (tbUserCouponVo.getCurrentUseNum() > 0) { + return tbUserCouponVo; + } + } + return null; + } + + private BigDecimal reduceProCoupon(HashMap> couponMap, TbCashierCart cashierCart, HashMap> usedCouponMap, BigDecimal discountAmount, ArrayList balanceCartList, + ArrayList outRecords, Integer memberId) { + TbUserCouponVo couponVo = getCanUseCoupon(couponMap, cashierCart.getProductId()); + if (couponVo != null && couponVo.getCurrentUseNum() > 0) { + BigDecimal currentUseNum; + List tbUserCouponVos = usedCouponMap.computeIfAbsent(Integer.valueOf(cashierCart.getProductId()), k -> new ArrayList<>()); + tbUserCouponVos.add(couponVo); + + TbCashierCart balanceCart = null; + if (cashierCart.getNumber() < couponVo.getCurrentUseNum()) { + cashierCart.setUserCouponId(couponVo.getId()); + discountAmount = discountAmount.add(cashierCart.getTotalAmountByNum(null)); + couponVo.setCurrentUseNum(couponVo.getCurrentUseNum() - cashierCart.getNumber()); + currentUseNum = BigDecimal.valueOf(cashierCart.getNumber()); + // 优惠券数量小于购物车数量,分割购物车数据 + }else if (cashierCart.getNumber() > couponVo.getCurrentUseNum()) { + currentUseNum = BigDecimal.valueOf(couponVo.getCurrentUseNum()); + BigDecimal cartNum = BigDecimal.valueOf(cashierCart.getNumber()); + int balanceNum = cashierCart.getTotalNumber() - couponVo.getCurrentUseNum(); + BigDecimal singlePackFee = cashierCart.getPackFee().divide(cartNum, RoundingMode.HALF_UP); + cashierCart.setPackFee(singlePackFee.multiply(currentUseNum)); + BigDecimal totalAmountByNum = cashierCart.getTotalAmountByNum(couponVo.getCurrentUseNum()); + cashierCart.setTotalAmount(totalAmountByNum.add(singlePackFee.multiply(currentUseNum))); + cashierCart.setNumber(couponVo.getCurrentUseNum()); + cashierCart.setTotalNumber(couponVo.getCurrentUseNum()); + cashierCart.setUserCouponId(couponVo.getId()); + discountAmount = discountAmount.add(totalAmountByNum); + couponVo.setCurrentUseNum(couponVo.getCurrentUseNum() - cashierCart.getNumber()); + currentUseNum = BigDecimal.valueOf(cashierCart.getNumber()); + + + + // 创建结余购物车 + balanceCart = BeanUtil.copyProperties(cashierCart, TbCashierCart.class); + BigDecimal num = BigDecimal.valueOf(balanceNum); + balanceCart.setUserCouponId(null); + balanceCart.setId(null); + balanceCart.setNumber(balanceNum); + balanceCart.setTotalNumber(balanceNum); + balanceCart.setPackFee(singlePackFee.multiply(num)); + balanceCart.setTotalAmount(cashierCart.getTotalAmountByNum(balanceNum).add(singlePackFee.multiply(num))); + balanceCartList.add(balanceCart); + } else { + currentUseNum = BigDecimal.valueOf(cashierCart.getNumber()); + discountAmount = discountAmount.add(cashierCart.getTotalAmount()); + cashierCart.setUserCouponId(couponVo.getId()); + couponVo.setCurrentUseNum(couponVo.getCurrentUseNum() - cashierCart.getNumber()); + } + // 消耗并返还商品优惠券 + Integer shopId = Integer.valueOf(cashierCart.getShopId()); + TbActivateOutRecord tbActivateOutRecord = new TbActivateOutRecord(); + tbActivateOutRecord.setShopId(shopId); + tbActivateOutRecord.setGiveId(couponVo.getId()); + tbActivateOutRecord.setVipUserId(memberId); + tbActivateOutRecord.setType(TableConstant.ActivateOutRecord.Type.FULL_REDUCTION.getValue()); + tbActivateOutRecord.setUseNum(currentUseNum.toBigInteger().intValue()); + tbActivateOutRecord.setStatus(TableConstant.ActivateOutRecord.Status.CLOSED.getValue()); + tbActivateOutRecord.setCreateTime(DateUtil.date()); + tbActivateOutRecord.setRefNum(0); + outRecords.add(tbActivateOutRecord); + + couponVo.setFinalDiscountAmount(discountAmount); + // 优惠券未消耗完毕 + if (balanceCart != null && getCanUseCoupon(couponMap, balanceCart.getProductId()) != null) { + discountAmount = reduceProCoupon(couponMap, balanceCart, usedCouponMap, discountAmount, balanceCartList, outRecords, memberId); + } + return discountAmount; + } + return discountAmount; + } + + private BigDecimal calcCartPriceWithCoupon(List newCashierCarts, OrderCouponInfoDTO couponInfoDTO, Integer memberId, TbOrderInfo orderInfo) { + ArrayList balanceCartList = new ArrayList<>(); + BigDecimal discountAmount = BigDecimal.ZERO; + HashMap> couponMap = new HashMap<>(); + couponInfoDTO.getProductCouponMap().values().forEach(item -> { + if (item.getCurrentUseNum() <= 0) { + return; + } + List tbUserCouponVos = couponMap.get(item.getProId().toString()); + if (tbUserCouponVos == null) { + tbUserCouponVos = new ArrayList<>(); + tbUserCouponVos.add(item); + couponMap.put(item.getProId().toString(), tbUserCouponVos); + }else { + tbUserCouponVos.add(item); + } + }); + HashMap> usedCouponMap = new HashMap<>(); + ArrayList outRecords = new ArrayList<>(); + for (TbCashierCart cashierCart : newCashierCarts) { + discountAmount = reduceProCoupon(couponMap, cashierCart, usedCouponMap, discountAmount, balanceCartList, outRecords, memberId); + } + + if (!balanceCartList.isEmpty()) { + newCashierCarts.addAll(balanceCartList); + mpCashierCartService.saveBatch(balanceCartList); + } + // 更新购物车信息 + mpCashierCartService.updateBatchById(newCashierCarts); + + couponInfoDTO.setOutRecordList(outRecords); + couponInfoDTO.setCouponMap(usedCouponMap); + + return discountAmount; + } + + private OrderCouponInfoDTO getCouponInfo(Integer memberId, Integer shopId, List userCouponInfoDTOList, BigDecimal orderAmount, Set productIds) { + OrderCouponInfoDTO infoDTO = new OrderCouponInfoDTO(); + // 查询优惠券信息 + TbShopUser shopUser = null; + if (memberId != null) { + shopUser = tbShopUserMapper.selectById(memberId); + if (shopUser == null) { + throw new BadRequestException("用户不存在"); + } + // 获取当前用户可用的优惠券 + List activateCouponList = shopCouponService.getActivateCoupon(shopUser, orderAmount, shopId, productIds); + // 将优惠券分类为满减和商品 + HashMap fullReductionCoupon = new HashMap<>(); + HashMap productCoupon = new HashMap<>(); + if (activateCouponList.isEmpty()) { + throw new BadRequestException("未查询到相关优惠券"); + } + activateCouponList.forEach(item -> { + if (TableConstant.ActivateOutRecord.Type.FULL_REDUCTION.equalsVals(item.getType())) { + fullReductionCoupon.put(item.getId(), item); + } else { + productCoupon.put(item.getId(), item); + } + }); + + userCouponInfoDTOList.forEach(item -> { + TbUserCouponVo couponVo = fullReductionCoupon.get(item.getUserCouponId()); + if (couponVo != null) { + if (couponVo.getNum() < item.getNum()) { + throw new BadRequestException(couponVo.getName() + "数量不足: " + couponVo.getNum()); + } + couponVo.setCurrentUseNum(item.getNum()); + infoDTO.getFullReductionCouponMap().put(couponVo.getId(), couponVo); + return; + } + couponVo = productCoupon.get(item.getUserCouponId()); + if (couponVo == null) { + throw new BadRequestException("存在不可用优惠券"); + } + couponVo.setCurrentUseNum(item.getNum()); + couponVo.setFinalUseNum(item.getNum()); + infoDTO.getProductCouponMap().put(item.getUserCouponId(), couponVo); + }); + + } + infoDTO.setShopUser(shopUser); + + return infoDTO; + } + + private OrderCartInfoDTO getCartForCreateOrder(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, TbShopUser shopUser, Integer orderId, boolean ignoreEmpty) { + OrderCartInfoDTO cartInfoDTO = new OrderCartInfoDTO(); + List allCashierCarts; + if (orderId != null) { + allCashierCarts = mpCashierCartService.selectByOrderIdAndState(orderId, null); + }else { + allCashierCarts = mpCashierCartService.selectByShopEatType(shopEatTypeInfoDTO, masterId); + } + TbCashierCart seatCart = null; + for (TbCashierCart cashierCart : allCashierCarts) { + if (TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId())) { + seatCart = cashierCart; + cartInfoDTO.setSeatCart(cashierCart); + } + if (OrderStatusEnums.CREATE.getValue().equals(cashierCart.getStatus())) { + cartInfoDTO.getNewCashierCarts().add(cashierCart); + } + cartInfoDTO.getCashierCarts().add(cashierCart); + } + + if (!ignoreEmpty && (StrUtil.isNotBlank(shopEatTypeInfoDTO.getTableId()) + && (cartInfoDTO.getCashierCarts().isEmpty() || + (shopEatTypeInfoDTO.isNeedSeatFee() && !shopEatTypeInfoDTO.isTakeout() && seatCart != null && cartInfoDTO.getCashierCarts().size() < 2) + || (shopEatTypeInfoDTO.isNeedSeatFee() && !shopEatTypeInfoDTO.isTakeout() && seatCart == null)))) { + throw new BadRequestException("购物车为空或未选择餐位费,请先添加商品或选择餐位费"); + } + + if (cartInfoDTO.getCashierCarts().isEmpty()) { + throw new BadRequestException("购物车为空"); + } + + ArrayList cartIdList = new ArrayList<>(); + // 订单总价 + for (TbCashierCart tbCashierCart : cartInfoDTO.getCashierCarts()) { + if (tbCashierCart.getOrderId() != null) { + cartInfoDTO.setOrderId(tbCashierCart.getOrderId()); + } + cartIdList.add(tbCashierCart.getId()); + if (TableConstant.CashierCart.Status.CREATE.equalsVals(tbCashierCart.getStatus())) { + cartInfoDTO.setNewAddTotalAmount(cartInfoDTO.getNewAddTotalAmount().add(tbCashierCart.getTotalAmount())); + } + if (shopUser != null) { + tbCashierCart.setIsMember(shopEatTypeInfoDTO.isMemberPrice() && tbCashierCart.getMemberPrice() == null && shopUser.getIsVip() == 1 ? 0 : 1); + } + tbCashierCart.resetTotalAmount(); + + cartInfoDTO.setTotalAmount(cartInfoDTO.getTotalAmount().add(tbCashierCart.getTotalAmount())); + } + cartInfoDTO.setCashierCartIds(cartIdList); + return cartInfoDTO; + } + + private void consumeCoupon(List outRecordList, Integer memberId, TbOrderInfo orderInfo) { + boolean use = shopCouponService.use(Integer.valueOf(orderInfo.getShopId()), orderInfo.getId(), memberId, outRecordList); + if (!use) { + throw new BadRequestException("消耗券失败"); + } + } + + private void returnCoupon(TbOrderInfo orderInfo) { + // 返还优惠券 + if (StrUtil.isNotBlank(orderInfo.getCouponInfoList())) { + OrderCouponInfoDTO couponInfoDTO = JSONObject.parseObject(orderInfo.getCouponInfoList(), OrderCouponInfoDTO.class); + // 券返还 + if (!couponInfoDTO.getOutRecordList().isEmpty()) { + couponInfoDTO.getOutRecordList().forEach(item -> { + item.setRefNum(item.getUseNum()); + }); + shopCouponService.refund(couponInfoDTO.getOutRecordList()); + couponInfoDTO.setOutRecordList(new ArrayList<>()); + orderInfo.setCouponInfoList(JSONObject.toJSONString(couponInfoDTO)); + } + } + + } + + /** + * 根据商品优惠券 + * + * @param fullCashierCarts + * @param orderInfo + * @param shopId + * @param updateState + * @return + */ + private OrderPriceDTO createOrderDetailWithCoupon(List fullCashierCarts, TbOrderInfo orderInfo, Integer shopId, boolean updateState, ShopEatTypeInfoDTO shopEatTypeInfoDTO) { + OrderPriceDTO priceDTO = new OrderPriceDTO(); + + List cartIds = fullCashierCarts.stream().map(TbCashierCart::getId).collect(Collectors.toList()); + // 查询历史orderDetail + List oldOrderDetailList = mpOrderDetailService + .selectByCartIdOrOrderId(shopId, cartIds, orderInfo == null ? -1 : orderInfo.getId()); + HashMap oldOrderDetailMap = new HashMap<>(); + oldOrderDetailList.forEach(item -> { + if (cartIds.contains(item.getCartId())) { + oldOrderDetailMap.put(item.getOrderId().toString() + item.getCartId(), item); + } else { + priceDTO.getRemoveOrderDetailIds().add(item.getId()); + priceDTO.getRemoveOrderDetailList().add(item); + } + }); + + for (TbCashierCart cashierCart : fullCashierCarts) { + if (orderInfo != null && shopEatTypeInfoDTO != null) { + cashierCart.setIsMember(StrUtil.isBlank(orderInfo.getMemberId()) ? 0 : shopEatTypeInfoDTO.isMemberPrice() ? 1 : 0); + } + cashierCart.resetTotalAmount(); + + // 已经退款和使用优惠券的商品不进行统计金额 + if (!"return".equals(cashierCart.getStatus()) && cashierCart.getUserCouponId() == null) { + priceDTO.setTotalAmount(priceDTO.getTotalAmount().add(cashierCart.getTotalAmount())); + priceDTO.setPackAmount(priceDTO.getPackAmount().add(cashierCart.getPackFee())); + } + + if(!"return".equals(cashierCart.getStatus())) { + priceDTO.setOriginAmount(priceDTO.getOriginAmount().add(cashierCart.getTotalAmount())); + } + + TbProductSku productSku = productSkuRepository.findById(Integer.valueOf(cashierCart.getSkuId())).orElse(null); + TbOrderDetail orderDetail = null; + if (cashierCart.getOrderId() != null) { + orderDetail = oldOrderDetailMap.get(cashierCart.getOrderId().toString() + cashierCart.getId()); + } + + if (orderDetail == null) { + orderDetail = new TbOrderDetail(); + priceDTO.setHasNewInfo(true); + priceDTO.getNewOrderDetailList().add(orderDetail); + } + + if (Objects.nonNull(productSku)) { + orderDetail.setProductSkuName(productSku.getSpecSnap()); + } + + orderDetail.setUserCouponId(cashierCart.getUserCouponId()); + orderDetail.setMemberPrice(cashierCart.getMemberPrice()); + orderDetail.setNote(cashierCart.getNote()); + orderDetail.setCreateTime(DateUtil.date().toTimestamp()); + orderDetail.setNum(cashierCart.getNumber()); + orderDetail.setPrice(cashierCart.getSalePrice()); + orderDetail.setPriceAmount(cashierCart.getTotalAmount()); + orderDetail.setProductId(Integer.valueOf(cashierCart.getProductId())); + orderDetail.setProductSkuId(Integer.valueOf(cashierCart.getSkuId())); + orderDetail.setProductName(cashierCart.getName()); + orderDetail.setShopId(Integer.valueOf(cashierCart.getShopId())); + orderDetail.setPackAmount(cashierCart.getPackFee()); + if (updateState) { + orderDetail.setStatus(TableConstant.CashierCart.Status.RETURN.equalsVals(cashierCart.getStatus()) ? cashierCart.getStatus() : "unpaid"); + } + orderDetail.setUseType(cashierCart.getUseType()); + orderDetail.setProductImg(cashierCart.getCoverImg()); + orderDetail.setCartId(cashierCart.getId()); + orderDetail.setOrderId(orderInfo == null ? null : orderInfo.getId()); + priceDTO.getOrderDetailList().add(orderDetail); + } + return priceDTO; + } + + private TbOrderInfo createOrderWithAction(CreateOrderDTO createOrderDTO, OrderPriceDTO priceDTO, ShopEatTypeInfoDTO eatTypeInfoDTO, + TbOrderInfo orderInfo, TbCashierCart seatCart, TbShopUser shopUser, TbShopTable shopTable) { + int placeNum = getCurrentPlaceNum(eatTypeInfoDTO); + boolean isFirst = false; + // 修改订单信息 + if (orderInfo == null) { + isFirst = true; + String orderNo = generateOrderNumber(null); + orderInfo = new TbOrderInfo(); + orderInfo.setOrderNo(orderNo); + orderInfo.setCreatedAt(DateUtil.current()); + orderInfo.setTradeDay(cn.ysk.cashier.utils.DateUtils.getDay()); + orderInfo.setRefundAble(1); + orderInfo.setOrderType("cash"); + orderInfo.setShopId(createOrderDTO.getShopId().toString()); + orderInfo.setTableId(createOrderDTO.getTableId()); + orderInfo.setTableName(shopTable != null ? shopTable.getName() : null); + orderInfo.setMasterId(createOrderDTO.getMasterId()); + TbMerchantAccount merchantAccount = merchantAccountMapper.selectOne(new LambdaQueryWrapper() + .eq(TbMerchantAccount::getShopId, createOrderDTO.getShopId()) + .eq(TbMerchantAccount::getStatus, 1)); + if (merchantAccount == null) { + throw new BadRequestException("商户信息不存在"); + } + orderInfo.setMerchantId(merchantAccount.getId().toString()); + orderInfo.setIsPostpaid(eatTypeInfoDTO.isDineInAfter() ? 1 : 0); + } + // 更新取餐号 + orderInfo.setOutNumber(updateOutNumber(String.valueOf(createOrderDTO.getShopId())).toString()); + orderInfo.setUpdatedAt(System.currentTimeMillis()); + orderInfo.setSettlementAmount(priceDTO.getTotalAmount()); + orderInfo.setAmount(priceDTO.getTotalAmount()); + orderInfo.setOriginAmount(priceDTO.getOriginAmount()); + orderInfo.setOrderAmount(priceDTO.getTotalAmount()); + orderInfo.setRemark(createOrderDTO.getNote()); + orderInfo.setFreightAmount(BigDecimal.ZERO); + orderInfo.setProductAmount(BigDecimal.ZERO); + orderInfo.setTradeDay(DateUtils.getDay()); + orderInfo.setUseType(eatTypeInfoDTO.getUseType()); + if (seatCart != null) { + orderInfo.setSeatAmount(seatCart.getTotalAmount()); + orderInfo.setSeatCount(seatCart.getNumber()); + } + if (createOrderDTO.getVipUserId() != null) { + orderInfo.setMemberId(String.valueOf(shopUser.getId())); + orderInfo.setUserId(shopUser.getUserId()); + } + orderInfo.setSendType(eatTypeInfoDTO.getSendType()); + // 存在新添加的商品,增加下单次数 + if (priceDTO.isHasNewInfo()) { + orderInfo.setPlaceNum(placeNum); + } + orderInfoMapper.insertOrUpdate(orderInfo); + + if (isFirst) { + // 后付费,不增加当前台桌取餐号 + if (!eatTypeInfoDTO.isIncrMaterId()) { + addGlobalCode(cn.ysk.cashier.utils.DateUtils.getDay(), "pc", String.valueOf(createOrderDTO.getShopId())); + } + + if (eatTypeInfoDTO.isIncrMaterId() || "pending".equals(orderInfo.getStatus())) { + String key = RedisConstant.getMasterIdKey(createOrderDTO.getShopId(), cn.ysk.cashier.utils.DateUtils.getDay(), orderInfo.getTableId()); + redisTemplate.delete(key); + } + } + + return orderInfo; + } + + private void updateDetailAndPrint(TbOrderInfo orderInfo, OrderPriceDTO priceDTO, ShopEatTypeInfoDTO shopEatTypeInfoDTO) { + // 添加订单详细数据 + Integer orderId = orderInfo.getId(); + for (TbOrderDetail orderDetail : priceDTO.getOrderDetailList()) { + orderDetail.setOrderId(orderId); + if (orderDetail.getPlaceNum() == null) { + orderDetail.setPlaceNum(orderInfo.getPlaceNum()); + } + } + // 删除已经移除购物车的订单 修改并保存数据 + if (!priceDTO.getOrderDetailList().isEmpty()) { + mpOrderDetailService.saveOrUpdateBatch(priceDTO.getOrderDetailList()); + } + + // 菜品票 + if (!priceDTO.getNewOrderDetailList().isEmpty() && shopEatTypeInfoDTO.isDineInAfter()) { + rabbitMsgUtils.printDishesTicket(orderInfo.getId(), false, priceDTO.getNewOrderDetailList().toArray(new TbOrderDetail[0])); + } + + if (!priceDTO.getRemoveOrderDetailIds().isEmpty()) { + // 退单票 + orderDetailMapper.deleteBatchIds(priceDTO.getRemoveOrderDetailIds()); + if (shopEatTypeInfoDTO.isDineInAfter()) { + rabbitMsgUtils.printDishesTicket(orderInfo.getId(), true, priceDTO.getRemoveOrderDetailList().toArray(new TbOrderDetail[0])); + } + } + } + + private void updateCartAndStock(List newAddCashierCarts, TbOrderInfo orderInfo, ShopEatTypeInfoDTO shopEatTypeInfoDTO) { + // 更新购物车记录的orderId + for (TbCashierCart cashierCart : newAddCashierCarts) { + if (!"-999".equals(cashierCart.getProductId())) { + TbProduct product = productMapper.selectById(cashierCart.getProductId()); + TbProductSku productSku = productSkuRepository.findById(Integer.valueOf(cashierCart.getSkuId())).orElse(null); + + log.info("下单,开始校验库存预警,购物车id:{}", cashierCart.getId()); + CompletableFuture.runAsync(() -> checkWarnLineAndSendMsg(productSku, product, Integer.valueOf(cashierCart.getShopId()), cashierCart.getNumber())); + // 已经添加的商品,修改数量 + updateStock(cashierCart); + } + + cashierCart.setOrderId(orderInfo.getId()); + cashierCart.setUpdatedAt(System.currentTimeMillis()); + cashierCart.setStatus("pending".equals(orderInfo.getStatus()) ? "refund" : cashierCart.getStatus()); + if (cashierCart.getPlaceNum() == null) { + cashierCart.setPlaceNum(orderInfo.getPlaceNum()); + } + + // 先付费模式,结束购物车状态 + if (!shopEatTypeInfoDTO.isDineInAfter() || StrUtil.isBlank(shopEatTypeInfoDTO.getTableId())) { + cashierCart.setStatus("final"); + } + cashierCartMapper.updateById(cashierCart); + } + } + + + private void updateTableState(ShopEatTypeInfoDTO shopEatTypeInfoDTO, TbOrderInfo orderInfo, List fullCashierCarts, TbCashierCart seatCart) { + if (!shopEatTypeInfoDTO.isTakeout() && StrUtil.isNotBlank(shopEatTypeInfoDTO.getTableId())) { + // 清空台桌信息 + if (shopEatTypeInfoDTO.isDineInBefore()) { + mpShopTableMapper.update(null, new LambdaUpdateWrapper() + .eq(TbShopTable::getShopId, shopEatTypeInfoDTO.getShopId()) + .eq(TbShopTable::getQrcode, shopEatTypeInfoDTO.getTableId()) + .set(TbShopTable::getProductNum, 0) + .set(TbShopTable::getTotalAmount, 0) + .set(TbShopTable::getRealAmount, 0) + .set(TbShopTable::getUseNum, 0) + .set(TbShopTable::getStatus, TableStateEnum.IDLE.getState())); + // 设置台桌信息 + } else { + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper() + .eq(TbShopTable::getShopId, shopEatTypeInfoDTO.getShopId()) + .eq(TbShopTable::getQrcode, shopEatTypeInfoDTO.getTableId()) + .set(TbShopTable::getProductNum, fullCashierCarts.size()) + .set(TbShopTable::getTotalAmount, orderInfo.getOrderAmount()) + .set(TbShopTable::getRealAmount, orderInfo.getOrderAmount()) + .set(TbShopTable::getUseNum, seatCart != null ? seatCart.getNumber() : null) + .set(TbShopTable::getStatus, TableStateEnum.USING.getState()); + if (orderInfo.getPlaceNum() == 1) { + wrapper.set(TbShopTable::getUseTime, DateUtil.date()); + } + mpShopTableMapper.update(null, wrapper); + + } + } + + if (StrUtil.isNotBlank(shopEatTypeInfoDTO.getTableId())) { + String tableCartKey = RedisConstant.getTableCartKey(shopEatTypeInfoDTO.getTableId(), shopEatTypeInfoDTO.getShopId().toString()); + redisTemplate.delete(tableCartKey); + } + } + + private TbShopTable checkTableState(CreateOrderDTO createOrderDTO) { + + // 非堂食校验台桌状态 + TbShopTable tbShopTable = null; + if (StrUtil.isNotBlank(createOrderDTO.getTableId())) { + tbShopTable = mpShopTableMapper.selectOne(new LambdaQueryWrapper() + .eq(TbShopTable::getQrcode, createOrderDTO.getTableId()) + .in(TbShopTable::getStatus, "idle", "using")); + if (tbShopTable == null) { + throw new BadRequestException("台桌未开台或不存在"); + } + } + return tbShopTable; + } + + private void calculateOrderCouponAndPoints(TbOrderInfo orderInfo, List mineUserCouponList, Integer pointsNum) { + BigDecimal shouldPayAmount = BigDecimal.ZERO; + if (pointsNum != null) { + Long memberId = Long.valueOf(orderInfo.getMemberId()); + OrderDeductionPointsDTO memberUsablePoints = memberPointsService.getMemberUsablePoints(memberId, orderInfo.getOrderAmount()); + if (!memberUsablePoints.getUsable()) { + throw new BadRequestException(memberUsablePoints.getUnusableReason()); + } + if (pointsNum < memberUsablePoints.getMinDeductionPoints() || pointsNum > memberUsablePoints.getMaxUsablePoints()) { + throw new BadRequestException("可抵扣积分区间为: [" + memberUsablePoints.getMinDeductionPoints() + "-" + memberUsablePoints.getMaxUsablePoints() + "]"); + } + + BigDecimal discountAmount = memberPointsService.calcDeductionAmount(memberId, orderInfo.getOrderAmount(), pointsNum); + orderInfo.setPointsNum(pointsNum); + orderInfo.setPointsDiscountAmount(discountAmount); + shouldPayAmount = shouldPayAmount.subtract(discountAmount); + memberPointsService.deductPoints(memberId, pointsNum, "霸王餐充值抵扣", Long.valueOf(orderInfo.getId())); + } + + if (!mineUserCouponList.isEmpty()) { + CouponDto couponDto = new CouponDto(); + couponDto.setShopId(Integer.valueOf(orderInfo.getShopId())); + couponDto.setUserId(Integer.valueOf(orderInfo.getUserId())); + couponDto.setStatus(1); + couponDto.setOrderId(orderInfo.getId()); + List userCouponList = (List) shopCouponService.find(couponDto).getBody(); + if (userCouponList == null || userCouponList.isEmpty()) { + throw new BadRequestException("存在不可用优惠券"); + } + + ArrayList activateInInfoVOS = new ArrayList<>(); + for (Integer userCouponId : mineUserCouponList) { + TbUserCouponVo userCouponVo = userCouponList.stream().filter(item -> item.getId().equals(userCouponId)).findFirst().orElse(null); + if (userCouponVo == null) { + throw new BadRequestException("存在不可用优惠券"); + } + + shouldPayAmount = shouldPayAmount.subtract(userCouponVo.getDiscountAmount()); + ActivateInInfoVO activateInInfoVO = new ActivateInInfoVO() + .setId(userCouponVo.getId()) + .setCouponId(userCouponVo.getCouponId()) + .setType(userCouponVo.getType()) + .setNum(1); + activateInInfoVOS.add(activateInInfoVO); + } + + List tbShopCoupons = shopCouponService.listByIds(activateInInfoVOS.stream().map(ActivateInInfoVO::getCouponId).collect(Collectors.toList())); + if (tbShopCoupons.size() != mineUserCouponList.size()) { + throw new BadRequestException("存在不可用优惠券"); + } + + // 设置优惠券信息 + orderInfo.setCouponInfoList(JSONObject.toJSONString(activateInInfoVOS)); + orderInfo.setUserCouponAmount(tbShopCoupons.stream().map(TbShopCoupon::getDiscountAmount).reduce(BigDecimal.ZERO, BigDecimal::add)); +// record.setCouponInfo(JSONObject.toJSONString(userCouponList)); + } + } + @Override public Object pending(PendingDTO pendingDTO) { @@ -1484,7 +1813,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { createOrderDTO.setMasterId(pendingDTO.getMasterId()); createOrderDTO.setNote(pendingDTO.getNote()); createOrderDTO.setUseType(pendingDTO.getUseType()); - orderId = createOrder(createOrderDTO, true, false).getId(); + orderId = createOrder(createOrderDTO, false).getId(); } @@ -1571,7 +1900,155 @@ public class TbShopTableServiceImpl implements TbShopTableService { return payTypeRepository.findByShopId(String.valueOf(shopId)); } + private TbActivateOutRecord calcOrderInfoDiscount(PayDTO payDTO, TbOrderInfo orderInfo, OrderCouponInfoDTO couponInfo) { + if (payDTO.getVipUserId() != null) { + BigDecimal finalAmount = orderInfo.getOrderAmount(); + TbActivateOutRecord tbActivateOutRecord = null; + if (!couponInfo.getFullReductionCouponMap().isEmpty()) { + TbUserCouponVo couponVo = couponInfo.getFullReductionCouponMap().values().stream().findFirst().orElse(null); + finalAmount = finalAmount.subtract(couponVo.getDiscountAmount()); + orderInfo.setFullCouponDiscountAmount(couponVo.getDiscountAmount()); + + tbActivateOutRecord = new TbActivateOutRecord(); + tbActivateOutRecord.setShopId(Integer.valueOf(orderInfo.getShopId())); + tbActivateOutRecord.setGiveId(couponVo.getId()); + tbActivateOutRecord.setVipUserId(payDTO.getVipUserId()); + tbActivateOutRecord.setType(TableConstant.ActivateOutRecord.Type.FULL_REDUCTION.getValue()); + tbActivateOutRecord.setUseNum(couponVo.getCurrentUseNum()); + tbActivateOutRecord.setStatus(TableConstant.ActivateOutRecord.Status.CLOSED.getValue()); + tbActivateOutRecord.setCreateTime(DateUtil.date()); + tbActivateOutRecord.setRefNum(0); + + couponVo.setFinalDiscountAmount(couponVo.getDiscountAmount()); + + } + + // 计算积分优惠 + if (payDTO.getPointsNum() != null && payDTO.getPointsNum() != 0) { + BigDecimal discountPointsAmount = calcPointsDiscountAndReturn(orderInfo, payDTO.getPointsNum()); + finalAmount = finalAmount.subtract(discountPointsAmount); + orderInfo.setPointsDiscountAmount(discountPointsAmount); + } + + if (finalAmount.compareTo(BigDecimal.ZERO) < 0) { + finalAmount = BigDecimal.ZERO; + orderInfo.setFullCouponDiscountAmount(orderInfo.getOrderAmount()); + } + + orderInfo.setSettlementAmount(finalAmount); + orderInfo.setOrderAmount(finalAmount); + orderInfo.setAmount(finalAmount); + + return tbActivateOutRecord; + } + + return null; + + } + + private BigDecimal calcPointsDiscountAndReturn(TbOrderInfo orderInfo, int pointsNum) { + Long memberId = Long.valueOf(orderInfo.getMemberId()); + + if (orderInfo.getPointsNum() != null && orderInfo.getPointsNum() != 0) { + memberPointsService.addPoints(memberId, orderInfo.getPointsNum(), "用户未支付订单积分返还: " + orderInfo.getPointsNum() + "积分", Long.valueOf(orderInfo.getId())); + } + + OrderDeductionPointsDTO memberUsablePoints = memberPointsService.getMemberUsablePoints(memberId, orderInfo.getOrderAmount()); + if (!memberUsablePoints.getUsable()) { + throw new BadRequestException(memberUsablePoints.getUnusableReason()); + } + if (pointsNum < memberUsablePoints.getMinDeductionPoints() || pointsNum > memberUsablePoints.getMaxUsablePoints()) { + throw new BadRequestException("可抵扣积分区间为: [" + memberUsablePoints.getMinDeductionPoints() + "-" + memberUsablePoints.getMaxUsablePoints() + "]"); + } + + BigDecimal discountAmount = memberPointsService.calcDeductionAmount(memberId, orderInfo.getOrderAmount(), pointsNum); + orderInfo.setPointsNum(pointsNum); + orderInfo.setPointsDiscountAmount(discountAmount); + memberPointsService.deductPoints(memberId, pointsNum, "订单积分抵扣" + discountAmount + "元", Long.valueOf(orderInfo.getId())); + return discountAmount; + } + + private BigDecimal getCartCouponDiscount(TbOrderInfo orderInfo, PayDTO payDTO) { + Set productIdSet = new HashSet<>(); + List cashierCarts = mpCashierCartService.selectByOrderIdAndState(orderInfo.getId(), null); + ArrayList activateCartInfo = new ArrayList<>(); + for (TbCashierCart cashierCart : cashierCarts) { + productIdSet.add(cashierCart.getProductId()); + if (TableConstant.OrderInfo.Status.CREATE.equalsVals(cashierCart.getStatus()) || TableConstant.OrderInfo.Status.FINAL.equalsVals(cashierCart.getStatus())) { + activateCartInfo.add(cashierCart); + } + } + + // 获取优惠券信息 + OrderCouponInfoDTO couponInfo = new OrderCouponInfoDTO(); + if (!payDTO.getUserCouponInfos().isEmpty()) { + couponInfo = getCouponInfo(payDTO.getVipUserId(), payDTO.getShopId(), payDTO.getUserCouponInfos(), + orderInfo.getOrderAmount(), productIdSet); + } + + BigDecimal productDiscount = calcCartPriceWithCoupon(activateCartInfo, couponInfo, payDTO.getVipUserId(), orderInfo); + orderInfo.setProductCouponDiscountAmount(productDiscount); + return productDiscount; + } + + private BigDecimal calcDiscountAndUpdateInfo(PayDTO payDTO, TbOrderInfo orderInfo) { + // 返还上次使用的券 + returnCoupon(orderInfo); + + Set productIdSet = new HashSet<>(); + List cashierCarts = mpCashierCartService.selectByOrderIdAndState(orderInfo.getId()); + ArrayList activateCartInfo = new ArrayList<>(); + for (TbCashierCart cashierCart : cashierCarts) { + productIdSet.add(cashierCart.getProductId()); + if (TableConstant.OrderInfo.Status.CREATE.equalsVals(cashierCart.getStatus()) || TableConstant.OrderInfo.Status.FINAL.equalsVals(cashierCart.getStatus())) { + activateCartInfo.add(cashierCart); + } + } + + // 获取优惠券信息 + OrderCouponInfoDTO couponInfo = new OrderCouponInfoDTO(); + if (!payDTO.getUserCouponInfos().isEmpty()) { + couponInfo = getCouponInfo(payDTO.getVipUserId(), payDTO.getShopId(), payDTO.getUserCouponInfos(), + orderInfo.getOrderAmount(), productIdSet); + } + + BigDecimal productDiscount = calcCartPriceWithCoupon(activateCartInfo, couponInfo, payDTO.getVipUserId(), orderInfo); + orderInfo.setProductCouponDiscountAmount(productDiscount); + + // 更新订单信息 + + OrderPriceDTO priceDTO = createOrderDetailWithCoupon(activateCartInfo, orderInfo, payDTO.getShopId(), false, null); + BigDecimal finalAmount = priceDTO.getTotalAmount().multiply(BigDecimal.valueOf(payDTO.getDiscount())).setScale(2, RoundingMode.HALF_UP); + + orderInfo.setUpdatedAt(System.currentTimeMillis()); + orderInfo.setSettlementAmount(finalAmount); + orderInfo.setAmount(finalAmount); + orderInfo.setOrderAmount(finalAmount); + + // 计算订单优惠 + TbActivateOutRecord outRecord = calcOrderInfoDiscount(payDTO, orderInfo, couponInfo); + if (outRecord != null) { + couponInfo.getOutRecordList().add(outRecord); + } + + // 消耗优惠券并返回上次未使用的券 + consumeCoupon(couponInfo.getOutRecordList(), payDTO.getVipUserId(), orderInfo); + + couponInfo.setProductCouponMap(BeanUtil.copyProperties(couponInfo.getProductCouponMap(), HashMap.class)); + HashMap map = new HashMap<>(); + map.put("outRecordList", couponInfo.getOutRecordList()); + map.put("fullReductionCoupon", couponInfo.getFullReductionCouponMap().values()); + map.put("productCoupon", couponInfo.getProductCouponMap().values()); + orderInfo.setCouponInfoList(JSONObject.toJSONString(map)); +// orderInfo.setCouponInfoList(JSONObject.toJSONString(couponInfo)); + + // 修改订单detail + mpOrderDetailService.saveOrUpdateBatch(priceDTO.getOrderDetailList()); + return orderInfo.getOrderAmount(); + } + @Override +// @Transactional public Object pay(PayDTO payDTO) { return Utils.runFunAndCheckKey(() -> { long count = tbShopPayTypeMapper.selectCount(new LambdaQueryWrapper() @@ -1582,9 +2059,15 @@ public class TbShopTableServiceImpl implements TbShopTableService { throw new BadRequestException("未知支付方式"); } - TbOrderInfo orderInfo = orderInfoMapper.selectById(payDTO.getOrderId()); + // 计算优惠券价格信息 + if (payDTO.getVipUserId() == null) { + payDTO.setVipUserId(orderInfo.getMemberId() != null ? Integer.valueOf(orderInfo.getMemberId()) : null); + } + + + if (ObjectUtil.isEmpty(orderInfo)) { throw new BadRequestException("订单不存在"); } @@ -1598,7 +2081,16 @@ public class TbShopTableServiceImpl implements TbShopTableService { payDTO.setDiscount((double) 1); } - BigDecimal finalAmount = orderInfo.getOrderAmount().multiply(BigDecimal.valueOf(payDTO.getDiscount())).setScale(2, RoundingMode.HALF_UP); + // 计算优惠券积分折扣信息 + BigDecimal finalAmount = null; + if (payDTO.getVipUserId() != null) { + // 计算商品券折扣 + finalAmount = calcDiscountAndUpdateInfo(payDTO, orderInfo); + } + + if (finalAmount == null) { + finalAmount = orderInfo.getOrderAmount().multiply(BigDecimal.valueOf(payDTO.getDiscount())).setScale(2, RoundingMode.HALF_UP); + } boolean isOnline = false; @@ -1607,7 +2099,9 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (payDTO.getVipUserId() != null) { orderInfo.setUserId(String.valueOf(payDTO.getVipUserId())); } - tbPayServiceImpl.vipPay(finalAmount, Integer.valueOf(orderInfo.getUserId())); + TbShopUser shopUser = tbPayServiceImpl.vipPay(finalAmount, payDTO.getVipUserId()); + orderInfo.setMemberId(String.valueOf(shopUser.getId())); + orderInfo.setUserId(shopUser.getUserId()); orderInfo.setPayOrderNo("vipPay".concat(SnowFlakeUtil.generateOrderNo())); orderInfo.setPayType("deposit"); break; @@ -1661,6 +2155,9 @@ public class TbShopTableServiceImpl implements TbShopTableService { JSONObject jsonObject = new JSONObject(); jsonObject.put("token", payDTO.getToken()); + jsonObject.put("shopId", payDTO.getShopId()); + jsonObject.put("staffId", payDTO.getStaffId()); + jsonObject.put("loginName", payDTO.getLoginName()); jsonObject.put("type", "create"); jsonObject.put("orderId", orderInfo.getId()); rabbitMsgUtils.sendOrderCollectMsg(jsonObject, 3); @@ -1714,7 +2211,6 @@ public class TbShopTableServiceImpl implements TbShopTableService { return "success"; }, stringRedisTemplate, RedisConstant.getLockKey("", payDTO.getShopId(), payDTO.getOrderId())); - } @Override @@ -1734,35 +2230,58 @@ public class TbShopTableServiceImpl implements TbShopTableService { } @Override + @Transactional public Object updateVip(UpdateVipDTO updateVipDTO) { - ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(updateVipDTO.getShopId(), updateVipDTO.getTableId()); - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() - .in(TbCashierCart::getStatus, "create", "return") - .eq(TbCashierCart::getShopId, updateVipDTO.getShopId()) - .eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType()) - .and(q -> q.eq(TbCashierCart::getMasterId, updateVipDTO.getMasterId()).or().isNull(TbCashierCart::getMasterId)); - - if (!shopEatTypeInfoDTO.isTakeout()) { - queryWrapper.eq(TbCashierCart::getTableId, updateVipDTO.getTableId()); - } else { - queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, "")) - .in(TbCashierCart::getPlatformType, OrderPlatformTypeEnum.PC.getValue(), OrderPlatformTypeEnum.CASH.getValue()); - } - - List tbCashierCarts = cashierCartMapper.selectList(queryWrapper.isNotNull(TbCashierCart::getOrderId)); - if (!tbCashierCarts.isEmpty()) { - Integer orderId = tbCashierCarts.get(0).getOrderId(); - if (updateVipDTO.getType() == 0) { - return orderInfoMapper.update(null, new LambdaUpdateWrapper() - .eq(TbOrderInfo::getId, orderId) - .set(TbOrderInfo::getUserId, updateVipDTO.getVipUserId())); - } else { - return orderInfoMapper.update(null, new LambdaUpdateWrapper() - .eq(TbOrderInfo::getId, orderId) - .set(TbOrderInfo::getUserId, null)); + Integer orderId = updateVipDTO.getOrderId(); + if (orderId == null) { + ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(updateVipDTO.getShopId(), updateVipDTO.getTableId()); + List tbCashierCarts = mpCashierCartService.selectByShopEatType(shopEatTypeInfoDTO, updateVipDTO.getMasterId()); + for (TbCashierCart item : tbCashierCarts) { + if (item.getOrderId() != null) { + orderId = item.getOrderId(); + } } } - return true; + + CreateOrderDTO dto = null; + if (orderId != null) { + TbOrderInfo orderInfo = mpOrderInfoService.getById(orderId); + if(!TableConstant.OrderInfo.Status.UNPAID.equalsVals(orderInfo.getStatus())) { + throw new BadRequestException("订单状态异常"); + } + dto = new CreateOrderDTO(); + dto.setTableId(orderInfo.getTableId()); + dto.setOrderId(orderInfo.getId()); + dto.setShopId(Integer.valueOf(orderInfo.getShopId())); + dto.setMasterId(orderInfo.getMasterId()); + dto.setUseType(orderInfo.getUseType()); + } + + + if (updateVipDTO.getType() == 0) { + TbShopUser shopUser = tbShopUserMapper.selectById(updateVipDTO.getVipUserId()); + if (shopUser == null) { + throw new BadRequestException("用户信息不存在"); + } + + orderInfoMapper.update(null, new LambdaUpdateWrapper() + .eq(TbOrderInfo::getId, orderId) + .set(TbOrderInfo::getUserId, shopUser.getUserId()) + .set(TbOrderInfo::getMemberId, updateVipDTO.getVipUserId())); + + } else { + mpCashierCartService.updateMemberAndAmountByOrderId(orderId, false); + orderInfoMapper.update(null, new LambdaUpdateWrapper() + .eq(TbOrderInfo::getId, orderId) + .set(TbOrderInfo::getUserId, null) + .set(TbOrderInfo::getMemberId, null)); + } + + if (dto != null) { + return createOrder(dto, true); + } + return "哈哈哈"; + } @@ -1863,6 +2382,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { tbCashierCart.setTableId(choseCountDTO.getTableId()); tbCashierCart.setName("客座费"); tbCashierCart.setSalePrice(shopInfo.getTableFee()); + tbCashierCart.setMemberPrice(shopInfo.getTableFee()); tbCashierCart.setMasterId(choseCountDTO.getMasterId()); tbCashierCart.setShopId(String.valueOf(choseCountDTO.getShopId())); tbCashierCart.setTradeDay(DateUtils.getDay()); @@ -1877,6 +2397,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { tbCashierCart.setUseType(choseCountDTO.getUseType()); tbCashierCartMapper.insert(tbCashierCart); } else { + tbCashierCart.setMemberPrice(shopInfo.getTableFee()); + tbCashierCart.setStatus(TableConstant.CashierCart.Status.CREATE.getValue()); tbCashierCart.setTotalAmount(new BigDecimal(choseCountDTO.getNum()).multiply(shopInfo.getTableFee())); tbCashierCart.setNumber(choseCountDTO.getNum()); tbCashierCart.setTotalNumber(choseCountDTO.getNum()); @@ -1998,11 +2520,14 @@ public class TbShopTableServiceImpl implements TbShopTableService { cashierCarts.forEach(item -> { TbProduct product = productMap.get(item.getProductId()); // 设置打包费 - item.setPackFee(product.getPackFee() != null ? - product.getPackFee().multiply(BigDecimal.valueOf(item.getNumber())) : BigDecimal.ZERO); - item.setTableId(""); - item.setUseType(OrderUseTypeEnum.TAKEOUT.getValue()); - item.setIsPack("true"); + mpCashierCartService.update(new LambdaUpdateWrapper() + .eq(TbCashierCart::getId, item.getId()) + .set(TbCashierCart::getPackFee, product.getPackFee() != null ? + product.getPackFee().multiply(BigDecimal.valueOf(item.getNumber())) : BigDecimal.ZERO) + .set(TbCashierCart::getTableId, null) + .set(TbCashierCart::getUseType, OrderUseTypeEnum.TAKEOUT.getValue()) + .set(TbCashierCart::getIsPack, "true")); + }); List detailList = orderDetailMapper.selectList(new LambdaQueryWrapper() @@ -2019,19 +2544,18 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (!detailList.isEmpty()) { mpOrderDetailService.updateBatchById(detailList); } - - return mpCashierCartService.updateBatchById(cashierCarts); + return true; } else { cashierCartMapper.update(null, new LambdaUpdateWrapper() .in(TbCashierCart::getId, choseModelDTO.getCartIds()) .eq(TbCashierCart::getShopId, choseModelDTO.getShopId()) .set(TbCashierCart::getTableId, choseModelDTO.getTableId()) - .set(TbCashierCart::getUseType, choseModelDTO.getUseType()) + .set(TbCashierCart::getUseType, StrUtil.isNotBlank(choseModelDTO.getTableId()) ? choseModelDTO.getUseType() : TableConstant.OrderInfo.UseType.NONE_TABLE.getValue()) .set(TbCashierCart::getIsPack, "false") .set(TbCashierCart::getPackFee, BigDecimal.ZERO)); return orderDetailMapper.update(null, new LambdaUpdateWrapper() .in(TbOrderDetail::getCartId, choseModelDTO.getCartIds()) - .set(TbOrderDetail::getUseType, choseModelDTO.getUseType()) + .set(TbOrderDetail::getUseType, StrUtil.isNotBlank(choseModelDTO.getTableId()) ? choseModelDTO.getUseType() : TableConstant.OrderInfo.UseType.NONE_TABLE.getValue()) .set(TbOrderDetail::getPackAmount, BigDecimal.ZERO)); } @@ -2058,6 +2582,9 @@ public class TbShopTableServiceImpl implements TbShopTableService { BigDecimal saleAmount = BigDecimal.ZERO; ArrayList remainOrderDetailList = new ArrayList<>(); for (TbOrderDetail orderDetail : detailList) { + if (orderDetail.getUserCouponId() != null) { + throw new BadRequestException("选择了优惠券抵扣商品,无法退款"); + } Integer returnNum = returnNumMap.get(orderDetail.getId().toString()); int remainNum = orderDetail.getNum() - returnNum; if (remainNum < 0) { @@ -2093,7 +2620,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { .add(returnPackFee)); orderDetail.setPackAmount(returnPackFee); orderDetail.setRefundNumber(returnNum); - orderDetail.setStatus("refunding"); +// orderDetail.setStatus(isOnline ? "refunding" : "refund"); + orderDetail.setStatus("refund"); } if (returnAmount.compareTo(BigDecimal.ZERO) <= 0) { @@ -2105,7 +2633,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { mpOrderDetailService.saveBatch(remainOrderDetailList); } - TbOrderInfo returnOrder = mpOrderInfoService.selectReturnOrderByOrderId(returnOrderDTO.getOrderId()); +// TbOrderInfo returnOrder = mpOrderInfoService.selectReturnOrderByOrderId(returnOrderDTO.getOrderId()); + TbOrderInfo returnOrder = null; if (returnOrder == null) { String orderNo = generateOrderNumber(isOnline ? "OLRO" : "RO"); returnOrder = BeanUtil.copyProperties(oldOrderInfo, TbOrderInfo.class); @@ -2113,13 +2642,17 @@ public class TbShopTableServiceImpl implements TbShopTableService { returnOrder.setOrderNo(orderNo); returnOrder.setRefundAmount(returnAmount); returnOrder.setOrderType("return"); - returnOrder.setStatus("refunding"); + returnOrder.setStatus(isOnline ? "refunding" : "refund"); returnOrder.setUpdatedAt(null); returnOrder.setSystemTime(DateUtil.current()); returnOrder.setCreatedAt(DateUtil.current()); returnOrder.setPayOrderNo(null); returnOrder.setSource(oldOrderInfo.getId()); returnOrder.setRefundRemark(returnOrderDTO.getNote()); + returnOrder.setOrderAmount(returnAmount); + returnOrder.setAmount(returnAmount); + returnOrder.setSettlementAmount(returnAmount); + returnOrder.setPayAmount(returnAmount); orderInfoMapper.insert(returnOrder); } else { returnOrder.setUpdatedAt(DateUtil.current()); @@ -2128,7 +2661,6 @@ public class TbShopTableServiceImpl implements TbShopTableService { orderInfoMapper.updateById(returnOrder); } - updateStockAndRecord(detailList); mpOrderDetailService.updateBatchById(detailList); HashMap data = new HashMap<>(); @@ -2193,30 +2725,29 @@ public class TbShopTableServiceImpl implements TbShopTableService { if ("1".equals(shopInfo.getIsReturn())) { // TODO 密码校验 } - - HashMap returnInfoData = updateReturnOrderInfo(returnOrderDTO, orderInfo, true); + String payType = orderInfo.getPayType(); + HashMap returnInfoData = updateReturnOrderInfo(returnOrderDTO, orderInfo, "scanCode".equals(payType) || "wx_lite".equals(payType)); TbOrderInfo returnOrderInfo = (TbOrderInfo) returnInfoData.get("returnOrder"); BigDecimal returnAmount = (BigDecimal) returnInfoData.get("returnAmount"); String shopId = orderInfo.getShopId(); - String payType = orderInfo.getPayType(); // // 线上退款 orderInfo.setRefundAmount(returnOrderInfo.getRefundAmount()); orderInfo.setRefundRemark(returnOrderDTO.getNote()); if ("scanCode".equals(payType) || "wx_lite".equals(payType)) { payService.returnOrder(Integer.valueOf(shopId), orderInfo, returnOrderInfo); - orderInfo.setStatus("refund"); + returnOrderInfo.setStatus("refund"); + mpOrderInfoService.updateById(returnOrderInfo); // 储值卡支付退款 } else if ("deposit".equals(payType)) { orderInfoService.depositReturn(Integer.valueOf(orderInfo.getUserId()), Integer.valueOf(orderInfo.getShopId()), returnAmount); - orderInfo.setStatus("refund"); mpOrderDetailService.updateStatusByOrderIdAndIds(OrderStatusEnums.REFUNDING, OrderStatusEnums.REFUND, returnOrderDTO.getOrderId(), returnOrderDTO.getOrderDetails().stream().map(ReturnOrderDTO.OrderDetail::getId).collect(Collectors.toList())); } else if ("cash".equals(payType)) { - orderInfo.setStatus("refund"); mpOrderDetailService.updateStatusByOrderIdAndIds(OrderStatusEnums.REFUNDING, OrderStatusEnums.REFUND, returnOrderDTO.getOrderId(), returnOrderDTO.getOrderDetails().stream().map(ReturnOrderDTO.OrderDetail::getId).collect(Collectors.toList())); } + orderInfo.setStatus(TableConstant.OrderInfo.Status.CLOSED.getValue()); orderInfoMapper.updateById(orderInfo); // 打印退款小票 // producer.printMechine(newOrderInfo.getId().toString()); @@ -2236,6 +2767,20 @@ public class TbShopTableServiceImpl implements TbShopTableService { long cartCount = mpCashierCartService.countByTableId(shopId, tableId, OrderStatusEnums.CREATE, OrderStatusEnums.RETURN); Map map = BeanUtil.beanToMap(tbShopTable, false, false); map.put("cartCount", cartCount); + + TbOrderInfo orderInfo = null; + if (StrUtil.isNotBlank(tbShopTable.getQrcode())) { + try { + + ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(tbShopTable.getShopId(), tbShopTable.getQrcode()); + orderInfo = getCurrentOrder(shopEatTypeInfoDTO); + } catch (Exception e) { + log.info(e.getMessage()); + } + } + map.put("orderId", orderInfo == null ? null : orderInfo.getId()); + map.put("useType", orderInfo == null ? null : orderInfo.getUseType()); + map.put("masterId", orderInfo == null ? null : orderInfo.getMasterId()); return map; } return null; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopUserServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopUserServiceImpl.java index 291e13ea..9b9b869d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopUserServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopUserServiceImpl.java @@ -71,6 +71,9 @@ public class TbShopUserServiceImpl implements TbShopUserService { shopUserInfoVo.setHeadImg(tbShopUser.getHeadImg()); shopUserInfoVo.setTelephone(tbShopUser.getTelephone()); shopUserInfoVo.setTotalScore(0); + shopUserInfoVo.setAccountPoints(tbShopUser.getAccountPoints()); + shopUserInfoVo.setLastPointsChangeTime(tbShopUser.getLastPointsChangeTime()); + shopUserInfoVo.setLastFloatPoints(tbShopUser.getLastFloatPoints()); }); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbMerchantCouponService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbMerchantCouponService.java deleted file mode 100644 index 8450783d..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbMerchantCouponService.java +++ /dev/null @@ -1,83 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.service.shop; - -import cn.ysk.cashier.pojo.shop.TbMerchantCoupon; -import cn.ysk.cashier.dto.shop.TbMerchantCouponDto; -import cn.ysk.cashier.dto.shop.TbMerchantCouponQueryCriteria; -import org.springframework.data.domain.Pageable; -import java.util.Map; -import java.util.List; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; - -/** -* @website https://eladmin.vip -* @description 服务接口 -* @author lyf -* @date 2024-03-20 -**/ -public interface TbMerchantCouponService { - - /** - * 查询数据分页 - * @param criteria 条件 - * @param pageable 分页参数 - * @return Map - */ - Map queryAll(TbMerchantCouponQueryCriteria criteria, Pageable pageable); - - /** - * 查询所有数据不分页 - * @param criteria 条件参数 - * @return List - */ - List queryAll(TbMerchantCouponQueryCriteria criteria); - - /** - * 根据ID查询 - * @param id ID - * @return TbMerchantCouponDto - */ - TbMerchantCouponDto findById(Integer id); - - /** - * 创建 - * @param resources / - * @return TbMerchantCouponDto - */ - TbMerchantCoupon create(TbMerchantCoupon resources); - - /** - * 编辑 - * @param resources / - */ - void update(TbMerchantCoupon resources); - - /** - * 多选删除 - * @param ids / - */ - void deleteAll(Integer[] ids); - - /** - * 导出数据 - * @param all 待导出的数据 - * @param response / - * @throws IOException / - */ - void download(List all, HttpServletResponse response) throws IOException; -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbReceiptSalesService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbReceiptSalesService.java deleted file mode 100644 index 304e84b3..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbReceiptSalesService.java +++ /dev/null @@ -1,83 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.service.shop; - -import cn.ysk.cashier.pojo.shop.TbReceiptSales; -import cn.ysk.cashier.dto.shop.TbReceiptSalesDto; -import cn.ysk.cashier.dto.shop.TbReceiptSalesQueryCriteria; -import org.springframework.data.domain.Pageable; -import java.util.Map; -import java.util.List; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; - -/** -* @website https://eladmin.vip -* @description 服务接口 -* @author lyf -* @date 2024-01-08 -**/ -public interface TbReceiptSalesService { - - /** - * 查询数据分页 - * @param criteria 条件 - * @param pageable 分页参数 - * @return Map - */ - Map queryAll(TbReceiptSalesQueryCriteria criteria, Pageable pageable); - - /** - * 查询所有数据不分页 - * @param criteria 条件参数 - * @return List - */ - List queryAll(TbReceiptSalesQueryCriteria criteria); - - /** - * 根据ID查询 - * @param id ID - * @return TbReceiptSalesDto - */ - TbReceiptSalesDto findById(Integer id); - - /** - * 创建 - * @param resources / - * @return TbReceiptSalesDto - */ - TbReceiptSalesDto create(TbReceiptSales resources); - - /** - * 编辑 - * @param resources / - */ - void update(TbReceiptSales resources); - - /** - * 多选删除 - * @param ids / - */ - void deleteAll(Integer[] ids); - - /** - * 导出数据 - * @param all 待导出的数据 - * @param response / - * @throws IOException / - */ - void download(List all, HttpServletResponse response) throws IOException; -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopCashSpreadService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopCashSpreadService.java deleted file mode 100644 index 97dfc581..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopCashSpreadService.java +++ /dev/null @@ -1,84 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.service.shop; - -import cn.ysk.cashier.pojo.shop.TbShopCashSpread; -import cn.ysk.cashier.dto.shop.TbShopCashSpreadDto; -import cn.ysk.cashier.dto.shop.TbShopCashSpreadQueryCriteria; -import org.springframework.data.domain.Pageable; -import java.util.Map; -import java.util.List; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; - -/** -* @website https://eladmin.vip -* @description 服务接口 -* @author lyf -* @date 2024-01-05 -**/ -public interface TbShopCashSpreadService { - - /** - * 查询数据分页 - * @param criteria 条件 - * @param pageable 分页参数 - * @return Map - */ - Map queryAll(TbShopCashSpreadQueryCriteria criteria, Pageable pageable); - - /** - * 查询所有数据不分页 - * @param criteria 条件参数 - * @return List - */ - List queryAll(TbShopCashSpreadQueryCriteria criteria); - - /** - * 根据ID查询 - * @param id ID - * @return TbShopCashSpreadDto - */ - TbShopCashSpreadDto findById(String id); - TbShopCashSpread findByShopId(Integer id); - - /** - * 创建 - * @param resources / - * @return TbShopCashSpreadDto - */ - TbShopCashSpreadDto create(TbShopCashSpread resources); - - /** - * 编辑 - * @param resources / - */ - Integer update(TbShopCashSpread resources); - - /** - * 多选删除 - * @param ids / - */ - void deleteAll(String[] ids); - - /** - * 导出数据 - * @param all 待导出的数据 - * @param response / - * @throws IOException / - */ - void download(List all, HttpServletResponse response) throws IOException; -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopCurrencyService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopCurrencyService.java deleted file mode 100644 index 3ffad699..00000000 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopCurrencyService.java +++ /dev/null @@ -1,90 +0,0 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package cn.ysk.cashier.service.shop; - -import cn.ysk.cashier.pojo.shop.TbShopCurrency; -import cn.ysk.cashier.dto.shop.TbShopCurrencyDto; -import cn.ysk.cashier.dto.shop.TbShopCurrencyQueryCriteria; -import org.springframework.data.domain.Pageable; -import java.util.Map; -import java.util.List; -import java.io.IOException; -import javax.servlet.http.HttpServletResponse; - -/** -* @website https://eladmin.vip -* @description 服务接口 -* @author lyf -* @date 2024-01-05 -**/ -public interface TbShopCurrencyService { - - /** - * 查询数据分页 - * @param criteria 条件 - * @param pageable 分页参数 - * @return Map - */ - Map queryAll(TbShopCurrencyQueryCriteria criteria, Pageable pageable); - - /** - * 查询所有数据不分页 - * @param criteria 条件参数 - * @return List - */ - List queryAll(TbShopCurrencyQueryCriteria criteria); - - /** - * 根据ID查询 - * @param id ID - * @return TbShopCurrencyDto - */ - TbShopCurrencyDto findById(Integer id); - - /** - * 根据ID查询 - * @param id ID - * @return TbShopCurrencyDto - */ - TbShopCurrency findByShopId(String id); - - /** - * 创建 - * @param resources / - * @return TbShopCurrencyDto - */ - TbShopCurrencyDto create(TbShopCurrency resources); - - /** - * 编辑 - * @param resources / - */ - void update(TbShopCurrency resources); - - /** - * 多选删除 - * @param ids / - */ - void deleteAll(Integer[] ids); - - /** - * 导出数据 - * @param all 待导出的数据 - * @param response / - * @throws IOException / - */ - void download(List all, HttpServletResponse response) throws IOException; -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java index 58fd4474..10be0f97 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java @@ -110,7 +110,7 @@ public interface TbShopTableService { void pack(PackCartDTO packCartDTO); - Object createOrder(CreateOrderDTO createOrderDTO, boolean addMasterId, boolean isPrint); + Object createOrder(CreateOrderDTO createOrderDTO, boolean addMasterId); JSONObject getMasterId(Integer shopId, String tableId, String useType, Integer orderId); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/system/rest/ParamsController.java b/eladmin-system/src/main/java/cn/ysk/cashier/system/rest/ParamsController.java index 19eeadee..420c0a7f 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/system/rest/ParamsController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/system/rest/ParamsController.java @@ -36,11 +36,6 @@ public class ParamsController { @GetMapping("page") @ApiOperation("分页") - @ApiImplicitParams({ - @ApiImplicitParam(name = "page", value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , - @ApiImplicitParam(name = "size", value = "每页显示记录数", paramType = "query",required = true, dataType="int") , - @ApiImplicitParam(name = "paramCode", value = "参数编码", paramType = "query", dataType="String") - }) public ResponseEntity page(@ApiIgnore @RequestParam Map params){ Map page = paramsService.page(params); return ResponseEntity.ok().body(page); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/vo/ActivateInInfoVO.java b/eladmin-system/src/main/java/cn/ysk/cashier/vo/ActivateInInfoVO.java new file mode 100644 index 00000000..9bf08cea --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/vo/ActivateInInfoVO.java @@ -0,0 +1,15 @@ +package cn.ysk.cashier.vo; + +import lombok.Data; +import lombok.experimental.Accessors; + +@Data +@Accessors(chain = true) +public class ActivateInInfoVO { + private Integer id; + private Integer couponId; + private Integer num; + // 1满减 2商品 + private Integer type; +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/vo/QueryReceiveVo.java b/eladmin-system/src/main/java/cn/ysk/cashier/vo/QueryReceiveVo.java new file mode 100644 index 00000000..8db77f94 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/vo/QueryReceiveVo.java @@ -0,0 +1,24 @@ +package cn.ysk.cashier.vo; + +import lombok.Data; + +import java.util.Date; + +@Data +public class QueryReceiveVo { + + private Integer id; + private Integer userId; + private String name; + private String phone; + private Date receiveTime; + private Date useTime; + private String num; + private String overNum; + private String source; + private String status; + + + + +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/vo/ShopUserInfoVo.java b/eladmin-system/src/main/java/cn/ysk/cashier/vo/ShopUserInfoVo.java index 499d33af..82904907 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/vo/ShopUserInfoVo.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/vo/ShopUserInfoVo.java @@ -1,10 +1,12 @@ package cn.ysk.cashier.vo; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import java.io.Serializable; import java.math.BigDecimal; +import java.util.Date; @Data public class ShopUserInfoVo implements Serializable { @@ -25,6 +27,20 @@ public class ShopUserInfoVo implements Serializable { private BigDecimal inMoney; private Integer orderNumber; + /** + * 账户积分 + */ + private Integer accountPoints; + /** + * 最近一次积分变动时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date lastPointsChangeTime; + /** + * 最近一次浮动积分 + */ + private Integer lastFloatPoints; + public Object getSex() { return sex; } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbUserCouponVo.java b/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbUserCouponVo.java new file mode 100644 index 00000000..ea03ff86 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbUserCouponVo.java @@ -0,0 +1,43 @@ +package cn.ysk.cashier.vo; + +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +@Data +public class TbUserCouponVo { + private Integer id; + private BigDecimal fullAmount; + private BigDecimal discountAmount; + private Integer couponId; + private Integer proId; + // 商品名称 + private String productName; + private String productCover; + //优惠券名称 + private String name; + + //优惠券类型 1 满减 2 商品券 + private Integer type; + //数量 + private Integer num; + //到期时间 + private Date endTime; + private Long expireTime; + private String useRestrictions; + private boolean isUse = false; + //当前使用数量 + private Integer currentUseNum; + private Integer finalUseNum; + private BigDecimal finalDiscountAmount = new BigDecimal(0); + + + public void setEndTime(Date endTime) { + this.endTime = endTime; + if(endTime!=null){ + expireTime=endTime.getTime(); + } + } + +} diff --git a/eladmin-system/src/main/resources/config/application-dev.yml b/eladmin-system/src/main/resources/config/application-dev.yml index 86fd03fa..81fa474f 100644 --- a/eladmin-system/src/main/resources/config/application-dev.yml +++ b/eladmin-system/src/main/resources/config/application-dev.yml @@ -4,9 +4,9 @@ spring: druid: db-type: com.alibaba.druid.pool.DruidDataSource # driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy -# url: jdbc:p6spy:mysql://rm-bp1kn7h89nz62cno1ro.mysql.rds.aliyuncs.com:3306/fycashier_test?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false&allowMultiQueries=true + url: jdbc:p6spy:mysql://rm-bp1kn7h89nz62cno1ro.mysql.rds.aliyuncs.com:3306/fycashier_test?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false&allowMultiQueries=true # url: jdbc:mysql://127.0.0.1:3306/fycashier?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false&allowMultiQueries=true - url: jdbc:p6spy:mysql://rm-bp1kn7h89nz62cno1ro.mysql.rds.aliyuncs.com:3306/fycashier_pre?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false&allowMultiQueries=true +# url: jdbc:p6spy:mysql://rm-bp1kn7h89nz62cno1ro.mysql.rds.aliyuncs.com:3306/fycashier_pre?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false&allowMultiQueries=true username: cashier password: Cashier@1@ # driver-class-name: com.mysql.cj.jdbc.Driver diff --git a/eladmin-system/src/main/resources/config/application.yml b/eladmin-system/src/main/resources/config/application.yml index 5d57fe2c..debc3e04 100644 --- a/eladmin-system/src/main/resources/config/application.yml +++ b/eladmin-system/src/main/resources/config/application.yml @@ -68,8 +68,8 @@ thirdPay: url: https://paymentapi.sxczgkj.cn mybatis-plus: - mapper-locations: classpath:/cn/ysk/cashier/mybatis/mapper/*Mapper.xml - type-aliases-package: me.zhengjie.mybatis.entity + mapper-locations: classpath*:/mapper/plus/*.xml + #type-aliases-package: cn.ysk.cashier.pojo,cn.ysk.cashier.pojo.*,cn.ysk.cashier.system.domain.* configuration: map-underscore-to-camel-case: true cache-enabled: true diff --git a/eladmin-system/src/main/resources/mapper/TbActivateMapper.xml b/eladmin-system/src/main/resources/mapper/TbActivateMapper.xml deleted file mode 100644 index 77ad900a..00000000 --- a/eladmin-system/src/main/resources/mapper/TbActivateMapper.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - id,shop_id,min_num, - max_num,handsel_num,handsel_type, - is_del,is_user - - diff --git a/eladmin-system/src/main/resources/mapper/TbShopMsgStateMapper.xml b/eladmin-system/src/main/resources/mapper/TbShopMsgStateMapper.xml index a6ccca7d..728b48b4 100644 --- a/eladmin-system/src/main/resources/mapper/TbShopMsgStateMapper.xml +++ b/eladmin-system/src/main/resources/mapper/TbShopMsgStateMapper.xml @@ -4,15 +4,6 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - - - - - - - - - id,shop_id,type, state,create_time,update_time diff --git a/eladmin-system/src/main/resources/mapper/SysParamsMapper.xml b/eladmin-system/src/main/resources/mapper/plus/SysParamsMapper.xml similarity index 100% rename from eladmin-system/src/main/resources/mapper/SysParamsMapper.xml rename to eladmin-system/src/main/resources/mapper/plus/SysParamsMapper.xml diff --git a/eladmin-system/src/main/resources/mapper/plus/TbMemberPointsLogMapper.xml b/eladmin-system/src/main/resources/mapper/plus/TbMemberPointsLogMapper.xml new file mode 100644 index 00000000..e491c1f3 --- /dev/null +++ b/eladmin-system/src/main/resources/mapper/plus/TbMemberPointsLogMapper.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/eladmin-system/src/main/resources/mapper/plus/TbMemberPointsMapper.xml b/eladmin-system/src/main/resources/mapper/plus/TbMemberPointsMapper.xml new file mode 100644 index 00000000..2d0c97c1 --- /dev/null +++ b/eladmin-system/src/main/resources/mapper/plus/TbMemberPointsMapper.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/eladmin-system/src/main/resources/mapper/plus/TbPadProductCategoryMapper.xml b/eladmin-system/src/main/resources/mapper/plus/TbPadProductCategoryMapper.xml new file mode 100644 index 00000000..5f921c14 --- /dev/null +++ b/eladmin-system/src/main/resources/mapper/plus/TbPadProductCategoryMapper.xml @@ -0,0 +1,39 @@ + + + + + + \ No newline at end of file diff --git a/eladmin-system/src/main/resources/mapper/plus/TbPointsBasicSettingMapper.xml b/eladmin-system/src/main/resources/mapper/plus/TbPointsBasicSettingMapper.xml new file mode 100644 index 00000000..e9449ec2 --- /dev/null +++ b/eladmin-system/src/main/resources/mapper/plus/TbPointsBasicSettingMapper.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/eladmin-system/src/main/resources/mapper/plus/TbPointsExchangeRecordMapper.xml b/eladmin-system/src/main/resources/mapper/plus/TbPointsExchangeRecordMapper.xml new file mode 100644 index 00000000..c9e6387b --- /dev/null +++ b/eladmin-system/src/main/resources/mapper/plus/TbPointsExchangeRecordMapper.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/eladmin-system/src/main/resources/mapper/plus/TbPointsGoodsSettingMapper.xml b/eladmin-system/src/main/resources/mapper/plus/TbPointsGoodsSettingMapper.xml new file mode 100644 index 00000000..120e2743 --- /dev/null +++ b/eladmin-system/src/main/resources/mapper/plus/TbPointsGoodsSettingMapper.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 4e5d59af..e6bab1cf 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,6 @@ eladmin-logging eladmin-system eladmin-tools - eladmin-generator ELADMIN 后台管理