| | |
| | | package com.yeshi.fanli.service.impl.order.vipshop;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.vipshop.VipShopAfterSaleDetailInfoMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.vipshop.VipShopOrderDetailMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.vipshop.VipShopOrderMapper;
|
| | | import com.yeshi.fanli.entity.vipshop.VipShopAfterSaleDetailInfo;
|
| | | import com.yeshi.fanli.entity.vipshop.VipShopOrder;
|
| | | import com.yeshi.fanli.entity.vipshop.VipShopOrderDetail;
|
| | | import com.yeshi.fanli.exception.vipshop.VipShopOrderException;
|
| | | import com.yeshi.fanli.service.inter.order.vipshop.VipShopOrderService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.vipshop.VipShopUtil;
|
| | |
|
| | | @Service
|
| | | public class VipShopOrderServiceImpl implements VipShopOrderService {
|
| | |
|
| | | @Resource
|
| | | private VipShopOrderMapper vipShopOrderMapper;
|
| | |
|
| | | @Resource
|
| | | private VipShopOrderDetailMapper vipShopOrderDetailMapper;
|
| | |
|
| | | @Resource
|
| | | private VipShopAfterSaleDetailInfoMapper vipShopAfterSaleDetailInfoMapper;
|
| | |
|
| | | @Override
|
| | | public void addOrder(VipShopOrder order) throws VipShopOrderException {
|
| | |
|
| | | if (order == null || StringUtil.isNullOrEmpty(order.getOrderSn())) {
|
| | | throw new VipShopOrderException(1, "数据不完整");
|
| | | }
|
| | |
|
| | | // 查询是否添加过
|
| | | VipShopOrder old = vipShopOrderMapper.selectByOrderSn(order.getOrderSn());
|
| | | if (old == null) {// 新增
|
| | | // 添加信息
|
| | | if (order.getCreateTime() == null)
|
| | | order.setCreateTime(new Date());
|
| | | vipShopOrderMapper.insertSelective(order);
|
| | | } else {// 更新
|
| | | order.setId(old.getId());
|
| | | order.setUpdateTime(new Date());
|
| | | vipShopOrderMapper.updateByPrimaryKeySelective(order);
|
| | | }
|
| | |
|
| | | for (VipShopOrderDetail detail : order.getDetailList()) {
|
| | | detail.setIdentifyCode(VipShopUtil.getOrderDetailIdentifyCode(order.getOrderSn(), detail.getGoodsId(),
|
| | | detail.getSizeId()));
|
| | | detail.setOrderSn(order.getOrderSn());
|
| | | addOrderDetail(detail);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 添加详情信息
|
| | | * @Title: addOrderDetail
|
| | | * @Description: |
| | | * @param detail |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | private void addOrderDetail(VipShopOrderDetail detail) {
|
| | | VipShopOrderDetail old = vipShopOrderDetailMapper.selectByIdentifyCode(detail.getIdentifyCode());
|
| | | Long detailId = null;
|
| | | if (old == null) {
|
| | | if (detail.getCreateTime() == null)
|
| | | detail.setCreateTime(new Date());
|
| | | vipShopOrderDetailMapper.insertSelective(detail);
|
| | | detailId = detail.getId();
|
| | | } else {
|
| | | detail.setId(old.getId());
|
| | | detail.setUpdateTime(new Date());
|
| | | vipShopOrderDetailMapper.insertSelective(detail);
|
| | | detailId = detail.getId();
|
| | | }
|
| | |
|
| | | if (detail.getAfterSaleInfo() != null)
|
| | | for (VipShopAfterSaleDetailInfo info : detail.getAfterSaleInfo()) {
|
| | | info.setOrderDetailId(detailId);
|
| | | addAfterSaleDetailInfo(info);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 添加售后信息
|
| | | * @Title: addAfterSaleDetailInfo
|
| | | * @Description: |
| | | * @param detailInfo |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | private void addAfterSaleDetailInfo(VipShopAfterSaleDetailInfo detailInfo) {
|
| | | VipShopAfterSaleDetailInfo oldInfo = vipShopAfterSaleDetailInfoMapper.selectByOrderDetailId(detailInfo.getId());
|
| | | if (oldInfo == null) {
|
| | | if (detailInfo.getCreateTime() == null)
|
| | | detailInfo.setCreateTime(new Date());
|
| | | vipShopAfterSaleDetailInfoMapper.insertSelective(detailInfo);
|
| | | } else {
|
| | | detailInfo.setId(oldInfo.getId());
|
| | | detailInfo.setUpdateTime(new Date());
|
| | | vipShopAfterSaleDetailInfoMapper.updateByPrimaryKeySelective(detailInfo);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public VipShopOrder selectByPrimaryKey(Long orderId) {
|
| | |
|
| | | return vipShopOrderMapper.selectByPrimaryKey(orderId);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<VipShopOrder> listByOrderSn(String orderSn) {
|
| | | List<VipShopOrder> list = new ArrayList<>();
|
| | | VipShopOrder order = vipShopOrderMapper.selectByOrderSn(orderSn);
|
| | | if (order == null)
|
| | | return null;
|
| | | list.add(order);
|
| | | return list;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public VipShopOrder selectDetailByPrimaryKey(Long orderId) {
|
| | | VipShopOrder order = vipShopOrderMapper.selectByPrimaryKey(orderId);
|
| | | if (order == null)
|
| | | return null;
|
| | | List<VipShopOrderDetail> detailList = vipShopOrderDetailMapper.listByOrderSn(order.getOrderSn());
|
| | | order.setDetailList(detailList);
|
| | | return order;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Long countOrderByDay(String preDay) {
|
| | | // TODO Auto-generated method stub
|
| | | return null;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<VipShopOrderDetail> listDetailQuery(long start, int count, String key) {
|
| | | // TODO Auto-generated method stub
|
| | | return null;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countDetailQuery(String key) {
|
| | | // TODO Auto-generated method stub
|
| | | return 0;
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.service.impl.order.vipshop; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.yeshi.fanli.dao.mybatis.vipshop.VipShopAfterSaleDetailInfoMapper; |
| | | import com.yeshi.fanli.dao.mybatis.vipshop.VipShopOrderDetailMapper; |
| | | import com.yeshi.fanli.dao.mybatis.vipshop.VipShopOrderMapper; |
| | | import com.yeshi.fanli.entity.vipshop.VipShopAfterSaleDetailInfo; |
| | | import com.yeshi.fanli.entity.vipshop.VipShopOrder; |
| | | import com.yeshi.fanli.entity.vipshop.VipShopOrderDetail; |
| | | import com.yeshi.fanli.exception.vipshop.VipShopOrderException; |
| | | import com.yeshi.fanli.service.inter.order.vipshop.VipShopOrderService; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.vipshop.VipShopUtil; |
| | | |
| | | @Service |
| | | public class VipShopOrderServiceImpl implements VipShopOrderService { |
| | | |
| | | @Resource |
| | | private VipShopOrderMapper vipShopOrderMapper; |
| | | |
| | | @Resource |
| | | private VipShopOrderDetailMapper vipShopOrderDetailMapper; |
| | | |
| | | @Resource |
| | | private VipShopAfterSaleDetailInfoMapper vipShopAfterSaleDetailInfoMapper; |
| | | |
| | | @Override |
| | | public void addOrder(VipShopOrder order) throws VipShopOrderException { |
| | | |
| | | if (order == null || StringUtil.isNullOrEmpty(order.getOrderSn())) { |
| | | throw new VipShopOrderException(1, "数据不完整"); |
| | | } |
| | | |
| | | // 查询是否添加过 |
| | | VipShopOrder old = vipShopOrderMapper.selectByOrderSn(order.getOrderSn()); |
| | | if (old == null) {// 新增 |
| | | // 添加信息 |
| | | if (order.getCreateTime() == null) |
| | | order.setCreateTime(new Date()); |
| | | vipShopOrderMapper.insertSelective(order); |
| | | } else {// 更新 |
| | | order.setId(old.getId()); |
| | | order.setUpdateTime(new Date()); |
| | | vipShopOrderMapper.updateByPrimaryKeySelective(order); |
| | | } |
| | | |
| | | for (VipShopOrderDetail detail : order.getDetailList()) { |
| | | detail.setIdentifyCode(VipShopUtil.getOrderDetailIdentifyCode(order.getOrderSn(), detail.getGoodsId(), |
| | | detail.getSizeId())); |
| | | detail.setOrderSn(order.getOrderSn()); |
| | | addOrderDetail(detail); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 添加详情信息 |
| | | * |
| | | * @param detail void 返回类型 |
| | | * @throws |
| | | * @Title: addOrderDetail |
| | | * @Description: |
| | | */ |
| | | private void addOrderDetail(VipShopOrderDetail detail) { |
| | | VipShopOrderDetail old = vipShopOrderDetailMapper.selectByIdentifyCode(detail.getIdentifyCode()); |
| | | Long detailId = null; |
| | | if (old == null) { |
| | | if (detail.getCreateTime() == null) |
| | | detail.setCreateTime(new Date()); |
| | | vipShopOrderDetailMapper.insertSelective(detail); |
| | | detailId = detail.getId(); |
| | | } else { |
| | | detail.setId(old.getId()); |
| | | detail.setUpdateTime(new Date()); |
| | | vipShopOrderDetailMapper.updateByPrimaryKey(detail); |
| | | detailId = detail.getId(); |
| | | } |
| | | |
| | | if (detail.getAfterSaleInfo() != null) |
| | | for (VipShopAfterSaleDetailInfo info : detail.getAfterSaleInfo()) { |
| | | info.setOrderDetailId(detailId); |
| | | addAfterSaleDetailInfo(info); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 添加售后信息 |
| | | * |
| | | * @param detailInfo void 返回类型 |
| | | * @throws |
| | | * @Title: addAfterSaleDetailInfo |
| | | * @Description: |
| | | */ |
| | | private void addAfterSaleDetailInfo(VipShopAfterSaleDetailInfo detailInfo) { |
| | | VipShopAfterSaleDetailInfo oldInfo = vipShopAfterSaleDetailInfoMapper.selectByOrderDetailId(detailInfo.getId()); |
| | | if (oldInfo == null) { |
| | | if (detailInfo.getCreateTime() == null) |
| | | detailInfo.setCreateTime(new Date()); |
| | | vipShopAfterSaleDetailInfoMapper.insertSelective(detailInfo); |
| | | } else { |
| | | detailInfo.setId(oldInfo.getId()); |
| | | detailInfo.setUpdateTime(new Date()); |
| | | vipShopAfterSaleDetailInfoMapper.updateByPrimaryKeySelective(detailInfo); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public VipShopOrder selectByPrimaryKey(Long orderId) { |
| | | |
| | | return vipShopOrderMapper.selectByPrimaryKey(orderId); |
| | | } |
| | | |
| | | @Override |
| | | public List<VipShopOrder> listByOrderSn(String orderSn) { |
| | | List<VipShopOrder> list = new ArrayList<>(); |
| | | VipShopOrder order = vipShopOrderMapper.selectByOrderSn(orderSn); |
| | | if (order == null) |
| | | return null; |
| | | list.add(order); |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public List<VipShopOrder> listDetailByOrderSn(String orderSn) { |
| | | List<VipShopOrder> list = new ArrayList<>(); |
| | | VipShopOrder order = vipShopOrderMapper.selectByOrderSn(orderSn); |
| | | if (order == null) |
| | | return null; |
| | | order = selectDetailByPrimaryKey(order.getId()); |
| | | list.add(order); |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public VipShopOrder selectDetailByPrimaryKey(Long orderId) { |
| | | VipShopOrder order = vipShopOrderMapper.selectByPrimaryKey(orderId); |
| | | if (order == null) |
| | | return null; |
| | | List<VipShopOrderDetail> detailList = vipShopOrderDetailMapper.listByOrderSn(order.getOrderSn()); |
| | | order.setDetailList(detailList); |
| | | return order; |
| | | } |
| | | |
| | | @Override |
| | | public Long countOrderByDay(String preDay) { |
| | | // TODO Auto-generated method stub |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public List<VipShopOrderDetail> listDetailQuery(long start, int count, String key) { |
| | | // TODO Auto-generated method stub |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public long countDetailQuery(String key) { |
| | | // TODO Auto-generated method stub |
| | | return 0; |
| | | } |
| | | |
| | | } |