You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 lines
3.6 KiB

3 years ago
package com.cyl.oms.service;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import com.cyl.oms.mapper.RefundMapper;
import com.cyl.oms.domain.Refund;
import com.cyl.oms.pojo.query.RefundQuery;
/**
* Service
*
*
* @author zcc
*/
@Service
public class RefundService {
@Autowired
private RefundMapper refundMapper;
/**
*
*
* @param id
* @return
*/
public Refund selectById(Long id) {
return refundMapper.selectById(id);
}
/**
*
*
* @param query
* @param page
* @return
*/
public List<Refund> selectList(RefundQuery query, Pageable page) {
if (page != null) {
PageHelper.startPage(page.getPageNumber() + 1, page.getPageSize());
}
QueryWrapper<Refund> qw = new QueryWrapper<>();
Long memberId = query.getMemberId();
if (memberId != null) {
qw.eq("member_id", memberId);
}
Long orderId = query.getOrderId();
if (orderId != null) {
qw.eq("order_id", orderId);
}
BigDecimal returnAmount = query.getReturnAmount();
if (returnAmount != null) {
qw.eq("return_amount", returnAmount);
}
Integer type = query.getType();
if (type != null) {
qw.eq("type", type);
}
Integer status = query.getStatus();
if (status != null) {
qw.eq("status", status);
}
LocalDateTime handleTime = query.getHandleTime();
if (handleTime != null) {
qw.eq("handle_time", handleTime);
}
Integer quantity = query.getQuantity();
if (quantity != null) {
qw.eq("quantity", quantity);
}
String reason = query.getReason();
if (!StringUtils.isEmpty(reason)) {
qw.eq("reason", reason);
}
String description = query.getDescription();
if (!StringUtils.isEmpty(description)) {
qw.eq("description", description);
}
String proofPics = query.getProofPics();
if (!StringUtils.isEmpty(proofPics)) {
qw.eq("proof_pics", proofPics);
}
String handleNote = query.getHandleNote();
if (!StringUtils.isEmpty(handleNote)) {
qw.eq("handle_note", handleNote);
}
String handleMan = query.getHandleMan();
if (!StringUtils.isEmpty(handleMan)) {
qw.eq("handle_man", handleMan);
}
return refundMapper.selectList(qw);
}
/**
*
*
* @param refund
* @return
*/
public int insert(Refund refund) {
refund.setCreateTime(LocalDateTime.now());
return refundMapper.insert(refund);
}
/**
*
*
* @param refund
* @return
*/
public int update(Refund refund) {
return refundMapper.updateById(refund);
}
/**
*
*
* @param id
* @return
*/
public int deleteById(Long id) {
return refundMapper.deleteById(id);
}
}