|
@@ -1,7 +1,10 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
import com.diagbot.dto.ProductAuthProgressDTO;
|
|
|
+import com.diagbot.entity.LantoneProduct;
|
|
|
+import com.diagbot.entity.OrderDetails;
|
|
|
import com.diagbot.entity.ProductOrder;
|
|
|
+import com.diagbot.entity.ServiceInfo;
|
|
|
import com.diagbot.enums.VisibleIdTypeEnum;
|
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.idc.VisibleIdCreater;
|
|
@@ -9,8 +12,11 @@ import com.diagbot.service.impl.ProductOrderServiceImpl;
|
|
|
import com.diagbot.util.DateUtil;
|
|
|
import com.diagbot.util.UserUtils;
|
|
|
import com.diagbot.vo.AddOrderVO;
|
|
|
+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;
|
|
@@ -24,7 +30,15 @@ import java.util.List;
|
|
|
public class ProductOrderFacade extends ProductOrderServiceImpl {
|
|
|
@Autowired
|
|
|
private VisibleIdCreater visibleIdCreater;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private OrderDetailsFacade orderDetailsFacade;
|
|
|
+ @Autowired
|
|
|
+ private ServiceInfoFacade serviceInfoFacade;
|
|
|
+ @Autowired
|
|
|
+ private LantoneProductFacade lantoneProductFacade;
|
|
|
+ @Autowired
|
|
|
+ private ProductServiceFacade productServiceFacade;
|
|
|
+
|
|
|
public List<ProductAuthProgressDTO> productAuthProgress(){
|
|
|
List<ProductAuthProgressDTO> retList = new ArrayList<ProductAuthProgressDTO>();
|
|
|
Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
|
|
@@ -44,16 +58,45 @@ public class ProductOrderFacade extends ProductOrderServiceImpl {
|
|
|
* @Author: wangyu
|
|
|
* @Date: 19:59 2018/9/18
|
|
|
*/
|
|
|
+ @Transactional
|
|
|
public CommonErrorCode addOrders(AddOrderVO addOrderVO){
|
|
|
- /*Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());*/
|
|
|
+ Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
|
|
|
ProductOrder productOrder =new ProductOrder();
|
|
|
- productOrder.setCreator(/*UserUtils.getCurrentPrincipleID()*/"1");
|
|
|
+ productOrder.setCreator(UserUtils.getCurrentPrincipleID());
|
|
|
productOrder.setGmtCreate(DateUtil.now());
|
|
|
String imgId = visibleIdCreater.getNextId(VisibleIdTypeEnum.IS_ORDER.getKey()).toString();
|
|
|
productOrder.setNum(imgId);
|
|
|
- productOrder.setUserId(/*userId*/1l);
|
|
|
+ productOrder.setUserId(userId);
|
|
|
productOrder.setTime(DateUtil.now());
|
|
|
- addOrder(productOrder);
|
|
|
+ if(!save(productOrder)){
|
|
|
+ return CommonErrorCode.FAIL;
|
|
|
+ }
|
|
|
+ for (Long o:addOrderVO.getProductId()
|
|
|
+ ) {
|
|
|
+ LantoneProduct lantoneProduct = lantoneProductFacade.selectLanProduct(o);
|
|
|
+ if(null==lantoneProduct){
|
|
|
+ return CommonErrorCode.FAIL;
|
|
|
+ }
|
|
|
+ OrderDetails orderDetails =new OrderDetails();
|
|
|
+ orderDetails.setUserId(1l);
|
|
|
+ orderDetails.setOrderNum(imgId);
|
|
|
+ orderDetails.setGmtCreate(DateUtil.now());
|
|
|
+ orderDetails.setCreator("");
|
|
|
+ orderDetails.setProductId(o);
|
|
|
+ if(orderDetailsFacade.addOrderDetails(orderDetails)){
|
|
|
+ ServiceSaveVO serviceSaveVO =new ServiceSaveVO();
|
|
|
+ ProductServiceSaveVO productServiceSaveVO =new ProductServiceSaveVO();
|
|
|
+ serviceSaveVO.setDescription(lantoneProduct.getDecription());
|
|
|
+ serviceSaveVO.setName(lantoneProduct.getName());
|
|
|
+ serviceSaveVO.setType(1);
|
|
|
+ ServiceInfo serviceInfo = serviceInfoFacade.createService(serviceSaveVO);
|
|
|
+ productServiceSaveVO.setProductId(o);
|
|
|
+ productServiceSaveVO.setServiceId(serviceInfo.getId());
|
|
|
+ productServiceSaveVO.setType(1);
|
|
|
+ productServiceFacade.genProductService(productServiceSaveVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return CommonErrorCode.OK;
|
|
|
}
|
|
|
|