瀏覽代碼

优化商品下单

赵冬冬 4 年之前
父節點
當前提交
254ab88859

+ 8 - 2
forest-portal/portal-server/src/main/java/com/hwrj/cloud/portal/controller/WechatH5PayController.java

@@ -6,6 +6,7 @@ import com.github.binarywang.wxpay.constant.WxPayConstants;
 import com.github.binarywang.wxpay.exception.WxPayException;
 import com.github.binarywang.wxpay.service.WxPayService;
 import com.hwrj.cloud.common.api.CommonResult;
+import com.hwrj.cloud.common.exception.Asserts;
 import com.hwrj.cloud.portal.from.WxPayFrom;
 import com.hwrj.cloud.portal.model.OmsOrder;
 import com.hwrj.cloud.portal.service.OmsOrderPayService;
@@ -66,7 +67,12 @@ public class WechatH5PayController {
 
         orderRequest.setNonceStr(s);
         //商品描述
-        String productName = omsPortalOrderService.getProductName(orderId);
+        String productName = null;
+        try {
+            productName = omsPortalOrderService.getProductName(orderId);
+        } catch (Exception e) {
+            productName = "购买林产品!";
+        }
         orderRequest.setBody(productName);
         //商户订单号(支付编号)
         GeneratorIdUtils generatorIdUtils = new GeneratorIdUtils();
@@ -105,7 +111,7 @@ public class WechatH5PayController {
             //e.printStackTrace();
             log.error(e.getMessage());
             //签名完成新增支付订单
-            return CommonResult.failed("微信支付失败");
+            Asserts.fail("微信支付签名失败!");
         }
         //更新本地订单支付id
         //orderClient.update(data);

+ 13 - 2
forest-portal/portal-server/src/main/java/com/hwrj/cloud/portal/service/impl/OmsPortalOrderServiceImpl.java

@@ -767,7 +767,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
         order.setOrderType(0);
         //收货人信息:姓名、电话、邮编、地址
         UmsMemberReceiveAddress address = memberReceiveAddressService.getItem(orderParam.getMemberReceiveAddressId());
-        if(StringUtils.isEmpty(address)){
+        if (StringUtils.isEmpty(address)) {
             throw new RuntimeException("收货地址不存在!");
         }
         order.setReceiverName(address.getName());
@@ -1227,7 +1227,18 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
 
     @Override
     public String getProductName(Long orderId) {
-        return omsOrderDao.getProductName(orderId);
+        String productName = omsOrderDao.getProductName(orderId);
+
+        if(!StringUtils.isEmpty(productName)){
+            //去除最后一个逗号
+            productName = productName.substring(0, productName.length() - 1);
+            //字符串超过6000个字...拼接!
+            int length = 6000;
+            if(productName.length()>length){
+                productName = productName.substring(0, length)+"....";
+            }
+        }
+        return productName;
     }
 
 }

+ 1 - 1
forest-portal/portal-server/src/main/resources/dao/OmsOrderDao.xml

@@ -7,7 +7,7 @@
         SELECT
             GROUP_CONCAT(
                 a.product_brand,'-',
-                a.product_name
+                a.product_name,','
             )
         FROM
             oms_order_item a