| | |
| | | package com.yeshi.fanli.service.impl.order;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.order.OrderSubsidyMapper;
|
| | | import com.yeshi.fanli.entity.order.OrderSubsidy;
|
| | | import com.yeshi.fanli.exception.order.OrderSubsidyException;
|
| | | import com.yeshi.fanli.service.inter.order.OrderSubsidyService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | @Service
|
| | | public class OrderSubsidyServiceImpl implements OrderSubsidyService {
|
| | |
| | | return orderSubsidyMapper.getByOrderNoAndType(uid, orderNo, type);
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void addOrderSubsidy(OrderSubsidy orderSubsidy) throws OrderSubsidyException {
|
| | | if (orderSubsidy.getMoney() == null || StringUtil.isNullOrEmpty(orderSubsidy.getOrderNo())
|
| | | || orderSubsidy.getSourceType() == null || orderSubsidy.getUid() == null)
|
| | | throw new OrderSubsidyException(1, "数据不完整");
|
| | | OrderSubsidy old = getByOrderNoAndType(orderSubsidy.getUid(), orderSubsidy.getOrderNo(),
|
| | | orderSubsidy.getSourceType());
|
| | | if (old != null) {// 修改
|
| | | // 修改状态
|
| | | OrderSubsidy update = new OrderSubsidy(old.getId());
|
| | | update.setMoney(orderSubsidy.getMoney());
|
| | | update.setState(orderSubsidy.getState());
|
| | | update.setUpdateTime(new Date());
|
| | | orderSubsidyMapper.updateByPrimaryKeySelective(update);
|
| | | } else {// 添加
|
| | | if (orderSubsidy.getCreateTime() == null)
|
| | | orderSubsidy.setCreateTime(new Date());
|
| | | orderSubsidyMapper.insertSelective(orderSubsidy);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|