Merge branch 'develop'

master
taylor.dang 6 years ago
commit 9699c485cc

@ -76,4 +76,6 @@ public interface TransactionAnalysisMapper {
PageList<JSONObject> getAreaMerchantAmountAnalysis(JSONObject params,PageBounds pagination);
List<JSONObject> getAreaMerchantAmountByCycle(JSONObject params);
JSONObject getOrderClearAmount(@Param("order_id") String order_id);
}

@ -120,9 +120,9 @@ public interface RetailAppService {
void useCoupon(JSONObject device, String coupon_log_id);
JSONObject getAd(JSONObject device);
JSONObject getAd();
JSONObject getAdDetail(JSONObject device, String article_id);
JSONObject getAdDetail(String article_id);
JSONObject getCheckClientInfo(JSONObject device);
@ -163,4 +163,6 @@ public interface RetailAppService {
JSONObject getCouponCusCouponLog(String client_moniker, AppQueryBean appQueryBean);
void saveCouponAccuessLog(int client_id, String coupon_id);
JSONObject getStyle();
}

@ -498,6 +498,11 @@ public class RetailAppServiceImp implements RetailAppService {
couponAccuessLogMapper.save(couponAccuessLog);
}
@Override
public JSONObject getStyle() {
return royalPayCMSSupport.getStyle();
}
@Override
public void updateClient(JSONObject device, AppClientBean appClientBean) {
String clientType = device.getString("client_type");
@ -1765,23 +1770,44 @@ public class RetailAppServiceImp implements RetailAppService {
}
@Override
public JSONObject getAd(JSONObject device) {
String clientType = device.getString("client_type");
deviceSupport.findRegister(clientType);
public JSONObject getAd() {
JSONObject res = royalPayCMSSupport.listArticles("app_ad", false, true, 1, 10);
JSONArray acts = res.getJSONArray("data");
if (acts.size() > 0) {
int selectNo = RandomUtils.nextInt(0, acts.size());
return acts.getJSONObject(selectNo);
JSONObject getActs = acts.getJSONObject(selectNo);
getActs.put("ad_cover", getActs.getString("page_desc"));
getActs.put("ad_mode", getActs.getString("page_keywords"));
getActs.put("ad_link", getActs.getString("summery"));
getActs.put("publish_date", DateFormatUtils.format(getActs.getDate("publish_time"),"yyyy/MM/dd HH:mm:ss"));
String reference = getActs.getString("reference");
JSONObject referenceObj = JSONObject.parseObject(reference);
if (reference != null) {
if (referenceObj.getString("ad_type") != null) {
getActs.put("ad_type", referenceObj.getString("ad_type"));
}
if (referenceObj.getString("expire_date") != null) {
getActs.put("expire_date", referenceObj.getString("expire_date"));
}
if (referenceObj.getString("duration_time") != null) {
getActs.put("duration_time", referenceObj.getString("duration_time"));
}
}else {
getActs.put("message", "mess : (ad_type && expire_date && duration_time) not set");
}
getActs.remove("reference");
getActs.remove("page_desc");
getActs.remove("page_keywords");
getActs.remove("summery");
getActs.remove("publish_time");
return getActs;
}
return null;
}
@Override
public JSONObject getAdDetail(JSONObject device, String article_id) {
String clientType = device.getString("client_type");
deviceSupport.findRegister(clientType);
public JSONObject getAdDetail(String article_id) {
JSONObject res = royalPayCMSSupport.getArticle("app_ad", article_id);
Document doc = Jsoup.parse(res.getString("content"));
String father = "<div style=\"padding:0 10px\"></div>";

@ -395,19 +395,6 @@ public class RetailAppController {
}
/* 优惠券End */
/**
* 广
*/
@RequestMapping(value = "/ads", method = RequestMethod.GET)
public JSONObject getAd(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
return retailAppService.getAd(device);
}
@RequestMapping(value = "/ads/{article_id}", method = RequestMethod.GET)
public JSONObject getAdDetail(@PathVariable String article_id, @ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
return retailAppService.getAdDetail(device, article_id);
}
@RequestMapping(value = "/bills/{bill_id}", method = RequestMethod.GET)
public JSONObject getBill(@PathVariable("bill_id") String bill_id, @ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) {
return billService.getBillDetail(bill_id, device.getIntValue("client_id"));
@ -574,4 +561,9 @@ public class RetailAppController {
retailAppService.saveCouponAccuessLog(client_id, coupon_id);
}
@RequestMapping(value = "/style", method = RequestMethod.GET)
public JSONObject getStyle() {
return retailAppService.getStyle();
}
}

@ -1,7 +1,9 @@
package au.com.royalpay.payment.manage.appclient.web;
import au.com.royalpay.payment.manage.appclient.beans.RetailLoginInfo;
import au.com.royalpay.payment.manage.appclient.core.RetailAppService;
import au.com.royalpay.payment.manage.signin.core.SignInStatusManager;
import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.device.DeviceSupport;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.http.HttpUtils;
@ -32,6 +34,8 @@ public class RetailValidationController {
private SignInStatusManager signInStatusManager;
@Resource
private DeviceSupport deviceSupport;
@Resource
private RetailAppService retailAppService;
@RequestMapping(value = "/devices/{devType}/register", method = RequestMethod.POST)
public JSONObject register(@RequestBody String registeration, @PathVariable String devType) {
@ -91,4 +95,17 @@ public class RetailValidationController {
}
return res;
}
/**
* 广
*/
@RequestMapping(value = "/ads", method = RequestMethod.GET)
public JSONObject getAd() {
return retailAppService.getAd();
}
@RequestMapping(value = "/ads/{article_id}", method = RequestMethod.GET)
public JSONObject getAdDetail(@PathVariable String article_id) {
return retailAppService.getAdDetail( article_id);
}
}

@ -3,6 +3,8 @@ package au.com.royalpay.payment.manage.customers.core;
import au.com.royalpay.payment.manage.customers.beans.GatewayParams;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
/**
* Created by yishuqian on 24/04/2017.
*/
@ -19,4 +21,6 @@ public interface CustomerPointsService {
int getOldPoints(String customer_id, String channel);
int checkPointsAfterPay(String order_id);
BigDecimal checkLotteryAfterPay(String order_id);
}

@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.customers.core.impls;
import au.com.royalpay.payment.core.exceptions.SignInvalidException;
import au.com.royalpay.payment.core.exceptions.SignTimeoutException;
import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper;
import au.com.royalpay.payment.manage.customers.beans.GatewayParams;
import au.com.royalpay.payment.manage.customers.core.CustomerPointsService;
import au.com.royalpay.payment.manage.mappers.customers.CustomerMembershipMapper;
@ -21,6 +22,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
@ -49,6 +51,8 @@ public class CustomerPointsServiceImp implements CustomerPointsService {
private CustomerPointsMapper customerPointsMapper;
@Resource
private CustomerMembershipMapper customerMembershipMapper;
@Resource
private TransactionAnalysisMapper transactionAnalysisMapper;
private String auth_code = "w2DgCF2cvlNHo3R6";
@ -276,6 +280,15 @@ public class CustomerPointsServiceImp implements CustomerPointsService {
}
}
@Override
public BigDecimal checkLotteryAfterPay(String order_id) {
JSONObject order = transactionAnalysisMapper.getOrderClearAmount(order_id);
if (order.getIntValue("client_id") != 9) {
return BigDecimal.valueOf(0);
}
return order.getBigDecimal("clearing_amount");
}
/**
*
*

@ -2,12 +2,10 @@ package au.com.royalpay.payment.manage.customers.web;
import au.com.royalpay.payment.manage.customers.core.CustomerPointsService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.math.BigDecimal;
@Controller
@RequestMapping(value = "/customers/points")
@ -21,4 +19,10 @@ public class CustomerPointsController {
public int checkPointsAfterPay(@PathVariable String order_id) {
return customerPointsService.checkPointsAfterPay(order_id);
}
@RequestMapping(value = "/lottery/{order_id}/check",method = RequestMethod.GET)
@ResponseBody
public BigDecimal checkLotteryAfterPay(@PathVariable String order_id) {
return customerPointsService.checkLotteryAfterPay(order_id);
}
}

@ -34,11 +34,11 @@ public interface RiskAttentionMerchantsMapper {
PageList<JSONObject> query(JSONObject params, PageBounds pagination);
@Select("SELECT client_moniker FROM risk_attention_merchants " +
"WHERE (abn LIKE CONCAT('%',#{abn},'%') ) OR (acn LIKE CONCAT('%',#{acn},'%') ) " +
" OR (contact_phone LIKE CONCAT('%',#{contact_phone},'%') ) " +
" OR (contact_person LIKE CONCAT('%',#{contact_person},'%') ) " +
" OR (client_moniker LIKE CONCAT('%',#{client_moniker},'%') ) " +
" OR (bank_account_no LIKE CONCAT('%',#{bank_account_no},'%') ) AND is_valid=1")
"WHERE (abn = #{abn} ) OR (acn = #{acn} ) " +
" OR (contact_phone = #{contact_phone} ) " +
" OR (contact_person = #{contact_person} ) " +
" OR (client_moniker = #{client_moniker} ) " +
" OR (bank_account_no = #{bank_account_no} ) AND is_valid=1")
List<JSONObject> listRiskySimilarMerchants(JSONObject params);
}

@ -6,6 +6,7 @@ import au.com.royalpay.payment.channels.wechat.runtime.MpPaymentApi;
import au.com.royalpay.payment.channels.wechat.runtime.WxPayClient;
import au.com.royalpay.payment.channels.wechat.runtime.beans.SubMerchantInfo;
import au.com.royalpay.payment.core.PaymentChannelApi;
import au.com.royalpay.payment.core.beans.PayChannel;
import au.com.royalpay.payment.core.exceptions.EmailException;
import au.com.royalpay.payment.core.exceptions.InvalidShortIdException;
import au.com.royalpay.payment.core.utils.OrderExpiryRuleResolver;
@ -591,8 +592,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (clientMapper.findClientByMoniker(registery.getClientMoniker()) != null) {
throw new BadRequestException("error.partner.valid.dumplicate_client_moniker");
}
//检查商户是否进入系统黑名单
isRiskyMerchant(partner, null);
//2018-09-10,新建商户不检查是否在系统黑名单
//isRiskyMerchant(partner, null);
try {
@ -1184,8 +1185,20 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(manager, clientMoniker, "enable_hf_email_notice", allow));
}
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(manager, clientMoniker, "enable_" + channel.toLowerCase(), allow));
logger.info(manager.getString("display_name") + "(" + manager.getString("manager_id") + ") switched client " + clientMoniker + " channel "
+ channel + " to " + allow);
if (allow && (StringUtils.equalsAnyIgnoreCase("Wechat", channel) || StringUtils.equalsAnyIgnoreCase("Alipay", channel))) {
int clientId = client.getIntValue("client_id");
List<JSONObject> clientBankAccounts = clientBankAccountMapper.clientBankAccounts(clientId);
if (clientBankAccounts.size() > 0) {
isRiskyMerchant(client, clientBankAccounts.get(0));
} else {
isRiskyMerchant(client, null);
}
}
return;
}
}
@ -3839,9 +3852,15 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
List<JSONObject> listRiskySimilarMerchants = riskAttentionMerchantsMapper.listRiskySimilarMerchants(needCheckParams);
if (listRiskySimilarMerchants.size() > 0) {
StringBuilder appendStr = new StringBuilder();
listRiskySimilarMerchants.forEach(json -> appendStr.append(json.getString("client_moniker")).append(","));
StringBuilder infoStr = new StringBuilder();
listRiskySimilarMerchants.forEach(json -> {
appendStr.append(json.getString("client_moniker")).append(",");
JSONObject riskInfo = riskAttentionMerchantsMapper.findByClientMoniker(json.getString("client_moniker"));
infoStr.append("ABN = " + riskInfo.getString("abn") + ",ACN = " + riskInfo.getString("acn") + ",contact_phone = " + riskInfo.getString("contact_phone") + ",contact_person = " + riskInfo.getString("contact_person") + ",bank_account_no = " + riskInfo.getString("bank_account_no"));
});
appendStr.deleteCharAt(appendStr.length() - 1);
throw new BadRequestException("该商户信息已经进入系统黑名单,关联商户为【" + appendStr + "】");
throw new BadRequestException("该商户信息已经进入系统黑名单,关联商户为【" + appendStr.toString().toUpperCase() + "】【" + infoStr.toString() + "】");
}
}

@ -863,4 +863,12 @@
</if>
GROUP BY c.client_id order by old_total desc
</select>
<select id="getOrderClearAmount" resultType="com.alibaba.fastjson.JSONObject">
SELECT clearing_amount,o.client_id
FROM pmt_orders o
INNER JOIN pmt_transactions pt ON o.order_id = pt.order_id
WHERE o.order_id = #{order_id}
LIMIT 1;
</select>
</mapper>

@ -18,7 +18,7 @@
SELECT
t.*,
count(p.red_packet_customer_order_id) total_counts,
sum(if(p.open_id IS NULL, 1, 0)) unsend_counts
SUM(ISNULL(p.open_id) AND p.red_pack_type_id IS NOT NULL) unsend_counts
FROM act_prize_type_customer t
LEFT JOIN act_red_packets_customer_orders p ON p.red_pack_type_id = t.type_id
AND date(p.create_time) <= curdate()

@ -109,6 +109,7 @@ define(['angular', 'uiRouter', 'static/commons/angular-ueditor'], function (angu
app.controller('cmsAddArticleCtrl', ['$scope', '$http', '$state', '$stateParams', 'commonDialog', function ($scope, $http, $state, $stateParams, commonDialog) {
$scope.saveArticle = function () {
$scope.article.reference =$scope.reference;
$http.post('/app/cms/categories/' + $stateParams.catId + '/articles', $scope.article).then(function (resp) {
$state.go('^.article_view', {articleId: resp.data.article_id});
}, function (resp) {
@ -119,7 +120,14 @@ define(['angular', 'uiRouter', 'static/commons/angular-ueditor'], function (angu
app.controller('cmsArticleEditCtrl', ['$scope', '$http', '$state', '$stateParams', 'commonDialog', 'article', function ($scope, $http, $state, $stateParams, commonDialog, article) {
$scope.article = article.data;
if ($scope.article.reference) {
$scope.reference = JSON.parse($scope.article.reference);
}else {
$scope.reference = {};
}
$scope.saveArticle = function () {
$scope.article.reference =$scope.reference;
$http.put('/app/cms/categories/' + $stateParams.catId + '/articles/' + $stateParams.articleId, $scope.article).then(function (resp) {
$state.go('^.article_view', {articleId: $stateParams.articleId});
}, function (resp) {

@ -20,7 +20,7 @@
<label class="col-md-2 control-label" for="kw-input">HTML Keywords</label>
<div class="col-md-10">
<input ng-model="article.page_keywords" type="text" name="title" id="kw-input" class="form-control">
<p ng-if="catId=='app_ad'"class="small text-warning">(重要0不允许跳转 1跳转编辑内容 2跳转到外链)</p>
<p ng-if="catId=='app_ad'"class="small text-warning">(重要0不允许跳转 1跳转到外链)</p>
</div>
</div>
<div class="form-group">
@ -40,7 +40,27 @@
<p ng-if="catId=='app_ad'"class="small text-warning">(若有外链,则填,否则留空)</p>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="kw-input">Type</label>
<div class="col-md-10">
<input ng-model="reference.ad_type" type="text" name="title" id="type-input" class="form-control">
<p ng-if="catId=='app_ad'"class="small text-warning">(广告封面 type=0时 为图片地址 type=1时 为视频地址)</p>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="kw-input">Mode</label>
<div class="col-md-10">
<input ng-model="reference.expire_date" type="text" name="title" id="expire_date-input" class="form-control">
<p ng-if="catId=='app_ad'"class="small text-warning">(广告过期时间 格式为: 2018/10/01 00:00:00)</p>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="kw-input">Duration time</label>
<div class="col-md-10">
<input ng-model="reference.duration_time" type="text" name="title" id="duration_time-input" class="form-control">
<p ng-if="catId=='app_ad'"class="small text-warning">(广告展示时间(s))</p>
</div>
</div>
</form>
<div class="form-group">
<label class="control-label">Content</label>

@ -31,7 +31,7 @@
<th>Title</th>
<th>Add Time</th>
<th>Published</th>
<th>Recommended</th>
<!-- <th>Recommended</th>-->
<th>Operation</th>
</tr>
</thead>
@ -44,11 +44,11 @@
<i class="fa" ng-class="{'fa-check text-success':article.publish_status,'fa-remove text-danger':!article.publish_status}"></i>
</a>
</td>
<td>
<!-- <td>
<a role="button" ng-click="toggleArticleRecommended(article)" title="Toggle recommended">
<i class="fa" ng-class="{'fa-check text-success':article.recommended,'fa-remove text-danger':!article.recommended}"></i>
</a>
</td>
</td>-->
<td>
<a ui-sref=".edit_article({articleId:article.article_id})" title="edit"><i class="fa fa-edit"></i></a>
<a ui-sref=".article_view({articleId:article.article_id})" title="preview"><i class="fa fa-eye"></i></a>

@ -0,0 +1,390 @@
/**
* Created by yixian on 2017-05-08
*/
$(function () {
'use strict';
var dataCache = {price: '0', coupons: [], coupon_groups:{}};
var exchangeRate = parseFloat(window.exchange_rate);
dataCache.paying = false;
var ctrl = {};
$('.weui_grid.key').bind('touchstart', function () {
if (dataCache.paying) {
return;
}
var char = $(this).attr('data-char');
appendChar(char);
});
$('.coupons .use-check').click(function () {
if ($(this).hasClass('disabled')) {
return;
}
var couponId = $(this).attr('data-coupon-id');
var couponGroup = $(this).attr('data-coupon-group');
if (couponGroup) {
var prevCouponId = dataCache.coupon_groups[couponGroup];
if (prevCouponId) {
var prevIdx = dataCache.coupons.indexOf(prevCouponId);
if (prevIdx >= 0) {
dataCache.coupons.splice(prevIdx, 1);
}
if (prevCouponId!=couponId) {
$('.coupons .use-check[data-coupon-id="' + prevCouponId + '"]').removeClass('checked').addClass('unchecked');
dataCache.coupon_groups[couponGroup] = couponId;
}else {
dataCache.coupon_groups[couponGroup]= null;
}
}else {
dataCache.coupon_groups[couponGroup] = couponId;
}
}
if ($(this).is('.checked')) {
$(this).removeClass('checked').addClass('unchecked');
} else {
$(this).removeClass('unchecked').addClass('checked');
}
var checked = $(this).is('.checked');
if (checked) {
dataCache.coupons.push(couponId);
updatePrice();
} else {
var idx = dataCache.coupons.indexOf(couponId);
dataCache.coupons.splice(idx, 1);
updatePrice();
}
});
$('#key_B').bind('touchstart', function () {
backspace();
});
function updatePoundage(price) {
if (window.extensions.indexOf('customerrate') >= 0 && window.rateValue != null) {
if (window.use_customised_rate) {
var rate = new Decimal(100).plus(window.rateValue).div(100);
var poundageValue = new Decimal(dataCache.price).mul(rate).sub(dataCache.price);
} else {
var rateRemain = new Decimal(100).sub(window.rateValue).div(100);
poundageValue = new Decimal(dataCache.price).div(rateRemain).sub(dataCache.price);
}
dataCache.poundageValue = poundageValue.toFixed(2, Decimal.ROUND_HALF_UP);
return poundageValue.plus(price).toFixed(2, Decimal.ROUND_HALF_UP);
}
return price;
}
function updatePrice() {
$('#audVal').html(dataCache.price);
var realPrice = dataCache.price;
$('#audValReal').html(realPrice);
var surchargeData = calculateSurcharge(realPrice);
dataCache.tax = surchargeData.tax;
dataCache.surcharge = surchargeData.surcharge;
var price = surchargeData.newPrice || realPrice;
var priceBeforeDiscount = price;
dataCache.discounts = [];
$(window.coupons).each(function () {
price = this.handleDiscount(price, dataCache.price, dataCache.discounts, dataCache.coupons);
});
dataCache.customSurcharge = new Decimal(price).sub(realPrice).toFixed(2,Decimal.ROUND_HALF_UP);
dataCache.finalPrice = new Decimal(price).toFixed(2, Decimal.ROUND_FLOOR);
var rate = 'CNY' == window.currency ? 1 : exchangeRate;
var cnyVal = Decimal.mul(price, rate).toFixed(2, Decimal.ROUND_HALF_UP);
$('#cnyVal').html(cnyVal);
dataCache.currencyPrice = 'CNY' == window.currency ? Decimal.div(priceBeforeDiscount, exchangeRate).toFixed(2, Decimal.ROUND_FLOOR) : priceBeforeDiscount;
}
function updatePoundageStatus() {
$(window.coupons).each(function () {
var coupon = this;
var couponId = coupon.couponId();
if (coupon.isEnable(dataCache.currencyPrice||0)) {
$('.coupons .use-check[data-coupon-id=' + couponId + ']').removeClass('disabled');
} else {
var dom = $('.coupons .use-check[data-coupon-id=' + couponId + ']').addClass('disabled');
var couponGroup = dom.attr('data-coupon-group');
if (couponGroup) {
if (dataCache.coupon_groups[couponGroup] == couponId) {
dataCache.coupon_groups[couponGroup] = null;
}
}
var idx = dataCache.coupons.indexOf(couponId);
if (idx >= 0) {
dataCache.coupons.splice(idx, 1);
}
dom.removeClass('checked').addClass('unchecked');
}
})
}
updatePoundageStatus();
function backspace() {
dataCache.price = dataCache.price.substring(0, dataCache.price.length - 1);
if (dataCache.price.length == 0) {
dataCache.price = '0';
}
updatePrice();
updatePoundageStatus();
}
function appendChar(char) {
var pointLocation = dataCache.price.indexOf('.');
if (pointLocation >= 0 || char == '.' || dataCache.price.length < 5) {
if (pointLocation >= 0 && char == '.') {
return;
}
if (pointLocation >= 0 && pointLocation <= dataCache.price.length - 3) {
return;
}
if (dataCache.price == '0' && char != '.') {
dataCache.price = '';
}
dataCache.price += char;
updatePrice();
updatePoundageStatus();
}
}
$('#coupon-box-toggle').click(function () {
$('.coupons-container').addClass('show')
});
$('.coupons-container>.coupons-mask,.coupons-container #close-coupon-box').click(function () {
$(this).parents('.coupons-container').removeClass('show');
});
$('.remark-btn').click(function () {
var cfg = {
title: '备注 Remark',
template: '',
initialize: function (dialog) {
$('<textarea rows="2"></textarea>').addClass('remark-input').attr('name', 'remark').val(dataCache.remark || '').appendTo($('.weui_dialog_bd', dialog));
},
confirm: function (dialog, chosen) {
if (chosen) {
var remark = $('textarea[name="remark"]', dialog).val();
if (remark) {
$('#remark-box').text('备注:' + remark).show()
} else {
$('#remark-box').text('').hide();
}
dataCache.remark = remark;
}
}
};
showWeuiDialog(cfg);
});
$('.paydetail').click(function () {
var config = {
title: 'Payment Detail',
template: '',
initialize: function (dialog) {
var bd = $('.weui_dialog_bd', dialog);
var currencySymbol = window.currency == 'AUD' ? '$' : '¥';
$('<p></p>').html('Input Price 输入金额:' + currencySymbol + dataCache.price).appendTo(bd);
if (parseFloat(dataCache.customSurcharge) > 0) {
$('<p></p>').html('Surcharge 手续费(' + window.rateValue + '%):+' + currencySymbol + dataCache.customSurcharge).appendTo(bd);
}
$(dataCache.discounts).each(function () {
$('<p></p>').html(this.title + ':-' + currencySymbol + this.amount).appendTo(bd);
});
$('<p></p>').addClass('final').html('Final 支付金额:' + currencySymbol + (dataCache.finalPrice || 0)).appendTo(bd);
}
};
showWeuiDialog(config);
});
$('#key_P').bind('touchstart', function () {
pay();
// $('#key_P').addClass('hidden');
// $('#key_Loading').removeClass('hidden');
// if (dataCache.paying) {
// return;
// }
// dataCache.paying = true;
// var data = {price: dataCache.price + '', original_number: true, currency: window.currency};
// if (dataCache.remark) {
// data.description = dataCache.remark;
// }
// if (window.extensions.indexOf('preauthorize') >= 0) {
// data.preauthorize = true;
// }
// if (window.extensions.indexOf('qrcodemode') >= 0) {
// data.qrmode = true;
// }
// if (window.extensions.indexOf('customerrate') >= 0) {
// data.customerrate = true;
// }
// data.coupons = dataCache.coupons;
// dataCache.remark = '';
// data.account_id = User.getProduct();
// data.qrcodeVersion = window.qrcodeVersion;
// $.ajax({
// url: '/api/v1.0/bestpay/partners/' + window.client_moniker + '/app_order',
// method: 'POST',
// data: JSON.stringify(data),
// dataType: 'json',
// contentType: 'application/json',
// success: function (pay) {
// if (pay.direct_paid) {
// window.location = '/api/v1.0/bestpay/partners/' + window.client_moniker + '/orders/' + pay.order_id;
// return;
// }
// var paydata = pay.params;
// try {
// Payment.onPay(paydata, function () {
// window.location = '/api/v1.0/bestpay/partners/' + window.client_moniker + '/orders/' + pay.order_id;
// dataCache.paying = false;
// $('#key_P').removeClass('hidden');
// $('#key_Loading').addClass('hidden');
// }, function (rescode) {
// dataCache.paying = false;
// if (rescode === "cancel") {
// Dialog.alert("支付取消" + rescode)
// } else {
// Dialog.alert("支付失败" + rescode)
// }
// $('#key_P').removeClass('hidden');
// $('#key_Loading').addClass('hidden');
// })
// } catch (e) {
// Dialog.alert(e);
// dataCache.paying = false;
// $('#key_P').removeClass('hidden');
// $('#key_Loading').addClass('hidden');
// }
// Dialog.dismissDialog(dataCache.process);
// },
// error: function (jqXhr) {
// Dialog.alert(jqXhr.responseJSON.message);
// Dialog.dismissDialog(dataCache.process);
// dataCache.paying = false;
// $('#key_P').removeClass('hidden');
// $('#key_Loading').addClass('hidden');
// }
// });
});
function showWeuiDialog(config) {
if (config.templateUrl) {
$.ajax({
url: config.templateUrl,
dataType: 'html',
success: function (template) {
buildDialog(template);
}
});
} else {
buildDialog(config.template);
}
function buildDialog(template) {
var defaultConfig = {backdrop: true};
config = $.extend({}, defaultConfig, config);
var dialog = $("<div></div>", {class: 'weui_dialog_confirm'});
var mask = $('<div></div>', {class: 'weui_mask'}).appendTo(dialog);
if (config.backdrop) {
mask.click(function () {
dialog.remove();
if ($.isFunction(config.dismiss)) {
config.dismiss();
}
})
}
var dialogBox = $("<div></div>", {class: 'weui_dialog'}).appendTo(dialog);
if (config.title) {
$('<div></div>', {class: 'weui_dialog_hd'}).append($('<strong></strong>', {class: 'weui_dialog_title'}).html(config.title)).appendTo(dialogBox);
}
var dialogBody = $("<div></div>", {class: 'weui_dialog_bd'}).appendTo(dialogBox);
if (template) {
dialogBody.append(template);
}
if ($.isFunction(config.initialize)) {
config.initialize(dialog);
}
var ft = $('<div class="weui_dialog_ft"></div>').appendTo(dialogBox);
if ($.isFunction(config.confirm)) {
var yes = $('<a></a>', {class: 'weui_btn_dialog primary', text: 'OK'}).appendTo(ft);
yes.click(function () {
config.confirm(dialog, true);
dialog.remove();
});
var no = $('<a></a>', {class: 'weui_btn_dialog default', text: 'Cancel'}).appendTo(ft);
no.click(function () {
config.confirm(dialog, false);
dialog.remove();
})
} else {
var ok = $('<a></a>', {class: 'weui_btn_dialog primary', text: 'OK'}).appendTo(ft);
ok.click(function () {
dialog.remove();
})
}
dialog.appendTo($('body'));
}
}
function getUserId(){
window.RPayPlus.send("getUserId", null, function(data){
alert(data);
});
}
function pay(){
var order={
orderId:'00002',
amount:'$100.07',
title:'Gift card purchase'
};
window.RPayPlus.send('pay', order, function(data){
alert('this is callback from native and data='+JSON.stringify(data));
});
}
function back(){
window.RPayPlus.send("back", null, null);
}
function jsInvoke(){
window.RPayPlus.send("jsInvoke", 'Native Test', null);
}
function createOrder(msg){
alert('create order information='+JSON.stringify(msg));
}
function queryOrder(msg){
alert('query order information='+JSON.stringify(msg));
var order={
orderId:'00001',
amount:'$10.98',
title:'Balance Top-UP'
};
setTimeout("window.RPayPlus.onResult("+JSON.stringify(order)+");", 1500);
}
function registerJs(){
window.RPayPlus.register('createOrder', function(data){
createOrder(data);
});
window.RPayPlus.register('queryOrder', function(data){
queryOrder(data);
});
}
getUserId();
});

@ -0,0 +1,57 @@
$(function (){
var callbacks = {};
var functions = {};
window.RPayPlus = {
// 向Native端发送消息用于实现JS->Native
send: function(methodName, param, callback) {
var thisId = 0;
if(callback){
thisId = new Date().getTime();; // 获取唯一id
callbacks[thisId] = callback; // 存储Callback
}
var json = {
method: methodName,
data: param || {},
callbackId: thisId // 传到 Native 端
};
var msg = JSON.stringify(json);
var u = navigator.userAgent;
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
if(isiOS){
window.webkit.messageHandlers.rpayplus.postMessage(msg);
} else{
rpayplus.send(msg);
}
},
// 接收来自Native发送的消息用于实现Native->JS
receive: function(msg) {
var method = msg.methodName,
data = msg.data || {},
callbackId = msg.callbackId; // JS->Native的回调函数ID
// 具体逻辑 bridgeName 和 callbackId 不会同时存在;
// callbackId有效表示此接收信息源自JS->Native的回调
// callbackId无效且method有效表示是Native->JS的直接调用
if (callbackId && callbacks[callbackId]) {
callbacks[callbackId](msg.data); // 执行调用
return;
}
if (method && functions[method]) {
functions[method](msg);
}
},
// 注册JS方法供Native调用未被注册的方法Native无法调用
register: function(methodName, callback) {
if (!functions[methodName]) {
functions[methodName] = callback;
}
},
// JS端逻辑处理完成后回调给Native的数据
onResult: function(data){
window.RPayPlus.send("jsCallback", data, null);
}
};
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

@ -69,6 +69,26 @@ $(function () {
loadPoints();
function loadLottery() {
$.ajax({
url: '/customers/points/lottery/' + window.order_id + '/check',
method: 'GET',
dataType: 'text',
success: function (data) {
if (data >= 1.99) {
$('.points-title').html('恭喜您!获得抽奖奖励');
$('.points-desc').html('使用RoyalPay任意消费满1.99澳币获取1次抽奖机会');
$('.points-dialog .points-value').html('+ ' + 1);
$('.points-dialog a').html('进入抽奖页面');
$('.points-dialog a').attr("href","https://customer.royalpay.com.au/activity/luck_draw");
$('.points-dialog').removeClass('hide');
}
}, error: function () {
}
});
}
loadLottery();
$('.encourage-dialog .close-circle').click(function () {
$('.encourage-dialog').addClass('hide');
});

Loading…
Cancel
Save