支付订单逻辑整理完毕

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>
<script>
import { getGuildStoreDetail, getGuildCoupon, getPaySign } from "@/api/service";
import {
getGuildStoreDetail,
getGuildCoupon,
getPaySign,
appBuy,
} from "@/api/service";
import NavHeader from "@/components/NavHeader/NavHeader.vue";
export default {
@ -332,37 +337,74 @@ export default {
//
// couponId:num;couponId:num 2324:1;2325:2
const couponStr = selectedItems
.map((item) => `${item.couponId}:${item.quantity}`)
.map((item) => `${item.id}:${item.quantity}`)
.join(";");
// this.totalAmount ,
const trxamt = (this.totalAmount * 100).toFixed(0);
// this.totalAmount ,
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(){
//
const reqsn =
"mini" + Date.now() + "" + Math.floor(Math.random() * 10000);
async handlePay(order) {
//
// const reqsn =
// "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) + "";
//
//
// STring ,
let params = {
appid: "00390105", // appid
body: "body订单标题", //
body: bodyStr, //
cusid: "56479107531MPMN", //
notify_url:
"http://e989c692.natappfree.cc/admin-api/member/labor-union-coupon-purchase/tlNotice", //
orgid: "56479107392N35H",
paytype: "W06",
randomstr: randomstr,
remark: "remark备注",
reqsn: reqsn,
remark: order.orderNumber+ ":" + bodyStr,
reqsn: order.orderNumber,
sign: "",
signtype: "RSA",
trxamt: "1",
// trxamt: "" + order.payableAmount,
trxamt: "1",//
version: "12",
//"asinfo":"56479107392MP4J:01:0.01" //(, ) , ,01 , ,0.01
};
@ -370,10 +412,6 @@ export default {
const sign = await getPaySign(params);
console.log("测试返回的签名:" + sign);
params["sign"] = sign;
console.log(params);
// params = this.sortObjectByKey(params);
console.log(params);
// 使 navigateToMiniProgram
uni.navigateToMiniProgram({
appId: "wxef277996acc166c3", // appid
@ -395,7 +433,7 @@ export default {
});
//----
}
},
},
};
</script>