Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gogirl-miniapp-backend
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
huluobin
gogirl-miniapp-backend
Commits
4c480d01
Commit
4c480d01
authored
Mar 25, 2020
by
huluobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
order pay
parent
4dcc3740
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
288 additions
and
2 deletions
+288
-2
MarketServiceImpl.java
...com/gogirl/application/market/impl/MarketServiceImpl.java
+7
-2
Test.java
src/test/java/com/gogirl/Test.java
+281
-0
No files found.
src/main/java/com/gogirl/application/market/impl/MarketServiceImpl.java
View file @
4c480d01
...
...
@@ -316,8 +316,13 @@ public class MarketServiceImpl implements MarketService {
orderServe
.
setPayPrice
(
orderServe
.
getPrice
().
add
(
orderServe
.
getServeChangePrice
()));
//服务折金额=0
orderServe
.
setDiscountPrice
(
BigDecimal
.
ZERO
);
//业绩的实际支付金额
orderServe
.
setAchievement
(
orderServe
.
getPrice
().
add
(
orderServe
.
getServeChangePrice
()));
//如果是贵族会员免费手部基础护理 或者 特级会员免费修手 业绩为10元 其他的是实际支付金额
if
(
orderServe
.
getServeName
().
equals
(
"贵族会员免费手部基础护理"
)
||
orderServe
.
getServeName
().
equals
(
"特级会员免费修手"
))
{
orderServe
.
setAchievement
(
new
BigDecimal
(
10
).
add
(
orderServe
.
getServeChangePrice
()));
}
else
{
orderServe
.
setAchievement
(
orderServe
.
getPrice
().
add
(
orderServe
.
getServeChangePrice
()));
}
});
//3.次卡
...
...
src/test/java/com/gogirl/Test.java
View file @
4c480d01
...
...
@@ -2,6 +2,9 @@ package com.gogirl;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.IdWorker
;
import
com.gogirl.application.market.CouponCustomerRelevanceService
;
import
com.gogirl.application.market.TimesCardCustomerRelevanceService
;
import
com.gogirl.application.market.TimesCardUsedRecordService
;
import
com.gogirl.application.xcx.GogirlTokenService
;
import
com.gogirl.domain.market.coupon.CouponCustomerRelevance
;
import
com.gogirl.domain.order.pay.OrderPay
;
...
...
@@ -18,6 +21,7 @@ import com.gogirl.domain.xcx.WeekConfig;
import
com.gogirl.infrastructure.common.util.JsonUtilByFsJson
;
import
com.gogirl.infrastructure.mapper.market.coupon.CouponCustomerRelevanceMapper
;
import
com.gogirl.infrastructure.mapper.market.discount.LeisureDiscountConfigWeekMapper
;
import
com.gogirl.infrastructure.mapper.market.timescard.TimesCardCustomerRelevanceMapper
;
import
com.gogirl.infrastructure.mapper.order.pay.OrderPayMapper
;
import
com.gogirl.infrastructure.mapper.order.serve.OrderManageMapper
;
import
com.gogirl.infrastructure.mapper.order.serve.OrderServeMapper
;
...
...
@@ -210,6 +214,8 @@ public class Test {
ComplaintMainMapper
complaintMainMapper
;
@Resource
ComplaintDetailedTechnicianMapper
complaintDetailedTechnicianMapper
;
@Resource
TimesCardCustomerRelevanceMapper
timesCardCustomerRelevanceMapper
;
@org
.
junit
.
Test
public
void
complain
()
{
...
...
@@ -236,4 +242,279 @@ public class Test {
});
}
@Resource
CouponCustomerRelevanceService
couponCustomerRelevanceService
;
@Resource
TimesCardUsedRecordService
timesCardUsedRecordService
;
@Resource
TimesCardCustomerRelevanceService
timesCardCustomerRelevanceService
;
// public void orderAch() {
// List<OrderManage> orderManageList = orderManageMapper.selectList(new LambdaQueryWrapper<OrderManage>()
// .in(OrderManage::getStatus, Lists.newArrayList(3, 4))
// .ge(OrderManage::getCreateTime, "2020-03-01"));
// orderManageList.forEach(orderManage -> {
// Integer orderId = orderManage.getId();
// //订单使用的内部券
// List<CouponCustomerRelevance> innerCouponCustomerRelevanceServiceList = couponCustomerRelevanceService
// .list(new LambdaQueryWrapper<CouponCustomerRelevance>()
// .eq(CouponCustomerRelevance::getOrderId, orderId)
// .eq(CouponCustomerRelevance::getState, 1)
// .eq(CouponCustomerRelevance::getSourceType, 0));
//
// //订单使用的外部券
// List<CouponCustomerRelevance> outerCouponCustomerRelevanceServiceList = couponCustomerRelevanceService
// .list(new LambdaQueryWrapper<CouponCustomerRelevance>()
// .eq(CouponCustomerRelevance::getOrderId, orderId)
// .eq(CouponCustomerRelevance::getState, 1)
// .eq(CouponCustomerRelevance::getSourceType, 1));
//
//
// //订单使用的次卡
// List<TimesCardUsedRecord> timesCardUsedRecordList = timesCardUsedRecordService
// .list(new LambdaQueryWrapper<TimesCardUsedRecord>()
// .eq(TimesCardUsedRecord::getOrderId, orderId)
// .eq(TimesCardUsedRecord::getStatus, 1));
//
//
// //查询订单聚合
//
// List<OrderServe> orderServeList = orderServeMapper.selectList(new LambdaQueryWrapper<OrderServe>().eq(OrderServe::getOrderId, orderId));
// orderManage.setListOrderServer(orderServeList);
// orderServeList.forEach(orderServe -> {
// orderServe.setBindInnerCoupon(2);
// orderServe.setBindTimesCard(2);
// orderServe.setBindOuterCoupon(2);
// });
//
// //1.改价结算
// //总支付金额等于 总价格+总改价
// orderManage.setTotalPaymentAmount(orderManage.getTotalPrice().add(orderManage.getChangePrice()));
// //总折扣金额
// orderManage.setDiscountPrice(BigDecimal.ZERO);
//
// orderManage.getListOrderServer().forEach(orderServe -> {
// //服务实际支付金额=服务价格+服务改价
// orderServe.setPayPrice(orderServe.getPrice().add(orderServe.getServeChangePrice()));
// //服务折金额=0
// orderServe.setDiscountPrice(BigDecimal.ZERO);
// //业绩的实际支付金额
// orderServe.setAchievement(orderServe.getPrice().add(orderServe.getServeChangePrice()));
// });
//
// //3.次卡
// if (ListUtil.isNotEmpty(timesCardUsedRecordList)) {
// //次卡使用记录
// timesCardUsedRecordList.forEach(timesCardUsedRecord -> timesCardUsedRecord.setStatus(TimesCardUsedRecord.STATUS_CHOSE));
//
// timesCardUsedRecordList.stream()
// .sorted(Comparator.comparing(TimesCardUsedRecord::getDiscountAmount))
// .forEach(timesCardUsedRecord -> {
//
//
// //次卡能用的服务id
// List<Integer> serveIds = timesCardCustomerRelevanceMapper.queryTimesCardServeIds(timesCardUsedRecord.getCardTypeId());
// //抵扣的服务为 作用范围内支付金额最高的服务
// OrderServe orderServe = this.queryMaxPayPrice(orderManage, serveIds);
// if (orderServe != null) {
//
// BigDecimal actualDiscountAmount = orderServe.getPayPrice().min(timesCardUsedRecord.getDiscountAmount());
// //更新次卡记录 已使用
// timesCardUsedRecord.setStatus(TimesCardUsedRecord.STATUS_USED);
// //次卡对应订单服务的美甲师
// timesCardUsedRecord.setTechnicianName(orderServe.getTechnicianName());
// //次卡店铺名称
// timesCardUsedRecord.setDepartmentName(orderManage.getDepartmentName());
// //次卡店铺id
// timesCardUsedRecord.setDepartmentId(orderManage.getDepartmentId());
// //次卡折扣的
// timesCardUsedRecord.setServeName(orderServe.getServeName());
// //次卡作用的服务id
// timesCardUsedRecord.setOrderServeId(orderServe.getServeId());
// timesCardUsedRecord.setOrderId(orderId);
// timesCardUsedRecord.setActualDiscountAmount(actualDiscountAmount);
//
// //在主服务上折扣的钱
// TimesCardOrderServeDetail timesCardOrderServeDetail = new TimesCardOrderServeDetail();
// timesCardOrderServeDetail.setDiscountAmount(actualDiscountAmount);
// timesCardOrderServeDetail.setOrderServeId(orderServe.getId());
// timesCardOrderServeDetail.setOrderId(orderId);
// timesCardOrderServeDetail.setTimesCardUserRecordId(timesCardUsedRecord.getOrderServeId());
// //业绩
// timesCardOrderServeDetail.setAchievement(timesCardUsedRecord.getPayAmount());
//
// //订单折扣金额更新
// orderServe.setBindTimesCard(1);
// orderServe.addDiscountPrice(actualDiscountAmount);
//
// //业绩
// orderServe.setAchievement(orderServe.getAchievement().subtract(actualDiscountAmount).add(timesCardUsedRecord.getPayAmount()));
// orderManage.addDiscountPrice(actualDiscountAmount);
//
// //更新使用次数
// TimesCardCustomerRelevance timesCardCustomerRelevance = timesCardCustomerRelevanceService.getById(timesCardUsedRecord.getCardRelevanceCustomerId());
// timesCardCustomerRelevance.setUsedTimes(timesCardCustomerRelevance.getUsedTimes() + 1);
// if (timesCardCustomerRelevance.getUsedTimes().equals(timesCardCustomerRelevance.getSumTimes())) {
// //次数用完
// timesCardCustomerRelevance.setStatus(2);
// }
// timesCardCustomerRelevanceService.updateById(timesCardCustomerRelevance);
// } else {
// throw new RRException("次卡冲突");
// }
//
// });
// }
//
//
// //4。外部券
// if (ListUtil.isNotEmpty(outerCouponCustomerRelevanceServiceList)) {
//
//
//
// outerCouponCustomerRelevanceServiceList
// .stream()
// .sorted(Comparator.comparing(CouponCustomerRelevance::getDiscountAmount).reversed())
// .forEach(couponCustomerRelevance -> {
//
//
// //外部券能用的服务id
// List<Integer> serveIds = couponCustomerRelevanceMapper.queryCouponCustomerServeRelevance(couponCustomerRelevance.getCouponId());
//
// //抵扣的服务为 作用范围内支付金额最高的服务
// OrderServe orderServe = this.queryMaxPayPrice(orderManage, serveIds);
//
// if (orderServe != null) {
// //如果有属于这个服务的辅助服务 就查出来一起折扣
// OrderServe supportServe = this.querySupportServe(orderManage, orderServe);
//
// BigDecimal actualDiscountAmount = orderServe.getPayPrice().min(couponCustomerRelevance.getDiscountAmount());
//
// //新增外部券抵扣情况记录
// CouponOrderRelevance couponOrderRelevance = CouponOrderRelevance.builder()
// .couponCustomerRelevanceId(couponCustomerRelevance.getId())
// .couponId(couponCustomerRelevance.getCouponId())
// .couponName(couponCustomerRelevance.getCouponName())
// .orderServeId(orderServe.getId())
// .serveName(orderServe.getServeName())
// .orderId(orderManage.getId())
// //支付金额
// .payForOrderServe(couponCustomerRelevance.getPayAmount())
// //折扣金额
// .discountAmount(actualDiscountAmount)
// .createTime(new Date())
// .confirmTime(new Date())
// .message(orderServe.getServeName())
// .customerId(orderManage.getOrderUser())
// .status(2)
// .build();
// //如果计算业绩
// if (couponCustomerRelevance.getIsCalcAchievement() == 1) {
// couponOrderRelevance.setAchievement(couponCustomerRelevance.getPayAmount());
// } else {
// couponOrderRelevance.setAchievement(couponOrderRelevance.getDiscountAmount());
// }
//
// //业绩
// orderServe.setAchievement(orderServe.getAchievement().subtract(actualDiscountAmount).add(couponCustomerRelevance.getPayAmount()));
//
// orderServe.addDiscountPrice(actualDiscountAmount);
// orderManage.addDiscountPrice(actualDiscountAmount);
// orderServe.setBindOuterCoupon(1);
// couponOrderRelevanceService.save(couponOrderRelevance);
//
// } else {
// throw new RRException("外部券冲突");
// }
//
// });
// }
// //5.内部券
// if (ListUtil.isNotEmpty(innerCouponCustomerRelevanceServiceList)) {
//
// innerCouponCustomerRelevanceServiceList
// .forEach(couponCustomerRelevance -> {
// //内部券能用的服务id
// List<Integer> serveIds = couponCustomerRelevanceMapper.queryCouponCustomerServeRelevance(couponCustomerRelevance.getCouponId());
//
// //作用的服务id
// List<OrderServe> canUserOrderServeList = this.queryCanDiscount(orderManage, serveIds, couponCustomerRelevance.getCouponId());
//
// //打折订单项总支付金额
// BigDecimal total = canUserOrderServeList.stream().map(OrderServe::getPayPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
//
// if (!total.setScale(2, BigDecimal.ROUND_HALF_UP).equals(BigDecimal.ZERO.setScale(2, BigDecimal.ROUND_HALF_UP))) {
// //卡券的总折扣金额
// BigDecimal totalCouponDiscount = couponCustomerRelevance.getDiscountAmount();
// //卡券总支付金额
// BigDecimal totalCouponPay = couponCustomerRelevance.getPayAmount();
//
// //计算参数(最后一个订单服务的折扣金额要用总折扣金额减 防止除法计算精度问题)
// BigDecimal discountCalc = BigDecimal.ZERO;
//
// //计算参数(最后一个订单服务的实际支付要用总实际支付金额减 防止除法计算精度问题)
// BigDecimal payCalc = BigDecimal.ZERO;
//
// for (OrderServe orderServe : canUserOrderServeList) {
//
// //每个服务的内部券抵扣金额
// BigDecimal discountAmount = orderServe.getPayPrice().multiply(totalCouponDiscount).divide(total, 2, BigDecimal.ROUND_HALF_UP);
// //每个服务的卡券实际支付金额
// BigDecimal payAmount = orderServe.getPayPrice().multiply(totalCouponPay).divide(total, 2, BigDecimal.ROUND_HALF_UP);
//
//
// //最后一个服务使用总额减法而不是除法
// if (canUserOrderServeList.lastIndexOf(orderServe) == canUserOrderServeList.size() - 1) {
// discountAmount = totalCouponDiscount.subtract(discountCalc);
// payAmount = totalCouponPay.subtract(payCalc);
// }
// BigDecimal actualDiscountAmount = discountAmount.min(orderServe.getPayPrice());
//
// //卡券在订单服务上的抵扣情况
// CouponOrderRelevance couponOrderRelevance = CouponOrderRelevance.builder()
// .discountAmount(actualDiscountAmount)
// //卡券在这个服务上的实际支付金额
// .payForOrderServe(payAmount)
// .createTime(new Date())
// .orderServeId(orderServe.getId())
// .orderId(orderManage.getId())
// .couponId(couponCustomerRelevance.getCouponId())
// .couponCustomerRelevanceId(couponCustomerRelevance.getId())
// .confirmTime(new Date())
// .message(orderServe.getServeName())
// .customerId(orderManage.getOrderUser())
// .status(2)
// .build();
//
// //如果计算业绩
// if (couponCustomerRelevance.getIsCalcAchievement() == 1) {
// couponOrderRelevance.setAchievement(couponCustomerRelevance.getPayAmount());
// } else {
// couponOrderRelevance.setAchievement(couponOrderRelevance.getDiscountAmount());
// }
//
// //免单券Id
// List<Integer> discountConfigListCouponId = discountConfigMapper.selectList(new QueryWrapper<>()).stream().map(DiscountConfig::getCouponId).filter(Objects::nonNull).collect(Collectors.toList());
// //如果不是免单券 业绩就要扣除实际折扣金额
// if (!discountConfigListCouponId.contains(couponCustomerRelevance.getCouponId())) {
// orderServe.setAchievement(orderServe.getAchievement().subtract(actualDiscountAmount));
// }
//
// orderServe.addDiscountPrice(actualDiscountAmount);
// orderManage.addDiscountPrice(actualDiscountAmount);
//
// orderServe.setBindInnerCoupon(1);
// discountCalc = discountCalc.add(discountAmount);
// payCalc = payCalc.add(payAmount);
// }
// }
// //内部券抵扣不了
// else {
// throw new RRException("内部券冲突");
// }
// });
// }
// });
// }
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment