Просмотр исходного кода

fix 发货时,发放实物权益;可选权益车票

zoujiajian 3 лет назад
Родитель
Сommit
5d8ac6fd8c

+ 6 - 0
netflix-dao/src/main/java/com/cyksj/model/manage/views/OrderDonView.java

@@ -189,4 +189,10 @@ public class OrderDonView {
 
     @DbIgnore
     private String afterServiceName;
+
+    /**
+     * 是否可领取实物购买权益
+     */
+    @DbIgnore
+    private Boolean isHasBenefits;
 }

+ 43 - 0
netflix-dao/src/main/java/com/cyksj/model/views/UserAvailableGoodsTicketView.java

@@ -0,0 +1,43 @@
+package com.cyksj.model.views;
+
+import com.cyksj.model.manage.views.GroupsRelationView;
+import com.ejlchina.searcher.bean.DbField;
+import com.ejlchina.searcher.bean.DbIgnore;
+import com.ejlchina.searcher.bean.SearchBean;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/*
+ *项目名: netflix
+ *文件名: UserAvailableGoodsTicketView
+ *创建者: JavaZou
+ *创建时间:2023/3/8 17:02
+ */
+@Getter
+@Setter
+@SearchBean(tables = "user_pay_equipment_available_benefits ub left join goods_don_sku gdk on gdk.id = ub.sku_id" +
+		" left join goods_don g on g.id = gdk.goods_id")
+public class UserAvailableGoodsTicketView {
+
+	@DbField("g.id")
+	private Long goodsId;
+
+	@DbField("g.title")
+	private String goodsTile;
+
+	@DbField("ub.sku_id")
+	private Long skuId;
+
+	@DbField("ub.user_id")
+	private Long userId;
+
+	@DbField("ub.deleted")
+	@JsonIgnore
+	private Boolean deleted;
+
+	@DbIgnore
+	private List<GroupsRelationView> ticketList;
+}

+ 22 - 15
netflix-service/src/main/java/com/cyksj/service/exchange/impl/ExchangeCodeServiceImpl.java

@@ -25,6 +25,7 @@ import com.cyksj.model.request.ExchangeCodeReq;
 import com.cyksj.model.request.ExchangeCodeTicket;
 import com.cyksj.redis.RedisService;
 import com.cyksj.service.exchange.ExchangeCodeService;
+import com.cyksj.service.relation.GroupRelationFrontService;
 import com.cyksj.service.template.TemplateCommonService;
 import com.ejlchina.searcher.BeanSearcher;
 import com.ejlchina.searcher.util.MapUtils;
@@ -78,6 +79,8 @@ public class ExchangeCodeServiceImpl extends ServiceImpl<ExchangeCodeMapper, Exc
 
 	private final BeanSearcher beanSearcher;
 
+	private final GroupRelationFrontService groupRelationFrontService;
+
 	@Override
 	@Transactional(rollbackFor = Throwable.class)
 	public List<ExcelExchangeCodeData> createExchangeCode(ExchangeCodeReq exchangeCodeReq) {
@@ -224,23 +227,27 @@ public class ExchangeCodeServiceImpl extends ServiceImpl<ExchangeCodeMapper, Exc
 		if (user == null) {
 			throw BusinessRuntimeException.getInstance("用户不存在");
 		}
-		GroupsTrips groups = groupsMapper.selectOne(Wrappers.lambdaQuery(GroupsTrips.class).eq(GroupsTrips::getSkuId, sku.getId()).gt(GroupsTrips::getAvailableNum, 0).last("limit 1").orderByAsc(GroupsTrips::getAvailableNum));
 		GroupsRelation relation = null;
-		if (groups == null) {
-			//新增车位 并关联
-			relation = createNewGroupTripsAndRelation(sku, groups, relation);
-		} else {
-			//寻找快满编车队进行占座
-			relation = groupsRelationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class)
-					.eq(GroupsRelation::getGroupsId, groups.getId())
-					.eq(GroupsRelation::getStatus, "none")
-					.eq(GroupsRelation::getUserId, 0)
-					.orderByAsc(GroupsRelation::getNum)
-					.last("limit 1")
-			);
-			//如果占位失败 新增车位并关联
-			if (relation == null) {
+		//寻找差不多过期时间规格的车位
+		relation = groupRelationFrontService.getSimilarExpiredGroupRelation(sku.getId(), sku.getMonths());
+		if (relation == null) {
+			GroupsTrips groups = groupsMapper.selectOne(Wrappers.lambdaQuery(GroupsTrips.class).eq(GroupsTrips::getSkuId, sku.getId()).gt(GroupsTrips::getAvailableNum, 0).last("limit 1").orderByAsc(GroupsTrips::getAvailableNum));
+			if (groups == null) {
+				//新增车位 并关联
 				relation = createNewGroupTripsAndRelation(sku, groups, relation);
+			} else {
+				//寻找快满编车队进行占座
+				relation = groupsRelationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class)
+						.eq(GroupsRelation::getGroupsId, groups.getId())
+						.eq(GroupsRelation::getStatus, "none")
+						.eq(GroupsRelation::getUserId, 0)
+						.orderByAsc(GroupsRelation::getNum)
+						.last("limit 1")
+				);
+				//如果占位失败 新增车位并关联
+				if (relation == null) {
+					relation = createNewGroupTripsAndRelation(sku, groups, relation);
+				}
 			}
 		}
 

+ 26 - 5
netflix-service/src/main/java/com/cyksj/service/mange/impl/CmsOrderDonServiceImpl.java

@@ -1,20 +1,21 @@
 package com.cyksj.service.mange.impl;
 
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.cyksj.common.task.GlobalThreadPoolTaskExecutor;
+import com.cyksj.common.util.Jsons;
+import com.cyksj.mapper.GoodsDonSkuMapper;
 import com.cyksj.mapper.OrderDonMapper;
 import com.cyksj.mapper.OrderDonTransportMapper;
 import com.cyksj.mapper.OrderDonWaybillMapper;
 import com.cyksj.mapper.stock.GoodsSkuStockRelateMapper;
-import com.cyksj.model.entity.GoodsSkuStockRelate;
-import com.cyksj.model.entity.OrderDon;
-import com.cyksj.model.entity.OrderDonTransport;
-import com.cyksj.model.entity.OrderDonWaybill;
+import com.cyksj.model.entity.*;
 import com.cyksj.model.excel.ExcelOrderDonInfo;
 import com.cyksj.model.manage.request.ReqSetLogisticsPost;
 import com.cyksj.service.mange.CmsOrderDonService;
 import com.cyksj.service.mange.stock.GoodsDonStockService;
+import com.cyksj.service.order.UserRealOrderBenefitsService;
 import com.cyksj.service.template.TemplateCommonService;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -43,6 +44,10 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
 
     private final TemplateCommonService templateCommonService;
 
+    private final GoodsDonSkuMapper goodsDonSkuMapper;
+
+    private final UserRealOrderBenefitsService userRealOrderBenefitsService;
+
     private static final GlobalThreadPoolTaskExecutor TASK_POOL = GlobalThreadPoolTaskExecutor.getInstance();
 
     @Override
@@ -68,7 +73,23 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
             orderDonWaybillMapper.insert(orderDonWaybill);
             orderDon.setStatus(OrderDon.Status.transport);
             updateById(orderDon);
+            //发放实物购买权益
+            Boolean isReceivedAll = true;
+            GoodsDonSku sku = goodsDonSkuMapper.selectById(orderDon.getSkuId());
+            if (sku != null) {
+                if (sku.getIsBenefits()) {
+                    if (StrUtil.isNotEmpty(sku.getBenefitsList())) {
+                        try {
+                            List<Long> skuIds = Jsons.parseList(sku.getBenefitsList(), Long.class);
+                            //自购实物 获取权益
+                            isReceivedAll = userRealOrderBenefitsService.getPayRealGoodsBenefits(orderDon.getUserId(), orderDon.getId(), sku.getId(), skuIds);
+                        } catch (Exception e) {
 
+                        }
+                    }
+                }
+            }
+            final Boolean flag = isReceivedAll;
             //库存扣减逻辑
             List<GoodsSkuStockRelate> relateList = skuStockRelateMapper.selectList(Wrappers.lambdaQuery(GoodsSkuStockRelate.class).eq(GoodsSkuStockRelate::getSkuId,orderDon.getSkuId()));
             if(!relateList.isEmpty()){
@@ -81,7 +102,7 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
             TASK_POOL.execute(()->{
                 try {
                     log.info("发送发货通知至{}用户", orderDon.getUserId());
-                    templateCommonService.sendTransportMsgNotify(orderDon, reqSetLogisticsPost);
+                    templateCommonService.sendTransportMsgNotify(orderDon, reqSetLogisticsPost, flag);
                 } catch (Exception e) {
                     log.error("发送发货通知至{}用户失败:{}", orderDon.getUserId(), e);
                 }

+ 7 - 1
netflix-service/src/main/java/com/cyksj/service/order/UserRealOrderBenefitsService.java

@@ -1,6 +1,7 @@
 package com.cyksj.service.order;
 
 import com.cyksj.model.manage.views.GroupsRelationView;
+import com.cyksj.model.views.UserAvailableGoodsTicketView;
 
 import java.util.List;
 
@@ -15,7 +16,7 @@ public interface UserRealOrderBenefitsService {
 	/**
 	 * 获取购买实物权益
 	 */
-	void getPayRealGoodsBenefits(Long userId, Long goodsId, Long skuId, List<Long> skuIds);
+	Boolean getPayRealGoodsBenefits(Long userId, Long goodsId, Long skuId, List<Long> skuIds);
 
 	/**
 	 * 扣除实物权益
@@ -26,4 +27,9 @@ public interface UserRealOrderBenefitsService {
 	 * 领取实物权益
 	 */
 	GroupsRelationView receiveRealGoodsBenefits(Long userId, Long benefitsId, Long goodsId, Long skuId, Long relationId);
+
+	/**
+	 * 实物权益可选车票
+	 */
+	List<UserAvailableGoodsTicketView> getAvailableBenefitsTickets(Long userId);
 }

+ 4 - 39
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java

@@ -64,6 +64,7 @@ import com.cyksj.service.market.MarketFrontService;
 import com.cyksj.service.market.task.TaskService;
 import com.cyksj.service.order.OrderDonService;
 import com.cyksj.service.order.UserRealOrderBenefitsService;
+import com.cyksj.service.relation.GroupRelationFrontService;
 import com.cyksj.service.template.TemplateCommonService;
 import com.cyksj.service.wechat.WeChatService;
 import com.cyksj.task.JobManager;
@@ -181,6 +182,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 
 	private final CouponDistributePopularizeMapper couponDistributePopularizeMapper;
 
+	private final GroupRelationFrontService groupRelationFrontService;
+
 	private final List<String> noChekGoodsTemp = List.of("Apple One", "Youtube", "Spotify");
 
 	@Transactional(rollbackFor = Throwable.class)
@@ -224,7 +227,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 
 				} else {
 					//寻找差不多过期时间规格的车位
-					relation = getSimilarExpiredGroupRelation(sku.getId(), sku.getMonths());
+					relation = groupRelationFrontService.getSimilarExpiredGroupRelation(sku.getId(), sku.getMonths());
 					if (relation == null) {
 						//TODO 如果没指定座位,等待逻辑确认
 						GroupsTrips groups = groupsMapper.selectOne(Wrappers.lambdaQuery(GroupsTrips.class).eq(GroupsTrips::getSkuId, payRequest.getSkuId()).gt(GroupsTrips::getAvailableNum, 0).last("limit 1").orderByAsc(GroupsTrips::getAvailableNum));
@@ -354,22 +357,6 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		return orderDon;
 	}
 
-	private GroupsRelation getSimilarExpiredGroupRelation(Long skuId, Integer months) {
-		DateTime expiryTime = DateUtil.offsetMonth(DateTime.now(), months);
-		DateTime minExpiryTime = DateUtil.offsetDay(expiryTime, -5);
-		Long groupsId = groupsRelationMapper.selectSimilarExpiredRelation(skuId, minExpiryTime);
-		if (groupsId == null) {
-			return null;
-		}
-		GroupsRelation relation = groupsRelationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class)
-				.eq(GroupsRelation::getGroupsId, groupsId)
-				.eq(GroupsRelation::getStatus, GroupsRelation.Status.none)
-				.eq(GroupsRelation::getUserId, 0)
-				.orderByAsc(GroupsRelation::getNum)
-				.last("limit 1"));
-		return relation;
-	}
-
 	@Override
 	public H5JsPayParams pay(Long orderId, String tradeType) throws Exception {
 		log.info("调起微信支付[start] orderId:{}", orderId);
@@ -526,17 +513,6 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 				marketFrontService.addSpecificChanceNum(order.getUserId(), order.getId(), order.getGoodsId(), order.getSkuId());
 				if (goodsDon.getType() == 2) {
 					equipmentDistributeService.addDistributeBenefitsChance(order.getUserId(), order.getId());
-					if (sku.getIsBenefits()) {
-						if (StrUtil.isNotEmpty(sku.getBenefitsList())) {
-							try {
-								List<Long> skuIds = Jsons.parseList(sku.getBenefitsList(), Long.class);
-								//自购实物 获取权益
-								userRealOrderBenefitsService.getPayRealGoodsBenefits(order.getUserId(), order.getId(), goodsDon.getId(), skuIds);
-							} catch (Exception e) {
-
-							}
-						}
-					}
 				}
 				//若该订单使用了规定推广者的兑换码 增加上下级关系
 				if (StrUtil.isNotBlank(order.getCouponExCode())) {
@@ -815,17 +791,6 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 				marketFrontService.addSpecificChanceNum(orderDon.getUserId(), orderDon.getId(), orderDon.getGoodsId(), orderDon.getSkuId());
 				if (goodsDon.getType() == 2) {
 					equipmentDistributeService.addDistributeBenefitsChance(orderDon.getUserId(), orderDon.getId());
-					if (sku.getIsBenefits()) {
-						if (StrUtil.isNotEmpty(sku.getBenefitsList())) {
-							try {
-								List<Long> skuIds = Jsons.parseList(sku.getBenefitsList(), Long.class);
-								//自购实物 获取权益
-								userRealOrderBenefitsService.getPayRealGoodsBenefits(orderDon.getUserId(), orderDon.getId(), goodsDon.getId(), skuIds);
-							} catch (Exception e) {
-
-							}
-						}
-					}
 				}
 				//若该订单使用了规定推广者的兑换码 增加上下级关系
 				if (StrUtil.isNotBlank(orderDon.getCouponExCode())) {

+ 35 - 8
netflix-service/src/main/java/com/cyksj/service/order/impl/UserRealOrderBenefitsImpl.java

@@ -13,10 +13,12 @@ import com.cyksj.mapper.channel.UserPayEquipmentAvailableBenefitsMapper;
 import com.cyksj.mapper.channel.UserPayEquipmentReceiveBenefitsRecordMapper;
 import com.cyksj.model.entity.*;
 import com.cyksj.model.manage.views.GroupsRelationView;
+import com.cyksj.model.views.UserAvailableGoodsTicketView;
 import com.cyksj.service.exchange.ExchangeCodeService;
 import com.cyksj.service.order.UserRealOrderBenefitsService;
 import com.cyksj.service.relation.GroupRelationClearService;
 import com.ejlchina.searcher.BeanSearcher;
+import com.ejlchina.searcher.param.Operator;
 import com.ejlchina.searcher.util.MapUtils;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -24,10 +26,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Optional;
+import java.util.*;
 
 /*
  *项目名: netflix
@@ -56,8 +55,9 @@ public class UserRealOrderBenefitsImpl implements UserRealOrderBenefitsService {
 	private final OrderDonMapper orderDonMapper;
 
 	@Override
-	public void getPayRealGoodsBenefits(Long userId, Long orderId, Long goodsId, List<Long> skuIds) {
-		skuIds.forEach(skuId->{
+	public Boolean getPayRealGoodsBenefits(Long userId, Long orderId, Long goodsId, List<Long> skuIds) {
+		Boolean isReceivedAll = true;
+		for (Long skuId : skuIds) {
 			GoodsDonSku goodsDonSku = goodsDonSkuMapper.selectById(skuId);
 			if (goodsDonSku != null) {
 				List<GroupsRelationView> relationViewList = beanSearcher.searchAll(GroupsRelationView.class, MapUtils.builder()
@@ -70,6 +70,11 @@ public class UserRealOrderBenefitsImpl implements UserRealOrderBenefitsService {
 				if (CollUtil.isEmpty(relationViewList)) {
 					//领取权益时,没有车票的用户自动上车,获得对应车票
 					GroupsRelation relation = exchangeCodeService.getGroupTripsTicket(goodsDonSku, userId, null, OrderDon.Type.PAY_EQUIPMENT);
+					//多给三天
+					DateTime expiryTime = DateUtil.offsetDay(relation.getExpiryTime(), 3);
+					groupsRelationMapper.update(null, Wrappers.lambdaUpdate(GroupsRelation.class)
+							.set(GroupsRelation::getExpiryTime, expiryTime)
+							.eq(GroupsRelation::getId, relation.getId()));
 					saveReceiveBenefitsRecord(userId, skuId, orderId, relation.getOrderId(), relation.getId(), goodsDonSku.getMonths(), 1);
 				} else if (relationViewList.size() == 1) {
 					//若有且只有一张增加时长
@@ -79,18 +84,23 @@ public class UserRealOrderBenefitsImpl implements UserRealOrderBenefitsService {
 						throw BusinessRuntimeException.getInstance("该车位暂未发车,请发车后再领取权益");
 					}
 					DateTime updateExpiryTime = DateUtil.offset(expiryTime, DateField.MONTH, goodsDonSku.getMonths());
+					updateExpiryTime = DateUtil.offsetDay(updateExpiryTime, 3);
 					groupsRelationMapper.update(null, Wrappers.lambdaUpdate(GroupsRelation.class)
 							.eq(GroupsRelation::getId, groupsRelationView.getId())
 							.eq(GroupsRelation::getUserId, userId)
 							.set(GroupsRelation::getExpiryTime, updateExpiryTime));
 					groupsRelationView.setUpdateExpiryTime(updateExpiryTime);
 					saveReceiveBenefitsRecord(userId, skuId, orderId, null, groupsRelationView.getId(), goodsDonSku.getMonths(), 1);
-				}else {
+				} else {
 					//若有该规格多张车票,保存可获取的车票权益 以供用户自行选择
 					saveAvailableBenefits(userId, skuId, orderId);
+					if (isReceivedAll) {
+						isReceivedAll = false;
+					}
 				}
 			}
-		});
+		}
+		return isReceivedAll;
 	}
 
 	@Override
@@ -150,6 +160,7 @@ public class UserRealOrderBenefitsImpl implements UserRealOrderBenefitsService {
 				throw BusinessRuntimeException.getInstance("系统错误,请刷新页面重试");
 			}
 			DateTime updateExpiryTime = DateUtil.offset(expiryTime, DateField.MONTH, goodsDonSku.getMonths());
+			updateExpiryTime = DateUtil.offsetDay(updateExpiryTime, 3);
 			groupsRelationMapper.update(null, Wrappers.lambdaUpdate(GroupsRelation.class)
 					.eq(GroupsRelation::getId, groupsRelationView.getId())
 					.eq(GroupsRelation::getUserId, userId)
@@ -163,6 +174,22 @@ public class UserRealOrderBenefitsImpl implements UserRealOrderBenefitsService {
 		return groupsRelationView;
 	}
 
+	@Override
+	public List<UserAvailableGoodsTicketView> getAvailableBenefitsTickets(Long userId) {
+		List<UserAvailableGoodsTicketView> ticketViews = beanSearcher.searchAll(UserAvailableGoodsTicketView.class, MapUtils.builder().field(UserAvailableGoodsTicketView::getUserId, userId)
+				.field(UserAvailableGoodsTicketView::getDeleted, true).build());
+		ticketViews.forEach(ticket -> {
+			List<GroupsRelationView> relationViewList = beanSearcher.searchAll(GroupsRelationView.class, MapUtils.builder()
+					.field(GroupsRelationView::getSkuId, ticket.getSkuId())
+					.field(GroupsRelationView::getUserId, userId)
+					.field(GroupsRelationView::getStatus, GroupsRelation.Status.validity.name())
+					.field(GroupsRelationView::getExpiryTime).op(Operator.NotNull)
+					.build());
+			ticket.setTicketList(relationViewList);
+		});
+		return ticketViews;
+	}
+
 	/**
 	 * 保存获取权益记录
 	 */

+ 3 - 0
netflix-service/src/main/java/com/cyksj/service/relation/GroupRelationFrontService.java

@@ -1,5 +1,6 @@
 package com.cyksj.service.relation;
 
+import com.cyksj.model.entity.GroupsRelation;
 import com.cyksj.model.views.RenewalView;
 
 import java.util.List;
@@ -14,4 +15,6 @@ public interface GroupRelationFrontService {
 	List<RenewalView> getMyTicket(long userId, Boolean isLoginPopularize);
 
 	Boolean isJoinCorpWx(Long userId, Boolean isJoin, Boolean noCoupon);
+
+	GroupsRelation getSimilarExpiredGroupRelation(Long skuId, Integer months);
 }

+ 21 - 0
netflix-service/src/main/java/com/cyksj/service/relation/impl/GroupRelationFrontServiceImpl.java

@@ -1,11 +1,13 @@
 package com.cyksj.service.relation.impl;
 
 import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.cyksj.common.exception.BusinessRuntimeException;
 import com.cyksj.enums.GatewayApiCode;
+import com.cyksj.mapper.GroupsRelationMapper;
 import com.cyksj.mapper.UserMapper;
 import com.cyksj.mapper.corp.CorpUserMapper;
 import com.cyksj.mapper.market.task.UserBindPhoneMapper;
@@ -44,6 +46,8 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 
 	private final CouponCommonService couponCommonService;
 
+	private final GroupsRelationMapper groupsRelationMapper;
+
 	@Override
 	public List<RenewalView> getMyTicket(long userId, Boolean isLoginPopularize) {
 		User u = userMapper.selectById(userId);
@@ -127,4 +131,21 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 		}
 		return true;
 	}
+
+	@Override
+	public GroupsRelation getSimilarExpiredGroupRelation(Long skuId, Integer months) {
+		DateTime expiryTime = DateUtil.offsetMonth(DateTime.now(), months);
+		DateTime minExpiryTime = DateUtil.offsetDay(expiryTime, -5);
+		Long groupsId = groupsRelationMapper.selectSimilarExpiredRelation(skuId, minExpiryTime);
+		if (groupsId == null) {
+			return null;
+		}
+		GroupsRelation relation = groupsRelationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class)
+				.eq(GroupsRelation::getGroupsId, groupsId)
+				.eq(GroupsRelation::getStatus, GroupsRelation.Status.none)
+				.eq(GroupsRelation::getUserId, 0)
+				.orderByAsc(GroupsRelation::getNum)
+				.last("limit 1"));
+		return relation;
+	}
 }

+ 1 - 1
netflix-service/src/main/java/com/cyksj/service/template/TemplateCommonService.java

@@ -29,7 +29,7 @@ public interface TemplateCommonService {
 	/**
 	 * 发货通知模板消息
 	 */
-	void sendTransportMsgNotify(OrderDon orderDon, ReqSetLogisticsPost reqSetLogisticsPost) throws Exception;
+	void sendTransportMsgNotify(OrderDon orderDon, ReqSetLogisticsPost reqSetLogisticsPost, Boolean isReceiveAll) throws Exception;
 
 	/**
 	 * 空车位通知模板

+ 5 - 4
netflix-service/src/main/java/com/cyksj/service/template/impl/TemplateCommonServiceImpl.java

@@ -124,7 +124,7 @@ public class TemplateCommonServiceImpl implements TemplateCommonService {
 	}
 
 	@Override
-	public void sendTransportMsgNotify(OrderDon orderDon, ReqSetLogisticsPost reqSetLogisticsPost) throws Exception {
+	public void sendTransportMsgNotify(OrderDon orderDon, ReqSetLogisticsPost reqSetLogisticsPost, Boolean isReceiveAll) throws Exception {
 		if (!EnvCommonService.active.equals(envCommonService.getEnv())) {
 			Long userId = orderDon.getUserId();
 			WxAppTemplateView wxAppTemplateView = this.getWxAppByUserId(userId, TemplateEnum.ORDER_TRANSPORT_TEMPLATE.getDesc());
@@ -137,11 +137,12 @@ public class TemplateCommonServiceImpl implements TemplateCommonService {
 					}
 					openId = u.getOpenId();
 				}
+				String url = String.format("%s%s", envCommonService.getDomain(), "order");
 				WxMpTemplateMessage templateMessage = new WxMpTemplateMessage()
 						.setToUser(openId)
 						.setTemplateId(wxAppTemplateView.getTemplateId())
-						//TODO
-						.setUrl(" ");
+						.setUrl(url);
+				String msg = isReceiveAll ? "家庭套餐特权已生效,可在我的车票中查看" : "存在待领取权益,点击查看详情";
 				GoodsDon goodsDon = goodsDonMapper.selectById(orderDon.getGoodsId());
 				OrderDonTransport transport = transportMapper.selectOne(Wrappers.lambdaQuery(OrderDonTransport.class).eq(OrderDonTransport::getOrderId, reqSetLogisticsPost.getOrderId()).last("limit 1"));
 				WxMpTemplateMessage.TemplateData data = templateMessage.getData();
@@ -151,7 +152,7 @@ public class TemplateCommonServiceImpl implements TemplateCommonService {
 				data.setKeyword3(new WxMpTemplateData(reqSetLogisticsPost.getCodeCn()));
 				data.setKeyword4(new WxMpTemplateData(reqSetLogisticsPost.getTrackingNumber()));
 				data.setKeyword5(new WxMpTemplateData(String.format("%s%s%s%s", transport.getProvince(), transport.getCity(), transport.getDistrict(), transport.getAddress())));
-				data.setRemark(new WxMpTemplateData("可复制运单编号查询物流信息"));
+				data.setRemark(new WxMpTemplateData(String.format("可复制运单编号查询物流信息\n%s", msg)));
 				weChatService.sendTemplateMessage(weChatService.getAccessToken(wxAppTemplateView.getAppId()), Jsons.toJson(templateMessage));
 			}
 		}

+ 12 - 0
netflix-web/src/main/java/com/cyksj/web/controller/payment/OrderController.java

@@ -3,6 +3,7 @@ package com.cyksj.web.controller.payment;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.extra.qrcode.QrCodeUtil;
 import cn.hutool.extra.qrcode.QrConfig;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.cyksj.common.exception.BusinessRuntimeException;
 import com.cyksj.common.util.IoKit;
 import com.cyksj.common.util.Xmls;
@@ -11,9 +12,11 @@ import com.cyksj.config.zfb.ZfbProductCode;
 import com.cyksj.dto.Result;
 import com.cyksj.enums.GatewayResponse;
 import com.cyksj.mapper.OrderDonMapper;
+import com.cyksj.mapper.channel.UserPayEquipmentAvailableBenefitsMapper;
 import com.cyksj.model.dto.AliPayParams;
 import com.cyksj.model.dto.H5JsPayParams;
 import com.cyksj.model.entity.OrderDon;
+import com.cyksj.model.entity.UserPayEquipmentAvailableBenefits;
 import com.cyksj.model.manage.views.OrderDonView;
 import com.cyksj.model.request.AlipayOrderDonReq;
 import com.cyksj.model.request.OrderPayRequest;
@@ -63,6 +66,9 @@ public class OrderController {
     @Autowired
     private OrderDonMapper orderDonMapper;
 
+    @Autowired
+    private UserPayEquipmentAvailableBenefitsMapper availableBenefitsMapper;
+
     /**
      * 支付
      * @author chan
@@ -298,6 +304,12 @@ public class OrderController {
                 .field(OrderDonView::getUserId,userId)
                 .orderBy(OrderDonView::getId).desc()
                 .build());
+        search.getDataList().forEach(data->{
+            Integer count = availableBenefitsMapper.selectCount(Wrappers.lambdaQuery(UserPayEquipmentAvailableBenefits.class)
+                    .eq(UserPayEquipmentAvailableBenefits::getRealOrderId, data.getId())
+                    .eq(UserPayEquipmentAvailableBenefits::getDeleted, true));
+            data.setIsHasBenefits(count > 0 ? true : false);
+        });
         return GatewayResponse.SUCCESS.newBuilder().toResult(search);
     }
 

+ 7 - 1
netflix-web/src/main/java/com/cyksj/web/controller/user/UserController.java

@@ -16,6 +16,7 @@ import com.cyksj.model.manage.views.GroupsRelationView;
 import com.cyksj.model.request.ExchangeCodeTicket;
 import com.cyksj.model.request.ReceiveBenefitsReq;
 import com.cyksj.model.views.RenewalView;
+import com.cyksj.model.views.UserAvailableGoodsTicketView;
 import com.cyksj.model.views.UserPersonalView;
 import com.cyksj.service.exchange.ExchangeCodeService;
 import com.cyksj.service.order.UserRealOrderBenefitsService;
@@ -109,7 +110,12 @@ public class UserController {
     /**
      * 用户已有实物权益 可选车票
      */
-    @GetMapping("/get/")
+    @GetMapping("/get/available/benefits/tickets")
+    public Result<List<UserAvailableGoodsTicketView>> getAvailableBenefitsTickets() {
+        Long userId = StpUserUtil.getLoginIdAsLong();
+        List<UserAvailableGoodsTicketView> tickets = userRealOrderBenefitsService.getAvailableBenefitsTickets(userId);
+        return GatewayResponse.SUCCESS.newBuilder().toResult(tickets);
+    }
 
     /**
      * 用户领取实物权益