添加钱包模块、美化前端
This commit is contained in:
parent
1c54eaff29
commit
2681504445
Binary file not shown.
|
After Width: | Height: | Size: 4.5 KiB |
|
|
@ -1,314 +1,327 @@
|
|||
<template>
|
||||
<!------总容器------>
|
||||
<div class="wrapper">
|
||||
<!------总容器------>
|
||||
<div class="wrapper">
|
||||
|
||||
<header>
|
||||
<i class="fa fa-angle-left" @click="back"></i>
|
||||
<p>修改地址</p>
|
||||
</header>
|
||||
<header>
|
||||
<i class="fa fa-angle-left" @click="back"></i>
|
||||
<p>修改地址</p>
|
||||
</header>
|
||||
|
||||
<div class="shangbiao">
|
||||
<img src="../assets/elmlogo.jpg">
|
||||
</div>
|
||||
<!------自动识别------>
|
||||
<div class="identify">
|
||||
<input type="text" placeholder=" 粘贴地址,智能识别填写" v-model="addressInfo">
|
||||
<button @click="fill">
|
||||
<p>AI识别</p>
|
||||
</button>
|
||||
</div>
|
||||
<div class="shangbiao">
|
||||
<img src="../assets/elmlogo.jpg">
|
||||
</div>
|
||||
<!------自动识别------>
|
||||
<div class="identify">
|
||||
<input type="text" placeholder=" 粘贴地址,智能识别填写" v-model="addressInfo">
|
||||
<button @click="fill">
|
||||
<p>AI识别</p>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!------列表------>
|
||||
<ul class="form">
|
||||
<li>
|
||||
<div class="title">
|
||||
收货人:
|
||||
</div>
|
||||
<div class="content">
|
||||
<input type="text" placeholder=" 收货人姓名" v-model="deliveryAddress.contactName">
|
||||
</div>
|
||||
</li>
|
||||
<!------列表------>
|
||||
<ul class="form">
|
||||
<li>
|
||||
<div class="title">
|
||||
收货人:
|
||||
</div>
|
||||
<div class="content">
|
||||
<input type="text" placeholder=" 收货人姓名" v-model="deliveryAddress.contactName">
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<div class="gender" style="font-size: 3.5vw">
|
||||
<input type="radio" name="sex" checked style="width: 8vw;height: 4.2vw;">先生
|
||||
<input type="radio" name="sex" style="width: 8vw;height: 4.2vw;">女士
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="gender" style="font-size: 3.5vw">
|
||||
<input type="radio" name="sex" checked style="width: 8vw;height: 4.2vw;">先生
|
||||
<input type="radio" name="sex" style="width: 8vw;height: 4.2vw;">女士
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<div class="title">
|
||||
手机号:
|
||||
</div>
|
||||
<div class="content">
|
||||
<input type="text" placeholder=" 填写收获人手机号码" v-model="deliveryAddress.contactTel">
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="title">
|
||||
手机号:
|
||||
</div>
|
||||
<div class="content">
|
||||
<input type="text" placeholder=" 填写收获人手机号码" v-model="deliveryAddress.contactTel">
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<div class="title">
|
||||
地址:
|
||||
</div>
|
||||
<div class="content">
|
||||
<input type="text" placeholder=" 填写详细地址,精确到门牌号" v-model="deliveryAddress.address">
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="title">
|
||||
地址:
|
||||
</div>
|
||||
<div class="content">
|
||||
<input type="text" placeholder=" 填写详细地址,精确到门牌号" v-model="deliveryAddress.address">
|
||||
</div>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
<!------确认修改------>
|
||||
<div class="ok">
|
||||
<button @click="addUserAddress">
|
||||
<p>保存修改</p>
|
||||
</button>
|
||||
<!------确认修改------>
|
||||
<div class="ok">
|
||||
<button @click="addUserAddress">
|
||||
<p>保存修改</p>
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import Footer from '../components/Footer.vue';
|
||||
export default {
|
||||
name: 'AddUserAddress',
|
||||
data() {
|
||||
return {
|
||||
businessId: this.$route.query.businessId,
|
||||
user: {},
|
||||
addressInfo: '',
|
||||
deliveryAddress: {
|
||||
contactName: '',
|
||||
contactSex: 1,
|
||||
contactTel: '',
|
||||
address: ''
|
||||
},
|
||||
nameVisible: false,
|
||||
phoneVisible: false,
|
||||
phoneError: false,
|
||||
addrVisible: false
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.user = this.$getSessionStorage('user');
|
||||
},
|
||||
components: {
|
||||
Footer
|
||||
},
|
||||
methods: {
|
||||
back() {
|
||||
this.$router.go(-1);
|
||||
},
|
||||
addUserAddress() {
|
||||
if (this.deliveryAddress.contactName == '') {
|
||||
this.nameVisible = true;
|
||||
setTimeout(() => {
|
||||
this.nameVisible = false;
|
||||
}, 2000);
|
||||
return;
|
||||
}
|
||||
if (this.deliveryAddress.contactTel == '') {
|
||||
this.phoneVisible = true;
|
||||
setTimeout(() => {
|
||||
this.phoneVisible = false;
|
||||
}, 2000);
|
||||
return;
|
||||
} else {
|
||||
const contactTelString = this.deliveryAddress.contactTel.toString();
|
||||
if (contactTelString.length === 11 && !isNaN(contactTelString) && contactTelString.startsWith('1')) {
|
||||
// 数字以1开头,有11位,且全为数字
|
||||
} else {
|
||||
this.phoneError = true;
|
||||
setTimeout(() => {
|
||||
this.phoneError = false;
|
||||
}, 2000);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this.deliveryAddress.address == '') {
|
||||
this.addrVisible = true;
|
||||
setTimeout(() => {
|
||||
this.addrVisible = false;
|
||||
}, 2000);
|
||||
return;
|
||||
}
|
||||
import Footer from '../components/Footer.vue';
|
||||
export default {
|
||||
name: 'AddUserAddress',
|
||||
data() {
|
||||
return {
|
||||
businessId: this.$route.query.businessId,
|
||||
user: {},
|
||||
addressInfo: '',
|
||||
deliveryAddress: {
|
||||
contactName: '',
|
||||
contactSex: 1,
|
||||
contactTel: '',
|
||||
address: ''
|
||||
},
|
||||
nameVisible: false,
|
||||
phoneVisible: false,
|
||||
phoneError: false,
|
||||
addrVisible: false
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.user = this.$getSessionStorage('user');
|
||||
},
|
||||
components: {
|
||||
Footer
|
||||
},
|
||||
methods: {
|
||||
back() {
|
||||
this.$router.go(-1);
|
||||
},
|
||||
addUserAddress() {
|
||||
if (this.deliveryAddress.contactName == '') {
|
||||
this.nameVisible = true;
|
||||
setTimeout(() => {
|
||||
this.nameVisible = false;
|
||||
}, 2000);
|
||||
return;
|
||||
}
|
||||
if (this.deliveryAddress.contactTel == '') {
|
||||
this.phoneVisible = true;
|
||||
setTimeout(() => {
|
||||
this.phoneVisible = false;
|
||||
}, 2000);
|
||||
return;
|
||||
} else {
|
||||
const contactTelString = this.deliveryAddress.contactTel.toString();
|
||||
if (contactTelString.length === 11 && !isNaN(contactTelString) && contactTelString.startsWith('1')) {
|
||||
// 数字以1开头,有11位,且全为数字
|
||||
} else {
|
||||
this.phoneError = true;
|
||||
setTimeout(() => {
|
||||
this.phoneError = false;
|
||||
}, 2000);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this.deliveryAddress.address == '') {
|
||||
this.addrVisible = true;
|
||||
setTimeout(() => {
|
||||
this.addrVisible = false;
|
||||
}, 2000);
|
||||
return;
|
||||
}
|
||||
|
||||
let url=`DeliveryAddressController/saveDeliveryAddress/${this.deliveryAddress.contactName}/${this.deliveryAddress.contactSex}/${this.deliveryAddress.contactTel}/${this.deliveryAddress.address}/${this.user.userId}`
|
||||
this.$axios.post(url).then(response => {
|
||||
if (response.data.result > 0) {
|
||||
this.$router.push({
|
||||
path: '/userAddress',
|
||||
query: {
|
||||
businessId: this.businessId
|
||||
}
|
||||
});
|
||||
} else {
|
||||
alert('新增地址失败!');
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
},
|
||||
fill() {
|
||||
this.$axios.get('DeliveryAddressController/AddressInfo',{
|
||||
params:{
|
||||
addressInfo: this.addressInfo
|
||||
}
|
||||
}).then(response => {
|
||||
this.deliveryAddress.contactName = response.data[0];
|
||||
this.deliveryAddress.contactTel = response.data[1];
|
||||
this.deliveryAddress.address = response.data[2];
|
||||
}).catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
let url =
|
||||
`DeliveryAddressController/saveDeliveryAddress/${this.deliveryAddress.contactName}/${this.deliveryAddress.contactSex}/${this.deliveryAddress.contactTel}/${this.deliveryAddress.address}/${this.user.userId}`
|
||||
this.$axios.post(url).then(response => {
|
||||
if (response.data.result > 0) {
|
||||
this.$router.push({
|
||||
path: '/userAddress',
|
||||
query: {
|
||||
businessId: this.businessId
|
||||
}
|
||||
});
|
||||
} else {
|
||||
alert('新增地址失败!');
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
},
|
||||
fill() {
|
||||
this.$axios.get('DeliveryAddressController/AddressInfo', {
|
||||
params: {
|
||||
addressInfo: this.addressInfo
|
||||
}
|
||||
}).then(response => {
|
||||
this.deliveryAddress.contactName = response.data[0];
|
||||
this.deliveryAddress.contactTel = response.data[1];
|
||||
this.deliveryAddress.address = response.data[2];
|
||||
}).catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
/****************** 总容器 ******************/
|
||||
.wrapper {
|
||||
width: 100vw;
|
||||
position: absolute;
|
||||
}
|
||||
/****************** 总容器 ******************/
|
||||
.wrapper {
|
||||
width: 100vw;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
/******head部分********/
|
||||
.wrapper header {
|
||||
width: 100%;
|
||||
height: 12vw;
|
||||
background-color: #01B0F2;
|
||||
font-size: 4.8vw;
|
||||
color: #fff;
|
||||
/******head部分********/
|
||||
.wrapper header {
|
||||
width: 100%;
|
||||
height: 12vw;
|
||||
background-color: #01B0F2;
|
||||
font-size: 5.5vw;
|
||||
color: #fff;
|
||||
z-index: 10;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
z-index: 10;
|
||||
.wrapper header i {
|
||||
margin-right: 3vw;
|
||||
font-size: 7vw;
|
||||
user-select: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.wrapper header i {
|
||||
margin: 0vw 0vw 0vw 3vw;
|
||||
font-size: 6vw;
|
||||
user-select: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.wrapper header p {
|
||||
margin: 0vw 0vw 0vw 33.5vw;
|
||||
}
|
||||
|
||||
.wrapper .shangbiao {
|
||||
width:100vw;
|
||||
height: 20vw;
|
||||
margin-top: 20vw;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.wrapper .shangbiao img{
|
||||
width: 30vw;
|
||||
height: 25vw;
|
||||
}
|
||||
|
||||
/*******自动识别********/
|
||||
.wrapper .identify {
|
||||
width: 100vw;
|
||||
height: 18vw;
|
||||
|
||||
margin-top: 2vw;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.wrapper .identify input {
|
||||
width: 70%;
|
||||
height: 8vw;
|
||||
font-size: 4vw;
|
||||
background-color: #d4ebfe;
|
||||
border-radius: 2.5vw;
|
||||
outline: none;
|
||||
border-style: dotted;
|
||||
}
|
||||
|
||||
.wrapper .identify button{
|
||||
width: 14vw;
|
||||
height: 8vw;
|
||||
border-radius: 3vw;
|
||||
margin-left: 3vw;
|
||||
}
|
||||
|
||||
.wrapper .identify button p{
|
||||
font-size: 3.5vw;
|
||||
}
|
||||
.wrapper header p {
|
||||
margin-left: 3vw;
|
||||
}
|
||||
|
||||
|
||||
/******列表******/
|
||||
.wrapper .form{
|
||||
width: 100vw;
|
||||
margin-top: 2vw;
|
||||
}
|
||||
.wrapper .shangbiao {
|
||||
width: 100vw;
|
||||
height: 20vw;
|
||||
margin-top: 14vw;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.wrapper .form li {
|
||||
box-sizing: border-box;
|
||||
padding: 4vw 3vw 0 3vw;
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.wrapper .shangbiao img {
|
||||
width: 30vw;
|
||||
height: 25vw;
|
||||
}
|
||||
|
||||
.wrapper .form li .title {
|
||||
flex: 0 0 18vw;
|
||||
font-size: 4vw;
|
||||
font-weight: 450;
|
||||
color: #666;
|
||||
margin-left: 5vw;
|
||||
}
|
||||
/*******自动识别********/
|
||||
.wrapper .identify {
|
||||
width: 100vw;
|
||||
height: 18vw;
|
||||
|
||||
.wrapper .form li .content {
|
||||
flex: 1;
|
||||
}
|
||||
margin-top: 2vw;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.wrapper .form li .content input {
|
||||
outline: none;
|
||||
width: 90%;
|
||||
height: 7vw;
|
||||
font-size: 3.5vw;
|
||||
}
|
||||
.wrapper .identify input {
|
||||
width: 80%;
|
||||
height: 10vw;
|
||||
font-size: 4.5vw;
|
||||
background-color: #d4ebfe;
|
||||
border-radius: 5vw;
|
||||
outline: none;
|
||||
border: none;
|
||||
padding: 0 2vw;
|
||||
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.wrapper .form li .gender {
|
||||
width: 100vw;
|
||||
height: 6vw;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
.wrapper .identify button {
|
||||
width: 16vw;
|
||||
height: 10vw;
|
||||
border-radius: 5vw;
|
||||
margin-left: 3vw;
|
||||
background-color: #01B0F2;
|
||||
border: none;
|
||||
outline: none;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.wrapper .identify button p {
|
||||
font-size: 4vw;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.wrapper .identify button:hover {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******确认修改********/
|
||||
.wrapper .ok{
|
||||
height: 20vw;
|
||||
width: 100vw;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
/******列表******/
|
||||
.wrapper .form {
|
||||
width: 100vw;
|
||||
margin-top: 2vw;
|
||||
}
|
||||
|
||||
.wrapper .ok button{
|
||||
width: 35vw;
|
||||
height: 8vw;
|
||||
border-radius: 3vw;
|
||||
margin-left: 3vw;
|
||||
background-color: #4ba0fa;
|
||||
border: none;
|
||||
margin-top: 8vw;
|
||||
}
|
||||
.wrapper .form li {
|
||||
box-sizing: border-box;
|
||||
padding: 3vw 3vw 0 3vw;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.wrapper .ok p{
|
||||
font-size: 4vw;
|
||||
color: #fff;
|
||||
font-weight: 800;
|
||||
}
|
||||
.wrapper .form li .title {
|
||||
flex: 0 0 20vw;
|
||||
font-size: 4.5vw;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
margin-left: 3vw;
|
||||
}
|
||||
|
||||
.wrapper .form li .content {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.wrapper .form li .content input {
|
||||
outline: none;
|
||||
width: 90%;
|
||||
height: 7vw;
|
||||
font-size: 4vw;
|
||||
border: none;
|
||||
border-bottom: 1px solid #ccc;
|
||||
}
|
||||
|
||||
.wrapper .form li .gender {
|
||||
width: 100vw;
|
||||
height: 6vw;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.wrapper .ok {
|
||||
height: 20vw;
|
||||
width: 100vw;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.wrapper .ok button {
|
||||
width: 35vw;
|
||||
height: 10vw;
|
||||
border-radius: 5vw;
|
||||
background-color: #4ba0fa;
|
||||
border: none;
|
||||
margin-top: 6vw;
|
||||
font-size: 4.5vw;
|
||||
font-weight: 600;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.wrapper .ok button:hover {
|
||||
background-color: #3687d8;
|
||||
}
|
||||
</style>
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,204 +1,236 @@
|
|||
<template>
|
||||
<div class="wrapper">
|
||||
<div class="wrapper">
|
||||
|
||||
<!-- header部分 -->
|
||||
<header>
|
||||
<i class="fa fa-angle-left" @click="back"></i>
|
||||
<p>商家列表</p>
|
||||
</header>
|
||||
<!-- header部分 -->
|
||||
<header>
|
||||
<i class="fa fa-angle-left" @click="back"></i>
|
||||
<p>商家列表</p>
|
||||
</header>
|
||||
|
||||
<!-- 商家列表部分 -->
|
||||
<ul class="business">
|
||||
<!-- 商家列表部分 -->
|
||||
<ul class="business">
|
||||
|
||||
<li v-for="item in businessArr" @click="toBusinessInfo(item.businessId)">
|
||||
<div class="border">
|
||||
<div class="business-img">
|
||||
<img :src="item.businessImg">
|
||||
<div class="business-img-quantity" v-show="item.quantity>0">{{item.quantity}}</div>
|
||||
</div>
|
||||
<div class="business-info">
|
||||
<h3>{{item.businessName}}</h3>
|
||||
<p>¥{{item.starPrice}}起送 | ¥{{item.deliveryPrice}}配送</p>
|
||||
<p>{{item.businessExplain}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li v-for="item in businessArr" @click="toBusinessInfo(item.businessId)">
|
||||
<div class="border">
|
||||
<div class="business-img">
|
||||
<img :src="item.businessImg">
|
||||
<div class="business-img-quantity" v-show="item.quantity>0">{{item.quantity}}</div>
|
||||
</div>
|
||||
<div class="business-info">
|
||||
<h3>{{item.businessName}}</h3>
|
||||
<p>¥{{item.starPrice}}起送 | ¥{{item.deliveryPrice}}配送</p>
|
||||
<p>{{item.businessExplain}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
<Footer></Footer>
|
||||
</div>
|
||||
<Footer></Footer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Footer from '../components/Footer.vue';
|
||||
import Footer from '../components/Footer.vue';
|
||||
|
||||
export default {
|
||||
name: 'BusinessList',
|
||||
data() {
|
||||
return {
|
||||
orderTypeId: this.$route.query.orderTypeId,
|
||||
businessArr: [],
|
||||
user: {}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.user = this.$getSessionStorage('user');
|
||||
export default {
|
||||
name: 'BusinessList',
|
||||
data() {
|
||||
return {
|
||||
orderTypeId: this.$route.query.orderTypeId,
|
||||
businessArr: [],
|
||||
user: {}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.user = this.$getSessionStorage('user');
|
||||
|
||||
//根据orderTypeId查询商家信息
|
||||
let url=`BusinessController/listBusinessByOrderTypeId/${this.orderTypeId}`
|
||||
this.$axios.get(url).then(response => {
|
||||
this.businessArr = response.data.result;
|
||||
console.log(response.data.message);
|
||||
//判断是否登录
|
||||
if (this.user != null) {
|
||||
this.listCart();
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
},
|
||||
components: {
|
||||
Footer
|
||||
},
|
||||
methods: {
|
||||
back() {
|
||||
this.$router.go(-1);
|
||||
},
|
||||
listCart() {
|
||||
let url=`CartController/listCart/${this.user.userId}`
|
||||
this.$axios.get(url).then(response => {
|
||||
let cartArr = response.data.result;
|
||||
//遍历所有食品列表
|
||||
for (let businessItem of this.businessArr) {
|
||||
businessItem.quantity = 0;
|
||||
for (let cartItem of cartArr) {
|
||||
if (cartItem.businessId == businessItem.businessId) {
|
||||
businessItem.quantity += cartItem.quantity;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.businessArr.sort();
|
||||
}).catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
},
|
||||
//根据orderTypeId查询商家信息
|
||||
let url = `BusinessController/listBusinessByOrderTypeId/${this.orderTypeId}`
|
||||
this.$axios.get(url).then(response => {
|
||||
this.businessArr = response.data.result;
|
||||
console.log(response.data.message);
|
||||
//判断是否登录
|
||||
if (this.user != null) {
|
||||
this.listCart();
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
},
|
||||
components: {
|
||||
Footer
|
||||
},
|
||||
methods: {
|
||||
back() {
|
||||
this.$router.go(-1);
|
||||
},
|
||||
listCart() {
|
||||
let url = `CartController/listCart/${this.user.userId}`
|
||||
this.$axios.get(url).then(response => {
|
||||
let cartArr = response.data.result;
|
||||
//遍历所有食品列表
|
||||
for (let businessItem of this.businessArr) {
|
||||
businessItem.quantity = 0;
|
||||
for (let cartItem of cartArr) {
|
||||
if (cartItem.businessId == businessItem.businessId) {
|
||||
businessItem.quantity += cartItem.quantity;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.businessArr.sort();
|
||||
}).catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
},
|
||||
|
||||
toBusinessInfo(businessId) {
|
||||
this.$router.push({
|
||||
path: '/businessInfo',
|
||||
query: {
|
||||
businessId: businessId
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
toBusinessInfo(businessId) {
|
||||
this.$router.push({
|
||||
path: '/businessInfo',
|
||||
query: {
|
||||
businessId: businessId
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/****************总容器***************/
|
||||
.wrapper {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
/****************总容器***************/
|
||||
.wrapper {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
/****************header部分***************/
|
||||
.wrapper header {
|
||||
width: 100%;
|
||||
height: 12vw;
|
||||
background-color: #01B0F2;
|
||||
font-size: 4.8vw;
|
||||
color: #fff;
|
||||
/****************header部分***************/
|
||||
.wrapper header {
|
||||
width: 100%;
|
||||
height: 12vw;
|
||||
background-color: #01B0F2;
|
||||
font-size: 4.8vw;
|
||||
color: #fff;
|
||||
|
||||
z-index: 10;
|
||||
z-index: 10;
|
||||
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.wrapper header i {
|
||||
margin: 0vw 0vw 0vw 3vw;
|
||||
font-size: 6vw;
|
||||
user-select: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
.wrapper header i {
|
||||
margin: 0vw 0vw 0vw 3vw;
|
||||
font-size: 6vw;
|
||||
user-select: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.wrapper header p {
|
||||
margin: 0vw 0vw 0vw 33.5vw;
|
||||
}
|
||||
.wrapper header p {
|
||||
margin: 0vw 0vw 0vw 33.5vw;
|
||||
}
|
||||
|
||||
/****************商家列表部分***************/
|
||||
.wrapper .business {
|
||||
width: 100%;
|
||||
margin-top: 12vw;
|
||||
padding-bottom: 14vw;
|
||||
}
|
||||
/****************商家列表部分***************/
|
||||
.wrapper .business {
|
||||
width: 100%;
|
||||
margin-top: 12vw;
|
||||
padding-bottom: 14vw;
|
||||
}
|
||||
|
||||
.wrapper .business li {
|
||||
width: 100%;
|
||||
padding: 2vw 2vw 0vw 2vw;
|
||||
background-color: #F4F8Fb;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.wrapper .business li {
|
||||
width: 100%;
|
||||
padding: 2vw 2vw 0vw 2vw;
|
||||
background-color: #F4F8Fb;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.wrapper .business li .border {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 2vw;
|
||||
user-select: none;
|
||||
background-color: #fff;
|
||||
cursor: pointer;
|
||||
border-radius: 2vw;
|
||||
.wrapper .business li .border {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 2vw;
|
||||
user-select: none;
|
||||
background-color: #fff;
|
||||
cursor: pointer;
|
||||
border-radius: 2vw;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
animation: fadeIn 1.0s ease forwards;
|
||||
opacity: 0;
|
||||
/* 初始透明度为0 */
|
||||
transition: background-color 0.3s, transform 0.3s;
|
||||
}
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.wrapper .business li:hover .border {
|
||||
background-color: #E0F2FE;
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.wrapper .business li .border .business-img {
|
||||
position: relative;
|
||||
}
|
||||
.wrapper .business li:active .border {
|
||||
border: 2px solid #FF5722;
|
||||
transform: scale(0.95);
|
||||
}
|
||||
|
||||
.wrapper .business li .border .business-img img {
|
||||
width: 20vw;
|
||||
height: 20vw;
|
||||
border-radius: 2vw;
|
||||
}
|
||||
@keyframes fadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.wrapper .business li .border .business-img .business-img-quantity {
|
||||
width: 5vw;
|
||||
height: 5vw;
|
||||
background-color: red;
|
||||
color: #fff;
|
||||
font-size: 3.6vw;
|
||||
border-radius: 2.5vw;
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
.wrapper .business li .border .business-img {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
position: absolute;
|
||||
right: -1.5vw;
|
||||
top: -1.5vw;
|
||||
}
|
||||
.wrapper .business li .border .business-img img {
|
||||
width: 20vw;
|
||||
height: 20vw;
|
||||
border-radius: 2vw;
|
||||
transition: transform 0.3s;
|
||||
}
|
||||
|
||||
.wrapper .business li .border .business-info {
|
||||
margin-left: 3vw;
|
||||
}
|
||||
.wrapper .business li .border:hover .business-img img {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
.wrapper .business li .border .business-info h3 {
|
||||
font-size: 3.8vw;
|
||||
color: #555;
|
||||
}
|
||||
.wrapper .business li .border:active .business-img img {
|
||||
transform: scale(0.9);
|
||||
}
|
||||
|
||||
.wrapper .business li .border .business-info p {
|
||||
font-size: 3vw;
|
||||
color: #888;
|
||||
margin-top: 2vw;
|
||||
}
|
||||
.wrapper .business li .border .business-img .business-img-quantity {
|
||||
width: 5vw;
|
||||
height: 5vw;
|
||||
background-color: red;
|
||||
color: #fff;
|
||||
font-size: 3.6vw;
|
||||
border-radius: 2.5vw;
|
||||
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
position: absolute;
|
||||
right: -1.5vw;
|
||||
top: -1.5vw;
|
||||
}
|
||||
|
||||
.wrapper .business li .border .business-info {
|
||||
margin-left: 3vw;
|
||||
}
|
||||
|
||||
.wrapper .business li .border .business-info h3 {
|
||||
font-size: 3.8vw;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.wrapper .business li .border .business-info p {
|
||||
font-size: 3vw;
|
||||
color: #888;
|
||||
margin-top: 2vw;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1,271 +1,272 @@
|
|||
<template>
|
||||
<div class="wrapper">
|
||||
<!-- header部分 -->
|
||||
<header>
|
||||
<i class="fa fa-angle-left" @click="back"></i>
|
||||
<p>消费券选择</p>
|
||||
</header>
|
||||
<!-- 地址列表部分 -->
|
||||
<ul class="addresslist">
|
||||
<li v-for="item in CouponList">
|
||||
<!-- <div class="addresslist-left" @click="setDeliveryAddress(item)">
|
||||
<h3>{{item.contactName}}{{getSexText(item.contactSex)}} {{item.contactTel}}
|
||||
</h3>
|
||||
<p>{{item.address}}</p>
|
||||
</div>
|
||||
<div class="addresslist-right">
|
||||
<i class="fa fa-edit" @click="editUserAddress(item.daId)"></i>
|
||||
<i class="fa fa-remove" @click="removeUserAddress(item.daId)"></i>
|
||||
</div> -->
|
||||
<div class="Coupon-Intro" @click="useThisCoupon(item)">
|
||||
<p class="Coupon-Name">满{{item.limitNum}}减{{item.minusNum}}优惠券</p>
|
||||
<p class="Coupon-Outdate">有效日期:{{item.outDate}}</p>
|
||||
</div>
|
||||
</li>
|
||||
<div class="wrapper">
|
||||
<!-- header部分 -->
|
||||
<header>
|
||||
<i class="fa fa-angle-left" @click="back"></i>
|
||||
<p>消费券选择</p>
|
||||
</header>
|
||||
<!-- 地址列表部分 -->
|
||||
<ul class="addresslist">
|
||||
<li v-for="item in CouponList" v-show="this.totalPrice>=item.limitNum">
|
||||
<!-- <div class="addresslist-left" @click="setDeliveryAddress(item)">
|
||||
<h3>{{item.contactName}}{{getSexText(item.contactSex)}} {{item.contactTel}}
|
||||
</h3>
|
||||
<p>{{item.address}}</p>
|
||||
</div>
|
||||
<div class="addresslist-right">
|
||||
<i class="fa fa-edit" @click="editUserAddress(item.daId)"></i>
|
||||
<i class="fa fa-remove" @click="removeUserAddress(item.daId)"></i>
|
||||
</div> -->
|
||||
<div class="Coupon-Intro" @click="useThisCoupon(item)">
|
||||
<p class="Coupon-Name">满{{item.limitNum}}减{{item.minusNum}}优惠券</p>
|
||||
<p class="Coupon-Outdate">有效日期:{{item.outDate}}</p>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<div class="Coupon-Intro" @click="notUseCoupon()">
|
||||
<p class="Coupon-Name">不使用消费券</p>
|
||||
<p class="Coupon-Outdate">-</p>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- 新增地址部分 -->
|
||||
<!-- <div class="addbtn" @click="toAddUserAddress">
|
||||
<i class="fa fa-plus-circle"></i>
|
||||
<p>新增收货地址</p>
|
||||
</div> -->
|
||||
<!-- 底部菜单部分 -->
|
||||
<Footer></Footer>
|
||||
</div>
|
||||
<li>
|
||||
<div class="Coupon-Intro" @click="notUseCoupon()">
|
||||
<p class="Coupon-Name">不使用消费券</p>
|
||||
<p class="Coupon-Outdate">-</p>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- 新增地址部分 -->
|
||||
<!-- <div class="addbtn" @click="toAddUserAddress">
|
||||
<i class="fa fa-plus-circle"></i>
|
||||
<p>新增收货地址</p>
|
||||
</div> -->
|
||||
<!-- 底部菜单部分 -->
|
||||
<Footer></Footer>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import Footer from '../components/Footer.vue';
|
||||
import Footer from '../components/Footer.vue';
|
||||
|
||||
export default {
|
||||
name: 'UserAddress',
|
||||
data() {
|
||||
return {
|
||||
businessId: this.$route.query.businessId,
|
||||
user: {},
|
||||
deliveryAddressArr: [],
|
||||
CouponList:[],
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.user = this.$getSessionStorage('user');
|
||||
export default {
|
||||
name: 'UserAddress',
|
||||
data() {
|
||||
return {
|
||||
businessId: this.$route.query.businessId,
|
||||
user: {},
|
||||
deliveryAddressArr: [],
|
||||
CouponList:[],
|
||||
totalPrice:this.$route.query.totalPrice,
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.user = this.$getSessionStorage('user');
|
||||
|
||||
this.listDeliveryAddressByUserId();
|
||||
this.getCouponByUserId(this.user.userId);
|
||||
},
|
||||
components: {
|
||||
Footer
|
||||
},
|
||||
methods: {
|
||||
back() {
|
||||
this.$router.go(-1);
|
||||
},
|
||||
getSexText(sex) {
|
||||
return sex === 1 ? '先生' : '女士';
|
||||
},
|
||||
listDeliveryAddressByUserId() {
|
||||
//查询送货地址
|
||||
let url=`DeliveryAddressController/listDeliveryAddressByUserId/${this.user.userId}`
|
||||
this.$axios.get(url).then(response => {
|
||||
this.deliveryAddressArr = response.data.result;
|
||||
}).catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
},
|
||||
setDeliveryAddress(deliveryAddress) {
|
||||
//把用户选择的默认送货地址存储到localStorage中
|
||||
this.$setLocalStorage(this.user.userId, deliveryAddress);
|
||||
this.$router.push({
|
||||
path: '/orders',
|
||||
query: {
|
||||
businessId: this.businessId
|
||||
}
|
||||
});
|
||||
},
|
||||
toAddUserAddress() {
|
||||
this.$router.push({
|
||||
path: '/addUserAddress',
|
||||
query: {
|
||||
businessId: this.businessId
|
||||
}
|
||||
});
|
||||
},
|
||||
editUserAddress(daId) {
|
||||
this.$router.push({
|
||||
path: '/editUserAddress',
|
||||
query: {
|
||||
businessId: this.businessId,
|
||||
daId: daId
|
||||
}
|
||||
});
|
||||
},
|
||||
removeUserAddress(daId) {
|
||||
if (!confirm('确认要删除此送货地址吗?')) {
|
||||
return;
|
||||
}
|
||||
let url=`DeliveryAddressController/removeDeliveryAddress/${daId}`
|
||||
this.$axios.delete(url).then(response => {
|
||||
if (response.data.result > 0) {
|
||||
let deliveryAddress = this.$getLocalStorage(this.user.userId);
|
||||
if (deliveryAddress != null && deliveryAddress.daId == daId) {
|
||||
this.$removeLocalStorage(this.user.userId);
|
||||
}
|
||||
this.listDeliveryAddressByUserId();
|
||||
} else {
|
||||
alert('删除地址失败!');
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
},
|
||||
getCouponByUserId(userId)
|
||||
{
|
||||
this.$axios.get(`CouponController/getCouponByUserId/${userId}`).then(response =>{
|
||||
this.CouponList=response.data.result;
|
||||
})
|
||||
},
|
||||
useThisCoupon(Coupon)
|
||||
{
|
||||
this.$setLocalStorage(this.$route.query.businessId,Coupon);
|
||||
this.$router.push({
|
||||
path: '/orders',
|
||||
query: {
|
||||
businessId: this.businessId
|
||||
}
|
||||
});
|
||||
},
|
||||
notUseCoupon()
|
||||
{
|
||||
this.listDeliveryAddressByUserId();
|
||||
this.getCouponByUserId(this.user.userId);
|
||||
},
|
||||
components: {
|
||||
Footer
|
||||
},
|
||||
methods: {
|
||||
back() {
|
||||
this.$router.go(-1);
|
||||
},
|
||||
getSexText(sex) {
|
||||
return sex === 1 ? '先生' : '女士';
|
||||
},
|
||||
listDeliveryAddressByUserId() {
|
||||
//查询送货地址
|
||||
let url=`DeliveryAddressController/listDeliveryAddressByUserId/${this.user.userId}`
|
||||
this.$axios.get(url).then(response => {
|
||||
this.deliveryAddressArr = response.data.result;
|
||||
}).catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
},
|
||||
setDeliveryAddress(deliveryAddress) {
|
||||
//把用户选择的默认送货地址存储到localStorage中
|
||||
this.$setLocalStorage(this.user.userId, deliveryAddress);
|
||||
this.$router.push({
|
||||
path: '/orders',
|
||||
query: {
|
||||
businessId: this.businessId
|
||||
}
|
||||
});
|
||||
},
|
||||
toAddUserAddress() {
|
||||
this.$router.push({
|
||||
path: '/addUserAddress',
|
||||
query: {
|
||||
businessId: this.businessId
|
||||
}
|
||||
});
|
||||
},
|
||||
editUserAddress(daId) {
|
||||
this.$router.push({
|
||||
path: '/editUserAddress',
|
||||
query: {
|
||||
businessId: this.businessId,
|
||||
daId: daId
|
||||
}
|
||||
});
|
||||
},
|
||||
removeUserAddress(daId) {
|
||||
if (!confirm('确认要删除此送货地址吗?')) {
|
||||
return;
|
||||
}
|
||||
let url=`DeliveryAddressController/removeDeliveryAddress/${daId}`
|
||||
this.$axios.delete(url).then(response => {
|
||||
if (response.data.result > 0) {
|
||||
let deliveryAddress = this.$getLocalStorage(this.user.userId);
|
||||
if (deliveryAddress != null && deliveryAddress.daId == daId) {
|
||||
this.$removeLocalStorage(this.user.userId);
|
||||
}
|
||||
this.listDeliveryAddressByUserId();
|
||||
} else {
|
||||
alert('删除地址失败!');
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
},
|
||||
getCouponByUserId(userId)
|
||||
{
|
||||
this.$axios.get(`CouponController/getCouponByUserId/${userId}`).then(response =>{
|
||||
this.CouponList=response.data.result;
|
||||
})
|
||||
},
|
||||
useThisCoupon(Coupon)
|
||||
{
|
||||
this.$setLocalStorage(this.$route.query.businessId,Coupon);
|
||||
this.$router.push({
|
||||
path: '/orders',
|
||||
query: {
|
||||
businessId: this.businessId
|
||||
}
|
||||
});
|
||||
},
|
||||
notUseCoupon()
|
||||
{
|
||||
|
||||
this.$setLocalStorage(this.$route.query.businessId,null)
|
||||
this.$router.push({
|
||||
path: '/orders',
|
||||
query: {
|
||||
businessId: this.businessId
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
this.$setLocalStorage(this.$route.query.businessId,null)
|
||||
this.$router.push({
|
||||
path: '/orders',
|
||||
query: {
|
||||
businessId: this.businessId
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
/*************** 总容器 ***************/
|
||||
.wrapper {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: #F5F5F5;
|
||||
}
|
||||
/*************** 总容器 ***************/
|
||||
.wrapper {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: #F5F5F5;
|
||||
}
|
||||
|
||||
/*************** header ***************/
|
||||
.wrapper header {
|
||||
width: 100%;
|
||||
height: 12vw;
|
||||
background-color: #01B0F2;
|
||||
font-size: 4.8vw;
|
||||
color: #fff;
|
||||
/*************** header ***************/
|
||||
.wrapper header {
|
||||
width: 100%;
|
||||
height: 12vw;
|
||||
background-color: #01B0F2;
|
||||
font-size: 4.8vw;
|
||||
color: #fff;
|
||||
|
||||
z-index: 10;
|
||||
z-index: 10;
|
||||
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.wrapper header i {
|
||||
margin: 0vw 0vw 0vw 3vw;
|
||||
font-size: 6vw;
|
||||
user-select: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
.wrapper header i {
|
||||
margin: 0vw 0vw 0vw 3vw;
|
||||
font-size: 6vw;
|
||||
user-select: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.wrapper header p {
|
||||
margin: 0vw 0vw 0vw 33.5vw;
|
||||
}
|
||||
.wrapper header p {
|
||||
margin: 0vw 0vw 0vw 33.5vw;
|
||||
}
|
||||
|
||||
|
||||
/*************** addresslist ***************/
|
||||
.wrapper .addresslist {
|
||||
width: 100%;
|
||||
padding-top: 12vw;
|
||||
background-color: #fff;
|
||||
}
|
||||
/*************** addresslist ***************/
|
||||
.wrapper .addresslist {
|
||||
width: 100%;
|
||||
padding-top: 12vw;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.wrapper .addresslist li {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
border-bottom: solid 1px #DDD;
|
||||
padding: 3vw;
|
||||
display: flex;
|
||||
}
|
||||
.wrapper .addresslist li {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
border-bottom: solid 1px #DDD;
|
||||
padding: 3vw;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.wrapper .addresslist li .addresslist-left {
|
||||
flex: 5;
|
||||
/*左边这块区域是可以点击的*/
|
||||
user-select: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
.wrapper .addresslist li .addresslist-left {
|
||||
flex: 5;
|
||||
/*左边这块区域是可以点击的*/
|
||||
user-select: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.wrapper .addresslist li .addresslist-left h3 {
|
||||
font-size: 4.6vw;
|
||||
font-weight: 300;
|
||||
color: #666;
|
||||
}
|
||||
.wrapper .addresslist li .addresslist-left h3 {
|
||||
font-size: 4.6vw;
|
||||
font-weight: 300;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.wrapper .addresslist li .addresslist-left p {
|
||||
font-size: 4vw;
|
||||
color: #666;
|
||||
}
|
||||
.wrapper .addresslist li .addresslist-left p {
|
||||
font-size: 4vw;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.wrapper .addresslist li .addresslist-right {
|
||||
flex: 1;
|
||||
font-size: 5.6vw;
|
||||
color: #999;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
}
|
||||
.wrapper .addresslist li .addresslist-right {
|
||||
flex: 1;
|
||||
font-size: 5.6vw;
|
||||
color: #999;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/*************** 新增地址部分 ***************/
|
||||
.wrapper .addbtn {
|
||||
width: 100%;
|
||||
height: 14vw;
|
||||
border-top: solid 1px #DDD;
|
||||
border-bottom: solid 1px #DDD;
|
||||
background-color: #fff;
|
||||
margin-top: 4vw;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-size: 4.5vw;
|
||||
color: #01B0F2;
|
||||
user-select: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
/*************** 新增地址部分 ***************/
|
||||
.wrapper .addbtn {
|
||||
width: 100%;
|
||||
height: 14vw;
|
||||
border-top: solid 1px #DDD;
|
||||
border-bottom: solid 1px #DDD;
|
||||
background-color: #fff;
|
||||
margin-top: 4vw;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-size: 4.5vw;
|
||||
color: #01B0F2;
|
||||
user-select: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-left: 2vw;
|
||||
}
|
||||
p {
|
||||
margin-left: 2vw;
|
||||
}
|
||||
|
||||
.wrapper .Coupon-Intro{
|
||||
cursor: pointer;
|
||||
width: 100%;
|
||||
height: 16vw;
|
||||
box-sizing: border-box;
|
||||
padding: 3vw;
|
||||
color: #666;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-size: 3.5vw;
|
||||
}
|
||||
.wrapper .Coupon-Intro{
|
||||
cursor: pointer;
|
||||
width: 100%;
|
||||
height: 16vw;
|
||||
box-sizing: border-box;
|
||||
padding: 3vw;
|
||||
color: #666;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-size: 3.5vw;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -44,7 +44,7 @@
|
|||
<!-- 合计部分 -->
|
||||
<div class="total">
|
||||
<div class="total-left">
|
||||
¥{{ totalPrice }}
|
||||
¥{{ finalPrice }}
|
||||
</div>
|
||||
<div class="box">
|
||||
<div class="total-right" @click="toPayment">
|
||||
|
|
@ -66,10 +66,14 @@ export default {
|
|||
cartArr: [],
|
||||
deliveryaddress: {},
|
||||
availablePointArr: [],
|
||||
couponUsed: {}
|
||||
couponUsed: {},
|
||||
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// 首先初始化finalPrice
|
||||
// finalPrice=totalPrice;
|
||||
|
||||
this.user = this.$getSessionStorage('user');
|
||||
this.deliveryaddress = this.$getLocalStorage(this.user.userId);
|
||||
this.couponUsed = this.$getLocalStorage(this.businessId);
|
||||
|
|
@ -96,13 +100,25 @@ export default {
|
|||
totalPrice += cartItem.food.foodPrice * cartItem.quantity;
|
||||
}
|
||||
totalPrice += this.business.deliveryPrice;
|
||||
|
||||
//积分券包界面新增
|
||||
// if (this.couponUsed != null) {
|
||||
// totalPrice -= this.couponUsed.minusNum;
|
||||
// }
|
||||
return totalPrice;
|
||||
},
|
||||
finalPrice() {
|
||||
let totalPrice = 0;
|
||||
for (let cartItem of this.cartArr) {
|
||||
totalPrice += cartItem.food.foodPrice * cartItem.quantity;
|
||||
}
|
||||
totalPrice += this.business.deliveryPrice;
|
||||
//积分券包界面新增
|
||||
if (this.couponUsed != null) {
|
||||
totalPrice -= this.couponUsed.minusNum;
|
||||
}
|
||||
return totalPrice;
|
||||
}
|
||||
|
||||
},
|
||||
methods: {
|
||||
back() {
|
||||
|
|
@ -126,25 +142,30 @@ export default {
|
|||
}
|
||||
|
||||
//创建订单
|
||||
|
||||
let url = `OrdersController/createOrders/${this.user.userId}/${this.businessId}/${this.deliveryaddress.daId}/${this.totalPrice}`
|
||||
let finalPrice = this.totalPrice;
|
||||
if (this.couponUsed != null) {
|
||||
finalPrice -= this.couponUsed.minusNum;
|
||||
}
|
||||
let url =
|
||||
`OrdersController/createOrders/${this.user.userId}/${this.businessId}/${this.deliveryaddress.daId}/${this.finalPrice}`
|
||||
this.$axios.post(url).then(response => {
|
||||
let orderId = response.data.result;
|
||||
if (orderId > 0) {
|
||||
//积分系统新增代码
|
||||
if (this.couponUsed != null) {
|
||||
this.$axios.delete(`CouponController/deleteCouponByCouponId/${this.couponUsed.couponId}`);
|
||||
this.$axios.delete(
|
||||
`CouponController/deleteCouponByCouponId/${this.couponUsed.couponId}`);
|
||||
}
|
||||
this.$router.push({
|
||||
path: '/payment',
|
||||
query: {
|
||||
orderId: orderId,
|
||||
userId: this.user.userId,
|
||||
reduction: this.couponUsed===null?0:this.couponUsed.minusNum
|
||||
reduction: this.couponUsed === null ? 0 : this.couponUsed.minusNum
|
||||
}
|
||||
});
|
||||
this.$removeSessionStorage(this.businessId);
|
||||
|
||||
this.$setLocalStorage(this.businessId,null);
|
||||
console.log("this.$removeSessionStorage(this.businessId)");
|
||||
} else {
|
||||
alert('创建订单失败!');
|
||||
}
|
||||
|
|
@ -153,13 +174,13 @@ export default {
|
|||
});
|
||||
},
|
||||
toCouponSelect() {
|
||||
this.$router.push(
|
||||
{
|
||||
path: '/CouponSelect',
|
||||
query: {
|
||||
businessId: this.businessId
|
||||
}
|
||||
});
|
||||
this.$router.push({
|
||||
path: '/CouponSelect',
|
||||
query: {
|
||||
businessId: this.businessId,
|
||||
totalPrice: this.totalPrice
|
||||
}
|
||||
});
|
||||
},
|
||||
getCouponName() {
|
||||
if (this.couponUsed == null) {
|
||||
|
|
|
|||
|
|
@ -9,29 +9,29 @@
|
|||
<h3>订单信息:</h3>
|
||||
<div class="order-info">
|
||||
<p>
|
||||
{{orders.business.businessName}}
|
||||
{{ orders.business.businessName }}
|
||||
<i class="fa fa-caret-down" @click="detailetShow"></i>
|
||||
</p>
|
||||
<p>¥{{orders.orderTotal}}</p>
|
||||
<p>¥{{ orders.orderTotal }}</p>
|
||||
</div>
|
||||
<!-- 订单明细部分 -->
|
||||
<ul class="order-detailet" v-show="isShowDetailet">
|
||||
<li v-for="item in orders.list">
|
||||
<p>{{item.food.foodName}} x {{item.quantity}}</p>
|
||||
<p>¥{{item.food.foodPrice*item.quantity}}</p>
|
||||
<p>{{ item.food.foodName }} x {{ item.quantity }}</p>
|
||||
<p>¥{{ item.food.foodPrice * item.quantity }}</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>配送费</p>
|
||||
<p>¥{{orders.business.deliveryPrice}}</p>
|
||||
<p>¥{{ orders.business.deliveryPrice }}</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>消费券减免</p>
|
||||
<p>-¥{{reduction}}</p>
|
||||
<p>-¥{{ reduction }}</p>
|
||||
</li>
|
||||
<!-- 积分系统新增显示 -->
|
||||
<li>
|
||||
<p>获得积分</p>
|
||||
<p>{{orders.orderTotal*10}}</p>
|
||||
<p>{{ orders.orderTotal * 10 }}</p>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- 支付方式部分 -->
|
||||
|
|
@ -45,17 +45,21 @@
|
|||
</li>
|
||||
</ul>
|
||||
<div class="payment-button">
|
||||
<button :style="{ backgroundColor: isPayed ? 'gray' : '#38CA73'}" @click="pay">确认支付</button>
|
||||
<button :style="{ backgroundColor: isPayed ? 'gray' : '#38CA73'}" @click="pay">确认支付</button>
|
||||
</div>
|
||||
<h2 v-show="paySuccess" style="color: #0097FF;text-align: center;">
|
||||
支付成功!
|
||||
</h2>
|
||||
<h2 v-show="noMoney" style="color: red;text-align: center;">
|
||||
钱包余额不足!
|
||||
</h2>
|
||||
<!-- 底部菜单部分 -->
|
||||
<Footer></Footer>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import Footer from '../components/Footer.vue';
|
||||
|
||||
export default {
|
||||
name: 'Payment',
|
||||
data() {
|
||||
|
|
@ -68,11 +72,12 @@ export default {
|
|||
},
|
||||
isShowDetailet: false,
|
||||
paySuccess: false,
|
||||
isPayed: false
|
||||
isPayed: false,
|
||||
noMoney: false
|
||||
}
|
||||
},
|
||||
created() {
|
||||
let url=`OrdersController/getOrdersById/${this.orderId}`
|
||||
let url = `OrdersController/getOrdersById/${this.orderId}`
|
||||
this.$axios.get(url).then(response => {
|
||||
this.orders = response.data.result;
|
||||
}).catch(error => {
|
||||
|
|
@ -94,66 +99,57 @@ export default {
|
|||
window.onpopstate = null;
|
||||
},
|
||||
computed: {
|
||||
pointGot(){
|
||||
let res=this.orders.orderTotal+this.reduction;
|
||||
pointGot() {
|
||||
let res = this.orders.orderTotal + this.reduction;
|
||||
return Math.floor(res);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
back() {
|
||||
this.$router.go(-1);
|
||||
},
|
||||
detailetShow() {
|
||||
this.isShowDetailet = !this.isShowDetailet;
|
||||
},
|
||||
pay() {
|
||||
// this.$axios.put('OrdersController/Orders', this.$qs.stringify({
|
||||
// orderId: this.orderId,
|
||||
// userId: this.userId,
|
||||
// orderTotal: this.orders.orderTotal,
|
||||
// reduction: this.reduction
|
||||
// }),{
|
||||
// headers: {
|
||||
// Authorization:this.$getSessionStorage('user').password
|
||||
// }
|
||||
// }).then(response => {
|
||||
// let orderId = response.data;
|
||||
// if (orderId > 0) {
|
||||
// this.paySuccess=true;
|
||||
// this.isPayed=true;
|
||||
// setTimeout(() => {
|
||||
// this.$router.push({
|
||||
// path: '/orderList'
|
||||
// });
|
||||
// }, 500);
|
||||
// } else {
|
||||
// alert('支付失败!');
|
||||
// }
|
||||
// }).catch(error => {
|
||||
// console.error(error);
|
||||
// });
|
||||
|
||||
console.log("Kicked");
|
||||
let url=`OrdersController/Orders/${this.orderId}`
|
||||
this.$axios.put(url)
|
||||
.then(
|
||||
response =>
|
||||
{
|
||||
console.log(response);
|
||||
console.log("支付成功");
|
||||
let url=`PointController/addPointByPointId/${this.userId}/${this.orders.orderDate}/${this.orders.orderTotal*10}`
|
||||
console.log(url);
|
||||
this.$axios.post(url).then(response =>
|
||||
{
|
||||
console.log(response.data);
|
||||
});
|
||||
this.$router.push({path:'/orderList'});
|
||||
}
|
||||
)
|
||||
.catch(error =>
|
||||
{
|
||||
console.error(error);
|
||||
}
|
||||
);
|
||||
|
||||
let url0 = `WalletController/expense/${this.userId}/${this.orders.orderTotal}`;
|
||||
let url = `OrdersController/Orders/${this.orderId}`;
|
||||
|
||||
this.$axios.post(url0)
|
||||
.then(response => {
|
||||
if (response.data.result === 1) {
|
||||
// url0 返回 1,继续执行 url
|
||||
this.$axios.put(url)
|
||||
.then(response => {
|
||||
let url =
|
||||
`PointController/addPointByPointId/${this.userId}/${this.orders.orderDate}/${this.orders.orderTotal * 10}`;
|
||||
console.log(url);
|
||||
this.$axios.post(url)
|
||||
.then(response => {
|
||||
console.log(response.data);
|
||||
});
|
||||
this.paySuccess = true;
|
||||
this.isPayed = true;
|
||||
setTimeout(() => {
|
||||
this.$router.push({
|
||||
path: '/orderList'
|
||||
})
|
||||
}, 500);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
} else {
|
||||
// url0 返回非 1,输出提示信息
|
||||
this.noMoney = true
|
||||
setTimeout(() => {
|
||||
this.noMoney = false
|
||||
}, 1000);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
}
|
||||
},
|
||||
components: {
|
||||
|
|
|
|||
|
|
@ -1,181 +1,247 @@
|
|||
<template>
|
||||
<div class="wrapper">
|
||||
<!-- header部分 -->
|
||||
<header>
|
||||
<i class="fa fa-angle-left" @click="back"></i>
|
||||
<p>我的钱包</p>
|
||||
</header>
|
||||
</div>
|
||||
<div class="wrapper">
|
||||
<!-- header部分 -->
|
||||
<header>
|
||||
<i class="fa fa-angle-left" @click="back"></i>
|
||||
<p>我的钱包</p>
|
||||
</header>
|
||||
|
||||
<div class="wallet-total">
|
||||
<div class="num">
|
||||
<img src="../assets/钱包.png">
|
||||
<p style="color: black;">{{balance}}</p>
|
||||
</div>
|
||||
<div class="text">
|
||||
<p></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wallet-detail">
|
||||
<div class="top">
|
||||
<p :class="{ active: isShouzhi }" @click="toggleTab('shouzhi')">钱包流水</p>
|
||||
|
||||
</div>
|
||||
<div class="border">
|
||||
<ul class="get-pay" v-show="isShouzhi">
|
||||
<li class="li1">
|
||||
<ul class="details">
|
||||
<li class="x">
|
||||
<h4>交易时间</h4>
|
||||
</li>
|
||||
<li class="y">
|
||||
<h4>交易额</h4>
|
||||
</li>
|
||||
<li class="y">
|
||||
<h4>余额</h4>
|
||||
</li>
|
||||
<li class="y">
|
||||
<h4>交易类型</h4>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="li1">
|
||||
<ul class="details" v-for="item in availablePointArr">
|
||||
<li class="x">
|
||||
<h4>{{item.transactionTime}}</h4>
|
||||
</li>
|
||||
<li class="y">
|
||||
<p>{{ item.transactionNum }}</p>
|
||||
</li>
|
||||
<li class="y">
|
||||
<p>{{ item.balance }}</p>
|
||||
</li>
|
||||
<li class="y">
|
||||
<p style="color: green;">{{ item.transactionType }}</p>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'Wallet',
|
||||
data() {
|
||||
return {
|
||||
isShouzhi: true,
|
||||
availablePointArr: [],
|
||||
outDatePointArr: [],
|
||||
user: {}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
sum() {
|
||||
return this.availablePointArr.reduce((accumulator, currentValue) => accumulator + currentValue.pointNum,
|
||||
0);
|
||||
}
|
||||
},
|
||||
created() {
|
||||
export default {
|
||||
name: 'walletDetails',
|
||||
data() {
|
||||
return {
|
||||
isShouzhi: true,
|
||||
availablePointArr: [],
|
||||
balance: [],
|
||||
user: {}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
sum() {
|
||||
return this.availablePointArr.reduce((accumulator, currentValue) => accumulator + currentValue.pointNum,
|
||||
0);
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.user = this.$getSessionStorage('user');
|
||||
|
||||
},
|
||||
methods: {
|
||||
back() {
|
||||
this.$router.go(-1);
|
||||
},
|
||||
toggleTab(tab) {
|
||||
this.isShouzhi = tab === 'shouzhi';
|
||||
},
|
||||
},
|
||||
};
|
||||
this.$axios.get(`WalletController/listWallets`, {
|
||||
params: {
|
||||
userId: this.user.userId
|
||||
},
|
||||
headers: {
|
||||
Authorization: this.user.password
|
||||
}
|
||||
}).then(response => {
|
||||
// 积分系统新增的改动
|
||||
let result = response.data.result;
|
||||
this.availablePointArr = result;
|
||||
console.log(response);
|
||||
// console.log(this.user.userId+" "+this.user.password);
|
||||
}).catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
|
||||
let url = `WalletController/getWalletBalance/${this.user.userId}`
|
||||
this.$axios.get(url).then(response => {
|
||||
let result = response.data.result;
|
||||
this.balance = result;
|
||||
console.log("balance:\n" + result)
|
||||
}).catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
back() {
|
||||
this.$router.go(-1);
|
||||
},
|
||||
toggleTab(tab) {
|
||||
this.isShouzhi = tab === 'shouzhi';
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.wrapper {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: #F4F8Fb;
|
||||
}
|
||||
.wrapper {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: #F4F8Fb;
|
||||
}
|
||||
|
||||
/****************** header ******************/
|
||||
.wrapper header {
|
||||
width: 100%;
|
||||
height: 12vw;
|
||||
background-color: #01B0F2;
|
||||
font-size: 4.8vw;
|
||||
color: #fff;
|
||||
/****************** header ******************/
|
||||
.wrapper header {
|
||||
width: 100%;
|
||||
height: 12vw;
|
||||
background-color: #01B0F2;
|
||||
font-size: 4.8vw;
|
||||
color: #fff;
|
||||
|
||||
z-index: 10;
|
||||
z-index: 10;
|
||||
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.wrapper header i {
|
||||
margin: 0vw 0vw 0vw 3vw;
|
||||
font-size: 6vw;
|
||||
user-select: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
.wrapper header i {
|
||||
margin: 0vw 0vw 0vw 3vw;
|
||||
font-size: 6vw;
|
||||
user-select: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.wrapper header p {
|
||||
margin: 0vw 0vw 0vw 32vw;
|
||||
}
|
||||
.wrapper header p {
|
||||
margin: 0vw 0vw 0vw 32vw;
|
||||
}
|
||||
|
||||
.wrapper .points-total {
|
||||
padding-top: 20vw;
|
||||
}
|
||||
.wrapper .wallet-total {
|
||||
padding-top: 20vw;
|
||||
}
|
||||
|
||||
.wrapper .points-total .num {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin-bottom: 1vw;
|
||||
}
|
||||
.wrapper .wallet-total .num {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin-bottom: 1vw;
|
||||
}
|
||||
|
||||
.wrapper .points-total .num p {
|
||||
font-size: 6vw;
|
||||
}
|
||||
.wrapper .wallet-total .num p {
|
||||
font-size: 6.5vw;
|
||||
padding-left: 2vw;
|
||||
}
|
||||
|
||||
.wrapper .points-total .num img {
|
||||
width: 8vw;
|
||||
height: 8vw;
|
||||
}
|
||||
.wrapper .wallet-total .num img {
|
||||
width: 12vw;
|
||||
height: 12vw;
|
||||
}
|
||||
|
||||
.wrapper .points-total .text {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-size: 2.8vw;
|
||||
}
|
||||
.wrapper .wallet-total .text {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-size: 2.8vw;
|
||||
}
|
||||
|
||||
.wrapper .points-detail {
|
||||
padding-top: 6vw;
|
||||
}
|
||||
.wrapper .wallet-detail {
|
||||
padding-top: 6vw;
|
||||
}
|
||||
|
||||
.wrapper .points-detail .top {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
font-size: 3.5vw;
|
||||
padding-bottom: 2vw;
|
||||
}
|
||||
.wrapper .wallet-detail .top {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
font-size: 3.5vw;
|
||||
padding-bottom: 2vw;
|
||||
}
|
||||
|
||||
.wrapper .points-detail .top p {
|
||||
font-weight: normal;
|
||||
user-select: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
.wrapper .wallet-detail .top p {
|
||||
font-weight: normal;
|
||||
user-select: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.wrapper .points-detail .top p.active {
|
||||
font-weight: bold;
|
||||
user-select: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
.wrapper .wallet-detail .top p.active {
|
||||
font-weight: bold;
|
||||
user-select: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.wrapper .points-detail .border {
|
||||
width: 100%;
|
||||
padding: 2vw 2vw 0vw 2vw;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.wrapper .wallet-detail .border {
|
||||
width: 100%;
|
||||
padding: 2vw 2vw 0vw 2vw;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.wrapper .points-detail .border .get-pay {
|
||||
width: 100%;
|
||||
background-color: #fff;
|
||||
border-radius: 2vw;
|
||||
}
|
||||
.wrapper .wallet-detail .border .get-pay {
|
||||
width: 100%;
|
||||
background-color: #fff;
|
||||
border-radius: 2vw;
|
||||
}
|
||||
|
||||
.wrapper .points-detail .border .get-pay .li1 {
|
||||
padding: 2vw 0vw;
|
||||
}
|
||||
.wrapper .wallet-detail .border .get-pay .li1 {
|
||||
padding: 2vw 0vw;
|
||||
}
|
||||
|
||||
.wrapper .points-detail .border .get-pay .details {
|
||||
display: flex;
|
||||
margin: 0vw 2vw;
|
||||
}
|
||||
.wrapper .wallet-detail .border .get-pay .details {
|
||||
display: flex;
|
||||
padding: 0vw 2vw 1vw 2vw;
|
||||
}
|
||||
|
||||
.wrapper .points-detail .border .get-pay .details li {
|
||||
width: 34%;
|
||||
font-size: 2.8vw;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.wrapper .wallet-detail .border .get-pay .details .x{
|
||||
width: 37%;
|
||||
font-size: 2.8vw;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.wrapper .points-detail .border .duihuan {
|
||||
width: 100%;
|
||||
background-color: #fff;
|
||||
border-radius: 2vw;
|
||||
}
|
||||
|
||||
.wrapper .points-detail .border .duihuan .li1 {
|
||||
padding: 2vw 0vw;
|
||||
}
|
||||
|
||||
.wrapper .points-detail .border .duihuan .details {
|
||||
display: flex;
|
||||
margin: 0vw 2vw;
|
||||
}
|
||||
|
||||
.wrapper .points-detail .border .duihuan .details li {
|
||||
width: 34%;
|
||||
font-size: 2.8vw;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.wrapper .wallet-detail .border .get-pay .details .y{
|
||||
width: 21%;
|
||||
font-size: 2.8vw;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -25,7 +25,11 @@
|
|||
<module name="deliveryaddress_server_10500" />
|
||||
<module name="search_server_11600" />
|
||||
<module name="business_server_10300" />
|
||||
<module name="wallet_server_11000" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
<bytecodeTargetLevel>
|
||||
<module name="wallet_server_10800" target="1.8" />
|
||||
</bytecodeTargetLevel>
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -41,5 +41,7 @@
|
|||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/user_server_10100/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/user_server_10100/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/wallet_server_11000/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/wallet_server_11000/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="wallet_server_11000" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
|
||||
<option name="FRAME_DEACTIVATION_UPDATE_POLICY" value="UpdateClassesAndResources" />
|
||||
<module name="wallet_server_11000" />
|
||||
<option name="SPRING_BOOT_MAIN_CLASS" value="com.neusoft.MyApplication" />
|
||||
<extension name="coverage">
|
||||
<pattern>
|
||||
<option name="PATTERN" value="com.neusoft.*" />
|
||||
<option name="ENABLED" value="true" />
|
||||
</pattern>
|
||||
</extension>
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.neusoft.service.impl;
|
||||
|
||||
import com.neusoft.po.Cart;
|
||||
import com.neusoft.service.CartService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AbstractCartService implements CartService {
|
||||
|
||||
protected abstract List<Cart> listCartInternal(Cart cart);
|
||||
|
||||
protected abstract int saveCartInternal(Cart cart);
|
||||
|
||||
protected abstract int updateCartInternal(Cart cart);
|
||||
|
||||
protected abstract int removeCartInternal(Cart cart);
|
||||
|
||||
@Override
|
||||
public List<Cart> listCart(Cart cart) {
|
||||
return listCartInternal(cart);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int saveCart(Cart cart) {
|
||||
return saveCartInternal(cart);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateCart(Cart cart) {
|
||||
return updateCartInternal(cart);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int removeCart(Cart cart) {
|
||||
return removeCartInternal(cart);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +1,38 @@
|
|||
//模板方法模式
|
||||
/*模板方法模式可以将一些共同的行为放在一个抽象类中,然后由具体的子类实现具体的行为。创建一个抽象的 AbstractCartService 类,其中包含通用的方法实现,然后 CartServiceImpl 类继承这个抽象类并实现具体的方法。*/
|
||||
|
||||
package com.neusoft.service.impl;
|
||||
|
||||
import com.neusoft.mapper.CartMapper;
|
||||
import com.neusoft.po.Cart;
|
||||
import com.neusoft.service.CartService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CartServiceImpl implements CartService {
|
||||
public class CartServiceImpl extends AbstractCartService {
|
||||
|
||||
@Autowired
|
||||
private CartMapper cartMapper;
|
||||
|
||||
@Override
|
||||
public List<Cart> listCart(Cart cart) {
|
||||
protected List<Cart> listCartInternal(Cart cart) {
|
||||
return cartMapper.listCart(cart);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int saveCart(Cart cart) {
|
||||
protected int saveCartInternal(Cart cart) {
|
||||
return cartMapper.saveCart(cart);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateCart(Cart cart) {
|
||||
protected int updateCartInternal(Cart cart) {
|
||||
return cartMapper.updateCart(cart);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int removeCart(Cart cart) {
|
||||
protected int removeCartInternal(Cart cart) {
|
||||
return cartMapper.removeCart(cart);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,6 +73,11 @@ spring:
|
|||
predicates:
|
||||
- Path=/CollectController/*/**
|
||||
|
||||
- id: walletServer
|
||||
uri: lb://wallet-server
|
||||
predicates:
|
||||
- Path=/WalletController/*/**
|
||||
|
||||
eureka:
|
||||
client:
|
||||
service-url:
|
||||
|
|
|
|||
|
|
@ -73,6 +73,11 @@ spring:
|
|||
predicates:
|
||||
- Path=/CollectController/*/**
|
||||
|
||||
- id: walletServer
|
||||
uri: lb://wallet-server
|
||||
predicates:
|
||||
- Path=/WalletController/*/**
|
||||
|
||||
eureka:
|
||||
client:
|
||||
service-url:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
package com.neusoft.controller;
|
||||
|
||||
import com.neusoft.po.CommonResult;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class CommonResultFactory {
|
||||
|
||||
public <T> CommonResult<T> createSuccessResult(T data) {
|
||||
return new CommonResult<>(200, "success", data);
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ import com.neusoft.service.OrdersService;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.neusoft.controller.CommonResultFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -16,6 +17,12 @@ public class OrdersController {
|
|||
@Autowired
|
||||
private OrdersService ordersService;
|
||||
|
||||
private final CommonResultFactory commonResultFactory;
|
||||
|
||||
public OrdersController(CommonResultFactory commonResultFactory) {
|
||||
this.commonResultFactory = commonResultFactory;
|
||||
}
|
||||
|
||||
@PostMapping("/createOrders/{userId}/{businessId}/{daId}/{orderTotal}")
|
||||
public CommonResult<Integer> createOrders(
|
||||
@PathVariable("userId") String userId,
|
||||
|
|
@ -29,26 +36,26 @@ public class OrdersController {
|
|||
param.setDaId(daId);
|
||||
param.setOrderTotal(orderTotal);
|
||||
int orderId=ordersService.createOrders(param);
|
||||
return new CommonResult<>(200,"success",orderId);
|
||||
return commonResultFactory.createSuccessResult(orderId);
|
||||
}
|
||||
|
||||
@GetMapping("/getOrdersById/{orderId}")
|
||||
public CommonResult<Orders> getOrdersById(@PathVariable("orderId") Integer orderId) throws Exception {
|
||||
Orders orders=ordersService.getOrdersById(orderId);
|
||||
return new CommonResult<>(200,"success",orders);
|
||||
return commonResultFactory.createSuccessResult(orders);
|
||||
}
|
||||
|
||||
@GetMapping("/listOrdersByUserId/{userId}")
|
||||
public CommonResult<List<Orders>> listOrdersByUserId(@PathVariable("userId") String userId) throws Exception {
|
||||
List<Orders> list=ordersService.listOrdersByUserId(userId);
|
||||
return new CommonResult<>(200,"success",list);
|
||||
return commonResultFactory.createSuccessResult(list);
|
||||
}
|
||||
|
||||
@PutMapping("/Orders/{orderId}")
|
||||
public CommonResult<Integer>payOrdersById(@PathVariable("orderId") Integer orderId)throws Exception
|
||||
{
|
||||
int result=ordersService.payOrdersById(orderId, null, null, null);
|
||||
return new CommonResult<>(200,"success",result);
|
||||
return commonResultFactory.createSuccessResult(result);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
package com.neusoft.controller;
|
||||
|
||||
import com.neusoft.po.CommonResult;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class CommonResultFactory {
|
||||
|
||||
public <T> CommonResult<T> createSuccessResult(T data) {
|
||||
return new CommonResult<>(200, "success", data);
|
||||
}
|
||||
}
|
||||
|
|
@ -16,6 +16,12 @@ public class OrdersController {
|
|||
@Autowired
|
||||
private OrdersService ordersService;
|
||||
|
||||
private final CommonResultFactory commonResultFactory;
|
||||
|
||||
public OrdersController(CommonResultFactory commonResultFactory) {
|
||||
this.commonResultFactory = commonResultFactory;
|
||||
}
|
||||
|
||||
@PostMapping("/createOrders/{userId}/{businessId}/{daId}/{orderTotal}")
|
||||
public CommonResult<Integer> createOrders(
|
||||
@PathVariable("userId") String userId,
|
||||
|
|
@ -29,21 +35,29 @@ public class OrdersController {
|
|||
param.setDaId(daId);
|
||||
param.setOrderTotal(orderTotal);
|
||||
int orderId=ordersService.createOrders(param);
|
||||
return new CommonResult<>(200,"success",orderId);
|
||||
return commonResultFactory.createSuccessResult(orderId);
|
||||
}
|
||||
|
||||
@GetMapping("/getOrdersById/{orderId}")
|
||||
public CommonResult<Orders> getOrdersById(@PathVariable("orderId") Integer orderId) throws Exception {
|
||||
Orders orders=ordersService.getOrdersById(orderId);
|
||||
return new CommonResult<>(200,"success",orders);
|
||||
return commonResultFactory.createSuccessResult(orders);
|
||||
}
|
||||
|
||||
@GetMapping("/listOrdersByUserId/{userId}")
|
||||
public CommonResult<List<Orders>> listOrdersByUserId(@PathVariable("userId") String userId) throws Exception {
|
||||
List<Orders> list=ordersService.listOrdersByUserId(userId);
|
||||
return new CommonResult<>(200,"success",list);
|
||||
return commonResultFactory.createSuccessResult(list);
|
||||
}
|
||||
|
||||
@PutMapping("/Orders/{orderId}")
|
||||
public CommonResult<Integer>payOrdersById(@PathVariable("orderId") Integer orderId)throws Exception
|
||||
{
|
||||
int result=ordersService.payOrdersById(orderId, null, null, null);
|
||||
return commonResultFactory.createSuccessResult(result);
|
||||
}
|
||||
|
||||
|
||||
// @PutMapping("/Orders")
|
||||
// public int payOrdersById(OrderState orderState, @RequestHeader("Authorization") String token) throws Exception {
|
||||
// return ordersService.payOrdersById(orderState.getOrderId(), orderState.getUserId(), orderState.getOrderTotal(), orderState.getReduction(),token);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
<module>point_server_10900</module>
|
||||
<module>coupon_server_10950</module>
|
||||
<module>collect_server_10800</module>
|
||||
<module>wallet_server_11000</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,65 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.neusoft</groupId>
|
||||
<artifactId>springcloud_elm</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>wallet_server_11000</artifactId>
|
||||
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-bus</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-config</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.20</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!-- 热部署 gav -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.neusoft</groupId>
|
||||
<artifactId>business_server_10300</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.neusoft;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class MyApplication {
|
||||
public static void main(String[] args){
|
||||
SpringApplication.run(MyApplication.class,args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.neusoft.controller;
|
||||
|
||||
import com.neusoft.po.CommonResult;
|
||||
import com.neusoft.po.Wallet;
|
||||
import com.neusoft.service.WalletService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/WalletController")
|
||||
public class WalletController {
|
||||
@Autowired
|
||||
private WalletService walletService;
|
||||
|
||||
@GetMapping("/listWallets")
|
||||
public CommonResult<List<Wallet>> listWallets(@RequestParam("userId") String userId, @RequestHeader("Authorization") String token) throws Exception {
|
||||
return new CommonResult<>(200, "success", walletService.listWallets(userId, token));
|
||||
}
|
||||
|
||||
@PostMapping("/deposit/{userId}/{amount}")
|
||||
public CommonResult<Integer> deposit(@PathVariable("userId") String userId, @PathVariable("amount") double amount) {
|
||||
return new CommonResult<>(200, "success", walletService.deposit(userId, amount));
|
||||
}
|
||||
|
||||
@PostMapping("/withdraw/{userId}/{amount}")
|
||||
public CommonResult<Integer> withdraw(@PathVariable("userId") String userId, @PathVariable("amount") double amount) {
|
||||
return new CommonResult<>(200, "success", walletService.withdraw(userId, amount));
|
||||
}
|
||||
|
||||
@PostMapping("/expense/{userId}/{amount}")
|
||||
public CommonResult<Integer> transfer(@PathVariable("userId") String userId,@PathVariable("amount") double amount) {
|
||||
return new CommonResult<>(200, "success", walletService.expense(userId, amount));
|
||||
}
|
||||
|
||||
@GetMapping("/getWalletBalance/{userId}")
|
||||
public CommonResult<Double> getWalletBalance(@PathVariable("userId") String userId) {
|
||||
return new CommonResult<>(200, "success", walletService.getWalletBalance(userId));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package com.neusoft.mapper;
|
||||
|
||||
|
||||
import com.neusoft.po.Point;
|
||||
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Options;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface PointMapper {
|
||||
@Select("select * from point where userId=#{userId}")
|
||||
public List<Point> listPointsByUserId(String userId);
|
||||
|
||||
@Update("update point set pointNum=#{pointNum} where pointId=#{pointId}")
|
||||
public void setPointByPointId(Point point);
|
||||
|
||||
@Delete("delete from point where pointId=#{pointId}")
|
||||
public void deletePointByPointId(String pointId);
|
||||
|
||||
@Select("insert into point(userId,pointDate,pointNum,outDate) values(#{userId},#{pointDate},#{pointNum},#{outDate})")
|
||||
@Options(useGeneratedKeys=true,keyProperty="pointId",keyColumn="pointId")
|
||||
public void addPointByPointId(Point point);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.neusoft.mapper;
|
||||
|
||||
import com.neusoft.po.User;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
@Mapper
|
||||
public interface UserMapper {
|
||||
@Select("select * from user where userId=#{userId} and password=#{password}")
|
||||
public User getUserByIdByPass(User user);
|
||||
|
||||
@Select("select count(*) from user where userId=#{userId}")
|
||||
public int getUserById(String userId);
|
||||
|
||||
@Insert("insert into user values(#{userId},#{password},#{userName},#{userSex},null,1)")
|
||||
public int saveUser(User user);
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.neusoft.mapper;
|
||||
|
||||
|
||||
import com.neusoft.po.Wallet;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Options;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface WalletMapper {
|
||||
@Select("select * from wallet where userId=#{userId}")
|
||||
public List<Wallet> listWalletsByUserId(String userId);
|
||||
|
||||
@Select("insert into wallet(userId,balance,transactionNum,transactionTime,transactionType) values(#{userId},#{balance},#{transactionNum},#{transactionTime},#{transactionType})")
|
||||
@Options(useGeneratedKeys=true,keyProperty="walletId",keyColumn="walletId")
|
||||
public void addWalletByWallet(Wallet wallet);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.neusoft.po;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class CommonResult<T> implements Serializable {
|
||||
private Integer code;
|
||||
private String message;
|
||||
private T result;
|
||||
|
||||
public CommonResult() {}
|
||||
|
||||
public CommonResult(Integer code, String message, T result) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public T getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(T result) {
|
||||
this.result = result;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
package com.neusoft.po;
|
||||
|
||||
public class Point {
|
||||
|
||||
private String pointId;
|
||||
private String userId;
|
||||
private String pointDate;
|
||||
private Integer pointNum;
|
||||
private String outDate;
|
||||
public Point()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Point(String pointId,String userId,String pointDate,Integer pointNum,String outDate)
|
||||
{
|
||||
this.pointId=pointId;
|
||||
this.userId=userId;
|
||||
this.pointDate=pointDate;
|
||||
this.pointNum=pointNum;
|
||||
this.outDate=outDate;
|
||||
}
|
||||
|
||||
public String getPointId()
|
||||
{
|
||||
return this.pointId;
|
||||
}
|
||||
public String getUserId()
|
||||
{
|
||||
return this.userId;
|
||||
}
|
||||
public String getPointDate()
|
||||
{
|
||||
return this.pointDate;
|
||||
}
|
||||
public Integer getPointNum()
|
||||
{
|
||||
return this.pointNum;
|
||||
}
|
||||
|
||||
public void setPointId(String pointId)
|
||||
{
|
||||
this.pointId=pointId;
|
||||
}
|
||||
public void setUserId(String userId)
|
||||
{
|
||||
this.userId=userId;
|
||||
}
|
||||
public void setPointDate(String pointDate)
|
||||
{
|
||||
this.pointDate=pointDate;
|
||||
}
|
||||
public void setPointNum(Integer pointNum)
|
||||
{
|
||||
this.pointNum=pointNum;
|
||||
}
|
||||
public String getOutDate() {
|
||||
return outDate;
|
||||
}
|
||||
public void setOutDate(String outDate) {
|
||||
this.outDate = outDate;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.neusoft.po;
|
||||
|
||||
public enum TransactionType {
|
||||
DEPOSIT("Deposit"),
|
||||
WITHDRAWAL("Withdrawal"),
|
||||
EXPENSE("Expense"),
|
||||
CREATE("Create");
|
||||
private final String type;
|
||||
|
||||
TransactionType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package com.neusoft.po;
|
||||
|
||||
public class User {
|
||||
|
||||
private String userId;
|
||||
private String password;
|
||||
private String userName;
|
||||
private Integer userSex;
|
||||
private String userImg;
|
||||
private Integer delTag;
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public Integer getUserSex() {
|
||||
return userSex;
|
||||
}
|
||||
|
||||
public void setUserSex(Integer userSex) {
|
||||
this.userSex = userSex;
|
||||
}
|
||||
|
||||
public String getUserImg() {
|
||||
return userImg;
|
||||
}
|
||||
|
||||
public void setUserImg(String userImg) {
|
||||
this.userImg = userImg;
|
||||
}
|
||||
|
||||
public Integer getDelTag() {
|
||||
return delTag;
|
||||
}
|
||||
|
||||
public void setDelTag(Integer delTag) {
|
||||
this.delTag = delTag;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
package com.neusoft.po;
|
||||
import java.util.Date;
|
||||
|
||||
public class Wallet {
|
||||
private Integer walletId;
|
||||
private String userId;
|
||||
private double balance;
|
||||
private double transactionNum;
|
||||
private String transactionTime;
|
||||
private TransactionType transactionType;
|
||||
|
||||
public Wallet(Integer walletId,String userId,double balance,double transactionNum,String transactionTime,TransactionType transactionType)
|
||||
{
|
||||
this.walletId=walletId;
|
||||
this.userId=userId;
|
||||
this.balance=balance;
|
||||
this.transactionNum=transactionNum;
|
||||
this.transactionTime=transactionTime;
|
||||
this.transactionType=transactionType;
|
||||
}
|
||||
|
||||
public Integer getWalletId() {
|
||||
return walletId;
|
||||
}
|
||||
|
||||
public void setWalletId(Integer walletId) {
|
||||
this.walletId = walletId;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public double getBalance() {
|
||||
return balance;
|
||||
}
|
||||
|
||||
public void setBalance(double balance) {
|
||||
this.balance = balance;
|
||||
}
|
||||
|
||||
public String getTransactionTime() {
|
||||
return transactionTime;
|
||||
}
|
||||
|
||||
public void setTransactionTime(String transactionTime) {
|
||||
this.transactionTime = transactionTime;
|
||||
}
|
||||
|
||||
public TransactionType getTransactionType() {
|
||||
return transactionType;
|
||||
}
|
||||
|
||||
public void setTransactionType(TransactionType transactionType) {
|
||||
this.transactionType = transactionType;
|
||||
}
|
||||
|
||||
public double getTransactionNum() {
|
||||
return transactionNum;
|
||||
}
|
||||
|
||||
public void setTransactionNum(double transactionNum) {
|
||||
this.transactionNum = transactionNum;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.neusoft.service;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
|
||||
import com.neusoft.po.Wallet;
|
||||
|
||||
public interface WalletService {
|
||||
public List<Wallet> listWallets(String userId, String token) throws ParseException;
|
||||
|
||||
public int deposit(String userId, double amount);
|
||||
|
||||
public int withdraw(String userId, double amount);
|
||||
|
||||
public int expense(String userId, double amount);
|
||||
|
||||
public double getWalletBalance(String userId);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,152 @@
|
|||
package com.neusoft.service.impl;
|
||||
|
||||
import com.neusoft.mapper.UserMapper;
|
||||
import com.neusoft.mapper.WalletMapper;
|
||||
import com.neusoft.po.TransactionType;
|
||||
import com.neusoft.po.User;
|
||||
import com.neusoft.po.Wallet;
|
||||
import com.neusoft.service.WalletService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class WalletServiceImpl implements WalletService {
|
||||
@Autowired
|
||||
private WalletMapper walletMapper;
|
||||
|
||||
@Autowired
|
||||
private UserMapper userMapper0;
|
||||
|
||||
@Override
|
||||
public List<Wallet> listWallets(String userId, String token) throws ParseException {
|
||||
User user = new User();
|
||||
user.setUserId(userId);
|
||||
user.setPassword(token);
|
||||
if (userMapper0.getUserByIdByPass(user) == null)
|
||||
return null;
|
||||
|
||||
List<Wallet> list = new ArrayList<>();
|
||||
list = walletMapper.listWalletsByUserId(userId);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deposit(String userId, double amount) {
|
||||
try {
|
||||
// 获取用户当前余额
|
||||
double balance = getWalletBalance(userId);
|
||||
balance = balance += amount;
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
// 创建 Wallet 对象
|
||||
Wallet wallet = new Wallet(null, userId, balance, amount, sdf.format(new Date()), TransactionType.DEPOSIT);
|
||||
|
||||
// 调用 Mapper 方法插入数据
|
||||
walletMapper.addWalletByWallet(wallet);
|
||||
|
||||
// 插入成功,返回 1
|
||||
return 1;
|
||||
} catch (Exception e) {
|
||||
// 插入失败,记录异常并返回 0
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int withdraw(String userId, double amount) {
|
||||
try {
|
||||
// 获取用户当前余额
|
||||
double balance = getWalletBalance(userId);
|
||||
|
||||
// 如果余额不足,直接返回 0
|
||||
if (balance < amount) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 更新余额
|
||||
balance -= amount;
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
// 创建 Wallet 对象并插入数据
|
||||
Wallet wallet = new Wallet(null, userId, balance, amount, sdf.format(new Date()), TransactionType.WITHDRAWAL);
|
||||
walletMapper.addWalletByWallet(wallet);
|
||||
|
||||
// 插入成功,返回 1
|
||||
return 1;
|
||||
} catch (Exception e) {
|
||||
// 记录异常并返回 0
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int expense(String userId, double amount) {
|
||||
try {
|
||||
// 获取用户当前余额
|
||||
double balance = getWalletBalance(userId);
|
||||
|
||||
// 如果余额不足,直接返回 0
|
||||
if (balance < amount) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 更新余额
|
||||
balance -= amount;
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
// 创建 Wallet 对象并插入数据
|
||||
Wallet wallet = new Wallet(null, userId, balance, amount, sdf.format(new Date()), TransactionType.EXPENSE);
|
||||
walletMapper.addWalletByWallet(wallet);
|
||||
|
||||
// 插入成功,返回 1
|
||||
return 1;
|
||||
} catch (Exception e) {
|
||||
// 记录异常并返回 0
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double getWalletBalance(String userId) {
|
||||
try {
|
||||
// 查询用户所有钱包记录
|
||||
List<Wallet> wallets = walletMapper.listWalletsByUserId(userId);
|
||||
|
||||
// 如果用户没有钱包记录,则余额为0
|
||||
double balance = 0.0;
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
if (wallets.isEmpty()) {
|
||||
// 创建 Wallet 对象
|
||||
Wallet wallet = new Wallet(null, userId, balance, 0.0, sdf.format(new Date()), TransactionType.CREATE);
|
||||
// 调用 Mapper 方法插入数据
|
||||
walletMapper.addWalletByWallet(wallet);
|
||||
}
|
||||
|
||||
if (!wallets.isEmpty()) {
|
||||
// 找到具有最大钱包ID的记录
|
||||
Wallet maxWallet = Collections.max(wallets, Comparator.comparing(w -> w.getWalletId()));
|
||||
|
||||
// 获取最大钱包的余额
|
||||
balance = maxWallet.getBalance();
|
||||
}
|
||||
|
||||
return balance;
|
||||
} catch (Exception e) {
|
||||
// 发生异常时记录并返回0
|
||||
e.printStackTrace();
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
spring:
|
||||
cloud:
|
||||
config:
|
||||
name: wallet_server_11000
|
||||
profile: dev
|
||||
label: master
|
||||
discovery:
|
||||
enabled: true
|
||||
service-id: config-server
|
||||
|
||||
eureka:
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://eurekaServer13000:13000/eureka/,http://eurekaServer13001:13001/eureka/
|
||||
instance:
|
||||
prefer-ip-address: true #使用ip地址向eureka server进行注册
|
||||
instance-id: ${spring.cloud.client.ip-address}:${server.port} #设置eureka控制台中显示的注册信息
|
||||
lease-renewal-interval-in-seconds: 5
|
||||
lease-expiration-duration-in-seconds: 15
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
Manifest-Version: 1.0
|
||||
Built-By: ₩ᄁチ¦ᄌタ¥ヘモ
|
||||
Build-Jdk: 1.8.0_371
|
||||
Created-By: Maven Integration for Eclipse
|
||||
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
#Generated by Maven Integration for Eclipse
|
||||
#Sun Apr 21 15:15:43 CST 2024
|
||||
version=1.0-SNAPSHOT
|
||||
groupId=com.neusoft
|
||||
m2e.projectName=wallet_server_10800
|
||||
m2e.projectLocation=D\:\\OneDrive - tju.edu.cn\\my homework\\\u9AD8\u7EA7\u5B9E\u8DF5\\elm_springcloud-main\\springcloud_elm\\wallet_server_10800
|
||||
artifactId=wallet_server_10800
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.neusoft</groupId>
|
||||
<artifactId>springcloud_elm</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>wallet_server_10800</artifactId>
|
||||
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-bus</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-config</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.20</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!-- 热部署 gav -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.neusoft</groupId>
|
||||
<artifactId>business_server_10300</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
spring:
|
||||
cloud:
|
||||
config:
|
||||
name: wallet_server_11000
|
||||
profile: dev
|
||||
label: master
|
||||
discovery:
|
||||
enabled: true
|
||||
service-id: config-server
|
||||
|
||||
eureka:
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://eurekaServer13000:13000/eureka/,http://eurekaServer13001:13001/eureka/
|
||||
instance:
|
||||
prefer-ip-address: true #使用ip地址向eureka server进行注册
|
||||
instance-id: ${spring.cloud.client.ip-address}:${server.port} #设置eureka控制台中显示的注册信息
|
||||
lease-renewal-interval-in-seconds: 5
|
||||
lease-expiration-duration-in-seconds: 15
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
CREATE TABLE Wallet (
|
||||
walletId INT PRIMARY KEY AUTO_INCREMENT,
|
||||
userId VARCHAR(20),
|
||||
balance DOUBLE,
|
||||
transactionNum DOUBLE,
|
||||
transactionTime DATETIME,
|
||||
transactionType VARCHAR(50),
|
||||
FOREIGN KEY (userId) REFERENCES user(userId)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
Loading…
Reference in New Issue