| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.config.wx.SendWxMessage; |
| | | import com.doumee.config.wx.WxMiniConfig; |
| | | import com.doumee.config.wx.WxMiniUtilService; |
| | | import com.doumee.core.constants.Constants; |
| | |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.dao.dto.*; |
| | | import com.doumee.dao.vo.OrderReleaseVO; |
| | | import com.doumee.service.business.AliSmsService; |
| | | import com.doumee.service.business.OrdersService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | |
| | | import com.wechat.pay.java.service.refund.model.RefundNotification; |
| | | import jodd.util.StringUtil; |
| | | import lombok.With; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import nonapi.io.github.classgraph.json.Id; |
| | | import org.apache.poi.sl.image.ImageHeaderEMF; |
| | | import org.checkerframework.checker.units.qual.A; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 订单信息记录Service实现 |
| | | * @author 江蹄蹄 |
| | | * @date 2025/07/09 12:00 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class OrdersServiceImpl implements OrdersService { |
| | | |
| | |
| | | @Autowired |
| | | private WxMiniUtilService wxMiniUtilService; |
| | | |
| | | @Autowired |
| | | private SendWxMessage sendWxMessage; |
| | | |
| | | @Autowired |
| | | private AliSmsService aliSmsService; |
| | | |
| | | @Resource |
| | | private RedisTemplate<String,Object> redisTemplate; |
| | | |
| | |
| | | OrderReleaseVO orderReleaseVO = new OrderReleaseVO(); |
| | | Object objects = null; |
| | | this.initVerification(orders); |
| | | Member member = memberMapper.selectById(orders.getMember().getId()); |
| | | if(Objects.isNull(member)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"用户信息异常"); |
| | | } |
| | | |
| | | orders.setCreateTime(new Date()); |
| | | orders.setUpdateTime(orders.getUpdateTime()); |
| | | orders.setPayStatus(Constants.ZERO); |
| | |
| | | if(Objects.isNull(category)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"参数配置错误,请联系管理员"); |
| | | } |
| | | orders.setPayAccount(orders.getEstimatedAccount()); |
| | | Long tcje = Long.valueOf(new BigDecimal(orders.getPayAccount().toString()).multiply(orders.getPlatformRata()).intValue()); |
| | | orders.setReceiveAccount(orders.getPayAccount() - tcje); |
| | | //用餐订单 |
| | | if(Constants.equalsInteger(orders.getType(),Constants.TWO)){ |
| | | orders.setStatus(Constants.ordersStatus.waitPay.getKey()); |
| | | orders.setOutTradeNo(UUID.randomUUID().toString().replace("-","")); |
| | | orders.setPayAccount(orders.getEstimatedAccount()); |
| | | //唤起支付业务 |
| | | objects = this.getWxPayResponse(orders,orders.getMember().getOpenid()); |
| | | objects = this.getWxPayResponse(orders,member.getOpenid()); |
| | | orderReleaseVO.setObject(objects); |
| | | }else{ |
| | | orders.setStatus(Constants.ordersStatus.wait.getKey()); |
| | | } |
| | | orders.setOriginPriceNum1(orders.getPriceNum1()); |
| | | orders.setOriginPriceNum2(orders.getPriceNum2()); |
| | | orders.setOriginEstimatedAccount(orders.getEstimatedAccount()); |
| | | orders.setConfirmOtherFee(0l); |
| | | ordersMapper.insert(orders); |
| | | |
| | | orderReleaseVO.setId(orders.getId()); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(orders.getMultifileList())){ |
| | | List<Multifile> multifileList = orders.getMultifileList(); |
| | |
| | | multifileMapper.insert(multifileList); |
| | | } |
| | | //更新用户发单量 |
| | | memberMapper.update(new UpdateWrapper<Member>().lambda().setSql(" receive_num = ( receive_num + 1 )").eq(Member::getId,orders.getMember().getId())); |
| | | memberMapper.update(new UpdateWrapper<Member>().lambda().setSql(" PUBLISH_NUM = ( ifnull(PUBLISH_NUM,0) + 1 )").eq(Member::getId,orders.getMember().getId())); |
| | | |
| | | //创建操作日志 |
| | | Constants.OrdersLog ordersLog = Constants.OrdersLog.UPLOAD; |
| | | String orderTypeInfo = "用工单"; |
| | | String orderTypeInfo = Constants.getOrderInfo(orders);/*"用工单"; |
| | | if(!Constants.equalsInteger(orders.getType(),Constants.ZERO)){ |
| | | orderTypeInfo = Constants.equalsInteger(orders.getType(),Constants.ONE)?"用车单":"送餐单"; |
| | | }else{ |
| | |
| | | }else{ |
| | | orderTypeInfo = orderTypeInfo + (Constants.equalsInteger(orders.getWorkType(),Constants.ONE)?"-分拣工":"-包装工"); |
| | | } |
| | | } |
| | | }*/ |
| | | String logInfo = ordersLog.getInfo() |
| | | .replace("{param}",orderTypeInfo); |
| | | this.saveOrderLog(orders,ordersLog, |
| | |
| | | request.setOutTradeNo(orders.getOutTradeNo()); |
| | | request.setNotifyUrl(WxMiniConfig.wxProperties.getNotifyUrl());//这个回调url必须是https开头的 |
| | | Amount amount = new Amount(); |
| | | amount.setTotal(1);//orders.getPayAccount().intValue()); |
| | | amount.setTotal(orders.getPayAccount().intValue()); |
| | | request.setAmount(amount); |
| | | // PrepayResponse res = WxMiniConfig.wxPayService.prepay(request); |
| | | // 跟之前下单示例一样,填充预下单参数 |
| | |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | if( (Constants.equalsInteger(orders.getType(),Constants.ZERO) && Constants.equalsInteger(orders.getWorkType(),Constants.TWO) && |
| | | ( Constants.equalsInteger(orders.getCarType(),Constants.ZERO) || Constants.equalsInteger(orders.getCarType(),Constants.ONE) )) |
| | | || (Constants.equalsInteger(orders.getType(),Constants.ZERO) && Constants.equalsInteger(orders.getWorkType(),Constants.ONE)) |
| | | Integer priceNum2 = orders.getPriceNum2(); |
| | | if( (Constants.equalsInteger(orders.getType(),Constants.ZERO) |
| | | && Constants.equalsInteger(orders.getWorkType(),Constants.TWO) && |
| | | ( Constants.equalsInteger(orders.getCarType(),Constants.ZERO) |
| | | || Constants.equalsInteger(orders.getCarType(),Constants.ONE) )) |
| | | || (Constants.equalsInteger(orders.getType(),Constants.ZERO) |
| | | && Constants.equalsInteger(orders.getWorkType(),Constants.ONE)) |
| | | ){ |
| | | if(Objects.isNull(orders.getPriceNum2())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | |
| | | orders.setTotalDays(DateUtil.daysBetweenDates(orders.getEndDate(),orders.getStartDate())+1); |
| | | if(Constants.equalsInteger(orders.getType(),Constants.ZERO)){ |
| | | if(Constants.equalsInteger(orders.getWorkType(),Constants.TWO) |
| | | && ( Objects.isNull(orders.getCarType()) ) ){ |
| | | && ( Objects.isNull(orders.getCarType()) ) ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | }else if(Constants.equalsInteger(orders.getType(),Constants.ONE)){ |
| | |
| | | } |
| | | orders.setWayInfo(JSONObject.toJSONString(orders.getWayInfoDTOList())); |
| | | }else{ |
| | | List<Category> categoryList = categoryMapper.selectList(new QueryWrapper<Category>().lambda().eq(Category::getDeleted,Constants.ZERO) |
| | | .eq(Category::getType,Constants.TWO) |
| | | ); |
| | | if(CollectionUtils.isEmpty(categoryList)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"餐标信息错误"); |
| | | } |
| | | //用餐订单 |
| | | if(CollectionUtils.isEmpty(orders.getCateringDTOList())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | Long sumPrice = 0L; |
| | | // List<CateringDTO> cateringDTOList = new ArrayList<>(); |
| | | for (CateringDTO cateringDTO:orders.getCateringDTOList()) { |
| | | if(Objects.isNull(cateringDTO) |
| | | || StringUtils.isEmpty(cateringDTO.getName()) |
| | |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"用餐标准数据错误"); |
| | | } |
| | | //餐标信息 |
| | | List<Category> categories = categoryList.stream().filter(i->Constants.equalsInteger(i.getId(),cateringDTO.getId())).collect(Collectors.toList()); |
| | | if(CollectionUtils.isEmpty(categories)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"用餐标准数据错误,请刷新重试"); |
| | | } |
| | | Category category = categories.get(Constants.ZERO); |
| | | List<String> priceList = JSONArray.parseArray(category.getDetail(),String.class ); |
| | | if(CollectionUtils.isEmpty(priceList)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"用餐标准数据错误,请刷新重试"); |
| | | } |
| | | if(priceList.stream().filter(i->((Long.valueOf(i)*100)+"").equals((cateringDTO.getPrice()+""))).collect(Collectors.toList()).size()==Constants.ZERO){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"用餐标准数据错误,请刷新重试"); |
| | | } |
| | | sumPrice = sumPrice + (cateringDTO.getPrice() * cateringDTO.getNum()) ; |
| | | |
| | | } |
| | | if(!sumPrice.equals(orders.getPrice())){ |
| | | if(new BigDecimal(sumPrice.toString()).compareTo(orders.getPrice())!=Constants.ZERO){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"单价计算错误"); |
| | | } |
| | | |
| | | |
| | | orders.setWayInfo(JSONObject.toJSONString(orders.getCateringDTOList())); |
| | | } |
| | | if(!orders.getEstimatedAccount().equals(this.getTotal(orders))){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"金额计算错误!"); |
| | | } |
| | | orders.setPriceNum2(priceNum2); |
| | | } |
| | | |
| | | |
| | |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单已修改,待接单方确认,无法进行该操作"); |
| | | } |
| | | if(!Constants.equalsInteger(model.getType(),Constants.TWO)){ |
| | | if(Constants.equalsInteger(model.getStatus(),Constants.ZERO)||Constants.equalsInteger(model.getStatus(),Constants.ONE)){ |
| | | if(Constants.equalsInteger(model.getStatus(),Constants.ZERO) |
| | | ||Constants.equalsInteger(model.getStatus(),Constants.ONE)){ |
| | | this.updateById(orders); |
| | | }else if(Constants.equalsInteger(model.getStatus(),Constants.TWO)){ |
| | | this.updOrderData(orders,model); |
| | |
| | | }else{ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | multifileMapper.insert(multifileList); |
| | | } |
| | | orders.setOriginPriceNum1(orders.getPriceNum1()); |
| | | orders.setOriginPriceNum2(orders.getPriceNum2()); |
| | | orders.setOriginEstimatedAccount(orders.getOriginEstimatedAccount()); |
| | | orders.setConfirmOtherFee(0L); |
| | | ordersMapper.updateById(orders); |
| | | } |
| | | |
| | |
| | | ); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(orderLogList)){ |
| | | for (OrderLog orderLog:orderLogList) { |
| | | if(Constants.equalsInteger(orderLog.getOptUserType(),Constants.ZERO)){ |
| | | if(Constants.equalsInteger(orderLog.getOptUserType(),Constants.ZERO)&& org.apache.commons.lang3.StringUtils.isNotBlank(orders.getReleaseName())){ |
| | | orderLog.setLogInfo(orderLog.getLogInfo().replace("{userName}",orders.getReleaseName())); |
| | | }else if(Constants.equalsInteger(orderLog.getOptUserType(),Constants.ONE)){ |
| | | }else if(Constants.equalsInteger(orderLog.getOptUserType(),Constants.ONE)&& org.apache.commons.lang3.StringUtils.isNotBlank(orders.getAcceptName())){ |
| | | orderLog.setLogInfo(orderLog.getLogInfo().replace("{userName}",orders.getAcceptName())); |
| | | } |
| | | } |
| | |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(cateringDTOList)){ |
| | | for (CateringDTO cateringDTO:cateringDTOList) { |
| | | if(StringUtils.isEmpty(orders.getOrderContent())){ |
| | | orders.setOrderContent(cateringDTO.getName()+cateringDTO.getPrice()+" 需"+cateringDTO.getNum()+"份"); |
| | | orders.setOrderContent(cateringDTO.getName()+(new BigDecimal(cateringDTO.getPrice().toString()).divide(new BigDecimal("100"),2,BigDecimal.ROUND_HALF_UP))+" 需"+cateringDTO.getNum()+"份"); |
| | | }else{ |
| | | orders.setOrderContent(orders.getOrderContent()+" | "+cateringDTO.getName()+cateringDTO.getPrice()+" 需"+cateringDTO.getNum()+"份"); |
| | | orders.setOrderContent(orders.getOrderContent()+" | "+cateringDTO.getName()+(new BigDecimal(cateringDTO.getPrice().toString()).divide(new BigDecimal("100"),2,BigDecimal.ROUND_HALF_UP))+" 需"+cateringDTO.getNum()+"份"); |
| | | } |
| | | } |
| | | } |
| | |
| | | //查询用户是否有对应身份 |
| | | if(Constants.equalsInteger(orders.getType(),Constants.ZERO)){ |
| | | if(!Constants.equalsInteger(member.getWorkerIdentity(),Constants.TWO)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"身份信息异常,请前往个人中心进行身份认证!"); |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"您还未注册该服务,请前往\"我的\"页面提交申请"); |
| | | } |
| | | }else if(Constants.equalsInteger(orders.getType(),Constants.ONE)){ |
| | | if(!Constants.equalsInteger(member.getDriverIdentity(),Constants.TWO)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"身份信息异常,请前往个人中心进行身份认证!"); |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"您还未注册该服务,请前往\"我的\"页面提交申请"); |
| | | } |
| | | }else{ |
| | | if(!Constants.equalsInteger(member.getChefIdentity(),Constants.TWO)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"身份信息异常,请前往个人中心进行身份认证!"); |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"您还未注册该服务,请前往\"我的\"页面提交申请"); |
| | | } |
| | | } |
| | | |
| | |
| | | .set(Orders::getStatus,Constants.ordersStatus.accept.getKey()) |
| | | ); |
| | | |
| | | |
| | | |
| | | //更新接单量 |
| | | memberMapper.update(new UpdateWrapper<Member>().lambda().setSql(" publish_num = (publish_num + 1 )").eq(Member::getId,member.getId())); |
| | | memberMapper.update(new UpdateWrapper<Member>().lambda().setSql(" RECEIVE_NUM = (ifnull(RECEIVE_NUM,0) + 1 )").eq(Member::getId,member.getId())); |
| | | |
| | | //创建操作日志 |
| | | Constants.OrdersLog ordersLog = Constants.OrdersLog.RECEIVE; |
| | | this.saveOrderLog(orders,ordersLog, |
| | | ordersLog.getInfo(),member.getId(),null); |
| | | |
| | | //TODO 微信公众号提醒 已接单提醒 |
| | | IdentityInfo wokerIdentityInfo = identityInfoMapper.selectOne(new QueryWrapper<IdentityInfo>().lambda() |
| | | .eq(IdentityInfo::getMemberId,member.getId()) |
| | | .eq(IdentityInfo::getType,orders.getType()) |
| | | .eq(IdentityInfo::getAuditStatus,Constants.TWO) |
| | | .last("limit 1") |
| | | ); |
| | | Member releaseMember = memberMapper.selectById(orders.getReleaseMemberId()); |
| | | |
| | | if(Objects.nonNull(releaseMember)){ |
| | | if(org.apache.commons.lang3.StringUtils.isNotBlank(releaseMember.getOpenid())&&Objects.nonNull(wokerIdentityInfo)){ |
| | | //发送微信通知 |
| | | sendWxMessage.acceptMessage(releaseMember.getOpenid(),orders,wokerIdentityInfo.getLinkName(),wokerIdentityInfo.getTelephone()); |
| | | } |
| | | if(org.apache.commons.lang3.StringUtils.isNotBlank(orders.getLinkPhone())){ |
| | | //短信通知 |
| | | aliSmsService.businessSendSms(Constants.smsContent.accept.getKey(),orders.getLinkPhone(),orders,null, |
| | | wokerIdentityInfo,categoryMapper); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | if(Constants.equalsInteger(orders.getIsUpdate(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单修改待确认,无法进行该操作"); |
| | | } |
| | | if(orders.getStartDate().getTime()>System.currentTimeMillis()){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单未到开始时间无法进行该操作"); |
| | | } |
| | | orders.setUpdateTime(new Date()); |
| | | orders.setStatus(Constants.ordersStatus.doing.getKey()); |
| | |
| | | model.setPriceNum1(orders.getTotalDays()); |
| | | } |
| | | Long total = this.getTotal(orders); |
| | | Long tcje = Long.valueOf(new BigDecimal(total.toString()).multiply(model.getPlatformRata()).intValue()); |
| | | Long reciveTotal = total - tcje; |
| | | ordersMapper.update(new UpdateWrapper<Orders>().lambda() |
| | | .set(Orders::getStartDate,model.getStartDate()) |
| | | .set(Orders::getEndDate,model.getEndDate()) |
| | |
| | | .set(Orders::getIsUpdateTime,new Date()) |
| | | .set(Orders::getUpdateTime,new Date()) |
| | | .set(Orders::getEstimatedAccount,total) |
| | | .set(Orders::getOriginEstimatedAccount,total) |
| | | .set(Orders::getReceiveAccount,reciveTotal) |
| | | .eq(Orders::getId,orders.getId()) |
| | | ); |
| | | //创建操作日志 |
| | |
| | | this.saveOrderLog(model,ordersLog, |
| | | ordersLog.getInfo(),orders.getMember().getId(),null); |
| | | |
| | | //TODO 通知接单人 订单发生变更 |
| | | //通知接单人 订单发生变更 |
| | | Member member = memberMapper.selectById(model.getAcceptMemberId()); |
| | | if(Objects.nonNull(member)){ |
| | | if(org.apache.commons.lang3.StringUtils.isNotBlank(member.getOpenid())){ |
| | | model.setStartDate(orders.getStartDate()); |
| | | model.setEndDate(orders.getEndDate()); |
| | | //发送微信通知 |
| | | sendWxMessage.orderUpdMessage(member.getOpenid(),model); |
| | | } |
| | | IdentityInfo wokerIdentityInfo = identityInfoMapper.selectOne(new QueryWrapper<IdentityInfo>().lambda() |
| | | .eq(IdentityInfo::getMemberId,member.getId()) |
| | | .eq(IdentityInfo::getType,orders.getType()) |
| | | .eq(IdentityInfo::getAuditStatus,Constants.TWO) |
| | | .last("limit 1") |
| | | ); |
| | | if(Objects.nonNull(wokerIdentityInfo)){ |
| | | //短信通知 |
| | | aliSmsService.businessSendSms(Constants.smsContent.orderUpd.getKey(),wokerIdentityInfo.getTelephone(),orders,null, |
| | | null,categoryMapper); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | public Long getTotal(Orders orders){ |
| | | if(Objects.isNull(orders) |
| | | ||Objects.isNull(orders.getPrice()) |
| | | ||Objects.isNull(orders.getPriceNum1())){ |
| | | ||Objects.isNull(orders.getPriceNum1()) |
| | | ||Objects.isNull(orders.getType()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | BigDecimal bigDecimalPrice = BigDecimal.ZERO; |
| | | if( |
| | | (Constants.equalsInteger(orders.getType(),Constants.ZERO) && Constants.equalsInteger(orders.getWorkType(),Constants.ZERO )) |
| | | || Constants.equalsInteger(orders.getType(),Constants.ONE) |
| | | || (Constants.equalsInteger(orders.getType(),Constants.ZERO) && Objects.nonNull(orders.getCarType()) && Constants.equalsInteger(orders.getWorkType(),Constants.TWO ) && Constants.equalsInteger(orders.getCarType(),Constants.TWO)) |
| | | || Constants.equalsInteger(orders.getType(),Constants.ONE) |
| | | || Constants.equalsInteger(orders.getType(),Constants.TWO) |
| | | ){ |
| | | orders.setPriceNum2(Constants.ONE); |
| | | bigDecimalPrice = orders.getPrice().multiply(new BigDecimal(orders.getPriceNum1().toString())); |
| | | }else{ |
| | | if(Objects.isNull(orders.getPriceNum2())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | bigDecimalPrice = orders.getPrice().multiply(new BigDecimal(orders.getPriceNum1().toString())).multiply(new BigDecimal(orders.getPriceNum2().toString())); |
| | | } |
| | | return orders.getPrice() * orders.getPriceNum1() * orders.getPriceNum2(); |
| | | if(Objects.nonNull(orders.getConfirmOtherFee())){ |
| | | bigDecimalPrice = bigDecimalPrice.add(new BigDecimal(orders.getConfirmOtherFee().toString())); |
| | | } |
| | | return bigDecimalPrice.divide(new BigDecimal("1"),0,BigDecimal.ROUND_HALF_UP).longValue();//orders.getPrice() * orders.getPriceNum1() * orders.getPriceNum2(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 接单方确认订单费用 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public void confirmFee(ConfirmFeeOrderDTO confirmUpdOrderDTO){ |
| | | if(Objects.isNull(confirmUpdOrderDTO) |
| | | || Objects.isNull(confirmUpdOrderDTO.getOrderId()) |
| | | || Objects.isNull(confirmUpdOrderDTO.getPriceNum1())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | Orders orders = ordersMapper.selectById(confirmUpdOrderDTO.getOrderId()); |
| | | if(Objects.isNull(orders)||Constants.equalsInteger(orders.getDeleted(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(!Constants.equalsInteger(orders.getAcceptMemberId(),confirmUpdOrderDTO.getMember().getId())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非您的订单无法进行该操作"); |
| | | } |
| | | if(!Constants.equalsInteger(orders.getStatus(),Constants.ordersStatus.doing.getKey())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行该操作"); |
| | | } |
| | | //类型:0=用工;1=运货;2=订餐 |
| | | if(Constants.equalsInteger(orders.getType(),Constants.ZERO)){ |
| | | //用工类型:0=采摘工;1=分拣工;2=包装工;(用工订单) |
| | | if(Constants.equalsInteger(orders.getWorkType(),Constants.ONE)){ |
| | | //1=分拣工 |
| | | if( Objects.isNull(confirmUpdOrderDTO.getPriceNum2())){//必须有用工数量(人) |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | }else if(Constants.equalsInteger(orders.getWorkType(),Constants.TWO)){ |
| | | //包装工 用车类型(用工包装/运货使用):0=天;1=次/小时;2=重量 |
| | | if( !Constants.equalsInteger(orders.getCarType(),Constants.TWO) |
| | | && Objects.isNull(confirmUpdOrderDTO.getPriceNum2())){ |
| | | //不是按重量计费的,必须有用工数量(人) |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | } |
| | | }else if(Constants.equalsInteger(orders.getType(),Constants.ONE)){ |
| | | //运货订单 |
| | | |
| | | }else{ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"该订单不支持该操作,请返回刷新重试!"); |
| | | } |
| | | orders.setPriceNum1(confirmUpdOrderDTO.getPriceNum1()); |
| | | orders.setPriceNum2(confirmUpdOrderDTO.getPriceNum2()); |
| | | orders.setConfirmOtherFee(confirmUpdOrderDTO.getConfirmOtherFee()); |
| | | Long totalFee = this.getTotal(orders);//重新计算费用 |
| | | Long payFee = totalFee;//重新计算费用 |
| | | Long tcje = Long.valueOf(new BigDecimal(orders.getPayAccount().toString()).multiply(orders.getPlatformRata()).intValue()); |
| | | Long reciveTotal = payFee - tcje; |
| | | //BigDecimal recFee = new BigDecimal(payFee).multiply((new BigDecimal(1).subtract(Constants.formatBigDecimal(orders.getPlatformRata())))).setScale(0, RoundingMode.HALF_UP) ; |
| | | ordersMapper.update(new UpdateWrapper<Orders>().lambda() |
| | | .set(Orders::getPriceNum1,confirmUpdOrderDTO.getPriceNum1()) |
| | | .set(Orders::getPriceNum2,confirmUpdOrderDTO.getPriceNum2()) |
| | | .set(Orders::getConfirmFeeRemark,confirmUpdOrderDTO.getConfirmFeeRemark()) |
| | | .set(Orders::getConfirmOtherFee,confirmUpdOrderDTO.getConfirmOtherFee()) |
| | | .set(Orders::getEstimatedAccount,totalFee) |
| | | .set(Orders::getStatus,Constants.ordersStatus.feeconfirm.getKey()) |
| | | .set(Orders::getPayAccount,payFee) |
| | | .set(Orders::getReceiveAccount,reciveTotal) |
| | | .set(Orders::getUpdateTime,new Date()) |
| | | .set(Orders::getConfirmFeeTime,new Date()) |
| | | .eq(Orders::getId,orders.getId()) |
| | | ); |
| | | //记录同意修改的日志 |
| | | Constants.OrdersLog ordersLog = Constants.OrdersLog.FEE_CONFIRM; |
| | | this.saveOrderLog(orders,ordersLog, |
| | | ordersLog.getInfo(),confirmUpdOrderDTO.getMember().getId(),null); |
| | | |
| | | //微信通知 |
| | | Member member = memberMapper.selectById(orders.getReleaseMemberId()); |
| | | if(Objects.nonNull(member)&& org.apache.commons.lang3.StringUtils.isNotBlank(member.getOpenid())){ |
| | | sendWxMessage.waitPayMessage(member.getOpenid(),orders); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 接单方处理订单修改 |
| | |
| | | Constants.OrdersLog ordersLog = Constants.OrdersLog.UPD_DISAGREE; |
| | | this.saveOrderLog(orders,ordersLog, |
| | | ordersLog.getInfo(),confirmUpdOrderDTO.getMember().getId(),null); |
| | | //TODO 发送不同意变更通知 |
| | | } |
| | | //短信通知 |
| | | aliSmsService.businessSendSms(!Constants.equalsInteger(confirmUpdOrderDTO.getStatus(),Constants.ONE)? |
| | | Constants.smsContent.agreeUpd.getKey():Constants.smsContent.disAgreeUpd.getKey() |
| | | ,orders.getLinkPhone(),null,null, |
| | | null,categoryMapper); |
| | | } |
| | | |
| | | |
| | |
| | | }else{ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非您的订单无法进行该操作"); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | .eq(Orders::getReleaseMemberId,member.getId())); |
| | | //查询取消次数 |
| | | if(totalCancelTimes<=cancelTimes){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"今日订单主动取消次数已超出"+totalCancelTimes+"次,无法取消订单,如需处理请联系客服"); |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"今日订单主动取消次数已超出"+totalCancelTimes+"次,无法取消订单"); |
| | | } |
| | | |
| | | Integer cancelTimeHour = Integer.valueOf(systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.RELEASE_CANCEL_TIME).getCode()); |
| | | Long hours = DateUtil.getBetweenHours(new Date(),orders.getStartDate()); |
| | | if(hours < cancelTimeHour){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"距离订单开始时间不足"+cancelTimeHour+"小时,无法取消订单,如需处理请联系客服"); |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"距离订单开始时间不足"+cancelTimeHour+"小时,无法取消订单"); |
| | | } |
| | | return "今日还可主动取消"+(totalCancelTimes-cancelTimes)+"次,是否确认取消"; |
| | | |
| | |
| | | .eq(Orders::getReleaseMemberId,orders.getReleaseMemberId())); |
| | | //查询取消次数 |
| | | if(totalCancelTimes<=cancelTimes){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"今日订单主动取消次数已超出"+totalCancelTimes+"次,无法取消订单,如需处理请联系客服"); |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"今日订单主动取消次数已超出"+totalCancelTimes+"次,无法取消订单"); |
| | | } |
| | | |
| | | Integer cancelTimeHour = Integer.valueOf(systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.RELEASE_CANCEL_TIME).getCode()); |
| | | Long hours = DateUtil.getBetweenHours(new Date(),orders.getStartDate()); |
| | | if(hours < cancelTimeHour){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"距离订单开始时间不足"+cancelTimeHour+"小时,无法取消订单,如需处理请联系客服"); |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"距离订单开始时间不足"+cancelTimeHour+"小时,无法取消订单"); |
| | | } |
| | | |
| | | if(Constants.equalsInteger(orders.getType(),Constants.TWO)){ |
| | |
| | | .set(Orders::getCancelType,Constants.ONE) |
| | | .eq(Orders::getId,orders.getId()) |
| | | ); |
| | | //TODO 发单方取消订单通知接单方 |
| | | |
| | | //减少接单量 |
| | | memberMapper.update(new UpdateWrapper<Member>().lambda().setSql("receive_num = (receive_num - 1) ").eq(Member::getId,orders.getAcceptMemberId())); |
| | | } |
| | |
| | | this.saveOrderLog(orders,ordersLog, |
| | | ordersLog.getInfo(),member.getId(),null); |
| | | |
| | | List<Member> members = memberMapper.selectList(new QueryWrapper<Member>().lambda() |
| | | .and(i->i.eq(Member::getId,orders.getReleaseMemberId()).or().eq(Member::getId,orders.getAcceptMemberId())) |
| | | ); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(members)){ |
| | | List<String> openIdList = members.stream().map(i->i.getOpenid()).collect(Collectors.toList()); |
| | | //发送微信通知 |
| | | orders.setCancelTime(new Date()); |
| | | sendWxMessage.cancelMessage(openIdList,orders,Constants.ONE); |
| | | } |
| | | |
| | | |
| | | IdentityInfo wokerIdentityInfo = identityInfoMapper.selectOne(new QueryWrapper<IdentityInfo>().lambda() |
| | | .eq(IdentityInfo::getMemberId,orders.getAcceptMemberId()) |
| | | .eq(IdentityInfo::getType,orders.getType()) |
| | | .eq(IdentityInfo::getAuditStatus,Constants.TWO) |
| | | .last("limit 1") |
| | | ); |
| | | if(Objects.nonNull(wokerIdentityInfo)){ |
| | | //短信通知 |
| | | aliSmsService.businessSendSms(Constants.smsContent.releaseCancel.getKey(),wokerIdentityInfo.getTelephone(),orders,null, |
| | | null,categoryMapper); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | .eq(OrderLog::getMemberId,member.getId())); |
| | | //查询取消次数 |
| | | if(totalCancelTimes<=cancelTimes){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"今日订单主动取消次数已超出"+totalCancelTimes+"次,无法取消订单,如需处理请联系客服"); |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"今日订单主动取消次数已超出"+totalCancelTimes+"次,无法取消订单"); |
| | | } |
| | | |
| | | Integer cancelTimeHour = Integer.valueOf(systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.RECEIVE_CANCEL_TIME).getCode()); |
| | | Long hours = DateUtil.getBetweenHours(new Date(),orders.getStartDate()); |
| | | if(hours < cancelTimeHour){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"距离订单开始时间不足"+cancelTimeHour+"小时,无法取消订单,如需处理请联系客服"); |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"距离订单开始时间不足"+cancelTimeHour+"小时,无法取消订单"); |
| | | } |
| | | ordersMapper.update(new UpdateWrapper<Orders>().lambda() |
| | | .set(Orders::getUpdateTime,new Date()) |
| | | .set(Orders::getCancelTime,new Date()) |
| | | .set(Orders::getStatus,Constants.ordersStatus.wait.getKey()) |
| | | .set(Orders::getAcceptMemberId,null) |
| | | .set(Orders::getAcceptType,null) |
| | |
| | | this.saveOrderLog(orders,ordersLog, |
| | | ordersLog.getInfo(),member.getId(),null); |
| | | |
| | | //TODO 接单方取消订单通知 |
| | | |
| | | List<Member> members = memberMapper.selectList(new QueryWrapper<Member>().lambda() |
| | | .and(i->i.eq(Member::getId,orders.getReleaseMemberId()).or().eq(Member::getId,orders.getAcceptMemberId())) |
| | | ); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(members)){ |
| | | List<String> openIdList = members.stream().map(i->i.getOpenid()).collect(Collectors.toList()); |
| | | //发送微信通知 |
| | | orders.setCancelTime(new Date()); |
| | | sendWxMessage.cancelMessage(openIdList,orders,Constants.TWO); |
| | | } |
| | | //短信通知 |
| | | aliSmsService.businessSendSms(Constants.smsContent.receiveCancel.getKey(),member.getTelephone(),orders,null, |
| | | null,categoryMapper); |
| | | } |
| | | |
| | | |
| | |
| | | if(Objects.isNull(orders)||Constants.equalsInteger(orders.getDeleted(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(!Constants.equalsInteger(orders.getStatus(),Constants.ordersStatus.doing.getKey())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行取消"); |
| | | if(Constants.equalsInteger(orders.getType(),Constants.orderType.scd.getKey())){ |
| | | if(!Constants.equalsInteger(orders.getStatus(),Constants.ordersStatus.doing.getKey())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行取消"); |
| | | } |
| | | }else{ |
| | | if(!Constants.equalsInteger(orders.getStatus(),Constants.ordersStatus.feeconfirm.getKey())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行取消"); |
| | | } |
| | | } |
| | | |
| | | if(!Constants.equalsInteger(orders.getReleaseMemberId(),doneOrderDTO.getMember().getId())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非您的订单无法进行该操作"); |
| | | } |
| | | Member payMember = memberMapper.selectById(doneOrderDTO.getMember().getId()); |
| | | if(Objects.isNull(payMember)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"用户信息异常"); |
| | | } |
| | | |
| | | OrderReleaseVO orderReleaseVO = new OrderReleaseVO(); |
| | | orderReleaseVO.setId(orders.getId()); |
| | | Object object = null; |
| | |
| | | if(!Constants.equalsInteger(orders.getType(),Constants.TWO)){ |
| | | orders.setPayAccount(doneOrderDTO.getAmount()); |
| | | //提成金额 |
| | | // Long tcje = (new BigDecimal(orders.getPayAccount().toString()).multiply(Constants.formatBigDecimal(orders.getPlatformRata())).setScale(0,RoundingMode.HALF_UP).longValue()); |
| | | Long tcje = Long.valueOf(new BigDecimal(orders.getPayAccount().toString()).multiply(orders.getPlatformRata()).intValue()); |
| | | orders.setReceiveAccount(orders.getPayAccount() - tcje); |
| | | orders.setOutTradeNo(UUID.randomUUID().toString().replace("-","")); |
| | | ordersMapper.updateById(orders); |
| | | //唤起支付业务 |
| | | object = this.getWxPayResponse(orders,doneOrderDTO.getMember().getOpenid()); |
| | | object = this.getWxPayResponse(orders,payMember.getOpenid()); |
| | | orderReleaseVO.setObject(object); |
| | | }else{ |
| | | orders.setStatus(Constants.ordersStatus.done.getKey()); |
| | |
| | | Constants.OrdersLog ordersLog = Constants.OrdersLog.DONE; |
| | | this.saveOrderLog(orders,ordersLog, |
| | | ordersLog.getInfo(),doneOrderDTO.getMember().getId(),null); |
| | | |
| | | sendWxMessage.revenueMessage(member.getOpenid(),orders); |
| | | |
| | | //短信通知接单方 |
| | | if(Objects.nonNull(orders.getAcceptMemberId())){ |
| | | IdentityInfo wokerIdentityInfo = identityInfoMapper.selectOne(new QueryWrapper<IdentityInfo>().lambda() |
| | | .eq(IdentityInfo::getMemberId,orders.getAcceptMemberId()) |
| | | .eq(IdentityInfo::getType,orders.getType()) |
| | | .eq(IdentityInfo::getAuditStatus,Constants.TWO) |
| | | .last("limit 1") |
| | | ); |
| | | if(Objects.nonNull(wokerIdentityInfo)){ |
| | | aliSmsService.businessSendSms(Constants.smsContent.pay.getKey(),wokerIdentityInfo.getTelephone(),orders,null, |
| | | null,categoryMapper); |
| | | } |
| | | } |
| | | } |
| | | return orderReleaseVO; |
| | | } |
| | |
| | | } |
| | | |
| | | if(!((( Constants.equalsInteger(orders.getType(),Constants.TWO) && Constants.equalsInteger(orders.getStatus(),Constants.ZERO) ) |
| | | || ( !Constants.equalsInteger(orders.getType(),Constants.TWO) && Constants.equalsInteger(orders.getStatus(),Constants.THREE) )) |
| | | || ( !Constants.equalsInteger(orders.getType(),Constants.TWO) && Constants.equalsInteger(orders.getStatus(),Constants.FIVE) )) |
| | | && Constants.equalsInteger(orders.getPayStatus(),Constants.ZERO) )){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转"); |
| | | } |
| | | Member payMember = memberMapper.selectById(reusePayDTO.getMember().getId()); |
| | | if(Objects.isNull(payMember)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"用户信息异常"); |
| | | } |
| | | |
| | | OrderReleaseVO orderReleaseVO = new OrderReleaseVO(); |
| | | if(!Constants.equalsInteger(orders.getType(),Constants.TWO)){ |
| | | orders.setPayAccount(reusePayDTO.getAmount()); |
| | | //提成金额 |
| | | Long tcje = Long.valueOf(new BigDecimal(orders.getPayAccount().toString()).multiply(orders.getPlatformRata()).intValue()); |
| | | orders.setReceiveAccount(orders.getPayAccount() - tcje); |
| | | orders.setOutTradeNo(UUID.randomUUID().toString().replace("-","")); |
| | | ordersMapper.updateById(orders); |
| | | } |
| | | orders.setOutTradeNo(UUID.randomUUID().toString().replace("-","")); |
| | | ordersMapper.updateById(orders); |
| | | //唤起支付业务 |
| | | Object object = this.getWxPayResponse(orders,orders.getMember().getOpenid()); |
| | | Object object = this.getWxPayResponse(orders,payMember.getOpenid()); |
| | | orderReleaseVO.setObject(object); |
| | | orderReleaseVO.setId(orders.getId()); |
| | | return orderReleaseVO; |
| | |
| | | Constants.OrdersLog ordersLog = Constants.OrdersLog.SYSTEM_CANCEL; |
| | | this.saveOrderLog(orders,ordersLog, |
| | | ordersLog.getInfo(),null,loginUserInfo.getId()); |
| | | |
| | | List<Member> members = memberMapper.selectList(new QueryWrapper<Member>().lambda() |
| | | .and(i->i.eq(Member::getId,orders.getReleaseMemberId()).or().eq(Member::getId,orders.getAcceptMemberId())) |
| | | ); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(members)){ |
| | | List<String> openIdList = members.stream().map(i->i.getOpenid()).collect(Collectors.toList()); |
| | | orders.setCancelTime(new Date()); |
| | | //发送微信通知 |
| | | orders.setCancelTime(new Date()); |
| | | sendWxMessage.cancelMessage(openIdList,orders,Constants.ZERO); |
| | | } |
| | | //短信通知发单方 |
| | | aliSmsService.businessSendSms(Constants.smsContent.platformCancel.getKey(),orders.getLinkPhone(),orders,null, |
| | | null,categoryMapper); |
| | | //短信通知接单方 |
| | | if(Objects.nonNull(orders.getAcceptMemberId())){ |
| | | IdentityInfo wokerIdentityInfo = identityInfoMapper.selectOne(new QueryWrapper<IdentityInfo>().lambda() |
| | | .eq(IdentityInfo::getMemberId,orders.getAcceptMemberId()) |
| | | .eq(IdentityInfo::getType,orders.getType()) |
| | | .eq(IdentityInfo::getAuditStatus,Constants.TWO) |
| | | .last("limit 1") |
| | | ); |
| | | if(Objects.nonNull(wokerIdentityInfo)){ |
| | | aliSmsService.businessSendSms(Constants.smsContent.platformCancel2.getKey(),wokerIdentityInfo.getTelephone(),orders,null, |
| | | null,categoryMapper); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | .eq(Orders::getId,orders.getId()) |
| | | ); |
| | | memberMapper.update(new UpdateWrapper<Member>().lambda() |
| | | .setSql(" score = ( total_score +" + commentDTO.getLevel() + " ) / (score_order_num + 1 )") |
| | | .setSql(" total_score = total_score +" + commentDTO.getLevel()) |
| | | .setSql(" score_order_num = score_order_num + 1 " ).eq(Member::getId,orders.getAcceptMemberId()) |
| | | .setSql(" score = ( ifnull(total_score,0) +" + commentDTO.getLevel() + " ) / (ifnull(score_order_num,0) + 1 )") |
| | | .setSql(" total_score = ifnull(total_score,0) +" + commentDTO.getLevel()) |
| | | .setSql(" score_order_num = ifnull(score_order_num,0) + 1 " ) |
| | | .eq(Member::getId,orders.getAcceptMemberId()) |
| | | ); |
| | | //日志存储 |
| | | Constants.OrdersLog ordersLog = Constants.OrdersLog.COMMENT; |
| | |
| | | } |
| | | }else{ |
| | | //非用餐类订单 |
| | | if(!Constants.equalsInteger(orders.getStatus(),Constants.THREE)){ |
| | | if(!Constants.equalsInteger(orders.getStatus(),Constants.FIVE)){ |
| | | return ("处理成功!"); |
| | | }else{ |
| | | //处理支付完成逻辑 |
| | |
| | | this.saveOrderLog(orders,ordersLog, |
| | | ordersLog.getInfo(),orders.getReleaseMemberId(),null); |
| | | |
| | | //TODO 通知接单方 款项已到账 |
| | | // 通知接单方 款项已到账 |
| | | sendWxMessage.revenueMessage(member.getOpenid(),orders); |
| | | |
| | | //短信通知接单方 |
| | | if(Objects.nonNull(orders.getAcceptMemberId())){ |
| | | IdentityInfo wokerIdentityInfo = identityInfoMapper.selectOne(new QueryWrapper<IdentityInfo>().lambda() |
| | | .eq(IdentityInfo::getMemberId,orders.getAcceptMemberId()) |
| | | .eq(IdentityInfo::getType,orders.getType()) |
| | | .eq(IdentityInfo::getAuditStatus,Constants.TWO) |
| | | .last("limit 1") |
| | | ); |
| | | if(Objects.nonNull(wokerIdentityInfo)){ |
| | | aliSmsService.businessSendSms(Constants.smsContent.pay.getKey(),wokerIdentityInfo.getTelephone(),orders,null, |
| | | null,categoryMapper); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | Orders model = pageWrap.getModel(); |
| | | if(Objects.isNull(model) |
| | | || Objects.isNull(model.getQueryLat()) |
| | | || Objects.isNull(model.getQueryLgt()) |
| | | || Objects.isNull(model.getQueryMyOrderType()) |
| | | || Objects.isNull(model.getQueryMyOrderType()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | |
| | | .select("c2.name",Orders::getTransportTypeName) |
| | | .leftJoin(" category c1 on t.category_id = c1.id ") |
| | | .leftJoin(" category c2 on t.TRANSPORT_TYPE_ID = c2.id ") |
| | | .select(" case when T.LGT IS NULL OR T.LAT IS NULL THEN 0 " + |
| | | " when t.TYPE = 0 then CONVERT( ST_Distance_Sphere ( POINT ( t.LGT, t.LAT ), POINT ( "+workerLgt+", "+workerLat+" )) /1000,DECIMAL(15,2)) " + |
| | | " when t.TYPE = 1 then CONVERT( ST_Distance_Sphere ( POINT ( t.LGT, t.LAT ), POINT ( "+driverLgt+", "+driverLat+" )) /1000,DECIMAL(15,2)) " + |
| | | " else CONVERT( ST_Distance_Sphere ( POINT ( t.LGT, t.LAT ), POINT ( "+chefLgt+", "+chefLat+" )) /1000,DECIMAL(15,2)) end " , Orders::getDistance) |
| | | .eq(Objects.nonNull(model.getType()),Orders::getType,model.getType()); |
| | | .eq(Objects.nonNull(model.getType()),Orders::getType,model.getType()) |
| | | .eq(Objects.nonNull(model.getCommentStatus()),Orders::getCommentStatus,model.getCommentStatus());; |
| | | if(!(Objects.isNull(model.getQueryLat())||Objects.isNull(model.getQueryLgt()))){ |
| | | queryWrapper.select(" case when T.LGT IS NULL OR T.LAT IS NULL THEN 0 " + |
| | | " when t.TYPE = 0 then CONVERT( ST_Distance_Sphere ( POINT ( t.LGT, t.LAT ), POINT ( "+workerLgt+", "+workerLat+" )) /1000,DECIMAL(15,2)) " + |
| | | " when t.TYPE = 1 then CONVERT( ST_Distance_Sphere ( POINT ( t.LGT, t.LAT ), POINT ( "+driverLgt+", "+driverLat+" )) /1000,DECIMAL(15,2)) " + |
| | | " else CONVERT( ST_Distance_Sphere ( POINT ( t.LGT, t.LAT ), POINT ( "+chefLgt+", "+chefLat+" )) /1000,DECIMAL(15,2)) end " , Orders::getDistance); |
| | | } |
| | | if(Objects.nonNull(model.getQueryMyOrderType())){ |
| | | if(Constants.equalsInteger(model.getQueryMyOrderType(),Constants.ZERO)){ |
| | | //发单方 我的订单 |
| | | queryWrapper.eq(Orders::getReleaseMemberId,model.getMember().getId()); |
| | | queryWrapper.eq(Objects.nonNull(model.getStatus()),Orders::getStatus,model.getStatus()); |
| | | queryWrapper.eq(Objects.nonNull(model.getStatus())&&!Constants.equalsInteger(model.getStatus(),Constants.ordersStatus.waitPay.getKey()),Orders::getStatus,model.getStatus()); |
| | | queryWrapper.in(Objects.nonNull(model.getStatus())&&Constants.equalsInteger(model.getStatus(),Constants.ordersStatus.waitPay.getKey()),Orders::getStatus,model.getStatus(),Constants.ordersStatus.feeconfirm.getKey()); |
| | | queryWrapper.orderByDesc(Orders::getCreateTime); |
| | | }else if(Constants.equalsInteger(model.getQueryMyOrderType(),Constants.ONE)){ |
| | | //接单方 我的订单 |
| | | queryWrapper.eq(Orders::getAcceptMemberId,model.getMember().getId()); |
| | | queryWrapper.eq(Objects.nonNull(model.getStatus()),Orders::getStatus,model.getStatus()); |
| | | // queryWrapper.in(Objects.nonNull(model.getStatus())&&Constants.equalsInteger(model.getStatus(),Constants.ordersStatus.waitPay.getKey()),Orders::getStatus,model.getStatus(),Constants.ordersStatus.feeconfirm.getKey()); |
| | | queryWrapper.orderByDesc(Orders::getAcceptTime); |
| | | }else{ |
| | | //查询用户的接单权重 |
| | | //查询用户的接单权重 接单大厅 |
| | | ReceiveWeight receiveWeight = receiveWeightMapper.selectOne(new QueryWrapper<ReceiveWeight>().lambda().eq(ReceiveWeight::getDeleted,Constants.ZERO).apply(" RECEIVE_MIN < "+model.getMember().getReceiveNum()+" and RECEIVE_MAX > " + model.getMember().getReceiveNum()).last(" limit 1 ")); |
| | | if(Objects.nonNull(receiveWeight)){ |
| | | queryWrapper.apply(" DATE_ADD(t.CREATE_TIME, INTERVAL "+receiveWeight.getDelayTime()+" MINUTE) < now() "); |
| | |
| | | IPage<Orders> iPage = ordersMapper.selectJoinPage(page,Orders.class,queryWrapper); |
| | | for (Orders orders:iPage.getRecords()) { |
| | | this.getPriceUnit(orders); |
| | | if(Constants.equalsInteger(model.getQueryMyOrderType(),Constants.ZERO)||Constants.equalsInteger(model.getQueryMyOrderType(),Constants.ONE)){ |
| | | orders.setStatusName( |
| | | Constants.equalsInteger(model.getQueryMyOrderType(),Constants.ZERO)?Constants.ordersStatus.getName(orders.getStatus()): |
| | | Constants.ordersStatus.getInfo(orders.getStatus()) |
| | | ); |
| | | } |
| | | } |
| | | // if(Objects.nonNull(model.getQueryMyOrderType())&&Constants.equalsInteger(model.getQueryMyOrderType(),Constants.TWO)){ |
| | | // if(Constants.equalsInteger(model.getMember().getUseIdentity(),Constants.ONE)){ |
| | | // model.getMember().setWorkerIdentityModel( |
| | | // identityInfoMapper.selectOne(new QueryWrapper<IdentityInfo>().lambda() |
| | | // .eq(IdentityInfo::getMemberId,model.getMember().getId()) |
| | | // .eq(IdentityInfo::getType,Constants.ZERO) |
| | | // .eq(IdentityInfo::getAuditStatus,Constants.TWO) |
| | | // .last("limit 1") |
| | | // ) |
| | | // ); |
| | | // model.getMember().setDriverIdentityModel( |
| | | // identityInfoMapper.selectOne(new QueryWrapper<IdentityInfo>().lambda() |
| | | // .eq(IdentityInfo::getMemberId,model.getMember().getId()) |
| | | // .eq(IdentityInfo::getType,Constants.ONE) |
| | | // .eq(IdentityInfo::getAuditStatus,Constants.TWO) |
| | | // .last("limit 1") |
| | | // ) |
| | | // ); |
| | | // model.getMember().setChefIdentityModel( |
| | | // identityInfoMapper.selectOne(new QueryWrapper<IdentityInfo>().lambda() |
| | | // .eq(IdentityInfo::getMemberId,model.getMember().getId()) |
| | | // .eq(IdentityInfo::getType,Constants.TWO) |
| | | // .eq(IdentityInfo::getAuditStatus,Constants.TWO) |
| | | // .last("limit 1") |
| | | // ) |
| | | // ); |
| | | // } |
| | | // for (Orders orders:iPage.getRecords()) { |
| | | // this.getDistance(model.getMember(),orders); |
| | | // } |
| | | // } |
| | | return PageData.from(iPage); |
| | | } |
| | | |
| | |
| | | } |
| | | orders.setStatusName(Constants.ordersStatus.getName(orders.getStatus())); |
| | | orders.setCancelStatus(Constants.ZERO); |
| | | if(Constants.equalsInteger(orders.getStatus(),Constants.ordersStatus.accept.getKey())&&Constants.equalsInteger(orders.getIsUpdate(),Constants.ONE)){ |
| | | String autoConfirmTime = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.AUTO_CONFIRM).getCode(); |
| | | orders.setConfirmCountdown(DateUtil.getXMinuteAfterDate(orders.getIsUpdateTime(),Integer.valueOf(autoConfirmTime)).getTime() - System.currentTimeMillis()); |
| | | if(orders.getConfirmCountdown()<=Constants.ZERO){ |
| | | orders.setConfirmCountdown(0L); |
| | | } |
| | | } |
| | | if(Constants.equalsInteger(orders.getStatus(),Constants.ordersStatus.waitPay.getKey())){ |
| | | orders.setCancelCountdown(DateUtil.getXMinuteAfterDate(orders.getCreateTime(),15).getTime() - System.currentTimeMillis()); |
| | | if(orders.getCancelCountdown()<=Constants.ZERO){ |
| | | orders.setCancelCountdown(0L); |
| | | } |
| | | } |
| | | this.getPriceUnit(orders); |
| | | orders.setCanStart(Constants.ZERO); |
| | | if(orders.getStatus() <= Constants.ordersStatus.accept.getKey()){ |
| | | if(Constants.equalsInteger(orders.getReleaseMemberId(),member.getId())){ |
| | | if(Constants.equalsInteger(orders.getStatus(),Constants.ordersStatus.accept.getKey())&&orders.getStartDate().getTime() <= System.currentTimeMillis()){ |
| | | orders.setCanStart(Constants.ONE); |
| | | } |
| | | //判断是否可修改 已取消次数 与 时间限制 |
| | | Integer totalCancelTimes = Integer.valueOf(systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.RELEASE_CANCEL_TIMES).getCode()); |
| | | Long cancelTimes = ordersMapper.selectCount(new QueryWrapper<Orders>().lambda() |
| | |
| | | @Override |
| | | public void autoGrabOrders(){ |
| | | String autoConfirmTime = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.AUTO_DISPATCH).getCode(); |
| | | List<Orders> ordersList = ordersMapper.selectList(new QueryWrapper<Orders>().lambda() |
| | | List<Orders> ordersList = ordersMapper.selectList(new QueryWrapper<Orders>().lambda().eq(Orders::getDeleted,Constants.ZERO) |
| | | .eq(Orders::getStatus,Constants.ONE).eq(Orders::getCommentStatus,Constants.ZERO) |
| | | .apply(" DATE_ADD(create_time, INTERVAL "+autoConfirmTime+" MINUTE) < now() ") |
| | | .last("limit 100") |
| | |
| | | BigDecimal lat = orders.getLat(); |
| | | BigDecimal lgt = orders.getLgt(); |
| | | //查询范围内的会员 |
| | | List<Member> memberList = memberMapper.selectList(new MPJLambdaWrapper<Member>().selectAll(Member.class) |
| | | .select(" ifnull((select r.level from receive_weight r where r.RECEIVE_MAX > t.RECEIVE_NUM and t.RECEIVE_NUM > r.RECEIVE_MIN limit 1 ),0) " ,Member::getLevel) |
| | | .select( " ifnull( (select CONVERT( ST_Distance_Sphere ( POINT ( ii.lgt, ii.lat ), POINT ( "+lgt+", "+lat+" )) /1000,DECIMAL(15,2)) from identity_info ii where ii.AUDIT_STATUS = 2 and type = 0 and ii.member_id = t.ID limit 1 ),0) ",Member::getDistance ) |
| | | |
| | | .apply(" id in (" + |
| | | " select ii.member_id from identity_info ii where ii.AUDIT_STATUS = 2 and type = '"+orders.getType()+"' " + |
| | | " and ( CONVERT( ST_Distance_Sphere ( POINT ( ii.lgt, ii.lat ), POINT ( "+lgt+", "+lat+" )) /1000,DECIMAL(15,2))) < 100 " + |
| | | ") ") |
| | | .orderByDesc(Member::getLevel) |
| | | .orderByDesc(Member::getScore) |
| | | .orderByAsc(Member::getDistance) |
| | | .last(" limit 1 ") |
| | | ); |
| | | List<Member> memberList = memberMapper.getList(lgt,lat,orders.getType(),orders.getReleaseMemberId()); |
| | | // memberMapper.selectList(new MPJLambdaWrapper<Member>() |
| | | // .select(Member::getId,Member::getScore) |
| | | // .select(" ifnull((select r.level from receive_weight r where r.RECEIVE_MAX > RECEIVE_NUM and RECEIVE_NUM > r.RECEIVE_MIN limit 1 ),0) " ,Member::getLevel) |
| | | // .select( " ifnull( (select CONVERT( ST_Distance_Sphere ( POINT ( ii.lgt, ii.lat ), POINT ( "+lgt+", "+lat+" )) /1000,DECIMAL(15,2)) from identity_info ii where ii.AUDIT_STATUS = 2 and type = 0 and ii.member_id = ID limit 1 ),0) ",Member::getDistance ) |
| | | //// |
| | | // .apply(" id in (" + |
| | | // " select ii.member_id from identity_info ii where ii.AUDIT_STATUS = 2 and type = '"+orders.getType()+"' " + |
| | | // " and ( CONVERT( ST_Distance_Sphere ( POINT ( ii.lgt, ii.lat ), POINT ( "+lgt+", "+lat+" )) /1000,DECIMAL(15,2))) < 100 " + |
| | | // ") ") |
| | | // .orderByDesc(" level , score ") |
| | | // .orderByAsc(Member::getDistance) |
| | | // .last(" limit 1 ") |
| | | // ); |
| | | if(CollectionUtils.isEmpty(memberList)){ |
| | | continue; |
| | | } |
| | | |
| | | Member member = memberList.get(Constants.ZERO); |
| | | Member releaseMember = memberMapper.selectById(orders.getReleaseMemberId()); |
| | | //自动派单 |
| | | Orders model = ordersMapper.selectById(orders.getStatus()); |
| | | if(!Constants.equalsInteger(model.getStatus(),Constants.ONE)){ |
| | | Orders model = ordersMapper.selectById(orders.getId()); |
| | | if(!Constants.equalsInteger(model.getStatus(),Constants.ONE) || Constants.equalsInteger(releaseMember.getId(),model.getReleaseMemberId())){ |
| | | //如果订单已删除 并且非发布方 |
| | | continue; |
| | | } |
| | | ordersMapper.update(new UpdateWrapper<Orders>().lambda().eq(Orders::getId,model.getId()) |
| | |
| | | ); |
| | | |
| | | //更新接单量 |
| | | memberMapper.update(new UpdateWrapper<Member>().lambda().setSql(" publish_num = (publish_num + 1 )").eq(Member::getId,member.getId())); |
| | | memberMapper.update(new UpdateWrapper<Member>().lambda().setSql(" RECEIVE_NUM = (ifnull(RECEIVE_NUM,0) + 1 )").eq(Member::getId,member.getId())); |
| | | |
| | | //创建操作日志 |
| | | Constants.OrdersLog ordersLog = Constants.OrdersLog.AUTO; |
| | | this.saveOrderLog(orders,ordersLog, |
| | | ordersLog.getInfo(),member.getId(),null); |
| | | |
| | | IdentityInfo wokerIdentityInfo = identityInfoMapper.selectOne(new QueryWrapper<IdentityInfo>().lambda() |
| | | .eq(IdentityInfo::getMemberId,member.getId()) |
| | | .eq(IdentityInfo::getType,orders.getType()) |
| | | .eq(IdentityInfo::getAuditStatus,Constants.TWO) |
| | | .last("limit 1") |
| | | ); |
| | | //通知发单方 |
| | | if(org.apache.commons.lang3.StringUtils.isNotBlank(releaseMember.getOpenid())&&Objects.nonNull(wokerIdentityInfo)){ |
| | | //发送微信通知 |
| | | sendWxMessage.acceptMessage(releaseMember.getOpenid(),orders,wokerIdentityInfo.getLinkName(),wokerIdentityInfo.getTelephone()); |
| | | } |
| | | |
| | | //通知接单方 |
| | | sendWxMessage.autoDispatchMessage(member.getOpenid(),orders,GeoUtils.haversineDistance( |
| | | orders.getLgt().doubleValue(), orders.getLat().doubleValue(), |
| | | wokerIdentityInfo.getLgt().doubleValue(), |
| | | wokerIdentityInfo.getLat().doubleValue() |
| | | )); |
| | | |
| | | aliSmsService.businessSendSms(Constants.smsContent.dispatch.getKey(),orders.getLinkPhone(),orders,null, |
| | | null,categoryMapper); |
| | | } |
| | | } |
| | | |
| | |
| | | public void autoConfirm(){ |
| | | String autoConfirmTime = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.AUTO_CONFIRM).getCode(); |
| | | List<Orders> ordersList = ordersMapper.selectList(new QueryWrapper<Orders>().lambda() |
| | | .eq(Orders::getStatus,Constants.ordersStatus.accept).eq(Orders::getIsUpdate,Constants.ONE) |
| | | .eq(Orders::getStatus,Constants.ordersStatus.accept.getKey()) |
| | | .eq(Orders::getIsUpdate,Constants.ONE) |
| | | .apply(" DATE_ADD(IS_UPDATE_TIME, INTERVAL "+autoConfirmTime+" MINUTE) < now() ") |
| | | .last("limit 100") |
| | | ); |
| | |
| | | //记录同意修改的日志 |
| | | Constants.OrdersLog ordersLog = Constants.OrdersLog.AUTO_AGREE; |
| | | this.saveOrderLog(orders,ordersLog, |
| | | ordersLog.getInfo(),null,null); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | //自动取消 订单未支付 |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) |
| | | public void autoCancelWaitPay(){ |
| | | List<Orders> ordersList = ordersMapper.selectList(new QueryWrapper<Orders>().lambda() |
| | | .eq(Orders::getStatus,Constants.ordersStatus.waitPay) |
| | | .apply(" DATE_ADD(CREATE_TIME, INTERVAL 15 MINUTE) < now() ") |
| | | .last("limit 100") |
| | | ); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ordersList)){ |
| | | for (Orders orders:ordersList) { |
| | | ordersMapper.update(new UpdateWrapper<Orders>().lambda() |
| | | .set(Orders::getStatus,Constants.ordersStatus.cancel.getKey()) |
| | | .set(Orders::getUpdateTime,DateUtil.getCurrDateTime()) |
| | | .set(Orders::getCancelTime,DateUtil.getCurrDateTime()) |
| | | .set(Orders::getCancelType,Constants.TWO) |
| | | .eq(Orders::getId,orders.getId()) |
| | | ); |
| | | //记录同意修改的日志 |
| | | Constants.OrdersLog ordersLog = Constants.OrdersLog.SYSTEM_CANCEL; |
| | | this.saveOrderLog(orders,ordersLog, |
| | | ordersLog.getInfo(),orders.getAcceptMemberId(),null); |
| | | } |
| | | } |