Commit d6f243d8 authored by Junling Bu's avatar Junling Bu
Browse files

perf: 团购代码优化

parent eff4862d
......@@ -28,6 +28,9 @@ public class WxResponseCode {
public static final Integer ORDER_COMMENT_EXPIRED = 727;
public static final Integer GROUPON_EXPIRED = 730;
public static final Integer GROUPON_OFFLINE = 731;
public static final Integer GROUPON_FULL = 732;
public static final Integer GROUPON_JOIN = 733;
public static final int COUPON_EXCEED_LIMIT = 740;
public static final int COUPON_RECEIVE_FAIL= 741;
......
package org.linlinjava.litemall.wx.vo;
import java.math.BigDecimal;
import java.time.LocalDateTime;
public class GrouponRuleVo {
private Integer id;
......@@ -12,6 +13,15 @@ public class GrouponRuleVo {
private BigDecimal grouponPrice;
private BigDecimal grouponDiscount;
private Integer grouponMember;
private LocalDateTime expireTime;
public LocalDateTime getExpireTime() {
return expireTime;
}
public void setExpireTime(LocalDateTime expireTime) {
this.expireTime = expireTime;
}
public BigDecimal getGrouponDiscount() {
return grouponDiscount;
......
......@@ -438,7 +438,7 @@ public class WxCartController {
// 团购优惠
BigDecimal grouponPrice = new BigDecimal(0.00);
LitemallGrouponRules grouponRules = grouponRulesService.queryById(grouponRulesId);
LitemallGrouponRules grouponRules = grouponRulesService.findById(grouponRulesId);
if (grouponRules != null) {
grouponPrice = grouponRules.getDiscount();
}
......
......@@ -19,13 +19,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 优惠券服务
......@@ -132,7 +129,7 @@ public class WxCouponController {
// 团购优惠
BigDecimal grouponPrice = new BigDecimal(0.00);
LitemallGrouponRules grouponRules = grouponRulesService.queryById(grouponRulesId);
LitemallGrouponRules grouponRules = grouponRulesService.findById(grouponRulesId);
if (grouponRules != null) {
grouponPrice = grouponRules.getDiscount();
}
......
......@@ -92,7 +92,7 @@ public class WxGrouponController {
return ResponseUtil.badArgumentValue();
}
LitemallGrouponRules rules = rulesService.queryById(groupon.getRulesId());
LitemallGrouponRules rules = rulesService.findById(groupon.getRulesId());
if (rules == null) {
return ResponseUtil.badArgumentValue();
}
......@@ -186,7 +186,7 @@ public class WxGrouponController {
return ResponseUtil.badArgumentValue();
}
LitemallGrouponRules rules = rulesService.queryById(groupon.getRulesId());
LitemallGrouponRules rules = rulesService.findById(groupon.getRulesId());
if (rules == null) {
return ResponseUtil.badArgumentValue();
}
......@@ -230,7 +230,7 @@ public class WxGrouponController {
LitemallUser creator;
for (LitemallGroupon groupon : myGroupons) {
order = orderService.findById(groupon.getOrderId());
rules = rulesService.queryById(groupon.getRulesId());
rules = rulesService.findById(groupon.getRulesId());
creator = userService.findById(groupon.getCreatorUserId());
Map<String, Object> grouponVo = new HashMap<>();
......@@ -257,7 +257,6 @@ public class WxGrouponController {
grouponVo.put("orderSn", order.getOrderSn());
grouponVo.put("actualPrice", order.getActualPrice());
grouponVo.put("orderStatusText", OrderUtil.orderStatusText(order));
grouponVo.put("handleOption", OrderUtil.build(order));
List<LitemallOrderGoods> orderGoodsList = orderGoodsService.queryByOid(order.getId());
List<Map<String, Object>> orderGoodsVoList = new ArrayList<>(orderGoodsList.size());
......
......@@ -87,7 +87,8 @@
},
"debug": true,
"usingComponents": {
"van-tag": "./lib/vant-weapp/tag/index"
"van-tag": "./lib/vant-weapp/tag/index",
"van-steps": "./lib/vant-weapp/steps/index"
},
"sitemapLocation": "sitemap.json"
}
\ No newline at end of file
......@@ -19,7 +19,7 @@ Page({
couponId: 0,
userCouponId: 0,
message: '',
grouponLinkId: 0, //参与的团购,如果是发起则为0
grouponLinkId: 0, //参与的团购
grouponRulesId: 0 //团购规则ID
},
onLoad: function(options) {
......@@ -145,7 +145,7 @@ Page({
grouponLinkId: this.data.grouponLinkId
}, 'POST').then(res => {
if (res.errno === 0) {
// 下单成功,重置couponId
try {
wx.setStorageSync('couponId', 0);
......@@ -154,6 +154,7 @@ Page({
}
const orderId = res.data.orderId;
const grouponLinkId = res.data.grouponLinkId;
util.request(api.OrderPrepay, {
orderId: orderId
}, 'POST').then(function(res) {
......@@ -168,9 +169,17 @@ Page({
'paySign': payParam.paySign,
'success': function(res) {
console.log("支付过程成功");
wx.redirectTo({
url: '/pages/payResult/payResult?status=1&orderId=' + orderId
});
if (grouponLinkId) {
setTimeout(() => {
wx.redirectTo({
url: '/pages/groupon/grouponDetail/grouponDetail?id=' + grouponLinkId
})
}, 1000);
} else {
wx.redirectTo({
url: '/pages/payResult/payResult?status=1&orderId=' + orderId
});
}
},
'fail': function(res) {
console.log("支付过程失败");
......
......@@ -4,15 +4,15 @@ var api = require('../../../config/api.js');
Page({
data: {
id: 0,
orderId: 0,
groupon: {},
linkGrouponId: 0,
joiners: [],
orderInfo: {},
orderGoods: [],
expressInfo: {},
flag: false,
handleOption: {}
rules: {},
active: 0,
steps: [],
activeIcon: '',
activeColor: ''
},
onLoad: function(options) {
......@@ -29,251 +29,56 @@ Page({
return {
title: '邀请团购',
desc: '唯爱与美食不可辜负',
path: '/pages/index/index?grouponId=' + this.data.linkGrouponId
path: '/pages/index/index?grouponId=' + this.data.id
}
},
shareGroupon: function() {
let that = this;
wx.showActionSheet({
itemList: ['分享给朋友', '分享到朋友圈'],
success: function(res) {
if (res.tapIndex == 0) {
wx.showModal({
title: '提示',
content: '点击右上角 "..." 转发给朋友',
showCancel: false
});
} else if (res.tapIndex == 1) {
that.saveShare();
} else {
console.log(res.tapIndex);
}
},
fail: function(res) {
console.log(res.errMsg);
}
})
},
// 保存分享图
saveShare: function() {
let that = this;
wx.downloadFile({
url: that.data.groupon.shareUrl,
success: function(res) {
console.log(res)
wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: function(res) {
wx.showModal({
title: '存图成功',
content: '图片成功保存到相册了,可以分享到朋友圈了',
showCancel: false,
confirmText: '好的',
confirmColor: '#a78845',
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
}
}
})
},
fail: function(res) {
console.log('fail')
}
})
},
fail: function() {
console.log('fail')
}
})
},
onPullDownRefresh() {
wx.showNavigationBarLoading() //在标题栏中显示加载
this.getOrderDetail();
wx.hideNavigationBarLoading() //完成停止加载
wx.stopPullDownRefresh() //停止下拉刷新
},
//获取物流信息
getOrderExpress: function() {
let that = this;
util.request(api.ExpressQuery, {
expCode: that.data.orderInfo.expCode,
expNo: that.data.orderInfo.expNo
}, 'POST').then(function(res) {
if (res.errno === 0) {
that.setData({
expressInfo: res.data
});
}
});
},
expandDetail: function() {
let that = this;
this.setData({
flag: !that.data.flag
})
},
getOrderDetail: function() {
let that = this;
util.request(api.GroupOnDetail, {
grouponId: that.data.id
}).then(function(res) {
if (res.errno === 0) {
let _steps = [{
text: '已开团'
},
{
text: '开团中'
},
{
text: '开团成功'
}
]
let _active = res.data.groupon.status
let _activeIcon = 'success'
let _activeColor = '#07c160'
if (res.data.groupon.status === 3) {
_steps = [{
text: '已开团'
},
{
text: '开团中'
},
{
text: '开团失败'
}
]
_active = 2
_activeIcon = 'fail'
_activeColor = '#EE0A24'
}
that.setData({
joiners: res.data.joiners,
groupon: res.data.groupon,
linkGrouponId: res.data.linkGrouponId,
orderId: res.data.orderInfo.id,
orderInfo: res.data.orderInfo,
orderGoods: res.data.orderGoods,
handleOption: res.data.orderInfo.handleOption
});
// 请求物流信息,仅当订单状态为发货时才请求
if (res.data.orderInfo.handleOption.confirm) {
that.getOrderExpress();
}
}
});
},
// “去付款”按钮点击效果
payOrder: function() {
let that = this;
util.request(api.OrderPrepay, {
orderId: that.data.orderId
}, 'POST').then(function(res) {
if (res.errno === 0) {
const payParam = res.data;
console.log("支付过程开始");
wx.requestPayment({
'timeStamp': payParam.timeStamp,
'nonceStr': payParam.nonceStr,
'package': payParam.packageValue,
'signType': payParam.signType,
'paySign': payParam.paySign,
'success': function(res) {
console.log("支付过程成功");
util.redirect('/pages/ucenter/order/order');
},
'fail': function(res) {
console.log("支付过程失败");
util.showErrorToast('支付失败');
},
'complete': function(res) {
console.log("支付过程结束")
}
rules: res.data.rules,
active: _active,
steps: _steps,
activeIcon: _activeIcon,
activeColor: _activeColor
});
}
});
},
// “取消订单”点击效果
cancelOrder: function() {
let that = this;
let orderInfo = that.data.orderInfo;
wx.showModal({
title: '',
content: '确定要取消此订单?',
success: function(res) {
if (res.confirm) {
util.request(api.OrderCancel, {
orderId: orderInfo.id
}, 'POST').then(function(res) {
if (res.errno === 0) {
wx.showToast({
title: '取消订单成功'
});
util.redirect('/pages/ucenter/order/order');
} else {
util.showErrorToast(res.errmsg);
}
});
}
}
});
},
// “取消订单并退款”点击效果
refundOrder: function() {
let that = this;
let orderInfo = that.data.orderInfo;
wx.showModal({
title: '',
content: '确定要取消此订单?',
success: function(res) {
if (res.confirm) {
util.request(api.OrderRefund, {
orderId: orderInfo.id
}, 'POST').then(function(res) {
if (res.errno === 0) {
wx.showToast({
title: '取消订单成功'
});
util.redirect('/pages/ucenter/order/order');
} else {
util.showErrorToast(res.errmsg);
}
});
}
}
});
},
// “删除”点击效果
deleteOrder: function() {
let that = this;
let orderInfo = that.data.orderInfo;
wx.showModal({
title: '',
content: '确定要删除此订单?',
success: function(res) {
if (res.confirm) {
util.request(api.OrderDelete, {
orderId: orderInfo.id
}, 'POST').then(function(res) {
if (res.errno === 0) {
wx.showToast({
title: '删除订单成功'
});
util.redirect('/pages/ucenter/order/order');
} else {
util.showErrorToast(res.errmsg);
}
});
}
}
});
},
// “确认收货”点击效果
confirmOrder: function() {
let that = this;
let orderInfo = that.data.orderInfo;
wx.showModal({
title: '',
content: '确认收货?',
success: function(res) {
if (res.confirm) {
util.request(api.OrderConfirm, {
orderId: orderInfo.id
}, 'POST').then(function(res) {
if (res.errno === 0) {
wx.showToast({
title: '确认收货成功!'
});
util.redirect('/pages/ucenter/order/order');
} else {
util.showErrorToast(res.errmsg);
}
});
}
}
});
},
onReady: function() {
// 页面渲染完成
......
<view class="container">
<view class="order-info">
<view class="item-a">下单时间:{{orderInfo.addTime}}</view>
<view class="item-b">订单编号:{{orderInfo.orderSn}}</view>
<view class="item-c">
<view class="l">实付:
<text class="cost">¥{{orderInfo.actualPrice}}</text>
<view class="progress">
<view class="item-a">
<van-steps steps="{{ steps }}" active="{{ active }}" active-icon="{{ activeIcon }}"
active-color="{{ activeColor }}" />
</view>
<view class="item-c" wx:if="{{groupon.status === 1}}">
<view class="l">
开团还缺
<van-tag type="danger">{{rules.discountMember - joiners.length}}</van-tag>
</view>
<view class="r">
<view class="btn active" bindtap="shareGroupon">邀请参团</view>
<button class="btn active" open-type="share">邀请参团</button>
</view>
</view>
</view>
......@@ -26,7 +30,6 @@
<view class="order-goods">
<view class="h">
<view class="label">商品信息</view>
<view class="status">{{orderInfo.orderStatusText}}</view>
</view>
<view class="goods">
<view class="item" wx:for="{{orderGoods}}" wx:key="id">
......@@ -45,47 +48,20 @@
</view>
<view class="order-bottom">
<view class="address">
<view class="t">
<text class="name">{{orderInfo.consignee}}</text>
<text class="mobile">{{orderInfo.mobile}}</text>
</view>
<view class="b">{{orderInfo.address}}</view>
</view>
<view class="total">
<view class="t">
<text class="label">商品合计:</text>
<text class="txt">¥{{orderInfo.goodsPrice}}</text>
</view>
<view class="t">
<text class="label">运费:</text>
<text class="label">商品运费:</text>
<text class="txt">¥{{orderInfo.freightPrice}}</text>
</view>
</view>
<view class="pay-fee">
<text class="label">实付:</text>
<text class="label">商品实付:</text>
<text class="txt">¥{{orderInfo.actualPrice}}</text>
</view>
</view>
</view>
<!-- 物流信息,仅收货状态下可见 -->
<view class="order-express" bindtap="expandDetail" wx:if="{{ handleOption.confirm }}">
<view class="expand">
<view class="title">
<view class="t">快递公司:{{expressInfo.shipperName}}</view>
<view class="b">物流单号:{{expressInfo.logisticCode}}</view>
</view>
<image class="ti" src="/static/images/address_right.png" background-size="cover"></image>
</view>
<!-- <view class="order-express" > -->
<view class="traces" wx:for="{{expressInfo.Traces}}" wx:key="item" wx:for-item="iitem" wx:if="{{ flag }}">
<view class="trace">
<view class="acceptStation">{{iitem.AcceptStation}}</view>
<view class="acceptTime">{{iitem.AcceptTime}}</view>
</view>
</view>
</view>
<!-- </view> -->
</view>
\ No newline at end of file
......@@ -4,7 +4,7 @@ page {
background: #f4f4f4;
}
.order-info {
.progress {
padding-top: 25rpx;
background: #fff;
height: auto;
......@@ -12,27 +12,11 @@ page {
}
.item-a {
padding-left: 31.25rpx;
height: 42.5rpx;
padding-bottom: 12.5rpx;
line-height: 30rpx;
font-size: 30rpx;
color: #666;
}
.item-b {
padding-left: 31.25rpx;
height: 29rpx;
line-height: 29rpx;
margin-top: 12.5rpx;
margin-bottom: 41.5rpx;
font-size: 30rpx;
color: #666;
padding: 0 21.25rpx;
}
.item-c {
margin-left: 31.25rpx;
border-top: 1px solid #f4f4f4;
height: 103rpx;
line-height: 103rpx;
}
......@@ -49,16 +33,10 @@ page {
padding-right: 16rpx;
}
.item-c .r .btn {
float: right;
}
.item-c .cost {
color: #b4282d;
}
.item-c .btn {
float: right;
line-height: 66rpx;
font-size: 30rpx;
border-radius: 5rpx;
text-align: center;
margin: 0 15rpx;
......@@ -236,23 +214,21 @@ page {
height: 30rpx;
line-height: 30rpx;
margin-bottom: 7.5rpx;
display: flex;
}
.order-bottom .total .label {
.order-bottom .total .t .label {
width: 150rpx;
display: inline-block;
height: 35rpx;
line-height: 35rpx;
font-size: 30rpx;
}
.order-bottom .total .txt {
flex: 1;
display: inline-block;
.order-bottom .total .t .txt {
float: right;
height: 35rpx;
line-height: 35rpx;
font-size: 30rpx;
padding-right: 31.25rpx;
}
.order-bottom .pay-fee {
......@@ -261,79 +237,12 @@ page {
}
.order-bottom .pay-fee .label {
display: inline-block;
width: 140rpx;
color: #b4282d;
}
.order-bottom .pay-fee .txt {
display: inline-block;
width: 140rpx;
color: #b4282d;
}
.order-express {
margin-top: 20rpx;
width: 100%;
height: 100rpx;
background: #fff;
}
.order-express .expand {
/* margin-top: 20rpx; */
width: 100%;
height: 100rpx;
background: #fff;
/* border: 10rpx #a78845; */
}
.order-express .title {
float: left;
margin-bottom: 20rpx;
padding: 10rpx;
}
.order-express .ti {
float: right;
width: 52rpx;
height: 52rpx;
margin-right: 16rpx;
margin-top: 28rpx;
}
.order-express .t {
font-size: 29rpx;
margin-left: 10.25rpx;
color: #a78845;
}
.order-express .b {
font-size: 29rpx;
margin-left: 10.25rpx;
color: #a78845;
}
.order-express .traces {
padding: 17.5rpx;
background: #fff;
border-bottom: 1rpx solid #f1e6cdcc;
}
.order-express .trace {
padding-bottom: 17.5rpx;
padding-top: 17.5rpx;
background: #fff;
}
.order-express .acceptTime {
margin-top: 20rpx;
margin-right: 40rpx;
text-align: right;
font-size: 26rpx;
}
.order-express .acceptStation {
font-size: 26rpx;
padding-right: 31.25rpx;
}
.menu-list-pro {
......
......@@ -8,8 +8,11 @@
<view class="text">
<view class="header">
<text class="name">{{item.name}}</text>
<van-tag type="warning">{{item.grouponMember}}人成团</van-tag>
<van-tag type="primary">{{item.grouponMember}}人成团</van-tag>
</view>
<view class="expire">
<van-tag round type="warning">有效期至 {{item.expireTime}}</van-tag>
</view>
<text class="desc">{{item.brief}}</text>
<view class="price">
<view class="counterPrice">现价:¥{{item.retailPrice}}</view>
......
......@@ -47,7 +47,6 @@ page, .container {
.groupon-list .name {
float: left;
width: 330rpx;
display: block;
color: #333;
line-height: 50rpx;
......
......@@ -16,6 +16,12 @@
<view class="orders">
<navigator url="../grouponDetail/grouponDetail?id={{item.id}}" class="order" open-type="navigate" wx:for="{{orderList}}" wx:key="id">
<view class="h">
<van-tag type="primary" wx:if="{{item.groupon.status === 1}}">开团中</van-tag>
<van-tag type="success" wx:if="{{item.groupon.status === 2}}">开团成功</van-tag>
<van-tag type="danger" wx:if="{{item.groupon.status === 3}}">开团失败</van-tag>
<van-tag round type="warning" wx:if="{{!item.isCreator}}">{{item.creator}}发起</van-tag>
</view>
<view class="h">
<view class="l">订单编号:{{item.orderSn}}</view>
<view class="r">{{item.orderStatusText}}</view>
......@@ -26,7 +32,7 @@
</view>
<view class="i">
<view class="l">团购要求:{{item.rules.discountMember}}人</view>
<view class="r">当前参:{{item.joinerCount}}</view>
<view class="r">当前参:{{item.joinerCount}}</view>
</view>
<view class="goods" wx:for="{{item.goodsList}}" wx:key="id" wx:for-item="gitem">
<view class="img">
......@@ -40,8 +46,6 @@
</view>
<view class="b">
<view class="l">实付:¥{{item.actualPrice}}</view>
<van-tag type="primary">{{item.joinerCount>=item.rules.discountMember?'已达成':'团购中'}}</van-tag>
<van-tag round type="warning" wx:if="{{!item.isCreator}}">{{item.creator}}发起</van-tag>
</view>
</navigator>
</view>
......
......@@ -72,7 +72,10 @@
<view class="text">
<view class="header">
<text class="name">{{item.name}}</text>
<van-tag type="warning">{{item.grouponMember}}人成团</van-tag>
<van-tag type="primary">{{item.grouponMember}}人成团</van-tag>
</view>
<view class="expire">
<van-tag round type="warning">有效期至 {{item.expireTime}}</van-tag>
</view>
<text class="desc">{{item.brief}}</text>
<view class="price">
......
......@@ -235,7 +235,6 @@
.a-groupon .b .name {
float: left;
width: 330rpx;
display: block;
color: #333;
line-height: 50rpx;
......
......@@ -267,6 +267,13 @@
"pathName": "pages/help/help",
"query": "",
"scene": null
},
{
"id": -1,
"name": "我的团购",
"pathName": "pages/groupon/myGroupon/myGroupon",
"query": "",
"scene": null
}
]
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment