CompanyProfitController.java 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. package com.fs.company.controller;
  2. import java.math.BigDecimal;
  3. import java.util.Date;
  4. import java.util.List;
  5. import cn.hutool.core.bean.BeanUtil;
  6. import com.fs.common.core.domain.R;
  7. import com.fs.common.utils.ServletUtils;
  8. import com.fs.company.domain.Company;
  9. import com.fs.company.domain.CompanyMoneyLogs;
  10. import com.fs.company.domain.CompanyProfitLogs;
  11. import com.fs.company.param.CompanyProfitAuditParam;
  12. import com.fs.company.service.ICompanyMoneyLogsService;
  13. import com.fs.company.service.ICompanyProfitLogsService;
  14. import com.fs.company.service.ICompanyService;
  15. import com.fs.company.vo.CompanyProfitVO;
  16. import com.fs.core.security.LoginUser;
  17. import com.fs.core.web.service.TokenService;
  18. import org.springframework.security.access.prepost.PreAuthorize;
  19. import org.springframework.beans.factory.annotation.Autowired;
  20. import org.springframework.security.core.parameters.P;
  21. import org.springframework.transaction.annotation.Transactional;
  22. import org.springframework.web.bind.annotation.GetMapping;
  23. import org.springframework.web.bind.annotation.PostMapping;
  24. import org.springframework.web.bind.annotation.PutMapping;
  25. import org.springframework.web.bind.annotation.DeleteMapping;
  26. import org.springframework.web.bind.annotation.PathVariable;
  27. import org.springframework.web.bind.annotation.RequestBody;
  28. import org.springframework.web.bind.annotation.RequestMapping;
  29. import org.springframework.web.bind.annotation.RestController;
  30. import com.fs.common.annotation.Log;
  31. import com.fs.common.core.controller.BaseController;
  32. import com.fs.common.core.domain.AjaxResult;
  33. import com.fs.common.enums.BusinessType;
  34. import com.fs.company.domain.CompanyProfit;
  35. import com.fs.company.service.ICompanyProfitService;
  36. import com.fs.common.utils.poi.ExcelUtil;
  37. import com.fs.common.core.page.TableDataInfo;
  38. /**
  39. * 提现Controller
  40. *
  41. * @author fs
  42. * @date 2022-07-04
  43. */
  44. @RestController
  45. @RequestMapping("/company/companyProfit")
  46. public class CompanyProfitController extends BaseController
  47. {
  48. @Autowired
  49. private ICompanyProfitService companyProfitService;
  50. @Autowired
  51. private ICompanyService companyService;
  52. @Autowired
  53. private ICompanyMoneyLogsService moneyLogsService;
  54. @Autowired
  55. private ICompanyProfitLogsService logsService;
  56. @Autowired
  57. private TokenService tokenService;
  58. /**
  59. * 查询提现列表
  60. */
  61. @PreAuthorize("@ss.hasPermi('company:companyProfit:list')")
  62. @GetMapping("/list")
  63. public TableDataInfo list(CompanyProfit companyProfit)
  64. {
  65. startPage();
  66. List<CompanyProfitVO> list = companyProfitService.selectCompanyProfitListVO(companyProfit);
  67. return getDataTable(list);
  68. }
  69. /**
  70. * 导出提现列表
  71. */
  72. @PreAuthorize("@ss.hasPermi('company:companyProfit:export')")
  73. @Log(title = "提现", businessType = BusinessType.EXPORT)
  74. @GetMapping("/export")
  75. public AjaxResult export(CompanyProfit companyProfit)
  76. {
  77. List<CompanyProfitVO> list = companyProfitService.selectCompanyProfitListVO(companyProfit);
  78. ExcelUtil<CompanyProfitVO> util = new ExcelUtil<CompanyProfitVO>(CompanyProfitVO.class);
  79. return util.exportExcel(list, "公司提现记录");
  80. }
  81. /**
  82. * 获取提现详细信息
  83. */
  84. @PreAuthorize("@ss.hasPermi('company:companyProfit:query')")
  85. @GetMapping(value = "/{profitId}")
  86. public R getInfo(@PathVariable("profitId") Long profitId)
  87. {
  88. CompanyProfit profit=companyProfitService.selectCompanyProfitById(profitId);
  89. CompanyProfitLogs map=new CompanyProfitLogs();
  90. map.setProfitId(profitId);
  91. List<CompanyProfitLogs> logs= logsService.selectCompanyProfitLogsList(map);
  92. return R.ok().put("profit",profit).put("logs",logs);
  93. }
  94. /**
  95. * 新增提现
  96. */
  97. @PreAuthorize("@ss.hasPermi('company:companyProfit:add')")
  98. @Log(title = "提现", businessType = BusinessType.INSERT)
  99. @PostMapping
  100. public AjaxResult add(@RequestBody CompanyProfit companyProfit)
  101. {
  102. return toAjax(companyProfitService.insertCompanyProfit(companyProfit));
  103. }
  104. /**
  105. * 修改提现
  106. */
  107. @PreAuthorize("@ss.hasPermi('company:companyProfit:edit')")
  108. @Log(title = "提现", businessType = BusinessType.UPDATE)
  109. @PutMapping
  110. public AjaxResult edit(@RequestBody CompanyProfit companyProfit)
  111. {
  112. return toAjax(companyProfitService.updateCompanyProfit(companyProfit));
  113. }
  114. /**
  115. * 删除提现
  116. */
  117. @PreAuthorize("@ss.hasPermi('company:companyProfit:remove')")
  118. @Log(title = "提现", businessType = BusinessType.DELETE)
  119. @DeleteMapping("/{profitIds}")
  120. public AjaxResult remove(@PathVariable Long[] profitIds)
  121. {
  122. return toAjax(companyProfitService.deleteCompanyProfitByIds(profitIds));
  123. }
  124. @PreAuthorize("@ss.hasPermi('company:companyProfit:audit1')")
  125. @PostMapping("/audit1")
  126. @Transactional
  127. public R audit1(@RequestBody CompanyProfitAuditParam param)
  128. {
  129. LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
  130. CompanyProfit profit=companyProfitService.selectCompanyProfitById(param.getProfitId());
  131. if(profit.getProfitStatus()!=1){
  132. return R.error("非法操作");
  133. }
  134. Company company=companyService.selectCompanyByIdForUpdate(profit.getCompanyId());
  135. if(param.getStatus()==1){
  136. profit.setRemark(param.getRemark());
  137. profit.setProfitStatus(2);
  138. profit.setUpdateTime(new Date());
  139. companyProfitService.updateCompanyProfit(profit);
  140. CompanyProfitLogs logs=new CompanyProfitLogs();
  141. logs.setProfitId(profit.getProfitId());
  142. logs.setReason(param.getRemark());
  143. logs.setCreateTime(new Date());
  144. logs.setTitle(loginUser.getUser().getNickName()+"审核通过");
  145. logsService.insertCompanyProfitLogs(logs);
  146. }
  147. else if(param.getStatus()==0){
  148. //驳回退款
  149. profit.setRemark(param.getRemark());
  150. profit.setProfitStatus(0);
  151. profit.setUpdateTime(new Date());
  152. companyProfitService.updateCompanyProfit(profit);
  153. company.setMoney(company.getMoney().add(profit.getMoney()));
  154. companyService.updateCompany(company);
  155. CompanyMoneyLogs logs=new CompanyMoneyLogs();
  156. logs.setCompanyId(company.getCompanyId());
  157. logs.setMoney(profit.getMoney());
  158. logs.setLogsType(7);
  159. logs.setBalance(company.getMoney());
  160. logs.setRemark("驳回退款:"+profit.getMoney());
  161. logs.setCreateTime(new Date());
  162. moneyLogsService.insertCompanyMoneyLogs(logs);
  163. CompanyProfitLogs profitLogs=new CompanyProfitLogs();
  164. profitLogs.setProfitId(profit.getProfitId());
  165. profitLogs.setReason(param.getRemark());
  166. profitLogs.setCreateTime(new Date());
  167. profitLogs.setTitle(loginUser.getUser().getNickName()+"驳回退款");
  168. logsService.insertCompanyProfitLogs(profitLogs);
  169. }
  170. return R.ok("操作成功");
  171. }
  172. @PreAuthorize("@ss.hasPermi('company:companyProfit:audit2')")
  173. @PostMapping("/audit2")
  174. @Transactional
  175. public R audit2(@RequestBody CompanyProfitAuditParam param)
  176. {
  177. LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
  178. CompanyProfit profit=companyProfitService.selectCompanyProfitById(param.getProfitId());
  179. if(profit.getProfitStatus()!=2){
  180. return R.error("非法操作");
  181. }
  182. Company company=companyService.selectCompanyByIdForUpdate(profit.getCompanyId());
  183. if(param.getStatus()==1){
  184. profit.setRemark(param.getRemark());
  185. profit.setProfitStatus(3);
  186. profit.setUpdateTime(new Date());
  187. companyProfitService.updateCompanyProfit(profit);
  188. CompanyProfitLogs logs=new CompanyProfitLogs();
  189. logs.setProfitId(profit.getProfitId());
  190. logs.setReason(param.getRemark());
  191. logs.setCreateTime(new Date());
  192. logs.setTitle(loginUser.getUser().getNickName()+"审核通过");
  193. logsService.insertCompanyProfitLogs(logs);
  194. }
  195. else if(param.getStatus()==0){
  196. //驳回退款
  197. profit.setRemark(param.getRemark());
  198. profit.setProfitStatus(0);
  199. profit.setUpdateTime(new Date());
  200. companyProfitService.updateCompanyProfit(profit);
  201. company.setMoney(company.getMoney().add(profit.getMoney()));
  202. companyService.updateCompany(company);
  203. CompanyMoneyLogs logs=new CompanyMoneyLogs();
  204. logs.setCompanyId(company.getCompanyId());
  205. logs.setMoney(profit.getMoney());
  206. logs.setLogsType(7);
  207. logs.setBalance(company.getMoney());
  208. logs.setRemark("驳回退款:"+profit.getMoney());
  209. logs.setCreateTime(new Date());
  210. moneyLogsService.insertCompanyMoneyLogs(logs);
  211. CompanyProfitLogs profitLogs=new CompanyProfitLogs();
  212. profitLogs.setProfitId(profit.getProfitId());
  213. profitLogs.setReason(param.getRemark());
  214. profitLogs.setCreateTime(new Date());
  215. profitLogs.setTitle(loginUser.getUser().getNickName()+"驳回退款");
  216. logsService.insertCompanyProfitLogs(profitLogs);
  217. }
  218. return R.ok("操作成功");
  219. }
  220. @PreAuthorize("@ss.hasPermi('company:companyProfit:audit3')")
  221. @PostMapping("/audit3")
  222. @Transactional
  223. public R audit3(@RequestBody CompanyProfitAuditParam param)
  224. {
  225. LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
  226. CompanyProfit profit=companyProfitService.selectCompanyProfitById(param.getProfitId());
  227. if(profit.getProfitStatus()!=3){
  228. return R.error("非法操作");
  229. }
  230. Company company=companyService.selectCompanyByIdForUpdate(profit.getCompanyId());
  231. if(param.getStatus()==1){
  232. profit.setRemark(param.getRemark());
  233. profit.setProfitStatus(4);
  234. profit.setUpdateTime(new Date());
  235. profit.setImgUrl(param.getImgUrl());
  236. companyProfitService.updateCompanyProfit(profit);
  237. CompanyProfitLogs logs=new CompanyProfitLogs();
  238. logs.setProfitId(profit.getProfitId());
  239. logs.setReason(param.getRemark());
  240. logs.setCreateTime(new Date());
  241. logs.setTitle(loginUser.getUser().getNickName()+"审核通过");
  242. logsService.insertCompanyProfitLogs(logs);
  243. }
  244. else if(param.getStatus()==0){
  245. //驳回退款
  246. profit.setRemark(param.getRemark());
  247. profit.setProfitStatus(0);
  248. profit.setUpdateTime(new Date());
  249. companyProfitService.updateCompanyProfit(profit);
  250. company.setMoney(company.getMoney().add(profit.getMoney()));
  251. companyService.updateCompany(company);
  252. CompanyMoneyLogs logs=new CompanyMoneyLogs();
  253. logs.setCompanyId(company.getCompanyId());
  254. logs.setMoney(profit.getMoney());
  255. logs.setLogsType(7);
  256. logs.setBalance(company.getMoney());
  257. logs.setRemark("驳回退款:"+profit.getMoney());
  258. logs.setCreateTime(new Date());
  259. moneyLogsService.insertCompanyMoneyLogs(logs);
  260. CompanyProfitLogs profitLogs=new CompanyProfitLogs();
  261. profitLogs.setProfitId(profit.getProfitId());
  262. profitLogs.setReason(param.getRemark());
  263. profitLogs.setCreateTime(new Date());
  264. profitLogs.setTitle(loginUser.getUser().getNickName()+"驳回退款");
  265. logsService.insertCompanyProfitLogs(profitLogs);
  266. }
  267. return R.ok("操作成功");
  268. }
  269. }