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.
93 lines
3.3 KiB
93 lines
3.3 KiB
package com.hai.service.impl;
|
|
|
|
import com.hai.dao.HighDiscountMapper;
|
|
import com.hai.entity.HighDiscount;
|
|
import com.hai.entity.HighDiscountCouponRel;
|
|
import com.hai.entity.HighDiscountExample;
|
|
import com.hai.service.HighDiscountService;
|
|
import org.apache.commons.collections4.MapUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.math.BigDecimal;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.stream.Collectors;
|
|
|
|
/**
|
|
* @Auther: 胡锐
|
|
* @Description:
|
|
* @Date: 2021/4/3 21:39
|
|
*/
|
|
@Service("highDiscountService")
|
|
public class HighDiscountServiceImpl implements HighDiscountService {
|
|
|
|
@Resource
|
|
private HighDiscountMapper highDiscountMapper;
|
|
|
|
@Override
|
|
public void insertDiscount(HighDiscount highDiscount) {
|
|
highDiscountMapper.insert(highDiscount);
|
|
}
|
|
|
|
@Override
|
|
public void updateDiscount(HighDiscount highDiscount) {
|
|
highDiscountMapper.updateByPrimaryKey(highDiscount);
|
|
}
|
|
|
|
@Override
|
|
public HighDiscount getDiscountById(Long id) {
|
|
return highDiscountMapper.selectByPrimaryKey(id);
|
|
}
|
|
|
|
@Override
|
|
public HighDiscount getDiscountByKey(String discountKey) {
|
|
HighDiscountExample example = new HighDiscountExample();
|
|
example.createCriteria().andDiscountKeyEqualTo(discountKey).andStatusNotEqualTo(0);
|
|
List<HighDiscount> list = highDiscountMapper.selectByExample(example);
|
|
if (list.size() > 0) {
|
|
return list.get(0);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public List<HighDiscount> getDiscount(Map<String, Object> map) {
|
|
HighDiscountExample example = new HighDiscountExample();
|
|
HighDiscountExample.Criteria criteria = example.createCriteria();
|
|
|
|
if (StringUtils.isNotBlank(MapUtils.getString(map, "discountKey"))) {
|
|
criteria.andDiscountKeyEqualTo(MapUtils.getString(map, "discountKey"));
|
|
}
|
|
if (StringUtils.isNotBlank(MapUtils.getString(map, "discountName"))) {
|
|
criteria.andDiscountNameLike("%" + MapUtils.getString(map, "discountName") + "%");
|
|
}
|
|
if (MapUtils.getInteger(map, "discountType") != null) {
|
|
criteria.andDiscountTypeEqualTo(MapUtils.getInteger(map, "discountType"));
|
|
}
|
|
if (MapUtils.getInteger(map, "useScope") != null) {
|
|
criteria.andUseScopeEqualTo(MapUtils.getInteger(map, "useScope"));
|
|
}
|
|
if (MapUtils.getLong(map, "companyId") != null) {
|
|
criteria.andCompanyIdEqualTo(MapUtils.getLong(map, "companyId"));
|
|
}
|
|
|
|
|
|
example.setOrderByClause("update_time desc");
|
|
return highDiscountMapper.selectByExample(example);
|
|
}
|
|
|
|
@Override
|
|
public List<BigDecimal> getDiscountPrice(Integer usingRange) {
|
|
HighDiscountExample discountExample = new HighDiscountExample();
|
|
discountExample.createCriteria().andUsingRangeEqualTo(usingRange);
|
|
List<HighDiscount> list = highDiscountMapper.selectByExample(discountExample);
|
|
List<BigDecimal> priceList = new ArrayList<>();
|
|
for (HighDiscount discount : list) {
|
|
priceList.add(discount.getDiscountPrice());
|
|
}
|
|
return priceList.stream().distinct().sorted().collect(Collectors.toList());
|
|
}
|
|
}
|
|
|