$memberId, 'site_id' => $this->site_id, 'cart_id' => implode(',',$cardIds), 'order_id' => 0, 'is_get' => 0, 'popularize_num' => $popularizeNum, 'create_time' => time() ]; $this->insert($data); } /** * Common: 处理领奖名额信息 * Author: wu-hui * Time: 2022/12/14 15:28 * @param $out_trade_no * @param $cardIdStr * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function handleInfo($out_trade_no,$cardIdStr){ // 获取信息 $orderInfo = Db::name('order') ->field('order_id,member_id') ->where('out_trade_no',$out_trade_no) ->find(); $popularizeNum = $this->where('cart_id',$cardIdStr)->value('popularize_num'); // 处理名额信息 $ids = (new MemberLevelPopularize())->availableQuotaIds($orderInfo['member_id'],$popularizeNum); (new MemberLevelPopularize())->whereIn('id',$ids)->update(['is_use' => 1]); $this->where('cart_id',$cardIdStr)->update(['is_get'=>1]); } /** * Common: 获取领奖次数 * Author: wu-hui * Time: 2022/12/14 20:46 * @param $memberId * @return int * @throws \think\db\exception\DbException */ public function isGetTotal($memberId){ return (int)$this->where('member_id',$memberId)->where('is_get',1)->count(); } }