Pārlūkot izejas kodu

商家端定时任务修改

liangpeile 1 gadu atpakaļ
vecāks
revīzija
6e14d3df83

+ 5 - 5
crmeb-admin/src/main/java/com/zbkj/admin/task/sms/DynamicScheduledTask.java

@@ -83,7 +83,7 @@ public class DynamicScheduledTask {
                     } else {
                         //每月最后一天
                         if (list.get(i).getIsLastDay() == 1) {
-                            cronExpression = "0 " + minute + "" + hour + "" + "L" + "" + "*" + " ? " + year;
+                            cronExpression = "0 " + minute + "" + hour + "" + "28-31" + "" + "*" + " ? " + year;
                         } else {
                             cronExpression = "0 " + minute + "" + hour + "" + "*" + "" + month + " ? " + year;
                         }
@@ -121,19 +121,19 @@ public class DynamicScheduledTask {
                 String minute = sendTime.substring(14, 16);
                 //单次发送
                 if (list.get(i).getSendType() == 1) {
-                    cronExpression = "0 " + minute + " " + hour + " " + day + " " + month + " ? ";
+                    cronExpression = "0 " + minute + " " + hour + " " + day + " " + month + " ? *";
                     //循环发送
                 } else {
                     //每天
                     if (list.get(i).getIsCirculate() == 1) {
-                        cronExpression = "0 " + minute + " " + hour + " " + "*" + " " + "*" + " ? ";
+                        cronExpression = "0 " + minute + " " + hour + " " + "*" + " " + "*" + " ? *";
                         //每月
                     } else {
                         //每月最后一天
                         if (list.get(i).getIsLastDay() == 1) {
-                            cronExpression = "0 " + "0" + " " + "0" + " " + "28-31" + " " + "*" + " ? ";
+                            cronExpression = "0 " + "0" + " " + "0" + " " + "28-31" + " " + "*" + " ? *";
                         } else {
-                            cronExpression = "0 " + minute + " " + hour + " " + "*" + " " + month + " ? ";
+                            cronExpression = "0 " + minute + " " + hour + " " + "*" + " " + month + " ? *";
                         }
                     }
                 }

+ 12 - 12
crmeb-front/src/main/java/com/zbkj/front/service/impl/AAAServiceImpl.java

@@ -63,17 +63,17 @@ public class AAAServiceImpl implements AAAService {
 //        String fileNmaes = "C:\\Users\\ASUS\\Desktop\\mer_java\\crmebimage\\public\\miniprogrampic\\"+fileNmae;
         String fileNmaes = "/usr/java/AimagePath" + fileNmae;
         //将分享的购物车数据存入新表,以便后期查看数据保证分享数据不发生变化
-        String cartIdString = scene.substring(0, scene.indexOf("&"));
-        String substring = cartIdString.substring(cartIdString.indexOf("=")+1);
-        String[] cartIds = substring.split(",");
-        List<Cart> cartList = cartService.getListByid(cartIds);
-        ArrayList<CartShare> cartShares = new ArrayList<>();
-        for (Cart cart:cartList){
-            CartShare cartShare = new CartShare();
-            BeanUtils.copyProperties(cart,cartShare);
-            cartShares.add(cartShare);
-        }
-        cartShareService.saveBatch(cartShares);
+//        String cartIdString = scene.substring(0, scene.indexOf("&"));
+//        String substring = cartIdString.substring(cartIdString.indexOf("=")+1);
+//        String[] cartIds = substring.split(",");
+//        List<Cart> cartList = cartService.getListByid(cartIds);
+//        ArrayList<CartShare> cartShares = new ArrayList<>();
+//        for (Cart cart:cartList){
+//            CartShare cartShare = new CartShare();
+//            BeanUtils.copyProperties(cart,cartShare);
+//            cartShares.add(cartShare);
+//        }
+//        cartShareService.saveBatch(cartShares);
 
 
         File outputFile = new File(fileNmaes);
@@ -90,7 +90,7 @@ public class AAAServiceImpl implements AAAService {
 //                return null;
 //            }
             updateAccessToken();
-            redisUtil.set("wxaccessToken", accessToken, 6000L);
+            redisUtil.set("wxaccessToken", accessToken, 0L);
         }
         String accessToken2 = redisUtil.get("wxaccessToken");
         try {

+ 58 - 5
crmeb-service/src/main/java/com/zbkj/service/service/impl/CartServiceImpl.java

@@ -42,7 +42,6 @@ import java.util.stream.Collectors;
 
 /**
  * StoreCartServiceImpl 接口实现
-
  */
 @Service
 public class CartServiceImpl extends ServiceImpl<CartDao, Cart> implements CartService {
@@ -66,6 +65,8 @@ public class CartServiceImpl extends ServiceImpl<CartDao, Cart> implements CartS
     private TransactionTemplate transactionTemplate;
     @Autowired
     private ProductRelationService productRelationService;
+    @Autowired
+    private CartShareService cartShareService;
 
     /**
      * 列表
@@ -185,6 +186,7 @@ public class CartServiceImpl extends ServiceImpl<CartDao, Cart> implements CartS
         });
         return responseList;
     }
+
     /**
      * 购物车数量
      *
@@ -231,22 +233,38 @@ public class CartServiceImpl extends ServiceImpl<CartDao, Cart> implements CartS
         // 是否已经有同类型商品在购物车,有则添加数量没有则新增
         User user = userService.getInfo();
         Cart forUpdateStoreCart = getByUniqueAndUid(request.getProductAttrUnique(), user.getId());
+        CartShare forUpdateStoreCartShare = getCartShareByUniqueAndUid(request.getProductAttrUnique(), user.getId());
         Boolean execute = transactionTemplate.execute(e -> {
-            if (ObjectUtil.isNotNull(forUpdateStoreCart)) { // 购物车添加数量
+            if (ObjectUtil.isNotNull(forUpdateStoreCart) && ObjectUtil.isNotNull(forUpdateStoreCartShare)) { // 购物车添加数量
                 forUpdateStoreCart.setCartNum(forUpdateStoreCart.getCartNum() + request.getCartNum());
                 boolean updateResult = updateById(forUpdateStoreCart);
                 if (!updateResult) throw new CrmebException("添加购物车失败");
+
+                forUpdateStoreCartShare.setCartNum(forUpdateStoreCartShare.getCartNum() + request.getCartNum());
+                boolean updateResult1 = cartShareService.updateById(forUpdateStoreCartShare);
+                if (!updateResult1) throw new CrmebException("添加购物车失败");
+
+
             } else {// 新增购物车数据
                 Cart storeCart = new Cart();
                 BeanUtils.copyProperties(request, storeCart);
                 storeCart.setUid(user.getId());
                 storeCart.setMerId(product.getMerId());
                 if (dao.insert(storeCart) <= 0) throw new CrmebException("添加购物车失败");
+
+                CartShare storeCartShare = new CartShare();
+                BeanUtils.copyProperties(storeCart, storeCartShare);
+                storeCartShare.setCartNum(storeCart.getCartNum());
+                if (cartShareDao.insert(storeCartShare) <= 0) throw new CrmebException("添加购物车分享失败");
             }
+
             return Boolean.TRUE;
         });
+
+
         if (execute) {
             purchaseStatistics(request.getProductId(), request.getCartNum());
+
         }
         return execute;
     }
@@ -264,6 +282,9 @@ public class CartServiceImpl extends ServiceImpl<CartDao, Cart> implements CartS
         }
         List<Cart> updateCartList = new ArrayList<>();
         List<Cart> addCartList = new ArrayList<>();
+        //购物车分享
+        List<CartShare> updateCartShareList = new ArrayList<>();
+        List<CartShare> addCartShareList = new ArrayList<>();
         User currentUser = userService.getInfo();
         cartListRequest.forEach(cartRequest -> {
             // 判断商品正常
@@ -282,21 +303,36 @@ public class CartServiceImpl extends ServiceImpl<CartDao, Cart> implements CartS
             // 普通商品部分(只有普通商品才能添加购物车)
             // 是否已经有同类型商品在购物车,有则添加数量没有则新增
             Cart forUpdateStoreCart = getByUniqueAndUid(cartRequest.getProductAttrUnique(), currentUser.getId());
-            if (ObjectUtil.isNotNull(forUpdateStoreCart)) { // 购物车添加数量
+            CartShare forUpdateStoreCartShare = getCartShareByUniqueAndUid(cartRequest.getProductAttrUnique(), currentUser.getId());
+
+            if (ObjectUtil.isNotNull(forUpdateStoreCart)&&ObjectUtil.isNotNull(forUpdateStoreCartShare)) { // 购物车添加数量
                 forUpdateStoreCart.setCartNum(forUpdateStoreCart.getCartNum() + cartRequest.getCartNum());
                 updateCartList.add(forUpdateStoreCart);
+
+                forUpdateStoreCartShare.setCartNum(forUpdateStoreCart.getCartNum() + cartRequest.getCartNum());
+                updateCartShareList.add(forUpdateStoreCartShare);
             } else {// 新增购物车数据
                 Cart cart = new Cart();
                 BeanUtils.copyProperties(cartRequest, cart);
                 cart.setUid(currentUser.getId());
                 cart.setMerId(product.getMerId());
                 addCartList.add(cart);
+
+                CartShare cartShare = new CartShare();
+                BeanUtils.copyProperties(cart, cartShare);
+                cartShare.setUid(currentUser.getId());
+                cartShare.setMerId(product.getMerId());
+                cartShare.setCartNum(cart.getCartNum());
+                addCartShareList.add(cartShare);
+
             }
         });
-
         Boolean execute = transactionTemplate.execute(exec -> {
             saveBatch(addCartList);
             updateBatchById(updateCartList);
+            //分享表数据
+            cartShareService.saveBatch(addCartShareList);
+            cartShareService.updateBatchById(updateCartShareList);
             return Boolean.TRUE;
         });
         if (execute) {
@@ -309,7 +345,7 @@ public class CartServiceImpl extends ServiceImpl<CartDao, Cart> implements CartS
      * 加购商品统计
      *
      * @param productId 商品id
-     * @param num 加购数量
+     * @param num       加购数量
      */
     private void purchaseStatistics(Integer productId, Integer num) {
         String todayStr = DateUtil.date().toString(DateConstants.DATE_FORMAT_DATE);
@@ -335,6 +371,21 @@ public class CartServiceImpl extends ServiceImpl<CartDao, Cart> implements CartS
     }
 
     /**
+     * 获取购物车分享表信息
+     *
+     * @param productAttrUnique 商品规制值
+     * @param uid               uid
+     * @return StoreCart
+     */
+    private CartShare getCartShareByUniqueAndUid(Integer productAttrUnique, Integer uid) {
+        LambdaQueryWrapper<CartShare> lqw = Wrappers.lambdaQuery();
+        lqw.eq(CartShare::getProductAttrUnique, productAttrUnique);
+        lqw.eq(CartShare::getUid, uid);
+        lqw.last(" limit 1");
+        return cartShareDao.selectOne(lqw);
+    }
+
+    /**
      * 删除购物车信息
      *
      * @param ids 待删除id
@@ -465,6 +516,7 @@ public class CartServiceImpl extends ServiceImpl<CartDao, Cart> implements CartS
 
     /**
      * 购物车移入收藏
+     *
      * @param ids 购物车id列表
      * @return Boolean
      */
@@ -489,6 +541,7 @@ public class CartServiceImpl extends ServiceImpl<CartDao, Cart> implements CartS
 
     /**
      * 通过用户id删除
+     *
      * @param uid 用户ID
      */
     @Override

+ 3 - 0
crmeb-service/src/main/java/com/zbkj/service/service/impl/OnePassSmsServiceImpl.java

@@ -197,6 +197,9 @@ public class OnePassSmsServiceImpl implements OnePassSmsService, SmsService {
     }
     @Override
     public Boolean sendSSM2(String phone, Integer tempId,Integer merId,Integer isLastDay) {
+        if (null==isLastDay){
+            isLastDay=2;
+        }
 
         if (1==isLastDay){
             final Calendar c = Calendar.getInstance();