From 6df8f9816bdfde3ddf860146a72189b7271caf35 Mon Sep 17 00:00:00 2001 From: KKSU <15274802129@163.com> Date: Fri, 22 Dec 2023 16:27:34 +0800 Subject: [PATCH] 富文本框输入版本变化 --- src/main/java/cc/mrbird/febs/rabbit/enumerates/RabbitQueueEnum.java | 5 ++ src/main/java/cc/mrbird/febs/common/configure/RabbitConfigure.java | 16 ++++++++ src/main/java/cc/mrbird/febs/rabbit/consumer/AgentConsumer.java | 10 +++++ src/main/java/cc/mrbird/febs/pay/service/impl/xcxCodePayServiceImpl.java | 4 ++ src/main/java/cc/mrbird/febs/mall/service/impl/MemberProfitServiceImpl.java | 66 +++++++++++++++++++++++++++++++-- src/main/java/cc/mrbird/febs/rabbit/constants/QueueConstants.java | 1 src/main/java/cc/mrbird/febs/rabbit/producter/AgentProducer.java | 5 ++ src/main/java/cc/mrbird/febs/mall/controller/ApiMallAppController.java | 4 + src/main/java/cc/mrbird/febs/mall/service/IMemberProfitService.java | 2 + 9 files changed, 107 insertions(+), 6 deletions(-) diff --git a/src/main/java/cc/mrbird/febs/common/configure/RabbitConfigure.java b/src/main/java/cc/mrbird/febs/common/configure/RabbitConfigure.java index 50797b6..5871658 100644 --- a/src/main/java/cc/mrbird/febs/common/configure/RabbitConfigure.java +++ b/src/main/java/cc/mrbird/febs/common/configure/RabbitConfigure.java @@ -122,4 +122,20 @@ return BindingBuilder.bind(orderReturnMoneyQueue()).to(orderReturnMoneyExchange()).with(RabbitQueueEnum.ORDER_RETURN_MONEY.getRoute()); } + + @Bean + public DirectExchange syAppOrderPayDoneExchange() { + return new DirectExchange(RabbitQueueEnum.SY_APP_ORDER_PAY_DONE.getExchange()); + } + + @Bean + public Queue syAppOrderPayDoneQueue() { + return new Queue(RabbitQueueEnum.SY_APP_ORDER_PAY_DONE.getQueue()); + } + + @Bean + public Binding syAppOrderPayDoneBind() { + return BindingBuilder.bind(syAppOrderPayDoneQueue()).to(syAppOrderPayDoneExchange()).with(RabbitQueueEnum.SY_APP_ORDER_PAY_DONE.getRoute()); + } + } diff --git a/src/main/java/cc/mrbird/febs/mall/controller/ApiMallAppController.java b/src/main/java/cc/mrbird/febs/mall/controller/ApiMallAppController.java index ebaaa80..1468f28 100644 --- a/src/main/java/cc/mrbird/febs/mall/controller/ApiMallAppController.java +++ b/src/main/java/cc/mrbird/febs/mall/controller/ApiMallAppController.java @@ -13,6 +13,8 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; +import javax.validation.Valid; + @Slf4j @CrossOrigin("*") @RequiredArgsConstructor @@ -28,7 +30,7 @@ @ApiResponse(code = 200, message = "success", response = ApiMallAppMemberInfoVo.class) }) @PostMapping(value = "/appMemberInfo") - public FebsResponse appMemberInfo(@RequestBody ApiMallAppMemberInfoDto apiMallAppMemberInfoDto) { + public FebsResponse appMemberInfo(@RequestBody @Valid ApiMallAppMemberInfoDto apiMallAppMemberInfoDto) { return mallAppService.appMemberInfo(apiMallAppMemberInfoDto); } diff --git a/src/main/java/cc/mrbird/febs/mall/service/IMemberProfitService.java b/src/main/java/cc/mrbird/febs/mall/service/IMemberProfitService.java index 2d7a643..5a5ddd6 100644 --- a/src/main/java/cc/mrbird/febs/mall/service/IMemberProfitService.java +++ b/src/main/java/cc/mrbird/febs/mall/service/IMemberProfitService.java @@ -39,4 +39,6 @@ * 店补/董事 */ void storeAndDirectorProfit(Date profitDate); + + void syAppOrderPayDoneQueue(String orderNo); } diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/MemberProfitServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/MemberProfitServiceImpl.java index 89dab43..4e0702e 100644 --- a/src/main/java/cc/mrbird/febs/mall/service/impl/MemberProfitServiceImpl.java +++ b/src/main/java/cc/mrbird/febs/mall/service/impl/MemberProfitServiceImpl.java @@ -1,9 +1,6 @@ package cc.mrbird.febs.mall.service.impl; -import cc.mrbird.febs.common.enumerates.AgentLevelEnum; -import cc.mrbird.febs.common.enumerates.DataDictionaryEnum; -import cc.mrbird.febs.common.enumerates.FlowTypeEnum; -import cc.mrbird.febs.common.enumerates.MoneyFlowTypeEnum; +import cc.mrbird.febs.common.enumerates.*; import cc.mrbird.febs.common.utils.AppContants; import cc.mrbird.febs.mall.entity.*; import cc.mrbird.febs.mall.mapper.*; @@ -15,8 +12,10 @@ import cn.hutool.core.date.DateField; import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.RequiredArgsConstructor; @@ -46,6 +45,7 @@ private final DataDictionaryCustomMapper dataDictionaryCustomMapper; private final MallMoneyFlowMapper mallMoneyFlowMapper; private final MallAchieveRecordMapper mallAchieveRecordMapper; + private final MallMemberWalletMapper mallMemberWalletMapper; @Override @Transactional(rollbackFor = Exception.class) @@ -477,4 +477,62 @@ } log.info("#####==店补/董事==end==######"); } + + @Override + public void syAppOrderPayDoneQueue(String orderNo) { + LambdaQueryWrapper<MallOrderInfo> query = new LambdaQueryWrapper<>(); + query.eq(MallOrderInfo::getOrderNo, orderNo); + MallOrderInfo orderInfo = mallOrderInfoMapper.selectOne(query); + if(ObjectUtil.isEmpty(orderInfo)){ + return; + } + if ("1".equals(orderInfo.getPayResult())) { + return; + } + orderInfo.setStatus(OrderStatusEnum.FINISH.getValue()); + orderInfo.setPayResult("1"); + orderInfo.setPayTime(DateUtil.date()); + mallOrderInfoMapper.updateById(orderInfo); + + if(ObjectUtil.isEmpty(orderInfo.getMemberId())){ + return; + } + Long memberId = orderInfo.getMemberId(); + MallMemberWallet mallMemberWallet = mallMemberWalletMapper.selectWalletByMemberId(memberId); + if(ObjectUtil.isEmpty(mallMemberWallet)){ + return; + } + List<MallOrderItem> mallOrderItemList = mallOrderItemMapper.selectListByOrderId(orderInfo.getId()); + if(ObjectUtil.isEmpty(mallOrderItemList)){ + return; + } + /** + * 会员增加积分 + * (现价-成本价)/现价*支付的金额 = 这个商品可以得到的积分 + * 然后累加得到总增加的积分数量 + */ + BigDecimal totalScoreAdd = BigDecimal.ZERO; + for(MallOrderItem mallOrderItem : mallOrderItemList){ + Long goodsId = mallOrderItem.getGoodsId(); + MallGoods mallGoods = mallGoodsMapper.selectById(goodsId); + if(ObjectUtil.isEmpty(mallGoods)){ + continue; + } + BigDecimal presentPrice = new BigDecimal(mallGoods.getPresentPrice()); + BigDecimal costPrice = mallGoods.getCostPrice(); + BigDecimal subtractPrice = presentPrice.subtract(costPrice);//现价和成本价之间的差价 + if(subtractPrice.compareTo(BigDecimal.ZERO) <= 0){ + continue; + } + BigDecimal multiply = subtractPrice.divide(presentPrice, 2, BigDecimal.ROUND_DOWN).multiply(mallOrderItem.getAmount()); + totalScoreAdd = totalScoreAdd.add(multiply); + } + if(totalScoreAdd.compareTo(BigDecimal.ZERO) <= 0){ + return; + } + BigDecimal bigDecimal = totalScoreAdd.add(mallMemberWallet.getScore()).setScale(2, BigDecimal.ROUND_DOWN); + mallMemberWallet.setScore(bigDecimal); + mallMemberWallet.setBalance(mallMemberWallet.getBalance()); + mallMemberWalletMapper.updateBalanceScoreWithId(mallMemberWallet); + } } diff --git a/src/main/java/cc/mrbird/febs/pay/service/impl/xcxCodePayServiceImpl.java b/src/main/java/cc/mrbird/febs/pay/service/impl/xcxCodePayServiceImpl.java index d45e026..950130a 100644 --- a/src/main/java/cc/mrbird/febs/pay/service/impl/xcxCodePayServiceImpl.java +++ b/src/main/java/cc/mrbird/febs/pay/service/impl/xcxCodePayServiceImpl.java @@ -11,6 +11,7 @@ import cc.mrbird.febs.pay.util.Signature; import cc.mrbird.febs.pay.util.WebUtil; import cc.mrbird.febs.pay.util.WeixinServiceUtil; +import cc.mrbird.febs.rabbit.producter.AgentProducer; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; @@ -44,6 +45,7 @@ private final MallOrderInfoMapper mallOrderInfoMapper; private final DataDictionaryCustomMapper dataDictionaryCustomMapper; private final WeixinServiceUtil weixinServiceUtil; + private final AgentProducer agentProducer; private static final String PAY_SUCCESS = "SUCCESS"; private static final String PAY_USERPAYING = "USERPAYING"; @Override @@ -126,6 +128,7 @@ if(PAY_SUCCESS.equals(returnCode) && PAY_SUCCESS.equals(resultCode)){ log.info("微信免密支付成功"); + agentProducer.sendSyAppOrderPayDoneQueue(outTradeNo); return PAY_SUCCESS; } else if (PAY_USERPAYING.equals(errCode)){//等待用户输入密码 for(int i = 0; i < 4; i++){ @@ -146,6 +149,7 @@ String tradeTypePaying = wxPayOrderQueryResult.getTradeType(); if(PAY_SUCCESS.equals(tradeTypePaying)&& PAY_SUCCESS.equals(returnCodePaying)&& PAY_SUCCESS.equals(resultCodePaying)){ log.info("微信加密支付成功!"); + agentProducer.sendSyAppOrderPayDoneQueue(outTradeNo); return PAY_SUCCESS; } log.info("正在支付" + wxPayOrderQueryResult.getDetail()); diff --git a/src/main/java/cc/mrbird/febs/rabbit/constants/QueueConstants.java b/src/main/java/cc/mrbird/febs/rabbit/constants/QueueConstants.java index 47cee57..ec453f0 100644 --- a/src/main/java/cc/mrbird/febs/rabbit/constants/QueueConstants.java +++ b/src/main/java/cc/mrbird/febs/rabbit/constants/QueueConstants.java @@ -10,4 +10,5 @@ public static final String AGENT_AUTO_LEVEL_UP = "queue_agent_auto_level_up"; public static final String AGENT_RETURN_MONEY = "queue_agent_return_money"; public static final String ORDER_RETURN_MONEY = "queue_order_return_money"; + public static final String SY_APP_ORDER_PAY_DONE = "queue_sy_app_order_pay_done"; } diff --git a/src/main/java/cc/mrbird/febs/rabbit/consumer/AgentConsumer.java b/src/main/java/cc/mrbird/febs/rabbit/consumer/AgentConsumer.java index 46c50a1..3c01f4c 100644 --- a/src/main/java/cc/mrbird/febs/rabbit/consumer/AgentConsumer.java +++ b/src/main/java/cc/mrbird/febs/rabbit/consumer/AgentConsumer.java @@ -72,4 +72,14 @@ log.error("订单返利异常:", e); } } + + @RabbitListener(queues = QueueConstants.SY_APP_ORDER_PAY_DONE) + public void syAppOrderPayDoneQueue(String orderNo) { + log.info("收到付款码支付成功:{}", orderNo); + try { + memberProfitService.syAppOrderPayDoneQueue(orderNo); + } catch (Exception e) { + log.error("付款码支付成功异常:", e); + } + } } diff --git a/src/main/java/cc/mrbird/febs/rabbit/enumerates/RabbitQueueEnum.java b/src/main/java/cc/mrbird/febs/rabbit/enumerates/RabbitQueueEnum.java index 90122ca..6bbb463 100644 --- a/src/main/java/cc/mrbird/febs/rabbit/enumerates/RabbitQueueEnum.java +++ b/src/main/java/cc/mrbird/febs/rabbit/enumerates/RabbitQueueEnum.java @@ -1,5 +1,6 @@ package cc.mrbird.febs.rabbit.enumerates; +import cc.mrbird.febs.rabbit.constants.QueueConstants; import lombok.Getter; @Getter @@ -12,7 +13,9 @@ AGENT_REUTRN_MONEY("exchange_agent_return_money", "route_key_agent_return_money", "queue_agent_return_money"), - ORDER_RETURN_MONEY("exchange_order_return_money", "route_key_order_return_money", "queue_order_return_money"); + ORDER_RETURN_MONEY("exchange_order_return_money", "route_key_order_return_money", "queue_order_return_money"), + + SY_APP_ORDER_PAY_DONE("exchange_sy_app_order_pay_done", "route_key_sy_app_order_pay_done",QueueConstants.SY_APP_ORDER_PAY_DONE); private String exchange; diff --git a/src/main/java/cc/mrbird/febs/rabbit/producter/AgentProducer.java b/src/main/java/cc/mrbird/febs/rabbit/producter/AgentProducer.java index 0ddb24b..2b5fddd 100644 --- a/src/main/java/cc/mrbird/febs/rabbit/producter/AgentProducer.java +++ b/src/main/java/cc/mrbird/febs/rabbit/producter/AgentProducer.java @@ -76,4 +76,9 @@ log.info("发送返利消息:{}", orderId); rabbitTemplate.convertAndSend(RabbitQueueEnum.AGENT_REUTRN_MONEY.getExchange(), RabbitQueueEnum.AGENT_REUTRN_MONEY.getRoute(), orderId); } + + public void sendSyAppOrderPayDoneQueue(String orderNo) { + log.info("发送付款码支付成功:{}", orderNo); + rabbitTemplate.convertAndSend(RabbitQueueEnum.SY_APP_ORDER_PAY_DONE.getExchange(), RabbitQueueEnum.SY_APP_ORDER_PAY_DONE.getRoute(), orderNo); + } } -- Gitblit v1.9.1