package com.yeshi.fanli.service.impl.order.dy;
|
|
import com.yeshi.fanli.dao.dy.DYOrderDao;
|
|
import com.yeshi.fanli.entity.dy.DYOrder;
|
|
import com.yeshi.fanli.exception.dy.DYOrderException;
|
|
import com.yeshi.fanli.service.inter.order.dy.DYOrderService;
|
|
import com.yeshi.fanli.util.StringUtil;
|
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
|
import java.util.Date;
|
import java.util.List;
|
|
@Service
|
public class DYOrderServiceImpl implements DYOrderService {
|
|
@Resource
|
private DYOrderDao dyOrderDao;
|
|
|
@Override
|
public void addOrder(DYOrder order) throws DYOrderException {
|
|
if (order == null || StringUtil.isNullOrEmpty(order.getOrder_id())) {
|
throw new DYOrderException(1, "数据不完整");
|
}
|
|
// 查询是否添加过
|
List<DYOrder> oldList = dyOrderDao.listByOrderId(order.getOrder_id());
|
DYOrder old = null;
|
if (oldList != null && oldList.size() > 0) {
|
old = oldList.get(0);
|
}
|
if (old == null) {// 新增
|
// 添加信息
|
if (order.getCreateTime() == null)
|
order.setCreateTime(new Date());
|
if (order.getId()==null){
|
order.setId(order.toId());
|
}
|
dyOrderDao.save(order);
|
} else {// 更新
|
order.setId(old.getId());
|
order.setUpdateTime(new Date());
|
dyOrderDao.updateByPrimaryKey(order);
|
}
|
|
}
|
|
@Override
|
public DYOrder selectByPrimaryKey(String id) {
|
|
return dyOrderDao.selectByPrimaryKey(id);
|
}
|
|
@Override
|
public List<DYOrder> listByOrderId(String orderId) {
|
List<DYOrder> oldList = dyOrderDao.listByOrderId(orderId);
|
return oldList;
|
}
|
|
@Override
|
public Long countOrderByDay(String preDay) {
|
// TODO Auto-generated method stub
|
return null;
|
}
|
|
}
|