支付订单逻辑整理完毕

cz_dev
格调main 2026-03-01 20:21:54 +08:00
parent e7755657fd
commit a8400f9d95
1 changed files with 59 additions and 21 deletions

View File

@ -116,7 +116,12 @@
</template> </template>
<script> <script>
import { getGuildStoreDetail, getGuildCoupon, getPaySign } from "@/api/service"; import {
getGuildStoreDetail,
getGuildCoupon,
getPaySign,
appBuy,
} from "@/api/service";
import NavHeader from "@/components/NavHeader/NavHeader.vue"; import NavHeader from "@/components/NavHeader/NavHeader.vue";
export default { export default {
@ -329,40 +334,77 @@ export default {
}); });
return; return;
} }
// //
// couponId:num;couponId:num 2324:1;2325:2 // couponId:num;couponId:num 2324:1;2325:2
const couponStr = selectedItems const couponStr = selectedItems
.map((item) => `${item.couponId}:${item.quantity}`) .map((item) => `${item.id}:${item.quantity}`)
.join(";"); .join(";");
// this.totalAmount , // this.totalAmount ,
const trxamt = (this.totalAmount * 100).toFixed(0); const trxamt = (this.totalAmount * 100).toFixed(0);
console.log("购买信息: " + couponStr);
console.log("金额:" + trxamt);
const res = await appBuy({
shopId: this.shopId,
couponData: couponStr,
payableAmount: trxamt,
});
console.log(res);
if (!res) {
uni.showToast({
title: "购买失败,请稍后重试",
icon: "none",
});
}
// res
this.handlePay(res);
}, },
// //
async handlePay(){ async handlePay(order) {
// //
const reqsn = // const reqsn =
"mini" + Date.now() + "" + Math.floor(Math.random() * 10000); // "mini" + Date.now() + "" + Math.floor(Math.random() * 10000);
const couponArray = order.couponPurchaseRespVOS || [];
const couponMap = new Map();
couponArray.forEach((item) => {
const key = item.couponId;
if (!key) return;
// Map
const currentList = couponMap.get(key) || [];
currentList.push(item);
// Map
couponMap.set(key, currentList);
});
let bodyStr = ''
couponMap.forEach((couponList, couponId) => {
console.log(`优惠券ID${couponId}`);
console.log(`优惠券列表:`, couponList);
bodyStr = bodyStr + couponList[0].couponName + 'x' + couponList.length + ';';
});
const randomstr = Math.floor(Math.random() * 10000000) + ""; const randomstr = Math.floor(Math.random() * 10000000) + "";
// //
// //
// STring , // STring ,
let params = { let params = {
appid: "00390105", // appid appid: "00390105", // appid
body: "body订单标题", // body: bodyStr, //
cusid: "56479107531MPMN", // cusid: "56479107531MPMN", //
notify_url: notify_url:
"http://e989c692.natappfree.cc/admin-api/member/labor-union-coupon-purchase/tlNotice", // "http://e989c692.natappfree.cc/admin-api/member/labor-union-coupon-purchase/tlNotice", //
orgid: "56479107392N35H", orgid: "56479107392N35H",
paytype: "W06", paytype: "W06",
randomstr: randomstr, randomstr: randomstr,
remark: "remark备注", remark: order.orderNumber+ ":" + bodyStr,
reqsn: reqsn, reqsn: order.orderNumber,
sign: "", sign: "",
signtype: "RSA", signtype: "RSA",
trxamt: "1", // trxamt: "" + order.payableAmount,
trxamt: "1",//
version: "12", version: "12",
//"asinfo":"56479107392MP4J:01:0.01" //(, ) , ,01 , ,0.01 //"asinfo":"56479107392MP4J:01:0.01" //(, ) , ,01 , ,0.01
}; };
@ -370,10 +412,6 @@ export default {
const sign = await getPaySign(params); const sign = await getPaySign(params);
console.log("测试返回的签名:" + sign); console.log("测试返回的签名:" + sign);
params["sign"] = sign; params["sign"] = sign;
console.log(params);
// params = this.sortObjectByKey(params);
console.log(params);
// 使 navigateToMiniProgram // 使 navigateToMiniProgram
uni.navigateToMiniProgram({ uni.navigateToMiniProgram({
appId: "wxef277996acc166c3", // appid appId: "wxef277996acc166c3", // appid
@ -395,7 +433,7 @@ export default {
}); });
//---- //----
} },
}, },
}; };
</script> </script>