|  |  |  | 
|---|
|  |  |  | import cc.mrbird.febs.mall.vo.*; | 
|---|
|  |  |  | import cc.mrbird.febs.pay.model.AgreementPayDto; | 
|---|
|  |  |  | import cc.mrbird.febs.pay.model.AgreementSignDto; | 
|---|
|  |  |  | import cc.mrbird.febs.pay.model.LaKaLaCreateOrderReqDate; | 
|---|
|  |  |  | import cc.mrbird.febs.pay.model.UnipayDto; | 
|---|
|  |  |  | import cc.mrbird.febs.pay.service.IAliPayService; | 
|---|
|  |  |  | import cc.mrbird.febs.pay.service.IPayService; | 
|---|
|  |  |  | import cc.mrbird.febs.pay.service.LaKaLaService; | 
|---|
|  |  |  | import cc.mrbird.febs.pay.service.UnipayService; | 
|---|
|  |  |  | import cc.mrbird.febs.rabbit.producter.AgentProducer; | 
|---|
|  |  |  | import cn.hutool.core.collection.CollUtil; | 
|---|
|  |  |  | 
|---|
|  |  |  | private final MallOrderRefundMapper mallOrderRefundMapper; | 
|---|
|  |  |  | private final MallOrderRefundOperationMapper mallOrderRefundOperationMapper; | 
|---|
|  |  |  | private final MallShoppingCartMapper mallShoppingCartMapper; | 
|---|
|  |  |  | private final IApiMallMemberService memberService; | 
|---|
|  |  |  | private final IMallMoneyFlowService mallMoneyFlowService; | 
|---|
|  |  |  | private final RedisUtils redisUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private final AgentProducer agentProducer; | 
|---|
|  |  |  | private final IPayService payService; | 
|---|
|  |  |  | private final IAliPayService payService; | 
|---|
|  |  |  | private final IMallAchieveService mallAchieveService; | 
|---|
|  |  |  | private final UnipayService unipayService; | 
|---|
|  |  |  | private final IPayService wechatPayService; | 
|---|
|  |  |  | private final LaKaLaService laKaLaService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private final MallMemberBankSignMapper mallMemberBankSignMapper; | 
|---|
|  |  |  | private final MallMemberBankMapper mallMemberBankMapper; | 
|---|
|  |  |  | 
|---|
|  |  |  | private final MallAchieveRecordMapper mallAchieveRecordMapper; | 
|---|
|  |  |  | private final MallMemberWalletMapper mallMemberWalletMapper; | 
|---|
|  |  |  | private final MallMqRecordMapper mallMqRecordMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private final ICommonService commonService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = Exception.class) | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | this.baseMapper.updateById(orderInfo); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | agentProducer.sendOrderCancelDelayMsg(orderInfo.getId(), 15 * 60 * 1000L); | 
|---|
|  |  |  | return orderInfo.getId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | String rcResult = ""; | 
|---|
|  |  |  | switch (payOrderDto.getType()) { | 
|---|
|  |  |  | case "1": | 
|---|
|  |  |  | UnipayDto unipayDtoWx = new UnipayDto(); | 
|---|
|  |  |  | //                unipayDto.setAmount(new BigDecimal("0.01")); | 
|---|
|  |  |  | unipayDtoWx.setAmount(orderInfo.getAmount()); | 
|---|
|  |  |  | unipayDtoWx.setFrpCode("WEIXIN_APP3"); | 
|---|
|  |  |  | unipayDtoWx.setTradeMerchantNo("777180800385820"); | 
|---|
|  |  |  | unipayDtoWx.setOrderNo(orderInfo.getOrderNo()); | 
|---|
|  |  |  | List<MallOrderItem> itemsWx = orderInfo.getItems(); | 
|---|
|  |  |  | if(CollUtil.isEmpty(itemsWx)){ | 
|---|
|  |  |  | unipayDtoWx.setProductName("商品"); | 
|---|
|  |  |  | orderInfo.setName("商品"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | unipayDtoWx.setProductName(itemsWx.get(0).getGoodsName()); | 
|---|
|  |  |  | orderInfo.setName(itemsWx.get(0).getGoodsName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String unipayStrWx = unipayService.unipay(unipayDtoWx); | 
|---|
|  |  |  | if("fail" == unipayStrWx){ | 
|---|
|  |  |  | throw new FebsException("支付失败"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //                    JSONUtil.parseObj(unipayStr); | 
|---|
|  |  |  | JSONObject jsonObject = JSONUtil.parseObj(unipayStrWx); | 
|---|
|  |  |  | payResultStr = (String) jsonObject.get("r7_TrxNo"); | 
|---|
|  |  |  | rcResult = (String) jsonObject.get("rc_Result"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | payResultStr = wechatPayService.pay(orderInfo); | 
|---|
|  |  |  | orderInfo.setPayOrderNo(payResultStr); | 
|---|
|  |  |  | //                orderInfo.setPayOrderNo(payOrderDto.getPayOrderNo()); | 
|---|
|  |  |  | //                orderInfo.setPayImage(payOrderDto.getPayImage()); | 
|---|
|  |  |  | orderInfo.setPayMethod("微信支付"); | 
|---|
|  |  |  | orderInfo.setPayResult("2"); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case "2": | 
|---|
|  |  |  | //                if (StrUtil.isNotBlank(orderInfo.getPayOrderNo())) { | 
|---|
|  |  |  | //                    payResultStr = orderInfo.getPayOrderNo(); | 
|---|
|  |  |  | //                } else { | 
|---|
|  |  |  | //                    payResultStr = payService.aliPay(orderInfo); | 
|---|
|  |  |  | LaKaLaCreateOrderReqDate laKaLaCreateOrderReqDate = new LaKaLaCreateOrderReqDate(); | 
|---|
|  |  |  | //订单编号 | 
|---|
|  |  |  | laKaLaCreateOrderReqDate.setOut_order_no(orderInfo.getOrderNo()); | 
|---|
|  |  |  | //订单金额,分计 | 
|---|
|  |  |  | laKaLaCreateOrderReqDate.setTotal_amount(orderInfo.getAmount().multiply(new BigDecimal(100)).longValue()); | 
|---|
|  |  |  | List<MallOrderItem> itemsLKL = orderInfo.getItems(); | 
|---|
|  |  |  | //商品名称 | 
|---|
|  |  |  | if(CollUtil.isEmpty(itemsLKL)){ | 
|---|
|  |  |  | laKaLaCreateOrderReqDate.setOrder_info("商品"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | laKaLaCreateOrderReqDate.setOrder_info(itemsLKL.get(0).getGoodsName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | payResultStr = laKaLaService.verifyCreateOrder(laKaLaCreateOrderReqDate); | 
|---|
|  |  |  | JSONObject parseObj = JSONUtil.parseObj(payResultStr); | 
|---|
|  |  |  | String code = parseObj.get("code").toString(); | 
|---|
|  |  |  | if (!"true".equals(code)) { | 
|---|
|  |  |  | throw new FebsException("跳转收银台失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | orderInfo.setPayOrderNo(parseObj.get("payOrderNo").toString()); | 
|---|
|  |  |  | orderInfo.setPayMethod("拉卡拉支付"); | 
|---|
|  |  |  | orderInfo.setPayResult("2"); | 
|---|
|  |  |  | //                UnipayDto unipayDto = new UnipayDto(); | 
|---|
|  |  |  | //                unipayDto.setAmount(orderInfo.getAmount()); | 
|---|
|  |  |  | //                unipayDto.setFrpCode("ALIPAY_H5"); | 
|---|
|  |  |  | //                unipayDto.setTradeMerchantNo("777184100385821"); | 
|---|
|  |  |  | //                unipayDto.setOrderNo(orderInfo.getOrderNo()); | 
|---|
|  |  |  | //                List<MallOrderItem> items = orderInfo.getItems(); | 
|---|
|  |  |  | //                if(CollUtil.isEmpty(items)){ | 
|---|
|  |  |  | //                    unipayDto.setProductName("商品"); | 
|---|
|  |  |  | //                }else{ | 
|---|
|  |  |  | //                    unipayDto.setProductName(items.get(0).getGoodsName()); | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | UnipayDto unipayDto = new UnipayDto(); | 
|---|
|  |  |  | //                unipayDto.setAmount(new BigDecimal("0.01")); | 
|---|
|  |  |  | unipayDto.setAmount(orderInfo.getAmount()); | 
|---|
|  |  |  | unipayDto.setFrpCode("ALIPAY_H5"); | 
|---|
|  |  |  | unipayDto.setTradeMerchantNo("777184100385821"); | 
|---|
|  |  |  | unipayDto.setOrderNo(orderInfo.getOrderNo()); | 
|---|
|  |  |  | List<MallOrderItem> items = orderInfo.getItems(); | 
|---|
|  |  |  | if(CollUtil.isEmpty(items)){ | 
|---|
|  |  |  | unipayDto.setProductName("商品"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | unipayDto.setProductName(items.get(0).getGoodsName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String unipayStr = unipayService.unipay(unipayDto); | 
|---|
|  |  |  | if("fail" == unipayStr){ | 
|---|
|  |  |  | throw new FebsException("支付失败"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //                    JSONUtil.parseObj(unipayStr); | 
|---|
|  |  |  | JSONObject jsonObject = JSONUtil.parseObj(unipayStr); | 
|---|
|  |  |  | payResultStr = (String) jsonObject.get("r7_TrxNo"); | 
|---|
|  |  |  | rcResult = (String) jsonObject.get("rc_Result"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orderInfo.setPayOrderNo(payResultStr); | 
|---|
|  |  |  | orderInfo.setPayMethod("支付宝支付"); | 
|---|
|  |  |  | //                agentProducer.sendOrderReturn(orderInfo.getId()); | 
|---|
|  |  |  | //                String unipayStr = unipayService.unipay(unipayDto); | 
|---|
|  |  |  | //                if("fail" == unipayStr){ | 
|---|
|  |  |  | //                    throw new FebsException("支付失败"); | 
|---|
|  |  |  | //                }else{ | 
|---|
|  |  |  | //                    JSONObject jsonObject = JSONUtil.parseObj(unipayStr); | 
|---|
|  |  |  | //                    payResultStr = (String) jsonObject.get("r7_TrxNo"); | 
|---|
|  |  |  | //                    rcResult = (String) jsonObject.get("rc_Result"); | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //                orderInfo.setPayOrderNo(payResultStr); | 
|---|
|  |  |  | //                orderInfo.setPayMethod("支付宝支付"); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case "3": | 
|---|
|  |  |  | payResultStr = balancePay(orderInfo, payOrderDto.getTradePwd(), "balance"); | 
|---|
|  |  |  | 
|---|
|  |  |  | orderInfo.setStatus(OrderStatusEnum.WAIT_SHIPPING.getValue()); | 
|---|
|  |  |  | orderInfo.setPayTime(new Date()); | 
|---|
|  |  |  | orderInfo.setPayResult("1"); | 
|---|
|  |  |  | this.baseMapper.updateById(orderInfo); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | changeWallet(orderInfo.getId()); | 
|---|
|  |  |  | commonService.changeWallet(orderInfo.getId(), FlowTypeEnum.BALANCE.getValue()); | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 插入一条待处理记录 | 
|---|
|  |  |  | * mq处理之后,更新状态 | 
|---|
|  |  |  | 
|---|
|  |  |  | mallMqRecord.setOrderId(orderInfo.getId()); | 
|---|
|  |  |  | mallMqRecord.setState(2); | 
|---|
|  |  |  | mallMqRecord.setRetryTimes(2); | 
|---|
|  |  |  | mallMqRecord.setCreateTime(orderInfo.getPayTime()); | 
|---|
|  |  |  | mallMqRecordMapper.insert(mallMqRecord); | 
|---|
|  |  |  | //发送补贴消息 | 
|---|
|  |  |  | agentProducer.sendPerkMoneyMsg(orderInfo.getId()); | 
|---|
|  |  |  | //发送代理自动升级消息 | 
|---|
|  |  |  | agentProducer.sendAutoLevelUpMsg(member.getId()); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case "4": | 
|---|
|  |  |  | if (orderInfo.getOrderType() != 2) { | 
|---|
|  |  |  | 
|---|
|  |  |  | map.put("rcResult", rcResult); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return map; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 支付金额后的操作 | 
|---|
|  |  |  | *      减少积分,增加流水 | 
|---|
|  |  |  | *      购买套餐后,升级会员等级 | 
|---|
|  |  |  | *      增加支付金额流水 | 
|---|
|  |  |  | *      增加补贴额度 | 
|---|
|  |  |  | *      增加贡献值,增加流水 | 
|---|
|  |  |  | *      产生一条业绩记录 | 
|---|
|  |  |  | * @param orderId | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void changeWallet(Long orderId){ | 
|---|
|  |  |  | MallOrderInfo orderInfo = this.baseMapper.selectById(orderId); | 
|---|
|  |  |  | Long memberId = orderInfo.getMemberId(); | 
|---|
|  |  |  | boolean hasTc = false; | 
|---|
|  |  |  | //总贡献值 | 
|---|
|  |  |  | BigDecimal starSum = BigDecimal.ZERO; | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 总补贴额度 | 
|---|
|  |  |  | * 所有合伙人补贴至消费礼包的三倍额度需要复购一次。 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | BigDecimal scoreSum = BigDecimal.ZERO; | 
|---|
|  |  |  | BigDecimal achieveSum = BigDecimal.ZERO; | 
|---|
|  |  |  | List<MallOrderItem> orderItems = this.baseMapper.getMallOrderItemByOrderId(orderInfo.getId()); | 
|---|
|  |  |  | if (CollUtil.isNotEmpty(orderItems)) { | 
|---|
|  |  |  | for (MallOrderItem orderItem : orderItems) { | 
|---|
|  |  |  | MallGoods mallGoods = mallGoodsMapper.selectById(orderItem.getGoodsId()); | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 购买套餐赠送贡献值 | 
|---|
|  |  |  | * 补贴3倍额度 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | if (mallGoods.getIsNormal() == 2) { | 
|---|
|  |  |  | hasTc = true; | 
|---|
|  |  |  | BigDecimal star = (mallGoods.getStar()==null ? BigDecimal.ZERO : mallGoods.getStar()) | 
|---|
|  |  |  | .multiply(new BigDecimal(orderItem.getCnt())); | 
|---|
|  |  |  | starSum = starSum.add(star); | 
|---|
|  |  |  | //                    scoreSum = scoreSum.add( | 
|---|
|  |  |  | //                            new BigDecimal(mallGoods.getPresentPrice()) | 
|---|
|  |  |  | //                                    .multiply(new BigDecimal(3)) | 
|---|
|  |  |  | //                                    .multiply(new BigDecimal(orderItem.getCnt())) | 
|---|
|  |  |  | //                                    .abs() | 
|---|
|  |  |  | //                                    .setScale(2,BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  | String goodsName = mallGoods.getGoodsName(); | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 1-2档投资级别,2.5倍 | 
|---|
|  |  |  | * 3-4档投资级别,2.8倍 | 
|---|
|  |  |  | * 5-6档投资级别,3倍 | 
|---|
|  |  |  | * 目前紧急修改成按照商品名称 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | BigDecimal basePercent = new BigDecimal("3"); | 
|---|
|  |  |  | if(goodsName.equals("礼包一") || goodsName.equals("礼包二")){ | 
|---|
|  |  |  | basePercent = new BigDecimal("2.5"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(goodsName.equals("礼包三") || goodsName.equals("礼包四")){ | 
|---|
|  |  |  | basePercent = new BigDecimal("2.8"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(goodsName.equals("礼包五") || goodsName.equals("礼包六")){ | 
|---|
|  |  |  | basePercent = new BigDecimal("3"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | scoreSum = scoreSum.add( | 
|---|
|  |  |  | new BigDecimal(mallGoods.getPresentPrice()) | 
|---|
|  |  |  | .multiply(new BigDecimal(orderItem.getCnt())) | 
|---|
|  |  |  | .multiply(basePercent) | 
|---|
|  |  |  | .abs() | 
|---|
|  |  |  | .setScale(2,BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  | achieveSum = achieveSum.add( | 
|---|
|  |  |  | new BigDecimal(mallGoods.getPresentPrice()) | 
|---|
|  |  |  | .multiply(new BigDecimal(orderItem.getCnt())) | 
|---|
|  |  |  | .abs() | 
|---|
|  |  |  | .setScale(2,BigDecimal.ROUND_DOWN)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 增加贡献值,增加流水 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | if (starSum.compareTo(BigDecimal.ZERO) > 0) { | 
|---|
|  |  |  | //系统设置的个人贡献点最大值 | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | MallMemberWallet mallMemberWallet = mallMemberWalletMapper.selectWalletByMemberId(memberId); | 
|---|
|  |  |  | BigDecimal star = new BigDecimal(mallMemberWallet.getStar()); | 
|---|
|  |  |  | if(starGet.compareTo(star.add(starSum)) < 0){ | 
|---|
|  |  |  | if(starGet.compareTo(BigDecimal.ZERO) == 0){ | 
|---|
|  |  |  | mallMemberWalletMapper.addStarByMemberId(starSum.intValue(), memberId); | 
|---|
|  |  |  | mallMoneyFlowService.addMoneyFlow( | 
|---|
|  |  |  | memberId, | 
|---|
|  |  |  | starSum, | 
|---|
|  |  |  | MoneyFlowTypeEnum.STAR.getValue(), | 
|---|
|  |  |  | orderInfo.getOrderNo(), | 
|---|
|  |  |  | FlowTypeEnum.STAR.getValue(), | 
|---|
|  |  |  | 2); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(starGet.compareTo(star) > 0){ | 
|---|
|  |  |  | BigDecimal subtract = starGet.subtract(star); | 
|---|
|  |  |  | if(subtract.compareTo(starSum) < 0){ | 
|---|
|  |  |  | starSum = subtract; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | mallMemberWalletMapper.addStarByMemberId(starSum.intValue(), memberId); | 
|---|
|  |  |  | mallMoneyFlowService.addMoneyFlow( | 
|---|
|  |  |  | memberId, | 
|---|
|  |  |  | starSum, | 
|---|
|  |  |  | MoneyFlowTypeEnum.STAR.getValue(), | 
|---|
|  |  |  | orderInfo.getOrderNo(), | 
|---|
|  |  |  | FlowTypeEnum.STAR.getValue(), | 
|---|
|  |  |  | 2); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | mallMemberWalletMapper.addStarByMemberId(starSum.intValue(), memberId); | 
|---|
|  |  |  | mallMoneyFlowService.addMoneyFlow( | 
|---|
|  |  |  | memberId, | 
|---|
|  |  |  | starSum, | 
|---|
|  |  |  | MoneyFlowTypeEnum.STAR.getValue(), | 
|---|
|  |  |  | orderInfo.getOrderNo(), | 
|---|
|  |  |  | FlowTypeEnum.STAR.getValue(), | 
|---|
|  |  |  | 2); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 增加补贴额度 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | if (scoreSum.compareTo(BigDecimal.ZERO) > 0) { | 
|---|
|  |  |  | //                MallMember mallMember = memberMapper.selectById(memberId); | 
|---|
|  |  |  | //                if(MemberLevelEnum.SECOND_LEVEL.getLevelCode(mallMember.getLevel()) >= 5){ | 
|---|
|  |  |  | //                    scoreSum = scoreSum.multiply(new BigDecimal(3)); | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //                if(MemberLevelEnum.SECOND_LEVEL.getLevelCode(mallMember.getLevel()) >= 3 | 
|---|
|  |  |  | //                &&MemberLevelEnum.SECOND_LEVEL.getLevelCode(mallMember.getLevel()) < 5){ | 
|---|
|  |  |  | //                    scoreSum = scoreSum.multiply(new BigDecimal(2.8)); | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //                if(MemberLevelEnum.SECOND_LEVEL.getLevelCode(mallMember.getLevel()) < 3){ | 
|---|
|  |  |  | //                    scoreSum = scoreSum.multiply(new BigDecimal(2.5)); | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | memberWalletService.add(scoreSum, memberId, "totalScore"); | 
|---|
|  |  |  | mallMoneyFlowService.addMoneyFlow( | 
|---|
|  |  |  | memberId, | 
|---|
|  |  |  | scoreSum, | 
|---|
|  |  |  | MoneyFlowTypeEnum.TOTAL_SCORE.getValue(), | 
|---|
|  |  |  | orderInfo.getOrderNo(), | 
|---|
|  |  |  | "", | 
|---|
|  |  |  | scoreSum.toString(), | 
|---|
|  |  |  | memberId, | 
|---|
|  |  |  | 1, | 
|---|
|  |  |  | FlowTypeEnum.TOTAL_SCORE.getValue(), | 
|---|
|  |  |  | 2); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 购买套餐后,升级会员等级 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | if (hasTc) { | 
|---|
|  |  |  | MallMember mallMember = memberMapper.selectById(memberId); | 
|---|
|  |  |  | if (AgentLevelEnum.ZERO_LEVEL.name().equals(mallMember.getLevel())) { | 
|---|
|  |  |  | mallMember.setLevel(AgentLevelEnum.SECOND_LEVEL.name()); | 
|---|
|  |  |  | memberMapper.updateById(mallMember); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 增加支付金额流水 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | mallMoneyFlowService.addMoneyFlow( | 
|---|
|  |  |  | memberId, | 
|---|
|  |  |  | orderInfo.getAmount().subtract(orderInfo.getScoreAmount()).negate(), | 
|---|
|  |  |  | MoneyFlowTypeEnum.PAY.getValue(), | 
|---|
|  |  |  | orderInfo.getOrderNo(), | 
|---|
|  |  |  | FlowTypeEnum.BALANCE.getValue()); | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 减少积分,增加流水 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | int reduce = memberWalletService.reduce(orderInfo.getScoreCnt(), memberId, "prizeScore"); | 
|---|
|  |  |  | if (reduce == 2) { | 
|---|
|  |  |  | throw new FebsException("积分不足"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | mallMoneyFlowService.addMoneyFlow( | 
|---|
|  |  |  | memberId, | 
|---|
|  |  |  | orderInfo.getScoreCnt().negate(), | 
|---|
|  |  |  | MoneyFlowTypeEnum.PAY.getValue(), | 
|---|
|  |  |  | orderInfo.getOrderNo(), | 
|---|
|  |  |  | FlowTypeEnum.PRIZE_SCORE.getValue()); | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 产生一条业绩记录 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | if(achieveSum.compareTo(BigDecimal.ZERO) > 0){ | 
|---|
|  |  |  | MallAchieveRecord mallAchieveRecord = new MallAchieveRecord(); | 
|---|
|  |  |  | mallAchieveRecord.setMemberId(memberId); | 
|---|
|  |  |  | mallAchieveRecord.setAchieveTime(new Date()); | 
|---|
|  |  |  | mallAchieveRecord.setAmount(achieveSum.subtract(orderInfo.getScoreAmount())); | 
|---|
|  |  |  | mallAchieveRecord.setOrderId(orderId); | 
|---|
|  |  |  | mallAchieveRecord.setPayTime(orderInfo.getPayTime()); | 
|---|
|  |  |  | mallAchieveRecordMapper.insert(mallAchieveRecord); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static void main(String[] args) { | 
|---|
|  |  |  | 
|---|
|  |  |  | 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("无法购买套餐"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 使用积分折扣现金 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | 
|---|
|  |  |  | if(scorePercentMaxAmount.compareTo(score) < 0){ | 
|---|
|  |  |  | throw new FebsException("最多可使用"+scorePercentMaxAmount+"积分"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new FebsResponse().success().message("购买套餐不会获得贡献点"); | 
|---|
|  |  |  | //                    throw new FebsException("无法购买套餐"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return new FebsResponse().success(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|