Skip to content

Commit

Permalink
采用阿里代码规约,对代码进行优化
Browse files Browse the repository at this point in the history
  • Loading branch information
lifenlong committed Jul 9, 2021
1 parent 3e73257 commit 18d2379
Show file tree
Hide file tree
Showing 32 changed files with 262 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,16 @@ public class MemberCollectionController {
@Autowired
private StoreCollectionService storeCollectionService;

/**
* 商品收藏关键字
*/
private String goods="GOODS";

@ApiOperation(value = "查询会员收藏列表")
@ApiImplicitParam(name = "type", value = "类型", dataType = "String", paramType = "path", example = "GOODS:商品,STORE:店铺")
@GetMapping("/{type}")
public ResultMessage<Object> goodsList(@PathVariable String type, PageVO page) {
if (type.equals("GOODS")) {
if (goods.equals(type)) {
return ResultUtil.data(goodsCollectionService.goodsCollection(page));
}
return ResultUtil.data(storeCollectionService.storeCollection(page));
Expand All @@ -54,7 +59,7 @@ public ResultMessage<Object> goodsList(@PathVariable String type, PageVO page) {
@PostMapping("/add/{type}/{id}")
public ResultMessage<Object> addGoodsCollection(@PathVariable String type,
@NotNull(message = "值不能为空") @PathVariable String id) {
if (type.equals("GOODS")) {
if (goods.equals(type)) {
return ResultUtil.data(goodsCollectionService.addGoodsCollection(id));
}
return ResultUtil.data(storeCollectionService.addStoreCollection(id));
Expand All @@ -69,7 +74,7 @@ public ResultMessage<Object> addGoodsCollection(@PathVariable String type,
@DeleteMapping(value = "/delete/{type}/{id}")
public ResultMessage<Object> deleteGoodsCollection(@PathVariable String type,
@NotNull(message = "值不能为空") @PathVariable String id) {
if (type.equals("GOODS")) {
if (goods.equals(type)) {
return ResultUtil.data(goodsCollectionService.deleteGoodsCollection(id));
}
return ResultUtil.data(storeCollectionService.deleteStoreCollection(id));
Expand All @@ -83,7 +88,7 @@ public ResultMessage<Object> deleteGoodsCollection(@PathVariable String type,
@GetMapping(value = "/isCollection/{type}/{id}")
public ResultMessage<Boolean> isCollection(@PathVariable String type,
@NotNull(message = "值不能为空") @PathVariable String id) {
if (type.equals("GOODS")) {
if (goods.equals(type)) {
return ResultUtil.data(this.goodsCollectionService.isCollection(id));
}
return ResultUtil.data(this.storeCollectionService.isCollection(id));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class MiniProgramBuyerController {
public ConnectService connectService;
@Autowired
public WechatMpCodeUtil wechatMpCodeUtil;
@SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
@Autowired
public WechatMPMessageService wechatMPMessageService;
@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
* @date 2020-07-03 11:20
*/
@Service
public class GoodsSkuExecute implements GoodsCommentCompleteEvent {
public class GoodsSkuExecute implements GoodsCommentCompleteEvent {

//商品
/**
* 商品
*/
@Autowired
private GoodsSkuService goodsSkuService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,25 @@
@Service
public class MemberExperienceExecute implements MemberRegisterEvent, GoodsCommentCompleteEvent, OrderStatusChangeEvent {

//配置
/**
* 配置
*/
@Autowired
private SettingService settingService;
//会员
/**
* 会员
*/
@Autowired
private MemberService memberService;
//订单
/**
* 订单
*/
@Autowired
private OrderService orderService;

/**
* 会员注册赠送经验值
*
* @param member 会员
*/
@Override
Expand All @@ -53,6 +60,7 @@ public void memberRegister(Member member) {

/**
* 商品评价赠送经验值
*
* @param memberEvaluation 会员评价
*/
@Override
Expand All @@ -65,27 +73,29 @@ public void goodsComment(MemberEvaluation memberEvaluation) {

/**
* 完成订单赠送经验值
*
* @param orderMessage 订单消息
*/
@Override
public void orderChange(OrderMessage orderMessage) {
if(orderMessage.getNewStatus().equals(OrderStatusEnum.COMPLETED)){
if (orderMessage.getNewStatus().equals(OrderStatusEnum.COMPLETED)) {
//获取经验值设置
ExperienceSetting experienceSetting = getExperienceSetting();
//获取订单信息
Order order = orderService.getBySn(orderMessage.getOrderSn());
//计算赠送经验值数量
Double point= CurrencyUtil.mul(experienceSetting.getMoney(),order.getFlowPrice(),0);
Double point = CurrencyUtil.mul(experienceSetting.getMoney(), order.getFlowPrice(), 0);
//赠送会员经验值
memberService.updateMemberExperience(point.longValue(), true, order.getMemberId(), "会员下单,赠送经验值" + point + "分");
}
}

/**
* 获取经验值设置
*
* @return 经验值设置
*/
private ExperienceSetting getExperienceSetting(){
private ExperienceSetting getExperienceSetting() {
Setting setting = settingService.get(SettingEnum.EXPERIENCE_SETTING.name());
return new Gson().fromJson(setting.getSettingValue(), ExperienceSetting.class);
}
Expand Down
35 changes: 23 additions & 12 deletions consumer/src/main/java/cn/lili/event/impl/MemberPointExecute.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,57 +33,66 @@
@Service
public class MemberPointExecute implements MemberRegisterEvent, GoodsCommentCompleteEvent, OrderStatusChangeEvent, AfterSaleStatusChangeEvent {

//配置
/**
* 配置
*/
@Autowired
private SettingService settingService;
//会员
/**
* 会员
*/
@Autowired
private MemberService memberService;
//订单
/**
* 订单
*/
@Autowired
private OrderService orderService;

/**
* 会员注册赠送积分
*
* @param member 会员
*/
@Override
public void memberRegister(Member member) {
//获取积分设置
PointSetting pointSetting=getPointSetting();
PointSetting pointSetting = getPointSetting();
//赠送会员积分
memberService.updateMemberPoint(Long.valueOf(pointSetting.getRegister().longValue()), true, member.getId(), "会员注册,赠送积分" + pointSetting.getRegister() + "分");
}

/**
* 会员评价赠送积分
*
* @param memberEvaluation 会员评价
*/
@Override
public void goodsComment(MemberEvaluation memberEvaluation) {
//获取积分设置
PointSetting pointSetting=getPointSetting();
PointSetting pointSetting = getPointSetting();
//赠送会员积分
memberService.updateMemberPoint(Long.valueOf(pointSetting.getComment().longValue()), true, memberEvaluation.getMemberId(), "会员评价,赠送积分" + pointSetting.getComment() + "分");
}

/**
* 非积分订单订单完成后赠送积分
*
* @param orderMessage 订单消息
*/
@Override
public void orderChange(OrderMessage orderMessage) {

if(orderMessage.getNewStatus().equals(OrderStatusEnum.COMPLETED)){
if (orderMessage.getNewStatus().equals(OrderStatusEnum.COMPLETED)) {
//根据订单编号获取订单数据,如果为积分订单则跳回
Order order = orderService.getBySn(orderMessage.getOrderSn());
if(order.getOrderPromotionType().equals(OrderPromotionTypeEnum.POINT.name())){
if (order.getOrderPromotionType().equals(OrderPromotionTypeEnum.POINT.name())) {
return;
}
//获取积分设置
PointSetting pointSetting=getPointSetting();
PointSetting pointSetting = getPointSetting();
//计算赠送积分数量
Double point=CurrencyUtil.mul(pointSetting.getMoney(),order.getFlowPrice(),0);
Double point = CurrencyUtil.mul(pointSetting.getMoney(), order.getFlowPrice(), 0);
//赠送会员积分
memberService.updateMemberPoint(point.longValue(), true, order.getMemberId(), "会员下单,赠送积分" + point + "分");

Expand All @@ -92,15 +101,16 @@ public void orderChange(OrderMessage orderMessage) {

/**
* 提交售后后扣除积分
*
* @param afterSale 售后
*/
@Override
public void afterSaleStatusChange(AfterSale afterSale) {
if (afterSale.getServiceStatus().equals(AfterSaleStatusEnum.COMPLETE.name())) {
//获取积分设置
PointSetting pointSetting=getPointSetting();
PointSetting pointSetting = getPointSetting();
//计算扣除积分数量
Double point=CurrencyUtil.mul(pointSetting.getMoney(), afterSale.getActualRefundPrice(),0);
Double point = CurrencyUtil.mul(pointSetting.getMoney(), afterSale.getActualRefundPrice(), 0);
//扣除会员积分
memberService.updateMemberPoint(point.longValue(), false, afterSale.getMemberId(), "会员退款,扣除积分" + point + "分");

Expand All @@ -109,9 +119,10 @@ public void afterSaleStatusChange(AfterSale afterSale) {

/**
* 获取积分设置
*
* @return 积分设置
*/
private PointSetting getPointSetting(){
private PointSetting getPointSetting() {
Setting setting = settingService.get(SettingEnum.POINT_SETTING.name());
return new Gson().fromJson(setting.getSettingValue(), PointSetting.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
@Service
public class PaymentExecute implements OrderStatusChangeEvent {

//订单
/**
* 订单
*/
@Autowired
private OrderService orderService;

Expand Down
24 changes: 18 additions & 6 deletions consumer/src/main/java/cn/lili/event/impl/StockUpdateExecute.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,35 @@
@Service
public class StockUpdateExecute implements OrderStatusChangeEvent {

//出库失败消息
/**
* 出库失败消息
*/
static String outOfStockMessage = "库存不足,出库失败";
//Redis
/**
* Redis
*/
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Autowired
private DefaultRedisScript<Boolean> quantityScript;
//订单
/**
* 订单
*/
@Autowired
private OrderService orderService;
//规格商品
/**
* 规格商品
*/
@Autowired
private GoodsSkuService goodsSkuService;
//促销商品
/**
* 促销商品
*/
@Autowired
private PromotionGoodsService promotionGoodsService;
//缓存
/**
* 缓存
*/
@Autowired
private Cache cache;

Expand Down
50 changes: 35 additions & 15 deletions consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,49 @@
@RocketMQMessageListener(topic = "${lili.data.rocketmq.goods-topic}", consumerGroup = "${lili.data.rocketmq.goods-group}")
public class GoodsMessageListener implements RocketMQListener<MessageExt> {

//ES商品
/**
* ES商品
*/
@Autowired
private EsGoodsIndexService goodsIndexService;
//店铺
/**
* 店铺
*/
@Autowired
private StoreService storeService;
//商品
/**
* 商品
*/
@Autowired
private GoodsService goodsService;
//商品
/**
* 商品Sku
*/
@Autowired
private GoodsSkuService goodsSkuService;
//用户足迹
/**
* 用户足迹
*/
@Autowired
private FootprintService footprintService;
//商品收藏
/**
* 商品收藏
*/
@Autowired
private GoodsCollectionService goodsCollectionService;
//商品评价
/**
* 商品评价
*/
@Autowired
private List<GoodsCommentCompleteEvent> goodsCommentCompleteEvents;
//分销商品
/**
* 分销商品
*/
@Autowired
private DistributionGoodsService distributionGoodsService;
//分销员-商品关联表
/**
* 分销员-商品关联表
*/
@Autowired
private DistributionSelectedGoodsService distributionSelectedGoodsService;

Expand Down Expand Up @@ -133,20 +151,21 @@ public void onMessage(MessageExt messageExt) {
* 1.更新店铺的商品数量
* 2.删除分销员-分销商品绑定关系
* 3.删除分销商品
*
* @param messageExt 消息
*/
private void deleteGoods(MessageExt messageExt){
Goods goods=JSONUtil.toBean(new String(messageExt.getBody()),Goods.class);
private void deleteGoods(MessageExt messageExt) {
Goods goods = JSONUtil.toBean(new String(messageExt.getBody()), Goods.class);
//更新店铺商品数量
storeService.updateStoreGoodsNum(goods.getStoreId());

//删除获取分销商品
DistributionGoods distributionGoods=distributionGoodsService.getOne(new LambdaQueryWrapper<DistributionGoods>()
.eq(DistributionGoods::getGoodsId,goods.getId()));
DistributionGoods distributionGoods = distributionGoodsService.getOne(new LambdaQueryWrapper<DistributionGoods>()
.eq(DistributionGoods::getGoodsId, goods.getId()));

//删除分销商品绑定关系
distributionSelectedGoodsService.remove(new LambdaQueryWrapper<DistributionSelectedGoods>()
.eq(DistributionSelectedGoods::getDistributionGoodsId,distributionGoods.getId()));
.eq(DistributionSelectedGoods::getDistributionGoodsId, distributionGoods.getId()));

//删除分销商品
distributionGoodsService.removeById(distributionGoods.getId());
Expand All @@ -157,9 +176,10 @@ private void deleteGoods(MessageExt messageExt){
* 1.更新商品购买数量
* 2.更新SKU购买数量
* 3.更新索引购买数量
*
* @param messageExt
*/
private void goodsBuyComplete(MessageExt messageExt){
private void goodsBuyComplete(MessageExt messageExt) {
String goodsCompleteMessageStr = new String(messageExt.getBody());
List<GoodsCompleteMessage> goodsCompleteMessageList = JSONUtil.toList(JSONUtil.parseArray(goodsCompleteMessageStr), GoodsCompleteMessage.class);
for (GoodsCompleteMessage goodsCompleteMessage : goodsCompleteMessageList) {
Expand Down
Loading

0 comments on commit 18d2379

Please sign in to comment.