Przeglądaj źródła

Merge branch 'release_lutong_bug' into sit

lutong 1 miesiąc temu
rodzic
commit
08220dbade

+ 7 - 0
alien-entity/src/main/java/shop/alien/entity/store/LifeDiscountCouponFriendRule.java

@@ -59,6 +59,13 @@ public class LifeDiscountCouponFriendRule {
     @TableLogic
     private Integer deleteFlag;
 
+    /**
+     * 优惠券类型:1-满减券,2-折扣券(仅优惠券有值,代金券为null)
+     */
+    @ApiModelProperty(value = "优惠券类型:1-满减券,2-折扣券(仅优惠券有值,代金券为null)")
+    @TableField("coupon_type")
+    private Integer couponType;
+
     @TableField(exist = false)
     private List<LifeDiscountCouponFriendRuleDetail> details;
 }

+ 3 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/LifeDiscountCouponFriendRuleDetailVo.java

@@ -25,4 +25,7 @@ public class LifeDiscountCouponFriendRuleDetailVo extends LifeDiscountCouponFrie
 
     /** 代金券id(type=4 时返回,对应 life_coupon.id) */
     private String voucherId;
+
+    /** 优惠券类型:1-满减券,2-折扣券(仅优惠券有值,代金券为null) */
+    private Integer couponType;
 }

+ 3 - 3
alien-entity/src/main/java/shop/alien/mapper/LifeDiscountCouponFriendRuleDetailMapper.java

@@ -8,7 +8,6 @@ import shop.alien.entity.store.LifeDiscountCouponFriendRuleDetail;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import shop.alien.entity.store.vo.LifeDiscountCouponFriendRuleDetailVo;
 import shop.alien.entity.store.vo.LifeDiscountCouponFriendRuleVo;
-import shop.alien.entity.store.vo.LifeGroupBuyThaliVo;
 
 import java.util.List;
 
@@ -22,7 +21,7 @@ public interface LifeDiscountCouponFriendRuleDetailMapper extends BaseMapper<Lif
 
     void insertList(List<LifeDiscountCouponFriendRuleDetail> lifeDiscountCouponFriendRuleDetailList);
 
-    @Select("select si.store_name storeName,ldc.name couponName,ldc.id couponId,sum(ldcsf.single_qty) couponNum,ldcsf.friend_store_user_id friendStoreUserId from life_discount_coupon_store_friend ldcsf left join life_discount_coupon ldc on ldcsf.coupon_id = ldc.id left join store_user su on ldcsf.friend_store_user_id = su.id left join store_info si on su.store_id = si.id ${ew.customSqlSegment}")
+    @Select("select si.store_name storeName,ldc.name couponName,ldc.id couponId,ldc.coupon_type couponType,sum(ldcsf.single_qty) couponNum,ldcsf.friend_store_user_id friendStoreUserId from life_discount_coupon_store_friend ldcsf left join life_discount_coupon ldc on ldcsf.coupon_id = ldc.id left join store_user su on ldcsf.friend_store_user_id = su.id left join store_info si on su.store_id = si.id ${ew.customSqlSegment}")
     List<LifeDiscountCouponFriendRuleDetailVo> getReceivedFriendCouponList(@Param(Constants.WRAPPER) QueryWrapper<LifeDiscountCouponFriendRuleDetailVo> queryWrapper);
 
     /** 查询收到的代金券列表(life_coupon,voucher_id 不为空) */
@@ -36,7 +35,7 @@ public interface LifeDiscountCouponFriendRuleDetailMapper extends BaseMapper<Lif
             "COALESCE(c.name, v.name) AS couponName, " +
             "c.id AS couponId, " +
             "d.voucher_id AS voucherId, " +
-            "c.coupon_type AS couponType, " +
+            "COALESCE(a.coupon_type, c.coupon_type) AS couponType, " +
             "c.discount_rate AS discountRate " +
             "FROM life_discount_coupon_friend_rule a " +
             "INNER JOIN life_discount_coupon_friend_rule_detail d ON d.rule_id = a.id " +
@@ -47,6 +46,7 @@ public interface LifeDiscountCouponFriendRuleDetailMapper extends BaseMapper<Lif
     List<LifeDiscountCouponFriendRuleVo> getRuleList(@Param("storeId") String storeId);
 
     @Select("SELECT a.*, c.name as couponName, c.id as couponId, " +
+            "c.coupon_type as couponType, " +
             "si_friend.store_name AS storeName, " +
             "(SELECT sum(single_qty) FROM life_discount_coupon_store_friend b " +
             "WHERE b.friend_store_user_id = a.friend_store_user_id AND b.coupon_id = a.coupon_id AND b.store_user_id = a.store_id) couponNum " +

+ 2 - 1
alien-entity/src/main/resources/mapper/LifeDiscountCouponFriendRuleMapper.xml

@@ -10,9 +10,10 @@
             <result property="moneyLow" column="money_low" />
             <result property="moneyHigh" column="money_high" />
             <result property="deleteFlag" column="delete_flag" />
+            <result property="couponType" column="coupon_type" />
     </resultMap>
 
     <sql id="Base_Column_List">
-        id,ac_name,money_low,money_high,delete_flag
+        id,ac_name,money_low,money_high,delete_flag,coupon_type
     </sql>
 </mapper>

+ 11 - 0
alien-store/src/main/java/shop/alien/store/service/impl/LifeDiscountCouponStoreFriendServiceImpl.java

@@ -633,6 +633,17 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
         if (ObjectUtils.isNotEmpty(lifeDiscountCouponFriendRule)) {
             List<LifeDiscountCouponFriendRuleDetailVo> lifeDiscountCouponFriendRuleDetails = lifeDiscountCouponFriendRuleDetailMapper.getDetailList(lifeDiscountCouponFriendRule.getId().toString());
             ruleVo.setLifeDiscountCouponFriendRuleDetailVos(lifeDiscountCouponFriendRuleDetails);
+            
+            // 如果规则表中没有 couponType,尝试从关联的优惠券中获取
+            if (ruleVo.getCouponType() == null && ObjectUtils.isNotEmpty(lifeDiscountCouponFriendRuleDetails)) {
+                // 查找第一个优惠券(非代金券)的 couponType
+                for (LifeDiscountCouponFriendRuleDetailVo detail : lifeDiscountCouponFriendRuleDetails) {
+                    if (detail.getCouponId() != null && detail.getCouponType() != null) {
+                        ruleVo.setCouponType(detail.getCouponType());
+                        break;
+                    }
+                }
+            }
         }
         return ruleVo;
     }