|
|
@@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
import org.jeecg.common.system.base.controller.JeecgController;
|
|
|
+import org.jeecg.common.util.businessAccountUtils;
|
|
|
import org.jeecg.modules.hlwinvoice.entity.HlwInvoice;
|
|
|
import org.jeecg.modules.hlwinvoice.service.IHlwInvoiceService;
|
|
|
import org.jeecg.modules.hlwsubcontractor.entity.HlwSubcontractorAccountFlow;
|
|
|
@@ -73,6 +74,61 @@ public class HlwInvoiceApiController extends JeecgController<HlwInvoice, IHlwInv
|
|
|
return Result.ok(pageList);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 能否开票
|
|
|
+ *
|
|
|
+ * @param jsonObject
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @AutoLog(value = "能否开票")
|
|
|
+ @ApiOperation(value = "能否开票", notes = "能否开票")
|
|
|
+ @PostMapping(value = "/checkApply")
|
|
|
+ public Result<?> checkApply(@RequestBody JSONObject jsonObject) {
|
|
|
+ Integer applicationId = jsonObject.getInteger("applicationId");
|
|
|
+ JSONArray jsonArray = jsonObject.getJSONArray("idsList");
|
|
|
+ List<Integer> idsList=new ArrayList<>();
|
|
|
+ for (int i = 0; i <jsonArray.size() ; i++) {
|
|
|
+ idsList.add((Integer)jsonArray.get(i));
|
|
|
+ }
|
|
|
+ HlwSubcontractorAccountFlow hlwSubcontractorAccountFlow1 = hlwSubcontractorAccountFlowService.getHlwSubcontractorAccountFlowById(idsList.get(0));
|
|
|
+ hlwSubcontractorAccountFlow1.setIdsList(idsList);
|
|
|
+ if (idsList.size() == 1) {
|
|
|
+ //选择单个直接返回实体对象
|
|
|
+ return Result.ok(hlwSubcontractorAccountFlow1);
|
|
|
+ }
|
|
|
+ Double totalPayment = 0.00;
|
|
|
+ Double serviceAmount=0.00;
|
|
|
+ for (int i = 0; i < idsList.size(); i++) {
|
|
|
+ HlwSubcontractorAccountFlow hlwSubcontractorAccountFlow2 = hlwSubcontractorAccountFlowService.getHlwSubcontractorAccountFlowById(idsList.get(i));
|
|
|
+ if(hlwSubcontractorAccountFlow2.getIsThroughPlatform()==1){
|
|
|
+ //选择多个如果选择的付款企业和收款服务商有不同的则返回错误提示
|
|
|
+ if (i < idsList.size() - 1) {
|
|
|
+ HlwSubcontractorAccountFlow hlwSubcontractorAccountFlow3 = hlwSubcontractorAccountFlowService.getHlwSubcontractorAccountFlowById(idsList.get(i + 1));
|
|
|
+ if (!hlwSubcontractorAccountFlow2.getSubcontractorId().equals(hlwSubcontractorAccountFlow3.getSubcontractorId()) ||
|
|
|
+ !hlwSubcontractorAccountFlow2.getIsThroughPlatform().equals(hlwSubcontractorAccountFlow3.getIsThroughPlatform())||
|
|
|
+ !hlwSubcontractorAccountFlow2.getCpId().equals(hlwSubcontractorAccountFlow3.getCpId())) {
|
|
|
+ return Result.error("请选择付款企业、收款服务商都相同的数据");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ serviceAmount = businessAccountUtils.add(serviceAmount, businessAccountUtils.add(hlwSubcontractorAccountFlow2.getCompanyCpAmount(),hlwSubcontractorAccountFlow2.getCompanyCpServiceFee()));
|
|
|
+ }else{
|
|
|
+ //选择多个如果选择的付款企业和收款服务商有不同的则返回错误提示
|
|
|
+ if (i < idsList.size() - 1) {
|
|
|
+ HlwSubcontractorAccountFlow hlwSubcontractorAccountFlow3 = hlwSubcontractorAccountFlowService.getHlwSubcontractorAccountFlowById(idsList.get(i + 1));
|
|
|
+ if (!hlwSubcontractorAccountFlow2.getCompanyId().equals(hlwSubcontractorAccountFlow3.getCompanyId()) ||
|
|
|
+ !hlwSubcontractorAccountFlow2.getSubcontractorId().equals(hlwSubcontractorAccountFlow3.getSubcontractorId()) ||
|
|
|
+ !hlwSubcontractorAccountFlow2.getIsThroughPlatform().equals(hlwSubcontractorAccountFlow3.getIsThroughPlatform())) {
|
|
|
+ return Result.error("请选择付款企业、收款服务商都相同的数据");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ totalPayment = businessAccountUtils.add(totalPayment, businessAccountUtils.add(hlwSubcontractorAccountFlow2.getAmount(),hlwSubcontractorAccountFlow2.getServiceFee()));
|
|
|
+ }
|
|
|
+ //将所有选择付款的金额总和存放到准备返回的对象里
|
|
|
+ hlwSubcontractorAccountFlow1.setTotalPayment(totalPayment);
|
|
|
+ hlwSubcontractorAccountFlow1.setServiceAmount(serviceAmount);
|
|
|
+ //如果都相同则返回所需开票页面参数实体对象
|
|
|
+ return Result.ok(hlwSubcontractorAccountFlow1);
|
|
|
+ }
|
|
|
|
|
|
}
|