TdCCustPersonServiceImpl.java 19.7 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473
package com.zteits.pay.biz;

import cn.hutool.core.collection.CollectionUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.dypnsapi.model.v20170525.GetMobileRequest;
import com.aliyuncs.dypnsapi.model.v20170525.GetMobileResponse;
import com.aliyuncs.profile.DefaultProfile;
import com.clouds.common.cache.sys.SysCodeValueCacheUtil;
import com.clouds.common.constants.CodeValKindEnum;
import com.clouds.common.utils.ListCopyUtil;
import com.clouds.common.utils.SequenceUtil;
import com.github.pagehelper.PageInfo;
import com.google.gson.Gson;
import com.xiaoleilu.hutool.date.DateUtil;
import com.zteits.clouds.api.apibase.bean.BizResult;
import com.zteits.clouds.api.apibase.bean.PageBean;
import com.zteits.clouds.api.apibase.constants.DataStatusEnum;
import com.zteits.clouds.api.apibase.constants.ErrorType;
import com.zteits.clouds.api.apibase.constants.SequenceTypeEnum;
import com.zteits.clouds.api.dto.park.param.SwitchETCstateRequest;
import com.zteits.clouds.api.dto.pay.TdCCarDTO;
import com.zteits.clouds.api.dto.pay.TdCCustPersonDTO;
import com.zteits.clouds.api.dto.pay.custperson.CustPersonStatisticDTO;
import com.zteits.clouds.api.dto.pay.custperson.CustPersonStatisticForHourDTO;
import com.zteits.clouds.api.dto.pay.custperson.CustPersonStatisticForWeekDTO;
import com.zteits.clouds.api.dto.pay.dto.RegisterPresentDTO;
import com.zteits.clouds.api.dto.pay.param.*;
import com.zteits.clouds.api.service.pay.TdCCustPersonService;
import com.zteits.pay.dao.*;
import com.zteits.pay.dao.impl.TdCCouponRuleCustidCarnumRelDaoImpl;
import com.zteits.pay.domain.*;
import com.zteits.pay.pagepager.PageBeanUtil;
import com.zteits.pay.service.presentrule.oper.TdCPresentRuleOperInnerService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;
import java.util.stream.Collectors;

@Service("com.zteits.pay.biz.TdCCustPersonServiceImpl")
public class TdCCustPersonServiceImpl implements TdCCustPersonService {
	private static final Logger logger = LoggerFactory.getLogger(TdCCustPersonServiceImpl.class);
	@Autowired
	private TdCCustPersonDao tdCCustPersonDao;
	@Autowired
	private TdCPresentRuleOperInnerService tdCPresentRuleOperInnerService;
	@Autowired
	private TdCCarDao tdCCarDao;
	@Autowired
	private TdCCustUseDayDao tdCCustUseDayDao;

	@Autowired
	private TdCCustPersonChangeOrgDao tdCCustPersonChangeOrgDao;
	@Autowired
	private TdCCouponRuleDao tdCCouponRuleDao;
	@Autowired
	private TdCCouponRuleCustidCarnumRelDaoImpl tdCCouponRuleCustidCarnumRelDaoImpl;
//	@Autowired
//	private Client client;


	@Override
	public BizResult<PageBean<TdCCustPersonDTO>> queryPersonForPage(TdCCustPersonRequest request) {
		PageInfo<TdCCustPersonDTO> pageInfo = tdCCustPersonDao.queryPersonForPage(request);
		PageBean<TdCCustPersonDTO> pageBean = new PageBean<>();
		PageBeanUtil.copyProperties(pageInfo, pageBean, TdCCustPersonDTO.class);
		if(CollectionUtils.isNotEmpty(pageBean.getDataList())) {
			List<String> custIds = pageBean.getDataList().stream().map(item->item.getCustId()).collect(Collectors.toList());
			/**查询车牌号信息*/
			List<TdCCarDTO> carlistdto = new ArrayList<>();
			List<TdCCar> carlist = tdCCarDao.selectCustInfoBycustIds(custIds);
			if (CollectionUtils.isNotEmpty(carlist)) {
				for (TdCCar car : carlist) {
					TdCCarDTO tdCCarDTO = new TdCCarDTO();
					BeanUtils.copyProperties(car, tdCCarDTO);
					carlistdto.add(tdCCarDTO);
				}
			}
			Map<String, List<TdCCarDTO>> aMap = new HashMap<>();
			aMap = carlistdto.stream().collect(Collectors.groupingBy(TdCCarDTO::getCustId));
			for(TdCCustPersonDTO dto : pageBean.getDataList()){
				dto.setCarDtolist(aMap.get(dto.getCustId()));
			}
		}
		return new BizResult<>(pageBean);
	}

	@Override
	public BizResult<TdCCustPersonDTO> selectByUserPhone(TdCCustPersonRequest request) {
		TdCCustPersonDTO dto  = new TdCCustPersonDTO();
		TdCCustPerson person = tdCCustPersonDao.selectByUserPhone(request.getUserPhone());
		if(person!=null){
			BeanUtils.copyProperties(person, dto);
		}
		return new BizResult<TdCCustPersonDTO>(dto);
	}

	@Override
	public BizResult<String> selectByOperatorToken(TdCCustOperatorRequest request){

		//从缓存字典获取keyid+keysecret
		Map<String,String> map = SysCodeValueCacheUtil.queryCodeValueAndNames(CodeValKindEnum.APP_ACCESSKEY_INFO);
		String accessKeyId = map.get("ACCESS_KEY_ID");
		String accessKeySecret = map.get("ACCESS_KEY_SECRET");
		String endpoint = map.get("ACCESS_ENDPOINT");
		logger.info("从APP_ACCESSKEY_INFO缓存获取:endpoint:"+ endpoint);

		DefaultProfile profile = DefaultProfile.getProfile("cn-qingdao", accessKeyId, accessKeySecret);
		IAcsClient client = new DefaultAcsClient(profile);

		GetMobileRequest getMobileRequest = new GetMobileRequest();
		getMobileRequest.setAccessToken(request.getOperatorToken());
		String mobile ="";
		try {
			GetMobileResponse response = client.getAcsResponse(getMobileRequest);
			logger.info("调用阿里接口返回手机号码:" + new Gson().toJson(response));
			mobile = response.getGetMobileResultDTO().getMobile();
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("调用查询手机号接口异常,{}",e.getMessage());
			return null;
		}
		//202302因jar包冲突,替换为1.0版本,原2.0版本代码注释
//		String mobile ="";
//		Config config = new Config()
//				// 您的AccessKey ID
//				.setAccessKeyId(accessKeyId)
//				// 您的AccessKey Secret
//				.setAccessKeySecret(accessKeySecret);
//
//		// 访问的域名
////		config.endpoint = "dypnsapi.aliyuncs.com";
//		config.endpoint = endpoint;
//
//		GetMobileRequest getMobileRequest = new GetMobileRequest();
//		getMobileRequest.setAccessToken(request.getOperatorToken());
//		try {
//			Client client = new Client(config);
//			GetMobileResponse resp = client.getMobile(getMobileRequest);
//			logger.info("调用运营商接口返回::"+ JSONObject.toJSONString(resp));
//
//			mobile = resp.getBody().getGetMobileResultDTO().getMobile();
//		} catch (Exception e) {
//			e.printStackTrace();
//			logger.error("调用查询手机号接口异常,{}",e.getMessage());
//			return null;
//		}

		return new BizResult<String>(mobile);
	}

	@Override
	public BizResult<List<RegisterPresentDTO>> insertSelective(TdCCustPersonRequest request) {
		TdCCustPerson person = new TdCCustPerson();
		BeanUtils.copyProperties(request, person);
		List<RegisterPresentDTO> registerPresentDTOS;
		if(StringUtils.isEmpty(request.getCustId())) {
			String custId = SequenceUtil.getNextId(SequenceTypeEnum.CUST_PERSION_SQE);
			person.setCustId(custId);
		}else{
			person.setCustId(request.getCustId());
		}
		person.setUserPhone(request.getUserPhone());
		person.setCustType(1);
		person.setSex(3);
	    person.setDataState(DataStatusEnum.DATA_STATUS_VALID.value());
	    person.setPettyPayAmount(0);
	    person.setCreateDate(new Date());
	    person.setModfiyDate(new Date());
	    person.setCustNickname(request.getCustNickname());
		int i  = tdCCustPersonDao.insertSelective(person);

		registerPresentDTOS = tdCPresentRuleOperInnerService.presentForRegister(person);

		return new BizResult<List<RegisterPresentDTO>>(registerPresentDTOS);
	}

	@Override
	public BizResult<Integer> updateByUserPhone(TdCCustPersonRequest request) {
		TdCCustPerson person = new TdCCustPerson();
		BeanUtils.copyProperties(request, person);
		person.setModfiyDate(new Date());
		int i  = tdCCustPersonDao.updateByUserPhone(person);
		/**将用户的今天的操作信息插入到数据库(每天插入一条信息)**/
		TdCCustPerson tdCCustPerson = tdCCustPersonDao.selectByUserPhone(person.getUserPhone());
		TdCCustUseDay record = new TdCCustUseDay();
		BeanUtils.copyProperties(tdCCustPerson,record);
		int flg = tdCCustUseDayDao.selectCustUseDayByUserPhone(record);
		if(flg == 0){
			tdCCustUseDayDao.saveCustUseDay(record);
		}
		return new BizResult<>(i);
	}

	@Override
	public BizResult<Integer> openPettyPayment(PettyPaymentRequest request) {
		TdCCustPerson person = new TdCCustPerson();
		BeanUtils.copyProperties(request, person);
		int i  = tdCCustPersonDao.updateByUserPhone(person);
		return new BizResult<Integer>(i);
	}

	@Override
	public BizResult<Integer> resetPettyPayPass(PettyPaymentRequest request) {
		TdCCustPerson person = new TdCCustPerson();
		BeanUtils.copyProperties(request,person);
		int i  = tdCCustPersonDao.updateByUserPhone(person);
		return new BizResult<Integer>(i);
	}

	@Override
	public BizResult<Integer> openMsgPush(MsgPushRequest request) {
		TdCCustPerson person = new TdCCustPerson();
		BeanUtils.copyProperties(request,person);
		int i  = tdCCustPersonDao.updateByUserPhone(person);
		return new BizResult<Integer>(i);
	}

	@Override
	public BizResult<String> saveCustPerson(SaveCustPersonRequest request) {
		TdCCustPerson person = new TdCCustPerson();
		BeanUtils.copyProperties(request, person);
		person.setUserPhone(request.getUserPhone());
		person.setCustId(SequenceUtil.getNextId(SequenceTypeEnum.CUST_PERSION_SQE));
		person.setCustType(1);
		person.setSex(3);
	    person.setDataState(DataStatusEnum.DATA_STATUS_VALID.value());
	    person.setPettyPayAmount(0);
	    person.setCreateDate(new Date());
	    person.setModfiyDate(new Date());
		int i  = tdCCustPersonDao.insertSelective(person);
		return new BizResult<String>(i > 0 ? person.getCustId() : "");
	}

	@Override
	public BizResult<Integer> updateByCustId(TdCCustPersonByCustIdRequest request) {
		TdCCustPerson person = new TdCCustPerson();
		BeanUtils.copyProperties(request, person);
		person.setModfiyDate(new Date());
		int a= tdCCustPersonDao.updateByCustId(person);
		return new BizResult<Integer>(a);
	}

	@Override
	public BizResult<TdCCustPersonDTO> queryPersonByCustId(TdCCustPersonByCustIdRequest request) {
		TdCCustPersonDTO dto  = new TdCCustPersonDTO();
		TdCCustPerson person = tdCCustPersonDao.queryPersonByCustId(request.getCustId());
		if(person!=null){
			BeanUtils.copyProperties(person, dto);
		}
		return new BizResult<TdCCustPersonDTO>(dto);
	}

	@Override
	public BizResult<Integer> updateCustPersonBaseInfoByCustId(TdCCustPersonByCustIdRequest request) {
		TdCCustPerson person = new TdCCustPerson();
		BeanUtils.copyProperties(request, person);
		int a= tdCCustPersonDao.updateCustPersonBaseInfoByCustId(person);
		return new BizResult<Integer>(a);
	}
	@Override
	public BizResult<List<TdCCustPersonDTO>> queryPersonByCustIds(TdCCustPersonByCustIdRequest request) {
		List<TdCCustPersonDTO> result = new ArrayList<>();
		List<TdCCustPerson> list = new ArrayList<>();
		list = tdCCustPersonDao.queryPersonByCustIds(request.getCustIds());
		if(CollectionUtils.isNotEmpty(list)){
			ListCopyUtil.listCopyProperties(list, result, TdCCustPersonDTO.class);
		}
		return new BizResult<>(result);
	}

	@Override
	public BizResult<CustPersonStatisticDTO> queryUserPersonStatistic(TdCCustPersonQueryStatisticRequest request) {
		CustPersonStatisticDTO custPersonStatisticDTO = tdCCustPersonDao.queryUserPersonStatistic(request);
		return new BizResult<>(custPersonStatisticDTO);
	}

	@Override
	public BizResult<List<CustPersonStatisticForHourDTO>> queryUserPersonStatisticForHour(TdCCustPersonQueryStatisticRequest request) {
		List<CustPersonStatisticForHourDTO> custPersonStatisticForHourDTOs = tdCCustPersonDao.queryUserPersonStatisticForHour(request);
		List<CustPersonStatisticForHourDTO> custPersonStatisticForHourDTOsR = new ArrayList<>();
		//查询一天的数据-按小时统计
		for(int i=0;i<=23;i++){
			CustPersonStatisticForHourDTO custPersonStatisticForHourDTO = new CustPersonStatisticForHourDTO();
			custPersonStatisticForHourDTO.setHour(i);
			custPersonStatisticForHourDTO.setNum(0);
			custPersonStatisticForHourDTOsR.add(custPersonStatisticForHourDTO);
		}
		if(CollectionUtils.isNotEmpty(custPersonStatisticForHourDTOs)) {
			for (CustPersonStatisticForHourDTO dtoQ : custPersonStatisticForHourDTOsR) {
				for (CustPersonStatisticForHourDTO dto : custPersonStatisticForHourDTOs) {
					if (dtoQ.getHour().equals(dto.getHour())) {
						dtoQ.setNum(dto.getNum());
					}
				}
			}
		}
		return new BizResult<>(custPersonStatisticForHourDTOsR);
	}

	@Override
	public BizResult<List<CustPersonStatisticForWeekDTO>> queryUserPersonStatisticForWeek(TdCCustPersonQueryStatisticRequest request) {
		List<CustPersonStatisticForWeekDTO> statisticForWeek = tdCCustPersonDao.queryUserPersonStatisticForWeek(request);
		List<CustPersonStatisticForWeekDTO> statisticForWeekDTOs = new ArrayList<>();
		Long dayNum = DateUtil.betweenDay(request.getEndTime(),request.getStartTime(),true);
		//查询一天的数据-按小时统计
		for(int i=0;i<=dayNum;i++){
			CustPersonStatisticForWeekDTO statisticForWeekDTO = new CustPersonStatisticForWeekDTO();
			statisticForWeekDTO.setCreateDate(DateUtil.format(DateUtil.offsetDay(request.getStartTime(),i),DateUtil.NORM_DATE_PATTERN));
			statisticForWeekDTO.setNum(0);
			statisticForWeekDTOs.add(statisticForWeekDTO);
		}
		if(CollectionUtils.isNotEmpty(statisticForWeek)) {
			for (CustPersonStatisticForWeekDTO dtoQ : statisticForWeekDTOs) {
				for (CustPersonStatisticForWeekDTO dto : statisticForWeek) {
					if (dtoQ.getCreateDate().equals(dto.getCreateDate())) {
						dtoQ.setNum(dto.getNum());
					}
				}
			}
		}
		return new BizResult<>(statisticForWeekDTOs);


	}

	@Override
	public BizResult<Integer> updateUserChangeOrgId(TdCCustPersonByCustIdRequest requestQ) {

		/**1.先查询数据库存的跟要修改的是否相同*/
		TdCCustPerson person = tdCCustPersonDao.queryPersonByCustId(requestQ.getCustId());
		if(person!=null&&!requestQ.getOrgId().equals(person.getOrgId())) {
			BeanUtils.copyProperties(requestQ, person);
			int a = tdCCustPersonDao.updateByCustId(person);
			/**插入用户变更记录*/
			TdCCustPersonChangeOrg changeOrg = new TdCCustPersonChangeOrg();
			changeOrg.setCustId(requestQ.getCustId());
			changeOrg.setOrgId(requestQ.getOrgId());
			changeOrg.setDataState(DataStatusEnum.DATA_STATUS_VALID.value());
			changeOrg.setCreateEmpid(requestQ.getCustId());
			changeOrg.setCreateDate(new Date());
			tdCCustPersonChangeOrgDao.insertSelective(changeOrg);
		}
//		/**1.先查询数据库存的跟要修改的是否相同*/
//		TdCCustPerson person = tdCCustPersonDao.queryPersonByCustId(requestQ.getCustId());
//		/**归属地不在进行变更,只能变更一次**/
//		if(person!=null && person.getOrgId() != null){
//			/**插入用户变更记录*/
//			TdCCustPersonChangeOrg changeOrg = new TdCCustPersonChangeOrg();
//			changeOrg.setCustId(requestQ.getCustId());
//			changeOrg.setOrgId(requestQ.getOrgId());
//			changeOrg.setDataState(DataStatusEnum.DATA_STATUS_VALID.value());
//			changeOrg.setCreateEmpid(requestQ.getCustId());
//			changeOrg.setCreateDate(new Date());
//			tdCCustPersonChangeOrgDao.insertSelective(changeOrg);
//		}
//		if(person!=null && person.getOrgId() == null ) {
//			BeanUtils.copyProperties(requestQ, person);
//			int a = tdCCustPersonDao.updateByCustId(person);
//			/**插入用户变更记录*/
//			TdCCustPersonChangeOrg changeOrg = new TdCCustPersonChangeOrg();
//			changeOrg.setCustId(requestQ.getCustId());
//			changeOrg.setOrgId(requestQ.getOrgId());
//			changeOrg.setDataState(DataStatusEnum.DATA_STATUS_VALID.value());
//			changeOrg.setCreateEmpid(requestQ.getCustId());
//			changeOrg.setCreateDate(new Date());
//			tdCCustPersonChangeOrgDao.insertSelective(changeOrg);
//		}
		return new BizResult<>(1);
	}

	/**
	 * 通过手机号查询个人客户信息
	 * @param
	 * @return
	 * @Author: wangfs
	 * @Date: 2019/11/22 12:04
	 *
	 */
	@Override
	public BizResult<PageBean<TdCCustPersonDTO>> queryPersonForPageByUserPhone(QueryPersonForPageByUserPhoneQReq request) {
		PageBean<TdCCustPersonDTO> pageBean = new PageBean<TdCCustPersonDTO>();
		PageInfo<TdCCustPerson> pageInfo = tdCCustPersonDao.queryPersonForPageByUserPhone(request);
		PageBeanUtil.copyProperties(pageInfo,pageBean,TdCCustPersonDTO.class);
		return new BizResult<PageBean<TdCCustPersonDTO>>(pageBean);
	}

    @Override
    public BizResult<PageBean<TdCCustPersonDTO>> queryPersonAndCarNumForPageByUserPhone(QueryPersonForPageByUserPhoneQReq request) {
        // 查询分页用户信息
        PageBean<TdCCustPersonDTO> pageBean = new PageBean<TdCCustPersonDTO>();
        PageInfo<TdCCustPerson> pageInfo = tdCCustPersonDao.queryPersonForPageByUserPhone(request);
        PageBeanUtil.copyProperties(pageInfo, pageBean, TdCCustPersonDTO.class);
        // 查询优惠券编号-客户编号-车牌号码 关系表
        List<TdCCouponRuleCustidCarnumRel> relList = tdCCouponRuleCustidCarnumRelDaoImpl.getListByCardNo(request.getCardNo());
        // 车牌号码关联分页数据
        if (CollectionUtil.isNotEmpty(relList)) {
            List<TdCCustPersonDTO> dataList = pageBean.getDataList();
            for (TdCCustPersonDTO tdCCustPersonDTO : dataList) {
                for (TdCCouponRuleCustidCarnumRel tdCCouponRuleCustidCarnumRel : relList) {
                    if (tdCCustPersonDTO.getCustId().equals(tdCCouponRuleCustidCarnumRel.getCustId())) {
                        tdCCustPersonDTO.setCarNum(tdCCouponRuleCustidCarnumRel.getCarNum());
                    }
                }
            }
        }
        return new BizResult<PageBean<TdCCustPersonDTO>>(pageBean);
    }

    @Transactional(rollbackFor = Exception.class)
    public BizResult<Boolean> saveCardNoAndCustIdAndCarNum(CouponRuleCustidCarnumRelRequest request) {
        TdCCouponRuleCustidCarnumRel rel = new TdCCouponRuleCustidCarnumRel();
        BeanUtils.copyProperties(request, rel);
        List<TdCCouponRuleCustidCarnumRel> list = tdCCouponRuleCustidCarnumRelDaoImpl.getList(rel);
        List<Long> ids = Optional.ofNullable(list).orElse(null).stream().map(e -> e.getId()).collect(Collectors.toList());
        if (CollectionUtils.isNotEmpty(ids)) {
            tdCCouponRuleCustidCarnumRelDaoImpl.delTdCCouponRuleCustidCarnumRel(ids);
        }
        int i = tdCCouponRuleCustidCarnumRelDaoImpl.insertTdCCouponRuleCustidCarnumRel(rel);
        return new BizResult<>(i > 0);
    }

    @Override
    public BizResult<TdCCustPersonDTO> selectByCustId(TdCCustPersonRequest personRequest) {
        TdCCustPerson person = tdCCustPersonDao.selectByCustId(personRequest);
        if (person == null) {
            return null;
        }
        TdCCustPersonDTO dto = new TdCCustPersonDTO();
        BeanUtils.copyProperties(person, dto);
        return new BizResult<>(dto);
    }

	@Override
	public BizResult<Integer> switchETCstate(SwitchETCstateRequest request) {
		int i = tdCCustPersonDao.switchETCstate(request);
		return new BizResult<>(i);
	}

    @Override
    public BizResult<String> insertCustPerson(SaveCustPersonRequest request) {
        if (StringUtils.isEmpty(request.getUserPhone())) {
            return new BizResult<>(ErrorType.PARAMM_NULL, "手机号不能为空");
        }
        // 查询手机号是否注册过
        TdCCustPerson person = tdCCustPersonDao.selectByUserPhone(request.getUserPhone());
        if (person != null) {
			return new BizResult<>(ErrorType.CUST_INFO_HAS_EXISTS, "账户存在");
		}
		// 手机号不存在就插入
		TdCCustPerson newPerson = new TdCCustPerson();
        BeanUtils.copyProperties(request, newPerson);
		newPerson.setUserPhone(request.getUserPhone());
		newPerson.setCustId(SequenceUtil.getNextId(SequenceTypeEnum.CUST_PERSION_SQE));
		newPerson.setCustType(1);
		newPerson.setSex(3);
		newPerson.setDataState(DataStatusEnum.DATA_STATUS_VALID.value());
		newPerson.setPettyPayAmount(0);
		newPerson.setCreateDate(new Date());
		newPerson.setModfiyDate(new Date());
        int i = tdCCustPersonDao.insertSelective(newPerson);
        return new BizResult<>(i > 0 ? newPerson.getUserPhone() : "");
    }


}