| | |
| | | |
| | | import com.alibaba.fastjson2.util.UUIDUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | |
| | | @PostMapping("/addGoods") |
| | | @ApiOperation(value = "添加", tags = {"后台-商品管理"}) |
| | | public R addGoods(@RequestBody TGoods dto) { |
| | | dto.setSurplus(dto.getTotal()); |
| | | goodsService.save(dto); |
| | | return R.ok("添加成功"); |
| | | } |
| | |
| | | } |
| | | @GetMapping("/exchangeRecordParent") |
| | | @ApiOperation(value = "家长端-兑换记录", tags = {"家长端-兑换记录"}) |
| | | public R<List<TOrder>> exchangeRecordParent() { |
| | | public R<Page<TOrder>> exchangeRecordParent(Integer pageNumber,Integer pageSize) { |
| | | if (tokenService.getLoginUser1() == null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | return R.ok(orderService.lambdaQuery().eq(TOrder::getUserId, tokenService.getLoginUser1().getUserid()) |
| | | .orderByDesc(TOrder::getCreateTime).list()); |
| | | Page<TOrder> page = orderService.page(new Page<>(pageNumber, pageSize), new QueryWrapper<TOrder>().eq("userId", tokenService.getLoginUser1().getUserid()) |
| | | .orderByDesc("createTime")); |
| | | List<TOrder> records = page.getRecords(); |
| | | for (TOrder tOrder : records) { |
| | | TGoods byId = goodsService.getById(tOrder.getGoodsId()); |
| | | tOrder.setName(byId.getName()); |
| | | tOrder.setImg(byId.getCoverImg()); |
| | | StringBuilder stringBuilder = new StringBuilder(); |
| | | if (StringUtils.hasLength(byId.getTypeIds())){ |
| | | String[] split = byId.getTypeIds().split(","); |
| | | for (String s : split) { |
| | | TGoodsType byId1 = goodsTypeService.getById(s); |
| | | stringBuilder.append(byId1.getName()).append("|"); |
| | | } |
| | | // 去除最后一个字符 |
| | | stringBuilder.deleteCharAt(stringBuilder.length() - 1); |
| | | tOrder.setType(stringBuilder.toString()); |
| | | } |
| | | } |
| | | |
| | | return R.ok(page); |
| | | } |
| | | |
| | | /** |
| | |
| | | Recipient byId = recipientService.getById(id); |
| | | byId.setIsDefault(1); |
| | | recipientService.updateById(byId); |
| | | // 如果设置为默认地址 那么要将之前的默认地址取消掉 |
| | | List<Recipient> userId = recipientService.list(new QueryWrapper<Recipient>() |
| | | .eq("userId", tokenService.getLoginUser1().getUserid()) |
| | | .ne("id",byId.getId())); |
| | | for (Recipient recipient1 : userId) { |
| | | recipient1.setIsDefault(0); |
| | | recipientService.updateById(recipient1); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | /** |
| | |
| | | Recipient byId = recipientService.getById(id); |
| | | byId.setIsDefault(1); |
| | | recipientService.updateById(byId); |
| | | // 如果设置为默认地址 那么要将之前的默认地址取消掉 |
| | | List<Recipient> userId = recipientService.list(new QueryWrapper<Recipient>() |
| | | .eq("userId", tokenService.getLoginUser1().getUserid()) |
| | | .ne("id",byId.getId())); |
| | | for (Recipient recipient1 : userId) { |
| | | recipient1.setIsDefault(0); |
| | | recipientService.updateById(recipient1); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "学习端-新增收货地址/修改收货地址", tags = {"学习端-新增收货地址/修改收货地址"}) |
| | | public R<String> addressSave(@RequestBody Recipient recipient) { |
| | | recipient.setUserId(tokenService.getLoginUserStudy().getUserid()); |
| | | if (recipient.getIsDefault() == 1){ |
| | | // 如果设置为默认地址 那么要将之前的默认地址取消掉 |
| | | List<Recipient> userId = recipientService.list(new QueryWrapper<Recipient>() |
| | | .eq("userId", tokenService.getLoginUser1().getUserid())); |
| | | for (Recipient recipient1 : userId) { |
| | | recipient1.setIsDefault(0); |
| | | recipientService.updateById(recipient1); |
| | | } |
| | | } |
| | | recipientService.addressSaveOrUpdate(recipient); |
| | | return R.ok(); |
| | | } |
| | |
| | | @PostMapping("/addressSaveOrUpdateParent") |
| | | @ApiOperation(value = "家长端-新增收货地址/修改收货地址", tags = {"家长端-新增收货地址/修改收货地址"}) |
| | | public R<String> addressSaveOrUpdateParent(@RequestBody Recipient recipient) { |
| | | if (tokenService.getLoginUser1() == null){ |
| | | return R.tokenError("登录失效!"); |
| | | } |
| | | recipient.setUserId(tokenService.getLoginUser1().getUserid()); |
| | | if (recipient.getId() == null){ |
| | | if (recipient.getId() != null){ |
| | | if (recipient.getIsDefault() == 1){ |
| | | // 如果设置为默认地址 那么要将之前的默认地址取消掉 |
| | | List<Recipient> userId = recipientService.list(new QueryWrapper<Recipient>() |
| | | .eq("userId", tokenService.getLoginUser1().getUserid())); |
| | | for (Recipient recipient1 : userId) { |
| | | recipient1.setIsDefault(0); |
| | | recipientService.updateById(recipient1); |
| | | } |
| | | } |
| | | recipientService.updateById(recipient); |
| | | }else{ |
| | | if (recipient.getIsDefault() == 1){ |
| | | // 如果设置为默认地址 那么要将之前的默认地址取消掉 |
| | | List<Recipient> userId = recipientService.list(new QueryWrapper<Recipient>() |
| | | .eq("userId", tokenService.getLoginUser1().getUserid())); |
| | | for (Recipient recipient1 : userId) { |
| | | recipient1.setIsDefault(0); |
| | | recipientService.updateById(recipient1); |
| | | } |
| | | } |
| | | recipientService.save(recipient); |
| | | |
| | | } |
| | | return R.ok(); |
| | | } |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "地址信息id", name = "id", dataType = "String", required = true) |
| | | }) |
| | | public R<String> addressDeleteParent(@RequestParam String id) { |
| | | public R<String> addressDeleteParent(@RequestParam Integer id) { |
| | | return R.ok(recipientService.removeById(id) ? "删除成功!" : "删除失败!"); |
| | | } |
| | | |
| | |
| | | } |
| | | Recipient userId = recipientService.getById(recipientId); |
| | | TOrder byId = orderService.getById(orderId); |
| | | byId.setConsigneeName(userId.getAddress()); |
| | | byId.setConsigneeName(userId.getRecipient()); |
| | | byId.setConsigneePhone(userId.getRecipientPhone()); |
| | | byId.setConsigneeAddress(userId.getAddress()); |
| | | orderService.updateById(byId); |
| | |
| | | Recipient recipient = recipientService.lambdaQuery() |
| | | .eq(Recipient::getUserId, tokenService.getLoginUser1().getUserid()) |
| | | .eq(Recipient::getIsDefault, 1).one(); |
| | | if (recipient == null){ |
| | | // 随便取一条地址数据 |
| | | List<Recipient> list = recipientService.lambdaQuery() |
| | | .eq(Recipient::getUserId, tokenService.getLoginUser1().getUserid()) |
| | | .eq(Recipient::getIsDefault, 1).list(); |
| | | if (!list.isEmpty()){ |
| | | recipient = list.get(0); |
| | | } |
| | | } |
| | | GoodDetailVO goodDetailVO = goodsService.redeemNow(goodId, recipient); |
| | | LocalDateTime currentDateTime = LocalDateTime.now(); |
| | | // 格式化日期和时间信息 |
| | |
| | | * @param goodExchange 商品信息 |
| | | */ |
| | | @PostMapping("/goodExchange") |
| | | @ApiOperation(value = "学习端-商品兑换确认", tags = {"家长端-商品兑换确认"}) |
| | | @ApiOperation(value = "家长端-商品兑换确认", tags = {"家长端-商品兑换确认"}) |
| | | public R goodExchange(@RequestBody GoodExchangeDTO goodExchange) { |
| | | Recipient recipient = recipientService.getById(goodExchange.getRecipientId()); |
| | | Recipient recipient = recipientService.getById(Integer.valueOf(goodExchange.getRecipientId())); |
| | | return goodsService.goodExchange1(goodExchange, recipient); |
| | | } |
| | | @PostMapping("/goodExchangeStudy") |