|
|
@@ -1,5 +1,6 @@
|
|
|
package org.springblade.gateway.goods_gateway.controller;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
@@ -13,12 +14,16 @@ import org.springblade.gateway.goods_gateway.util.HelpGoodsUtil;
|
|
|
import org.springblade.payment.cmcc.request.CmccDectOrderRequest;
|
|
|
import org.springblade.payment.cmcc.request.CmccPlaceOrderRequest;
|
|
|
import org.springblade.payment.cmcc.util.CmccUtil;
|
|
|
+import org.springblade.sing.active.entity.ActiveRecord;
|
|
|
+import org.springblade.sing.active.service.IActiveRecordService;
|
|
|
+import org.springblade.sing.goods.entity.HelpGoods;
|
|
|
import org.springblade.sing.goods.service.IHelpGoodsService;
|
|
|
import org.springblade.sing.goods.vo.HelpGoodsVO;
|
|
|
import org.springblade.sing.goods.wrapper.HelpGoodsWrapper;
|
|
|
import org.springblade.sing.point.entity.CmccPointRecord;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.annotation.PostConstruct;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.List;
|
|
|
|
|
|
@@ -36,6 +41,7 @@ import java.util.List;
|
|
|
public class AppHelpGoodsController {
|
|
|
private final AppHelpGoodsService appHelpGoodsService;
|
|
|
private final IHelpGoodsService helpGoodsService;
|
|
|
+ private final IActiveRecordService activeRecordService;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -45,19 +51,19 @@ public class AppHelpGoodsController {
|
|
|
@PostMapping("/exchangeProps")
|
|
|
@ApiOperationSupport(order = 1)
|
|
|
@ApiOperation(value = "兑换道具", notes = "传入pointRecord")
|
|
|
- public R<String> exchangeProps(@ApiParam(value = "道具ID",required = true) @RequestParam Long helpGoodsId,
|
|
|
- @ApiParam(value = "用户ID",required = true) @RequestParam Long userId,
|
|
|
- @ApiParam(value = "购买数量",required = true) @RequestParam BigDecimal num,
|
|
|
- @ApiParam(value = "作品ID",required = true) @RequestParam Long productId,
|
|
|
- CmccDectOrderRequest cmccDectOrderRequest){
|
|
|
+ public R<String> exchangeProps(@ApiParam(value = "道具ID", required = true) @RequestParam Long helpGoodsId,
|
|
|
+ @ApiParam(value = "用户ID", required = true) @RequestParam Long userId,
|
|
|
+ @ApiParam(value = "购买数量", required = true) @RequestParam BigDecimal num,
|
|
|
+ @ApiParam(value = "作品ID", required = true) @RequestParam Long productId,
|
|
|
+ CmccDectOrderRequest cmccDectOrderRequest) {
|
|
|
try {
|
|
|
CmccPointRecord cmccPointRecord = new CmccPointRecord();
|
|
|
cmccPointRecord.setHelpGoodsId(helpGoodsId);
|
|
|
cmccPointRecord.setUserId(userId);
|
|
|
cmccPointRecord.setNum(num);
|
|
|
//加锁
|
|
|
- synchronized (cmccPointRecord.getUserId().toString().intern()){
|
|
|
- appHelpGoodsService.exchangeProps(cmccPointRecord,cmccDectOrderRequest,productId);
|
|
|
+ synchronized (cmccPointRecord.getUserId().toString().intern()) {
|
|
|
+ appHelpGoodsService.exchangeProps(cmccPointRecord, cmccDectOrderRequest, productId);
|
|
|
}
|
|
|
return R.success("兑换成功");
|
|
|
} catch (Exception e) {
|
|
|
@@ -73,12 +79,12 @@ public class AppHelpGoodsController {
|
|
|
@PostMapping("/createPropsOrder")
|
|
|
@ApiOperationSupport(order = 1)
|
|
|
@ApiOperation(value = "创建道具订单", notes = "传入cmccPointRecord")
|
|
|
- public R<String> createPropsOrder(@ApiParam(value = "道具ID",required = true) @RequestParam Long helpGoodsId,
|
|
|
- @ApiParam(value = "用户ID",required = true) @RequestParam Long userId,
|
|
|
- @ApiParam(value = "手机号码",required = true) @RequestParam String phone,
|
|
|
- @ApiParam(value = "购买数量",required = true) @RequestParam BigDecimal num,
|
|
|
- @ApiParam(value = "同盾设备指纹",required = true) @RequestParam String fingerprint,
|
|
|
- @ApiParam(value = "通付盾参数",required = true) @RequestParam String sessionId){
|
|
|
+ public R<String> createPropsOrder(@ApiParam(value = "道具ID", required = true) @RequestParam Long helpGoodsId,
|
|
|
+ @ApiParam(value = "用户ID", required = true) @RequestParam Long userId,
|
|
|
+ @ApiParam(value = "手机号码", required = true) @RequestParam String phone,
|
|
|
+ @ApiParam(value = "购买数量", required = true) @RequestParam BigDecimal num,
|
|
|
+ @ApiParam(value = "同盾设备指纹", required = true) @RequestParam String fingerprint,
|
|
|
+ @ApiParam(value = "通付盾参数", required = true) @RequestParam String sessionId) {
|
|
|
try {
|
|
|
CmccPlaceOrderRequest cmccPlaceOrderRequest = CmccPlaceOrderRequest
|
|
|
.builder()
|
|
|
@@ -107,8 +113,8 @@ public class AppHelpGoodsController {
|
|
|
@PostMapping("/sendCmccSms")
|
|
|
@ApiOperationSupport(order = 1)
|
|
|
@ApiOperation(value = "发送验证码", notes = "传入cmccPlaceOrderRequest")
|
|
|
- public R<String> sendCmccSms(@ApiParam(value = "手机号码",required = true) @RequestParam String mobile,
|
|
|
- @ApiParam(value = "订单号ID",required = true) @RequestParam String outOrderId){
|
|
|
+ public R<String> sendCmccSms(@ApiParam(value = "手机号码", required = true) @RequestParam String mobile,
|
|
|
+ @ApiParam(value = "订单号ID", required = true) @RequestParam String outOrderId) {
|
|
|
try {
|
|
|
CmccPlaceOrderRequest cmccPlaceOrderRequest = CmccPlaceOrderRequest
|
|
|
.builder()
|
|
|
@@ -124,15 +130,27 @@ public class AppHelpGoodsController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 分页 助力商城
|
|
|
+ * 初始化道具缓存(预热)
|
|
|
+ */
|
|
|
+ @PostConstruct
|
|
|
+ public void init() {
|
|
|
+ for (ActiveRecord activeRecord : activeRecordService.list(
|
|
|
+ Wrappers.<ActiveRecord>lambdaQuery().select(ActiveRecord::getId))) {
|
|
|
+ HelpGoodsUtil.setHelpGoodsListCache(activeRecord.getId(),
|
|
|
+ helpGoodsService.list(Wrappers.<HelpGoods>lambdaQuery().eq(HelpGoods::getActiveId, activeRecord.getId())));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取道具助力列表
|
|
|
*/
|
|
|
@GetMapping("/getHelpGoodsList")
|
|
|
@ApiOperationSupport(order = 2)
|
|
|
@ApiOperation(value = "获取道具助力列表", notes = "传入helpGoods")
|
|
|
- public R<List<HelpGoodsVO>> getHelpGoodsList(@ApiParam(value = "活动ID",required = true) @RequestParam Long activeId,
|
|
|
- @ApiParam(value = "用户ID",required = true) @RequestParam Long userId,
|
|
|
- @ApiParam(value = "作品ID",required = true) @RequestParam Long productId) {
|
|
|
- return R.data(HelpGoodsWrapper.build(userId,productId)
|
|
|
+ public R<List<HelpGoodsVO>> getHelpGoodsList(@ApiParam(value = "活动ID", required = true) @RequestParam Long activeId,
|
|
|
+ @ApiParam(value = "用户ID", required = true) @RequestParam Long userId,
|
|
|
+ @ApiParam(value = "作品ID", required = true) @RequestParam Long productId) {
|
|
|
+ return R.data(HelpGoodsWrapper.build(userId, productId)
|
|
|
.listVO(HelpGoodsUtil.getHelpGoodsList(activeId)));
|
|
|
}
|
|
|
}
|