no message

This commit is contained in:
2025-09-01 15:54:31 +08:00
parent 98a0628344
commit 53e2e13a7d

View File

@ -3,14 +3,9 @@ package com.sczx.sync.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.nacos.common.utils.MD5Utils; import com.alibaba.nacos.common.utils.MD5Utils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sczx.sync.mapper.*;
import com.sczx.sync.po.StoreInfo;
import com.sczx.sync.po.CompanyInfo;
import com.sczx.sync.po.BaseUser;
import com.sczx.sync.po.BatteryRule;
import com.sczx.sync.po.SyncRequest;
import com.sczx.sync.entity.UserInfo; import com.sczx.sync.entity.UserInfo;
import com.sczx.sync.po.UserStore; import com.sczx.sync.mapper.*;
import com.sczx.sync.po.*;
import com.sczx.sync.service.ReceiveService; import com.sczx.sync.service.ReceiveService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -22,8 +17,6 @@ import java.time.LocalDateTime;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import static com.sczx.sync.common.enums.ApiErrorCode.NOT_PERMISSION;
@Slf4j @Slf4j
@Service @Service
@Component @Component
@ -37,97 +30,99 @@ public class ReceiveServiceImpl implements ReceiveService {
@Autowired @Autowired
private UserStoreMapper userStoreMapper; private UserStoreMapper userStoreMapper;
@Autowired @Autowired
private CompanyInfoMapper companyInfoMapper; private CompanyInfoMapper companyInfoMapper;
@Autowired @Autowired
private CompanyStoreMapper companyStoreMapper; private CompanyStoreMapper companyStoreMapper;
@Value("${battery-platform.appid}") @Value("${battery-platform.appid}")
private String appId; private String appId;
@Value("${battery-platform.access-token}") @Value("${battery-platform.access-token}")
private String accessToken; private String accessToken;
@Override @Override
public Map<String, String> recceiveMeals(String request) { public Map<String, String> recceiveMeals(String request) {
SyncRequest<BatteryRule> syncRequest = JSON.parseObject(request, SyncRequest.class); SyncRequest<BatteryRule> syncRequest = JSON.parseObject(request, SyncRequest.class);
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
if(!syncRequest.getAppid().equals(appId)||!syncRequest.getAccessToken().equals(accessToken)){ if (!syncRequest.getAppid().equals(appId) || !syncRequest.getAccessToken().equals(accessToken)) {
map.put("msg","没有权限"); map.put("msg", "没有权限");
map.put("code","500"); map.put("code", "500");
return map; return map;
} }
BatteryRule batteryRule = new BatteryRule(); BatteryRule batteryRule = new BatteryRule();
try { try {
batteryRule = JSON.parseObject(String.valueOf(syncRequest.getData()), BatteryRule.class); batteryRule = JSON.parseObject(String.valueOf(syncRequest.getData()), BatteryRule.class);
}catch (Exception e) } catch (Exception e) {
{ map.put("msg", "数据格式错误");
map.put("msg","数据格式错误"); map.put("exception", e.getMessage());
map.put("exception",e.getMessage()); map.put("code", "500");
map.put("code","500");
return map; return map;
} }
if (batteryRule.getTitle() == null || batteryRule.getTitle().isEmpty()){ if (batteryRule.getTitle() == null || batteryRule.getTitle().isEmpty()) {
map.put("msg","套餐名称不能为空"); map.put("msg", "套餐名称不能为空");
map.put("code","500"); map.put("code", "500");
return map;
}if (batteryRule.getDetail() == null || batteryRule.getDetail().isEmpty()){
map.put("msg","套餐详情不能为空");
map.put("code","500");
return map;
}if (batteryRule.getVoltage() == null){
map.put("msg","套餐电压不能为空");
map.put("code","500");
return map;
}if (batteryRule.getAh() == null){
map.put("msg","套餐Ah不能为空");
map.put("code","500");
return map; return map;
} }
if (batteryRule.getRent_price() == null){ if (batteryRule.getDetail() == null || batteryRule.getDetail().isEmpty()) {
map.put("msg","套餐价格不能为空"); map.put("msg", "套餐详情不能为空");
map.put("code","500"); map.put("code", "500");
return map; return map;
} }
if (batteryRule.getDuration() == null){ if (batteryRule.getVoltage() == null) {
map.put("msg","套餐时长不能为空"); map.put("msg", "套餐电压不能为空");
map.put("code","500"); map.put("code", "500");
return map; return map;
} }
if (batteryRule.getCity() == null ){ if (batteryRule.getAh() == null) {
map.put("msg","套餐城市不能为空"); map.put("msg", "套餐Ah不能为空");
map.put("code","500"); map.put("code", "500");
return map; return map;
} }
if (batteryRule.getProvince() == null){ if (batteryRule.getRent_price() == null) {
map.put("msg","套餐省份不能为空"); map.put("msg", "套餐价格不能为空");
map.put("code","500"); map.put("code", "500");
return map; return map;
} }
if (batteryRule.getCategory_id() == null){ if (batteryRule.getDuration() == null) {
map.put("msg","电池类型不能为空"); map.put("msg", "套餐时长不能为空");
map.put("code","500"); map.put("code", "500");
return map; return map;
} }
if (batteryRule.getOperator_id() == null){ if (batteryRule.getCity() == null) {
map.put("msg","运营商id不能为空"); map.put("msg", "套餐城市不能为空");
map.put("code","500"); map.put("code", "500");
return map; return map;
} }
if (batteryRule.getDuration_type() == null){ if (batteryRule.getProvince() == null) {
map.put("msg","套餐时长类型不能为空"); map.put("msg", "套餐省份不能为空");
map.put("code","500"); map.put("code", "500");
return map; return map;
} }
if(batteryRule.getMeal_id() == null ){ if (batteryRule.getCategory_id() == null) {
map.put("msg","套餐id不能为空"); map.put("msg", "电池类型不能为空");
map.put("code","500"); map.put("code", "500");
return map;
}
if (batteryRule.getOperator_id() == null) {
map.put("msg", "运营商id不能为空");
map.put("code", "500");
return map;
}
if (batteryRule.getDuration_type() == null) {
map.put("msg", "套餐时长类型不能为空");
map.put("code", "500");
return map;
}
if (batteryRule.getMeal_id() == null) {
map.put("msg", "套餐id不能为空");
map.put("code", "500");
return map; return map;
} }
CompanyInfo companyInfo = companyInfoMapper.selectByOpId(Long.parseLong(batteryRule.getOperator_id().toString())); CompanyInfo companyInfo = companyInfoMapper.selectByOpId(Long.parseLong(batteryRule.getOperator_id().toString()));
if (companyInfo == null){ if (companyInfo == null) {
map.put("msg","该运营商不存在,请先进行运营商同步"); map.put("msg", "该运营商不存在,请先进行运营商同步");
map.put("code","500"); map.put("code", "500");
return map; return map;
} }
@ -142,8 +137,8 @@ public class ReceiveServiceImpl implements ReceiveService {
batteryRule.setOperator_id(companyInfo.getId().intValue()); batteryRule.setOperator_id(companyInfo.getId().intValue());
batteryMealMapper.insertZcRentBatteyRule(batteryRule); batteryMealMapper.insertZcRentBatteyRule(batteryRule);
} }
map.put("msg","套餐同步成功"); map.put("msg", "套餐同步成功");
map.put("code","200"); map.put("code", "200");
return map; return map;
} }
@ -152,33 +147,34 @@ public class ReceiveServiceImpl implements ReceiveService {
SyncRequest<UserInfo> syncRequest = JSON.parseObject(request, SyncRequest.class); SyncRequest<UserInfo> syncRequest = JSON.parseObject(request, SyncRequest.class);
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
if(!syncRequest.getAppid().equals(appId)||!syncRequest.getAccessToken().equals(accessToken)){ if (!syncRequest.getAppid().equals(appId) || !syncRequest.getAccessToken().equals(accessToken)) {
map.put("msg","没有权限"); map.put("msg", "没有权限");
map.put("code","500"); map.put("code", "500");
return map; return map;
} }
UserInfo user = JSON.parseObject(String.valueOf(syncRequest.getData()), UserInfo.class); UserInfo user = JSON.parseObject(String.valueOf(syncRequest.getData()), UserInfo.class);
if (user.getPhone() == null || user.getPhone().isEmpty()){ if (user.getPhone() == null || user.getPhone().isEmpty()) {
map.put("msg","手机号不能为空"); map.put("msg", "手机号不能为空");
map.put("code","500"); map.put("code", "500");
return map; return map;
} }
if (user.getName() == null || user.getName().isEmpty()){ if (user.getName() == null || user.getName().isEmpty()) {
map.put("msg","用户姓名不能为空"); map.put("msg", "用户姓名不能为空");
map.put("code","500"); map.put("code", "500");
return map; return map;
} }
if (user.getIsauthentication() == null){ if (user.getIsauthentication() == null) {
map.put("msg","用户认证状态不能为空"); map.put("msg", "用户认证状态不能为空");
map.put("code","500"); map.put("code", "500");
return map; return map;
}if (user.getIsmerchant() == null) { }
if (user.getIsmerchant() == null) {
map.put("msg", "用户类型不能为空"); map.put("msg", "用户类型不能为空");
map.put("code", "500"); map.put("code", "500");
return map; return map;
} }
if(user.getIsmerchant() == 1){ if (user.getIsmerchant() == 1) {
if (user.getStoreId() == null || user.getStoreId().isEmpty()) { if (user.getStoreId() == null || user.getStoreId().isEmpty()) {
map.put("msg", "用户为商户时门店不能为空"); map.put("msg", "用户为商户时门店不能为空");
map.put("code", "500"); map.put("code", "500");
@ -196,7 +192,8 @@ public class ReceiveServiceImpl implements ReceiveService {
baseUser.setIdNo(user.getCardno()); baseUser.setIdNo(user.getCardno());
baseUser.setAuthed(user.getIsauthentication()); baseUser.setAuthed(user.getIsauthentication());
baseUser.setIsStore(user.getIsmerchant()); baseUser.setIsStore(user.getIsmerchant());
baseUser.setFrontPhoto(user.getCard1());; baseUser.setFrontPhoto(user.getCard1());
;
baseUser.setBackPhoto(user.getCard2()); baseUser.setBackPhoto(user.getCard2());
baseUser.setDelFlag("0"); baseUser.setDelFlag("0");
@ -212,18 +209,21 @@ public class ReceiveServiceImpl implements ReceiveService {
UserStore userStore = new UserStore(); UserStore userStore = new UserStore();
String storeIds = user.getStoreId(); String storeIds = user.getStoreId();
String[] storeIdsArray = storeIds.split(","); if (user.getIsmerchant() == 1) {
for (String storeId : storeIdsArray) { String[] storeIdsArray = storeIds.split(",");
userStore.setStoreId(Long.parseLong(storeId)); for (String storeId : storeIdsArray) {
userStore.setOperatorId(Long.parseLong(user.getOperatorId())); userStore.setStoreId(Long.parseLong(storeId));
userStore.setUserId(Long.parseLong(String.valueOf(baseUserId))); userStore.setOperatorId(Long.parseLong(user.getOperatorId()));
userStore.setDelFlag("0"); userStore.setUserId(Long.parseLong(String.valueOf(baseUserId)));
userStore.setCreateTime(LocalDateTime.now()); userStore.setDelFlag("0");
userStore.setUpdateTime(LocalDateTime.now()); userStore.setCreateTime(LocalDateTime.now());
userStoreMapper.insertUserStore(userStore) ; userStore.setUpdateTime(LocalDateTime.now());
userStoreMapper.insertUserStore(userStore);
}
} }
map.put("msg","成功");
map.put("code","200"); map.put("msg", "成功");
map.put("code", "200");
return map; return map;
@ -234,40 +234,46 @@ public class ReceiveServiceImpl implements ReceiveService {
log.info("接收运营商数据:", request); log.info("接收运营商数据:", request);
SyncRequest<CompanyInfo> syncRequest = JSON.parseObject(request, SyncRequest.class); SyncRequest<CompanyInfo> syncRequest = JSON.parseObject(request, SyncRequest.class);
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
if(!syncRequest.getAppid().equals(appId)||!syncRequest.getAccessToken().equals(accessToken)){ if (!syncRequest.getAppid().equals(appId) || !syncRequest.getAccessToken().equals(accessToken)) {
map.put("msg","没有权限"); map.put("msg", "没有权限");
map.put("code","500"); map.put("code", "500");
return map; return map;
} }
CompanyInfo companyInfo = JSON.parseObject(String.valueOf(syncRequest.getData()), CompanyInfo.class); CompanyInfo companyInfo = JSON.parseObject(String.valueOf(syncRequest.getData()), CompanyInfo.class);
if (companyInfo.getCompany_name() == null || companyInfo.getCompany_name().isEmpty()){ if (companyInfo.getCompany_name() == null || companyInfo.getCompany_name().isEmpty()) {
map.put("msg","公司名称不能为空"); map.put("msg", "公司名称不能为空");
map.put("code","500"); map.put("code", "500");
return map; return map;
}if (companyInfo.getContact_name() == null || companyInfo.getContact_name().isEmpty()){ }
map.put("msg","联系人不能为空"); if (companyInfo.getContact_name() == null || companyInfo.getContact_name().isEmpty()) {
map.put("code","500"); map.put("msg", "联系人不能为空");
map.put("code", "500");
return map; return map;
}if (companyInfo.getPhone() == null || companyInfo.getPhone().isEmpty()) { }
if (companyInfo.getPhone() == null || companyInfo.getPhone().isEmpty()) {
map.put("msg", "手机号不能为空"); map.put("msg", "手机号不能为空");
map.put("code", "500"); map.put("code", "500");
return map; return map;
}if (companyInfo.getAddress() == null || companyInfo.getAddress().isEmpty()){ }
map.put("msg","地址不能为空"); if (companyInfo.getAddress() == null || companyInfo.getAddress().isEmpty()) {
map.put("code","500"); map.put("msg", "地址不能为空");
map.put("code", "500");
return map; return map;
}if (companyInfo.getCitys() == null || companyInfo.getCitys().isEmpty()){ }
map.put("msg","城市不能为空"); if (companyInfo.getCitys() == null || companyInfo.getCitys().isEmpty()) {
map.put("code","500"); map.put("msg", "城市不能为空");
map.put("code", "500");
return map; return map;
}if (companyInfo.getIs_delete() == null || companyInfo.getIs_delete().isEmpty()){ }
map.put("msg","删除状态不能为空"); if (companyInfo.getIs_delete() == null || companyInfo.getIs_delete().isEmpty()) {
map.put("code","500"); map.put("msg", "删除状态不能为空");
map.put("code", "500");
return map; return map;
}if (companyInfo.getbOpId() == null){ }
map.put("msg","租电平台运营商id不能为空,请补传'bOpId'"); if (companyInfo.getbOpId() == null) {
map.put("code","500"); map.put("msg", "租电平台运营商id不能为空,请补传'bOpId'");
map.put("code", "500");
return map; return map;
} }
@ -276,17 +282,17 @@ public class ReceiveServiceImpl implements ReceiveService {
// //
// } // }
if(companyInfoMapper.selectByOpId(companyInfo.getbOpId()) != null){ if (companyInfoMapper.selectByOpId(companyInfo.getbOpId()) != null) {
companyInfoMapper.updateByOpId(companyInfo); companyInfoMapper.updateByOpId(companyInfo);
} else if(companyInfoMapper.selectByPhone(companyInfo.getPhone())!=null){ } else if (companyInfoMapper.selectByPhone(companyInfo.getPhone()) != null) {
companyInfoMapper.updateByPhone(companyInfo); companyInfoMapper.updateByPhone(companyInfo);
}else { } else {
companyInfoMapper.insertCompanyInfo(companyInfo); companyInfoMapper.insertCompanyInfo(companyInfo);
} }
map.put("msg","成功"); map.put("msg", "成功");
map.put("code","200"); map.put("code", "200");
map.put("operator_id",companyInfo.getId().toString()); map.put("operator_id", companyInfo.getId().toString());
return map; return map;
} }
@ -295,69 +301,79 @@ public class ReceiveServiceImpl implements ReceiveService {
log.info("接收门店数据:", request); log.info("接收门店数据:", request);
SyncRequest<StoreInfo> syncRequest = JSON.parseObject(request, SyncRequest.class); SyncRequest<StoreInfo> syncRequest = JSON.parseObject(request, SyncRequest.class);
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
if(!syncRequest.getAppid().equals(appId)||!syncRequest.getAccessToken().equals(accessToken)){ if (!syncRequest.getAppid().equals(appId) || !syncRequest.getAccessToken().equals(accessToken)) {
map.put("msg","没有权限"); map.put("msg", "没有权限");
map.put("code","500"); map.put("code", "500");
return map; return map;
} }
StoreInfo storeInfo = JSON.parseObject(String.valueOf(syncRequest.getData()), StoreInfo.class); StoreInfo storeInfo = JSON.parseObject(String.valueOf(syncRequest.getData()), StoreInfo.class);
if (storeInfo.getName() == null || storeInfo.getName().isEmpty()){ if (storeInfo.getName() == null || storeInfo.getName().isEmpty()) {
map.put("msg","门店名称不能为空"); map.put("msg", "门店名称不能为空");
map.put("code","500"); map.put("code", "500");
return map; return map;
}if (storeInfo.getPhone() == null || storeInfo.getPhone().isEmpty()){ }
map.put("msg","门店手机号不能为空"); if (storeInfo.getPhone() == null || storeInfo.getPhone().isEmpty()) {
map.put("code","500"); map.put("msg", "门店手机号不能为空");
map.put("code", "500");
return map; return map;
}if (storeInfo.getProvince() == null || storeInfo.getProvince().isEmpty()){ }
map.put("msg","门店省份不能为空"); if (storeInfo.getProvince() == null || storeInfo.getProvince().isEmpty()) {
map.put("code","500"); map.put("msg", "门店省份不能为空");
map.put("code", "500");
return map; return map;
}if (storeInfo.getCity() == null || storeInfo.getCity().isEmpty()){ }
map.put("msg","门店城市不能为空"); if (storeInfo.getCity() == null || storeInfo.getCity().isEmpty()) {
map.put("code","500"); map.put("msg", "门店城市不能为空");
map.put("code", "500");
return map; return map;
}if (storeInfo.getAddress() == null || storeInfo.getAddress().isEmpty()){ }
map.put("msg","门店地址不能为空"); if (storeInfo.getAddress() == null || storeInfo.getAddress().isEmpty()) {
map.put("code","500"); map.put("msg", "门店地址不能为空");
map.put("code", "500");
return map; return map;
}if (storeInfo.getImage() == null || storeInfo.getImage().isEmpty()){ }
map.put("msg","门店照片不能为空"); if (storeInfo.getImage() == null || storeInfo.getImage().isEmpty()) {
map.put("code","500"); map.put("msg", "门店照片不能为空");
map.put("code", "500");
return map; return map;
}if (storeInfo.getLatitude() == null ){ }
map.put("msg","门店纬度不能为空"); if (storeInfo.getLatitude() == null) {
map.put("code","500"); map.put("msg", "门店纬度不能为空");
map.put("code", "500");
return map; return map;
}if (storeInfo.getLongitude() == null){ }
map.put("msg","门店经度不能为空"); if (storeInfo.getLongitude() == null) {
map.put("code","500"); map.put("msg", "门店经度不能为空");
map.put("code", "500");
return map; return map;
}if (storeInfo.getIs_delete() == null){ }
map.put("msg","门店删除状态不能为空"); if (storeInfo.getIs_delete() == null) {
map.put("code","500"); map.put("msg", "门店删除状态不能为空");
map.put("code", "500");
return map; return map;
}if (storeInfo.getContact_name() == null || storeInfo.getContact_name().isEmpty()){ }
map.put("msg","门店联系人不能为空"); if (storeInfo.getContact_name() == null || storeInfo.getContact_name().isEmpty()) {
map.put("code","500"); map.put("msg", "门店联系人不能为空");
map.put("code", "500");
return map; return map;
}if (storeInfo.getBpStoreId() == null){ }
map.put("msg","租电平台门店id不能为空,请补传'bpStoreId'"); if (storeInfo.getBpStoreId() == null) {
map.put("code","500"); map.put("msg", "租电平台门店id不能为空,请补传'bpStoreId'");
map.put("code", "500");
return map; return map;
} }
if(companyStoreMapper.selectByBid(storeInfo.getBpStoreId()) != null){ if (companyStoreMapper.selectByBid(storeInfo.getBpStoreId()) != null) {
companyStoreMapper.updateByBid(storeInfo); companyStoreMapper.updateByBid(storeInfo);
} else if(companyStoreMapper.selectByPhone(storeInfo.getPhone())!=null){ } else if (companyStoreMapper.selectByPhone(storeInfo.getPhone()) != null) {
companyStoreMapper.updateByName(storeInfo); companyStoreMapper.updateByName(storeInfo);
}else { } else {
companyStoreMapper.insertStoreInfo(storeInfo); companyStoreMapper.insertStoreInfo(storeInfo);
} }
map.put("msg","成功"); map.put("msg", "成功");
map.put("code","200"); map.put("code", "200");
map.put("store_id",storeInfo.getId().toString()); map.put("store_id", storeInfo.getId().toString());
return map; return map;
} }