# 抽奖盲盒系统API接口文档 ## 1. 接口概览 ### 基础信息 - **基础URL**: `https://api.zfunbox.cn/api/` - **API版本**: `v1` - **数据格式**: `JSON` - **字符编码**: `UTF-8` - **认证方式**: `Token认证` - **签名方式**: `MD5签名 + 时间戳防重放` ### 通用响应格式 ```json { "status": 1, "msg": "success", "data": {}, "timestamp": 1640995200 } ``` ### 状态码说明 | 状态码 | 说明 | |--------|------| | 1 | 请求成功 | | 0 | 请求失败 | | -1 | 未登录 | | -9 | 需要绑定手机号 | | 2222 | 特殊状态(如已领取等) | ### 请求签名机制 所有POST请求都需要包含以下参数: - `timestamp`: 当前时间戳 - `nonce`: 随机字符串 - `sign`: MD5签名 签名算法: 1. 将所有参数按键名排序 2. 拼接为 `key1=value1&key2=value2` 格式 3. 添加密钥:`host + timestamp` 4. 对整个字符串进行MD5加密 ## 2. 用户认证接口 ### 2.1 发送短信验证码 ```http POST /v2/account/sendSms ``` **请求参数:** ```json { "phone": "13800138000" } ``` **参数说明:** | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | phone | string | 是 | 手机号 | **响应示例:** ```json { "status": 1, "msg": "验证码发送成功", "data": 60 } ``` ### 2.2 手机号登录 ```http POST /mobileLogin ``` **迁移状态**: ✅ 已迁移到 .NET 8 **新接口地址**: `POST /api/mobileLogin` **请求参数:** ```json { "mobile": "13800138000", "code": "123456", "pid": 0, "clickId": "" } ``` **参数说明:** | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | mobile | string | 是 | 手机号 | | code | string | 是 | 验证码 | | pid | int | 否 | 推荐人ID | | clickId | string | 否 | 点击ID | **响应示例:** ```json { "status": 1, "msg": "登录成功", "data": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..." } ``` ### 2.3 微信授权登录 ```http POST /login ``` **迁移状态**: ✅ 已迁移到 .NET 8 **新接口地址**: `POST /api/login` **请求参数:** ```json { "code": "wx_auth_code", "pid": 0, "clickId": "" } ``` **参数说明:** | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | code | string | 是 | 微信授权code | | pid | int | 否 | 推荐人ID | | clickId | string | 否 | 点击ID | **响应示例:** ```json { "status": 1, "msg": "登录成功", "data": "token_string" } ``` ### 2.4 获取用户信息 ```http POST /user ``` **迁移状态**: ✅ 已迁移到 .NET 8 **新接口地址**: `POST /api/user` **请求头:** ``` Authorization: Bearer {token} ``` **响应示例:** ```json { "status": 1, "msg": "success", "data": { "userinfo": { "id": 1001, "phone": "138****8000", "nickname": "用户昵称", "avatar": "头像URL", "money": "100.00", "integral": "50.00", "money2": "20.00", "level": 1, "mobile_is": 1 } } } ``` ### 2.5 更新用户信息 ```http POST /update_userinfo ``` **迁移状态**: ✅ 已迁移到 .NET 8 **新接口地址**: `POST /api/update_userinfo` **请求头:** ``` Authorization: Bearer {token} ``` **请求参数:** ```json { "nickname": "新昵称", "headimg": "头像URL", "imagebase": "Base64编码的图片数据" } ``` **参数说明:** | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | nickname | string | 否 | 新昵称 | | headimg | string | 否 | 头像URL(直接使用URL) | | imagebase | string | 否 | Base64编码的图片数据(优先使用) | **响应示例:** ```json { "status": 1, "msg": "更新成功" } ``` ### 2.6 注销账号 ```http POST /user_log_off ``` **迁移状态**: ✅ 已迁移到 .NET 8 **新接口地址**: `POST /api/user_log_off` **请求头:** ``` Authorization: Bearer {token} ``` **请求参数:** ```json { "type": 0 } ``` **参数说明:** | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | type | int | 否 | 类型:0-注销账号,1-取消注销 | **响应示例:** ```json { "status": 1, "msg": "注销成功" } ``` ### 2.6 微信授权绑定手机号 ```http POST /login_bind_mobile ``` **迁移状态**: ✅ 已迁移到 .NET 8 **新接口地址**: `POST /api/login_bind_mobile` **请求头:** ``` Authorization: Bearer {token} ``` **请求参数:** ```json { "code": "wx_phone_auth_code" } ``` **参数说明:** | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | code | string | 是 | 微信获取手机号授权code | **响应示例:** ```json { "status": 1, "msg": "绑定成功", "data": { "token": "new_token_if_account_merged" } } ``` **说明:** - 如果手机号已被其他用户绑定,会进行账户合并,返回新的token - 如果手机号未被绑定,直接绑定到当前用户,token为null ### 2.7 验证码绑定手机号 ```http POST /bindMobile ``` **迁移状态**: ✅ 已迁移到 .NET 8 **新接口地址**: `POST /api/bindMobile` **请求头:** ``` Authorization: Bearer {token} ``` **请求参数:** ```json { "mobile": "13800138000", "code": "123456" } ``` **参数说明:** | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | mobile | string | 是 | 手机号 | | code | string | 是 | 短信验证码 | **响应示例:** ```json { "status": 1, "msg": "绑定成功", "data": { "token": "new_token_if_account_merged" } } ``` **说明:** - 如果手机号已被其他用户绑定,会进行账户合并,返回新的token - 如果手机号未被绑定,直接绑定到当前用户,token为null ### 2.8 记录用户登录 ```http GET|POST /login_record ``` **迁移状态**: ✅ 已迁移到 .NET 8 **新接口地址**: `GET|POST /api/login_record` **请求头:** ``` Authorization: Bearer {token} ``` **请求参数:** ```json { "device": "android", "deviceInfo": "设备信息" } ``` **参数说明:** | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | device | string | 否 | 设备类型 | | deviceInfo | string | 否 | 设备信息 | **响应示例:** ```json { "status": 1, "msg": "success", "data": { "uid": "100001", "nickname": "用户昵称", "headimg": "头像URL" } } } ``` ## 3. 商品相关接口 ### 3.1 获取首页商品列表 ```http POST /goods ``` **请求参数:** ```json { "page": 1, "type": 0, "keyword": "" } ``` **参数说明:** | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | page | int | 是 | 页码,从1开始 | | type | int | 否 | 商品类型:0-全部,1-一番赏,2-无限赏等 | | keyword | string | 否 | 搜索关键词 | **响应示例:** ```json { "status": 1, "msg": "success", "data": { "data": [ { "id": 1001, "title": "精美手办盲盒", "imgurl": "商品图片URL", "price": "29.90", "type": 1, "stock": 100, "sale_stock": 50, "status": 1, "prize_num": 1, "show_price": "29.9元/抽" } ], "total": 100, "current_page": 1, "last_page": 10 } } ``` ### 3.2 获取商品详情(一番赏) ```http POST /goodsdetail ``` **请求参数:** ```json { "goods_id": 1001, "num": 0 } ``` **响应示例:** ```json { "status": 1, "msg": "success", "data": { "goods": { "id": 1001, "title": "精美手办盲盒", "imgurl": "商品封面图", "imgurl_detail": "商品详情图", "price": "29.90", "type": 1, "stock": 100, "prize_num": 1, "goods_describe": "商品描述" }, "goods_list": [ { "id": 2001, "title": "限定手办A", "imgurl": "奖品图片", "price": "299.00", "money": "150.00", "real_pro": "0.05000", "goods_type": 1, "prize_code": "A001" } ] } } ``` ### 3.3 获取无限赏商品详情 ```http POST /infinite_goodsdetail ``` **请求参数:** ```json { "goods_id": 1001 } ``` **响应示例:** ```json { "status": 1, "msg": "success", "data": { "goods": { "id": 1001, "title": "无限赏盲盒", "imgurl": "商品图片", "price": "19.90", "type": 2, "lingzhu_is": 1, "king_user_id": 1234 }, "goods_list": [ { "id": 2001, "title": "稀有奖品", "imgurl": "奖品图片", "price": "199.00", "real_pro": "0.01000" } ] } } ``` ### 3.4 获取商品奖品数量统计 ```http POST /goodslist_count ``` **请求参数:** ```json { "goods_id": 1001 } ``` ### 3.5 获取商品奖品内容 ```http POST /goodslist_content ``` **请求参数:** ```json { "goods_id": 1001, "num": 0 } ``` ### 3.6 获取预售日历 ```http POST /yushourili ``` **请求参数:** ```json { "page": 1 } ``` ## 4. 订单相关接口 ### 4.1 计算订单金额(一番赏) ```http POST /ordermoney ``` **请求参数:** ```json { "goods_id": 1001, "num": 0, "prize_num": 1, "coupon_id": "", "use_money_is": 2, "use_integral_is": 2, "use_money2_is": 2 } ``` **参数说明:** | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | goods_id | int | 是 | 商品ID | | num | int | 是 | 第几套 | | prize_num | int | 是 | 抽奖数量 | | coupon_id | string | 否 | 优惠券ID | | use_money_is | int | 否 | 是否使用余额:1-是,2-否 | | use_integral_is | int | 否 | 是否使用积分:1-是,2-否 | | use_money2_is | int | 否 | 是否使用哈尼券:1-是,2-否 | **响应示例:** ```json { "status": 1, "msg": "success", "data": { "order_total": "29.90", "price": "29.90", "goods_info": { "id": 1001, "title": "精美手办盲盒", "imgurl": "商品图片" }, "goodsExtend": { "pay_wechat": 1, "pay_balance": 1, "pay_currency": 1, "pay_currency2": 1 } } } ``` ### 4.2 创建订单并支付(一番赏) ```http POST /orderbuy ``` **请求参数:** ```json { "goods_id": 1001, "num": 0, "prize_num": 1, "coupon_id": "", "use_money_is": 2, "use_integral_is": 2, "use_money2_is": 2 } ``` **响应示例:** ```json { "status": 1, "msg": "success", "data": { "status": 1, "order_num": "202401010001", "res": { "appId": "wx123456789", "timeStamp": "1640995200", "nonceStr": "abc123", "package": "prepay_id=wx123456789", "signType": "RSA", "paySign": "signature" } } } ``` ### 4.3 无限赏订单金额计算 ```http POST /infinite_ordermoney ``` **请求参数:** ```json { "goods_id": 1001, "prize_num": 1, "use_money_is": 2, "use_integral_is": 2, "use_money2_is": 2, "coupon_id": "" } ``` ### 4.4 无限赏创建订单 ```http POST /infinite_orderbuy ``` **请求参数:** ```json { "goods_id": 1001, "prize_num": 1, "use_money_is": 2, "use_integral_is": 2, "use_money2_is": 2, "coupon_id": "" } ``` ### 4.5 商城订单金额计算 ```http POST /mall_ordermoney ``` **请求参数:** ```json { "goods_id": 1001, "prize_num": 1, "goods_num": 1, "use_money_is": 2, "use_integral_is": 2, "use_money2_is": 2 } ``` ### 4.6 获取订单列表 ```http POST /order_list ``` **请求参数:** ```json { "page": 1, "page_size": 20 } ``` **响应示例:** ```json { "status": 1, "msg": "success", "data": { "data": [ { "id": 10001, "order_num": "202401010001", "goods_title": "精美手办盲盒", "goods_imgurl": "商品图片", "order_total": "29.90", "price": "29.90", "prize_num": 1, "status": 1, "addtime": 1640995200, "pay_time": 1640995300 } ], "total": 50, "current_page": 1, "last_page": 3 } } ``` ### 4.7 获取订单详情 ```http POST /order_detail ``` **请求参数:** ```json { "order_num": "202401010001" } ``` ## 5. 抽奖相关接口 ### 5.1 获取抽奖结果(一番赏) ```http POST /prizeorderlog ``` **请求参数:** ```json { "order_num": "202401010001" } ``` **响应示例:** ```json { "status": 1, "msg": "success", "data": [ { "id": 20001, "order_id": 10001, "goodslist_title": "限定手办A", "goodslist_imgurl": "奖品图片", "goodslist_price": "299.00", "goodslist_money": "150.00", "goodslist_type": 1, "status": 0, "addtime": 1640995300, "prize_code": "A001", "luck_no": 1 } ] } ``` ### 5.2 获取无限赏抽奖结果 ```http POST /infinite_prizeorderlog ``` **请求参数:** ```json { "order_num": "202401010001" } ``` ### 5.3 获取中奖记录 ```http POST /shang_log ``` **请求参数:** ```json { "goods_id": 1001, "num": 0, "page": 1 } ``` **响应示例:** ```json { "status": 1, "msg": "success", "data": { "data": [ { "user_nickname": "用户***", "goodslist_title": "限定手办A", "addtime": "2024-01-01 10:30:00", "luck_no": 1 } ] } } ``` ### 5.4 获取无限赏中奖记录 ```http POST /infinite_shang_log ``` **请求参数:** ```json { "goods_id": 1001, "page": 1 } ``` ### 5.5 获取每日抽奖记录 ```http POST /infinite_prizerecords ``` **请求参数:** ```json { "goods_id": 1001 } ``` ### 5.6 使用道具卡抽奖 ```http POST /item_card_chou ``` **请求参数:** ```json { "goods_id": 1001, "item_card_id": 1 } ``` ## 6. 盒柜(仓库)相关接口 ### 6.1 获取仓库首页 ```http POST /warehouse_index ``` **请求参数:** ```json { "page": 1, "status": 0 } ``` **参数说明:** | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | page | int | 是 | 页码 | | status | int | 否 | 状态:0-待选择,1-回收,2-发货,3-集市 | **响应示例:** ```json { "status": 1, "msg": "success", "data": { "data": [ { "id": 20001, "goodslist_title": "限定手办A", "goodslist_imgurl": "奖品图片", "goodslist_price": "299.00", "goodslist_money": "150.00", "status": 0, "addtime": 1640995300 } ] } } ``` ### 6.2 回收奖品 ```http POST /warehouse_recovery ``` **请求参数:** ```json { "order_list_ids": "20001,20002" } ``` ### 6.3 发货奖品 ```http POST /warehouse_send ``` **请求参数:** ```json { "order_list_ids": "20001,20002", "name": "张三", "mobile": "13800138000", "address": "北京市朝阳区xxx街道xxx号", "message": "请小心轻放" } ``` ### 6.4 确认发货 ```http POST /warehouse_send_confirm ``` **请求参数:** ```json { "id": 70001 } ``` ### 6.5 获取发货记录 ```http POST /warehouse_send_record ``` **请求参数:** ```json { "page": 1 } ``` ### 6.6 获取发货记录详情 ```http POST /warehouse_send_record_detail ``` **请求参数:** ```json { "id": 70001 } ``` ### 6.7 获取回收记录 ```http POST /warehouse_recovery_record ``` **请求参数:** ```json { "page": 1 } ``` ### 6.8 获取物流信息 ```http POST /warehouse_order_logistics ``` **请求参数:** ```json { "id": 70001 } ``` ## 7. 财务相关接口 ### 7.1 获取资金明细 ```http POST /profitMoney ``` **请求参数:** ```json { "page": 1, "type": 0 } ``` **参数说明:** | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | page | int | 是 | 页码 | | type | int | 否 | 类型:0-全部,1-充值,2-消费,3-回收等 | **响应示例:** ```json { "status": 1, "msg": "success", "data": { "data": [ { "id": 50001, "change_money": "+150.00", "money": "250.00", "type": 4, "type_name": "背包回收", "content": "回收奖品获得", "addtime": 1640995500 } ] } } ``` ### 7.2 获取积分明细 ```http POST /profitScore ``` **请求参数:** ```json { "page": 1, "type": 0 } ``` ### 7.3 获取支付明细 ```http POST /profitPay ``` **请求参数:** ```json { "page": 1, "type": 0 } ``` ### 7.4 获取优惠券列表 ```http POST /coupon_list ``` **请求参数:** ```json { "page": 1, "status": 0 } ``` **参数说明:** | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | page | int | 是 | 页码 | | status | int | 否 | 状态:0-未使用,1-已使用,2-已过期 | **响应示例:** ```json { "status": 1, "msg": "success", "data": { "data": [ { "id": 60001, "title": "新人专享券", "price": "5.00", "man_price": "30.00", "end_time": 1641081600, "status": 0, "state": 0 } ] } } ``` ### 7.5 领取优惠券 ```http POST /coupon_ling ``` **请求参数:** ```json { "coupon_id": 60001 } ``` ### 7.6 分享优惠券 ```http POST /coupon_share ``` **请求参数:** ```json { "coupon_id": 60001 } ``` ### 7.7 合成优惠券 ```http POST /coupon_synthesis ``` **请求参数:** ```json { "coupon_ids": "60001,60002,60003" } ``` ### 7.8 计算优惠券合成 ```http POST /coupon_ji_suan ``` **请求参数:** ```json { "coupon_ids": "60001,60002,60003" } ``` ## 8. 福利相关接口 ### 8.1 获取福利屋列表 ```http POST /welfare_house_list ``` **响应示例:** ```json { "status": 1, "msg": "success", "data": [ { "id": 1001, "title": "每日福利", "imgurl": "福利图片", "status": 1 } ] } ``` ### 8.2 获取福利屋详情 ```http POST /fuliwu_detail ``` **请求参数:** ```json { "goods_id": 1001 } ``` ### 8.3 获取福利屋参与者 ```http POST /fuliwu_participants ``` **请求参数:** ```json { "goods_id": 1001, "page": 1 } ``` ### 8.4 获取福利屋记录 ```http POST /fuliwu_records ``` **请求参数:** ```json { "goods_id": 1001, "page": 1 } ``` ### 8.5 获取用户福利屋参与记录 ```http GET /fuliwu_user_records ``` ### 8.6 获取用户福利屋中奖记录 ```http GET /fuliwu_user_winning_records ``` ### 8.7 完成任务 ```http POST /ling_task ``` **请求参数:** ```json { "task_list_id": 1001 } ``` ## 9. 系统配置接口 ### 9.1 获取全局配置 ```http GET /config ``` **响应示例:** ```json { "status": 1, "msg": "success", "data": { "good_type": [ { "value": 1, "name": "一番赏", "is_show": 1, "pay_wechat": 1, "pay_balance": 1 } ], "app_setting": { "app_name": "友达赏", "balance_name": "钻石", "currency1_name": "UU币", "currency2_name": "哈尼券", "applet_version": "v1.0.3" } } } ``` ### 9.2 获取轮播图 ```http GET /getAdvert ``` **请求参数:** | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | type_id | int | 否 | 类型:1-首页轮播,2-抽卡机轮播 | **响应示例:** ```json { "status": 1, "msg": "success", "data": [ { "id": 1, "imgurl": "轮播图URL", "url": "跳转链接", "ttype": 2, "goods_id": 1001 } ] } ``` ### 9.3 获取单页内容 ```http GET /getDanye ``` **请求参数:** | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | type | int | 是 | 页面类型:1-服务协议,2-隐私政策,3-公告 | **响应示例:** ```json { "status": 1, "msg": "success", "data": { "title": "用户协议", "content": "协议内容..." } } ``` ### 9.4 获取优惠券中心 ```http POST /coupon ``` **响应示例:** ```json { "status": 1, "msg": "success", "data": { "status": 1, "goods": { "list": [ { "id": 60001, "title": "新人券", "price": "5.00" } ] } } } ``` ### 9.5 领取优惠券 ```http POST /receive ``` **请求参数:** ```json { "coupon_id": "60001,60002" } ``` ### 9.6 添加收藏 ```http POST /addCollect ``` **请求参数:** ```json { "goods_id": 1001, "type": 1, "num": 0 } ``` ## 10. 其他功能接口 ### 10.1 获取排行榜 ```http GET /getRankList ``` **请求参数:** | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | type | string | 是 | 排行榜类型:invite-邀请榜,consume-消费榜 | ### 10.2 获取邀请信息 ```http POST /invitation ``` **请求参数:** ```json { "page": 1 } ``` ### 10.3 绑定邀请码 ```http POST /bind_invite_code ``` **请求参数:** ```json { "invite_code": "ABC123" } ``` ### 10.4 获取VIP列表 ```http POST /vip_list ``` ### 10.5 使用兑换码 ```http POST /used ``` **请求参数:** ```json { "code": "EXCHANGE123" } ``` ## 11. 错误码说明 | 错误码 | 说明 | |--------|------| | 1 | 请求成功 | | 0 | 请求失败 | | -1 | 用户未登录 | | -9 | 需要绑定手机号 | | 2222 | 特殊状态(如已领取、已完成等) | ## 12. UniApp小程序接口调用示例 ### 12.1 请求封装使用 ```javascript // 在小程序页面中调用API export default { methods: { // 获取商品列表 async getGoodsList() { try { const res = await this.$request.post('goods', { page: 1, type: 0 }); if (res.status === 1) { this.goodsList = res.data.data; } else { this.$c.toast(res.msg); } } catch (error) { console.error('获取商品列表失败:', error); } }, // 创建订单并支付 async createOrder() { const res = await this.req({ url: 'orderbuy', data: { goods_id: this.goodsId, num: 0, prize_num: 1, use_money_is: 2, use_integral_is: 2 } }); if (res.status === 1 && res.data.status === 1) { // 调起微信支付 const payResult = await this.$platform.pay({ data: res.data.res }, this); if (payResult === 'success') { // 支付成功,获取抽奖结果 this.getPrizeResult(res.data.order_num); } } }, // 获取抽奖结果 async getPrizeResult(orderNum) { const res = await this.$request.post('prizeorderlog', { order_num: orderNum }); if (res.status === 1) { // 显示中奖结果 this.showPrizeResult(res.data); } } } } ``` ### 12.2 配置管理使用 ```javascript // 获取全局配置 const appName = this.$config.getAppSetting('app_name'); const balanceName = this.$config.getAppSetting('balance_name'); // 获取商品类型配置 const goodTypes = this.$config.getGoodType(); // 检查支付方式 const goodTypeConfig = this.$config.getGoodTypeFind(1); // 一番赏 if (goodTypeConfig.pay_wechat === 1) { // 支持微信支付 } ``` ### 12.3 路由跳转使用 ```javascript // 跳转到商品详情页 this.$c.to({ url: '/pages/shouye/detail', query: { goods_id: 1001, num: 0 } }); // 跳转到用户中心 this.$customRouter.navigateTo('/pages/user/index'); ``` ### 12.4 平台适配使用 ```javascript // 调起支付(自动适配不同平台) const payResult = await this.$platform.pay({ data: payParams }, this); // 平台特定功能 if (this.$platform.code === 'mp-weixin') { // 微信小程序特有功能 wx.requestPayment(payParams); } ``` 这份更新后的API文档基于小程序中实际使用的接口,包含了完整的请求参数、响应格式和使用示例,更贴近实际开发需求。