|
@@ -614,7 +614,7 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
|
|
|
private static final Integer TYPE_VOUCHER = 4;
|
|
private static final Integer TYPE_VOUCHER = 4;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public List<LifeDiscountCouponFriendRuleVo> getReceivedSendFriendCouponList(String storeUserId, Integer queryType, String storeName, Integer type) {
|
|
|
|
|
|
|
+ public List<LifeDiscountCouponFriendRuleVo> getReceivedSendFriendCouponList(String storeUserId, Integer queryType, String storeName, Integer type, Integer couponType) {
|
|
|
// 参数校验
|
|
// 参数校验
|
|
|
if (StringUtils.isEmpty(storeUserId)) {
|
|
if (StringUtils.isEmpty(storeUserId)) {
|
|
|
log.warn("getReceivedSendFriendCouponList 参数错误:storeUserId 不能为空");
|
|
log.warn("getReceivedSendFriendCouponList 参数错误:storeUserId 不能为空");
|
|
@@ -624,6 +624,11 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
|
|
|
log.warn("getReceivedSendFriendCouponList 参数错误:queryType 必须为 1 或 2,当前值={}", queryType);
|
|
log.warn("getReceivedSendFriendCouponList 参数错误:queryType 必须为 1 或 2,当前值={}", queryType);
|
|
|
return new ArrayList<>();
|
|
return new ArrayList<>();
|
|
|
}
|
|
}
|
|
|
|
|
+ // 校验couponType参数(1=满减券,2=折扣券)
|
|
|
|
|
+ if (couponType != null && couponType != 1 && couponType != 2) {
|
|
|
|
|
+ log.warn("getReceivedSendFriendCouponList 参数错误:couponType 必须为 1(满减券)或 2(折扣券),当前值={}", couponType);
|
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// 判断是否仅查询代金券
|
|
// 判断是否仅查询代金券
|
|
|
boolean voucherOnly = TYPE_VOUCHER.equals(type);
|
|
boolean voucherOnly = TYPE_VOUCHER.equals(type);
|
|
@@ -637,7 +642,7 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
|
|
|
// queryType = 2: 我送出的(我送给所有好友的)-> friend_store_user_id = 我的店铺用户ID(我是送券的用户)
|
|
// queryType = 2: 我送出的(我送给所有好友的)-> friend_store_user_id = 我的店铺用户ID(我是送券的用户)
|
|
|
boolean isReceivedByMe = (queryType == 1);
|
|
boolean isReceivedByMe = (queryType == 1);
|
|
|
|
|
|
|
|
- return queryCouponList(isReceivedByMe, storeUserId, storeName, type, voucherOnly);
|
|
|
|
|
|
|
+ return queryCouponList(isReceivedByMe, storeUserId, storeName, type, voucherOnly, couponType);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -648,9 +653,10 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
|
|
|
* @param storeName 店铺名称(模糊查询)
|
|
* @param storeName 店铺名称(模糊查询)
|
|
|
* @param type 类型参数(4=代金券,其他=优惠券,null=全部)
|
|
* @param type 类型参数(4=代金券,其他=优惠券,null=全部)
|
|
|
* @param voucherOnly 是否仅查询代金券
|
|
* @param voucherOnly 是否仅查询代金券
|
|
|
|
|
+ * @param couponType 优惠券类型(1=满减券,2=折扣券,null=全部优惠券)
|
|
|
* @return 赠券列表
|
|
* @return 赠券列表
|
|
|
*/
|
|
*/
|
|
|
- private List<LifeDiscountCouponFriendRuleVo> queryCouponList(boolean isReceivedByMe, String storeUserId, String storeName, Integer type, boolean voucherOnly) {
|
|
|
|
|
|
|
+ private List<LifeDiscountCouponFriendRuleVo> queryCouponList(boolean isReceivedByMe, String storeUserId, String storeName, Integer type, boolean voucherOnly, Integer couponType) {
|
|
|
List<LifeDiscountCouponFriendRuleVo> result;
|
|
List<LifeDiscountCouponFriendRuleVo> result;
|
|
|
|
|
|
|
|
// 仅查询代金券
|
|
// 仅查询代金券
|
|
@@ -664,6 +670,10 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
|
|
|
// 查询优惠券
|
|
// 查询优惠券
|
|
|
QueryWrapper<LifeDiscountCouponFriendRuleVo> couponQuery = buildBaseQueryWrapper(isReceivedByMe, storeUserId, storeName);
|
|
QueryWrapper<LifeDiscountCouponFriendRuleVo> couponQuery = buildBaseQueryWrapper(isReceivedByMe, storeUserId, storeName);
|
|
|
couponQuery.isNotNull("ldcsf.coupon_id");
|
|
couponQuery.isNotNull("ldcsf.coupon_id");
|
|
|
|
|
+ // 如果指定了优惠券类型(满减券或折扣券),添加筛选条件
|
|
|
|
|
+ if (couponType != null) {
|
|
|
|
|
+ couponQuery.eq("ldc.coupon_type", couponType);
|
|
|
|
|
+ }
|
|
|
List<LifeDiscountCouponFriendRuleVo> couponList = isReceivedByMe
|
|
List<LifeDiscountCouponFriendRuleVo> couponList = isReceivedByMe
|
|
|
? lifeDiscountCouponStoreFriendMapper.getReceivedSendFriendCouponList(couponQuery)
|
|
? lifeDiscountCouponStoreFriendMapper.getReceivedSendFriendCouponList(couponQuery)
|
|
|
: lifeDiscountCouponStoreFriendMapper.getReceivedSendFriendCouponListwzhy(couponQuery);
|
|
: lifeDiscountCouponStoreFriendMapper.getReceivedSendFriendCouponListwzhy(couponQuery);
|
|
@@ -896,6 +906,7 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
|
|
|
int grantedVoucher = 0;
|
|
int grantedVoucher = 0;
|
|
|
String couponName = null; // 优惠券名称
|
|
String couponName = null; // 优惠券名称
|
|
|
String voucherName = null; // 代金券名称
|
|
String voucherName = null; // 代金券名称
|
|
|
|
|
+ LifeDiscountCoupon lifeDiscountCoupon = null; // 保存优惠券对象,用于通知消息
|
|
|
|
|
|
|
|
// 按优惠券ID发放:发放1张,扣减库存,发优惠券通知
|
|
// 按优惠券ID发放:发放1张,扣减库存,发优惠券通知
|
|
|
if (couponId != null && couponId > 0) {
|
|
if (couponId != null && couponId > 0) {
|
|
@@ -915,6 +926,7 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
|
|
|
lifeDiscountCouponMapper.updateById(coupon);
|
|
lifeDiscountCouponMapper.updateById(coupon);
|
|
|
grantedCoupon = 1;
|
|
grantedCoupon = 1;
|
|
|
couponName = coupon.getName(); // 保存优惠券名称
|
|
couponName = coupon.getName(); // 保存优惠券名称
|
|
|
|
|
+ lifeDiscountCoupon = coupon; // 保存优惠券对象,用于通知消息
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.error("发放优惠券失败,userId={}, storeId={}, couponId={}, error={}", userId, storeId, couponId, e.getMessage(), e);
|
|
log.error("发放优惠券失败,userId={}, storeId={}, couponId={}, error={}", userId, storeId, couponId, e.getMessage(), e);
|
|
|
}
|
|
}
|
|
@@ -953,12 +965,42 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
|
|
|
LifeNotice couponNotice = new LifeNotice();
|
|
LifeNotice couponNotice = new LifeNotice();
|
|
|
couponNotice.setSenderId("system");
|
|
couponNotice.setSenderId("system");
|
|
|
couponNotice.setReceiverId("user_" + lifeUser.getUserPhone());
|
|
couponNotice.setReceiverId("user_" + lifeUser.getUserPhone());
|
|
|
- // 明确标注是优惠券,并包含券的具体名称
|
|
|
|
|
- String couponText = "您对店铺「" + storeInfo.getStoreName() + "」的好评已通过审核,已为您发放优惠券「" + couponName + "」,快去我的券包查看吧~";
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 构建优惠券详情信息
|
|
|
|
|
+ String couponDetailText = "";
|
|
|
|
|
+ if (lifeDiscountCoupon != null) {
|
|
|
|
|
+ Integer couponType = lifeDiscountCoupon.getCouponType();
|
|
|
|
|
+ if (couponType != null && couponType == 2) {
|
|
|
|
|
+ // 折扣券
|
|
|
|
|
+ BigDecimal discountRate = lifeDiscountCoupon.getDiscountRate();
|
|
|
|
|
+ if (discountRate != null) {
|
|
|
|
|
+ couponDetailText = "(" + discountRate + "折";
|
|
|
|
|
+ if (lifeDiscountCoupon.getMinimumSpendingAmount() != null) {
|
|
|
|
|
+ couponDetailText += ",满" + lifeDiscountCoupon.getMinimumSpendingAmount() + "可用";
|
|
|
|
|
+ }
|
|
|
|
|
+ couponDetailText += ")";
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 满减券(默认)
|
|
|
|
|
+ if (lifeDiscountCoupon.getNominalValue() != null) {
|
|
|
|
|
+ couponDetailText = "(满减" + lifeDiscountCoupon.getNominalValue() + "元";
|
|
|
|
|
+ if (lifeDiscountCoupon.getMinimumSpendingAmount() != null) {
|
|
|
|
|
+ couponDetailText += ",满" + lifeDiscountCoupon.getMinimumSpendingAmount() + "可用";
|
|
|
|
|
+ }
|
|
|
|
|
+ couponDetailText += ")";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 明确标注是优惠券,并包含券的具体名称和详情
|
|
|
|
|
+ String couponText = "您对店铺「" + storeInfo.getStoreName() + "」的好评已通过审核,已为您发放优惠券「" + couponName + "」" + couponDetailText + ",快去我的券包查看吧~";
|
|
|
JSONObject couponJson = new JSONObject();
|
|
JSONObject couponJson = new JSONObject();
|
|
|
couponJson.put("message", couponText);
|
|
couponJson.put("message", couponText);
|
|
|
couponJson.put("couponType", "优惠券"); // 明确标识券类型
|
|
couponJson.put("couponType", "优惠券"); // 明确标识券类型
|
|
|
couponJson.put("couponName", couponName); // 券名称
|
|
couponJson.put("couponName", couponName); // 券名称
|
|
|
|
|
+ if (lifeDiscountCoupon != null) {
|
|
|
|
|
+ couponJson.put("couponTypeValue", lifeDiscountCoupon.getCouponType()); // 优惠券类型值(1-满减券,2-折扣券)
|
|
|
|
|
+ }
|
|
|
couponNotice.setContext(couponJson.toJSONString());
|
|
couponNotice.setContext(couponJson.toJSONString());
|
|
|
couponNotice.setNoticeType(1);
|
|
couponNotice.setNoticeType(1);
|
|
|
couponNotice.setTitle("好评送优惠券"); // 标题明确标注是优惠券
|
|
couponNotice.setTitle("好评送优惠券"); // 标题明确标注是优惠券
|