mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-10-01 17:56:39 +08:00
commit
fa407b0308
5
package-lock.json
generated
5
package-lock.json
generated
@ -1,6 +1,3 @@
|
||||
{
|
||||
"name": "smart-admin",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {}
|
||||
"lockfileVersion": 1
|
||||
}
|
||||
|
@ -37,7 +37,7 @@
|
||||
¥
|
||||
</i>
|
||||
<span>
|
||||
{{ item.couponAmount?item.couponAmount:(parseInt((1-item.discount)*10)+'折') }}
|
||||
{{ item.couponAmount?item.couponAmount:(parseInt(10 - item.discount*10)+'折') }}
|
||||
</span>
|
||||
</div>
|
||||
<strong>{{ item.couponName }}</strong>
|
||||
|
@ -167,7 +167,7 @@
|
||||
¥
|
||||
</i>
|
||||
<span>
|
||||
{{ item.couponAmount?item.couponAmount:(parseInt((1-item.discount)*10)+'折') }}
|
||||
{{ item.couponAmount?item.couponAmount:(parseInt(10 - item.discount*10)+'折') }}
|
||||
</span>
|
||||
</div>
|
||||
<strong>{{ item.couponName }}</strong>
|
||||
@ -268,8 +268,9 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
...mapMutations(["checkIsLogin"]),
|
||||
/* 计算优惠券价格 */
|
||||
discountedSumPrice() {
|
||||
let total = 0;
|
||||
/* 判断是否为商品卷 */
|
||||
if(this.curCoupon.productCodes)
|
||||
this.finalAmount = this.qualifiedProductDiscount();
|
||||
else
|
||||
@ -282,7 +283,16 @@ export default {
|
||||
let checkResult = true;
|
||||
if(this.curCoupon.minPrice && this.curCoupon.minPrice > this.sumPrice) {
|
||||
checkResult = false;
|
||||
}
|
||||
}
|
||||
if(this.curCoupon.minQuantity && this.curCoupon.minQuantity > 0) {
|
||||
let totalItemNum = 0;
|
||||
let tmpShoppingCartList = this.arrSort(this.goldmedal);
|
||||
for(let itemInCart of tmpShoppingCartList) {
|
||||
totalItemNum += itemInCart.buyCount;
|
||||
}
|
||||
if(this.curCoupon.minQuantity > totalItemNum)
|
||||
checkResult = false;
|
||||
}
|
||||
if(this.curCoupon.couponAmount && this.curCoupon.couponAmount > this.sumPrice) {
|
||||
checkResult = false;
|
||||
}
|
||||
@ -301,72 +311,93 @@ export default {
|
||||
return this.sumPrice;
|
||||
}
|
||||
},
|
||||
/* 计算价格商品折扣 */
|
||||
qualifiedProductDiscount(){
|
||||
this.discountedItemIndex = 0;
|
||||
let total = 0;
|
||||
let totalItemNum = 0; //判断满足优惠券条件的商品数量
|
||||
let couponUsed = false;
|
||||
let tmpShoppingCartList = this.arrSort(this.goldmedal);
|
||||
let qualifiedProductAmount = 0;
|
||||
let tmpShoppingCartList = this.arrSort(this.goldmedal); //对应的商品
|
||||
let qualifiedProductAmount = 0; //满足条件的优惠券商品价格总价
|
||||
let skipQualifiedProductAmountCalculating = false;
|
||||
|
||||
let checkResult = true; //是否可使用
|
||||
let selectProduct = []; //满足条件的商品
|
||||
for(let itemInCart of tmpShoppingCartList) {
|
||||
if(this.curCoupon.productCodes.indexOf(itemInCart.productCode)>-1) {
|
||||
qualifiedProductAmount += (itemInCart.productPrice * itemInCart.buyCount);
|
||||
totalItemNum += itemInCart.buyCount;
|
||||
}
|
||||
}
|
||||
if(this.curCoupon.minPrice && this.curCoupon.minPrice > qualifiedProductAmount) {
|
||||
checkResult = false;
|
||||
}
|
||||
if(this.curCoupon.minQuantity && this.curCoupon.minQuantity > totalItemNum) {
|
||||
checkResult = false;
|
||||
}
|
||||
if(this.curCoupon.couponAmount && this.curCoupon.couponAmount > qualifiedProductAmount) {
|
||||
checkResult = false;
|
||||
}
|
||||
|
||||
|
||||
// couponTypeId
|
||||
// 0-不用折扣
|
||||
// 1-狗干粮金额券(50)
|
||||
// 2-通用金额满减券(50)
|
||||
// 3-通用折扣券(6折)
|
||||
// 4-指定干粮折扣券(7折)
|
||||
// 6-指定干粮金额券(100)
|
||||
for(let itemInCart of tmpShoppingCartList) {
|
||||
if(this.curCoupon.productCodes.indexOf(itemInCart.productCode)>-1 && !couponUsed) {
|
||||
if(this.curCoupon.minQuantity && this.curCoupon.minQuantity>itemInCart.buyCount) {
|
||||
//Check minQuantity
|
||||
total+=(itemInCart.buyCount * itemInCart.productPrice);
|
||||
} else if(this.curCoupon.minPrice && this.curCoupon.minPrice > (itemInCart.buyCount * itemInCart.productPrice)) {
|
||||
//Check minPrice
|
||||
total+=(itemInCart.buyCount * itemInCart.productPrice);
|
||||
} else {
|
||||
//Into coupon discount calculation
|
||||
switch(this.curCoupon.couponTypeId) {
|
||||
case 1: //Amount deduct
|
||||
/*
|
||||
if(this.curCoupon.couponAmount && this.curCoupon.couponAmount <= (itemInCart.productPrice * itemInCart.buyCount)) {
|
||||
total = total + (itemInCart.productPrice * itemInCart.buyCount - this.curCoupon.couponAmount);
|
||||
this.discountAmount = this.curCoupon.couponAmount;
|
||||
this.discountedProductCode = itemInCart.productCode;
|
||||
couponUsed=true;
|
||||
} else if(this.curCoupon.couponAmount && this.curCoupon.couponAmount > (itemInCart.productPrice * itemInCart.buyCount)) {
|
||||
total = total + itemInCart.productPrice * itemInCart.buyCount;
|
||||
this.discountAmount = 0;
|
||||
this.curCoupon = {couponName:'未能使用该优惠券'};
|
||||
}
|
||||
break;
|
||||
*/
|
||||
case 2: //Amount deduct with minPrice restriction
|
||||
case 6:
|
||||
if(this.curCoupon.couponAmount && this.curCoupon.couponAmount <= qualifiedProductAmount && this.curCoupon.productCodes.indexOf(itemInCart.productCode)>-1) {
|
||||
total = total + qualifiedProductAmount - this.curCoupon.couponAmount;
|
||||
this.discountAmount = this.curCoupon.couponAmount;
|
||||
this.discountedProductCode = itemInCart.productCode;
|
||||
skipQualifiedProductAmountCalculating = true;
|
||||
couponUsed=true;
|
||||
} else if(this.curCoupon.couponAmount && this.curCoupon.couponAmount > qualifiedProductAmount) {
|
||||
total = total + itemInCart.productPrice * itemInCart.buyCount;
|
||||
this.discountAmount = 0;
|
||||
this.curCoupon = {couponName:'未能使用该优惠券'};
|
||||
}
|
||||
break;
|
||||
case 3: //Limited product % discount
|
||||
case 4: //% discount
|
||||
total = total + (itemInCart.productPrice * itemInCart.buyCount) * ( 1 - this.curCoupon.discount );
|
||||
this.discountAmount = (itemInCart.productPrice * itemInCart.buyCount) * this.curCoupon.discount;
|
||||
if(this.curCoupon.productCodes && this.curCoupon.productCodes.indexOf(itemInCart.productCode)>-1 && !couponUsed && checkResult) {
|
||||
console.log(itemInCart,'itemInCart');
|
||||
//Into coupon discount calculation
|
||||
switch(this.curCoupon.couponTypeId) {
|
||||
case 1: //Amount deduct
|
||||
/*
|
||||
if(this.curCoupon.couponAmount && this.curCoupon.couponAmount <= (itemInCart.productPrice * itemInCart.buyCount)) {
|
||||
total = total + (itemInCart.productPrice * itemInCart.buyCount - this.curCoupon.couponAmount);
|
||||
this.discountAmount = this.curCoupon.couponAmount;
|
||||
this.discountedProductCode = itemInCart.productCode;
|
||||
couponUsed=true;
|
||||
break;
|
||||
default:
|
||||
total += itemInCart.productPrice * itemInCart.buyCount;
|
||||
break;
|
||||
}
|
||||
//Into coupon discount calculation end
|
||||
} else if(this.curCoupon.couponAmount && this.curCoupon.couponAmount > (itemInCart.productPrice * itemInCart.buyCount)) {
|
||||
total = total + itemInCart.productPrice * itemInCart.buyCount;
|
||||
this.discountAmount = 0;
|
||||
this.curCoupon = {couponName:'未能使用该优惠券'};
|
||||
}
|
||||
break;
|
||||
*/
|
||||
case 2: //Amount deduct with minPrice restriction
|
||||
case 6:
|
||||
if(this.curCoupon.couponAmount && this.curCoupon.couponAmount <= qualifiedProductAmount && this.curCoupon.productCodes.indexOf(itemInCart.productCode)>-1) {
|
||||
total = total + qualifiedProductAmount - this.curCoupon.couponAmount;
|
||||
this.discountAmount = this.curCoupon.couponAmount;
|
||||
this.discountedProductCode = itemInCart.productCode;
|
||||
skipQualifiedProductAmountCalculating = true;
|
||||
couponUsed=true;
|
||||
} else if(this.curCoupon.couponAmount && this.curCoupon.couponAmount > qualifiedProductAmount) {
|
||||
total = total + itemInCart.productPrice * itemInCart.buyCount;
|
||||
this.discountAmount = 0;
|
||||
this.curCoupon = {couponName:'未能使用该优惠券'};
|
||||
}
|
||||
break;
|
||||
case 3: //Limited product % discount
|
||||
case 4: //% discount
|
||||
if(this.curCoupon.discount && this.curCoupon.productCodes.indexOf(itemInCart.productCode)>-1) {
|
||||
total = total + qualifiedProductAmount * ( 1 - this.curCoupon.discount );
|
||||
this.discountAmount = qualifiedProductAmount * this.curCoupon.discount;
|
||||
this.discountedProductCode = itemInCart.productCode;
|
||||
couponUsed=true;
|
||||
skipQualifiedProductAmountCalculating = true;
|
||||
} else if(this.curCoupon.couponAmount && this.curCoupon.couponAmount > qualifiedProductAmount) {
|
||||
total = total + itemInCart.productPrice * itemInCart.buyCount;
|
||||
this.discountAmount = 0;
|
||||
this.curCoupon = {couponName:'未能使用该优惠券'};
|
||||
}
|
||||
break;
|
||||
default:
|
||||
total += itemInCart.productPrice * itemInCart.buyCount;
|
||||
break;
|
||||
}
|
||||
//Into coupon discount calculation end
|
||||
} else {
|
||||
if(skipQualifiedProductAmountCalculating && this.curCoupon.productCodes.indexOf(itemInCart.productCode)>-1) {
|
||||
|
||||
@ -375,6 +406,11 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!couponUsed) {
|
||||
this.discountAmount = 0;
|
||||
this.curCoupon = {couponName:'未能使用该优惠券'};
|
||||
total = this.sumPrice;
|
||||
}
|
||||
return total;
|
||||
},
|
||||
arrSort(arr) {
|
||||
@ -436,16 +472,13 @@ export default {
|
||||
let avaliableCouponNum = 0;
|
||||
if (data) {
|
||||
this.drawlist=[];
|
||||
//avaliableCouponNum = data.length;
|
||||
//this.drawlist = data.data;
|
||||
|
||||
/*
|
||||
for(let itemInCart of this.goldmedal) {
|
||||
let tmpIndex=0;
|
||||
for(let myCoupon of data.data) {
|
||||
valDateFromTime=0;
|
||||
valDateToTime=0;
|
||||
dateChecked=true;
|
||||
/* */
|
||||
if(myCoupon.fValidFrom) {
|
||||
//Fix ios date issue
|
||||
myCoupon.fValidFrom = myCoupon.fValidFrom.replace(/-/g, '/');
|
||||
@ -487,12 +520,17 @@ export default {
|
||||
tmpIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
avaliableCouponNum = data.length;
|
||||
this.drawlist = data.data;
|
||||
|
||||
if(avaliableCouponNum > 0) {
|
||||
this.curCoupon.couponName = '有 '+avaliableCouponNum+' 张优惠券可以使用';
|
||||
}
|
||||
}
|
||||
},
|
||||
/* 关闭弹出框 计算价格 */
|
||||
pickCoupon(item){
|
||||
this.curCoupon = item;
|
||||
this.dialogInfo1 = false;
|
||||
|
@ -215,75 +215,16 @@ export default {
|
||||
|
||||
goldmedal: [
|
||||
{
|
||||
ordernumber: "1111111111111111111",
|
||||
ordernumber: "",
|
||||
orderstype: 1,
|
||||
usereat: "专属升级奖励",
|
||||
usereat: "",
|
||||
ordernum: 0,
|
||||
num: "5kg",
|
||||
specification: "1",
|
||||
buttontitle: "立即支付",
|
||||
userprice: "167.00",
|
||||
catimage: require("../../assets/image/rc-win.png"),
|
||||
},
|
||||
|
||||
{
|
||||
ordernumber: "1111111111111111111",
|
||||
|
||||
usereat: "每年4次免积分产品试吃",
|
||||
ordernum: 0,
|
||||
buttontitle: "再次购买",
|
||||
catimage: require("../../assets/image/usereat.png"),
|
||||
orderstype: 2,
|
||||
userprice: "167.00",
|
||||
},
|
||||
{
|
||||
ordernumber: "1111111111111111111",
|
||||
usereat: "尊享订单免邮服务(指点商品)",
|
||||
ordernum: 0,
|
||||
buttontitle: "取消订单",
|
||||
catimage: require("../../assets/image/usercar.png"),
|
||||
orderstype: 3,
|
||||
userprice: "167.00",
|
||||
},
|
||||
{
|
||||
ordernumber: "1111111111111111111",
|
||||
usereat: "365天专属养宠工具",
|
||||
ordernum: 1,
|
||||
catimage: require("../../assets/image/rc-growth.png"),
|
||||
orderstype: 1,
|
||||
userprice: "167.00",
|
||||
},
|
||||
{
|
||||
ordernumber: "1111111111111111111",
|
||||
usereat: "10年专业团队1v1咨询",
|
||||
ordernum: 2,
|
||||
catimage: require("../../assets/image/consult.png"),
|
||||
orderstype: 2,
|
||||
userprice: "167.00",
|
||||
},
|
||||
{
|
||||
ordernumber: "1111111111111111111",
|
||||
usereat: "行业大咖专业养宠知识",
|
||||
ordernum: 3,
|
||||
catimage: require("../../assets/image/rc-book.png"),
|
||||
orderstype: 3,
|
||||
userprice: "167.00",
|
||||
},
|
||||
{
|
||||
ordernumber: "1111111111111111111",
|
||||
usereat: "爱宠生活定制活动高级养宠宝典",
|
||||
ordernum: 3,
|
||||
catimage: require("../../assets/image/userself.png"),
|
||||
orderstype: 3,
|
||||
userprice: "167.00",
|
||||
},
|
||||
{
|
||||
usereat: "每年积分兑换1次价值288元的免费体检及100元医院绝育券",
|
||||
ordernum: 4,
|
||||
catimage: require("../../assets/image/rc-health.png"),
|
||||
orderstype: 3,
|
||||
userprice: "167.00",
|
||||
},
|
||||
num: "",
|
||||
specification: "",
|
||||
buttontitle: "",
|
||||
userprice: "",
|
||||
catimage: '',
|
||||
}
|
||||
],
|
||||
};
|
||||
},
|
||||
@ -322,6 +263,9 @@ export default {
|
||||
this.receiving=[];
|
||||
this.pending=[];
|
||||
for (let i = 0; i < this.goldmedal.length; i++) {
|
||||
|
||||
if(!this.goldmedal[i].orderDetailList)
|
||||
continue;
|
||||
this.useralllist.push(this.goldmedal[i].orderDetailList[0]);
|
||||
this.alllist.push(this.goldmedal[i].orderDetailList[0])
|
||||
this.allmessage.push(this.goldmedal[i].orderDetailList[0])
|
||||
@ -334,14 +278,19 @@ export default {
|
||||
this.pending.push(this.goldmedal[i].orderDetailList[0]);
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < this.goldmedal.length; i++) {
|
||||
this.useralllist[i].orderNumber = this.goldmedal[i].orderNumber;
|
||||
this.useralllist[i].status = this.goldmedal[i].status;
|
||||
this.useralllist[i].addressUserName = this.goldmedal[i].addressUserName;
|
||||
this.useralllist[i].phoneNumber = this.goldmedal[i].addressPhoneNumber;
|
||||
this.useralllist[i].salesAmount = this.goldmedal[i].salesAmount;
|
||||
this.useralllist[i].lengthnum=this.goldmedal[i].orderDetailList.length;
|
||||
this.useralllist[i].paytype=this.goldmedal[i].paytype;
|
||||
for (let y = 0; y < this.goldmedal.length; y++) {
|
||||
if(!this.goldmedal[y].orderDetailList)
|
||||
continue;
|
||||
if(!this.useralllist[y]){
|
||||
this.useralllist[y] = {};
|
||||
}
|
||||
this.useralllist[y].orderNumber = this.goldmedal[y].orderNumber;
|
||||
this.useralllist[y].status = this.goldmedal[y].status;
|
||||
this.useralllist[y].addressUserName = this.goldmedal[y].addressUserName;
|
||||
this.useralllist[y].phoneNumber = this.goldmedal[y].addressPhoneNumber;
|
||||
this.useralllist[y].salesAmount = this.goldmedal[y].salesAmount;
|
||||
this.useralllist[y].lengthnum=this.goldmedal[y].orderDetailList.length;
|
||||
this.useralllist[y].paytype=this.goldmedal[y].paytype;
|
||||
}
|
||||
if(this.userstype==1){
|
||||
this.useralllist=this.obligation
|
||||
@ -407,12 +356,13 @@ export default {
|
||||
type: "warning",
|
||||
message: "取消订单成功",
|
||||
});
|
||||
setTimeout(() => {
|
||||
this.indet(this.userdata);
|
||||
this.activeIndex=0;
|
||||
this.useralllist=[];
|
||||
}, 500);
|
||||
|
||||
/* 这个在全部变量去除的时候 记得加 */
|
||||
// setTimeout(() => {
|
||||
// this.indet(this.userdata);
|
||||
// this.activeIndex=0;
|
||||
// this.useralllist=[];
|
||||
// console.log('2222');
|
||||
// }, 500);
|
||||
}
|
||||
},
|
||||
|
||||
@ -456,10 +406,9 @@ export default {
|
||||
this.activeIndex = index;
|
||||
if(item.title=='待付款'){
|
||||
list=this.obligation
|
||||
}
|
||||
else if(item.title=='待收货'){
|
||||
} else if(item.title=='待收货'){
|
||||
list=this.receiving
|
||||
}else if(item.title=='待发货'){
|
||||
} else if(item.title=='待发货'){
|
||||
this.useralllist=this.pending
|
||||
list=this.pending
|
||||
}
|
||||
|
@ -109,7 +109,7 @@
|
||||
|
||||
</div>
|
||||
<div class="rc-button" v-if="!userbuy && curItem.curGoodUrl && curItem.curGoodUrl.length>5">
|
||||
<a :href="curItem.curGoodUrl" target='_blank' class="ts-standard-btn">立即购买</a>
|
||||
<a @click="goBuyRxgoods(curItem)" class="ts-standard-btn">立即购买</a>
|
||||
</div>
|
||||
|
||||
|
||||
@ -237,7 +237,8 @@
|
||||
¥
|
||||
</i>
|
||||
<span>
|
||||
{{ item.couponAmount?item.couponAmount:(parseInt((1-item.discount)*10)+'折') }}
|
||||
<!-- 不合并 因为0.1计算器不是0.1 -->
|
||||
{{ item.couponAmount?item.couponAmount:(parseInt(10 - item.discount*10)+'折') }}
|
||||
</span>
|
||||
</div>
|
||||
<strong>{{ item.couponName }}</strong>
|
||||
@ -280,7 +281,7 @@
|
||||
<span @click="usertanchu(curItem, 1)">立即购买</span>
|
||||
</div>
|
||||
<div class="rc-button rc-md-down " v-if="!userbuy && curItem.goodUrl && curItem.goodUrl.length>5">
|
||||
<a :href="curItem.goodUrl" target='_blank' class="ts-standard-btn">立即购买</a>
|
||||
<a @click="goBuyRxgoods(curItem)" class="ts-standard-btn">立即购买</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -510,7 +511,27 @@ export default {
|
||||
}
|
||||
])
|
||||
},
|
||||
|
||||
goBuyRxgoods() {
|
||||
this.checkIsLogin();
|
||||
let _self = this;
|
||||
let memberId = '';
|
||||
if (this.$store.state.userInfo && this.$store.state.userInfo.data !== undefined) {
|
||||
memberId = this.$store.state.userInfo.data.id;
|
||||
}
|
||||
_hmt.push([
|
||||
'_trackCustomEvent',
|
||||
'buy_rxgoods',
|
||||
{
|
||||
'member_id': memberId, // 会员ID,文本类型
|
||||
'product_name': this.curItem.productName, // 商品名称,文本类型
|
||||
'product_id': this.curItem.productCode // 商品ID,文本类型
|
||||
}
|
||||
])
|
||||
|
||||
setTimeout(function(){
|
||||
window.open(_self.curItem.curGoodUrl, '_blank');
|
||||
},1000);
|
||||
},
|
||||
//获取用户领取的优惠券
|
||||
async getconf(memberId, couponId) {
|
||||
let data = await getConfig(memberId, couponId);
|
||||
|
@ -143,7 +143,7 @@
|
||||
|
||||
<script>
|
||||
import { userLongin,sendMsg,vadatnmsg,userregOrLogin,inserdiscount } from "../../ajax/getData";
|
||||
import { mapMutations } from "vuex";
|
||||
import { mapMutations,mapState } from "vuex";
|
||||
import envData from "~/config/env-data.js";
|
||||
import Myheader from "~/components/header.vue"; //引用头部公共组件
|
||||
export default {
|
||||
@ -218,6 +218,9 @@ export default {
|
||||
return "";
|
||||
}
|
||||
},
|
||||
...mapState({
|
||||
userInfo : state => state.user.userInfo,
|
||||
})
|
||||
},
|
||||
mounted() {
|
||||
//console.log(this.$route.params);
|
||||
|
38
rc-busness/plugins/until/until.js
Normal file
38
rc-busness/plugins/until/until.js
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
这个是存放静态公共方法
|
||||
*/
|
||||
|
||||
/**
|
||||
* 设置cookie的值
|
||||
* @param {String} key cookie的键
|
||||
* @param {String} val cookie的值
|
||||
* @param {String} exdays 过期时间默认的话是7天
|
||||
*/
|
||||
const setCookie = (key,val,exdays = 7)=>{
|
||||
var d = new Date();
|
||||
d.setTime(d.getTime()+(exdays*24*60*60*1000));
|
||||
var expires = "expires="+d.toGMTString();
|
||||
document.cookie = key + "=" + val + "; " + expires;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取cookie的值
|
||||
* @param {String} key cookie的键
|
||||
*/
|
||||
const getCookie = (key)=>{
|
||||
var name = key + "=";
|
||||
var ca = document.cookie.split(';');
|
||||
for(var i=0; i<ca.length; i++){
|
||||
var c = ca[i].trim();
|
||||
if(c.indexOf(name)==0) return c.substring(name.length,c.length);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
export {
|
||||
setCookie,
|
||||
getCookie,
|
||||
}
|
@ -1,3 +1,6 @@
|
||||
import user from './modules/user.js';
|
||||
|
||||
|
||||
const state = () => ({
|
||||
// 这里是全局数据保存的地方
|
||||
tabsList: [
|
||||
@ -61,4 +64,11 @@ const actions = {
|
||||
}
|
||||
}
|
||||
|
||||
export default {namespaced: true, state, mutations, actions}
|
||||
/* 功能模块 */
|
||||
const modules = {
|
||||
user,
|
||||
}
|
||||
|
||||
|
||||
|
||||
export default {namespaced: true, state, mutations, actions,modules}
|
||||
|
17
rc-busness/store/modules/login.js
Normal file
17
rc-busness/store/modules/login.js
Normal file
@ -0,0 +1,17 @@
|
||||
export default {
|
||||
state : {
|
||||
des : '这个存储用户登录逻辑操作',
|
||||
loginState : false, //登录状态
|
||||
},
|
||||
/* 存储修改状态的静态方法 */
|
||||
mutations : {
|
||||
/* 设置登录状态 */
|
||||
SET_LOGIN_STATE(state){
|
||||
console.log(state);
|
||||
}
|
||||
},
|
||||
/* 存储修改数据的动态方法 */
|
||||
actions : {
|
||||
|
||||
}
|
||||
}
|
18
rc-busness/store/modules/user.js
Normal file
18
rc-busness/store/modules/user.js
Normal file
@ -0,0 +1,18 @@
|
||||
export default {
|
||||
state : {
|
||||
des : '这个存储用户数据的模块列表',
|
||||
userInfo : {}, //用户信息
|
||||
loginState : false, //登录状态
|
||||
},
|
||||
/* 存储修改状态的静态方法 */
|
||||
mutations : {
|
||||
/* 设置用户信息 */
|
||||
SET_USER_INFO(state){
|
||||
console.log(state);
|
||||
}
|
||||
},
|
||||
/* 存储修改数据的动态方法 */
|
||||
actions : {
|
||||
|
||||
}
|
||||
}
|
@ -20,6 +20,8 @@
|
||||
"axios": "^0.19.2",
|
||||
"core-js": "^3.6.5",
|
||||
"fastclick": "^1.0.6",
|
||||
"joi": "^17.6.0",
|
||||
"join": "^3.0.0",
|
||||
"js-cookie": "^2.2.1",
|
||||
"lib-flexible": "^0.3.2",
|
||||
"lodash": "^4.17.20",
|
||||
@ -27,19 +29,21 @@
|
||||
"nprogress": "^0.2.0",
|
||||
"regenerator-runtime": "^0.13.5",
|
||||
"vant": "^2.11.1",
|
||||
"vue": "^2.6.12",
|
||||
"vue": "^3.2.31",
|
||||
"vue-enum": "^1.0.5",
|
||||
"vue-loader": "^17.0.0",
|
||||
"vue-loading-overlay": "^3.4.2",
|
||||
"vue-router": "^3.4.0",
|
||||
"vuex": "^3.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sentry/webpack-plugin": "^1.11.1",
|
||||
"@sentry/webpack-plugin": "^1.18.8",
|
||||
"@vue/cli-plugin-babel": "~4.5.0",
|
||||
"@vue/cli-plugin-eslint": "~4.5.0",
|
||||
"@vue/cli-plugin-router": "~4.5.0",
|
||||
"@vue/cli-plugin-vuex": "~4.5.0",
|
||||
"@vue/cli-service": "~4.5.0",
|
||||
"@vue/compiler-sfc": "^3.2.31",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"babel-plugin-import": "^1.13.0",
|
||||
"babel-plugin-transform-remove-console": "^6.9.4",
|
||||
|
@ -11,6 +11,9 @@ const projectConfig = require('./src/config/index.js');
|
||||
// 生产环境,测试和正式
|
||||
const isProductionEnv = ['production'].includes(process.env.NODE_ENV);
|
||||
const isProductionAppEnv = ['prod', 'pre'].includes(process.env.VUE_APP_ENV);
|
||||
const addOptions = {
|
||||
preserveWhitespace: true
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
publicPath: projectConfig.publicPath,
|
||||
@ -93,7 +96,7 @@ module.exports = {
|
||||
.use('vue-loader')
|
||||
.loader('vue-loader')
|
||||
.tap(options => {
|
||||
options.compilerOptions.preserveWhitespace = true;
|
||||
options.compilerOptions = addOptions;
|
||||
return options;
|
||||
})
|
||||
.end();
|
||||
|
@ -7,6 +7,7 @@ import net.lab1024.smartadmin.module.system.royalcanin.coupon.*;
|
||||
import net.lab1024.smartadmin.util.MapRemoveNullUtil;
|
||||
import net.lab1024.smartadmin.util.SmartDateUtil;
|
||||
import net.lab1024.smartadmin.util.SmartHttpUtil;
|
||||
import net.lab1024.smartadmin.util.SmartStringUtil;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -56,13 +57,18 @@ public class CouponService {
|
||||
JSONObject jsonObjectResult = JSONObject.parseObject(result);
|
||||
com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(jsonObjectResult.getString("data"));
|
||||
com.alibaba.fastjson.JSONArray afterFilterArrary = new JSONArray();
|
||||
Date nowDate =SmartDateUtil.parseYMD(SmartDateUtil.formatYMD(new Date()));
|
||||
for(int i = 0;i < jsonArray.size();i ++){
|
||||
JSONObject jsonResult = (JSONObject)jsonArray.get(i);
|
||||
if(jsonResult.getString("udf2") != null) {
|
||||
//优惠券有效过期时间
|
||||
Date compareDate = SmartDateUtil.parseYMD(jsonResult.get("fValidTo").toString());
|
||||
if ("H5".equals(jsonResult.getString("udf2"))&&"".equals(productCode)&&compareDate.compareTo(currentDate)!=-1) {
|
||||
//优惠券有效开始时间
|
||||
Date startDate = SmartDateUtil.parseYMD(jsonResult.get("fValidFrom").toString());
|
||||
if ("H5".equals(jsonResult.getString("udf2"))&& SmartStringUtil.isBlank(couponGetAllEntity.getProductCodes())) {
|
||||
afterFilterArrary.add(jsonResult);
|
||||
}else if ("H5".equals(jsonResult.getString("udf2"))&&!"".equals(productCode)&&compareDate.compareTo(currentDate)!=-1){
|
||||
}else if ("H5".equals(jsonResult.getString("udf2"))&& SmartStringUtil.isNotBlank(couponGetAllEntity.getProductCodes()) &&compareDate.compareTo(currentDate)!=-1
|
||||
&& startDate.compareTo(nowDate) != 1 && compareDate.compareTo(nowDate) != -1){
|
||||
for(int g = 0 ;g<productCode.length;g++) {
|
||||
if ((jsonResult.get("productCodes") != null ? jsonResult.get("productCodes").toString().indexOf(productCode[g]) : "".indexOf(productCode[g])) != -1 || jsonResult.get("productCodes") == null) {
|
||||
afterFilterArrary.add(jsonResult);
|
||||
|
@ -28,6 +28,7 @@ import net.lab1024.smartadmin.module.system.wxpay.MyConfig;
|
||||
import net.lab1024.smartadmin.module.system.wxpay.WxpayService;
|
||||
import net.lab1024.smartadmin.module.system.wxpay.wxPayModel.WxPayEntity;
|
||||
import net.lab1024.smartadmin.util.GenerateSequenceUtil;
|
||||
import net.lab1024.smartadmin.util.SmartStringUtil;
|
||||
import net.sf.json.JSONArray;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -60,8 +61,21 @@ public class OrderController {
|
||||
@Autowired
|
||||
private GoodService goodService;
|
||||
|
||||
|
||||
@ApiOperation(value = "微信支付订单", notes = "生成订单")
|
||||
@PostMapping("royalcanin/generateOrderWX")
|
||||
public ResponseDTO<Map<String, String>> generateOrderWX(@RequestBody List<OrdersEntity> ordersEntityList){
|
||||
return orderService.createOrderWXInfo(ordersEntityList);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "微信支付H5订单", notes = "生成H5订单")
|
||||
@PostMapping("royalcanin/generateOrderWXH5")
|
||||
public ResponseDTO<Map<String, String>> generateOrderWXH5(@RequestBody List<OrdersEntity> ordersEntityList){
|
||||
return orderService.createOrderWXH5Info(ordersEntityList);
|
||||
}
|
||||
|
||||
|
||||
//原API
|
||||
/* @ApiOperation(value = "微信支付订单", notes = "生成订单")
|
||||
@PostMapping("royalcanin/generateOrderWX")
|
||||
public ResponseDTO<Map<String, String>> generateOrderWX(@RequestBody List<OrdersEntity> ordersEntityList){
|
||||
StringBuffer productId = new StringBuffer();
|
||||
@ -71,7 +85,7 @@ public class OrderController {
|
||||
int buyCount = 0;
|
||||
double total_fee = 0 ;
|
||||
double basePoint = 0 ;
|
||||
WxPayEntity wxPayEntity = new WxPayEntity();
|
||||
WxPayEntity wxPayEntity = new WxPayEntity();--------
|
||||
JSONArray orderDatilListJson = new JSONArray();
|
||||
OrdersEntity ordersEntity = new OrdersEntity();
|
||||
OrderAddress orderAddress = new OrderAddress();
|
||||
@ -170,10 +184,10 @@ public class OrderController {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_FAIL,resultMsg.get("msg"));
|
||||
}
|
||||
} */
|
||||
|
||||
|
||||
@ApiOperation(value = "微信支付H5订单", notes = "生成H5订单")
|
||||
/* @ApiOperation(value = "微信支付H5订单", notes = "生成H5订单")
|
||||
@PostMapping("royalcanin/generateOrderWXH5")
|
||||
public ResponseDTO<Map<String, String>> generateOrderWXH5(@RequestBody List<OrdersEntity> ordersEntityList){
|
||||
StringBuffer productId = new StringBuffer();
|
||||
@ -281,7 +295,7 @@ public class OrderController {
|
||||
}
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_FAIL,resultMsg.get("msg"));
|
||||
}
|
||||
|
||||
*/
|
||||
@ApiOperation(value = "微信支付JSAPI订单", notes = "生成JSAPI订单")
|
||||
@PostMapping("royalcanin/generateOrderWXJSAPI")
|
||||
public ResponseDTO<Map<String, String>> generateOrderWXJSAPI(@RequestBody List<OrdersEntity> ordersEntityList,String resp) throws Exception {
|
||||
|
@ -7,7 +7,6 @@ public class OrderResponseCodeConst extends ResponseCodeConst {
|
||||
|
||||
public static final OrderResponseCodeConst COUPON_USE_FAIL = new OrderResponseCodeConst(9001, "优惠卷使用失败!");
|
||||
|
||||
|
||||
public static final OrderResponseCodeConst GENERATE_ORDER_FAIL = new OrderResponseCodeConst(9002, "订单生成失败!");
|
||||
|
||||
public static final OrderResponseCodeConst GENERATE_FAIL = new OrderResponseCodeConst(9003, "数据生成失败!");
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.lab1024.smartadmin.module.system.royalcanin.good.service;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import net.lab1024.smartadmin.common.domain.ResponseDTO;
|
||||
@ -9,6 +10,7 @@ import net.lab1024.smartadmin.module.system.royalcanin.CouponService;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.coupon.CouponCancelEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.coupon.CouponCosumeEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.coupon.CouponFetchEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.coupon.CouponGetAllEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.domain.RoyalcaninOperateLogEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.domain.RoyalcaninOperateLogService;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.constant.OrderResponseCodeConst;
|
||||
@ -16,13 +18,15 @@ import net.lab1024.smartadmin.module.system.royalcanin.good.dao.OrdersDao;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.model.OrderAddress;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.model.OrderEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.model.OrdersEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.model.ProductMasterQueryEntity;
|
||||
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.OrderDatilListEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.orderMaster.QueryEntity;
|
||||
import net.lab1024.smartadmin.util.AESUtil;
|
||||
import net.lab1024.smartadmin.util.MapRemoveNullUtil;
|
||||
import net.lab1024.smartadmin.util.SmartHttpUtil;
|
||||
import net.lab1024.smartadmin.module.system.wxpay.WxpayService;
|
||||
import net.lab1024.smartadmin.module.system.wxpay.wxPayModel.WxPayEntity;
|
||||
import net.lab1024.smartadmin.util.*;
|
||||
import net.sf.json.JSONArray;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@ -31,7 +35,9 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@ -40,6 +46,18 @@ public class OrderService {
|
||||
@Autowired
|
||||
private CouponService couponService;
|
||||
|
||||
@Autowired
|
||||
private GoodService goodService;
|
||||
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
|
||||
@Autowired
|
||||
private CartService cartService;
|
||||
|
||||
@Autowired
|
||||
private WxpayService wxpayService;
|
||||
|
||||
@Autowired
|
||||
private RoyalcaninOperateLogService royalcaninOperateLogService;
|
||||
|
||||
@ -53,7 +71,7 @@ public class OrderService {
|
||||
private String url ;
|
||||
|
||||
@Transactional
|
||||
public Map<String,String> generateOrder(OrdersEntity ordersEntity, JSONArray listJson) throws Exception {
|
||||
public Map<String,String>generateOrder(OrdersEntity ordersEntity, JSONArray listJson) throws Exception {
|
||||
AddOrSaveEntity addOrSaveEntity = new AddOrSaveEntity();
|
||||
Map<String, String>resultMap = new HashMap<>();
|
||||
try {
|
||||
@ -253,6 +271,10 @@ public class OrderService {
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
String afterDecodeResult = AESUtil.decryptLinux(jsonObject.getString("data"), AESUtil.KEY);
|
||||
com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(afterDecodeResult);
|
||||
//获取的是接收的数据
|
||||
jsonObject.put("data", jsonArray);
|
||||
result = JSONObject.toJSONString(jsonObject);
|
||||
|
||||
for (int i = 0; i < jsonArray.size();i++){
|
||||
JSONObject jsonObjectResult = (JSONObject)jsonArray.get(i);
|
||||
OrderEntity orderEntity = ordersDao.findByOrderId(jsonObjectResult.getString("orderNumber"));
|
||||
@ -277,6 +299,7 @@ public class OrderService {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//记录服务响应时间
|
||||
addOperatreFullData(url+"orderMaster/query",queryEntity.toString(),result, startTime,elapsedTime,acceptTime);
|
||||
|
||||
@ -335,4 +358,396 @@ public class OrderService {
|
||||
public int updateOrder(String orderNumber){
|
||||
return ordersDao.updateByOrderNumber(orderNumber);
|
||||
}
|
||||
|
||||
public BigDecimal computeTotal(String couponTypeId, BigDecimal discount, BigDecimal total) {
|
||||
BigDecimal endTotal = new BigDecimal("0");
|
||||
switch (couponTypeId)
|
||||
{
|
||||
// case "5" :
|
||||
// endTotal = (total * (buyCount-1)) + (total * discount);
|
||||
// break;
|
||||
case "2":
|
||||
//total - discount
|
||||
endTotal = total.subtract(discount);
|
||||
break;
|
||||
case "3":
|
||||
//total *(1 - discount)
|
||||
endTotal = total.multiply(new BigDecimal("1").subtract(discount));
|
||||
break;
|
||||
case "1" :
|
||||
//total - discount
|
||||
endTotal = total.subtract(discount);
|
||||
break;
|
||||
case "4" :
|
||||
//total *(1 - discount)
|
||||
endTotal = total.multiply(new BigDecimal("1").subtract(discount));
|
||||
break;
|
||||
case "6" :
|
||||
//total - discount
|
||||
endTotal = total.subtract(discount);
|
||||
break;
|
||||
}
|
||||
return endTotal;
|
||||
}
|
||||
|
||||
//
|
||||
public ResponseDTO<Map<String, String>> createOrderWXInfo(List<OrdersEntity> ordersEntityList) {
|
||||
Map<String, String> resultMsg = new HashMap<>();
|
||||
BigDecimal total_fee = new BigDecimal("0");
|
||||
WxPayEntity wxPayEntity = new WxPayEntity();
|
||||
JSONArray orderDatilListJson = new JSONArray();
|
||||
OrdersEntity ordersEntity = new OrdersEntity();
|
||||
JSONObject couponJson = null;
|
||||
|
||||
String memberId = null;
|
||||
String couponCode = null;
|
||||
try {
|
||||
//先查订单存在的优惠券
|
||||
for (OrdersEntity orders : ordersEntityList){
|
||||
if (SmartStringUtil.isNotEmpty(orders.getCouponCode())) {
|
||||
couponCode = orders.getCouponCode();
|
||||
}
|
||||
memberId = orders.getMemberId();
|
||||
}
|
||||
|
||||
//根据有没有优惠券来计算商品的总价
|
||||
if(SmartStringUtil.isNotEmpty(couponCode)){
|
||||
CouponGetAllEntity couponGetAllEntity = new CouponGetAllEntity();
|
||||
couponGetAllEntity.setMemberId(memberId);
|
||||
couponGetAllEntity.setCouponCode(couponCode);
|
||||
String couponInfo = couponService.couponGetAll(couponGetAllEntity);
|
||||
JSONObject jsonObject = JSONObject.parseObject(couponInfo);
|
||||
com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(jsonObject.getString("data"));
|
||||
if(jsonArray.size() == 0){
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL);
|
||||
}
|
||||
|
||||
JSONObject jsonObjectData = (JSONObject) jsonArray.get(0);
|
||||
if (jsonObjectData.getString("udf2") != null){
|
||||
if (!jsonObjectData.getString("udf2").equals("H5")){
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL);
|
||||
}
|
||||
}
|
||||
|
||||
//根据productCodes来判断优惠券的类型,空的话就是通用券,不是空就是指定类别券
|
||||
if(SmartStringUtil.isNotBlank(jsonObjectData.getString("productCodes"))){
|
||||
// BigDecimal total_Coupon = new BigDecimal("0");
|
||||
Map<String, Object> resultMap = addOrdersEntityInfo(ordersEntityList, ordersEntity, jsonObjectData,total_fee);
|
||||
//ordersEntity = (OrdersEntity) resultMap.get("ordersEntity");
|
||||
orderDatilListJson = (JSONArray) resultMap.get("orderDatilListJson");
|
||||
//得到当前能用优惠券的商品总金额
|
||||
BigDecimal total_Coupon = (BigDecimal) resultMap.get("total_Coupon");
|
||||
int minCount = (int) resultMap.get("minCount");
|
||||
|
||||
//校验当前订单金额小于优惠券金额
|
||||
if(jsonObjectData.getString("couponAmount") != null ){
|
||||
BigDecimal couponAmount = new BigDecimal(jsonObjectData.getString("couponAmount"));
|
||||
if(total_Coupon.compareTo(couponAmount) == -1){
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL);
|
||||
}
|
||||
}
|
||||
|
||||
//校验当前指定商品的总数量有没有大于等于minCount
|
||||
if(jsonObjectData.getString("minCount") != null ){
|
||||
int count = Integer.parseInt(jsonObjectData.getString("minCount"));
|
||||
if(minCount < count ){
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL);
|
||||
}
|
||||
}
|
||||
//校验当前指定商品的总购买数量有没有大于等于minPrice
|
||||
if(jsonObjectData.getString("minPrice") != null ){
|
||||
if(total_Coupon.compareTo(new BigDecimal(jsonObjectData.getString("minPrice"))) == -1){
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL);
|
||||
}
|
||||
}
|
||||
|
||||
//设置ordersEntity的参数
|
||||
addOrdersEntity(jsonObjectData, ordersEntity);
|
||||
//total_fee = orderService.couponTotal(ordersEntity.getCouponTypeId(), Double.parseDouble(ordersEntity.getCouponAmount()), total_Coupon);
|
||||
//得出指定类用完优惠券后的金额
|
||||
total_Coupon = orderService.computeTotal(ordersEntity.getCouponTypeId(), new BigDecimal(ordersEntity.getCouponAmount()), total_Coupon);
|
||||
//得出最终实际的支付金额
|
||||
total_fee = new BigDecimal(ordersEntity.getOrderAmount()).add(total_Coupon);
|
||||
}else{//通用类优惠券的实际支付逻辑
|
||||
Map<String, Object> resultMap = addOrdersEntityInfo(ordersEntityList, ordersEntity, couponJson, total_fee);
|
||||
//ordersEntity = (OrdersEntity) resultMap.get("ordersEntity");
|
||||
orderDatilListJson = (JSONArray) resultMap.get("orderDatilListJson");
|
||||
//校验当前订单金额小于优惠券金额
|
||||
if(jsonObjectData.getString("couponAmount") != null ){
|
||||
BigDecimal couponAmount = new BigDecimal(jsonObjectData.getString("couponAmount"));
|
||||
if(new BigDecimal(ordersEntity.getOrderAmount()).compareTo(couponAmount) == -1){
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL);
|
||||
}
|
||||
}
|
||||
//设置ordersEntity的参数
|
||||
addOrdersEntity(jsonObjectData, ordersEntity);
|
||||
//total_fee = orderService.couponTotal(ordersEntity.getCouponTypeId(), Double.parseDouble(ordersEntity.getCouponAmount()), total_fee);
|
||||
total_fee = orderService.computeTotal(ordersEntity.getCouponTypeId(), new BigDecimal(ordersEntity.getCouponAmount()), new BigDecimal(ordersEntity.getOrderAmount()));
|
||||
}
|
||||
}else{//没有优惠券的计算总价逻辑
|
||||
Map<String, Object> resultMap = addOrdersEntityInfo(ordersEntityList, ordersEntity, couponJson, total_fee);
|
||||
total_fee = new BigDecimal(ordersEntity.getOrderAmount());
|
||||
orderDatilListJson = (JSONArray) resultMap.get("orderDatilListJson");
|
||||
}
|
||||
|
||||
ordersEntity.setMemberId(memberId);
|
||||
ordersEntity.setOrderAmount(StringUtil.toString(total_fee));
|
||||
ordersEntity.setOrderNo(GenerateSequenceUtil.generateSequenceNo());
|
||||
ordersEntity.setOrderStatus("0");
|
||||
ordersEntity.setPayType("3");
|
||||
resultMsg = orderService.generateOrder(ordersEntity, orderDatilListJson);
|
||||
if (resultMsg.get("code").equals("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.generateQRCode(wxPayEntity));
|
||||
}else if (resultMsg.get("code").equals("0")){
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_ERROR,resultMsg.get("msg"));
|
||||
}else if (resultMsg.get("code").equals("3")){
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_FAIL_COUPONDED,resultMsg.get("msg"));
|
||||
}else if (resultMsg.get("code").equals("4")){
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL,resultMsg.get("msg"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_FAIL,resultMsg.get("msg"));
|
||||
}
|
||||
|
||||
//提交订单生成逻辑
|
||||
public ResponseDTO<Map<String, String>> createOrderWXH5Info(List<OrdersEntity> ordersEntityList) {
|
||||
Map<String, String> resultMsg = new HashMap<>();
|
||||
BigDecimal total_fee = new BigDecimal("0");
|
||||
WxPayEntity wxPayEntity = new WxPayEntity();
|
||||
JSONArray orderDatilListJson = new JSONArray();
|
||||
OrdersEntity ordersEntity = new OrdersEntity();
|
||||
JSONObject couponJson = null;
|
||||
|
||||
String memberId = null;
|
||||
String couponCode = null;
|
||||
try {
|
||||
//先查订单存在的优惠券
|
||||
for (OrdersEntity orders : ordersEntityList){
|
||||
if (SmartStringUtil.isNotEmpty(orders.getCouponCode())) {
|
||||
couponCode = orders.getCouponCode();
|
||||
}
|
||||
memberId = orders.getMemberId();
|
||||
}
|
||||
|
||||
//根据有没有优惠券来计算商品的总价
|
||||
if(SmartStringUtil.isNotEmpty(couponCode)){
|
||||
CouponGetAllEntity couponGetAllEntity = new CouponGetAllEntity();
|
||||
couponGetAllEntity.setMemberId(memberId);
|
||||
couponGetAllEntity.setCouponCode(couponCode);
|
||||
String couponInfo = couponService.couponGetAll(couponGetAllEntity);
|
||||
JSONObject jsonObject = JSONObject.parseObject(couponInfo);
|
||||
com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(jsonObject.getString("data"));
|
||||
if(jsonArray.size() == 0){
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL);
|
||||
}
|
||||
|
||||
JSONObject jsonObjectData = (JSONObject) jsonArray.get(0);
|
||||
if (jsonObjectData.getString("udf2") != null){
|
||||
if (!jsonObjectData.getString("udf2").equals("H5")){
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL);
|
||||
}
|
||||
}
|
||||
|
||||
//根据productCodes来判断优惠券的类型,空的话就是通用券,不是空就是指定类别券
|
||||
if(SmartStringUtil.isNotBlank(jsonObjectData.getString("productCodes"))){
|
||||
// BigDecimal total_Coupon = new BigDecimal("0");
|
||||
Map<String, Object> resultMap = addOrdersEntityInfo(ordersEntityList, ordersEntity, jsonObjectData,total_fee);
|
||||
//ordersEntity = (OrdersEntity) resultMap.get("ordersEntity");
|
||||
orderDatilListJson = (JSONArray) resultMap.get("orderDatilListJson");
|
||||
//得到当前能用优惠券的商品总金额
|
||||
BigDecimal total_Coupon = (BigDecimal) resultMap.get("total_Coupon");
|
||||
int minCount = (int) resultMap.get("minCount");
|
||||
|
||||
//校验当前订单金额小于优惠券金额
|
||||
if(jsonObjectData.getString("couponAmount") != null ){
|
||||
BigDecimal couponAmount = new BigDecimal(jsonObjectData.getString("couponAmount"));
|
||||
if(total_Coupon.compareTo(couponAmount) == -1){
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL);
|
||||
}
|
||||
}
|
||||
//校验当前指定商品的总数量有没有大于等于minCount
|
||||
if(jsonObjectData.getString("minCount") != null ){
|
||||
int count = Integer.parseInt(jsonObjectData.getString("minCount"));
|
||||
if(minCount < count ){
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL);
|
||||
}
|
||||
}
|
||||
//校验当前指定商品的总购买数量有没有大于等于minPrice
|
||||
if(jsonObjectData.getString("minPrice") != null ){
|
||||
if(total_Coupon.compareTo(new BigDecimal(jsonObjectData.getString("minPrice"))) == -1){
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL);
|
||||
}
|
||||
}
|
||||
|
||||
//设置ordersEntity的参数
|
||||
addOrdersEntity(jsonObjectData, ordersEntity);
|
||||
//total_fee = orderService.couponTotal(ordersEntity.getCouponTypeId(), Double.parseDouble(ordersEntity.getCouponAmount()), total_Coupon);
|
||||
//得出指定类用完优惠券后的金额
|
||||
total_Coupon = orderService.computeTotal(ordersEntity.getCouponTypeId(), new BigDecimal(ordersEntity.getCouponAmount()), total_Coupon);
|
||||
//得出最终实际的支付金额
|
||||
total_fee = new BigDecimal(ordersEntity.getOrderAmount()).add(total_Coupon);
|
||||
}else{//通用类优惠券的实际支付逻辑
|
||||
Map<String, Object> resultMap = addOrdersEntityInfo(ordersEntityList, ordersEntity, couponJson, total_fee);
|
||||
//ordersEntity = (OrdersEntity) resultMap.get("ordersEntity");
|
||||
orderDatilListJson = (JSONArray) resultMap.get("orderDatilListJson");
|
||||
//校验当前订单金额小于优惠券金额
|
||||
if(jsonObjectData.getString("couponAmount") != null ){
|
||||
BigDecimal couponAmount = new BigDecimal(jsonObjectData.getString("couponAmount"));
|
||||
if(new BigDecimal(ordersEntity.getOrderAmount()).compareTo(couponAmount) == -1){
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL);
|
||||
}
|
||||
}
|
||||
//设置ordersEntity的参数
|
||||
addOrdersEntity(jsonObjectData, ordersEntity);
|
||||
//total_fee = orderService.couponTotal(ordersEntity.getCouponTypeId(), Double.parseDouble(ordersEntity.getCouponAmount()), total_fee);
|
||||
total_fee = orderService.computeTotal(ordersEntity.getCouponTypeId(), new BigDecimal(ordersEntity.getCouponAmount()), new BigDecimal(ordersEntity.getOrderAmount()));
|
||||
}
|
||||
}else{//没有优惠券的计算总价逻辑
|
||||
Map<String, Object> resultMap = addOrdersEntityInfo(ordersEntityList, ordersEntity, couponJson, total_fee);
|
||||
total_fee = new BigDecimal(ordersEntity.getOrderAmount());
|
||||
orderDatilListJson = (JSONArray) resultMap.get("orderDatilListJson");
|
||||
}
|
||||
|
||||
ordersEntity.setMemberId(memberId);
|
||||
ordersEntity.setOrderAmount(StringUtil.toString(total_fee));
|
||||
ordersEntity.setOrderNo(GenerateSequenceUtil.generateSequenceNo());
|
||||
ordersEntity.setOrderStatus("0");
|
||||
ordersEntity.setPayType("3");
|
||||
resultMsg = generateOrder(ordersEntity, orderDatilListJson);
|
||||
if (resultMsg.get("code").equals("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.dounifiedOrder(wxPayEntity));
|
||||
}else if (resultMsg.get("code").equals("0")){
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_ERROR,resultMsg.get("msg"));
|
||||
}else if (resultMsg.get("code").equals("3")){
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_FAIL_COUPONDED,resultMsg.get("msg"));
|
||||
}else if (resultMsg.get("code").equals("4")){
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL,resultMsg.get("msg"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_ORDER_FAIL,resultMsg.get("msg"));
|
||||
}
|
||||
|
||||
//计算无优惠券、通用券商品总价等信息
|
||||
private Map<String, Object> addOrdersEntityInfo(List<OrdersEntity> ordersEntityList, OrdersEntity ordersEntity, JSONObject couponJson, BigDecimal total_fee) throws Exception {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
JSONArray orderDatilListJson = new JSONArray();
|
||||
OrderAddress orderAddress = new OrderAddress();
|
||||
StringBuffer productId = new StringBuffer();
|
||||
StringBuffer productName = new StringBuffer();
|
||||
//BigDecimal total_fee = new BigDecimal("0");
|
||||
BigDecimal total_Coupon = new BigDecimal("0");
|
||||
String[] productCodes = null;
|
||||
Boolean isExist = false;
|
||||
double basePoint = 0 ;
|
||||
String mobile = "";
|
||||
int buyCount = 0;
|
||||
int minCount = 0;
|
||||
|
||||
//判断是否属于指定类
|
||||
if(couponJson != null && SmartStringUtil.isNotBlank(couponJson.getString("productCodes"))){
|
||||
isExist = true;
|
||||
productCodes = couponJson.getString("productCodes").toString().split(",");
|
||||
}
|
||||
|
||||
for (OrdersEntity order : ordersEntityList) {
|
||||
//从crm获取商品的json数据信息
|
||||
JSONObject goodsObject = gainGoodsObject(order);
|
||||
//删除购物车信息
|
||||
cartService.cancelProduct(order.getMemberId(), order.getProductCode());
|
||||
//拼接商品数据信息得到
|
||||
splicingOrderDetail(order, goodsObject, orderDatilListJson);
|
||||
//设置订单地址信息
|
||||
addOrderAddress(orderAddress, order);
|
||||
//筛选能用当前优惠券的商品3
|
||||
if(isExist && Arrays.asList(productCodes).contains(goodsObject.get("productCode"))){
|
||||
//计算商品价格、数量、basepoint相关信息
|
||||
total_Coupon = calculationTotal(order, goodsObject, total_Coupon);
|
||||
minCount = minCount + order.getBuyCount();
|
||||
}else{
|
||||
//计算商品价格、数量、basepoint相关信息
|
||||
total_fee = calculationTotal(order, goodsObject, total_fee);
|
||||
}
|
||||
buyCount = buyCount + order.getBuyCount();
|
||||
basePoint = basePoint + order.getBasePoint();
|
||||
productId.append(order.getProductCode() + ",");
|
||||
productName.append(order.getProductName() + ",");
|
||||
mobile = order.getPhoneNumber();
|
||||
}
|
||||
|
||||
ordersEntity.setOrderAddress(orderAddress);
|
||||
ordersEntity.setCouponAmount(ordersEntity.getCouponAmount());
|
||||
ordersEntity.setBuyCount(buyCount);
|
||||
ordersEntity.setBasePoint(basePoint);
|
||||
ordersEntity.setPhoneNumber(mobile);
|
||||
ordersEntity.setOrderAmount(StringUtil.toString(total_fee));
|
||||
ordersEntity.setProductCode(productId.substring(0, productId.length()-1));
|
||||
ordersEntity.setProductName(productName.substring(0, productName.length()-1));
|
||||
map.put("ordersEntity", ordersEntity);
|
||||
map.put("orderDatilListJson", orderDatilListJson);
|
||||
map.put("total_Coupon", total_Coupon);
|
||||
map.put("minCount", minCount);
|
||||
return map;
|
||||
}
|
||||
|
||||
private JSONObject gainGoodsObject(OrdersEntity appointCoupon) throws Exception {
|
||||
//存储orderDetailList
|
||||
ProductMasterQueryEntity productMasterQueryEntity = new ProductMasterQueryEntity();
|
||||
productMasterQueryEntity.setProductCode(appointCoupon.getProductCode());
|
||||
String goodsStr = goodService.productQuery(productMasterQueryEntity);
|
||||
com.alibaba.fastjson.JSONArray jsonGoodsArray = JSONObject.parseArray(goodsStr);
|
||||
JSONObject goodsObject = (JSONObject) jsonGoodsArray.get(0);
|
||||
return goodsObject;
|
||||
}
|
||||
|
||||
private void addOrdersEntity(JSONObject jsonObjectData, OrdersEntity ordersEntity) {
|
||||
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"));
|
||||
ordersEntity.setCouponTypeId(jsonObjectData.getString("couponTypeId"));
|
||||
}
|
||||
|
||||
private BigDecimal calculationTotal(OrdersEntity appointCoupon, JSONObject goodsObject, BigDecimal total_other) {
|
||||
//total_Coupon = total_Coupon + Double.parseDouble(goodsObject2.getString("ecPrice")) * entity.getBuyCount();
|
||||
BigDecimal ecPrice = new BigDecimal(goodsObject.getString("ecPrice"));
|
||||
BigDecimal buyCounts = new BigDecimal(appointCoupon.getBuyCount());
|
||||
total_other = total_other.add(ecPrice.multiply(buyCounts)) ;
|
||||
return total_other;
|
||||
}
|
||||
|
||||
private void addOrderAddress(OrderAddress orderAddress, OrdersEntity appointCoupon) {
|
||||
orderAddress.setAddressCityName(appointCoupon.getOrderAddress().getAddressCityName());
|
||||
orderAddress.setAddressCountyName(appointCoupon.getOrderAddress().getAddressCountyName());
|
||||
orderAddress.setAddressDetailInfo(appointCoupon.getOrderAddress().getAddressDetailInfo());
|
||||
orderAddress.setAddressPhoneNumber(appointCoupon.getOrderAddress().getAddressPhoneNumber());
|
||||
orderAddress.setAddressUserName(appointCoupon.getOrderAddress().getAddressUserName());
|
||||
orderAddress.setAddressProvinceName(appointCoupon.getOrderAddress().getAddressProvinceName());
|
||||
}
|
||||
|
||||
private void splicingOrderDetail(OrdersEntity appointCoupon, JSONObject goodsObject, JSONArray orderDatilListJson) {
|
||||
OrderDatilListEntity orderDatilListEntity = new OrderDatilListEntity();
|
||||
orderDatilListEntity.setProductName(goodsObject.getString("productName"));
|
||||
orderDatilListEntity.setPcs(appointCoupon.getBuyCount());
|
||||
orderDatilListEntity.setProductCode(goodsObject.getString("productCode"));
|
||||
orderDatilListEntity.setEcPrice(goodsObject.getString("ecPrice"));
|
||||
orderDatilListJson.add(orderDatilListEntity);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
3
smart-admin-web/package-lock.json
generated
3
smart-admin-web/package-lock.json
generated
@ -4084,8 +4084,7 @@
|
||||
"core-js": {
|
||||
"version": "2.6.11",
|
||||
"resolved": "https://registry.npm.taobao.org/core-js/download/core-js-2.6.11.tgz?cache=0&sync_timestamp=1586450269267&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcore-js%2Fdownload%2Fcore-js-2.6.11.tgz",
|
||||
"integrity": "sha1-OIMUafmSK97Y7iHJ3EaYXgOZMIw=",
|
||||
"dev": true
|
||||
"integrity": "sha1-OIMUafmSK97Y7iHJ3EaYXgOZMIw="
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
|
@ -23,7 +23,7 @@
|
||||
"cropperjs": "^1.2.2",
|
||||
"dayjs": "^1.7.7",
|
||||
"decimal.js": "^10.1.1",
|
||||
"core-js":"^2.0.0",
|
||||
"core-js": "^2.0.0",
|
||||
"e-guide-layer": "^0.1.1",
|
||||
"echarts": "^4.0.4",
|
||||
"gq-plus": "^2.1.5",
|
||||
|
Loading…
Reference in New Issue
Block a user