Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
Damonny 2025-03-06 14:13:28 +08:00
commit 0d4b13c396
19 changed files with 349 additions and 317 deletions

View File

@ -50,4 +50,7 @@ public interface ErrorCodeConstants {
ErrorCode ORDER_OPERATE_LOG_NOT_EXISTS = new ErrorCode(1_826_001_001, "订单操作日志不存在"); ErrorCode ORDER_OPERATE_LOG_NOT_EXISTS = new ErrorCode(1_826_001_001, "订单操作日志不存在");
ErrorCode ORDER_SYNC_LOG_NOT_EXISTS = new ErrorCode(1_827_001_001, "抓单记录不存在"); ErrorCode ORDER_SYNC_LOG_NOT_EXISTS = new ErrorCode(1_827_001_001, "抓单记录不存在");
ErrorCode PRODUCT_EXITS = new ErrorCode(1_827_001_021, "产品已经存在");
} }

View File

@ -4,6 +4,9 @@ import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import java.text.SimpleDateFormat;
import java.util.Date;
@Data @Data
public class HaiNanDxInfo { public class HaiNanDxInfo {
@Data @Data
@ -70,34 +73,34 @@ public class HaiNanDxInfo {
// 接口2同步订单信息给BPSsyn.orderinfo.SynJdServiceOrder // 接口2同步订单信息给BPSsyn.orderinfo.SynJdServiceOrder
@Data @Data
public static class SyncOrderParam { public static class SyncOrderParam {
private String serviceOrderOutOrderId; // 提交订单ID private String serviceOrderOutOrderId = ""; // 提交订单ID
private String serviceOrderSubmitTime; // 提交时间 private String serviceOrderSubmitTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); // 提交时间
private String serviceOrderCusName; // 客户入网姓名 private String serviceOrderCusName = ""; // 客户入网姓名
private String serviceOrderCusCardNo; // 客户入网身份证 private String serviceOrderCusCardNo = ""; // 客户入网身份证
private String serviceOrderCusAccPhone;// 客户预占号码 private String serviceOrderCusAccPhone = ""; // 客户预占号码
private String serviceOrderSalesNumber;// 入网所选套餐ID private String serviceOrderSalesNumber = ""; // 入网所选套餐ID
private String serviceOrderCpsRefereePeople; // CPS1 private String serviceOrderCusContactPhone = ""; // 客户联系电话
private String serviceOrderRefereePeople; // CPS2 private String serviceOrderIccid = ""; // ICCID
private String serviceOrderReceiverName; private String serviceOrderPhoneCellcore = ""; // 号码归属地
private String serviceOrderReceiverProvCode; private String serviceOrderReceiverName = ""; // 收货人姓名
private String serviceOrderReceiverCityCode; private String serviceOrderReceiverProvCode = ""; // 收货人省份
private String serviceOrderReceiverDistrictCode; private String serviceOrderReceiverCityCode = ""; // 收货人城市
private String serviceOrderReceiverAddress; private String serviceOrderReceiverDistrictCode = ""; // 收货人区县
private String serviceOrderReceiverAddress = ""; // 收货人详细地址
private String serviceOrderSource; private String serviceOrderType = ""; // 订单类型
private String serviceOrderSource = ""; // 订单来源
// serviceOrderCardPic1 string 入网身份图片信息 private String serviceOrderCpsRefereePeople = ""; // CPS1
private String serviceOrderPayStatus; // string 支付状态:1 已支付, -1 未支付 private String serviceOrderRefereePeople = ""; // CPS2
private String serviceOrderPayPrice; // string 支付金额X元预存 private String serviceOrderPayMethod = ""; // 支付方式
private String serviceOrderPayTranid; // string 短信验证流水号 private String serviceOrderPayStatus = ""; // 支付状态:1 已支付, -1 未支付
private String serviceOrderPayOrderid; // string 支付订单号号百流水号 private String serviceOrderPayTranid = ""; // 短信验证流水号
private String serviceOrderCardPic1; // string 入网身份图片信息 private String serviceOrderPayOrderid = ""; // 支付订单号号百流水号
private String serviceOrderActivationReferee; // string 推荐人工号 private String serviceOrderCardPic1 = ""; // 入网身份图片信息
private String fingerNum; // string 指纹编码由js前端获取 private String serviceOrderActivationReferee = ""; // 推荐人工号
private String installAddress; // string 装机地址 private String fingerNum = ""; // 指纹编码由js前端获取
private String serviceOrderPhoneCellCode; // string 号码归属地 0731 private String installAddress = ""; // 装机地址
private String tbBusOppBroadBusAcc; // string 预受理单号 或销售员编码校园编码 private String tbBusOppBroadBusAcc = ""; // 预受理单号 或销售员编码校园编码
private String serviceOrderRemark; // string 专属优惠 private String serviceOrderRemark = ""; // 专属优惠g 专属优惠
} }

View File

@ -152,14 +152,14 @@ public class HuNanDXApi {
try (CloseableHttpClient httpClient = createHttpClientIgnoreSSL()) { try (CloseableHttpClient httpClient = createHttpClientIgnoreSSL()) {
String baseUrl = config.getBaseUrl(); String baseUrl = config.getBaseUrl();
logVO.setUrl(baseUrl); logVO.setUrl(baseUrl);
logVO.setParam(JSON.toJSONString(requestBody)); String jsonString = JSON.toJSONString(requestBody);
logVO.setParam(jsonString);
HttpPost httpPost = new HttpPost(baseUrl); HttpPost httpPost = new HttpPost(baseUrl);
httpPost.setHeader("Content-Type", "application/json; charset=UTF-8"); httpPost.setHeader("Content-Type", "application/json; charset=UTF-8");
httpPost.setEntity(new StringEntity(new ObjectMapper().writeValueAsString(requestBody))); httpPost.setEntity(new StringEntity(jsonString,"utf-8"));
CloseableHttpResponse response = httpClient.execute(httpPost); CloseableHttpResponse response = httpClient.execute(httpPost);
String string = EntityUtils.toString(response.getEntity()); String string = EntityUtils.toString(response.getEntity(),"utf-8");
logVO.setResponse(JSON.toJSONString(string)); logVO.setResponse(JSON.toJSONString(string));
httpClient.close(); httpClient.close();
return string; return string;

View File

@ -58,7 +58,7 @@ public class LianTongAreaUtils {
// csv 中加载数据 // csv 中加载数据
List<CsvRow> rows = CsvUtil.getReader().read(ResourceUtil.getUtf8Reader("api/liantong/收货地址省市区编码20200427.csv")).getRows(); List<CsvRow> rows = CsvUtil.getReader().read(ResourceUtil.getUtf8Reader("api/liantong/LT.csv")).getRows();
rows.remove(0); // 删除 header rows.remove(0); // 删除 header
for (CsvRow row : rows) { for (CsvRow row : rows) {
LianTongArea area = new LianTongArea( LianTongArea area = new LianTongArea(

View File

@ -41,14 +41,14 @@ public class BlackListController {
@PostMapping("/create") @PostMapping("/create")
@Operation(summary = "创建黑名单") @Operation(summary = "创建黑名单")
@PreAuthorize("@ss.hasPermission('haoka:black-list:create')") @PreAuthorize("@ss.hasPermission('haoka:black-list:create')")
public CommonResult<Long> createBlackList(@Valid @RequestBody BlackListSaveReqVO createReqVO) { public CommonResult<Long> createBlackList( @RequestBody BlackListSaveReqVO createReqVO) {
return success(blackListService.createBlackList(createReqVO)); return success(blackListService.createBlackList(createReqVO));
} }
@PutMapping("/update") @PutMapping("/update")
@Operation(summary = "更新黑名单") @Operation(summary = "更新黑名单")
@PreAuthorize("@ss.hasPermission('haoka:black-list:update')") @PreAuthorize("@ss.hasPermission('haoka:black-list:update')")
public CommonResult<Boolean> updateBlackList(@Valid @RequestBody BlackListSaveReqVO updateReqVO) { public CommonResult<Boolean> updateBlackList( @RequestBody BlackListSaveReqVO updateReqVO) {
blackListService.updateBlackList(updateReqVO); blackListService.updateBlackList(updateReqVO);
return success(true); return success(true);
} }
@ -92,4 +92,4 @@ public class BlackListController {
BeanUtils.toBean(list, BlackListRespVO.class)); BeanUtils.toBean(list, BlackListRespVO.class));
} }
} }

View File

@ -9,21 +9,15 @@ import jakarta.validation.constraints.*;
@Data @Data
public class BlackListSaveReqVO { public class BlackListSaveReqVO {
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "19320") private Long id;
private Long id;
@Schema(description = "运营商")
private Integer operation; private Integer operation;
@Schema(description = "收货地址电话", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "收货地址电话不能为空")
private String addressPhone; private String addressPhone;
@Schema(description = "身份证", requiredMode = Schema.RequiredMode.REQUIRED) private String personIdCard;
@NotEmpty(message = "身份证不能为空")
private String personIdCard;
@Schema(description = "部门ID", example = "21276") private Long deptId;
private Long deptId;
} }

View File

@ -13,6 +13,7 @@ import jakarta.validation.*;
import jakarta.servlet.http.*; import jakarta.servlet.http.*;
import java.util.*; import java.util.*;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.ExecutionException;
import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
@ -41,8 +42,9 @@ public class OrderOperateLogController {
@PostMapping("/create") @PostMapping("/create")
@Operation(summary = "创建订单操作日志") @Operation(summary = "创建订单操作日志")
@PreAuthorize("@ss.hasPermission('haoka:order-operate-log:create')") @PreAuthorize("@ss.hasPermission('haoka:order-operate-log:create')")
public CommonResult<Long> createOrderOperateLog(@Valid @RequestBody OrderOperateLogSaveReqVO createReqVO) { public CommonResult<Long> createOrderOperateLog(@Valid @RequestBody OrderOperateLogSaveReqVO createReqVO) throws ExecutionException, InterruptedException {
return success(orderOperateLogService.createOrderOperateLog(createReqVO));
return success( orderOperateLogService.createOrderOperateLog(createReqVO).get());
} }
@PutMapping("/update") @PutMapping("/update")
@ -92,4 +94,4 @@ public class OrderOperateLogController {
BeanUtils.toBean(list, OrderOperateLogRespVO.class)); BeanUtils.toBean(list, OrderOperateLogRespVO.class));
} }
} }

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

@ -85,7 +85,9 @@ public class ApiDealServiceImpl implements ApiDealStrategyService {
return respApiDealResp; return respApiDealResp;
} catch (Exception e) { } catch (Exception e) {
logVO.setSuccess(false); logVO.setSuccess(false);
logVO.setResponse(e.getMessage());
logVO.setErrorInfo(e.getMessage()); logVO.setErrorInfo(e.getMessage());
logVO.setInnerNote(e.getMessage());
return ApiDealResp.failed(e.getMessage()); return ApiDealResp.failed(e.getMessage());
} finally { } finally {
// lock.unlock(); // lock.unlock();

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

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.haoka.service.api.strategy; package cn.iocoder.yudao.module.haoka.service.api.strategy;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.haoka.api.ApiFrom; import cn.iocoder.yudao.module.haoka.api.ApiFrom;
import cn.iocoder.yudao.module.haoka.api.ApiHuNanDXService; import cn.iocoder.yudao.module.haoka.api.ApiHuNanDXService;
import cn.iocoder.yudao.module.haoka.api.hainandianxin.HaiNanDianXinApi; import cn.iocoder.yudao.module.haoka.api.hainandianxin.HaiNanDianXinApi;
@ -47,6 +48,13 @@ public class HuNanDxApiDealStrategy implements ApiDealStrategy {
return haoKaAddressService.getAddress(code); return haoKaAddressService.getAddress(code);
} }
private String defaultString(String value) {
if (value == null) {
return "";
}
return value;
}
@Override @Override
public ApiDealResp<OrderApiCreateResp> createOrder(final SuperiorApiLogSaveReqVO logVO, OrderApiCreateParam param) throws Exception { public ApiDealResp<OrderApiCreateResp> createOrder(final SuperiorApiLogSaveReqVO logVO, OrderApiCreateParam param) throws Exception {
OnSaleProductPreOrderRespVO preProduct = onSaleProductService.getOnSaleProductPreOrder(param.getOnSaleProductId()); OnSaleProductPreOrderRespVO preProduct = onSaleProductService.getOnSaleProductPreOrder(param.getOnSaleProductId());
@ -54,7 +62,7 @@ public class HuNanDxApiDealStrategy 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("商品对接上游配置不存在");
} }
@ -101,7 +109,7 @@ public class HuNanDxApiDealStrategy implements ApiDealStrategy {
orderParam.setServiceOrderCusName(param.getIdCardName()); orderParam.setServiceOrderCusName(param.getIdCardName());
orderParam.setServiceOrderCusCardNo(param.getIdCardNum()); orderParam.setServiceOrderCusCardNo(param.getIdCardNum());
orderParam.setServiceOrderCusAccPhone(param.getPlanMobile()); orderParam.setServiceOrderCusAccPhone(param.getPlanMobile());
orderParam.setServiceOrderCusAccPhone(param.getAddressMobile()); orderParam.setServiceOrderCusContactPhone(param.getAddressMobile());
orderParam.setServiceOrderSalesNumber(skuConfigVO.getSuperiorCode()); orderParam.setServiceOrderSalesNumber(skuConfigVO.getSuperiorCode());
orderParam.setServiceOrderReceiverProvCode(addressProvince.getName()); orderParam.setServiceOrderReceiverProvCode(addressProvince.getName());
orderParam.setServiceOrderReceiverCityCode(addressCity.getName()); orderParam.setServiceOrderReceiverCityCode(addressCity.getName());
@ -117,14 +125,35 @@ public class HuNanDxApiDealStrategy implements ApiDealStrategy {
if (StringUtils.isNotEmpty(skuConfigVO.getConfig())) { if (StringUtils.isNotEmpty(skuConfigVO.getConfig())) {
String config = skuConfigVO.getConfig(); String config = skuConfigVO.getConfig();
JSONObject configs = JSON.parseObject(config); JSONObject configs = JSON.parseObject(config);
cardQualificationParam.setServiceOrderSource(configs.getString("ApiPrefix_serviceOrderSource")); String string = configs.getString("ApiPrefix_serviceOrderSource");
cardQualificationParam.setServiceOrderSource(string);
orderParam.setServiceOrderSource(configs.getString("ApiPrefix_serviceOrderSource")); orderParam.setServiceOrderSource(configs.getString("ApiPrefix_serviceOrderSource"));
String string1 = configs.getString("ApiPrefix_serviceOrderType");
orderParam.setServiceOrderType(string1!=null?string1:configs.getString("ApiPrefix_serviceOrderSource"));
// 补充其他字段如果 configs.getString 返回 null则填入 ""
orderParam.setServiceOrderIccid(defaultString(configs.getString("ApiPrefix_serviceOrderIccid")));
orderParam.setServiceOrderPhoneCellcore(defaultString(configs.getString("ApiPrefix_serviceOrderPhoneCellcore")));
orderParam.setServiceOrderReceiverName(defaultString(configs.getString("ApiPrefix_serviceOrderReceiverName")));
orderParam.setServiceOrderCpsRefereePeople(defaultString(configs.getString("ApiPrefix_serviceOrderCpsRefereePeople")));
orderParam.setServiceOrderRefereePeople(defaultString(configs.getString("ApiPrefix_serviceOrderRefereePeople")));
orderParam.setServiceOrderPayMethod(defaultString(configs.getString("ApiPrefix_serviceOrderPayMethod")));
orderParam.setServiceOrderPayStatus(defaultString(configs.getString("ApiPrefix_serviceOrderPayStatus")));
orderParam.setServiceOrderPayTranid(defaultString(configs.getString("ApiPrefix_serviceOrderPayTranid")));
orderParam.setServiceOrderPayOrderid(defaultString(configs.getString("ApiPrefix_serviceOrderPayOrderid")));
orderParam.setServiceOrderCardPic1(defaultString(configs.getString("ApiPrefix_serviceOrderCardPic1")));
orderParam.setServiceOrderActivationReferee(defaultString(configs.getString("ApiPrefix_serviceOrderActivationReferee")));
orderParam.setFingerNum(defaultString(configs.getString("ApiPrefix_fingerNum")));
orderParam.setInstallAddress(defaultString(configs.getString("ApiPrefix_installAddress")));
orderParam.setTbBusOppBroadBusAcc(defaultString(configs.getString("ApiPrefix_tbBusOppBroadBusAcc")));
orderParam.setServiceOrderRemark(defaultString(configs.getString("ApiPrefix_serviceOrderRemark")));
} }
HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.InternetCardQualificationResp> checked = apiHuNanDXService.checkInternetCardQualification(logVO, haokaSuperiorApiId,cardQualificationParam); HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.InternetCardQualificationResp> checked =
apiHuNanDXService.checkInternetCardQualification(logVO, haokaSuperiorApiId, cardQualificationParam);
OrderApiCreateResp superApiResponse = new OrderApiCreateResp(); OrderApiCreateResp superApiResponse = new OrderApiCreateResp();
if (!"00000".equals(checked.getRes_code())) { if (!"00000".equals(checked.getRes_code())) {
logVO.setResponse(JSON.toJSONString(checked)); logVO.setResponse(JSON.toJSONString(checked));
@ -162,97 +191,97 @@ public class HuNanDxApiDealStrategy implements ApiDealStrategy {
} }
HaiNanDxInfo.NeedSignQueryParam<HaiNanDxInfo.PossessPhoneNumberParam> needSignQueryParam = new HaiNanDxInfo.NeedSignQueryParam<>(); // HaiNanDxInfo.NeedSignQueryParam<HaiNanDxInfo.PossessPhoneNumberParam> needSignQueryParam = new HaiNanDxInfo.NeedSignQueryParam<>();
// 预占 1 // // 预占 1
{ // {
needSignQueryParam.setData(possessParam); // needSignQueryParam.setData(possessParam);
needSignQueryParam.setApiName("num.accept.possessNumber2To3"); // needSignQueryParam.setApiName("num.accept.possessNumber2To3");
HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.PossessPhoneNumberResp> possessResponse = apiHuNanDXService.possessPhoneNumber(logVO,haokaSuperiorApiId, needSignQueryParam); // HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.PossessPhoneNumberResp> possessResponse = apiHuNanDXService.possessPhoneNumber(logVO,haokaSuperiorApiId, needSignQueryParam);
if (!"00000".equals(possessResponse.getRes_code())) { // if (!"00000".equals(possessResponse.getRes_code())) {
logVO.setResponse(JSON.toJSONString(possessResponse)); // logVO.setResponse(JSON.toJSONString(possessResponse));
// return ApiDealResp.failed(checked.getRes_message()); //// return ApiDealResp.failed(checked.getRes_message());
//
superApiResponse.setOrderStatusCode("0"); // superApiResponse.setOrderStatusCode("0");
superApiResponse.setSupplierOrderStatusDesc(checked.getRes_message()); // superApiResponse.setSupplierOrderStatusDesc(checked.getRes_message());
return ApiDealResp.ok(superApiResponse); // return ApiDealResp.ok(superApiResponse);
} // }
JSONObject result = possessResponse.getResult(); // JSONObject result = possessResponse.getResult();
if (result == null || result.getJSONObject("respData") == null) { // if (result == null || result.getJSONObject("respData") == null) {
logVO.setResponse(JSON.toJSONString(possessResponse)); // logVO.setResponse(JSON.toJSONString(possessResponse));
// return ApiDealResp.failed(checked.getRes_message()); //// return ApiDealResp.failed(checked.getRes_message());
//
superApiResponse.setOrderStatusCode("0"); // superApiResponse.setOrderStatusCode("0");
superApiResponse.setSupplierOrderStatusDesc(checked.getRes_message()); // superApiResponse.setSupplierOrderStatusDesc(checked.getRes_message());
return ApiDealResp.ok(superApiResponse); // return ApiDealResp.ok(superApiResponse);
} // }
if (!"0000".equals(result.getJSONObject("respData").getString("respCode"))) { // if (!"0000".equals(result.getJSONObject("respData").getString("respCode"))) {
logVO.setResponse(result.getJSONObject("respData").getString("respDesc")); // logVO.setResponse(result.getJSONObject("respData").getString("respDesc"));
// return ApiDealResp.failed(checked.getRes_message()); //// return ApiDealResp.failed(checked.getRes_message());
//
superApiResponse.setOrderStatusCode("0"); // superApiResponse.setOrderStatusCode("0");
superApiResponse.setSupplierOrderStatusDesc(checked.getRes_message()); // superApiResponse.setSupplierOrderStatusDesc(checked.getRes_message());
return ApiDealResp.ok(superApiResponse); // return ApiDealResp.ok(superApiResponse);
} // }
} // }
//
// 正式占用 // // 正式占用
{ // {
needSignQueryParam.setData(possessParam); // needSignQueryParam.setData(possessParam);
needSignQueryParam.setApiName("num.accept.possessNumber3To5"); // needSignQueryParam.setApiName("num.accept.possessNumber3To5");
HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.PossessPhoneNumberResp> possessResponse = apiHuNanDXService.possessPhoneNumber(logVO, haokaSuperiorApiId,needSignQueryParam); // HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.PossessPhoneNumberResp> possessResponse = apiHuNanDXService.possessPhoneNumber(logVO, haokaSuperiorApiId,needSignQueryParam);
if (!"00000".equals(possessResponse.getRes_code())) { // if (!"00000".equals(possessResponse.getRes_code())) {
logVO.setResponse(JSON.toJSONString(possessResponse)); // logVO.setResponse(JSON.toJSONString(possessResponse));
// return ApiDealResp.failed(checked.getRes_message()); //// return ApiDealResp.failed(checked.getRes_message());
//
superApiResponse.setOrderStatusCode("0"); // superApiResponse.setOrderStatusCode("0");
superApiResponse.setSupplierOrderStatusDesc(checked.getRes_message()); // superApiResponse.setSupplierOrderStatusDesc(checked.getRes_message());
return ApiDealResp.ok(superApiResponse); // return ApiDealResp.ok(superApiResponse);
} // }
JSONObject result = possessResponse.getResult(); // JSONObject result = possessResponse.getResult();
if (result == null || result.getJSONObject("respData") == null) { // if (result == null || result.getJSONObject("respData") == null) {
logVO.setResponse(JSON.toJSONString(possessResponse)); // logVO.setResponse(JSON.toJSONString(possessResponse));
// return ApiDealResp.failed(checked.getRes_message()); //// return ApiDealResp.failed(checked.getRes_message());
//
superApiResponse.setOrderStatusCode("0"); // superApiResponse.setOrderStatusCode("0");
superApiResponse.setSupplierOrderStatusDesc(checked.getRes_message()); // superApiResponse.setSupplierOrderStatusDesc(checked.getRes_message());
return ApiDealResp.ok(superApiResponse); // return ApiDealResp.ok(superApiResponse);
} // }
if (!"0000".equals(result.getJSONObject("respData").getString("respCode"))) { // if (!"0000".equals(result.getJSONObject("respData").getString("respCode"))) {
logVO.setResponse(result.getJSONObject("respData").getString("respDesc")); // logVO.setResponse(result.getJSONObject("respData").getString("respDesc"));
// return ApiDealResp.failed(checked.getRes_message()); //// return ApiDealResp.failed(checked.getRes_message());
//
superApiResponse.setOrderStatusCode("0"); // superApiResponse.setOrderStatusCode("0");
superApiResponse.setSupplierOrderStatusDesc(result.getJSONObject("respData").getString("respDesc")); // superApiResponse.setSupplierOrderStatusDesc(result.getJSONObject("respData").getString("respDesc"));
return ApiDealResp.ok(superApiResponse); // return ApiDealResp.ok(superApiResponse);
} // }
} // }
// 下单 // 下单
HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.SyncOrderResp> responseInfo = apiHuNanDXService.syncOrder(logVO,haokaSuperiorApiId, orderParam); HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.SyncOrderResp> responseInfo = apiHuNanDXService.syncOrder(logVO, haokaSuperiorApiId, orderParam);
if (!"00000".equals(responseInfo.getRes_code())) { if (!"00000".equals(responseInfo.getRes_code())) {
logVO.setResponse(JSON.toJSONString(responseInfo)); logVO.setResponse(JSON.toJSONString(responseInfo));
// return ApiDealResp.failed(checked.getRes_message()); // return ApiDealResp.failed(checked.getRes_message());
superApiResponse.setOrderStatusCode("0"); superApiResponse.setOrderStatusCode("0");
superApiResponse.setSupplierOrderStatusDesc(checked.getRes_message()); superApiResponse.setSupplierOrderStatusDesc(responseInfo.getRes_message());
return ApiDealResp.ok(superApiResponse); return ApiDealResp.ok(superApiResponse);
} }
JSONObject result = responseInfo.getResult(); JSONObject result = responseInfo.getResult();
if (result == null || result.getJSONObject("code") == null) { if (result == null || result.getString("code") == null) {
logVO.setResponse(JSON.toJSONString(responseInfo)); logVO.setResponse(JSON.toJSONString(responseInfo));
// return ApiDealResp.failed(checked.getRes_message()); // return ApiDealResp.failed(checked.getRes_message());
superApiResponse.setOrderStatusCode("0"); superApiResponse.setOrderStatusCode("0");
superApiResponse.setSupplierOrderStatusDesc(checked.getRes_message()); superApiResponse.setSupplierOrderStatusDesc(responseInfo.getRes_message());
return ApiDealResp.ok(superApiResponse); return ApiDealResp.ok(superApiResponse);
} }
if (!"0".equals(result.getString("code"))) { if (!"0".equals(result.getString("code"))) {
logVO.setResponse(result.getString("message")); logVO.setResponse(result.getString("message"));
// return ApiDealResp.failed(checked.getRes_message()); // return ApiDealResp.failed(checked.getRes_message());
superApiResponse.setOrderStatusCode("0"); superApiResponse.setOrderStatusCode("0");
superApiResponse.setSupplierOrderStatusDesc(checked.getRes_message()); superApiResponse.setSupplierOrderStatusDesc(result.getString("message"));
return ApiDealResp.ok(superApiResponse); return ApiDealResp.ok(superApiResponse);
} }
@ -272,8 +301,8 @@ 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("商品对接上游配置不存在");
} }
@ -283,23 +312,75 @@ public class HuNanDxApiDealStrategy implements ApiDealStrategy {
try { try {
HaiNanDxInfo.QueryOrderParam queryParam = new HaiNanDxInfo.QueryOrderParam(); HaiNanDxInfo.QueryOrderParam queryParam = new HaiNanDxInfo.QueryOrderParam();
queryParam.setOutId(param.getId().toString()); queryParam.setOutId(param.getId().toString());
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");
@ -307,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");
@ -316,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

@ -13,11 +13,13 @@ import cn.iocoder.yudao.module.haoka.api.liantong.model.response.KingIdentityCus
import cn.iocoder.yudao.module.haoka.api.liantong.model.response.KingOrderSyncResponse; import cn.iocoder.yudao.module.haoka.api.liantong.model.response.KingOrderSyncResponse;
import cn.iocoder.yudao.module.haoka.api.liantong.model.response.KingPreOrderSyncResponse; import cn.iocoder.yudao.module.haoka.api.liantong.model.response.KingPreOrderSyncResponse;
import cn.iocoder.yudao.module.haoka.api.liantong.util.StringUtils; import cn.iocoder.yudao.module.haoka.api.liantong.util.StringUtils;
import cn.iocoder.yudao.module.haoka.controller.admin.address.vo.AddressVo;
import cn.iocoder.yudao.module.haoka.controller.admin.onsaleproduct.vo.OnSaleProductPreOrderRespVO; import cn.iocoder.yudao.module.haoka.controller.admin.onsaleproduct.vo.OnSaleProductPreOrderRespVO;
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.controller.admin.superiorproductconfig.vo.SuperiorProductConfigRespVO; import cn.iocoder.yudao.module.haoka.controller.admin.superiorproductconfig.vo.SuperiorProductConfigRespVO;
import cn.iocoder.yudao.module.haoka.dal.dataobject.superiorapi.SuperiorApiDO; import cn.iocoder.yudao.module.haoka.dal.dataobject.superiorapi.SuperiorApiDO;
import cn.iocoder.yudao.module.haoka.dal.dataobject.superiorproductconfig.SuperiorProductConfigDO; import cn.iocoder.yudao.module.haoka.dal.dataobject.superiorproductconfig.SuperiorProductConfigDO;
import cn.iocoder.yudao.module.haoka.service.address.HaoKaAddressService;
import cn.iocoder.yudao.module.haoka.service.api.*; import cn.iocoder.yudao.module.haoka.service.api.*;
import cn.iocoder.yudao.module.haoka.service.api.models.*; import cn.iocoder.yudao.module.haoka.service.api.models.*;
import cn.iocoder.yudao.module.haoka.service.onsaleproduct.OnSaleProductService; import cn.iocoder.yudao.module.haoka.service.onsaleproduct.OnSaleProductService;
@ -26,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 {
@ -46,8 +50,16 @@ public class LianTongApiDealStrategy implements ApiDealStrategy {
@Resource @Resource
private SuperiorProductConfigService superiorProductConfigService; private SuperiorProductConfigService superiorProductConfigService;
@Resource
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
@ -57,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("商品对接上游配置不存在");
} }
@ -67,7 +79,21 @@ public class LianTongApiDealStrategy implements ApiDealStrategy {
String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
LianTongArea receiveAddress = getAddress(param.getAddressDistrictCode()); String addressDistrictCode = param.getAddressDistrictCode();
LianTongArea receiveAddress = getAddress(addressDistrictCode);
if (receiveAddress == null) {
AddressVo address = haoKaAddressService.getAddress(addressDistrictCode);
String substring = addressDistrictCode.substring(0, 4) + "00";
receiveAddress = getAddress(substring);
if (address != null) {
receiveAddress = new LianTongArea();
receiveAddress.setName(address.getName());
receiveAddress.setProvinceCode(address.getProvinceCode() + "0000");
receiveAddress.setCityCode(address.getCityCode() + "00");
receiveAddress.setDistrictCode(address.getCode());
receiveAddress.setDistrictName(address.getName());
}
}
LianTongArea numAddress = getAddress(preProduct.getParentProduct().getBelongAreaCode()); LianTongArea numAddress = getAddress(preProduct.getParentProduct().getBelongAreaCode());
@ -90,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());
} }
@ -126,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);
@ -161,8 +187,11 @@ public class LianTongApiDealStrategy implements ApiDealStrategy {
preOrder.setChannel(configs.getString("ApiPrefix_channel")); preOrder.setChannel(configs.getString("ApiPrefix_channel"));
// 填充 preOrder 的其他字段 // 填充 preOrder 的其他字段
String orderTotalFee = configs.getString("ApiPrefix_orderTotalFee");
preOrder.setOrderTotalFee(configs.getString("ApiPrefix_orderTotalFee")); preOrder.setOrderTotalFee(orderTotalFee);
if (orderTotalFee==null){
preOrder.setOrderTotalFee("0");
}
preOrder.setIsOpenCF(configs.getString("ApiPrefix_isOpenCF")); preOrder.setIsOpenCF(configs.getString("ApiPrefix_isOpenCF"));
preOrder.setFinanceFlag(configs.getString("ApiPrefix_financeFlag")); preOrder.setFinanceFlag(configs.getString("ApiPrefix_financeFlag"));
preOrder.setFinanceChannelCode(configs.getString("ApiPrefix_financeChannelCode")); preOrder.setFinanceChannelCode(configs.getString("ApiPrefix_financeChannelCode"));
@ -195,7 +224,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());
} }

View File

@ -36,7 +36,7 @@ import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.invalidParamException; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.invalidParamException;
import static cn.iocoder.yudao.module.haoka.enums.ErrorCodeConstants.ON_SALE_PRODUCT_NOT_EXISTS; import static cn.iocoder.yudao.module.haoka.enums.ErrorCodeConstants.*;
/** /**
* 在售产品 Service 实现类 * 在售产品 Service 实现类
@ -75,6 +75,16 @@ public class OnSaleProductServiceImpl extends ServiceImpl<OnSaleProductMapper,On
public Long createOnSaleProduct(OnSaleProductSaveReqVO createReqVO) { public Long createOnSaleProduct(OnSaleProductSaveReqVO createReqVO) {
// 插入 // 插入
OnSaleProductDO onSaleProduct = BeanUtils.toBean(createReqVO, OnSaleProductDO.class); OnSaleProductDO onSaleProduct = BeanUtils.toBean(createReqVO, OnSaleProductDO.class);
if ( createReqVO.getSku()!=null){
OnSaleProductDO onSaleProductDO =
onSaleProductMapper.selectOne(new LambdaQueryWrapperX<OnSaleProductDO>().eq(OnSaleProductDO::getSku, createReqVO.getSku()));
if (onSaleProductDO!=null){
throw exception(PRODUCT_EXITS);
}
}
onSaleProductMapper.insert(onSaleProduct); onSaleProductMapper.insert(onSaleProduct);
onSaleProduct.setId(SnowflakeId.generate()); onSaleProduct.setId(SnowflakeId.generate());

View File

@ -1,11 +1,12 @@
package cn.iocoder.yudao.module.haoka.service.orderoperatelog; package cn.iocoder.yudao.module.haoka.service.orderoperatelog;
import java.util.*; import java.util.concurrent.CompletableFuture;
import jakarta.validation.*; import jakarta.validation.*;
import cn.iocoder.yudao.module.haoka.controller.admin.orderoperatelog.vo.*; import cn.iocoder.yudao.module.haoka.controller.admin.orderoperatelog.vo.*;
import cn.iocoder.yudao.module.haoka.dal.dataobject.orderoperatelog.OrderOperateLogDO; import cn.iocoder.yudao.module.haoka.dal.dataobject.orderoperatelog.OrderOperateLogDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam; import org.springframework.scheduling.annotation.Async;
/** /**
* 订单操作日志 Service 接口 * 订单操作日志 Service 接口
@ -20,7 +21,8 @@ public interface OrderOperateLogService {
* @param createReqVO 创建信息 * @param createReqVO 创建信息
* @return 编号 * @return 编号
*/ */
Long createOrderOperateLog(@Valid OrderOperateLogSaveReqVO createReqVO); @Async
CompletableFuture<Long> createOrderOperateLog(@Valid OrderOperateLogSaveReqVO createReqVO);
/** /**
* 更新订单操作日志 * 更新订单操作日志
@ -52,4 +54,4 @@ public interface OrderOperateLogService {
*/ */
PageResult<OrderOperateLogDO> getOrderOperateLogPage(OrderOperateLogPageReqVO pageReqVO); PageResult<OrderOperateLogDO> getOrderOperateLogPage(OrderOperateLogPageReqVO pageReqVO);
} }

View File

@ -1,15 +1,15 @@
package cn.iocoder.yudao.module.haoka.service.orderoperatelog; package cn.iocoder.yudao.module.haoka.service.orderoperatelog;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*; import java.util.concurrent.CompletableFuture;
import cn.iocoder.yudao.module.haoka.controller.admin.orderoperatelog.vo.*; import cn.iocoder.yudao.module.haoka.controller.admin.orderoperatelog.vo.*;
import cn.iocoder.yudao.module.haoka.dal.dataobject.orderoperatelog.OrderOperateLogDO; import cn.iocoder.yudao.module.haoka.dal.dataobject.orderoperatelog.OrderOperateLogDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.haoka.dal.mysql.orderoperatelog.OrderOperateLogMapper; import cn.iocoder.yudao.module.haoka.dal.mysql.orderoperatelog.OrderOperateLogMapper;
@ -29,15 +29,16 @@ public class OrderOperateLogServiceImpl implements OrderOperateLogService {
@Resource @Resource
private OrderOperateLogMapper orderOperateLogMapper; private OrderOperateLogMapper orderOperateLogMapper;
@Async
@Override @Override
public Long createOrderOperateLog(OrderOperateLogSaveReqVO createReqVO) { public CompletableFuture<Long> createOrderOperateLog(OrderOperateLogSaveReqVO createReqVO) {
// 插入 // 插入
OrderOperateLogDO orderOperateLog = BeanUtils.toBean(createReqVO, OrderOperateLogDO.class); OrderOperateLogDO orderOperateLog = BeanUtils.toBean(createReqVO, OrderOperateLogDO.class);
orderOperateLog.setCreator("1"); orderOperateLog.setCreator("1");
orderOperateLog.setUpdater("1"); orderOperateLog.setUpdater("1");
orderOperateLogMapper.insert(orderOperateLog); orderOperateLogMapper.insert(orderOperateLog);
// 返回 // 返回
return orderOperateLog.getId(); return CompletableFuture.completedFuture(orderOperateLog.getId());
} }
@Override @Override
@ -73,4 +74,4 @@ public class OrderOperateLogServiceImpl implements OrderOperateLogService {
return orderOperateLogMapper.selectPage(pageReqVO); return orderOperateLogMapper.selectPage(pageReqVO);
} }
} }

View File

@ -64,6 +64,14 @@ public class HaoKaProductServiceImpl extends ServiceImpl<HaoKaProductMapper, Hao
bizNo = "{{#haoKaProduct.id}}", bizNo = "{{#haoKaProduct.id}}",
success = LogRecordConstants.HAOKA_PRODUCT_CREATE_SUCCESS) success = LogRecordConstants.HAOKA_PRODUCT_CREATE_SUCCESS)
public Long createHaoKaProduct(HaoKaProductSaveReqVO createReqVO) { public Long createHaoKaProduct(HaoKaProductSaveReqVO createReqVO) {
if ( createReqVO.getSku()!=null){
HaoKaProductDO onSaleProductDO =
haoKaProductMapper.selectOne(new LambdaQueryWrapperX<HaoKaProductDO>().eq(HaoKaProductDO::getSku, createReqVO.getSku()));
if (onSaleProductDO!=null){
throw exception(PRODUCT_EXITS);
}
}
// 插入 // 插入
HaoKaProductDO haoKaProduct = BeanUtils.toBean(createReqVO, HaoKaProductDO.class); HaoKaProductDO haoKaProduct = BeanUtils.toBean(createReqVO, HaoKaProductDO.class);
haoKaProduct.setId(SnowflakeId.generate()); haoKaProduct.setId(SnowflakeId.generate());

View File

@ -1,5 +1,7 @@
package cn.iocoder.yudao.module.haoka.service.superiorproductconfig; package cn.iocoder.yudao.module.haoka.service.superiorproductconfig;
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
@ -35,6 +37,16 @@ public class SuperiorProductConfigServiceImpl
@Override @Override
public Long createSuperiorProductConfig(SuperiorProductConfigSaveReqVO createReqVO) { public Long createSuperiorProductConfig(SuperiorProductConfigSaveReqVO createReqVO) {
Long haokaProductId = createReqVO.getHaokaProductId();
Long haokaSuperiorApiId = createReqVO.getHaokaSuperiorApiId();
if (haokaProductId!=null&& haokaSuperiorApiId!=null){
SuperiorProductConfigDO superiorProductConfigDO = superiorProductConfigMapper.selectOne(new LambdaQueryWrapperX<SuperiorProductConfigDO>()
.eq(SuperiorProductConfigDO::getHaokaProductId, haokaProductId)
.eq(SuperiorProductConfigDO::getHaokaSuperiorApiId, haokaSuperiorApiId));
if (superiorProductConfigDO!=null){
throw exception(new ErrorCode(10012,"配置已经存在"));
}
}
// 插入 // 插入
SuperiorProductConfigDO superiorProductConfig = BeanUtils.toBean(createReqVO, SuperiorProductConfigDO.class); SuperiorProductConfigDO superiorProductConfig = BeanUtils.toBean(createReqVO, SuperiorProductConfigDO.class);
superiorProductConfigMapper.insert(superiorProductConfig); superiorProductConfigMapper.insert(superiorProductConfig);

View File

@ -1,154 +0,0 @@
package cn.iocoder.yudao.module.haoka.service.orderoperatelog;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.mock.mockito.MockBean;
import jakarta.annotation.Resource;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.haoka.controller.admin.orderoperatelog.vo.*;
import cn.iocoder.yudao.module.haoka.dal.dataobject.orderoperatelog.OrderOperateLogDO;
import cn.iocoder.yudao.module.haoka.dal.mysql.orderoperatelog.OrderOperateLogMapper;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Import;
import java.util.*;
import java.time.LocalDateTime;
import static cn.hutool.core.util.RandomUtil.*;
import static cn.iocoder.yudao.module.haoka.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
/**
* {@link OrderOperateLogServiceImpl} 的单元测试类
*
* @author 超级管理员
*/
@Import(OrderOperateLogServiceImpl.class)
public class OrderOperateLogServiceImplTest extends BaseDbUnitTest {
@Resource
private OrderOperateLogServiceImpl orderOperateLogService;
@Resource
private OrderOperateLogMapper orderOperateLogMapper;
@Test
public void testCreateOrderOperateLog_success() {
// 准备参数
OrderOperateLogSaveReqVO createReqVO = randomPojo(OrderOperateLogSaveReqVO.class).setId(null);
// 调用
Long orderOperateLogId = orderOperateLogService.createOrderOperateLog(createReqVO);
// 断言
assertNotNull(orderOperateLogId);
// 校验记录的属性是否正确
OrderOperateLogDO orderOperateLog = orderOperateLogMapper.selectById(orderOperateLogId);
assertPojoEquals(createReqVO, orderOperateLog, "id");
}
@Test
public void testUpdateOrderOperateLog_success() {
// mock 数据
OrderOperateLogDO dbOrderOperateLog = randomPojo(OrderOperateLogDO.class);
orderOperateLogMapper.insert(dbOrderOperateLog);// @Sql: 先插入出一条存在的数据
// 准备参数
OrderOperateLogSaveReqVO updateReqVO = randomPojo(OrderOperateLogSaveReqVO.class, o -> {
o.setId(dbOrderOperateLog.getId()); // 设置更新的 ID
});
// 调用
orderOperateLogService.updateOrderOperateLog(updateReqVO);
// 校验是否更新正确
OrderOperateLogDO orderOperateLog = orderOperateLogMapper.selectById(updateReqVO.getId()); // 获取最新的
assertPojoEquals(updateReqVO, orderOperateLog);
}
@Test
public void testUpdateOrderOperateLog_notExists() {
// 准备参数
OrderOperateLogSaveReqVO updateReqVO = randomPojo(OrderOperateLogSaveReqVO.class);
// 调用, 并断言异常
assertServiceException(() -> orderOperateLogService.updateOrderOperateLog(updateReqVO), ORDER_OPERATE_LOG_NOT_EXISTS);
}
@Test
public void testDeleteOrderOperateLog_success() {
// mock 数据
OrderOperateLogDO dbOrderOperateLog = randomPojo(OrderOperateLogDO.class);
orderOperateLogMapper.insert(dbOrderOperateLog);// @Sql: 先插入出一条存在的数据
// 准备参数
Long id = dbOrderOperateLog.getId();
// 调用
orderOperateLogService.deleteOrderOperateLog(id);
// 校验数据不存在了
assertNull(orderOperateLogMapper.selectById(id));
}
@Test
public void testDeleteOrderOperateLog_notExists() {
// 准备参数
Long id = randomLongId();
// 调用, 并断言异常
assertServiceException(() -> orderOperateLogService.deleteOrderOperateLog(id), ORDER_OPERATE_LOG_NOT_EXISTS);
}
@Test
@Disabled // TODO 请修改 null 为需要的值然后删除 @Disabled 注解
public void testGetOrderOperateLogPage() {
// mock 数据
OrderOperateLogDO dbOrderOperateLog = randomPojo(OrderOperateLogDO.class, o -> { // 等会查询到
o.setOrderId(null);
o.setMsg(null);
o.setMsgSource(null);
o.setMsgType(null);
o.setRemark(null);
o.setDeptId(null);
o.setCreateTime(null);
});
orderOperateLogMapper.insert(dbOrderOperateLog);
// 测试 orderId 不匹配
orderOperateLogMapper.insert(cloneIgnoreId(dbOrderOperateLog, o -> o.setOrderId(null)));
// 测试 msg 不匹配
orderOperateLogMapper.insert(cloneIgnoreId(dbOrderOperateLog, o -> o.setMsg(null)));
// 测试 msgSource 不匹配
orderOperateLogMapper.insert(cloneIgnoreId(dbOrderOperateLog, o -> o.setMsgSource(null)));
// 测试 msgType 不匹配
orderOperateLogMapper.insert(cloneIgnoreId(dbOrderOperateLog, o -> o.setMsgType(null)));
// 测试 remark 不匹配
orderOperateLogMapper.insert(cloneIgnoreId(dbOrderOperateLog, o -> o.setRemark(null)));
// 测试 deptId 不匹配
orderOperateLogMapper.insert(cloneIgnoreId(dbOrderOperateLog, o -> o.setDeptId(null)));
// 测试 createTime 不匹配
orderOperateLogMapper.insert(cloneIgnoreId(dbOrderOperateLog, o -> o.setCreateTime(null)));
// 准备参数
OrderOperateLogPageReqVO reqVO = new OrderOperateLogPageReqVO();
reqVO.setOrderId(null);
reqVO.setMsg(null);
reqVO.setMsgSource(null);
reqVO.setMsgType(null);
reqVO.setRemark(null);
reqVO.setDeptId(null);
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
// 调用
PageResult<OrderOperateLogDO> pageResult = orderOperateLogService.getOrderOperateLogPage(reqVO);
// 断言
assertEquals(1, pageResult.getTotal());
assertEquals(1, pageResult.getList().size());
assertPojoEquals(dbOrderOperateLog, pageResult.getList().get(0));
}
}