fix:完善门店和总部管理端
This commit is contained in:
@@ -13,7 +13,8 @@ MOCK_SMS_CODE=123456
|
||||
MOCK_PAY=true
|
||||
MOCK_DELIVERY_AUTO=true
|
||||
AUTO_APPROVE_STORE=true
|
||||
# preV1 Mock 微信授权登录:点击授权按钮走 Mock 流程直接登录(不接真实微信)
|
||||
# 微信 OAuth Mock(preV1 本地联调):须在微信内置浏览器内打开 H5,走 OAuth 回跳带 mock code;
|
||||
# 非微信浏览器不会发起 /login/wechat 请求。生产请 MOCK_WECHAT=false 且 WECHAT_AUTH_ENABLED=true。
|
||||
MOCK_WECHAT=true
|
||||
|
||||
# C 端 H5 落地页(推广码二维码链接前缀)
|
||||
@@ -22,7 +23,8 @@ USER_H5_URL=http://localhost:5173
|
||||
# 反向代理后提取真实客户端 IP(下单 IP 定位)
|
||||
TRUST_PROXY=true
|
||||
|
||||
# 微信SDK(WECHAT_AUTH_ENABLED=true 时生效)
|
||||
# 微信 SDK(生产:WECHAT_AUTH_ENABLED=true,配置 WX_APP_ID / WX_APP_SECRET)
|
||||
# OAuth 授权页由 /common/wechat/oauth-url 生成;C/合伙人/总部 H5 均须在微信内置浏览器内授权。
|
||||
WX_APP_ID=
|
||||
WX_APP_SECRET=
|
||||
WECHAT_AUTH_ENABLED=false
|
||||
|
||||
@@ -216,6 +216,14 @@ async function main() {
|
||||
},
|
||||
});
|
||||
|
||||
await prisma.commonPromoCode.create({
|
||||
data: {
|
||||
code: 'DKDEMO1',
|
||||
name: '郑州品鉴会演示',
|
||||
status: 'ACTIVE',
|
||||
},
|
||||
});
|
||||
|
||||
const now = new Date();
|
||||
const periodStart = new Date(now.getFullYear(), now.getMonth(), 1);
|
||||
const periodEnd = new Date(now.getFullYear(), now.getMonth() + 1, 0);
|
||||
|
||||
@@ -114,46 +114,65 @@ export class TradeService {
|
||||
body.clientLocation,
|
||||
);
|
||||
|
||||
const order = await this.prisma.order.create({
|
||||
data: {
|
||||
orderNo,
|
||||
userId,
|
||||
cityId: city.id,
|
||||
status: 'PENDING_PAY',
|
||||
payStatus: 'UNPAID',
|
||||
deliveryType: preview.deliveryType as 'LOCAL' | 'CROSS_CITY',
|
||||
productId: product.id,
|
||||
barcode69: product.barcode69,
|
||||
productName: product.name,
|
||||
productSpec: product.spec,
|
||||
imageResourceId: product.coverResourceId,
|
||||
quantity: body.quantity,
|
||||
listUnitPrice: product.price,
|
||||
listAmount: preview.productAmount,
|
||||
productAmount: preview.productAmount,
|
||||
receiverName: address.receiverName,
|
||||
receiverPhone: address.phone,
|
||||
receiverAddress: `${address.province}${address.city}${address.district}${address.detail}`,
|
||||
receiverProvince: address.province,
|
||||
receiverCity: address.city,
|
||||
receiverDistrict: address.district,
|
||||
clientIp: location.clientIp,
|
||||
ipProvince: location.ipProvince,
|
||||
ipCity: location.ipCity,
|
||||
ipDistrict: location.ipDistrict,
|
||||
gpsProvince: location.gpsProvince,
|
||||
gpsCity: location.gpsCity,
|
||||
gpsDistrict: location.gpsDistrict,
|
||||
gpsLatitude: location.gpsLatitude,
|
||||
gpsLongitude: location.gpsLongitude,
|
||||
gpsAddress: location.gpsAddress,
|
||||
freightAmount: preview.freightAmount,
|
||||
freightPayType: preview.freightPayType,
|
||||
payAmount: preview.payAmount,
|
||||
benefitAmount: preview.benefitAmount,
|
||||
payExpireAt,
|
||||
},
|
||||
include: { product: true, imageResource: true },
|
||||
const attribution = await this.prisma.userPromoAttribution.findUnique({
|
||||
where: { userId },
|
||||
include: { promoCode: true },
|
||||
});
|
||||
const promoCodeId =
|
||||
attribution?.promoCode?.status === 'ACTIVE' ? attribution.promoCodeId : undefined;
|
||||
|
||||
const order = await this.prisma.$transaction(async (tx) => {
|
||||
const created = await tx.order.create({
|
||||
data: {
|
||||
orderNo,
|
||||
userId,
|
||||
cityId: city.id,
|
||||
status: 'PENDING_PAY',
|
||||
payStatus: 'UNPAID',
|
||||
deliveryType: preview.deliveryType as 'LOCAL' | 'CROSS_CITY',
|
||||
productId: product.id,
|
||||
barcode69: product.barcode69,
|
||||
productName: product.name,
|
||||
productSpec: product.spec,
|
||||
imageResourceId: product.coverResourceId,
|
||||
quantity: body.quantity,
|
||||
listUnitPrice: product.price,
|
||||
listAmount: preview.productAmount,
|
||||
productAmount: preview.productAmount,
|
||||
receiverName: address.receiverName,
|
||||
receiverPhone: address.phone,
|
||||
receiverAddress: `${address.province}${address.city}${address.district}${address.detail}`,
|
||||
receiverProvince: address.province,
|
||||
receiverCity: address.city,
|
||||
receiverDistrict: address.district,
|
||||
clientIp: location.clientIp,
|
||||
ipProvince: location.ipProvince,
|
||||
ipCity: location.ipCity,
|
||||
ipDistrict: location.ipDistrict,
|
||||
gpsProvince: location.gpsProvince,
|
||||
gpsCity: location.gpsCity,
|
||||
gpsDistrict: location.gpsDistrict,
|
||||
gpsLatitude: location.gpsLatitude,
|
||||
gpsLongitude: location.gpsLongitude,
|
||||
gpsAddress: location.gpsAddress,
|
||||
freightAmount: preview.freightAmount,
|
||||
freightPayType: preview.freightPayType,
|
||||
payAmount: preview.payAmount,
|
||||
benefitAmount: preview.benefitAmount,
|
||||
payExpireAt,
|
||||
promoCodeId,
|
||||
},
|
||||
include: { product: true, imageResource: true },
|
||||
});
|
||||
|
||||
if (promoCodeId) {
|
||||
await tx.commonPromoCode.update({
|
||||
where: { id: promoCodeId },
|
||||
data: { orderCount: { increment: 1 } },
|
||||
});
|
||||
}
|
||||
|
||||
return created;
|
||||
});
|
||||
|
||||
return serializeBigInt(mapOrderCompat(order));
|
||||
|
||||
Reference in New Issue
Block a user