|
@@ -5,16 +5,14 @@ import com.diagbot.dto.WaitExamOrderCouDTO;
|
|
|
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.exception.CommonException;
|
|
|
import com.diagbot.idc.VisibleIdCreater;
|
|
|
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;
|
|
@@ -60,45 +58,32 @@ public class ProductOrderFacade extends ProductOrderServiceImpl {
|
|
|
* @Date: 19:59 2018/9/18
|
|
|
*/
|
|
|
@Transactional
|
|
|
- public CommonErrorCode addOrders(AddOrderVO addOrderVO){
|
|
|
+ public Boolean addOrders(AddOrderVO addOrderVO){
|
|
|
Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
|
|
|
ProductOrder productOrder =new ProductOrder();
|
|
|
productOrder.setCreator(UserUtils.getCurrentPrincipleID());
|
|
|
productOrder.setGmtCreate(DateUtil.now());
|
|
|
- String imgId = visibleIdCreater.getNextId(VisibleIdTypeEnum.IS_ORDER.getKey()).toString();
|
|
|
- productOrder.setNum(imgId);
|
|
|
+ String orderNum = visibleIdCreater.getNextId(VisibleIdTypeEnum.IS_ORDER.getKey()).toString();
|
|
|
+ productOrder.setNum(orderNum);
|
|
|
productOrder.setUserId(userId);
|
|
|
productOrder.setTime(DateUtil.now());
|
|
|
if(!save(productOrder)){
|
|
|
- return CommonErrorCode.FAIL;
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,"添加订单失败");
|
|
|
}
|
|
|
- for (Long o:addOrderVO.getProductId()
|
|
|
- ) {
|
|
|
+ for (Long o:addOrderVO.getProductId()) {
|
|
|
LantoneProduct lantoneProduct = lantoneProductFacade.selectLanProduct(o);
|
|
|
if(null==lantoneProduct){
|
|
|
- return CommonErrorCode.FAIL;
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,"获取产品信息失败:"+o);
|
|
|
}
|
|
|
OrderDetails orderDetails =new OrderDetails();
|
|
|
orderDetails.setUserId(1l);
|
|
|
- orderDetails.setOrderNum(imgId);
|
|
|
+ orderDetails.setOrderNum(orderNum);
|
|
|
orderDetails.setGmtCreate(DateUtil.now());
|
|
|
- orderDetails.setCreator("");
|
|
|
+ orderDetails.setCreator(UserUtils.getCurrentPrincipleID());
|
|
|
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);
|
|
|
- }
|
|
|
+ orderDetailsFacade.save(orderDetails);
|
|
|
}
|
|
|
-
|
|
|
- return CommonErrorCode.OK;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
/**
|