Search in sources :

Example 1 with StoreDetail

use of cn.lili.modules.store.entity.dos.StoreDetail in project lilishop by lilishop.

the class StoreServiceImpl method add.

@Override
@Transactional(rollbackFor = Exception.class)
public Store add(AdminStoreApplyDTO adminStoreApplyDTO) {
    // 判断店铺名称是否存在
    QueryWrapper<Store> queryWrapper = Wrappers.query();
    queryWrapper.eq("store_name", adminStoreApplyDTO.getStoreName());
    if (this.getOne(queryWrapper) != null) {
        throw new ServiceException(ResultCode.STORE_NAME_EXIST_ERROR);
    }
    Member member = memberService.getById(adminStoreApplyDTO.getMemberId());
    // 判断用户是否存在
    if (member == null) {
        throw new ServiceException(ResultCode.USER_NOT_EXIST);
    }
    // 判断是否拥有店铺
    if (Boolean.TRUE.equals(member.getHaveStore())) {
        throw new ServiceException(ResultCode.STORE_APPLY_DOUBLE_ERROR);
    }
    // 添加店铺
    Store store = new Store(member, adminStoreApplyDTO);
    this.save(store);
    // 判断是否存在店铺详情,如果没有则进行新建,如果存在则进行修改
    StoreDetail storeDetail = new StoreDetail(store, adminStoreApplyDTO);
    storeDetailService.save(storeDetail);
    // 设置会员-店铺信息
    memberService.update(new LambdaUpdateWrapper<Member>().eq(Member::getId, member.getId()).set(Member::getHaveStore, true).set(Member::getStoreId, store.getId()));
    return store;
}
Also used : LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) StoreDetail(cn.lili.modules.store.entity.dos.StoreDetail) ServiceException(cn.lili.common.exception.ServiceException) Store(cn.lili.modules.store.entity.dos.Store) Member(cn.lili.modules.member.entity.dos.Member) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with StoreDetail

use of cn.lili.modules.store.entity.dos.StoreDetail in project lilishop by lilishop.

the class StoreServiceImpl method applyThirdStep.

@Override
public boolean applyThirdStep(StoreOtherInfoDTO storeOtherInfoDTO) {
    // 获取当前操作的店铺
    Store store = getStoreByMember();
    BeanUtil.copyProperties(storeOtherInfoDTO, store);
    this.updateById(store);
    StoreDetail storeDetail = storeDetailService.getStoreDetail(store.getId());
    // 设置店铺的其他信息
    BeanUtil.copyProperties(storeOtherInfoDTO, storeDetail);
    // 设置店铺经营范围
    storeDetail.setGoodsManagementCategory(storeOtherInfoDTO.getGoodsManagementCategory());
    // 最后一步申请,给予店铺设置库存预警默认值
    storeDetail.setStockWarning(10);
    // 修改店铺详细信息
    storeDetailService.updateById(storeDetail);
    // 设置店铺名称,修改店铺信息
    store.setStoreName(storeOtherInfoDTO.getStoreName());
    store.setStoreDisable(StoreStatusEnum.APPLYING.name());
    store.setStoreCenter(storeOtherInfoDTO.getStoreCenter());
    store.setStoreDesc(storeOtherInfoDTO.getStoreDesc());
    store.setStoreLogo(storeOtherInfoDTO.getStoreLogo());
    return this.updateById(store);
}
Also used : StoreDetail(cn.lili.modules.store.entity.dos.StoreDetail) Store(cn.lili.modules.store.entity.dos.Store)

Example 3 with StoreDetail

use of cn.lili.modules.store.entity.dos.StoreDetail in project lilishop by lilishop.

the class StoreServiceImpl method applySecondStep.

@Override
public boolean applySecondStep(StoreBankDTO storeBankDTO) {
    // 获取当前操作的店铺
    Store store = getStoreByMember();
    StoreDetail storeDetail = storeDetailService.getStoreDetail(store.getId());
    // 设置店铺的银行信息
    BeanUtil.copyProperties(storeBankDTO, storeDetail);
    return storeDetailService.updateById(storeDetail);
}
Also used : StoreDetail(cn.lili.modules.store.entity.dos.StoreDetail) Store(cn.lili.modules.store.entity.dos.Store)

Example 4 with StoreDetail

use of cn.lili.modules.store.entity.dos.StoreDetail in project lilishop by lilishop.

the class StoreDetailServiceImpl method goodsManagementCategory.

@Override
public List<StoreManagementCategoryVO> goodsManagementCategory(String storeId) {
    // 获取顶部分类列表
    List<Category> categoryList = categoryService.firstCategory();
    // 获取店铺信息
    StoreDetail storeDetail = this.getOne(new LambdaQueryWrapper<StoreDetail>().eq(StoreDetail::getStoreId, storeId));
    // 获取店铺分类
    String[] storeCategoryList = storeDetail.getGoodsManagementCategory().split(",");
    List<StoreManagementCategoryVO> list = new ArrayList<>();
    for (Category category : categoryList) {
        StoreManagementCategoryVO storeManagementCategoryVO = new StoreManagementCategoryVO(category);
        for (String storeCategory : storeCategoryList) {
            if (storeCategory.equals(category.getId())) {
                storeManagementCategoryVO.setSelected(true);
            }
        }
        list.add(storeManagementCategoryVO);
    }
    return list;
}
Also used : StoreDetail(cn.lili.modules.store.entity.dos.StoreDetail) Category(cn.lili.modules.goods.entity.dos.Category) StoreManagementCategoryVO(cn.lili.modules.store.entity.vos.StoreManagementCategoryVO) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 5 with StoreDetail

use of cn.lili.modules.store.entity.dos.StoreDetail in project lilishop by lilishop.

the class StoreServiceImpl method applyFirstStep.

@Override
public boolean applyFirstStep(StoreCompanyDTO storeCompanyDTO) {
    // 获取当前操作的店铺
    Store store = getStoreByMember();
    // 如果没有申请过店铺,新增店铺
    if (!Optional.ofNullable(store).isPresent()) {
        AuthUser authUser = Objects.requireNonNull(UserContext.getCurrentUser());
        Member member = memberService.getById(authUser.getId());
        store = new Store(member);
        BeanUtil.copyProperties(storeCompanyDTO, store);
        this.save(store);
        StoreDetail storeDetail = new StoreDetail();
        storeDetail.setStoreId(store.getId());
        BeanUtil.copyProperties(storeCompanyDTO, storeDetail);
        return storeDetailService.save(storeDetail);
    } else {
        BeanUtil.copyProperties(storeCompanyDTO, store);
        this.updateById(store);
        // 判断是否存在店铺详情,如果没有则进行新建,如果存在则进行修改
        StoreDetail storeDetail = storeDetailService.getStoreDetail(store.getId());
        BeanUtil.copyProperties(storeCompanyDTO, storeDetail);
        return storeDetailService.updateById(storeDetail);
    }
}
Also used : StoreDetail(cn.lili.modules.store.entity.dos.StoreDetail) Store(cn.lili.modules.store.entity.dos.Store) AuthUser(cn.lili.common.security.AuthUser) Member(cn.lili.modules.member.entity.dos.Member)

Aggregations

StoreDetail (cn.lili.modules.store.entity.dos.StoreDetail)8 Store (cn.lili.modules.store.entity.dos.Store)5 Member (cn.lili.modules.member.entity.dos.Member)3 ServiceException (cn.lili.common.exception.ServiceException)2 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)2 Transactional (org.springframework.transaction.annotation.Transactional)2 DateTime (cn.hutool.core.date.DateTime)1 AuthUser (cn.lili.common.security.AuthUser)1 Category (cn.lili.modules.goods.entity.dos.Category)1 GoodsSku (cn.lili.modules.goods.entity.dos.GoodsSku)1 StockWarningVO (cn.lili.modules.goods.entity.vos.StockWarningVO)1 StoreManagementCategoryVO (cn.lili.modules.store.entity.vos.StoreManagementCategoryVO)1 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)1 LambdaUpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper)1 ApiOperation (io.swagger.annotations.ApiOperation)1