From 77b52c06afdb843ee67c6e938afab0458143d76f Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期五, 05 九月 2025 10:48:48 +0800
Subject: [PATCH] 前端

---
 server/services/src/main/java/com/doumee/service/business/impl/OrdersServiceImpl.java |  234 ++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 179 insertions(+), 55 deletions(-)

diff --git a/server/services/src/main/java/com/doumee/service/business/impl/OrdersServiceImpl.java b/server/services/src/main/java/com/doumee/service/business/impl/OrdersServiceImpl.java
index 0041ca0..f015f0c 100644
--- a/server/services/src/main/java/com/doumee/service/business/impl/OrdersServiceImpl.java
+++ b/server/services/src/main/java/com/doumee/service/business/impl/OrdersServiceImpl.java
@@ -33,6 +33,7 @@
 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;
@@ -45,6 +46,7 @@
 
 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;
@@ -54,6 +56,7 @@
  * @author 姹熻箘韫�
  * @date 2025/07/09 12:00
  */
+@Slf4j
 @Service
 public class OrdersServiceImpl implements OrdersService {
 
@@ -145,6 +148,10 @@
         }else{
             orders.setStatus(Constants.ordersStatus.wait.getKey());
         }
+        orders.setOriginPriceNum1(orders.getPriceNum1());
+        orders.setOriginPriceNum2(orders.getPriceNum2());
+        orders.setOriginEstimatedAccount(orders.getOriginEstimatedAccount());
+        orders.setConfirmOtherFee(0l);
         ordersMapper.insert(orders);
 
         orderReleaseVO.setId(orders.getId());
@@ -254,9 +261,12 @@
         ){
             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))
+        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);
@@ -297,6 +307,12 @@
             }
             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);
@@ -310,9 +326,22 @@
                 ){
                     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()));
@@ -361,7 +390,8 @@
             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);
@@ -418,6 +448,10 @@
             }
             multifileMapper.insert(multifileList);
         }
+        orders.setOriginPriceNum1(orders.getPriceNum1());
+        orders.setOriginPriceNum2(orders.getPriceNum2());
+        orders.setOriginEstimatedAccount(orders.getOriginEstimatedAccount());
+        orders.setConfirmOtherFee(0l);
         ordersMapper.updateById(orders);
     }
 
@@ -474,9 +508,9 @@
         );
         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()));
                 }
             }
@@ -651,15 +685,15 @@
         //鏌ヨ鐢ㄦ埛鏄惁鏈夊搴旇韩浠�
         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(),"鎮ㄨ繕鏈敞鍐岃鏈嶅姟锛岃鍓嶅線涓汉淇℃伅涓彁浜ょ敵璇枫��");
             }
         }
 
@@ -685,14 +719,20 @@
                 .eq(IdentityInfo::getAuditStatus,Constants.TWO)
                 .last("limit 1")
         );
+        Member releaseMember = memberMapper.selectById(orders.getReleaseMemberId());
 
-        if(org.apache.commons.lang3.StringUtils.isNotBlank(member.getOpenid())&&Objects.nonNull(wokerIdentityInfo)){
-            //鍙戦�佸井淇¢�氱煡
-            sendWxMessage.acceptMessage(member.getOpenid(),orders,wokerIdentityInfo.getLinkName(),wokerIdentityInfo.getTelephone());
+        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);
+            }
         }
-        //鐭俊閫氱煡
-        aliSmsService.businessSendSms(Constants.smsContent.accept.getKey(),member.getTelephone(),orders,null,
-                wokerIdentityInfo,categoryMapper);
+
 
 
     }
@@ -767,6 +807,7 @@
                 .set(Orders::getIsUpdateTime,new Date())
                 .set(Orders::getUpdateTime,new Date())
                 .set(Orders::getEstimatedAccount,total)
+                .set(Orders::getOriginEstimatedAccount,total)
                 .eq(Orders::getId,orders.getId())
         );
         //鍒涘缓鎿嶄綔鏃ュ織
@@ -775,20 +816,25 @@
                 ordersLog.getInfo(),orders.getMember().getId(),null);
 
         //閫氱煡鎺ュ崟浜� 璁㈠崟鍙戠敓鍙樻洿
-        Member member = memberMapper.selectById(orders.getAcceptMemberId());
-        //鍙戦�佸井淇¢�氱煡
-        sendWxMessage.orderUpdMessage(member.getOpenid(),orders);
-
-        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);
+        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);
+            }
         }
 
     }
@@ -802,8 +848,9 @@
             throw new BusinessException(ResponseStatus.BAD_REQUEST);
         }
         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)
+                    && Constants.equalsInteger(orders.getWorkType(),Constants.ZERO ))
+                || Constants.equalsInteger(orders.getType(),Constants.ONE)
                 || Constants.equalsInteger(orders.getType(),Constants.TWO)
         ){
             orders.setPriceNum2(Constants.ONE);
@@ -812,9 +859,79 @@
                 throw new BusinessException(ResponseStatus.BAD_REQUEST);
             }
         }
-        return orders.getPrice() * orders.getPriceNum1() * orders.getPriceNum2();
+        BigDecimal bigDecimalPrice = orders.getPrice().
+                multiply(new BigDecimal(orders.getPriceNum1().toString()))
+                .multiply(new BigDecimal(orders.getPriceNum2().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());
+        Long totalFee = this.getTotal(orders);//閲嶆柊璁$畻璐圭敤
+        Long payFee = totalFee+Constants.formatLongNum(confirmUpdOrderDTO.getConfirmOtherFee());//閲嶆柊璁$畻璐圭敤
+        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,recFee.longValue())
+                .set(Orders::getUpdateTime,new Date())
+                .eq(Orders::getId,orders.getId())
+        );
+        //璁板綍鍚屾剰淇敼鐨勬棩蹇�
+        Constants.OrdersLog ordersLog = Constants.OrdersLog.FEE_CONFIRM;
+        this.saveOrderLog(orders,ordersLog,
+                ordersLog.getInfo(),confirmUpdOrderDTO.getMember().getId(),null);
+
+    }
 
     /**
      * 鎺ュ崟鏂瑰鐞嗚鍗曚慨鏀�
@@ -911,13 +1028,13 @@
                 .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)+"娆★紝鏄惁纭鍙栨秷";
 
@@ -1125,7 +1242,7 @@
         if(!Constants.equalsInteger(orders.getType(),Constants.TWO)){
             orders.setPayAccount(doneOrderDTO.getAmount());
             //鎻愭垚閲戦
-            Long tcje = Long.valueOf(new BigDecimal(orders.getPayAccount().toString()).multiply(orders.getPlatformRata()).intValue());
+            Long tcje =  (new BigDecimal(orders.getPayAccount().toString()).multiply(Constants.formatBigDecimal(orders.getPlatformRata())).setScale(0,RoundingMode.HALF_UP).longValue());
             orders.setReceiveAccount(orders.getPayAccount() - tcje);
             orders.setOutTradeNo(UUID.randomUUID().toString().replace("-",""));
             ordersMapper.updateById(orders);
@@ -1275,6 +1392,7 @@
                 );
         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.ZERO);
         }
@@ -1670,6 +1788,10 @@
         }
         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)){
+            orders.setConfirmCountdown(DateUtil.getXMinuteAfterDate(orders.getIsUpdateTime(),60).getTime() - System.currentTimeMillis());
+        }
+
         this.getPriceUnit(orders);
         if(orders.getStatus() <= Constants.ordersStatus.accept.getKey()){
             if(Constants.equalsInteger(orders.getReleaseMemberId(),member.getId())){
@@ -1762,7 +1884,7 @@
     @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")
@@ -1771,19 +1893,20 @@
             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());
+//                    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;
             }
@@ -1791,8 +1914,9 @@
             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(model.getId(),model.getReleaseMemberId())){
+               //濡傛灉璁㈠崟宸插垹闄� 骞朵笖闈炲彂甯冩柟
                 continue;
             }
             ordersMapper.update(new UpdateWrapper<Orders>().lambda().eq(Orders::getId,model.getId())
@@ -1804,7 +1928,7 @@
             );
 
             //鏇存柊鎺ュ崟閲�
-            memberMapper.update(new UpdateWrapper<Member>().lambda().setSql(" publish_num = (ifnull(publish_num,0) + 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;
@@ -1826,8 +1950,8 @@
             //閫氱煡鎺ュ崟鏂�
             sendWxMessage.autoDispatchMessage(member.getOpenid(),orders,GeoUtils.haversineDistance(
                     orders.getLgt().doubleValue(), orders.getLat().doubleValue(),
-                    member.getDriverIdentityModel().getLgt().doubleValue(),
-                    member.getDriverIdentityModel().getLat().doubleValue()
+                    wokerIdentityInfo.getLgt().doubleValue(),
+                    wokerIdentityInfo.getLat().doubleValue()
             ));
              
             aliSmsService.businessSendSms(Constants.smsContent.dispatch.getKey(),orders.getLinkPhone(),orders,null,

--
Gitblit v1.9.3