|
@@ -1,10 +1,33 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.diagbot.client.UserServiceClient;
|
|
|
+import com.diagbot.dto.RespDTO;
|
|
|
+import com.diagbot.dto.UserOrgDTO;
|
|
|
+import com.diagbot.entity.LantoneProduct;
|
|
|
+import com.diagbot.entity.OpenedProducts;
|
|
|
import com.diagbot.entity.OrderDetails;
|
|
|
+import com.diagbot.entity.OrderDetailsIndex;
|
|
|
+import com.diagbot.entity.ServiceInfo;
|
|
|
+import com.diagbot.entity.wrapper.OrderDetailsWapper;
|
|
|
+import com.diagbot.enums.AuditStatusEnum;
|
|
|
+import com.diagbot.enums.TokenTypeEnum;
|
|
|
+import com.diagbot.exception.CommonErrorCode;
|
|
|
+import com.diagbot.exception.CommonException;
|
|
|
import com.diagbot.service.impl.OrderDetailsServiceImpl;
|
|
|
+import com.diagbot.util.BeanUtil;
|
|
|
+import com.diagbot.util.DateUtil;
|
|
|
+import com.diagbot.util.UserUtils;
|
|
|
+import com.diagbot.vo.AuditStatusVO;
|
|
|
+import com.diagbot.vo.OrderDetialsVO;
|
|
|
+import com.diagbot.vo.ProductServiceSaveVO;
|
|
|
+import com.diagbot.vo.ServiceSaveVO;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @Description:
|
|
@@ -13,13 +36,115 @@ import org.springframework.stereotype.Component;
|
|
|
*/
|
|
|
@Component
|
|
|
public class OrderDetailsFacade extends OrderDetailsServiceImpl{
|
|
|
+ @Autowired
|
|
|
+ private OpenedProductsFacade openedProductsFacade;
|
|
|
+ @Autowired
|
|
|
+ private LantoneProductFacade lantoneProductFacade;
|
|
|
+ @Autowired
|
|
|
+ private ServiceInfoFacade serviceInfoFacade;
|
|
|
+ @Autowired
|
|
|
+ private ProductServiceFacade productServiceFacade;
|
|
|
+ @Autowired
|
|
|
+ private UserServiceClient userServiceClient;
|
|
|
/**
|
|
|
- * @Description: 分页查询订单明细
|
|
|
+ * @Description: 产品申请审核接口
|
|
|
* @Author: wangyu
|
|
|
- * @Date: 21:50 2018/9/24
|
|
|
+ * @Date: 21:39 2018/9/24
|
|
|
*/
|
|
|
- public IPage<OrderDetails> orderDetialShows(Page page,OrderDetails orderDetails){
|
|
|
- IPage<OrderDetails> orderDetailsIPage =this.orderDetialShow(page,orderDetails);
|
|
|
- return orderDetailsIPage;
|
|
|
+ @Transactional
|
|
|
+ public Boolean updateAuditStatus(AuditStatusVO auditStatusVO){
|
|
|
+ OrderDetails orderDetails =this.getById(auditStatusVO.getId());
|
|
|
+ if(orderDetails==null){
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
+ "订单明细不存在");
|
|
|
+ }
|
|
|
+ orderDetails.setGmtModified(DateUtil.now());
|
|
|
+ orderDetails.setModifier(UserUtils.getCurrentPrincipleID());
|
|
|
+ orderDetails.setAuditStatus(auditStatusVO.getAuditStatus());
|
|
|
+ //TODO 审核不通过
|
|
|
+ if(auditStatusVO.getAuditStatus()== AuditStatusEnum.Veto.getKey()){
|
|
|
+ if(!this.updateById(orderDetails)){
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
+ "审核状态修改失败");
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ //TODO 审核通过 添加已开通产品 判断产品类型是否有online(添加服务 服务产品表 token表)
|
|
|
+ if(!this.updateById(orderDetails)){
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
+ "审核状态修改失败");
|
|
|
+ }
|
|
|
+ Long userId =Long.parseLong(UserUtils.getCurrentPrincipleID());
|
|
|
+ OpenedProducts openedProducts =new OpenedProducts();
|
|
|
+ openedProducts.setGmtCreate(DateUtil.now());
|
|
|
+ openedProducts.setCreator(UserUtils.getCurrentPrincipleID());
|
|
|
+ openedProducts.setProductId(1L);
|
|
|
+ openedProducts.setUserId(userId);
|
|
|
+ openedProducts.setStartTime(auditStatusVO.getStartTime());
|
|
|
+ openedProducts.setEndTime(auditStatusVO.getEndTime());
|
|
|
+ openedProducts.setOrderId(1L);
|
|
|
+ openedProductsFacade.save(openedProducts);
|
|
|
+ LantoneProduct lantoneProduct =new LantoneProduct();
|
|
|
+ if(lantoneProductFacade.getById(lantoneProduct).getAccessType().indexOf(TokenTypeEnum.Online.getKey())==-1){
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
+ "该产品没有线上模式");
|
|
|
+ }
|
|
|
+ ServiceSaveVO serviceSaveVO =new ServiceSaveVO();
|
|
|
+ serviceSaveVO.setDescription(lantoneProduct.getDecription());
|
|
|
+ serviceSaveVO.setName(lantoneProduct.getName());
|
|
|
+ serviceSaveVO.setType(TokenTypeEnum.Online.getKey());
|
|
|
+ ServiceInfo serviceInfo = serviceInfoFacade.createService(serviceSaveVO);
|
|
|
+ ProductServiceSaveVO productServiceSaveVO =new ProductServiceSaveVO();
|
|
|
+ productServiceSaveVO.setProductId(auditStatusVO.getId());
|
|
|
+ productServiceSaveVO.setServiceId(serviceInfo.getId());
|
|
|
+ productServiceSaveVO.setType(TokenTypeEnum.Online.getKey());
|
|
|
+ productServiceFacade.genProductService(productServiceSaveVO);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Description: 产品申请查询所有订单明细
|
|
|
+ * @Author: wangyu
|
|
|
+ * @Date: 16:19 2018/9/21
|
|
|
+ */
|
|
|
+ public List<OrderDetailsWapper> getAllOrderDetials(OrderDetialsVO orderDetialsVO){
|
|
|
+ OrderDetailsIndex orderDetailsIndex =new OrderDetailsIndex();
|
|
|
+ Long curren = orderDetialsVO.getCurrent();
|
|
|
+ Long size =orderDetialsVO.getSize();
|
|
|
+ if(curren==null){
|
|
|
+ orderDetialsVO.setCurrent(1L);
|
|
|
+ }
|
|
|
+ if (size==null){
|
|
|
+ orderDetialsVO.setSize(10L);
|
|
|
+ }
|
|
|
+ BeanUtil.copyProperties(orderDetialsVO, orderDetailsIndex);
|
|
|
+ orderDetailsIndex.setIndex((orderDetialsVO.getCurrent().longValue()-1)*orderDetialsVO.getSize().longValue());
|
|
|
+
|
|
|
+ orderDetailsIndex.setUserId(1L);
|
|
|
+ List<OrderDetailsWapper> list =this.seleAllOrderDetials(orderDetailsIndex);
|
|
|
+ List<Long> list1 =new ArrayList<>();
|
|
|
+ for (OrderDetails orderDetails:list) {
|
|
|
+ Long longs = orderDetails.getUserId();
|
|
|
+ list1.add(longs);
|
|
|
+ }
|
|
|
+ RespDTO<Map<Long, UserOrgDTO>> mapRespDTO = userServiceClient.getUserAndOrg(list1);
|
|
|
+ if(mapRespDTO == null || !"0".equals(mapRespDTO.code) ) {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
+ "获取用户和机构信息失败");
|
|
|
+ }
|
|
|
+ Map<Long, UserOrgDTO> dataMap = mapRespDTO.data;
|
|
|
+ for(OrderDetailsWapper bean : list) {
|
|
|
+ UserOrgDTO uo = dataMap.get(bean.getUserId());
|
|
|
+ if(uo != null) {
|
|
|
+ bean.setUsername(uo.getUsername());
|
|
|
+ bean.setLinkman(uo.getLinkman());
|
|
|
+ bean.setEmail(uo.getEmail());
|
|
|
+ bean.setOrgId(uo.getOrgId());
|
|
|
+ bean.setOrgName(uo.getOrgName());
|
|
|
+ bean.setIsReject(uo.getIsReject());
|
|
|
+ bean.setAuStatus(uo.getAuStatus());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
}
|
|
|
}
|