毕业设计|SSM+VUE的旅游平台系统(一)https://developer.aliyun.com/article/1423953
四,核心代码展示
4.1 SbsnOrderServiceImpl
@Service public class SbsnOrderServiceImpl implements SbsnOrderService { @Resource private SbsnOrderDao sbsnOrderDao; @Resource private TSbsnActDao tSbsnActDao; @Resource private TSbsnCode tSbsnCode; @Resource private ScenicDao scenicDao; @Override public PageInfo queryByParam(Page<SbsnOrder> page) { PageHelper.startPage(page.getPageNo(),page.getPageSize()); PageInfo pageInfo = new PageInfo(sbsnOrderDao.queryByParam(page.getData())); return pageInfo; } /** * 查询全部 * @param queryTime * @param scenicName * @return */ @Override public List<Map> queryAll(String queryTime, String scenicName) { return sbsnOrderDao.queryAll(queryTime,scenicName); } /** * 设置订单的初始化信息 * @param sbsnOrder 前台传过来的订单 * @return */ @Override @Transactional public SbsnOrder add(SbsnOrder sbsnOrder) { //设置参数 代付款 sbsnOrder.setCodeid(ConstantUtil.OrderStatus.PENDING_PAYMENT); sbsnOrder.setState(ConstantUtil.OrderStatus.PENDING_PAYMENT); sbsnOrder.setOrdertime(new Date()); //返回添加的主键 int add = sbsnOrderDao.add(sbsnOrder); //添加状态 TSbsnAct tSbsnAct = new TSbsnAct(); tSbsnAct.setOrderid(sbsnOrder.getOrderid()); tSbsnAct.setCodeid(sbsnOrder.getCodeid()); tSbsnAct.setActcode(sbsnOrder.getCodeid()); //查询动作名称 tSbsnAct.setActname(tSbsnCode.queryName(sbsnOrder.getCodeid())); tSbsnAct.setBz("待付款"); tSbsnAct.setCztime(sbsnOrder.getOrdertime()); tSbsnAct.setCzrid(sbsnOrder.getUserid()); //调用添加 tSbsnActDao.add(tSbsnAct); //景区添加票数 Scenic scenic = scenicDao.queryBy(sbsnOrder.getScenicid()); Integer onums = scenic.getOnums(); scenic.setOnums(onums+1); //修改订票信息 scenicDao.update(scenic); return sbsnOrder; } /** * 更改订单状态 * @param sbsnOrder 更改订单状态 * @return */ @Override @Transactional public int update(SbsnOrder sbsnOrder) { //设置参数 已付款 sbsnOrder.setCodeid(ConstantUtil.OrderStatus.PAID); sbsnOrder.setState(ConstantUtil.OrderStatus.PAID); sbsnOrder.setOrdertime(new Date()); // sbsnOrder.setCodeid(12); // sbsnOrder.setState(12); System.out.println(sbsnOrder+"----------------"); int update = sbsnOrderDao.update(sbsnOrder); //设置订单状态 TSbsnAct tSbsnAct = tSbsnActDao.queryById(sbsnOrder.getOrderid()); tSbsnAct.setCodeid(sbsnOrder.getCodeid()); tSbsnAct.setActcode(sbsnOrder.getCodeid()); //查询动作名称 tSbsnAct.setActname(tSbsnCode.queryName(tSbsnAct.getCodeid())); tSbsnAct.setBz("付款成功"); tSbsnActDao.update(tSbsnAct); //更新景区门票 Scenic scenic = scenicDao.queryBy(sbsnOrder.getScenicid()); Integer snums = scenic.getSnums(); scenic.setSnums(snums+1); Integer onums = scenic.getOnums(); scenic.setOnums(onums-1); scenicDao.update(scenic); return update; } /** * 更改订单状态 * @param sbsnOrder 更改订单状态 * @return */ @Override @Transactional public int setOrder(SbsnOrder sbsnOrder) { //设置参数 已付款 sbsnOrder.setCodeid(ConstantUtil.OrderStatus.CANCER); sbsnOrder.setState(ConstantUtil.OrderStatus.CANCER); sbsnOrder.setOrdertime(new Date()); int update = sbsnOrderDao.update(sbsnOrder); //设置订单状态 TSbsnAct tSbsnAct = tSbsnActDao.queryById(sbsnOrder.getOrderid()); tSbsnAct.setCodeid(sbsnOrder.getCodeid()); tSbsnAct.setActcode(sbsnOrder.getCodeid()); //查询动作名称 tSbsnAct.setActname(tSbsnCode.queryName(tSbsnAct.getCodeid())); tSbsnAct.setBz("已取消订单"); tSbsnActDao.update(tSbsnAct); //更新景区门票 Scenic scenic = scenicDao.queryBy(sbsnOrder.getScenicid()); Integer onums = scenic.getOnums(); scenic.setOnums(onums-1); scenicDao.update(scenic); return update; } @Override @Transactional public int sysUpdate(SbsnOrder sbsnOrder) { Integer state = sbsnOrder.getState();//判断用的 Integer codeid = sbsnOrder.getCodeid(); if (codeid==11){ if (state==11){ return sbsnOrderDao.update(sbsnOrder); } sbsnOrder.setCodeid(ConstantUtil.OrderStatus.PENDING_PAYMENT); sbsnOrder.setState(ConstantUtil.OrderStatus.PENDING_PAYMENT); //添加状态 TSbsnAct tSbsnAct = tSbsnActDao.queryById(sbsnOrder.getOrderid()); tSbsnAct.setOrderid(sbsnOrder.getOrderid()); tSbsnAct.setCodeid(ConstantUtil.OrderStatus.PENDING_PAYMENT); tSbsnAct.setActcode(ConstantUtil.OrderStatus.PENDING_PAYMENT); //查询动作名称 tSbsnAct.setActname(tSbsnCode.queryName(sbsnOrder.getCodeid())); tSbsnAct.setBz("待付款"); tSbsnAct.setCztime(sbsnOrder.getOrdertime()); tSbsnAct.setCzrid(sbsnOrder.getUserid()); //调用更改 tSbsnActDao.update(tSbsnAct); //景区票数设置 Scenic scenic = scenicDao.queryBy(sbsnOrder.getScenicid()); if (state!=11){ Integer onums = scenic.getOnums(); scenic.setOnums(onums+1); } if (state==12){ scenic.setSnums(scenic.getSnums()-1); } //修改订票信息 scenicDao.update(scenic); //修改订单信息 return sbsnOrderDao.update(sbsnOrder); }else if (codeid==12){ if (state==12){ return sbsnOrderDao.update(sbsnOrder); } //已付款 return update(sbsnOrder); }else{ if (state==13){ return sbsnOrderDao.update(sbsnOrder); } //已取消 //设置参数 已付款 sbsnOrder.setCodeid(ConstantUtil.OrderStatus.CANCER); sbsnOrder.setState(ConstantUtil.OrderStatus.CANCER); //设置订单状态 TSbsnAct tSbsnAct = tSbsnActDao.queryById(sbsnOrder.getOrderid()); tSbsnAct.setCodeid(codeid); tSbsnAct.setActcode(codeid); //查询动作名称 tSbsnAct.setActname(tSbsnCode.queryName(tSbsnAct.getCodeid())); tSbsnAct.setBz("已取消订单"); tSbsnActDao.update(tSbsnAct); //更新景区门票 Scenic scenic = scenicDao.queryBy(sbsnOrder.getScenicid()); scenic.setSnums(scenic.getSnums()-1); scenicDao.update(scenic); return sbsnOrderDao.update(sbsnOrder); } } @Override public int deleteById(Integer orderid) { return sbsnOrderDao.deleteById(orderid); } }
毕业设计|SSM+VUE的旅游平台系统(三)https://developer.aliyun.com/article/1423955