From b687aa0f371e12d4ec1813f18a4f889e8f825f67 Mon Sep 17 00:00:00 2001
From: jyy <jyy>
Date: Fri, 03 Sep 2021 14:19:08 +0800
Subject: [PATCH] Merge branch 'score_shop' into api_score_meger

---
 zq-erp/src/main/java/com/matrix/system/common/interceptor/ApiUserLoginInterceptor.java |   10 ++--
 zq-erp/src/main/java/com/matrix/config/CrossOriginConfig.java                          |   33 ++++++++++++++++
 zq-erp/src/main/java/com/matrix/system/app/action/ApiCommonAction.java                 |    5 ++
 zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java       |   14 ++++---
 4 files changed, 51 insertions(+), 11 deletions(-)

diff --git a/zq-erp/src/main/java/com/matrix/config/CrossOriginConfig.java b/zq-erp/src/main/java/com/matrix/config/CrossOriginConfig.java
new file mode 100644
index 0000000..f389e3f
--- /dev/null
+++ b/zq-erp/src/main/java/com/matrix/config/CrossOriginConfig.java
@@ -0,0 +1,33 @@
+package com.matrix.config;
+
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.cors.CorsConfiguration;
+import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
+import org.springframework.web.filter.CorsFilter;
+
+/**
+ * @author JIANGYOUYAO
+ * @date 2021/5/29 0029
+ */
+@Configuration
+public class CrossOriginConfig {
+
+    private CorsConfiguration buildConfig() {
+        CorsConfiguration corsConfiguration = new CorsConfiguration();
+        corsConfiguration.addAllowedOrigin("*");
+        corsConfiguration.addAllowedHeader("*");
+        corsConfiguration.addAllowedMethod("*");
+        corsConfiguration.setAllowCredentials(true);
+        return corsConfiguration;
+    }
+
+    @Bean
+    public CorsFilter corsFilter() {
+        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
+        source.registerCorsConfiguration("/**", buildConfig());
+        return new CorsFilter(source);
+    }
+
+}
diff --git a/zq-erp/src/main/java/com/matrix/system/app/action/ApiCommonAction.java b/zq-erp/src/main/java/com/matrix/system/app/action/ApiCommonAction.java
index 6090035..5093d22 100644
--- a/zq-erp/src/main/java/com/matrix/system/app/action/ApiCommonAction.java
+++ b/zq-erp/src/main/java/com/matrix/system/app/action/ApiCommonAction.java
@@ -238,6 +238,11 @@
         urlDto.setName("美度专线");
         data.add(urlDto);
 
+        urlDto = new UrlDto();
+        urlDto.setUrl("http://localhost:8080");
+        urlDto.setName("开发环境");
+        data.add(urlDto);
+
         return AjaxResult.buildSuccessInstance(data);
     }
 
diff --git a/zq-erp/src/main/java/com/matrix/system/common/interceptor/ApiUserLoginInterceptor.java b/zq-erp/src/main/java/com/matrix/system/common/interceptor/ApiUserLoginInterceptor.java
index e7597e6..0d24e53 100644
--- a/zq-erp/src/main/java/com/matrix/system/common/interceptor/ApiUserLoginInterceptor.java
+++ b/zq-erp/src/main/java/com/matrix/system/common/interceptor/ApiUserLoginInterceptor.java
@@ -43,11 +43,11 @@
 
     @Override
     public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
-    if ("dev".equals(evn)) {
-            SysUsers sysUsers = sysUsersDao.selectById(1022L);
-            request.getSession().setAttribute(MatrixConstance.LOGIN_KEY, sysUsers);
-            return true;
-        }
+//    if ("dev".equals(evn)) {
+//            SysUsers sysUsers = sysUsersDao.selectById(1022L);
+//            request.getSession().setAttribute(MatrixConstance.LOGIN_KEY, sysUsers);
+//            return true;
+//        }
 
         String token = resolveToken(request,privateKey);
         AjaxResult ajaxResult = new AjaxResult();
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java
index da3972f..eace5b4 100644
--- a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java
+++ b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java
@@ -1188,7 +1188,7 @@
             List<ShoppingGoodsAssemble> assembleList = shoppingGoodsAssembleDao.selectGoodsByShoppingGoodsIdAndType(sysOrderItem.getGoodsId(), ShoppingGoods.SHOPPING_GOODS_TYPE_XM);
             assembleList.forEach(item -> {
                 //TODO 补综合卡逻辑
-                createProjuseByAssemble(order, sysOrderItem, item, null, null,null);
+                createProjuseByAssemble(order, sysOrderItem, item, null, null,null,0);
             });
 
             //处理综合卡中包含的套餐
@@ -1209,7 +1209,7 @@
      * 通过组合关系创建用户项目余次
      */
     private SysProjUse createProjuseByAssemble(SysOrder order, SysOrderItem sysOrderItem,
-                                               ShoppingGoodsAssemble goodsAssemble, Long taocanId, Date failTime,String source) {
+                                               ShoppingGoodsAssemble goodsAssemble, Long taocanId, Date failTime,String source,int maxCount) {
         //计算折扣
         Double zk = sysOrderItem.getZkPrice() / sysOrderItem.getPrice();
 
@@ -1217,7 +1217,7 @@
         puse.setIsOver(Dictionary.DELETED_N);
         puse.setOrderItemId(sysOrderItem.getId());
         puse.setProjId(goodsAssemble.getAssembleGoodId());
-        puse.setSurplusCount(goodsAssemble.getTotal());
+        puse.setSurplusCount(goodsAssemble.getTotal()==null?maxCount: goodsAssemble.getTotal());
         puse.setDeductionNum(goodsAssemble.getDeductionNum());
         puse.setProjName(goodsAssemble.getShoppingGoods().getName());
         puse.setVipId(order.getVipId());
@@ -1297,19 +1297,21 @@
         //创建套餐绑定的项目
         List<ShoppingGoodsAssemble> assembleList = shoppingGoodsAssembleDao.selectGoodsByShoppingGoodsIdAndType(projId, ShoppingGoods.SHOPPING_GOODS_TYPE_XM);
         for (ShoppingGoodsAssemble assemble : assembleList) {
-            SysProjUse tempUse = createProjuseByAssemble(order, sysOrderItem, assemble, taocanProjUse.getId(),taocanProjUse.getFailTime(),taocanProjUse.getSource());
+            SysProjUse tempUse = createProjuseByAssemble(order, sysOrderItem, assemble, taocanProjUse.getId(),taocanProjUse.getFailTime(),taocanProjUse.getSource(),taocanShoppingGoods.getCarUseCount());
             sumBanance += tempUse.getBalance();
             surplusCount += tempUse.getSurplusCount();
         }
         if (Dictionary.FLAG_NO_N.equals(taocanShoppingGoods.getIsCourse())) {
             //固定套餐,剩余次数等于绑定项目的次数
             taocanProjUse.setSurplusCount(surplusCount);
+            //合计套餐余额
+            taocanProjUse.setBalance(sumBanance);
         } else {
             //任选套餐剩余次数等于最大使用次数
             taocanProjUse.setSurplusCount(taocanShoppingGoods.getCarUseCount());
+            taocanProjUse.setBalance(sysOrderItem.getZkPrice());
         }
-        //合计套餐余额
-        taocanProjUse.setBalance(sumBanance);
+
         sysProjUseDao.update(taocanProjUse);
     }
 

--
Gitblit v1.9.1