|
@@ -11,6 +11,8 @@ import com.jpsoft.picc.modules.common.dto.MessageResult;
|
|
import com.jpsoft.picc.modules.base.entity.CompanyInvoice;
|
|
import com.jpsoft.picc.modules.base.entity.CompanyInvoice;
|
|
import com.jpsoft.picc.modules.base.service.CompanyInvoiceService;
|
|
import com.jpsoft.picc.modules.base.service.CompanyInvoiceService;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.jasig.cas.client.authentication.AttributePrincipal;
|
|
import org.jasig.cas.client.authentication.AttributePrincipal;
|
|
@@ -24,7 +26,7 @@ import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
-@RequestMapping("/companyInvoice")
|
|
|
|
|
|
+@RequestMapping("/auth/companyInvoice")
|
|
@Api(description = "companyInvoice")
|
|
@Api(description = "companyInvoice")
|
|
public class CompanyInvoiceController {
|
|
public class CompanyInvoiceController {
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
@@ -64,27 +66,72 @@ public class CompanyInvoiceController {
|
|
|
|
|
|
@PostMapping(value="save")
|
|
@PostMapping(value="save")
|
|
@ApiOperation(value = "保存发票信息")
|
|
@ApiOperation(value = "保存发票信息")
|
|
- public MessageResult<String> save(CompanyInvoice companyInvoice,HttpServletRequest request){
|
|
|
|
- MessageResult<String> messageResult = new MessageResult<>();
|
|
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
+ @ApiImplicitParam(name = "type",value = "发票类型", paramType = "form",dataType = "String"),
|
|
|
|
+ @ApiImplicitParam(name = "title",value = "发票抬头", paramType = "form",dataType = "String"),
|
|
|
|
+ @ApiImplicitParam(name = "identifier",value = "税号", paramType = "form",dataType = "String"),
|
|
|
|
+ @ApiImplicitParam(name = "bank",value = "开户银行", paramType = "form",dataType = "String"),
|
|
|
|
+ @ApiImplicitParam(name = "companyAccount",value = "企业账号", paramType = "form",dataType = "String"),
|
|
|
|
+ @ApiImplicitParam(name = "bankAccount",value = "联行号", paramType = "form",dataType = "String"),
|
|
|
|
+ @ApiImplicitParam(name = "address",value = "企业地址", paramType = "form",dataType = "String"),
|
|
|
|
+ @ApiImplicitParam(name = "telephone",value = "联系电话", paramType = "form",dataType = "String")
|
|
|
|
+ })
|
|
|
|
+ public MessageResult<CompanyInvoice> save(
|
|
|
|
+ @RequestParam(value="type",defaultValue="") String type,
|
|
|
|
+ @RequestParam(value="title",defaultValue="null") String title,
|
|
|
|
+ @RequestParam(value="identifier",defaultValue="null") String identifier,
|
|
|
|
+ @RequestParam(value="bank",defaultValue="null") String bank,
|
|
|
|
+ @RequestParam(value="companyAccount",defaultValue="null") String companyAccount,
|
|
|
|
+ @RequestParam(value="bankAccount",defaultValue="null") String bankAccount,
|
|
|
|
+ @RequestParam(value="address",defaultValue="null") String address,
|
|
|
|
+ @RequestParam(value="telephone",defaultValue="null") String telephone,
|
|
|
|
+ HttpServletRequest request){
|
|
|
|
+ MessageResult<CompanyInvoice> messageResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
try {
|
|
//todo
|
|
//todo
|
|
AttributePrincipal principal = (AttributePrincipal) request.getUserPrincipal();
|
|
AttributePrincipal principal = (AttributePrincipal) request.getUserPrincipal();
|
|
CompanyUser companyUser = companyUserService.findByUserName(principal.getName());
|
|
CompanyUser companyUser = companyUserService.findByUserName(principal.getName());
|
|
|
|
|
|
- if(StringUtils.isNotEmpty(companyInvoice.getId())){
|
|
|
|
|
|
+ CompanyInvoice companyInvoice = companyInvoiceService.getByCompanyId(companyUser.getCompanyId());
|
|
|
|
+
|
|
|
|
+ if(companyInvoice != null){
|
|
companyInvoice.setUpdateBy(principal.getName());
|
|
companyInvoice.setUpdateBy(principal.getName());
|
|
companyInvoice.setUpdateTime(new Date());
|
|
companyInvoice.setUpdateTime(new Date());
|
|
|
|
+
|
|
|
|
+ companyInvoice.setType(type);
|
|
|
|
+ companyInvoice.setTitle(title);
|
|
|
|
+ companyInvoice.setIdentifier(identifier);
|
|
|
|
+ companyInvoice.setBank(bank);
|
|
|
|
+ companyInvoice.setCompanyAccount(companyAccount);
|
|
|
|
+ companyInvoice.setBankAccount(bankAccount);
|
|
|
|
+ companyInvoice.setAddress(address);
|
|
|
|
+ companyInvoice.setTelephone(telephone);
|
|
|
|
+
|
|
companyInvoiceService.update(companyInvoice);
|
|
companyInvoiceService.update(companyInvoice);
|
|
}else{
|
|
}else{
|
|
|
|
+ companyInvoice = new CompanyInvoice();
|
|
|
|
+
|
|
|
|
+ companyInvoice.setId(UUID.randomUUID().toString());
|
|
companyInvoice.setCompanyId(companyUser.getCompanyId());
|
|
companyInvoice.setCompanyId(companyUser.getCompanyId());
|
|
companyInvoice.setDelFlag(false);
|
|
companyInvoice.setDelFlag(false);
|
|
companyInvoice.setCreateBy(principal.getName());
|
|
companyInvoice.setCreateBy(principal.getName());
|
|
companyInvoice.setCreateTime(new Date());
|
|
companyInvoice.setCreateTime(new Date());
|
|
|
|
+
|
|
|
|
+ companyInvoice.setType(type);
|
|
|
|
+ companyInvoice.setTitle(title);
|
|
|
|
+ companyInvoice.setIdentifier(identifier);
|
|
|
|
+ companyInvoice.setBank(bank);
|
|
|
|
+ companyInvoice.setCompanyAccount(companyAccount);
|
|
|
|
+ companyInvoice.setBankAccount(bankAccount);
|
|
|
|
+ companyInvoice.setAddress(address);
|
|
|
|
+ companyInvoice.setTelephone(telephone);
|
|
|
|
+
|
|
companyInvoiceService.insert(companyInvoice);
|
|
companyInvoiceService.insert(companyInvoice);
|
|
}
|
|
}
|
|
|
|
|
|
messageResult.setResult(true);
|
|
messageResult.setResult(true);
|
|
|
|
+ messageResult.setData(companyInvoice);
|
|
}
|
|
}
|
|
catch (Exception ex){
|
|
catch (Exception ex){
|
|
messageResult.setResult(false);
|
|
messageResult.setResult(false);
|