This commit is contained in:
sjk
2025-11-17 14:11:46 +08:00
commit ad4a600af9
1659 changed files with 171560 additions and 0 deletions

View File

@@ -0,0 +1,329 @@
import { mockIp, mockReqId } from '../../utils/mock';
const orderResps = [
{
data: {
saasId: '88888888',
uid: '88888888205468',
storeId: '1000',
skuId: '135691625',
numOfSku: 1,
numOfSkuAvailable: 1,
refundableAmount: '26900',
refundableDiscountAmount: '0',
shippingFeeIncluded: '0',
paidAmountEach: '26900',
boughtQuantity: 1,
orderNo: '132222623132329291',
goodsInfo: {
goodsName: '迷你便携高颜值蓝牙无线耳机立体声只能触控式操作简约立体声耳机',
skuImage: 'https://tdesign.gtimg.com/miniprogram/template/retail/goods/dz-2a.png',
specInfo: [
{
specId: '50456',
specTitle: '颜色',
specValue: '黑色',
},
{
specId: '50459',
specTitle: '尺码',
specValue: '简约款',
},
],
},
},
code: 'Success',
msg: null,
requestId: mockReqId(),
clientIp: mockIp(),
rt: 36,
success: true,
},
{
data: {
saasId: '88888888',
uid: '88888888205468',
storeId: '1000',
skuId: '135676631',
numOfSku: 1,
numOfSkuAvailable: 1,
refundableAmount: '26900',
refundableDiscountAmount: '0',
shippingFeeIncluded: '0',
paidAmountEach: '26900',
boughtQuantity: 1,
orderNo: '132222623132329291',
goodsInfo: {
goodsName: '白色短袖连衣裙荷叶边裙摆宽松韩版休闲纯白清爽优雅连衣裙',
skuImage: 'https://tdesign.gtimg.com/miniprogram/template/retail/goods/nz-09a.png',
specInfo: [
{
specId: '50456',
specTitle: '颜色',
specValue: '米色荷叶边',
},
{
specId: '50459',
specTitle: '尺码',
specValue: 'S',
},
],
},
},
code: 'Success',
msg: null,
requestId: mockReqId(),
clientIp: mockIp(),
rt: 36,
success: true,
},
{
data: {
saasId: '88888888',
uid: '88888888205468',
storeId: '1000',
skuId: '135691622',
numOfSku: 1,
numOfSkuAvailable: 1,
refundableAmount: '26900',
refundableDiscountAmount: '0',
shippingFeeIncluded: '0',
paidAmountEach: '26900',
boughtQuantity: 1,
orderNo: '132222623132329291',
goodsInfo: {
goodsName: '腾讯极光盒子4智能网络电视机顶盒6K千兆网络机顶盒4K高分辨率',
skuImage: 'https://tdesign.gtimg.com/miniprogram/template/retail/goods/dz-3a.png',
specInfo: [
{
specId: '50456',
specTitle: '颜色',
specValue: '经典白',
},
{
specId: '50459',
specTitle: '类型',
specValue: '经典套装',
},
],
},
},
code: 'Success',
msg: null,
requestId: mockReqId(),
clientIp: mockIp(),
rt: 36,
success: true,
},
{
data: {
saasId: '88888888',
uid: '88888888205468',
storeId: '1000',
skuId: '135676629',
numOfSku: 1,
numOfSkuAvailable: 1,
refundableAmount: '26900',
refundableDiscountAmount: '0',
shippingFeeIncluded: '0',
paidAmountEach: '26900',
boughtQuantity: 1,
orderNo: '132222623132329291',
goodsInfo: {
goodsName: '带帽午休毯虎年款多功能加厚加大加绒简约多功能午休毯连帽披肩',
skuImage: 'https://tdesign.gtimg.com/miniprogram/template/retail/goods/muy-3a.png',
specInfo: [
{
specId: '50456',
specTitle: '颜色',
specValue: '浅灰色',
},
{
specId: '50459',
specTitle: '尺码',
specValue: 'S',
},
],
},
},
code: 'Success',
msg: null,
requestId: mockReqId(),
clientIp: mockIp(),
rt: 36,
success: true,
},
{
data: {
saasId: '88888888',
uid: '88888888205468',
storeId: '1000',
skuId: '135686631',
numOfSku: 1,
numOfSkuAvailable: 1,
refundableAmount: '26900',
refundableDiscountAmount: '0',
shippingFeeIncluded: '0',
paidAmountEach: '26900',
boughtQuantity: 1,
orderNo: '132222623132329291',
goodsInfo: {
goodsName: '运动连帽拉链卫衣休闲开衫长袖多色运动细绒面料运动上衣',
skuImage: 'https://tdesign.gtimg.com/miniprogram/template/retail/goods/nz-17a.png',
specInfo: [
{
specId: '50456',
specTitle: '颜色',
specValue: '军绿色',
},
{
specId: '50459',
specTitle: '尺码',
specValue: 'XS',
},
],
},
},
code: 'Success',
msg: null,
requestId: mockReqId(),
clientIp: mockIp(),
rt: 36,
success: true,
},
{
data: {
saasId: '88888888',
uid: '88888888205468',
storeId: '1000',
skuId: '19384938948343',
numOfSku: 1,
numOfSkuAvailable: 1,
refundableAmount: '26900',
refundableDiscountAmount: '0',
shippingFeeIncluded: '0',
paidAmountEach: '26900',
boughtQuantity: 1,
orderNo: '130169571554503755',
goodsInfo: {
goodsName: '纯色纯棉休闲圆领短袖T恤纯白亲肤厚柔软细腻面料纯白短袖套头T恤',
skuImage: 'https://tdesign.gtimg.com/miniprogram/template/retail/goods/nz-08b.png',
specInfo: [
{
specId: '50456',
specTitle: '颜色',
specValue: '军绿色',
},
{
specId: '50459',
specTitle: '尺码',
specValue: 'XS',
},
],
},
},
code: 'Success',
msg: null,
requestId: mockReqId(),
clientIp: mockIp(),
rt: 36,
success: true,
},
{
data: {
saasId: '88888888',
uid: '88888888205468',
storeId: '1000',
skuId: '19384938948343',
numOfSku: 1,
numOfSkuAvailable: 1,
refundableAmount: '26900',
refundableDiscountAmount: '0',
shippingFeeIncluded: '0',
paidAmountEach: '26900',
boughtQuantity: 1,
orderNo: '130169571554503755',
goodsInfo: {
goodsName: '纯色纯棉休闲圆领短袖T恤纯白亲肤厚柔软细腻面料纯白短袖套头T恤',
skuImage: 'https://cdn-we-retail.ym.tencent.com/tsr/goods/nz-08b.png',
specInfo: [
{
specId: '50456',
specTitle: '颜色',
specValue: '军绿色',
},
{
specId: '50459',
specTitle: '尺码',
specValue: 'XS',
},
],
},
},
code: 'Success',
msg: null,
requestId: mockReqId(),
clientIp: mockIp(),
rt: 36,
success: true,
},
];
export function genRightsPreview(params) {
const { orderNo, skuId } = params;
const resp = orderResps.find((r) => r.data.orderNo === orderNo && r.data.skuId === skuId);
return resp;
}
export function genApplyReasonList(params) {
const resp = {
data: {
saasId: '70000001',
rightsReasonList: [
{ id: '1', desc: '实际商品与描述不符' },
{ id: '2', desc: '质量问题' },
{ id: '3', desc: '少件/漏发' },
{ id: '4', desc: '包装/商品/污迹/裂痕/变形' },
{ id: '5', desc: '发货太慢' },
{ id: '6', desc: '物流配送太慢' },
{ id: '7', desc: '商家发错货' },
{ id: '8', desc: '不喜欢' },
],
},
code: 'Success',
msg: null,
requestId: mockReqId(),
clientIp: mockIp(),
rt: 6,
success: true,
};
// 未收货对应的原因列表
if (params.rightsReasonType === 'REFUND_MONEY') {
resp.data.rightsReasonList = [
{ id: '9', desc: '空包裹' },
{ id: '10', desc: '快递/物流一直未送到' },
{ id: '11', desc: '货物破损已拒签' },
{ id: '12', desc: '不喜欢' },
];
}
return resp;
}
export function applyService() {
const resp = {
data: {
rightsNo: '123123423',
saasId: '70000001',
uid: '700000011070005',
storeId: '542',
result: null,
},
code: 'Success',
msg: null,
requestId: mockReqId(),
clientIp: mockIp(),
rt: 269,
success: true,
};
return resp;
}

View File

@@ -0,0 +1,169 @@
import { mockIp, mockReqId } from '../../utils/mock';
export const transformGoodsDataToConfirmData = (goodsDataList) => {
const list = [];
goodsDataList.forEach((goodsData) => {
list.push({
storeId: goodsData.storeId,
spuId: goodsData.spuId,
skuId: goodsData.skuId,
goodsName: goodsData.title,
image: goodsData.primaryImage,
reminderStock: 119,
quantity: goodsData.quantity,
payPrice: goodsData.price,
totalSkuPrice: goodsData.price,
discountSettlePrice: goodsData.price,
realSettlePrice: goodsData.price,
settlePrice: goodsData.price,
oriPrice: goodsData.originPrice,
tagPrice: null,
tagText: null,
skuSpecLst: goodsData.specInfo,
promotionIds: null,
weight: 0.0,
unit: 'KG',
volume: null,
masterGoodsType: 0,
viceGoodsType: 0,
roomId: goodsData.roomId,
egoodsName: null,
});
});
return list;
};
/** 生成结算数据 */
export function genSettleDetail(params) {
const { userAddressReq, couponList, goodsRequestList } = params;
const resp = {
data: {
settleType: 0,
userAddress: null,
totalGoodsCount: 3,
packageCount: 1,
totalAmount: '289997',
totalPayAmount: '',
totalDiscountAmount: '110000',
totalPromotionAmount: '1100',
totalCouponAmount: '0',
totalSalePrice: '289997',
totalGoodsAmount: '289997',
totalDeliveryFee: '0',
invoiceRequest: null,
skuImages: null,
deliveryFeeList: null,
storeGoodsList: [
{
storeId: '1000',
storeName: '云Mall深圳旗舰店',
remark: null,
goodsCount: 1,
deliveryFee: '0',
deliveryWords: null,
storeTotalAmount: '0',
storeTotalPayAmount: '179997',
storeTotalDiscountAmount: '110000',
storeTotalCouponAmount: '0',
skuDetailVos: [],
couponList: [],
},
],
inValidGoodsList: null,
outOfStockGoodsList: null,
limitGoodsList: null,
abnormalDeliveryGoodsList: null,
invoiceSupport: 1,
},
code: 'Success',
msg: null,
requestId: mockReqId(),
clientIp: mockIp(),
rt: 244,
success: true,
};
const list = transformGoodsDataToConfirmData(goodsRequestList);
// 获取购物车传递的商品数据
if (resp.data.storeGoodsList && resp.data.storeGoodsList.length > 0 && resp.data.storeGoodsList[0]) {
resp.data.storeGoodsList[0].skuDetailVos = list;
}
// 处理传入的优惠券数据
const discountPrice = [];
const selectedCoupons = [];
if (couponList && couponList.length > 0) {
couponList.forEach((coupon) => {
if (coupon.status === 'default') {
// 添加到折扣计算
discountPrice.push({
type: coupon.type,
value: coupon.value,
});
// 添加到响应的couponList中
selectedCoupons.push({
couponId: coupon.id || coupon.couponId,
storeId: coupon.storeId || '1000',
});
}
});
}
// 将选中的优惠券设置到响应数据中
if (resp.data.storeGoodsList && resp.data.storeGoodsList.length > 0 && resp.data.storeGoodsList[0]) {
resp.data.storeGoodsList[0].couponList = selectedCoupons;
}
// 模拟计算场景
// 计算总价
const totalPrice = list.reduce((pre, cur) => {
return pre + cur.quantity * Number(cur.settlePrice);
}, 0);
// 计算折扣
const totalDiscountPrice =
discountPrice.length > 0
? discountPrice.reduce((pre, cur) => {
if (cur.type === 1) {
// 满减券:直接减去固定金额
return pre + cur.value;
}
if (cur.type === 2) {
// 折扣券:计算折扣金额
// cur.value 是折扣值如80表示8折
// 8折意味着支付80%的价格,所以折扣金额 = 总价 * (100 - 折扣值) / 100
const discountAmount = (Number(totalPrice) * (100 - cur.value)) / 100;
console.log('折扣券计算:', {
totalPrice: Number(totalPrice),
discountValue: cur.value,
finalPrice: Number(totalPrice) * cur.value / 100,
discountAmount: discountAmount,
formula: `折扣金额 = ${Number(totalPrice)} * (100 - ${cur.value}) / 100 = ${discountAmount}`
});
return pre + discountAmount;
}
return pre + cur;
}, 0)
: 0;
resp.data.totalSalePrice = totalPrice;
resp.data.totalCouponAmount = totalDiscountPrice;
resp.data.totalPayAmount =
totalPrice - totalDiscountPrice - Number(resp.data.totalPromotionAmount);
if (userAddressReq) {
resp.data.settleType = 1;
resp.data.userAddress = userAddressReq;
}
return resp;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,51 @@
export function genOrders() {
return {
data: {
pageNum: 1,
pageSize: 10,
totalCount: 0,
orders: [],
},
code: 'Success',
msg: null,
requestId: 'mock-request-id',
clientIp: '127.0.0.1',
rt: 100,
success: true,
};
}
export function genOrdersCount() {
return {
data: {
orderNum: [
{
orderStatus: -1,
orderNum: 7,
},
{
orderStatus: 10,
orderNum: 1,
},
{
orderStatus: 30,
orderNum: 1,
},
{
orderStatus: 40,
orderNum: 1,
},
{
orderStatus: 50,
orderNum: 4,
},
],
},
code: 'Success',
msg: null,
requestId: 'mock-request-id',
clientIp: '127.0.0.1',
rt: 100,
success: true,
};
}