| | |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.enumerates.*; |
| | | import cc.mrbird.febs.common.exception.FebsException; |
| | | import cc.mrbird.febs.common.exception.GeneratorException; |
| | | import cc.mrbird.febs.common.utils.AppContants; |
| | | import cc.mrbird.febs.common.utils.LoginUserUtil; |
| | | import cc.mrbird.febs.common.utils.MallUtils; |
| | |
| | | import cc.mrbird.febs.pay.service.UnipayService; |
| | | import cc.mrbird.febs.rabbit.producter.AgentProducer; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateField; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUnit; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.thread.ThreadUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.crypto.SecureUtil; |
| | |
| | | throw new FebsException(mallGoods.getGoodsName() + "已下架"); |
| | | } |
| | | |
| | | if (mallGoods.getRulesTimes() != null && mallGoods.getRulesCnt() != null) { |
| | | DateTime startDate = DateUtil.offset(new Date(), DateField.DAY_OF_YEAR, -mallGoods.getRulesTimes()); |
| | | List<MallOrderInfo> orderInfos = this.baseMapper.selectScoreOrderListInDate(DateUtil.beginOfDay(startDate), DateUtil.endOfDay(new Date()), mallGoods.getId(), member.getId()); |
| | | if (CollUtil.isNotEmpty(orderInfos) && orderInfos.size() >= mallGoods.getRulesCnt()) { |
| | | throw new FebsException("超出领取最大限制"); |
| | | } |
| | | } |
| | | |
| | | BigDecimal amount = mallGoods.getScore().multiply(BigDecimal.valueOf(item.getCnt())); |
| | | orderItem.setAmount(amount); |
| | | orderItem.setCnt(item.getCnt()); |
| | |
| | | orderItem.setSkuImage(sku.getSkuImage()); |
| | | orderItem.setIsNormal(mallGoods.getIsNormal()); |
| | | orderItem.setCostPrice(sku.getCostPrice()); |
| | | orderItem.setStaticMulti(mallGoods.getStaticMulti()); |
| | | orderItem.setGoodsLevel(mallGoods.getGoodsLevel()); |
| | | orderItem.setNormalBonus(mallGoods.getNormalBonus()); |
| | | orderItem.setNormalPer(mallGoods.getNormalPer()); |
| | | |
| | | |
| | | total = total.add(amount); |
| | | carriage = carriage.add(mallGoods.getCarriage()); |
| | |
| | | orderInfo.setName(itemsWx.get(0).getGoodsName()); |
| | | } |
| | | |
| | | if (orderInfo.getScoreCnt().compareTo(BigDecimal.ZERO) > 0) { |
| | | int reduce = memberWalletService.reduce(orderInfo.getScoreCnt(), member.getId(), "prizeScore"); |
| | | if (reduce == 2) { |
| | | throw new FebsException("积分不足"); |
| | | } |
| | | mallMoneyFlowService.addMoneyFlow(member.getId(), orderInfo.getScoreCnt().negate(), MoneyFlowTypeEnum.PAY.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.PRIZE_SCORE.getValue()); |
| | | } |
| | | |
| | | payResultStr = wechatPayService.pay(orderInfo); |
| | | orderInfo.setPayOrderNo(payResultStr); |
| | | orderInfo.setPayMethod("微信支付"); |
| | |
| | | orderInfo.setPayResult("1"); |
| | | this.baseMapper.updateById(orderInfo); |
| | | |
| | | commonService.changeWallet(orderInfo.getId(), FlowTypeEnum.BALANCE.getValue()); |
| | | // 商品级别 会员/代理/股东 |
| | | int goodsLevel = 0; |
| | | BigDecimal score = BigDecimal.ZERO; |
| | | for (MallOrderItem item : orderInfo.getItems()) { |
| | | // 计算静态倍数 |
| | | if(item.getIsNormal() == 2) { |
| | | score = score.add(item.getPrice().multiply(item.getStaticMulti())); |
| | | } |
| | | |
| | | //发送直推返利消息 |
| | | agentProducer.sendOrderReturn(orderInfo.getId()); |
| | | //发送代理自动升级消息 |
| | | agentProducer.sendAutoLevelUpMsg(member.getId()); |
| | | // 判断会员层级 |
| | | if (item.getIsNormal() == 2 && goodsLevel < item.getGoodsLevel()) { |
| | | goodsLevel = item.getGoodsLevel(); |
| | | } |
| | | |
| | | mallAchieveService.add(item.getId()); |
| | | } |
| | | member.setAccountLevel(goodsLevel); |
| | | String level = GoodsToLevelEnums.getLevelByAccountLevel(goodsLevel); |
| | | if (MemberLevelEnum.getLevelCode(member.getLevel()) < MemberLevelEnum.getLevelCode(level)) { |
| | | member.setLevel(level); |
| | | } |
| | | this.memberMapper.updateById(member); |
| | | |
| | | memberWalletService.add(score, member.getId(), "score"); |
| | | if (orderInfo.getScoreCnt().compareTo(BigDecimal.ZERO) > 0) { |
| | | int reduce = memberWalletService.reduce(orderInfo.getScoreCnt(), member.getId(), "prizeScore"); |
| | | if (reduce == 2) { |
| | | throw new FebsException("积分不足"); |
| | | } |
| | | mallMoneyFlowService.addMoneyFlow(member.getId(), orderInfo.getScoreCnt().negate(), MoneyFlowTypeEnum.PAY.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.PRIZE_SCORE.getValue()); |
| | | } |
| | | |
| | | mallMoneyFlowService.addMoneyFlow(member.getId(), score, MoneyFlowTypeEnum.BUY_TC.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.SCORE.getValue()); |
| | | mallMoneyFlowService.addMoneyFlow(member.getId(), orderInfo.getAmount().subtract(orderInfo.getScoreAmount()).negate(), MoneyFlowTypeEnum.PAY.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.BALANCE.getValue()); |
| | | ThreadUtil.execute(() -> { |
| | | ThreadUtil.sleep(5000); |
| | | |
| | | //发送代理自动升级消息 |
| | | agentProducer.sendAutoLevelUpMsg(member.getId()); |
| | | //发送直推返利消息 |
| | | agentProducer.sendOrderReturn(orderInfo.getId()); |
| | | // 发送分红消息 |
| | | agentProducer.sendOrderBonus(orderInfo.getId()); |
| | | }); |
| | | break; |
| | | case "4": |
| | | if (orderInfo.getOrderType() != 2) { |
| | |
| | | map.put("orderNo", orderInfo.getOrderNo()); |
| | | map.put("orderId", orderInfo.getId()); |
| | | map.put("rcResult", rcResult); |
| | | |
| | | return map; |
| | | } |
| | | |
| | |
| | | if (reduce == 2) { |
| | | throw new FebsException("余额不足"); |
| | | } |
| | | |
| | | |
| | | return orderInfo.getOrderNo(); |
| | | } |
| | | |
| | |
| | | orderDetailVo.setRemainTime(remainTime); |
| | | } |
| | | if(2 == deliverType){ |
| | | MallShopApply mallShopApply = mallShopApplyMapper.selectById(orderInfo.getShopId()); |
| | | MallShop mallShopApply = mallShopMapper.selectById(orderInfo.getShopId()); |
| | | if(ObjectUtil.isNotEmpty(mallShopApply)){ |
| | | ApiShopApplyVo apiShopApplyVo = new ApiShopApplyVo(); |
| | | apiShopApplyVo.setName(mallShopApply.getName()); |
| | | apiShopApplyVo.setName(mallShopApply.getShopName()); |
| | | apiShopApplyVo.setPhone(mallShopApply.getPhone()); |
| | | apiShopApplyVo.setSaleArea(mallShopApply.getSaleArea()); |
| | | apiShopApplyVo.setLatitude(mallShopApply.getLatitude()); |
| | | apiShopApplyVo.setLongitude(mallShopApply.getLongitude()); |
| | | apiShopApplyVo.setLatitude(mallShopApply.getLatitude().toPlainString()); |
| | | apiShopApplyVo.setLongitude(mallShopApply.getLongitude().toPlainString()); |
| | | apiShopApplyVo.setShopName(mallShopApply.getShopName()); |
| | | apiShopApplyVo.setAddress(mallShopApply.getAddress()); |
| | | apiShopApplyVo.setAddress(mallShopApply.getShopAddress()); |
| | | orderDetailVo.setApiShopApplyVo(apiShopApplyVo); |
| | | } |
| | | } |
| | |
| | | if(ObjectUtil.isEmpty(mallGoods)){ |
| | | throw new FebsException("商品已更新,请重新下单"); |
| | | } |
| | | /** |
| | | * 贡献点判断 |
| | | |
| | | /* |
| | | 获取单个商品的折扣积分数量 |
| | | = 现价 * 数量 * 折扣现金比例 |
| | | */ |
| | | if (mallGoods.getIsNormal() == 2) { |
| | | hasTc = true; |
| | | } |
| | | /* |
| | | 获取单个商品的折扣积分数量 |
| | | = 现价 * 数量 * 折扣现金比例 |
| | | */ |
| | | BigDecimal scorePercent = new BigDecimal(mallGoods.getScorePercent()).multiply(new BigDecimal(0.01)); |
| | | BigDecimal scorePercent = new BigDecimal(mallGoods.getScorePercent()).multiply(BigDecimal.valueOf(0.01)); |
| | | BigDecimal amount = sku.getPresentPrice().multiply(BigDecimal.valueOf(item.getCnt())).multiply(scorePercent); |
| | | total = total.add(amount); |
| | | } |
| | |
| | | if(prizeScore.compareTo(score) < 0){ |
| | | throw new FebsException("积分不足"); |
| | | } |
| | | if(hasTc){ |
| | | //系统设置的个人贡献点最大值 |
| | | DataDictionaryCustom starGetDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.STAR_GET.getType(), |
| | | DataDictionaryEnum.STAR_GET.getCode()); |
| | | if(ObjectUtil.isNotEmpty(starGetDic)){ |
| | | String starGetStr = StrUtil.isEmpty(starGetDic.getValue()) ? "0" : starGetDic.getValue(); |
| | | BigDecimal starGet = new BigDecimal(starGetStr); |
| | | BigDecimal star = new BigDecimal(mallMemberWallet.getStar()); |
| | | if(starGet.compareTo(BigDecimal.ZERO) != 0 && starGet.compareTo(star) <= 0){ |
| | | throw new FebsException("无法购买套餐"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 使用积分折扣现金 |
| | | */ |