Merge remote-tracking branch 'origin/main' into main

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

@ -66,7 +66,7 @@ public enum ExceptionEnum {
CANNOT_ADDED_REPEATEDLY(10026, "该用户已经是团队管理员,无法重复添加!"),
DEFAULT_ROLE_NOTEXIST(10027, "默认角色不存在"),
TEAM_NOT_EXIST(10028, "团队不存在"),
PARTNER_REMOVAL(10029, "移除只能移除团队内成员,管理员无法移除!"),
PARTNER_REMOVAL(10029, "该用户是组织超管,请转让超管后再移除!"),
SUPERVISING_ROLE(10030, "该用户存在超管角色,请转移后进行删除!"),
VERIFICATION_CODE_HAS_BEEN_SENT(10031, "验证码已发,请勿重复操作!"),
LOGIN_INVALID(401, "登录已失效,请重新登录"),

@ -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,13 @@ 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.PlatformTeam;
import com.huoran.nakadai.entity.PlatformTeamAccount;
import com.huoran.nakadai.entity.PlatformTeamClassification;
import com.huoran.nakadai.entity.req.*;
import com.huoran.nakadai.entity.res.PartnerAccountResp;
@ -152,7 +154,9 @@ public class PlatformTeamAccountController {
@GetMapping("/removeOrganization")
@ApiOperation(value = "移除组织")
public R removeOrganization(@ApiParam(name = "teamId", value = "团队id") @RequestParam Integer teamId, @ApiParam(name = "manageId", value = "组织id") @RequestParam Integer manageId) {
public R removeOrganization(
@ApiParam(name = "teamId", value = "团队id") @RequestParam Integer teamId,
@ApiParam(name = "manageId", value = "组织id") @RequestParam Integer manageId) {
PlatformTeamClassification teamClassification = platformTeamClassificationService.getById(teamId);
if (teamClassification.getIsTeam() == 1) {
throw new CustomException(ExceptionEnum.PARTNER_REMOVAL);
@ -165,16 +169,56 @@ public class PlatformTeamAccountController {
return remove ? R.ok() : R.error();
}
@ApiOperation(value = "后台更新团队状态,禁用无法查询到该组织")
@ApiOperation(value = "用户详情更新团队状态,禁用无法查询到该组织,同步禁用用户账号")
@PostMapping("/updateTeamStatus")
public R updateTeamStatus(@RequestParam("teamId") @ApiParam(value = "团队id") Integer teamId, @RequestParam("isEnable") @ApiParam(value = "是否禁用(1->禁用,0->启用)") Integer isEnable) {
PlatformTeamClassification platformTeamClassification = new PlatformTeamClassification();
platformTeamClassification.setId(teamId);
platformTeamClassification.setIsEnable(isEnable);
boolean update = platformTeamClassificationService.updateById(platformTeamClassification);
//查询组织平台账号
PlatformTeam platformTeam = platformTeamService.getOne(new QueryWrapper<PlatformTeam>().eq("classification_id", teamId));
PlatformTeamAccount platformTeamAccount = platformTeamAccountService.getById(platformTeam.getManageId());
int status = 1;
if (isEnable==1){
status=0;
}
platformTeamClassificationService.updateByAccountId(platformTeamAccount.getAccountId(), status);
return update ? R.ok() : R.error();
}
@ApiOperation(value = "用户列表更新账号状态,禁用整个账号禁止登录,不管是哪个端,哪个组织")
@PostMapping("/updateAccountStatus")
public R updateAccountStatus(
@RequestParam("openId") @ApiParam(value = "openId") String openId,
@RequestParam("isEnable") @ApiParam(value = "是否禁用(1->禁用,0->启用)") Integer isEnable) {
//根据openId查询账号详情List
List<UserAccount> userAccountList = platformTeamClassificationService.selectAccountList(openId);
for (UserAccount userAccount : userAccountList) {
int status = 1;
if (isEnable==1){
status=0;
}
//更新账号信息
platformTeamClassificationService.updateByAccountId(userAccount.getId(), status);
if (Integer.parseInt(userAccount.getPlatformId())!=7){
//查询账号绑定的组织信息
List<PlatformTeamAccount> platformTeamAccounts = platformTeamAccountService.list(new QueryWrapper<PlatformTeamAccount>().eq("account_id", userAccount.getId()));
for (PlatformTeamAccount platformTeamAccount : platformTeamAccounts) {
//查询组织平台账号
PlatformTeam platformTeam = platformTeamService.getOne(new QueryWrapper<PlatformTeam>().eq("manage_id", platformTeamAccount.getManageId()));
PlatformTeamClassification platformTeamClassification = new PlatformTeamClassification();
platformTeamClassification.setId(platformTeam.getClassificationId());
platformTeamClassification.setIsEnable(isEnable);
//更新账号绑定的组织信息
platformTeamClassificationService.updateById(platformTeamClassification);
}
}
}
return R.ok();
}
//================================以下接口为小程序调用===================================
@ApiOperation(value = "幼教产品微信小程序回调登录")
@PostMapping("/weChatAppletCallbackByKindergarten")

@ -1,113 +0,0 @@
package com.huoran.nakadai.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
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;
/**
* 主键id(平台用户id
*/
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
/**
* 用户表id
*/
private Integer userId;
private Integer customerId;
/**
* 账号
*/
private String account;
/**
* 密码
*/
private String password;
/**
* 工号
*/
private String workNumber;
/**
* 绑定的角色id
*/
private String roleId;
/**
* 绑定院校id
*/
private Integer schoolId;
@TableField(exist = false)
private String schoolName;
/**
* 所属平台1->职站 2->数据平台
*/
private String platformId;
@TableField(exist = false)
private String platformName;
/**
* 平台系统绑定时间
*/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date platformBindTime;
/**
* 平台端区分0->教师端 1->学生端
*/
private Integer type;
@TableField(exist = false)
private String typeName;
/**
* 是否删除(0未删除 1已删除)
*/
@TableLogic
private Integer isDel;
/**
* 是否禁用0->禁用1->启用
*/
private Integer isEnable;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@TableField(fill = FieldFill.INSERT)
private Date createTime;
/**
* 修改时间
*/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
}

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

@ -92,6 +92,9 @@ public class TeamAccountResp {
@ApiModelProperty(value = "团队数")
private Integer teamSize;
@ApiModelProperty(value = "组织禁用")
private Integer isEnable;
@ApiModelProperty(value = "团队名称")
private String teamName;

@ -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,10 +1,13 @@
package com.huoran.nakadai.mapper;
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;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* 幼教产业平台团队分类表 Mapper 接口
@ -17,4 +20,8 @@ import org.apache.ibatis.annotations.Param;
public interface PlatformTeamClassificationMapper extends BaseMapper<PlatformTeamClassification> {
PlatformTeamClassification getParentInformationBasedOnChild(@Param("id") String classificationId);
void updateByAccountId(@Param("accountId")Integer accountId, @Param("status")Integer status);
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}
@ -73,7 +73,8 @@
CASE
WHEN count(ai.id) > 0 THEN '已认证'
ELSE '未认证'
END as authentication
END as authentication,
c.is_enable
FROM
k_platform_team t
INNER JOIN k_platform_team_classification c ON c.id = t.classification_id
@ -82,7 +83,7 @@
INNER JOIN hr_user_info u on ua.user_id = u.user_id
left join hr_user_authentication_information ai on ai.open_id = ua.app_open_id
WHERE
c.is_del = 0 and c.is_enable = 0
c.is_del = 0
AND a.is_del = 0 and a.platform_id = #{platformId}
AND a.account_id = #{accountId}
</select>
@ -174,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}

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.huoran.nakadai.mapper.PlatformTeamClassificationMapper">
<update id="updateByAccountId">
update hr_user_account set is_enable = #{status} WHERE is_del = 0 and id = #{accountId}
</update>
<select id="getParentInformationBasedOnChild"
resultType="com.huoran.nakadai.entity.PlatformTeamClassification">
@ -26,4 +29,7 @@
ORDER BY
T1.lvl DESC
</select>
<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>
@ -25,7 +24,7 @@ public interface EnterpriseCertificationService extends IService<EnterpriseCerti
boolean deleteTeamInformation(Integer accountId);
UserAccount queryAccountInformation(String openId,Integer platformId);
UserAccount queryAccountInformation(String openId, Integer platformId);
//逻辑删除用户信息
boolean deleteUserInformation(Integer userId);

@ -1,8 +1,11 @@
package com.huoran.nakadai.service;
import com.huoran.common.entity.UserAccount;
import com.huoran.nakadai.entity.PlatformTeamClassification;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 幼教产业平台团队分类表 服务类
@ -13,4 +16,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface PlatformTeamClassificationService extends IService<PlatformTeamClassification> {
void updateByAccountId(Integer accountId, Integer status);
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,28 +98,46 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl<PlatformTeamAcco
arrayList.add(7);
boolean userExists = false; // 添加标志位,判断用户是否存在
UserAccount personalAccount = null; // 用于存储个人账号
for (Integer platformId : arrayList) {
UserAccount userAccount = baseMapper.selectAccountByOpenId(openid,platformId);
// 有平台存在返回登录信息
if (userAccount!= null){
if (!userAccount.getIsEnable()){
throw new CustomException(ExceptionEnum.ACCOUNT_DISABLED);
}
if (userAccount.getPhone()== null){
//登录更新手机号
baseMapper.updateAccountPhone(appletCallbackReq.getPhone(),userAccount.getId());
//根据openId查询账号详情List
List<UserAccount> userAccountList = platformTeamClassificationMapper.selectAccountList(openid);
for (UserAccount userAccount : userAccountList) {
if(userAccount.getPlatformId().equals(platformId.toString())){
if (!userAccount.getIsEnable()){
if (platformId == 7) { // 如果个人账号被禁用,抛出异常
throw new CustomException(ExceptionEnum.ACCOUNT_DISABLED);
}
continue; // 如果组织账号被禁用,跳过当前循环
}
if (platformId == 7) { // 如果是个人账号,保存信息并跳过当前循环
personalAccount = userAccount;
continue;
}
if (userAccount.getPhone()== null){
//登录更新手机号
baseMapper.updateAccountPhone(appletCallbackReq.getPhone(),userAccount.getId());
}
//更新登录时间
baseMapper.updateUserInfo(userAccount.getUserId());
data.put("state", "login");
data.put("platformId", platformId);
data.put("token", JwtUtils.getJwtToken(userAccount.getId().toString(),getShopId(openid,platformId),platformId));
userExists = true; // 如果用户存在,将标志位设为true
break; // 如果找到用户,就不需要继续查找
}
//更新登录时间
baseMapper.updateUserInfo(userAccount.getUserId());
data.put("state", "login");
data.put("platformId", platformId);
data.put("token", JwtUtils.getJwtToken(userAccount.getId().toString(),getShopId(openid,platformId),platformId));
userExists = true; // 如果用户存在,将标志位设为true
break; // 如果找到用户,就不需要继续查找
}
}
// 如果用户不存在,检查是否有个人账号
if (!userExists && personalAccount != null) {
data.put("state", "login");
data.put("platformId", 7);
data.put("token", JwtUtils.getJwtToken(personalAccount.getId().toString(),0L,7));
userExists = true;
}
// 如果用户不存在,返回状态为"绑定"
if (!userExists) {
data.put("state", "bind");
@ -130,6 +148,7 @@ public class PlatformTeamAccountServiceImpl extends ServiceImpl<PlatformTeamAcco
return data;
}
public Long getShopId(String openId, Integer platformId) {
return baseMapper.selectShopIdByOpenId(openId, platformId);
}

@ -1,11 +1,14 @@
package com.huoran.nakadai.service.impl;
import com.huoran.common.entity.UserAccount;
import com.huoran.nakadai.entity.PlatformTeamClassification;
import com.huoran.nakadai.mapper.PlatformTeamClassificationMapper;
import com.huoran.nakadai.service.PlatformTeamClassificationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 幼教产业平台团队分类表 服务实现类
@ -16,5 +19,13 @@ import org.springframework.stereotype.Service;
*/
@Service
public class PlatformTeamClassificationServiceImpl extends ServiceImpl<PlatformTeamClassificationMapper, PlatformTeamClassification> implements PlatformTeamClassificationService {
@Override
public void updateByAccountId(Integer accountId, Integer status) {
baseMapper.updateByAccountId(accountId, status);
}
@Override
public List<UserAccount> selectAccountList(String openId) {
return baseMapper.selectAccountList(openId);
}
}

Loading…
Cancel
Save