wzy
2021-03-11 7b645f7cf37136b078bcfdac62e656f3bbf6833d
zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysProjServicesServiceImpl.java
@@ -304,7 +304,8 @@
            SysProjUse sysProjUse = projUseService.findById(sysBeauticianState.getPuseId());
            ShoppingGoods shoppingGoods = shoppingGoodsDao.selectById(sysProjUse.getProjId());
            SysOrderItem orderItem = sysOrderItemService.findById(sysProjUse.getOrderItemId());
           SysOrderItem item = sysOrderItemService.findById(sysProjUse.getOrderItemId());
           SysOrder orderItem = sysOrderService.findById(item.getOrderId());
            if ("购买".equals(sysProjUse.getSource())) {
                // 如果用户有欠款,服务单总价不能超过已付金额
                if (orderItem!=null && orderItem.getArrears() > 0) {
@@ -320,14 +321,14 @@
                    double money = MoneyUtil.sub((bj - orderItem.getArrears()), (yxfje + bcxfje));
                    // 如果 已付金额  - (已消费金额+本次消费金额)<0 则不能再消费
                   if (money < 0) {
                        return new VerifyResult(true, shoppingGoods.getName() + "存在欠款" + orderItem.getArrears() + "元 , 订单编号[ " + sysOrderService.findById(orderItem.getOrderId()).getOrderNo() + " ] ");
                        return new VerifyResult(true, shoppingGoods.getName() + "存在欠款" + orderItem.getArrears() + "元 , 订单编号[ " + orderItem.getOrderNo() + " ] ");
                    }
                }
            } else if ("赠送".equals(sysProjUse.getSource())) {
                if (orderItem!=null &&orderItem.getArrears() > 0) {
                    return new VerifyResult(true, shoppingGoods.getName() + "存在欠款" + orderItem.getArrears() + "元 , 不能消费赠送项目,订单编号[ " + sysOrderService.findById(orderItem.getOrderId()).getOrderNo() + " ] ");
                    return new VerifyResult(true, shoppingGoods.getName() + "存在欠款" + orderItem.getArrears() + "元 , 不能消费赠送项目,订单编号[ " + orderItem.getOrderNo() + " ] ");
                }
            }
        }
@@ -689,12 +690,29 @@
            sysOutStoreItemDao.batchInsert(realOutStoreItemList);
        }
        // 设置服务单状态
        projServices.setState(Dictionary.SERVICE_STATU_PLWC);
//        projServices.setState(Dictionary.SERVICE_STATU_PLWC);
        projServices.setState(Dictionary.SERVICE_STATU_FWWC);
        if(projServices.getDevisionId()==null){
            //如果没有设置配料师则默认为操作配料的人为配料师
            projServices.setDevisionId(sysUsers.getSuId());
        }
        // 释放床位资源
        SysBedState checkBedState = sysBedStateDao.selectBySerIdAndBedId(projServices.getBedId(), projServices.getId());
        if (checkBedState != null) {
            checkBedState.setBedState(Dictionary.BED_STATE_SYJS);
            bedStateDao.update(checkBedState);
        }
        projServices.setStartTime(new Date());
        projServices.setEndTime(new Date());
        // 计算时差
        long minspace = DateUtil.getDifTimeMin(projServices.getStartTime(), projServices.getEndTime())
                - projServices.getTotalTime();
        // 判断是服务超时还是服务提前结束,如果minspace大于0则是超时服务,小于0则是提前结束服务
        projServices.setIsOverTime(minspace + "");
        projServices.setState(Dictionary.SERVICE_STATU_FWWC);
        return sysProjServicesDao.update(projServices);
    }