From 9f345310a755f35dcd06424b3923b119686365af Mon Sep 17 00:00:00 2001
From: cloudroam <cloudroam>
Date: 星期一, 09 九月 2024 16:14:33 +0800
Subject: [PATCH] add:合伙人账号启用/禁用;供应商启用/禁用;花店端账号禁用/启用
---
src/main/java/com/mzl/flower/service/supplier/SupplierService.java | 15 +++++
src/main/java/com/mzl/flower/dto/response/partner/PartnerDTO.java | 3 +
src/main/java/com/mzl/flower/service/partner/PartnerService.java | 16 +++++
src/main/java/com/mzl/flower/dto/request/partner/QueryPartnerDTO.java | 3 +
src/main/java/com/mzl/flower/dto/response/supplier/SupplierDTO.java | 3 +
src/main/java/com/mzl/flower/web/login/SupplierLoginController.java | 13 ++++
src/main/java/com/mzl/flower/service/customer/CustomerService.java | 14 ++++
src/main/java/com/mzl/flower/web/customer/CustomerController.java | 12 ++-
src/main/java/com/mzl/flower/entity/partner/Partner.java | 2
src/main/resources/mapper/partner/PartnerMapper.xml | 3 +
src/main/java/com/mzl/flower/web/login/PartnerLoginController.java | 13 ++++
src/main/java/com/mzl/flower/dto/response/customer/CustomerDTO.java | 3 +
src/main/java/com/mzl/flower/dto/request/supplier/QuerySupplierDTO.java | 3 +
src/main/java/com/mzl/flower/web/supplier/SupplierController.java | 7 ++
src/main/java/com/mzl/flower/dto/request/customer/QueryCustomerDTO.java | 3 +
src/main/java/com/mzl/flower/web/login/CustomerLoginController.java | 14 ++++
src/main/resources/mapper/customer/CustomerMapper.xml | 3 +
src/main/java/com/mzl/flower/entity/supplier/Supplier.java | 2
src/main/resources/mapper/supplier/SupplierMapper.xml | 3 +
src/main/java/com/mzl/flower/entity/customer/Customer.java | 3
src/main/java/com/mzl/flower/web/partner/PartnerController.java | 7 ++
21 files changed, 139 insertions(+), 6 deletions(-)
diff --git a/src/main/java/com/mzl/flower/dto/request/customer/QueryCustomerDTO.java b/src/main/java/com/mzl/flower/dto/request/customer/QueryCustomerDTO.java
index c8eaca9..7ee97d2 100644
--- a/src/main/java/com/mzl/flower/dto/request/customer/QueryCustomerDTO.java
+++ b/src/main/java/com/mzl/flower/dto/request/customer/QueryCustomerDTO.java
@@ -28,4 +28,7 @@
@ApiModelProperty(hidden = true)
private String partnerUserId;
+
+ @ApiModelProperty("启用/禁用(USER_ENABLED_OR_DISABLED)")
+ private Integer isEnabled;
}
diff --git a/src/main/java/com/mzl/flower/dto/request/partner/QueryPartnerDTO.java b/src/main/java/com/mzl/flower/dto/request/partner/QueryPartnerDTO.java
index b83eb27..94cee52 100644
--- a/src/main/java/com/mzl/flower/dto/request/partner/QueryPartnerDTO.java
+++ b/src/main/java/com/mzl/flower/dto/request/partner/QueryPartnerDTO.java
@@ -34,4 +34,7 @@
@ApiModelProperty(value = "申请时间(yyyy-mm-dd)", hidden = true)
private LocalDateTime createDateEnd;
+
+ @ApiModelProperty("启用/禁用(USER_ENABLED_OR_DISABLED)")
+ private Integer isEnabled;
}
diff --git a/src/main/java/com/mzl/flower/dto/request/supplier/QuerySupplierDTO.java b/src/main/java/com/mzl/flower/dto/request/supplier/QuerySupplierDTO.java
index db948e4..aea17e6 100644
--- a/src/main/java/com/mzl/flower/dto/request/supplier/QuerySupplierDTO.java
+++ b/src/main/java/com/mzl/flower/dto/request/supplier/QuerySupplierDTO.java
@@ -29,4 +29,7 @@
@ApiModelProperty(value = "申请时间(yyyy-mm-dd)", hidden = true)
private LocalDateTime createDateEnd;
+
+ @ApiModelProperty("启用/禁用(USER_ENABLED_OR_DISABLED)")
+ private Integer isEnabled;
}
diff --git a/src/main/java/com/mzl/flower/dto/response/customer/CustomerDTO.java b/src/main/java/com/mzl/flower/dto/response/customer/CustomerDTO.java
index 7038788..e32f68f 100644
--- a/src/main/java/com/mzl/flower/dto/response/customer/CustomerDTO.java
+++ b/src/main/java/com/mzl/flower/dto/response/customer/CustomerDTO.java
@@ -52,4 +52,7 @@
@ApiModelProperty("更新时间")
private LocalDateTime updateTime;
+
+ @ApiModelProperty("启用/禁用")
+ private Boolean isEnabled;
}
diff --git a/src/main/java/com/mzl/flower/dto/response/partner/PartnerDTO.java b/src/main/java/com/mzl/flower/dto/response/partner/PartnerDTO.java
index 9d292a0..f57ed7c 100644
--- a/src/main/java/com/mzl/flower/dto/response/partner/PartnerDTO.java
+++ b/src/main/java/com/mzl/flower/dto/response/partner/PartnerDTO.java
@@ -64,4 +64,7 @@
@ApiModelProperty("更新时间")
private LocalDateTime updateTime;
+
+ @ApiModelProperty("启用/禁用")
+ private Boolean isEnabled;
}
diff --git a/src/main/java/com/mzl/flower/dto/response/supplier/SupplierDTO.java b/src/main/java/com/mzl/flower/dto/response/supplier/SupplierDTO.java
index 282f638..71fb6c8 100644
--- a/src/main/java/com/mzl/flower/dto/response/supplier/SupplierDTO.java
+++ b/src/main/java/com/mzl/flower/dto/response/supplier/SupplierDTO.java
@@ -93,4 +93,7 @@
@ApiModelProperty("是否显示商品")
private Boolean showed;
+
+ @ApiModelProperty("启用/禁用")
+ private Boolean isEnabled;
}
diff --git a/src/main/java/com/mzl/flower/entity/customer/Customer.java b/src/main/java/com/mzl/flower/entity/customer/Customer.java
index 93e71ef..2332d65 100644
--- a/src/main/java/com/mzl/flower/entity/customer/Customer.java
+++ b/src/main/java/com/mzl/flower/entity/customer/Customer.java
@@ -6,7 +6,6 @@
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
-import java.time.LocalDateTime;
@Data
@TableName("t_customer_info")
@@ -42,4 +41,6 @@
@ApiModelProperty("店铺简介")
private String description;
+ @ApiModelProperty("启用/禁用")
+ private Boolean isEnabled;
}
diff --git a/src/main/java/com/mzl/flower/entity/partner/Partner.java b/src/main/java/com/mzl/flower/entity/partner/Partner.java
index 13fbb92..805f960 100644
--- a/src/main/java/com/mzl/flower/entity/partner/Partner.java
+++ b/src/main/java/com/mzl/flower/entity/partner/Partner.java
@@ -53,4 +53,6 @@
@ApiModelProperty("推广二维码-设计后")
private String codeUrl;
+ @ApiModelProperty("启用/禁用")
+ private Boolean isEnabled;
}
diff --git a/src/main/java/com/mzl/flower/entity/supplier/Supplier.java b/src/main/java/com/mzl/flower/entity/supplier/Supplier.java
index 6b8bd2f..0b7e974 100644
--- a/src/main/java/com/mzl/flower/entity/supplier/Supplier.java
+++ b/src/main/java/com/mzl/flower/entity/supplier/Supplier.java
@@ -70,5 +70,7 @@
@ApiModelProperty("是否显示商品")
private Boolean showed;
+ @ApiModelProperty("启用/禁用")
+ private Boolean isEnabled;
}
diff --git a/src/main/java/com/mzl/flower/service/customer/CustomerService.java b/src/main/java/com/mzl/flower/service/customer/CustomerService.java
index ffce4ed..a4aa812 100644
--- a/src/main/java/com/mzl/flower/service/customer/CustomerService.java
+++ b/src/main/java/com/mzl/flower/service/customer/CustomerService.java
@@ -65,6 +65,7 @@
}
customer.create(SecurityUtils.getUserId());
+ customer.setIsEnabled(true);
customerMapper.insert(customer);
} else {//重新修改
customer = customerMapper.selectById(dto.getId());
@@ -200,4 +201,17 @@
}
return null;
}
+ public void isEnable(Long id) {
+ Customer customer = customerMapper.selectById(id);
+ if (customer == null) {
+ throw new ValidationException("商户信息不存在");
+ }
+ if (customer.getIsEnabled()) {
+ customer.setIsEnabled(false);
+ } else {
+ customer.setIsEnabled(true);
+ }
+ customer.update(SecurityUtils.getUserId());
+ customerMapper.updateById(customer);
+ }
}
diff --git a/src/main/java/com/mzl/flower/service/partner/PartnerService.java b/src/main/java/com/mzl/flower/service/partner/PartnerService.java
index 609684c..15f9a26 100644
--- a/src/main/java/com/mzl/flower/service/partner/PartnerService.java
+++ b/src/main/java/com/mzl/flower/service/partner/PartnerService.java
@@ -10,6 +10,7 @@
import com.mzl.flower.dto.request.partner.*;
import com.mzl.flower.dto.response.partner.PartnerDTO;
import com.mzl.flower.entity.partner.Partner;
+import com.mzl.flower.entity.supplier.Supplier;
import com.mzl.flower.mapper.partner.PartnerMapper;
import com.mzl.flower.service.UploadService;
import com.mzl.flower.utils.DateUtils;
@@ -59,6 +60,7 @@
partner.setIdCards(JSON.toJSONString(dto.getIdCards()));
partner.create(SecurityUtils.getUserId());
partner.setStatus(PARTNER_STATUS_AUDIT);
+ partner.setIsEnabled(true);
partnerMapper.insert(partner);
}else{//重新修改
partner = partnerMapper.selectById(dto.getId());
@@ -161,4 +163,18 @@
partner.update(SecurityUtils.getUserId());
partnerMapper.updateById(partner);
}
+
+ public void isEnable(Long id) {
+ Partner partner = partnerMapper.selectById(id);
+ if (partner == null) {
+ throw new ValidationException("合伙人信息不存在");
+ }
+ if (partner.getIsEnabled()) {
+ partner.setIsEnabled(false);
+ } else {
+ partner.setIsEnabled(true);
+ }
+ partner.update(SecurityUtils.getUserId());
+ partnerMapper.updateById(partner);
+ }
}
diff --git a/src/main/java/com/mzl/flower/service/supplier/SupplierService.java b/src/main/java/com/mzl/flower/service/supplier/SupplierService.java
index c5516c6..67e2e99 100644
--- a/src/main/java/com/mzl/flower/service/supplier/SupplierService.java
+++ b/src/main/java/com/mzl/flower/service/supplier/SupplierService.java
@@ -50,6 +50,7 @@
supplier.create(SecurityUtils.getUserId());
supplier.setShowed(true);
supplier.setStatus(SUPPLIER_STATUS_AUDIT);
+ supplier.setIsEnabled(true);
supplierMapper.insert(supplier);
}else{//重新修改
supplier = supplierMapper.selectById(dto.getId());
@@ -187,4 +188,18 @@
supplier.update(SecurityUtils.getUserId());
supplierMapper.updateById(supplier);
}
+
+ public void isEnable(Long id) {
+ Supplier supplier = supplierMapper.selectById(id);
+ if (supplier == null) {
+ throw new ValidationException("供应商信息不存在");
+ }
+ if (supplier.getIsEnabled()) {
+ supplier.setIsEnabled(false);
+ } else {
+ supplier.setIsEnabled(true);
+ }
+ supplier.update(SecurityUtils.getUserId());
+ supplierMapper.updateById(supplier);
+ }
}
diff --git a/src/main/java/com/mzl/flower/web/customer/CustomerController.java b/src/main/java/com/mzl/flower/web/customer/CustomerController.java
index 4c552d3..8b870c9 100644
--- a/src/main/java/com/mzl/flower/web/customer/CustomerController.java
+++ b/src/main/java/com/mzl/flower/web/customer/CustomerController.java
@@ -4,15 +4,11 @@
import com.mzl.flower.base.BaseController;
import com.mzl.flower.base.R;
import com.mzl.flower.base.ReturnDataDTO;
-import com.mzl.flower.config.exception.ValidationException;
import com.mzl.flower.config.security.SecurityUtils;
import com.mzl.flower.dto.request.customer.BindPartnerDTO;
import com.mzl.flower.dto.request.customer.ChangePartnerDTO;
import com.mzl.flower.dto.request.customer.QueryCustomerDTO;
import com.mzl.flower.dto.request.customer.UpdateCustomerDTO;
-import com.mzl.flower.dto.request.supplier.AuditSupplierDTO;
-import com.mzl.flower.dto.request.supplier.QuerySupplierDTO;
-import com.mzl.flower.dto.request.supplier.UpdateSupplierDTO;
import com.mzl.flower.dto.response.customer.CustomerDTO;
import com.mzl.flower.dto.response.supplier.SupplierDTO;
import com.mzl.flower.service.customer.CustomerService;
@@ -24,6 +20,7 @@
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
@RestController
@RequestMapping("/api/customer")
@@ -85,4 +82,11 @@
public ResponseEntity<ReturnDataDTO<SupplierDTO>> getPartnerName(@NotBlank(message = "参数不能为空") String id) {
return returnData(R.SUCCESS.getCode(),customerService.getPartnerName(id));
}
+
+ @GetMapping("/page/isEnable")
+ @ApiOperation(value = "启用/禁用", notes = "启用/禁用商品")
+ public ResponseEntity<ReturnDataDTO<String>> isEnable(@NotNull(message = "id不能为空") Long id) {
+ customerService.isEnable(id);
+ return returnData(R.SUCCESS.getCode(),null);
+ }
}
diff --git a/src/main/java/com/mzl/flower/web/login/CustomerLoginController.java b/src/main/java/com/mzl/flower/web/login/CustomerLoginController.java
index 1f5b9a9..475685a 100644
--- a/src/main/java/com/mzl/flower/web/login/CustomerLoginController.java
+++ b/src/main/java/com/mzl/flower/web/login/CustomerLoginController.java
@@ -14,7 +14,10 @@
import com.mzl.flower.constant.Constants;
import com.mzl.flower.dto.request.CreateWechatUserDTO;
import com.mzl.flower.dto.request.UserLoginDTO;
+import com.mzl.flower.dto.response.customer.CustomerDTO;
import com.mzl.flower.entity.system.User;
+import com.mzl.flower.mapper.customer.CustomerMapper;
+import com.mzl.flower.service.customer.CustomerService;
import com.mzl.flower.service.login.LoginService;
import com.mzl.flower.service.system.UserService;
import com.mzl.flower.service.system.WeChatService;
@@ -33,6 +36,7 @@
import org.springframework.security.oauth2.common.OAuth2RefreshToken;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
+import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
@@ -60,6 +64,9 @@
@Autowired
private UserService userService;
+
+ @Autowired
+ private CustomerMapper customerMapper;
@Autowired
@@ -125,6 +132,13 @@
if(user == null){
throw new ValidationException("用户不存在");
}
+ CustomerDTO currentCustomer = customerMapper.getCurrentCustomer(user.getId());
+ if (ObjectUtils.isEmpty(currentCustomer)) {
+ throw new ValidationException("用户不存在");
+ }
+ if (currentCustomer.getIsEnabled() == false) {
+ throw new ValidationException("用户已禁用,请联系管理员");
+ }
String tokenCache = stringCacheClient.get(TOKEN_KEY + SEPARATOR + user.getId());
if (StringUtils.isNotBlank(tokenCache)) {
//强制删除token,下线
diff --git a/src/main/java/com/mzl/flower/web/login/PartnerLoginController.java b/src/main/java/com/mzl/flower/web/login/PartnerLoginController.java
index 375f43c..b7ffa9e 100644
--- a/src/main/java/com/mzl/flower/web/login/PartnerLoginController.java
+++ b/src/main/java/com/mzl/flower/web/login/PartnerLoginController.java
@@ -11,7 +11,9 @@
import com.mzl.flower.config.security.token.PhoneAuthenticationToken;
import com.mzl.flower.constant.Constants;
import com.mzl.flower.dto.request.UserLoginDTO;
+import com.mzl.flower.dto.response.partner.PartnerDTO;
import com.mzl.flower.entity.system.User;
+import com.mzl.flower.mapper.partner.PartnerMapper;
import com.mzl.flower.service.login.LoginService;
import com.mzl.flower.service.system.UserService;
import io.swagger.annotations.Api;
@@ -29,6 +31,7 @@
import org.springframework.security.oauth2.common.OAuth2RefreshToken;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
+import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -59,7 +62,8 @@
@Autowired
private TokenStore tokenStore;
-
+ @Autowired
+ private PartnerMapper partnerMapper;
public static final String SMS_CODE_KEY = "SMS-CODE-KEY";
public static final String TOKEN_KEY = "TOKEN-KEY";
@@ -82,6 +86,13 @@
if(user == null){
throw new ValidationException("用户不存在");
}
+ PartnerDTO partnerDTO = partnerMapper.getCurrentPartner(user.getId());
+ if (ObjectUtils.isEmpty(partnerDTO)) {
+ throw new ValidationException("用户不存在");
+ }
+ if (partnerDTO.getIsEnabled() == false) {
+ throw new ValidationException("用户已禁用,请联系管理员");
+ }
String tokenCache = stringCacheClient.get(TOKEN_KEY + SEPARATOR + user.getId());
if (StringUtils.isNotBlank(tokenCache)) {
//强制删除token,下线
diff --git a/src/main/java/com/mzl/flower/web/login/SupplierLoginController.java b/src/main/java/com/mzl/flower/web/login/SupplierLoginController.java
index 0147a61..0fd20e3 100644
--- a/src/main/java/com/mzl/flower/web/login/SupplierLoginController.java
+++ b/src/main/java/com/mzl/flower/web/login/SupplierLoginController.java
@@ -11,7 +11,9 @@
import com.mzl.flower.config.security.token.SupAuthenticationToken;
import com.mzl.flower.constant.Constants;
import com.mzl.flower.dto.request.UserLoginDTO;
+import com.mzl.flower.dto.response.supplier.SupplierDTO;
import com.mzl.flower.entity.system.User;
+import com.mzl.flower.mapper.supplier.SupplierMapper;
import com.mzl.flower.service.login.LoginService;
import com.mzl.flower.service.system.UserService;
import io.swagger.annotations.Api;
@@ -29,6 +31,7 @@
import org.springframework.security.oauth2.common.OAuth2RefreshToken;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
+import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -59,6 +62,9 @@
@Autowired
private TokenStore tokenStore;
+ @Autowired
+ private SupplierMapper supplierMapper;
+
public static final String SMS_CODE_KEY = "SMS-CODE-KEY";
public static final String TOKEN_KEY = "TOKEN-KEY";
@@ -81,6 +87,13 @@
if(user == null){
throw new ValidationException("用户不存在");
}
+ SupplierDTO supplierDTO = supplierMapper.getCurrentSupplier(user.getId());
+ if (ObjectUtils.isEmpty(supplierDTO)) {
+ throw new ValidationException("用户不存在");
+ }
+ if (supplierDTO.getIsEnabled() == false) {
+ throw new ValidationException("用户已禁用,请联系管理员");
+ }
String tokenCache = stringCacheClient.get(TOKEN_KEY + SEPARATOR + user.getId());
if (StringUtils.isNotBlank(tokenCache)) {
//强制删除token,下线
diff --git a/src/main/java/com/mzl/flower/web/partner/PartnerController.java b/src/main/java/com/mzl/flower/web/partner/PartnerController.java
index 9fabd8f..3a3a2c8 100644
--- a/src/main/java/com/mzl/flower/web/partner/PartnerController.java
+++ b/src/main/java/com/mzl/flower/web/partner/PartnerController.java
@@ -77,4 +77,11 @@
return returnData(R.SUCCESS.getCode(),null);
}
+ @GetMapping("/page/isEnable")
+ @ApiOperation(value = "启用/禁用", notes = "启用/禁用商品")
+ public ResponseEntity<ReturnDataDTO<String>> isEnable(@NotNull(message = "id不能为空") Long id) {
+ partnerService.isEnable(id);
+ return returnData(R.SUCCESS.getCode(),null);
+ }
+
}
diff --git a/src/main/java/com/mzl/flower/web/supplier/SupplierController.java b/src/main/java/com/mzl/flower/web/supplier/SupplierController.java
index 4bb7c62..c78ecb5 100644
--- a/src/main/java/com/mzl/flower/web/supplier/SupplierController.java
+++ b/src/main/java/com/mzl/flower/web/supplier/SupplierController.java
@@ -103,4 +103,11 @@
supplierService.configShow(id);
return returnData(R.SUCCESS.getCode(),null);
}
+
+ @GetMapping("/page/isEnable")
+ @ApiOperation(value = "启用/禁用", notes = "启用/禁用商品")
+ public ResponseEntity<ReturnDataDTO<String>> isEnable(@NotNull(message = "id不能为空") Long id) {
+ supplierService.isEnable(id);
+ return returnData(R.SUCCESS.getCode(),null);
+ }
}
diff --git a/src/main/resources/mapper/customer/CustomerMapper.xml b/src/main/resources/mapper/customer/CustomerMapper.xml
index 8fbff9f..e5ac30a 100644
--- a/src/main/resources/mapper/customer/CustomerMapper.xml
+++ b/src/main/resources/mapper/customer/CustomerMapper.xml
@@ -40,6 +40,9 @@
<if test="dto.partnerUserId != null and dto.partnerUserId != ''">
and c.partner_user_id = #{dto.partnerUserId}
</if>
+ <if test="dto.isEnabled!=null">
+ AND c.is_enabled = #{dto.isEnabled}
+ </if>
order by c.create_time desc
</select>
<select id="getCurrentCustomer" resultType="com.mzl.flower.dto.response.customer.CustomerDTO"
diff --git a/src/main/resources/mapper/partner/PartnerMapper.xml b/src/main/resources/mapper/partner/PartnerMapper.xml
index be23dd8..232cb24 100644
--- a/src/main/resources/mapper/partner/PartnerMapper.xml
+++ b/src/main/resources/mapper/partner/PartnerMapper.xml
@@ -32,6 +32,9 @@
<if test="dto.region!=null and dto.region!=''">
AND t.region like CONCAT('%',#{dto.region}, '%')
</if>
+ <if test="dto.isEnabled!=null">
+ AND t.is_enabled = #{dto.isEnabled}
+ </if>
order by t.create_time desc
</select>
<select id="getCurrentPartner" resultType="com.mzl.flower.dto.response.partner.PartnerDTO"
diff --git a/src/main/resources/mapper/supplier/SupplierMapper.xml b/src/main/resources/mapper/supplier/SupplierMapper.xml
index 2337500..7a06f2e 100644
--- a/src/main/resources/mapper/supplier/SupplierMapper.xml
+++ b/src/main/resources/mapper/supplier/SupplierMapper.xml
@@ -35,6 +35,9 @@
AND t.create_time <= #{dto.createDateEnd}
]]>
</if>
+ <if test="dto.isEnabled!=null">
+ AND t.is_enabled = #{dto.isEnabled}
+ </if>
order by t.create_time desc
</select>
<select id="findSupplierDetail" resultType="com.mzl.flower.dto.response.supplier.SupplierDTO"
--
Gitblit v1.9.3