新增:优化小程序菜单管理功能,支持管理中心分类图标

This commit is contained in:
gxwebsoft
2024-06-01 02:44:38 +08:00
parent 4822a1ed3a
commit 2c96d545ac
15 changed files with 167 additions and 73 deletions
@@ -35,7 +35,11 @@ public class CardController extends BaseController {
@GetMapping("/page") @GetMapping("/page")
public ApiResult<PageResult<Card>> page(CardParam param) { public ApiResult<PageResult<Card>> page(CardParam param) {
// 使用关联查询 // 使用关联查询
return success(cardService.pageRel(param)); final User loginUser = getLoginUser();
if(loginUser != null){
param.setBuyUserId(loginUser.getUserId());
}
return success(cardService.pageRel(param));
} }
@ApiOperation("查询全部会员卡") @ApiOperation("查询全部会员卡")
@@ -41,6 +41,12 @@ public class Card implements Serializable {
@ApiModelProperty(value = "会员卡介绍") @ApiModelProperty(value = "会员卡介绍")
private String cardDesc; private String cardDesc;
@ApiModelProperty(value = "IC卡类型:1年卡,2次卡,3月卡,4会员IC卡,5充值卡 ")
private Integer type;
@ApiModelProperty(value = "成人/儿童")
private Integer cardType;
@ApiModelProperty(value = "会员卡图片") @ApiModelProperty(value = "会员卡图片")
private String image; private String image;
@@ -29,6 +29,9 @@ public class UserCard implements Serializable {
@ApiModelProperty(value = "用户id") @ApiModelProperty(value = "用户id")
private Integer userId; private Integer userId;
@ApiModelProperty(value = "会员卡ID")
private Integer cardId;
@ApiModelProperty(value = "sid场馆id集合,适用的场馆") @ApiModelProperty(value = "sid场馆id集合,适用的场馆")
private String sid; private String sid;
@@ -2,78 +2,90 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gxwebsoft.booking.mapper.CardMapper"> <mapper namespace="com.gxwebsoft.booking.mapper.CardMapper">
<!-- 关联查询sql --> <!-- 关联查询sql -->
<sql id="selectSql"> <sql id="selectSql">
SELECT a.*,b.merchant_name,b.image as merchant_avatar SELECT a.*,b.merchant_name,b.image as merchant_avatar
FROM booking_card a FROM booking_card a
LEFT JOIN shop_merchant b ON a.merchant_id = b.merchant_id LEFT JOIN shop_merchant b ON a.merchant_id = b.merchant_id
<where> <where>
<if test="param.cardId != null"> <if test="param.cardId != null">
AND a.card_id = #{param.cardId} AND a.card_id = #{param.cardId}
</if> </if>
<if test="param.cardName != null"> <if test="param.cardName != null">
AND a.card_name LIKE CONCAT('%', #{param.cardName}, '%') AND a.card_name LIKE CONCAT('%', #{param.cardName}, '%')
</if> </if>
<if test="param.cardCode != null"> <if test="param.cardCode != null">
AND a.card_code = #{param.cardCode} AND a.card_code = #{param.cardCode}
</if> </if>
<if test="param.merchantType != null"> <if test="param.type != null">
AND a.merchant_type = #{param.merchantType} AND a.type = #{param.type}
</if> </if>
<if test="param.image != null"> <if test="param.cardType != null">
AND a.image LIKE CONCAT('%', #{param.image}, '%') AND a.card_type = #{param.cardType}
</if> </if>
<if test="param.price != null"> <if test="param.merchantType != null">
AND a.price = #{param.price} AND a.merchant_type = #{param.merchantType}
</if> </if>
<if test="param.number != null"> <if test="param.image != null">
AND a.number = #{param.number} AND a.image LIKE CONCAT('%', #{param.image}, '%')
</if> </if>
<if test="param.month != null"> <if test="param.price != null">
AND a.month = #{param.month} AND a.price = #{param.price}
</if> </if>
<if test="param.discount != null"> <if test="param.number != null">
AND a.discount = #{param.discount} AND a.number = #{param.number}
</if> </if>
<if test="param.content != null"> <if test="param.month != null">
AND a.content LIKE CONCAT('%', #{param.content}, '%') AND a.month = #{param.month}
</if> </if>
<if test="param.userId != null"> <if test="param.discount != null">
AND a.user_id = #{param.userId} AND a.discount = #{param.discount}
</if> </if>
<if test="param.merchantId != null"> <if test="param.content != null">
AND a.merchant_id = #{param.merchantId} AND a.content LIKE CONCAT('%', #{param.content}, '%')
</if> </if>
<if test="param.comments != null"> <if test="param.userId != null">
AND a.comments LIKE CONCAT('%', #{param.comments}, '%') AND a.user_id = #{param.userId}
</if> </if>
<if test="param.status != null"> <if test="param.merchantId != null">
AND a.status = #{param.status} AND a.merchant_id = #{param.merchantId}
</if> </if>
<if test="param.sortNumber != null"> <if test="param.comments != null">
AND a.sort_number = #{param.sortNumber} AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
</if> </if>
<if test="param.createTimeStart != null"> <if test="param.status != null">
AND a.create_time &gt;= #{param.createTimeStart} AND a.status = #{param.status}
</if> </if>
<if test="param.createTimeEnd != null"> <if test="param.sortNumber != null">
AND a.create_time &lt;= #{param.createTimeEnd} AND a.sort_number = #{param.sortNumber}
</if> </if>
<if test="param.keywords != null"> <if test="param.createTimeStart != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') AND a.create_time &gt;= #{param.createTimeStart}
) </if>
</if> <if test="param.createTimeEnd != null">
</where> AND a.create_time &lt;= #{param.createTimeEnd}
</sql> </if>
<if test="param.cardIds != null">
AND a.card_id NOT IN
<foreach collection="param.cardIds" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
)
</if>
</where>
</sql>
<!-- 分页查询 --> <!-- 分页查询 -->
<select id="selectPageRel" resultType="com.gxwebsoft.booking.entity.Card"> <select id="selectPageRel" resultType="com.gxwebsoft.booking.entity.Card">
<include refid="selectSql"></include> <include refid="selectSql"></include>
</select> </select>
<!-- 查询全部 --> <!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.booking.entity.Card"> <select id="selectListRel" resultType="com.gxwebsoft.booking.entity.Card">
<include refid="selectSql"></include> <include refid="selectSql"></include>
</select> </select>
</mapper> </mapper>
@@ -1,6 +1,9 @@
package com.gxwebsoft.booking.param; package com.gxwebsoft.booking.param;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Set;
import com.baomidou.mybatisplus.annotation.TableField;
import com.gxwebsoft.common.core.annotation.QueryField; import com.gxwebsoft.common.core.annotation.QueryField;
import com.gxwebsoft.common.core.annotation.QueryType; import com.gxwebsoft.common.core.annotation.QueryType;
import com.gxwebsoft.common.core.web.BaseParam; import com.gxwebsoft.common.core.web.BaseParam;
@@ -34,6 +37,13 @@ public class CardParam extends BaseParam {
@QueryField(type = QueryType.EQ) @QueryField(type = QueryType.EQ)
private String cardCode; private String cardCode;
@ApiModelProperty(value = "IC卡类型:1年卡,2次卡,3月卡,4会员IC卡,5充值卡 ")
@QueryField(type = QueryType.EQ)
private Integer type;
@ApiModelProperty(value = "成人/儿童")
private Integer cardType;
@ApiModelProperty(value = "会员卡图片") @ApiModelProperty(value = "会员卡图片")
private String image; private String image;
@@ -79,4 +89,12 @@ public class CardParam extends BaseParam {
@QueryField(type = QueryType.EQ) @QueryField(type = QueryType.EQ)
private Integer sortNumber; private Integer sortNumber;
@ApiModelProperty(value = "会员卡ID集合")
@TableField(exist = false)
private Set<Integer> cardIds;
@ApiModelProperty(value = "买家用户ID")
@TableField(exist = false)
private Integer buyUserId;
} }
@@ -1,6 +1,9 @@
package com.gxwebsoft.booking.param; package com.gxwebsoft.booking.param;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Set;
import com.baomidou.mybatisplus.annotation.TableField;
import com.gxwebsoft.common.core.annotation.QueryField; import com.gxwebsoft.common.core.annotation.QueryField;
import com.gxwebsoft.common.core.annotation.QueryType; import com.gxwebsoft.common.core.annotation.QueryType;
import com.gxwebsoft.common.core.web.BaseParam; import com.gxwebsoft.common.core.web.BaseParam;
@@ -30,6 +33,10 @@ public class UserCardParam extends BaseParam {
@QueryField(type = QueryType.EQ) @QueryField(type = QueryType.EQ)
private Integer userId; private Integer userId;
@ApiModelProperty(value = "会员卡ID")
@QueryField(type = QueryType.EQ)
private Integer cardId;
@ApiModelProperty(value = "sid场馆id集合,适用的场馆") @ApiModelProperty(value = "sid场馆id集合,适用的场馆")
private String sid; private String sid;
@@ -187,4 +194,8 @@ public class UserCardParam extends BaseParam {
@QueryField(type = QueryType.EQ) @QueryField(type = QueryType.EQ)
private Integer deleted; private Integer deleted;
@ApiModelProperty(value = "会员卡ID集合")
@TableField(exist = false)
private Set<Integer> cardIds;
} }
@@ -1,15 +1,21 @@
package com.gxwebsoft.booking.service.impl; package com.gxwebsoft.booking.service.impl;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.booking.entity.UserCard;
import com.gxwebsoft.booking.mapper.CardMapper; import com.gxwebsoft.booking.mapper.CardMapper;
import com.gxwebsoft.booking.service.CardService; import com.gxwebsoft.booking.service.CardService;
import com.gxwebsoft.booking.entity.Card; import com.gxwebsoft.booking.entity.Card;
import com.gxwebsoft.booking.param.CardParam; import com.gxwebsoft.booking.param.CardParam;
import com.gxwebsoft.booking.service.UserCardService;
import com.gxwebsoft.common.core.web.PageParam; import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult; import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/** /**
* 会员卡Service实现 * 会员卡Service实现
@@ -19,11 +25,21 @@ import java.util.List;
*/ */
@Service @Service
public class CardServiceImpl extends ServiceImpl<CardMapper, Card> implements CardService { public class CardServiceImpl extends ServiceImpl<CardMapper, Card> implements CardService {
@Resource
private UserCardService userCardService;
@Override @Override
public PageResult<Card> pageRel(CardParam param) { public PageResult<Card> pageRel(CardParam param) {
PageParam<Card, CardParam> page = new PageParam<>(param); PageParam<Card, CardParam> page = new PageParam<>(param);
page.setDefaultOrder("sort_number asc, price asc, create_time desc"); page.setDefaultOrder("sort_number asc, price asc, create_time desc");
// 只显示可购买的会员卡
if(param.getSceneType() != null && param.getSceneType().equals("showCanBuyVipCard")){
final List<UserCard> userCardList = userCardService.list(new LambdaUpdateWrapper<UserCard>().eq(UserCard::getUserId, param.getBuyUserId()));
final Set<Integer> collect = userCardList.stream().map(UserCard::getCardId).collect(Collectors.toSet());
param.setCardIds(collect);
}
List<Card> list = baseMapper.selectPageRel(page, param); List<Card> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal()); return new PageResult<>(list, page.getTotal());
} }
@@ -95,6 +95,9 @@ public class MpMenu implements Serializable {
@ApiModelProperty(value = "用户ID") @ApiModelProperty(value = "用户ID")
private Integer userId; private Integer userId;
@ApiModelProperty(value = "是否管理人员可见")
private Integer adminShow;
@ApiModelProperty(value = "设为首页") @ApiModelProperty(value = "设为首页")
private Integer home; private Integer home;
@@ -76,6 +76,9 @@
<if test="param.userId != null"> <if test="param.userId != null">
AND a.user_id = #{param.userId} AND a.user_id = #{param.userId}
</if> </if>
<if test="param.adminShow != null">
AND a.admin_show = #{param.adminShow}
</if>
<if test="param.home != null"> <if test="param.home != null">
AND a.home = #{param.home} AND a.home = #{param.home}
</if> </if>
@@ -106,6 +106,10 @@ public class MpMenuParam extends BaseParam {
@QueryField(type = QueryType.EQ) @QueryField(type = QueryType.EQ)
private Integer userId; private Integer userId;
@ApiModelProperty(value = "是否管理人员可见")
@QueryField(type = QueryType.EQ)
private Integer adminShow;
@ApiModelProperty(value = "设为首页") @ApiModelProperty(value = "设为首页")
@QueryField(type = QueryType.EQ) @QueryField(type = QueryType.EQ)
private Integer home; private Integer home;
@@ -168,6 +168,7 @@ public class OrderController extends BaseController {
final UserCard userCard = new UserCard(); final UserCard userCard = new UserCard();
userCard.setUserId(loginUser.getUserId()); userCard.setUserId(loginUser.getUserId());
// 适用场馆 // 适用场馆
userCard.setCardId(Integer.valueOf(order.getCardId()));
userCard.setSid(card.getMerchantIds()); userCard.setSid(card.getMerchantIds());
userCard.setCardNum(CommonUtil.createCardNo()); userCard.setCardNum(CommonUtil.createCardNo());
userCard.setName(card.getCardName()); userCard.setName(card.getCardName());
@@ -188,6 +189,7 @@ public class OrderController extends BaseController {
userCard.setMonth(card.getMonth()); userCard.setMonth(card.getMonth());
userCard.setMerchantId(card.getMerchantId()); userCard.setMerchantId(card.getMerchantId());
userCard.setPayType(1); userCard.setPayType(1);
userCard.setType(card.getType());
userCard.setTenantId(card.getTenantId()); userCard.setTenantId(card.getTenantId());
userCard.setExpirationTime(DateUtil.offset(DateUtil.date(), DateField.MONTH, card.getMonth())); userCard.setExpirationTime(DateUtil.offset(DateUtil.date(), DateField.MONTH, card.getMonth()));
userCardService.save(userCard); userCardService.save(userCard);
@@ -206,7 +208,7 @@ public class OrderController extends BaseController {
} }
// 会员卡支付 // 会员卡支付
if(!Integer.valueOf(order.getCardId()).equals(0)){ if(order.getPayType().equals(7)){
order.setAccessToken(access_token); order.setAccessToken(access_token);
order.setLoginUser(loginUser); order.setLoginUser(loginUser);
return success("下单成功", orderService.payByUserCard(order)); return success("下单成功", orderService.payByUserCard(order));
@@ -48,6 +48,9 @@ public class Merchant implements Serializable {
@ApiModelProperty(value = "店铺类型") @ApiModelProperty(value = "店铺类型")
private String shopType; private String shopType;
@ApiModelProperty(value = "项目类型")
private String itemType;
@ApiModelProperty(value = "商户分类") @ApiModelProperty(value = "商户分类")
private String category; private String category;
@@ -28,6 +28,9 @@
<if test="param.shopType != null"> <if test="param.shopType != null">
AND a.shop_type LIKE CONCAT('%', #{param.shopType}, '%') AND a.shop_type LIKE CONCAT('%', #{param.shopType}, '%')
</if> </if>
<if test="param.itemType != null">
AND a.item_type = #{param.merchantId}
</if>
<if test="param.category != null"> <if test="param.category != null">
AND a.category LIKE CONCAT('%', #{param.category}, '%') AND a.category LIKE CONCAT('%', #{param.category}, '%')
</if> </if>
@@ -49,6 +49,9 @@ public class MerchantParam extends BaseParam {
@ApiModelProperty(value = "店铺类型") @ApiModelProperty(value = "店铺类型")
private String shopType; private String shopType;
@ApiModelProperty(value = "项目类型")
private String itemType;
@ApiModelProperty(value = "商户分类") @ApiModelProperty(value = "商户分类")
private String category; private String category;
@@ -302,6 +302,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
public Boolean payByUserCard(Order order) { public Boolean payByUserCard(Order order) {
final User loginUser = order.getLoginUser(); final User loginUser = order.getLoginUser();
final UserCardLog userCardLog = new UserCardLog(); final UserCardLog userCardLog = new UserCardLog();
if(order.getCardId() == null){
throw new BusinessException("会员卡ID不存在");
}
// 查询会员卡信息 // 查询会员卡信息
final UserCard userCard = userCardService.getById(order.getCardId()); final UserCard userCard = userCardService.getById(order.getCardId());