123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285 |
- package com.fs.company.controller;
- import java.math.BigDecimal;
- import java.util.Date;
- import java.util.List;
- import cn.hutool.core.bean.BeanUtil;
- import com.fs.common.core.domain.R;
- import com.fs.common.utils.ServletUtils;
- import com.fs.company.domain.Company;
- import com.fs.company.domain.CompanyMoneyLogs;
- import com.fs.company.domain.CompanyProfitLogs;
- import com.fs.company.param.CompanyProfitAuditParam;
- import com.fs.company.service.ICompanyMoneyLogsService;
- import com.fs.company.service.ICompanyProfitLogsService;
- import com.fs.company.service.ICompanyService;
- import com.fs.company.vo.CompanyProfitVO;
- import com.fs.core.security.LoginUser;
- import com.fs.core.web.service.TokenService;
- import org.springframework.security.access.prepost.PreAuthorize;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.security.core.parameters.P;
- import org.springframework.transaction.annotation.Transactional;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.PutMapping;
- import org.springframework.web.bind.annotation.DeleteMapping;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import com.fs.common.annotation.Log;
- import com.fs.common.core.controller.BaseController;
- import com.fs.common.core.domain.AjaxResult;
- import com.fs.common.enums.BusinessType;
- import com.fs.company.domain.CompanyProfit;
- import com.fs.company.service.ICompanyProfitService;
- import com.fs.common.utils.poi.ExcelUtil;
- import com.fs.common.core.page.TableDataInfo;
- /**
- * 提现Controller
- *
- * @author fs
- * @date 2022-07-04
- */
- @RestController
- @RequestMapping("/company/companyProfit")
- public class CompanyProfitController extends BaseController
- {
- @Autowired
- private ICompanyProfitService companyProfitService;
- @Autowired
- private ICompanyService companyService;
- @Autowired
- private ICompanyMoneyLogsService moneyLogsService;
- @Autowired
- private ICompanyProfitLogsService logsService;
- @Autowired
- private TokenService tokenService;
- /**
- * 查询提现列表
- */
- @PreAuthorize("@ss.hasPermi('company:companyProfit:list')")
- @GetMapping("/list")
- public TableDataInfo list(CompanyProfit companyProfit)
- {
- startPage();
- List<CompanyProfitVO> list = companyProfitService.selectCompanyProfitListVO(companyProfit);
- return getDataTable(list);
- }
- /**
- * 导出提现列表
- */
- @PreAuthorize("@ss.hasPermi('company:companyProfit:export')")
- @Log(title = "提现", businessType = BusinessType.EXPORT)
- @GetMapping("/export")
- public AjaxResult export(CompanyProfit companyProfit)
- {
- List<CompanyProfitVO> list = companyProfitService.selectCompanyProfitListVO(companyProfit);
- ExcelUtil<CompanyProfitVO> util = new ExcelUtil<CompanyProfitVO>(CompanyProfitVO.class);
- return util.exportExcel(list, "公司提现记录");
- }
- /**
- * 获取提现详细信息
- */
- @PreAuthorize("@ss.hasPermi('company:companyProfit:query')")
- @GetMapping(value = "/{profitId}")
- public R getInfo(@PathVariable("profitId") Long profitId)
- {
- CompanyProfit profit=companyProfitService.selectCompanyProfitById(profitId);
- CompanyProfitLogs map=new CompanyProfitLogs();
- map.setProfitId(profitId);
- List<CompanyProfitLogs> logs= logsService.selectCompanyProfitLogsList(map);
- return R.ok().put("profit",profit).put("logs",logs);
- }
- /**
- * 新增提现
- */
- @PreAuthorize("@ss.hasPermi('company:companyProfit:add')")
- @Log(title = "提现", businessType = BusinessType.INSERT)
- @PostMapping
- public AjaxResult add(@RequestBody CompanyProfit companyProfit)
- {
- return toAjax(companyProfitService.insertCompanyProfit(companyProfit));
- }
- /**
- * 修改提现
- */
- @PreAuthorize("@ss.hasPermi('company:companyProfit:edit')")
- @Log(title = "提现", businessType = BusinessType.UPDATE)
- @PutMapping
- public AjaxResult edit(@RequestBody CompanyProfit companyProfit)
- {
- return toAjax(companyProfitService.updateCompanyProfit(companyProfit));
- }
- /**
- * 删除提现
- */
- @PreAuthorize("@ss.hasPermi('company:companyProfit:remove')")
- @Log(title = "提现", businessType = BusinessType.DELETE)
- @DeleteMapping("/{profitIds}")
- public AjaxResult remove(@PathVariable Long[] profitIds)
- {
- return toAjax(companyProfitService.deleteCompanyProfitByIds(profitIds));
- }
- @PreAuthorize("@ss.hasPermi('company:companyProfit:audit1')")
- @PostMapping("/audit1")
- @Transactional
- public R audit1(@RequestBody CompanyProfitAuditParam param)
- {
- LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
- CompanyProfit profit=companyProfitService.selectCompanyProfitById(param.getProfitId());
- if(profit.getProfitStatus()!=1){
- return R.error("非法操作");
- }
- Company company=companyService.selectCompanyByIdForUpdate(profit.getCompanyId());
- if(param.getStatus()==1){
- profit.setRemark(param.getRemark());
- profit.setProfitStatus(2);
- profit.setUpdateTime(new Date());
- companyProfitService.updateCompanyProfit(profit);
- CompanyProfitLogs logs=new CompanyProfitLogs();
- logs.setProfitId(profit.getProfitId());
- logs.setReason(param.getRemark());
- logs.setCreateTime(new Date());
- logs.setTitle(loginUser.getUser().getNickName()+"审核通过");
- logsService.insertCompanyProfitLogs(logs);
- }
- else if(param.getStatus()==0){
- //驳回退款
- profit.setRemark(param.getRemark());
- profit.setProfitStatus(0);
- profit.setUpdateTime(new Date());
- companyProfitService.updateCompanyProfit(profit);
- company.setMoney(company.getMoney().add(profit.getMoney()));
- companyService.updateCompany(company);
- CompanyMoneyLogs logs=new CompanyMoneyLogs();
- logs.setCompanyId(company.getCompanyId());
- logs.setMoney(profit.getMoney());
- logs.setLogsType(7);
- logs.setBalance(company.getMoney());
- logs.setRemark("驳回退款:"+profit.getMoney());
- logs.setCreateTime(new Date());
- moneyLogsService.insertCompanyMoneyLogs(logs);
- CompanyProfitLogs profitLogs=new CompanyProfitLogs();
- profitLogs.setProfitId(profit.getProfitId());
- profitLogs.setReason(param.getRemark());
- profitLogs.setCreateTime(new Date());
- profitLogs.setTitle(loginUser.getUser().getNickName()+"驳回退款");
- logsService.insertCompanyProfitLogs(profitLogs);
- }
- return R.ok("操作成功");
- }
- @PreAuthorize("@ss.hasPermi('company:companyProfit:audit2')")
- @PostMapping("/audit2")
- @Transactional
- public R audit2(@RequestBody CompanyProfitAuditParam param)
- {
- LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
- CompanyProfit profit=companyProfitService.selectCompanyProfitById(param.getProfitId());
- if(profit.getProfitStatus()!=2){
- return R.error("非法操作");
- }
- Company company=companyService.selectCompanyByIdForUpdate(profit.getCompanyId());
- if(param.getStatus()==1){
- profit.setRemark(param.getRemark());
- profit.setProfitStatus(3);
- profit.setUpdateTime(new Date());
- companyProfitService.updateCompanyProfit(profit);
- CompanyProfitLogs logs=new CompanyProfitLogs();
- logs.setProfitId(profit.getProfitId());
- logs.setReason(param.getRemark());
- logs.setCreateTime(new Date());
- logs.setTitle(loginUser.getUser().getNickName()+"审核通过");
- logsService.insertCompanyProfitLogs(logs);
- }
- else if(param.getStatus()==0){
- //驳回退款
- profit.setRemark(param.getRemark());
- profit.setProfitStatus(0);
- profit.setUpdateTime(new Date());
- companyProfitService.updateCompanyProfit(profit);
- company.setMoney(company.getMoney().add(profit.getMoney()));
- companyService.updateCompany(company);
- CompanyMoneyLogs logs=new CompanyMoneyLogs();
- logs.setCompanyId(company.getCompanyId());
- logs.setMoney(profit.getMoney());
- logs.setLogsType(7);
- logs.setBalance(company.getMoney());
- logs.setRemark("驳回退款:"+profit.getMoney());
- logs.setCreateTime(new Date());
- moneyLogsService.insertCompanyMoneyLogs(logs);
- CompanyProfitLogs profitLogs=new CompanyProfitLogs();
- profitLogs.setProfitId(profit.getProfitId());
- profitLogs.setReason(param.getRemark());
- profitLogs.setCreateTime(new Date());
- profitLogs.setTitle(loginUser.getUser().getNickName()+"驳回退款");
- logsService.insertCompanyProfitLogs(profitLogs);
- }
- return R.ok("操作成功");
- }
- @PreAuthorize("@ss.hasPermi('company:companyProfit:audit3')")
- @PostMapping("/audit3")
- @Transactional
- public R audit3(@RequestBody CompanyProfitAuditParam param)
- {
- LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
- CompanyProfit profit=companyProfitService.selectCompanyProfitById(param.getProfitId());
- if(profit.getProfitStatus()!=3){
- return R.error("非法操作");
- }
- Company company=companyService.selectCompanyByIdForUpdate(profit.getCompanyId());
- if(param.getStatus()==1){
- profit.setRemark(param.getRemark());
- profit.setProfitStatus(4);
- profit.setUpdateTime(new Date());
- profit.setImgUrl(param.getImgUrl());
- companyProfitService.updateCompanyProfit(profit);
- CompanyProfitLogs logs=new CompanyProfitLogs();
- logs.setProfitId(profit.getProfitId());
- logs.setReason(param.getRemark());
- logs.setCreateTime(new Date());
- logs.setTitle(loginUser.getUser().getNickName()+"审核通过");
- logsService.insertCompanyProfitLogs(logs);
- }
- else if(param.getStatus()==0){
- //驳回退款
- profit.setRemark(param.getRemark());
- profit.setProfitStatus(0);
- profit.setUpdateTime(new Date());
- companyProfitService.updateCompanyProfit(profit);
- company.setMoney(company.getMoney().add(profit.getMoney()));
- companyService.updateCompany(company);
- CompanyMoneyLogs logs=new CompanyMoneyLogs();
- logs.setCompanyId(company.getCompanyId());
- logs.setMoney(profit.getMoney());
- logs.setLogsType(7);
- logs.setBalance(company.getMoney());
- logs.setRemark("驳回退款:"+profit.getMoney());
- logs.setCreateTime(new Date());
- moneyLogsService.insertCompanyMoneyLogs(logs);
- CompanyProfitLogs profitLogs=new CompanyProfitLogs();
- profitLogs.setProfitId(profit.getProfitId());
- profitLogs.setReason(param.getRemark());
- profitLogs.setCreateTime(new Date());
- profitLogs.setTitle(loginUser.getUser().getNickName()+"驳回退款");
- logsService.insertCompanyProfitLogs(profitLogs);
- }
- return R.ok("操作成功");
- }
- }
|