6 changed files with 466 additions and 0 deletions
@ -0,0 +1,19 @@ |
|||||
|
package cc.hiver.core.dao; |
||||
|
|
||||
|
import cc.hiver.core.base.HiverBaseDao; |
||||
|
import cc.hiver.core.entity.Order; |
||||
|
import cc.hiver.core.entity.Order; |
||||
|
import org.springframework.data.jpa.repository.Modifying; |
||||
|
import org.springframework.data.jpa.repository.Query; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 用户数据处理层 |
||||
|
* |
||||
|
* @author Houpn |
||||
|
*/ |
||||
|
public interface OrderDao extends HiverBaseDao<Order, String> { |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,107 @@ |
|||||
|
package cc.hiver.core.entity; |
||||
|
|
||||
|
import cc.hiver.core.base.HiverBaseEntity; |
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
import lombok.experimental.Accessors; |
||||
|
import org.hibernate.annotations.DynamicInsert; |
||||
|
import org.hibernate.annotations.DynamicUpdate; |
||||
|
|
||||
|
import javax.persistence.Column; |
||||
|
import javax.persistence.Entity; |
||||
|
import javax.persistence.Id; |
||||
|
import javax.persistence.Table; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
@Data |
||||
|
@Accessors(chain = true) |
||||
|
@Entity |
||||
|
@DynamicInsert |
||||
|
@DynamicUpdate |
||||
|
@Table(name = "t_order") |
||||
|
@TableName("t_order") |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
@ApiModel(value = "下单") |
||||
|
public class Order extends HiverBaseEntity { |
||||
|
|
||||
|
/** |
||||
|
* 订单号,默认前缀为XD |
||||
|
*/ |
||||
|
@ApiModelProperty("订单号,默认前缀为XD") |
||||
|
@Column(name = "order_id", nullable = false) |
||||
|
private String orderId; |
||||
|
|
||||
|
/** |
||||
|
* 订单运送地址 |
||||
|
*/ |
||||
|
@ApiModelProperty("订单运送地址") |
||||
|
@Column(name = "order_address") |
||||
|
private String orderAddress; |
||||
|
|
||||
|
/** |
||||
|
* 物流方式 |
||||
|
*/ |
||||
|
@ApiModelProperty("物流方式") |
||||
|
@Column(name = "order_logistics") |
||||
|
private String orderLogistics; |
||||
|
|
||||
|
/** |
||||
|
* 商品信息描述 |
||||
|
*/ |
||||
|
@ApiModelProperty("商品信息描述") |
||||
|
@Column(name = "order_describe") |
||||
|
private String orderDescribe; |
||||
|
|
||||
|
/** |
||||
|
* 订单单位数量 |
||||
|
*/ |
||||
|
@Column(name = "order_num") |
||||
|
@ApiModelProperty("订单单位数量") |
||||
|
private Integer orderNum; |
||||
|
|
||||
|
/** |
||||
|
* 运送快递单号 |
||||
|
*/ |
||||
|
@ApiModelProperty("运送快递单号") |
||||
|
@Column(name = "kd_order_id") |
||||
|
private String kdOrderId; |
||||
|
|
||||
|
/** |
||||
|
* 订单是否超时 |
||||
|
*/ |
||||
|
@ApiModelProperty("订单是否超时") |
||||
|
@Column(name = "is_timeout") |
||||
|
private Boolean timeout; |
||||
|
|
||||
|
/** |
||||
|
* 订单状态 |
||||
|
*/ |
||||
|
@ApiModelProperty("订单状态") |
||||
|
@Column(name = "order_status") |
||||
|
private Integer orderStatus; |
||||
|
|
||||
|
/** |
||||
|
* 订单佣金 |
||||
|
*/ |
||||
|
@ApiModelProperty("订单佣金") |
||||
|
@Column(name = "order_bkge") |
||||
|
private Integer orderBkge; |
||||
|
|
||||
|
/** |
||||
|
* 抢单工编号 |
||||
|
*/ |
||||
|
@ApiModelProperty("抢单工编号") |
||||
|
@Column(name = "order_by_worker") |
||||
|
private String orderByWorker; |
||||
|
|
||||
|
/** |
||||
|
* 被抢单时间 |
||||
|
*/ |
||||
|
@ApiModelProperty("被抢单时间") |
||||
|
@Column(name = "order_by_workertime") |
||||
|
private Date orderByWorkertime; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,31 @@ |
|||||
|
package cc.hiver.core.service; |
||||
|
|
||||
|
import cc.hiver.core.base.HiverBaseService; |
||||
|
import cc.hiver.core.common.vo.SearchVo; |
||||
|
import cc.hiver.core.entity.Order; |
||||
|
import cc.hiver.core.entity.Order; |
||||
|
import org.springframework.cache.annotation.CacheConfig; |
||||
|
import org.springframework.data.domain.Page; |
||||
|
import org.springframework.data.domain.Pageable; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 用户接口 |
||||
|
* |
||||
|
* @author Houpn |
||||
|
*/ |
||||
|
@CacheConfig(cacheNames = "order") |
||||
|
public interface OrderService extends HiverBaseService<Order, String> { |
||||
|
|
||||
|
/** |
||||
|
* 多条件分页获取用户 |
||||
|
* |
||||
|
* @param Order |
||||
|
* @param searchVo |
||||
|
* @param pageable |
||||
|
* @return |
||||
|
*/ |
||||
|
Page<Order> findByCondition(Order Order, SearchVo searchVo, Pageable pageable); |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,99 @@ |
|||||
|
package cc.hiver.core.serviceimpl; |
||||
|
|
||||
|
import cc.hiver.core.common.utils.SecurityUtil; |
||||
|
import cc.hiver.core.common.vo.SearchVo; |
||||
|
import cc.hiver.core.dao.OrderDao; |
||||
|
import cc.hiver.core.entity.Order; |
||||
|
|
||||
|
import cc.hiver.core.service.OrderService; |
||||
|
import cn.hutool.core.date.DateUtil; |
||||
|
import cn.hutool.core.util.StrUtil; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.data.domain.Page; |
||||
|
import org.springframework.data.domain.Pageable; |
||||
|
import org.springframework.data.jpa.domain.Specification; |
||||
|
import org.springframework.lang.Nullable; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import javax.persistence.criteria.*; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
/** |
||||
|
* 用户接口实现 |
||||
|
* |
||||
|
* @author houpn |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Service |
||||
|
@Transactional |
||||
|
public class OrderServiceImpl implements OrderService { |
||||
|
@Autowired |
||||
|
private OrderDao orderDao; |
||||
|
|
||||
|
@Autowired |
||||
|
private SecurityUtil securityUtil; |
||||
|
|
||||
|
@Override |
||||
|
public OrderDao getRepository() { |
||||
|
return orderDao; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Page<Order> findByCondition(Order order, SearchVo searchVo, Pageable pageable) { |
||||
|
return orderDao.findAll(new Specification<Order>() { |
||||
|
@Nullable |
||||
|
@Override |
||||
|
public Predicate toPredicate(Root<Order> root, CriteriaQuery<?> cq, CriteriaBuilder cb) { |
||||
|
Path<String> OrderIdField = root.get("orderId"); |
||||
|
Path<String> norderLogisticsField = root.get("orderLogistics"); |
||||
|
Path<String> kdOrderIdField = root.get("kdOrderId"); |
||||
|
Path<Boolean> timeoutField = root.get("timeout"); |
||||
|
Path<Integer> orderStatusdField = root.get("orderStatus"); |
||||
|
Path<String> orderByWorkerField = root.get("orderByWorker"); |
||||
|
Path<Date> createTimeField = root.get("createTime"); |
||||
|
|
||||
|
List<Predicate> list = new ArrayList<>(); |
||||
|
|
||||
|
if (StrUtil.isNotBlank(order.getOrderId())) { |
||||
|
list.add(cb.equal(OrderIdField, order.getOrderId())); |
||||
|
} |
||||
|
|
||||
|
// 精确搜索
|
||||
|
if (StrUtil.isNotBlank(order.getOrderLogistics())) { |
||||
|
list.add(cb.like(norderLogisticsField, '%' + order.getOrderLogistics() + '%')); |
||||
|
} |
||||
|
if (StrUtil.isNotBlank(order.getKdOrderId())) { |
||||
|
list.add(cb.like(kdOrderIdField, '%' + order.getKdOrderId() + '%')); |
||||
|
} |
||||
|
|
||||
|
//list.add(cb.equal(timeoutField, order.getTimeout()));
|
||||
|
|
||||
|
// 状态
|
||||
|
if (order.getOrderStatus() != null) { |
||||
|
list.add(cb.equal(orderStatusdField, order.getOrderStatus())); |
||||
|
} |
||||
|
|
||||
|
if (StrUtil.isNotBlank(order.getOrderByWorker())) { |
||||
|
list.add(cb.like(orderByWorkerField, '%' + order.getOrderByWorker() + '%')); |
||||
|
} |
||||
|
// 创建时间
|
||||
|
if (StrUtil.isNotBlank(searchVo.getStartDate()) && StrUtil.isNotBlank(searchVo.getEndDate())) { |
||||
|
Date start = DateUtil.parse(searchVo.getStartDate()); |
||||
|
Date end = DateUtil.parse(searchVo.getEndDate()); |
||||
|
list.add(cb.between(createTimeField, start, DateUtil.endOfDay(end))); |
||||
|
} |
||||
|
|
||||
|
// 数据权限
|
||||
|
|
||||
|
Predicate[] arr = new Predicate[list.size()]; |
||||
|
cq.where(list.toArray(arr)); |
||||
|
return null; |
||||
|
} |
||||
|
}, pageable); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,95 @@ |
|||||
|
package cc.hiver.core.vo; |
||||
|
|
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotNull; |
||||
|
import java.io.Serializable; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
|
||||
|
@Data |
||||
|
@ApiModel("保存 ") |
||||
|
public class OrderVO implements Serializable { |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 订单号,默认前缀为XD |
||||
|
*/ |
||||
|
@NotNull(message = "orderId can not null") |
||||
|
@ApiModelProperty("订单号,默认前缀为XD") |
||||
|
private String orderId; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 订单运送地址 |
||||
|
*/ |
||||
|
@ApiModelProperty("订单运送地址") |
||||
|
private String orderAddress; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 物流方式 |
||||
|
*/ |
||||
|
@ApiModelProperty("物流方式") |
||||
|
private String orderLogistics; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 商品信息描述 |
||||
|
*/ |
||||
|
@ApiModelProperty("商品信息描述") |
||||
|
private String orderDescribe; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 订单单位数量 |
||||
|
*/ |
||||
|
@ApiModelProperty("订单单位数量") |
||||
|
private Integer orderNum; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 运送快递单号 |
||||
|
*/ |
||||
|
@ApiModelProperty("运送快递单号") |
||||
|
private String kdOrderId; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 订单是否超时 |
||||
|
*/ |
||||
|
@ApiModelProperty("订单是否超时") |
||||
|
private Boolean timeout; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 订单状态 |
||||
|
*/ |
||||
|
@ApiModelProperty("订单状态") |
||||
|
private Integer orderStatus; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 订单佣金 |
||||
|
*/ |
||||
|
@ApiModelProperty("订单佣金") |
||||
|
private Integer orderBkge; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 抢单工编号 |
||||
|
*/ |
||||
|
@ApiModelProperty("抢单工编号") |
||||
|
private String orderByWorker; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 被抢单时间 |
||||
|
*/ |
||||
|
@ApiModelProperty("被抢单时间") |
||||
|
private Date orderByWorkertime; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,115 @@ |
|||||
|
package cc.hiver.base.controller.manage; |
||||
|
|
||||
|
import cc.hiver.base.async.AddMessage; |
||||
|
import cc.hiver.core.common.constant.CommonConstant; |
||||
|
import cc.hiver.core.common.constant.UserConstant; |
||||
|
import cc.hiver.core.common.redis.RedisTemplateHelper; |
||||
|
import cc.hiver.core.common.utils.*; |
||||
|
import cc.hiver.core.common.vo.PageVo; |
||||
|
import cc.hiver.core.common.vo.Result; |
||||
|
import cc.hiver.core.common.vo.SearchVo; |
||||
|
import cc.hiver.core.dao.mapper.DeleteMapper; |
||||
|
import cc.hiver.core.entity.*; |
||||
|
import cc.hiver.core.service.*; |
||||
|
import cc.hiver.core.service.mybatis.IUserRoleService; |
||||
|
import cc.hiver.core.vo.RoleDTO; |
||||
|
import cn.hutool.core.util.StrUtil; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import io.swagger.annotations.ApiParam; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.cache.annotation.CacheConfig; |
||||
|
import org.springframework.cache.annotation.CacheEvict; |
||||
|
import org.springframework.data.domain.Page; |
||||
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import javax.persistence.EntityManager; |
||||
|
import javax.persistence.PersistenceContext; |
||||
|
import javax.validation.Valid; |
||||
|
import java.io.UnsupportedEncodingException; |
||||
|
import java.net.URLDecoder; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.Arrays; |
||||
|
import java.util.List; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
/** |
||||
|
* 用户管理接口 |
||||
|
* |
||||
|
* @author Yazhi Li |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@RestController |
||||
|
@Api(tags = "订单接口") |
||||
|
@RequestMapping("/hiver/order") |
||||
|
@CacheConfig(cacheNames = "order") |
||||
|
@Transactional |
||||
|
public class OrderController { |
||||
|
public static final String ORDER = "order::"; |
||||
|
|
||||
|
@Autowired |
||||
|
private OrderService orderService; |
||||
|
|
||||
|
@Autowired |
||||
|
private DeleteMapper deleteMapper; |
||||
|
|
||||
|
@Autowired |
||||
|
private RedisTemplateHelper redisTemplate; |
||||
|
|
||||
|
@Autowired |
||||
|
private SecurityUtil securityUtil; |
||||
|
|
||||
|
@PersistenceContext |
||||
|
private EntityManager entityManager; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
@RequestMapping(value = "/getByCondition", method = RequestMethod.GET) |
||||
|
@ApiOperation(value = "多条件分页获取订单列表") |
||||
|
public Result<Page<Order>> getByCondition(Order order, |
||||
|
SearchVo searchVo, |
||||
|
PageVo pageVo) { |
||||
|
Page<Order> page = orderService.findByCondition(order, searchVo, PageUtil.initPage(pageVo)); |
||||
|
return new ResultUtil<Page<Order>>().setData(page); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
@RequestMapping(value = "/delByIds", method = RequestMethod.POST) |
||||
|
@ApiOperation(value = "批量通过ids删除") |
||||
|
public Result delAllByIds(@RequestParam String[] ids) { |
||||
|
for (String id : ids) { |
||||
|
orderService.delete(id); |
||||
|
} |
||||
|
return ResultUtil.success("批量通过id删除数据成功"); |
||||
|
} |
||||
|
|
||||
|
@RequestMapping(value = "/admin/add", method = RequestMethod.POST) |
||||
|
@ApiOperation(value = "创建订单") |
||||
|
public Result add(@Valid Order u, |
||||
|
@RequestParam(required = false) String[] roleIds) { |
||||
|
|
||||
|
Order order = orderService.save(u); |
||||
|
|
||||
|
// 发送创建账号消息
|
||||
|
//addMessage.addSendMessage(user.getId());
|
||||
|
return ResultUtil.success("常见成功"); |
||||
|
} |
||||
|
|
||||
|
@RequestMapping(value = "/admin/edit", method = RequestMethod.POST) |
||||
|
@ApiOperation(value = "修改订单", notes = "需要通过下单编号获取订单信息") |
||||
|
@CacheEvict(key = "#u.username") |
||||
|
public Result edit(Order u, |
||||
|
@RequestParam(required = false) String[] roleIds) { |
||||
|
|
||||
|
orderService.update(u); |
||||
|
|
||||
|
return ResultUtil.success("修改成功"); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
Loading…
Reference in new issue