package com.szwl.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.szwl.model.bo.R; import com.szwl.model.bo.ResponseModel; import com.szwl.model.entity.TAdmin; import com.szwl.model.entity.TProportion; import com.szwl.model.entity.TProportionCheck; import com.szwl.service.TAdminService; import com.szwl.service.TEquipmentService; import com.szwl.service.TProportionCheckService; import com.szwl.service.TProportionService; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; 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; /** *

* 分账变动申请表 前端控制器 *

* * @author wuhs * @since 2022-05-10 */ @RestController @RequestMapping("/tProportionCheck") public class TProportionCheckController { @Autowired TProportionCheckService tProportionCheckService; @Autowired TProportionService tProportionService; @Autowired TEquipmentService tEquipmentService; @Autowired TAdminService adminService; @ApiOperation(value = "分销审核信息详情") @PostMapping("/getOne") public ResponseModel findById(Long id) { TAdmin admin = adminService.getById(id); LambdaQueryWrapper query = Wrappers.lambdaQuery(); query.eq(TProportionCheck::getId,id); List list = tProportionCheckService.list(query); if(list.size()>0){ TProportionCheck tProportionCheck = list.get(0); if(tProportionCheck.getAgencyId()!=null){ TAdmin admin1 = adminService.getById(tProportionCheck.getAgencyId()); tProportionCheck.setAgencyName(admin1.getUsername()); } if(tProportionCheck.getMerchantId()!=null){ TAdmin admin2 = adminService.getById(tProportionCheck.getMerchantId()); tProportionCheck.setAgencyName(admin2.getUsername()); } if(tProportionCheck.getPersonageId()!=null){ TAdmin admin3 = adminService.getById(tProportionCheck.getId()); tProportionCheck.setAgencyName(admin3.getUsername()); } return R.ok(tProportionCheck); }else { return R.fail(""); } } @ApiOperation(value = "撤销申请") @PostMapping("/update") public ResponseModel update(Long id) { LambdaQueryWrapper query = Wrappers.lambdaQuery(); query.eq(TProportionCheck::getId,id); List list = tProportionCheckService.list(query); if(list.size()>0){ TProportionCheck tProportionCheck = list.get(0); tProportionCheck.setCheckType("2"); tProportionCheck.setModifyDate(new Date()); tProportionCheckService.updateById(tProportionCheck); return R.ok(); }else { return R.fail("撤销失败"); } } @PostMapping("/getList") public ResponseModel getList(String username, String type) { LambdaQueryWrapper query = Wrappers.lambdaQuery(); if(StringUtils.isNotEmpty(username)){ LambdaQueryWrapper query1 = Wrappers.lambdaQuery(); query1.eq(TAdmin::getUsername,username); List list1 = adminService.list(query1); if(list1.size()>0){ query.eq(TProportionCheck::getAdminId,list1.get(0).getId()); } } if(StringUtils.isNotEmpty(type)){ query.eq(TProportionCheck::getCheckType,type); } List list = tProportionCheckService.list(query); if(list.size()>0){ return R.ok(list); }else { return R.fail("没有审核信息"); } } @ApiOperation(value = "平台审核是否通过") @PostMapping("/shenhe") public ResponseModel shenhe(Long id,String type) { if(type.equals("0")){ //通过 TProportionCheck tProportionCheck = tProportionCheckService.getById(id); LambdaQueryWrapper query = Wrappers.lambdaQuery(); query.eq(TProportion::getAdminId,tProportionCheck.getAdminId()); query.eq(TProportion::getEquipmentId,tProportionCheck.getEquipmentId()); List list = tProportionService.list(query); if(list.size()>0){ TProportion tProportion = list.get(0); tProportion.setModifyDate(new Date()); // tProportion.setAdminId(tProportionCheck.getAdminId()); // tProportion.setEquipmentId(tProportionCheck.getEquipmentId()); // tProportion.setClientId(tProportionCheck.getClientId()); tProportion.setType(tProportionCheck.getType()); tProportion.setProportion(tProportionCheck.getProportion()); tProportion.setAdminProportion(tProportionCheck.getAdminProportion()); tProportion.setAgencyId(tProportionCheck.getAgencyId()); tProportion.setMerchantId(tProportionCheck.getMerchantId()); tProportion.setPersonageId(tProportionCheck.getPersonageId()); tProportion.setAgencyProportion(tProportion.getAgencyProportion()); tProportion.setMerchantProportion(tProportion.getMerchantProportion()); tProportion.setPersonageProportion(tProportion.getPersonageProportion()); tProportionService.updateById(tProportion); tProportionCheck.setCheckType("1"); tProportionCheck.setModifyDate(new Date()); tProportionCheckService.updateById(tProportionCheck); } }else { //拒绝 TProportionCheck tShandeMchCheck = tProportionCheckService.getById(id); tShandeMchCheck.setModifyDate(new Date()); tShandeMchCheck.setCheckType("3"); tProportionCheckService.updateById(tShandeMchCheck); } return R.ok(); } }