ソースを参照

Merge remote-tracking branch 'origin/main'

jinch 2 日 前
コミット
0c8e8a7a06

+ 40 - 43
ship-module-trade/ship-module-trade-biz/src/main/java/com/yc/ship/module/trade/service/invoice/impl/InvoiceGroupServiceImpl.java

@@ -522,8 +522,8 @@ public class InvoiceGroupServiceImpl implements InvoiceGroupService {
         String secretKey = configApi.getPlatformConfigValueByKey("newinvoice.group.secretkey");
         String msg;
         try {
-//            JSONObject reqBody = this.buildRequestParam(invoiceList, type, "", remark);
-            JSONObject reqBody = this.buildRequestParamNew(invoiceList, type, "", remark);
+            JSONObject reqBody = this.buildRequestParam(invoiceList, type, "", remark);
+//            JSONObject reqBody = this.buildRequestParamNew(invoiceList, type, "", remark);//折扣行
             String batchNo = reqBody.getJSONObject("DDPCXX").getStr("DDQQPCH");
             log.error("发票开具请求参数reqBody={},secretKey={}", reqBody,secretKey);
             JSONObject resObj = this.doRequest(reqBody, method, secretKey);
@@ -876,13 +876,13 @@ public class InvoiceGroupServiceImpl implements InvoiceGroupService {
             JSONArray detailArray = new JSONArray();
             List<InvoiceInventoryDO> inventoryList = invoiceInventoryService.getInvoiceInventoryListByInvoiceId(invoice.getId());
             JSONObject detailObj;
-            BigDecimal taxExcludedAmount = BigDecimal.ZERO;
-            BigDecimal taxExcludedAmounttotal = BigDecimal.ZERO;
-            BigDecimal se = BigDecimal.ZERO;
-            BigDecimal tse = BigDecimal.ZERO;
-            BigDecimal tje = BigDecimal.ZERO;
-            BigDecimal taxIncludedAmount = BigDecimal.ZERO;
-            BigDecimal taxIncludedAmounttotal = BigDecimal.ZERO;
+            // 税价合计总金额
+            List<BigDecimal> zsjhjList = new ArrayList<>();
+            // 总税额
+            List<BigDecimal> zseList = new ArrayList<>();
+            // 总不含税金额
+            List<BigDecimal> zbhsjeList = new ArrayList<>();
+
             if (inventoryList.isEmpty()) {
                 int index = 1;
                 detailObj = new JSONObject();
@@ -898,22 +898,18 @@ public class InvoiceGroupServiceImpl implements InvoiceGroupService {
                 BigDecimal taxRate = new BigDecimal(configApi.getPlatformConfigValueByKey("newinvoice.taxRate"));
                 detailObj.set("SL", taxRate);
                 //含税金额
-                taxIncludedAmount = invoice.getPrice().add(invoice.getZkprice());
-                taxIncludedAmounttotal = invoice.getPrice();
+                BigDecimal hsje = invoice.getPrice().add(invoice.getZkprice()).setScale(2, RoundingMode.HALF_UP);
                 if (type == 1) {
-                    taxIncludedAmount = BigDecimal.ZERO.subtract(invoice.getPrice());
+                    hsje = BigDecimal.ZERO.subtract(invoice.getPrice()).setScale(2, RoundingMode.HALF_UP);
                 }
-//                String dylzfpmxxh = String.valueOf(IdWorker.getId()).substring(0,8);
-//                detailObj.set("DYLZFPMXXH", dylzfpmxxh);
+                zsjhjList.add(hsje);
                 //不含税金额
-                taxExcludedAmount = taxIncludedAmount.divide(new BigDecimal(1).add(taxRate), 2, RoundingMode.HALF_UP);
-                taxExcludedAmounttotal = taxIncludedAmounttotal.divide(new BigDecimal(1).add(taxRate), 2, RoundingMode.HALF_UP);
-                //金额
-                tje = taxIncludedAmount.setScale(2, RoundingMode.HALF_UP);
-                detailObj.set("JE", taxIncludedAmount.setScale(2, RoundingMode.HALF_UP));
+                BigDecimal bhsje = hsje.subtract(hsje.multiply(taxRate)).setScale(2, RoundingMode.HALF_UP);
+                zbhsjeList.add(bhsje);
+                detailObj.set("JE", hsje);
                 //税额
-                se = taxIncludedAmount.subtract(taxExcludedAmount).setScale(2, RoundingMode.HALF_UP);
-                tse =se;
+                BigDecimal se = hsje.subtract(bhsje).setScale(2, RoundingMode.HALF_UP);
+                zseList.add(se);
                 detailObj.set("SE", se);
                 //扣除额
                 detailObj.set("KCE", "");
@@ -938,18 +934,17 @@ public class InvoiceGroupServiceImpl implements InvoiceGroupService {
                     //税率
                     detailObj2.set("SL", taxRate);
                     //含税金额
-                    taxIncludedAmount = BigDecimal.ZERO.subtract( invoice.getZkprice());
-//                String dylzfpmxxh = String.valueOf(IdWorker.getId()).substring(0,8);
-//                detailObj.set("DYLZFPMXXH", dylzfpmxxh);
+                    BigDecimal hsje1 = BigDecimal.ZERO.subtract(invoice.getZkprice()).setScale(2, RoundingMode.HALF_UP);
+                    zsjhjList.add(hsje1);
                     //不含税金额
-                    taxExcludedAmount = taxIncludedAmount.divide(new BigDecimal(1).add(taxRate), 2, RoundingMode.HALF_UP);
+                    BigDecimal bhsje1 = hsje1.subtract(hsje1.multiply(taxRate)).setScale(2, RoundingMode.HALF_UP);
+                    zbhsjeList.add(bhsje1);
                     //金额
-                    tje = tje.add(taxIncludedAmount.setScale(2, RoundingMode.HALF_UP));
-                    detailObj2.set("JE", taxIncludedAmount.setScale(2, RoundingMode.HALF_UP));
+                    detailObj2.set("JE", hsje1);
                     //税额
-                    se = taxIncludedAmount.subtract(taxExcludedAmount);
-                    tse = tse.add(se.setScale(2, RoundingMode.HALF_UP));
-                    detailObj2.set("SE", se.setScale(2, RoundingMode.HALF_UP));
+                    BigDecimal se1 = hsje1.subtract(bhsje1).setScale(2, RoundingMode.HALF_UP);
+                    zseList.add(se1);
+                    detailObj2.set("SE", se1);
                     //扣除额
                     detailObj2.set("KCE", "");
                     //行性质。0-正常行 1-折扣行 2-被折扣行
@@ -966,15 +961,18 @@ public class InvoiceGroupServiceImpl implements InvoiceGroupService {
                 InvoiceInventorySaveReqVO saveReqVO = new InvoiceInventorySaveReqVO();
                 saveReqVO.setInvoiceId(invoice.getId());
                 saveReqVO.setSort(index);
-                saveReqVO.setAmount(taxIncludedAmount);
-                saveReqVO.setTax(se);
+                // 总含税金额
+                BigDecimal totalHsje = zsjhjList.stream().reduce(BigDecimal.ZERO, BigDecimal::add);
+                saveReqVO.setAmount(totalHsje);
+                // 总税额
+                BigDecimal totalSe = zseList.stream().reduce(BigDecimal.ZERO, BigDecimal::add);
+                saveReqVO.setTax(totalSe);
                 saveReqVO.setCode(spbm);
                 saveReqVO.setName(spmc);
                 saveReqVO.setTaxRate(taxRate);
                 saveReqVO.setFphxz(0);
                 saveReqVO.setHsbz(1);
                 saveReqVO.setYhzcbs(0);
-//                saveReqVO.setDylzfpmxxh(dylzfpmxxh);
                 InvoiceInventoryDO invoiceInventoryDO = invoiceInventoryService.createInvoiceInventory(saveReqVO);
                 inventoryList = new ArrayList<>(3);
                 inventoryList.add(invoiceInventoryDO);
@@ -1012,22 +1010,21 @@ public class InvoiceGroupServiceImpl implements InvoiceGroupService {
                     //0:不使用,1:使用,SPID为空时必填
                     detailObj.set("YHZCBS", invoiceInventoryDO.getYhzcbs());
                     detailArray.add(detailObj);
-
-                    taxExcludedAmount = taxExcludedAmount.add(thisTaxExcludedAmount);
-                    se = se.add(thisSe);
-                    taxIncludedAmount = taxIncludedAmount.add(thisTaxIncludedAmount);
                 }
             }
-            //合计金额
-            reqObj.set("HJJE", tje);
+            // 总不含税金额
+            BigDecimal totalBhsje = zbhsjeList.stream().reduce(BigDecimal.ZERO, BigDecimal::add);
+            reqObj.set("HJJE", totalBhsje);
             //合计税额
-            reqObj.set("HJSE", tse);
+            BigDecimal totalSe = zseList.stream().reduce(BigDecimal.ZERO, BigDecimal::add);
+            reqObj.set("HJSE", totalSe);
             if (StringUtils.isNotBlank(remark)) {
                 //备注
                 reqObj.set("BZ", remark);
             }
             //价税合计
-            reqObj.set("JSHJ", taxIncludedAmounttotal.setScale(2, RoundingMode.HALF_UP));
+            BigDecimal totalSjhj = zsjhjList.stream().reduce(BigDecimal.ZERO, BigDecimal::add);
+            reqObj.set("JSHJ", totalSjhj);
             //系统来源
             reqObj.set("SX_XTLY", StrUtil.isNotBlank(sysSource) ? sysSource : "SX_LYEQ");
 //            reqObj.set("DDMXXX", detailArray);
@@ -1037,8 +1034,8 @@ public class InvoiceGroupServiceImpl implements InvoiceGroupService {
             reqDDZ.add(jsonObject);
             log.error("请求参数:{}", reqDDZ);
 
-            invoice.setCHjse(se);
-            invoice.setCBhsje(taxExcludedAmounttotal);
+            invoice.setCHjse(totalSe);
+            invoice.setCBhsje(totalBhsje);
         });
         requestBody.set("DDZXX", reqDDZ);
         return requestBody;

+ 2 - 0
ship-module-trade/ship-module-trade-biz/src/main/java/com/yc/ship/module/trade/service/order/TradeOrderLogService.java

@@ -1,6 +1,7 @@
 package com.yc.ship.module.trade.service.order;
 
 
+import com.yc.ship.framework.tenant.core.aop.TenantIgnore;
 import com.yc.ship.module.trade.dal.dataobject.order.TradeOrderLogDO;
 import com.yc.ship.module.trade.enums.TradeOrderOperateTypeEnum;
 import com.yc.ship.module.trade.service.order.bo.TradeOrderLogCreateReqBO;
@@ -22,6 +23,7 @@ public interface TradeOrderLogService {
      */
     @Async
     @PermitAll
+    @TenantIgnore
     void createOrderLog(TradeOrderLogCreateReqBO logDTO);
 
     /**

+ 1 - 1
ship-module-trade/ship-module-trade-biz/src/main/java/com/yc/ship/module/trade/service/otc/impl/OtcTradeOrderServiceImpl.java

@@ -1911,9 +1911,9 @@ public class OtcTradeOrderServiceImpl implements OtcTradeOrderService {
             //支付倒计时--不超时,有预订单
             Map<String, Object> append = TradeOrderLogUtils.append("result", "订单创建成功");
             append.put("content", "");
-            TradeOrderLogUtils.setOrderInfo(orderId, null, orderStatus, append);
             tradePublishUtils.publishOrderCreateSuccessMsg(orderId + "");
             OtcTradeOrderCreateRespVO respVO = TradeOrderConvert.INSTANCE.convert(result.getData());
+            TradeOrderLogUtils.setOrderInfo(orderId, null, orderStatus, append);
             return CommonResult.success(respVO);
         } finally {
             if (lock.isHeldByCurrentThread() && lock.isLocked()) {

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

@@ -2202,7 +2202,7 @@
             trade_order_room_model t1
                 LEFT JOIN resource_room_model t2 ON t1.room_model_id = t2.id  and t2.deleted = 0
                 LEFT JOIN trade_visitor t3 ON t1.room_index_id = t3.room_index_id  and t3.deleted = 0
-                LEFT JOIN trade_detail t5 on t3.id = t5.visitor_id and t5.deleted =0
+                LEFT JOIN trade_detail t5 on t3.id = t5.visitor_id and t5.deleted =0 and t5.product_type = 0
                 LEFT JOIN area t4 ON t3.nationality = t4.id
         WHERE
             t1.order_id = #{orderId}