|
@@ -8,6 +8,7 @@ import common.annotation.API;
|
|
|
import common.data.Row;
|
|
|
import common.data.Rows;
|
|
|
import common.data.SQLFactory;
|
|
|
+import restcontroller.R;
|
|
|
import utility.wechat.WeChatHelper;
|
|
|
import utility.tools.Encryption;
|
|
|
import utility.wechat.miniprogram.WechatMiniProgram;
|
|
@@ -164,7 +165,14 @@ public class wechatpay extends Controller {
|
|
|
String trade_type = content.getString("trade_type");
|
|
|
|
|
|
WechatMiniProgram wechatMiniProgram = new WechatMiniProgram("wechatsaletool");
|
|
|
- String response = wechatMiniProgram.createPayOrder(orderno, trade_type, wechat_code, "", "使用年费");
|
|
|
+
|
|
|
+ int order_amount = 0;
|
|
|
+ Rows sys_payorderRows = dbConnect.runSqlQuery("select amount from sys_payorder where orderno='" + orderno + "'");
|
|
|
+ if (sys_payorderRows.isNotEmpty()) {
|
|
|
+ order_amount = new Double(sys_payorderRows.get(0).getDouble("amount") * 100).intValue();
|
|
|
+ }
|
|
|
+
|
|
|
+ String response = wechatMiniProgram.createPayOrder(orderno, trade_type, wechat_code, "", "使用年费",order_amount);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(response);
|
|
|
if (jsonObject.containsKey("prepay_id")) {
|
|
|
String package_str = "prepay_id=" + jsonObject.getStringValue("prepay_id");
|
|
@@ -197,6 +205,55 @@ public class wechatpay extends Controller {
|
|
|
return getSucReturnObject().setData(object).toString();
|
|
|
|
|
|
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "小程序门店支付", apiversion = R.ID20240507102402.v1.class)
|
|
|
+ public String createStoreWechatOrder() throws Exception {
|
|
|
+ String sonum = content.getString("sonum");
|
|
|
+ String wechat_code = content.getString("wechat_code");
|
|
|
+ //APP、JSAPI
|
|
|
+ String trade_type = content.getString("trade_type");
|
|
|
+
|
|
|
+ int order_amount = 0;
|
|
|
+ Rows custorderRows = dbConnect.runSqlQuery("select amount from sa_custorder where sonum='" + sonum + "'");
|
|
|
+ if (custorderRows.isNotEmpty()) {
|
|
|
+ order_amount = new Double(custorderRows.get(0).getDouble("amount") * 100).intValue();
|
|
|
+ }
|
|
|
+
|
|
|
+ WechatMiniProgram wechatMiniProgram = new WechatMiniProgram("wechatsaletool");
|
|
|
+ String response = wechatMiniProgram.createPayOrder(sonum, trade_type, wechat_code, "", "购买商品",order_amount);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(response);
|
|
|
+ if (jsonObject.containsKey("prepay_id")) {
|
|
|
+ String package_str = "prepay_id=" + jsonObject.getStringValue("prepay_id");
|
|
|
+ } else {
|
|
|
+ return getErrReturnObject().setErrMsg(jsonObject.getStringValue("message")).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ dbConnect.runSqlUpdate("UPDATE sa_custorder SET ispaid=1 WHERE sonum='" + sonum + "' and siteid='" + siteid + "'");
|
|
|
+
|
|
|
+ //应用ID
|
|
|
+ String appid = wechatMiniProgram.getAppId();
|
|
|
+ //随机码
|
|
|
+ String nonceStr = createNonce_str(appid);
|
|
|
+ String package_str = "prepay_id=" + jsonObject.getStringValue("prepay_id");
|
|
|
+ String timeStamp = String.valueOf(Calendar.getInstance().getTime().getTime() / 1000);
|
|
|
+
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
+ object.put("appId", appid);
|
|
|
+ object.put("timeStamp", timeStamp);
|
|
|
+ object.put("nonceStr", nonceStr);
|
|
|
+ object.put("package", package_str);
|
|
|
+
|
|
|
+ object.put("signType", "RSA");
|
|
|
+ String B = appid + "\n"
|
|
|
+ + timeStamp + "\n"
|
|
|
+ + nonceStr + "\n"
|
|
|
+ + package_str + "\n";
|
|
|
+
|
|
|
+ object.put("paySign", sign(B.getBytes(StandardCharsets.UTF_8)));
|
|
|
+ return getSucReturnObject().setData(object).toString();
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|