复制
收藏
提问
全网

$coupon['can_use_coupon_nums'] = $CouponMember->where([ ['member_id','eq',$member_id], ['is_used','eq','2'], ['efficient_start','<=',time()], ['efficient_end','>=',time()], ['status','eq',1] ])->count('id'); $coupon['expire_coupon_nums'] = $CouponMember->where([ ['member_id','eq',$member_id], ['is_used','eq','2'], ['efficient_end','<',time()], ])->count('id'); $coupon['use_coupon_nums'] = $CouponMember->where([['member_id','eq',$member_id], ['is_used','eq','1']])->count('id'); $coupon['draw_coupon_nums'] = $CouponMember->where([['member_id','eq',$member_id]])->count('id');是什么意思

7ecfcaea1
3个月前
全网
文档
学术
百科
知识库
时间不限
自动

理解问题$coupon['can_use_coupon_nums'] = $CouponMember->where([ ['member_id','eq',$member_id], ['is_used','eq','2'], ['efficient_start','<=',time()], ['efficient_end','>=',time()], ['status','eq',1] ])->count('id'); $coupon['expire_coupon_nums'] = $CouponMember->where([ ['member_id','eq',$member_id], ['is_used','eq','2'], ['efficient_end','<',time()], ])->count('id'); $coupon['use_coupon_nums'] = $CouponMember->where([['member_id','eq',$member_id], ['is_used','eq','1']])->count('id'); $coupon['draw_coupon_nums'] = $CouponMember->where([['member_id','eq',$member_id]])->count('id');是什么意思

已完成理解$coupon['can_use_coupon_nums'] = $CouponMember->where([ ['member_id','eq',$member_id], ['is_used','eq','2'], ['efficient_start','<=',time()], ['efficient_end','>=',time()], ['status','eq',1] ])->count('id'); $coupon['expire_coupon_nums'] = $CouponMember->where([ ['member_id','eq',$member_id], ['is_used','eq','2'], ['efficient_end','<',time()], ])->count('id'); $coupon['use_coupon_nums'] = $CouponMember->where([['member_id','eq',$member_id], ['is_used','eq','1']])->count('id'); $coupon['draw_coupon_nums'] = $CouponMember->where([['member_id','eq',$member_id]])->count('id');是什么意思

展开阅读网页

这段代码是用于统计用户优惠券状态的PHP脚本。

优惠券状态统计

  • 可使用优惠券数量:统计当前时间在有效期内、未使用(is_used为2)、状态为1的优惠券数量。
  • 已过期优惠券数量:统计已使用(is_used为2)且有效期结束时间小于当前时间的优惠券数量。
  • 已使用优惠券数量:统计已使用(is_used为1)的优惠券数量。
  • 总领取优惠券数量:统计用户总共领取的优惠券数量,不区分状态。

代码通过where方法设置查询条件,count('id')统计符合条件的记录数。678

更专业一些
转笔记
专业
$coupon['can_use_coupon_nums'] = $CouponMember->where([ ['member_id','eq',$member_id], ['is_used','eq','2'], ['efficient_start','<=',time()], ['efficient_end','>=',time()], ['status','eq',1] ])->count('id'); $coupon['expire_coupon_nums'] = $CouponMember->where([ ['member_id','eq',$member_id], ['is_used','eq','2'], ['efficient_end','<',time()], ])->count('id'); $coupon['use_coupon_nums'] = $CouponMember->where([['member_id','eq',$member_id], ['is_used','eq','1']])->count('id'); $coupon['draw_coupon_nums'] = $CouponMember->where([['member_id','eq',$member_id]])->count('id');是什么意思
不在提醒

更专业内容正在努力生成中
知识树
$coupon['can_use_coupon_nums'] = $CouponMember->where([ ['member_id','eq',$member_id], ['is_used','eq','2'], ['efficient_start','<=',time()], ['efficient_end','>=',time()], ['status','eq',1] ])->count('id'); $coupon['expire_coupon_nums'] = $CouponMember->where([ ['member_id','eq',$member_id], ['is_used','eq','2'], ['efficient_end','<',time()], ])->count('id'); $coupon['use_coupon_nums'] = $CouponMember->where([['member_id','eq',$member_id], ['is_used','eq','1']])->count('id'); $coupon['draw_coupon_nums'] = $CouponMember->where([['member_id','eq',$member_id]])->count('id');是什么意思
PHP中$coupon数组的作用是什么?
$CouponMember->where()方法的作用是什么?
PHP中time()函数的用途是什么?
在线客服