| | |
| | | import com.doumee.dao.business.web.response.*; |
| | | import com.doumee.dao.business.join.MemberRidesJoinMapper; |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.dao.system.model.SystemUser; |
| | | import com.doumee.service.business.GoodsorderService; |
| | | import com.doumee.service.business.MemberRidesService; |
| | | import com.doumee.service.business.PricingRuleService; |
| | |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.checkerframework.checker.units.qual.A; |
| | | import org.checkerframework.checker.units.qual.C; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | |
| | | @Autowired |
| | | private DiscountLogMapper discountLogMapper; |
| | | @Autowired |
| | | private DiscountMapper discountMapper; |
| | | |
| | | @Autowired |
| | | GoodsorderJoinMapper goodsorderJoinMapper; |
| | |
| | | if (Objects.nonNull(model.getEndDate())){ |
| | | queryWrapper.le( Goodsorder::getPayDate, Utils.Date.getEnd(model.getEndDate())); |
| | | } |
| | | |
| | | // queryWrapper.eq(model.getPayStatus() !=null,Goodsorder::getPayStatus,model.getPayStatus()); |
| | | // queryWrapper.like(model.getCode() !=null,Goodsorder::getCode,model.getCode()); |
| | | // queryWrapper.like(model.getId() !=null,Goodsorder::getId,model.getId()); |
| | | // queryWrapper.eq(model.getStatus() !=null,Goodsorder::getStatus,model.getStatus()); |
| | | // queryWrapper.like(model.getOnlineOrderid() !=null,Goodsorder::getOnlineOrderid,model.getOnlineOrderid()); |
| | | // queryWrapper.like(model.getOpenid() !=null,Member::getOpenid,model.getOpenid()); |
| | | queryWrapper.eq(Goodsorder::getIsdeleted,Constants.ZERO); |
| | | queryWrapper.eq(Goodsorder::getPayStatus,Constants.ONE); |
| | | queryWrapper.orderByAsc(Goodsorder::getPayDate); |
| | |
| | | queryWrapper.eq(Objects.nonNull(pageWrap.getModel().getType()),Goodsorder::getType,pageWrap.getModel().getType()); |
| | | queryWrapper.select("(select sum(er.discount_price) from member_rides er where er.ordre_id=t.id and er.isdeleted=0) as discountMoney," + |
| | | "(select er.status from member_rides er where er.ordre_id=t.id order by er.create_date desc limit 1) as memberRidesStatus"); |
| | | queryWrapper.select("( select s.realname from refund r left join system_user s on r.creator = s.id where r.obj_id = t.id order by r.id desc limit 1 ) ",Goodsorder::getRefundUserName); |
| | | if(Objects.nonNull(pageWrap.getModel().getCloseStatus()) && pageWrap.getModel().getCloseStatus().equals(Constants.ZERO)){ |
| | | queryWrapper.ne(Goodsorder::getStatus,Constants.GOODSORDER_STATUS.CLOSE.getKey()); |
| | | } |
| | |
| | | .eq("status",Constants.ZERO) |
| | | .orderByAsc("sortnum") |
| | | ));; |
| | | homeResponse.setDiscountList( |
| | | discountMapper.selectList(new QueryWrapper<Discount>().lambda() |
| | | .eq(Discount::getIsdeleted,Constants.ZERO) |
| | | .eq(Discount::getStatus,Constants.ZERO) |
| | | .orderByDesc(Discount::getId) |
| | | .last(" limit 3 ") |
| | | ) |
| | | ); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(homeResponse.getDiscountList())){ |
| | | for (Discount discount:homeResponse.getDiscountList()) { |
| | | discount.setDayPrice(discount.getPrice().divide(new BigDecimal(Integer.toString(discount.getUseDays())),2)); |
| | | } |
| | | } |
| | | if(!Objects.isNull(homeResponse.getAdList())&&homeResponse.getAdList().size()>Constants.ZERO){ |
| | | homeResponse.getAdList().forEach(i->{ |
| | | i.setImgfullurl(fullPath + i.getImgurl()); |
| | |
| | | |
| | | @Override |
| | | public GoodsorderDetailDTO getGoodsorderDetailDTO(String id) { |
| | | |
| | | List<PayOrderDTO> payOrderDTOList = new ArrayList<>(); |
| | | Goodsorder goodsorder = goodsorderMapper.selectById(id); |
| | | if(goodsorder == null){ |
| | |
| | | goodsorderDetailDTO.setModel(goodsorder);//订单对象 |
| | | return goodsorderDetailDTO; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public GoodsorderDetailVO getGoodsorderDetailForDisCount(String id){ |
| | | GoodsorderDetailVO goodsorderDetailVO = new GoodsorderDetailVO(); |
| | | Goodsorder goodsorder = goodsorderMapper.selectById(id); |
| | | if(goodsorder == null){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY ); |
| | | } |
| | | if(Constants.equalsInteger(goodsorder.getType(),Constants.ZERO)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED); |
| | | } |
| | | goodsorderDetailVO.setGoodsOrder(goodsorder); |
| | | Member member = memberMapper.selectById(goodsorder.getMemberId()); |
| | | if(Objects.nonNull(member)){ |
| | | goodsorderDetailVO.setMember(member); |
| | | } |
| | | //查询商品信息 |
| | | DiscountMember discountMember = discountMemberMapper.selectById(goodsorder.getObjId()); |
| | | if(Objects.nonNull(discountMember)){ |
| | | goodsorderDetailVO.setDiscountMember(discountMember); |
| | | } |
| | | //查询所有有退款记录 |
| | | List<Refund> refunds = refundJoinMapper.selectJoinList(Refund.class, |
| | | new MPJLambdaWrapper<Refund>() |
| | | .selectAll(Refund.class) |
| | | .selectAs(SystemUser::getRealname,Refund::getCreatorName) |
| | | .leftJoin(SystemUser.class,SystemUser::getId,Refund::getCreator) |
| | | .eq(Refund::getObjId,goodsorder.getId()) |
| | | .orderByDesc(Refund::getId) |
| | | ); |
| | | goodsorderDetailVO.setRefundList(refunds); |
| | | |
| | | return goodsorderDetailVO; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void forceCloseGoodsorder(String orderId) { |
| | | //查询订单 信息 |
| | |
| | | goodsorder.setCreateDate(new Date()); |
| | | goodsorder.setIsdeleted(Constants.ZERO); |
| | | goodsorder.setCode(goodsorder.getId()); |
| | | goodsorder.setType(Constants.ZERO); |
| | | goodsorder.setMemberId(memberId); |
| | | goodsorder.setMoney(new BigDecimal(systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.RENT_DEPOSIT).getCode()).multiply(new BigDecimal(100))); |
| | | goodsorder.setStatus(Constants.goodsorderStatus.waitPay); |
| | |
| | | } catch (Exception e) { |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,发起支付失败~"); |
| | | } |
| | | |
| | | return response; |
| | | } |
| | | |
| | | private Object getWxPayResponse(Goodsorder goodsorder,String openid) throws Exception { |
| | | |
| | | @Override |
| | | public Object createDiscountOrderPay(String memberId,String discountId){ |
| | | Member member = memberMapper.selectById(memberId); |
| | | if(Objects.isNull(member)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到用户对象信息"); |
| | | } |
| | | Discount discount = discountMapper.selectById(discountId); |
| | | this.checkDiscountSaleDate(discount); |
| | | String discountMemberId = Constants.getUUID(); |
| | | String goodsorderId = Constants.getUUID(); |
| | | DiscountMember discountMember = new DiscountMember(); |
| | | BeanUtils.copyProperties(discount,discountMember); |
| | | discountMember.setCreator(null); |
| | | discountMember.setId(discountMemberId); |
| | | discountMember.setCreateDate(new Date()); |
| | | discountMember.setEditDate(new Date()); |
| | | discountMember.setEditor(null); |
| | | discountMember.setMemberId(memberId); |
| | | discountMember.setStatus(Constants.TWO); |
| | | discountMember.setGoodsorderId(goodsorderId); |
| | | discountMemberMapper.insert(discountMember); |
| | | |
| | | Goodsorder goodsorder = new Goodsorder(); |
| | | goodsorder.setId(goodsorderId); |
| | | goodsorder.setCreateDate(new Date()); |
| | | goodsorder.setIsdeleted(Constants.ZERO); |
| | | goodsorder.setCode(goodsorder.getId()); |
| | | goodsorder.setMemberId(memberId); |
| | | goodsorder.setType(Constants.ONE); |
| | | goodsorder.setMoney(discount.getPrice().multiply(new BigDecimal(100))); |
| | | goodsorder.setStatus(Constants.goodsorderStatus.waitPay); |
| | | goodsorder.setPreOrderid(goodsorder.getId()); |
| | | goodsorder.setPayStatus(Constants.goodsorderPayStatus.waitPay); |
| | | goodsorder.setPayWay(Constants.ZERO); |
| | | goodsorder.setObjType(Constants.ZERO); |
| | | goodsorder.setObjId(discount.getId()); |
| | | this.goodsorderMapper.insert(goodsorder); |
| | | //调起支付 |
| | | Object response = null; |
| | | Object response = null; |
| | | try { |
| | | response = getWxPayResponse(goodsorder,member.getOpenid()); |
| | | } catch (Exception e) { |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,发起支付失败~"); |
| | | } |
| | | return response; |
| | | |
| | | } |
| | | |
| | | public void checkDiscountSaleDate(Discount discount){ |
| | | if(Objects.isNull(discount)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到套餐信息"); |
| | | } |
| | | if(!(Constants.equalsInteger(discount.getIsdeleted(),Constants.ZERO) |
| | | ||Constants.equalsInteger(discount.getStatus(),Constants.ZERO))){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"套餐已下架,无法进行购买,请刷新查看"); |
| | | } |
| | | if(!(discount.getStartDate().getTime() < System.currentTimeMillis() |
| | | && Utils.Date.getEnd(discount.getEndDate()).getTime() > System.currentTimeMillis() )){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"套餐开放时间未到,无法进行购买"); |
| | | } |
| | | //验证是否超过今日可售卖数量 |
| | | if(Objects.nonNull(discount.getSaleDayLimit())){ |
| | | if(goodsorderMapper.selectCount(new QueryWrapper<Goodsorder>().lambda() |
| | | .eq(Goodsorder::getType,Constants.ONE) |
| | | .eq(Goodsorder::getObjId,discount.getId()) |
| | | .in(Goodsorder::getStatus,Constants.ZERO,Constants.ONE) |
| | | .apply(" EXTRACT(DAY FROM create_date) = EXTRACT(DAY FROM CURRENT_DATE) ") |
| | | )>=discount.getSaleDayLimit()){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"套餐今日发行量已售罄,请明日查看!"); |
| | | } |
| | | } |
| | | if(Objects.nonNull(discount.getSaleLimit())){ |
| | | if(goodsorderMapper.selectCount(new QueryWrapper<Goodsorder>().lambda() |
| | | .eq(Goodsorder::getType,Constants.ONE) |
| | | .eq(Goodsorder::getObjId,discount.getId()) |
| | | .in(Goodsorder::getStatus,Constants.ZERO,Constants.ONE) |
| | | .apply(" EXTRACT(YEAR FROM create_date) = EXTRACT(YEAR FROM CURRENT_DATE) ") |
| | | )>=discount.getSaleDayLimit()){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"套餐发行量已售罄!"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | private Object getWxPayResponse(Goodsorder goodsorder,String openid){ |
| | | //调起支付 |
| | | Object response = null; |
| | | PrepayRequest request = new PrepayRequest(); |
| | | request.setAttach("createGoodsOrder"); |
| | | request.setDescription("森林公园自行车骑行押金支付"); |
| | | request.setDescription(Constants.equalsInteger(goodsorder.getType(),Constants.ZERO)?"森林公园自行车骑行押金支付":"森林公园自行车购买骑行套餐支付"); |
| | | request.setSpMchid(WxMiniConfig.wxProperties.getMchId()); |
| | | request.setSpAppid(WxMiniConfig.wxProperties.getAppId()); |
| | | request.setSubMchid(WxMiniConfig.wxProperties.getSubMchId()); |
| | |
| | | // 跟之前下单示例一样,填充预下单参数 |
| | | PrepayWithRequestPaymentResponse resParam = WxMiniConfig.jsapiExtService.prepayWithRequestPayment(request,WxMiniConfig.wxProperties.getSubAppId()); |
| | | response =resParam; |
| | | |
| | | return response; |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | return ("处理成功!"); |
| | | } |
| | | goodsorder.setOnlineOrderid(paymentNo); |
| | | if(Constants.equalsInteger(goodsorder.getType(),Constants.ZERO)){ |
| | | this.dealGoodsOrderCallBack(goodsorder); |
| | | }else{ |
| | | this.dealDiscountOrderCallBack(goodsorder); |
| | | } |
| | | return ("处理成功!"); |
| | | } |
| | | |
| | | public void dealDiscountOrderCallBack(Goodsorder goodsorder){ |
| | | goodsorder.setPayStatus(Constants.goodsorderPayStatus.pay); |
| | | goodsorder.setStatus(Constants.goodsorderStatus.pay); |
| | | goodsorder.setPayDate(new Date()); |
| | | goodsorder.setEditDate(new Date()); |
| | | goodsorderMapper.updateById(goodsorder); |
| | | |
| | | DiscountMember discountMember = discountMemberMapper.selectOne(new QueryWrapper<DiscountMember>().lambda() |
| | | .eq(DiscountMember::getGoodsorderId,goodsorder.getId()).last(" limit 1 ")); |
| | | discountMemberMapper.update(null,new UpdateWrapper<DiscountMember>().lambda() |
| | | .set(DiscountMember::getStatus,Constants.ZERO) |
| | | .eq(DiscountMember::getId,discountMember.getId()) |
| | | ); |
| | | Constants.TRANSACTIONS_TYPE discountConstants = Constants.TRANSACTIONS_TYPE.DISCOUNT; |
| | | //存储交易流水表 |
| | | Transactions transactions = new Transactions(); |
| | | transactions.setMemberId(goodsorder.getMemberId()); |
| | | transactions.setCreateDate(new Date()); |
| | | transactions.setIsdeleted(Constants.ZERO); |
| | | transactions.setOrderId(goodsorder.getId()); |
| | | transactions.setMoney(goodsorder.getMoney()); |
| | | transactions.setType(discountConstants.getKey()); |
| | | transactions.setPreOrderid(goodsorder.getPreOrderid()); |
| | | transactions.setOnlineOrderid(goodsorder.getOnlineOrderid()); |
| | | transactions.setDoneDate(new Date()); |
| | | transactions.setTitle(discountConstants.getName()); |
| | | transactions.setContent(discountConstants.getInfo()); |
| | | //transactions.setContent(discountMember.getName() +" 有效期" + DateUtil.dateToString(discountMember.getUseStartDate(),"yyyy-MM-dd") +"-"+DateUtil.dateToString(discountMember.getUseEndDate(),"yyyy-MM-dd")); |
| | | transactions.setBalance(goodsorder.getMoney()); |
| | | transactions.setObjId(discountMember.getId()); |
| | | transactions.setObjType(Constants.TWO); |
| | | transactionsMapper.insert(transactions); |
| | | } |
| | | |
| | | |
| | | public void dealGoodsOrderCallBack(Goodsorder goodsorder){ |
| | | goodsorder.setPayStatus(Constants.goodsorderPayStatus.pay); |
| | | goodsorder.setStatus(Constants.goodsorderStatus.pay); |
| | | goodsorder.setPayDate(new Date()); |
| | |
| | | transactions.setObjId(goodsorder.getId()); |
| | | transactions.setObjType(Constants.ZERO); |
| | | transactionsMapper.insert(transactions); |
| | | return ("处理成功!"); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |