19 changed files with 1580 additions and 0 deletions
@ -0,0 +1,24 @@ |
|||||
|
package cc.hiver.core.common.constant; |
||||
|
|
||||
|
/** |
||||
|
* 用户常量 |
||||
|
* |
||||
|
* @author Yazhi Li |
||||
|
*/ |
||||
|
public interface WorkerConstant { |
||||
|
|
||||
|
/** |
||||
|
* 抢单工正常抢单状态 |
||||
|
*/ |
||||
|
Integer WORKER_STATUS_NORMAL = 1; |
||||
|
/** |
||||
|
* 抢单工不可接单状态(押金不足) |
||||
|
*/ |
||||
|
Integer USER_STATUS_LOCK = 2; |
||||
|
|
||||
|
/** |
||||
|
* 抢单工禁用状态(管理员直接禁用) |
||||
|
*/ |
||||
|
Integer USER_STATUS_DISABLE = 3; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
package cc.hiver.core.dao; |
||||
|
|
||||
|
import cc.hiver.core.base.HiverBaseDao; |
||||
|
import cc.hiver.core.entity.OrderXd; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 用户数据处理层 |
||||
|
* |
||||
|
* @author Houpn |
||||
|
*/ |
||||
|
public interface OrderDao extends HiverBaseDao<OrderXd, String> { |
||||
|
|
||||
|
OrderXd findByOrderId(String orderId); |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
package cc.hiver.core.dao; |
||||
|
|
||||
|
import cc.hiver.core.base.HiverBaseDao; |
||||
|
import cc.hiver.core.entity.Worker; |
||||
|
|
||||
|
public interface WorkerDao extends HiverBaseDao<Worker, String> { |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,170 @@ |
|||||
|
package cc.hiver.core.entity; |
||||
|
|
||||
|
import cc.hiver.core.common.utils.NameUtil; |
||||
|
import cc.hiver.core.common.utils.SnowFlakeUtil; |
||||
|
import com.baomidou.mybatisplus.annotation.FieldFill; |
||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
import lombok.experimental.Accessors; |
||||
|
import org.hibernate.annotations.DynamicInsert; |
||||
|
import org.hibernate.annotations.DynamicUpdate; |
||||
|
import org.hibernate.annotations.NotFound; |
||||
|
import org.hibernate.annotations.NotFoundAction; |
||||
|
import org.springframework.data.annotation.CreatedBy; |
||||
|
import org.springframework.data.annotation.CreatedDate; |
||||
|
import org.springframework.data.annotation.LastModifiedBy; |
||||
|
import org.springframework.data.annotation.LastModifiedDate; |
||||
|
import org.springframework.data.jpa.domain.support.AuditingEntityListener; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import javax.persistence.*; |
||||
|
import javax.validation.constraints.Pattern; |
||||
|
import java.io.Serializable; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
@Data |
||||
|
@Accessors(chain = true) |
||||
|
@Entity |
||||
|
@DynamicInsert |
||||
|
@DynamicUpdate |
||||
|
@Table(name = "t_order") |
||||
|
@TableName("t_order") |
||||
|
@ApiModel(value = "下单") |
||||
|
@EntityListeners(AuditingEntityListener.class) |
||||
|
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler", "fieldHandler"}) |
||||
|
public class OrderXd implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 订单号,默认前缀为XD |
||||
|
*/ |
||||
|
@Id |
||||
|
@ApiModelProperty("订单号,默认前缀为XD") |
||||
|
@Column(name = "order_id", nullable = false,unique = true) |
||||
|
private String orderId = "XD" + SnowFlakeUtil.nextId().toString(); |
||||
|
|
||||
|
/** |
||||
|
* 订单运送地址 |
||||
|
*/ |
||||
|
@ApiModelProperty("订单运送省市地址") |
||||
|
@Column(name = "order_address") |
||||
|
private String orderAddress; |
||||
|
|
||||
|
@ApiModelProperty(value = "街道地址") |
||||
|
@Column(name = "order_street") |
||||
|
private String orderStreet; |
||||
|
|
||||
|
/** |
||||
|
* 物流方式 |
||||
|
*/ |
||||
|
@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 String 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("被抢单时间") |
||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@Column(name = "order_by_workertime") |
||||
|
private Date orderByWorkertime; |
||||
|
|
||||
|
@ApiModelProperty(value = "手机") |
||||
|
@Pattern(regexp = NameUtil.regMobile, message = "11位手机号格式不正确") |
||||
|
private String mobile; |
||||
|
|
||||
|
@ApiModelProperty("订单创建人") |
||||
|
@CreatedBy |
||||
|
@TableField(fill = FieldFill.INSERT) |
||||
|
private String createBy; |
||||
|
|
||||
|
@CreatedDate |
||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@ApiModelProperty("订单创建时间") |
||||
|
private Date createTime; |
||||
|
|
||||
|
@ApiModelProperty("订单修改人") |
||||
|
@LastModifiedBy |
||||
|
@TableField(fill = FieldFill.UPDATE) |
||||
|
private String updateBy; |
||||
|
|
||||
|
@LastModifiedDate |
||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@ApiModelProperty(value = "订单修改时间") |
||||
|
@TableField(fill = FieldFill.UPDATE) |
||||
|
private Date updateTime; |
||||
|
|
||||
|
/** |
||||
|
* 订单区域 |
||||
|
*/ |
||||
|
@ApiModelProperty("订单所属区域") |
||||
|
@Column(name = "region") |
||||
|
private String region; |
||||
|
|
||||
|
/** |
||||
|
* 关联订单工 |
||||
|
*/ |
||||
|
@ManyToOne(targetEntity = Worker.class) |
||||
|
@JoinColumn(name="order_by_worker",insertable=false, updatable=false) |
||||
|
private Worker worker; |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,130 @@ |
|||||
|
package cc.hiver.core.entity; |
||||
|
|
||||
|
import cc.hiver.core.common.utils.SnowFlakeUtil; |
||||
|
import com.baomidou.mybatisplus.annotation.FieldFill; |
||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
import lombok.experimental.Accessors; |
||||
|
import org.hibernate.annotations.DynamicInsert; |
||||
|
import org.hibernate.annotations.DynamicUpdate; |
||||
|
import org.springframework.data.annotation.CreatedBy; |
||||
|
import org.springframework.data.annotation.CreatedDate; |
||||
|
import org.springframework.data.annotation.LastModifiedBy; |
||||
|
import org.springframework.data.annotation.LastModifiedDate; |
||||
|
import org.springframework.data.jpa.domain.support.AuditingEntityListener; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import javax.persistence.*; |
||||
|
import java.io.Serializable; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
@Data |
||||
|
@Entity |
||||
|
@Accessors(chain = true) |
||||
|
@DynamicInsert |
||||
|
@DynamicUpdate |
||||
|
@Table(name = "t_worker") |
||||
|
@TableName("t_worker") |
||||
|
@ApiModel(value = "抢单工管理") |
||||
|
@EntityListeners(AuditingEntityListener.class) |
||||
|
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler", "fieldHandler"}) |
||||
|
public class Worker implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 抢单工编号 |
||||
|
*/ |
||||
|
@Id |
||||
|
@ApiModelProperty("抢单工编号") |
||||
|
@Column(name = "worker_id", nullable = false) |
||||
|
private String workerId = "W"+SnowFlakeUtil.nextId().toString(); |
||||
|
|
||||
|
/** |
||||
|
* 抢单工名称 |
||||
|
*/ |
||||
|
@ApiModelProperty("抢单工名称") |
||||
|
@Column(name = "worker_name") |
||||
|
private String workerName; |
||||
|
|
||||
|
/** |
||||
|
* 抢单工简介 |
||||
|
*/ |
||||
|
@ApiModelProperty("抢单工简介") |
||||
|
@Column(name = "worker_describe") |
||||
|
private String workerDescribe; |
||||
|
|
||||
|
/** |
||||
|
* 缴押金总额 |
||||
|
*/ |
||||
|
@Column(name = "depo_num") |
||||
|
@ApiModelProperty("缴押金总额") |
||||
|
private Integer depoNum; |
||||
|
|
||||
|
/** |
||||
|
* 押金余额 |
||||
|
*/ |
||||
|
@ApiModelProperty("押金余额") |
||||
|
@Column(name = "depo_bal") |
||||
|
private Integer depoBal; |
||||
|
|
||||
|
/** |
||||
|
* 接单状态 1-可抢单 2-不可接单(押金不足状态) 3-已禁用(手工预置状态) |
||||
|
*/ |
||||
|
@Column(name = "worker_status") |
||||
|
@ApiModelProperty("接单状态 1-可抢单 2-不可接单(押金不足状态) 3-已禁用(手工预置状态)") |
||||
|
private Integer workerStatus = 1; |
||||
|
|
||||
|
|
||||
|
@ApiModelProperty("订单工创建人") |
||||
|
@CreatedBy |
||||
|
@TableField(fill = FieldFill.INSERT) |
||||
|
private String createBy; |
||||
|
|
||||
|
@CreatedDate |
||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@ApiModelProperty("订单工创建时间") |
||||
|
private Date createTime; |
||||
|
|
||||
|
@ApiModelProperty("订单工修改人") |
||||
|
@LastModifiedBy |
||||
|
@TableField(fill = FieldFill.UPDATE) |
||||
|
private String updateBy; |
||||
|
|
||||
|
@LastModifiedDate |
||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@ApiModelProperty(value = "订单工修改时间") |
||||
|
@TableField(fill = FieldFill.UPDATE) |
||||
|
private Date updateTime; |
||||
|
|
||||
|
/** |
||||
|
* 联系方式 |
||||
|
*/ |
||||
|
@Column(name = "mobile") |
||||
|
@ApiModelProperty("联系方式") |
||||
|
private String mobile; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 订单与抢单工映射关系 |
||||
|
* |
||||
|
* 多端中的列键值《外键》指向一端 一对多的单向关联,我们还是推荐使用一张中间表来建立关系。 |
||||
|
*/ |
||||
|
/*@OneToMany(targetEntity = Order.class,mappedBy = "orderByWorker",cascade = CascadeType.ALL,fetch = FetchType.EAGER) |
||||
|
private List<Order> order;*/ |
||||
|
|
||||
|
/** |
||||
|
* 区域 |
||||
|
*/ |
||||
|
@Column(name = "region") |
||||
|
@ApiModelProperty("办公区域") |
||||
|
private String region; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,37 @@ |
|||||
|
package cc.hiver.core.service; |
||||
|
|
||||
|
import cc.hiver.core.base.HiverBaseService; |
||||
|
import cc.hiver.core.common.vo.SearchVo; |
||||
|
import cc.hiver.core.entity.OrderXd; |
||||
|
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 = "orderxd") |
||||
|
public interface OrderService extends HiverBaseService<OrderXd, String> { |
||||
|
|
||||
|
/** |
||||
|
* 多条件分页获取用户 |
||||
|
* |
||||
|
* @param |
||||
|
* @param searchVo |
||||
|
* @param pageable |
||||
|
* @return |
||||
|
*/ |
||||
|
Page<OrderXd> findByCondition(OrderXd order, SearchVo searchVo, Pageable pageable); |
||||
|
|
||||
|
OrderXd findByOrderId(String orderId); |
||||
|
|
||||
|
List<OrderXd> findByCondition(OrderXd order); |
||||
|
|
||||
|
Page<OrderXd> findAllByCondition(OrderXd order, SearchVo searchVo, Pageable pageable); |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,28 @@ |
|||||
|
package cc.hiver.core.service; |
||||
|
|
||||
|
import cc.hiver.core.base.HiverBaseService; |
||||
|
import cc.hiver.core.common.vo.SearchVo; |
||||
|
import cc.hiver.core.entity.Worker; |
||||
|
import org.springframework.cache.annotation.CacheConfig; |
||||
|
import org.springframework.data.domain.Page; |
||||
|
import org.springframework.data.domain.Pageable; |
||||
|
|
||||
|
/** |
||||
|
* 用户接口 |
||||
|
* |
||||
|
* @author Houpn |
||||
|
*/ |
||||
|
@CacheConfig(cacheNames = "worker") |
||||
|
public interface WorkerService extends HiverBaseService<Worker, String> { |
||||
|
|
||||
|
/** |
||||
|
* 多条件分页获取抢单工 |
||||
|
* |
||||
|
* @param Worker |
||||
|
* @param searchVo |
||||
|
* @param pageable |
||||
|
* @return |
||||
|
*/ |
||||
|
Page<Worker> findByCondition(Worker worker, SearchVo searchVo, Pageable pageable); |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,212 @@ |
|||||
|
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.OrderXd; |
||||
|
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; |
||||
|
|
||||
|
/** |
||||
|
* 用户接口实现 |
||||
|
* |
||||
|
* @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<OrderXd> findByCondition(OrderXd order, SearchVo searchVo, Pageable pageable) { |
||||
|
return orderDao.findAll(new Specification<OrderXd>() { |
||||
|
@Nullable |
||||
|
@Override |
||||
|
public Predicate toPredicate(Root<OrderXd> root, CriteriaQuery<?> cq, CriteriaBuilder cb) { |
||||
|
Path<String> OrderIdField = root.get("orderId"); |
||||
|
Path<String> norderLogisticsField = root.get("orderLogistics"); |
||||
|
Path<String> kdOrderIdField = root.get("kdOrderId"); |
||||
|
Path<String> 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() + '%')); |
||||
|
} |
||||
|
|
||||
|
if (StrUtil.isNotBlank(order.getTimeout())) { |
||||
|
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); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public OrderXd findByOrderId(String orderId) { |
||||
|
return orderDao.findByOrderId(orderId); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Page<OrderXd> findAllByCondition(OrderXd order, SearchVo searchVo, Pageable pageable) { |
||||
|
return orderDao.findAll(new Specification<OrderXd>() { |
||||
|
@Nullable |
||||
|
@Override |
||||
|
public Predicate toPredicate(Root<OrderXd> root, CriteriaQuery<?> cq, CriteriaBuilder cb) { |
||||
|
Path<String> orderIdField = root.get("orderId"); |
||||
|
Path<String> norderLogisticsField = root.get("orderLogistics"); |
||||
|
Path<String> kdOrderIdField = root.get("kdOrderId"); |
||||
|
Path<String> timeoutField = root.get("timeout"); |
||||
|
Path<Integer> orderStatusdField = root.get("orderStatus"); |
||||
|
Path<String> orderByWorkerField = root.get("orderByWorker"); |
||||
|
//抢单时间
|
||||
|
Path<Date> createTimeField = root.get("orderByWorkertime"); |
||||
|
|
||||
|
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.equal(norderLogisticsField, order.getOrderLogistics())); |
||||
|
} |
||||
|
if (StrUtil.isNotBlank(order.getKdOrderId())) { |
||||
|
list.add(cb.like(kdOrderIdField, order.getKdOrderId())); |
||||
|
} |
||||
|
|
||||
|
if (StrUtil.isNotBlank(order.getTimeout())) { |
||||
|
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.equal(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); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
public List<OrderXd> findByCondition(OrderXd order) { |
||||
|
return orderDao.findAll(new Specification<OrderXd>() { |
||||
|
@Nullable |
||||
|
@Override |
||||
|
public Predicate toPredicate(Root<OrderXd> root, CriteriaQuery<?> cq, CriteriaBuilder cb) { |
||||
|
Path<String> orderIdField = root.get("orderId"); |
||||
|
Path<String> norderLogisticsField = root.get("orderLogistics"); |
||||
|
Path<String> kdOrderIdField = root.get("kdOrderId"); |
||||
|
Path<String> timeoutField = root.get("timeout"); |
||||
|
Path<Integer> orderStatusdField = root.get("orderStatus"); |
||||
|
Path<String> orderByWorkerField = root.get("orderByWorker"); |
||||
|
Path<Date> createTimeField = root.get("createTime"); |
||||
|
Path<String> regionField = root.get("region"); |
||||
|
|
||||
|
List<Predicate> list = new ArrayList<>(); |
||||
|
|
||||
|
//区域条件
|
||||
|
if (StrUtil.isNotBlank(order.getRegion())) { |
||||
|
list.add(cb.equal(regionField,order.getRegion())); |
||||
|
} |
||||
|
//物流方式限制
|
||||
|
if (StrUtil.isNotBlank(order.getOrderLogistics())) { |
||||
|
list.add(cb.equal(norderLogisticsField,order.getOrderLogistics())); |
||||
|
} |
||||
|
|
||||
|
//订单工编号应该为空
|
||||
|
list.add(cb.or(cb.isNull(orderByWorkerField),cb.equal(orderByWorkerField,order.getOrderByWorker()))); |
||||
|
|
||||
|
|
||||
|
if (StrUtil.isNotBlank(order.getTimeout())) { |
||||
|
list.add(cb.equal(timeoutField, order.getTimeout())); |
||||
|
} |
||||
|
|
||||
|
// 状态
|
||||
|
if (order.getOrderStatus() != null) { |
||||
|
list.add(cb.equal(orderStatusdField, order.getOrderStatus())); |
||||
|
} |
||||
|
|
||||
|
// 数据权限
|
||||
|
Predicate[] arr = new Predicate[list.size()]; |
||||
|
cq.where(list.toArray(arr)); |
||||
|
return null; |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,91 @@ |
|||||
|
package cc.hiver.core.serviceimpl; |
||||
|
|
||||
|
import cc.hiver.core.common.utils.SecurityUtil; |
||||
|
import cc.hiver.core.common.vo.SearchVo; |
||||
|
import cc.hiver.core.dao.WorkerDao; |
||||
|
import cc.hiver.core.entity.Worker; |
||||
|
import cc.hiver.core.service.WorkerService; |
||||
|
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; |
||||
|
|
||||
|
/** |
||||
|
* 用户接口实现 |
||||
|
* |
||||
|
* @author houpn |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Service |
||||
|
@Transactional |
||||
|
public class WorkerServiceImpl implements WorkerService { |
||||
|
@Autowired |
||||
|
private WorkerDao workerDao; |
||||
|
|
||||
|
@Autowired |
||||
|
private SecurityUtil securityUtil; |
||||
|
|
||||
|
@Override |
||||
|
public WorkerDao getRepository() { |
||||
|
return workerDao; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Page<Worker> findByCondition(Worker worker, SearchVo searchVo, Pageable pageable) { |
||||
|
return workerDao.findAll(new Specification<Worker>() { |
||||
|
@Nullable |
||||
|
@Override |
||||
|
public Predicate toPredicate(Root<Worker> root, CriteriaQuery<?> cq, CriteriaBuilder cb) { |
||||
|
Path<String> workerIdField = root.get("workerId"); |
||||
|
Path<String> workerNameField = root.get("workerName"); |
||||
|
Path<Integer> workerStatusField = root.get("workerStatus"); |
||||
|
Path<String> mobileField = root.get("mobile"); |
||||
|
Path<Date> createTimeField = root.get("createTime"); |
||||
|
|
||||
|
List<Predicate> list = new ArrayList<>(); |
||||
|
|
||||
|
if (StrUtil.isNotBlank(worker.getWorkerId())) { |
||||
|
list.add(cb.equal(workerIdField, worker.getWorkerId())); |
||||
|
} |
||||
|
|
||||
|
// 模糊搜素
|
||||
|
if (StrUtil.isNotBlank(worker.getWorkerName())) { |
||||
|
list.add(cb.like(workerNameField, '%' + worker.getWorkerName() + '%')); |
||||
|
} |
||||
|
|
||||
|
// 状态
|
||||
|
if (worker.getWorkerStatus() != null) { |
||||
|
list.add(cb.equal(workerStatusField, worker.getWorkerStatus())); |
||||
|
} |
||||
|
|
||||
|
// 模糊搜素
|
||||
|
if (StrUtil.isNotBlank(worker.getMobile())) { |
||||
|
list.add(cb.like(mobileField, '%' + worker.getMobile() + '%')); |
||||
|
} |
||||
|
// 创建时间
|
||||
|
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,92 @@ |
|||||
|
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.util.Date; |
||||
|
|
||||
|
|
||||
|
@Data |
||||
|
@ApiModel("保存 ") |
||||
|
public class WorkerVO { |
||||
|
|
||||
|
/** |
||||
|
* 抢单工编号 |
||||
|
*/ |
||||
|
@NotNull(message = "workerId can not null") |
||||
|
@ApiModelProperty("抢单工编号") |
||||
|
private String workerId; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 抢单工名称 |
||||
|
*/ |
||||
|
@ApiModelProperty("抢单工名称") |
||||
|
private String workerName; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 抢单工简介 |
||||
|
*/ |
||||
|
@ApiModelProperty("抢单工简介") |
||||
|
private String workerDescribe; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 缴押金总额 |
||||
|
*/ |
||||
|
@ApiModelProperty("缴押金总额") |
||||
|
private Integer depoNum; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 押金余额 |
||||
|
*/ |
||||
|
@ApiModelProperty("押金余额") |
||||
|
private Integer depoBal; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 接单状态 1-可抢单 2-不可接单(押金不足状态) 3-已禁用(手工预置状态) |
||||
|
*/ |
||||
|
@ApiModelProperty("接单状态 1-可抢单 2-不可接单(押金不足状态) 3-已禁用(手工预置状态)") |
||||
|
private Integer workerStatus; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 订单工创建人 |
||||
|
*/ |
||||
|
@ApiModelProperty("订单工创建人") |
||||
|
private String createBy; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 订单工创建时间 |
||||
|
*/ |
||||
|
@ApiModelProperty("订单工创建时间") |
||||
|
private Date createTime; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 订单工修改人 |
||||
|
*/ |
||||
|
@ApiModelProperty("订单工修改人") |
||||
|
private String updateBy; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 订单工修改时间 |
||||
|
*/ |
||||
|
@ApiModelProperty("订单工修改时间") |
||||
|
private Date updateTime; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 联系方式 |
||||
|
*/ |
||||
|
@ApiModelProperty("联系方式") |
||||
|
private String mobile; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,90 @@ |
|||||
|
/* |
||||
|
Copyright [2022] [https://hiver.cc]
|
||||
|
|
||||
|
Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
you may not use this file except in compliance with the License. |
||||
|
You may obtain a copy of the License at |
||||
|
|
||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
|
||||
|
Unless required by applicable law or agreed to in writing, software |
||||
|
distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
See the License for the specific language governing permissions and |
||||
|
limitations under the License. |
||||
|
*/ |
||||
|
package cc.hiver.app.controller.admin; |
||||
|
|
||||
|
import cc.hiver.app.entity.Company; |
||||
|
import cc.hiver.app.entity.LogiticsCompany; |
||||
|
import cc.hiver.app.service.CompanyService; |
||||
|
import cc.hiver.app.service.LogiticsCompanyService; |
||||
|
import cc.hiver.core.common.utils.PageUtil; |
||||
|
import cc.hiver.core.common.utils.ResultUtil; |
||||
|
import cc.hiver.core.common.vo.PageVo; |
||||
|
import cc.hiver.core.common.vo.Result; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.data.domain.Page; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author houpn |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@RestController |
||||
|
@Api(tags = "物流管理公司接口") |
||||
|
@RequestMapping(value = "/hiver/app/logitics") |
||||
|
public class LogiticsCompanyController { |
||||
|
@Autowired |
||||
|
private LogiticsCompanyService companyService; |
||||
|
|
||||
|
@RequestMapping(value = "/getAll", method = RequestMethod.GET) |
||||
|
@ApiOperation(value = "获取全部数据") |
||||
|
public Result<List<LogiticsCompany>> getAll() { |
||||
|
List<LogiticsCompany> list = companyService.getAll(); |
||||
|
return new ResultUtil<List<LogiticsCompany>>().setData(list); |
||||
|
} |
||||
|
|
||||
|
@RequestMapping(value = "/add", method = RequestMethod.POST) |
||||
|
@ResponseBody |
||||
|
@ApiOperation(value = "添加") |
||||
|
public Result<Object> add(LogiticsCompany company) { |
||||
|
if (companyService.findByCompanyName(company.getCompanyName()) != null) { |
||||
|
return ResultUtil.error("公司名称已经存在"); |
||||
|
} |
||||
|
companyService.save(company); |
||||
|
return ResultUtil.success("添加成功"); |
||||
|
} |
||||
|
|
||||
|
@RequestMapping(value = "/edit", method = RequestMethod.PUT) |
||||
|
@ResponseBody |
||||
|
@ApiOperation(value = "编辑") |
||||
|
public Result<Object> edit(LogiticsCompany company) { |
||||
|
companyService.update(company); |
||||
|
return ResultUtil.success("编辑成功"); |
||||
|
} |
||||
|
|
||||
|
@RequestMapping(value = "/delByIds", method = RequestMethod.POST) |
||||
|
@ResponseBody |
||||
|
@ApiOperation(value = "通过id删除") |
||||
|
public Result<Object> delAllByIds(@RequestParam String[] ids) { |
||||
|
for (String id : ids) { |
||||
|
LogiticsCompany company = companyService.get(id); |
||||
|
companyService.delete(id); |
||||
|
} |
||||
|
return ResultUtil.success("删除成功"); |
||||
|
} |
||||
|
|
||||
|
@RequestMapping(value = "/getByCondition", method = RequestMethod.GET) |
||||
|
@ApiOperation(value = "多条件分页获取公司列表") |
||||
|
public Result<Page<LogiticsCompany>> getByCondition(LogiticsCompany company, |
||||
|
PageVo pageVo) { |
||||
|
Page<LogiticsCompany> page = companyService.findByCondition(company, PageUtil.initPage(pageVo)); |
||||
|
return new ResultUtil<Page<LogiticsCompany>>().setData(page); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,33 @@ |
|||||
|
/* |
||||
|
Copyright [2022] [https://hiver.cc]
|
||||
|
|
||||
|
Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
you may not use this file except in compliance with the License. |
||||
|
You may obtain a copy of the License at |
||||
|
|
||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
|
||||
|
Unless required by applicable law or agreed to in writing, software |
||||
|
distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
See the License for the specific language governing permissions and |
||||
|
limitations under the License. |
||||
|
*/ |
||||
|
package cc.hiver.app.dao; |
||||
|
|
||||
|
import cc.hiver.app.entity.Company; |
||||
|
import cc.hiver.app.entity.LogiticsCompany; |
||||
|
import cc.hiver.core.base.HiverBaseDao; |
||||
|
|
||||
|
/** |
||||
|
* @author houpn |
||||
|
*/ |
||||
|
public interface LogiticsCompanyDao extends HiverBaseDao<LogiticsCompany, String> { |
||||
|
/** |
||||
|
* 通过公司名称获得记录 |
||||
|
* |
||||
|
* @param companyName |
||||
|
* @return |
||||
|
*/ |
||||
|
LogiticsCompany findByCompanyName(String companyName); |
||||
|
} |
||||
@ -0,0 +1,67 @@ |
|||||
|
/* |
||||
|
Copyright [2022] [https://hiver.cc]
|
||||
|
|
||||
|
Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
you may not use this file except in compliance with the License. |
||||
|
You may obtain a copy of the License at |
||||
|
|
||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
|
||||
|
Unless required by applicable law or agreed to in writing, software |
||||
|
distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
See the License for the specific language governing permissions and |
||||
|
limitations under the License. |
||||
|
*/ |
||||
|
package cc.hiver.app.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 org.hibernate.annotations.DynamicInsert; |
||||
|
import org.hibernate.annotations.DynamicUpdate; |
||||
|
|
||||
|
import javax.persistence.Entity; |
||||
|
import javax.persistence.Table; |
||||
|
|
||||
|
/** |
||||
|
* 公司实体类 |
||||
|
* |
||||
|
* @author Yazhi Li |
||||
|
*/ |
||||
|
@Data |
||||
|
@Entity |
||||
|
@DynamicInsert |
||||
|
@DynamicUpdate |
||||
|
@Table(name = "t_lcompany") |
||||
|
@TableName("t_lcompany") |
||||
|
@ApiModel(value = "公司信息") |
||||
|
public class LogiticsCompany extends HiverBaseEntity { |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
@ApiModelProperty(value = "公司名称") |
||||
|
private String companyName; |
||||
|
|
||||
|
@ApiModelProperty(value = "公司电话") |
||||
|
private String companyTel; |
||||
|
|
||||
|
@ApiModelProperty(value = "公司邮箱") |
||||
|
private String companyEmail; |
||||
|
|
||||
|
@ApiModelProperty(value = "所在地区") |
||||
|
private String companyAddress; |
||||
|
|
||||
|
@ApiModelProperty(value = "详细地址") |
||||
|
private String companyStreet; |
||||
|
|
||||
|
@ApiModelProperty(value = "联系人") |
||||
|
private String contacts; |
||||
|
|
||||
|
@ApiModelProperty(value = "联系人手机号") |
||||
|
private String mobile; |
||||
|
|
||||
|
@ApiModelProperty(value = "办公区域") |
||||
|
private String region; |
||||
|
} |
||||
@ -0,0 +1,44 @@ |
|||||
|
/* |
||||
|
Copyright [2022] [https://hiver.cc]
|
||||
|
|
||||
|
Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
you may not use this file except in compliance with the License. |
||||
|
You may obtain a copy of the License at |
||||
|
|
||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
|
||||
|
Unless required by applicable law or agreed to in writing, software |
||||
|
distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
See the License for the specific language governing permissions and |
||||
|
limitations under the License. |
||||
|
*/ |
||||
|
package cc.hiver.app.service; |
||||
|
|
||||
|
import cc.hiver.app.entity.Company; |
||||
|
import cc.hiver.app.entity.LogiticsCompany; |
||||
|
import cc.hiver.core.base.HiverBaseService; |
||||
|
import org.springframework.data.domain.Page; |
||||
|
import org.springframework.data.domain.Pageable; |
||||
|
|
||||
|
/** |
||||
|
* @author Yazhi Li |
||||
|
*/ |
||||
|
public interface LogiticsCompanyService extends HiverBaseService<LogiticsCompany, String> { |
||||
|
/** |
||||
|
* 多条件获取 |
||||
|
* |
||||
|
* @param company |
||||
|
* @param pageable |
||||
|
* @return |
||||
|
*/ |
||||
|
Page<LogiticsCompany> findByCondition(LogiticsCompany company, Pageable pageable); |
||||
|
|
||||
|
/** |
||||
|
* 通过公司名称获得记录 |
||||
|
* |
||||
|
* @param companyName |
||||
|
* @return |
||||
|
*/ |
||||
|
LogiticsCompany findByCompanyName(String companyName); |
||||
|
} |
||||
@ -0,0 +1,89 @@ |
|||||
|
/* |
||||
|
Copyright [2022] [https://hiver.cc]
|
||||
|
|
||||
|
Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
you may not use this file except in compliance with the License. |
||||
|
You may obtain a copy of the License at |
||||
|
|
||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
|
||||
|
Unless required by applicable law or agreed to in writing, software |
||||
|
distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
See the License for the specific language governing permissions and |
||||
|
limitations under the License. |
||||
|
*/ |
||||
|
package cc.hiver.app.serviceimpl; |
||||
|
|
||||
|
import cc.hiver.app.dao.CompanyDao; |
||||
|
import cc.hiver.app.dao.LogiticsCompanyDao; |
||||
|
import cc.hiver.app.entity.Company; |
||||
|
import cc.hiver.app.entity.LogiticsCompany; |
||||
|
import cc.hiver.app.service.CompanyService; |
||||
|
import cc.hiver.app.service.LogiticsCompanyService; |
||||
|
import cc.hiver.core.base.HiverBaseDao; |
||||
|
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.List; |
||||
|
|
||||
|
/** |
||||
|
* @author houpn |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Service |
||||
|
@Transactional |
||||
|
public class LogiticsCompanyServiceImpl implements LogiticsCompanyService { |
||||
|
@Autowired |
||||
|
private LogiticsCompanyDao companyDao; |
||||
|
|
||||
|
@Override |
||||
|
public HiverBaseDao<LogiticsCompany, String> getRepository() { |
||||
|
return companyDao; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Page<LogiticsCompany> findByCondition(LogiticsCompany company, Pageable pageable) { |
||||
|
return companyDao.findAll(new Specification<LogiticsCompany>() { |
||||
|
@Nullable |
||||
|
@Override |
||||
|
public Predicate toPredicate(Root<LogiticsCompany> root, CriteriaQuery<?> cq, CriteriaBuilder cb) { |
||||
|
Path<String> companyNameField = root.get("companyName"); |
||||
|
Path<String> contactsField = root.get("contacts"); |
||||
|
Path<String> mobileField = root.get("mobile"); |
||||
|
|
||||
|
List<Predicate> list = new ArrayList<>(); |
||||
|
|
||||
|
if (StrUtil.isNotBlank(company.getCompanyName())) { |
||||
|
list.add(cb.like(companyNameField, '%' + company.getCompanyName() + '%')); |
||||
|
} |
||||
|
|
||||
|
if (StrUtil.isNotBlank(company.getContacts())) { |
||||
|
list.add(cb.like(contactsField, '%' + company.getContacts() + '%')); |
||||
|
} |
||||
|
|
||||
|
if (StrUtil.isNotBlank(company.getMobile())) { |
||||
|
list.add(cb.like(mobileField, '%' + company.getMobile() + '%')); |
||||
|
} |
||||
|
|
||||
|
Predicate[] arr = new Predicate[list.size()]; |
||||
|
cq.where(list.toArray(arr)); |
||||
|
return null; |
||||
|
} |
||||
|
}, pageable); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public LogiticsCompany findByCompanyName(String companyName) { |
||||
|
return companyDao.findByCompanyName(companyName); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,187 @@ |
|||||
|
package cc.hiver.base.controller.manage; |
||||
|
|
||||
|
import cc.hiver.core.common.annotation.ClearAndReloadCache; |
||||
|
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 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.Cacheable; |
||||
|
import org.springframework.data.domain.Page; |
||||
|
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.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 用户管理接口 |
||||
|
* |
||||
|
* @author Yazhi Li |
||||
|
*/ |
||||
|
|
||||
|
@Slf4j |
||||
|
@RestController |
||||
|
@Api(tags = "订单接口") |
||||
|
@RequestMapping("/hiver/order") |
||||
|
@CacheConfig(cacheNames = "orderxd") |
||||
|
@Transactional |
||||
|
public class OrderController { |
||||
|
public static final String ORDER = "ORDER::"; |
||||
|
|
||||
|
@Autowired |
||||
|
private OrderService orderService; |
||||
|
|
||||
|
@Autowired |
||||
|
private WorkerService workerService; |
||||
|
|
||||
|
@Autowired |
||||
|
private DeleteMapper deleteMapper; |
||||
|
|
||||
|
@Autowired |
||||
|
private RedisTemplateHelper redisTemplate; |
||||
|
|
||||
|
@Autowired |
||||
|
private SecurityUtil securityUtil; |
||||
|
|
||||
|
@PersistenceContext |
||||
|
private EntityManager entityManager; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 该接口即可展示实时物流管理页面,可复用 |
||||
|
*/ |
||||
|
@RequestMapping(value = "/getByCondition", method = RequestMethod.GET) |
||||
|
@ApiOperation(value = "多条件分页获取订单列表") |
||||
|
//@Cacheable(cacheNames = ORDER)
|
||||
|
public Result<Page<OrderXd>> getByCondition(OrderXd order, |
||||
|
SearchVo searchVo, |
||||
|
PageVo pageVo) { |
||||
|
Page<OrderXd> page = orderService.findByCondition(order, searchVo, PageUtil.initPage(pageVo)); |
||||
|
return new ResultUtil<Page<OrderXd>>().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 OrderXd u, |
||||
|
@RequestParam(required = false) String[] roleIds) { |
||||
|
|
||||
|
orderService.save(u); |
||||
|
|
||||
|
// 发送创建账号消息
|
||||
|
//addMessage.addSendMessage(user.getId());
|
||||
|
return ResultUtil.success("创建成功"); |
||||
|
} |
||||
|
|
||||
|
@RequestMapping(value = "/admin/edit", method = RequestMethod.POST) |
||||
|
@ApiOperation(value = "修改订单", notes = "需要通过下单编号获取订单信息") |
||||
|
public Result edit(OrderXd u, |
||||
|
@RequestParam(required = false) String[] roleIds) { |
||||
|
|
||||
|
orderService.update(u); |
||||
|
|
||||
|
return ResultUtil.success("修改成功"); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 需要进行如下判定: |
||||
|
* 1.当前抢单工的抢单状态需进行查验,非正常无法进行抢单 |
||||
|
* 2.正常状态下,判定当前抢单工押金余额是否充足,不足时需要将当前扛包工状态自动修正为不可接单状态,同时当前订单无法抢购。 |
||||
|
* 3.正常抢单情况下,需要在redis中设置抢单后的剩余押金金额,要存在抢单锁机制,实时更新余额 |
||||
|
* |
||||
|
* 一:计划暂定使用延时双删策略,尽量保证最终一致性,但不是强一致性: |
||||
|
* 先进行缓存清除,再执行update,最后(延迟N秒)再执行缓存清除。 |
||||
|
* (延迟N秒)的时间要大于一次写操作的时间,一般为3-5秒。 |
||||
|
* 原因:如果延迟时间小于写入redis的时间,会导致请求1清除了缓存,但是请求2缓存还未写入的尴尬。。。 |
||||
|
* ps:一般写入的时间会远小于5秒 |
||||
|
* 二:抢单过程需要进行分布式锁ID进行锁定,用于抢单,上述一是为了保证数据的最终一致性。 |
||||
|
* |
||||
|
*/ |
||||
|
@RequestMapping(value = "/rush/order/{orderId}", method = RequestMethod.POST) |
||||
|
@ApiOperation(value = "抢单接口", notes = "需要通过下单编号获取订单信息后进行绑定") |
||||
|
@ClearAndReloadCache(name = ORDER) |
||||
|
public Result rush(OrderXd u) { |
||||
|
|
||||
|
orderService.update(u); |
||||
|
|
||||
|
return ResultUtil.success("抢单成功"); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 需要进行如下判定:(订单/抢单工/抢单时间/是否超时) |
||||
|
* 1.定时任务轮训修正订单是否超时(当前抢单时间和当前时间做比较) |
||||
|
* 2.当前解绑操作暂定为 超时后手工解绑,创建订单人享有解绑权限,解绑后订单可重新进行抢单(但是否需要标注将原接单人不可见) |
||||
|
* |
||||
|
*/ |
||||
|
@RequestMapping(value = "/unbind/order/{orderId}", method = RequestMethod.POST) |
||||
|
@ApiOperation(value = "解绑订单接口", notes = "需要通过下单编号获取订单信息后进行解绑") |
||||
|
@ClearAndReloadCache(name = ORDER) |
||||
|
public Result revoke(OrderXd u, |
||||
|
@ApiParam("订单唯一id标识") @PathVariable String orderId) { |
||||
|
|
||||
|
OrderXd o = orderService.findById(orderId); |
||||
|
|
||||
|
o.setOrderByWorker(""); |
||||
|
o.setOrderByWorkertime(null); |
||||
|
o.setWorker(null); |
||||
|
|
||||
|
orderService.update(o); |
||||
|
|
||||
|
return ResultUtil.success("解绑成功"); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 该接口即可展示实时物流管理页面,可复用 |
||||
|
*/ |
||||
|
@RequestMapping(value = "/ow/getAllByCondition", method = RequestMethod.GET) |
||||
|
@ApiOperation(value = "多条件分页获取订单列表") |
||||
|
public Result<Page<OrderXd>> getAllByCondition(OrderXd order, |
||||
|
SearchVo searchVo, |
||||
|
PageVo pageVo) { |
||||
|
Page<OrderXd> page = orderService.findAllByCondition(order, searchVo, PageUtil.initPage(pageVo)); |
||||
|
return new ResultUtil<Page<OrderXd>>().setData(page); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 待抢单的订单类型 |
||||
|
* |
||||
|
* 该方法用于返回app端要抢单的展示列表信息 |
||||
|
* 1.需要根据订单工所在区域进行查询显示是否为所在区域订单信息 |
||||
|
* 2.显示的订单信息为未被抢单的订单信息 |
||||
|
* |
||||
|
* key值定义暂定以区域为类型进行查询 |
||||
|
* |
||||
|
* */ |
||||
|
@RequestMapping(value = "/app/getAll", method = RequestMethod.POST) |
||||
|
@ApiOperation(value = "获取全部订单列表") |
||||
|
@Cacheable(value="AllOrder",key="'Pending'") |
||||
|
public Result<List<OrderXd>> getAll(@RequestBody OrderXd orderxd) { |
||||
|
List<OrderXd> list = orderService.findByCondition(orderxd); |
||||
|
return new ResultUtil<List<OrderXd>>().setData(list); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,126 @@ |
|||||
|
package cc.hiver.base.controller.manage; |
||||
|
|
||||
|
import cc.hiver.core.common.constant.UserConstant; |
||||
|
import cc.hiver.core.common.constant.WorkerConstant; |
||||
|
import cc.hiver.core.common.redis.RedisTemplateHelper; |
||||
|
import cc.hiver.core.common.utils.PageUtil; |
||||
|
import cc.hiver.core.common.utils.ResultUtil; |
||||
|
import cc.hiver.core.common.utils.SecurityUtil; |
||||
|
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.Worker; |
||||
|
import cc.hiver.core.service.WorkerService; |
||||
|
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.data.domain.Page; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import javax.persistence.EntityManager; |
||||
|
import javax.persistence.PersistenceContext; |
||||
|
import javax.validation.Valid; |
||||
|
|
||||
|
/** |
||||
|
* 订单工管理接口 |
||||
|
* |
||||
|
* @author houpn |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@RestController |
||||
|
@Api(tags = "订单工接口") |
||||
|
@RequestMapping("/hiver/worker") |
||||
|
@CacheConfig(cacheNames = "worker") |
||||
|
@Transactional |
||||
|
public class WorkerController { |
||||
|
public static final String WORKER = "worker::"; |
||||
|
|
||||
|
@Autowired |
||||
|
private WorkerService workerService; |
||||
|
|
||||
|
@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<Worker>> getByCondition(Worker worker, |
||||
|
SearchVo searchVo, |
||||
|
PageVo pageVo) { |
||||
|
Page<Worker> page = workerService.findByCondition(worker, searchVo, PageUtil.initPage(pageVo)); |
||||
|
return new ResultUtil<Page<Worker>>().setData(page); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
@RequestMapping(value = "/delByIds", method = RequestMethod.POST) |
||||
|
@ApiOperation(value = "批量通过ids删除") |
||||
|
public Result delAllByIds(@RequestParam String[] ids) { |
||||
|
for (String id : ids) { |
||||
|
workerService.delete(id); |
||||
|
} |
||||
|
return ResultUtil.success("批量通过id删除数据成功"); |
||||
|
} |
||||
|
|
||||
|
@RequestMapping(value = "/admin/add", method = RequestMethod.POST) |
||||
|
@ApiOperation(value = "创建抢单工") |
||||
|
public Result add(@Valid Worker u, |
||||
|
@RequestParam(required = false) String[] roleIds) { |
||||
|
|
||||
|
Worker worker = workerService.save(u); |
||||
|
|
||||
|
// 发送创建账号消息
|
||||
|
//addMessage.addSendMessage(user.getId());
|
||||
|
return ResultUtil.success("创建成功"); |
||||
|
} |
||||
|
|
||||
|
@RequestMapping(value = "/admin/edit", method = RequestMethod.POST) |
||||
|
@ApiOperation(value = "修改抢单工信息", notes = "需要通过下单编号获取订单信息") |
||||
|
public Result edit(Worker u, |
||||
|
@RequestParam(required = false) String[] roleIds) { |
||||
|
|
||||
|
workerService.update(u); |
||||
|
|
||||
|
return ResultUtil.success("修改成功"); |
||||
|
} |
||||
|
|
||||
|
@RequestMapping(value = "/admin/disable/{workerId}", method = RequestMethod.POST) |
||||
|
@ApiOperation(value = "后台人工禁用抢单工") |
||||
|
public Result disable(@ApiParam("用户唯一id标识") @PathVariable String workerId) { |
||||
|
Worker worker = workerService.get(workerId); |
||||
|
worker.setWorkerStatus(WorkerConstant.USER_STATUS_DISABLE); |
||||
|
workerService.update(worker); |
||||
|
// 手动更新缓存
|
||||
|
//redisTemplate.delete(WORKER + worker.getWorkerId());
|
||||
|
return ResultUtil.success("操作成功"); |
||||
|
} |
||||
|
|
||||
|
@RequestMapping(value = "/admin/enable/{workerId}", method = RequestMethod.POST) |
||||
|
@ApiOperation(value = "后台人工启用抢单工") |
||||
|
public Result enable(@ApiParam("抢单工唯一id标识") @PathVariable String workerId) { |
||||
|
Worker worker = workerService.get(workerId); |
||||
|
//这儿暂时有bug,启用的时候其实需要判定原状态是启用还是不可接单状态,需要进行逻辑判断
|
||||
|
worker.setWorkerStatus(WorkerConstant.WORKER_STATUS_NORMAL); |
||||
|
workerService.update(worker); |
||||
|
// 手动更新缓存
|
||||
|
//redisTemplate.delete(WORKER + worker.getWorkerId());
|
||||
|
return ResultUtil.success("操作成功"); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,41 @@ |
|||||
|
package cc.hiver.base.handler; |
||||
|
|
||||
|
import cc.hiver.core.entity.OrderXd; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.data.redis.core.RedisTemplate; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* @author benjamin_5 |
||||
|
* @Description |
||||
|
* @date 2022/9/25 |
||||
|
*/ |
||||
|
//@CanalTable("t_order")
|
||||
|
//@Component
|
||||
|
//@AllArgsConstructor
|
||||
|
//@Slf4j
|
||||
|
/* |
||||
|
public class OrderXdHandler implements EntryHandler<OrderXd> { |
||||
|
|
||||
|
|
||||
|
//private final RedisTemplate<Object,Object> redisTemplate;
|
||||
|
|
||||
|
@Override |
||||
|
public void insert(OrderXd orderXd) { |
||||
|
log.info("[新增]"+orderXd.toString()); |
||||
|
redisTemplate.opsForValue().set("ORDER:"+orderXd.getOrderId(),orderXd); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void update(OrderXd before, OrderXd after) { |
||||
|
log.info("[更新]"+after.toString()); |
||||
|
redisTemplate.opsForValue().set("ORDER:"+after.getOrderId(),after); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void delete(OrderXd orderXd) { |
||||
|
log.info("[删除]"+orderXd); |
||||
|
redisTemplate.delete("ORDER:"+orderXd.getOrderId()); |
||||
|
} |
||||
|
}*/ |
||||
Loading…
Reference in new issue