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