diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/mappers/TransactionAnalysisMapper.java b/src/main/java/au/com/royalpay/payment/manage/analysis/mappers/TransactionAnalysisMapper.java index a60d93f7e..c28d1b8b2 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/mappers/TransactionAnalysisMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/mappers/TransactionAnalysisMapper.java @@ -76,4 +76,6 @@ public interface TransactionAnalysisMapper { PageList getAreaMerchantAmountAnalysis(JSONObject params,PageBounds pagination); List getAreaMerchantAmountByCycle(JSONObject params); + + JSONObject getOrderClearAmount(@Param("order_id") String order_id); } diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java index b0138c63c..3236e16dc 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java @@ -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(); } diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java index f8f3a01a9..375d3d42d 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java @@ -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 = "
"; diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java index 003e7b8ca..d8cf99f17 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java @@ -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(); + } + } diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailValidationController.java b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailValidationController.java index d00114502..5194f557a 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailValidationController.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailValidationController.java @@ -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); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/customers/core/CustomerPointsService.java b/src/main/java/au/com/royalpay/payment/manage/customers/core/CustomerPointsService.java index 80b89a490..f47965685 100644 --- a/src/main/java/au/com/royalpay/payment/manage/customers/core/CustomerPointsService.java +++ b/src/main/java/au/com/royalpay/payment/manage/customers/core/CustomerPointsService.java @@ -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); } diff --git a/src/main/java/au/com/royalpay/payment/manage/customers/core/impls/CustomerPointsServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/customers/core/impls/CustomerPointsServiceImp.java index a4408b2b1..3cd2e8dad 100644 --- a/src/main/java/au/com/royalpay/payment/manage/customers/core/impls/CustomerPointsServiceImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/customers/core/impls/CustomerPointsServiceImp.java @@ -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"); + } + /** * 获取过期积分 * diff --git a/src/main/java/au/com/royalpay/payment/manage/customers/web/CustomerPointsController.java b/src/main/java/au/com/royalpay/payment/manage/customers/web/CustomerPointsController.java index 6652324b1..3163086d7 100644 --- a/src/main/java/au/com/royalpay/payment/manage/customers/web/CustomerPointsController.java +++ b/src/main/java/au/com/royalpay/payment/manage/customers/web/CustomerPointsController.java @@ -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); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/risk/RiskAttentionMerchantsMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/risk/RiskAttentionMerchantsMapper.java index 3cd1d943f..b97ddb822 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/risk/RiskAttentionMerchantsMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/risk/RiskAttentionMerchantsMapper.java @@ -34,11 +34,11 @@ public interface RiskAttentionMerchantsMapper { PageList 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 listRiskySimilarMerchants(JSONObject params); } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java index 96e4b9fac..7364f74c3 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java @@ -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 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 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() + "】"); } } diff --git a/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/TransactionAnalysisMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/TransactionAnalysisMapper.xml index 6809568a6..c54de2dab 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/TransactionAnalysisMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/analysis/mappers/TransactionAnalysisMapper.xml @@ -863,4 +863,12 @@ GROUP BY c.client_id order by old_total desc + + \ No newline at end of file diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/redpack/ActPrizeTypeCustomerMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/redpack/ActPrizeTypeCustomerMapper.xml index 9c9c36919..d0e07513d 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/redpack/ActPrizeTypeCustomerMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/redpack/ActPrizeTypeCustomerMapper.xml @@ -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() diff --git a/src/main/ui/static/cms/cms.js b/src/main/ui/static/cms/cms.js index 2c6363284..3ab730034 100644 --- a/src/main/ui/static/cms/cms.js +++ b/src/main/ui/static/cms/cms.js @@ -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) { diff --git a/src/main/ui/static/cms/templates/article_editor.html b/src/main/ui/static/cms/templates/article_editor.html index 0ead12acb..7c9cd1bf5 100644 --- a/src/main/ui/static/cms/templates/article_editor.html +++ b/src/main/ui/static/cms/templates/article_editor.html @@ -20,7 +20,7 @@
-

(重要!!!0:不允许跳转 1:跳转编辑内容 2:跳转到外链)

+

(重要!!!0:不允许跳转 1:跳转到外链)

@@ -40,7 +40,27 @@

(若有外链,则填,否则留空)

- +
+ +
+ +

(广告封面 type=0时 为图片地址 type=1时 为视频地址)

+
+
+
+ +
+ +

(广告过期时间 格式为: 2018/10/01 00:00:00)

+
+
+
+ +
+ +

(广告展示时间(s))

+
+
diff --git a/src/main/ui/static/cms/templates/articles.html b/src/main/ui/static/cms/templates/articles.html index bb4489ce7..046393f0a 100644 --- a/src/main/ui/static/cms/templates/articles.html +++ b/src/main/ui/static/cms/templates/articles.html @@ -31,7 +31,7 @@ Title Add Time Published - Recommended + Operation @@ -44,11 +44,11 @@ - + diff --git a/src/main/ui/static/lib/rpay/app_pay_2.js b/src/main/ui/static/lib/rpay/app_pay_2.js new file mode 100644 index 000000000..5126e7f98 --- /dev/null +++ b/src/main/ui/static/lib/rpay/app_pay_2.js @@ -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) { + $('').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' ? '$' : '¥'; + $('

').html('Input Price 输入金额:' + currencySymbol + dataCache.price).appendTo(bd); + if (parseFloat(dataCache.customSurcharge) > 0) { + $('

').html('Surcharge 手续费(' + window.rateValue + '%):+' + currencySymbol + dataCache.customSurcharge).appendTo(bd); + } + $(dataCache.discounts).each(function () { + $('

').html(this.title + ':-' + currencySymbol + this.amount).appendTo(bd); + }); + $('

').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 = $("
", {class: 'weui_dialog_confirm'}); + var mask = $('
', {class: 'weui_mask'}).appendTo(dialog); + if (config.backdrop) { + mask.click(function () { + dialog.remove(); + if ($.isFunction(config.dismiss)) { + config.dismiss(); + } + }) + } + var dialogBox = $("
", {class: 'weui_dialog'}).appendTo(dialog); + if (config.title) { + $('
', {class: 'weui_dialog_hd'}).append($('', {class: 'weui_dialog_title'}).html(config.title)).appendTo(dialogBox); + } + var dialogBody = $("
", {class: 'weui_dialog_bd'}).appendTo(dialogBox); + if (template) { + dialogBody.append(template); + } + if ($.isFunction(config.initialize)) { + config.initialize(dialog); + } + var ft = $('
').appendTo(dialogBox); + if ($.isFunction(config.confirm)) { + var yes = $('', {class: 'weui_btn_dialog primary', text: 'OK'}).appendTo(ft); + yes.click(function () { + config.confirm(dialog, true); + dialog.remove(); + }); + var no = $('', {class: 'weui_btn_dialog default', text: 'Cancel'}).appendTo(ft); + no.click(function () { + config.confirm(dialog, false); + dialog.remove(); + }) + } else { + var ok = $('', {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(); +}); \ No newline at end of file diff --git a/src/main/ui/static/lib/rpay/rpay_jssdk.js b/src/main/ui/static/lib/rpay/rpay_jssdk.js new file mode 100644 index 000000000..e3f48ea99 --- /dev/null +++ b/src/main/ui/static/lib/rpay/rpay_jssdk.js @@ -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); + } + }; + }); \ No newline at end of file diff --git a/src/main/ui/static/lib/rpay/rrlogo.png b/src/main/ui/static/lib/rpay/rrlogo.png new file mode 100644 index 000000000..3af677129 Binary files /dev/null and b/src/main/ui/static/lib/rpay/rrlogo.png differ diff --git a/src/main/ui/static/templates/payment/success.js b/src/main/ui/static/templates/payment/success.js index 526e2751d..c48322bd2 100644 --- a/src/main/ui/static/templates/payment/success.js +++ b/src/main/ui/static/templates/payment/success.js @@ -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'); });