20221219
1、创建订单增加商品ID的入参
2、增加每日购买次数和购买商品会员等级判断
3、注册会员,设置了会员等级
4、商品接口增加了补贴金额和星级字段,增加总评价数量和总评价星数
1 files added
13 files modified
New file |
| | |
| | | package cc.mrbird.febs.common.enumerates; |
| | | |
| | | import lombok.Getter; |
| | | |
| | | //会员星级 |
| | | @Getter |
| | | public enum MemberAccountLevelEnum { |
| | | /** |
| | | * 定级规则 |
| | | */ |
| | | NORMAL("普通",0,1), |
| | | ONE_STAR("一星",50,2), |
| | | TWO_STAR("二星",100,3), |
| | | THREE_STAR("三星",200,4); |
| | | |
| | | private String name; |
| | | |
| | | private Integer amount; |
| | | |
| | | private Integer code; |
| | | |
| | | MemberAccountLevelEnum(String name,Integer amount,Integer code) { |
| | | this.name = name; |
| | | this.amount = amount; |
| | | this.code = code; |
| | | } |
| | | |
| | | /** |
| | | * 根据输入的会员星级获取对应的Code |
| | | * @param name |
| | | * @return |
| | | */ |
| | | public Integer getMemberLevelCode(String name){ |
| | | Integer code = 0; |
| | | for(MemberAccountLevelEnum memberAccountLevelEnum : MemberAccountLevelEnum.values()){ |
| | | if(memberAccountLevelEnum.name.equals(name)){ |
| | | code = memberAccountLevelEnum.code; |
| | | } |
| | | } |
| | | return code; |
| | | } |
| | | } |
| | |
| | | import lombok.Getter; |
| | | |
| | | import java.math.BigDecimal; |
| | | //商品星级 |
| | | @Getter |
| | | public enum StarRatingEnum { |
| | | /** |
| | | * 定级规则 |
| | | * 大于最小值,小于等于最大值 |
| | | */ |
| | | NORMAL("普通",0,30), |
| | | ONE_STAR("一星",30,50), |
| | | TWO_STAR("二星",50,100), |
| | | THREE_STAR("三星",100,200); |
| | | NORMAL("普通",0,30,1), |
| | | ONE_STAR("一星",30,50,2), |
| | | TWO_STAR("二星",50,100,3), |
| | | THREE_STAR("三星",100,200,4); |
| | | |
| | | private String name; |
| | | |
| | |
| | | |
| | | private Integer maxValue; |
| | | |
| | | StarRatingEnum(String name,Integer minValue, Integer maxValue) { |
| | | private Integer code; |
| | | |
| | | StarRatingEnum(String name,Integer minValue, Integer maxValue,Integer code) { |
| | | this.name = name; |
| | | this.minValue = minValue; |
| | | this.maxValue = maxValue; |
| | | this.code = code; |
| | | } |
| | | |
| | | /** |
| | |
| | | return name; |
| | | } |
| | | |
| | | /** |
| | | * 根据输入的商品星级获取对应的Code |
| | | * @param name |
| | | * @return |
| | | */ |
| | | public Integer getGoodsStarCode(String name){ |
| | | Integer code = 0; |
| | | for(StarRatingEnum starRatingEnum : StarRatingEnum.values()){ |
| | | if(starRatingEnum.name.equals(name)){ |
| | | code = starRatingEnum.code; |
| | | } |
| | | } |
| | | return code; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | String s = StarRatingEnum.NORMAL.belongStarRating(String.valueOf(100)); |
| | | System.out.println(s); |
| | |
| | | public class AddOrderDto { |
| | | |
| | | @NotNull(message = "参数不能为空") |
| | | @ApiModelProperty(value = "商品ID", example = "1") |
| | | private Long goodsId; |
| | | |
| | | @NotNull(message = "参数不能为空") |
| | | @ApiModelProperty(value = "地址ID", example = "1") |
| | | private Long addressId; |
| | | |
| | |
| | | */ |
| | | private Integer storeMaster; |
| | | |
| | | /** |
| | | * 会员等级 |
| | | */ |
| | | private String accountLevel; |
| | | |
| | | } |
| | |
| | | |
| | | IPage<AdminMallGoodsCommentVo> getCommentListInPage(Page<AdminMallGoodsCommentVo> page, @Param("record")AdminMallGoodsCommentDto adminMallGoodsCommentDto); |
| | | |
| | | Double selectSumStarByGoodsId(@Param("goodsId")Long id); |
| | | } |
| | |
| | | BigDecimal selectTotalAmountByPayDoneAndDataString(@Param("payResult")int i, @Param("date") Date date); |
| | | |
| | | BigDecimal selectSumAmountByPayMethodAndSomeStatue(@Param("payMethod")String name, @Param("statues") List<Long> values); |
| | | |
| | | Integer selectCountByCreateTimeAndMemberId(@Param("createdTime")String yyyyMMdd,@Param("memberId")Long memberId); |
| | | } |
| | |
| | | objectQueryWrapper.eq("goods_id",id); |
| | | Integer commentCount = mallGoodsCommentMapper.selectCount(objectQueryWrapper); |
| | | mallGoodsDetailsVo.setCommentCount(commentCount); |
| | | Double star = mallGoodsCommentMapper.selectSumStarByGoodsId(id); |
| | | mallGoodsDetailsVo.setStar(star); |
| | | return mallGoodsDetailsVo; |
| | | } |
| | | |
| | |
| | | package cc.mrbird.febs.mall.service.impl; |
| | | |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.enumerates.AgentLevelEnum; |
| | | import cc.mrbird.febs.common.enumerates.DataDictionaryEnum; |
| | | import cc.mrbird.febs.common.enumerates.FlowTypeEnum; |
| | | import cc.mrbird.febs.common.enumerates.MoneyFlowTypeEnum; |
| | | import cc.mrbird.febs.common.enumerates.*; |
| | | import cc.mrbird.febs.common.exception.FebsException; |
| | | import cc.mrbird.febs.common.utils.*; |
| | | import cc.mrbird.febs.mall.conversion.MallGoodsConversion; |
| | |
| | | mallMember.setName(registerDto.getName()); |
| | | mallMember.setAccountStatus(MallMember.ACCOUNT_STATUS_ENABLE); |
| | | mallMember.setAccountType(MallMember.ACCOUNT_TYPE_NORMAL); |
| | | mallMember.setAccountLevel(MemberAccountLevelEnum.NORMAL.getName()); |
| | | mallMember.setLevel(AgentLevelEnum.ZERO_LEVEL.name()); |
| | | mallMember.setSex("男"); |
| | | mallMember.setBindPhone(registerDto.getAccount()); |
| | |
| | | import cc.mrbird.febs.pay.service.UnipayService; |
| | | import cc.mrbird.febs.rabbit.producter.AgentProducer; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUnit; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.text.DecimalFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | private final MallMemberBankSignMapper mallMemberBankSignMapper; |
| | | private final MallMemberBankMapper mallMemberBankMapper; |
| | | private final MallShopApplyMapper mallShopApplyMapper; |
| | | private final DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Long createOrder(AddOrderDto addOrderDto) { |
| | | MallMember member = LoginUserUtil.getLoginUser(); |
| | | /** |
| | | * 根据会员星级判断是否可以购买该商品 |
| | | */ |
| | | MallMember mallMember = memberMapper.selectById(member.getId()); |
| | | String accountLevel = mallMember.getAccountLevel(); |
| | | Integer memberLevelCode = MemberAccountLevelEnum.NORMAL.getMemberLevelCode(accountLevel); |
| | | //获取商品星级 |
| | | MallGoods goods = mallGoodsMapper.selectById(addOrderDto.getGoodsId()); |
| | | String starRating = goods.getStarRating(); |
| | | Integer goodsStarCode = StarRatingEnum.NORMAL.getGoodsStarCode(starRating); |
| | | if(memberLevelCode < goodsStarCode){ |
| | | throw new FebsException("会员等级不够"); |
| | | } |
| | | /** |
| | | * 会员一天最多下单次数 |
| | | */ |
| | | DataDictionaryCustom buyTimesDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.BUY_TIMES.getType(), DataDictionaryEnum.BUY_TIMES.getCode()); |
| | | Integer buyTimes = Integer.parseInt(buyTimesDic.getValue()); |
| | | |
| | | DateTime date = DateUtil.date(); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String yyyyMMdd = sdf.format(date); |
| | | Integer times = this.baseMapper.selectCountByCreateTimeAndMemberId(yyyyMMdd,member.getId()); |
| | | if(buyTimes <= times){ |
| | | throw new FebsException("会员今日已无法购买"); |
| | | } |
| | | |
| | | // MallAddressInfo address = mallAddressInfoMapper.selectAddressInfoByMemberIdAndId(member.getId(), addOrderDto.getAddressId()); |
| | | // if (address == null) { |
| | |
| | | @ApiModelProperty(value = "样式") |
| | | private List<GoodsDetailsStyleVo> styles; |
| | | |
| | | @ApiModelProperty(value = "评论数量") |
| | | @ApiModelProperty(value = "评论总数量") |
| | | private Integer commentCount; |
| | | |
| | | @ApiModelProperty(value = "评论总星数") |
| | | private Double star; |
| | | //补贴金额 |
| | | |
| | | @ApiModelProperty(value = "补贴金额") |
| | | private BigDecimal subsidyAmount; |
| | | //星级等级 |
| | | |
| | | @ApiModelProperty(value = "星级等级") |
| | | private String starRating; |
| | | } |
| | |
| | | |
| | | @ApiModelProperty(value = "是否有运费 1-是 2-包邮") |
| | | private Integer hasCarriage; |
| | | //补贴金额 |
| | | |
| | | @ApiModelProperty(value = "补贴金额") |
| | | private BigDecimal subsidyAmount; |
| | | //星级等级 |
| | | |
| | | @ApiModelProperty(value = "星级等级") |
| | | private String starRating; |
| | | } |
| | |
| | | order by a.created_time desc |
| | | </select> |
| | | |
| | | <select id="selectSumStarByGoodsId" resultType="java.lang.Double"> |
| | | select Ifnull(sum(star),0) |
| | | from mall_goods_comment a |
| | | where goods_id = #{goodsId} |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | <result property="hasCarriage" column="has_carriage" /> |
| | | <result property="carriage" column="carriage" /> |
| | | <result property="isNormal" column="is_normal" /> |
| | | <result property="subsidyAmount" column="subsidy_amount" /> |
| | | <result property="starRating" column="star_rating" /> |
| | | <collection property="styles" ofType="cc.mrbird.febs.mall.entity.MallGoodsStyle"> |
| | | <id property="id" column="style_id" /> |
| | | <result property="name" column="style_name" /> |
| | |
| | | a.thumb, |
| | | a.original_price, |
| | | a.present_price, |
| | | a.subsidy_amount, |
| | | a.star_rating, |
| | | a.score, |
| | | a.is_hot, |
| | | min(b.present_price) price, |
| | |
| | | #{item} |
| | | </foreach> |
| | | </select> |
| | | |
| | | <select id="selectCountByCreateTimeAndMemberId" resultType="java.lang.Integer"> |
| | | select |
| | | count(a.id) |
| | | from mall_order_info a |
| | | where |
| | | date_format(a.CREATED_TIME, '%Y-%m-%d') = #{createTime} |
| | | and a.member_id = #{memberId} |
| | | </select> |
| | | </mapper> |