From e4636b43d19c8f288962cd44c9d61ea89a9239fb Mon Sep 17 00:00:00 2001
From: DESKTOP-71BH0QO\L、ming <172680469@qq.com>
Date: 星期日, 25 四月 2021 18:44:37 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopStoreServiceImpl.java | 103 ++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 89 insertions(+), 14 deletions(-)
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopStoreServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopStoreServiceImpl.java
index 94754c4..9e6e1c0 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopStoreServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopStoreServiceImpl.java
@@ -1,14 +1,18 @@
package com.panzhihua.service_community.service.impl;
+import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.panzhihua.common.constants.Constants;
import com.panzhihua.common.model.dtos.shop.PageComShopStoreDTO;
+import com.panzhihua.common.model.vos.LoginUserInfoVO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.shop.*;
import com.panzhihua.common.model.vos.shop.PageShopStoreVO;
+import com.panzhihua.common.service.user.UserService;
import com.panzhihua.service_community.dao.ComShopGoodsAttrDAO;
import com.panzhihua.service_community.dao.ComShopGoodsDAO;
import com.panzhihua.common.model.vos.shop.PageShopStoreVO;
@@ -37,6 +41,8 @@
private ComShopGoodsDAO shopGoodsDAO;
@Resource
private ComShopGoodsAttrDAO comShopGoodsAttrDAO;
+ @Resource
+ private UserService userService;
/**
* 查询店铺列表
@@ -92,13 +98,29 @@
@Override
public R saveStore(ShopStoreVO storeVO) {
if (storeVO == null) {
- return R.ok("500", "数据为空!");
+ return R.fail("数据为空!");
}
- ComShopStoreDO comShopStoreDO = this.baseMapper.selectOne(new LambdaQueryWrapper<ComShopStoreDO>()
- .eq(ComShopStoreDO::getStoreAccount, storeVO.getStoreAccount()));
- if (comShopStoreDO != null) {
- return R.ok("500", "商家账号存在");
+ //判断店铺是否存在
+ ComShopStoreDO oldComShopStoreDO = this.baseMapper.selectOne(new LambdaQueryWrapper<ComShopStoreDO>()
+ .eq(ComShopStoreDO::getStoreAccount, storeVO.getStoreAccount()).eq(ComShopStoreDO::getDeleteStatus,ComShopStoreDO.deleteStatus.no));
+ if (oldComShopStoreDO != null) {
+ return R.fail("商家已注册");
}
+// //新增店铺先判断是否拥有已删除的店铺
+// ComShopStoreDO comShopStoreDO = this.baseMapper.selectOne(new LambdaQueryWrapper<ComShopStoreDO>()
+// .eq(ComShopStoreDO::getStoreAccount, storeVO.getStoreAccount()).eq(ComShopStoreDO::getDeleteStatus,ComShopStoreDO.deleteStatus.yes));
+// if(comShopStoreDO != null){
+// //删除店铺规格信息
+// comShopGoodsAttrDAO.delete(new QueryWrapper<ComShopGoodsAttrDO>().lambda().eq(ComShopGoodsAttrDO::getStoreId,comShopStoreDO.getId()));
+// //删除店铺商品
+// shopGoodsDAO.delete(new QueryWrapper<ComShopGoodsDO>().lambda().eq(ComShopGoodsDO::getStoreId,comShopStoreDO.getId()));
+// //删除关联的sysUser用户权限
+// this.baseMapper.deleteSysRoleByAccount(Constants.SHOP_ROLE_KEY + comShopStoreDO.getStoreAccount());
+// //删除关联的sysUser用户
+// this.baseMapper.deleteSysUserBySysUserId(comShopStoreDO.getSysUserId());
+// //删除店铺
+// this.baseMapper.deleteById(comShopStoreDO.getId());
+// }
ComShopStoreDO storeDO = new ComShopStoreDO();
BeanUtils.copyProperties(storeVO, storeDO);
storeDO.setSale(0);
@@ -106,16 +128,50 @@
return R.ok();
}
- @Override
- public R editStore(Long id, ShopStoreVO storeVO) {
- if (storeVO == null) {
- return R.ok("500", "数据为空!");
+ public R addStore(ShopStoreVO storeVO){
+ //判断店铺是否存在
+ ComShopStoreDO oldComShopStoreDO = this.baseMapper.selectOne(new LambdaQueryWrapper<ComShopStoreDO>()
+ .eq(ComShopStoreDO::getStoreAccount, storeVO.getStoreAccount()).eq(ComShopStoreDO::getDeleteStatus,ComShopStoreDO.deleteStatus.no));
+ if (oldComShopStoreDO != null) {
+ return R.fail("商家已注册");
}
- LambdaQueryWrapper<ComShopStoreDO> query = new LambdaQueryWrapper<ComShopStoreDO>().eq(ComShopStoreDO::getId, id);
+ //新增店铺先判断是否拥有已删除的店铺
+ ComShopStoreDO comShopStoreDO = this.baseMapper.selectOne(new LambdaQueryWrapper<ComShopStoreDO>()
+ .eq(ComShopStoreDO::getStoreAccount, storeVO.getStoreAccount()).eq(ComShopStoreDO::getDeleteStatus,ComShopStoreDO.deleteStatus.yes));
+ if(comShopStoreDO != null){
+ //删除店铺规格信息
+ comShopGoodsAttrDAO.delete(new QueryWrapper<ComShopGoodsAttrDO>().lambda().eq(ComShopGoodsAttrDO::getStoreId,comShopStoreDO.getId()));
+ //删除店铺商品
+ shopGoodsDAO.delete(new QueryWrapper<ComShopGoodsDO>().lambda().eq(ComShopGoodsDO::getStoreId,comShopStoreDO.getId()));
+ //删除关联的sysUser用户权限
+ this.baseMapper.deleteSysRoleByAccount(Constants.SHOP_ROLE_KEY + comShopStoreDO.getStoreAccount());
+ //删除关联的sysUser用户
+ this.baseMapper.deleteSysUserBySysUserId(comShopStoreDO.getSysUserId());
+ //删除店铺
+ this.baseMapper.deleteById(comShopStoreDO.getId());
+ }
ComShopStoreDO storeDO = new ComShopStoreDO();
BeanUtils.copyProperties(storeVO, storeDO);
- int update = this.baseMapper.update(storeDO, query);
- return update > 0 ? R.ok() : R.fail();
+ storeDO.setSale(0);
+ if(this.baseMapper.insert(storeDO) > 0){
+ return R.ok();
+ }else{
+ return R.fail();
+ }
+ }
+
+ @Override
+ public R editStore(Long id, ShopStoreVO storeVO) {
+ ComShopStoreDO storeDO = this.baseMapper.selectById(id);
+ if(storeDO == null){
+ return R.fail("商家不存在");
+ }
+ BeanUtils.copyProperties(storeVO, storeDO);
+ if(this.baseMapper.updateById(storeDO) > 0){
+ return R.ok();
+ }else{
+ return R.fail();
+ }
}
@Override
@@ -147,7 +203,7 @@
public R getOneInfo(Long id) {
ComShopStoreDO comShopStoreDO = this.baseMapper.selectById(id);
if (comShopStoreDO == null) {
- R.fail(500, "商铺不存在");
+ return R.fail(500, "商铺不存在");
}
ShopStoreVO shopStoreVO = new ShopStoreVO();
BeanUtils.copyProperties(comShopStoreDO, shopStoreVO);
@@ -158,10 +214,29 @@
public R getUserStoreInfo(Long userId) {
ComShopStoreDO comShopStoreDO = this.baseMapper.selectOne(new LambdaQueryWrapper<ComShopStoreDO>().eq(ComShopStoreDO::getDeleteStatus, 1).eq(ComShopStoreDO::getSysUserId, userId));
if (comShopStoreDO == null) {
- R.fail(500, "商铺不存在");
+ return R.fail(500, "商铺不存在");
}
ShopStoreVO shopStoreVO = new ShopStoreVO();
BeanUtils.copyProperties(comShopStoreDO, shopStoreVO);
return R.ok(shopStoreVO);
}
+
+ @Override
+ public R getUserStoreInfo(String account) {
+ try {
+ R<LoginUserInfoVO> loginUserInfoVOR = userService.getUserInfo(account+"_5");
+ LoginUserInfoVO loginUserInfoVO = JSONObject.parseObject(JSONObject.toJSONString(loginUserInfoVOR.getData()), LoginUserInfoVO.class);
+
+ ComShopStoreDO comShopStoreDO = this.baseMapper.selectOne(new LambdaQueryWrapper<ComShopStoreDO>()
+ .eq(ComShopStoreDO::getDeleteStatus, 1).eq(ComShopStoreDO::getSysUserId, loginUserInfoVO.getUserId()));
+ if (comShopStoreDO == null) {
+ R.fail(500, "商铺不存在");
+ }
+ ShopStoreVO shopStoreVO = new ShopStoreVO();
+ BeanUtils.copyProperties(comShopStoreDO, shopStoreVO);
+ return R.ok(shopStoreVO);
+ }catch (Exception e){
+ return R.fail();
+ }
+ }
}
--
Gitblit v1.7.1