DeleteFeeConfigCmd.java 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package com.java110.fee.cmd.feeConfig;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.java110.core.annotation.Java110Cmd;
  4. import com.java110.core.annotation.Java110Transactional;
  5. import com.java110.core.context.ICmdDataFlowContext;
  6. import com.java110.core.event.cmd.AbstractServiceCmdListener;
  7. import com.java110.core.event.cmd.CmdEvent;
  8. import com.java110.dto.fee.FeeConfigDto;
  9. import com.java110.intf.fee.IFeeConfigInnerServiceSMO;
  10. import com.java110.intf.fee.IPayFeeConfigV1InnerServiceSMO;
  11. import com.java110.po.fee.PayFeeConfigPo;
  12. import com.java110.utils.exception.CmdException;
  13. import com.java110.utils.util.Assert;
  14. import com.java110.utils.util.BeanConvertUtil;
  15. import com.java110.vo.ResultVo;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. @Java110Cmd(serviceCode = "feeConfig.deleteFeeConfig")
  18. public class DeleteFeeConfigCmd extends AbstractServiceCmdListener {
  19. @Autowired
  20. private IPayFeeConfigV1InnerServiceSMO payFeeConfigV1InnerServiceSMOImpl;
  21. @Autowired
  22. private IFeeConfigInnerServiceSMO feeConfigInnerServiceSMOImpl;
  23. @Override
  24. public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
  25. Assert.hasKeyAndValue(reqJson, "configId", "费用项ID不能为空");
  26. Assert.hasKeyAndValue(reqJson, "communityId", "未包含小区ID");
  27. FeeConfigDto feeConfigDto = new FeeConfigDto();
  28. feeConfigDto.setCommunityId(reqJson.getString("communityId"));
  29. feeConfigDto.setConfigId(reqJson.getString("configId"));
  30. feeConfigDto.setIsDefault("T");
  31. int feeCount = feeConfigInnerServiceSMOImpl.queryFeeConfigsCount(feeConfigDto);
  32. if (feeCount > 0) {
  33. throw new IllegalArgumentException("该费用项目不能删除");
  34. }
  35. }
  36. @Override
  37. @Java110Transactional
  38. public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
  39. PayFeeConfigPo payFeeConfigPo = BeanConvertUtil.covertBean(reqJson, PayFeeConfigPo.class);
  40. int flag = payFeeConfigV1InnerServiceSMOImpl.deletePayFeeConfig(payFeeConfigPo);
  41. if (flag < 1) {
  42. throw new CmdException("删除费用项失败");
  43. }
  44. cmdDataFlowContext.setResponseEntity(ResultVo.success());
  45. }
  46. }