Upd:新版账单码

master
dulingling 5 years ago
parent 3a9ef10f62
commit 79425c194f

@ -9,7 +9,7 @@
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>manage</artifactId> <artifactId>manage</artifactId>
<version>2.1.6</version> <version>2.1.7</version>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jib-maven-plugin.version>1.8.0</jib-maven-plugin.version> <jib-maven-plugin.version>1.8.0</jib-maven-plugin.version>

@ -76,6 +76,14 @@ public class PartnerBillServiceImpl implements PartnerBillService {
String code_url = getQRCodeImg(record); String code_url = getQRCodeImg(record);
record.put("code_url",code_url); record.put("code_url",code_url);
directedBillCodeMapper.update(record); directedBillCodeMapper.update(record);
if("v1".equals(client.getString("billcode_version"))){
record.put("code_urls",code_url);
record.put("code_url",QRCodeUtils.qrcodeImageCode(code_url, 250, false));
}else{
String url = PlatformEnvironment.getEnv().concatUrl("api/v1.0/share_code/business/bills/"+record.getString("bill_code_id")+"/link/payment");
record.put("code_urls",url);
record.put("code_url",QRCodeUtils.qrcodeImageCode(url, 250, false));
}
return QRCodeUtils.qrcodeImageCode(code_url, 250, false); return QRCodeUtils.qrcodeImageCode(code_url, 250, false);
} }
@ -93,7 +101,18 @@ public class PartnerBillServiceImpl implements PartnerBillService {
JSONObject params = queryBillBean.toJson(); JSONObject params = queryBillBean.toJson();
params.put("client_id",client_id); params.put("client_id",client_id);
List<JSONObject> bills = directedBillCodeMapper.findByClientId(params,new PageBounds(queryBillBean.getPage(),queryBillBean.getLimit(), Order.formString("create_time.desc"))); List<JSONObject> bills = directedBillCodeMapper.findByClientId(params,new PageBounds(queryBillBean.getPage(),queryBillBean.getLimit(), Order.formString("create_time.desc")));
bills.stream().filter(t->StringUtils.isNotEmpty(t.getString("code_url"))).forEach(t->t.put("code_url",QRCodeUtils.qrcodeImageCode(t.getString("code_url"), 250, false))); // bills.stream().filter(t->StringUtils.isNotEmpty(t.getString("code_url"))).forEach(t->t.put("code_url",QRCodeUtils.qrcodeImageCode(t.getString("code_url"), 250, false)));
for (JSONObject bill : bills) {
switch (client.getString("billcode_version")){
case "v1":
bill.put("code_urls",bill.getString("code_url"));
break;
case "v2":
bill.put("code_urls", PlatformEnvironment.getEnv().concatUrl("api/v1.0/share_code/business/bills/"+bill.getString("bill_code_id")+"/link/payment"));
break;
}
bill.put("code_url",QRCodeUtils.qrcodeImageCode(bill.getString("code_urls"), 250, false));
}
return bills; return bills;
} }

@ -573,4 +573,7 @@ public interface ClientManager {
RPayMerchantEntity queryMWMerchantIdStatus(String clientMoniker, JSONObject manager); RPayMerchantEntity queryMWMerchantIdStatus(String clientMoniker, JSONObject manager);
RPayMerchantEntity queryMWMerchantInfo(String clientMoniker, JSONObject manager); RPayMerchantEntity queryMWMerchantInfo(String clientMoniker, JSONObject manager);
void selectBillCodeVersion(JSONObject manager, String clientMoniker, String version);
} }

@ -6881,4 +6881,15 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
return true; return true;
} }
@Override
public void selectBillCodeVersion(JSONObject manager, String clientMoniker, String version){
JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) {
throw new InvalidShortIdException();
}
client.put("billcode_version", version);
clientMapper.update(client);
clientInfoCacheSupport.clearClientCache(client.getIntValue("client_id"));
}
} }

@ -299,6 +299,11 @@ public class PartnerManageController {
clientManager.switchPermission(manager, clientMoniker, "common_sub_merchant_id", pass.getBooleanValue("allow")); clientManager.switchPermission(manager, clientMoniker, "common_sub_merchant_id", pass.getBooleanValue("allow"));
} }
@ManagerMapping(value = "/{clientMoniker}/selectBillVersion", method = RequestMethod.POST, role = {ManagerRole.OPERATOR, ManagerRole.BD_USER})
public void selectBillVersion(@PathVariable String clientMoniker, @RequestBody JSONObject pass, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
clientManager.selectBillCodeVersion(manager, clientMoniker, pass.getString("version"));
}
/** /**
* *
* *

@ -2487,6 +2487,21 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter
}) })
}; };
$scope.changeBillCodeVersion = function() {
if (!$scope.paymentInfo) {
return;
}
$http.post('/sys/partners/' + $scope.partner.client_moniker + '/selectBillVersion', {version: $scope.paymentInfo.billcode_version}).then(function () {
$scope.loadPartnerPaymentInfo();
}, function (resp) {
commonDialog.alert({
title: 'failed to change require bill version permission status',
content: resp.data.message,
type: 'error'
})
})
};
$scope.extChangeParam = function(name,value){ $scope.extChangeParam = function(name,value){
var flag = true; var flag = true;
$scope.convertExtParams.forEach(function (params) { $scope.convertExtParams.forEach(function (params) {

@ -604,6 +604,16 @@
switch-change="toggleRequireRemark()"> switch-change="toggleRequireRemark()">
</div> </div>
</div> </div>
<div class="form-group" ng-if="'1000000000111'|withRole">
<label class="col-sm-2 control-label">Bill Code Version</label>
<div class="col-sm-2">
<select class="form-control" ng-change="changeBillCodeVersion()" ng-model="paymentInfo.billcode_version"
title="Payment Page">
<option value="v1">v1</option>
<option value="v2">v2</option>
</select>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>

@ -0,0 +1,47 @@
.commit-button{
width: 100%;
border-radius: 25px;
background-color: #ED2424;
color: #FFFFFF;
font-size: 16px;
line-height: 40px;
border: 0px;
margin-top: 20px;
}
label{
color: #9B9B9B;
margin-bottom: 0px;
}
.bill-info-right{
float: right;
}
.margin-body{
margin: 15px
}
.row-line-height{
height: 20px;
margin: 15px 0px 15px -15px;
}
.row-line-height-plus{
height: 60px;
line-height: 60px;
}
.border-top-line{
border-top: 1px solid #EEEEEE
}
.border-button-line{
border-bottom: 1px solid #EEEEEE;
}
#timer{
font-weight: 600;
color: #ED2424;
}

@ -0,0 +1,129 @@
body{
padding: 3% 10%;
width: 100%;
height: 100%;
margin: 0;
}
.head{
padding-bottom: 20px;
border-bottom: 2px solid #DCDCDC;
}
.pc-cash{
font-size: 28px;
position: absolute;
margin: 15px;
}
.order-box{
text-align: center;
}
.count-down{
text-align: center;
font-size: 20px;
margin: 20px;
line-height: 97px;
background-color: #FEF4F4;
}
label{
color: #ED2424;
font-size: 20px;
margin-bottom: 0px;
}
.bill-info-right{
float: right;
font-size: 20px;
font-weight: 800;
}
.margin-body{
margin: 15px
}
.row-line-height{
height: 20px;
margin: 15px 0px 15px -15px;
}
.row-line-height-plus{
height: 60px;
line-height: 60px;
}
.border-top-line{
border-top: 1px solid #EEEEEE
}
.border-button-line{
border-bottom: 1px solid #EEEEEE;
padding: 20px 5px;
}
#timer{
font-weight: 600;
color: #ED2424;
}
.info-body{
background-color: #FEF4F4;
height: 650px;
margin-top: 20px;
border-radius: 10px 10px 0px 0px;
}
.info-body-title{
background: #ED2424;
line-height: 50px;
font-size: 25px;
color: #FFF;
border-radius: 10px 10px 0px 0px;
}
.pay-fun{
font-family: PingFang-SC-Bold;
font-size: 20px;
color: #ED2424;
font-weight: 600;
margin: 50px;
}
#commit-btn{
width: 30%;
border-radius: 5px;
background-color: #ED2424;
color: #FFFFFF;
font-size: 16px;
line-height: 40px;
border: 0px;
margin: 100px 0px;
text-align: center;
}
.select-pay-fun{
text-align: center;
width: 80%;
height: 120% ;
border: 1px solid #ED2424;
padding: 10px 0px;
margin-top: 5px;
}
.no-select-pay-fun{
text-align: center;
width: 80%;
height: 120% ;
border: 1px solid #EAEAEA;
padding: 10px 0px;
margin: 5px 0px 5px 0px;
}
#qrImg{
margin-top: 40px;
}
.img-size{
height: 58px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 559 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 17.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="304.5px" height="63.5px" viewBox="0 0 304.5 63.5" enable-background="new 0 0 304.5 63.5" xml:space="preserve">
<g>
<path fill="#ED6B2C" d="M28.416,39.902"/>
</g>
<path fill="#ED6B2C" d="M48.971,50.572c0-3.301-2.532-6.009-5.758-6.29l-7.385-15.836c-0.144-0.309-0.044-0.674,0.234-0.871
c2.709-1.91,4.48-5.06,4.48-8.626c0-5.817-4.711-10.535-10.525-10.544h-0.019c-0.033,0-0.066,0.002-0.098,0.002V8.405h-11.83
c-0.388,0-0.703,0.315-0.703,0.703v4.919c0,0.388,0.315,0.703,0.703,0.703H29.9v0h0.018c2.288,0,4.236,1.779,4.318,4.065
c0.085,2.401-1.837,4.375-4.219,4.375H6.825V6.794c0-0.259-0.21-0.469-0.469-0.469H5.185C2.598,6.325,0.5,8.423,0.5,11.01v38.214
c0,0.049,0.002,0.096,0.003,0.144C0.502,49.415,0.5,49.461,0.5,49.508c0,3.718,2.748,6.794,6.325,7.304
c0.344,0.049,0.696,0.075,1.054,0.075c0.358,0,0.71-0.026,1.054-0.075c2.213-0.316,4.107-1.614,5.231-3.437
c0.693-1.111,1.094-2.419,1.094-3.82V37.948H29.9v-0.002c0.003,0,0.006,0,0.009,0c0.4,0.003,0.664-0.418,0.495-0.781l-2.392-5.136
c-0.115-0.248-0.364-0.406-0.637-0.406H9.636c-0.388,0-0.703,0.315-0.703,0.703v0.001l0,17.139c0,0.551-0.404,1.042-0.953,1.093
c-0.629,0.058-1.156-0.433-1.156-1.049V29.496h22.067c0.273,0,0.522,0.158,0.637,0.406l7.951,17.051
c-0.719,1.026-1.141,2.272-1.141,3.619c0,3.301,2.532,6.009,5.76,6.29l0.002,0.005l0.007-0.005c0.18,0.016,0.361,0.026,0.546,0.026
c2.139,0,4.027-1.064,5.17-2.689l0.009-0.005l-0.002-0.005C48.549,53.163,48.971,51.917,48.971,50.572z"/>
<path fill="#ED6B2C" d="M8.933,20.38V4.685C8.933,2.098,11.031,0,13.619,0h16.398c10.621,0.009,19.198,8.747,18.949,19.429
c-0.139,5.878-2.994,11.102-7.332,14.487c-0.282,0.22-0.696,0.122-0.847-0.202l-2.242-4.806c-0.127-0.272-0.069-0.597,0.15-0.803
c2.402-2.257,3.925-5.427,3.972-8.962c0.091-7.063-5.608-12.819-12.65-12.819H15.853c-0.329,0-0.595,0.266-0.595,0.595v13.46
c0,0.388-0.315,0.703-0.703,0.703H9.636C9.247,21.083,8.933,20.767,8.933,20.38z"/>
<g>
<path fill="#ED6B2C" d="M336.166,39.902"/>
</g>
<path fill="#ED6B2C" d="M84.512,25.763c-0.117-0.199-0.237-0.396-0.361-0.59c-0.78-1.075-2.047-1.776-3.476-1.776
c-2.373,0-4.296,1.923-4.296,4.294c0,0.792,0.213,1.534,0.59,2.172c0.021,0.037,0.047,0.077,0.07,0.117
c0.832,1.394,1.312,3.027,1.312,4.77c0,5.144-4.17,9.314-9.312,9.314c-5.144,0-9.314-4.17-9.314-9.314
c0-5.142,4.17-9.312,9.314-9.312c0.295,0,0.586,0.014,0.874,0.042c0.166,0.014,0.33,0.033,0.492,0.059
c0.084,0.005,0.169,0.007,0.255,0.007c2.371,0,4.294-1.923,4.294-4.296c0-2.071-1.466-3.8-3.418-4.205c-0.002,0-0.007,0-0.012-0.002
c-0.23-0.033-0.461-0.059-0.696-0.082c-0.588-0.059-1.185-0.089-1.79-0.089c-9.888,0-17.902,8.016-17.902,17.902
s8.014,17.902,17.902,17.902c9.886,0,17.902-8.016,17.902-17.902C86.942,31.488,86.056,28.41,84.512,25.763z"/>
<path fill="#ED6B2C" d="M115.331,17.272l-9.279,21.534l-9.33-21.536c-0.111-0.257-0.365-0.423-0.645-0.423h-7.493
c-0.337,0-0.564,0.345-0.43,0.655l13.655,30.979h0.073l-2.078,4.822c-0.393,0.912-1.291,1.503-2.284,1.503h-4.501
c-0.388,0-0.703,0.315-0.703,0.703v7.028c0,0.388,0.315,0.703,0.703,0.703h4.947c3.635,0,6.921-2.162,8.36-5.501L123.9,17.502
c0.133-0.309-0.094-0.654-0.43-0.654h-7.493C115.696,16.848,115.442,17.015,115.331,17.272z"/>
<path fill="#ED6B2C" d="M158.638,44.233V17.478c0-0.388-0.315-0.703-0.703-0.703h-15.11c-9.943,0-17.994,8.097-17.92,18.057
c0.073,9.881,8.264,17.785,18.145,17.785h0.844c2.319,0,4.199-1.88,4.199-4.199v0c0-2.319-1.88-4.199-4.199-4.199h-0.902
c-5.252,0-9.688-4.296-9.655-9.548c0.016-2.595,1.074-4.945,2.778-6.649c1.717-1.717,4.088-2.778,6.709-2.778h7.377v21.8
c0,3.105,2.517,5.622,5.622,5.622h4.45c0.259,0,0.469-0.21,0.469-0.469v-7.496c0-0.259-0.21-0.469-0.469-0.469H158.638z"/>
<path fill="#ED6B2C" d="M158.622,44.255"/>
<path fill="#ED6B2C" d="M175.502,44.233V4.87c0-0.388-0.315-0.703-0.703-0.703h-7.028c-0.388,0-0.703,0.315-0.703,0.703v39.363
v2.808c0,3.103,2.515,5.62,5.618,5.622l4.221,0.003c0.388,0,0.703-0.315,0.703-0.703v-7.028c0-0.388-0.315-0.703-0.703-0.703
H175.502z"/>
<path fill="#ED6B2C" d="M183.972,9.094v42.869c0,0.388,0.315,0.703,0.703,0.703h7.028c0.388,0,0.703-0.315,0.703-0.703V17.645
c0-0.388,0.315-0.703,0.703-0.703h13.109c4.011,0,7.262,3.251,7.262,7.262v0c0,4.011-3.251,7.262-7.262,7.262h-5.329
c-2.361,0-4.275,1.914-4.275,4.275v0c0,2.361,1.914,4.275,4.275,4.275h5.212c8.733,0,15.813-7.079,15.813-15.813v0
c0-8.733-7.079-15.813-15.813-15.813h-21.425C184.287,8.391,183.972,8.706,183.972,9.094z"/>
<path fill="#ED6B2C" d="M259.848,44.233V17.478c0-0.388-0.315-0.703-0.703-0.703h-15.11c-9.943,0-17.994,8.097-17.92,18.057
c0.073,9.881,8.264,17.785,18.145,17.785h0.844c2.319,0,4.199-1.88,4.199-4.199v0c0-2.319-1.88-4.199-4.199-4.199h-0.902
c-5.252,0-9.688-4.296-9.655-9.548c0.016-2.595,1.074-4.945,2.778-6.649c1.717-1.717,4.088-2.778,6.709-2.778h7.377v21.8
c0,3.105,2.517,5.622,5.622,5.622h4.45c0.259,0,0.469-0.21,0.469-0.469v-7.496c0-0.259-0.21-0.469-0.469-0.469H259.848z"/>
<path fill="#ED6B2C" d="M295.507,17.236l-9.279,21.534l-9.33-21.536c-0.111-0.257-0.365-0.423-0.645-0.423h-7.493
c-0.337,0-0.564,0.345-0.43,0.655l13.655,30.979h0.073l-2.078,4.822c-0.393,0.912-1.291,1.503-2.284,1.503h-4.501
c-0.388,0-0.703,0.315-0.703,0.703V62.5c0,0.388,0.315,0.703,0.703,0.703h4.947c3.635,0,6.921-2.162,8.36-5.501l17.573-40.237
c0.133-0.309-0.094-0.654-0.43-0.654h-7.493C295.871,16.811,295.618,16.978,295.507,17.236z"/>
</svg>

After

Width:  |  Height:  |  Size: 5.5 KiB

@ -0,0 +1,252 @@
/**
* Created by dulingling on 2020-03-25.
*/
$(document).ready(function () {
var paymentFun = '';
var selectPaymentHTML = " <img src='/static/templates/billCode/img/bill_select.png'>";
var maxtime = window.maxtime;
var hasPayment =true;//可支付
if(window.openmobilefun == 'wechat'|| window.openmobilefun == 'other'){
paymentFun = 'Wechat'
}else{
paymentFun = 'Alipay'
$(".select_wechat").empty();
$(".select_alipay").append(selectPaymentHTML);
$(".select_bank").empty();
}
setInterval(function(){
if(maxtime>0){
var countdown=document.getElementById("timer");
maxtime=maxtime-1;
var minute=parseInt(maxtime/60);
var second=parseInt(maxtime%60);
countdown.innerHTML=minute+'分'+second+'秒';
}else{
$('#commit-btn').css({"background-color":"#eee",});
hasPayment = false;
}
},1000);
$("#select_wechat").click(function(){
if(paymentFun != 'Wechat'){
paymentFun = 'Wechat'
$(".select_wechat").append(selectPaymentHTML);
$(".select_alipay").empty();
$(".select_bank").empty();
}
})
$("#select_alipay").click(function(){
if(paymentFun != 'Alipay'){
paymentFun = 'Alipay'
$(".select_wechat").empty();
$(".select_alipay").append(selectPaymentHTML);
$(".select_bank").empty();
}
})
$("#select_bank").click(function(){
if(paymentFun != 'Bank'){
paymentFun = 'Bank'
$(".select_wechat").empty();
$(".select_alipay").empty();
$(".select_bank").append(selectPaymentHTML);
}
})
$("#commit-btn").click(function () {
if(hasPayment){
if(window.openmobilefun != 'other'){
appPayment()
}
}
})
function appPayment(){
var payUrl = getShareLink();
$("#commit-btn").css({"background-color":"#eee",});
$("#commit-btn").val("订单创建中...");
hasPayment = false;
$.ajax({
url: payUrl,
method: 'get',
contentType: 'application/json',
dataType: 'json',
success: function (res) {
if(paymentFun == 'Wechat'){
if( window.openmobilefun == 'wechat'){
invokePay(res.order_id,res.jsapi);
}else{
redirectH5Payment(res.partner_order_id,res.client_moniker)
}
}
if(paymentFun == 'Alipay'){
if(window.openmobilefun == 'alipay'){
callPayment(res);
}else{
redirectH5Payment(res.partner_order_id,res.client_moniker)
}
}
if(paymentFun == 'Bank'){
cbbankPayment(res);
}
},
error: function (jqXHR) {
alert(jqXHR.responseJSON.message);
$("#commit-btn").css({"background-color":"#ED2424",});
$("#commit-btn").val("支付");
if(maxtime>0){
hasPayment = true;
}else{
hasPayment = false;
}
}
})
}
function redirectH5Payment(orderId,clientMoniker){
window.location.href='/api/v1.0/share_code/business/bills/'+clientMoniker+'/orders/'+orderId+'/pay';
}
function getShareLink(){
var paymentLink = ''
if(window.sharetype != 'app'){
//PC端扫码访问
if(paymentFun == 'Wechat'){
if(window.openmobilefun == 'wechat'){
paymentLink = '/api/v1.0/share_code/business/bills/'+window.billInfo.bill_code_id+'/wechat/mobile';
}else{
paymentLink = '/api/v1.0/share_code/business/bills/'+window.billInfo.bill_code_id+'/alipay/mobile/redirectApp?priorityChannel=Wechat';
}
}
if(paymentFun == 'Alipay'){
if(window.openmobilefun == 'alipay'){
paymentLink = '/api/v1.0/share_code/business/bills/'+window.billInfo.bill_code_id+'/alipay/mobile';
}else{
paymentLink = '/api/v1.0/share_code/business/bills/'+window.billInfo.bill_code_id+'/alipay/mobile/redirectApp?priorityChannel=Alipay';
}
}
if(paymentFun == 'Bank'){
paymentLink = '/api/v1.0/share_code/business/bills/'+window.billInfo.bill_code_id+'/cbbank/mobile?partner_moniker='+window.clientmoniker;
}
}else{
//app扫码访问
if(paymentFun == 'Wechat'){
if(window.openmobilefun == 'wechat'){
paymentLink = '/api/v1.0/share_code/bills/payment/orders/'+window.billInfo.bill_code_id+'/wechat/share_link';
}else{
paymentLink = '/api/v1.0/share_code/bills/payment/'+window.billInfo.bill_code_id+'/alipay/mobile/redirectApp?priorityChannel=Wechat';
}
}
if(paymentFun == 'Alipay'){
if(window.openmobilefun == 'alipay'){
paymentLink = '/api/v1.0/share_code/bills/payment/orders/'+window.billInfo.bill_code_id+'/alipay/share_link'
}else{
paymentLink = '/api/v1.0/share_code/bills/payment/'+window.billInfo.bill_code_id+'/alipay/mobile/redirectApp?priorityChannel=Alipay';
}
}
if(paymentFun == 'Bank'){
paymentLink = '/api/v1.0/share_code/bills/payment/orders/'+window.billInfo.bill_code_id+'/cbbank/share_link?partner_moniker='+window.clientmoniker;
}
}
return paymentLink;
}
//微信支付方式
function invokePay(orderId,paydata) {
WeixinJSBridge.invoke('getBrandWCPayRequest', {
'appId': paydata.appId,
'timeStamp': paydata.timeStamp,
'nonceStr': paydata.nonceStr,
'package': paydata.package,
'signType': paydata.signType,
'paySign': paydata.paySign
}, function (res) {
var redirect = "/api/payment/v1.0/wechat_jsapi_payment/partners/" + window.clientmoniker + "/orders/" + orderId+"?";
if (res.err_msg == 'get_brand_wcpay_request:ok') {
startCheckOrder(orderId,redirect + (redirect.indexOf('?') < 0 ? '?' : '&') + 'success=true')
} else {
if (res.err_msg == 'get_brand_wcpay_request:cancel') {
hasPayment = true;
$("#commit-btn").css({"background-color":"#ED2424",});
$("#commit-btn").val("支付");
}
if( res.err_msg == 'get_brand_wcpay_request:fail'){
hasPayment = true;
$("#commit-btn").css({"background-color":"#ED2424",});
$("#commit-btn").val("支付");
location.href = redirect + (redirect.indexOf('?') < 0 ? '?' : '&') + 'success=false';
}
}
})
}
//支付宝支付方式
function callPayment(paydata) {
try {
if(typeof paydata.trade_no == 'undefined'){
window.location.href = paydata.mweb_url
}else {
AlipayJSBridge.call('tradePay', {
tradeNO: paydata.trade_no
}, function (res) {
if (res.resultCode == '9000') {
AlipayJSBridge.call('startApp', {
appId: '20000056',
param: {
actionType: 'showSuccPage',
payResult: res.result
},
closeCurrentApp: false
});
startCheckOrder(paydata.order_id, '/api/v1.0/alipay_direct/partners/' + window.clientmoniker + '/orders/' + paydata.order_id + '/result');
} else {
hasPayment = true;
$("#commit-btn").css({"background-color": "#ED2424",});
$("#commit-btn").val("支付");
}
})
}
} catch (err) {
alert(err);
$('#wdiv').hide();
}
}
//银联支付方式
function cbbankPayment(res){
if('SUCCESS' !== res.return_code && typeof res.return_code !== 'undefined'){
$("#commit-btn").css({"background-color":"#ED2424",});
if(maxtime>0){
hasPayment = true;
}else{
hasPayment = false;
}
}else {
location.href = res.pay_url;
}
}
//调用查询订单状态方法
function startCheckOrder(orderId, url) {
function checkOrderStd() {
$.ajax({
url: '/api/v1.0/payment/orders/' + orderId + '/status',
method: 'GET',
dataType: 'json',
success: function (res) {
if (res.paid) {
location.href = url;
} else {
setTimeout(checkOrderStd, 500);
}
}
})
}
checkOrderStd();
}
});

@ -0,0 +1,159 @@
/**
* Created by dulingling on 2020-03-25.
*/
$(document).ready(function () {
var paymentFun = 'Wechat';
var maxtime = window.maxtime;
var hasPayment =true;//可支付
if(document.documentElement.clientWidth<500){
$('.img-size').css({"height":"28px",})
}
if(window.clientInfo.enable_wechat){
var paymentFun = 'Wechat';
showQRcode();
}else if(window.clientInfo.enable_alipay){
var paymentFun = 'Alipay';
showQRcode();
}else if(window.clientInfo.enable_cb_bankpay){
var paymentFun = 'Bank';
showQRcode();
}
startCheckOrder();
setInterval(function(){
if(maxtime>0){
var countdown=document.getElementById("timer");
maxtime=maxtime-1;
var minute=parseInt(maxtime/60);
var second=parseInt(maxtime%60);
countdown.innerHTML=minute+'分'+second+'秒';
}else{
hasPayment = false;
$('#qrImg').empty();
}
},1000);
$("#select_wechat").click(function(){
if(paymentFun != 'Wechat'){
paymentFun = 'Wechat'
$("#select_wechat").removeClass("no-select-pay-fun").addClass("select-pay-fun");
$("#select_alipay").removeClass("select-pay-fun").addClass("no-select-pay-fun");
$("#select_bank").removeClass("select-pay-fun").addClass("no-select-pay-fun");
showQRcode();
}
})
$("#select_alipay").click(function(){
if(paymentFun != 'Alipay'){
paymentFun = 'Alipay'
$("#select_wechat").removeClass("select-pay-fun").addClass("no-select-pay-fun");
$("#select_alipay").removeClass("no-select-pay-fun").addClass("select-pay-fun");
$("#select_bank").removeClass("select-pay-fun").addClass("no-select-pay-fun");
showQRcode();
}
})
$("#select_bank").click(function(){
if(paymentFun != 'Bank'){
paymentFun = 'Bank'
$("#select_wechat").removeClass("select-pay-fun").addClass("no-select-pay-fun");
$("#select_alipay").removeClass("select-pay-fun").addClass("no-select-pay-fun");
$("#select_bank").removeClass("no-select-pay-fun").addClass("select-pay-fun");
showQRcode();
}
})
function showQRcode() {
if (hasPayment) {
var payUrl = '';
var orderId = window.clientmoniker + dateFormat() + String(Math.random()).substring(2, 8).toUpperCase();
var channelName = paymentFun == 'Wechat' ? '微信' : '支付宝'
if (paymentFun == 'Wechat') {
$('#qrImg').empty();
document.getElementById("qrImg").style.display = 'block';
var selectPaymentHTML =
"<p style='font-size: 20px;font-weight: 800'>请使用" + channelName + "客户端扫码支付</p>" +
"<img src='" + window.wechatqrcode + "'>";
$('#qrImg').append(selectPaymentHTML)
} else if (paymentFun == 'Alipay') {
$('#qrImg').empty();
document.getElementById("qrImg").style.display = 'block';
var selectPaymentHTML =
"<p style='font-size: 20px;font-weight: 800'>请使用" + channelName + "客户端扫码支付</p>" +
"<img src='" + window.alipayqrcode + "'>";
$('#qrImg').append(selectPaymentHTML)
} else if (paymentFun == 'Bank') {
$('#qrImg').empty();
document.getElementById("qrImg").style.display = 'block';
if( hasPayment){
createCBBankOrder();
}
}
}
}
function createCBBankOrder() {
$.ajax({
url: window.cbbankpaymentlink,
method: 'get',
contentType: 'application/json',
dataType: 'json',
success: function (res) {
cbbankPayment(res);
},
error: function (jqXHR) {
alert(jqXHR.responseJSON.message);
if(maxtime>0){
hasPayment = true;
}else{
hasPayment = false;
}
}
})
}
function cbbankPayment(res){
if('SUCCESS' !== res.return_code && typeof res.return_code !== 'undefined'){
}else {
location.href = res.pay_url;
}
}
//做个每5秒查询查询一次订单状态
function startCheckOrder(orderId) {
//通知URL
function checkOrderStd() {
$.ajax({
url: '/api/v1.0/payment/billOrder/' + window.billInfo.client_order_id + '/status',
method: 'GET',
dataType: 'json',
success: function (res) {
if (res.paid) {
location.href = res.redirect;
} else {
setTimeout(checkOrderStd, 500);
}
}
})
}
checkOrderStd();
}
function dateFormat() {
var date = new Date();
var formatTimeStr = '';
formatTimeStr += date.getFullYear();
formatTimeStr += date.getMonth()+1;
formatTimeStr += date.getDate();
formatTimeStr += date.getHours();
formatTimeStr += date.getMinutes();
formatTimeStr += date.getSeconds();
return formatTimeStr;
}
});
Loading…
Cancel
Save