Просмотр исходного кода

外部订单下单添加备注/批量审核

wangxy 3 дней назад
Родитель
Сommit
a2f8bd8393

+ 8 - 0
fs-company/src/main/java/com/fs/company/controller/store/FsExternalOrderController.java

@@ -128,6 +128,14 @@ public class FsExternalOrderController extends BaseController {
         return fsExternalOrderService.auditExternalOrder(orderId, auditor);
     }
 
+    @Log(title = "批量审核外部订单", businessType = BusinessType.UPDATE)
+    @PostMapping("/auditBatch")
+    @PreAuthorize("@ss.hasPermi('store:externalOrder:audit')")
+    public R auditBatch(@RequestBody List<Long> orderIds) {
+        String auditor = SecurityUtils.getLoginUser().getUser().getUserName();
+        return fsExternalOrderService.batchAuditExternalOrder(orderIds, auditor);
+    }
+
     @Log(title = "取消外部订单", businessType = BusinessType.UPDATE)
     @PostMapping("/cancel/{orderId}")
     @PreAuthorize("@ss.hasPermi('store:externalOrder:cancel')")

+ 6 - 2
fs-company/src/main/java/com/fs/framework/config/DataSourceConfig.java

@@ -5,6 +5,7 @@ import com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatPropertie
 import com.alibaba.druid.util.Utils;
 import com.fs.common.enums.DataSourceType;
 import com.fs.framework.datasource.DynamicDataSource;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -35,6 +36,7 @@ public class DataSourceConfig {
     }
 
     @Bean
+    @ConditionalOnProperty(prefix = "spring.datasource.easycall", name = "enabled", havingValue = "true", matchIfMissing = true)
     @ConfigurationProperties(prefix = "spring.datasource.easycall.druid.master")
     public DataSource easyCallSource() {
         return new DruidDataSource();
@@ -45,11 +47,13 @@ public class DataSourceConfig {
     @Primary
     public DynamicDataSource dataSource(@Qualifier("masterDataSource") DataSource masterDataSource,
                                         @Qualifier("sopDataSource") DataSource sopDataSource,
-                                        @Qualifier("easyCallSource") DataSource easyCallSource) {
+                                        @Autowired(required = false) @Qualifier("easyCallSource") DataSource easyCallSource) {
         Map<Object, Object> targetDataSources = new HashMap<>();
         targetDataSources.put(DataSourceType.MASTER, masterDataSource);
         targetDataSources.put(DataSourceType.SOP.name(), sopDataSource);
-        targetDataSources.put(DataSourceType.EASYCALL.name(), easyCallSource);
+        if (easyCallSource != null) {
+            targetDataSources.put(DataSourceType.EASYCALL.name(), easyCallSource);
+        }
         return new DynamicDataSource(masterDataSource, targetDataSources);
     }
 

+ 5 - 0
fs-service/src/main/java/com/fs/his/service/IFsExternalOrderService.java

@@ -57,6 +57,11 @@ public interface IFsExternalOrderService {
      */
     R auditExternalOrder(Long orderId, String auditor);
 
+    /**
+     * 批量审核外部订单
+     */
+    R batchAuditExternalOrder(List<Long> orderIds, String auditor);
+
     /**
      * 取消外部订单
      * @param orderId 订单ID

+ 51 - 4
fs-service/src/main/java/com/fs/his/service/impl/FsExternalOrderServiceImpl.java

@@ -539,6 +539,11 @@ public class FsExternalOrderServiceImpl implements IFsExternalOrderService {
             return null;
         }
         ShopOrderDTO codOrderDTO = JSON.parseObject(JSON.toJSONString(shopOrderDTO), ShopOrderDTO.class);
+        FsStore fsStore = null;
+        if (order.getStoreId() != null) {
+            fsStore = fsStoreMapper.selectFsStoreByShopCode(order.getStoreId().toString());
+        }
+        BigDecimal amountMultiplier = resolveJstAmountMultiplier(fsStore);
         BigDecimal totalPrice = order.getTotalPrice() == null ? BigDecimal.ZERO : order.getTotalPrice();
         BigDecimal payPrice = order.getPayPrice() == null ? BigDecimal.ZERO : order.getPayPrice();
         BigDecimal codAmount = totalPrice.subtract(payPrice);
@@ -546,10 +551,11 @@ public class FsExternalOrderServiceImpl implements IFsExternalOrderService {
             codAmount = BigDecimal.ZERO;
         }
         codOrderDTO.setIsCod(true);
-        codOrderDTO.setPayAmount(totalPrice.doubleValue());
+        // 货到付款:应收/商品总额、代收金额同样按店铺倍数推送
+        codOrderDTO.setPayAmount(multiplyForJst(totalPrice, amountMultiplier));
 
         PaymentDTO paymentDTO = new PaymentDTO();
-        paymentDTO.setAmount(codAmount.doubleValue());
+        paymentDTO.setAmount(multiplyForJst(codAmount, amountMultiplier));
         paymentDTO.setOuterPayId(String.format("%s%d", order.getOrderCode(), 1));
         paymentDTO.setPayDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
         paymentDTO.setPayment("货到付款");
@@ -578,8 +584,14 @@ public class FsExternalOrderServiceImpl implements IFsExternalOrderService {
         shopOrderDTO.setOrderDate(sdf.format(new Date()));
         shopOrderDTO.setShopStatus("WAIT_SELLER_SEND_GOODS");
         shopOrderDTO.setShopBuyerId(order.getUserName());
-        shopOrderDTO.setPayAmount(order.getTotalPrice().doubleValue());
+        // 推送聚水潭金额倍数:店铺名含「商贸」x2,普通店 x10(仅改推送金额,本地订单不变)
+        BigDecimal amountMultiplier = resolveJstAmountMultiplier(fsStore);
+        BigDecimal totalPrice = order.getTotalPrice() == null ? BigDecimal.ZERO : order.getTotalPrice();
+        BigDecimal payPrice = order.getPayPrice() == null ? BigDecimal.ZERO : order.getPayPrice();
+        shopOrderDTO.setPayAmount(multiplyForJst(totalPrice, amountMultiplier));
         shopOrderDTO.setFreight(order.getFreightPrice() != null ? order.getFreightPrice().doubleValue() : 0.0);
+        log.info("外部订单{}推送聚水潭金额倍数={}, 店铺={}, 原总额={}, 原定金={}",
+                order.getOrderCode(), amountMultiplier, fsStore.getStoreName(), totalPrice, payPrice);
 
         StringBuilder remarkBuilder = new StringBuilder();
         if (order.getCompanyId() != null) {
@@ -638,7 +650,7 @@ public class FsExternalOrderServiceImpl implements IFsExternalOrderService {
         shopOrderDTO.setItems(itemDTOList);
 
         PaymentDTO paymentDTO = new PaymentDTO();
-        paymentDTO.setAmount(order.getPayPrice().doubleValue());
+        paymentDTO.setAmount(multiplyForJst(payPrice, amountMultiplier));
         paymentDTO.setOuterPayId(order.getOrderCode());
         paymentDTO.setPayDate(sdf.format(new Date()));
         paymentDTO.setPayment("微信支付");
@@ -649,6 +661,23 @@ public class FsExternalOrderServiceImpl implements IFsExternalOrderService {
         return shopOrderDTO;
     }
 
+    /**
+     * 推送聚水潭金额倍数:店铺名称包含「商贸」乘 2,否则乘 10
+     */
+    private BigDecimal resolveJstAmountMultiplier(FsStore fsStore) {
+        String storeName = fsStore == null ? null : fsStore.getStoreName();
+        if (StringUtils.isNotBlank(storeName) && storeName.contains("商贸")) {
+            return BigDecimal.valueOf(2);
+        }
+        return BigDecimal.valueOf(10);
+    }
+
+    private double multiplyForJst(BigDecimal amount, BigDecimal multiplier) {
+        BigDecimal base = amount == null ? BigDecimal.ZERO : amount;
+        BigDecimal factor = multiplier == null ? BigDecimal.ONE : multiplier;
+        return base.multiply(factor).doubleValue();
+    }
+
     @Override
     public void syncOrderStatusFromJst() throws Exception {
         FsSysConfig sysConfig = configUtil.getSysConfig();
@@ -930,6 +959,24 @@ public class FsExternalOrderServiceImpl implements IFsExternalOrderService {
         return R.error("审核失败");
     }
 
+    @Override
+    public R batchAuditExternalOrder(List<Long> orderIds, String auditor) {
+        if (CollectionUtils.isEmpty(orderIds)) {
+            return R.error("请选择要审核的订单");
+        }
+        int successCount = 0;
+        int skipCount = 0;
+        for (Long orderId : orderIds) {
+            R result = auditExternalOrder(orderId, auditor);
+            if (result != null && Integer.valueOf(200).equals(result.get("code"))) {
+                successCount++;
+            } else {
+                skipCount++;
+            }
+        }
+        return R.ok("审核成功 " + successCount + " 条,跳过 " + skipCount + " 条");
+    }
+
     @Override
     public R cancelExternalOrder(Long orderId) {
         FsExternalOrder order = fsExternalOrderMapper.selectFsExternalOrderByOrderId(orderId);