|
@@ -152,108 +152,227 @@ public class TopOrderBankPayServiceImpl extends ServiceImpl<TopOrderBankPayMappe
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean payToCompany(TopOrderBankPayAddBo bo) {
|
|
|
- if(Validator.isEmpty(bo.getDivideLogId())||Validator.isEmpty(bo.getTenantId())){
|
|
|
- throw new CustomException("参数错误");
|
|
|
+ if(Validator.isEmpty(bo.getType())){
|
|
|
+ throw new CustomException("类型参数错误");
|
|
|
}
|
|
|
- if(Validator.isEmpty(bo.getToBankAcount())||Validator.isEmpty(bo.getToBankName())||Validator.isEmpty(bo.getToBankTypeName())){
|
|
|
- throw new CustomException("支付参数错误");
|
|
|
- }
|
|
|
- //校验当前角色审核权限
|
|
|
- List<TopSysUserRole> userRoleList = topSysUserRoleService.list(new LambdaQueryWrapper<TopSysUserRole>().eq(TopSysUserRole::getUserId, bo.getLoginId()));
|
|
|
- if (CollectionUtils.isEmpty(userRoleList) && !bo.getLoginName().equals("admin")) {
|
|
|
- throw new CustomException("当前账号没有审核权限");
|
|
|
- }
|
|
|
- List<Long> roleIds = userRoleList.stream().map(TopSysUserRole::getRoleId).collect(Collectors.toList());
|
|
|
- TopDivideLog divideLog = iTopDivideLogService.getOne(new LambdaQueryWrapper<TopDivideLog>()
|
|
|
- .eq(TopDivideLog::getId, bo.getDivideLogId()));
|
|
|
+ if(bo.getType()==4){
|
|
|
+ if(Validator.isEmpty(bo.getOrderSn())||Validator.isEmpty(bo.getTenantId())){
|
|
|
+ throw new CustomException("参数错误");
|
|
|
+ }
|
|
|
+ if(Validator.isEmpty(bo.getToBankAcount())||Validator.isEmpty(bo.getToBankName())||Validator.isEmpty(bo.getToBankTypeName())){
|
|
|
+ throw new CustomException("支付参数错误");
|
|
|
+ }
|
|
|
+ //校验当前角色审核权限
|
|
|
+ List<TopSysUserRole> userRoleList = topSysUserRoleService.list(new LambdaQueryWrapper<TopSysUserRole>().eq(TopSysUserRole::getUserId, bo.getLoginId()));
|
|
|
+ if (CollectionUtils.isEmpty(userRoleList) && !bo.getLoginName().equals("admin")) {
|
|
|
+ throw new CustomException("当前账号没有审核权限");
|
|
|
+ }
|
|
|
+ List<Long> roleIds = userRoleList.stream().map(TopSysUserRole::getRoleId).collect(Collectors.toList());
|
|
|
+ TopOldOrder order = iTopOldOrderService.getOne(new LambdaQueryWrapper<TopOldOrder>()
|
|
|
+ .eq(TopOldOrder::getOrderSn, bo.getOrderSn()));
|
|
|
+ TopOldOrderCheckLog checkLog = iTopOldOrderCheckLogService.getOne(new LambdaQueryWrapper<TopOldOrderCheckLog>()
|
|
|
+ .eq(TopOldOrderCheckLog::getOrderSn, bo.getOrderSn()).eq(TopOldOrderCheckLog::getCheckFrom, 4)
|
|
|
+ .eq(TopOldOrderCheckLog::getCheckSign, 1));
|
|
|
+ if(Validator.isEmpty(checkLog)||Validator.isEmpty(order)){
|
|
|
+ throw new CustomException("审核数据错误");
|
|
|
+ }
|
|
|
+ if(checkLog.getCheckStatus()!=2&&checkLog.getCheckStatus()!=5){
|
|
|
+ throw new CustomException("非待支付状态");
|
|
|
+ }
|
|
|
|
|
|
- if(Validator.isEmpty(divideLog)){
|
|
|
- throw new CustomException("审核数据错误");
|
|
|
- }
|
|
|
- if(divideLog.getPayStatus()!=0&÷Log.getPayStatus()!=4){
|
|
|
- throw new CustomException("非待支付状态");
|
|
|
- }
|
|
|
- List<Integer> pStatus = new ArrayList<>();
|
|
|
- pStatus.add(0);
|
|
|
- pStatus.add(4);
|
|
|
- TopDivideLog divideLogFirst = iTopDivideLogService.getOne(new LambdaQueryWrapper<TopDivideLog>()
|
|
|
- .eq(TopDivideLog::getTenantId, divideLog.getTenantId())
|
|
|
- .eq(TopDivideLog::getDivideType, divideLog.getDivideType())
|
|
|
- .in(TopDivideLog::getPayStatus, pStatus).last("limit 1"));
|
|
|
- if(!divideLogFirst.getId().equals(divideLog.getId())){
|
|
|
- throw new CustomException("存在历史未支付月份");
|
|
|
- }
|
|
|
- TopSysRole sysRole = iTopSysRoleService.getOne(new LambdaQueryWrapper<TopSysRole>()
|
|
|
- .eq(TopSysRole::getRoleName, "出纳")
|
|
|
- .eq(TopSysRole::getStatus, 1).last("limit 1"));
|
|
|
- if(Validator.isEmpty(sysRole)){
|
|
|
- throw new CustomException("当前系统没有出纳角色");
|
|
|
- }
|
|
|
- if (!roleIds.contains(sysRole.getRoleId()) && !bo.getLoginName().equals("admin") ) {
|
|
|
+ TopSysRole sysRole = iTopSysRoleService.getOne(new LambdaQueryWrapper<TopSysRole>()
|
|
|
+ .eq(TopSysRole::getRoleName, "出纳")
|
|
|
+ .eq(TopSysRole::getStatus, 1).last("limit 1"));
|
|
|
+ if(Validator.isEmpty(sysRole)){
|
|
|
+ throw new CustomException("当前系统没有出纳角色");
|
|
|
+ }
|
|
|
+ if (!roleIds.contains(sysRole.getRoleId()) && !bo.getLoginName().equals("admin") ) {
|
|
|
+ throw new CustomException("当前账号没有审核权限");
|
|
|
+ }
|
|
|
+ /*if (!roleIds.contains(checkLog.getRoleId()) && !bo.getLoginName().equals("admin") ) {
|
|
|
throw new CustomException("当前账号没有审核权限");
|
|
|
- }
|
|
|
+ }*/
|
|
|
+ if(order.getBrokerage().compareTo(BigDecimal.ZERO)==0){
|
|
|
+ //免费
|
|
|
+ checkLog.setCheckStatus(3);
|
|
|
+ checkLog.setCheckTime(DateUtils.getNowTime());
|
|
|
+ checkLog.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ iTopOldOrderCheckLogService.updateById(checkLog);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ bo.setTrainOrgId(checkLog.getTenantId().toString());//旧机构ID
|
|
|
+ String paySn = DateUtils.getTagOrderSn("CP");
|
|
|
+ TopOrderBankPay add = BeanUtil.toBean(bo, TopOrderBankPay.class);
|
|
|
+ add.setPaySn(paySn);
|
|
|
+ validEntityBeforeSave(add);
|
|
|
+ add.setCreateTime(DateUtils.getNowTime());
|
|
|
+ add.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ add.setResultStatus(0);
|
|
|
+ add.setPayUsername(bo.getLoginName());
|
|
|
+ add.setDivideLogId(bo.getDivideLogId());
|
|
|
+ BigDecimal money = null;
|
|
|
+ money =order.getBrokerage();
|
|
|
+ add.setMoney(money);
|
|
|
+ //网银支付
|
|
|
+ if(add.getPayType()==5){
|
|
|
+ Map<String, String> params = new HashMap<>();
|
|
|
+ Long nowTime = DateUtils.getNowTime();
|
|
|
+ String sign = ToolsUtils.EncoderByMd5(paySn+nowTime.toString()+"pubilc2022");
|
|
|
+ params.put("stamp", nowTime.toString());
|
|
|
+ params.put("sign", sign);
|
|
|
+ params.put("MainUniqueId", paySn);
|
|
|
+ params.put("ToBankAcount", bo.getToBankAcount());
|
|
|
+ params.put("ToBankName", bo.getToBankName());
|
|
|
+ params.put("ToBankTypeName", bo.getToBankTypeName());
|
|
|
+ params.put("Money", money.toString());
|
|
|
+ params.put("TrainOrgId", bo.getTrainOrgId());
|
|
|
+ if(Validator.isNotEmpty(bo.getToBankConnetNum())){
|
|
|
+ params.put("ToBankConnetNum", bo.getToBankConnetNum());
|
|
|
+ }
|
|
|
+ if(Validator.isNotEmpty(bo.getRemark())){
|
|
|
+ params.put("Remark", bo.getRemark());
|
|
|
+ }
|
|
|
+ String respone = "";
|
|
|
+ String paramStr = JSON.toJSONString(params);
|
|
|
+ add.setParamJson(paramStr);
|
|
|
+ log.info("网银支付参数" + paramStr, "");
|
|
|
+ String path = OLD_SYS_HOST+"/WitSystem/BussinessApi/NeedToPay";
|
|
|
+ try {
|
|
|
+ respone = HttpUtils.postFormBody(path, params);
|
|
|
+ if (!respone.contains("\"Status\":true")) {
|
|
|
+
|
|
|
+ throw new CustomException("同步请求错误"+respone);
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new CustomException("同步请求错误"+e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(this.save(add)){
|
|
|
+ if(add.getPayType()==4){
|
|
|
+ checkLog.setCheckStatus(3);
|
|
|
+ }else{
|
|
|
+ checkLog.setCheckStatus(6);//支付中
|
|
|
+ }
|
|
|
+ checkLog.setCheckTime(DateUtils.getNowTime());
|
|
|
+ checkLog.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ iTopOldOrderCheckLogService.updateById(checkLog);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }else{
|
|
|
+ if(Validator.isEmpty(bo.getDivideLogId())||Validator.isEmpty(bo.getTenantId())){
|
|
|
+ throw new CustomException("参数错误");
|
|
|
+ }
|
|
|
+ if(Validator.isEmpty(bo.getToBankAcount())||Validator.isEmpty(bo.getToBankName())||Validator.isEmpty(bo.getToBankTypeName())){
|
|
|
+ throw new CustomException("支付参数错误");
|
|
|
+ }
|
|
|
+ //校验当前角色审核权限
|
|
|
+ List<TopSysUserRole> userRoleList = topSysUserRoleService.list(new LambdaQueryWrapper<TopSysUserRole>().eq(TopSysUserRole::getUserId, bo.getLoginId()));
|
|
|
+ if (CollectionUtils.isEmpty(userRoleList) && !bo.getLoginName().equals("admin")) {
|
|
|
+ throw new CustomException("当前账号没有审核权限");
|
|
|
+ }
|
|
|
+ List<Long> roleIds = userRoleList.stream().map(TopSysUserRole::getRoleId).collect(Collectors.toList());
|
|
|
+ TopDivideLog divideLog = iTopDivideLogService.getOne(new LambdaQueryWrapper<TopDivideLog>()
|
|
|
+ .eq(TopDivideLog::getId, bo.getDivideLogId()));
|
|
|
+
|
|
|
+ if(Validator.isEmpty(divideLog)){
|
|
|
+ throw new CustomException("审核数据错误");
|
|
|
+ }
|
|
|
+ if(divideLog.getPayStatus()!=0&÷Log.getPayStatus()!=4){
|
|
|
+ throw new CustomException("非待支付状态");
|
|
|
+ }
|
|
|
+ List<Integer> pStatus = new ArrayList<>();
|
|
|
+ pStatus.add(0);
|
|
|
+ pStatus.add(4);
|
|
|
+ TopDivideLog divideLogFirst = iTopDivideLogService.getOne(new LambdaQueryWrapper<TopDivideLog>()
|
|
|
+ .eq(TopDivideLog::getTenantId, divideLog.getTenantId())
|
|
|
+ .eq(TopDivideLog::getDivideType, divideLog.getDivideType())
|
|
|
+ .in(TopDivideLog::getPayStatus, pStatus).last("limit 1"));
|
|
|
+ if(!divideLogFirst.getId().equals(divideLog.getId())){
|
|
|
+ throw new CustomException("存在历史未支付月份");
|
|
|
+ }
|
|
|
+ TopSysRole sysRole = iTopSysRoleService.getOne(new LambdaQueryWrapper<TopSysRole>()
|
|
|
+ .eq(TopSysRole::getRoleName, "出纳")
|
|
|
+ .eq(TopSysRole::getStatus, 1).last("limit 1"));
|
|
|
+ if(Validator.isEmpty(sysRole)){
|
|
|
+ throw new CustomException("当前系统没有出纳角色");
|
|
|
+ }
|
|
|
+ if (!roleIds.contains(sysRole.getRoleId()) && !bo.getLoginName().equals("admin") ) {
|
|
|
+ throw new CustomException("当前账号没有审核权限");
|
|
|
+ }
|
|
|
/*if (!roleIds.contains(checkLog.getRoleId()) && !bo.getLoginName().equals("admin") ) {
|
|
|
throw new CustomException("当前账号没有审核权限");
|
|
|
}*/
|
|
|
- if(divideLog.getPayMoney().compareTo(BigDecimal.ZERO)==0){
|
|
|
- //免费
|
|
|
- divideLog.setPayStatus(1);
|
|
|
- divideLog.setPayTime(DateUtils.getNowTime());
|
|
|
- divideLog.setUpdateTime(DateUtils.getNowTime());
|
|
|
- iTopDivideLogService.updateById(divideLog);
|
|
|
- return true;
|
|
|
- }
|
|
|
+ if(divideLog.getPayMoney().compareTo(BigDecimal.ZERO)==0){
|
|
|
+ //免费
|
|
|
+ divideLog.setPayStatus(1);
|
|
|
+ divideLog.setPayTime(DateUtils.getNowTime());
|
|
|
+ divideLog.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ iTopDivideLogService.updateById(divideLog);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
- bo.setTrainOrgId(divideLog.getTenantId().toString());//旧机构ID
|
|
|
- String paySn = DateUtils.getTagOrderSn("CP");
|
|
|
- TopOrderBankPay add = BeanUtil.toBean(bo, TopOrderBankPay.class);
|
|
|
- add.setPaySn(paySn);
|
|
|
- validEntityBeforeSave(add);
|
|
|
- add.setCreateTime(DateUtils.getNowTime());
|
|
|
- add.setUpdateTime(DateUtils.getNowTime());
|
|
|
- add.setResultStatus(0);
|
|
|
- add.setPayUsername(bo.getLoginName());
|
|
|
- add.setType(1);//分成
|
|
|
- add.setDivideLogId(bo.getDivideLogId());
|
|
|
- BigDecimal money = null;
|
|
|
- money =divideLog.getPayMoney();
|
|
|
- add.setMoney(money);
|
|
|
- Map<String, String> params = new HashMap<>();
|
|
|
- Long nowTime = DateUtils.getNowTime();
|
|
|
- String sign = ToolsUtils.EncoderByMd5(paySn+nowTime.toString()+"pubilc2022");
|
|
|
- params.put("stamp", nowTime.toString());
|
|
|
- params.put("sign", sign);
|
|
|
- params.put("MainUniqueId", paySn);
|
|
|
- params.put("ToBankAcount", bo.getToBankAcount());
|
|
|
- params.put("ToBankName", bo.getToBankName());
|
|
|
- params.put("ToBankTypeName", bo.getToBankTypeName());
|
|
|
- params.put("Money", money.toString());
|
|
|
- params.put("TrainOrgId", bo.getTrainOrgId());
|
|
|
- if(Validator.isNotEmpty(bo.getToBankConnetNum())){
|
|
|
- params.put("ToBankConnetNum", bo.getToBankConnetNum());
|
|
|
- }
|
|
|
- if(Validator.isNotEmpty(bo.getRemark())){
|
|
|
- params.put("Remark", bo.getRemark());
|
|
|
- }
|
|
|
- String respone = "";
|
|
|
- String paramStr = JSON.toJSONString(params);
|
|
|
- add.setParamJson(paramStr);
|
|
|
- log.info("网银支付参数" + paramStr, "");
|
|
|
- String path = OLD_SYS_HOST+"/WitSystem/BussinessApi/NeedToPay";
|
|
|
- try {
|
|
|
- respone = HttpUtils.postFormBody(path, params);
|
|
|
- if (!respone.contains("\"Status\":true")) {
|
|
|
+ bo.setTrainOrgId(divideLog.getTenantId().toString());//旧机构ID
|
|
|
+ String paySn = DateUtils.getTagOrderSn("CP");
|
|
|
+ TopOrderBankPay add = BeanUtil.toBean(bo, TopOrderBankPay.class);
|
|
|
+ add.setPaySn(paySn);
|
|
|
+ validEntityBeforeSave(add);
|
|
|
+ add.setCreateTime(DateUtils.getNowTime());
|
|
|
+ add.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ add.setResultStatus(0);
|
|
|
+ add.setPayUsername(bo.getLoginName());
|
|
|
+ add.setDivideLogId(bo.getDivideLogId());
|
|
|
+ BigDecimal money = null;
|
|
|
+ money =divideLog.getPayMoney();
|
|
|
+ add.setMoney(money);
|
|
|
+ //网银支付
|
|
|
+ if(add.getPayType()==5){
|
|
|
+ Map<String, String> params = new HashMap<>();
|
|
|
+ Long nowTime = DateUtils.getNowTime();
|
|
|
+ String sign = ToolsUtils.EncoderByMd5(paySn+nowTime.toString()+"pubilc2022");
|
|
|
+ params.put("stamp", nowTime.toString());
|
|
|
+ params.put("sign", sign);
|
|
|
+ params.put("MainUniqueId", paySn);
|
|
|
+ params.put("ToBankAcount", bo.getToBankAcount());
|
|
|
+ params.put("ToBankName", bo.getToBankName());
|
|
|
+ params.put("ToBankTypeName", bo.getToBankTypeName());
|
|
|
+ params.put("Money", money.toString());
|
|
|
+ params.put("TrainOrgId", bo.getTrainOrgId());
|
|
|
+ if(Validator.isNotEmpty(bo.getToBankConnetNum())){
|
|
|
+ params.put("ToBankConnetNum", bo.getToBankConnetNum());
|
|
|
+ }
|
|
|
+ if(Validator.isNotEmpty(bo.getRemark())){
|
|
|
+ params.put("Remark", bo.getRemark());
|
|
|
+ }
|
|
|
+ String respone = "";
|
|
|
+ String paramStr = JSON.toJSONString(params);
|
|
|
+ add.setParamJson(paramStr);
|
|
|
+ log.info("网银支付参数" + paramStr, "");
|
|
|
+ String path = OLD_SYS_HOST+"/WitSystem/BussinessApi/NeedToPay";
|
|
|
+ try {
|
|
|
+ respone = HttpUtils.postFormBody(path, params);
|
|
|
+ if (!respone.contains("\"Status\":true")) {
|
|
|
|
|
|
- throw new CustomException("同步请求错误"+respone);
|
|
|
+ throw new CustomException("同步请求错误"+respone);
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new CustomException("同步请求错误"+e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
- } catch (IOException e) {
|
|
|
- throw new CustomException("同步请求错误"+e.getMessage());
|
|
|
- }
|
|
|
- if(this.save(add)){
|
|
|
- divideLog.setPayStatus(3);//支付中
|
|
|
- iTopDivideLogService.updateById(divideLog);
|
|
|
- return true;
|
|
|
+
|
|
|
+ if(this.save(add)){
|
|
|
+ if(add.getPayType()==4){
|
|
|
+ divideLog.setPayStatus(1);//支付完成
|
|
|
+ }else{
|
|
|
+ divideLog.setPayStatus(3);//支付中
|
|
|
+ }
|
|
|
+ iTopDivideLogService.updateById(divideLog);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
}
|
|
|
- return false;
|
|
|
+
|
|
|
}
|
|
|
}
|