diff --git a/src/main/java/com/xujie/modules/baseInformation/controller/SrmPaymentTermController.java b/src/main/java/com/xujie/modules/baseInformation/controller/SrmPaymentTermController.java index df8d93d..4ab36bf 100644 --- a/src/main/java/com/xujie/modules/baseInformation/controller/SrmPaymentTermController.java +++ b/src/main/java/com/xujie/modules/baseInformation/controller/SrmPaymentTermController.java @@ -2,7 +2,6 @@ package com.xujie.modules.baseInformation.controller; import com.xujie.common.utils.PageUtils; import com.xujie.common.utils.R; -import com.xujie.modules.baseInformation.entity.SrmDeliveryTerm; import com.xujie.modules.baseInformation.entity.SrmPaymentTerm; import com.xujie.modules.baseInformation.service.SrmPaymentTermService; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/com/xujie/modules/baseInformation/controller/SrmTaxController.java b/src/main/java/com/xujie/modules/baseInformation/controller/SrmTaxController.java new file mode 100644 index 0000000..c43fe62 --- /dev/null +++ b/src/main/java/com/xujie/modules/baseInformation/controller/SrmTaxController.java @@ -0,0 +1,53 @@ +package com.xujie.modules.baseInformation.controller; + +import com.xujie.common.utils.PageUtils; +import com.xujie.common.utils.R; +import com.xujie.modules.baseInformation.entity.SrmTax; +import com.xujie.modules.baseInformation.service.SrmTaxService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/srmTax") +public class SrmTaxController { + + @Autowired + private SrmTaxService srmTaxService; + + /** + * 获取税号列表 + */ + @PostMapping("/getTaxListPaging") + public R getTaxListPaging(@RequestBody SrmTax tax) { + PageUtils page = srmTaxService.getTaxListPaging(tax); + return R.ok().put("data", page); + } + + /** + * 新增税率信息 + */ + @PostMapping("/saveTax") + public R saveTax(@RequestBody SrmTax tax) { + return srmTaxService.saveTax(tax); + } + + /** + * 更新税率信息 + */ + @PostMapping("/updateTax") + public R updateTax(@RequestBody SrmTax tax) { + return srmTaxService.updateTax(tax); + } + + /** + * 删除税率信息 + */ + @PostMapping("/deleteTax") + public R deleteTax(@RequestBody SrmTax tax) { + return srmTaxService.deleteTax(tax); + } + +} diff --git a/src/main/java/com/xujie/modules/baseInformation/entity/SrmTax.java b/src/main/java/com/xujie/modules/baseInformation/entity/SrmTax.java new file mode 100644 index 0000000..b97f61d --- /dev/null +++ b/src/main/java/com/xujie/modules/baseInformation/entity/SrmTax.java @@ -0,0 +1,19 @@ +package com.xujie.modules.baseInformation.entity; + +import com.xujie.common.utils.QueryPage; +import lombok.Data; + +@Data +public class SrmTax extends QueryPage { + + private String taxCode; + + private String taxDesc; + + private String site; + + private String taxRate; + + private String active; + +} diff --git a/src/main/java/com/xujie/modules/baseInformation/mapper/SrmTaxMapper.java b/src/main/java/com/xujie/modules/baseInformation/mapper/SrmTaxMapper.java new file mode 100644 index 0000000..6abf669 --- /dev/null +++ b/src/main/java/com/xujie/modules/baseInformation/mapper/SrmTaxMapper.java @@ -0,0 +1,22 @@ +package com.xujie.modules.baseInformation.mapper; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.xujie.modules.baseInformation.entity.SrmPaymentTerm; +import com.xujie.modules.baseInformation.entity.SrmTax; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface SrmTaxMapper { + IPage selectTaxWithPaging(Page page, SrmTax tax); + + SrmTax selectTaxByCode(String taxCode, String site); + + int insertTax(SrmTax tax); + + int updateTax(SrmTax tax); + + Integer checkTaxReference(String taxCode, String site); + + int deleteTax(String taxCode, String site); +} diff --git a/src/main/java/com/xujie/modules/baseInformation/service/SrmTaxService.java b/src/main/java/com/xujie/modules/baseInformation/service/SrmTaxService.java new file mode 100644 index 0000000..077318a --- /dev/null +++ b/src/main/java/com/xujie/modules/baseInformation/service/SrmTaxService.java @@ -0,0 +1,15 @@ +package com.xujie.modules.baseInformation.service; + +import com.xujie.common.utils.PageUtils; +import com.xujie.common.utils.R; +import com.xujie.modules.baseInformation.entity.SrmTax; + +public interface SrmTaxService { + PageUtils getTaxListPaging(SrmTax tax); + + R saveTax(SrmTax tax); + + R updateTax(SrmTax tax); + + R deleteTax(SrmTax tax); +} diff --git a/src/main/java/com/xujie/modules/baseInformation/service/impl/SrmTaxServiceImpl.java b/src/main/java/com/xujie/modules/baseInformation/service/impl/SrmTaxServiceImpl.java new file mode 100644 index 0000000..cc55ccb --- /dev/null +++ b/src/main/java/com/xujie/modules/baseInformation/service/impl/SrmTaxServiceImpl.java @@ -0,0 +1,75 @@ +package com.xujie.modules.baseInformation.service.impl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.xujie.common.utils.PageUtils; +import com.xujie.common.utils.R; +import com.xujie.modules.baseInformation.entity.SrmPaymentTerm; +import com.xujie.modules.baseInformation.entity.SrmTax; +import com.xujie.modules.baseInformation.mapper.SrmTaxMapper; +import com.xujie.modules.baseInformation.service.SrmTaxService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class SrmTaxServiceImpl implements SrmTaxService { + + @Autowired + private SrmTaxMapper srmTaxMapper; + + @Override + public PageUtils getTaxListPaging(SrmTax tax) { + Page page = new Page<>(tax.getPage(), tax.getLimit()); + IPage iPage = this.srmTaxMapper.selectTaxWithPaging(page, tax); + return new PageUtils(iPage); + } + + @Override + public R saveTax(SrmTax tax) { + + //检查是否存在相同的税号和site + SrmTax existing = srmTaxMapper.selectTaxByCode(tax.getTaxCode(), tax.getSite()); + if (existing != null) { + return R.error("税号已存在"); + } + + int result = srmTaxMapper.insertTax(tax); + if (result > 0) { + return R.ok().put("msg", "税号新增成功"); + }else { + return R.error("税号新增失败"); + } + } + + @Override + public R updateTax(SrmTax tax) { + //检查是否存在税号和site + SrmTax existing = srmTaxMapper.selectTaxByCode(tax.getTaxCode(), tax.getSite()); + if (existing == null) { + return R.error("税号已存在"); + } + + int result = srmTaxMapper.updateTax(tax); + if (result > 0) { + return R.ok().put("msg", "税号更新成功"); + }else { + return R.error("税号更新失败"); + } + } + + @Override + public R deleteTax(SrmTax tax) { + //检查税率编号是否被引用 + Integer referenceCount = srmTaxMapper.checkTaxReference(tax.getTaxCode(), tax.getSite()); + if (referenceCount > 0){ + return R.error("税率编号正在被使用,无法删除"); + } + + int result = srmTaxMapper.deleteTax(tax.getTaxCode(), tax.getSite()); + if (result > 0) { + return R.ok().put("msg", "税率编号删除成功"); + }else { + return R.error("税率编号删除失败"); + } + } +} diff --git a/src/main/resources/mapper/baseInformation/SrmTaxMapper.xml b/src/main/resources/mapper/baseInformation/SrmTaxMapper.xml new file mode 100644 index 0000000..27438f7 --- /dev/null +++ b/src/main/resources/mapper/baseInformation/SrmTaxMapper.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + INSERT INTO Tax ( + Taxcode, + Site, + TaxDesc, + TaxRate, + Active + ) VALUES ( + #{taxCode}, + #{site}, + #{taxDesc}, + #{taxRate}, + #{active} + ) + + + + UPDATE Tax + + + TaxDesc = #{taxDesc}, + + + TaxRate = #{taxRate}, + + + Active = #{active} + + + WHERE Taxcode = #{taxCode} AND Site = #{site} + + + SELECT COUNT(1) + from srm_supplier + WHERE Tax = #{taxCode} AND site = #{site} + + + + DELETE FROM Tax + WHERE Taxcode = #{taxCode} AND Site = #{site} + + \ No newline at end of file diff --git a/src/main/resources/mapper/srm/SrmSupplierMapper.xml b/src/main/resources/mapper/srm/SrmSupplierMapper.xml index 9269d75..6923ea9 100644 --- a/src/main/resources/mapper/srm/SrmSupplierMapper.xml +++ b/src/main/resources/mapper/srm/SrmSupplierMapper.xml @@ -5,7 +5,7 @@ id,site,supplier_no,supplier_name,supplier_group,create_date,create_by,update_date,update_by,supplier_doc_type, - TaxCode,tax,FaxNo,PhoneNo,PhoneNo2,PhoneNo3,Contact,Address,PaymentTerm,DeliveryTerm,Buyer,Sourcing_staff, + TaxCode,tax,FaxNo,PhoneNo,PhoneNo2,PhoneNo3,Contact,Address,PaymentTerm,DeliveryTerm,Buyer,SourcingStaff, Currency,ABC,Active,BankName,BankAccount,TaxNo,Email,Email2,Other_contact1,Other_contact2,Other_contact3,Memo @@ -13,7 +13,7 @@ SELECT id,site,supplier_no,supplier_name,supplier_group,create_date,create_by,update_date,update_by,supplier_doc_type, - TaxCode,tax,FaxNo,PhoneNo,PhoneNo2,PhoneNo3,Contact,Address,PaymentTerm,DeliveryTerm,Buyer,Sourcing_staff, + TaxCode,tax,FaxNo,PhoneNo,PhoneNo2,PhoneNo3,Contact,Address,PaymentTerm,DeliveryTerm,Buyer,SourcingStaff, Currency,ABC,Active,BankName,BankAccount,TaxNo,Email,Email2,Other_contact1,Other_contact2,Other_contact3,Memo FROM srm_supplier @@ -287,7 +287,7 @@ PaymentTerm, DeliveryTerm, Buyer, - Sourcing_staff, + SourcingStaff, Currency, ABC, Active, @@ -402,7 +402,7 @@ Buyer = #{buyer}, - Sourcingstaff = #{sourcingstaff}, + SourcingStaff = #{sourcingstaff}, Currency = #{currency}, @@ -429,13 +429,13 @@ Email2 = #{email2}, - OtherContact1 = #{otherContact1}, + Other_contact1 = #{otherContact1}, - OtherContact2 = #{otherContact2}, + Other_contact2 = #{otherContact2}, - OtherContact3 = #{otherContact3}, + Other_contact3 = #{otherContact3}, Memo = #{memo}