Преглед на файлове

Merge branch 'dev' of http://47.101.143.145:8090/77975466/pco into dev

# Conflicts:
#	sp-server/app.pid
#	sp-server/src/main/resources/application-dev.yml
qzyReal преди 3 години
родител
ревизия
3c5d7c3234

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

@@ -48,13 +48,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&&sa.isAuth('tb-business-item-confirm')" 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()">
@@ -67,7 +67,7 @@
 					<el-button type="primary" @click="sureConfirm">确 定</el-button>
 				</span>
 		</el-dialog>
-		<el-dialog title="提示" :visible.sync="emodel.visible" width="30%">
+		<el-dialog title="提示" :visible.sync="emodel.visible" width="36%">
 			<span>日期范围:</span>
 			<el-form size="mini">
 				<div class="c-item">
@@ -92,6 +92,7 @@
 			el: '.vue-box',
 			data: {
 				p: { // 查询参数
+					businessId: sa.p('businessId', 0),
 					id: '', // 主键
 					itemName: '', // 项目名称
 					pageNo: 1, // 当前页
@@ -110,6 +111,7 @@
 				emodel: {
 					visible: false,
 					form: {
+						businessId: sa.p('businessId', 0),
 						beginTime: '',
 						endTime: ''
 					}

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

@@ -77,7 +77,7 @@
 								&&s.row.adminConfirmInput==1
 								&&currentCustomerId!='1'" @click="payFn(s.row)">
 								马上支付</el-button>
-							<el-button class="c-btn" type="primary" @click="itemFn(s.row)">业务项</el-button>
+							<el-button class="c-btn" type="primary" @click="itemFn(s.row)" v-if="currentCustomerId=='1'">业务项</el-button>
 							<el-button v-if="sa.isAuth('tb-business-add')" class="c-btn" type="primary" @click="carFn(s.row)">车辆管理
 							</el-button>
 							<el-button class="c-btn" type="success" @click="get(s.row)">查看</el-button>

+ 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;
+        }
+    }
+
+}

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

@@ -0,0 +1,45 @@
+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 {
+        return AjaxJson.getSuccessData(jhService.initPay(request));
+    }
+
+}

+ 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;
+
+}

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

@@ -75,4 +75,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