lzm 3 роки тому
батько
коміт
a76fcfa9a8

+ 2 - 2
sp-admin/sa-view/tb-business/tb-business-item-list.html

@@ -50,13 +50,13 @@
 				<sa-td name="创建时间" prop="createTime" width="160"></sa-td>
 				<sa-td name="接单时间" prop="pickTime" width="160"></sa-td>
 				<sa-td name="确认时间" prop="confirmTime" width="160"></sa-td>
-				<el-table-column label="操作" fixed="right" width="200px" v-if="currentCustomerId=='1'">
+				<!--<el-table-column label="操作" fixed="right" width="200px" v-if="currentCustomerId=='1'">
 					<template slot-scope="s">
 						<el-button v-if="s.row.pickTime&&!s.row.confirmTime" class="c-btn" type="success"
 								   icon="el-icon-edit" @click="confirmFn(s.row)">确认
 						</el-button>
 					</template>
-				</el-table-column>
+				</el-table-column>-->
 			</el-table>
 			<!-- ------------- 分页 ------------- -->
 			<sa-item type="page" :curr.sync="p.pageNo" :size.sync="p.pageSize" :total="dataCount" @change="f5()">

+ 0 - 1
sp-server/app.pid

@@ -1 +0,0 @@
-29408

+ 73 - 0
sp-server/src/main/java/com/pj/api/jh/MerchantApiUtil.java

@@ -0,0 +1,73 @@
+package com.pj.api.jh;
+
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.crypto.SecureUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+/**
+ * Created with IntelliJ IDEA.
+ *
+ * @Auther: lzm
+ */
+@Component
+@Slf4j
+public class MerchantApiUtil {
+
+    /**
+     * 获取参数签名
+     *
+     * @param paramMap
+     *            签名参数
+     * @param paySecret
+     *            签名密钥
+     * @return
+     */
+    public static String getSign(Map<String, String> paramMap, String paySecret) {
+        SortedMap<String, Object> smap = new TreeMap<String, Object>(paramMap);
+        if (smap.get("sign") != null) {
+            smap.remove("sign");
+        }
+        StringBuffer stringBuffer = new StringBuffer();
+        for (Map.Entry<String, Object> m : smap.entrySet()) {
+            Object value = m.getValue();
+            if (value != null && StrUtil.isNotBlank(String.valueOf(value))) {
+                stringBuffer.append(m.getKey()).append("=").append(value).append("&");
+            }
+        }
+        stringBuffer.delete(stringBuffer.length() - 1, stringBuffer.length());
+        String argPreSign = stringBuffer.append("&paySecret=").append(paySecret).toString();
+        log.info("待签名数据:"+argPreSign);
+        return SecureUtil.md5(argPreSign).toUpperCase();
+    }
+
+    /**
+     * 验证商户签名
+     *
+     * @param paramMap
+     *            签名参数
+     * @param paySecret
+     *            签名私钥
+     * @param signStr
+     *            原始签名密文
+     * @return
+     */
+    public static boolean isRightSign(Map<String, String> paramMap, String paySecret, String signStr) {
+
+        if (StrUtil.isBlank(signStr)) {
+            return false;
+        }
+
+        String sign = getSign(paramMap, paySecret);
+        if (signStr.equals(sign)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+}

+ 46 - 0
sp-server/src/main/java/com/pj/api/jh/api/JhController.java

@@ -0,0 +1,46 @@
+package com.pj.api.jh.api;
+
+import cn.hutool.core.util.XmlUtil;
+import com.pj.api.jh.service.JhService;
+import com.pj.utils.sg.AjaxJson;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Created with IntelliJ IDEA.
+ *
+ * @Auther: lzm
+ * @Date: 2022/04/19/19:21
+ * @Description:
+ */
+@RequestMapping("jh")
+@RestController
+@Slf4j
+public class JhController {
+
+    @Resource
+    JhService jhService;
+
+    @RequestMapping(value = "notify")
+    public void notify(HttpServletResponse response) throws Exception{
+        response.setContentType("application/json");
+        response.setCharacterEncoding("UTF-8");
+
+    }
+
+    @RequestMapping(value = "init-pay")
+    public AjaxJson prePay( HttpServletRequest request) throws Exception {
+        jhService.initPay(request);
+        return null;
+    }
+
+}

+ 112 - 0
sp-server/src/main/java/com/pj/api/jh/service/JhService.java

@@ -0,0 +1,112 @@
+package com.pj.api.jh.service;
+
+import cn.hutool.core.util.NumberUtil;
+import cn.hutool.core.util.RandomUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.crypto.SecureUtil;
+import cn.hutool.http.HttpUtil;
+import cn.hutool.json.JSONObject;
+import cn.hutool.json.JSONUtil;
+import com.pj.api.jh.MerchantApiUtil;
+import com.pj.api.wx.WxUtils;
+import com.pj.api.wx.bo.Attach;
+import com.pj.api.wx.service.WxService;
+import com.pj.current.config.JhConfig;
+import com.pj.current.config.MyConfig;
+import com.pj.current.config.WxConfig;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @Auther: lzm
+ * @Date: 2022/04/19/17:38
+ */
+
+@Service
+@Transactional
+@Slf4j
+public class JhService {
+
+    @Resource
+    WxConfig wxConfig;
+    @Resource
+    MyConfig myConfig;
+    @Resource
+    JhConfig jhConfig;
+    @Resource
+    WxUtils wxUtils;
+
+    public Map<String, String> initPay(HttpServletRequest request) throws Exception {
+        String money = request.getParameter("money");
+        String openid = request.getParameter("openid");
+        String businessId = request.getParameter("b");
+        String c = request.getParameter("c");
+        String a = request.getParameter("a");
+        Attach atchMap = new Attach();
+        atchMap.setC(c).setB(businessId).setA(a);
+        String out_trade_no = RandomUtil.randomString(32);
+        Map<String, String> params = new HashMap<>();
+        params.put("attach", JSONUtil.toJsonStr(atchMap));
+        params.put("productType", jhConfig.getProductType());
+        params.put("businessMerchantNo", jhConfig.getBusinessMerchantNo());
+        params.put("openId", openid);
+        params.put("merchantNo", jhConfig.getBusinessMerchantNo());
+        params.put("tradeType", jhConfig.getTradeType());
+        params.put("subTradeType", "");
+        String total_free = NumberUtil.mul(money, 100 + "").intValue() + "";
+        log.info("order price:{}", total_free);
+        params.put("orderPrice", total_free);
+        params.put("outTradeNo", out_trade_no);
+        params.put("productName", "业务订单支付");
+        params.put("orderIp", WxService.getIpAddress(request));
+        String now = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
+        params.put("orderTime", now);
+        params.put("returnUrl", "");
+        params.put("notifyUrl", myConfig.getDomain() + "/wx/notify");
+        params.put("remark", "业务订单支付");
+
+        String paySecrit = jhConfig.getPaySecret();
+        String sign = MerchantApiUtil.getSign(params, paySecrit);
+
+        params.put("sign", sign);
+        String jsonParam = JSONUtil.toJsonStr(params);
+        String initPayUrl = "http://116.252.74.15:8081/uaps-web-gateway/cnpPay/initPay";
+        String result = HttpUtil.createPost(initPayUrl).header("Content-Type", "application/json").body(jsonParam)
+                .execute().body();
+        JSONObject jsonResult = JSONUtil.parseObj(result);
+        if(StrUtil.equals("0000", jsonResult.get("resultCode").toString())){
+            JSONObject payMessage = JSONUtil.parseObj(jsonResult.get("payMessage"));
+            Object prePayId = payMessage.get("prepay_id");
+            String preId = prePayId == null ? "" : prePayId.toString();
+            return getPayParams(openid, preId);
+        }
+        throw new Exception("支付信息有误");
+    }
+
+    public Map<String, String> getPayParams(String openid, String prePayId) {
+        Map<String, String> signMap = new HashMap<>(10);
+        signMap.put("appId", wxConfig.getAppId());
+        signMap.put("timeStamp", System.currentTimeMillis() / 1000 + "");
+        signMap.put("nonceStr", RandomUtil.randomString(32));
+        signMap.put("signType", "MD5");
+        signMap.put("package", "prepay_id=" + prePayId);
+        String sign = wxUtils.sign(signMap, wxConfig.getKey());
+        signMap.put("paySign", sign);
+        signMap.put("openId", openid);
+        return signMap;
+    }
+
+
+
+
+}

+ 23 - 0
sp-server/src/main/java/com/pj/current/config/JhConfig.java

@@ -0,0 +1,23 @@
+package com.pj.current.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Auther: lzm
+ * @Date: 2022/04/21/9:37
+ */
+@ConfigurationProperties(prefix = "jh-config")
+@Component
+@Data
+public class JhConfig {
+
+
+    private String productType;
+    private String businessMerchantNo;
+    private String merchantNo;
+    private String tradeType;
+    private String paySecret;
+
+}

+ 15 - 7
sp-server/src/main/resources/application-dev.yml

@@ -6,9 +6,9 @@ spring:
     # 数据源配置
     datasource:
         type: com.alibaba.druid.pool.DruidDataSource
-        url: jdbc:mysql://127.0.0.1:3306/pco_system?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC
+        url: jdbc:mysql://127.0.0.1:3307/pco_system?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC
         username: root
-        password: 123456
+        password: 1234
         # 是否打开sql监控台  (生产环境请务必关闭此选项)
         druid:
             stat-view-servlet:
@@ -45,8 +45,8 @@ spring:
     # 项目自定义配置
     myconfig:
         # 本项目部署到的服务器域名(文件上传等等模块  要用到)
-        domain: http://192.168.3.77:8099/pro
-        web-domain: https://192.168.3.77:8080
+        domain: http://192.168.3.131:8099/pro
+        web-domain: https://192.168.3.131:8080/h5
 part-config:
     base-price: 0.01 #基础费用
     extra-price: 0.01 #过夜额外收费
@@ -60,8 +60,10 @@ car:
 wx-config:
     title: 场站管理系统
     flush-second: 12000 #token刷新时间 秒
-    app-id: wxd40a34141872bf0c
-    secret: 2e6a69fab1fbab60369ebd21b0882f3e
+#    app-id: wxd40a34141872bf0c
+#    secret: 2e6a69fab1fbab60369ebd21b0882f3e
+    app-id: wx4979e287cbed0d86
+    secret: 0f2c93b93615b768c6423651ab536ddb
     mach-id: 1615645036
     key: dongxingkouanerqiao8888888888888
     token: dx1123
@@ -75,4 +77,10 @@ wx-config:
     send-msg-url: https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=ACCESS_TOKEN
     business-notice-template: x-uh28Okx9_Wl1ZXsmx_r2vn3KIixZrZqUw-18R0cqY
     business-pick-template: M2f0xbVnQNujOCbtDZ6kBGnTK8Uc2Hm7dMguU-dPH9Q
-    business-confirm-template: aOOyH-wldRhNviL-AKGZUl2g5uj6NXUaW8otkJJio90
+    business-confirm-template: aOOyH-wldRhNviL-AKGZUl2g5uj6NXUaW8otkJJio90
+jh-config:
+    product-type: 10000301
+    business-merchant-no: PRO88882021122310003030
+    merchant-no: PRO88882021122310003030
+    trade-type: GAS_PAY
+    pay-secret: f0b9d6ea704d4c03a6b44be50d055025

+ 6 - 1
sp-server/src/main/resources/application-pro.yml

@@ -70,4 +70,9 @@ wx-config:
     auth-login-url: https://open.weixin.qq.com/connect/oauth2/authorize?appid=${wx-config.app-id}&redirect_uri=REDIRECT_URI&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect
     js-api-token-url: https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=ACCESS_TOKEN&type=jsapi
     openid-url: https://api.weixin.qq.com/sns/oauth2/access_token?appid=${wx-config.app-id}&secret=${wx-config.secret}&code=CODE&grant_type=authorization_code
-
+jh-config:
+  product-type: 10000301
+  business-merchant-no: PRO88882021122310003030
+  merchant-no: PRO88882021122310003030
+  trade-type: GAS_PAY
+  pay-secret: f0b9d6ea704d4c03a6b44be50d055025