| | |
| | | package com.yeshi.fanli.service.impl.order.suning;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.suning.SuningOrderInfoMapper;
|
| | | import com.yeshi.fanli.entity.suning.SuningOrderInfo;
|
| | | import com.yeshi.fanli.exception.suning.SuningOrderException;
|
| | | import com.yeshi.fanli.service.inter.order.suning.SuningOrderService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | @Service
|
| | | public class SuningOrderServiceImpl implements SuningOrderService {
|
| | |
|
| | | @Resource
|
| | | private SuningOrderInfoMapper suningOrderMapper;
|
| | |
|
| | | @Override
|
| | | public void addOrder(SuningOrderInfo order) throws SuningOrderException {
|
| | |
|
| | | if (order == null || StringUtil.isNullOrEmpty(order.getOrderLineNumber())) {
|
| | | throw new SuningOrderException(1, "数据不完整");
|
| | | }
|
| | |
|
| | | // 查询是否添加过
|
| | | SuningOrderInfo old = suningOrderMapper.selectByOrderLineNum(order.getOrderLineNumber());
|
| | | if (old == null) {// 新增
|
| | | // 添加信息
|
| | | if (order.getCreateTime() == null)
|
| | | order.setCreateTime(new Date());
|
| | | suningOrderMapper.insertSelective(order);
|
| | | } else {// 更新
|
| | | order.setId(old.getId());
|
| | | order.setUpdateTime(new Date());
|
| | | suningOrderMapper.updateByPrimaryKeySelective(order);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public SuningOrderInfo selectByPrimaryKey(Long orderId) {
|
| | |
|
| | | return suningOrderMapper.selectByPrimaryKey(orderId);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<SuningOrderInfo> listByOrderCode(String orderCode) {
|
| | | return suningOrderMapper.listByOrderCode(orderCode);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public SuningOrderInfo selectByOrderLineNumber(String orderLineNo) {
|
| | | |
| | | return suningOrderMapper.selectByOrderLineNum(orderLineNo);
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.service.impl.order.suning; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.yeshi.fanli.dao.mybatis.suning.SuningOrderInfoMapper; |
| | | import com.yeshi.fanli.entity.suning.SuningOrderInfo; |
| | | import com.yeshi.fanli.exception.suning.SuningOrderException; |
| | | import com.yeshi.fanli.service.inter.order.suning.SuningOrderService; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | |
| | | @Service |
| | | public class SuningOrderServiceImpl implements SuningOrderService { |
| | | |
| | | @Resource |
| | | private SuningOrderInfoMapper suningOrderMapper; |
| | | |
| | | @Override |
| | | public void addOrder(SuningOrderInfo order) throws SuningOrderException { |
| | | |
| | | if (order == null || StringUtil.isNullOrEmpty(order.getOrderLineNumber())) { |
| | | throw new SuningOrderException(1, "数据不完整"); |
| | | } |
| | | |
| | | // 查询是否添加过 |
| | | SuningOrderInfo old = suningOrderMapper.selectByOrderLineNum(order.getOrderLineNumber()); |
| | | if (old == null) {// 新增 |
| | | // 添加信息 |
| | | if (order.getCreateTime() == null) |
| | | order.setCreateTime(new Date()); |
| | | suningOrderMapper.insertSelective(order); |
| | | } else {// 更新 |
| | | order.setId(old.getId()); |
| | | order.setUpdateTime(new Date()); |
| | | suningOrderMapper.updateByPrimaryKeySelective(order); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public SuningOrderInfo selectByPrimaryKey(Long orderId) { |
| | | |
| | | return suningOrderMapper.selectByPrimaryKey(orderId); |
| | | } |
| | | |
| | | @Override |
| | | public List<SuningOrderInfo> listByOrderCode(String orderCode) { |
| | | return suningOrderMapper.listByOrderCode(orderCode); |
| | | } |
| | | |
| | | @Override |
| | | public SuningOrderInfo selectByOrderLineNumber(String orderLineNo) { |
| | | |
| | | return suningOrderMapper.selectByOrderLineNum(orderLineNo); |
| | | } |
| | | |
| | | } |