@Override public IRespParam fillCustomerInfo(Dto pDto) throws Exception { pDto.put(TOKEN_NAME, getKmAccessToken()); KRespResParam resp = HttpClientUtils.post(getUrl(fillinfoMember_path), pDto, KRespResParam.class); return resp; }
/** * kmid 获取会员信息 * * @throws Exception */ @Test public void testMemberInfoByKmID() throws Exception { Dto param = new BaseDto(); String actionPath = "/Km/memberInfoByKmID"; param.put("access_token", accessToken).put("kmid", "000000022"); HttpClientUtils.post(ip + actionPath, param, BaseDto.class); }
@Test public void testMemberInfo() throws Exception { Dto param = new BaseDto(); String actionPath = "/Km/memberInfo"; param.put("access_token", accessToken).put("customerid", 1197); BaseDto pDto = HttpClientUtils.post(ip + actionPath, param, BaseDto.class); System.out.println(pDto); }
/** * K米APP获取在线申请会员等级 * * @throws Exception */ @Test public void applyMemberLevel() throws Exception { Dto param = new BaseDto(); String actionPath = ip + "/Km/applyMemberLevel"; param.put("access_token", accessToken); param.put("companyid", 1197); HttpClientUtils.post(actionPath, param, BaseDto.class); }
@Override public IRespParam registerByPhone(Dto pDto) throws Exception { logger.info("开始根据手机号码生成K米会员: 手机号{}", pDto.get("phoneno")); pDto.put(TOKEN_NAME, getKmAccessToken()); DynamicRespParam resp = HttpClientUtils.post(getUrl(registerMember_path), pDto, DynamicRespParam.class); logger.info("完成根据手机号码生成K米会员,手机号{},返回参数", pDto.get("phoneno"), resp); return resp; }
@Test public void testBindCardInfo() throws Exception { String actionPath = "/Km/bindCardInfo"; KDynamicReqParam param = new KDynamicReqParam(); param.setCompanyid(1197); param.setAccess_token(accessToken); param.set("cardnum", "5000028"); BaseDto pDto = HttpClientUtils.post(ip + actionPath, param, BaseDto.class); System.out.println(pDto); }
@Override public DynamicRespParam getKmAuthDirect() throws Exception { Dto pDto = new BaseDto(); pDto.put("granttype", "clientcredentials"); pDto.put("appid", "11"); pDto.put("appkey", appkey); pDto.put("scope", ""); DynamicRespParam resp = HttpClientUtils.post(getUrl(accesstoken_path), pDto, DynamicRespParam.class); return resp; }
/** * 商家密码更新 * * @throws Exception */ @Test public void updateCompanyPSWD() throws Exception { Dto param = new BaseDto(); String actionPath = ip + "/Km/updateCompanyPsw"; param.put("access_token", accessToken); param.put("companyid", 1199); param.put( "newcompanypsw", "25d55ad283aa400af464c76d713c07adTT"); // 25d55ad283aa400af464c76d713c07adTT HttpClientUtils.post(actionPath, param, BaseDto.class); }
@Test public void testMemberConsumeInfo() throws Exception { String actionPath = "/Km/memberConsumeInfo"; KDynamicReqParam param = new KDynamicReqParam(); param.setCompanyid(1197); param.setAccess_token(accessToken); param.set("kmid", "111111"); param.set("begintime", "2015-01-01 00:00:00"); param.set("endtime", "2015-06-23 23:59:59"); BaseDto pDto = HttpClientUtils.post(ip + actionPath, param, BaseDto.class); System.out.println(pDto); }
@Override public IRespParam pushTemplate(List<BaseDto> kmTemplateList) throws Exception { for (BaseDto baseDto : kmTemplateList) { baseDto.put(TOKEN_NAME, getKmAccessToken()); MRespParam resp = HttpClientUtils.post(getUrl(sendSMS_path), baseDto, MRespParam.class); if (AppUtils.checkSuccess(resp.getRet())) { logger.debug("向KM推送模板消息成功,{}", kmTemplateList); } else { logger.error("向KM推送模板消息失败,{}", kmTemplateList, "返回消息是:", resp); } return resp; } return null; }
@Test public void testUpdateMemberInfo() throws Exception { String actionPath = "/Km/updateMemberInfo"; KDynamicReqParam param = new KDynamicReqParam(); param.setCompanyid(1197); param.setAccess_token(accessToken); param.set("kmid", "000000023"); param.set("membername", "林龙灯3"); param.set("sex", "男"); param.set("birthday", "1988-10-21"); param.set("mobile", "18960863890"); BaseDto pDto = HttpClientUtils.post(ip + actionPath, param, BaseDto.class); System.out.println(pDto); }
@Override public IRespParam sendsms(KSmsReqParam param) throws Exception { Dto pDto = new BaseDto(); pDto.put(TOKEN_NAME, getKmAccessToken()); pDto.put("phoneno", param.getPhoneno()); Dto nestedDto = new BaseDto(); nestedDto.put("validcode", param.getValidcode()); pDto.put("sms_content", nestedDto); MRespParam resp = HttpClientUtils.post(getUrl(sendSMS_path), pDto, MRespParam.class); if (AppUtils.checkSuccess(resp.getRet())) { logger.debug("发送短信成功,手机号是{}", param.getPhoneno()); } else { logger.error("发送短信失败,手机号是{}", param.getPhoneno(), "返回消息是:", resp); } return resp; }
/** * 在线申请会员卡 待测试 * * @throws Exception */ @Test public void applyForMember() throws Exception { Dto param = new BaseDto(); String actionPath = ip + "/Km/applyForMember"; param.put("access_token", accessToken); param.put("companyid", 1197); param.put("customerid", 99999); param.put("gradeid", 1); param.put("membername", "接口测试"); param.put("sex", "灯"); param.put("papertype", ""); param.put("papernumber", ""); param.put("mobile", "01234567890"); param.put("birthday", "2005-01-01"); param.put("address", ""); param.put("email", ""); HttpClientUtils.post(actionPath, param, BaseDto.class); }
/** * 获取参数信息 * * @throws Exception */ @Test public void getparames() throws Exception { Dto param = new BaseDto(); String actionPath = "/Km/getParamer"; param.put("access_token", "mn1dcxfl1o63mcim5tt6lcwc7adl55"); param.put("companyid", 2); ArrayList<String> paramesNameList = new ArrayList<String>(); paramesNameList.add("iscustomer"); paramesNameList.add("userbindvalidatetype"); Map<String, String> map = new HashMap<String, String>(); map.put("parametername", "iscustomer111"); Map<String, String> map1 = new HashMap<String, String>(); map1.put("parametername", "userbindvalidatetype"); ArrayList<Map<String, String>> mapList = new ArrayList<Map<String, String>>(); mapList.add(map); mapList.add(map1); param.put("data", mapList); HttpClientUtils.post(ip + actionPath, param, BaseDto.class); }
/** * 参数更新 * * @throws Exception */ @Test public void updateparames() throws Exception { Dto param = new BaseDto(); String actionPath = ip + "/Km/updateParamer"; param.put("access_token", "vo4rj93um9fl5rhad1ryyv5oqvitdf"); param.put("companyid", 2); ArrayList<Map<String, String>> mapList = new ArrayList<Map<String, String>>(); Map<String, String> mapEntity = new HashMap<String, String>(); mapEntity.put("parametername", "iscustomer"); mapEntity.put("parametervalue", "0"); Map<String, String> mapEntity1 = new HashMap<String, String>(); mapEntity1.put("parametername", "memberqrcodevalidtime"); mapEntity1.put("parametervalue", "30"); mapList.add(mapEntity); mapList.add(mapEntity1); param.put("data", mapList); HttpClientUtils.post(actionPath, param, BaseDto.class); }
@Override @Scheduled(cron = "0 37 0 * * *") public void saveAllCompanyFromKm() throws Exception { logger.info("开始同步所有K米商家信息"); long startTime = System.currentTimeMillis(); Dto param = new BaseDto(); param.put(TOKEN_NAME, getKmAccessToken()); KRespResParam resp = HttpClientUtils.post(getUrl(getAllCompany_path), param, KRespResParam.class); List<BaseDto> resList = resp.getRes(); if (resList != null) { // 初步过滤非法数据 fiterIllegalData(resList); List<Company> companyList = new ArrayList<>(); for (BaseDto dto : resList) { int companyid = dto.getAsInteger("companyid"); Company company = new Company(); company.setCompanyID(companyid); company.setCompanyCode(dto.getAsString("companycode")); company.setCompanyPsw(dto.getAsString("pass")); company.setCompanyType(dto.getAsString("companytype")); company.setCompanyName(dto.getAsString("companyname")); company.setRegionCode(dto.getAsString("regioncode")); company.setCompanyAddress(dto.getAsString("companyaddress")); company.setCompanyMemo(dto.getAsString("companymemo")); company.setCompanyURL(dto.getAsString("companyurl")); company.setCompanyStatus(dto.getAsInteger("status").byteValue()); company.setMapPositionX(dto.getAsString("mappositionx")); company.setMapPositionY(dto.getAsString("mappositiony")); companyList.add(company); } companyRepository.save(companyList); } long endtime = System.currentTimeMillis(); logger.info("结束同步所有K米商家信息,花费时间是{} S", (endtime - startTime) / 1000); }