五、核心代码
5.1 查询商品
@RequestMapping(value = "/getByPage", method = RequestMethod.GET) @ApiOperation(value = "查询商品") public Result<IPage<Commodity>> getByPage(@ModelAttribute Commodity commodity ,@ModelAttribute PageVo page){ QueryWrapper<Commodity> qw = new QueryWrapper<>(); User currUser = securityUtil.getCurrUser(); qw.eq("user_id",currUser.getId()); if(!ZwzNullUtils.isNull(commodity.getTitle())) { qw.like("title",commodity.getTitle()); } if(!ZwzNullUtils.isNull(commodity.getSpecs())) { qw.like("specs",commodity.getSpecs()); } IPage<Commodity> data = iCommodityService.page(PageUtil.initMpPage(page),qw); return new ResultUtil<IPage<Commodity>>().setData(data); }
5.2 查询快递公司
@RequestMapping(value = "/getByPage", method = RequestMethod.GET) @ApiOperation(value = "查询快递公司") public Result<IPage<CourierCompany>> getByPage(@ModelAttribute CourierCompany courierCompany ,@ModelAttribute PageVo page){ QueryWrapper<CourierCompany> qw = new QueryWrapper<>(); if(!ZwzNullUtils.isNull(courierCompany.getTitle())) { qw.like("title",courierCompany.getTitle()); } if(!ZwzNullUtils.isNull(courierCompany.getCompanyName())) { qw.like("company_name",courierCompany.getCompanyName()); } IPage<CourierCompany> data = iCourierCompanyService.page(PageUtil.initMpPage(page),qw); return new ResultUtil<IPage<CourierCompany>>().setData(data); }
5.3 查询物流订单
@RequestMapping(value = "/getByPage", method = RequestMethod.GET) @ApiOperation(value = "查询物流单") public Result<IPage<LogisticsOrder>> getByPage(@ModelAttribute LogisticsOrder logisticsOrder ,@ModelAttribute PageVo page){ QueryWrapper<LogisticsOrder> qw = new QueryWrapper<>(); User currUser = securityUtil.getCurrUser(); QueryWrapper<User> userQw = new QueryWrapper<>(); userQw.eq("id",currUser.getId()); userQw.inSql("id","SELECT user_id FROM a_user_role WHERE del_flag = 0 AND role_id = '1536606659751841799'"); if(iUserService.count(userQw) < 1L) { // 判断物流 QueryWrapper<User> userQw2 = new QueryWrapper<>(); userQw2.eq("id",currUser.getId()); userQw2.inSql("id","SELECT user_id FROM a_user_role WHERE del_flag = 0 AND role_id = '1703243045803266048'"); if(iUserService.count(userQw2) > 0L) { // 物流 qw.eq("company_id",currUser.getCompanyId()); } else { // 商家 qw.eq("user_id",currUser.getId()); } } if(!ZwzNullUtils.isNull(logisticsOrder.getCollectUser())) { qw.like("collect_user",logisticsOrder.getCollectUser()); } if(!ZwzNullUtils.isNull(logisticsOrder.getCollectAddress())) { qw.like("collect_address",logisticsOrder.getCollectAddress()); } if(!ZwzNullUtils.isNull(logisticsOrder.getStatus())) { qw.eq("status",logisticsOrder.getStatus()); } IPage<LogisticsOrder> data = iLogisticsOrderService.page(PageUtil.initMpPage(page),qw); return new ResultUtil<IPage<LogisticsOrder>>().setData(data); }
5.4 新增物流订单
@RequestMapping(value = "/insert", method = RequestMethod.POST) @ApiOperation(value = "新增物流单") public Result<LogisticsOrder> insert(LogisticsOrder logisticsOrder){ User currUser = securityUtil.getCurrUser(); logisticsOrder.setUserId(currUser.getId()); logisticsOrder.setUserName(currUser.getNickname()); logisticsOrder.setDate(DateUtil.today()); logisticsOrder.setStatus("待发货"); logisticsOrder.setTime1(""); logisticsOrder.setTime2(""); logisticsOrder.setTime3(""); String itemString = logisticsOrder.getItemString(); List<LogisticsOrderItem> itemList = JSON.parseArray(itemString, LogisticsOrderItem.class); for (LogisticsOrderItem item : itemList) { Commodity commodity = iCommodityService.getById(item.getCommodityId()); if(commodity == null) { return ResultUtil.error("商品不存在"); } item.setCommodityName(commodity.getTitle() + " " + commodity.getSpecs()); } iLogisticsOrderService.saveOrUpdate(logisticsOrder); for (LogisticsOrderItem item : itemList) { item.setOrderId(logisticsOrder.getId()); iLogisticsOrderItemService.saveOrUpdate(item); } return new ResultUtil<LogisticsOrder>().setData(logisticsOrder); }
5.5 快递收揽派签
@RequestMapping(value = "/changeStatus1", method = RequestMethod.POST) @ApiOperation(value = "揽件") public Result<Object> changeStatus1(@RequestParam String id){ LogisticsOrder order = iLogisticsOrderService.getById(id); if(order == null) { return ResultUtil.error("物流单不存在"); } order.setStatus("已揽件"); order.setTime1(DateUtil.now()); iLogisticsOrderService.saveOrUpdate(order); return ResultUtil.success(); } @RequestMapping(value = "/changeStatus2", method = RequestMethod.POST) @ApiOperation(value = "派送") public Result<Object> changeStatus2(@RequestParam String id){ LogisticsOrder order = iLogisticsOrderService.getById(id); if(order == null) { return ResultUtil.error("物流单不存在"); } order.setStatus("已派送"); order.setTime2(DateUtil.now()); iLogisticsOrderService.saveOrUpdate(order); return ResultUtil.success(); } @RequestMapping(value = "/changeStatus3", method = RequestMethod.POST) @ApiOperation(value = "签收") public Result<Object> changeStatus3(@RequestParam String id){ LogisticsOrder order = iLogisticsOrderService.getById(id); if(order == null) { return ResultUtil.error("物流单不存在"); } order.setStatus("已签收"); order.setTime3(DateUtil.now()); iLogisticsOrderService.saveOrUpdate(order); return ResultUtil.success(); } @RequestMapping(value = "/fa", method = RequestMethod.POST) @ApiOperation(value = "发货") public Result<Object> fa(@RequestParam String id,@RequestParam String com){ LogisticsOrder order = iLogisticsOrderService.getById(id); if(order == null) { return ResultUtil.error("物流单不存在"); } if(!ZwzNullUtils.isNull(com)) { CourierCompany cc = iCourierCompanyService.getById(com); if(cc == null) { return ResultUtil.error("快递公司不存在"); } order.setCompanyId(cc.getId()); order.setCompanyName(cc.getTitle()); } else { QueryWrapper<CourierCompany> ccQw = new QueryWrapper<>(); ccQw.orderByAsc("order_number"); ccQw.last("limit 1"); CourierCompany cc = iCourierCompanyService.getOne(ccQw); if(cc == null) { return ResultUtil.error("系统没有注册快递公司"); } order.setCompanyId(cc.getId()); order.setCompanyName(cc.getTitle()); } order.setStatus("待揽收"); iLogisticsOrderService.saveOrUpdate(order); return ResultUtil.success(); }
六、免责说明
- 本项目仅供个人学习使用,商用授权请联系博主,否则后果自负。
- 博主拥有本软件构建后的应用系统全部内容所有权及独立的知识产权,拥有最终解释权。
- 如有问题,欢迎在仓库 Issue 留言,看到后会第一时间回复,相关意见会酌情考虑,但没有一定被采纳的承诺或保证。
下载本系统代码或使用本系统的用户,必须同意以下内容,否则请勿下载!
- 出于自愿而使用/开发本软件,了解使用本软件的风险,且同意自己承担使用本软件的风险。
- 利用本软件构建的网站的任何信息内容以及导致的任何版权纠纷和法律争议及后果和博主无关,博主对此不承担任何责任。
- 在任何情况下,对于因使用或无法使用本软件而导致的任何难以合理预估的损失(包括但不仅限于商业利润损失、业务中断与业务信息丢失),博主概不承担任何责任。
- 必须了解使用本软件的风险,博主不承诺提供一对一的技术支持、使用担保,也不承担任何因本软件而产生的难以预料的问题的相关责任。