| | |
| | | queryWrapper.selectAs(DiscountMember::getName, Goodsorder::getDiscountName); |
| | | queryWrapper.leftJoin(Member.class, Member::getId ,Goodsorder::getMemberId); |
| | | queryWrapper.leftJoin(DiscountMember.class, DiscountMember::getId ,Goodsorder::getObjId); |
| | | queryWrapper.select("(select max(r.done_date) from refund r where r.obj_id=t.id and r.status=2 ) as refund_date"); |
| | | queryWrapper.select("(select sum(r.money) from refund r where r.obj_id=t.id and r.status=2) as refund_money"); |
| | | queryWrapper.select("(select max(r.done_date) from refund r where r.obj_id=t.id and r.status in(0,1)) as refund_date"); |
| | | queryWrapper.select("(select sum(r.money) from refund r where r.obj_id=t.id and r.status in(0,1)) as refund_money"); |
| | | //时间段筛选 |
| | | if (Objects.nonNull(model.getStartDate())){ |
| | | queryWrapper.ge(Goodsorder::getPayDate, Utils.Date.getStart(model.getStartDate())); |
| | |
| | | homeResponse.setIsStopServe(this.checkTemporaryStop()?1:0); |
| | | homeResponse.setIsBusiness(this.checkBusiness()?0:1); |
| | | homeResponse.setUnBusinessTips("营业时间为"+ systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.BUSINESS_STARTTIME).getCode() +" ~ "+systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.BUSINESS_ENDTIME).getCode()+",请在营业时间内使用本系统"); |
| | | homeResponse.setEleBusinessArea(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.PARK_LAT_LNG_LIST).getCode()); |
| | | |
| | | homeResponse.setAdList(adMapper.selectList(new QueryWrapper<Ad>() |
| | | .eq("isdeleted",Constants.ZERO) |
| | |
| | | Goodsorder goodsorder = this.goodsorderMapper.selectOne(new QueryWrapper<Goodsorder>() |
| | | .eq("member_id",memberId) |
| | | .eq("status",Constants.goodsorderStatus.pay) |
| | | .eq("type",0) |
| | | .last(" limit 1 ")); |
| | | homeResponse.setDepositStatus(Constants.ZERO); |
| | | if(goodsorder!=null){ |
| | |
| | | update.setCloseDate(new Date()); |
| | | update.setCloseInfo(Constants.REFUND_TYPE.get(type).getInfo()); |
| | | update.setCloseUserId(goodsorder.getEditor()); |
| | | update.setType(Constants.ZERO); |
| | | if(Constants.REFUND_TYPE.PLAT_FORCE.getKey() == type){ |
| | | //如果是强制结算 |
| | | update.setCloseType(Constants.ONE); |
| | |
| | | doRefundTransactions(refund); |
| | | //退款乐行 |
| | | int type =Constants.formatIntegerNum(refund.getType()); |
| | | Goodsorder goodsorder = goodsorderMapper.selectById(refund.getObjId()); |
| | | closeGoodsorderDoneNoRefund(goodsorder,refund.getType(),refund.getMoney(),refund.getId(),null); |
| | | /* log.error("========================================"+JSONObject.toJSONString(goodsorder)); |
| | | if(goodsorder ==null || Constants.formatIntegerNum(goodsorder.getStatus()) != Constants.GOODSORDER_STATUS.HAVING_PAY.getKey()){ |
| | | return; |
| | | if(type == 0|| type ==1 || type==2){ |
| | | //如果是阶段退款 |
| | | Goodsorder goodsorder = goodsorderMapper.selectById(refund.getObjId()); |
| | | closeGoodsorderDoneNoRefund(goodsorder,type,refund.getMoney(),refund.getId(),null); |
| | | } |
| | | //进行订单结算业务处理 |
| | | List<MemberRides> memberRides = getMemberRidesForClose(refund.getObjId()); |
| | | //默认结算为押金金额 |
| | | if (!CollectionUtils.isEmpty(memberRides)){ |
| | | //骑行总时长 |
| | | for(MemberRides model :memberRides){ |
| | | MemberRides up = new MemberRides(); |
| | | up.setId(model.getId()); |
| | | up.setActualPrice(model.getActualPrice()); |
| | | up.setCloseDate(goodsorder.getEditDate()); |
| | | up.setCloseStatus(Constants.ONE); |
| | | up.setEditor(goodsorder.getEditor()); |
| | | up.setEditDate(goodsorder.getEditDate()); |
| | | //更新骑行记录的计算金额和状态 |
| | | memberRidesJoinMapper.updateById(up); |
| | | } |
| | | } |
| | | |
| | | Goodsorder update = new Goodsorder(); |
| | | update.setId(goodsorder.getId()); |
| | | update.setStatus(Constants.GOODSORDER_STATUS.CLOSE.getKey()); |
| | | update.setCloseMoney(closeMoney); |
| | | update.setCloseStatus(Constants.ONE); |
| | | update.setCloseDate(new Date()); |
| | | update.setCloseInfo(Constants.REFUND_TYPE.get(refund.getType()).getInfo()); |
| | | update.setCloseUserId(goodsorder.getEditor()); |
| | | if(Constants.REFUND_TYPE.PLAT_FORCE.getKey() == type){ |
| | | //如果是强制结算 |
| | | update.setCloseType(Constants.ONE); |
| | | // LoginUserInfo principal = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | // update.setEditor(principal.getId()); |
| | | }else if(Constants.REFUND_TYPE.NORMAL.getKey() == type){ |
| | | //如果是自行結算 |
| | | update.setCloseType(Constants.ZERO); |
| | | }else{ |
| | | //如果是平台自动结算 |
| | | update.setCloseType(Constants.TWO); |
| | | } |
| | | update.setCloseId(refund.getId()); |
| | | //存储 消费交易流水 |
| | | Transactions transactions = new Transactions(); |
| | | transactions.setId(Constants.getUUID()); |
| | | transactions.setMemberId(goodsorder.getMemberId()); |
| | | transactions.setCreateDate(new Date()); |
| | | transactions.setIsdeleted(Constants.ZERO); |
| | | transactions.setOrderId(goodsorder.getId()); |
| | | transactions.setMoney(goodsorder.getMoney().subtract(Constants.formatDecimalNum(refund.getMoney()))); |
| | | transactions.setType(Constants.TRANSACTIONS_TYPE.CONSUMPTION.getKey()); |
| | | transactions.setDoneDate(new Date()); |
| | | transactions.setTitle(Constants.TRANSACTIONS_TYPE.CONSUMPTION.getName()); |
| | | transactions.setContent(Constants.TRANSACTIONS_TYPE.CONSUMPTION.getInfo()); |
| | | transactions.setBalance(BigDecimal.ZERO); |
| | | transactions.setObjId(goodsorder.getId()); |
| | | transactions.setObjType(Constants.ONE); |
| | | transactionsMapper.insert(transactions); |
| | | //修改订单信息 |
| | | goodsorderMapper.updateById(update);*/ |
| | | } |
| | | } |
| | | |
| | | private void doRefundTransactions(Refund refund ) { |
| | | //存储交易流水表 |
| | |
| | | if(discountMember.getSurplusTime() >= durationSum){ |
| | | discountLog.setRideTime(durationSum); |
| | | discountLog.setRidePrice(closeMoney); |
| | | discountLogMapper.insert(discountLog); |
| | | topRides.setActualPrice(BigDecimal.ZERO); |
| | | closeMoney = BigDecimal.ZERO; |
| | | }else{ |
| | |
| | | if(goodsorder == null){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "对不起,订单信息不存在,请刷新页面重试!"); |
| | | } |
| | | if (Constants.formatIntegerNum(goodsorder.getStatus()) != Constants.GOODSORDER_STATUS.CLOSE.getKey()){ |
| | | if (Constants.equalsInteger(goodsorder.getType(),Constants.ZERO) && |
| | | Constants.formatIntegerNum(goodsorder.getStatus()) != Constants.GOODSORDER_STATUS.CLOSE.getKey()){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,该订单请结算后再退款~"); |
| | | } |
| | | if (Constants.equalsInteger(goodsorder.getType(),Constants.ONE) && |
| | | Constants.formatIntegerNum(goodsorder.getStatus()) != Constants.GOODSORDER_STATUS.HAVING_PAY.getKey()){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,该订单请支付后再退款~"); |
| | | } |
| | | QueryWrapper<Refund> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda() |
| | | .eq(Refund::getObjId,goodsorderBackDTO.getOrderId()) |
| | | .eq(Refund::getStatus,Constants.TWO) |
| | | .in(Refund::getStatus,Constants.TWO,Constants.ZERO) |
| | | .eq(Refund::getIsdeleted,Constants.ZERO) ; |
| | | wrapper.select("sum(money) as money").last(" limit 1"); |
| | | Refund total = refundMapper.selectOne(wrapper); |
| | |
| | | refundDTO.setType(Constants.REFUND_TYPE.BACK.getKey()); |
| | | //退货退款 查看套餐订单状态 更新订单信息 |
| | | if(Constants.equalsInteger(goodsorderBackDTO.getBackType(),Constants.ZERO)&&Constants.equalsInteger(goodsorder.getType(),Constants.ONE)){ |
| | | DiscountMember discountMember = discountMemberMapper.selectById(goodsorder.getObjId()); |
| | | DiscountMember discountMember = discountMemberMapper.selectOne(new QueryWrapper<DiscountMember>().lambda(). |
| | | eq(DiscountMember::getGoodsorderId,goodsorder.getId()) |
| | | .eq(DiscountMember::getIsdeleted,Constants.ZERO) |
| | | .last("limit 1")); |
| | | if(Objects.isNull(discountMember)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"未查询到套餐卡信息"); |
| | | } |
| | |
| | | QueryWrapper<Refund> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda() |
| | | .eq(Refund::getObjId,orderId) |
| | | .eq(Refund::getStatus,Constants.TWO) |
| | | .in(Refund::getStatus,Constants.TWO,Constants.ZERO) |
| | | .eq(Refund::getIsdeleted,Constants.ZERO) ; |
| | | wrapper.select("sum(money) as money").last(" limit 1"); |
| | | Refund total = refundMapper.selectOne(wrapper); |
| | |
| | | qry.setStatus(Constants.goodsorderStatus.pay); |
| | | qry.setMemberId(memberId); |
| | | qry.setIsdeleted(Constants.ZERO); |
| | | qry.setType(Constants.ZERO); |
| | | if(goodsorderMapper.selectCount(new QueryWrapper<>(qry))>Constants.ZERO){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"已支付过定金,无法重复该操作"); |
| | | } |
| | |
| | | * 获取当前可使用的套餐 |
| | | * @param memberId |
| | | */ |
| | | @Override |
| | | public DiscountMember getUseDiscount(String memberId,Integer driveTime){ |
| | | String today = DateUtil.getToday(); |
| | | //判断今天是否为节假日 |
| | |
| | | Integer holiday = holidaysMapper.selectCount(new QueryWrapper<>(holidays))>0?1:0; |
| | | List<DiscountMember> discountMemberList = discountMemberMapper.selectJoinList(DiscountMember.class,new MPJLambdaWrapper<DiscountMember>() |
| | | .selectAll(DiscountMember.class) |
| | | .select(" select sum(d.ride_time) from discount_log d where and d.discount_member_id = discount_member.id " + |
| | | "and d.isdeleted = 0 and d.type = 0 and EXTRACT(DAY FROM d.create_date) = EXTRACT(DAY FROM CURRENT_DATE) " , DiscountMember::getUseTime)//查询今日已使用时间 |
| | | .select(" ( select sum(d.ride_time) from discount_log d where d.discount_member_id = t.id " + |
| | | "and d.isdeleted = 0 and d.type = 0 and EXTRACT(DAY FROM d.create_date) = EXTRACT(DAY FROM CURRENT_DATE) ) " , DiscountMember::getUseTime)//查询今日已使用时间 |
| | | .eq(DiscountMember::getStatus,Constants.ZERO) |
| | | .eq(DiscountMember::getMemberId,memberId) |
| | | .ge(DiscountMember::getUseStartDate, Utils.Date.getStart(DateUtil.StringToDate(today))) |
| | | .le(DiscountMember::getUseEndDate, Utils.Date.getEnd(DateUtil.StringToDate(today))) |
| | | .le(DiscountMember::getUseStartDate, Utils.Date.getStart(DateUtil.stringToDate(today,"yyyy-MM-dd"))) |
| | | .ge(DiscountMember::getUseEndDate, Utils.Date.getEnd(DateUtil.stringToDate(today,"yyyy-MM-dd"))) |
| | | .eq(Constants.equalsInteger(holiday,Constants.ONE),DiscountMember::getUseHoliday,Constants.ONE) |
| | | .orderByDesc(DiscountMember::getLimitType) |
| | | .orderByDesc(DiscountMember::getLimitTime) |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | public void autCancel(){ |
| | | goodsorderMapper.update(null,new UpdateWrapper<Goodsorder>().lambda() |
| | | .set(Goodsorder::getStatus,Constants.GOODSORDER_STATUS.CANCEL.getKey()) |
| | | .set(Goodsorder::getEditDate,DateUtil.getCurrDateTime()) |
| | | .eq(Goodsorder::getStatus,Constants.GOODSORDER_STATUS.UN_PAY.getKey()) |
| | | .apply(" NOW() >= create_date + INTERVAL '30 min' ") |
| | | ); |
| | | } |
| | | |
| | | } |