Easyui+MongoDB充值记录查询
充值頁面的效果圖:
1.easyui頁面:
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<title></title>
</head>
<body>
<table class="easyui-datagrid" id="userList" class="easyui-datagrid" style="width: 1288px;height:420px;" title="充值记录"-->
<thead>
<tr>
<th data-options="field:'id'">id</th>
<th data-options="field:'appId'">appId</th>
<th data-options="field:'openId'">openId</th>
<th data-options="field:'mchId'">mchId</th>
<th data-options="field:'paySuccess'">paySuccess</th>
<th data-options="field:'createTime'">createTime</th>
<th data-options="field:'outTradeNo'">outTradeNo</th>
<th data-options="field:'totalFee'">totalFee</th>
<th data-options="field:'cashFee'">cashFee</th>
<th data-options="field:'rechargeToWallet'">rechargeToWallet</th>
</tr>
</thead>
<tbody>
<g:each in="${ret}" status="i" var="${data}">
<tr>
<td>${data.id}</td>
<td>${data.appId}</td>
<td>${data.openId}</td>
<td>${data.mchId}</td>
<td>${data.paySuccess}</td>
<td>${data.createTime}</td>
<td>${data.outTradeNo}</td>
<td>${data.totalFee}</td>
<td>${data.cashFee}</td>
<td>${data.rechargeToWallet}</td>
</tr>
</g:each>
</tbody>
</table>
</body>
</html>
2.緩存MonGoDb數據記錄
/**
* 将充值成功的记录保存到 mongo中
* @param orderInfo
*/
def saveMongoDbPayOrder(WxPayOrder order){
String IPADDRESS = "mongodb://39.108.121.200:27017"
try{
MongoClient client = new MongoClient("localhost" , 27017);
MongoDatabase database = client.getDatabase("cloudDB");
MongoCollection<Document> collection = database.getCollection("ACCESS_LOG");
Document document = new Document()
document.append("id", order.id)
document.append("appId", order.appId)
document.append("openId", order.openId)
document.append("mchId", order.mchId)
document.append("feeType", order.feeType)
document.append("transactionId", order.transactionId)//微信订单号,微信返回
document.append("outTradeNo", order.outTradeNo)//商户订单号,商户自定义
document.append("totalFee", order.totalFee)//订单总金额,单位为分
document.append("cashFee", order.cashFee)
document.append("timeEnd", order.timeEnd)
document.append("paySuccess", order.paySuccess)//支付成功 0=未成功 1=成功
document.append("refundFee", order.refundFee)//已退款的金额,单位为分
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
document.append("createTime", sdf.format(order.createTime))
document.append("rechargeToWallet", order.rechargeToyWallet)
List<Document> documents = new ArrayList<Document>();
documents.add(document);
collection.insertMany(documents);//添加到mondoDb
FindIterable<Document> findIterable = collection.find();
MongoCursor<Document> mongoCursor = findIterable.iterator();
while(mongoCursor.hasNext()){
println mongoCursor.next()
}
}catch (Exception e){
e.printStackTrace()
}
return null
}
3.获取ret数据的的controller
def payOrderMessage(){
def ret = dianMiMiBackService.getOrderMessage()
[ret: ret]
}
4.service
def getOrderMessage(){
def ret=[]
try{
MongoClient client = new MongoClient("localhost" , 27017);
MongoDatabase database = client.getDatabase("cloudDB");
MongoCollection<Document> collection = database.getCollection("ACCESS_LOG");
FindIterable<Document> findIterable = collection.find();
MongoCursor<Document> mongoCursor = findIterable.iterator();
while(mongoCursor.hasNext()){
Document a = mongoCursor.next();
ret.add(a)
}
return ret
}catch (Exception e){
e.printStackTrace()
}
}