包含完整功能模块: - 设备激活(直销激活码模式 + 代销免激活码模式) - 微信支付 + 天卡订单 - 天卡池管理 + 异步橘视厅SDK激活 - 第三方合作伙伴接口(代销模式) - 签名鉴权(appKey/appSecret + nonce防重放) - 天卡消耗(事务 + 幂等 + 并发控制) - 媒资接口(三级授权过滤) - 审计日志 - 定价策略(3层:门店 > 渠道 > 平台) - 分账(微信分账 + 分润规则) - Docker部署(含Redis容器)
91 lines
2.8 KiB
Java
91 lines
2.8 KiB
Java
package io.as.modules.openapi.controller;
|
|
|
|
import io.as.common.annotation.AuditAction;
|
|
import io.as.common.exception.ASException;
|
|
import io.as.common.utils.PageUtils;
|
|
import io.as.common.utils.R;
|
|
import io.as.modules.openapi.service.PartnerCardPoolService;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* 合作伙伴天卡池(代销)
|
|
*/
|
|
@Api(tags = "合作伙伴天卡池(代销)")
|
|
@RestController
|
|
@RequestMapping("/manage/partner-card")
|
|
public class PartnerCardPurchaseController {
|
|
|
|
@Autowired
|
|
private PartnerCardPoolService partnerCardPoolService;
|
|
|
|
/**
|
|
* 采购天卡到合作伙伴池子
|
|
*/
|
|
@ApiOperation("采购天卡")
|
|
@AuditAction(value = "PARTNER_CARD_PURCHASE", description = "采购天卡到合作伙伴池子")
|
|
@PostMapping("/purchase")
|
|
public R purchase(@RequestParam("partnerId") String partnerId,
|
|
@RequestParam("quantity") int quantity) {
|
|
if (partnerId == null || partnerId.trim().isEmpty()) {
|
|
throw new ASException("partnerId不能为空");
|
|
}
|
|
if (quantity <= 0) {
|
|
throw new ASException("quantity必须大于0");
|
|
}
|
|
int purchased = partnerCardPoolService.purchase(partnerId, quantity);
|
|
Map<String, Object> data = new HashMap<>();
|
|
data.put("purchased", purchased);
|
|
return R.dataSuccess(data);
|
|
}
|
|
|
|
/**
|
|
* 库存查询
|
|
*/
|
|
@ApiOperation("库存查询")
|
|
@GetMapping("/stock")
|
|
public R stock(@RequestParam("partnerId") String partnerId) {
|
|
int count = partnerCardPoolService.getAvailableCount(partnerId);
|
|
Map<String, Object> data = new HashMap<>();
|
|
data.put("available", count);
|
|
return R.dataSuccess(data);
|
|
}
|
|
|
|
/**
|
|
* 分页查询池子记录
|
|
*/
|
|
@ApiOperation("分页查询池子记录")
|
|
@GetMapping("/list")
|
|
public R list(@RequestParam Map<String, Object> params) {
|
|
PageUtils page = partnerCardPoolService.queryPage(params);
|
|
Map<String, Object> data = new HashMap<>();
|
|
data.put("page", page);
|
|
return R.dataSuccess(data);
|
|
}
|
|
|
|
/**
|
|
* 回退天卡:把partner池子里未消耗(AVAILABLE)的天卡回退到平台天卡池
|
|
*/
|
|
@ApiOperation("回退天卡")
|
|
@AuditAction(value = "PARTNER_CARD_REVERT", description = "回退天卡到平台池子")
|
|
@PostMapping("/revert")
|
|
public R revert(@RequestParam("partnerId") String partnerId,
|
|
@RequestParam("quantity") int quantity) {
|
|
if (partnerId == null || partnerId.trim().isEmpty()) {
|
|
throw new ASException("partnerId不能为空");
|
|
}
|
|
if (quantity <= 0) {
|
|
throw new ASException("回退数量必须大于0");
|
|
}
|
|
int reverted = partnerCardPoolService.revert(partnerId, quantity);
|
|
Map<String, Object> data = new HashMap<>();
|
|
data.put("reverted", reverted);
|
|
return R.dataSuccess(data);
|
|
}
|
|
}
|