初始化天卡开放平台后端项目

包含完整功能模块:
- 设备激活(直销激活码模式 + 代销免激活码模式)
- 微信支付 + 天卡订单
- 天卡池管理 + 异步橘视厅SDK激活
- 第三方合作伙伴接口(代销模式)
  - 签名鉴权(appKey/appSecret + nonce防重放)
  - 天卡消耗(事务 + 幂等 + 并发控制)
  - 媒资接口(三级授权过滤)
  - 审计日志
- 定价策略(3层:门店 > 渠道 > 平台)
- 分账(微信分账 + 分润规则)
- Docker部署(含Redis容器)
This commit is contained in:
zhaogd
2026-07-26 12:34:13 +08:00
commit 30198c7191
349 changed files with 28837 additions and 0 deletions
@@ -0,0 +1,187 @@
package io.as.modules.daycard.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.as.common.exception.ASException;
import io.as.common.utils.PageUtils;
import io.as.common.utils.Query;
import io.as.common.utils.R;
import io.as.modules.daycard.constants.DayCardConstants;
import io.as.modules.daycard.dao.ProfitSharingDetailDao;
import io.as.modules.daycard.dao.ProfitSharingOrderDao;
import io.as.modules.daycard.entity.ProfitSharingDetailEntity;
import io.as.modules.daycard.entity.ProfitSharingOrderEntity;
import io.as.modules.sys.dao.SysOrgDao;
import io.as.modules.sys.entity.SysOrgEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.*;
/**
* 分账记录查询 Controller
*/
@Api(tags = "分账记录查询")
@RestController
@RequestMapping("/manage/profit-sharing")
public class ProfitSharingQueryController {
@Autowired
private ProfitSharingOrderDao profitSharingOrderDao;
@Autowired
private ProfitSharingDetailDao profitSharingDetailDao;
@Autowired
private SysOrgDao sysOrgDao;
/**
* 分页查询分账单(支持 orderNo/status 筛选),返回详情列表
*/
@ApiOperation("分页查询分账单")
@GetMapping("/list")
public R list(@RequestParam Map<String, Object> params) {
IPage<ProfitSharingOrderEntity> page = new Query<ProfitSharingOrderEntity>().getPage(params, "created_at", false);
QueryWrapper<ProfitSharingOrderEntity> wrapper = new QueryWrapper<>();
wrapper.eq("delete_flag", DayCardConstants.DELETE_FLAG_UNDEL);
String orderNo = (String) params.get("orderNo");
if (StringUtils.isNotBlank(orderNo)) {
wrapper.eq("pay_order_no", orderNo);
}
String status = (String) params.get("status");
if (StringUtils.isNotBlank(status)) {
wrapper.eq("status", status);
}
String outOrderNo = (String) params.get("outOrderNo");
if (StringUtils.isNotBlank(outOrderNo)) {
wrapper.eq("out_order_no", outOrderNo);
}
IPage<ProfitSharingOrderEntity> result = profitSharingOrderDao.selectPage(page, wrapper);
// 填充明细列表
for (ProfitSharingOrderEntity order : result.getRecords()) {
QueryWrapper<ProfitSharingDetailEntity> detailWrapper = new QueryWrapper<>();
detailWrapper.eq("sharing_order_id", order.getId());
List<ProfitSharingDetailEntity> details = profitSharingDetailDao.selectList(detailWrapper);
order.setDetails(details);
}
Map<String, Object> data = new HashMap<>();
data.put("page", new PageUtils(result));
return R.dataSuccess(data);
}
/**
* 分账单详情 + details 子表
*/
@ApiOperation("分账单详情")
@GetMapping("/info/{id}")
public R info(@PathVariable("id") Long id) {
ProfitSharingOrderEntity order = profitSharingOrderDao.selectById(id);
if (order == null) {
throw new ASException("分账单不存在");
}
QueryWrapper<ProfitSharingDetailEntity> detailWrapper = new QueryWrapper<>();
detailWrapper.eq("sharing_order_id", id);
List<ProfitSharingDetailEntity> details = profitSharingDetailDao.selectList(detailWrapper);
order.setDetails(details);
Map<String, Object> data = new HashMap<>();
data.put("order", order);
return R.dataSuccess(data);
}
/**
* 统计(参数 startDate, endDate, groupBy)
* 返回: { summary: {totalCount, totalAmount, successCount, successAmount}, groups: [{orgId, orgName, orgType, count, amount}] }
*/
@ApiOperation("分账统计")
@GetMapping("/stats")
public R stats(@RequestParam(value = "startDate", required = false) String startDate,
@RequestParam(value = "endDate", required = false) String endDate,
@RequestParam(value = "groupBy", required = false) String groupBy) {
QueryWrapper<ProfitSharingOrderEntity> wrapper = new QueryWrapper<>();
wrapper.eq("delete_flag", DayCardConstants.DELETE_FLAG_UNDEL);
if (StringUtils.isNotBlank(startDate)) {
wrapper.ge("created_at", startDate + " 00:00:00");
}
if (StringUtils.isNotBlank(endDate)) {
wrapper.le("created_at", endDate + " 23:59:59");
}
List<ProfitSharingOrderEntity> orders = profitSharingOrderDao.selectList(wrapper);
// 汇总
int totalCount = orders.size();
int totalAmount = 0;
int successCount = 0;
int successAmount = 0;
for (ProfitSharingOrderEntity order : orders) {
if (order.getTotalAmount() != null) {
totalAmount += order.getTotalAmount();
}
if (DayCardConstants.SETTLE_STATUS_SUCCESS.equals(order.getStatus())) {
successCount++;
if (order.getTotalAmount() != null) {
successAmount += order.getTotalAmount();
}
}
}
Map<String, Object> summary = new HashMap<>();
summary.put("totalCount", totalCount);
summary.put("totalAmount", totalAmount);
summary.put("successCount", successCount);
summary.put("successAmount", successAmount);
// 分组统计
List<Map<String, Object>> groups = new ArrayList<>();
if (StringUtils.isNotBlank(groupBy) && "org".equals(groupBy)) {
// 按组织分组:查询所有明细,按 orgId 聚合
Map<Long, Map<String, Object>> orgMap = new HashMap<>();
for (ProfitSharingOrderEntity order : orders) {
QueryWrapper<ProfitSharingDetailEntity> detailWrapper = new QueryWrapper<>();
detailWrapper.eq("sharing_order_id", order.getId());
List<ProfitSharingDetailEntity> details = profitSharingDetailDao.selectList(detailWrapper);
for (ProfitSharingDetailEntity detail : details) {
Long orgId = detail.getOrgId();
if (orgId == null) {
continue;
}
Map<String, Object> group = orgMap.get(orgId);
if (group == null) {
group = new HashMap<>();
group.put("orgId", orgId);
group.put("count", 0);
group.put("amount", 0);
group.put("orgRole", detail.getOrgRole());
// 查询组织名称
SysOrgEntity org = sysOrgDao.selectById(orgId);
if (org != null) {
group.put("orgName", org.getName());
group.put("orgType", org.getType());
}
orgMap.put(orgId, group);
}
group.put("count", (Integer) group.get("count") + 1);
if (detail.getAmount() != null) {
group.put("amount", (Integer) group.get("amount") + detail.getAmount());
}
}
}
groups.addAll(orgMap.values());
}
Map<String, Object> result = new HashMap<>();
result.put("summary", summary);
result.put("groups", groups);
return R.dataSuccess(result);
}
}