ソースを参照

Merge remote-tracking branch 'origin/main'

lishiqiang 2 週間 前
コミット
0736569e1d

+ 8 - 0
ship-module-trade/ship-module-trade-biz/src/main/java/com/yc/ship/module/trade/controller/admin/insurance/InsuranceController.java

@@ -96,6 +96,14 @@ public class InsuranceController {
         return success(true);
     }
 
+    @GetMapping("/queryEpolicyAll")
+    @Operation(summary = "根据id获取电子保单")
+    @OperateLog(type = API)
+    public CommonResult queryEpolicyListAll() {
+        insuranceService.queryInsuranceQuey();
+        return success(true);
+    }
+
 
     @GetMapping("/cancel")
     @Operation(summary = "退保")

+ 3 - 1
ship-module-trade/ship-module-trade-biz/src/main/java/com/yc/ship/module/trade/controller/admin/notify/NotifyController.java

@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
+import java.io.UnsupportedEncodingException;
 import java.util.Enumeration;
 
 /**
@@ -27,7 +28,8 @@ public class NotifyController {
     private NotifyService notifyService;
 
     @PostMapping("/insurance")
-    public String insuranceNotify(HttpServletRequest request) {
+    public String insuranceNotify(HttpServletRequest request) throws UnsupportedEncodingException {
+        request.setCharacterEncoding("UTF-8");
         String req = request.getParameter("req");
         log.info("收到保险通知:{}", req);
         NotifyInsuranceReqVO notifyInsuranceReqVO = JSONObject.parseObject(req, NotifyInsuranceReqVO.class);

+ 37 - 12
ship-module-trade/ship-module-trade-biz/src/main/java/com/yc/ship/module/trade/service/insurance/InsuranceServiceImpl.java

@@ -481,19 +481,44 @@ public class InsuranceServiceImpl implements InsuranceService {
         insuranceDO.setId(id);
         CommonResult commonResult = insuranceUtil.sendInsuranceApply(insuranceApplyReqDTO);
         if (!commonResult.isSuccess()) {
-            log.error("投保失败:{}", commonResult.getMsg());
             InsuranceDO insuranceDO1 = insuranceMapper.selectByVisitorId(id);
-            if(insuranceDO1 != null) {
-                insuranceDO1.setInsuranceStatus(InsuranceStatusEnum.FAIL.getValue());
-                insuranceDO1.setResMsg(commonResult.getMsg());
-                insuranceMapper.updateById(insuranceDO1);
-            }else {
-                insuranceDO.setInsuranceStatus(InsuranceStatusEnum.FAIL.getValue());
-                insuranceDO.setResMsg(commonResult.getMsg());
-                insuranceMapper.insert(insuranceDO);
+            String msg = commonResult.getMsg();
+            log.error("投保失败:{}", msg);
+            if (msg.contains("重复投保")) {
+                String insuranceId1 = msg.substring(msg.indexOf("此前已有投保单")+7, msg.indexOf("投保成功")).trim();
+                String policyNo = msg.substring(msg.indexOf("对应的保单号是")+7, msg.indexOf("\"}]}"));
+                if(insuranceDO1 != null) {
+                    insuranceDO1.setInsuranceStatus(InsuranceStatusEnum.SUCCESS.getValue());
+                    insuranceMapper.deleteById(insuranceDO1.getId());
+                    insuranceDO1.setId(Long.valueOf(insuranceId1));
+                    insuranceDO1.setPolicyNo(policyNo);
+                    insuranceMapper.insert(insuranceDO1);
+                }else {
+                    insuranceDO.setInsuranceStatus(InsuranceStatusEnum.SUCCESS.getValue());
+                    insuranceDO.setId(Long.valueOf(insuranceId1));
+                    insuranceDO.setPolicyNo(policyNo);
+                    insuranceMapper.insert(insuranceDO);
+                }
+                tradeVisitorDO.setIsInsure(InsuranceStatusEnum.SUCCESS.getValue());
+                tradeVisitorMapper.updateById(tradeVisitorDO);
+            } else {
+                if(insuranceDO1 != null) {
+                    insuranceDO1.setInsuranceStatus(InsuranceStatusEnum.FAIL.getValue());
+                    insuranceDO1.setResMsg(msg);
+                    insuranceMapper.updateById(insuranceDO1);
+                }else {
+                    insuranceDO.setInsuranceStatus(InsuranceStatusEnum.FAIL.getValue());
+                    insuranceDO.setResMsg(msg);
+                    insuranceMapper.insert(insuranceDO);
+                }
+                tradeVisitorDO.setIsInsure(InsuranceStatusEnum.FAIL.getValue());
+                tradeVisitorDO.setInsureMsg(msg);
+                tradeVisitorMapper.updateById(tradeVisitorDO);
             }
-            throw exception0(commonResult.getCode(), commonResult.getMsg());
+            throw exception0(commonResult.getCode(), msg);
         }
+        tradeVisitorDO.setIsInsure(InsuranceStatusEnum.INSURE.getValue());
+        tradeVisitorMapper.updateById(tradeVisitorDO);
         //保存投保信息
         insuranceMapper.deleteByVisitorId(id);
         insuranceDO.setResMsg(String.valueOf(commonResult.getCheckedData()));
@@ -511,7 +536,7 @@ public class InsuranceServiceImpl implements InsuranceService {
     @Override
     public void queryInsuranceByOrderId(Long id) {
         InsuranceDO insuranceDO = insuranceMapper.selectById(id);
-        CommonResult commonResult = insuranceUtil.queryInsuranceNew(insuranceDO.getInsuranceNo(),insuranceDO.getOrderId());
+        CommonResult commonResult = insuranceUtil.queryInsurance(id.toString());
         if (!commonResult.isSuccess()) {
             throw exception0(commonResult.getCode(), commonResult.getMsg());
         }
@@ -551,7 +576,7 @@ public class InsuranceServiceImpl implements InsuranceService {
 
     @Override
     public void queryInsuranceQuey() {
-        List<InsuranceDO> list = insuranceMapper.selectList(new LambdaQueryWrapper<InsuranceDO>().eq(InsuranceDO::getInsuranceStatus, 0).ge(InsuranceDO::getCreateTime, DateUtil.yesterday()));
+        List<InsuranceDO> list = insuranceMapper.selectList(new LambdaQueryWrapper<InsuranceDO>().ne(InsuranceDO::getInsuranceStatus, 1));
         for (InsuranceDO insuranceDO : list) {
 //            CommonResult commonResult = insuranceUtil.queryInsuranceNew(insuranceDO.getInsuranceNo(), insuranceDO.getOrderId());
             CommonResult commonResult = insuranceUtil.queryInsurance(insuranceDO.getId().toString());

+ 4 - 1
ship-module-trade/ship-module-trade-biz/src/main/java/com/yc/ship/module/trade/service/order/impl/TradeOrderRepositoryServiceImpl.java

@@ -274,7 +274,10 @@ public class TradeOrderRepositoryServiceImpl implements TradeOrderRepositoryServ
             newDetail.setName(newVisitorId != null ? newVisitorId.getName() : (newVisitorId2 != null ? newVisitorId2.getName() : oldDetail.getName()));
             newDetail.setIdCard(newVisitorId != null ? newVisitorId.getCredentialNo() : (newVisitorId2 != null ? newVisitorId2.getCredentialNo() : oldDetail.getIdCard()) );
             newDetail.setTenantId(oldDetail.getTenantId());
-            newDetail.setPhone(newVisitorId != null ? newVisitorId.getMobile() : (newVisitorId2 != null ? newVisitorId2.getMobile() :  oldDetail.getPhone()));
+            String phone = (oldDetail.getPhone() != null && !oldDetail.getPhone().isEmpty()) ? oldDetail.getPhone()
+                    : ((newVisitorId != null && newVisitorId.getMobile() != null && !newVisitorId.getMobile().isEmpty()) ? newVisitorId.getMobile()
+                    : (newVisitorId2 != null && newVisitorId2.getMobile() != null && !newVisitorId2.getMobile().isEmpty()) ? newVisitorId2.getMobile() : null);
+            newDetail.setPhone(phone);
             newDetail.setRemark(oldDetail.getRemark());
             newDetail.setStatus(oldDetail.getStatus());
             newDetail.setSignTime(oldDetail.getSignTime());

+ 2 - 0
ship-module-trade/ship-module-trade-biz/src/main/java/com/yc/ship/module/trade/service/pay/impl/TradeOrderPayServiceImpl.java

@@ -339,6 +339,7 @@ public class TradeOrderPayServiceImpl implements TradeOrderPayService {
                     }
                     //银行账单号
                     tradeOrderPayDO.setBillNo(payNotifyReqBO.getBillNo());
+                    tradeOrderPayDO.setPosNo(payNotifyReqBO.getChannelOrderNo());
                     //同步银行返回的支付时间
                     if (StrUtil.isNotBlank(payNotifyReqBO.getBillDate())) {
                         try {
@@ -396,6 +397,7 @@ public class TradeOrderPayServiceImpl implements TradeOrderPayService {
                     }
                     //银行账单号
                     tradeOrderPayDO.setBillNo(payNotifyReqBO.getBillNo());
+                    tradeOrderPayDO.setPosNo(payNotifyReqBO.getChannelOrderNo());
                     //同步银行返回的支付时间
                     if (StrUtil.isNotBlank(payNotifyReqBO.getBillDate())) {
                         try {

+ 1 - 6
ship-module-trade/ship-module-trade-biz/src/main/java/com/yc/ship/module/trade/service/report/impl/BankTransactionDetailsServiceImpl.java

@@ -149,12 +149,7 @@ public class BankTransactionDetailsServiceImpl implements BankTransactionDetails
 
         BigDecimal totalAmount = BigDecimal.ZERO;
         for (BankTransactionDetailsRespVO item : list) {
-            if (item.getAmount() != null && item.getAmount().compareTo(BigDecimal.ZERO) > 0) {
-                totalAmount = totalAmount.add(item.getAmount());
-            } else if (item.getAmount() != null && item.getAmount().compareTo(BigDecimal.ZERO) < 0) {
-                if("2".equals(item.getTransactionType())) {
-                    totalAmount = totalAmount.add(item.getAmount());
-                }
+            if (item.getAmount() != null) {
                 totalAmount = totalAmount.add(item.getAmount());
             }
         }

+ 1 - 1
ship-module-trade/ship-module-trade-biz/src/main/resources/mapper/order/TradeVisitorMapper.xml

@@ -521,7 +521,7 @@
         <if test="vo.name != null and vo.name != ''">
             and t1.name like concat('%',#{vo.name},'%')
         </if>
-        <if test="vo.isInsure != null and vo.isInsure != ''">
+        <if test="vo.isInsure != null">
             and t1.is_insure = #{vo.isInsure}
         </if>
 

+ 22 - 6
ship-module-trade/ship-module-trade-biz/src/main/resources/mapper/report/IncomeOrderLedgerMapper.xml

@@ -23,14 +23,15 @@
             IFNULL(tot.free_num, 0) AS freeCount,
             (IFNULL(tot.adult_total_num, 0) + IFNULL(tot.child_total_num, 0) +
              IFNULL(tot.baby_total_num, 0) + IFNULL(tot.with_total_num, 0) + IFNULL(tot.free_num, 0)) AS totalCount,
-            o.pay_amount AS marketingPrice,
+            IFNULL(p.pay_amount, 0) - COALESCE(refund_fee_sum.refund_amount, 0) AS marketingPrice,
             o.free_amount AS discountAmount,
             COALESCE(refund_fee_sum.refundFee, 0) AS refundFee,
-            (o.pay_amount - IFNULL(o.free_amount, 0) - COALESCE(refund_fee_sum.refundFee, 0)) AS actualSettlementPrice
+           (IFNULL(p.pay_amount, 0) - IFNULL(o.free_amount, 0) - COALESCE(refund_fee_sum.refundFee, 0) - COALESCE(refund_fee_sum.refund_amount, 0)) AS actualSettlementPrice
         FROM trade_order o
         INNER JOIN product_voyage v ON o.voyage_id = v.id AND v.deleted = 0
         INNER JOIN resource_route r ON v.route_id = r.id AND r.deleted = 0
         LEFT JOIN trade_order_total tot ON o.id = tot.old_order_id AND tot.deleted = 0
+        LEFT JOIN trade_order_pay p ON o.pay_status = 1 AND p.order_id = o.id AND p.deleted = 0 AND p.pay_status = 1
         LEFT JOIN (
             SELECT rm.order_id,
                    GROUP_CONCAT(DISTINCT rm.room_model_name SEPARATOR ',') AS room_model_name
@@ -39,12 +40,19 @@
             GROUP BY rm.order_id
         ) rm ON o.id = rm.order_id
         LEFT JOIN (
-            SELECT order_id, SUM(fee) AS refundFee
+            SELECT order_id, SUM(fee) AS refundFee, SUM(refund_amount) AS refund_amount
             FROM trade_refund
             WHERE deleted = 0 AND refund_status IN (6)
             GROUP BY order_id
         ) refund_fee_sum ON o.id = refund_fee_sum.order_id
         WHERE o.deleted = 0
+        AND (o.pay_status != 1 OR p.id IS NOT NULL)
+        /*AND NOT EXISTS (
+            SELECT 1 FROM ota_bill_order bo
+            INNER JOIN ota_bill b ON bo.bill_id = b.id AND b.deleted = 0
+            WHERE bo.order_id = o.id AND bo.deleted = 0
+            AND b.bill_status = 0
+        )*/
         <if test="vo.orderNo != null and vo.orderNo != ''">
             AND o.order_no LIKE CONCAT('%', #{vo.orderNo}, '%')
         </if>
@@ -106,14 +114,15 @@
             IFNULL(tot.free_num, 0) AS freeCount,
             (IFNULL(tot.adult_total_num, 0) + IFNULL(tot.child_total_num, 0) +
              IFNULL(tot.baby_total_num, 0) + IFNULL(tot.with_total_num, 0) + IFNULL(tot.free_num, 0)) AS totalCount,
-            o.pay_amount AS marketingPrice,
+            IFNULL(p.pay_amount, 0) - COALESCE(refund_fee_sum.refund_amount, 0) AS marketingPrice,
             o.free_amount AS discountAmount,
             COALESCE(refund_fee_sum.refundFee, 0) AS refundFee,
-            (o.pay_amount - IFNULL(o.free_amount, 0) - COALESCE(refund_fee_sum.refundFee, 0)) AS actualSettlementPrice
+            (IFNULL(p.pay_amount, 0) - IFNULL(o.free_amount, 0) - COALESCE(refund_fee_sum.refundFee, 0) - COALESCE(refund_fee_sum.refund_amount, 0)) AS actualSettlementPrice
         FROM trade_order o
         INNER JOIN product_voyage v ON o.voyage_id = v.id AND v.deleted = 0
         INNER JOIN resource_route r ON v.route_id = r.id AND r.deleted = 0
         LEFT JOIN trade_order_total tot ON o.id = tot.old_order_id AND tot.deleted = 0
+        LEFT JOIN trade_order_pay p ON o.pay_status = 1 AND p.order_id = o.id AND p.deleted = 0 AND p.pay_status = 1
         LEFT JOIN (
             SELECT rm.order_id,
                    GROUP_CONCAT(DISTINCT rm.room_model_name SEPARATOR ',') AS room_model_name
@@ -122,12 +131,19 @@
             GROUP BY rm.order_id
         ) rm ON o.id = rm.order_id
         LEFT JOIN (
-            SELECT order_id, SUM(fee) AS refundFee
+            SELECT order_id, SUM(fee) AS refundFee, SUM(refund_amount) AS refund_amount
             FROM trade_refund
             WHERE deleted = 0 AND refund_status IN (6)
             GROUP BY order_id
         ) refund_fee_sum ON o.id = refund_fee_sum.order_id
         WHERE o.deleted = 0
+        AND (o.pay_status != 1 OR p.id IS NOT NULL)
+        /*AND NOT EXISTS (
+            SELECT 1 FROM ota_bill_order bo
+            INNER JOIN ota_bill b ON bo.bill_id = b.id AND b.deleted = 0
+            WHERE bo.order_id = o.id AND bo.deleted = 0
+            AND b.bill_status = 1
+        )*/
         <if test="vo.orderNo != null and vo.orderNo != ''">
             AND o.order_no LIKE CONCAT('%', #{vo.orderNo}, '%')
         </if>