src/main/java/com/mzl/flower/dto/request/flower/FlowerMarkupPsSpQueryDTO.java
@@ -20,4 +20,10 @@ @ApiModelProperty(value = "标签") private String tags; @ApiModelProperty(value = "是否加价") private String isFee; @ApiModelProperty(value = "供应商") private String supplierName; } src/main/java/com/mzl/flower/dto/request/flower/FlowerMarkupSpQueryDTO.java
@@ -20,4 +20,10 @@ @ApiModelProperty(value = "合伙人ID") private Long partnerId; @ApiModelProperty(value = "是否加价") private String isFee; @ApiModelProperty(value = "供应商") private String supplierName; } src/main/java/com/mzl/flower/dto/response/flower/FlowerMarkupSpListDTO.java
@@ -67,4 +67,7 @@ @ApiModelProperty(value = "重量") private Double weight; @ApiModelProperty(value = "售价") private BigDecimal sellPrice; } src/main/java/com/mzl/flower/mapper/flower/FlowerMapper.java
@@ -55,4 +55,6 @@ void restoreFlowerBatch(@Param("list") List<Long> ids); List<Flower> getDeletdFlowByIds(@Param("list") List<Long> ids); void updateTypeRankNull(@Param("category") Long category, @Param("level") String level); } src/main/java/com/mzl/flower/service/BaseService.java
@@ -1,8 +1,10 @@ package com.mzl.flower.service; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.mzl.flower.base.cache.MarkupCacheClient; import com.mzl.flower.base.cache.StringCacheClient; import com.mzl.flower.config.exception.ValidationException; import com.mzl.flower.config.security.SecurityUtils; import com.mzl.flower.constant.Constants; @@ -25,6 +27,10 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.security.oauth2.common.OAuth2AccessToken; import org.springframework.security.oauth2.common.OAuth2RefreshToken; import org.springframework.security.oauth2.provider.token.TokenStore; import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.math.RoundingMode; @@ -33,10 +39,10 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.regex.Pattern; import static java.time.format.DateTimeFormatter.BASIC_ISO_DATE; @Service public class BaseService { @Autowired @@ -66,6 +72,16 @@ protected Member getMember(Long levelId){ return memberMapper.selectById(levelId); } @Autowired private StringCacheClient stringCacheClient; @Autowired private TokenStore tokenStore; public static final String TOKEN_KEY = "TOKEN-KEY"; public static final String SEPARATOR = ":"; protected double getServiceFeeRate(List<FeeService> fees, Integer saleCount){ int sc = saleCount == null ? 0 : saleCount; @@ -690,4 +706,22 @@ return null; } public void removeToken(String userId) { String tokenCache = stringCacheClient.get(TOKEN_KEY + SEPARATOR + userId); if (StringUtils.isNotBlank(tokenCache)) { //强制删除token,下线 if (StringUtils.isNotBlank(tokenCache) && StringUtils.isNotBlank(userId)) { stringCacheClient.delete(TOKEN_KEY + SEPARATOR + userId); String tokenValue = tokenCache.replace(OAuth2AccessToken.BEARER_TYPE, StrUtil.EMPTY).trim(); OAuth2AccessToken accessToken = tokenStore.readAccessToken(tokenValue); if (accessToken != null && StringUtils.isNotBlank(accessToken.getValue())) { tokenStore.removeAccessToken(accessToken); OAuth2RefreshToken refreshToken = accessToken.getRefreshToken(); tokenStore.removeRefreshToken(refreshToken); } } } } } src/main/java/com/mzl/flower/service/customer/CustomerService.java
@@ -20,6 +20,7 @@ import com.mzl.flower.mapper.partner.PartnerMapper; import com.mzl.flower.service.menber.MemberGrowthRecordService; import lombok.extern.slf4j.Slf4j; import com.mzl.flower.service.BaseService; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; @@ -40,6 +41,9 @@ private final PartnerMapper partnerMapper; @Resource private MemberGrowthRecordService memberGrowthRecordService; @Resource private BaseService baseService; public CustomerService(CustomerMapper customerMapper, PartnerMapper partnerMapper) { this.customerMapper = customerMapper; @@ -223,6 +227,8 @@ } if (customer.getIsEnabled()) { customer.setIsEnabled(false); //强制下线 baseService.removeToken(customer.getUserId()); } else { customer.setIsEnabled(true); } src/main/java/com/mzl/flower/service/flower/FlowerMarkupSpService.java
@@ -15,6 +15,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.util.List; @Slf4j @@ -77,6 +78,11 @@ if(ll != null && ll.size() > 0){ for(FlowerMarkupSpListDTO ss : ll){ ss.setPrice(getFinalPriceForPartner(dto.getPartnerId(), ss.getCategory(), ss.getFlowerId(), ss.getPrice(), ss.getLevel())); BigDecimal fee = ss.getFee(); if (fee == null) { fee = BigDecimal.ZERO; } ss.setSellPrice(ss.getPrice().add(fee)); } } @@ -90,6 +96,11 @@ if(ll != null && ll.size() > 0){ for(FlowerMarkupSpListDTO ss : ll){ ss.setPrice(getFinalPriceForPartner(dto.getPartnerId(), ss.getCategory(), ss.getFlowerId(), ss.getPrice(), ss.getLevel())); BigDecimal fee = ss.getFee(); if (fee == null) { fee = BigDecimal.ZERO; } ss.setSellPrice(ss.getPrice().add(fee)); } } src/main/java/com/mzl/flower/service/flower/FlowerService.java
@@ -139,10 +139,13 @@ } try{ flowerMapper.updateTypeRankNull(flower.getCategory(),flower.getLevel()); QueryWrapper<Flower> queryWrapper=new QueryWrapper<>(); queryWrapper.lambda().eq(Flower::getDeleted,false) .eq(Objects.nonNull(flower.getCategory()),Flower::getCategory,flower.getCategory()) .eq(StringUtils.isNotEmpty(flower.getLevel()),Flower::getLevel,flower.getLevel()) .eq(Flower::getStatus,"UP") .orderByAsc(Flower::getPrice); final List<Flower> flowerList = flowerMapper.selectList(queryWrapper); @@ -453,6 +456,9 @@ //清除购物车商品 cartMapper.delete(new QueryWrapper<Cart>().eq("flower_id", id)); } //更新排名 updateFlowTypeRank(null,f.getCategory(),f.getLevel()); } public void deleteFlower(Long id){ src/main/java/com/mzl/flower/service/partner/PartnerService.java
@@ -12,6 +12,7 @@ import com.mzl.flower.entity.partner.Partner; import com.mzl.flower.entity.supplier.Supplier; import com.mzl.flower.mapper.partner.PartnerMapper; import com.mzl.flower.service.BaseService; import com.mzl.flower.service.UploadService; import com.mzl.flower.utils.DateUtils; import lombok.extern.slf4j.Slf4j; @@ -20,6 +21,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; @@ -42,6 +44,9 @@ private final UploadService uploadService; @Resource private BaseService baseService; public PartnerService(PartnerMapper partnerMapper, WxMaService maService, UploadService uploadService) { this.partnerMapper = partnerMapper; @@ -171,6 +176,8 @@ } if (partner.getIsEnabled()) { partner.setIsEnabled(false); //强制下线 baseService.removeToken(partner.getUserId()); } else { partner.setIsEnabled(true); } src/main/java/com/mzl/flower/service/supplier/SupplierService.java
@@ -1,5 +1,6 @@ package com.mzl.flower.service.supplier; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -8,15 +9,20 @@ import com.mzl.flower.constant.Constants; import com.mzl.flower.dto.request.supplier.*; import com.mzl.flower.dto.response.supplier.SupplierDTO; import com.mzl.flower.entity.customer.Customer; import com.mzl.flower.entity.supplier.Supplier; import com.mzl.flower.mapper.supplier.SupplierMapper; import com.mzl.flower.service.BaseService; import com.mzl.flower.utils.DateUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.oauth2.common.OAuth2AccessToken; import org.springframework.security.oauth2.common.OAuth2RefreshToken; import org.springframework.security.oauth2.provider.token.TokenStore; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.time.LocalDateTime; import java.util.List; @@ -29,6 +35,9 @@ private final static String SUPPLIER_STATUS_REJECT = "R"; // 审核拒绝 private final SupplierMapper supplierMapper; @Resource private BaseService baseService; public SupplierService(SupplierMapper supplierMapper) { this.supplierMapper = supplierMapper; @@ -196,6 +205,8 @@ } if (supplier.getIsEnabled()) { supplier.setIsEnabled(false); //强制下线 baseService.removeToken(supplier.getUserId()); } else { supplier.setIsEnabled(true); } src/main/resources/mapper/flower/FlowerMapper.xml
@@ -421,4 +421,7 @@ #{id} </foreach> </update> <update id="updateTypeRankNull"> update t_flower set type_rank=null where category=#{category} and level=#{level} </update> </mapper> src/main/resources/mapper/flower/FlowerMarkupPsSpMapper.xml
@@ -33,6 +33,19 @@ ) ) </if> <if test="condition.supplierName != null and condition.supplierName != ''"> AND s.name LIKE concat('%', #{condition.supplierName},'%') </if> <if test="condition.isFee != null"> <choose> <when test="condition.isFee == 'markup'"> AND sp.fee > 0 </when> <otherwise> AND (sp.fee is null or sp.fee = 0) </otherwise> </choose> </if> ORDER BY f.id </select> src/main/resources/mapper/flower/FlowerMarkupSpMapper.xml
@@ -33,6 +33,19 @@ ) ) </if> <if test="condition.supplierName != null and condition.supplierName != ''"> AND s.name LIKE concat('%', #{condition.supplierName},'%') </if> <if test="condition.isFee != null"> <choose> <when test="condition.isFee == 'markup'"> AND sp.fee > 0 </when> <otherwise> AND (sp.fee is null or sp.fee = 0) </otherwise> </choose> </if> ORDER BY f.id </select> @@ -68,6 +81,16 @@ ) ) </if> <if test="condition.isFee != null"> <choose> <when test="condition.isFee == 'markup'"> AND sp.fee > 0 </when> <otherwise> AND (sp.fee is null or sp.fee = 0) </otherwise> </choose> </if> ORDER BY f.id </select> </mapper>