Переглянути джерело

商家端代金券好友证券代码提交

wuchen 2 місяців тому
батько
коміт
5b3e24f9b8

+ 40 - 6
alien-entity/src/main/java/shop/alien/mapper/LifeDiscountCouponStoreFriendMapper.java

@@ -35,11 +35,14 @@ public interface LifeDiscountCouponStoreFriendMapper extends BaseMapper<LifeDisc
             "${ew.customSqlSegment}")
     IPage<LifeDiscountCouponVo> selectPage(IPage<LifeDiscountCouponStoreFriendVo> iPage, @Param(Constants.WRAPPER) QueryWrapper<LifeDiscountCouponStoreFriendVo> friendLifeDiscountCouponQueryWrapper);
 
+    /** 好友赠我 - 优惠券 */
     @Select("select ldcsf.created_time endDate,ldc.nominal_value nominalValue,ldc.minimum_spending_amount minimumSpendingAmount,img.img_url imgUrl,\n" +
             "si.store_name storeName,\n" +
             "ldc.name couponName,\n" +
             "ldc.id couponId,\n" +
-            "ldcsf.single_qty couponNum\n" +
+            "ldcsf.single_qty couponNum,\n" +
+            "1 as type,\n" +
+            "null as voucherId\n" +
             "from  life_discount_coupon_store_friend ldcsf\n" +
             "left join life_discount_coupon ldc\n" +
             "on ldc.id = ldcsf.coupon_id and ldc.delete_flag = 0\n" +
@@ -50,22 +53,53 @@ public interface LifeDiscountCouponStoreFriendMapper extends BaseMapper<LifeDisc
             "${ew.customSqlSegment}")
     List<LifeDiscountCouponFriendRuleVo> getReceivedSendFriendCouponList(@Param(Constants.WRAPPER) QueryWrapper<LifeDiscountCouponFriendRuleVo> lifeDiscountCouponFriendRuleVoQueryWrapper);
 
-    //我赠好友
+    /** 好友赠我 - 代金券(type=4) */
+    @Select("select ldcsf.created_time endDate,CAST(lc.price AS DECIMAL(10,2)) nominalValue,null minimumSpendingAmount,img.img_url imgUrl,\n" +
+            "si.store_name storeName,\n" +
+            "lc.name couponName,\n" +
+            "null couponId,\n" +
+            "ldcsf.single_qty couponNum,\n" +
+            "4 as type,\n" +
+            "lc.id voucherId\n" +
+            "from life_discount_coupon_store_friend ldcsf\n" +
+            "left join life_coupon lc on lc.id = ldcsf.voucher_id and lc.delete_flag = 0\n" +
+            "left join store_info si on si.id = lc.store_id and si.delete_flag = 0\n" +
+            "left join store_user su on si.id = su.store_id\n" +
+            "left join store_img img on si.id = img.store_id and img.img_type = 1 and img.delete_flag = 0\n" +
+            "${ew.customSqlSegment}")
+    List<LifeDiscountCouponFriendRuleVo> getReceivedSendFriendCouponListVoucher(@Param(Constants.WRAPPER) QueryWrapper<LifeDiscountCouponFriendRuleVo> lifeDiscountCouponFriendRuleVoQueryWrapper);
+
+    /** 我赠好友 - 优惠券 */
     @Select("select ldcsf.created_time endDate,ldc.nominal_value nominalValue,ldc.minimum_spending_amount minimumSpendingAmount,img.img_url imgUrl,\n" +
             "si.store_name storeName,\n" +
             "ldc.name couponName,\n" +
             "ldc.id couponId,\n" +
-            "ldcsf.single_qty couponNum\n" +
+            "ldcsf.single_qty couponNum,\n" +
+            "1 as type,\n" +
+            "null as voucherId\n" +
             "from  life_discount_coupon_store_friend ldcsf\n" +
             "left join life_discount_coupon ldc\n" +
             "on ldc.id = ldcsf.coupon_id and ldc.delete_flag = 0\n" +
-
             "left join store_info si\n" +
             "on si.id = ldcsf.store_user_id and si.delete_flag = 0\n" +
-
             "left join store_user su on ldcsf.store_user_id = su.store_id\n" +
-
             "left join store_img img on si.id = img.store_id and img.img_type = 1 and img.delete_flag = 0\n" +
             "${ew.customSqlSegment}")
     List<LifeDiscountCouponFriendRuleVo> getReceivedSendFriendCouponListwzhy(@Param(Constants.WRAPPER) QueryWrapper<LifeDiscountCouponFriendRuleVo> lifeDiscountCouponFriendRuleVoQueryWrapper);
+
+    /** 我赠好友 - 代金券(type=4) */
+    @Select("select ldcsf.created_time endDate,CAST(lc.price AS DECIMAL(10,2)) nominalValue,null minimumSpendingAmount,img.img_url imgUrl,\n" +
+            "si.store_name storeName,\n" +
+            "lc.name couponName,\n" +
+            "null couponId,\n" +
+            "ldcsf.single_qty couponNum,\n" +
+            "4 as type,\n" +
+            "lc.id voucherId\n" +
+            "from life_discount_coupon_store_friend ldcsf\n" +
+            "left join life_coupon lc on lc.id = ldcsf.voucher_id and lc.delete_flag = 0\n" +
+            "left join store_info si on si.id = lc.store_id and si.delete_flag = 0\n" +
+            "left join store_user su on ldcsf.store_user_id = su.store_id\n" +
+            "left join store_img img on si.id = img.store_id and img.img_type = 1 and img.delete_flag = 0\n" +
+            "${ew.customSqlSegment}")
+    List<LifeDiscountCouponFriendRuleVo> getReceivedSendFriendCouponListwzhyVoucher(@Param(Constants.WRAPPER) QueryWrapper<LifeDiscountCouponFriendRuleVo> lifeDiscountCouponFriendRuleVoQueryWrapper);
 }

+ 12 - 6
alien-store/src/main/java/shop/alien/store/controller/LifeDiscountCouponStoreFriendController.java

@@ -181,14 +181,20 @@ public class LifeDiscountCouponStoreFriendController {
         return R.data(lifeDiscountCouponStoreFriendService.getRuleList(storeId, acName, status));
     }
 
-    @ApiOperation("查询赠券记录")
-    @ApiImplicitParams({@ApiImplicitParam(name = "storeUserId", value = "好友赠我-当前登录店铺id", dataType = "String", paramType = "query", required = false)
-            ,@ApiImplicitParam(name = "friendStoreUserId", value = "我赠好友-选中好友店铺用户id", dataType = "String", paramType = "query", required = false)
+    @ApiOperation("查询赠券记录。type=4 仅代金券,不传返回全部(优惠券+代金券)")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "storeUserId", value = "好友赠我-当前登录店铺id", dataType = "String", paramType = "query", required = false),
+            @ApiImplicitParam(name = "friendStoreUserId", value = "我赠好友-选中好友店铺用户id", dataType = "String", paramType = "query", required = false),
+            @ApiImplicitParam(name = "storeName", value = "店铺名称模糊", dataType = "String", paramType = "query", required = false),
+            @ApiImplicitParam(name = "type", value = "4=仅代金券,不传=全部", dataType = "Integer", paramType = "query", required = false)
     })
     @GetMapping("/getReceivedSendFriendCouponList")
-    public R<List<LifeDiscountCouponFriendRuleVo>> getReceivedSendFriendCouponList(@RequestParam(value = "storeUserId",required = false) String storeUserId, @RequestParam(value = "friendStoreUserId",required = false)String friendStoreUserId, @RequestParam(value = "storeName",required = false)String storeName) {
-        log.info("LifeDiscountCouponStoreFriendController.getReceivedSendFriendCouponList?storeId={},friendStoreUserId={},storeName={}", storeUserId,friendStoreUserId,storeName);
-        return R.data(lifeDiscountCouponStoreFriendService.getReceivedSendFriendCouponList(storeUserId,friendStoreUserId,storeName));
+    public R<List<LifeDiscountCouponFriendRuleVo>> getReceivedSendFriendCouponList(@RequestParam(value = "storeUserId", required = false) String storeUserId,
+                                                                                   @RequestParam(value = "friendStoreUserId", required = false) String friendStoreUserId,
+                                                                                   @RequestParam(value = "storeName", required = false) String storeName,
+                                                                                   @RequestParam(value = "type", required = false) Integer type) {
+        log.info("LifeDiscountCouponStoreFriendController.getReceivedSendFriendCouponList?storeUserId={},friendStoreUserId={},storeName={},type={}", storeUserId, friendStoreUserId, storeName, type);
+        return R.data(lifeDiscountCouponStoreFriendService.getReceivedSendFriendCouponList(storeUserId, friendStoreUserId, storeName, type));
 
 
 

+ 2 - 1
alien-store/src/main/java/shop/alien/store/service/LifeDiscountCouponStoreFriendService.java

@@ -62,7 +62,8 @@ public interface LifeDiscountCouponStoreFriendService extends IService<LifeDisco
 
     LifeDiscountCouponFriendRuleVo getRuleById(String id);
 
-    List<LifeDiscountCouponFriendRuleVo> getReceivedSendFriendCouponList(String storeUserId, String friendStoreUserId,String storeName);
+    /** type=4 仅代金券,不传则返回全部(优惠券+代金券) */
+    List<LifeDiscountCouponFriendRuleVo> getReceivedSendFriendCouponList(String storeUserId, String friendStoreUserId, String storeName, Integer type);
 
     /**
      * 好评送券:用户对店铺好评且通过AI审核通过后,将店铺可用券发放到用户卡包

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

@@ -596,20 +596,53 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
     }
 
     @Override
-    public List<LifeDiscountCouponFriendRuleVo> getReceivedSendFriendCouponList(String storeUserId, String friendStoreUserId,String storeName) {
-        QueryWrapper<LifeDiscountCouponFriendRuleVo> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq(StringUtils.isNotEmpty(storeUserId),"ldcsf.store_user_id", storeUserId)
-                .eq(StringUtils.isNotEmpty(friendStoreUserId),"ldcsf.friend_store_user_id", friendStoreUserId)
-                .like(StringUtils.isNotEmpty(storeName),"si.store_name", storeName);
+    public List<LifeDiscountCouponFriendRuleVo> getReceivedSendFriendCouponList(String storeUserId, String friendStoreUserId, String storeName, Integer type) {
+        boolean voucherOnly = Integer.valueOf(4).equals(type);
         if (StringUtils.isNotEmpty(storeUserId)) {
-            return lifeDiscountCouponStoreFriendMapper.getReceivedSendFriendCouponList(queryWrapper);
+            // 好友赠我
+            if (voucherOnly) {
+                QueryWrapper<LifeDiscountCouponFriendRuleVo> q = new QueryWrapper<>();
+                q.eq("ldcsf.store_user_id", storeUserId).eq("ldcsf.delete_flag", 0).isNotNull("ldcsf.voucher_id");
+                if (StringUtils.isNotEmpty(storeName)) q.like("si.store_name", storeName);
+                return lifeDiscountCouponStoreFriendMapper.getReceivedSendFriendCouponListVoucher(q);
+            }
+            QueryWrapper<LifeDiscountCouponFriendRuleVo> qCoupon = new QueryWrapper<>();
+            qCoupon.eq("ldcsf.store_user_id", storeUserId).eq("ldcsf.delete_flag", 0).isNotNull("ldcsf.coupon_id");
+            if (StringUtils.isNotEmpty(storeName)) qCoupon.like("si.store_name", storeName);
+            List<LifeDiscountCouponFriendRuleVo> list = lifeDiscountCouponStoreFriendMapper.getReceivedSendFriendCouponList(qCoupon);
+            if (type != null) return list;
+            QueryWrapper<LifeDiscountCouponFriendRuleVo> qVoucher = new QueryWrapper<>();
+            qVoucher.eq("ldcsf.store_user_id", storeUserId).eq("ldcsf.delete_flag", 0).isNotNull("ldcsf.voucher_id");
+            if (StringUtils.isNotEmpty(storeName)) qVoucher.like("si.store_name", storeName);
+            List<LifeDiscountCouponFriendRuleVo> voucherList = lifeDiscountCouponStoreFriendMapper.getReceivedSendFriendCouponListVoucher(qVoucher);
+            list = new ArrayList<>(list);
+            list.addAll(voucherList);
+            list.sort((a, b) -> (b.getEndDate() != null && a.getEndDate() != null) ? b.getEndDate().compareTo(a.getEndDate()) : 0);
+            return list;
         }
         if (StringUtils.isNotEmpty(friendStoreUserId)) {
-            return lifeDiscountCouponStoreFriendMapper.getReceivedSendFriendCouponListwzhy(queryWrapper);
-        }
-        else {
-            return new ArrayList<>();
-        }
+            // 我赠好友
+            if (voucherOnly) {
+                QueryWrapper<LifeDiscountCouponFriendRuleVo> q = new QueryWrapper<>();
+                q.eq("ldcsf.friend_store_user_id", friendStoreUserId).eq("ldcsf.delete_flag", 0).isNotNull("ldcsf.voucher_id");
+                if (StringUtils.isNotEmpty(storeName)) q.like("si.store_name", storeName);
+                return lifeDiscountCouponStoreFriendMapper.getReceivedSendFriendCouponListwzhyVoucher(q);
+            }
+            QueryWrapper<LifeDiscountCouponFriendRuleVo> qCoupon = new QueryWrapper<>();
+            qCoupon.eq("ldcsf.friend_store_user_id", friendStoreUserId).eq("ldcsf.delete_flag", 0).isNotNull("ldcsf.coupon_id");
+            if (StringUtils.isNotEmpty(storeName)) qCoupon.like("si.store_name", storeName);
+            List<LifeDiscountCouponFriendRuleVo> list = lifeDiscountCouponStoreFriendMapper.getReceivedSendFriendCouponListwzhy(qCoupon);
+            if (type != null) return list;
+            QueryWrapper<LifeDiscountCouponFriendRuleVo> qVoucher = new QueryWrapper<>();
+            qVoucher.eq("ldcsf.friend_store_user_id", friendStoreUserId).eq("ldcsf.delete_flag", 0).isNotNull("ldcsf.voucher_id");
+            if (StringUtils.isNotEmpty(storeName)) qVoucher.like("si.store_name", storeName);
+            List<LifeDiscountCouponFriendRuleVo> voucherList = lifeDiscountCouponStoreFriendMapper.getReceivedSendFriendCouponListwzhyVoucher(qVoucher);
+            list = new ArrayList<>(list);
+            list.addAll(voucherList);
+            list.sort((a, b) -> (b.getEndDate() != null && a.getEndDate() != null) ? b.getEndDate().compareTo(a.getEndDate()) : 0);
+            return list;
+        }
+        return new ArrayList<>();
     }
 
     /**