zjh
2024-12-13 dba27f21bc05c999ace46fe15be6e4c824ed9104
ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjCustomerController.java
@@ -4,6 +4,7 @@
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.extra.pinyin.PinyinUtil;
import cn.hutool.json.JSONArray;
@@ -140,19 +141,26 @@
//    @Log(title = "客户身份信息", businessType = BusinessType.EXPORT)
    public AjaxResult getInfoByIdCard(@RequestParam @ApiParam(value = "客户身份证号") String cusIdcard) {
        if (!"".equals(cusIdcard) && cusIdcard != null) {
            String sfjysfzh = sysConfigService.selectConfigByKey("sfjysfzh");
//            String sfjysjh = configService.selectConfigByKey("sfjysjh");
            //判断身份证号格式是否正确
//            if(cusIdcard.length()==18){
//                if (! MatchUtils.isIdCard(cusIdcard)) {
//                    return AjaxResult.error("身份证号码错误");
//                }
//            }
//            if(cusIdcard.length()==9){
//                if (!MatchUtils.cardValidates(cusIdcard)) {
//                    return AjaxResult.error("身份证号码错误");
//                }
//            }
            Date dates = new Date();
            final String date = DateUtil.format(dates, "yyyy-MM-dd HH:mm:ss");
            if(sfjysfzh.equalsIgnoreCase("Y")){
                if(cusIdcard.length()==18){
                    if (! MatchUtils.isIdCard(cusIdcard)) {
                        return AjaxResult.error("身份证号码错误");
                    }
                }
                if(cusIdcard.length()==9){
                    if (!MatchUtils.cardValidates(cusIdcard)) {
                        return AjaxResult.error("身份证号码错误");
                    }
                }
            }
//            Date dates = new Date();
//            final String date = DateUtil.format(dates, "yyyy-MM-dd HH:mm:ss");
            final String getInfoFromSqlData = sysConfigService.selectConfigByKey("getInfoFromSqlData");
            if ("Y".equals(getInfoFromSqlData)) {
@@ -215,7 +223,8 @@
//                if (DateUtil.endOfDay(new Date()).before(tjReservation.getReservationTime())) {
//                    return AjaxResult.error("未到预约时间");
//                }
                if (null != tjReservation.getReservationTime() && DateUtil.endOfDay(tjReservation.getReservationTime()).before(new Date())) {
                if (null != tjReservation.getReservationTime() && DateUtil.endOfDay(DateUtil.offsetDay(tjReservation.getReservationTime(),
                        tjReservation.getYxts())).before(new Date())) {
                    tjReservation.setIsExpire(1);
                    tjReservationService.updateById(tjReservation);
                    return AjaxResult.error("对不起您的预约已超时请重新预约");
@@ -239,7 +248,7 @@
                    tjCustomer1.setAgeUnit(tjReservation.getAgeUnit());
                    tjCustomer1.setCareer(tjReservation.getCareer());
                    tjCustomer1.setPym(PinyinUtil.getFirstLetter(tjReservation.getName(),""));
                    if (null != key && key.equals("Y"))
/*                    if (null != key && key.equals("Y"))
                    {
                        AjaxResult result = controller.Outpincreateapply(tjCustomer1);
                        String result1 = getAjaxResult(result);
@@ -251,7 +260,7 @@
                            if (null != resultData && resultData.size() > 0) {
                                String pationid = resultData.get("PationId").toString();
                                if (null != pationid) {
                                    tjCustomer1.setPationId(pationid);
//                                    tjCustomer1.setPationId(pationid);
                                    tjCustomerService.updateById(tjCustomer1);
                                    //保存注册入参出参
                                    resultData.put("cardId",pationid);
@@ -265,7 +274,7 @@
                        }
                    }else {
                        tjCustomerService.updateById(tjCustomer1);
                    }
                    }*/
                    tjCustomer1.setTeamNo(tjReservation.getTeamNo());
                    tjCustomer1.setCompId(tjReservation.getCompanyId());
                    tjCustomer1.setReservationId(tjReservation.getId());
@@ -341,7 +350,7 @@
            if (null == tjCustomerServiceOne) {
                return AjaxResult.error("该人员信息不存在请先进行登记!!!");
            }
            if (null != key && key.equals("Y")) {
//            if (null != key && key.equals("Y")) {
                String cardId = tjCustomerServiceOne.getCardId();
                if (null != cardId && !cardId.equals("0")) {
                    int i = tjOrderService.selectTjOrderByCardId(cardId);
@@ -350,8 +359,11 @@
                    }
                }
//            }
            if(!tjCustomerServiceOne.getAge().equals(String.valueOf(DateUtil.ageOfNow(tjCustomerServiceOne.getCusBrithday())))){
                tjCustomerServiceOne.setAge(String.valueOf(DateUtil.ageOfNow(tjCustomerServiceOne.getCusBrithday())));
                tjCustomerService.updateById(tjCustomerServiceOne);
            }
            return AjaxResult.success(tjCustomerServiceOne);
        }
@@ -441,7 +453,6 @@
        if (null == tjCustomer.getCusIdcard() || null == tjCustomer.getCusPhone()) {
            return AjaxResult.error("请输入身份证号或手机号");
        }
        HisApiGetMethodService hisApiGetMethodService = new HisApiGetMethodService();
        Date dates = new Date();
        final String date = DateUtil.format(dates, "yyyy-MM-dd HH:mm:ss");
@@ -449,21 +460,32 @@
        String cusIdcard = tjCustomer.getCusIdcard();
        boolean b = true;
        String sfjysfzh = sysConfigService.selectConfigByKey("sfjysfzh");
        String sfjysjh = sysConfigService.selectConfigByKey("sfjysjh");
        if (null != tjCustomer.getIdType()) {
            if (tjCustomer.getIdType().equals("1")) {
                b = MatchUtils.isIdCard(cusIdcard);
                //判断身份证号格式是否正确
                if(sfjysfzh.equalsIgnoreCase("Y")){
                    if(cusIdcard.length()==18){
                        b = MatchUtils.isIdCard(cusIdcard);
                    }
                }
            } else {
                if(cusIdcard.length()==9){
                    b = MatchUtils.cardValidate(cusIdcard, tjCustomer.getIdType());
                }
            }
//            else {
//                b = MatchUtils.cardValidate(cusIdcard, tjCustomer.getIdType());
//            }
        } else {
            return AjaxResult.error("请选择证件类型");
        }
        if (!b) return AjaxResult.error("证件号有误");
        //判断身份证号格式是否正确
        if (!(MatchUtils.isMobileNO(tjCustomer.getCusPhone())))
            return AjaxResult.error("手机号错误");
        if(sfjysjh.equalsIgnoreCase("Y")){
            if (!(MatchUtils.isMobileNO(tjCustomer.getCusPhone())))
                return AjaxResult.error("手机号错误");
        }
        LambdaQueryWrapper<TjCustomer> wq = new LambdaQueryWrapper<>();
        wq.eq(TjCustomer::getCusIdcard, cusIdcard);
@@ -509,7 +531,7 @@
                String pationid = resultData.get("PationId").toString();
                if (null != pationid) {
                    tjCustomer.setPationId(pationid);
                    tjCustomerService.updateById(tjCustomer);
//                    tjCustomerService.updateById(tjCustomer);
                    //保存注册入参出参
                    resultData.put("cardId",pationid);
                    JSONObject object4 = JSONUtil.parseObj(resultData);
@@ -545,18 +567,35 @@
        if (null == cusPhone) {
            return AjaxResult.error("手机号不能为空");
        }
        /*LambdaQueryWrapper<TjCustomer> wq = new LambdaQueryWrapper<>();
        wq.eq(TjCustomer::getCusPhone, cusPhone);
        TjCustomer customer = tjCustomerService.getOne(wq);
        if (customer != null) {
            return AjaxResult.error("该手机号已被使用!");
        }*/
        String sfjysfzh = sysConfigService.selectConfigByKey("sfjysfzh");
        String sfjysjh = sysConfigService.selectConfigByKey("sfjysjh");
            //判断身份证号格式是否正确
            if(sfjysfzh.equalsIgnoreCase("Y")){
                if(tjCustomer.getCusIdcard().length()==18){
                    if (!(MatchUtils.isIdCard(tjCustomer.getCusIdcard())))
                        return AjaxResult.error("身份证号错误");
                }
                if(tjCustomer.getCusIdcard().length()==9){
                    if (!MatchUtils.cardValidates(tjCustomer.getCusIdcard())) {
                        return AjaxResult.error("身份证号码错误");
                    }
                }
            }
        //判断身份证号格式是否正确
        if(sfjysjh.equalsIgnoreCase("Y")){
            if (!(MatchUtils.isMobileNO(tjCustomer.getCusPhone())))
                return AjaxResult.error("手机号错误");
        }
        tjCustomer.setCusPhone(cusPhone);
        tjCustomer.setPym(PinyinUtil.getFirstLetter(tjCustomer.getCusName(),""));
        if (tjCustomerService.updateById(tjCustomer)) {
            String config = sysConfigService.selectConfigByKey("sfkqdyhis");
            if (null != config && config.equals("Y")) {
                tjCustomer.setPationId(customer.getPationId());
                AjaxResult result = controller.Outpincreateapply(tjCustomer);
                String result1 = getAjaxResult(result);
                JSONObject object = getJSONObject(result1);