Browse Source

志愿者看到的钱数动态展示

LiRong 3 months ago
parent
commit
ab93fee050

+ 29 - 1
leromro-core/src/main/java/com/leromro/core/controller/volunteerOrderController.java

@@ -9,6 +9,7 @@ import com.leromro.common.core.domain.R;
 import com.leromro.common.core.page.TableDataInfo;
 import com.leromro.common.utils.GeoUtils;
 import com.leromro.common.utils.SecurityUtils;
+import com.leromro.core.domain.OrderFrozenFunds;
 import com.leromro.core.domain.PlatformFinance;
 import com.leromro.core.domain.SecondOrder;
 import com.leromro.core.domain.dto.ConversationMsgDTO;
@@ -21,8 +22,12 @@ import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.List;
+import java.util.Map;
 import java.util.Objects;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 
 /**
  * 订单主Controller
@@ -44,6 +49,8 @@ public class volunteerOrderController extends BaseController {
     private IPlatformFinanceService platformFinanceService;
     @Autowired
     private IConversationRecordService conversationRecordService;
+    @Autowired
+    private IOrderFrozenFundsService orderFrozenFundsService;
 
     @ApiOperation("志愿者查询小订单列表")
     @GetMapping("/volunteerOrderList")
@@ -51,7 +58,28 @@ public class volunteerOrderController extends BaseController {
         startPage();
         Long userId = SecurityUtils.getUserId();
         List<VolunteerOrdersVO> list = secondOrderService.selectOrderList(userId, orderStatus);
-        list.forEach(volunteerOrdersVO -> volunteerOrdersVO.setServiceOnePrice(volunteerOrdersVO.getServiceOnePrice().multiply(BigDecimal.valueOf(volunteerOrdersVO.getSingleQuantity())).multiply(new BigDecimal("0.85"))));
+        List<Long> secondOrderIdList = list.stream().map(SecondOrder::getSecondOrderId).collect(Collectors.toList());
+        if(orderStatus.equals(4L)){
+            //如果已经完成
+            List<OrderFrozenFunds> orderFrozenFundsList = orderFrozenFundsService.list(new LambdaQueryWrapper<OrderFrozenFunds>().in(OrderFrozenFunds::getSecondOrderId, secondOrderIdList));
+            // 创建OrderId到OrderFrozenFunds的映射
+            Map<Long, OrderFrozenFunds> fundsMap = orderFrozenFundsList.stream()
+                    .collect(Collectors.toMap(OrderFrozenFunds::getSecondOrderId, Function.identity()));
+
+            // 遍历列表并设置serviceOnePrice
+            list.forEach(volunteerOrdersVO -> {
+                OrderFrozenFunds funds = fundsMap.get(volunteerOrdersVO.getSecondOrderId());
+                if(funds != null) {
+                    BigDecimal totalAmount = funds.getVolunteerMoney()
+                            .add(funds.getScoreMoney())
+                            .setScale(2, RoundingMode.HALF_UP);
+                    volunteerOrdersVO.setServiceOnePrice(totalAmount);
+                }
+            });
+        }else {
+            //如果订单还没有完成 列表上显示的是默认一星的钱数
+            list.forEach(volunteerOrdersVO -> volunteerOrdersVO.setServiceOnePrice(volunteerOrdersVO.getServiceOnePrice().multiply(BigDecimal.valueOf(volunteerOrdersVO.getSingleQuantity())).multiply(new BigDecimal("0.85")).setScale(2, RoundingMode.HALF_UP)));
+        }
         return getDataTable(list);
     }
 

+ 4 - 2
leromro-core/src/main/java/com/leromro/core/service/impl/MainOrderServiceImpl.java

@@ -30,6 +30,7 @@ import com.leromro.framework.config.ConstantsConfig;
 import com.leromro.system.mapper.SysConfigMapper;
 import com.leromro.system.mapper.SysDeptMapper;
 import com.leromro.system.mapper.SysUserMapper;
+import com.leromro.system.service.impl.SysConfigServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.redisson.api.RedissonClient;
 import org.springframework.beans.BeanUtils;
@@ -87,7 +88,7 @@ public class MainOrderServiceImpl extends ServiceImpl<MainOrdersMapper, MainOrde
     @Autowired
     private IConversationRecordService conversationRecordService;
     @Autowired
-    private SysConfigMapper sysConfigMapper;
+    private SysConfigServiceImpl sysConfigService;
 
     @Autowired
     private SendSmsUtil sendSmsUtil;
@@ -110,7 +111,8 @@ public class MainOrderServiceImpl extends ServiceImpl<MainOrdersMapper, MainOrde
     @Override
     @Transactional(rollbackFor = Exception.class)
     public R<OrderPaymentVO> createOrders(OrderRequestDTO orderRequest) throws Exception {
-        if (1==1) {
+        String s = sysConfigService.selectConfigByKey("OpenDeal");
+        if (s.equals("0")) {
             return R.fail("当前地区志愿者批量认证中,暂时关闭预约功能,请谅解");
         }
         //响应数据

+ 1 - 1
leromro-framework/src/main/java/com/leromro/framework/config/SecurityConfig.java

@@ -113,7 +113,7 @@ public class SecurityConfig
                 // 对于登录login 注册register 验证码captchaImage 允许匿名访问
                 requests.antMatchers("/login","/loginWeb", "/register", "/captchaImage","/system/dict/**,","/websocket/**",
                                 "/core/users/orders/payNotify","/core/users/orders/refundNotify","/system/config/getHomeRollText",
-                                "/system/config/serviceUrl/**","/core/searchHistory/info/businessTireNameHistory","/core/volunteer/info/searchBusinessTypeList",
+                                "/system/config/serviceUrl/**","/core/searchHistory/info/businessTireNameHistory","/core/volunteer/info/searchBusinessTypeList","/core/users/orders/web/hotService",
                                 "/core/volunteer/info/volunteerPicture","/setUserLocation").permitAll()
                     //微信小程序需要提供部分预览功能
                     .antMatchers("/core/volunteer/info/list","/core/volunteer/info/getDetails",