增加空值判断

This commit is contained in:
2025-08-31 02:41:53 +08:00
parent 56a6157ca2
commit 549deb2164
8 changed files with 412 additions and 202 deletions

View File

@ -16,6 +16,9 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
import static com.sczx.sync.common.enums.ApiErrorCode.NOT_PERMISSION; import static com.sczx.sync.common.enums.ApiErrorCode.NOT_PERMISSION;
/** /**
@ -35,42 +38,26 @@ public class ReceiveBatteryController {
@ApiOperation(value = "接收租电数据接口") @ApiOperation(value = "接收租电数据接口")
@PostMapping("/batterymeal") @PostMapping("/batterymeal")
public Result batteryMeal(@RequestBody String receiveMealReq){ public Map<String, String> batteryMeal(@RequestBody String receiveMealReq) {
String code = receiveService.recceiveMeals(receiveMealReq); return receiveService.recceiveMeals(receiveMealReq);
if (code.equals(NOT_PERMISSION.getCode())){
return Result.fail(NOT_PERMISSION);
}
return Result.ok("200","操作成功","操作成功","Cid",code);
} }
@ApiOperation(value = "接收用户数据接口") @ApiOperation(value = "接收用户数据接口")
@PostMapping("/userinfo") @PostMapping("/userinfo")
public Result userInfo(@RequestBody String receiveMealReq){ public Map<String, String> userInfo(@RequestBody String receiveMealReq){
String code = receiveService.recceiveUserInfo(receiveMealReq); return receiveService.recceiveUserInfo(receiveMealReq);
if (code.equals(NOT_PERMISSION.getCode())){
return Result.fail(NOT_PERMISSION);
}
return Result.ok("200","操作成功","操作成功","Cid",code);
} }
@ApiOperation(value = "接收运营商数据接口") @ApiOperation(value = "接收运营商数据接口")
@PostMapping("/companyinfo") @PostMapping("/companyinfo")
public Result companyInfo(@RequestBody String receiveMealReq){ public Map<String, String> companyInfo(@RequestBody String receiveMealReq){
String code = receiveService.recceiveCompanyInfo(receiveMealReq); return receiveService.recceiveCompanyInfo(receiveMealReq);
if (code.equals(NOT_PERMISSION.getCode())){
return Result.fail(NOT_PERMISSION);
}
return Result.ok("200","操作成功","操作成功","Cid",code);
} }
@ApiOperation(value = "接收门店数据接口") @ApiOperation(value = "接收门店数据接口")
@PostMapping("/storeinfo") @PostMapping("/storeinfo")
public Result storeInfo(@RequestBody String receiveMealReq){ public Map<String, String> storeInfo(@RequestBody String receiveMealReq){
String code = receiveService.recceiveStoreInfo(receiveMealReq); return receiveService.recceiveStoreInfo(receiveMealReq);
if (code.equals(NOT_PERMISSION.getCode())){
return Result.fail(NOT_PERMISSION);
}
return Result.ok("200","操作成功","操作成功","Cid",code);
} }

View File

@ -32,9 +32,6 @@ public class SendDataController {
@Autowired @Autowired
private SendDataService sendDataService; private SendDataService sendDataService;
@Autowired
private CompanyStoreMapper companyStoreMapper;
@ApiOperation(value = "接收需同步数据接口") @ApiOperation(value = "接收需同步数据接口")
@PostMapping("/dataToBattery") @PostMapping("/dataToBattery")
public Result sendDataToBattery(@RequestBody DataRceiveReq dataRceiveReq){ public Result sendDataToBattery(@RequestBody DataRceiveReq dataRceiveReq){
@ -49,20 +46,21 @@ public class SendDataController {
@ApiOperation(value = "接收运营商同步数据接口") @ApiOperation(value = "接收运营商同步数据接口")
@GetMapping("/companyinfo/{id}") @GetMapping("/companyinfo/{id}")
public Result sendCompanyInfoToBattery(@PathVariable String id){ public Map<String,String> sendCompanyInfoToBattery(@PathVariable String id){
return Result.ok(sendDataService.sendCompanyInfoToBattery(Long.parseLong(id))); Map<String, String> map = sendDataService.sendCompanyInfoToBattery(Long.parseLong(id));
return map;
} }
@ApiOperation(value = "接收门店同步数据接口") @ApiOperation(value = "接收门店同步数据接口")
@GetMapping("/storeinfo/{id}") @GetMapping("/storeinfo/{id}")
public Result sendStoreInfoToBattery(@PathVariable String id){ public Map<String,String> sendStoreInfoToBattery(@PathVariable String id){
return Result.ok(sendDataService.sendStoreInfoToBattery(Long.parseLong(id))); return sendDataService.sendStoreInfoToBattery(Long.parseLong(id));
} }
@ApiOperation(value = "接收充电同步数据接口") @ApiOperation(value = "接收充电同步数据接口")
@GetMapping("/subOrder/{id}") @GetMapping("/subOrder/{id}")
public Result sendSubOrderToBattery(@PathVariable String id){ public Map<String,String> sendSubOrderToBattery(@PathVariable String id){
return Result.ok(sendDataService.sendSubOrderToBattery(Long.parseLong(id))); return sendDataService.sendSubOrderToBattery(Long.parseLong(id));
} }
// //

View File

@ -2,17 +2,19 @@ package com.sczx.sync.po;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@TableName("zc_rent_battey_rule") @TableName("zc_rent_battey_rule")
@Data
public class BatteryRule implements Serializable { public class BatteryRule implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@TableField("id") @TableField("id")
private Long id; private Long id;
@TableField("meal_id") @TableField("meal_id")
private Integer mealId; private Integer meal_id;
@TableField("title") @TableField("title")
private String title; private String title;
@TableField("detail") @TableField("detail")
@ -22,129 +24,30 @@ public class BatteryRule implements Serializable {
@TableField("ah") @TableField("ah")
private Integer ah; private Integer ah;
@TableField("rent_price") @TableField("rent_price")
private Double rentPrice; private Double rent_price;
@TableField("duration_type") @TableField("duration_type")
private Integer durationType; private Integer duration_type;
@TableField("duration") @TableField("duration")
private Integer duration; private Integer duration;
@TableField("city_id") @TableField("city_id")
private Integer cityId; private Integer city;
@TableField("province_id") @TableField("province_id")
private Integer provinceId; private Integer province;
@TableField("category_id") @TableField("category_id")
private Integer categoryId; private Integer category_id;
@TableField("operator_id") @TableField("operator_id")
private Integer operatorId; private Integer operator_id;
private LocalDateTime syncTime; private LocalDateTime syncTime;
public LocalDateTime getSyncTime() { public LocalDateTime getSyncTime() {
return syncTime; return syncTime;
} }
public void setSyncTime(LocalDateTime syncTime) { public void setSyncTime(LocalDateTime syncTime) {
this.syncTime = syncTime; this.syncTime = syncTime;
} }
// Getters and Setters
public void setId(Long id) { this.id = id;}
public Long getId() { return id; }
public Integer getMealId() {
return mealId;
}
public void setMealId(Integer mealId) {
this.mealId = mealId;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDetail() {
return detail;
}
public void setDetail(String detail) {
this.detail = detail;
}
public Integer getVoltage() {
return voltage;
}
public void setVoltage(Integer voltage) {
this.voltage = voltage;
}
public Integer getAh() {
return ah;
}
public void setAh(Integer ah) {
this.ah = ah;
}
public Double getRentPrice() {
return rentPrice;
}
public void setRentPrice(Double rentPrice) {
this.rentPrice = rentPrice;
}
public Integer getDurationType() {
return durationType;
}
public void setDurationType(Integer durationType) {
this.durationType = durationType;
}
public Integer getDuration() {
return duration;
}
public void setDuration(Integer duration) {
this.duration = duration;
}
public Integer getCityId() {
return cityId;
}
public void setCityId(Integer cityId) {
this.cityId = cityId;
}
public Integer getProvinceId() {
return provinceId;
}
public void setProvinceId(Integer provinceId) {
this.provinceId = provinceId;
}
public Integer getCategoryId() {
return categoryId;
}
public void setCategoryId(Integer categoryId) {
this.categoryId = categoryId;
}
public Integer getOperatorId() {
return operatorId;
}
public void setOperatorId(Integer operatorId) {
this.operatorId = operatorId;
}
} }

View File

@ -1,12 +1,14 @@
package com.sczx.sync.service; package com.sczx.sync.service;
import java.util.Map;
public interface ReceiveService { public interface ReceiveService {
String recceiveMeals(String request); Map<String, String> recceiveMeals(String request);
String recceiveUserInfo(String request); Map<String, String> recceiveUserInfo(String request);
String recceiveCompanyInfo(String request); Map<String, String> recceiveCompanyInfo(String request);
String recceiveStoreInfo(String request); Map<String, String> recceiveStoreInfo(String request);
} }

View File

@ -2,6 +2,8 @@ package com.sczx.sync.service;
import com.sczx.sync.dto.DataRceiveReq; import com.sczx.sync.dto.DataRceiveReq;
import java.util.Map;
public interface SendDataService { public interface SendDataService {
/** /**
@ -14,11 +16,11 @@ public interface SendDataService {
boolean sendUserInfoById(Long id); boolean sendUserInfoById(Long id);
boolean sendCompanyInfoToBattery(Long id); Map<String, String> sendCompanyInfoToBattery(Long id);
boolean sendStoreInfoToBattery(Long id); Map<String, String> sendStoreInfoToBattery(Long id);
boolean sendSubOrderToBattery(Long id); Map<String,String> sendSubOrderToBattery(Long id);
/** /**
* 异步转发数据到第三方平台 * 异步转发数据到第三方平台
* *

View File

@ -19,6 +19,8 @@ import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import static com.sczx.sync.common.enums.ApiErrorCode.NOT_PERMISSION; import static com.sczx.sync.common.enums.ApiErrorCode.NOT_PERMISSION;
@ -45,37 +47,128 @@ public class ReceiveServiceImpl implements ReceiveService {
private String accessToken; private String accessToken;
@Override @Override
public 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<>();
if(!syncRequest.getAppid().equals(appId)||!syncRequest.getAccessToken().equals(accessToken)){ if(!syncRequest.getAppid().equals(appId)||!syncRequest.getAccessToken().equals(accessToken)){
return NOT_PERMISSION.getCode(); map.put("msg","没有权限");
map.put("code","500");
return map;
} }
BatteryRule batteryRule = JSON.parseObject(String.valueOf(syncRequest.getData()), BatteryRule.class); BatteryRule batteryRule = JSON.parseObject(String.valueOf(syncRequest.getData()), BatteryRule.class);
batteryRule.setSyncTime(LocalDateTime.now()); if (batteryRule.getTitle() == null || batteryRule.getTitle().isEmpty()){
QueryWrapper<BatteryRule> syncDataInfoQueryWrapper = new QueryWrapper<>(); map.put("msg","套餐名称不能为空");
QueryWrapper<BatteryRule> eq = syncDataInfoQueryWrapper.eq("meal_id", batteryRule.getMealId()); map.put("code","500");
return map;
if (batteryMealMapper.selectOne(eq) != null) { }if (batteryRule.getDetail() == null || batteryRule.getDetail().isEmpty()){
batteryMealMapper.updateBatteryRule(batteryRule); map.put("msg","套餐详情不能为空");
} else { map.put("code","500");
batteryMealMapper.insertZcRentBatteyRule(batteryRule); 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;
}
if (batteryRule.getRent_price() == null){
map.put("msg","套餐价格不能为空");
map.put("code","500");
return map;
}
if (batteryRule.getDuration() == null){
map.put("msg","套餐时长不能为空");
map.put("code","500");
return map;
}
if (batteryRule.getCity() == null){
map.put("msg","套餐城市不能为空");
map.put("code","500");
return map;
}
if (batteryRule.getProvince() == null){
map.put("msg","套餐省份不能为空");
map.put("code","500");
return map;
}
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");
return map;
} }
return batteryRule.getId() + ""; batteryRule.setSyncTime(LocalDateTime.now());
QueryWrapper<BatteryRule> syncDataInfoQueryWrapper = new QueryWrapper<>();
QueryWrapper<BatteryRule> eq = syncDataInfoQueryWrapper.eq("meal_id", batteryRule.getMeal_id());
if (batteryMealMapper.selectOne(eq) != null) {
batteryRule.setOperator_id(companyInfo.getId().intValue());
batteryMealMapper.updateBatteryRule(batteryRule);
} else {
batteryRule.setOperator_id(companyInfo.getId().intValue());
batteryMealMapper.insertZcRentBatteyRule(batteryRule);
}
map.put("msg","套餐同步成功");
map.put("code","200");
return map;
} }
@Override @Override
public String recceiveUserInfo(String request) { public Map<String, String> recceiveUserInfo(String request) {
SyncRequest<UserInfo> syncRequest = JSON.parseObject(request, SyncRequest.class); SyncRequest<UserInfo> syncRequest = JSON.parseObject(request, SyncRequest.class);
Map<String, String> map = new HashMap<>();
if(!syncRequest.getAppid().equals(appId)||!syncRequest.getAccessToken().equals(accessToken)){ if(!syncRequest.getAppid().equals(appId)||!syncRequest.getAccessToken().equals(accessToken)){
return NOT_PERMISSION.getCode(); map.put("msg","没有权限");
map.put("code","500");
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()){
map.put("msg","手机号不能为空");
map.put("code","500");
return map;
}
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");
return map;
}if (user.getIsmerchant() == null) {
map.put("msg", "用户类型不能为空");
map.put("code", "500");
return map;
}
BaseUser baseUser = new BaseUser(); BaseUser baseUser = new BaseUser();
baseUser.setUserName(user.getPhone()); baseUser.setUserName(user.getPhone());
@ -111,20 +204,55 @@ public class ReceiveServiceImpl implements ReceiveService {
userStore.setUpdateTime(LocalDateTime.now()); userStore.setUpdateTime(LocalDateTime.now());
userStoreMapper.insertUserStore(userStore) ; userStoreMapper.insertUserStore(userStore) ;
} }
map.put("msg","成功");
map.put("code","200");
return baseUserId + ""; return map;
} }
@Override @Override
public String recceiveCompanyInfo(String request) { public Map<String, String> recceiveCompanyInfo(String request) {
SyncRequest<CompanyInfo> syncRequest = JSON.parseObject(request, SyncRequest.class); SyncRequest<CompanyInfo> syncRequest = JSON.parseObject(request, SyncRequest.class);
Map<String, String> map = new HashMap<>();
if(!syncRequest.getAppid().equals(appId)||!syncRequest.getAccessToken().equals(accessToken)){ if(!syncRequest.getAppid().equals(appId)||!syncRequest.getAccessToken().equals(accessToken)){
return NOT_PERMISSION.getCode(); map.put("msg","没有权限");
map.put("code","500");
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()){
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");
return map;
}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");
return map;
}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");
return map;
}if (companyInfo.getbOpId() == null){
map.put("msg","租电平台运营商id不能为空,请补传'bOpId'");
map.put("code","500");
return map;
}
if (companyInfoMapper.selectByCompanyName(companyInfo.getCompanyName())!=null){ if (companyInfoMapper.selectByCompanyName(companyInfo.getCompanyName())!=null){
} }
@ -136,18 +264,67 @@ public class ReceiveServiceImpl implements ReceiveService {
}else { }else {
companyInfoMapper.insertCompanyInfo(companyInfo); companyInfoMapper.insertCompanyInfo(companyInfo);
} }
return companyInfo.getId() + "";
map.put("msg","成功");
map.put("code","200");
map.put("operator_id",companyInfo.getId().toString());
return map;
} }
@Override @Override
public String recceiveStoreInfo(String request) { public Map<String, String> recceiveStoreInfo(String request) {
SyncRequest<StoreInfo> syncRequest = JSON.parseObject(request, SyncRequest.class); SyncRequest<StoreInfo> syncRequest = JSON.parseObject(request, SyncRequest.class);
Map<String, String> map = new HashMap<>();
if(!syncRequest.getAppid().equals(appId)||!syncRequest.getAccessToken().equals(accessToken)){ if(!syncRequest.getAppid().equals(appId)||!syncRequest.getAccessToken().equals(accessToken)){
return NOT_PERMISSION.getCode(); map.put("msg","没有权限");
map.put("code","500");
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()){
map.put("msg","门店名称不能为空");
map.put("code","500");
return map;
}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");
return map;
}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");
return map;
}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");
return map;
}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");
return map;
}if (storeInfo.getContact_name() == null || storeInfo.getContact_name().isEmpty()){
map.put("msg","门店联系人不能为空");
map.put("code","500");
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){
@ -155,8 +332,10 @@ public class ReceiveServiceImpl implements ReceiveService {
}else { }else {
companyStoreMapper.insertStoreInfo(storeInfo); companyStoreMapper.insertStoreInfo(storeInfo);
} }
return storeInfo.getId() + ""; map.put("msg","成功");
map.put("code","200");
map.put("store_id",storeInfo.getId().toString());
return map;
} }
} }

View File

@ -18,10 +18,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.HashSet; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
@Slf4j @Slf4j
@Service @Service
@ -107,9 +104,38 @@ public class SendDataServiceImpl implements SendDataService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean sendCompanyInfoToBattery(Long id) { public Map<String, String> sendCompanyInfoToBattery(Long id) {
CompanyInfo company = companyInfoMapper.selectById( id); CompanyInfo company = companyInfoMapper.selectById( id);
List<StoreInfo> storeInfoList = companyStoreMapper.selectByOpId(id); List<StoreInfo> storeInfoList = companyStoreMapper.selectByOpId(id);
Map<String, String> map = new HashMap<>();
if(company == null){
map.put("msg","未找到此商户信息");
map.put("code","500");
return map;
}
if (company.getCompanyName() == null || company.getCompanyName().isEmpty()){
map.put("msg","运营商名称不能为空");
map.put("code","500");
return map;
}
if (company.getContactName() == null || company.getContactName().isEmpty()){
map.put("msg","运营商联系人不能为空");
map.put("code","500");
return map;
}if (company.getPhone() == null || company.getPhone().isEmpty()){
map.put("msg","运营商手机号不能为空");
map.put("code","500");
return map;
}if (company.getAddress() == null || company.getAddress().isEmpty()){
map.put("msg","运营商地址不能为空");
map.put("code","500");
return map;
}if (company.getCitys() == null || company.getCitys().isEmpty()){
map.put("msg","运营商城市不能为空");
map.put("code","500");
return map;
}
CompanyInfo companyInfo = new CompanyInfo(); CompanyInfo companyInfo = new CompanyInfo();
companyInfo.setCompany_name(company.getCompanyName()); companyInfo.setCompany_name(company.getCompanyName());
@ -134,29 +160,142 @@ public class SendDataServiceImpl implements SendDataService {
SyncRequest syncRequest = new SyncRequest(); SyncRequest syncRequest = new SyncRequest();
syncRequest.setData(companyInfo); syncRequest.setData(companyInfo);
return saveRecord(syncRequest, URL + "/companyinfo", id,"companyinfo"); if(saveRecord(syncRequest, URL + "/companyinfo", id,"companyinfo")){
map.put("msg","发送成功");
map.put("code","200");
}else {
map.put("msg","发送失败");
map.put("code","500");
}
return map;
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean sendStoreInfoToBattery(Long id) { public Map<String, String> sendStoreInfoToBattery(Long id) {
StoreInfo storeInfo = companyStoreMapper.selectById(id); StoreInfo storeInfo = companyStoreMapper.selectById(id);
Map<String, String> map = new HashMap<>();
if(storeInfo == null){
map.put("msg","未找到此门店信息");
map.put("code","500");
return map;
}
if (storeInfo.getName() == null || storeInfo.getName().isEmpty()){
map.put("msg","门店名称不能为空");
map.put("code","500");
return map;
}
if (storeInfo.getContactName() == null || storeInfo.getContactName().isEmpty()){
map.put("msg","门店联系人不能为空");
map.put("code","500");
return map;
}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");
return map;
}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");
return map;
}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");
return map;
}if (storeInfo.getLongitude() == null){
map.put("msg","门店经度不能为空");
map.put("code","500");
}
SyncRequest syncRequest = new SyncRequest(); SyncRequest syncRequest = new SyncRequest();
syncRequest.setData(storeInfo); syncRequest.setData(storeInfo);
return saveRecord(syncRequest,URL+"/storeinfo",id,"storeinfo"); if(saveRecord(syncRequest,URL+"/storeinfo",id,"storeinfo")){
map.put("msg","发送成功");
map.put("code","200");
}else {
map.put("msg","发送失败");
map.put("code","500");
}
return map;
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean sendSubOrderToBattery(Long id) { public Map<String,String> sendSubOrderToBattery(Long id) {
OrderBatteryInfo orderBatteryInfo = orderBatteryInfoMapper.selectOrderBatteryInfoById(id); OrderBatteryInfo orderBatteryInfo = orderBatteryInfoMapper.selectOrderBatteryInfoById(id);
Map<String, String> map = new HashMap<>();
if(orderBatteryInfo == null){
map.put("msg","未找到此租电订单信息");
map.put("code","500");
return map;
}
if (orderBatteryInfo.getPhone() == null || orderBatteryInfo.getPhone().isEmpty()){
map.put("msg","租电订单手机号不能为空");
map.put("code","500");
return map;
}
if (orderBatteryInfo.getStart_date() == null || orderBatteryInfo.getStart_date().isEmpty()){
map.put("msg","租电订单开始时间不能为空");
map.put("code","500");
return map;
}
if(orderBatteryInfo.getEnd_date() == null || orderBatteryInfo.getEnd_date().isEmpty()){
map.put("msg","租电订单结束时间不能为空");
map.put("code","500");
return map;
}
if (orderBatteryInfo.getCity() == null ) {
map.put("msg","租电订单城市不能为空");
map.put("code","500");
return map;
}
if (orderBatteryInfo.getStore() == null){
map.put("msg","租电订单门店不能为空");
map.put("code","500");
return map;
}
if (orderBatteryInfo.getCategory() == null){
map.put("msg","电池类别不能为空");
map.put("code","500");
return map;
}
if (orderBatteryInfo.getOperator_id() == null){
map.put("msg","运营商ID不能为空");
map.put("code","500");
return map;
}
if (orderBatteryInfo.getOrder_no() == null){
map.put("msg","租电订单编号不能为空");
map.put("code","500");
return map;
}
SyncRequest syncRequest = new SyncRequest(); SyncRequest syncRequest = new SyncRequest();
syncRequest.setData(orderBatteryInfo); syncRequest.setData(orderBatteryInfo);
return saveRecord(syncRequest,URL+"/batteryorder",id,"batteryorder"); if (saveRecord(syncRequest,URL+"/batteryorder",id,"batteryorder")){
map.put("msg","发送成功");
map.put("code","200");
}
else {
map.put("msg","发送失败");
map.put("code","500");
}
return map;
} }

View File

@ -11,14 +11,14 @@
<if test="voltage != null and voltage != ''">voltage,</if> <if test="voltage != null and voltage != ''">voltage,</if>
<if test="ah != null and ah != ''">ah,</if> <if test="ah != null and ah != ''">ah,</if>
<if test="rentPrice != null">rent_price,</if> <if test="rent_price != null">rent_price,</if>
<if test="durationType != null">duration_type,</if> <if test="duration_type != null">duration_type,</if>
<if test="duration != null">duration,</if> <if test="duration != null">duration,</if>
<if test="cityId != null">city_id,</if> <if test="city != null">city_id,</if>
<if test="operatorId != null">operator_id,</if> <if test="operator_id != null">operator_id,</if>
<if test="provinceId != null">province_id,</if> <if test="province != null">province_id,</if>
<if test="categoryId != null">category_id,</if> <if test="category_id != null">category_id,</if>
<if test="mealId != null">meal_id,</if> <if test="meal_id != null">meal_id,</if>
<if test="syncTime != null">sync_time,</if> <if test="syncTime != null">sync_time,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
@ -26,14 +26,14 @@
<if test="detail != null and detail != ''">#{detail},</if> <if test="detail != null and detail != ''">#{detail},</if>
<if test="voltage != null and voltage != ''">#{voltage},</if> <if test="voltage != null and voltage != ''">#{voltage},</if>
<if test="ah != null and ah != ''">#{ah},</if> <if test="ah != null and ah != ''">#{ah},</if>
<if test="rentPrice != null">#{rentPrice},</if> <if test="rent_price != null">#{rent_price},</if>
<if test="durationType != null">#{durationType},</if> <if test="duration_type != null">#{duration_type},</if>
<if test="duration != null">#{duration},</if> <if test="duration != null">#{duration},</if>
<if test="cityId != null">#{cityId},</if> <if test="city != null">#{city},</if>
<if test="operatorId != null">#{operatorId},</if> <if test="operator_id != null">#{operator_id},</if>
<if test="provinceId != null">#{provinceId},</if> <if test="province != null">#{province},</if>
<if test="categoryId != null">#{categoryId},</if> <if test="category_id != null">#{category_id},</if>
<if test="mealId != null">#{mealId},</if> <if test="meal_id != null">#{meal_id},</if>
<if test="syncTime != null">#{syncTime},</if> <if test="syncTime != null">#{syncTime},</if>
</trim> </trim>
</insert> </insert>
@ -51,13 +51,13 @@
<if test="detail != null and detail != ''">detail = #{detail},</if> <if test="detail != null and detail != ''">detail = #{detail},</if>
<if test="voltage != null and voltage != ''">voltage = #{voltage},</if> <if test="voltage != null and voltage != ''">voltage = #{voltage},</if>
<if test="ah != null and ah != ''">ah = #{ah},</if> <if test="ah != null and ah != ''">ah = #{ah},</if>
<if test="rentPrice != null">rent_price = #{rentPrice},</if> <if test="rent_price != null">rent_price = #{rent_price},</if>
<if test="durationType != null">duration_type = #{durationType},</if> <if test="duration_type != null">duration_type = #{duration_type},</if>
<if test="duration != null">duration = #{duration},</if> <if test="duration != null">duration = #{duration},</if>
<if test="cityId != null">city_id = #{cityId},</if> <if test="city != null">city_id = #{city},</if>
<if test="operatorId != null">operator_id = #{operatorId},</if> <if test="operator_id != null">operator_id = #{operator_id},</if>
<if test="provinceId != null">province_id = #{provinceId},</if> <if test="province != null">province_id = #{province},</if>
<if test="categoryId != null">category_id = #{categoryId},</if> <if test="category_id != null">category_id = #{category_id},</if>
<if test="syncTime != null">sync_time = #{syncTime},</if> <if test="syncTime != null">sync_time = #{syncTime},</if>
</trim> </trim>
where meal_id = #{mealId} where meal_id = #{mealId}