package com.hai.service.impl; import com.hai.dao.HighGasOrderMapper; import com.hai.entity.HighGasOrder; import com.hai.entity.HighGasOrderExample; import com.hai.service.HighGasOrderService; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.*; import java.util.stream.Collectors; import java.util.stream.IntStream; /** * @className: HighGasOrderServiceImpl * @author: HuRui * @date: 2022/9/6 **/ @Service("gasOrderService") public class HighGasOrderServiceImpl implements HighGasOrderService { @Resource private HighGasOrderMapper gasOrderMapper; @Override public void addGasOrder(HighGasOrder gasOrder) { gasOrder.setCreateTime(new Date()); gasOrderMapper.insert(gasOrder); } @Override public void updateGasOrder(HighGasOrder gasOrder) { gasOrderMapper.updateByPrimaryKeySelective(gasOrder); } @Override public HighGasOrder getDetailByChildOrderNo(String childOrderNo) { HighGasOrderExample example = new HighGasOrderExample(); example.createCriteria().andChildOrderNoEqualTo(childOrderNo); List list = gasOrderMapper.selectByExample(example); if (list.size() > 0) { return list.get(0); } return null; } @Override public HighGasOrder getDetailByOrderNo(String orderNo) { HighGasOrderExample example = new HighGasOrderExample(); example.createCriteria().andOrderNoEqualTo(orderNo); List list = gasOrderMapper.selectByExample(example); if (list.size() > 0) { return list.get(0); } return null; } @Override public List getGasOrderList(Map param) { HighGasOrderExample example = new HighGasOrderExample(); HighGasOrderExample.Criteria criteria = example.createCriteria(); if (MapUtils.getLong(param, "companyId") != null) { criteria.andCompanyIdEqualTo(MapUtils.getLong(param, "companyId")); } if (MapUtils.getLong(param, "merId") != null) { criteria.andMerIdEqualTo(MapUtils.getLong(param, "merId")); } if (MapUtils.getLong(param, "storeId") != null) { criteria.andStoreIdEqualTo(MapUtils.getLong(param, "storeId")); } if (MapUtils.getLong(param, "gasOrgId") != null) { criteria.andGasOrgIdEqualTo(MapUtils.getLong(param, "gasOrgId")); } if (MapUtils.getLong(param, "gasAgentId") != null) { criteria.andGasAgentIdEqualTo(MapUtils.getLong(param, "gasAgentId")); } if (MapUtils.getLong(param, "gasSalesmanId") != null) { criteria.andGasSalesmanIdEqualTo(MapUtils.getLong(param, "gasSalesmanId")); } if (MapUtils.getLong(param, "gasStaffId") != null) { criteria.andGasStaffIdEqualTo(MapUtils.getLong(param, "gasStaffId")); } if (StringUtils.isNotBlank(MapUtils.getString(param, "storeName"))) { criteria.andStoreNameLike("%"+MapUtils.getString(param, "storeName")+"%"); } if (StringUtils.isNotBlank(MapUtils.getString(param, "orderNo"))) { criteria.andOrderNoLike("%"+MapUtils.getString(param, "orderNo")+"%"); } if (StringUtils.isNotBlank(MapUtils.getString(param, "childOrderNo"))) { criteria.andChildOrderNoLike("%"+MapUtils.getString(param, "childOrderNo")+"%"); } if (StringUtils.isNotBlank(MapUtils.getString(param, "memCardNo"))) { criteria.andMemCardNoLike("%"+MapUtils.getString(param, "memCardNo")+"%"); } if (StringUtils.isNotBlank(MapUtils.getString(param, "memPhone"))) { criteria.andMemPhoneLike("%"+MapUtils.getString(param, "memPhone")+"%"); } if (MapUtils.getInteger(param, "gasOilType") != null) { criteria.andGasOilTypeEqualTo(MapUtils.getInteger(param, "storeId")); } if (StringUtils.isNotBlank(MapUtils.getString(param, "gasStaffName"))) { criteria.andGasStaffNameLike("%"+MapUtils.getString(param, "gasStaffName")+"%"); } if (StringUtils.isNotBlank(MapUtils.getString(param, "gasOilNo"))) { criteria.andGasOilNoEqualTo(MapUtils.getString(param, "gasOilNo")); } if (MapUtils.getInteger(param, "payType") != null) { criteria.andPayTypeEqualTo(MapUtils.getInteger(param, "payType")); } if (StringUtils.isNotBlank(MapUtils.getString(param, "status"))) { List status = Arrays.stream(MapUtils.getString(param, "status").split(",")) .flatMapToInt(num -> IntStream.of(Integer.parseInt(num))).boxed() .collect(Collectors.toList()); criteria.andStatusIn(status); } if (MapUtils.getLong(param, "createTimeS") != null) { criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(param, "createTimeS"))); } if (MapUtils.getLong(param, "createTimeE") != null) { criteria.andCreateTimeLessThanOrEqualTo(new Date(MapUtils.getLong(param, "createTimeE"))); } if (MapUtils.getLong(param, "payTimeS") != null) { criteria.andPayTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(param, "payTimeS"))); } if (MapUtils.getLong(param, "payTimeE") != null) { criteria.andPayTimeLessThanOrEqualTo(new Date(MapUtils.getLong(param, "payTimeE"))); } if (MapUtils.getLong(param, "refundTimeS") != null) { criteria.andRefundTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(param, "refundTimeS"))); } if (MapUtils.getLong(param, "refundTimeE") != null) { criteria.andRefundTimeLessThanOrEqualTo(new Date(MapUtils.getLong(param, "refundTimeE"))); } example.setOrderByClause("create_time desc"); return gasOrderMapper.selectByExample(example); } }