zhs 3 years ago
parent
commit
ab502a4f3d

+ 7 - 0
src/main/java/com/supplier/controller/WxPayAppController.java

@@ -1,6 +1,7 @@
 package com.supplier.controller;
 
 import com.supplier.model.BuyOfferNum;
+import com.supplier.model.Supplier;
 import com.supplier.model.SupplierRelease;
 import com.supplier.model.WxPay;
 import com.supplier.service.SupplierReleaseService;
@@ -221,8 +222,14 @@ public class WxPayAppController extends WxPayUtils {
                                 .setCode(supplierRelease1.getCode())
                                 .setDemandUuid(supplierRelease1.getDemandUuid());
                         if(supplierRelease1.getCode().equals(list.get(0).getCode())){
+                            //修改状态为已付费
                             supplierRelease2.setOrderType("2");
                             supplierReleaseService.updatePrivateType(supplierRelease2);
+                            //用户购买报价单后将50%的资金转入供应商余额
+                            Supplier supplier = new Supplier()
+                                    .setCode(list.get(0).getCode())
+                                    .setBalanceOf(String.valueOf(Double.parseDouble(wxPay.getTotalFee()) * 0.5));
+                            wxPayService.addSupplierBalanceOf(supplier);
                         } else {
                             supplierRelease2.setOrderType("9");
                             supplierReleaseService.updatePrivateType(supplierRelease2);//修改状态

+ 3 - 4
src/main/java/com/supplier/mapper/WxPayMapper.java

@@ -1,9 +1,6 @@
 package com.supplier.mapper;
 
-import com.supplier.model.BuyOfferNum;
-import com.supplier.model.WxPay;
-import com.supplier.model.WxRefund;
-import com.supplier.model.WxWithdrawal;
+import com.supplier.model.*;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -54,4 +51,6 @@ public interface WxPayMapper {
     int getAuditRefundCount(WxRefund wxRefund);
 
     void deletePay(WxPay wxPay);
+
+    void addSupplierBalanceOf(Supplier supplier);
 }

+ 4 - 0
src/main/java/com/supplier/model/WxPay.java

@@ -80,4 +80,8 @@ public class WxPay implements Serializable {
      * 支付方式
      */
     private String payType;
+    /**
+     * 供应商余额
+     */
+    private String balanceOf;
 }

+ 4 - 0
src/main/java/com/supplier/model/WxRefund.java

@@ -80,4 +80,8 @@ public class WxRefund implements Serializable {
      * 退款用户编号  发消息用
      */
     private String offerCode;
+    /**
+     * 支付方式
+     */
+    private String payType;
 }

+ 3 - 4
src/main/java/com/supplier/service/WxPayService.java

@@ -1,9 +1,6 @@
 package com.supplier.service;
 
-import com.supplier.model.BuyOfferNum;
-import com.supplier.model.WxPay;
-import com.supplier.model.WxRefund;
-import com.supplier.model.WxWithdrawal;
+import com.supplier.model.*;
 
 import java.util.List;
 import java.util.Map;
@@ -39,4 +36,6 @@ public interface WxPayService {
     Map<String, Object> getOfferNum(BuyOfferNum buyOfferNum);
 
     Map<String, Object> getAuditRefund(WxRefund wxRefund);
+
+    void addSupplierBalanceOf(Supplier supplier);
 }

+ 11 - 0
src/main/java/com/supplier/service/impl/WxPayServiceImpl.java

@@ -117,6 +117,11 @@ public class WxPayServiceImpl implements WxPayService {
                     map.put("errMsg", "退款金额大于支付金额");
                     return map;
                 }
+                if(Double.parseDouble(refund.getRefundFee()) > Double.parseDouble(wxPay.getBalanceOf())){
+                    map.put("msg", "500");
+                    map.put("errMsg", "余额不足,请先充值");
+                    return map;
+                }
                 Map<String, Object> map1 = WxRefundContoller.refund(refund.getRefundFee(), wxPay);
                 if(map1.get("msg").equals("200")){
                     wxPayMapper.updateRefundType(wxRefund.getReleaseUuid(), wxRefund.getRefundState());
@@ -229,4 +234,10 @@ public class WxPayServiceImpl implements WxPayService {
         }
         return map;
     }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void addSupplierBalanceOf(Supplier supplier) {
+        wxPayMapper.addSupplierBalanceOf(supplier);
+    }
 }

+ 20 - 3
src/main/resources/config/mapping/WxPayMapper.xml

@@ -61,16 +61,25 @@
     </insert>
     <!-- 查询指定报价单的支付信息 -->
     <select id="getRefundVal" resultType="WxPay" parameterType="String">
-        select * from bus_pay where release_uuid = #{releUuid}
+        SELECT
+            a.*,
+            c.balance_of
+        FROM
+            bus_pay a
+                LEFT JOIN bus_supplier_release b ON a.release_uuid = b.uuid
+                LEFT JOIN sys_supplier c ON b.code = c.code
+        WHERE
+            a.release_uuid = #{releUuid}
     </select>
     <!-- 查询退款信息 -->
     <select id="getUserRefund" resultType="WxRefund">
         SELECT
-            TOP ${limit} a.*,b.offer_name,b.order_no,c.id as offerCode
+            TOP ${limit} a.*,b.offer_name,b.order_no,c.id as offerCode,d.pay_type as payType
         FROM
             bus_refund a
             JOIN (select uuid,code,offer_name,jdrq,order_no from bus_supplier_release where code = #{code} GROUP BY uuid,code,offer_name,jdrq,order_no) b on a.release_uuid = b.uuid
             LEFT JOIN sys_users c on a.code = c.code
+            LEFT JOIN bus_pay d on a.release_uuid = d.release_uuid
         WHERE
             a.id NOT IN
                 (
@@ -94,11 +103,12 @@
     <!-- 查询退款信息 -->
     <select id="getAuditRefund" resultType="WxRefund">
         SELECT
-            TOP ${limit} a.*,b.offer_name,b.order_no,c.id as offerCode
+            TOP ${limit} a.*,b.offer_name,b.order_no,c.id as offerCode,d.pay_type as payType
         FROM
             bus_refund a
             JOIN (select uuid,code,offer_name,jdrq,order_no from bus_supplier_release where code = #{code} GROUP BY uuid,code,offer_name,jdrq,order_no) b on a.release_uuid = b.uuid
             LEFT JOIN sys_users c on a.code = c.code
+            LEFT JOIN bus_pay d on a.release_uuid = d.release_uuid
         WHERE
             a.id NOT IN
             (
@@ -216,4 +226,11 @@
     <delete id="delOfferNum">
         delete from bus_buy_offer_num where uuid = #{uuid}
     </delete>
+    <!-- 用户购买报价单后将50%的资金转入供应商余额 -->
+    <update id="addSupplierBalanceOf" parameterType="Supplier">
+        UPDATE sys_supplier
+        SET balance_of = ( SELECT balance_of + ${balanceOf} FROM sys_supplier WHERE code = #{code} )
+        WHERE
+            code = #{code}
+    </update>
 </mapper>

+ 5 - 5
src/main/resources/static/js/personal/function.js

@@ -116,11 +116,11 @@ function zfbSupplierBalance(){
         totalFee = $("input[name=totalFee]").val();
     }
     //判断金额不能小于1
-    if(totalFee < 1){
-        layer.msg("金额不能小于1", {icon: 2});
-        layer.closeAll("loading");
-        return false;
-    }
+    // if(totalFee < 1){
+    //     layer.msg("金额不能小于1", {icon: 2});
+    //     layer.closeAll("loading");
+    //     return false;
+    // }
     //非空验证
     if(totalFee == 0){
         layer.msg("请填写或选择金额", {icon: 2});

+ 10 - 3
src/main/resources/static/js/refund/function.js

@@ -34,7 +34,7 @@ function getQuotation(page, limit, startTime, endTime){
                         buttonElem = "<button class=\"ignore_button button_div_head audit_refund\"><img src=\"/images/refund/refused.png\"/><span data-locale=\"yijujue\">"+ paramReturn("已拒绝", parent.type) +"</span></button>\n" +
                             "<button class=\"offer_button button_div_head\" onclick='offerClick(this)'><img src=\"/images/refund/tongyi.png\"/><span data-locale=\"tongyituikuan\">"+ paramReturn("同意退款", parent.type) +"</span></button>\n";
                     }
-                    $(".content_div").append("<div offerCode="+ item.offerCode +" uuid="+ AES_ECB_encrypt(AES_ECB_encrypt(item.releaseUuid, null), null) +" class=\"content_column\">\n" +
+                    $(".content_div").append("<div payType="+ item.payType +" offerCode="+ item.offerCode +" uuid="+ AES_ECB_encrypt(AES_ECB_encrypt(item.releaseUuid, null), null) +" class=\"content_column\">\n" +
                         "<div class=\"content_div_input\">\n" +
                         "<div class=\"head_name\" style=\"width: 5%;\">"+ (index + 1) +"</div>\n" +
                         "<div class=\"head_name\" style=\"width: 20%;\">"+ item.offerName +"</div>\n" +
@@ -82,10 +82,17 @@ function offerClick(obj){
     }, function () {
         layer.load(3);
         var uuid = $(obj).parent().parent().parent().attr("uuid");
-        var offerCode = $(obj).parent().parent().parent().attr("offerCode")
+        var offerCode = $(obj).parent().parent().parent().attr("offerCode");
+        var payType = $(obj).parent().parent().parent().attr("payType");
+        var url = "/wxRefund/refusedRefund";
+        if(payType == "微信支付"){
+            url = "/wxRefund/refusedRefund";
+        } else if(payType == "支付宝支付"){
+            url = "http://localhost:9600/zfbRefund/refusedRefund";
+        }
         sendPrivateText(offerCode);
         $.ajax({
-            url: "/wxRefund/refusedRefund",
+            url: url,
             type: "put",
             data: {
                 "refundState": "1",