| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.config.wx.WxMiniConfig; |
| | | import com.doumee.config.wx.WxMiniUtilService; |
| | | import com.doumee.core.constants.Constants; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.OrdersMapper; |
| | | import com.doumee.dao.business.model.Orders; |
| | | import com.doumee.dao.business.*; |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.dao.dto.*; |
| | | import com.doumee.service.business.OrdersService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.wechat.pay.java.service.partnerpayments.jsapi.model.Amount; |
| | | import com.wechat.pay.java.service.partnerpayments.jsapi.model.Payer; |
| | | import com.wechat.pay.java.service.partnerpayments.jsapi.model.PrepayRequest; |
| | | import com.wechat.pay.java.service.partnerpayments.jsapi.model.PrepayWithRequestPaymentResponse; |
| | | import jodd.util.StringUtil; |
| | | import org.apache.poi.sl.image.ImageHeaderEMF; |
| | | import org.checkerframework.checker.units.qual.A; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * 订单信息记录Service实现 |
| | |
| | | @Autowired |
| | | private OrdersMapper ordersMapper; |
| | | |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | |
| | | @Autowired |
| | | private CategoryMapper categoryMapper; |
| | | |
| | | @Autowired |
| | | private MultifileMapper multifileMapper; |
| | | |
| | | @Autowired |
| | | private OrderLogMapper orderLogMapper; |
| | | |
| | | @Autowired |
| | | private MemberMapper memberMapper; |
| | | |
| | | @Autowired |
| | | private MemberRevenueMapper memberRevenueMapper; |
| | | |
| | | @Autowired |
| | | private WxMiniUtilService wxMiniUtilService; |
| | | |
| | | @Override |
| | | public Integer create(Orders orders) { |
| | | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) |
| | | public Object create(Orders orders) { |
| | | Object objects = null; |
| | | this.initVerification(orders); |
| | | orders.setCreateTime(new Date()); |
| | | orders.setPayStatus(Constants.ZERO); |
| | | //TODO 订单编号规则 |
| | | |
| | | |
| | | ordersMapper.insert(orders); |
| | | return orders.getId(); |
| | | Category category = categoryMapper.selectOne(new QueryWrapper<Category>().lambda() |
| | | .eq(Category::getDeleted,Constants.ZERO).eq(Category::getType,Constants.THREE) |
| | | .eq(Category::getName,orders.getType()) |
| | | .last("limit 1") |
| | | ); |
| | | if(Objects.isNull(category)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"参数配置错误,请联系管理员"); |
| | | } |
| | | //用餐订单 |
| | | if(Constants.equalsInteger(orders.getType(),Constants.TWO)){ |
| | | orders.setStatus(Constants.ZERO); |
| | | //唤起支付业务 |
| | | objects = this.getWxPayResponse(orders,orders.getMember().getOpenid()); |
| | | }else{ |
| | | orders.setStatus(Constants.ONE); |
| | | } |
| | | ordersMapper.insert(orders); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(orders.getMultifileList())){ |
| | | List<Multifile> multifileList = orders.getMultifileList(); |
| | | for (Multifile multifile:multifileList) { |
| | | if(Objects.isNull(multifile) |
| | | || Objects.isNull(multifile.getObjType()) |
| | | || StringUtils.isEmpty(multifile.getFileurl()) |
| | | || StringUtils.isEmpty(multifile.getName())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"附件信息错误"); |
| | | } |
| | | multifile.setIsdeleted(Constants.ZERO); |
| | | multifile.setCreateDate(new Date()); |
| | | multifile.setObjId(orders.getId()); |
| | | multifile.setObjType(Constants.ONE); |
| | | } |
| | | multifileMapper.insert(multifileList); |
| | | } |
| | | //更新用户发单量 |
| | | memberMapper.update(new UpdateWrapper<Member>().lambda().set(Member::getReceiveNum," (receive_num + 1 )").eq(Member::getId,orders.getMember().getId())); |
| | | |
| | | //创建操作日志 |
| | | Constants.OrdersLog ordersLog = Constants.OrdersLog.UPLOAD; |
| | | String orderTypeInfo = "用工单"; |
| | | if(!Constants.equalsInteger(orders.getType(),Constants.ZERO)){ |
| | | orderTypeInfo = Constants.equalsInteger(orders.getType(),Constants.ONE)?"用车单":"送餐单"; |
| | | }else{ |
| | | if(Constants.equalsInteger(orders.getWorkType(),Constants.ZERO)){ |
| | | orderTypeInfo = orderTypeInfo + "-采摘工"; |
| | | }else{ |
| | | orderTypeInfo = orderTypeInfo + (Constants.equalsInteger(orders.getWorkType(),Constants.ONE)?"-分拣工":"-包装工"); |
| | | } |
| | | } |
| | | String logInfo = ordersLog.getInfo() |
| | | .replace("{param}",orderTypeInfo); |
| | | this.saveOrderLog(orders,ordersLog, |
| | | logInfo,orders.getReleaseMemberId(),null); |
| | | return objects; |
| | | } |
| | | |
| | | private Object getWxPayResponse(Orders orders,String openid){ |
| | | Object response = null; |
| | | //调起支付 |
| | | PrepayRequest request = new PrepayRequest(); |
| | | request.setAttach("createOrder"); |
| | | request.setDescription("近快订单支付"); |
| | | request.setSpMchid(WxMiniConfig.wxProperties.getMchId()); |
| | | request.setSpAppid(WxMiniConfig.wxProperties.getAppId()); |
| | | request.setSubMchid(WxMiniConfig.wxProperties.getSubMchId()); |
| | | request.setSubAppid(WxMiniConfig.wxProperties.getSubAppId()); |
| | | Payer payer = new Payer(); |
| | | payer.setSubOpenid(openid); |
| | | request.setPayer(payer); |
| | | request.setOutTradeNo(orders.getCode()); |
| | | request.setNotifyUrl(WxMiniConfig.wxProperties.getNotifyUrl());//这个回调url必须是https开头的 |
| | | Amount amount = new Amount(); |
| | | amount.setTotal(orders.getEstimatedAccount().intValue()); |
| | | request.setAmount(amount); |
| | | // PrepayResponse res = WxMiniConfig.wxPayService.prepay(request); |
| | | // 跟之前下单示例一样,填充预下单参数 |
| | | PrepayWithRequestPaymentResponse resParam = WxMiniConfig.jsapiExtService.prepayWithRequestPayment(request,WxMiniConfig.wxProperties.getSubAppId()); |
| | | response =resParam; |
| | | return response; |
| | | } |
| | | |
| | | /** |
| | | * 日志信息 |
| | | * @param orders 订单信息 |
| | | * @param ordersLog 订单支持分类 |
| | | * @param logInfo 日志内容 |
| | | * @param memberId 移动端操作人 |
| | | * @param userId 系统操作人 |
| | | */ |
| | | public void saveOrderLog(Orders orders,Constants.OrdersLog ordersLog,String logInfo,Integer memberId,Integer userId){ |
| | | OrderLog orderLog = new OrderLog(); |
| | | orderLog.setCreateTime(orders.getUpdateTime()); |
| | | orderLog.setDeleted(Constants.ZERO); |
| | | orderLog.setOrderId(orders.getId()); |
| | | orderLog.setTitle(ordersLog.getName()); |
| | | orderLog.setLogInfo(logInfo); |
| | | orderLog.setObjType(ordersLog.getKey()); |
| | | orderLog.setOrderStatus(orders.getStatus()); |
| | | orderLog.setMemberId(memberId); |
| | | orderLog.setCreateUser(userId); |
| | | orderLog.setOptUserType(ordersLog.getUserType()); |
| | | orderLogMapper.insert(orderLog); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | |
| | | || Objects.isNull(orders.getLat()) |
| | | || Objects.isNull(orders.getLgt()) |
| | | || Objects.isNull(orders.getCategoryId()) |
| | | || Objects.isNull(orders.getTotalDays()) |
| | | || (Constants.equalsInteger(orders.getType(),Constants.ZERO) && Objects.isNull(orders.getWorkType())) |
| | | || Objects.isNull(orders.getPriceNum1()) |
| | | || (!( Constants.equalsInteger(orders.getType(),Constants.ZERO) |
| | | && Constants.equalsInteger(orders.getWorkType(),Constants.TWO) ) && Objects.isNull(orders.getPrice()) ) |
| | | || ( Constants.equalsInteger(orders.getType(),Constants.ONE) && Objects.isNull(orders.getTransportTypeId()) ) |
| | | |
| | | || Objects.isNull(orders.getEstimatedAccount()) |
| | | || Objects.isNull(orders.getPrice()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | |
| | | if(Constants.equalsInteger(orders.getType(),Constants.ONE)){ |
| | | |
| | | |
| | | if((Constants.equalsInteger(orders.getType(),Constants.ZERO) && Constants.equalsInteger(orders.getWorkType(),Constants.ZERO )) |
| | | || (Constants.equalsInteger(orders.getType(),Constants.ZERO) && Constants.equalsInteger(orders.getWorkType(),Constants.TWO) |
| | | &&Constants.equalsInteger(orders.getCarType(),Constants.TWO)) |
| | | || Constants.equalsInteger(orders.getType(),Constants.ONE) |
| | | ){ |
| | | orders.setPriceNum2(Constants.ONE); |
| | | } |
| | | |
| | | |
| | | if(Objects.isNull(orders.getPriceNum2())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | if(Constants.equalsInteger(orders.getType(),Constants.ZERO)){ |
| | | if(Constants.equalsInteger(orders.getWorkType(),Constants.TWO) |
| | | && Objects.isNull(orders.getCarType())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | }else if(Constants.equalsInteger(orders.getType(),Constants.ONE)){ |
| | | if(Objects.isNull(orders.getTransportTypeId()) |
| | | || Objects.isNull(orders.getCarType()) |
| | | || Objects.isNull(orders.getTransportNum()) |
| | | || StringUtils.isEmpty(orders.getTransportUnit()) |
| | | || StringUtils.isEmpty(orders.getLocationEnd()) |
| | | || Objects.isNull(orders.getLatEnd()) |
| | | || Objects.isNull(orders.getLgtEnd()) |
| | | || CollectionUtils.isEmpty(orders.getWayInfoDTOList()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | for (WayInfoDTO wayInfoDTO:orders.getWayInfoDTOList()) { |
| | | if(Objects.isNull(wayInfoDTO) |
| | | ||StringUtils.isEmpty(wayInfoDTO.getLocation()) |
| | | ||StringUtils.isEmpty(wayInfoDTO.getProvince()) |
| | | ||StringUtils.isEmpty(wayInfoDTO.getCity()) |
| | | ||StringUtils.isEmpty(wayInfoDTO.getArea()) |
| | | ||Objects.isNull(wayInfoDTO.getLat()) |
| | | ||Objects.isNull(wayInfoDTO.getLgt()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | } |
| | | orders.setWayInfo(JSONObject.toJSONString(orders.getWayInfoDTOList())); |
| | | }else{ |
| | | //用餐订单 |
| | | if(CollectionUtils.isEmpty(orders.getCateringDTOList())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | Long sumPrice = 0L; |
| | | for (CateringDTO cateringDTO:orders.getCateringDTOList()) { |
| | | if(Objects.isNull(cateringDTO) |
| | | || StringUtils.isEmpty(cateringDTO.getName()) |
| | | || Objects.isNull(cateringDTO.getPrice()) |
| | | || Objects.isNull(cateringDTO.getNum()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"用餐标准数据错误"); |
| | | } |
| | | sumPrice = sumPrice + (cateringDTO.getPrice() * cateringDTO.getNum()) ; |
| | | } |
| | | if(!sumPrice.equals(orders.getPrice())){ |
| | | 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(),"金额计算错误!"); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public void updateById(Orders orders) { |
| | | if(Objects.isNull(orders) |
| | | || Objects.isNull(orders.getId())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | Orders model = ordersMapper.selectById(orders.getId()); |
| | | if(Constants.equalsInteger(model.getType(),Constants.TWO)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"此类订单无法进行修改"); |
| | | } |
| | | if(!Constants.equalsInteger(model.getStatus(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行该操作"); |
| | | } |
| | | this.initVerification(orders); |
| | | orders.setUpdateTime(new Date()); |
| | | Category category = categoryMapper.selectOne(new QueryWrapper<Category>().lambda() |
| | | .eq(Category::getDeleted,Constants.ZERO).eq(Category::getType,Constants.THREE) |
| | | .eq(Category::getName,orders.getType()) |
| | | .last("limit 1") |
| | | ); |
| | | if(Objects.isNull(category)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"参数配置错误,请联系管理员"); |
| | | } |
| | | multifileMapper.update(new UpdateWrapper<Multifile>().lambda().set(Multifile::getIsdeleted,Constants.ONE).eq(Multifile::getObjType,Constants.ONE) |
| | | .eq(Multifile::getObjId,orders.getId())); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(orders.getMultifileList())){ |
| | | List<Multifile> multifileList = orders.getMultifileList(); |
| | | for (Multifile multifile:multifileList) { |
| | | if(Objects.isNull(multifile) |
| | | || Objects.isNull(multifile.getObjType()) |
| | | || StringUtils.isEmpty(multifile.getFileurl()) |
| | | || StringUtils.isEmpty(multifile.getName())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"附件信息错误"); |
| | | } |
| | | multifile.setIsdeleted(Constants.ZERO); |
| | | multifile.setCreateDate(new Date()); |
| | | multifile.setObjId(orders.getId()); |
| | | multifile.setObjType(Constants.ONE); |
| | | } |
| | | multifileMapper.insert(multifileList); |
| | | } |
| | | ordersMapper.updateById(orders); |
| | | } |
| | | |
| | |
| | | if (pageWrap.getModel().getPayAccount() != null) { |
| | | queryWrapper.lambda().eq(Orders::getPayAccount, pageWrap.getModel().getPayAccount()); |
| | | } |
| | | if (pageWrap.getModel().getPriceRemark() != null) { |
| | | queryWrapper.lambda().eq(Orders::getPriceRemark, pageWrap.getModel().getPriceRemark()); |
| | | } |
| | | if (pageWrap.getModel().getCarType() != null) { |
| | | queryWrapper.lambda().eq(Orders::getCarType, pageWrap.getModel().getCarType()); |
| | | } |
| | |
| | | QueryWrapper<Orders> wrapper = new QueryWrapper<>(orders); |
| | | return ordersMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 手动接单 |
| | | * @param orderId |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public void accept(Integer orderId,Member member){ |
| | | Orders orders = ordersMapper.selectById(orderId); |
| | | if(Objects.isNull(orders)||Constants.equalsInteger(orders.getDeleted(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(!Constants.equalsInteger(orders.getStatus(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行该操作"); |
| | | } |
| | | if(Constants.equalsInteger(orders.getReleaseMemberId(),member.getId())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"您自己的订单无法进行该操作"); |
| | | } |
| | | //查询用户是否有对应身份 |
| | | if(Constants.equalsInteger(orders.getType(),Constants.ZERO)){ |
| | | if(!Constants.equalsInteger(member.getWorkerIdentity(),Constants.TWO)){ |
| | | 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(),"身份信息异常,请联系管理员"); |
| | | } |
| | | }else{ |
| | | if(!Constants.equalsInteger(member.getChefIdentity(),Constants.TWO)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"身份信息异常,请联系管理员"); |
| | | } |
| | | } |
| | | orders.setUpdateTime(new Date()); |
| | | orders.setAcceptType(Constants.ZERO); |
| | | orders.setAcceptTime(new Date()); |
| | | orders.setAcceptMemberId(member.getId()); |
| | | orders.setStatus(Constants.TWO); |
| | | ordersMapper.updateById(orders); |
| | | //更新接单量 |
| | | memberMapper.update(new UpdateWrapper<Member>().lambda().set(Member::getPublishNum," (publish_num + 1 )").eq(Member::getId,member.getId())); |
| | | |
| | | //创建操作日志 |
| | | Constants.OrdersLog ordersLog = Constants.OrdersLog.RECEIVE; |
| | | this.saveOrderLog(orders,ordersLog, |
| | | ordersLog.getInfo(),member.getId(),null); |
| | | |
| | | //TODO 微信公众号提醒 已接单提醒 |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 开始作业 |
| | | * @param orderId |
| | | * @param member |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public void begin(Integer orderId,Member member){ |
| | | Orders orders = ordersMapper.selectById(orderId); |
| | | if(Objects.isNull(orders)||Constants.equalsInteger(orders.getDeleted(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(!Constants.equalsInteger(orders.getStatus(),Constants.TWO)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行该操作"); |
| | | } |
| | | if(Constants.equalsInteger(orders.getReleaseMemberId(),member.getId())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非您的订单无法进行该操作"); |
| | | } |
| | | if(Constants.equalsInteger(orders.getIsUpdate(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单修改待确认,无法进行该操作"); |
| | | } |
| | | orders.setUpdateTime(new Date()); |
| | | orders.setStatus(Constants.THREE); |
| | | orders.setWorkStartTime(new Date()); |
| | | ordersMapper.updateById(orders); |
| | | |
| | | //创建操作日志 |
| | | Constants.OrdersLog ordersLog = Constants.OrdersLog.BEGIN; |
| | | this.saveOrderLog(orders,ordersLog, |
| | | ordersLog.getInfo(),member.getId(),null); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 发单方修改订单 - 已接单状态 |
| | | * @param updOrderDataDTO |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public void updOrderData(UpdOrderDataDTO updOrderDataDTO){ |
| | | if(Objects.isNull(updOrderDataDTO) |
| | | || Objects.isNull(updOrderDataDTO.getOrderId()) |
| | | || Objects.isNull(updOrderDataDTO.getStartDate()) |
| | | || Objects.isNull(updOrderDataDTO.getEndDate()) |
| | | || Objects.isNull(updOrderDataDTO.getTotalDays())){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | Orders orders = ordersMapper.selectById(updOrderDataDTO.getOrderId()); |
| | | if(Objects.isNull(orders)||Constants.equalsInteger(orders.getDeleted(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(!Constants.equalsInteger(orders.getStatus(),Constants.TWO)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行该操作"); |
| | | } |
| | | if(Constants.equalsInteger(orders.getReleaseMemberId(),updOrderDataDTO.getMember().getId())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非您的订单无法进行该操作"); |
| | | } |
| | | if(Constants.equalsInteger(orders.getIsUpdate(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单已修改,待接单方确认,无法进行该操作"); |
| | | } |
| | | orders.setStartDate(updOrderDataDTO.getStartDate()); |
| | | orders.setEndDate(updOrderDataDTO.getEndDate()); |
| | | orders.setTotalDays(updOrderDataDTO.getTotalDays()); |
| | | //用车类型 |
| | | if(Constants.equalsInteger(orders.getType(),Constants.ONE)){ |
| | | if(Constants.equalsInteger(orders.getCarType(),Constants.ZERO)) { |
| | | orders.setPriceNum1(updOrderDataDTO.getTotalDays()); |
| | | } |
| | | }else if(Constants.equalsInteger(orders.getType(),Constants.ZERO)){ |
| | | if(Constants.equalsInteger(orders.getWorkType(),Constants.ONE)||(Constants.equalsInteger(orders.getWorkType(),Constants.TWO)&&Constants.equalsInteger(orders.getCarType(),Constants.ZERO))){ |
| | | orders.setPriceNum1(updOrderDataDTO.getTotalDays()); |
| | | } |
| | | }else{ |
| | | orders.setPriceNum1(updOrderDataDTO.getTotalDays()); |
| | | } |
| | | Long total = this.getTotal(orders); |
| | | ordersMapper.update(new UpdateWrapper<Orders>().lambda() |
| | | .set(Orders::getStartDate,updOrderDataDTO.getStartDate()) |
| | | .set(Orders::getEndDate,updOrderDataDTO.getEndDate()) |
| | | .set(Orders::getTotalDays,updOrderDataDTO.getTotalDays()) |
| | | .set(Orders::getIsUpdate,Constants.ONE) |
| | | .set(Orders::getUpdateTime,"now()") |
| | | .set(Orders::getEstimatedAccount,total) |
| | | .eq(Orders::getId,orders.getId()) |
| | | ); |
| | | //创建操作日志 |
| | | Constants.OrdersLog ordersLog = Constants.OrdersLog.UPD_ORDER; |
| | | this.saveOrderLog(orders,ordersLog, |
| | | ordersLog.getInfo(),updOrderDataDTO.getMember().getId(),null); |
| | | |
| | | //TODO 通知接单人 订单发生变更 |
| | | } |
| | | |
| | | |
| | | public Long getTotal(Orders orders){ |
| | | if( |
| | | (Constants.equalsInteger(orders.getType(),Constants.ZERO) && Constants.equalsInteger(orders.getWorkType(),Constants.ZERO )) || |
| | | (Constants.equalsInteger(orders.getType(),Constants.ZERO) && Constants.equalsInteger(orders.getWorkType(),Constants.TWO) |
| | | &&Constants.equalsInteger(orders.getCarType(),Constants.TWO)) |
| | | || Constants.equalsInteger(orders.getType(),Constants.ONE) |
| | | ){ |
| | | orders.setPriceNum2(Constants.ONE); |
| | | } |
| | | return orders.getPrice() * orders.getPriceNum1() * orders.getPriceNum2(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 接单方处理订单修改 |
| | | * @param confirmUpdOrderDTO |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public void confirmUpd(ConfirmUpdOrderDTO confirmUpdOrderDTO){ |
| | | if(Objects.isNull(confirmUpdOrderDTO) |
| | | || Objects.isNull(confirmUpdOrderDTO.getOrderId()) |
| | | || Objects.isNull(confirmUpdOrderDTO.getStatus()) |
| | | || !(Constants.equalsInteger(confirmUpdOrderDTO.getStatus(),Constants.ONE)|| |
| | | Constants.equalsInteger(confirmUpdOrderDTO.getStatus(),Constants.ZERO)) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | 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.getStatus(),Constants.TWO)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行该操作"); |
| | | } |
| | | if(!Constants.equalsInteger(orders.getIsUpdate(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单修改状态已流转,无法进行该操作"); |
| | | } |
| | | if(Constants.equalsInteger(orders.getAcceptMemberId(),confirmUpdOrderDTO.getMember().getId())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非您的订单无法进行该操作"); |
| | | } |
| | | if( Constants.equalsInteger(confirmUpdOrderDTO.getStatus(),Constants.ONE)){ |
| | | ordersMapper.update(new UpdateWrapper<Orders>().lambda() |
| | | .set(Orders::getIsUpdate,Constants.TWO) |
| | | .set(Orders::getUpdateTime,"now()") |
| | | .eq(Orders::getId,orders.getId()) |
| | | ); |
| | | //记录同意修改的日志 |
| | | Constants.OrdersLog ordersLog = Constants.OrdersLog.UPD_AGREE; |
| | | this.saveOrderLog(orders,ordersLog, |
| | | ordersLog.getInfo(),confirmUpdOrderDTO.getMember().getId(),null); |
| | | }else{ |
| | | ordersMapper.update(new UpdateWrapper<Orders>().lambda() |
| | | .set(Orders::getIsUpdate,Constants.TWO) |
| | | .set(Orders::getUpdateTime,"now()") |
| | | .set(Orders::getStatus,Constants.ONE) |
| | | .set(Orders::getAcceptMemberId,null) |
| | | .set(Orders::getAcceptType,null) |
| | | .eq(Orders::getId,orders.getId()) |
| | | ); |
| | | |
| | | memberMapper.update(new UpdateWrapper<Member>().lambda().set(Member::getReceiveNum,"receive_num - 1").eq(Member::getId,confirmUpdOrderDTO.getMember().getId())); |
| | | |
| | | //记录不同意修改的日志 |
| | | Constants.OrdersLog ordersLog = Constants.OrdersLog.UPD_DISAGREE; |
| | | this.saveOrderLog(orders,ordersLog, |
| | | ordersLog.getInfo(),confirmUpdOrderDTO.getMember().getId(),null); |
| | | |
| | | //TODO 发送不同意变更通知 |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 发单方取消订单 |
| | | * @param orderId |
| | | * @param member |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public void releaseCancelOrder(Integer orderId,Member member){ |
| | | Orders orders = ordersMapper.selectById(orderId); |
| | | if(Objects.isNull(orders)||Constants.equalsInteger(orders.getDeleted(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(!(Constants.equalsInteger(orders.getStatus(),Constants.ONE) |
| | | ||Constants.equalsInteger(orders.getStatus(),Constants.ZERO) |
| | | || Constants.equalsInteger(orders.getStatus(),Constants.TWO))){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行取消"); |
| | | } |
| | | if(Constants.equalsInteger(orders.getReleaseMemberId(),member.getId())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非您的订单无法进行该操作"); |
| | | } |
| | | //待支付用餐订单/待接单订单进行取消 |
| | | if(Constants.equalsInteger(orders.getStatus(),Constants.ONE) |
| | | ||Constants.equalsInteger(orders.getStatus(),Constants.ZERO)){ |
| | | if(Constants.equalsInteger(orders.getType(),Constants.TWO)&&Constants.equalsInteger(orders.getStatus(),Constants.ONE)){ |
| | | //退款业务 |
| | | WithdrawalOrders withdrawalOrders = new WithdrawalOrders(); |
| | | withdrawalOrders.setCreateTime(new Date()); |
| | | withdrawalOrders.setMemberId(orders.getReleaseMemberId()); |
| | | withdrawalOrders.setAmount(orders.getPayAccount()); |
| | | withdrawalOrders.setWxExternalNo("refund_"+orders.getCode()); |
| | | withdrawalOrders.setStatus(Constants.ONE); |
| | | withdrawalOrders.setDoneTime(new Date()); |
| | | withdrawalOrders.setType(Constants.ONE); |
| | | withdrawalOrders.setObjId(orders.getId()); |
| | | wxMiniUtilService.wxRefund(withdrawalOrders,orders); |
| | | } |
| | | ordersMapper.update(new UpdateWrapper<Orders>().lambda() |
| | | .set(Orders::getStatus,99) |
| | | .set(Orders::getUpdateTime,"now()") |
| | | .set(Orders::getCancelTime,"now()") |
| | | .set(Orders::getCancelType,Constants.ZERO) |
| | | .eq(Orders::getId,orders.getId()) |
| | | ); |
| | | }else{ |
| | | //判断是否可修改 已取消次数 与 时间限制 |
| | | Integer totalCancelTimes = Integer.valueOf(systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.RELEASE_CANCEL_TIMES).getCode()); |
| | | Long cancelTimes = ordersMapper.selectCount(new QueryWrapper<Orders>().lambda() |
| | | .apply(" DATE(cancel_time) = DATE(NOW()) ") |
| | | .eq(Orders::getStatus,99) |
| | | .eq(Orders::getReleaseMemberId,orders.getReleaseMemberId())); |
| | | //查询取消次数 |
| | | if(totalCancelTimes<=cancelTimes){ |
| | | 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+"小时,无法取消订单,如需处理请联系客服"); |
| | | } |
| | | |
| | | if(Constants.equalsInteger(orders.getType(),Constants.TWO)){ |
| | | //退款业务 |
| | | WithdrawalOrders withdrawalOrders = new WithdrawalOrders(); |
| | | withdrawalOrders.setCreateTime(new Date()); |
| | | withdrawalOrders.setMemberId(orders.getReleaseMemberId()); |
| | | withdrawalOrders.setAmount(orders.getPayAccount()); |
| | | withdrawalOrders.setWxExternalNo("refund_"+orders.getCode()); |
| | | withdrawalOrders.setStatus(Constants.ONE); |
| | | withdrawalOrders.setDoneTime(new Date()); |
| | | withdrawalOrders.setType(Constants.ONE); |
| | | withdrawalOrders.setObjId(orders.getId()); |
| | | wxMiniUtilService.wxRefund(withdrawalOrders,orders); |
| | | } |
| | | ordersMapper.update(new UpdateWrapper<Orders>().lambda() |
| | | .set(Orders::getStatus,99) |
| | | .set(Orders::getUpdateTime,"now()") |
| | | .set(Orders::getCancelTime,"now()") |
| | | .set(Orders::getCancelType,Constants.ONE) |
| | | .eq(Orders::getId,orders.getId()) |
| | | ); |
| | | //TODO 发单方取消订单通知接单方 |
| | | |
| | | //减少接单量 |
| | | memberMapper.update(new UpdateWrapper<Member>().lambda().set(Member::getReceiveNum,"receive_num - 1").eq(Member::getId,orders.getAcceptMemberId())); |
| | | } |
| | | //减少发单量 |
| | | memberMapper.update(new UpdateWrapper<Member>().lambda().set(Member::getPublishNum,"publish_num - 1").eq(Member::getId,orders.getReleaseMemberId())); |
| | | |
| | | //日志存储 |
| | | Constants.OrdersLog ordersLog = Constants.OrdersLog.RELEASE_CANCEL; |
| | | this.saveOrderLog(orders,ordersLog, |
| | | ordersLog.getInfo(),member.getId(),null); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 接单方取消接单 |
| | | * @param orderId |
| | | * @param member |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public void receiveCancelOrder(Integer orderId,Member member){ |
| | | Orders orders = ordersMapper.selectById(orderId); |
| | | if(Objects.isNull(orders)||Constants.equalsInteger(orders.getDeleted(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(!Constants.equalsInteger(orders.getStatus(),Constants.TWO)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行取消"); |
| | | } |
| | | if(Constants.equalsInteger(orders.getAcceptMemberId(),member.getId())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非您的订单无法进行该操作"); |
| | | } |
| | | //判断是否可修改 已取消次数 与 时间限制 |
| | | Integer totalCancelTimes = Integer.valueOf(systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.RECEIVE_CANCEL_TIMES).getCode()); |
| | | Long cancelTimes = orderLogMapper.selectCount(new QueryWrapper<OrderLog>().lambda() |
| | | .apply(" DATE(create_time) = DATE(NOW()) ") |
| | | .eq(OrderLog::getObjType,Constants.OrdersLog.CANCEL.getKey()) |
| | | .eq(OrderLog::getMemberId,member.getId())); |
| | | //查询取消次数 |
| | | if(totalCancelTimes<=cancelTimes){ |
| | | 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+"小时,无法取消订单,如需处理请联系客服"); |
| | | } |
| | | ordersMapper.update(new UpdateWrapper<Orders>().lambda() |
| | | .set(Orders::getUpdateTime,"now()") |
| | | .set(Orders::getStatus,Constants.ONE) |
| | | .set(Orders::getAcceptMemberId,null) |
| | | .set(Orders::getAcceptType,null) |
| | | .eq(Orders::getId,orders.getId()) |
| | | ); |
| | | |
| | | //减少接单量 |
| | | memberMapper.update(new UpdateWrapper<Member>().lambda().set(Member::getReceiveNum,"receive_num - 1").eq(Member::getId,orders.getAcceptMemberId())); |
| | | //日志存储 |
| | | Constants.OrdersLog ordersLog = Constants.OrdersLog.CANCEL; |
| | | this.saveOrderLog(orders,ordersLog, |
| | | ordersLog.getInfo(),member.getId(),null); |
| | | |
| | | //TODO 接单方取消订单通知 |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 完成订单 |
| | | * @param doneOrderDTO |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public Object doneOrder(DoneOrderDTO doneOrderDTO){ |
| | | if(Objects.isNull(doneOrderDTO)||Objects.isNull(doneOrderDTO.getOrderId())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | Orders orders = ordersMapper.selectById(doneOrderDTO.getOrderId()); |
| | | if(!Constants.equalsInteger(orders.getType(),Constants.TWO)&&Objects.isNull(doneOrderDTO.getAmount())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | if(Objects.isNull(orders)||Constants.equalsInteger(orders.getDeleted(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(!Constants.equalsInteger(orders.getStatus(),Constants.THREE)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行取消"); |
| | | } |
| | | if(Constants.equalsInteger(orders.getReleaseMemberId(),doneOrderDTO.getMember().getId())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非您的订单无法进行该操作"); |
| | | } |
| | | Object object = null; |
| | | //用餐订单 |
| | | if(!Constants.equalsInteger(orders.getType(),Constants.TWO)){ |
| | | orders.setPayAccount(doneOrderDTO.getAmount()); |
| | | //提成金额 |
| | | Long tcje = Long.valueOf(new BigDecimal(orders.getPayAccount().toString()).multiply(orders.getPlatformRata()).intValue()); |
| | | orders.setReceiveAccount(orders.getPayAccount() - tcje); |
| | | ordersMapper.updateById(orders); |
| | | //唤起支付业务 |
| | | object = this.getWxPayResponse(orders,orders.getMember().getOpenid()); |
| | | }else{ |
| | | orders.setStatus(Constants.FOUR); |
| | | //日志存储 |
| | | Constants.OrdersLog ordersLog = Constants.OrdersLog.DONE; |
| | | this.saveOrderLog(orders,ordersLog, |
| | | ordersLog.getInfo(),doneOrderDTO.getMember().getId(),null); |
| | | } |
| | | return object; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public void platformCancel(Integer orderId, LoginUserInfo loginUserInfo){ |
| | | Orders orders = ordersMapper.selectById(orderId); |
| | | if(Objects.isNull(orders)||Constants.equalsInteger(orders.getDeleted(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(!(Constants.equalsInteger(orders.getStatus(),Constants.ONE)||Constants.equalsInteger(orders.getStatus(),Constants.TWO) |
| | | ||Constants.equalsInteger(orders.getStatus(),Constants.THREE))){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行取消"); |
| | | } |
| | | //如果已支付 则需要进行退款 |
| | | if(Constants.equalsInteger(orders.getPayStatus(),Constants.ONE)){ |
| | | WithdrawalOrders withdrawalOrders = new WithdrawalOrders(); |
| | | withdrawalOrders.setCreateTime(new Date()); |
| | | withdrawalOrders.setMemberId(orders.getReleaseMemberId()); |
| | | withdrawalOrders.setAmount(orders.getPayAccount()); |
| | | withdrawalOrders.setWxExternalNo("refund_"+orders.getCode()); |
| | | withdrawalOrders.setStatus(Constants.ONE); |
| | | withdrawalOrders.setDoneTime(new Date()); |
| | | withdrawalOrders.setType(Constants.ONE); |
| | | withdrawalOrders.setObjId(orders.getId()); |
| | | wxMiniUtilService.wxRefund(withdrawalOrders,orders); |
| | | } |
| | | |
| | | //减少发单量 |
| | | memberMapper.update(new UpdateWrapper<Member>().lambda().set(Member::getPublishNum,"publish_num - 1").eq(Member::getId,orders.getReleaseMemberId())); |
| | | |
| | | if(Constants.equalsInteger(orders.getStatus(),Constants.TWO)||Constants.equalsInteger(orders.getStatus(),Constants.THREE)){ |
| | | //减少接单量 |
| | | memberMapper.update(new UpdateWrapper<Member>().lambda().set(Member::getReceiveNum,"receive_num - 1").eq(Member::getId,orders.getAcceptMemberId())); |
| | | } |
| | | |
| | | ordersMapper.update(new UpdateWrapper<Orders>().lambda() |
| | | .set(Orders::getStatus,99) |
| | | .set(Orders::getUpdateTime,"now()") |
| | | .set(Orders::getCancelTime,"now()") |
| | | .set(Orders::getCancelType,Constants.TWO) |
| | | .eq(Orders::getId,orders.getId()) |
| | | ); |
| | | |
| | | //日志存储 |
| | | Constants.OrdersLog ordersLog = Constants.OrdersLog.SYSTEM_CANCEL; |
| | | this.saveOrderLog(orders,ordersLog, |
| | | ordersLog.getInfo(),null,loginUserInfo.getId()); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void comment(CommentDTO commentDTO){ |
| | | if(Objects.isNull(commentDTO) |
| | | || Objects.isNull(commentDTO.getOrderId()) |
| | | || Objects.isNull(commentDTO.getLevel()) |
| | | || commentDTO.getLevel()<1 || commentDTO.getLevel() > 5 ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | Orders orders = ordersMapper.selectById(commentDTO.getOrderId()); |
| | | if(Objects.isNull(orders) |
| | | ||Constants.equalsInteger(orders.getDeleted(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(!Constants.equalsInteger(orders.getStatus(),Constants.FOUR)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单状态已流转,无法进行评价"); |
| | | } |
| | | if(Constants.equalsInteger(orders.getCommentStatus(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"订单已评价!"); |
| | | } |
| | | |
| | | ordersMapper.update(new UpdateWrapper<Orders>().lambda() |
| | | .set(Orders::getCommentStatus,Constants.ONE) |
| | | .set(Orders::getUpdateTime,"now()") |
| | | .set(Orders::getCommentTime,"now()") |
| | | .set(Orders::getCommentLevel,commentDTO.getLevel()) |
| | | .set(Orders::getCommentType,Constants.ZERO) |
| | | .eq(Orders::getId,orders.getId()) |
| | | ); |
| | | |
| | | memberMapper.update(new UpdateWrapper<Member>().lambda() |
| | | .set(Member::getScore," ( total_score +" + commentDTO.getLevel() + " ) / (score_order_num + 1 )") |
| | | .set(Member::getTotalScore," total_score +" + commentDTO.getLevel()) |
| | | .set(Member::getScoreOrderNum," score_order_num + 1 " ).eq(Member::getId,orders.getAcceptMemberId()) |
| | | ); |
| | | |
| | | //日志存储 |
| | | Constants.OrdersLog ordersLog = Constants.OrdersLog.COMMENT; |
| | | this.saveOrderLog(orders,ordersLog, |
| | | ordersLog.getInfo(),orders.getAcceptMemberId(),null); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 支付回调 |
| | | * @param preOrderId |
| | | * @param paymentNo |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public String payNotify(String preOrderId,String paymentNo){ |
| | | Orders orders = ordersMapper.selectOne(new QueryWrapper<Orders>().lambda().eq(Orders::getCode,preOrderId).last("limit 1")); |
| | | if(Constants.equalsInteger(orders.getType(),Constants.TWO)){ |
| | | //用餐订单 如果已经流转到已支付 则直接返回 |
| | | if(!Constants.equalsInteger(orders.getStatus(),Constants.ZERO)){ |
| | | return ("处理成功!"); |
| | | }else{ |
| | | //处理支付完成逻辑 |
| | | ordersMapper.update(new UpdateWrapper<Orders>().lambda() |
| | | .set(Orders::getUpdateTime,"now()") |
| | | .set(Orders::getStatus,Constants.ONE) |
| | | .set(Orders::getPayStatus,Constants.ONE) |
| | | .set(Orders::getWxExternalNo,paymentNo) |
| | | .eq(Orders::getId,orders.getId()) |
| | | ); |
| | | |
| | | //存储日志 |
| | | Constants.OrdersLog ordersLog = Constants.OrdersLog.PAY; |
| | | this.saveOrderLog(orders,ordersLog, |
| | | ordersLog.getInfo(),orders.getReleaseMemberId(),null); |
| | | } |
| | | }else{ |
| | | //非用餐类订单 |
| | | if(!Constants.equalsInteger(orders.getStatus(),Constants.THREE)){ |
| | | return ("处理成功!"); |
| | | }else{ |
| | | //处理支付完成逻辑 |
| | | ordersMapper.update(new UpdateWrapper<Orders>().lambda() |
| | | .set(Orders::getUpdateTime,"now()") |
| | | .set(Orders::getStatus,Constants.FOUR) |
| | | .set(Orders::getPayStatus,Constants.ONE) |
| | | .set(Orders::getWxExternalNo,paymentNo) |
| | | .set(Orders::getFinishTime,"now()") |
| | | .eq(Orders::getId,orders.getId()) |
| | | ); |
| | | |
| | | Member member = memberMapper.selectById(orders.getAcceptMemberId()); |
| | | //存储流水记录 |
| | | MemberRevenue memberRevenue = new MemberRevenue(); |
| | | memberRevenue.setCreateTime(new Date()); |
| | | memberRevenue.setMemberId(orders.getAcceptMemberId()); |
| | | memberRevenue.setType(orders.getType()); |
| | | memberRevenue.setOptType(Constants.ONE); |
| | | memberRevenue.setBeforeAmount(member.getAmount()); |
| | | memberRevenue.setAmount(orders.getReceiveAccount()); |
| | | memberRevenue.setAfterAmount(member.getAmount() + orders.getReceiveAccount()); |
| | | memberRevenue.setObjId(orders.getId()); |
| | | memberRevenue.setObjType(Constants.ZERO); |
| | | memberRevenue.setStatus(Constants.ZERO); |
| | | memberRevenueMapper.insert(memberRevenue); |
| | | |
| | | //更新接单用户的余额与历史总金额 |
| | | memberMapper.update(new UpdateWrapper<Member>().lambda() |
| | | .set(Member::getAmount,"amount + " + orders.getReceiveAccount() ) |
| | | .set(Member::getTotalAmount,"amount + " + orders.getReceiveAccount() ) |
| | | .eq(Member::getId,member.getId()) |
| | | ); |
| | | |
| | | //存储日志 |
| | | Constants.OrdersLog ordersLog = Constants.OrdersLog.PAY; |
| | | this.saveOrderLog(orders,ordersLog, |
| | | ordersLog.getInfo(),orders.getReleaseMemberId(),null); |
| | | |
| | | //TODO 通知接单方 款项已到账 |
| | | } |
| | | } |
| | | return ("处理成功!"); |
| | | } |
| | | |
| | | } |