Commit 31c45ee6 by 丁伟峰

订单创建接口实现

1 parent ac6441f3
package com.alibaba.cloud.integration.order.dao;
import com.alibaba.cloud.integration.order.entity.OrderRequestEntity;
import org.springframework.data.jpa.repository.JpaRepository;
public interface OrderReqeustDao extends JpaRepository <OrderRequestEntity, Long> {
}
......@@ -15,5 +15,5 @@ public class OrderCreateReqDTO {
private String expectEnd;
private String priority;
private String orderTags;
private String memo;
private String description;
}
......@@ -16,6 +16,8 @@
package com.alibaba.cloud.integration.order.entity;
import lombok.Data;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
......@@ -23,7 +25,8 @@ import javax.persistence.Id;
import java.io.Serializable;
@Entity
public class OrderRequestEntity implements Serializable {
@Data
public class OrderRequestEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
......
......@@ -17,7 +17,10 @@
package com.alibaba.cloud.integration.order.service.impl;
import com.alibaba.cloud.integration.common.Result;
import com.alibaba.cloud.integration.order.dao.OrderReqeustDao;
import com.alibaba.cloud.integration.order.dto.LocationDTO;
import com.alibaba.cloud.integration.order.dto.OrderCreateReqDTO;
import com.alibaba.cloud.integration.order.entity.OrderRequestEntity;
import com.alibaba.cloud.integration.order.feign.AccountServiceFeignClient;
import com.alibaba.cloud.integration.order.feign.StorageServiceFeignClient;
import com.alibaba.cloud.integration.order.mapper.OrderMapper;
......@@ -33,22 +36,37 @@ import org.springframework.stereotype.Service;
@Service
public class OrderServiceImpl implements OrderService {
@Autowired
private OrderMapper orderMapper;
@Autowired
private OrderReqeustDao orderReqeustDao;
@Autowired
private AccountServiceFeignClient accountService;
@Autowired
private StorageServiceFeignClient storageService;
@Override
@GlobalTransactional
public Result<?> createOrder(OrderCreateReqDTO orderCreateReqDTO) {
log.info("[createOrder] current XID: {}", RootContext.getXID());
return null;
}
@Override
@GlobalTransactional
public Result<?> createOrder(OrderCreateReqDTO req) {
log.info("[createOrder] current XID: {}", RootContext.getXID());
OrderRequestEntity entity = new OrderRequestEntity();
entity.setName(req.getName());
entity.setPhone(req.getPhone());
entity.setAddress(req.getAddress());
entity.setBrand(req.getBrand());
entity.setCategoryId(req.getCatalogId());
entity.setFaultDescribe(req.getFaultDescribe());
entity.setExpectTimeBegin(req.getExpectBegin());
entity.setExpectTimeEnd(req.getExpectEnd());
entity.setDescription(req.getDescription());
// location
LocationDTO location = req.getLocation();
entity.setProvince(location.getProvince());
entity.setCity(location.getCity());
entity.setCounty(location.getCountry());
orderReqeustDao.save(entity);
// 根据orderTags, 解析保存到type、skill等字段
String[] l = req.getLocation().getLocation().split(",");
entity.setX(l[0]);
entity.setY(l[1]);
// todo 服务单状态、预约状态等
entity.setStatus("");
entity.setAppointmentStatus("");
return Result.success(null);
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!