支付订单逻辑整理完毕
parent
e7755657fd
commit
a8400f9d95
|
|
@ -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 {
|
||||||
|
|
@ -332,37 +337,74 @@ export default {
|
||||||
//
|
//
|
||||||
// 把选中的数据拼接成这样的数据 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>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue