package com.nuvole.four.controller.pc; import cn.hutool.core.util.StrUtil; import com.github.pagehelper.PageHelper; import com.nuvole.base.domain.SysUser; import com.nuvole.common.domain.result.CommonResult; import com.nuvole.common.domain.result.PageBean; import com.nuvole.four.client.ShopServiceClient; import com.nuvole.four.contants.Contants; import com.nuvole.four.controller.BaseController; import com.nuvole.four.domain.ActivityDistributeRecord; import com.nuvole.four.domain.ActivityFee; import com.nuvole.four.domain.SysOrg; import com.nuvole.four.domain.dto.ActivityFeeDetailDto; import com.nuvole.four.domain.query.ActivityFeeQuery; import com.nuvole.four.service.ActivityFeeService; import com.nuvole.four.service.impl.ActivityDistributeRecordServiceImpl; import com.nuvole.four.service.impl.SysOrgServiceImpl; import com.nuvole.four.util.SystemUtil; import com.nuvole.util.CommonUtil; import io.swagger.annotations.*; import lombok.RequiredArgsConstructor; import org.springframework.beans.BeanUtils; import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.Date; import java.util.List; import java.util.Map; /** * @Description 费率补贴活动管理 * @Author dqh * @Date 2024-04-13 21:33:08 */ @Api(value = "费率补贴活动管理接口", tags = "费率补贴活动管理接口") @EnableTransactionManagement @RestController @RequestMapping("/v1/four/pc/acitivity/fee") @RequiredArgsConstructor public class ActivityFeeController extends BaseController { private final ActivityFeeService activityFeeService; private final SysOrgServiceImpl sysOrgService; private final ActivityDistributeRecordServiceImpl activityDistributeRecordService; private final ShopServiceClient shopServiceClient; /** * 方法描述:查询费率补贴活动列表 * * @date 2024-04-13 21:46 **/ @ApiOperation(value = "查询列表", notes = "查询列表") @ApiImplicitParams({ @ApiImplicitParam(name = "AcitivityFeeQuery") }) @GetMapping("/getList") public CommonResult getList(@ApiParam(name = "pageNumber", value = "分页页码", required = true) Integer pageNumber, @ApiParam(name = "pageSize", value = "每页展示数", required = true) Integer pageSize) { ActivityFeeQuery copy = CommonUtil.getObjFromReq(ActivityFeeQuery.class); ActivityFeeQuery query = new ActivityFeeQuery(); BeanUtils.copyProperties(copy, query); PageHelper.startPage(pageNumber, pageSize); PageHelper.orderBy("create_time desc"); List list = activityFeeService.getList(query); CommonResult result = new CommonResult<>(new PageBean(list)); CommonResult result1 = new CommonResult<>(); BeanUtils.copyProperties(result, result1); result = result1; return result; } /** * 方法描述: 费率补贴活动添加 * * @date 2024-04-13 21:46 **/ @ApiOperation(value = "添加", notes = "添加") @ApiImplicitParams({ @ApiImplicitParam(name = "AcitivityFee") }) @PostMapping("/add") public CommonResult add() { ActivityFee copy = CommonUtil.getObjFromReq(ActivityFee.class); ActivityFee activityFee = new ActivityFee(); BeanUtils.copyProperties(copy, activityFee); CommonResult result = new CommonResult<>(activityFeeService.addSelective(activityFee)); CommonResult result1 = new CommonResult<>(); BeanUtils.copyProperties(result, result1); result = result1; return result; } /** * 方法描述:根据id查询分配预算详情 * * @date 2024-04-13 22:02 **/ @ApiOperation(value = "查询分配预算详情", notes = "根据id查询分配预算详情") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "主键id") }) @GetMapping("/get") public CommonResult get(Long id) { CommonResult result = new CommonResult(); result = new CommonResult<>(activityFeeService.get(id)); CommonResult result1 = new CommonResult<>(); BeanUtils.copyProperties(result, result1); result = result1; return result; } /** * 方法描述:查询分配额度信息 * **/ @ApiOperation(value = "查询分配额度信息", notes = "查询分配额度信息") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "主键id") }) @GetMapping("/getFeeMsg") public CommonResult getFeeMsg(Long id) { SysUser user = SystemUtil.getLoginUser(Contants.LOGIN_TYPE_PC); CommonResult result = new CommonResult(); //super用户直接查询活动本身 if(user.getLoginName().equalsIgnoreCase("super") && user.getOrgId() == null){ return new CommonResult(activityFeeService.get(id)); } if(user.getOrgId() != null){ SysOrg sysOrg = sysOrgService.getById(user.getOrgId()); //查询机构分配的预算额度 ActivityDistributeRecord record = activityDistributeRecordService.getFeeByCondition(id, sysOrg.getId()); result = new CommonResult<>(record); if(record == null){ //查询活动本身的预算额度 result = new CommonResult<>(activityDistributeRecordService.getActivityFeeByIdAndOrgId(id, sysOrg.getId())); } } CommonResult result1 = new CommonResult<>(); BeanUtils.copyProperties(result, result1); result = result1; return result; } /** * 方法描述: 查询活动详情-活动数据 * * @date 2024-04-15 13:17 **/ @ApiOperation(value = "查询活动详情-活动数据", notes = "查询活动详情-活动数据") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "主键id") }) @GetMapping("/getDetail") public CommonResult getActivityFeeDetail(Long id) { ActivityFeeDetailDto detailDto = activityFeeService.getActivityFeeDetail(id); return new CommonResult<>(detailDto); } /** * 方法描述: 查询活动详情-商户活动数据 * * @date 2024-04-15 16:47 **/ @ApiOperation(value = "查询活动详情-商户活动数据", notes = "查询活动详情-商户活动数据") @GetMapping("/merchantActivityList") public CommonResult merchantActivityList( @ApiParam(name = "orgCode", value = "机构code") String orgCode, @ApiParam(name = "channelId", value = "通道id") Long channelId, @ApiParam(name = "activityId", value = "活动ID", required = true) Long activityId, @ApiParam(name = "startDate", value = "交易时间") Date startDate, @ApiParam(name = "endDate", value = "交易结束时间") Date endDate, @ApiParam(name = "pageNumber", value = "分页页码", required = true) Integer pageNumber, @ApiParam(name = "pageSize", value = "每页展示数", required = true) Integer pageSize) { if(activityId == null){ throw new IllegalArgumentException("活动ID不能为空"); } if(StrUtil.isBlank(orgCode)){ SysUser user = SystemUtil.getLoginUser(Contants.LOGIN_TYPE_PC); orgCode = user.getOrgCode(); } CommonResult> mapResult = shopServiceClient.merchantActivityList(orgCode, channelId, activityId, startDate,endDate, pageNumber, pageSize); return mapResult; } /** * 方法描述: 查询活动详情-商户活动数据-数据汇总 **/ @ApiOperation(value = "查询活动详情-商户活动数据-数据汇总", notes = "查询活动详情-商户活动数据-数据汇总") @GetMapping("/merchantActivityCollect") public CommonResult merchantActivityCollect( @ApiParam(name = "orgCode", value = "机构code") String orgCode, @ApiParam(name = "channelId", value = "通道id") Long channelId, @ApiParam(name = "activityId", value = "活动ID", required = true) Long activityId, @ApiParam(name = "startDate", value = "交易开始时间") Date startDate, @ApiParam(name = "endDate", value = "交易结束时间") Date endDate) { if(activityId == null){ throw new IllegalArgumentException("活动ID不能为空"); } if(StrUtil.isBlank(orgCode)){ SysUser user = SystemUtil.getLoginUser(Contants.LOGIN_TYPE_PC); orgCode = user.getOrgCode(); } CommonResult mapResult = shopServiceClient.merchantActivityCollect(orgCode, channelId, activityId, startDate,endDate); return mapResult; } /** * 方法描述: 编辑费率补贴活动 * * @date 2024-04-13 22:01 **/ @ApiOperation(value = "修改", notes = "修改") @ApiImplicitParams({ @ApiImplicitParam(name = "AcitivityFee") }) @PostMapping("/upd") public CommonResult upd() { ActivityFee copy = CommonUtil.getObjFromReq(ActivityFee.class); ActivityFee activityFee = new ActivityFee(); BeanUtils.copyProperties(copy, activityFee); CommonResult result = new CommonResult<>(activityFeeService.editSelective(activityFee)); CommonResult result1 = new CommonResult<>(); BeanUtils.copyProperties(result, result1); result = result1; return result; } /** * 方法描述: 删除费率补贴活动 * * @date 2024-04-13 22:01 **/ @ApiOperation(value = "删除", notes = "删除") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "主键id") }) @PostMapping("/del") public CommonResult del(Long id) { CommonResult result = new CommonResult<>(activityFeeService.del(id)); CommonResult result1 = new CommonResult<>(); BeanUtils.copyProperties(result, result1); result = result1; return result; } /** * 方法描述: 开始/停止 * 同步停止活动表、商户活动表、机构预算分配表 * * @date 2024-04-14 15:55 **/ @ApiOperation(value = "开始/停止", notes = "开始/停止") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "主键id"), @ApiImplicitParam(name = "status", value = "状态;1=开始 2=停止(结束)")}) @PostMapping("/startOrStop") public CommonResult startOrStop(Long id,Integer status) { CommonResult result = new CommonResult<>(activityFeeService.startOrStop(id,status)); CommonResult result1 = new CommonResult<>(); BeanUtils.copyProperties(result, result1); result = result1; return result; } }