package com.stylefeng.guns.modular.system.controller.general; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.stylefeng.guns.core.base.controller.BaseController; import com.stylefeng.guns.core.log.LogObjectHolder; import com.stylefeng.guns.core.shiro.ShiroKit; import com.stylefeng.guns.core.util.ToolUtil; import com.stylefeng.guns.modular.system.model.TCompanyWithdraw; import com.stylefeng.guns.modular.system.model.TEnterpriseWithdrawal; import com.stylefeng.guns.modular.system.model.User; import com.stylefeng.guns.modular.system.service.ITCompanyWithdrawService; import com.stylefeng.guns.modular.system.service.ITEnterpriseWithdrawalService; import com.stylefeng.guns.modular.system.service.IUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import java.math.BigDecimal; import java.util.Date; import java.util.List; /** * 控制器 * * @author fengshuonan * @Date 2023-03-17 14:18:09 */ @Controller @RequestMapping("/tCompanyWithdraw") public class TCompanyWithdrawController extends BaseController { private String PREFIX = "/system/tCompanyWithdraw/"; @Autowired private ITCompanyWithdrawService tCompanyWithdrawService; @Resource private ITEnterpriseWithdrawalService enterpriseWithdrawalService; /** * 跳转到首页 */ @RequestMapping("") public String index(Model model) { Integer id = ShiroKit.getUser().getObjectId(); List companyId = enterpriseWithdrawalService.selectList(new EntityWrapper().eq("companyId", id)); if (companyId.size() > 0) { } else { model.addAttribute("money",0); } return PREFIX + "tCompanyWithdraw.html"; } /** * 跳转到添加 */ @RequestMapping("/tCompanyWithdraw_add") public String tCompanyWithdrawAdd() { return PREFIX + "tCompanyWithdraw_add.html"; } /** * 跳转到修改 */ @RequestMapping("/tCompanyWithdraw_update/{tCompanyWithdrawId}") public String tCompanyWithdrawUpdate(@PathVariable Integer tCompanyWithdrawId, Model model) { TCompanyWithdraw tCompanyWithdraw = tCompanyWithdrawService.selectById(tCompanyWithdrawId); model.addAttribute("item",tCompanyWithdraw); LogObjectHolder.me().set(tCompanyWithdraw); return PREFIX + "tCompanyWithdraw_edit.html"; } @Autowired private IUserService userService; /** * 获取列表 */ @RequestMapping(value = "/list") @ResponseBody public Object list(String createTime,Integer state) { Integer id = ShiroKit.getUser().getObjectId(); EntityWrapper withdrawEntityWrapper = new EntityWrapper<>(); String sTime=null; String eTime=null; if(ToolUtil.isNotEmpty(state)){ withdrawEntityWrapper.eq("status",state); } withdrawEntityWrapper.eq("companyId",id); if(ToolUtil.isNotEmpty(createTime)){ sTime=createTime.split(" - ")[0]+" 00:00:01"; eTime=createTime.split(" - ")[1]+" 23:59:59"; withdrawEntityWrapper.between("createTime",sTime,eTime); } List tCompanyWithdraws = tCompanyWithdrawService.selectList(withdrawEntityWrapper); for (TCompanyWithdraw tCompanyWithdraw : tCompanyWithdraws) { Integer createId = tCompanyWithdraw.getCreateId(); User user = userService.selectById(createId); tCompanyWithdraw.setCreateUserName(user.getName()); } return tCompanyWithdraws; } /** * 新增 */ @RequestMapping(value = "/add") @ResponseBody @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRES_NEW) public Object add(Double money,String type,String remark) { List companyId = enterpriseWithdrawalService.selectList(new EntityWrapper().eq("companyId", ShiroKit.getUser().getObjectId())); if (companyId.size() > 0) { } TCompanyWithdraw tCompanyWithdraw = new TCompanyWithdraw(); tCompanyWithdraw.setWithdrawMoney(new BigDecimal(money)); tCompanyWithdraw.setCompanyId(ShiroKit.getUser().getObjectId()); tCompanyWithdraw.setCreateId(ShiroKit.getUser().getId()); tCompanyWithdraw.setCreateTime(new Date()); if ("提现".equals(type)) { tCompanyWithdraw.setType(1); } tCompanyWithdraw.setRemark(remark); tCompanyWithdraw.setStatus(0); // TODO 创建提现 需要回调进行提现状态查询 tCompanyWithdrawService.insert(tCompanyWithdraw); return SUCCESS_TIP; } /** * 删除 */ @RequestMapping(value = "/delete") @ResponseBody public Object delete(@RequestParam Integer tCompanyWithdrawId) { tCompanyWithdrawService.deleteById(tCompanyWithdrawId); return SUCCESS_TIP; } /** * 修改 */ @RequestMapping(value = "/update") @ResponseBody public Object update(TCompanyWithdraw tCompanyWithdraw) { tCompanyWithdrawService.updateById(tCompanyWithdraw); return SUCCESS_TIP; } /** * 详情 */ @RequestMapping(value = "/detail/{tCompanyWithdrawId}") @ResponseBody public Object detail(@PathVariable("tCompanyWithdrawId") Integer tCompanyWithdrawId) { return tCompanyWithdrawService.selectById(tCompanyWithdrawId); } }