Merge branch 'listTopUP' into develop

master
wangning 7 years ago
commit d5bbf8e0be

@ -1,10 +1,12 @@
package au.com.royalpay.payment.manage.mappers.ofei;
import com.alibaba.fastjson.JSONObject;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
@ -26,4 +28,5 @@ public interface TopUpOrderMapper {
List<String> findOrderIdByStatus(@Param("status") String status);
PageList<JSONObject> listPageable(JSONObject jsonObject, PageBounds pageBounds);
}

@ -0,0 +1,67 @@
package au.com.royalpay.payment.manage.ofei.bean;
import com.alibaba.fastjson.JSONObject;
/**
* Created by wangning on 2018/1/3.
*/
public class PhoneTopUpQuery {
private String status;
private int amount;
private String phone;
private int page = 1;
private int limit = 10;
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public int getAmount() {
return amount;
}
public void setAmount(int amount) {
this.amount = amount;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public int getLimit() {
return limit;
}
public void setLimit(int limit) {
this.limit = limit;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public JSONObject toParam(){
JSONObject param = new JSONObject();
param.put("status",this.status);
param.put("amount",this.amount);
param.put("customer_number",this.phone);
return param;
}
}

@ -10,4 +10,6 @@ public interface OfeiServer {
void checkOrder(String orderId);
void phoneTopUp(String price, boolean quickTopUp, String topUpDelayTime, String phoneNumber);
}

@ -0,0 +1,14 @@
package au.com.royalpay.payment.manage.ofei.core;
import au.com.royalpay.payment.manage.ofei.bean.PhoneTopUpQuery;
import com.alibaba.fastjson.JSONObject;
/**
* Created by wangning on 2018/1/3.
*/
public interface PhoneTopUpService {
JSONObject listPageable(PhoneTopUpQuery phoneTopUpQuery);
}

@ -1,8 +1,13 @@
package au.com.royalpay.payment.manage.ofei.core.impl;
import java.util.concurrent.TimeUnit;
import javax.annotation.Resource;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.dom4j.Element;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONObject;
@ -10,6 +15,7 @@ import com.alibaba.fastjson.JSONObject;
import au.com.royalpay.payment.manage.mappers.ofei.TopUpOrderMapper;
import au.com.royalpay.payment.manage.ofei.core.OfeiClient;
import au.com.royalpay.payment.manage.ofei.core.OfeiServer;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
/**
* Created by wangning on 2017/12/8.
@ -20,6 +26,8 @@ public class OfeiServceImpl implements OfeiServer {
private TopUpOrderMapper topUpOrderMapper;
@Resource
private OfeiClient ofeiClient;
@Resource
private StringRedisTemplate stringRedisTemplate;
@Override
public void checkOrderForNotify(JSONObject param) {
@ -74,4 +82,16 @@ public class OfeiServceImpl implements OfeiServer {
topUpOrderMapper.update(order);
}
@Override
public void phoneTopUp(String price, boolean quickTopUp, String topUpDelayTime, String phoneNumber) {
String reidsCheckCodeKey = "topup"+phoneNumber;
String value = stringRedisTemplate.boundValueOps(reidsCheckCodeKey).get();
if (!StringUtils.isEmpty(value)) {
throw new ForbiddenException("A phone number can only be recharged in 10 minutes");
}
ofeiClient.phoneTopUp(price,quickTopUp,topUpDelayTime,phoneNumber);
String bindId = RandomStringUtils.random(6, false, true);
stringRedisTemplate.boundValueOps(reidsCheckCodeKey).set(bindId, 10, TimeUnit.MINUTES);
}
}

@ -0,0 +1,29 @@
package au.com.royalpay.payment.manage.ofei.core.impl;
import au.com.royalpay.payment.manage.mappers.ofei.TopUpOrderMapper;
import au.com.royalpay.payment.manage.ofei.bean.PhoneTopUpQuery;
import au.com.royalpay.payment.manage.ofei.core.PhoneTopUpService;
import au.com.royalpay.payment.tools.utils.PageListUtils;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* Created by wangning on 2018/1/3.
*/
@Service
public class PhoneTopUpServieImpl implements PhoneTopUpService {
@Resource
private TopUpOrderMapper topUpOrderMapper;
@Override
public JSONObject listPageable(PhoneTopUpQuery phoneTopUpQuery) {
PageList<JSONObject> topUpOrders = topUpOrderMapper.listPageable(phoneTopUpQuery.toParam(),new PageBounds(phoneTopUpQuery.getPage(), phoneTopUpQuery.getLimit(), Order.formString("create_time.desc")));
return PageListUtils.buildPageListResult(topUpOrders);
}
}

@ -1,6 +1,10 @@
package au.com.royalpay.payment.manage.ofei.web;
import au.com.royalpay.payment.manage.ofei.core.OfeiClient;
import au.com.royalpay.payment.manage.ofei.bean.PhoneTopUpQuery;
import au.com.royalpay.payment.manage.ofei.core.OfeiServer;
import au.com.royalpay.payment.manage.ofei.core.PhoneTopUpService;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@ -16,10 +20,18 @@ import javax.annotation.Resource;
@RequestMapping("/phone_top_up")
public class PhoneTopUpController {
@Resource
private OfeiClient ofeiClient;
private OfeiServer ofeiServer;
@Resource
private PhoneTopUpService phoneTopUpService;
@RequestMapping(value = "/recharge",method = {RequestMethod.GET, RequestMethod.POST})
public void listNotices(@RequestParam String phoneNumber, @RequestParam String amount) {
ofeiClient.phoneTopUp(amount,true,null,phoneNumber);
public void recharge(@RequestParam String phoneNumber, @RequestParam String amount) {
ofeiServer.phoneTopUp(amount,true,null,phoneNumber);
}
@RequestMapping(value = "/list",method = {RequestMethod.GET, RequestMethod.GET})
public JSONObject list(PhoneTopUpQuery phoneTopUpQuery) {
return phoneTopUpService.listPageable(phoneTopUpQuery);
}
}

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="au.com.royalpay.payment.manage.mappers.ofei.TopUpOrderMapper">
<select id="findOrderIdByStatus" resultType="java.lang.String">
SELECT
@ -8,4 +9,19 @@
where status = #{status}
</select>
<select id="listPageable" resultType="com.alibaba.fastjson.JSONObject">
select *
FROM top_up_order
<where>
<if test="status!=null">
and status = #{status}
</if>
<if test="customer_number!=null">
and customer_number = #{customer_number}
</if>
<if test="amount > 0">
amount = #{amount}
</if>
</where>
</select>
</mapper>

@ -45,6 +45,8 @@ define(['angular', 'uiRouter', 'static/commons/angular-ueditor'], function (angu
}]);
app.controller('CmsPhonetopupCtrl', ['$scope', '$http', '$filter', function ($scope, $http, $filter) {
$scope.queryParams = {};
$scope.pagination = {};
$scope.topUp = function () {
var params = angular.copy($scope.params);
$http.get('/phone_top_up/recharge',{params: params}).then(function (resp) {
@ -53,6 +55,25 @@ define(['angular', 'uiRouter', 'static/commons/angular-ueditor'], function (angu
alert(resp.data.message);
})
}
$scope.listTopUpOrders = function (page) {
var params = angular.copy($scope.queryParams);
params.page = page || $scope.pagination.page || 1;
if(params.amount==''|| params.amount==null){
delete params.amount;
}
if(params.phone==''|| params.phone==null){
delete params.phone;
}
if(params.status==''|| params.status==null){
delete params.status;
}
$http.get('/phone_top_up/list',{params: params}).then(function (resp) {
$scope.orders = resp.data.data;
$scope.pagination = resp.data.pagination;
})
};
$scope.listTopUpOrders(1);
}]);
app.controller('cmsArticleListCtrl', ['$scope', '$http', '$stateParams', function ($scope, $http, $stateParams) {
@ -103,5 +124,37 @@ define(['angular', 'uiRouter', 'static/commons/angular-ueditor'], function (angu
app.controller('cmsArticlePreviewCtrl', ['$scope', 'article', function ($scope, article) {
$scope.article = article.data;
}])
}]);
app.filter('topUpType', function () {
return function (status) {
switch (status + '') {
case '1':
return '话费充值';
case '2':
return '流量';
}
}
});
app.filter('topUpStatus', function () {
return function (status) {
switch (status + '') {
case '0':
return 'Creating';
case '1':
return 'Success';
case '10':
return 'Wait for success';
case '20':
return 'fail';
case '30':
return 'refund';
case '99':
return 'System Error';
case '100':
return 'Ofei Error';
}
}
});
});

@ -18,14 +18,17 @@
<form role="form" style="margin:0px auto;width: 50%">
<div class="form-group">
<label>Phone Number</label>
<input ng-model="params.phoneNumber" name="code" class="form-control" type="text"/>
<input ng-model="params.phoneNumber" name="code"
class="form-control" type="text"/>
</div>
<div class="form-group">
<label>Amount</label>
<input ng-model="params.amount" class="form-control" type="text" />
<input ng-model="params.amount" class="form-control" type="text"/>
</div>
<div class="form-group">
<button class="btn btn-primary btn-block" ng-click="topUp()">commit</button>
<button class="btn btn-primary btn-block" ng-click="topUp()">
commit
</button>
</div>
</form>
</div>
@ -33,4 +36,103 @@
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="box-solid">
<div class="box box-warning">
<div class="box-header">
<div class="form-group col-xs-12">
<label class="control-label col-xs-4 col-sm-2">Status</label>
<div class="col-sm-10 col-xs-8">
<p class="form-control-static">
<a role="button" ng-class="{'bg-primary':queryParams.status==null}"
ng-click="queryParams.status='';listTopUpOrders(1)">All</a> |
<a role="button" ng-class="{'bg-primary':queryParams.status=='1'}"
ng-click="queryParams.status='1';listTopUpOrders(1)">Success</a> |
<a role="button" ng-class="{'bg-primary':queryParams.status=='10'}"
ng-click="queryParams.status='10';listTopUpOrders(1)">Wating</a> |
<a role="button" ng-class="{'bg-primary':queryParams.status=='30'}"
ng-click="queryParams.status='30';listTopUpOrders(1)">Refund</a> |
<a role="button" ng-class="{'bg-primary':queryParams.status=='20'}"
ng-click="queryParams.status='20';listTopUpOrders(1)">fail</a> |
<a role="button" ng-class="{'bg-primary':queryParams.status=='99'}"
ng-click="queryParams.status='99';listTopUpOrders(1)">Error</a>
</p>
</div>
</div>
<div class="form-group col-xs-12">
<label class="control-label col-xs-4 col-sm-2">Amount</label>
<div class="col-sm-10 col-xs-8">
<input ng-model="queryParams.amount" class="form-control" type="text"/>
</div>
</div>
<div class="form-group col-xs-12">
<label class="control-label col-xs-4 col-sm-2">Phone</label>
<div class="col-sm-10 col-xs-8">
<input ng-model="queryParams.phone" class="form-control" type="text"/>
</div>
</div>
<button class="btn btn-success" type="button" ng-click="listTopUpOrders(1)">
<i class="fa fa-search"></i> Search
</button>
<div class="box-body table-responsive">
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>Order ID</th>
<th>Type</th>
<th>Amount</th>
<th>Phone</th>
<th>Status</th>
<th>Create Time</th>
<th>Detail</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="order in orders">
<td>
{{order.id}}
</td>
<td ng-bind="order.type|topUpType"></td>
<td>
{{order.amount}}
</td>
<td>{{order.customer_number}}</td>
<td ng-bind="order.status|topUpStatus"></td>
<td>{{order.create_time}}</td>
<td> {{order.detail}} </td>
</tr>
</tbody>
</table>
</div>
<div class="box-body" ng-if="orders.length">
<uib-pagination class="pagination"
total-items="pagination.totalCount"
boundary-links="true"
ng-model="pagination.page"
items-per-page="pagination.limit"
max-size="10"
ng-change="listTopUpOrders()"
previous-text="&lsaquo;"
next-text="&rsaquo;"
first-text="&laquo;"
last-text="&raquo;"></uib-pagination>
<div class="row">
<div class="col-xs-12">Total Records:{{pagination.totalCount}};Total
Pages:{{pagination.totalPages}}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

Loading…
Cancel
Save