店员
This commit is contained in:
commit
fd003eff8b
1
.gitignore
vendored
1
.gitignore
vendored
@ -10,6 +10,7 @@ target
|
||||
.factorypath
|
||||
|
||||
log/
|
||||
logs/
|
||||
*.factorypath
|
||||
lili-shop/src/main/java/cn/lili/generator/CodeGenerator.java
|
||||
lili-logs
|
||||
|
@ -54,3 +54,11 @@ ALTER TABLE li_goods RENAME COLUMN is_auth TO auth_flag;
|
||||
|
||||
ALTER TABLE li_goods_sku RENAME COLUMN is_promotion TO promotion_flag;
|
||||
ALTER TABLE li_goods_sku RENAME COLUMN is_auth TO auth_flag;
|
||||
|
||||
|
||||
-- 增加会员表索引
|
||||
ALTER TABLE li_member ADD INDEX query_mobile (`mobile`) COMMENT 'query_member';
|
||||
-- 会员签到唯一索引 惠券查询索引
|
||||
ALTER TABLE li_member_sign ADD INDEX query_create_time (`create_time`) COMMENT 'query_create_time';
|
||||
ALTER TABLE li_member_sign ADD INDEX query_member_id (`member_id`) COMMENT 'query_member_id';
|
||||
ALTER TABLE li_member_sign add unique uk_member_day (member_id, create_time) COMMENT 'uk_member_day';
|
@ -75,7 +75,7 @@ PS:手机验证码为 ‘111111’
|
||||
|
||||
#### 平台管理端功能
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.lili.controller.distribution;
|
||||
|
||||
import cn.lili.common.aop.annotation.PreventDuplicateSubmissions;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
@ -13,6 +14,7 @@ import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -33,6 +35,7 @@ import javax.validation.constraints.NotNull;
|
||||
@RestController
|
||||
@Api(tags = "买家端,分销商品佣金提现接口")
|
||||
@RequestMapping("/buyer/distribution/cash")
|
||||
@Validated
|
||||
public class DistributionCashBuyerController {
|
||||
|
||||
/**
|
||||
@ -47,15 +50,16 @@ public class DistributionCashBuyerController {
|
||||
private DistributionCashService distributorCashService;
|
||||
|
||||
|
||||
@PreventDuplicateSubmissions
|
||||
@ApiOperation(value = "分销员提现")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "price", value = "申请金额", required = true, paramType = "query", dataType = "double")
|
||||
})
|
||||
@PostMapping
|
||||
public ResultMessage<Object> cash(@Max(value = 1000, message = "提现金额单次最多允许提现1000元")
|
||||
public ResultMessage<Object> cash(@Validated @Max(value = 9999, message = "提现金额单次最多允许提现9999元")
|
||||
@Min(value = 1, message = "提现金额单次最少提现金额为1元")
|
||||
@NotNull @ApiIgnore Double price) {
|
||||
if (distributionCashService.cash(price)) {
|
||||
if (Boolean.TRUE.equals(distributionCashService.cash(price))) {
|
||||
return ResultUtil.success();
|
||||
}
|
||||
throw new ServiceException(ResultCode.ERROR);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.lili.controller.distribution;
|
||||
|
||||
import cn.lili.common.aop.annotation.PreventDuplicateSubmissions;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
@ -50,6 +51,7 @@ public class DistributionGoodsBuyerController {
|
||||
return ResultUtil.data(distributionGoodsService.goodsPage(distributionGoodsSearchParams));
|
||||
}
|
||||
|
||||
@PreventDuplicateSubmissions
|
||||
@ApiOperation(value = "选择分销商品")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "distributionGoodsId", value = "分销ID", required = true, dataType = "String", paramType = "path"),
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.lili.controller.member;
|
||||
|
||||
import cn.lili.common.aop.annotation.PreventDuplicateSubmissions;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.enums.SwitchEnum;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
@ -37,10 +38,11 @@ public class MemberEvaluationBuyerController {
|
||||
@Autowired
|
||||
private MemberEvaluationService memberEvaluationService;
|
||||
|
||||
@PreventDuplicateSubmissions
|
||||
@ApiOperation(value = "添加会员评价")
|
||||
@PostMapping
|
||||
public ResultMessage<MemberEvaluationDTO> save(@Valid MemberEvaluationDTO memberEvaluationDTO) {
|
||||
return ResultUtil.data(memberEvaluationService.addMemberEvaluation(memberEvaluationDTO));
|
||||
return ResultUtil.data(memberEvaluationService.addMemberEvaluation(memberEvaluationDTO, true));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查看会员评价详情")
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.lili.controller.member;
|
||||
|
||||
import cn.lili.common.aop.annotation.PreventDuplicateSubmissions;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.member.entity.dos.MemberSign;
|
||||
@ -27,6 +28,8 @@ public class MemberSignBuyerController {
|
||||
@Autowired
|
||||
private MemberSignService memberSignService;
|
||||
|
||||
|
||||
@PreventDuplicateSubmissions
|
||||
@PostMapping
|
||||
@ApiOperation(value = "会员签到")
|
||||
public ResultMessage<Boolean> memberSign() {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.lili.controller.order;
|
||||
|
||||
import cn.lili.common.aop.annotation.PreventDuplicateSubmissions;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.security.OperationalJudgment;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
@ -77,6 +78,7 @@ public class AfterSaleBuyerController {
|
||||
return ResultUtil.data(afterSaleService.getAfterSaleVO(sn));
|
||||
}
|
||||
|
||||
@PreventDuplicateSubmissions
|
||||
@PostMapping(value = "/save/{orderItemSn}")
|
||||
@ApiImplicitParam(name = "orderItemSn", value = "订单货物编号", required = true, paramType = "query")
|
||||
@ApiOperation(value = "申请售后")
|
||||
@ -101,6 +103,7 @@ public class AfterSaleBuyerController {
|
||||
return ResultUtil.data(afterSaleService.buyerDelivery(afterSaleSn, logisticsNo, logisticsId, mDeliverTime));
|
||||
}
|
||||
|
||||
@PreventDuplicateSubmissions
|
||||
@ApiOperation(value = "售后,取消售后")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "afterSaleSn", value = "售后sn", required = true, dataType = "String", paramType = "path")
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.lili.controller.order;
|
||||
|
||||
import cn.lili.common.aop.annotation.PreventDuplicateSubmissions;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
@ -235,6 +236,7 @@ public class CartController {
|
||||
}
|
||||
|
||||
|
||||
@PreventDuplicateSubmissions
|
||||
@ApiOperation(value = "创建交易")
|
||||
@PostMapping(value = "/create/trade", consumes = "application/json", produces = "application/json")
|
||||
public ResultMessage<Object> crateTrade(@RequestBody TradeParams tradeParams) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.lili.controller.order;
|
||||
|
||||
import cn.lili.common.aop.annotation.PreventDuplicateSubmissions;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
@ -62,6 +63,7 @@ public class OrderBuyerController {
|
||||
return ResultUtil.data(orderDetailVO);
|
||||
}
|
||||
|
||||
@PreventDuplicateSubmissions
|
||||
@ApiOperation(value = "确认收货")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "orderSn", value = "订单编号", required = true, paramType = "path")
|
||||
@ -80,6 +82,7 @@ public class OrderBuyerController {
|
||||
return ResultUtil.success();
|
||||
}
|
||||
|
||||
@PreventDuplicateSubmissions
|
||||
@ApiOperation(value = "取消订单")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "orderSn", value = "订单编号", required = true, dataType = "String", paramType = "path"),
|
||||
@ -91,6 +94,7 @@ public class OrderBuyerController {
|
||||
return ResultUtil.success();
|
||||
}
|
||||
|
||||
@PreventDuplicateSubmissions
|
||||
@ApiOperation(value = "删除订单")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "orderSn", value = "订单编号", required = true, dataType = "String", paramType = "path")
|
||||
@ -113,6 +117,7 @@ public class OrderBuyerController {
|
||||
}
|
||||
|
||||
|
||||
@PreventDuplicateSubmissions
|
||||
@ApiOperation(value = "开票")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "orderSn", value = "订单编号", required = true, dataType = "String", paramType = "path")
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.lili.controller.order;
|
||||
|
||||
import cn.lili.common.aop.annotation.PreventDuplicateSubmissions;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.OperationalJudgment;
|
||||
@ -66,6 +67,7 @@ public class OrderComplaintBuyerController {
|
||||
|
||||
}
|
||||
|
||||
@PreventDuplicateSubmissions
|
||||
@ApiOperation(value = "添加交易投诉")
|
||||
@PostMapping
|
||||
public ResultMessage<OrderComplaint> add(@Valid OrderComplaintDTO orderComplaintDTO) {
|
||||
@ -85,6 +87,7 @@ public class OrderComplaintBuyerController {
|
||||
return ResultUtil.data(communicationVO);
|
||||
}
|
||||
|
||||
@PreventDuplicateSubmissions
|
||||
@ApiOperation(value = "取消售后")
|
||||
@ApiImplicitParam(name = "id", value = "投诉单ID", required = true, paramType = "path")
|
||||
@PutMapping(value = "/status/{id}")
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.lili.controller.order;
|
||||
|
||||
import cn.lili.common.aop.annotation.PreventDuplicateSubmissions;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
@ -41,6 +42,7 @@ public class ReceiptBuyerController {
|
||||
return ResultUtil.data(this.receiptService.getReceiptData(searchParams, pageVO));
|
||||
}
|
||||
|
||||
@PreventDuplicateSubmissions
|
||||
@ApiOperation(value = "保存发票信息")
|
||||
@PostMapping
|
||||
public ResultMessage<Receipt> save(@Valid Receipt receipt) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.lili.controller.order;
|
||||
|
||||
import cn.lili.common.aop.annotation.PreventDuplicateSubmissions;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.wallet.entity.dos.Recharge;
|
||||
@ -26,12 +27,12 @@ import javax.validation.constraints.Min;
|
||||
@RestController
|
||||
@Api(tags = "买家端,预存款充值记录接口")
|
||||
@RequestMapping("/buyer/trade/recharge")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class RechargeTradeBuyerController {
|
||||
|
||||
@Autowired
|
||||
private RechargeService rechargeService;
|
||||
|
||||
@PreventDuplicateSubmissions
|
||||
@PostMapping
|
||||
@ApiOperation(value = "创建余额充值订单")
|
||||
@ApiImplicitParams({
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.lili.controller.other;
|
||||
|
||||
import cn.lili.common.aop.annotation.PreventDuplicateSubmissions;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
@ -31,6 +32,7 @@ public class FeedbackBuyerController {
|
||||
@Autowired
|
||||
private FeedbackService feedbackService;
|
||||
|
||||
@PreventDuplicateSubmissions
|
||||
@ApiOperation(value = "添加意见反馈")
|
||||
@PostMapping()
|
||||
public ResultMessage<Object> save(@Valid Feedback feedback) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.lili.controller.other.purchase;
|
||||
|
||||
import cn.lili.common.aop.annotation.PreventDuplicateSubmissions;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
@ -48,6 +49,8 @@ public class PurchaseBuyerController {
|
||||
return ResultUtil.data(goodsUnitService.page(PageUtil.initPage(pageVO)));
|
||||
}
|
||||
|
||||
|
||||
@PreventDuplicateSubmissions
|
||||
@ApiOperation(value = "添加采购单")
|
||||
@PostMapping
|
||||
public ResultMessage<PurchaseOrderVO> addPurchaseOrderVO(@RequestBody PurchaseOrderVO purchaseOrderVO) {
|
||||
@ -74,6 +77,7 @@ public class PurchaseBuyerController {
|
||||
return ResultUtil.data(purchaseOrderService.page(purchaseOrderSearchParams));
|
||||
}
|
||||
|
||||
@PreventDuplicateSubmissions
|
||||
@ApiOperation(value = "关闭采购单")
|
||||
@ApiImplicitParam(name = "id", value = "采购单ID", required = true, dataType = "Long", paramType = "path")
|
||||
@PutMapping("/{id}")
|
||||
|
@ -74,8 +74,11 @@ public class MemberBuyerController {
|
||||
public ResultMessage<Object> smsLogin(@NotNull(message = "手机号为空") @RequestParam String mobile,
|
||||
@NotNull(message = "验证码为空") @RequestParam String code,
|
||||
@RequestHeader String uuid) {
|
||||
smsUtil.verifyCode(mobile, VerificationEnums.LOGIN, uuid, code);
|
||||
return ResultUtil.data(memberService.mobilePhoneLogin(mobile));
|
||||
if (smsUtil.verifyCode(mobile, VerificationEnums.LOGIN, uuid, code)) {
|
||||
return ResultUtil.data(memberService.mobilePhoneLogin(mobile));
|
||||
} else {
|
||||
throw new ServiceException(ResultCode.VERIFICATION_SMS_CHECKED_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "注册用户")
|
||||
@ -92,8 +95,11 @@ public class MemberBuyerController {
|
||||
@RequestHeader String uuid,
|
||||
@NotNull(message = "验证码不能为空") @RequestParam String code) {
|
||||
|
||||
smsUtil.verifyCode(mobilePhone, VerificationEnums.REGISTER, uuid, code);
|
||||
return ResultUtil.data(memberService.register(username, password, mobilePhone));
|
||||
if (smsUtil.verifyCode(mobilePhone, VerificationEnums.REGISTER, uuid, code)) {
|
||||
return ResultUtil.data(memberService.register(username, password, mobilePhone));
|
||||
} else {
|
||||
throw new ServiceException(ResultCode.VERIFICATION_SMS_CHECKED_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -114,14 +120,18 @@ public class MemberBuyerController {
|
||||
@NotNull(message = "验证码为空") @RequestParam String code,
|
||||
@RequestHeader String uuid) {
|
||||
//校验短信验证码是否正确
|
||||
smsUtil.verifyCode(mobile, VerificationEnums.FIND_USER, uuid, code);
|
||||
//校验是否通过手机号可获取会员,存在则将会员信息存入缓存,有效时间3分钟
|
||||
Member member = memberService.findByMobile(mobile);
|
||||
if (member == null) {
|
||||
throw new ServiceException(ResultCode.USER_NOT_PHONE);
|
||||
if (smsUtil.verifyCode(mobile, VerificationEnums.FIND_USER, uuid, code)) {
|
||||
//校验是否通过手机号可获取会员,存在则将会员信息存入缓存,有效时间3分钟
|
||||
Member member = memberService.findByMobile(mobile);
|
||||
if (member == null) {
|
||||
throw new ServiceException(ResultCode.USER_NOT_PHONE);
|
||||
}
|
||||
cache.put(CachePrefix.FIND_MOBILE + uuid, mobile, 300L);
|
||||
return ResultUtil.success();
|
||||
|
||||
} else {
|
||||
throw new ServiceException(ResultCode.VERIFICATION_SMS_CHECKED_ERROR);
|
||||
}
|
||||
cache.put(CachePrefix.FIND_MOBILE + uuid, mobile, 300L);
|
||||
return ResultUtil.success();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改密码")
|
||||
|
@ -7,9 +7,10 @@ import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.promotion.entity.dos.MemberCoupon;
|
||||
import cn.lili.modules.promotion.entity.dto.search.CouponSearchParams;
|
||||
import cn.lili.modules.promotion.entity.dto.search.MemberCouponSearchParams;
|
||||
import cn.lili.modules.promotion.entity.enums.CouponGetEnum;
|
||||
import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum;
|
||||
import cn.lili.modules.promotion.entity.vos.CouponSearchParams;
|
||||
import cn.lili.modules.promotion.entity.vos.CouponVO;
|
||||
import cn.lili.modules.promotion.service.CouponService;
|
||||
import cn.lili.modules.promotion.service.MemberCouponService;
|
||||
@ -61,7 +62,7 @@ public class CouponBuyerController {
|
||||
|
||||
@ApiOperation(value = "获取当前会员的优惠券列表")
|
||||
@GetMapping("/getCoupons")
|
||||
public ResultMessage<IPage<MemberCoupon>> getCoupons(CouponSearchParams param, PageVO pageVo) {
|
||||
public ResultMessage<IPage<MemberCoupon>> getCoupons(MemberCouponSearchParams param, PageVO pageVo) {
|
||||
AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser());
|
||||
param.setMemberId(currentUser.getId());
|
||||
return ResultUtil.data(memberCouponService.getMemberCoupons(param, pageVo));
|
||||
@ -69,7 +70,7 @@ public class CouponBuyerController {
|
||||
|
||||
@ApiOperation(value = "获取当前会员的对于当前商品可使用的优惠券列表")
|
||||
@GetMapping("/canUse")
|
||||
public ResultMessage<IPage<MemberCoupon>> getCouponsByCanUse(CouponSearchParams param, Double totalPrice, PageVO pageVo) {
|
||||
public ResultMessage<IPage<MemberCoupon>> getCouponsByCanUse(MemberCouponSearchParams param, Double totalPrice, PageVO pageVo) {
|
||||
AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser());
|
||||
param.setMemberId(currentUser.getId());
|
||||
return ResultUtil.data(memberCouponService.getMemberCouponsByCanUse(param, totalPrice, pageVo));
|
||||
|
@ -1,16 +1,20 @@
|
||||
package cn.lili.controller.promotion;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.promotion.entity.dos.KanjiaActivity;
|
||||
import cn.lili.modules.promotion.entity.dos.KanjiaActivityLog;
|
||||
import cn.lili.modules.promotion.entity.dto.KanJiaActivityLogQuery;
|
||||
import cn.lili.modules.promotion.entity.dto.KanjiaActivityQuery;
|
||||
import cn.lili.modules.promotion.entity.dto.search.KanJiaActivityLogQuery;
|
||||
import cn.lili.modules.promotion.entity.dto.search.KanjiaActivityGoodsParams;
|
||||
import cn.lili.modules.promotion.entity.dto.search.KanjiaActivityQuery;
|
||||
import cn.lili.modules.promotion.entity.dto.search.KanjiaActivitySearchParams;
|
||||
import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum;
|
||||
import cn.lili.modules.promotion.entity.vos.kanjia.*;
|
||||
import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivityGoodsListVO;
|
||||
import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivityGoodsVO;
|
||||
import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivityVO;
|
||||
import cn.lili.modules.promotion.service.KanjiaActivityGoodsService;
|
||||
import cn.lili.modules.promotion.service.KanjiaActivityLogService;
|
||||
import cn.lili.modules.promotion.service.KanjiaActivityService;
|
||||
@ -75,7 +79,7 @@ public class KanjiaGoodsActivityBuyerController {
|
||||
@ApiOperation(value = "获取砍价活动")
|
||||
public ResultMessage<KanjiaActivityVO> getKanJiaActivity(KanjiaActivitySearchParams kanjiaActivitySearchParams) {
|
||||
//如果是非被邀请关系则填写会员ID
|
||||
if (StrUtil.isEmpty(kanjiaActivitySearchParams.getKanjiaActivityId())) {
|
||||
if (CharSequenceUtil.isEmpty(kanjiaActivitySearchParams.getKanjiaActivityId())) {
|
||||
kanjiaActivitySearchParams.setMemberId(UserContext.getCurrentUser().getId());
|
||||
}
|
||||
return ResultUtil.data(kanJiaActivityService.getKanjiaActivityVO(kanjiaActivitySearchParams));
|
||||
|
@ -5,10 +5,10 @@ import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.promotion.entity.dos.PromotionGoods;
|
||||
import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams;
|
||||
import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum;
|
||||
import cn.lili.modules.promotion.entity.vos.PintuanMemberVO;
|
||||
import cn.lili.modules.promotion.entity.vos.PintuanShareVO;
|
||||
import cn.lili.modules.promotion.entity.vos.PromotionGoodsSearchParams;
|
||||
import cn.lili.modules.promotion.service.PintuanService;
|
||||
import cn.lili.modules.promotion.service.PromotionGoodsService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
@ -5,8 +5,8 @@ import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.promotion.entity.dos.PointsGoods;
|
||||
import cn.lili.modules.promotion.entity.dos.PointsGoodsCategory;
|
||||
import cn.lili.modules.promotion.entity.dto.search.PointsGoodsSearchParams;
|
||||
import cn.lili.modules.promotion.entity.enums.PromotionsStatusEnum;
|
||||
import cn.lili.modules.promotion.entity.vos.PointsGoodsSearchParams;
|
||||
import cn.lili.modules.promotion.entity.vos.PointsGoodsVO;
|
||||
import cn.lili.modules.promotion.service.PointsGoodsCategoryService;
|
||||
import cn.lili.modules.promotion.service.PointsGoodsService;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.lili.controller.wallet;
|
||||
|
||||
|
||||
import cn.lili.common.aop.annotation.PreventDuplicateSubmissions;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
@ -35,6 +36,7 @@ public class MemberReceiptController {
|
||||
return ResultUtil.data(memberReceiptService.getPage(memberReceiptVO, page));
|
||||
}
|
||||
|
||||
@PreventDuplicateSubmissions
|
||||
@ApiOperation(value = "新增会员发票")
|
||||
@PostMapping
|
||||
public ResultMessage<Object> add(MemberReceiptAddVO memberReceiptAddVO) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.lili.controller.wallet;
|
||||
|
||||
import cn.lili.common.aop.annotation.PreventDuplicateSubmissions;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
@ -120,12 +121,13 @@ public class MemberWalletBuyerController {
|
||||
}
|
||||
|
||||
|
||||
@PreventDuplicateSubmissions
|
||||
@PostMapping(value = "/withdrawal")
|
||||
@ApiOperation(value = "会员中心余额提现")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "price", value = "提现金额", required = true, dataType = "double", paramType = "query")
|
||||
})
|
||||
public ResultMessage<Boolean> withdrawal(@Max(value = 1000, message = "充值金额单次最多允许提现1000元") @Min(value = 1, message = "充值金额单次最少提现金额为1元") Double price) {
|
||||
public ResultMessage<Boolean> withdrawal(@Max(value = 9999, message = "充值金额单次最多允许提现9999元") @Min(value = 1, message = "充值金额单次最少提现金额为1元") Double price) {
|
||||
return ResultUtil.data(memberWalletService.applyWithdrawal(price));
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,6 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RestController
|
||||
@Api(tags = "买家端,余额提现记录接口")
|
||||
@RequestMapping("/buyer/member/withdrawApply")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class MemberWithdrawApplyBuyerController {
|
||||
@Autowired
|
||||
private MemberWithdrawApplyService memberWithdrawApplyService;
|
||||
|
@ -25,7 +25,6 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RestController
|
||||
@Api(tags = "买家端,预存款充值记录接口")
|
||||
@RequestMapping("/buyer/member/recharge")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class RechargeBuyerController {
|
||||
|
||||
@Autowired
|
||||
|
@ -3,12 +3,19 @@ server:
|
||||
|
||||
servlet:
|
||||
context-path: /
|
||||
|
||||
tomcat:
|
||||
uri-encoding: UTF-8
|
||||
threads:
|
||||
min-spare: 50
|
||||
max: 1000
|
||||
#
|
||||
# tomcat:
|
||||
# #最大链接数,默认不设置,默认是10000
|
||||
# max-connections: 6500
|
||||
# #最大等待队列长度,允许HTTP请求缓存到请求队列的最大个数,默认不限制
|
||||
# accept-count: 1000
|
||||
# threads:
|
||||
# #最少闲置
|
||||
# min-spare: 50
|
||||
# #最大线程数 ,默认是200
|
||||
# max: 800
|
||||
netty:
|
||||
connection-timeout:
|
||||
|
||||
# 与Spring Boot 2一样,默认情况下,大多数端点都不通过http公开,我们公开了所有端点。对于生产,您应该仔细选择要公开的端点。
|
||||
management:
|
||||
@ -69,10 +76,10 @@ spring:
|
||||
url: jdbc:mysql://127.0.0.1:3306/lilishop?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
username: root
|
||||
password: lilishop
|
||||
maxActive: 20
|
||||
initialSize: 5
|
||||
maxActive: 50
|
||||
initialSize: 10
|
||||
maxWait: 60000
|
||||
minIdle: 5
|
||||
minIdle: 10
|
||||
timeBetweenEvictionRunsMillis: 60000
|
||||
minEvictableIdleTimeMillis: 300000
|
||||
validationQuery: SELECT 1 FROM DUAL
|
||||
@ -110,7 +117,7 @@ spring:
|
||||
props:
|
||||
#是否打印逻辑SQL语句和实际SQL语句,建议调试时打印,在生产环境关闭
|
||||
sql:
|
||||
show: true
|
||||
show: false
|
||||
|
||||
# 忽略TOKEN 鉴权 的url
|
||||
ignored:
|
||||
@ -176,8 +183,7 @@ logging:
|
||||
config: classpath:logback-spring.xml
|
||||
# 输出级别
|
||||
level:
|
||||
cn.lili: debug
|
||||
org.hibernate: debug
|
||||
root: error
|
||||
# org.springframework: debug
|
||||
file:
|
||||
# 指定路径
|
||||
|
21
buyer-api/src/main/resources/redisson.yaml
Normal file
21
buyer-api/src/main/resources/redisson.yaml
Normal file
@ -0,0 +1,21 @@
|
||||
---
|
||||
singleServerConfig:
|
||||
idleConnectionTimeout: 10000
|
||||
connectTimeout: 10000
|
||||
timeout: 3000
|
||||
retryAttempts: 3
|
||||
retryInterval: 1500
|
||||
password: lilishop
|
||||
subscriptionsPerConnection: 5
|
||||
clientName: null
|
||||
address: "redis://127.0.0.1:6379"
|
||||
subscriptionConnectionMinimumIdleSize: 1
|
||||
subscriptionConnectionPoolSize: 50
|
||||
connectionMinimumIdleSize: 24
|
||||
connectionPoolSize: 64
|
||||
database: 0
|
||||
dnsMonitoringInterval: 5000
|
||||
threads: 16
|
||||
nettyThreads: 32
|
||||
codec: !<org.redisson.codec.MarshallingCodec> {}
|
||||
transportMode: "NIO"
|
@ -1,6 +1,7 @@
|
||||
package cn.lili.controller.common;
|
||||
|
||||
import cn.lili.cache.limit.annotation.LimitPoint;
|
||||
import cn.lili.common.aop.annotation.PreventDuplicateSubmissions;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.verification.entity.enums.VerificationEnums;
|
||||
|
@ -52,9 +52,6 @@ public class UploadController {
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
|
||||
@Autowired
|
||||
private SystemSettingProperties systemSettingProperties;
|
||||
|
||||
@ApiOperation(value = "文件上传")
|
||||
@PostMapping(value = "/file")
|
||||
public ResultMessage<Object> upload(MultipartFile file,
|
||||
|
@ -108,7 +108,7 @@ spring:
|
||||
props:
|
||||
#是否打印逻辑SQL语句和实际SQL语句,建议调试时打印,在生产环境关闭
|
||||
sql:
|
||||
show: true
|
||||
show: false
|
||||
|
||||
# 忽略鉴权url
|
||||
ignored:
|
||||
@ -176,7 +176,7 @@ logging:
|
||||
config: classpath:logback-spring.xml
|
||||
# 输出级别
|
||||
level:
|
||||
cn.lili: info
|
||||
root: error
|
||||
# org.hibernate: debug
|
||||
# org.springframework: debug
|
||||
file:
|
||||
|
21
common-api/src/main/resources/redisson.yaml
Normal file
21
common-api/src/main/resources/redisson.yaml
Normal file
@ -0,0 +1,21 @@
|
||||
---
|
||||
singleServerConfig:
|
||||
idleConnectionTimeout: 10000
|
||||
connectTimeout: 10000
|
||||
timeout: 3000
|
||||
retryAttempts: 3
|
||||
retryInterval: 1500
|
||||
password: lilishop
|
||||
subscriptionsPerConnection: 5
|
||||
clientName: null
|
||||
address: "redis://127.0.0.1:6379"
|
||||
subscriptionConnectionMinimumIdleSize: 1
|
||||
subscriptionConnectionPoolSize: 50
|
||||
connectionMinimumIdleSize: 24
|
||||
connectionPoolSize: 64
|
||||
database: 0
|
||||
dnsMonitoringInterval: 5000
|
||||
threads: 16
|
||||
nettyThreads: 32
|
||||
codec: !<org.redisson.codec.MarshallingCodec> {}
|
||||
transportMode: "NIO"
|
@ -72,8 +72,8 @@ spring:
|
||||
url: jdbc:mysql://192.168.0.116:3306/clerk?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
username: root
|
||||
password: lilishop
|
||||
maxActive: 20
|
||||
initialSize: 5
|
||||
maxActive: 50
|
||||
initialSize: 20
|
||||
maxWait: 60000
|
||||
minIdle: 5
|
||||
timeBetweenEvictionRunsMillis: 60000
|
||||
@ -183,7 +183,7 @@ mybatis-plus:
|
||||
logging:
|
||||
# 输出级别
|
||||
level:
|
||||
cn.lili: info
|
||||
root: info
|
||||
# org.hibernate: debug
|
||||
# org.springframework: debug
|
||||
# org.springframework.data.mongodb.core: debug
|
||||
|
19
consumer/src/main/java/cn/lili/event/MemberLoginEvent.java
Normal file
19
consumer/src/main/java/cn/lili/event/MemberLoginEvent.java
Normal file
@ -0,0 +1,19 @@
|
||||
package cn.lili.event;
|
||||
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
|
||||
/**
|
||||
* 会员登录消息
|
||||
*
|
||||
* @author Chopper
|
||||
* @since 2020/11/17 7:13 下午
|
||||
*/
|
||||
public interface MemberLoginEvent {
|
||||
|
||||
/**
|
||||
* 会员登录
|
||||
*
|
||||
* @param member 会员
|
||||
*/
|
||||
void memberLogin(Member member);
|
||||
}
|
@ -11,7 +11,7 @@ import cn.lili.modules.member.entity.dos.Member;
|
||||
public interface MemberRegisterEvent {
|
||||
|
||||
/**
|
||||
* 会员登录
|
||||
* 会员注册
|
||||
*
|
||||
* @param member 会员
|
||||
*/
|
||||
|
@ -10,6 +10,7 @@ import cn.lili.common.utils.SnowFlake;
|
||||
import cn.lili.event.OrderStatusChangeEvent;
|
||||
import cn.lili.event.TradeEvent;
|
||||
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsTypeEnum;
|
||||
import cn.lili.modules.goods.service.GoodsSkuService;
|
||||
import cn.lili.modules.member.entity.enums.PointTypeEnum;
|
||||
import cn.lili.modules.member.service.MemberService;
|
||||
@ -34,6 +35,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 订单状态处理类
|
||||
@ -82,7 +84,7 @@ public class FullDiscountExecute implements TradeEvent, OrderStatusChangeEvent {
|
||||
if ((cartVO.getGiftList() != null && !cartVO.getGiftList().isEmpty())
|
||||
|| (cartVO.getGiftPoint() != null && cartVO.getGiftPoint() > 0)
|
||||
|| (cartVO.getGiftCouponList() != null && !cartVO.getGiftCouponList().isEmpty())) {
|
||||
cache.put(CachePrefix.ORDER.getPrefix() + cartVO.getSn(), cartVO);
|
||||
cache.put(CachePrefix.ORDER.getPrefix() + cartVO.getSn(), JSONUtil.toJsonStr(cartVO));
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -90,9 +92,10 @@ public class FullDiscountExecute implements TradeEvent, OrderStatusChangeEvent {
|
||||
|
||||
@Override
|
||||
public void orderChange(OrderMessage orderMessage) {
|
||||
//如果订单已支付
|
||||
if (orderMessage.getNewStatus().equals(OrderStatusEnum.PAID)) {
|
||||
log.debug("满减活动,订单状态操作 {}", CachePrefix.ORDER.getPrefix() + orderMessage.getOrderSn());
|
||||
renderGift((CartVO) cache.get(CachePrefix.ORDER.getPrefix() + orderMessage.getOrderSn()), orderMessage);
|
||||
renderGift(JSONUtil.toBean(cache.getString(CachePrefix.ORDER.getPrefix() + orderMessage.getOrderSn()), CartVO.class), orderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,49 +145,89 @@ public class FullDiscountExecute implements TradeEvent, OrderStatusChangeEvent {
|
||||
* @param originOrder 赠品原订单信息
|
||||
*/
|
||||
private void generatorGiftOrder(List<String> skuIds, Order originOrder) {
|
||||
//获取赠品列表
|
||||
List<GoodsSku> goodsSkus = goodsSkuService.getGoodsSkuByIdFromCache(skuIds);
|
||||
|
||||
//赠品判定
|
||||
if (goodsSkus == null || goodsSkus.isEmpty()) {
|
||||
log.error("赠品不存在:{}", skuIds);
|
||||
return;
|
||||
}
|
||||
|
||||
//赠品分类,分为实体商品/虚拟商品/电子卡券
|
||||
List<GoodsSku> physicalSkus = goodsSkus.stream().filter(goodsSku -> goodsSku.getGoodsType().equals(GoodsTypeEnum.PHYSICAL_GOODS.name())).collect(Collectors.toList());
|
||||
List<GoodsSku> virtualSkus = goodsSkus.stream().filter(goodsSku -> goodsSku.getGoodsType().equals(GoodsTypeEnum.VIRTUAL_GOODS.name())).collect(Collectors.toList());
|
||||
List<GoodsSku> eCouponSkus = goodsSkus.stream().filter(goodsSku -> goodsSku.getGoodsType().equals(GoodsTypeEnum.E_COUPON.name())).collect(Collectors.toList());
|
||||
|
||||
//如果赠品不为空,则生成对应的赠品订单
|
||||
if (!physicalSkus.isEmpty()) {
|
||||
giftOrderHandler(physicalSkus, originOrder, OrderTypeEnum.NORMAL);
|
||||
}
|
||||
if (!virtualSkus.isEmpty()) {
|
||||
giftOrderHandler(virtualSkus, originOrder, OrderTypeEnum.VIRTUAL);
|
||||
}
|
||||
if (!eCouponSkus.isEmpty()) {
|
||||
giftOrderHandler(eCouponSkus, originOrder, OrderTypeEnum.E_COUPON);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 赠品订单处理
|
||||
*
|
||||
* @param skuList 赠品列表
|
||||
* @param originOrder 原始订单
|
||||
* @param orderTypeEnum 订单类型
|
||||
*/
|
||||
private void giftOrderHandler(List<GoodsSku> skuList, Order originOrder, OrderTypeEnum orderTypeEnum) {
|
||||
//初始化订单对象/订单日志/自订单
|
||||
Order order = new Order();
|
||||
List<OrderItem> orderItems = new ArrayList<>();
|
||||
List<OrderLog> orderLogs = new ArrayList<>();
|
||||
Order order = new Order();
|
||||
//初始化价格详情
|
||||
PriceDetailDTO priceDetailDTO = new PriceDetailDTO();
|
||||
//复制通用属性
|
||||
BeanUtil.copyProperties(originOrder, order, "id");
|
||||
BeanUtil.copyProperties(priceDetailDTO, order, "id");
|
||||
//生成订单参数
|
||||
order.setSn(SnowFlake.createStr("G"));
|
||||
order.setOrderType(OrderPromotionTypeEnum.GIFT.name());
|
||||
order.setOrderPromotionType(OrderPromotionTypeEnum.GIFT.name());
|
||||
order.setOrderStatus(OrderStatusEnum.UNPAID.name());
|
||||
order.setPayStatus(PayStatusEnum.PAID.name());
|
||||
order.setDeliverStatus(DeliverStatusEnum.UNDELIVERED.name());
|
||||
order.setOrderType(orderTypeEnum.name());
|
||||
order.setNeedReceipt(false);
|
||||
order.setPriceDetailDTO(priceDetailDTO);
|
||||
order.setClientType(originOrder.getClientType());
|
||||
//订单日志
|
||||
String message = "赠品订单[" + order.getSn() + "]创建";
|
||||
orderLogs.add(new OrderLog(order.getSn(), originOrder.getMemberId(), UserEnums.MEMBER.name(), originOrder.getMemberName(), message));
|
||||
|
||||
for (String skuId : skuIds) {
|
||||
GoodsSku goodsSkuByIdFromCache = goodsSkuService.getGoodsSkuByIdFromCache(skuId);
|
||||
//生成子订单
|
||||
for (GoodsSku goodsSku : skuList) {
|
||||
OrderItem orderItem = new OrderItem();
|
||||
BeanUtil.copyProperties(goodsSkuByIdFromCache, orderItem, "id");
|
||||
BeanUtil.copyProperties(goodsSku, orderItem, "id");
|
||||
BeanUtil.copyProperties(priceDetailDTO, orderItem, "id");
|
||||
orderItem.setAfterSaleStatus(OrderItemAfterSaleStatusEnum.NEW.name());
|
||||
orderItem.setCommentStatus(CommentStatusEnum.NEW.name());
|
||||
orderItem.setComplainStatus(OrderComplaintStatusEnum.NEW.name());
|
||||
orderItem.setNum(1);
|
||||
orderItem.setOrderSn(order.getSn());
|
||||
orderItem.setImage(goodsSkuByIdFromCache.getThumbnail());
|
||||
orderItem.setGoodsName(goodsSkuByIdFromCache.getGoodsName());
|
||||
orderItem.setSkuId(goodsSkuByIdFromCache.getId());
|
||||
orderItem.setCategoryId(goodsSkuByIdFromCache.getCategoryPath().substring(
|
||||
goodsSkuByIdFromCache.getCategoryPath().lastIndexOf(",") + 1
|
||||
orderItem.setImage(goodsSku.getThumbnail());
|
||||
orderItem.setGoodsName(goodsSku.getGoodsName());
|
||||
orderItem.setSkuId(goodsSku.getId());
|
||||
orderItem.setCategoryId(goodsSku.getCategoryPath().substring(
|
||||
goodsSku.getCategoryPath().lastIndexOf(",") + 1
|
||||
));
|
||||
orderItem.setGoodsPrice(goodsSkuByIdFromCache.getPrice());
|
||||
orderItem.setGoodsPrice(goodsSku.getPrice());
|
||||
orderItem.setPriceDetailDTO(priceDetailDTO);
|
||||
orderItems.add(orderItem);
|
||||
}
|
||||
//保存订单
|
||||
orderService.save(order);
|
||||
orderItemService.saveBatch(orderItems);
|
||||
orderLogService.saveBatch(orderLogs);
|
||||
|
||||
|
||||
//发送订单已付款消息
|
||||
//发送订单已付款消息(PS:不在这里处理逻辑是因为期望加交给消费者统一处理库存等等问题)
|
||||
OrderMessage orderMessage = new OrderMessage();
|
||||
orderMessage.setOrderSn(order.getSn());
|
||||
orderMessage.setPaymentMethod(order.getPaymentMethod());
|
||||
@ -193,7 +236,5 @@ public class FullDiscountExecute implements TradeEvent, OrderStatusChangeEvent {
|
||||
String destination = rocketmqCustomProperties.getOrderTopic() + ":" + OrderTagsEnum.STATUS_CHANGE.name();
|
||||
//发送订单变更mq消息
|
||||
rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(orderMessage), RocketmqSendCallbackBuilder.commonCallback());
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
25
consumer/src/main/java/cn/lili/event/impl/MemberExecute.java
Normal file
25
consumer/src/main/java/cn/lili/event/impl/MemberExecute.java
Normal file
@ -0,0 +1,25 @@
|
||||
package cn.lili.event.impl;
|
||||
|
||||
import cn.lili.event.MemberLoginEvent;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.member.service.MemberService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 会员自身业务
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2022-01-11 11:08
|
||||
*/
|
||||
@Service
|
||||
public class MemberExecute implements MemberLoginEvent {
|
||||
@Autowired
|
||||
private MemberService memberService;
|
||||
|
||||
@Override
|
||||
public void memberLogin(Member member) {
|
||||
memberService.updateMemberLoginTime(member.getId());
|
||||
}
|
||||
}
|
@ -103,14 +103,18 @@ public class MemberPointExecute implements MemberRegisterEvent, GoodsCommentComp
|
||||
}
|
||||
case COMPLETED: {
|
||||
Order order = orderService.getBySn(orderMessage.getOrderSn());
|
||||
//根据订单编号获取订单数据,如果订单促销类型不为空,并且订单促销类型为积分订单 则直接返回
|
||||
if (StringUtils.isNotEmpty(order.getOrderPromotionType()) && order.getOrderPromotionType().equals(OrderPromotionTypeEnum.POINTS.name())) {
|
||||
//如果是积分订单 则直接返回
|
||||
if (StringUtils.isNotEmpty(order.getOrderPromotionType())
|
||||
&& order.getOrderPromotionType().equals(OrderPromotionTypeEnum.POINTS.name())) {
|
||||
return;
|
||||
}
|
||||
//获取积分设置
|
||||
PointSetting pointSetting = getPointSetting();
|
||||
if (pointSetting.getConsumer() == 0) {
|
||||
return;
|
||||
}
|
||||
//计算赠送积分数量
|
||||
Double point = CurrencyUtil.mul(pointSetting.getMoney(), order.getFlowPrice(), 0);
|
||||
Double point = CurrencyUtil.mul(pointSetting.getConsumer(), order.getFlowPrice(), 0);
|
||||
//赠送会员积分
|
||||
memberService.updateMemberPoint(point.longValue(), PointTypeEnum.INCREASE.name(), order.getMemberId(), "会员下单,赠送积分" + point + "分");
|
||||
break;
|
||||
|
@ -14,8 +14,8 @@ import cn.lili.modules.order.order.service.OrderService;
|
||||
import cn.lili.modules.promotion.entity.dos.KanjiaActivity;
|
||||
import cn.lili.modules.promotion.entity.dos.PromotionGoods;
|
||||
import cn.lili.modules.promotion.entity.dto.KanjiaActivityGoodsDTO;
|
||||
import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams;
|
||||
import cn.lili.modules.promotion.entity.vos.PointsGoodsVO;
|
||||
import cn.lili.modules.promotion.entity.vos.PromotionGoodsSearchParams;
|
||||
import cn.lili.modules.promotion.service.KanjiaActivityGoodsService;
|
||||
import cn.lili.modules.promotion.service.KanjiaActivityService;
|
||||
import cn.lili.modules.promotion.service.PointsGoodsService;
|
||||
@ -154,14 +154,11 @@ public class StockUpdateExecute implements OrderStatusChangeEvent {
|
||||
* @param stocks
|
||||
*/
|
||||
private void checkStocks(List<Integer> stocks, OrderDetailVO order) {
|
||||
for (int i = 0; i < stocks.size(); i++) {
|
||||
if (null == stocks.get(i)) {
|
||||
initSkuCache(order.getOrderItems());
|
||||
initPromotionCache(order.getOrderItems());
|
||||
return;
|
||||
}
|
||||
|
||||
if (order.getOrderItems().size() == stocks.size()) {
|
||||
return;
|
||||
}
|
||||
initSkuCache(order.getOrderItems());
|
||||
initPromotionCache(order.getOrderItems());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -298,7 +295,7 @@ public class StockUpdateExecute implements OrderStatusChangeEvent {
|
||||
pointsGoodsService.updateById(pointsGoodsVO);
|
||||
} else {
|
||||
PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams();
|
||||
searchParams.setPromotionStatus(promotionTypeEnum.name());
|
||||
searchParams.setPromotionType(promotionTypeEnum.name());
|
||||
searchParams.setPromotionId(orderItem.getPromotionId());
|
||||
searchParams.setSkuId(orderItem.getSkuId());
|
||||
PromotionGoods pGoods = promotionGoodsService.getPromotionsGoods(searchParams);
|
||||
|
@ -22,10 +22,10 @@ import cn.lili.modules.member.entity.dos.FootPrint;
|
||||
import cn.lili.modules.member.entity.dos.MemberEvaluation;
|
||||
import cn.lili.modules.member.service.FootprintService;
|
||||
import cn.lili.modules.member.service.GoodsCollectionService;
|
||||
import cn.lili.modules.promotion.entity.dos.BasePromotions;
|
||||
import cn.lili.modules.promotion.entity.dos.PromotionGoods;
|
||||
import cn.lili.modules.promotion.entity.dto.BasePromotions;
|
||||
import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams;
|
||||
import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum;
|
||||
import cn.lili.modules.promotion.entity.vos.PromotionGoodsSearchParams;
|
||||
import cn.lili.modules.promotion.service.PromotionGoodsService;
|
||||
import cn.lili.modules.promotion.service.PromotionService;
|
||||
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
||||
@ -133,6 +133,7 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
|
||||
case GENERATOR_GOODS_INDEX:
|
||||
try {
|
||||
String goodsId = new String(messageExt.getBody());
|
||||
log.info("生成索引: {}", goodsId);
|
||||
Goods goods = this.goodsService.getById(goodsId);
|
||||
updateGoodsIndex(goods);
|
||||
} catch (Exception e) {
|
||||
@ -144,7 +145,6 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
|
||||
break;
|
||||
case DELETE_GOODS_INDEX_PROMOTIONS:
|
||||
BasePromotions promotions = JSONUtil.toBean(new String(messageExt.getBody()), BasePromotions.class);
|
||||
log.info("删除索引信息: {}", promotions);
|
||||
if (CharSequenceUtil.isNotEmpty(promotions.getScopeId())) {
|
||||
this.goodsIndexService.deleteEsGoodsPromotionByPromotionId(Arrays.asList(promotions.getScopeId().split(",")), promotions.getId());
|
||||
} else {
|
||||
@ -188,6 +188,7 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
|
||||
case GOODS_AUDIT:
|
||||
Goods goods = JSONUtil.toBean(new String(messageExt.getBody()), Goods.class);
|
||||
updateGoodsNum(goods);
|
||||
updateGoodsIndex(goods);
|
||||
break;
|
||||
//删除商品
|
||||
case GOODS_DELETE:
|
||||
@ -258,12 +259,13 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
|
||||
searchParams.setCategoryPath(promotions.getScopeId());
|
||||
List<GoodsSku> goodsSkuByList = this.goodsSkuService.getGoodsSkuByList(searchParams);
|
||||
List<String> skuIds = goodsSkuByList.stream().map(GoodsSku::getId).collect(Collectors.toList());
|
||||
this.goodsIndexService.deleteEsGoodsPromotionByPromotionId(skuIds, promotions.getId());
|
||||
this.goodsIndexService.updateEsGoodsIndexPromotions(skuIds, promotions, esPromotionKey);
|
||||
} else if (PromotionsScopeTypeEnum.ALL.name().equals(promotions.getScopeType())) {
|
||||
this.goodsIndexService.updateEsGoodsIndexAllByList(promotions, esPromotionKey);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("生成商品索引促销信息执行异常,参数信息 {}", promotionsJsonStr);
|
||||
log.error("生成商品索引促销信息执行异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -311,6 +313,8 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
|
||||
GoodsSearchParams searchParams = new GoodsSearchParams();
|
||||
searchParams.setGoodsId(goods.getId());
|
||||
List<GoodsSku> goodsSkuList = this.goodsSkuService.getGoodsSkuByList(searchParams);
|
||||
log.info("goods:{}", goods);
|
||||
log.info("goodsSkuList:{}", goodsSkuList);
|
||||
if (goods.getAuthFlag().equals(GoodsAuthEnum.PASS.name())
|
||||
&& goods.getMarketEnable().equals(GoodsStatusEnum.UPPER.name())
|
||||
&& Boolean.FALSE.equals(goods.getDeleteFlag())) {
|
||||
@ -339,6 +343,8 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
|
||||
EsGoodsIndex esGoodsOld = goodsIndexService.findById(goodsSku.getId());
|
||||
EsGoodsIndex goodsIndex = this.settingUpGoodsIndexData(goods, goodsSku);
|
||||
goodsIndex.setSkuSource(skuSource--);
|
||||
log.info("goodsSku:{}", goodsSku);
|
||||
log.info("esGoodsOld:{}", esGoodsOld);
|
||||
//如果商品库存不为0,并且es中有数据
|
||||
if (goodsSku.getQuantity() > 0 && esGoodsOld == null) {
|
||||
log.info("生成商品索引 {}", goodsIndex);
|
||||
@ -384,8 +390,8 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
|
||||
}
|
||||
|
||||
if (goodsIndex.getPromotionMap() == null || goodsIndex.getPromotionMap().isEmpty()) {
|
||||
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsPromotionMap(goodsIndex);
|
||||
goodsIndex.setPromotionMap(goodsCurrentPromotionMap);
|
||||
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsSkuPromotionMap(goodsIndex.getStoreId(), goodsIndex.getId());
|
||||
goodsIndex.setPromotionMapJson(JSONUtil.toJsonStr(goodsCurrentPromotionMap));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.lili.listener;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.event.MemberLoginEvent;
|
||||
import cn.lili.event.MemberPointChangeEvent;
|
||||
import cn.lili.event.MemberRegisterEvent;
|
||||
import cn.lili.event.MemberWithdrawalEvent;
|
||||
@ -51,6 +52,12 @@ public class MemberMessageListener implements RocketMQListener<MessageExt> {
|
||||
@Autowired
|
||||
private List<MemberRegisterEvent> memberSignEvents;
|
||||
|
||||
/**
|
||||
* 会员注册
|
||||
*/
|
||||
@Autowired
|
||||
private List<MemberLoginEvent> memberLoginEvents;
|
||||
|
||||
|
||||
@Override
|
||||
public void onMessage(MessageExt messageExt) {
|
||||
@ -69,6 +76,21 @@ public class MemberMessageListener implements RocketMQListener<MessageExt> {
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MEMBER_LOGIN:
|
||||
|
||||
for (MemberLoginEvent memberLoginEvent : memberLoginEvents) {
|
||||
try {
|
||||
Member member = JSONUtil.toBean(new String(messageExt.getBody()), Member.class);
|
||||
memberLoginEvent.memberLogin(member);
|
||||
} catch (Exception e) {
|
||||
log.error("会员{},在{}业务中,状态修改事件执行异常",
|
||||
new String(messageExt.getBody()),
|
||||
memberLoginEvent.getClass().getName(),
|
||||
e);
|
||||
}
|
||||
}
|
||||
break;
|
||||
//会员签到
|
||||
case MEMBER_SING:
|
||||
MemberSign memberSign = JSONUtil.toBean(new String(messageExt.getBody()), MemberSign.class);
|
||||
|
@ -5,7 +5,6 @@ import cn.lili.common.enums.SwitchEnum;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.member.entity.vo.MemberSearchVO;
|
||||
import cn.lili.modules.member.entity.vo.MemberVO;
|
||||
import cn.lili.modules.member.mapper.MemberMapper;
|
||||
import cn.lili.modules.member.service.MemberService;
|
||||
import cn.lili.modules.message.entity.dos.MemberMessage;
|
||||
import cn.lili.modules.message.entity.dos.Message;
|
||||
@ -28,7 +27,6 @@ import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -42,11 +40,6 @@ import java.util.List;
|
||||
@RocketMQMessageListener(topic = "${lili.data.rocketmq.notice-send-topic}", consumerGroup = "${lili.data.rocketmq.notice-send-group}")
|
||||
public class NoticeSendMessageListener implements RocketMQListener<MessageExt> {
|
||||
|
||||
/**
|
||||
* 会员
|
||||
*/
|
||||
@Resource
|
||||
private MemberMapper memberMapper;
|
||||
/**
|
||||
* 短信
|
||||
*/
|
||||
@ -82,7 +75,7 @@ public class NoticeSendMessageListener implements RocketMQListener<MessageExt> {
|
||||
//发送全部会员
|
||||
if (smsReachDTO.getSmsRange().equals(RangeEnum.ALL.name())) {
|
||||
//获取所有会员的手机号
|
||||
List<String> list = memberMapper.getAllMemberMobile();
|
||||
List<String> list = memberService.getAllMemberMobile();
|
||||
smsUtil.sendBatchSms(smsReachDTO.getSignName(), list, smsReachDTO.getMessageCode());
|
||||
//判断为发送部分用户
|
||||
} else {
|
||||
|
@ -3,13 +3,12 @@ package cn.lili.timetask.handler.impl.bill;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.lili.modules.store.entity.dto.StoreSettlementDay;
|
||||
import cn.lili.modules.store.mapper.StoreDetailMapper;
|
||||
import cn.lili.modules.store.service.BillService;
|
||||
import cn.lili.modules.store.service.StoreDetailService;
|
||||
import cn.lili.timetask.handler.EveryDayExecute;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -29,8 +28,8 @@ public class BillExecute implements EveryDayExecute {
|
||||
/**
|
||||
* 店铺详情
|
||||
*/
|
||||
@Resource
|
||||
private StoreDetailMapper storeDetailMapper;
|
||||
@Autowired
|
||||
private StoreDetailService storeDetailService;
|
||||
|
||||
/**
|
||||
* 1.查询今日待结算的商家
|
||||
@ -44,18 +43,18 @@ public class BillExecute implements EveryDayExecute {
|
||||
int day = DateUtil.date().dayOfMonth();
|
||||
|
||||
//获取待结算商家列表
|
||||
List<StoreSettlementDay> storeList = storeDetailMapper.getSettlementStore(day);
|
||||
List<StoreSettlementDay> storeList = storeDetailService.getSettlementStore(day);
|
||||
|
||||
//获取当前时间
|
||||
DateTime endTime =DateUtil.date();
|
||||
DateTime endTime = DateUtil.date();
|
||||
//批量商家结算
|
||||
for (StoreSettlementDay storeSettlementDay : storeList) {
|
||||
|
||||
//生成结算单
|
||||
billService.createBill(storeSettlementDay.getStoreId(), storeSettlementDay.getSettlementDay(),endTime);
|
||||
billService.createBill(storeSettlementDay.getStoreId(), storeSettlementDay.getSettlementDay(), endTime);
|
||||
|
||||
//修改店铺结算时间
|
||||
storeDetailMapper.updateSettlementDay(storeSettlementDay.getStoreId(), endTime);
|
||||
storeDetailService.updateSettlementDay(storeSettlementDay.getStoreId(), endTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ public class OrderEveryDayTaskExecute implements EveryDayExecute {
|
||||
memberEvaluationDTO.setDescriptionScore(5);
|
||||
memberEvaluationDTO.setServiceScore(5);
|
||||
|
||||
memberEvaluationService.addMemberEvaluation(memberEvaluationDTO);
|
||||
memberEvaluationService.addMemberEvaluation(memberEvaluationDTO, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,9 @@ public class PromotionEverydayExecute implements EveryDayExecute {
|
||||
private void addSeckill() {
|
||||
Setting setting = settingService.get(SettingEnum.SECKILL_SETTING.name());
|
||||
SeckillSetting seckillSetting = new Gson().fromJson(setting.getSettingValue(), SeckillSetting.class);
|
||||
Seckill seckill = new Seckill(SeckillService.PRE_CREATION, seckillSetting.getHours(), seckillSetting.getSeckillRule());
|
||||
seckillService.savePromotions(seckill);
|
||||
for (int i = 1; i <= SeckillService.PRE_CREATION; i++) {
|
||||
Seckill seckill = new Seckill(i, seckillSetting.getHours(), seckillSetting.getSeckillRule());
|
||||
seckillService.savePromotions(seckill);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,10 @@ import cn.lili.cache.Cache;
|
||||
import cn.lili.common.utils.ThreadPoolUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.data.redis.core.DefaultTypedTuple;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -19,7 +19,7 @@ import java.util.concurrent.TimeUnit;
|
||||
* @since 2020/11/7
|
||||
**/
|
||||
@Slf4j
|
||||
public abstract class AbstractDelayQueueListen {
|
||||
public abstract class AbstractDelayQueueListen implements ApplicationRunner {
|
||||
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
@ -87,7 +87,6 @@ public abstract class AbstractDelayQueueListen {
|
||||
/**
|
||||
* 监听队列
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
ThreadPoolUtil.getPool().execute(this::startDelayQueueMachine);
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
package cn.lili.trigger.listen;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.trigger.AbstractDelayQueueListen;
|
||||
import cn.lili.trigger.enums.DelayQueueEnums;
|
||||
import cn.lili.trigger.interfaces.TimeTrigger;
|
||||
import cn.lili.trigger.model.TimeTriggerMsg;
|
||||
import cn.lili.trigger.AbstractDelayQueueListen;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
@ -31,4 +32,9 @@ public class PromotionDelayQueueListen extends AbstractDelayQueueListen {
|
||||
public String setDelayQueueName() {
|
||||
return DelayQueueEnums.PROMOTION.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
this.init();
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ spring:
|
||||
props:
|
||||
#是否打印逻辑SQL语句和实际SQL语句,建议调试时打印,在生产环境关闭
|
||||
sql:
|
||||
show: true
|
||||
show: false
|
||||
|
||||
# 忽略鉴权url
|
||||
ignored:
|
||||
@ -179,7 +179,7 @@ logging:
|
||||
config: classpath:logback-spring.xml
|
||||
# 输出级别
|
||||
level:
|
||||
cn.lili: info
|
||||
root: error
|
||||
# org.hibernate: debug
|
||||
# org.springframework: debug
|
||||
file:
|
||||
|
21
consumer/src/main/resources/redisson.yaml
Normal file
21
consumer/src/main/resources/redisson.yaml
Normal file
@ -0,0 +1,21 @@
|
||||
---
|
||||
singleServerConfig:
|
||||
idleConnectionTimeout: 10000
|
||||
connectTimeout: 10000
|
||||
timeout: 3000
|
||||
retryAttempts: 3
|
||||
retryInterval: 1500
|
||||
password: lilishop
|
||||
subscriptionsPerConnection: 5
|
||||
clientName: null
|
||||
address: "redis://127.0.0.1:6379"
|
||||
subscriptionConnectionMinimumIdleSize: 1
|
||||
subscriptionConnectionPoolSize: 50
|
||||
connectionMinimumIdleSize: 24
|
||||
connectionPoolSize: 64
|
||||
database: 0
|
||||
dnsMonitoringInterval: 5000
|
||||
threads: 16
|
||||
nettyThreads: 32
|
||||
codec: !<org.redisson.codec.MarshallingCodec> {}
|
||||
transportMode: "NIO"
|
61
consumer/src/test/java/cn/lili/buyer/test/bill/BillTest.java
Normal file
61
consumer/src/test/java/cn/lili/buyer/test/bill/BillTest.java
Normal file
@ -0,0 +1,61 @@
|
||||
package cn.lili.buyer.test.bill;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.lili.modules.store.entity.dto.StoreSettlementDay;
|
||||
import cn.lili.modules.store.service.BillService;
|
||||
import cn.lili.modules.store.service.StoreDetailService;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author paulG
|
||||
* @since 2022/1/10
|
||||
**/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@SpringBootTest
|
||||
public class BillTest {
|
||||
|
||||
|
||||
/**
|
||||
* 结算单
|
||||
*/
|
||||
@Autowired
|
||||
private BillService billService;
|
||||
|
||||
/**
|
||||
* 店铺详情
|
||||
*/
|
||||
@Autowired
|
||||
private StoreDetailService storeDetailService;
|
||||
|
||||
@Test
|
||||
void createBillTest() {
|
||||
//获取当前天数
|
||||
int day = DateUtil.date().dayOfMonth();
|
||||
|
||||
//获取待结算商家列表
|
||||
List<StoreSettlementDay> storeList = storeDetailService.getSettlementStore(day);
|
||||
|
||||
//获取当前时间
|
||||
DateTime endTime = DateUtil.date();
|
||||
//批量商家结算
|
||||
for (StoreSettlementDay storeSettlementDay : storeList) {
|
||||
|
||||
//生成结算单
|
||||
billService.createBill(storeSettlementDay.getStoreId(), storeSettlementDay.getSettlementDay(), endTime);
|
||||
|
||||
//修改店铺结算时间
|
||||
storeDetailService.updateSettlementDay(storeSettlementDay.getStoreId(), endTime);
|
||||
}
|
||||
Assertions.assertTrue(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -15,6 +15,11 @@
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-properties-migrator</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
@ -30,6 +35,12 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-quartz</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -67,6 +78,10 @@
|
||||
<artifactId>HdrHistogram</artifactId>
|
||||
<groupId>org.hdrhistogram</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -76,6 +91,12 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-redis</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
@ -91,29 +112,40 @@
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>${mybatis-plus-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter-test</artifactId>
|
||||
<version>2.2.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>${mysql-connector-version}</version>
|
||||
</dependency>
|
||||
<!-- Redis-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
<!-- Swagger API文档 -->
|
||||
<!-- https://mvnrepository.com/artifact/org.redisson/redisson-spring-boot-starter -->
|
||||
<dependency>
|
||||
<groupId>org.redisson</groupId>
|
||||
<artifactId>redisson</artifactId>
|
||||
<version>${redisson}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||
<version>${knife4j.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- Hutool工具包 -->
|
||||
<dependency>
|
||||
@ -143,6 +175,12 @@
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||
<version>${aliyun-version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- 阿里云OSS -->
|
||||
<dependency>
|
||||
@ -161,6 +199,16 @@
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>dysmsapi20170525</artifactId>
|
||||
<version>${aliyun-sdk-dysms-version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>org.jacoco.agent</artifactId>
|
||||
<groupId>org.jacoco</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!--脚本编程-->
|
||||
<dependency>
|
||||
@ -172,6 +220,16 @@
|
||||
<groupId>org.apache.rocketmq</groupId>
|
||||
<artifactId>rocketmq-spring-boot-starter</artifactId>
|
||||
<version>${rocketmq-version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<groupId>com.alibaba</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- token加密 -->
|
||||
<dependency>
|
||||
@ -195,6 +253,12 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- 解决版本提示问题 -->
|
||||
@ -220,6 +284,18 @@
|
||||
<artifactId>groovy</artifactId>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-collections4</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>antlr4-runtime</artifactId>
|
||||
<groupId>org.antlr</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
@ -227,6 +303,12 @@
|
||||
<groupId>org.apache.shardingsphere</groupId>
|
||||
<artifactId>sharding-jdbc-spring-namespace</artifactId>
|
||||
<version>${sharding-jdbc-version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!--druid-->
|
||||
<dependency>
|
||||
@ -248,6 +330,20 @@
|
||||
<groupId>com.alipay.sdk</groupId>
|
||||
<artifactId>alipay-sdk-java</artifactId>
|
||||
<version>${alipay-sdk-version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>xml-apis</artifactId>
|
||||
<groupId>xml-apis</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!--用户端类型处理-->
|
||||
@ -272,11 +368,6 @@
|
||||
<artifactId>logstash-logback-encoder</artifactId>
|
||||
<version>${logstash-logback-encoder}</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>javax.interceptor</groupId>-->
|
||||
<!-- <artifactId>javax.interceptor-api</artifactId>-->
|
||||
<!-- <version>${interceptor-api}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>de.codecentric</groupId>
|
||||
<artifactId>spring-boot-admin-starter-client</artifactId>
|
||||
@ -314,6 +405,12 @@
|
||||
<groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
|
||||
<artifactId>owasp-java-html-sanitizer</artifactId>
|
||||
<version>${owasp-java-html-sanitizer}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>guava</artifactId>
|
||||
<groupId>com.google.guava</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
@ -211,6 +211,14 @@ public interface Cache<T> {
|
||||
* @return 计数器结果
|
||||
*/
|
||||
Long incr(String key, long liveTime);
|
||||
/**
|
||||
* redis 计数器 累加
|
||||
* 注:到达liveTime之后,该次增加取消,即自动-1,而不是redis值为空
|
||||
*
|
||||
* @param key 为累计的key,同一key每次调用则值 +1
|
||||
* @return 计数器结果
|
||||
*/
|
||||
Long incr(String key);
|
||||
//-----------------------------------------------redis计数---------------------------------------------
|
||||
|
||||
/**
|
||||
|
@ -4,6 +4,9 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.redisson.Redisson;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.redisson.config.Config;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
@ -17,6 +20,7 @@ import org.springframework.cache.interceptor.KeyGenerator;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||
import org.springframework.data.redis.cache.RedisCacheManager;
|
||||
import org.springframework.data.redis.cache.RedisCacheWriter;
|
||||
@ -27,6 +31,7 @@ import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.RedisSerializationContext;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -78,6 +83,7 @@ public class RedisConfig extends CachingConfigurerSupport {
|
||||
可参考 https://blog.csdn.net/u012240455/article/details/80538540
|
||||
*/
|
||||
ParserConfig.getGlobalInstance().addAccept("cn.lili.");
|
||||
ParserConfig.getGlobalInstance().addAccept("cn.hutool.json.");
|
||||
|
||||
return cacheManager;
|
||||
}
|
||||
@ -98,6 +104,12 @@ public class RedisConfig extends CachingConfigurerSupport {
|
||||
return template;
|
||||
}
|
||||
|
||||
@Bean(destroyMethod = "shutdown")
|
||||
public RedissonClient redisson() throws IOException {
|
||||
return Redisson.create(
|
||||
Config.fromYAML(new ClassPathResource("redisson.yaml").getInputStream()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义缓存key生成策略,默认将使用该策略
|
||||
*/
|
||||
|
@ -80,7 +80,7 @@ public class RedisCache implements Cache {
|
||||
@Override
|
||||
public Boolean remove(Object key) {
|
||||
|
||||
return redisTemplate.delete(key);
|
||||
return redisTemplate.delete(key);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -207,13 +207,19 @@ public class RedisCache implements Cache {
|
||||
RedisAtomicLong entityIdCounter = new RedisAtomicLong(key, redisTemplate.getConnectionFactory());
|
||||
Long increment = entityIdCounter.getAndIncrement();
|
||||
//初始设置过期时间
|
||||
if ((null == increment || increment == 0) && liveTime > 0) {
|
||||
if (increment == 0 && liveTime > 0) {
|
||||
entityIdCounter.expire(liveTime, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
return increment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long incr(String key) {
|
||||
RedisAtomicLong entityIdCounter = new RedisAtomicLong(key, redisTemplate.getConnectionFactory());
|
||||
return entityIdCounter.getAndIncrement();
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用Sorted Set记录keyword
|
||||
* zincrby命令,对于一个Sorted Set,存在的就把分数加x(x可自行设定),不存在就创建一个分数为1的成员
|
||||
|
@ -4,6 +4,7 @@ import cn.lili.cache.limit.enums.LimitTypeEnums;
|
||||
import cn.lili.cache.limit.annotation.LimitPoint;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.utils.IpUtils;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -54,7 +55,8 @@ public class LimitInterceptor {
|
||||
key = limitPointAnnotation.key();
|
||||
break;
|
||||
default:
|
||||
key = limitPointAnnotation.key() + getIpAddress();
|
||||
key = limitPointAnnotation.key() + IpUtils
|
||||
.getIpAddress(((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
||||
}
|
||||
ImmutableList<String> keys = ImmutableList.of(StringUtils.join(limitPointAnnotation.prefix(), key));
|
||||
try {
|
||||
@ -71,32 +73,8 @@ public class LimitInterceptor {
|
||||
} catch (ServiceException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("服务器异常,请稍后再试");
|
||||
throw new ServiceException(ResultCode.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 默认unknown常量值
|
||||
*/
|
||||
private static final String UNKNOWN = "unknown";
|
||||
|
||||
/**
|
||||
* 获取ip
|
||||
* @return ip
|
||||
*/
|
||||
public String getIpAddress() {
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
String ip = request.getHeader("x-forwarded-for");
|
||||
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
ip = request.getRemoteAddr();
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
}
|
@ -4,6 +4,8 @@ import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 演示站点注解
|
||||
* <p>
|
||||
* PS 此注解需要用户登录之后才可以使用
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @since 2021/7/9 1:40 上午
|
||||
|
@ -0,0 +1,25 @@
|
||||
package cn.lili.common.aop.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 防止重复提交注解
|
||||
*
|
||||
* @author liushuai(liushuai711 @ gmail.com)
|
||||
* @version v4.0
|
||||
* @Description:
|
||||
* @since 2022/1/25 09:17
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Inherited
|
||||
public @interface PreventDuplicateSubmissions {
|
||||
|
||||
|
||||
/**
|
||||
* 过期时间
|
||||
*/
|
||||
long expire() default 3;
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package cn.lili.common.aop.interceptor;
|
||||
|
||||
/**
|
||||
* 防重复提交业务
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2022-01-25 09:20
|
||||
*/
|
||||
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.common.aop.annotation.PreventDuplicateSubmissions;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@Aspect
|
||||
@Component
|
||||
@Slf4j
|
||||
public class PreventDuplicateSubmissionsInterceptor {
|
||||
|
||||
@Autowired
|
||||
private Cache<String> cache;
|
||||
|
||||
|
||||
@Before("@annotation(preventDuplicateSubmissions)")
|
||||
public void interceptor(PreventDuplicateSubmissions preventDuplicateSubmissions) {
|
||||
|
||||
try {
|
||||
Long count = cache.incr(getParams(), preventDuplicateSubmissions.expire());
|
||||
//如果超过1或者设置的参数,则表示重复提交了
|
||||
if (count.intValue() >= preventDuplicateSubmissions.expire()) {
|
||||
throw new ServiceException(ResultCode.LIMIT_ERROR);
|
||||
}
|
||||
}
|
||||
//如果参数为空,则表示用户未登录,直接略过,不做处理
|
||||
catch (NullPointerException e) {
|
||||
return;
|
||||
} catch (ServiceException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException(ResultCode.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表单参数
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String getParams() {
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
//请求地址
|
||||
return request.getRequestURI() + UserContext.getCurrentUser().getId() + UserContext.getCurrentUser().getUsername();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -23,7 +23,7 @@ public enum PromotionTypeEnum {
|
||||
/**
|
||||
* 有促销库存的活动类型
|
||||
*/
|
||||
static PromotionTypeEnum[] haveStockPromotion = new PromotionTypeEnum[]{PINTUAN, SECKILL, KANJIA, POINTS_GOODS};
|
||||
static final PromotionTypeEnum[] haveStockPromotion = new PromotionTypeEnum[]{PINTUAN, SECKILL, KANJIA, POINTS_GOODS};
|
||||
|
||||
private final String description;
|
||||
|
||||
|
@ -115,8 +115,7 @@ public enum ResultCode {
|
||||
USER_AUTH_EXPIRED(20004, "用户已退出,请重新登录"),
|
||||
USER_AUTHORITY_ERROR(20005, "权限不足"),
|
||||
USER_CONNECT_LOGIN_ERROR(20006, "未找到登录信息"),
|
||||
USER_NAME_EXIST(20007, "该用户名已被注册"),
|
||||
USER_PHONE_EXIST(20008, "该手机号已被注册"),
|
||||
USER_EXIST(20008, "该用户名或手机号已被注册"),
|
||||
USER_PHONE_NOT_EXIST(20009, "手机号不存在"),
|
||||
USER_PASSWORD_ERROR(20010, "密码不正确"),
|
||||
USER_NOT_PHONE(20011, "非当前用户的手机号"),
|
||||
|
@ -132,4 +132,18 @@ public class GlobalControllerExceptionHandler {
|
||||
return ResultUtil.error(ResultCode.PARAMS_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* bean校验未通过异常
|
||||
*
|
||||
* @see javax.validation.Valid
|
||||
* @see org.springframework.validation.Validator
|
||||
* @see org.springframework.validation.DataBinder
|
||||
*/
|
||||
@ExceptionHandler(ConstraintViolationException.class)
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
@ResponseBody
|
||||
public ResultMessage<Object> constraintViolationExceptionHandler(HttpServletRequest request, final Exception e, HttpServletResponse response) {
|
||||
ConstraintViolationException exception = (ConstraintViolationException) e;
|
||||
return ResultUtil.error(ResultCode.PARAMS_ERROR.code(), exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,11 @@ public class AuthUser implements Serializable {
|
||||
*/
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String face;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@ -63,16 +68,18 @@ public class AuthUser implements Serializable {
|
||||
*/
|
||||
private Boolean isSuper = false;
|
||||
|
||||
public AuthUser(String username, String id, String nickName, UserEnums role) {
|
||||
public AuthUser(String username, String id, String nickName, String face, UserEnums role) {
|
||||
this.username = username;
|
||||
this.face = face;
|
||||
this.id = id;
|
||||
this.role = role;
|
||||
this.nickName = nickName;
|
||||
}
|
||||
|
||||
public AuthUser(String username, String id, UserEnums manager, String nickName, Boolean isSuper) {
|
||||
public AuthUser(String username, String id, String face, UserEnums manager, String nickName, Boolean isSuper) {
|
||||
this.username = username;
|
||||
this.id = id;
|
||||
this.face = face;
|
||||
this.role = manager;
|
||||
this.isSuper = isSuper;
|
||||
this.nickName = nickName;
|
||||
|
@ -37,6 +37,19 @@ public class UserContext {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据request获取用户信息
|
||||
*
|
||||
* @return 授权用户
|
||||
*/
|
||||
public static String getUuid() {
|
||||
if (RequestContextHolder.getRequestAttributes() != null) {
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
return request.getHeader(SecurityEnum.UUID.getValue());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据jwt获取token重的用户信息
|
||||
|
@ -10,7 +10,7 @@ public enum SecurityEnum {
|
||||
/**
|
||||
* 存在与header中的token参数头 名
|
||||
*/
|
||||
HEADER_TOKEN("accessToken"), USER_CONTEXT("userContext"), JWT_SECRET("secret");
|
||||
HEADER_TOKEN("accessToken"), USER_CONTEXT("userContext"), JWT_SECRET("secret"), UUID("uuid");
|
||||
|
||||
String value;
|
||||
|
||||
|
@ -2,9 +2,11 @@ package cn.lili.common.security.filter;
|
||||
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.http.HtmlUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.owasp.html.Sanitizers;
|
||||
import org.owasp.html.HtmlPolicyBuilder;
|
||||
import org.owasp.html.PolicyFactory;
|
||||
|
||||
import javax.servlet.ReadListener;
|
||||
import javax.servlet.ServletInputStream;
|
||||
@ -17,7 +19,6 @@ import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -30,28 +31,26 @@ import java.util.Map;
|
||||
@Slf4j
|
||||
public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
|
||||
|
||||
/**
|
||||
* xss过滤参数
|
||||
*
|
||||
* @todo 这里的参数应该更智能些,例如iv,前端的参数包含这两个字母就会放过,这是有问题的
|
||||
*/
|
||||
private static final String[] IGNORE_FIELD = {
|
||||
"logo",
|
||||
"url",
|
||||
"photo",
|
||||
"intro",
|
||||
"content",
|
||||
"name",
|
||||
"image",
|
||||
"encrypted",
|
||||
"iv",
|
||||
"mail",
|
||||
"sell",
|
||||
"privateKey",
|
||||
"wechatpay",
|
||||
//允许的标签
|
||||
private static final String[] allowedTags = {"h1", "h2", "h3", "h4", "h5", "h6",
|
||||
"span", "strong",
|
||||
"img", "video", "source", "iframe", "code",
|
||||
"blockquote", "p", "div",
|
||||
"ul", "ol", "li",
|
||||
"table", "thead", "caption", "tbody", "tr", "th", "td", "br",
|
||||
"a"
|
||||
};
|
||||
|
||||
//需要转化的标签
|
||||
private static final String[] needTransformTags = {"article", "aside", "command", "datalist", "details", "figcaption", "figure",
|
||||
"footer", "header", "hgroup", "section", "summary"};
|
||||
|
||||
//带有超链接的标签
|
||||
private static final String[] linkTags = {"img", "video", "source", "a", "iframe", "p"};
|
||||
|
||||
//带有超链接的标签
|
||||
private static final String[] allowAttributes = {"style", "src", "href", "target", "width", "height"};
|
||||
|
||||
public XssHttpServletRequestWrapper(HttpServletRequest request) {
|
||||
super(request);
|
||||
}
|
||||
@ -252,9 +251,20 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
|
||||
private String cleanXSS(String value) {
|
||||
if (value != null) {
|
||||
value = Sanitizers.FORMATTING.and(Sanitizers.LINKS).sanitize(value);
|
||||
// 自定义策略
|
||||
PolicyFactory policy = new HtmlPolicyBuilder()
|
||||
.allowStandardUrlProtocols()
|
||||
//所有允许的标签
|
||||
.allowElements(allowedTags)
|
||||
//内容标签转化为div
|
||||
.allowElements((elementName, attributes) -> "div", needTransformTags)
|
||||
.allowAttributes(allowAttributes).onElements(linkTags)
|
||||
.allowStyling()
|
||||
.toFactory();
|
||||
// basic prepackaged policies for links, tables, integers, images, styles, blocks
|
||||
value = policy.sanitize(value);
|
||||
}
|
||||
return value;
|
||||
return HtmlUtil.unescape(value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -265,12 +275,7 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
* @return 参数值
|
||||
*/
|
||||
private String filterXss(String name, String value) {
|
||||
if (CharSequenceUtil.containsAny(name.toLowerCase(Locale.ROOT), IGNORE_FIELD)) {
|
||||
// 忽略的处理,(过滤敏感字符)
|
||||
return value;
|
||||
} else {
|
||||
return cleanXSS(value);
|
||||
}
|
||||
return cleanXSS(value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class SensitiveJsonSerializer extends JsonSerializer<String>
|
||||
AuthUser authUser = UserContext.getCurrentUser();
|
||||
//默认脱敏
|
||||
if (authUser == null) {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
//如果是店铺
|
||||
|
@ -11,16 +11,16 @@ import cn.lili.common.security.token.Token;
|
||||
* @version v1.0
|
||||
* 2020-11-13 10:13
|
||||
*/
|
||||
public abstract class AbstractTokenGenerate {
|
||||
public abstract class AbstractTokenGenerate<T> {
|
||||
|
||||
/**
|
||||
* 生成token
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param user 用户名
|
||||
* @param longTerm 是否长时间有效
|
||||
* @return TOKEN对象
|
||||
*/
|
||||
public abstract Token createToken(String username, Boolean longTerm);
|
||||
public abstract Token createToken(T user, Boolean longTerm);
|
||||
|
||||
/**
|
||||
* 刷新token
|
||||
|
@ -2,6 +2,7 @@ package cn.lili.common.utils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 金额计算工具
|
||||
@ -24,27 +25,29 @@ public final class CurrencyUtil {
|
||||
/**
|
||||
* 提供精确的加法运算。
|
||||
*
|
||||
* @param v1 被加数
|
||||
* @param v2 加数
|
||||
* @return 两个参数的和
|
||||
* @return 累加之和
|
||||
*/
|
||||
public static Double add(double v1, double v2) {
|
||||
BigDecimal b1 = BigDecimal.valueOf(v1);
|
||||
BigDecimal b2 = BigDecimal.valueOf(v2);
|
||||
return b1.add(b2).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
public static Double add(double... params) {
|
||||
BigDecimal result = new BigDecimal("0");
|
||||
for (double param : params) {
|
||||
BigDecimal bigParam = BigDecimal.valueOf(param);
|
||||
result = result.add(bigParam).setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
return result.doubleValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* 提供精确的减法运算。
|
||||
*
|
||||
* @param v1 被减数
|
||||
* @param v2 减数
|
||||
* @return 两个参数的差
|
||||
* @return 第一个参数为被减数,其余数字为减数
|
||||
*/
|
||||
public static double sub(double v1, double v2) {
|
||||
BigDecimal b1 = BigDecimal.valueOf(v1);
|
||||
BigDecimal b2 = BigDecimal.valueOf(v2);
|
||||
return b1.subtract(b2).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
public static Double sub(double... params) {
|
||||
BigDecimal result = BigDecimal.valueOf(params[0]);
|
||||
params = Arrays.stream(params).skip(1).toArray();
|
||||
for (double param : params) {
|
||||
BigDecimal bigParam = BigDecimal.valueOf(param);
|
||||
result = result.subtract(bigParam).setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
return result.doubleValue();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,6 +2,7 @@ package cn.lili.common.utils;
|
||||
|
||||
import cn.hutool.core.lang.Snowflake;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ -10,18 +11,29 @@ import java.util.Date;
|
||||
*
|
||||
* @author Chopper
|
||||
*/
|
||||
@Slf4j
|
||||
public class SnowFlake {
|
||||
|
||||
/**
|
||||
* 机器id
|
||||
*/
|
||||
private static long workerId = 0L;
|
||||
/**
|
||||
* 机房id
|
||||
*/
|
||||
private static long datacenterId = 0L;
|
||||
// /**
|
||||
// * 机器id
|
||||
// */
|
||||
// private static long workerId = 0L;
|
||||
// /**
|
||||
// * 机房id
|
||||
// */
|
||||
// public static long datacenterId = 0L;
|
||||
|
||||
private static Snowflake snowflake = IdUtil.createSnowflake(workerId, datacenterId);
|
||||
private static Snowflake snowflake;
|
||||
|
||||
/**
|
||||
* 初始化配置
|
||||
*
|
||||
* @param workerId
|
||||
* @param datacenterId
|
||||
*/
|
||||
public static void initialize(long workerId, long datacenterId) {
|
||||
snowflake = IdUtil.getSnowflake(workerId, datacenterId);
|
||||
}
|
||||
|
||||
public static long getId() {
|
||||
return snowflake.nextId();
|
||||
@ -29,12 +41,14 @@ public class SnowFlake {
|
||||
|
||||
/**
|
||||
* 生成字符,带有前缀
|
||||
*
|
||||
* @param prefix
|
||||
* @return
|
||||
*/
|
||||
public static String createStr(String prefix) {
|
||||
return prefix + DateUtil.toString(new Date(), "yyyyMMdd") + SnowFlake.getId();
|
||||
}
|
||||
|
||||
public static String getIdStr() {
|
||||
return snowflake.nextId() + "";
|
||||
}
|
||||
|
@ -0,0 +1,58 @@
|
||||
package cn.lili.common.utils;
|
||||
|
||||
import cn.lili.cache.Cache;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* SnowflakeInitiator
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2022-01-14 14:04
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class SnowflakeInitiator {
|
||||
|
||||
/**
|
||||
* 缓存前缀
|
||||
*/
|
||||
private static String KEY = "{Snowflake}";
|
||||
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
|
||||
/**
|
||||
* 尝试初始化
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
Long num = cache.incr(KEY);
|
||||
long dataCenter = num / 32;
|
||||
long workedId = num % 32;
|
||||
//如果数据中心大于32,则抹除缓存,从头开始
|
||||
if (dataCenter >= 32) {
|
||||
cache.remove(KEY);
|
||||
num = cache.incr(KEY);
|
||||
dataCenter = num / 32;
|
||||
workedId = num % 32;
|
||||
}
|
||||
SnowFlake.initialize(workedId, dataCenter);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SnowFlake.initialize(0, 8);
|
||||
|
||||
System.out.println(SnowFlake.getId());
|
||||
}
|
||||
}
|
@ -31,8 +31,7 @@ public class SearchVO implements Serializable {
|
||||
if (StringUtils.isEmpty(startDate)) {
|
||||
return null;
|
||||
}
|
||||
Date date = DateUtil.toDate(startDate, DateUtil.STANDARD_DATE_FORMAT);
|
||||
return date;
|
||||
return DateUtil.toDate(startDate, DateUtil.STANDARD_DATE_FORMAT);
|
||||
}
|
||||
|
||||
public Date getConvertEndDate() {
|
||||
|
@ -331,6 +331,9 @@ public abstract class BaseElasticsearchService {
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" \"promotionMapJson\": {\n" +
|
||||
" \"type\": \"text\"\n" +
|
||||
" },\n" +
|
||||
" \"thumbnail\": {\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"fields\": {\n" +
|
||||
|
@ -63,7 +63,7 @@ public class ElasticsearchConfig extends AbstractElasticsearchConfiguration {
|
||||
restBuilder.setRequestConfigCallback(requestConfigBuilder ->
|
||||
requestConfigBuilder.setConnectTimeout(1000) //time until a connection with the server is established.
|
||||
.setSocketTimeout(12 * 1000) //time of inactivity to wait for packets[data] to receive.
|
||||
.setConnectionRequestTimeout(2 * 1000)); //time to fetch a connection from the connection pool 0 for infinite.
|
||||
.setConnectionRequestTimeout(-1)); //time to fetch a connection from the connection pool 0 for infinite.
|
||||
|
||||
client = new RestHighLevelClient(restBuilder);
|
||||
return client;
|
||||
|
@ -87,7 +87,7 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
|
||||
this.remove(queryWrapper);
|
||||
throw new NoPermissionException("未绑定用户");
|
||||
}
|
||||
return memberTokenGenerate.createToken(member.getUsername(), longTerm);
|
||||
return memberTokenGenerate.createToken(member, longTerm);
|
||||
} catch (NoPermissionException e) {
|
||||
throw e;
|
||||
}
|
||||
@ -222,7 +222,7 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
|
||||
//如果不存在会员,则进行绑定微信openid 和 unionid,并且登录
|
||||
if (member != null) {
|
||||
bindMpMember(openId, unionId, member);
|
||||
return memberTokenGenerate.createToken(member.getUsername(), true);
|
||||
return memberTokenGenerate.createToken(member, true);
|
||||
}
|
||||
|
||||
//如果没有会员,则根据手机号注册会员
|
||||
@ -230,7 +230,7 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
|
||||
memberService.save(newMember);
|
||||
newMember = memberService.findByUsername(newMember.getUsername());
|
||||
bindMpMember(openId, unionId, newMember);
|
||||
return memberTokenGenerate.createToken(newMember.getUsername(), true);
|
||||
return memberTokenGenerate.createToken(newMember, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,13 +2,14 @@ package cn.lili.modules.distribution.entity.dto;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 分销员商品查询条件
|
||||
*
|
||||
@ -37,13 +38,13 @@ public class DistributionGoodsSearchParams extends PageVO {
|
||||
|
||||
public <T> QueryWrapper<T> storeQueryWrapper() {
|
||||
QueryWrapper<T> queryWrapper = this.distributionQueryWrapper();
|
||||
queryWrapper.eq("dg.store_id", UserContext.getCurrentUser().getStoreId());
|
||||
queryWrapper.eq("dg.store_id", Objects.requireNonNull(UserContext.getCurrentUser()).getStoreId());
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
public <T> QueryWrapper<T> distributionQueryWrapper() {
|
||||
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.like(StringUtils.isNotEmpty(goodsName), "dg.goods_name", goodsName);
|
||||
queryWrapper.like(CharSequenceUtil.isNotEmpty(goodsName), "dg.goods_name", goodsName);
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
|
@ -13,21 +13,21 @@ public interface DistributionSelectedGoodsService extends IService<DistributionS
|
||||
/**
|
||||
* 分销员添加分销商品
|
||||
* @param distributionGoodsId 分销商品ID
|
||||
* @return
|
||||
* @return 是否添加成功
|
||||
*/
|
||||
boolean add(String distributionGoodsId);
|
||||
|
||||
/**
|
||||
* 分销员添加分销商品
|
||||
* 分销员删除分销商品
|
||||
* @param distributionGoodsId 分销商品ID
|
||||
* @return
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
boolean delete(String distributionGoodsId);
|
||||
|
||||
/**
|
||||
* 分销员添加分销商品
|
||||
* 分销员删除分销商品(管理员操作)
|
||||
* @param distributionGoodsId 分销商品ID
|
||||
* @return
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
boolean deleteByDistributionGoodsId(String distributionGoodsId);
|
||||
}
|
||||
|
@ -40,7 +40,6 @@ import java.util.Date;
|
||||
* @since 2020-03-126 18:04:56
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class DistributionCashServiceImpl extends ServiceImpl<DistributionCashMapper, DistributionCash> implements DistributionCashService {
|
||||
/**
|
||||
* 分销员
|
||||
|
@ -34,7 +34,6 @@ import java.util.Objects;
|
||||
* @since 2020-03-24 23:04:56
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class DistributionGoodsServiceImpl extends ServiceImpl<DistributionGoodsMapper, DistributionGoods> implements DistributionGoodsService {
|
||||
|
||||
/**
|
||||
|
@ -42,7 +42,6 @@ import java.util.List;
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class DistributionOrderServiceImpl extends ServiceImpl<DistributionOrderMapper, DistributionOrder> implements DistributionOrderService {
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* @since 2020-03-24 23:04:56
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class DistributionSelectedGoodsServiceImpl extends ServiceImpl<DistributionSelectedGoodsMapper, DistributionSelectedGoods> implements DistributionSelectedGoodsService {
|
||||
|
||||
/**
|
||||
@ -47,12 +46,6 @@ public class DistributionSelectedGoodsServiceImpl extends ServiceImpl<Distributi
|
||||
.eq(DistributionSelectedGoods::getDistributionId, distributionId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销员添加分销商品
|
||||
*
|
||||
* @param distributionGoodsId 商品ID
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteByDistributionGoodsId(String distributionGoodsId) {
|
||||
return this.remove(new LambdaQueryWrapper<DistributionSelectedGoods>()
|
||||
|
@ -38,7 +38,6 @@ import java.util.concurrent.TimeUnit;
|
||||
* @since 2020-03-14 23:04:56
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class DistributionServiceImpl extends ServiceImpl<DistributionMapper, Distribution> implements DistributionService {
|
||||
|
||||
/**
|
||||
|
@ -29,7 +29,6 @@ import java.util.List;
|
||||
* @since 2020/11/26 17:50
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class FileServiceImpl extends ServiceImpl<FileMapper, File> implements FileService {
|
||||
|
||||
@Autowired
|
||||
|
@ -103,7 +103,7 @@ public class GoodsOperationDTO implements Serializable {
|
||||
* @see cn.lili.modules.goods.entity.enums.GoodsTypeEnum
|
||||
*/
|
||||
@ApiModelProperty(value = "商品类型")
|
||||
@EnumValue(strValues = {"PHYSICAL_GOODS","VIRTUAL_GOODS","E_COUPON"},message = "商品类型参数值错误")
|
||||
@EnumValue(strValues = {"PHYSICAL_GOODS", "VIRTUAL_GOODS", "E_COUPON"}, message = "商品类型参数值错误")
|
||||
private String goodsType;
|
||||
|
||||
/**
|
||||
@ -112,6 +112,9 @@ public class GoodsOperationDTO implements Serializable {
|
||||
@ApiModelProperty(value = "商品视频")
|
||||
private String goodsVideo;
|
||||
|
||||
|
||||
|
||||
public String getGoodsName() {
|
||||
//对商品对名称做一个极限处理。这里没有用xss过滤是因为xss过滤为全局过滤,影响很大。
|
||||
// 业务中,全局代码中只有商品名称不能拥有英文逗号,是由于商品名称存在一个数据库联合查询,结果要根据逗号分组
|
||||
return goodsName.replace(",", "");
|
||||
}
|
||||
}
|
||||
|
@ -131,9 +131,9 @@ public class GoodsSearchParams extends PageVO {
|
||||
if (CharSequenceUtil.isNotEmpty(price)) {
|
||||
String[] s = price.split("_");
|
||||
if (s.length > 1) {
|
||||
queryWrapper.ge("price", s[1]);
|
||||
queryWrapper.between("price", s[0], s[1]);
|
||||
} else {
|
||||
queryWrapper.le("price", s[0]);
|
||||
queryWrapper.ge("price", s[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package cn.lili.modules.goods.event;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
/**
|
||||
* @author paulG
|
||||
* @since 2022/1/19
|
||||
**/
|
||||
@Data
|
||||
public class GeneratorEsGoodsIndexEvent extends ApplicationEvent {
|
||||
|
||||
private String goodsId;
|
||||
|
||||
public GeneratorEsGoodsIndexEvent(Object source, String goodsId) {
|
||||
super(source);
|
||||
this.goodsId = goodsId;
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package cn.lili.modules.goods.listener;
|
||||
|
||||
import cn.lili.common.properties.RocketmqCustomProperties;
|
||||
import cn.lili.modules.goods.event.GeneratorEsGoodsIndexEvent;
|
||||
import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
|
||||
import cn.lili.rocketmq.tags.GoodsTagsEnum;
|
||||
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.event.TransactionPhase;
|
||||
import org.springframework.transaction.event.TransactionalEventListener;
|
||||
|
||||
/**
|
||||
* @author paulG
|
||||
* @since 2022/1/19
|
||||
**/
|
||||
@Component
|
||||
public class GeneratorEsGoodsIndexListener {
|
||||
|
||||
/**
|
||||
* rocketMq
|
||||
*/
|
||||
@Autowired
|
||||
private RocketMQTemplate rocketMQTemplate;
|
||||
/**
|
||||
* rocketMq配置
|
||||
*/
|
||||
@Autowired
|
||||
private RocketmqCustomProperties rocketmqCustomProperties;
|
||||
|
||||
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
|
||||
public void generatorEsGoodsIndex(GeneratorEsGoodsIndexEvent esGoodsIndexEvent) {
|
||||
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GENERATOR_GOODS_INDEX.name();
|
||||
//发送mq消息
|
||||
rocketMQTemplate.asyncSend(destination, esGoodsIndexEvent.getGoodsId(), RocketmqSendCallbackBuilder.commonCallback());
|
||||
}
|
||||
|
||||
}
|
@ -4,7 +4,11 @@ package cn.lili.modules.goods.service;
|
||||
import cn.lili.modules.goods.entity.dos.Category;
|
||||
import cn.lili.modules.goods.entity.vos.CategoryVO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -13,6 +17,7 @@ import java.util.List;
|
||||
* @author pikachu
|
||||
* @since 2020-03-02 16:44:56
|
||||
*/
|
||||
@CacheConfig(cacheNames = "{category}")
|
||||
public interface CategoryService extends IService<Category> {
|
||||
|
||||
|
||||
@ -25,6 +30,15 @@ public interface CategoryService extends IService<Category> {
|
||||
*/
|
||||
List<Category> dbList(String parentId);
|
||||
|
||||
/**
|
||||
* 获取分类
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(key = "#id")
|
||||
Category getCategoryById(String id);
|
||||
|
||||
/**
|
||||
* 根据分类id集合获取所有分类根据层级排序
|
||||
*
|
||||
@ -86,6 +100,7 @@ public interface CategoryService extends IService<Category> {
|
||||
* @param category 商品分类信息
|
||||
* @return 修改结果
|
||||
*/
|
||||
@CacheEvict(key = "#category.id")
|
||||
void updateCategory(Category category);
|
||||
|
||||
/**
|
||||
|
@ -195,14 +195,6 @@ public interface GoodsSkuService extends IService<GoodsSku> {
|
||||
*/
|
||||
void updateGoodsSkuCommentNum(String skuId);
|
||||
|
||||
/**
|
||||
* 更新商品sku促销价格
|
||||
*
|
||||
* @param skuId skuId
|
||||
* @param promotionPrice 促销价格
|
||||
*/
|
||||
void updateGoodsSkuPromotion(String skuId, Double promotionPrice);
|
||||
|
||||
/**
|
||||
* 根据商品id获取全部skuId的集合
|
||||
*
|
||||
|
@ -34,7 +34,6 @@ import java.util.stream.Collectors;
|
||||
* @since 2020-02-18 16:18:56
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class BrandServiceImpl extends ServiceImpl<BrandMapper, Brand> implements BrandService {
|
||||
|
||||
/**
|
||||
|
@ -20,7 +20,6 @@ import java.util.List;
|
||||
* @since 2020-02-18 16:18:56
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class CategoryBrandServiceImpl extends ServiceImpl<CategoryBrandMapper, CategoryBrand> implements CategoryBrandService {
|
||||
|
||||
@Override
|
||||
|
@ -37,7 +37,6 @@ import java.util.stream.Collectors;
|
||||
* 2020-03-02 16:45:03
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class CategoryParameterGroupServiceImpl extends ServiceImpl<CategoryParameterGroupMapper, CategoryParameterGroup> implements CategoryParameterGroupService {
|
||||
/**
|
||||
* 商品参数
|
||||
|
@ -36,7 +36,6 @@ import java.util.stream.Collectors;
|
||||
* @since 2020-02-23 15:18:56
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements CategoryService {
|
||||
|
||||
private static final String DELETE_FLAG_COLUMN = "delete_flag";
|
||||
@ -60,6 +59,11 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
|
||||
return this.list(new LambdaQueryWrapper<Category>().eq(Category::getParentId, parentId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category getCategoryById(String id) {
|
||||
return this.getById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据分类id集合获取所有分类根据层级排序
|
||||
*
|
||||
|
@ -18,7 +18,6 @@ import java.util.List;
|
||||
* @since 2020-02-23 15:18:56
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class CategorySpecificationServiceImpl extends ServiceImpl<CategorySpecificationMapper, CategorySpecification> implements CategorySpecificationService {
|
||||
|
||||
@Override
|
||||
|
@ -33,7 +33,6 @@ import java.util.*;
|
||||
* @since 2020/12/19
|
||||
**/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class DraftGoodsServiceImpl extends ServiceImpl<DraftGoodsMapper, DraftGoods> implements DraftGoodsService {
|
||||
/**
|
||||
* 分类
|
||||
|
@ -27,7 +27,6 @@ import java.util.List;
|
||||
* 2020-02-23 15:18:56
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class GoodsGalleryServiceImpl extends ServiceImpl<GoodsGalleryMapper, GoodsGallery> implements GoodsGalleryService {
|
||||
/**
|
||||
* 设置
|
||||
|
@ -54,10 +54,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 商品业务层实现
|
||||
@ -66,7 +63,6 @@ import java.util.Objects;
|
||||
* @since 2020-02-23 15:18:56
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements GoodsService {
|
||||
|
||||
|
||||
@ -119,7 +115,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
|
||||
@Override
|
||||
public List<Goods> getByBrandIds(List<String> brandIds) {
|
||||
LambdaQueryWrapper<Goods> lambdaQueryWrapper = new LambdaQueryWrapper<Goods>();
|
||||
LambdaQueryWrapper<Goods> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.in(Goods::getBrandId, brandIds);
|
||||
return list(lambdaQueryWrapper);
|
||||
}
|
||||
@ -197,6 +193,9 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
if (goodsOperationDTO.getGoodsGalleryList() != null && !goodsOperationDTO.getGoodsGalleryList().isEmpty()) {
|
||||
this.goodsGalleryService.add(goodsOperationDTO.getGoodsGalleryList(), goods.getId());
|
||||
}
|
||||
if (GoodsAuthEnum.TOBEAUDITED.name().equals(goods.getAuthFlag())) {
|
||||
this.deleteEsGoods(Collections.singletonList(goodsId));
|
||||
}
|
||||
cache.remove(CachePrefix.GOODS.getPrefix() + goodsId);
|
||||
}
|
||||
|
||||
@ -306,11 +305,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
}
|
||||
|
||||
if (GoodsStatusEnum.DOWN.equals(goodsStatusEnum)) {
|
||||
|
||||
//商品删除消息
|
||||
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GOODS_DELETE.name();
|
||||
//发送mq消息
|
||||
rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(goodsIds), RocketmqSendCallbackBuilder.commonCallback());
|
||||
this.deleteEsGoods(goodsIds);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -340,6 +335,9 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
for (Goods goods : goodsList) {
|
||||
goodsSkuService.updateGoodsSkuStatus(goods);
|
||||
}
|
||||
if (GoodsStatusEnum.DOWN.equals(goodsStatusEnum)) {
|
||||
this.deleteEsGoods(goodsIds);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -361,10 +359,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
goodsSkuService.updateGoodsSkuStatus(goods);
|
||||
}
|
||||
|
||||
//商品删除消息
|
||||
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GOODS_DELETE.name();
|
||||
//发送mq消息
|
||||
rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(goodsIds), RocketmqSendCallbackBuilder.commonCallback());
|
||||
this.deleteEsGoods(goodsIds);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -388,6 +383,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateStock(String goodsId, Integer quantity) {
|
||||
LambdaUpdateWrapper<Goods> lambdaUpdateWrapper = Wrappers.lambdaUpdate();
|
||||
lambdaUpdateWrapper.set(Goods::getQuantity, quantity);
|
||||
@ -447,6 +443,19 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
.eq(Goods::getMarketEnable, GoodsStatusEnum.UPPER.name()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发送删除es索引的信息
|
||||
*
|
||||
* @param goodsIds 商品id
|
||||
*/
|
||||
private void deleteEsGoods(List<String> goodsIds) {
|
||||
//商品删除消息
|
||||
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GOODS_DELETE.name();
|
||||
//发送mq消息
|
||||
rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(goodsIds), RocketmqSendCallbackBuilder.commonCallback());
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加商品默认图片
|
||||
*
|
||||
@ -522,8 +531,8 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
/**
|
||||
* 判断商品是否存在
|
||||
*
|
||||
* @param goodsId
|
||||
* @return
|
||||
* @param goodsId 商品id
|
||||
* @return 商品信息
|
||||
*/
|
||||
private Goods checkExist(String goodsId) {
|
||||
Goods goods = getById(goodsId);
|
||||
@ -579,20 +588,6 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取UpdateWrapper(检查用户越权)
|
||||
*
|
||||
* @return updateWrapper
|
||||
*/
|
||||
private LambdaUpdateWrapper<Goods> getUpdateWrapperByManagerAuthority() {
|
||||
LambdaUpdateWrapper<Goods> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
AuthUser authUser = this.checkStoreAuthority();
|
||||
if (authUser != null) {
|
||||
updateWrapper.eq(Goods::getStoreId, authUser.getStoreId());
|
||||
}
|
||||
return updateWrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取QueryWrapper(检查用户越权)
|
||||
*
|
||||
|
@ -3,9 +3,7 @@ package cn.lili.modules.goods.serviceimpl;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.cache.Cache;
|
||||
@ -24,16 +22,20 @@ import cn.lili.modules.goods.entity.vos.GoodsSkuSpecVO;
|
||||
import cn.lili.modules.goods.entity.vos.GoodsSkuVO;
|
||||
import cn.lili.modules.goods.entity.vos.GoodsVO;
|
||||
import cn.lili.modules.goods.entity.vos.SpecValueVO;
|
||||
import cn.lili.modules.goods.event.GeneratorEsGoodsIndexEvent;
|
||||
import cn.lili.modules.goods.mapper.GoodsSkuMapper;
|
||||
import cn.lili.modules.goods.service.CategoryService;
|
||||
import cn.lili.modules.goods.service.GoodsGalleryService;
|
||||
import cn.lili.modules.goods.service.GoodsService;
|
||||
import cn.lili.modules.goods.service.GoodsSkuService;
|
||||
import cn.lili.modules.member.entity.dos.FootPrint;
|
||||
import cn.lili.modules.member.entity.dos.MemberEvaluation;
|
||||
import cn.lili.modules.member.entity.dto.EvaluationQueryParams;
|
||||
import cn.lili.modules.member.entity.enums.EvaluationGradeEnum;
|
||||
import cn.lili.modules.member.service.MemberEvaluationService;
|
||||
import cn.lili.modules.promotion.entity.dos.PromotionGoods;
|
||||
import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams;
|
||||
import cn.lili.modules.promotion.entity.enums.CouponGetEnum;
|
||||
import cn.lili.modules.promotion.service.PromotionGoodsService;
|
||||
import cn.lili.modules.search.entity.dos.EsGoodsAttribute;
|
||||
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
||||
import cn.lili.modules.search.service.EsGoodsIndexService;
|
||||
@ -47,6 +49,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@ -60,7 +63,6 @@ import java.util.stream.Collectors;
|
||||
* @since 2020-02-23 15:18:56
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> implements GoodsSkuService {
|
||||
|
||||
/**
|
||||
@ -104,6 +106,12 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
@Autowired
|
||||
private EsGoodsIndexService goodsIndexService;
|
||||
|
||||
@Autowired
|
||||
private PromotionGoodsService promotionGoodsService;
|
||||
|
||||
@Autowired
|
||||
private ApplicationEventPublisher applicationEventPublisher;
|
||||
|
||||
@Override
|
||||
public void add(List<Map<String, Object>> skuList, Goods goods) {
|
||||
// 检查是否需要生成索引
|
||||
@ -117,10 +125,13 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
}
|
||||
|
||||
this.updateStock(newSkuList);
|
||||
generateEs(goods);
|
||||
if (!newSkuList.isEmpty()) {
|
||||
generateEs(goods);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(List<Map<String, Object>> skuList, Goods goods, Boolean regeneratorSkuFlag) {
|
||||
// 是否存在规格
|
||||
if (skuList == null || skuList.isEmpty()) {
|
||||
@ -134,9 +145,9 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
//删除旧索引
|
||||
for (GoodsSkuVO goodsSkuVO : goodsListByGoodsId) {
|
||||
oldSkuIds.add(goodsSkuVO.getId());
|
||||
goodsIndexService.deleteIndexById(goodsSkuVO.getId());
|
||||
cache.remove(GoodsSkuService.getCacheKeys(goodsSkuVO.getId()));
|
||||
}
|
||||
goodsIndexService.deleteIndexByIds(oldSkuIds);
|
||||
this.removeByIds(oldSkuIds);
|
||||
//删除sku相册
|
||||
goodsGalleryService.removeByIds(oldSkuIds);
|
||||
@ -164,7 +175,9 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
this.updateBatchById(newSkuList);
|
||||
}
|
||||
this.updateStock(newSkuList);
|
||||
generateEs(goods);
|
||||
if (GoodsAuthEnum.PASS.name().equals(goods.getAuthFlag()) && !newSkuList.isEmpty()) {
|
||||
generateEs(goods);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -241,11 +254,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
//获取当前商品的索引信息
|
||||
EsGoodsIndex goodsIndex = goodsIndexService.findById(skuId);
|
||||
if (goodsIndex == null) {
|
||||
goodsIndex = goodsIndexService.getTempEsGoodsIndex(goodsSku, goodsVO.getGoodsParamsDTOList());
|
||||
|
||||
//发送mq消息
|
||||
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.RESET_GOODS_INDEX.name();
|
||||
rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(Collections.singletonList(goodsIndex)), RocketmqSendCallbackBuilder.commonCallback());
|
||||
goodsIndex = goodsIndexService.getResetEsGoodsIndex(goodsSku, goodsVO.getGoodsParamsDTOList());
|
||||
}
|
||||
|
||||
//商品规格
|
||||
@ -253,9 +262,6 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
|
||||
Map<String, Object> promotionMap = goodsIndex.getPromotionMap();
|
||||
//设置当前商品的促销价格
|
||||
if (promotionMap != null && !promotionMap.isEmpty() && goodsIndex.getPromotionPrice() != null) {
|
||||
goodsSkuDetail.setPromotionPrice(goodsIndex.getPromotionPrice());
|
||||
}
|
||||
if (promotionMap != null && !promotionMap.isEmpty()) {
|
||||
promotionMap = promotionMap.entrySet().stream().parallel().filter(i -> {
|
||||
JSONObject jsonObject = JSONUtil.parseObj(i.getValue());
|
||||
@ -265,11 +271,18 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
(jsonObject.get("endTime") == null || jsonObject.get("endTime", Date.class).getTime() >= System.currentTimeMillis());
|
||||
}).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
|
||||
boolean containsPromotion = promotionMap.keySet().stream().anyMatch(i ->
|
||||
i.contains(PromotionTypeEnum.SECKILL.name()) || i.contains(PromotionTypeEnum.PINTUAN.name()));
|
||||
if (containsPromotion && goodsIndex.getPromotionPrice() != null) {
|
||||
goodsSkuDetail.setPromotionFlag(true);
|
||||
goodsSkuDetail.setPromotionPrice(goodsIndex.getPromotionPrice());
|
||||
Optional<Map.Entry<String, Object>> containsPromotion = promotionMap.entrySet().stream().filter(i ->
|
||||
i.getKey().contains(PromotionTypeEnum.SECKILL.name()) || i.getKey().contains(PromotionTypeEnum.PINTUAN.name())).findFirst();
|
||||
if (containsPromotion.isPresent()) {
|
||||
JSONObject jsonObject = JSONUtil.parseObj(containsPromotion.get().getValue());
|
||||
PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams();
|
||||
searchParams.setSkuId(skuId);
|
||||
searchParams.setPromotionId(jsonObject.get("id").toString());
|
||||
PromotionGoods promotionsGoods = promotionGoodsService.getPromotionsGoods(searchParams);
|
||||
if (promotionsGoods != null && promotionsGoods.getPrice() != null) {
|
||||
goodsSkuDetail.setPromotionFlag(true);
|
||||
goodsSkuDetail.setPromotionPrice(promotionsGoods.getPrice());
|
||||
}
|
||||
} else {
|
||||
goodsSkuDetail.setPromotionFlag(false);
|
||||
goodsSkuDetail.setPromotionPrice(null);
|
||||
@ -319,7 +332,9 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
cache.remove(GoodsSkuService.getCacheKeys(sku.getId()));
|
||||
cache.put(GoodsSkuService.getCacheKeys(sku.getId()), sku);
|
||||
}
|
||||
generateEs(goods);
|
||||
if (!goodsSkus.isEmpty()) {
|
||||
generateEs(goods);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -487,12 +502,11 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
//获取商品信息
|
||||
GoodsSku goodsSku = this.getGoodsSkuByIdFromCache(skuId);
|
||||
|
||||
LambdaQueryWrapper<MemberEvaluation> goodEvaluationQueryWrapper = new LambdaQueryWrapper<>();
|
||||
goodEvaluationQueryWrapper.eq(MemberEvaluation::getSkuId, goodsSku.getId());
|
||||
goodEvaluationQueryWrapper.eq(MemberEvaluation::getGrade, EvaluationGradeEnum.GOOD.name());
|
||||
|
||||
EvaluationQueryParams queryParams = new EvaluationQueryParams();
|
||||
queryParams.setGrade(EvaluationGradeEnum.GOOD.name());
|
||||
queryParams.setSkuId(goodsSku.getId());
|
||||
//好评数量
|
||||
long highPraiseNum = memberEvaluationService.count(goodEvaluationQueryWrapper);
|
||||
long highPraiseNum = memberEvaluationService.getEvaluationCount(queryParams);
|
||||
|
||||
//更新商品评价数量
|
||||
goodsSku.setCommentNum(goodsSku.getCommentNum() != null ? goodsSku.getCommentNum() + 1 : 1);
|
||||
@ -516,22 +530,6 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
goodsService.updateGoodsCommentNum(goodsSku.getGoodsId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品sku促销价格
|
||||
*
|
||||
* @param skuId skuId
|
||||
* @param promotionPrice 促销价格
|
||||
*/
|
||||
@Override
|
||||
public void updateGoodsSkuPromotion(String skuId, Double promotionPrice) {
|
||||
LambdaUpdateWrapper<GoodsSku> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(GoodsSku::getId, skuId);
|
||||
updateWrapper.set(GoodsSku::getPromotionPrice, promotionPrice);
|
||||
updateWrapper.set(GoodsSku::getPromotionFlag, true);
|
||||
this.update(updateWrapper);
|
||||
cache.remove(GoodsSkuService.getCacheKeys(skuId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商品id获取全部skuId的集合
|
||||
*
|
||||
@ -554,18 +552,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
if (!GoodsStatusEnum.UPPER.name().equals(goods.getMarketEnable()) || !GoodsAuthEnum.PASS.name().equals(goods.getAuthFlag())) {
|
||||
return;
|
||||
}
|
||||
ThreadUtil.execAsync(() -> {
|
||||
try {
|
||||
// 延时执行,防止商品未保存完成就去生成商品索引导致生成索引时找不到商品问题
|
||||
Thread.sleep(2000);
|
||||
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GENERATOR_GOODS_INDEX.name();
|
||||
//发送mq消息
|
||||
rocketMQTemplate.asyncSend(destination, goods.getId(), RocketmqSendCallbackBuilder.commonCallback());
|
||||
} catch (InterruptedException e) {
|
||||
log.error("发送商品索引信息失败!", e);
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
});
|
||||
applicationEventPublisher.publishEvent(new GeneratorEsGoodsIndexEvent("生成商品索引事件", goods.getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -591,7 +578,8 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
* @param skuList sku列表
|
||||
* @param goods 商品信息
|
||||
*/
|
||||
private List<GoodsSku> addGoodsSku(List<Map<String, Object>> skuList, Goods goods) {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
List<GoodsSku> addGoodsSku(List<Map<String, Object>> skuList, Goods goods) {
|
||||
List<GoodsSku> skus = new ArrayList<>();
|
||||
for (Map<String, Object> skuVO : skuList) {
|
||||
Map<String, Object> resultMap = this.add(skuVO, goods);
|
||||
@ -700,7 +688,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
}
|
||||
//设置规格商品缩略图
|
||||
//如果规格没有图片,则用商品图片复盖。有则增加规格图片,放在商品图片集合之前
|
||||
if (spec.getValue() != null && StrUtil.isNotEmpty(spec.getValue().toString())) {
|
||||
if (CharSequenceUtil.isNotEmpty(spec.getValue().toString())) {
|
||||
thumbnail = goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getThumbnail();
|
||||
small = goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getSmall();
|
||||
}
|
||||
|
@ -14,6 +14,5 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* @since 2020/10/15
|
||||
**/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class GoodsWordsServiceImpl extends ServiceImpl<GoodsWordsMapper, GoodsWords> implements GoodsWordsService {
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ import java.util.List;
|
||||
* @since 2020-03-07 16:18:56
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class StoreGoodsLabelServiceImpl extends ServiceImpl<StoreGoodsLabelMapper, StoreGoodsLabel> implements StoreGoodsLabelService {
|
||||
|
||||
/**
|
||||
|
@ -1,12 +1,11 @@
|
||||
package cn.lili.modules.member.entity.dto;
|
||||
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 评价查询条件
|
||||
@ -14,13 +13,19 @@ import lombok.Data;
|
||||
* @author Bulbasaur
|
||||
* @since 2020/11/30 14:52
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class EvaluationQueryParams extends PageVO {
|
||||
|
||||
@ApiModelProperty(value = "ID")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "买家ID")
|
||||
private String memberId;
|
||||
|
||||
@ApiModelProperty(value = "skuID")
|
||||
private String skuId;
|
||||
|
||||
@ApiModelProperty(value = "会员名称")
|
||||
private String memberName;
|
||||
|
||||
@ -51,40 +56,42 @@ public class EvaluationQueryParams extends PageVO {
|
||||
@ApiModelProperty(value = "状态")
|
||||
private String status;
|
||||
|
||||
public EvaluationQueryParams() {
|
||||
|
||||
}
|
||||
|
||||
public <T> QueryWrapper<T> queryWrapper() {
|
||||
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
||||
if (StringUtils.isNotEmpty(startTime) && StringUtils.isNotEmpty(endTime)) {
|
||||
if (CharSequenceUtil.isNotEmpty(id)) {
|
||||
queryWrapper.eq("id", id);
|
||||
}
|
||||
if (CharSequenceUtil.isNotEmpty(startTime) && CharSequenceUtil.isNotEmpty(endTime)) {
|
||||
queryWrapper.between("create_time", startTime, endTime);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(grade)) {
|
||||
if (CharSequenceUtil.isNotEmpty(grade)) {
|
||||
queryWrapper.eq("grade", grade);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(goodsName)) {
|
||||
if (CharSequenceUtil.isNotEmpty(goodsName)) {
|
||||
queryWrapper.like("goods_name", goodsName);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(storeName)) {
|
||||
if (CharSequenceUtil.isNotEmpty(storeName)) {
|
||||
queryWrapper.like("store_name", storeName);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(memberName)) {
|
||||
if (CharSequenceUtil.isNotEmpty(memberName)) {
|
||||
queryWrapper.like("member_name", memberName);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(goodsId)) {
|
||||
if (CharSequenceUtil.isNotEmpty(goodsId)) {
|
||||
queryWrapper.eq("goods_id", goodsId);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(storeId)) {
|
||||
if (CharSequenceUtil.isNotEmpty(skuId)) {
|
||||
queryWrapper.eq("sku_id", skuId);
|
||||
}
|
||||
if (CharSequenceUtil.isNotEmpty(storeId)) {
|
||||
queryWrapper.eq("store_id", storeId);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(memberId)) {
|
||||
if (CharSequenceUtil.isNotEmpty(memberId)) {
|
||||
queryWrapper.eq("member_id", memberId);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(haveImage)) {
|
||||
if (CharSequenceUtil.isNotEmpty(haveImage)) {
|
||||
queryWrapper.eq("have_image", haveImage);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(status)) {
|
||||
if (CharSequenceUtil.isNotEmpty(status)) {
|
||||
queryWrapper.eq("status", status);
|
||||
}
|
||||
queryWrapper.eq("delete_flag", false);
|
||||
|
@ -34,8 +34,9 @@ public interface FootprintMapper extends BaseMapper<FootPrint> {
|
||||
*
|
||||
* @param memberId 会员ID
|
||||
*/
|
||||
@Delete("DELETE FROM li_foot_print WHERE (SELECT COUNT(b.id) FROM ( SELECT * FROM li_foot_print WHERE member_id = #{memberId} ) b) >100 " +
|
||||
" AND id =(SELECT a.id FROM ( SELECT * FROM li_foot_print WHERE member_id = #{memberId} ORDER BY create_time ASC LIMIT 1 ) AS a)")
|
||||
@Delete("DELETE FROM li_foot_print l1 WHERE l1.id IN (" +
|
||||
"SELECT l2.id FROM (" +
|
||||
"SELECT l3.id FROM li_foot_print l3 WHERE l3.member_id=${memberId} ORDER BY id DESC LIMIT 100,100) l2)")
|
||||
void deleteLastFootPrint(String memberId);
|
||||
|
||||
}
|
@ -41,9 +41,10 @@ public interface MemberEvaluationService extends IService<MemberEvaluation> {
|
||||
* 4.发送用户评价消息修改商品的评价数量以及好评率
|
||||
*
|
||||
* @param memberEvaluationDTO 评论
|
||||
* @param isSelf 是否自己操作(true:买家操作/false 系统操作)
|
||||
* @return 操作状态
|
||||
*/
|
||||
MemberEvaluationDTO addMemberEvaluation(MemberEvaluationDTO memberEvaluationDTO);
|
||||
MemberEvaluationDTO addMemberEvaluation(MemberEvaluationDTO memberEvaluationDTO, Boolean isSelf);
|
||||
|
||||
/**
|
||||
* 根据ID查询会员评价
|
||||
@ -88,5 +89,26 @@ public interface MemberEvaluationService extends IService<MemberEvaluation> {
|
||||
*/
|
||||
EvaluationNumberVO getEvaluationNumber(String goodsId);
|
||||
|
||||
/**
|
||||
* 获取今天新增的评价数量
|
||||
*
|
||||
* @return 今日评价数量
|
||||
*/
|
||||
long todayMemberEvaluation();
|
||||
|
||||
/**
|
||||
* 获取等待回复评价数量
|
||||
*
|
||||
* @return 等待回复评价数量
|
||||
*/
|
||||
long getWaitReplyNum();
|
||||
|
||||
/**
|
||||
* 统计商品评价数量
|
||||
*
|
||||
* @param evaluationQueryParams 查询条件
|
||||
* @return 商品评价数量
|
||||
*/
|
||||
long getEvaluationCount(EvaluationQueryParams evaluationQueryParams);
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user