Fix:湖南电信

This commit is contained in:
Owen 2025-03-06 11:22:11 +08:00
parent 1a8b730e71
commit 70f20834d5
4 changed files with 128 additions and 30 deletions

View File

@ -10,6 +10,7 @@ import cn.iocoder.yudao.framework.tenant.core.service.TenantFrameworkService;
import cn.iocoder.yudao.module.haoka.api.ApiFrom; import cn.iocoder.yudao.module.haoka.api.ApiFrom;
import cn.iocoder.yudao.module.haoka.api.ApiLianTongService; import cn.iocoder.yudao.module.haoka.api.ApiLianTongService;
import cn.iocoder.yudao.module.haoka.api.liantong.model.response.KingMessageGetResponse; import cn.iocoder.yudao.module.haoka.api.liantong.model.response.KingMessageGetResponse;
import cn.iocoder.yudao.module.haoka.api.liantong.util.StringUtils;
import cn.iocoder.yudao.module.haoka.controller.admin.orders.vo.OrdersPageReqVO; import cn.iocoder.yudao.module.haoka.controller.admin.orders.vo.OrdersPageReqVO;
import cn.iocoder.yudao.module.haoka.controller.admin.superiorapilog.vo.SuperiorApiLogSaveReqVO; import cn.iocoder.yudao.module.haoka.controller.admin.superiorapilog.vo.SuperiorApiLogSaveReqVO;
import cn.iocoder.yudao.module.haoka.dal.dataobject.orders.OrdersDO; import cn.iocoder.yudao.module.haoka.dal.dataobject.orders.OrdersDO;
@ -56,7 +57,7 @@ public class HaokaUpdateOrderSchedule {
private ApiLianTongService apiLianTongService; private ApiLianTongService apiLianTongService;
//@Scheduled(cron = "0 */22 * * * ?") @Scheduled(cron = "0 */10 * * * ?")
public void updateOrder() { public void updateOrder() {
log.info("开始-----------更新订单开始--------------------"); log.info("开始-----------更新订单开始--------------------");
tenantFrameworkService.getTenantIds().forEach((tenantId) -> { tenantFrameworkService.getTenantIds().forEach((tenantId) -> {
@ -130,29 +131,63 @@ public class HaokaUpdateOrderSchedule {
private void updateOrderInfo(final OrdersDO ordersDO) { private void updateOrderInfo(final OrdersDO ordersDO) {
log.info("更新前--{}", JSON.toJSONString(ordersDO)); log.info("更新前--{}", JSON.toJSONString(ordersDO));
// 查询上游的订单结果 // 查询上游的订单结果
ApiDealResp<OrderApiQueryResp> updateOrderInfo = apiDealStrategyService.getUpdateOrderInfo(ordersDO); ApiDealResp<OrderApiQueryResp> resp = apiDealStrategyService.getUpdateOrderInfo(ordersDO);
// 上游是否支持查询接口 比如联通不支持查询接口走消息队列 // 上游是否支持查询接口 比如联通不支持查询接口走消息队列
if (updateOrderInfo.getIsSupport()){ if (!resp.getIsSupport()){
return; return;
} }
// 上游黑名单 // 上游黑名单
if (updateOrderInfo.getIsBlack()){ if (resp.getIsBlack()){
} }
// 查询成功 // 查询成功
if (!updateOrderInfo.getSuccess()){ if (!resp.getSuccess()){
// 不成功原因 // 不成功原因
String msg = updateOrderInfo.getMsg(); String msg = resp.getMsg();
} }
// 查询结果 // 查询结果
OrderApiQueryResp data = updateOrderInfo.getData(); OrderApiQueryResp data = resp.getData();
if (data == null) {
return;
}
// 订单状态 // 订单状态
String orderStatusCode = data.getOrderStatusCode(); String orderStatusCode = data.getOrderStatusCode();
if (StringUtils.isNotEmpty(orderStatusCode)) {
try {
ordersDO.setUpstreamOrderStatus(Integer.valueOf(orderStatusCode));
}catch (Exception e){
log.error(e.getMessage());
}
// 订单状态描述 }
// 上游对订单状态的描述
String orderStatusDesc = data.getSupplierOrderStatusDesc(); String orderStatusDesc = data.getSupplierOrderStatusDesc();
if (StringUtils.isNotEmpty(orderStatusDesc)) {
ordersDO.setUpStatus(orderStatusDesc);
}
// 物流信息 头都
String trackingNumber = data.getTrackingNumber();
if (StringUtils.isNotEmpty(trackingNumber)) {
ordersDO.setTrackingNumber(trackingNumber);
}
String trackingCompany = data.getTrackingCompany();
if (StringUtils.isNotEmpty(trackingCompany)) {
ordersDO.setTrackingCompany(trackingCompany);
}
if (data.isNeedUpdateProducePhoneNum()) {
ordersDO.setPlanMobileProduced(data.getSupplierPhoneNumber());
}
// todo 上游更新 // todo 上游更新
ordersService.updateById(ordersDO); ordersService.updateById(ordersDO);

View File

@ -53,4 +53,7 @@ public class OrderApiQueryResp extends BaseDO {
*/ */
private String trackingCompany; private String trackingCompany;
private String supplierPhoneNumber;
private boolean needUpdateProducePhoneNum = false;
} }

View File

@ -301,7 +301,7 @@ public class HuNanDxApiDealStrategy implements ApiDealStrategy {
if (preProduct == null) { if (preProduct == null) {
return ApiDealResp.failed("商品下架或者不存在"); return ApiDealResp.failed("商品下架或者不存在");
} }
SuperiorApiDO superiorApi = superiorApiService.getSuperiorApi(param.getSuperiorApiId()); SuperiorApiRespVO superiorApi = preProduct.getSuperiorApiRespVO();
final SuperiorProductConfigDO skuConfigVO = superiorProductConfigService.getById(param.getSuperiorProductConfigId()); final SuperiorProductConfigDO skuConfigVO = superiorProductConfigService.getById(param.getSuperiorProductConfigId());
if (skuConfigVO == null) { if (skuConfigVO == null) {
return ApiDealResp.failed("商品对接上游配置不存在"); return ApiDealResp.failed("商品对接上游配置不存在");
@ -315,20 +315,72 @@ public class HuNanDxApiDealStrategy implements ApiDealStrategy {
HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.QueryOrderResp> responseInfo = apiHuNanDXService.queryOrder(logVO, haokaSuperiorApiId, queryParam); HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.QueryOrderResp> responseInfo = apiHuNanDXService.queryOrder(logVO, haokaSuperiorApiId, queryParam);
logVO.setResponse(JSON.toJSONString(responseInfo)); logVO.setResponse(JSON.toJSONString(responseInfo));
OrderApiQueryResp orderApiQueryResp = new OrderApiQueryResp(); OrderApiQueryResp orderApiQueryResp = new OrderApiQueryResp();
if (responseInfo.getResult() == null) { JSONObject result = responseInfo.getResult();
if (result == null) {
orderApiQueryResp.setOrderStatusCode("0"); orderApiQueryResp.setOrderStatusCode("0");
orderApiQueryResp.setSupplierOrderStatusDesc(responseInfo.getRes_message()); orderApiQueryResp.setSupplierOrderStatusDesc(responseInfo.getRes_message());
return ApiDealResp.ok(orderApiQueryResp); return ApiDealResp.ok(orderApiQueryResp);
// return ApiDealResp.failed(responseInfo.getRes_message()); // return ApiDealResp.failed(responseInfo.getRes_message());
} }
if (responseInfo.getResult().getJSONObject("data") == null) { JSONObject data = result.getJSONObject("data");
if (data == null) {
// return ApiDealResp.failed(responseInfo.getResult().getString("message")); // return ApiDealResp.failed(responseInfo.getResult().getString("message"));
orderApiQueryResp.setOrderStatusCode("0"); orderApiQueryResp.setOrderStatusCode("0");
orderApiQueryResp.setSupplierOrderStatusDesc(responseInfo.getResult().getString("message")); orderApiQueryResp.setSupplierOrderStatusDesc(result.getString("message"));
return ApiDealResp.ok(orderApiQueryResp); return ApiDealResp.ok(orderApiQueryResp);
} }
if (responseInfo.getResult().getJSONObject("data").getJSONObject("busOppOrder") == null) { JSONObject serviceOrder = data.getJSONObject("serviceOrder");
if (serviceOrder!=null){
// 订单状态 pending 待处理,processing 处理中,completed 处理完成,ORDER_CANCEL 业务订单作废
String serviceOrderState = serviceOrder.getString("serviceOrderState");
// RM状态
//pending:待同步;CHARGE_SUCCESS:收费成功;IS_COMPLETED:已竣工;WRITE_EXCEPTION:
// 写卡异常;CHARGE_EXCEPTION:收费异常WRITE_SUCCESS:写卡成功WRITE_FAIL:写卡失败;NO_COMPLETED:未竣工PIPEI SUCCESS集团配卡成功
String serviceOrderCrmStatus = serviceOrder.getString("serviceOrderCrmStatus");
if ("IS_COMPLETED".equals(serviceOrderCrmStatus)){
orderApiQueryResp.setOrderStatusCode("500");
orderApiQueryResp.setSupplierOrderStatusDesc("CrmStatus IS_COMPLETED 已竣工");
String serviceOrderCusAccPhone = serviceOrder.getString("serviceOrderCusAccPhone");
if (serviceOrderCusAccPhone!=null){
orderApiQueryResp.setNeedUpdateProducePhoneNum(true);
orderApiQueryResp.setSupplierPhoneNumber(serviceOrderCusAccPhone);
}
return ApiDealResp.ok(orderApiQueryResp);
}
if ("pending".equals(serviceOrderState)){
orderApiQueryResp.setOrderStatusCode("470");
orderApiQueryResp.setSupplierOrderStatusDesc("订单状态 pending 待处理");
return ApiDealResp.ok(orderApiQueryResp);
}
if ("completed".equals(serviceOrderState)){
orderApiQueryResp.setOrderStatusCode("500");
orderApiQueryResp.setSupplierOrderStatusDesc("订单状态 completed 待处理");
return ApiDealResp.ok(orderApiQueryResp);
}
if ("ORDER_CANCEL".equals(serviceOrderState)){
orderApiQueryResp.setOrderStatusCode("-460");
orderApiQueryResp.setSupplierOrderStatusDesc("订单状态 IS_COMPLETED 业务订单作废");
return ApiDealResp.ok(orderApiQueryResp);
}
orderApiQueryResp.setOrderStatusCode("0");
orderApiQueryResp.setSupplierOrderStatusDesc("busOppOrder null");
return ApiDealResp.ok(orderApiQueryResp);
}
JSONObject busOppOrder = data.getJSONObject("busOppOrder");
if (busOppOrder == null) {
// return ApiDealResp.failed("busOppOrder null"); // return ApiDealResp.failed("busOppOrder null");
orderApiQueryResp.setOrderStatusCode("0"); orderApiQueryResp.setOrderStatusCode("0");
@ -336,8 +388,9 @@ public class HuNanDxApiDealStrategy implements ApiDealStrategy {
return ApiDealResp.ok(orderApiQueryResp); return ApiDealResp.ok(orderApiQueryResp);
} }
String string = responseInfo.getResult().getJSONObject("data").getJSONObject("busOppOrder").getString("tbBusOppOrderThState"); String tbBusOppOrderThState = busOppOrder.getString("tbBusOppOrderThState");
if (string == null) {
if (tbBusOppOrderThState == null) {
// return ApiDealResp.failed("tbBusOppOrderThState null"); // return ApiDealResp.failed("tbBusOppOrderThState null");
orderApiQueryResp.setOrderStatusCode("0"); orderApiQueryResp.setOrderStatusCode("0");
@ -345,17 +398,17 @@ public class HuNanDxApiDealStrategy implements ApiDealStrategy {
return ApiDealResp.ok(orderApiQueryResp); return ApiDealResp.ok(orderApiQueryResp);
} }
if (!string.equals("1")) { if (!tbBusOppOrderThState.equals("1")) {
// return ApiDealResp.failed("tbBusOppOrderThState null"); // return ApiDealResp.failed("tbBusOppOrderThState null");
orderApiQueryResp.setOrderStatusCode("0"); orderApiQueryResp.setOrderStatusCode("0");
orderApiQueryResp.setSupplierOrderStatusDesc("状态为:" + string + ",状态说明0待确认1生产2作废3同步失败4待下单5待转业务单8业务单挂起状态"); orderApiQueryResp.setSupplierOrderStatusDesc("状态为:" + tbBusOppOrderThState + ",状态说明0待确认1生产2作废3同步失败4待下单5待转业务单8业务单挂起状态");
return ApiDealResp.ok(orderApiQueryResp); return ApiDealResp.ok(orderApiQueryResp);
} }
orderApiQueryResp.setData(responseInfo); orderApiQueryResp.setData(responseInfo);
orderApiQueryResp.setOrderStatusCode("470"); orderApiQueryResp.setOrderStatusCode("470");
orderApiQueryResp.setSupplierOrderStatusDesc("状态为:" + string + ",状态说明0待确认1生产2作废3同步失败4待下单5待转业务单8业务单挂起状态"); orderApiQueryResp.setSupplierOrderStatusDesc("状态为:" + tbBusOppOrderThState + ",状态说明0待确认1生产2作废3同步失败4待下单5待转业务单8业务单挂起状态");
return ApiDealResp.ok(orderApiQueryResp); return ApiDealResp.ok(orderApiQueryResp);
} catch (Exception e) { } catch (Exception e) {
return ApiDealResp.failed(e.getMessage()); return ApiDealResp.failed(e.getMessage());

View File

@ -28,12 +28,14 @@ import cn.iocoder.yudao.module.haoka.service.superiorproductconfig.SuperiorProdu
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import lombok.val; import lombok.val;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
@Slf4j
@Component(ApiFrom.LianTongApiDealStrategy) @Component(ApiFrom.LianTongApiDealStrategy)
public class LianTongApiDealStrategy implements ApiDealStrategy { public class LianTongApiDealStrategy implements ApiDealStrategy {
@ -52,7 +54,12 @@ public class LianTongApiDealStrategy implements ApiDealStrategy {
private HaoKaAddressService haoKaAddressService; private HaoKaAddressService haoKaAddressService;
private LianTongArea getAddress(String code) { private LianTongArea getAddress(String code) {
return LianTongAreaUtils.getArea(code); try {
return LianTongAreaUtils.getArea(code);
} catch (Exception e) {
log.error("获取联通地址失败:{}--ErrL{}", code, e.getMessage());
}
return null;
} }
@Override @Override
@ -62,7 +69,7 @@ public class LianTongApiDealStrategy implements ApiDealStrategy {
return ApiDealResp.failed("商品下架或者不存在"); return ApiDealResp.failed("商品下架或者不存在");
} }
SuperiorApiDO superiorApi = superiorApiService.getSuperiorApi(param.getSuperiorApiId()); SuperiorApiDO superiorApi = superiorApiService.getSuperiorApi(param.getSuperiorApiId());
final SuperiorProductConfigDO skuConfigVO = superiorProductConfigService.getById(param.getSuperiorProductConfigId()); final SuperiorProductConfigDO skuConfigVO = superiorProductConfigService.getById(param.getSuperiorProductConfigId());
if (skuConfigVO == null) { if (skuConfigVO == null) {
return ApiDealResp.failed("商品对接上游配置不存在"); return ApiDealResp.failed("商品对接上游配置不存在");
} }
@ -74,15 +81,15 @@ public class LianTongApiDealStrategy implements ApiDealStrategy {
String addressDistrictCode = param.getAddressDistrictCode(); String addressDistrictCode = param.getAddressDistrictCode();
LianTongArea receiveAddress = getAddress(addressDistrictCode); LianTongArea receiveAddress = getAddress(addressDistrictCode);
if (receiveAddress==null){ if (receiveAddress == null) {
AddressVo address = haoKaAddressService.getAddress(addressDistrictCode); AddressVo address = haoKaAddressService.getAddress(addressDistrictCode);
String substring = addressDistrictCode.substring(0, 4)+"00"; String substring = addressDistrictCode.substring(0, 4) + "00";
receiveAddress = getAddress(substring); receiveAddress = getAddress(substring);
if (address!=null){ if (address != null) {
receiveAddress=new LianTongArea(); receiveAddress = new LianTongArea();
receiveAddress.setName(address.getName()); receiveAddress.setName(address.getName());
receiveAddress.setProvinceCode(address.getProvinceCode()+"0000"); receiveAddress.setProvinceCode(address.getProvinceCode() + "0000");
receiveAddress.setCityCode(address.getCityCode()+"00"); receiveAddress.setCityCode(address.getCityCode() + "00");
receiveAddress.setDistrictCode(address.getCode()); receiveAddress.setDistrictCode(address.getCode());
receiveAddress.setDistrictName(address.getName()); receiveAddress.setDistrictName(address.getName());
} }
@ -109,7 +116,7 @@ public class LianTongApiDealStrategy implements ApiDealStrategy {
// 1提交资料 lianTongSubmitUserInfo // 1提交资料 lianTongSubmitUserInfo
KingIdentityCustV2Request ziLiao = new KingIdentityCustV2Request(); KingIdentityCustV2Request ziLiao = new KingIdentityCustV2Request();
if (numAddress!=null){ if (numAddress != null) {
ziLiao.setProvince(numAddress.getPhoneProvinceCode()); ziLiao.setProvince(numAddress.getPhoneProvinceCode());
ziLiao.setCity(numAddress.getPhoneCityCode()); ziLiao.setCity(numAddress.getPhoneCityCode());
} }
@ -145,8 +152,8 @@ public class LianTongApiDealStrategy implements ApiDealStrategy {
if (!"成功".equals(rspCode)) { if (!"成功".equals(rspCode)) {
superApiResponse.setOrderStatusCode("0"); superApiResponse.setOrderStatusCode("0");
String rspDesc = ziLiaoResponse.getRspDesc(); String rspDesc = ziLiaoResponse.getRspDesc();
if (StringUtils.isEmpty(rspDesc)){ if (StringUtils.isEmpty(rspDesc)) {
rspDesc=rspCode; rspDesc = rspCode;
} }
superApiResponse.setSupplierOrderStatusDesc(rspDesc); superApiResponse.setSupplierOrderStatusDesc(rspDesc);
return ApiDealResp.ok(superApiResponse); return ApiDealResp.ok(superApiResponse);
@ -214,7 +221,7 @@ public class LianTongApiDealStrategy implements ApiDealStrategy {
// 3 token提交正式订单 lianTongOrderSyncV2 // 3 token提交正式订单 lianTongOrderSyncV2
KingOrderSyncV2Request syncV2 = new KingOrderSyncV2Request(); KingOrderSyncV2Request syncV2 = new KingOrderSyncV2Request();
if (numAddress!=null){ if (numAddress != null) {
syncV2.setProvinceCode(numAddress.getPhoneProvinceCode()); syncV2.setProvinceCode(numAddress.getPhoneProvinceCode());
syncV2.setCityCode(numAddress.getPhoneCityCode()); syncV2.setCityCode(numAddress.getPhoneCityCode());
} }