7 changed files with 348 additions and 15 deletions
@ -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,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.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,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,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