he2802 4 år sedan
förälder
incheckning
b99ebc0c19

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderServiceImpl.java

@@ -357,7 +357,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         if(!this.save(add)){
             throw new CustomException("订单数据错误");
         }
-        Map<String, String> result =  iWxPayService.paymentGzh(out_trade_no,userVo.getGzhOpenId(),body,price,url);
+        Map<String, String> result =  iWxPayService.paymentGzh(out_trade_no,userVo.getGzhOpenId(),body,totalPrice,url);
         return result;
     }
 

+ 2 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/wx/service/IWxPayService.java

@@ -9,6 +9,7 @@ import com.zhongzheng.modules.polyv.vo.PolyvVideoQuerVo;
 import com.zhongzheng.modules.polyv.vo.PolyvVideoVo;
 import com.zhongzheng.modules.wx.vo.WxPayVo;
 
+import java.math.BigDecimal;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
@@ -26,7 +27,7 @@ public interface IWxPayService {
 	 */
 	Map<String, String> payment(String out_trade_no,String openid,String body,String price);
 
-	Map<String, String> paymentGzh(String out_trade_no,String openid,String body,String price,String url);
+	Map<String, String> paymentGzh(String out_trade_no, String openid, String body, BigDecimal price, String url);
 
 	String paymentCallBack(String notifyData);
 

+ 5 - 3
zhongzheng-system/src/main/java/com/zhongzheng/modules/wx/service/impl/WxPayServiceImpl.java

@@ -57,6 +57,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.io.IOException;
+import java.math.BigDecimal;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
@@ -162,18 +163,19 @@ public class WxPayServiceImpl  implements IWxPayService {
     }
 
     @Override
-    public Map<String, String> paymentGzh(String out_trade_no, String openid, String body, String price,String url) {
+    public Map<String, String> paymentGzh(String out_trade_no, String openid, String body, BigDecimal price, String url) {
         WxSmallConfig config = new WxSmallConfig(gzhAppid,mchid,key);
         try {
             WXPay wxpay = new WXPay(config);
-
+            BigDecimal unit = new BigDecimal(100);
+            price = price.multiply(unit);
             Map<String, String> data = new HashMap<String, String>();
     //        data.put("attach", "pay");
             data.put("body", body);
             data.put("out_trade_no", out_trade_no);
             data.put("device_info", "");
             data.put("fee_type", "CNY");
-            data.put("total_fee", "1");
+            data.put("total_fee", price.toString());
             data.put("openid", openid);
             data.put("spbill_create_ip", IpUtils.getIpAddr(ServletUtils.getRequest()));
             data.put("notify_url", notifyUrl);