|
@@ -0,0 +1,148 @@
|
|
|
+package com.fs.company.controller;
|
|
|
+
|
|
|
+import com.fs.common.annotation.Log;
|
|
|
+import com.fs.common.core.controller.BaseController;
|
|
|
+import com.fs.common.core.domain.AjaxResult;
|
|
|
+import com.fs.common.core.domain.R;
|
|
|
+import com.fs.common.core.domain.model.LoginUser;
|
|
|
+import com.fs.common.core.page.TableDataInfo;
|
|
|
+import com.fs.common.enums.BusinessType;
|
|
|
+import com.fs.common.utils.ServletUtils;
|
|
|
+import com.fs.common.utils.poi.ExcelUtil;
|
|
|
+import com.fs.company.domain.Company;
|
|
|
+import com.fs.company.domain.CompanyDeduct;
|
|
|
+import com.fs.company.domain.CompanyMoneyLogs;
|
|
|
+import com.fs.company.service.ICompanyDeductService;
|
|
|
+import com.fs.company.service.ICompanyMoneyLogsService;
|
|
|
+import com.fs.company.service.ICompanyService;
|
|
|
+import com.fs.company.vo.CompanyDeductExportVO;
|
|
|
+import com.fs.company.vo.CompanyDeductVO;
|
|
|
+import com.fs.framework.web.service.TokenService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 扣款Controller
|
|
|
+ *
|
|
|
+ * @author fs
|
|
|
+ * @date 2023-02-27
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/company/companyDeduct")
|
|
|
+public class CompanyDeductController extends BaseController
|
|
|
+{
|
|
|
+ @Autowired
|
|
|
+ private ICompanyDeductService companyDeductService;
|
|
|
+ @Autowired
|
|
|
+ private TokenService tokenService;
|
|
|
+ @Autowired
|
|
|
+ private ICompanyService companyService;
|
|
|
+ @Autowired
|
|
|
+ private ICompanyMoneyLogsService moneyLogsService;
|
|
|
+ /**
|
|
|
+ * 查询扣款列表
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('company:companyDeduct:list')")
|
|
|
+ @GetMapping("/list")
|
|
|
+ public TableDataInfo list(CompanyDeduct companyDeduct)
|
|
|
+ {
|
|
|
+ startPage();
|
|
|
+ List<CompanyDeductVO> list = companyDeductService.selectCompanyDeductVOList(companyDeduct);
|
|
|
+ return getDataTable(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出扣款列表
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('company:companyDeduct:export')")
|
|
|
+ @Log(title = "扣款", businessType = BusinessType.EXPORT)
|
|
|
+ @GetMapping("/export")
|
|
|
+ public AjaxResult export(CompanyDeduct companyDeduct)
|
|
|
+ {
|
|
|
+ List<CompanyDeductExportVO> list = companyDeductService.selectCompanyExportDeductList(companyDeduct);
|
|
|
+ ExcelUtil<CompanyDeductExportVO> util = new ExcelUtil<CompanyDeductExportVO>(CompanyDeductExportVO.class);
|
|
|
+ return util.exportExcel(list, "companyDeduct");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取扣款详细信息
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('company:companyDeduct:query')")
|
|
|
+ @GetMapping(value = "/{deductId}")
|
|
|
+ public AjaxResult getInfo(@PathVariable("deductId") Long deductId)
|
|
|
+ {
|
|
|
+ return AjaxResult.success(companyDeductService.selectCompanyDeductById(deductId));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增扣款
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('company:companyDeduct:add')")
|
|
|
+ @Log(title = "扣款", businessType = BusinessType.INSERT)
|
|
|
+ @PostMapping
|
|
|
+ public AjaxResult add(@RequestBody CompanyDeduct companyDeduct)
|
|
|
+ {
|
|
|
+ return toAjax(companyDeductService.insertCompanyDeduct(companyDeduct));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改扣款
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('company:companyDeduct:edit')")
|
|
|
+ @Log(title = "扣款", businessType = BusinessType.UPDATE)
|
|
|
+ @PutMapping
|
|
|
+ public AjaxResult edit(@RequestBody CompanyDeduct companyDeduct)
|
|
|
+ {
|
|
|
+ return toAjax(companyDeductService.updateCompanyDeduct(companyDeduct));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除扣款
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('company:companyDeduct:remove')")
|
|
|
+ @Log(title = "扣款", businessType = BusinessType.DELETE)
|
|
|
+ @DeleteMapping("/{deductIds}")
|
|
|
+ public AjaxResult remove(@PathVariable Long[] deductIds)
|
|
|
+ {
|
|
|
+ return toAjax(companyDeductService.deleteCompanyDeductByIds(deductIds));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('company:companyDeduct:audit')")
|
|
|
+ @PostMapping("/audit")
|
|
|
+ @Transactional
|
|
|
+ public R audit(@RequestBody CompanyDeduct param)
|
|
|
+ {
|
|
|
+ CompanyDeduct deduct=companyDeductService.selectCompanyDeductById(param.getDeductId());
|
|
|
+ if(deduct.getIsAudit()!=0){
|
|
|
+ return R.error("非法操作");
|
|
|
+ }
|
|
|
+ deduct.setIsAudit(param.getIsAudit());
|
|
|
+ deduct.setRemark(param.getRemark());
|
|
|
+ LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
+ if(deduct.getIsAudit()==1){
|
|
|
+ Company company=companyService.selectCompanyByIdForUpdate(deduct.getCompanyId());
|
|
|
+ company.setMoney(company.getMoney().subtract(deduct.getMoney()));
|
|
|
+ companyService.updateCompany(company);
|
|
|
+ CompanyMoneyLogs log=new CompanyMoneyLogs();
|
|
|
+ log.setCompanyId(deduct.getCompanyId());
|
|
|
+ log.setMoney(deduct.getMoney().multiply(new BigDecimal(-1)));
|
|
|
+ log.setRemark(deduct.getRemark());
|
|
|
+ log.setLogsType(2);
|
|
|
+ log.setBalance(company.getMoney());
|
|
|
+ log.setCreateTime(new Date());
|
|
|
+ moneyLogsService.insertCompanyMoneyLogs(log);
|
|
|
+ }
|
|
|
+ deduct.setAuditTime(new Date());
|
|
|
+ deduct.setAuditUserId(loginUser.getUser().getUserId());
|
|
|
+ companyDeductService.updateCompanyDeduct(deduct);
|
|
|
+ return R.ok("操作成功");
|
|
|
+
|
|
|
+ }
|
|
|
+}
|