| | |
| | | orderInfo.setStatus(OrderStatusEnum.WAIT_PAY.getValue()); |
| | | orderInfo.setRemark(addOrderDto.getRemark()); |
| | | orderInfo.setOrderType(addOrderDto.getOrderType()); |
| | | orderInfo.setDeliveryType(2); |
| | | orderInfo.setDeliveryType(addOrderDto.getDeliveryType() == null ? 2 : addOrderDto.getDeliveryType()); |
| | | if (CollUtil.isEmpty(addOrderDto.getItems())) { |
| | | throw new FebsException("参数错误"); |
| | | } |
| | |
| | | |
| | | orderInfo.setPayOrderNo(payOrderDto.getRollId().toString()); |
| | | orderInfo.setPayMethod("兑换券支付"); |
| | | orderInfo.setStatus(OrderStatusEnum.WAIT_SHIPPING.getValue()); |
| | | orderInfo.setPayTime(new Date()); |
| | | orderInfo.setPayResult("1"); |
| | | |
| | | mallMoneyFlowService.addMoneyFlow(member.getId(), orderInfo.getAmount().negate(), MoneyFlowTypeEnum.ROLL_PAY.getValue(), |
| | | orderInfo.getOrderNo(), FlowTypeEnum.PRIZE_SCORE.getValue()); |
| | | break; |
| | | default: |
| | | /** |
| | | * 余额加微信 |
| | | */ |
| | | case "2,1": |
| | | MallMemberWallet mallMemberWalletThree = mallMemberWalletMapper.selectWalletByMemberId(member.getId()); |
| | | BigDecimal balanceThree = mallMemberWalletThree.getBalance(); |
| | | BigDecimal amountThree = orderInfo.getAmount(); |
| | | |
| | | int reduceThree = memberWalletService.reduce(balanceThree, member.getId(), "balance"); |
| | | if (reduceThree == 2) { |
| | | throw new FebsException("余额不足"); |
| | | } |
| | | mallMoneyFlowService.addMoneyFlow(member.getId(), balanceThree.negate(), MoneyFlowTypeEnum.PAY.getValue(), |
| | | orderInfo.getOrderNo(), FlowTypeEnum.BALANCE.getValue(),"余额支付",2); |
| | | |
| | | //实际支付余额 |
| | | BigDecimal amountActualThree = amountThree.subtract(balanceThree).setScale(2, BigDecimal.ROUND_DOWN); |
| | | orderInfo.setAmount(amountActualThree); |
| | | |
| | | BrandWCPayRequestData brandWCPayRequestDataThree = null; |
| | | try { |
| | | brandWCPayRequestDataThree = iXcxPayService.startPayment(orderInfo); |
| | | } catch (Exception e) { |
| | | throw new FebsException("支付失败"); |
| | | } |
| | | wxResultStr = JSONUtil.toJsonStr(brandWCPayRequestDataThree); |
| | | payResultStr = brandWCPayRequestDataThree.getPrepay_id(); |
| | | orderInfo.setPayMethod("余额加微信"); |
| | | amountActualMsg = amountThree.toString(); |
| | | break; |
| | | /** |
| | | * 积分加余额 |
| | | */ |
| | | case "3,2": |
| | | /** |
| | | * 获取用户的当前积分 |
| | | */ |
| | | MallMemberWallet mallMemberWalletNOne = mallMemberWalletMapper.selectWalletByMemberId(member.getId()); |
| | | BigDecimal scoreOne = mallMemberWalletNOne.getScore(); |
| | | BigDecimal amountOne = orderInfo.getAmount(); |
| | | //积分兑换比例 |
| | | DataDictionaryCustom scoreChangeOneDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.SCORE_CHANGE.getType(), |
| | | DataDictionaryEnum.SCORE_CHANGE.getCode() |
| | | ); |
| | | BigDecimal scoreChangeOne = StrUtil.isEmpty(scoreChangeOneDic.getValue()) ? new BigDecimal("1") : new BigDecimal(scoreChangeOneDic.getValue()); |
| | | int reduceOne = memberWalletService.reduce(scoreOne, member.getId(), "score"); |
| | | if (reduceOne == 2) { |
| | | throw new FebsException("积分余额不足"); |
| | | } |
| | | BigDecimal scoreToAmountOne = scoreOne.divide(scoreChangeOne, 2, BigDecimal.ROUND_DOWN); |
| | | //实际支付余额 |
| | | BigDecimal amountActualOne = amountOne.subtract(scoreToAmountOne).setScale(2, BigDecimal.ROUND_DOWN); |
| | | int balanceOne = memberWalletService.reduce(amountActualOne, member.getId(), "balance"); |
| | | if (balanceOne == 2) { |
| | | throw new FebsException("余额不足"); |
| | | } |
| | | orderInfo.setPayOrderNo(orderInfo.getOrderNo()); |
| | | orderInfo.setStatus(OrderStatusEnum.WAIT_SHIPPING.getValue()); |
| | | orderInfo.setPayTime(new Date()); |
| | | orderInfo.setPayResult("1"); |
| | | orderInfo.setDeliveryState(OrderDeliveryStateEnum.DELIVERY_WAIT.getValue()); |
| | | mallMoneyFlowService.addMoneyFlow(member.getId(), amountActualOne.negate(), MoneyFlowTypeEnum.PAY.getValue(), |
| | | orderInfo.getOrderNo(), FlowTypeEnum.BALANCE.getValue(),"余额支付",2); |
| | | amountActualMsg = amountActualOne.toString(); |
| | | |
| | | orderInfo.setPayMethod("积分加余额"); |
| | | mallMoneyFlowService.addMoneyFlow(member.getId(), scoreOne.negate(), |
| | | MoneyFlowTypeEnum.SCORE_PAY.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.SCORE.getValue(),"积分支付",2); |
| | | break; |
| | | /** |
| | | * 积分加微信 |
| | | */ |
| | | case "3,1": |
| | | MallMemberWallet mallMemberWalletNTwo = mallMemberWalletMapper.selectWalletByMemberId(member.getId()); |
| | | BigDecimal scoreTwo = mallMemberWalletNTwo.getScore(); |
| | | BigDecimal amountTwo = orderInfo.getAmount(); |
| | | //积分兑换比例 |
| | | DataDictionaryCustom scoreChangeTwoDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.SCORE_CHANGE.getType(), |
| | | DataDictionaryEnum.SCORE_CHANGE.getCode() |
| | | ); |
| | | BigDecimal scoreChangeTwo = StrUtil.isEmpty(scoreChangeTwoDic.getValue()) ? new BigDecimal("1") : new BigDecimal(scoreChangeTwoDic.getValue()); |
| | | int reduceTwo = memberWalletService.reduce(scoreTwo, member.getId(), "score"); |
| | | if (reduceTwo == 2) { |
| | | throw new FebsException("积分余额不足"); |
| | | } |
| | | mallMoneyFlowService.addMoneyFlow(member.getId(), scoreTwo.negate(), |
| | | MoneyFlowTypeEnum.SCORE_PAY.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.SCORE.getValue(),"积分支付",2); |
| | | |
| | | BigDecimal scoreToAmountTwo = scoreTwo.divide(scoreChangeTwo, 2, BigDecimal.ROUND_DOWN); |
| | | //实际支付余额 |
| | | BigDecimal amountActualTwo = amountTwo.subtract(scoreToAmountTwo).setScale(2, BigDecimal.ROUND_DOWN); |
| | | orderInfo.setAmount(amountActualTwo); |
| | | |
| | | BrandWCPayRequestData brandWCPayRequestDataTwo = null; |
| | | try { |
| | | brandWCPayRequestDataTwo = iXcxPayService.startPayment(orderInfo); |
| | | } catch (Exception e) { |
| | | throw new FebsException("支付失败"); |
| | | } |
| | | wxResultStr = JSONUtil.toJsonStr(brandWCPayRequestDataTwo); |
| | | payResultStr = brandWCPayRequestDataTwo.getPrepay_id(); |
| | | orderInfo.setPayMethod("积分加微信"); |
| | | amountActualMsg = amountActualTwo.toString(); |
| | | break; |
| | | default: |
| | | throw new FebsException("请选择正确的支付方式"); |
| | | |
| | | } |
| | | if(ObjectUtil.isNotEmpty(payOrderDto.getUseTime())){ |
| | | orderInfo.setUseTime(DateUtil.parseDate(payOrderDto.getUseTime())); |
| | | } |
| | | |
| | | //订单支付成功产生一个提货码 |
| | |
| | | stringBuffer.append("@"); |
| | | stringBuffer.append(amountActualMsg); |
| | | agentProducer.sendOrderGetMsg(stringBuffer.toString()); |
| | | agentProducer.sendRollSendMsg(orderInfo.getId()); |
| | | |
| | | // OrderStateDto orderStateDto = new OrderStateDto(); |
| | | // orderStateDto.setOrderNo(orderInfo.getOrderNo()); |