| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult; |
| | | import com.github.binarywang.wxpay.exception.WxPayException; |
| | | import com.ruoyi.common.constant.HttpStatus; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.utils.AliSmsUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.AddBuyerCompanyInfoDto; |
| | |
| | | |
| | | import javax.validation.Valid; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | |
| | | @Slf4j |
| | | @RestController |
| | |
| | | @Autowired |
| | | private TbUserService userService; |
| | | |
| | | @Autowired |
| | | private TbAgreementService agreementService; |
| | | |
| | | @ApiOperation(value = "获取我的订单", tags = {"订单模块"}) |
| | | |
| | | @ApiOperation(value = "获取我的订单", tags = {"订单模块"},response =MyPushCompanyListVo.class ) |
| | | @GetMapping("/getMyOrderList") |
| | | public R<Page<MyPushCompanyListVo>> getMyOrderList(MyOrderListQuery query) { |
| | | public R<HashMap<String, Object>> getMyOrderList(MyOrderListQuery query) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if(loginUser==null){ |
| | | return R.fail(HttpStatus.UNAUTHORIZED,"请重新登录"); |
| | | } |
| | | Long userId = loginUser.getUserId(); |
| | | Page<MyPushCompanyListVo> page = orderService.getMyOrderList(query, userId); |
| | | return R.ok(page); |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("data",page); |
| | | map = orderService.getMyOrderListNum(userId,map); |
| | | return R.ok(map); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | @ApiOperation(value = "立即支付前填写信息", tags = {"订单模块"}) |
| | | @PostMapping("/lastPayOrderData") |
| | | public R<?> lastPayOrderData(@RequestBody @Valid AddBuyerCompanyInfoDto dto) { |
| | | public synchronized R<WxPayMpOrderResult> lastPayOrderData(@RequestBody @Valid AddBuyerCompanyInfoDto dto) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if(loginUser==null){ |
| | | return R.fail(HttpStatus.UNAUTHORIZED,"请重新登录"); |
| | | } |
| | | Long userId = loginUser.getUserId(); |
| | | TbOrder tbOrder = orderService.getById(dto.getOrderId()); |
| | | |
| | |
| | | if (company == null || company.getStatus() == 2 || 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(); |
| | | TbBuyerCompanyInfo one = buyerCompanyInfoService.getOne(new LambdaQueryWrapper<TbBuyerCompanyInfo>().eq(TbBuyerCompanyInfo::getOrderId, dto.getOrderId())); |
| | | orderService.lastPayOrderData(tbOrder, dto, userId, company,one); |
| | | R<WxPayMpOrderResult> wxPayMpOrderResultR = payOrder(dto.getOrderId()); |
| | | return wxPayMpOrderResultR; |
| | | } |
| | | |
| | | |
| | |
| | | R.fail("订单id不能为空"); |
| | | } |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if(loginUser==null){ |
| | | return R.fail(HttpStatus.UNAUTHORIZED,"请重新登录"); |
| | | } |
| | | Long userId = loginUser.getUserId(); |
| | | TbOrder tbOrder = orderService.getById(orderId); |
| | | if (!tbOrder.getUserId().equals(userId.toString())) { |
| | |
| | | @PostMapping("/placeOrder") |
| | | public synchronized R<?> placeOrder(String companyId) { |
| | | if (StringUtils.isEmpty(companyId)) { |
| | | R.fail("id不能为空"); |
| | | return R.fail("id不能为空"); |
| | | } |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if(loginUser==null){ |
| | | return R.fail(HttpStatus.UNAUTHORIZED,"请重新登录"); |
| | | } |
| | | Long userId = loginUser.getUserId(); |
| | | // 查看现在是否可以单 判断这个公司是否上架 是否已经产生的了订单 |
| | | TbCompany company = companyService.getById(companyId); |
| | |
| | | if (company.getStatus() == 4) { |
| | | return R.fail("改公司已被预定"); |
| | | } |
| | | orderService.placeOrder(companyId, company, userId); |
| | | return R.ok(); |
| | | String orderId = orderService.placeOrder(companyId, company, userId); |
| | | messageService.addMessage("买家申请了交易", company.getUserId(), orderId,1); |
| | | |
| | | TbUser user = userService.getById(company.getUserId()); |
| | | AliSmsUtil.sendSuccessMessageSeller(user.getPhone()); |
| | | return R.ok(orderId); |
| | | } |
| | | |
| | | @ApiOperation(value = "下单预定-获取信息", tags = {"订单模块"}) |
| | | @GetMapping("/placeOrderInfo") |
| | | public R<?> placeOrderInfo(String companyId) { |
| | | if (StringUtils.isEmpty(companyId)) { |
| | | R.fail("id不能为空"); |
| | | } |
| | | TbCompany company = companyService.getById(companyId); |
| | | String information = company.getInformation(); |
| | | HashMap<String, String> map = new HashMap<>(); |
| | | map.put("information", information); |
| | | TbAgreement one = agreementService.getOne(new LambdaQueryWrapper<TbAgreement>().eq(TbAgreement::getType, 3)); |
| | | map.put("agreement", one.getContent()); |
| | | return R.ok(map); |
| | | } |
| | | |
| | | |
| | |
| | | R.fail("订单id不能为空"); |
| | | } |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if(loginUser==null){ |
| | | return R.fail(HttpStatus.UNAUTHORIZED,"请重新登录"); |
| | | } |
| | | Long userId = loginUser.getUserId(); |
| | | TbOrder order = orderService.getById(orderId); |
| | | if (order == null) { |
| | |
| | | } |
| | | // 订单完成 商品已售卖 |
| | | order.setStatus(6); |
| | | order.updateById(); |
| | | order.setFinishTime( new Date()); |
| | | |
| | | order.updateById(); |
| | | company.setStatus(3); |
| | | |
| | | // 分佣 |
| | | // 结算 |
| | | orderService.commission(order, company.getUserId()); |
| | | |
| | | // 卖家账户明细记录更新 |
| | | TbAccountDetail one = accountDetailService.getOne(new LambdaQueryWrapper<TbAccountDetail>().eq(TbAccountDetail::getOrderId, orderId).eq(TbAccountDetail::getCategory, 2)); |
| | | TbAccountDetail one = accountDetailService.getOne(new LambdaQueryWrapper<TbAccountDetail>().eq(TbAccountDetail::getUserId,company.getUserId()).eq(TbAccountDetail::getOrderId, orderId).eq(TbAccountDetail::getCategory, 2)); |
| | | if (one != null) { |
| | | one.setStatus(2); |
| | | one.updateById(); |
| | |
| | | @PostMapping("/buyerAddSchedule") |
| | | public synchronized R<?> buyerAddSchedule(@RequestBody @Valid AddScheduleDto dto) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if(loginUser==null){ |
| | | return R.fail(HttpStatus.UNAUTHORIZED,"请重新登录"); |
| | | } |
| | | Long userId = loginUser.getUserId(); |
| | | TbOrder order = orderService.getById(dto.getOrderId()); |
| | | if (order == null) { |
| | |
| | | scheduleService.buyerAddSchedule(dto, userId); |
| | | String userId1 = companyService.getById(order.getCompanyId()).getUserId(); |
| | | |
| | | messageService.addMessage("您的订单有新的回复", userId1, order.getId()); |
| | | messageService.addMessage("您的订单有新的回复", userId1, order.getId(),1); |
| | | return R.ok(); |
| | | |
| | | } |
| | |
| | | R.fail("订单id不能为空"); |
| | | } |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if(loginUser==null){ |
| | | return R.fail(HttpStatus.UNAUTHORIZED,"请重新登录"); |
| | | } |
| | | Long userId = loginUser.getUserId(); |
| | | TbOrder order = orderService.getById(orderId); |
| | | if (order == null) { |
| | |
| | | if (!order.getUserId().equals(userId.toString())) { |
| | | return R.fail("非法操作"); |
| | | } |
| | | if (order.getStatus() != 3) { |
| | | if (order.getStatus() != 3 && order.getStatus() != 2) { |
| | | return R.fail("该订单状态不能取消"); |
| | | } |
| | | TbCompany company = companyService.getById(order.getCompanyId()); |
| | | company.setStatus(1); |
| | | company.updateById(); |
| | | order.setStatus(-1); |
| | | order.setCancelType(2); |
| | | order.updateById(); |
| | | |
| | | messageService.addMessage("您发布的订单买家已取消", company.getUserId(), order.getId()); |
| | | messageService.addMessage("您发布的订单买家已取消", company.getUserId(), order.getId(),1); |
| | | return R.ok(); |
| | | |
| | | } |
| | |
| | | @PostMapping("/updateSchedule") |
| | | public R<?> updateSchedule(@RequestBody @Valid EditScheduleDto dto) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if(loginUser==null){ |
| | | return R.fail(HttpStatus.UNAUTHORIZED,"请重新登录"); |
| | | } |
| | | Long userId = loginUser.getUserId(); |
| | | TbSchedule schedule = scheduleService.getById(dto.getScheduleId()); |
| | | if (schedule == null) { |
| | |
| | | @DeleteMapping("/delSchedule/{scheduleId}") |
| | | public R<?> delSchedule(@PathVariable("scheduleId") String scheduleId) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if(loginUser==null){ |
| | | return R.fail(HttpStatus.UNAUTHORIZED,"请重新登录"); |
| | | } |
| | | Long userId = loginUser.getUserId(); |
| | | TbSchedule schedule = scheduleService.getById(scheduleId); |
| | | if (schedule == null) { |