Commit 14f571bf by huluobin

update

parent 3a7093bc
......@@ -290,7 +290,11 @@ public class MarketServiceImpl implements MarketService {
OrderManage orderManage = orderManageMapper.selectById(orderId);
List<OrderServe> orderServeList = orderServeMapper.selectList(new LambdaQueryWrapper<OrderServe>().eq(OrderServe::getOrderId, orderId));
orderManage.setListOrderServer(orderServeList);
// orderServeList.forEach(orderServe -> orderServe.setBindCoupon(2));
orderServeList.forEach(orderServe -> {
orderServe.setBindInnerCoupon(2);
orderServe.setBindTimesCard(2);
orderServe.setBindOuterCoupon(2);
});
//1.改价结算
//总支付金额等于 总价格+总改价
......@@ -307,20 +311,6 @@ public class MarketServiceImpl implements MarketService {
orderServe.setAchievement(orderServe.getPrice().add(orderServe.getServeChangePrice()));
});
// //2.闲时折扣结算
// orderManage.getListOrderServer().forEach(orderServe -> {
// //服务折扣金额等于闲时折扣金额
// orderServe.setDiscountPrice(orderServe.getLeisureDiscountPrice());
// //服务支付金额-闲时折扣金额
// orderServe.setPayPrice(orderServe.getPayPrice().subtract(orderServe.getLeisureDiscountPrice()));
// //总支付金额- 闲时折扣基恩
// orderManage.setTotalPaymentAmount(orderManage.getTotalPaymentAmount().subtract(orderServe.getLeisureDiscountPrice()));
// //总折扣金额 + = 闲时折扣金额
// orderManage.setDiscountPrice(orderManage.getDiscountPrice().add(orderServe.getLeisureDiscountPrice()));
// });
//3.次卡
if (ListUtil.isNotEmpty(timesCardUsedRecordList)) {
//次卡使用记录
......@@ -371,25 +361,6 @@ public class MarketServiceImpl implements MarketService {
orderServe.setBindTimesCard(1);
orderServe.addDiscountPrice(actualDiscountAmount);
orderManage.addDiscountPrice(actualDiscountAmount);
// 在从服务上折扣的钱
// BigDecimal leftServeDiscountAmount = timesCardUsedRecord.getDiscountAmount().subtract(serveDiscountAmount);
// if (supportServe != null && leftServeDiscountAmount.compareTo(BigDecimal.ZERO) > 0) {
//
// BigDecimal actualSupportServeDiscountAmount = leftServeDiscountAmount.min(supportServe.getPayPrice());
// TimesCardOrderServeDetail supportTimesCardOrderServeDetail = new TimesCardOrderServeDetail();
// supportTimesCardOrderServeDetail.setDiscountAmount(actualSupportServeDiscountAmount);
// supportTimesCardOrderServeDetail.setOrderServeId(supportServe.getId());
// supportTimesCardOrderServeDetail.setOrderId(orderId);
// supportTimesCardOrderServeDetail.setTimesCardUserRecordId(timesCardUsedRecord.getOrderServeId());
// //业绩
// supportTimesCardOrderServeDetail.setAchievement(BigDecimal.ZERO);
// timesCardOrderServeDetailMapper.insert(supportTimesCardOrderServeDetail);
//
// //订单折扣金额更新
// supportServe.setBindCoupon(1);
// supportServe.addDiscountPrice(actualSupportServeDiscountAmount);
// orderManage.addDiscountPrice(actualSupportServeDiscountAmount);
// }
//更新使用次数
TimesCardCustomerRelevance timesCardCustomerRelevance = timesCardCustomerRelevanceService.getById(timesCardUsedRecord.getCardRelevanceCustomerId());
......@@ -401,8 +372,6 @@ public class MarketServiceImpl implements MarketService {
timesCardCustomerRelevanceService.updateById(timesCardCustomerRelevance);
} else {
throw new RRException("次卡冲突");
// timesCardUsedRecord.setOrderId(null);
// timesCardUsedRecordMapper.updateById(timesCardUsedRecord);
}
});
......@@ -499,8 +468,6 @@ public class MarketServiceImpl implements MarketService {
// }
} else {
throw new RRException("外部券冲突");
// couponCustomerRelevance.setOrderId(null);
// couponCustomerRelevanceMapper.updateById(couponCustomerRelevance);
}
});
......@@ -586,9 +553,6 @@ public class MarketServiceImpl implements MarketService {
}
//内部券抵扣不了
else {
// couponCustomerRelevance.setState(null);
// couponCustomerRelevance.setOrderId(null);
// couponCustomerRelevanceService.updateById(couponCustomerRelevance);
throw new RRException("内部券冲突");
}
});
......
......@@ -30,6 +30,7 @@ public class MvcInterceptorConfig extends WebMvcConfigurationSupport {
//登陆
.excludePathPatterns("/customer/message/loginLog")
.excludePathPatterns("/customer/message/pageIn")
.excludePathPatterns("/customer/message/logoutLog")
.excludePathPatterns("/customer/xcx/login")
.excludePathPatterns("/customer/csrf")
......
package com.gogirl.infrastructure.util.lock;
import java.util.HashMap;
import java.util.concurrent.locks.ReentrantLock;
/**
*  * 分段锁,系统提供一定数量的原始锁,根据传入用户id值获取对应的锁并加锁  * 注意:要锁的用户id值如果发生改变,有可能导致锁无法成功释放!!!
*/
public class CustomerIdLock {
private final static HashMap<Integer, ReentrantLock> lockMap = new HashMap<>();
private Integer segments = 500;// 默认分段数量
private CustomerIdLock() {
init(null, false);
}
private CustomerIdLock(Integer counts, boolean fair) {
init(counts, fair);
}
/*静态内部类实现单例*/
public static final CustomerIdLock getInsatance() {
return SingletonHolder.instance;
}
private void init(Integer counts, boolean fair) {
if (counts != null) {
segments = counts;
}
for (int i = 0; i < segments; i++) {
lockMap.put(i, new ReentrantLock(fair));
}
}
public void lock(int key) {
ReentrantLock lock = lockMap.get(key % segments);
lock.lock();
}
public void unlock(int key) {
ReentrantLock lock = lockMap.get(key % segments);
lock.unlock();
}
@Override
public String toString() {
return "SegmentLock [segments=" + segments + ", lockMap=" + lockMap
+ "]";
}
/*静态内部类实现单例*/
private static class SingletonHolder {
private static final CustomerIdLock instance = new CustomerIdLock(null, true);
}
}
......@@ -3,11 +3,9 @@ package com.gogirl.interfaces.user;
import com.gogirl.application.market.CouponService;
import com.gogirl.application.xcx.GogirlTokenService;
import com.gogirl.domain.market.coupon.Coupon;
import com.gogirl.domain.xcx.GogirlToken;
import com.gogirl.infrastructure.common.base.JsonResult;
import com.gogirl.infrastructure.common.util.StringUtils;
import com.gogirl.infrastructure.util.SessionUtils;
import com.google.common.collect.Lists;
import com.gogirl.infrastructure.util.lock.CustomerIdLock;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
......@@ -15,7 +13,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.stream.Collectors;
@RestController
@Api(tags = {"优惠券配置接口"}, value = "优惠券配置接口")
......@@ -47,8 +44,14 @@ public class CouponController {
@PostMapping("/customer/sendNewCustomerCouponXcx")
public JsonResult<Coupon> sendNewCustomerCouponXcx(String token) {
Integer customerId = SessionUtils.getCustomerId();
CustomerIdLock lock = CustomerIdLock.getInsatance();
try {
lock.lock(customerId);
Coupon coupon = couponService.sendNewCustomerCouponXcx(customerId);
return JsonResult.success(coupon);
} finally {
lock.unlock(customerId);
}
}
@ApiOperation(value = "小程序发券")
......@@ -64,7 +67,6 @@ public class CouponController {
}
@ApiOperation(value = "美甲师根据订单号查询可用外部券")
@GetMapping("/technician/getOrderExternalCoupon")
public JsonResult<List<Coupon>> getOrderExternalCoupon(@RequestHeader String token,
......
......@@ -79,7 +79,7 @@ public class XcxController {
@RequestParam String iv) throws InvalidAlgorithmParameterException {
log.info("手机号码授权,用户信息:");
Customer customer = customerService.authorizedPhone(token, encryptedData, iv);
return JsonResult.success();
return JsonResult.success(customer);
}
@GetMapping("/customer/xcx/getUserInfo")
......
Markdown is supported
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