|
@@ -8,17 +8,26 @@ import com.diagbot.dto.LantoneProductDTO;
|
|
|
import com.diagbot.dto.LantoneProductOrgDTO;
|
|
|
import com.diagbot.dto.OpendProductDTO;
|
|
|
import com.diagbot.dto.ProductLineDTO;
|
|
|
+import com.diagbot.dto.RenewalsInfosDTO;
|
|
|
import com.diagbot.dto.RespDTO;
|
|
|
import com.diagbot.dto.UserOrgDTO;
|
|
|
import com.diagbot.entity.LantoneProduct;
|
|
|
import com.diagbot.entity.OpenedProducts;
|
|
|
import com.diagbot.entity.OpenedProductsIndex;
|
|
|
+import com.diagbot.entity.OrderDetailsIndex;
|
|
|
import com.diagbot.entity.ServiceInfo;
|
|
|
+import com.diagbot.entity.User;
|
|
|
+import com.diagbot.entity.UserRenewals;
|
|
|
import com.diagbot.entity.wrapper.OpendProductWrapper;
|
|
|
import com.diagbot.entity.wrapper.ServiceInfoWrapper;
|
|
|
+import com.diagbot.entity.wrapper.UserRenewalsWrapper;
|
|
|
import com.diagbot.enums.AccessTypeEnum;
|
|
|
+import com.diagbot.enums.AuditStatusEnum;
|
|
|
+import com.diagbot.enums.CancelRenewalsEnum;
|
|
|
+import com.diagbot.enums.ChargeTypeEnum;
|
|
|
import com.diagbot.enums.IsDeleteEnum;
|
|
|
import com.diagbot.enums.ProductAuditEnum;
|
|
|
+import com.diagbot.enums.RenewalsEnum;
|
|
|
import com.diagbot.enums.ServiceTypeEnum;
|
|
|
import com.diagbot.enums.StatusEnum;
|
|
|
import com.diagbot.enums.TrialStatusEnum;
|
|
@@ -38,6 +47,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -57,6 +67,10 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
|
|
|
private OrderDetailsFacade orderDetailsFacade;
|
|
|
@Autowired
|
|
|
private ServiceInfoFacade serviceInfoFacade;
|
|
|
+ @Autowired
|
|
|
+ private UserRenewalsFacade userRenewalsFacade;
|
|
|
+ @Autowired
|
|
|
+ private ProductServiceFacade productServiceFacade;
|
|
|
|
|
|
/**
|
|
|
* 产品线管理添加产品
|
|
@@ -65,7 +79,8 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
|
|
|
* @return Boolean true
|
|
|
*/
|
|
|
public Boolean addProducts(AddProductsVO addProductsVO) {
|
|
|
- if(addProductsVO.getName().equals(this.selectProductByName(addProductsVO.getName()).getName())){
|
|
|
+ LantoneProduct lantoneProductInfos = this.selectProductByName(addProductsVO.getName());
|
|
|
+ if(lantoneProductInfos != null && addProductsVO.getName().equals(lantoneProductInfos.getName())){
|
|
|
throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
"产品名称重复");
|
|
|
}
|
|
@@ -74,7 +89,7 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
|
|
|
lantoneProduct.setGmtCreate(DateUtil.now());
|
|
|
lantoneProduct.setCreator(UserUtils.getCurrentPrincipleID());
|
|
|
if (!save(lantoneProduct)) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
+ throw new CommonException(CommonErrorCode.UPDATE_INFO_FAIL,
|
|
|
"产品添加失败");
|
|
|
}
|
|
|
return true;
|
|
@@ -88,15 +103,20 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
|
|
|
* @return Boolean true
|
|
|
*/
|
|
|
public Boolean updateProduct(UpdateProductVO updateProductVO) {
|
|
|
- if(updateProductVO.getName().equals(this.selectProductByName(updateProductVO.getName()).getName())){
|
|
|
+ LantoneProduct lantoneProductInfo = this.selectProductByName(updateProductVO.getName());
|
|
|
+ if(null != lantoneProductInfo && updateProductVO.getName().equals(lantoneProductInfo.getName()) && updateProductVO.getId() != lantoneProductInfo.getId()){
|
|
|
throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
"产品名称重复");
|
|
|
}
|
|
|
LantoneProduct lantoneProduct = this.getById(updateProductVO.getId());
|
|
|
+ if(lantoneProduct.getIsDeleted().equals(IsDeleteEnum.Y.getKey())){
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS,
|
|
|
+ "该产品已删除");
|
|
|
+ }
|
|
|
BeanUtil.copyProperties(updateProductVO, lantoneProduct);
|
|
|
lantoneProduct.setModifier(UserUtils.getCurrentPrincipleID());
|
|
|
lantoneProduct.setGmtModified(DateUtil.now());
|
|
|
- if(updateProductVO.getServiceStatus()==StatusEnum.Disable.getKey()){
|
|
|
+ if(null != updateProductVO.getServiceStatus() && updateProductVO.getServiceStatus()==StatusEnum.Disable.getKey()){
|
|
|
Page page =new Page();
|
|
|
OpenedProductsIndex openedProductsIndex =new OpenedProductsIndex();
|
|
|
openedProductsIndex.setProductId(updateProductVO.getId());
|
|
@@ -107,7 +127,7 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
|
|
|
}
|
|
|
}
|
|
|
if (!updateById(lantoneProduct)) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
+ throw new CommonException(CommonErrorCode.UPDATE_INFO_FAIL,
|
|
|
"产品修改失败");
|
|
|
}
|
|
|
return true;
|
|
@@ -121,21 +141,51 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
|
|
|
*/
|
|
|
public Boolean stopProduct(UpdateProductVO updateProductVO) {
|
|
|
LantoneProduct lantoneProduct = this.getById(updateProductVO.getId());
|
|
|
+ if(lantoneProduct.getIsDeleted().equals(IsDeleteEnum.Y.getKey())){
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS,
|
|
|
+ "该产品已删除");
|
|
|
+ }
|
|
|
+ if(updateProductVO.getServiceStatus() == lantoneProduct.getServiceStatus() && updateProductVO.getServiceStatus() == StatusEnum.Enable.getKey()){
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
+ "该产品已启用,启用失败");
|
|
|
+ }
|
|
|
+ if(updateProductVO.getServiceStatus() == lantoneProduct.getServiceStatus() && updateProductVO.getServiceStatus() == StatusEnum.Disable.getKey()){
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
+ "该产品已停用,停用失败");
|
|
|
+ }
|
|
|
BeanUtil.copyProperties(updateProductVO, lantoneProduct);
|
|
|
lantoneProduct.setModifier(UserUtils.getCurrentPrincipleID());
|
|
|
lantoneProduct.setGmtModified(DateUtil.now());
|
|
|
- if(updateProductVO.getServiceStatus()==StatusEnum.Disable.getKey()){
|
|
|
+ if(updateProductVO.getServiceStatus().intValue() == StatusEnum.Disable.getKey()){
|
|
|
Page page =new Page();
|
|
|
OpenedProductsIndex openedProductsIndex =new OpenedProductsIndex();
|
|
|
openedProductsIndex.setProductId(updateProductVO.getId());
|
|
|
openedProductsIndex.setServiceStatus(StatusEnum.Enable.getKey());
|
|
|
- if(openedProductsFacade.getByProductId(page,openedProductsIndex).getRecords().size()>0){
|
|
|
+ if(openedProductsFacade.getByProductId(page,openedProductsIndex).getRecords().size() > 0){
|
|
|
throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
"用户正在使用中,停用失败");
|
|
|
}
|
|
|
+ OrderDetailsIndex orderDetailsIndex =new OrderDetailsIndex();
|
|
|
+ orderDetailsIndex.setProductId(updateProductVO.getId());
|
|
|
+ orderDetailsIndex.setAuditStatus(AuditStatusEnum.NotAudit.getKey());
|
|
|
+ if(orderDetailsFacade.seleAllOrderDetials(orderDetailsIndex).size() > 0){
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
+ "该产品无法停用,请先处理申请信息");
|
|
|
+ }
|
|
|
+ UserRenewalsWrapper renewalsInfosDTO =new UserRenewalsWrapper();
|
|
|
+ renewalsInfosDTO.setProductId(updateProductVO.getId());
|
|
|
+ renewalsInfosDTO.setRenewalsStatus(RenewalsEnum.NOT_RENEWALS.getKey());
|
|
|
+ List<RenewalsInfosDTO> list = userRenewalsFacade.selectUserRenewals(page,renewalsInfosDTO).getRecords();
|
|
|
+ UserRenewals userRenewals = new UserRenewals();
|
|
|
+ userRenewals.setRenewalsStatus(RenewalsEnum.NOT_RENEWALS.getKey());
|
|
|
+ userRenewals.setCancelRenewals(CancelRenewalsEnum.NOT_CANCEL.getKey());
|
|
|
+ if(list.contains(userRenewals)){
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
+ "该产品无法停用,请先处理续费申请信息");
|
|
|
+ }
|
|
|
}
|
|
|
if (!updateById(lantoneProduct)) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
+ throw new CommonException(CommonErrorCode.UPDATE_INFO_FAIL,
|
|
|
"产品修改失败");
|
|
|
}
|
|
|
return true;
|
|
@@ -148,7 +198,11 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
|
|
|
* @return Boolean true
|
|
|
*/
|
|
|
public Boolean deleteProduct(UpdateProductVO updateProductVO) {
|
|
|
- LantoneProduct lantoneProduct = getById(updateProductVO.getId());
|
|
|
+ LantoneProduct lantoneProduct = this.getById(updateProductVO.getId());
|
|
|
+ if(lantoneProduct.getIsDeleted().equals(IsDeleteEnum.Y.getKey())){
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS,
|
|
|
+ "该产品已删除");
|
|
|
+ }
|
|
|
if(lantoneProduct.getServiceStatus()==StatusEnum.Enable.getKey()){
|
|
|
throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
"当前产品正在使用中不可删除");
|
|
@@ -164,9 +218,13 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
|
|
|
lantoneProduct.setGmtModified(DateUtil.now());
|
|
|
lantoneProduct.setIsDeleted(IsDeleteEnum.Y.getKey());
|
|
|
if (!updateById(lantoneProduct)) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
+ throw new CommonException(CommonErrorCode.UPDATE_INFO_FAIL,
|
|
|
"产品删除失败");
|
|
|
}
|
|
|
+ if(!productServiceFacade.deleteByProductId(updateProductVO.getId())){
|
|
|
+ throw new CommonException(CommonErrorCode.UPDATE_INFO_FAIL,
|
|
|
+ "产品令牌删除失败");
|
|
|
+ }
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -182,7 +240,7 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
|
|
|
userIdList.add(userId);
|
|
|
RespDTO<Map<Long, UserOrgDTO>> mapRespDTO = userServiceClient.getUserAndOrg(userIdList);
|
|
|
if (mapRespDTO == null || !"0".equals(mapRespDTO.code)) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
+ throw new CommonException(CommonErrorCode.RPC_ERROR,
|
|
|
"获取用户机构信息失败");
|
|
|
}
|
|
|
|
|
@@ -202,6 +260,18 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
|
|
|
String[] accessTypeArray = new String[accessType.length];
|
|
|
String[] chargeTypeArray = new String[chargeType.length];
|
|
|
|
|
|
+ // 仅线上模式
|
|
|
+ if (accessType.length == 1 && Integer.valueOf(accessType[0]).equals(AccessTypeEnum.Online.getKey())) {
|
|
|
+ product.setOnlyOnline(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 产品是否在有效期内 该产品未在有效服务期内,无法使用
|
|
|
+ if (product.getEndTime().before(new Date())) {
|
|
|
+ product.setIsExpired(true);
|
|
|
+ } else if (product.getStartTime().after(new Date())) {
|
|
|
+ product.setUnStarted(true);
|
|
|
+ }
|
|
|
+
|
|
|
for (int i = 0; i < accessType.length; i++) {
|
|
|
accessTypeArray[i] = AccessTypeEnum.getName(Integer.parseInt(accessType[i]));
|
|
|
}
|
|
@@ -250,19 +320,13 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
|
|
|
productLineDTO.setProductAudit(ProductAuditEnum.NotOpend.getKey());
|
|
|
}
|
|
|
}
|
|
|
- RespDTO<Map<Long, UserOrgDTO>> mapRespDTO = userServiceClient.getUserAndOrg(userIdList);
|
|
|
+ RespDTO<User> mapRespDTO = userServiceClient.getUserAuthStatus(userId);
|
|
|
if (mapRespDTO == null || !"0".equals(mapRespDTO.code)) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
+ throw new CommonException(CommonErrorCode.RPC_ERROR,
|
|
|
"获取用户机构信息失败");
|
|
|
}
|
|
|
- Map<Long, UserOrgDTO> dataMap =mapRespDTO.data;
|
|
|
- UserOrgDTO uo =dataMap.get(userId);
|
|
|
Map map =new HashMap();
|
|
|
- if(uo.getAuStatus() == null){
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
- "账号信息不完善");
|
|
|
- }
|
|
|
- map.put("userAuStatus",uo.getAuStatus());
|
|
|
+ map.put("userAuStatus",mapRespDTO.data.getAuthStatus());
|
|
|
List list =new ArrayList();
|
|
|
list.add(productLineDTOList);
|
|
|
list.add(map);
|
|
@@ -276,13 +340,34 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
|
|
|
* @return 当条产品线下所有订单信息
|
|
|
*/
|
|
|
public IPage<OpendProductDTO> opendedProduct(OppendedProductVO oppendedProductVO) {
|
|
|
+ LantoneProduct lantoneProduct = new LantoneProduct();
|
|
|
+ lantoneProduct.setId(oppendedProductVO.getProductId());
|
|
|
+ LantoneProduct lantoneProducts = this.getById(lantoneProduct.getId());
|
|
|
+ if(lantoneProducts.getIsDeleted().equals(IsDeleteEnum.Y.getKey())){
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS,
|
|
|
+ "该产品已删除");
|
|
|
+ }
|
|
|
Page page =new Page();
|
|
|
BeanUtil.copyProperties(oppendedProductVO,page);
|
|
|
OpenedProductsIndex openedProductsIndex = new OpenedProductsIndex();
|
|
|
BeanUtil.copyProperties(oppendedProductVO, openedProductsIndex);
|
|
|
if(oppendedProductVO.getOrgName()!=null&&oppendedProductVO.getOrgName()!=""){
|
|
|
RespDTO<List<Long>> rlist = userServiceClient.getUserByOrgName(oppendedProductVO.getOrgName());
|
|
|
+ if(rlist.data.size() == 0){
|
|
|
+ rlist.data.add(-1L);
|
|
|
+ }
|
|
|
openedProductsIndex.setUserId(rlist.data);
|
|
|
+ }else{
|
|
|
+ RespDTO<List<User>> userInfiList = userServiceClient.getUserAllInfo();
|
|
|
+ if(userInfiList == null || !"0".equals(userInfiList.code) ) {
|
|
|
+ throw new CommonException(CommonErrorCode.RPC_ERROR,
|
|
|
+ "获取用户和机构信息失败");
|
|
|
+ }
|
|
|
+ List<Long> userIds =new ArrayList<>();
|
|
|
+ for (User user:userInfiList.data) {
|
|
|
+ userIds.add(user.getId());
|
|
|
+ }
|
|
|
+ openedProductsIndex.setUserId(userIds);
|
|
|
}
|
|
|
List<OpendProductDTO> list = openedProductsFacade.getByProductId(page,openedProductsIndex).getRecords();
|
|
|
List<Long> list1 = new ArrayList<>();
|
|
@@ -292,7 +377,7 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
|
|
|
}
|
|
|
RespDTO<Map<Long, UserOrgDTO>> mapRespDTO = userServiceClient.getUserAndOrg(list1);
|
|
|
if (mapRespDTO == null || !"0".equals(mapRespDTO.code)) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
+ throw new CommonException(CommonErrorCode.RPC_ERROR,
|
|
|
"获取用户和机构信息失败");
|
|
|
}
|
|
|
Map<Long, UserOrgDTO> dataMap = mapRespDTO.data;
|
|
@@ -315,8 +400,24 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
|
|
|
Page page =new Page();
|
|
|
BeanUtil.copyProperties(lantoneProductSelectVO,page);
|
|
|
IPage<LantoneProductDTO> res = this.selectProduct(page, lantoneProductSelectVO.getName());
|
|
|
+ String charName = null;
|
|
|
+ String acssName = null;
|
|
|
for (LantoneProductDTO lantoneProductDTO:res.getRecords()) {
|
|
|
+ String charNamebc =new String();
|
|
|
+ String acssNamebc =new String();
|
|
|
+ charName =lantoneProductDTO.getChargeType();
|
|
|
+ acssName =lantoneProductDTO.getAccessType();
|
|
|
lantoneProductDTO.setTrialStatusName(TrialStatusEnum.getName(lantoneProductDTO.getTrialStatus()));
|
|
|
+ String[] strs =charName.split(",");
|
|
|
+ for (int i = 0; i<strs.length;i++){
|
|
|
+ charNamebc += ChargeTypeEnum.getName(Integer.parseInt(strs[i]))+",";
|
|
|
+ }
|
|
|
+ String[] strs1 = acssName.split(",");
|
|
|
+ for (int j = 0; j<strs1.length;j++){
|
|
|
+ acssNamebc += AccessTypeEnum.getName(Integer.parseInt(strs1[j]))+",";
|
|
|
+ }
|
|
|
+ lantoneProductDTO.setChargeTypeName(charNamebc);
|
|
|
+ lantoneProductDTO.setAccessTypeName(acssNamebc);
|
|
|
}
|
|
|
return RespDTO.onSuc(res);
|
|
|
}
|