批量查验加入收费逻辑

beta-prop-all
kk 2 years ago
parent 59b268b365
commit 80c0d73fc8
  1. 10
      jianshui-admin/src/main/java/com/jianshui/api/controller/http/income/v1/InvoiceCheckController.java
  2. 5
      jianshui-income/src/main/java/com/jianshui/income/service/impl/EleCheckInvoiceImpl.java
  3. 4
      jianshui-invoice/src/main/java/com/jianshui/invoice/utils/BillDetailFormatUtil.java
  4. 3
      jianshui-system/src/main/java/com/jianshui/system/service/IServiceManageService.java
  5. 55
      jianshui-system/src/main/java/com/jianshui/system/service/impl/ServiceManageServiceImpl.java

@ -114,6 +114,16 @@ public class InvoiceCheckController {
ICheckInvoice incomeService = incomeServiceFactory.getService(serviceKey); ICheckInvoice incomeService = incomeServiceFactory.getService(serviceKey);
AjaxResult result = incomeService.checkInvoiceMultil(companyservice, invoiceCheck); AjaxResult result = incomeService.checkInvoiceMultil(companyservice, invoiceCheck);
// 2023/11/30 新增扣费逻辑,成功就扣
if (result.isSuccess()) {
JSONObject resp = result.getJsonData();
Integer robUser = resp.getInteger("robUserMoney");
if (robUser != null && robUser >= 1) {
serviceManageService.companyConsume("income", companyservice.getCompanyid(),robUser);
}
}
String responseAdapterKey = serviceManageService.getResponseAdapterKey("income", companyservice.getCompanyid()); String responseAdapterKey = serviceManageService.getResponseAdapterKey("income", companyservice.getCompanyid());
IIncomeResponseService incomeResponseService = incomeResponseFactory.getService(responseAdapterKey); IIncomeResponseService incomeResponseService = incomeResponseFactory.getService(responseAdapterKey);
return incomeResponseService.response(result, companyservice, "check_multil"); return incomeResponseService.response(result, companyservice, "check_multil");

@ -282,8 +282,11 @@ public class EleCheckInvoiceImpl implements ICheckInvoice {
return AjaxResult.error(errorCode, errorString); return AjaxResult.error(errorCode, errorString);
} }
JSONObject result = new JSONObject();
result.put("robUserMoney", invoiceCheckList.size());
return new AjaxResult(200, "批次接收成功!", result);
return AjaxResult.success("批次接收成功!"); // return AjaxResult.success("批次接收成功!");
} }
/** /**

@ -144,9 +144,9 @@ public class BillDetailFormatUtil {
BillDetail billDetail = JSONObject.parseObject(JSONObject.toJSONString(billDetailRaw), BillDetail.class); BillDetail billDetail = JSONObject.parseObject(JSONObject.toJSONString(billDetailRaw), BillDetail.class);
Integer fphxz = billDetail.getFphxz(); Integer fphxz = billDetail.getFphxz();
// 如果是被折扣行,直接返回 // 如果是被折扣行,直接返回
if (fphxz != null && fphxz == 1) { /*if (fphxz != null && fphxz == 1) {
return AjaxResult.error(300, "明细行为被折扣行"); return AjaxResult.error(300, "明细行为被折扣行");
} }*/
//如果税率为空,直接返回 //如果税率为空,直接返回
if (billDetail.getTaxrate() == null) { if (billDetail.getTaxrate() == null) {
return AjaxResult.error("税率为空", billDetail); return AjaxResult.error("税率为空", billDetail);

@ -88,6 +88,9 @@ public interface IServiceManageService {
*/ */
public AjaxResult companyConsume(String serviceKey, Long companyid); public AjaxResult companyConsume(String serviceKey, Long companyid);
/** 对指定服务进行消费减n */
public AjaxResult companyConsume(String serviceKey, Long companyid,int num);
/** /**
* 获得入口请求适配器 * 获得入口请求适配器
* *

@ -151,6 +151,14 @@ public class ServiceManageServiceImpl implements IServiceManageService {
setCache(config); setCache(config);
} }
/** 剩余次数减n */
private void subNumSurplus(ServiceManage config,int num ) {
config.setSurplus(config.getSurplus() - num);
// 更新记录
serviceManageMapper.updateSurplus(config);
setCache(config);
}
/** /**
* 清空缓存 * 清空缓存
*/ */
@ -249,6 +257,53 @@ public class ServiceManageServiceImpl implements IServiceManageService {
} }
/** 扣费,根据传入的次数决定扣几次 */
@Override
public AjaxResult companyConsume(String serviceKey, Long companyid,int num) {
ServiceManage serviceManage = selectServiceManageByCompanyIdAndServiceKey(serviceKey, companyid);
if (serviceManage == null) {
throw new JianshuiNoServiceException("此销方未配置应用服务", serviceKey, companyid);
}
// 处理扣费逻辑
// 如果过期时间不为Null
Date expireTime = serviceManage.getExpireTime();
Date now = DateUtils.getNowDate();
// 如果过期了
if (expireTime != null) {
if (expireTime.getTime() < now.getTime()) {
throw new JianshuiServiceExpireException("服务已过期", serviceKey, companyid);
}
}
// 免费
if (StringUtils.equals("0", serviceManage.getServiceMode())) {
// 调用次数 -n
subNumSurplus(serviceManage,num);
return AjaxResult.success("消费成功");
}
// 预付费
if (StringUtils.equals("1", serviceManage.getServiceMode())) {
// 调用次数 -n
if (serviceManage.getSurplus() <= 0) {
throw new JianshuiServiceNoSurplusException("服务次数不足", serviceKey, companyid);
}
subNumSurplus(serviceManage,num);
return AjaxResult.success("消费成功");
}
// 定期结算
if (StringUtils.equals("2", serviceManage.getServiceMode())) {
subNumSurplus(serviceManage,num);
return AjaxResult.success("消费成功");
}
return AjaxResult.error("未知的消费模式");
}
/** /**
* 获得入口请求适配器 * 获得入口请求适配器
* *