Search in sources :

Example 1 with YxUser

use of co.yixiang.modules.shop.domain.YxUser in project yshopmall by guchengwuyue.

the class YxStoreCouponUserServiceImpl method queryAll.

@Override
public // @Cacheable
Map<String, Object> queryAll(YxStoreCouponUserQueryCriteria criteria, Pageable pageable) {
    getPage(pageable);
    PageInfo<YxStoreCouponUser> page = new PageInfo<>(queryAll(criteria));
    List<YxStoreCouponUserDto> storeOrderDTOS = generator.convert(page.getList(), YxStoreCouponUserDto.class);
    for (YxStoreCouponUserDto couponUserDTO : storeOrderDTOS) {
        YxUser yxUser = userService.getOne(new LambdaQueryWrapper<YxUser>().eq(YxUser::getUid, couponUserDTO.getUid()));
        if (yxUser == null) {
            couponUserDTO.setNickname("--");
            continue;
        }
        couponUserDTO.setNickname(yxUser.getNickname());
    }
    Map<String, Object> map = new LinkedHashMap<>(2);
    map.put("content", storeOrderDTOS);
    map.put("totalElements", page.getTotal());
    return map;
}
Also used : PageInfo(com.github.pagehelper.PageInfo) YxStoreCouponUserDto(co.yixiang.modules.activity.service.dto.YxStoreCouponUserDto) YxUser(co.yixiang.modules.shop.domain.YxUser) YxStoreCouponUser(co.yixiang.modules.activity.domain.YxStoreCouponUser) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with YxUser

use of co.yixiang.modules.shop.domain.YxUser in project yshopmall by guchengwuyue.

the class YxUserExtractServiceImpl method doExtract.

@Override
public void doExtract(YxUserExtract resources) {
    if (resources.getStatus() == null) {
        throw new BadRequestException("请选择审核状态");
    }
    if (ShopCommonEnum.EXTRACT_0.getValue().equals(resources.getStatus())) {
        throw new BadRequestException("请选择审核状态");
    }
    if (ShopCommonEnum.EXTRACT_MINUS_1.getValue().equals(resources.getStatus())) {
        if (StrUtil.isEmpty(resources.getFailMsg())) {
            throw new BadRequestException("请填写失败原因");
        }
        String mark = "提现失败,退回佣金" + resources.getExtractPrice() + "元";
        YxUserDto userDTO = generator.convert(yxUserService.getOne(new LambdaQueryWrapper<YxUser>().eq(YxUser::getUid, resources.getUid())), YxUserDto.class);
        // 增加流水
        YxUserBill userBill = new YxUserBill();
        userBill.setTitle("提现失败");
        userBill.setUid(resources.getUid());
        userBill.setCategory("now_money");
        userBill.setType("extract");
        userBill.setNumber(resources.getExtractPrice());
        userBill.setLinkId(resources.getId().toString());
        userBill.setBalance(NumberUtil.add(userDTO.getBrokeragePrice(), resources.getExtractPrice()));
        userBill.setMark(mark);
        userBill.setStatus(1);
        userBill.setPm(1);
        billService.save(userBill);
        // 返回提现金额
        yxUserService.incBrokeragePrice(resources.getExtractPrice().doubleValue(), resources.getUid());
        resources.setFailTime(new Date());
    }
    // todo 此处为企业付款,没经过测试
    boolean isTest = true;
    if (!isTest) {
        String openid = this.getUserOpenid(resources.getUid());
        if (StrUtil.isNotBlank(openid)) {
            try {
                payService.entPay(openid, resources.getId().toString(), resources.getRealName(), resources.getExtractPrice().multiply(new BigDecimal(100)).intValue());
            } catch (WxPayException e) {
                throw new BadRequestException(e.getMessage());
            }
        } else {
            throw new BadRequestException("不是微信用户无法退款");
        }
    }
    this.saveOrUpdate(resources);
}
Also used : WxPayException(com.github.binarywang.wxpay.exception.WxPayException) YxUser(co.yixiang.modules.shop.domain.YxUser) BadRequestException(co.yixiang.exception.BadRequestException) YxUserBill(co.yixiang.modules.shop.domain.YxUserBill) Date(java.util.Date) BigDecimal(java.math.BigDecimal) YxUserDto(co.yixiang.modules.shop.service.dto.YxUserDto)

Example 3 with YxUser

use of co.yixiang.modules.shop.domain.YxUser in project yshopmall by guchengwuyue.

the class YxUserServiceImpl method updateMoney.

@Override
@Transactional(rollbackFor = Exception.class)
public void updateMoney(UserMoneyDto param) {
    YxUserDto userDTO = generator.convert(getById(param.getUid()), YxUserDto.class);
    Double newMoney = 0d;
    String mark = "";
    String type = "system_add";
    Integer pm = 1;
    String title = "系统增加余额";
    if (param.getPtype() == 1) {
        mark = "系统增加了" + param.getMoney() + "余额";
        newMoney = NumberUtil.add(userDTO.getNowMoney(), param.getMoney()).doubleValue();
    } else {
        title = "系统减少余额";
        mark = "系统扣除了" + param.getMoney() + "余额";
        type = "system_sub";
        pm = 0;
        newMoney = NumberUtil.sub(userDTO.getNowMoney(), param.getMoney()).doubleValue();
        if (newMoney < 0) {
            newMoney = 0d;
        }
    }
    YxUser user = new YxUser();
    user.setUid(userDTO.getUid());
    user.setNowMoney(BigDecimal.valueOf(newMoney));
    saveOrUpdate(user);
    YxUserBill userBill = new YxUserBill();
    userBill.setUid(userDTO.getUid());
    userBill.setLinkId("0");
    userBill.setPm(pm);
    userBill.setTitle(title);
    userBill.setCategory("now_money");
    userBill.setType(type);
    userBill.setNumber(BigDecimal.valueOf(param.getMoney()));
    userBill.setBalance(BigDecimal.valueOf(newMoney));
    userBill.setMark(mark);
    userBill.setStatus(1);
    yxUserBillService.save(userBill);
}
Also used : YxUser(co.yixiang.modules.shop.domain.YxUser) YxUserBill(co.yixiang.modules.shop.domain.YxUserBill) YxUserDto(co.yixiang.modules.shop.service.dto.YxUserDto) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with YxUser

use of co.yixiang.modules.shop.domain.YxUser in project yshopmall by guchengwuyue.

the class StoreOrderController method getUserOpenid.

/**
 * 获取openid
 * @param uid uid
 * @return String
 */
private String getUserOpenid(Long uid) {
    YxUser yxUser = userService.getById(uid);
    if (yxUser == null) {
        return "";
    }
    WechatUserDto wechatUserDto = yxUser.getWxProfile();
    if (wechatUserDto == null) {
        return "";
    }
    if (StrUtil.isBlank(wechatUserDto.getOpenid())) {
        return "";
    }
    return wechatUserDto.getOpenid();
}
Also used : WechatUserDto(co.yixiang.modules.shop.service.dto.WechatUserDto) YxUser(co.yixiang.modules.shop.domain.YxUser)

Example 5 with YxUser

use of co.yixiang.modules.shop.domain.YxUser in project yshopmall by guchengwuyue.

the class YxUserExtractServiceImpl method getUserOpenid.

/**
 * 获取openid
 * @param uid uid
 * @return String
 */
private String getUserOpenid(Long uid) {
    YxUser yxUser = yxUserService.getById(uid);
    if (yxUser == null) {
        return "";
    }
    WechatUserDto wechatUserDto = yxUser.getWxProfile();
    if (wechatUserDto == null) {
        return "";
    }
    if (StrUtil.isBlank(wechatUserDto.getOpenid())) {
        return "";
    }
    return wechatUserDto.getOpenid();
}
Also used : WechatUserDto(co.yixiang.modules.shop.service.dto.WechatUserDto) YxUser(co.yixiang.modules.shop.domain.YxUser)

Aggregations

YxUser (co.yixiang.modules.shop.domain.YxUser)5 YxUserBill (co.yixiang.modules.shop.domain.YxUserBill)2 WechatUserDto (co.yixiang.modules.shop.service.dto.WechatUserDto)2 YxUserDto (co.yixiang.modules.shop.service.dto.YxUserDto)2 BadRequestException (co.yixiang.exception.BadRequestException)1 YxStoreCouponUser (co.yixiang.modules.activity.domain.YxStoreCouponUser)1 YxStoreCouponUserDto (co.yixiang.modules.activity.service.dto.YxStoreCouponUserDto)1 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)1 WxPayException (com.github.binarywang.wxpay.exception.WxPayException)1 PageInfo (com.github.pagehelper.PageInfo)1 BigDecimal (java.math.BigDecimal)1 Date (java.util.Date)1 LinkedHashMap (java.util.LinkedHashMap)1 Transactional (org.springframework.transaction.annotation.Transactional)1