2024-12-09 16:53:29 +08:00
|
|
|
|
package com.ai.da.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-12-23 14:31:48 +08:00
|
|
|
|
import com.ai.da.common.response.PageBaseResponse;
|
2024-12-09 16:53:29 +08:00
|
|
|
|
import com.ai.da.common.response.Response;
|
|
|
|
|
|
import com.ai.da.model.dto.AffiliateQueryDTO;
|
2025-08-19 17:44:34 +08:00
|
|
|
|
import com.ai.da.model.dto.EditReferralDTO;
|
|
|
|
|
|
import com.ai.da.model.dto.ReferralPageQueryDTO;
|
2024-12-16 10:26:02 +08:00
|
|
|
|
import com.ai.da.model.vo.AffiliateInvitationDetailsVO;
|
2024-12-09 16:53:29 +08:00
|
|
|
|
import com.ai.da.model.vo.AffiliateVO;
|
2025-08-19 17:44:34 +08:00
|
|
|
|
import com.ai.da.model.vo.ReferralPageQueryVO;
|
2024-12-09 16:53:29 +08:00
|
|
|
|
import com.ai.da.service.AffiliateService;
|
2025-08-19 17:44:34 +08:00
|
|
|
|
import com.ai.da.service.ReferralService;
|
2024-12-09 16:53:29 +08:00
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
2024-12-16 10:26:02 +08:00
|
|
|
|
import io.swagger.annotations.Api;
|
2024-12-09 16:53:29 +08:00
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
2025-08-19 17:44:34 +08:00
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
2024-12-09 16:53:29 +08:00
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
import javax.validation.Valid;
|
2025-08-19 17:44:34 +08:00
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
import java.util.List;
|
2024-12-09 16:53:29 +08:00
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
|
@RestController
|
|
|
|
|
|
@RequestMapping("/api/affiliate")
|
2024-12-16 10:26:02 +08:00
|
|
|
|
@Api(tags = "Affiliate模块")
|
2024-12-09 16:53:29 +08:00
|
|
|
|
public class AffiliateController {
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
private AffiliateService affiliateService;
|
|
|
|
|
|
|
2025-08-19 17:44:34 +08:00
|
|
|
|
@Resource
|
|
|
|
|
|
private ReferralService referralService;
|
|
|
|
|
|
|
2024-12-09 16:53:29 +08:00
|
|
|
|
@ApiOperation(value = "注册成为affiliate")
|
|
|
|
|
|
@GetMapping("/registration")
|
2024-12-18 11:53:41 +08:00
|
|
|
|
public Response<Boolean> completeGuidance(@RequestParam(value = "promotionMethod", required = false) String promotionMethod) {
|
2024-12-09 16:53:29 +08:00
|
|
|
|
return Response.success(affiliateService.registerAsAnAffiliate(promotionMethod));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "获取affiliate列表")
|
|
|
|
|
|
@PostMapping("/list")
|
2024-12-23 14:31:48 +08:00
|
|
|
|
public Response<PageBaseResponse<AffiliateVO>> getAffiliateList(@Valid @RequestBody AffiliateQueryDTO affiliateQueryDTO) {
|
2024-12-09 16:53:29 +08:00
|
|
|
|
return Response.success(affiliateService.getAffiliateList(affiliateQueryDTO));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "获取affiliate个人中心")
|
|
|
|
|
|
@GetMapping("/personalCenter")
|
|
|
|
|
|
public Response<AffiliateVO> personalAffiliateCenter() {
|
|
|
|
|
|
return Response.success(affiliateService.personalAffiliateCenter());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-18 11:53:41 +08:00
|
|
|
|
@ApiOperation(value = "获取个人佣金图表数据")
|
|
|
|
|
|
@GetMapping("/getPersonalMonthlyIncome")
|
2025-08-19 17:44:34 +08:00
|
|
|
|
public Response<BigDecimal[]> getPersonalMonthlyIncome(@RequestParam("year")int year) {
|
2024-12-18 11:53:41 +08:00
|
|
|
|
return Response.success(affiliateService.getPersonalMonthlyIncome(year));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-09 16:53:29 +08:00
|
|
|
|
@ApiOperation(value = "审批affiliate申请")
|
|
|
|
|
|
@GetMapping("/approval")
|
2025-04-28 14:40:42 +08:00
|
|
|
|
public Response<Boolean> applicationApproval(@RequestParam("id") Long id,
|
|
|
|
|
|
@RequestParam("isApproved")Boolean isApproved,
|
|
|
|
|
|
@RequestParam("commission") Float commission) {
|
|
|
|
|
|
return Response.success(affiliateService.applicationApproval(id, isApproved, commission));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "更新佣金比例")
|
|
|
|
|
|
@GetMapping("/updateCommission")
|
|
|
|
|
|
public Response<String> updateCommissionPercentage(@RequestParam("id") Long id, @RequestParam("commission") Float commission) {
|
|
|
|
|
|
affiliateService.updateCommissionPercentage(id, commission);
|
|
|
|
|
|
return Response.success("success");
|
2024-12-09 16:53:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-18 11:53:41 +08:00
|
|
|
|
/*@ApiOperation(value = "定时计算佣金")
|
2024-12-09 16:53:29 +08:00
|
|
|
|
@GetMapping("/testTask")
|
|
|
|
|
|
public Response<String> testTask() {
|
|
|
|
|
|
affiliateService.updateAffiliateInfoWithPayment();
|
|
|
|
|
|
return Response.success("success ");
|
2024-12-18 11:53:41 +08:00
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
/*@ApiOperation(value = "每月发送结算邮件")
|
|
|
|
|
|
@GetMapping("/commissionCalculation")
|
2025-02-04 15:29:22 +08:00
|
|
|
|
public Response<String> commissionCalculation(@RequestParam("year") Integer year, @RequestParam("month") Integer month) {
|
|
|
|
|
|
affiliateService.commissionCalculation(year, month);
|
2024-12-18 11:53:41 +08:00
|
|
|
|
return Response.success("success ");
|
|
|
|
|
|
}*/
|
2024-12-09 16:53:29 +08:00
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "affiliate链接浏览量增加")
|
|
|
|
|
|
@GetMapping("/viewsIncrease")
|
|
|
|
|
|
public Response<Boolean> viewsGet(@RequestParam("id") Long id) {
|
|
|
|
|
|
return Response.success(affiliateService.affiliateLinkViewsIncrease(id));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-16 10:26:02 +08:00
|
|
|
|
@ApiOperation(value = "获取每个affiliate产生的收入")
|
2024-12-18 11:53:41 +08:00
|
|
|
|
@PostMapping("/getEachAffiliateGeneratedRevenue")
|
2025-08-19 17:44:34 +08:00
|
|
|
|
public Response<IPage<AffiliateInvitationDetailsVO>> getEachAffiliateGeneratedRevenue(@Validated @RequestBody AffiliateQueryDTO affiliateQueryDTO) {
|
2024-12-18 11:53:41 +08:00
|
|
|
|
return Response.success(affiliateService.getEachAffiliateGeneratedRevenue(affiliateQueryDTO));
|
2024-12-16 10:26:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-19 17:44:34 +08:00
|
|
|
|
@ApiOperation(value = "获取所有的referral")
|
|
|
|
|
|
@PostMapping("/getReferrals")
|
|
|
|
|
|
public Response<IPage<ReferralPageQueryVO>> getReferrals(@RequestBody ReferralPageQueryDTO referralPageQueryDTO) {
|
|
|
|
|
|
return Response.success(referralService.queryByPage(referralPageQueryDTO));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "编辑单个referral")
|
|
|
|
|
|
@PostMapping("/editReferral")
|
|
|
|
|
|
public Response<String> editReferral(@Validated @RequestBody EditReferralDTO editReferralDTO) {
|
|
|
|
|
|
referralService.editReferral(editReferralDTO);
|
|
|
|
|
|
return Response.success();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "(批量)删除referral")
|
|
|
|
|
|
@PostMapping("/batchDeleteReferral")
|
|
|
|
|
|
public Response<String> batchDeleteReferral(@RequestBody List<Long> idList) {
|
|
|
|
|
|
referralService.deleteReferral(idList);
|
|
|
|
|
|
return Response.success();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-09 16:53:29 +08:00
|
|
|
|
|
|
|
|
|
|
}
|