| | |
| | | package com.ruoyi.order.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.api.feignClient.AppUserClient; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | | import com.ruoyi.chargingPile.api.domain.SiteMenu; |
| | | import com.ruoyi.chargingPile.api.dto.GetSiteListDTO; |
| | | import com.ruoyi.chargingPile.api.feignClient.PartnerClient; |
| | | import com.ruoyi.chargingPile.api.feignClient.SiteClient; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.domain.BasePojo; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.log.enums.OperatorType; |
| | | import com.ruoyi.common.security.annotation.Logical; |
| | | import com.ruoyi.common.security.annotation.RequiresPermissions; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.order.api.model.*; |
| | | import com.ruoyi.order.api.query.TOrderAppealQuery; |
| | | import com.ruoyi.order.api.vo.ChargingOrderVO; |
| | | import com.ruoyi.order.api.vo.TOrderAppealVO; |
| | | import com.ruoyi.order.dto.ManageFeedbackDto; |
| | | import com.ruoyi.order.dto.ManageOrderAppealQuery; |
| | | import com.ruoyi.order.service.*; |
| | | import com.ruoyi.other.api.feignClient.RoleSiteClient; |
| | | import com.ruoyi.other.api.feignClient.UserSiteClient; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import com.ruoyi.system.api.feignClient.SysUserRoleClient; |
| | | import com.ruoyi.system.api.model.SysUserRoleVo; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Arrays; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @Resource |
| | | private TVipOrderService vipOrderService; |
| | | |
| | | |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | |
| | | @Resource |
| | | private PartnerClient partnerService; |
| | | |
| | | @Resource |
| | | private UserSiteClient userSiteClient; |
| | | |
| | | @Resource |
| | | private RoleSiteClient roleSiteClient; |
| | | |
| | | @Resource |
| | | private SysUserRoleClient sysUserRoleClient; |
| | | @Resource |
| | | private PartnerClient partnerClient; |
| | | |
| | | @Autowired |
| | | public TOrderAppealController(TOrderAppealService orderAppealService, TokenService tokenService) { |
| | | this.orderAppealService = orderAppealService; |
| | | this.tokenService = tokenService; |
| | | } |
| | | @Resource |
| | | private SiteClient siteClient; |
| | | |
| | | |
| | | @RequiresPermissions(value = {"/appealOrder"}, logical = Logical.OR) |
| | | @ApiOperation(tags = {"后台-订单管理-订单申诉"},value = "列表") |
| | | @PostMapping(value = "/manage/pageList") |
| | | public R<Page<TOrderAppeal>> managePageList(@RequestBody ManageOrderAppealQuery manageOrderAppealQuery) { |
| | | |
| | | Integer pageCurr = manageOrderAppealQuery.getPageCurr(); |
| | | Integer pageSize = manageOrderAppealQuery.getPageSize(); |
| | | Page<TOrderAppeal> page = orderAppealService.lambdaQuery().eq(manageOrderAppealQuery.getStatus() != null, TOrderAppeal::getStatus, manageOrderAppealQuery.getStatus()) |
| | | .like(manageOrderAppealQuery.getCode() != null, TOrderAppeal::getCode, manageOrderAppealQuery.getCode()) |
| | | .like(manageOrderAppealQuery.getPhone() != null, TOrderAppeal::getPhone, manageOrderAppealQuery.getPhone()) |
| | | .eq(manageOrderAppealQuery.getOrderType() != null, TOrderAppeal::getOrderType, manageOrderAppealQuery.getOrderType()) |
| | | .in(TOrderAppeal::getOrderType, 1, 2).page(Page.of(manageOrderAppealQuery.getPageCurr(), manageOrderAppealQuery.getPageSize())); |
| | | |
| | | .in(TOrderAppeal::getOrderType, 1, 2) |
| | | .orderByDesc(TOrderAppeal::getCreateTime) |
| | | .page(Page.of(1, 99999999)); |
| | | SysUser sysUser = sysUserClient.getSysUser(tokenService.getLoginUser().getUserid()).getData(); |
| | | Integer roleType = sysUser.getRoleType(); |
| | | List<TOrderAppeal> res = new ArrayList<>(); |
| | | for (TOrderAppeal record : page.getRecords()) { |
| | | record.setUid(record.getId().toString()); |
| | | record.setUid(record.getId()+""); |
| | | if (record.getOrderType()!=1){ |
| | | res.add(record); |
| | | continue; |
| | | } |
| | | if(roleType!=2){ |
| | | res.add(record); |
| | | continue; |
| | | } |
| | | if (roleType == 2 && record.getOrderType()==1){ |
| | | List<Integer> siteIds = new ArrayList<>(); |
| | | if (sysUser.getUserId() != null){ |
| | | List<GetSiteListDTO> data = siteClient.getSiteListByUserId(sysUser.getUserId()).getData(); |
| | | for (GetSiteListDTO datum : data) { |
| | | siteIds.add(datum.getId()); |
| | | } |
| | | } |
| | | if (siteIds.isEmpty()){ |
| | | siteIds.add(-1); |
| | | }else{ |
| | | List<Integer> integers = new ArrayList<>(); |
| | | for (Integer siteId : siteIds) { |
| | | // 校验有没有这个站点的权限 |
| | | List<Boolean> t1= partnerClient.managePageListMenu(sysUser.getObjectId(),siteId).getData(); |
| | | |
| | | Boolean b = t1.get(2); |
| | | if (b){ |
| | | integers.add(siteId); |
| | | } |
| | | } |
| | | siteIds = integers; |
| | | } |
| | | if (siteIds.isEmpty()){ |
| | | siteIds.add(-1); |
| | | } |
| | | TChargingOrder byId = chargingOrderService.getById(record.getOrderId()); |
| | | if (byId!=null&&siteIds.contains(byId.getSiteId())){ |
| | | res.add(record); |
| | | // 校验有没有这个站点的权限 |
| | | List<Boolean> data = partnerClient.managePageListMenu(sysUser.getObjectId(), byId.getSiteId()).getData(); |
| | | record.setAuthInfo(data.get(0)); |
| | | record.setAuthHandle(data.get(1)); |
| | | } |
| | | if (byId==null){ |
| | | record.setAuthInfo(false); |
| | | record.setAuthHandle(false); |
| | | } |
| | | } |
| | | } |
| | | List<TOrderAppeal> res1 = testing4(res.size(), pageCurr, pageSize, res); |
| | | page.setCurrent(pageCurr); |
| | | page.setSize(pageSize); |
| | | page.setTotal(res.size()); |
| | | page.setRecords(res1); |
| | | return R.ok(page); |
| | | |
| | | |
| | | } |
| | | public static List<TOrderAppeal> testing4(long total, long current, long size, List<TOrderAppeal> str){ |
| | | List<TOrderAppeal> result = new ArrayList<>(); |
| | | //获取初始化分页结构 |
| | | com.ruoyi.order.util.Page<TOrderAppeal> page = new com.ruoyi.order.util.Page().getPage(total, size, current - 1); |
| | | //获取集合下标初始值 |
| | | long startIndex = page.getStartIndex(); |
| | | //获取集合下标结束值 |
| | | long endInddex = 0; |
| | | if(startIndex + page.getCurrent() >= total || size > total){ |
| | | endInddex = total; |
| | | }else { |
| | | endInddex = Math.min(startIndex + page.getSize(), total); |
| | | } |
| | | //如果输入的开始查询下标大于集合大小,则查询为空值 |
| | | if(startIndex > total){ |
| | | result = Collections.emptyList(); |
| | | }else{ |
| | | result = str.subList((int)startIndex,(int)endInddex); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | @RequiresPermissions(value = {"/appealOrder/del"}, logical = Logical.OR) |
| | | @ApiOperation(tags = {"后台-订单管理-订单申诉"},value = "删除") |
| | | @DeleteMapping (value = "/manage/delete") |
| | | public R<Page<TOrderAppeal>> delete(String ids) { |
| | | orderAppealService.removeBatchByIds(Arrays.asList(ids.split(","))); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @RequiresPermissions(value = {"/appealOrder/select", "/appealOrder/handle"}, logical = Logical.OR) |
| | | @ApiOperation(tags = {"后台-订单管理-订单申诉"},value = "后台-订单管理-订单申诉") |
| | | @PostMapping(value = "/manage/feedback") |
| | | public R manageFeedback(@RequestBody ManageFeedbackDto manageFeedbackDto) { |
| | | TOrderAppeal byId = orderAppealService.getById(manageFeedbackDto.getId()); |
| | | byId.setFeedback(manageFeedbackDto.getFeedback()); |
| | | byId.setStatus(2); |
| | | orderAppealService.updateById(byId); |
| | | return R.ok(); |
| | | } |
| | |
| | | @GetMapping(value = "/getDetailById") |
| | | @ApiOperation(tags = {"小程序-订单申诉"},value = "查询订单申诉详情") |
| | | public AjaxResult<TOrderAppealVO> getDetailById(String id) { |
| | | TOrderAppeal orderAppeal = orderAppealService.getById(id); |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | if(!orderAppeal.getAppUserId().equals(userId)){ |
| | | return AjaxResult.error("权限不足"); |
| | | } |
| | | return AjaxResult.ok(orderAppealService.getDetailById(id)); |
| | | } |
| | | |
| | | |
| | | |
| | | @Log(title = "【我的】申诉订单", businessType = BusinessType.INSERT,operatorType = OperatorType.MOBILE) |
| | | @ResponseBody |
| | | @PostMapping(value = "/addOrderAppeal") |
| | | @ApiOperation(value = "申诉订单", tags = {"小程序-充电记录(个人中心)"}) |