Browse Source

收银台数据

chao 3 years ago
parent
commit
d0c78c88ac

+ 0 - 1
src/main/java/com/caimei365/order/components/OrderCommonService.java

@@ -120,7 +120,6 @@ public class OrderCommonService {
                     order.setOnlinePayFlag(0);
                 } else {
                     order.setOnlinePayFlag(1);
-                    receiptAmount = tempAmount;
                 }
             }
         }

+ 58 - 0
src/main/java/com/caimei365/order/controller/OnlinePayApi.java

@@ -0,0 +1,58 @@
+package com.caimei365.order.controller;
+
+import com.caimei365.order.model.ResponseJson;
+import com.caimei365.order.service.OnlinePayService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Map;
+
+/**
+ * 在线支付API
+ *
+ * @author : Charles
+ * @date : 2021/7/29
+ */
+@Api(tags="在线支付API")
+@RestController
+@RequiredArgsConstructor
+@RequestMapping("/order/pay")
+public class OnlinePayApi {
+    private final OnlinePayService onlinePayService;
+
+    /**
+     * 获取线上支付全局开关状态
+     */
+    @ApiOperation("获取线上支付全局开关状态(旧:/PayOrder/onLineSwitch)")
+    @GetMapping("/online/switch")
+    public ResponseJson<Integer> getPayOnLineSwitch() {
+        return onlinePayService.getPayOnLineSwitch();
+    }
+
+
+    /**
+     * 收银台数据显示
+     */
+    @ApiOperation("收银台数据(旧:/PayOrder/checkoutCounter)")
+    @ApiImplicitParam(required = false, name = "orderId", value = "订单Id")
+    @GetMapping("/checkout/counter")
+    public ResponseJson<Map<String, Object>> getCheckoutCounter(Integer orderId) {
+        if (null == orderId) {
+            return ResponseJson.error("订单Id不能为空!", null);
+        }
+        return onlinePayService.getCheckoutCounter(orderId);
+    }
+
+
+
+
+
+
+
+
+}

+ 23 - 0
src/main/java/com/caimei365/order/mapper/OnlinePayMapper.java

@@ -0,0 +1,23 @@
+package com.caimei365.order.mapper;
+
+import com.caimei365.order.model.vo.OrderVo;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/7/29
+ */
+@Mapper
+public interface OnlinePayMapper {
+    /**
+     * 获取线上支付全局开关状态
+     */
+    Integer getPayOnLineSwitch();
+    /**
+     * 根据订单Id获取订单
+     * @param orderId 订单Id
+     */
+    OrderVo getOrderByOrderId(Integer orderId);
+}

+ 1 - 5
src/main/java/com/caimei365/order/mapper/OrderClubMapper.java

@@ -207,9 +207,5 @@ public interface OrderClubMapper {
      * 保存分享码使用记录
      */
     void insertOrderShareCodeRecord(OrderShareCodeRecordVo codeRecord);
-    /**
-     * 更具订单Id获取订单商品列表
-     * @param orderId 订单Id
-     */
-    List<OrderProductVo> getOrderProductByOrderId(Integer orderId);
+
 }

+ 5 - 0
src/main/java/com/caimei365/order/mapper/OrderCommonMapper.java

@@ -34,6 +34,11 @@ public interface OrderCommonMapper {
      * @param shopOrderId 子订单Id
      */
     List<OrderProductVo> getShopOrderProduct(Integer shopOrderId);
+    /**
+     * 更具订单Id获取订单商品列表
+     * @param orderId 订单Id
+     */
+    List<OrderProductVo> getOrderProductByOrderId(Integer orderId);
     /**
      * 支付记录(收款记录)
      * @param orderId 订单Id

+ 4 - 0
src/main/java/com/caimei365/order/model/vo/OrderVo.java

@@ -231,4 +231,8 @@ public class OrderVo implements Serializable {
      * 退款总金额
      */
     private Double returnedPurchaseFee;
+    /**
+     * 是否有商品发票属性的限制,为true时只能线下支付
+     */
+    private boolean invoiceStatus = false;
 }

+ 23 - 0
src/main/java/com/caimei365/order/service/OnlinePayService.java

@@ -0,0 +1,23 @@
+package com.caimei365.order.service;
+
+import com.caimei365.order.model.ResponseJson;
+
+import java.util.Map;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/7/29
+ */
+public interface OnlinePayService {
+    /**
+     * 获取线上支付全局开关状态
+     */
+    ResponseJson<Integer> getPayOnLineSwitch();
+    /**
+     * 收银台数据显示
+     * @param orderId 订单Id
+     */
+    ResponseJson<Map<String, Object>> getCheckoutCounter(Integer orderId);
+}

+ 101 - 0
src/main/java/com/caimei365/order/service/impl/OnlinePayServiceImpl.java

@@ -0,0 +1,101 @@
+package com.caimei365.order.service.impl;
+
+import com.caimei365.order.mapper.BaseMapper;
+import com.caimei365.order.mapper.OnlinePayMapper;
+import com.caimei365.order.mapper.OrderCommonMapper;
+import com.caimei365.order.model.ResponseJson;
+import com.caimei365.order.model.vo.DiscernReceiptVo;
+import com.caimei365.order.model.vo.OrderProductVo;
+import com.caimei365.order.model.vo.OrderVo;
+import com.caimei365.order.service.OnlinePayService;
+import com.caimei365.order.utils.MathUtil;
+import com.google.common.util.concurrent.AtomicDouble;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/7/29
+ */
+@Slf4j
+@Service
+public class OnlinePayServiceImpl implements OnlinePayService {
+    @Resource
+    private BaseMapper baseMapper;
+    @Resource
+    private OnlinePayMapper onlinePayMapper;
+    @Resource
+    private OrderCommonMapper orderCommonMapper;
+
+    /**
+     * 获取线上支付全局开关状态
+     */
+    @Override
+    public ResponseJson<Integer> getPayOnLineSwitch() {
+        Integer status = onlinePayMapper.getPayOnLineSwitch();
+        return ResponseJson.success(status);
+    }
+
+    /**
+     * 收银台数据显示
+     *
+     * @param orderId 订单Id
+     */
+    @Override
+    public ResponseJson<Map<String, Object>> getCheckoutCounter(Integer orderId) {
+        // 订单信息
+        OrderVo order = onlinePayMapper.getOrderByOrderId(orderId);
+        if (null == order) {
+            return ResponseJson.error("订单不存在", null);
+        }
+        // 机构信息
+        String userName = baseMapper.getUserNameByUserId(order.getUserId());
+        // 支付记录
+        List<DiscernReceiptVo> discernReceiptList = orderCommonMapper.getDiscernReceipt(order.getOrderId());
+        if (!discernReceiptList.isEmpty()) {
+            AtomicDouble receiptAmount = new AtomicDouble(0d);
+            AtomicReference<Boolean> offlineFlag = new AtomicReference<>(false);
+            discernReceiptList.forEach(discernReceipt -> {
+                if (2 == discernReceipt.getPayWay()) {
+                    offlineFlag.set(true);
+                }
+                if (3 == discernReceipt.getReceiptStatus()) {
+                    receiptAmount.set(MathUtil.add(receiptAmount.get(), discernReceipt.getAssociateAmount()).doubleValue());
+                }
+            });
+            if (offlineFlag.get()) {
+                return ResponseJson.error("已经线下支付过,只能支付支付!", null);
+            }
+            order.setReceiptAmount(receiptAmount.get());
+        }
+        // 商品数据
+        List<OrderProductVo> orderProductList = orderCommonMapper.getOrderProductByOrderId(orderId);
+        //过滤运费商品
+        orderProductList.removeIf(product -> product.getShopId() == 998);
+        // 是否有商品发票属性的限制
+        orderProductList.forEach(orderProduct -> {
+            // 商品含税未知 or 订单选择开企业发票,商品不含税不能开票
+            boolean productTaxFlag = (null == orderProduct.getIncludedTax()) || (null == orderProduct.getInvoiceType()) || (2 == orderProduct.getIncludedTax())
+                                     || (2 == order.getInvoiceFlag() && (0 == orderProduct.getIncludedTax() && 3 == orderProduct.getInvoiceType()));
+            if (productTaxFlag) {
+                order.setInvoiceStatus(true);
+            }
+        });
+        // 返回数据
+        Map<String, Object> map = new HashMap<>();
+        map.put("userName", userName);
+        map.put("order", order);
+        map.put("discernReceipt", discernReceiptList);
+        map.put("orderProductList", orderProductList);
+
+        return ResponseJson.success(map);
+    }
+}

+ 1 - 1
src/main/java/com/caimei365/order/service/impl/OrderClubServiceImpl.java

@@ -649,7 +649,7 @@ public class OrderClubServiceImpl implements OrderClubService {
      */
     @Override
     public ResponseJson<List<OrderProductVo>> getOrderShareInitProduct(Integer orderId) {
-        List<OrderProductVo> orderProductList = orderClubMapper.getOrderProductByOrderId(orderId);
+        List<OrderProductVo> orderProductList = orderCommonMapper.getOrderProductByOrderId(orderId);
         orderProductList.forEach(orderProduct -> orderProduct.setImage(ImageUtil.getImageUrl("product", orderProduct.getImage(), domain)));
         return ResponseJson.success(orderProductList);
     }

+ 53 - 0
src/main/resources/mapper/OnlinePayMapper.xml

@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.caimei365.order.mapper.OnlinePayMapper">
+    <select id="getPayOnLineSwitch" resultType="java.lang.Integer">
+        select status from cm_pay_online_switch where id=1
+    </select>
+    <select id="getOrderByOrderId" resultType="com.caimei365.order.model.vo.OrderVo">
+        SELECT
+            orderSource,
+            orderNo,
+            userID AS userId,
+            clubID AS clubId,
+            buyUserID AS buyUserId,
+            orderTime AS orderTime,
+            updateDate AS updateDate,
+            delFlag,
+            userBeans,
+            orderType,
+            orderSubmitType,
+            confirmFlag,
+            onlinePayFlag,
+            splitFlag,
+            payFlag,
+            receiptStatus,
+            payStatus,
+            zeroCostFlag,
+            sendOutStatus,
+            refundType,
+            affirmPaymentFlag,
+            productCount,
+            presentCount,
+            promotionalGiftsCount,
+            hasActProduct,
+            promotionFullReduction,
+            secondHandOrderFlag,
+            invoiceFlag,
+            freePostFlag AS postageFlag,
+            freight AS postage,
+            productTotalFee,
+            orderTotalFee,
+            payTotalFee,
+            payableAmount,
+            balancePayFee,
+            status,
+            confirmTime,
+            payTime,
+            rebateFlag,
+            clauseID AS clauseId,
+            clauseName
+        FROM cm_order
+        WHERE orderID = #{orderId}
+    </select>
+</mapper>

+ 0 - 50
src/main/resources/mapper/OrderClubMapper.xml

@@ -514,54 +514,4 @@
         WHERE scr.openid = #{openId} AND osc.orderID = #{orderId}
         AND scr.delFlag = '0' AND osc.expiredTime > NOW()
     </select>
-    <select id="getOrderProductByOrderId" resultType="com.caimei365.order.model.vo.OrderProductVo">
-        SELECT
-            cop.orderID AS orderId,
-            cop.orderNo,
-            cop.shopOrderID AS shopOrderId,
-            cop.shopOrderNo,
-            cop.orderPromotionsId,
-            cop.productId,
-            cop.shopId,
-            cop.name,
-            cop.image,
-            cop.price1 AS price,
-            cop.shopName,
-            cop.costPrice,
-            cop.normalPrice,
-            cop.ladderPriceFlag,
-            cop.discountPrice,
-            cop.discount,
-            cop.totalAmount,
-            cop.totalFee,
-            cop.shouldPayFee,
-            cop.productUnit,
-            cop.num,
-            cop.presentNum,
-            cop.discountFee,
-            cop.includedTax,
-            cop.invoiceType,
-            cop.taxRate,
-            cop.addedValueTax,
-            cop.totalAddedValueTax,
-            cop.singleShouldPayTotalTax,
-            cop.shouldPayTotalTax,
-            cop.shopProductAmount,
-            cop.singleShopFee,
-            cop.shopFee,
-            cop.singleOtherFee,
-            cop.otherFee,
-            cop.singleCmFee,
-            cop.cmFee,
-            cop.payStatus,
-            cop.buyAgainFlag,
-            cop.notOutStore,
-            cop.isActProduct AS actProduct,
-            p.productCategory as productCategory
-        FROM cm_order_product cop
-        LEFT JOIN product p ON cop.productID = p.productID
-        WHERE orderID = #{orderId}
-    </select>
-
-
 </mapper>

+ 49 - 0
src/main/resources/mapper/OrderCommonMapper.xml

@@ -174,4 +174,53 @@
     <select id="countSearchHistory" resultType="java.lang.Integer">
         SELECT COUNT(*) FROM user_order_history WHERE userId = #{userId}
     </select>
+    <select id="getOrderProductByOrderId" resultType="com.caimei365.order.model.vo.OrderProductVo">
+        SELECT
+        cop.orderID AS orderId,
+        cop.orderNo,
+        cop.shopOrderID AS shopOrderId,
+        cop.shopOrderNo,
+        cop.orderPromotionsId,
+        cop.productId,
+        cop.shopId,
+        cop.name,
+        cop.image,
+        cop.price1 AS price,
+        cop.shopName,
+        cop.costPrice,
+        cop.normalPrice,
+        cop.ladderPriceFlag,
+        cop.discountPrice,
+        cop.discount,
+        cop.totalAmount,
+        cop.totalFee,
+        cop.shouldPayFee,
+        cop.productUnit,
+        cop.num,
+        cop.presentNum,
+        cop.discountFee,
+        cop.includedTax,
+        cop.invoiceType,
+        cop.taxRate,
+        cop.addedValueTax,
+        cop.totalAddedValueTax,
+        cop.singleShouldPayTotalTax,
+        cop.shouldPayTotalTax,
+        cop.shopProductAmount,
+        cop.singleShopFee,
+        cop.shopFee,
+        cop.singleOtherFee,
+        cop.otherFee,
+        cop.singleCmFee,
+        cop.cmFee,
+        cop.payStatus,
+        cop.buyAgainFlag,
+        cop.notOutStore,
+        cop.isActProduct AS actProduct,
+        p.productCategory as productCategory
+        FROM cm_order_product cop
+        LEFT JOIN product p ON cop.productID = p.productID
+        WHERE orderID = #{orderId}
+        ORDER BY shopID ASC, productID ASC
+    </select>
 </mapper>