- if (!user) {
- return response.error(new Error('用户未登录'));
- }
- const authData = user.get('authData');
- if (!authData || !authData.lc_weapp) {
- return response.error(new Error('当前用户不是小程序用户'));
- }
- const order = new Order();
- order.tradeId = uuid().replace(/-/g, '');
- order.status = 'INIT';
- order.user = request.currentUser;
- order.productDescription = 'LeanCloud-小程序支付测试';
- order.amount = 1;
- order.ip = request.meta.remoteAddress;
- if (!(order.ip && /^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/.test(order.ip))) {
- order.ip = '127.0.0.1';
- }
- order.tradeType = 'JSAPI';
- const acl = new AV.ACL();
- // 只有创建订单的用户可以读,没有人可以写
- acl.setPublicReadAccess(false);