From 1a4e7bbab3d15b36ebb4d7329ee31de62f092eb6 Mon Sep 17 00:00:00 2001 From: liujie <1793218484@qq.com> Date: 星期三, 28 五月 2025 16:40:06 +0800 Subject: [PATCH] 小程序接口 --- ruoyi-applet/src/main/java/com/ruoyi/web/controller/system/OrderController.java | 73 +++++++++++++++++++++++++++++++++++- 1 files changed, 70 insertions(+), 3 deletions(-) diff --git a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/system/OrderController.java b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/system/OrderController.java index 5f2aadb..66ea1b1 100644 --- a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/system/OrderController.java +++ b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/system/OrderController.java @@ -11,6 +11,7 @@ import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.framework.web.service.TokenService; +import com.ruoyi.system.dto.AddBuyerCompanyInfoDto; import com.ruoyi.system.dto.AddScheduleDto; import com.ruoyi.system.dto.EditScheduleDto; import com.ruoyi.system.model.*; @@ -47,6 +48,15 @@ @Autowired private TbScheduleService scheduleService; + @Autowired + private TbBuyerCompanyInfoService buyerCompanyInfoService; + + @Autowired + private TbMessageService messageService; + + @Autowired + private TbAccountDetailService accountDetailService; + @@ -58,6 +68,45 @@ Page<MyPushCompanyListVo> page = orderService.getMyOrderList(query,userId); return R.ok(page); } + + + /** + * 填写了 如果金额变动要修改订单金额 + * @param + * @return + */ + @ApiOperation(value = "立即支付前填写信息",tags = {"订单模块"}) + @PostMapping("/lastPayOrderData") + public R<?> lastPayOrderData(@RequestBody @Valid AddBuyerCompanyInfoDto dto) { + LoginUser loginUser = tokenService.getLoginUser(); + Long userId = loginUser.getUserId(); + TbOrder tbOrder = orderService.getById(dto.getOrderId()); + + if(dto.getNeedRename()==1){ + if(StringUtils.isEmpty(dto.getBackupsName())){ + return R.fail("请填写备选名称"); + } + } + + if(!tbOrder.getUserId().equals(userId.toString())){ + return R.fail("非法操作"); + } + if(tbOrder.getStatus()!=3){ + return R.fail("订单状态错误"); + } + TbCompany company = companyService.getById(tbOrder.getCompanyId()); + // 判断是否在支付前下架了 或者删除了 + if(company==null || company.getStatus()!=1 || company.getIsDelete()==1){ + return R.fail("该公司已下架或者删除"); + } + long count = buyerCompanyInfoService.count(new LambdaQueryWrapper<TbBuyerCompanyInfo>().eq(TbBuyerCompanyInfo::getOrderId, dto.getOrderId())); + if(count>0){ + return R.fail("请勿重复填写"); + } + orderService.lastPayOrderData(tbOrder,dto,userId,company); + return R.ok(); + } + @ApiOperation(value = "立即支付",tags = {"订单模块"}) @@ -77,7 +126,10 @@ if(company==null || company.getStatus()!=1 || company.getIsDelete()==1){ return R.fail("该公司已下架或者删除"); } - + long count = buyerCompanyInfoService.count(new LambdaQueryWrapper<TbBuyerCompanyInfo>().eq(TbBuyerCompanyInfo::getOrderId,orderId)); + if(count==0){ + return R.fail("请先填写信息"); + } WxPayMpOrderResult result = orderService.payOrder(tbOrder,userId); return R.ok(result); } @@ -97,8 +149,8 @@ if(company.getStatus()!=1){ return R.fail("公司未上架"); } - long count = orderService.count(new LambdaQueryWrapper<TbOrder>().eq(TbOrder::getCompanyId, companyId).ne(TbOrder::getStatus, -1)); - if (count > 0) { +// long count = orderService.count(new LambdaQueryWrapper<TbOrder>().eq(TbOrder::getCompanyId, companyId).ne(TbOrder::getStatus, -1)); + if (company.getStatus()==4) { return R.fail("改公司已被预定"); } orderService.placeOrder(companyId,company,userId); @@ -134,6 +186,13 @@ orderService.commission(order,company.getUserId()); + // 卖家账户明细记录更新 + TbAccountDetail one = accountDetailService.getOne(new LambdaQueryWrapper<TbAccountDetail>().eq(TbAccountDetail::getOrderId, orderId).eq(TbAccountDetail::getCategory, 2)); + if (one != null) { + one.setStatus(2); + one.updateById(); + } + company.updateById(); return R.ok(); @@ -156,6 +215,9 @@ return R.fail("该订单状态不能回复"); } scheduleService.buyerAddSchedule(dto,userId); + String userId1 = companyService.getById(order.getCompanyId()).getUserId(); + + messageService.addMessage("您的订单有新的回复", userId1,order.getId()); return R.ok(); } @@ -179,8 +241,13 @@ if(order.getStatus()!=3){ return R.fail("该订单状态不能取消"); } + TbCompany company = companyService.getById(order.getCompanyId()); + company.setStatus(1); + company.updateById(); order.setStatus(-1); order.updateById(); + + messageService.addMessage("您发布的订单买家已取消", company.getUserId(),order.getId()); return R.ok(); } -- Gitblit v1.7.1