《仿盒马》app开发技术分享-- 订单提交逻辑完善(74)
2025-06-28 13:35:55
105次阅读
0个评论
## 技术栈
Appgallery connect
开发准备
上一节我们实现了兑换订单的提交功能,并且成功的把数据提交到云端,但是我们的业务逻辑并没有完全实现,我们只是把数据提交到了云端,但我们的积分还存在,我们回到积分数据查看的页面也没有消费积分的记录,这一节我们要实现的就是完善订单提交的业务逻辑
功能分析
首先我们要在兑换完成后把用户信息的积分给扣除掉,点击按钮后进行云端交互修改用户信息表,然后我们在兑换成功时新增一条积分消费记录。
代码实现
我们先在订单提交的时候修改用户信息表的内容
if (num>0) {
showToast("兑换成功")
let userData=new user_info()
userData.id=this.userInfo!.id
userData.user_id=this.userInfo!.user_id
userData.sex=this.userInfo!.sex
userData.bind_phone=this.userInfo!.bind_phone
userData.create_time=this.userInfo!.create_time
userData.nickname=this.userInfo!.nickname
userData.head_img=this.userInfo!.head_img
userData.money=this.userInfo!.money
userData.points=this.userInfo!.points-this.pointsProduct!.points
let s= await databaseZone.upsert(userData);
}
修改完用户信息之后,我们同时还需要新增一条积分收支记录,在收支记录添加前,还需要实现一个时间获取的方法
@State year:string=''
@State month:string=''
@State day:string=''
@State time:string=''
formatCurrent() {
const now = new Date();
const years = now.getFullYear();
const months = String(now.getMonth() + 1).padStart(2, '0');
const days = String(now.getDate()).padStart(2, '0');
const m_hours = String(now.getHours()).padStart(2, '0');
const m_minutes = String(now.getMinutes()).padStart(2, '0');
const m_seconds = String(now.getSeconds()).padStart(2, '0');
this.year=String(years)
this.month=months
this.day=days
this.time=m_hours+":"+m_minutes+":"+m_seconds
}
记录生成
let points=new points_info()
points.id=Math.floor(Math.random() * 1000000)
points.user_id=this.user!.user_id
points.points=String(this.pointsProduct?.points)
points.points_type='0'
points.address='客户端下单奖励'
points.year=this.year
points.month=this.month
points.day=this.day
points.time=this.time
points.create_time=this.year+"-"+this.month+"-"+this.day+" "+this.time
let points_nums = await databaseZone.upsert(points);
到这里我们的订单提交逻辑就彻底完善了
00
- 0回答
- 0粉丝
- 0关注
相关话题
- 《仿盒马》app开发技术分享-- 兑换订单提交(73)
- 《仿盒马》app开发技术分享-- 购物车业务逻辑完善(34)
- 《仿盒马》app开发技术分享-- 个人中心&关于逻辑完善(36)
- 《仿盒马》app开发技术分享-- 回收订单页功能完善(45)
- 《仿盒马》app开发技术分享-- 确认订单页(业务逻辑)(30)
- 《仿盒马》app开发技术分享-- 兑换提交准备(72)
- 《仿盒马》app开发技术分享-- 订单地址修改(31)
- 《仿盒马》app开发技术分享--未完成订单列表展示逻辑优化(61)
- 《仿盒马》app开发技术分享-- 购物车功能完善(14)
- 《仿盒马》app开发技术分享-- 旧物回收页(提交云端)(42)
- 《仿盒马》app开发技术分享-- 订单列表页(33)
- 《仿盒马》app开发技术分享-- 订单详情页(32)
- 《仿盒马》app开发技术分享-- 用户登录页(业务逻辑)(21)
- 《仿盒马》app开发技术分享-- 购物车逻辑优化(39)
- 《仿盒马》app开发技术分享-- 旧物回收页(业务逻辑)(41)