From 9aa253b56feb8dc89a34f98bc3720d3f0ae742bb Mon Sep 17 00:00:00 2001 From: paulGao Date: Mon, 14 Feb 2022 14:17:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E7=BC=BA=E5=A4=B1=E7=9A=84?= =?UTF-8?q?=E4=BA=8B=E5=8A=A1=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/event/impl/StockUpdateExecute.java | 2 + .../serviceimpl/ConnectServiceImpl.java | 30 +++++++------- .../DistributionCashServiceImpl.java | 7 +++- .../DistributionOrderServiceImpl.java | 3 ++ .../serviceimpl/DistributionServiceImpl.java | 4 +- .../file/serviceimpl/FileServiceImpl.java | 30 +++++++------- .../goods/serviceimpl/BrandServiceImpl.java | 14 ++----- .../serviceimpl/CategoryBrandServiceImpl.java | 2 + .../CategoryParameterGroupServiceImpl.java | 10 +---- .../serviceimpl/CategoryServiceImpl.java | 41 ++++--------------- .../serviceimpl/CommodityServiceImpl.java | 7 +++- .../serviceimpl/GoodsGalleryServiceImpl.java | 2 + .../goods/serviceimpl/GoodsServiceImpl.java | 11 ++++- .../serviceimpl/GoodsSkuServiceImpl.java | 6 ++- .../serviceimpl/ParametersServiceImpl.java | 2 + .../serviceimpl/SpecificationServiceImpl.java | 11 ++--- .../StoreGoodsLabelServiceImpl.java | 3 ++ .../goods/serviceimpl/StudioServiceImpl.java | 5 +++ .../serviceimpl/FootprintServiceImpl.java | 5 ++- .../serviceimpl/MemberAddressServiceImpl.java | 3 ++ .../MemberEvaluationServiceImpl.java | 3 +- .../MemberNoticeSenterServiceImpl.java | 7 ++-- .../MemberPointsHistoryServiceImpl.java | 3 +- .../serviceimpl/MemberReceiptServiceImpl.java | 11 +++-- .../member/serviceimpl/MemberServiceImpl.java | 2 + .../StoreCollectionServiceImpl.java | 3 ++ .../serviceimpl/MessageServiceImpl.java | 2 + .../serviceimpl/NoticeMessageServiceImpl.java | 14 +++---- .../serviceimpl/StoreMessageServiceImpl.java | 8 ++-- .../serviceimpl/AfterSaleServiceImpl.java | 6 +++ .../order/cart/service/CartServiceImpl.java | 3 ++ .../OrderComplaintServiceImpl.java | 2 + .../order/serviceimpl/OrderServiceImpl.java | 17 ++++++-- .../serviceimpl/StoreFlowServiceImpl.java | 12 +++--- .../order/serviceimpl/TradeServiceImpl.java | 2 +- .../ArticleCategoryServiceImpl.java | 2 + .../page/serviceimpl/ArticleServiceImpl.java | 14 +++---- .../page/serviceimpl/PageDataServiceImpl.java | 6 +++ .../page/serviceimpl/SpecialServiceImpl.java | 3 ++ .../serviceimpl/AdminUserServiceImpl.java | 19 +++++---- .../DepartmentRoleServiceImpl.java | 2 + .../serviceimpl/DepartmentServiceImpl.java | 2 + .../serviceimpl/RoleMenuServiceImpl.java | 2 + .../serviceimpl/RoleServiceImpl.java | 2 + .../serviceimpl/UserRoleServiceImpl.java | 2 + .../CouponActivityItemServiceImpl.java | 2 - .../CouponActivityServiceImpl.java | 4 +- .../serviceimpl/CouponServiceImpl.java | 2 - .../KanjiaActivityGoodsServiceImpl.java | 3 ++ .../KanjiaActivityServiceImpl.java | 2 + .../serviceimpl/PointsGoodsServiceImpl.java | 5 +++ .../serviceimpl/SeckillServiceImpl.java | 2 + .../PurchaseOrderItemServiceImpl.java | 3 +- .../serviceimpl/PurchaseOrderServiceImpl.java | 3 ++ .../PurchaseQuotedItemServiceImpl.java | 2 + .../PurchaseQuotedServiceImpl.java | 2 + .../serviceimpl/CustomWordsServiceImpl.java | 3 ++ .../sms/serviceimpl/SmsReachServiceImpl.java | 2 + .../sms/serviceimpl/SmsSignServiceImpl.java | 5 +++ .../serviceimpl/SmsTemplateServiceImpl.java | 3 +- .../store/serviceimpl/StoreServiceImpl.java | 4 ++ .../serviceimpl/LogisticsServiceImpl.java | 12 +++--- .../system/serviceimpl/RegionServiceImpl.java | 41 ++++++++----------- .../service/impl/VerificationServiceImpl.java | 2 +- .../serviceimpl/MemberWalletServiceImpl.java | 11 ++++- .../MemberWithdrawApplyServiceImpl.java | 6 ++- .../serviceimpl/RechargeServiceImpl.java | 10 ++--- .../serviceimpl/WalletLogServiceImpl.java | 8 ++-- 68 files changed, 285 insertions(+), 199 deletions(-) diff --git a/consumer/src/main/java/cn/lili/event/impl/StockUpdateExecute.java b/consumer/src/main/java/cn/lili/event/impl/StockUpdateExecute.java index eb8ed3d7..ab9f5d63 100644 --- a/consumer/src/main/java/cn/lili/event/impl/StockUpdateExecute.java +++ b/consumer/src/main/java/cn/lili/event/impl/StockUpdateExecute.java @@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.script.DefaultRedisScript; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; @@ -79,6 +80,7 @@ public class StockUpdateExecute implements OrderStatusChangeEvent { private PointsGoodsService pointsGoodsService; @Override + @Transactional(rollbackFor = Exception.class) public void orderChange(OrderMessage orderMessage) { switch (orderMessage.getNewStatus()) { diff --git a/framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java b/framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java index a71f8f79..f7a98a6b 100644 --- a/framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/connect/serviceimpl/ConnectServiceImpl.java @@ -1,5 +1,6 @@ package cn.lili.modules.connect.serviceimpl; +import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import cn.lili.cache.Cache; @@ -13,7 +14,6 @@ import cn.lili.common.security.context.UserContext; import cn.lili.common.security.token.Token; import cn.lili.common.utils.CookieUtil; import cn.lili.common.utils.HttpUtils; -import cn.lili.common.utils.StringUtils; import cn.lili.modules.connect.entity.Connect; import cn.lili.modules.connect.entity.dto.ConnectAuthUser; import cn.lili.modules.connect.entity.dto.WechatMPLoginParams; @@ -35,6 +35,7 @@ import lombok.extern.slf4j.Slf4j; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; @@ -55,6 +56,7 @@ import java.util.concurrent.TimeUnit; @Service public class ConnectServiceImpl extends ServiceImpl implements ConnectService { + static final boolean AUTO_REGION = true; @Autowired private SettingService settingService; @@ -65,10 +67,8 @@ public class ConnectServiceImpl extends ServiceImpl impl @Autowired private Cache cache; - static boolean AUTO_REGION = true; - - @Override + @Transactional(rollbackFor = Exception.class) public Token unionLoginCallback(String type, String unionid, String uuid, boolean longTerm) throws NoPermissionException { try { @@ -94,6 +94,7 @@ public class ConnectServiceImpl extends ServiceImpl impl } @Override + @Transactional(rollbackFor = Exception.class) public Token unionLoginCallback(String type, ConnectAuthUser authUser, String uuid) { Token token; @@ -126,6 +127,7 @@ public class ConnectServiceImpl extends ServiceImpl impl } @Override + @Transactional(rollbackFor = Exception.class) public void unbind(String type) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); @@ -142,13 +144,12 @@ public class ConnectServiceImpl extends ServiceImpl impl queryWrapper.eq(Connect::getUserId, UserContext.getCurrentUser().getId()); List connects = this.list(queryWrapper); List keys = new ArrayList<>(); - connects.forEach(item -> { - keys.add(item.getUnionType()); - }); + connects.forEach(item -> keys.add(item.getUnionType())); return keys; } @Override + @Transactional(rollbackFor = Exception.class) public Token appLoginCallback(ConnectAuthUser authUser, String uuid) { try { return this.unionLoginCallback(authUser.getSource(), authUser.getUuid(), uuid, true); @@ -209,6 +210,7 @@ public class ConnectServiceImpl extends ServiceImpl impl * @param unionId 微信unionid * @return */ + @Transactional(rollbackFor = Exception.class) public Token phoneMpBindAndLogin(String sessionKey, WechatMPLoginParams params, String openId, String unionId) { String encryptedData = params.getEncryptedData(), iv = params.getIv(); JSONObject userInfo = this.getUserInfo(encryptedData, sessionKey, iv); @@ -237,9 +239,9 @@ public class ConnectServiceImpl extends ServiceImpl impl public Connect queryConnect(ConnectQueryDTO connectQueryDTO) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(StringUtils.isNotEmpty(connectQueryDTO.getUserId()), Connect::getUserId, connectQueryDTO.getUserId()) - .eq(StringUtils.isNotEmpty(connectQueryDTO.getUnionType()), Connect::getUnionType, connectQueryDTO.getUnionType()) - .eq(StringUtils.isNotEmpty(connectQueryDTO.getUnionId()), Connect::getUnionId, connectQueryDTO.getUnionId()); + queryWrapper.eq(CharSequenceUtil.isNotEmpty(connectQueryDTO.getUserId()), Connect::getUserId, connectQueryDTO.getUserId()) + .eq(CharSequenceUtil.isNotEmpty(connectQueryDTO.getUnionType()), Connect::getUnionType, connectQueryDTO.getUnionType()) + .eq(CharSequenceUtil.isNotEmpty(connectQueryDTO.getUnionId()), Connect::getUnionId, connectQueryDTO.getUnionId()); return this.getOne(queryWrapper); } @@ -258,7 +260,7 @@ public class ConnectServiceImpl extends ServiceImpl impl //如果unionid 不为空 则为账号绑定unionid - if (StringUtils.isNotEmpty(unionId)) { + if (CharSequenceUtil.isNotEmpty(unionId)) { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper(); lambdaQueryWrapper.eq(Connect::getUnionId, unionId); lambdaQueryWrapper.eq(Connect::getUnionType, ConnectEnum.WECHAT.name()); @@ -271,12 +273,12 @@ public class ConnectServiceImpl extends ServiceImpl impl this.save(connect); } }//如果openid 不为空 则为账号绑定openid - if (StringUtils.isNotEmpty(openId)) { + if (CharSequenceUtil.isNotEmpty(openId)) { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper(); lambdaQueryWrapper.eq(Connect::getUnionId, openId); lambdaQueryWrapper.eq(Connect::getUnionType, ConnectEnum.WECHAT_MP_OPEN_ID.name()); List connects = this.list(lambdaQueryWrapper); - if (connects.size() == 0) { + if (connects.isEmpty()) { Connect connect = new Connect(); connect.setUnionId(openId); connect.setUserId(member.getId()); @@ -290,7 +292,7 @@ public class ConnectServiceImpl extends ServiceImpl impl /** * 获取微信小程序配置 * - * @return + * @return 微信小程序配置 */ private WechatConnectSettingItem getWechatMPSetting() { Setting setting = settingService.get(SettingEnum.WECHAT_CONNECT.name()); diff --git a/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionCashServiceImpl.java b/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionCashServiceImpl.java index 3e789ba1..805fc9db 100644 --- a/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionCashServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/distribution/serviceimpl/DistributionCashServiceImpl.java @@ -28,6 +28,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.Date; @@ -56,6 +57,7 @@ public class DistributionCashServiceImpl extends ServiceImpl implements Fi @Override public void batchDelete(List ids) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.in(File::getId, ids); List files = this.list(queryWrapper); @@ -48,7 +48,7 @@ public class FileServiceImpl extends ServiceImpl implements Fi @Override public void batchDelete(List ids, AuthUser authUser) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.in(File::getId, ids); queryWrapper.eq(File::getUserEnums, authUser.getRole().name()); @@ -75,26 +75,24 @@ public class FileServiceImpl extends ServiceImpl implements Fi @Override public IPage customerPage(File file, SearchVO searchVO, PageVO pageVo) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.like(StringUtils.isNotEmpty(file.getName()), File::getName, file.getName()) - .like(StringUtils.isNotEmpty(file.getFileKey()), File::getFileKey, file.getFileKey()) - .like(StringUtils.isNotEmpty(file.getFileType()), File::getFileType, file.getFileType()) - .between(StringUtils.isNotEmpty(searchVO.getStartDate()) && StringUtils.isNotEmpty(searchVO.getEndDate()), + queryWrapper.like(CharSequenceUtil.isNotEmpty(file.getName()), File::getName, file.getName()) + .like(CharSequenceUtil.isNotEmpty(file.getFileKey()), File::getFileKey, file.getFileKey()) + .like(CharSequenceUtil.isNotEmpty(file.getFileType()), File::getFileType, file.getFileType()) + .between(CharSequenceUtil.isNotEmpty(searchVO.getStartDate()) && CharSequenceUtil.isNotEmpty(searchVO.getEndDate()), File::getCreateTime, searchVO.getStartDate(), searchVO.getEndDate()); - IPage page = this.page(PageUtil.initPage(pageVo), queryWrapper); - return page; + return this.page(PageUtil.initPage(pageVo), queryWrapper); } @Override public IPage customerPageOwner(FileOwnerDTO ownerDTO, File file, SearchVO searchVO, PageVO pageVo) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(StringUtils.isNotEmpty(ownerDTO.getOwnerId()), File::getOwnerId, ownerDTO.getOwnerId()) + queryWrapper.eq(CharSequenceUtil.isNotEmpty(ownerDTO.getOwnerId()), File::getOwnerId, ownerDTO.getOwnerId()) .eq(File::getUserEnums, ownerDTO.getUserEnums()) - .like(StringUtils.isNotEmpty(file.getName()), File::getName, file.getName()) - .like(StringUtils.isNotEmpty(file.getFileKey()), File::getFileKey, file.getFileKey()) - .like(StringUtils.isNotEmpty(file.getFileType()), File::getFileType, file.getFileType()) - .between(StringUtils.isNotEmpty(searchVO.getStartDate()) && StringUtils.isNotEmpty(searchVO.getEndDate()), + .like(CharSequenceUtil.isNotEmpty(file.getName()), File::getName, file.getName()) + .like(CharSequenceUtil.isNotEmpty(file.getFileKey()), File::getFileKey, file.getFileKey()) + .like(CharSequenceUtil.isNotEmpty(file.getFileType()), File::getFileType, file.getFileType()) + .between(CharSequenceUtil.isNotEmpty(searchVO.getStartDate()) && CharSequenceUtil.isNotEmpty(searchVO.getEndDate()), File::getCreateTime, searchVO.getStartDate(), searchVO.getEndDate()); - IPage page = this.page(PageUtil.initPage(pageVo), queryWrapper); - return page; + return this.page(PageUtil.initPage(pageVo), queryWrapper); } } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/BrandServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/BrandServiceImpl.java index c802c817..c9b945e3 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/BrandServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/BrandServiceImpl.java @@ -109,7 +109,7 @@ public class BrandServiceImpl extends ServiceImpl implements /** * 校验绑定关系 * - * @param brandIds + * @param brandIds 品牌Ids */ private void checkBind(List brandIds) { //分了绑定关系查询 @@ -129,19 +129,11 @@ public class BrandServiceImpl extends ServiceImpl implements } } - /** - * 校验绑定关系 - * - * @param brandIds - */ - private void checkoutGoods(List brandIds) { - } - /** * 校验是否存在 * - * @param brandId - * @return + * @param brandId 品牌ID + * @return 品牌 */ private Brand checkExist(String brandId) { Brand brand = getById(brandId); diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryBrandServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryBrandServiceImpl.java index afdfec52..7374868f 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryBrandServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryBrandServiceImpl.java @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; @@ -37,6 +38,7 @@ public class CategoryBrandServiceImpl extends ServiceImpl brandIds) { //删除分类品牌绑定信息 this.deleteByCategoryId(categoryId); diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryParameterGroupServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryParameterGroupServiceImpl.java index d6c195c5..9d5ab172 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryParameterGroupServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CategoryParameterGroupServiceImpl.java @@ -3,7 +3,6 @@ package cn.lili.modules.goods.serviceimpl; import cn.hutool.json.JSONUtil; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; -import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.modules.goods.entity.dos.CategoryParameterGroup; import cn.lili.modules.goods.entity.dos.Goods; import cn.lili.modules.goods.entity.dos.Parameters; @@ -17,9 +16,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.HashMap; @@ -46,12 +45,6 @@ public class CategoryParameterGroupServiceImpl extends ServiceImpl getCategoryParams(String categoryId) { //根据id查询参数组 @@ -74,6 +67,7 @@ public class CategoryParameterGroupServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = Exception.class) public boolean saveCategory(Category category) { //判断分类佣金是否正确 if (category.getCommissionRate() < 0) { @@ -214,6 +216,7 @@ public class CategoryServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = Exception.class) public void updateCategory(Category category) { //判断分类佣金是否正确 if (category.getCommissionRate() < 0) { @@ -239,6 +242,7 @@ public class CategoryServiceImpl extends ServiceImpl i @Override + @Transactional(rollbackFor = Exception.class) public void delete(String id) { this.removeById(id); removeCache(); @@ -249,6 +253,7 @@ public class CategoryServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = Exception.class) public void updateCategoryStatus(String categoryId, Boolean enableOperations) { //禁用子分类 CategoryVO categoryVO = new CategoryVO(this.getById(categoryId)); @@ -302,34 +307,6 @@ public class CategoryServiceImpl extends ServiceImpl i } } - /** - * 拼装返回值 - * - * @param paramList 参数列表 - * @return 拼装后的返回值 - */ - private List convertParamList(List groupList, List paramList) { - Map> map = new HashMap<>(16); - for (GoodsParamsVO param : paramList) { - if (map.get(param.getGroupId()) != null) { - map.get(param.getGroupId()).add(param); - } else { - List list = new ArrayList<>(); - list.add(param); - map.put(param.getGroupId(), list); - } - } - List resList = new ArrayList<>(); - for (CategoryParameterGroup group : groupList) { - GoodsParamsGroupVO list = new GoodsParamsGroupVO(); - list.setGroupName(group.getGroupName()); - list.setGroupId(group.getId()); - list.setParams(map.get(group.getId())); - resList.add(list); - } - return resList; - } - /** * 获取所有的子分类ID * diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CommodityServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CommodityServiceImpl.java index 983c56b5..0beff15b 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CommodityServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/CommodityServiceImpl.java @@ -27,6 +27,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.List; import java.util.Objects; @@ -46,6 +47,7 @@ public class CommodityServiceImpl extends ServiceImpl commodityList) { String storeId = Objects.requireNonNull(UserContext.getCurrentUser()).getStoreId(); for (Commodity commodity : commodityList) { @@ -54,7 +56,7 @@ public class CommodityServiceImpl extends ServiceImpl goodsIdList = this.baseMapper.getAuditCommodity(); - if (goodsIdList.size() > 0) { + if (!goodsIdList.isEmpty()) { //同步状态 JSONObject json = wechatLivePlayerUtil.getGoodsWareHouse(goodsIdList); //修改状态 diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsGalleryServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsGalleryServiceImpl.java index 365e2a4d..5e4577d7 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsGalleryServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsGalleryServiceImpl.java @@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -35,6 +36,7 @@ public class GoodsGalleryServiceImpl extends ServiceImpl goodsGalleryList, String goodsId) { //删除原来商品相册信息 this.baseMapper.delete(new UpdateWrapper().eq("goods_id", goodsId)); diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java index 6a68590a..ee8fe200 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java @@ -121,6 +121,7 @@ public class GoodsServiceImpl extends ServiceImpl implements } @Override + @Transactional(rollbackFor = Exception.class) public void underStoreGoods(String storeId) { //获取商品ID列表 List list = this.baseMapper.getGoodsIdByStoreId(storeId); @@ -135,6 +136,7 @@ public class GoodsServiceImpl extends ServiceImpl implements * @param params 商品参数 */ @Override + @Transactional(rollbackFor = Exception.class) public void updateGoodsParams(String goodsId, String params) { LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); updateWrapper.eq(Goods::getId, goodsId); @@ -151,6 +153,7 @@ public class GoodsServiceImpl extends ServiceImpl implements } @Override + @Transactional(rollbackFor = Exception.class) public void addGoods(GoodsOperationDTO goodsOperationDTO) { Goods goods = new Goods(goodsOperationDTO); //检查商品 @@ -174,6 +177,7 @@ public class GoodsServiceImpl extends ServiceImpl implements @Override + @Transactional(rollbackFor = Exception.class) public void editGoods(GoodsOperationDTO goodsOperationDTO, String goodsId) { Goods goods = new Goods(goodsOperationDTO); goods.setId(goodsId); @@ -264,6 +268,7 @@ public class GoodsServiceImpl extends ServiceImpl implements } @Override + @Transactional(rollbackFor = Exception.class) public boolean auditGoods(List goodsIds, GoodsAuthEnum goodsAuthEnum) { boolean result = false; for (String goodsId : goodsIds) { @@ -282,6 +287,7 @@ public class GoodsServiceImpl extends ServiceImpl implements } @Override + @Transactional(rollbackFor = Exception.class) public Boolean updateGoodsMarketAble(List goodsIds, GoodsStatusEnum goodsStatusEnum, String underReason) { boolean result; @@ -311,6 +317,7 @@ public class GoodsServiceImpl extends ServiceImpl implements } @Override + @Transactional(rollbackFor = Exception.class) public Boolean managerUpdateGoodsMarketAble(List goodsIds, GoodsStatusEnum goodsStatusEnum, String underReason) { boolean result; @@ -342,6 +349,7 @@ public class GoodsServiceImpl extends ServiceImpl implements } @Override + @Transactional(rollbackFor = Exception.class) public Boolean deleteGoods(List goodsIds) { LambdaUpdateWrapper updateWrapper = this.getUpdateWrapperByStoreAuthority(); @@ -365,6 +373,7 @@ public class GoodsServiceImpl extends ServiceImpl implements } @Override + @Transactional(rollbackFor = Exception.class) public Boolean freight(List goodsIds, String templateId) { AuthUser authUser = this.checkStoreAuthority(); @@ -383,7 +392,6 @@ public class GoodsServiceImpl extends ServiceImpl implements } @Override - @Transactional(rollbackFor = Exception.class) public void updateStock(String goodsId, Integer quantity) { LambdaUpdateWrapper lambdaUpdateWrapper = Wrappers.lambdaUpdate(); lambdaUpdateWrapper.set(Goods::getQuantity, quantity); @@ -425,6 +433,7 @@ public class GoodsServiceImpl extends ServiceImpl implements } @Override + @Transactional(rollbackFor = Exception.class) public void updateStoreDetail(Store store) { UpdateWrapper updateWrapper = new UpdateWrapper<>() .eq("store_id", store.getId()) diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java index 8bc803b4..f7a5932f 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java @@ -188,6 +188,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i * @param goodsSku sku信息 */ @Override + @Transactional(rollbackFor = Exception.class) public void update(GoodsSku goodsSku) { this.updateById(goodsSku); cache.remove(GoodsSkuService.getCacheKeys(goodsSku.getId())); @@ -434,6 +435,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = Exception.class) public void updateStocks(List goodsSkuStockDTOS) { for (GoodsSkuStockDTO goodsSkuStockDTO : goodsSkuStockDTOS) { this.updateStock(goodsSkuStockDTO.getSkuId(), goodsSkuStockDTO.getQuantity()); @@ -441,6 +443,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = Exception.class) public void updateStock(String skuId, Integer quantity) { GoodsSku goodsSku = getGoodsSkuByIdFromCache(skuId); if (goodsSku != null) { @@ -476,6 +479,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = Exception.class) public void updateGoodsStuck(List goodsSkus) { //商品id集合 hashset 去重复 Set goodsIds = new HashSet<>(); @@ -504,6 +508,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = Exception.class) public void updateGoodsSkuCommentNum(String skuId) { //获取商品信息 GoodsSku goodsSku = this.getGoodsSkuByIdFromCache(skuId); @@ -584,7 +589,6 @@ public class GoodsSkuServiceImpl extends ServiceImpl i * @param skuList sku列表 * @param goods 商品信息 */ - @Transactional(rollbackFor = Exception.class) List addGoodsSku(List> skuList, Goods goods) { List skus = new ArrayList<>(); for (Map skuVO : skuList) { diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/ParametersServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/ParametersServiceImpl.java index 4aaa0ea6..13fa9704 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/ParametersServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/ParametersServiceImpl.java @@ -19,6 +19,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; @@ -51,6 +52,7 @@ public class ParametersServiceImpl extends ServiceImpl ids) { + boolean result = false; for (String id : ids) { //如果此规格绑定分类则不允许删除 List list = categorySpecificationService.list(new QueryWrapper().eq("specification_id", id)); if (!list.isEmpty()) { List categoryIds = new ArrayList<>(); - list.forEach(item -> { - categoryIds.add(item.getCategoryId()); - }); + list.forEach(item -> categoryIds.add(item.getCategoryId())); throw new ServiceException(ResultCode.SPEC_DELETE_ERROR, JSONUtil.toJsonStr(categoryService.getCategoryNameByIds(categoryIds))); } //删除规格 - this.removeById(id); + result = this.removeById(id); } - return true; + return result; } } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StoreGoodsLabelServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StoreGoodsLabelServiceImpl.java index 4ae5dfac..99801a9d 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StoreGoodsLabelServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/StoreGoodsLabelServiceImpl.java @@ -17,6 +17,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Comparator; @@ -82,6 +83,7 @@ public class StoreGoodsLabelServiceImpl extends ServiceImpl impleme private GoodsService goodsService; @Override + @Transactional(rollbackFor = Exception.class) public Boolean create(Studio studio) { studio.setStoreId(Objects.requireNonNull(UserContext.getCurrentUser()).getStoreId()); //创建小程序直播 @@ -97,6 +99,7 @@ public class StudioServiceImpl extends ServiceImpl impleme } @Override + @Transactional(rollbackFor = Exception.class) public Boolean edit(Studio studio) { Studio oldStudio = this.getById(studio.getId()); wechatLivePlayerUtil.editRoom(studio); @@ -153,6 +156,7 @@ public class StudioServiceImpl extends ServiceImpl impleme } @Override + @Transactional(rollbackFor = Exception.class) public Boolean push(Integer roomId, Integer goodsId, String storeId) { //判断直播间是否已添加商品 @@ -183,6 +187,7 @@ public class StudioServiceImpl extends ServiceImpl impleme } @Override + @Transactional(rollbackFor = Exception.class) public Boolean goodsDeleteInRoom(Integer roomId, Integer goodsId, String storeId) { Goods goods = goodsService.getOne(new LambdaQueryWrapper().eq(Goods::getId, goodsId).eq(Goods::getStoreId, storeId)); if (goods == null) { diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/FootprintServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/FootprintServiceImpl.java index 8c1181fa..0fea8a25 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/FootprintServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/FootprintServiceImpl.java @@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.Collections; import java.util.Date; @@ -35,6 +36,7 @@ public class FootprintServiceImpl extends ServiceImpl queryWrapper = Wrappers.lambdaQuery(); queryWrapper.eq(FootPrint::getMemberId, footPrint.getMemberId()); @@ -68,8 +70,7 @@ public class FootprintServiceImpl extends ServiceImpl lambdaQueryWrapper = Wrappers.lambdaQuery(); lambdaQueryWrapper.eq(FootPrint::getMemberId, UserContext.getCurrentUser().getId()); lambdaQueryWrapper.in(FootPrint::getGoodsId, ids); - this.remove(lambdaQueryWrapper); - return true; + return this.remove(lambdaQueryWrapper); } @Override diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberAddressServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberAddressServiceImpl.java index d46d1118..a05ff296 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberAddressServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberAddressServiceImpl.java @@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.Objects; @@ -54,6 +55,7 @@ public class MemberAddressServiceImpl extends ServiceImpl updateWrapper = Wrappers.update(); updateWrapper.set("reply_status", true); updateWrapper.set("reply", reply); - if (StringUtils.isNotEmpty(replyImage)) { + if (CharSequenceUtil.isNotEmpty(replyImage)) { updateWrapper.set("have_reply_image", true); updateWrapper.set("reply_image", replyImage); } diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberNoticeSenterServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberNoticeSenterServiceImpl.java index 934a5495..1bccca56 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberNoticeSenterServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberNoticeSenterServiceImpl.java @@ -1,8 +1,8 @@ package cn.lili.modules.member.serviceimpl; +import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; -import cn.lili.common.utils.StringUtils; import cn.lili.modules.member.entity.dos.Member; import cn.lili.modules.member.entity.dos.MemberNotice; import cn.lili.modules.member.entity.dos.MemberNoticeSenter; @@ -42,6 +42,7 @@ public class MemberNoticeSenterServiceImpl extends ServiceImpl 0) { + if (!memberNotices.isEmpty()) { //批量保存 if (memberNoticeService.saveBatch(memberNotices)) { return true; diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberPointsHistoryServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberPointsHistoryServiceImpl.java index f1557ca6..70c40c38 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberPointsHistoryServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberPointsHistoryServiceImpl.java @@ -2,7 +2,6 @@ package cn.lili.modules.member.serviceimpl; import cn.hutool.core.text.CharSequenceUtil; -import cn.lili.common.utils.StringUtils; import cn.lili.common.vo.PageVO; import cn.lili.modules.member.entity.dos.Member; import cn.lili.modules.member.entity.dos.MemberPointsHistory; @@ -49,7 +48,7 @@ public class MemberPointsHistoryServiceImpl extends ServiceImpl receipts = this.baseMapper.selectList(new QueryWrapper() .eq("member_id", memberId) .eq("receipt_title", memberReceiptAddVO.getReceiptTitle()) ); - if (receipts.size() > 0) { + if (!receipts.isEmpty()) { throw new ServiceException(ResultCode.USER_RECEIPT_REPEAT_ERROR); } //参数封装 @@ -60,7 +62,7 @@ public class MemberReceiptServiceImpl extends ServiceImpl list = this.baseMapper.selectList(new QueryWrapper().eq("member_id", memberId)); //如果当前会员只有一个发票则默认为默认发票,反之需要校验参数默认值,做一些处理 - if (list.size() <= 0) { + if (list.isEmpty()) { memberReceipt.setIsDefault(1); } else { if (memberReceiptAddVO.getIsDefault().equals(1)) { @@ -78,6 +80,7 @@ public class MemberReceiptServiceImpl extends ServiceImpl 0) { + if (!receipts.isEmpty()) { throw new ServiceException(ResultCode.USER_RECEIPT_REPEAT_ERROR); } BeanUtil.copyProperties(memberReceiptAddVO, memberReceiptDb); diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java index 52bd1052..e0fef231 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/MemberServiceImpl.java @@ -50,6 +50,7 @@ import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.Date; import java.util.List; @@ -380,6 +381,7 @@ public class MemberServiceImpl extends ServiceImpl impleme @Override @PointLogPoint + @Transactional(rollbackFor = Exception.class) public Boolean updateMemberPoint(Long point, String type, String memberId, String content) { //获取当前会员信息 Member member = this.getById(memberId); diff --git a/framework/src/main/java/cn/lili/modules/member/serviceimpl/StoreCollectionServiceImpl.java b/framework/src/main/java/cn/lili/modules/member/serviceimpl/StoreCollectionServiceImpl.java index bfd798f2..6772fb93 100644 --- a/framework/src/main/java/cn/lili/modules/member/serviceimpl/StoreCollectionServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/member/serviceimpl/StoreCollectionServiceImpl.java @@ -17,6 +17,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.Optional; @@ -50,6 +51,7 @@ public class StoreCollectionServiceImpl extends ServiceImpl() .eq(StoreCollection::getMemberId, UserContext.getCurrentUser().getId()) @@ -63,6 +65,7 @@ public class StoreCollectionServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper(); queryWrapper.eq("member_id", UserContext.getCurrentUser().getId()); diff --git a/framework/src/main/java/cn/lili/modules/message/serviceimpl/MessageServiceImpl.java b/framework/src/main/java/cn/lili/modules/message/serviceimpl/MessageServiceImpl.java index 6344f564..0f057d1a 100644 --- a/framework/src/main/java/cn/lili/modules/message/serviceimpl/MessageServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/message/serviceimpl/MessageServiceImpl.java @@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; /** * 管理端发送消息内容业务层实现 @@ -37,6 +38,7 @@ public class MessageServiceImpl extends ServiceImpl impl @Override + @Transactional(rollbackFor = Exception.class) public Boolean sendMessage(Message message) { //保存站内信信息 this.save(message); diff --git a/framework/src/main/java/cn/lili/modules/message/serviceimpl/NoticeMessageServiceImpl.java b/framework/src/main/java/cn/lili/modules/message/serviceimpl/NoticeMessageServiceImpl.java index 8bc64782..e177cb6a 100644 --- a/framework/src/main/java/cn/lili/modules/message/serviceimpl/NoticeMessageServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/message/serviceimpl/NoticeMessageServiceImpl.java @@ -1,8 +1,7 @@ package cn.lili.modules.message.serviceimpl; +import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.enums.SwitchEnum; -import cn.lili.mybatis.util.PageUtil; -import cn.lili.common.utils.StringUtils; import cn.lili.common.vo.PageVO; import cn.lili.modules.message.entity.dos.MemberMessage; import cn.lili.modules.message.entity.dos.NoticeMessage; @@ -12,6 +11,7 @@ import cn.lili.modules.message.entity.enums.NoticeMessageParameterEnum; import cn.lili.modules.message.mapper.NoticeMessageTemplateMapper; import cn.lili.modules.message.service.MemberMessageService; import cn.lili.modules.message.service.NoticeMessageService; +import cn.lili.mybatis.util.PageUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -38,7 +38,7 @@ public class NoticeMessageServiceImpl extends ServiceImpl messageTemplateQueryWrapper = new QueryWrapper<>(); //消息模板类型 - messageTemplateQueryWrapper.eq(!StringUtils.isEmpty(type), "type", type); + messageTemplateQueryWrapper.eq(!CharSequenceUtil.isEmpty(type), "type", type); messageTemplateQueryWrapper.orderByDesc("create_time"); //查询数据返回 return this.page(PageUtil.initPage(pageVO), messageTemplateQueryWrapper); @@ -85,10 +85,10 @@ public class NoticeMessageServiceImpl extends ServiceImpl parameter) { - for (String key : parameter.keySet()) { - String description = NoticeMessageParameterEnum.getValueByType(key); - if (description != null && parameter.get(key) != null) { - noticeContent = noticeContent.replace("#{" + description + "}".trim(), parameter.get(key)); + for (Map.Entry entry : parameter.entrySet()) { + String description = NoticeMessageParameterEnum.getValueByType(entry.getKey()); + if (description != null && entry.getValue() != null) { + noticeContent = noticeContent.replace("#{" + description + "}".trim(), entry.getValue()); } } return noticeContent; diff --git a/framework/src/main/java/cn/lili/modules/message/serviceimpl/StoreMessageServiceImpl.java b/framework/src/main/java/cn/lili/modules/message/serviceimpl/StoreMessageServiceImpl.java index 1202b4d2..104685e7 100644 --- a/framework/src/main/java/cn/lili/modules/message/serviceimpl/StoreMessageServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/message/serviceimpl/StoreMessageServiceImpl.java @@ -1,15 +1,15 @@ package cn.lili.modules.message.serviceimpl; +import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.enums.ResultCode; import cn.lili.common.security.context.UserContext; -import cn.lili.mybatis.util.PageUtil; -import cn.lili.common.utils.StringUtils; import cn.lili.common.vo.PageVO; import cn.lili.modules.message.entity.dos.StoreMessage; import cn.lili.modules.message.entity.vos.StoreMessageQueryVO; import cn.lili.modules.message.mapper.StoreMessageMapper; import cn.lili.modules.message.service.StoreMessageService; +import cn.lili.mybatis.util.PageUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -42,11 +42,11 @@ public class StoreMessageServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); //消息id查询 - if (StringUtils.isNotEmpty(storeMessageQueryVO.getMessageId())) { + if (CharSequenceUtil.isNotEmpty(storeMessageQueryVO.getMessageId())) { queryWrapper.eq("message_id", storeMessageQueryVO.getMessageId()); } //商家id - if (StringUtils.isNotEmpty(storeMessageQueryVO.getStoreId())) { + if (CharSequenceUtil.isNotEmpty(storeMessageQueryVO.getStoreId())) { queryWrapper.eq("store_id", storeMessageQueryVO.getStoreId()); } //状态查询 diff --git a/framework/src/main/java/cn/lili/modules/order/aftersale/serviceimpl/AfterSaleServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/aftersale/serviceimpl/AfterSaleServiceImpl.java index 8772c14c..d86fee45 100644 --- a/framework/src/main/java/cn/lili/modules/order/aftersale/serviceimpl/AfterSaleServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/aftersale/serviceimpl/AfterSaleServiceImpl.java @@ -51,6 +51,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.Date; import java.util.List; @@ -167,6 +168,7 @@ public class AfterSaleServiceImpl extends ServiceImpl cartSkuVOS = tradeDTO.getSkuList(); @@ -496,6 +498,7 @@ public class CartServiceImpl implements CartService { } @Override + @Transactional(rollbackFor = Exception.class) public void selectCoupon(String couponId, String way, boolean use) { AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser()); //获取购物车,然后重新写入优惠券 diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderComplaintServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderComplaintServiceImpl.java index 405c712a..bc5ebcaf 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderComplaintServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderComplaintServiceImpl.java @@ -32,6 +32,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.Date; import java.util.List; @@ -118,6 +119,7 @@ public class OrderComplaintServiceImpl extends ServiceImpl implements @Override @OrderLogPoint(description = "'订单['+#orderSn+']取消,原因为:'+#reason", orderSn = "#orderSn") + @Transactional(rollbackFor = Exception.class) public Order cancel(String orderSn, String reason) { Order order = OperationalJudgment.judgment(this.getBySn(orderSn)); //如果订单促销类型不为空&&订单是拼团订单,并且订单未成团,则抛出异常 @@ -307,6 +307,7 @@ public class OrderServiceImpl extends ServiceImpl implements @Override @OrderLogPoint(description = "'订单['+#orderSn+']系统取消,原因为:'+#reason", orderSn = "#orderSn") + @Transactional(rollbackFor = Exception.class) public void systemCancel(String orderSn, String reason) { Order order = this.getBySn(orderSn); order.setOrderStatus(OrderStatusEnum.CANCELLED.name()); @@ -327,6 +328,7 @@ public class OrderServiceImpl extends ServiceImpl implements } @Override + @Transactional(rollbackFor = Exception.class) public void payOrder(String orderSn, String paymentMethod, String receivableNo) { Order order = this.getBySn(orderSn); @@ -362,6 +364,7 @@ public class OrderServiceImpl extends ServiceImpl implements @Override @OrderLogPoint(description = "'库存确认'", orderSn = "#orderSn") + @Transactional(rollbackFor = Exception.class) public void afterOrderConfirm(String orderSn) { Order order = this.getBySn(orderSn); //判断是否为拼团订单,进行特殊处理 @@ -382,6 +385,7 @@ public class OrderServiceImpl extends ServiceImpl implements @Override @SystemLogPoint(description = "修改订单", customerLog = "'订单[' + #orderSn + ']收货信息修改,修改为'+#memberAddressDTO.consigneeDetail+'") + @Transactional(rollbackFor = Exception.class) public Order updateConsignee(String orderSn, MemberAddressDTO memberAddressDTO) { Order order = OperationalJudgment.judgment(this.getBySn(orderSn)); @@ -399,6 +403,7 @@ public class OrderServiceImpl extends ServiceImpl implements @Override @OrderLogPoint(description = "'订单['+#orderSn+']发货,发货单号['+#logisticsNo+']'", orderSn = "#orderSn") + @Transactional(rollbackFor = Exception.class) public Order delivery(String orderSn, String logisticsNo, String logisticsId) { Order order = OperationalJudgment.judgment(this.getBySn(orderSn)); //如果订单未发货,并且订单状态值等于待发货 @@ -465,6 +470,7 @@ public class OrderServiceImpl extends ServiceImpl implements @Override @OrderLogPoint(description = "'订单['+#orderSn+']完成'", orderSn = "#orderSn") + @Transactional(rollbackFor = Exception.class) public void complete(String orderSn) { //是否可以查询到订单 Order order = OperationalJudgment.judgment(this.getBySn(orderSn)); @@ -473,6 +479,7 @@ public class OrderServiceImpl extends ServiceImpl implements @Override @OrderLogPoint(description = "'订单['+#orderSn+']完成'", orderSn = "#orderSn") + @Transactional(rollbackFor = Exception.class) public void systemComplete(String orderSn) { Order order = this.getBySn(orderSn); complete(order, orderSn); @@ -530,6 +537,7 @@ public class OrderServiceImpl extends ServiceImpl implements } @Override + @Transactional(rollbackFor = Exception.class) public void deleteOrder(String sn) { Order order = this.getBySn(sn); if (order == null) { @@ -563,6 +571,7 @@ public class OrderServiceImpl extends ServiceImpl implements * @param parentOrderSn 拼团订单sn */ @Override + @Transactional(rollbackFor = Exception.class) public void agglomeratePintuanOrder(String pintuanId, String parentOrderSn) { //获取拼团配置 Pintuan pintuan = pintuanService.getById(pintuanId); @@ -610,7 +619,7 @@ public class OrderServiceImpl extends ServiceImpl implements @Override public void batchDeliver(MultipartFile files) { - InputStream inputStream = null; + InputStream inputStream; List orderBatchDeliverDTOList = new ArrayList<>(); try { inputStream = files.getInputStream(); @@ -643,7 +652,7 @@ public class OrderServiceImpl extends ServiceImpl implements Order order = this.getBySn(orderSn); Trade trade = tradeService.getBySn(order.getTradeSn()); //如果交易不为空,则返回交易的金额,否则返回订单金额 - if (StringUtils.isNotEmpty(trade.getPayStatus()) + if (CharSequenceUtil.isNotEmpty(trade.getPayStatus()) && trade.getPayStatus().equals(PayStatusEnum.PAID.name())) { return trade.getFlowPrice(); } @@ -679,7 +688,7 @@ public class OrderServiceImpl extends ServiceImpl implements orderBatchDeliverDTO.setLogisticsId(item.getId()); } }); - if (StringUtils.isEmpty(orderBatchDeliverDTO.getLogisticsId())) { + if (CharSequenceUtil.isEmpty(orderBatchDeliverDTO.getLogisticsId())) { throw new ServiceException("物流公司:'" + orderBatchDeliverDTO.getLogisticsName() + " '不存在"); } } diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java index 844af67b..6df5053f 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java @@ -1,9 +1,9 @@ package cn.lili.modules.order.order.serviceimpl; +import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.utils.BeanUtil; import cn.lili.common.utils.CurrencyUtil; import cn.lili.common.utils.SnowFlake; -import cn.lili.common.utils.StringUtils; import cn.lili.common.vo.PageVO; import cn.lili.modules.order.aftersale.entity.dos.AfterSale; import cn.lili.modules.order.order.entity.dos.Order; @@ -103,7 +103,7 @@ public class StoreFlowServiceImpl extends ServiceImpl implements TradeService { /** * 缓存 */ @Autowired private Cache cache; /** * 订单 */ @Autowired private OrderService orderService; /** * 会员 */ @Autowired private MemberService memberService; /** * 优惠券 */ @Autowired private CouponService couponService; /** * 会员优惠券 */ @Autowired private MemberCouponService memberCouponService; /** * 砍价 */ @Autowired private KanjiaActivityService kanjiaActivityService; /** * RocketMQ */ @Autowired private RocketMQTemplate rocketMQTemplate; /** * RocketMQ 配置 */ @Autowired private RocketmqCustomProperties rocketmqCustomProperties; @Override @Transactional(rollbackFor = Exception.class) public Trade createTrade(TradeDTO tradeDTO) { //创建订单预校验 createTradeCheck(tradeDTO); Trade trade = new Trade(tradeDTO); String key = CachePrefix.TRADE.getPrefix() + trade.getSn(); //优惠券预处理 couponPretreatment(tradeDTO); //积分预处理 pointPretreatment(tradeDTO); //添加交易 this.save(trade); //添加订单 orderService.intoDB(tradeDTO); //砍价订单处理 kanjiaPretreatment(tradeDTO); //写入缓存,给消费者调用 cache.put(key, JSONUtil.toJsonStr(tradeDTO)); //构建订单创建消息 String destination = rocketmqCustomProperties.getOrderTopic() + ":" + OrderTagsEnum.ORDER_CREATE.name(); //发送订单创建消息 rocketMQTemplate.asyncSend(destination, key, RocketmqSendCallbackBuilder.commonCallback()); return trade; } /** * 创建订单最后一步校验 * * @param tradeDTO 购物车视图 */ private void createTradeCheck(TradeDTO tradeDTO) { //创建订单如果没有收获地址, MemberAddress memberAddress = tradeDTO.getMemberAddress(); if (memberAddress == null) { throw new ServiceException(ResultCode.MEMBER_ADDRESS_NOT_EXIST); } //订单配送区域校验 if (tradeDTO.getNotSupportFreight() != null && !tradeDTO.getNotSupportFreight().isEmpty()) { StringBuilder stringBuilder = new StringBuilder("包含商品有-"); tradeDTO.getNotSupportFreight().forEach(sku -> stringBuilder.append(sku.getGoodsSku().getGoodsName())); throw new ServiceException(ResultCode.ORDER_NOT_SUPPORT_DISTRIBUTION, stringBuilder.toString()); } } @Override public Trade getBySn(String sn) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(Trade::getSn, sn); return this.getOne(queryWrapper); } @Override public void payTrade(String tradeSn, String paymentName, String receivableNo) { LambdaQueryWrapper orderQueryWrapper = new LambdaQueryWrapper<>(); orderQueryWrapper.eq(Order::getTradeSn, tradeSn); List orders = orderService.list(orderQueryWrapper); for (Order order : orders) { orderService.payOrder(order.getSn(), paymentName, receivableNo); } Trade trade = this.getBySn(tradeSn); trade.setPayStatus(PayStatusEnum.PAID.name()); this.saveOrUpdate(trade); } /** * 优惠券预处理 * 下单同时,扣除优惠券 * * @param tradeDTO 购物车视图 */ private void couponPretreatment(TradeDTO tradeDTO) { List memberCouponDTOList = new ArrayList<>(); if (null != tradeDTO.getPlatformCoupon()) { memberCouponDTOList.add(tradeDTO.getPlatformCoupon()); } Collection storeCoupons = tradeDTO.getStoreCoupons().values(); if (!storeCoupons.isEmpty()) { memberCouponDTOList.addAll(storeCoupons); } List ids = memberCouponDTOList.stream().map(e -> e.getMemberCoupon().getId()).collect(Collectors.toList()); memberCouponService.used(tradeDTO.getMemberId(), ids); memberCouponDTOList.forEach(e -> couponService.usedCoupon(e.getMemberCoupon().getCouponId(), 1)); } /** * 创建交易,积分处理 * * @param tradeDTO 购物车视图 */ private void pointPretreatment(TradeDTO tradeDTO) { //需要支付积分 if (tradeDTO.getPriceDetailDTO() != null && tradeDTO.getPriceDetailDTO().getPayPoint() != null && tradeDTO.getPriceDetailDTO().getPayPoint() > 0) { StringBuilder orderSns = new StringBuilder(); for (CartVO item : tradeDTO.getCartList()) { orderSns.append(item.getSn()); } boolean result = memberService.updateMemberPoint(tradeDTO.getPriceDetailDTO().getPayPoint(), PointTypeEnum.REDUCE.name(), tradeDTO.getMemberId(), "订单【" + orderSns + "】创建,积分扣减"); if (!result) { throw new ServiceException(ResultCode.PAY_POINT_ENOUGH); } } } /** * 创建交易、砍价处理 * * @param tradeDTO 购物车视图 */ private void kanjiaPretreatment(TradeDTO tradeDTO) { if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.KANJIA)) { String kanjiaId = tradeDTO.getSkuList().get(0).getKanjiaId(); kanjiaActivityService.endKanjiaActivity(kanjiaId); } } } \ No newline at end of file +package cn.lili.modules.order.order.serviceimpl; import cn.hutool.json.JSONUtil; import cn.lili.cache.Cache; import cn.lili.cache.CachePrefix; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; import cn.lili.common.properties.RocketmqCustomProperties; import cn.lili.modules.member.entity.dos.MemberAddress; import cn.lili.modules.member.entity.enums.PointTypeEnum; import cn.lili.modules.member.service.MemberService; import cn.lili.modules.order.cart.entity.dto.MemberCouponDTO; import cn.lili.modules.order.cart.entity.dto.TradeDTO; import cn.lili.modules.order.cart.entity.enums.CartTypeEnum; import cn.lili.modules.order.cart.entity.vo.CartVO; import cn.lili.modules.order.order.entity.dos.Order; import cn.lili.modules.order.order.entity.dos.Trade; import cn.lili.modules.order.order.entity.enums.PayStatusEnum; import cn.lili.modules.order.order.mapper.TradeMapper; import cn.lili.modules.order.order.service.OrderService; import cn.lili.modules.order.order.service.TradeService; import cn.lili.modules.promotion.service.CouponService; import cn.lili.modules.promotion.service.KanjiaActivityService; import cn.lili.modules.promotion.service.MemberCouponService; import cn.lili.rocketmq.RocketmqSendCallbackBuilder; import cn.lili.rocketmq.tags.OrderTagsEnum; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; /** * 交易业务层实现 * * @author Chopper * @since 2020/11/17 7:39 下午 */ @Service public class TradeServiceImpl extends ServiceImpl implements TradeService { /** * 缓存 */ @Autowired private Cache cache; /** * 订单 */ @Autowired private OrderService orderService; /** * 会员 */ @Autowired private MemberService memberService; /** * 优惠券 */ @Autowired private CouponService couponService; /** * 会员优惠券 */ @Autowired private MemberCouponService memberCouponService; /** * 砍价 */ @Autowired private KanjiaActivityService kanjiaActivityService; /** * RocketMQ */ @Autowired private RocketMQTemplate rocketMQTemplate; /** * RocketMQ 配置 */ @Autowired private RocketmqCustomProperties rocketmqCustomProperties; @Override @Transactional(rollbackFor = Exception.class) public Trade createTrade(TradeDTO tradeDTO) { //创建订单预校验 createTradeCheck(tradeDTO); Trade trade = new Trade(tradeDTO); String key = CachePrefix.TRADE.getPrefix() + trade.getSn(); //优惠券预处理 couponPretreatment(tradeDTO); //积分预处理 pointPretreatment(tradeDTO); //添加交易 this.save(trade); //添加订单 orderService.intoDB(tradeDTO); //砍价订单处理 kanjiaPretreatment(tradeDTO); //写入缓存,给消费者调用 cache.put(key, JSONUtil.toJsonStr(tradeDTO)); //构建订单创建消息 String destination = rocketmqCustomProperties.getOrderTopic() + ":" + OrderTagsEnum.ORDER_CREATE.name(); //发送订单创建消息 rocketMQTemplate.asyncSend(destination, key, RocketmqSendCallbackBuilder.commonCallback()); return trade; } /** * 创建订单最后一步校验 * * @param tradeDTO 购物车视图 */ private void createTradeCheck(TradeDTO tradeDTO) { //创建订单如果没有收获地址, MemberAddress memberAddress = tradeDTO.getMemberAddress(); if (memberAddress == null) { throw new ServiceException(ResultCode.MEMBER_ADDRESS_NOT_EXIST); } //订单配送区域校验 if (tradeDTO.getNotSupportFreight() != null && !tradeDTO.getNotSupportFreight().isEmpty()) { StringBuilder stringBuilder = new StringBuilder("包含商品有-"); tradeDTO.getNotSupportFreight().forEach(sku -> stringBuilder.append(sku.getGoodsSku().getGoodsName())); throw new ServiceException(ResultCode.ORDER_NOT_SUPPORT_DISTRIBUTION, stringBuilder.toString()); } } @Override public Trade getBySn(String sn) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(Trade::getSn, sn); return this.getOne(queryWrapper); } @Override @Transactional(rollbackFor = Exception.class) public void payTrade(String tradeSn, String paymentName, String receivableNo) { LambdaQueryWrapper orderQueryWrapper = new LambdaQueryWrapper<>(); orderQueryWrapper.eq(Order::getTradeSn, tradeSn); List orders = orderService.list(orderQueryWrapper); for (Order order : orders) { orderService.payOrder(order.getSn(), paymentName, receivableNo); } Trade trade = this.getBySn(tradeSn); trade.setPayStatus(PayStatusEnum.PAID.name()); this.saveOrUpdate(trade); } /** * 优惠券预处理 * 下单同时,扣除优惠券 * * @param tradeDTO 购物车视图 */ private void couponPretreatment(TradeDTO tradeDTO) { List memberCouponDTOList = new ArrayList<>(); if (null != tradeDTO.getPlatformCoupon()) { memberCouponDTOList.add(tradeDTO.getPlatformCoupon()); } Collection storeCoupons = tradeDTO.getStoreCoupons().values(); if (!storeCoupons.isEmpty()) { memberCouponDTOList.addAll(storeCoupons); } List ids = memberCouponDTOList.stream().map(e -> e.getMemberCoupon().getId()).collect(Collectors.toList()); memberCouponService.used(tradeDTO.getMemberId(), ids); memberCouponDTOList.forEach(e -> couponService.usedCoupon(e.getMemberCoupon().getCouponId(), 1)); } /** * 创建交易,积分处理 * * @param tradeDTO 购物车视图 */ private void pointPretreatment(TradeDTO tradeDTO) { //需要支付积分 if (tradeDTO.getPriceDetailDTO() != null && tradeDTO.getPriceDetailDTO().getPayPoint() != null && tradeDTO.getPriceDetailDTO().getPayPoint() > 0) { StringBuilder orderSns = new StringBuilder(); for (CartVO item : tradeDTO.getCartList()) { orderSns.append(item.getSn()); } boolean result = memberService.updateMemberPoint(tradeDTO.getPriceDetailDTO().getPayPoint(), PointTypeEnum.REDUCE.name(), tradeDTO.getMemberId(), "订单【" + orderSns + "】创建,积分扣减"); if (!result) { throw new ServiceException(ResultCode.PAY_POINT_ENOUGH); } } } /** * 创建交易、砍价处理 * * @param tradeDTO 购物车视图 */ private void kanjiaPretreatment(TradeDTO tradeDTO) { if (tradeDTO.getCartTypeEnum().equals(CartTypeEnum.KANJIA)) { String kanjiaId = tradeDTO.getSkuList().get(0).getKanjiaId(); kanjiaActivityService.endKanjiaActivity(kanjiaId); } } } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/page/serviceimpl/ArticleCategoryServiceImpl.java b/framework/src/main/java/cn/lili/modules/page/serviceimpl/ArticleCategoryServiceImpl.java index 0aecef3c..199f73b5 100644 --- a/framework/src/main/java/cn/lili/modules/page/serviceimpl/ArticleCategoryServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/page/serviceimpl/ArticleCategoryServiceImpl.java @@ -16,6 +16,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Comparator; @@ -50,6 +51,7 @@ public class ArticleCategoryServiceImpl extends ServiceImpl impl public IPage articlePage(ArticleSearchParams articleSearchParams) { articleSearchParams.setSort("a.sort"); QueryWrapper queryWrapper = articleSearchParams.queryWrapper(); - queryWrapper.eq("open_status",true); + queryWrapper.eq("open_status", true); return this.baseMapper.getArticleList(PageUtil.initPage(articleSearchParams), queryWrapper); } @@ -65,9 +65,9 @@ public class ArticleServiceImpl extends ServiceImpl impl @Override public void customRemove(String id) { //判断是否为默认文章 - if(this.getById(id).getType().equals(ArticleEnum.OTHER.name())){ + if (this.getById(id).getType().equals(ArticleEnum.OTHER.name())) { this.removeById(id); - }else{ + } else { throw new ServiceException(ResultCode.ARTICLE_NO_DELETION); } } @@ -79,15 +79,15 @@ public class ArticleServiceImpl extends ServiceImpl impl @Override public Article customGetByType(String type) { - if(!StrUtil.equals(type, ArticleEnum.OTHER.name())){ - return this.getOne(new LambdaUpdateWrapper
().eq(Article::getType,type)); + if (!CharSequenceUtil.equals(type, ArticleEnum.OTHER.name())) { + return this.getOne(new LambdaUpdateWrapper
().eq(Article::getType, type)); } return null; } @Override public Boolean updateArticleStatus(String id, boolean status) { - Article article=this.getById(id); + Article article = this.getById(id); article.setOpenStatus(status); return this.updateById(article); } diff --git a/framework/src/main/java/cn/lili/modules/page/serviceimpl/PageDataServiceImpl.java b/framework/src/main/java/cn/lili/modules/page/serviceimpl/PageDataServiceImpl.java index 7b9b442f..905c1789 100644 --- a/framework/src/main/java/cn/lili/modules/page/serviceimpl/PageDataServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/page/serviceimpl/PageDataServiceImpl.java @@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; /** * 楼层装修管理业务层实现 @@ -36,6 +37,7 @@ public class PageDataServiceImpl extends ServiceImpl i private SystemSettingProperties systemSettingProperties; @Override + @Transactional(rollbackFor = Exception.class) public void addStorePageData(String storeId) { //设置店铺的PC页面 PageData pageData = new PageData(); @@ -55,6 +57,7 @@ public class PageDataServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = Exception.class) public PageData addPageData(PageData pageData) { //如果页面为发布,则关闭其他页面,开启此页面 //演示站点不可以开启楼层 @@ -72,6 +75,7 @@ public class PageDataServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = Exception.class) public PageData updatePageData(PageData pageData) { //如果页面为发布,则关闭其他页面,开启此页面 if (pageData.getPageShow() != null && pageData.getPageShow().equals(SwitchEnum.OPEN.name())) { @@ -91,6 +95,7 @@ public class PageDataServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = Exception.class) public PageData releasePageData(String id) { PageData pageData = this.getById(id); @@ -120,6 +125,7 @@ public class PageDataServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = Exception.class) public boolean removePageData(String id) { PageData pageData = this.getById(id); //专题则直接进行删除 diff --git a/framework/src/main/java/cn/lili/modules/page/serviceimpl/SpecialServiceImpl.java b/framework/src/main/java/cn/lili/modules/page/serviceimpl/SpecialServiceImpl.java index 6e6b4fee..70639808 100644 --- a/framework/src/main/java/cn/lili/modules/page/serviceimpl/SpecialServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/page/serviceimpl/SpecialServiceImpl.java @@ -8,6 +8,7 @@ import cn.lili.modules.page.service.SpecialService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; /** * 专题活动业务层实现 @@ -25,6 +26,7 @@ public class SpecialServiceImpl extends ServiceImpl impl private PageDataService pageDataService; @Override + @Transactional(rollbackFor = Exception.class) public Special addSpecial(Special special) { //新建页面 PageData pageData = new PageData(); @@ -37,6 +39,7 @@ public class SpecialServiceImpl extends ServiceImpl impl } @Override + @Transactional(rollbackFor = Exception.class) public boolean removeSpecial(String id) { //删除页面内容 diff --git a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/AdminUserServiceImpl.java b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/AdminUserServiceImpl.java index d73fb93f..a7411f44 100644 --- a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/AdminUserServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/AdminUserServiceImpl.java @@ -27,6 +27,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Arrays; @@ -55,7 +56,7 @@ public class AdminUserServiceImpl extends ServiceImpl adminUserPage(Page initPage, QueryWrapper initWrapper) { @@ -71,7 +72,7 @@ public class AdminUserServiceImpl extends ServiceImpl department.getId().equals(adminUser.getDepartmentId())) + (department -> department.getId().equals(adminUser.getDepartmentId())) .collect(Collectors.toList()) .get(0) .getTitle() @@ -80,12 +81,12 @@ public class AdminUserServiceImpl extends ServiceImpl memberRoles = Arrays.asList(adminUser.getRoleIds().split(",")); adminUserVO.setRoles( roles.stream().filter - (role -> memberRoles.contains(role.getId())) + (role -> memberRoles.contains(role.getId())) .collect(Collectors.toList()) ); } catch (Exception e) { @@ -155,14 +156,15 @@ public class AdminUserServiceImpl extends ServiceImpl roles) { - if (roles != null && roles.size() > 0) { + if (roles != null && !roles.isEmpty()) { if (roles.size() > rolesMaxSize) { throw new ServiceException(ResultCode.PERMISSION_BEYOND_TEN); } - adminUser.setRoleIds(StringUtils.join(",", roles)); + adminUser.setRoleIds(CharSequenceUtil.join(",", roles)); } else { adminUser.setRoleIds(""); @@ -193,13 +195,14 @@ public class AdminUserServiceImpl extends ServiceImpl adminUsers = this.list(lambdaQueryWrapper); String password = StringUtils.md5("123456"); String newEncryptPass = new BCryptPasswordEncoder().encode(password); - if (null != adminUsers && adminUsers.size() > 0) { + if (null != adminUsers && !adminUsers.isEmpty()) { adminUsers.forEach(item -> item.setPassword(newEncryptPass)); this.updateBatchById(adminUsers); } } @Override + @Transactional(rollbackFor = Exception.class) public void saveAdminUser(AdminUserDTO adminUser, List roles) { AdminUser dbUser = new AdminUser(); BeanUtil.copyProperties(adminUser, dbUser); @@ -239,7 +242,7 @@ public class AdminUserServiceImpl extends ServiceImpl userRoles = new ArrayList<>(roles.size()); diff --git a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/DepartmentRoleServiceImpl.java b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/DepartmentRoleServiceImpl.java index d7e35b9d..10e484de 100644 --- a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/DepartmentRoleServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/DepartmentRoleServiceImpl.java @@ -6,6 +6,7 @@ import cn.lili.modules.permission.service.DepartmentRoleService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -27,6 +28,7 @@ public class DepartmentRoleServiceImpl extends ServiceImpl departmentRoles) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("department_id", departmentId); diff --git a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/DepartmentServiceImpl.java b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/DepartmentServiceImpl.java index 2ed31e47..076eaaf5 100644 --- a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/DepartmentServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/DepartmentServiceImpl.java @@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; @@ -40,6 +41,7 @@ public class DepartmentServiceImpl extends ServiceImpl ids) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.in("department_id", ids); diff --git a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/RoleMenuServiceImpl.java b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/RoleMenuServiceImpl.java index db9c3be2..8966c190 100644 --- a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/RoleMenuServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/RoleMenuServiceImpl.java @@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import groovy.util.logging.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.List; @@ -57,6 +58,7 @@ public class RoleMenuServiceImpl extends ServiceImpl i @Override + @Transactional(rollbackFor = Exception.class) public void updateRoleMenu(String roleId, List roleMenus) { try { //删除角色已经绑定的菜单 diff --git a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/RoleServiceImpl.java b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/RoleServiceImpl.java index 2ca61b57..510e7041 100644 --- a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/RoleServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/RoleServiceImpl.java @@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -46,6 +47,7 @@ public class RoleServiceImpl extends ServiceImpl implements Ro } @Override + @Transactional(rollbackFor = Exception.class) public void deleteRoles(List roleIds) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.in("role_id", roleIds); diff --git a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/UserRoleServiceImpl.java b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/UserRoleServiceImpl.java index 19ad367e..e3e84d4e 100644 --- a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/UserRoleServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/UserRoleServiceImpl.java @@ -6,6 +6,7 @@ import cn.lili.modules.permission.service.UserRoleService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; @@ -35,6 +36,7 @@ public class UserRoleServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = Exception.class) public void updateUserRole(String userId, List userRoles) { //删除 diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityItemServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityItemServiceImpl.java index b7fcde45..03eedfa4 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityItemServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityItemServiceImpl.java @@ -7,7 +7,6 @@ import cn.lili.modules.promotion.service.CouponActivityItemService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -38,7 +37,6 @@ public class CouponActivityItemServiceImpl extends ServiceImpl couponIds) { this.remove(new LambdaQueryWrapper() .in(CouponActivityItem::getCouponId, couponIds)); diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityServiceImpl.java index ee56fcdc..ef8e5a43 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponActivityServiceImpl.java @@ -54,6 +54,7 @@ public class CouponActivityServiceImpl extends AbstractPromotionsServiceImpl couponActivityList, Member member) { for (CouponActivity couponActivity : couponActivityList) { //获取会员信息 @@ -164,6 +166,7 @@ public class CouponActivityServiceImpl extends AbstractPromotionsServiceImpl> memberList, List couponActivityItems) { for (CouponActivityItem couponActivityItem : couponActivityItems) { diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java index 076d45ea..4f08616f 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java @@ -77,7 +77,6 @@ public class CouponServiceImpl extends AbstractPromotionsServiceImpl kanjiaActivityGoodsList = new ArrayList<>(); List promotionGoodsList = new ArrayList<>(); @@ -242,6 +244,7 @@ public class KanjiaActivityGoodsServiceImpl extends AbstractPromotionsServiceImp } @Override + @Transactional(rollbackFor = Exception.class) public boolean updateKanjiaActivityGoods(KanjiaActivityGoodsDTO kanJiaActivityGoodsDTO) { //校验砍价商品是否存在 KanjiaActivityGoods dbKanJiaActivityGoods = this.getKanjiaGoodsDetail(kanJiaActivityGoodsDTO.getId()); diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/KanjiaActivityServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/KanjiaActivityServiceImpl.java index 24d0382b..b48a3096 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/KanjiaActivityServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/KanjiaActivityServiceImpl.java @@ -35,6 +35,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.math.RoundingMode; @@ -93,6 +94,7 @@ public class KanjiaActivityServiceImpl extends ServiceImpl promotionsList) { List promotionGoodsList = new ArrayList<>(); for (PointsGoods pointsGoods : promotionsList) { @@ -106,6 +108,7 @@ public class PointsGoodsServiceImpl extends AbstractPromotionsServiceImpl ids) { for (String id : ids) { PointsGoods pointsGoods = this.getById(id); @@ -205,6 +209,7 @@ public class PointsGoodsServiceImpl extends AbstractPromotionsServiceImpl implements PurchaseOrderItemService { @Override + @Transactional(rollbackFor = Exception.class) public boolean addPurchaseOrderItem(String purchaseOrderId, List purchaseOrderItemList) { //添加采购单子内容 for (PurchaseOrderItem purchaseOrderItem : purchaseOrderItemList) { diff --git a/framework/src/main/java/cn/lili/modules/purchase/serviceimpl/PurchaseOrderServiceImpl.java b/framework/src/main/java/cn/lili/modules/purchase/serviceimpl/PurchaseOrderServiceImpl.java index 72e1e28e..bfb29b6b 100644 --- a/framework/src/main/java/cn/lili/modules/purchase/serviceimpl/PurchaseOrderServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/purchase/serviceimpl/PurchaseOrderServiceImpl.java @@ -17,6 +17,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; /** @@ -31,6 +32,7 @@ public class PurchaseOrderServiceImpl extends ServiceImpl implements PurchaseQuotedItemService { @Override + @Transactional(rollbackFor = Exception.class) public boolean addPurchaseQuotedItem(String purchaseQuotedId, List purchaseQuotedItemList) { for (PurchaseQuotedItem purchaseQuotedItem : purchaseQuotedItemList) { purchaseQuotedItem.setPurchaseQuotedId(purchaseQuotedId); diff --git a/framework/src/main/java/cn/lili/modules/purchase/serviceimpl/PurchaseQuotedServiceImpl.java b/framework/src/main/java/cn/lili/modules/purchase/serviceimpl/PurchaseQuotedServiceImpl.java index 703d1749..a963215d 100644 --- a/framework/src/main/java/cn/lili/modules/purchase/serviceimpl/PurchaseQuotedServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/purchase/serviceimpl/PurchaseQuotedServiceImpl.java @@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -26,6 +27,7 @@ public class PurchaseQuotedServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper().eq(CustomWords::getName, customWordsVO.getName()); CustomWords one = this.getOne(queryWrapper, false); @@ -81,6 +83,7 @@ public class CustomWordsServiceImpl extends ServiceImpl i @Override + @Transactional(rollbackFor = Exception.class) public void addSmsReach(SmsReach smsReach,List mobile) { String destination = rocketmqCustomProperties.getNoticeSendTopic() + ":" + OtherTagsEnum.SMS.name(); SmsReachDTO smsReachDTO = new SmsReachDTO(); diff --git a/framework/src/main/java/cn/lili/modules/sms/serviceimpl/SmsSignServiceImpl.java b/framework/src/main/java/cn/lili/modules/sms/serviceimpl/SmsSignServiceImpl.java index 49b8faab..d55c8b98 100644 --- a/framework/src/main/java/cn/lili/modules/sms/serviceimpl/SmsSignServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/sms/serviceimpl/SmsSignServiceImpl.java @@ -15,6 +15,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.HashMap; import java.util.List; @@ -32,6 +33,7 @@ public class SmsSignServiceImpl extends ServiceImpl impl private AliSmsUtil aliSmsUtil; @Override + @Transactional(rollbackFor = Exception.class) public void addSmsSign(SmsSign smsSign) { try { //如果短信签名已存在,不能重复申请 @@ -47,6 +49,7 @@ public class SmsSignServiceImpl extends ServiceImpl impl } @Override + @Transactional(rollbackFor = Exception.class) public void deleteSmsSign(String id) { try { SmsSign smsSign = this.getById(id); @@ -61,6 +64,7 @@ public class SmsSignServiceImpl extends ServiceImpl impl } @Override + @Transactional(rollbackFor = Exception.class) public void querySmsSign() { try { Map map = new HashMap<>(16); @@ -79,6 +83,7 @@ public class SmsSignServiceImpl extends ServiceImpl impl } @Override + @Transactional(rollbackFor = Exception.class) public void modifySmsSign(SmsSign smsSign) { try { aliSmsUtil.modifySmsSign(smsSign); diff --git a/framework/src/main/java/cn/lili/modules/sms/serviceimpl/SmsTemplateServiceImpl.java b/framework/src/main/java/cn/lili/modules/sms/serviceimpl/SmsTemplateServiceImpl.java index c5d8dddf..b23a4990 100644 --- a/framework/src/main/java/cn/lili/modules/sms/serviceimpl/SmsTemplateServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/sms/serviceimpl/SmsTemplateServiceImpl.java @@ -14,7 +14,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.HashMap; import java.util.List; import java.util.Map; @@ -59,7 +58,7 @@ public class SmsTemplateServiceImpl extends ServiceImpl map = new HashMap<>(16); + Map map; //获取未审核通过的签名列表 List list = list(new LambdaQueryWrapper().eq(SmsTemplate::getTemplateStatus, 0)); //查询签名状态 diff --git a/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java b/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java index 40b4e3dc..2f60c9e9 100644 --- a/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/store/serviceimpl/StoreServiceImpl.java @@ -30,6 +30,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.Objects; import java.util.Optional; @@ -73,6 +74,7 @@ public class StoreServiceImpl extends ServiceImpl implements } @Override + @Transactional(rollbackFor = Exception.class) public Store add(AdminStoreApplyDTO adminStoreApplyDTO) { //判断店铺名称是否存在 @@ -111,6 +113,7 @@ public class StoreServiceImpl extends ServiceImpl implements } @Override + @Transactional(rollbackFor = Exception.class) public Store edit(StoreEditDTO storeEditDTO) { if (storeEditDTO != null) { //判断店铺名是否唯一 @@ -157,6 +160,7 @@ public class StoreServiceImpl extends ServiceImpl implements } @Override + @Transactional(rollbackFor = Exception.class) public boolean audit(String id, Integer passed) { Store store = this.getById(id); if (store == null) { diff --git a/framework/src/main/java/cn/lili/modules/system/serviceimpl/LogisticsServiceImpl.java b/framework/src/main/java/cn/lili/modules/system/serviceimpl/LogisticsServiceImpl.java index 26722cf9..e7b40f61 100644 --- a/framework/src/main/java/cn/lili/modules/system/serviceimpl/LogisticsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/system/serviceimpl/LogisticsServiceImpl.java @@ -1,6 +1,6 @@ package cn.lili.modules.system.serviceimpl; -import cn.hutool.core.util.StrUtil; +import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.enums.ResultCode; import cn.lili.common.enums.SwitchEnum; import cn.lili.common.exception.ServiceException; @@ -70,7 +70,7 @@ public class LogisticsServiceImpl extends ServiceImpl params = new HashMap(8); + Map params = new HashMap<>(8); params.put("RequestData", urlEncoder(requestData, "UTF-8")); params.put("EBusinessID", EBusinessID); params.put("RequestType", "1002"); @@ -134,14 +134,12 @@ public class LogisticsServiceImpl extends ServiceImpl impleme /** * 同步请求地址 */ - private String syncUrl = "https://restapi.amap.com/v3/config/district?subdistrict=4&key=e456d77800e2084a326f7b777278f89d"; + private final String syncUrl = "https://restapi.amap.com/v3/config/district?subdistrict=4&key=e456d77800e2084a326f7b777278f89d"; @Autowired private Cache cache; @@ -41,12 +41,12 @@ public class RegionServiceImpl extends ServiceImpl impleme try { //清空数据 - QueryWrapper queryWrapper = new QueryWrapper(); + QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.ne("id", "-1"); this.remove(queryWrapper); //读取数据 - String jsonString = HttpClientUtils.doGet(StringUtils.isEmpty(url) ? syncUrl : url, null); + String jsonString = HttpClientUtils.doGet(CharSequenceUtil.isEmpty(url) ? syncUrl : url, null); //构造存储数据库的对象集合 List regions = this.initData(jsonString); @@ -66,12 +66,7 @@ public class RegionServiceImpl extends ServiceImpl impleme LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); lambdaQueryWrapper.eq(Region::getParentId, id); List regions = this.list(lambdaQueryWrapper); - regions.sort(new Comparator() { - @Override - public int compare(Region o1, Region o2) { - return o1.getOrderNum().compareTo(o2.getOrderNum()); - } - }); + regions.sort(Comparator.comparing(Region::getOrderNum)); return regions; } @@ -89,26 +84,26 @@ public class RegionServiceImpl extends ServiceImpl impleme result = ArrayUtils.remove(result, 0); result = ArrayUtils.remove(result, 0); //地址id - String regionIds = ""; + StringBuilder regionIds = new StringBuilder(); //地址名称 - String regionNames = ""; + StringBuilder regionNames = new StringBuilder(); //循环构建新的数据 for (String regionId : result) { Region reg = this.baseMapper.selectById(regionId); if (reg != null) { - regionIds += regionId + ","; - regionNames += reg.getName() + ","; + regionIds.append(regionId).append(","); + regionNames.append(reg.getName()).append(","); } } - regionIds += region.getId(); - regionNames += region.getName(); + regionIds.append(region.getId()); + regionNames.append(region.getName()); //构建返回数据 Map obj = new HashMap<>(2); - obj.put("id", regionIds); - obj.put("name", regionNames); + obj.put("id", regionIds.toString()); + obj.put("name", regionNames.toString()); return obj; } - return null; + return Collections.emptyMap(); } @Override @@ -121,9 +116,7 @@ public class RegionServiceImpl extends ServiceImpl impleme private List regionTree(List regions) { List regionVOS = new ArrayList<>(); - regions.stream().filter(region -> ("province").equals(region.getLevel())).forEach(item -> { - regionVOS.add(new RegionVO(item)); - }); + regions.stream().filter(region -> ("province").equals(region.getLevel())).forEach(item -> regionVOS.add(new RegionVO(item))); regions.stream().filter(region -> ("city").equals(region.getLevel())).forEach(item -> { for (RegionVO region : regionVOS) { if (region.getId().equals(item.getParentId())) { @@ -238,9 +231,9 @@ public class RegionServiceImpl extends ServiceImpl impleme record.setParentId(parentId); record.setOrderNum(order); record.setId(String.valueOf(SnowFlake.getId())); - StringBuffer megName = new StringBuffer(","); + StringBuilder megName = new StringBuilder(","); for (int i = 0; i < ids.length; i++) { - megName = megName.append(ids[i]) ; + megName.append(ids[i]); if (i < ids.length - 1) { megName.append(","); } diff --git a/framework/src/main/java/cn/lili/modules/verification/service/impl/VerificationServiceImpl.java b/framework/src/main/java/cn/lili/modules/verification/service/impl/VerificationServiceImpl.java index 35f8b481..dd4b5894 100644 --- a/framework/src/main/java/cn/lili/modules/verification/service/impl/VerificationServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/verification/service/impl/VerificationServiceImpl.java @@ -156,7 +156,7 @@ public class VerificationServiceImpl implements VerificationService { @Override public boolean check(String uuid, VerificationEnums verificationEnums) { //如果有校验标记,则返回校验结果 - if (cache.remove(cacheResult(verificationEnums, uuid))) { + if (Boolean.TRUE.equals(cache.remove(cacheResult(verificationEnums, uuid)))) { return true; } throw new ServiceException(ResultCode.VERIFICATION_CODE_INVALID); diff --git a/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/MemberWalletServiceImpl.java b/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/MemberWalletServiceImpl.java index a9aea270..87766492 100644 --- a/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/MemberWalletServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/MemberWalletServiceImpl.java @@ -37,6 +37,7 @@ import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.Date; @@ -93,6 +94,7 @@ public class MemberWalletServiceImpl extends ServiceImpl i //构建查询条件 QueryWrapper queryWrapper = new QueryWrapper<>(); //会员名称 - queryWrapper.like(!StringUtils.isEmpty(rechargeQueryVO.getMemberName()), "member_name", rechargeQueryVO.getMemberName()); + queryWrapper.like(!CharSequenceUtil.isEmpty(rechargeQueryVO.getMemberName()), "member_name", rechargeQueryVO.getMemberName()); //充值订单号 - queryWrapper.eq(!StringUtils.isEmpty(rechargeQueryVO.getRechargeSn()), "recharge_sn", rechargeQueryVO.getRechargeSn()); + queryWrapper.eq(!CharSequenceUtil.isEmpty(rechargeQueryVO.getRechargeSn()), "recharge_sn", rechargeQueryVO.getRechargeSn()); //会员id - queryWrapper.eq(!StringUtils.isEmpty(rechargeQueryVO.getMemberId()), "member_id", rechargeQueryVO.getMemberId()); + queryWrapper.eq(!CharSequenceUtil.isEmpty(rechargeQueryVO.getMemberId()), "member_id", rechargeQueryVO.getMemberId()); //支付时间 开始时间和结束时间 - if (!StringUtils.isEmpty(rechargeQueryVO.getStartDate()) && !StringUtils.isEmpty(rechargeQueryVO.getEndDate())) { + if (!CharSequenceUtil.isEmpty(rechargeQueryVO.getStartDate()) && !CharSequenceUtil.isEmpty(rechargeQueryVO.getEndDate())) { Date start = cn.hutool.core.date.DateUtil.parse(rechargeQueryVO.getStartDate()); Date end = cn.hutool.core.date.DateUtil.parse(rechargeQueryVO.getEndDate()); queryWrapper.between("pay_time", start, end); diff --git a/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/WalletLogServiceImpl.java b/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/WalletLogServiceImpl.java index b1957e80..f3a53b17 100644 --- a/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/WalletLogServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/wallet/serviceimpl/WalletLogServiceImpl.java @@ -1,6 +1,6 @@ package cn.lili.modules.wallet.serviceimpl; -import cn.lili.common.utils.StringUtils; +import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.vo.PageVO; import cn.lili.modules.order.trade.entity.vo.DepositQueryVO; import cn.lili.modules.wallet.entity.dos.WalletLog; @@ -28,11 +28,11 @@ public class WalletLogServiceImpl extends ServiceImpl depositLogQueryWrapper = new QueryWrapper<>(); //会员名称 - depositLogQueryWrapper.like(!StringUtils.isEmpty(depositQueryVO.getMemberName()), "member_name", depositQueryVO.getMemberName()); + depositLogQueryWrapper.like(!CharSequenceUtil.isEmpty(depositQueryVO.getMemberName()), "member_name", depositQueryVO.getMemberName()); //会员id - depositLogQueryWrapper.eq(!StringUtils.isEmpty(depositQueryVO.getMemberId()), "member_id", depositQueryVO.getMemberId()); + depositLogQueryWrapper.eq(!CharSequenceUtil.isEmpty(depositQueryVO.getMemberId()), "member_id", depositQueryVO.getMemberId()); //开始时间和技术时间 - if (!StringUtils.isEmpty(depositQueryVO.getStartDate()) && !StringUtils.isEmpty(depositQueryVO.getEndDate())) { + if (!CharSequenceUtil.isEmpty(depositQueryVO.getStartDate()) && !CharSequenceUtil.isEmpty(depositQueryVO.getEndDate())) { Date start = cn.hutool.core.date.DateUtil.parse(depositQueryVO.getStartDate()); Date end = cn.hutool.core.date.DateUtil.parse(depositQueryVO.getEndDate()); depositLogQueryWrapper.between("create_time", start, end);