jiangping
2025-02-28 d7aaa1eae5335b38ba1e8e9a465ef9099bc334c5
server/services/src/main/java/com/doumee/service/business/impl/GoodsorderServiceImpl.java
@@ -73,8 +73,6 @@
@Slf4j
public class GoodsorderServiceImpl implements GoodsorderService {
    @Autowired
    private GoodsorderMapper goodsorderMapper;
@@ -259,7 +257,6 @@
            MPJLambdaWrapper<Goodsorder> queryWrapper = initQueryParamByModel(model);
            queryWrapper.orderByAsc(Goodsorder::getPayDate);
           goodsorderList = goodsorderJoinMapper.selectJoinList(GoodsorderExportVO.class,queryWrapper);
        }else{
            MPJLambdaWrapper<Refund> queryWrapper = new MPJLambdaWrapper<>();
            queryWrapper.selectAs(Refund::getMoney,GoodsorderExportVO::getRefundMoney);
@@ -298,9 +295,8 @@
        MPJLambdaWrapper<Goodsorder> queryWrapper = new MPJLambdaWrapper<>();
        queryWrapper.selectAll(Goodsorder.class);
        queryWrapper.selectAs(Member::getOpenid, Goodsorder::getOpenid);
        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 r.name from discount_member r where r.isdeleted=0  and r.goodsorder_id=t.id limit 1) as discountName");
        queryWrapper.select("(select max(r.done_date) from refund r where r.obj_id=t.id  and  r.status in(0,2)) as refund_date");
        queryWrapper.select("(select sum(r.money) from refund r where r.obj_id=t.id and r.status in(0,2)) as refund_money");
        //时间段筛选
@@ -353,7 +349,6 @@
        return PageData.from(goodsorderIPage);
    }
    @Override
    public long count(Goodsorder goodsorder) {
        QueryWrapper<Goodsorder> wrapper = new QueryWrapper<>(goodsorder);
@@ -376,6 +371,7 @@
        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)
@@ -405,6 +401,7 @@
        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){
@@ -543,7 +540,9 @@
            goodsorderDetailVO.setMember(member);
        }
        //查询商品信息
        DiscountMember discountMember = discountMemberMapper.selectById(goodsorder.getObjId());
        DiscountMember discountMember = discountMemberMapper.selectOne(new QueryWrapper<DiscountMember>().lambda()
                .eq(DiscountMember::getIsdeleted,Constants.ZERO)
                .eq(DiscountMember::getGoodsorderId,goodsorder.getId()));
        if(Objects.nonNull(discountMember)){
            goodsorderDetailVO.setDiscountMember(discountMember);
        }
@@ -673,6 +672,7 @@
        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);
@@ -833,7 +833,6 @@
            if(discountMember.getSurplusTime() >= durationSum){
                discountLog.setRideTime(durationSum);
                discountLog.setRidePrice(closeMoney);
                discountLogMapper.insert(discountLog);
                topRides.setActualPrice(BigDecimal.ZERO);
                closeMoney = BigDecimal.ZERO;
            }else{
@@ -1119,6 +1118,7 @@
        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(),"已支付过定金,无法重复该操作");
        }
@@ -1513,6 +1513,7 @@
     * 获取当前可使用的套餐
     * @param memberId
     */
    @Override
    public DiscountMember getUseDiscount(String memberId,Integer driveTime){
        String today = DateUtil.getToday();
        //判断今天是否为节假日
@@ -1523,12 +1524,12 @@
        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,"yyyy-MM-dd")))
                .le(DiscountMember::getUseEndDate, Utils.Date.getEnd(DateUtil.stringToDate(today,"yyyy-MM-dd")))
                .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)
@@ -1580,4 +1581,14 @@
    }
    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'  ")
        );
    }
}