Преглед изворни кода

fix 车位顺序;空车位模板消息

fix 车位顺序

fix 新增空车队发送模板消息
zoujiajian пре 3 година
родитељ
комит
cf74b36eac

+ 0 - 7
netflix-dao/src/main/java/com/cyksj/mapper/GroupsMapper.java

@@ -2,7 +2,6 @@ package com.cyksj.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.cyksj.model.entity.GroupsTrips;
-import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Update;
 
 /**
@@ -15,10 +14,4 @@ public interface GroupsMapper extends BaseMapper<GroupsTrips> {
 
     @Update("update groups_trips set available_num = available_num + 1 where id = #{groupId} and available_num < num")
     int incrAvailableNum(Long groupId);
-
-    @Update("update groups_trips set is_full_seat = true where id = #{id} and available_num = 0")
-    void tripsFullSeat(@Param("id") Long id);
-
-    @Update("update groups_trips set is_full_seat = false where id = #{id} and available_num > 0")
-    void tripsNoFullSeat(@Param("id") Long id);
 }

+ 5 - 3
netflix-dao/src/main/java/com/cyksj/model/views/GroupsView.java

@@ -4,6 +4,7 @@ import com.cyksj.model.manage.views.GroupsRelationView;
 import com.ejlchina.searcher.bean.DbField;
 import com.ejlchina.searcher.bean.DbIgnore;
 import com.ejlchina.searcher.bean.SearchBean;
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -36,9 +37,6 @@ public class GroupsView {
     @DbField("g.available_num")
     private Integer availableNum;
 
-    @DbField("g.is_full_seat")
-    private Boolean isFullSeat;
-
     /**
      * 状态
      */
@@ -51,6 +49,10 @@ public class GroupsView {
     @DbField("g.remark")
     private String remark;
 
+    @DbField("case when available_num = 0 then 66 when available_num != 0 then available_num end")
+    @JsonIgnore
+    private Integer orderBy;
+
     /**
      * 关系
      */

+ 16 - 9
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java

@@ -138,6 +138,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		User user = userMapper.selectById(payRequest.getUserId());
 		GoodsDonSku sku = goodsDonSkuMapper.selectById(payRequest.getSkuId());
 		GoodsDon goodsDon = goodsDonMapper.selectById(sku.getGoodsId());
+		Boolean isNew = false;
 		if (goodsDon == null || !goodsDon.getStatus()) {
 			throw new BusinessRuntimeException("商品已下架");
 		}
@@ -183,6 +184,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 						groupsRelation.setStatus(GroupsRelation.Status.none);
 						groupsRelationMapper.insert(groupsRelation);
 					}
+					isNew = true;
 				} else {
 					//寻找快满编车队进行占座
 					relation = groupsRelationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class)
@@ -238,7 +240,20 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		if (goodsDon.getType() == 2) {
 			saveTransport(payRequest.getAddressId(), orderDon.getId());
 		}
-
+		if (isNew) {
+			//新增空车队发送模板消息
+			TASK_POOL.execute(() -> {
+				try {
+					List<CustomerService> customerServices = customerServiceMapper.selectList(null);
+					for (CustomerService customerService : customerServices) {
+						log.info("发送客服{}空车位通知消息", customerService.getNickName());
+						emptySendMsgNotify(orderDon, customerService.getOpenId());
+					}
+				} catch (Exception e) {
+					log.error("发送{}空车位模板消息至客服失败:{}", orderDon.getGoodsId(), e);
+				}
+			});
+		}
 		jobManager.addJob(EXPIRY_TIME, () -> {
 			closeOrder(orderDon.getId());
 		});
@@ -846,10 +861,6 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 				log.error("车位异常 groupId:{}", relation.getGroupsId());
 				throw new BusinessRuntimeException("车位异常");
 			}
-			GroupsTrips groupsTrips = groupsMapper.selectOne(Wrappers.lambdaQuery(GroupsTrips.class).eq(GroupsTrips::getId, relation.getGroupsId()).last("limit 1"));
-			if (groupsTrips.getAvailableNum() == 0) {
-				groupsMapper.tripsFullSeat(groupsTrips.getId());
-			}
 		}
 	}
 
@@ -861,10 +872,6 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 			log.error("车位异常 groupId:{}", relation.getGroupsId());
 			throw new BusinessRuntimeException("车位异常");
 		}
-		GroupsTrips groupsTrips = groupsMapper.selectOne(Wrappers.lambdaQuery(GroupsTrips.class).eq(GroupsTrips::getId, relation.getGroupsId()).last("limit 1"));
-		if (groupsTrips.getIsFullSeat()) {
-			groupsMapper.tripsNoFullSeat(groupsTrips.getId());
-		}
 	}
 
 	public void saveTransport(Long addressId, Long orderId) {

+ 1 - 2
netflix-web/src/main/java/com/cyksj/web/controller/group/GroupController.java

@@ -32,8 +32,7 @@ public class GroupController {
     @GetMapping("/get")
     public Result<SearchResult<GroupsView>> get(){
         SearchResult<GroupsView> search = beanSearcher.search(GroupsView.class, MapUtils.flatBuilder(request.getParameterMap())
-                .orderBy(GroupsView::getIsFullSeat).asc()
-                .orderBy(GroupsView::getAvailableNum).asc()
+                .orderBy(GroupsView::getOrderBy).asc()
                 .orderBy(GroupsView::getId).desc().build()
         );
         search.getDataList().forEach((groupsView)->{