20 changed files with 1100 additions and 18 deletions
@ -0,0 +1,24 @@ |
|||||
|
package cc.hiver.core.common.constant; |
||||
|
|
||||
|
/** |
||||
|
* 用户常量 |
||||
|
* |
||||
|
* @author Yazhi Li |
||||
|
*/ |
||||
|
public interface CourierConstant { |
||||
|
|
||||
|
/** |
||||
|
* 抢单工正常抢单状态 |
||||
|
*/ |
||||
|
Integer COURIER_STATUS_NORMAL = 1; |
||||
|
/** |
||||
|
* 抢单工不可接单状态(押金不足) |
||||
|
*/ |
||||
|
Integer COURIER_STATUS_LOCK = 2; |
||||
|
|
||||
|
/** |
||||
|
* 抢单工禁用状态(管理员直接禁用) |
||||
|
*/ |
||||
|
Integer COURIER_STATUS_DISABLE = 3; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
package cc.hiver.core.dao; |
||||
|
|
||||
|
import cc.hiver.core.base.HiverBaseDao; |
||||
|
import cc.hiver.core.entity.Courier; |
||||
|
import cc.hiver.core.entity.Worker; |
||||
|
|
||||
|
public interface CourierDao extends HiverBaseDao<Courier, String> { |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
package cc.hiver.core.dao; |
||||
|
|
||||
|
import cc.hiver.core.base.HiverBaseDao; |
||||
|
import cc.hiver.core.entity.Courier; |
||||
|
import cc.hiver.core.entity.Recharge; |
||||
|
|
||||
|
public interface RechargeDao extends HiverBaseDao<Recharge, String> { |
||||
|
|
||||
|
} |
||||
@ -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_courier") |
||||
|
@TableName("t_courier") |
||||
|
@ApiModel(value = "快递员管理") |
||||
|
@EntityListeners(AuditingEntityListener.class) |
||||
|
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler", "fieldHandler"}) |
||||
|
public class Courier implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 抢单工编号 |
||||
|
*/ |
||||
|
@Id |
||||
|
@ApiModelProperty("快递员编号") |
||||
|
@Column(name = "courier_id", nullable = false) |
||||
|
private String courierId = "K"+SnowFlakeUtil.nextId().toString(); |
||||
|
|
||||
|
/** |
||||
|
* 抢单工名称 |
||||
|
*/ |
||||
|
@ApiModelProperty("快递员名称") |
||||
|
@Column(name = "courier_name") |
||||
|
private String courierName; |
||||
|
|
||||
|
/** |
||||
|
* 抢单工简介 |
||||
|
*/ |
||||
|
@ApiModelProperty("快递员简介") |
||||
|
@Column(name = "courier_describe") |
||||
|
private String courierDescribe; |
||||
|
|
||||
|
/** |
||||
|
* 缴押金总额 |
||||
|
*/ |
||||
|
@Column(name = "depo_num") |
||||
|
@ApiModelProperty("当次缴纳") |
||||
|
private Integer depoNum = 0; |
||||
|
|
||||
|
/** |
||||
|
* 押金余额 |
||||
|
*/ |
||||
|
@ApiModelProperty("押金余额") |
||||
|
@Column(name = "depo_bal") |
||||
|
private Integer depoBal = 0; |
||||
|
|
||||
|
/** |
||||
|
* 接单状态 1-可抢单 2-不可接单(押金不足状态) 3-已禁用(手工预置状态) |
||||
|
*/ |
||||
|
@Column(name = "courier_status") |
||||
|
@ApiModelProperty("接单状态 1-可抢单 2-不可接单(押金不足状态) 3-已禁用(手工预置状态)") |
||||
|
private Integer courierStatus = 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,109 @@ |
|||||
|
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_recharge_log") |
||||
|
@TableName("t_recharge_log") |
||||
|
@ApiModel(value = "押金充值记录管理") |
||||
|
@EntityListeners(AuditingEntityListener.class) |
||||
|
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler", "fieldHandler"}) |
||||
|
public class Recharge implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 充值记录编号 |
||||
|
*/ |
||||
|
@Id |
||||
|
@ApiModelProperty("充值编号") |
||||
|
@Column(name = "recharge_id", nullable = false) |
||||
|
private String rechargeId = "RZ"+SnowFlakeUtil.nextId().toString(); |
||||
|
|
||||
|
/** |
||||
|
* 被充值人名称 |
||||
|
*/ |
||||
|
@ApiModelProperty("充值名称") |
||||
|
@Column(name = "recharge_name") |
||||
|
private String rechargeName; |
||||
|
|
||||
|
/** |
||||
|
* 被充值人编号 |
||||
|
*/ |
||||
|
@ApiModelProperty("被充值人编号") |
||||
|
@Column(name = "recharge_worker_id") |
||||
|
private String rechargeWorkerId; |
||||
|
|
||||
|
/** |
||||
|
* 充值简介 |
||||
|
*/ |
||||
|
@ApiModelProperty("充值简介") |
||||
|
@Column(name = "recharge_describe") |
||||
|
private String rechargeDescribe; |
||||
|
|
||||
|
/** |
||||
|
* 缴押金总额 |
||||
|
*/ |
||||
|
@Column(name = "recharge_num") |
||||
|
@ApiModelProperty("当次缴纳") |
||||
|
private Integer rechargeNum = 0; |
||||
|
|
||||
|
|
||||
|
|
||||
|
@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; |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,29 @@ |
|||||
|
package cc.hiver.core.service; |
||||
|
|
||||
|
import cc.hiver.core.base.HiverBaseService; |
||||
|
import cc.hiver.core.common.vo.SearchVo; |
||||
|
import cc.hiver.core.entity.Courier; |
||||
|
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 = "courier") |
||||
|
public interface CourierService extends HiverBaseService<Courier, String> { |
||||
|
|
||||
|
/** |
||||
|
* 多条件分页获取快递员 |
||||
|
* |
||||
|
* @param Courier |
||||
|
* @param searchVo |
||||
|
* @param pageable |
||||
|
* @return |
||||
|
*/ |
||||
|
Page<Courier> findByCondition(Courier courier, SearchVo searchVo, Pageable pageable); |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,29 @@ |
|||||
|
package cc.hiver.core.service; |
||||
|
|
||||
|
import cc.hiver.core.base.HiverBaseService; |
||||
|
import cc.hiver.core.common.vo.SearchVo; |
||||
|
import cc.hiver.core.entity.Courier; |
||||
|
import cc.hiver.core.entity.Recharge; |
||||
|
import org.springframework.cache.annotation.CacheConfig; |
||||
|
import org.springframework.data.domain.Page; |
||||
|
import org.springframework.data.domain.Pageable; |
||||
|
|
||||
|
/** |
||||
|
* 用户接口 |
||||
|
* |
||||
|
* @author Houpn |
||||
|
*/ |
||||
|
@CacheConfig(cacheNames = "recharge") |
||||
|
public interface RechargeService extends HiverBaseService<Recharge, String> { |
||||
|
|
||||
|
/** |
||||
|
* 多条件分页获取充值记录 |
||||
|
* |
||||
|
* @param Recharge |
||||
|
* @param searchVo |
||||
|
* @param pageable |
||||
|
* @return |
||||
|
*/ |
||||
|
Page<Recharge> findByCondition(Recharge recharge, SearchVo searchVo, Pageable pageable); |
||||
|
|
||||
|
} |
||||
@ -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.CourierDao; |
||||
|
import cc.hiver.core.entity.Courier; |
||||
|
import cc.hiver.core.service.CourierService; |
||||
|
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 CourierServiceImpl implements CourierService { |
||||
|
@Autowired |
||||
|
private CourierDao courierDao; |
||||
|
|
||||
|
@Autowired |
||||
|
private SecurityUtil securityUtil; |
||||
|
|
||||
|
@Override |
||||
|
public CourierDao getRepository() { |
||||
|
return courierDao; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Page<Courier> findByCondition(Courier courier, SearchVo searchVo, Pageable pageable) { |
||||
|
return courierDao.findAll(new Specification<Courier>() { |
||||
|
@Nullable |
||||
|
@Override |
||||
|
public Predicate toPredicate(Root<Courier> root, CriteriaQuery<?> cq, CriteriaBuilder cb) { |
||||
|
Path<String> courierIdField = root.get("courierId"); |
||||
|
Path<String> courierNameField = root.get("courierName"); |
||||
|
Path<Integer> courierStatusField = root.get("courierStatus"); |
||||
|
Path<String> mobileField = root.get("mobile"); |
||||
|
Path<Date> createTimeField = root.get("createTime"); |
||||
|
|
||||
|
List<Predicate> list = new ArrayList<>(); |
||||
|
|
||||
|
if (StrUtil.isNotBlank(courier.getCourierId())) { |
||||
|
list.add(cb.equal(courierIdField, courier.getCourierId())); |
||||
|
} |
||||
|
|
||||
|
// 模糊搜素
|
||||
|
if (StrUtil.isNotBlank(courier.getCourierName())) { |
||||
|
list.add(cb.like(courierNameField, '%' + courier.getCourierName() + '%')); |
||||
|
} |
||||
|
|
||||
|
// 状态
|
||||
|
if (courier.getCourierStatus() != null) { |
||||
|
list.add(cb.equal(courierStatusField, courier.getCourierStatus())); |
||||
|
} |
||||
|
|
||||
|
// 模糊搜素
|
||||
|
if (StrUtil.isNotBlank(courier.getMobile())) { |
||||
|
list.add(cb.like(mobileField, '%' + courier.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,90 @@ |
|||||
|
package cc.hiver.core.serviceimpl; |
||||
|
|
||||
|
import cc.hiver.core.common.utils.SecurityUtil; |
||||
|
import cc.hiver.core.common.vo.SearchVo; |
||||
|
import cc.hiver.core.dao.RechargeDao; |
||||
|
import cc.hiver.core.entity.Recharge; |
||||
|
import cc.hiver.core.service.RechargeService; |
||||
|
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 RechargeServiceImpl implements RechargeService { |
||||
|
@Autowired |
||||
|
private RechargeDao rechargeDao; |
||||
|
|
||||
|
@Autowired |
||||
|
private SecurityUtil securityUtil; |
||||
|
|
||||
|
@Override |
||||
|
public RechargeDao getRepository() { |
||||
|
return rechargeDao; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Page<Recharge> findByCondition(Recharge recharge, SearchVo searchVo, Pageable pageable) { |
||||
|
return rechargeDao.findAll(new Specification<Recharge>() { |
||||
|
@Nullable |
||||
|
@Override |
||||
|
public Predicate toPredicate(Root<Recharge> root, CriteriaQuery<?> cq, CriteriaBuilder cb) { |
||||
|
Path<String> rechargeIdField = root.get("rechargeId"); |
||||
|
Path<String> rechargeWorkerIdField = root.get("rechargeWorkerId"); |
||||
|
Path<String> rechargeNameField = root.get("rechargeName"); |
||||
|
Path<String> mobileField = root.get("mobile"); |
||||
|
Path<Date> createTimeField = root.get("createTime"); |
||||
|
|
||||
|
List<Predicate> list = new ArrayList<>(); |
||||
|
|
||||
|
/*if (StrUtil.isNotBlank(recharge.getRechargeId())) { |
||||
|
list.add(cb.equal(rechargeIdField, recharge.getRechargeId())); |
||||
|
}*/ |
||||
|
|
||||
|
if (StrUtil.isNotBlank(recharge.getRechargeWorkerId())) { |
||||
|
list.add(cb.equal(rechargeWorkerIdField, recharge.getRechargeWorkerId())); |
||||
|
} |
||||
|
|
||||
|
// 模糊搜素
|
||||
|
if (StrUtil.isNotBlank(recharge.getRechargeName())) { |
||||
|
list.add(cb.like(rechargeNameField, '%' + recharge.getRechargeName() + '%')); |
||||
|
} |
||||
|
|
||||
|
// 模糊搜素
|
||||
|
if (StrUtil.isNotBlank(recharge.getMobile())) { |
||||
|
list.add(cb.like(mobileField, '%' + recharge.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,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.ExpressCompany; |
||||
|
import cc.hiver.app.entity.LogiticsCompany; |
||||
|
import cc.hiver.app.service.ExpressCompanyService; |
||||
|
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/express") |
||||
|
public class ExpressCompanyController { |
||||
|
@Autowired |
||||
|
private ExpressCompanyService companyService; |
||||
|
|
||||
|
@RequestMapping(value = "/getAll", method = RequestMethod.GET) |
||||
|
@ApiOperation(value = "获取全部数据") |
||||
|
public Result<List<ExpressCompany>> getAll() { |
||||
|
List<ExpressCompany> list = companyService.getAll(); |
||||
|
return new ResultUtil<List<ExpressCompany>>().setData(list); |
||||
|
} |
||||
|
|
||||
|
@RequestMapping(value = "/add", method = RequestMethod.POST) |
||||
|
@ResponseBody |
||||
|
@ApiOperation(value = "添加") |
||||
|
public Result<Object> add(ExpressCompany 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(ExpressCompany 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) { |
||||
|
ExpressCompany company = companyService.get(id); |
||||
|
companyService.delete(id); |
||||
|
} |
||||
|
return ResultUtil.success("删除成功"); |
||||
|
} |
||||
|
|
||||
|
@RequestMapping(value = "/getByCondition", method = RequestMethod.GET) |
||||
|
@ApiOperation(value = "多条件分页获取公司列表") |
||||
|
public Result<Page<ExpressCompany>> getByCondition(ExpressCompany company, |
||||
|
PageVo pageVo) { |
||||
|
Page<ExpressCompany> page = companyService.findByCondition(company, PageUtil.initPage(pageVo)); |
||||
|
return new ResultUtil<Page<ExpressCompany>>().setData(page); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,32 @@ |
|||||
|
/* |
||||
|
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.ExpressCompany; |
||||
|
import cc.hiver.core.base.HiverBaseDao; |
||||
|
|
||||
|
/** |
||||
|
* @author houpn |
||||
|
*/ |
||||
|
public interface ExpressCompanyDao extends HiverBaseDao<ExpressCompany, String> { |
||||
|
/** |
||||
|
* 通过公司名称获得记录 |
||||
|
* |
||||
|
* @param companyName |
||||
|
* @return |
||||
|
*/ |
||||
|
ExpressCompany findByCompanyName(String companyName); |
||||
|
} |
||||
@ -0,0 +1,68 @@ |
|||||
|
/* |
||||
|
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_ecompany") |
||||
|
@TableName("t_ecompany") |
||||
|
@ApiModel(value = "公司信息") |
||||
|
public class ExpressCompany 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,43 @@ |
|||||
|
/* |
||||
|
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.ExpressCompany; |
||||
|
import cc.hiver.core.base.HiverBaseService; |
||||
|
import org.springframework.data.domain.Page; |
||||
|
import org.springframework.data.domain.Pageable; |
||||
|
|
||||
|
/** |
||||
|
* @author Yazhi Li |
||||
|
*/ |
||||
|
public interface ExpressCompanyService extends HiverBaseService<ExpressCompany, String> { |
||||
|
/** |
||||
|
* 多条件获取 |
||||
|
* |
||||
|
* @param company |
||||
|
* @param pageable |
||||
|
* @return |
||||
|
*/ |
||||
|
Page<ExpressCompany> findByCondition(ExpressCompany company, Pageable pageable); |
||||
|
|
||||
|
/** |
||||
|
* 通过公司名称获得记录 |
||||
|
* |
||||
|
* @param companyName |
||||
|
* @return |
||||
|
*/ |
||||
|
ExpressCompany findByCompanyName(String companyName); |
||||
|
} |
||||
@ -0,0 +1,86 @@ |
|||||
|
/* |
||||
|
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.ExpressCompanyDao; |
||||
|
import cc.hiver.app.entity.ExpressCompany; |
||||
|
import cc.hiver.app.service.ExpressCompanyService; |
||||
|
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 ExpressCompanyServiceImpl implements ExpressCompanyService { |
||||
|
@Autowired |
||||
|
private ExpressCompanyDao companyDao; |
||||
|
|
||||
|
@Override |
||||
|
public HiverBaseDao<ExpressCompany, String> getRepository() { |
||||
|
return companyDao; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Page<ExpressCompany> findByCondition(ExpressCompany company, Pageable pageable) { |
||||
|
return companyDao.findAll(new Specification<ExpressCompany>() { |
||||
|
@Nullable |
||||
|
@Override |
||||
|
public Predicate toPredicate(Root<ExpressCompany> 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 ExpressCompany findByCompanyName(String companyName) { |
||||
|
return companyDao.findByCompanyName(companyName); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,135 @@ |
|||||
|
package cc.hiver.base.controller.manage; |
||||
|
|
||||
|
import cc.hiver.core.common.constant.CourierConstant; |
||||
|
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.Courier; |
||||
|
import cc.hiver.core.service.CourierService; |
||||
|
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/courier") |
||||
|
@CacheConfig(cacheNames = "courier") |
||||
|
@Transactional |
||||
|
public class CourierController { |
||||
|
public static final String courier = "courier::"; |
||||
|
|
||||
|
@Autowired |
||||
|
private CourierService courierService; |
||||
|
|
||||
|
@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<Courier>> getByCondition(Courier courier, |
||||
|
SearchVo searchVo, |
||||
|
PageVo pageVo) { |
||||
|
Page<Courier> page = courierService.findByCondition(courier, searchVo, PageUtil.initPage(pageVo)); |
||||
|
return new ResultUtil<Page<Courier>>().setData(page); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
@RequestMapping(value = "/delByIds", method = RequestMethod.POST) |
||||
|
@ApiOperation(value = "批量通过ids删除") |
||||
|
public Result delAllByIds(@RequestParam String[] ids) { |
||||
|
for (String id : ids) { |
||||
|
courierService.delete(id); |
||||
|
} |
||||
|
return ResultUtil.success("批量通过id删除数据成功"); |
||||
|
} |
||||
|
|
||||
|
@RequestMapping(value = "/admin/add", method = RequestMethod.POST) |
||||
|
@ApiOperation(value = "创建快递员") |
||||
|
public Result add(@Valid Courier u, |
||||
|
@RequestParam(required = false) String[] roleIds) { |
||||
|
|
||||
|
//更新余额,重置当次应缴
|
||||
|
u.setDepoBal(u.getDepoBal() + u.getDepoNum()); |
||||
|
u.setDepoNum(0); |
||||
|
|
||||
|
courierService.save(u); |
||||
|
|
||||
|
// 发送创建账号消息
|
||||
|
//addMessage.addSendMessage(user.getId());
|
||||
|
return ResultUtil.success("创建成功"); |
||||
|
} |
||||
|
|
||||
|
@RequestMapping(value = "/admin/edit", method = RequestMethod.POST) |
||||
|
@ApiOperation(value = "修改快递员信息", notes = "需要通过下单编号获取订单信息") |
||||
|
public Result edit(Courier u, |
||||
|
@RequestParam(required = false) String[] roleIds) { |
||||
|
//修改快递员信息时如涉及到充值押金情况,需要更新余额且重置应缴
|
||||
|
if(u.getDepoNum()>0){ |
||||
|
Courier courier = courierService.findById(u.getCourierId()); |
||||
|
u.setDepoBal(courier.getDepoBal() + u.getDepoNum()); |
||||
|
u.setDepoNum(0); |
||||
|
} |
||||
|
|
||||
|
courierService.update(u); |
||||
|
|
||||
|
return ResultUtil.success("修改成功"); |
||||
|
} |
||||
|
|
||||
|
@RequestMapping(value = "/admin/disable/{courierId}", method = RequestMethod.POST) |
||||
|
@ApiOperation(value = "后台人工禁用快递员") |
||||
|
public Result disable(@ApiParam("用户唯一id标识") @PathVariable String courierId) { |
||||
|
Courier courier = courierService.get(courierId); |
||||
|
courier.setCourierStatus(CourierConstant.COURIER_STATUS_DISABLE); |
||||
|
courierService.update(courier); |
||||
|
// 手动更新缓存
|
||||
|
//redisTemplate.delete(courier + courier.getcourierId());
|
||||
|
return ResultUtil.success("操作成功"); |
||||
|
} |
||||
|
|
||||
|
@RequestMapping(value = "/admin/enable/{courierId}", method = RequestMethod.POST) |
||||
|
@ApiOperation(value = "后台人工启用快递员") |
||||
|
public Result enable(@ApiParam("快递员唯一id标识") @PathVariable String courierId) { |
||||
|
Courier courier = courierService.get(courierId); |
||||
|
//这儿暂时有bug,启用的时候其实需要判定原状态是启用还是不可接单状态,需要进行逻辑判断
|
||||
|
courier.setCourierStatus(CourierConstant.COURIER_STATUS_NORMAL); |
||||
|
courierService.update(courier); |
||||
|
// 手动更新缓存
|
||||
|
//redisTemplate.delete(courier + courier.getcourierId());
|
||||
|
return ResultUtil.success("操作成功"); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,47 @@ |
|||||
|
package cc.hiver.base.controller.manage; |
||||
|
|
||||
|
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 cc.hiver.core.common.vo.SearchVo; |
||||
|
import cc.hiver.core.entity.Recharge; |
||||
|
import cc.hiver.core.service.RechargeService; |
||||
|
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.cache.annotation.CacheConfig; |
||||
|
import org.springframework.data.domain.Page; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
/** |
||||
|
* 充值记录管理接口 |
||||
|
* |
||||
|
* @author houpn |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@RestController |
||||
|
@Api(tags = "充值记录管理接口") |
||||
|
@RequestMapping("/hiver/recharge") |
||||
|
@Transactional |
||||
|
public class RechargeController { |
||||
|
public static final String recharge = "recharge::"; |
||||
|
|
||||
|
@Autowired |
||||
|
private RechargeService rechargeService; |
||||
|
|
||||
|
|
||||
|
|
||||
|
@RequestMapping(value = "/getByCondition", method = RequestMethod.GET) |
||||
|
@ApiOperation(value = "多条件分页获取订单列表") |
||||
|
public Result<Page<Recharge>> getByCondition(Recharge recharge, |
||||
|
SearchVo searchVo, |
||||
|
PageVo pageVo) { |
||||
|
Page<Recharge> page = rechargeService.findByCondition(recharge, searchVo, PageUtil.initPage(pageVo)); |
||||
|
return new ResultUtil<Page<Recharge>>().setData(page); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
Loading…
Reference in new issue