Commit 074060e1 by 杨清松

账单相关接口

parent 1a1acb61
...@@ -11,4 +11,6 @@ public interface StatementAccountDao { ...@@ -11,4 +11,6 @@ public interface StatementAccountDao {
List<KObject> queryStatementAccountByContractId(JSONObject jsonObject, String modelPath); List<KObject> queryStatementAccountByContractId(JSONObject jsonObject, String modelPath);
List<KObject> queryAdvanceByContractId(UUID contractId, String fundType, String entity);
} }
...@@ -17,6 +17,7 @@ import org.springframework.orm.hibernate5.HibernateOperations; ...@@ -17,6 +17,7 @@ import org.springframework.orm.hibernate5.HibernateOperations;
import com.beecode.bcp.type.KObject; import com.beecode.bcp.type.KObject;
import com.xyst.dinas.finance.dao.StatementAccountDao; import com.xyst.dinas.finance.dao.StatementAccountDao;
import com.xyst.dinas.finance.enumeration.FundTypeEnum;
public class StatementAccountDaoImpl implements StatementAccountDao{ public class StatementAccountDaoImpl implements StatementAccountDao{
...@@ -67,4 +68,29 @@ public class StatementAccountDaoImpl implements StatementAccountDao{ ...@@ -67,4 +68,29 @@ public class StatementAccountDaoImpl implements StatementAccountDao{
} }
}); });
} }
@Override
public List<KObject> queryAdvanceByContractId(UUID contractId, String fundType, String entity) {
return (List<KObject>)template.execute(new HibernateCallback<List<KObject>>() {
StringBuilder hql = new StringBuilder("from " + entity + " where contract.id=:contractId and fundType=:fundType");
@SuppressWarnings("unchecked")
@Override
public List<KObject> doInHibernate(Session session) throws HibernateException {
Query<KObject> query = session.createQuery(hql.toString(), KObject.class);
query.setParameter("contractId", contractId);
if (entity.equals("com.xyst.dinas.finance.datamodel.FinanceRefund")) {
if (fundType.equals(FundTypeEnum.ADVANCE.name())) {
query.setParameter("fundType", 0);
} if (fundType.equals(FundTypeEnum.DEPOSIT.name())) {
query.setParameter("fundType", 1);
}
} else {
query.setParameter("fundType", fundType);
}
List<KObject> resultList = query.getResultList();
return resultList;
}
});
}
} }
...@@ -190,4 +190,64 @@ public class StatementAccountServiceImpl implements StatementAccountService{ ...@@ -190,4 +190,64 @@ public class StatementAccountServiceImpl implements StatementAccountService{
} }
@Override
public List<StatementAccount> queryAccountByContractId(JSONObject jsonObject) {
UUID contractId = UUID.fromString(jsonObject.getString("contractId"));
String fundType = jsonObject.getString("fundType");
Map<String, Object> map = new HashMap<>();
List<KObject> artificialRechargeAdvanceList = statementAccountDao.queryAdvanceByContractId(contractId, fundType, ArtificialRechargeConstant.ENTITY);
List<StatementAccount> statementAccounts = new ArrayList<StatementAccount>();
//人工充值
if (artificialRechargeAdvanceList.size() > 0) {
for (int i = 0; i < artificialRechargeAdvanceList.size(); i++) {
KObject kObject = artificialRechargeAdvanceList.get(i);
StatementAccount statementAccount = new StatementAccount();
if (kObject.getString("fundType").equals(FundTypeEnum.ADVANCE.name())) { //预付款
statementAccount.setDealType("预付款充值");
} else if(kObject.getString("fundType").equals(FundTypeEnum.DEPOSIT.name())){
statementAccount.setDealType("保证金充值");
}
statementAccount.setDealAmount(kObject.getBigDecimal("rechargeAmount"));
statementAccount.setDealDate(kObject.getString("createTime"));
statementAccounts.add(statementAccount);
}
}
//退费
List<KObject> financeRefundList = statementAccountDao.queryAdvanceByContractId(contractId, fundType, FinanceRefundConstant.ENTITY);
if (financeRefundList.size() > 0) {
for (int i = 0; i < financeRefundList.size(); i++) {
KObject kObject = financeRefundList.get(i);
StatementAccount statementAccount = new StatementAccount();
if (fundType.equals(FundTypeEnum.ADVANCE.name())) { //预付款
statementAccount.setDealType("预付款退费");
} else if (fundType.equals(FundTypeEnum.DEPOSIT.name())){
statementAccount.setDealType("保证金退费");
}
statementAccount.setDealAmount(kObject.getBigDecimal("actualRefundAmount"));
statementAccount.setDealDate(kObject.getString("createTime"));
statementAccounts.add(statementAccount);
}
}
//费用调整
List<KObject> expenseAdjustList = statementAccountDao.queryAdvanceByContractId(contractId, fundType, ExpenseAdjustConstant.ENTITY);
if (expenseAdjustList.size() > 0) {
for (int i = 0; i < expenseAdjustList.size(); i++) {
KObject kObject = expenseAdjustList.get(i);
StatementAccount statementAccount = new StatementAccount();
if (kObject.getString("fundType").equals(FundTypeEnum.ADVANCE.name())) { //预付款
statementAccount.setDealType("预付款费用调整");
} else if (kObject.getString("fundType").equals(FundTypeEnum.DEPOSIT.name())){
statementAccount.setDealType("保证金费用调整");
}
statementAccount.setDealAmount(kObject.getBigDecimal("expenseAdjustAmount"));
statementAccount.setDealDate(kObject.getString("createTime"));
statementAccounts.add(statementAccount);
}
}
return statementAccounts;
}
} }
package com.xyst.dinas.finance.service; package com.xyst.dinas.finance.service;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
...@@ -7,10 +8,14 @@ import javax.servlet.http.HttpServletResponse; ...@@ -7,10 +8,14 @@ import javax.servlet.http.HttpServletResponse;
import org.json.JSONObject; import org.json.JSONObject;
import com.xyst.dinas.finance.entity.StatementAccount;
public interface StatementAccountService { public interface StatementAccountService {
Map<String, Object> queryStatementAccountByContractId(JSONObject jsonObject); Map<String, Object> queryStatementAccountByContractId(JSONObject jsonObject);
void exportStatementAccountDetails(HttpServletResponse response, JSONObject param); void exportStatementAccountDetails(HttpServletResponse response, JSONObject param);
List<StatementAccount> queryAccountByContractId(JSONObject jsonObject);
} }
package com.xyst.dinas.finance.web; package com.xyst.dinas.finance.web;
import java.io.IOException; import java.io.IOException;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
...@@ -18,6 +19,7 @@ import org.springframework.web.bind.annotation.ResponseBody; ...@@ -18,6 +19,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.beecode.inz.basis.team.pojo.ResponseObj; import com.beecode.inz.basis.team.pojo.ResponseObj;
import com.xyst.dinas.finance.entity.StatementAccount;
import com.xyst.dinas.finance.service.StatementAccountService; import com.xyst.dinas.finance.service.StatementAccountService;
/** /**
...@@ -65,5 +67,23 @@ public class StatementAccountController { ...@@ -65,5 +67,23 @@ public class StatementAccountController {
} }
return obj.toString(); return obj.toString();
} }
/**
* 预付款
* @param
* @return
*/
@ResponseBody
@RequestMapping(value = "/finance/statementAccount/queryAccountByContractId", method = RequestMethod.POST)
public Object queryAdvanceByContractId(@RequestBody String body) {
try{
List<StatementAccount> advanceAmount = statementAccountService.queryAccountByContractId(new JSONObject(body));
return ResponseObj.success("查询成功", advanceAmount);
} catch(Exception e) {
e.printStackTrace();
return ResponseObj.error();
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment