TOrderController.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. package com.ylx.web.controller.massage;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  5. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  6. import com.ylx.common.annotation.Log;
  7. import com.ylx.common.core.controller.BaseController;
  8. import com.ylx.common.core.domain.R;
  9. import com.ylx.common.core.domain.model.LoginUser;
  10. import com.ylx.common.enums.BusinessType;
  11. import com.ylx.common.exception.ServiceException;
  12. import com.ylx.common.utils.StringUtils;
  13. import com.ylx.common.utils.poi.ExcelUtil;
  14. import com.ylx.massage.domain.TJs;
  15. import com.ylx.massage.domain.TOrder;
  16. import com.ylx.massage.domain.vo.OrderAllocationResultVo;
  17. import com.ylx.massage.domain.vo.OrderVerificationVo;
  18. import com.ylx.massage.domain.vo.TechnicianAvailabilityVo;
  19. import com.ylx.massage.enums.Enumproject;
  20. import com.ylx.massage.enums.OrderStatusEnum;
  21. import com.ylx.massage.enums.OrderStatusEnumVo;
  22. import com.ylx.massage.domain.OrderAllocationLog;
  23. import com.ylx.massage.service.TJsService;
  24. import com.ylx.massage.service.TOrderService;
  25. import com.ylx.massage.service.OrderAllocationLogService;
  26. import io.swagger.annotations.Api;
  27. import io.swagger.annotations.ApiOperation;
  28. import io.swagger.annotations.ApiParam;
  29. import lombok.extern.slf4j.Slf4j;
  30. import org.springframework.beans.BeanUtils;
  31. import org.springframework.web.bind.annotation.*;
  32. import javax.annotation.Resource;
  33. import javax.servlet.http.HttpServletResponse;
  34. import java.math.BigDecimal;
  35. import java.time.LocalDateTime;
  36. import java.util.List;
  37. import java.util.Optional;
  38. import java.util.stream.Collectors;
  39. /**
  40. * 订单表 前端控制器
  41. */
  42. @RestController
  43. @Slf4j
  44. @Api(tags = {"订单管理"})
  45. @RequestMapping("api/order/v1")
  46. public class TOrderController extends BaseController {
  47. @Resource
  48. private TOrderService orderService;
  49. @Resource
  50. private OrderAllocationLogService allocationLogService;
  51. @Resource
  52. private TJsService jsService;
  53. /**
  54. * 下单
  55. *
  56. * @param order
  57. * @return R<TOrder>
  58. */
  59. @ApiOperation("下单")
  60. @RequestMapping(value = "wx/add", method = RequestMethod.POST)
  61. public R<TOrder> add(@RequestBody TOrder order) {
  62. try {
  63. return R.ok(orderService.addOrder(order));
  64. } catch (ServiceException s) {
  65. log.error(s.toString());
  66. return R.fail(s.getMessage());
  67. } catch (Exception e) {
  68. e.printStackTrace();
  69. return R.fail("系统异常");
  70. }
  71. }
  72. /**
  73. * 优惠卷核销
  74. *
  75. * @param order
  76. * @return
  77. */
  78. @Log(title = "优惠卷核销", businessType = BusinessType.UPDATE)
  79. @ApiOperation("优惠卷核销")
  80. @RequestMapping(value = "wx/verification", method = RequestMethod.POST)
  81. public R<OrderVerificationVo> verification(@RequestBody TOrder order) {
  82. try {
  83. return R.ok(orderService.verification(order));
  84. } catch (ServiceException s) {
  85. log.error(s.toString());
  86. return R.fail(s.getMessage());
  87. } catch (Exception e) {
  88. StackTraceElement stackTraceElement = e.getStackTrace()[0];
  89. log.error("系统出错,错误信息:" + e + " at " + stackTraceElement.getClassName() + "." + stackTraceElement.getMethodName() + ":" + stackTraceElement.getLineNumber());
  90. return R.fail("系统异常");
  91. }
  92. }
  93. /**
  94. * 转单
  95. *
  96. * @param order
  97. * @return R<TOrder>
  98. */
  99. @Log(title = "转单", businessType = BusinessType.INSERT)
  100. @ApiOperation("转单")
  101. @RequestMapping(value = "wx/transferOrder", method = RequestMethod.POST)
  102. public R<TOrder> transferOrder(@RequestBody TOrder order) {
  103. try {
  104. return R.ok(orderService.transferOrder(order));
  105. } catch (ServiceException s) {
  106. log.error(s.toString());
  107. return R.fail(s.getMessage());
  108. } catch (Exception e) {
  109. StackTraceElement stackTraceElement = e.getStackTrace()[0];
  110. log.error("系统出错,错误信息:" + e + " at " + stackTraceElement.getClassName() + "." + stackTraceElement.getMethodName() + ":" + stackTraceElement.getLineNumber());
  111. return R.fail("系统异常");
  112. }
  113. }
  114. /**
  115. * 支付订单
  116. *
  117. * @param order
  118. * @return R
  119. */
  120. @ApiOperation("支付订单")
  121. @Log(title = "支付订单", businessType = BusinessType.UPDATE)
  122. @RequestMapping(value = "wx/pay", method = RequestMethod.POST)
  123. public R pay(@RequestBody TOrder order) {
  124. try {
  125. log.info("支付订单接口前端传递的参数:{}", JSON.toJSONString(order));
  126. return orderService.payOrder(order);
  127. } catch (ServiceException s) {
  128. log.error(s.toString());
  129. return R.fail(s.getMessage());
  130. } catch (Exception e) {
  131. StackTraceElement stackTraceElement = e.getStackTrace()[0];
  132. log.error("系统出错,错误信息:" + e + " at " + stackTraceElement.getClassName() + "." + stackTraceElement.getMethodName() + ":" + stackTraceElement.getLineNumber());
  133. return R.fail("系统异常");
  134. }
  135. }
  136. /**
  137. * 退单申请
  138. *
  139. * 业务流程:
  140. * 1. 用户在订单详情页点击"取消订单"按钮
  141. * 2. 填写退单原因
  142. * 3. 提交申请
  143. * 4. 系统创建退单申请记录,状态为待审核
  144. * 5. 等待客服审核
  145. *
  146. *
  147. * @param order 订单对象
  148. * @return R
  149. */
  150. //@Log(title = "取消订单申请", businessType = BusinessType.UPDATE)
  151. @ApiOperation("退单申请")
  152. @RequestMapping(value = "wx/applyCancle", method = RequestMethod.POST)
  153. public R applyCancle(@RequestBody JSONObject jsonObject) {
  154. try {
  155. log.info("收到退单申请请求,订单ID:{},退单原因:{}", jsonObject.getString("cId"), jsonObject.getString("cancelReason"));
  156. // 调用服务层处理退单申请
  157. orderService.applyCancle(jsonObject.getString("cId"), jsonObject.getString("cancelReason"));
  158. // 返回成功提示
  159. return R.ok("您的申请已提交,客服审核中,请注意接听客服电话:19936963696");
  160. } catch (ServiceException s) {
  161. log.error("退单申请失败:{}", s.getMessage());
  162. return R.fail(s.getMessage());
  163. } catch (Exception e) {
  164. log.error("退单申请系统异常", e);
  165. return R.fail("系统异常,请稍后重试");
  166. }
  167. }
  168. /**
  169. * 取消退单申请(用户操作的接口)
  170. *
  171. * 业务流程:
  172. * 1. 用户在订单详情页点击"取消退单申请"按钮
  173. * 2. 系统校验订单状态和退单申请状态
  174. * 3. 取消退单申请,将申请状态标记为已取消
  175. * 4. 恢复订单到申请前的原始状态
  176. * 5. 返回成功提示
  177. *
  178. * @param order 订单对象,需要包含cId(订单ID)
  179. * @return R 操作结果
  180. */
  181. @ApiOperation("取消退单申请")
  182. @RequestMapping(value = "wx/cancelApplyCancle", method = RequestMethod.POST)
  183. public R cancelApplyCancle(@RequestBody TOrder order) {
  184. try {
  185. log.info("收到取消退单申请请求,订单ID:{}", order.getcId());
  186. // 调用服务层处理取消退单申请
  187. orderService.cancelApplyCancle(order);
  188. // 返回成功提示
  189. return R.ok("已成功取消退单申请,订单已恢复到原状态");
  190. } catch (ServiceException s) {
  191. log.error("取消退单申请失败:{}", s.getMessage());
  192. return R.fail(s.getMessage());
  193. } catch (Exception e) {
  194. log.error("取消退单申请系统异常", e);
  195. return R.fail("系统异常,请稍后重试");
  196. }
  197. }
  198. /**
  199. * 取消订单(用户操作的接口)
  200. *
  201. * @param order
  202. * @return R
  203. */
  204. @Log(title = "取消订单", businessType = BusinessType.UPDATE)
  205. @ApiOperation("取消订单")
  206. @RequestMapping(value = "wx/cancle", method = RequestMethod.POST)
  207. public R cancle(@RequestBody TOrder order) {
  208. try {
  209. return R.ok(orderService.cancle(order));
  210. } catch (ServiceException s) {
  211. log.error(s.toString());
  212. return R.fail(s.getMessage());
  213. } catch (Exception e) {
  214. StackTraceElement stackTraceElement = e.getStackTrace()[0];
  215. log.error("系统出错,错误信息:" + e + " at " + stackTraceElement.getClassName() + "." + stackTraceElement.getMethodName() + ":" + stackTraceElement.getLineNumber());
  216. return R.fail("系统异常");
  217. }
  218. }
  219. /**
  220. * 拒绝订单
  221. *
  222. * @param order
  223. * @return
  224. */
  225. @Log(title = "拒绝订单", businessType = BusinessType.UPDATE)
  226. @ApiOperation("拒绝订单")
  227. @RequestMapping(value = "wx/jujue", method = RequestMethod.POST)
  228. public R jujue(@RequestBody TOrder order) {
  229. try {
  230. return R.ok(orderService.jujue(order));
  231. } catch (ServiceException s) {
  232. log.error(s.toString());
  233. return R.fail(s.getMessage());
  234. } catch (Exception e) {
  235. StackTraceElement stackTraceElement = e.getStackTrace()[0];
  236. log.error("系统出错,错误信息:" + e + " at " + stackTraceElement.getClassName() + "." + stackTraceElement.getMethodName() + ":" + stackTraceElement.getLineNumber());
  237. return R.fail("系统异常");
  238. }
  239. }
  240. /**
  241. * 接受订单(技师端操作的接口)
  242. *
  243. * @param order
  244. * @return R
  245. */
  246. @Log(title = "接受订单", businessType = BusinessType.UPDATE)
  247. @ApiOperation("接受订单")
  248. @RequestMapping(value = "wx/takingOrders", method = RequestMethod.POST)
  249. public R takingOrders(@RequestBody TOrder order) {
  250. try {
  251. orderService.takingOrders(order);
  252. return R.ok();
  253. } catch (ServiceException s) {
  254. log.error(s.toString());
  255. return R.fail(s.getMessage());
  256. } catch (Exception e) {
  257. StackTraceElement stackTraceElement = e.getStackTrace()[0];
  258. log.error("系统出错,错误信息:" + e + " at " + stackTraceElement.getClassName() + "." + stackTraceElement.getMethodName() + ":" + stackTraceElement.getLineNumber());
  259. return R.fail("系统异常");
  260. }
  261. }
  262. /**
  263. * 出发(技师端操作的接口)
  264. *
  265. * @param order
  266. * @return R
  267. */
  268. @Log(title = "出发", businessType = BusinessType.UPDATE)
  269. @ApiOperation("出发")
  270. @RequestMapping(value = "wx/depart", method = RequestMethod.POST)
  271. public R depart(@RequestBody TOrder order) {
  272. try {
  273. orderService.depart(order);
  274. return R.ok();
  275. } catch (ServiceException s) {
  276. log.error(s.toString());
  277. return R.fail(s.getMessage());
  278. } catch (Exception e) {
  279. StackTraceElement stackTraceElement = e.getStackTrace()[0];
  280. log.error("系统出错,错误信息:" + e + " at " + stackTraceElement.getClassName() + "." + stackTraceElement.getMethodName() + ":" + stackTraceElement.getLineNumber());
  281. return R.fail("系统异常");
  282. }
  283. }
  284. /**
  285. * 到达订单位置(技师端操作的接口)
  286. *
  287. * @param order
  288. * @return R
  289. */
  290. @Log(title = "到达订单位置", businessType = BusinessType.UPDATE)
  291. @ApiOperation("到达订单位置")
  292. @RequestMapping(value = "wx/reach", method = RequestMethod.POST)
  293. public R reach(@RequestBody TOrder order) {
  294. try {
  295. log.info("到达订单位置,order对象的值:{}", JSON.toJSONString(order));
  296. LambdaQueryWrapper<TOrder> wrapper = new LambdaQueryWrapper<>();
  297. wrapper.eq(TOrder::getcId, order.getcId()).eq(TOrder::getnStatus, OrderStatusEnum.DEPART.getCode());
  298. order.setnStatus(OrderStatusEnum.ARRIVED.getCode());
  299. order.setReachTime(LocalDateTime.now());
  300. order.setArrivalLatitude(Optional.ofNullable(order.getArrivalLatitude()).orElse(BigDecimal.ZERO));
  301. order.setArrivalLongitude(Optional.ofNullable(order.getArrivalLongitude()).orElse(BigDecimal.ZERO));
  302. order.setArrivalPhoto(Optional.ofNullable(order.getArrivalPhoto()).orElse(StringUtils.EMPTY));
  303. return R.ok(orderService.update(order, wrapper));
  304. } catch (ServiceException s) {
  305. log.error(s.toString());
  306. return R.fail(s.getMessage());
  307. } catch (Exception e) {
  308. StackTraceElement stackTraceElement = e.getStackTrace()[0];
  309. log.error("系统出错,错误信息:" + e + " at " + stackTraceElement.getClassName() + "." + stackTraceElement.getMethodName() + ":" + stackTraceElement.getLineNumber());
  310. return R.fail("系统异常");
  311. }
  312. }
  313. /**
  314. * 开始服务(技师端操作的接口)
  315. *
  316. * @param order
  317. * @return R
  318. */
  319. @Log(title = "开始服务", businessType = BusinessType.UPDATE)
  320. @ApiOperation("开始服务")
  321. @RequestMapping(value = "wx/service", method = RequestMethod.POST)
  322. public R service(@RequestBody TOrder order) {
  323. try {
  324. LambdaQueryWrapper<TOrder> wrapper = new LambdaQueryWrapper<>();
  325. wrapper.eq(TOrder::getcId, order.getcId()).eq(TOrder::getnStatus, OrderStatusEnum.ARRIVED.getCode());
  326. // 设置订单状态:服务中
  327. order.setnStatus(OrderStatusEnum.SERVICE.getCode());
  328. order.setStartTime(LocalDateTime.now());
  329. return R.ok(orderService.update(order, wrapper));
  330. } catch (ServiceException s) {
  331. log.error(s.toString());
  332. return R.fail(s.getMessage());
  333. } catch (Exception e) {
  334. StackTraceElement stackTraceElement = e.getStackTrace()[0];
  335. log.error("系统出错,错误信息:" + e + " at " + stackTraceElement.getClassName() + "." + stackTraceElement.getMethodName() + ":" + stackTraceElement.getLineNumber());
  336. return R.fail("系统异常");
  337. }
  338. }
  339. /**
  340. * 确认订单(技师端的操作接口)
  341. *
  342. * @param order
  343. * @return R
  344. */
  345. //@Log(title = "确认服务完成", businessType = BusinessType.UPDATE)
  346. @ApiOperation("确认服务完成")
  347. @RequestMapping(value = "wx/confirm", method = RequestMethod.POST)
  348. public R confirm(@RequestBody TOrder order) {
  349. try {
  350. return R.ok(orderService.confirm(order));
  351. } catch (ServiceException s) {
  352. log.error(s.toString());
  353. return R.fail(s.getMessage());
  354. } catch (Exception e) {
  355. StackTraceElement stackTraceElement = e.getStackTrace()[0];
  356. log.error("系统出错,错误信息:" + e + " at " + stackTraceElement.getClassName() + "."
  357. + stackTraceElement.getMethodName() + ":" + stackTraceElement.getLineNumber());
  358. return R.fail("系统异常");
  359. }
  360. }
  361. /**
  362. * 获取订单信息(H5端 用户端)
  363. *
  364. * @param page
  365. * @param param
  366. * @return R
  367. */
  368. @Log(title = "微信获取订单信息", businessType = BusinessType.OTHER)
  369. @ApiOperation("获取订单信息")
  370. @RequestMapping(value = "wx/getOrder", method = RequestMethod.GET)
  371. public R getOrder(Page<TOrder> page, TOrder param) {
  372. try {
  373. Page<TOrder> all = orderService.getAll(page, param);
  374. return R.ok(all);
  375. } catch (Exception e) {
  376. e.printStackTrace();
  377. throw new RuntimeException(e);
  378. }
  379. }
  380. @Log(title = "技师端-获取待接单数量", businessType = BusinessType.OTHER)
  381. @ApiOperation("技师端-获取待接单数量")
  382. @RequestMapping(value = "wx/waitOrder", method = RequestMethod.GET)
  383. public R waitOrder(@RequestParam String cJsId) {
  384. List<TOrder> list = orderService.list(new LambdaQueryWrapper<TOrder>().
  385. eq(TOrder::getnStatus, OrderStatusEnum.WAIT_JD.getCode()).
  386. eq(TOrder::getcJsId, cJsId));
  387. return R.ok(list.size());
  388. }
  389. /**
  390. * PC获取订单信息(PC端)
  391. *
  392. * @param page
  393. * @param order
  394. * @return R
  395. */
  396. @Log(title = "PC获取订单信息", businessType = BusinessType.OTHER)
  397. @ApiOperation("PC获取订单信息")
  398. @RequestMapping(value = "pc/getOrder", method = RequestMethod.GET)
  399. public R getPcOrder(Page<TOrder> page, TOrder order) {
  400. try {
  401. LoginUser loginUser = this.getLoginUser();
  402. log.info("登录用户信息:{}", JSON.toJSONString(loginUser));
  403. order.setDeptId(loginUser.getDeptId().toString());
  404. Page<TOrder> all = orderService.getAll(page, order);
  405. return R.ok(all);
  406. } catch (Exception e) {
  407. e.printStackTrace();
  408. throw new RuntimeException(e);
  409. }
  410. }
  411. @Log(title = "微信获取订单信息", businessType = BusinessType.EXPORT)
  412. @ApiOperation("导出")
  413. @PostMapping(value = "wx/export")
  414. public void export(HttpServletResponse response, Page<TOrder> page, TOrder param) {
  415. Page<TOrder> all = orderService.getAll(page, param);
  416. ExcelUtil<TOrder> util = new ExcelUtil<>(TOrder.class);
  417. util.exportExcel(response, all.getRecords(), "订单");
  418. }
  419. /**
  420. * 分页查询订单数据
  421. *
  422. * @param page
  423. * @param order
  424. * @return R
  425. */
  426. @ApiOperation("分页查询订单数据")
  427. @RequestMapping(value = "/select", method = RequestMethod.GET)
  428. public R selectSp(Page<TOrder> page, TOrder order) {
  429. LambdaQueryWrapper<TOrder> tOrderLambdaQueryWrapper = new LambdaQueryWrapper<>();
  430. tOrderLambdaQueryWrapper.eq(StringUtils.isNotBlank(order.getcJsId()), TOrder::getcJsId, order.getcJsId()).
  431. eq(StringUtils.isNotBlank(order.getcOpenId()), TOrder::getcOpenId, order.getcOpenId()).
  432. eq(null != order.getnStatus(), TOrder::getnStatus, order.getnStatus());
  433. // 获取查询返回结果
  434. Page<TOrder> pageSelect = orderService.page(page, tOrderLambdaQueryWrapper);
  435. return R.ok(pageSelect);
  436. }
  437. /**
  438. * 更新订单数据
  439. *
  440. * @param borrow
  441. * @return R 操作结果
  442. */
  443. @ApiOperation("更新订单数据")
  444. @Log(title = "更新订单数据", businessType = BusinessType.OTHER)
  445. @RequestMapping(value = "/update", method = RequestMethod.POST)
  446. public R update(@RequestBody TOrder borrow) {
  447. try {
  448. return R.ok(orderService.updateAddressById(borrow));
  449. } catch (ServiceException s) {
  450. log.error(s.toString());
  451. return R.fail(s.getMessage());
  452. } catch (Exception e) {
  453. StackTraceElement stackTraceElement = e.getStackTrace()[0];
  454. log.error("系统出错,错误信息:" + e + " at " + stackTraceElement.getClassName() + "."
  455. + stackTraceElement.getMethodName() + ":" + stackTraceElement.getLineNumber());
  456. return R.fail("系统异常");
  457. }
  458. }
  459. /**
  460. * 根据订单ID删除订单数据
  461. *
  462. * @param borrow
  463. * @return R 操作结果
  464. */
  465. @ApiOperation("删除数据")
  466. @RequestMapping(value = "/del", method = RequestMethod.POST)
  467. public R del(@RequestBody TOrder borrow) {
  468. try {
  469. log.info("删除订单ID:{}", borrow.getcId());
  470. return R.ok(orderService.removeById(borrow));
  471. } catch (Exception e) {
  472. e.printStackTrace();
  473. throw new RuntimeException(e);
  474. }
  475. }
  476. /**
  477. * 根据订单ID查询订单详情
  478. *
  479. * @param borrow
  480. * @return R<TOrder> 订单详情
  481. */
  482. @ApiOperation("根据订单ID查询订单详情")
  483. @RequestMapping(value = "/getByid", method = RequestMethod.POST)
  484. public R<TOrder> getByid(@RequestBody TOrder borrow) {
  485. try {
  486. return R.ok(orderService.getById(borrow.getcId()));
  487. } catch (Exception e) {
  488. e.printStackTrace();
  489. throw new RuntimeException(e);
  490. }
  491. }
  492. /**
  493. * 获取订单状态
  494. *
  495. * @return R
  496. */
  497. @ApiOperation("订单状态")
  498. @RequestMapping(value = "/getStatus", method = RequestMethod.GET)
  499. public R getStatus() {
  500. List<Enumproject> statusEnum = OrderStatusEnumVo.getStatusEnum();
  501. return R.ok(statusEnum);
  502. }
  503. /**
  504. * 分页查询订单分配操作记录
  505. *
  506. * @param page 分页参数
  507. * @param orderNo 订单号
  508. * @return R 分页结果
  509. */
  510. @Log(title = "分页查询订单分配操作记录", businessType = BusinessType.OTHER)
  511. @ApiOperation("分页查询订单分配操作记录")
  512. @RequestMapping(value = "/allocationLogs/page", method = RequestMethod.GET)
  513. public R getAllocationLogsPage(Page<OrderAllocationLog> page, @RequestParam String orderNo) {
  514. try {
  515. // 构建查询条件
  516. LambdaQueryWrapper<OrderAllocationLog> wrapper = new LambdaQueryWrapper<>();
  517. // 订单号条件
  518. wrapper.eq(StringUtils.isNotBlank(orderNo), OrderAllocationLog::getOrderNo, orderNo);
  519. // 按创建时间倒序排列
  520. wrapper.orderByDesc(OrderAllocationLog::getCreateTime);
  521. // 分页查询
  522. Page<OrderAllocationLog> resultPage = allocationLogService.page(page, wrapper);
  523. // 转换为VO列表
  524. List<OrderAllocationResultVo> voList = resultPage.getRecords().stream()
  525. .map(log -> {
  526. // 转换为VO
  527. OrderAllocationResultVo vo = new OrderAllocationResultVo();
  528. BeanUtils.copyProperties(log, vo);
  529. //根据newTechnicianId查询新技师电话
  530. if (StringUtils.isNotBlank(vo.getNewTechnicianId())) {
  531. TJs technician = jsService.getById(log.getNewTechnicianId());
  532. if (technician != null) {
  533. vo.setNewTechnicianPhone(technician.getcPhone());
  534. }
  535. }
  536. return vo;
  537. }).collect(Collectors.toList());
  538. // 创建新的分页对象,包装转换后的VO列表
  539. Page<OrderAllocationResultVo> voPage = new Page<>(page.getCurrent(), page.getSize(), resultPage.getTotal());
  540. voPage.setRecords(voList);
  541. voPage.setPages(resultPage.getPages());
  542. return R.ok(voPage);
  543. } catch (Exception e) {
  544. log.error("分页查询订单分配记录失败 - 错误信息:{}", e.getMessage(), e);
  545. return R.fail("分页查询分配记录失败:" + e.getMessage());
  546. }
  547. }
  548. /**
  549. * 获取技师当天可预约时间
  550. *
  551. * @param technicianId 技师ID
  552. * @param date 查询日期(格式:yyyy-MM-dd),可选,不传则查询当天
  553. * @return R
  554. */
  555. //@Log(title = "获取技师当天可预约时间", businessType = BusinessType.OTHER)
  556. @ApiOperation("获取技师当天可预约时间")
  557. @RequestMapping(value = "wx/getTechnicianAvailability", method = RequestMethod.GET)
  558. public R<TechnicianAvailabilityVo> getTechnicianAvailability(@RequestParam String technicianId, @RequestParam(required = false) String date) {
  559. try {
  560. log.info("获取技师当天可预约时间,技师ID:{},查询日期:{}", technicianId, date);
  561. TechnicianAvailabilityVo availability = orderService.getTechnicianAvailability(technicianId, date);
  562. return R.ok(availability);
  563. } catch (ServiceException s) {
  564. log.error(s.toString());
  565. return R.fail(s.getMessage());
  566. } catch (Exception e) {
  567. e.printStackTrace();
  568. return R.fail("系统异常");
  569. }
  570. }
  571. }