From 9b0c64d2f7956b81d1eef12141a4a7590be21b3d Mon Sep 17 00:00:00 2001 From: cheney <1251790704@qq.com> Date: Wed, 3 Jan 2024 11:00:51 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=B4=A6=E5=8F=B7=E5=AE=9E?= =?UTF-8?q?=E4=BD=93=E7=B1=BB=E7=BB=9F=E4=B8=80=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/huoran/common/constant/Constant.java | 16 + .../common/constant/OauthCacheNames.java | 38 +++ .../com/huoran/common/entity/CurrentInfo.java | 11 + .../com/huoran/common/entity/UserAccount.java | 22 +- .../huoran/common/utils/SecurityUtils.java | 32 ++ .../AliRealNameAuthenticationController.java | 3 +- .../EnterpriseCertificationController.java | 5 +- .../nakadai/controller/OrderController.java | 152 +++++---- .../PlatformTeamAccountController.java | 6 +- .../huoran/nakadai/entity/HrUserAccount.java | 93 ------ .../huoran/nakadai/entity/UserAccount.java | 90 ------ .../entity/app/dto/ProductItemDto.java | 2 +- .../entity/app/dto/ShopCartItemDto.java | 2 +- .../app/dto/ShopCartOrderMergerDto.java | 12 +- .../entity/app/param/OrderItemParam.java | 4 +- .../nakadai/entity/app/param/OrderParam.java | 18 +- .../entity/order/ConfirmOrderOrder.java | 38 +++ .../entity/order/ShopCartEventOrder.java | 28 ++ .../entity/order/SubmitOrderOrder.java | 33 ++ .../nakadai/event/CancelOrderEvent.java | 26 ++ .../nakadai/event/ConfirmOrderEvent.java | 44 +++ .../nakadai/event/PaySuccessOrderEvent.java | 28 ++ .../nakadai/event/ReceiptOrderEvent.java | 27 ++ .../huoran/nakadai/event/ShopCartEvent.java | 38 +++ .../nakadai/event/SubmitOrderEvent.java | 34 ++ .../listener/ConfirmOrderListener.java | 99 ++++++ .../nakadai/listener/ShopCartListener.java | 54 ++++ .../nakadai/listener/SubmitOrderListener.java | 304 ++++++++++++++++++ .../huoran/nakadai/mapper/BasketMapper.java | 2 +- .../nakadai/mapper/CurriculumMapper.java | 2 + .../huoran/nakadai/mapper/CustomerMapper.java | 7 +- .../mapper/EnterpriseCertificationMapper.java | 2 +- .../HrStaffAccountArchitectureMapper.java | 2 + .../mapper/HrStaffDepartmentMapper.java | 2 + .../huoran/nakadai/mapper/HrStaffMapper.java | 2 +- .../mapper/PlatformTeamAccountMapper.java | 3 +- .../PlatformTeamClassificationMapper.java | 4 +- .../nakadai/mapper/xml/CustomerMapper.xml | 6 +- .../xml/EnterpriseCertificationMapper.xml | 2 +- .../nakadai/mapper/xml/HrStaffMapper.xml | 8 +- .../mapper/xml/PlatformTeamAccountMapper.xml | 6 +- .../xml/PlatformTeamClassificationMapper.xml | 2 +- .../huoran/nakadai/service/BasketService.java | 2 +- .../EnterpriseCertificationService.java | 5 +- .../PlatformTeamClassificationService.java | 4 +- .../service/impl/BasketServiceImpl.java | 6 +- .../service/impl/CustomerServiceImpl.java | 5 +- .../EnterpriseCertificationServiceImpl.java | 2 +- .../service/impl/HrStaffServiceImpl.java | 1 + .../impl/PartnerAccountServiceImpl.java | 1 + .../impl/PlatformTeamAccountServiceImpl.java | 8 +- ...PlatformTeamClassificationServiceImpl.java | 4 +- 52 files changed, 1009 insertions(+), 338 deletions(-) create mode 100644 common/src/main/java/com/huoran/common/constant/Constant.java create mode 100644 common/src/main/java/com/huoran/common/constant/OauthCacheNames.java create mode 100644 common/src/main/java/com/huoran/common/entity/CurrentInfo.java create mode 100644 common/src/main/java/com/huoran/common/utils/SecurityUtils.java delete mode 100644 nakadai/src/main/java/com/huoran/nakadai/entity/HrUserAccount.java delete mode 100644 nakadai/src/main/java/com/huoran/nakadai/entity/UserAccount.java create mode 100644 nakadai/src/main/java/com/huoran/nakadai/entity/order/ConfirmOrderOrder.java create mode 100644 nakadai/src/main/java/com/huoran/nakadai/entity/order/ShopCartEventOrder.java create mode 100644 nakadai/src/main/java/com/huoran/nakadai/entity/order/SubmitOrderOrder.java create mode 100644 nakadai/src/main/java/com/huoran/nakadai/event/CancelOrderEvent.java create mode 100644 nakadai/src/main/java/com/huoran/nakadai/event/ConfirmOrderEvent.java create mode 100644 nakadai/src/main/java/com/huoran/nakadai/event/PaySuccessOrderEvent.java create mode 100644 nakadai/src/main/java/com/huoran/nakadai/event/ReceiptOrderEvent.java create mode 100644 nakadai/src/main/java/com/huoran/nakadai/event/ShopCartEvent.java create mode 100644 nakadai/src/main/java/com/huoran/nakadai/event/SubmitOrderEvent.java create mode 100644 nakadai/src/main/java/com/huoran/nakadai/listener/ConfirmOrderListener.java create mode 100644 nakadai/src/main/java/com/huoran/nakadai/listener/ShopCartListener.java create mode 100644 nakadai/src/main/java/com/huoran/nakadai/listener/SubmitOrderListener.java diff --git a/common/src/main/java/com/huoran/common/constant/Constant.java b/common/src/main/java/com/huoran/common/constant/Constant.java new file mode 100644 index 0000000..e38ac49 --- /dev/null +++ b/common/src/main/java/com/huoran/common/constant/Constant.java @@ -0,0 +1,16 @@ +package com.huoran.common.constant; + +/** + * @author TRACK + */ +public class Constant { + + /** + * 句号(英文符号) + */ + public static final String PERIOD = "."; + /** + * 逗号 + */ + public static final String COMMA = ","; +} diff --git a/common/src/main/java/com/huoran/common/constant/OauthCacheNames.java b/common/src/main/java/com/huoran/common/constant/OauthCacheNames.java new file mode 100644 index 0000000..17e184a --- /dev/null +++ b/common/src/main/java/com/huoran/common/constant/OauthCacheNames.java @@ -0,0 +1,38 @@ +package com.huoran.common.constant; + +/** + * @author 菠萝凤梨 + * @date 2022/3/28 14:32 + */ +public interface OauthCacheNames { + + /** + * oauth 授权相关key + */ + String OAUTH_PREFIX = "huoran_oauth:"; + + /** + * token 授权相关key + */ + String OAUTH_TOKEN_PREFIX = OAUTH_PREFIX + "token:"; + + /** + * 保存token 缓存使用key + */ + String ACCESS = OAUTH_TOKEN_PREFIX + "access:"; + + /** + * 刷新token 缓存使用key + */ + String REFRESH_TO_ACCESS = OAUTH_TOKEN_PREFIX + "refresh_to_access:"; + + /** + * 根据uid获取保存的token key缓存使用的key + */ + String UID_TO_ACCESS = OAUTH_TOKEN_PREFIX + "uid_to_access:"; + + /** + * 保存token的用户信息使用的key + */ + String USER_INFO = OAUTH_TOKEN_PREFIX + "user_info:"; +} diff --git a/common/src/main/java/com/huoran/common/entity/CurrentInfo.java b/common/src/main/java/com/huoran/common/entity/CurrentInfo.java new file mode 100644 index 0000000..42a2459 --- /dev/null +++ b/common/src/main/java/com/huoran/common/entity/CurrentInfo.java @@ -0,0 +1,11 @@ +package com.huoran.common.entity; + +import lombok.Data; + +@Data +public class CurrentInfo { + // 当前用户信息 + private String accountId; + private Integer shopId; + private Integer platformId; +} diff --git a/common/src/main/java/com/huoran/common/entity/UserAccount.java b/common/src/main/java/com/huoran/common/entity/UserAccount.java index 489bfe4..43c1141 100644 --- a/common/src/main/java/com/huoran/common/entity/UserAccount.java +++ b/common/src/main/java/com/huoran/common/entity/UserAccount.java @@ -35,6 +35,9 @@ public class UserAccount implements Serializable { @ApiModelProperty(value = "账号") private String account; + @ApiModelProperty("手机号(平台唯一标识)") + private String phone; + @ApiModelProperty(value = "密码") private String password; @@ -50,16 +53,23 @@ public class UserAccount implements Serializable { @ApiModelProperty(value = "所属平台id") private String platformId; + @ApiModelProperty(value = "小程序id") + private String appOpenId; + + @ApiModelProperty(value = "开放平台与公众平台唯一id") + private String unionid; + @ApiModelProperty(value = "平台(系统)绑定时间") private Date platformBindTime; + @ApiModelProperty(value = "手机绑定时间") + private Date phoneBindingTime; + @ApiModelProperty(value = "平台端区分:0->教师端 1->学生端 2->无端") private Integer type; - @ApiModelProperty(value = "电话", example = "17788771965") - private String phone; - @ApiModelProperty(value = "是否删除(0、未删除 1、已删除)") + @TableLogic private Integer isDel; @ApiModelProperty(value = "是否禁用(0->禁用,1->启用)") @@ -80,10 +90,4 @@ public class UserAccount implements Serializable { @ApiModelProperty(value = "班级id") @TableField(exist = false) private String userName; - - @ApiModelProperty(value = "小程序id") - private String appOpenId; - - @ApiModelProperty(value = "绑定时间") - private String phoneBindingTime; } \ No newline at end of file diff --git a/common/src/main/java/com/huoran/common/utils/SecurityUtils.java b/common/src/main/java/com/huoran/common/utils/SecurityUtils.java new file mode 100644 index 0000000..b188234 --- /dev/null +++ b/common/src/main/java/com/huoran/common/utils/SecurityUtils.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved. + * + * https://www.mall4j.com/ + * + * 未经允许,不可做商业用途! + * + * 版权所有,侵权必究! + */ +package com.huoran.common.utils; + + +import com.huoran.common.entity.CurrentInfo; +import lombok.experimental.UtilityClass; + +/** + * @author LGH + */ +@UtilityClass +public class SecurityUtils { + + /** + * 获取用户信息 + */ + public CurrentInfo getCurrentInfo() { + CurrentInfo currentInfo = new CurrentInfo(); + currentInfo.setAccountId(TokenUtils.getIdByJwtToken(HttpContextUtils.getHttpServletRequest())); + currentInfo.setShopId(TokenUtils.getShopIdByJwtToken(HttpContextUtils.getHttpServletRequest())); + currentInfo.setPlatformId(TokenUtils.getPlatformIdByJwtToken(HttpContextUtils.getHttpServletRequest())); + return currentInfo; + } +} diff --git a/nakadai/src/main/java/com/huoran/nakadai/controller/AliRealNameAuthenticationController.java b/nakadai/src/main/java/com/huoran/nakadai/controller/AliRealNameAuthenticationController.java index 5494c1b..e47b53f 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/controller/AliRealNameAuthenticationController.java +++ b/nakadai/src/main/java/com/huoran/nakadai/controller/AliRealNameAuthenticationController.java @@ -1,14 +1,13 @@ package com.huoran.nakadai.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.google.gson.Gson; +import com.huoran.common.entity.UserAccount; import com.huoran.common.response.R; import com.huoran.common.utils.TokenUtils; import com.huoran.nakadai.config.AliRealNameAuthenticationConfig; import com.huoran.nakadai.entity.EnterpriseCertification; import com.huoran.nakadai.entity.UserInfo; -import com.huoran.nakadai.entity.UserAccount; import com.huoran.nakadai.entity.UserAuthenticationInformation; import com.huoran.nakadai.entity.res.BusinessLicenseOCRResp; import com.huoran.nakadai.entity.res.CreditCodeResp; diff --git a/nakadai/src/main/java/com/huoran/nakadai/controller/EnterpriseCertificationController.java b/nakadai/src/main/java/com/huoran/nakadai/controller/EnterpriseCertificationController.java index b44ae94..632b7b8 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/controller/EnterpriseCertificationController.java +++ b/nakadai/src/main/java/com/huoran/nakadai/controller/EnterpriseCertificationController.java @@ -1,13 +1,10 @@ package com.huoran.nakadai.controller; -import cn.hutool.json.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.huoran.common.entity.UserAccount; import com.huoran.common.response.R; import com.huoran.common.utils.TokenUtils; import com.huoran.nakadai.entity.EnterpriseCertification; -import com.huoran.nakadai.entity.HrUserAccount; -import com.huoran.nakadai.entity.PartnerAccount; -import com.huoran.nakadai.entity.UserAccount; import com.huoran.nakadai.entity.req.EnterpriseCertificationLIstReq; import com.huoran.nakadai.entity.vo.WxMssVo; import com.huoran.nakadai.service.EnterpriseCertificationService; diff --git a/nakadai/src/main/java/com/huoran/nakadai/controller/OrderController.java b/nakadai/src/main/java/com/huoran/nakadai/controller/OrderController.java index a149a4d..6ba3064 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/controller/OrderController.java +++ b/nakadai/src/main/java/com/huoran/nakadai/controller/OrderController.java @@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.google.common.base.Objects; import com.huoran.common.exception.YamiShopBindException; import com.huoran.common.response.ServerResponseEntity; +import com.huoran.common.utils.SecurityUtils; import com.huoran.common.utils.TokenUtils; import com.huoran.nakadai.entity.app.dto.*; import com.huoran.nakadai.entity.app.param.OrderParam; @@ -34,16 +35,16 @@ import com.huoran.nakadai.entity.model.UserAddr; import com.huoran.nakadai.entity.model.UserAddrOrder; import com.huoran.nakadai.entity.param.DeliveryOrderParam; -import com.huoran.nakadai.service.OrderItemService; -import com.huoran.nakadai.service.OrderService; -import com.huoran.nakadai.service.ProductService; -import com.huoran.nakadai.service.SkuService; +import com.huoran.nakadai.event.ConfirmOrderEvent; +import com.huoran.nakadai.service.*; import com.huoran.nakadai.utils.Arith; import com.huoran.nakadai.utils.PageParam; +import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.apache.poi.ss.usermodel.Sheet; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.web.bind.annotation.*; @@ -63,6 +64,7 @@ import static com.huoran.nakadai.utils.SpringContextUtils.applicationContext; * @author lgh on 2018/09/15. */ @Slf4j +@Api(tags = "订单管理") @RestController @RequestMapping("/order/order") public class OrderController { @@ -73,85 +75,81 @@ public class OrderController { @Autowired private OrderItemService orderItemService; + @Autowired + private SkuService skuService; @Autowired private ProductService productService; @Autowired - private SkuService skuService; + private BasketService basketService; + @Autowired + private ApplicationContext applicationContext; -// @PostMapping("/sendInquiryForm") -// @ApiOperation(value = "根据店铺发送询价单给商家或留言") -// public ServerResponseEntity confirm(@Valid @RequestBody OrderParam orderParam,HttpServletRequest request) { -// String userId = SecurityUtils.getUser().getUserId(); -// TokenUtils.getShopIdByJwtToken(request); -// // 订单的地址信息 -// UserAddr userAddr = userAddrService.getUserAddrByUserId(orderParam.getAddrId(), userId); -// UserAddrDto userAddrDto = BeanUtil.copyProperties(userAddr, UserAddrDto.class); -// -// -// // 组装获取用户提交的购物车商品项 -// List shopCartItems = basketService.getShopCartItemsByOrderItems(orderParam.getBasketIds(),orderParam.getOrderItem(),userId); -// -// if (CollectionUtil.isEmpty(shopCartItems)) { -// throw new YamiShopBindException("请选择您需要的商品加入购物车"); -// } -// -// // 根据店铺组装购车中的商品信息,返回每个店铺中的购物车商品信息 -// List shopCarts = basketService.getShopCarts(shopCartItems); -// -// // 将要返回给前端的完整的订单信息 -// ShopCartOrderMergerDto shopCartOrderMergerDto = new ShopCartOrderMergerDto(); -// -// shopCartOrderMergerDto.setUserAddr(userAddrDto); -// -// // 所有店铺的订单信息 -// List shopCartOrders = new ArrayList<>(); -// -// double actualTotal = 0.0; -// double total = 0.0; -// int totalCount = 0; -// double orderReduce = 0.0; -// for (ShopCartDto shopCart : shopCarts) { -// -// // 每个店铺的订单信息 -// ShopCartOrderDto shopCartOrder = new ShopCartOrderDto(); -// shopCartOrder.setShopId(shopCart.getShopId()); -// shopCartOrder.setShopName(shopCart.getShopName()); -// -// -// List shopCartItemDiscounts = shopCart.getShopCartItemDiscounts(); -// -// // 店铺中的所有商品项信息 -// List shopAllShopCartItems = new ArrayList<>(); -// for (ShopCartItemDiscountDto shopCartItemDiscount : shopCartItemDiscounts) { -// List discountShopCartItems = shopCartItemDiscount.getShopCartItems(); -// shopAllShopCartItems.addAll(discountShopCartItems); -// } -// -// shopCartOrder.setShopCartItemDiscounts(shopCartItemDiscounts); -// -// applicationContext.publishEvent(new ConfirmOrderEvent(shopCartOrder,orderParam,shopAllShopCartItems)); -// -// actualTotal = Arith.add(actualTotal,shopCartOrder.getActualTotal()); -// total = Arith.add(total,shopCartOrder.getTotal()); -// totalCount = totalCount + shopCartOrder.getTotalCount(); -// orderReduce = Arith.add(orderReduce,shopCartOrder.getShopReduce()); -// shopCartOrders.add(shopCartOrder); -// -// -// } -// -// shopCartOrderMergerDto.setActualTotal(actualTotal); -// shopCartOrderMergerDto.setTotal(total); -// shopCartOrderMergerDto.setTotalCount(totalCount); -// shopCartOrderMergerDto.setShopCartOrders(shopCartOrders); -// shopCartOrderMergerDto.setOrderReduce(orderReduce); -// -// shopCartOrderMergerDto = orderService.putConfirmOrderCache(userId, shopCartOrderMergerDto); -// -// return ServerResponseEntity.success(shopCartOrderMergerDto); -// } + @PostMapping("/sendInquiryForm") + @ApiOperation(value = "根据店铺发送询价单给商家或留言",response = ShopCartOrderMergerDto.class) + public ServerResponseEntity confirm( + @Valid @RequestBody OrderParam orderParam) { + String userId = SecurityUtils.getCurrentInfo().getAccountId(); + + // 组装获取用户提交的购物车商品项 + List shopCartItems = basketService.getShopCartItemsByOrderItems(null,orderParam.getOrderItem(),userId); + + if (CollectionUtil.isEmpty(shopCartItems)) { + throw new YamiShopBindException("请选择您需要的商品加入购物车"); + } + + // 根据店铺组装购车中的商品信息,返回每个店铺中的购物车商品信息 + List shopCarts = basketService.getShopCarts(shopCartItems); + + // 将要返回给前端的完整的订单信息 + ShopCartOrderMergerDto shopCartOrderMergerDto = new ShopCartOrderMergerDto(); + + // 所有店铺的订单信息 + List shopCartOrders = new ArrayList<>(); + + double actualTotal = 0.0; + double total = 0.0; + int totalCount = 0; + double orderReduce = 0.0; + for (ShopCartDto shopCart : shopCarts) { + + // 每个店铺的订单信息 + ShopCartOrderDto shopCartOrder = new ShopCartOrderDto(); + shopCartOrder.setShopId(shopCart.getShopId()); + shopCartOrder.setShopName(shopCart.getShopName()); + + + List shopCartItemDiscounts = shopCart.getShopCartItemDiscounts(); + + // 店铺中的所有商品项信息 + List shopAllShopCartItems = new ArrayList<>(); + for (ShopCartItemDiscountDto shopCartItemDiscount : shopCartItemDiscounts) { + List discountShopCartItems = shopCartItemDiscount.getShopCartItems(); + shopAllShopCartItems.addAll(discountShopCartItems); + } + + shopCartOrder.setShopCartItemDiscounts(shopCartItemDiscounts); + + applicationContext.publishEvent(new ConfirmOrderEvent(shopCartOrder,orderParam,shopAllShopCartItems)); + + actualTotal = Arith.add(actualTotal,shopCartOrder.getActualTotal()); + total = Arith.add(total,shopCartOrder.getTotal()); + totalCount = totalCount + shopCartOrder.getTotalCount(); + orderReduce = Arith.add(orderReduce,shopCartOrder.getShopReduce()); + shopCartOrders.add(shopCartOrder); + + + } + + shopCartOrderMergerDto.setActualTotal(actualTotal); + shopCartOrderMergerDto.setTotal(total); + shopCartOrderMergerDto.setTotalCount(totalCount); + shopCartOrderMergerDto.setShopCartOrders(shopCartOrders); + shopCartOrderMergerDto.setOrderReduce(orderReduce); + + return ServerResponseEntity.success(shopCartOrderMergerDto); + } /** * 分页获取 diff --git a/nakadai/src/main/java/com/huoran/nakadai/controller/PlatformTeamAccountController.java b/nakadai/src/main/java/com/huoran/nakadai/controller/PlatformTeamAccountController.java index 42d5ce5..73a4489 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/controller/PlatformTeamAccountController.java +++ b/nakadai/src/main/java/com/huoran/nakadai/controller/PlatformTeamAccountController.java @@ -2,11 +2,11 @@ package com.huoran.nakadai.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.huoran.common.entity.UserAccount; import com.huoran.common.exception.CustomException; import com.huoran.common.exception.ExceptionEnum; import com.huoran.common.response.R; import com.huoran.common.utils.TokenUtils; -import com.huoran.nakadai.entity.HrUserAccount; import com.huoran.nakadai.entity.PlatformTeam; import com.huoran.nakadai.entity.PlatformTeamAccount; import com.huoran.nakadai.entity.PlatformTeamClassification; @@ -190,8 +190,8 @@ public class PlatformTeamAccountController { @RequestParam("openId") @ApiParam(value = "openId") String openId, @RequestParam("isEnable") @ApiParam(value = "是否禁用(1->禁用,0->启用)") Integer isEnable) { //根据openId查询账号详情List - List userAccountList = platformTeamClassificationService.selectAccountList(openId); - for (HrUserAccount userAccount : userAccountList) { + List userAccountList = platformTeamClassificationService.selectAccountList(openId); + for (UserAccount userAccount : userAccountList) { int status = 1; if (isEnable==1){ status=0; diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/HrUserAccount.java b/nakadai/src/main/java/com/huoran/nakadai/entity/HrUserAccount.java deleted file mode 100644 index d0f12bd..0000000 --- a/nakadai/src/main/java/com/huoran/nakadai/entity/HrUserAccount.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.huoran.nakadai.entity; - -import com.baomidou.mybatisplus.annotation.*; -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; -import java.util.Date; - -/** - *

- * 各个平台账号表 - *

- * - * @author huoran - * @since 2021-06-28 - */ -@Data -@TableName("hr_user_account") -public class HrUserAccount implements Serializable { - - private static final long serialVersionUID = 1L; - - @TableId(type = IdType.AUTO) - @ApiModelProperty(value = "主键id(平台用户id)") - private Integer id; - - @ApiModelProperty(value = "用户表id") - private Integer userId; - - @ApiModelProperty(value = "客户表id") - private Integer customerId; - - @ApiModelProperty(value = "账号") - private String account; - - @ApiModelProperty("手机号(平台唯一标识)") - private String phone; - - @ApiModelProperty(value = "密码") - private String password; - - @ApiModelProperty(value = "工号") - private String workNumber; - - @ApiModelProperty(value = "绑定的角色id(0为数据平台普通用户)") - private String roleId; - - @ApiModelProperty(value = "绑定院校id") - private Integer schoolId; - - @ApiModelProperty(value = "所属平台id") - private String platformId; - - @ApiModelProperty(value = "小程序id") - private String appOpenId; - - @ApiModelProperty(value = "开放平台与公众平台唯一id") - private String unionid; - - @ApiModelProperty(value = "平台(系统)绑定时间") - private Date platformBindTime; - - @ApiModelProperty(value = "手机绑定时间") - private Date phoneBindingTime; - - @ApiModelProperty(value = "平台端区分:0->教师端 1->学生端 2->无端") - private Integer type; - - @ApiModelProperty(value = "是否删除(0、未删除 1、已删除)") - private Integer isDel; - - @ApiModelProperty(value = "是否禁用(0->禁用,1->启用)") - private Boolean isEnable; - - @ApiModelProperty(value = "创建时间") - @TableField(fill = FieldFill.INSERT) - private Date createTime; - - @ApiModelProperty(value = "更新时间") - @TableField(fill = FieldFill.INSERT_UPDATE) - private Date updateTime; - - @ApiModelProperty(value = "班级id") - @TableField(exist = false) - private String classId; - - @ApiModelProperty(value = "班级id") - @TableField(exist = false) - private String userName; - -} diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/UserAccount.java b/nakadai/src/main/java/com/huoran/nakadai/entity/UserAccount.java deleted file mode 100644 index 2fde1cf..0000000 --- a/nakadai/src/main/java/com/huoran/nakadai/entity/UserAccount.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.huoran.nakadai.entity; - -import com.baomidou.mybatisplus.annotation.*; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; -import java.util.Date; - -/** - * @描述:各个平台账号表 - * @作者: Rong - * @日期: 2021-08-25 - */ -@Data -@ApiModel(value = "各个平台账号表") -@TableName("hr_user_account") -public class UserAccount implements Serializable { - - private static final long serialVersionUID = 1L; - - @TableId(type = IdType.AUTO) - @ApiModelProperty(value = "主键id(平台用户id)") - private Integer id; - - @ApiModelProperty(value = "用户表id") - private Integer userId; - - @ApiModelProperty(value = "客户表id") - private Integer customerId; - - @ApiModelProperty(value = "账号") - private String account; - - @ApiModelProperty("手机号(平台唯一标识)") - private String phone; - - @ApiModelProperty(value = "密码") - private String password; - - @ApiModelProperty(value = "工号") - private String workNumber; - - @ApiModelProperty(value = "绑定的角色id(0为数据平台普通用户)") - private String roleId; - - @ApiModelProperty(value = "绑定院校id") - private Integer schoolId; - - @ApiModelProperty(value = "所属平台id") - private String platformId; - - @ApiModelProperty(value = "小程序id") - private String appOpenId; - - @ApiModelProperty(value = "开放平台与公众平台唯一id") - private String unionid; - - @ApiModelProperty(value = "平台(系统)绑定时间") - private Date platformBindTime; - - @ApiModelProperty(value = "手机绑定时间") - private Date phoneBindingTime; - - @ApiModelProperty(value = "平台端区分:0->教师端 1->学生端 2->无端") - private Integer type; - - @ApiModelProperty(value = "是否删除(0、未删除 1、已删除)") - private Integer isDel; - - @ApiModelProperty(value = "是否禁用(0->禁用,1->启用)") - private Boolean isEnable; - - @ApiModelProperty(value = "创建时间") - @TableField(fill = FieldFill.INSERT) - private Date createTime; - - @ApiModelProperty(value = "更新时间") - @TableField(fill = FieldFill.INSERT_UPDATE) - private Date updateTime; - - @ApiModelProperty(value = "班级id") - @TableField(exist = false) - private String classId; - - @ApiModelProperty(value = "班级id") - @TableField(exist = false) - private String userName; -} \ No newline at end of file diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/ProductItemDto.java b/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/ProductItemDto.java index 30b008b..e9fc626 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/ProductItemDto.java +++ b/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/ProductItemDto.java @@ -48,7 +48,7 @@ public class ProductItemDto implements Serializable { private String skuName; @ApiModelProperty(value = "basketId" ,required=true) - private Long basketId; + private Integer basketId; @ApiModelProperty(value = "商品实际金额 = 商品总金额 - 分摊的优惠金额" ) private Double actualTotal; diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/ShopCartItemDto.java b/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/ShopCartItemDto.java index 4482786..763e55f 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/ShopCartItemDto.java +++ b/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/ShopCartItemDto.java @@ -26,7 +26,7 @@ public class ShopCartItemDto extends ProductItemDto implements Serializable { private static final long serialVersionUID = -8284981156242930909L; @ApiModelProperty(value = "购物车ID" , required = true) - private Long basketId; + private Integer basketId; @ApiModelProperty(value = "店铺ID" , required = true) private Integer shopId; diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/ShopCartOrderMergerDto.java b/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/ShopCartOrderMergerDto.java index 35b20ef..e6776bb 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/ShopCartOrderMergerDto.java +++ b/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/ShopCartOrderMergerDto.java @@ -36,12 +36,12 @@ public class ShopCartOrderMergerDto implements Serializable{ @ApiModelProperty(value = "订单优惠金额(所有店铺优惠金额相加)" , required = true) private Double orderReduce; - @ApiModelProperty(value = "地址Dto" , required = true) - private UserAddrDto userAddr; - +// @ApiModelProperty(value = "地址Dto" , required = true) +// private UserAddrDto userAddr; +// @ApiModelProperty(value = "每个店铺的购物车信息" , required = true) private List shopCartOrders; - - @ApiModelProperty(value = "整个订单可以使用的优惠券列表" , required = true) - private List coupons; +// +// @ApiModelProperty(value = "整个订单可以使用的优惠券列表" , required = true) +// private List coupons; } diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/app/param/OrderItemParam.java b/nakadai/src/main/java/com/huoran/nakadai/entity/app/param/OrderItemParam.java index e6a94e0..88388e4 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/entity/app/param/OrderItemParam.java +++ b/nakadai/src/main/java/com/huoran/nakadai/entity/app/param/OrderItemParam.java @@ -40,6 +40,6 @@ public class OrderItemParam { @ApiModelProperty(value = "店铺id" ,required=true) private Integer shopId; - @ApiModelProperty(value = "推广员使用的推销卡号" ) - private String distributionCardNo; +// @ApiModelProperty(value = "推广员使用的推销卡号" ) +// private String distributionCardNo; } diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/app/param/OrderParam.java b/nakadai/src/main/java/com/huoran/nakadai/entity/app/param/OrderParam.java index 244d085..3e62228 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/entity/app/param/OrderParam.java +++ b/nakadai/src/main/java/com/huoran/nakadai/entity/app/param/OrderParam.java @@ -24,21 +24,21 @@ import java.util.List; public class OrderParam { - @ApiModelProperty(value = "购物车id 数组" ) - private List basketIds; +// @ApiModelProperty(value = "购物车id 数组" ) +// private List basketIds; @ApiModelProperty(value = "立即购买时提交的商品项" ) private OrderItemParam orderItem; - @ApiModelProperty(value = "地址ID,0为默认地址" ,required=true) - @NotNull(message = "地址不能为空") - private Long addrId; +// @ApiModelProperty(value = "地址ID,0为默认地址" ,required=true) +// @NotNull(message = "地址不能为空") +// private Long addrId; - @ApiModelProperty(value = "用户是否改变了优惠券的选择,如果用户改变了优惠券的选择,则完全根据传入参数进行优惠券的选择" ) - private Integer userChangeCoupon; +// @ApiModelProperty(value = "用户是否改变了优惠券的选择,如果用户改变了优惠券的选择,则完全根据传入参数进行优惠券的选择" ) +// private Integer userChangeCoupon; - @ApiModelProperty(value = "优惠券id数组" ) - private List couponIds; +// @ApiModelProperty(value = "优惠券id数组" ) +// private List couponIds; // @Schema(description = "每次订单提交时的uuid" ) // private String uuid; diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/order/ConfirmOrderOrder.java b/nakadai/src/main/java/com/huoran/nakadai/entity/order/ConfirmOrderOrder.java new file mode 100644 index 0000000..db363d4 --- /dev/null +++ b/nakadai/src/main/java/com/huoran/nakadai/entity/order/ConfirmOrderOrder.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved. + * + * https://www.mall4j.com/ + * + * 未经允许,不可做商业用途! + * + * 版权所有,侵权必究! + */ + +package com.huoran.nakadai.entity.order; + +/** + * 提交订单事件先后顺序 + * @author LGH + */ +public interface ConfirmOrderOrder { + + /** + * 没有任何活动时的顺序 + */ + int DEFAULT = 0; + + /** + * 满减,排在DEFAULT后面 + */ + int DISCOUNT = 100; + + /** + * 优惠券,排在DISCOUNT后面 + */ + int COUPON = 200; + + /** + * 分销,排在COUPON后面 + */ + int DISTRIBUTION = 300; +} diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/order/ShopCartEventOrder.java b/nakadai/src/main/java/com/huoran/nakadai/entity/order/ShopCartEventOrder.java new file mode 100644 index 0000000..3c7028e --- /dev/null +++ b/nakadai/src/main/java/com/huoran/nakadai/entity/order/ShopCartEventOrder.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved. + * + * https://www.mall4j.com/ + * + * 未经允许,不可做商业用途! + * + * 版权所有,侵权必究! + */ + +package com.huoran.nakadai.entity.order; + +/** + * 购物车事件先后顺序 + * @author LGH + */ +public interface ShopCartEventOrder { + + /** + * 没有任何活动时的顺序 + */ + int DEFAULT = 0; + + /** + * 满减活动的组装顺序,排在DEFAULT后面 + */ + int DISCOUNT = 100; +} diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/order/SubmitOrderOrder.java b/nakadai/src/main/java/com/huoran/nakadai/entity/order/SubmitOrderOrder.java new file mode 100644 index 0000000..f42ebf1 --- /dev/null +++ b/nakadai/src/main/java/com/huoran/nakadai/entity/order/SubmitOrderOrder.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved. + * + * https://www.mall4j.com/ + * + * 未经允许,不可做商业用途! + * + * 版权所有,侵权必究! + */ + +package com.huoran.nakadai.entity.order; + +/** + * 提交订单事件先后顺序 + * @author LGH + */ +public interface SubmitOrderOrder { + + /** + * 没有任何活动时的顺序 + */ + int DEFAULT = 0; + + /** + * 优惠券,排在DEFAULT后面 + */ + int DISCOUNT = 100; + + /** + * 优惠券,排在DEFAULT后面 + */ + int COUPON = 200; +} diff --git a/nakadai/src/main/java/com/huoran/nakadai/event/CancelOrderEvent.java b/nakadai/src/main/java/com/huoran/nakadai/event/CancelOrderEvent.java new file mode 100644 index 0000000..cbe6fc7 --- /dev/null +++ b/nakadai/src/main/java/com/huoran/nakadai/event/CancelOrderEvent.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved. + * + * https://www.mall4j.com/ + * + * 未经允许,不可做商业用途! + * + * 版权所有,侵权必究! + */ + +package com.huoran.nakadai.event; + +import com.huoran.nakadai.entity.model.Order; +import lombok.AllArgsConstructor; +import lombok.Data; + +/** + * 取消订单的事件 + * @author + */ +@Data +@AllArgsConstructor +public class CancelOrderEvent { + + private Order order; +} diff --git a/nakadai/src/main/java/com/huoran/nakadai/event/ConfirmOrderEvent.java b/nakadai/src/main/java/com/huoran/nakadai/event/ConfirmOrderEvent.java new file mode 100644 index 0000000..5d0f142 --- /dev/null +++ b/nakadai/src/main/java/com/huoran/nakadai/event/ConfirmOrderEvent.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved. + * + * https://www.mall4j.com/ + * + * 未经允许,不可做商业用途! + * + * 版权所有,侵权必究! + */ + +package com.huoran.nakadai.event; + + +import com.huoran.nakadai.entity.app.dto.ShopCartItemDto; +import com.huoran.nakadai.entity.app.dto.ShopCartOrderDto; +import com.huoran.nakadai.entity.app.param.OrderParam; +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.util.List; + +/** + * 确认订单时的事件 + * @author LGH + */ +@Data +@AllArgsConstructor +public class ConfirmOrderEvent { + + /** + * 购物车已经组装好的店铺订单信息 + */ + private ShopCartOrderDto shopCartOrderDto; + + /** + * 下单请求的参数 + */ + private OrderParam orderParam; + + /** + * 店铺中的所有商品项 + */ + private List shopCartItems; +} diff --git a/nakadai/src/main/java/com/huoran/nakadai/event/PaySuccessOrderEvent.java b/nakadai/src/main/java/com/huoran/nakadai/event/PaySuccessOrderEvent.java new file mode 100644 index 0000000..344aea6 --- /dev/null +++ b/nakadai/src/main/java/com/huoran/nakadai/event/PaySuccessOrderEvent.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved. + * + * https://www.mall4j.com/ + * + * 未经允许,不可做商业用途! + * + * 版权所有,侵权必究! + */ + +package com.huoran.nakadai.event; + +import com.huoran.nakadai.entity.model.Order; +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.util.List; + +/** + * 订单付款成功的事件 + * @author + */ +@Data +@AllArgsConstructor +public class PaySuccessOrderEvent { + + private List orders; +} diff --git a/nakadai/src/main/java/com/huoran/nakadai/event/ReceiptOrderEvent.java b/nakadai/src/main/java/com/huoran/nakadai/event/ReceiptOrderEvent.java new file mode 100644 index 0000000..a58434b --- /dev/null +++ b/nakadai/src/main/java/com/huoran/nakadai/event/ReceiptOrderEvent.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved. + * + * https://www.mall4j.com/ + * + * 未经允许,不可做商业用途! + * + * 版权所有,侵权必究! + */ + +package com.huoran.nakadai.event; + +import com.huoran.nakadai.entity.model.Order; +import lombok.AllArgsConstructor; +import lombok.Data; + + +/** + * 确认收货的事件 + * @author + */ +@Data +@AllArgsConstructor +public class ReceiptOrderEvent { + + private Order order; +} diff --git a/nakadai/src/main/java/com/huoran/nakadai/event/ShopCartEvent.java b/nakadai/src/main/java/com/huoran/nakadai/event/ShopCartEvent.java new file mode 100644 index 0000000..fbb12ad --- /dev/null +++ b/nakadai/src/main/java/com/huoran/nakadai/event/ShopCartEvent.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved. + * + * https://www.mall4j.com/ + * + * 未经允许,不可做商业用途! + * + * 版权所有,侵权必究! + */ + +package com.huoran.nakadai.event; + + +import com.huoran.nakadai.entity.app.dto.ShopCartDto; +import com.huoran.nakadai.entity.app.dto.ShopCartItemDto; +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.util.List; + +/** + * 购物车商品发生改变时的事件 + * @author LGH + */ +@Data +@AllArgsConstructor +public class ShopCartEvent { + + /** + * 将要组装的单个店铺的店铺信息 + */ + private ShopCartDto shopCartDto; + + /** + * 该店铺下的所有商品信息 + */ + private List shopCartItemDtoList; +} diff --git a/nakadai/src/main/java/com/huoran/nakadai/event/SubmitOrderEvent.java b/nakadai/src/main/java/com/huoran/nakadai/event/SubmitOrderEvent.java new file mode 100644 index 0000000..f1bb223 --- /dev/null +++ b/nakadai/src/main/java/com/huoran/nakadai/event/SubmitOrderEvent.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved. + * + * https://www.mall4j.com/ + * + * 未经允许,不可做商业用途! + * + * 版权所有,侵权必究! + */ + +package com.huoran.nakadai.event; + +import com.huoran.nakadai.entity.app.dto.ShopCartOrderMergerDto; +import com.huoran.nakadai.entity.model.Order; +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.util.List; + +/** + * 提交订单时的事件 + * @author LGH + */ +@Data +@AllArgsConstructor +public class SubmitOrderEvent { + /** + * 完整的订单信息 + */ + private final ShopCartOrderMergerDto mergerOrder; + + private List orders; + +} diff --git a/nakadai/src/main/java/com/huoran/nakadai/listener/ConfirmOrderListener.java b/nakadai/src/main/java/com/huoran/nakadai/listener/ConfirmOrderListener.java new file mode 100644 index 0000000..a8f6656 --- /dev/null +++ b/nakadai/src/main/java/com/huoran/nakadai/listener/ConfirmOrderListener.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved. + * + * https://www.mall4j.com/ + * + * 未经允许,不可做商业用途! + * + * 版权所有,侵权必究! + */ + +package com.huoran.nakadai.listener; + + +import com.huoran.common.exception.YamiShopBindException; +import com.huoran.common.utils.SecurityUtils; +import com.huoran.common.utils.TokenUtils; +import com.huoran.nakadai.entity.app.dto.ShopCartItemDto; +import com.huoran.nakadai.entity.app.dto.ShopCartOrderDto; +import com.huoran.nakadai.entity.app.param.OrderParam; +import com.huoran.nakadai.entity.model.Product; +import com.huoran.nakadai.entity.model.Sku; +import com.huoran.nakadai.entity.order.ConfirmOrderOrder; +import com.huoran.nakadai.event.ConfirmOrderEvent; +import com.huoran.nakadai.service.ProductService; +import com.huoran.nakadai.service.SkuService; +import com.huoran.nakadai.utils.Arith; +import lombok.AllArgsConstructor; +import org.springframework.context.event.EventListener; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; + +/** + * 确认订单信息时的默认操作 + * @author LGH + */ +@Component("defaultConfirmOrderListener") +@AllArgsConstructor +public class ConfirmOrderListener { + +// private final UserAddrService userAddrService; +// +// private final TransportManagerService transportManagerService; + + private final ProductService productService; + + private final SkuService skuService; + + /** + * 计算订单金额 + */ + @EventListener(ConfirmOrderEvent.class) + @Order(ConfirmOrderOrder.DEFAULT) + public void defaultConfirmOrderEvent(ConfirmOrderEvent event) { + + + ShopCartOrderDto shopCartOrderDto = event.getShopCartOrderDto(); + + OrderParam orderParam = event.getOrderParam(); + String userId = SecurityUtils.getCurrentInfo().getAccountId(); + + // 订单的地址信息 +// UserAddr userAddr = userAddrService.getUserAddrByUserId(orderParam.getAddrId(), userId); + + double total = 0.0; + + int totalCount = 0; + + double transfee = 0.0; + + for (ShopCartItemDto shopCartItem : event.getShopCartItems()) { + // 获取商品信息 + Product product = productService.getProductByProdId(shopCartItem.getProdId()); + // 获取sku信息 + Sku sku = skuService.getSkuBySkuId(shopCartItem.getSkuId()); + if (product == null || sku == null) { + throw new YamiShopBindException("购物车包含无法识别的商品"); + } + if (product.getStatus() != 1 || sku.getStatus() != 1) { + throw new YamiShopBindException("商品[" + sku.getProdName() + "]已下架"); + } + + totalCount = shopCartItem.getProdCount() + totalCount; + total = Arith.add(shopCartItem.getProductTotalAmount(), total); + // 用户地址如果为空,则表示该用户从未设置过任何地址相关信息 +// if (userAddr != null) { +// // 每个产品的运费相加 +// transfee = Arith.add(transfee, transportManagerService.calculateTransfee(shopCartItem, userAddr)); +// } + + shopCartItem.setActualTotal(shopCartItem.getProductTotalAmount()); + shopCartOrderDto.setActualTotal(Arith.add(total, transfee)); + shopCartOrderDto.setTotal(total); + shopCartOrderDto.setTotalCount(totalCount); + shopCartOrderDto.setTransfee(transfee); + } + } +} diff --git a/nakadai/src/main/java/com/huoran/nakadai/listener/ShopCartListener.java b/nakadai/src/main/java/com/huoran/nakadai/listener/ShopCartListener.java new file mode 100644 index 0000000..38dcdde --- /dev/null +++ b/nakadai/src/main/java/com/huoran/nakadai/listener/ShopCartListener.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved. + * + * https://www.mall4j.com/ + * + * 未经允许,不可做商业用途! + * + * 版权所有,侵权必究! + */ + +package com.huoran.nakadai.listener; + +import com.google.common.collect.Lists; + +import com.huoran.nakadai.entity.app.dto.ShopCartDto; +import com.huoran.nakadai.entity.app.dto.ShopCartItemDiscountDto; +import com.huoran.nakadai.entity.app.dto.ShopCartItemDto; +import com.huoran.nakadai.entity.order.ShopCartEventOrder; +import com.huoran.nakadai.event.ShopCartEvent; +import org.springframework.context.event.EventListener; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * 默认的购物车链进行组装时的操作 + * @author LGH + */ +@Component("defaultShopCartListener") +public class ShopCartListener { + + /** + * 将店铺下的所有商品归属到该店铺的购物车当中 + * @param event#getShopCart() 购物车 + * @param event#shopCartItemDtoList 该购物车的商品 + * @return 是否继续组装 + */ + @EventListener(ShopCartEvent.class) + @Order(ShopCartEventOrder.DEFAULT) + public void defaultShopCartEvent(ShopCartEvent event) { + ShopCartDto shopCart = event.getShopCartDto(); + List shopCartItemDtoList = event.getShopCartItemDtoList(); + // 对数据进行组装 + List shopCartItemDiscountDtoList = Lists.newArrayList(); + ShopCartItemDiscountDto shopCartItemDiscountDto = new ShopCartItemDiscountDto(); + + shopCartItemDiscountDto.setShopCartItems(shopCartItemDtoList); + shopCartItemDiscountDtoList.add(shopCartItemDiscountDto); + + shopCart.setShopCartItemDiscounts(shopCartItemDiscountDtoList); + } + +} diff --git a/nakadai/src/main/java/com/huoran/nakadai/listener/SubmitOrderListener.java b/nakadai/src/main/java/com/huoran/nakadai/listener/SubmitOrderListener.java new file mode 100644 index 0000000..6cb65c3 --- /dev/null +++ b/nakadai/src/main/java/com/huoran/nakadai/listener/SubmitOrderListener.java @@ -0,0 +1,304 @@ +/* + * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved. + * + * https://www.mall4j.com/ + * + * 未经允许,不可做商业用途! + * + * 版权所有,侵权必究! + */ + +package com.huoran.nakadai.listener; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.lang.Snowflake; +import cn.hutool.core.util.StrUtil; + +import com.huoran.common.constant.Constant; +import com.huoran.common.exception.YamiShopBindException; +import com.huoran.common.utils.SecurityUtils; +import com.huoran.common.utils.TokenUtils; +import com.huoran.nakadai.entity.app.dto.ShopCartItemDiscountDto; +import com.huoran.nakadai.entity.app.dto.ShopCartItemDto; +import com.huoran.nakadai.entity.app.dto.ShopCartOrderDto; +import com.huoran.nakadai.entity.app.dto.ShopCartOrderMergerDto; +import com.huoran.nakadai.entity.enums.OrderStatus; +import com.huoran.nakadai.entity.model.*; +import com.huoran.nakadai.entity.order.SubmitOrderOrder; +import com.huoran.nakadai.event.SubmitOrderEvent; +import com.huoran.nakadai.mapper.*; +import com.huoran.nakadai.service.ProductService; +import com.huoran.nakadai.service.SkuService; +import com.huoran.nakadai.utils.Arith; +import lombok.AllArgsConstructor; +import org.springframework.context.event.EventListener; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import java.util.*; + +/** + * 确认订单信息时的默认操作 + * + * @author LGH + */ +@Component("defaultSubmitOrderListener") +@AllArgsConstructor +public class SubmitOrderListener { + + + + +// private final UserAddrOrderService userAddrOrderService; + + private final ProductService productService; + + private final SkuService skuService; + + private final Snowflake snowflake; + + private final OrderItemMapper orderItemMapper; + + private final SkuMapper skuMapper; + + private final ProductMapper productMapper; + + private final OrderMapper orderMapper; + + private final OrderSettlementMapper orderSettlementMapper; + + private final BasketMapper basketMapper; + + /** + * 计算订单金额 + */ + @EventListener(SubmitOrderEvent.class) + @Order(SubmitOrderOrder.DEFAULT) + public void defaultSubmitOrderListener(SubmitOrderEvent event) { + Date now = new Date(); + String userId = SecurityUtils.getCurrentInfo().getAccountId(); + ShopCartOrderMergerDto mergerOrder = event.getMergerOrder(); + + // 订单商品参数 + List shopCartOrders = mergerOrder.getShopCartOrders(); + + List basketIds = new ArrayList<>(); + // 商品skuId为key 需要更新的sku为value的map + Map skuStocksMap = new HashMap<>(16); + // 商品productId为key 需要更新的product为value的map + Map prodStocksMap = new HashMap<>(16); + + // 把订单地址保存到数据库 +// UserAddrOrder userAddrOrder = BeanUtil.copyProperties(mergerOrder.getUserAddr(), UserAddrOrder.class); +// if (userAddrOrder == null) { +// throw new YamiShopBindException("请填写收货地址"); +// } +// userAddrOrder.setUserId(userId); +// userAddrOrder.setCreateTime(now); +// userAddrOrderService.save(userAddrOrder); + + // 订单地址id +// Long addrOrderId = userAddrOrder.getAddrOrderId(); + + + // 每个店铺生成一个订单 + for (ShopCartOrderDto shopCartOrderDto : shopCartOrders) { + createOrder(event, now, userId, basketIds, skuStocksMap, prodStocksMap, 0L, shopCartOrderDto); + + } + + // 删除购物车的商品信息 + if (!basketIds.isEmpty()) { + basketMapper.deleteShopCartItemsByBasketIds(userId, basketIds); + + } + + + // 更新sku库存 + skuStocksMap.forEach((key, sku) -> { + + if (skuMapper.updateStocks(sku) == 0) { + skuService.removeSkuCacheBySkuId(key, sku.getProdId()); + throw new YamiShopBindException("商品:[" + sku.getProdName() + "]库存不足"); + } + }); + + // 更新商品库存 + prodStocksMap.forEach((prodId, prod) -> { + + if (productMapper.updateStocks(prod) == 0) { + productService.removeProductCacheByProdId(prodId); + throw new YamiShopBindException("商品:[" + prod.getProdName() + "]库存不足"); + } + }); + + } + + private void createOrder(SubmitOrderEvent event, Date now, String userId, List basketIds, Map skuStocksMap, Map prodStocksMap, Long addrOrderId, ShopCartOrderDto shopCartOrderDto) { + // 使用雪花算法生成的订单号 + String orderNumber = String.valueOf(snowflake.nextId()); + shopCartOrderDto.setOrderNumber(orderNumber); + + Integer shopId = shopCartOrderDto.getShopId(); + + // 订单商品名称 + StringBuilder orderProdName = new StringBuilder(100); + + List orderItems = new ArrayList<>(); + + List shopCartItemDiscounts = shopCartOrderDto.getShopCartItemDiscounts(); + for (ShopCartItemDiscountDto shopCartItemDiscount : shopCartItemDiscounts) { + List shopCartItems = shopCartItemDiscount.getShopCartItems(); + for (ShopCartItemDto shopCartItem : shopCartItems) { + Sku sku = checkAndGetSku(shopCartItem.getSkuId(), shopCartItem, skuStocksMap); + Product product = checkAndGetProd(shopCartItem.getProdId(), shopCartItem, prodStocksMap); + + OrderItem orderItem = getOrderItem(now, userId, orderNumber, shopId, orderProdName, shopCartItem, sku, product); + + orderItems.add(orderItem); + + if (shopCartItem.getBasketId() != null && shopCartItem.getBasketId() != 0) { + basketIds.add(shopCartItem.getBasketId()); + } + } + + } + + + orderProdName.subSequence(0, Math.min(orderProdName.length() - 1, 100)); + if (orderProdName.lastIndexOf(Constant.COMMA) == orderProdName.length() - 1) { + orderProdName.deleteCharAt(orderProdName.length() - 1); + } + + + // 订单信息 + com.huoran.nakadai.entity.model.Order order = getOrder(now, userId, addrOrderId, shopCartOrderDto, orderNumber, shopId, orderProdName, orderItems); + event.getOrders().add(order); + // 插入订单结算表 + OrderSettlement orderSettlement = new OrderSettlement(); + orderSettlement.setUserId(userId); + orderSettlement.setIsClearing(0); + orderSettlement.setCreateTime(now); + orderSettlement.setOrderNumber(orderNumber); + orderSettlement.setPayAmount(order.getActualTotal()); + orderSettlement.setPayStatus(0); + orderSettlement.setVersion(0); + orderSettlementMapper.insert(orderSettlement); + } + + private com.huoran.nakadai.entity.model.Order getOrder(Date now, String userId, Long addrOrderId, ShopCartOrderDto shopCartOrderDto, String orderNumber, Integer shopId, StringBuilder orderProdName, List orderItems) { + com.huoran.nakadai.entity.model.Order order = new com.huoran.nakadai.entity.model.Order(); + + order.setShopId(shopId); + order.setOrderNumber(orderNumber); + // 订单商品名称 + order.setProdName(orderProdName.toString()); + // 用户id + order.setUserId(userId); + // 商品总额 + order.setTotal(shopCartOrderDto.getTotal()); + // 实际总额 + order.setActualTotal(shopCartOrderDto.getActualTotal()); + order.setStatus(OrderStatus.UNPAY.value()); + order.setUpdateTime(now); + order.setCreateTime(now); + order.setIsPayed(0); + order.setDeleteStatus(0); + order.setProductNums(shopCartOrderDto.getTotalCount()); + order.setAddrOrderId(addrOrderId); + order.setReduceAmount(Arith.sub(Arith.add(shopCartOrderDto.getTotal(), shopCartOrderDto.getTransfee()), shopCartOrderDto.getActualTotal())); + order.setFreightAmount(shopCartOrderDto.getTransfee()); + order.setRemarks(shopCartOrderDto.getRemarks()); + + order.setOrderItems(orderItems); + return order; + } + + private OrderItem getOrderItem(Date now, String userId, String orderNumber, Integer shopId, StringBuilder orderProdName, ShopCartItemDto shopCartItem, Sku sku, Product product) { + OrderItem orderItem = new OrderItem(); + orderItem.setShopId(shopId); + orderItem.setOrderNumber(orderNumber); + orderItem.setProdId(sku.getProdId()); + orderItem.setSkuId(sku.getSkuId()); + orderItem.setSkuName(sku.getSkuName()); + orderItem.setProdCount(shopCartItem.getProdCount()); + orderItem.setProdName(sku.getProdName()); + orderItem.setPic(StrUtil.isBlank(sku.getPic()) ? product.getPic() : sku.getPic()); + orderItem.setPrice(shopCartItem.getPrice()); + orderItem.setUserId(userId); + orderItem.setProductTotalAmount(shopCartItem.getProductTotalAmount()); + orderItem.setRecTime(now); + orderItem.setCommSts(0); + orderItem.setBasketDate(shopCartItem.getBasketDate()); + orderProdName.append(orderItem.getProdName()).append(","); + //推广员卡号 + orderItem.setDistributionCardNo(shopCartItem.getDistributionCardNo()); + return orderItem; + } + + @SuppressWarnings({"Duplicates"}) + private Product checkAndGetProd(Integer prodId, ShopCartItemDto shopCartItem, Map prodStocksMap) { + Product product = productService.getProductByProdId(prodId); + if (product == null) { + throw new YamiShopBindException("购物车包含无法识别的商品"); + } + + if (product.getStatus() != 1) { + throw new YamiShopBindException("商品[" + product.getProdName() + "]已下架"); + } + + // 商品需要改变的库存 + Product mapProduct = prodStocksMap.get(prodId); + + if (mapProduct == null) { + mapProduct = new Product(); + mapProduct.setTotalStocks(0); + mapProduct.setProdId(prodId); + mapProduct.setProdName(product.getProdName()); + + } + + if (product.getTotalStocks() != -1) { + mapProduct.setTotalStocks(mapProduct.getTotalStocks() + shopCartItem.getProdCount()); + prodStocksMap.put(product.getProdId(), mapProduct); + } + + // -1为无限库存 + if (product.getTotalStocks() != -1 && mapProduct.getTotalStocks() > product.getTotalStocks()) { + throw new YamiShopBindException("商品:[" + product.getProdName() + "]库存不足"); + } + + return product; + } + + @SuppressWarnings({"Duplicates"}) + private Sku checkAndGetSku(Integer skuId, ShopCartItemDto shopCartItem, Map skuStocksMap) { + // 获取sku信息 + Sku sku = skuService.getSkuBySkuId(skuId); + if (sku == null) { + throw new YamiShopBindException("购物车包含无法识别的商品"); + } + + if (sku.getStatus() != 1) { + throw new YamiShopBindException("商品[" + sku.getProdName() + "]已下架"); + } + // -1为无限库存 + if (sku.getStocks() != -1 && shopCartItem.getProdCount() > sku.getStocks()) { + throw new YamiShopBindException("商品:[" + sku.getProdName() + "]库存不足"); + } + + if (sku.getStocks() != -1) { + Sku mapSku = new Sku(); + mapSku.setProdId(sku.getProdId()); + // 这里的库存是改变的库存 + mapSku.setStocks(shopCartItem.getProdCount()); + mapSku.setSkuId(sku.getSkuId()); + mapSku.setProdName(sku.getProdName()); + skuStocksMap.put(sku.getSkuId(), mapSku); + } + return sku; + } + + +} diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/BasketMapper.java b/nakadai/src/main/java/com/huoran/nakadai/mapper/BasketMapper.java index 1b84c8d..e15cc23 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/mapper/BasketMapper.java +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/BasketMapper.java @@ -37,7 +37,7 @@ public interface BasketMapper extends BaseMapper { * @param userId 用户id * @param basketIds 购物车id列表 */ - void deleteShopCartItemsByBasketIds(@Param("userId") String userId, @Param("basketIds") List basketIds); + void deleteShopCartItemsByBasketIds(@Param("userId") String userId, @Param("basketIds") List basketIds); /** * 删除所有购物车 diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/CurriculumMapper.java b/nakadai/src/main/java/com/huoran/nakadai/mapper/CurriculumMapper.java index 8363573..d34b795 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/mapper/CurriculumMapper.java +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/CurriculumMapper.java @@ -6,6 +6,7 @@ import com.huoran.nakadai.entity.Curriculum; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.huoran.nakadai.entity.req.PageCurriculumReq; import com.huoran.nakadai.entity.res.CurriculumRes; +import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -19,6 +20,7 @@ import java.util.Set; * @author lr * @since 2021-09-16 */ +@Mapper public interface CurriculumMapper extends BaseMapper { IPage curriculumList(Page page, @Param("req") PageCurriculumReq req); diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/CustomerMapper.java b/nakadai/src/main/java/com/huoran/nakadai/mapper/CustomerMapper.java index d04e274..486933a 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/mapper/CustomerMapper.java +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/CustomerMapper.java @@ -3,9 +3,8 @@ package com.huoran.nakadai.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.huoran.common.entity.UserAccount; import com.huoran.nakadai.entity.Customer; -import com.huoran.nakadai.entity.HrUserAccount; -import com.huoran.nakadai.entity.UserAccount; import com.huoran.nakadai.entity.req.CustomerListReq; import com.huoran.nakadai.entity.req.ListOfClientCommercialManagersReq; import com.huoran.nakadai.entity.req.SalesProgressReq; @@ -36,11 +35,11 @@ public interface CustomerMapper extends BaseMapper { int delCustomers(@Param("ids") List ids); - boolean insertUserAccount(HrUserAccount account); + boolean insertUserAccount(UserAccount account); int queryAccountExists(String account); - int updatePwdByCustomerId(HrUserAccount hrUserAccount); + int updatePwdByCustomerId(UserAccount hrUserAccount); boolean updateDelById(Integer customerId); diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/EnterpriseCertificationMapper.java b/nakadai/src/main/java/com/huoran/nakadai/mapper/EnterpriseCertificationMapper.java index 908675e..ab75a9c 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/mapper/EnterpriseCertificationMapper.java +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/EnterpriseCertificationMapper.java @@ -2,8 +2,8 @@ package com.huoran.nakadai.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.huoran.common.entity.UserAccount; import com.huoran.nakadai.entity.EnterpriseCertification; -import com.huoran.nakadai.entity.UserAccount; import com.huoran.nakadai.entity.UserInfo; import com.huoran.nakadai.entity.req.EnterpriseCertificationLIstReq; import org.apache.ibatis.annotations.Mapper; diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/HrStaffAccountArchitectureMapper.java b/nakadai/src/main/java/com/huoran/nakadai/mapper/HrStaffAccountArchitectureMapper.java index ffcea82..0cd096c 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/mapper/HrStaffAccountArchitectureMapper.java +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/HrStaffAccountArchitectureMapper.java @@ -2,6 +2,7 @@ package com.huoran.nakadai.mapper; import com.huoran.nakadai.entity.HrStaffAccountArchitecture; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; import java.util.List; @@ -13,6 +14,7 @@ import java.util.List; * @author chen * @since 2022-03-22 */ +@Mapper public interface HrStaffAccountArchitectureMapper extends BaseMapper { List selectIdByPid(Integer id); diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/HrStaffDepartmentMapper.java b/nakadai/src/main/java/com/huoran/nakadai/mapper/HrStaffDepartmentMapper.java index 3196a14..237b04a 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/mapper/HrStaffDepartmentMapper.java +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/HrStaffDepartmentMapper.java @@ -2,6 +2,7 @@ package com.huoran.nakadai.mapper; import com.huoran.nakadai.entity.HrStaffDepartment; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; /** *

@@ -11,6 +12,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; * @author chen * @since 2022-03-23 */ +@Mapper public interface HrStaffDepartmentMapper extends BaseMapper { } diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/HrStaffMapper.java b/nakadai/src/main/java/com/huoran/nakadai/mapper/HrStaffMapper.java index 27dd59e..1a1382f 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/mapper/HrStaffMapper.java +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/HrStaffMapper.java @@ -2,9 +2,9 @@ package com.huoran.nakadai.mapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.huoran.common.entity.UserAccount; import com.huoran.nakadai.entity.HrStaff; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.huoran.nakadai.entity.UserAccount; import com.huoran.nakadai.entity.UserInfo; import com.huoran.nakadai.entity.req.StaffListReq; import com.huoran.nakadai.entity.res.StaffResp; diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamAccountMapper.java b/nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamAccountMapper.java index 280b776..4b5eae3 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamAccountMapper.java +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamAccountMapper.java @@ -2,9 +2,9 @@ package com.huoran.nakadai.mapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.huoran.common.entity.UserAccount; import com.huoran.nakadai.entity.PlatformTeamAccount; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.huoran.nakadai.entity.UserAccount; import com.huoran.nakadai.entity.req.PlatformTeamAccountListReq; import com.huoran.nakadai.entity.res.PlatformTeamAccountResp; import com.huoran.nakadai.entity.res.TeamAccountResp; @@ -12,7 +12,6 @@ import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.ArrayList; -import java.util.Date; import java.util.List; /** diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamClassificationMapper.java b/nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamClassificationMapper.java index 7aa5062..f60e338 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamClassificationMapper.java +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamClassificationMapper.java @@ -1,6 +1,6 @@ package com.huoran.nakadai.mapper; -import com.huoran.nakadai.entity.HrUserAccount; +import com.huoran.common.entity.UserAccount; import com.huoran.nakadai.entity.PlatformTeamClassification; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; @@ -23,5 +23,5 @@ public interface PlatformTeamClassificationMapper extends BaseMapper selectAccountList(@Param("openId")String openId); + List selectAccountList(@Param("openId")String openId); } diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/CustomerMapper.xml b/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/CustomerMapper.xml index 4c5a6fc..20b9a6e 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/CustomerMapper.xml +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/CustomerMapper.xml @@ -131,7 +131,7 @@ - insert into hr_user_account(customer_id, user_id, account, password, school_id, role_id, create_time, update_time, platform_id) @@ -146,7 +146,7 @@ AND is_del = 0 - + UPDATE hr_user_account set password = #{password} WHERE customer_id = #{customerId} @@ -247,7 +247,7 @@ - select * from hr_user_account where customer_id = #{customerId} diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/EnterpriseCertificationMapper.xml b/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/EnterpriseCertificationMapper.xml index 84000cd..6e37417 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/EnterpriseCertificationMapper.xml +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/EnterpriseCertificationMapper.xml @@ -137,7 +137,7 @@ WHERE t.id = #{id} - SELECT * FROM diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/HrStaffMapper.xml b/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/HrStaffMapper.xml index 555e70d..4de8894 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/HrStaffMapper.xml +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/HrStaffMapper.xml @@ -11,7 +11,7 @@ - INSERT INTO nakadai.hr_user_account(user_id, account,phone , password, work_number, school_id, platform_id, type, create_time, update_time,app_open_id) @@ -26,7 +26,7 @@ where user_id = #{userId} - + UPDATE nakadai.hr_user_account @@ -138,8 +138,8 @@ - SELECT * from hr_user_account WHERE is_del = 0 diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamAccountMapper.xml b/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamAccountMapper.xml index 9a456a8..756939e 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamAccountMapper.xml +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamAccountMapper.xml @@ -51,12 +51,12 @@ ORDER BY hpa.manage_id DESC - SELECT * from hr_user_account WHERE is_del = 0 and platform_id = #{platformId} and phone = #{phone} - SELECT * from hr_user_account WHERE is_del = 0 and platform_id = #{platformId} and app_open_id = #{openid} @@ -175,7 +175,7 @@ a.app_open_id = #{openId} AND a.platform_id = #{platformId} and tc.is_team = 1 and ta.is_del = 0 - SELECT * from hr_user_account WHERE is_del = 0 and id = #{accountId} diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamClassificationMapper.xml b/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamClassificationMapper.xml index 49bed54..7459183 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamClassificationMapper.xml +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamClassificationMapper.xml @@ -29,7 +29,7 @@ ORDER BY T1.lvl DESC - select * from hr_user_account WHERE is_del = 0 and app_open_id = #{openId} diff --git a/nakadai/src/main/java/com/huoran/nakadai/service/BasketService.java b/nakadai/src/main/java/com/huoran/nakadai/service/BasketService.java index abb8aa3..8152e54 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/service/BasketService.java +++ b/nakadai/src/main/java/com/huoran/nakadai/service/BasketService.java @@ -32,7 +32,7 @@ public interface BasketService extends IService { * @param userId 用户id * @param basketIds 购物车id列表 */ - void deleteShopCartItemsByBasketIds(String userId, List basketIds); + void deleteShopCartItemsByBasketIds(String userId, List basketIds); /** * 添加购物车 diff --git a/nakadai/src/main/java/com/huoran/nakadai/service/EnterpriseCertificationService.java b/nakadai/src/main/java/com/huoran/nakadai/service/EnterpriseCertificationService.java index fd9ec77..a117b7a 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/service/EnterpriseCertificationService.java +++ b/nakadai/src/main/java/com/huoran/nakadai/service/EnterpriseCertificationService.java @@ -1,12 +1,11 @@ package com.huoran.nakadai.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.huoran.common.entity.UserAccount; import com.huoran.common.response.R; import com.huoran.nakadai.entity.EnterpriseCertification; -import com.huoran.nakadai.entity.UserAccount; import com.huoran.nakadai.entity.UserInfo; import com.huoran.nakadai.entity.req.EnterpriseCertificationLIstReq; -import org.apache.ibatis.annotations.Param; /** *

@@ -25,7 +24,7 @@ public interface EnterpriseCertificationService extends IService selectAccountList(String openId); + List selectAccountList(String openId); } diff --git a/nakadai/src/main/java/com/huoran/nakadai/service/impl/BasketServiceImpl.java b/nakadai/src/main/java/com/huoran/nakadai/service/impl/BasketServiceImpl.java index 7265b65..3bd454e 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/service/impl/BasketServiceImpl.java +++ b/nakadai/src/main/java/com/huoran/nakadai/service/impl/BasketServiceImpl.java @@ -63,7 +63,7 @@ public class BasketServiceImpl extends ServiceImpl impleme @Override @CacheEvict(cacheNames = "ShopCartItems", key = "#userId") - public void deleteShopCartItemsByBasketIds(String userId, List basketIds) { + public void deleteShopCartItemsByBasketIds(String userId, List basketIds) { basketMapper.deleteShopCartItemsByBasketIds(userId, basketIds); } @@ -183,7 +183,7 @@ public class BasketServiceImpl extends ServiceImpl impleme // 拿到购物车的所有item ShopCartItemDto shopCartItemDto = new ShopCartItemDto(); - shopCartItemDto.setBasketId(-1L); + shopCartItemDto.setBasketId(-1); shopCartItemDto.setSkuId(orderItem.getSkuId()); shopCartItemDto.setProdCount(orderItem.getProdCount()); shopCartItemDto.setProdId(orderItem.getProdId()); @@ -192,7 +192,7 @@ public class BasketServiceImpl extends ServiceImpl impleme shopCartItemDto.setProdName(sku.getProdName()); shopCartItemDto.setProductTotalAmount(Arith.mul(sku.getPrice(),orderItem.getProdCount())); shopCartItemDto.setPrice(sku.getPrice()); - shopCartItemDto.setDistributionCardNo(orderItem.getDistributionCardNo()); +// shopCartItemDto.setDistributionCardNo(orderItem.getDistributionCardNo()); shopCartItemDto.setBasketDate(new Date()); ShopDetail shopDetail = shopDetailService.getShopDetailByShopId(orderItem.getShopId()); shopCartItemDto.setShopId(shopDetail.getShopId()); diff --git a/nakadai/src/main/java/com/huoran/nakadai/service/impl/CustomerServiceImpl.java b/nakadai/src/main/java/com/huoran/nakadai/service/impl/CustomerServiceImpl.java index e61b962..9a3514d 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/service/impl/CustomerServiceImpl.java +++ b/nakadai/src/main/java/com/huoran/nakadai/service/impl/CustomerServiceImpl.java @@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.huoran.api.OccupationlabClient; import com.huoran.api.UserClient; +import com.huoran.common.entity.UserAccount; import com.huoran.common.exception.CustomException; import com.huoran.common.exception.ExceptionEnum; import com.huoran.common.response.R; @@ -120,7 +121,7 @@ public class CustomerServiceImpl extends ServiceImpl i baseMapper.insert(customer); //将账号密码以及学校id添加到账号表 - HrUserAccount account = new HrUserAccount(); + UserAccount account = new UserAccount(); account.setAccount(customerReq.getAccount()); account.setPassword(MD5.encrypt("1122aa")); account.setSchoolId(customerReq.getSchoolId()); @@ -220,7 +221,7 @@ public class CustomerServiceImpl extends ServiceImpl i @Override public int resetPwd(Integer customerId) { //根据客户id修改所有的账号密码 - HrUserAccount hrUserAccount = new HrUserAccount(); + UserAccount hrUserAccount = new UserAccount(); hrUserAccount.setCustomerId(customerId); hrUserAccount.setPassword(MD5.encrypt("1122aa")); return baseMapper.updatePwdByCustomerId(hrUserAccount); diff --git a/nakadai/src/main/java/com/huoran/nakadai/service/impl/EnterpriseCertificationServiceImpl.java b/nakadai/src/main/java/com/huoran/nakadai/service/impl/EnterpriseCertificationServiceImpl.java index 6a28750..5a834fb 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/service/impl/EnterpriseCertificationServiceImpl.java +++ b/nakadai/src/main/java/com/huoran/nakadai/service/impl/EnterpriseCertificationServiceImpl.java @@ -4,9 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.huoran.common.entity.UserAccount; import com.huoran.common.response.R; import com.huoran.nakadai.entity.EnterpriseCertification; -import com.huoran.nakadai.entity.UserAccount; import com.huoran.nakadai.entity.UserInfo; import com.huoran.nakadai.entity.req.EnterpriseCertificationLIstReq; import com.huoran.nakadai.mapper.EnterpriseCertificationMapper; diff --git a/nakadai/src/main/java/com/huoran/nakadai/service/impl/HrStaffServiceImpl.java b/nakadai/src/main/java/com/huoran/nakadai/service/impl/HrStaffServiceImpl.java index bb20bd6..64a95d4 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/service/impl/HrStaffServiceImpl.java +++ b/nakadai/src/main/java/com/huoran/nakadai/service/impl/HrStaffServiceImpl.java @@ -13,6 +13,7 @@ import com.google.common.collect.Maps; import com.huoran.api.UserClient; import com.huoran.common.constant.DelConstant; import com.huoran.common.entity.Role; +import com.huoran.common.entity.UserAccount; import com.huoran.common.exception.CustomException; import com.huoran.common.exception.ExceptionEnum; import com.huoran.common.response.R; diff --git a/nakadai/src/main/java/com/huoran/nakadai/service/impl/PartnerAccountServiceImpl.java b/nakadai/src/main/java/com/huoran/nakadai/service/impl/PartnerAccountServiceImpl.java index c520dc0..867f71d 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/service/impl/PartnerAccountServiceImpl.java +++ b/nakadai/src/main/java/com/huoran/nakadai/service/impl/PartnerAccountServiceImpl.java @@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.huoran.api.UserClient; import com.huoran.common.constant.DelConstant; import com.huoran.common.constant.SMSTemplate; +import com.huoran.common.entity.UserAccount; import com.huoran.common.exception.CustomException; import com.huoran.common.exception.ExceptionEnum; import com.huoran.common.response.R; diff --git a/nakadai/src/main/java/com/huoran/nakadai/service/impl/PlatformTeamAccountServiceImpl.java b/nakadai/src/main/java/com/huoran/nakadai/service/impl/PlatformTeamAccountServiceImpl.java index 8410114..19f6833 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/service/impl/PlatformTeamAccountServiceImpl.java +++ b/nakadai/src/main/java/com/huoran/nakadai/service/impl/PlatformTeamAccountServiceImpl.java @@ -2,7 +2,6 @@ package com.huoran.nakadai.service.impl; import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.RandomUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -10,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.huoran.common.constant.SMSTemplate; +import com.huoran.common.entity.UserAccount; import com.huoran.common.exception.CustomException; import com.huoran.common.exception.ExceptionEnum; import com.huoran.common.response.R; @@ -98,12 +98,12 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl userAccountList = platformTeamClassificationMapper.selectAccountList(openid); - for (HrUserAccount userAccount : userAccountList) { + List userAccountList = platformTeamClassificationMapper.selectAccountList(openid); + for (UserAccount userAccount : userAccountList) { if(userAccount.getPlatformId().equals(platformId.toString())){ if (!userAccount.getIsEnable()){ if (platformId == 7) { // 如果个人账号被禁用,抛出异常 diff --git a/nakadai/src/main/java/com/huoran/nakadai/service/impl/PlatformTeamClassificationServiceImpl.java b/nakadai/src/main/java/com/huoran/nakadai/service/impl/PlatformTeamClassificationServiceImpl.java index 4fb3c83..ad4bc69 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/service/impl/PlatformTeamClassificationServiceImpl.java +++ b/nakadai/src/main/java/com/huoran/nakadai/service/impl/PlatformTeamClassificationServiceImpl.java @@ -1,6 +1,6 @@ package com.huoran.nakadai.service.impl; -import com.huoran.nakadai.entity.HrUserAccount; +import com.huoran.common.entity.UserAccount; import com.huoran.nakadai.entity.PlatformTeamClassification; import com.huoran.nakadai.mapper.PlatformTeamClassificationMapper; import com.huoran.nakadai.service.PlatformTeamClassificationService; @@ -25,7 +25,7 @@ public class PlatformTeamClassificationServiceImpl extends ServiceImpl selectAccountList(String openId) { + public List selectAccountList(String openId) { return baseMapper.selectAccountList(openId); } }