同步租电平台
This commit is contained in:
@ -11,10 +11,7 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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 org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -44,6 +41,48 @@ public class SendDataController {
|
||||
return Result.ok(sendDataService.recAndSend(dataRceiveReq));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "接收用户同步数据接口")
|
||||
@GetMapping("/userinfo/{id}")
|
||||
public Result sendUserInfoToBattery(@PathVariable String id){
|
||||
return Result.ok(sendDataService.sendUserInfoById(Long.parseLong(id)));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "接收运营商同步数据接口")
|
||||
@GetMapping("/companyinfo/{id}")
|
||||
public Result sendCompanyInfoToBattery(@PathVariable String id){
|
||||
return Result.ok(sendDataService.sendCompanyInfoToBattery(Long.parseLong(id)));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "接收门店同步数据接口")
|
||||
@GetMapping("/storeinfo/{id}")
|
||||
public Result sendStoreInfoToBattery(@PathVariable String id){
|
||||
return Result.ok(sendDataService.sendStoreInfoToBattery(Long.parseLong(id)));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "接收充电同步数据接口")
|
||||
@GetMapping("/subOrder/{id}")
|
||||
public Result sendSubOrderToBattery(@PathVariable String id){
|
||||
return Result.ok(sendDataService.sendSubOrderToBattery(Long.parseLong(id)));
|
||||
}
|
||||
|
||||
//
|
||||
// @ApiOperation(value = "接收需同步数据接口")
|
||||
// @GetMapping("/companyinfo")
|
||||
// public Result sendDataToBattery(@PathVariable Long id){
|
||||
// return Result.ok(sendDataService.recAndSend(dataRceiveReq));
|
||||
// }
|
||||
//
|
||||
// @ApiOperation(value = "接收需同步数据接口")
|
||||
// @GetMapping("/storeinfo")
|
||||
// public Result sendDataToBattery(@PathVariable Long id){
|
||||
// return Result.ok(sendDataService.recAndSend(dataRceiveReq));
|
||||
// }
|
||||
//
|
||||
// @ApiOperation(value = "接收需同步数据接口")
|
||||
// @GetMapping("/order")
|
||||
// public Result sendDataToBattery(@PathVariable Long id){
|
||||
// return Result.ok(sendDataService.recAndSend(dataRceiveReq));
|
||||
// }
|
||||
// @ApiOperation(value = "c2btest")
|
||||
// @PostMapping("/json")
|
||||
// public Result json(@RequestBody String dataRceiveReq){
|
||||
|
||||
@ -13,7 +13,7 @@ public class ReceiveMealReq {
|
||||
@ApiModelProperty("APPID")
|
||||
private String appid;
|
||||
|
||||
@ApiModelProperty("租车平台对应表主键ID")
|
||||
@ApiModelProperty("access_token")
|
||||
private String access_token;
|
||||
|
||||
@ApiModelProperty("传入数据Map")
|
||||
|
||||
@ -19,6 +19,8 @@ public interface BaseUserMapper extends BaseMapper<BaseUser> {
|
||||
BaseUser selectByPhoneNumber(@Param("phoneNumber") String phoneNumber);
|
||||
|
||||
|
||||
BaseUser selectById(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 插入用户信息
|
||||
* @param user 用户信息
|
||||
|
||||
@ -18,6 +18,8 @@ public interface CompanyInfoMapper extends BaseMapper<CompanyInfo> {
|
||||
*/
|
||||
CompanyInfo selectByPhone(@Param("phone") String phone);
|
||||
|
||||
|
||||
CompanyInfo selectById(@Param("id") Long id);
|
||||
/**
|
||||
* 根据opid查询公司信息
|
||||
* @param bOpId 电话号码
|
||||
|
||||
@ -5,6 +5,8 @@ import com.sczx.sync.po.StoreInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface CompanyStoreMapper extends BaseMapper<StoreInfo> {
|
||||
|
||||
@ -24,7 +26,9 @@ public interface CompanyStoreMapper extends BaseMapper<StoreInfo> {
|
||||
|
||||
StoreInfo selectByBid(@Param("bpStoreId") Long bpStoreId);
|
||||
|
||||
List<StoreInfo> selectByOpId(@Param("opId") Long opId);
|
||||
|
||||
StoreInfo selectById(@Param("id") Long id);
|
||||
/**
|
||||
* 根据门店名称更新门店信息
|
||||
* @param storeInfo 门店信息
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
package com.sczx.sync.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sczx.sync.po.DataReceivePo;
|
||||
import com.sczx.sync.po.OrderBatteryInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 电池订单信息Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface OrderBatteryInfoMapper extends BaseMapper<OrderBatteryInfo> {
|
||||
|
||||
/**
|
||||
* 根据子订单ID查询电池订单信息
|
||||
*
|
||||
* @param id 子订单ID
|
||||
* @return 电池订单信息
|
||||
*/
|
||||
OrderBatteryInfo selectOrderBatteryInfoById(@Param("id") Long id);
|
||||
}
|
||||
@ -5,6 +5,8 @@ import com.sczx.sync.po.UserStore;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户与门店信息 Mapper 接口
|
||||
*/
|
||||
@ -16,7 +18,7 @@ public interface UserStoreMapper extends BaseMapper<UserStore> {
|
||||
* @param userId 用户ID
|
||||
* @return 用户门店信息
|
||||
*/
|
||||
UserStore selectByUserId(@Param("userId") Long userId);
|
||||
List<UserStore> selectByUserId(@Param("userId") Long userId);
|
||||
|
||||
/**
|
||||
* 根据用户ID更新用户门店信息
|
||||
|
||||
@ -41,7 +41,37 @@ public class CompanyInfo implements Serializable {
|
||||
* 是否删除标记 (0-未删除, 1-已删除)
|
||||
*/
|
||||
private Integer isDelete;
|
||||
|
||||
|
||||
private String company_name;
|
||||
|
||||
private String contact_name;
|
||||
|
||||
private String is_delete;
|
||||
|
||||
public String getCompany_name() {
|
||||
return company_name;
|
||||
}
|
||||
|
||||
public void setCompany_name(String company_name) {
|
||||
this.company_name = company_name;
|
||||
}
|
||||
|
||||
public String getContact_name() {
|
||||
return contact_name;
|
||||
}
|
||||
|
||||
public void setContact_name(String contact_name) {
|
||||
this.contact_name = contact_name;
|
||||
}
|
||||
|
||||
public String getIs_delete() {
|
||||
return is_delete;
|
||||
}
|
||||
|
||||
public void setIs_delete(String is_delete) {
|
||||
this.is_delete = is_delete;
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步时间
|
||||
*/
|
||||
|
||||
55
src/main/java/com/sczx/sync/po/OrderBatteryInfo.java
Normal file
55
src/main/java/com/sczx/sync/po/OrderBatteryInfo.java
Normal file
@ -0,0 +1,55 @@
|
||||
package com.sczx.sync.po;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 电池订单信息实体类
|
||||
*/
|
||||
@Data
|
||||
public class OrderBatteryInfo {
|
||||
|
||||
/**
|
||||
* 客户手机号
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 套餐ID
|
||||
*/
|
||||
private Long meal_id;
|
||||
|
||||
/**
|
||||
* 租赁开始时间
|
||||
*/
|
||||
private String start_date;
|
||||
|
||||
/**
|
||||
* 租赁结束时间
|
||||
*/
|
||||
private String end_date;
|
||||
|
||||
/**
|
||||
* 城市ID
|
||||
*/
|
||||
private Long city;
|
||||
|
||||
/**
|
||||
* 门店ID
|
||||
*/
|
||||
private Long store;
|
||||
|
||||
/**
|
||||
* 分类ID
|
||||
*/
|
||||
private Long category;
|
||||
|
||||
/**
|
||||
* 运营公司ID
|
||||
*/
|
||||
private Long operator_id;
|
||||
|
||||
/**
|
||||
* 子订单号
|
||||
*/
|
||||
private String order_no;
|
||||
}
|
||||
@ -23,6 +23,8 @@ public class StoreInfo implements Serializable {
|
||||
* 联系人姓名
|
||||
*/
|
||||
private String contactName;
|
||||
|
||||
private String contact_name;
|
||||
|
||||
/**
|
||||
* 联系电话
|
||||
@ -58,7 +60,9 @@ public class StoreInfo implements Serializable {
|
||||
* 纬度
|
||||
*/
|
||||
private Double latitude;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
@ -69,8 +73,12 @@ public class StoreInfo implements Serializable {
|
||||
*/
|
||||
private Integer isDelete;
|
||||
|
||||
|
||||
|
||||
private Long bpStoreId;
|
||||
|
||||
private String is_delete;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@ -166,4 +174,20 @@ public class StoreInfo implements Serializable {
|
||||
public void setBpStoreId(Long bpStoreId) {
|
||||
this.bpStoreId = bpStoreId;
|
||||
}
|
||||
|
||||
public String getContact_name() {
|
||||
return contact_name;
|
||||
}
|
||||
|
||||
public void setContact_name(String contact_name) {
|
||||
this.contact_name = contact_name;
|
||||
}
|
||||
|
||||
public String getIs_delete() {
|
||||
return is_delete;
|
||||
}
|
||||
|
||||
public void setIs_delete(String is_delete) {
|
||||
this.is_delete = is_delete;
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,6 +12,13 @@ public interface SendDataService {
|
||||
*/
|
||||
boolean recAndSend(DataRceiveReq request);
|
||||
|
||||
boolean sendUserInfoById(Long id);
|
||||
|
||||
boolean sendCompanyInfoToBattery(Long id);
|
||||
|
||||
boolean sendStoreInfoToBattery(Long id);
|
||||
|
||||
boolean sendSubOrderToBattery(Long id);
|
||||
/**
|
||||
* 异步转发数据到第三方平台
|
||||
*
|
||||
@ -25,4 +32,6 @@ public interface SendDataService {
|
||||
* @param recordId 记录ID
|
||||
*/
|
||||
void retryForward(Long recordId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -4,9 +4,9 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.sczx.sync.dto.DataRceiveReq;
|
||||
|
||||
import com.sczx.sync.mapper.CompanyStoreMapper;
|
||||
import com.sczx.sync.mapper.DataReceiveRecordMapper;
|
||||
import com.sczx.sync.po.DataReceivePo;
|
||||
import com.sczx.sync.entity.UserInfo;
|
||||
import com.sczx.sync.mapper.*;
|
||||
import com.sczx.sync.po.*;
|
||||
import com.sczx.sync.service.SendDataService;
|
||||
import com.sczx.sync.service.ThirdPartyForwardService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -18,7 +18,10 @@ 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;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@ -34,6 +37,18 @@ public class SendDataServiceImpl implements SendDataService {
|
||||
@Autowired
|
||||
private ThirdPartyForwardService thirdPartyForwardService;
|
||||
|
||||
@Autowired
|
||||
private BaseUserMapper baseUserMapper;
|
||||
|
||||
@Autowired
|
||||
private UserStoreMapper userStoreMapper;
|
||||
|
||||
@Autowired
|
||||
private CompanyInfoMapper companyInfoMapper;
|
||||
|
||||
@Autowired
|
||||
private OrderBatteryInfoMapper orderBatteryInfoMapper;
|
||||
|
||||
@Value("${third-party.platform.api-url}")
|
||||
private String URL;
|
||||
@Value("${third-party.platform.app-id}")
|
||||
@ -43,30 +58,135 @@ public class SendDataServiceImpl implements SendDataService {
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean recAndSend(DataRceiveReq dataRceiveReq) {
|
||||
String dataType = dataRceiveReq.getDataType();
|
||||
|
||||
System.out.println("dataType "+dataType);
|
||||
return saveRecord(dataRceiveReq,URL+"/"+dataType);
|
||||
|
||||
switch (dataType){
|
||||
case "userinfo":
|
||||
}
|
||||
|
||||
return saveRecord(dataRceiveReq,URL+"/"+dataType);
|
||||
case "companyinfo":
|
||||
return saveRecord(dataRceiveReq,URL+"/"+dataType);
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean sendUserInfoById(Long id) {
|
||||
BaseUser user = baseUserMapper.selectById( id);
|
||||
List<UserStore> userStoreList = userStoreMapper.selectByUserId( id);
|
||||
|
||||
case "storeinfo":
|
||||
return saveRecord(dataRceiveReq,URL+"/"+dataType);
|
||||
|
||||
case "batteryorder":
|
||||
return saveRecord(dataRceiveReq,URL+"/"+dataType);
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setWxunionid("");
|
||||
userInfo.setMywxunionid("");
|
||||
userInfo.setPhone(user.getPhoneNumber());
|
||||
userInfo.setName(user.getRealName());
|
||||
userInfo.setIsauthentication(user.getAuthed());
|
||||
userInfo.setCardno(user.getIdNo());
|
||||
userInfo.setCard1(user.getFrontPhoto());
|
||||
userInfo.setCard2(user.getBackPhoto());
|
||||
userInfo.setIsmerchant(user.getIsStore());
|
||||
|
||||
StringBuilder storeIdsBuilder = new StringBuilder();
|
||||
if (userStoreList != null && !userStoreList.isEmpty()) {
|
||||
for (int i = 0; i < userStoreList.size(); i++) {
|
||||
UserStore store = userStoreList.get(i);
|
||||
if (store != null && store.getStoreId() != null) {
|
||||
if (storeIdsBuilder.length() > 0) {
|
||||
storeIdsBuilder.append(",");
|
||||
}
|
||||
storeIdsBuilder.append(store.getStoreId().toString());
|
||||
userInfo.setOperatorId(store.getOperatorId().toString());
|
||||
}
|
||||
}
|
||||
String storeIdsStr = storeIdsBuilder.toString();
|
||||
userInfo.setStoreId(storeIdsStr);
|
||||
}
|
||||
|
||||
return false;
|
||||
SyncRequest syncRequest = new SyncRequest();
|
||||
syncRequest.setData(userInfo);
|
||||
return saveRecord(syncRequest,URL+"/userinfo",id,"userinfo");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean sendCompanyInfoToBattery(Long id) {
|
||||
CompanyInfo company = companyInfoMapper.selectById( id);
|
||||
List<StoreInfo> storeInfoList = companyStoreMapper.selectByOpId(id);
|
||||
|
||||
CompanyInfo companyInfo = new CompanyInfo();
|
||||
companyInfo.setCompany_name(company.getCompanyName());
|
||||
companyInfo.setContact_name(company.getContactName());
|
||||
companyInfo.setPhone(company.getPhone());
|
||||
companyInfo.setAddress(company.getAddress());
|
||||
companyInfo.setIs_delete(company.getIsDelete().toString());
|
||||
|
||||
// 使用 Set 去除重复城市
|
||||
Set<String> uniqueCities = new HashSet<>();
|
||||
if (storeInfoList != null && !storeInfoList.isEmpty()) {
|
||||
for (StoreInfo store : storeInfoList) {
|
||||
if (store != null && store.getCity() != null) {
|
||||
uniqueCities.add(store.getCity());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 拼接去重后的城市字符串
|
||||
String citysStr = String.join(",", uniqueCities);
|
||||
companyInfo.setCitys(citysStr);
|
||||
|
||||
SyncRequest syncRequest = new SyncRequest();
|
||||
syncRequest.setData(companyInfo);
|
||||
return saveRecord(syncRequest, URL + "/companyinfo", id,"companyinfo");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean sendStoreInfoToBattery(Long id) {
|
||||
StoreInfo storeInfo = companyStoreMapper.selectById(id);
|
||||
|
||||
SyncRequest syncRequest = new SyncRequest();
|
||||
syncRequest.setData(storeInfo);
|
||||
return saveRecord(syncRequest,URL+"/storeinfo",id,"storeinfo");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean sendSubOrderToBattery(Long id) {
|
||||
OrderBatteryInfo orderBatteryInfo = orderBatteryInfoMapper.selectOrderBatteryInfoById(id);
|
||||
|
||||
SyncRequest syncRequest = new SyncRequest();
|
||||
syncRequest.setData(orderBatteryInfo);
|
||||
return saveRecord(syncRequest,URL+"/batteryorder",id,"batteryorder");
|
||||
}
|
||||
|
||||
|
||||
private boolean saveRecord(SyncRequest request,String url,Long id,String dataType) {
|
||||
|
||||
try {
|
||||
|
||||
// 保存接收记录
|
||||
DataReceivePo record = new DataReceivePo();
|
||||
record.setCid( id);
|
||||
record.setDataType(dataType);
|
||||
record.setRequestData(JSON.toJSONString(request.getData()));
|
||||
record.setRequestTime(LocalDateTime.now());
|
||||
record.setStatus(0); // 待转发
|
||||
record.setRetryCount(0);
|
||||
|
||||
dataReceiveRecordMapper.insert(record);
|
||||
|
||||
// 异步转发数据
|
||||
forwardToThirdParty(record.getId(),url);
|
||||
|
||||
log.info("数据接收成功,记录ID: {}", record.getId());
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error("数据接收失败", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public void forwardToThirdParty(Long recordId,String url) {
|
||||
@ -83,9 +203,9 @@ public class SendDataServiceImpl implements SendDataService {
|
||||
|
||||
String dataType = record.getDataType();
|
||||
// 转发数据
|
||||
String response = thirdPartyForwardService.forwardData(dataType,record.getRequestData());
|
||||
String response = thirdPartyForwardService.forwardData(url,record.getRequestData());
|
||||
|
||||
modifyData(dataType,record.getCid(),response);
|
||||
modifyData(record.getCid(),response,dataType);
|
||||
|
||||
// 更新记录状态
|
||||
record.setStatus(2); // 转发成功
|
||||
@ -143,8 +263,6 @@ public class SendDataServiceImpl implements SendDataService {
|
||||
}
|
||||
|
||||
private boolean saveRecord(DataRceiveReq request,String url) {
|
||||
System.out.println(url);
|
||||
|
||||
try {
|
||||
|
||||
// 保存接收记录
|
||||
@ -169,29 +287,45 @@ public class SendDataServiceImpl implements SendDataService {
|
||||
}
|
||||
}
|
||||
|
||||
private void modifyData(String dataType,Long Cid,String response){
|
||||
private void modifyData(Long Cid,String response,String dataType){
|
||||
|
||||
JSONObject jsonObject=JSON.parseObject(response.toString());
|
||||
jsonObject.remove("status");
|
||||
jsonObject.remove("msg");
|
||||
JSONObject jsonObj = JSON.parseObject(jsonObject.toJSONString());
|
||||
for (Map.Entry<String, Object> entry : jsonObj.entrySet()) {
|
||||
System.out.println(entry.getKey() + ":" + entry.getValue());
|
||||
String keyStr = entry.getKey();
|
||||
long bId = Long.parseLong(entry.getValue().toString());
|
||||
switch (keyStr){
|
||||
case "order_no":
|
||||
companyStoreMapper.updateOdId(bId,Cid);
|
||||
break;
|
||||
case "store_id":
|
||||
companyStoreMapper.updateStoreId(bId,Cid);
|
||||
break;
|
||||
case "operator_id":
|
||||
companyStoreMapper.updateOpeId(bId,Cid);
|
||||
break;
|
||||
}
|
||||
JSONObject jsonObject=JSON.parseObject(response);
|
||||
Long bId = Long.parseLong(jsonObject.get("data").toString());
|
||||
switch (dataType){
|
||||
case "userinfo":
|
||||
break;
|
||||
case "companyinfo":
|
||||
companyStoreMapper.updateOpeId(bId,Cid);
|
||||
break;
|
||||
case "storeinfo":
|
||||
companyStoreMapper.updateStoreId(bId,Cid);
|
||||
break;
|
||||
case "batteryorder":
|
||||
companyStoreMapper.updateOdId(bId,Cid);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// jsonObject.remove("status");
|
||||
// jsonObject.remove("msg");
|
||||
// JSONObject jsonObj = JSON.parseObject(jsonObject.toJSONString());
|
||||
// for (Map.Entry<String, Object> entry : jsonObj.entrySet()) {
|
||||
// System.out.println(entry.getKey() + ":" + entry.getValue());
|
||||
// String keyStr = entry.getKey();
|
||||
// long bId = Long.parseLong(entry.getValue().toString());
|
||||
// switch (keyStr){
|
||||
// case "order_no":
|
||||
// companyStoreMapper.updateOdId(bId,Cid);
|
||||
// break;
|
||||
// case "store_id":
|
||||
// companyStoreMapper.updateStoreId(bId,Cid);
|
||||
// break;
|
||||
// case "operator_id":
|
||||
// companyStoreMapper.updateOpeId(bId,Cid);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -34,15 +34,12 @@ public class ThirdPartyForwardServiceImpl implements ThirdPartyForwardService {
|
||||
private String appId;
|
||||
@Value("${third-party.platform.access-token}")
|
||||
private String accessToken;
|
||||
@Value("${third-party.platform.api-url}")
|
||||
private String apiUrl;
|
||||
@Value("${third-party.platform.timeout}")
|
||||
private int timeOut;
|
||||
@Value("${third-party.platform.retry-times}")
|
||||
private int retryTimes;
|
||||
|
||||
|
||||
@Override
|
||||
public String forwardData(String datatype,String data) {
|
||||
public String forwardData(String url,String data) {
|
||||
CloseableHttpClient httpClient = null;
|
||||
CloseableHttpResponse response = null;
|
||||
|
||||
@ -51,7 +48,6 @@ public class ThirdPartyForwardServiceImpl implements ThirdPartyForwardService {
|
||||
try {
|
||||
// 创建HTTP客户端
|
||||
httpClient = HttpClients.createDefault();
|
||||
String url = URL+'/'+datatype;
|
||||
// 创建POST请求
|
||||
HttpPost httpPost = new HttpPost(url);
|
||||
|
||||
@ -61,10 +57,13 @@ public class ThirdPartyForwardServiceImpl implements ThirdPartyForwardService {
|
||||
|
||||
// 构建请求体
|
||||
Map<String, Object> requestBody = new HashMap<>();
|
||||
requestBody.put("appId", appId);
|
||||
requestBody.put("accessToken",accessToken);
|
||||
requestBody.put("data", JSON.parse(data));
|
||||
requestBody.put("appid", appId);
|
||||
requestBody.put("access_token",accessToken);
|
||||
requestBody.put("Data", JSON.parse(data));
|
||||
requestBody.put("timestamp", System.currentTimeMillis());
|
||||
|
||||
|
||||
|
||||
|
||||
StringEntity entity = new StringEntity(JSON.toJSONString(requestBody), StandardCharsets.UTF_8);
|
||||
httpPost.setEntity(entity);
|
||||
@ -76,7 +75,7 @@ public class ThirdPartyForwardServiceImpl implements ThirdPartyForwardService {
|
||||
.build();
|
||||
httpPost.setConfig(requestConfig);
|
||||
|
||||
log.info("开始转发数据到第三方平台: {}, 数据: {}", url, data);
|
||||
log.info("开始转发数据到第三方平台: {}, 数据: {}", url, requestBody);
|
||||
|
||||
// 执行请求
|
||||
response = httpClient.execute(httpPost);
|
||||
|
||||
@ -58,9 +58,9 @@ mybatis-plus:
|
||||
# 第三方平台配置
|
||||
third-party:
|
||||
platform:
|
||||
app-id: 111
|
||||
access-token: 111
|
||||
api-url: 127.0.0.1:8081/api/ddd
|
||||
app-id: C202508001
|
||||
access-token: 5DCCABD4641B40948B64F1B4B4D59DAC
|
||||
api-url: https://sczx-zuche-datasync.de-wincle.cn/c2b
|
||||
timeout: 30000
|
||||
retry-times: 3
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id, user_name, avatar_url, phone_number, role_id, is_store, nick_name,id_no
|
||||
id, user_name, avatar_url, phone_number, role_id, is_store, nick_name,id_no,real_name,front_photo,back_photo,authed
|
||||
</sql>
|
||||
|
||||
<select id="selectByPhoneNumber" parameterType="java.lang.String" resultMap="BaseResultMap">
|
||||
@ -38,6 +38,14 @@
|
||||
AND del_flag = 0
|
||||
</select>
|
||||
|
||||
<select id="selectById" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM zc_base_user
|
||||
WHERE id = #{id}
|
||||
AND del_flag = 0
|
||||
</select>
|
||||
|
||||
<!-- 选择性插入用户信息 -->
|
||||
<insert id="insertBaseUser" parameterType="com.sczx.sync.po.BaseUser" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO zc_base_user
|
||||
|
||||
@ -9,13 +9,13 @@
|
||||
<result column="phone" property="phone" />
|
||||
<result column="address" property="address" />
|
||||
<result column="citys" property="citys" />
|
||||
<result column="is_delete" property="isDelete" />
|
||||
<result column="del_flag" property="isDelete" />
|
||||
<result column="b_op_id" property="bOpId" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
b_op_id, company_name, contact_name, phone, address, citys, is_delete
|
||||
b_op_id, company_name, contact_name, phone, address, citys, del_flag
|
||||
</sql>
|
||||
|
||||
<!-- 根据电话号码查询公司信息 -->
|
||||
@ -27,6 +27,13 @@
|
||||
AND is_delete = 0
|
||||
</select>
|
||||
|
||||
<select id="selectById" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM zc_company
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 根据bOpId查询公司信息 -->
|
||||
<select id="selectByOpId" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
|
||||
@ -17,6 +17,8 @@
|
||||
<result column="longitude" property="longitude" />
|
||||
<result column="del_flag" property="isDelete" />
|
||||
<result column="bp_store_id" property="bpStoreId" />
|
||||
<result column="contact_person" property="contact_name" />
|
||||
<result column="del_flag" property="is_delete" />
|
||||
</resultMap>
|
||||
|
||||
|
||||
@ -42,6 +44,22 @@
|
||||
AND del_flag = 0
|
||||
</select>
|
||||
|
||||
<select id="selectByOpId" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM zc_company_store
|
||||
WHERE operating_company_id = #{opId}
|
||||
AND del_flag = 0
|
||||
</select>
|
||||
|
||||
<select id="selectById" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM zc_company_store
|
||||
WHERE id = #{id}
|
||||
AND del_flag = 0
|
||||
</select>
|
||||
|
||||
<!-- 根据门店名称更新门店信息 -->
|
||||
<update id="updateByName" parameterType="com.sczx.sync.po.StoreInfo">
|
||||
<selectKey keyProperty='id' resultType='java.lang.Long' order='AFTER'>
|
||||
@ -179,5 +197,4 @@
|
||||
update zc_order_sub set b_order_id = #{bOdId} where order_id =#{cId} and suborder_type = "RENTBATTEY"
|
||||
</update>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
45
src/main/resources/mapper/OrderBatteryInfoMapper.xml
Normal file
45
src/main/resources/mapper/OrderBatteryInfoMapper.xml
Normal file
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.sczx.sync.mapper.OrderBatteryInfoMapper">
|
||||
|
||||
<!-- 结果映射 -->
|
||||
<resultMap id="OrderBatteryInfoMap" type="com.sczx.sync.po.OrderBatteryInfo">
|
||||
<result property="phone" column="phone"/>
|
||||
<result property="meal_id" column="meal_id"/>
|
||||
<result property="start_date" column="start_date"/>
|
||||
<result property="end_date" column="end_date"/>
|
||||
<result property="city" column="city"/>
|
||||
<result property="store" column="store"/>
|
||||
<result property="category" column="category"/>
|
||||
<result property="operator_id" column="operator_id"/>
|
||||
<result property="order_no" column="order_no"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 根据子订单ID查询电池订单信息 -->
|
||||
<select id="selectOrderBatteryInfoById" resultMap="OrderBatteryInfoMap">
|
||||
SELECT
|
||||
zom.customer_phone AS phone,
|
||||
zrb.meal_id AS meal_id,
|
||||
zom.start_rent_time AS start_date,
|
||||
zom.end_rent_time AS end_date,
|
||||
zcs.city_id as city,
|
||||
zcs.id as store,
|
||||
zrb.category_id as category,
|
||||
zcs.operating_company_id as operator_id,
|
||||
zos.suborder_no as order_no
|
||||
FROM
|
||||
zc_order_main AS zom,
|
||||
zc_order_sub AS zos,
|
||||
zc_rent_battey_rule AS zrb,
|
||||
zc_company_store AS zcs
|
||||
WHERE
|
||||
zom.rent_battey_rule_id = zrb.id
|
||||
AND zom.order_id = zos.order_id
|
||||
AND suborder_type = 'RENTBATTEY'
|
||||
and zom.store_id = zcs.id
|
||||
and zos.suborder_id = #{id}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@ -25,7 +25,6 @@
|
||||
SELECT <include refid="Base_Column_List"/>
|
||||
FROM zc_base_user_store
|
||||
WHERE user_id = #{userId}
|
||||
AND del_flag = '0'
|
||||
</select>
|
||||
|
||||
<!-- 根据用户ID更新用户门店信息 -->
|
||||
|
||||
Reference in New Issue
Block a user