Bläddra i källkod

支付问题修改

huan.wang@yueguanjia.com 5 år sedan
förälder
incheckning
9e2a37fe2f

+ 18 - 0
src/main/java/com/ygj/yuemum/controller/pay/CreatePayQrCodeController.java

@@ -2,8 +2,13 @@ package com.ygj.yuemum.controller.pay;
 
 
 import com.ygj.yuemum.component.Constant;
+import com.ygj.yuemum.domain.order.YSOrder;
+import com.ygj.yuemum.domain.pay.CustomerPay;
+import com.ygj.yuemum.domain.pay.PayMents;
+import com.ygj.yuemum.service.order.YSOrderService;
 import com.ygj.yuemum.service.pay.CustomerPayService;
 import io.swagger.annotations.Api;
+import io.swagger.models.auth.In;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import sun.misc.BASE64Encoder;
@@ -20,6 +25,8 @@ public class CreatePayQrCodeController {
     public static final String RESUMEFILE = Constant.RESUMEFILE;
     @Autowired
     private CustomerPayService customerPayService;
+    @Autowired
+    private YSOrderService ysOrderService;
 
     @RequestMapping(value = "/createPayQrCode", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
     @ResponseBody
@@ -33,6 +40,17 @@ public class CreatePayQrCodeController {
         Integer productId= Integer.parseInt(params.get("productId"));
         String payment_steps = params.get("payment_steps");
         String out_trade_no = orderNo + "SEQ" + payment_steps;
+        //check 本流水号是否已经付过款
+        CustomerPay customerPay = customerPayService.checkTrade(out_trade_no);
+        if (customerPay != null) {
+            //check 订单是否已经支付完成
+            YSOrder ysOrder =  ysOrderService.selectByOdNo(orderNo);
+            if (ysOrder.getOd_order_pay_amount() == 0) {
+                return "all";
+            } else {
+                out_trade_no = orderNo + "SEQ" + (Integer.parseInt(params.get("payment_steps")) + 1);
+            }
+        }
         BufferedImage bufferedImage =  customerPayService.createPayQrCode(out_trade_no,channel,price,originPrice,title,productName,productId);
         //保存一下
 //        ByteArrayOutputStream os = new ByteArrayOutputStream();

+ 0 - 7
src/main/java/com/ygj/yuemum/controller/pay/CustomerPayController.java

@@ -1,19 +1,12 @@
 package com.ygj.yuemum.controller.pay;
 
 
-import com.google.zxing.WriterException;
 import com.ygj.yuemum.domain.pay.CustomerPay;
 import com.ygj.yuemum.service.pay.CustomerPayService;
 import io.swagger.annotations.Api;
-import io.swagger.models.auth.In;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.swing.plaf.IconUIResource;
-import java.awt.image.BufferedImage;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;

+ 1 - 0
src/main/java/com/ygj/yuemum/dao/pay/CustomerPayDao.java

@@ -14,4 +14,5 @@ public interface CustomerPayDao {
     List<CustomerPay> queryCustomerPayAndVoucher(String cp_orderno);
     int checkCustomerPay (CustomerPay customerPay);
     double queryPaySumByOrderNo(String cp_orderno);
+    CustomerPay checkTrade(String out_trade_no);
 }

+ 16 - 2
src/main/java/com/ygj/yuemum/service/pay/CustomerPayService.java

@@ -24,9 +24,7 @@ import org.apache.http.util.EntityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import javax.swing.plaf.IconUIResource;
 import java.awt.image.BufferedImage;
-import java.io.ByteArrayOutputStream;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.Date;
@@ -105,6 +103,19 @@ public class CustomerPayService {
     }
 
     public int insertYsOrderPay(CustomerPay customerPay) {
+        if (customerPay.getOut_trade_no() == null ) {  //没有流水号
+            List<CustomerPay> customerPayOlds = customerPayDao.selectCustomerPay(customerPay.getCp_orderno());
+            if (customerPayOlds != null && customerPayOlds.size() > 0) {
+                CustomerPay customerPayTemp = customerPayOlds.get(customerPayOlds.size());
+                customerPay.setOut_trade_no(customerPayTemp.getCp_orderno() + "SEQ" + (customerPayOlds.size() + 1));
+                customerPay.setPayment_steps(customerPayOlds.size() + 1);
+                customerPay.setCp_paytype("1");
+            } else {
+                customerPay.setOut_trade_no(customerPay.getCp_orderno() + "SEQ" + "1");
+                customerPay.setCp_paytype("1");
+                customerPay.setCp_paytype("1");
+            }
+        }
         try {
             YSOrder ysOrder = ysOrderService.selectByOdNo(customerPay.getCp_orderno());
             BigDecimal amount = new BigDecimal(String.valueOf(ysOrder.getOd_order_amount()));
@@ -166,4 +177,7 @@ public class CustomerPayService {
 
         return qrCodeUtils.encodeIO(url, true);
     }
+    public CustomerPay checkTrade (String out_trade_no) {
+        return customerPayDao.checkTrade(out_trade_no);
+    }
 }

+ 4 - 7
src/main/resources/mybatis/mapper/order/YSOrder.xml

@@ -123,17 +123,14 @@
         od_date
         from ys_order
         where od_status != 99
-        <if test="od_date != null and od_date != ''">
-            and od_date like concat ('%',#{od_date,jdbcType=VARCHAR},'%')
-        </if>
         <if test="od_no != null and od_no != ''">
-            and od_no like concat ('%',#{od_no,jdbcType=VARCHAR},'%')
+            and od_no like concat ("%",#{od_no,jdbcType=VARCHAR},"%")
         </if>
         <if test="od_user_address != null and od_user_address != ''">
-            and od_user_address like concat ('%',#{od_user_address,jdbcType=VARCHAR},'%')
+            and od_user_address like "%"#{od_user_address,jdbcType=VARCHAR}"%"
         </if>
         <if test="od_user_name != null and od_user_name != ''">
-            and od_user_name like concat ('%',#{od_user_name,jdbcType=VARCHAR},'%')
+            and od_user_name like "%"#{od_user_name,jdbcType=VARCHAR}"%"
         </if>
         <if test="od_startdate != null and od_startdate != ''">
             and DATE_FORMAT(od_startdate,'%Y-%m-%d') &gt;= DATE_FORMAT(#{od_startdate,jdbcType=DATE},'%Y-%m-%d')
@@ -160,7 +157,7 @@
             and od_cityid = #{od_cityid,jdbcType=INTEGER}
         </if>
         <if test="od_contract != null and od_contract != ''">
-            and od_contract like concat ('%',#{od_contract,jdbcType=VARCHAR},'%')
+            and od_contract like "%"#{od_contract,jdbcType=VARCHAR}"%"
         </if>
         <if test="od_consultantid != null and od_consultantid != ''">
             and od_consultantid = #{od_consultantid,jdbcType=INTEGER}

+ 8 - 0
src/main/resources/mybatis/mapper/pay/CustomerPayMapper.xml

@@ -97,6 +97,14 @@
         order by id desc
     </select>
 
+    <select id="checkTrade" resultType="com.ygj.yuemum.domain.pay.CustomerPay" parameterType="java.lang.String" >
+        select
+            *
+        from customer_pay
+        where out_trade_no = #{out_trade_no,jdbcType=INTEGER}
+        order by id desc
+    </select>
+
     <!-- 插入一条培训信息 -->
     <insert id="insertCustomerPay" parameterType="com.ygj.yuemum.domain.pay.CustomerPay" >
         insert into customer_pay