use of cn.lili.modules.system.entity.dos.Setting in project lilishop by lilishop.
the class LogisticsServiceImpl method getOrderTracesByJson.
/**
* 获取物流信息
*
* @param logisticsId 物流公司ID
* @param expNo 物流单号
* @param customerName 手机号后四位
* @return 物流信息
* @throws Exception
*/
private Traces getOrderTracesByJson(String logisticsId, String expNo, String customerName) throws Exception {
Setting setting = settingService.get(SettingEnum.KUAIDI_SETTING.name());
if (CharSequenceUtil.isBlank(setting.getSettingValue())) {
throw new ServiceException(ResultCode.LOGISTICS_NOT_SETTING);
}
KuaidiSetting kuaidiSetting = new Gson().fromJson(setting.getSettingValue(), KuaidiSetting.class);
// ID
String EBusinessID = kuaidiSetting.getEbusinessID();
// KEY
String AppKey = kuaidiSetting.getAppKey();
// 请求url
String ReqURL = kuaidiSetting.getReqURL();
Logistics logistics = this.getById(logisticsId);
if (logistics != null) {
String requestData = "{'OrderCode':'','ShipperCode':'" + logistics.getCode() + "','LogisticCode':'" + expNo + "'" + ",'CustomerName':'" + customerName + "'" + "}";
Map<String, String> params = new HashMap<>(8);
params.put("RequestData", urlEncoder(requestData, "UTF-8"));
params.put("EBusinessID", EBusinessID);
params.put("RequestType", "1002");
String dataSign = encrypt(requestData, AppKey, "UTF-8");
params.put("DataSign", urlEncoder(dataSign, "UTF-8"));
params.put("DataType", "2");
String result = sendPost(ReqURL, params);
Map map = (Map) JSON.parse(result);
return new Traces(logistics.getName(), expNo, (List<Map>) map.get("Traces"));
}
return null;
}
use of cn.lili.modules.system.entity.dos.Setting 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.modules.system.entity.dos.Setting in project lilishop by lilishop.
the class DistributionServiceImpl method bindingDistribution.
@Override
public void bindingDistribution(String distributionId) {
// 判断用户是否登录,未登录不能进行绑定
if (UserContext.getCurrentUser() == null) {
throw new ServiceException(ResultCode.USER_NOT_LOGIN);
}
// 储存分销关系时间
Distribution distribution = this.getById(distributionId);
if (distribution != null) {
Setting setting = settingService.get(SettingEnum.DISTRIBUTION_SETTING.name());
DistributionSetting distributionSetting = JSONUtil.toBean(setting.getSettingValue(), DistributionSetting.class);
cache.put(CachePrefix.DISTRIBUTION.getPrefix() + "_" + UserContext.getCurrentUser().getId(), distribution.getId(), distributionSetting.getDistributionDay().longValue(), TimeUnit.DAYS);
}
}
use of cn.lili.modules.system.entity.dos.Setting in project lilishop by lilishop.
the class AliFileManagerPlugin method getSetting.
/**
* 获取配置
*
* @return
*/
private OssSetting getSetting() {
// 如果没有配置,或者没有下次刷新时间,或者下次刷新时间小于当前时间,则从redis 更新一次
if (ossSetting == null || nextInitSetting == null || nextInitSetting < System.currentTimeMillis()) {
Setting setting = settingService.get(SettingEnum.OSS_SETTING.name());
if (setting == null || StrUtil.isBlank(setting.getSettingValue())) {
throw new ServiceException(ResultCode.OSS_NOT_EXIST);
}
nextInitSetting = System.currentTimeMillis() + INTERVAL;
ossSetting = new Gson().fromJson(setting.getSettingValue(), OssSetting.class);
return ossSetting;
}
return ossSetting;
}
use of cn.lili.modules.system.entity.dos.Setting in project lilishop by lilishop.
the class GoodsGalleryServiceImpl method getGoodsGallery.
@Override
public GoodsGallery getGoodsGallery(String origin) {
GoodsGallery goodsGallery = new GoodsGallery();
// 获取商品系统配置决定是否审核
Setting setting = settingService.get(SettingEnum.GOODS_SETTING.name());
GoodsSetting goodsSetting = JSONUtil.toBean(setting.getSettingValue(), GoodsSetting.class);
// 缩略图
String thumbnail = FileUtil.getUrl(origin, goodsSetting.getAbbreviationPictureWidth(), goodsSetting.getAbbreviationPictureHeight());
// 小图
String small = FileUtil.getUrl(origin, goodsSetting.getSmallPictureWidth(), goodsSetting.getSmallPictureHeight());
// 赋值
goodsGallery.setSmall(small);
goodsGallery.setThumbnail(thumbnail);
goodsGallery.setOriginal(origin);
return goodsGallery;
}
Aggregations