Search in sources :

Example 1 with AuthUser

use of cn.lili.common.security.AuthUser in project lilishop by lilishop.

the class FreightTemplateServiceImpl method editFreightTemplate.

@Override
@Transactional(rollbackFor = Exception.class)
public FreightTemplateVO editFreightTemplate(FreightTemplateVO freightTemplateVO) {
    // 获取当前登录商家账号
    AuthUser tokenUser = UserContext.getCurrentUser();
    if (freightTemplateVO.getId().equals(tokenUser.getStoreId())) {
        throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR);
    }
    FreightTemplate freightTemplate = new FreightTemplate();
    // 复制属性
    BeanUtils.copyProperties(freightTemplateVO, freightTemplate);
    // 修改运费模板
    this.updateById(freightTemplate);
    // 删除模板子内容
    freightTemplateChildService.removeFreightTemplate(freightTemplateVO.getId());
    // 给子模板赋父模板的id
    List<FreightTemplateChild> list = new ArrayList<>();
    for (FreightTemplateChild freightTemplateChild : freightTemplateVO.getFreightTemplateChildList()) {
        freightTemplateChild.setFreightTemplateId(freightTemplate.getId());
        list.add(freightTemplateChild);
    }
    // 添加模板子内容
    freightTemplateChildService.addFreightTemplateChild(list);
    // 更新缓存
    cache.remove(CachePrefix.SHIP_TEMPLATE.getPrefix() + tokenUser.getStoreId());
    return null;
}
Also used : ServiceException(cn.lili.common.exception.ServiceException) ArrayList(java.util.ArrayList) AuthUser(cn.lili.common.security.AuthUser) FreightTemplateChild(cn.lili.modules.store.entity.dos.FreightTemplateChild) FreightTemplate(cn.lili.modules.store.entity.dos.FreightTemplate) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with AuthUser

use of cn.lili.common.security.AuthUser in project lilishop by lilishop.

the class FreightTemplateServiceImpl method addFreightTemplate.

@Override
public FreightTemplateVO addFreightTemplate(FreightTemplateVO freightTemplateVO) {
    // 获取当前登录商家账号
    AuthUser tokenUser = UserContext.getCurrentUser();
    FreightTemplate freightTemplate = new FreightTemplate();
    // 设置店铺ID
    freightTemplateVO.setStoreId(tokenUser.getStoreId());
    // 复制属性
    BeanUtils.copyProperties(freightTemplateVO, freightTemplate);
    // 添加运费模板
    this.save(freightTemplate);
    // 给子模板赋父模板的id
    List<FreightTemplateChild> list = new ArrayList<>();
    // 如果子运费模板不为空则进行新增
    if (freightTemplateVO.getFreightTemplateChildList() != null) {
        for (FreightTemplateChild freightTemplateChild : freightTemplateVO.getFreightTemplateChildList()) {
            freightTemplateChild.setFreightTemplateId(freightTemplate.getId());
            list.add(freightTemplateChild);
        }
        // 添加运费模板子内容
        freightTemplateChildService.addFreightTemplateChild(list);
    }
    // 更新缓存
    cache.remove(CachePrefix.SHIP_TEMPLATE.getPrefix() + tokenUser.getStoreId());
    return freightTemplateVO;
}
Also used : ArrayList(java.util.ArrayList) AuthUser(cn.lili.common.security.AuthUser) FreightTemplateChild(cn.lili.modules.store.entity.dos.FreightTemplateChild) FreightTemplate(cn.lili.modules.store.entity.dos.FreightTemplate)

Example 3 with AuthUser

use of cn.lili.common.security.AuthUser in project lilishop by lilishop.

the class StoreDetailServiceImpl method editMerchantEuid.

@Override
public Boolean editMerchantEuid(String merchantEuid) {
    AuthUser tokenUser = Objects.requireNonNull(UserContext.getCurrentUser());
    Store store = storeService.getById(tokenUser.getStoreId());
    store.setMerchantEuid(merchantEuid);
    return storeService.updateById(store);
}
Also used : Store(cn.lili.modules.store.entity.dos.Store) AuthUser(cn.lili.common.security.AuthUser)

Example 4 with AuthUser

use of cn.lili.common.security.AuthUser in project lilishop by lilishop.

the class MemberWalletServiceImpl method applyWithdrawal.

/**
 * 提现方法
 * 1、先执行平台逻辑,平台逻辑成功后扣减第三方余额,顺序问题为了防止第三方提现成功,平台逻辑失败导致第三方零钱已提现,而我们商城余额未扣减
 * 2、如果余额扣减失败 则抛出异常,事务回滚
 *
 * @param price 提现金额
 * @return
 */
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean applyWithdrawal(Double price) {
    MemberWithdrawalMessage memberWithdrawalMessage = new MemberWithdrawalMessage();
    AuthUser authUser = UserContext.getCurrentUser();
    // 构建审核参数
    MemberWithdrawApply memberWithdrawApply = new MemberWithdrawApply();
    memberWithdrawApply.setMemberId(authUser.getId());
    memberWithdrawApply.setMemberName(authUser.getNickName());
    memberWithdrawApply.setApplyMoney(price);
    memberWithdrawApply.setApplyStatus(WithdrawStatusEnum.APPLY.name());
    memberWithdrawApply.setSn("W" + SnowFlake.getId());
    // 校验该次提现是否需要审核,如果未进行配置 默认是需要审核
    Setting setting = settingService.get(SettingEnum.WITHDRAWAL_SETTING.name());
    if (setting != null) {
        // 如果不需要审核则审核自动通过
        WithdrawalSetting withdrawalSetting = new Gson().fromJson(setting.getSettingValue(), WithdrawalSetting.class);
        if (Boolean.FALSE.equals(withdrawalSetting.getApply())) {
            memberWithdrawApply.setApplyStatus(WithdrawStatusEnum.VIA_AUDITING.name());
            memberWithdrawApply.setInspectRemark("系统自动审核通过");
            // 校验金额是否满足提现,因为是从余额扣减,所以校验的是余额
            MemberWalletVO memberWalletVO = this.getMemberWallet(memberWithdrawApply.getMemberId());
            if (memberWalletVO.getMemberWallet() < price) {
                throw new ServiceException(ResultCode.WALLET_WITHDRAWAL_INSUFFICIENT);
            }
            memberWithdrawalMessage.setStatus(WithdrawStatusEnum.VIA_AUDITING.name());
            // 微信零钱提现
            Boolean result = withdrawal(memberWithdrawApply);
            if (Boolean.TRUE.equals(result)) {
                this.reduce(new MemberWalletUpdateDTO(price, authUser.getId(), "余额提现成功", DepositServiceTypeEnum.WALLET_WITHDRAWAL.name()));
            }
        } else {
            memberWithdrawalMessage.setStatus(WithdrawStatusEnum.APPLY.name());
            // 扣减余额到冻结金额
            this.reduceWithdrawal(new MemberWalletUpdateDTO(price, authUser.getId(), "提现金额已冻结,审核成功后到账", DepositServiceTypeEnum.WALLET_WITHDRAWAL.name()));
        }
        // 发送余额提现申请消息
        memberWithdrawalMessage.setMemberId(authUser.getId());
        memberWithdrawalMessage.setPrice(price);
        memberWithdrawalMessage.setDestination(MemberWithdrawalDestinationEnum.WECHAT.name());
        String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_WITHDRAWAL.name();
        rocketMQTemplate.asyncSend(destination, memberWithdrawalMessage, RocketmqSendCallbackBuilder.commonCallback());
    }
    return memberWithdrawApplyService.save(memberWithdrawApply);
}
Also used : MemberWalletUpdateDTO(cn.lili.modules.wallet.entity.dto.MemberWalletUpdateDTO) MemberWithdrawalMessage(cn.lili.modules.wallet.entity.dto.MemberWithdrawalMessage) MemberWithdrawApply(cn.lili.modules.wallet.entity.dos.MemberWithdrawApply) ServiceException(cn.lili.common.exception.ServiceException) WithdrawalSetting(cn.lili.modules.system.entity.dto.WithdrawalSetting) MemberWalletVO(cn.lili.modules.wallet.entity.vo.MemberWalletVO) WithdrawalSetting(cn.lili.modules.system.entity.dto.WithdrawalSetting) Setting(cn.lili.modules.system.entity.dos.Setting) Gson(com.google.gson.Gson) AuthUser(cn.lili.common.security.AuthUser) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with AuthUser

use of cn.lili.common.security.AuthUser in project lilishop by lilishop.

the class ManagerTokenGenerate method createToken.

@Override
public Token createToken(AdminUser adminUser, Boolean longTerm) {
    AuthUser authUser = new AuthUser(adminUser.getUsername(), adminUser.getId(), adminUser.getAvatar(), UserEnums.MANAGER, adminUser.getNickName(), adminUser.getIsSuper());
    List<UserMenuVO> userMenuVOList = roleMenuService.findAllMenu(authUser.getId());
    // 缓存权限列表
    cache.put(CachePrefix.PERMISSION_LIST.getPrefix(UserEnums.MANAGER) + authUser.getId(), this.permissionList(userMenuVOList));
    return tokenUtil.createToken(adminUser.getUsername(), authUser, longTerm, UserEnums.MANAGER);
}
Also used : UserMenuVO(cn.lili.modules.permission.entity.vo.UserMenuVO) AuthUser(cn.lili.common.security.AuthUser)

Aggregations

AuthUser (cn.lili.common.security.AuthUser)79 ServiceException (cn.lili.common.exception.ServiceException)32 ApiOperation (io.swagger.annotations.ApiOperation)28 Member (cn.lili.modules.member.entity.dos.Member)11 Transactional (org.springframework.transaction.annotation.Transactional)9 ConnectAuthUser (cn.lili.modules.connect.entity.dto.ConnectAuthUser)6 ApiImplicitParams (io.swagger.annotations.ApiImplicitParams)6 ArrayList (java.util.ArrayList)6 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)5 Goods (cn.lili.modules.goods.entity.dos.Goods)4 FreightTemplate (cn.lili.modules.store.entity.dos.FreightTemplate)4 Store (cn.lili.modules.store.entity.dos.Store)4 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)4 Gson (com.google.gson.Gson)4 BCryptPasswordEncoder (org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder)4 GetMapping (org.springframework.web.bind.annotation.GetMapping)4 GoodsSku (cn.lili.modules.goods.entity.dos.GoodsSku)3 TradeDTO (cn.lili.modules.order.cart.entity.dto.TradeDTO)3 AdminUser (cn.lili.modules.permission.entity.dos.AdminUser)3 KanjiaActivity (cn.lili.modules.promotion.entity.dos.KanjiaActivity)3