cy 3 роки тому
батько
коміт
1057f16e98

+ 12 - 0
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/CourseGroupController.java

@@ -1,10 +1,12 @@
 package com.yonge.cooleshow.admin.controller;
 
+import com.alibaba.fastjson.JSON;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.dto.search.CourseGroupDetailSearch;
 import com.yonge.cooleshow.biz.dal.dto.search.CourseGroupSearch;
 import com.yonge.cooleshow.biz.dal.entity.VideoLessonGroupDetail;
+import com.yonge.cooleshow.biz.dal.sdk.WithdrawSdk;
 import com.yonge.cooleshow.biz.dal.service.CourseGroupService;
 import com.yonge.cooleshow.biz.dal.service.CourseScheduleService;
 import com.yonge.toolset.mybatis.support.PageUtil;
@@ -21,6 +23,8 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.validation.constraints.NotNull;
 import java.util.List;
+import java.util.Map;
+import java.util.UUID;
 
 /**
  * @Author: cy
@@ -37,6 +41,8 @@ public class CourseGroupController extends BaseController {
     private SysUserFeignService sysUserFeignService;
     @Autowired
     private CourseScheduleService courseScheduleService;
+    @Autowired
+    private WithdrawSdk sdk;
 
     @ApiOperation(value = "课程组管理-陪练课",notes = "{\n" +
             "    \"subjectId\":20,\n" +
@@ -215,4 +221,10 @@ public class CourseGroupController extends BaseController {
     public HttpResponseResult<PageInfo<CourseGroupPianoDetailVo>> selectPianoGroupTeacherDetail(@Validated @RequestBody CourseGroupDetailSearch search) {
         return succeed(PageUtil.pageInfo(courseGroupService.selectPianoGroupTeacherDetail(PageUtil.getPage(search), search)));
     }
+
+
+    @GetMapping("/test")
+    public void aaa(){
+        sdk.test();
+    }
 }

+ 112 - 4
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/sdk/WithdrawSdk.java

@@ -1,13 +1,23 @@
 package com.yonge.cooleshow.biz.dal.sdk;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONPath;
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import com.yonge.toolset.base.exception.ThirdpartyException;
 import com.yonge.toolset.thirdparty.lingxinpay.Md5EncryptUtils;
 import com.yonge.toolset.thirdparty.lingxinpay.RSA;
 import com.yonge.toolset.utils.date.DateUtil;
 import com.yonge.toolset.utils.http.HttpUtil;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.util.EntityUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Value;
@@ -17,6 +27,7 @@ import java.io.IOException;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.UUID;
 
 /**
  * @author: cy
@@ -152,8 +163,8 @@ public class WithdrawSdk {
      * @param remark        备注(扩展字段) 只针对测试环境:只要参数合规都会返回交易成功,如果想要模拟交易失败,该字段值中含有“失败”二字即会失败。
      * @return
      */
-    public String withdraw(String outerOrderNo, String name, String mobile, String certificateNo, Integer predictAmount,
-                           String payAccount, String remark) {
+    public HttpResponseResult<Boolean> withdraw(String outerOrderNo, String name, String mobile, String certificateNo, Integer predictAmount,
+                                                String payAccount, String remark) {
         Map<String, Object> map = new HashMap<>();
         map.put("outMemberNo", memberNo);
         map.put("outerOrderNo", outerOrderNo);
@@ -193,11 +204,12 @@ public class WithdrawSdk {
         try {
             String resultJsonStr = HttpUtil.postForHttp(apiUrl + "/bpotop_trade/single", JSONObject.toJSONString(mapParam), null);
             logger.info("单笔请求返回参数:{}", resultJsonStr);
-            return resultJsonStr;
+            Map<String,Object> mapTypes = JSON.parseObject(resultJsonStr);
+            return HttpResponseResult.succeed(true);
         } catch (IOException e) {
             logger.info("发送失败:{}", e);
         }
-        return null;
+        return HttpResponseResult.failed("提现失败");
     }
 
     /**
@@ -237,4 +249,100 @@ public class WithdrawSdk {
         return null;
     }
 
+
+    public void test(){
+        //输入商户订单号
+        String outerOrderNo = UUID.randomUUID().toString().substring(0,12);
+        System.out.println(outerOrderNo);
+        //输入收款人手机号
+        String name = "何亮";
+        //输入收款人姓名
+        String mobile = "17600220933";
+        //输入收款人身份证号
+        String certificateNo = "130423199206192818";
+        //输入转账金额(单位分)
+        String predictAmount = "1";
+        //输入收款人账号
+        String payAccount = "6228480018864836772";
+        //输入卡类型:DC借记卡,CC信用卡(暂不支持)
+        String cardType = "DC";
+        //输入发放类型(0:工资,1:奖金,2:绩效,3:劳务,4:个人经营所得,5:其他)
+        String salaryType = "4";
+        //输入项目名称
+        String projectName = "测试";
+        //输入支付类型(1:银行卡)
+        String payType = "1";
+        //输入卡属性:(C:对私 ,B:对公)暂时不支持对公
+        String cardAttribute = "C";
+        String requestParam = doSign(outerOrderNo, name, mobile, certificateNo, predictAmount, payAccount, cardType,
+                salaryType, projectName, payType, cardAttribute);
+        String resultJsonStr = doPost("http://39.107.15.64:8090/bpotop_trade/single", requestParam);
+        System.out.println("单笔请求返回参数:{}"+resultJsonStr);
+        Map<String,Object> mapTypes = JSON.parseObject(resultJsonStr);
+        System.out.println(mapTypes);
+    }
+    private static String pk="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCYT5eCY6r8sGWgbiId/VqSZmS6XkBNGMkzUqTIkpkecOzsFBxFXTQmgDeR991YfgqmyOaHsJ/ons/H+e8l+RmHsOm4eErFU+9qXFq+k195YFV1vAR9O7MIG+FR5vmLDuhgimPsgqscWhUrGinc8RUpi5KwClgx7d+d8ZJ4GmkR0QIDAQAB";
+    private static String md5="0fd42370bad6485e46718b97f3dd1536";
+
+    public static String doSign(String outerOrderNo, String name, String mobile, String certificateNo, String predictAmount,
+                                String payAccount, String cardType, String salaryType, String projectName, String payType, String cardAttribute){
+        Map<String, Object> map = new HashMap<>();
+        //输入商户号
+        String memberNo = "1491663782974988288";
+
+        map.put("outMemberNo", memberNo);
+        map.put("outerOrderNo", outerOrderNo);
+        map.put("name", name);
+        map.put("certificateNo", certificateNo);
+        map.put("predictAmount", predictAmount);
+        String signs = Md5EncryptUtils.sign(map, md5);
+        map.put("charset", "UTF-8");
+        map.put("mobile", mobile);
+        map.put("version", "1.1");
+        map.put("service", "bpotop.zx.pay.order");
+        map.put("Md5Key", signs);
+        map.put("notifyUrl", "http://apis.bpotop.com/bpotop_trade/test");
+        map.put("cardType", cardType);
+        map.put("salaryType", salaryType);
+        map.put("projectName", projectName);
+        map.put("payType", payType);
+        map.put("cardAttribute", cardAttribute);
+        map.put("payAccount", payAccount);
+        String jsonStr = JSONObject.toJSONString(map);
+        try {
+            //使用公钥加密
+            String encryptStr = RSA.encryptPub(jsonStr,pk);
+            JSONObject mapParam = new JSONObject();
+            mapParam.put("outMemberNo",memberNo);
+            mapParam.put("signType","RSA");
+            mapParam.put("sign",encryptStr);
+            logger.info("单笔请求请求参数:{}",JSONObject.toJSONString(mapParam));
+            return JSONObject.toJSONString(mapParam);
+        } catch (Exception e) {
+            logger.info("加密/发送失败:{}",e);
+        }
+        return null;
+    }
+
+    public static String doPost(String url, String json) {
+        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
+        HttpPost post = new HttpPost(url);
+        HttpGet get = new HttpGet(url);
+
+        String response = null;
+        try {
+            StringEntity s = new StringEntity(json,"UTF-8");
+//			s.setContentEncoding("UTF-8");
+            // 发送json数据需要设置contentType
+            s.setContentType("application/json");
+            post.setEntity(s);
+            HttpResponse res = httpclient.execute(post);
+            if (res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+                response = EntityUtils.toString(res.getEntity());// 返回json格式:
+            }
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        return response;
+    }
 }

+ 3 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseGroupMapper.xml

@@ -818,6 +818,8 @@
         cs.start_time_ AS startTime,
         cs.end_time_ AS endTime,
         p.user_id_ AS studentId,
+        su.username_ AS studentName,
+        su.real_name_ AS studentRealName,
         (CASE WHEN cs.start_time_ &gt;= ta.sign_in_time_ THEN 1 ELSE 0 END) AS teacherInSign,
         (CASE WHEN cs.end_time_ &lt;= ta.sign_out_time_ THEN 1 ELSE 0 END) AS teacherOutSign,
         (CASE WHEN cs.start_time_ &gt;= sa.sign_in_time_ THEN 1 ELSE 0 END) AS studentInSign,
@@ -832,6 +834,7 @@
         LEFT JOIN teacher_attendance ta ON cs.id_=ta.course_schedule_id_
         LEFT JOIN student_attendance sa ON cs.id_=sa.course_schedule_id_
         LEFT JOIN course_schedule_student_payment p ON cs.id_=p.course_id_
+        LEFT JOIN sys_user su ON p.user_id_ = su.id_
         WHERE cs.type_='PIANO_ROOM_CLASS'
         AND p.user_id_=#{param.studentId}
         AND p.course_group_id_=#{param.courseGroupId}) m