From e971ea090aa1f320f3c3f78c3a2a8d50f16dd4d0 Mon Sep 17 00:00:00 2001 From: 935090232@qq.com <ak473600000> Date: Fri, 15 Jan 2021 23:38:19 +0800 Subject: [PATCH] 小程序预约接口修改 --- zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/YuyueAction.java | 275 ++++++++++++++++++++++++++++++------------------------- 1 files changed, 150 insertions(+), 125 deletions(-) diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/YuyueAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/YuyueAction.java index 8530bcd..ec285b8 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/YuyueAction.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/YuyueAction.java @@ -1,37 +1,42 @@ package com.matrix.system.shopXcx.api.action; -import com.alibaba.fastjson.JSONObject; import com.matrix.biz.bean.BizUser; import com.matrix.biz.dao.BizUserDao; import com.matrix.component.rabbitmq.RabiitMqTemplate; import com.matrix.component.redis.RedisUserLoginUtils; +import com.matrix.core.constance.MatrixConstance; +import com.matrix.core.exception.GlobleException; import com.matrix.core.pojo.AjaxResult; +import com.matrix.core.pojo.PaginationVO; +import com.matrix.core.pojo.VerifyResult; import com.matrix.core.tools.DateUtil; import com.matrix.core.tools.StringUtils; +import com.matrix.core.tools.WebUtil; +import com.matrix.system.app.dto.ServiceOrderListDto; +import com.matrix.system.app.mapper.SysBeauticianStateMapper; +import com.matrix.system.app.mapper.SysProjServiceMapper; +import com.matrix.system.app.mapper.SysProjUseMapper; +import com.matrix.system.app.vo.*; import com.matrix.system.common.bean.SysUsers; import com.matrix.system.common.dao.SysUsersDao; import com.matrix.system.common.interceptor.HostInterceptor; +import com.matrix.system.common.tools.DataAuthUtil; import com.matrix.system.common.tools.LocationUtil; import com.matrix.system.constance.Dictionary; import com.matrix.system.hive.bean.*; import com.matrix.system.hive.dao.*; -import com.matrix.system.hive.plugin.message.StringUtil; import com.matrix.system.hive.plugin.util.CollectionUtils; -import com.matrix.core.tools.DateUtil; -import com.matrix.system.hive.service.CodeService; -import com.matrix.system.hive.service.SysProjUseService; -import com.matrix.system.hive.service.SysWorkBeatuistaffService; -import com.matrix.system.hive.service.SysWorktimeService; +import com.matrix.system.hive.service.*; import com.matrix.system.shopXcx.bean.ShopProduct; import com.matrix.system.shopXcx.dao.ShopProductDao; +import com.matrix.system.shopXcx.dao.ShopSkuDao; import com.matrix.system.shopXcx.dto.YYDayOfWeek; import com.matrix.system.shopXcx.dto.YYmonth; import com.matrix.system.shopXcx.mqTask.DTO.UserProjInfo; -import com.matrix.system.shopXcx.mqTask.MQTaskRouting; -import com.matrix.system.shopXcx.shopEnum.TemplateMsgType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -52,10 +57,18 @@ SysShopInfoDao shopInfoDao; @Autowired - private SysVipInfoDao vipDap; + private SysVipInfoDao vipInfoDao; @Autowired private OnlinebookingDao onlinebookingDao; + @Autowired + private SysProjServicesService projServicesService; + + @Autowired + private SysProjServicesDao projServicesDao; + + @Autowired + private SysBeauticianStateService sysBeauticianStateService; @Autowired RedisUserLoginUtils redisUserLoginUtils; @@ -72,7 +85,11 @@ @Autowired RabiitMqTemplate rabiitMqTemplate; + @Autowired + SysProjUseDao projUseDao; + @Autowired + ShopSkuDao skuDao; @Autowired ShoppingGoodsAssembleDao shoppingGoodsAssembleDao; @@ -197,45 +214,42 @@ @ResponseBody public AjaxResult getUserPro(@PathVariable String phone) { - SysVipInfo vipInfo = vipDap.selectByPhone(phone); - // 根据时间获取一段排班码 - Map<Object, Object> taocanProjMap = new HashMap<>(); - List<UserProjInfo> userProjInfoList = new ArrayList(); - SysProjUse sysProjUse = new SysProjUse(); - sysProjUse.setVipId(vipInfo.getId()); - sysProjUse.setIsOver(Dictionary.DELETED_N); - sysProjUse.setIsOver(Dictionary.DELETED_N); - sysProjUse.setStatus(Dictionary.TAOCAN_STATUS_YX); - // 查询出该会员的所有可消耗的选择 - List<SysProjUse> sysProjUseList = projUseService.findByModel(sysProjUse); - for (int i = 0; i < sysProjUseList.size(); i++) { - if (sysProjUseList.get(i).getTaocanId() != null) { - String flag = sysProjUseList.get(i).getOrderItemId()+""; - if (taocanProjMap.keySet().contains(flag)) { - ((UserProjInfo) taocanProjMap.get(flag)).getChildPro().add(coversion(sysProjUseList.get(i))); - } else { - SysProjUse pru = sysProjUseList.get(i); - UserProjInfo taocan = new UserProjInfo(); - taocan.setId(pru.getId()); - taocan.setName(pru.getProjName()); - if (pru.getSurplusCount() > 10000) { - taocan.setSurplusCount("不限"); - } else { - taocan.setSurplusCount(pru.getSurplusCount() + ""); - } - taocan.setChildPro(new ArrayList<UserProjInfo>()); - taocan.getChildPro().add(coversion(pru)); - taocanProjMap.put(flag, taocan); - } - } else { - userProjInfoList.add(coversion(sysProjUseList.get(i))); - } + SysVipInfo vipInfo = vipInfoDao.selectByPhone(phone); + + if (vipInfo == null) { + throw new GlobleException("会员不存在"); } - AjaxResult result = new AjaxResult(); - result.setStatus("200"); - result.setMapInfo(taocanProjMap); - result.setRows(userProjInfoList); - return result; + ServiceProductListVo productListVo = new ServiceProductListVo(); + productListVo.setName(vipInfo.getVipName()); + productListVo.setVipId(vipInfo.getId()); + + SysProjUse queryUse = new SysProjUse(); + queryUse.setVipId(vipInfo.getId()); + queryUse.setType(Dictionary.SHOPPING_GOODS_TYPE_XM); + queryUse.setTaocanId(-1L); + queryUse.setStatus(Dictionary.TAOCAN_STATUS_YX); + queryUse.setIsOver(Dictionary.FLAG_NO_N); + List<SysProjUse> projList = projUseService.findInPage(queryUse, null); + List<ServiceProjVo> serviceProjVos = SysProjUseMapper.INSTANCE.entityListToProjVoList(projList); + + queryUse.setTaocanId(null); + queryUse.setType(Dictionary.SHOPPING_GOODS_TYPE_TC); + List<SysProjUse> taoCanList = projUseService.findInPage(queryUse, null); + List<ServiceTcVo> serviceTcVos = SysProjUseMapper.INSTANCE.entityListToTcVoList(taoCanList); + + if (CollectionUtils.isNotEmpty(serviceTcVos)) { + serviceTcVos.forEach(item -> { + List<SysProjUse> sysProjUses = projUseService.selectTaocanProjUse(item.getId()); + List<ServiceProjVo> taocanProj = SysProjUseMapper.INSTANCE.entityListToProjVoList(sysProjUses); + item.setProj(taocanProj); + }); + } + + productListVo.setProj(serviceProjVos); + productListVo.setComposeProj(serviceTcVos); + AjaxResult ajaxResult = AjaxResult.buildSuccessInstance("获取成功"); + ajaxResult.putInMap("proj", productListVo); + return ajaxResult; } @@ -253,21 +267,55 @@ AjaxResult createServiceOrder(@RequestBody Onlinebooking onlinebooking) { BizUser bizUser = redisUserLoginUtils.getLoginUser(BizUser.class); bizUser = bizUserDao.findByOpenId(bizUser.getOpenId()); - SysVipInfo vipInfo = vipDap.selectByPhone(bizUser.getPhoneNumber()); - onlinebooking.setOrderNo(codeService.getServiceOrderCode()); - onlinebooking.setVipName(vipInfo.getVipName()); - onlinebooking.setVipId(vipInfo.getId()); - onlinebooking.setBizUserId(bizUser.getOpenId()); - onlinebooking.setStatus(Dictionary.ONLINEBOOKING_DFW); - onlinebooking.setCreateTime(new Date()); - onlinebooking.setTime(DateUtil.stringToDate(onlinebooking.getTimeStr(), DateUtil.DATE_FORMAT_MM)); - onlinebookingDao.insert(onlinebooking); - //发送消息通知 - JSONObject msg = new JSONObject(); - msg.put("templateMsgType", TemplateMsgType.APPOINTMENT_SUCCESS.getCode()); - msg.put("content", onlinebooking.getId()); - rabiitMqTemplate.sendMsg(MQTaskRouting.SEND_TEMPLATE_MSG+evn, msg.toJSONString()); - return new AjaxResult(AjaxResult.STATUS_SUCCESS, Collections.singletonList(onlinebooking)); + SysVipInfo vipInfo = vipInfoDao.selectByPhone(bizUser.getPhoneNumber()); + + + SysProjUse sysProjUse = projUseDao.selectById(Long.parseLong(onlinebooking.getProductId() + "")); + Date yyTime = DateUtil.stringToDate(onlinebooking.getTimeStr(), DateUtil.DATE_FORMAT_MM); + SysProjServices sysProjServices = new SysProjServices(); + sysProjServices.setCompanyId(vipInfo.getCompanyId()); + sysProjServices.setShopId(onlinebooking.getShopId()); + sysProjServices.setVipId(vipInfo.getId()); + + sysProjServices.setYyTime(yyTime); + sysProjServices.setRemark(onlinebooking.getRemark()); + + List<SysBeauticianState> sysBeauticianStates = new ArrayList<>(); + + SysBeauticianState sysBeauticianState = new SysBeauticianState(); + sysBeauticianState.setPuseId(sysProjUse.getId()); + sysBeauticianState.setProjUse(sysProjUse); + sysBeauticianState.setCount(1); + sysBeauticianState.setBeginTime(yyTime); + int timeLength=30; + if(sysProjUse.getTimeLength()!=null){ + timeLength=sysProjUse.getTimeLength(); + } + sysBeauticianState.setEndTime(DateUtil.getDateAfterMinute(yyTime, timeLength)); + if(onlinebooking.getStaffId()!=null){ + sysBeauticianState.setStaffId(Long.parseLong(onlinebooking.getStaffId()+"")); + } + + sysBeauticianStates.add(sysBeauticianState); + sysProjServices.setServiceItems(sysBeauticianStates); + + //检测欠款 + VerifyResult arrearsVerifyResult = projServicesService.checkArrears(sysProjServices); + if (arrearsVerifyResult.isError()) { + return new AjaxResult(AjaxResult.STATUS_FAIL, arrearsVerifyResult.getMsg()); + } + //检测余次 + VerifyResult balanceverifyResult = projServicesService.checkBalance(sysProjServices); + if (balanceverifyResult.isError()) { + return new AjaxResult(AjaxResult.STATUS_FAIL, balanceverifyResult.getMsg()); + } + sysProjServices.setState(Dictionary.SERVICE_STATU_DQR); + SysProjServices newSysProjServices = projServicesService.addSysProjServices(sysProjServices); + if (newSysProjServices != null) { + return AjaxResult.buildSuccessInstance("下单成功"); + } else { + return new AjaxResult(AjaxResult.STATUS_FAIL, "下单失败!"); + } } @@ -279,50 +327,43 @@ */ @RequestMapping(value = "/getServiceOrderById/{id}") public @ResponseBody - AjaxResult getServiceOrderById(@PathVariable Long id) { - - Onlinebooking onlinebooking = onlinebookingDao.selectById(id); - ShopProduct shopProduct = productDao.selectById(onlinebooking.getProductId()); - onlinebooking.setShopProduct(shopProduct); - if (onlinebooking.getStaffId() != null) { - SysUsers shopstaffInfo = staffInfoDao.selectById(Long.parseLong(onlinebooking.getStaffId() + "")); - onlinebooking.setStaffInfo(shopstaffInfo); + AjaxResult getServiceOrderById(@PathVariable("id") Long id) { + SysProjServices projServices = projServicesService.findById(id); + if (projServices == null) { + return AjaxResult.buildFailInstance("服务单不存在"); } - SysShopInfo shopInfo = shopInfoDao.selectById(onlinebooking.getShopId()); - onlinebooking.setShopInfo(shopInfo); - AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, "查询成功"); - result.putInMap("serviceOrder", onlinebooking); - return result; - + ServiceOrderDetailVo detailVo = SysProjServiceMapper.INSTANCE.projServiceToDetailVo(projServices); + List<SysBeauticianState> beauticianStates = sysBeauticianStateService.findBySerId(projServices.getId()); + List<ServiceOrderDetailItemVo> items = SysBeauticianStateMapper.INSTANCE.entitiesToDetailItemsVo(beauticianStates); + detailVo.setItems(items); + AjaxResult ajaxResult = AjaxResult.buildSuccessInstance("获取成功"); + ajaxResult.putInMap("detail", detailVo); + ajaxResult.putInMap("shopInfo", shopInfoDao.selectById(projServices.getShopId())); + return ajaxResult; } + + /** - * 订单列表查询 - * + * 查询服务单 + * @param orderListDto * @return */ - @RequestMapping(value = "/getServiceOrderList") - public @ResponseBody - AjaxResult getServiceOrderList(@RequestBody Onlinebooking onlinebooking) { + @PostMapping(value = "/getServiceOrderList") + @ResponseBody + public AjaxResult findServiceOrderList(@RequestBody @Validated ServiceOrderListDto orderListDto) { BizUser bizUser = redisUserLoginUtils.getLoginUser(BizUser.class); - onlinebooking.setBizUserId(bizUser.getOpenId()); - List<Onlinebooking> list = onlinebookingDao.selectInPageForWx(onlinebooking); - //相关数据赋值 - list.stream().forEach(order -> { - ShopProduct shopProduct = productDao.selectById(order.getProductId()); - order.setShopProduct(shopProduct); - if (order.getStaffId() != null) { - SysUsers shopstaffInfo = staffInfoDao.selectById(Long.parseLong(order.getStaffId() + "")); - order.setStaffInfo(shopstaffInfo); - } - SysShopInfo shopInfo = shopInfoDao.selectById(order.getShopId()); - order.setShopInfo(shopInfo); - }); - AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, "查询成功"); - result.setRows(list); - return result; - } + SysVipInfo vipInfo= vipInfoDao.selectByPhone(bizUser.getPhoneNumber()); + PaginationVO pageVo = new PaginationVO(); + int offset = (orderListDto.getPageNum() - 1) * orderListDto.getPageSize(); + int limit = orderListDto.getPageSize(); + pageVo.setOffset(offset); + pageVo.setLimit(limit); + orderListDto.setVipId(vipInfo.getId()); + List<ServiceOrderListVo> apiServiceOrderListInPage = projServicesService.findApiServiceOrderListInPage(orderListDto, pageVo); + return AjaxResult.buildSuccessInstance(apiServiceOrderListInPage, projServicesService.findApiServiceOrderListTotal(orderListDto)); + } /** * 取消预约订单 @@ -330,38 +371,22 @@ * @param * @return */ - @RequestMapping(value = "/cancelOrderById") + @RequestMapping(value = "/cancelOrderById/{id}") public @ResponseBody - AjaxResult cancelOrderById(@RequestBody Onlinebooking onlinebooking) { + AjaxResult cancelOrderById(@PathVariable("id") Long id) { - AjaxResult result = new AjaxResult(); - if (onlinebooking.getId() == null) { - result.setStatus(AjaxResult.STATUS_FAIL); - result.setInfo("请求参数错误"); + SysProjServices services = new SysProjServices(); + services.setId(id); + int i = projServicesService.modifyCancelProjServices(services); + if (i > 0) { + return new AjaxResult(AjaxResult.STATUS_SUCCESS, "取消预约成功"); } else { - onlinebooking.setStatus(Dictionary.ONLINEBOOKING_YQX); - onlinebookingDao.update(onlinebooking); - result.setStatus(AjaxResult.STATUS_SUCCESS); - result.setInfo("订单取消成功"); + return new AjaxResult(AjaxResult.STATUS_FAIL, "取消预约失败"); } - return result; + } - /** - * 删除订单 - * - * @param - * @return - */ - @RequestMapping(value = "/removeOrderById/{id}") - public @ResponseBody - AjaxResult removeOrderById(@PathVariable Long id) { - onlinebookingDao.deleteById(id); - AjaxResult result = new AjaxResult(); - result.setStatus(AjaxResult.STATUS_SUCCESS); - result.setInfo("删除成功"); - return result; - } + private UserProjInfo coversion(SysProjUse pUse) { -- Gitblit v1.9.1