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;
}
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;
}
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);
}
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);
}
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);
}
Aggregations