用户账号实体类统一管理

main
cheney 11 months ago
parent 40f5df5bf6
commit 9b0c64d2f7
  1. 16
      common/src/main/java/com/huoran/common/constant/Constant.java
  2. 38
      common/src/main/java/com/huoran/common/constant/OauthCacheNames.java
  3. 11
      common/src/main/java/com/huoran/common/entity/CurrentInfo.java
  4. 22
      common/src/main/java/com/huoran/common/entity/UserAccount.java
  5. 32
      common/src/main/java/com/huoran/common/utils/SecurityUtils.java
  6. 3
      nakadai/src/main/java/com/huoran/nakadai/controller/AliRealNameAuthenticationController.java
  7. 5
      nakadai/src/main/java/com/huoran/nakadai/controller/EnterpriseCertificationController.java
  8. 152
      nakadai/src/main/java/com/huoran/nakadai/controller/OrderController.java
  9. 6
      nakadai/src/main/java/com/huoran/nakadai/controller/PlatformTeamAccountController.java
  10. 93
      nakadai/src/main/java/com/huoran/nakadai/entity/HrUserAccount.java
  11. 90
      nakadai/src/main/java/com/huoran/nakadai/entity/UserAccount.java
  12. 2
      nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/ProductItemDto.java
  13. 2
      nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/ShopCartItemDto.java
  14. 12
      nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/ShopCartOrderMergerDto.java
  15. 4
      nakadai/src/main/java/com/huoran/nakadai/entity/app/param/OrderItemParam.java
  16. 18
      nakadai/src/main/java/com/huoran/nakadai/entity/app/param/OrderParam.java
  17. 38
      nakadai/src/main/java/com/huoran/nakadai/entity/order/ConfirmOrderOrder.java
  18. 28
      nakadai/src/main/java/com/huoran/nakadai/entity/order/ShopCartEventOrder.java
  19. 33
      nakadai/src/main/java/com/huoran/nakadai/entity/order/SubmitOrderOrder.java
  20. 26
      nakadai/src/main/java/com/huoran/nakadai/event/CancelOrderEvent.java
  21. 44
      nakadai/src/main/java/com/huoran/nakadai/event/ConfirmOrderEvent.java
  22. 28
      nakadai/src/main/java/com/huoran/nakadai/event/PaySuccessOrderEvent.java
  23. 27
      nakadai/src/main/java/com/huoran/nakadai/event/ReceiptOrderEvent.java
  24. 38
      nakadai/src/main/java/com/huoran/nakadai/event/ShopCartEvent.java
  25. 34
      nakadai/src/main/java/com/huoran/nakadai/event/SubmitOrderEvent.java
  26. 99
      nakadai/src/main/java/com/huoran/nakadai/listener/ConfirmOrderListener.java
  27. 54
      nakadai/src/main/java/com/huoran/nakadai/listener/ShopCartListener.java
  28. 304
      nakadai/src/main/java/com/huoran/nakadai/listener/SubmitOrderListener.java
  29. 2
      nakadai/src/main/java/com/huoran/nakadai/mapper/BasketMapper.java
  30. 2
      nakadai/src/main/java/com/huoran/nakadai/mapper/CurriculumMapper.java
  31. 7
      nakadai/src/main/java/com/huoran/nakadai/mapper/CustomerMapper.java
  32. 2
      nakadai/src/main/java/com/huoran/nakadai/mapper/EnterpriseCertificationMapper.java
  33. 2
      nakadai/src/main/java/com/huoran/nakadai/mapper/HrStaffAccountArchitectureMapper.java
  34. 2
      nakadai/src/main/java/com/huoran/nakadai/mapper/HrStaffDepartmentMapper.java
  35. 2
      nakadai/src/main/java/com/huoran/nakadai/mapper/HrStaffMapper.java
  36. 3
      nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamAccountMapper.java
  37. 4
      nakadai/src/main/java/com/huoran/nakadai/mapper/PlatformTeamClassificationMapper.java
  38. 6
      nakadai/src/main/java/com/huoran/nakadai/mapper/xml/CustomerMapper.xml
  39. 2
      nakadai/src/main/java/com/huoran/nakadai/mapper/xml/EnterpriseCertificationMapper.xml
  40. 8
      nakadai/src/main/java/com/huoran/nakadai/mapper/xml/HrStaffMapper.xml
  41. 6
      nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamAccountMapper.xml
  42. 2
      nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamClassificationMapper.xml
  43. 2
      nakadai/src/main/java/com/huoran/nakadai/service/BasketService.java
  44. 3
      nakadai/src/main/java/com/huoran/nakadai/service/EnterpriseCertificationService.java
  45. 4
      nakadai/src/main/java/com/huoran/nakadai/service/PlatformTeamClassificationService.java
  46. 6
      nakadai/src/main/java/com/huoran/nakadai/service/impl/BasketServiceImpl.java
  47. 5
      nakadai/src/main/java/com/huoran/nakadai/service/impl/CustomerServiceImpl.java
  48. 2
      nakadai/src/main/java/com/huoran/nakadai/service/impl/EnterpriseCertificationServiceImpl.java
  49. 1
      nakadai/src/main/java/com/huoran/nakadai/service/impl/HrStaffServiceImpl.java
  50. 1
      nakadai/src/main/java/com/huoran/nakadai/service/impl/PartnerAccountServiceImpl.java
  51. 8
      nakadai/src/main/java/com/huoran/nakadai/service/impl/PlatformTeamAccountServiceImpl.java
  52. 4
      nakadai/src/main/java/com/huoran/nakadai/service/impl/PlatformTeamClassificationServiceImpl.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 = ",";
}

@ -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:";
}

@ -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;
}

@ -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;
}

@ -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;
}
}

@ -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;

@ -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;

@ -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<ShopCartOrderMergerDto> 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<ShopCartItemDto> shopCartItems = basketService.getShopCartItemsByOrderItems(orderParam.getBasketIds(),orderParam.getOrderItem(),userId);
//
// if (CollectionUtil.isEmpty(shopCartItems)) {
// throw new YamiShopBindException("请选择您需要的商品加入购物车");
// }
//
// // 根据店铺组装购车中的商品信息,返回每个店铺中的购物车商品信息
// List<ShopCartDto> shopCarts = basketService.getShopCarts(shopCartItems);
//
// // 将要返回给前端的完整的订单信息
// ShopCartOrderMergerDto shopCartOrderMergerDto = new ShopCartOrderMergerDto();
//
// shopCartOrderMergerDto.setUserAddr(userAddrDto);
//
// // 所有店铺的订单信息
// List<ShopCartOrderDto> 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<ShopCartItemDiscountDto> shopCartItemDiscounts = shopCart.getShopCartItemDiscounts();
//
// // 店铺中的所有商品项信息
// List<ShopCartItemDto> shopAllShopCartItems = new ArrayList<>();
// for (ShopCartItemDiscountDto shopCartItemDiscount : shopCartItemDiscounts) {
// List<ShopCartItemDto> 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<ShopCartOrderMergerDto> confirm(
@Valid @RequestBody OrderParam orderParam) {
String userId = SecurityUtils.getCurrentInfo().getAccountId();
// 组装获取用户提交的购物车商品项
List<ShopCartItemDto> shopCartItems = basketService.getShopCartItemsByOrderItems(null,orderParam.getOrderItem(),userId);
if (CollectionUtil.isEmpty(shopCartItems)) {
throw new YamiShopBindException("请选择您需要的商品加入购物车");
}
// 根据店铺组装购车中的商品信息,返回每个店铺中的购物车商品信息
List<ShopCartDto> shopCarts = basketService.getShopCarts(shopCartItems);
// 将要返回给前端的完整的订单信息
ShopCartOrderMergerDto shopCartOrderMergerDto = new ShopCartOrderMergerDto();
// 所有店铺的订单信息
List<ShopCartOrderDto> 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<ShopCartItemDiscountDto> shopCartItemDiscounts = shopCart.getShopCartItemDiscounts();
// 店铺中的所有商品项信息
List<ShopCartItemDto> shopAllShopCartItems = new ArrayList<>();
for (ShopCartItemDiscountDto shopCartItemDiscount : shopCartItemDiscounts) {
List<ShopCartItemDto> 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);
}
/**
* 分页获取

@ -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<HrUserAccount> userAccountList = platformTeamClassificationService.selectAccountList(openId);
for (HrUserAccount userAccount : userAccountList) {
List<UserAccount> userAccountList = platformTeamClassificationService.selectAccountList(openId);
for (UserAccount userAccount : userAccountList) {
int status = 1;
if (isEnable==1){
status=0;

@ -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;
/**
* <p>
* 各个平台账号表
* </p>
*
* @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;
}

@ -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;
}

@ -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;

@ -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;

@ -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<ShopCartOrderDto> shopCartOrders;
@ApiModelProperty(value = "整个订单可以使用的优惠券列表" , required = true)
private List<CouponOrderDto> coupons;
//
// @ApiModelProperty(value = "整个订单可以使用的优惠券列表" , required = true)
// private List<CouponOrderDto> coupons;
}

@ -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;
}

@ -24,21 +24,21 @@ import java.util.List;
public class OrderParam {
@ApiModelProperty(value = "购物车id 数组" )
private List<Long> basketIds;
// @ApiModelProperty(value = "购物车id 数组" )
// private List<Integer> 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<Long> couponIds;
// @ApiModelProperty(value = "优惠券id数组" )
// private List<Long> couponIds;
// @Schema(description = "每次订单提交时的uuid" )
// private String uuid;

@ -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;
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -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<ShopCartItemDto> shopCartItems;
}

@ -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<Order> orders;
}

@ -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;
}

@ -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<ShopCartItemDto> shopCartItemDtoList;
}

@ -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<Order> orders;
}

@ -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);
}
}
}

@ -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<ShopCartItemDto> shopCartItemDtoList = event.getShopCartItemDtoList();
// 对数据进行组装
List<ShopCartItemDiscountDto> shopCartItemDiscountDtoList = Lists.newArrayList();
ShopCartItemDiscountDto shopCartItemDiscountDto = new ShopCartItemDiscountDto();
shopCartItemDiscountDto.setShopCartItems(shopCartItemDtoList);
shopCartItemDiscountDtoList.add(shopCartItemDiscountDto);
shopCart.setShopCartItemDiscounts(shopCartItemDiscountDtoList);
}
}

@ -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<ShopCartOrderDto> shopCartOrders = mergerOrder.getShopCartOrders();
List<Integer> basketIds = new ArrayList<>();
// 商品skuId为key 需要更新的sku为value的map
Map<Integer, Sku> skuStocksMap = new HashMap<>(16);
// 商品productId为key 需要更新的product为value的map
Map<Integer, Product> 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<Integer> basketIds, Map<Integer, Sku> skuStocksMap, Map<Integer, Product> prodStocksMap, Long addrOrderId, ShopCartOrderDto shopCartOrderDto) {
// 使用雪花算法生成的订单号
String orderNumber = String.valueOf(snowflake.nextId());
shopCartOrderDto.setOrderNumber(orderNumber);
Integer shopId = shopCartOrderDto.getShopId();
// 订单商品名称
StringBuilder orderProdName = new StringBuilder(100);
List<OrderItem> orderItems = new ArrayList<>();
List<ShopCartItemDiscountDto> shopCartItemDiscounts = shopCartOrderDto.getShopCartItemDiscounts();
for (ShopCartItemDiscountDto shopCartItemDiscount : shopCartItemDiscounts) {
List<ShopCartItemDto> 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<OrderItem> 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<Integer, Product> 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<Integer, Sku> 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;
}
}

@ -37,7 +37,7 @@ public interface BasketMapper extends BaseMapper<Basket> {
* @param userId 用户id
* @param basketIds 购物车id列表
*/
void deleteShopCartItemsByBasketIds(@Param("userId") String userId, @Param("basketIds") List<Long> basketIds);
void deleteShopCartItemsByBasketIds(@Param("userId") String userId, @Param("basketIds") List<Integer> basketIds);
/**
* 删除所有购物车

@ -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<Curriculum> {
IPage<CurriculumRes> curriculumList(Page<CurriculumRes> page, @Param("req") PageCurriculumReq req);

@ -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<Customer> {
int delCustomers(@Param("ids") List<Integer> 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);

@ -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;

@ -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<HrStaffAccountArchitecture> {
List<Integer> selectIdByPid(Integer id);

@ -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;
/**
* <p>
@ -11,6 +12,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @author chen
* @since 2022-03-23
*/
@Mapper
public interface HrStaffDepartmentMapper extends BaseMapper<HrStaffDepartment> {
}

@ -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;

@ -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;
/**

@ -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<PlatformTea
void updateByAccountId(@Param("accountId")Integer accountId, @Param("status")Integer status);
List<HrUserAccount> selectAccountList(@Param("openId")String openId);
List<UserAccount> selectAccountList(@Param("openId")String openId);
}

@ -131,7 +131,7 @@
</foreach>
</update>
<insert id="insertUserAccount" parameterType="com.huoran.nakadai.entity.HrUserAccount" useGeneratedKeys="true"
<insert id="insertUserAccount" parameterType="com.huoran.common.entity.UserAccount" useGeneratedKeys="true"
keyProperty="id" keyColumn="id">
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
</select>
<update id="updatePwdByCustomerId" parameterType="com.huoran.nakadai.entity.HrUserAccount">
<update id="updatePwdByCustomerId" parameterType="com.huoran.common.entity.UserAccount">
UPDATE hr_user_account
set password = #{password}
WHERE customer_id = #{customerId}
@ -247,7 +247,7 @@
</if>
</select>
<select id="selectCustomerAccount" resultType="com.huoran.nakadai.entity.UserAccount">
<select id="selectCustomerAccount" resultType="com.huoran.common.entity.UserAccount">
select *
from hr_user_account
where customer_id = #{customerId}

@ -137,7 +137,7 @@
WHERE
t.id = #{id}
</select>
<select id="queryAccountInformation" resultType="com.huoran.nakadai.entity.UserAccount">
<select id="queryAccountInformation" resultType="com.huoran.common.entity.UserAccount">
SELECT
*
FROM

@ -11,7 +11,7 @@
</insert>
<!--新增账号信息-->
<insert id="addUserAccount" parameterType="com.huoran.nakadai.entity.UserAccount" useGeneratedKeys="true"
<insert id="addUserAccount" parameterType="com.huoran.common.entity.UserAccount" useGeneratedKeys="true"
keyProperty="id">
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>
<update id="modifyUserAccount" parameterType="com.huoran.nakadai.entity.UserAccount">
<update id="modifyUserAccount" parameterType="com.huoran.common.entity.UserAccount">
UPDATE nakadai.hr_user_account
<trim prefix="set" suffixOverrides=",">
<if test="workNumber!=null and workNumber!=''">
@ -138,8 +138,8 @@
<!--学号(本校内)——————账号(全平台)判重 and platform_id = 1 and type = 1 -->
<!-- 学号、工号通过学校id以及平台端区分(因为后期改成一个用户存在多个平台中) -->
<!-- 账号根据平台-->
<select id="checkUserAccount" resultType="com.huoran.nakadai.entity.UserAccount"
parameterType="com.huoran.nakadai.entity.UserAccount">
<select id="checkUserAccount" resultType="com.huoran.common.entity.UserAccount"
parameterType="com.huoran.common.entity.UserAccount">
SELECT *
from hr_user_account
WHERE is_del = 0

@ -51,12 +51,12 @@
ORDER BY
hpa.manage_id DESC
</select>
<select id="selectAccount" resultType="com.huoran.nakadai.entity.UserAccount">
<select id="selectAccount" resultType="com.huoran.common.entity.UserAccount">
SELECT *
from hr_user_account
WHERE is_del = 0 and platform_id = #{platformId} and phone = #{phone}
</select>
<select id="selectAccountByOpenId" resultType="com.huoran.nakadai.entity.UserAccount">
<select id="selectAccountByOpenId" resultType="com.huoran.common.entity.UserAccount">
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>
<select id="selectAccountPlatform" resultType="com.huoran.nakadai.entity.UserAccount">
<select id="selectAccountPlatform" resultType="com.huoran.common.entity.UserAccount">
SELECT *
from hr_user_account
WHERE is_del = 0 and id = #{accountId}

@ -29,7 +29,7 @@
ORDER BY
T1.lvl DESC
</select>
<select id="selectAccountList" resultType="com.huoran.nakadai.entity.HrUserAccount">
<select id="selectAccountList" resultType="com.huoran.common.entity.UserAccount">
select * from hr_user_account WHERE is_del = 0 and app_open_id = #{openId}
</select>
</mapper>

@ -32,7 +32,7 @@ public interface BasketService extends IService<Basket> {
* @param userId 用户id
* @param basketIds 购物车id列表
*/
void deleteShopCartItemsByBasketIds(String userId, List<Long> basketIds);
void deleteShopCartItemsByBasketIds(String userId, List<Integer> basketIds);
/**
* 添加购物车

@ -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;
/**
* <p>

@ -1,6 +1,6 @@
package com.huoran.nakadai.service;
import com.huoran.nakadai.entity.HrUserAccount;
import com.huoran.common.entity.UserAccount;
import com.huoran.nakadai.entity.PlatformTeamClassification;
import com.baomidou.mybatisplus.extension.service.IService;
@ -18,5 +18,5 @@ public interface PlatformTeamClassificationService extends IService<PlatformTeam
void updateByAccountId(Integer accountId, Integer status);
List<HrUserAccount> selectAccountList(String openId);
List<UserAccount> selectAccountList(String openId);
}

@ -63,7 +63,7 @@ public class BasketServiceImpl extends ServiceImpl<BasketMapper, Basket> impleme
@Override
@CacheEvict(cacheNames = "ShopCartItems", key = "#userId")
public void deleteShopCartItemsByBasketIds(String userId, List<Long> basketIds) {
public void deleteShopCartItemsByBasketIds(String userId, List<Integer> basketIds) {
basketMapper.deleteShopCartItemsByBasketIds(userId, basketIds);
}
@ -183,7 +183,7 @@ public class BasketServiceImpl extends ServiceImpl<BasketMapper, Basket> 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<BasketMapper, Basket> 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());

@ -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<CustomerMapper, Customer> 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<CustomerMapper, Customer> 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);

@ -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;

@ -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;

@ -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;

@ -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<PlatformTeamAcco
arrayList.add(7);
boolean userExists = false; // 添加标志位,判断用户是否存在
HrUserAccount personalAccount = null; // 用于存储个人账号
UserAccount personalAccount = null; // 用于存储个人账号
for (Integer platformId : arrayList) {
//根据openId查询账号详情List
List<HrUserAccount> userAccountList = platformTeamClassificationMapper.selectAccountList(openid);
for (HrUserAccount userAccount : userAccountList) {
List<UserAccount> userAccountList = platformTeamClassificationMapper.selectAccountList(openid);
for (UserAccount userAccount : userAccountList) {
if(userAccount.getPlatformId().equals(platformId.toString())){
if (!userAccount.getIsEnable()){
if (platformId == 7) { // 如果个人账号被禁用,抛出异常

@ -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<PlatformT
}
@Override
public List<HrUserAccount> selectAccountList(String openId) {
public List<UserAccount> selectAccountList(String openId) {
return baseMapper.selectAccountList(openId);
}
}

Loading…
Cancel
Save