InsOrdersComponents.java 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package com.ydtech.modules.order.components;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.ydtech.modules.order.constants.OrderCacheConstant;
  5. import com.ydtech.modules.order.entity.InsOrders;
  6. import com.ydtech.modules.order.entity.vo.BaseQuoteInfoVo;
  7. import com.ydtech.modules.order.service.InsOrdersService;
  8. import com.ydtech.modules.protocol.service.PtlAgreementUnderwritingRulesService;
  9. import org.springframework.context.annotation.Lazy;
  10. import org.springframework.data.redis.core.StringRedisTemplate;
  11. import org.springframework.stereotype.Component;
  12. import org.springframework.util.ObjectUtils;
  13. @Component
  14. public class InsOrdersComponents {
  15. private final InsOrdersService insOrdersService;
  16. private final StringRedisTemplate redisTemplate;
  17. private final InsOrdersComponents proxyService;
  18. private final PtlAgreementUnderwritingRulesService ptlAgreementUnderwritingRulesService;
  19. public InsOrdersComponents(InsOrdersService insOrdersService, StringRedisTemplate redisTemplate,
  20. PtlAgreementUnderwritingRulesService ptlAgreementUnderwritingRulesService,
  21. @Lazy InsOrdersComponents proxyService) {
  22. this.insOrdersService = insOrdersService;
  23. this.redisTemplate = redisTemplate;
  24. this.ptlAgreementUnderwritingRulesService = ptlAgreementUnderwritingRulesService;
  25. this.proxyService = proxyService;
  26. }
  27. /**
  28. * 通订单号获取报价信息
  29. *
  30. * @param orderNo 订单ID
  31. * @return BaseQuoteInfoVo
  32. */
  33. public BaseQuoteInfoVo getQuoteInfo(String orderNo) {
  34. insOrdersService.existOrder(orderNo);
  35. String s = redisTemplate.opsForValue().get(OrderCacheConstant.QUOTE_INFO_KEY + orderNo);
  36. BaseQuoteInfoVo quoteInfoVo = JSON.parseObject(s, BaseQuoteInfoVo.class);
  37. if (ObjectUtils.isEmpty(quoteInfoVo)) {
  38. // 缓存中不存在,在数据库中取
  39. InsOrders insOrders = insOrdersService.getById(orderNo);
  40. return new BaseQuoteInfoVo(insOrders);
  41. }
  42. quoteInfoVo.setOrderNo(orderNo);
  43. // 核保规则
  44. return quoteInfoVo;
  45. }
  46. /**
  47. * 通过订单号校验核保规则
  48. * 通订单号获取报价信息
  49. *
  50. * @param orderNo 订单ID
  51. * @param agreementId 协议id
  52. * @return BaseQuoteInfoVo
  53. */
  54. public BaseQuoteInfoVo getQuoteInfo(String orderNo, String agreementId) {
  55. // 核保规则
  56. proxyService.getQuoteRules(orderNo, agreementId);
  57. return proxyService.getQuoteInfo(orderNo);
  58. }
  59. //查询子订单
  60. /**
  61. * 通订单号判断核保规则
  62. *
  63. * @param orderNo 订单ID
  64. */
  65. public void getQuoteRules(String orderNo, String agreementId) {
  66. String s = redisTemplate.opsForValue().get(OrderCacheConstant.QUOTE_RULES_KEY + orderNo);
  67. JSONObject jsonObject = JSON.parseObject(s);
  68. // ptlAgreementUnderwritingRulesService.ruleComparison(jsonObject, agreementId, 0);
  69. }
  70. }