Browse Source

优惠券详情回显指定门店

cup 2 years ago
parent
commit
e49315b85c

+ 47 - 6
mp-admin/src/main/java/com/qs/mp/web/controller/api/admin/CouponMgrController.java

@@ -19,6 +19,8 @@ import com.qs.mp.admin.service.ICouponService;
 import com.qs.mp.admin.service.ICouponTicketService;
 import com.qs.mp.admin.service.ITicketBoxService;
 import com.qs.mp.channel.domain.Channel;
+import com.qs.mp.channel.domain.ChannelUserRel;
+import com.qs.mp.channel.domain.vo.ChannelVO;
 import com.qs.mp.channel.service.IChannelService;
 import com.qs.mp.common.annotation.Log;
 import com.qs.mp.common.constant.Constants;
@@ -154,7 +156,6 @@ public class CouponMgrController extends BaseApiController {
 			}
 		}
 		// 查询门店限制列表
-		List<Channel> channelList = new ArrayList<>();
 		List<CouponChannel> couponChannelList = new ArrayList<>();
 		LambdaQueryWrapper<CouponChannel> couponChanneQueryWrapper = new LambdaQueryWrapper<>();
 		couponChanneQueryWrapper.eq(CouponChannel::getCouponId, coupon.getCouponId());
@@ -163,11 +164,19 @@ public class CouponMgrController extends BaseApiController {
 		if(null != couponChannelList && couponChannelList.size() > 0) {
 			List<Long> channelIdList = couponChannelList.stream().map(CouponChannel::getChannelId).collect(Collectors.toList());
 			if(null != channelIdList && channelIdList.size() > 0) {
-				LambdaQueryWrapper<Channel> channelQueryWrapper = new LambdaQueryWrapper<>();
-				channelQueryWrapper.in(Channel::getChannelId, channelIdList);
-				channelQueryWrapper.orderByDesc(Channel::getCreatedTime);
-				channelList = channelService.list(channelQueryWrapper);
-				couponVO.setChannelList(channelList);
+				QueryWrapper<Channel> queryWrapper = new QueryWrapper<>();
+				queryWrapper.in("t1.channel_id", channelIdList);
+				List<ChannelVO> list = channelService.selectSaleSiteList(queryWrapper);
+
+				if(null != list && list.size() > 0) {
+					for(ChannelVO channelVO : list) {
+						if(null != channelVO && null != channelVO.getChannelId()
+							&& StringUtils.isNotBlank(channelVO.getChannelNo())) {
+							channelVO.setParentsName(getParentsName(channelVO.getChannelNo()));
+						}
+					}
+				}
+				couponVO.setChannelList(list);
 			}
 		}
 		return AjaxResult.success(couponVO);
@@ -341,4 +350,36 @@ public class CouponMgrController extends BaseApiController {
 		return AjaxResult.success("代金券删除成功");
 	}
 
+
+
+
+	private String getParentsName(String channelNo) {
+		if(StringUtils.isNotBlank(channelNo)) {
+			String[] noArray = channelNo.split("\\.");
+			if(null != noArray && noArray.length > 0) {
+				List<String> noList = new ArrayList<String>();
+				String parentNo = "";
+				for (int i = 0; i < noArray.length; i++) {
+					if(null != noArray[i] && StringUtils.isNotBlank(noArray[i])) {
+						parentNo += (i>0?".":"")+noArray[i];
+						if(StringUtils.isNotBlank(parentNo) && !parentNo.equals(channelNo)) {
+							noList.add(parentNo);
+						}
+					}
+				}
+				if(noList.size() > 0 ) {
+					LambdaQueryWrapper<Channel> queryWrapper = new LambdaQueryWrapper<Channel>();
+					queryWrapper.gt(Channel::getLevel, 0);
+					queryWrapper.in(Channel::getChannelNo,noList);
+					queryWrapper.orderByAsc(Channel::getLevel);
+					List<Channel> list = channelService.list(queryWrapper);
+					if(null != list && list.size() >0) {
+						String names = list.stream().map(Channel::getName).collect(Collectors.joining(" > "));
+						return names;
+					}
+				}
+			}
+		}
+		return "";
+	}
 }

+ 2 - 1
mp-service/src/main/java/com/qs/mp/admin/domain/vo/CouponVO.java

@@ -6,6 +6,7 @@ import com.qs.mp.admin.domain.CouponTicket;
 import com.qs.mp.admin.domain.GoodsSku;
 import com.qs.mp.admin.domain.TicketBox;
 import com.qs.mp.channel.domain.Channel;
+import com.qs.mp.channel.domain.vo.ChannelVO;
 import com.qs.mp.common.enums.CouponDiscountTypeEnum;
 import com.qs.mp.common.enums.CouponDistributeTypeEnum;
 import com.qs.mp.common.enums.CouponStatusEnum;
@@ -39,7 +40,7 @@ public class CouponVO {
      * 经销商门店优惠券使用范围限制列表
      */
     @ApiModelProperty("经销商门店优惠券使用范围限制列表")
-    private List<Channel> channelList;
+    private List<ChannelVO> channelList;
 
 
     /**