后台划拨福利积分: 用户到用户
This commit is contained in:
@@ -1,37 +0,0 @@
|
|||||||
package org.springblade.modules.common.manager;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import org.springblade.modules.common.eums.BenefitPointSourceType;
|
|
||||||
import org.springblade.modules.market.pojo.dto.MarketBenefitPointApiDTO;
|
|
||||||
import org.springblade.modules.common.request.GiveBenefitPointRequest;
|
|
||||||
import org.springblade.modules.market.service.IMarketBenefitPointService;
|
|
||||||
import org.springblade.modules.system.pojo.entity.User;
|
|
||||||
import org.springblade.modules.system.service.IUserService;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.util.Assert;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class CommonUserPointManager {
|
|
||||||
|
|
||||||
private final IMarketBenefitPointService commonBenefitPointService;
|
|
||||||
private final IUserService userService;
|
|
||||||
|
|
||||||
public boolean giveBenefitPoint(GiveBenefitPointRequest request) {
|
|
||||||
User user = userService.getById(request.getId());
|
|
||||||
Assert.notNull(user , "用户不存在或已注销");
|
|
||||||
Assert.isTrue(request.getAmount().compareTo(BigDecimal.ZERO) > 0, "划拨福利积分必须大于0");
|
|
||||||
|
|
||||||
MarketBenefitPointApiDTO dto = new MarketBenefitPointApiDTO();
|
|
||||||
dto.setUserId(user.getId())
|
|
||||||
.setAmount(request.getAmount())
|
|
||||||
.setFee(BigDecimal.ZERO)
|
|
||||||
.setSourceType(BenefitPointSourceType.BACKEND_TRANSFER)
|
|
||||||
.setSourceId(request.getId())
|
|
||||||
.setSourceDetail("后台划拨福利积分")
|
|
||||||
.setRemark(request.getRemark());
|
|
||||||
return commonBenefitPointService.addBenefitPoint(dto);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,6 +9,7 @@ import java.math.BigDecimal;
|
|||||||
public class GiveBenefitPointRequest implements Serializable {
|
public class GiveBenefitPointRequest implements Serializable {
|
||||||
|
|
||||||
private Long id;
|
private Long id;
|
||||||
|
private String account;
|
||||||
private BigDecimal amount;
|
private BigDecimal amount;
|
||||||
private String remark;
|
private String remark;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import org.springblade.core.mp.support.Condition;
|
|||||||
import org.springblade.core.mp.support.Query;
|
import org.springblade.core.mp.support.Query;
|
||||||
import org.springblade.core.tool.api.R;
|
import org.springblade.core.tool.api.R;
|
||||||
import org.springblade.core.tool.utils.Func;
|
import org.springblade.core.tool.utils.Func;
|
||||||
import org.springblade.modules.common.manager.CommonUserPointManager;
|
import org.springblade.modules.market.manager.MarketUserPointManager;
|
||||||
import org.springblade.modules.common.request.GiveBenefitPointRequest;
|
import org.springblade.modules.common.request.GiveBenefitPointRequest;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
@@ -36,8 +36,8 @@ import java.util.Map;
|
|||||||
@Tag(name = "用户福利值表", description = "用户福利值表接口")
|
@Tag(name = "用户福利值表", description = "用户福利值表接口")
|
||||||
public class MarketBenefitPointController extends BladeController {
|
public class MarketBenefitPointController extends BladeController {
|
||||||
|
|
||||||
private final IMarketBenefitPointService commonBenefitPointService;
|
private final IMarketBenefitPointService marketBenefitPointService;
|
||||||
private final CommonUserPointManager commonUserPointManager;
|
private final MarketUserPointManager marketUserPointManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户福利值表 详情
|
* 用户福利值表 详情
|
||||||
@@ -46,7 +46,7 @@ public class MarketBenefitPointController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 1)
|
@ApiOperationSupport(order = 1)
|
||||||
@Operation(summary = "详情", description = "传入commonBenefitPoint")
|
@Operation(summary = "详情", description = "传入commonBenefitPoint")
|
||||||
public R<MarketBenefitPointVO> detail(MarketBenefitPointEntity commonBenefitPoint) {
|
public R<MarketBenefitPointVO> detail(MarketBenefitPointEntity commonBenefitPoint) {
|
||||||
MarketBenefitPointEntity detail = commonBenefitPointService.getOne(Condition.getQueryWrapper(commonBenefitPoint));
|
MarketBenefitPointEntity detail = marketBenefitPointService.getOne(Condition.getQueryWrapper(commonBenefitPoint));
|
||||||
return R.data(MarketBenefitPointWrapper.build().entityVO(detail));
|
return R.data(MarketBenefitPointWrapper.build().entityVO(detail));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -56,7 +56,7 @@ public class MarketBenefitPointController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 2)
|
@ApiOperationSupport(order = 2)
|
||||||
@Operation(summary = "分页", description = "传入commonBenefitPoint")
|
@Operation(summary = "分页", description = "传入commonBenefitPoint")
|
||||||
public R<IPage<MarketBenefitPointVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> commonBenefitPoint, Query query) {
|
public R<IPage<MarketBenefitPointVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> commonBenefitPoint, Query query) {
|
||||||
IPage<MarketBenefitPointEntity> pages = commonBenefitPointService.page(Condition.getPage(query), Condition.getQueryWrapper(commonBenefitPoint, MarketBenefitPointEntity.class));
|
IPage<MarketBenefitPointEntity> pages = marketBenefitPointService.page(Condition.getPage(query), Condition.getQueryWrapper(commonBenefitPoint, MarketBenefitPointEntity.class));
|
||||||
return R.data(MarketBenefitPointWrapper.build().pageVO(pages));
|
return R.data(MarketBenefitPointWrapper.build().pageVO(pages));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ public class MarketBenefitPointController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 3)
|
@ApiOperationSupport(order = 3)
|
||||||
@Operation(summary = "分页", description = "传入commonBenefitPoint")
|
@Operation(summary = "分页", description = "传入commonBenefitPoint")
|
||||||
public R<IPage<MarketBenefitPointVO>> page(MarketBenefitPointVO commonBenefitPoint, Query query) {
|
public R<IPage<MarketBenefitPointVO>> page(MarketBenefitPointVO commonBenefitPoint, Query query) {
|
||||||
IPage<MarketBenefitPointVO> pages = commonBenefitPointService.selectCommonBenefitPointPage(Condition.getPage(query), commonBenefitPoint);
|
IPage<MarketBenefitPointVO> pages = marketBenefitPointService.selectCommonBenefitPointPage(Condition.getPage(query), commonBenefitPoint);
|
||||||
return R.data(pages);
|
return R.data(pages);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ public class MarketBenefitPointController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 4)
|
@ApiOperationSupport(order = 4)
|
||||||
@Operation(summary = "新增", description = "传入commonBenefitPoint")
|
@Operation(summary = "新增", description = "传入commonBenefitPoint")
|
||||||
public R save(@Valid @RequestBody MarketBenefitPointEntity commonBenefitPoint) {
|
public R save(@Valid @RequestBody MarketBenefitPointEntity commonBenefitPoint) {
|
||||||
return R.status(commonBenefitPointService.save(commonBenefitPoint));
|
return R.status(marketBenefitPointService.save(commonBenefitPoint));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,7 +88,7 @@ public class MarketBenefitPointController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 5)
|
@ApiOperationSupport(order = 5)
|
||||||
@Operation(summary = "修改", description = "传入commonBenefitPoint")
|
@Operation(summary = "修改", description = "传入commonBenefitPoint")
|
||||||
public R update(@Valid @RequestBody MarketBenefitPointEntity commonBenefitPoint) {
|
public R update(@Valid @RequestBody MarketBenefitPointEntity commonBenefitPoint) {
|
||||||
return R.status(commonBenefitPointService.updateById(commonBenefitPoint));
|
return R.status(marketBenefitPointService.updateById(commonBenefitPoint));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,7 +98,7 @@ public class MarketBenefitPointController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 6)
|
@ApiOperationSupport(order = 6)
|
||||||
@Operation(summary = "新增或修改", description = "传入commonBenefitPoint")
|
@Operation(summary = "新增或修改", description = "传入commonBenefitPoint")
|
||||||
public R submit(@Valid @RequestBody MarketBenefitPointEntity commonBenefitPoint) {
|
public R submit(@Valid @RequestBody MarketBenefitPointEntity commonBenefitPoint) {
|
||||||
return R.status(commonBenefitPointService.saveOrUpdate(commonBenefitPoint));
|
return R.status(marketBenefitPointService.saveOrUpdate(commonBenefitPoint));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -108,7 +108,7 @@ public class MarketBenefitPointController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 7)
|
@ApiOperationSupport(order = 7)
|
||||||
@Operation(summary = "逻辑删除", description = "传入ids")
|
@Operation(summary = "逻辑删除", description = "传入ids")
|
||||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||||
return R.status(commonBenefitPointService.deleteLogic(Func.toLongList(ids)));
|
return R.status(marketBenefitPointService.deleteLogic(Func.toLongList(ids)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ public class MarketBenefitPointController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 8)
|
@ApiOperationSupport(order = 8)
|
||||||
@Operation(summary = "划拨福利积分", description = "传入request")
|
@Operation(summary = "划拨福利积分", description = "传入request")
|
||||||
public R giveBenefitPoint(@RequestBody GiveBenefitPointRequest request) {
|
public R giveBenefitPoint(@RequestBody GiveBenefitPointRequest request) {
|
||||||
return R.status(commonUserPointManager.giveBenefitPoint(request));
|
return R.status(marketUserPointManager.giveBenefitPoint(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import java.util.Map;
|
|||||||
@Tag(name = "用户福利值流水表", description = "用户福利值流水表接口")
|
@Tag(name = "用户福利值流水表", description = "用户福利值流水表接口")
|
||||||
public class MarketBenefitPointLogController extends BladeController {
|
public class MarketBenefitPointLogController extends BladeController {
|
||||||
|
|
||||||
private final IMarketBenefitPointLogService commonBenefitPointLogService;
|
private final IMarketBenefitPointLogService marketBenefitPointLogService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户福利值流水表 详情
|
* 用户福利值流水表 详情
|
||||||
@@ -42,7 +42,7 @@ public class MarketBenefitPointLogController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 1)
|
@ApiOperationSupport(order = 1)
|
||||||
@Operation(summary = "详情", description = "传入commonBenefitPointLog")
|
@Operation(summary = "详情", description = "传入commonBenefitPointLog")
|
||||||
public R<MarketBenefitPointLogVO> detail(MarketBenefitPointLogEntity commonBenefitPointLog) {
|
public R<MarketBenefitPointLogVO> detail(MarketBenefitPointLogEntity commonBenefitPointLog) {
|
||||||
MarketBenefitPointLogEntity detail = commonBenefitPointLogService.getOne(Condition.getQueryWrapper(commonBenefitPointLog));
|
MarketBenefitPointLogEntity detail = marketBenefitPointLogService.getOne(Condition.getQueryWrapper(commonBenefitPointLog));
|
||||||
return R.data(MarketBenefitPointLogWrapper.build().entityVO(detail));
|
return R.data(MarketBenefitPointLogWrapper.build().entityVO(detail));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -52,7 +52,7 @@ public class MarketBenefitPointLogController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 2)
|
@ApiOperationSupport(order = 2)
|
||||||
@Operation(summary = "分页", description = "传入commonBenefitPointLog")
|
@Operation(summary = "分页", description = "传入commonBenefitPointLog")
|
||||||
public R<IPage<MarketBenefitPointLogVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> commonBenefitPointLog, Query query) {
|
public R<IPage<MarketBenefitPointLogVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> commonBenefitPointLog, Query query) {
|
||||||
IPage<MarketBenefitPointLogEntity> pages = commonBenefitPointLogService.page(Condition.getPage(query), Condition.getQueryWrapper(commonBenefitPointLog, MarketBenefitPointLogEntity.class));
|
IPage<MarketBenefitPointLogEntity> pages = marketBenefitPointLogService.page(Condition.getPage(query), Condition.getQueryWrapper(commonBenefitPointLog, MarketBenefitPointLogEntity.class));
|
||||||
return R.data(MarketBenefitPointLogWrapper.build().pageVO(pages));
|
return R.data(MarketBenefitPointLogWrapper.build().pageVO(pages));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ public class MarketBenefitPointLogController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 3)
|
@ApiOperationSupport(order = 3)
|
||||||
@Operation(summary = "分页", description = "传入commonBenefitPointLog")
|
@Operation(summary = "分页", description = "传入commonBenefitPointLog")
|
||||||
public R<IPage<MarketBenefitPointLogVO>> page(MarketBenefitPointLogVO commonBenefitPointLog, Query query) {
|
public R<IPage<MarketBenefitPointLogVO>> page(MarketBenefitPointLogVO commonBenefitPointLog, Query query) {
|
||||||
IPage<MarketBenefitPointLogVO> pages = commonBenefitPointLogService.selectCommonBenefitPointLogPage(Condition.getPage(query), commonBenefitPointLog);
|
IPage<MarketBenefitPointLogVO> pages = marketBenefitPointLogService.selectCommonBenefitPointLogPage(Condition.getPage(query), commonBenefitPointLog);
|
||||||
return R.data(pages);
|
return R.data(pages);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ public class MarketBenefitPointLogController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 4)
|
@ApiOperationSupport(order = 4)
|
||||||
@Operation(summary = "新增", description = "传入commonBenefitPointLog")
|
@Operation(summary = "新增", description = "传入commonBenefitPointLog")
|
||||||
public R save(@Valid @RequestBody MarketBenefitPointLogEntity commonBenefitPointLog) {
|
public R save(@Valid @RequestBody MarketBenefitPointLogEntity commonBenefitPointLog) {
|
||||||
return R.status(commonBenefitPointLogService.save(commonBenefitPointLog));
|
return R.status(marketBenefitPointLogService.save(commonBenefitPointLog));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,7 +84,7 @@ public class MarketBenefitPointLogController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 5)
|
@ApiOperationSupport(order = 5)
|
||||||
@Operation(summary = "修改", description = "传入commonBenefitPointLog")
|
@Operation(summary = "修改", description = "传入commonBenefitPointLog")
|
||||||
public R update(@Valid @RequestBody MarketBenefitPointLogEntity commonBenefitPointLog) {
|
public R update(@Valid @RequestBody MarketBenefitPointLogEntity commonBenefitPointLog) {
|
||||||
return R.status(commonBenefitPointLogService.updateById(commonBenefitPointLog));
|
return R.status(marketBenefitPointLogService.updateById(commonBenefitPointLog));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -94,7 +94,7 @@ public class MarketBenefitPointLogController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 6)
|
@ApiOperationSupport(order = 6)
|
||||||
@Operation(summary = "新增或修改", description = "传入commonBenefitPointLog")
|
@Operation(summary = "新增或修改", description = "传入commonBenefitPointLog")
|
||||||
public R submit(@Valid @RequestBody MarketBenefitPointLogEntity commonBenefitPointLog) {
|
public R submit(@Valid @RequestBody MarketBenefitPointLogEntity commonBenefitPointLog) {
|
||||||
return R.status(commonBenefitPointLogService.saveOrUpdate(commonBenefitPointLog));
|
return R.status(marketBenefitPointLogService.saveOrUpdate(commonBenefitPointLog));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,7 +104,7 @@ public class MarketBenefitPointLogController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 7)
|
@ApiOperationSupport(order = 7)
|
||||||
@Operation(summary = "逻辑删除", description = "传入ids")
|
@Operation(summary = "逻辑删除", description = "传入ids")
|
||||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||||
return R.status(commonBenefitPointLogService.deleteLogic(Func.toLongList(ids)));
|
return R.status(marketBenefitPointLogService.deleteLogic(Func.toLongList(ids)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import java.util.Map;
|
|||||||
@Tag(name = "用户现金券表", description = "用户现金券表接口")
|
@Tag(name = "用户现金券表", description = "用户现金券表接口")
|
||||||
public class MarketCashCouponController extends BladeController {
|
public class MarketCashCouponController extends BladeController {
|
||||||
|
|
||||||
private final IMarketCashCouponService commonCashCouponService;
|
private final IMarketCashCouponService marketCashCouponService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户现金券表 详情
|
* 用户现金券表 详情
|
||||||
@@ -42,7 +42,7 @@ public class MarketCashCouponController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 1)
|
@ApiOperationSupport(order = 1)
|
||||||
@Operation(summary = "详情", description = "传入commonCashCoupon")
|
@Operation(summary = "详情", description = "传入commonCashCoupon")
|
||||||
public R<MarketCashCouponVO> detail(MarketCashCouponEntity commonCashCoupon) {
|
public R<MarketCashCouponVO> detail(MarketCashCouponEntity commonCashCoupon) {
|
||||||
MarketCashCouponEntity detail = commonCashCouponService.getOne(Condition.getQueryWrapper(commonCashCoupon));
|
MarketCashCouponEntity detail = marketCashCouponService.getOne(Condition.getQueryWrapper(commonCashCoupon));
|
||||||
return R.data(MarketCashCouponWrapper.build().entityVO(detail));
|
return R.data(MarketCashCouponWrapper.build().entityVO(detail));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -52,7 +52,7 @@ public class MarketCashCouponController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 2)
|
@ApiOperationSupport(order = 2)
|
||||||
@Operation(summary = "分页", description = "传入commonCashCoupon")
|
@Operation(summary = "分页", description = "传入commonCashCoupon")
|
||||||
public R<IPage<MarketCashCouponVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> commonCashCoupon, Query query) {
|
public R<IPage<MarketCashCouponVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> commonCashCoupon, Query query) {
|
||||||
IPage<MarketCashCouponEntity> pages = commonCashCouponService.page(Condition.getPage(query), Condition.getQueryWrapper(commonCashCoupon, MarketCashCouponEntity.class));
|
IPage<MarketCashCouponEntity> pages = marketCashCouponService.page(Condition.getPage(query), Condition.getQueryWrapper(commonCashCoupon, MarketCashCouponEntity.class));
|
||||||
return R.data(MarketCashCouponWrapper.build().pageVO(pages));
|
return R.data(MarketCashCouponWrapper.build().pageVO(pages));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ public class MarketCashCouponController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 3)
|
@ApiOperationSupport(order = 3)
|
||||||
@Operation(summary = "分页", description = "传入commonCashCoupon")
|
@Operation(summary = "分页", description = "传入commonCashCoupon")
|
||||||
public R<IPage<MarketCashCouponVO>> page(MarketCashCouponVO commonCashCoupon, Query query) {
|
public R<IPage<MarketCashCouponVO>> page(MarketCashCouponVO commonCashCoupon, Query query) {
|
||||||
IPage<MarketCashCouponVO> pages = commonCashCouponService.selectCommonCashCouponPage(Condition.getPage(query), commonCashCoupon);
|
IPage<MarketCashCouponVO> pages = marketCashCouponService.selectCommonCashCouponPage(Condition.getPage(query), commonCashCoupon);
|
||||||
return R.data(pages);
|
return R.data(pages);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ public class MarketCashCouponController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 4)
|
@ApiOperationSupport(order = 4)
|
||||||
@Operation(summary = "新增", description = "传入commonCashCoupon")
|
@Operation(summary = "新增", description = "传入commonCashCoupon")
|
||||||
public R save(@Valid @RequestBody MarketCashCouponEntity commonCashCoupon) {
|
public R save(@Valid @RequestBody MarketCashCouponEntity commonCashCoupon) {
|
||||||
return R.status(commonCashCouponService.save(commonCashCoupon));
|
return R.status(marketCashCouponService.save(commonCashCoupon));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,7 +84,7 @@ public class MarketCashCouponController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 5)
|
@ApiOperationSupport(order = 5)
|
||||||
@Operation(summary = "修改", description = "传入commonCashCoupon")
|
@Operation(summary = "修改", description = "传入commonCashCoupon")
|
||||||
public R update(@Valid @RequestBody MarketCashCouponEntity commonCashCoupon) {
|
public R update(@Valid @RequestBody MarketCashCouponEntity commonCashCoupon) {
|
||||||
return R.status(commonCashCouponService.updateById(commonCashCoupon));
|
return R.status(marketCashCouponService.updateById(commonCashCoupon));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -94,7 +94,7 @@ public class MarketCashCouponController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 6)
|
@ApiOperationSupport(order = 6)
|
||||||
@Operation(summary = "新增或修改", description = "传入commonCashCoupon")
|
@Operation(summary = "新增或修改", description = "传入commonCashCoupon")
|
||||||
public R submit(@Valid @RequestBody MarketCashCouponEntity commonCashCoupon) {
|
public R submit(@Valid @RequestBody MarketCashCouponEntity commonCashCoupon) {
|
||||||
return R.status(commonCashCouponService.saveOrUpdate(commonCashCoupon));
|
return R.status(marketCashCouponService.saveOrUpdate(commonCashCoupon));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,7 +104,7 @@ public class MarketCashCouponController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 7)
|
@ApiOperationSupport(order = 7)
|
||||||
@Operation(summary = "逻辑删除", description = "传入ids")
|
@Operation(summary = "逻辑删除", description = "传入ids")
|
||||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||||
return R.status(commonCashCouponService.deleteLogic(Func.toLongList(ids)));
|
return R.status(marketCashCouponService.deleteLogic(Func.toLongList(ids)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import java.util.Map;
|
|||||||
@Tag(name = "用户现金券流水表", description = "用户现金券流水表接口")
|
@Tag(name = "用户现金券流水表", description = "用户现金券流水表接口")
|
||||||
public class MarketCashCouponLogController extends BladeController {
|
public class MarketCashCouponLogController extends BladeController {
|
||||||
|
|
||||||
private final IMarketCashCouponLogService commonCashCouponLogService;
|
private final IMarketCashCouponLogService marketCashCouponLogService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户现金券流水表 详情
|
* 用户现金券流水表 详情
|
||||||
@@ -42,7 +42,7 @@ public class MarketCashCouponLogController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 1)
|
@ApiOperationSupport(order = 1)
|
||||||
@Operation(summary = "详情", description = "传入commonCashCouponLog")
|
@Operation(summary = "详情", description = "传入commonCashCouponLog")
|
||||||
public R<MarketCashCouponLogVO> detail(MarketCashCouponLogEntity commonCashCouponLog) {
|
public R<MarketCashCouponLogVO> detail(MarketCashCouponLogEntity commonCashCouponLog) {
|
||||||
MarketCashCouponLogEntity detail = commonCashCouponLogService.getOne(Condition.getQueryWrapper(commonCashCouponLog));
|
MarketCashCouponLogEntity detail = marketCashCouponLogService.getOne(Condition.getQueryWrapper(commonCashCouponLog));
|
||||||
return R.data(MarketCashCouponLogWrapper.build().entityVO(detail));
|
return R.data(MarketCashCouponLogWrapper.build().entityVO(detail));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -52,7 +52,7 @@ public class MarketCashCouponLogController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 2)
|
@ApiOperationSupport(order = 2)
|
||||||
@Operation(summary = "分页", description = "传入commonCashCouponLog")
|
@Operation(summary = "分页", description = "传入commonCashCouponLog")
|
||||||
public R<IPage<MarketCashCouponLogVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> commonCashCouponLog, Query query) {
|
public R<IPage<MarketCashCouponLogVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> commonCashCouponLog, Query query) {
|
||||||
IPage<MarketCashCouponLogEntity> pages = commonCashCouponLogService.page(Condition.getPage(query), Condition.getQueryWrapper(commonCashCouponLog, MarketCashCouponLogEntity.class));
|
IPage<MarketCashCouponLogEntity> pages = marketCashCouponLogService.page(Condition.getPage(query), Condition.getQueryWrapper(commonCashCouponLog, MarketCashCouponLogEntity.class));
|
||||||
return R.data(MarketCashCouponLogWrapper.build().pageVO(pages));
|
return R.data(MarketCashCouponLogWrapper.build().pageVO(pages));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ public class MarketCashCouponLogController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 3)
|
@ApiOperationSupport(order = 3)
|
||||||
@Operation(summary = "分页", description = "传入commonCashCouponLog")
|
@Operation(summary = "分页", description = "传入commonCashCouponLog")
|
||||||
public R<IPage<MarketCashCouponLogVO>> page(MarketCashCouponLogVO commonCashCouponLog, Query query) {
|
public R<IPage<MarketCashCouponLogVO>> page(MarketCashCouponLogVO commonCashCouponLog, Query query) {
|
||||||
IPage<MarketCashCouponLogVO> pages = commonCashCouponLogService.selectCommonCashCouponLogPage(Condition.getPage(query), commonCashCouponLog);
|
IPage<MarketCashCouponLogVO> pages = marketCashCouponLogService.selectCommonCashCouponLogPage(Condition.getPage(query), commonCashCouponLog);
|
||||||
return R.data(pages);
|
return R.data(pages);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ public class MarketCashCouponLogController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 4)
|
@ApiOperationSupport(order = 4)
|
||||||
@Operation(summary = "新增", description = "传入commonCashCouponLog")
|
@Operation(summary = "新增", description = "传入commonCashCouponLog")
|
||||||
public R save(@Valid @RequestBody MarketCashCouponLogEntity commonCashCouponLog) {
|
public R save(@Valid @RequestBody MarketCashCouponLogEntity commonCashCouponLog) {
|
||||||
return R.status(commonCashCouponLogService.save(commonCashCouponLog));
|
return R.status(marketCashCouponLogService.save(commonCashCouponLog));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,7 +84,7 @@ public class MarketCashCouponLogController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 5)
|
@ApiOperationSupport(order = 5)
|
||||||
@Operation(summary = "修改", description = "传入commonCashCouponLog")
|
@Operation(summary = "修改", description = "传入commonCashCouponLog")
|
||||||
public R update(@Valid @RequestBody MarketCashCouponLogEntity commonCashCouponLog) {
|
public R update(@Valid @RequestBody MarketCashCouponLogEntity commonCashCouponLog) {
|
||||||
return R.status(commonCashCouponLogService.updateById(commonCashCouponLog));
|
return R.status(marketCashCouponLogService.updateById(commonCashCouponLog));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -94,7 +94,7 @@ public class MarketCashCouponLogController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 6)
|
@ApiOperationSupport(order = 6)
|
||||||
@Operation(summary = "新增或修改", description = "传入commonCashCouponLog")
|
@Operation(summary = "新增或修改", description = "传入commonCashCouponLog")
|
||||||
public R submit(@Valid @RequestBody MarketCashCouponLogEntity commonCashCouponLog) {
|
public R submit(@Valid @RequestBody MarketCashCouponLogEntity commonCashCouponLog) {
|
||||||
return R.status(commonCashCouponLogService.saveOrUpdate(commonCashCouponLog));
|
return R.status(marketCashCouponLogService.saveOrUpdate(commonCashCouponLog));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,7 +104,7 @@ public class MarketCashCouponLogController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 7)
|
@ApiOperationSupport(order = 7)
|
||||||
@Operation(summary = "逻辑删除", description = "传入ids")
|
@Operation(summary = "逻辑删除", description = "传入ids")
|
||||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||||
return R.status(commonCashCouponLogService.deleteLogic(Func.toLongList(ids)));
|
return R.status(marketCashCouponLogService.deleteLogic(Func.toLongList(ids)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package org.springblade.modules.market.manager;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springblade.modules.common.eums.BenefitPointSourceType;
|
||||||
|
import org.springblade.modules.market.pojo.dto.MarketBenefitPointApiDTO;
|
||||||
|
import org.springblade.modules.common.request.GiveBenefitPointRequest;
|
||||||
|
import org.springblade.modules.market.pojo.entity.MarketBenefitPointEntity;
|
||||||
|
import org.springblade.modules.market.service.IMarketBenefitPointService;
|
||||||
|
import org.springblade.modules.system.pojo.entity.User;
|
||||||
|
import org.springblade.modules.system.service.IUserService;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class MarketUserPointManager {
|
||||||
|
|
||||||
|
private final IMarketBenefitPointService marketBenefitPointService;
|
||||||
|
private final IUserService userService;
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = RuntimeException.class)
|
||||||
|
public boolean giveBenefitPoint(GiveBenefitPointRequest request) {
|
||||||
|
User user = userService.getById(request.getId());
|
||||||
|
Assert.notNull(user , "用户不存在或已注销");
|
||||||
|
|
||||||
|
User creditUser = userService.getOne(
|
||||||
|
Wrappers.lambdaQuery(User.class)
|
||||||
|
.eq(User::getAccount, request.getAccount())
|
||||||
|
.eq(User::getUserType, 2)
|
||||||
|
.last("limit 1")
|
||||||
|
);
|
||||||
|
Assert.notNull(creditUser, "划拨用户不存在或已注销");
|
||||||
|
Assert.isTrue(!creditUser.getId().equals(user.getId()), "不能给自己划拨福利积分");
|
||||||
|
|
||||||
|
Assert.isTrue(request.getAmount().compareTo(BigDecimal.ZERO) > 0, "划拨福利积分必须大于0");
|
||||||
|
|
||||||
|
MarketBenefitPointEntity benefitPoint = marketBenefitPointService.getById(user.getId());
|
||||||
|
Assert.isTrue(benefitPoint != null && benefitPoint.getAmount().compareTo(request.getAmount()) >= 0, "福利积分不足");
|
||||||
|
|
||||||
|
MarketBenefitPointApiDTO addDto = new MarketBenefitPointApiDTO();
|
||||||
|
addDto.setUserId(creditUser.getId())
|
||||||
|
.setAmount(request.getAmount())
|
||||||
|
.setFee(BigDecimal.ZERO)
|
||||||
|
.setSourceType(BenefitPointSourceType.BACKEND_TRANSFER)
|
||||||
|
.setSourceId(user.getId())
|
||||||
|
.setSourceDetail("后台划拨福利积分")
|
||||||
|
.setRemark(request.getRemark());
|
||||||
|
|
||||||
|
MarketBenefitPointApiDTO deductDto = new MarketBenefitPointApiDTO();
|
||||||
|
deductDto.setUserId(user.getId())
|
||||||
|
.setAmount(request.getAmount())
|
||||||
|
.setFee(BigDecimal.ZERO)
|
||||||
|
.setSourceType(BenefitPointSourceType.BACKEND_TRANSFER)
|
||||||
|
.setSourceId(user.getId())
|
||||||
|
.setSourceDetail("后台划拨福利积分")
|
||||||
|
.setRemark(request.getRemark());
|
||||||
|
if(marketBenefitPointService.deductBenefitPoint(deductDto)
|
||||||
|
&& marketBenefitPointService.addBenefitPoint(addDto))
|
||||||
|
{
|
||||||
|
return Boolean.TRUE;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new RuntimeException("划拨福利积分失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -78,7 +78,7 @@ public class MarketBenefitPointServiceImpl extends BaseServiceImpl<MarketBenefit
|
|||||||
log.error("扣除福利积分失败, dto: [{}]" , dto);
|
log.error("扣除福利积分失败, dto: [{}]" , dto);
|
||||||
throw new RuntimeException("扣除福利积分失败");
|
throw new RuntimeException("扣除福利积分失败");
|
||||||
}
|
}
|
||||||
return null;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user