| | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.security.annotation.RequiresPermissions; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.order.api.entity.Evaluate; |
| | | import com.ruoyi.order.api.feignClient.EvaluateClient; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | |
| | | private MasterWorkerService masterWorkerService; |
| | | @Resource |
| | | private EvaluateClient evaluateClient; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | |
| | | /** |
| | | * 师傅列表分页查询 (添加订单-选择师傅列表) |
| | | */ |
| | | @RequiresPermissions("master_worker_list") |
| | | @ApiOperation(value = "师傅列表", tags = {"后台-师傅管理"}) |
| | | @GetMapping(value = "/selectServe") |
| | | @ApiImplicitParams({ |
| | |
| | | public R<IPage<MasterWorker>> selectServe(String workerName, String phone, String city, Integer state, |
| | | @RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (null == loginUser) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | | List<String> cityList = new ArrayList<>(); |
| | | if (loginUser.getIsFranchisee()) { |
| | | cityList = loginUser.getCityList(); |
| | | } |
| | | LambdaQueryChainWrapper<MasterWorker> wrapper = masterWorkerService.lambdaQuery(); |
| | | wrapper = StringUtils.isNotBlank(workerName) ? wrapper.like(MasterWorker::getRealName, workerName) : wrapper; |
| | | wrapper = StringUtils.isNotBlank(phone) ? wrapper.like(MasterWorker::getPhone, phone) : wrapper; |
| | |
| | | if (null != state) { |
| | | wrapper.eq(MasterWorker::getIsEnable, Constants.ONE); |
| | | } |
| | | wrapper.in(!cityList.isEmpty(),MasterWorker::getCityCode,cityList); |
| | | // for (int i = 0; i < cityList.size(); i++) { |
| | | // // 最后一跳城市不匹配or条件 |
| | | // String s = cityList.get(i); |
| | | // if (cityList.size() - 1 == i) { |
| | | // wrapper.like(MasterWorker::getCityCode, s); |
| | | // } else { |
| | | // wrapper.like(MasterWorker::getCityCode, s).or(); |
| | | // } |
| | | // } |
| | | return R.ok(wrapper.eq(MasterWorker::getIsDelete, Constants.ZERO) |
| | | .orderByDesc(MasterWorker::getCreateTime).page(Page.of(pageNum, pageSize))); |
| | | } |
| | |
| | | * |
| | | * @param masterWorker 师傅详细信息 |
| | | */ |
| | | @RequiresPermissions("worker_save") |
| | | @ApiOperation(value = "新增师傅信息", tags = {"后台-师傅管理-师傅列表管理"}) |
| | | @PostMapping(value = "/save") |
| | | public R<String> save(@RequestBody MasterWorker masterWorker) { |
| | |
| | | * |
| | | * @param ids 账号id拼接 |
| | | */ |
| | | @RequiresPermissions("worker_delete") |
| | | @ApiOperation(value = "删除师傅信息", tags = {"后台-师傅管理-师傅列表管理"}) |
| | | @GetMapping(value = "/batchDelete") |
| | | @ApiImplicitParams({ |
| | |
| | | * |
| | | * @param masterWorker 师傅信息 |
| | | */ |
| | | @RequiresPermissions("worker_update") |
| | | @ApiOperation(value = "修改师傅信息", tags = {"后台-师傅管理-师傅列表管理"}) |
| | | @PostMapping(value = "/update") |
| | | public R<String> update(@RequestBody @Validated MasterWorker masterWorker) { |
| | |
| | | * @param id 师傅信息id |
| | | * @param enable 启用/关闭 |
| | | */ |
| | | @RequiresPermissions("worker_enable") |
| | | @ApiOperation(value = "启用/关闭师傅账号", tags = {"后台-师傅管理-师傅列表管理"}) |
| | | @GetMapping(value = "/enable") |
| | | @ApiImplicitParams({ |
| | |
| | | * |
| | | * @param workerId 师傅id |
| | | */ |
| | | @RequiresPermissions("worker_detail") |
| | | @ApiOperation(value = "师傅详细信息", tags = {"后台-师傅管理-师傅列表管理"}) |
| | | @GetMapping(value = "/detail") |
| | | @ApiImplicitParams({ |
| | |
| | | if (!star.isEmpty()) { |
| | | // 总评分 / 评价数量 |
| | | double sum = star.stream().mapToDouble(Double::doubleValue).sum(); |
| | | workerDetail.setStarRating(new BigDecimal(sum / star.size())); |
| | | BigDecimal average = new BigDecimal(sum / star.size()).setScale(1, RoundingMode.HALF_UP); |
| | | workerDetail.setStarRating(average); |
| | | } else { |
| | | workerDetail.setStarRating(new BigDecimal("0.0")); |
| | | } |
| | | |
| | | return R.ok(workerDetail); |
| | | } |
| | | |