|
@@ -1,4 +1,6 @@
|
|
|
package org.dromara.backstage.consumption.service.impl;
|
|
package org.dromara.backstage.consumption.service.impl;
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
|
+import java.util.Date;
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.http.HttpRequest;
|
|
import cn.hutool.http.HttpRequest;
|
|
@@ -10,8 +12,10 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import io.seata.common.util.CollectionUtils;
|
|
import io.seata.common.util.CollectionUtils;
|
|
|
|
|
+import kotlin.reflect.jvm.internal.impl.load.java.JavaClassesTracker;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.dromara.backstage.consumption.domain.XfConsumeDetail;
|
|
import org.dromara.backstage.consumption.domain.XfConsumeDetail;
|
|
|
import org.dromara.backstage.consumption.domain.bo.HandImportConsumeBo;
|
|
import org.dromara.backstage.consumption.domain.bo.HandImportConsumeBo;
|
|
|
import org.dromara.backstage.consumption.domain.bo.HandImportExcelConsumeBo;
|
|
import org.dromara.backstage.consumption.domain.bo.HandImportExcelConsumeBo;
|
|
@@ -21,13 +25,18 @@ import org.dromara.backstage.consumption.domain.vo.XfConsumeDetailCKBKVo;
|
|
|
import org.dromara.backstage.consumption.domain.vo.XfConsumeDetailVo;
|
|
import org.dromara.backstage.consumption.domain.vo.XfConsumeDetailVo;
|
|
|
import org.dromara.backstage.consumption.mapper.XfConsumeDetailMapper;
|
|
import org.dromara.backstage.consumption.mapper.XfConsumeDetailMapper;
|
|
|
import org.dromara.backstage.consumption.service.IXfConsumeDetailService;
|
|
import org.dromara.backstage.consumption.service.IXfConsumeDetailService;
|
|
|
|
|
+import org.dromara.common.core.domain.R;
|
|
|
|
|
+import org.dromara.common.core.domain.model.ErrorInfo;
|
|
|
import org.dromara.common.core.enums.ConsumeRecordTypeEnum;
|
|
import org.dromara.common.core.enums.ConsumeRecordTypeEnum;
|
|
|
import org.dromara.common.core.enums.CreditTypeEnum;
|
|
import org.dromara.common.core.enums.CreditTypeEnum;
|
|
|
|
|
+import org.dromara.common.core.enums.SystemUseTypeEnum;
|
|
|
import org.dromara.common.core.utils.DateUtils;
|
|
import org.dromara.common.core.utils.DateUtils;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
|
|
+import org.dromara.consume.api.RemoteConsumeService;
|
|
|
|
|
+import org.dromara.consume.api.domain.bo.RemoteConsumeBo;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
@@ -48,6 +57,9 @@ public class XfConsumeDetailServiceImpl implements IXfConsumeDetailService {
|
|
|
|
|
|
|
|
private final XfConsumeDetailMapper baseMapper;
|
|
private final XfConsumeDetailMapper baseMapper;
|
|
|
|
|
|
|
|
|
|
+ @DubboReference
|
|
|
|
|
+ private final RemoteConsumeService remoteConsumeService;
|
|
|
|
|
+
|
|
|
// http://172.16.137.72/prod-api/consume
|
|
// http://172.16.137.72/prod-api/consume
|
|
|
@Value("${XF_CONSUME_URL}")
|
|
@Value("${XF_CONSUME_URL}")
|
|
|
private String XF_CONSUME_URL;
|
|
private String XF_CONSUME_URL;
|
|
@@ -331,48 +343,82 @@ public class XfConsumeDetailServiceImpl implements IXfConsumeDetailService {
|
|
|
bo.setPosRecordState("364");
|
|
bo.setPosRecordState("364");
|
|
|
bo.setTermRecordID(String.valueOf(i));
|
|
bo.setTermRecordID(String.valueOf(i));
|
|
|
|
|
|
|
|
- // 调用消费接口
|
|
|
|
|
- // http://172.16.137.72/prod-api/consume/v1/Consumes/ConsumeOriginal
|
|
|
|
|
- // 使用hutool工具包的http请求工具类 发送post请求
|
|
|
|
|
- HttpRequest httpRequest = HttpRequest.post(XF_CONSUME_URL+"/v1/Consumes/ConsumeOriginal")
|
|
|
|
|
- .body(JSONUtil.toJsonStr(bo));
|
|
|
|
|
- log.info("请求ConsumeOriginal开始:{}",httpRequest.toString());
|
|
|
|
|
- HttpResponse result = httpRequest.execute();
|
|
|
|
|
- log.info("请求ConsumeOriginal返回:{}", result.toString());
|
|
|
|
|
- String resBody = result.body();
|
|
|
|
|
- if(StringUtils.isBlank(resBody)){
|
|
|
|
|
- bo.setResult("失败");
|
|
|
|
|
- bo.setReason("ConsumeOriginal请求失败,返回为空");
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- JSONObject jsonObject = JSONUtil.parseObj(resBody);
|
|
|
|
|
- String employeeStrID = jsonObject.getStr("employeeStrID");
|
|
|
|
|
- if(StringUtils.isBlank(employeeStrID)){
|
|
|
|
|
- bo.setResult("失败");
|
|
|
|
|
- bo.setReason(resBody);
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- bo.setEmployeeName(jsonObject.getStr("employeeName"));
|
|
|
|
|
-
|
|
|
|
|
- // http://172.16.137.72/prod-api/consume/v1/Consumes/Consume
|
|
|
|
|
- HttpRequest httpRequestAgain = HttpRequest.post(XF_CONSUME_URL+"/v1/Consumes/Consume")
|
|
|
|
|
- .body(resBody);
|
|
|
|
|
- log.info("请求Consume开始:{}",httpRequestAgain.toString());
|
|
|
|
|
- HttpResponse resultAgain = httpRequestAgain.execute();
|
|
|
|
|
- log.info("请求Consume返回:{}", resultAgain.toString());
|
|
|
|
|
- String resBodyAgain = resultAgain.body();
|
|
|
|
|
- if(StringUtils.isBlank(resBodyAgain)){
|
|
|
|
|
- bo.setResult("失败");
|
|
|
|
|
- bo.setReason("Consume请求失败,返回为空");
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- JSONObject jsonObjectAgain = JSONUtil.parseObj(resBodyAgain);
|
|
|
|
|
- String employeeStrIDAgain = jsonObjectAgain.getStr("employeeStrID");
|
|
|
|
|
- if(StringUtils.isBlank(employeeStrIDAgain)){
|
|
|
|
|
- bo.setResult("失败");
|
|
|
|
|
- bo.setReason(resBody);
|
|
|
|
|
- continue;
|
|
|
|
|
|
|
+ RemoteConsumeBo remoteConsumeBo = new RemoteConsumeBo();
|
|
|
|
|
+ remoteConsumeBo.setUserId(0L);
|
|
|
|
|
+ remoteConsumeBo.setUserNo(0L);
|
|
|
|
|
+ remoteConsumeBo.setUserNumb(handImportExcelConsumeBo.getEmployeeStrID());
|
|
|
|
|
+ remoteConsumeBo.setRealName("");
|
|
|
|
|
+ remoteConsumeBo.setCardNo(0L);
|
|
|
|
|
+ remoteConsumeBo.setFactoryId(0L);
|
|
|
|
|
+ remoteConsumeBo.setBagType("");
|
|
|
|
|
+ remoteConsumeBo.setConsumeMoney(new BigDecimal(handImportExcelConsumeBo.getConsumeValue()));
|
|
|
|
|
+ remoteConsumeBo.setBalance(new BigDecimal("0"));
|
|
|
|
|
+ remoteConsumeBo.setConsumeDate(DateUtils.dateTime("yyyy-MM-dd HH:mm:ss",handImportExcelConsumeBo.getConsumeDate()));
|
|
|
|
|
+ remoteConsumeBo.setTermNo(Long.valueOf(handImportExcelConsumeBo.getTermID()));
|
|
|
|
|
+ remoteConsumeBo.setTermMac("");
|
|
|
|
|
+ remoteConsumeBo.setTermRecordId((long) i);
|
|
|
|
|
+ remoteConsumeBo.setMealType(0L);
|
|
|
|
|
+ // remoteConsumeBo.setConsumeId("");
|
|
|
|
|
+ // remoteConsumeBo.setRecordId(0L);
|
|
|
|
|
+ remoteConsumeBo.setRecordStatus(364L);
|
|
|
|
|
+ remoteConsumeBo.setStatusFlag(3);
|
|
|
|
|
+ remoteConsumeBo.setUseType(SystemUseTypeEnum.CONSUME.code());
|
|
|
|
|
+ // remoteConsumeBo.setOperatorId(0L);
|
|
|
|
|
+ // remoteConsumeBo.setOperatorName("");
|
|
|
|
|
+ remoteConsumeBo.setCreditType(CreditTypeEnum.HAND_CONSUME.code());
|
|
|
|
|
+ remoteConsumeBo.setTenantId("25");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ R<ErrorInfo> result = remoteConsumeService.dealKafkaConsumeData(remoteConsumeBo);
|
|
|
|
|
+ if (R.isError(result)) {
|
|
|
|
|
+ bo.setResult("失败");
|
|
|
|
|
+ bo.setReason(JSONUtil.toJsonStr(result.getData()));
|
|
|
|
|
+ continue;
|
|
|
}
|
|
}
|
|
|
|
|
+ // 调用消费接口
|
|
|
|
|
+ // // http://172.16.137.72/prod-api/consume/v1/Consumes/ConsumeOriginal
|
|
|
|
|
+ // // 使用hutool工具包的http请求工具类 发送post请求
|
|
|
|
|
+ // HttpRequest httpRequest = HttpRequest.post(XF_CONSUME_URL+"/v1/Consumes/ConsumeOriginal")
|
|
|
|
|
+ // .body(JSONUtil.toJsonStr(bo));
|
|
|
|
|
+ // log.info("请求ConsumeOriginal开始:{}",httpRequest.toString());
|
|
|
|
|
+ // HttpResponse result = httpRequest.execute();
|
|
|
|
|
+ // log.info("请求ConsumeOriginal返回:{}", result.toString());
|
|
|
|
|
+ // String resBody = result.body();
|
|
|
|
|
+ //
|
|
|
|
|
+ //
|
|
|
|
|
+ // if(StringUtils.isBlank(resBody)){
|
|
|
|
|
+ // bo.setResult("失败");
|
|
|
|
|
+ // bo.setReason("ConsumeOriginal请求失败,返回为空");
|
|
|
|
|
+ // continue;
|
|
|
|
|
+ // }
|
|
|
|
|
+ // JSONObject jsonObject = JSONUtil.parseObj(resBody);
|
|
|
|
|
+ // String employeeStrID = jsonObject.getStr("employeeStrID");
|
|
|
|
|
+ // if(StringUtils.isBlank(employeeStrID)){
|
|
|
|
|
+ // bo.setResult("失败");
|
|
|
|
|
+ // bo.setReason(resBody);
|
|
|
|
|
+ // continue;
|
|
|
|
|
+ // }
|
|
|
|
|
+ // bo.setEmployeeName(jsonObject.getStr("employeeName"));
|
|
|
|
|
+ //
|
|
|
|
|
+ // // http://172.16.137.72/prod-api/consume/v1/Consumes/Consume
|
|
|
|
|
+ // HttpRequest httpRequestAgain = HttpRequest.post(XF_CONSUME_URL+"/v1/Consumes/Consume")
|
|
|
|
|
+ // .body(resBody);
|
|
|
|
|
+ // log.info("请求Consume开始:{}",httpRequestAgain.toString());
|
|
|
|
|
+ // HttpResponse resultAgain = httpRequestAgain.execute();
|
|
|
|
|
+ // log.info("请求Consume返回:{}", resultAgain.toString());
|
|
|
|
|
+ // String resBodyAgain = resultAgain.body();
|
|
|
|
|
+ // if(StringUtils.isBlank(resBodyAgain)){
|
|
|
|
|
+ // bo.setResult("失败");
|
|
|
|
|
+ // bo.setReason("Consume请求失败,返回为空");
|
|
|
|
|
+ // continue;
|
|
|
|
|
+ // }
|
|
|
|
|
+ // JSONObject jsonObjectAgain = JSONUtil.parseObj(resBodyAgain);
|
|
|
|
|
+ // String employeeStrIDAgain = jsonObjectAgain.getStr("employeeStrID");
|
|
|
|
|
+ // if(StringUtils.isBlank(employeeStrIDAgain)){
|
|
|
|
|
+ // bo.setResult("失败");
|
|
|
|
|
+ // bo.setReason(resBody);
|
|
|
|
|
+ // continue;
|
|
|
|
|
+ // }
|
|
|
bo.setResult("成功");
|
|
bo.setResult("成功");
|
|
|
|
|
|
|
|
}
|
|
}
|