| | |
| | | package com.matrix.system.hive.service.imp; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.google.common.collect.Lists; |
| | | import com.matrix.component.asyncmessage.AsyncMessageManager; |
| | | import com.matrix.core.constance.MatrixConstance; |
| | | import com.matrix.core.exception.GlobleException; |
| | | import com.matrix.core.pojo.PaginationVO; |
| | | import com.matrix.core.pojo.VerifyResult; |
| | | import com.matrix.core.tools.*; |
| | | import com.matrix.core.tools.DateUtil; |
| | | import com.matrix.core.tools.LogUtil; |
| | | import com.matrix.core.tools.StringUtils; |
| | | import com.matrix.core.tools.WebUtil; |
| | | import com.matrix.system.app.dto.ServiceOrderListDto; |
| | | import com.matrix.system.app.vo.ServiceOrderListVo; |
| | | import com.matrix.system.common.bean.BusParameterSettings; |
| | |
| | | import com.matrix.system.common.constance.AppConstance; |
| | | import com.matrix.system.common.dao.BusParameterSettingsDao; |
| | | import com.matrix.system.common.dao.SysUsersDao; |
| | | import com.matrix.system.common.service.BusParameterSettingService; |
| | | import com.matrix.system.common.service.OperationLogService; |
| | | import com.matrix.system.constance.Dictionary; |
| | | import com.matrix.system.enums.OperationButtonEnum; |
| | | import com.matrix.system.enums.OperationFunctionEnum; |
| | | import com.matrix.system.hive.bean.*; |
| | | import com.matrix.system.hive.dao.*; |
| | | import com.matrix.system.hive.plugin.util.MoneyUtil; |
| | |
| | | @Autowired |
| | | private SysProjUseDao sysProjUseDao; |
| | | |
| | | |
| | | @Autowired |
| | | private OperationLogService operationLogService; |
| | | @Autowired |
| | | private SysOutStoreDao sysOutStoreDao; |
| | | |
| | |
| | | BusParameterSettingsDao busParameterSettingsDao; |
| | | |
| | | @Autowired |
| | | BusParameterSettingService busParameterSettingService; |
| | | |
| | | @Autowired |
| | | ScoreVipDetailService scoreVipDetailService; |
| | | |
| | | @Autowired |
| | | SysVipInfoDao sysVipInfoDao; |
| | | |
| | | |
| | | @Autowired |
| | | ShoppingGoodsAssembleDao goodsAssembleDao; |
| | | |
| | | /** |
| | | * 新增服务单 jyy |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public SysProjServices addSysProjServices(SysProjServices sysProjServices) throws GlobleException { |
| | | |
| | | SysUsers user = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY); |
| | | //创建服务单 |
| | | if (WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY) != null) { |
| | | SysUsers user = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY); |
| | | |
| | | sysProjServices.setCreateStaffId(user.getSuId()); |
| | | sysProjServices.setShopId(user.getShopId()); |
| | | sysProjServices.setCompanyId(user.getCompanyId()); |
| | |
| | | sysProjServices.setTotalTime(totalTime); |
| | | sysProjServices.setMoney(new BigDecimal(hkPrice).setScale(2, BigDecimal.ROUND_HALF_DOWN).doubleValue()); |
| | | sysProjServicesDao.update(sysProjServices); |
| | | //jyytodo 小程序订单没有操作人 |
| | | Long userId=0L; |
| | | if(user!=null){ |
| | | userId= user.getSuId(); |
| | | } |
| | | //保存单据日志 |
| | | operationLogService.saveOperation(sysProjServices.getCompanyId(), sysProjServices.getShopId(),userId, |
| | | OperationFunctionEnum.SERVICE_ORDER, |
| | | OperationButtonEnum.CREATE, |
| | | sysProjServices.getId(), |
| | | sysProjServices.getServiceNo(), |
| | | sysProjServices.getVipId()); |
| | | |
| | | return sysProjServices; |
| | | } |
| | | |
| | |
| | | SysProjUse sysProjUse = projUseService.findById(sysBeauticianState.getPuseId()); |
| | | |
| | | //检查是否已经处于无效状态 |
| | | if(Dictionary.TAOCAN_STATUS_WX.equals(sysProjUse.getStatus())){ |
| | | if (Dictionary.TAOCAN_STATUS_WX.equals(sysProjUse.getStatus())) { |
| | | return new VerifyResult(true, sysProjUse.getProjName() + "项目已经失效"); |
| | | } |
| | | |
| | |
| | | lastList.add(lastWork); |
| | | } |
| | | LastestWorkBeatuistaffDao.batchInsert(lastList); |
| | | return sysProjServicesDao.update(projServices); |
| | | int i = sysProjServicesDao.update(projServices); |
| | | |
| | | //根据配置是否完成自动配料 |
| | | if (busParameterSettingService.isSettingOpen(AppConstance.OPEN_SERVICE_ORDER_AUTO_BATCHING, checkProjServices.getCompanyId())){ |
| | | autoBatching(projServices); |
| | | } |
| | | |
| | | SysUsers users = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); |
| | | //保存单据日志 |
| | | operationLogService.saveOperation(checkProjServices.getCompanyId(), checkProjServices.getShopId(),users.getSuId(), |
| | | OperationFunctionEnum.SERVICE_ORDER, |
| | | OperationButtonEnum.SERVICE_ORDER_PB, |
| | | checkProjServices.getId(), |
| | | checkProjServices.getServiceNo(), |
| | | checkProjServices.getVipId()); |
| | | |
| | | return i; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据配置是否完成自动配料 |
| | | * |
| | | * @param projServices |
| | | */ |
| | | private void autoBatching(SysProjServices projServices) { |
| | | |
| | | //获取最新的服务单信息 |
| | | projServices=findById(projServices.getId()); |
| | | List<SysBeauticianState> beauticianStateList = beauticianStateDao.selectBySerIds(projServices.getId()); |
| | | |
| | | |
| | | List<SysOutStoreItem> outStoreItemList = Lists.newLinkedList(); |
| | | beauticianStateList.stream().forEach(item -> { |
| | | |
| | | List<ShoppingGoodsAssemble> shoppingGoodsAssembles = goodsAssembleDao.selectGoodsByShoppingGoodsIdAndType(item.getProjId(), ShoppingGoods.SHOPPING_GOODS_TYPE_JJCP); |
| | | |
| | | if (CollUtil.isNotEmpty(shoppingGoodsAssembles)) { |
| | | outStoreItemList.addAll(shoppingGoodsAssembles.stream().map(assemble -> { |
| | | SysOutStoreItem outStoreItem = new SysOutStoreItem(); |
| | | outStoreItem.setSkuId(assemble.getAssembleGoodId()); |
| | | outStoreItem.setAmount(Double.parseDouble(assemble.getTotal()+"")); |
| | | outStoreItem.setRemark("自动配料"); |
| | | return outStoreItem; |
| | | }).collect(Collectors.toList())); |
| | | } |
| | | }); |
| | | //组合配料参数 |
| | | projServices.setOutStoreItem(outStoreItemList); |
| | | //调用配料出库方法 |
| | | try { |
| | | modifyPLProjServices(projServices); |
| | | }catch (GlobleException e){ |
| | | LogUtil.debug("配料失败:{}",e.getMessage()); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | //删除积分 |
| | | scoreVipDetailService.removeByBusinessId(checkProjServices.getVipId(), checkProjServices.getId()); |
| | | |
| | | SysUsers users = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); |
| | | //保存单据日志 |
| | | operationLogService.saveOperation(checkProjServices.getCompanyId(), checkProjServices.getShopId(),users.getSuId(), |
| | | OperationFunctionEnum.SERVICE_ORDER, |
| | | OperationButtonEnum.CANCEL, |
| | | checkProjServices.getId(), |
| | | checkProjServices.getServiceNo(), |
| | | checkProjServices.getVipId()); |
| | | |
| | | |
| | | //更新服务单状态 |
| | | return sysProjServicesDao.update(checkProjServices); |
| | | } |
| | |
| | | taocanProjUse.setIsOver(Dictionary.DELETED_N); |
| | | taocanProjUse.setStatus(Dictionary.MONEYCARD_STATUS_YX); |
| | | taocanProjUse.setBalance(MoneyUtil.add(taocanProjUse.getBalance(), backBlance.doubleValue())); |
| | | if (Dictionary.FLAG_YES_Y.equals(taocanProjUse.getIsCourse())) { |
| | | if (StringUtils.isBlank(taocanProjUse.getIsInfinite()) || Dictionary.FLAG_NO_N.equals(taocanProjUse.getIsInfinite())) { |
| | | taocanProjUse.setSurplusCount(taocanProjUse.getSurplusCount() + beauticianState.getCount()); |
| | | } |
| | | // if (Dictionary.FLAG_YES_Y.equals(taocanProjUse.getIsCourse())) { |
| | | if (StringUtils.isBlank(taocanProjUse.getIsInfinite()) || Dictionary.FLAG_NO_N.equals(taocanProjUse.getIsInfinite())) { |
| | | taocanProjUse.setSurplusCount(taocanProjUse.getSurplusCount() + beauticianState.getCount()); |
| | | } |
| | | // } |
| | | sysProjUseDao.update(taocanProjUse); |
| | | } |
| | | |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public int modifyHKProjServices(SysProjServices projServices) throws GlobleException { |
| | | SysUsers sysUsers = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); |
| | | projServices = sysProjServicesDao.selectById(projServices.getId()); |
| | | if (!projServices.getState().equals(Dictionary.SERVICE_STATU_FWWC)) { |
| | | throw new GlobleException("该服务单状态为" + projServices.getState() + ",不可以进行当前操作!"); |
| | |
| | | |
| | | projServices.setState(Dictionary.SERVICE_STATU_FFJS); |
| | | projServices.setConsumeTime(new Date()); |
| | | projServices.setCashierId(sysUsers.getSuId()); |
| | | int result = sysProjServicesDao.update(projServices); |
| | | achieveNewService.addAchieveByServiceOrder(projServices); |
| | | |
| | |
| | | //发送微信公众号提醒 |
| | | UniformMsgParam uniformMsgParam = new UniformMsgParam(projServices.getCompanyId(), UniformMsgParam.GZH_FWWC); |
| | | uniformMsgParam.put("serviceId", projServices.getId()); |
| | | asyncMessageManager.sendMsg(AsyncMessageRouting.SEND_UNIFORM_TEMPLATE_MSG ,uniformMsgParam); |
| | | asyncMessageManager.sendMsg(AsyncMessageRouting.SEND_UNIFORM_TEMPLATE_MSG, uniformMsgParam); |
| | | //发送划扣短信提醒 |
| | | taiYanAliyunSmsService.sendHkNotice(projServices); |
| | | |
| | | //保存单据日志 |
| | | operationLogService.saveOperation(projServices.getCompanyId(), projServices.getShopId(),users.getSuId(), |
| | | OperationFunctionEnum.SERVICE_ORDER, |
| | | OperationButtonEnum.SERVICE_ORDER_HK, |
| | | projServices.getId(), |
| | | projServices.getServiceNo(), |
| | | projServices.getVipId()); |
| | | |
| | | return result; |
| | | } |
| | |
| | | BusParameterSettings principalConsumption = busParameterSettingsDao.selectCompanyParamByCode(ScoreSettingConstant.PRINCIPAL_CONSUMPTION, vipInfo.getCompanyId()); |
| | | //本金消耗 |
| | | if (principalPrice > 0 |
| | | && StringUtils.isNotBlank(principalConsumption.getParamValue())) { |
| | | && StringUtils.isNotBlank(principalConsumption.getParamValue()) && Double.parseDouble(principalConsumption.getParamValue()) > 0 ) { |
| | | |
| | | principalConsumScore[0] = (int) (principalPrice / Double.parseDouble(principalConsumption.getParamValue())); |
| | | |
| | | if (StringUtils.isNotBlank(principalConsumption.getParamValue1())) { |
| | | if (StringUtils.isNotBlank(principalConsumption.getParamValue1()) && Double.parseDouble(principalConsumption.getParamValue1()) > 0 ) { |
| | | principalConsumScore[1] = (int) (principalPrice / Double.parseDouble(principalConsumption.getParamValue1())); |
| | | } |
| | | |
| | | if (StringUtils.isNotBlank(principalConsumption.getParamValue2())) { |
| | | if (StringUtils.isNotBlank(principalConsumption.getParamValue2()) && Double.parseDouble(principalConsumption.getParamValue2()) > 0 ) { |
| | | principalConsumScore[2] = (int) (principalPrice / Double.parseDouble(principalConsumption.getParamValue2())); |
| | | } |
| | | } |
| | |
| | | BusParameterSettings giveConsumption = busParameterSettingsDao.selectCompanyParamByCode(ScoreSettingConstant.GIVE_CONSUMPTION, vipInfo.getCompanyId()); |
| | | //本金消耗 |
| | | if (giftPrice > 0 |
| | | && StringUtils.isNotBlank(giveConsumption.getParamValue())) { |
| | | && StringUtils.isNotBlank(giveConsumption.getParamValue()) && Double.parseDouble(giveConsumption.getParamValue())>0) { |
| | | |
| | | giveConsumScore[0] = (int) (giftPrice / Double.parseDouble(giveConsumption.getParamValue())); |
| | | |
| | | if (StringUtils.isNotBlank(giveConsumption.getParamValue1())) { |
| | | if (StringUtils.isNotBlank(giveConsumption.getParamValue1()) && Double.parseDouble(giveConsumption.getParamValue1())>0) { |
| | | giveConsumScore[1] = (int) (giftPrice / Double.parseDouble(giveConsumption.getParamValue1())); |
| | | } |
| | | |
| | | if (StringUtils.isNotBlank(giveConsumption.getParamValue2())) { |
| | | if (StringUtils.isNotBlank(giveConsumption.getParamValue2()) && Double.parseDouble(giveConsumption.getParamValue2())>0 ) { |
| | | giveConsumScore[2] = (int) (giftPrice / Double.parseDouble(giveConsumption.getParamValue2())); |
| | | } |
| | | } |
| | |
| | | // // 判断是服务超时还是服务提前结束,如果minspace大于0则是超时服务,小于0则是提前结束服务 |
| | | // projServices.setIsOverTime(minspace + ""); |
| | | // projServices.setState(Dictionary.SERVICE_STATU_FWWC); |
| | | //保存单据日志 |
| | | operationLogService.saveOperation(projServices.getCompanyId(), projServices.getShopId(),sysUsers.getSuId(), |
| | | OperationFunctionEnum.SERVICE_ORDER, |
| | | OperationButtonEnum.SERVICE_ORDER_PL, |
| | | projServices.getId(), |
| | | projServices.getServiceNo(), |
| | | projServices.getVipId()); |
| | | |
| | | |
| | | return sysProjServicesDao.update(projServices); |
| | | } |
| | | |
| | |
| | | // 设置美疗师实际开始时间 |
| | | checkBeauticianState.setState(Dictionary.BEATUI_STATE_SYZ); |
| | | projServices.getVipId(); |
| | | //保存单据日志 |
| | | operationLogService.saveOperation(projServices.getCompanyId(), projServices.getShopId(),users.getSuId(), |
| | | OperationFunctionEnum.SERVICE_ORDER, |
| | | OperationButtonEnum.SERVICE_ORDER_BEGIN, |
| | | projServices.getId(), |
| | | projServices.getServiceNo(), |
| | | projServices.getVipId()); |
| | | |
| | | return beauticianStateDao.update(checkBeauticianState); |
| | | } |
| | | |
| | |
| | | checkprojServices.setState(Dictionary.SERVICE_STATU_FWWC); |
| | | sysProjServicesDao.update(checkprojServices); |
| | | } |
| | | |
| | | //保存单据日志 |
| | | operationLogService.saveOperation(projServices.getCompanyId(), projServices.getShopId(),users.getSuId(), |
| | | OperationFunctionEnum.SERVICE_ORDER, |
| | | OperationButtonEnum.SERVICE_ORDER_END, |
| | | projServices.getId(), |
| | | projServices.getServiceNo(), |
| | | projServices.getVipId()); |
| | | return rerunlt; |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int confirmServiceOrder(Long id) { |
| | | SysUsers users = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY); |
| | | SysProjServices services = new SysProjServices(); |
| | | services.setId(id); |
| | | services.setState(Dictionary.BEATUI_STATE_DYY); |
| | | int i = modify(services); |
| | | SysProjServices projServices =findById(id); |
| | | //保存单据日志 |
| | | operationLogService.saveOperation(projServices.getCompanyId(), projServices.getShopId(),users.getSuId(), |
| | | OperationFunctionEnum.SERVICE_ORDER, |
| | | OperationButtonEnum.SERVICE_ORDER_QRYY, |
| | | projServices.getId(), |
| | | projServices.getServiceNo(), |
| | | projServices.getVipId()); |
| | | |
| | | if (i > 0) { |
| | | //发送微信公众号提醒 |
| | | services=findById(services.getId()); |
| | | UniformMsgParam uniformMsgParam=new UniformMsgParam(services.getCompanyId(),UniformMsgParam.GZH_YYCG); |
| | | uniformMsgParam.put("serviceId",services.getId()); |
| | | asyncMessageManager.sendMsg(AsyncMessageRouting.SEND_UNIFORM_TEMPLATE_MSG ,uniformMsgParam); |
| | | services = findById(services.getId()); |
| | | UniformMsgParam uniformMsgParam = new UniformMsgParam(services.getCompanyId(), UniformMsgParam.GZH_YYCG); |
| | | uniformMsgParam.put("serviceId", services.getId()); |
| | | asyncMessageManager.sendMsg(AsyncMessageRouting.SEND_UNIFORM_TEMPLATE_MSG, uniformMsgParam); |
| | | |
| | | taiYanAliyunSmsService.sendYycgNotice(services); |
| | | |
| | |
| | | } |
| | | return i; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |