| | |
| | | package com.ruoyi.order.controller; |
| | | |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.account.api.model.UserAddress; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.core.web.page.TableDataInfo; |
| | |
| | | import com.ruoyi.order.model.RefundPass; |
| | | import com.ruoyi.order.service.OrderService; |
| | | import com.ruoyi.order.service.RefundPassService; |
| | | import com.ruoyi.order.util.ExpressDeliveryUtil; |
| | | import com.ruoyi.order.util.vo.MapTrackKD100Vo; |
| | | import com.ruoyi.order.util.vo.QueryKD100ListVo; |
| | | import com.ruoyi.order.vo.*; |
| | | import com.ruoyi.other.api.domain.SystemConfig; |
| | | import com.ruoyi.other.api.feignClient.SystemConfigClient; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneOffset; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | @Resource |
| | | private OrderService orderService; |
| | | |
| | | @Resource |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | @Resource |
| | | private SystemConfigClient systemConfigClient; |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/applyRefundPass") |
| | |
| | | } |
| | | RefundPass one = refundPassService.getOne(new LambdaQueryWrapper<RefundPass>().eq(RefundPass::getOrderId, orderId) |
| | | .eq(RefundPass::getDelFlag, 0).last(" order by create_time desc limit 0,1")); |
| | | if(null == one){ |
| | | return R.fail("无效的售后数据"); |
| | | } |
| | | one.setIdStr(one.getId().toString()); |
| | | one.setAddressJson(order.getAddressJson()); |
| | | if(StringUtils.isNotEmpty(one.getExpressResult())){ |
| | | MapTrackKD100Vo mapTrackKD100Vo = JSON.parseObject(one.getExpressResult(), MapTrackKD100Vo.class); |
| | | List<QueryKD100ListVo> data = mapTrackKD100Vo.getData(); |
| | | one.setExpress(null != data && data.size() > 0 ? data.get(0).getContext() : ""); |
| | | } |
| | | return R.ok(one); |
| | | } |
| | | |
| | |
| | | if(Arrays.asList(2, 3).contains(refundPass.getStatus())){ |
| | | return R.fail("售后取消失败"); |
| | | } |
| | | // refundPass.setDelFlag(1); |
| | | refundPassService.removeById(id); |
| | | order.setOrderStatus(4); |
| | | refundPass.setDelFlag(1); |
| | | refundPassService.updateById(refundPass); |
| | | order.setOrderStatus(order.getOldOrderStatus()); |
| | | orderService.updateById(order); |
| | | return R.ok(); |
| | | } |
| | |
| | | } |
| | | refundPass.setStatus(5); |
| | | refundPass.setCode(pass.getCode()); |
| | | |
| | | //添加查询快递信息队列 |
| | | //一小时后定时查询快递信息 |
| | | SystemConfig systemConfig = systemConfigClient.getSystemConfig(3).getData(); |
| | | JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); |
| | | Integer waitTime = jsonObject.getInteger("waitTime"); |
| | | redisTemplate.opsForZSet().add("order_refund_express", refundPass.getId(), LocalDateTime.now().plusHours(waitTime).toEpochSecond(ZoneOffset.UTC)); |
| | | |
| | | JSONObject jsonObject1 = JSON.parseObject(pass.getCode()); |
| | | String com = jsonObject1.getString("com"); |
| | | String num = jsonObject1.getString("num"); |
| | | UserAddress userAddress = JSON.parseObject(order.getAddressJson(), UserAddress.class); |
| | | MapTrackKD100Vo mapTrackKD100Vo = ExpressDeliveryUtil.kd100MapTrack(com, num, userAddress.getProvince() + userAddress.getCity(), order.getDeliverProvince() + order.getDeliverCity()); |
| | | refundPass.setExpressResult(JSON.toJSONString(mapTrackKD100Vo)); |
| | | refundPassService.updateById(refundPass); |
| | | return R.ok(); |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取订单快递明细 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @GetMapping("/getOrderExpress/{id}") |
| | | @ApiOperation(value = "获取售后订单快递明细", tags = {"小程序-订单管理"}) |
| | | public R<MapTrackKD100Vo> getOrderExpress(@PathVariable("id") Long id){ |
| | | RefundPass refundPass = refundPassService.getById(id); |
| | | String expressResult = refundPass.getExpressResult(); |
| | | if(StringUtils.isNotEmpty(expressResult)){ |
| | | MapTrackKD100Vo mapTrackKD100Vo = JSON.parseObject(expressResult, MapTrackKD100Vo.class); |
| | | return R.ok(mapTrackKD100Vo); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |
| | | |