|
|
@ -33,61 +33,60 @@ public class CommonOrderServiceImpl extends ServiceImpl<CommonOrderMapper, Commo |
|
|
|
@Autowired |
|
|
|
private IHanHaiMemberService hanHaiMemberService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public void addCommonOrder(CommonOrder commonOrder) { |
|
|
|
//新增时设置hasChild为0 |
|
|
|
commonOrder.setHasChild(ICommonOrderService.NOCHILD); |
|
|
|
if(oConvertUtils.isEmpty(commonOrder.getPid())){ |
|
|
|
commonOrder.setPid(ICommonOrderService.ROOT_PID_VALUE); |
|
|
|
}else{ |
|
|
|
//如果当前节点父ID不为空 则设置父节点的hasChildren 为1 |
|
|
|
CommonOrder parent = baseMapper.selectById(commonOrder.getPid()); |
|
|
|
if(parent!=null && !"1".equals(parent.getHasChild())){ |
|
|
|
parent.setHasChild("1"); |
|
|
|
baseMapper.updateById(parent); |
|
|
|
} |
|
|
|
} |
|
|
|
baseMapper.insert(commonOrder); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void updateCommonOrder(CommonOrder commonOrder) { |
|
|
|
CommonOrder entity = this.getById(commonOrder.getId()); |
|
|
|
if(entity==null) { |
|
|
|
throw new JeecgBootException("未找到对应实体"); |
|
|
|
} |
|
|
|
String old_pid = entity.getPid(); |
|
|
|
String new_pid = commonOrder.getPid(); |
|
|
|
if(!old_pid.equals(new_pid)) { |
|
|
|
updateOldParentNode(old_pid); |
|
|
|
if(oConvertUtils.isEmpty(new_pid)){ |
|
|
|
commonOrder.setPid(ICommonOrderService.ROOT_PID_VALUE); |
|
|
|
} |
|
|
|
if(!ICommonOrderService.ROOT_PID_VALUE.equals(commonOrder.getPid())) { |
|
|
|
baseMapper.updateTreeNodeStatus(commonOrder.getPid(), ICommonOrderService.HASCHILD); |
|
|
|
} |
|
|
|
} |
|
|
|
@Override |
|
|
|
public void addCommonOrder(CommonOrder commonOrder) { |
|
|
|
//新增时设置hasChild为0 |
|
|
|
commonOrder.setHasChild(ICommonOrderService.NOCHILD); |
|
|
|
if(oConvertUtils.isEmpty(commonOrder.getPid())){ |
|
|
|
commonOrder.setPid(ICommonOrderService.ROOT_PID_VALUE); |
|
|
|
}else{ |
|
|
|
//如果当前节点父ID不为空 则设置父节点的hasChildren 为1 |
|
|
|
CommonOrder parent = baseMapper.selectById(commonOrder.getPid()); |
|
|
|
if(parent!=null && !"1".equals(parent.getHasChild())){ |
|
|
|
parent.setHasChild("1"); |
|
|
|
baseMapper.updateById(parent); |
|
|
|
} |
|
|
|
} |
|
|
|
baseMapper.insert(commonOrder); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void updateCommonOrder(CommonOrder commonOrder) { |
|
|
|
CommonOrder entity = this.getById(commonOrder.getId()); |
|
|
|
if(entity==null) { |
|
|
|
throw new JeecgBootException("未找到对应实体"); |
|
|
|
} |
|
|
|
String old_pid = entity.getPid(); |
|
|
|
String new_pid = commonOrder.getPid(); |
|
|
|
if(!old_pid.equals(new_pid)) { |
|
|
|
updateOldParentNode(old_pid); |
|
|
|
if(oConvertUtils.isEmpty(new_pid)){ |
|
|
|
commonOrder.setPid(ICommonOrderService.ROOT_PID_VALUE); |
|
|
|
} |
|
|
|
if(!ICommonOrderService.ROOT_PID_VALUE.equals(commonOrder.getPid())) { |
|
|
|
baseMapper.updateTreeNodeStatus(commonOrder.getPid(), ICommonOrderService.HASCHILD); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//发货 |
|
|
|
if ("1".equals(commonOrder.getStatus())){ |
|
|
|
commonOrder.setStatus("2"); |
|
|
|
if ("2".equals(commonOrder.getStatus())){ |
|
|
|
if("1".equals(commonOrder.getPayType())){ |
|
|
|
HanHaiMember member = hanHaiMemberService.getById(commonOrder.getUserId()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wxOrderLogisticsUtil.doShipmentOneself(commonOrder.getId(), commonOrder.getTitle(), member.getAppletOpenid()); |
|
|
|
try { |
|
|
|
wxOrderLogisticsUtil.doShipmentOneself(commonOrder.getId(), commonOrder.getTitle(), member.getAppletOpenid()); |
|
|
|
}catch (Exception e){} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
baseMapper.updateById(commonOrder); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void deleteCommonOrder(String id) throws JeecgBootException { |
|
|
|
//查询选中节点下所有子节点一并删除 |
|
|
|
baseMapper.updateById(commonOrder); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void deleteCommonOrder(String id) throws JeecgBootException { |
|
|
|
//查询选中节点下所有子节点一并删除 |
|
|
|
id = this.queryTreeChildIds(id); |
|
|
|
if(id.indexOf(",")>0) { |
|
|
|
StringBuffer sb = new StringBuffer(); |
|
|
@ -120,9 +119,9 @@ public class CommonOrderServiceImpl extends ServiceImpl<CommonOrderMapper, Commo |
|
|
|
updateOldParentNode(commonOrder.getPid()); |
|
|
|
baseMapper.deleteById(id); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<CommonOrder> queryTreeListNoPage(QueryWrapper<CommonOrder> queryWrapper) { |
|
|
|
List<CommonOrder> dataList = baseMapper.selectList(queryWrapper); |
|
|
|
List<CommonOrder> mapList = new ArrayList<>(); |
|
|
@ -142,21 +141,21 @@ public class CommonOrderServiceImpl extends ServiceImpl<CommonOrderMapper, Commo |
|
|
|
} |
|
|
|
return mapList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据所传pid查询旧的父级节点的子节点并修改相应状态值 |
|
|
|
* @param pid |
|
|
|
*/ |
|
|
|
private void updateOldParentNode(String pid) { |
|
|
|
if(!ICommonOrderService.ROOT_PID_VALUE.equals(pid)) { |
|
|
|
Long count = baseMapper.selectCount(new QueryWrapper<CommonOrder>().eq("pid", pid)); |
|
|
|
if(count==null || count<=1) { |
|
|
|
baseMapper.updateTreeNodeStatus(pid, ICommonOrderService.NOCHILD); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据所传pid查询旧的父级节点的子节点并修改相应状态值 |
|
|
|
* @param pid |
|
|
|
*/ |
|
|
|
private void updateOldParentNode(String pid) { |
|
|
|
if(!ICommonOrderService.ROOT_PID_VALUE.equals(pid)) { |
|
|
|
Long count = baseMapper.selectCount(new QueryWrapper<CommonOrder>().eq("pid", pid)); |
|
|
|
if(count==null || count<=1) { |
|
|
|
baseMapper.updateTreeNodeStatus(pid, ICommonOrderService.NOCHILD); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 递归查询节点的根节点 |
|
|
|
* @param pidVal |
|
|
|
* @return |
|
|
|