| | |
| | | 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.*; |
| | |
| | | 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; |
| | |
| | | private final DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | private final MallMoneyFlowMapper mallMoneyFlowMapper; |
| | | private final MallAchieveRecordMapper mallAchieveRecordMapper; |
| | | private final MallMemberWalletMapper mallMemberWalletMapper; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | } |
| | | 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); |
| | | } |
| | | } |