Commit adc0eb3d authored by zhangfeng's avatar zhangfeng

订单V值规则触发

parent a1e8bcbe
package cn.iocoder.boot.module.order.api;
import cn.iocoder.boot.module.order.api.dto.OrderItemRespDTO;
import cn.iocoder.boot.module.order.api.dto.OrderRespDTO;
import java.util.List;
/**
* 订单 api
*/
......@@ -14,4 +17,8 @@ public interface OrderApi {
* 判断是否用户首单
*/
boolean isFirstOrder(Long userId);
/**
* 根据订单id获取所有订单项
*/
List<OrderItemRespDTO> getOrderItemsByOrderId(Long orderId);
}
package cn.iocoder.boot.module.order.api.dto;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.apache.commons.lang3.StringUtils;
/**
* 订单收货人信息 DO
*
* @author 系统管理员
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class OrderConsigneeApiDO extends BaseDO {
/**
* 主键ID
*/
@TableId
private Long id;
/**
* 下单用户id
*/
private Long relationId;
/**
* 订单id
*/
private Long orderId;
/**
* 收货人姓名
*/
private String name;
/**
* 收货人姓名(英文)
*/
private String nameEn;
/**
* 手机
*/
private String phone;
/**
* 邮箱
*/
private String email;
/**
* 公司
*/
private String company;
/**
* 公司(英文)
*/
private String companyEn;
@ApiModelProperty(value = "收获方式:1 自提 2 送货上门 ")
private Integer harvestMethod;
@ApiModelProperty(value = "送货时间", required = true)
private String deliveryDate;
/**
* 地址
*/
private String address;
@ApiModelProperty(value = "国家")
private Long country;
@ApiModelProperty(value = "省")
private Long province;
@ApiModelProperty(value = "市")
private Long city;
/**
* 国家简称
*/
private String countryAbbreviation;
/**
* 国家区号
*/
private String countryCode;
/**
* 客户id
*/
private Long customerId;
/**
* 客户联系人id
*/
private Long customerContactsId;
public void setCountryCode(String countryCode) {
if (StringUtils.isNotBlank(countryCode)) {
this.countryCode = countryCode.replace("+", "");
}else {
this.countryCode = countryCode;
}
}
}
package cn.iocoder.boot.module.order.api.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class OrderItemRespDTO {
@ApiModelProperty(value = "收费重量")
private BigDecimal chargeWeight;
@ApiModelProperty(value = "收费体积")
private BigDecimal chargeVolume;
}
......@@ -278,6 +278,11 @@ public class OrderRespDTO {
@NotNull(message = "目的地信息不能为空")
private OrderObjectiveApiDO orderObjectiveDO;
@TableField(exist = false)
@ApiModelProperty(value = "收货人信息")
@NotNull(message = "收货人信息不能为空")
private OrderConsigneeApiDO orderConsigneeDO;
@TableField(exist = false)
@ApiModelProperty(value = "目的地ID")
private Long objectiveId;
......
package cn.iocoder.yudao.module.order.api;
import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.boot.module.order.api.OrderApi;
import cn.iocoder.boot.module.order.api.dto.OrderConsigneeApiDO;
import cn.iocoder.boot.module.order.api.dto.OrderItemRespDTO;
import cn.iocoder.boot.module.order.api.dto.OrderObjectiveApiDO;
import cn.iocoder.boot.module.order.api.dto.OrderRespDTO;
import cn.iocoder.yudao.module.order.dal.dataobject.order.OrderDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderConsignee.OrderConsigneeDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderItem.OrderItemDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderObjective.OrderObjectiveDO;
import cn.iocoder.yudao.module.order.service.order.OrderConsigneeService;
import cn.iocoder.yudao.module.order.service.order.OrderObjectiveService;
import cn.iocoder.yudao.module.order.service.order.OrderService;
import cn.iocoder.yudao.module.order.service.order.impl.OrderItemServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
@Service
@Validated
......@@ -21,6 +30,10 @@ public class OrderApiImpl implements OrderApi {
private OrderService orderService;
@Resource
private OrderObjectiveService objectiveService;
@Resource
private OrderConsigneeService orderConsigneeService;
@Resource
private OrderItemServiceImpl orderItemService;
@Override
public OrderRespDTO getOrder(Long id, String orderNo) {
......@@ -36,13 +49,22 @@ public class OrderApiImpl implements OrderApi {
OrderRespDTO orderRespDTO = new OrderRespDTO();
BeanUtils.copyProperties(orderDO, orderRespDTO);
// 设置目的地信息
OrderObjectiveDO orderObjectiveDO = objectiveService.getByOrderId(id);
if (orderObjectiveDO == null) {
return orderRespDTO;
if (orderObjectiveDO != null) {
OrderObjectiveApiDO orderObjectiveApiDO = new OrderObjectiveApiDO();
BeanUtils.copyProperties(orderObjectiveDO, orderObjectiveApiDO);
orderRespDTO.setOrderObjectiveDO(orderObjectiveApiDO);
}
OrderObjectiveApiDO orderObjectiveApiDO = new OrderObjectiveApiDO();
BeanUtils.copyProperties(orderObjectiveDO, orderObjectiveApiDO);
orderRespDTO.setOrderObjectiveDO(orderObjectiveApiDO);
// 设置收货人信息
OrderConsigneeDO orderConsigneeByOrderId = orderConsigneeService.getOrderConsigneeByOrderId(id);
if (orderConsigneeByOrderId != null) {
OrderConsigneeApiDO orderConsigneeApiDO = new OrderConsigneeApiDO();
BeanUtils.copyProperties(orderConsigneeByOrderId, orderConsigneeApiDO);
orderRespDTO.setOrderConsigneeDO(orderConsigneeApiDO);
}
return orderRespDTO;
}
......@@ -51,4 +73,13 @@ public class OrderApiImpl implements OrderApi {
Long count = orderService.selectCount(new LambdaQueryWrapper<OrderDO>().eq(OrderDO::getUserId, userId));
return count <= 0;
}
@Override
public List<OrderItemRespDTO> getOrderItemsByOrderId(Long orderId) {
List<OrderItemDO> orderItemDOS = orderItemService.selectList("order_id", orderId);
if (CollectionUtil.isNotEmpty(orderItemDOS)) {
return orderItemDOS.stream().map(orderItemDO -> new OrderItemRespDTO(orderItemDO.getChargeWeight(), orderItemDO.getChargeVolume())).collect(Collectors.toList());
}
return null;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment