package com.goafanti.order.service.impl; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.commons.lang3.StringUtils; import org.hibernate.validator.constraints.Mod11Check.ProcessingDirection; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.goafanti.common.dao.OutsourceOrganizationMapper; import com.goafanti.common.dao.TOrderLogMapper; import com.goafanti.common.dao.TOrderNewMapper; import com.goafanti.common.dao.TOrderOutsourceMapper; import com.goafanti.common.enums.OrderLogProcess; import com.goafanti.common.model.OutsourceOrganization; import com.goafanti.common.model.TOrderLog; import com.goafanti.common.model.TOrderNew; import com.goafanti.core.mybatis.BaseMybatisDao; import com.goafanti.core.mybatis.page.Pagination; import com.goafanti.core.shiro.token.TokenManager; import com.goafanti.order.bo.OrderOutsourceBo; import com.goafanti.order.bo.OrderOutsourceDtails; import com.goafanti.order.bo.OutsourceOrganizationBo; import com.goafanti.order.enums.ProcessStatus; import com.goafanti.order.service.OrderService; import com.goafanti.order.service.OutsourceOrgService; @Service public class OutsourceOrgServiceImpl extends BaseMybatisDao implements OutsourceOrgService { @Autowired private OutsourceOrganizationMapper outsourceOrganizationMapper; @Autowired private TOrderOutsourceMapper tOrderOutsourceMapper; @Autowired private TOrderNewMapper tOrderNewMapper; @Autowired private OrderService orderService; @Autowired private TOrderLogMapper tOrderLogMapper; @Override public int addOutsourceOrg(OutsourceOrganization o) { return outsourceOrganizationMapper.insertSelective(o); } @Override public int updateOutsourceOrg(OutsourceOrganization o) { return outsourceOrganizationMapper.updateByPrimaryKeySelective(o); } @Override public int deleteOutsourceOrg(Integer id) { return outsourceOrganizationMapper.deleteByPrimaryKey(id); } @Override public List selectOutsourceOrg(String orderNo,String tid) { List l=outsourceOrganizationMapper.selectOutsourceOrg(orderNo,tid); return l; } @Override public List selectOrderOutsourceOrg(String orderNo) { return outsourceOrganizationMapper.selectOrderOutsourceOrg(orderNo); } @Override @SuppressWarnings("unchecked") public Pagination orderOutsourceList(String name, String contractNo, String starTime, String endTime,Integer refundStatus, Integer pageNo, Integer pageSize) { Map params = new HashMap(); if(pageSize==null||pageSize<0)pageSize=10; if(pageNo==null||pageNo<0)pageNo=1; if (StringUtils.isNotBlank(name)) params.put("name", name); if(refundStatus != null) params.put("refundStatus", refundStatus); if (StringUtils.isNotBlank(contractNo)) params.put("contractNo", contractNo); if (StringUtils.isNotBlank(starTime)) params.put("starTime", starTime); if (StringUtils.isNotBlank(endTime)) params.put("endTime", endTime+" 23:59:59"); Pagination p = (Pagination)findPage("orderOutsourceList", "orderOutsourceCount", params, pageNo, pageSize); return p; } @Override public OrderOutsourceDtails orderOutsourceDtails(String orderNo) { return tOrderOutsourceMapper.selectByOrderNo(orderNo); } @Override public int updateAuditOutsource(OrderOutsourceDtails o) { o.setAuditTime(new Date()); TOrderNew t=new TOrderNew(); if (o.getRefundStatus()==1) { t.setOrderNo(o.getOrderNo()); t.setOrderStatus(2);//订单审核标记通过 t.setProcessStatus(ProcessStatus.YPCWGLY.getCode()); addOrderLog(o.getOrderNo(),OrderLogProcess.WBSH.getCode()); tOrderNewMapper.updateByPrimaryKeySelective(t); }else { t.setOrderStatus(3); addOrderLog(o.getOrderNo(),OrderLogProcess.WBBH.getCode()); } return tOrderOutsourceMapper.updateByPrimaryKeySelective(o); } public void addOrderLog(String orderNo, Integer code) { TOrderLog tl=new TOrderLog(); tl.setOrderNo(orderNo); tl.setProcess(code); tl.setAid(TokenManager.getAdminId()); tOrderLogMapper.insertSelective(tl); } @SuppressWarnings("unchecked") @Override public Pagination salesmanOrderOutsourceList(String name, String contractNo, String starTime, String endTime, Integer refundStatus, Integer pageNo, Integer pageSize) { Map params = new HashMap(); if(pageSize==null||pageSize<0)pageSize=10; if(pageNo==null||pageNo<0)pageNo=1; if (StringUtils.isNotBlank(name)) params.put("name", name); params.put("deps", orderService.selectMyDeps()); if(refundStatus != null) params.put("refundStatus", refundStatus); if (StringUtils.isNotBlank(contractNo)) params.put("contractNo", contractNo); if (StringUtils.isNotBlank(starTime)) params.put("starTime", starTime); if (StringUtils.isNotBlank(endTime)) params.put("endTime", endTime+" 23:59:59"); Pagination p = (Pagination)findPage("salesmanOrderOutsourceList", "salesmanOrderOutsourceCount", params, pageNo, pageSize); return p; } }