浏览代码

0.1元一个G的流量,限购,登录

xw 1 周之前
父节点
当前提交
b9119f06b9

+ 3 - 3
fs-service/src/main/java/com/fs/course/vo/FsCourseTrafficLogListVO.java

@@ -29,7 +29,7 @@ public class FsCourseTrafficLogListVO implements Serializable
 
     @Excel(name = "总流量 (GB)")
     private String formattedTotalTraffic;
-    
+
     @Excel(name = "耗费金额(元)")
     private String formattedAmount;
 
@@ -44,8 +44,8 @@ public class FsCourseTrafficLogListVO implements Serializable
         } else {
             double gb = this.totalInternetTraffic.doubleValue() / (1024 * 1024 * 1024);
             this.formattedTotalTraffic = String.format("%.4f GB", gb);
-            // 0.08元一个G的流量
-            double amount = gb * 0.08;
+            // 0.1元一个G的流量
+            double amount = gb * 0.1;
             this.formattedAmount = String.format("%.2f", amount);
         }
     }

+ 10 - 1
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreOrderScrmMapper.java

@@ -520,7 +520,7 @@ public interface FsStoreOrderScrmMapper
     List<FsStoreOrderTuiVO> selectFsStoreOrderTuiListVO(String userId);
     @Select({"<script> " +
             "select ifnull(count(1),0) from fs_store_order_scrm o  " +
-            "where o.user_id=#{uid} and o.package_id=#{packageId} and o.status &gt; 0 and o.paid = 1 " +
+            "where o.user_id=#{uid} and o.package_id=#{packageId} and o.status &lt;&gt; -3 " +
             "</script>"})
     int checkPackageOrderCount(@Param("uid") long uid, @Param("packageId")String packageId);
     @Select({"<script> " +
@@ -1276,6 +1276,15 @@ public interface FsStoreOrderScrmMapper
     Integer selectUserPurchasedCount(@Param("userId") Long userId,
                                      @Param("productAttrValueId") Long productAttrValueId);
 
+    /**
+     * 根据商品ID查询用户已购买数量(不区分规格)
+     * @param userId 用户ID
+     * @param productId 商品ID
+     * @return 已购买数量
+     */
+    Integer selectUserPurchasedCountByProductId(@Param("userId") Long userId,
+                                                @Param("productId") Long productId);
+
     List<FsStoreOrderVO> selectFsStoreOrderListVOByErpAccount(@Param("maps")FsStoreOrderParam param);
 
     int batchUpdateErpByOrderIds(@Param("maps")ArrayList<Map<String, String>> maps);

+ 1 - 1
fs-service/src/main/java/com/fs/hisStore/mapper/FsUserScrmMapper.java

@@ -124,7 +124,7 @@ public interface FsUserScrmMapper
     @Update("update fs_user set pay_count=pay_count+1" +
             " where user_id=#{userId}")
     int incPayCount(Long userId);
-    @Select("select * from fs_user where phone=#{phone}")
+    @Select("select * from fs_user where phone=#{phone} order by user_id desc limit 1")
     FsUserScrm selectFsUserByPhone(String phone);
 
     /**

+ 26 - 1
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java

@@ -863,7 +863,13 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
         if (userId == null || productAttrValueId == null) {
             return 0;
         }
-        return fsStoreOrderMapper.selectUserPurchasedCount(userId, productAttrValueId);
+        // 获取商品ID(通过规格ID查询)
+        FsStoreProductAttrValueScrm attrValue = attrValueService.selectFsStoreProductAttrValueById(productAttrValueId);
+        if (attrValue == null || attrValue.getProductId() == null) {
+            return 0;
+        }
+        // 按商品ID统计购买数量,不区分规格
+        return fsStoreOrderMapper.selectUserPurchasedCountByProductId(userId, attrValue.getProductId());
     }
 
 
@@ -4368,6 +4374,25 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
             return R.error("正在支付中...");
         }
 
+        // 支付前检查限购
+        List<FsStoreOrderItemVO> orderItems = fsStoreOrderItemMapper.selectFsStoreOrderItemListByOrderId(order.getId());
+        for (FsStoreOrderItemVO item : orderItems) {
+            FsStoreProductAttrValueScrm attrValue = attrValueService.selectFsStoreProductAttrValueById(item.getProductAttrValueId());
+            if (attrValue != null && attrValue.getPurchaseLimit() != null && attrValue.getPurchaseLimit() > 0) {
+                // 查询用户已购买该商品的数量(按商品ID统计)
+                Integer purchasedCount = this.selectUserPurchasedCount(order.getUserId(), item.getProductAttrValueId());
+                if (purchasedCount == null) {
+                    purchasedCount = 0;
+                }
+                // 计算总购买数量(已购买 + 本次订单数量)
+                long totalPurchased = purchasedCount + item.getNum();
+                // 检查是否超过限购数量
+                if (totalPurchased > attrValue.getPurchaseLimit()) {
+                    return R.error("商品限购" + attrValue.getPurchaseLimit() + "件,您已购买" + purchasedCount + "件,无法再次购买");
+                }
+            }
+        }
+
         FsUserScrm user=userService.selectFsUserById(order.getUserId());
         if(user!=null){
             //已改价处理

+ 1 - 1
fs-service/src/main/java/com/fs/hisStore/service/impl/FsUserScrmServiceImpl.java

@@ -1149,7 +1149,7 @@ public class FsUserScrmServiceImpl implements IFsUserScrmService
             fsUserWx.setCreateTime(new Date());
             fsUserWx.setUpdateTime(new Date());
             fsUserWxService.saveOrUpdateByUniqueKey(fsUserWx);
-            log.info("zyp \n 【更新或插入用户与小程序{}的绑定关系】:{}", param.getAppId(), user.getUserId());
+            log.info("夏伟到此一游 \n 【更新或插入用户与小程序{}的绑定关系】:{}", param.getAppId(), user.getUserId());
         } catch (Exception e) {
             throw new RuntimeException(e);
         }

+ 13 - 0
fs-service/src/main/resources/mapper/hisStore/FsStoreOrderScrmMapper.xml

@@ -2062,6 +2062,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
           AND o.paid = 1
           AND o.is_del = 0
     </select>
+    
+    <!-- 根据商品ID查询用户已购买数量(不区分规格) -->
+    <select id="selectUserPurchasedCountByProductId" resultType="java.lang.Integer">
+        SELECT IFNULL(SUM(oi.num), 0)
+        FROM fs_store_order_item_scrm oi
+        INNER JOIN fs_store_order_scrm o ON oi.order_id = o.id
+        WHERE o.user_id = #{userId}
+          AND oi.product_id = #{productId}
+          AND o.status > 0
+          AND o.paid = 1
+          AND o.is_del = 0
+    </select>
+    
     <select id="selectFsStoreOrderAmountScrmStats" resultType="com.fs.his.vo.FsStoreOrderAmountScrmStatsVo">
         SELECT
         COUNT(*) AS totalOrderCount,