| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.goods.domain.*; |
| | | import com.ruoyi.goods.dto.GoodExchangeDTO; |
| | | import com.ruoyi.goods.dto.GoodQueryDTO; |
| | | import com.ruoyi.goods.dto.GoodsTypeQuery; |
| | | import com.ruoyi.goods.dto.*; |
| | | import com.ruoyi.goods.service.*; |
| | | import com.ruoyi.goods.vo.GoodDetailVO; |
| | | import com.ruoyi.goods.vo.TGoodsVO; |
| | | import com.ruoyi.goods.vo.TOrderVO; |
| | | import com.ruoyi.study.api.domain.TUser; |
| | | import com.ruoyi.study.api.feignClient.StudyClient; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | return R.ok(goodsService.redeemNow(goodId, recipient)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 商品兑换 |
| | | * |
| | |
| | | Recipient recipient = recipientService.getById(goodExchange.getRecipientId()); |
| | | return R.ok(goodsService.goodExchange(goodExchange, recipient)); |
| | | } |
| | | @Autowired |
| | | private StudyClient studyClient; |
| | | @PostMapping("/getOrderInfo/{id}") |
| | | @ApiOperation(value = "查看详情", tags = {"后台-订单管理"}) |
| | | public R<TOrderVO> getOrderInfo(@PathVariable("id")Integer id) { |
| | | TOrder byId = orderService.getById(id); |
| | | TGoods byId2 = goodsService.getById(byId.getGoodsId()); |
| | | TOrderVO tGoodsVO = new TOrderVO(); |
| | | tGoodsVO.setName(byId2.getName()); |
| | | BeanUtils.copyProperties(byId,tGoodsVO); |
| | | TUser byId1 = studyClient.getUserById(byId.getUserId()).getData(); |
| | | tGoodsVO.setUserName(byId1.getName()); |
| | | tGoodsVO.setPhone(byId1.getPhone()); |
| | | return R.ok(tGoodsVO); |
| | | } |
| | | @PostMapping("/confirm1") |
| | | @ApiOperation(value = "确认发货", tags = {"后台-订单管理"}) |
| | | public R getGoodsInfo1(@RequestBody OrderDTO dto) { |
| | | TOrder byId = orderService.getById(dto.getId()); |
| | | byId.setState(2); |
| | | byId.setExpress(dto.getExpress()); |
| | | byId.setExpressNumber(dto.getExpressNumber()); |
| | | byId.setExpressTime(new Date()); |
| | | orderService.updateById(byId); |
| | | return R.ok("修改成功"); |
| | | } |
| | | @PostMapping("/listAll1") |
| | | @ApiOperation(value = "列表查询", tags = {"后台-订单管理"}) |
| | | public R<PageInfo<TOrderVO>> listAll1(@RequestBody OrderQuery query) throws ParseException { |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | |
| | | if (query.getEndTime()!=null){ |
| | | Date parse = format.parse(query.getStartTime()); |
| | | Date parse1 = format.parse(query.getEndTime()); |
| | | query.setStartTime1(parse); |
| | | query.setEndTime1(parse1); |
| | | } |
| | | List<TOrderVO> list = orderService.listAll(query); |
| | | List<TOrderVO> list1 = new ArrayList<>(); |
| | | for (TOrderVO tOrderVO : list) { |
| | | TUser data = studyClient.getUserById(tOrderVO.getUserId()).getData(); |
| | | if (data!=null){ |
| | | tOrderVO.setUserName(data.getName()); |
| | | tOrderVO.setPhone(data.getPhone()); |
| | | } |
| | | if (!StringUtils.hasLength(query.getPhone()) && !StringUtils.hasLength(query.getUserName())){ |
| | | list1.add(tOrderVO); |
| | | continue; |
| | | } |
| | | // 如果筛选条件输入了电话或者姓名那么需要过滤掉不符合条件的数据 |
| | | if (StringUtils.hasLength(query.getPhone()) && StringUtils.hasLength(query.getUserName())){ |
| | | if (tOrderVO.getPhone().contains(query.getPhone()) && tOrderVO.getUserName().contains(query.getUserName())){ |
| | | list1.add(tOrderVO); |
| | | } |
| | | }else if (StringUtils.hasLength(query.getPhone())){ |
| | | if (tOrderVO.getPhone().contains(query.getPhone())){ |
| | | list1.add(tOrderVO); |
| | | } |
| | | }else if (StringUtils.hasLength(query.getUserName())){ |
| | | if (tOrderVO.getUserName().contains(query.getUserName())){ |
| | | list1.add(tOrderVO); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | PageInfo<TOrderVO> res = new PageInfo<>(query.getPageNumber(), query.getPageSize()); |
| | | res.setRecords(list1); |
| | | return R.ok(res); |
| | | } |
| | | } |
| | | |