'integer', 'coupon_dispense_id' => 'integer', 'user_id' => 'integer', 'total_count' => 'integer', 'receive_count' => 'integer']; const string CREATED_AT = 'create_time'; const string UPDATED_AT = 'update_time'; /** * @param int $dispenseId * @return int */ public function getNoSendCountByDispenseId(int $dispenseId): int { return $this ->where('dispense_id', $dispenseId) ->where('receive_count',0) ->count() ?? 0; } public function getNoSendUserListByDispenseId(int $dispenseId): array { return $this ->where('dispense_id', $dispenseId) ->where('receive_count',0) ->pluck('user_id') ->toArray(); } /** * @param array $userIds * @param int $count * @return int */ public function updateReceiveCountByUserIds(array $userIds,int $count): int { return $this ->whereIn('user_id', $userIds) ->update([ 'receive_count' => $count, 'is_receive' => CouponCode::DISPENSE_STATUS_IS_RECEIVED ]); } /** * @param array $userIds * @return array */ public function getNoReceiveCountByUserIds(array $userIds): array { return $this ->whereIn('user_id', $userIds) ->where('receive_count',CouponCode::DISPENSE_STATUS_IS_NO_RECEIVED) ->pluck('coupon_dispense_id') ->toArray(); } }