zjh
2024-04-26 d183f6f3f4dd871721e9bd3f30a4e8c71b4a9f1b
ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java
@@ -10,6 +10,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.codec.Base64;
@@ -53,6 +54,7 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpRequest;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
@@ -407,7 +409,7 @@
                    order.setTjCustomerSex(tjCustomer.getCusSex());
                    order.setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday()));
                    order.setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName()));
                    order.setTjCustomerName(MatchUtils.hideCusName(tjCustomer.getCusName()));
                    order.setTjCustomerName(tjCustomer.getCusName());
                    order.setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone()));
//                    order.setTjCusIdCard(MatchUtils.hideIdCardNum(tjCustomer.getCusIdcard()));
                    order.setTjCusIdCard(tjCustomer.getCusIdcard());
@@ -919,6 +921,12 @@
            Date date1 = new Date(System.currentTimeMillis());
            String s1 = SecurityUtils.getUsername() + new SimpleDateFormat("yyMMddHHmmssSSS").format(date1);
            tjFlowingWater.setWaterId(PinyinUtil.getFirstLetter(tjCustomer.getCusName(), "").toUpperCase() + s1);
            tjFlowingWater.setCopeWith(tjOrder.getTjFlowingWater().getCopeWith());
            tjFlowingWater.setPaidIn(tjOrder.getTjFlowingWater().getPaidIn());
            tjFlowingWater.setDiscount(tjOrder.getTjFlowingWater().getDiscount());
            if (isPay.equals("true")) {
                if (null != mallOrder) {
                    if (mallOrder.getOrderStatus().equals(201L)) {
@@ -940,7 +948,8 @@
                        mallOrder.setOrderStatus(301L);
                        mallOrderService.updateById(mallOrder);
                    }
                } else {
                }
                else {
                    tjFlowingWater.setCopeWith(tjOrder.getTjFlowingWater().getCopeWith());
                    tjFlowingWater.setPaidIn(tjOrder.getTjFlowingWater().getPaidIn());
                    tjFlowingWater.setDiscount(tjOrder.getTjFlowingWater().getDiscount());
@@ -950,17 +959,16 @@
            if (tjFlowingWaterService.save(tjFlowingWater)) {
                tjOrder.setTjSerialNumber(String.valueOf(tjFlowingWater.getTjSerialNumber()));
                tjOrderService.updateById(tjOrder);
            }
            //团体
            if ("1".equals(tjOrder.getTjType())) {
                asyncService.ttextracted(tjOrder, tjCustomer, sysUser, tjReservation, tjFlowingWater);
            }
            //个人
            if ("2".equals(tjOrder.getTjType())) {
                //asyncService.newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
                newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
            }
@@ -1091,7 +1099,13 @@
                    for (TjPackageProject tjPackageProject : ppList) {
                        TjProject project = projectService.getTjProjectById(String.valueOf(tjPackageProject.getProId()));
                        if (null != project) {
                            BigDecimal divide = tjPackageProject.getPriceNow().divide(project.getProPrice(), 5, RoundingMode.HALF_DOWN);
                            BigDecimal divide = BigDecimal.valueOf(0);
                            if(tjPackageProject.getPriceNow().compareTo(BigDecimal.valueOf(0))==0 || project.getProPrice().compareTo(BigDecimal.valueOf(0))==0 ){
                                divide=BigDecimal.valueOf(0);
                            }else {
                                divide=tjPackageProject.getPriceNow().divide(project.getProPrice(), 5, RoundingMode.HALF_DOWN);
                            }
                            List<TjProject> tjProSonList = projectService.getTjProjectListBySoneId(String.valueOf(project.getProId()));
                            if (null != tjProSonList && tjProSonList.size() > 0) {
                                //addRedisTransitionPac(cusId, tbTransitionList, pacId, tjPackageProject, project, divide, tjProSonList);
@@ -1170,6 +1184,8 @@
                }
            }
        }
        if (null != tbTransitionList && tbTransitionList.size() > 0) {
            if (redisCache.hasKey(cardId + cusId)) {
                redisCache.deleteObject(cardId + cusId);
@@ -1413,19 +1429,20 @@
        if (!handleOption.isCanship()) {
            return AjaxResult.error("订单不能核销");
        }
        Date date = new Date();
        order.setOrderStatus(OrderUtil.STATUS_SHIP.longValue());
        order.setShipTime(new Date());
        order.setConfirmTime(new Date());
        order.setShipTime(date);
        order.setConfirmTime(date);
        MallCheckLog checkLog = new MallCheckLog();
        String s1 = SecurityUtils.getUsername() + new SimpleDateFormat("yyMMddHHmmssSSS").format(new Date());
        String s1 = SecurityUtils.getUsername() + new SimpleDateFormat("yyMMddHHmmssSSS").format(date);
        checkLog.setCheckBy(String.valueOf(SecurityUtils.getUserId()));
        checkLog.setUserId(order.getUserId());
        checkLog.setConsignee(order.getConsignee());
        checkLog.setIdCard(order.getIdCard());
        checkLog.setOrderId(String.valueOf(order.getId()));
        checkLog.setOrderSn(order.getOrderSn());
        checkLog.setCheckTime(new Date());
        checkLog.setCheckTime(date);
        checkLog.setShipSn("HX" + s1);
        mallCheckLogService.save(checkLog);
        mallOrderService.updateById(order);
@@ -1436,11 +1453,11 @@
    private List<Map<String, Object>> getMaps(String cusId, String cardId) {
        List<TbTransition> transitionList = null;
        if (redisCache.hasKey(cardId + cusId)) {
            transitionList = redisCache.getCacheList(cardId + cusId);
        } else {
//        if (redisCache.hasKey(cardId + cusId)) {
//            transitionList = redisCache.getCacheList(cardId + cusId);
//        } else {
            transitionList = transitionService.getTbTransitionListByCusId(cusId, cardId);
        }
//        }
        if (null == transitionList) return null;
        Map<Long, List<TbTransition>> collect = transitionList.stream().collect(Collectors.groupingBy(TbTransition::getParentProId));
        List<Map<String, Object>> list = new ArrayList<>();
@@ -1451,14 +1468,15 @@
                TjPackage aPackage = tjPackageService.getById(entry.getValue().get(0).getPacId());
                map.put("pacName", aPackage.getPacName());
                TjProject tjProject = projectService.getById(entry.getKey());
                TjPackageProject project = tjPackageProjectService.getOne(new LambdaQueryWrapper<TjPackageProject>().eq(TjPackageProject::getPacId, pacId)
                        .eq(TjPackageProject::getProId, entry.getKey()));
//                TjPackageProject project = tjPackageProjectService.getOne(new LambdaQueryWrapper<TjPackageProject>().eq(TjPackageProject::getPacId, pacId)
//                        .eq(TjPackageProject::getProId, entry.getKey()));
                map.put("ordPrice", tjProject.getProPrice());
                if (null != project) {
                    map.put("nowPrice", project.getPriceNow());
                } else {
                    map.put("nowPrice", tjProject.getProPrice());
                }
//                if (null != project) {
//                    map.put("nowPrice", project.getPriceNow());
//                } else {
//                    map.put("nowPrice", tjProject.getProPrice());
//                }
                map.put("nowPrice",transitionService.getTbTransitionDxPriceByPac(cusId,entry.getKey(),cardId,pacId));
            } else {
                map.put("pacName", "单项");
                List<TbTransition> tbTransitionList = entry.getValue();
@@ -1475,8 +1493,6 @@
            }
            map.put("parentName", projectService.getById(entry.getKey()).getProName());
            map.put("list", entry.getValue());
            list.add(map);
        }
        return list;
@@ -1711,6 +1727,11 @@
        if (tjFlowingWater.getPayStasus() == 1L) {
            tjOrderDetailService.updateTjOrderDetailsByOrderId(String.valueOf(tjOrder.getOrderId()),
                    sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjFlowingWater.getTjSerialNumber()));
            tjFlowingWater.setPaidIn(tjOrder.getTjFlowingWater().getPaidIn());
            tjFlowingWater.setCopeWith(tjOrder.getTjFlowingWater().getCopeWith());
            tjFlowingWater.setPayType(4L);
            tjFlowingWaterService.updateById(tjFlowingWater);
            asyncService.addTjChargingStandard(tjOrder, transitionService.getTbTransitionListByCusId(tjCustomer.getCusIdcard(), tjOrder.getCardId()), sysUser);
        }
//        System.out.println("这段代码时间" + (System.currentTimeMillis() - l));
    }
@@ -1813,4 +1834,40 @@
        return AjaxResult.success("暂无历史记录");
    }
    @GetMapping("/getHistryTjOrderByCusId")
    @ApiOperation(value = "根据客户id查看历史体检记录")
    @Transactional
    public AjaxResult getHistryTjOrderByCusId(@RequestParam String cusId) {
        TjCustomer tjCustomer = tjCustomerService.getById(cusId);
        List<HistoryTjOrder> list = new ArrayList<>();
        if (null != tjCustomer) {
            List<TjOrder> orderList = tjOrderService.getTjOrderListByCusId(tjCustomer.getCusId());
            for (TjOrder order : orderList) {
                HistoryTjOrder historyTjOrder = new HistoryTjOrder();
                historyTjOrder.setUserName(tjCustomer.getCusName());
                historyTjOrder.setTjNum(order.getTjNumber());
                historyTjOrder.setTjTime(order.getCreateTime());
                historyTjOrder.setTjProName(tjOrderService.getHistoryTjOrderProByTjNum(order.getTjNumber()));
                //查流水
                BigDecimal res = new BigDecimal(0);
                LambdaQueryWrapper<TjFlowingWater> wqq = new LambdaQueryWrapper<>();
                wqq.eq(TjFlowingWater::getOrderId, order.getOrderId());
                final List<TjFlowingWater> list1 = tjFlowingWaterService.list(wqq);
                if (list1 != null) {
                    for (TjFlowingWater tjFlowingWater : list1) {
                        if (tjFlowingWater!=null && tjFlowingWater.getPaidIn()!=null){
                            res.add(tjFlowingWater.getPaidIn());
                        }
                    }
                }
                historyTjOrder.setPaidIn(res);
                list.add(historyTjOrder);
            }
        }
        return AjaxResult.success(list);
    }
}