From bbe0a2fd03063316e50cf141986bda984599bbda Mon Sep 17 00:00:00 2001 From: 935090232@qq.com <ak473600000> Date: Tue, 22 Feb 2022 23:41:42 +0800 Subject: [PATCH] Merge branch 'developer' --- zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/YuyueAction.java | 335 ++++++++++++++++++++++++++++++------------------------- 1 files changed, 183 insertions(+), 152 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 efcd693..4e958b3 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,42 +1,50 @@ 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.system.common.init.UserCacheManager; +import com.matrix.core.exception.GlobleException; import com.matrix.core.pojo.AjaxResult; +import com.matrix.core.pojo.VerifyResult; import com.matrix.core.tools.DateUtil; import com.matrix.core.tools.StringUtils; +import com.matrix.system.app.mapper.SysProjUseMapper; +import com.matrix.system.app.vo.ServiceProductListVo; +import com.matrix.system.app.vo.ServiceProjVo; +import com.matrix.system.app.vo.ServiceTcVo; +import com.matrix.system.common.bean.BusParameterSettings; import com.matrix.system.common.bean.SysUsers; +import com.matrix.system.common.dao.BusParameterSettingsDao; import com.matrix.system.common.dao.SysUsersDao; import com.matrix.system.common.interceptor.HostInterceptor; 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.shopXcx.bean.ShopProduct; +import com.matrix.system.hive.service.*; +import com.matrix.system.score.constant.ScoreSettingConstant; +import com.matrix.system.score.entity.ScoreVipDetail; +import com.matrix.system.score.service.ScoreVipDetailService; +import com.matrix.system.shopXcx.api.dto.ErpServiceCommentDto; +import com.matrix.system.shopXcx.api.dto.ErpServiceOrderListDto; +import com.matrix.system.shopXcx.api.vo.ErpServiceOrderListVo; 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 io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; 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; import java.math.BigDecimal; -import java.util.*; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; /** * @author jiangyouyao @@ -52,13 +60,21 @@ SysShopInfoDao shopInfoDao; @Autowired - private SysVipInfoDao vipDap; + private SysVipInfoDao vipInfoDao; @Autowired private OnlinebookingDao onlinebookingDao; + @Autowired + private SysProjServicesService projServicesService; @Autowired - RedisUserLoginUtils redisUserLoginUtils; + private SysProjServicesDao projServicesDao; + + @Autowired + private SysBeauticianStateService sysBeauticianStateService; + + @Autowired + private UserCacheManager userCacheManager; @Autowired ShopProductDao productDao; @@ -67,18 +83,25 @@ SysUsersDao staffInfoDao; @Autowired - BizUserDao bizUserDao; + SysVipInfoDao sysVipInfoDao; + @Autowired - RabiitMqTemplate rabiitMqTemplate; + SysProjUseDao projUseDao; - + @Autowired + ShopSkuDao skuDao; @Autowired ShoppingGoodsAssembleDao shoppingGoodsAssembleDao; @Autowired ShoppingGoodsDao shoppingGoodsDao; + @Autowired + ScoreVipDetailService scoreVipDetailService; + + @Autowired + private BusParameterSettingsDao busParameterSettingsDao; @Value("${evn}") private String evn; @@ -194,48 +217,44 @@ * @return */ @RequestMapping(value = "/getUserPro/{phone}") - public @ResponseBody + @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).getPlatformFlag(); - 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()); - taocan.setType(pru.getType()); - 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,HostInterceptor.getCompanyId()); + + 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); + 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(), queryUse.getStatus()); + 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; } @@ -251,23 +270,60 @@ @RequestMapping(value = "/createServiceOrder") public @ResponseBody 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 sysVipInfo = userCacheManager.getLoginUser(); + SysVipInfo vipInfo = vipInfoDao.selectByPhone(sysVipInfo.getPhone(),HostInterceptor.getCompanyId()); + 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) { + + //添加用户积分 + BusParameterSettings parameterSetting = busParameterSettingsDao.selectCompanyParamByCode(ScoreSettingConstant.RESERVATION_SERVICE_SHOP, sysVipInfo.getCompanyId()); + scoreVipDetailService.addScoreByParamSetting(sysVipInfo.getId(), null,null, newSysProjServices.getId(), + ScoreVipDetail.SCORE_VIP_TYPE_JOIN_ACTIVE,"预约送积分", parameterSetting); + + + return AjaxResult.buildSuccessInstance("下单成功"); + } else { + return new AjaxResult(AjaxResult.STATUS_FAIL, "下单失败!"); + } } @@ -277,52 +333,42 @@ * @param id * @return */ + @ApiOperation(value = " 根据id查询预约订单的详情", notes = " 根据id查询预约订单的详情") + @ApiResponses({ + @ApiResponse(code = 200, message = "ok", response = ErpServiceOrderListVo.class) + }) @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; - + ErpServiceOrderListVo serviceOrder = projServicesDao.findWxServiceOrderById(id); + AjaxResult ajaxResult = AjaxResult.buildSuccessInstance("获取成功"); + ajaxResult.putInMap("detail", serviceOrder); + return ajaxResult; } + + /** - * 订单列表查询 - * + * 查询服务单 + * @param orderListDto * @return */ - @RequestMapping(value = "/getServiceOrderList") - public @ResponseBody - AjaxResult getServiceOrderList(@RequestBody Onlinebooking onlinebooking) { - 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; + @ApiOperation(value = "查询服务单列表", notes = "查询服务单列表") + @ApiResponses({ + @ApiResponse(code = 200, message = "ok", response = ErpServiceOrderListVo.class) + }) + @PostMapping(value = "/getServiceOrderList") + @ResponseBody + public AjaxResult findServiceOrderList(@RequestBody @Validated ErpServiceOrderListDto orderListDto) { + SysVipInfo sysVipInfo = userCacheManager.getLoginUser(); + orderListDto.setVipId(sysVipInfo.getId()); + List<ErpServiceOrderListVo> apiServiceOrderListInPage = projServicesDao.findWxServiceOrderList(orderListDto); + return AjaxResult.buildSuccessInstance(apiServiceOrderListInPage,"查询成功"); } - /** * 取消预约订单 @@ -330,53 +376,38 @@ * @param * @return */ - @RequestMapping(value = "/cancelOrderById") + @ApiOperation(value = "取消预约", notes = "取消预约") + @GetMapping(value = "/cancelOrderById/{id}") public @ResponseBody - AjaxResult cancelOrderById(@RequestBody Onlinebooking onlinebooking) { - - AjaxResult result = new AjaxResult(); - if (onlinebooking.getId() == null) { - result.setStatus(AjaxResult.STATUS_FAIL); - result.setInfo("请求参数错误"); + AjaxResult cancelOrderById(@PathVariable Long id) { + 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}") + + @ApiOperation(value = "服务单评论", notes = "服务单评论") + @PostMapping(value = "/commentService") public @ResponseBody - AjaxResult removeOrderById(@PathVariable Long id) { - onlinebookingDao.deleteById(id); - AjaxResult result = new AjaxResult(); - result.setStatus(AjaxResult.STATUS_SUCCESS); - result.setInfo("删除成功"); - return result; + AjaxResult commentService(@RequestBody @Validated ErpServiceCommentDto commentDto) { + SysProjServices services = new SysProjServices(); + services.setId(commentDto.getId()); + services.setComment(commentDto.getComment()); + int i = projServicesDao.update(services); + if (i > 0) { + return new AjaxResult(AjaxResult.STATUS_SUCCESS, "评论成功"); + } else { + return new AjaxResult(AjaxResult.STATUS_FAIL, "评论失败"); + } } - private UserProjInfo coversion(SysProjUse pUse) { - UserProjInfo projInfo = new UserProjInfo(); - projInfo.setId(pUse.getId()); - projInfo.setName(shoppingGoodsDao.selectById(pUse.getProjId()).getName()); - projInfo.setSurplusCount(pUse.getSurplusCount() + ""); - projInfo.setType(pUse.getType()); - return projInfo; - } - - private int dateToCodeInt(Date date) { - return Integer.parseInt(DateUtil.dateToString(date, DateUtil.HHmm)); - } } -- Gitblit v1.9.1