diff --git a/src/main/java/com/sczx/sync/controller/ReceiveBatteryController.java b/src/main/java/com/sczx/sync/controller/ReceiveBatteryController.java index 8be1992..5049b57 100644 --- a/src/main/java/com/sczx/sync/controller/ReceiveBatteryController.java +++ b/src/main/java/com/sczx/sync/controller/ReceiveBatteryController.java @@ -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 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 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 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 storeInfo(@RequestBody String receiveMealReq){ + return receiveService.recceiveStoreInfo(receiveMealReq); } diff --git a/src/main/java/com/sczx/sync/controller/SendDataController.java b/src/main/java/com/sczx/sync/controller/SendDataController.java index 56c4ea2..7284edf 100644 --- a/src/main/java/com/sczx/sync/controller/SendDataController.java +++ b/src/main/java/com/sczx/sync/controller/SendDataController.java @@ -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 sendCompanyInfoToBattery(@PathVariable String id){ + Map 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 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 sendSubOrderToBattery(@PathVariable String id){ + return sendDataService.sendSubOrderToBattery(Long.parseLong(id)); } // diff --git a/src/main/java/com/sczx/sync/po/BatteryRule.java b/src/main/java/com/sczx/sync/po/BatteryRule.java index 5ebe26a..9312876 100644 --- a/src/main/java/com/sczx/sync/po/BatteryRule.java +++ b/src/main/java/com/sczx/sync/po/BatteryRule.java @@ -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; - } } \ No newline at end of file diff --git a/src/main/java/com/sczx/sync/service/ReceiveService.java b/src/main/java/com/sczx/sync/service/ReceiveService.java index 5dd157e..d3ffa99 100644 --- a/src/main/java/com/sczx/sync/service/ReceiveService.java +++ b/src/main/java/com/sczx/sync/service/ReceiveService.java @@ -1,12 +1,14 @@ package com.sczx.sync.service; +import java.util.Map; + public interface ReceiveService { - String recceiveMeals(String request); + Map recceiveMeals(String request); - String recceiveUserInfo(String request); + Map recceiveUserInfo(String request); - String recceiveCompanyInfo(String request); + Map recceiveCompanyInfo(String request); - String recceiveStoreInfo(String request); + Map recceiveStoreInfo(String request); } diff --git a/src/main/java/com/sczx/sync/service/SendDataService.java b/src/main/java/com/sczx/sync/service/SendDataService.java index 8793a78..641181e 100644 --- a/src/main/java/com/sczx/sync/service/SendDataService.java +++ b/src/main/java/com/sczx/sync/service/SendDataService.java @@ -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 sendCompanyInfoToBattery(Long id); - boolean sendStoreInfoToBattery(Long id); + Map sendStoreInfoToBattery(Long id); - boolean sendSubOrderToBattery(Long id); + Map sendSubOrderToBattery(Long id); /** * 异步转发数据到第三方平台 * 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 5560b0e..8a2b7ec 100644 --- a/src/main/java/com/sczx/sync/service/impl/ReceiveServiceImpl.java +++ b/src/main/java/com/sczx/sync/service/impl/ReceiveServiceImpl.java @@ -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 recceiveMeals(String request) { SyncRequest syncRequest = JSON.parseObject(request, SyncRequest.class); - + Map 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 syncDataInfoQueryWrapper = new QueryWrapper<>(); - QueryWrapper 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 syncDataInfoQueryWrapper = new QueryWrapper<>(); + QueryWrapper 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 recceiveUserInfo(String request) { SyncRequest syncRequest = JSON.parseObject(request, SyncRequest.class); - + Map 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 recceiveCompanyInfo(String request) { SyncRequest syncRequest = JSON.parseObject(request, SyncRequest.class); - + Map 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 recceiveStoreInfo(String request) { SyncRequest syncRequest = JSON.parseObject(request, SyncRequest.class); - + Map 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; } } diff --git a/src/main/java/com/sczx/sync/service/impl/SendDataServiceImpl.java b/src/main/java/com/sczx/sync/service/impl/SendDataServiceImpl.java index 1a0e5de..c2880ea 100644 --- a/src/main/java/com/sczx/sync/service/impl/SendDataServiceImpl.java +++ b/src/main/java/com/sczx/sync/service/impl/SendDataServiceImpl.java @@ -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 sendCompanyInfoToBattery(Long id) { CompanyInfo company = companyInfoMapper.selectById( id); List storeInfoList = companyStoreMapper.selectByOpId(id); + Map 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 sendStoreInfoToBattery(Long id) { StoreInfo storeInfo = companyStoreMapper.selectById(id); + Map 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 sendSubOrderToBattery(Long id) { OrderBatteryInfo orderBatteryInfo = orderBatteryInfoMapper.selectOrderBatteryInfoById(id); + Map 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; } diff --git a/src/main/resources/mapper/BatteryMeal.xml b/src/main/resources/mapper/BatteryMeal.xml index c86940e..696a77e 100644 --- a/src/main/resources/mapper/BatteryMeal.xml +++ b/src/main/resources/mapper/BatteryMeal.xml @@ -11,14 +11,14 @@ voltage, ah, - rent_price, - duration_type, + rent_price, + duration_type, duration, - city_id, - operator_id, - province_id, - category_id, - meal_id, + city_id, + operator_id, + province_id, + category_id, + meal_id, sync_time, @@ -26,14 +26,14 @@ #{detail}, #{voltage}, #{ah}, - #{rentPrice}, - #{durationType}, + #{rent_price}, + #{duration_type}, #{duration}, - #{cityId}, - #{operatorId}, - #{provinceId}, - #{categoryId}, - #{mealId}, + #{city}, + #{operator_id}, + #{province}, + #{category_id}, + #{meal_id}, #{syncTime}, @@ -51,13 +51,13 @@ detail = #{detail}, voltage = #{voltage}, ah = #{ah}, - rent_price = #{rentPrice}, - duration_type = #{durationType}, + rent_price = #{rent_price}, + duration_type = #{duration_type}, duration = #{duration}, - city_id = #{cityId}, - operator_id = #{operatorId}, - province_id = #{provinceId}, - category_id = #{categoryId}, + city_id = #{city}, + operator_id = #{operator_id}, + province_id = #{province}, + category_id = #{category_id}, sync_time = #{syncTime}, where meal_id = #{mealId}