Search in sources :

Example 1 with Setting

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;
}
Also used : KuaidiSetting(cn.lili.modules.system.entity.dto.KuaidiSetting) ServiceException(cn.lili.common.exception.ServiceException) HashMap(java.util.HashMap) Traces(cn.lili.modules.system.entity.vo.Traces) KuaidiSetting(cn.lili.modules.system.entity.dto.KuaidiSetting) Setting(cn.lili.modules.system.entity.dos.Setting) Gson(com.google.gson.Gson) HashMap(java.util.HashMap) Map(java.util.Map) Logistics(cn.lili.modules.system.entity.dos.Logistics)

Example 2 with Setting

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);
}
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 3 with Setting

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);
    }
}
Also used : ServiceException(cn.lili.common.exception.ServiceException) DistributionSetting(cn.lili.modules.system.entity.dto.DistributionSetting) Distribution(cn.lili.modules.distribution.entity.dos.Distribution) DistributionSetting(cn.lili.modules.system.entity.dto.DistributionSetting) Setting(cn.lili.modules.system.entity.dos.Setting)

Example 4 with Setting

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;
}
Also used : ServiceException(cn.lili.common.exception.ServiceException) OssSetting(cn.lili.modules.system.entity.dto.OssSetting) Setting(cn.lili.modules.system.entity.dos.Setting) OssSetting(cn.lili.modules.system.entity.dto.OssSetting) Gson(com.google.gson.Gson)

Example 5 with Setting

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;
}
Also used : GoodsGallery(cn.lili.modules.goods.entity.dos.GoodsGallery) GoodsSetting(cn.lili.modules.system.entity.dto.GoodsSetting) Setting(cn.lili.modules.system.entity.dos.Setting) GoodsSetting(cn.lili.modules.system.entity.dto.GoodsSetting)

Aggregations

Setting (cn.lili.modules.system.entity.dos.Setting)29 ServiceException (cn.lili.common.exception.ServiceException)19 Gson (com.google.gson.Gson)10 WechatConnectSetting (cn.lili.modules.system.entity.dto.connect.WechatConnectSetting)5 OrderSetting (cn.lili.modules.system.entity.dto.OrderSetting)4 DateTime (cn.hutool.core.date.DateTime)3 Seckill (cn.lili.modules.promotion.entity.dos.Seckill)3 DistributionSetting (cn.lili.modules.system.entity.dto.DistributionSetting)3 SeckillSetting (cn.lili.modules.system.entity.dto.SeckillSetting)3 QQConnectSetting (cn.lili.modules.system.entity.dto.connect.QQConnectSetting)3 WechatConnectSettingItem (cn.lili.modules.system.entity.dto.connect.dto.WechatConnectSettingItem)3 AlipayPaymentSetting (cn.lili.modules.system.entity.dto.payment.AlipayPaymentSetting)3 PaymentSupportSetting (cn.lili.modules.system.entity.dto.payment.PaymentSupportSetting)3 WechatPaymentSetting (cn.lili.modules.system.entity.dto.payment.WechatPaymentSetting)3 JSONObject (cn.hutool.json.JSONObject)2 AuthUser (cn.lili.common.security.AuthUser)2 Distribution (cn.lili.modules.distribution.entity.dos.Distribution)2 Order (cn.lili.modules.order.order.entity.dos.Order)2 GoodsSetting (cn.lili.modules.system.entity.dto.GoodsSetting)2 SmsSetting (cn.lili.modules.system.entity.dto.SmsSetting)2