|
|
@@ -8,8 +8,16 @@ import com.java110.core.smo.IComputeFeeSMO;
|
|
|
import com.java110.dto.fee.FeeDetailDto;
|
|
|
import com.java110.dto.fee.FeeDto;
|
|
|
import com.java110.dto.logSystemError.LogSystemErrorDto;
|
|
|
+import com.java110.dto.machinePrinter.MachinePrinterDto;
|
|
|
import com.java110.dto.owner.OwnerDto;
|
|
|
+import com.java110.dto.printerRule.PrinterRuleDto;
|
|
|
+import com.java110.dto.printerRuleFee.PrinterRuleFeeDto;
|
|
|
+import com.java110.dto.printerRuleMachine.PrinterRuleMachineDto;
|
|
|
import com.java110.entity.order.Business;
|
|
|
+import com.java110.intf.common.IMachinePrinterV1InnerServiceSMO;
|
|
|
+import com.java110.intf.common.IPrinterRuleFeeV1InnerServiceSMO;
|
|
|
+import com.java110.intf.common.IPrinterRuleMachineV1InnerServiceSMO;
|
|
|
+import com.java110.intf.common.IPrinterRuleV1InnerServiceSMO;
|
|
|
import com.java110.intf.community.ICommunityInnerServiceSMO;
|
|
|
import com.java110.intf.fee.IFeeDetailInnerServiceSMO;
|
|
|
import com.java110.intf.fee.IFeeInnerServiceSMO;
|
|
|
@@ -20,15 +28,19 @@ import com.java110.intf.user.IOwnerCarInnerServiceSMO;
|
|
|
import com.java110.intf.user.IOwnerInnerServiceSMO;
|
|
|
import com.java110.intf.user.IOwnerRoomRelInnerServiceSMO;
|
|
|
import com.java110.job.adapt.DatabusAdaptImpl;
|
|
|
+import com.java110.job.printer.IPrinter;
|
|
|
import com.java110.po.fee.PayFeeDetailPo;
|
|
|
import com.java110.po.feeReceipt.FeeReceiptPo;
|
|
|
import com.java110.po.feeReceiptDetail.FeeReceiptDetailPo;
|
|
|
import com.java110.po.logSystemError.LogSystemErrorPo;
|
|
|
import com.java110.service.smo.ISaveSystemErrorSMO;
|
|
|
+import com.java110.utils.exception.CmdException;
|
|
|
+import com.java110.utils.factory.ApplicationContextFactory;
|
|
|
import com.java110.utils.util.Assert;
|
|
|
import com.java110.utils.util.BeanConvertUtil;
|
|
|
import com.java110.utils.util.ExceptionUtil;
|
|
|
import com.java110.utils.util.StringUtil;
|
|
|
+import com.java110.vo.ResultVo;
|
|
|
import org.slf4j.Logger;
|
|
|
import com.java110.core.log.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -81,6 +93,18 @@ public class PayFeeReceiptAdapt extends DatabusAdaptImpl {
|
|
|
@Autowired
|
|
|
private IOwnerAppUserInnerServiceSMO ownerAppUserInnerServiceSMO;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IPrinterRuleFeeV1InnerServiceSMO printerRuleFeeV1InnerServiceSMOImpl;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IPrinterRuleV1InnerServiceSMO printerRuleV1InnerServiceSMOImpl;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IPrinterRuleMachineV1InnerServiceSMO printerRuleMachineV1InnerServiceSMOImpl;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IMachinePrinterV1InnerServiceSMO machinePrinterV1InnerServiceSMOImpl;
|
|
|
+
|
|
|
//模板信息推送地址
|
|
|
private static String sendMsgUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=";
|
|
|
|
|
|
@@ -90,8 +114,8 @@ public class PayFeeReceiptAdapt extends DatabusAdaptImpl {
|
|
|
public void execute(Business business, List<Business> businesses) {
|
|
|
JSONObject data = business.getData();
|
|
|
|
|
|
- if(data != null){
|
|
|
- logger.debug("请求日志:{}",data);
|
|
|
+ if (data != null) {
|
|
|
+ logger.debug("请求日志:{}", data);
|
|
|
}
|
|
|
JSONArray businessPayFeeDetails = null;
|
|
|
if (data == null) {
|
|
|
@@ -147,9 +171,9 @@ public class PayFeeReceiptAdapt extends DatabusAdaptImpl {
|
|
|
|
|
|
// if received amount lt zero
|
|
|
|
|
|
- if(businessPayFeeDetail.containsKey("receivedAmount")
|
|
|
- && businessPayFeeDetail.getDoubleValue("receivedAmount")<0){
|
|
|
- return ;
|
|
|
+ if (businessPayFeeDetail.containsKey("receivedAmount")
|
|
|
+ && businessPayFeeDetail.getDoubleValue("receivedAmount") < 0) {
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
//添加单元信息
|
|
|
@@ -185,7 +209,10 @@ public class PayFeeReceiptAdapt extends DatabusAdaptImpl {
|
|
|
//这里只是写入 收据表,暂不考虑 事务一致性问题,就算写入失败 也只是影响 收据打印,如果 贵公司对 收据要求 比较高,不能有失败的情况 请加入事务管理
|
|
|
feeReceiptDetailInnerServiceSMOImpl.saveFeeReceiptDetail(feeReceiptDetailPo);
|
|
|
feeReceiptInnerServiceSMOImpl.saveFeeReceipt(feeReceiptPo);
|
|
|
- }catch (Exception e){
|
|
|
+
|
|
|
+ // 是否配置了自动打印功能 如果配置了自动打印功能 自动打印
|
|
|
+ autoPrintReceipt(businessPayFeeDetail.getString("detailId"), feeDto.getCommunityId());
|
|
|
+ } catch (Exception e) {
|
|
|
LogSystemErrorPo logSystemErrorPo = new LogSystemErrorPo();
|
|
|
logSystemErrorPo.setErrId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_errId));
|
|
|
logSystemErrorPo.setErrType(LogSystemErrorDto.ERR_TYPE_NOTICE);
|
|
|
@@ -196,4 +223,72 @@ public class PayFeeReceiptAdapt extends DatabusAdaptImpl {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ private void autoPrintReceipt(String detailId, String communityId) {
|
|
|
+
|
|
|
+ FeeDetailDto feeDetailDto = new FeeDetailDto();
|
|
|
+ feeDetailDto.setDetailId(detailId);
|
|
|
+ feeDetailDto.setCommunityId(communityId);
|
|
|
+ List<FeeDetailDto> feeDetailDtos = feeDetailInnerServiceSMOImpl.queryFeeDetails(feeDetailDto);
|
|
|
+
|
|
|
+ if (feeDetailDtos == null || feeDetailDtos.size() < 1) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ PrinterRuleFeeDto printerRuleFeeDto = new PrinterRuleFeeDto();
|
|
|
+ printerRuleFeeDto.setCommunityId(communityId);
|
|
|
+ printerRuleFeeDto.setFeeId(feeDetailDtos.get(0).getConfigId());
|
|
|
+ List<PrinterRuleFeeDto> printerRuleFeeDtos = printerRuleFeeV1InnerServiceSMOImpl.queryPrinterRuleFees(printerRuleFeeDto);
|
|
|
+
|
|
|
+ if (printerRuleFeeDtos == null || printerRuleFeeDtos.size() < 1) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ PrinterRuleDto printerRuleDto = new PrinterRuleDto();
|
|
|
+ printerRuleDto.setRuleId(printerRuleFeeDtos.get(0).getRuleId());
|
|
|
+ printerRuleDto.setCommunityId(communityId);
|
|
|
+ printerRuleDto.setState(PrinterRuleDto.STATE_NORMAL);
|
|
|
+ int count = printerRuleV1InnerServiceSMOImpl.queryPrinterRulesCount(printerRuleDto);
|
|
|
+
|
|
|
+ if (count < 1) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ PrinterRuleMachineDto printerRuleMachineDto = new PrinterRuleMachineDto();
|
|
|
+ printerRuleMachineDto.setCommunityId(communityId);
|
|
|
+ printerRuleMachineDto.setRuleId(printerRuleFeeDtos.get(0).getRuleId());
|
|
|
+ List<PrinterRuleMachineDto> printerRuleMachineDtos = printerRuleMachineV1InnerServiceSMOImpl.queryPrinterRuleMachines(printerRuleMachineDto);
|
|
|
+ if (printerRuleMachineDtos == null || printerRuleMachineDtos.size() < 1) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (PrinterRuleMachineDto tmpPrinterRuleMachineDto : printerRuleMachineDtos) {
|
|
|
+ try {
|
|
|
+ doPrint(tmpPrinterRuleMachineDto, detailId);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void doPrint(PrinterRuleMachineDto tmpPrinterRuleMachineDto, String detailId) {
|
|
|
+ MachinePrinterDto machinePrinterDto = new MachinePrinterDto();
|
|
|
+ machinePrinterDto.setCommunityId(tmpPrinterRuleMachineDto.getCommunityId());
|
|
|
+ machinePrinterDto.setMachineId(tmpPrinterRuleMachineDto.getMachineId());
|
|
|
+ List<MachinePrinterDto> machinePrinterDtos = machinePrinterV1InnerServiceSMOImpl.queryMachinePrinters(machinePrinterDto);
|
|
|
+
|
|
|
+ Assert.listOnlyOne(machinePrinterDtos, "云打印机不存在");
|
|
|
+
|
|
|
+ IPrinter printer = ApplicationContextFactory.getBean(machinePrinterDtos.get(0).getImplBean(), IPrinter.class);
|
|
|
+
|
|
|
+ if (printer == null) {
|
|
|
+ throw new CmdException("打印机异常,未包含适配器");
|
|
|
+ }
|
|
|
+
|
|
|
+ printer.printPayFeeDetail(new String[]{detailId}, tmpPrinterRuleMachineDto.getCommunityId(), Integer.parseInt(tmpPrinterRuleMachineDto.getQuantity()), machinePrinterDtos.get(0));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|