소스 검색

Merge remote-tracking branch 'origin/developerA' into developerA

# Conflicts:
#	src/main/java/com/caimei365/order/service/impl/CartClubServiceImpl.java
Aslee 3 년 전
부모
커밋
a73d33c055

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

@@ -77,7 +77,8 @@ public class OrderCommonService {
                 // 不含税可开票商品,单价/折后单价在原基础上加上税费
                 boolean taxFlag = (Integer.valueOf(0).equals(orderProduct.getIncludedTax()) && (Integer.valueOf(1).equals(orderProduct.getInvoiceType()) || Integer.valueOf(2).equals(orderProduct.getInvoiceType())));
                 if (taxFlag) {
-                    orderProduct.setPrice(MathUtil.add(orderProduct.getPrice(), orderProduct.getAddedValueTax()).doubleValue());
+                    Double valueTax = MathUtil.div(MathUtil.mul(orderProduct.getPrice(), orderProduct.getTaxRate()), 100).doubleValue();
+                    orderProduct.setPrice(MathUtil.add(orderProduct.getPrice(), valueTax).doubleValue());
                     orderProduct.setDiscountPrice(MathUtil.add(orderProduct.getPrice(), orderProduct.getAddedValueTax()).doubleValue());
                 }
                 orderProduct.setImage(ImageUtil.getImageUrl("product", orderProduct.getImage(), domain));

+ 3 - 3
src/main/java/com/caimei365/order/components/ProductService.java

@@ -44,9 +44,9 @@ public class ProductService {
         boolean taxFlag = (Integer.valueOf(0).equals(cartItemVo.getIncludedTax()) && (Integer.valueOf(1).equals(cartItemVo.getInvoiceType()) || Integer.valueOf(2).equals(cartItemVo.getInvoiceType())));
         if (taxFlag) {
             BigDecimal cartItemTax = MathUtil.div(MathUtil.mul(cartItemVo.getPrice(), cartItemVo.getTaxRate()), 100, 2);
-            double price = MathUtil.add(cartItemVo.getPrice(), cartItemTax).doubleValue();
-            cartItemVo.setPrice(price);
-            cartItemVo.setOriginalPrice(price);
+            BigDecimal originalcartItemTax = MathUtil.div(MathUtil.mul(cartItemVo.getOriginalPrice(), cartItemVo.getTaxRate()), 100, 2);
+            cartItemVo.setPrice(MathUtil.add(cartItemVo.getPrice(), cartItemTax).doubleValue());
+            cartItemVo.setOriginalPrice(MathUtil.add(cartItemVo.getOriginalPrice(), originalcartItemTax).doubleValue());
         }
         return taxFlag;
     }

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

@@ -83,5 +83,5 @@ public interface PayNonOrderService {
     /**
      * 升级超级会员-支付回调
      */
-    String paymentSuperVipCallback(String data);
+    String paymentSuperVipCallback(String data) throws NoSuchAlgorithmException, InvalidKeySpecException;
 }

+ 59 - 50
src/main/java/com/caimei365/order/service/impl/CartClubServiceImpl.java

@@ -105,6 +105,8 @@ public class CartClubServiceImpl implements CartClubService {
                 AtomicDouble shopReducedPrice = new AtomicDouble(0);
                 // 该供应商svip优惠金额
                 AtomicDouble shopSvipReducedPrice = new AtomicDouble(0);
+                // 该供应商划线价
+                AtomicDouble shopOriginalPrice = new AtomicDouble(0);
                 // 供应商促销优惠活动
                 PromotionsVo shopPromotion = baseMapper.getPromotionByShopId(shop.getShopId());
                 // 供应商下商品列表
@@ -132,8 +134,9 @@ public class CartClubServiceImpl implements CartClubService {
                                 // 超级会员设置商品优惠价
                                 productService.setSvipProductPrice(cartItemVo, taxFlag, svipUserFlag);
                                 if (svipUserFlag) {
-                                    // 超级会员设置超级会员优惠总额 + 商品优惠金额
-                                    shopSvipReducedPrice.set(MathUtil.add(shopSvipReducedPrice, cartItemVo.getSvipTotalReducedPrice()).doubleValue());
+                                    // 超级会员设置供应商价格-商品优惠金额,店铺优惠总额 + 商品优惠金额
+                                    shopPrice.set(MathUtil.sub(shopPrice.get(), cartItemVo.getSvipTotalReducedPrice()).doubleValue());
+                                    shopReducedPrice.set(MathUtil.add(shopReducedPrice, cartItemVo.getSvipTotalReducedPrice()).doubleValue());
                                 }
                             } else {
                                 // 获取商品促销信息
@@ -187,6 +190,7 @@ public class CartClubServiceImpl implements CartClubService {
                             }
                             // 该供应商下价格累加
                             shopPrice.set(MathUtil.add(shopPrice, MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice())).doubleValue());
+                            shopOriginalPrice.set(MathUtil.sub(shopOriginalPrice.get(), MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getOriginalPrice())).doubleValue());
                             // 该供应商下可参与店铺促销的商品价格累加
                             if (!(1 == cartItemVo.getSvipProductFlag() && svipUserFlag)) {
                                 // 超级会员购买svip商品不享受店铺促销优惠
@@ -289,6 +293,7 @@ public class CartClubServiceImpl implements CartClubService {
                     shop.setSvipReducedPrice(shopSvipReducedPrice.get());
                     // 供应商划线价
                     shop.setOriginalPrice(MathUtil.add(shopPrice.get(), shopReduction).doubleValue());
+                    shop.setOriginalPrice(shopOriginalPrice.get());
                     // 计算总价
                     totalPrice.set(MathUtil.add(totalPrice, shop.getTotalPrice()).doubleValue());
                     // 优惠总额
@@ -659,8 +664,6 @@ public class CartClubServiceImpl implements CartClubService {
         AtomicDouble totalPrice = new AtomicDouble(0);
         // 统计总促销满减
         AtomicDouble reducedPrice = new AtomicDouble(0);
-        // 统计总超级会员优惠
-        AtomicDouble svipReducedPrice = new AtomicDouble(0);
         // 统计总划线价
         AtomicDouble totalOriginalPrice = new AtomicDouble(0);
         // 促销活动(总)
@@ -702,6 +705,8 @@ public class CartClubServiceImpl implements CartClubService {
                     AtomicDouble shopPromotionFee = new AtomicDouble(0);
                     // 该供应商满减金额(供应商满减,单品满减)
                     AtomicDouble shopReducedPrice = new AtomicDouble(0);
+                    // 该供应商划线价
+                    AtomicDouble shopOriginalPrice = new AtomicDouble(0);
                     // 该供应商svip优惠金额
                     AtomicDouble shopSvipReducedPrice = new AtomicDouble(0);
                     // 供应商促销优惠活动
@@ -782,6 +787,7 @@ public class CartClubServiceImpl implements CartClubService {
                             }
                             // 该供应商下价格累加
                             shopPrice.set(MathUtil.add(shopPrice, MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice())).doubleValue());
+                            shopOriginalPrice.set(MathUtil.sub(shopOriginalPrice.get(), MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getOriginalPrice())).doubleValue());
                             // 该供应商下可参与店铺促销的商品价格累加
                             if (!(1 == cartItemVo.getSvipProductFlag() && svipUserFlag)) {
                                 // 超级会员购买svip商品不享受店铺促销优惠
@@ -841,6 +847,7 @@ public class CartClubServiceImpl implements CartClubService {
                             // 供应商划线价
                             shop.setOriginalPrice(MathUtil.add(shopPrice.get(), shopReduction).doubleValue());
 
+                            shop.setOriginalPrice(shopOriginalPrice.get());
                             // 添加供应商Id集合
                             shopIds.add(shop.getShopId());
                             // 计算总价
@@ -868,33 +875,34 @@ public class CartClubServiceImpl implements CartClubService {
         totalPromotions.forEach(promotions -> {
             // 该促销内商品总价
             double touchPrice = promotions.getProductList().stream().mapToDouble(product -> product.getNumber() * product.getPrice()).sum();
-            // 凑单满减
-            if (promotions.getType() == 2 && promotions.getMode() == 2) {
-                if (MathUtil.compare(touchPrice, promotions.getTouchPrice()) > -1) {
+            // 满足促销条件
+            if (MathUtil.compare(touchPrice, promotions.getTouchPrice()) > -1) {
+                // 凑单满减
+                if (promotions.getType() == 2 && promotions.getMode() == 2) {
                     // 总价 - 满减金额
                     totalPrice.set(MathUtil.sub(totalPrice, promotions.getReducedPrice()).doubleValue());
                     // 优惠总额 + 满减金额
                     reducedPrice.set(MathUtil.add(reducedPrice, promotions.getReducedPrice()).doubleValue());
+                } else if (promotions.getMode() == 3) {
+                    // 全部满赠
+                    promotions.getGiftList().forEach(gift -> {
+                        if (shopIds.contains(gift.getShopId())) {
+                            // 赠品在当前订单内的供应商下
+                            shopList.forEach(shop -> {
+                                if (shop.getShopId().equals(gift.getShopId())) {
+                                    shop.getCartList().add(gift);
+                                }
+                            });
+                        } else {
+                            // 获取赠品供应商
+                            CartShopVo giftShop = baseMapper.getShopByProductId(gift.getProductId());
+                            shopIds.add(giftShop.getShopId());
+                            giftShop.setCartList(new ArrayList<>());
+                            giftShop.getCartList().add(gift);
+                            shopList.add(giftShop);
+                        }
+                    });
                 }
-            } else if (promotions.getMode() == 3) {
-                // 全部满赠
-                promotions.getGiftList().forEach(gift -> {
-                    if (shopIds.contains(gift.getShopId())) {
-                        // 赠品在当前订单内的供应商下
-                        shopList.forEach(shop -> {
-                            if (shop.getShopId().equals(gift.getShopId())) {
-                                shop.getCartList().add(gift);
-                            }
-                        });
-                    } else {
-                        // 获取赠品供应商
-                        CartShopVo giftShop = baseMapper.getShopByProductId(gift.getProductId());
-                        shopIds.add(giftShop.getShopId());
-                        giftShop.setCartList(new ArrayList<>());
-                        giftShop.getCartList().add(gift);
-                        shopList.add(giftShop);
-                    }
-                });
             }
         });
 
@@ -914,7 +922,6 @@ public class CartClubServiceImpl implements CartClubService {
         resultData.put("totalCount", totalCount);
         resultData.put("totalPrice", totalPrice);
         resultData.put("reducedPrice", reducedPrice);
-        resultData.put("svipReducedPrice", svipReducedPrice);
         resultData.put("totalOriginalPrice", totalOriginalPrice);
         resultData.put("promotions", totalPromotions);
         resultData.put("invoice", invoice);
@@ -986,31 +993,33 @@ public class CartClubServiceImpl implements CartClubService {
             List<PromotionPriceVo> promotionPriceList = productService.getPromotionProducts(promotions, cartItemVo, taxFlag);
             promotions.setProductList(promotionPriceList);
             Double totalAmount = MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice()).doubleValue();
-            // 满减
-            if (promotions.getMode() == 2 && MathUtil.compare(totalAmount, promotions.getTouchPrice()) >= 0) {
-                // 总价 - 满减金额
-                totalPrice.set(MathUtil.sub(totalPrice.get(), promotions.getReducedPrice()).doubleValue());
-                // 优惠总额 + 满减金额
-                reducedPrice.set(MathUtil.add(reducedPrice.get(), promotions.getReducedPrice()).doubleValue());
-            }
-            if (promotions.getMode() == 3) {
-                // 获取赠品
-                List<CartItemVo> giftList = baseMapper.getPromotionGifts(promotions.getId());
-                giftList.forEach(gift -> {
-                    if (shop.getShopId().equals(gift.getShopId())) {
-                        // 赠品在当前订单内的供应商下
+            // 满足促销条件
+            if (MathUtil.compare(totalAmount, promotions.getTouchPrice()) >= 0) {
+                // 满减
+                if (promotions.getMode() == 2) {
+                    // 总价 - 满减金额
+                    totalPrice.set(MathUtil.sub(totalPrice.get(), promotions.getReducedPrice()).doubleValue());
+                    // 优惠总额 + 满减金额
+                    reducedPrice.set(MathUtil.add(reducedPrice.get(), promotions.getReducedPrice()).doubleValue());
+                } else if (promotions.getMode() == 3) {
+                    // 满赠
+                    List<CartItemVo> giftList = baseMapper.getPromotionGifts(promotions.getId());
+                    giftList.forEach(gift -> {
                         if (shop.getShopId().equals(gift.getShopId())) {
-                            shop.getCartList().add(gift);
+                            // 赠品在当前订单内的供应商下
+                            if (shop.getShopId().equals(gift.getShopId())) {
+                                shop.getCartList().add(gift);
+                            }
+                        } else {
+                            // 获取赠品供应商
+                            CartShopVo giftShop = baseMapper.getShopByProductId(gift.getProductId());
+                            giftShop.setCartList(new ArrayList<>());
+                            giftShop.getCartList().add(gift);
+                            shopList.add(giftShop);
                         }
-                    } else {
-                        // 获取赠品供应商
-                        CartShopVo giftShop = baseMapper.getShopByProductId(gift.getProductId());
-                        giftShop.setCartList(new ArrayList<>());
-                        giftShop.getCartList().add(gift);
-                        shopList.add(giftShop);
-                    }
-                });
-                promotions.setGiftList(giftList);
+                    });
+                    promotions.setGiftList(giftList);
+                }
             }
             // 添加到总促销
             totalPromotions.add(promotions);

+ 41 - 3
src/main/java/com/caimei365/order/service/impl/PayNonOrderServiceImpl.java

@@ -416,7 +416,7 @@ public class PayNonOrderServiceImpl implements PayNonOrderService {
             //商品名称
             String product = "采美订单" + orderId;
             json.put("product", product);
-            String attach = payParam.getProductId() + "," + payParam.getPayType();
+            String attach = payParam.getVipId() + "," + payParam.getPayType()+ "," + payParam.getUserId();
             json.put("attach", attach);
             // 升级超级会员默认公账
             List<Map<String, String>> list = new ArrayList<>();
@@ -481,8 +481,46 @@ public class PayNonOrderServiceImpl implements PayNonOrderService {
      * @param data
      */
     @Override
-    public String paymentSuperVipCallback(String data) {
-        return null;
+    public String paymentSuperVipCallback(String data) throws NoSuchAlgorithmException, InvalidKeySpecException {
+        log.info("******************** 升级超级会员异步回调 start *******************");
+        // 公钥解密
+        JSONObject json = PayUtil.publicKeyDecrypt(data, PayUtil.publicKey);
+        log.info("公钥解密>>>>>>" + json);
+        // 公钥验签
+        String signaa = json.getString("sign");
+        json.remove("sign");
+        String signbb = PayUtil.getPaySign(json, PayUtil.publicKey);
+        if (!signaa.equals(signbb)) {
+            return "验签失败";
+        }
+        // 订单状态
+        String orderStatus = json.getString("orderStatus");
+        // 平台唯一流水号
+        String mbOrderId = json.getString("mbOrderId");
+        // 金额,以元为单位
+        BigDecimal amount = json.getBigDecimal("amount");
+        log.info("订单状态>>>>>>" + orderStatus);
+        if ("FAILED".equals(orderStatus)) {
+            return "支付失败";
+        }
+        // 附加数据,支付时若有传输则原样返回(vipId,payType,userId),下单时为空,则不返回该数据
+        String attach = json.getString("attach");
+        String[] split = attach.split(",");
+        // 会员套餐Id
+        Integer vipId = Integer.valueOf(split[0]);
+        // 支付类型
+        String payType = split[1];
+        // 用户Id
+        Integer userId = Integer.valueOf(split[2]);
+        // 金额
+        double payAmount = amount.doubleValue();
+        String payFormData = json.toJSONString();
+
+        // todo 支付成功-超级会员数据库修改
+
+        //修改分账付款状态
+        payOrderMapper.updateSplitAccountByPay(mbOrderId);
+        return "SUCCESS";
     }
 
 }

+ 2 - 0
src/main/java/com/caimei365/order/service/impl/SubmitServiceImpl.java

@@ -756,6 +756,8 @@ public class SubmitServiceImpl implements SubmitService {
             shopOrder.setShopTaxFee(shopTaxFee.get());
             // 付供应商 = 商品费 + 运费 + 税费
             shopOrder.setShouldPayShopAmount(MathUtil.add(shopProductAmount.get(), shopTaxFee.get()).doubleValue());
+            // 付给供应商运费
+            shopOrder.setShopPostFee(0d);
             // 已付供应商金额
             shopOrder.setPayedShopAmount(0d);
             // (付款供应商)付款状态:1待付款、2部分付款、3已付款