MaTechnicianController.java 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. package com.ylx.web.controller.massage;
  2. import java.util.*;
  3. import java.util.concurrent.TimeUnit;
  4. import java.util.regex.Pattern;
  5. import javax.servlet.http.HttpServletRequest;
  6. import javax.servlet.http.HttpServletResponse;
  7. import cn.hutool.json.JSONObject;
  8. import com.alibaba.fastjson.JSON;
  9. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  10. import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
  11. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  12. import com.ylx.common.core.domain.R;
  13. import com.ylx.common.core.domain.model.LoginUser;
  14. import com.ylx.common.core.domain.model.aliyun.SMSVerificationCode;
  15. import com.ylx.common.core.domain.model.aliyun.SendSmsComponents;
  16. import com.ylx.common.core.domain.model.aliyun.SendSmsEnum;
  17. import com.ylx.common.utils.StringUtils;
  18. import com.ylx.massage.domain.MaProject;
  19. import com.ylx.massage.domain.dto.*;
  20. import com.ylx.massage.domain.dto.MaProjectSaveDto;
  21. import com.ylx.massage.domain.dto.MaProjectUpdateDto;
  22. import com.ylx.massage.domain.dto.MaTechnicianAuditQueryDTO;
  23. import com.ylx.massage.domain.dto.MaTechnicianAuditSubmitDTO;
  24. import com.ylx.massage.domain.dto.MaTechnicianMerchantAddDTO;
  25. import com.ylx.massage.domain.dto.MaTechnicianMerchantQueryDTO;
  26. import com.ylx.massage.domain.dto.MaTechnicianPendingAuditSubmitDTO;
  27. import com.ylx.massage.domain.vo.*;
  28. import com.ylx.massage.service.IMaProjectService;
  29. import com.ylx.project.domain.Project;
  30. import com.ylx.servicecategory.domain.ServiceCategory;
  31. import com.ylx.servicecategory.service.ServiceCategoryService;
  32. import io.swagger.annotations.Api;
  33. import io.swagger.annotations.ApiOperation;
  34. import org.springframework.data.redis.core.StringRedisTemplate;
  35. import org.springframework.security.access.prepost.PreAuthorize;
  36. import org.springframework.beans.factory.annotation.Autowired;
  37. import org.springframework.transaction.annotation.Transactional;
  38. import org.springframework.util.ObjectUtils;
  39. import org.springframework.web.bind.annotation.*;
  40. import com.ylx.common.annotation.Log;
  41. import com.ylx.common.core.controller.BaseController;
  42. import com.ylx.common.core.domain.AjaxResult;
  43. import com.ylx.common.enums.BusinessType;
  44. import com.ylx.massage.domain.MaTechnician;
  45. import com.ylx.massage.service.IMaTechnicianService;
  46. import com.ylx.common.utils.poi.ExcelUtil;
  47. import com.ylx.common.core.page.TableDataInfo;
  48. import org.springframework.web.multipart.MultipartFile;
  49. /**
  50. * 技师Controller
  51. *
  52. * @author ylx
  53. * @date 2024-03-22
  54. */
  55. @Api("技师管理")
  56. @RestController
  57. @RequestMapping("/technician/technician")
  58. public class MaTechnicianController extends BaseController {
  59. @Autowired
  60. private IMaTechnicianService maTechnicianService;
  61. @Autowired
  62. private StringRedisTemplate redisTemplate;
  63. @Autowired
  64. private SendSmsComponents sendSms;
  65. @Autowired
  66. private ServiceCategoryService serviceCategoryService;
  67. @Autowired
  68. private IMaProjectService maProjectService;
  69. public static final String PHONE_THREEUSERPARTCLIENT_CODE_KEY = "sys:threeUserPartClient:phone:";
  70. @GetMapping("/sendMsg")
  71. @ApiOperation(value = "短信发送", notes = "短信发送")
  72. public Result sendMsg(@RequestParam String phone, HttpServletRequest request) {
  73. if (org.apache.commons.lang3.StringUtils.isEmpty(phone)) {
  74. return Result.error("手机号不能为空");
  75. }
  76. Random rand = new Random();
  77. // randNumber 将被赋值为一个 MIN 和 MAX 范围内的随机数
  78. int randNumber = rand.nextInt(9999 - 1000 + 1) + 1000;
  79. // 保存验证码到redis
  80. redisTemplate.opsForValue()
  81. .set("userH5:order:phone:" + phone, String.valueOf(randNumber), 5L
  82. , TimeUnit.MINUTES);
  83. try {
  84. SMSVerificationCode smsVerificationCode = new SMSVerificationCode(String.valueOf(randNumber));
  85. String jsonString = JSON.toJSONString(smsVerificationCode);
  86. sendSms.sendSms(phone, SendSmsEnum.SMS_220650024, jsonString);
  87. return Result.ok("发送成功");
  88. } catch (Exception e) {
  89. e.printStackTrace();
  90. }
  91. return Result.ok("发送失败");
  92. }
  93. /**
  94. * 商户登录接口
  95. *
  96. * @param thirdPartyLoginsVo
  97. * @return
  98. */
  99. @ApiOperation(value = "商户登录", notes = "商户登录")
  100. @PostMapping(value = "/clientLogin")
  101. @Transactional
  102. public Result<JSONObject> login(@RequestBody ThirdPartyLoginsVo thirdPartyLoginsVo) throws Exception {
  103. // 获取登录用户信息
  104. Result<JSONObject> result = new Result<>();
  105. // 校验手机号是否为空
  106. if (StringUtils.isEmpty(thirdPartyLoginsVo.getPhone())) {
  107. return result.error500("请输入手机号");
  108. }
  109. // 校验用户是否存在且有效
  110. LambdaQueryWrapper<MaTechnician> queryWrapper = new LambdaQueryWrapper<>();
  111. queryWrapper.eq(MaTechnician::getTePhone, thirdPartyLoginsVo.getPhone());
  112. MaTechnician maTechnician = maTechnicianService.getBaseMapper().selectOne(queryWrapper);
  113. // 校验用户是否有效
  114. if (ObjectUtils.isEmpty(maTechnician)) {
  115. return result.error500("商户不存在,请先注册");
  116. }
  117. if (thirdPartyLoginsVo.getCodeSwitch()) {
  118. // 短信验证
  119. String msg = redisTemplate.opsForValue().get(PHONE_THREEUSERPARTCLIENT_CODE_KEY + thirdPartyLoginsVo.getPhone());
  120. if (StringUtils.isEmpty(msg)) {
  121. return Result.error("验证码已失效");
  122. }
  123. if (!thirdPartyLoginsVo.getPhoneMsg().equals(msg)) {
  124. return Result.error("短信验证码不正确");
  125. }
  126. } else {
  127. if (!thirdPartyLoginsVo.getPassWord().equals(maTechnician.getTePassword())) {
  128. return Result.error("密码错误");
  129. }
  130. }
  131. // 登录成功删除验证码
  132. redisTemplate.delete(PHONE_THREEUSERPARTCLIENT_CODE_KEY + thirdPartyLoginsVo.getPhone());
  133. result.success("登录成功");
  134. return result;
  135. }
  136. /**
  137. * 商户忘记密码接口
  138. */
  139. @PostMapping("/resetPassword")
  140. public Result<?> resetPassword(@RequestBody ThirdPartyLoginsVo thirdPartyLoginsVo) {
  141. // 核心正则表达式:
  142. // ^ 表示开头,$ 表示结尾
  143. // [a-zA-Z0-9] 表示只能是字母或数字
  144. // {8,20} 表示长度必须在8到20之间
  145. String regex = "^[a-zA-Z0-9]{8,20}$";
  146. boolean isMatch = Pattern.matches(regex, thirdPartyLoginsVo.getPhoneMsg());
  147. if (!isMatch) {
  148. // 根据需求返回指定的异常提示
  149. return Result.error("请输入8-20位数字/字母组合");
  150. }
  151. // 短信验证
  152. String msg = redisTemplate.opsForValue().get(PHONE_THREEUSERPARTCLIENT_CODE_KEY + thirdPartyLoginsVo.getPhone());
  153. if (StringUtils.isEmpty(msg)) {
  154. return Result.error("验证码已失效");
  155. }
  156. if (!thirdPartyLoginsVo.getPhoneMsg().equals(msg)) {
  157. return Result.error("短信验证码不正确");
  158. }
  159. // 重置密码逻辑
  160. LambdaUpdateWrapper<MaTechnician> updateWrapper = new LambdaUpdateWrapper<>();
  161. updateWrapper.eq(MaTechnician::getTePhone, thirdPartyLoginsVo.getPhone());
  162. updateWrapper.set(MaTechnician::getTePassword, thirdPartyLoginsVo.getPassWord());
  163. maTechnicianService.update(updateWrapper);
  164. redisTemplate.delete(PHONE_THREEUSERPARTCLIENT_CODE_KEY + thirdPartyLoginsVo.getPhone());
  165. return Result.ok("重置密码成功");
  166. }
  167. /**
  168. * 商户入驻申请接口
  169. */
  170. @PostMapping("/apply")
  171. public Result<?> apply(@RequestBody MaTechnicianAppAddVo req) {
  172. // 1. 基础参数校验
  173. if (StringUtils.isAnyBlank(req.getTeName(), req.getTePhone(), req.getTeAddress(), req.getAvatar())) {
  174. return Result.error("必填项不能为空");
  175. }
  176. //校验性别不能为空
  177. if(Objects.isNull(req.getTeSex())){
  178. return Result.error("性别不能为空");
  179. }
  180. // 2. 调用业务层处理入驻申请
  181. maTechnicianService.apply(req);
  182. return Result.ok("提交成功,进入审核流程");
  183. }
  184. /**
  185. * 申请技师文件
  186. * @param req
  187. */
  188. @PostMapping("/applyFile")
  189. public Result applyFile(MerchantApplyFileDto req){
  190. maTechnicianService.applyFile(req);
  191. return Result.ok("上传成功");
  192. }
  193. /**
  194. * 技师状态切换
  195. *
  196. * @param
  197. */
  198. @GetMapping("/switchToOffline")
  199. public Result switchToOffline(@RequestParam Long userId, @RequestParam Boolean forceConfirm){
  200. return maTechnicianService.switchToOffline(userId, forceConfirm);
  201. }
  202. /**
  203. * 查询商户信息接口
  204. */
  205. @GetMapping("/getTechnician")
  206. public Result<?> getTechnician(@RequestParam String phone) {
  207. LambdaQueryWrapper<MaTechnician> queryWrapper = new LambdaQueryWrapper<>();
  208. queryWrapper.eq(MaTechnician::getTePhone, phone);
  209. MaTechnician maTechnician = maTechnicianService.getBaseMapper().selectOne(queryWrapper);
  210. return Result.ok(maTechnician);
  211. }
  212. /**
  213. * 修改和上传商户信息接口
  214. */
  215. @PostMapping("/updateTechnician")
  216. public Result<?> updateTechnician(@RequestBody MaTechnicianAppAddVo req) {
  217. if (req.getAuditStatus() == 0 || req.getAuditStatus() == 3) {
  218. //修改基本信息
  219. updateMaTechnician(req);
  220. }
  221. return Result.ok("修改成功");
  222. }
  223. private void updateMaTechnician(MaTechnicianAppAddVo req) {
  224. LambdaUpdateWrapper<MaTechnician> updateWrapper = new LambdaUpdateWrapper<>();
  225. updateWrapper.eq(MaTechnician::getId, req.getId());
  226. updateWrapper.set(MaTechnician::getTePhone, req.getTePhone());
  227. updateWrapper.set(MaTechnician::getTeName, req.getTeName());
  228. updateWrapper.set(MaTechnician::getOpenService, req.getOpenService());
  229. updateWrapper.set(MaTechnician::getTeAddress, req.getTeAddress());
  230. updateWrapper.set(MaTechnician::getTeAge, req.getTeAge());
  231. updateWrapper.set(MaTechnician::getAvatar, req.getAvatar());
  232. maTechnicianService.update(updateWrapper);
  233. }
  234. /**
  235. * 查询技师列表
  236. */
  237. @PreAuthorize("@ss.hasPermi('technician:technician:list')")
  238. @GetMapping("/list")
  239. public TableDataInfo list(MaTechnician maTechnician) {
  240. startPage();
  241. List<MaTechnician> list = maTechnicianService.selectMaTechnicianList(maTechnician);
  242. return getDataTable(list);
  243. }
  244. /**
  245. * 导出技师列表
  246. */
  247. @PreAuthorize("@ss.hasPermi('technician:technician:export')")
  248. @Log(title = "技师", businessType = BusinessType.EXPORT)
  249. @PostMapping("/export")
  250. public void export(HttpServletResponse response, MaTechnician maTechnician) {
  251. List<MaTechnician> list = maTechnicianService.selectMaTechnicianList(maTechnician);
  252. ExcelUtil<MaTechnician> util = new ExcelUtil<MaTechnician>(MaTechnician.class);
  253. util.exportExcel(response, list, "技师数据");
  254. }
  255. /**
  256. * 获取技师详细信息
  257. */
  258. @PreAuthorize("@ss.hasPermi('technician:technician:query')")
  259. @GetMapping(value = "/{id}")
  260. public AjaxResult getInfo(@PathVariable("id") Long id) {
  261. return success(maTechnicianService.selectMaTechnicianById(id));
  262. }
  263. /**
  264. * 新增技师
  265. */
  266. @ApiOperation("技师入驻")
  267. @PreAuthorize("@ss.hasPermi('technician:technician:add')")
  268. @Log(title = "技师", businessType = BusinessType.INSERT)
  269. @PostMapping
  270. public AjaxResult add(@RequestBody MaTechnicianAppAddVo maTechnicianAppAddVo) {
  271. return toAjax(maTechnicianService.insertMaTechnician(maTechnicianAppAddVo));
  272. }
  273. /**
  274. * 后台新增商户
  275. *
  276. * @param dto 商户新增DTO
  277. * @return AjaxResult 结果
  278. */
  279. @ApiOperation("后台新增商户")
  280. @PreAuthorize("@ss.hasPermi('technician:technician:add')")
  281. @Log(title = "商户", businessType = BusinessType.INSERT)
  282. @PostMapping("/merchant")
  283. public AjaxResult addMerchant(@RequestBody MaTechnicianMerchantAddDTO dto) {
  284. try {
  285. LoginUser loginUser = getLoginUser();
  286. return toAjax(maTechnicianService.insertMerchant(dto, loginUser));
  287. } catch (Exception e) {
  288. e.printStackTrace();
  289. throw new RuntimeException(e);
  290. }
  291. }
  292. /**
  293. * 后台编辑商户
  294. *
  295. * @param id 商户ID
  296. * @param dto 商户编辑DTO
  297. * @return AjaxResult 结果
  298. */
  299. @ApiOperation("后台编辑商户")
  300. @PreAuthorize("@ss.hasPermi('technician:technician:edit')")
  301. @Log(title = "商户", businessType = BusinessType.UPDATE)
  302. @PutMapping("/merchant/{id}")
  303. public AjaxResult editMerchant(@PathVariable("id") Integer id, @RequestBody MaTechnicianMerchantAddDTO dto) {
  304. try {
  305. LoginUser loginUser = getLoginUser();
  306. return toAjax(maTechnicianService.updateMerchant(id, dto, loginUser));
  307. } catch (Exception e) {
  308. e.printStackTrace();
  309. throw new RuntimeException(e);
  310. }
  311. }
  312. /**
  313. * 后台上传商户合同文件
  314. *
  315. * @param id 商户ID
  316. * @param map 合同文件
  317. * @return R 上传结果
  318. */
  319. @ApiOperation("后台上传商户合同文件")
  320. @PreAuthorize("@ss.hasPermi('technician:technician:edit')")
  321. @Log(title = "商户合同", businessType = BusinessType.UPDATE)
  322. @PostMapping("/merchant/{id}/contract")
  323. public R uploadMerchantContract(@PathVariable("id") Integer id, @RequestBody Map<String,Object> map) {
  324. try {
  325. LoginUser loginUser = getLoginUser();
  326. return R.ok(maTechnicianService.uploadMerchantContract(id, map, loginUser));
  327. } catch (Exception e) {
  328. e.printStackTrace();
  329. throw new RuntimeException(e);
  330. }
  331. }
  332. /**
  333. * 查询商户入驻审核列表
  334. *
  335. * @param page 分页参数
  336. * @param dto 查询条件
  337. * @return Page 商户入驻审核分页列表
  338. */
  339. @ApiOperation("后台查询商户入驻审核列表")
  340. @PreAuthorize("@ss.hasPermi('technician:technician:list')")
  341. @GetMapping("/merchant/audit/list")
  342. public R<Page<MaTechnicianAuditListVO>> merchantAuditList(Page<MaTechnicianAuditListVO> page, MaTechnicianAuditQueryDTO dto) {
  343. try {
  344. return R.ok(maTechnicianService.selectMerchantAuditList(page, dto));
  345. } catch (Exception e) {
  346. e.printStackTrace();
  347. throw new RuntimeException(e);
  348. }
  349. }
  350. /**
  351. * 商户入驻审核
  352. *
  353. * @param id 商户ID
  354. * @param dto 审核提交参数
  355. * @return AjaxResult 结果
  356. */
  357. @ApiOperation("商户入驻审核")
  358. @PreAuthorize("@ss.hasPermi('technician:technician:edit')")
  359. @Log(title = "商户入驻审核", businessType = BusinessType.UPDATE)
  360. @PutMapping("/merchant/audit/{id}/submit")
  361. public AjaxResult submitMerchantAudit(@PathVariable("id") Integer id, @RequestBody MaTechnicianAuditSubmitDTO dto) {
  362. try {
  363. LoginUser loginUser = getLoginUser();
  364. return toAjax(maTechnicianService.submitMerchantAudit(id, dto, loginUser));
  365. } catch (Exception e) {
  366. e.printStackTrace();
  367. throw new RuntimeException(e);
  368. }
  369. }
  370. /**
  371. * 待审核页面审核通过商户
  372. *
  373. * @param id 商户ID
  374. * @param dto 待审核通过参数
  375. * @return AjaxResult 结果
  376. */
  377. @ApiOperation("待审核页面审核通过商户")
  378. @PreAuthorize("@ss.hasPermi('technician:technician:edit')")
  379. @Log(title = "商户待审核通过", businessType = BusinessType.UPDATE)
  380. @PutMapping("/merchant/audit/{id}/approve")
  381. public AjaxResult approvePendingMerchantAudit(@PathVariable("id") Integer id,
  382. @RequestBody MaTechnicianPendingAuditSubmitDTO dto) {
  383. try {
  384. LoginUser loginUser = getLoginUser();
  385. return toAjax(maTechnicianService.approvePendingMerchantAudit(id, dto, loginUser));
  386. } catch (Exception e) {
  387. e.printStackTrace();
  388. throw new RuntimeException(e);
  389. }
  390. }
  391. /**
  392. * 查询商户列表
  393. *
  394. * @param page 分页参数
  395. * @param dto 商户查询DTO
  396. * @return Page 商户分页列表
  397. */
  398. @ApiOperation("后台查询商户列表")
  399. @PreAuthorize("@ss.hasPermi('technician:technician:list')")
  400. @GetMapping("/merchant/list")
  401. public R<Page<MaTechnicianMerchantListVO>> merchantList(Page<MaTechnicianMerchantListVO> page, MaTechnicianMerchantQueryDTO dto) {
  402. try {
  403. return R.ok(maTechnicianService.selectMerchantList(page, dto));
  404. } catch (Exception e) {
  405. e.printStackTrace();
  406. throw new RuntimeException(e);
  407. }
  408. }
  409. /**
  410. * 查询商户详情
  411. *
  412. * @param id 商户ID
  413. * @return R<MaTechnicianMerchantDetailVO> 商户详情
  414. */
  415. @ApiOperation("后台查询商户详情")
  416. @PreAuthorize("@ss.hasPermi('technician:technician:query')")
  417. @GetMapping("/merchant/detail/{id}")
  418. public R<MaTechnicianMerchantDetailVO> merchantDetail(@PathVariable("id") Long id) {
  419. try {
  420. return R.ok(maTechnicianService.selectMerchantDetail(id));
  421. } catch (Exception e) {
  422. e.printStackTrace();
  423. throw new RuntimeException(e);
  424. }
  425. }
  426. /**
  427. * 查看商户证照
  428. *
  429. * @param id 商户ID
  430. * @return R<MaTechnicianCertificateVO> 商户证照
  431. */
  432. @ApiOperation("后台查看商户证照")
  433. @PreAuthorize("@ss.hasPermi('technician:technician:query')")
  434. @GetMapping("/merchant/{id}/certificate")
  435. public R<MaTechnicianCertificateVO> merchantCertificate(@PathVariable("id") Integer id) {
  436. try {
  437. return R.ok(maTechnicianService.selectMerchantCertificate(id));
  438. } catch (Exception e) {
  439. e.printStackTrace();
  440. throw new RuntimeException(e);
  441. }
  442. }
  443. /**
  444. * 修改技师
  445. */
  446. @PreAuthorize("@ss.hasPermi('technician:technician:edit')")
  447. @Log(title = "技师", businessType = BusinessType.UPDATE)
  448. @PutMapping
  449. public AjaxResult edit(@RequestBody MaTechnicianAppAddVo maTechnicianAppAddVo) {
  450. return toAjax(maTechnicianService.updateMaTechnician(maTechnicianAppAddVo));
  451. }
  452. /**
  453. * 删除技师
  454. */
  455. @PreAuthorize("@ss.hasPermi('technician:technician:remove')")
  456. @Log(title = "技师", businessType = BusinessType.DELETE)
  457. @DeleteMapping("/{ids}")
  458. public AjaxResult remove(@PathVariable Long[] ids) {
  459. return toAjax(maTechnicianService.deleteMaTechnicianByIds(ids));
  460. }
  461. /**
  462. * 1. 获取服务类目列表 (对应图1、图3)
  463. */
  464. @GetMapping("/getServiceCategoryList")
  465. public AjaxResult getServiceCategoryList() {
  466. List<ServiceCategory> list = serviceCategoryService.listH5ServiceCategory();
  467. return AjaxResult.success(list);
  468. }
  469. /**
  470. * 1. 获取技能列表 (对应图1、图3)
  471. * 支持 Tab 切换:all(全部), active(已开通), applying(申请中), rejected(驳回)
  472. */
  473. @PostMapping("/getSkillList")
  474. public TableDataInfo getSkillList(@RequestBody MaProjectGetVo req) {
  475. startPage();
  476. List<MaProject> list = maTechnicianService.selectMaTechnicianListBy(req.getUserId(), req.getAuditStatus());
  477. if (ObjectUtils.isEmpty(list)) {
  478. List<Project> projectslist = maTechnicianService.selectTechnicianListBy(req.getTypeId());
  479. return getDataTable(projectslist);
  480. } else {
  481. return getDataTable(list);
  482. }
  483. }
  484. /**
  485. * 查询未开通的服务项目列表
  486. *
  487. * @param req
  488. * @return
  489. */
  490. @PostMapping("/getNotApplyList")
  491. public Result<?> getNotApplyList(@RequestBody MaProjectGetVo req) {
  492. return Result.ok(maTechnicianService.getNotApplyList(req.getUserId(), req.getTypeId()));
  493. }
  494. /**
  495. * 申请开通新服务
  496. */
  497. @PostMapping("/applyForService")
  498. public AjaxResult applyForService(@RequestBody MaProjectSaveDto dto) {
  499. return toAjax(maTechnicianService.applyForService(dto));
  500. }
  501. /**
  502. * 重新申请开通新服务
  503. *
  504. * @param req
  505. * @return
  506. */
  507. @PostMapping("/updateApply")
  508. public Result<?> updateApply(@RequestBody MaProjectUpdateDto req) {
  509. if (StringUtils.isNotEmpty(req.getProjectId()) && StringUtils.isNotEmpty(req.getApplyReason())) {
  510. LambdaUpdateWrapper<MaProject> updateWrapper = new LambdaUpdateWrapper<>();
  511. updateWrapper.eq(MaProject::getId, req.getProjectId());
  512. updateWrapper.set(MaProject::getApplyReason, req.getApplyReason());
  513. updateWrapper.set(MaProject::getAuditStatus, 0);
  514. maProjectService.update(updateWrapper);
  515. }
  516. return Result.ok("重新申请成功,提交到审核阶段");
  517. }
  518. /**
  519. * 申请下架,删除服务项目,编辑售价价格
  520. *
  521. * @param req
  522. * @return
  523. */
  524. @PostMapping("/updateMaProject")
  525. public Result<?> updateMaProject(@RequestBody MaProjectUpdateDto req) {
  526. String message = "";
  527. if (StringUtils.isNotEmpty(req.getProjectId())) {
  528. if (req.getIsDelete()) {
  529. LambdaUpdateWrapper<MaProject> updateWrapper = new LambdaUpdateWrapper<>();
  530. updateWrapper.eq(MaProject::getId, req.getProjectId());
  531. updateWrapper.set(MaProject::getIsDelete, 1);
  532. maProjectService.update(updateWrapper);
  533. message = "删除成功";
  534. }
  535. if (req.getIsPass()) {
  536. LambdaUpdateWrapper<MaProject> updateWrapper = new LambdaUpdateWrapper<>();
  537. updateWrapper.eq(MaProject::getId, req.getProjectId());
  538. updateWrapper.set(MaProject::getProjectIsEnable, 1);
  539. maProjectService.update(updateWrapper);
  540. message = "申请下架成功";
  541. }
  542. if (req.getProjectCurrentPrice() != null) {
  543. LambdaUpdateWrapper<MaProject> updateWrapper = new LambdaUpdateWrapper<>();
  544. updateWrapper.eq(MaProject::getId, req.getProjectId());
  545. updateWrapper.set(MaProject::getProjectCurrentPrice, req.getProjectCurrentPrice());
  546. maProjectService.update(updateWrapper);
  547. message = "修改价格完成";
  548. }
  549. }
  550. return Result.ok(message);
  551. }
  552. @GetMapping("/getTechnicianList")
  553. public Result<?> getTechnicianList(@RequestParam(value = "userId") Long userId) {
  554. return Result.ok(maTechnicianService.getTechnicianList(userId));
  555. }
  556. }