Преглед изворни кода

增加乐团缴费状态查询

周箭河 пре 5 година
родитељ
комит
a461265ebb

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysAccountDao.java

@@ -0,0 +1,9 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.ym.mec.biz.dal.entity.SysAccount;
+import com.ym.mec.common.dal.BaseDAO;
+
+public interface SysAccountDao extends BaseDAO<Integer, SysAccount> {
+
+    int updateByPrimaryKey(SysAccount record);
+}

+ 93 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SysAccount.java

@@ -0,0 +1,93 @@
+package com.ym.mec.biz.dal.entity;
+
+import java.math.BigDecimal;
+
+public class SysAccount {
+    private Integer id;
+
+    /**
+    * 收款商户号
+    */
+    private String merNo;
+
+    /**
+    * 最大收款金额
+    */
+    private BigDecimal maxReceipt;
+
+    /**
+    * 已收金额
+    */
+    private BigDecimal hasReceipt;
+
+    /**
+    * 支付渠道
+    */
+    private String channel;
+
+    /**
+    * 支付渠道类型(PER-个人 COM-公户)
+    */
+    private String channelType;
+
+    /**
+    * 版本号
+    */
+    private Integer version;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getMerNo() {
+        return merNo;
+    }
+
+    public void setMerNo(String merNo) {
+        this.merNo = merNo;
+    }
+
+    public BigDecimal getMaxReceipt() {
+        return maxReceipt;
+    }
+
+    public void setMaxReceipt(BigDecimal maxReceipt) {
+        this.maxReceipt = maxReceipt;
+    }
+
+    public BigDecimal getHasReceipt() {
+        return hasReceipt;
+    }
+
+    public void setHasReceipt(BigDecimal hasReceipt) {
+        this.hasReceipt = hasReceipt;
+    }
+
+    public String getChannel() {
+        return channel;
+    }
+
+    public void setChannel(String channel) {
+        this.channel = channel;
+    }
+
+    public String getChannelType() {
+        return channelType;
+    }
+
+    public void setChannelType(String channelType) {
+        this.channelType = channelType;
+    }
+
+    public Integer getVersion() {
+        return version;
+    }
+
+    public void setVersion(Integer version) {
+        this.version = version;
+    }
+}

+ 6 - 21
mec-biz/src/main/java/com/ym/mec/biz/service/PayService.java

@@ -1,24 +1,17 @@
 package com.ym.mec.biz.service;
 
 
-import com.ym.mec.thirdparty.union.H5;
-import com.ym.mec.thirdparty.union.UnionPay;
-import com.ym.mec.thirdparty.yqpay.YqPayUtil;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.stereotype.Service;
+import com.ym.mec.thirdparty.yqpay.Msg;
 
-import java.io.InputStream;
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
 import java.util.Map;
 
 /**
  * 支付服务类
  */
-@Service
-public class PayService {
+
+public interface PayService {
+
 
     /**
      * 返回订单提交数据
@@ -32,16 +25,8 @@ public class PayService {
      * @return
      * @throws Exception
      */
-    public Map getPayMap(BigDecimal amount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody) throws Exception {
-        String routingMerNo = "006718";
-
-        //支付通道决策
-
-        //易乾支付
-        YqPayUtil.getPayMap(amount, orderNo, notifyUrl, returnUrl, orderSubject, orderBody, routingMerNo);
-
-        return UnionPay.getPayMap(amount, orderNo, notifyUrl, returnUrl, orderSubject);
+    public Map getPayMap(BigDecimal amount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody) throws Exception;
 
-    }
+    public Map query(String orderNo) throws Exception;
 
 }

+ 62 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PayServiceImpl.java

@@ -0,0 +1,62 @@
+package com.ym.mec.biz.service.impl;
+
+
+import com.ym.mec.biz.service.PayService;
+import com.ym.mec.thirdparty.union.UnionPay;
+import com.ym.mec.thirdparty.union.UnionPayFeignService;
+import com.ym.mec.thirdparty.yqpay.YqPayUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.Map;
+
+/**
+ * 支付服务类
+ */
+@Service
+public class PayServiceImpl implements PayService {
+
+    @Autowired
+    private UnionPayFeignService unionPayFeignService;
+
+
+    /**
+     * 返回订单提交数据
+     *
+     * @param amount       金额
+     * @param orderNo      订单编号
+     * @param notifyUrl    异步通知地址
+     * @param returnUrl    支付返回地址
+     * @param orderSubject 订单标题
+     * @param orderBody    订单内容
+     * @return
+     * @throws Exception
+     */
+    public Map getPayMap(BigDecimal amount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody) throws Exception {
+        String routingMerNo = "006718";
+
+        //支付通道决策()
+
+        //易乾支付
+        return YqPayUtil.getPayMap(amount, orderNo, notifyUrl, returnUrl, orderSubject, orderBody, routingMerNo);
+
+       // return UnionPay.getPayMap(amount, orderNo, notifyUrl, returnUrl, orderSubject);
+
+    }
+
+    public Map<String, Object> query(String orderNo) throws Exception {
+        return new UnionPay(unionPayFeignService).query(orderNo);
+    }
+
+//    public Account getRoutingAccount(int branchId, BigDecimal money) {
+//        int payOrderNums = orderService.getPayOrderNums(); //获取支付中和成功的订单数
+//        //分佣账户(1、每10笔,前四笔收入私户 2、私户每个商户最多收款400万),进武汉商户
+//        int rem = (payOrderNums + 1) % 10;
+//        if (rem > 0 && rem <= 5) { //私人账户
+//            branchId = 0;
+//        }
+//        return this.getAccountByBranchId(branchId, money);
+//    }
+
+}

+ 110 - 0
mec-biz/src/main/resources/config/mybatis/SysAccountMapper.xml

@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ym.mec.biz.dal.dao.SysAccountDao">
+  <resultMap id="SysAccount" type="com.ym.mec.biz.dal.entity.SysAccount">
+    <!--@Table sys_account-->
+    <id column="id_" jdbcType="INTEGER" property="id" />
+    <result column="mer_no_" jdbcType="VARCHAR" property="merNo" />
+    <result column="max_receipt_" jdbcType="DECIMAL" property="maxReceipt" />
+    <result column="has_receipt_" jdbcType="DECIMAL" property="hasReceipt" />
+    <result column="channel_" jdbcType="VARCHAR" property="channel" />
+    <result column="channel_type_" jdbcType="CHAR" property="channelType" />
+    <result column="version" jdbcType="INTEGER" property="version" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    id_, mer_no_, max_receipt_, has_receipt_, channel_, channel_type_, version
+  </sql>
+  <select id="get" parameterType="java.lang.Integer" resultMap="SysAccount">
+    <!--@mbg.generated-->
+    select 
+    <include refid="Base_Column_List" />
+    from sys_account
+    where id_ = #{id,jdbcType=INTEGER}
+  </select>
+  <delete id="delete" parameterType="java.lang.Integer">
+    <!--@mbg.generated-->
+    delete from sys_account
+    where id_ = #{id,jdbcType=INTEGER}
+  </delete>
+  <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.SysAccount" useGeneratedKeys="true">
+    <!--@mbg.generated-->
+    insert into sys_account
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="merNo != null">
+        mer_no_,
+      </if>
+      <if test="maxReceipt != null">
+        max_receipt_,
+      </if>
+      <if test="hasReceipt != null">
+        has_receipt_,
+      </if>
+      <if test="channel != null">
+        channel_,
+      </if>
+      <if test="channelType != null">
+        channel_type_,
+      </if>
+      <if test="version != null">
+        version,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="merNo != null">
+        #{merNo,jdbcType=VARCHAR},
+      </if>
+      <if test="maxReceipt != null">
+        #{maxReceipt,jdbcType=DECIMAL},
+      </if>
+      <if test="hasReceipt != null">
+        #{hasReceipt,jdbcType=DECIMAL},
+      </if>
+      <if test="channel != null">
+        #{channel,jdbcType=VARCHAR},
+      </if>
+      <if test="channelType != null">
+        #{channelType,jdbcType=CHAR},
+      </if>
+      <if test="version != null">
+        #{version,jdbcType=INTEGER},
+      </if>
+    </trim>
+  </insert>
+  <update id="update" parameterType="com.ym.mec.biz.dal.entity.SysAccount">
+    <!--@mbg.generated-->
+    update sys_account
+    <set>
+      <if test="merNo != null">
+        mer_no_ = #{merNo,jdbcType=VARCHAR},
+      </if>
+      <if test="maxReceipt != null">
+        max_receipt_ = #{maxReceipt,jdbcType=DECIMAL},
+      </if>
+      <if test="hasReceipt != null">
+        has_receipt_ = #{hasReceipt,jdbcType=DECIMAL},
+      </if>
+      <if test="channel != null">
+        channel_ = #{channel,jdbcType=VARCHAR},
+      </if>
+      <if test="channelType != null">
+        channel_type_ = #{channelType,jdbcType=CHAR},
+      </if>
+      <if test="version != null">
+        version = #{version,jdbcType=INTEGER},
+      </if>
+    </set>
+    where id_ = #{id,jdbcType=INTEGER}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.ym.mec.biz.dal.entity.SysAccount">
+    <!--@mbg.generated-->
+    update sys_account
+    set mer_no_ = #{merNo,jdbcType=VARCHAR},
+      max_receipt_ = #{maxReceipt,jdbcType=DECIMAL},
+      has_receipt_ = #{hasReceipt,jdbcType=DECIMAL},
+      channel_ = #{channel,jdbcType=VARCHAR},
+      channel_type_ = #{channelType,jdbcType=CHAR},
+      version = #{version,jdbcType=INTEGER}
+    where id_ = #{id,jdbcType=INTEGER}
+  </update>
+  <select id="find"></select>
+</mapper>

+ 0 - 24
mec-client-api/src/main/java/com/ym/mec/im/YqPayService.java

@@ -1,24 +0,0 @@
-package com.ym.mec.im;
-
-import com.ym.mec.thirdparty.yqpay.Msg;
-import org.springframework.cloud.openfeign.FeignClient;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-
-import java.util.Map;
-
-@FeignClient(value = "yqPay", url = "${yq-pay.pay-host}")
-public interface YqPayService {
-    @RequestMapping(name = "统一下单",value = "/api/api/pay/toPay", method= RequestMethod.POST)
-    Msg toPay(@RequestParam Map<String, Object> map);
-
-    @RequestMapping(name = "平台转账",value = "/api/api/platformTransfer/toAcc", method= RequestMethod.POST)
-    String platformTransferAcc(@RequestParam Map<String, Object> map);
-
-    @RequestMapping(name = "提现",value = "/api/api/withdraw/intfc", method= RequestMethod.POST)
-    Msg intfc(@RequestParam Map<String, Object> map);
-
-    @RequestMapping(name = "发送验证码",value = "/api/api/withdraw/sendSms", method= RequestMethod.POST)
-    Msg sendSms(@RequestParam Map<String, Object> map);
-}

+ 30 - 10
mec-student/src/main/java/com/ym/mec/student/controller/MusicGroupController.java

@@ -1,5 +1,7 @@
 package com.ym.mec.student.controller;
 
+import com.ym.mec.biz.dal.entity.*;
+import com.ym.mec.biz.dal.enums.*;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -23,14 +25,6 @@ import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dto.MusicGroupSubjectGoodsAndInfoDto;
 import com.ym.mec.biz.dal.dto.RegisterPayDto;
-import com.ym.mec.biz.dal.entity.Goods;
-import com.ym.mec.biz.dal.entity.MusicGroupSubjectGoodsGroup;
-import com.ym.mec.biz.dal.entity.MusicGroupSubjectPlan;
-import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
-import com.ym.mec.biz.dal.entity.StudentRegistration;
-import com.ym.mec.biz.dal.enums.DealStatusEnum;
-import com.ym.mec.biz.dal.enums.GoodsType;
-import com.ym.mec.biz.dal.enums.KitGroupPurchaseTypeEnum;
 import com.ym.mec.biz.service.GoodsService;
 import com.ym.mec.biz.service.MusicGroupService;
 import com.ym.mec.biz.service.MusicGroupSubjectGoodsGroupService;
@@ -62,7 +56,7 @@ public class MusicGroupController extends BaseController {
     @Autowired
     private StudentPaymentOrderService studentPaymentOrderService;
     @Autowired
-    PayService payService;
+    private PayService payService;
 
     @ApiOperation("获取学生所在乐团列表")
     @GetMapping(value = "/queryUserMusicGroups")
@@ -105,6 +99,27 @@ public class MusicGroupController extends BaseController {
         return succeed(subjectGoodsAndInfo);
     }
 
+    @ApiOperation(value = "乐团报名缴费状态查询")
+    @GetMapping("/getMusicGroupStatus")
+    @ApiImplicitParams({@ApiImplicitParam(name = "musicGroupId", value = "乐团id", required = true, dataType = "String")})
+    public HttpResponseResult getMusicGroupStatus(String musicGroupId) throws Exception {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        Integer userId = sysUser.getId();
+        MusicGroup musicGroup = musicGroupService.get(musicGroupId);
+        if (musicGroup == null) {
+            return failed("乐团不存在");
+        }
+        StudentRegistration studentRegistration = studentRegistrationService.queryByUserIdAndMusicGroupId(userId, musicGroupId);
+        if (studentRegistration == null) {
+            return failed("乐团报名信息不存在");
+        }
+        if (!musicGroup.getStatus().equals(MusicGroupStatusEnum.PAY) && !studentRegistration.getPaymentStatus().equals(YesOrNoEnum.YES)) {
+            return failed("乐团还未开启缴费,请等待通知");
+        }
+        return succeed(studentRegistration);
+    }
+
+
     @ApiOperation(value = "乐团报名支付")
     @PostMapping("/pay")
     @ApiImplicitParams({@ApiImplicitParam(name = "registerPayDto", value = "支付信息", required = true, dataType = "Integer")})
@@ -261,8 +276,13 @@ public class MusicGroupController extends BaseController {
     @GetMapping("/test")
     public Object test() throws Exception {
 
+        Map query = payService.query("1017201910111756231647562047");
+
+
+        System.out.println(query);
+
         IdWorker idWorker = new IdWorker(0, 0);
-        String orderNo = idWorker.nextId();
+        String orderNo = "1017" + idWorker.nextId();
         BigDecimal amount = new BigDecimal("200");
         Map map = payService.getPayMap(amount, orderNo, "https://pay.dayaedu.com/notify", "https://baodiu.com", "测试订单", "测试订单");
         return succeed(map);

+ 5 - 2
mec-thirdparty/pom.xml

@@ -66,7 +66,10 @@
 			<scope>system</scope>
 			<systemPath>${project.basedir}/libs/SADK-3.2.5.2.jar</systemPath>
 		</dependency>
-
-	</dependencies>
+		<dependency>
+			<groupId>org.springframework.cloud</groupId>
+			<artifactId>spring-cloud-starter-openfeign</artifactId>
+		</dependency>
+    </dependencies>
 
 </project>

+ 24 - 5
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/union/UnionPay.java

@@ -5,10 +5,12 @@ import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.lang.RandomStringUtils;
 import org.apache.commons.lang.time.DateFormatUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 
 import javax.crypto.Mac;
 import javax.crypto.spec.SecretKeySpec;
 import java.math.BigDecimal;
+import java.net.URI;
 import java.net.URLEncoder;
 import java.security.InvalidKeyException;
 import java.security.NoSuchAlgorithmException;
@@ -18,10 +20,14 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 
+
 /**
  * 银联商务主扫
  */
 public class UnionPay {
+
+    private UnionPayFeignService unionPayFeignService;
+
     static String aliPayUrl = "http://58.247.0.18:29015/v1/netpay/trade/h5-pay";//支付宝
     static String qmfPayUrl = "http://58.247.0.18:29015/v1/netpay/qmf/h5-pay";//银联无卡
     static String H5AppId = "10037e6f6a4e6da4016a670fd4530012";
@@ -40,6 +46,10 @@ public class UnionPay {
     static String timestamp = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
     static String nonce = UUID.randomUUID().toString().replace("-", "");
 
+    public UnionPay(UnionPayFeignService unionPayFeignService) {
+        this.unionPayFeignService = unionPayFeignService;
+    }
+
     private static byte[] hmacSHA256(byte[] data, byte[] key) throws InvalidKeyException, NoSuchAlgorithmException {
         String algorithm = "HmacSHA256";
         Mac mac = Mac.getInstance(algorithm);
@@ -51,7 +61,7 @@ public class UnionPay {
         String signatureStr = appId + timestamp + nonce + DigestUtils.sha256Hex(content);
         byte[] localSignature = hmacSHA256(signatureStr.getBytes(), appKey.getBytes());
         if (method.toUpperCase().equals("POST")) {
-            return ("OPEN-BODY-SIG AppId=" + "\"" + appId + "\"" + ", Timestamp=" + "\"" + timestamp + "\"" + ", Nonce=" + "\"" + nonce + "\"" + ", Signature=" + "\"" + signatureStr + "\"");
+            return ("OPEN-BODY-SIG AppId=" + "\"" + appId + "\"" + ", Timestamp=" + "\"" + timestamp + "\"" + ", Nonce=" + "\"" + nonce + "\"" + ", Signature=" + "\"" + Base64.encodeBase64String(localSignature) + "\"");
         } else {
             return ("authorization=OPEN-FORM-PARAM" + "&appId=" + appId + "&timestamp=" + timestamp + "&nonce=" + nonce + "&content=" + URLEncoder.encode(content, "UTF-8") + "&signature=" + URLEncoder.encode(Base64.encodeBase64String(localSignature), "UTF-8"));
         }
@@ -102,25 +112,34 @@ public class UnionPay {
      * 订单查询
      *
      * @param orderNo 自己系统订单号
-     * @return
+     * @return 1017201910111756231647562047 测试订单号
      */
-    public static Map query(String orderNo) {
+    public Map<String, Object> query(String orderNo) throws Exception {
         JSONObject json = new JSONObject();
         json.put("instMid", "H5DEFAULT");
         json.put("mid", h5Mid);
         json.put("tid", h5Tid);
         json.put("merOrderId", orderNo);
         json.put("requestTimestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
-        return new HashMap();
+
+        String authorization = getOpenBodySig(wpAppId, wpAppKey, timestamp, nonce, json.toString(), "POST");
+        HashMap<String, String> header = new HashMap<>();
+        header.put("Authorization", authorization);
+        header.put("Content-Type", "application/json; charset=utf-8");
+        Map query = unionPayFeignService.query(json.getInnerMap(), header);
+        return query;
     }
 
 
     public static void main(String[] args) throws Exception {
         String orderNo = "1017" + new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date()) + RandomStringUtils.randomNumeric(7);
 
-        Map<String, String> payMap = getPayMap(new BigDecimal("20.33"), orderNo, "http://pay.dayaedu.com/pay/notify", "http://dev.daya.com", "大雅测试订单");
+        System.out.println(orderNo);
+
+        Map<String, String> payMap = getPayMap(new BigDecimal("0.01"), orderNo, "http://pay.dayaedu.com/pay/notify", "http://dev.daya.com", "大雅测试订单");
         System.out.println("weChat= " + payMap.get("weChatPay"));
         System.out.println("H5= " + payMap.get("aliPay"));
+        System.out.println("qmfPay= " + payMap.get("qmfPay"));
     }
 }
 

+ 15 - 0
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/union/UnionPayFeignService.java

@@ -0,0 +1,15 @@
+package com.ym.mec.thirdparty.union;
+
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Map;
+
+
+@FeignClient(value = "UnionPayFeignService", url = "http://58.247.0.18:29015")
+public interface UnionPayFeignService {
+
+    @RequestMapping(name = "查询订单", value = "/v1/netpay/query", method = RequestMethod.POST)
+    Map query(@RequestBody Map body, @RequestHeader Map Header);
+
+}