Merge pull request !172 from Admin/sit-Carl
This commit is contained in:
Admin 2022-02-15 08:16:21 +00:00 committed by Gitee
commit 9372334f54
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
23 changed files with 755 additions and 162 deletions

View File

@ -662,7 +662,19 @@ export const getOrderList = (user, status) => {
//支付宝支付二维码 //支付宝支付二维码
export const generateOrderAlipay = (data) => { export const generateOrderAlipay = (orderNo, payType) => {
return fetch('generateOrderAlipay', data, 'POST' ) //Dictionary : 1: PC, 2: Mobile
let url = 'generateOrderAlipayPC';
if(payType == 2) {
url = 'generateOrderAlipayPhone'
}
var data = {
//orderNo:orderNo
}
url = url+"?orderNo="+orderNo;
return fetch(url, data, 'POST')
//let ret = { "code": 1, "msg": "操作成功!", "success": true, "data": "<form name=\"punchout_form\" method=\"post\" action=\"https://openapi.alipay.com/gateway.do?charset=utf-8&method=alipay.trade.wap.pay&sign=GK1NjnOYPh%2BHTcTtuZg4YunsBNGPHiyc9BwXLx%2FG4G6Z7S8ILYy2E6VmxkGVwZEwZ1G5PA3u2eZxJN3ysyynL9uwG7L4jGQcOB6I2m1763VBi7euNiyMhimv5AYeXP4KiDtmZNDIAdyi3eKWemKTq74AfS0TTubYvKL8aqhJHTQy2GtYdXA89v53ZeFkXjoqpylwCf2j%2FJWD1nV1eO0a0PB5MFqPaZB5Eif69XkT1TNAt1eZiwIn4AO6yqMFJ41gGN5ymmLQUVcUgc5dxlGkMNgY4FUsI6mFYucQ%2BRPPmuH78YJTFU6VS5E%2BZ%2BCL%2BGLxeJs068n%2BLAPqpPqDbhveYg%3D%3D&return_url=https%3A%2F%2Fshop.royalcanin.com.cn&notify_url=https%3A%2F%2Fshop.royalcanin.com.cn%2Froyalcanin%2Froyalcanin%2Froyalcanin%2FupdateOrderAliPay&version=1.0&app_id=2021003108690157&sign_type=RSA2&timestamp=2022-02-14+15%3A08%3A05&alipay_sdk=alipay-sdk-java-dynamicVersionNo&format=json\">\n<input type=\"hidden\" name=\"biz_content\" value=\"{&quot;out_trade_no&quot;:&quot;02110014172230000&quot;,&quot;total_amount&quot;:&quot;138.0&quot;,&quot;subject&quot;:&quot;皇家宠物食品官方商城&quot;}\">\n<input type=\"submit\" value=\"立即支付\" style=\"display:none\" >\n</form>\n<script>document.forms[0].submit();</script>" };
//ret = JSON.parse(ret);
//return ret;
} }

View File

@ -63,7 +63,8 @@ export default {
//this.customerServerStop = true; //this.customerServerStop = true;
/* Stop until 2022-2-10 */ /* Stop until 2022-2-10 */
var option = { var option = {
customer: {id: '', name: '', email: '', mobile: '', memberId: curMemberId} customer: {id: '', name: '', email: '', mobile: '', memberId: curMemberId, types:'14054'},
type:3
} }
dis_livchat(option); dis_livchat(option);
_hmt.push([ _hmt.push([
@ -91,7 +92,8 @@ export default {
//this.customerServerStop = true; //this.customerServerStop = true;
/* Stop until 2022-2-10*/ /* Stop until 2022-2-10*/
var option = { var option = {
customer: {id: '', name: '', email: '', mobile: '', memberId: curMemberId} customer: {id: '', name: '', email: '', mobile: '', memberId: curMemberId, types:'14053'},
type:3
} }
dis_livchat(option); dis_livchat(option);
_hmt.push([ _hmt.push([

View File

@ -343,6 +343,84 @@ let devData={
], ],
}, },
] ]
},
rxgoods:{
dog:[
{
title: "皇家成犬肠道全价处方粮",
productimage: "/images/rxgoods/dog-1.png",
detail: "帮助维持消化系统健康 满足爱宠能量需求 满足爱宠食欲减退",
ecPrice: "",
productCode:'30',
productList: [
{
productCode: "30",
},
],
},
{
title: "皇家成犬泌尿道全价处方粮",
productimage: "/images/rxgoods/dog-2.png",
detail: "高品质高易消化蛋白质 优化尿液PH值和 尿液离子浓度",
ecPrice: "",
productCode:'23',
productList: [
{
productCode: "23",
},
],
},
{
title: "皇家成犬皮肤全价处方粮",
productimage: "/images/rxgoods/dog-3.png",
detail: "抗氧化复合物协同作用帮助中和自由基 添加必须脂肪酸EPA和DHA 帮助维持肠道菌群支持消化系统健康",
ecPrice: "",
productCode:'27',
productList: [
{
productCode: "27",
},
],
},
],
cat:[
{
title: "皇家成猫泌尿道全价处方粮",
productimage: "/images/rxgoods/cat-1.png",
detail: "控制镁、钙及磷含量 促进尿液达到理想离子浓度及PH值 有助于猫咪适应环境带来的新挑战",
ecPrice: "",
productCode:'5',
productList: [
{
productCode: "5",
},
],
},
{
title: "皇家成猫肠道全价处方粮",
productimage: "/images/rxgoods/cat-2.png",
detail: "高易消化成分配以均衡的电解质 含有EPA、DHA、维生素E支持消化健康 益生元帮助促进肠道菌群平衡",
ecPrice: "",
productCode:'12',
productList: [
{
productCode: "12",
},
],
},
{
title: "皇家成猫皮肤被毛全价处方粮",
productimage: "/images/rxgoods/cat-3.png",
detail: "添加皮肤屏障复合物 添加必须脂肪酸EPA和DHA 帮助减少鸟粪石和草酸钙结石形成",
ecPrice: "",
productCode:'8',
productList: [
{
productCode: "8",
},
],
},
]
} }
}; };
@ -693,6 +771,84 @@ let prdData={
], ],
}, },
] ]
},
rxgoods:{
dog:[
{
title: "皇家成犬肠道全价处方粮",
productimage: "/images/rxgoods/dog-1.png",
detail: "帮助维持消化系统健康 满足爱宠能量需求 满足爱宠食欲减退",
ecPrice: "",
productCode:'30',
productList: [
{
productCode: "30",
},
],
},
{
title: "皇家成犬泌尿道全价处方粮",
productimage: "/images/rxgoods/dog-2.png",
detail: "高品质高易消化蛋白质 优化尿液PH值和 尿液离子浓度",
ecPrice: "",
productCode:'23',
productList: [
{
productCode: "23",
},
],
},
{
title: "皇家成犬皮肤全价处方粮",
productimage: "/images/rxgoods/dog-3.png",
detail: "抗氧化复合物协同作用帮助中和自由基 添加必须脂肪酸EPA和DHA 帮助维持肠道菌群支持消化系统健康",
ecPrice: "",
productCode:'27',
productList: [
{
productCode: "27",
},
],
},
],
cat:[
{
title: "皇家成猫泌尿道全价处方粮",
productimage: "/images/rxgoods/cat-1.png",
detail: "控制镁、钙及磷含量 促进尿液达到理想离子浓度及PH值 有助于猫咪适应环境带来的新挑战",
ecPrice: "",
productCode:'5',
productList: [
{
productCode: "5",
},
],
},
{
title: "皇家成猫肠道全价处方粮",
productimage: "/images/rxgoods/cat-2.png",
detail: "高易消化成分配以均衡的电解质 含有EPA、DHA、维生素E支持消化健康 益生元帮助促进肠道菌群平衡",
ecPrice: "",
productCode:'12',
productList: [
{
productCode: "12",
},
],
},
{
title: "皇家成猫皮肤被毛全价处方粮",
productimage: "/images/rxgoods/cat-3.png",
detail: "添加皮肤屏障复合物 添加必须脂肪酸EPA和DHA 帮助减少鸟粪石和草酸钙结石形成",
ecPrice: "",
productCode:'8',
productList: [
{
productCode: "8",
},
],
},
]
} }
}; };
//Production data end //Production data end

View File

@ -2,8 +2,8 @@ const trackingScript = 'var dataLayer = window.dataLayer = window.dataLayer || [
const assetsUrl = 'var assetsUrl="/royalcanin-cdn-assets-new/css_js/";var isInitialized=false;'; const assetsUrl = 'var assetsUrl="/royalcanin-cdn-assets-new/css_js/";var isInitialized=false;';
export default { export default {
env: { env: {
//NODE_ENV: 'development' NODE_ENV: 'development'
NODE_ENV: 'production' //NODE_ENV: 'production'
}, },
// Global page headers: https://go.nuxtjs.dev/config-head // Global page headers: https://go.nuxtjs.dev/config-head
head: { head: {
@ -15,8 +15,8 @@ export default {
script: [ script: [
//{ src: '/js/rem.js' }, //{ src: '/js/rem.js' },
// { src: '/js/flexible.js', type: 'text/javascript', charset: 'utf-8'}, // { src: '/js/flexible.js', type: 'text/javascript', charset: 'utf-8'},
//{ src: 'https://ocstest.royalcanin.com.cn:8081/livechat/chatapp/customer/branch/RoyalCanin/14053/index.js' }, { src: 'https://ocstest.royalcanin.com.cn:8081/livechat/chatapp/customer/branch/RoyalCanin/14054/index.js' },
{ src: 'https://ocs.royalcanin.com.cn:8081/livechat/chatapp/customer/branch/RoyalCanin/14053/index.js' }, //{ src: 'https://ocs.royalcanin.com.cn:8081/livechat/chatapp/customer/branch/RoyalCanin/14053/index.js' },
//{ src: 'https://ocstest.royalcanin.com.cn:8081/livechat/chatapp/customer/branch/RoyalCanin/14054/index.js' }, //{ src: 'https://ocstest.royalcanin.com.cn:8081/livechat/chatapp/customer/branch/RoyalCanin/14054/index.js' },
{ innerHTML: trackingScript, type: 'text/javascript', charset: 'utf-8'}, { innerHTML: trackingScript, type: 'text/javascript', charset: 'utf-8'},
{ innerHTML: assetsUrl, type: 'text/javascript', charset: 'utf-8'}, { innerHTML: assetsUrl, type: 'text/javascript', charset: 'utf-8'},

View File

@ -296,6 +296,8 @@ export default {
return this.sumPrice * ( 1 - this.curCoupon.discount ); return this.sumPrice * ( 1 - this.curCoupon.discount );
} }
} else { } else {
this.discountAmount = 0;
this.curCoupon = {couponName:'未能使用该优惠券'};
return this.sumPrice; return this.sumPrice;
} }
}, },

View File

@ -93,10 +93,7 @@
<p>请返回商品结算页面重新支付</p> <p>请返回商品结算页面重新支付</p>
</div> </div>
</el-dialog> </el-dialog>
<div style="display:none"> <div style="display:none" ref="h5SubmitForm">
<form :action="this.h5PayUrl" method="post" ref="h5SubmitForm">
<input type="hidden" v-model="h5payRedirectUrl">
</form>
</div> </div>
</div> </div>
</template> </template>
@ -114,7 +111,6 @@ export default {
data() { data() {
return { return {
util, util,
h5payRedirectUrl:'',
activeIndex: 0, activeIndex: 0,
paymentTimer:undefined, paymentTimer:undefined,
isSucess: false, isSucess: false,
@ -148,28 +144,44 @@ export default {
}, },
mounted() { mounted() {
let isWx = this.util.isWX();
if(!isWx) {
//this.disableAlipay = false; //Disabled due to 0 deposit quota
}
let stype=this.$route.query.stype; let stype=this.$route.query.stype;
this.userPayData = JSON.parse(this.$route.query.userPayData); this.userPayData = JSON.parse(this.$route.query.userPayData);
this.defaultHandlePayment(); this.defaultHandlePayment();
}, },
methods: { methods: {
detectQrcodeDisplay(){
let payType = this.util.pickPaytype();
switch(payType) {
case 1:
this.disableQrcode=false;
break;
case 2:
this.disableQrcode=true;
break;
case 3:
//TODO raise WX jsapi pay
break;
}
},
defaultHandlePayment() { defaultHandlePayment() {
let isMobile = this.util.isMobile(); let isMobile = this.util.isMobile();
let isWx = this.util.isWX(); let isWx = this.util.isWX();
let payType = this.util.pickPaytype(); let payType = this.util.pickPaytype();
if(!this.userPayData.wxPay || this.userPayData.wxPay.length<4) if(!this.userPayData.wxPay || this.userPayData.wxPay.length<4)
throw new Error("订单信息错误,请删除商品后再次购买"); throw new Error("订单信息错误,请删除商品后再次购买");
this.detectQrcodeDisplay();
//Dictionary : 1: scan qrcode, 2:redirect 3: raise local app //Dictionary : 1: scan qrcode, 2:redirect 3: raise local app
switch(payType) { switch(payType) {
case 1: case 1:
this.disableQrcode=false;
this.qrtext=this.userPayData.wxPay; this.qrtext=this.userPayData.wxPay;
this.payOrderWX(); this.updateOrderNotification();
break; break;
case 2: case 2:
this.disableQrcode=true; this.$refs["h5SubmitForm"].innerHTML = '<form action="'+this.userPayData.wxPay+'" method="post"><form>';
break; break;
case 3: case 3:
//TODO raise WX jsapi pay //TODO raise WX jsapi pay
@ -185,13 +197,12 @@ export default {
]) ])
}, },
goPayH5() { goPayH5() {
let isMobile = this.util.isMobile(); if(this.userPayData.wxPay) {
if(this.userPayData.wxPay && isMobile) {
//this.$refs["h5SubmitForm"].action="http://47.96.75.242:10086/royalcanin/royalcanin/redirectUrlWXH5"; //this.$refs["h5SubmitForm"].action="http://47.96.75.242:10086/royalcanin/royalcanin/redirectUrlWXH5";
this.$refs["h5SubmitForm"].action=this.userPayData.wxPay; //this.$refs["h5SubmitForm"].action=this.userPayData.wxPay;
this.$refs["h5SubmitForm"].submit(); this.$refs["h5SubmitForm"].children[0].submit()
//window.location.href=this.userPayData.wxPay;; //window.location.href=this.userPayData.wxPay;
this.disableQrcode=true; //this.disableQrcode=true;
} else { } else {
throw new Error("订单信息错误,请删除商品后再次购买"); throw new Error("订单信息错误,请删除商品后再次购买");
} }
@ -217,21 +228,25 @@ export default {
this.paytype = item.paytype; this.paytype = item.paytype;
if (index == 1) { if (index == 1) {
// //
let res = await generateOrderAlipay(this.userPayData.orderId); let isMobile = this.util.isMobile();
this.qrtext = ''; isMobile = (isMobile?2:1);
let res = await generateOrderAlipay(this.userPayData.orderId, isMobile);
if (res.success) { if (res.success) {
this.disableQrcode = true;
this.qrtext=res.data; let virtualForm = res.data;
virtualForm = virtualForm.substr(0,virtualForm.indexOf("</form>")+7);
this.$refs["h5SubmitForm"].innerHTML = virtualForm;
} }
} else { } else {
this.userPayData = JSON.parse(this.$route.query.userPayData); this.userPayData = JSON.parse(this.$route.query.userPayData);
this.qrtext=this.userPayData.wxPay this.qrtext=this.userPayData.wxPay;
this.$refs["h5SubmitForm"].innerHTML = '<form method="get" action="'+this.userPayData.wxPay+'"></form>';
this.detectQrcodeDisplay();
} }
}, },
// //
async payOrderWX() { async updateOrderNotification() {
let res = await monitorOrderNotify(this.userPayData.orderId); let res = await monitorOrderNotify(this.userPayData.orderId);
if (res.success) { if (res.success) {
this.qrtext = '成功加入群的二维码'; this.qrtext = '成功加入群的二维码';
@ -250,7 +265,7 @@ export default {
} else { } else {
let _self = this; let _self = this;
this.paymentTimer = setTimeout(function(){ this.paymentTimer = setTimeout(function(){
_self.payOrderWX() _self.updateOrderNotification()
},5000); },5000);
} }

View File

@ -0,0 +1,245 @@
<template>
<div class="ts-resentation rc-padding-y--lg">
<Myheader></Myheader>
<div class="rc-top"></div>
<div class="ts-banner-swiper-container rc-margin-bottom--lg--desktop">
<picture>
<source
media="(max-width: 768px)"
srcset="/images/rxgoods/banner-mobile.png"
/>
<source
media="(min-width: 769px)"
srcset="/images/rxgoods/banner.png"
/>
<img src="/images/banner/pc-weixin.png" />
</picture>
</div>
<div>
<h2 class="rc-alpha rc-margin-y--md rc-text--center rc-margin-y--lg--mobile">明星犬粮</h2>
<ul class="ts-product-list rc-margin-bottom--lg rc-md-up">
<li
v-for="(item, index) in dataList.rxgoods.dog"
:key="index"
class="rc-margin-top--md"
>
<div class="rc-click rc-margin-bottom--md" @click="selectproduce(item, index)">
<div class="rc-rccontair">
<img :src="item.productimage" alt="" />
</div>
</div>
<div class="rc-column">
<div class="rc-click" @click="selectproduce(item, index)">
<span>{{ item.title }}</span>
<div class="desc">{{ item.detail }}</div>
</div>
<strong
class="
ts-standard-btn ts-standard-btn--two
rc-margin-y--md
center
"
@click="selectproduce(item, index)"
>立即购买</strong
>
</div>
</li>
</ul>
<div class="rc-md-down ts-product-list">
<swiper :options="swiperAOption">
<swiper-slide
v-for="(item, index) in dataList.rxgoods.dog"
:key="index"
>
<div class="rc-click rc-margin-bottom--md" @click="selectproduce(item, index)">
<div class="rc-rccontair">
<img :src="item.productimage" alt="" />
</div>
</div>
<div class="rc-column">
<div class="rc-click" @click="selectproduce(item, index)">
<h2 class="rc-beta">{{ item.title }}</h2>
<div class="desc">{{ item.detail }}</div>
</div>
<strong
class="
ts-standard-btn ts-standard-btn--two
rc-margin-y--md
center
"
@click="selectproduce(item, index)"
>立即购买</strong
>
</div>
</swiper-slide>
</swiper>
<div id="swiperAPagnation" class="swiper-pagination ts-carousel-indicator center"></div>
<div id="swiperAprev" class="swiper-button-prev ts-swiper-arrow"></div>
<div id="swiperAnext" class="swiper-button-next ts-swiper-arrow"></div>
</div>
</div>
<div class="contair rc-margin-y--lg--mobile">
<nuxt-link :to="`/productdetails/productlist/?stype=1&rxgoods=1`">
<span class="ts-standard-btn center">查看更多</span>
</nuxt-link>
</div>
<!-- Dog end -->
<div class="online bold rc-margin-y--lg"></div>
<!-- Cat start -->
<div>
<h2 class="rc-alpha rc-margin-y--md rc-text--center rc-margin-y--lg--mobile">明星猫粮</h2>
<ul class="ts-product-list rc-margin-bottom--lg rc-md-up">
<li
v-for="(item, index) in dataList.rxgoods.cat"
:key="index"
class="rc-margin-top--md"
>
<div class="rc-click rc-margin-bottom--md" @click="selectproduce(item, index)">
<div class="rc-rccontair">
<img :src="item.productimage" alt="" />
</div>
</div>
<div class="rc-column">
<div class="rc-click" @click="selectproduce(item, index)">
<span>{{ item.title }}</span>
<div class="desc">{{ item.detail }}</div>
</div>
<strong
class="
ts-standard-btn ts-standard-btn--two
rc-margin-y--md
center
"
@click="selectproduce(item, index)"
>立即购买</strong
>
</div>
</li>
</ul>
<div class="rc-md-down ts-product-list">
<swiper :options="swiperBOption">
<swiper-slide
v-for="(item, index) in dataList.rxgoods.cat"
:key="index"
>
<div class="rc-click rc-margin-bottom--md" @click="selectproduce(item, index)">
<div class="rc-rccontair">
<img :src="item.productimage" alt="" />
</div>
</div>
<div class="rc-column">
<div class="rc-click" @click="selectproduce(item, index)">
<h2 class="rc-beta">{{ item.title }}</h2>
<div class="desc">{{ item.detail }}</div>
</div>
<strong
class="
ts-standard-btn ts-standard-btn--two
rc-margin-y--md
center
"
@click="selectproduce(item, index)"
>立即购买</strong
>
</div>
</swiper-slide>
</swiper>
<div id="swiperBPagnation" class="swiper-pagination ts-carousel-indicator center"></div>
<div id="swiperBprev" class="swiper-button-prev ts-swiper-arrow"></div>
<div id="swiperBnext" class="swiper-button-next ts-swiper-arrow"></div>
</div>
</div>
<div class="contair rc-margin-y--lg--mobile">
<nuxt-link :to="`/productdetails/productlist/?stype=0&rxgoods=1`">
<span class="ts-standard-btn center">查看更多</span>
</nuxt-link>
</div>
<!-- Cat end-->
</div>
</template>
<script>
import Myheader from "~/components/header.vue";
import envData from "~/config/env-data.js";
export default {
data() {
return {
envData,
dataList:{rxgoods:{dog:[],cat:[]}},
swiperAOption: {
loop: false,
slidesPerView: "auto",
centeredSlides: true,
speed: 1000,
autoplay: {
delay: 3000,
},
spaceBetween: 0,
pagination: {
el: "#swiperAPagnation",
clickable: true,
},
loopAdditionalSlides: 100,
navigation: {
nextEl: "#swiperAprev",
prevEl: "#swiperAnext",
}
},
swiperBOption: {
loop: false,
slidesPerView: "auto",
centeredSlides: true,
speed: 1000,
autoplay: {
delay: 3000,
},
spaceBetween: 0,
pagination: {
el: "#swiperBPagnation",
clickable: true,
},
loopAdditionalSlides: 100,
navigation: {
nextEl: "#swiperBprev",
prevEl: "#swiperBnext",
}
},
}
},
components: {
Myheader,
},
mounted(){
let env=process.env.NODE_ENV;
this.dataList=this.envData[env];
},
methods:{
selectproduce(item) {
let isRxGoods = false;
let productCode = [];
let mainProductCode = item.productCode;
if (!item.ecPrice && !item.price) {
isRxGoods = 1;
productCode = [item.productCode];
} else {
for (let i of item.productList) {
productCode.push(i.productCode);
}
}
this.$router.push({
path: "/productdetails/producted",
query: {
stype: 1,
isRxGoods: isRxGoods,
mainProductCode: mainProductCode,
productCode: productCode.join(","),
},
});
},
}
};
</script>
<style lang="less" scoped >
@import url("../../assets/css/resentation.less");
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 349 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -325,7 +325,9 @@
<properties> <properties>
<profiles.active>dev</profiles.active> <profiles.active>dev</profiles.active>
</properties> </properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile> </profile>
<profile> <profile>
<id>telework</id> <id>telework</id>
@ -350,9 +352,7 @@
<properties> <properties>
<profiles.active>prod</profiles.active> <profiles.active>prod</profiles.active>
</properties> </properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile> </profile>
</profiles> </profiles>

View File

@ -1,10 +1,12 @@
package net.lab1024.smartadmin.module.system.alipay; package net.lab1024.smartadmin.module.system.alipay;
import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayClient; import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient; import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.domain.AlipayTradePrecreateModel; import com.alipay.api.request.AlipayTradePagePayRequest;
import com.alipay.api.request.AlipayTradePrecreateRequest; import com.alipay.api.request.AlipayTradeWapPayRequest;
import com.alipay.api.response.AlipayTradePrecreateResponse; import com.alipay.api.response.AlipayTradePagePayResponse;
import com.alipay.api.response.AlipayTradeWapPayResponse;
import net.lab1024.smartadmin.module.system.alipay.alipayModel.AliPayEntity; import net.lab1024.smartadmin.module.system.alipay.alipayModel.AliPayEntity;
import net.lab1024.smartadmin.module.system.alipay.conf.AlipayConfig; import net.lab1024.smartadmin.module.system.alipay.conf.AlipayConfig;
import net.lab1024.smartadmin.module.system.royalcanin.good.service.OrderService; import net.lab1024.smartadmin.module.system.royalcanin.good.service.OrderService;
@ -12,7 +14,6 @@ import net.lab1024.smartadmin.module.system.royalcanin.orderMaster.QueryEntity;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.UUID;
@Service @Service
public class AliPayService { public class AliPayService {
@ -22,28 +23,49 @@ public class AliPayService {
private OrderService orderService; private OrderService orderService;
public String generateQRCode(AliPayEntity aliPayEntity) throws Exception { public String generateOrderPhone(AliPayEntity aliPayEntity) throws Exception {
AlipayTradePrecreateModel model = new AlipayTradePrecreateModel(); JSONObject bizContent = new JSONObject();
model.setSubject("皇家宠物食品官方商城"); bizContent.put("subject","皇家宠物食品官方商城");
model.setTotalAmount(aliPayEntity.getTotal_amount()); bizContent.put("total_amount",String.format("%.2f", Double.parseDouble(aliPayEntity.getTotal_amount())));
model.setStoreId(UUID.randomUUID().toString()); bizContent.put("out_trade_no",aliPayEntity.getOut_trade_no());
model.setTimeoutExpress("3m"); bizContent.put("product_code", aliPayEntity.getProduct_code());
model.setOutTradeNo(aliPayEntity.getOut_trade_no()); bizContent.put("quit_url", AlipayConfig.return_url);
model.setBody(aliPayEntity.getBody()); AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest();
model.setGoodsDetail(aliPayEntity.getGoodsDetail()); request.setBizContent(bizContent.toString());
AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest();
request.setBizModel(model);
request.setNotifyUrl(AlipayConfig.notify_url); request.setNotifyUrl(AlipayConfig.notify_url);
request.setReturnUrl(AlipayConfig.return_url);
AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfig.gatewayUrl, AlipayConfig.app_id, AlipayConfig.merchant_private_key, "json", AlipayConfig.charset, AlipayConfig.alipay_public_key, AlipayConfig.sign_type); AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfig.gatewayUrl, AlipayConfig.app_id, AlipayConfig.merchant_private_key, "json", AlipayConfig.charset, AlipayConfig.alipay_public_key, AlipayConfig.sign_type);
AlipayTradePrecreateResponse alipayTradePrecreateResponse = alipayClient.execute(request); AlipayTradeWapPayResponse alipayTradeWapPayResponse = alipayClient.pageExecute(request);
if (alipayTradePrecreateResponse.isSuccess()) { if (alipayTradeWapPayResponse.isSuccess()) {
String code = alipayTradePrecreateResponse.getQrCode(); String body = alipayTradeWapPayResponse.getBody();
return code; return body;
} else { } else {
throw new RuntimeException("支付宝生成二维码失败"); throw new RuntimeException("支付宝调用失败!");
} }
} }
public String generateOrderPC(AliPayEntity aliPayEntity) throws Exception {
AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfig.gatewayUrl, AlipayConfig.app_id, AlipayConfig.merchant_private_key, "json", AlipayConfig.charset, AlipayConfig.alipay_public_key, AlipayConfig.sign_type);
AlipayTradePagePayRequest request = new AlipayTradePagePayRequest ();
request.setNotifyUrl(AlipayConfig.notify_url);
request.setReturnUrl(AlipayConfig.return_url);
JSONObject bizContent = new JSONObject();
bizContent.put("subject","皇家宠物食品官方商城");
bizContent.put("total_amount",String.format("%.2f", Double.parseDouble(aliPayEntity.getTotal_amount())));
bizContent.put("out_trade_no",aliPayEntity.getOut_trade_no());
bizContent.put("product_code", "FAST_INSTANT_TRADE_PAY");
request.setBizContent(bizContent.toString());
AlipayTradePagePayResponse alipayTradePagePayResponse = alipayClient.pageExecute(request);
if (alipayTradePagePayResponse.isSuccess()) {
String body = alipayTradePagePayResponse.getBody();
return body;
} else {
throw new RuntimeException("支付宝调用失败!");
}
}
public void orderCallBackAliPay(String outTradeNo,String totalFee ) throws Exception { public void orderCallBackAliPay(String outTradeNo,String totalFee ) throws Exception {
if (orderService.afterPaySucceedUpdateOrderStatus(outTradeNo,totalFee)) { if (orderService.afterPaySucceedUpdateOrderStatus(outTradeNo,totalFee)) {
QueryEntity queryEntity = new QueryEntity(); QueryEntity queryEntity = new QueryEntity();

View File

@ -23,6 +23,9 @@ import net.lab1024.smartadmin.module.system.royalcanin.good.service.OrderService
import net.lab1024.smartadmin.module.system.royalcanin.memberAccount.MemberAccountChangeEntity; import net.lab1024.smartadmin.module.system.royalcanin.memberAccount.MemberAccountChangeEntity;
import net.lab1024.smartadmin.module.system.royalcanin.notify.model.NotifyEntity; import net.lab1024.smartadmin.module.system.royalcanin.notify.model.NotifyEntity;
import net.lab1024.smartadmin.module.system.royalcanin.notify.service.NotifyService; import net.lab1024.smartadmin.module.system.royalcanin.notify.service.NotifyService;
import net.lab1024.smartadmin.module.system.royalcanin.orderMaster.AddOrSaveEntity;
import net.lab1024.smartadmin.module.system.royalcanin.orderMaster.OrderCouponEntity;
import net.lab1024.smartadmin.module.system.royalcanin.orderMaster.QueryEntity;
import net.lab1024.smartadmin.util.MapRemoveNullUtil; import net.lab1024.smartadmin.util.MapRemoveNullUtil;
import net.lab1024.smartadmin.util.SmartHttpUtil; import net.lab1024.smartadmin.util.SmartHttpUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -89,88 +92,6 @@ public class AlipayController {
} }
//
// @RequestMapping("royalcanin/updateOrderAliPay")
// public String returnUrl(HttpServletRequest request) throws Exception {
// Map<String,String> params = new HashMap<String,String>();
// Map<String,String[]> requestParams = request.getParameterMap();
// for (Iterator<String> iter = requestParams.keySet().iterator(); iter.hasNext();) {
// String name = (String) iter.next();
// String[] values = (String[]) requestParams.get(name);
// String valueStr = "";
// for (int i = 0; i < values.length; i++) {
// valueStr = (i == values.length - 1) ? valueStr + values[i]
// : valueStr + values[i] + ",";
// }
// //乱码解决这段代码在出现乱码时使用(如果感觉自己配置没问题然后验签一直失败就把这个注释掉试试反正我的是这个问题)
// //valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8");
// params.put(name, valueStr);
// }
// System.out.println("params:"+params);
// boolean signVerified = AlipaySignature.rsaCheckV1(params,AlipayConfig.alipay_public_key,AlipayConfig.charset,AlipayConfig.sign_type); //调用SDK验证签名
// System.out.println(signVerified);
// //请在这里编写您的程序以下代码仅作参考
// if(signVerified) {
// // 更新订单状态
// //商户订单号
// String out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"),"UTF-8");
// //付款金额
// String total_amount = new String(request.getParameter("total_amount").getBytes("ISO-8859-1"),"UTF-8");
//
//
// //支付宝交易号
// String trade_no = new String(request.getParameter("trade_no").getBytes("ISO-8859-1"),"UTF-8");
// OrderEntity orderEntity = orderService.findByOrderId(out_trade_no);
// String[] products = orderEntity.getProductCode().split(",");
// ProductMasterQueryEntity productMasterQueryEntity = new ProductMasterQueryEntity();
// double basePoint = 0;
// //自动获取会员积分
// for (String product : products) {
// productMasterQueryEntity.setProductCode(product);
// Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(productMasterQueryEntity);
// MapRemoveNullUtil.removeNullEntry(paramMap);
// paramMap.put("secret", "H5@2021");
// paramMap.put("channelId", "15");
// String sb = SmartHttpUtil.sendPostForm(url + "productMaster/query", paramMap, null);
// JSONObject jsonObject = JSONObject.parseObject(sb);
// com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(jsonObject.getString("data"));
// JSONObject jsonObjectData = (JSONObject) jsonArray.get(0);
// basePoint = basePoint + Double.parseDouble(jsonObjectData.getString("basePoint"));
// }
// MemberAccountChangeEntity memberAccountChangeEntity = new MemberAccountChangeEntity();
// memberAccountChangeEntity.setChangeTypeId("1");
// memberAccountChangeEntity.setChangeValue(StringUtil.toString(basePoint));
// memberAccountChangeEntity.setMemberId(orderEntity.getMemberId());
// memberAccountService.memberAccountChange(memberAccountChangeEntity);
// NotifyEntity notifyEntity = new NotifyEntity();
// notifyEntity.setAppId(AlipayConfig.app_id);
// notifyEntity.setMchId(request.getParameter("seller_id"));
// notifyEntity.setSign(request.getParameter("sign"));
// notifyEntity.setResultCode(request.getParameter("code"));
// notifyEntity.setOpenid(request.getParameter("merchant_order_no"));
// notifyEntity.setOutTradeNo(out_trade_no);
// notifyEntity.setTotalFee(total_amount);
// notifyEntity.setTradeType(request.getParameter("sub_code"));
// notifyEntity.setFeeType("CNY");
// notifyEntity.setNonceStr(trade_no);
// notifyService.insertNotify(notifyEntity);
//
//
//
//
//
//
// String trade_status= new String(request.getParameter("trade_status").getBytes("ISO-8859-1"),"UTF-8");
// System.out.println("trade_status"+trade_status);
// return "trade_no:"+trade_no+"<br/>out_trade_no:"+out_trade_no+"<br/>total_amount:"+total_amount;
// }else {
// return "验签失败";
// }
// }
@RequestMapping("royalcanin/updateOrderAliPay") @RequestMapping("royalcanin/updateOrderAliPay")
@ResponseBody @ResponseBody
public String alipayNotifyNotice(HttpServletRequest request, HttpServletRequest response) throws Exception { public String alipayNotifyNotice(HttpServletRequest request, HttpServletRequest response) throws Exception {
@ -215,6 +136,10 @@ public class AlipayController {
//付款金额 //付款金额
String total_amount = new String(request.getParameter("total_amount").getBytes("ISO-8859-1"), "UTF-8"); String total_amount = new String(request.getParameter("total_amount").getBytes("ISO-8859-1"), "UTF-8");
//校验通知中的seller_id
String seller_id = new String(request.getParameter("seller_id").getBytes("ISO-8859-1"), "UTF-8");
if (trade_status.equals("TRADE_FINISHED")) { if (trade_status.equals("TRADE_FINISHED")) {
return "TRADE_FINISHED"; return "TRADE_FINISHED";
@ -257,18 +182,58 @@ public class AlipayController {
memberAccountChangeEntity.setChangeValue(StringUtil.toString(basePoint)); memberAccountChangeEntity.setChangeValue(StringUtil.toString(basePoint));
memberAccountChangeEntity.setMemberId(orderEntity.getMemberId()); memberAccountChangeEntity.setMemberId(orderEntity.getMemberId());
memberAccountService.memberAccountChange(memberAccountChangeEntity); memberAccountService.memberAccountChange(memberAccountChangeEntity);
//更新订单信息
QueryEntity queryEntity = new QueryEntity();
queryEntity.setOrderNumber(out_trade_no);
String orderEntityJson = orderService.query(queryEntity);
com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(orderEntityJson);
JSONObject jsonObject = (JSONObject)jsonArray.get(0);
if(orderEntity != null) {
AddOrSaveEntity addOrSaveEntity = new AddOrSaveEntity();
addOrSaveEntity.setOrderNumber(out_trade_no);
addOrSaveEntity.setPhoneNumber(orderEntity.getPhoneNumber());
addOrSaveEntity.setStatus("1");
addOrSaveEntity.setOrderDetailList(jsonObject.getString("orderDetailList"));
addOrSaveEntity.setDeliveryType(jsonObject.getString("deliveryType"));
addOrSaveEntity.setSalesAmount(jsonObject.getString("salesAmount"));
addOrSaveEntity.setOrderDate(jsonObject.getString("orderDate"));
addOrSaveEntity.setAddressCityName(jsonObject.getString("addressCityName"));
addOrSaveEntity.setAddressCountyName(jsonObject.getString("addressCountyName"));
addOrSaveEntity.setAddressDetailInfo(jsonObject.getString("addressDetailInfo"));
addOrSaveEntity.setAddressPhoneNumber(jsonObject.getString("addressPhoneNumber"));
addOrSaveEntity.setAddressProvinceName(jsonObject.getString("addressProvinceName"));
addOrSaveEntity.setAddressUserName(jsonObject.getString("addressUserName"));
addOrSaveEntity.setPaymentAmount(total_amount);
addOrSaveEntity.setPaymentToken(trade_no);
addOrSaveEntity.setPaymentResult("SUCCESS");
if (orderEntity.getCouponCode() != "" && null != orderEntity.getCouponCode()) {
//coupon json化
OrderCouponEntity orderCouponEntity = new OrderCouponEntity();
orderCouponEntity.setCouponCode(orderEntity.getCouponCode());
orderCouponEntity.setCouponName(orderEntity.getCouponName());
orderCouponEntity.setCouponId(orderEntity.getCouponId());
Map<String, String> orderCouponParamMap = MapRemoveNullUtil.setConditionMap(orderCouponEntity);
MapRemoveNullUtil.removeNullEntry(orderCouponParamMap);
net.sf.json.JSONObject orderCouponJson = net.sf.json.JSONObject.fromObject(orderCouponParamMap);
addOrSaveEntity.setOrderCoupon(orderCouponJson.toString());
}
orderService.addOrSave(addOrSaveEntity);
}
NotifyEntity notifyEntity = new NotifyEntity(); NotifyEntity notifyEntity = new NotifyEntity();
notifyEntity.setAppId(AlipayConfig.app_id); notifyEntity.setAppId(AlipayConfig.app_id);
notifyEntity.setMchId(request.getParameter("seller_id")); notifyEntity.setMchId(seller_id);
notifyEntity.setSign(request.getParameter("sign")); notifyEntity.setSign(AlipayConfig.sign_type);
notifyEntity.setResultCode(request.getParameter("code")); notifyEntity.setResultCode("");
notifyEntity.setOpenid(request.getParameter("merchant_order_no")); notifyEntity.setOpenid("");
notifyEntity.setOutTradeNo(out_trade_no); notifyEntity.setOutTradeNo(out_trade_no);
notifyEntity.setTotalFee(total_amount); notifyEntity.setTotalFee(total_amount);
notifyEntity.setTradeType(request.getParameter("sub_code")); notifyEntity.setTimeEnd("");
notifyEntity.setTradeType("");
notifyEntity.setFeeType("CNY"); notifyEntity.setFeeType("CNY");
notifyEntity.setNonceStr(trade_no); notifyEntity.setNonceStr("");
notifyService.insertNotify(notifyEntity); notifyService.insertNotify(notifyEntity);
orderService.afterPaySucceedUpdateOrderStatus(out_trade_no,total_amount);
}else { }else {
return "验签失败"; return "验签失败";
} }

View File

@ -31,9 +31,9 @@ public class AlipayConfig {
public static String alipay_public_key = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9yEe5sOFYFmEW0GdVCyvuU5vXCLsk2lwWmfC/bh/kcjBaBNTaFSiuG1VFPWsNIKWEHLdbEwMQnq4WxhqYN741wXxJlOpvsECFYtGSL6szx7BDaTYATQGVk963SeKYplz5ZPlXg1QiKgcqS3brvnpxxtcS1JKCJ/6iJXJkZXxK2QIDAQAB"; public static String alipay_public_key = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9yEe5sOFYFmEW0GdVCyvuU5vXCLsk2lwWmfC/bh/kcjBaBNTaFSiuG1VFPWsNIKWEHLdbEwMQnq4WxhqYN741wXxJlOpvsECFYtGSL6szx7BDaTYATQGVk963SeKYplz5ZPlXg1QiKgcqS3brvnpxxtcS1JKCJ/6iJXJkZXxK2QIDAQAB";
// public static String alipay_public_key = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCnxj/9qwVfgoUh/y2W89L6BkRAFljhNhgPdyPuBV64bfQNN1PjbCzkIM6qRdKBoLPXmKKMiFYnkd6rAoprih3/PrQEB/VsW8OoM8fxn67UDYuyBTqA23MML9q1+ilIZwBC2AQ2UBVOrFXfFl75p6/B5KsiNG9zpgmLCUYuLkxpLQIDAQAB"; // public static String alipay_public_key = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCnxj/9qwVfgoUh/y2W89L6BkRAFljhNhgPdyPuBV64bfQNN1PjbCzkIM6qRdKBoLPXmKKMiFYnkd6rAoprih3/PrQEB/VsW8OoM8fxn67UDYuyBTqA23MML9q1+ilIZwBC2AQ2UBVOrFXfFl75p6/B5KsiNG9zpgmLCUYuLkxpLQIDAQAB";
// 服务器异步通知页面路径 需http://格式的完整路径不能加?id=123这类自定义参数必须外网可以正常访问 // 服务器异步通知页面路径 需http://格式的完整路径不能加?id=123这类自定义参数必须外网可以正常访问
public static String notify_url = "https://royalcanincn.escase.cn/jc/royalcanin/royalcanin/updateOrderAliPay"; public static String notify_url = "https://shop.royalcanin.com.cn/royalcanin/royalcanin/royalcanin/updateOrderAliPay";
// 页面跳转同步通知页面路径 需http://格式的完整路径不能加?id=123这类自定义参数必须外网可以正常访问 // 页面跳转同步通知页面路径 需http://格式的完整路径不能加?id=123这类自定义参数必须外网可以正常访问
public static String return_url = "https://royalcanincn.escase.cn/jc/royalcanin/royalcanin/updateOrderAliPay"; public static String return_url = "https://shop.royalcanin.com.cn";
// 签名方式 // 签名方式
public static String sign_type = "RSA2"; public static String sign_type = "RSA2";

View File

@ -220,6 +220,85 @@ public class OrderController {
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_FAIL); return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_FAIL);
} }
@ApiOperation(value = "微信支付JSAPI订单", notes = "生成JSAPI订单")
@PostMapping("royalcanin/generateOrderWXJSAPI")
public ResponseDTO<Map<String, String>> generateOrderWXJSAPI(@RequestBody List<OrdersEntity> ordersEntityList) throws Exception {
StringBuffer productId = new StringBuffer();
StringBuffer productName = new StringBuffer();
String memberId = "";
String mobile = "";
int buyCount = 0;
double total_fee = 0 ;
double basePoint = 0 ;
WxPayEntity wxPayEntity = new WxPayEntity();
JSONArray orderDatilListJson = new JSONArray();
OrdersEntity ordersEntity = new OrdersEntity();
OrderAddress orderAddress = new OrderAddress();
for (OrdersEntity ordersEntitys:ordersEntityList) {
cartService.cancelProduct(ordersEntitys.getMemberId(),ordersEntity.getProductCode());
//存储orderDetailList
OrderDatilListEntity orderDatilListEntity= new OrderDatilListEntity();
orderDatilListEntity.setProductName(ordersEntitys.getProductName());
orderDatilListEntity.setPcs(ordersEntitys.getBuyCount());
orderDatilListEntity.setProductCode(ordersEntitys.getProductCode());
orderDatilListEntity.setEcPrice(ordersEntitys.getPayAmount());
orderDatilListJson.add(orderDatilListEntity);
if(ordersEntitys.getCouponCode() != "" && ordersEntitys.getCouponCode() != null) {
CouponGetAllEntity couponGetAllEntity = new CouponGetAllEntity ();
couponGetAllEntity.setMemberId(ordersEntitys.getMemberId());
couponGetAllEntity.setCouponCode(ordersEntitys.getCouponCode());
String couponInfo = couponService.couponGetAll(couponGetAllEntity);
JSONObject jsonObject = JSONObject.parseObject(couponInfo);
com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(jsonObject.getString("data"));
JSONObject jsonObjectData = (JSONObject)jsonArray.get(0);
ordersEntity.setCouponAmount(jsonObjectData.getString("couponAmount") == null ?jsonObjectData.getString("discount"):jsonObjectData.getString("couponAmount"));
ordersEntity.setCouponCode(jsonObjectData.getString("couponCode"));
ordersEntity.setCouponName(jsonObjectData.getString("couponName"));
ordersEntity.setCouponId(jsonObjectData.getString("couponId"));
total_fee = total_fee + orderService.couponTotal(ordersEntitys.getCouponTypeId(),Double.parseDouble(ordersEntitys.getCouponAmount()),Double.parseDouble(ordersEntitys.getPayAmount()),ordersEntitys.getBuyCount());
}else{
total_fee = total_fee + Double.parseDouble(ordersEntitys.getPayAmount()) * ordersEntitys.getBuyCount() ;
}
basePoint = basePoint + ordersEntitys.getBasePoint();
orderAddress.setAddressCityName(ordersEntitys.getOrderAddress().getAddressCityName());
orderAddress.setAddressCountyName(ordersEntitys.getOrderAddress().getAddressCountyName());
orderAddress.setAddressDetailInfo(ordersEntitys.getOrderAddress().getAddressDetailInfo());
orderAddress.setAddressPhoneNumber(ordersEntitys.getOrderAddress().getAddressPhoneNumber());
orderAddress.setAddressUserName(ordersEntitys.getOrderAddress().getAddressUserName());
orderAddress.setAddressProvinceName(ordersEntitys.getOrderAddress().getAddressProvinceName());
productId.append(ordersEntitys.getProductCode()+",");
productName.append(ordersEntitys.getProductName()+",");
memberId = ordersEntitys.getMemberId();
mobile = ordersEntitys.getPhoneNumber();
buyCount = buyCount + ordersEntitys.getBuyCount();
}
ordersEntity.setOrderAddress(orderAddress);
ordersEntity.setProductCode(productId.substring(0,productId.length()-1));
ordersEntity.setProductName(productName.substring(0,productName.length()-1));
ordersEntity.setOrderAmount(StringUtil.toString(total_fee));
ordersEntity.setMemberId(memberId);
ordersEntity.setPhoneNumber(mobile);
ordersEntity.setBuyCount(buyCount);
ordersEntity.setOrderNo(GenerateSequenceUtil.generateSequenceNo());
ordersEntity.setOrderStatus("0");
ordersEntity.setBasePoint(basePoint);
ordersEntity.setPayType("3");
if(orderService.generateOrder(ordersEntity,orderDatilListJson) == 1){
wxPayEntity.setProduct_id(ordersEntity.getProductCode());
wxPayEntity.setTotal_fee(StringUtil.toString(total_fee));
wxPayEntity.setOut_trade_no(ordersEntity.getOrderNo());
Map<String, String> returnMap = new HashMap<>();
returnMap.put("orderNumber",ordersEntity.getOrderNo());
returnMap.put("orderAmount",ordersEntity.getOrderAmount());
return ResponseDTO.succData(returnMap,wxpayService.dounifiedOrderJSAPI(wxPayEntity));
}
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_FAIL);
}
@ApiOperation(value = "重新支付(二维码)", notes = "重新支付(二维码)") @ApiOperation(value = "重新支付(二维码)", notes = "重新支付(二维码)")
@PostMapping("royalcanin/repayOrderWX") @PostMapping("royalcanin/repayOrderWX")
public ResponseDTO<String> repayOrderWX(String orderNo) throws Exception { public ResponseDTO<String> repayOrderWX(String orderNo) throws Exception {
@ -277,6 +356,30 @@ public class OrderController {
} }
} }
@ApiOperation(value = "重新支付JSAPI", notes = "重新支付JSAPI")
@PostMapping("royalcanin/repayOrderJSAPI")
public ResponseDTO<String> repayOrderWXJSAPI(String orderNo) throws Exception {
OrderEntity ordersEntity = orderService.findByOrderId(orderNo);
if(ordersEntity != null){
QueryEntity queryEntity = new QueryEntity();
queryEntity.setOrderNumber(ordersEntity.getOrderNo());
String orderInfo = orderService.query(queryEntity);
com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(orderInfo);
JSONObject jsonObject = (JSONObject)jsonArray.get(0);
if(jsonObject.getString("status").equals("0")) {
WxPayEntity wxPayEntity = new WxPayEntity();
wxPayEntity.setProduct_id(ordersEntity.getProductCode());
wxPayEntity.setTotal_fee(jsonObject.getString("salesAmount"));
wxPayEntity.setOut_trade_no(ordersEntity.getOrderNo());
return ResponseDTO.succData(wxpayService.dounifiedOrderJSAPI(wxPayEntity));
}else {
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_ERROR,orderInfo);
}
}else {
return ResponseDTO.wrap(OrderResponseCodeConst.WITHOUT_ORDER);
}
}
@ -307,9 +410,9 @@ public class OrderController {
} }
@ApiOperation(value = "支付宝支付订单", notes = "生成订单") @ApiOperation(value = "支付宝支付订单PC", notes = "生成订单")
@PostMapping("royalcanin/generateOrderAlipay") @PostMapping("royalcanin/generateOrderAlipayPC")
public ResponseDTO<String> generateOrderAliPay(String orderNo) throws Exception { public ResponseDTO<String> generateOrderAliPayPC(String orderNo) throws Exception {
OrderEntity ordersEntity = orderService.findByOrderId(orderNo); OrderEntity ordersEntity = orderService.findByOrderId(orderNo);
if(ordersEntity != null) { if(ordersEntity != null) {
QueryEntity queryEntity = new QueryEntity(); QueryEntity queryEntity = new QueryEntity();
@ -325,7 +428,7 @@ public class OrderController {
aliPayEntity.setProduct_code(ordersEntity.getProductCode()); aliPayEntity.setProduct_code(ordersEntity.getProductCode());
aliPayEntity.setTotal_amount(ordersEntity.getOrderAmount()); aliPayEntity.setTotal_amount(ordersEntity.getOrderAmount());
aliPayEntity.setOut_trade_no(ordersEntity.getOrderNo()); aliPayEntity.setOut_trade_no(ordersEntity.getOrderNo());
return ResponseDTO.succData(aliPayService.generateQRCode(aliPayEntity)); return ResponseDTO.succData(aliPayService.generateOrderPC(aliPayEntity));
} else { } else {
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_FAIL); return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_FAIL);
} }
@ -336,6 +439,36 @@ public class OrderController {
return ResponseDTO.wrap(OrderResponseCodeConst.WITHOUT_ORDER); return ResponseDTO.wrap(OrderResponseCodeConst.WITHOUT_ORDER);
} }
} }
@ApiOperation(value = "支付宝支付订单Phone", notes = "生成订单")
@PostMapping("royalcanin/generateOrderAlipayPhone")
public ResponseDTO<String> generateOrderAliPayPhone(String orderNo) throws Exception {
OrderEntity ordersEntity = orderService.findByOrderId(orderNo);
if(ordersEntity != null) {
QueryEntity queryEntity = new QueryEntity();
queryEntity.setOrderNumber(ordersEntity.getOrderNo());
String orderInfo = orderService.query(queryEntity);
com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(orderInfo);
JSONObject jsonObject = (JSONObject)jsonArray.get(0);
if(jsonObject.getString("status").equals("0")) {
AliPayEntity aliPayEntity = new AliPayEntity();
ordersEntity.setPayType("2");
ordersEntity.setOrderStatus("0");
if (orderService.updateOrder(ordersEntity.getOrderNo()) == 1) {
aliPayEntity.setProduct_code(ordersEntity.getProductCode());
aliPayEntity.setTotal_amount(ordersEntity.getOrderAmount());
aliPayEntity.setOut_trade_no(ordersEntity.getOrderNo());
return ResponseDTO.succData(aliPayService.generateOrderPhone(aliPayEntity));
} else {
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_FAIL);
}
}else{
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_ERROR);
}
}else{
return ResponseDTO.wrap(OrderResponseCodeConst.WITHOUT_ORDER);
}
}
@PostMapping("royalcanin/updateOrderAliPay") @PostMapping("royalcanin/updateOrderAliPay")
public ResponseDTO<String> alipayNotify(HttpServletRequest request) throws Exception { public ResponseDTO<String> alipayNotify(HttpServletRequest request) throws Exception {

View File

@ -250,7 +250,48 @@ public class WxpayService {
} }
/**
* /H5微信支付(预下单)
* @return
* @throws Exception
*/
public String dounifiedOrderJSAPI(WxPayEntity wxPayEntity) throws Exception {
//返回参数
Map<String, String> returnMap = new HashMap<>();
WXPay wxpay = new WXPay(config);
//请求参数封装
Map<String, String> data = new HashMap<>();
data.put("out_trade_no",wxPayEntity.getOut_trade_no());
data.put("notify_url",config.notify_url);
data.put("fee_type","CNY");
data.put("total_fee",getMoney(wxPayEntity.getTotal_fee()));
data.put("spbill_create_ip", SmartIPUtil.getLocalHostIP());
data.put("trade_type", "JSAPI"); // 此处指定为H5支付
data.put("body","皇家宠物食品官方商城");
data.put("nonce_str", WXPayUtil.generateNonceStr());
data.put("product_id",wxPayEntity.getProduct_id());
String s = WXPayUtil.generateSignature(data, config.getKey()); //签名
data.put("sign", s);//签名
try {
//使用官方API请求预付订单
Map<String, String> response = wxpay.unifiedOrder(data);
String returnCode = response.get("return_code");//获取返回码
//若返回码为SUCCESS则会返回一个result_code,再对该result_code进行判断
if (returnCode.equals("SUCCESS")) {
net.sf.json.JSONObject jsonResponse = net.sf.json.JSONObject.fromObject(response);
return jsonResponse.toString();
} else {
returnMap.put("ok", "201");
return "";
}
} catch (Exception e) {
System.out.println(e);
return "ERROR!";
//系统等其他错误的时候
}
}
/** /**

View File

@ -22,7 +22,7 @@ public class SmartJWTUtil {
private static final String CLAIM_ID_KEY = "id"; private static final String CLAIM_ID_KEY = "id";
//设置过期时间 //设置过期时间
private static final long EXPIRE_DATE = 30 * 60 * 100000; private static final long EXPIRE_DATE = 5256 * 60 * 100000;
//token秘钥 //token秘钥
private static final String TOKEN_SECRET = "smart-admin-jwt-key"; private static final String TOKEN_SECRET = "smart-admin-jwt-key";
@ -80,7 +80,7 @@ public class SmartJWTUtil {
public static void main(String[] args) { public static void main(String[] args) {
String token = SmartJWTUtil.generateToken("884159"); String token = SmartJWTUtil.generateToken("884159");
System.out.println(token); System.out.println(token);
System.out.println(SmartJWTUtil.decodeToken(token)); System.out.println(SmartJWTUtil.decodeToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6Ijg4NDE1OSIsImV4cCI6MTY0NjM4Mzk1NH0.-ilK-e-49c88IxdkSW1QMNZQ3P2LG7iIsQRXYlrXjjo"));
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 94 KiB