增加空值判断
This commit is contained in:
@ -16,6 +16,9 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static com.sczx.sync.common.enums.ApiErrorCode.NOT_PERMISSION;
|
||||
|
||||
/**
|
||||
@ -35,42 +38,26 @@ public class ReceiveBatteryController {
|
||||
|
||||
@ApiOperation(value = "接收租电数据接口")
|
||||
@PostMapping("/batterymeal")
|
||||
public Result batteryMeal(@RequestBody String receiveMealReq){
|
||||
String code = receiveService.recceiveMeals(receiveMealReq);
|
||||
if (code.equals(NOT_PERMISSION.getCode())){
|
||||
return Result.fail(NOT_PERMISSION);
|
||||
}
|
||||
return Result.ok("200","操作成功","操作成功","Cid",code);
|
||||
public Map<String, String> batteryMeal(@RequestBody String receiveMealReq) {
|
||||
return receiveService.recceiveMeals(receiveMealReq);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "接收用户数据接口")
|
||||
@PostMapping("/userinfo")
|
||||
public Result userInfo(@RequestBody String receiveMealReq){
|
||||
String code = receiveService.recceiveUserInfo(receiveMealReq);
|
||||
if (code.equals(NOT_PERMISSION.getCode())){
|
||||
return Result.fail(NOT_PERMISSION);
|
||||
}
|
||||
return Result.ok("200","操作成功","操作成功","Cid",code);
|
||||
public Map<String, String> userInfo(@RequestBody String receiveMealReq){
|
||||
return receiveService.recceiveUserInfo(receiveMealReq);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "接收运营商数据接口")
|
||||
@PostMapping("/companyinfo")
|
||||
public Result companyInfo(@RequestBody String receiveMealReq){
|
||||
String code = receiveService.recceiveCompanyInfo(receiveMealReq);
|
||||
if (code.equals(NOT_PERMISSION.getCode())){
|
||||
return Result.fail(NOT_PERMISSION);
|
||||
}
|
||||
return Result.ok("200","操作成功","操作成功","Cid",code);
|
||||
public Map<String, String> companyInfo(@RequestBody String receiveMealReq){
|
||||
return receiveService.recceiveCompanyInfo(receiveMealReq);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "接收门店数据接口")
|
||||
@PostMapping("/storeinfo")
|
||||
public Result storeInfo(@RequestBody String receiveMealReq){
|
||||
String code = receiveService.recceiveStoreInfo(receiveMealReq);
|
||||
if (code.equals(NOT_PERMISSION.getCode())){
|
||||
return Result.fail(NOT_PERMISSION);
|
||||
}
|
||||
return Result.ok("200","操作成功","操作成功","Cid",code);
|
||||
public Map<String, String> storeInfo(@RequestBody String receiveMealReq){
|
||||
return receiveService.recceiveStoreInfo(receiveMealReq);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -32,9 +32,6 @@ public class SendDataController {
|
||||
@Autowired
|
||||
private SendDataService sendDataService;
|
||||
|
||||
@Autowired
|
||||
private CompanyStoreMapper companyStoreMapper;
|
||||
|
||||
@ApiOperation(value = "接收需同步数据接口")
|
||||
@PostMapping("/dataToBattery")
|
||||
public Result sendDataToBattery(@RequestBody DataRceiveReq dataRceiveReq){
|
||||
@ -49,20 +46,21 @@ public class SendDataController {
|
||||
|
||||
@ApiOperation(value = "接收运营商同步数据接口")
|
||||
@GetMapping("/companyinfo/{id}")
|
||||
public Result sendCompanyInfoToBattery(@PathVariable String id){
|
||||
return Result.ok(sendDataService.sendCompanyInfoToBattery(Long.parseLong(id)));
|
||||
public Map<String,String> sendCompanyInfoToBattery(@PathVariable String id){
|
||||
Map<String, String> map = sendDataService.sendCompanyInfoToBattery(Long.parseLong(id));
|
||||
return map;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "接收门店同步数据接口")
|
||||
@GetMapping("/storeinfo/{id}")
|
||||
public Result sendStoreInfoToBattery(@PathVariable String id){
|
||||
return Result.ok(sendDataService.sendStoreInfoToBattery(Long.parseLong(id)));
|
||||
public Map<String,String> sendStoreInfoToBattery(@PathVariable String id){
|
||||
return sendDataService.sendStoreInfoToBattery(Long.parseLong(id));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "接收充电同步数据接口")
|
||||
@GetMapping("/subOrder/{id}")
|
||||
public Result sendSubOrderToBattery(@PathVariable String id){
|
||||
return Result.ok(sendDataService.sendSubOrderToBattery(Long.parseLong(id)));
|
||||
public Map<String,String> sendSubOrderToBattery(@PathVariable String id){
|
||||
return sendDataService.sendSubOrderToBattery(Long.parseLong(id));
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@ -2,17 +2,19 @@ package com.sczx.sync.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@TableName("zc_rent_battey_rule")
|
||||
@Data
|
||||
public class BatteryRule implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableField("id")
|
||||
private Long id;
|
||||
@TableField("meal_id")
|
||||
private Integer mealId;
|
||||
private Integer meal_id;
|
||||
@TableField("title")
|
||||
private String title;
|
||||
@TableField("detail")
|
||||
@ -22,129 +24,30 @@ public class BatteryRule implements Serializable {
|
||||
@TableField("ah")
|
||||
private Integer ah;
|
||||
@TableField("rent_price")
|
||||
private Double rentPrice;
|
||||
private Double rent_price;
|
||||
@TableField("duration_type")
|
||||
private Integer durationType;
|
||||
private Integer duration_type;
|
||||
@TableField("duration")
|
||||
private Integer duration;
|
||||
@TableField("city_id")
|
||||
private Integer cityId;
|
||||
private Integer city;
|
||||
@TableField("province_id")
|
||||
private Integer provinceId;
|
||||
private Integer province;
|
||||
@TableField("category_id")
|
||||
private Integer categoryId;
|
||||
private Integer category_id;
|
||||
@TableField("operator_id")
|
||||
private Integer operatorId;
|
||||
private Integer operator_id;
|
||||
private LocalDateTime syncTime;
|
||||
public LocalDateTime getSyncTime() {
|
||||
return syncTime;
|
||||
}
|
||||
|
||||
|
||||
public void setSyncTime(LocalDateTime 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;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,12 +1,14 @@
|
||||
package com.sczx.sync.service;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -2,6 +2,8 @@ package com.sczx.sync.service;
|
||||
|
||||
import com.sczx.sync.dto.DataRceiveReq;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface SendDataService {
|
||||
|
||||
/**
|
||||
@ -14,11 +16,11 @@ public interface SendDataService {
|
||||
|
||||
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);
|
||||
/**
|
||||
* 异步转发数据到第三方平台
|
||||
*
|
||||
|
||||
@ -19,6 +19,8 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.sczx.sync.common.enums.ApiErrorCode.NOT_PERMISSION;
|
||||
|
||||
@ -45,37 +47,128 @@ public class ReceiveServiceImpl implements ReceiveService {
|
||||
private String accessToken;
|
||||
|
||||
@Override
|
||||
public String recceiveMeals(String request) {
|
||||
public Map<String, String> recceiveMeals(String request) {
|
||||
|
||||
SyncRequest<BatteryRule> syncRequest = JSON.parseObject(request, SyncRequest.class);
|
||||
|
||||
Map<String, String> map = new HashMap<>();
|
||||
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.setSyncTime(LocalDateTime.now());
|
||||
QueryWrapper<BatteryRule> syncDataInfoQueryWrapper = new QueryWrapper<>();
|
||||
QueryWrapper<BatteryRule> eq = syncDataInfoQueryWrapper.eq("meal_id", batteryRule.getMealId());
|
||||
|
||||
if (batteryMealMapper.selectOne(eq) != null) {
|
||||
batteryMealMapper.updateBatteryRule(batteryRule);
|
||||
} else {
|
||||
batteryMealMapper.insertZcRentBatteyRule(batteryRule);
|
||||
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");
|
||||
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
|
||||
public String recceiveUserInfo(String request) {
|
||||
public Map<String, String> recceiveUserInfo(String request) {
|
||||
|
||||
SyncRequest<UserInfo> syncRequest = JSON.parseObject(request, SyncRequest.class);
|
||||
|
||||
Map<String, String> map = new HashMap<>();
|
||||
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);
|
||||
|
||||
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.setUserName(user.getPhone());
|
||||
@ -111,20 +204,55 @@ public class ReceiveServiceImpl implements ReceiveService {
|
||||
userStore.setUpdateTime(LocalDateTime.now());
|
||||
userStoreMapper.insertUserStore(userStore) ;
|
||||
}
|
||||
map.put("msg","成功");
|
||||
map.put("code","200");
|
||||
|
||||
|
||||
return baseUserId + "";
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String recceiveCompanyInfo(String request) {
|
||||
public Map<String, String> recceiveCompanyInfo(String request) {
|
||||
SyncRequest<CompanyInfo> syncRequest = JSON.parseObject(request, SyncRequest.class);
|
||||
|
||||
Map<String, String> map = new HashMap<>();
|
||||
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);
|
||||
|
||||
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){
|
||||
|
||||
}
|
||||
@ -136,18 +264,67 @@ public class ReceiveServiceImpl implements ReceiveService {
|
||||
}else {
|
||||
companyInfoMapper.insertCompanyInfo(companyInfo);
|
||||
}
|
||||
return companyInfo.getId() + "";
|
||||
|
||||
map.put("msg","成功");
|
||||
map.put("code","200");
|
||||
map.put("operator_id",companyInfo.getId().toString());
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String recceiveStoreInfo(String request) {
|
||||
public Map<String, String> recceiveStoreInfo(String request) {
|
||||
SyncRequest<StoreInfo> syncRequest = JSON.parseObject(request, SyncRequest.class);
|
||||
|
||||
Map<String, String> map = new HashMap<>();
|
||||
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);
|
||||
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){
|
||||
companyStoreMapper.updateByBid(storeInfo);
|
||||
} else if(companyStoreMapper.selectByPhone(storeInfo.getPhone())!=null){
|
||||
@ -155,8 +332,10 @@ public class ReceiveServiceImpl implements ReceiveService {
|
||||
}else {
|
||||
companyStoreMapper.insertStoreInfo(storeInfo);
|
||||
}
|
||||
return storeInfo.getId() + "";
|
||||
|
||||
map.put("msg","成功");
|
||||
map.put("code","200");
|
||||
map.put("store_id",storeInfo.getId().toString());
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -18,10 +18,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@ -107,9 +104,38 @@ public class SendDataServiceImpl implements SendDataService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean sendCompanyInfoToBattery(Long id) {
|
||||
public Map<String, String> sendCompanyInfoToBattery(Long id) {
|
||||
CompanyInfo company = companyInfoMapper.selectById( 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.setCompany_name(company.getCompanyName());
|
||||
@ -134,29 +160,142 @@ public class SendDataServiceImpl implements SendDataService {
|
||||
|
||||
SyncRequest syncRequest = new SyncRequest();
|
||||
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
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean sendStoreInfoToBattery(Long id) {
|
||||
public Map<String, String> sendStoreInfoToBattery(Long 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.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
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean sendSubOrderToBattery(Long id) {
|
||||
public Map<String,String> sendSubOrderToBattery(Long 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.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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -11,14 +11,14 @@
|
||||
<if test="voltage != null and voltage != ''">voltage,</if>
|
||||
<if test="ah != null and ah != ''">ah,</if>
|
||||
|
||||
<if test="rentPrice != null">rent_price,</if>
|
||||
<if test="durationType != null">duration_type,</if>
|
||||
<if test="rent_price != null">rent_price,</if>
|
||||
<if test="duration_type != null">duration_type,</if>
|
||||
<if test="duration != null">duration,</if>
|
||||
<if test="cityId != null">city_id,</if>
|
||||
<if test="operatorId != null">operator_id,</if>
|
||||
<if test="provinceId != null">province_id,</if>
|
||||
<if test="categoryId != null">category_id,</if>
|
||||
<if test="mealId != null">meal_id,</if>
|
||||
<if test="city != null">city_id,</if>
|
||||
<if test="operator_id != null">operator_id,</if>
|
||||
<if test="province != null">province_id,</if>
|
||||
<if test="category_id != null">category_id,</if>
|
||||
<if test="meal_id != null">meal_id,</if>
|
||||
<if test="syncTime != null">sync_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
@ -26,14 +26,14 @@
|
||||
<if test="detail != null and detail != ''">#{detail},</if>
|
||||
<if test="voltage != null and voltage != ''">#{voltage},</if>
|
||||
<if test="ah != null and ah != ''">#{ah},</if>
|
||||
<if test="rentPrice != null">#{rentPrice},</if>
|
||||
<if test="durationType != null">#{durationType},</if>
|
||||
<if test="rent_price != null">#{rent_price},</if>
|
||||
<if test="duration_type != null">#{duration_type},</if>
|
||||
<if test="duration != null">#{duration},</if>
|
||||
<if test="cityId != null">#{cityId},</if>
|
||||
<if test="operatorId != null">#{operatorId},</if>
|
||||
<if test="provinceId != null">#{provinceId},</if>
|
||||
<if test="categoryId != null">#{categoryId},</if>
|
||||
<if test="mealId != null">#{mealId},</if>
|
||||
<if test="city != null">#{city},</if>
|
||||
<if test="operator_id != null">#{operator_id},</if>
|
||||
<if test="province != null">#{province},</if>
|
||||
<if test="category_id != null">#{category_id},</if>
|
||||
<if test="meal_id != null">#{meal_id},</if>
|
||||
<if test="syncTime != null">#{syncTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
@ -51,13 +51,13 @@
|
||||
<if test="detail != null and detail != ''">detail = #{detail},</if>
|
||||
<if test="voltage != null and voltage != ''">voltage = #{voltage},</if>
|
||||
<if test="ah != null and ah != ''">ah = #{ah},</if>
|
||||
<if test="rentPrice != null">rent_price = #{rentPrice},</if>
|
||||
<if test="durationType != null">duration_type = #{durationType},</if>
|
||||
<if test="rent_price != null">rent_price = #{rent_price},</if>
|
||||
<if test="duration_type != null">duration_type = #{duration_type},</if>
|
||||
<if test="duration != null">duration = #{duration},</if>
|
||||
<if test="cityId != null">city_id = #{cityId},</if>
|
||||
<if test="operatorId != null">operator_id = #{operatorId},</if>
|
||||
<if test="provinceId != null">province_id = #{provinceId},</if>
|
||||
<if test="categoryId != null">category_id = #{categoryId},</if>
|
||||
<if test="city != null">city_id = #{city},</if>
|
||||
<if test="operator_id != null">operator_id = #{operator_id},</if>
|
||||
<if test="province != null">province_id = #{province},</if>
|
||||
<if test="category_id != null">category_id = #{category_id},</if>
|
||||
<if test="syncTime != null">sync_time = #{syncTime},</if>
|
||||
</trim>
|
||||
where meal_id = #{mealId}
|
||||
|
||||
Reference in New Issue
Block a user