大屏接口

dev_0531
yechenhao 6 years ago
parent 147c219935
commit 0100793bc4

@ -722,61 +722,66 @@ public class CustomerViewService {
//查询企业微信已配置联系我的用户
int i = 0;
for (OpCustomer customer : customers) {
List<OpCustomer> opCustomers = customers.subList(132800, customers.size());
for (OpCustomer customer : opCustomers) {
i++;
String wechatUniId = customer.getWechatUniId();
if (StringUtils.isBlank(wechatUniId)){
continue;
}
if (customer.getMemberId() != 0L){
continue;
}
String url = "";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Map<String, Object> params = new HashMap<>();
params.put("unionId", wechatUniId);
String message = HttpClientUtil.httpPost(vipBsdUrl + MD5FileUtil.getMD5String("BOSIDENG" + sdf.format(new Date())), JSONObject.toJSONString(params)).getMessage();
if (StringUtils.isBlank(message)){
continue;
}
System.out.println(i+"/"+customers.size()+"------"+message);
JSONObject vipJson = JSONObject.parseObject(message);
BsdVipResponse bsdResponse = vipJson.toJavaObject(BsdVipResponse.class);
if (bsdResponse.getSuccess() && bsdResponse.getData() != null){
MemberDtlDTO data = bsdResponse.getData();
OpCustomer opCustomer = new OpCustomer(data.getMemberName(), data.getMobileNo());
opCustomer.setUpdateBy(Constants.SYS_OPERATION);
// 根据手机号码去重
QueryWrapper<OpVip> wrapper = new QueryWrapper<>();
wrapper.eq("phone", data.getMobileNo()).last("limit 1");
OpVip opVip = opVipDOMapper.selectOne(wrapper);
OpVip opVip1 = new OpVip();
opVip1.setStatus(1L);
opVip1.setLevel(data.getMemberLevel().toString());
opVip1.setPhone(data.getMobileNo());
opVip1.setName(data.getMemberName());
opVip1.setBirthday(data.getBirthday());
opVip1.setRegisterTime(data.getCreateDate());
if (opVip == null) {
//数据库没有这个数据--新建数据
opVip1.setCreateBy(Constants.SYS_OPERATION);
opVip1.setCreateTime(new Date());
opVipDOMapper.insert(opVip1);
//有vip信息就绑定信息
opCustomer.setMemberId(opVip1.getId());
} else {
opVip1.setId(opVip.getId());
opVip1.setUpdateTime(new Date());
opVip1.setUpdateBy(Constants.SYS_OPERATION);
opVipDOMapper.updateById(opVip1);
//有vip信息就绑定信息
opCustomer.setMemberId(opVip.getId());
try{
String wechatUniId = customer.getWechatUniId();
if (StringUtils.isBlank(wechatUniId)){
continue;
}
if (customer.getMemberId() != 0L){
continue;
}
String url = "";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Map<String, Object> params = new HashMap<>();
params.put("unionId", wechatUniId);
String message = HttpClientUtil.httpPost(vipBsdUrl + MD5FileUtil.getMD5String("BOSIDENG" + sdf.format(new Date())), JSONObject.toJSONString(params)).getMessage();
if (StringUtils.isBlank(message)){
continue;
}
System.out.println(i+"/"+customers.size()+"------"+message);
JSONObject vipJson = JSONObject.parseObject(message);
BsdVipResponse bsdResponse = vipJson.toJavaObject(BsdVipResponse.class);
if (bsdResponse.getSuccess() && bsdResponse.getData() != null){
MemberDtlDTO data = bsdResponse.getData();
OpCustomer opCustomer = new OpCustomer(data.getMemberName(), data.getMobileNo());
opCustomer.setUpdateBy(Constants.SYS_OPERATION);
// 根据手机号码去重
QueryWrapper<OpVip> wrapper = new QueryWrapper<>();
wrapper.eq("phone", data.getMobileNo()).last("limit 1");
OpVip opVip = opVipDOMapper.selectOne(wrapper);
OpVip opVip1 = new OpVip();
opVip1.setStatus(1L);
opVip1.setLevel(data.getMemberLevel().toString());
opVip1.setPhone(data.getMobileNo());
opVip1.setName(data.getMemberName());
opVip1.setBirthday(data.getBirthday());
opVip1.setRegisterTime(data.getCreateDate());
if (opVip == null) {
//数据库没有这个数据--新建数据
opVip1.setCreateBy(Constants.SYS_OPERATION);
opVip1.setCreateTime(new Date());
opVipDOMapper.insert(opVip1);
//有vip信息就绑定信息
opCustomer.setMemberId(opVip1.getId());
} else {
opVip1.setId(opVip.getId());
opVip1.setUpdateTime(new Date());
opVip1.setUpdateBy(Constants.SYS_OPERATION);
opVipDOMapper.updateById(opVip1);
//有vip信息就绑定信息
opCustomer.setMemberId(opVip.getId());
}
QueryWrapper<OpCustomer> wrapper1 = new QueryWrapper<>();
wrapper1.eq("wechat_uni_id", wechatUniId);
opCustomerDOMapper.update(opCustomer, wrapper1);
}
QueryWrapper<OpCustomer> wrapper1 = new QueryWrapper<>();
wrapper1.eq("wechat_uni_id", wechatUniId);
opCustomerDOMapper.update(opCustomer, wrapper1);
}catch (Exception e){
log.error("同步vip出错",e);
}
}
}

Loading…
Cancel
Save