cshenfu
2024-05-21 09d8c671d5e6e6045677bfb5218a5fb78c26aa0f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
'use strict';
const orderState = require('../../../../../application/service/orderState.js')
const applicationConstant = require('../../../../../application/constant/applicationsConstant.js')
const businessState = require('../../../../../application/service/businessState.js')
const orderPaySuccess = require('../../../../../application/service/orderPaySuccess.js');
module.exports = {
    /**
     * 购买会员
     * @url client/order/kh/create/role 前端调用的url参数地址
     * data 请求参数
     * @param {String} params1  参数1
     */
    main: async (event) => {
        let { data = {}, userInfo, util, filterResponse, originalParam } = event;
        let { customUtil, uniID, config, pubFun, vk, db, _ } = util;
        let { uid } = data;
        let res = { code: 0, msg: "" };
        // 业务逻辑开始-----------------------------------------------------------
 
        //数据准备
        let promoCodeId = ""
 
        let platform = data.platform
 
        let role = await vk.baseDao.findById({
            dbName: "uce-vip-role",
            id: data._id,
            whereJson: {
                status: true
            }
        });
        //不存在
        if (!role) {
            res.code = -1
            res.msg = "无效的会员"
            return res;
        }
 
 
        let type = applicationConstant.ROLE
        let total = role.charge * 100
        let title = role.name
        let goods_item = [{
            'oid': null,
            'user_id': uid,
            'goods_id': role._id,
            'charge': role.charge * 100,
            'type': type,
            'num': 1,
            'goods_name': title,
        }]
 
        //统一创建订单
        res = await orderState.createOrder(event, uid, total, title, type, platform, goods_item, promoCodeId)
 
        // 业务逻辑结束-----------------------------------------------------------
        return res;
    }
}