1 Commits

Author SHA1 Message Date
Lemon
cc532bfcec 新增 发票导出接口 2026-07-16 15:21:42 +08:00
19 changed files with 324 additions and 191 deletions

View File

@@ -237,12 +237,9 @@ public class AdapayMemberController extends BaseController {
try { try {
adapayService.updateSettleAccountConfig(dto); adapayService.updateSettleAccountConfig(dto);
result = AjaxResult.success(); result = AjaxResult.success();
} catch (BusinessException e) {
logger.warn("修改汇付结算配置warn", e);
result = AjaxResult.error(e.getMessage());
} catch (BaseAdaPayException e) { } catch (BaseAdaPayException e) {
logger.error("修改汇付结算配置error", e); logger.error("查询汇付账户余额error", e);
result = AjaxResult.error("修改汇付结算配置异常"); result = AjaxResult.error();
} }
return result; return result;
} }
@@ -257,12 +254,9 @@ public class AdapayMemberController extends BaseController {
try { try {
adapayService.changeBankCard(dto); adapayService.changeBankCard(dto);
result = AjaxResult.success(); result = AjaxResult.success();
} catch (BusinessException e) {
logger.warn("换绑银行卡warn", e);
result = AjaxResult.error(e.getMessage());
} catch (BaseAdaPayException e) { } catch (BaseAdaPayException e) {
logger.error("换绑银行卡error", e); logger.error("换绑银行卡error", e);
result = AjaxResult.error("换绑银行卡异常"); result = AjaxResult.error();
} }
return result; return result;
} }
@@ -298,14 +292,12 @@ public class AdapayMemberController extends BaseController {
public AjaxResult deleteSettleAccount(@RequestBody AdapayMemberInfoDTO dto) { public AjaxResult deleteSettleAccount(@RequestBody AdapayMemberInfoDTO dto) {
AjaxResult result = null; AjaxResult result = null;
try { try {
// 新写删除方法
adapayService.deleteSettleAccount(dto); adapayService.deleteSettleAccount(dto);
result = AjaxResult.success(); result = AjaxResult.success();
} catch (BusinessException e) {
logger.warn("删除结算账户warn", e);
result = AjaxResult.error(e.getMessage());
} catch (Exception e) { } catch (Exception e) {
logger.error("删除结算账户 error,", e); logger.error("删除结算账户 error,", e);
result = AjaxResult.error("删除结算账户异常"); result = AjaxResult.error();
} }
return result; return result;
} }
@@ -322,13 +314,9 @@ public class AdapayMemberController extends BaseController {
AjaxResult result = null; AjaxResult result = null;
try { try {
adapayService.createBankAccount(dto); adapayService.createBankAccount(dto);
result = AjaxResult.success();
} catch (BusinessException e) {
logger.warn("重新创建结算账户warn", e);
result = AjaxResult.error(e.getMessage());
} catch (Exception e) { } catch (Exception e) {
logger.error("重新创建结算账户 error, ", e); logger.error("重新创建结算账户 error, ", e);
result = AjaxResult.error("重新创建结算账户异常"); result = AjaxResult.error();
} }
return result; return result;
} }

View File

@@ -10,6 +10,7 @@ import com.jsowell.pile.domain.OrderInvoiceRecord;
import com.jsowell.pile.dto.GetInvoiceInfoDTO; import com.jsowell.pile.dto.GetInvoiceInfoDTO;
import com.jsowell.pile.service.OrderInvoiceRecordService; import com.jsowell.pile.service.OrderInvoiceRecordService;
import com.jsowell.pile.service.PileMerchantInfoService; import com.jsowell.pile.service.PileMerchantInfoService;
import com.jsowell.pile.vo.web.OrderInvoiceExportVO;
import com.jsowell.pile.vo.web.OrderInvoiceRecordVO; import com.jsowell.pile.vo.web.OrderInvoiceRecordVO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
@@ -18,6 +19,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@@ -64,6 +66,18 @@ public class OrderInvoiceRecordController extends BaseController {
util.exportExcel(response, list, "申请开票数据"); util.exportExcel(response, list, "申请开票数据");
} }
/**
* 导出所选申请开票详情
*/
@PreAuthorize("@ss.hasPermi('order:invoice:export')")
@Log(title = "申请开票", businessType = BusinessType.EXPORT)
@PostMapping("/export/selected")
public void exportSelected(HttpServletResponse response, @RequestParam("ids") Integer[] ids) {
List<OrderInvoiceExportVO> list = orderInvoiceRecordService.selectInvoiceExportList(ids);
ExcelUtil<OrderInvoiceExportVO> util = new ExcelUtil<OrderInvoiceExportVO>(OrderInvoiceExportVO.class);
util.exportExcel(response, list, "所选申请开票详情数据");
}
/** /**
* 获取申请开票详细信息 * 获取申请开票详细信息
*/ */

View File

@@ -14,9 +14,8 @@ public enum AdapayOpenActionEnum {
UPDATE_CORP_MEMBER("UPDATE_CORP_MEMBER", "更新企业资料"), UPDATE_CORP_MEMBER("UPDATE_CORP_MEMBER", "更新企业资料"),
RESUBMIT_CORP_MEMBER("RESUBMIT_CORP_MEMBER", "重新提交企业开户"), RESUBMIT_CORP_MEMBER("RESUBMIT_CORP_MEMBER", "重新提交企业开户"),
CREATE_SETTLE_ACCOUNT("CREATE_SETTLE_ACCOUNT", "创建结算账户"), CREATE_SETTLE_ACCOUNT("CREATE_SETTLE_ACCOUNT", "创建结算账户"),
UPDATE_SETTLE_ACCOUNT_CONFIG("UPDATE_SETTLE_ACCOUNT_CONFIG", "修改结算配置"),
DELETE_SETTLE_ACCOUNT("DELETE_SETTLE_ACCOUNT", "删除结算账户"), DELETE_SETTLE_ACCOUNT("DELETE_SETTLE_ACCOUNT", "删除结算账户"),
DELETE_MEMBER("DELETE_MEMBER", "删除账户(本地解绑)"); DELETE_MEMBER("DELETE_MEMBER", "删除汇付用户");
private final String value; private final String value;
private final String label; private final String label;

View File

@@ -59,8 +59,5 @@ public class QueryMemberResponse extends AdapayBaseResponse{
private String bank_acct_type; private String bank_acct_type;
private String prov_code; private String prov_code;
private String card_id; private String card_id;
private String min_amt;
private String remained_amt;
private String channel_remark;
} }
} }

View File

@@ -83,9 +83,6 @@ public class AdapayService {
@Autowired @Autowired
private PileMerchantInfoService pileMerchantInfoService; private PileMerchantInfoService pileMerchantInfoService;
@Autowired
private StationSplitConfigService stationSplitConfigService;
@Autowired @Autowired
private MemberBasicInfoService memberBasicInfoService; private MemberBasicInfoService memberBasicInfoService;
@@ -327,11 +324,8 @@ public class AdapayService {
String wechatAppId = pileMerchantInfoService.queryAppIdByMerchantId(dto.getMerchantId()); String wechatAppId = pileMerchantInfoService.queryAppIdByMerchantId(dto.getMerchantId());
SettleAccountDTO request = buildSettleAccountDTO(dto); SettleAccountDTO request = buildSettleAccountDTO(dto);
Map<String, Object> settleCount = createSettleAccountRequest(request, adapayMemberAccount.getAdapayMemberId(), wechatAppId); Map<String, Object> settleCount = createSettleAccountRequest(request, adapayMemberAccount.getAdapayMemberId(), wechatAppId);
if (settleCount == null if (settleCount == null || StringUtils.equals((String) settleCount.get("status"), "failed")) {
|| !AdapayStatusEnum.SUCCEEDED.getValue().equals(settleCount.get("status")) String errorMsg = settleCount == null ? "创建汇付结算账户失败" : (String) settleCount.get("error_msg");
|| StringUtils.isBlank((String) settleCount.get("id"))) {
String errorMsg = settleCount == null ? null : (String) settleCount.get("error_msg");
errorMsg = StringUtils.isNotBlank(errorMsg) ? errorMsg : "创建汇付结算账户失败";
throw new BusinessException("00500001", errorMsg); throw new BusinessException("00500001", errorMsg);
} }
@@ -351,7 +345,13 @@ public class AdapayService {
return Lists.newArrayList(); return Lists.newArrayList();
} }
String wechatAppId = pileMerchantInfoService.queryAppIdByMerchantId(merchantId); String wechatAppId = pileMerchantInfoService.queryAppIdByMerchantId(merchantId);
String settleAccountId = resolveSettleAccountId(adapayMemberAccount, wechatAppId); String settleAccountId = adapayMemberAccount.getSettleAccountId();
if (StringUtils.isBlank(settleAccountId) && isCorpMember(adapayMemberAccount.getAdapayMemberId())) {
AdapayCorpMemberVO corpMemberVO = queryCorpAdapayMemberInfo(adapayMemberAccount.getAdapayMemberId(), wechatAppId);
if (corpMemberVO != null) {
settleAccountId = corpMemberVO.getSettleAccountId();
}
}
AdapaySettleAccountVO adapaySettleAccountVO = queryAdapaySettleAccount(adapayMemberAccount.getAdapayMemberId(), settleAccountId, wechatAppId); AdapaySettleAccountVO adapaySettleAccountVO = queryAdapaySettleAccount(adapayMemberAccount.getAdapayMemberId(), settleAccountId, wechatAppId);
if (adapaySettleAccountVO == null) { if (adapaySettleAccountVO == null) {
return Lists.newArrayList(); return Lists.newArrayList();
@@ -360,35 +360,6 @@ public class AdapayService {
return Lists.newArrayList(adapaySettleAccountVO); return Lists.newArrayList(adapaySettleAccountVO);
} }
private String resolveSettleAccountId(AdapayMemberAccount account, String wechatAppId) throws BaseAdaPayException {
if (StringUtils.isNotBlank(account.getSettleAccountId())) {
return account.getSettleAccountId();
}
String settleAccountId = null;
if (isPersonalMember(account.getAdapayMemberId())) {
AdapayMemberInfoVO memberInfo = queryAdapayMemberInfo(account.getAdapayMemberId(), wechatAppId);
if (memberInfo != null) {
settleAccountId = memberInfo.getSettleAccountId();
}
} else {
AdapayCorpMemberVO corpMember = queryCorpAdapayMemberInfo(account.getAdapayMemberId(), wechatAppId);
if (corpMember != null) {
settleAccountId = corpMember.getSettleAccountId();
}
}
if (StringUtils.isNotBlank(settleAccountId)) {
AdapayMemberAccount updateRecord = new AdapayMemberAccount();
updateRecord.setMerchantId(account.getMerchantId());
updateRecord.setAdapayMemberId(account.getAdapayMemberId());
updateRecord.setSettleAccountId(settleAccountId);
adapayMemberAccountService.updateAdapayMemberAccountByMemberId(updateRecord);
account.setSettleAccountId(settleAccountId);
}
return settleAccountId;
}
/** /**
* 创建汇付会员 * 创建汇付会员
* *
@@ -527,21 +498,12 @@ public class AdapayService {
} }
QueryMemberResponse queryMemberResponse = JSON.parseObject(JSON.toJSONString(member), QueryMemberResponse.class); QueryMemberResponse queryMemberResponse = JSON.parseObject(JSON.toJSONString(member), QueryMemberResponse.class);
String settleAccountId = null;
if (CollectionUtils.isNotEmpty(queryMemberResponse.getSettle_accounts())) {
settleAccountId = queryMemberResponse.getSettle_accounts().stream()
.map(QueryMemberResponse.SettleAccount::getId)
.filter(StringUtils::isNotBlank)
.findFirst()
.orElse(null);
}
AdapayMemberInfoVO resultVO = AdapayMemberInfoVO.builder() AdapayMemberInfoVO resultVO = AdapayMemberInfoVO.builder()
.memberId(adapayMemberId) .memberId(adapayMemberId)
.nickname(queryMemberResponse.getNickname()) .nickname(queryMemberResponse.getNickname())
.gender(queryMemberResponse.getGender()) .gender(queryMemberResponse.getGender())
.email(queryMemberResponse.getEmail()) .email(queryMemberResponse.getEmail())
.location(queryMemberResponse.getLocation()) .location(queryMemberResponse.getLocation())
.settleAccountId(settleAccountId)
.build(); .build();
return resultVO; return resultVO;
} }
@@ -673,11 +635,6 @@ public class AdapayService {
settleCountParams.put("app_id", config.getAdapayAppId()); settleCountParams.put("app_id", config.getAdapayAppId());
Map<String, Object> settleCount = SettleAccount.delete(settleCountParams, wechatAppId); Map<String, Object> settleCount = SettleAccount.delete(settleCountParams, wechatAppId);
log.info("创建删除结算账户请求param:{}, result:{}", JSON.toJSONString(settleCountParams), JSON.toJSONString(settleCount)); log.info("创建删除结算账户请求param:{}, result:{}", JSON.toJSONString(settleCountParams), JSON.toJSONString(settleCount));
if (settleCount == null
|| !AdapayStatusEnum.SUCCEEDED.getValue().equals(settleCount.get("status"))) {
String errorMsg = settleCount == null ? null : (String) settleCount.get("error_msg");
throw new BusinessException("", StringUtils.isNotBlank(errorMsg) ? errorMsg : "删除汇付结算账户失败");
}
} }
/** /**
@@ -721,9 +678,6 @@ public class AdapayService {
.bankAcctType(accountInfo.getBank_acct_type()) .bankAcctType(accountInfo.getBank_acct_type())
.provCode(accountInfo.getProv_code()) .provCode(accountInfo.getProv_code())
.areaCode(accountInfo.getArea_code()) .areaCode(accountInfo.getArea_code())
.minAmt(accountInfo.getMin_amt())
.remainedAmt(accountInfo.getRemained_amt())
.channelRemark(accountInfo.getChannel_remark())
.build(); .build();
return resultVO; return resultVO;
} }
@@ -814,7 +768,6 @@ public class AdapayService {
* @throws BaseAdaPayException * @throws BaseAdaPayException
*/ */
public void updateSettleAccountConfig(UpdateAccountConfigDTO dto) throws BaseAdaPayException { public void updateSettleAccountConfig(UpdateAccountConfigDTO dto) throws BaseAdaPayException {
assertActionAllowed(dto.getMerchantId(), AdapayOpenActionEnum.UPDATE_SETTLE_ACCOUNT_CONFIG);
String wechatAppId = pileMerchantInfoService.queryAppIdByMerchantId(dto.getMerchantId()); String wechatAppId = pileMerchantInfoService.queryAppIdByMerchantId(dto.getMerchantId());
// 获取汇付支付配置 // 获取汇付支付配置
AbstractAdapayConfig config = AdapayConfigFactory.getConfig(wechatAppId); AbstractAdapayConfig config = AdapayConfigFactory.getConfig(wechatAppId);
@@ -823,19 +776,16 @@ public class AdapayService {
} }
// 通过merchantId 查询出汇付会员id 和 结算账户id用来查询余额 // 通过merchantId 查询出汇付会员id 和 结算账户id用来查询余额
AdapayMemberAccount adapayMemberAccount = requireCurrentMemberAccount(dto.getMerchantId()); AdapayMemberAccount adapayMemberAccount = adapayMemberAccountService.selectByMerchantId(dto.getMerchantId());
String settleAccountId = resolveSettleAccountId(adapayMemberAccount, wechatAppId); if (adapayMemberAccount == null) {
if (StringUtils.isBlank(settleAccountId)) { log.error("通过merchantId:{}, 没有查询到结算账户配置", dto.getMerchantId());
throw new BusinessException("", "未查询到结算账户"); return;
}
if (StringUtils.isAllBlank(dto.getMinAmt(), dto.getRemainedAmt(), dto.getChannelRemark())) {
throw new BusinessException("", "结算起始金额、结算留存金额和结算摘要至少填写一项");
} }
// 修改账户配置 // 修改账户配置
Map<String, Object> params = Maps.newHashMap(); Map<String, Object> params = Maps.newHashMap();
params.put("app_id", config.getAdapayAppId()); params.put("app_id", config.getAdapayAppId());
params.put("member_id", adapayMemberAccount.getAdapayMemberId()); params.put("member_id", adapayMemberAccount.getAdapayMemberId());
params.put("settle_account_id", settleAccountId); params.put("settle_account_id", adapayMemberAccount.getSettleAccountId());
if (StringUtils.isNotBlank(dto.getMinAmt())) { if (StringUtils.isNotBlank(dto.getMinAmt())) {
params.put("min_amt", dto.getMinAmt()); params.put("min_amt", dto.getMinAmt());
} }
@@ -845,13 +795,8 @@ public class AdapayService {
if (StringUtils.isNotBlank(dto.getChannelRemark())) { if (StringUtils.isNotBlank(dto.getChannelRemark())) {
params.put("channel_remark", dto.getChannelRemark()); params.put("channel_remark", dto.getChannelRemark());
} }
Map<String, Object> settleCount = SettleAccount.modify(params, config.getWechatAppId()); Map<String, Object> settleCount = SettleAccount.update(params);
log.info("更新结算账户设置 param:{}, result:{}", JSON.toJSONString(params), JSON.toJSONString(settleCount)); log.info("更新结算账户设置 param:{}, result:{}", JSON.toJSONString(params), JSON.toJSONString(settleCount));
if (settleCount == null
|| !AdapayStatusEnum.SUCCEEDED.getValue().equals(settleCount.get("status"))) {
String errorMsg = settleCount == null ? null : (String) settleCount.get("error_msg");
throw new BusinessException("", StringUtils.isNotBlank(errorMsg) ? errorMsg : "修改汇付结算配置失败");
}
} }
/** /**
@@ -1730,20 +1675,38 @@ public class AdapayService {
* 用户需要换绑银行卡 1-删除结算账户信息2-使用新账户信息创建结算账户】 * 用户需要换绑银行卡 1-删除结算账户信息2-使用新账户信息创建结算账户】
*/ */
public void changeBankCard(ChangeBankCardDTO dto) throws BaseAdaPayException { public void changeBankCard(ChangeBankCardDTO dto) throws BaseAdaPayException {
deleteSettleAccount(AdapayMemberInfoDTO.builder().merchantId(dto.getMerchantId()).build()); String wechatAppId = pileMerchantInfoService.queryAppIdByMerchantId(dto.getMerchantId());
CreateSettleAccountDTO createRequest = CreateSettleAccountDTO.builder() // 获取汇付支会员信息
.merchantId(dto.getMerchantId()) AdapayMemberAccount account = adapayMemberAccountService.selectByMerchantId(dto.getMerchantId());
.bankAcctType(dto.getBankAcctType()) if (account == null) {
.cardId(dto.getCardId()) return;
.cardName(dto.getCardName()) }
.certId(dto.getCertId())
.certType(dto.getCertType()) // 1-删除结算账户信息
.telNo(dto.getTelNo()) String adapayMemberId = account.getAdapayMemberId();
.bankCode(dto.getBankCode()) String settleAccountId = null;
.provCode(dto.getProvCode()) AdapayCorpMemberVO adapayCorpMemberVO = this.queryCorpAdapayMemberInfo(adapayMemberId, wechatAppId);
.areaCode(dto.getAreaCode()) if (adapayCorpMemberVO != null) {
.build(); settleAccountId = adapayCorpMemberVO.getSettleAccountId();
createSettleAccount(createRequest); }
this.createDeleteSettleAccountRequest(adapayMemberId, settleAccountId, wechatAppId);
// 2-使用新账户信息创建结算账户
SettleAccountDTO settleAccountDTO = new SettleAccountDTO();
settleAccountDTO.setCardId(dto.getCardId());
settleAccountDTO.setCardName(dto.getCardName());
settleAccountDTO.setTelNo(dto.getTelNo());
settleAccountDTO.setBankCode(dto.getBankCode());
settleAccountDTO.setBankAcctType(dto.getBankAcctType());
settleAccountDTO.setProvCode(dto.getProvCode());
settleAccountDTO.setAreaCode(dto.getAreaCode());
Map<String, Object> settleAccount = this.createSettleAccountRequest(settleAccountDTO, adapayMemberId, wechatAppId);
if (settleAccount != null && !StringUtils.equals((String) settleAccount.get("status"), "failed")) {
AdapayMemberAccount updateRecord = new AdapayMemberAccount();
updateRecord.setAdapayMemberId(adapayMemberId);
updateRecord.setMerchantId(dto.getMerchantId());
updateRecord.setSettleAccountId((String) settleAccount.get("id"));
adapayMemberAccountService.updateAdapayMemberAccountByMemberId(updateRecord);
}
} }
/** /**
@@ -1834,27 +1797,21 @@ public class AdapayService {
assertActionAllowed(dto.getMerchantId(), AdapayOpenActionEnum.DELETE_SETTLE_ACCOUNT); assertActionAllowed(dto.getMerchantId(), AdapayOpenActionEnum.DELETE_SETTLE_ACCOUNT);
AdapayMemberAccount adapayMemberAccount = requireCurrentMemberAccount(dto.getMerchantId()); AdapayMemberAccount adapayMemberAccount = requireCurrentMemberAccount(dto.getMerchantId());
String wechatAppId = pileMerchantInfoService.queryAppIdByMerchantId(dto.getMerchantId()); String wechatAppId = pileMerchantInfoService.queryAppIdByMerchantId(dto.getMerchantId());
String adapayMemberId = adapayMemberAccount.getAdapayMemberId(); String adapayMemberId = StringUtils.isNotBlank(dto.getAdapayMemberId()) ? dto.getAdapayMemberId() : adapayMemberAccount.getAdapayMemberId();
if (StringUtils.isNotBlank(dto.getAdapayMemberId()) String settleAccountId = StringUtils.isNotBlank(dto.getSettleAccountId()) ? dto.getSettleAccountId() : adapayMemberAccount.getSettleAccountId();
&& !StringUtils.equals(dto.getAdapayMemberId(), adapayMemberId)) { if (StringUtils.isBlank(settleAccountId) && isCorpMember(adapayMemberId)) {
throw new BusinessException("", "汇付用户信息不匹配"); AdapayCorpMemberVO corpMemberVO = queryCorpAdapayMemberInfo(adapayMemberId, wechatAppId);
if (corpMemberVO != null) {
settleAccountId = corpMemberVO.getSettleAccountId();
}
} }
String settleAccountId = resolveSettleAccountId(adapayMemberAccount, wechatAppId);
if (StringUtils.isBlank(settleAccountId)) { if (StringUtils.isBlank(settleAccountId)) {
throw new BusinessException("", "未查询到结算账户"); throw new BusinessException("", "未查询到结算账户");
} }
if (StringUtils.isNotBlank(dto.getSettleAccountId())
&& !StringUtils.equals(dto.getSettleAccountId(), settleAccountId)) {
throw new BusinessException("", "结算账户信息不匹配");
}
assertSettleAccountCanDelete(dto.getMerchantId()); assertSettleAccountCanDelete(dto.getMerchantId());
this.createDeleteSettleAccountRequest(adapayMemberId, settleAccountId, wechatAppId); this.createDeleteSettleAccountRequest(adapayMemberId, settleAccountId, wechatAppId);
int cleared = adapayMemberAccountService.clearCurrentSettleAccount( adapayMemberAccountService.clearSettleAccountByMerchantId(dto.getMerchantId());
adapayMemberAccount.getId(), dto.getMerchantId(), adapayMemberId, settleAccountId);
if (cleared != 1) {
throw new BusinessException("", "汇付结算账户已删除,但本地账户状态更新失败,请联系管理员处理");
}
} }
public void deleteAdapayMember(DeleteAdapayMemberDTO dto) throws BaseAdaPayException { public void deleteAdapayMember(DeleteAdapayMemberDTO dto) throws BaseAdaPayException {
@@ -1868,16 +1825,7 @@ public class AdapayService {
if (CollectionUtils.isNotEmpty(selectSettleAccount(dto.getMerchantId()))) { if (CollectionUtils.isNotEmpty(selectSettleAccount(dto.getMerchantId()))) {
throw new BusinessException("", "请先删除结算账户"); throw new BusinessException("", "请先删除结算账户");
} }
assertSettleAccountCanDelete(dto.getMerchantId()); adapayMemberAccountService.deleteAccountByMerchantId(dto.getMerchantId());
int splitStationCount = stationSplitConfigService.countActiveByAdapayMemberId(adapayMemberAccount.getAdapayMemberId());
if (splitStationCount > 0) {
throw new BusinessException("", String.format("当前账户仍被%d个站点的分账配置引用请先调整分账配置", splitStationCount));
}
int deleted = adapayMemberAccountService.deleteCurrentAccount(
adapayMemberAccount.getId(), dto.getMerchantId(), adapayMemberAccount.getAdapayMemberId());
if (deleted != 1) {
throw new BusinessException("", "账户状态已变化,请刷新后重试");
}
} }
/** /**
@@ -2053,7 +2001,6 @@ public class AdapayService {
break; break;
case PERSONAL_COMPLETED: case PERSONAL_COMPLETED:
actions.add(AdapayOpenActionEnum.UPDATE_PERSONAL_MEMBER.getValue()); actions.add(AdapayOpenActionEnum.UPDATE_PERSONAL_MEMBER.getValue());
actions.add(AdapayOpenActionEnum.UPDATE_SETTLE_ACCOUNT_CONFIG.getValue());
actions.add(AdapayOpenActionEnum.DELETE_SETTLE_ACCOUNT.getValue()); actions.add(AdapayOpenActionEnum.DELETE_SETTLE_ACCOUNT.getValue());
break; break;
case CORP_AUDITING: case CORP_AUDITING:
@@ -2067,11 +2014,9 @@ public class AdapayService {
case CORP_OPENED_NO_SETTLE: case CORP_OPENED_NO_SETTLE:
actions.add(AdapayOpenActionEnum.CREATE_SETTLE_ACCOUNT.getValue()); actions.add(AdapayOpenActionEnum.CREATE_SETTLE_ACCOUNT.getValue());
actions.add(AdapayOpenActionEnum.UPDATE_CORP_MEMBER.getValue()); actions.add(AdapayOpenActionEnum.UPDATE_CORP_MEMBER.getValue());
actions.add(AdapayOpenActionEnum.DELETE_MEMBER.getValue());
break; break;
case CORP_COMPLETED: case CORP_COMPLETED:
actions.add(AdapayOpenActionEnum.UPDATE_CORP_MEMBER.getValue()); actions.add(AdapayOpenActionEnum.UPDATE_CORP_MEMBER.getValue());
actions.add(AdapayOpenActionEnum.UPDATE_SETTLE_ACCOUNT_CONFIG.getValue());
actions.add(AdapayOpenActionEnum.DELETE_SETTLE_ACCOUNT.getValue()); actions.add(AdapayOpenActionEnum.DELETE_SETTLE_ACCOUNT.getValue());
break; break;
default: default:

View File

@@ -20,6 +20,4 @@ public class AdapayMemberInfoVO {
private String gender; private String gender;
// 昵称 // 昵称
private String nickname; private String nickname;
// 结算账户id
private String settleAccountId;
} }

View File

@@ -73,10 +73,4 @@ public class AdapaySettleAccountVO {
* 银行账户开户银行所在地区编码(省市编码),银行账户类型为对公时,必填 * 银行账户开户银行所在地区编码(省市编码),银行账户类型为对公时,必填
*/ */
private String areaCode; private String areaCode;
private String minAmt;
private String remainedAmt;
private String channelRemark;
} }

View File

@@ -120,14 +120,13 @@ public interface AdapayMemberAccountMapper {
AdapayMemberAccount selectByMemberId(String memberId); AdapayMemberAccount selectByMemberId(String memberId);
int deleteCurrentAccount(@Param("id") Integer id, /**
@Param("merchantId") String merchantId, * 通过运营商id删除账户信息
@Param("adapayMemberId") String adapayMemberId); * @param merchantId
*/
void deleteAccountByMerchantId(String merchantId);
int clearCurrentSettleAccount(@Param("id") Integer id, void clearSettleAccountByMerchantId(String merchantId);
@Param("merchantId") String merchantId,
@Param("adapayMemberId") String adapayMemberId,
@Param("settleAccountId") String settleAccountId);
/** /**
* 根据运营商id查询最近一条的信息 * 根据运营商id查询最近一条的信息

View File

@@ -35,6 +35,4 @@ public interface StationSplitConfigMapper {
* @return * @return
*/ */
List<SplitConfigStationVO> queryStationList(String adapayMemberId); List<SplitConfigStationVO> queryStationList(String adapayMemberId);
int countActiveByAdapayMemberId(String adapayMemberId);
} }

View File

@@ -111,11 +111,12 @@ public interface AdapayMemberAccountService {
String selectMerchantNameByAdapayMemberId(String adapayMemberId); String selectMerchantNameByAdapayMemberId(String adapayMemberId);
/** /**
* 精确逻辑删除当前有效账户,避免并发开户时误删新记录 * 根据运营商id删除记录
* @param merchantId
*/ */
int deleteCurrentAccount(Integer id, String merchantId, String adapayMemberId); void deleteAccountByMerchantId(String merchantId);
int clearCurrentSettleAccount(Integer id, String merchantId, String adapayMemberId, String settleAccountId); void clearSettleAccountByMerchantId(String merchantId);
/** /**
* 根据运营商Id查询最近一条的信息 * 根据运营商Id查询最近一条的信息

View File

@@ -4,6 +4,7 @@ import com.jsowell.pile.domain.OrderInvoiceRecord;
import com.jsowell.pile.dto.GetInvoiceInfoDTO; import com.jsowell.pile.dto.GetInvoiceInfoDTO;
import com.jsowell.pile.dto.QueryInvoiceRecordDTO; import com.jsowell.pile.dto.QueryInvoiceRecordDTO;
import com.jsowell.pile.vo.web.InvoiceRecordVO; import com.jsowell.pile.vo.web.InvoiceRecordVO;
import com.jsowell.pile.vo.web.OrderInvoiceExportVO;
import com.jsowell.pile.vo.web.OrderInvoiceRecordVO; import com.jsowell.pile.vo.web.OrderInvoiceRecordVO;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@@ -26,6 +27,8 @@ public interface OrderInvoiceRecordService {
InvoiceRecordVO selectInvoiceTitleVO(Integer id); InvoiceRecordVO selectInvoiceTitleVO(Integer id);
List<OrderInvoiceExportVO> selectInvoiceExportList(Integer[] ids);
/** /**
* 查询申请开票列表 * 查询申请开票列表
* *

View File

@@ -59,6 +59,4 @@ public interface StationSplitConfigService {
* @return * @return
*/ */
Map<String,List<SplitConfigStationVO>> queryStationList(SplitConfigStationDTO splitConfigStationDTO); Map<String,List<SplitConfigStationVO>> queryStationList(SplitConfigStationDTO splitConfigStationDTO);
int countActiveByAdapayMemberId(String adapayMemberId);
} }

View File

@@ -270,22 +270,16 @@ public class AdapayMemberAccountServiceImpl implements AdapayMemberAccountServic
} }
@Override @Override
public int deleteCurrentAccount(Integer id, String merchantId, String adapayMemberId) { public void deleteAccountByMerchantId(String merchantId) {
int result = adapayMemberAccountMapper.deleteCurrentAccount(id, merchantId, adapayMemberId); adapayMemberAccountMapper.deleteAccountByMerchantId(merchantId);
if (result > 0) {
redisCache.deleteObject(CacheConstants.ADAPAY_MEMBER_ACCOUNT + merchantId); redisCache.deleteObject(CacheConstants.ADAPAY_MEMBER_ACCOUNT + merchantId);
} }
return result;
}
@Override @Override
public int clearCurrentSettleAccount(Integer id, String merchantId, String adapayMemberId, String settleAccountId) { public void clearSettleAccountByMerchantId(String merchantId) {
int result = adapayMemberAccountMapper.clearCurrentSettleAccount(id, merchantId, adapayMemberId, settleAccountId); adapayMemberAccountMapper.clearSettleAccountByMerchantId(merchantId);
if (result > 0) {
redisCache.deleteObject(CacheConstants.ADAPAY_MEMBER_ACCOUNT + merchantId); redisCache.deleteObject(CacheConstants.ADAPAY_MEMBER_ACCOUNT + merchantId);
} }
return result;
}
/** /**
* 根据运营商id查询最近一条的信息 * 根据运营商id查询最近一条的信息

View File

@@ -13,6 +13,8 @@ import com.jsowell.pile.util.UserUtils;
import com.jsowell.pile.vo.base.OrderAmountDetailVO; import com.jsowell.pile.vo.base.OrderAmountDetailVO;
import com.jsowell.pile.vo.uniapp.customer.InvoiceTitleVO; import com.jsowell.pile.vo.uniapp.customer.InvoiceTitleVO;
import com.jsowell.pile.vo.web.InvoiceRecordVO; import com.jsowell.pile.vo.web.InvoiceRecordVO;
import com.jsowell.pile.vo.web.OrderInvoiceExportVO;
import com.jsowell.pile.vo.web.OrderInvoiceOrderExportVO;
import com.jsowell.pile.vo.web.OrderInvoiceRecordVO; import com.jsowell.pile.vo.web.OrderInvoiceRecordVO;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -20,7 +22,11 @@ import org.springframework.stereotype.Service;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/** /**
* 申请开票Service业务层处理 * 申请开票Service业务层处理
@@ -76,6 +82,82 @@ public class OrderInvoiceRecordServiceImpl implements OrderInvoiceRecordService
.build(); .build();
} }
@Override
public List<OrderInvoiceExportVO> selectInvoiceExportList(Integer[] ids) {
if (ids == null || ids.length == 0) {
return Collections.emptyList();
}
return Arrays.stream(ids)
.filter(Objects::nonNull)
.distinct()
.map(this::selectInvoiceTitleVO)
.filter(Objects::nonNull)
.map(this::buildOrderInvoiceExportVO)
.collect(Collectors.toList());
}
private OrderInvoiceExportVO buildOrderInvoiceExportVO(InvoiceRecordVO invoiceRecordVO) {
InvoiceTitleVO invoiceTitle = invoiceRecordVO.getInvoiceTitle();
return OrderInvoiceExportVO.builder()
.id(invoiceRecordVO.getId())
.memberId(invoiceRecordVO.getMemberId())
.phoneNumber(invoiceRecordVO.getPhoneNumber())
.status(invoiceRecordVO.getStatus())
.createTime(invoiceRecordVO.getCreateTime())
.updateTime(invoiceRecordVO.getUpdateTime())
.titleId(invoiceTitle == null ? null : invoiceTitle.getTitleId())
.titleName(invoiceTitle == null ? null : invoiceTitle.getTitleName())
.titleType(invoiceTitle == null ? null : invoiceTitle.getTitleType())
.taxId(invoiceTitle == null ? null : invoiceTitle.getTaxId())
.unitAddress(invoiceTitle == null ? null : invoiceTitle.getUnitAddress())
.email(invoiceTitle == null ? null : invoiceTitle.getEmail())
.reception(invoiceTitle == null ? null : invoiceTitle.getReception())
.titlePhoneNumber(invoiceTitle == null ? null : invoiceTitle.getPhoneNumber())
.bankName(invoiceTitle == null ? null : invoiceTitle.getBankName())
.bankAccountNumber(invoiceTitle == null ? null : invoiceTitle.getBankAccountNumber())
.defaultFlag(invoiceTitle == null ? null : invoiceTitle.getDefaultFlag())
.orderList(buildOrderExportList(invoiceRecordVO.getOrderList()))
.build();
}
private List<OrderInvoiceOrderExportVO> buildOrderExportList(List<OrderAmountDetailVO> orderList) {
if (CollectionUtils.isEmpty(orderList)) {
List<OrderInvoiceOrderExportVO> emptyOrderList = new ArrayList<>();
emptyOrderList.add(new OrderInvoiceOrderExportVO());
return emptyOrderList;
}
List<OrderInvoiceOrderExportVO> exportList = orderList.stream()
.filter(Objects::nonNull)
.map(this::buildOrderInvoiceOrderExportVO)
.collect(Collectors.toList());
if (CollectionUtils.isEmpty(exportList)) {
exportList.add(new OrderInvoiceOrderExportVO());
}
return exportList;
}
private OrderInvoiceOrderExportVO buildOrderInvoiceOrderExportVO(OrderAmountDetailVO orderAmountDetailVO) {
return OrderInvoiceOrderExportVO.builder()
.orderCode(orderAmountDetailVO.getOrderCode())
.totalUsedElectricity(orderAmountDetailVO.getTotalUsedElectricity())
.totalOrderAmount(orderAmountDetailVO.getTotalOrderAmount())
.totalElectricityAmount(orderAmountDetailVO.getTotalElectricityAmount())
.totalServiceAmount(orderAmountDetailVO.getTotalServiceAmount())
.sharpUsedElectricity(orderAmountDetailVO.getSharpUsedElectricity())
.sharpElectricityPrice(orderAmountDetailVO.getSharpElectricityPrice())
.sharpServicePrice(orderAmountDetailVO.getSharpServicePrice())
.peakUsedElectricity(orderAmountDetailVO.getPeakUsedElectricity())
.peakElectricityPrice(orderAmountDetailVO.getPeakElectricityPrice())
.peakServicePrice(orderAmountDetailVO.getPeakServicePrice())
.flatUsedElectricity(orderAmountDetailVO.getFlatUsedElectricity())
.flatElectricityPrice(orderAmountDetailVO.getFlatElectricityPrice())
.flatServicePrice(orderAmountDetailVO.getFlatServicePrice())
.valleyUsedElectricity(orderAmountDetailVO.getValleyUsedElectricity())
.valleyElectricityPrice(orderAmountDetailVO.getValleyElectricityPrice())
.valleyServicePrice(orderAmountDetailVO.getValleyServicePrice())
.build();
}
/** /**
* 查询申请开票列表 * 查询申请开票列表
* *

View File

@@ -316,9 +316,4 @@ public class StationSplitConfigServiceImpl implements StationSplitConfigService{
return stationMap; return stationMap;
} }
@Override
public int countActiveByAdapayMemberId(String adapayMemberId) {
return stationSplitConfigMapper.countActiveByAdapayMemberId(adapayMemberId);
}
} }

View File

@@ -0,0 +1,72 @@
package com.jsowell.pile.vo.web;
import com.jsowell.common.annotation.Excel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* 发票详情导出数据
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class OrderInvoiceExportVO {
@Excel(name = "申请记录ID", sort = 1, needMerge = true)
private String id;
@Excel(name = "会员ID", sort = 2, needMerge = true, width = 20)
private String memberId;
@Excel(name = "申请人电话", sort = 3, needMerge = true, width = 18)
private String phoneNumber;
@Excel(name = "状态", sort = 4, needMerge = true, readConverterExp = "0=未开票,1=已开票")
private String status;
@Excel(name = "申请时间", sort = 5, needMerge = true, width = 20)
private String createTime;
@Excel(name = "开票时间", sort = 6, needMerge = true, width = 20)
private String updateTime;
@Excel(name = "抬头ID", sort = 7, needMerge = true)
private String titleId;
@Excel(name = "抬头名称", sort = 8, needMerge = true, width = 30)
private String titleName;
@Excel(name = "抬头类型", sort = 9, needMerge = true)
private String titleType;
@Excel(name = "税号", sort = 10, needMerge = true, width = 24)
private String taxId;
@Excel(name = "单位地址", sort = 11, needMerge = true, width = 30)
private String unitAddress;
@Excel(name = "抬头邮箱", sort = 12, needMerge = true, width = 24)
private String email;
@Excel(name = "接收方式", sort = 13, needMerge = true)
private String reception;
@Excel(name = "抬头电话", sort = 14, needMerge = true, width = 18)
private String titlePhoneNumber;
@Excel(name = "开户银行", sort = 15, needMerge = true, width = 24)
private String bankName;
@Excel(name = "银行账户", sort = 16, needMerge = true, width = 24)
private String bankAccountNumber;
@Excel(name = "默认抬头", sort = 17, needMerge = true, readConverterExp = "0=否,1=是")
private String defaultFlag;
@Excel(name = "订单明细", sort = 18)
private List<OrderInvoiceOrderExportVO> orderList;
}

View File

@@ -0,0 +1,69 @@
package com.jsowell.pile.vo.web;
import com.jsowell.common.annotation.Excel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
* 发票关联订单导出明细
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class OrderInvoiceOrderExportVO {
@Excel(name = "订单号", sort = 1, width = 24)
private String orderCode;
@Excel(name = "总用电量", sort = 2)
private BigDecimal totalUsedElectricity;
@Excel(name = "订单总金额", sort = 3)
private BigDecimal totalOrderAmount;
@Excel(name = "电费总金额", sort = 4)
private BigDecimal totalElectricityAmount;
@Excel(name = "服务费总金额", sort = 5)
private BigDecimal totalServiceAmount;
@Excel(name = "尖时段用电量", sort = 6)
private BigDecimal sharpUsedElectricity;
@Excel(name = "尖时段电费单价", sort = 7)
private BigDecimal sharpElectricityPrice;
@Excel(name = "尖时段服务费单价", sort = 8)
private BigDecimal sharpServicePrice;
@Excel(name = "峰时段用电量", sort = 9)
private BigDecimal peakUsedElectricity;
@Excel(name = "峰时段电费单价", sort = 10)
private BigDecimal peakElectricityPrice;
@Excel(name = "峰时段服务费单价", sort = 11)
private BigDecimal peakServicePrice;
@Excel(name = "平时段用电量", sort = 12)
private BigDecimal flatUsedElectricity;
@Excel(name = "平时段电费单价", sort = 13)
private BigDecimal flatElectricityPrice;
@Excel(name = "平时段服务费单价", sort = 14)
private BigDecimal flatServicePrice;
@Excel(name = "谷时段用电量", sort = 15)
private BigDecimal valleyUsedElectricity;
@Excel(name = "谷时段电费单价", sort = 16)
private BigDecimal valleyElectricityPrice;
@Excel(name = "谷时段服务费单价", sort = 17)
private BigDecimal valleyServicePrice;
}

View File

@@ -572,26 +572,20 @@
and adapay_member_id = #{memberId,jdbcType=VARCHAR} and adapay_member_id = #{memberId,jdbcType=VARCHAR}
</select> </select>
<update id="deleteCurrentAccount"> <update id="deleteAccountByMerchantId">
update update
adapay_member_account adapay_member_account
set del_flag = '1', set del_flag = '1'
update_time = now() where merchant_id = #{merchantId,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
and merchant_id = #{merchantId,jdbcType=VARCHAR}
and adapay_member_id = #{adapayMemberId,jdbcType=VARCHAR}
and del_flag = '0' and del_flag = '0'
</update> </update>
<update id="clearCurrentSettleAccount"> <update id="clearSettleAccountByMerchantId">
update update
adapay_member_account adapay_member_account
set settle_account_id = null, set settle_account_id = null,
update_time = now() update_time = now()
where id = #{id,jdbcType=INTEGER} where merchant_id = #{merchantId,jdbcType=VARCHAR}
and merchant_id = #{merchantId,jdbcType=VARCHAR}
and adapay_member_id = #{adapayMemberId,jdbcType=VARCHAR}
and settle_account_id = #{settleAccountId,jdbcType=VARCHAR}
and del_flag = '0' and del_flag = '0'
</update> </update>

View File

@@ -41,13 +41,6 @@
where t1.adapay_member_id = #{adapayMemberId} where t1.adapay_member_id = #{adapayMemberId}
</select> </select>
<select id="countActiveByAdapayMemberId" resultType="int">
select count(distinct station_id)
from station_split_config
where adapay_member_id = #{adapayMemberId}
and del_flag = '0'
</select>
<insert id="batchInsert" parameterType="map"> <insert id="batchInsert" parameterType="map">
<!--@mbg.generated--> <!--@mbg.generated-->
insert into station_split_config insert into station_split_config