package com.yeshi.fanli.service.impl.pdd;
|
|
import java.util.Date;
|
|
import javax.annotation.Resource;
|
|
import org.springframework.stereotype.Service;
|
|
import com.yeshi.fanli.dao.mybatis.pdd.PDDOrderMapper;
|
import com.yeshi.fanli.entity.pdd.PDDOrder;
|
import com.yeshi.fanli.exception.pdd.PDDOrderException;
|
import com.yeshi.fanli.service.inter.pdd.PDDOrderService;
|
import com.yeshi.fanli.util.StringUtil;
|
|
@Service
|
public class PDDOrderServiceImpl implements PDDOrderService {
|
|
@Resource
|
private PDDOrderMapper pddOrderMapper;
|
|
@Override
|
public PDDOrder addOrder(PDDOrder order) throws PDDOrderException {
|
if (order == null || StringUtil.isNullOrEmpty(order.getOrderSn()))
|
throw new PDDOrderException(1, "订单信息不完整");
|
|
PDDOrder old = pddOrderMapper.selectByOrderSN(order.getOrderSn());
|
if (old != null) {
|
// 更新订单信息
|
if (order.getOrderStatus().intValue() != old.getOrderStatus()) {// 状态改变了才更改订单信息
|
PDDOrder update = new PDDOrder();
|
update.setId(old.getId());
|
update.setOrderStatus(order.getOrderStatus());
|
update.setOrderAmount(order.getOrderAmount());
|
update.setOrderStatusDesc(order.getOrderStatusDesc());
|
update.setOrderVerifyTime(order.getOrderVerifyTime());
|
update.setOrderGroupSuccessTime(order.getOrderGroupSuccessTime());
|
update.setOrderModifyAt(order.getOrderModifyAt());
|
update.setOrderPayTime(order.getOrderPayTime());
|
update.setOrderSettleTime(order.getOrderSettleTime());
|
update.setGoodsName(order.getGoodsName());
|
update.setGoodsPrice(order.getGoodsPrice());
|
update.setUpdateTime(new Date());
|
pddOrderMapper.updateByPrimaryKeySelective(update);
|
return pddOrderMapper.selectByPrimaryKey(old.getId());
|
}
|
} else {
|
if (order.getUpdateTime() == null)
|
order.setUpdateTime(new Date());
|
if (order.getCreateTime() == null)
|
order.setCreateTime(new Date());
|
pddOrderMapper.insertSelective(order);
|
}
|
|
return order;
|
}
|
|
}
|